@toptal/picasso-utils 2.0.1-alpha-fx-6033-end-adornment-in-input-is-broken-in-firefox-768d306ef.43 → 3.0.1-alpha-fx-6095-number-input-misses-type-button-353a18c00.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/dist-package/src/utils/useOnScreen/use-on-screen.d.ts +4 -1
- package/dist-package/src/utils/useOnScreen/use-on-screen.d.ts.map +1 -1
- package/dist-package/src/utils/useOnScreen/use-on-screen.js +5 -3
- package/dist-package/src/utils/useOnScreen/use-on-screen.js.map +1 -1
- package/package.json +5 -5
- package/src/utils/useOnScreen/use-on-screen.ts +5 -3
|
@@ -5,6 +5,9 @@ interface UseOnScreenProps {
|
|
|
5
5
|
rootMargin?: string;
|
|
6
6
|
threshold?: number | number[];
|
|
7
7
|
}
|
|
8
|
-
declare const useOnScreen: ({ ref, root, rootMargin, threshold, }: UseOnScreenProps) =>
|
|
8
|
+
declare const useOnScreen: ({ ref, root, rootMargin, threshold, }: UseOnScreenProps) => {
|
|
9
|
+
isOnScreen: boolean;
|
|
10
|
+
isObserved: boolean;
|
|
11
|
+
};
|
|
9
12
|
export default useOnScreen;
|
|
10
13
|
//# sourceMappingURL=use-on-screen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-screen.d.ts","sourceRoot":"","sources":["../../../../src/utils/useOnScreen/use-on-screen.ts"],"names":[],"mappings":";AAEA,UAAU,gBAAgB;IACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC9B;AAED,QAAA,MAAM,WAAW,0CAKd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"use-on-screen.d.ts","sourceRoot":"","sources":["../../../../src/utils/useOnScreen/use-on-screen.ts"],"names":[],"mappings":";AAEA,UAAU,gBAAgB;IACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACjC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAC9B;AAED,QAAA,MAAM,WAAW,0CAKd,gBAAgB;;;CAmClB,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState, useMemo } from 'react';
|
|
2
2
|
const useOnScreen = ({ ref, root, rootMargin, threshold, }) => {
|
|
3
|
-
const [
|
|
3
|
+
const [isOnScreen, setIsOnScreen] = useState(false);
|
|
4
|
+
const [isObserved, setObserved] = useState(false);
|
|
4
5
|
const observer = useMemo(() => new IntersectionObserver(([entry]) => {
|
|
5
|
-
|
|
6
|
+
setIsOnScreen(entry.isIntersecting);
|
|
7
|
+
setObserved(true);
|
|
6
8
|
}, {
|
|
7
9
|
root: root === null || root === void 0 ? void 0 : root.current,
|
|
8
10
|
rootMargin,
|
|
@@ -18,7 +20,7 @@ const useOnScreen = ({ ref, root, rootMargin, threshold, }) => {
|
|
|
18
20
|
observer.unobserve(element);
|
|
19
21
|
};
|
|
20
22
|
}, [observer, ref]);
|
|
21
|
-
return
|
|
23
|
+
return { isOnScreen, isObserved };
|
|
22
24
|
};
|
|
23
25
|
export default useOnScreen;
|
|
24
26
|
//# sourceMappingURL=use-on-screen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-on-screen.js","sourceRoot":"","sources":["../../../../src/utils/useOnScreen/use-on-screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AASpD,MA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EAAE,UAAU,EAAE,UAAU,EAAE,CAAA;AACnC,CAAC,CAAA;AAED,eAAe,WAAW,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toptal/picasso-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1-alpha-fx-6095-number-input-misses-type-button-353a18c00.1+353a18c00",
|
|
4
4
|
"description": "Toptal UI components library - Utils",
|
|
5
5
|
"homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"prepublishOnly": "yarn build:package"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@toptal/picasso-shared": "15.0.1-alpha-fx-
|
|
29
|
+
"@toptal/picasso-shared": "15.0.1-alpha-fx-6095-number-input-misses-type-button-353a18c00.254+353a18c00",
|
|
30
30
|
"ap-style-title-case": "^1.1.2",
|
|
31
31
|
"classnames": "^2.5.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@toptal/picasso-provider": "5.0.1-alpha-fx-
|
|
35
|
-
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-
|
|
34
|
+
"@toptal/picasso-provider": "5.0.1-alpha-fx-6095-number-input-misses-type-button-353a18c00.175+353a18c00",
|
|
35
|
+
"@toptal/picasso-test-utils": "1.1.2-alpha-fx-6095-number-input-misses-type-button-353a18c00.254+353a18c00",
|
|
36
36
|
"styled-components": "^6.1.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"!dist-package/tsconfig.tsbuildinfo",
|
|
50
50
|
"src"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "353a18c00d04fe7c52e2ba8a52a4bc900ca33bda"
|
|
53
53
|
}
|
|
@@ -13,13 +13,15 @@ const useOnScreen = ({
|
|
|
13
13
|
rootMargin,
|
|
14
14
|
threshold,
|
|
15
15
|
}: UseOnScreenProps) => {
|
|
16
|
-
const [
|
|
16
|
+
const [isOnScreen, setIsOnScreen] = useState(false)
|
|
17
|
+
const [isObserved, setObserved] = useState(false)
|
|
17
18
|
|
|
18
19
|
const observer = useMemo(
|
|
19
20
|
() =>
|
|
20
21
|
new IntersectionObserver(
|
|
21
22
|
([entry]) => {
|
|
22
|
-
|
|
23
|
+
setIsOnScreen(entry.isIntersecting)
|
|
24
|
+
setObserved(true)
|
|
23
25
|
},
|
|
24
26
|
{
|
|
25
27
|
root: root?.current,
|
|
@@ -44,7 +46,7 @@ const useOnScreen = ({
|
|
|
44
46
|
}
|
|
45
47
|
}, [observer, ref])
|
|
46
48
|
|
|
47
|
-
return
|
|
49
|
+
return { isOnScreen, isObserved }
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export default useOnScreen
|