@react-aria/utils 3.19.0 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +40 -57
- package/dist/main.js +40 -57
- package/dist/main.js.map +1 -1
- package/dist/module.js +40 -57
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/isVirtualEvent.ts +1 -1
- package/src/useValueEffect.ts +20 -27
package/dist/import.mjs
CHANGED
|
@@ -50,51 +50,59 @@ const $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== "undefined
|
|
|
50
50
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
51
51
|
* governing permissions and limitations under the License.
|
|
52
52
|
*/
|
|
53
|
+
/*
|
|
54
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
55
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
56
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
57
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
58
|
+
*
|
|
59
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
60
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
61
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
62
|
+
* governing permissions and limitations under the License.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
|
|
66
|
+
const ref = (0, $12uGp$useRef)(null);
|
|
67
|
+
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
68
|
+
ref.current = fn;
|
|
69
|
+
}, [
|
|
70
|
+
fn
|
|
71
|
+
]);
|
|
72
|
+
return (0, $12uGp$useCallback)((...args)=>{
|
|
73
|
+
const f = ref.current;
|
|
74
|
+
return f(...args);
|
|
75
|
+
}, []);
|
|
76
|
+
}
|
|
77
|
+
|
|
53
78
|
|
|
54
79
|
function $1dbecbe27a04f9af$export$14d238f342723f25(defaultValue) {
|
|
55
80
|
let [value, setValue] = (0, $12uGp$useState)(defaultValue);
|
|
56
|
-
let valueRef = (0, $12uGp$useRef)(value);
|
|
57
81
|
let effect = (0, $12uGp$useRef)(null);
|
|
58
|
-
//
|
|
59
|
-
|
|
82
|
+
// Store the function in a ref so we can always access the current version
|
|
83
|
+
// which has the proper `value` in scope.
|
|
84
|
+
let nextRef = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(()=>{
|
|
60
85
|
// Run the generator to the next yield.
|
|
61
86
|
let newValue = effect.current.next();
|
|
62
|
-
while(!newValue.done && valueRef.current === newValue.value)// If the value is the same as the current value,
|
|
63
|
-
// then continue to the next yield. Otherwise,
|
|
64
|
-
// set the value in state and wait for the next layout effect.
|
|
65
|
-
newValue = effect.current.next();
|
|
66
87
|
// If the generator is done, reset the effect.
|
|
67
88
|
if (newValue.done) {
|
|
68
89
|
effect.current = null;
|
|
69
90
|
return;
|
|
70
91
|
}
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
setValue(newValue.value);
|
|
76
|
-
|
|
77
|
-
// this list of dependencies is stable, setState and refs never change after first render.
|
|
78
|
-
}, [
|
|
79
|
-
setValue,
|
|
80
|
-
valueRef,
|
|
81
|
-
effect
|
|
82
|
-
]);
|
|
92
|
+
// If the value is the same as the current value,
|
|
93
|
+
// then continue to the next yield. Otherwise,
|
|
94
|
+
// set the value in state and wait for the next layout effect.
|
|
95
|
+
if (value === newValue.value) nextRef();
|
|
96
|
+
else setValue(newValue.value);
|
|
97
|
+
});
|
|
83
98
|
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
84
99
|
// If there is an effect currently running, continue to the next yield.
|
|
85
|
-
if (effect.current)
|
|
100
|
+
if (effect.current) nextRef();
|
|
101
|
+
});
|
|
102
|
+
let queue = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)((fn)=>{
|
|
103
|
+
effect.current = fn(value);
|
|
104
|
+
nextRef();
|
|
86
105
|
});
|
|
87
|
-
// queue must be a stable function, much like setState.
|
|
88
|
-
let queue = (0, $12uGp$useCallback)((fn)=>{
|
|
89
|
-
effect.current = fn(valueRef.current);
|
|
90
|
-
nextIter();
|
|
91
|
-
// this list of dependencies is stable, setState and refs never change after first render.
|
|
92
|
-
// in addition, nextIter is stable as outlined above
|
|
93
|
-
}, [
|
|
94
|
-
nextIter,
|
|
95
|
-
effect,
|
|
96
|
-
valueRef
|
|
97
|
-
]);
|
|
98
106
|
return [
|
|
99
107
|
value,
|
|
100
108
|
queue
|
|
@@ -920,31 +928,6 @@ function $c87311424ea30a05$export$a11b0059900ceec8() {
|
|
|
920
928
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
921
929
|
* governing permissions and limitations under the License.
|
|
922
930
|
*/
|
|
923
|
-
/*
|
|
924
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
925
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
926
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
927
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
928
|
-
*
|
|
929
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
930
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
931
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
932
|
-
* governing permissions and limitations under the License.
|
|
933
|
-
*/
|
|
934
|
-
|
|
935
|
-
function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) {
|
|
936
|
-
const ref = (0, $12uGp$useRef)(null);
|
|
937
|
-
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{
|
|
938
|
-
ref.current = fn;
|
|
939
|
-
}, [
|
|
940
|
-
fn
|
|
941
|
-
]);
|
|
942
|
-
return (0, $12uGp$useCallback)((...args)=>{
|
|
943
|
-
const f = ref.current;
|
|
944
|
-
return f(...args);
|
|
945
|
-
}, []);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
931
|
|
|
949
932
|
function $e9faafb641e167db$export$90fc3a17d93f704c(ref, event, handler, options) {
|
|
950
933
|
let handleEvent = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(handler);
|
|
@@ -1085,7 +1068,7 @@ function $6a7db85432448f7f$export$29bf1b5f2c56cf63(event) {
|
|
|
1085
1068
|
// Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
|
|
1086
1069
|
// instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
|
|
1087
1070
|
// Talkback double tap from Windows Firefox touch screen press
|
|
1088
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse";
|
|
1071
|
+
return !(0, $c87311424ea30a05$export$a11b0059900ceec8)() && event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse";
|
|
1089
1072
|
}
|
|
1090
1073
|
|
|
1091
1074
|
|
package/dist/main.js
CHANGED
|
@@ -98,51 +98,59 @@ const $78605a5d7424e31b$export$e5c5a5f917a5871c = typeof document !== "undefined
|
|
|
98
98
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
99
99
|
* governing permissions and limitations under the License.
|
|
100
100
|
*/
|
|
101
|
+
/*
|
|
102
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
103
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
104
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
105
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
106
|
+
*
|
|
107
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
108
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
109
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
110
|
+
* governing permissions and limitations under the License.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) {
|
|
114
|
+
const ref = (0, $1Yh1N$react.useRef)(null);
|
|
115
|
+
(0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
|
|
116
|
+
ref.current = fn;
|
|
117
|
+
}, [
|
|
118
|
+
fn
|
|
119
|
+
]);
|
|
120
|
+
return (0, $1Yh1N$react.useCallback)((...args)=>{
|
|
121
|
+
const f = ref.current;
|
|
122
|
+
return f(...args);
|
|
123
|
+
}, []);
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
|
|
102
127
|
function $19a2307bfabafaf1$export$14d238f342723f25(defaultValue) {
|
|
103
128
|
let [value, setValue] = (0, $1Yh1N$react.useState)(defaultValue);
|
|
104
|
-
let valueRef = (0, $1Yh1N$react.useRef)(value);
|
|
105
129
|
let effect = (0, $1Yh1N$react.useRef)(null);
|
|
106
|
-
//
|
|
107
|
-
|
|
130
|
+
// Store the function in a ref so we can always access the current version
|
|
131
|
+
// which has the proper `value` in scope.
|
|
132
|
+
let nextRef = (0, $1254e5bb94ac8761$export$7f54fc3180508a52)(()=>{
|
|
108
133
|
// Run the generator to the next yield.
|
|
109
134
|
let newValue = effect.current.next();
|
|
110
|
-
while(!newValue.done && valueRef.current === newValue.value)// If the value is the same as the current value,
|
|
111
|
-
// then continue to the next yield. Otherwise,
|
|
112
|
-
// set the value in state and wait for the next layout effect.
|
|
113
|
-
newValue = effect.current.next();
|
|
114
135
|
// If the generator is done, reset the effect.
|
|
115
136
|
if (newValue.done) {
|
|
116
137
|
effect.current = null;
|
|
117
138
|
return;
|
|
118
139
|
}
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
setValue(newValue.value);
|
|
124
|
-
|
|
125
|
-
// this list of dependencies is stable, setState and refs never change after first render.
|
|
126
|
-
}, [
|
|
127
|
-
setValue,
|
|
128
|
-
valueRef,
|
|
129
|
-
effect
|
|
130
|
-
]);
|
|
140
|
+
// If the value is the same as the current value,
|
|
141
|
+
// then continue to the next yield. Otherwise,
|
|
142
|
+
// set the value in state and wait for the next layout effect.
|
|
143
|
+
if (value === newValue.value) nextRef();
|
|
144
|
+
else setValue(newValue.value);
|
|
145
|
+
});
|
|
131
146
|
(0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
|
|
132
147
|
// If there is an effect currently running, continue to the next yield.
|
|
133
|
-
if (effect.current)
|
|
148
|
+
if (effect.current) nextRef();
|
|
149
|
+
});
|
|
150
|
+
let queue = (0, $1254e5bb94ac8761$export$7f54fc3180508a52)((fn)=>{
|
|
151
|
+
effect.current = fn(value);
|
|
152
|
+
nextRef();
|
|
134
153
|
});
|
|
135
|
-
// queue must be a stable function, much like setState.
|
|
136
|
-
let queue = (0, $1Yh1N$react.useCallback)((fn)=>{
|
|
137
|
-
effect.current = fn(valueRef.current);
|
|
138
|
-
nextIter();
|
|
139
|
-
// this list of dependencies is stable, setState and refs never change after first render.
|
|
140
|
-
// in addition, nextIter is stable as outlined above
|
|
141
|
-
}, [
|
|
142
|
-
nextIter,
|
|
143
|
-
effect,
|
|
144
|
-
valueRef
|
|
145
|
-
]);
|
|
146
154
|
return [
|
|
147
155
|
value,
|
|
148
156
|
queue
|
|
@@ -968,31 +976,6 @@ function $9e20cff0af27e8cc$export$a11b0059900ceec8() {
|
|
|
968
976
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
969
977
|
* governing permissions and limitations under the License.
|
|
970
978
|
*/
|
|
971
|
-
/*
|
|
972
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
973
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
974
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
975
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
976
|
-
*
|
|
977
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
978
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
979
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
980
|
-
* governing permissions and limitations under the License.
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
|
-
function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) {
|
|
984
|
-
const ref = (0, $1Yh1N$react.useRef)(null);
|
|
985
|
-
(0, $78605a5d7424e31b$export$e5c5a5f917a5871c)(()=>{
|
|
986
|
-
ref.current = fn;
|
|
987
|
-
}, [
|
|
988
|
-
fn
|
|
989
|
-
]);
|
|
990
|
-
return (0, $1Yh1N$react.useCallback)((...args)=>{
|
|
991
|
-
const f = ref.current;
|
|
992
|
-
return f(...args);
|
|
993
|
-
}, []);
|
|
994
|
-
}
|
|
995
|
-
|
|
996
979
|
|
|
997
980
|
function $2a8c0bb1629926c8$export$90fc3a17d93f704c(ref, event, handler, options) {
|
|
998
981
|
let handleEvent = (0, $1254e5bb94ac8761$export$7f54fc3180508a52)(handler);
|
|
@@ -1133,7 +1116,7 @@ function $577e795361f19be9$export$29bf1b5f2c56cf63(event) {
|
|
|
1133
1116
|
// Cannot use "event.pressure === 0" as the sole check due to Safari pointer events always returning pressure === 0
|
|
1134
1117
|
// instead of .5, see https://bugs.webkit.org/show_bug.cgi?id=206216. event.pointerType === 'mouse' is to distingush
|
|
1135
1118
|
// Talkback double tap from Windows Firefox touch screen press
|
|
1136
|
-
return event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse";
|
|
1119
|
+
return !(0, $9e20cff0af27e8cc$export$a11b0059900ceec8)() && event.width === 0 && event.height === 0 || event.width === 1 && event.height === 1 && event.pressure === 0 && event.detail === 0 && event.pointerType === "mouse";
|
|
1137
1120
|
}
|
|
1138
1121
|
|
|
1139
1122
|
|