@cloudscape-design/components 3.0.553 → 3.0.555
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.
- package/button/index.d.ts.map +1 -1
- package/button/index.js +0 -8
- package/button/index.js.map +1 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +9 -0
- package/button/internal.js.map +1 -1
- package/flashbar/internal/analytics.d.ts.map +1 -1
- package/flashbar/internal/analytics.js +3 -1
- package/flashbar/internal/analytics.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-performance-marks.d.ts +3 -0
- package/internal/hooks/use-performance-marks.d.ts.map +1 -0
- package/internal/hooks/use-performance-marks.js +41 -0
- package/internal/hooks/use-performance-marks.js.map +1 -0
- package/internal/hooks/use-unique-id/index.d.ts +0 -1
- package/internal/hooks/use-unique-id/index.d.ts.map +1 -1
- package/internal/hooks/use-unique-id/index.js +1 -1
- package/internal/hooks/use-unique-id/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/spinner/index.d.ts.map +1 -1
- package/spinner/index.js +0 -9
- package/spinner/index.js.map +1 -1
- package/table/header-cell/index.d.ts +1 -2
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js +1 -3
- package/table/header-cell/index.js.map +1 -1
- package/table/index.d.ts.map +1 -1
- package/table/index.js +1 -10
- package/table/index.js.map +1 -1
- package/table/internal.d.ts +1 -8
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +12 -3
- package/table/internal.js.map +1 -1
- package/table/thead.d.ts +0 -1
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js +2 -2
- package/table/thead.js.map +1 -1
- package/table/tools-header.d.ts +1 -2
- package/table/tools-header.d.ts.map +1 -1
- package/table/tools-header.js +4 -4
- package/table/tools-header.js.map +1 -1
- package/internal/analytics/metrics.d.ts +0 -3
- package/internal/analytics/metrics.d.ts.map +0 -1
- package/internal/analytics/metrics.js +0 -6
- package/internal/analytics/metrics.js.map +0 -1
- package/internal/hooks/use-latency-metrics/index.d.ts +0 -12
- package/internal/hooks/use-latency-metrics/index.d.ts.map +0 -1
- package/internal/hooks/use-latency-metrics/index.js +0 -108
- package/internal/hooks/use-latency-metrics/index.js.map +0 -1
- package/internal/hooks/use-latency-metrics/is-in-viewport.d.ts +0 -9
- package/internal/hooks/use-latency-metrics/is-in-viewport.d.ts.map +0 -1
- package/internal/hooks/use-latency-metrics/is-in-viewport.js +0 -74
- package/internal/hooks/use-latency-metrics/is-in-viewport.js.map +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
let map = new WeakMap();
|
|
4
|
-
const MAX_DELAY_MS = 1000;
|
|
5
|
-
const MANUAL_TRIGGER_DELAY = 2000;
|
|
6
|
-
/**
|
|
7
|
-
* This function determines whether an element is in the viewport. The callback
|
|
8
|
-
* is batched with other elements that also use this function, in order to improve
|
|
9
|
-
* performance.
|
|
10
|
-
*/
|
|
11
|
-
export function isInViewport(element, callback) {
|
|
12
|
-
const mapSnapshot = map;
|
|
13
|
-
let called = false;
|
|
14
|
-
mapSnapshot.set(element, entry => {
|
|
15
|
-
if (!called) {
|
|
16
|
-
called = true;
|
|
17
|
-
callback(entry);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
/*
|
|
21
|
-
If the IntersectionObserver does not fire in reasonable time (for example
|
|
22
|
-
in a background page in Chrome), we need to call the callback manually.
|
|
23
|
-
|
|
24
|
-
See https://issues.chromium.org/issues/41383759
|
|
25
|
-
*/
|
|
26
|
-
const timeoutHandle = setTimeout(() => {
|
|
27
|
-
if (!called) {
|
|
28
|
-
called = true;
|
|
29
|
-
callback(false);
|
|
30
|
-
}
|
|
31
|
-
}, MANUAL_TRIGGER_DELAY);
|
|
32
|
-
observer.observe(element);
|
|
33
|
-
// Cleanup
|
|
34
|
-
return () => {
|
|
35
|
-
clearTimeout(timeoutHandle);
|
|
36
|
-
mapSnapshot.delete(element);
|
|
37
|
-
observer.unobserve(element);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function createIntersectionObserver(callback) {
|
|
41
|
-
if (typeof IntersectionObserver === 'undefined') {
|
|
42
|
-
return {
|
|
43
|
-
observe: () => { },
|
|
44
|
-
unobserve: () => { },
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return new IntersectionObserver(callback);
|
|
48
|
-
}
|
|
49
|
-
const observer = createIntersectionObserver(function isInViewportObserver(entries) {
|
|
50
|
-
// This avoids interference when the IntersectionObserver is called again during the delay.
|
|
51
|
-
const mapSnapshot = map;
|
|
52
|
-
map = new Map();
|
|
53
|
-
// We only want the first run of the observer.
|
|
54
|
-
for (const entry of entries) {
|
|
55
|
-
observer.unobserve(entry.target);
|
|
56
|
-
}
|
|
57
|
-
// We yield the event loop, since these events are low priority and not time critical.
|
|
58
|
-
defer(() => {
|
|
59
|
-
var _a;
|
|
60
|
-
for (const entry of entries) {
|
|
61
|
-
(_a = mapSnapshot.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry.isIntersecting);
|
|
62
|
-
}
|
|
63
|
-
}, MAX_DELAY_MS);
|
|
64
|
-
});
|
|
65
|
-
function defer(callback, maxDelayMs) {
|
|
66
|
-
if (typeof requestIdleCallback === 'function') {
|
|
67
|
-
requestIdleCallback(callback, { timeout: maxDelayMs });
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// requestIdleCallback is not supported in Safari
|
|
71
|
-
setTimeout(callback, maxDelayMs);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=is-in-viewport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-in-viewport.js","sourceRoot":"lib/default/","sources":["internal/hooks/use-latency-metrics/is-in-viewport.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAC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OAAO;IAC/E,2FAA2F;IAC3F,MAAM,WAAW,GAAG,GAAG,CAAC;IACxB,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IAEhB,8CAA8C;IAC9C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KAClC;IAED,sFAAsF;IACtF,KAAK,CAAC,GAAG,EAAE;;QACT,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;YAC3B,MAAA,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,0CAAG,KAAK,CAAC,cAAc,CAAC,CAAC;SACvD;IACH,CAAC,EAAE,YAAY,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,SAAS,KAAK,CAAC,QAAoB,EAAE,UAAkB;IACrD,IAAI,OAAO,mBAAmB,KAAK,UAAU,EAAE;QAC7C,mBAAmB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;KACxD;SAAM;QACL,iDAAiD;QACjD,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;KAClC;AACH,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\ntype Callback = (inViewport: boolean) => void;\nlet map = new WeakMap<Element, Callback>();\n\nconst MAX_DELAY_MS = 1000;\nconst MANUAL_TRIGGER_DELAY = 2000;\n\n/**\n * This function determines whether an element is in the viewport. The callback\n * is batched with other elements that also use this function, in order to improve\n * performance.\n */\nexport function isInViewport(element: Element, callback: Callback) {\n const mapSnapshot = map;\n let called = false;\n\n mapSnapshot.set(element, entry => {\n if (!called) {\n called = true;\n callback(entry);\n }\n });\n\n /*\n If the IntersectionObserver does not fire in reasonable time (for example\n in a background page in Chrome), we need to call the callback manually.\n\n See https://issues.chromium.org/issues/41383759\n */\n const timeoutHandle = setTimeout(() => {\n if (!called) {\n called = true;\n callback(false);\n }\n }, MANUAL_TRIGGER_DELAY);\n\n observer.observe(element);\n\n // Cleanup\n return () => {\n clearTimeout(timeoutHandle);\n mapSnapshot.delete(element);\n observer.unobserve(element);\n };\n}\n\nfunction createIntersectionObserver(callback: IntersectionObserverCallback) {\n if (typeof IntersectionObserver === 'undefined') {\n return {\n observe: () => {},\n unobserve: () => {},\n };\n }\n return new IntersectionObserver(callback);\n}\n\nconst observer = createIntersectionObserver(function isInViewportObserver(entries) {\n // This avoids interference when the IntersectionObserver is called again during the delay.\n const mapSnapshot = map;\n map = new Map();\n\n // We only want the first run of the observer.\n for (const entry of entries) {\n observer.unobserve(entry.target);\n }\n\n // We yield the event loop, since these events are low priority and not time critical.\n defer(() => {\n for (const entry of entries) {\n mapSnapshot.get(entry.target)?.(entry.isIntersecting);\n }\n }, MAX_DELAY_MS);\n});\n\nfunction defer(callback: () => void, maxDelayMs: number) {\n if (typeof requestIdleCallback === 'function') {\n requestIdleCallback(callback, { timeout: maxDelayMs });\n } else {\n // requestIdleCallback is not supported in Safari\n setTimeout(callback, maxDelayMs);\n }\n}\n"]}
|