@nectary/components 0.40.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/accordion-item/index.js +4 -0
  2. package/action-menu/index.js +11 -13
  3. package/action-menu-option/index.js +2 -1
  4. package/button/index.js +5 -1
  5. package/button/types.d.ts +1 -1
  6. package/checkbox/index.js +4 -0
  7. package/chip/index.js +18 -15
  8. package/chip/types.d.ts +3 -4
  9. package/color-menu/index.d.ts +1 -0
  10. package/color-menu/index.js +37 -51
  11. package/color-menu/types.d.ts +5 -6
  12. package/color-menu/utils.d.ts +1 -0
  13. package/color-menu/utils.js +15 -0
  14. package/color-swatch/index.js +8 -7
  15. package/color-swatch/types.d.ts +3 -4
  16. package/colors.json +14 -10
  17. package/date-picker/index.js +1 -1
  18. package/field/index.js +22 -5
  19. package/file-drop/index.js +1 -1
  20. package/file-picker/index.js +1 -1
  21. package/help-tooltip/index.js +10 -27
  22. package/icon-button/index.d.ts +1 -0
  23. package/icon-button/index.js +26 -15
  24. package/icon-button/types.d.ts +16 -2
  25. package/input/index.js +4 -0
  26. package/link/index.js +5 -1
  27. package/package.json +1 -1
  28. package/pagination/index.js +4 -0
  29. package/pop/index.d.ts +11 -0
  30. package/pop/index.js +429 -0
  31. package/pop/types.d.ts +35 -0
  32. package/pop/utils.d.ts +7 -0
  33. package/pop/utils.js +18 -0
  34. package/popover/index.d.ts +1 -0
  35. package/popover/index.js +91 -230
  36. package/popover/types.d.ts +8 -1
  37. package/popover/utils.d.ts +5 -0
  38. package/popover/utils.js +17 -1
  39. package/radio-option/index.js +4 -0
  40. package/segment-collapse/index.js +4 -0
  41. package/segmented-control-option/index.js +5 -1
  42. package/segmented-icon-control-option/index.js +5 -1
  43. package/select-button/index.js +6 -1
  44. package/select-menu/index.js +12 -13
  45. package/tabs-option/index.js +4 -0
  46. package/tag/index.js +13 -15
  47. package/tag/types.d.ts +3 -4
  48. package/textarea/index.js +4 -0
  49. package/theme.css +76 -10
  50. package/tile-control-option/index.js +5 -1
  51. package/time-picker/index.js +1 -1
  52. package/toggle/index.js +5 -1
  53. package/tooltip/index.d.ts +2 -0
  54. package/tooltip/index.js +160 -17
  55. package/tooltip/types.d.ts +13 -0
  56. package/tooltip/utils.d.ts +5 -0
  57. package/tooltip/utils.js +25 -1
  58. package/types.d.ts +0 -7
  59. package/utils/animation.d.ts +17 -0
  60. package/utils/animation.js +142 -0
  61. package/utils/colors.d.ts +4 -9
  62. package/utils/colors.js +4 -120
  63. package/utils/context.d.ts +15 -0
  64. package/utils/context.js +57 -0
  65. package/utils/index.d.ts +5 -9
  66. package/utils/index.js +49 -50
  67. package/dropdown-checkbox-option/index.d.ts +0 -11
  68. package/dropdown-checkbox-option/index.js +0 -74
  69. package/dropdown-checkbox-option/types.d.ts +0 -15
  70. package/dropdown-radio-option/index.d.ts +0 -11
  71. package/dropdown-radio-option/index.js +0 -74
  72. package/dropdown-radio-option/types.d.ts +0 -15
  73. package/dropdown-radio-option/types.js +0 -1
  74. /package/{dropdown-checkbox-option → pop}/types.js +0 -0
package/pop/index.js ADDED
@@ -0,0 +1,429 @@
1
+ import dialogPolyfill from 'dialog-polyfill';
2
+ import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, updateLiteralAttribute, getReactEventHandler, updateBooleanAttribute, NectaryElement, throttleAnimationFrame, isElementFocused, updateIntegerAttribute, getIntegerAttribute, getFirstFocusableElement, getFirstSlotElement } from '../utils';
3
+ import { Context, dispatchContextConnectEvent, dispatchContextDisconnectEvent } from '../utils/context';
4
+ const templateHTML = '<style>:host{display:contents;position:relative}dialog{position:fixed;left:0;top:0;margin:0;outline:0;padding:0;border:none;box-sizing:border-box;max-width:unset;max-height:unset;z-index:1;background:0 0;overflow:visible}dialog:not([open]){display:none}dialog::backdrop{background-color:transparent}dialog+.backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background-color:transparent}dialog.fixed{position:fixed;top:50%;transform:translate(0,-50%)}._dialog_overlay{position:fixed;top:0;right:0;bottom:0;left:0}#content{position:relative;z-index:1}#target-open{display:flex;flex-direction:column;position:absolute;left:0;top:0}#focus{display:none;position:absolute;width:0;height:0}</style><slot id="target" aria-haspopup="dialog" aria-expanded="false" name="target"></slot><div id="focus" tabindex="-1"></div><dialog id="dialog"><div id="content"><slot name="content"></slot></div><div id="target-open"><slot name="target-open"></slot></div></dialog>';
5
+ import { assertOrientation, disableScroll, enableScroll, orientationValues } from './utils';
6
+ const template = document.createElement('template');
7
+ template.innerHTML = templateHTML;
8
+ defineCustomElement('sinch-pop', class extends NectaryElement {
9
+ #$target;
10
+ #$focus;
11
+ #$dialog;
12
+ #isConnected;
13
+ #resizeThrottle;
14
+ #$targetSlot;
15
+ #$targetOpenSlot;
16
+ #$contentSlot;
17
+ #$targetOpenWrapper;
18
+ #targetActiveElement = null;
19
+ #controller = null;
20
+ #keydownContext;
21
+ #visibilityContext;
22
+ #targetStyleValue = null;
23
+
24
+ constructor() {
25
+ super();
26
+ const shadowRoot = this.attachShadow();
27
+ shadowRoot.appendChild(template.content.cloneNode(true));
28
+ this.#$target = shadowRoot.querySelector('#target');
29
+ this.#$focus = shadowRoot.querySelector('#focus');
30
+ this.#$dialog = shadowRoot.querySelector('#dialog');
31
+ this.#$targetSlot = shadowRoot.querySelector('slot[name="target"]');
32
+ this.#$targetOpenSlot = shadowRoot.querySelector('slot[name="target-open"]');
33
+ this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
34
+ this.#$targetOpenWrapper = shadowRoot.querySelector('#target-open');
35
+ this.#isConnected = false;
36
+ this.#resizeThrottle = throttleAnimationFrame(this.#updateOrientation);
37
+ this.#keydownContext = new Context(this.#$contentSlot, 'keydown');
38
+ this.#visibilityContext = new Context(this.#$contentSlot, 'visibility');
39
+ dialogPolyfill.registerDialog(this.#$dialog);
40
+
41
+ dialogPolyfill.dm.handleFocus_ = function () {};
42
+ }
43
+
44
+ connectedCallback() {
45
+ this.#controller = new AbortController();
46
+ const {
47
+ signal
48
+ } = this.#controller;
49
+ this.#keydownContext.subscribe();
50
+ this.#visibilityContext.subscribe();
51
+ this.setAttribute('role', 'dialog');
52
+ this.#$dialog.addEventListener('cancel', this.#onCancel, {
53
+ signal
54
+ });
55
+ this.#$dialog.addEventListener('mousedown', this.#onBackdropMouseDown, {
56
+ signal
57
+ });
58
+ this.addEventListener('-close', this.#onCloseReactHandler, {
59
+ signal
60
+ });
61
+ this.addEventListener('-visibility', this.#onContextVisibility, {
62
+ signal
63
+ });
64
+ dispatchContextConnectEvent(this, 'visibility');
65
+ this.#isConnected = true;
66
+
67
+ if (getBooleanAttribute(this, 'open')) {
68
+ this.#onExpand();
69
+ }
70
+ }
71
+
72
+ disconnectedCallback() {
73
+ this.#controller.abort();
74
+ this.#keydownContext.unsubscribe();
75
+ this.#visibilityContext.unsubscribe();
76
+ dispatchContextDisconnectEvent(this, 'visibility');
77
+ this.#onCollapse();
78
+ this.#isConnected = false;
79
+ }
80
+
81
+ static get observedAttributes() {
82
+ return ['orientation', 'open'];
83
+ }
84
+
85
+ set modal(isModal) {
86
+ updateBooleanAttribute(this, 'modal', isModal);
87
+ }
88
+
89
+ get modal() {
90
+ return getBooleanAttribute(this, 'modal');
91
+ }
92
+
93
+ set open(isOpen) {
94
+ updateBooleanAttribute(this, 'open', isOpen);
95
+ }
96
+
97
+ get open() {
98
+ return getBooleanAttribute(this, 'open');
99
+ }
100
+
101
+ get orientation() {
102
+ return getLiteralAttribute(this, orientationValues, 'orientation');
103
+ }
104
+
105
+ set orientation(value) {
106
+ updateLiteralAttribute(this, orientationValues, 'orientation', value);
107
+ }
108
+
109
+ set inset(inset) {
110
+ updateIntegerAttribute(this, 'inset', inset);
111
+ }
112
+
113
+ get inset() {
114
+ return getIntegerAttribute(this, 'inset', 0);
115
+ }
116
+
117
+ get footprintRect() {
118
+ return this.#getTargetRect();
119
+ }
120
+
121
+ get popoverRect() {
122
+ return getRect(this.#$dialog);
123
+ }
124
+
125
+ attributeChangedCallback(name, oldVal, newVal) {
126
+ if (oldVal === newVal) {
127
+ return;
128
+ }
129
+
130
+ switch (name) {
131
+ case 'open':
132
+ {
133
+ if (isAttrTrue(newVal)) {
134
+ requestAnimationFrame(() => {
135
+ this.#onExpand();
136
+ });
137
+ } else {
138
+ this.#onCollapse();
139
+ }
140
+
141
+ updateBooleanAttribute(this, 'open', isAttrTrue(newVal));
142
+ break;
143
+ }
144
+
145
+ case 'orientation':
146
+ {
147
+ assertOrientation(newVal);
148
+
149
+ if (this.#isOpen()) {
150
+ this.#updateOrientation();
151
+ }
152
+
153
+ break;
154
+ }
155
+ }
156
+ }
157
+
158
+ #getTargetRect() {
159
+ let item = getFirstSlotElement(this.#$targetSlot, true);
160
+
161
+ if (item === null && this.#isOpen()) {
162
+ item = getFirstSlotElement(this.#$targetOpenSlot, true);
163
+ }
164
+
165
+ if (item === null) {
166
+ return getRect(this.#$target);
167
+ }
168
+
169
+ if (Reflect.has(item, 'footprintRect')) {
170
+ return item.footprintRect;
171
+ }
172
+
173
+ return getRect(item);
174
+ }
175
+
176
+ #getFirstTargetElement(slot) {
177
+ const item = getFirstSlotElement(slot, true);
178
+
179
+ if (item === null) {
180
+ return this.#$target;
181
+ }
182
+
183
+ return item;
184
+ }
185
+
186
+ #onExpand() {
187
+ if (!this.#isConnected || this.#isOpen()) {
188
+ return;
189
+ }
190
+
191
+ this.#$targetSlot.addEventListener('blur', this.#stopEventPropagation, true);
192
+ this.#$focus.style.setProperty('display', 'block');
193
+ this.#$focus.addEventListener('focus', this.#captureRelatedActiveElement);
194
+ this.#$focus.focus();
195
+ this.#$focus.removeEventListener('focus', this.#captureRelatedActiveElement);
196
+ this.#$focus.style.removeProperty('display');
197
+ this.#$targetSlot.removeEventListener('blur', this.#stopEventPropagation, true);
198
+ this.#$dialog.showModal();
199
+ this.#$target.setAttribute('aria-expanded', 'true');
200
+ this.#updateOrientation();
201
+
202
+ if (this.modal) {
203
+ getFirstFocusableElement(this.#$contentSlot)?.focus();
204
+ } else {
205
+ const $targetEl = this.#getFirstTargetElement(this.#$targetSlot);
206
+ const targetElComputedStyle = getComputedStyle($targetEl);
207
+ const marginLeft = parseInt(targetElComputedStyle.marginLeft);
208
+ const marginRight = parseInt(targetElComputedStyle.marginRight);
209
+ const marginTop = parseInt(targetElComputedStyle.marginTop);
210
+ const marginBottom = parseInt(targetElComputedStyle.marginBottom);
211
+ const targetRect = this.#getTargetRect();
212
+ this.#$target.style.setProperty('display', 'block');
213
+ this.#$target.style.setProperty('width', `${targetRect.width + marginLeft + marginRight}px`);
214
+ this.#$target.style.setProperty('height', `${targetRect.height + marginTop + marginBottom}px`);
215
+ this.#$targetOpenWrapper.style.setProperty('width', `${targetRect.width}px`);
216
+ this.#$targetOpenWrapper.style.setProperty('height', `${targetRect.height}px`);
217
+ this.#targetStyleValue = $targetEl.getAttribute('style');
218
+ $targetEl.style.setProperty('margin', '0');
219
+ $targetEl.style.setProperty('position', 'static');
220
+
221
+ if (targetElComputedStyle.transform !== 'none') {
222
+ const matrix = new DOMMatrixReadOnly(targetElComputedStyle.transform);
223
+ $targetEl.style.setProperty('transform', matrix.translate(-matrix.e, -matrix.f).toString());
224
+ }
225
+
226
+ getFirstSlotElement(this.#$targetSlot)?.setAttribute('slot', 'target-open');
227
+ this.#$targetOpenSlot.addEventListener('keydown', this.#onTargetKeydown);
228
+
229
+ if (this.#targetActiveElement !== null) {
230
+ requestAnimationFrame(this.#focusTargetElementOnExpandNonModal);
231
+ this.#focusTargetElementOnExpandNonModal();
232
+ }
233
+ }
234
+
235
+ disableScroll();
236
+ window.addEventListener('resize', this.#onResize);
237
+ this.#dispatchContentVisibility(true);
238
+ }
239
+
240
+ #focusTargetElementOnExpandNonModal = () => {
241
+ if (this.#targetActiveElement !== null) {
242
+ this.#$targetOpenSlot.addEventListener('focus', this.#stopEventPropagation, true);
243
+ this.#targetActiveElement.focus();
244
+ this.#$targetOpenSlot.removeEventListener('focus', this.#stopEventPropagation, true);
245
+ }
246
+ };
247
+
248
+ #onCollapse() {
249
+ if (!this.#isOpen()) {
250
+ return;
251
+ }
252
+
253
+ const isNonModal = !this.modal;
254
+ this.#dispatchContentVisibility(false);
255
+ this.#$targetOpenSlot.removeEventListener('keydown', this.#onTargetKeydown);
256
+
257
+ if (isNonModal) {
258
+ this.#targetActiveElement = null;
259
+ this.#$targetOpenSlot.addEventListener('blur', this.#captureActiveElement, true);
260
+ }
261
+
262
+ this.#$dialog.close();
263
+ this.#$target.setAttribute('aria-expanded', 'false');
264
+
265
+ if (isNonModal) {
266
+ this.#$targetOpenSlot.removeEventListener('blur', this.#captureActiveElement, true);
267
+ }
268
+
269
+ const targetEl = this.#getFirstTargetElement(this.#$targetOpenSlot);
270
+ targetEl.style.removeProperty('margin');
271
+ targetEl.style.removeProperty('position');
272
+ targetEl.style.removeProperty('transform');
273
+
274
+ if (this.#targetStyleValue !== null) {
275
+ targetEl.setAttribute('style', this.#targetStyleValue);
276
+ this.#targetStyleValue = null;
277
+ }
278
+
279
+ getFirstSlotElement(this.#$targetOpenSlot)?.setAttribute('slot', 'target');
280
+ this.#$target.style.removeProperty('display');
281
+ this.#$target.style.removeProperty('width');
282
+ this.#$target.style.removeProperty('height');
283
+
284
+ if (this.#targetActiveElement !== null) {
285
+ if (!isElementFocused(this.#targetActiveElement)) {
286
+ this.#$targetSlot.addEventListener('focus', this.#stopEventPropagation, true);
287
+ this.#targetActiveElement.focus();
288
+ this.#$targetSlot.removeEventListener('focus', this.#stopEventPropagation, true);
289
+ }
290
+
291
+ this.#targetActiveElement = null;
292
+ }
293
+
294
+ enableScroll();
295
+ this.#resizeThrottle.cancel();
296
+ window.removeEventListener('resize', this.#onResize);
297
+ }
298
+
299
+ #isOpen() {
300
+ return getBooleanAttribute(this.#$dialog, 'open');
301
+ }
302
+
303
+ #onResize = () => {
304
+ this.#resizeThrottle.fn();
305
+ };
306
+ #updateOrientation = () => {
307
+ this.#$dialog.style.setProperty('width', 'max-content');
308
+ const targetRect = this.#getTargetRect();
309
+ const modalRect = this.#$dialog.getBoundingClientRect();
310
+ const orient = this.orientation;
311
+ const shouldSetWidthToTarget = orient === 'top-stretch' || orient === 'bottom-stretch';
312
+ const modalHeight = modalRect.height;
313
+ const modalWidth = shouldSetWidthToTarget ? targetRect.width : modalRect.width;
314
+ const inset = this.inset;
315
+ let xPos = 0;
316
+ let yPos = 0;
317
+
318
+ if (orient === 'bottom-right' || orient === 'top-right' || orient === 'top-stretch' || orient === 'bottom-stretch') {
319
+ xPos = targetRect.x;
320
+ }
321
+
322
+ if (orient === 'bottom-left' || orient === 'top-left') {
323
+ xPos = targetRect.x + targetRect.width - modalWidth;
324
+ }
325
+
326
+ if (orient === 'bottom-center' || orient === 'top-center') {
327
+ xPos = targetRect.x + targetRect.width / 2 - modalWidth / 2;
328
+ }
329
+
330
+ if (orient === 'center-right') {
331
+ xPos = targetRect.x + targetRect.width;
332
+ }
333
+
334
+ if (orient === 'center-left') {
335
+ xPos = targetRect.x - modalWidth;
336
+ }
337
+
338
+ if (orient === 'bottom-left' || orient === 'bottom-right' || orient === 'bottom-stretch' || orient === 'bottom-center') {
339
+ yPos = targetRect.y + targetRect.height;
340
+ }
341
+
342
+ if (orient === 'top-left' || orient === 'top-right' || orient === 'top-stretch' || orient === 'top-center') {
343
+ yPos = targetRect.y - modalHeight;
344
+ }
345
+
346
+ if (orient === 'center-left' || orient === 'center-right') {
347
+ yPos = targetRect.y + targetRect.height / 2 - modalHeight / 2;
348
+ }
349
+
350
+ xPos = Math.round(Math.max(inset, Math.min(xPos, window.innerWidth - modalWidth - inset)));
351
+ yPos = Math.round(Math.max(inset, Math.min(yPos, window.innerHeight - modalHeight - inset)));
352
+ this.#$dialog.style.setProperty('left', `${xPos}px`);
353
+ this.#$dialog.style.setProperty('top', `${yPos}px`);
354
+ this.#$dialog.style.setProperty('width', `${modalWidth}px`);
355
+
356
+ if (!this.modal) {
357
+ const targetLeftPos = targetRect.x - xPos;
358
+ const targetTopPos = targetRect.y - yPos;
359
+ this.#$targetOpenWrapper.style.setProperty('left', `${targetLeftPos}px`);
360
+ this.#$targetOpenWrapper.style.setProperty('top', `${targetTopPos}px`);
361
+ }
362
+ };
363
+ #onBackdropMouseDown = e => {
364
+ if (e.target !== this.#$dialog) {
365
+ return;
366
+ }
367
+
368
+ const rect = this.popoverRect;
369
+ const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
370
+
371
+ if (!isInside) {
372
+ this.#dispatchCloseEvent();
373
+ }
374
+ };
375
+ #onCancel = e => {
376
+ e.preventDefault();
377
+ this.#dispatchCloseEvent();
378
+ };
379
+ #onCloseReactHandler = e => {
380
+ getReactEventHandler(this, 'on-close')?.(e);
381
+ };
382
+
383
+ #dispatchCloseEvent() {
384
+ this.dispatchEvent(new CustomEvent('-close'));
385
+ }
386
+
387
+ #captureRelatedActiveElement = e => {
388
+ e.stopPropagation();
389
+ this.#targetActiveElement = e.relatedTarget;
390
+ };
391
+ #captureActiveElement = e => {
392
+ e.stopPropagation();
393
+ this.#targetActiveElement = e.target;
394
+ };
395
+ #stopEventPropagation = e => {
396
+ e.stopPropagation();
397
+ };
398
+
399
+ #dispatchContentVisibility(isVisible) {
400
+ for (const $el of this.#visibilityContext.elements) {
401
+ $el.dispatchEvent(new CustomEvent('-visibility', {
402
+ detail: isVisible
403
+ }));
404
+ }
405
+ }
406
+
407
+ #onTargetKeydown = e => {
408
+ for (const $el of this.#keydownContext.elements) {
409
+ let isPrevented = false;
410
+ $el.dispatchEvent(new CustomEvent('-keydown', {
411
+ detail: {
412
+ code: e.code,
413
+ preventDefault: () => {
414
+ isPrevented = true;
415
+ }
416
+ }
417
+ }));
418
+
419
+ if (isPrevented) {
420
+ e.preventDefault();
421
+ }
422
+ }
423
+ };
424
+ #onContextVisibility = e => {
425
+ if (!e.detail) {
426
+ this.#dispatchCloseEvent();
427
+ }
428
+ };
429
+ });
package/pop/types.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { TRect, TSinchElementReact } from '../types';
2
+ export declare type TSinchPopOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'bottom-stretch' | 'top-center' | 'top-stretch' | 'center-right' | 'center-left';
3
+ export declare type TSinchPopElement = HTMLElement & {
4
+ /** Open/close state */
5
+ open: boolean;
6
+ /** Orientation, where it *points to* from origin */
7
+ orientation: TSinchPopOrientation;
8
+ /** Modal/non-modal mode */
9
+ modal: boolean;
10
+ inset: number;
11
+ readonly footprintRect: TRect;
12
+ readonly popoverRect: TRect;
13
+ /** Close event */
14
+ addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
15
+ /** Open/close state */
16
+ setAttribute(name: 'open', value: ''): void;
17
+ /** Orientation, where it *points to* from origin */
18
+ setAttribute(name: 'orientation', value: TSinchPopOrientation): void;
19
+ /** Modal/non-modal mode */
20
+ setAttribute(name: 'modal', value: boolean): void;
21
+ setAttribute(name: 'inset', value: string): void;
22
+ };
23
+ export declare type TSinchPopReact = TSinchElementReact<TSinchPopElement> & {
24
+ /** Open/close state */
25
+ open: boolean;
26
+ /** Orientation, where it *points to* from origin */
27
+ orientation: TSinchPopOrientation;
28
+ /** Modal/non-modal mode */
29
+ modal?: boolean;
30
+ inset?: number;
31
+ /** Label that is used for a11y */
32
+ 'aria-label': string;
33
+ /** Close event handler */
34
+ 'on-close'?: (e: CustomEvent<void>) => void;
35
+ };
package/pop/utils.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { TSinchPopOrientation } from './types';
2
+ export declare const orientationValues: readonly TSinchPopOrientation[];
3
+ declare type TAssertOrientation = (value: string | null) => asserts value is TSinchPopOrientation;
4
+ export declare const assertOrientation: TAssertOrientation;
5
+ export declare const disableScroll: () => void;
6
+ export declare const enableScroll: () => void;
7
+ export {};
package/pop/utils.js ADDED
@@ -0,0 +1,18 @@
1
+ export const orientationValues = ['top-left', 'top-right', 'bottom-left', 'bottom-right', 'bottom-stretch', 'bottom-center', 'top-stretch', 'top-center', 'center-left', 'center-right'];
2
+ export const assertOrientation = value => {
3
+ if (value === null || !orientationValues.includes(value)) {
4
+ throw new Error(`sinch-pop: invalid orientation attribute: ${value}`);
5
+ }
6
+ };
7
+ const bodyEl = document.body;
8
+ export const disableScroll = () => {
9
+ bodyEl.style.overflow = 'hidden';
10
+ bodyEl.__pop_counter__ = (bodyEl.__pop_counter__ ?? 0) + 1;
11
+ };
12
+ export const enableScroll = () => {
13
+ bodyEl.__pop_counter__ = Math.max(0, (bodyEl.__pop_counter__ ?? 0) - 1);
14
+
15
+ if (bodyEl.__pop_counter__ === 0) {
16
+ document.body.style.overflow = '';
17
+ }
18
+ };
@@ -1,3 +1,4 @@
1
+ import '../pop';
1
2
  import type { TSinchPopoverElement, TSinchPopoverReact } from './types';
2
3
  declare global {
3
4
  namespace JSX {