@wordpress/compose 6.7.0 → 6.8.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 +2 -0
- package/README.md +35 -109
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -63,8 +63,7 @@ For more details, you can refer to each Higher Order Component's README file. [A
|
|
|
63
63
|
|
|
64
64
|
### compose
|
|
65
65
|
|
|
66
|
-
Composes multiple higher-order components into a single higher-order component. Performs right-to-left function
|
|
67
|
-
composition, where each successive invocation is supplied the return value of the previous.
|
|
66
|
+
Composes multiple higher-order components into a single higher-order component. Performs right-to-left function composition, where each successive invocation is supplied the return value of the previous.
|
|
68
67
|
|
|
69
68
|
This is inspired by `lodash`'s `flowRight` function.
|
|
70
69
|
|
|
@@ -74,8 +73,7 @@ _Related_
|
|
|
74
73
|
|
|
75
74
|
### createHigherOrderComponent
|
|
76
75
|
|
|
77
|
-
Given a function mapping a component to an enhanced component and modifier
|
|
78
|
-
name, returns the enhanced component augmented with a generated displayName.
|
|
76
|
+
Given a function mapping a component to an enhanced component and modifier name, returns the enhanced component augmented with a generated displayName.
|
|
79
77
|
|
|
80
78
|
_Parameters_
|
|
81
79
|
|
|
@@ -88,24 +86,13 @@ _Returns_
|
|
|
88
86
|
|
|
89
87
|
### debounce
|
|
90
88
|
|
|
91
|
-
A simplified and properly typed version of lodash's `debounce`, that
|
|
92
|
-
always uses timers instead of sometimes using rAF.
|
|
89
|
+
A simplified and properly typed version of lodash's `debounce`, that always uses timers instead of sometimes using rAF.
|
|
93
90
|
|
|
94
|
-
Creates a debounced function that delays invoking `func` until after `wait`
|
|
95
|
-
milliseconds have elapsed since the last time the debounced function was
|
|
96
|
-
invoked. The debounced function comes with a `cancel` method to cancel delayed
|
|
97
|
-
`func` invocations and a `flush` method to immediately invoke them. Provide
|
|
98
|
-
`options` to indicate whether `func` should be invoked on the leading and/or
|
|
99
|
-
trailing edge of the `wait` timeout. The `func` is invoked with the last
|
|
100
|
-
arguments provided to the debounced function. Subsequent calls to the debounced
|
|
101
|
-
function return the result of the last `func` invocation.
|
|
91
|
+
Creates a debounced function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. The debounced function comes with a `cancel` method to cancel delayed `func` invocations and a `flush` method to immediately invoke them. Provide `options` to indicate whether `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. The `func` is invoked with the last arguments provided to the debounced function. Subsequent calls to the debounced function return the result of the last `func` invocation.
|
|
102
92
|
|
|
103
|
-
**Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
104
|
-
invoked on the trailing edge of the timeout only if the debounced function
|
|
105
|
-
is invoked more than once during the `wait` timeout.
|
|
93
|
+
**Note:** If `leading` and `trailing` options are `true`, `func` is invoked on the trailing edge of the timeout only if the debounced function is invoked more than once during the `wait` timeout.
|
|
106
94
|
|
|
107
|
-
If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
108
|
-
until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
95
|
+
If `wait` is `0` and `leading` is `false`, `func` invocation is deferred until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
109
96
|
|
|
110
97
|
_Parameters_
|
|
111
98
|
|
|
@@ -122,8 +109,7 @@ _Returns_
|
|
|
122
109
|
|
|
123
110
|
### ifCondition
|
|
124
111
|
|
|
125
|
-
Higher-order component creator, creating a new component which renders if
|
|
126
|
-
the given condition is satisfied or with the given optional prop name.
|
|
112
|
+
Higher-order component creator, creating a new component which renders if the given condition is satisfied or with the given optional prop name.
|
|
127
113
|
|
|
128
114
|
_Usage_
|
|
129
115
|
|
|
@@ -147,8 +133,7 @@ _Returns_
|
|
|
147
133
|
|
|
148
134
|
### pipe
|
|
149
135
|
|
|
150
|
-
Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
|
|
151
|
-
composition, where each successive invocation is supplied the return value of the previous.
|
|
136
|
+
Composes multiple higher-order components into a single higher-order component. Performs left-to-right function composition, where each successive invocation is supplied the return value of the previous.
|
|
152
137
|
|
|
153
138
|
This is inspired by `lodash`'s `flow` function.
|
|
154
139
|
|
|
@@ -158,29 +143,17 @@ _Related_
|
|
|
158
143
|
|
|
159
144
|
### pure
|
|
160
145
|
|
|
161
|
-
Given a component returns the enhanced component augmented with a component
|
|
162
|
-
only re-rendering when its props/state change
|
|
146
|
+
Given a component returns the enhanced component augmented with a component only re-rendering when its props/state change
|
|
163
147
|
|
|
164
148
|
### throttle
|
|
165
149
|
|
|
166
|
-
A simplified and properly typed version of lodash's `throttle`, that
|
|
167
|
-
always uses timers instead of sometimes using rAF.
|
|
150
|
+
A simplified and properly typed version of lodash's `throttle`, that always uses timers instead of sometimes using rAF.
|
|
168
151
|
|
|
169
|
-
Creates a throttled function that only invokes `func` at most once per
|
|
170
|
-
every `wait` milliseconds. The throttled function comes with a `cancel`
|
|
171
|
-
method to cancel delayed `func` invocations and a `flush` method to
|
|
172
|
-
immediately invoke them. Provide `options` to indicate whether `func`
|
|
173
|
-
should be invoked on the leading and/or trailing edge of the `wait`
|
|
174
|
-
timeout. The `func` is invoked with the last arguments provided to the
|
|
175
|
-
throttled function. Subsequent calls to the throttled function return
|
|
176
|
-
the result of the last `func` invocation.
|
|
152
|
+
Creates a throttled function that only invokes `func` at most once per every `wait` milliseconds. The throttled function comes with a `cancel` method to cancel delayed `func` invocations and a `flush` method to immediately invoke them. Provide `options` to indicate whether `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. The `func` is invoked with the last arguments provided to the throttled function. Subsequent calls to the throttled function return the result of the last `func` invocation.
|
|
177
153
|
|
|
178
|
-
**Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
179
|
-
invoked on the trailing edge of the timeout only if the throttled function
|
|
180
|
-
is invoked more than once during the `wait` timeout.
|
|
154
|
+
**Note:** If `leading` and `trailing` options are `true`, `func` is invoked on the trailing edge of the timeout only if the throttled function is invoked more than once during the `wait` timeout.
|
|
181
155
|
|
|
182
|
-
If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
183
|
-
until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
156
|
+
If `wait` is `0` and `leading` is `false`, `func` invocation is deferred until the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
184
157
|
|
|
185
158
|
_Parameters_
|
|
186
159
|
|
|
@@ -196,8 +169,7 @@ _Returns_
|
|
|
196
169
|
|
|
197
170
|
### useAsyncList
|
|
198
171
|
|
|
199
|
-
React hook returns an array which items get asynchronously appended from a source array.
|
|
200
|
-
This behavior is useful if we want to render a list of items asynchronously for performance reasons.
|
|
172
|
+
React hook returns an array which items get asynchronously appended from a source array. This behavior is useful if we want to render a list of items asynchronously for performance reasons.
|
|
201
173
|
|
|
202
174
|
_Parameters_
|
|
203
175
|
|
|
@@ -210,8 +182,7 @@ _Returns_
|
|
|
210
182
|
|
|
211
183
|
### useConstrainedTabbing
|
|
212
184
|
|
|
213
|
-
In Dialogs/modals, the tabbing must be constrained to the content of
|
|
214
|
-
the wrapper element. This hook adds the behavior to the returned ref.
|
|
185
|
+
In Dialogs/modals, the tabbing must be constrained to the content of the wrapper element. This hook adds the behavior to the returned ref.
|
|
215
186
|
|
|
216
187
|
_Usage_
|
|
217
188
|
|
|
@@ -264,10 +235,7 @@ _Returns_
|
|
|
264
235
|
|
|
265
236
|
### useDebounce
|
|
266
237
|
|
|
267
|
-
Debounces a function similar to Lodash's `debounce`. A new debounced function will
|
|
268
|
-
be returned and any scheduled calls cancelled if any of the arguments change,
|
|
269
|
-
including the function to debounce, so please wrap functions created on
|
|
270
|
-
render in components in `useCallback`.
|
|
238
|
+
Debounces a function similar to Lodash's `debounce`. A new debounced function will be returned and any scheduled calls cancelled if any of the arguments change, including the function to debounce, so please wrap functions created on render in components in `useCallback`.
|
|
271
239
|
|
|
272
240
|
_Related_
|
|
273
241
|
|
|
@@ -285,9 +253,7 @@ _Returns_
|
|
|
285
253
|
|
|
286
254
|
### useDisabled
|
|
287
255
|
|
|
288
|
-
In some circumstances, such as block previews, all focusable DOM elements
|
|
289
|
-
(input fields, links, buttons, etc.) need to be disabled. This hook adds the
|
|
290
|
-
behavior to disable nested DOM elements to the returned ref.
|
|
256
|
+
In some circumstances, such as block previews, all focusable DOM elements (input fields, links, buttons, etc.) need to be disabled. This hook adds the behavior to disable nested DOM elements to the returned ref.
|
|
291
257
|
|
|
292
258
|
If you can, prefer the use of the inert HTML attribute.
|
|
293
259
|
|
|
@@ -321,8 +287,7 @@ _Returns_
|
|
|
321
287
|
|
|
322
288
|
### useFocusableIframe
|
|
323
289
|
|
|
324
|
-
Dispatches a bubbling focus event when the iframe receives focus. Use
|
|
325
|
-
`onFocus` as usual on the iframe or a parent element.
|
|
290
|
+
Dispatches a bubbling focus event when the iframe receives focus. Use `onFocus` as usual on the iframe or a parent element.
|
|
326
291
|
|
|
327
292
|
_Returns_
|
|
328
293
|
|
|
@@ -358,10 +323,7 @@ _Returns_
|
|
|
358
323
|
|
|
359
324
|
### useFocusReturn
|
|
360
325
|
|
|
361
|
-
When opening modals/sidebars/dialogs, the focus
|
|
362
|
-
must move to the opened area and return to the
|
|
363
|
-
previously focused element when closed.
|
|
364
|
-
The current hook implements the returning behavior.
|
|
326
|
+
When opening modals/sidebars/dialogs, the focus must move to the opened area and return to the previously focused element when closed. The current hook implements the returning behavior.
|
|
365
327
|
|
|
366
328
|
_Usage_
|
|
367
329
|
|
|
@@ -403,9 +365,7 @@ _Returns_
|
|
|
403
365
|
|
|
404
366
|
### useIsomorphicLayoutEffect
|
|
405
367
|
|
|
406
|
-
Preferred over direct usage of `useLayoutEffect` when supporting
|
|
407
|
-
server rendered components (SSR) because currently React
|
|
408
|
-
throws a warning when using useLayoutEffect in that environment.
|
|
368
|
+
Preferred over direct usage of `useLayoutEffect` when supporting server rendered components (SSR) because currently React throws a warning when using useLayoutEffect in that environment.
|
|
409
369
|
|
|
410
370
|
### useKeyboardShortcut
|
|
411
371
|
|
|
@@ -437,25 +397,15 @@ _Returns_
|
|
|
437
397
|
|
|
438
398
|
Merges refs into one ref callback.
|
|
439
399
|
|
|
440
|
-
It also ensures that the merged ref callbacks are only called when they
|
|
441
|
-
change (as a result of a `useCallback` dependency update) OR when the ref
|
|
442
|
-
value changes, just as React does when passing a single ref callback to the
|
|
443
|
-
component.
|
|
400
|
+
It also ensures that the merged ref callbacks are only called when they change (as a result of a `useCallback` dependency update) OR when the ref value changes, just as React does when passing a single ref callback to the component.
|
|
444
401
|
|
|
445
|
-
As expected, if you pass a new function on every render, the ref callback
|
|
446
|
-
will be called after every render.
|
|
402
|
+
As expected, if you pass a new function on every render, the ref callback will be called after every render.
|
|
447
403
|
|
|
448
|
-
If you don't wish a ref callback to be called after every render, wrap it
|
|
449
|
-
with `useCallback( callback, dependencies )`. When a dependency changes, the
|
|
450
|
-
old ref callback will be called with `null` and the new ref callback will be
|
|
451
|
-
called with the same value.
|
|
404
|
+
If you don't wish a ref callback to be called after every render, wrap it with `useCallback( callback, dependencies )`. When a dependency changes, the old ref callback will be called with `null` and the new ref callback will be called with the same value.
|
|
452
405
|
|
|
453
|
-
To make ref callbacks easier to use, you can also pass the result of
|
|
454
|
-
`useRefEffect`, which makes cleanup easier by allowing you to return a
|
|
455
|
-
cleanup function instead of handling `null`.
|
|
406
|
+
To make ref callbacks easier to use, you can also pass the result of `useRefEffect`, which makes cleanup easier by allowing you to return a cleanup function instead of handling `null`.
|
|
456
407
|
|
|
457
|
-
It's also possible to _disable_ a ref (and its behaviour) by simply not
|
|
458
|
-
passing the ref.
|
|
408
|
+
It's also possible to _disable_ a ref (and its behaviour) by simply not passing the ref.
|
|
459
409
|
|
|
460
410
|
```jsx
|
|
461
411
|
const ref = useRefEffect( ( node ) => {
|
|
@@ -482,8 +432,7 @@ _Returns_
|
|
|
482
432
|
|
|
483
433
|
### usePrevious
|
|
484
434
|
|
|
485
|
-
Use something's value from the previous render.
|
|
486
|
-
Based on <https://usehooks.com/usePrevious/>.
|
|
435
|
+
Use something's value from the previous render. Based on <https://usehooks.com/usePrevious/>.
|
|
487
436
|
|
|
488
437
|
_Parameters_
|
|
489
438
|
|
|
@@ -503,18 +452,9 @@ _Returns_
|
|
|
503
452
|
|
|
504
453
|
### useRefEffect
|
|
505
454
|
|
|
506
|
-
Effect-like ref callback. Just like with `useEffect`, this allows you to
|
|
507
|
-
return a cleanup function to be run if the ref changes or one of the
|
|
508
|
-
dependencies changes. The ref is provided as an argument to the callback
|
|
509
|
-
functions. The main difference between this and `useEffect` is that
|
|
510
|
-
the `useEffect` callback is not called when the ref changes, but this is.
|
|
511
|
-
Pass the returned ref callback as the component's ref and merge multiple refs
|
|
512
|
-
with `useMergeRefs`.
|
|
455
|
+
Effect-like ref callback. Just like with `useEffect`, this allows you to return a cleanup function to be run if the ref changes or one of the dependencies changes. The ref is provided as an argument to the callback functions. The main difference between this and `useEffect` is that the `useEffect` callback is not called when the ref changes, but this is. Pass the returned ref callback as the component's ref and merge multiple refs with `useMergeRefs`.
|
|
513
456
|
|
|
514
|
-
It's worth noting that if the dependencies array is empty, there's not
|
|
515
|
-
strictly a need to clean up event handlers for example, because the node is
|
|
516
|
-
to be removed. It _is_ necessary if you add dependencies because the ref
|
|
517
|
-
callback will be called multiple times for the same node.
|
|
457
|
+
It's worth noting that if the dependencies array is empty, there's not strictly a need to clean up event handlers for example, because the node is to be removed. It _is_ necessary if you add dependencies because the ref callback will be called multiple times for the same node.
|
|
518
458
|
|
|
519
459
|
_Parameters_
|
|
520
460
|
|
|
@@ -527,8 +467,7 @@ _Returns_
|
|
|
527
467
|
|
|
528
468
|
### useResizeObserver
|
|
529
469
|
|
|
530
|
-
Hook which allows to listen the resize event of any target element when it changes sizes.
|
|
531
|
-
\_Note: `useResizeObserver` will report `null` until after first render.
|
|
470
|
+
Hook which allows to listen the resize event of any target element when it changes sizes. \_Note: `useResizeObserver` will report `null` until after first render.
|
|
532
471
|
|
|
533
472
|
_Usage_
|
|
534
473
|
|
|
@@ -547,10 +486,7 @@ const App = () => {
|
|
|
547
486
|
|
|
548
487
|
### useThrottle
|
|
549
488
|
|
|
550
|
-
Throttles a function similar to Lodash's `throttle`. A new throttled function will
|
|
551
|
-
be returned and any scheduled calls cancelled if any of the arguments change,
|
|
552
|
-
including the function to throttle, so please wrap functions created on
|
|
553
|
-
render in components in `useCallback`.
|
|
489
|
+
Throttles a function similar to Lodash's `throttle`. A new throttled function will be returned and any scheduled calls cancelled if any of the arguments change, including the function to throttle, so please wrap functions created on render in components in `useCallback`.
|
|
554
490
|
|
|
555
491
|
_Related_
|
|
556
492
|
|
|
@@ -588,9 +524,7 @@ _Returns_
|
|
|
588
524
|
|
|
589
525
|
### useWarnOnChange
|
|
590
526
|
|
|
591
|
-
Hook that performs a shallow comparison between the preview value of an object
|
|
592
|
-
and the new one, if there's a difference, it prints it to the console.
|
|
593
|
-
this is useful in performance related work, to check why a component re-renders.
|
|
527
|
+
Hook that performs a shallow comparison between the preview value of an object and the new one, if there's a difference, it prints it to the console. this is useful in performance related work, to check why a component re-renders.
|
|
594
528
|
|
|
595
529
|
_Usage_
|
|
596
530
|
|
|
@@ -611,12 +545,7 @@ _Parameters_
|
|
|
611
545
|
|
|
612
546
|
> **Deprecated**
|
|
613
547
|
|
|
614
|
-
Higher-order component creator which, given an object of DOM event types and
|
|
615
|
-
values corresponding to a callback function name on the component, will
|
|
616
|
-
create or update a window event handler to invoke the callback when an event
|
|
617
|
-
occurs. On behalf of the consuming developer, the higher-order component
|
|
618
|
-
manages unbinding when the component unmounts, and binding at most a single
|
|
619
|
-
event handler for the entire application.
|
|
548
|
+
Higher-order component creator which, given an object of DOM event types and values corresponding to a callback function name on the component, will create or update a window event handler to invoke the callback when an event occurs. On behalf of the consuming developer, the higher-order component manages unbinding when the component unmounts, and binding at most a single event handler for the entire application.
|
|
620
549
|
|
|
621
550
|
_Parameters_
|
|
622
551
|
|
|
@@ -628,20 +557,17 @@ _Returns_
|
|
|
628
557
|
|
|
629
558
|
### withInstanceId
|
|
630
559
|
|
|
631
|
-
A Higher Order Component used to be provide a unique instance ID by
|
|
632
|
-
component.
|
|
560
|
+
A Higher Order Component used to be provide a unique instance ID by component.
|
|
633
561
|
|
|
634
562
|
### withSafeTimeout
|
|
635
563
|
|
|
636
|
-
A higher-order component used to provide and manage delayed function calls
|
|
637
|
-
that ought to be bound to a component's lifecycle.
|
|
564
|
+
A higher-order component used to provide and manage delayed function calls that ought to be bound to a component's lifecycle.
|
|
638
565
|
|
|
639
566
|
### withState
|
|
640
567
|
|
|
641
568
|
> **Deprecated** Use `useState` instead.
|
|
642
569
|
|
|
643
|
-
A Higher Order Component used to provide and manage internal component state
|
|
644
|
-
via props.
|
|
570
|
+
A Higher Order Component used to provide and manage internal component state via props.
|
|
645
571
|
|
|
646
572
|
_Parameters_
|
|
647
573
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/compose",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "WordPress higher-order components (HOCs).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.16.0",
|
|
33
33
|
"@types/mousetrap": "^1.6.8",
|
|
34
|
-
"@wordpress/deprecated": "^3.
|
|
35
|
-
"@wordpress/dom": "^3.
|
|
36
|
-
"@wordpress/element": "^5.
|
|
37
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
38
|
-
"@wordpress/keycodes": "^3.
|
|
39
|
-
"@wordpress/priority-queue": "^2.
|
|
34
|
+
"@wordpress/deprecated": "^3.31.0",
|
|
35
|
+
"@wordpress/dom": "^3.31.0",
|
|
36
|
+
"@wordpress/element": "^5.8.0",
|
|
37
|
+
"@wordpress/is-shallow-equal": "^4.31.0",
|
|
38
|
+
"@wordpress/keycodes": "^3.31.0",
|
|
39
|
+
"@wordpress/priority-queue": "^2.31.0",
|
|
40
40
|
"change-case": "^4.1.2",
|
|
41
41
|
"clipboard": "^2.0.8",
|
|
42
42
|
"mousetrap": "^1.6.5",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d61700b9f1c72ba0b030fc815ef1685b4f4031ec"
|
|
52
52
|
}
|