@prom-ui/core 1.7.0-alpha.0 → 1.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Avatar/package.json +1 -1
- package/Backdrop/package.json +1 -1
- package/Body/package.json +1 -1
- package/BodyContext/package.json +1 -1
- package/BodyProvider/package.json +1 -1
- package/Box/package.json +1 -1
- package/Button/package.json +1 -1
- package/ButtonPageUp/package.json +1 -1
- package/Checkbox/package.json +1 -1
- package/Flex/package.json +1 -1
- package/Grid/package.json +1 -1
- package/Icon/package.json +1 -1
- package/Image/package.json +1 -1
- package/ImageEmoji/package.json +1 -1
- package/Input/package.json +1 -1
- package/InputField/package.json +1 -1
- package/KeyPress/package.json +1 -1
- package/Line/package.json +1 -1
- package/Link/package.json +1 -1
- package/List/package.json +1 -1
- package/Media/package.json +1 -1
- package/OutsideClick/package.json +1 -1
- package/Overlay/cjs/index.development.js +2 -3
- package/Overlay/cjs/index.development.v2.js +2 -3
- package/Overlay/cjs/index.production.js +1 -1
- package/Overlay/cjs/index.production.v2.js +1 -1
- package/Overlay/package.json +1 -1
- package/Picture/package.json +1 -1
- package/Portal/package.json +1 -1
- package/QRCode/package.json +1 -1
- package/Rating/package.json +1 -1
- package/RatingSelect/package.json +1 -1
- package/SafeQuery/package.json +1 -1
- package/Scroll/package.json +1 -1
- package/ScrollControls/package.json +1 -1
- package/ScrollLock/cjs/index.development.js +445 -18
- package/ScrollLock/cjs/index.development.v2.js +445 -18
- package/ScrollLock/cjs/index.production.js +1 -1
- package/ScrollLock/cjs/index.production.v2.js +1 -1
- package/ScrollLock/package.json +2 -5
- package/SimpleSlider/cjs/index.development.js +0 -1
- package/SimpleSlider/cjs/index.development.v2.js +0 -1
- package/SimpleSlider/cjs/index.production.js +1 -1
- package/SimpleSlider/cjs/index.production.v2.js +1 -1
- package/SimpleSlider/index.d.ts +0 -1
- package/SimpleSlider/package.json +1 -2
- package/Skeleton/package.json +1 -1
- package/Spinner/package.json +1 -1
- package/Text/package.json +1 -1
- package/TextEmoji/package.json +1 -1
- package/Tooltip/package.json +1 -1
- package/Tumbler/package.json +1 -1
- package/package.json +2 -3
- package/useBodyTTag/package.json +1 -1
- package/useDebounce/package.json +1 -1
- package/useId/package.json +1 -1
- package/useIsMounted/package.json +1 -1
- package/useKeyPress/package.json +1 -1
- package/useMedia/package.json +1 -1
- package/useOutsideClick/package.json +1 -1
- package/usePortal/package.json +1 -1
- package/useScrollPosition/package.json +1 -1
|
@@ -2,36 +2,463 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var reactAria = require('react-aria');
|
|
5
|
+
var $73SJx$react = require('react');
|
|
7
6
|
|
|
8
7
|
function _interopNamespaceCompat(e) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
}
|
|
8
|
+
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
20
17
|
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var $73SJx$react__namespace = /*#__PURE__*/_interopNamespaceCompat($73SJx$react);
|
|
26
|
+
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
28
|
+
if (!o) return;
|
|
29
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
30
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
32
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
33
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
34
|
+
}
|
|
35
|
+
function _arrayLikeToArray(arr, len) {
|
|
36
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
37
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
38
|
+
return arr2;
|
|
39
|
+
}
|
|
40
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
41
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
42
|
+
if (!it) {
|
|
43
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
44
|
+
if (it) o = it;
|
|
45
|
+
var i = 0;
|
|
46
|
+
var F = function () {};
|
|
47
|
+
return {
|
|
48
|
+
s: F,
|
|
49
|
+
n: function () {
|
|
50
|
+
if (i >= o.length) return {
|
|
51
|
+
done: true
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
done: false,
|
|
55
|
+
value: o[i++]
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
e: function (e) {
|
|
59
|
+
throw e;
|
|
60
|
+
},
|
|
61
|
+
f: F
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
+
}
|
|
66
|
+
var normalCompletion = true,
|
|
67
|
+
didErr = false,
|
|
68
|
+
err;
|
|
69
|
+
return {
|
|
70
|
+
s: function () {
|
|
71
|
+
it = it.call(o);
|
|
72
|
+
},
|
|
73
|
+
n: function () {
|
|
74
|
+
var step = it.next();
|
|
75
|
+
normalCompletion = step.done;
|
|
76
|
+
return step;
|
|
77
|
+
},
|
|
78
|
+
e: function (e) {
|
|
79
|
+
didErr = true;
|
|
80
|
+
err = e;
|
|
81
|
+
},
|
|
82
|
+
f: function () {
|
|
83
|
+
try {
|
|
84
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
85
|
+
} finally {
|
|
86
|
+
if (didErr) throw err;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
94
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
95
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
96
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
97
|
+
*
|
|
98
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
99
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
100
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
101
|
+
* governing permissions and limitations under the License.
|
|
102
|
+
*/ /*
|
|
103
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
104
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
105
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
106
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
107
|
+
*
|
|
108
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
109
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
110
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
111
|
+
* governing permissions and limitations under the License.
|
|
112
|
+
*/
|
|
113
|
+
/*
|
|
114
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
115
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
116
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
117
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
118
|
+
*
|
|
119
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
120
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
121
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
122
|
+
* governing permissions and limitations under the License.
|
|
123
|
+
*/
|
|
124
|
+
var $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof document !== "undefined" ? ($73SJx$react__namespace.default).useLayoutEffect : function () {};
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
128
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
129
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
130
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
131
|
+
*
|
|
132
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
133
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
134
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
135
|
+
* governing permissions and limitations under the License.
|
|
136
|
+
*/ /**
|
|
137
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
138
|
+
*/
|
|
139
|
+
function $ff5963eb1fccf552$export$e08e3b67e392101e() {
|
|
140
|
+
for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
141
|
+
callbacks[_key] = arguments[_key];
|
|
142
|
+
}
|
|
143
|
+
return function () {
|
|
144
|
+
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
145
|
+
var callback = _callbacks[_i];
|
|
146
|
+
if (typeof callback === "function") callback.apply(void 0, arguments);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
153
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
154
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
155
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
156
|
+
*
|
|
157
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
158
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
159
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
160
|
+
* governing permissions and limitations under the License.
|
|
161
|
+
*/ // We store a global list of elements that are currently transitioning,
|
|
162
|
+
// mapped to a set of CSS properties that are transitioning for that element.
|
|
163
|
+
// This is necessary rather than a simple count of transitions because of browser
|
|
164
|
+
// bugs, e.g. Chrome sometimes fires both transitionend and transitioncancel rather
|
|
165
|
+
// than one or the other. So we need to track what's actually transitioning so that
|
|
166
|
+
// we can ignore these duplicate events.
|
|
167
|
+
var $bbed8b41f857bcc0$var$transitionsByElement = new Map();
|
|
168
|
+
// A list of callbacks to call once there are no transitioning elements.
|
|
169
|
+
var $bbed8b41f857bcc0$var$transitionCallbacks = new Set();
|
|
170
|
+
function $bbed8b41f857bcc0$var$setupGlobalEvents() {
|
|
171
|
+
if (typeof window === "undefined") return;
|
|
172
|
+
var onTransitionStart = function onTransitionStart(e) {
|
|
173
|
+
// Add the transitioning property to the list for this element.
|
|
174
|
+
var transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
|
175
|
+
if (!transitions) {
|
|
176
|
+
transitions = new Set();
|
|
177
|
+
$bbed8b41f857bcc0$var$transitionsByElement.set(e.target, transitions);
|
|
178
|
+
// The transitioncancel event must be registered on the element itself, rather than as a global
|
|
179
|
+
// event. This enables us to handle when the node is deleted from the document while it is transitioning.
|
|
180
|
+
// In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
|
|
181
|
+
e.target.addEventListener("transitioncancel", onTransitionEnd);
|
|
182
|
+
}
|
|
183
|
+
transitions.add(e.propertyName);
|
|
184
|
+
};
|
|
185
|
+
var onTransitionEnd = function onTransitionEnd(e) {
|
|
186
|
+
// Remove property from list of transitioning properties.
|
|
187
|
+
var properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
|
188
|
+
if (!properties) return;
|
|
189
|
+
properties["delete"](e.propertyName);
|
|
190
|
+
// If empty, remove transitioncancel event, and remove the element from the list of transitioning elements.
|
|
191
|
+
if (properties.size === 0) {
|
|
192
|
+
e.target.removeEventListener("transitioncancel", onTransitionEnd);
|
|
193
|
+
$bbed8b41f857bcc0$var$transitionsByElement["delete"](e.target);
|
|
21
194
|
}
|
|
22
|
-
|
|
23
|
-
|
|
195
|
+
// If no transitioning elements, call all of the queued callbacks.
|
|
196
|
+
if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) {
|
|
197
|
+
var _iterator2 = _createForOfIteratorHelper($bbed8b41f857bcc0$var$transitionCallbacks),
|
|
198
|
+
_step2;
|
|
199
|
+
try {
|
|
200
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
201
|
+
var cb = _step2.value;
|
|
202
|
+
cb();
|
|
203
|
+
}
|
|
204
|
+
} catch (err) {
|
|
205
|
+
_iterator2.e(err);
|
|
206
|
+
} finally {
|
|
207
|
+
_iterator2.f();
|
|
208
|
+
}
|
|
209
|
+
$bbed8b41f857bcc0$var$transitionCallbacks.clear();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
document.body.addEventListener("transitionrun", onTransitionStart);
|
|
213
|
+
document.body.addEventListener("transitionend", onTransitionEnd);
|
|
214
|
+
}
|
|
215
|
+
if (typeof document !== "undefined") {
|
|
216
|
+
if (document.readyState !== "loading") $bbed8b41f857bcc0$var$setupGlobalEvents();else document.addEventListener("DOMContentLoaded", $bbed8b41f857bcc0$var$setupGlobalEvents);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/*
|
|
220
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
221
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
222
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
223
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
224
|
+
*
|
|
225
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
226
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
227
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
228
|
+
* governing permissions and limitations under the License.
|
|
229
|
+
*/
|
|
230
|
+
function $62d8ded9296f3872$export$cfa2225e87938781(node) {
|
|
231
|
+
if ($62d8ded9296f3872$export$2bb74740c4e19def(node)) node = node.parentElement;
|
|
232
|
+
while (node && !$62d8ded9296f3872$export$2bb74740c4e19def(node)) node = node.parentElement;
|
|
233
|
+
return node || document.scrollingElement || document.documentElement;
|
|
234
|
+
}
|
|
235
|
+
function $62d8ded9296f3872$export$2bb74740c4e19def(node) {
|
|
236
|
+
var style = window.getComputedStyle(node);
|
|
237
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
238
|
+
}
|
|
239
|
+
function $c87311424ea30a05$var$testPlatform(re) {
|
|
240
|
+
var _window_navigator_userAgentData;
|
|
241
|
+
return typeof window !== "undefined" && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator["userAgentData"]) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
|
|
242
|
+
}
|
|
243
|
+
function $c87311424ea30a05$export$9ac100e40613ea10() {
|
|
244
|
+
return $c87311424ea30a05$var$testPlatform(/^Mac/i);
|
|
245
|
+
}
|
|
246
|
+
function $c87311424ea30a05$export$186c6964ca17d99() {
|
|
247
|
+
return $c87311424ea30a05$var$testPlatform(/^iPhone/i);
|
|
248
|
+
}
|
|
249
|
+
function $c87311424ea30a05$export$7bef049ce92e4224() {
|
|
250
|
+
return $c87311424ea30a05$var$testPlatform(/^iPad/i) ||
|
|
251
|
+
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
252
|
+
$c87311424ea30a05$export$9ac100e40613ea10() && navigator.maxTouchPoints > 1;
|
|
253
|
+
}
|
|
254
|
+
function $c87311424ea30a05$export$fedb369cb70207f1() {
|
|
255
|
+
return $c87311424ea30a05$export$186c6964ca17d99() || $c87311424ea30a05$export$7bef049ce92e4224();
|
|
24
256
|
}
|
|
25
257
|
|
|
26
|
-
|
|
258
|
+
/*
|
|
259
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
260
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
261
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
262
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
265
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
266
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
267
|
+
* governing permissions and limitations under the License.
|
|
268
|
+
*/
|
|
269
|
+
// @ts-ignore
|
|
270
|
+
var $49c51c25361d4cd2$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
|
|
271
|
+
// HTML input types that do not cause the software keyboard to appear.
|
|
272
|
+
var $49c51c25361d4cd2$var$nonTextInputTypes = new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
|
|
273
|
+
// The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
|
|
274
|
+
var $49c51c25361d4cd2$var$preventScrollCount = 0;
|
|
275
|
+
var $49c51c25361d4cd2$var$restore;
|
|
276
|
+
function $49c51c25361d4cd2$export$ee0f7cc6afcd1c18() {
|
|
277
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
278
|
+
var isDisabled = options.isDisabled;
|
|
279
|
+
($f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(function () {
|
|
280
|
+
if (isDisabled) return;
|
|
281
|
+
$49c51c25361d4cd2$var$preventScrollCount++;
|
|
282
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 1) {
|
|
283
|
+
if (($c87311424ea30a05$export$fedb369cb70207f1)()) $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollMobileSafari();else $49c51c25361d4cd2$var$restore = $49c51c25361d4cd2$var$preventScrollStandard();
|
|
284
|
+
}
|
|
285
|
+
return function () {
|
|
286
|
+
$49c51c25361d4cd2$var$preventScrollCount--;
|
|
287
|
+
if ($49c51c25361d4cd2$var$preventScrollCount === 0) $49c51c25361d4cd2$var$restore();
|
|
288
|
+
};
|
|
289
|
+
}, [isDisabled]);
|
|
290
|
+
}
|
|
291
|
+
// For most browsers, all we need to do is set `overflow: hidden` on the root element, and
|
|
292
|
+
// add some padding to prevent the page from shifting when the scrollbar is hidden.
|
|
293
|
+
function $49c51c25361d4cd2$var$preventScrollStandard() {
|
|
294
|
+
return ($ff5963eb1fccf552$export$e08e3b67e392101e)($49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", "".concat(window.innerWidth - document.documentElement.clientWidth, "px")), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"));
|
|
295
|
+
}
|
|
296
|
+
// Mobile Safari is a whole different beast. Even with overflow: hidden,
|
|
297
|
+
// it still scrolls the page in many situations:
|
|
298
|
+
//
|
|
299
|
+
// 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
|
|
300
|
+
// 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
|
|
301
|
+
// it, so it becomes scrollable.
|
|
302
|
+
// 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
|
|
303
|
+
// This may cause even fixed position elements to scroll off the screen.
|
|
304
|
+
// 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
|
|
305
|
+
// scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
|
|
306
|
+
//
|
|
307
|
+
// In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
|
|
308
|
+
//
|
|
309
|
+
// 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
|
|
310
|
+
// on the window.
|
|
311
|
+
// 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
|
|
312
|
+
// top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
|
|
313
|
+
// 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
|
|
314
|
+
// 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
|
|
315
|
+
// of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
|
|
316
|
+
// into view ourselves, without scrolling the whole page.
|
|
317
|
+
// 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
|
|
318
|
+
// same visually, but makes the actual scroll position always zero. This is required to make all of the
|
|
319
|
+
// above work or Safari will still try to scroll the page when focusing an input.
|
|
320
|
+
// 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
|
|
321
|
+
// to navigate to an input with the next/previous buttons that's outside a modal.
|
|
322
|
+
function $49c51c25361d4cd2$var$preventScrollMobileSafari() {
|
|
323
|
+
var scrollable;
|
|
324
|
+
var lastY = 0;
|
|
325
|
+
var onTouchStart = function onTouchStart(e) {
|
|
326
|
+
// Store the nearest scrollable parent element from the element that the user touched.
|
|
327
|
+
scrollable = ($62d8ded9296f3872$export$cfa2225e87938781)(e.target);
|
|
328
|
+
if (scrollable === document.documentElement && scrollable === document.body) return;
|
|
329
|
+
lastY = e.changedTouches[0].pageY;
|
|
330
|
+
};
|
|
331
|
+
var onTouchMove = function onTouchMove(e) {
|
|
332
|
+
// Prevent scrolling the window.
|
|
333
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
// Prevent scrolling up when at the top and scrolling down when at the bottom
|
|
338
|
+
// of a nested scrollable area, otherwise mobile Safari will start scrolling
|
|
339
|
+
// the window instead. Unfortunately, this disables bounce scrolling when at
|
|
340
|
+
// the top but it's the best we can do.
|
|
341
|
+
var y = e.changedTouches[0].pageY;
|
|
342
|
+
var scrollTop = scrollable.scrollTop;
|
|
343
|
+
var bottom = scrollable.scrollHeight - scrollable.clientHeight;
|
|
344
|
+
if (bottom === 0) return;
|
|
345
|
+
if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) e.preventDefault();
|
|
346
|
+
lastY = y;
|
|
347
|
+
};
|
|
348
|
+
var onTouchEnd = function onTouchEnd(e) {
|
|
349
|
+
var target = e.target;
|
|
350
|
+
// Apply this change if we're not already focused on the target element
|
|
351
|
+
if ($49c51c25361d4cd2$var$willOpenKeyboard(target) && target !== document.activeElement) {
|
|
352
|
+
e.preventDefault();
|
|
353
|
+
// Apply a transform to trick Safari into thinking the input is at the top of the page
|
|
354
|
+
// so it doesn't try to scroll it into view. When tapping on an input, this needs to
|
|
355
|
+
// be done before the "focus" event, so we have to focus the element ourselves.
|
|
356
|
+
target.style.transform = "translateY(-2000px)";
|
|
357
|
+
target.focus();
|
|
358
|
+
requestAnimationFrame(function () {
|
|
359
|
+
target.style.transform = "";
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var onFocus = function onFocus(e) {
|
|
364
|
+
var target = e.target;
|
|
365
|
+
if ($49c51c25361d4cd2$var$willOpenKeyboard(target)) {
|
|
366
|
+
// Transform also needs to be applied in the focus event in cases where focus moves
|
|
367
|
+
// other than tapping on an input directly, e.g. the next/previous buttons in the
|
|
368
|
+
// software keyboard. In these cases, it seems applying the transform in the focus event
|
|
369
|
+
// is good enough, whereas when tapping an input, it must be done before the focus event. 🤷♂️
|
|
370
|
+
target.style.transform = "translateY(-2000px)";
|
|
371
|
+
requestAnimationFrame(function () {
|
|
372
|
+
target.style.transform = "";
|
|
373
|
+
// This will have prevented the browser from scrolling the focused element into view,
|
|
374
|
+
// so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
|
|
375
|
+
if ($49c51c25361d4cd2$var$visualViewport) {
|
|
376
|
+
if ($49c51c25361d4cd2$var$visualViewport.height < window.innerHeight)
|
|
377
|
+
// If the keyboard is already visible, do this after one additional frame
|
|
378
|
+
// to wait for the transform to be removed.
|
|
379
|
+
requestAnimationFrame(function () {
|
|
380
|
+
$49c51c25361d4cd2$var$scrollIntoView(target);
|
|
381
|
+
});else
|
|
382
|
+
// Otherwise, wait for the visual viewport to resize before scrolling so we can
|
|
383
|
+
// measure the correct position to scroll to.
|
|
384
|
+
$49c51c25361d4cd2$var$visualViewport.addEventListener("resize", function () {
|
|
385
|
+
return $49c51c25361d4cd2$var$scrollIntoView(target);
|
|
386
|
+
}, {
|
|
387
|
+
once: true
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
var onWindowScroll = function onWindowScroll() {
|
|
394
|
+
// Last resort. If the window scrolled, scroll it back to the top.
|
|
395
|
+
// It should always be at the top because the body will have a negative margin (see below).
|
|
396
|
+
window.scrollTo(0, 0);
|
|
397
|
+
};
|
|
398
|
+
// Record the original scroll position so we can restore it.
|
|
399
|
+
// Then apply a negative margin to the body to offset it by the scroll position. This will
|
|
400
|
+
// enable us to scroll the window to the top, which is required for the rest of this to work.
|
|
401
|
+
var scrollX = window.pageXOffset;
|
|
402
|
+
var scrollY = window.pageYOffset;
|
|
403
|
+
var restoreStyles = ($ff5963eb1fccf552$export$e08e3b67e392101e)($49c51c25361d4cd2$var$setStyle(document.documentElement, "paddingRight", "".concat(window.innerWidth - document.documentElement.clientWidth, "px")), $49c51c25361d4cd2$var$setStyle(document.documentElement, "overflow", "hidden"), $49c51c25361d4cd2$var$setStyle(document.body, "marginTop", "-".concat(scrollY, "px")));
|
|
404
|
+
// Scroll to the top. The negative margin on the body will make this appear the same.
|
|
405
|
+
window.scrollTo(0, 0);
|
|
406
|
+
var removeEvents = ($ff5963eb1fccf552$export$e08e3b67e392101e)($49c51c25361d4cd2$var$addEvent(document, "touchstart", onTouchStart, {
|
|
407
|
+
passive: false,
|
|
408
|
+
capture: true
|
|
409
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "touchmove", onTouchMove, {
|
|
410
|
+
passive: false,
|
|
411
|
+
capture: true
|
|
412
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "touchend", onTouchEnd, {
|
|
413
|
+
passive: false,
|
|
414
|
+
capture: true
|
|
415
|
+
}), $49c51c25361d4cd2$var$addEvent(document, "focus", onFocus, true), $49c51c25361d4cd2$var$addEvent(window, "scroll", onWindowScroll));
|
|
416
|
+
return function () {
|
|
417
|
+
// Restore styles and scroll the page back to where it was.
|
|
418
|
+
restoreStyles();
|
|
419
|
+
removeEvents();
|
|
420
|
+
window.scrollTo(scrollX, scrollY);
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
// Sets a CSS property on an element, and returns a function to revert it to the previous value.
|
|
424
|
+
function $49c51c25361d4cd2$var$setStyle(element, style, value) {
|
|
425
|
+
var cur = element.style[style];
|
|
426
|
+
element.style[style] = value;
|
|
427
|
+
return function () {
|
|
428
|
+
element.style[style] = cur;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
// Adds an event listener to an element, and returns a function to remove it.
|
|
432
|
+
function $49c51c25361d4cd2$var$addEvent(target, event, handler, options) {
|
|
433
|
+
target.addEventListener(event, handler, options);
|
|
434
|
+
return function () {
|
|
435
|
+
target.removeEventListener(event, handler, options);
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function $49c51c25361d4cd2$var$scrollIntoView(target) {
|
|
439
|
+
var root = document.scrollingElement || document.documentElement;
|
|
440
|
+
while (target && target !== root) {
|
|
441
|
+
// Find the parent scrollable element and adjust the scroll position if the target is not already in view.
|
|
442
|
+
var scrollable = ($62d8ded9296f3872$export$cfa2225e87938781)(target);
|
|
443
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
|
|
444
|
+
var scrollableTop = scrollable.getBoundingClientRect().top;
|
|
445
|
+
var targetTop = target.getBoundingClientRect().top;
|
|
446
|
+
if (targetTop > scrollableTop + target.clientHeight) scrollable.scrollTop += targetTop - scrollableTop;
|
|
447
|
+
}
|
|
448
|
+
target = scrollable.parentElement;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function $49c51c25361d4cd2$var$willOpenKeyboard(target) {
|
|
452
|
+
return target instanceof HTMLInputElement && !$49c51c25361d4cd2$var$nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
|
|
453
|
+
}
|
|
27
454
|
|
|
28
455
|
var ScrollLock = function ScrollLock(_ref) {
|
|
29
456
|
var _ref$isActive = _ref.isActive,
|
|
30
457
|
isActive = _ref$isActive === void 0 ? true : _ref$isActive;
|
|
31
|
-
|
|
458
|
+
$49c51c25361d4cd2$export$ee0f7cc6afcd1c18({
|
|
32
459
|
isDisabled: !isActive
|
|
33
460
|
});
|
|
34
|
-
return /*#__PURE__
|
|
461
|
+
return /*#__PURE__*/$73SJx$react__namespace.createElement($73SJx$react__namespace.Fragment, null);
|
|
35
462
|
};
|
|
36
463
|
|
|
37
464
|
exports.ScrollLock = ScrollLock;
|