@react-aria/utils 3.0.0-nightly-641446f65-240905
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 +3 -0
- package/dist/chain.main.js +26 -0
- package/dist/chain.main.js.map +1 -0
- package/dist/chain.mjs +21 -0
- package/dist/chain.module.js +21 -0
- package/dist/chain.module.js.map +1 -0
- package/dist/domHelpers.main.js +19 -0
- package/dist/domHelpers.main.js.map +1 -0
- package/dist/domHelpers.mjs +13 -0
- package/dist/domHelpers.module.js +13 -0
- package/dist/domHelpers.module.js.map +1 -0
- package/dist/filterDOMProps.main.js +45 -0
- package/dist/filterDOMProps.main.js.map +1 -0
- package/dist/filterDOMProps.mjs +40 -0
- package/dist/filterDOMProps.module.js +40 -0
- package/dist/filterDOMProps.module.js.map +1 -0
- package/dist/focusWithoutScrolling.main.js +72 -0
- package/dist/focusWithoutScrolling.main.js.map +1 -0
- package/dist/focusWithoutScrolling.mjs +67 -0
- package/dist/focusWithoutScrolling.module.js +67 -0
- package/dist/focusWithoutScrolling.module.js.map +1 -0
- package/dist/getOffset.main.js +24 -0
- package/dist/getOffset.main.js.map +1 -0
- package/dist/getOffset.mjs +19 -0
- package/dist/getOffset.module.js +19 -0
- package/dist/getOffset.module.js.map +1 -0
- package/dist/getScrollParent.main.js +28 -0
- package/dist/getScrollParent.main.js.map +1 -0
- package/dist/getScrollParent.mjs +23 -0
- package/dist/getScrollParent.module.js +23 -0
- package/dist/getScrollParent.module.js.map +1 -0
- package/dist/getScrollParents.main.js +30 -0
- package/dist/getScrollParents.main.js.map +1 -0
- package/dist/getScrollParents.mjs +25 -0
- package/dist/getScrollParents.module.js +25 -0
- package/dist/getScrollParents.module.js.map +1 -0
- package/dist/import.mjs +81 -0
- package/dist/isScrollable.main.js +25 -0
- package/dist/isScrollable.main.js.map +1 -0
- package/dist/isScrollable.mjs +20 -0
- package/dist/isScrollable.module.js +20 -0
- package/dist/isScrollable.module.js.map +1 -0
- package/dist/isVirtualEvent.main.js +41 -0
- package/dist/isVirtualEvent.main.js.map +1 -0
- package/dist/isVirtualEvent.mjs +35 -0
- package/dist/isVirtualEvent.module.js +35 -0
- package/dist/isVirtualEvent.module.js.map +1 -0
- package/dist/main.js +138 -0
- package/dist/main.js.map +1 -0
- package/dist/mergeProps.main.js +51 -0
- package/dist/mergeProps.main.js.map +1 -0
- package/dist/mergeProps.mjs +42 -0
- package/dist/mergeProps.module.js +42 -0
- package/dist/mergeProps.module.js.map +1 -0
- package/dist/mergeRefs.main.js +28 -0
- package/dist/mergeRefs.main.js.map +1 -0
- package/dist/mergeRefs.mjs +23 -0
- package/dist/mergeRefs.module.js +23 -0
- package/dist/mergeRefs.module.js.map +1 -0
- package/dist/module.js +81 -0
- package/dist/module.js.map +1 -0
- package/dist/openLink.main.js +155 -0
- package/dist/openLink.main.js.map +1 -0
- package/dist/openLink.mjs +140 -0
- package/dist/openLink.module.js +140 -0
- package/dist/openLink.module.js.map +1 -0
- package/dist/platform.main.js +71 -0
- package/dist/platform.main.js.map +1 -0
- package/dist/platform.mjs +58 -0
- package/dist/platform.module.js +58 -0
- package/dist/platform.module.js.map +1 -0
- package/dist/runAfterTransition.main.js +82 -0
- package/dist/runAfterTransition.main.js.map +1 -0
- package/dist/runAfterTransition.mjs +77 -0
- package/dist/runAfterTransition.module.js +77 -0
- package/dist/runAfterTransition.module.js.map +1 -0
- package/dist/scrollIntoView.main.js +96 -0
- package/dist/scrollIntoView.main.js.map +1 -0
- package/dist/scrollIntoView.mjs +90 -0
- package/dist/scrollIntoView.module.js +90 -0
- package/dist/scrollIntoView.module.js.map +1 -0
- package/dist/types.d.ts +229 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/useDeepMemo.main.js +30 -0
- package/dist/useDeepMemo.main.js.map +1 -0
- package/dist/useDeepMemo.mjs +25 -0
- package/dist/useDeepMemo.module.js +25 -0
- package/dist/useDeepMemo.module.js.map +1 -0
- package/dist/useDescription.main.js +59 -0
- package/dist/useDescription.main.js.map +1 -0
- package/dist/useDescription.mjs +54 -0
- package/dist/useDescription.module.js +54 -0
- package/dist/useDescription.module.js.map +1 -0
- package/dist/useDrag1D.main.js +139 -0
- package/dist/useDrag1D.main.js.map +1 -0
- package/dist/useDrag1D.mjs +134 -0
- package/dist/useDrag1D.module.js +134 -0
- package/dist/useDrag1D.module.js.map +1 -0
- package/dist/useEffectEvent.main.js +37 -0
- package/dist/useEffectEvent.main.js.map +1 -0
- package/dist/useEffectEvent.mjs +32 -0
- package/dist/useEffectEvent.module.js +32 -0
- package/dist/useEffectEvent.module.js.map +1 -0
- package/dist/useEvent.main.js +42 -0
- package/dist/useEvent.main.js.map +1 -0
- package/dist/useEvent.mjs +37 -0
- package/dist/useEvent.module.js +37 -0
- package/dist/useEvent.module.js.map +1 -0
- package/dist/useFormReset.main.js +41 -0
- package/dist/useFormReset.main.js.map +1 -0
- package/dist/useFormReset.mjs +36 -0
- package/dist/useFormReset.module.js +36 -0
- package/dist/useFormReset.module.js.map +1 -0
- package/dist/useGlobalListeners.main.js +63 -0
- package/dist/useGlobalListeners.main.js.map +1 -0
- package/dist/useGlobalListeners.mjs +58 -0
- package/dist/useGlobalListeners.module.js +58 -0
- package/dist/useGlobalListeners.module.js.map +1 -0
- package/dist/useId.main.js +93 -0
- package/dist/useId.main.js.map +1 -0
- package/dist/useId.mjs +86 -0
- package/dist/useId.module.js +86 -0
- package/dist/useId.module.js.map +1 -0
- package/dist/useLabels.main.js +44 -0
- package/dist/useLabels.main.js.map +1 -0
- package/dist/useLabels.mjs +39 -0
- package/dist/useLabels.module.js +39 -0
- package/dist/useLabels.module.js.map +1 -0
- package/dist/useLayoutEffect.main.js +27 -0
- package/dist/useLayoutEffect.main.js.map +1 -0
- package/dist/useLayoutEffect.mjs +18 -0
- package/dist/useLayoutEffect.module.js +18 -0
- package/dist/useLayoutEffect.module.js.map +1 -0
- package/dist/useLoadMore.main.js +72 -0
- package/dist/useLoadMore.main.js.map +1 -0
- package/dist/useLoadMore.mjs +67 -0
- package/dist/useLoadMore.module.js +67 -0
- package/dist/useLoadMore.module.js.map +1 -0
- package/dist/useObjectRef.main.js +37 -0
- package/dist/useObjectRef.main.js.map +1 -0
- package/dist/useObjectRef.mjs +32 -0
- package/dist/useObjectRef.module.js +32 -0
- package/dist/useObjectRef.module.js.map +1 -0
- package/dist/useResizeObserver.main.js +43 -0
- package/dist/useResizeObserver.main.js.map +1 -0
- package/dist/useResizeObserver.mjs +38 -0
- package/dist/useResizeObserver.module.js +38 -0
- package/dist/useResizeObserver.module.js.map +1 -0
- package/dist/useSyncRef.main.js +32 -0
- package/dist/useSyncRef.main.js.map +1 -0
- package/dist/useSyncRef.mjs +27 -0
- package/dist/useSyncRef.module.js +27 -0
- package/dist/useSyncRef.module.js.map +1 -0
- package/dist/useUpdateEffect.main.js +38 -0
- package/dist/useUpdateEffect.main.js.map +1 -0
- package/dist/useUpdateEffect.mjs +33 -0
- package/dist/useUpdateEffect.module.js +33 -0
- package/dist/useUpdateEffect.module.js.map +1 -0
- package/dist/useValueEffect.main.js +58 -0
- package/dist/useValueEffect.main.js.map +1 -0
- package/dist/useValueEffect.mjs +53 -0
- package/dist/useValueEffect.module.js +53 -0
- package/dist/useValueEffect.module.js.map +1 -0
- package/dist/useViewportSize.main.js +56 -0
- package/dist/useViewportSize.main.js.map +1 -0
- package/dist/useViewportSize.mjs +51 -0
- package/dist/useViewportSize.module.js +51 -0
- package/dist/useViewportSize.module.js.map +1 -0
- package/package.json +38 -0
- package/src/chain.ts +24 -0
- package/src/domHelpers.ts +14 -0
- package/src/filterDOMProps.ts +76 -0
- package/src/focusWithoutScrolling.ts +96 -0
- package/src/getOffset.ts +19 -0
- package/src/getScrollParent.ts +27 -0
- package/src/getScrollParents.ts +26 -0
- package/src/index.ts +44 -0
- package/src/isScrollable.ts +22 -0
- package/src/isVirtualEvent.ts +58 -0
- package/src/mergeProps.ts +75 -0
- package/src/mergeRefs.ts +32 -0
- package/src/openLink.tsx +183 -0
- package/src/platform.ts +79 -0
- package/src/runAfterTransition.ts +105 -0
- package/src/scrollIntoView.ts +109 -0
- package/src/useDeepMemo.ts +27 -0
- package/src/useDescription.ts +56 -0
- package/src/useDrag1D.ts +190 -0
- package/src/useEffectEvent.ts +26 -0
- package/src/useEvent.ts +37 -0
- package/src/useFormReset.ts +36 -0
- package/src/useGlobalListeners.ts +51 -0
- package/src/useId.ts +108 -0
- package/src/useLabels.ts +48 -0
- package/src/useLayoutEffect.ts +20 -0
- package/src/useLoadMore.ts +82 -0
- package/src/useObjectRef.ts +39 -0
- package/src/useResizeObserver.ts +48 -0
- package/src/useSyncRef.ts +33 -0
- package/src/useUpdateEffect.ts +36 -0
- package/src/useValueEffect.ts +64 -0
- package/src/useViewportSize.ts +63 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var $16ec41ef3e36c19c$exports = require("./getOffset.main.js");
|
|
2
|
+
var $hK8r3$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useDrag1D", () => $28ed3fb20343b78b$export$7bbed75feba39706);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
21
|
+
|
|
22
|
+
// Keep track of elements that we are currently handling dragging for via useDrag1D.
|
|
23
|
+
// If there's an ancestor and a descendant both using useDrag1D(), and the user starts
|
|
24
|
+
// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
|
|
25
|
+
const $28ed3fb20343b78b$var$draggingElements = [];
|
|
26
|
+
function $28ed3fb20343b78b$export$7bbed75feba39706(props) {
|
|
27
|
+
console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
|
|
28
|
+
let { containerRef: containerRef, reverse: reverse, orientation: orientation, onHover: onHover, onDrag: onDrag, onPositionChange: onPositionChange, onIncrement: onIncrement, onDecrement: onDecrement, onIncrementToMax: onIncrementToMax, onDecrementToMin: onDecrementToMin, onCollapseToggle: onCollapseToggle } = props;
|
|
29
|
+
let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY;
|
|
30
|
+
let getNextOffset = (e)=>{
|
|
31
|
+
let containerOffset = (0, $16ec41ef3e36c19c$exports.getOffset)(containerRef.current, reverse, orientation);
|
|
32
|
+
let mouseOffset = getPosition(e);
|
|
33
|
+
let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
|
|
34
|
+
return nextOffset;
|
|
35
|
+
};
|
|
36
|
+
let dragging = (0, $hK8r3$react.useRef)(false);
|
|
37
|
+
let prevPosition = (0, $hK8r3$react.useRef)(0);
|
|
38
|
+
// Keep track of the current handlers in a ref so that the events can access them.
|
|
39
|
+
let handlers = (0, $hK8r3$react.useRef)({
|
|
40
|
+
onPositionChange: onPositionChange,
|
|
41
|
+
onDrag: onDrag
|
|
42
|
+
});
|
|
43
|
+
handlers.current.onDrag = onDrag;
|
|
44
|
+
handlers.current.onPositionChange = onPositionChange;
|
|
45
|
+
let onMouseDragged = (e)=>{
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
let nextOffset = getNextOffset(e);
|
|
48
|
+
if (!dragging.current) {
|
|
49
|
+
dragging.current = true;
|
|
50
|
+
if (handlers.current.onDrag) handlers.current.onDrag(true);
|
|
51
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
52
|
+
}
|
|
53
|
+
if (prevPosition.current === nextOffset) return;
|
|
54
|
+
prevPosition.current = nextOffset;
|
|
55
|
+
if (onPositionChange) onPositionChange(nextOffset);
|
|
56
|
+
};
|
|
57
|
+
let onMouseUp = (e)=>{
|
|
58
|
+
const target = e.target;
|
|
59
|
+
dragging.current = false;
|
|
60
|
+
let nextOffset = getNextOffset(e);
|
|
61
|
+
if (handlers.current.onDrag) handlers.current.onDrag(false);
|
|
62
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
63
|
+
$28ed3fb20343b78b$var$draggingElements.splice($28ed3fb20343b78b$var$draggingElements.indexOf(target), 1);
|
|
64
|
+
window.removeEventListener('mouseup', onMouseUp, false);
|
|
65
|
+
window.removeEventListener('mousemove', onMouseDragged, false);
|
|
66
|
+
};
|
|
67
|
+
let onMouseDown = (e)=>{
|
|
68
|
+
const target = e.currentTarget;
|
|
69
|
+
// If we're already handling dragging on a descendant with useDrag1D, then
|
|
70
|
+
// we don't want to handle the drag motion on this target as well.
|
|
71
|
+
if ($28ed3fb20343b78b$var$draggingElements.some((elt)=>target.contains(elt))) return;
|
|
72
|
+
$28ed3fb20343b78b$var$draggingElements.push(target);
|
|
73
|
+
window.addEventListener('mousemove', onMouseDragged, false);
|
|
74
|
+
window.addEventListener('mouseup', onMouseUp, false);
|
|
75
|
+
};
|
|
76
|
+
let onMouseEnter = ()=>{
|
|
77
|
+
if (onHover) onHover(true);
|
|
78
|
+
};
|
|
79
|
+
let onMouseOut = ()=>{
|
|
80
|
+
if (onHover) onHover(false);
|
|
81
|
+
};
|
|
82
|
+
let onKeyDown = (e)=>{
|
|
83
|
+
switch(e.key){
|
|
84
|
+
case 'Left':
|
|
85
|
+
case 'ArrowLeft':
|
|
86
|
+
if (orientation === 'horizontal') {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
if (onDecrement && !reverse) onDecrement();
|
|
89
|
+
else if (onIncrement && reverse) onIncrement();
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case 'Up':
|
|
93
|
+
case 'ArrowUp':
|
|
94
|
+
if (orientation === 'vertical') {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
if (onDecrement && !reverse) onDecrement();
|
|
97
|
+
else if (onIncrement && reverse) onIncrement();
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
case 'Right':
|
|
101
|
+
case 'ArrowRight':
|
|
102
|
+
if (orientation === 'horizontal') {
|
|
103
|
+
e.preventDefault();
|
|
104
|
+
if (onIncrement && !reverse) onIncrement();
|
|
105
|
+
else if (onDecrement && reverse) onDecrement();
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case 'Down':
|
|
109
|
+
case 'ArrowDown':
|
|
110
|
+
if (orientation === 'vertical') {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
if (onIncrement && !reverse) onIncrement();
|
|
113
|
+
else if (onDecrement && reverse) onDecrement();
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
case 'Home':
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
if (onDecrementToMin) onDecrementToMin();
|
|
119
|
+
break;
|
|
120
|
+
case 'End':
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
if (onIncrementToMax) onIncrementToMax();
|
|
123
|
+
break;
|
|
124
|
+
case 'Enter':
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
if (onCollapseToggle) onCollapseToggle();
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
onMouseDown: onMouseDown,
|
|
132
|
+
onMouseEnter: onMouseEnter,
|
|
133
|
+
onMouseOut: onMouseOut,
|
|
134
|
+
onKeyDown: onKeyDown
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=useDrag1D.main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;yBACK,IAAI,eAAe,SACxB;gBAEJ;gBACA;YACF,KAAK;YACL,KAAK;gBACH,IAAI,gBAAgB,YAAY;oBAC9B,EAAE,cAAc;oBAChB,IAAI,eAAe,CAAC,SAClB;yBACK,IAAI,eAAe,SACxB;gBAEJ;gBACA;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;QACJ;IACF;IAEA,OAAO;qBAAC;sBAAa;oBAAc;mBAAY;IAAS;AAC1D","sources":["packages/@react-aria/utils/src/useDrag1D.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n /* eslint-disable rulesdir/pure-render */\n\nimport {getOffset} from './getOffset';\nimport {Orientation} from '@react-types/shared';\nimport React, {HTMLAttributes, MutableRefObject, useRef} from 'react';\n\ninterface UseDrag1DProps {\n containerRef: MutableRefObject<HTMLElement>,\n reverse?: boolean,\n orientation?: Orientation,\n onHover?: (hovered: boolean) => void,\n onDrag?: (dragging: boolean) => void,\n onPositionChange?: (position: number) => void,\n onIncrement?: () => void,\n onDecrement?: () => void,\n onIncrementToMax?: () => void,\n onDecrementToMin?: () => void,\n onCollapseToggle?: () => void\n}\n\n// Keep track of elements that we are currently handling dragging for via useDrag1D.\n// If there's an ancestor and a descendant both using useDrag1D(), and the user starts\n// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.\nconst draggingElements: HTMLElement[] = [];\n\n// created for splitview, this should be reusable for things like sliders/dials\n// It also handles keyboard events on the target allowing for increment/decrement by a given stepsize as well as minifying/maximizing and toggling between minified and previous size\n// It can also take a 'reverse' param to say if we should measure from the right/bottom instead of the top/left\n// It can also handle either a vertical or horizontal movement, but not both at the same time\n\nexport function useDrag1D(props: UseDrag1DProps): HTMLAttributes<HTMLElement> {\n console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');\n let {containerRef, reverse, orientation, onHover, onDrag, onPositionChange, onIncrement, onDecrement, onIncrementToMax, onDecrementToMin, onCollapseToggle} = props;\n let getPosition = (e) => orientation === 'horizontal' ? e.clientX : e.clientY;\n let getNextOffset = (e: MouseEvent) => {\n let containerOffset = getOffset(containerRef.current, reverse, orientation);\n let mouseOffset = getPosition(e);\n let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;\n return nextOffset;\n };\n let dragging = useRef(false);\n let prevPosition = useRef(0);\n\n // Keep track of the current handlers in a ref so that the events can access them.\n let handlers = useRef({onPositionChange, onDrag});\n handlers.current.onDrag = onDrag;\n handlers.current.onPositionChange = onPositionChange;\n\n let onMouseDragged = (e: MouseEvent) => {\n e.preventDefault();\n let nextOffset = getNextOffset(e);\n if (!dragging.current) {\n dragging.current = true;\n if (handlers.current.onDrag) {\n handlers.current.onDrag(true);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n }\n if (prevPosition.current === nextOffset) {\n return;\n }\n prevPosition.current = nextOffset;\n if (onPositionChange) {\n onPositionChange(nextOffset);\n }\n };\n\n let onMouseUp = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n dragging.current = false;\n let nextOffset = getNextOffset(e);\n if (handlers.current.onDrag) {\n handlers.current.onDrag(false);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n\n draggingElements.splice(draggingElements.indexOf(target), 1);\n window.removeEventListener('mouseup', onMouseUp, false);\n window.removeEventListener('mousemove', onMouseDragged, false);\n };\n\n let onMouseDown = (e: React.MouseEvent<HTMLElement>) => {\n const target = e.currentTarget;\n // If we're already handling dragging on a descendant with useDrag1D, then\n // we don't want to handle the drag motion on this target as well.\n if (draggingElements.some(elt => target.contains(elt))) {\n return;\n }\n draggingElements.push(target);\n window.addEventListener('mousemove', onMouseDragged, false);\n window.addEventListener('mouseup', onMouseUp, false);\n };\n\n let onMouseEnter = () => {\n if (onHover) {\n onHover(true);\n }\n };\n\n let onMouseOut = () => {\n if (onHover) {\n onHover(false);\n }\n };\n\n let onKeyDown = (e) => {\n switch (e.key) {\n case 'Left':\n case 'ArrowLeft':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Up':\n case 'ArrowUp':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Right':\n case 'ArrowRight':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Down':\n case 'ArrowDown':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Home':\n e.preventDefault();\n if (onDecrementToMin) {\n onDecrementToMin();\n }\n break;\n case 'End':\n e.preventDefault();\n if (onIncrementToMax) {\n onIncrementToMax();\n }\n break;\n case 'Enter':\n e.preventDefault();\n if (onCollapseToggle) {\n onCollapseToggle();\n }\n break;\n }\n };\n\n return {onMouseDown, onMouseEnter, onMouseOut, onKeyDown};\n}\n"],"names":[],"version":3,"file":"useDrag1D.main.js.map"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {getOffset as $ab71dadb03a6fb2e$export$622cea445a1c5b7d} from "./getOffset.mjs";
|
|
2
|
+
import {useRef as $1rnCS$useRef} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
15
|
+
|
|
16
|
+
// Keep track of elements that we are currently handling dragging for via useDrag1D.
|
|
17
|
+
// If there's an ancestor and a descendant both using useDrag1D(), and the user starts
|
|
18
|
+
// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
|
|
19
|
+
const $9cc09df9fd7676be$var$draggingElements = [];
|
|
20
|
+
function $9cc09df9fd7676be$export$7bbed75feba39706(props) {
|
|
21
|
+
console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
|
|
22
|
+
let { containerRef: containerRef, reverse: reverse, orientation: orientation, onHover: onHover, onDrag: onDrag, onPositionChange: onPositionChange, onIncrement: onIncrement, onDecrement: onDecrement, onIncrementToMax: onIncrementToMax, onDecrementToMin: onDecrementToMin, onCollapseToggle: onCollapseToggle } = props;
|
|
23
|
+
let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY;
|
|
24
|
+
let getNextOffset = (e)=>{
|
|
25
|
+
let containerOffset = (0, $ab71dadb03a6fb2e$export$622cea445a1c5b7d)(containerRef.current, reverse, orientation);
|
|
26
|
+
let mouseOffset = getPosition(e);
|
|
27
|
+
let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
|
|
28
|
+
return nextOffset;
|
|
29
|
+
};
|
|
30
|
+
let dragging = (0, $1rnCS$useRef)(false);
|
|
31
|
+
let prevPosition = (0, $1rnCS$useRef)(0);
|
|
32
|
+
// Keep track of the current handlers in a ref so that the events can access them.
|
|
33
|
+
let handlers = (0, $1rnCS$useRef)({
|
|
34
|
+
onPositionChange: onPositionChange,
|
|
35
|
+
onDrag: onDrag
|
|
36
|
+
});
|
|
37
|
+
handlers.current.onDrag = onDrag;
|
|
38
|
+
handlers.current.onPositionChange = onPositionChange;
|
|
39
|
+
let onMouseDragged = (e)=>{
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
let nextOffset = getNextOffset(e);
|
|
42
|
+
if (!dragging.current) {
|
|
43
|
+
dragging.current = true;
|
|
44
|
+
if (handlers.current.onDrag) handlers.current.onDrag(true);
|
|
45
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
46
|
+
}
|
|
47
|
+
if (prevPosition.current === nextOffset) return;
|
|
48
|
+
prevPosition.current = nextOffset;
|
|
49
|
+
if (onPositionChange) onPositionChange(nextOffset);
|
|
50
|
+
};
|
|
51
|
+
let onMouseUp = (e)=>{
|
|
52
|
+
const target = e.target;
|
|
53
|
+
dragging.current = false;
|
|
54
|
+
let nextOffset = getNextOffset(e);
|
|
55
|
+
if (handlers.current.onDrag) handlers.current.onDrag(false);
|
|
56
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
57
|
+
$9cc09df9fd7676be$var$draggingElements.splice($9cc09df9fd7676be$var$draggingElements.indexOf(target), 1);
|
|
58
|
+
window.removeEventListener('mouseup', onMouseUp, false);
|
|
59
|
+
window.removeEventListener('mousemove', onMouseDragged, false);
|
|
60
|
+
};
|
|
61
|
+
let onMouseDown = (e)=>{
|
|
62
|
+
const target = e.currentTarget;
|
|
63
|
+
// If we're already handling dragging on a descendant with useDrag1D, then
|
|
64
|
+
// we don't want to handle the drag motion on this target as well.
|
|
65
|
+
if ($9cc09df9fd7676be$var$draggingElements.some((elt)=>target.contains(elt))) return;
|
|
66
|
+
$9cc09df9fd7676be$var$draggingElements.push(target);
|
|
67
|
+
window.addEventListener('mousemove', onMouseDragged, false);
|
|
68
|
+
window.addEventListener('mouseup', onMouseUp, false);
|
|
69
|
+
};
|
|
70
|
+
let onMouseEnter = ()=>{
|
|
71
|
+
if (onHover) onHover(true);
|
|
72
|
+
};
|
|
73
|
+
let onMouseOut = ()=>{
|
|
74
|
+
if (onHover) onHover(false);
|
|
75
|
+
};
|
|
76
|
+
let onKeyDown = (e)=>{
|
|
77
|
+
switch(e.key){
|
|
78
|
+
case 'Left':
|
|
79
|
+
case 'ArrowLeft':
|
|
80
|
+
if (orientation === 'horizontal') {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
if (onDecrement && !reverse) onDecrement();
|
|
83
|
+
else if (onIncrement && reverse) onIncrement();
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case 'Up':
|
|
87
|
+
case 'ArrowUp':
|
|
88
|
+
if (orientation === 'vertical') {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (onDecrement && !reverse) onDecrement();
|
|
91
|
+
else if (onIncrement && reverse) onIncrement();
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'Right':
|
|
95
|
+
case 'ArrowRight':
|
|
96
|
+
if (orientation === 'horizontal') {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
if (onIncrement && !reverse) onIncrement();
|
|
99
|
+
else if (onDecrement && reverse) onDecrement();
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 'Down':
|
|
103
|
+
case 'ArrowDown':
|
|
104
|
+
if (orientation === 'vertical') {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
if (onIncrement && !reverse) onIncrement();
|
|
107
|
+
else if (onDecrement && reverse) onDecrement();
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case 'Home':
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
if (onDecrementToMin) onDecrementToMin();
|
|
113
|
+
break;
|
|
114
|
+
case 'End':
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
if (onIncrementToMax) onIncrementToMax();
|
|
117
|
+
break;
|
|
118
|
+
case 'Enter':
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
if (onCollapseToggle) onCollapseToggle();
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
onMouseDown: onMouseDown,
|
|
126
|
+
onMouseEnter: onMouseEnter,
|
|
127
|
+
onMouseOut: onMouseOut,
|
|
128
|
+
onKeyDown: onKeyDown
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
export {$9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D};
|
|
134
|
+
//# sourceMappingURL=useDrag1D.module.js.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {getOffset as $ab71dadb03a6fb2e$export$622cea445a1c5b7d} from "./getOffset.module.js";
|
|
2
|
+
import {useRef as $1rnCS$useRef} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ /* eslint-disable rulesdir/pure-render */
|
|
15
|
+
|
|
16
|
+
// Keep track of elements that we are currently handling dragging for via useDrag1D.
|
|
17
|
+
// If there's an ancestor and a descendant both using useDrag1D(), and the user starts
|
|
18
|
+
// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.
|
|
19
|
+
const $9cc09df9fd7676be$var$draggingElements = [];
|
|
20
|
+
function $9cc09df9fd7676be$export$7bbed75feba39706(props) {
|
|
21
|
+
console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');
|
|
22
|
+
let { containerRef: containerRef, reverse: reverse, orientation: orientation, onHover: onHover, onDrag: onDrag, onPositionChange: onPositionChange, onIncrement: onIncrement, onDecrement: onDecrement, onIncrementToMax: onIncrementToMax, onDecrementToMin: onDecrementToMin, onCollapseToggle: onCollapseToggle } = props;
|
|
23
|
+
let getPosition = (e)=>orientation === 'horizontal' ? e.clientX : e.clientY;
|
|
24
|
+
let getNextOffset = (e)=>{
|
|
25
|
+
let containerOffset = (0, $ab71dadb03a6fb2e$export$622cea445a1c5b7d)(containerRef.current, reverse, orientation);
|
|
26
|
+
let mouseOffset = getPosition(e);
|
|
27
|
+
let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;
|
|
28
|
+
return nextOffset;
|
|
29
|
+
};
|
|
30
|
+
let dragging = (0, $1rnCS$useRef)(false);
|
|
31
|
+
let prevPosition = (0, $1rnCS$useRef)(0);
|
|
32
|
+
// Keep track of the current handlers in a ref so that the events can access them.
|
|
33
|
+
let handlers = (0, $1rnCS$useRef)({
|
|
34
|
+
onPositionChange: onPositionChange,
|
|
35
|
+
onDrag: onDrag
|
|
36
|
+
});
|
|
37
|
+
handlers.current.onDrag = onDrag;
|
|
38
|
+
handlers.current.onPositionChange = onPositionChange;
|
|
39
|
+
let onMouseDragged = (e)=>{
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
let nextOffset = getNextOffset(e);
|
|
42
|
+
if (!dragging.current) {
|
|
43
|
+
dragging.current = true;
|
|
44
|
+
if (handlers.current.onDrag) handlers.current.onDrag(true);
|
|
45
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
46
|
+
}
|
|
47
|
+
if (prevPosition.current === nextOffset) return;
|
|
48
|
+
prevPosition.current = nextOffset;
|
|
49
|
+
if (onPositionChange) onPositionChange(nextOffset);
|
|
50
|
+
};
|
|
51
|
+
let onMouseUp = (e)=>{
|
|
52
|
+
const target = e.target;
|
|
53
|
+
dragging.current = false;
|
|
54
|
+
let nextOffset = getNextOffset(e);
|
|
55
|
+
if (handlers.current.onDrag) handlers.current.onDrag(false);
|
|
56
|
+
if (handlers.current.onPositionChange) handlers.current.onPositionChange(nextOffset);
|
|
57
|
+
$9cc09df9fd7676be$var$draggingElements.splice($9cc09df9fd7676be$var$draggingElements.indexOf(target), 1);
|
|
58
|
+
window.removeEventListener('mouseup', onMouseUp, false);
|
|
59
|
+
window.removeEventListener('mousemove', onMouseDragged, false);
|
|
60
|
+
};
|
|
61
|
+
let onMouseDown = (e)=>{
|
|
62
|
+
const target = e.currentTarget;
|
|
63
|
+
// If we're already handling dragging on a descendant with useDrag1D, then
|
|
64
|
+
// we don't want to handle the drag motion on this target as well.
|
|
65
|
+
if ($9cc09df9fd7676be$var$draggingElements.some((elt)=>target.contains(elt))) return;
|
|
66
|
+
$9cc09df9fd7676be$var$draggingElements.push(target);
|
|
67
|
+
window.addEventListener('mousemove', onMouseDragged, false);
|
|
68
|
+
window.addEventListener('mouseup', onMouseUp, false);
|
|
69
|
+
};
|
|
70
|
+
let onMouseEnter = ()=>{
|
|
71
|
+
if (onHover) onHover(true);
|
|
72
|
+
};
|
|
73
|
+
let onMouseOut = ()=>{
|
|
74
|
+
if (onHover) onHover(false);
|
|
75
|
+
};
|
|
76
|
+
let onKeyDown = (e)=>{
|
|
77
|
+
switch(e.key){
|
|
78
|
+
case 'Left':
|
|
79
|
+
case 'ArrowLeft':
|
|
80
|
+
if (orientation === 'horizontal') {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
if (onDecrement && !reverse) onDecrement();
|
|
83
|
+
else if (onIncrement && reverse) onIncrement();
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case 'Up':
|
|
87
|
+
case 'ArrowUp':
|
|
88
|
+
if (orientation === 'vertical') {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
if (onDecrement && !reverse) onDecrement();
|
|
91
|
+
else if (onIncrement && reverse) onIncrement();
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'Right':
|
|
95
|
+
case 'ArrowRight':
|
|
96
|
+
if (orientation === 'horizontal') {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
if (onIncrement && !reverse) onIncrement();
|
|
99
|
+
else if (onDecrement && reverse) onDecrement();
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case 'Down':
|
|
103
|
+
case 'ArrowDown':
|
|
104
|
+
if (orientation === 'vertical') {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
if (onIncrement && !reverse) onIncrement();
|
|
107
|
+
else if (onDecrement && reverse) onDecrement();
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case 'Home':
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
if (onDecrementToMin) onDecrementToMin();
|
|
113
|
+
break;
|
|
114
|
+
case 'End':
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
if (onIncrementToMax) onIncrementToMax();
|
|
117
|
+
break;
|
|
118
|
+
case 'Enter':
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
if (onCollapseToggle) onCollapseToggle();
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return {
|
|
125
|
+
onMouseDown: onMouseDown,
|
|
126
|
+
onMouseEnter: onMouseEnter,
|
|
127
|
+
onMouseOut: onMouseOut,
|
|
128
|
+
onKeyDown: onKeyDown
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
export {$9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D};
|
|
134
|
+
//# sourceMappingURL=useDrag1D.module.js.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AAe,SACxB;gBAEJ;gBACA;YACF,KAAK;YACL,KAAK;gBACH,IAAI,gBAAgB,YAAY;oBAC9B,EAAE,cAAc;oBAChB,IAAI,eAAe,CAAC,SAClB;yBACK,IAAI,eAAe,SACxB;gBAEJ;gBACA;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,IAAI,kBACF;gBAEF;QACJ;IACF;IAEA,OAAO;qBAAC;sBAAa;oBAAc;mBAAY;IAAS;AAC1D","sources":["packages/@react-aria/utils/src/useDrag1D.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n /* eslint-disable rulesdir/pure-render */\n\nimport {getOffset} from './getOffset';\nimport {Orientation} from '@react-types/shared';\nimport React, {HTMLAttributes, MutableRefObject, useRef} from 'react';\n\ninterface UseDrag1DProps {\n containerRef: MutableRefObject<HTMLElement>,\n reverse?: boolean,\n orientation?: Orientation,\n onHover?: (hovered: boolean) => void,\n onDrag?: (dragging: boolean) => void,\n onPositionChange?: (position: number) => void,\n onIncrement?: () => void,\n onDecrement?: () => void,\n onIncrementToMax?: () => void,\n onDecrementToMin?: () => void,\n onCollapseToggle?: () => void\n}\n\n// Keep track of elements that we are currently handling dragging for via useDrag1D.\n// If there's an ancestor and a descendant both using useDrag1D(), and the user starts\n// dragging the descendant, we don't want useDrag1D events to fire for the ancestor.\nconst draggingElements: HTMLElement[] = [];\n\n// created for splitview, this should be reusable for things like sliders/dials\n// It also handles keyboard events on the target allowing for increment/decrement by a given stepsize as well as minifying/maximizing and toggling between minified and previous size\n// It can also take a 'reverse' param to say if we should measure from the right/bottom instead of the top/left\n// It can also handle either a vertical or horizontal movement, but not both at the same time\n\nexport function useDrag1D(props: UseDrag1DProps): HTMLAttributes<HTMLElement> {\n console.warn('useDrag1D is deprecated, please use `useMove` instead https://react-spectrum.adobe.com/react-aria/useMove.html');\n let {containerRef, reverse, orientation, onHover, onDrag, onPositionChange, onIncrement, onDecrement, onIncrementToMax, onDecrementToMin, onCollapseToggle} = props;\n let getPosition = (e) => orientation === 'horizontal' ? e.clientX : e.clientY;\n let getNextOffset = (e: MouseEvent) => {\n let containerOffset = getOffset(containerRef.current, reverse, orientation);\n let mouseOffset = getPosition(e);\n let nextOffset = reverse ? containerOffset - mouseOffset : mouseOffset - containerOffset;\n return nextOffset;\n };\n let dragging = useRef(false);\n let prevPosition = useRef(0);\n\n // Keep track of the current handlers in a ref so that the events can access them.\n let handlers = useRef({onPositionChange, onDrag});\n handlers.current.onDrag = onDrag;\n handlers.current.onPositionChange = onPositionChange;\n\n let onMouseDragged = (e: MouseEvent) => {\n e.preventDefault();\n let nextOffset = getNextOffset(e);\n if (!dragging.current) {\n dragging.current = true;\n if (handlers.current.onDrag) {\n handlers.current.onDrag(true);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n }\n if (prevPosition.current === nextOffset) {\n return;\n }\n prevPosition.current = nextOffset;\n if (onPositionChange) {\n onPositionChange(nextOffset);\n }\n };\n\n let onMouseUp = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n dragging.current = false;\n let nextOffset = getNextOffset(e);\n if (handlers.current.onDrag) {\n handlers.current.onDrag(false);\n }\n if (handlers.current.onPositionChange) {\n handlers.current.onPositionChange(nextOffset);\n }\n\n draggingElements.splice(draggingElements.indexOf(target), 1);\n window.removeEventListener('mouseup', onMouseUp, false);\n window.removeEventListener('mousemove', onMouseDragged, false);\n };\n\n let onMouseDown = (e: React.MouseEvent<HTMLElement>) => {\n const target = e.currentTarget;\n // If we're already handling dragging on a descendant with useDrag1D, then\n // we don't want to handle the drag motion on this target as well.\n if (draggingElements.some(elt => target.contains(elt))) {\n return;\n }\n draggingElements.push(target);\n window.addEventListener('mousemove', onMouseDragged, false);\n window.addEventListener('mouseup', onMouseUp, false);\n };\n\n let onMouseEnter = () => {\n if (onHover) {\n onHover(true);\n }\n };\n\n let onMouseOut = () => {\n if (onHover) {\n onHover(false);\n }\n };\n\n let onKeyDown = (e) => {\n switch (e.key) {\n case 'Left':\n case 'ArrowLeft':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Up':\n case 'ArrowUp':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onDecrement && !reverse) {\n onDecrement();\n } else if (onIncrement && reverse) {\n onIncrement();\n }\n }\n break;\n case 'Right':\n case 'ArrowRight':\n if (orientation === 'horizontal') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Down':\n case 'ArrowDown':\n if (orientation === 'vertical') {\n e.preventDefault();\n if (onIncrement && !reverse) {\n onIncrement();\n } else if (onDecrement && reverse) {\n onDecrement();\n }\n }\n break;\n case 'Home':\n e.preventDefault();\n if (onDecrementToMin) {\n onDecrementToMin();\n }\n break;\n case 'End':\n e.preventDefault();\n if (onIncrementToMax) {\n onIncrementToMax();\n }\n break;\n case 'Enter':\n e.preventDefault();\n if (onCollapseToggle) {\n onCollapseToggle();\n }\n break;\n }\n };\n\n return {onMouseDown, onMouseEnter, onMouseOut, onKeyDown};\n}\n"],"names":[],"version":3,"file":"useDrag1D.module.js.map"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");
|
|
2
|
+
var $gErir$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useEffectEvent", () => $1254e5bb94ac8761$export$7f54fc3180508a52);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) {
|
|
23
|
+
const ref = (0, $gErir$react.useRef)(null);
|
|
24
|
+
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{
|
|
25
|
+
ref.current = fn;
|
|
26
|
+
}, [
|
|
27
|
+
fn
|
|
28
|
+
]);
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
return (0, $gErir$react.useCallback)((...args)=>{
|
|
31
|
+
const f = ref.current;
|
|
32
|
+
return f === null || f === void 0 ? void 0 : f(...args);
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=useEffectEvent.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAKM,SAAS,0CAAmC,EAAM;IACvD,MAAM,MAAM,CAAA,GAAA,mBAAK,EAAwB;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,OAAO,GAAG;IAChB,GAAG;QAAC;KAAG;IACP,aAAa;IACb,OAAO,CAAA,GAAA,wBAAU,EAAK,CAAC,GAAG;QACxB,MAAM,IAAI,IAAI,OAAO;QACrB,OAAO,cAAA,wBAAA,KAAO;IAChB,GAAG,EAAE;AACP","sources":["packages/@react-aria/utils/src/useEffectEvent.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEffectEvent<T extends Function>(fn?: T): T {\n const ref = useRef<T | null | undefined>(null);\n useLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n // @ts-ignore\n return useCallback<T>((...args) => {\n const f = ref.current!;\n return f?.(...args);\n }, []);\n}\n"],"names":[],"version":3,"file":"useEffectEvent.main.js.map"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.mjs";
|
|
2
|
+
import {useRef as $lmaYr$useRef, useCallback as $lmaYr$useCallback} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
|
|
17
|
+
const ref = (0, $lmaYr$useRef)(null);
|
|
18
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
19
|
+
ref.current = fn;
|
|
20
|
+
}, [
|
|
21
|
+
fn
|
|
22
|
+
]);
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return (0, $lmaYr$useCallback)((...args)=>{
|
|
25
|
+
const f = ref.current;
|
|
26
|
+
return f === null || f === void 0 ? void 0 : f(...args);
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export {$8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent};
|
|
32
|
+
//# sourceMappingURL=useEffectEvent.module.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";
|
|
2
|
+
import {useRef as $lmaYr$useRef, useCallback as $lmaYr$useCallback} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
|
|
17
|
+
const ref = (0, $lmaYr$useRef)(null);
|
|
18
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
19
|
+
ref.current = fn;
|
|
20
|
+
}, [
|
|
21
|
+
fn
|
|
22
|
+
]);
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return (0, $lmaYr$useCallback)((...args)=>{
|
|
25
|
+
const f = ref.current;
|
|
26
|
+
return f === null || f === void 0 ? void 0 : f(...args);
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export {$8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent};
|
|
32
|
+
//# sourceMappingURL=useEffectEvent.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKM,SAAS,0CAAmC,EAAM;IACvD,MAAM,MAAM,CAAA,GAAA,aAAK,EAAwB;IACzC,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,OAAO,GAAG;IAChB,GAAG;QAAC;KAAG;IACP,aAAa;IACb,OAAO,CAAA,GAAA,kBAAU,EAAK,CAAC,GAAG;QACxB,MAAM,IAAI,IAAI,OAAO;QACrB,OAAO,cAAA,wBAAA,KAAO;IAChB,GAAG,EAAE;AACP","sources":["packages/@react-aria/utils/src/useEffectEvent.ts"],"sourcesContent":["/*\n * Copyright 2023 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCallback, useRef} from 'react';\nimport {useLayoutEffect} from './useLayoutEffect';\n\nexport function useEffectEvent<T extends Function>(fn?: T): T {\n const ref = useRef<T | null | undefined>(null);\n useLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n // @ts-ignore\n return useCallback<T>((...args) => {\n const f = ref.current!;\n return f?.(...args);\n }, []);\n}\n"],"names":[],"version":3,"file":"useEffectEvent.module.js.map"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js");
|
|
2
|
+
var $8UjJN$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useEvent", () => $2a8c0bb1629926c8$export$90fc3a17d93f704c);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
function $2a8c0bb1629926c8$export$90fc3a17d93f704c(ref, event, handler, options) {
|
|
23
|
+
let handleEvent = (0, $1254e5bb94ac8761$exports.useEffectEvent)(handler);
|
|
24
|
+
let isDisabled = handler == null;
|
|
25
|
+
(0, $8UjJN$react.useEffect)(()=>{
|
|
26
|
+
if (isDisabled || !ref.current) return;
|
|
27
|
+
let element = ref.current;
|
|
28
|
+
element.addEventListener(event, handleEvent, options);
|
|
29
|
+
return ()=>{
|
|
30
|
+
element.removeEventListener(event, handleEvent, options);
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
ref,
|
|
34
|
+
event,
|
|
35
|
+
options,
|
|
36
|
+
isDisabled,
|
|
37
|
+
handleEvent
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=useEvent.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAMM,SAAS,0CACd,GAAkC,EAClC,KAAwB,EACxB,OAAqE,EACrE,OAA2C;IAE3C,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;IACjC,IAAI,aAAa,WAAW;IAE5B,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,cAAc,CAAC,IAAI,OAAO,EAC5B;QAGF,IAAI,UAAU,IAAI,OAAO;QACzB,QAAQ,gBAAgB,CAAC,OAAO,aAA8B;QAC9D,OAAO;YACL,QAAQ,mBAAmB,CAAC,OAAO,aAA8B;QACnE;IACF,GAAG;QAAC;QAAK;QAAO;QAAS;QAAY;KAAY;AACnD","sources":["packages/@react-aria/utils/src/useEvent.ts"],"sourcesContent":["/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject} from '@react-types/shared';\nimport {useEffect} from 'react';\nimport {useEffectEvent} from './useEffectEvent';\n\nexport function useEvent<K extends keyof GlobalEventHandlersEventMap>(\n ref: RefObject<EventTarget | null>,\n event: K | (string & {}),\n handler?: (this: Document, ev: GlobalEventHandlersEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n let handleEvent = useEffectEvent(handler);\n let isDisabled = handler == null;\n\n useEffect(() => {\n if (isDisabled || !ref.current) {\n return;\n }\n\n let element = ref.current;\n element.addEventListener(event, handleEvent as EventListener, options);\n return () => {\n element.removeEventListener(event, handleEvent as EventListener, options);\n };\n }, [ref, event, options, isDisabled, handleEvent]);\n}\n"],"names":[],"version":3,"file":"useEvent.main.js.map"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.mjs";
|
|
2
|
+
import {useEffect as $ceQd6$useEffect} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
|
|
17
|
+
let handleEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(handler);
|
|
18
|
+
let isDisabled = handler == null;
|
|
19
|
+
(0, $ceQd6$useEffect)(()=>{
|
|
20
|
+
if (isDisabled || !ref.current) return;
|
|
21
|
+
let element = ref.current;
|
|
22
|
+
element.addEventListener(event, handleEvent, options);
|
|
23
|
+
return ()=>{
|
|
24
|
+
element.removeEventListener(event, handleEvent, options);
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
ref,
|
|
28
|
+
event,
|
|
29
|
+
options,
|
|
30
|
+
isDisabled,
|
|
31
|
+
handleEvent
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export {$e9faafb641e167db$export$90fc3a17d93f704c as useEvent};
|
|
37
|
+
//# sourceMappingURL=useEvent.module.js.map
|