@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,254 @@
1
+ import { act, fireEvent, render, waitFor } from '@testing-library/react';
2
+ import React, { StrictMode } from 'react';
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
+ import { PopupAlignment } from '../../types/popup';
5
+ import Popup from './Popup';
6
+ const measurement = vi.hoisted(() => ({
7
+ width: 250,
8
+ height: 90
9
+ }));
10
+ vi.mock('../../hooks/element', () => ({
11
+ useMeasuredClone: () => ({
12
+ ...measurement,
13
+ measuredElement: null
14
+ })
15
+ }));
16
+ vi.mock('chayns-api', () => ({
17
+ useSite: () => ({
18
+ colorMode: 0
19
+ })
20
+ }));
21
+ vi.mock('./popup-content-wrapper/PopupContentWrapper', () => {
22
+ const PopupSurface = /*#__PURE__*/React.forwardRef(({
23
+ children,
24
+ coordinates,
25
+ offset,
26
+ alignment,
27
+ width
28
+ }, ref) => /*#__PURE__*/React.createElement("div", {
29
+ ref: ref,
30
+ "data-surface": true,
31
+ "data-x": coordinates.x,
32
+ "data-y": coordinates.y,
33
+ "data-offset": offset,
34
+ "data-alignment": alignment,
35
+ "data-width": width
36
+ }, children));
37
+ PopupSurface.displayName = 'PopupSurface';
38
+ return {
39
+ default: PopupSurface
40
+ };
41
+ });
42
+ let container;
43
+ let triggerLeft;
44
+ let containerWidth;
45
+ let containerLeft;
46
+ let zoom;
47
+ let getRect;
48
+ const content = /*#__PURE__*/React.createElement("p", null, "Popup hint");
49
+ const surface = () => {
50
+ const element = document.querySelector('[data-surface]');
51
+ if (!element) throw new Error('Popup surface missing');
52
+ return element;
53
+ };
54
+ const number = name => Number(surface().dataset[name]);
55
+ const popup = (props = {}, isControlled = true) => /*#__PURE__*/React.createElement(StrictMode, null, /*#__PURE__*/React.createElement(Popup, {
56
+ content: content,
57
+ container: container,
58
+ isOpen: isControlled ? true : undefined,
59
+ shouldUseChildrenWidth: true,
60
+ alignment: props.alignment,
61
+ boundaryInsets: props.boundaryInsets,
62
+ shouldScrollWithContent: props.shouldScrollWithContent,
63
+ onShow: props.onShow,
64
+ onHide: props.onHide
65
+ }, /*#__PURE__*/React.createElement("button", {
66
+ type: "button"
67
+ }, "Trigger")));
68
+ beforeEach(() => {
69
+ triggerLeft = 270;
70
+ containerWidth = 390;
71
+ containerLeft = 0;
72
+ zoom = 1;
73
+ measurement.width = 250;
74
+ measurement.height = 90;
75
+ container = document.createElement('div');
76
+ document.body.append(container);
77
+ Object.defineProperty(container, 'offsetWidth', {
78
+ get: () => containerWidth / zoom
79
+ });
80
+ Object.defineProperty(container, 'offsetHeight', {
81
+ value: 800
82
+ });
83
+ Object.defineProperty(container, 'clientHeight', {
84
+ value: 800
85
+ });
86
+ getRect = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function getFixtureRect() {
87
+ if (this === container) return new DOMRect(containerLeft, 0, containerWidth, 800);
88
+ return new DOMRect(triggerLeft, 20, 26, 26);
89
+ });
90
+ });
91
+ afterEach(() => {
92
+ container.remove();
93
+ vi.restoreAllMocks();
94
+ });
95
+ describe('Popup boundary insets', () => {
96
+ it('preserves the legacy position when omitted or zero', async () => {
97
+ const {
98
+ rerender
99
+ } = render(popup());
100
+ await waitFor(() => expect(number('x')).toBe(283));
101
+ expect(number('offset')).toBe(0);
102
+ const before = {
103
+ ...surface().dataset
104
+ };
105
+ rerender(popup({
106
+ boundaryInsets: {
107
+ left: 0,
108
+ right: 0
109
+ }
110
+ }));
111
+ expect({
112
+ ...surface().dataset
113
+ }).toEqual(before);
114
+ });
115
+ it('updates an open popup when only its insets change and restores its position', async () => {
116
+ triggerLeft = 320;
117
+ const onShow = vi.fn();
118
+ const onHide = vi.fn();
119
+ const {
120
+ rerender
121
+ } = render(popup({
122
+ onShow,
123
+ onHide
124
+ }));
125
+ await waitFor(() => expect(number('x')).toBe(333));
126
+ rerender(popup({
127
+ boundaryInsets: {
128
+ left: 17,
129
+ right: 43
130
+ },
131
+ onShow,
132
+ onHide
133
+ }));
134
+ await waitFor(() => expect(number('x')).toBe(311));
135
+ expect(number('alignment')).toBe(PopupAlignment.BottomLeft);
136
+ expect(number('offset')).toBe(-22);
137
+ expect(surface().firstElementChild).toHaveStyle({
138
+ maxWidth: '284px'
139
+ });
140
+ rerender(popup({
141
+ onShow,
142
+ onHide
143
+ }));
144
+ await waitFor(() => expect(number('x')).toBe(333));
145
+ expect(onShow).toHaveBeenCalledTimes(1);
146
+ expect(onHide).not.toHaveBeenCalled();
147
+ });
148
+ it('shifts right-aligned popups left and keeps the arrow at the trigger', async () => {
149
+ render(popup({
150
+ boundaryInsets: {
151
+ right: 59
152
+ },
153
+ alignment: PopupAlignment.BottomRight
154
+ }));
155
+ await waitFor(() => expect(number('x')).toBe(71));
156
+ expect(number('offset')).toBe(212);
157
+ expect(number('x') + number('offset')).toBe(283);
158
+ });
159
+ it('repositions on scrolling and rotation in scaled, offset containers', async () => {
160
+ zoom = 2;
161
+ containerLeft = 100;
162
+ containerWidth = 780;
163
+ triggerLeft = 700;
164
+ const {
165
+ unmount
166
+ } = render(popup({
167
+ boundaryInsets: {
168
+ right: 59
169
+ }
170
+ }));
171
+ await waitFor(() => expect(number('x')).toBe(295));
172
+ act(() => {
173
+ container.scrollLeft = 80;
174
+ fireEvent.scroll(container);
175
+ });
176
+ await waitFor(() => expect(number('x')).toBe(375));
177
+ act(() => {
178
+ containerWidth = 1000;
179
+ fireEvent.resize(window);
180
+ });
181
+ await waitFor(() => expect(surface().firstElementChild).toHaveStyle({
182
+ maxWidth: '395px'
183
+ }));
184
+ const remove = vi.spyOn(window, 'removeEventListener');
185
+ unmount();
186
+ expect(remove).toHaveBeenCalledWith('resize', expect.any(Function));
187
+ expect(remove).toHaveBeenCalledWith('scroll', expect.any(Function), true);
188
+ });
189
+ it('uses body geometry for fixed popups', async () => {
190
+ Object.defineProperty(document.body, 'offsetWidth', {
191
+ configurable: true,
192
+ value: 390
193
+ });
194
+ Object.defineProperty(document.body, 'offsetHeight', {
195
+ configurable: true,
196
+ value: 800
197
+ });
198
+ getRect.mockImplementation(function getBodyRect() {
199
+ return this === document.body ? new DOMRect(0, 0, 390, 800) : new DOMRect(320, 20, 26, 26);
200
+ });
201
+ render(popup({
202
+ shouldScrollWithContent: false,
203
+ boundaryInsets: {
204
+ right: 59
205
+ }
206
+ }));
207
+ await waitFor(() => expect(number('x')).toBe(295));
208
+ });
209
+ it('updates an uncontrolled open popup when insets change or are removed', async () => {
210
+ triggerLeft = 320;
211
+ const {
212
+ getByRole,
213
+ rerender
214
+ } = render(popup({}, false));
215
+ fireEvent.click(getByRole('button', {
216
+ name: 'Trigger'
217
+ }));
218
+ await waitFor(() => expect(number('x')).toBe(333));
219
+ rerender(popup({
220
+ boundaryInsets: {
221
+ right: 59
222
+ }
223
+ }, false));
224
+ await waitFor(() => expect(number('x')).toBe(295));
225
+ rerender(popup({}, false));
226
+ await waitFor(() => expect(number('x')).toBe(333));
227
+ });
228
+ it('retains content when configured insets change between zero and nonzero', async () => {
229
+ const {
230
+ rerender
231
+ } = render(popup({
232
+ boundaryInsets: {
233
+ left: 0,
234
+ right: 0
235
+ }
236
+ }));
237
+ await waitFor(() => expect(number('x')).toBe(283));
238
+ const paragraph = surface().querySelector('p');
239
+ rerender(popup({
240
+ boundaryInsets: {
241
+ right: 59
242
+ }
243
+ }));
244
+ expect(surface().querySelector('p')).toBe(paragraph);
245
+ rerender(popup({
246
+ boundaryInsets: {
247
+ right: 0
248
+ }
249
+ }));
250
+ expect(surface().querySelector('p')).toBe(paragraph);
251
+ expect(surface().firstElementChild?.getAttribute('style') ?? '').not.toContain('max-width');
252
+ });
253
+ });
254
+ //# sourceMappingURL=Popup.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Popup.test.js","names":["act","fireEvent","render","waitFor","React","StrictMode","afterEach","beforeEach","describe","expect","it","vi","PopupAlignment","Popup","measurement","hoisted","width","height","mock","useMeasuredClone","measuredElement","useSite","colorMode","PopupSurface","forwardRef","children","coordinates","offset","alignment","ref","createElement","x","y","displayName","default","container","triggerLeft","containerWidth","containerLeft","zoom","getRect","content","surface","element","document","querySelector","Error","number","name","Number","dataset","popup","props","isControlled","isOpen","undefined","shouldUseChildrenWidth","boundaryInsets","shouldScrollWithContent","onShow","onHide","type","body","append","Object","defineProperty","get","value","spyOn","HTMLElement","prototype","mockImplementation","getFixtureRect","DOMRect","remove","restoreAllMocks","rerender","toBe","before","left","right","toEqual","fn","BottomLeft","firstElementChild","toHaveStyle","maxWidth","toHaveBeenCalledTimes","not","toHaveBeenCalled","BottomRight","unmount","scrollLeft","scroll","resize","window","toHaveBeenCalledWith","any","Function","configurable","getBodyRect","getByRole","click","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,SAASA,GAAG,EAAEC,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,wBAAwB;AACxE,OAAOC,KAAK,IAAoBC,UAAU,QAAQ,OAAO;AACzD,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAA2B,QAAQ;AAC3F,SAASC,cAAc,QAAQ,mBAAmB;AAClD,OAAOC,KAAK,MAA2B,SAAS;AAEhD,MAAMC,WAAW,GAAGH,EAAE,CAACI,OAAO,CAAC,OAAO;EAAEC,KAAK,EAAE,GAAG;EAAEC,MAAM,EAAE;AAAG,CAAC,CAAC,CAAC;AAClEN,EAAE,CAACO,IAAI,CAAC,qBAAqB,EAAE,OAAO;EAClCC,gBAAgB,EAAEA,CAAA,MAAO;IAAE,GAAGL,WAAW;IAAEM,eAAe,EAAE;EAAK,CAAC;AACtE,CAAC,CAAC,CAAC;AACHT,EAAE,CAACO,IAAI,CAAC,YAAY,EAAE,OAAO;EAAEG,OAAO,EAAEA,CAAA,MAAO;IAAEC,SAAS,EAAE;EAAE,CAAC;AAAE,CAAC,C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M0B,SAAS,GAAG7D,OAAO,CAAC,CAAC,CAACG,aAAa,CAAC,GAAG,CAAC;IAC9C+B,QAAQ,CAACzB,KAAK,CAAC;MAAEM,cAAc,EAAE;QAAEuB,KAAK,EAAE;MAAG;IAAE,CAAC,CAAC,CAAC;IAClDvE,MAAM,CAACiC,OAAO,CAAC,CAAC,CAACG,aAAa,CAAC,GAAG,CAAC,CAAC,CAACgC,IAAI,CAAC0B,SAAS,CAAC;IACpD3B,QAAQ,CAACzB,KAAK,CAAC;MAAEM,cAAc,EAAE;QAAEuB,KAAK,EAAE;MAAE;IAAE,CAAC,CAAC,CAAC;IACjDvE,MAAM,CAACiC,OAAO,CAAC,CAAC,CAACG,aAAa,CAAC,GAAG,CAAC,CAAC,CAACgC,IAAI,CAAC0B,SAAS,CAAC;IACpD9F,MAAM,CAACiC,OAAO,CAAC,CAAC,CAAC0C,iBAAiB,EAAEoB,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAChB,GAAG,CAACiB,SAAS,CAAC,WAAW,CAAC;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":[]}
@@ -47,13 +47,13 @@ export const StyledMotionPopupContentWrapper = styled(motion.div)`
47
47
  case PopupAlignment.TopCenter:
48
48
  return css`
49
49
  bottom: -7px;
50
- left: calc(50% - 7px);
50
+ left: calc(50% - 7px + ${$offset}px);
51
51
  transform: rotate(45deg);
52
52
  `;
53
53
  case PopupAlignment.BottomCenter:
54
54
  return css`
55
55
  top: -7px;
56
- left: calc(50% - 7px);
56
+ left: calc(50% - 7px + ${$offset}px);
57
57
  transform: rotate(225deg);
58
58
  `;
59
59
  case PopupAlignment.TopRight:
@@ -1 +1 @@
1
- {"version":3,"file":"PopupContentWrapper.styles.js","names":["motion","styled","css","PopupAlignment","StyledMotionPopupContentWrapper","div","theme","text","$shouldScrollWithContent","$position","$offset","TopLeft","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,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,cAAc,QAAQ,sBAAsB;AAUrD,OAAO,MAAMC,+BAA+B,GAAGH,MAAM,CACjDD,MAAM,CAACK,GACX,CAAuC;AACvC,wBAAwB,CAAC;EAAEC;AAA4C,CAAC,KAAKA,KAAK,CAAC,KAAK,CAAC;AACzF;AACA;AACA,aAAa,CAAC;EAAEA;AAA4C,CAAC,KAAKA,KAAK,CAACC,IAAI;AAC5E;AACA,gBAAgB,CAAC;EAAEC;AAAyB,CAAC,KACrCA,wBAAwB,GAAG,UAAU,GAAG,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,CAAC;EAAEC,SAAS;EAAEC;AAAQ,CAAC,KAAK;EAC1B,QAAQD,SAAS;IACb,KAAKN,cAAc,CAACQ,OAAO;MACvB,OAAOT,GAAG;AAC9B;AACA,iCAAiC,CAAC,GAAGQ,OAAO;AAC5C;AACA,qBAAqB;IACL,KAAKP,cAAc,CAACS,UAAU;MAC1B,OAAOV,GAAG;AAC9B;AACA,iCAAiC,CAAC,GAAGQ,OAAO;AAC5C;AACA,qBAAqB;IACL,KAAKP,cAAc,CAACU,SAAS;MACzB,OAAOX,GAAG;AAC9B;AACA;AACA;AACA,qBAAqB;IACL,KAAKC,cAAc,CAACW,YAAY;MAC5B,OAAOZ,GAAG;AAC9B;AACA;AACA;AACA,qBAAqB;IACL,KAAKC,cAAc,CAACY,QAAQ;MACxB,OAAOb,GAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGQ,OAAO;AAC3C,qBAAqB;IACL,KAAKP,cAAc,CAACa,WAAW;MAC3B,OAAOd,GAAG;AAC9B;AACA;AACA,gCAAgC,CAAC,GAAGQ,OAAO;AAC3C,qBAAqB;IACL;MACI,OAAOO,SAAS;EACxB;AACJ,CAAC;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAMD,OAAO,MAAMC,gCAAgC,GAAGjB,MAAM,CAACI,GAA0C;AACjG;AACA;AACA;AACA,MAAM,CAAC;EAAEc;AAAW,CAAC,KACbA,UAAU,IACVjB,GAAG;AACX,0BAA0BiB,UAAU;AACpC;AACA;AACA,SAAS;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"PopupContentWrapper.styles.js","names":["motion","styled","css","PopupAlignment","StyledMotionPopupContentWrapper","div","theme","text","$shouldScrollWithContent","$position","$offset","TopLeft","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,SAASA,MAAM,QAAQ,cAAc;AACrC,OAAOC,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAC/C,SAASC,cAAc,QAAQ,sBAAsB;AAUrD,OAAO,MAAMC,+BAA+B,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AACjG;AACA;AACA;AACA,MAAM,CAAC;EAAEc;AAAW,CAAC,KACbA,UAAU,IACVjB,GAAG;AACX,0BAA0BiB,UAAU;AACpC;AACA;AACA,SAAS;AACT,CAAC","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ import { PopupAlignment } from '../../types/popup';
2
+ export const POPUP_HORIZONTAL_PADDING = 23;
3
+ const POPUP_ANCHOR_OFFSET = 13;
4
+ /** Constrain the popup surface while keeping its arrow attached to the trigger. */
5
+ export const getPopupInsetPosition = ({
6
+ alignment,
7
+ anchorX,
8
+ boundaryLeft,
9
+ boundaryWidth,
10
+ width
11
+ }) => {
12
+ const isLeft = alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;
13
+ const isCenter = alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;
14
+ let surfaceOffset = -POPUP_ANCHOR_OFFSET;
15
+ if (isLeft) surfaceOffset = POPUP_ANCHOR_OFFSET - width;
16
+ if (isCenter) surfaceOffset = -width / 2;
17
+ const minLeft = boundaryLeft + POPUP_HORIZONTAL_PADDING;
18
+ const maxLeft = Math.max(minLeft, boundaryLeft + boundaryWidth - POPUP_HORIZONTAL_PADDING - width);
19
+ const surfaceLeft = Math.max(minLeft, Math.min(maxLeft, anchorX + surfaceOffset));
20
+ const x = surfaceLeft - surfaceOffset;
21
+ return {
22
+ x,
23
+ offset: isLeft ? x - anchorX : anchorX - x
24
+ };
25
+ };
26
+ //# sourceMappingURL=popupPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popupPosition.js","names":["PopupAlignment","POPUP_HORIZONTAL_PADDING","POPUP_ANCHOR_OFFSET","getPopupInsetPosition","alignment","anchorX","boundaryLeft","boundaryWidth","width","isLeft","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,SAASA,cAAc,QAAQ,mBAAmB;AAElD,OAAO,MAAMC,wBAAwB,GAAG,EAAE;AAC1C,MAAMC,mBAAmB,GAAG,EAAE;AAU9B;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAC;EAClCC,SAAS;EACTC,OAAO;EACPC,YAAY;EACZC,aAAa;EACbC;AACuB,CAAC,KAAoC;EAC5D,MAAMC,MAAM,GAAGL,SAAS,KAAKJ,cAAc,CAACU,OAAO,IAAIN,SAAS,KAAKJ,cAAc,CAACW,UAAU;EAC9F,MAAMC,QAAQ,GACVR,SAAS,KAAKJ,cAAc,CAACa,SAAS,IAAIT,SAAS,KAAKJ,cAAc,CAACc,YAAY;EACvF,IAAIC,aAAa,GAAG,CAACb,mBAAmB;EACxC,IAAIO,MAAM,EAAEM,aAAa,GAAGb,mBAAmB,GAAGM,KAAK;EACvD,IAAII,QAAQ,EAAEG,aAAa,GAAG,CAACP,KAAK,GAAG,CAAC;EAExC,MAAMQ,OAAO,GAAGV,YAAY,GAAGL,wBAAwB;EACvD,MAAMgB,OAAO,GAAGC,IAAI,CAACC,GAAG,CACpBH,OAAO,EACPV,YAAY,GAAGC,aAAa,GAAGN,wBAAwB,GAAGO,KAC9D,CAAC;EACD,MAAMY,WAAW,GAAGF,IAAI,CAACC,GAAG,CAACH,OAAO,EAAEE,IAAI,CAACG,GAAG,CAACJ,OAAO,EAAEZ,OAAO,GAAGU,aAAa,CAAC,CAAC;EACjF,MAAMO,CAAC,GAAGF,WAAW,GAAGL,aAAa;EAErC,OAAO;IAAEO,CAAC;IAAEC,MAAM,EAAEd,MAAM,GAAGa,CAAC,GAAGjB,OAAO,GAAGA,OAAO,GAAGiB;EAAE,CAAC;AAC5D,CAAC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { PopupAlignment } from '../../types/popup';
3
+ import { getPopupInsetPosition } from './popupPosition';
4
+ const alignments = Object.values(PopupAlignment).filter(value => typeof value === 'number');
5
+ describe('popup inset positioning', () => {
6
+ it.each(alignments)('keeps the surface and arrow aligned within asymmetric bounds for alignment %s', alignment => {
7
+ const isLeft = alignment === PopupAlignment.TopLeft || alignment === PopupAlignment.BottomLeft;
8
+ const isCenter = alignment === PopupAlignment.TopCenter || alignment === PopupAlignment.BottomCenter;
9
+ [30, 100, 250, 350].forEach(anchorX => {
10
+ const width = 240;
11
+ const position = getPopupInsetPosition({
12
+ alignment,
13
+ anchorX,
14
+ width,
15
+ boundaryLeft: 17,
16
+ boundaryWidth: 330
17
+ });
18
+ let surfaceLeft = position.x - 13;
19
+ if (isLeft) surfaceLeft = position.x - width + 13;
20
+ if (isCenter) surfaceLeft = position.x - width / 2;
21
+ expect(surfaceLeft).toBeGreaterThanOrEqual(40);
22
+ expect(surfaceLeft + width).toBeLessThanOrEqual(324);
23
+ const arrowAnchor = isLeft ? position.x - position.offset : position.x + position.offset;
24
+ expect(arrowAnchor).toBe(anchorX);
25
+ });
26
+ });
27
+ it('keeps scroll offsets in the same coordinate space', () => {
28
+ const options = {
29
+ alignment: PopupAlignment.BottomRight,
30
+ anchorX: 350,
31
+ width: 240,
32
+ boundaryLeft: 17,
33
+ boundaryWidth: 330
34
+ };
35
+ const position = getPopupInsetPosition(options);
36
+ const scrolled = getPopupInsetPosition({
37
+ ...options,
38
+ anchorX: options.anchorX + 120,
39
+ boundaryLeft: options.boundaryLeft + 120
40
+ });
41
+ expect(scrolled.x).toBe(position.x + 120);
42
+ expect(scrolled.offset).toBe(position.offset);
43
+ });
44
+ });
45
+ //# sourceMappingURL=popupPosition.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popupPosition.test.js","names":["describe","expect","it","PopupAlignment","getPopupInsetPosition","alignments","Object","values","filter","value","each","alignment","isLeft","TopLeft","BottomLeft","isCenter","TopCenter","BottomCenter","forEach","anchorX","width","position","boundaryLeft","boundaryWidth","surfaceLeft","x","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,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,qBAAqB,QAAQ,iBAAiB;AAEvD,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,cAAc,CAAC,CAACK,MAAM,CAClDC,KAAK,IAA8B,OAAOA,KAAK,KAAK,QACzD,CAAC;AAEDT,QAAQ,CAAC,yBAAyB,EAAE,MAAM;EACtCE,EAAE,CAACQ,IAAI,CAACL,UAAU,CAAC,CACf,+EAA+E,EAC9EM,SAAS,IAAK;IACX,MAAMC,MAAM,GACRD,SAAS,KAAKR,cAAc,CAACU,OAAO,IAAIF,SAAS,KAAKR,cAAc,CAACW,UAAU;IACnF,MAAMC,QAAQ,GACVJ,SAAS,KAAKR,cAAc,CAACa,SAAS,IAAIL,SAAS,KAAKR,cAAc,CAACc,YAAY;IACvF,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAACC,OAAO,CAAEC,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G;IACzC,CAAC,CAAC;IACFrB,MAAM,CAACgC,QAAQ,CAACR,CAAC,CAAC,CAACK,IAAI,CAACT,QAAQ,CAACI,CAAC,GAAG,GAAG,CAAC;IACzCxB,MAAM,CAACgC,QAAQ,CAACJ,MAAM,CAAC,CAACC,IAAI,CAACT,QAAQ,CAACQ,MAAM,CAAC;EACjD,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
@@ -11,4 +11,7 @@ export declare const StyledPopupPseudo: import("styled-components/dist/types").I
11
11
  }, {
12
12
  $menuHeight: number;
13
13
  }>> & string;
14
+ export declare const StyledPopupInsetContent: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
15
+ style?: React.CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
16
+ }> & string;
14
17
  export {};
@@ -21,6 +21,22 @@ export type PopupProps = {
21
21
  * @optional
22
22
  */
23
23
  children?: ReactNode;
24
+ /**
25
+ * Additional horizontal insets inside the positioning container, in CSS pixels.
26
+ * @description
27
+ * Reserve space for safe areas or host controls without moving the trigger. Each side defaults
28
+ * to zero and is added to the standard popup edge spacing. Insets use the positioning container's
29
+ * unscaled coordinate space; fixed popups use the document body. Updating the values repositions
30
+ * an open popup. Oversized content is constrained to the remaining width and allowed to wrap.
31
+ * @default { left: 0, right: 0 }
32
+ * @example
33
+ * <Popup boundaryInsets={{ left: 17, right: 43 }} content="Details">Open</Popup>
34
+ * @optional
35
+ */
36
+ boundaryInsets?: {
37
+ left?: number;
38
+ right?: number;
39
+ };
24
40
  /**
25
41
  * The DOM element that should receive the popup portal.
26
42
  * @description
@@ -0,0 +1,15 @@
1
+ import { PopupAlignment } from '../../types/popup';
2
+ export declare const POPUP_HORIZONTAL_PADDING = 23;
3
+ interface PopupInsetPositionOptions {
4
+ alignment: PopupAlignment;
5
+ anchorX: number;
6
+ boundaryLeft: number;
7
+ boundaryWidth: number;
8
+ width: number;
9
+ }
10
+ /** Constrain the popup surface while keeping its arrow attached to the trigger. */
11
+ export declare const getPopupInsetPosition: ({ alignment, anchorX, boundaryLeft, boundaryWidth, width, }: PopupInsetPositionOptions) => {
12
+ x: number;
13
+ offset: number;
14
+ };
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chayns-components/core",
3
- "version": "5.6.11",
3
+ "version": "5.6.12",
4
4
  "description": "A set of beautiful React components for developing your own applications with chayns.",
5
5
  "sideEffects": false,
6
6
  "browserslist": [
@@ -93,5 +93,5 @@
93
93
  "publishConfig": {
94
94
  "access": "public"
95
95
  },
96
- "gitHead": "4b9760582fb8529d7037577b1ea76e9d6ee8f17f"
96
+ "gitHead": "c6d6890a4da8f52747fc279c13e53af0fd424a15"
97
97
  }