@wordpress/compose 7.40.1-next.v.202602271551.0 → 7.40.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 +4 -0
- package/README.md +11 -9
- package/build/hooks/use-copy-on-click/index.cjs +43 -18
- package/build/hooks/use-copy-on-click/index.cjs.map +4 -4
- package/build/hooks/use-copy-to-clipboard/index.cjs +58 -12
- package/build/hooks/use-copy-to-clipboard/index.cjs.map +4 -4
- package/build/hooks/use-dialog/index.cjs +2 -2
- package/build/hooks/use-dialog/index.cjs.map +3 -3
- package/build/hooks/use-focus-on-mount/index.cjs +15 -13
- package/build/hooks/use-focus-on-mount/index.cjs.map +3 -3
- package/build/hooks/use-media-query/index.cjs +12 -9
- package/build/hooks/use-media-query/index.cjs.map +3 -3
- package/build/hooks/use-viewport-match/index.cjs +2 -2
- package/build/hooks/use-viewport-match/index.cjs.map +2 -2
- package/build/index.cjs +2 -2
- package/build/index.cjs.map +2 -2
- package/build-module/hooks/use-copy-on-click/index.mjs +44 -19
- package/build-module/hooks/use-copy-on-click/index.mjs.map +3 -3
- package/build-module/hooks/use-copy-to-clipboard/index.mjs +53 -12
- package/build-module/hooks/use-copy-to-clipboard/index.mjs.map +3 -3
- package/build-module/hooks/use-dialog/index.mjs +1 -1
- package/build-module/hooks/use-dialog/index.mjs.map +2 -2
- package/build-module/hooks/use-focus-on-mount/index.mjs +15 -9
- package/build-module/hooks/use-focus-on-mount/index.mjs.map +3 -3
- package/build-module/hooks/use-media-query/index.mjs +12 -9
- package/build-module/hooks/use-media-query/index.mjs.map +3 -3
- package/build-module/hooks/use-viewport-match/index.mjs +2 -2
- package/build-module/hooks/use-viewport-match/index.mjs.map +2 -2
- package/build-module/index.mjs +46 -46
- package/build-module/index.mjs.map +2 -2
- package/build-types/hooks/use-copy-on-click/index.d.ts +8 -9
- package/build-types/hooks/use-copy-on-click/index.d.ts.map +1 -1
- package/build-types/hooks/use-copy-to-clipboard/index.d.ts +22 -6
- package/build-types/hooks/use-copy-to-clipboard/index.d.ts.map +1 -1
- package/build-types/hooks/use-dialog/index.d.ts +6 -9
- package/build-types/hooks/use-dialog/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-on-mount/index.d.ts +4 -10
- package/build-types/hooks/use-focus-on-mount/index.d.ts.map +1 -1
- package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts +2 -2
- package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts.map +1 -1
- package/build-types/hooks/use-media-query/index.d.ts +4 -3
- package/build-types/hooks/use-media-query/index.d.ts.map +1 -1
- package/build-types/hooks/use-viewport-match/index.d.ts +2 -1
- package/build-types/hooks/use-viewport-match/index.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +5 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/utils/subscribe-delegated-listener/index.d.ts +27 -0
- package/build-types/utils/subscribe-delegated-listener/index.d.ts.map +1 -0
- package/package.json +9 -10
- package/src/hooks/use-copy-on-click/index.ts +101 -0
- package/src/hooks/use-copy-on-click/test/index.tsx +162 -0
- package/src/hooks/use-copy-to-clipboard/index.ts +120 -0
- package/src/hooks/use-copy-to-clipboard/test/index.tsx +144 -0
- package/src/hooks/use-dialog/index.ts +6 -9
- package/src/hooks/use-focus-on-mount/{index.ts → index.js} +34 -23
- package/src/hooks/use-media-query/{index.js → index.ts} +27 -16
- package/src/hooks/use-viewport-match/index.js +3 -2
- package/src/hooks/use-viewport-match/test/index.js +32 -10
- package/src/index.js +1 -1
- package/src/hooks/use-copy-on-click/index.js +0 -75
- package/src/hooks/use-copy-to-clipboard/index.js +0 -69
package/build-module/index.mjs
CHANGED
|
@@ -18,64 +18,64 @@ import { default as default13 } from "./hooks/use-dialog/index.mjs";
|
|
|
18
18
|
import { default as default14 } from "./hooks/use-disabled/index.mjs";
|
|
19
19
|
import { default as default15 } from "./hooks/use-event/index.mjs";
|
|
20
20
|
import { default as default16 } from "./hooks/use-dragging/index.mjs";
|
|
21
|
-
import {
|
|
22
|
-
import { default as
|
|
23
|
-
import { default as
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
26
|
-
import { default as
|
|
27
|
-
import { default as
|
|
28
|
-
import { default as
|
|
29
|
-
import { default as
|
|
30
|
-
import { default as
|
|
31
|
-
import { default as
|
|
32
|
-
import { default as
|
|
33
|
-
import { default as
|
|
34
|
-
import { default as
|
|
35
|
-
import { default as
|
|
36
|
-
import { default as
|
|
37
|
-
import { default as
|
|
38
|
-
import { default as
|
|
39
|
-
import { default as
|
|
40
|
-
import { default as
|
|
41
|
-
import { default as
|
|
42
|
-
import { default as
|
|
43
|
-
import { default as
|
|
21
|
+
import { default as default17 } from "./hooks/use-focus-on-mount/index.mjs";
|
|
22
|
+
import { default as default18 } from "./hooks/use-focus-outside/index.mjs";
|
|
23
|
+
import { default as default19 } from "./hooks/use-focus-return/index.mjs";
|
|
24
|
+
import { default as default20 } from "./hooks/use-instance-id/index.mjs";
|
|
25
|
+
import { default as default21 } from "./hooks/use-isomorphic-layout-effect/index.mjs";
|
|
26
|
+
import { default as default22 } from "./hooks/use-keyboard-shortcut/index.mjs";
|
|
27
|
+
import { default as default23 } from "./hooks/use-media-query/index.mjs";
|
|
28
|
+
import { default as default24 } from "./hooks/use-previous/index.mjs";
|
|
29
|
+
import { default as default25 } from "./hooks/use-reduced-motion/index.mjs";
|
|
30
|
+
import { default as default26 } from "./hooks/use-state-with-history/index.mjs";
|
|
31
|
+
import { default as default27 } from "./hooks/use-viewport-match/index.mjs";
|
|
32
|
+
import { default as default28 } from "./hooks/use-resize-observer/index.mjs";
|
|
33
|
+
import { default as default29 } from "./hooks/use-async-list/index.mjs";
|
|
34
|
+
import { default as default30 } from "./hooks/use-warn-on-change/index.mjs";
|
|
35
|
+
import { default as default31 } from "./hooks/use-debounce/index.mjs";
|
|
36
|
+
import { default as default32 } from "./hooks/use-debounced-input/index.mjs";
|
|
37
|
+
import { default as default33 } from "./hooks/use-throttle/index.mjs";
|
|
38
|
+
import { default as default34 } from "./hooks/use-merge-refs/index.mjs";
|
|
39
|
+
import { default as default35 } from "./hooks/use-ref-effect/index.mjs";
|
|
40
|
+
import { default as default36 } from "./hooks/use-drop-zone/index.mjs";
|
|
41
|
+
import { default as default37 } from "./hooks/use-focusable-iframe/index.mjs";
|
|
42
|
+
import { default as default38 } from "./hooks/use-fixed-window-list/index.mjs";
|
|
43
|
+
import { default as default39 } from "./hooks/use-observable-value/index.mjs";
|
|
44
44
|
export {
|
|
45
45
|
default13 as __experimentalUseDialog,
|
|
46
46
|
default16 as __experimentalUseDragging,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
default36 as __experimentalUseDropZone,
|
|
48
|
+
default38 as __experimentalUseFixedWindowList,
|
|
49
|
+
default18 as __experimentalUseFocusOutside,
|
|
50
50
|
default2 as compose,
|
|
51
51
|
default4 as ifCondition,
|
|
52
52
|
default3 as pipe,
|
|
53
53
|
default5 as pure,
|
|
54
|
-
|
|
54
|
+
default29 as useAsyncList,
|
|
55
55
|
default10 as useConstrainedTabbing,
|
|
56
56
|
default11 as useCopyOnClick,
|
|
57
57
|
default12 as useCopyToClipboard,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
default31 as useDebounce,
|
|
59
|
+
default32 as useDebouncedInput,
|
|
60
60
|
default14 as useDisabled,
|
|
61
61
|
default15 as useEvent,
|
|
62
|
-
useFocusOnMount,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
default17 as useFocusOnMount,
|
|
63
|
+
default19 as useFocusReturn,
|
|
64
|
+
default37 as useFocusableIframe,
|
|
65
|
+
default20 as useInstanceId,
|
|
66
|
+
default21 as useIsomorphicLayoutEffect,
|
|
67
|
+
default22 as useKeyboardShortcut,
|
|
68
|
+
default23 as useMediaQuery,
|
|
69
|
+
default34 as useMergeRefs,
|
|
70
|
+
default39 as useObservableValue,
|
|
71
|
+
default24 as usePrevious,
|
|
72
|
+
default25 as useReducedMotion,
|
|
73
|
+
default35 as useRefEffect,
|
|
74
|
+
default28 as useResizeObserver,
|
|
75
|
+
default26 as useStateWithHistory,
|
|
76
|
+
default33 as useThrottle,
|
|
77
|
+
default27 as useViewportMatch,
|
|
78
|
+
default30 as useWarnOnChange,
|
|
79
79
|
default6 as withGlobalEvents,
|
|
80
80
|
default7 as withInstanceId,
|
|
81
81
|
default8 as withSafeTimeout,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.js"],
|
|
4
|
-
"sourcesContent": ["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n// The `ObservableMap` data structure\nexport * from './utils/observable-map';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as useEvent } from './hooks/use-event';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useStateWithHistory } from './hooks/use-state-with-history';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useDebouncedInput } from './hooks/use-debounced-input';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\nexport { default as useObservableValue } from './hooks/use-observable-value';\n"],
|
|
5
|
-
"mappings": ";AACA,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd,cAAc;AAGd,SAAoB,WAAXA,gBAA0B;AACnC,SAAoB,WAAXA,gBAAuB;AAGhC,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA4B;AAGrC,SAAoB,WAAXA,iBAAwC;AACjD,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA0C;AACnD,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA4C;AACrD,
|
|
4
|
+
"sourcesContent": ["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n// The `ObservableMap` data structure\nexport * from './utils/observable-map';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as useEvent } from './hooks/use-event';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useStateWithHistory } from './hooks/use-state-with-history';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useDebouncedInput } from './hooks/use-debounced-input';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\nexport { default as useObservableValue } from './hooks/use-observable-value';\n"],
|
|
5
|
+
"mappings": ";AACA,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd,cAAc;AAGd,SAAoB,WAAXA,gBAA0B;AACnC,SAAoB,WAAXA,gBAAuB;AAGhC,SAAoB,WAAXA,gBAA8B;AACvC,SAAoB,WAAXA,gBAAuB;AAChC,SAAoB,WAAXA,gBAAmC;AAC5C,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAkC;AAC3C,SAAoB,WAAXA,gBAA4B;AAGrC,SAAoB,WAAXA,iBAAwC;AACjD,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAA0C;AACnD,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA2B;AACpC,SAAoB,WAAXA,iBAA4C;AACrD,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAAgD;AACzD,SAAoB,WAAXA,iBAAiC;AAC1C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA4C;AACrD,SAAoB,WAAXA,iBAAsC;AAC/C,SAAoB,WAAXA,iBAAgC;AACzC,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAmC;AAC5C,SAAoB,WAAXA,iBAAsC;AAC/C,SAAoB,WAAXA,iBAAmC;AAC5C,SAAoB,WAAXA,iBAAoC;AAC7C,SAAoB,WAAXA,iBAA+B;AACxC,SAAoB,WAAXA,iBAAkC;AAC3C,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAAoC;AAC7C,SAAoB,WAAXA,iBAA8B;AACvC,SAAoB,WAAXA,iBAA+B;AACxC,SAAoB,WAAXA,iBAA+B;AACxC,SAAoB,WAAXA,iBAA4C;AACrD,SAAoB,WAAXA,iBAAqC;AAC9C,SAAoB,WAAXA,iBAAmD;AAC5D,SAAoB,WAAXA,iBAAqC;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Copies the text to the clipboard when the element is clicked.
|
|
3
4
|
*
|
|
4
5
|
* @deprecated
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @return {boolean} Whether or not the text has been copied. Resets after the
|
|
12
|
-
* timeout.
|
|
6
|
+
* @param ref Reference with the element.
|
|
7
|
+
* @param text The text to copy.
|
|
8
|
+
* @param timeout Optional timeout to reset the returned
|
|
9
|
+
* state. 4 seconds by default.
|
|
10
|
+
* @return Whether or not the text has been copied. Resets after the
|
|
11
|
+
* timeout.
|
|
13
12
|
*/
|
|
14
|
-
export default function useCopyOnClick(ref:
|
|
13
|
+
export default function useCopyOnClick(ref: RefObject<string | Element | NodeListOf<Element>>, text: string | (() => string), timeout?: number): boolean;
|
|
15
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-on-click/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-on-click/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,GAAG,EAAE,SAAS,CAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAE,OAAO,CAAE,CAAE,EAC1D,IAAI,EAAE,MAAM,GAAG,CAAE,MAAM,MAAM,CAAE,EAC/B,OAAO,GAAE,MAAa,GACpB,OAAO,CAyET"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
+
import type { RefCallback } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Copies text to the clipboard using the Clipboard API when available,
|
|
4
|
+
* with a fallback for non-secure contexts (e.g. HTTP) and older browsers.
|
|
5
|
+
*
|
|
6
|
+
* @param text The text to copy.
|
|
7
|
+
* @param trigger The element that triggered the copy.
|
|
8
|
+
* @return Resolves to true if successful, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function copyToClipboard(text: string, trigger: Element | null): Promise<boolean>;
|
|
11
|
+
/**
|
|
12
|
+
* Clears the current selection and restores focus to the trigger element.
|
|
13
|
+
*
|
|
14
|
+
* @param trigger The element that triggered the copy.
|
|
15
|
+
*/
|
|
16
|
+
export declare function clearSelection(trigger: Element): void;
|
|
1
17
|
/**
|
|
2
18
|
* Copies the given text to the clipboard when the element is clicked.
|
|
3
19
|
*
|
|
4
|
-
* @template
|
|
5
|
-
* @param
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
20
|
+
* @template T
|
|
21
|
+
* @param text The text to copy. Use a function if not
|
|
22
|
+
* already available and expensive to compute.
|
|
23
|
+
* @param onSuccess Called when to text is copied.
|
|
8
24
|
*
|
|
9
|
-
* @return
|
|
25
|
+
* @return A ref to assign to the target element.
|
|
10
26
|
*/
|
|
11
|
-
export default function useCopyToClipboard<
|
|
27
|
+
export default function useCopyToClipboard<T extends HTMLElement>(text: string | (() => string), onSuccess?: () => void): RefCallback<T>;
|
|
12
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-to-clipboard/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-to-clipboard/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,WAAW,EAAE,MAAM,OAAO,CAAC;AAO3D;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GAAG,IAAI,GACrB,OAAO,CAAE,OAAO,CAAE,CA6BpB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAE,OAAO,EAAE,OAAO,GAAI,IAAI,CAKvD;AAeD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAE,CAAC,SAAS,WAAW,EAChE,IAAI,EAAE,MAAM,GAAG,CAAE,MAAM,MAAM,CAAE,EAC/B,SAAS,CAAC,EAAE,MAAM,IAAI,GACpB,WAAW,CAAE,CAAC,CAAE,CA4BlB"}
|
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { RefCallback, SyntheticEvent } from 'react';
|
|
5
|
-
import
|
|
5
|
+
import useFocusOnMount from '../use-focus-on-mount';
|
|
6
6
|
import useFocusOutside from '../use-focus-outside';
|
|
7
7
|
type DialogOptions = {
|
|
8
8
|
/**
|
|
9
|
-
* Determines focus
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - `true` focuses the element itself.
|
|
14
|
-
* - `false` does nothing and _should not be used unless an accessible
|
|
15
|
-
* substitute behavior is implemented_.
|
|
9
|
+
* Determines whether focus should be automatically moved to the popover
|
|
10
|
+
* when it mounts. `false` causes no focus shift, `true` causes the popover
|
|
11
|
+
* itself to gain focus, and `firstElement` focuses the first focusable
|
|
12
|
+
* element within the popover.
|
|
16
13
|
*
|
|
17
14
|
* @default 'firstElement'
|
|
18
15
|
*/
|
|
19
|
-
focusOnMount?: useFocusOnMount
|
|
16
|
+
focusOnMount?: Parameters<typeof useFocusOnMount>[0];
|
|
20
17
|
/**
|
|
21
18
|
* Determines whether tabbing is constrained to within the popover,
|
|
22
19
|
* preventing keyboard focus from leaving the popover content without
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dialog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAYzD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dialog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAYzD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,KAAK,aAAa,GAAG;IACpB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,UAAU,CAAE,OAAO,eAAe,CAAE,CAAE,CAAC,CAAE,CAAC;IACzD;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CACnB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,cAAc,KACjB,IAAI,CAAC;CACV,CAAC;AAEF,KAAK,eAAe,GAAG;IACtB,WAAW,CAAE,WAAW,CAAE;IAC1B,UAAU,CAAE,OAAO,eAAe,CAAE,GAAG,IAAI,CAAE,WAAW,EAAE,UAAU,CAAE;CACtE,CAAC;AAEF;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAE,OAAO,EAAE,aAAa,GAAI,eAAe,CAgD5D;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Hook used to focus the first tabbable element on mount.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
*
|
|
6
|
-
* first value control within; `true` focuses the element itself;
|
|
7
|
-
* `false` does nothing.
|
|
8
|
-
* @return Ref callback.
|
|
4
|
+
* @param {boolean | 'firstElement' | 'firstInputElement'} focusOnMount Focus on mount mode.
|
|
5
|
+
* @return {React.RefCallback<HTMLElement>} Ref callback.
|
|
9
6
|
*
|
|
10
7
|
* @example
|
|
11
8
|
* ```js
|
|
@@ -22,8 +19,5 @@
|
|
|
22
19
|
* }
|
|
23
20
|
* ```
|
|
24
21
|
*/
|
|
25
|
-
export
|
|
26
|
-
export declare namespace useFocusOnMount {
|
|
27
|
-
type Mode = boolean | 'firstElement' | 'firstInputElement';
|
|
28
|
-
}
|
|
22
|
+
export default function useFocusOnMount(focusOnMount?: boolean | "firstElement" | "firstInputElement"): React.RefCallback<HTMLElement>;
|
|
29
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-on-mount/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-on-mount/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,uDAlBW,OAAO,GAAG,cAAc,GAAG,mBAAmB,GAC7C,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CA4FzC"}
|
|
@@ -4,6 +4,6 @@ export default useIsomorphicLayoutEffect;
|
|
|
4
4
|
* server rendered components (SSR) because currently React
|
|
5
5
|
* throws a warning when using useLayoutEffect in that environment.
|
|
6
6
|
*/
|
|
7
|
-
declare const useIsomorphicLayoutEffect: typeof
|
|
8
|
-
import {
|
|
7
|
+
declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
8
|
+
import { useLayoutEffect } from '@wordpress/element';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-isomorphic-layout-effect/index.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-isomorphic-layout-effect/index.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH,gEAC6D;gCARlB,oBAAoB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runs a media query and returns its value when it changes.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @
|
|
4
|
+
* @param [query] Media Query.
|
|
5
|
+
* @param [view] Window instance, else default to global window
|
|
6
|
+
* @return return value of the media query.
|
|
6
7
|
*/
|
|
7
|
-
export default function useMediaQuery(query?: string): boolean;
|
|
8
|
+
export default function useMediaQuery(query?: string, view?: Window): boolean;
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-media-query/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-media-query/index.ts"],"names":[],"mappings":"AA4CA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACpC,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,GAAE,MAAe,GACnB,OAAO,CA8BT"}
|
|
@@ -6,6 +6,7 @@ export type WPViewportOperator = ">=" | "<";
|
|
|
6
6
|
*
|
|
7
7
|
* @param {WPBreakpoint} breakpoint Breakpoint size name.
|
|
8
8
|
* @param {WPViewportOperator} [operator=">="] Viewport operator.
|
|
9
|
+
* @param {Window} [view=window] Window instance in which to perform viewport matching.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
*
|
|
@@ -16,7 +17,7 @@ export type WPViewportOperator = ">=" | "<";
|
|
|
16
17
|
*
|
|
17
18
|
* @return {boolean} Whether viewport matches query.
|
|
18
19
|
*/
|
|
19
|
-
declare function useViewportMatch(breakpoint: WPBreakpoint, operator?: WPViewportOperator): boolean;
|
|
20
|
+
declare function useViewportMatch(breakpoint: WPBreakpoint, operator?: WPViewportOperator, view?: Window): boolean;
|
|
20
21
|
declare namespace useViewportMatch {
|
|
21
22
|
let __experimentalWidthProvider: import("react").Provider<number | null>;
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-viewport-match/index.js"],"names":[],"mappings":";2BAWa,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ;iCAsB9E,IAAI,GAAG,GAAG;AA4BvB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-viewport-match/index.js"],"names":[],"mappings":";2BAWa,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ;iCAsB9E,IAAI,GAAG,GAAG;AA4BvB;;;;;;;;;;;;;;;GAeG;AACH,8CAbW,YAAY,aACZ,kBAAkB,SAClB,MAAM,GASL,OAAO,CAelB"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { default as __experimentalUseDialog } from "./hooks/use-dialog";
|
|
|
17
17
|
export { default as useDisabled } from "./hooks/use-disabled";
|
|
18
18
|
export { default as useEvent } from "./hooks/use-event";
|
|
19
19
|
export { default as __experimentalUseDragging } from "./hooks/use-dragging";
|
|
20
|
-
export { useFocusOnMount } from "./hooks/use-focus-on-mount";
|
|
20
|
+
export { default as useFocusOnMount } from "./hooks/use-focus-on-mount";
|
|
21
21
|
export { default as __experimentalUseFocusOutside } from "./hooks/use-focus-outside";
|
|
22
22
|
export { default as useFocusReturn } from "./hooks/use-focus-return";
|
|
23
23
|
export { default as useInstanceId } from "./hooks/use-instance-id";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock-unlock.d.ts","sourceRoot":"","sources":["../src/lock-unlock.ts"],"names":[],"mappings":"AAKA,eAAO,MAAQ,IAAI,mDAAE,MAAM,iCAIzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-apis.d.ts","sourceRoot":"","sources":["../src/private-apis.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,WAAW,IAAK,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a callback to a shared `addEventListener`. Only one underlying
|
|
3
|
+
* native listener is attached per (root, event type, phase); subscribers
|
|
4
|
+
* join an in-JS registry that dispatches events along the DOM ancestry
|
|
5
|
+
* of `event.target`.
|
|
6
|
+
*
|
|
7
|
+
* The model mirrors React's synthetic event system: a single root
|
|
8
|
+
* listener handles every event of a given type, and callbacks bound to
|
|
9
|
+
* an `Element` only fire when that element is on the target's path.
|
|
10
|
+
* Callbacks bound to a `Document` always fire (document is the root of
|
|
11
|
+
* every event in that document); callbacks bound to a `Window` always
|
|
12
|
+
* fire as a flat fan-out, since `window` isn't on the DOM tree.
|
|
13
|
+
*
|
|
14
|
+
* @param target `Element`, `Document`, or `Window` to bind the
|
|
15
|
+
* callback to. For `Element`, the callback only fires
|
|
16
|
+
* when the event happens on the element or a
|
|
17
|
+
* descendant.
|
|
18
|
+
* @param eventType DOM event name.
|
|
19
|
+
* @param callback Listener to be invoked with the event.
|
|
20
|
+
* @param capture Use the capture phase. Required when ancestor
|
|
21
|
+
* listeners gate on `event.defaultPrevented`, since a
|
|
22
|
+
* bubble-phase root listener fires after them. Defaults
|
|
23
|
+
* to `false`.
|
|
24
|
+
* @return Unsubscribe function.
|
|
25
|
+
*/
|
|
26
|
+
export default function subscribeDelegatedListener(target: EventTarget, eventType: string, callback: EventListener, capture?: boolean): () => void;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/subscribe-delegated-listener/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAYH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CACjD,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,EACvB,OAAO,GAAE,OAAe,GACtB,MAAM,IAAI,CAsFZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/compose",
|
|
3
|
-
"version": "7.40.1
|
|
3
|
+
"version": "7.40.1",
|
|
4
4
|
"description": "WordPress higher-order components (HOCs).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -47,15 +47,14 @@
|
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@types/mousetrap": "^1.6.8",
|
|
50
|
-
"@wordpress/deprecated": "^4.40.1
|
|
51
|
-
"@wordpress/dom": "^4.40.1
|
|
52
|
-
"@wordpress/element": "^6.40.1
|
|
53
|
-
"@wordpress/is-shallow-equal": "^5.40.1
|
|
54
|
-
"@wordpress/keycodes": "^4.40.1
|
|
55
|
-
"@wordpress/priority-queue": "^3.40.1
|
|
56
|
-
"@wordpress/undo-manager": "^1.40.1
|
|
50
|
+
"@wordpress/deprecated": "^4.40.1",
|
|
51
|
+
"@wordpress/dom": "^4.40.1",
|
|
52
|
+
"@wordpress/element": "^6.40.1",
|
|
53
|
+
"@wordpress/is-shallow-equal": "^5.40.1",
|
|
54
|
+
"@wordpress/keycodes": "^4.40.1",
|
|
55
|
+
"@wordpress/priority-queue": "^3.40.1",
|
|
56
|
+
"@wordpress/undo-manager": "^1.40.1",
|
|
57
57
|
"change-case": "^4.1.2",
|
|
58
|
-
"clipboard": "^2.0.11",
|
|
59
58
|
"mousetrap": "^1.6.5",
|
|
60
59
|
"use-memo-one": "^1.1.1"
|
|
61
60
|
},
|
|
@@ -68,5 +67,5 @@
|
|
|
68
67
|
"publishConfig": {
|
|
69
68
|
"access": "public"
|
|
70
69
|
},
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "adb6623c9f32490cfc73c7ac7f122578c1f10c65"
|
|
72
71
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
5
|
+
import deprecated from '@wordpress/deprecated';
|
|
6
|
+
import type { RefObject } from 'react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { clearSelection, copyToClipboard } from '../use-copy-to-clipboard';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Copies the text to the clipboard when the element is clicked.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated
|
|
17
|
+
* @param ref Reference with the element.
|
|
18
|
+
* @param text The text to copy.
|
|
19
|
+
* @param timeout Optional timeout to reset the returned
|
|
20
|
+
* state. 4 seconds by default.
|
|
21
|
+
* @return Whether or not the text has been copied. Resets after the
|
|
22
|
+
* timeout.
|
|
23
|
+
*/
|
|
24
|
+
export default function useCopyOnClick(
|
|
25
|
+
ref: RefObject< string | Element | NodeListOf< Element > >,
|
|
26
|
+
text: string | ( () => string ),
|
|
27
|
+
timeout: number = 4000
|
|
28
|
+
): boolean {
|
|
29
|
+
deprecated( 'wp.compose.useCopyOnClick', {
|
|
30
|
+
since: '5.8',
|
|
31
|
+
alternative: 'wp.compose.useCopyToClipboard',
|
|
32
|
+
} );
|
|
33
|
+
|
|
34
|
+
const [ hasCopied, setHasCopied ] = useState( false );
|
|
35
|
+
|
|
36
|
+
useEffect( () => {
|
|
37
|
+
// Flag to prevent state updates after unmount when the Promise resolves.
|
|
38
|
+
let isActive = true;
|
|
39
|
+
let timeoutId: ReturnType< typeof setTimeout > | undefined;
|
|
40
|
+
if ( ! ref.current ) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let targets: Element[];
|
|
45
|
+
if ( typeof ref.current === 'string' ) {
|
|
46
|
+
targets =
|
|
47
|
+
typeof document !== 'undefined'
|
|
48
|
+
? Array.from( document.querySelectorAll( ref.current ) )
|
|
49
|
+
: [];
|
|
50
|
+
} else if (
|
|
51
|
+
'length' in ref.current &&
|
|
52
|
+
typeof ref.current.length === 'number'
|
|
53
|
+
) {
|
|
54
|
+
targets = Array.from( ref.current );
|
|
55
|
+
} else {
|
|
56
|
+
targets = [ ref.current as Element ];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if ( targets.length === 0 ) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleClick = async ( event: Event ) => {
|
|
64
|
+
const trigger = event.currentTarget as Element;
|
|
65
|
+
if ( ! trigger ) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const success = await copyToClipboard(
|
|
69
|
+
typeof text === 'function' ? text() : text || '',
|
|
70
|
+
trigger
|
|
71
|
+
);
|
|
72
|
+
if ( ! isActive ) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if ( success ) {
|
|
76
|
+
clearSelection( trigger );
|
|
77
|
+
if ( timeout ) {
|
|
78
|
+
setHasCopied( true );
|
|
79
|
+
clearTimeout( timeoutId );
|
|
80
|
+
timeoutId = setTimeout(
|
|
81
|
+
() => setHasCopied( false ),
|
|
82
|
+
timeout
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
for ( const target of targets ) {
|
|
89
|
+
target.addEventListener( 'click', handleClick );
|
|
90
|
+
}
|
|
91
|
+
return () => {
|
|
92
|
+
isActive = false;
|
|
93
|
+
for ( const target of targets ) {
|
|
94
|
+
target.removeEventListener( 'click', handleClick );
|
|
95
|
+
}
|
|
96
|
+
clearTimeout( timeoutId );
|
|
97
|
+
};
|
|
98
|
+
}, [ ref, text, timeout ] );
|
|
99
|
+
|
|
100
|
+
return hasCopied;
|
|
101
|
+
}
|