@transferwise/components 46.48.0 → 46.50.0

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 (181) hide show
  1. package/build/actionOption/ActionOption.js +4 -2
  2. package/build/actionOption/ActionOption.js.map +1 -1
  3. package/build/actionOption/ActionOption.mjs +4 -2
  4. package/build/actionOption/ActionOption.mjs.map +1 -1
  5. package/build/avatar/Avatar.js +3 -1
  6. package/build/avatar/Avatar.js.map +1 -1
  7. package/build/avatar/Avatar.mjs +3 -1
  8. package/build/avatar/Avatar.mjs.map +1 -1
  9. package/build/avatarWrapper/AvatarWrapper.js +16 -4
  10. package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
  11. package/build/avatarWrapper/AvatarWrapper.mjs +16 -4
  12. package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
  13. package/build/badge/Badge.js +2 -0
  14. package/build/badge/Badge.js.map +1 -1
  15. package/build/badge/Badge.mjs +2 -0
  16. package/build/badge/Badge.mjs.map +1 -1
  17. package/build/card/Card.js.map +1 -1
  18. package/build/card/Card.mjs.map +1 -1
  19. package/build/common/bottomSheet/BottomSheet.js +3 -0
  20. package/build/common/bottomSheet/BottomSheet.js.map +1 -1
  21. package/build/common/bottomSheet/BottomSheet.mjs +4 -1
  22. package/build/common/bottomSheet/BottomSheet.mjs.map +1 -1
  23. package/build/common/panel/Panel.js +3 -0
  24. package/build/common/panel/Panel.js.map +1 -1
  25. package/build/common/panel/Panel.mjs +4 -1
  26. package/build/common/panel/Panel.mjs.map +1 -1
  27. package/build/dateLookup/DateLookup.js +21 -17
  28. package/build/dateLookup/DateLookup.js.map +1 -1
  29. package/build/dateLookup/DateLookup.mjs +21 -17
  30. package/build/dateLookup/DateLookup.mjs.map +1 -1
  31. package/build/dateLookup/dateTrigger/DateTrigger.js +6 -0
  32. package/build/dateLookup/dateTrigger/DateTrigger.js.map +1 -1
  33. package/build/dateLookup/dateTrigger/DateTrigger.mjs +6 -0
  34. package/build/dateLookup/dateTrigger/DateTrigger.mjs.map +1 -1
  35. package/build/drawer/Drawer.js +3 -0
  36. package/build/drawer/Drawer.js.map +1 -1
  37. package/build/drawer/Drawer.mjs +4 -1
  38. package/build/drawer/Drawer.mjs.map +1 -1
  39. package/build/i18n/de.json +2 -0
  40. package/build/i18n/de.json.js +2 -0
  41. package/build/i18n/de.json.js.map +1 -1
  42. package/build/i18n/de.json.mjs +2 -0
  43. package/build/i18n/de.json.mjs.map +1 -1
  44. package/build/i18n/es.json +2 -0
  45. package/build/i18n/es.json.js +2 -0
  46. package/build/i18n/es.json.js.map +1 -1
  47. package/build/i18n/es.json.mjs +2 -0
  48. package/build/i18n/es.json.mjs.map +1 -1
  49. package/build/i18n/fr.json +2 -0
  50. package/build/i18n/fr.json.js +2 -0
  51. package/build/i18n/fr.json.js.map +1 -1
  52. package/build/i18n/fr.json.mjs +2 -0
  53. package/build/i18n/fr.json.mjs.map +1 -1
  54. package/build/i18n/hu.json +2 -0
  55. package/build/i18n/hu.json.js +2 -0
  56. package/build/i18n/hu.json.js.map +1 -1
  57. package/build/i18n/hu.json.mjs +2 -0
  58. package/build/i18n/hu.json.mjs.map +1 -1
  59. package/build/i18n/id.json +2 -0
  60. package/build/i18n/id.json.js +2 -0
  61. package/build/i18n/id.json.js.map +1 -1
  62. package/build/i18n/id.json.mjs +2 -0
  63. package/build/i18n/id.json.mjs.map +1 -1
  64. package/build/i18n/it.json +2 -0
  65. package/build/i18n/it.json.js +2 -0
  66. package/build/i18n/it.json.js.map +1 -1
  67. package/build/i18n/it.json.mjs +2 -0
  68. package/build/i18n/it.json.mjs.map +1 -1
  69. package/build/i18n/ja.json +2 -0
  70. package/build/i18n/ja.json.js +2 -0
  71. package/build/i18n/ja.json.js.map +1 -1
  72. package/build/i18n/ja.json.mjs +2 -0
  73. package/build/i18n/ja.json.mjs.map +1 -1
  74. package/build/i18n/pl.json +2 -0
  75. package/build/i18n/pl.json.js +2 -0
  76. package/build/i18n/pl.json.js.map +1 -1
  77. package/build/i18n/pl.json.mjs +2 -0
  78. package/build/i18n/pl.json.mjs.map +1 -1
  79. package/build/i18n/ro.json +2 -0
  80. package/build/i18n/ro.json.js +2 -0
  81. package/build/i18n/ro.json.js.map +1 -1
  82. package/build/i18n/ro.json.mjs +2 -0
  83. package/build/i18n/ro.json.mjs.map +1 -1
  84. package/build/i18n/ru.json +2 -0
  85. package/build/i18n/ru.json.js +2 -0
  86. package/build/i18n/ru.json.js.map +1 -1
  87. package/build/i18n/ru.json.mjs +2 -0
  88. package/build/i18n/ru.json.mjs.map +1 -1
  89. package/build/i18n/th.json +2 -0
  90. package/build/i18n/th.json.js +2 -0
  91. package/build/i18n/th.json.js.map +1 -1
  92. package/build/i18n/th.json.mjs +2 -0
  93. package/build/i18n/th.json.mjs.map +1 -1
  94. package/build/i18n/tr.json +2 -0
  95. package/build/i18n/tr.json.js +2 -0
  96. package/build/i18n/tr.json.js.map +1 -1
  97. package/build/i18n/tr.json.mjs +2 -0
  98. package/build/i18n/tr.json.mjs.map +1 -1
  99. package/build/main.css +28 -20
  100. package/build/modal/Modal.js +3 -0
  101. package/build/modal/Modal.js.map +1 -1
  102. package/build/modal/Modal.mjs +4 -1
  103. package/build/modal/Modal.mjs.map +1 -1
  104. package/build/provider/overlay/OverlayIdProvider.js +20 -0
  105. package/build/provider/overlay/OverlayIdProvider.js.map +1 -0
  106. package/build/provider/overlay/OverlayIdProvider.mjs +17 -0
  107. package/build/provider/overlay/OverlayIdProvider.mjs.map +1 -0
  108. package/build/styles/main.css +28 -20
  109. package/build/styles/uploadInput/uploadButton/UploadButton.css +5 -0
  110. package/build/styles/uploadInput/uploadItem/UploadItem.css +23 -20
  111. package/build/types/actionOption/ActionOption.d.ts +2 -1
  112. package/build/types/actionOption/ActionOption.d.ts.map +1 -1
  113. package/build/types/avatar/Avatar.d.ts +1 -0
  114. package/build/types/avatar/Avatar.d.ts.map +1 -1
  115. package/build/types/avatarWrapper/AvatarWrapper.d.ts +2 -1
  116. package/build/types/avatarWrapper/AvatarWrapper.d.ts.map +1 -1
  117. package/build/types/badge/Badge.d.ts +2 -1
  118. package/build/types/badge/Badge.d.ts.map +1 -1
  119. package/build/types/card/Card.d.ts +4 -0
  120. package/build/types/card/Card.d.ts.map +1 -1
  121. package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
  122. package/build/types/common/panel/Panel.d.ts.map +1 -1
  123. package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
  124. package/build/types/dateLookup/dateTrigger/DateTrigger.d.ts.map +1 -1
  125. package/build/types/drawer/Drawer.d.ts.map +1 -1
  126. package/build/types/modal/Modal.d.ts.map +1 -1
  127. package/build/types/provider/overlay/OverlayIdProvider.d.ts +7 -0
  128. package/build/types/provider/overlay/OverlayIdProvider.d.ts.map +1 -0
  129. package/build/types/uploadInput/uploadItem/UploadItem.d.ts.map +1 -1
  130. package/build/types/uploadInput/uploadItem/{UploadItemBody.d.ts → UploadItemLink.d.ts} +2 -2
  131. package/build/types/uploadInput/uploadItem/UploadItemLink.d.ts.map +1 -0
  132. package/build/uploadInput/uploadItem/UploadItem.js +14 -11
  133. package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
  134. package/build/uploadInput/uploadItem/UploadItem.mjs +15 -12
  135. package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
  136. package/build/uploadInput/uploadItem/UploadItemLink.js +32 -0
  137. package/build/uploadInput/uploadItem/UploadItemLink.js.map +1 -0
  138. package/build/uploadInput/uploadItem/{UploadItemBody.mjs → UploadItemLink.mjs} +5 -4
  139. package/build/uploadInput/uploadItem/UploadItemLink.mjs.map +1 -0
  140. package/package.json +19 -19
  141. package/src/actionOption/ActionOption.tsx +3 -0
  142. package/src/avatar/Avatar.spec.tsx +10 -0
  143. package/src/avatar/Avatar.tsx +3 -0
  144. package/src/avatarWrapper/AvatarWrapper.spec.tsx +15 -4
  145. package/src/avatarWrapper/AvatarWrapper.story.tsx +2 -0
  146. package/src/avatarWrapper/AvatarWrapper.tsx +26 -7
  147. package/src/avatarWrapper/__snapshots__/AvatarWrapper.spec.tsx.snap +0 -64
  148. package/src/badge/Badge.spec.tsx +8 -0
  149. package/src/badge/Badge.tsx +3 -1
  150. package/src/card/Card.tsx +4 -0
  151. package/src/common/bottomSheet/BottomSheet.tsx +12 -1
  152. package/src/common/panel/Panel.tsx +5 -0
  153. package/src/dateLookup/DateLookup.tsx +22 -19
  154. package/src/dateLookup/dateTrigger/DateTrigger.spec.js +1 -0
  155. package/src/dateLookup/dateTrigger/DateTrigger.tsx +7 -0
  156. package/src/drawer/Drawer.tsx +5 -1
  157. package/src/i18n/de.json +2 -0
  158. package/src/i18n/es.json +2 -0
  159. package/src/i18n/fr.json +2 -0
  160. package/src/i18n/hu.json +2 -0
  161. package/src/i18n/id.json +2 -0
  162. package/src/i18n/it.json +2 -0
  163. package/src/i18n/ja.json +2 -0
  164. package/src/i18n/pl.json +2 -0
  165. package/src/i18n/ro.json +2 -0
  166. package/src/i18n/ru.json +2 -0
  167. package/src/i18n/th.json +2 -0
  168. package/src/i18n/tr.json +2 -0
  169. package/src/main.css +28 -20
  170. package/src/modal/Modal.tsx +5 -1
  171. package/src/provider/overlay/OverlayIdProvider.tsx +15 -0
  172. package/src/uploadInput/uploadButton/UploadButton.css +5 -0
  173. package/src/uploadInput/uploadButton/UploadButton.less +6 -0
  174. package/src/uploadInput/uploadItem/UploadItem.css +23 -20
  175. package/src/uploadInput/uploadItem/UploadItem.less +16 -12
  176. package/src/uploadInput/uploadItem/UploadItem.tsx +12 -7
  177. package/src/uploadInput/uploadItem/{UploadItemBody.tsx → UploadItemLink.tsx} +6 -2
  178. package/build/types/uploadInput/uploadItem/UploadItemBody.d.ts.map +0 -1
  179. package/build/uploadInput/uploadItem/UploadItemBody.js +0 -27
  180. package/build/uploadInput/uploadItem/UploadItemBody.js.map +0 -1
  181. package/build/uploadInput/uploadItem/UploadItemBody.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheet.js","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useRef, useState, PropsWithChildren, CSSProperties, SyntheticEvent } from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\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>;\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 = (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 return is400Zoom ? (\n <Drawer open={props.open} className={props.className} onClose={close}>\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={classNames('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n role=\"dialog\"\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","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","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","classNames","_jsxs","role","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;AAcA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAShC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAIC,KAAuB,IAAI;AAC9C,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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mBAAmB,EAAG;AAC7Bc,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC3D,KAAK,CAAC2D,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 classNames from 'classnames';\nimport {\n CSSProperties,\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>;\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 = (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 open={props.open} className={props.className} onClose={close}>\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={classNames('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n role=\"dialog\"\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","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","classNames","_jsxs","id","role","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAShC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAIC,KAAuB,IAAI;AAC9C,EAAA,MAAMC,oBAAoB,GAAGC,YAAM,CAAiB,IAAI,CAAC,CAAA;AACzD,EAAA,MA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AAEhE,eAAgB;AAAC0D,UAAAA,SAAS,EAAC,0BAA0B;AAAAC,UAAAA,QAAA,gBAC7DH,cAAA,CAAA,KAAA,EAAA;AAAKE,YAAAA,SAAS,EAAC,0BAAA;AAA0B,WACzC,CAAA,eAAAF,cAAA,CAACsB,uBAAW,EAAA;AAACC,YAAAA,IAAI,EAAC,IAAI;AAACrB,YAAAA,SAAS,EAAC,oCAAoC;AAACsB,YAAAA,OAAO,EAAEtD,KAAAA;AAAM,WACvF,CAAA,CAAA;SAAK,CACL,eAAA8B,cAAA,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;;;;"}
@@ -1,7 +1,8 @@
1
1
  import classNames from 'classnames';
2
- import { useRef, useState } from 'react';
2
+ import { useRef, useState, useContext } from 'react';
3
3
  import Dimmer from '../../dimmer/Dimmer.mjs';
4
4
  import Drawer from '../../drawer/Drawer.mjs';
5
+ import { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider.mjs';
5
6
  import SlidingPanel from '../../slidingPanel/SlidingPanel.mjs';
6
7
  import { CloseButton } from '../closeButton/CloseButton.mjs';
7
8
  import { isServerSide } from '../domHelpers/documentIosClick.mjs';
@@ -139,6 +140,7 @@ const BottomSheet = props => {
139
140
  };
140
141
  }
141
142
  const is400Zoom = useMedia(`(max-width: ${Breakpoint.ZOOM_400}px)`);
143
+ const overlayId = useContext(OverlayIdContext);
142
144
  return is400Zoom ? /*#__PURE__*/jsx(Drawer, {
143
145
  open: props.open,
144
146
  className: props.className,
@@ -155,6 +157,7 @@ const BottomSheet = props => {
155
157
  position: Position.BOTTOM,
156
158
  className: classNames('np-bottom-sheet', props.className),
157
159
  children: /*#__PURE__*/jsxs("div", {
160
+ id: overlayId,
158
161
  role: "dialog",
159
162
  "aria-modal": true,
160
163
  onTouchStart: onSwipeStart,
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheet.mjs","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { useRef, useState, PropsWithChildren, CSSProperties, SyntheticEvent } from 'react';\n\nimport Dimmer from '../../dimmer';\nimport Drawer from '../../drawer';\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>;\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 = (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 return is400Zoom ? (\n <Drawer open={props.open} className={props.className} onClose={close}>\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={classNames('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n role=\"dialog\"\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","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","_jsx","Drawer","className","children","Dimmer","fadeContentOnEnter","fadeContentOnExit","SlidingPanel","ref","position","Position","BOTTOM","classNames","_jsxs","role","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;AAcA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAShC;;;;;AAKG;AACGC,MAAAA,WAAW,GAAIC,KAAuB,IAAI;AAC9C,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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AAA,CAAA;SAAK,CACL,eAAA2B,GAAA,CAAA,KAAA,EAAA;AACEQ,UAAAA,GAAG,EAAE5D,gBAAiB;UACtBuB,KAAK,EAAEiB,mBAAmB,EAAG;AAC7Bc,UAAAA,SAAS,EAAC,0BAA0B;UAAAC,QAAA,EAEnC3D,KAAK,CAAC2D,QAAAA;AAAQ,SACZ,CACP,CAAA;OAAK,CAAA;KACO,CAAA;AAChB,GAAQ,CACT,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"BottomSheet.mjs","sources":["../../../src/common/bottomSheet/BottomSheet.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport {\n CSSProperties,\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>;\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 = (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 open={props.open} className={props.className} onClose={close}>\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={classNames('np-bottom-sheet', props.className)}\n >\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */}\n <div\n id={overlayId}\n role=\"dialog\"\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","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","classNames","_jsxs","id","role","onTouchStart","onTouchMove","onTouchEnd","onMouseDown","onMouseMove","onMouseUp","CloseButton","size","onClick"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAMA,kBAAkB,GAAG,CAAC,CAAA;AAE5B,MAAMC,wBAAwB,GAAG,CAAC,CAAA;AAElC,MAAMC,qBAAqB,GAAG,EAAE,CAAA;AAShC;;;;;AAKG;AACGC,MAAAA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A,SAAS,EAAExC,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,CAACsB,WAAW,EAAA;AAACC,YAAAA,IAAI,EAAC,IAAI;AAACrB,YAAAA,SAAS,EAAC,oCAAoC;AAACsB,YAAAA,OAAO,EAAEtD,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;;;;"}
@@ -4,6 +4,7 @@ var classNames = require('classnames');
4
4
  var React = require('react');
5
5
  var reactPopper = require('react-popper');
6
6
  var Dimmer = require('../../dimmer/Dimmer.js');
7
+ var OverlayIdProvider = require('../../provider/overlay/OverlayIdProvider.js');
7
8
  var jsxRuntime = require('react/jsx-runtime');
8
9
  var position = require('../propsValues/position.js');
9
10
 
@@ -92,6 +93,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
92
93
  width: anchorRef.current?.clientWidth
93
94
  } : undefined)
94
95
  };
96
+ const overlayId = React.useContext(OverlayIdProvider.OverlayIdContext);
95
97
  return /*#__PURE__*/jsxRuntime.jsx(Dimmer.default, {
96
98
  open: open,
97
99
  transparent: true,
@@ -99,6 +101,7 @@ const Panel = /*#__PURE__*/React.forwardRef(function Panel({
99
101
  fadeContentOnExit: true,
100
102
  onClose: onClose,
101
103
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
104
+ id: overlayId,
102
105
  ...rest,
103
106
  ref: setPopperElement,
104
107
  role: "dialog"
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={classnames('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={classnames('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={classnames('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","ref","role","style","popper","className","classnames","_jsxs"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,iBAAQ,CAACC,GAAG,GAAG,CAACD,iBAAQ,CAACE,MAAM,EAAEF,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACE,MAAM,GAAG,CAACF,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACI,IAAI,GAAG,CAACJ,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,iBAAQ,CAACG,KAAK,GAAG,CAACH,iBAAQ,CAACI,IAAI,EAAEJ,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,gBAAU,CAA6B,SAASD,KAAKA,CACjE;AACEE,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;AACXC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;AACRC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;YACPC,UAAQ,GAAGb,iBAAQ,CAACE,MAAM;EAC1BY,SAAS;AACTC,EAAAA,WAAW,GAAG,KAAK;EACnB,GAAGC,IAAAA;AAAI,CACI,EACbC,SAAS,EAAA;EAET,MAAM,CAACC,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,QAAQ,EAERH,KAAK,iBACJmC,cAAA,CAAA,KAAA,EAAA;AACEK,UAAAA,GAAG,EAAE5B,eAAgB;UACrBgC,SAAS,EAAEC,2BAAU,CAAC,iBAAiB,CAAA;AACvC;AAAA;UACAH,KAAK,EAAElB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
1
+ {"version":3,"file":"Panel.js","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={classnames('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={classnames('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={classnames('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","classnames","_jsxs"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,iBAAQ,CAACC,GAAG,GAAG,CAACD,iBAAQ,CAACE,MAAM,EAAEF,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACE,MAAM,GAAG,CAACF,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,iBAAQ,CAACI,IAAI,GAAG,CAACJ,iBAAQ,CAACG,KAAK,EAAEH,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,iBAAQ,CAACG,KAAK,GAAG,CAACH,iBAAQ,CAACI,IAAI,EAAEJ,iBAAQ,CAACC,GAAG,EAAED,iBAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,gBAAU,CAA6B,SAASD,KAAKA,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CAACuB,MAAAA;OAAS;MAAA,GACxBtB,UAAU,CAACsB,MAAM;AACrBC,MAAAA,SAAS,EAAEC,2BAAU,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAE9E+C,eAAA,CAAA,KAAA,EAAA;AACEN,QAAAA,GAAG,EAAElC,SAAAA;AACL;AACAoC,QAAAA,KAAK,EAAEf,YAAa;AACpBiB,QAAAA,SAAS,EAAEC,2BAAU,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAE1CA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,cAAA,CAAA,KAAA,EAAA;AACEM,UAAAA,GAAG,EAAEhC,eAAgB;UACrBoC,SAAS,EAAEC,2BAAU,CAAC,iBAAiB,CAAA;AACvC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
@@ -1,7 +1,8 @@
1
1
  import classNames from 'classnames';
2
- import { forwardRef, useState, useEffect } from 'react';
2
+ import { forwardRef, useState, useEffect, useContext } from 'react';
3
3
  import { usePopper } from 'react-popper';
4
4
  import Dimmer from '../../dimmer/Dimmer.mjs';
5
+ import { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider.mjs';
5
6
  import { jsx, jsxs } from 'react/jsx-runtime';
6
7
  import { Position } from '../propsValues/position.mjs';
7
8
 
@@ -86,6 +87,7 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
86
87
  width: anchorRef.current?.clientWidth
87
88
  } : undefined)
88
89
  };
90
+ const overlayId = useContext(OverlayIdContext);
89
91
  return /*#__PURE__*/jsx(Dimmer, {
90
92
  open: open,
91
93
  transparent: true,
@@ -93,6 +95,7 @@ const Panel = /*#__PURE__*/forwardRef(function Panel({
93
95
  fadeContentOnExit: true,
94
96
  onClose: onClose,
95
97
  children: /*#__PURE__*/jsx("div", {
98
+ id: overlayId,
96
99
  ...rest,
97
100
  ref: setPopperElement,
98
101
  role: "dialog"
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={classnames('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={classnames('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={classnames('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","ref","role","style","popper","className","classnames","_jsxs"],"mappings":";;;;;;;AAgBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,QAAQ,CAACG,KAAK,GAAG,CAACH,QAAQ,CAACI,IAAI,EAAEJ,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,UAAU,CAA6B,SAASD,KAAKA,CACjE;AACEE,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,IAAI,GAAG,IAAI;AACXC,EAAAA,OAAO,GAAG,KAAK;EACfC,QAAQ;AACRC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ,GAAGb,QAAQ,CAACE,MAAM;EAC1BY,SAAS;AACTC,EAAAA,WAAW,GAAG,KAAK;EACnB,GAAGC,IAAAA;AAAI,CACI,EACbC,SAAS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QAAA,EAE1CA,CAAAA,QAAQ,EAERH,KAAK,iBACJmC,GAAA,CAAA,KAAA,EAAA;AACEK,UAAAA,GAAG,EAAE5B,eAAgB;UACrBgC,SAAS,EAAEC,UAAU,CAAC,iBAAiB,CAAA;AACvC;AAAA;UACAH,KAAK,EAAElB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
1
+ {"version":3,"file":"Panel.mjs","sources":["../../../src/common/panel/Panel.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport {\n CSSProperties,\n HTMLAttributes,\n MutableRefObject,\n PropsWithChildren,\n SyntheticEvent,\n forwardRef,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { usePopper } from 'react-popper';\n\nimport { Position, PositionBottom, PositionLeft, PositionRight, PositionTop } from '..';\nimport Dimmer from '../../dimmer';\nimport { OverlayIdContext } from '../../provider/overlay/OverlayIdProvider';\n\nconst POPOVER_OFFSET = [0, 16];\n\n// By default the flip positioning explores only the opposite alternative. So if left is passed and there's no enough space\n// the right one gets chosen. If there's no space on both sides popover goes back to the initially chosen one left.\n// This mapping forces popover to try the four available positions before going back to the initial chosen one.\nconst fallbackPlacements = {\n [Position.TOP]: [Position.BOTTOM, Position.RIGHT, Position.LEFT],\n [Position.BOTTOM]: [Position.TOP, Position.RIGHT, Position.LEFT],\n [Position.LEFT]: [Position.RIGHT, Position.TOP, Position.BOTTOM],\n [Position.RIGHT]: [Position.LEFT, Position.TOP, Position.BOTTOM],\n};\n\nexport type PanelProps = PropsWithChildren<{\n arrow?: boolean;\n flip?: boolean;\n altAxis?: boolean;\n open?: boolean;\n onClose?: (event: Event | SyntheticEvent) => void;\n position?: PositionBottom | PositionLeft | PositionRight | PositionTop;\n anchorRef: MutableRefObject<Element | null>;\n anchorWidth?: boolean;\n}> &\n HTMLAttributes<HTMLDivElement>;\n\nconst Panel = forwardRef<HTMLDivElement, PanelProps>(function Panel(\n {\n arrow = false,\n flip = true,\n altAxis = false,\n children,\n open = false,\n onClose,\n position = Position.BOTTOM,\n anchorRef,\n anchorWidth = false,\n ...rest\n }: PanelProps,\n reference,\n) {\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);\n\n const modifiers = [];\n\n if (altAxis) {\n modifiers.push({\n // https://popper.js.org/docs/v2/modifiers/prevent-overflow\n name: 'preventOverflow',\n options: {\n altAxis: true,\n tether: false,\n },\n });\n }\n\n if (arrow) {\n modifiers.push({\n name: 'arrow',\n options: {\n element: arrowElement,\n options: {\n padding: 8, // 8px from the edges of the popper\n },\n },\n });\n // This lets you displace a popper element from its reference element.\n modifiers.push({ name: 'offset', options: { offset: POPOVER_OFFSET } });\n }\n if (flip && fallbackPlacements[position]) {\n modifiers.push({\n name: 'flip',\n options: {\n fallbackPlacements: fallbackPlacements[position],\n },\n });\n }\n\n const { styles, attributes, forceUpdate } = usePopper(anchorRef.current, popperElement, {\n placement: position,\n modifiers,\n });\n\n // If the trigger is not visible when the position is calculated, it will be incorrect. Because this can happen repeatedly (on resize for example),\n // it is most simple just to always position before opening\n useEffect(() => {\n if (open && forceUpdate) {\n forceUpdate();\n }\n }, [open]);\n\n const contentStyle: CSSProperties = {\n ...(anchorWidth ? { width: anchorRef.current?.clientWidth } : undefined),\n };\n\n const overlayId = useContext(OverlayIdContext);\n\n return (\n <Dimmer open={open} transparent fadeContentOnEnter fadeContentOnExit onClose={onClose}>\n <div\n id={overlayId}\n {...rest}\n ref={setPopperElement}\n role=\"dialog\"\n // eslint-disable-next-line react/forbid-dom-props\n style={{ ...styles.popper }}\n {...attributes.popper}\n className={classnames('np-panel', { 'np-panel--open': open }, rest.className)}\n >\n <div\n ref={reference}\n /* eslint-disable-next-line react/forbid-dom-props */\n style={contentStyle}\n className={classnames('np-panel__content')}\n >\n {children}\n {/* Arrow has to stay inside content to get the same animations as the \"dialog\" and to get hidden when panel is closed. */}\n {arrow && (\n <div\n ref={setArrowElement}\n className={classnames('np-panel__arrow')}\n // eslint-disable-next-line react/forbid-dom-props\n style={styles.arrow}\n />\n )}\n </div>\n </div>\n </Dimmer>\n );\n});\n\nexport default Panel;\n"],"names":["POPOVER_OFFSET","fallbackPlacements","Position","TOP","BOTTOM","RIGHT","LEFT","Panel","forwardRef","arrow","flip","altAxis","children","open","onClose","position","anchorRef","anchorWidth","rest","reference","arrowElement","setArrowElement","useState","popperElement","setPopperElement","modifiers","push","name","options","tether","element","padding","offset","styles","attributes","forceUpdate","usePopper","current","placement","useEffect","contentStyle","width","clientWidth","undefined","overlayId","useContext","OverlayIdContext","_jsx","Dimmer","transparent","fadeContentOnEnter","fadeContentOnExit","id","ref","role","style","popper","className","classnames","_jsxs"],"mappings":";;;;;;;;AAkBA,MAAMA,cAAc,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE9B;AACA;AACA;AACA,MAAMC,kBAAkB,GAAG;AACzB,EAAA,CAACC,QAAQ,CAACC,GAAG,GAAG,CAACD,QAAQ,CAACE,MAAM,EAAEF,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACE,MAAM,GAAG,CAACF,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACI,IAAI,CAAC;AAChE,EAAA,CAACJ,QAAQ,CAACI,IAAI,GAAG,CAACJ,QAAQ,CAACG,KAAK,EAAEH,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAC;AAChE,EAAA,CAACF,QAAQ,CAACG,KAAK,GAAG,CAACH,QAAQ,CAACI,IAAI,EAAEJ,QAAQ,CAACC,GAAG,EAAED,QAAQ,CAACE,MAAM,CAAA;CAChE,CAAA;AAcD,MAAMG,KAAK,gBAAGC,UAAU,CAA6B,SAASD,KAAKA,CACjE;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AAA;OAAS;MAAA,GACxBtB,UAAU,CAACsB,MAAM;AACrBC,MAAAA,SAAS,EAAEC,UAAU,CAAC,UAAU,EAAE;AAAE,QAAA,gBAAgB,EAAE7C,IAAAA;AAAI,OAAE,EAAEK,IAAI,CAACuC,SAAS,CAAE;AAAA7C,MAAAA,QAAA,eAE9E+C,IAAA,CAAA,KAAA,EAAA;AACEN,QAAAA,GAAG,EAAElC,SAAAA;AACL;AACAoC,QAAAA,KAAK,EAAEf,YAAa;AACpBiB,QAAAA,SAAS,EAAEC,UAAU,CAAC,mBAAmB,CAAE;AAAA9C,QAAAA,QAAA,EAE1CA,CAAAA,QAAQ,EAERH,KAAK,iBACJsC,GAAA,CAAA,KAAA,EAAA;AACEM,UAAAA,GAAG,EAAEhC,eAAgB;UACrBoC,SAAS,EAAEC,UAAU,CAAC,iBAAiB,CAAA;AACvC;AAAA;UACAH,KAAK,EAAEtB,MAAM,CAACxB,KAAAA;AAAM,SAAA,CAEvB,CAAA;OACE,CAAA;KACF,CAAA;AACP,GAAQ,CAAC,CAAA;AAEb,CAAC,CAAC,CAAA;AAEF,cAAeF,KAAK;;;;"}
@@ -6,6 +6,7 @@ require('@transferwise/formatting');
6
6
  var moveToWithinRange = require('../common/dateUtils/moveToWithinRange/moveToWithinRange.js');
7
7
  var isWithinRange = require('../common/dateUtils/isWithinRange/isWithinRange.js');
8
8
  var contexts = require('../inputs/contexts.js');
9
+ var OverlayIdProvider = require('../provider/overlay/OverlayIdProvider.js');
9
10
  var DateTrigger = require('./dateTrigger/DateTrigger.js');
10
11
  var DayCalendar = require('./dayCalendar/DayCalendar.js');
11
12
  var getStartOfDay = require('./getStartOfDay/getStartOfDay.js');
@@ -304,30 +305,33 @@ class DateLookup extends React.PureComponent {
304
305
  } = this.props;
305
306
  const id = idProp ?? inputAttributes?.id;
306
307
  const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
307
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
308
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
308
309
  ref: this.element,
309
310
  ...inputAttributes,
310
311
  id: id,
311
312
  "aria-labelledby": ariaLabelledBy,
312
313
  className: "input-group",
313
314
  onKeyDown: this.handleKeyDown,
314
- children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger, {
315
- selectedDate: selectedDate,
316
- size: size,
317
- placeholder: placeholder,
318
- label: label,
319
- monthFormat: monthFormat,
320
- disabled: disabled || false,
321
- onClick: this.open,
322
- onClear: !disabled && clearable && value ? this.handleClear : undefined
323
- }), /*#__PURE__*/jsxRuntime.jsx(ResponsivePanel, {
324
- anchorRef: this.element,
315
+ children: /*#__PURE__*/jsxRuntime.jsxs(OverlayIdProvider.OverlayIdProvider, {
325
316
  open: open,
326
- className: "tw-date-lookup-menu",
327
- position: position.Position.BOTTOM,
328
- onClose: this.discard,
329
- children: this.getCalendar()
330
- })]
317
+ children: [/*#__PURE__*/jsxRuntime.jsx(DateTrigger, {
318
+ selectedDate: selectedDate,
319
+ size: size,
320
+ placeholder: placeholder,
321
+ label: label,
322
+ monthFormat: monthFormat,
323
+ disabled: disabled || false,
324
+ onClick: this.open,
325
+ onClear: !disabled && clearable && value ? this.handleClear : undefined
326
+ }), /*#__PURE__*/jsxRuntime.jsx(ResponsivePanel, {
327
+ anchorRef: this.element,
328
+ open: open,
329
+ className: "tw-date-lookup-menu",
330
+ position: position.Position.BOTTOM,
331
+ onClose: this.discard,
332
+ children: this.getCalendar()
333
+ })]
334
+ })
331
335
  });
332
336
  }
333
337
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DateLookup.js","sources":["../../src/dateLookup/DateLookup.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, PureComponent, KeyboardEvent } from 'react';\n\nimport {\n Size,\n MonthFormat,\n Position,\n Breakpoint,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport { isWithinRange, moveToWithinRange } from '../common/dateUtils';\nimport ResponsivePanel from '../common/responsivePanel';\nimport { WithInputAttributesProps, withInputAttributes } from '../inputs/contexts';\nimport DateTrigger from './dateTrigger';\nimport DayCalendar from './dayCalendar';\nimport { getStartOfDay } from './getStartOfDay';\nimport MonthCalendar from './monthCalendar';\nimport YearCalendar from './yearCalendar';\n\nexport interface DateLookupProps {\n id?: string;\n value: Date | null;\n min?: Date | null;\n max?: Date | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n placeholder?: string;\n label?: string;\n 'aria-labelledby'?: string;\n monthFormat?: `${MonthFormat}`;\n disabled?: boolean;\n clearable?: boolean;\n onChange: (date: Date | null) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n}\n\ntype DateLookupPropsWithInputAttributes = DateLookupProps & Partial<WithInputAttributesProps>;\n\ninterface DateLookupState {\n selectedDate: Date | null;\n originalDate: Date | null;\n min: Date | null;\n max: Date | null;\n viewMonth: number;\n viewYear: number;\n open: boolean;\n mode: 'day' | 'month' | 'year';\n isMobile: boolean;\n}\n\nclass DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateLookupState> {\n declare props: DateLookupPropsWithInputAttributes &\n Required<Pick<DateLookupPropsWithInputAttributes, keyof typeof DateLookup.defaultProps>>;\n\n static defaultProps = {\n value: null,\n min: null,\n max: null,\n size: Size.MEDIUM,\n placeholder: '',\n label: '',\n monthFormat: MonthFormat.LONG,\n disabled: false,\n clearable: false,\n } satisfies Partial<DateLookupPropsWithInputAttributes>;\n\n element = createRef<HTMLDivElement>();\n dropdown = createRef<HTMLDivElement>();\n\n constructor(props: DateLookup['props']) {\n super(props);\n this.state = {\n selectedDate: getStartOfDay(props.value),\n originalDate: null,\n min: getStartOfDay(props.min),\n max: getStartOfDay(props.max),\n viewMonth: (props.value || new Date()).getMonth(),\n viewYear: (props.value || new Date()).getFullYear(),\n open: false,\n mode: 'day',\n isMobile: false,\n };\n }\n\n static getDerivedStateFromProps(props: DateLookup['props'], state: DateLookupState) {\n const propsSelected = getStartOfDay(props.value);\n const propsMin = getStartOfDay(props.min);\n const propsMax = getStartOfDay(props.max);\n const hasSelectedChanged = state.selectedDate?.getTime() !== propsSelected?.getTime();\n const hasMinChanged = state.min?.getTime() !== propsMin?.getTime();\n const hasMaxChanged = state.max?.getTime() !== propsMax?.getTime();\n if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {\n const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;\n const min = hasMinChanged ? propsMin : state.min;\n const max = hasMaxChanged ? propsMax : state.max;\n if (selectedDate && !isWithinRange(selectedDate, min, max)) {\n props.onChange(moveToWithinRange(selectedDate, min, max));\n return null;\n }\n const viewDateThatIsWithinRange: Date =\n selectedDate || ((min || max) && moveToWithinRange(new Date(), min, max)) || new Date();\n const viewMonth = viewDateThatIsWithinRange.getMonth();\n const viewYear = viewDateThatIsWithinRange.getFullYear();\n return { selectedDate, min, max, viewMonth, viewYear };\n }\n return null;\n }\n\n componentDidUpdate(previousProps: DateLookupPropsWithInputAttributes) {\n if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {\n this.focusOn('.active');\n }\n const mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);\n this.setState({ isMobile: mediaQuery.matches });\n }\n\n componentWillUnmount() {\n // Prevents memory leak by cleaning state.\n this.setState = () => {};\n }\n\n open = () => {\n const { onFocus } = this.props;\n\n this.setState({ open: true, mode: 'day' });\n if (onFocus) {\n onFocus();\n }\n };\n\n discard = () => {\n const { originalDate } = this.state;\n if (originalDate !== null) {\n this.props.onChange(originalDate);\n }\n this.close();\n };\n\n close = () => {\n const { onBlur } = this.props;\n this.setState({ open: false, originalDate: null });\n if (onBlur) {\n onBlur();\n }\n };\n\n handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const { open, originalDate } = this.state;\n switch (event.key) {\n case 'ArrowLeft':\n if (open) {\n this.adjustDate(-1, -1, -1);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowUp':\n if (open) {\n this.adjustDate(-7, -4, -4);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowRight':\n if (open) {\n this.adjustDate(1, 1, 1);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowDown':\n if (open) {\n this.adjustDate(7, 4, 4);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'Escape':\n if (originalDate !== null) {\n this.props.onChange(originalDate);\n }\n this.close();\n event.preventDefault();\n break;\n default:\n break;\n }\n };\n\n adjustDate = (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {\n const { selectedDate, min, max, mode, originalDate } = this.state;\n if (originalDate === null) {\n this.setState({ originalDate: selectedDate });\n }\n let date: Date | null;\n if (selectedDate) {\n date = new Date(\n mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),\n mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(),\n mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate(),\n );\n } else {\n date = getStartOfDay(new Date());\n }\n if (date) {\n date = moveToWithinRange(date, min, max);\n }\n if (date?.getTime() !== selectedDate?.getTime()) {\n this.props.onChange(date);\n }\n };\n\n focusOn = (preferredElement: string, fallbackElement?: string) => {\n const element = this.element.current?.querySelector(preferredElement) as HTMLElement | null;\n if (element) {\n element.focus();\n } else if (fallbackElement) {\n this.focusOn(fallbackElement);\n }\n };\n\n switchMode = (mode: 'day' | 'month' | 'year') => {\n this.setState({ mode }, () => {\n this.focusOn('.active', '.today');\n });\n };\n\n switchToDays = () => this.switchMode('day');\n\n switchToMonths = () => this.switchMode('month');\n\n switchToYears = () => this.switchMode('year');\n\n handleSelectedDateUpdate = (selectedDate: Date) => {\n this.setState({ selectedDate }, () => {\n this.props.onChange(selectedDate);\n this.close();\n this.focusOn('.btn');\n });\n };\n\n handleViewDateUpdate = ({ month = this.state.viewMonth, year = this.state.viewYear }) => {\n this.setState({ viewMonth: month, viewYear: year });\n };\n\n getCalendar = () => {\n const { selectedDate, min, max, viewMonth, viewYear, mode, isMobile } = this.state;\n const { placeholder, monthFormat } = this.props;\n return (\n <div className={classNames({ 'p-a-1': !isMobile })}>\n {mode === 'day' && (\n <DayCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewMonth={viewMonth}\n viewYear={viewYear}\n monthFormat={monthFormat}\n onSelect={this.handleSelectedDateUpdate}\n onLabelClick={this.switchToYears}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n {mode === 'month' && (\n <MonthCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n placeholder={placeholder}\n onSelect={this.switchToDays}\n onLabelClick={this.switchToYears}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n {mode === 'year' && (\n <YearCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n placeholder={placeholder}\n onSelect={this.switchToMonths}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n </div>\n );\n };\n\n handleClear = () => {\n this.props.onChange(null);\n this.focusOn('.np-date-trigger');\n };\n\n render() {\n const { selectedDate, open } = this.state;\n\n const {\n inputAttributes,\n id: idProp,\n 'aria-labelledby': ariaLabelledByProp,\n size,\n placeholder,\n label,\n monthFormat,\n disabled,\n clearable,\n value,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n\n return (\n <div\n ref={this.element}\n {...inputAttributes}\n id={id}\n aria-labelledby={ariaLabelledBy}\n className=\"input-group\"\n onKeyDown={this.handleKeyDown}\n >\n <DateTrigger\n selectedDate={selectedDate}\n size={size}\n placeholder={placeholder}\n label={label}\n monthFormat={monthFormat}\n disabled={disabled || false}\n onClick={this.open}\n onClear={!disabled && clearable && value ? this.handleClear : undefined}\n />\n <ResponsivePanel\n anchorRef={this.element}\n open={open}\n className=\"tw-date-lookup-menu\"\n position={Position.BOTTOM}\n onClose={this.discard}\n >\n {this.getCalendar()}\n </ResponsivePanel>\n </div>\n );\n }\n}\n\nexport const DateLookupWithoutInputAttributes = DateLookup;\n\nexport default withInputAttributes(\n DateLookup as React.ComponentType<DateLookupPropsWithInputAttributes>,\n { nonLabelable: true },\n);\n"],"names":["DateLookup","PureComponent","defaultProps","value","min","max","size","Size","MEDIUM","placeholder","label","monthFormat","MonthFormat","LONG","disabled","clearable","element","createRef","dropdown","constructor","props","state","selectedDate","getStartOfDay","originalDate","viewMonth","Date","getMonth","viewYear","getFullYear","open","mode","isMobile","getDerivedStateFromProps","propsSelected","propsMin","propsMax","hasSelectedChanged","getTime","hasMinChanged","hasMaxChanged","isWithinRange","onChange","moveToWithinRange","viewDateThatIsWithinRange","componentDidUpdate","previousProps","focusOn","mediaQuery","window","matchMedia","Breakpoint","SMALL","setState","matches","componentWillUnmount","onFocus","discard","close","onBlur","handleKeyDown","event","key","adjustDate","preventDefault","daysToAdd","monthsToAdd","yearsToAdd","date","getDate","preferredElement","fallbackElement","current","querySelector","focus","switchMode","switchToDays","switchToMonths","switchToYears","handleSelectedDateUpdate","handleViewDateUpdate","month","year","getCalendar","_jsxs","className","classNames","children","_jsx","DayCalendar","onSelect","onLabelClick","onViewDateUpdate","MonthCalendar","YearCalendar","handleClear","render","inputAttributes","id","idProp","ariaLabelledByProp","ariaLabelledBy","ref","onKeyDown","DateTrigger","onClick","onClear","undefined","ResponsivePanel","anchorRef","position","Position","BOTTOM","onClose","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAMA,UAAW,SAAQC,mBAAkE,CAAA;AAIzF,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,KAAK,EAAE,IAAI;AACXC,IAAAA,GAAG,EAAE,IAAI;AACTC,IAAAA,GAAG,EAAE,IAAI;IACTC,IAAI,EAAEC,SAAI,CAACC,MAAM;AACjBC,IAAAA,WAAW,EAAE,EAAE;AACfC,IAAAA,KAAK,EAAE,EAAE;IACTC,WAAW,EAAEC,uBAAW,CAACC,IAAI;AAC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;AAAA8B,QAAAA,QAAA,EAErB,IAAI,CAACJ,WAAW,EAAA;AAAE,OACJ,CACnB,CAAA;AAAA,KAAK,CAAC,CAAA;AAEV,GAAA;;AAKF,mBAAe+B,4BAAmB,CAChClH,UAAqE,EACrE;AAAEmH,EAAAA,YAAY,EAAE,IAAA;AAAM,CAAA,CACvB;;;;"}
1
+ {"version":3,"file":"DateLookup.js","sources":["../../src/dateLookup/DateLookup.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport { createRef, PureComponent, KeyboardEvent } from 'react';\n\nimport {\n Size,\n MonthFormat,\n Position,\n Breakpoint,\n SizeSmall,\n SizeMedium,\n SizeLarge,\n} from '../common';\nimport { isWithinRange, moveToWithinRange } from '../common/dateUtils';\nimport ResponsivePanel from '../common/responsivePanel';\nimport { WithInputAttributesProps, withInputAttributes } from '../inputs/contexts';\nimport { OverlayIdContext, OverlayIdProvider } from '../provider/overlay/OverlayIdProvider';\nimport DateTrigger from './dateTrigger';\nimport DayCalendar from './dayCalendar';\nimport { getStartOfDay } from './getStartOfDay';\nimport MonthCalendar from './monthCalendar';\nimport YearCalendar from './yearCalendar';\n\nexport interface DateLookupProps {\n id?: string;\n value: Date | null;\n min?: Date | null;\n max?: Date | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n placeholder?: string;\n label?: string;\n 'aria-labelledby'?: string;\n monthFormat?: `${MonthFormat}`;\n disabled?: boolean;\n clearable?: boolean;\n onChange: (date: Date | null) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n}\n\ntype DateLookupPropsWithInputAttributes = DateLookupProps & Partial<WithInputAttributesProps>;\n\ninterface DateLookupState {\n selectedDate: Date | null;\n originalDate: Date | null;\n min: Date | null;\n max: Date | null;\n viewMonth: number;\n viewYear: number;\n open: boolean;\n mode: 'day' | 'month' | 'year';\n isMobile: boolean;\n}\n\nclass DateLookup extends PureComponent<DateLookupPropsWithInputAttributes, DateLookupState> {\n declare props: DateLookupPropsWithInputAttributes &\n Required<Pick<DateLookupPropsWithInputAttributes, keyof typeof DateLookup.defaultProps>>;\n\n static defaultProps = {\n value: null,\n min: null,\n max: null,\n size: Size.MEDIUM,\n placeholder: '',\n label: '',\n monthFormat: MonthFormat.LONG,\n disabled: false,\n clearable: false,\n } satisfies Partial<DateLookupPropsWithInputAttributes>;\n\n element = createRef<HTMLDivElement>();\n dropdown = createRef<HTMLDivElement>();\n\n constructor(props: DateLookup['props']) {\n super(props);\n this.state = {\n selectedDate: getStartOfDay(props.value),\n originalDate: null,\n min: getStartOfDay(props.min),\n max: getStartOfDay(props.max),\n viewMonth: (props.value || new Date()).getMonth(),\n viewYear: (props.value || new Date()).getFullYear(),\n open: false,\n mode: 'day',\n isMobile: false,\n };\n }\n\n static getDerivedStateFromProps(props: DateLookup['props'], state: DateLookupState) {\n const propsSelected = getStartOfDay(props.value);\n const propsMin = getStartOfDay(props.min);\n const propsMax = getStartOfDay(props.max);\n const hasSelectedChanged = state.selectedDate?.getTime() !== propsSelected?.getTime();\n const hasMinChanged = state.min?.getTime() !== propsMin?.getTime();\n const hasMaxChanged = state.max?.getTime() !== propsMax?.getTime();\n if (hasSelectedChanged || hasMinChanged || hasMaxChanged) {\n const selectedDate = hasSelectedChanged ? propsSelected : state.selectedDate;\n const min = hasMinChanged ? propsMin : state.min;\n const max = hasMaxChanged ? propsMax : state.max;\n if (selectedDate && !isWithinRange(selectedDate, min, max)) {\n props.onChange(moveToWithinRange(selectedDate, min, max));\n return null;\n }\n const viewDateThatIsWithinRange: Date =\n selectedDate || ((min || max) && moveToWithinRange(new Date(), min, max)) || new Date();\n const viewMonth = viewDateThatIsWithinRange.getMonth();\n const viewYear = viewDateThatIsWithinRange.getFullYear();\n return { selectedDate, min, max, viewMonth, viewYear };\n }\n return null;\n }\n\n componentDidUpdate(previousProps: DateLookupPropsWithInputAttributes) {\n if (this.props.value?.getTime() !== previousProps.value?.getTime() && this.state.open) {\n this.focusOn('.active');\n }\n const mediaQuery = window.matchMedia(`(max-width: ${Breakpoint.SMALL}px)`);\n this.setState({ isMobile: mediaQuery.matches });\n }\n\n componentWillUnmount() {\n // Prevents memory leak by cleaning state.\n this.setState = () => {};\n }\n\n open = () => {\n const { onFocus } = this.props;\n\n this.setState({ open: true, mode: 'day' });\n if (onFocus) {\n onFocus();\n }\n };\n\n discard = () => {\n const { originalDate } = this.state;\n if (originalDate !== null) {\n this.props.onChange(originalDate);\n }\n this.close();\n };\n\n close = () => {\n const { onBlur } = this.props;\n this.setState({ open: false, originalDate: null });\n if (onBlur) {\n onBlur();\n }\n };\n\n handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const { open, originalDate } = this.state;\n switch (event.key) {\n case 'ArrowLeft':\n if (open) {\n this.adjustDate(-1, -1, -1);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowUp':\n if (open) {\n this.adjustDate(-7, -4, -4);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowRight':\n if (open) {\n this.adjustDate(1, 1, 1);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'ArrowDown':\n if (open) {\n this.adjustDate(7, 4, 4);\n } else {\n this.open();\n }\n event.preventDefault();\n break;\n case 'Escape':\n if (originalDate !== null) {\n this.props.onChange(originalDate);\n }\n this.close();\n event.preventDefault();\n break;\n default:\n break;\n }\n };\n\n adjustDate = (daysToAdd: number, monthsToAdd: number, yearsToAdd: number) => {\n const { selectedDate, min, max, mode, originalDate } = this.state;\n if (originalDate === null) {\n this.setState({ originalDate: selectedDate });\n }\n let date: Date | null;\n if (selectedDate) {\n date = new Date(\n mode === 'year' ? selectedDate.getFullYear() + yearsToAdd : selectedDate.getFullYear(),\n mode === 'month' ? selectedDate.getMonth() + monthsToAdd : selectedDate.getMonth(),\n mode === 'day' ? selectedDate.getDate() + daysToAdd : selectedDate.getDate(),\n );\n } else {\n date = getStartOfDay(new Date());\n }\n if (date) {\n date = moveToWithinRange(date, min, max);\n }\n if (date?.getTime() !== selectedDate?.getTime()) {\n this.props.onChange(date);\n }\n };\n\n focusOn = (preferredElement: string, fallbackElement?: string) => {\n const element = this.element.current?.querySelector(preferredElement) as HTMLElement | null;\n if (element) {\n element.focus();\n } else if (fallbackElement) {\n this.focusOn(fallbackElement);\n }\n };\n\n switchMode = (mode: 'day' | 'month' | 'year') => {\n this.setState({ mode }, () => {\n this.focusOn('.active', '.today');\n });\n };\n\n switchToDays = () => this.switchMode('day');\n\n switchToMonths = () => this.switchMode('month');\n\n switchToYears = () => this.switchMode('year');\n\n handleSelectedDateUpdate = (selectedDate: Date) => {\n this.setState({ selectedDate }, () => {\n this.props.onChange(selectedDate);\n this.close();\n this.focusOn('.btn');\n });\n };\n\n handleViewDateUpdate = ({ month = this.state.viewMonth, year = this.state.viewYear }) => {\n this.setState({ viewMonth: month, viewYear: year });\n };\n\n getCalendar = () => {\n const { selectedDate, min, max, viewMonth, viewYear, mode, isMobile } = this.state;\n const { placeholder, monthFormat } = this.props;\n return (\n <div className={classNames({ 'p-a-1': !isMobile })}>\n {mode === 'day' && (\n <DayCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewMonth={viewMonth}\n viewYear={viewYear}\n monthFormat={monthFormat}\n onSelect={this.handleSelectedDateUpdate}\n onLabelClick={this.switchToYears}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n {mode === 'month' && (\n <MonthCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n placeholder={placeholder}\n onSelect={this.switchToDays}\n onLabelClick={this.switchToYears}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n {mode === 'year' && (\n <YearCalendar\n selectedDate={selectedDate}\n min={min}\n max={max}\n viewYear={viewYear}\n placeholder={placeholder}\n onSelect={this.switchToMonths}\n onViewDateUpdate={this.handleViewDateUpdate}\n />\n )}\n </div>\n );\n };\n\n handleClear = () => {\n this.props.onChange(null);\n this.focusOn('.np-date-trigger');\n };\n\n render() {\n const { selectedDate, open } = this.state;\n\n const {\n inputAttributes,\n id: idProp,\n 'aria-labelledby': ariaLabelledByProp,\n size,\n placeholder,\n label,\n monthFormat,\n disabled,\n clearable,\n value,\n } = this.props;\n const id = idProp ?? inputAttributes?.id;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n\n return (\n <div\n ref={this.element}\n {...inputAttributes}\n id={id}\n aria-labelledby={ariaLabelledBy}\n className=\"input-group\"\n onKeyDown={this.handleKeyDown}\n >\n <OverlayIdProvider open={open}>\n <DateTrigger\n selectedDate={selectedDate}\n size={size}\n placeholder={placeholder}\n label={label}\n monthFormat={monthFormat}\n disabled={disabled || false}\n onClick={this.open}\n onClear={!disabled && clearable && value ? this.handleClear : undefined}\n />\n <ResponsivePanel\n anchorRef={this.element}\n open={open}\n className=\"tw-date-lookup-menu\"\n position={Position.BOTTOM}\n onClose={this.discard}\n >\n {this.getCalendar()}\n </ResponsivePanel>\n </OverlayIdProvider>\n </div>\n );\n }\n}\n\nexport const DateLookupWithoutInputAttributes = DateLookup;\n\nexport default withInputAttributes(\n DateLookup as React.ComponentType<DateLookupPropsWithInputAttributes>,\n { nonLabelable: true },\n);\n"],"names":["DateLookup","PureComponent","defaultProps","value","min","max","size","Size","MEDIUM","placeholder","label","monthFormat","MonthFormat","LONG","disabled","clearable","element","createRef","dropdown","constructor","props","state","selectedDate","getStartOfDay","originalDate","viewMonth","Date","getMonth","viewYear","getFullYear","open","mode","isMobile","getDerivedStateFromProps","propsSelected","propsMin","propsMax","hasSelectedChanged","getTime","hasMinChanged","hasMaxChanged","isWithinRange","onChange","moveToWithinRange","viewDateThatIsWithinRange","componentDidUpdate","previousProps","focusOn","mediaQuery","window","matchMedia","Breakpoint","SMALL","setState","matches","componentWillUnmount","onFocus","discard","close","onBlur","handleKeyDown","event","key","adjustDate","preventDefault","daysToAdd","monthsToAdd","yearsToAdd","date","getDate","preferredElement","fallbackElement","current","querySelector","focus","switchMode","switchToDays","switchToMonths","switchToYears","handleSelectedDateUpdate","handleViewDateUpdate","month","year","getCalendar","_jsxs","className","classNames","children","_jsx","DayCalendar","onSelect","onLabelClick","onViewDateUpdate","MonthCalendar","YearCalendar","handleClear","render","inputAttributes","id","idProp","ariaLabelledByProp","ariaLabelledBy","ref","onKeyDown","OverlayIdProvider","DateTrigger","onClick","onClear","undefined","ResponsivePanel","anchorRef","position","Position","BOTTOM","onClose","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAMA,UAAW,SAAQC,mBAAkE,CAAA;AAIzF,EAAA,OAAOC,YAAY,GAAG;AACpBC,IAAAA,KAAK,EAAE,IAAI;AACXC,IAAAA,GAAG,EAAE,IAAI;AACTC,IAAAA,GAAG,EAAE,IAAI;IACTC,IAAI,EAAEC,SAAI,CAACC,MAAM;AACjBC,IAAAA,WAAW,EAAE,EAAE;AACfC,IAAAA,KAAK,EAAE,EAAE;IACTC,WAAW,EAAEC,uBAAW,CAACC,IAAI;AAC7BC,IAAAA,QAAQ,EAAE,KAAK;AACfC,IAAAA,SAAS,EAAE,KAAA;GAC0C,CAAA;EAEvDC,OAAO,gBAAGC,eAAS,EAAkB,CAAA;EACrCC,QAAQ,gBAAGD,eAAS,EAAkB,CAAA;EAEtCE,WAAAA,CAAYC,KAA0B,EAAA;IACpC,KAAK,CAACA,KAAK,CAAC,CAAA;IACZ,IAAI,CAACC,KAAK,GAAG;AACXC,MAAAA,YAAY,EAAEC,2BAAa,CAACH,KAAK,CAACjB,KAAK,CAAC;AACxCqB,MAAAA,YAAY,EAAE,IAAI;AAClBpB,MAAAA,GAAG,EAAEmB,2BAAa,CAACH,KAAK,CAAChB,GAAG,CAAC;AAC7BC,MAAAA,GAAG,EAAEkB,2BAAa,CAACH,KAAK,CAACf,GAAG,CAAC;AAC7BoB,MAAAA,SAAS,EAAE,CAACL,KAAK,CAACjB,KAAK,IAAI,IAAIuB,IAAI,EAAE,EAAEC,QAAQ,EAAE;AACjDC,MAAAA,QAAQ,EAAE,CAACR,KAAK,CAAC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IAAI,EAAEA,IAAK;QAAAyD,QAAA,EAAA,cAC5BC,cAAA,CAACiB,WAAW,EAAA;AACVnF,UAAAA,YAAY,EAAEA,YAAa;AAC3BhB,UAAAA,IAAI,EAAEA,IAAK;AACXG,UAAAA,WAAW,EAAEA,WAAY;AACzBC,UAAAA,KAAK,EAAEA,KAAM;AACbC,UAAAA,WAAW,EAAEA,WAAY;UACzBG,QAAQ,EAAEA,QAAQ,IAAI,KAAM;UAC5B4F,OAAO,EAAE,IAAI,CAAC5E,IAAK;UACnB6E,OAAO,EAAE,CAAC7F,QAAQ,IAAIC,SAAS,IAAIZ,KAAK,GAAG,IAAI,CAAC4F,WAAW,GAAGa,SAAAA;AAAU,SAE1E,CAAA,eAAApB,cAAA,CAACqB,eAAe,EAAA;UACdC,SAAS,EAAE,IAAI,CAAC9F,OAAQ;AACxBc,UAAAA,IAAI,EAAEA,IAAK;AACXuD,UAAAA,SAAS,EAAC,qBAAqB;UAC/B0B,QAAQ,EAAEC,iBAAQ,CAACC,MAAO;UAC1BC,OAAO,EAAE,IAAI,CAACzD,OAAQ;AAAA8B,UAAAA,QAAA,EAErB,IAAI,CAACJ,WAAW,EAAA;AAAE,SACJ,CACnB,CAAA;OAAmB,CAAA;AACrB,KAAK,CAAC,CAAA;AAEV,GAAA;;AAKF,mBAAegC,4BAAmB,CAChCnH,UAAqE,EACrE;AAAEoH,EAAAA,YAAY,EAAE,IAAA;AAAM,CAAA,CACvB;;;;"}
@@ -4,6 +4,7 @@ import '@transferwise/formatting';
4
4
  import { moveToWithinRange } from '../common/dateUtils/moveToWithinRange/moveToWithinRange.mjs';
5
5
  import { isWithinRange } from '../common/dateUtils/isWithinRange/isWithinRange.mjs';
6
6
  import { withInputAttributes } from '../inputs/contexts.mjs';
7
+ import { OverlayIdProvider } from '../provider/overlay/OverlayIdProvider.mjs';
7
8
  import DateTrigger from './dateTrigger/DateTrigger.mjs';
8
9
  import DayCalendar from './dayCalendar/DayCalendar.mjs';
9
10
  import { getStartOfDay } from './getStartOfDay/getStartOfDay.mjs';
@@ -298,30 +299,33 @@ class DateLookup extends PureComponent {
298
299
  } = this.props;
299
300
  const id = idProp ?? inputAttributes?.id;
300
301
  const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
301
- return /*#__PURE__*/jsxs("div", {
302
+ return /*#__PURE__*/jsx("div", {
302
303
  ref: this.element,
303
304
  ...inputAttributes,
304
305
  id: id,
305
306
  "aria-labelledby": ariaLabelledBy,
306
307
  className: "input-group",
307
308
  onKeyDown: this.handleKeyDown,
308
- children: [/*#__PURE__*/jsx(DateTrigger, {
309
- selectedDate: selectedDate,
310
- size: size,
311
- placeholder: placeholder,
312
- label: label,
313
- monthFormat: monthFormat,
314
- disabled: disabled || false,
315
- onClick: this.open,
316
- onClear: !disabled && clearable && value ? this.handleClear : undefined
317
- }), /*#__PURE__*/jsx(ResponsivePanel, {
318
- anchorRef: this.element,
309
+ children: /*#__PURE__*/jsxs(OverlayIdProvider, {
319
310
  open: open,
320
- className: "tw-date-lookup-menu",
321
- position: Position.BOTTOM,
322
- onClose: this.discard,
323
- children: this.getCalendar()
324
- })]
311
+ children: [/*#__PURE__*/jsx(DateTrigger, {
312
+ selectedDate: selectedDate,
313
+ size: size,
314
+ placeholder: placeholder,
315
+ label: label,
316
+ monthFormat: monthFormat,
317
+ disabled: disabled || false,
318
+ onClick: this.open,
319
+ onClear: !disabled && clearable && value ? this.handleClear : undefined
320
+ }), /*#__PURE__*/jsx(ResponsivePanel, {
321
+ anchorRef: this.element,
322
+ open: open,
323
+ className: "tw-date-lookup-menu",
324
+ position: Position.BOTTOM,
325
+ onClose: this.discard,
326
+ children: this.getCalendar()
327
+ })]
328
+ })
325
329
  });
326
330
  }
327
331
  }