fontdue-js 3.11.0 → 3.12.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.
- package/CHANGELOG.md +10 -0
- package/dist/__generated__/CustomerLoginFormLoginMutation.graphql.d.ts +2 -1
- package/dist/__generated__/CustomerLoginFormLoginMutation.graphql.js +1 -1
- package/dist/__generated__/CustomerLoginFormRecaptchaQuery.graphql.d.ts +21 -0
- package/dist/__generated__/CustomerLoginFormRecaptchaQuery.graphql.js +86 -0
- package/dist/__generated__/CustomerSignInElementQuery.graphql.d.ts +22 -0
- package/dist/__generated__/CustomerSignInElementQuery.graphql.js +87 -0
- package/dist/__tests__/customerLoginRecaptcha.test.js +113 -0
- package/dist/__tests__/customerSignInElement.test.js +155 -0
- package/dist/__tests__/customerSignInRequest.test.js +85 -0
- package/dist/__tests__/stripeCheckoutError.test.js +110 -0
- package/dist/__tests__/typeTesterHeightAnimation.test.js +124 -0
- package/dist/__tests__/typeTesterPrefetchStyles.test.js +108 -0
- package/dist/__tests__/typeTesterShyFeaturesClose.test.js +133 -0
- package/dist/components/CustomerLoginForm/index.js +106 -11
- package/dist/components/CustomerSignIn/CustomerSignInElement.d.ts +22 -0
- package/dist/components/CustomerSignIn/CustomerSignInElement.js +132 -0
- package/dist/components/CustomerSignIn/index.js +4 -2
- package/dist/components/Root/index.js +2 -0
- package/dist/components/StripeProvider/index.js +19 -2
- package/dist/components/TypeTester/TypeTesterFeatures.js +27 -44
- package/dist/components/TypeTester/TypeTesterStyleSelect.js +6 -1
- package/dist/components/TypeTester/useCloseWhenToolbarHides.d.ts +17 -0
- package/dist/components/TypeTester/useCloseWhenToolbarHides.js +79 -0
- package/dist/components/TypeTester/useHeightAnimation.d.ts +27 -0
- package/dist/components/TypeTester/useHeightAnimation.js +85 -0
- package/dist/components/TypeTester/usePrefetchWhenNear.d.ts +14 -0
- package/dist/components/TypeTester/usePrefetchWhenNear.js +69 -0
- package/dist/fontdue.css +2 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
// How far outside the viewport a tester counts as "near".
|
|
4
|
+
export const PREFETCH_ROOT_MARGIN = '300px';
|
|
5
|
+
// Upper bound on waiting for the browser to go idle.
|
|
6
|
+
export const PREFETCH_IDLE_TIMEOUT = 2000;
|
|
7
|
+
function onIdle(cb) {
|
|
8
|
+
if (typeof window.requestIdleCallback === 'function') {
|
|
9
|
+
const id = window.requestIdleCallback(cb, {
|
|
10
|
+
timeout: PREFETCH_IDLE_TIMEOUT
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
cancel: () => window.cancelIdleCallback(id)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// Safari has no requestIdleCallback.
|
|
17
|
+
const id = window.setTimeout(cb, 200);
|
|
18
|
+
return {
|
|
19
|
+
cancel: () => window.clearTimeout(id)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Calls `prefetch` once, at idle time, after the element first comes near the
|
|
25
|
+
* viewport. Native `<select>` menus snapshot their options when they open (in
|
|
26
|
+
* Safari the open menu never updates), so data a dropdown needs has to be
|
|
27
|
+
* there before the first click – fetching on mousedown is too late. Waiting
|
|
28
|
+
* for idle keeps the request off the initial render, and waiting for the
|
|
29
|
+
* viewport keeps a long page of testers from fetching for every one at once.
|
|
30
|
+
*
|
|
31
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
32
|
+
* usePrefetchWhenNear(ref, loadOptions);
|
|
33
|
+
*/
|
|
34
|
+
export default function usePrefetchWhenNear(ref, prefetch) {
|
|
35
|
+
const prefetchRef = useRef(prefetch);
|
|
36
|
+
prefetchRef.current = prefetch;
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const el = ref.current;
|
|
39
|
+
if (!el) return;
|
|
40
|
+
let idle = null;
|
|
41
|
+
const schedule = () => {
|
|
42
|
+
idle ??= onIdle(() => {
|
|
43
|
+
var _prefetchRef$current;
|
|
44
|
+
return (_prefetchRef$current = prefetchRef.current) === null || _prefetchRef$current === void 0 ? void 0 : _prefetchRef$current.call(prefetchRef);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
if (typeof IntersectionObserver !== 'function') {
|
|
48
|
+
schedule();
|
|
49
|
+
return () => {
|
|
50
|
+
var _idle;
|
|
51
|
+
return (_idle = idle) === null || _idle === void 0 ? void 0 : _idle.cancel();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const observer = new IntersectionObserver(entries => {
|
|
55
|
+
if (entries.some(entry => entry.isIntersecting)) {
|
|
56
|
+
observer.disconnect();
|
|
57
|
+
schedule();
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
rootMargin: PREFETCH_ROOT_MARGIN
|
|
61
|
+
});
|
|
62
|
+
observer.observe(el);
|
|
63
|
+
return () => {
|
|
64
|
+
var _idle2;
|
|
65
|
+
observer.disconnect();
|
|
66
|
+
(_idle2 = idle) === null || _idle2 === void 0 ? void 0 : _idle2.cancel();
|
|
67
|
+
};
|
|
68
|
+
}, [ref]);
|
|
69
|
+
}
|
package/dist/fontdue.css
CHANGED
package/dist/version.js
CHANGED
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
// (Fontage.ClientVersions) to spot sites that need to upgrade before a
|
|
9
9
|
// feature that depends on a newer client can work for them.
|
|
10
10
|
export const CLIENT_VERSION_HEADER = 'fontdue-client-version';
|
|
11
|
-
export const version = "3.
|
|
11
|
+
export const version = "3.12.1";
|