@chayns-components/core 5.6.11 → 5.6.12

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 (31) 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/esm/components/popup/Popup.js +54 -40
  16. package/lib/esm/components/popup/Popup.js.map +1 -1
  17. package/lib/esm/components/popup/Popup.styles.js +10 -0
  18. package/lib/esm/components/popup/Popup.styles.js.map +1 -1
  19. package/lib/esm/components/popup/Popup.test.js +254 -0
  20. package/lib/esm/components/popup/Popup.test.js.map +1 -0
  21. package/lib/esm/components/popup/Popup.types.js.map +1 -1
  22. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js +2 -2
  23. package/lib/esm/components/popup/popup-content-wrapper/PopupContentWrapper.styles.js.map +1 -1
  24. package/lib/esm/components/popup/popupPosition.js +26 -0
  25. package/lib/esm/components/popup/popupPosition.js.map +1 -0
  26. package/lib/esm/components/popup/popupPosition.test.js +45 -0
  27. package/lib/esm/components/popup/popupPosition.test.js.map +1 -0
  28. package/lib/types/components/popup/Popup.styles.d.ts +3 -0
  29. package/lib/types/components/popup/Popup.types.d.ts +16 -0
  30. package/lib/types/components/popup/popupPosition.d.ts +15 -0
  31. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.test.js","names":["_react","require","_react2","_interopRequireWildcard","_vitest","_popup","_Popup","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","measurement","vi","hoisted","width","height","mock","useMeasuredClone","measuredElement","useSite","colorMode","PopupSurface","React","forwardRef","children","coordinates","offset","alignment","ref","createElement","x","y","displayName","container","triggerLeft","containerWidth","containerLeft","zoom","getRect","content","surface","element","document","querySelector","Error","number","name","Number","dataset","popup","props","isControlled","StrictMode","isOpen","undefined","shouldUseChildrenWidth","boundaryInsets","shouldScrollWithContent","onShow","onHide","type","beforeEach","body","append","value","spyOn","HTMLElement","prototype","mockImplementation","getFixtureRect","DOMRect","afterEach","remove","restoreAllMocks","describe","it","rerender","render","waitFor","expect","toBe","before","left","right","toEqual","fn","PopupAlignment","BottomLeft","firstElementChild","toHaveStyle","maxWidth","toHaveBeenCalledTimes","not","toHaveBeenCalled","BottomRight","unmount","act","scrollLeft","fireEvent","scroll","resize","window","toHaveBeenCalledWith","any","Function","configurable","getBodyRect","getByRole","click","_surface$firstElement","paragraph","getAttribute","toContain"],"sources":["../../../../src/components/popup/Popup.test.tsx"],"sourcesContent":["import { act, fireEvent, render, waitFor } from '@testing-library/react';\nimport React, { type ReactNode, StrictMode } from 'react';\nimport { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from 'vitest';\nimport { PopupAlignment } from '../../types/popup';\nimport Popup, { type PopupProps } from './Popup';\n\nconst measurement = vi.hoisted(() => ({ width: 250, height: 90 }));\nvi.mock('../../hooks/element', () => ({\n useMeasuredClone: () => ({ ...measurement, measuredElement: null }),\n}));\nvi.mock('chayns-api', () => ({ useSite: () => ({ colorMode: 0 }) }));\nvi.mock('./popup-content-wrapper/PopupContentWrapper', () => {\n const PopupSurface = React.forwardRef<\n HTMLDivElement,\n {\n children: ReactNode;\n coordinates: { x: number; y: number };\n offset: number;\n alignment: PopupAlignment;\n width: number;\n }\n >(({ children, coordinates, offset, alignment, width }, ref) => (\n <div\n ref={ref}\n data-surface\n data-x={coordinates.x}\n data-y={coordinates.y}\n data-offset={offset}\n data-alignment={alignment}\n data-width={width}\n >\n {children}\n </div>\n ));\n PopupSurface.displayName = 'PopupSurface';\n return { default: PopupSurface };\n});\n\nlet container: HTMLDivElement;\nlet triggerLeft: number;\nlet containerWidth: number;\nlet containerLeft: number;\nlet zoom: number;\nlet getRect: MockInstance<[], DOMRect>;\nconst content = <p>Popup hint</p>;\nconst surface = () => {\n const element = document.querySelector<HTMLElement>('[data-surface]');\n if (!element) throw new Error('Popup surface missing');\n return element;\n};\nconst number = (name: string) => Number(surface().dataset[name]);\nconst popup = (props: Partial<PopupProps> = {}, isControlled = true) => (\n <StrictMode>\n <Popup\n content={content}\n container={container}\n isOpen={isControlled ? true : undefined}\n shouldUseChildrenWidth\n alignment={props.alignment}\n boundaryInsets={props.boundaryInsets}\n shouldScrollWithContent={props.shouldScrollWithContent}\n onShow={props.onShow}\n onHide={props.onHide}\n >\n <button type=\"button\">Trigger</button>\n </Popup>\n </StrictMode>\n);\n\nbeforeEach(() => {\n triggerLeft = 270;\n containerWidth = 390;\n containerLeft = 0;\n zoom = 1;\n measurement.width = 250;\n measurement.height = 90;\n container = document.createElement('div');\n document.body.append(container);\n Object.defineProperty(container, 'offsetWidth', { get: () => containerWidth / zoom });\n Object.defineProperty(container, 'offsetHeight', { value: 800 });\n Object.defineProperty(container, 'clientHeight', { value: 800 });\n getRect = vi\n .spyOn(HTMLElement.prototype, 'getBoundingClientRect')\n .mockImplementation(function getFixtureRect(this: HTMLElement) {\n if (this === container) return new DOMRect(containerLeft, 0, containerWidth, 800);\n return new DOMRect(triggerLeft, 20, 26, 26);\n });\n});\n\nafterEach(() => {\n container.remove();\n vi.restoreAllMocks();\n});\n\ndescribe('Popup boundary insets', () => {\n it('preserves the legacy position when omitted or zero', async () => {\n const { rerender } = render(popup());\n await waitFor(() => expect(number('x')).toBe(283));\n expect(number('offset')).toBe(0);\n const before = { ...surface().dataset };\n rerender(popup({ boundaryInsets: { left: 0, right: 0 } }));\n expect({ ...surface().dataset }).toEqual(before);\n });\n\n it('updates an open popup when only its insets change and restores its position', async () => {\n triggerLeft = 320;\n const onShow = vi.fn();\n const onHide = vi.fn();\n const { rerender } = render(popup({ onShow, onHide }));\n await waitFor(() => expect(number('x')).toBe(333));\n rerender(popup({ boundaryInsets: { left: 17, right: 43 }, onShow, onHide }));\n await waitFor(() => expect(number('x')).toBe(311));\n expect(number('alignment')).toBe(PopupAlignment.BottomLeft);\n expect(number('offset')).toBe(-22);\n expect(surface().firstElementChild).toHaveStyle({ maxWidth: '284px' });\n rerender(popup({ onShow, onHide }));\n await waitFor(() => expect(number('x')).toBe(333));\n expect(onShow).toHaveBeenCalledTimes(1);\n expect(onHide).not.toHaveBeenCalled();\n });\n\n it('shifts right-aligned popups left and keeps the arrow at the trigger', async () => {\n render(popup({ boundaryInsets: { right: 59 }, alignment: PopupAlignment.BottomRight }));\n await waitFor(() => expect(number('x')).toBe(71));\n expect(number('offset')).toBe(212);\n expect(number('x') + number('offset')).toBe(283);\n });\n\n it('repositions on scrolling and rotation in scaled, offset containers', async () => {\n zoom = 2;\n containerLeft = 100;\n containerWidth = 780;\n triggerLeft = 700;\n const { unmount } = render(popup({ boundaryInsets: { right: 59 } }));\n await waitFor(() => expect(number('x')).toBe(295));\n act(() => {\n container.scrollLeft = 80;\n fireEvent.scroll(container);\n });\n await waitFor(() => expect(number('x')).toBe(375));\n act(() => {\n containerWidth = 1000;\n fireEvent.resize(window);\n });\n await waitFor(() => expect(surface().firstElementChild).toHaveStyle({ maxWidth: '395px' }));\n const remove = vi.spyOn(window, 'removeEventListener');\n unmount();\n expect(remove).toHaveBeenCalledWith('resize', expect.any(Function));\n expect(remove).toHaveBeenCalledWith('scroll', expect.any(Function), true);\n });\n\n it('uses body geometry for fixed popups', async () => {\n Object.defineProperty(document.body, 'offsetWidth', { configurable: true, value: 390 });\n Object.defineProperty(document.body, 'offsetHeight', { configurable: true, value: 800 });\n getRect.mockImplementation(function getBodyRect(this: HTMLElement) {\n return this === document.body\n ? new DOMRect(0, 0, 390, 800)\n : new DOMRect(320, 20, 26, 26);\n });\n render(popup({ shouldScrollWithContent: false, boundaryInsets: { right: 59 } }));\n await waitFor(() => expect(number('x')).toBe(295));\n });\n\n it('updates an uncontrolled open popup when insets change or are removed', async () => {\n triggerLeft = 320;\n const { getByRole, rerender } = render(popup({}, false));\n fireEvent.click(getByRole('button', { name: 'Trigger' }));\n await waitFor(() => expect(number('x')).toBe(333));\n rerender(popup({ boundaryInsets: { right: 59 } }, false));\n await waitFor(() => expect(number('x')).toBe(295));\n rerender(popup({}, false));\n await waitFor(() => expect(number('x')).toBe(333));\n });\n\n it('retains content when configured insets change between zero and nonzero', async () => {\n const { rerender } = render(popup({ boundaryInsets: { left: 0, right: 0 } }));\n await waitFor(() => expect(number('x')).toBe(283));\n const paragraph = surface().querySelector('p');\n rerender(popup({ boundaryInsets: { right: 59 } }));\n expect(surface().querySelector('p')).toBe(paragraph);\n rerender(popup({ boundaryInsets: { right: 0 } }));\n expect(surface().querySelector('p')).toBe(paragraph);\n expect(surface().firstElementChild?.getAttribute('style') ?? '').not.toContain('max-width');\n });\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAC,sBAAA,CAAAN,OAAA;AAAiD,SAAAM,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,E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EAC/F,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.types.js","names":[],"sources":["../../../../src/components/popup/Popup.types.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { PopupAlignment } from '../../types/popup';\n\nexport type PopupProps = {\n /**\n * The preferred alignment of the popup relative to its trigger element.\n * @description\n * Use this prop to influence where the popup should appear around its trigger. If no alignment is provided,\n * the component automatically chooses a suitable position based on the available space.\n * @example\n * <Popup alignment={PopupAlignment.BottomRight} content=\"Details\">Open</Popup>\n * @optional\n */\n alignment?: PopupAlignment;\n /**\n * The trigger element that the popup is attached to.\n * @description\n * This content is rendered in place and acts as the interactive anchor for the popup.\n * Depending on the configured behavior, clicking or hovering this element can show or hide the popup.\n * @example\n * <Popup content=\"Details\"><button type=\"button\">Open</button></Popup>\n * @optional\n */\n children?: ReactNode;\n /**\n * The DOM element that should receive the popup portal.\n * @description\n * By default, the popup resolves a suitable container automatically. Use this prop when the popup should be rendered\n * into a specific element instead, for example to keep it inside a dialog or another scrollable area.\n * @example\n * <Popup container={document.body} content=\"Details\">Open</Popup>\n * @optional\n */\n container?: Element;\n /**\n * The content rendered inside the popup.\n * @description\n * This can be any React node, such as text, markup, or a fully custom component tree.\n * @example\n * <Popup content={<div>Additional information</div>}>Open</Popup>\n */\n content: ReactNode;\n /**\n * Fully controls whether the popup is visible.\n * @description\n * When this prop receives a boolean value, the popup becomes fully controlled from the outside.\n * Internal triggers such as click, hover, outside click, blur handling, or imperative `show` and `hide`\n * calls no longer change the visibility state. The popup is then shown only when `isOpen` is `true`\n * and hidden only when `isOpen` is `false`.\n * @example\n * <Popup isOpen={isPopupOpen} content=\"Details\">Open</Popup>\n * @optional\n */\n isOpen?: boolean;\n /**\n * Callback that is called after the popup becomes hidden.\n * @description\n * Use this callback to react to the popup closing, for example to synchronize external UI state.\n * It is called when the effective popup visibility changes from open to closed.\n * @example\n * <Popup onHide={() => console.log('Popup hidden')} content=\"Details\">Open</Popup>\n * @optional\n */\n onHide?: VoidFunction;\n /**\n * Callback that is called after the popup becomes visible.\n * @description\n * Use this callback to react to the popup opening, for example to start related UI behavior or analytics.\n * It is called when the effective popup visibility changes from closed to open.\n * @example\n * <Popup onShow={() => console.log('Popup shown')} content=\"Details\">Open</Popup>\n * @optional\n */\n onShow?: VoidFunction;\n /**\n * Hides the popup when the pointer leaves the trigger element.\n * @description\n * This prop is only relevant when `shouldShowOnHover` is enabled. When set to `true`, the popup closes immediately\n * after the pointer leaves the trigger element instead of waiting for the delayed hide behavior.\n * This prop has no effect while `isOpen` is used as a controlled prop.\n * @default false\n * @example\n * <Popup shouldShowOnHover shouldHideOnChildrenLeave content=\"Details\">Open</Popup>\n * @optional\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Keeps the popup aligned within the scrolling content container.\n * @description\n * When set to `true`, the popup uses the resolved container for positioning and scroll synchronization.\n * When set to `false`, it is positioned relative to the document body instead.\n * @default true\n * @example\n * <Popup shouldScrollWithContent={false} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldScrollWithContent?: boolean;\n /**\n * Opens the popup when the trigger element is hovered instead of clicked.\n * @description\n * By default, the popup opens on click. Set this prop to `true` to switch to hover-based interaction.\n * This prop has no effect while `isOpen` is used as a controlled prop.\n * @default false\n * @example\n * <Popup shouldShowOnHover content=\"Details\">Open</Popup>\n * @optional\n */\n shouldShowOnHover?: boolean;\n /**\n * Uses the trigger element width as the popup width reference.\n * @description\n * When enabled, the popup measurement and layout respect the width of the trigger element.\n * Disable this when the popup should size itself more freely based on its content.\n * @default true\n * @example\n * <Popup shouldUseChildrenWidth={false} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * Stretches the trigger element to the full available width.\n * @description\n * This affects the wrapper around the popup trigger and is useful when the trigger should behave like a block-level element.\n * @default false\n * @example\n * <Popup shouldUseFullWidth content=\"Details\">Open</Popup>\n * @optional\n */\n shouldUseFullWidth?: boolean;\n /**\n * Requests that the popup should be opened from outside.\n * @description\n * Unlike `isOpen`, this prop does not fully control visibility. It acts as an external open trigger and keeps compatibility\n * with the existing behavior, while other internal interactions may still influence the popup state.\n * Use `isOpen` when you need full external control over showing and hiding the popup.\n * @default false\n * @example\n * <Popup shouldBeOpen={shouldOpenInitially} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldBeOpen?: boolean;\n /**\n * Vertical offset between the trigger element and the popup.\n * @description\n * Use this prop to fine-tune the popup position on the Y axis. Positive and negative values can be used depending on the desired spacing.\n * @default 0\n * @example\n * <Popup yOffset={8} content=\"Details\">Open</Popup>\n * @optional\n */\n yOffset?: number;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"Popup.types.js","names":[],"sources":["../../../../src/components/popup/Popup.types.ts"],"sourcesContent":["import { ReactNode } from 'react';\nimport { PopupAlignment } from '../../types/popup';\n\nexport type PopupProps = {\n /**\n * The preferred alignment of the popup relative to its trigger element.\n * @description\n * Use this prop to influence where the popup should appear around its trigger. If no alignment is provided,\n * the component automatically chooses a suitable position based on the available space.\n * @example\n * <Popup alignment={PopupAlignment.BottomRight} content=\"Details\">Open</Popup>\n * @optional\n */\n alignment?: PopupAlignment;\n /**\n * The trigger element that the popup is attached to.\n * @description\n * This content is rendered in place and acts as the interactive anchor for the popup.\n * Depending on the configured behavior, clicking or hovering this element can show or hide the popup.\n * @example\n * <Popup content=\"Details\"><button type=\"button\">Open</button></Popup>\n * @optional\n */\n children?: ReactNode;\n /**\n * Additional horizontal insets inside the positioning container, in CSS pixels.\n * @description\n * Reserve space for safe areas or host controls without moving the trigger. Each side defaults\n * to zero and is added to the standard popup edge spacing. Insets use the positioning container's\n * unscaled coordinate space; fixed popups use the document body. Updating the values repositions\n * an open popup. Oversized content is constrained to the remaining width and allowed to wrap.\n * @default { left: 0, right: 0 }\n * @example\n * <Popup boundaryInsets={{ left: 17, right: 43 }} content=\"Details\">Open</Popup>\n * @optional\n */\n boundaryInsets?: { left?: number; right?: number };\n /**\n * The DOM element that should receive the popup portal.\n * @description\n * By default, the popup resolves a suitable container automatically. Use this prop when the popup should be rendered\n * into a specific element instead, for example to keep it inside a dialog or another scrollable area.\n * @example\n * <Popup container={document.body} content=\"Details\">Open</Popup>\n * @optional\n */\n container?: Element;\n /**\n * The content rendered inside the popup.\n * @description\n * This can be any React node, such as text, markup, or a fully custom component tree.\n * @example\n * <Popup content={<div>Additional information</div>}>Open</Popup>\n */\n content: ReactNode;\n /**\n * Fully controls whether the popup is visible.\n * @description\n * When this prop receives a boolean value, the popup becomes fully controlled from the outside.\n * Internal triggers such as click, hover, outside click, blur handling, or imperative `show` and `hide`\n * calls no longer change the visibility state. The popup is then shown only when `isOpen` is `true`\n * and hidden only when `isOpen` is `false`.\n * @example\n * <Popup isOpen={isPopupOpen} content=\"Details\">Open</Popup>\n * @optional\n */\n isOpen?: boolean;\n /**\n * Callback that is called after the popup becomes hidden.\n * @description\n * Use this callback to react to the popup closing, for example to synchronize external UI state.\n * It is called when the effective popup visibility changes from open to closed.\n * @example\n * <Popup onHide={() => console.log('Popup hidden')} content=\"Details\">Open</Popup>\n * @optional\n */\n onHide?: VoidFunction;\n /**\n * Callback that is called after the popup becomes visible.\n * @description\n * Use this callback to react to the popup opening, for example to start related UI behavior or analytics.\n * It is called when the effective popup visibility changes from closed to open.\n * @example\n * <Popup onShow={() => console.log('Popup shown')} content=\"Details\">Open</Popup>\n * @optional\n */\n onShow?: VoidFunction;\n /**\n * Hides the popup when the pointer leaves the trigger element.\n * @description\n * This prop is only relevant when `shouldShowOnHover` is enabled. When set to `true`, the popup closes immediately\n * after the pointer leaves the trigger element instead of waiting for the delayed hide behavior.\n * This prop has no effect while `isOpen` is used as a controlled prop.\n * @default false\n * @example\n * <Popup shouldShowOnHover shouldHideOnChildrenLeave content=\"Details\">Open</Popup>\n * @optional\n */\n shouldHideOnChildrenLeave?: boolean;\n /**\n * Keeps the popup aligned within the scrolling content container.\n * @description\n * When set to `true`, the popup uses the resolved container for positioning and scroll synchronization.\n * When set to `false`, it is positioned relative to the document body instead.\n * @default true\n * @example\n * <Popup shouldScrollWithContent={false} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldScrollWithContent?: boolean;\n /**\n * Opens the popup when the trigger element is hovered instead of clicked.\n * @description\n * By default, the popup opens on click. Set this prop to `true` to switch to hover-based interaction.\n * This prop has no effect while `isOpen` is used as a controlled prop.\n * @default false\n * @example\n * <Popup shouldShowOnHover content=\"Details\">Open</Popup>\n * @optional\n */\n shouldShowOnHover?: boolean;\n /**\n * Uses the trigger element width as the popup width reference.\n * @description\n * When enabled, the popup measurement and layout respect the width of the trigger element.\n * Disable this when the popup should size itself more freely based on its content.\n * @default true\n * @example\n * <Popup shouldUseChildrenWidth={false} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldUseChildrenWidth?: boolean;\n /**\n * Stretches the trigger element to the full available width.\n * @description\n * This affects the wrapper around the popup trigger and is useful when the trigger should behave like a block-level element.\n * @default false\n * @example\n * <Popup shouldUseFullWidth content=\"Details\">Open</Popup>\n * @optional\n */\n shouldUseFullWidth?: boolean;\n /**\n * Requests that the popup should be opened from outside.\n * @description\n * Unlike `isOpen`, this prop does not fully control visibility. It acts as an external open trigger and keeps compatibility\n * with the existing behavior, while other internal interactions may still influence the popup state.\n * Use `isOpen` when you need full external control over showing and hiding the popup.\n * @default false\n * @example\n * <Popup shouldBeOpen={shouldOpenInitially} content=\"Details\">Open</Popup>\n * @optional\n */\n shouldBeOpen?: boolean;\n /**\n * Vertical offset between the trigger element and the popup.\n * @description\n * Use this prop to fine-tune the popup position on the Y axis. Positive and negative values can be used depending on the desired spacing.\n * @default 0\n * @example\n * <Popup yOffset={8} content=\"Details\">Open</Popup>\n * @optional\n */\n yOffset?: number;\n};\n"],"mappings":"","ignoreList":[]}
@@ -54,13 +54,13 @@ const StyledMotionPopupContentWrapper = exports.StyledMotionPopupContentWrapper
54
54
  case _popup.PopupAlignment.TopCenter:
55
55
  return (0, _styledComponents.css)`
56
56
  bottom: -7px;
57
- left: calc(50% - 7px);
57
+ left: calc(50% - 7px + ${$offset}px);
58
58
  transform: rotate(45deg);
59
59
  `;
60
60
  case _popup.PopupAlignment.BottomCenter:
61
61
  return (0, _styledComponents.css)`
62
62
  top: -7px;
63
- left: calc(50% - 7px);
63
+ left: calc(50% - 7px + ${$offset}px);
64
64
  transform: rotate(225deg);
65
65
  `;
66
66
  case _popup.PopupAlignment.TopRight:
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContentWrapper.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_popup","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledMotionPopupContentWrapper","exports","styled","motion","div","theme","text","$shouldScrollWithContent","$position","$offset","PopupAlignment","TopLeft","css","BottomLeft","TopCenter","BottomCenter","TopRight","BottomRight","undefined","StyledPopupContentWrapperContent","$maxHeight"],"sources":["../../../../../src/components/popup/popup-content-wrapper/PopupContentWrapper.styles.ts"],"sourcesContent":["import { ColorMode } from 'chayns-api';\nimport { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../../types/popup';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledMotionPopupContentWrapperProps = WithTheme<{\n $position: PopupAlignment;\n $colorMode: ColorMode;\n $offset: number;\n $shouldScrollWithContent: boolean;\n}>;\n\nexport const StyledMotionPopupContentWrapper = styled(\n motion.div,\n)<StyledMotionPopupContentWrapperProps>`\n background-color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme['000']};\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme.text};\n z-index: 100;\n position: ${({ $shouldScrollWithContent }) =>\n $shouldScrollWithContent ? 'absolute' : 'fixed'};\n pointer-events: all;\n\n &::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ $position, $offset }) => {\n switch ($position) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -7px;\n right: ${5 + $offset}px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -7px;\n right: ${5 + $offset}px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopCenter:\n return css`\n bottom: -7px;\n left: calc(50% - 7px);\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomCenter:\n return css`\n top: -7px;\n left: calc(50% - 7px);\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -7px;\n left: ${5 + $offset}px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -7px;\n left: ${5 + $offset}px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n &::before {\n background-color: inherit;\n border-radius: 3px;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n\ntype StyledPopupContentWrapperContentProps = WithTheme<{\n $maxHeight?: number;\n}>;\n\nexport const StyledPopupContentWrapperContent = styled.div<StyledPopupContentWrapperContentProps>`\n height: 100%;\n width: 100%;\n\n ${({ $maxHeight }) =>\n $maxHeight &&\n css`\n max-height: ${$maxHeight}px;\n overflow-y: auto;\n overflow-x: hidden;\n `}\n`;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAsD,SAAAE,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAA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,UAAU,CAAC;EAAEC,SAAS;EAAEC;AAAQ,CAAC,KAAK;EAC1B,QAAQD,SAAS;IACb,KAAKE,qBAAc,CAACC,OAAO;MACvB,OAAO,IAAAC,qBAAG;AAC9B;AACA,iCAAiC,CAAC,GAAGH,OAAO;AAC5C;AACA,qBAAqB;IACL,KAAKC,qBAAc,CAACG,UAAU;MAC1B,OAAO,IAAAD,qBAAG;AAC9B;AACA,iCAAiC,CAAC,GAAGH,OAAO;AAC5C;AACA,qBAAqB;IACL,KAAKC,qBAAc,CAACI,SAAS;MACzB,OAAO,IAAAF,qBAAG;AAC9B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,qBAAc,CAACK,YAAY;MAC5B,OAAO,IAAAH,qBAAG;AAC9B;AACA;AACA;AACA,qBAAqB;IACL,KAAKF,qBAAc,CAACM,QAAQ;MACxB,OAAO,IAAAJ,qBAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGH,OAAO;AAC3C,qBAAqB;IACL,KAAKC,qBAAc,CAACO,WAAW;MAC3B,OAAO,IAAAL,qBAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGH,OAAO;AAC3C,qBAAqB;IACL;MACI,OAAOS,SAAS;EACxB;AACJ,CAAC;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMC,gCAAgC,GAAAlB,OAAA,CAAAkB,gCAAA,GAAGjB,yBAAM,CAACE,GAA0C;AACjG;AACA;AACA;AACA,MAAM,CAAC;EAAEgB;AAAW,CAAC,KACbA,UAAU,IACV,IAAAR,qBAAG;AACX,0BAA0BQ,UAAU;AACpC;AACA;AACA,SAAS;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"PopupContentWrapper.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_popup","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledMotionPopupContentWrapper","exports","styled","motion","div","theme","text","$shouldScrollWithContent","$position","$offset","PopupAlignment","TopLeft","css","BottomLeft","TopCenter","BottomCenter","TopRight","BottomRight","undefined","StyledPopupContentWrapperContent","$maxHeight"],"sources":["../../../../../src/components/popup/popup-content-wrapper/PopupContentWrapper.styles.ts"],"sourcesContent":["import { ColorMode } from 'chayns-api';\nimport { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { PopupAlignment } from '../../../types/popup';\nimport type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledMotionPopupContentWrapperProps = WithTheme<{\n $position: PopupAlignment;\n $colorMode: ColorMode;\n $offset: number;\n $shouldScrollWithContent: boolean;\n}>;\n\nexport const StyledMotionPopupContentWrapper = styled(\n motion.div,\n)<StyledMotionPopupContentWrapperProps>`\n background-color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme['000']};\n border-radius: 3px;\n box-shadow: 1px 3px 8px rgb(0 0 0 / 30%);\n color: ${({ theme }: StyledMotionPopupContentWrapperProps) => theme.text};\n z-index: 100;\n position: ${({ $shouldScrollWithContent }) =>\n $shouldScrollWithContent ? 'absolute' : 'fixed'};\n pointer-events: all;\n\n &::after {\n background-color: inherit;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n border-right: 1px solid rgba(0, 0, 0, 0.1);\n box-shadow: 2px 2px 8px rgb(4 3 4 / 10%);\n content: '';\n height: 14px;\n position: absolute;\n width: 14px;\n z-index: -2;\n\n ${({ $position, $offset }) => {\n switch ($position) {\n case PopupAlignment.TopLeft:\n return css`\n bottom: -7px;\n right: ${5 + $offset}px;\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomLeft:\n return css`\n top: -7px;\n right: ${5 + $offset}px;\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopCenter:\n return css`\n bottom: -7px;\n left: calc(50% - 7px + ${$offset}px);\n transform: rotate(45deg);\n `;\n case PopupAlignment.BottomCenter:\n return css`\n top: -7px;\n left: calc(50% - 7px + ${$offset}px);\n transform: rotate(225deg);\n `;\n case PopupAlignment.TopRight:\n return css`\n transform: rotate(45deg);\n bottom: -7px;\n left: ${5 + $offset}px;\n `;\n case PopupAlignment.BottomRight:\n return css`\n transform: rotate(225deg);\n top: -7px;\n left: ${5 + $offset}px;\n `;\n default:\n return undefined;\n }\n }}\n }\n\n &::before {\n background-color: inherit;\n border-radius: 3px;\n bottom: 0;\n content: '';\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n z-index: -1;\n }\n`;\n\ntype StyledPopupContentWrapperContentProps = WithTheme<{\n $maxHeight?: number;\n}>;\n\nexport const StyledPopupContentWrapperContent = styled.div<StyledPopupContentWrapperContentProps>`\n height: 100%;\n width: 100%;\n\n ${({ $maxHeight }) =>\n $maxHeight &&\n css`\n max-height: ${$maxHeight}px;\n overflow-y: auto;\n overflow-x: hidden;\n `}\n`;\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAAsD,SAAAE,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,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qBAAc,CAACK,YAAY;MAC5B,OAAO,IAAAH,qBAAG;AAC9B;AACA,iDAAiDH,OAAO;AACxD;AACA,qBAAqB;IACL,KAAKC,qBAAc,CAACM,QAAQ;MACxB,OAAO,IAAAJ,qBAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGH,OAAO;AAC3C,qBAAqB;IACL,KAAKC,qBAAc,CAACO,WAAW;MAC3B,OAAO,IAAAL,qBAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGH,OAAO;AAC3C,qBAAqB;IACL;MACI,OAAOS,SAAS;EACxB;AACJ,CAAC;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMM,MAAMC,gCAAgC,GAAAlB,OAAA,CAAAkB,gCAAA,GAAGjB,yBAAM,CAACE,GAA0C;AACjG;AACA;AACA;AACA,MAAM,CAAC;EAAEgB;AAAW,CAAC,KACbA,UAAU,IACV,IAAAR,qBAAG;AACX,0BAA0BQ,UAAU;AACpC;AACA;AACA,SAAS;AACT,CAAC","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopupInsetPosition = exports.POPUP_HORIZONTAL_PADDING = void 0;
7
+ var _popup = require("../../types/popup");
8
+ const POPUP_HORIZONTAL_PADDING = exports.POPUP_HORIZONTAL_PADDING = 23;
9
+ const POPUP_ANCHOR_OFFSET = 13;
10
+ /** Constrain the popup surface while keeping its arrow attached to the trigger. */
11
+ const getPopupInsetPosition = ({
12
+ alignment,
13
+ anchorX,
14
+ boundaryLeft,
15
+ boundaryWidth,
16
+ width
17
+ }) => {
18
+ const isLeft = alignment === _popup.PopupAlignment.TopLeft || alignment === _popup.PopupAlignment.BottomLeft;
19
+ const isCenter = alignment === _popup.PopupAlignment.TopCenter || alignment === _popup.PopupAlignment.BottomCenter;
20
+ let surfaceOffset = -POPUP_ANCHOR_OFFSET;
21
+ if (isLeft) surfaceOffset = POPUP_ANCHOR_OFFSET - width;
22
+ if (isCenter) surfaceOffset = -width / 2;
23
+ const minLeft = boundaryLeft + POPUP_HORIZONTAL_PADDING;
24
+ const maxLeft = Math.max(minLeft, boundaryLeft + boundaryWidth - POPUP_HORIZONTAL_PADDING - width);
25
+ const surfaceLeft = Math.max(minLeft, Math.min(maxLeft, anchorX + surfaceOffset));
26
+ const x = surfaceLeft - surfaceOffset;
27
+ return {
28
+ x,
29
+ offset: isLeft ? x - anchorX : anchorX - x
30
+ };
31
+ };
32
+ exports.getPopupInsetPosition = getPopupInsetPosition;
33
+ //# sourceMappingURL=popupPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popupPosition.js","names":["_popup","require","POPUP_HORIZONTAL_PADDING","exports","POPUP_ANCHOR_OFFSET","getPopupInsetPosition","alignment","anchorX","boundaryLeft","boundaryWidth","width","isLeft","PopupAlignment","TopLeft","BottomLeft","isCenter","TopCenter","BottomCenter","surfaceOffset","minLeft","maxLeft","Math","max","surfaceLeft","min","x","offset"],"sources":["../../../../src/components/popup/popupPosition.ts"],"sourcesContent":["import { PopupAlignment } from '../../types/popup';\n\nexport const POPUP_HORIZONTAL_PADDING = 23;\nconst POPUP_ANCHOR_OFFSET = 13;\n\ninterface PopupInsetPositionOptions {\n alignment: PopupAlignment;\n anchorX: number;\n boundaryLeft: number;\n boundaryWidth: number;\n width: number;\n}\n\n/** Constrain the popup surface while keeping its arrow attached to the trigger. */\nexport const getPopupInsetPosition = ({\n alignment,\n anchorX,\n boundaryLeft,\n boundaryWidth,\n width,\n}: PopupInsetPositionOptions): { x: number; offset: number } => {\n const isLeft = alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;\n const isCenter =\n alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;\n let surfaceOffset = -POPUP_ANCHOR_OFFSET;\n if (isLeft) surfaceOffset = POPUP_ANCHOR_OFFSET - width;\n if (isCenter) surfaceOffset = -width / 2;\n\n const minLeft = boundaryLeft + POPUP_HORIZONTAL_PADDING;\n const maxLeft = Math.max(\n minLeft,\n boundaryLeft + boundaryWidth - POPUP_HORIZONTAL_PADDING - width,\n );\n const surfaceLeft = Math.max(minLeft, Math.min(maxLeft, anchorX + surfaceOffset));\n const x = surfaceLeft - surfaceOffset;\n\n return { x, offset: isLeft ? x - anchorX : anchorX - x };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEO,MAAMC,wBAAwB,GAAAC,OAAA,CAAAD,wBAAA,GAAG,EAAE;AAC1C,MAAME,mBAAmB,GAAG,EAAE;AAU9B;AACO,MAAMC,qBAAqB,GAAGA,CAAC;EAClCC,SAAS;EACTC,OAAO;EACPC,YAAY;EACZC,aAAa;EACbC;AACuB,CAAC,KAAoC;EAC5D,MAAMC,MAAM,GAAGL,SAAS,KAAKM,qBAAc,CAACC,OAAO,IAAIP,SAAS,KAAKM,qBAAc,CAACE,UAAU;EAC9F,MAAMC,QAAQ,GACVT,SAAS,KAAKM,qBAAc,CAACI,SAAS,IAAIV,SAAS,KAAKM,qBAAc,CAACK,YAAY;EACvF,IAAIC,aAAa,GAAG,CAACd,mBAAmB;EACxC,IAAIO,MAAM,EAAEO,aAAa,GAAGd,mBAAmB,GAAGM,KAAK;EACvD,IAAIK,QAAQ,EAAEG,aAAa,GAAG,CAACR,KAAK,GAAG,CAAC;EAExC,MAAMS,OAAO,GAAGX,YAAY,GAAGN,wBAAwB;EACvD,MAAMkB,OAAO,GAAGC,IAAI,CAACC,GAAG,CACpBH,OAAO,EACPX,YAAY,GAAGC,aAAa,GAAGP,wBAAwB,GAAGQ,KAC9D,CAAC;EACD,MAAMa,WAAW,GAAGF,IAAI,CAACC,GAAG,CAACH,OAAO,EAAEE,IAAI,CAACG,GAAG,CAACJ,OAAO,EAAEb,OAAO,GAAGW,aAAa,CAAC,CAAC;EACjF,MAAMO,CAAC,GAAGF,WAAW,GAAGL,aAAa;EAErC,OAAO;IAAEO,CAAC;IAAEC,MAAM,EAAEf,MAAM,GAAGc,CAAC,GAAGlB,OAAO,GAAGA,OAAO,GAAGkB;EAAE,CAAC;AAC5D,CAAC;AAACtB,OAAA,CAAAE,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _popup = require("../../types/popup");
5
+ var _popupPosition = require("./popupPosition");
6
+ const alignments = Object.values(_popup.PopupAlignment).filter(value => typeof value === 'number');
7
+ (0, _vitest.describe)('popup inset positioning', () => {
8
+ _vitest.it.each(alignments)('keeps the surface and arrow aligned within asymmetric bounds for alignment %s', alignment => {
9
+ const isLeft = alignment === _popup.PopupAlignment.TopLeft || alignment === _popup.PopupAlignment.BottomLeft;
10
+ const isCenter = alignment === _popup.PopupAlignment.TopCenter || alignment === _popup.PopupAlignment.BottomCenter;
11
+ [30, 100, 250, 350].forEach(anchorX => {
12
+ const width = 240;
13
+ const position = (0, _popupPosition.getPopupInsetPosition)({
14
+ alignment,
15
+ anchorX,
16
+ width,
17
+ boundaryLeft: 17,
18
+ boundaryWidth: 330
19
+ });
20
+ let surfaceLeft = position.x - 13;
21
+ if (isLeft) surfaceLeft = position.x - width + 13;
22
+ if (isCenter) surfaceLeft = position.x - width / 2;
23
+ (0, _vitest.expect)(surfaceLeft).toBeGreaterThanOrEqual(40);
24
+ (0, _vitest.expect)(surfaceLeft + width).toBeLessThanOrEqual(324);
25
+ const arrowAnchor = isLeft ? position.x - position.offset : position.x + position.offset;
26
+ (0, _vitest.expect)(arrowAnchor).toBe(anchorX);
27
+ });
28
+ });
29
+ (0, _vitest.it)('keeps scroll offsets in the same coordinate space', () => {
30
+ const options = {
31
+ alignment: _popup.PopupAlignment.BottomRight,
32
+ anchorX: 350,
33
+ width: 240,
34
+ boundaryLeft: 17,
35
+ boundaryWidth: 330
36
+ };
37
+ const position = (0, _popupPosition.getPopupInsetPosition)(options);
38
+ const scrolled = (0, _popupPosition.getPopupInsetPosition)({
39
+ ...options,
40
+ anchorX: options.anchorX + 120,
41
+ boundaryLeft: options.boundaryLeft + 120
42
+ });
43
+ (0, _vitest.expect)(scrolled.x).toBe(position.x + 120);
44
+ (0, _vitest.expect)(scrolled.offset).toBe(position.offset);
45
+ });
46
+ });
47
+ //# sourceMappingURL=popupPosition.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popupPosition.test.js","names":["_vitest","require","_popup","_popupPosition","alignments","Object","values","PopupAlignment","filter","value","describe","it","each","alignment","isLeft","TopLeft","BottomLeft","isCenter","TopCenter","BottomCenter","forEach","anchorX","width","position","getPopupInsetPosition","boundaryLeft","boundaryWidth","surfaceLeft","x","expect","toBeGreaterThanOrEqual","toBeLessThanOrEqual","arrowAnchor","offset","toBe","options","BottomRight","scrolled"],"sources":["../../../../src/components/popup/popupPosition.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { PopupAlignment } from '../../types/popup';\nimport { getPopupInsetPosition } from './popupPosition';\n\nconst alignments = Object.values(PopupAlignment).filter(\n (value): value is PopupAlignment => typeof value === 'number',\n);\n\ndescribe('popup inset positioning', () => {\n it.each(alignments)(\n 'keeps the surface and arrow aligned within asymmetric bounds for alignment %s',\n (alignment) => {\n const isLeft =\n alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;\n const isCenter =\n alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;\n [30, 100, 250, 350].forEach((anchorX) => {\n const width = 240;\n const position = getPopupInsetPosition({\n alignment,\n anchorX,\n width,\n boundaryLeft: 17,\n boundaryWidth: 330,\n });\n let surfaceLeft = position.x - 13;\n if (isLeft) surfaceLeft = position.x - width + 13;\n if (isCenter) surfaceLeft = position.x - width / 2;\n expect(surfaceLeft).toBeGreaterThanOrEqual(40);\n expect(surfaceLeft + width).toBeLessThanOrEqual(324);\n const arrowAnchor = isLeft\n ? position.x - position.offset\n : position.x + position.offset;\n expect(arrowAnchor).toBe(anchorX);\n });\n },\n );\n\n it('keeps scroll offsets in the same coordinate space', () => {\n const options = {\n alignment: PopupAlignment.BottomRight,\n anchorX: 350,\n width: 240,\n boundaryLeft: 17,\n boundaryWidth: 330,\n };\n const position = getPopupInsetPosition(options);\n const scrolled = getPopupInsetPosition({\n ...options,\n anchorX: options.anchorX + 120,\n boundaryLeft: options.boundaryLeft + 120,\n });\n expect(scrolled.x).toBe(position.x + 120);\n expect(scrolled.offset).toBe(position.offset);\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACC,qBAAc,CAAC,CAACC,MAAM,CAClDC,KAAK,IAA8B,OAAOA,KAAK,KAAK,QACzD,CAAC;AAED,IAAAC,gBAAQ,EAAC,yBAAyB,EAAE,MAAM;EACtCC,UAAE,CAACC,IAAI,CAACR,UAAU,CAAC,CACf,+EAA+E,EAC9ES,SAAS,IAAK;IACX,MAAMC,MAAM,GACRD,SAAS,KAAKN,qBAAc,CAACQ,OAAO,IAAIF,SAAS,KAAKN,qBAAc,CAACS,UAAU;IACnF,MAAMC,QAAQ,GACVJ,SAAS,KAAKN,qBAAc,CAACW,SAAS,IAAIL,SAAS,KAAKN,qBAAc,CAACY,YAAY;IACvF,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAACC,OAAO,CAAEC,OAAO,IAAK;MACrC,MAAMC,KAAK,GAAG,GAAG;MACjB,MAAMC,QAAQ,GAAG,IAAAC,oCAAqB,EAAC;QACnCX,SAAS;QACTQ,OAAO;QACPC,KAAK;QACLG,YAAY,EAAE,EAAE;QAChBC,aAAa,EAAE;MACnB,CAAC,CAAC;MACF,IAAIC,WAAW,GAAGJ,QAAQ,CAACK,CAAC,GAAG,EAAE;MACjC,IAAId,MAAM,EAAEa,WAAW,GAAGJ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":[]}
@@ -1,14 +1,16 @@
1
1
  import { AnimatePresence } from 'motion/react';
2
- import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
2
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { useUuid } from '../../hooks/uuid';
5
5
  import { PopupAlignment } from '../../types/popup';
6
6
  import AreaContextProvider from '../area-provider/AreaContextProvider';
7
7
  import PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';
8
- import { StyledPopup } from './Popup.styles';
8
+ import { StyledPopup, StyledPopupInsetContent } from './Popup.styles';
9
+ import { getPopupInsetPosition, POPUP_HORIZONTAL_PADDING } from './popupPosition';
9
10
  import { useMeasuredClone } from '../../hooks/element';
10
11
  const Popup = /*#__PURE__*/forwardRef(({
11
12
  alignment,
13
+ boundaryInsets,
12
14
  content,
13
15
  onShow,
14
16
  container,
@@ -33,19 +35,29 @@ const Popup = /*#__PURE__*/forwardRef(({
33
35
  const [portal, setPortal] = useState();
34
36
  const [pseudoSize, setPseudoSize] = useState();
35
37
  const [newContainer, setNewContainer] = useState(container ?? null);
38
+ const [contentMaxWidth, setContentMaxWidth] = useState();
36
39
  const [contentMaxHeight, setContentMaxHeight] = useState(undefined);
37
40
  const timeout = useRef();
38
41
  const previousIsVisibleRef = useRef(false);
39
42
  const uuid = useUuid();
40
43
  const isControlled = typeof isOpen === 'boolean';
41
44
  const isPopupOpen = isControlled ? isOpen : isInternallyOpen;
45
+ const leftInset = Number.isFinite(boundaryInsets?.left) ? Math.max(0, boundaryInsets?.left ?? 0) : 0;
46
+ const rightInset = Number.isFinite(boundaryInsets?.right) ? Math.max(0, boundaryInsets?.right ?? 0) : 0;
47
+ const hasBoundaryInsets = leftInset > 0 || rightInset > 0;
48
+ const shouldWrapContent = boundaryInsets !== undefined;
49
+ const popupContent = useMemo(() => shouldWrapContent ? /*#__PURE__*/React.createElement(StyledPopupInsetContent, {
50
+ style: {
51
+ maxWidth: hasBoundaryInsets ? contentMaxWidth : undefined
52
+ }
53
+ }, content) : content, [content, contentMaxWidth, hasBoundaryInsets, shouldWrapContent]);
42
54
  const {
43
55
  height,
44
56
  width,
45
57
  measuredElement
46
58
  } = useMeasuredClone({
47
- content,
48
- shouldPreventTextWrapping: !shouldUseChildrenWidth
59
+ content: popupContent,
60
+ shouldPreventTextWrapping: !shouldUseChildrenWidth && !hasBoundaryInsets
49
61
  });
50
62
  const popupContentRef = useRef(null);
51
63
  const popupRef = useRef(null);
@@ -72,7 +84,7 @@ const Popup = /*#__PURE__*/forwardRef(({
72
84
  if (!newContainer) {
73
85
  return;
74
86
  }
75
- const HORIZONTAL_PADDING = 23;
87
+ const HORIZONTAL_PADDING = POPUP_HORIZONTAL_PADDING;
76
88
  const {
77
89
  height: pseudoHeight,
78
90
  width: pseudoWidth
@@ -97,44 +109,47 @@ const Popup = /*#__PURE__*/forwardRef(({
97
109
  const y = (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;
98
110
 
99
111
  // Use one coordinate space for all horizontal bounds checks.
100
- const boundaryLeft = element.scrollLeft;
101
- const boundaryWidth = containerWidth / zoomX;
112
+ const boundaryLeft = element.scrollLeft + leftInset;
113
+ const boundaryWidth = Math.max(0, containerWidth / zoomX - leftInset - rightInset);
114
+ setContentMaxWidth(hasBoundaryInsets ? Math.max(0, boundaryWidth - 2 * HORIZONTAL_PADDING) : undefined);
102
115
  const relativeX = x - boundaryLeft;
103
116
  const shouldShowBottom = pseudoHeight > childrenTop - 25 || alignment === PopupAlignment.BottomLeft || alignment === PopupAlignment.BottomRight || alignment === PopupAlignment.BottomCenter;
104
117
  const shouldForceRight = shouldShowBottom ? alignment === PopupAlignment.BottomRight : alignment === PopupAlignment.TopRight;
105
118
  const shouldUseCenterAlignment = shouldShowBottom ? alignment === PopupAlignment.BottomCenter : alignment === PopupAlignment.TopCenter;
106
119
  const hasEnoughSpaceForCenter = pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING && pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;
120
+ let nextAlignment;
121
+ let nextOffset = 0;
107
122
  if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {
108
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter);
109
- setOffset(0);
110
- setCoordinates({
111
- x,
112
- y
113
- });
123
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter;
114
124
  } else {
115
- let isRight = false;
116
- if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {
117
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight);
118
- isRight = true;
119
- } else {
120
- setInternalAlignment(shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft);
121
- }
122
- let newOffset;
125
+ const isRight = pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight;
123
126
  if (isRight) {
124
- newOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
127
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight;
128
+ nextOffset = relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING) : 0;
125
129
  } else {
130
+ nextAlignment = shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft;
126
131
  const right = boundaryWidth - relativeX;
127
- newOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
132
+ nextOffset = right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING) : 0;
128
133
  }
129
- setOffset(newOffset);
130
- const newX = x - newOffset;
131
- setCoordinates({
132
- x: newX,
133
- y
134
- });
135
134
  }
135
+ const position = hasBoundaryInsets ? getPopupInsetPosition({
136
+ alignment: nextAlignment,
137
+ anchorX: x,
138
+ boundaryLeft,
139
+ boundaryWidth,
140
+ width: pseudoWidth
141
+ }) : {
142
+ x: x - nextOffset,
143
+ offset: nextOffset
144
+ };
145
+ setInternalAlignment(nextAlignment);
146
+ setOffset(position.offset);
147
+ setCoordinates({
148
+ x: position.x,
149
+ y
150
+ });
136
151
  }
137
- }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);
152
+ }, [alignment, hasBoundaryInsets, leftInset, newContainer, pseudoSize, rightInset, shouldScrollWithContent, yOffset]);
138
153
  const handleShow = useCallback(() => {
139
154
  updatePopupPosition();
140
155
  if (isControlled) {
@@ -143,16 +158,15 @@ const Popup = /*#__PURE__*/forwardRef(({
143
158
  setIsInternallyOpen(true);
144
159
  }, [isControlled, updatePopupPosition]);
145
160
  useEffect(() => {
146
- if (isControlled) {
147
- if (isOpen) {
148
- updatePopupPosition();
149
- }
150
- return;
151
- }
152
- if (shouldBeOpen) {
161
+ if (!isControlled && shouldBeOpen) {
153
162
  handleShow();
154
163
  }
155
- }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);
164
+ }, [handleShow, isControlled, shouldBeOpen]);
165
+ useEffect(() => {
166
+ if (isPopupOpen) {
167
+ updatePopupPosition();
168
+ }
169
+ }, [isPopupOpen, updatePopupPosition]);
156
170
  const handleReposition = useCallback(() => {
157
171
  if (isPopupOpen) {
158
172
  updatePopupPosition();
@@ -274,8 +288,8 @@ const Popup = /*#__PURE__*/forwardRef(({
274
288
  onMouseEnter: handleMouseEnter
275
289
  }, /*#__PURE__*/React.createElement(AreaContextProvider, {
276
290
  shouldChangeColor: true
277
- }, content))), newContainer));
278
- }, [contentMaxHeight, internalAlignment, newContainer, content, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize?.width, uuid, shouldScrollWithContent]);
291
+ }, popupContent))), newContainer));
292
+ }, [contentMaxHeight, internalAlignment, newContainer, popupContent, coordinates, handleMouseEnter, handleMouseLeave, isPopupOpen, offset, pseudoSize?.width, uuid, shouldScrollWithContent]);
279
293
  return /*#__PURE__*/React.createElement(React.Fragment, null, measuredElement, /*#__PURE__*/React.createElement(StyledPopup, {
280
294
  className: "beta-chayns-popup",
281
295
  ref: popupRef,
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","useMeasuredClone","Popup","alignment","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","previousIsVisibleRef","uuid","isControlled","isPopupOpen","height","width","measuredElement","shouldPreventTextWrapping","popupContentRef","popupRef","current","el","element","closest","Element","updatePopupPosition","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","contains","target","handleDocumentKeyDown","key","hide","show","createElement","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName"],"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 },\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DgH,mBAAmB,EAAE9G;EAAmB,GAEvCN,QACQ,CAAC,EACbqB,MACH,CAAC;AAEX,CACJ,CAAC;AAED3B,KAAK,CAAC2H,WAAW,GAAG,OAAO;AAE3B,eAAe3H,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Popup.js","names":["AnimatePresence","React","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","createPortal","useUuid","PopupAlignment","AreaContextProvider","PopupContentWrapper","StyledPopup","StyledPopupInsetContent","getPopupInsetPosition","POPUP_HORIZONTAL_PADDING","useMeasuredClone","Popup","alignment","boundaryInsets","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","x","y","internalAlignment","setInternalAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxWidth","setContentMaxWidth","contentMaxHeight","setContentMaxHeight","undefined","timeout","previousIsVisibleRef","uuid","isControlled","isPopupOpen","leftInset","Number","isFinite","left","Math","max","rightInset","right","hasBoundaryInsets","shouldWrapContent","popupContent","createElement","style","maxWidth","height","width","measuredElement","shouldPreventTextWrapping","popupContentRef","popupRef","current","el","element","closest","Element","updatePopupPosition","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","anchorX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","contains","target","handleDocumentKeyDown","key","hide","show","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName"],"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 >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAc;AAC9C,OAAOC,KAAK,IACRC,UAAU,EAEVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACL,OAAO;AACd,SAASC,YAAY,QAAQ,WAAW;AACxC,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,cAAc,QAAoC,mBAAmB;AAC9E,OAAOC,mBAAmB,MAAM,sCAAs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KAAK,CAAC2I,WAAW,GAAG,OAAO;AAE3B,eAAe3I,KAAK","ignoreList":[]}
@@ -27,4 +27,14 @@ export const StyledPopupPseudo = styled.div`
27
27
  opacity: 0;
28
28
  position: absolute;
29
29
  `;
30
+
31
+ // Apply the same wrapping constraint to the measured clone and the visible content.
32
+ export const StyledPopupInsetContent = styled.div`
33
+ overflow-wrap: anywhere;
34
+
35
+ > * {
36
+ box-sizing: border-box;
37
+ max-width: 100%;
38
+ }
39
+ `;
30
40
  //# sourceMappingURL=Popup.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.styles.js","names":["styled","css","StyledPopup","span","$shouldUseFullWidth","$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 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"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,IAAsB;AACxD;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAoB,CAAC,KACtBA,mBAAmB,IACnBH,GAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEI;AAAwB,CAAC,KAC1BA,uBAAuB,IACvBJ,GAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMK,iBAAiB,GAAGN,MAAM,CAACO,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":["styled","css","StyledPopup","span","$shouldUseFullWidth","$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 StyledPopupInsetContent = styled.div`\n overflow-wrap: anywhere;\n\n > * {\n box-sizing: border-box;\n max-width: 100%;\n }\n`;\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAQ/C,OAAO,MAAMC,WAAW,GAAGF,MAAM,CAACG,IAAsB;AACxD;AACA;AACA;AACA,MAAM,CAAC;EAAEC;AAAoB,CAAC,KACtBA,mBAAmB,IACnBH,GAAG;AACX;AACA,SAAS;AACT;AACA,MAAM,CAAC;EAAEI;AAAwB,CAAC,KAC1BA,uBAAuB,IACvBJ,GAAG;AACX;AACA;AACA;AACA,SAAS;AACT,CAAC;AAED,OAAO,MAAMK,iBAAiB,GAAGN,MAAM,CAACO,GAEtC;AACF,WAAW,CAAC;EAAEC;AAAY,CAAC,KAAK,GAAGA,WAAW,GAAG,CAAC,IAAI;AACtD;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,uBAAuB,GAAGT,MAAM,CAACO,GAAG;AACjD;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}