@ionic/core 7.3.1-dev.11692293668.19f31f09 → 7.3.1-dev.11692305436.16a4008f
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/button.js +16 -0
- package/components/input-shims.js +2 -76
- package/dist/cjs/{input-shims-d8e322aa.js → input-shims-f8569707.js} +2 -76
- package/dist/cjs/ion-app_8.cjs.entry.js +1 -1
- package/dist/cjs/ion-button_2.cjs.entry.js +16 -0
- package/dist/collection/components/button/button.js +16 -0
- package/dist/collection/utils/input-shims/hacks/scroll-assist.js +2 -76
- package/dist/docs.json +1 -1
- package/dist/esm/{input-shims-c738363e.js → input-shims-af993f05.js} +2 -76
- package/dist/esm/ion-app_8.entry.js +1 -1
- package/dist/esm/ion-button_2.entry.js +16 -0
- package/dist/esm-es5/input-shims-af993f05.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-e5a92aa9.entry.js → p-20087c90.entry.js} +1 -1
- package/dist/ionic/p-4531b920.system.js +4 -0
- package/dist/ionic/p-6405e9f0.system.js +1 -1
- package/dist/ionic/{p-d79af848.system.entry.js → p-8074bdd7.system.entry.js} +1 -1
- package/dist/ionic/p-d898dd46.js +4 -0
- package/dist/types/components/button/button.d.ts +9 -0
- package/hydrate/index.js +16 -0
- package/package.json +1 -1
- package/dist/esm-es5/input-shims-c738363e.js +0 -4
- package/dist/ionic/p-c254bde2.js +0 -4
- package/dist/ionic/p-f58cbf92.system.js +0 -4
package/components/button.js
CHANGED
|
@@ -63,6 +63,15 @@ const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement
|
|
|
63
63
|
this.formButtonEl.disabled = disabled;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* This is responsible for rendering a hidden native
|
|
68
|
+
* button element inside the associated form. This allows
|
|
69
|
+
* users to submit a form by pressing "Enter" when a text
|
|
70
|
+
* field inside of the form is focused. The native button
|
|
71
|
+
* rendered inside of `ion-button` is in the Shadow DOM
|
|
72
|
+
* and therefore does not participate in form submission
|
|
73
|
+
* which is why the following code is necessary.
|
|
74
|
+
*/
|
|
66
75
|
renderHiddenButton() {
|
|
67
76
|
const formEl = (this.formEl = this.findForm());
|
|
68
77
|
if (formEl) {
|
|
@@ -181,6 +190,13 @@ const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement
|
|
|
181
190
|
if (fill == null) {
|
|
182
191
|
fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid';
|
|
183
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* We call renderHiddenButton in the render function to account
|
|
195
|
+
* for any properties being set async. For example, changing the
|
|
196
|
+
* "type" prop from "button" to "submit" after the component has
|
|
197
|
+
* loaded would warrant the hidden button being added to the
|
|
198
|
+
* associated form.
|
|
199
|
+
*/
|
|
184
200
|
{
|
|
185
201
|
type !== 'button' && this.renderHiddenButton();
|
|
186
202
|
}
|
|
@@ -253,68 +253,6 @@ 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;
|
|
264
|
-
/**
|
|
265
|
-
* Scroll assist is run when a text field
|
|
266
|
-
* is focused. However, it may need to
|
|
267
|
-
* re-run when the keyboard size changes
|
|
268
|
-
* such that the text field is now hidden
|
|
269
|
-
* underneath the keyboard.
|
|
270
|
-
* This function re-runs scroll assist
|
|
271
|
-
* when that happens.
|
|
272
|
-
*
|
|
273
|
-
* One limitation of this is on a web browser
|
|
274
|
-
* where native keyboard APIs do not have cross-browser
|
|
275
|
-
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
276
|
-
* This means that if the keyboard changes but does not change
|
|
277
|
-
* geometry, then scroll assist will not re-run even if
|
|
278
|
-
* the user has scrolled the text field under the keyboard.
|
|
279
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
280
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
281
|
-
* which fire every time the keyboard changes.
|
|
282
|
-
*/
|
|
283
|
-
const keyboardShow = (ev) => {
|
|
284
|
-
/**
|
|
285
|
-
* If the keyboard has not yet been presented
|
|
286
|
-
* for this text field then the text field has just
|
|
287
|
-
* received focus. In that case, the focusin listener
|
|
288
|
-
* will run scroll assist.
|
|
289
|
-
*/
|
|
290
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
291
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* Otherwise, the keyboard has already been presented
|
|
296
|
-
* for the focused text field.
|
|
297
|
-
* This means that the keyboard likely changed
|
|
298
|
-
* geometry, and we need to re-run scroll assist.
|
|
299
|
-
* This can happen when the user rotates their device
|
|
300
|
-
* or when they switch keyboards.
|
|
301
|
-
*
|
|
302
|
-
* Make sure we pass in the computed keyboard height
|
|
303
|
-
* rather than the estimated keyboard height.
|
|
304
|
-
*
|
|
305
|
-
* Since the keyboard is already open then we do not
|
|
306
|
-
* need to wait for the webview to resize, so we pass
|
|
307
|
-
* "waitForResize: false".
|
|
308
|
-
*/
|
|
309
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Reset the internal state when the text field loses focus.
|
|
313
|
-
*/
|
|
314
|
-
const focusOut = () => {
|
|
315
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
316
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
317
|
-
};
|
|
318
256
|
/**
|
|
319
257
|
* When the input is about to receive
|
|
320
258
|
* focus, we need to move it to prevent
|
|
@@ -332,22 +270,10 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
332
270
|
return;
|
|
333
271
|
}
|
|
334
272
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
335
|
-
/**
|
|
336
|
-
* Listen for any changes to the keyboard
|
|
337
|
-
* dimensions in case we need to re-run scroll assist.
|
|
338
|
-
*/
|
|
339
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
340
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
341
273
|
};
|
|
342
274
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
343
|
-
/**
|
|
344
|
-
* Scroll assist is being destroyed for this
|
|
345
|
-
* text field instance, so remove any remaining listeners.
|
|
346
|
-
*/
|
|
347
275
|
return () => {
|
|
348
276
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
349
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
350
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
351
277
|
};
|
|
352
278
|
};
|
|
353
279
|
/**
|
|
@@ -366,7 +292,7 @@ const setManualFocus = (el) => {
|
|
|
366
292
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
367
293
|
el.focus();
|
|
368
294
|
};
|
|
369
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false
|
|
295
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false) => {
|
|
370
296
|
if (!contentEl && !footerEl) {
|
|
371
297
|
return;
|
|
372
298
|
}
|
|
@@ -457,7 +383,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
457
383
|
* bandwidth to become available.
|
|
458
384
|
*/
|
|
459
385
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
460
|
-
if (
|
|
386
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
461
387
|
/**
|
|
462
388
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
463
389
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -258,68 +258,6 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
258
258
|
* Resize info is available on Capacitor 4+
|
|
259
259
|
*/
|
|
260
260
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === keyboard.KeyboardResize.None);
|
|
261
|
-
/**
|
|
262
|
-
* This tracks whether or not the keyboard has been
|
|
263
|
-
* presented for a single focused text field. Note
|
|
264
|
-
* that it does not track if the keyboard is open
|
|
265
|
-
* in general such as if the keyboard is open for
|
|
266
|
-
* a different focused text field.
|
|
267
|
-
*/
|
|
268
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
269
|
-
/**
|
|
270
|
-
* Scroll assist is run when a text field
|
|
271
|
-
* is focused. However, it may need to
|
|
272
|
-
* re-run when the keyboard size changes
|
|
273
|
-
* such that the text field is now hidden
|
|
274
|
-
* underneath the keyboard.
|
|
275
|
-
* This function re-runs scroll assist
|
|
276
|
-
* when that happens.
|
|
277
|
-
*
|
|
278
|
-
* One limitation of this is on a web browser
|
|
279
|
-
* where native keyboard APIs do not have cross-browser
|
|
280
|
-
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
281
|
-
* This means that if the keyboard changes but does not change
|
|
282
|
-
* geometry, then scroll assist will not re-run even if
|
|
283
|
-
* the user has scrolled the text field under the keyboard.
|
|
284
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
285
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
286
|
-
* which fire every time the keyboard changes.
|
|
287
|
-
*/
|
|
288
|
-
const keyboardShow = (ev) => {
|
|
289
|
-
/**
|
|
290
|
-
* If the keyboard has not yet been presented
|
|
291
|
-
* for this text field then the text field has just
|
|
292
|
-
* received focus. In that case, the focusin listener
|
|
293
|
-
* will run scroll assist.
|
|
294
|
-
*/
|
|
295
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
296
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Otherwise, the keyboard has already been presented
|
|
301
|
-
* for the focused text field.
|
|
302
|
-
* This means that the keyboard likely changed
|
|
303
|
-
* geometry, and we need to re-run scroll assist.
|
|
304
|
-
* This can happen when the user rotates their device
|
|
305
|
-
* or when they switch keyboards.
|
|
306
|
-
*
|
|
307
|
-
* Make sure we pass in the computed keyboard height
|
|
308
|
-
* rather than the estimated keyboard height.
|
|
309
|
-
*
|
|
310
|
-
* Since the keyboard is already open then we do not
|
|
311
|
-
* need to wait for the webview to resize, so we pass
|
|
312
|
-
* "waitForResize: false".
|
|
313
|
-
*/
|
|
314
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* Reset the internal state when the text field loses focus.
|
|
318
|
-
*/
|
|
319
|
-
const focusOut = () => {
|
|
320
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
321
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
322
|
-
};
|
|
323
261
|
/**
|
|
324
262
|
* When the input is about to receive
|
|
325
263
|
* focus, we need to move it to prevent
|
|
@@ -337,22 +275,10 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
337
275
|
return;
|
|
338
276
|
}
|
|
339
277
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
340
|
-
/**
|
|
341
|
-
* Listen for any changes to the keyboard
|
|
342
|
-
* dimensions in case we need to re-run scroll assist.
|
|
343
|
-
*/
|
|
344
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
345
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
346
278
|
};
|
|
347
279
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
348
|
-
/**
|
|
349
|
-
* Scroll assist is being destroyed for this
|
|
350
|
-
* text field instance, so remove any remaining listeners.
|
|
351
|
-
*/
|
|
352
280
|
return () => {
|
|
353
281
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
354
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
355
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
356
282
|
};
|
|
357
283
|
};
|
|
358
284
|
/**
|
|
@@ -371,7 +297,7 @@ const setManualFocus = (el) => {
|
|
|
371
297
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
372
298
|
el.focus();
|
|
373
299
|
};
|
|
374
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false
|
|
300
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false) => {
|
|
375
301
|
if (!contentEl && !footerEl) {
|
|
376
302
|
return;
|
|
377
303
|
}
|
|
@@ -462,7 +388,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
462
388
|
* bandwidth to become available.
|
|
463
389
|
*/
|
|
464
390
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
465
|
-
if (
|
|
391
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
466
392
|
/**
|
|
467
393
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
468
394
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
|
@@ -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-f8569707.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)) {
|
|
@@ -184,6 +184,15 @@ const Button = class {
|
|
|
184
184
|
this.formButtonEl.disabled = disabled;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* This is responsible for rendering a hidden native
|
|
189
|
+
* button element inside the associated form. This allows
|
|
190
|
+
* users to submit a form by pressing "Enter" when a text
|
|
191
|
+
* field inside of the form is focused. The native button
|
|
192
|
+
* rendered inside of `ion-button` is in the Shadow DOM
|
|
193
|
+
* and therefore does not participate in form submission
|
|
194
|
+
* which is why the following code is necessary.
|
|
195
|
+
*/
|
|
187
196
|
renderHiddenButton() {
|
|
188
197
|
const formEl = (this.formEl = this.findForm());
|
|
189
198
|
if (formEl) {
|
|
@@ -302,6 +311,13 @@ const Button = class {
|
|
|
302
311
|
if (fill == null) {
|
|
303
312
|
fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid';
|
|
304
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* We call renderHiddenButton in the render function to account
|
|
316
|
+
* for any properties being set async. For example, changing the
|
|
317
|
+
* "type" prop from "button" to "submit" after the component has
|
|
318
|
+
* loaded would warrant the hidden button being added to the
|
|
319
|
+
* associated form.
|
|
320
|
+
*/
|
|
305
321
|
{
|
|
306
322
|
type !== 'button' && this.renderHiddenButton();
|
|
307
323
|
}
|
|
@@ -62,6 +62,15 @@ export class Button {
|
|
|
62
62
|
this.formButtonEl.disabled = disabled;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* This is responsible for rendering a hidden native
|
|
67
|
+
* button element inside the associated form. This allows
|
|
68
|
+
* users to submit a form by pressing "Enter" when a text
|
|
69
|
+
* field inside of the form is focused. The native button
|
|
70
|
+
* rendered inside of `ion-button` is in the Shadow DOM
|
|
71
|
+
* and therefore does not participate in form submission
|
|
72
|
+
* which is why the following code is necessary.
|
|
73
|
+
*/
|
|
65
74
|
renderHiddenButton() {
|
|
66
75
|
const formEl = (this.formEl = this.findForm());
|
|
67
76
|
if (formEl) {
|
|
@@ -180,6 +189,13 @@ export class Button {
|
|
|
180
189
|
if (fill == null) {
|
|
181
190
|
fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid';
|
|
182
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* We call renderHiddenButton in the render function to account
|
|
194
|
+
* for any properties being set async. For example, changing the
|
|
195
|
+
* "type" prop from "button" to "submit" after the component has
|
|
196
|
+
* loaded would warrant the hidden button being added to the
|
|
197
|
+
* associated form.
|
|
198
|
+
*/
|
|
183
199
|
{
|
|
184
200
|
type !== 'button' && this.renderHiddenButton();
|
|
185
201
|
}
|
|
@@ -20,68 +20,6 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
20
20
|
* Resize info is available on Capacitor 4+
|
|
21
21
|
*/
|
|
22
22
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
23
|
-
/**
|
|
24
|
-
* This tracks whether or not the keyboard has been
|
|
25
|
-
* presented for a single focused text field. Note
|
|
26
|
-
* that it does not track if the keyboard is open
|
|
27
|
-
* in general such as if the keyboard is open for
|
|
28
|
-
* a different focused text field.
|
|
29
|
-
*/
|
|
30
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
31
|
-
/**
|
|
32
|
-
* Scroll assist is run when a text field
|
|
33
|
-
* is focused. However, it may need to
|
|
34
|
-
* re-run when the keyboard size changes
|
|
35
|
-
* such that the text field is now hidden
|
|
36
|
-
* underneath the keyboard.
|
|
37
|
-
* This function re-runs scroll assist
|
|
38
|
-
* when that happens.
|
|
39
|
-
*
|
|
40
|
-
* One limitation of this is on a web browser
|
|
41
|
-
* where native keyboard APIs do not have cross-browser
|
|
42
|
-
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
43
|
-
* This means that if the keyboard changes but does not change
|
|
44
|
-
* geometry, then scroll assist will not re-run even if
|
|
45
|
-
* the user has scrolled the text field under the keyboard.
|
|
46
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
47
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
48
|
-
* which fire every time the keyboard changes.
|
|
49
|
-
*/
|
|
50
|
-
const keyboardShow = (ev) => {
|
|
51
|
-
/**
|
|
52
|
-
* If the keyboard has not yet been presented
|
|
53
|
-
* for this text field then the text field has just
|
|
54
|
-
* received focus. In that case, the focusin listener
|
|
55
|
-
* will run scroll assist.
|
|
56
|
-
*/
|
|
57
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
58
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Otherwise, the keyboard has already been presented
|
|
63
|
-
* for the focused text field.
|
|
64
|
-
* This means that the keyboard likely changed
|
|
65
|
-
* geometry, and we need to re-run scroll assist.
|
|
66
|
-
* This can happen when the user rotates their device
|
|
67
|
-
* or when they switch keyboards.
|
|
68
|
-
*
|
|
69
|
-
* Make sure we pass in the computed keyboard height
|
|
70
|
-
* rather than the estimated keyboard height.
|
|
71
|
-
*
|
|
72
|
-
* Since the keyboard is already open then we do not
|
|
73
|
-
* need to wait for the webview to resize, so we pass
|
|
74
|
-
* "waitForResize: false".
|
|
75
|
-
*/
|
|
76
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Reset the internal state when the text field loses focus.
|
|
80
|
-
*/
|
|
81
|
-
const focusOut = () => {
|
|
82
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
83
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
84
|
-
};
|
|
85
23
|
/**
|
|
86
24
|
* When the input is about to receive
|
|
87
25
|
* focus, we need to move it to prevent
|
|
@@ -99,22 +37,10 @@ export const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, ke
|
|
|
99
37
|
return;
|
|
100
38
|
}
|
|
101
39
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
102
|
-
/**
|
|
103
|
-
* Listen for any changes to the keyboard
|
|
104
|
-
* dimensions in case we need to re-run scroll assist.
|
|
105
|
-
*/
|
|
106
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
107
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
108
40
|
};
|
|
109
41
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
110
|
-
/**
|
|
111
|
-
* Scroll assist is being destroyed for this
|
|
112
|
-
* text field instance, so remove any remaining listeners.
|
|
113
|
-
*/
|
|
114
42
|
return () => {
|
|
115
43
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
116
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
117
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
118
44
|
};
|
|
119
45
|
};
|
|
120
46
|
/**
|
|
@@ -133,7 +59,7 @@ const setManualFocus = (el) => {
|
|
|
133
59
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
134
60
|
el.focus();
|
|
135
61
|
};
|
|
136
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false
|
|
62
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false) => {
|
|
137
63
|
if (!contentEl && !footerEl) {
|
|
138
64
|
return;
|
|
139
65
|
}
|
|
@@ -224,7 +150,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
224
150
|
* bandwidth to become available.
|
|
225
151
|
*/
|
|
226
152
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
227
|
-
if (
|
|
153
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
228
154
|
/**
|
|
229
155
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
230
156
|
* after the initial keyboard is shown. This prevents the webview from resizing
|
package/dist/docs.json
CHANGED
|
@@ -256,68 +256,6 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
256
256
|
* Resize info is available on Capacitor 4+
|
|
257
257
|
*/
|
|
258
258
|
const addScrollPadding = enableScrollPadding && (keyboardResize === undefined || keyboardResize.mode === KeyboardResize.None);
|
|
259
|
-
/**
|
|
260
|
-
* This tracks whether or not the keyboard has been
|
|
261
|
-
* presented for a single focused text field. Note
|
|
262
|
-
* that it does not track if the keyboard is open
|
|
263
|
-
* in general such as if the keyboard is open for
|
|
264
|
-
* a different focused text field.
|
|
265
|
-
*/
|
|
266
|
-
let hasKeyboardBeenPresentedForTextField = false;
|
|
267
|
-
/**
|
|
268
|
-
* Scroll assist is run when a text field
|
|
269
|
-
* is focused. However, it may need to
|
|
270
|
-
* re-run when the keyboard size changes
|
|
271
|
-
* such that the text field is now hidden
|
|
272
|
-
* underneath the keyboard.
|
|
273
|
-
* This function re-runs scroll assist
|
|
274
|
-
* when that happens.
|
|
275
|
-
*
|
|
276
|
-
* One limitation of this is on a web browser
|
|
277
|
-
* where native keyboard APIs do not have cross-browser
|
|
278
|
-
* support. `ionKeyboardDidShow` relies on the Visual Viewport API.
|
|
279
|
-
* This means that if the keyboard changes but does not change
|
|
280
|
-
* geometry, then scroll assist will not re-run even if
|
|
281
|
-
* the user has scrolled the text field under the keyboard.
|
|
282
|
-
* This should not be a problem when running in Cordova/Capacitor
|
|
283
|
-
* because `ionKeyboardDidShow` uses the native events
|
|
284
|
-
* which fire every time the keyboard changes.
|
|
285
|
-
*/
|
|
286
|
-
const keyboardShow = (ev) => {
|
|
287
|
-
/**
|
|
288
|
-
* If the keyboard has not yet been presented
|
|
289
|
-
* for this text field then the text field has just
|
|
290
|
-
* received focus. In that case, the focusin listener
|
|
291
|
-
* will run scroll assist.
|
|
292
|
-
*/
|
|
293
|
-
if (hasKeyboardBeenPresentedForTextField === false) {
|
|
294
|
-
hasKeyboardBeenPresentedForTextField = true;
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Otherwise, the keyboard has already been presented
|
|
299
|
-
* for the focused text field.
|
|
300
|
-
* This means that the keyboard likely changed
|
|
301
|
-
* geometry, and we need to re-run scroll assist.
|
|
302
|
-
* This can happen when the user rotates their device
|
|
303
|
-
* or when they switch keyboards.
|
|
304
|
-
*
|
|
305
|
-
* Make sure we pass in the computed keyboard height
|
|
306
|
-
* rather than the estimated keyboard height.
|
|
307
|
-
*
|
|
308
|
-
* Since the keyboard is already open then we do not
|
|
309
|
-
* need to wait for the webview to resize, so we pass
|
|
310
|
-
* "waitForResize: false".
|
|
311
|
-
*/
|
|
312
|
-
jsSetFocus(componentEl, inputEl, contentEl, footerEl, ev.detail.keyboardHeight, addScrollPadding, disableClonedInput, false);
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Reset the internal state when the text field loses focus.
|
|
316
|
-
*/
|
|
317
|
-
const focusOut = () => {
|
|
318
|
-
hasKeyboardBeenPresentedForTextField = false;
|
|
319
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
320
|
-
};
|
|
321
259
|
/**
|
|
322
260
|
* When the input is about to receive
|
|
323
261
|
* focus, we need to move it to prevent
|
|
@@ -335,22 +273,10 @@ const enableScrollAssist = (componentEl, inputEl, contentEl, footerEl, keyboardH
|
|
|
335
273
|
return;
|
|
336
274
|
}
|
|
337
275
|
jsSetFocus(componentEl, inputEl, contentEl, footerEl, keyboardHeight, addScrollPadding, disableClonedInput);
|
|
338
|
-
/**
|
|
339
|
-
* Listen for any changes to the keyboard
|
|
340
|
-
* dimensions in case we need to re-run scroll assist.
|
|
341
|
-
*/
|
|
342
|
-
window.addEventListener('ionKeyboardDidShow', keyboardShow);
|
|
343
|
-
componentEl.addEventListener('focusout', focusOut, true);
|
|
344
276
|
};
|
|
345
277
|
componentEl.addEventListener('focusin', focusIn, true);
|
|
346
|
-
/**
|
|
347
|
-
* Scroll assist is being destroyed for this
|
|
348
|
-
* text field instance, so remove any remaining listeners.
|
|
349
|
-
*/
|
|
350
278
|
return () => {
|
|
351
279
|
componentEl.removeEventListener('focusin', focusIn, true);
|
|
352
|
-
window.removeEventListener('ionKeyboardDidShow', keyboardShow);
|
|
353
|
-
componentEl.removeEventListener('focusout', focusOut, true);
|
|
354
280
|
};
|
|
355
281
|
};
|
|
356
282
|
/**
|
|
@@ -369,7 +295,7 @@ const setManualFocus = (el) => {
|
|
|
369
295
|
el.setAttribute(SKIP_SCROLL_ASSIST, 'true');
|
|
370
296
|
el.focus();
|
|
371
297
|
};
|
|
372
|
-
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false
|
|
298
|
+
const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHeight, enableScrollPadding, disableClonedInput = false) => {
|
|
373
299
|
if (!contentEl && !footerEl) {
|
|
374
300
|
return;
|
|
375
301
|
}
|
|
@@ -460,7 +386,7 @@ const jsSetFocus = async (componentEl, inputEl, contentEl, footerEl, keyboardHei
|
|
|
460
386
|
* bandwidth to become available.
|
|
461
387
|
*/
|
|
462
388
|
const totalScrollAmount = scrollEl.scrollHeight - scrollEl.clientHeight;
|
|
463
|
-
if (
|
|
389
|
+
if (scrollData.scrollAmount > totalScrollAmount - scrollEl.scrollTop) {
|
|
464
390
|
/**
|
|
465
391
|
* On iOS devices, the system will show a "Passwords" bar above the keyboard
|
|
466
392
|
* 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-af993f05.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)) {
|
|
@@ -180,6 +180,15 @@ const Button = class {
|
|
|
180
180
|
this.formButtonEl.disabled = disabled;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* This is responsible for rendering a hidden native
|
|
185
|
+
* button element inside the associated form. This allows
|
|
186
|
+
* users to submit a form by pressing "Enter" when a text
|
|
187
|
+
* field inside of the form is focused. The native button
|
|
188
|
+
* rendered inside of `ion-button` is in the Shadow DOM
|
|
189
|
+
* and therefore does not participate in form submission
|
|
190
|
+
* which is why the following code is necessary.
|
|
191
|
+
*/
|
|
183
192
|
renderHiddenButton() {
|
|
184
193
|
const formEl = (this.formEl = this.findForm());
|
|
185
194
|
if (formEl) {
|
|
@@ -298,6 +307,13 @@ const Button = class {
|
|
|
298
307
|
if (fill == null) {
|
|
299
308
|
fill = this.inToolbar || this.inListHeader ? 'clear' : 'solid';
|
|
300
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* We call renderHiddenButton in the render function to account
|
|
312
|
+
* for any properties being set async. For example, changing the
|
|
313
|
+
* "type" prop from "button" to "submit" after the component has
|
|
314
|
+
* loaded would warrant the hidden button being added to the
|
|
315
|
+
* associated form.
|
|
316
|
+
*/
|
|
301
317
|
{
|
|
302
318
|
type !== 'button' && this.renderHiddenButton();
|
|
303
319
|
}
|
|
@@ -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"./index-595d62c9.js";import"./capacitor-b4979570.js";import"./index-7a14ecec.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 l=a.dir==="rtl"?9999:-9999;e.style.pointerEvents="none";t.style.transform="translate3d(".concat(l,"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){var r;var o=(r=e.closest("ion-item,[ion-item]"))!==null&&r!==void 0?r:e;return calcScrollData(o.getBoundingClientRect(),t.getBoundingClientRect(),n,e.ownerDocument.defaultView.innerHeight)};var calcScrollData=function(e,t,n,r){var o=e.top;var i=e.bottom;var a=t.top;var l=Math.min(t.bottom,r-n);var u=a+15;var s=l-SCROLL_AMOUNT_PADDING;var c=s-i;var d=u-o;var f=Math.round(c<0?-c:d>0?-d:0);var v=Math.min(f,o-a);var S=Math.abs(v);var m=S/SCROLL_ASSIST_SPEED;var p=Math.min(400,Math.max(150,m));return{scrollAmount:v,scrollDuration:p,scrollPadding:n,inputSafeY:-(o-u)+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,l){if(l===void 0){l=false}var u=i&&(a===undefined||a.mode===KeyboardResize.None);var s=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,u,l);return[2]}))}))};e.addEventListener("focusin",s,true);return function(){e.removeEventListener("focusin",s,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){if(a===void 0){a=false}return __awaiter(void 0,void 0,void 0,(function(){var l,u,s,c,d,f;return __generator(this,(function(v){switch(v.label){case 0:if(!n&&!r){return[2]}l=getScrollData(e,n||r,o);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];s=function(){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:if(u!==undefined){clearTimeout(u)}window.removeEventListener("ionKeyboardDidShow",c);window.removeEventListener("ionKeyboardDidShow",s);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]}}))}))};c=function(){window.removeEventListener("ionKeyboardDidShow",c);window.addEventListener("ionKeyboardDidShow",s)};if(!n)return[3,2];return[4,getScrollElement(n)];case 1:d=v.sent();f=d.scrollHeight-d.clientHeight;if(l.scrollAmount>f-d.scrollTop){if(t.type==="password"){l.scrollAmount+=SCROLL_AMOUNT_PADDING;window.addEventListener("ionKeyboardDidShow",c)}else{window.addEventListener("ionKeyboardDidShow",s)}u=setTimeout(s,1e3);return[2]}v.label=2;case 2:s();v.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,l,u,s,c,d,f,v,S,m,p,L,_;return __generator(this,(function(E){switch(E.label){case 0:n=document;r=t==="ios";o=t==="android";i=e.getNumber("keyboardHeight",290);a=e.getBoolean("scrollAssist",true);l=e.getBoolean("hideCaretOnScroll",r);u=e.getBoolean("inputBlurring",r);s=e.getBoolean("scrollPadding",true);c=Array.from(n.querySelectorAll("ion-input, ion-textarea"));d=new WeakMap;f=new WeakMap;return[4,Keyboard.getResizeMode()];case 1:v=E.sent();S=function(e){return __awaiter(void 0,void 0,void 0,(function(){var t,n,r,u,c,S,c;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);u=!r?e.closest("ion-footer"):null;if(!n){return[2]}if(!!r&&l&&!d.has(e)){c=enableHideCaretOnScroll(e,n,r);d.set(e,c)}S=n.type==="date"||n.type==="datetime-local";if(!S&&(!!r||!!u)&&a&&!f.has(e)){c=enableScrollAssist(e,n,r,u,i,s,v,o);f.set(e,c)}return[2]}}))}))};m=function(e){if(l){var t=d.get(e);if(t){t()}d.delete(e)}if(a){var t=f.get(e);if(t){t()}f.delete(e)}};if(u&&INPUT_BLURRING){enableInputBlurring()}for(p=0,L=c;p<L.length;p++){_=L[p];S(_)}n.addEventListener("ionInputDidLoad",(function(e){S(e.detail)}));n.addEventListener("ionInputDidUnload",(function(e){m(e.detail)}));return[2]}}))}))};export{startInputShims};
|