@folklore/hooks 0.0.65 → 0.0.66
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/cjs.js +10 -19
- package/package.json +5 -5
package/dist/cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var raf = require('raf');
|
|
6
4
|
var react = require('react');
|
|
7
5
|
var services = require('@folklore/services');
|
|
@@ -10,13 +8,6 @@ var EventsManager = require('@folklore/events');
|
|
|
10
8
|
var cancelablePromise = require('cancelable-promise');
|
|
11
9
|
var isNumber = require('lodash/isNumber');
|
|
12
10
|
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var raf__default = /*#__PURE__*/_interopDefaultLegacy(raf);
|
|
16
|
-
var createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
|
|
17
|
-
var EventsManager__default = /*#__PURE__*/_interopDefaultLegacy(EventsManager);
|
|
18
|
-
var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
|
|
19
|
-
|
|
20
11
|
function useCounter(desiredValue, _ref) {
|
|
21
12
|
let {
|
|
22
13
|
disabled = false,
|
|
@@ -48,20 +39,20 @@ function useCounter(desiredValue, _ref) {
|
|
|
48
39
|
const newValue = Math.round(startValue + progress * delta);
|
|
49
40
|
setCurrentValue(newValue);
|
|
50
41
|
if (newValue !== desiredValue) {
|
|
51
|
-
animationFrame =
|
|
42
|
+
animationFrame = raf(loop);
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
if (delta !== 0) {
|
|
55
46
|
duration = Math.min(maxDuration, Math.abs(delta) * speed * 1000);
|
|
56
47
|
startTime = Date.now();
|
|
57
|
-
animationFrame =
|
|
48
|
+
animationFrame = raf(loop);
|
|
58
49
|
} else if (disabled) {
|
|
59
50
|
setCurrentValue(desiredValue);
|
|
60
51
|
}
|
|
61
52
|
return () => {
|
|
62
53
|
canceled = true;
|
|
63
54
|
if (animationFrame !== null) {
|
|
64
|
-
|
|
55
|
+
raf.cancel(animationFrame);
|
|
65
56
|
}
|
|
66
57
|
};
|
|
67
58
|
}, [desiredValue, disabled, initialValue, maxDuration, speed]);
|
|
@@ -95,7 +86,7 @@ function useDailymotionPlayer() {
|
|
|
95
86
|
return null;
|
|
96
87
|
}
|
|
97
88
|
} = params;
|
|
98
|
-
const debug = react.useMemo(() =>
|
|
89
|
+
const debug = react.useMemo(() => createDebug('folklore:video:dailymotion'), []);
|
|
99
90
|
const [apiLoaded, setApiLoaded] = react.useState(typeof window !== 'undefined' && typeof window.dailymotion !== 'undefined');
|
|
100
91
|
const [playerReady, setPlayerReady] = react.useState(false);
|
|
101
92
|
const [loaded, setLoaded] = react.useState(false);
|
|
@@ -399,7 +390,7 @@ function useDailymotionPlayer() {
|
|
|
399
390
|
};
|
|
400
391
|
}
|
|
401
392
|
|
|
402
|
-
const eventsManager$1 = typeof document !== 'undefined' ? new
|
|
393
|
+
const eventsManager$1 = typeof document !== 'undefined' ? new EventsManager(document) : null;
|
|
403
394
|
function useDocumentEvent(event, callback) {
|
|
404
395
|
react.useEffect(() => {
|
|
405
396
|
if (eventsManager$1 !== null && callback !== null) {
|
|
@@ -629,7 +620,7 @@ function useIsVisible() {
|
|
|
629
620
|
};
|
|
630
621
|
}
|
|
631
622
|
|
|
632
|
-
const eventsManager = typeof window !== 'undefined' ? new
|
|
623
|
+
const eventsManager = typeof window !== 'undefined' ? new EventsManager(window) : null;
|
|
633
624
|
function useWindowEvent(event, callback) {
|
|
634
625
|
react.useEffect(() => {
|
|
635
626
|
if (eventsManager !== null && callback !== null) {
|
|
@@ -764,7 +755,7 @@ const useItemsPaginated = function (loader) {
|
|
|
764
755
|
}
|
|
765
756
|
return aPage > bPage ? 1 : -1;
|
|
766
757
|
}
|
|
767
|
-
if (
|
|
758
|
+
if (isNumber(a) && isNumber(b)) {
|
|
768
759
|
if (a === b) {
|
|
769
760
|
return 0;
|
|
770
761
|
}
|
|
@@ -940,7 +931,7 @@ function useNativeVideoPlayer(url) {
|
|
|
940
931
|
timeUpdateInterval = 1000,
|
|
941
932
|
onTimeUpdate: customOnTimeUpdate = null
|
|
942
933
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
943
|
-
const debug = react.useMemo(() =>
|
|
934
|
+
const debug = react.useMemo(() => createDebug('folklore:video:native'), []);
|
|
944
935
|
const elementRef = react.useRef(null);
|
|
945
936
|
const [loaded, setLoaded] = react.useState(false);
|
|
946
937
|
const [volume, setVolumeState] = react.useState(initialMuted ? 0 : 1);
|
|
@@ -1131,7 +1122,7 @@ function useVimeoPlayer(id) {
|
|
|
1131
1122
|
return match !== null ? match[1] : null;
|
|
1132
1123
|
}
|
|
1133
1124
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1134
|
-
const debug = react.useMemo(() =>
|
|
1125
|
+
const debug = react.useMemo(() => createDebug('folklore:video:vimeo'), []);
|
|
1135
1126
|
const [apiLoaded, setApiLoaded] = react.useState(false);
|
|
1136
1127
|
const apiRef = react.useRef(null);
|
|
1137
1128
|
const elementRef = react.useRef(null);
|
|
@@ -1433,7 +1424,7 @@ function useYouTubePlayer(id) {
|
|
|
1433
1424
|
return match !== null ? match[7] : null;
|
|
1434
1425
|
}
|
|
1435
1426
|
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1436
|
-
const debug = react.useMemo(() =>
|
|
1427
|
+
const debug = react.useMemo(() => createDebug('folklore:video:youtube'), []);
|
|
1437
1428
|
const [apiLoaded, setApiLoaded] = react.useState(typeof window !== 'undefined' && typeof window.YT !== 'undefined');
|
|
1438
1429
|
const apiRef = react.useRef(typeof window !== 'undefined' && typeof window.YT !== 'undefined' ? window.YT : null);
|
|
1439
1430
|
const elementRef = react.useRef(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"description": "React hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"sideEffects": false,
|
|
36
36
|
"scripts": {
|
|
37
37
|
"clean": "rm -rf dist",
|
|
38
|
-
"build": "rollup --config ../../rollup.config.js",
|
|
38
|
+
"build": "rollup --bundleConfigAsCjs --config ../../rollup.config.js",
|
|
39
39
|
"prepare": "npm run clean && npm run build"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c13ef70b8126b3182b3e3365f34f9231fa9b1535",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@folklore/events": "^0.0.
|
|
55
|
-
"@folklore/services": "^0.1.
|
|
54
|
+
"@folklore/events": "^0.0.6",
|
|
55
|
+
"@folklore/services": "^0.1.42",
|
|
56
56
|
"cancelable-promise": "^4.3.1",
|
|
57
57
|
"debug": "^4.3.4",
|
|
58
58
|
"lodash": "^4.17.21",
|