@wordpress/compose 5.15.2 → 5.16.1-next.4d3b314fd5.0
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 +11 -0
- package/README.md +86 -8
- package/build/higher-order/compose.js +5 -4
- package/build/higher-order/compose.js.map +1 -1
- package/build/higher-order/pipe.js +93 -0
- package/build/higher-order/pipe.js.map +1 -0
- package/build/hooks/use-debounce/index.js +11 -10
- package/build/hooks/use-debounce/index.js.map +1 -1
- package/build/hooks/use-disabled/index.js +3 -1
- package/build/hooks/use-disabled/index.js.map +1 -1
- package/build/hooks/use-drop-zone/index.js +4 -10
- package/build/hooks/use-drop-zone/index.js.map +1 -1
- package/build/hooks/use-fixed-window-list/index.js +5 -5
- package/build/hooks/use-fixed-window-list/index.js.map +1 -1
- package/build/hooks/use-instance-id/index.js +22 -20
- package/build/hooks/use-instance-id/index.js.map +1 -1
- package/build/hooks/use-throttle/index.js +12 -8
- package/build/hooks/use-throttle/index.js.map +1 -1
- package/build/index.js +37 -0
- package/build/index.js.map +1 -1
- package/build/index.native.js +37 -0
- package/build/index.native.js.map +1 -1
- package/build/utils/debounce/index.js +230 -0
- package/build/utils/debounce/index.js.map +1 -0
- package/build/utils/throttle/index.js +98 -0
- package/build/utils/throttle/index.js.map +1 -0
- package/build-module/higher-order/compose.js +4 -3
- package/build-module/higher-order/compose.js.map +1 -1
- package/build-module/higher-order/pipe.js +85 -0
- package/build-module/higher-order/pipe.js.map +1 -0
- package/build-module/hooks/use-debounce/index.js +10 -9
- package/build-module/hooks/use-debounce/index.js.map +1 -1
- package/build-module/hooks/use-disabled/index.js +3 -2
- package/build-module/hooks/use-disabled/index.js.map +1 -1
- package/build-module/hooks/use-drop-zone/index.js +4 -10
- package/build-module/hooks/use-drop-zone/index.js.map +1 -1
- package/build-module/hooks/use-fixed-window-list/index.js +5 -5
- package/build-module/hooks/use-fixed-window-list/index.js.map +1 -1
- package/build-module/hooks/use-instance-id/index.js +20 -19
- package/build-module/hooks/use-instance-id/index.js.map +1 -1
- package/build-module/hooks/use-throttle/index.js +11 -7
- package/build-module/hooks/use-throttle/index.js.map +1 -1
- package/build-module/index.js +7 -2
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +7 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/utils/debounce/index.js +221 -0
- package/build-module/utils/debounce/index.js.map +1 -0
- package/build-module/utils/throttle/index.js +88 -0
- package/build-module/utils/throttle/index.js.map +1 -0
- package/build-types/higher-order/compose.d.ts +2 -5
- package/build-types/higher-order/compose.d.ts.map +1 -1
- package/build-types/higher-order/pipe.d.ts +61 -0
- package/build-types/higher-order/pipe.d.ts.map +1 -0
- package/build-types/hooks/use-debounce/index.d.ts +6 -6
- package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
- package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
- package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
- package/build-types/hooks/use-instance-id/index.d.ts +11 -6
- package/build-types/hooks/use-instance-id/index.d.ts.map +1 -1
- package/build-types/hooks/use-throttle/index.d.ts +6 -6
- package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
- package/build-types/index.d.ts +3 -0
- package/build-types/utils/debounce/index.d.ts +104 -0
- package/build-types/utils/debounce/index.d.ts.map +1 -0
- package/build-types/utils/throttle/index.d.ts +77 -0
- package/build-types/utils/throttle/index.d.ts.map +1 -0
- package/package.json +8 -8
- package/src/higher-order/compose.ts +5 -3
- package/src/higher-order/pipe.ts +76 -0
- package/src/higher-order/test/compose.ts +39 -0
- package/src/higher-order/test/pipe.ts +37 -0
- package/src/hooks/use-debounce/index.js +11 -9
- package/src/hooks/use-disabled/index.js +3 -2
- package/src/hooks/use-drop-zone/index.js +6 -13
- package/src/hooks/use-fixed-window-list/index.js +5 -5
- package/src/hooks/use-instance-id/index.ts +59 -0
- package/src/hooks/use-throttle/index.js +11 -7
- package/src/index.js +6 -1
- package/src/index.native.js +6 -1
- package/src/utils/debounce/index.ts +260 -0
- package/src/utils/debounce/test/index.ts +367 -0
- package/src/utils/throttle/index.ts +95 -0
- package/src/utils/throttle/test/index.ts +256 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/src/hooks/use-instance-id/index.js +0 -42
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parts of this source were derived and modified from lodash,
|
|
3
|
+
* released under the MIT license.
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/lodash/lodash
|
|
6
|
+
*
|
|
7
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
8
|
+
*
|
|
9
|
+
* Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
10
|
+
* DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
11
|
+
*
|
|
12
|
+
* This software consists of voluntary contributions made by many
|
|
13
|
+
* individuals. For exact contribution history, see the revision history
|
|
14
|
+
* available at https://github.com/lodash/lodash
|
|
15
|
+
*
|
|
16
|
+
* The following license applies to all parts of this software except as
|
|
17
|
+
* documented below:
|
|
18
|
+
*
|
|
19
|
+
* ====
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
* a copy of this software and associated documentation files (the
|
|
23
|
+
* "Software"), to deal in the Software without restriction, including
|
|
24
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
* the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be
|
|
30
|
+
* included in all copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
35
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
36
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
37
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
38
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Creates a pipe function.
|
|
42
|
+
*
|
|
43
|
+
* Allows to choose whether to perform left-to-right or right-to-left composition.
|
|
44
|
+
*
|
|
45
|
+
* @see https://docs-lodash.com/v4/flow/
|
|
46
|
+
*
|
|
47
|
+
* @param {boolean} reverse True if right-to-left, false for left-to-right composition.
|
|
48
|
+
*/
|
|
49
|
+
declare const basePipe: (reverse?: boolean) => (...funcs: Function[]) => (...args: unknown[]) => unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
|
|
52
|
+
* composition, where each successive invocation is supplied the return value of the previous.
|
|
53
|
+
*
|
|
54
|
+
* This is inspired by `lodash`'s `flow` function.
|
|
55
|
+
*
|
|
56
|
+
* @see https://docs-lodash.com/v4/flow/
|
|
57
|
+
*/
|
|
58
|
+
declare const pipe: (...funcs: Function[]) => (...args: unknown[]) => unknown;
|
|
59
|
+
export { basePipe };
|
|
60
|
+
export default pipe;
|
|
61
|
+
//# sourceMappingURL=pipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../src/higher-order/pipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;;;GAQG;AACH,QAAA,MAAM,QAAQ,aACF,OAAO,gBACN,QAAQ,EAAE,eACX,OAAO,EAAE,YASnB,CAAC;AAEH;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,aApBG,QAAQ,EAAE,eACX,OAAO,EAAE,YAmBE,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,eAAe,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Debounces a function
|
|
2
|
+
* Debounces a function similar to Lodash's `debounce`. A new debounced function will
|
|
3
3
|
* be returned and any scheduled calls cancelled if any of the arguments change,
|
|
4
4
|
* including the function to debounce, so please wrap functions created on
|
|
5
5
|
* render in components in `useCallback`.
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @template {(...args: any[]) => void} TFunc
|
|
10
10
|
*
|
|
11
|
-
* @param {TFunc}
|
|
12
|
-
* @param {number}
|
|
13
|
-
* @param {import('
|
|
14
|
-
* @return {import('
|
|
11
|
+
* @param {TFunc} fn The function to debounce.
|
|
12
|
+
* @param {number} [wait] The number of milliseconds to delay.
|
|
13
|
+
* @param {import('../../utils/debounce').DebounceOptions} [options] The options object.
|
|
14
|
+
* @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function.
|
|
15
15
|
*/
|
|
16
|
-
export default function useDebounce<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("
|
|
16
|
+
export default function useDebounce<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("../../utils/debounce").DebounceOptions | undefined): import("../../utils/debounce").DebouncedFunc<TFunc>;
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-debounce/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-debounce/index.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,mKAcrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-disabled/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-disabled/index.js"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;IAjB4B,UAAU,GAA3B,OAAO;IACN,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CAgKnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;GAaG;AACH;IAV2C,UAAU;IACV,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,UAAU,QAAtC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,SAAS,QAArC,UAAU,KAAK,IAAI;IACS,MAAM,QAAlC,SAAS,KAAK,IAAI;IAErB,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;GAaG;AACH;IAV2C,UAAU;IACV,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,UAAU,QAAtC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,SAAS,QAArC,UAAU,KAAK,IAAI;IACS,MAAM,QAAlC,SAAS,KAAK,IAAI;IAErB,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CA4LnD"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Specify the useInstanceId *function* signatures.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* More accurately, useInstanceId distinguishes between three different
|
|
5
|
+
* signatures:
|
|
6
|
+
*
|
|
7
|
+
* 1. When only object is given, the returned value is a number
|
|
8
|
+
* 2. When object and prefix is given, the returned value is a string
|
|
9
|
+
* 3. When preferredId is given, the returned value is the type of preferredId
|
|
8
10
|
*/
|
|
9
|
-
|
|
11
|
+
declare function useInstanceId(object: object): number;
|
|
12
|
+
declare function useInstanceId(object: object, prefix: string): string;
|
|
13
|
+
declare function useInstanceId<T extends string | number>(object: object, prefix: string, preferredId?: T): T;
|
|
14
|
+
export default useInstanceId;
|
|
10
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-instance-id/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-instance-id/index.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,iBAAS,aAAa,CAAE,MAAM,EAAE,MAAM,GAAI,MAAM,CAAC;AACjD,iBAAS,aAAa,CAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,MAAM,CAAC;AACjE,iBAAS,aAAa,CAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAChD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,CAAC,GACb,CAAC,CAAC;AAuBL,eAAe,aAAa,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Throttles a function
|
|
2
|
+
* Throttles a function similar to Lodash's `throttle`. A new throttled function will
|
|
3
3
|
* be returned and any scheduled calls cancelled if any of the arguments change,
|
|
4
4
|
* including the function to throttle, so please wrap functions created on
|
|
5
5
|
* render in components in `useCallback`.
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @template {(...args: any[]) => void} TFunc
|
|
10
10
|
*
|
|
11
|
-
* @param {TFunc}
|
|
12
|
-
* @param {number}
|
|
13
|
-
* @param {import('
|
|
14
|
-
* @return {import('
|
|
11
|
+
* @param {TFunc} fn The function to throttle.
|
|
12
|
+
* @param {number} [wait] The number of milliseconds to throttle invocations to.
|
|
13
|
+
* @param {import('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details.
|
|
14
|
+
* @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function.
|
|
15
15
|
*/
|
|
16
|
-
export default function useThrottle<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("
|
|
16
|
+
export default function useThrottle<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("../../utils/throttle").ThrottleOptions | undefined): import("../../utils/debounce").DebouncedFunc<TFunc>;
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-throttle/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-throttle/index.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,mKAcrC"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from "./utils/create-higher-order-component";
|
|
2
|
+
export * from "./utils/debounce";
|
|
3
|
+
export * from "./utils/throttle";
|
|
2
4
|
export { default as compose } from "./higher-order/compose";
|
|
5
|
+
export { default as pipe } from "./higher-order/pipe";
|
|
3
6
|
export { default as ifCondition } from "./higher-order/if-condition";
|
|
4
7
|
export { default as pure } from "./higher-order/pure";
|
|
5
8
|
export { default as withGlobalEvents } from "./higher-order/with-global-events";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parts of this source were derived and modified from lodash,
|
|
3
|
+
* released under the MIT license.
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/lodash/lodash
|
|
6
|
+
*
|
|
7
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
8
|
+
*
|
|
9
|
+
* Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
10
|
+
* DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
11
|
+
*
|
|
12
|
+
* This software consists of voluntary contributions made by many
|
|
13
|
+
* individuals. For exact contribution history, see the revision history
|
|
14
|
+
* available at https://github.com/lodash/lodash
|
|
15
|
+
*
|
|
16
|
+
* The following license applies to all parts of this software except as
|
|
17
|
+
* documented below:
|
|
18
|
+
*
|
|
19
|
+
* ====
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
* a copy of this software and associated documentation files (the
|
|
23
|
+
* "Software"), to deal in the Software without restriction, including
|
|
24
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
* the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be
|
|
30
|
+
* included in all copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
35
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
36
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
37
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
38
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
export interface DebounceOptions {
|
|
41
|
+
leading: boolean;
|
|
42
|
+
maxWait: number;
|
|
43
|
+
trailing: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface DebouncedFunc<T extends (...args: any[]) => any> {
|
|
46
|
+
/**
|
|
47
|
+
* Call the original function, but applying the debounce rules.
|
|
48
|
+
*
|
|
49
|
+
* If the debounced function can be run immediately, this calls it and returns its return
|
|
50
|
+
* value.
|
|
51
|
+
*
|
|
52
|
+
* Otherwise, it returns the return value of the last invocation, or undefined if the debounced
|
|
53
|
+
* function was not invoked yet.
|
|
54
|
+
*/
|
|
55
|
+
(...args: Parameters<T>): ReturnType<T> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Throw away any pending invocation of the debounced function.
|
|
58
|
+
*/
|
|
59
|
+
cancel(): void;
|
|
60
|
+
/**
|
|
61
|
+
* If there is a pending invocation of the debounced function, invoke it immediately and return
|
|
62
|
+
* its return value.
|
|
63
|
+
*
|
|
64
|
+
* Otherwise, return the value from the last invocation, or undefined if the debounced function
|
|
65
|
+
* was never invoked.
|
|
66
|
+
*/
|
|
67
|
+
flush(): ReturnType<T> | undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A simplified and properly typed version of lodash's `debounce`, that
|
|
71
|
+
* always uses timers instead of sometimes using rAF.
|
|
72
|
+
*
|
|
73
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
74
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
75
|
+
* invoked. The debounced function comes with a `cancel` method to cancel delayed
|
|
76
|
+
* `func` invocations and a `flush` method to immediately invoke them. Provide
|
|
77
|
+
* `options` to indicate whether `func` should be invoked on the leading and/or
|
|
78
|
+
* trailing edge of the `wait` timeout. The `func` is invoked with the last
|
|
79
|
+
* arguments provided to the debounced function. Subsequent calls to the debounced
|
|
80
|
+
* function return the result of the last `func` invocation.
|
|
81
|
+
*
|
|
82
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
83
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
84
|
+
* is invoked more than once during the `wait` timeout.
|
|
85
|
+
*
|
|
86
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
87
|
+
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
88
|
+
*
|
|
89
|
+
* @param {Function} func The function to debounce.
|
|
90
|
+
* @param {number} wait The number of milliseconds to delay.
|
|
91
|
+
* @param {Partial< DebounceOptions >} options The options object.
|
|
92
|
+
* @param {boolean} options.leading Specify invoking on the leading edge of the timeout.
|
|
93
|
+
* @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked.
|
|
94
|
+
* @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout.
|
|
95
|
+
*
|
|
96
|
+
* @return Returns the new debounced function.
|
|
97
|
+
*/
|
|
98
|
+
export declare const debounce: <FunctionT extends (...args: unknown[]) => unknown>(func: FunctionT, wait: number, options?: Partial<DebounceOptions> | undefined) => {
|
|
99
|
+
(this: unknown, ...args: Parameters<FunctionT>): ReturnType<FunctionT>;
|
|
100
|
+
cancel: () => void;
|
|
101
|
+
flush: () => ReturnType<FunctionT>;
|
|
102
|
+
pending: () => boolean;
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/debounce/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa,CAAE,CAAC,SAAS,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAM,GAAG;IAClE;;;;;;;;OAQG;IACH,CAAE,GAAG,IAAI,EAAE,UAAU,CAAE,CAAC,CAAE,GAAI,UAAU,CAAE,CAAC,CAAE,GAAG,SAAS,CAAC;IAE1D;;OAEG;IACH,MAAM,IAAI,IAAI,CAAC;IAEf;;;;;;OAMG;IACH,KAAK,IAAI,UAAU,CAAE,CAAC,CAAE,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,QAAQ,+BAAkC,OAAO,EAAE,KAAM,OAAO,yBAEtE,MAAM;WAgIc,OAAO;;;;CA2BjC,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parts of this source were derived and modified from lodash,
|
|
3
|
+
* released under the MIT license.
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/lodash/lodash
|
|
6
|
+
*
|
|
7
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
8
|
+
*
|
|
9
|
+
* Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
10
|
+
* DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
11
|
+
*
|
|
12
|
+
* This software consists of voluntary contributions made by many
|
|
13
|
+
* individuals. For exact contribution history, see the revision history
|
|
14
|
+
* available at https://github.com/lodash/lodash
|
|
15
|
+
*
|
|
16
|
+
* The following license applies to all parts of this software except as
|
|
17
|
+
* documented below:
|
|
18
|
+
*
|
|
19
|
+
* ====
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
* a copy of this software and associated documentation files (the
|
|
23
|
+
* "Software"), to deal in the Software without restriction, including
|
|
24
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
* the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be
|
|
30
|
+
* included in all copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
35
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
36
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
37
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
38
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
export interface ThrottleOptions {
|
|
41
|
+
leading?: boolean;
|
|
42
|
+
trailing?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A simplified and properly typed version of lodash's `throttle`, that
|
|
46
|
+
* always uses timers instead of sometimes using rAF.
|
|
47
|
+
*
|
|
48
|
+
* Creates a throttled function that only invokes `func` at most once per
|
|
49
|
+
* every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
50
|
+
* method to cancel delayed `func` invocations and a `flush` method to
|
|
51
|
+
* immediately invoke them. Provide `options` to indicate whether `func`
|
|
52
|
+
* should be invoked on the leading and/or trailing edge of the `wait`
|
|
53
|
+
* timeout. The `func` is invoked with the last arguments provided to the
|
|
54
|
+
* throttled function. Subsequent calls to the throttled function return
|
|
55
|
+
* the result of the last `func` invocation.
|
|
56
|
+
*
|
|
57
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
58
|
+
* invoked on the trailing edge of the timeout only if the throttled function
|
|
59
|
+
* is invoked more than once during the `wait` timeout.
|
|
60
|
+
*
|
|
61
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
62
|
+
* until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
63
|
+
*
|
|
64
|
+
* @param {Function} func The function to throttle.
|
|
65
|
+
* @param {number} wait The number of milliseconds to throttle invocations to.
|
|
66
|
+
* @param {Partial< ThrottleOptions >} options The options object.
|
|
67
|
+
* @param {boolean} options.leading Specify invoking on the leading edge of the timeout.
|
|
68
|
+
* @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout.
|
|
69
|
+
* @return Returns the new throttled function.
|
|
70
|
+
*/
|
|
71
|
+
export declare const throttle: <FunctionT extends (...args: unknown[]) => unknown>(func: FunctionT, wait: number, options?: ThrottleOptions | undefined) => {
|
|
72
|
+
(this: unknown, ...args: Parameters<FunctionT>): ReturnType<FunctionT>;
|
|
73
|
+
cancel: () => void;
|
|
74
|
+
flush: () => ReturnType<FunctionT>;
|
|
75
|
+
pending: () => boolean;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/throttle/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAOH,MAAM,WAAW,eAAe;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,QAAQ,+BAAkC,OAAO,EAAE,KAAM,OAAO,yBAEtE,MAAM;;;;;CAeZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/compose",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.1-next.4d3b314fd5.0",
|
|
4
4
|
"description": "WordPress higher-order components (HOCs).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@babel/runtime": "^7.16.0",
|
|
33
33
|
"@types/lodash": "^4.14.172",
|
|
34
34
|
"@types/mousetrap": "^1.6.8",
|
|
35
|
-
"@wordpress/deprecated": "^3.
|
|
36
|
-
"@wordpress/dom": "^3.
|
|
37
|
-
"@wordpress/element": "^4.
|
|
38
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
39
|
-
"@wordpress/keycodes": "^3.
|
|
40
|
-
"@wordpress/priority-queue": "^2.
|
|
35
|
+
"@wordpress/deprecated": "^3.18.1-next.4d3b314fd5.0",
|
|
36
|
+
"@wordpress/dom": "^3.18.1-next.4d3b314fd5.0",
|
|
37
|
+
"@wordpress/element": "^4.16.1-next.4d3b314fd5.0",
|
|
38
|
+
"@wordpress/is-shallow-equal": "^4.18.1-next.4d3b314fd5.0",
|
|
39
|
+
"@wordpress/keycodes": "^3.18.1-next.4d3b314fd5.0",
|
|
40
|
+
"@wordpress/priority-queue": "^2.18.1-next.4d3b314fd5.0",
|
|
41
41
|
"change-case": "^4.1.2",
|
|
42
42
|
"clipboard": "^2.0.8",
|
|
43
43
|
"lodash": "^4.17.21",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "25054766423cb49d959eb656c2533530073ff5c2"
|
|
54
54
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { basePipe } from './pipe';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
|
|
8
8
|
* composition, where each successive invocation is supplied the return value of the previous.
|
|
9
9
|
*
|
|
10
|
-
* This is
|
|
10
|
+
* This is inspired by `lodash`'s `flowRight` function.
|
|
11
11
|
*
|
|
12
12
|
* @see https://docs-lodash.com/v4/flow-right/
|
|
13
13
|
*/
|
|
14
|
+
const compose = basePipe( true );
|
|
15
|
+
|
|
14
16
|
export default compose;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parts of this source were derived and modified from lodash,
|
|
3
|
+
* released under the MIT license.
|
|
4
|
+
*
|
|
5
|
+
* https://github.com/lodash/lodash
|
|
6
|
+
*
|
|
7
|
+
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
8
|
+
*
|
|
9
|
+
* Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
10
|
+
* DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
11
|
+
*
|
|
12
|
+
* This software consists of voluntary contributions made by many
|
|
13
|
+
* individuals. For exact contribution history, see the revision history
|
|
14
|
+
* available at https://github.com/lodash/lodash
|
|
15
|
+
*
|
|
16
|
+
* The following license applies to all parts of this software except as
|
|
17
|
+
* documented below:
|
|
18
|
+
*
|
|
19
|
+
* ====
|
|
20
|
+
*
|
|
21
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
+
* a copy of this software and associated documentation files (the
|
|
23
|
+
* "Software"), to deal in the Software without restriction, including
|
|
24
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
+
* the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be
|
|
30
|
+
* included in all copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
35
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
36
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
37
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
38
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a pipe function.
|
|
43
|
+
*
|
|
44
|
+
* Allows to choose whether to perform left-to-right or right-to-left composition.
|
|
45
|
+
*
|
|
46
|
+
* @see https://docs-lodash.com/v4/flow/
|
|
47
|
+
*
|
|
48
|
+
* @param {boolean} reverse True if right-to-left, false for left-to-right composition.
|
|
49
|
+
*/
|
|
50
|
+
const basePipe =
|
|
51
|
+
( reverse: boolean = false ) =>
|
|
52
|
+
( ...funcs: Function[] ) =>
|
|
53
|
+
( ...args: unknown[] ) => {
|
|
54
|
+
const functions = funcs.flat();
|
|
55
|
+
if ( reverse ) {
|
|
56
|
+
functions.reverse();
|
|
57
|
+
}
|
|
58
|
+
return functions.reduce(
|
|
59
|
+
( prev, func ) => [ func( ...prev ) ],
|
|
60
|
+
args
|
|
61
|
+
)[ 0 ];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
|
|
66
|
+
* composition, where each successive invocation is supplied the return value of the previous.
|
|
67
|
+
*
|
|
68
|
+
* This is inspired by `lodash`'s `flow` function.
|
|
69
|
+
*
|
|
70
|
+
* @see https://docs-lodash.com/v4/flow/
|
|
71
|
+
*/
|
|
72
|
+
const pipe = basePipe();
|
|
73
|
+
|
|
74
|
+
export { basePipe };
|
|
75
|
+
|
|
76
|
+
export default pipe;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import compose from '../compose';
|
|
5
|
+
|
|
6
|
+
describe( 'compose', () => {
|
|
7
|
+
it( 'returns the initial value if no functions are specified', () => {
|
|
8
|
+
expect( compose()( 'test' ) ).toBe( 'test' );
|
|
9
|
+
} );
|
|
10
|
+
|
|
11
|
+
it( 'executes functions right-to-left when passed as separate arguments', () => {
|
|
12
|
+
const a = ( value ) => ( value += 'a' );
|
|
13
|
+
const b = ( value ) => ( value += 'b' );
|
|
14
|
+
const c = ( value ) => ( value += 'c' );
|
|
15
|
+
|
|
16
|
+
expect( compose( a, b, c )( 'test' ) ).toBe( 'testcba' );
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
it( 'executes functions right-to-left when passed as a single array', () => {
|
|
20
|
+
const a = ( value ) => ( value += 'a' );
|
|
21
|
+
const b = ( value ) => ( value += 'b' );
|
|
22
|
+
const c = ( value ) => ( value += 'c' );
|
|
23
|
+
|
|
24
|
+
expect( compose( [ a, b, c ] )( 'test' ) ).toBe( 'testcba' );
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
it( 'executes functions right-to-left when passed as a mix of separate arguments and arrays', () => {
|
|
28
|
+
const a = ( value ) => ( value += 'a' );
|
|
29
|
+
const b = ( value ) => ( value += 'b' );
|
|
30
|
+
const c = ( value ) => ( value += 'c' );
|
|
31
|
+
const d = ( value ) => ( value += 'd' );
|
|
32
|
+
const e = ( value ) => ( value += 'e' );
|
|
33
|
+
const f = ( value ) => ( value += 'f' );
|
|
34
|
+
|
|
35
|
+
expect( compose( [ a, b ], c, [ d ], e )( 'test' ) ).toBe(
|
|
36
|
+
'testedcba'
|
|
37
|
+
);
|
|
38
|
+
} );
|
|
39
|
+
} );
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import pipe from '../pipe';
|
|
5
|
+
|
|
6
|
+
describe( 'pipe', () => {
|
|
7
|
+
it( 'returns the initial value if no functions are specified', () => {
|
|
8
|
+
expect( pipe()( 'test' ) ).toBe( 'test' );
|
|
9
|
+
} );
|
|
10
|
+
|
|
11
|
+
it( 'executes functions left-to-right when passed as separate arguments', () => {
|
|
12
|
+
const a = ( value ) => ( value += 'a' );
|
|
13
|
+
const b = ( value ) => ( value += 'b' );
|
|
14
|
+
const c = ( value ) => ( value += 'c' );
|
|
15
|
+
|
|
16
|
+
expect( pipe( a, b, c )( 'test' ) ).toBe( 'testabc' );
|
|
17
|
+
} );
|
|
18
|
+
|
|
19
|
+
it( 'executes functions left-to-right when passed as a single array', () => {
|
|
20
|
+
const a = ( value ) => ( value += 'a' );
|
|
21
|
+
const b = ( value ) => ( value += 'b' );
|
|
22
|
+
const c = ( value ) => ( value += 'c' );
|
|
23
|
+
|
|
24
|
+
expect( pipe( [ a, b, c ] )( 'test' ) ).toBe( 'testabc' );
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
it( 'executes functions left-to-right when passed as a mix of separate arguments and arrays', () => {
|
|
28
|
+
const a = ( value ) => ( value += 'a' );
|
|
29
|
+
const b = ( value ) => ( value += 'b' );
|
|
30
|
+
const c = ( value ) => ( value += 'c' );
|
|
31
|
+
const d = ( value ) => ( value += 'd' );
|
|
32
|
+
const e = ( value ) => ( value += 'e' );
|
|
33
|
+
const f = ( value ) => ( value += 'f' );
|
|
34
|
+
|
|
35
|
+
expect( pipe( [ a, b ], c, [ d ], e )( 'test' ) ).toBe( 'testabcde' );
|
|
36
|
+
} );
|
|
37
|
+
} );
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { debounce } from 'lodash';
|
|
5
4
|
import { useMemoOne } from 'use-memo-one';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -9,9 +8,13 @@ import { useMemoOne } from 'use-memo-one';
|
|
|
9
8
|
*/
|
|
10
9
|
import { useEffect } from '@wordpress/element';
|
|
11
10
|
|
|
12
|
-
/* eslint-disable jsdoc/valid-types */
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { debounce } from '../../utils/debounce';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Debounces a function similar to Lodash's `debounce`. A new debounced function will
|
|
15
18
|
* be returned and any scheduled calls cancelled if any of the arguments change,
|
|
16
19
|
* including the function to debounce, so please wrap functions created on
|
|
17
20
|
* render in components in `useCallback`.
|
|
@@ -20,15 +23,14 @@ import { useEffect } from '@wordpress/element';
|
|
|
20
23
|
*
|
|
21
24
|
* @template {(...args: any[]) => void} TFunc
|
|
22
25
|
*
|
|
23
|
-
* @param {TFunc}
|
|
24
|
-
* @param {number}
|
|
25
|
-
* @param {import('
|
|
26
|
-
* @return {import('
|
|
26
|
+
* @param {TFunc} fn The function to debounce.
|
|
27
|
+
* @param {number} [wait] The number of milliseconds to delay.
|
|
28
|
+
* @param {import('../../utils/debounce').DebounceOptions} [options] The options object.
|
|
29
|
+
* @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function.
|
|
27
30
|
*/
|
|
28
31
|
export default function useDebounce( fn, wait, options ) {
|
|
29
|
-
/* eslint-enable jsdoc/valid-types */
|
|
30
32
|
const debounced = useMemoOne(
|
|
31
|
-
() => debounce( fn, wait, options ),
|
|
33
|
+
() => debounce( fn, wait ?? 0, options ),
|
|
32
34
|
[ fn, wait, options ]
|
|
33
35
|
);
|
|
34
36
|
useEffect( () => () => debounced.cancel(), [ debounced ] );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { includes
|
|
4
|
+
import { includes } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -11,6 +11,7 @@ import { focus } from '@wordpress/dom';
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
|
+
import { debounce } from '../../utils/debounce';
|
|
14
15
|
import useRefEffect from '../use-ref-effect';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -176,7 +177,7 @@ export default function useDisabled( {
|
|
|
176
177
|
|
|
177
178
|
// Debounce re-disable since disabling process itself will incur
|
|
178
179
|
// additional mutations which should be ignored.
|
|
179
|
-
const debouncedDisable = debounce( disable,
|
|
180
|
+
const debouncedDisable = debounce( disable, 0, {
|
|
180
181
|
leading: true,
|
|
181
182
|
} );
|
|
182
183
|
disable();
|