@onereach/ui-components-common 26.9.1-beta.5983.0 → 26.9.1-beta.5986.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ import { autoUpdate as originalAutoUpdate } from '@floating-ui/dom';
2
+ /**
3
+ * App runs inside a parent page on another origin
4
+ * (e.g. hitl-embed iframe inside hitl.qa).
5
+ */
6
+ export declare function isCrossOriginEmbedded(): boolean;
7
+ /** Host page embeds an app in a cross-origin iframe. */
8
+ export declare function hasCrossOriginChildIframe(): boolean;
9
+ export declare function shouldLimitFloatingUiAncestors(): boolean;
10
+ type AutoUpdateFn = typeof originalAutoUpdate;
11
+ /**
12
+ * `autoUpdate` that skips ancestor scroll/resize when cross-origin frames are involved.
13
+ * @see https://floating-ui.com/docs/autoUpdate
14
+ */
15
+ export declare const autoUpdate: AutoUpdateFn;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from '@floating-ui/dom';
2
+ export { autoUpdate } from './auto-update';
@@ -0,0 +1,31 @@
1
+ import { autoUpdate as o } from "@floating-ui/dom";
2
+ export * from "@floating-ui/dom";
3
+ function i() {
4
+ if (typeof window > "u" || window.self === window.top || !window.parent)
5
+ return !1;
6
+ try {
7
+ return window.parent.document, !1;
8
+ } catch {
9
+ return !0;
10
+ }
11
+ }
12
+ function u() {
13
+ return typeof document > "u" ? !1 : Array.from(document.querySelectorAll("iframe")).some((e) => {
14
+ try {
15
+ return e.contentDocument, !1;
16
+ } catch {
17
+ return !0;
18
+ }
19
+ });
20
+ }
21
+ function a() {
22
+ return i() || u();
23
+ }
24
+ const s = (e, r, t, n = {}) => a() ? o(e, r, t, {
25
+ ...n,
26
+ ancestorScroll: !1,
27
+ ancestorResize: !1
28
+ }) : o(e, r, t, n);
29
+ export {
30
+ s as autoUpdate
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/ui-components-common",
3
- "version": "26.9.1-beta.5983.0",
3
+ "version": "26.9.1-beta.5986.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -44,6 +44,11 @@
44
44
  "types": "./dist/assets/index.d.ts",
45
45
  "import": "./dist/assets.js",
46
46
  "default": "./dist/assets.js"
47
+ },
48
+ "./floating-ui-dom": {
49
+ "types": "./dist/floating-ui/index.d.ts",
50
+ "import": "./dist/floating-ui.js",
51
+ "default": "./dist/floating-ui.js"
47
52
  }
48
53
  },
49
54
  "main": "./dist/index.js",
@@ -59,7 +64,8 @@
59
64
  "dev": "vite build --watch"
60
65
  },
61
66
  "dependencies": {
62
- "@onereach/styles": "^26.9.1-beta.5983.0",
67
+ "@floating-ui/dom": "1.6.13",
68
+ "@onereach/styles": "^26.9.1-beta.5986.0",
63
69
  "@vueuse/core": "11.3.0"
64
70
  },
65
71
  "devDependencies": {
@@ -0,0 +1,63 @@
1
+ import {
2
+ autoUpdate as originalAutoUpdate,
3
+ type AutoUpdateOptions,
4
+ } from '@floating-ui/dom';
5
+
6
+ /**
7
+ * App runs inside a parent page on another origin
8
+ * (e.g. hitl-embed iframe inside hitl.qa).
9
+ */
10
+ export function isCrossOriginEmbedded(): boolean {
11
+ if (typeof window === 'undefined' || window.self === window.top) {
12
+ return false;
13
+ }
14
+
15
+ if (!window.parent) {
16
+ return false;
17
+ }
18
+
19
+ try {
20
+ void window.parent.document;
21
+ return false;
22
+ } catch {
23
+ return true;
24
+ }
25
+ }
26
+
27
+ /** Host page embeds an app in a cross-origin iframe. */
28
+ export function hasCrossOriginChildIframe(): boolean {
29
+ if (typeof document === 'undefined') {
30
+ return false;
31
+ }
32
+
33
+ return Array.from(document.querySelectorAll('iframe')).some((iframe) => {
34
+ try {
35
+ void iframe.contentDocument;
36
+ return false;
37
+ } catch {
38
+ return true;
39
+ }
40
+ });
41
+ }
42
+
43
+ export function shouldLimitFloatingUiAncestors(): boolean {
44
+ return isCrossOriginEmbedded() || hasCrossOriginChildIframe();
45
+ }
46
+
47
+ type AutoUpdateFn = typeof originalAutoUpdate;
48
+
49
+ /**
50
+ * `autoUpdate` that skips ancestor scroll/resize when cross-origin frames are involved.
51
+ * @see https://floating-ui.com/docs/autoUpdate
52
+ */
53
+ export const autoUpdate: AutoUpdateFn = (reference, floating, update, options: AutoUpdateOptions = {}) => {
54
+ if (shouldLimitFloatingUiAncestors()) {
55
+ return originalAutoUpdate(reference, floating, update, {
56
+ ...options,
57
+ ancestorScroll: false,
58
+ ancestorResize: false,
59
+ });
60
+ }
61
+
62
+ return originalAutoUpdate(reference, floating, update, options);
63
+ };
@@ -0,0 +1,2 @@
1
+ export * from '@floating-ui/dom';
2
+ export { autoUpdate } from './auto-update';