@ionic/core 7.3.4-dev.11694548895.1578981b → 7.3.4-dev.11694698515.1504c90b
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/components/input-shims.js +69 -2
- package/dist/cjs/{input-shims-93284c80.js → input-shims-5d7b09e8.js} +75 -8
- package/dist/cjs/ion-app_8.cjs.entry.js +1 -1
- package/dist/collection/utils/input-shims/hacks/scroll-assist.js +69 -2
- package/dist/docs.json +1 -1
- package/dist/esm/{input-shims-4f1b0af9.js → input-shims-451757bd.js} +69 -2
- package/dist/esm/ion-app_8.entry.js +1 -1
- package/dist/esm-es5/input-shims-451757bd.js +4 -0
- package/dist/esm-es5/ion-app_8.entry.js +1 -1
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-5e5c1e58.js +4 -0
- package/dist/ionic/p-9dc4d33e.system.js +4 -0
- package/dist/ionic/{p-fc991193.entry.js → p-bcabbf15.entry.js} +1 -1
- package/dist/ionic/p-c68a8814.system.js +1 -1
- package/dist/ionic/{p-d524e68b.system.entry.js → p-ccc90dcb.system.entry.js} +1 -1
- package/dist/types/utils/browser/index.d.ts +16 -1
- package/package.json +1 -1
- package/dist/esm-es5/input-shims-4f1b0af9.js +0 -4
- package/dist/ionic/p-1d4a4a94.system.js +0 -4
- package/dist/ionic/p-c4abd708.js +0 -4
|
@@ -253,6 +253,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
253
253
|
* Resize info is available on Capacitor 4+
|
|
254
254
|
*/
|
|
255
255
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
256
|
+
/**
|
|
257
|
+
* This tracks whether or not the keyboard has been
|
|
258
|
+
* presented for a single focused text field. Note
|
|
259
|
+
* that it does not track if the keyboard is open
|
|
260
|
+
* in general such as if the keyboard is open for
|
|
261
|
+
* a different focused text field.
|
|
262
|
+
*/
|
|
263
|
+
let hasKeyboardBeenPresentedForTextField = false;
|
|
256
264
|
/**
|
|
257
265
|
* When adding scroll padding we need to know
|
|
258
266
|
* how much of the viewport the keyboard obscures.
|
|
@@ -267,6 +275,61 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
267
275
|
* being scrolled more than it needs to.
|
|
268
276
|
*/
|
|
269
277
|
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
278
|
+
/**
|
|
279
|
+
* Scroll assist is run when a text field
|
|
280
|
+
* is focused. However, it may need to
|
|
281
|
+
* re-run when the keyboard size changes
|
|
282
|
+
* such that the text field is now hidden
|
|
283
|
+
* underneath the keyboard.
|
|
284
|
+
* This function re-runs scroll assist
|
|
285
|
+
* when that happens.
|
|
286
|
+
*
|
|
287
|
+
* One limitation of this is on a web browser
|
|
288
|
+
* where native keyboard APIs do not have cross-browser
|
|
289
|
+
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
290
|
+
* This means that if the keyboard changes but does not change
|
|
291
|
+
* geometry, then scroll assist will not re-run even if
|
|
292
|
+
* the user has scrolled the text field under the keyboard.
|
|
293
|
+
* This should not be a problem when running in Cordova/Capacitor
|
|
294
|
+
* because `ionKeyboardDidShow` uses the native events
|
|
295
|
+
* which fire every time the keyboard changes.
|
|
296
|
+
*/
|
|
297
|
+
const keyboardShow = (ev) => {
|
|
298
|
+
/**
|
|
299
|
+
* If the keyboard has not yet been presented
|
|
300
|
+
* for this text field then the text field has just
|
|
301
|
+
* received focus. In that case, the focusin listener
|
|
302
|
+
* will run scroll assist.
|
|
303
|
+
*/
|
|
304
|
+
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
305
|
+
hasKeyboardBeenPresentedForTextField = true;
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Otherwise, the keyboard has already been presented
|
|
310
|
+
* for the focused text field.
|
|
311
|
+
* This means that the keyboard likely changed
|
|
312
|
+
* geometry, and we need to re-run scroll assist.
|
|
313
|
+
* This can happen when the user rotates their device
|
|
314
|
+
* or when they switch keyboards.
|
|
315
|
+
*
|
|
316
|
+
* Make sure we pass in the computed keyboard height
|
|
317
|
+
* rather than the estimated keyboard height.
|
|
318
|
+
*
|
|
319
|
+
* Since the keyboard is already open then we do not
|
|
320
|
+
* need to wait for the webview to resize, so we pass
|
|
321
|
+
* "waitForResize: false".
|
|
322
|
+
*/
|
|
323
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, platformHeight, false);
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Reset the internal state when the text field loses focus.
|
|
327
|
+
*/
|
|
328
|
+
const focusOut = () => {
|
|
329
|
+
hasKeyboardBeenPresentedForTextField = false;
|
|
330
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
331
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
332
|
+
};
|
|
270
333
|
/**
|
|
271
334
|
* When the input is about to receive
|
|
272
335
|
* focus, we need to move it to prevent
|
|
@@ -284,10 +347,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
284
347
|
return;
|
|
285
348
|
}
|
|
286
349
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
350
|
+
win === null || win === void 0 ? void 0 : win.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
351
|
+
componentEl.addEventListener('focusout', focusOut, true);
|
|
287
352
|
};
|
|
288
353
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
289
354
|
return () => {
|
|
290
355
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
356
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
357
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
291
358
|
};
|
|
292
359
|
};
|
|
293
360
|
/**
|
|
@@ -306,7 +373,7 @@ const setManualFocus = (el) => {
|
|
|
306
373
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
307
374
|
el.focus();
|
|
308
375
|
};
|
|
309
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
376
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0, waitForResize = true) => {
|
|
310
377
|
if (!contentEl && !footerEl) {
|
|
311
378
|
return;
|
|
312
379
|
}
|
|
@@ -397,7 +464,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
397
464
|
* bandwidth to become available.
|
|
398
465
|
*/
|
|
399
466
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
400
|
-
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
467
|
+
if (waitForResize && scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
401
468
|
/**
|
|
402
469
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
403
470
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
const index = require('./index-10873539.js');
|
|
6
|
+
const index$1 = require('./index-10873539.js');
|
|
7
7
|
const helpers = require('./helpers-ea4ccbcb.js');
|
|
8
8
|
const keyboard = require('./keyboard-fd7db491.js');
|
|
9
|
-
const index
|
|
9
|
+
const index = require('./index-306a7476.js');
|
|
10
10
|
require('./index-cc7dfb7c.js');
|
|
11
11
|
require('./capacitor-2ffba62a.js');
|
|
12
12
|
|
|
@@ -257,6 +257,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
257
257
|
* Resize info is available on Capacitor 4+
|
|
258
258
|
*/
|
|
259
259
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === keyboard.KeyboardResize.None);
|
|
260
|
+
/**
|
|
261
|
+
* This tracks whether or not the keyboard has been
|
|
262
|
+
* presented for a single focused text field. Note
|
|
263
|
+
* that it does not track if the keyboard is open
|
|
264
|
+
* in general such as if the keyboard is open for
|
|
265
|
+
* a different focused text field.
|
|
266
|
+
*/
|
|
267
|
+
let hasKeyboardBeenPresentedForTextField = false;
|
|
260
268
|
/**
|
|
261
269
|
* When adding scroll padding we need to know
|
|
262
270
|
* how much of the viewport the keyboard obscures.
|
|
@@ -270,7 +278,62 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
270
278
|
* the keyboard height again. This will result in the input
|
|
271
279
|
* being scrolled more than it needs to.
|
|
272
280
|
*/
|
|
273
|
-
const platformHeight = index
|
|
281
|
+
const platformHeight = index.win !== undefined ? index.win.innerHeight : 0;
|
|
282
|
+
/**
|
|
283
|
+
* Scroll assist is run when a text field
|
|
284
|
+
* is focused. However, it may need to
|
|
285
|
+
* re-run when the keyboard size changes
|
|
286
|
+
* such that the text field is now hidden
|
|
287
|
+
* underneath the keyboard.
|
|
288
|
+
* This function re-runs scroll assist
|
|
289
|
+
* when that happens.
|
|
290
|
+
*
|
|
291
|
+
* One limitation of this is on a web browser
|
|
292
|
+
* where native keyboard APIs do not have cross-browser
|
|
293
|
+
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
294
|
+
* This means that if the keyboard changes but does not change
|
|
295
|
+
* geometry, then scroll assist will not re-run even if
|
|
296
|
+
* the user has scrolled the text field under the keyboard.
|
|
297
|
+
* This should not be a problem when running in Cordova/Capacitor
|
|
298
|
+
* because `ionKeyboardDidShow` uses the native events
|
|
299
|
+
* which fire every time the keyboard changes.
|
|
300
|
+
*/
|
|
301
|
+
const keyboardShow = (ev) => {
|
|
302
|
+
/**
|
|
303
|
+
* If the keyboard has not yet been presented
|
|
304
|
+
* for this text field then the text field has just
|
|
305
|
+
* received focus. In that case, the focusin listener
|
|
306
|
+
* will run scroll assist.
|
|
307
|
+
*/
|
|
308
|
+
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
309
|
+
hasKeyboardBeenPresentedForTextField = true;
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Otherwise, the keyboard has already been presented
|
|
314
|
+
* for the focused text field.
|
|
315
|
+
* This means that the keyboard likely changed
|
|
316
|
+
* geometry, and we need to re-run scroll assist.
|
|
317
|
+
* This can happen when the user rotates their device
|
|
318
|
+
* or when they switch keyboards.
|
|
319
|
+
*
|
|
320
|
+
* Make sure we pass in the computed keyboard height
|
|
321
|
+
* rather than the estimated keyboard height.
|
|
322
|
+
*
|
|
323
|
+
* Since the keyboard is already open then we do not
|
|
324
|
+
* need to wait for the webview to resize, so we pass
|
|
325
|
+
* "waitForResize: false".
|
|
326
|
+
*/
|
|
327
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, platformHeight, false);
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Reset the internal state when the text field loses focus.
|
|
331
|
+
*/
|
|
332
|
+
const focusOut = () => {
|
|
333
|
+
hasKeyboardBeenPresentedForTextField = false;
|
|
334
|
+
index.win === null || index.win === void 0 ? void 0 : index.win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
335
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
336
|
+
};
|
|
274
337
|
/**
|
|
275
338
|
* When the input is about to receive
|
|
276
339
|
* focus, we need to move it to prevent
|
|
@@ -288,10 +351,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
288
351
|
return;
|
|
289
352
|
}
|
|
290
353
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
354
|
+
index.win === null || index.win === void 0 ? void 0 : index.win.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
355
|
+
componentEl.addEventListener('focusout', focusOut, true);
|
|
291
356
|
};
|
|
292
357
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
293
358
|
return () => {
|
|
294
359
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
360
|
+
index.win === null || index.win === void 0 ? void 0 : index.win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
361
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
295
362
|
};
|
|
296
363
|
};
|
|
297
364
|
/**
|
|
@@ -310,7 +377,7 @@ const setManualFocus = (el) => {
|
|
|
310
377
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
311
378
|
el.focus();
|
|
312
379
|
};
|
|
313
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
380
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0, waitForResize = true) => {
|
|
314
381
|
if (!contentEl && !footerEl) {
|
|
315
382
|
return;
|
|
316
383
|
}
|
|
@@ -366,7 +433,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
366
433
|
window.removeEventListener('ionKeyboardDidShow', scrollContent);
|
|
367
434
|
// scroll the input into place
|
|
368
435
|
if (contentEl) {
|
|
369
|
-
await index.scrollByPoint(contentEl, 0, scrollData.scrollAmount, scrollData.scrollDuration);
|
|
436
|
+
await index$1.scrollByPoint(contentEl, 0, scrollData.scrollAmount, scrollData.scrollDuration);
|
|
370
437
|
}
|
|
371
438
|
// the scroll view is in the correct position now
|
|
372
439
|
// give the native text input focus
|
|
@@ -387,7 +454,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
387
454
|
window.addEventListener('ionKeyboardDidShow', scrollContent);
|
|
388
455
|
};
|
|
389
456
|
if (contentEl) {
|
|
390
|
-
const scrollEl = await index.getScrollElement(contentEl);
|
|
457
|
+
const scrollEl = await index$1.getScrollElement(contentEl);
|
|
391
458
|
/**
|
|
392
459
|
* scrollData will only consider the amount we need
|
|
393
460
|
* to scroll in order to properly bring the input
|
|
@@ -401,7 +468,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
401
468
|
* bandwidth to become available.
|
|
402
469
|
*/
|
|
403
470
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
404
|
-
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
471
|
+
if (waitForResize && scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
405
472
|
/**
|
|
406
473
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
407
474
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -460,7 +527,7 @@ const startInputShims = async (config, platform) => {
|
|
|
460
527
|
await new Promise((resolve) => helpers.componentOnReady(componentEl, resolve));
|
|
461
528
|
const inputRoot = componentEl.shadowRoot || componentEl;
|
|
462
529
|
const inputEl = inputRoot.querySelector('input') || inputRoot.querySelector('textarea');
|
|
463
|
-
const scrollEl = index.findClosestIonContent(componentEl);
|
|
530
|
+
const scrollEl = index$1.findClosestIonContent(componentEl);
|
|
464
531
|
const footerEl = !scrollEl ? componentEl.closest('ion-footer') : null;
|
|
465
532
|
if (!inputEl) {
|
|
466
533
|
return;
|
|
@@ -42,7 +42,7 @@ const App = class {
|
|
|
42
42
|
* platforms proceed into this block.
|
|
43
43
|
*/
|
|
44
44
|
const platform = ionicGlobal.isPlatform(window, 'ios') ? 'ios' : 'android';
|
|
45
|
-
Promise.resolve().then(function () { return require('./input-shims-
|
|
45
|
+
Promise.resolve().then(function () { return require('./input-shims-5d7b09e8.js'); }).then((module) => module.startInputShims(ionicGlobal.config, platform));
|
|
46
46
|
}
|
|
47
47
|
const hardwareBackButtonModule = await Promise.resolve().then(function () { return require('./hardware-back-button-b67c8e75.js'); });
|
|
48
48
|
if (ionicGlobal.config.getBoolean('hardwareBackButton', isHybrid)) {
|
|
@@ -21,6 +21,14 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
21
21
|
* Resize info is available on Capacitor 4+
|
|
22
22
|
*/
|
|
23
23
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
24
|
+
/**
|
|
25
|
+
* This tracks whether or not the keyboard has been
|
|
26
|
+
* presented for a single focused text field. Note
|
|
27
|
+
* that it does not track if the keyboard is open
|
|
28
|
+
* in general such as if the keyboard is open for
|
|
29
|
+
* a different focused text field.
|
|
30
|
+
*/
|
|
31
|
+
let hasKeyboardBeenPresentedForTextField = false;
|
|
24
32
|
/**
|
|
25
33
|
* When adding scroll padding we need to know
|
|
26
34
|
* how much of the viewport the keyboard obscures.
|
|
@@ -35,6 +43,61 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
35
43
|
* being scrolled more than it needs to.
|
|
36
44
|
*/
|
|
37
45
|
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
46
|
+
/**
|
|
47
|
+
* Scroll assist is run when a text field
|
|
48
|
+
* is focused. However, it may need to
|
|
49
|
+
* re-run when the keyboard size changes
|
|
50
|
+
* such that the text field is now hidden
|
|
51
|
+
* underneath the keyboard.
|
|
52
|
+
* This function re-runs scroll assist
|
|
53
|
+
* when that happens.
|
|
54
|
+
*
|
|
55
|
+
* One limitation of this is on a web browser
|
|
56
|
+
* where native keyboard APIs do not have cross-browser
|
|
57
|
+
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
58
|
+
* This means that if the keyboard changes but does not change
|
|
59
|
+
* geometry, then scroll assist will not re-run even if
|
|
60
|
+
* the user has scrolled the text field under the keyboard.
|
|
61
|
+
* This should not be a problem when running in Cordova/Capacitor
|
|
62
|
+
* because `ionKeyboardDidShow` uses the native events
|
|
63
|
+
* which fire every time the keyboard changes.
|
|
64
|
+
*/
|
|
65
|
+
const keyboardShow = (ev) => {
|
|
66
|
+
/**
|
|
67
|
+
* If the keyboard has not yet been presented
|
|
68
|
+
* for this text field then the text field has just
|
|
69
|
+
* received focus. In that case, the focusin listener
|
|
70
|
+
* will run scroll assist.
|
|
71
|
+
*/
|
|
72
|
+
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
73
|
+
hasKeyboardBeenPresentedForTextField = true;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Otherwise, the keyboard has already been presented
|
|
78
|
+
* for the focused text field.
|
|
79
|
+
* This means that the keyboard likely changed
|
|
80
|
+
* geometry, and we need to re-run scroll assist.
|
|
81
|
+
* This can happen when the user rotates their device
|
|
82
|
+
* or when they switch keyboards.
|
|
83
|
+
*
|
|
84
|
+
* Make sure we pass in the computed keyboard height
|
|
85
|
+
* rather than the estimated keyboard height.
|
|
86
|
+
*
|
|
87
|
+
* Since the keyboard is already open then we do not
|
|
88
|
+
* need to wait for the webview to resize, so we pass
|
|
89
|
+
* "waitForResize: false".
|
|
90
|
+
*/
|
|
91
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, platformHeight, false);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Reset the internal state when the text field loses focus.
|
|
95
|
+
*/
|
|
96
|
+
const focusOut = () => {
|
|
97
|
+
hasKeyboardBeenPresentedForTextField = false;
|
|
98
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
99
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
100
|
+
};
|
|
38
101
|
/**
|
|
39
102
|
* When the input is about to receive
|
|
40
103
|
* focus, we need to move it to prevent
|
|
@@ -52,10 +115,14 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
52
115
|
return;
|
|
53
116
|
}
|
|
54
117
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
118
|
+
win === null || win === void 0 ? void 0 : win.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
119
|
+
componentEl.addEventListener('focusout', focusOut, true);
|
|
55
120
|
};
|
|
56
121
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
57
122
|
return () => {
|
|
58
123
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
124
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
125
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
59
126
|
};
|
|
60
127
|
};
|
|
61
128
|
/**
|
|
@@ -74,7 +141,7 @@ const setManualFocus = (el) => {
|
|
|
74
141
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
75
142
|
el.focus();
|
|
76
143
|
};
|
|
77
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
144
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0, waitForResize = true) => {
|
|
78
145
|
if (!contentEl && !footerEl) {
|
|
79
146
|
return;
|
|
80
147
|
}
|
|
@@ -165,7 +232,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
165
232
|
* bandwidth to become available.
|
|
166
233
|
*/
|
|
167
234
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
168
|
-
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
235
|
+
if (waitForResize && scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
169
236
|
/**
|
|
170
237
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
171
238
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
package/dist/docs.json
CHANGED
|
@@ -255,6 +255,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
255
255
|
* Resize info is available on Capacitor 4+
|
|
256
256
|
*/
|
|
257
257
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
258
|
+
/**
|
|
259
|
+
* This tracks whether or not the keyboard has been
|
|
260
|
+
* presented for a single focused text field. Note
|
|
261
|
+
* that it does not track if the keyboard is open
|
|
262
|
+
* in general such as if the keyboard is open for
|
|
263
|
+
* a different focused text field.
|
|
264
|
+
*/
|
|
265
|
+
let hasKeyboardBeenPresentedForTextField = false;
|
|
258
266
|
/**
|
|
259
267
|
* When adding scroll padding we need to know
|
|
260
268
|
* how much of the viewport the keyboard obscures.
|
|
@@ -269,6 +277,61 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
269
277
|
* being scrolled more than it needs to.
|
|
270
278
|
*/
|
|
271
279
|
const platformHeight = win !== undefined ? win.innerHeight : 0;
|
|
280
|
+
/**
|
|
281
|
+
* Scroll assist is run when a text field
|
|
282
|
+
* is focused. However, it may need to
|
|
283
|
+
* re-run when the keyboard size changes
|
|
284
|
+
* such that the text field is now hidden
|
|
285
|
+
* underneath the keyboard.
|
|
286
|
+
* This function re-runs scroll assist
|
|
287
|
+
* when that happens.
|
|
288
|
+
*
|
|
289
|
+
* One limitation of this is on a web browser
|
|
290
|
+
* where native keyboard APIs do not have cross-browser
|
|
291
|
+
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
292
|
+
* This means that if the keyboard changes but does not change
|
|
293
|
+
* geometry, then scroll assist will not re-run even if
|
|
294
|
+
* the user has scrolled the text field under the keyboard.
|
|
295
|
+
* This should not be a problem when running in Cordova/Capacitor
|
|
296
|
+
* because `ionKeyboardDidShow` uses the native events
|
|
297
|
+
* which fire every time the keyboard changes.
|
|
298
|
+
*/
|
|
299
|
+
const keyboardShow = (ev) => {
|
|
300
|
+
/**
|
|
301
|
+
* If the keyboard has not yet been presented
|
|
302
|
+
* for this text field then the text field has just
|
|
303
|
+
* received focus. In that case, the focusin listener
|
|
304
|
+
* will run scroll assist.
|
|
305
|
+
*/
|
|
306
|
+
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
307
|
+
hasKeyboardBeenPresentedForTextField = true;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Otherwise, the keyboard has already been presented
|
|
312
|
+
* for the focused text field.
|
|
313
|
+
* This means that the keyboard likely changed
|
|
314
|
+
* geometry, and we need to re-run scroll assist.
|
|
315
|
+
* This can happen when the user rotates their device
|
|
316
|
+
* or when they switch keyboards.
|
|
317
|
+
*
|
|
318
|
+
* Make sure we pass in the computed keyboard height
|
|
319
|
+
* rather than the estimated keyboard height.
|
|
320
|
+
*
|
|
321
|
+
* Since the keyboard is already open then we do not
|
|
322
|
+
* need to wait for the webview to resize, so we pass
|
|
323
|
+
* "waitForResize: false".
|
|
324
|
+
*/
|
|
325
|
+
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, platformHeight, false);
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Reset the internal state when the text field loses focus.
|
|
329
|
+
*/
|
|
330
|
+
const focusOut = () => {
|
|
331
|
+
hasKeyboardBeenPresentedForTextField = false;
|
|
332
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
333
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
334
|
+
};
|
|
272
335
|
/**
|
|
273
336
|
* When the input is about to receive
|
|
274
337
|
* focus, we need to move it to prevent
|
|
@@ -286,10 +349,14 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
286
349
|
return;
|
|
287
350
|
}
|
|
288
351
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput, platformHeight);
|
|
352
|
+
win === null || win === void 0 ? void 0 : win.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
353
|
+
componentEl.addEventListener('focusout', focusOut, true);
|
|
289
354
|
};
|
|
290
355
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
291
356
|
return () => {
|
|
292
357
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
358
|
+
win === null || win === void 0 ? void 0 : win.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
359
|
+
componentEl.removeEventListener('focusout', focusOut, true);
|
|
293
360
|
};
|
|
294
361
|
};
|
|
295
362
|
/**
|
|
@@ -308,7 +375,7 @@ const setManualFocus = (el) => {
|
|
|
308
375
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
309
376
|
el.focus();
|
|
310
377
|
};
|
|
311
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0) => {
|
|
378
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false, platformHeight = 0, waitForResize = true) => {
|
|
312
379
|
if (!contentEl && !footerEl) {
|
|
313
380
|
return;
|
|
314
381
|
}
|
|
@@ -399,7 +466,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
399
466
|
* bandwidth to become available.
|
|
400
467
|
*/
|
|
401
468
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
402
|
-
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
469
|
+
if (waitForResize && scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
403
470
|
/**
|
|
404
471
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
405
472
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -38,7 +38,7 @@ const App = class {
|
|
|
38
38
|
* platforms proceed into this block.
|
|
39
39
|
*/
|
|
40
40
|
const platform = isPlatform(window, 'ios') ? 'ios' : 'android';
|
|
41
|
-
import('./input-shims-
|
|
41
|
+
import('./input-shims-451757bd.js').then((module) => module.startInputShims(config, platform));
|
|
42
42
|
}
|
|
43
43
|
const hardwareBackButtonModule = await import('./hardware-back-button-39299f84.js');
|
|
44
44
|
if (config.getBoolean('hardwareBackButton', isHybrid)) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{__awaiter,__generator}from"tslib";
|
|
2
|
+
/*!
|
|
3
|
+
* (C) Ionic http://ionicframework.com - MIT License
|
|
4
|
+
*/import{g as getScrollElement,c as scrollByPoint,f as findClosestIonContent}from"./index-746a238e.js";import{a as addEventListener,b as removeEventListener,r as raf,c as componentOnReady}from"./helpers-3379ba19.js";import{a as KeyboardResize,K as Keyboard}from"./keyboard-b063f012.js";import{w as win}from"./index-7a14ecec.js";import"./index-595d62c9.js";import"./capacitor-b4979570.js";var cloneMap=new WeakMap;var relocateInput=function(e,t,n,r,o){if(r===void 0){r=0}if(o===void 0){o=false}if(cloneMap.has(e)===n){return}if(n){addClone(e,t,r,o)}else{removeClone(e,t)}};var isFocused=function(e){return e===e.getRootNode().activeElement};var addClone=function(e,t,n,r){if(r===void 0){r=false}var o=t.parentNode;var i=t.cloneNode(false);i.classList.add("cloned-input");i.tabIndex=-1;if(r){i.disabled=true}o.appendChild(i);cloneMap.set(e,i);var a=e.ownerDocument;var u=a.dir==="rtl"?9999:-9999;e.style.pointerEvents="none";t.style.transform="translate3d(".concat(u,"px,").concat(n,"px,0) scale(0)")};var removeClone=function(e,t){var n=cloneMap.get(e);if(n){cloneMap.delete(e);n.remove()}e.style.pointerEvents="";t.style.transform=""};var SCROLL_AMOUNT_PADDING=50;var enableHideCaretOnScroll=function(e,t,n){if(!n||!t){return function(){return}}var r=function(n){if(isFocused(t)){relocateInput(e,t,n)}};var o=function(){return relocateInput(e,t,false)};var i=function(){return r(true)};var a=function(){return r(false)};addEventListener(n,"ionScrollStart",i);addEventListener(n,"ionScrollEnd",a);t.addEventListener("blur",o);return function(){removeEventListener(n,"ionScrollStart",i);removeEventListener(n,"ionScrollEnd",a);t.removeEventListener("blur",o)}};var SKIP_SELECTOR="input, textarea, [no-blur], [contenteditable]";var enableInputBlurring=function(){var e=true;var t=false;var n=document;var r=function(){t=true};var o=function(){e=true};var i=function(r){if(t){t=false;return}var o=n.activeElement;if(!o){return}if(o.matches(SKIP_SELECTOR)){return}var i=r.target;if(i===o){return}if(i.matches(SKIP_SELECTOR)||i.closest(SKIP_SELECTOR)){return}e=false;setTimeout((function(){if(!e){o.blur()}}),50)};addEventListener(n,"ionScrollStart",r);n.addEventListener("focusin",o,true);n.addEventListener("touchend",i,false);return function(){removeEventListener(n,"ionScrollStart",r,true);n.removeEventListener("focusin",o,true);n.removeEventListener("touchend",i,false)}};var SCROLL_ASSIST_SPEED=.3;var getScrollData=function(e,t,n,r){var o;var i=(o=e.closest("ion-item,[ion-item]"))!==null&&o!==void 0?o:e;return calcScrollData(i.getBoundingClientRect(),t.getBoundingClientRect(),n,r)};var calcScrollData=function(e,t,n,r){var o=e.top;var i=e.bottom;var a=t.top;var u=Math.min(t.bottom,r-n);var s=a+15;var l=u-SCROLL_AMOUNT_PADDING;var d=l-i;var c=s-o;var v=Math.round(d<0?-d:c>0?-c:0);var f=Math.min(v,o-a);var S=Math.abs(f);var m=S/SCROLL_ASSIST_SPEED;var L=Math.min(400,Math.max(150,m));return{scrollAmount:f,scrollDuration:L,scrollPadding:n,inputSafeY:-(o-s)+4}};var PADDING_TIMER_KEY="$ionPaddingTimer";var setScrollPadding=function(e,t,n){var r=e[PADDING_TIMER_KEY];if(r){clearTimeout(r)}if(t>0){e.style.setProperty("--keyboard-offset","".concat(t,"px"))}else{e[PADDING_TIMER_KEY]=setTimeout((function(){e.style.setProperty("--keyboard-offset","0px");if(n){n()}}),120)}};var setClearScrollPaddingListener=function(e,t,n){var r=function(){if(t){setScrollPadding(t,0,n)}};e.addEventListener("focusout",r,{once:true})};var currentPadding=0;var SKIP_SCROLL_ASSIST="data-ionic-skip-scroll-assist";var enableScrollAssist=function(e,t,n,r,o,i,a,u){if(u===void 0){u=false}var s=i&&(a===undefined||a.mode===KeyboardResize.None);var l=false;var d=win!==undefined?win.innerHeight:0;var c=function(o){if(l===false){l=true;return}jsSetFocus(e,t,n,r,o.detail.keyboardHeight,s,u,d,false)};var v=function(){l=false;win===null||win===void 0?void 0:win.removeEventListener("ionKeyboardDidShow",c);e.removeEventListener("focusout",v,true)};var f=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(i){if(t.hasAttribute(SKIP_SCROLL_ASSIST)){t.removeAttribute(SKIP_SCROLL_ASSIST);return[2]}jsSetFocus(e,t,n,r,o,s,u,d);win===null||win===void 0?void 0:win.addEventListener("ionKeyboardDidShow",c);e.addEventListener("focusout",v,true);return[2]}))}))};e.addEventListener("focusin",f,true);return function(){e.removeEventListener("focusin",f,true);win===null||win===void 0?void 0:win.removeEventListener("ionKeyboardDidShow",c);e.removeEventListener("focusout",v,true)}};var setManualFocus=function(e){if(document.activeElement===e){return}e.setAttribute(SKIP_SCROLL_ASSIST,"true");e.focus()};var jsSetFocus=function(e,t,n,r,o,i,a,u,s){if(a===void 0){a=false}if(u===void 0){u=0}if(s===void 0){s=true}return __awaiter(void 0,void 0,void 0,(function(){var l,d,c,v,f,S;return __generator(this,(function(m){switch(m.label){case 0:if(!n&&!r){return[2]}l=getScrollData(e,n||r,o,u);if(n&&Math.abs(l.scrollAmount)<4){setManualFocus(t);if(i&&n!==null){setScrollPadding(n,currentPadding);setClearScrollPaddingListener(t,n,(function(){return currentPadding=0}))}return[2]}relocateInput(e,t,true,l.inputSafeY,a);setManualFocus(t);raf((function(){return e.click()}));if(i&&n){currentPadding=l.scrollPadding;setScrollPadding(n,currentPadding)}if(!(typeof window!=="undefined"))return[3,3];c=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:if(d!==undefined){clearTimeout(d)}window.removeEventListener("ionKeyboardDidShow",v);window.removeEventListener("ionKeyboardDidShow",c);if(!n)return[3,2];return[4,scrollByPoint(n,0,l.scrollAmount,l.scrollDuration)];case 1:r.sent();r.label=2;case 2:relocateInput(e,t,false,l.inputSafeY);setManualFocus(t);if(i){setClearScrollPaddingListener(t,n,(function(){return currentPadding=0}))}return[2]}}))}))};v=function(){window.removeEventListener("ionKeyboardDidShow",v);window.addEventListener("ionKeyboardDidShow",c)};if(!n)return[3,2];return[4,getScrollElement(n)];case 1:f=m.sent();S=f.scrollHeight-f.clientHeight;if(s&&l.scrollAmount>S-f.scrollTop){if(t.type==="password"){l.scrollAmount+=SCROLL_AMOUNT_PADDING;window.addEventListener("ionKeyboardDidShow",v)}else{window.addEventListener("ionKeyboardDidShow",c)}d=setTimeout(c,1e3);return[2]}m.label=2;case 2:c();m.label=3;case 3:return[2]}}))}))};var INPUT_BLURRING=true;var startInputShims=function(e,t){return __awaiter(void 0,void 0,void 0,(function(){var n,r,o,i,a,u,s,l,d,c,v,f,S,m,L,p,E;return __generator(this,(function(_){switch(_.label){case 0:n=document;r=t==="ios";o=t==="android";i=e.getNumber("keyboardHeight",290);a=e.getBoolean("scrollAssist",true);u=e.getBoolean("hideCaretOnScroll",r);s=e.getBoolean("inputBlurring",r);l=e.getBoolean("scrollPadding",true);d=Array.from(n.querySelectorAll("ion-input, ion-textarea"));c=new WeakMap;v=new WeakMap;return[4,Keyboard.getResizeMode()];case 1:f=_.sent();S=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,n,r,s,d,S,d;return __generator(this,(function(m){switch(m.label){case 0:return[4,new Promise((function(t){return componentOnReady(e,t)}))];case 1:m.sent();t=e.shadowRoot||e;n=t.querySelector("input")||t.querySelector("textarea");r=findClosestIonContent(e);s=!r?e.closest("ion-footer"):null;if(!n){return[2]}if(!!r&&u&&!c.has(e)){d=enableHideCaretOnScroll(e,n,r);c.set(e,d)}S=n.type==="date"||n.type==="datetime-local";if(!S&&(!!r||!!s)&&a&&!v.has(e)){d=enableScrollAssist(e,n,r,s,i,l,f,o);v.set(e,d)}return[2]}}))}))};m=function(e){if(u){var t=c.get(e);if(t){t()}c.delete(e)}if(a){var t=v.get(e);if(t){t()}v.delete(e)}};if(s&&INPUT_BLURRING){enableInputBlurring()}for(L=0,p=d;L<p.length;L++){E=p[L];S(E)}n.addEventListener("ionInputDidLoad",(function(e){S(e.detail)}));n.addEventListener("ionInputDidUnload",(function(e){m(e.detail)}));return[2]}}))}))};export{startInputShims};
|