@lucasols/dnd-kit-utilities 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/index.d.ts +119 -11
  2. package/dist/index.js +229 -7
  3. package/dist/index.js.map +1 -0
  4. package/package.json +18 -16
  5. package/dist/adjustment.d.ts +0 -2
  6. package/dist/coordinates/getEventCoordinates.d.ts +0 -5
  7. package/dist/coordinates/index.d.ts +0 -2
  8. package/dist/coordinates/types.d.ts +0 -4
  9. package/dist/css.d.ts +0 -25
  10. package/dist/dnd-kit-utilities.cjs.development.js +0 -361
  11. package/dist/dnd-kit-utilities.cjs.development.js.map +0 -1
  12. package/dist/dnd-kit-utilities.cjs.production.min.js +0 -2
  13. package/dist/dnd-kit-utilities.cjs.production.min.js.map +0 -1
  14. package/dist/dnd-kit-utilities.esm.js +0 -333
  15. package/dist/dnd-kit-utilities.esm.js.map +0 -1
  16. package/dist/event/hasViewportRelativeCoordinates.d.ts +0 -1
  17. package/dist/event/index.d.ts +0 -3
  18. package/dist/event/isKeyboardEvent.d.ts +0 -1
  19. package/dist/event/isTouchEvent.d.ts +0 -1
  20. package/dist/execution-context/canUseDOM.d.ts +0 -1
  21. package/dist/execution-context/getOwnerDocument.d.ts +0 -1
  22. package/dist/execution-context/getWindow.d.ts +0 -1
  23. package/dist/execution-context/index.d.ts +0 -3
  24. package/dist/focus/findFirstFocusableNode.d.ts +0 -1
  25. package/dist/focus/index.d.ts +0 -1
  26. package/dist/hooks/index.d.ts +0 -9
  27. package/dist/hooks/useCombinedRefs.d.ts +0 -1
  28. package/dist/hooks/useEvent.d.ts +0 -1
  29. package/dist/hooks/useInterval.d.ts +0 -1
  30. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +0 -6
  31. package/dist/hooks/useLatestValue.d.ts +0 -2
  32. package/dist/hooks/useLazyMemo.d.ts +0 -1
  33. package/dist/hooks/useNodeRef.d.ts +0 -2
  34. package/dist/hooks/usePrevious.d.ts +0 -1
  35. package/dist/hooks/useUniqueId.d.ts +0 -1
  36. package/dist/type-guards/index.d.ts +0 -5
  37. package/dist/type-guards/isDocument.d.ts +0 -1
  38. package/dist/type-guards/isHTMLElement.d.ts +0 -1
  39. package/dist/type-guards/isNode.d.ts +0 -1
  40. package/dist/type-guards/isSVGElement.d.ts +0 -1
  41. package/dist/type-guards/isWindow.d.ts +0 -1
  42. package/dist/types.d.ts +0 -6
@@ -1,333 +0,0 @@
1
- import { useMemo, useLayoutEffect, useEffect, useRef, useCallback } from 'react';
2
-
3
- function useCombinedRefs() {
4
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
5
- refs[_key] = arguments[_key];
6
- }
7
-
8
- return useMemo(() => node => {
9
- refs.forEach(ref => ref(node));
10
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
11
- refs);
12
- }
13
-
14
- // https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js
15
- const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
16
-
17
- function isWindow(element) {
18
- const elementString = Object.prototype.toString.call(element);
19
- return elementString === '[object Window]' || // In Electron context the Window object serializes to [object global]
20
- elementString === '[object global]';
21
- }
22
-
23
- function isNode(node) {
24
- return 'nodeType' in node;
25
- }
26
-
27
- function getWindow(target) {
28
- var _target$ownerDocument, _target$ownerDocument2;
29
-
30
- if (!target) {
31
- return window;
32
- }
33
-
34
- if (isWindow(target)) {
35
- return target;
36
- }
37
-
38
- if (!isNode(target)) {
39
- return window;
40
- }
41
-
42
- return (_target$ownerDocument = (_target$ownerDocument2 = target.ownerDocument) == null ? void 0 : _target$ownerDocument2.defaultView) != null ? _target$ownerDocument : window;
43
- }
44
-
45
- function isDocument(node) {
46
- const {
47
- Document
48
- } = getWindow(node);
49
- return node instanceof Document;
50
- }
51
-
52
- function isHTMLElement(node) {
53
- if (isWindow(node)) {
54
- return false;
55
- }
56
-
57
- return node instanceof getWindow(node).HTMLElement;
58
- }
59
-
60
- function isSVGElement(node) {
61
- return node instanceof getWindow(node).SVGElement;
62
- }
63
-
64
- function getOwnerDocument(target) {
65
- if (!target) {
66
- return document;
67
- }
68
-
69
- if (isWindow(target)) {
70
- return target.document;
71
- }
72
-
73
- if (!isNode(target)) {
74
- return document;
75
- }
76
-
77
- if (isDocument(target)) {
78
- return target;
79
- }
80
-
81
- if (isHTMLElement(target) || isSVGElement(target)) {
82
- return target.ownerDocument;
83
- }
84
-
85
- return document;
86
- }
87
-
88
- /**
89
- * A hook that resolves to useEffect on the server and useLayoutEffect on the client
90
- * @param callback {function} Callback function that is invoked when the dependencies of the hook change
91
- */
92
-
93
- const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
94
-
95
- function useEvent(handler) {
96
- const handlerRef = useRef(handler);
97
- useIsomorphicLayoutEffect(() => {
98
- handlerRef.current = handler;
99
- });
100
- return useCallback(function () {
101
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
102
- args[_key] = arguments[_key];
103
- }
104
-
105
- return handlerRef.current == null ? void 0 : handlerRef.current(...args);
106
- }, []);
107
- }
108
-
109
- function useInterval() {
110
- const intervalRef = useRef(null);
111
- const set = useCallback((listener, duration) => {
112
- intervalRef.current = setInterval(listener, duration);
113
- }, []);
114
- const clear = useCallback(() => {
115
- if (intervalRef.current !== null) {
116
- clearInterval(intervalRef.current);
117
- intervalRef.current = null;
118
- }
119
- }, []);
120
- return [set, clear];
121
- }
122
-
123
- function useLatestValue(value, dependencies) {
124
- if (dependencies === void 0) {
125
- dependencies = [value];
126
- }
127
-
128
- const valueRef = useRef(value);
129
- useIsomorphicLayoutEffect(() => {
130
- if (valueRef.current !== value) {
131
- valueRef.current = value;
132
- }
133
- }, dependencies);
134
- return valueRef;
135
- }
136
-
137
- function useLazyMemo(callback, dependencies) {
138
- const valueRef = useRef();
139
- return useMemo(() => {
140
- const newValue = callback(valueRef.current);
141
- valueRef.current = newValue;
142
- return newValue;
143
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
144
- [...dependencies]);
145
- }
146
-
147
- function useNodeRef(onChange) {
148
- const onChangeHandler = useEvent(onChange);
149
- const node = useRef(null);
150
- const setNodeRef = useCallback(element => {
151
- if (element !== node.current) {
152
- onChangeHandler == null ? void 0 : onChangeHandler(element, node.current);
153
- }
154
-
155
- node.current = element;
156
- }, //eslint-disable-next-line
157
- []);
158
- return [node, setNodeRef];
159
- }
160
-
161
- function usePrevious(value) {
162
- const ref = useRef();
163
- useEffect(() => {
164
- ref.current = value;
165
- }, [value]);
166
- return ref.current;
167
- }
168
-
169
- let ids = {};
170
- function useUniqueId(prefix, value) {
171
- return useMemo(() => {
172
- if (value) {
173
- return value;
174
- }
175
-
176
- const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
177
- ids[prefix] = id;
178
- return prefix + "-" + id;
179
- }, [prefix, value]);
180
- }
181
-
182
- function createAdjustmentFn(modifier) {
183
- return function (object) {
184
- for (var _len = arguments.length, adjustments = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
185
- adjustments[_key - 1] = arguments[_key];
186
- }
187
-
188
- return adjustments.reduce((accumulator, adjustment) => {
189
- const entries = Object.entries(adjustment);
190
-
191
- for (const [key, valueAdjustment] of entries) {
192
- const value = accumulator[key];
193
-
194
- if (value != null) {
195
- accumulator[key] = value + modifier * valueAdjustment;
196
- }
197
- }
198
-
199
- return accumulator;
200
- }, { ...object
201
- });
202
- };
203
- }
204
-
205
- const add = /*#__PURE__*/createAdjustmentFn(1);
206
- const subtract = /*#__PURE__*/createAdjustmentFn(-1);
207
-
208
- function hasViewportRelativeCoordinates(event) {
209
- return 'clientX' in event && 'clientY' in event;
210
- }
211
-
212
- function isKeyboardEvent(event) {
213
- if (!event) {
214
- return false;
215
- }
216
-
217
- const {
218
- KeyboardEvent
219
- } = getWindow(event.target);
220
- return KeyboardEvent && event instanceof KeyboardEvent;
221
- }
222
-
223
- function isTouchEvent(event) {
224
- if (!event) {
225
- return false;
226
- }
227
-
228
- const {
229
- TouchEvent
230
- } = getWindow(event.target);
231
- return TouchEvent && event instanceof TouchEvent;
232
- }
233
-
234
- /**
235
- * Returns the normalized x and y coordinates for mouse and touch events.
236
- */
237
-
238
- function getEventCoordinates(event) {
239
- if (isTouchEvent(event)) {
240
- if (event.touches && event.touches.length) {
241
- const {
242
- clientX: x,
243
- clientY: y
244
- } = event.touches[0];
245
- return {
246
- x,
247
- y
248
- };
249
- } else if (event.changedTouches && event.changedTouches.length) {
250
- const {
251
- clientX: x,
252
- clientY: y
253
- } = event.changedTouches[0];
254
- return {
255
- x,
256
- y
257
- };
258
- }
259
- }
260
-
261
- if (hasViewportRelativeCoordinates(event)) {
262
- return {
263
- x: event.clientX,
264
- y: event.clientY
265
- };
266
- }
267
-
268
- return null;
269
- }
270
-
271
- const CSS = /*#__PURE__*/Object.freeze({
272
- Translate: {
273
- toString(transform) {
274
- if (!transform) {
275
- return;
276
- }
277
-
278
- const {
279
- x,
280
- y
281
- } = transform;
282
- return "translate3d(" + (x ? Math.round(x) : 0) + "px, " + (y ? Math.round(y) : 0) + "px, 0)";
283
- }
284
-
285
- },
286
- Scale: {
287
- toString(transform) {
288
- if (!transform) {
289
- return;
290
- }
291
-
292
- const {
293
- scaleX,
294
- scaleY
295
- } = transform;
296
- return "scaleX(" + scaleX + ") scaleY(" + scaleY + ")";
297
- }
298
-
299
- },
300
- Transform: {
301
- toString(transform) {
302
- if (!transform) {
303
- return;
304
- }
305
-
306
- return [CSS.Translate.toString(transform), CSS.Scale.toString(transform)].join(' ');
307
- }
308
-
309
- },
310
- Transition: {
311
- toString(_ref) {
312
- let {
313
- property,
314
- duration,
315
- easing
316
- } = _ref;
317
- return property + " " + duration + "ms " + easing;
318
- }
319
-
320
- }
321
- });
322
-
323
- const SELECTOR = 'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]';
324
- function findFirstFocusableNode(element) {
325
- if (element.matches(SELECTOR)) {
326
- return element;
327
- }
328
-
329
- return element.querySelector(SELECTOR);
330
- }
331
-
332
- export { CSS, add, canUseDOM, findFirstFocusableNode, getEventCoordinates, getOwnerDocument, getWindow, hasViewportRelativeCoordinates, isDocument, isHTMLElement, isKeyboardEvent, isNode, isSVGElement, isTouchEvent, isWindow, subtract, useCombinedRefs, useEvent, useInterval, useIsomorphicLayoutEffect, useLatestValue, useLazyMemo, useNodeRef, usePrevious, useUniqueId };
333
- //# sourceMappingURL=dnd-kit-utilities.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dnd-kit-utilities.esm.js","sources":["../src/hooks/useCombinedRefs.ts","../src/execution-context/canUseDOM.ts","../src/type-guards/isWindow.ts","../src/type-guards/isNode.ts","../src/execution-context/getWindow.ts","../src/type-guards/isDocument.ts","../src/type-guards/isHTMLElement.ts","../src/type-guards/isSVGElement.ts","../src/execution-context/getOwnerDocument.ts","../src/hooks/useIsomorphicLayoutEffect.ts","../src/hooks/useEvent.ts","../src/hooks/useInterval.ts","../src/hooks/useLatestValue.ts","../src/hooks/useLazyMemo.ts","../src/hooks/useNodeRef.ts","../src/hooks/usePrevious.ts","../src/hooks/useUniqueId.ts","../src/adjustment.ts","../src/event/hasViewportRelativeCoordinates.ts","../src/event/isKeyboardEvent.ts","../src/event/isTouchEvent.ts","../src/coordinates/getEventCoordinates.ts","../src/css.ts","../src/focus/findFirstFocusableNode.ts"],"sourcesContent":["import {useMemo} from 'react';\n\nexport function useCombinedRefs<T>(\n ...refs: ((node: T) => void)[]\n): (node: T) => void {\n return useMemo(\n () => (node: T) => {\n refs.forEach((ref) => ref(node));\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n refs\n );\n}\n","// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js\nexport const canUseDOM =\n typeof window !== 'undefined' &&\n typeof window.document !== 'undefined' &&\n typeof window.document.createElement !== 'undefined';\n","export function isWindow(element: Object): element is typeof window {\n const elementString = Object.prototype.toString.call(element);\n return (\n elementString === '[object Window]' ||\n // In Electron context the Window object serializes to [object global]\n elementString === '[object global]'\n );\n}\n","export function isNode(node: Object): node is Node {\n return 'nodeType' in node;\n}\n","import {isWindow} from '../type-guards/isWindow';\nimport {isNode} from '../type-guards/isNode';\n\nexport function getWindow(target: Event['target']): typeof window {\n if (!target) {\n return window;\n }\n\n if (isWindow(target)) {\n return target;\n }\n\n if (!isNode(target)) {\n return window;\n }\n\n return target.ownerDocument?.defaultView ?? window;\n}\n","import {getWindow} from '../execution-context/getWindow';\n\nexport function isDocument(node: Node): node is Document {\n const {Document} = getWindow(node);\n\n return node instanceof Document;\n}\n","import {getWindow} from '../execution-context/getWindow';\n\nimport {isWindow} from './isWindow';\n\nexport function isHTMLElement(node: Node | Window): node is HTMLElement {\n if (isWindow(node)) {\n return false;\n }\n\n return node instanceof getWindow(node).HTMLElement;\n}\n","import {getWindow} from '../execution-context/getWindow';\n\nexport function isSVGElement(node: Node): node is SVGElement {\n return node instanceof getWindow(node).SVGElement;\n}\n","import {\n isWindow,\n isHTMLElement,\n isDocument,\n isNode,\n isSVGElement,\n} from '../type-guards';\n\nexport function getOwnerDocument(target: Event['target']): Document {\n if (!target) {\n return document;\n }\n\n if (isWindow(target)) {\n return target.document;\n }\n\n if (!isNode(target)) {\n return document;\n }\n\n if (isDocument(target)) {\n return target;\n }\n\n if (isHTMLElement(target) || isSVGElement(target)) {\n return target.ownerDocument;\n }\n\n return document;\n}\n","import {useEffect, useLayoutEffect} from 'react';\n\nimport {canUseDOM} from '../execution-context';\n\n/**\n * A hook that resolves to useEffect on the server and useLayoutEffect on the client\n * @param callback {function} Callback function that is invoked when the dependencies of the hook change\n */\nexport const useIsomorphicLayoutEffect = canUseDOM\n ? useLayoutEffect\n : useEffect;\n","import {useCallback, useRef} from 'react';\n\nimport {useIsomorphicLayoutEffect} from './useIsomorphicLayoutEffect';\n\nexport function useEvent<T extends Function>(handler: T | undefined) {\n const handlerRef = useRef<T | undefined>(handler);\n\n useIsomorphicLayoutEffect(() => {\n handlerRef.current = handler;\n });\n\n return useCallback(function (...args: any) {\n return handlerRef.current?.(...args);\n }, []);\n}\n","import {useCallback, useRef} from 'react';\n\nexport function useInterval() {\n const intervalRef = useRef<number | null>(null);\n\n const set = useCallback((listener: Function, duration: number) => {\n intervalRef.current = setInterval(listener, duration);\n }, []);\n\n const clear = useCallback(() => {\n if (intervalRef.current !== null) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n }, []);\n\n return [set, clear] as const;\n}\n","import {useRef} from 'react';\nimport type {DependencyList} from 'react';\n\nimport {useIsomorphicLayoutEffect} from './useIsomorphicLayoutEffect';\n\nexport function useLatestValue<T extends any>(\n value: T,\n dependencies: DependencyList = [value]\n) {\n const valueRef = useRef<T>(value);\n\n useIsomorphicLayoutEffect(() => {\n if (valueRef.current !== value) {\n valueRef.current = value;\n }\n }, dependencies);\n\n return valueRef;\n}\n","import {useMemo, useRef} from 'react';\n\nexport function useLazyMemo<T>(\n callback: (prevValue: T | undefined) => T,\n dependencies: any[]\n) {\n const valueRef = useRef<T>();\n\n return useMemo(\n () => {\n const newValue = callback(valueRef.current);\n valueRef.current = newValue;\n\n return newValue;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...dependencies]\n );\n}\n","import {useRef, useCallback} from 'react';\n\nimport {useEvent} from './useEvent';\n\nexport function useNodeRef(\n onChange?: (\n newElement: HTMLElement | null,\n previousElement: HTMLElement | null\n ) => void\n) {\n const onChangeHandler = useEvent(onChange);\n const node = useRef<HTMLElement | null>(null);\n const setNodeRef = useCallback(\n (element: HTMLElement | null) => {\n if (element !== node.current) {\n onChangeHandler?.(element, node.current);\n }\n\n node.current = element;\n },\n //eslint-disable-next-line\n []\n );\n\n return [node, setNodeRef] as const;\n}\n","import {useRef, useEffect} from 'react';\n\nexport function usePrevious<T>(value: T) {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n","import {useMemo} from 'react';\n\nlet ids: Record<string, number> = {};\n\nexport function useUniqueId(prefix: string, value?: string) {\n return useMemo(() => {\n if (value) {\n return value;\n }\n\n const id = ids[prefix] == null ? 0 : ids[prefix] + 1;\n ids[prefix] = id;\n\n return `${prefix}-${id}`;\n }, [prefix, value]);\n}\n","function createAdjustmentFn(modifier: number) {\n return <T extends Record<U, number>, U extends string>(\n object: T,\n ...adjustments: Partial<T>[]\n ): T => {\n return adjustments.reduce<T>(\n (accumulator, adjustment) => {\n const entries = Object.entries(adjustment) as [U, number][];\n\n for (const [key, valueAdjustment] of entries) {\n const value = accumulator[key];\n\n if (value != null) {\n accumulator[key] = (value + modifier * valueAdjustment) as T[U];\n }\n }\n\n return accumulator;\n },\n {\n ...object,\n }\n );\n };\n}\n\nexport const add = createAdjustmentFn(1);\nexport const subtract = createAdjustmentFn(-1);\n","export function hasViewportRelativeCoordinates(\n event: Event\n): event is Event & Pick<PointerEvent, 'clientX' | 'clientY'> {\n return 'clientX' in event && 'clientY' in event;\n}\n","import {getWindow} from '../execution-context';\n\nexport function isKeyboardEvent(\n event: Event | undefined | null\n): event is KeyboardEvent {\n if (!event) {\n return false;\n }\n\n const {KeyboardEvent} = getWindow(event.target);\n\n return KeyboardEvent && event instanceof KeyboardEvent;\n}\n","import {getWindow} from '../execution-context';\n\nexport function isTouchEvent(\n event: Event | undefined | null\n): event is TouchEvent {\n if (!event) {\n return false;\n }\n\n const {TouchEvent} = getWindow(event.target);\n\n return TouchEvent && event instanceof TouchEvent;\n}\n","import type {Coordinates} from './types';\nimport {isTouchEvent, hasViewportRelativeCoordinates} from '../event';\n\n/**\n * Returns the normalized x and y coordinates for mouse and touch events.\n */\nexport function getEventCoordinates(event: Event): Coordinates | null {\n if (isTouchEvent(event)) {\n if (event.touches && event.touches.length) {\n const {clientX: x, clientY: y} = event.touches[0];\n\n return {\n x,\n y,\n };\n } else if (event.changedTouches && event.changedTouches.length) {\n const {clientX: x, clientY: y} = event.changedTouches[0];\n\n return {\n x,\n y,\n };\n }\n }\n\n if (hasViewportRelativeCoordinates(event)) {\n return {\n x: event.clientX,\n y: event.clientY,\n };\n }\n\n return null;\n}\n","export type Transform = {\n x: number;\n y: number;\n scaleX: number;\n scaleY: number;\n};\n\nexport interface Transition {\n property: string;\n easing: string;\n duration: number;\n}\n\nexport const CSS = Object.freeze({\n Translate: {\n toString(transform: Transform | null) {\n if (!transform) {\n return;\n }\n\n const {x, y} = transform;\n\n return `translate3d(${x ? Math.round(x) : 0}px, ${\n y ? Math.round(y) : 0\n }px, 0)`;\n },\n },\n Scale: {\n toString(transform: Transform | null) {\n if (!transform) {\n return;\n }\n\n const {scaleX, scaleY} = transform;\n\n return `scaleX(${scaleX}) scaleY(${scaleY})`;\n },\n },\n Transform: {\n toString(transform: Transform | null) {\n if (!transform) {\n return;\n }\n\n return [\n CSS.Translate.toString(transform),\n CSS.Scale.toString(transform),\n ].join(' ');\n },\n },\n Transition: {\n toString({property, duration, easing}: Transition) {\n return `${property} ${duration}ms ${easing}`;\n },\n },\n});\n","const SELECTOR =\n 'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]';\n\nexport function findFirstFocusableNode(\n element: HTMLElement\n): HTMLElement | null {\n if (element.matches(SELECTOR)) {\n return element;\n }\n\n return element.querySelector(SELECTOR);\n}\n"],"names":["useCombinedRefs","refs","useMemo","node","forEach","ref","canUseDOM","window","document","createElement","isWindow","element","elementString","Object","prototype","toString","call","isNode","getWindow","target","ownerDocument","defaultView","isDocument","Document","isHTMLElement","HTMLElement","isSVGElement","SVGElement","getOwnerDocument","useIsomorphicLayoutEffect","useLayoutEffect","useEffect","useEvent","handler","handlerRef","useRef","current","useCallback","args","useInterval","intervalRef","set","listener","duration","setInterval","clear","clearInterval","useLatestValue","value","dependencies","valueRef","useLazyMemo","callback","newValue","useNodeRef","onChange","onChangeHandler","setNodeRef","usePrevious","ids","useUniqueId","prefix","id","createAdjustmentFn","modifier","object","adjustments","reduce","accumulator","adjustment","entries","key","valueAdjustment","add","subtract","hasViewportRelativeCoordinates","event","isKeyboardEvent","KeyboardEvent","isTouchEvent","TouchEvent","getEventCoordinates","touches","length","clientX","x","clientY","y","changedTouches","CSS","freeze","Translate","transform","Math","round","Scale","scaleX","scaleY","Transform","join","Transition","property","easing","SELECTOR","findFirstFocusableNode","matches","querySelector"],"mappings":";;SAEgBA;oCACXC;IAAAA;;;EAEH,OAAOC,OAAO,CACZ,MAAOC,IAAD;IACJF,IAAI,CAACG,OAAL,CAAcC,GAAD,IAASA,GAAG,CAACF,IAAD,CAAzB;GAFU;EAKZF,IALY,CAAd;AAOD;;ACZD;AACA,MAAaK,SAAS,GACpB,OAAOC,MAAP,KAAkB,WAAlB,IACA,OAAOA,MAAM,CAACC,QAAd,KAA2B,WAD3B,IAEA,OAAOD,MAAM,CAACC,QAAP,CAAgBC,aAAvB,KAAyC,WAHpC;;SCDSC,SAASC;EACvB,MAAMC,aAAa,GAAGC,MAAM,CAACC,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BL,OAA/B,CAAtB;EACA,OACEC,aAAa,KAAK,iBAAlB;EAEAA,aAAa,KAAK,iBAHpB;AAKD;;SCPeK,OAAOd;EACrB,OAAO,cAAcA,IAArB;AACD;;SCCee,UAAUC;;;EACxB,IAAI,CAACA,MAAL,EAAa;IACX,OAAOZ,MAAP;;;EAGF,IAAIG,QAAQ,CAACS,MAAD,CAAZ,EAAsB;IACpB,OAAOA,MAAP;;;EAGF,IAAI,CAACF,MAAM,CAACE,MAAD,CAAX,EAAqB;IACnB,OAAOZ,MAAP;;;EAGF,0DAAOY,MAAM,CAACC,aAAd,qBAAO,uBAAsBC,WAA7B,oCAA4Cd,MAA5C;AACD;;SCfee,WAAWnB;EACzB,MAAM;IAACoB;MAAYL,SAAS,CAACf,IAAD,CAA5B;EAEA,OAAOA,IAAI,YAAYoB,QAAvB;AACD;;SCF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0 @@
1
- export { hasViewportRelativeCoordinates } from './hasViewportRelativeCoordinates';
2
- export { isKeyboardEvent } from './isKeyboardEvent';
3
- export { isTouchEvent } from './isTouchEvent';
@@ -1 +0,0 @@
1
- export declare function isKeyboardEvent(event: Event | undefined | null): event is KeyboardEvent;
@@ -1 +0,0 @@
1
- export declare function isTouchEvent(event: Event | undefined | null): event is TouchEvent;
@@ -1 +0,0 @@
1
- export declare const canUseDOM: boolean;
@@ -1 +0,0 @@
1
- export declare function getOwnerDocument(target: Event['target']): Document;
@@ -1 +0,0 @@
1
- export declare function getWindow(target: Event['target']): typeof window;
@@ -1,3 +0,0 @@
1
- export { canUseDOM } from './canUseDOM';
2
- export { getOwnerDocument } from './getOwnerDocument';
3
- export { getWindow } from './getWindow';
@@ -1 +0,0 @@
1
- export declare function findFirstFocusableNode(element: HTMLElement): HTMLElement | null;
@@ -1 +0,0 @@
1
- export { findFirstFocusableNode } from './findFirstFocusableNode';
@@ -1,9 +0,0 @@
1
- export { useCombinedRefs } from './useCombinedRefs';
2
- export { useEvent } from './useEvent';
3
- export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
4
- export { useInterval } from './useInterval';
5
- export { useLatestValue } from './useLatestValue';
6
- export { useLazyMemo } from './useLazyMemo';
7
- export { useNodeRef } from './useNodeRef';
8
- export { usePrevious } from './usePrevious';
9
- export { useUniqueId } from './useUniqueId';
@@ -1 +0,0 @@
1
- export declare function useCombinedRefs<T>(...refs: ((node: T) => void)[]): (node: T) => void;
@@ -1 +0,0 @@
1
- export declare function useEvent<T extends Function>(handler: T | undefined): (...args: any) => any;
@@ -1 +0,0 @@
1
- export declare function useInterval(): readonly [(listener: Function, duration: number) => void, () => void];
@@ -1,6 +0,0 @@
1
- import { useLayoutEffect } from 'react';
2
- /**
3
- * A hook that resolves to useEffect on the server and useLayoutEffect on the client
4
- * @param callback {function} Callback function that is invoked when the dependencies of the hook change
5
- */
6
- export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
@@ -1,2 +0,0 @@
1
- import type { DependencyList } from 'react';
2
- export declare function useLatestValue<T extends any>(value: T, dependencies?: DependencyList): import("react").MutableRefObject<T>;
@@ -1 +0,0 @@
1
- export declare function useLazyMemo<T>(callback: (prevValue: T | undefined) => T, dependencies: any[]): T;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function useNodeRef(onChange?: (newElement: HTMLElement | null, previousElement: HTMLElement | null) => void): readonly [import("react").MutableRefObject<HTMLElement | null>, (element: HTMLElement | null) => void];
@@ -1 +0,0 @@
1
- export declare function usePrevious<T>(value: T): T | undefined;
@@ -1 +0,0 @@
1
- export declare function useUniqueId(prefix: string, value?: string): string;
@@ -1,5 +0,0 @@
1
- export { isDocument } from './isDocument';
2
- export { isHTMLElement } from './isHTMLElement';
3
- export { isNode } from './isNode';
4
- export { isSVGElement } from './isSVGElement';
5
- export { isWindow } from './isWindow';
@@ -1 +0,0 @@
1
- export declare function isDocument(node: Node): node is Document;
@@ -1 +0,0 @@
1
- export declare function isHTMLElement(node: Node | Window): node is HTMLElement;
@@ -1 +0,0 @@
1
- export declare function isNode(node: Object): node is Node;
@@ -1 +0,0 @@
1
- export declare function isSVGElement(node: Node): node is SVGElement;
@@ -1 +0,0 @@
1
- export declare function isWindow(element: Object): element is typeof window;
package/dist/types.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare type Arguments<T> = T extends (...args: infer U) => any ? U : never;
2
- export declare type DeepRequired<T> = {
3
- [K in keyof T]-?: Required<T[K]>;
4
- };
5
- export declare type FirstArgument<T> = T extends (firstArg: infer U, ...args: Array<any>) => any ? U : never;
6
- export declare type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;