@ionic/core 7.4.1 → 7.4.2-dev.11695324357.11675a9b
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/ion-input.js +20 -6
- package/dist/cjs/ion-input.cjs.entry.js +17 -5
- package/dist/cjs/ionic.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/input/input.js +50 -6
- package/dist/collection/components/item-sliding/test/basic/item-sliding.e2e.js +36 -6
- package/dist/collection/components/item-sliding/test/icons/item-sliding.e2e.js +22 -7
- package/dist/collection/components/item-sliding/test/scroll-target/item-sliding.e2e.js +3 -9
- package/dist/collection/components/item-sliding/test/test.utils.js +8 -0
- package/dist/docs.json +51 -3
- package/dist/esm/ion-input.entry.js +17 -5
- package/dist/esm/ionic.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm-es5/ion-input.entry.js +1 -1
- package/dist/esm-es5/ionic.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/html.html-data.json +4 -0
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-6edbc09b.system.js +1 -1
- package/dist/ionic/p-73496625.entry.js +4 -0
- package/dist/ionic/{p-cd675d89.system.entry.js → p-94efbb73.system.entry.js} +1 -1
- package/dist/types/components/input/input-interface.d.ts +1 -0
- package/dist/types/components/input/input.d.ts +4 -2
- package/dist/types/components/item-sliding/test/test.utils.d.ts +5 -0
- package/dist/types/components.d.ts +6 -4
- package/hydrate/index.js +18 -5
- package/package.json +1 -1
- package/dist/ionic/p-ea88031d.entry.js +0 -4
|
@@ -114,6 +114,7 @@ export class Input {
|
|
|
114
114
|
this.size = undefined;
|
|
115
115
|
this.type = 'text';
|
|
116
116
|
this.value = '';
|
|
117
|
+
this.defaultValue = this.getValue();
|
|
117
118
|
}
|
|
118
119
|
debounceChanged() {
|
|
119
120
|
const { ionInput, debounce, originalIonInput } = this;
|
|
@@ -151,6 +152,9 @@ export class Input {
|
|
|
151
152
|
}
|
|
152
153
|
this.emitStyle();
|
|
153
154
|
}
|
|
155
|
+
defaultValueChanged(newValue) {
|
|
156
|
+
this.value = this.defaultValue = this.getValue(newValue);
|
|
157
|
+
}
|
|
154
158
|
componentWillLoad() {
|
|
155
159
|
this.inheritedAttributes = Object.assign(Object.assign({}, inheritAriaAttributes(this.el)), inheritAttributes(this.el, ['tabindex', 'title', 'data-form-type']));
|
|
156
160
|
}
|
|
@@ -169,6 +173,11 @@ export class Input {
|
|
|
169
173
|
}
|
|
170
174
|
componentDidLoad() {
|
|
171
175
|
this.originalIonInput = this.ionInput;
|
|
176
|
+
if (this.value === '' || this.value == null) {
|
|
177
|
+
if (this.defaultValue !== '') {
|
|
178
|
+
this.value = this.getValue(this.defaultValue);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
172
181
|
}
|
|
173
182
|
componentDidRender() {
|
|
174
183
|
var _a;
|
|
@@ -237,8 +246,8 @@ export class Input {
|
|
|
237
246
|
const { type, clearOnEdit } = this;
|
|
238
247
|
return clearOnEdit === undefined ? type === 'password' : clearOnEdit;
|
|
239
248
|
}
|
|
240
|
-
getValue() {
|
|
241
|
-
return typeof
|
|
249
|
+
getValue(value = this.value) {
|
|
250
|
+
return typeof value === 'number' ? value.toString() : (value || '').toString();
|
|
242
251
|
}
|
|
243
252
|
emitStyle() {
|
|
244
253
|
if (this.legacyFormController.hasLegacyControl()) {
|
|
@@ -357,6 +366,7 @@ export class Input {
|
|
|
357
366
|
const { disabled, fill, readonly, shape, inputId, labelPlacement } = this;
|
|
358
367
|
const mode = getIonMode(this);
|
|
359
368
|
const value = this.getValue();
|
|
369
|
+
const defaultValue = this.getValue(this.defaultValue);
|
|
360
370
|
const inItem = hostContext('ion-item', this.el);
|
|
361
371
|
const shouldRenderHighlight = mode === 'md' && fill !== 'outline' && !inItem;
|
|
362
372
|
return (h(Host, { class: createColorClasses(this.color, {
|
|
@@ -369,7 +379,7 @@ export class Input {
|
|
|
369
379
|
'in-item': inItem,
|
|
370
380
|
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
|
371
381
|
'input-disabled': disabled,
|
|
372
|
-
}) }, h("label", { class: "input-wrapper" }, this.renderLabelContainer(), h("div", { class: "native-wrapper" }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), id: inputId, disabled: disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown, onCompositionstart: this.onCompositionStart, onCompositionend: this.onCompositionEnd }, this.inheritedAttributes)), this.clearInput && !readonly && !disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
382
|
+
}) }, h("label", { class: "input-wrapper" }, this.renderLabelContainer(), h("div", { class: "native-wrapper" }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), id: inputId, disabled: disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, defaultValue: defaultValue, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown, onCompositionstart: this.onCompositionStart, onCompositionend: this.onCompositionEnd }, this.inheritedAttributes)), this.clearInput && !readonly && !disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
373
383
|
/**
|
|
374
384
|
* This prevents mobile browsers from
|
|
375
385
|
* blurring the input when the clear
|
|
@@ -398,6 +408,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
398
408
|
}
|
|
399
409
|
const mode = getIonMode(this);
|
|
400
410
|
const value = this.getValue();
|
|
411
|
+
const defaultValue = this.getValue(this.defaultValue);
|
|
401
412
|
const labelId = this.inputId + '-lbl';
|
|
402
413
|
const label = findItemLabel(this.el);
|
|
403
414
|
if (label) {
|
|
@@ -409,7 +420,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
409
420
|
'has-focus': this.hasFocus,
|
|
410
421
|
'legacy-input': true,
|
|
411
422
|
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
|
412
|
-
}) }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), "aria-labelledby": label ? label.id : null, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown }, this.inheritedAttributes)), this.clearInput && !this.readonly && !this.disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
423
|
+
}) }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), "aria-labelledby": label ? label.id : null, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, defaultValue: defaultValue, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown }, this.inheritedAttributes)), this.clearInput && !this.readonly && !this.disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
413
424
|
/**
|
|
414
425
|
* This prevents mobile browsers from
|
|
415
426
|
* blurring the input when the clear
|
|
@@ -1069,9 +1080,15 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
1069
1080
|
"type": "any",
|
|
1070
1081
|
"mutable": true,
|
|
1071
1082
|
"complexType": {
|
|
1072
|
-
"original": "
|
|
1083
|
+
"original": "InputValue",
|
|
1073
1084
|
"resolved": "null | number | string | undefined",
|
|
1074
|
-
"references": {
|
|
1085
|
+
"references": {
|
|
1086
|
+
"InputValue": {
|
|
1087
|
+
"location": "import",
|
|
1088
|
+
"path": "./input-interface",
|
|
1089
|
+
"id": "src/components/input/input-interface.ts::InputValue"
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1075
1092
|
},
|
|
1076
1093
|
"required": false,
|
|
1077
1094
|
"optional": true,
|
|
@@ -1082,6 +1099,30 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
1082
1099
|
"attribute": "value",
|
|
1083
1100
|
"reflect": false,
|
|
1084
1101
|
"defaultValue": "''"
|
|
1102
|
+
},
|
|
1103
|
+
"defaultValue": {
|
|
1104
|
+
"type": "any",
|
|
1105
|
+
"mutable": true,
|
|
1106
|
+
"complexType": {
|
|
1107
|
+
"original": "InputValue",
|
|
1108
|
+
"resolved": "null | number | string | undefined",
|
|
1109
|
+
"references": {
|
|
1110
|
+
"InputValue": {
|
|
1111
|
+
"location": "import",
|
|
1112
|
+
"path": "./input-interface",
|
|
1113
|
+
"id": "src/components/input/input-interface.ts::InputValue"
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
"required": false,
|
|
1118
|
+
"optional": true,
|
|
1119
|
+
"docs": {
|
|
1120
|
+
"tags": [],
|
|
1121
|
+
"text": ""
|
|
1122
|
+
},
|
|
1123
|
+
"attribute": "default-value",
|
|
1124
|
+
"reflect": false,
|
|
1125
|
+
"defaultValue": "this.getValue()"
|
|
1085
1126
|
}
|
|
1086
1127
|
};
|
|
1087
1128
|
}
|
|
@@ -1255,6 +1296,9 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
1255
1296
|
}, {
|
|
1256
1297
|
"propName": "value",
|
|
1257
1298
|
"methodName": "valueChanged"
|
|
1299
|
+
}, {
|
|
1300
|
+
"propName": "defaultValue",
|
|
1301
|
+
"methodName": "defaultValueChanged"
|
|
1258
1302
|
}];
|
|
1259
1303
|
}
|
|
1260
1304
|
}
|
|
@@ -3,16 +3,46 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { expect } from "@playwright/test";
|
|
5
5
|
import { configs, dragElementBy, test } from "../../../../utils/test/playwright/index";
|
|
6
|
-
import { testSlidingItem } from "../test.utils";
|
|
7
6
|
/**
|
|
8
|
-
* item-sliding doesn't have mode-specific styling
|
|
7
|
+
* item-sliding doesn't have mode-specific styling,
|
|
8
|
+
* but the child components, item-options and item-option, do.
|
|
9
|
+
*
|
|
10
|
+
* It is important to test all modes to ensure that the
|
|
11
|
+
* child components are being rendered correctly.
|
|
9
12
|
*/
|
|
10
|
-
configs(
|
|
13
|
+
configs().forEach(({ title, screenshot, config }) => {
|
|
11
14
|
test.describe(title('item-sliding: basic'), () => {
|
|
12
|
-
test.
|
|
15
|
+
test.beforeEach(async ({ page }) => {
|
|
13
16
|
await page.goto(`/src/components/item-sliding/test/basic`, config);
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
});
|
|
18
|
+
test.describe('start options', () => {
|
|
19
|
+
test('should not have visual regressions', async ({ page }) => {
|
|
20
|
+
const item = page.locator('#item2');
|
|
21
|
+
/**
|
|
22
|
+
* Negative dragByX value to drag element from the right to the left
|
|
23
|
+
* to reveal the options on the right side.
|
|
24
|
+
* Positive dragByX value to drag element from the left to the right
|
|
25
|
+
* to reveal the options on the left side.
|
|
26
|
+
*/
|
|
27
|
+
const dragByX = config.direction === 'rtl' ? -150 : 150;
|
|
28
|
+
await dragElementBy(item, page, dragByX);
|
|
29
|
+
await page.waitForChanges();
|
|
30
|
+
await expect(item).toHaveScreenshot(screenshot('item-sliding-start'));
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
test.describe('end options', () => {
|
|
34
|
+
test('should not have visual regressions', async ({ page }) => {
|
|
35
|
+
const item = page.locator('#item2');
|
|
36
|
+
/**
|
|
37
|
+
* Negative dragByX value to drag element from the right to the left
|
|
38
|
+
* to reveal the options on the right side.
|
|
39
|
+
* Positive dragByX value to drag element from the left to the right
|
|
40
|
+
* to reveal the options on the left side.
|
|
41
|
+
*/
|
|
42
|
+
const dragByX = config.direction === 'rtl' ? 150 : -150;
|
|
43
|
+
await dragElementBy(item, page, dragByX);
|
|
44
|
+
await expect(item).toHaveScreenshot(screenshot('item-sliding-end'));
|
|
45
|
+
});
|
|
16
46
|
});
|
|
17
47
|
});
|
|
18
48
|
});
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
// TODO FW-3006
|
|
4
|
+
import { expect } from "@playwright/test";
|
|
5
|
+
import { configs, test, dragElementBy } from "../../../../utils/test/playwright/index";
|
|
7
6
|
/**
|
|
8
|
-
* item-sliding doesn't have mode-specific styling
|
|
7
|
+
* item-sliding doesn't have mode-specific styling,
|
|
8
|
+
* but the child components, item-options and item-option, do.
|
|
9
|
+
*
|
|
10
|
+
* It is important to test all modes to ensure that the
|
|
11
|
+
* child components are being rendered correctly.
|
|
9
12
|
*/
|
|
10
|
-
configs(
|
|
11
|
-
test.describe
|
|
13
|
+
configs().forEach(({ title, screenshot, config }) => {
|
|
14
|
+
test.describe(title('item-sliding: icons'), () => {
|
|
12
15
|
test('should not have visual regressions', async ({ page }) => {
|
|
13
16
|
await page.goto(`/src/components/item-sliding/test/icons`, config);
|
|
14
17
|
const itemIDs = ['iconsOnly', 'iconsStart', 'iconsEnd', 'iconsTop', 'iconsBottom'];
|
|
15
18
|
for (const itemID of itemIDs) {
|
|
16
|
-
|
|
19
|
+
const item = page.locator(`#${itemID}`);
|
|
20
|
+
/**
|
|
21
|
+
* Negative dragByX value to drag element from the right to the left
|
|
22
|
+
* to reveal the options on the right side.
|
|
23
|
+
* Positive dragByX value to drag element from the left to the right
|
|
24
|
+
* to reveal the options on the left side.
|
|
25
|
+
*/
|
|
26
|
+
const dragByX = config.direction === 'rtl' ? 150 : -150;
|
|
27
|
+
await dragElementBy(item, page, dragByX);
|
|
28
|
+
await page.waitForChanges();
|
|
29
|
+
// Convert camelCase ids to kebab-case for screenshot file names
|
|
30
|
+
const itemIDKebab = itemID.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
31
|
+
await expect(item).toHaveScreenshot(screenshot(`item-sliding-${itemIDKebab}`));
|
|
17
32
|
}
|
|
18
33
|
});
|
|
19
34
|
});
|
|
@@ -2,25 +2,19 @@
|
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
4
|
import { expect } from "@playwright/test";
|
|
5
|
-
import { configs, test } from "../../../../utils/test/playwright/index";
|
|
5
|
+
import { configs, test, dragElementBy } from "../../../../utils/test/playwright/index";
|
|
6
6
|
/**
|
|
7
7
|
* This behavior does not vary across modes/directions
|
|
8
8
|
*/
|
|
9
9
|
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
|
10
10
|
test.describe(title('item-sliding: scroll-target'), () => {
|
|
11
|
-
|
|
12
|
-
test.skip('should not scroll when the item-sliding is swiped in custom scroll target', async ({ page, skip }) => {
|
|
11
|
+
test('should not scroll when the item-sliding is swiped in custom scroll target', async ({ page, skip }) => {
|
|
13
12
|
skip.browser('webkit', 'mouse.wheel is not available in WebKit');
|
|
14
13
|
await page.goto(`/src/components/item-sliding/test/scroll-target`, config);
|
|
15
14
|
const itemSlidingEl = page.locator('ion-item-sliding');
|
|
16
15
|
const scrollEl = page.locator('.ion-content-scroll-host');
|
|
17
16
|
expect(await scrollEl.evaluate((el) => el.scrollTop)).toEqual(0);
|
|
18
|
-
|
|
19
|
-
const centerX = box.x + box.width / 2;
|
|
20
|
-
const centerY = box.y + box.height / 2;
|
|
21
|
-
await page.mouse.move(centerX, centerY);
|
|
22
|
-
await page.mouse.down();
|
|
23
|
-
await page.mouse.move(centerX - 30, centerY);
|
|
17
|
+
await dragElementBy(itemSlidingEl, page, -150, 0, undefined, undefined, false);
|
|
24
18
|
/**
|
|
25
19
|
* Do not use scrollToBottom() or other scrolling methods
|
|
26
20
|
* on ion-content as those will update the scroll position.
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* (C) Ionic http://ionicframework.com - MIT License
|
|
3
3
|
*/
|
|
4
4
|
import { expect } from "@playwright/test";
|
|
5
|
+
/**
|
|
6
|
+
* Warning: This function will fail when in RTL mode.
|
|
7
|
+
* TODO(FW-3711): Remove the `directions` config when this issue preventing
|
|
8
|
+
* tests from passing in RTL mode is resolved.
|
|
9
|
+
*/
|
|
5
10
|
export const testSlidingItem = async (page, itemID, screenshotNameSuffix, screenshot, openStart = false) => {
|
|
6
11
|
const item = page.locator(`#${itemID}`);
|
|
7
12
|
// passing a param into the eval callback is tricky due to execution context
|
|
@@ -17,6 +22,9 @@ export const testSlidingItem = async (page, itemID, screenshotNameSuffix, screen
|
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
24
|
// opening animation takes longer than waitForChanges accounts for
|
|
25
|
+
// especially if another item sliding is already open,
|
|
26
|
+
// so we wait to ensure the opened item is closed before
|
|
27
|
+
// opening another
|
|
20
28
|
await page.waitForTimeout(500);
|
|
21
29
|
await expect(item).toHaveScreenshot(screenshot(`item-sliding-${screenshotNameSuffix}`));
|
|
22
30
|
await item.evaluate(async (el) => {
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2023-09-
|
|
2
|
+
"timestamp": "2023-09-21T19:28:39",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.3.0",
|
|
@@ -10175,6 +10175,43 @@
|
|
|
10175
10175
|
"optional": true,
|
|
10176
10176
|
"required": false
|
|
10177
10177
|
},
|
|
10178
|
+
{
|
|
10179
|
+
"name": "defaultValue",
|
|
10180
|
+
"type": "null | number | string | undefined",
|
|
10181
|
+
"complexType": {
|
|
10182
|
+
"original": "InputValue",
|
|
10183
|
+
"resolved": "null | number | string | undefined",
|
|
10184
|
+
"references": {
|
|
10185
|
+
"InputValue": {
|
|
10186
|
+
"location": "import",
|
|
10187
|
+
"path": "./input-interface",
|
|
10188
|
+
"id": "src/components/input/input-interface.ts::InputValue"
|
|
10189
|
+
}
|
|
10190
|
+
}
|
|
10191
|
+
},
|
|
10192
|
+
"mutable": true,
|
|
10193
|
+
"attr": "default-value",
|
|
10194
|
+
"reflectToAttr": false,
|
|
10195
|
+
"docs": "",
|
|
10196
|
+
"docsTags": [],
|
|
10197
|
+
"default": "this.getValue()",
|
|
10198
|
+
"values": [
|
|
10199
|
+
{
|
|
10200
|
+
"type": "null"
|
|
10201
|
+
},
|
|
10202
|
+
{
|
|
10203
|
+
"type": "number"
|
|
10204
|
+
},
|
|
10205
|
+
{
|
|
10206
|
+
"type": "string"
|
|
10207
|
+
},
|
|
10208
|
+
{
|
|
10209
|
+
"type": "undefined"
|
|
10210
|
+
}
|
|
10211
|
+
],
|
|
10212
|
+
"optional": true,
|
|
10213
|
+
"required": false
|
|
10214
|
+
},
|
|
10178
10215
|
{
|
|
10179
10216
|
"name": "disabled",
|
|
10180
10217
|
"type": "boolean",
|
|
@@ -10896,9 +10933,15 @@
|
|
|
10896
10933
|
"name": "value",
|
|
10897
10934
|
"type": "null | number | string | undefined",
|
|
10898
10935
|
"complexType": {
|
|
10899
|
-
"original": "
|
|
10936
|
+
"original": "InputValue",
|
|
10900
10937
|
"resolved": "null | number | string | undefined",
|
|
10901
|
-
"references": {
|
|
10938
|
+
"references": {
|
|
10939
|
+
"InputValue": {
|
|
10940
|
+
"location": "import",
|
|
10941
|
+
"path": "./input-interface",
|
|
10942
|
+
"id": "src/components/input/input-interface.ts::InputValue"
|
|
10943
|
+
}
|
|
10944
|
+
}
|
|
10902
10945
|
},
|
|
10903
10946
|
"mutable": true,
|
|
10904
10947
|
"attr": "value",
|
|
@@ -29015,6 +29058,11 @@
|
|
|
29015
29058
|
"docstring": "",
|
|
29016
29059
|
"path": "src/interface.d.ts"
|
|
29017
29060
|
},
|
|
29061
|
+
"src/components/input/input-interface.ts::InputValue": {
|
|
29062
|
+
"declaration": "export type InputValue = string | number | null | undefined;",
|
|
29063
|
+
"docstring": "",
|
|
29064
|
+
"path": "src/components/input/input-interface.ts"
|
|
29065
|
+
},
|
|
29018
29066
|
"src/components/input/input-interface.ts::InputInputEventDetail": {
|
|
29019
29067
|
"declaration": "export interface InputInputEventDetail {\n value?: string | null;\n event?: Event;\n}",
|
|
29020
29068
|
"docstring": "",
|
|
@@ -121,6 +121,7 @@ const Input = class {
|
|
|
121
121
|
this.size = undefined;
|
|
122
122
|
this.type = 'text';
|
|
123
123
|
this.value = '';
|
|
124
|
+
this.defaultValue = this.getValue();
|
|
124
125
|
}
|
|
125
126
|
debounceChanged() {
|
|
126
127
|
const { ionInput, debounce, originalIonInput } = this;
|
|
@@ -158,6 +159,9 @@ const Input = class {
|
|
|
158
159
|
}
|
|
159
160
|
this.emitStyle();
|
|
160
161
|
}
|
|
162
|
+
defaultValueChanged(newValue) {
|
|
163
|
+
this.value = this.defaultValue = this.getValue(newValue);
|
|
164
|
+
}
|
|
161
165
|
componentWillLoad() {
|
|
162
166
|
this.inheritedAttributes = Object.assign(Object.assign({}, inheritAriaAttributes(this.el)), inheritAttributes(this.el, ['tabindex', 'title', 'data-form-type']));
|
|
163
167
|
}
|
|
@@ -176,6 +180,11 @@ const Input = class {
|
|
|
176
180
|
}
|
|
177
181
|
componentDidLoad() {
|
|
178
182
|
this.originalIonInput = this.ionInput;
|
|
183
|
+
if (this.value === '' || this.value == null) {
|
|
184
|
+
if (this.defaultValue !== '') {
|
|
185
|
+
this.value = this.getValue(this.defaultValue);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
179
188
|
}
|
|
180
189
|
componentDidRender() {
|
|
181
190
|
var _a;
|
|
@@ -244,8 +253,8 @@ const Input = class {
|
|
|
244
253
|
const { type, clearOnEdit } = this;
|
|
245
254
|
return clearOnEdit === undefined ? type === 'password' : clearOnEdit;
|
|
246
255
|
}
|
|
247
|
-
getValue() {
|
|
248
|
-
return typeof
|
|
256
|
+
getValue(value = this.value) {
|
|
257
|
+
return typeof value === 'number' ? value.toString() : (value || '').toString();
|
|
249
258
|
}
|
|
250
259
|
emitStyle() {
|
|
251
260
|
if (this.legacyFormController.hasLegacyControl()) {
|
|
@@ -364,6 +373,7 @@ const Input = class {
|
|
|
364
373
|
const { disabled, fill, readonly, shape, inputId, labelPlacement } = this;
|
|
365
374
|
const mode = getIonMode(this);
|
|
366
375
|
const value = this.getValue();
|
|
376
|
+
const defaultValue = this.getValue(this.defaultValue);
|
|
367
377
|
const inItem = hostContext('ion-item', this.el);
|
|
368
378
|
const shouldRenderHighlight = mode === 'md' && fill !== 'outline' && !inItem;
|
|
369
379
|
return (h(Host, { class: createColorClasses(this.color, {
|
|
@@ -376,7 +386,7 @@ const Input = class {
|
|
|
376
386
|
'in-item': inItem,
|
|
377
387
|
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
|
378
388
|
'input-disabled': disabled,
|
|
379
|
-
}) }, h("label", { class: "input-wrapper" }, this.renderLabelContainer(), h("div", { class: "native-wrapper" }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), id: inputId, disabled: disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown, onCompositionstart: this.onCompositionStart, onCompositionend: this.onCompositionEnd }, this.inheritedAttributes)), this.clearInput && !readonly && !disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
389
|
+
}) }, h("label", { class: "input-wrapper" }, this.renderLabelContainer(), h("div", { class: "native-wrapper" }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), id: inputId, disabled: disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, defaultValue: defaultValue, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown, onCompositionstart: this.onCompositionStart, onCompositionend: this.onCompositionEnd }, this.inheritedAttributes)), this.clearInput && !readonly && !disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
380
390
|
/**
|
|
381
391
|
* This prevents mobile browsers from
|
|
382
392
|
* blurring the input when the clear
|
|
@@ -405,6 +415,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
405
415
|
}
|
|
406
416
|
const mode = getIonMode(this);
|
|
407
417
|
const value = this.getValue();
|
|
418
|
+
const defaultValue = this.getValue(this.defaultValue);
|
|
408
419
|
const labelId = this.inputId + '-lbl';
|
|
409
420
|
const label = findItemLabel(this.el);
|
|
410
421
|
if (label) {
|
|
@@ -416,7 +427,7 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
416
427
|
'has-focus': this.hasFocus,
|
|
417
428
|
'legacy-input': true,
|
|
418
429
|
'in-item-color': hostContext('ion-item.ion-color', this.el),
|
|
419
|
-
}) }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), "aria-labelledby": label ? label.id : null, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown }, this.inheritedAttributes)), this.clearInput && !this.readonly && !this.disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
430
|
+
}) }, h("input", Object.assign({ class: "native-input", ref: (input) => (this.nativeInput = input), "aria-labelledby": label ? label.id : null, disabled: this.disabled, accept: this.accept, autoCapitalize: this.autocapitalize, autoComplete: this.autocomplete, autoCorrect: this.autocorrect, autoFocus: this.autofocus, enterKeyHint: this.enterkeyhint, inputMode: this.inputmode, min: this.min, max: this.max, minLength: this.minlength, maxLength: this.maxlength, multiple: this.multiple, name: this.name, pattern: this.pattern, placeholder: this.placeholder || '', readOnly: this.readonly, required: this.required, spellcheck: this.spellcheck, step: this.step, size: this.size, type: this.type, value: value, defaultValue: defaultValue, onInput: this.onInput, onChange: this.onChange, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown }, this.inheritedAttributes)), this.clearInput && !this.readonly && !this.disabled && (h("button", { "aria-label": "reset", type: "button", class: "input-clear-icon", onPointerDown: (ev) => {
|
|
420
431
|
/**
|
|
421
432
|
* This prevents mobile browsers from
|
|
422
433
|
* blurring the input when the clear
|
|
@@ -434,7 +445,8 @@ Developers can dismiss this warning by removing their usage of the "legacy" prop
|
|
|
434
445
|
"debounce": ["debounceChanged"],
|
|
435
446
|
"disabled": ["disabledChanged"],
|
|
436
447
|
"placeholder": ["placeholderChanged"],
|
|
437
|
-
"value": ["valueChanged"]
|
|
448
|
+
"value": ["valueChanged"],
|
|
449
|
+
"defaultValue": ["defaultValueChanged"]
|
|
438
450
|
}; }
|
|
439
451
|
};
|
|
440
452
|
let inputIds = 0;
|