@chayns-components/core 5.6.11 → 5.6.14

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 (48) hide show
  1. package/AGENTS.md +13 -0
  2. package/lib/cjs/components/popup/Popup.js +52 -38
  3. package/lib/cjs/components/popup/Popup.js.map +1 -1
  4. package/lib/cjs/components/popup/Popup.styles.js +11 -1
  5. package/lib/cjs/components/popup/Popup.styles.js.map +1 -1
  6. package/lib/cjs/components/popup/Popup.test.js +259 -0
  7. package/lib/cjs/components/popup/Popup.test.js.map +1 -0
  8. package/lib/cjs/components/popup/Popup.types.js.map +1 -1
  9. package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
  10. package/lib/cjs/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
  11. package/lib/cjs/components/popup/popupPosition.js +33 -0
  12. package/lib/cjs/components/popup/popupPosition.js.map +1 -0
  13. package/lib/cjs/components/popup/popupPosition.test.js +47 -0
  14. package/lib/cjs/components/popup/popupPosition.test.js.map +1 -0
  15. package/lib/cjs/components/search-box/SearchBox.js +1 -2
  16. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  17. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js +2 -1
  18. package/lib/cjs/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  19. package/lib/cjs/utils/searchBox.js +3 -1
  20. package/lib/cjs/utils/searchBox.js.map +1 -1
  21. package/lib/cjs/utils/searchBox.test.js +13 -0
  22. package/lib/cjs/utils/searchBox.test.js.map +1 -1
  23. package/lib/esm/components/popup/Popup.js +54 -40
  24. package/lib/esm/components/popup/Popup.js.map +1 -1
  25. package/lib/esm/components/popup/Popup.styles.js +10 -0
  26. package/lib/esm/components/popup/Popup.styles.js.map +1 -1
  27. package/lib/esm/components/popup/Popup.test.js +254 -0
  28. package/lib/esm/components/popup/Popup.test.js.map +1 -0
  29. package/lib/esm/components/popup/Popup.types.js.map +1 -1
  30. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
  31. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
  32. package/lib/esm/components/popup/popupPosition.js +26 -0
  33. package/lib/esm/components/popup/popupPosition.js.map +1 -0
  34. package/lib/esm/components/popup/popupPosition.test.js +45 -0
  35. package/lib/esm/components/popup/popupPosition.test.js.map +1 -0
  36. package/lib/esm/components/search-box/SearchBox.js +2 -3
  37. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  38. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js +2 -1
  39. package/lib/esm/components/search-box/search-box-item/SearchBoxItem.js.map +1 -1
  40. package/lib/esm/utils/searchBox.js +1 -0
  41. package/lib/esm/utils/searchBox.js.map +1 -1
  42. package/lib/esm/utils/searchBox.test.js +14 -1
  43. package/lib/esm/utils/searchBox.test.js.map +1 -1
  44. package/lib/types/components/popup/Popup.styles.d.ts +3 -0
  45. package/lib/types/components/popup/Popup.types.d.ts +16 -0
  46. package/lib/types/components/popup/popupPosition.d.ts +15 -0
  47. package/lib/types/utils/searchBox.d.ts +1 -0
  48. package/package.json +2 -2
package/AGENTS.md CHANGED
@@ -4449,11 +4449,24 @@ import { Popup } from '@chayns-components/core';
4449
4449
  />
4450
4450
  ```
4451
4451
 
4452
+ #### Safe Area Insets
4453
+
4454
+ ```tsx
4455
+ <Popup
4456
+ content={<span style={{ display: 'block' }}>
4457
+ <h1 style={{ margin: 0 }}>Popup</h1>
4458
+ <p>Das ist ein Popup!</p>
4459
+ </span>}
4460
+ boundaryInsets={{ left: 17, right: 59 }}
4461
+ />
4462
+ ```
4463
+
4452
4464
  ### Props
4453
4465
 
4454
4466
  | name | type | required | description |
4455
4467
  | --- | --- | --- | --- |
4456
4468
  | `alignment` | `PopupAlignment \| undefined` | no | The preferred alignment of the popup relative to its trigger element. |
4469
+ | `boundaryInsets` | `{ left?: number \| undefined; right?: number \| undefined; } \| undefined` | no | Additional horizontal insets inside the positioning container, in CSS pixels. |
4457
4470
  | `children` | `ReactNode` | no | The trigger element that the popup is attached to. |
4458
4471
  | `container` | `Element \| undefined` | no | The DOM element that should receive the popup portal. |
4459
4472
  | `content` | `ReactNode` | yes | The content rendered inside the popup. |
@@ -12,11 +12,13 @@ var _popup = require("../../types/popup");
12
12
  var _AreaContextProvider = _interopRequireDefault(require("../area-provider/AreaContextProvider"));
13
13
  var _PopupContentWrapper = _interopRequireDefault(require("./popup-content-wrapper/PopupContentWrapper"));
14
14
  var _Popup = require("./Popup.styles");
15
+ var _popupPosition = require("./popupPosition");
15
16
  var _element = require("../../hooks/element");
16
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
18
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
19
  const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
19
20
  alignment,
21
+ boundaryInsets,
20
22
  content,
21
23
  onShow,
22
24
  container,
@@ -41,19 +43,29 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
41
43
  const [portal, setPortal] = (0, _react2.useState)();
42
44
  const [pseudoSize, setPseudoSize] = (0, _react2.useState)();
43
45
  const [newContainer, setNewContainer] = (0, _react2.useState)(container ?? null);
46
+ const [contentMaxWidth, setContentMaxWidth] = (0, _react2.useState)();
44
47
  const [contentMaxHeight, setContentMaxHeight] = (0, _react2.useState)(undefined);
45
48
  const timeout = (0, _react2.useRef)();
46
49
  const previousIsVisibleRef = (0, _react2.useRef)(false);
47
50
  const uuid = (0, _uuid.useUuid)();
48
51
  const isControlled = typeof isOpen === 'boolean';
49
52
  const isPopupOpen = isControlled ? isOpen : isInternallyOpen;
53
+ const leftInset = Number.isFinite(boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.left) ? Math.max(0, (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.left) ?? 0) : 0;
54
+ const rightInset = Number.isFinite(boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.right) ? Math.max(0, (boundaryInsets === null || boundaryInsets === void 0 ? void 0 : boundaryInsets.right) ?? 0) : 0;
55
+ const hasBoundaryInsets = leftInset > 0 || rightInset > 0;
56
+ const shouldWrapContent = boundaryInsets !== undefined;
57
+ const popupContent = (0, _react2.useMemo)(() => shouldWrapContent ? /*#__PURE__*/_react2.default.createElement(_Popup.StyledPopupInsetContent, {
58
+ style: {
59
+ maxWidth: hasBoundaryInsets ? contentMaxWidth : undefined
60
+ }
61
+ }, content) : content, [content, contentMaxWidth, hasBoundaryInsets, shouldWrapContent]);
50
62
  const {
51
63
  height,
52
64
  width,
53
65
  measuredElement
54
66
  } = (0, _element.useMeasuredClone)({
55
- content,
56
- shouldPreventTextWrapping: !shouldUseChildrenWidth
67
+ content: popupContent,
68
+ shouldPreventTextWrapping: !shouldUseChildrenWidth && !hasBoundaryInsets
57
69
  });
58
70
  const popupContentRef = (0, _react2.useRef)(null);
59
71
  const popupRef = (0, _react2.useRef)(null);
@@ -80,7 +92,7 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
80
92
  if (!newContainer) {
81
93
  return;
82
94
  }
83
- const HORIZONTAL_PADDING = 23;
95
+ const HORIZONTAL_PADDING = _popupPosition.POPUP_HORIZONTAL_PADDING;
84
96
  const {
85
97
  height: pseudoHeight,
86
98
  width: pseudoWidth
@@ -105,44 +117,47 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
105
117
  const y = (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;
106
118
 
107
119
  // Use one coordinate space for all horizontal bounds checks.
108
- const boundaryLeft = element.scrollLeft;
109
- const boundaryWidth = containerWidth / zoomX;
120
+ const boundaryLeft = element.scrollLeft + leftInset;
121
+ const boundaryWidth = Math.max(0, containerWidth / zoomX - leftInset - rightInset);
122
+ setContentMaxWidth(hasBoundaryInsets ? Math.max(0, boundaryWidth - 2 * HORIZONTAL_PADDING) : undefined);
110
123
  const relativeX = x - boundaryLeft;
111
124
  const shouldShowBottom = pseudoHeight > childrenTop - 25 || alignment === _popup.PopupAlignment.BottomLeft || alignment === _popup.PopupAlignment.BottomRight || alignment === _popup.PopupAlignment.BottomCenter;
112
125
  const shouldForceRight = shouldShowBottom ? alignment === _popup.PopupAlignment.BottomRight : alignment === _popup.PopupAlignment.TopRight;
113
126
  const shouldUseCenterAlignment = shouldShowBottom ? alignment === _popup.PopupAlignment.BottomCenter : alignment === _popup.PopupAlignment.TopCenter;
114
127
  const hasEnoughSpaceForCenter = pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING && pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;
128
+ let nextAlignment;
129
+ let nextOffset = 0;
115
130
  if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {
116
- setInternalAlignment(shouldShowBottom ? _popup.PopupAlignment.BottomCenter : _popup.PopupAlignment.TopCenter);
117
- setOffset(0);
118
- setCoordinates({
119
- x,
120
- y
121
- });
131
+ nextAlignment = shouldShowBottom ? _popup.PopupAlignment.BottomCenter : _popup.PopupAlignment.TopCenter;
122
132
  } else {
123
- let isRight = false;
124
- if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {
125
- setInternalAlignment(shouldShowBottom ? _popup.PopupAlignment.BottomRight : _popup.PopupAlignment.TopRight);
126
- isRight = true;
127
- } else {
128
- setInternalAlignment(shouldShowBottom ? _popup.PopupAlignment.BottomLeft : _popup.PopupAlignment.TopLeft);
129
- }
130
- let newOffset;
133
+ const isRight = pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight;
131
134
  if (isRight) {
132
- newOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
135
+ nextAlignment = shouldShowBottom ? _popup.PopupAlignment.BottomRight : _popup.PopupAlignment.TopRight;
136
+ nextOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
133
137
  } else {
138
+ nextAlignment = shouldShowBottom ? _popup.PopupAlignment.BottomLeft : _popup.PopupAlignment.TopLeft;
134
139
  const right = boundaryWidth - relativeX;
135
- newOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
140
+ nextOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
136
141
  }
137
- setOffset(newOffset);
138
- const newX = x - newOffset;
139
- setCoordinates({
140
- x: newX,
141
- y
142
- });
143
142
  }
143
+ const position = hasBoundaryInsets ? (0, _popupPosition.getPopupInsetPosition)({
144
+ alignment: nextAlignment,
145
+ anchorX: x,
146
+ boundaryLeft,
147
+ boundaryWidth,
148
+ width: pseudoWidth
149
+ }) : {
150
+ x: x - nextOffset,
151
+ offset: nextOffset
152
+ };
153
+ setInternalAlignment(nextAlignment);
154
+ setOffset(position.offset);
155
+ setCoordinates({
156
+ x: position.x,
157
+ y
158
+ });
144
159
  }
145
- }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);
160
+ }, [alignment, hasBoundaryInsets, leftInset, newContainer, pseudoSize, rightInset, shouldScrollWithContent, yOffset]);
146
161
  const handleShow = (0, _react2.useCallback)(() => {
147
162
  updatePopupPosition();
148
163
  if (isControlled) {
@@ -151,16 +166,15 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
151
166
  setIsInternallyOpen(true);
152
167
  }, [isControlled, updatePopupPosition]);
153
168
  (0, _react2.useEffect)(() => {
154
- if (isControlled) {
155
- if (isOpen) {
156
- updatePopupPosition();
157
- }
158
- return;
159
- }
160
- if (shouldBeOpen) {
169
+ if (!isControlled && shouldBeOpen) {
161
170
  handleShow();
162
171
  }
163
- }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);
172
+ }, [handleShow, isControlled, shouldBeOpen]);
173
+ (0, _react2.useEffect)(() => {
174
+ if (isPopupOpen) {
175
+ updatePopupPosition();
176
+ }
177
+ }, [isPopupOpen, updatePopupPosition]);
164
178
  const handleReposition = (0, _react2.useCallback)(() => {
165
179
  if (isPopupOpen) {
166
180
  updatePopupPosition();
@@ -283,8 +297,8 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
283
297
  onMouseEnter: handleMouseEnter
284
298
  }, /*#__PURE__*/_react2.default.createElement(_AreaContextProvider.default, {
285
299
  shouldChangeColor: true
286
- }, content))), newContainer));
287
- }, [contentMaxHeight, internalAlignment, newContainer, content, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize === null || pseudoSize === void 0 ? void 0 : pseudoSize.width, uuid, shouldScrollWithContent]);
300
+ }, popupContent))), newContainer));
301
+ }, [contentMaxHeight, internalAlignment, newContainer, popupContent, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize === null || pseudoSize === void 0 ? void 0 : pseudoSize.width, uuid, shouldScrollWithContent]);
288
302
  return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, measuredElement, /*#__PURE__*/_react2.default.createElement(_Popup.StyledPopup, {
289
303
  className: "beta-chayns-popup",
290
304
  ref: popupRef,
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","previousIsVisibleRef","uuid","useUuid","isControlled","isPopupOpen","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","updatePopupPosition","useCallback","HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","isRight","newOffset","right","newX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","handleDocumentKeyDown","key","useImperativeHandle","hide","show","createPortal","createElement","AnimatePresence","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = 23;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft;\n const boundaryWidth = containerWidth / zoomX;\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter,\n );\n setOffset(0);\n setCoordinates({\n x,\n y,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight,\n );\n isRight = true;\n } else {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft,\n );\n }\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n const right = boundaryWidth - relativeX;\n\n newOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX,\n y,\n });\n }\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (isControlled) {\n if (isOpen) {\n updatePopupPosition();\n }\n\n return;\n }\n\n if (shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n const handleDocumentKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n document.addEventListener('keydown', handleDocumentKeyDown);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n document.removeEventListener('keydown', handleDocumentKeyDown);\n };\n }, [\n handleDocumentClick,\n handleDocumentKeyDown,\n handleHide,\n isControlled,\n isPopupOpen,\n shouldBeOpen,\n ]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAA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pH,GAAG,EAAEoC,QAAS;IACdiF,OAAO,EAAE3B,mBAAoB;IAC7BqB,YAAY,EAAEjB,gBAAiB;IAC/BkB,YAAY,EAAEpB,gBAAiB;IAC/B0B,uBAAuB,EAAE3H,sBAAuB;IAChD4H,mBAAmB,EAAE1H;EAAmB,GAEvCN,QACQ,CAAC,EACbuB,MACH,CAAC;AAEX,CACJ,CAAC;AAED9B,KAAK,CAACwI,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3J,OAAA,GAEbiB,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_popupPosition","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","boundaryInsets","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxWidth","setContentMaxWidth","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","previousIsVisibleRef","uuid","useUuid","isControlled","isPopupOpen","leftInset","Number","isFinite","left","Math","max","rightInset","right","hasBoundaryInsets","shouldWrapContent","popupContent","useMemo","createElement","StyledPopupInsetContent","style","maxWidth","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","updatePopupPosition","useCallback","HORIZONTAL_PADDING","POPUP_HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","nextAlignment","nextOffset","isRight","position","getPopupInsetPosition","anchorX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","handleDocumentKeyDown","key","useImperativeHandle","hide","show","createPortal","AnimatePresence","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup, StyledPopupInsetContent } from './Popup.styles';\nimport { getPopupInsetPosition, POPUP_HORIZONTAL_PADDING } from './popupPosition';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n boundaryInsets,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxWidth, setContentMaxWidth] = useState<number | undefined>();\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const leftInset = Number.isFinite(boundaryInsets?.left)\n ? Math.max(0, boundaryInsets?.left ?? 0)\n : 0;\n const rightInset = Number.isFinite(boundaryInsets?.right)\n ? Math.max(0, boundaryInsets?.right ?? 0)\n : 0;\n const hasBoundaryInsets = leftInset > 0 || rightInset > 0;\n const shouldWrapContent = boundaryInsets !== undefined;\n const popupContent = useMemo(\n () =>\n shouldWrapContent ? (\n <StyledPopupInsetContent\n style={{ maxWidth: hasBoundaryInsets ? contentMaxWidth : undefined }}\n >\n {content}\n </StyledPopupInsetContent>\n ) : (\n content\n ),\n [content, contentMaxWidth, hasBoundaryInsets, shouldWrapContent],\n );\n\n const { height, width, measuredElement } = useMeasuredClone({\n content: popupContent,\n shouldPreventTextWrapping: !shouldUseChildrenWidth && !hasBoundaryInsets,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = POPUP_HORIZONTAL_PADDING;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft + leftInset;\n const boundaryWidth = Math.max(0, containerWidth / zoomX - leftInset - rightInset);\n setContentMaxWidth(\n hasBoundaryInsets\n ? Math.max(0, boundaryWidth - 2 * HORIZONTAL_PADDING)\n : undefined,\n );\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n let nextAlignment: PopupAlignment;\n let nextOffset = 0;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomCenter\n : PopupAlignment.TopCenter;\n } else {\n const isRight =\n pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight;\n if (isRight) {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomRight\n : PopupAlignment.TopRight;\n nextOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n nextAlignment = shouldShowBottom\n ? PopupAlignment.BottomLeft\n : PopupAlignment.TopLeft;\n const right = boundaryWidth - relativeX;\n nextOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n }\n\n const position = hasBoundaryInsets\n ? getPopupInsetPosition({\n alignment: nextAlignment,\n anchorX: x,\n boundaryLeft,\n boundaryWidth,\n width: pseudoWidth,\n })\n : { x: x - nextOffset, offset: nextOffset };\n\n setInternalAlignment(nextAlignment);\n setOffset(position.offset);\n setCoordinates({ x: position.x, y });\n }\n }, [\n alignment,\n hasBoundaryInsets,\n leftInset,\n newContainer,\n pseudoSize,\n rightInset,\n shouldScrollWithContent,\n yOffset,\n ]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (!isControlled && shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, shouldBeOpen]);\n\n useEffect(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n const handleDocumentKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n document.addEventListener('keydown', handleDocumentKeyDown);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n document.removeEventListener('keydown', handleDocumentKeyDown);\n };\n }, [\n handleDocumentClick,\n handleDocumentKeyDown,\n handleHide,\n isControlled,\n isPopupOpen,\n shouldBeOpen,\n ]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {popupContent}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n popupContent,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n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AAA,CAAAQ,OAAmB;MAACsK,iBAAiB;IAAA,GACjC1F,YACgB,CACJ,CAEZ,CAAC,EAClBxB,YACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCI,gBAAgB,EAChBhB,iBAAiB,EACjBY,YAAY,EACZwB,YAAY,EACZzC,WAAW,EACX+G,gBAAgB,EAChBE,gBAAgB,EAChBnF,WAAW,EACXrB,MAAM,EACNM,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEiC,KAAK,EACjBrB,IAAI,EACJhC,uBAAuB,CAC1B,CAAC;EAEF,oBACI3C,OAAA,CAAAa,OAAA,CAAA8E,aAAA,CAAA3F,OAAA,CAAAa,OAAA,CAAAuK,QAAA,QACKnF,eAAe,eAChBjG,OAAA,CAAAa,OAAA,CAAA8E,aAAA,CAACnF,MAAA,CAAA6K,WAAW;IACRC,SAAS,EAAC,mBAAmB;IAC7BvI,GAAG,EAAEsD,QAAS;IACdkF,OAAO,EAAE1B,mBAAoB;IAC7BoB,YAAY,EAAEhB,gBAAiB;IAC/BiB,YAAY,EAAEnB,gBAAiB;IAC/ByB,uBAAuB,EAAE9I,sBAAuB;IAChD+I,mBAAmB,EAAE7I;EAAmB,GAEvCN,QACQ,CAAC,EACbuB,MACH,CAAC;AAEX,CACJ,CAAC;AAED/B,KAAK,CAAC4J,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA/K,OAAA,GAEbiB,KAAK","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledPopupPseudo = exports.StyledPopup = void 0;
6
+ exports.StyledPopupPseudo = exports.StyledPopupInsetContent = exports.StyledPopup = void 0;
7
7
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
8
8
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
9
  const StyledPopup = exports.StyledPopup = _styledComponents.default.span`
@@ -34,4 +34,14 @@ const StyledPopupPseudo = exports.StyledPopupPseudo = _styledComponents.default.
34
34
  opacity: 0;
35
35
  position: absolute;
36
36
  `;
37
+
38
+ // Apply the same wrapping constraint to the measured clone and the visible content.
39
+ const StyledPopupInsetContent = exports.StyledPopupInsetContent = _styledComponents.default.div`
40
+ overflow-wrap: anywhere;
41
+
42
+ > * {
43
+ box-sizing: border-box;
44
+ max-width: 100%;
45
+ }
46
+ `;
37
47
  //# sourceMappingURL=Popup.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledPopup","exports","styled","span","$shouldUseFullWidth","css","$shouldUseChildrenWidth","StyledPopupPseudo","div","$menuHeight"],"sources":["../../../../src/components/popup/Popup.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledPopupProps = WithTheme<{\n $shouldUseChildrenWidth: boolean;\n $shouldUseFullWidth: boolean;\n}>;\n\nexport const StyledPopup = styled.span<StyledPopupProps>`\n cursor: pointer;\n position: relative;\n\n ${({ $shouldUseFullWidth }) =>\n $shouldUseFullWidth &&\n css`\n width: 100%;\n `};\n\n ${({ $shouldUseChildrenWidth }) =>\n $shouldUseChildrenWidth &&\n css`\n display: flex;\n width: fit-content;\n height: fit-content;\n `}\n`;\n\nexport const StyledP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A;AACA;AACA,MAAM,CAAC;EAAEC;AAAoB,CAAC,KACtBA,mBAAmB,IACnB,IAAAC,qBAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEC;AAAwB,CAAC,KAC1BA,uBAAuB,IACvB,IAAAD,qBAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAEM,MAAME,iBAAiB,GAAAN,OAAA,CAAAM,iBAAA,GAAGL,yBAAM,CAACM,GAEtC;AACF,WAAW,CAAC;EAAEC;AAAY,CAAC,KAAK,GAAGA,WAAW,GAAG,CAAC,IAAI;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Popup.styles.js","names":["_styledComponents","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledPopup","exports","styled","span","$shouldUseFullWidth","css","$shouldUseChildrenWidth","StyledPopupPseudo","div","$menuHeight","StyledPopupInsetContent"],"sources":["../../../../src/components/popup/Popup.styles.ts"],"sourcesContent":["import styled, { css } from 'styled-components';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledPopupProps = WithTheme<{\n $shouldUseChildrenWidth: boolean;\n $shouldUseFullWidth: boolean;\n}>;\n\nexport const StyledPopup = styled.span<StyledPopupProps>`\n cursor: pointer;\n position: relative;\n\n ${({ $shouldUseFullWidth }) =>\n $shouldUseFullWidth &&\n css`\n width: 100%;\n `};\n\n ${({ $shouldUseChildrenWidth }) =>\n $shouldUseChildrenWidth &&\n css`\n display: flex;\n width: fit-content;\n height: fit-content;\n `}\n`;\n\nexport const StyledPopupPseudo = styled.div<{\n $menuHeight: number;\n}>`\n top: ${({ $menuHeight }) => `${$menuHeight - 0}px`};\n left: 0;\n margin: 2px;\n pointer-events: none;\n opacity: 0;\n position: absolute;\n`;\n\n// Apply the same wrapping constraint to the measured clone and the visible content.\nexport const StyledPopupIn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mB,IACnB,IAAAC,qBAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEC;AAAwB,CAAC,KAC1BA,uBAAuB,IACvB,IAAAD,qBAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAEM,MAAME,iBAAiB,GAAAN,OAAA,CAAAM,iBAAA,GAAGL,yBAAM,CAACM,GAEtC;AACF,WAAW,CAAC;EAAEC;AAAY,CAAC,KAAK,GAAGA,WAAW,GAAG,CAAC,IAAI;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACO,MAAMC,uBAAuB,GAAAT,OAAA,CAAAS,uBAAA,GAAGR,yBAAM,CAACM,GAAG;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+
3
+ var _react = require("@testing-library/react");
4
+ var _react2 = _interopRequireWildcard(require("react"));
5
+ var _vitest = require("vitest");
6
+ var _popup = require("../../types/popup");
7
+ var _Popup = _interopRequireDefault(require("./Popup"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
+ const measurement = _vitest.vi.hoisted(() => ({
11
+ width: 250,
12
+ height: 90
13
+ }));
14
+ _vitest.vi.mock('../../hooks/element', () => ({
15
+ useMeasuredClone: () => ({
16
+ ...measurement,
17
+ measuredElement: null
18
+ })
19
+ }));
20
+ _vitest.vi.mock('chayns-api', () => ({
21
+ useSite: () => ({
22
+ colorMode: 0
23
+ })
24
+ }));
25
+ _vitest.vi.mock('./popup-content-wrapper/PopupContentWrapper', () => {
26
+ const PopupSurface = /*#__PURE__*/_react2.default.forwardRef(({
27
+ children,
28
+ coordinates,
29
+ offset,
30
+ alignment,
31
+ width
32
+ }, ref) => /*#__PURE__*/_react2.default.createElement("div", {
33
+ ref: ref,
34
+ "data-surface": true,
35
+ "data-x": coordinates.x,
36
+ "data-y": coordinates.y,
37
+ "data-offset": offset,
38
+ "data-alignment": alignment,
39
+ "data-width": width
40
+ }, children));
41
+ PopupSurface.displayName = 'PopupSurface';
42
+ return {
43
+ default: PopupSurface
44
+ };
45
+ });
46
+ let container;
47
+ let triggerLeft;
48
+ let containerWidth;
49
+ let containerLeft;
50
+ let zoom;
51
+ let getRect;
52
+ const content = /*#__PURE__*/_react2.default.createElement("p", null, "Popup hint");
53
+ const surface = () => {
54
+ const element = document.querySelector('[data-surface]');
55
+ if (!element) throw new Error('Popup surface missing');
56
+ return element;
57
+ };
58
+ const number = name => Number(surface().dataset[name]);
59
+ const popup = (props = {}, isControlled = true) => /*#__PURE__*/_react2.default.createElement(_react2.StrictMode, null, /*#__PURE__*/_react2.default.createElement(_Popup.default, {
60
+ content: content,
61
+ container: container,
62
+ isOpen: isControlled ? true : undefined,
63
+ shouldUseChildrenWidth: true,
64
+ alignment: props.alignment,
65
+ boundaryInsets: props.boundaryInsets,
66
+ shouldScrollWithContent: props.shouldScrollWithContent,
67
+ onShow: props.onShow,
68
+ onHide: props.onHide
69
+ }, /*#__PURE__*/_react2.default.createElement("button", {
70
+ type: "button"
71
+ }, "Trigger")));
72
+ (0, _vitest.beforeEach)(() => {
73
+ triggerLeft = 270;
74
+ containerWidth = 390;
75
+ containerLeft = 0;
76
+ zoom = 1;
77
+ measurement.width = 250;
78
+ measurement.height = 90;
79
+ container = document.createElement('div');
80
+ document.body.append(container);
81
+ Object.defineProperty(container, 'offsetWidth', {
82
+ get: () => containerWidth / zoom
83
+ });
84
+ Object.defineProperty(container, 'offsetHeight', {
85
+ value: 800
86
+ });
87
+ Object.defineProperty(container, 'clientHeight', {
88
+ value: 800
89
+ });
90
+ getRect = _vitest.vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function getFixtureRect() {
91
+ if (this === container) return new DOMRect(containerLeft, 0, containerWidth, 800);
92
+ return new DOMRect(triggerLeft, 20, 26, 26);
93
+ });
94
+ });
95
+ (0, _vitest.afterEach)(() => {
96
+ container.remove();
97
+ _vitest.vi.restoreAllMocks();
98
+ });
99
+ (0, _vitest.describe)('Popup boundary insets', () => {
100
+ (0, _vitest.it)('preserves the legacy position when omitted or zero', async () => {
101
+ const {
102
+ rerender
103
+ } = (0, _react.render)(popup());
104
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(283));
105
+ (0, _vitest.expect)(number('offset')).toBe(0);
106
+ const before = {
107
+ ...surface().dataset
108
+ };
109
+ rerender(popup({
110
+ boundaryInsets: {
111
+ left: 0,
112
+ right: 0
113
+ }
114
+ }));
115
+ (0, _vitest.expect)({
116
+ ...surface().dataset
117
+ }).toEqual(before);
118
+ });
119
+ (0, _vitest.it)('updates an open popup when only its insets change and restores its position', async () => {
120
+ triggerLeft = 320;
121
+ const onShow = _vitest.vi.fn();
122
+ const onHide = _vitest.vi.fn();
123
+ const {
124
+ rerender
125
+ } = (0, _react.render)(popup({
126
+ onShow,
127
+ onHide
128
+ }));
129
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(333));
130
+ rerender(popup({
131
+ boundaryInsets: {
132
+ left: 17,
133
+ right: 43
134
+ },
135
+ onShow,
136
+ onHide
137
+ }));
138
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(311));
139
+ (0, _vitest.expect)(number('alignment')).toBe(_popup.PopupAlignment.BottomLeft);
140
+ (0, _vitest.expect)(number('offset')).toBe(-22);
141
+ (0, _vitest.expect)(surface().firstElementChild).toHaveStyle({
142
+ maxWidth: '284px'
143
+ });
144
+ rerender(popup({
145
+ onShow,
146
+ onHide
147
+ }));
148
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(333));
149
+ (0, _vitest.expect)(onShow).toHaveBeenCalledTimes(1);
150
+ (0, _vitest.expect)(onHide).not.toHaveBeenCalled();
151
+ });
152
+ (0, _vitest.it)('shifts right-aligned popups left and keeps the arrow at the trigger', async () => {
153
+ (0, _react.render)(popup({
154
+ boundaryInsets: {
155
+ right: 59
156
+ },
157
+ alignment: _popup.PopupAlignment.BottomRight
158
+ }));
159
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(71));
160
+ (0, _vitest.expect)(number('offset')).toBe(212);
161
+ (0, _vitest.expect)(number('x') + number('offset')).toBe(283);
162
+ });
163
+ (0, _vitest.it)('repositions on scrolling and rotation in scaled, offset containers', async () => {
164
+ zoom = 2;
165
+ containerLeft = 100;
166
+ containerWidth = 780;
167
+ triggerLeft = 700;
168
+ const {
169
+ unmount
170
+ } = (0, _react.render)(popup({
171
+ boundaryInsets: {
172
+ right: 59
173
+ }
174
+ }));
175
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(295));
176
+ (0, _react.act)(() => {
177
+ container.scrollLeft = 80;
178
+ _react.fireEvent.scroll(container);
179
+ });
180
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(375));
181
+ (0, _react.act)(() => {
182
+ containerWidth = 1000;
183
+ _react.fireEvent.resize(window);
184
+ });
185
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(surface().firstElementChild).toHaveStyle({
186
+ maxWidth: '395px'
187
+ }));
188
+ const remove = _vitest.vi.spyOn(window, 'removeEventListener');
189
+ unmount();
190
+ (0, _vitest.expect)(remove).toHaveBeenCalledWith('resize', _vitest.expect.any(Function));
191
+ (0, _vitest.expect)(remove).toHaveBeenCalledWith('scroll', _vitest.expect.any(Function), true);
192
+ });
193
+ (0, _vitest.it)('uses body geometry for fixed popups', async () => {
194
+ Object.defineProperty(document.body, 'offsetWidth', {
195
+ configurable: true,
196
+ value: 390
197
+ });
198
+ Object.defineProperty(document.body, 'offsetHeight', {
199
+ configurable: true,
200
+ value: 800
201
+ });
202
+ getRect.mockImplementation(function getBodyRect() {
203
+ return this === document.body ? new DOMRect(0, 0, 390, 800) : new DOMRect(320, 20, 26, 26);
204
+ });
205
+ (0, _react.render)(popup({
206
+ shouldScrollWithContent: false,
207
+ boundaryInsets: {
208
+ right: 59
209
+ }
210
+ }));
211
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(295));
212
+ });
213
+ (0, _vitest.it)('updates an uncontrolled open popup when insets change or are removed', async () => {
214
+ triggerLeft = 320;
215
+ const {
216
+ getByRole,
217
+ rerender
218
+ } = (0, _react.render)(popup({}, false));
219
+ _react.fireEvent.click(getByRole('button', {
220
+ name: 'Trigger'
221
+ }));
222
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(333));
223
+ rerender(popup({
224
+ boundaryInsets: {
225
+ right: 59
226
+ }
227
+ }, false));
228
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(295));
229
+ rerender(popup({}, false));
230
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(333));
231
+ });
232
+ (0, _vitest.it)('retains content when configured insets change between zero and nonzero', async () => {
233
+ var _surface$firstElement;
234
+ const {
235
+ rerender
236
+ } = (0, _react.render)(popup({
237
+ boundaryInsets: {
238
+ left: 0,
239
+ right: 0
240
+ }
241
+ }));
242
+ await (0, _react.waitFor)(() => (0, _vitest.expect)(number('x')).toBe(283));
243
+ const paragraph = surface().querySelector('p');
244
+ rerender(popup({
245
+ boundaryInsets: {
246
+ right: 59
247
+ }
248
+ }));
249
+ (0, _vitest.expect)(surface().querySelector('p')).toBe(paragraph);
250
+ rerender(popup({
251
+ boundaryInsets: {
252
+ right: 0
253
+ }
254
+ }));
255
+ (0, _vitest.expect)(surface().querySelector('p')).toBe(paragraph);
256
+ (0, _vitest.expect)(((_surface$firstElement = surface().firstElementChild) === null || _surface$firstElement === void 0 ? void 0 : _surface$firstElement.getAttribute('style')) ?? '').not.toContain('max-width');
257
+ });
258
+ });
259
+ //# sourceMappingURL=Popup.test.js.map