@wordpress/compose 5.0.1 → 5.0.5
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/README.md +12 -3
- package/build/higher-order/if-condition/index.js.map +1 -1
- package/build/higher-order/pure/index.js.map +1 -1
- package/build/higher-order/with-instance-id/index.js.map +1 -1
- package/build/higher-order/with-safe-timeout/index.js.map +1 -1
- package/build/hooks/use-constrained-tabbing/index.js +46 -43
- package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
- package/build/hooks/use-debounce/index.js +1 -1
- package/build/hooks/use-debounce/index.js.map +1 -1
- package/build/hooks/use-drop-zone/index.js +12 -6
- package/build/hooks/use-drop-zone/index.js.map +1 -1
- package/build/hooks/use-fixed-window-list/index.js +175 -0
- package/build/hooks/use-fixed-window-list/index.js.map +1 -0
- package/build/hooks/use-focusable-iframe/index.js +50 -0
- package/build/hooks/use-focusable-iframe/index.js.map +1 -0
- package/build/hooks/use-previous/index.js +3 -14
- package/build/hooks/use-previous/index.js.map +1 -1
- package/build/hooks/use-reduced-motion/index.js +1 -7
- package/build/hooks/use-reduced-motion/index.js.map +1 -1
- package/build/hooks/use-throttle/index.js +1 -1
- package/build/hooks/use-throttle/index.js.map +1 -1
- package/build/index.js +16 -0
- package/build/index.js.map +1 -1
- package/build-module/higher-order/if-condition/index.js +1 -1
- package/build-module/higher-order/if-condition/index.js.map +1 -1
- package/build-module/higher-order/pure/index.js +1 -1
- package/build-module/higher-order/pure/index.js.map +1 -1
- package/build-module/higher-order/with-instance-id/index.js +1 -2
- package/build-module/higher-order/with-instance-id/index.js.map +1 -1
- package/build-module/higher-order/with-safe-timeout/index.js +1 -1
- package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
- package/build-module/hooks/use-constrained-tabbing/index.js +41 -40
- package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
- package/build-module/hooks/use-debounce/index.js +1 -1
- package/build-module/hooks/use-debounce/index.js.map +1 -1
- package/build-module/hooks/use-drop-zone/index.js +12 -6
- package/build-module/hooks/use-drop-zone/index.js.map +1 -1
- package/build-module/hooks/use-fixed-window-list/index.js +164 -0
- package/build-module/hooks/use-fixed-window-list/index.js.map +1 -0
- package/build-module/hooks/use-focusable-iframe/index.js +40 -0
- package/build-module/hooks/use-focusable-iframe/index.js.map +1 -0
- package/build-module/hooks/use-previous/index.js +3 -14
- package/build-module/hooks/use-previous/index.js.map +1 -1
- package/build-module/hooks/use-reduced-motion/index.js +2 -8
- package/build-module/hooks/use-reduced-motion/index.js.map +1 -1
- package/build-module/hooks/use-throttle/index.js +1 -1
- package/build-module/hooks/use-throttle/index.js.map +1 -1
- package/build-module/index.js +2 -0
- package/build-module/index.js.map +1 -1
- package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
- package/build-types/higher-order/pure/index.d.ts.map +1 -1
- package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
- package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
- package/build-types/hooks/use-constrained-tabbing/index.d.ts.map +1 -1
- package/build-types/hooks/use-debounce/index.d.ts +2 -2
- package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
- package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
- package/build-types/hooks/use-fixed-window-list/index.d.ts +57 -0
- package/build-types/hooks/use-fixed-window-list/index.d.ts.map +1 -0
- package/build-types/hooks/use-focus-outside/index.d.ts +3 -3
- package/build-types/hooks/use-focus-outside/index.d.ts.map +1 -1
- package/build-types/hooks/use-focusable-iframe/index.d.ts +8 -0
- package/build-types/hooks/use-focusable-iframe/index.d.ts.map +1 -0
- package/build-types/hooks/use-previous/index.d.ts +2 -4
- package/build-types/hooks/use-previous/index.d.ts.map +1 -1
- package/build-types/hooks/use-reduced-motion/index.d.ts +5 -0
- package/build-types/hooks/use-reduced-motion/index.d.ts.map +1 -1
- package/build-types/hooks/use-throttle/index.d.ts +2 -2
- package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
- package/build-types/hooks/use-viewport-match/index.d.ts +2 -2
- package/build-types/hooks/use-viewport-match/index.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -0
- package/package.json +9 -9
- package/src/higher-order/if-condition/index.tsx +0 -1
- package/src/higher-order/pure/index.tsx +0 -1
- package/src/higher-order/with-instance-id/index.tsx +0 -1
- package/src/higher-order/with-safe-timeout/index.tsx +0 -1
- package/src/hooks/use-constrained-tabbing/index.js +39 -33
- package/src/hooks/use-debounce/index.js +1 -1
- package/src/hooks/use-drop-zone/index.js +11 -9
- package/src/hooks/use-fixed-window-list/index.js +174 -0
- package/src/hooks/use-focusable-iframe/README.md +29 -0
- package/src/hooks/use-focusable-iframe/index.js +34 -0
- package/src/hooks/use-previous/index.ts +24 -0
- package/src/hooks/use-reduced-motion/index.js +2 -13
- package/src/hooks/use-throttle/index.js +1 -1
- package/src/index.js +2 -0
- package/tsconfig.tsbuildinfo +1 -1694
- package/src/hooks/use-previous/index.js +0 -31
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { debounce } from 'lodash';
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useState, useLayoutEffect } from '@wordpress/element';
|
|
10
|
+
import { getScrollContainer } from '@wordpress/dom';
|
|
11
|
+
import { PAGEUP, PAGEDOWN, HOME, END } from '@wordpress/keycodes';
|
|
12
|
+
const DEFAULT_INIT_WINDOW_SIZE = 30;
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} WPFixedWindowList
|
|
15
|
+
*
|
|
16
|
+
* @property {number} visibleItems Items visible in the current viewport
|
|
17
|
+
* @property {number} start Start index of the window
|
|
18
|
+
* @property {number} end End index of the window
|
|
19
|
+
* @property {(index:number)=>boolean} itemInView Returns true if item is in the window
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @typedef {Object} WPFixedWindowListOptions
|
|
24
|
+
*
|
|
25
|
+
* @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window.
|
|
26
|
+
* @property {boolean} [useWindowing] When false avoids calculating the window size
|
|
27
|
+
* @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
|
|
33
|
+
* @param { number } itemHeight Fixed item height in pixels
|
|
34
|
+
* @param { number } totalItems Total items in list
|
|
35
|
+
* @param { WPFixedWindowListOptions } [options] Options object
|
|
36
|
+
* @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export default function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
|
|
40
|
+
var _options$initWindowSi, _options$useWindowing;
|
|
41
|
+
|
|
42
|
+
const initWindowSize = (_options$initWindowSi = options === null || options === void 0 ? void 0 : options.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE;
|
|
43
|
+
const useWindowing = (_options$useWindowing = options === null || options === void 0 ? void 0 : options.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true;
|
|
44
|
+
const [fixedListWindow, setFixedListWindow] = useState({
|
|
45
|
+
visibleItems: initWindowSize,
|
|
46
|
+
start: 0,
|
|
47
|
+
end: initWindowSize,
|
|
48
|
+
itemInView:
|
|
49
|
+
/** @type {number} */
|
|
50
|
+
index => {
|
|
51
|
+
return index >= 0 && index <= initWindowSize;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
var _scrollContainer$owne, _scrollContainer$owne2, _scrollContainer$owne3, _scrollContainer$owne4;
|
|
56
|
+
|
|
57
|
+
if (!useWindowing) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const scrollContainer = getScrollContainer(elementRef.current);
|
|
62
|
+
|
|
63
|
+
const measureWindow =
|
|
64
|
+
/** @type {boolean | undefined} */
|
|
65
|
+
initRender => {
|
|
66
|
+
var _options$windowOversc;
|
|
67
|
+
|
|
68
|
+
if (!scrollContainer) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); // Aim to keep opening list view fast, afterward we can optimize for scrolling
|
|
73
|
+
|
|
74
|
+
const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options === null || options === void 0 ? void 0 : options.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems;
|
|
75
|
+
const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight);
|
|
76
|
+
const start = Math.max(0, firstViewableIndex - windowOverscan);
|
|
77
|
+
const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan);
|
|
78
|
+
setFixedListWindow(lastWindow => {
|
|
79
|
+
const nextWindow = {
|
|
80
|
+
visibleItems,
|
|
81
|
+
start,
|
|
82
|
+
end,
|
|
83
|
+
itemInView:
|
|
84
|
+
/** @type {number} */
|
|
85
|
+
index => {
|
|
86
|
+
return start <= index && index <= end;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
|
|
91
|
+
return nextWindow;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return lastWindow;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
measureWindow(true);
|
|
99
|
+
const debounceMeasureList = debounce(() => {
|
|
100
|
+
measureWindow();
|
|
101
|
+
}, 16);
|
|
102
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', debounceMeasureList);
|
|
103
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne = scrollContainer.ownerDocument) === null || _scrollContainer$owne === void 0 ? void 0 : (_scrollContainer$owne2 = _scrollContainer$owne.defaultView) === null || _scrollContainer$owne2 === void 0 ? void 0 : _scrollContainer$owne2.addEventListener('resize', debounceMeasureList);
|
|
104
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne3 = scrollContainer.ownerDocument) === null || _scrollContainer$owne3 === void 0 ? void 0 : (_scrollContainer$owne4 = _scrollContainer$owne3.defaultView) === null || _scrollContainer$owne4 === void 0 ? void 0 : _scrollContainer$owne4.addEventListener('resize', debounceMeasureList);
|
|
105
|
+
return () => {
|
|
106
|
+
var _scrollContainer$owne5, _scrollContainer$owne6;
|
|
107
|
+
|
|
108
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', debounceMeasureList);
|
|
109
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne5 = scrollContainer.ownerDocument) === null || _scrollContainer$owne5 === void 0 ? void 0 : (_scrollContainer$owne6 = _scrollContainer$owne5.defaultView) === null || _scrollContainer$owne6 === void 0 ? void 0 : _scrollContainer$owne6.removeEventListener('resize', debounceMeasureList);
|
|
110
|
+
};
|
|
111
|
+
}, [itemHeight, elementRef, totalItems]);
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
var _scrollContainer$owne7, _scrollContainer$owne8;
|
|
114
|
+
|
|
115
|
+
if (!useWindowing) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const scrollContainer = getScrollContainer(elementRef.current);
|
|
120
|
+
|
|
121
|
+
const handleKeyDown =
|
|
122
|
+
/** @type {KeyboardEvent} */
|
|
123
|
+
event => {
|
|
124
|
+
switch (event.keyCode) {
|
|
125
|
+
case HOME:
|
|
126
|
+
{
|
|
127
|
+
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
|
|
128
|
+
top: 0
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
case END:
|
|
133
|
+
{
|
|
134
|
+
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
|
|
135
|
+
top: totalItems * itemHeight
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
case PAGEUP:
|
|
140
|
+
{
|
|
141
|
+
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
|
|
142
|
+
top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
case PAGEDOWN:
|
|
147
|
+
{
|
|
148
|
+
return scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollTo({
|
|
149
|
+
top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne7 = scrollContainer.ownerDocument) === null || _scrollContainer$owne7 === void 0 ? void 0 : (_scrollContainer$owne8 = _scrollContainer$owne7.defaultView) === null || _scrollContainer$owne8 === void 0 ? void 0 : _scrollContainer$owne8.addEventListener('keydown', handleKeyDown);
|
|
156
|
+
return () => {
|
|
157
|
+
var _scrollContainer$owne9, _scrollContainer$owne10;
|
|
158
|
+
|
|
159
|
+
scrollContainer === null || scrollContainer === void 0 ? void 0 : (_scrollContainer$owne9 = scrollContainer.ownerDocument) === null || _scrollContainer$owne9 === void 0 ? void 0 : (_scrollContainer$owne10 = _scrollContainer$owne9.defaultView) === null || _scrollContainer$owne10 === void 0 ? void 0 : _scrollContainer$owne10.removeEventListener('keydown', handleKeyDown);
|
|
160
|
+
};
|
|
161
|
+
}, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems]);
|
|
162
|
+
return [fixedListWindow, setFixedListWindow];
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-fixed-window-list/index.js"],"names":["debounce","useState","useLayoutEffect","getScrollContainer","PAGEUP","PAGEDOWN","HOME","END","DEFAULT_INIT_WINDOW_SIZE","useFixedWindowList","elementRef","itemHeight","totalItems","options","initWindowSize","useWindowing","fixedListWindow","setFixedListWindow","visibleItems","start","end","itemInView","index","scrollContainer","current","measureWindow","initRender","Math","ceil","clientHeight","windowOverscan","firstViewableIndex","floor","scrollTop","max","min","lastWindow","nextWindow","debounceMeasureList","addEventListener","ownerDocument","defaultView","removeEventListener","handleKeyDown","event","keyCode","scrollTo","top"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { PAGEUP, PAGEDOWN, HOME, END } from '@wordpress/keycodes';\n\nconst DEFAULT_INIT_WINDOW_SIZE = 30;\n\n/**\n * @typedef {Object} WPFixedWindowList\n *\n * @property {number} visibleItems Items visible in the current viewport\n * @property {number} start Start index of the window\n * @property {number} end End index of the window\n * @property {(index:number)=>boolean} itemInView Returns true if item is in the window\n */\n\n/**\n * @typedef {Object} WPFixedWindowListOptions\n *\n * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window.\n * @property {boolean} [useWindowing] When false avoids calculating the window size\n * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size.\n */\n\n/**\n *\n * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.\n * @param { number } itemHeight Fixed item height in pixels\n * @param { number } totalItems Total items in list\n * @param { WPFixedWindowListOptions } [options] Options object\n * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter\n */\nexport default function useFixedWindowList(\n\telementRef,\n\titemHeight,\n\ttotalItems,\n\toptions\n) {\n\tconst initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE;\n\tconst useWindowing = options?.useWindowing ?? true;\n\n\tconst [ fixedListWindow, setFixedListWindow ] = useState( {\n\t\tvisibleItems: initWindowSize,\n\t\tstart: 0,\n\t\tend: initWindowSize,\n\t\titemInView: ( /** @type {number} */ index ) => {\n\t\t\treturn index >= 0 && index <= initWindowSize;\n\t\t},\n\t} );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! useWindowing ) {\n\t\t\treturn;\n\t\t}\n\t\tconst scrollContainer = getScrollContainer( elementRef.current );\n\t\tconst measureWindow = (\n\t\t\t/** @type {boolean | undefined} */ initRender\n\t\t) => {\n\t\t\tif ( ! scrollContainer ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst visibleItems = Math.ceil(\n\t\t\t\tscrollContainer.clientHeight / itemHeight\n\t\t\t);\n\t\t\t// Aim to keep opening list view fast, afterward we can optimize for scrolling\n\t\t\tconst windowOverscan = initRender\n\t\t\t\t? visibleItems\n\t\t\t\t: options?.windowOverscan ?? visibleItems;\n\t\t\tconst firstViewableIndex = Math.floor(\n\t\t\t\tscrollContainer.scrollTop / itemHeight\n\t\t\t);\n\t\t\tconst start = Math.max( 0, firstViewableIndex - windowOverscan );\n\t\t\tconst end = Math.min(\n\t\t\t\ttotalItems - 1,\n\t\t\t\tfirstViewableIndex + visibleItems + windowOverscan\n\t\t\t);\n\t\t\tsetFixedListWindow( ( lastWindow ) => {\n\t\t\t\tconst nextWindow = {\n\t\t\t\t\tvisibleItems,\n\t\t\t\t\tstart,\n\t\t\t\t\tend,\n\t\t\t\t\titemInView: ( /** @type {number} */ index ) => {\n\t\t\t\t\t\treturn start <= index && index <= end;\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\tif (\n\t\t\t\t\tlastWindow.start !== nextWindow.start ||\n\t\t\t\t\tlastWindow.end !== nextWindow.end ||\n\t\t\t\t\tlastWindow.visibleItems !== nextWindow.visibleItems\n\t\t\t\t) {\n\t\t\t\t\treturn nextWindow;\n\t\t\t\t}\n\t\t\t\treturn lastWindow;\n\t\t\t} );\n\t\t};\n\n\t\tmeasureWindow( true );\n\t\tconst debounceMeasureList = debounce( () => {\n\t\t\tmeasureWindow();\n\t\t}, 16 );\n\t\tscrollContainer?.addEventListener( 'scroll', debounceMeasureList );\n\t\tscrollContainer?.ownerDocument?.defaultView?.addEventListener(\n\t\t\t'resize',\n\t\t\tdebounceMeasureList\n\t\t);\n\t\tscrollContainer?.ownerDocument?.defaultView?.addEventListener(\n\t\t\t'resize',\n\t\t\tdebounceMeasureList\n\t\t);\n\n\t\treturn () => {\n\t\t\tscrollContainer?.removeEventListener(\n\t\t\t\t'scroll',\n\t\t\t\tdebounceMeasureList\n\t\t\t);\n\t\t\tscrollContainer?.ownerDocument?.defaultView?.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tdebounceMeasureList\n\t\t\t);\n\t\t};\n\t}, [ itemHeight, elementRef, totalItems ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! useWindowing ) {\n\t\t\treturn;\n\t\t}\n\t\tconst scrollContainer = getScrollContainer( elementRef.current );\n\t\tconst handleKeyDown = ( /** @type {KeyboardEvent} */ event ) => {\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\tcase HOME: {\n\t\t\t\t\treturn scrollContainer?.scrollTo( { top: 0 } );\n\t\t\t\t}\n\t\t\t\tcase END: {\n\t\t\t\t\treturn scrollContainer?.scrollTo( {\n\t\t\t\t\t\ttop: totalItems * itemHeight,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tcase PAGEUP: {\n\t\t\t\t\treturn scrollContainer?.scrollTo( {\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\tscrollContainer.scrollTop -\n\t\t\t\t\t\t\tfixedListWindow.visibleItems * itemHeight,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tcase PAGEDOWN: {\n\t\t\t\t\treturn scrollContainer?.scrollTo( {\n\t\t\t\t\t\ttop:\n\t\t\t\t\t\t\tscrollContainer.scrollTop +\n\t\t\t\t\t\t\tfixedListWindow.visibleItems * itemHeight,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tscrollContainer?.ownerDocument?.defaultView?.addEventListener(\n\t\t\t'keydown',\n\t\t\thandleKeyDown\n\t\t);\n\t\treturn () => {\n\t\t\tscrollContainer?.ownerDocument?.defaultView?.removeEventListener(\n\t\t\t\t'keydown',\n\t\t\t\thandleKeyDown\n\t\t\t);\n\t\t};\n\t}, [ totalItems, itemHeight, elementRef, fixedListWindow.visibleItems ] );\n\n\treturn [ fixedListWindow, setFixedListWindow ];\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import useRefEffect from '../use-ref-effect';
|
|
5
|
+
/**
|
|
6
|
+
* Dispatches a bubbling focus event when the iframe receives focus. Use
|
|
7
|
+
* `onFocus` as usual on the iframe or a parent element.
|
|
8
|
+
*
|
|
9
|
+
* @return {Object} Ref to pass to the iframe.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export default function useFocusableIframe() {
|
|
13
|
+
return useRefEffect(element => {
|
|
14
|
+
const {
|
|
15
|
+
ownerDocument
|
|
16
|
+
} = element;
|
|
17
|
+
if (!ownerDocument) return;
|
|
18
|
+
const {
|
|
19
|
+
defaultView
|
|
20
|
+
} = ownerDocument;
|
|
21
|
+
if (!defaultView) return;
|
|
22
|
+
/**
|
|
23
|
+
* Checks whether the iframe is the activeElement, inferring that it has
|
|
24
|
+
* then received focus, and dispatches a focus event.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function checkFocus() {
|
|
28
|
+
if (ownerDocument && ownerDocument.activeElement === element) {
|
|
29
|
+
/** @type {HTMLElement} */
|
|
30
|
+
element.focus();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
defaultView.addEventListener('blur', checkFocus);
|
|
35
|
+
return () => {
|
|
36
|
+
defaultView.removeEventListener('blur', checkFocus);
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-focusable-iframe/index.js"],"names":["useRefEffect","useFocusableIframe","element","ownerDocument","defaultView","checkFocus","activeElement","focus","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,SAAOD,YAAY,CAAIE,OAAF,IAAe;AACnC,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,OAA1B;AACA,QAAK,CAAEC,aAAP,EAAuB;AACvB,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,aAAxB;AACA,QAAK,CAAEC,WAAP,EAAqB;AAErB;AACF;AACA;AACA;;AACE,aAASC,UAAT,GAAsB;AACrB,UAAKF,aAAa,IAAIA,aAAa,CAACG,aAAd,KAAgCJ,OAAtD,EAAgE;AAC/D;AAA6BA,QAAAA,OAAF,CAAYK,KAAZ;AAC3B;AACD;;AAEDH,IAAAA,WAAW,CAACI,gBAAZ,CAA8B,MAA9B,EAAsCH,UAAtC;AACA,WAAO,MAAM;AACZD,MAAAA,WAAW,CAACK,mBAAZ,CAAiC,MAAjC,EAAyCJ,UAAzC;AACA,KAFD;AAGA,GApBkB,EAoBhB,EApBgB,CAAnB;AAqBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * Dispatches a bubbling focus event when the iframe receives focus. Use\n * `onFocus` as usual on the iframe or a parent element.\n *\n * @return {Object} Ref to pass to the iframe.\n */\nexport default function useFocusableIframe() {\n\treturn useRefEffect( ( element ) => {\n\t\tconst { ownerDocument } = element;\n\t\tif ( ! ownerDocument ) return;\n\t\tconst { defaultView } = ownerDocument;\n\t\tif ( ! defaultView ) return;\n\n\t\t/**\n\t\t * Checks whether the iframe is the activeElement, inferring that it has\n\t\t * then received focus, and dispatches a focus event.\n\t\t */\n\t\tfunction checkFocus() {\n\t\t\tif ( ownerDocument && ownerDocument.activeElement === element ) {\n\t\t\t\t/** @type {HTMLElement} */ ( element ).focus();\n\t\t\t}\n\t\t}\n\n\t\tdefaultView.addEventListener( 'blur', checkFocus );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'blur', checkFocus );\n\t\t};\n\t}, [] );\n}\n"]}
|
|
@@ -6,24 +6,13 @@ import { useEffect, useRef } from '@wordpress/element';
|
|
|
6
6
|
* Use something's value from the previous render.
|
|
7
7
|
* Based on https://usehooks.com/usePrevious/.
|
|
8
8
|
*
|
|
9
|
-
* @
|
|
9
|
+
* @param value The value to track.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
12
|
-
*
|
|
13
|
-
* @return {T | undefined} The value from the previous render.
|
|
11
|
+
* @return The value from the previous render.
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
14
|
export default function usePrevious(value) {
|
|
17
|
-
|
|
18
|
-
// inferred based on the initial useRef argument, which is undefined.
|
|
19
|
-
// https://github.com/WordPress/gutenberg/pull/22597#issuecomment-633588366
|
|
20
|
-
|
|
21
|
-
/* eslint-disable jsdoc/no-undefined-types */
|
|
22
|
-
const ref = useRef(
|
|
23
|
-
/** @type {T | undefined} */
|
|
24
|
-
undefined);
|
|
25
|
-
/* eslint-enable jsdoc/no-undefined-types */
|
|
26
|
-
// Store current value in ref.
|
|
15
|
+
const ref = useRef(); // Store current value in ref.
|
|
27
16
|
|
|
28
17
|
useEffect(() => {
|
|
29
18
|
ref.current = value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-previous/index.
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-previous/index.ts"],"names":["useEffect","useRef","usePrevious","value","ref","current"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAA2BC,KAA3B,EAAqD;AACnE,QAAMC,GAAG,GAAGH,MAAM,EAAlB,CADmE,CAGnE;;AACAD,EAAAA,SAAS,CAAE,MAAM;AAChBI,IAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACA,GAFQ,EAEN,CAAEA,KAAF,CAFM,CAAT,CAJmE,CAMnD;AAEhB;;AACA,SAAOC,GAAG,CAACC,OAAX;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Use something's value from the previous render.\n * Based on https://usehooks.com/usePrevious/.\n *\n * @param value The value to track.\n *\n * @return The value from the previous render.\n */\nexport default function usePrevious< T >( value: T ): T | undefined {\n\tconst ref = useRef< T >();\n\n\t// Store current value in ref.\n\tuseEffect( () => {\n\t\tref.current = value;\n\t}, [ value ] ); // Re-run when value changes.\n\n\t// Return previous value (happens before update in useEffect above).\n\treturn ref.current;\n}\n"]}
|
|
@@ -2,19 +2,13 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import useMediaQuery from '../use-media-query';
|
|
5
|
-
/**
|
|
6
|
-
* Whether or not the user agent is Internet Explorer.
|
|
7
|
-
*
|
|
8
|
-
* @type {boolean}
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const IS_IE = typeof window !== 'undefined' && window.navigator.userAgent.indexOf('Trident') >= 0;
|
|
12
5
|
/**
|
|
13
6
|
* Hook returning whether the user has a preference for reduced motion.
|
|
14
7
|
*
|
|
15
8
|
* @return {boolean} Reduced motion preference value.
|
|
16
9
|
*/
|
|
17
10
|
|
|
18
|
-
const useReducedMotion =
|
|
11
|
+
const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)');
|
|
12
|
+
|
|
19
13
|
export default useReducedMotion;
|
|
20
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"names":["useMediaQuery","
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-reduced-motion/index.js"],"names":["useMediaQuery","useReducedMotion"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,oBAA1B;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,MACxBD,aAAa,CAAE,kCAAF,CADd;;AAGA,eAAeC,gBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * Hook returning whether the user has a preference for reduced motion.\n *\n * @return {boolean} Reduced motion preference value.\n */\nconst useReducedMotion = () =>\n\tuseMediaQuery( '(prefers-reduced-motion: reduce)' );\n\nexport default useReducedMotion;\n"]}
|
|
@@ -21,7 +21,7 @@ import { useEffect } from '@wordpress/element';
|
|
|
21
21
|
* @param {TFunc} fn The function to throttle.
|
|
22
22
|
* @param {number} [wait] The number of milliseconds to throttle invocations to.
|
|
23
23
|
* @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
|
|
24
|
-
* @return {
|
|
24
|
+
* @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
export default function useThrottle(fn, wait, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["throttle","useMemoOne","useEffect","useThrottle","fn","wait","options","throttled","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAGN,UAAU,CAAE,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAAhB,EAAuC,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAvC,CAA5B;AAKAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["throttle","useMemoOne","useEffect","useThrottle","fn","wait","options","throttled","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAGN,UAAU,CAAE,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAAhB,EAAuC,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAvC,CAA5B;AAKAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne( () => throttle( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -33,4 +33,6 @@ export { default as useThrottle } from './hooks/use-throttle';
|
|
|
33
33
|
export { default as useMergeRefs } from './hooks/use-merge-refs';
|
|
34
34
|
export { default as useRefEffect } from './hooks/use-ref-effect';
|
|
35
35
|
export { default as __experimentalUseDropZone } from './hooks/use-drop-zone';
|
|
36
|
+
export { default as useFocusableIframe } from './hooks/use-focusable-iframe';
|
|
37
|
+
export { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';
|
|
36
38
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/index.js"],"names":["default","createHigherOrderComponent","compose","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,0BAApB,QAAsD,uCAAtD,C,CAEA;;AACA,SAASD,OAAO,IAAIE,OAApB,QAAmC,wBAAnC,C,CAEA;;AACA,SAASF,OAAO,IAAIG,WAApB,QAAuC,6BAAvC;AACA,SAASH,OAAO,IAAII,IAApB,QAAgC,qBAAhC;AACA,SAASJ,OAAO,IAAIK,gBAApB,QAA4C,mCAA5C;AACA,SAASL,OAAO,IAAIM,cAApB,QAA0C,iCAA1C;AACA,SAASN,OAAO,IAAIO,eAApB,QAA2C,kCAA3C;AACA,SAASP,OAAO,IAAIQ,SAApB,QAAqC,2BAArC,C,CAEA;;AACA,SAASR,OAAO,IAAIS,qBAApB,QAAiD,iCAAjD;AACA,SAAST,OAAO,IAAIU,cAApB,QAA0C,2BAA1C;AACA,SAASV,OAAO,IAAIW,kBAApB,QAA8C,+BAA9C;AACA,SAASX,OAAO,IAAIY,uBAApB,QAAmD,oBAAnD;AACA,SAASZ,OAAO,IAAIa,yBAApB,QAAqD,sBAArD;AACA,SAASb,OAAO,IAAIc,eAApB,QAA2C,4BAA3C;AACA,SAASd,OAAO,IAAIe,6BAApB,QAAyD,2BAAzD;AACA,SAASf,OAAO,IAAIgB,cAApB,QAA0C,0BAA1C;AACA,SAAShB,OAAO,IAAIiB,aAApB,QAAyC,yBAAzC;AACA,SAASjB,OAAO,IAAIkB,yBAApB,QAAqD,sCAArD;AACA,SAASlB,OAAO,IAAImB,mBAApB,QAA+C,+BAA/C;AACA,SAASnB,OAAO,IAAIoB,aAApB,QAAyC,yBAAzC;AACA,SAASpB,OAAO,IAAIqB,WAApB,QAAuC,sBAAvC;AACA,SAASrB,OAAO,IAAIsB,gBAApB,QAA4C,4BAA5C;AACA,SAAStB,OAAO,IAAIuB,gBAApB,QAA4C,4BAA5C;AACA,SAASvB,OAAO,IAAIwB,iBAApB,QAA6C,6BAA7C;AACA,SAASxB,OAAO,IAAIyB,YAApB,QAAwC,wBAAxC;AACA,SAASzB,OAAO,IAAI0B,eAApB,QAA2C,4BAA3C;AACA,SAAS1B,OAAO,IAAI2B,WAApB,QAAuC,sBAAvC;AACA,SAAS3B,OAAO,IAAI4B,WAApB,QAAuC,sBAAvC;AACA,SAAS5B,OAAO,IAAI6B,YAApB,QAAwC,wBAAxC;AACA,SAAS7B,OAAO,IAAI8B,YAApB,QAAwC,wBAAxC;AACA,SAAS9B,OAAO,IAAI+B,yBAApB,QAAqD,uBAArD","sourcesContent":["// Utils\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\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 __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 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 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';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/index.js"],"names":["default","createHigherOrderComponent","compose","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone","useFocusableIframe","__experimentalUseFixedWindowList"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,0BAApB,QAAsD,uCAAtD,C,CAEA;;AACA,SAASD,OAAO,IAAIE,OAApB,QAAmC,wBAAnC,C,CAEA;;AACA,SAASF,OAAO,IAAIG,WAApB,QAAuC,6BAAvC;AACA,SAASH,OAAO,IAAII,IAApB,QAAgC,qBAAhC;AACA,SAASJ,OAAO,IAAIK,gBAApB,QAA4C,mCAA5C;AACA,SAASL,OAAO,IAAIM,cAApB,QAA0C,iCAA1C;AACA,SAASN,OAAO,IAAIO,eAApB,QAA2C,kCAA3C;AACA,SAASP,OAAO,IAAIQ,SAApB,QAAqC,2BAArC,C,CAEA;;AACA,SAASR,OAAO,IAAIS,qBAApB,QAAiD,iCAAjD;AACA,SAAST,OAAO,IAAIU,cAApB,QAA0C,2BAA1C;AACA,SAASV,OAAO,IAAIW,kBAApB,QAA8C,+BAA9C;AACA,SAASX,OAAO,IAAIY,uBAApB,QAAmD,oBAAnD;AACA,SAASZ,OAAO,IAAIa,yBAApB,QAAqD,sBAArD;AACA,SAASb,OAAO,IAAIc,eAApB,QAA2C,4BAA3C;AACA,SAASd,OAAO,IAAIe,6BAApB,QAAyD,2BAAzD;AACA,SAASf,OAAO,IAAIgB,cAApB,QAA0C,0BAA1C;AACA,SAAShB,OAAO,IAAIiB,aAApB,QAAyC,yBAAzC;AACA,SAASjB,OAAO,IAAIkB,yBAApB,QAAqD,sCAArD;AACA,SAASlB,OAAO,IAAImB,mBAApB,QAA+C,+BAA/C;AACA,SAASnB,OAAO,IAAIoB,aAApB,QAAyC,yBAAzC;AACA,SAASpB,OAAO,IAAIqB,WAApB,QAAuC,sBAAvC;AACA,SAASrB,OAAO,IAAIsB,gBAApB,QAA4C,4BAA5C;AACA,SAAStB,OAAO,IAAIuB,gBAApB,QAA4C,4BAA5C;AACA,SAASvB,OAAO,IAAIwB,iBAApB,QAA6C,6BAA7C;AACA,SAASxB,OAAO,IAAIyB,YAApB,QAAwC,wBAAxC;AACA,SAASzB,OAAO,IAAI0B,eAApB,QAA2C,4BAA3C;AACA,SAAS1B,OAAO,IAAI2B,WAApB,QAAuC,sBAAvC;AACA,SAAS3B,OAAO,IAAI4B,WAApB,QAAuC,sBAAvC;AACA,SAAS5B,OAAO,IAAI6B,YAApB,QAAwC,wBAAxC;AACA,SAAS7B,OAAO,IAAI8B,YAApB,QAAwC,wBAAxC;AACA,SAAS9B,OAAO,IAAI+B,yBAApB,QAAqD,uBAArD;AACA,SAAS/B,OAAO,IAAIgC,kBAApB,QAA8C,8BAA9C;AACA,SAAShC,OAAO,IAAIiC,gCAApB,QAA4D,+BAA5D","sourcesContent":["// Utils\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\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 __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 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 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';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/if-condition/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/if-condition/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEtF;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,WAAW,yCACgB,OAAO,yCAWtC,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/pure/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/pure/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAQ5F;;;GAGG;AACH,QAAA,MAAM,IAAI,EAAE,0BAwBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-instance-id/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-instance-id/index.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAGnG;;;GAGG;AACH,QAAA,MAAM,cAAc,EAAE,iCAAiC,CAAE;IACxD,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B,CAeA,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-safe-timeout/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-safe-timeout/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2CAA2C,CAAC;AAEnG;;;;;;;GAOG;AACH,aAAK,YAAY,GAAG;IACnB,UAAU,EAAE,CAAE,EAAE,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,KAAM,MAAM,CAAC;IACxD,YAAY,EAAE,CAAE,EAAE,EAAE,MAAM,KAAM,IAAI,CAAC;CACrC,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,eAAe,EAAE,iCAAiC,CAAE,YAAY,CA6CrE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-constrained-tabbing/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-constrained-tabbing/index.js"],"names":[],"mappings":";AAWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,0CAjBY,OAAO,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CA4D/C"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param {TFunc} fn The function to debounce.
|
|
12
12
|
* @param {number} [wait] The number of milliseconds to delay.
|
|
13
13
|
* @param {import('lodash').DebounceSettings} [options] The options object.
|
|
14
|
-
* @return {
|
|
14
|
+
* @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.
|
|
15
15
|
*/
|
|
16
|
-
export default function useDebounce<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("lodash").DebounceSettings | undefined):
|
|
16
|
+
export default function useDebounce<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("lodash").DebounceSettings | undefined): import("lodash").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":"AAYA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-debounce/index.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,wIAgBrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;GAaG;AACH;gBAVW,OAAO;qBACH,SAAS,KAAK,IAAI;qBAClB,SAAS,KAAK,IAAI;oBAClB,SAAS,KAAK,IAAI;qBAClB,SAAS,KAAK,IAAI;mBAClB,UAAU,KAAK,IAAI;gBACnB,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;gBAVW,OAAO;qBACH,SAAS,KAAK,IAAI;qBAClB,SAAS,KAAK,IAAI;oBAClB,SAAS,KAAK,IAAI;qBAClB,SAAS,KAAK,IAAI;mBAClB,UAAU,KAAK,IAAI;gBACnB,SAAS,KAAK,IAAI;IAErB,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CA6LnD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} WPFixedWindowList
|
|
3
|
+
*
|
|
4
|
+
* @property {number} visibleItems Items visible in the current viewport
|
|
5
|
+
* @property {number} start Start index of the window
|
|
6
|
+
* @property {number} end End index of the window
|
|
7
|
+
* @property {(index:number)=>boolean} itemInView Returns true if item is in the window
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Object} WPFixedWindowListOptions
|
|
11
|
+
*
|
|
12
|
+
* @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window.
|
|
13
|
+
* @property {boolean} [useWindowing] When false avoids calculating the window size
|
|
14
|
+
* @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
|
|
19
|
+
* @param { number } itemHeight Fixed item height in pixels
|
|
20
|
+
* @param { number } totalItems Total items in list
|
|
21
|
+
* @param { WPFixedWindowListOptions } [options] Options object
|
|
22
|
+
* @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
|
|
23
|
+
*/
|
|
24
|
+
export default function useFixedWindowList(elementRef: import('react').RefObject<HTMLElement>, itemHeight: number, totalItems: number, options?: WPFixedWindowListOptions | undefined): [WPFixedWindowList, (nextWindow: WPFixedWindowList) => void];
|
|
25
|
+
export type WPFixedWindowList = {
|
|
26
|
+
/**
|
|
27
|
+
* Items visible in the current viewport
|
|
28
|
+
*/
|
|
29
|
+
visibleItems: number;
|
|
30
|
+
/**
|
|
31
|
+
* Start index of the window
|
|
32
|
+
*/
|
|
33
|
+
start: number;
|
|
34
|
+
/**
|
|
35
|
+
* End index of the window
|
|
36
|
+
*/
|
|
37
|
+
end: number;
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if item is in the window
|
|
40
|
+
*/
|
|
41
|
+
itemInView: (index: number) => boolean;
|
|
42
|
+
};
|
|
43
|
+
export type WPFixedWindowListOptions = {
|
|
44
|
+
/**
|
|
45
|
+
* Renders windowOverscan number of items before and after the calculated visible window.
|
|
46
|
+
*/
|
|
47
|
+
windowOverscan?: number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* When false avoids calculating the window size
|
|
50
|
+
*/
|
|
51
|
+
useWindowing?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Initial window size to use on first render before we can calculate the window size.
|
|
54
|
+
*/
|
|
55
|
+
initWindowSize?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-fixed-window-list/index.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,uDANW,OAAO,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,cACrC,MAAM,cACN,MAAM,oFAE8C,iBAAiB,KAAG,IAAI,EAwIvF;;;;;kBA5Ja,MAAM;;;;WACN,MAAM;;;;SACN,MAAM;;;;wBACC,MAAM,KAAG,OAAO"}
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
* outside that element.
|
|
34
34
|
*/
|
|
35
35
|
export default function useFocusOutside(onFocusOutside: EventCallback): FocusOutsideReturnValue;
|
|
36
|
-
export type FocusNormalizedButton = HTMLButtonElement |
|
|
37
|
-
export type SyntheticEvent = import(
|
|
36
|
+
export type FocusNormalizedButton = HTMLButtonElement | HTMLLinkElement | HTMLInputElement;
|
|
37
|
+
export type SyntheticEvent = import('react').SyntheticEvent;
|
|
38
38
|
export type EventCallback = (event: SyntheticEvent) => any;
|
|
39
39
|
export type FocusOutsideReactElement = {
|
|
40
40
|
/**
|
|
@@ -42,7 +42,7 @@ export type FocusOutsideReactElement = {
|
|
|
42
42
|
*/
|
|
43
43
|
handleFocusOutside: EventCallback;
|
|
44
44
|
};
|
|
45
|
-
export type FocusOutsideRef = import(
|
|
45
|
+
export type FocusOutsideRef = import('react').MutableRefObject<FocusOutsideReactElement | undefined>;
|
|
46
46
|
export type FocusOutsideReturnValue = {
|
|
47
47
|
/**
|
|
48
48
|
* An event handler for focus events.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-outside/index.js"],"names":[],"mappings":"AAsDA;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,wDAPW,aAAa,GAGZ,uBAAuB,CAqGlC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-outside/index.js"],"names":[],"mappings":"AAsDA;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,wDAPW,aAAa,GAGZ,uBAAuB,CAqGlC;oCA3KY,iBAAiB,GAAG,eAAe,GAAG,gBAAgB;6BAoCtD,OAAO,OAAO,EAAE,cAAc;oCAKhC,cAAc;;;;;wBAKX,aAAa;;8BAId,OAAO,OAAO,EAAE,gBAAgB,CAAC,wBAAwB,GAAG,SAAS,CAAC;;;;;aAKrE,aAAa;;;;YACb,aAAa;;;;iBACb,aAAa;;;;eACb,aAAa;;;;kBACb,aAAa;;;;gBACb,aAAa"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dispatches a bubbling focus event when the iframe receives focus. Use
|
|
3
|
+
* `onFocus` as usual on the iframe or a parent element.
|
|
4
|
+
*
|
|
5
|
+
* @return {Object} Ref to pass to the iframe.
|
|
6
|
+
*/
|
|
7
|
+
export default function useFocusableIframe(): Object;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focusable-iframe/index.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,8CAFY,MAAM,CAwBjB"}
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Use something's value from the previous render.
|
|
3
3
|
* Based on https://usehooks.com/usePrevious/.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @param value The value to track.
|
|
6
6
|
*
|
|
7
|
-
* @
|
|
8
|
-
*
|
|
9
|
-
* @return {T | undefined} The value from the previous render.
|
|
7
|
+
* @return The value from the previous render.
|
|
10
8
|
*/
|
|
11
9
|
export default function usePrevious<T>(value: T): T | undefined;
|
|
12
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-previous/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-previous/index.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,CAAC,EAAI,KAAK,EAAE,CAAC,GAAI,CAAC,GAAG,SAAS,CAUlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-reduced-motion/index.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-reduced-motion/index.js"],"names":[],"mappings":";AAKA;;;;GAIG;AACH,qCAFY,OAAO,CAGiC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param {TFunc} fn The function to throttle.
|
|
12
12
|
* @param {number} [wait] The number of milliseconds to throttle invocations to.
|
|
13
13
|
* @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.
|
|
14
|
-
* @return {
|
|
14
|
+
* @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.
|
|
15
15
|
*/
|
|
16
|
-
export default function useThrottle<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("lodash").ThrottleSettings | undefined):
|
|
16
|
+
export default function useThrottle<TFunc extends (...args: any[]) => void>(fn: TFunc, wait?: number | undefined, options?: import("lodash").ThrottleSettings | undefined): import("lodash").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":"AAWA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-throttle/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,4DAPwB,GAAG,EAAE,KAAK,IAAI,wIAerC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default useViewportMatch;
|
|
2
|
-
export type WPBreakpoint = "
|
|
2
|
+
export type WPBreakpoint = "huge" | "wide" | "large" | "medium" | "small" | "mobile";
|
|
3
3
|
export type WPViewportOperator = ">=" | "<";
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if the viewport matches the given query, or false otherwise.
|
|
@@ -16,7 +16,7 @@ export type WPViewportOperator = ">=" | "<";
|
|
|
16
16
|
*
|
|
17
17
|
* @return {boolean} Whether viewport matches query.
|
|
18
18
|
*/
|
|
19
|
-
declare function useViewportMatch(breakpoint: WPBreakpoint, operator?:
|
|
19
|
+
declare function useViewportMatch(breakpoint: WPBreakpoint, operator?: WPViewportOperator | undefined): boolean;
|
|
20
20
|
declare namespace useViewportMatch {
|
|
21
21
|
const __experimentalWidthProvider: import("react").Provider<number | null>;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-viewport-match/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-viewport-match/index.js"],"names":[],"mappings":";2BAWa,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ;iCAoBzD,IAAI,GAAG,GAAG;AA2BvB;;;;;;;;;;;;;;GAcG;AACH,8CAZW,YAAY,8CAUX,OAAO,CAelB"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -29,4 +29,6 @@ export { default as useThrottle } from "./hooks/use-throttle";
|
|
|
29
29
|
export { default as useMergeRefs } from "./hooks/use-merge-refs";
|
|
30
30
|
export { default as useRefEffect } from "./hooks/use-ref-effect";
|
|
31
31
|
export { default as __experimentalUseDropZone } from "./hooks/use-drop-zone";
|
|
32
|
+
export { default as useFocusableIframe } from "./hooks/use-focusable-iframe";
|
|
33
|
+
export { default as __experimentalUseFixedWindowList } from "./hooks/use-fixed-window-list";
|
|
32
34
|
//# sourceMappingURL=index.d.ts.map
|