@maggioli-design-system/mds-input 7.4.2 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mds-input.cjs.entry.js +53 -8
- package/dist/cjs/mds-input.cjs.js +1 -1
- package/dist/collection/components/mds-input/mds-input.js +59 -10
- package/dist/collection/components/mds-input/test/mds-input.stories.js +6 -0
- package/dist/collection/type/input-tip.js +1 -0
- package/dist/components/mds-input.js +57 -9
- package/dist/documentation.json +7 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mds-input.entry.js +53 -8
- package/dist/esm/mds-input.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-input.entry.js +1 -1
- package/dist/esm-es5/mds-input.js +1 -1
- package/dist/mds-input/mds-input.esm.js +1 -1
- package/dist/mds-input/p-3d99713e.system.js +1 -1
- package/dist/mds-input/{p-231a1ba8.system.entry.js → p-5772c2c0.system.entry.js} +1 -1
- package/dist/mds-input/p-9fd1ecc7.entry.js +6 -0
- package/dist/stats.json +40 -21
- package/dist/types/components/mds-input/mds-input.d.ts +9 -3
- package/dist/types/components/mds-input/test/mds-input.stories.d.ts +1 -0
- package/dist/types/components.d.ts +2 -2
- package/dist/types/type/input-tip.d.ts +1 -0
- package/documentation.json +10 -6
- package/package.json +3 -3
- package/readme.md +29 -43
- package/src/components/mds-input/mds-input.tsx +57 -4
- package/src/components/mds-input/readme.md +28 -27
- package/src/components/mds-input/test/mds-input.stories.tsx +7 -0
- package/src/components.d.ts +2 -2
- package/src/type/input-tip.ts +11 -0
- package/www/build/mds-input.esm.js +1 -1
- package/www/build/p-3d99713e.system.js +1 -1
- package/www/build/{p-231a1ba8.system.entry.js → p-5772c2c0.system.entry.js} +1 -1
- package/www/build/p-9fd1ecc7.entry.js +6 -0
- package/dist/mds-input/p-49bf8765.entry.js +0 -6
- package/www/build/p-49bf8765.entry.js +0 -6
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["mds-input.cjs",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[
|
|
11
|
+
return index.bootstrapLazy([["mds-input.cjs",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[1538],"min":[520],"minlength":[514],"name":[513],"pattern":[513],"placeholder":[513],"readonly":[516],"required":[516],"variant":[513],"tip":[513],"step":[513],"type":[513],"typography":[513],"value":[1537],"hasFocus":[32],"language":[32],"currentLengthLabel":[32],"countVariant":[32],"isPasswordVisible":[32],"updateLang":[64],"setFocus":[64],"getInputElement":[64]},null,{"value":["valueChanged"],"maxlength":["maxLengthChanged"],"disabled":["disabledChanged"]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|
|
@@ -922,6 +922,7 @@ const MdsInput = class {
|
|
|
922
922
|
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
923
923
|
}
|
|
924
924
|
this.hasFocus = false;
|
|
925
|
+
this.countVariant = 'count-empty';
|
|
925
926
|
this.isPasswordVisible = false;
|
|
926
927
|
this.t = new Locale({
|
|
927
928
|
el: localeEl,
|
|
@@ -985,6 +986,36 @@ const MdsInput = class {
|
|
|
985
986
|
* Specifies the value of the input element
|
|
986
987
|
*/
|
|
987
988
|
this.value = '';
|
|
989
|
+
this.countMaxLength = () => {
|
|
990
|
+
var _a, _b, _c;
|
|
991
|
+
if (!this.maxlength)
|
|
992
|
+
return;
|
|
993
|
+
if (this.value === undefined)
|
|
994
|
+
return;
|
|
995
|
+
this.currentLengthLabel = `${(_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} / ${this.maxlength}`;
|
|
996
|
+
const completionPerc = Math.round(this.value.length * 100 / this.maxlength);
|
|
997
|
+
if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) === this.maxlength) {
|
|
998
|
+
this.countVariant = 'count-full';
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (completionPerc >= 100) {
|
|
1002
|
+
this.countVariant = 'count-full';
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (completionPerc >= 75) {
|
|
1006
|
+
this.countVariant = 'count-almost-full';
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (completionPerc >= 50) {
|
|
1010
|
+
this.countVariant = 'count-almost';
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
if (completionPerc >= 25) {
|
|
1014
|
+
this.countVariant = 'count-incomplete';
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
this.countVariant = 'count-empty';
|
|
1018
|
+
};
|
|
988
1019
|
this.onInput = (ev) => {
|
|
989
1020
|
const input = ev.target;
|
|
990
1021
|
if (input) {
|
|
@@ -1041,6 +1072,7 @@ const MdsInput = class {
|
|
|
1041
1072
|
this.el.removeAttribute('tabindex');
|
|
1042
1073
|
}
|
|
1043
1074
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1075
|
+
this.maxLengthChanged(this.maxlength);
|
|
1044
1076
|
}
|
|
1045
1077
|
/**
|
|
1046
1078
|
* Emits the change event when the component value changes
|
|
@@ -1049,6 +1081,18 @@ const MdsInput = class {
|
|
|
1049
1081
|
var _a;
|
|
1050
1082
|
this.changeEvent.emit({ value: this.value });
|
|
1051
1083
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1084
|
+
if (this.maxlength !== undefined) {
|
|
1085
|
+
this.countMaxLength();
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
maxLengthChanged(newValue) {
|
|
1089
|
+
if (newValue === undefined)
|
|
1090
|
+
return;
|
|
1091
|
+
if (newValue <= 0) {
|
|
1092
|
+
this.maxlength = undefined;
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
this.countMaxLength();
|
|
1052
1096
|
}
|
|
1053
1097
|
disabledChanged(newValue) {
|
|
1054
1098
|
/**
|
|
@@ -1082,25 +1126,26 @@ const MdsInput = class {
|
|
|
1082
1126
|
}
|
|
1083
1127
|
render() {
|
|
1084
1128
|
var _a, _b;
|
|
1085
|
-
return (index.h(index.Host, { key: '
|
|
1129
|
+
return (index.h(index.Host, { key: '092c047d986f352fb6619c0226ee298ba7c47b5d' }, this.type === 'number'
|
|
1086
1130
|
&& this.controlsLayout === 'horizontal'
|
|
1087
|
-
&& index.h("mds-button", { key: '
|
|
1131
|
+
&& index.h("mds-button", { key: '8d1102c0c344ef165aa8362f07a70c5c15486497', class: "counter-button counter-button--horizontal counter-button--decrease", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" }), this.type === 'textarea'
|
|
1088
1132
|
? index.h("textarea", { class: clsx('input', ((_a = this.icon) !== null && _a !== void 0 ? _a : this.await) && 'has-icon'), autoFocus: this.autofocus, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, tabIndex: this.tabindex, value: this.value })
|
|
1089
1133
|
: index.h("input", { class: clsx('input', ((_b = this.icon) !== null && _b !== void 0 ? _b : this.await) && 'has-icon'), autoComplete: this.autocomplete, autoFocus: this.autofocus, disabled: this.disabled, max: this.max, maxLength: this.maxlength, min: this.min, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, pattern: this.pattern, list: this.datalist && 'datalist', part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, step: this.step, tabIndex: this.tabindex, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, value: this.value }), this.type === 'number'
|
|
1090
1134
|
&& this.controlsLayout === 'vertical'
|
|
1091
|
-
&& index.h("div", { key: '
|
|
1135
|
+
&& index.h("div", { key: 'cb9f7381220cc239be4a7b0496632f712b5884a8', class: "counter counter--vertical" }, index.h("mds-button", { key: '811d62fc18062aa87d3c2feb367ea0ff5a8b96ee', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), index.h("mds-button", { key: '1da6e70684e4c54ffc5fd6e46ee72e93fa71c92e', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" })), this.type === 'number'
|
|
1092
1136
|
&& this.controlsLayout === 'horizontal'
|
|
1093
|
-
&& index.h("mds-button", { key: '
|
|
1094
|
-
&& index.h("mds-button", { key: '
|
|
1095
|
-
index.h("mds-input-tip-item", { key: '
|
|
1096
|
-
index.h("datalist", { key: '
|
|
1137
|
+
&& index.h("mds-button", { key: 'c272f0e9fd2af1f2947a82c8954a33b91ec8952b', class: "counter-button counter-button--horizontal counter-button--increase", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), this.type === 'password'
|
|
1138
|
+
&& index.h("mds-button", { key: '2276154fb4451cf52f0fb806c4bd206299a75798', class: "password-toggle-button", icon: this.isPasswordVisible ? miBaselineVisibleOff : miBaselineVisible, onClick: () => this.isPasswordVisible = !this.isPasswordVisible, role: "button", tabindex: "0", tone: "quiet", title: this.isPasswordVisible ? this.t.get('hidePassword') : this.t.get('showPassword'), part: "password-toggle-button" }), index.h("mds-input-tip", { key: '0b8733d237a76ebc88c0a57bb9b3bd23608a21aa', lang: this.language, position: "top", active: this.hasFocus }, this.disabled && index.h("mds-input-tip-item", { key: 'ba27f229ed7eab375381ba4e84979a738e33a14e', expanded: true, variant: "disabled" }), this.readonly && index.h("mds-input-tip-item", { key: '8acbfe6d3df8d1500b23a217fbb595470e9fef34', expanded: true, variant: "readonly" }), this.required &&
|
|
1139
|
+
index.h("mds-input-tip-item", { key: '85605f3ecd99fb27e219273c5f7e22c2059389d9', expanded: this.hasFocus, variant: this.value === '' ? 'required' : 'required-success' })), index.h("mds-input-tip", { key: '8550422b58133c91848038dd29c09e2e7bcecbe4', lang: this.language, position: "bottom", active: this.hasFocus }, this.tip && index.h("mds-input-tip-item", { key: '65de4760bffbd1c938c440a6112d04bcbfe2f62d', expanded: true, variant: "text" }, this.tip), this.maxlength && index.h("mds-input-tip-item", { key: 'f47b47b2fcd1cc20f834596e1dd2b74f1ca7b4b5', part: "tip-count", expanded: true, variant: this.countVariant }, this.currentLengthLabel)), this.datalist &&
|
|
1140
|
+
index.h("datalist", { key: 'bdc3f13692b00dae9e034f33f450ab4f4d6260f6', id: "datalist", class: "datalist" }, this.datalist.forEach(element => {
|
|
1097
1141
|
index.h("option", { value: element });
|
|
1098
|
-
})), this.icon && !this.await && index.h("mds-icon", { key: '
|
|
1142
|
+
})), this.icon && !this.await && index.h("mds-icon", { key: '890a24ac77cea5ceac8c8ac10d9995fd1e76a3f1', class: clsx('icon', this.variant), name: this.icon }), index.h("mds-spinner", { key: '83bea6775de9cabd0d399dcd547404a42a739730', running: this.await, class: clsx('await', this.variant) })));
|
|
1099
1143
|
}
|
|
1100
1144
|
static get formAssociated() { return true; }
|
|
1101
1145
|
get el() { return index.getElement(this); }
|
|
1102
1146
|
static get watchers() { return {
|
|
1103
1147
|
"value": ["valueChanged"],
|
|
1148
|
+
"maxlength": ["maxLengthChanged"],
|
|
1104
1149
|
"disabled": ["disabledChanged"]
|
|
1105
1150
|
}; }
|
|
1106
1151
|
};
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["mds-input.cjs",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[
|
|
22
|
+
return index.bootstrapLazy([["mds-input.cjs",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[1538],"min":[520],"minlength":[514],"name":[513],"pattern":[513],"placeholder":[513],"readonly":[516],"required":[516],"variant":[513],"tip":[513],"step":[513],"type":[513],"typography":[513],"value":[1537],"hasFocus":[32],"language":[32],"currentLengthLabel":[32],"countVariant":[32],"isPasswordVisible":[32],"updateLang":[64],"setFocus":[64],"getInputElement":[64]},null,{"value":["valueChanged"],"maxlength":["maxLengthChanged"],"disabled":["disabledChanged"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
|
@@ -14,6 +14,7 @@ import localeIt from "./meta/locale.it.json";
|
|
|
14
14
|
export class MdsInput {
|
|
15
15
|
constructor() {
|
|
16
16
|
this.hasFocus = false;
|
|
17
|
+
this.countVariant = 'count-empty';
|
|
17
18
|
this.isPasswordVisible = false;
|
|
18
19
|
this.t = new Locale({
|
|
19
20
|
el: localeEl,
|
|
@@ -77,6 +78,36 @@ export class MdsInput {
|
|
|
77
78
|
* Specifies the value of the input element
|
|
78
79
|
*/
|
|
79
80
|
this.value = '';
|
|
81
|
+
this.countMaxLength = () => {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
if (!this.maxlength)
|
|
84
|
+
return;
|
|
85
|
+
if (this.value === undefined)
|
|
86
|
+
return;
|
|
87
|
+
this.currentLengthLabel = `${(_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} / ${this.maxlength}`;
|
|
88
|
+
const completionPerc = Math.round(this.value.length * 100 / this.maxlength);
|
|
89
|
+
if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) === this.maxlength) {
|
|
90
|
+
this.countVariant = 'count-full';
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (completionPerc >= 100) {
|
|
94
|
+
this.countVariant = 'count-full';
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (completionPerc >= 75) {
|
|
98
|
+
this.countVariant = 'count-almost-full';
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (completionPerc >= 50) {
|
|
102
|
+
this.countVariant = 'count-almost';
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (completionPerc >= 25) {
|
|
106
|
+
this.countVariant = 'count-incomplete';
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.countVariant = 'count-empty';
|
|
110
|
+
};
|
|
80
111
|
this.onInput = (ev) => {
|
|
81
112
|
const input = ev.target;
|
|
82
113
|
if (input) {
|
|
@@ -133,6 +164,7 @@ export class MdsInput {
|
|
|
133
164
|
this.el.removeAttribute('tabindex');
|
|
134
165
|
}
|
|
135
166
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
167
|
+
this.maxLengthChanged(this.maxlength);
|
|
136
168
|
}
|
|
137
169
|
/**
|
|
138
170
|
* Emits the change event when the component value changes
|
|
@@ -141,6 +173,18 @@ export class MdsInput {
|
|
|
141
173
|
var _a;
|
|
142
174
|
this.changeEvent.emit({ value: this.value });
|
|
143
175
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
176
|
+
if (this.maxlength !== undefined) {
|
|
177
|
+
this.countMaxLength();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
maxLengthChanged(newValue) {
|
|
181
|
+
if (newValue === undefined)
|
|
182
|
+
return;
|
|
183
|
+
if (newValue <= 0) {
|
|
184
|
+
this.maxlength = undefined;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.countMaxLength();
|
|
144
188
|
}
|
|
145
189
|
disabledChanged(newValue) {
|
|
146
190
|
/**
|
|
@@ -174,20 +218,20 @@ export class MdsInput {
|
|
|
174
218
|
}
|
|
175
219
|
render() {
|
|
176
220
|
var _a, _b;
|
|
177
|
-
return (h(Host, { key: '
|
|
221
|
+
return (h(Host, { key: '092c047d986f352fb6619c0226ee298ba7c47b5d' }, this.type === 'number'
|
|
178
222
|
&& this.controlsLayout === 'horizontal'
|
|
179
|
-
&& h("mds-button", { key: '
|
|
223
|
+
&& h("mds-button", { key: '8d1102c0c344ef165aa8362f07a70c5c15486497', class: "counter-button counter-button--horizontal counter-button--decrease", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" }), this.type === 'textarea'
|
|
180
224
|
? h("textarea", { class: clsx('input', ((_a = this.icon) !== null && _a !== void 0 ? _a : this.await) && 'has-icon'), autoFocus: this.autofocus, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, tabIndex: this.tabindex, value: this.value })
|
|
181
225
|
: h("input", { class: clsx('input', ((_b = this.icon) !== null && _b !== void 0 ? _b : this.await) && 'has-icon'), autoComplete: this.autocomplete, autoFocus: this.autofocus, disabled: this.disabled, max: this.max, maxLength: this.maxlength, min: this.min, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, pattern: this.pattern, list: this.datalist && 'datalist', part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, step: this.step, tabIndex: this.tabindex, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, value: this.value }), this.type === 'number'
|
|
182
226
|
&& this.controlsLayout === 'vertical'
|
|
183
|
-
&& h("div", { key: '
|
|
227
|
+
&& h("div", { key: 'cb9f7381220cc239be4a7b0496632f712b5884a8', class: "counter counter--vertical" }, h("mds-button", { key: '811d62fc18062aa87d3c2feb367ea0ff5a8b96ee', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), h("mds-button", { key: '1da6e70684e4c54ffc5fd6e46ee72e93fa71c92e', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" })), this.type === 'number'
|
|
184
228
|
&& this.controlsLayout === 'horizontal'
|
|
185
|
-
&& h("mds-button", { key: '
|
|
186
|
-
&& h("mds-button", { key: '
|
|
187
|
-
h("mds-input-tip-item", { key: '
|
|
188
|
-
h("datalist", { key: '
|
|
229
|
+
&& h("mds-button", { key: 'c272f0e9fd2af1f2947a82c8954a33b91ec8952b', class: "counter-button counter-button--horizontal counter-button--increase", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), this.type === 'password'
|
|
230
|
+
&& h("mds-button", { key: '2276154fb4451cf52f0fb806c4bd206299a75798', class: "password-toggle-button", icon: this.isPasswordVisible ? miBaselineVisibleOff : miBaselineVisible, onClick: () => this.isPasswordVisible = !this.isPasswordVisible, role: "button", tabindex: "0", tone: "quiet", title: this.isPasswordVisible ? this.t.get('hidePassword') : this.t.get('showPassword'), part: "password-toggle-button" }), h("mds-input-tip", { key: '0b8733d237a76ebc88c0a57bb9b3bd23608a21aa', lang: this.language, position: "top", active: this.hasFocus }, this.disabled && h("mds-input-tip-item", { key: 'ba27f229ed7eab375381ba4e84979a738e33a14e', expanded: true, variant: "disabled" }), this.readonly && h("mds-input-tip-item", { key: '8acbfe6d3df8d1500b23a217fbb595470e9fef34', expanded: true, variant: "readonly" }), this.required &&
|
|
231
|
+
h("mds-input-tip-item", { key: '85605f3ecd99fb27e219273c5f7e22c2059389d9', expanded: this.hasFocus, variant: this.value === '' ? 'required' : 'required-success' })), h("mds-input-tip", { key: '8550422b58133c91848038dd29c09e2e7bcecbe4', lang: this.language, position: "bottom", active: this.hasFocus }, this.tip && h("mds-input-tip-item", { key: '65de4760bffbd1c938c440a6112d04bcbfe2f62d', expanded: true, variant: "text" }, this.tip), this.maxlength && h("mds-input-tip-item", { key: 'f47b47b2fcd1cc20f834596e1dd2b74f1ca7b4b5', part: "tip-count", expanded: true, variant: this.countVariant }, this.currentLengthLabel)), this.datalist &&
|
|
232
|
+
h("datalist", { key: 'bdc3f13692b00dae9e034f33f450ab4f4d6260f6', id: "datalist", class: "datalist" }, this.datalist.forEach(element => {
|
|
189
233
|
h("option", { value: element });
|
|
190
|
-
})), this.icon && !this.await && h("mds-icon", { key: '
|
|
234
|
+
})), this.icon && !this.await && h("mds-icon", { key: '890a24ac77cea5ceac8c8ac10d9995fd1e76a3f1', class: clsx('icon', this.variant), name: this.icon }), h("mds-spinner", { key: '83bea6775de9cabd0d399dcd547404a42a739730', running: this.await, class: clsx('await', this.variant) })));
|
|
191
235
|
}
|
|
192
236
|
static get is() { return "mds-input"; }
|
|
193
237
|
static get encapsulation() { return "shadow"; }
|
|
@@ -439,7 +483,7 @@ export class MdsInput {
|
|
|
439
483
|
},
|
|
440
484
|
"maxlength": {
|
|
441
485
|
"type": "number",
|
|
442
|
-
"mutable":
|
|
486
|
+
"mutable": true,
|
|
443
487
|
"complexType": {
|
|
444
488
|
"original": "number",
|
|
445
489
|
"resolved": "number | undefined",
|
|
@@ -449,7 +493,7 @@ export class MdsInput {
|
|
|
449
493
|
"optional": true,
|
|
450
494
|
"docs": {
|
|
451
495
|
"tags": [],
|
|
452
|
-
"text": "Specifies the maximum number of characters allowed in an element
|
|
496
|
+
"text": "Specifies the maximum number of characters allowed in an element.\nUse it with input type=\"text\".\nIf maxlength is set to 0 or a negative number it will be considered as undefined."
|
|
453
497
|
},
|
|
454
498
|
"getter": false,
|
|
455
499
|
"setter": false,
|
|
@@ -733,6 +777,8 @@ export class MdsInput {
|
|
|
733
777
|
return {
|
|
734
778
|
"hasFocus": {},
|
|
735
779
|
"language": {},
|
|
780
|
+
"currentLengthLabel": {},
|
|
781
|
+
"countVariant": {},
|
|
736
782
|
"isPasswordVisible": {}
|
|
737
783
|
};
|
|
738
784
|
}
|
|
@@ -878,6 +924,9 @@ export class MdsInput {
|
|
|
878
924
|
return [{
|
|
879
925
|
"propName": "value",
|
|
880
926
|
"methodName": "valueChanged"
|
|
927
|
+
}, {
|
|
928
|
+
"propName": "maxlength",
|
|
929
|
+
"methodName": "maxLengthChanged"
|
|
881
930
|
}, {
|
|
882
931
|
"propName": "disabled",
|
|
883
932
|
"methodName": "disabledChanged"
|
|
@@ -171,6 +171,12 @@ Max.args = {
|
|
|
171
171
|
type: 'number',
|
|
172
172
|
value: '2',
|
|
173
173
|
};
|
|
174
|
+
export const MaxLength = Template.bind({});
|
|
175
|
+
MaxLength.args = {
|
|
176
|
+
maxlength: 128,
|
|
177
|
+
type: 'text',
|
|
178
|
+
value: 'Hello',
|
|
179
|
+
};
|
|
174
180
|
export const Min = Template.bind({});
|
|
175
181
|
Min.args = {
|
|
176
182
|
min: '3',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -914,6 +914,7 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
914
914
|
this.focusEvent = createEvent(this, "mdsInputFocus", 7);
|
|
915
915
|
this.internals = this.attachInternals();
|
|
916
916
|
this.hasFocus = false;
|
|
917
|
+
this.countVariant = 'count-empty';
|
|
917
918
|
this.isPasswordVisible = false;
|
|
918
919
|
this.t = new Locale({
|
|
919
920
|
el: localeEl,
|
|
@@ -977,6 +978,36 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
977
978
|
* Specifies the value of the input element
|
|
978
979
|
*/
|
|
979
980
|
this.value = '';
|
|
981
|
+
this.countMaxLength = () => {
|
|
982
|
+
var _a, _b, _c;
|
|
983
|
+
if (!this.maxlength)
|
|
984
|
+
return;
|
|
985
|
+
if (this.value === undefined)
|
|
986
|
+
return;
|
|
987
|
+
this.currentLengthLabel = `${(_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} / ${this.maxlength}`;
|
|
988
|
+
const completionPerc = Math.round(this.value.length * 100 / this.maxlength);
|
|
989
|
+
if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) === this.maxlength) {
|
|
990
|
+
this.countVariant = 'count-full';
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (completionPerc >= 100) {
|
|
994
|
+
this.countVariant = 'count-full';
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (completionPerc >= 75) {
|
|
998
|
+
this.countVariant = 'count-almost-full';
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (completionPerc >= 50) {
|
|
1002
|
+
this.countVariant = 'count-almost';
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (completionPerc >= 25) {
|
|
1006
|
+
this.countVariant = 'count-incomplete';
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
this.countVariant = 'count-empty';
|
|
1010
|
+
};
|
|
980
1011
|
this.onInput = (ev) => {
|
|
981
1012
|
const input = ev.target;
|
|
982
1013
|
if (input) {
|
|
@@ -1033,6 +1064,7 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
1033
1064
|
this.el.removeAttribute('tabindex');
|
|
1034
1065
|
}
|
|
1035
1066
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1067
|
+
this.maxLengthChanged(this.maxlength);
|
|
1036
1068
|
}
|
|
1037
1069
|
/**
|
|
1038
1070
|
* Emits the change event when the component value changes
|
|
@@ -1041,6 +1073,18 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
1041
1073
|
var _a;
|
|
1042
1074
|
this.changeEvent.emit({ value: this.value });
|
|
1043
1075
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1076
|
+
if (this.maxlength !== undefined) {
|
|
1077
|
+
this.countMaxLength();
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
maxLengthChanged(newValue) {
|
|
1081
|
+
if (newValue === undefined)
|
|
1082
|
+
return;
|
|
1083
|
+
if (newValue <= 0) {
|
|
1084
|
+
this.maxlength = undefined;
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
this.countMaxLength();
|
|
1044
1088
|
}
|
|
1045
1089
|
disabledChanged(newValue) {
|
|
1046
1090
|
/**
|
|
@@ -1074,25 +1118,26 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
1074
1118
|
}
|
|
1075
1119
|
render() {
|
|
1076
1120
|
var _a, _b;
|
|
1077
|
-
return (h(Host, { key: '
|
|
1121
|
+
return (h(Host, { key: '092c047d986f352fb6619c0226ee298ba7c47b5d' }, this.type === 'number'
|
|
1078
1122
|
&& this.controlsLayout === 'horizontal'
|
|
1079
|
-
&& h("mds-button", { key: '
|
|
1123
|
+
&& h("mds-button", { key: '8d1102c0c344ef165aa8362f07a70c5c15486497', class: "counter-button counter-button--horizontal counter-button--decrease", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" }), this.type === 'textarea'
|
|
1080
1124
|
? h("textarea", { class: clsx('input', ((_a = this.icon) !== null && _a !== void 0 ? _a : this.await) && 'has-icon'), autoFocus: this.autofocus, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, tabIndex: this.tabindex, value: this.value })
|
|
1081
1125
|
: h("input", { class: clsx('input', ((_b = this.icon) !== null && _b !== void 0 ? _b : this.await) && 'has-icon'), autoComplete: this.autocomplete, autoFocus: this.autofocus, disabled: this.disabled, max: this.max, maxLength: this.maxlength, min: this.min, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, pattern: this.pattern, list: this.datalist && 'datalist', part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, step: this.step, tabIndex: this.tabindex, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, value: this.value }), this.type === 'number'
|
|
1082
1126
|
&& this.controlsLayout === 'vertical'
|
|
1083
|
-
&& h("div", { key: '
|
|
1127
|
+
&& h("div", { key: 'cb9f7381220cc239be4a7b0496632f712b5884a8', class: "counter counter--vertical" }, h("mds-button", { key: '811d62fc18062aa87d3c2feb367ea0ff5a8b96ee', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), h("mds-button", { key: '1da6e70684e4c54ffc5fd6e46ee72e93fa71c92e', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" })), this.type === 'number'
|
|
1084
1128
|
&& this.controlsLayout === 'horizontal'
|
|
1085
|
-
&& h("mds-button", { key: '
|
|
1086
|
-
&& h("mds-button", { key: '
|
|
1087
|
-
h("mds-input-tip-item", { key: '
|
|
1088
|
-
h("datalist", { key: '
|
|
1129
|
+
&& h("mds-button", { key: 'c272f0e9fd2af1f2947a82c8954a33b91ec8952b', class: "counter-button counter-button--horizontal counter-button--increase", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), this.type === 'password'
|
|
1130
|
+
&& h("mds-button", { key: '2276154fb4451cf52f0fb806c4bd206299a75798', class: "password-toggle-button", icon: this.isPasswordVisible ? miBaselineVisibleOff : miBaselineVisible, onClick: () => this.isPasswordVisible = !this.isPasswordVisible, role: "button", tabindex: "0", tone: "quiet", title: this.isPasswordVisible ? this.t.get('hidePassword') : this.t.get('showPassword'), part: "password-toggle-button" }), h("mds-input-tip", { key: '0b8733d237a76ebc88c0a57bb9b3bd23608a21aa', lang: this.language, position: "top", active: this.hasFocus }, this.disabled && h("mds-input-tip-item", { key: 'ba27f229ed7eab375381ba4e84979a738e33a14e', expanded: true, variant: "disabled" }), this.readonly && h("mds-input-tip-item", { key: '8acbfe6d3df8d1500b23a217fbb595470e9fef34', expanded: true, variant: "readonly" }), this.required &&
|
|
1131
|
+
h("mds-input-tip-item", { key: '85605f3ecd99fb27e219273c5f7e22c2059389d9', expanded: this.hasFocus, variant: this.value === '' ? 'required' : 'required-success' })), h("mds-input-tip", { key: '8550422b58133c91848038dd29c09e2e7bcecbe4', lang: this.language, position: "bottom", active: this.hasFocus }, this.tip && h("mds-input-tip-item", { key: '65de4760bffbd1c938c440a6112d04bcbfe2f62d', expanded: true, variant: "text" }, this.tip), this.maxlength && h("mds-input-tip-item", { key: 'f47b47b2fcd1cc20f834596e1dd2b74f1ca7b4b5', part: "tip-count", expanded: true, variant: this.countVariant }, this.currentLengthLabel)), this.datalist &&
|
|
1132
|
+
h("datalist", { key: 'bdc3f13692b00dae9e034f33f450ab4f4d6260f6', id: "datalist", class: "datalist" }, this.datalist.forEach(element => {
|
|
1089
1133
|
h("option", { value: element });
|
|
1090
|
-
})), this.icon && !this.await && h("mds-icon", { key: '
|
|
1134
|
+
})), this.icon && !this.await && h("mds-icon", { key: '890a24ac77cea5ceac8c8ac10d9995fd1e76a3f1', class: clsx('icon', this.variant), name: this.icon }), h("mds-spinner", { key: '83bea6775de9cabd0d399dcd547404a42a739730', running: this.await, class: clsx('await', this.variant) })));
|
|
1091
1135
|
}
|
|
1092
1136
|
static get formAssociated() { return true; }
|
|
1093
1137
|
get el() { return this; }
|
|
1094
1138
|
static get watchers() { return {
|
|
1095
1139
|
"value": ["valueChanged"],
|
|
1140
|
+
"maxlength": ["maxLengthChanged"],
|
|
1096
1141
|
"disabled": ["disabledChanged"]
|
|
1097
1142
|
}; }
|
|
1098
1143
|
static get style() { return MdsInputStyle0; }
|
|
@@ -1108,7 +1153,7 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
1108
1153
|
"disabled": [516],
|
|
1109
1154
|
"icon": [513],
|
|
1110
1155
|
"max": [513],
|
|
1111
|
-
"maxlength": [
|
|
1156
|
+
"maxlength": [1538],
|
|
1112
1157
|
"min": [520],
|
|
1113
1158
|
"minlength": [514],
|
|
1114
1159
|
"name": [513],
|
|
@@ -1124,12 +1169,15 @@ const MdsInput$1 = /*@__PURE__*/ proxyCustomElement(class MdsInput extends HTMLE
|
|
|
1124
1169
|
"value": [1537],
|
|
1125
1170
|
"hasFocus": [32],
|
|
1126
1171
|
"language": [32],
|
|
1172
|
+
"currentLengthLabel": [32],
|
|
1173
|
+
"countVariant": [32],
|
|
1127
1174
|
"isPasswordVisible": [32],
|
|
1128
1175
|
"updateLang": [64],
|
|
1129
1176
|
"setFocus": [64],
|
|
1130
1177
|
"getInputElement": [64]
|
|
1131
1178
|
}, undefined, {
|
|
1132
1179
|
"value": ["valueChanged"],
|
|
1180
|
+
"maxlength": ["maxLengthChanged"],
|
|
1133
1181
|
"disabled": ["disabledChanged"]
|
|
1134
1182
|
}]);
|
|
1135
1183
|
function defineCustomElement$1() {
|
package/dist/documentation.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-03-
|
|
2
|
+
"timestamp": "2025-03-18T08:27:31",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.27.2",
|
|
@@ -337,10 +337,10 @@
|
|
|
337
337
|
"resolved": "number | undefined",
|
|
338
338
|
"references": {}
|
|
339
339
|
},
|
|
340
|
-
"mutable":
|
|
340
|
+
"mutable": true,
|
|
341
341
|
"attr": "maxlength",
|
|
342
342
|
"reflectToAttr": true,
|
|
343
|
-
"docs": "Specifies the maximum number of characters allowed in an element
|
|
343
|
+
"docs": "Specifies the maximum number of characters allowed in an element.\nUse it with input type=\"text\".\nIf maxlength is set to 0 or a negative number it will be considered as undefined.",
|
|
344
344
|
"docsTags": [],
|
|
345
345
|
"values": [
|
|
346
346
|
{
|
|
@@ -980,6 +980,10 @@
|
|
|
980
980
|
{
|
|
981
981
|
"name": "password-toggle-button",
|
|
982
982
|
"docs": ""
|
|
983
|
+
},
|
|
984
|
+
{
|
|
985
|
+
"name": "tip-count",
|
|
986
|
+
"docs": ""
|
|
983
987
|
}
|
|
984
988
|
],
|
|
985
989
|
"dependents": [],
|
package/dist/esm/loader.js
CHANGED
|
@@ -5,7 +5,7 @@ import { g as globalScripts } from './app-globals-0f993ce5.js';
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await globalScripts();
|
|
8
|
-
return bootstrapLazy([["mds-input",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[
|
|
8
|
+
return bootstrapLazy([["mds-input",[[65,"mds-input",{"autocomplete":[513],"autofocus":[516],"await":[516],"controlsLayout":[513,"controls-layout"],"controlsIcon":[513,"controls-icon"],"controlIncreaseLabel":[513,"control-increase-label"],"controlDecreaseLabel":[513,"control-decrease-label"],"datalist":[16],"disabled":[516],"icon":[513],"max":[513],"maxlength":[1538],"min":[520],"minlength":[514],"name":[513],"pattern":[513],"placeholder":[513],"readonly":[516],"required":[516],"variant":[513],"tip":[513],"step":[513],"type":[513],"typography":[513],"value":[1537],"hasFocus":[32],"language":[32],"currentLengthLabel":[32],"countVariant":[32],"isPasswordVisible":[32],"updateLang":[64],"setFocus":[64],"getInputElement":[64]},null,{"value":["valueChanged"],"maxlength":["maxLengthChanged"],"disabled":["disabledChanged"]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { defineCustomElements };
|
|
@@ -918,6 +918,7 @@ const MdsInput = class {
|
|
|
918
918
|
hostRef.$hostElement$["s-ei"] = this.internals;
|
|
919
919
|
}
|
|
920
920
|
this.hasFocus = false;
|
|
921
|
+
this.countVariant = 'count-empty';
|
|
921
922
|
this.isPasswordVisible = false;
|
|
922
923
|
this.t = new Locale({
|
|
923
924
|
el: localeEl,
|
|
@@ -981,6 +982,36 @@ const MdsInput = class {
|
|
|
981
982
|
* Specifies the value of the input element
|
|
982
983
|
*/
|
|
983
984
|
this.value = '';
|
|
985
|
+
this.countMaxLength = () => {
|
|
986
|
+
var _a, _b, _c;
|
|
987
|
+
if (!this.maxlength)
|
|
988
|
+
return;
|
|
989
|
+
if (this.value === undefined)
|
|
990
|
+
return;
|
|
991
|
+
this.currentLengthLabel = `${(_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} / ${this.maxlength}`;
|
|
992
|
+
const completionPerc = Math.round(this.value.length * 100 / this.maxlength);
|
|
993
|
+
if (((_c = this.value) === null || _c === void 0 ? void 0 : _c.length) === this.maxlength) {
|
|
994
|
+
this.countVariant = 'count-full';
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
if (completionPerc >= 100) {
|
|
998
|
+
this.countVariant = 'count-full';
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (completionPerc >= 75) {
|
|
1002
|
+
this.countVariant = 'count-almost-full';
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (completionPerc >= 50) {
|
|
1006
|
+
this.countVariant = 'count-almost';
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
if (completionPerc >= 25) {
|
|
1010
|
+
this.countVariant = 'count-incomplete';
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
this.countVariant = 'count-empty';
|
|
1014
|
+
};
|
|
984
1015
|
this.onInput = (ev) => {
|
|
985
1016
|
const input = ev.target;
|
|
986
1017
|
if (input) {
|
|
@@ -1037,6 +1068,7 @@ const MdsInput = class {
|
|
|
1037
1068
|
this.el.removeAttribute('tabindex');
|
|
1038
1069
|
}
|
|
1039
1070
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1071
|
+
this.maxLengthChanged(this.maxlength);
|
|
1040
1072
|
}
|
|
1041
1073
|
/**
|
|
1042
1074
|
* Emits the change event when the component value changes
|
|
@@ -1045,6 +1077,18 @@ const MdsInput = class {
|
|
|
1045
1077
|
var _a;
|
|
1046
1078
|
this.changeEvent.emit({ value: this.value });
|
|
1047
1079
|
this.internals.setFormValue((_a = this.value) !== null && _a !== void 0 ? _a : null);
|
|
1080
|
+
if (this.maxlength !== undefined) {
|
|
1081
|
+
this.countMaxLength();
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
maxLengthChanged(newValue) {
|
|
1085
|
+
if (newValue === undefined)
|
|
1086
|
+
return;
|
|
1087
|
+
if (newValue <= 0) {
|
|
1088
|
+
this.maxlength = undefined;
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
this.countMaxLength();
|
|
1048
1092
|
}
|
|
1049
1093
|
disabledChanged(newValue) {
|
|
1050
1094
|
/**
|
|
@@ -1078,25 +1122,26 @@ const MdsInput = class {
|
|
|
1078
1122
|
}
|
|
1079
1123
|
render() {
|
|
1080
1124
|
var _a, _b;
|
|
1081
|
-
return (h(Host, { key: '
|
|
1125
|
+
return (h(Host, { key: '092c047d986f352fb6619c0226ee298ba7c47b5d' }, this.type === 'number'
|
|
1082
1126
|
&& this.controlsLayout === 'horizontal'
|
|
1083
|
-
&& h("mds-button", { key: '
|
|
1127
|
+
&& h("mds-button", { key: '8d1102c0c344ef165aa8362f07a70c5c15486497', class: "counter-button counter-button--horizontal counter-button--decrease", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" }), this.type === 'textarea'
|
|
1084
1128
|
? h("textarea", { class: clsx('input', ((_a = this.icon) !== null && _a !== void 0 ? _a : this.await) && 'has-icon'), autoFocus: this.autofocus, disabled: this.disabled, maxLength: this.maxlength, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, tabIndex: this.tabindex, value: this.value })
|
|
1085
1129
|
: h("input", { class: clsx('input', ((_b = this.icon) !== null && _b !== void 0 ? _b : this.await) && 'has-icon'), autoComplete: this.autocomplete, autoFocus: this.autofocus, disabled: this.disabled, max: this.max, maxLength: this.maxlength, min: this.min, minLength: this.minlength, name: this.name, onBlur: this.onBlur, onFocus: this.onFocus, onInput: this.onInput, pattern: this.pattern, list: this.datalist && 'datalist', part: "field", placeholder: this.placeholder, readOnly: this.readonly, ref: input => (this.nativeInput = input), required: this.required, step: this.step, tabIndex: this.tabindex, type: this.type === 'password' && this.isPasswordVisible ? 'text' : this.type, value: this.value }), this.type === 'number'
|
|
1086
1130
|
&& this.controlsLayout === 'vertical'
|
|
1087
|
-
&& h("div", { key: '
|
|
1131
|
+
&& h("div", { key: 'cb9f7381220cc239be4a7b0496632f712b5884a8', class: "counter counter--vertical" }, h("mds-button", { key: '811d62fc18062aa87d3c2feb367ea0ff5a8b96ee', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), h("mds-button", { key: '1da6e70684e4c54ffc5fd6e46ee72e93fa71c92e', class: "counter-button", icon: this.controlsIcon === 'arrow' ? miBaselineArrowDown : miBaselineRemove, onClick: this.stepDown, role: "button", tabindex: "0", title: this.t.get('decrease'), part: "counter-button-decrease" })), this.type === 'number'
|
|
1088
1132
|
&& this.controlsLayout === 'horizontal'
|
|
1089
|
-
&& h("mds-button", { key: '
|
|
1090
|
-
&& h("mds-button", { key: '
|
|
1091
|
-
h("mds-input-tip-item", { key: '
|
|
1092
|
-
h("datalist", { key: '
|
|
1133
|
+
&& h("mds-button", { key: 'c272f0e9fd2af1f2947a82c8954a33b91ec8952b', class: "counter-button counter-button--horizontal counter-button--increase", icon: this.controlsIcon === 'arrow' ? miBaselineArrowUp : miBaselineAdd, onClick: this.stepUp, role: "button", tabindex: "0", title: this.t.get('increase'), part: "counter-button-increase" }), this.type === 'password'
|
|
1134
|
+
&& h("mds-button", { key: '2276154fb4451cf52f0fb806c4bd206299a75798', class: "password-toggle-button", icon: this.isPasswordVisible ? miBaselineVisibleOff : miBaselineVisible, onClick: () => this.isPasswordVisible = !this.isPasswordVisible, role: "button", tabindex: "0", tone: "quiet", title: this.isPasswordVisible ? this.t.get('hidePassword') : this.t.get('showPassword'), part: "password-toggle-button" }), h("mds-input-tip", { key: '0b8733d237a76ebc88c0a57bb9b3bd23608a21aa', lang: this.language, position: "top", active: this.hasFocus }, this.disabled && h("mds-input-tip-item", { key: 'ba27f229ed7eab375381ba4e84979a738e33a14e', expanded: true, variant: "disabled" }), this.readonly && h("mds-input-tip-item", { key: '8acbfe6d3df8d1500b23a217fbb595470e9fef34', expanded: true, variant: "readonly" }), this.required &&
|
|
1135
|
+
h("mds-input-tip-item", { key: '85605f3ecd99fb27e219273c5f7e22c2059389d9', expanded: this.hasFocus, variant: this.value === '' ? 'required' : 'required-success' })), h("mds-input-tip", { key: '8550422b58133c91848038dd29c09e2e7bcecbe4', lang: this.language, position: "bottom", active: this.hasFocus }, this.tip && h("mds-input-tip-item", { key: '65de4760bffbd1c938c440a6112d04bcbfe2f62d', expanded: true, variant: "text" }, this.tip), this.maxlength && h("mds-input-tip-item", { key: 'f47b47b2fcd1cc20f834596e1dd2b74f1ca7b4b5', part: "tip-count", expanded: true, variant: this.countVariant }, this.currentLengthLabel)), this.datalist &&
|
|
1136
|
+
h("datalist", { key: 'bdc3f13692b00dae9e034f33f450ab4f4d6260f6', id: "datalist", class: "datalist" }, this.datalist.forEach(element => {
|
|
1093
1137
|
h("option", { value: element });
|
|
1094
|
-
})), this.icon && !this.await && h("mds-icon", { key: '
|
|
1138
|
+
})), this.icon && !this.await && h("mds-icon", { key: '890a24ac77cea5ceac8c8ac10d9995fd1e76a3f1', class: clsx('icon', this.variant), name: this.icon }), h("mds-spinner", { key: '83bea6775de9cabd0d399dcd547404a42a739730', running: this.await, class: clsx('await', this.variant) })));
|
|
1095
1139
|
}
|
|
1096
1140
|
static get formAssociated() { return true; }
|
|
1097
1141
|
get el() { return getElement(this); }
|
|
1098
1142
|
static get watchers() { return {
|
|
1099
1143
|
"value": ["valueChanged"],
|
|
1144
|
+
"maxlength": ["maxLengthChanged"],
|
|
1100
1145
|
"disabled": ["disabledChanged"]
|
|
1101
1146
|
}; }
|
|
1102
1147
|
};
|