@cloudscape-design/components 3.0.993 → 3.0.994

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.
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (2209247e)";
2
+ export var PACKAGE_VERSION = "3.0.0 (a512a914)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (2209247e)",
3
+ "PACKAGE_VERSION": "3.0.0 (a512a914)",
4
4
  "THEME": "open-source-visual-refresh",
5
5
  "ALWAYS_VISUAL_REFRESH": true
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAKA,UAAU,6BAA6B;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAAE,EAC7D,YAAoB,GACrB,GAAE,6BAAkC;;;EAuBpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAKA,UAAU,6BAA6B;IACrC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,EAAE,EAC7D,YAAoB,GACrB,GAAE,6BAAkC;;;EAkCpC"}
@@ -19,7 +19,19 @@ export function useIntersectionObserver({ initialState = false, } = {}) {
19
19
  }
20
20
  // Create a new observer with the target element
21
21
  if (targetElement) {
22
- observerRef.current = new IntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting));
22
+ // Fix for AWSUI-60898: In Firefox, IntersectionObserver instances inside an
23
+ // iframe context can't detect visibility changes caused by changes to elements
24
+ // outside the iframe (e.g. if an element wrapping the iframe is set to `display: none`).
25
+ let TopLevelIntersectionObserver = IntersectionObserver;
26
+ try {
27
+ if (window.top) {
28
+ TopLevelIntersectionObserver = window.top.IntersectionObserver;
29
+ }
30
+ }
31
+ catch (_a) {
32
+ // Tried to access a cross-origin iframe. Fall back to current IntersectionObserver.
33
+ }
34
+ observerRef.current = new TopLevelIntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting));
23
35
  observerRef.current.observe(targetElement);
24
36
  }
25
37
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMnE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAwB,EAC7D,YAAY,GAAG,KAAK,MACa,EAAE;IACnC,MAAM,WAAW,GAAG,MAAM,CAA8B,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEnE,MAAM,GAAG,GAAG,WAAW,CAAiB,aAAa,CAAC,EAAE;QACtD,IAAI,OAAO,oBAAoB,KAAK,WAAW,EAAE;YAC/C,wCAAwC;YACxC,OAAO;SACR;QAED,IAAI,WAAW,CAAC,OAAO,EAAE;YACvB,uDAAuD;YACvD,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;SAClC;QAED,gDAAgD;QAChD,IAAI,aAAa,EAAE;YACjB,WAAW,CAAC,OAAO,GAAG,IAAI,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YACrG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAC5C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RefCallback, useCallback, useRef, useState } from 'react';\n\ninterface UseIntersectionObserverConfig {\n initialState?: boolean;\n}\n\n/**\n * A hook that uses an Intersection Observer on the target element ref\n * and detects if the element is intersecting with its parent.\n */\nexport function useIntersectionObserver<T extends HTMLElement>({\n initialState = false,\n}: UseIntersectionObserverConfig = {}) {\n const observerRef = useRef<IntersectionObserver | null>(null);\n const [isIntersecting, setIsIntersecting] = useState(initialState);\n\n const ref = useCallback<RefCallback<T>>(targetElement => {\n if (typeof IntersectionObserver === 'undefined') {\n // Do nothing in environments like JSDOM\n return;\n }\n\n if (observerRef.current) {\n // Dismiss previous observer because the target changed\n observerRef.current.disconnect();\n }\n\n // Create a new observer with the target element\n if (targetElement) {\n observerRef.current = new IntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting));\n observerRef.current.observe(targetElement);\n }\n }, []);\n\n return { ref, isIntersecting };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-intersection-observer/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMnE;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAwB,EAC7D,YAAY,GAAG,KAAK,MACa,EAAE;IACnC,MAAM,WAAW,GAAG,MAAM,CAA8B,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEnE,MAAM,GAAG,GAAG,WAAW,CAAiB,aAAa,CAAC,EAAE;QACtD,IAAI,OAAO,oBAAoB,KAAK,WAAW,EAAE;YAC/C,wCAAwC;YACxC,OAAO;SACR;QAED,IAAI,WAAW,CAAC,OAAO,EAAE;YACvB,uDAAuD;YACvD,WAAW,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;SAClC;QAED,gDAAgD;QAChD,IAAI,aAAa,EAAE;YACjB,4EAA4E;YAC5E,iFAAiF;YACjF,2FAA2F;YAC3F,IAAI,4BAA4B,GAAG,oBAAoB,CAAC;YACxD,IAAI;gBACF,IAAI,MAAM,CAAC,GAAG,EAAE;oBACd,4BAA4B,GAAI,MAAM,CAAC,GAAqB,CAAC,oBAAoB,CAAC;iBACnF;aACF;YAAC,WAAM;gBACN,oFAAoF;aACrF;YACD,WAAW,CAAC,OAAO,GAAG,IAAI,4BAA4B,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;YAC7G,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SAC5C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { RefCallback, useCallback, useRef, useState } from 'react';\n\ninterface UseIntersectionObserverConfig {\n initialState?: boolean;\n}\n\n/**\n * A hook that uses an Intersection Observer on the target element ref\n * and detects if the element is intersecting with its parent.\n */\nexport function useIntersectionObserver<T extends HTMLElement>({\n initialState = false,\n}: UseIntersectionObserverConfig = {}) {\n const observerRef = useRef<IntersectionObserver | null>(null);\n const [isIntersecting, setIsIntersecting] = useState(initialState);\n\n const ref = useCallback<RefCallback<T>>(targetElement => {\n if (typeof IntersectionObserver === 'undefined') {\n // Do nothing in environments like JSDOM\n return;\n }\n\n if (observerRef.current) {\n // Dismiss previous observer because the target changed\n observerRef.current.disconnect();\n }\n\n // Create a new observer with the target element\n if (targetElement) {\n // Fix for AWSUI-60898: In Firefox, IntersectionObserver instances inside an\n // iframe context can't detect visibility changes caused by changes to elements\n // outside the iframe (e.g. if an element wrapping the iframe is set to `display: none`).\n let TopLevelIntersectionObserver = IntersectionObserver;\n try {\n if (window.top) {\n TopLevelIntersectionObserver = (window.top as typeof window).IntersectionObserver;\n }\n } catch {\n // Tried to access a cross-origin iframe. Fall back to current IntersectionObserver.\n }\n observerRef.current = new TopLevelIntersectionObserver(([entry]) => setIsIntersecting(entry.isIntersecting));\n observerRef.current.observe(targetElement);\n }\n }, []);\n\n return { ref, isIntersecting };\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "2209247eb21071fec3e5c12c7f209368ca4625b3"
2
+ "commit": "a512a914e2752dd5e2b56b4ede7d27fe12b04cd9"
3
3
  }
package/package.json CHANGED
@@ -149,7 +149,7 @@
149
149
  "./internal/base-component/index.js",
150
150
  "./internal/base-component/styles.css.js"
151
151
  ],
152
- "version": "3.0.993",
152
+ "version": "3.0.994",
153
153
  "repository": {
154
154
  "type": "git",
155
155
  "url": "https://github.com/cloudscape-design/components.git"