@mgdis/mg-components 6.19.0 → 6.21.0
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/{index-Bp6wZzau.js → index-C2viYwrR.js} +1757 -80
- package/dist/cjs/{index-TUElr4Wv.js → index-CCsGMNyq.js} +46 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +735 -337
- package/dist/cjs/mg-alert.cjs.entry.js +17 -9
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-fieldset.cjs.entry.js +24 -7
- package/dist/cjs/mg-input-combobox.cjs.entry.js +63 -29
- package/dist/cjs/mg-input-file.cjs.entry.js +384 -0
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +30 -18
- package/dist/cjs/{mg-input.conf-D7jmj_lh.js → mg-input.conf-BNpeATnq.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +8 -6
- package/dist/cjs/mg-progress.cjs.entry.js +19 -9
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +15 -11
- package/dist/collection/components/molecules/inputs/mg-input-file/mg-input-file.js +877 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +12 -12
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +72 -84
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +12 -3
- package/dist/collection/components/molecules/mg-form/mg-form.js +12 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/locales/en/messages.json +11 -0
- package/dist/collection/locales/fr/messages.json +11 -0
- package/dist/components/events.utils.js +1 -23
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -1
- package/dist/components/index2.js +1 -408
- package/dist/components/index3.js +1 -476
- package/dist/components/mg-action-more.js +1 -254
- package/dist/components/mg-alert.js +1 -224
- package/dist/components/mg-badge.js +1 -6
- package/dist/components/mg-badge2.js +1 -113
- package/dist/components/mg-button.js +1 -6
- package/dist/components/mg-button2.js +1 -275
- package/dist/components/mg-card.js +1 -6
- package/dist/components/mg-card2.js +1 -92
- package/dist/components/mg-character-left.js +1 -6
- package/dist/components/mg-character-left2.js +1 -75
- package/dist/components/mg-details.js +1 -104
- package/dist/components/mg-divider.js +1 -6
- package/dist/components/mg-divider2.js +1 -49
- package/dist/components/mg-fieldset.js +1 -209
- package/dist/components/mg-form.js +1 -302
- package/dist/components/mg-icon.js +1 -6
- package/dist/components/mg-icon2.js +1 -188
- package/dist/components/mg-illustrated-message.js +1 -129
- package/dist/components/mg-input-checkbox-paginated.js +1 -6
- package/dist/components/mg-input-checkbox-paginated2.js +1 -135
- package/dist/components/mg-input-checkbox.js +1 -762
- package/dist/components/mg-input-combobox.js +1 -936
- package/dist/components/mg-input-date.js +1 -463
- package/dist/components/mg-input-file.d.ts +11 -0
- package/dist/components/mg-input-file.js +1 -0
- package/dist/components/mg-input-numeric.js +1 -592
- package/dist/components/mg-input-password.js +1 -360
- package/dist/components/mg-input-radio.js +1 -392
- package/dist/components/mg-input-rich-text-editor.js +1 -16797
- package/dist/components/mg-input-select.js +1 -6
- package/dist/components/mg-input-select2.js +1 -481
- package/dist/components/mg-input-text.js +1 -6
- package/dist/components/mg-input-text2.js +1 -514
- package/dist/components/mg-input-textarea.js +1 -412
- package/dist/components/mg-input-title.js +1 -6
- package/dist/components/mg-input-title2.js +1 -81
- package/dist/components/mg-input-toggle.js +1 -386
- package/dist/components/mg-input.conf.js +1 -0
- package/dist/components/mg-input.js +1 -6
- package/dist/components/mg-input2.js +1 -459
- package/dist/components/mg-item-more.js +1 -6
- package/dist/components/mg-item-more2.js +1 -505
- package/dist/components/mg-loader.js +1 -6
- package/dist/components/mg-loader2.js +1 -74
- package/dist/components/mg-menu-item.js +1 -6
- package/dist/components/mg-menu-item2.js +1 -485
- package/dist/components/mg-menu.js +1 -6
- package/dist/components/mg-message.js +1 -6
- package/dist/components/mg-message2.js +1 -146
- package/dist/components/mg-modal.js +1 -184
- package/dist/components/mg-pagination.js +1 -234
- package/dist/components/mg-panel.js +1 -350
- package/dist/components/mg-popover-content.js +1 -6
- package/dist/components/mg-popover-content2.js +1 -96
- package/dist/components/mg-popover.js +1 -6
- package/dist/components/mg-popover2.js +1 -312
- package/dist/components/mg-progress.js +1 -123
- package/dist/components/mg-skip-links.js +1 -78
- package/dist/components/mg-table.js +1 -319
- package/dist/components/mg-tabs.js +1 -6
- package/dist/components/mg-tabs2.js +1 -315
- package/dist/components/mg-tag.js +1 -133
- package/dist/components/mg-tooltip-content.js +1 -6
- package/dist/components/mg-tooltip-content2.js +1 -42
- package/dist/components/mg-tooltip.js +1 -6
- package/dist/components/mg-tooltip2.js +1 -421
- package/dist/components/popper.js +1 -1790
- package/dist/esm/{index-CNX6lq0x.js → index-D-uaxCxH.js} +46 -1
- package/dist/esm/{index-BluNKQ3L.js → index-DFwaH2hS.js} +1757 -80
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +735 -337
- package/dist/esm/mg-alert.entry.js +17 -9
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-fieldset.entry.js +24 -7
- package/dist/esm/mg-input-combobox.entry.js +63 -29
- package/dist/esm/mg-input-file.entry.js +382 -0
- package/dist/esm/mg-input-rich-text-editor.entry.js +30 -18
- package/dist/esm/{mg-input.conf-DDnrE1hD.js → mg-input.conf-C9rmNQIL.js} +7 -1
- package/dist/esm/mg-loader.entry.js +8 -6
- package/dist/esm/mg-progress.entry.js +19 -9
- package/dist/mg-components/locales/en/messages.json +11 -0
- package/dist/mg-components/locales/fr/messages.json +11 -0
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-d5a276eb.entry.js → p-08fa327b.entry.js} +1 -1
- package/dist/mg-components/p-4175dcbe.entry.js +1 -0
- package/dist/mg-components/p-6b57f249.entry.js +1 -0
- package/dist/mg-components/p-6b655830.entry.js +1 -0
- package/dist/mg-components/p-988c282e.entry.js +1 -0
- package/dist/mg-components/p-C9rmNQIL.js +1 -0
- package/dist/mg-components/p-D-uaxCxH.js +1 -0
- package/dist/mg-components/p-DFwaH2hS.js +2 -0
- package/dist/mg-components/p-a79b1f19.entry.js +1 -0
- package/dist/mg-components/{p-916dfb6d.entry.js → p-c3d116b9.entry.js} +1 -1
- package/dist/mg-components/p-dd1934f4.entry.js +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-file/mg-input-file.d.ts +210 -0
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -4
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +13 -16
- package/dist/types/components.d.ts +217 -18
- package/dist/types/stencil-public-runtime.d.ts +76 -12
- package/ide/intellij/web-types.json +373 -26
- package/ide/vscode/css-custom-data.json +12 -0
- package/ide/vscode/html-custom-data.json +341 -79
- package/package.json +22 -22
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +0 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +0 -1
- package/dist/mg-components/p-016bd291.entry.js +0 -1
- package/dist/mg-components/p-186a6139.entry.js +0 -1
- package/dist/mg-components/p-66a1cb83.entry.js +0 -1
- package/dist/mg-components/p-6efd819f.entry.js +0 -1
- package/dist/mg-components/p-BluNKQ3L.js +0 -2
- package/dist/mg-components/p-CNX6lq0x.js +0 -1
- package/dist/mg-components/p-DDnrE1hD.js +0 -1
- package/dist/mg-components/p-d2c72f09.entry.js +0 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +0 -8
|
@@ -0,0 +1,877 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { allItemsAreString, ClassList, isObject, isValidString, toString } from "@mgdis/core-ui-helpers/dist/utils";
|
|
3
|
+
import { localeByte } from "@mgdis/core-ui-helpers/dist/locale";
|
|
4
|
+
import { classDisabled } from "../mg-input/mg-input.conf";
|
|
5
|
+
import { initLocales } from "../../../../locales";
|
|
6
|
+
const allItemsAreFile = (items) => {
|
|
7
|
+
return Array.isArray(items) && items.every(item => isObject(item) && typeof item.name === 'string' && typeof item.size === 'number');
|
|
8
|
+
};
|
|
9
|
+
export class MgInputFile {
|
|
10
|
+
constructor() {
|
|
11
|
+
// hasDisplayedError (triggered by blur event)
|
|
12
|
+
this.hasDisplayedError = false;
|
|
13
|
+
this.customErrorMessage = { lock: false };
|
|
14
|
+
/**
|
|
15
|
+
* Input name
|
|
16
|
+
* If not set the value equals the identifier
|
|
17
|
+
*/
|
|
18
|
+
this.name = this.identifier;
|
|
19
|
+
/**
|
|
20
|
+
* Define if label is displayed on top
|
|
21
|
+
*/
|
|
22
|
+
this.labelOnTop = false;
|
|
23
|
+
/**
|
|
24
|
+
* Define if label is visible
|
|
25
|
+
*/
|
|
26
|
+
this.labelHide = false;
|
|
27
|
+
/**
|
|
28
|
+
* Define multiple files
|
|
29
|
+
* When the multiple Boolean attribute is specified, the file input allows the user to select more than one file.
|
|
30
|
+
* (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple).
|
|
31
|
+
*/
|
|
32
|
+
this.multiple = false;
|
|
33
|
+
/**
|
|
34
|
+
* Define if input is required
|
|
35
|
+
*/
|
|
36
|
+
this.required = false;
|
|
37
|
+
/**
|
|
38
|
+
* Define if input is disabled
|
|
39
|
+
*/
|
|
40
|
+
this.disabled = false;
|
|
41
|
+
/**
|
|
42
|
+
* Define tooltip position
|
|
43
|
+
*/
|
|
44
|
+
this.tooltipPosition = 'input';
|
|
45
|
+
/**
|
|
46
|
+
* Component classes
|
|
47
|
+
*/
|
|
48
|
+
this.classCollection = new ClassList(['mg-c-input--file']);
|
|
49
|
+
/**
|
|
50
|
+
* Files list
|
|
51
|
+
*/
|
|
52
|
+
this.files = [];
|
|
53
|
+
/**
|
|
54
|
+
* Method to set validity values
|
|
55
|
+
* @param newValue - valid new value
|
|
56
|
+
*/
|
|
57
|
+
this.setValidity = (newValue) => {
|
|
58
|
+
const oldValue = this.valid;
|
|
59
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
60
|
+
this.valid = newValue;
|
|
61
|
+
}
|
|
62
|
+
this.invalid = !this.valid;
|
|
63
|
+
// We need to send valid event even if it is the same value
|
|
64
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue)) {
|
|
65
|
+
this.inputValid.emit(this.valid);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Handle change event
|
|
70
|
+
*/
|
|
71
|
+
this.handleInputChange = (event) => {
|
|
72
|
+
this.checkValidity();
|
|
73
|
+
if (this.hasDisplayedError) {
|
|
74
|
+
this.setErrorMessage();
|
|
75
|
+
}
|
|
76
|
+
this.files = Array.from(event.target.files);
|
|
77
|
+
// Reset input focus to the button after file selection
|
|
78
|
+
this.fileButtonElement.focus();
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Handle input focus event
|
|
82
|
+
*/
|
|
83
|
+
this.handleInputFocus = () => {
|
|
84
|
+
this.fileButtonElement.dataset.focusVisible = '';
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Handle input blur event
|
|
88
|
+
*/
|
|
89
|
+
this.handleInputBlur = () => {
|
|
90
|
+
// Display Error
|
|
91
|
+
this.handlerInProgress = 'blur';
|
|
92
|
+
this.displayError().finally(() => {
|
|
93
|
+
// reset guard
|
|
94
|
+
this.handlerInProgress = undefined;
|
|
95
|
+
});
|
|
96
|
+
delete this.fileButtonElement.dataset.focusVisible;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Handle button blur event
|
|
100
|
+
*/
|
|
101
|
+
this.handleButtonBlur = () => {
|
|
102
|
+
this.inputElement.blur();
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Handle add file button click
|
|
106
|
+
*/
|
|
107
|
+
this.handleButtonClick = () => {
|
|
108
|
+
this.inputElement.click();
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Check if input is valid
|
|
112
|
+
*/
|
|
113
|
+
this.checkValidity = () => {
|
|
114
|
+
this.setValidity(this.disabled || (!this.isMaxSizeExceeded() && this.inputElement.checkValidity()));
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Handle delete file button click
|
|
118
|
+
*/
|
|
119
|
+
this.handleDeleteFileClick = () => {
|
|
120
|
+
this.files = [];
|
|
121
|
+
// Reset input focus to the button after file selection
|
|
122
|
+
this.fileButtonElement.focus();
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Set input error message
|
|
126
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
127
|
+
*/
|
|
128
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
129
|
+
// Set error message
|
|
130
|
+
this.errorMessage = undefined;
|
|
131
|
+
if (!this.valid) {
|
|
132
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
133
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
134
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
135
|
+
}
|
|
136
|
+
// Does not match max size
|
|
137
|
+
else if (this.isMaxSizeExceeded()) {
|
|
138
|
+
this.errorMessage = this.messages.input.file.errors.maxSize.replace('{{maxSize}}', localeByte(this.maxSize, this.locale));
|
|
139
|
+
}
|
|
140
|
+
// required
|
|
141
|
+
else if (this.inputElement.validity.valueMissing) {
|
|
142
|
+
this.errorMessage = this.messages.errors.required;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Check if max size is exceeded
|
|
148
|
+
* @returns boolean - true if max size is exceeded
|
|
149
|
+
*/
|
|
150
|
+
this.isMaxSizeExceeded = () => {
|
|
151
|
+
return this.maxSize >= 0 && this.files.some(file => file.size > this.maxSize);
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Render files
|
|
155
|
+
* @returns formated files.
|
|
156
|
+
*/
|
|
157
|
+
this.renderFiles = () => {
|
|
158
|
+
const fileListId = `${this.identifier}-file-list`;
|
|
159
|
+
const renderFileName = (file) => (h("span", { class: "mg-c-input__file-item-name" }, file.name, file.size > 0 ? h("span", { class: "mg-c-input__file-item-size" }, ` ${localeByte(file.size, this.locale)}`) : undefined));
|
|
160
|
+
const renderDeleteButton = () => (h("mg-button", { variant: "flat", class: "mg-c-input__file-delete-button", "is-icon": true, label: this.messages.input.file.deleteButton, type: "button", disabled: this.disabled, "aria-controls": [this.identifier, fileListId].join(' '), onClick: this.handleDeleteFileClick }, h("mg-icon", { icon: "cross" })));
|
|
161
|
+
if (this.files.length === 0) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
else if (this.files.length === 1) {
|
|
165
|
+
return (h("div", { class: "mg-c-input__file-item" }, renderFileName(this.files[0]), renderDeleteButton()));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return (h("div", { class: "mg-c-input__file-list-container" }, h("ul", { role: "list", class: "mg-c-input__file-list", id: fileListId }, Array.from(this.files).map((file, index) => (h("li", { class: "mg-c-input__file-item", key: `${file.name}-${index}` }, renderFileName(file))))), renderDeleteButton()));
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
watchValue(newValue) {
|
|
173
|
+
if (allItemsAreString(newValue)) {
|
|
174
|
+
this.files = this.value.map((fileName) => new File([], fileName));
|
|
175
|
+
}
|
|
176
|
+
else if (allItemsAreFile(newValue)) {
|
|
177
|
+
this.files = this.value;
|
|
178
|
+
}
|
|
179
|
+
else if (newValue !== undefined) {
|
|
180
|
+
throw new Error(`<mg-input-file> prop "value" must be an array of strings or File objects. Passed value: ${toString(newValue)}.`);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.files = [];
|
|
184
|
+
}
|
|
185
|
+
this.valueChange.emit(newValue);
|
|
186
|
+
}
|
|
187
|
+
watchMultiple() {
|
|
188
|
+
if (this.multiple === false && this.files.length > 1) {
|
|
189
|
+
throw new Error(`<mg-input-file> prop "value" must be a single file when prop "multiple" is set to false.`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
watchAccept(newValue) {
|
|
193
|
+
if (newValue !== undefined && !isValidString(newValue)) {
|
|
194
|
+
throw new Error(`<mg-input-file> prop "accept" must be a valid string.`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
198
|
+
if (this.inputElement !== undefined) {
|
|
199
|
+
this.inputElement[prop] = newValue;
|
|
200
|
+
this.checkValidity();
|
|
201
|
+
if (this.hasDisplayedError) {
|
|
202
|
+
this.setErrorMessage();
|
|
203
|
+
this.hasDisplayedError = false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
watchDisabled(newValue) {
|
|
208
|
+
if (newValue) {
|
|
209
|
+
this.classCollection.add(classDisabled);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.classCollection.delete(classDisabled);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
watchHelpText() {
|
|
216
|
+
if (!isValidString(this.helpText)) {
|
|
217
|
+
const helpText = [];
|
|
218
|
+
if (this.maxSize !== undefined) {
|
|
219
|
+
helpText.push(this.messages.input.file.helpText.maxSize.replace('{{maxSize}}', localeByte(this.maxSize, this.locale)));
|
|
220
|
+
}
|
|
221
|
+
if (this.accept !== undefined) {
|
|
222
|
+
helpText.push(this.messages.input.file.helpText.accept.replace('{{accept}}', this.accept));
|
|
223
|
+
}
|
|
224
|
+
this.helpText = helpText.join('. ');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
watchFiles(newValue, oldValue) {
|
|
228
|
+
if (toString(newValue) !== toString(oldValue)) {
|
|
229
|
+
this.value = newValue.length > 0 ? newValue : undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Set focus on input add file button
|
|
234
|
+
*/
|
|
235
|
+
async setFocus() {
|
|
236
|
+
this.fileButtonElement.focus();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Display input error if it exists.
|
|
240
|
+
*/
|
|
241
|
+
displayError() {
|
|
242
|
+
// Use `Promise` as requested for stencil method
|
|
243
|
+
// Use `requestAnimationFrame` to ensure:
|
|
244
|
+
// - DOM is fully updated before validation
|
|
245
|
+
// - Async operations are completed
|
|
246
|
+
// - No timing issues with Stencil's render cycle
|
|
247
|
+
// - Keep everything in sync both inside and outside the component
|
|
248
|
+
return new Promise(resolve => {
|
|
249
|
+
requestAnimationFrame(() => {
|
|
250
|
+
this.checkValidity();
|
|
251
|
+
this.setErrorMessage();
|
|
252
|
+
this.hasDisplayedError = this.invalid;
|
|
253
|
+
resolve();
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Set an error and display a custom error message.
|
|
259
|
+
* This method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.
|
|
260
|
+
* It must be paired with an error message to display for the given context.
|
|
261
|
+
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
262
|
+
* @param valid - value indicating the validity
|
|
263
|
+
* @param errorMessage - the error message to display
|
|
264
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
265
|
+
*/
|
|
266
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
267
|
+
if (typeof valid !== 'boolean') {
|
|
268
|
+
throw new Error('<mg-input-file> method "setError()" param "valid" must be a boolean.');
|
|
269
|
+
}
|
|
270
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
271
|
+
throw new Error('<mg-input-file> method "setError()" param "errorMessage" must be a string.');
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
this.customErrorMessage = {
|
|
275
|
+
lock: valid ? false : errorMessageLock,
|
|
276
|
+
message: valid ? undefined : errorMessage,
|
|
277
|
+
};
|
|
278
|
+
this.setValidity(valid);
|
|
279
|
+
this.setErrorMessage(true);
|
|
280
|
+
this.hasDisplayedError = this.invalid;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Reset value, validity and error state
|
|
285
|
+
*/
|
|
286
|
+
async reset() {
|
|
287
|
+
this.files = [];
|
|
288
|
+
// Use `Promise` as requested for stencil method
|
|
289
|
+
// Use `requestAnimationFrame` to ensure:
|
|
290
|
+
// - DOM is fully updated before validation
|
|
291
|
+
// - Async operations are completed
|
|
292
|
+
// - No timing issues with Stencil's render cycle
|
|
293
|
+
// - Keep everything in sync both inside and outside the component
|
|
294
|
+
return new Promise(resolve => {
|
|
295
|
+
requestAnimationFrame(() => {
|
|
296
|
+
// unlock validity check by resetting customErrorMessage
|
|
297
|
+
this.customErrorMessage = { lock: false };
|
|
298
|
+
this.checkValidity();
|
|
299
|
+
this.errorMessage = undefined;
|
|
300
|
+
this.hasDisplayedError = false;
|
|
301
|
+
resolve();
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/*************
|
|
306
|
+
* Lifecycle *
|
|
307
|
+
*************/
|
|
308
|
+
/**
|
|
309
|
+
* Check if component props are well configured on init
|
|
310
|
+
* @returns timeout
|
|
311
|
+
*/
|
|
312
|
+
componentWillLoad() {
|
|
313
|
+
// Get locales
|
|
314
|
+
const locales = initLocales(this.element);
|
|
315
|
+
this.locale = locales.locale;
|
|
316
|
+
this.messages = locales.messages;
|
|
317
|
+
// Validate
|
|
318
|
+
this.watchValue(this.value);
|
|
319
|
+
this.watchDisabled(this.disabled);
|
|
320
|
+
this.watchHelpText();
|
|
321
|
+
this.watchAccept(this.accept);
|
|
322
|
+
this.watchMultiple();
|
|
323
|
+
// Check validity when component is ready
|
|
324
|
+
// return a promise to process action only in the FIRST render().
|
|
325
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
326
|
+
return setTimeout(() => {
|
|
327
|
+
this.checkValidity();
|
|
328
|
+
}, 0);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Render
|
|
332
|
+
* @returns HTML Element
|
|
333
|
+
*/
|
|
334
|
+
render() {
|
|
335
|
+
return (h("mg-input", { key: '3bcbf416c083d857aac2ad556bb2a218fe9ef82f', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, h("div", { key: '88fafc6fd4a84c05a545c0083193e2ee0db54bfb', class: "mg-c-input__file-container" }, h("input", { key: 'ad1d14bc95390d5db56191ebff0d092ed5478183', name: this.name, id: this.identifier, class: "mg-u-visually-hidden", type: "file", multiple: this.multiple === true, capture: this.capture, accept: this.accept, disabled: this.disabled, required: this.files.length === 0 && this.required, onFocus: this.handleInputFocus, onBlur: this.handleInputBlur, onChange: this.handleInputChange, "aria-invalid": (this.invalid === true).toString(), ref: (el) => {
|
|
336
|
+
this.inputElement = el;
|
|
337
|
+
} }), h("mg-button", { key: 'ace59bb90e27f924ce85e96abd277e752c75b6b8', variant: "secondary", class: "mg-c-input__file-button", type: "button", disabled: this.disabled, onClick: this.handleButtonClick, onBlur: this.handleButtonBlur, tabindex: "-1", ref: (el) => {
|
|
338
|
+
this.fileButtonElement = el;
|
|
339
|
+
} }, this.messages.input.file.browse), this.renderFiles())));
|
|
340
|
+
}
|
|
341
|
+
static get is() { return "mg-input-file"; }
|
|
342
|
+
static get encapsulation() { return "shadow"; }
|
|
343
|
+
static get originalStyleUrls() {
|
|
344
|
+
return {
|
|
345
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-file.css"]
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
static get styleUrls() {
|
|
349
|
+
return {
|
|
350
|
+
"$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-file.css"]
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
static get properties() {
|
|
354
|
+
return {
|
|
355
|
+
"value": {
|
|
356
|
+
"type": "any",
|
|
357
|
+
"mutable": true,
|
|
358
|
+
"complexType": {
|
|
359
|
+
"original": "any",
|
|
360
|
+
"resolved": "any",
|
|
361
|
+
"references": {}
|
|
362
|
+
},
|
|
363
|
+
"required": false,
|
|
364
|
+
"optional": false,
|
|
365
|
+
"docs": {
|
|
366
|
+
"tags": [],
|
|
367
|
+
"text": "Component value"
|
|
368
|
+
},
|
|
369
|
+
"getter": false,
|
|
370
|
+
"setter": false,
|
|
371
|
+
"reflect": false,
|
|
372
|
+
"attribute": "value"
|
|
373
|
+
},
|
|
374
|
+
"identifier": {
|
|
375
|
+
"type": "string",
|
|
376
|
+
"mutable": false,
|
|
377
|
+
"complexType": {
|
|
378
|
+
"original": "string",
|
|
379
|
+
"resolved": "string",
|
|
380
|
+
"references": {}
|
|
381
|
+
},
|
|
382
|
+
"required": true,
|
|
383
|
+
"optional": false,
|
|
384
|
+
"docs": {
|
|
385
|
+
"tags": [],
|
|
386
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)"
|
|
387
|
+
},
|
|
388
|
+
"getter": false,
|
|
389
|
+
"setter": false,
|
|
390
|
+
"reflect": false,
|
|
391
|
+
"attribute": "identifier"
|
|
392
|
+
},
|
|
393
|
+
"name": {
|
|
394
|
+
"type": "string",
|
|
395
|
+
"mutable": false,
|
|
396
|
+
"complexType": {
|
|
397
|
+
"original": "string",
|
|
398
|
+
"resolved": "string",
|
|
399
|
+
"references": {}
|
|
400
|
+
},
|
|
401
|
+
"required": false,
|
|
402
|
+
"optional": false,
|
|
403
|
+
"docs": {
|
|
404
|
+
"tags": [],
|
|
405
|
+
"text": "Input name\nIf not set the value equals the identifier"
|
|
406
|
+
},
|
|
407
|
+
"getter": false,
|
|
408
|
+
"setter": false,
|
|
409
|
+
"reflect": false,
|
|
410
|
+
"attribute": "name",
|
|
411
|
+
"defaultValue": "this.identifier"
|
|
412
|
+
},
|
|
413
|
+
"label": {
|
|
414
|
+
"type": "string",
|
|
415
|
+
"mutable": false,
|
|
416
|
+
"complexType": {
|
|
417
|
+
"original": "string",
|
|
418
|
+
"resolved": "string",
|
|
419
|
+
"references": {}
|
|
420
|
+
},
|
|
421
|
+
"required": true,
|
|
422
|
+
"optional": false,
|
|
423
|
+
"docs": {
|
|
424
|
+
"tags": [],
|
|
425
|
+
"text": "Input label"
|
|
426
|
+
},
|
|
427
|
+
"getter": false,
|
|
428
|
+
"setter": false,
|
|
429
|
+
"reflect": false,
|
|
430
|
+
"attribute": "label"
|
|
431
|
+
},
|
|
432
|
+
"labelOnTop": {
|
|
433
|
+
"type": "boolean",
|
|
434
|
+
"mutable": false,
|
|
435
|
+
"complexType": {
|
|
436
|
+
"original": "boolean",
|
|
437
|
+
"resolved": "boolean",
|
|
438
|
+
"references": {}
|
|
439
|
+
},
|
|
440
|
+
"required": false,
|
|
441
|
+
"optional": false,
|
|
442
|
+
"docs": {
|
|
443
|
+
"tags": [],
|
|
444
|
+
"text": "Define if label is displayed on top"
|
|
445
|
+
},
|
|
446
|
+
"getter": false,
|
|
447
|
+
"setter": false,
|
|
448
|
+
"reflect": false,
|
|
449
|
+
"attribute": "label-on-top",
|
|
450
|
+
"defaultValue": "false"
|
|
451
|
+
},
|
|
452
|
+
"labelHide": {
|
|
453
|
+
"type": "boolean",
|
|
454
|
+
"mutable": false,
|
|
455
|
+
"complexType": {
|
|
456
|
+
"original": "boolean",
|
|
457
|
+
"resolved": "boolean",
|
|
458
|
+
"references": {}
|
|
459
|
+
},
|
|
460
|
+
"required": false,
|
|
461
|
+
"optional": false,
|
|
462
|
+
"docs": {
|
|
463
|
+
"tags": [],
|
|
464
|
+
"text": "Define if label is visible"
|
|
465
|
+
},
|
|
466
|
+
"getter": false,
|
|
467
|
+
"setter": false,
|
|
468
|
+
"reflect": false,
|
|
469
|
+
"attribute": "label-hide",
|
|
470
|
+
"defaultValue": "false"
|
|
471
|
+
},
|
|
472
|
+
"multiple": {
|
|
473
|
+
"type": "boolean",
|
|
474
|
+
"mutable": false,
|
|
475
|
+
"complexType": {
|
|
476
|
+
"original": "boolean",
|
|
477
|
+
"resolved": "boolean",
|
|
478
|
+
"references": {}
|
|
479
|
+
},
|
|
480
|
+
"required": false,
|
|
481
|
+
"optional": false,
|
|
482
|
+
"docs": {
|
|
483
|
+
"tags": [],
|
|
484
|
+
"text": "Define multiple files\nWhen the multiple Boolean attribute is specified, the file input allows the user to select more than one file.\n(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple)."
|
|
485
|
+
},
|
|
486
|
+
"getter": false,
|
|
487
|
+
"setter": false,
|
|
488
|
+
"reflect": false,
|
|
489
|
+
"attribute": "multiple",
|
|
490
|
+
"defaultValue": "false"
|
|
491
|
+
},
|
|
492
|
+
"accept": {
|
|
493
|
+
"type": "string",
|
|
494
|
+
"mutable": false,
|
|
495
|
+
"complexType": {
|
|
496
|
+
"original": "string",
|
|
497
|
+
"resolved": "string",
|
|
498
|
+
"references": {}
|
|
499
|
+
},
|
|
500
|
+
"required": false,
|
|
501
|
+
"optional": true,
|
|
502
|
+
"docs": {
|
|
503
|
+
"tags": [],
|
|
504
|
+
"text": "Define file accept format\nThe accept property is an attribute of the file `<input>` type\nthat defines the file types the file input should accept\n(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)."
|
|
505
|
+
},
|
|
506
|
+
"getter": false,
|
|
507
|
+
"setter": false,
|
|
508
|
+
"reflect": false,
|
|
509
|
+
"attribute": "accept"
|
|
510
|
+
},
|
|
511
|
+
"maxSize": {
|
|
512
|
+
"type": "number",
|
|
513
|
+
"mutable": false,
|
|
514
|
+
"complexType": {
|
|
515
|
+
"original": "number",
|
|
516
|
+
"resolved": "number",
|
|
517
|
+
"references": {}
|
|
518
|
+
},
|
|
519
|
+
"required": false,
|
|
520
|
+
"optional": true,
|
|
521
|
+
"docs": {
|
|
522
|
+
"tags": [],
|
|
523
|
+
"text": "Define max file size (in octets)"
|
|
524
|
+
},
|
|
525
|
+
"getter": false,
|
|
526
|
+
"setter": false,
|
|
527
|
+
"reflect": false,
|
|
528
|
+
"attribute": "max-size"
|
|
529
|
+
},
|
|
530
|
+
"capture": {
|
|
531
|
+
"type": "string",
|
|
532
|
+
"mutable": false,
|
|
533
|
+
"complexType": {
|
|
534
|
+
"original": "'user' | 'environment' | ''",
|
|
535
|
+
"resolved": "\"\" | \"environment\" | \"user\"",
|
|
536
|
+
"references": {}
|
|
537
|
+
},
|
|
538
|
+
"required": false,
|
|
539
|
+
"optional": true,
|
|
540
|
+
"docs": {
|
|
541
|
+
"tags": [],
|
|
542
|
+
"text": "Define input capture attribute\nThe capture attribute is a Boolean attribute that specifies\nif the device's camera or microphone should be used to capture\nmedia directly, instead of choosing an existing file.\n(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#capture)."
|
|
543
|
+
},
|
|
544
|
+
"getter": false,
|
|
545
|
+
"setter": false,
|
|
546
|
+
"reflect": false,
|
|
547
|
+
"attribute": "capture"
|
|
548
|
+
},
|
|
549
|
+
"required": {
|
|
550
|
+
"type": "boolean",
|
|
551
|
+
"mutable": false,
|
|
552
|
+
"complexType": {
|
|
553
|
+
"original": "boolean",
|
|
554
|
+
"resolved": "boolean",
|
|
555
|
+
"references": {}
|
|
556
|
+
},
|
|
557
|
+
"required": false,
|
|
558
|
+
"optional": false,
|
|
559
|
+
"docs": {
|
|
560
|
+
"tags": [],
|
|
561
|
+
"text": "Define if input is required"
|
|
562
|
+
},
|
|
563
|
+
"getter": false,
|
|
564
|
+
"setter": false,
|
|
565
|
+
"reflect": false,
|
|
566
|
+
"attribute": "required",
|
|
567
|
+
"defaultValue": "false"
|
|
568
|
+
},
|
|
569
|
+
"disabled": {
|
|
570
|
+
"type": "boolean",
|
|
571
|
+
"mutable": false,
|
|
572
|
+
"complexType": {
|
|
573
|
+
"original": "boolean",
|
|
574
|
+
"resolved": "boolean",
|
|
575
|
+
"references": {}
|
|
576
|
+
},
|
|
577
|
+
"required": false,
|
|
578
|
+
"optional": false,
|
|
579
|
+
"docs": {
|
|
580
|
+
"tags": [],
|
|
581
|
+
"text": "Define if input is disabled"
|
|
582
|
+
},
|
|
583
|
+
"getter": false,
|
|
584
|
+
"setter": false,
|
|
585
|
+
"reflect": false,
|
|
586
|
+
"attribute": "disabled",
|
|
587
|
+
"defaultValue": "false"
|
|
588
|
+
},
|
|
589
|
+
"tooltip": {
|
|
590
|
+
"type": "string",
|
|
591
|
+
"mutable": false,
|
|
592
|
+
"complexType": {
|
|
593
|
+
"original": "string",
|
|
594
|
+
"resolved": "string",
|
|
595
|
+
"references": {}
|
|
596
|
+
},
|
|
597
|
+
"required": false,
|
|
598
|
+
"optional": true,
|
|
599
|
+
"docs": {
|
|
600
|
+
"tags": [],
|
|
601
|
+
"text": "Add a tooltip message next to the input"
|
|
602
|
+
},
|
|
603
|
+
"getter": false,
|
|
604
|
+
"setter": false,
|
|
605
|
+
"reflect": false,
|
|
606
|
+
"attribute": "tooltip"
|
|
607
|
+
},
|
|
608
|
+
"tooltipPosition": {
|
|
609
|
+
"type": "string",
|
|
610
|
+
"mutable": false,
|
|
611
|
+
"complexType": {
|
|
612
|
+
"original": "TooltipPosition",
|
|
613
|
+
"resolved": "\"input\" | \"label\"",
|
|
614
|
+
"references": {
|
|
615
|
+
"TooltipPosition": {
|
|
616
|
+
"location": "import",
|
|
617
|
+
"path": "../mg-input/mg-input.conf",
|
|
618
|
+
"id": "src/components/molecules/inputs/mg-input/mg-input.conf.ts::TooltipPosition"
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
"required": false,
|
|
623
|
+
"optional": false,
|
|
624
|
+
"docs": {
|
|
625
|
+
"tags": [],
|
|
626
|
+
"text": "Define tooltip position"
|
|
627
|
+
},
|
|
628
|
+
"getter": false,
|
|
629
|
+
"setter": false,
|
|
630
|
+
"reflect": false,
|
|
631
|
+
"attribute": "tooltip-position",
|
|
632
|
+
"defaultValue": "'input'"
|
|
633
|
+
},
|
|
634
|
+
"helpText": {
|
|
635
|
+
"type": "string",
|
|
636
|
+
"mutable": true,
|
|
637
|
+
"complexType": {
|
|
638
|
+
"original": "string",
|
|
639
|
+
"resolved": "string",
|
|
640
|
+
"references": {}
|
|
641
|
+
},
|
|
642
|
+
"required": false,
|
|
643
|
+
"optional": true,
|
|
644
|
+
"docs": {
|
|
645
|
+
"tags": [],
|
|
646
|
+
"text": "Add a help text under the input, usually expected data format and example"
|
|
647
|
+
},
|
|
648
|
+
"getter": false,
|
|
649
|
+
"setter": false,
|
|
650
|
+
"reflect": false,
|
|
651
|
+
"attribute": "help-text"
|
|
652
|
+
},
|
|
653
|
+
"valid": {
|
|
654
|
+
"type": "boolean",
|
|
655
|
+
"mutable": true,
|
|
656
|
+
"complexType": {
|
|
657
|
+
"original": "boolean",
|
|
658
|
+
"resolved": "boolean",
|
|
659
|
+
"references": {}
|
|
660
|
+
},
|
|
661
|
+
"required": false,
|
|
662
|
+
"optional": false,
|
|
663
|
+
"docs": {
|
|
664
|
+
"tags": [],
|
|
665
|
+
"text": "Define input valid state"
|
|
666
|
+
},
|
|
667
|
+
"getter": false,
|
|
668
|
+
"setter": false,
|
|
669
|
+
"reflect": false,
|
|
670
|
+
"attribute": "valid"
|
|
671
|
+
},
|
|
672
|
+
"invalid": {
|
|
673
|
+
"type": "boolean",
|
|
674
|
+
"mutable": true,
|
|
675
|
+
"complexType": {
|
|
676
|
+
"original": "boolean",
|
|
677
|
+
"resolved": "boolean",
|
|
678
|
+
"references": {}
|
|
679
|
+
},
|
|
680
|
+
"required": false,
|
|
681
|
+
"optional": false,
|
|
682
|
+
"docs": {
|
|
683
|
+
"tags": [],
|
|
684
|
+
"text": "Define input invalid state"
|
|
685
|
+
},
|
|
686
|
+
"getter": false,
|
|
687
|
+
"setter": false,
|
|
688
|
+
"reflect": false,
|
|
689
|
+
"attribute": "invalid"
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
static get states() {
|
|
694
|
+
return {
|
|
695
|
+
"classCollection": {},
|
|
696
|
+
"errorMessage": {},
|
|
697
|
+
"files": {}
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
static get events() {
|
|
701
|
+
return [{
|
|
702
|
+
"method": "valueChange",
|
|
703
|
+
"name": "value-change",
|
|
704
|
+
"bubbles": true,
|
|
705
|
+
"cancelable": true,
|
|
706
|
+
"composed": true,
|
|
707
|
+
"docs": {
|
|
708
|
+
"tags": [],
|
|
709
|
+
"text": "Emitted event when value change"
|
|
710
|
+
},
|
|
711
|
+
"complexType": {
|
|
712
|
+
"original": "HTMLMgInputFileElement['value']",
|
|
713
|
+
"resolved": "any",
|
|
714
|
+
"references": {
|
|
715
|
+
"HTMLMgInputFileElement": {
|
|
716
|
+
"location": "global",
|
|
717
|
+
"id": "global::HTMLMgInputFileElement"
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}, {
|
|
722
|
+
"method": "inputValid",
|
|
723
|
+
"name": "input-valid",
|
|
724
|
+
"bubbles": true,
|
|
725
|
+
"cancelable": true,
|
|
726
|
+
"composed": true,
|
|
727
|
+
"docs": {
|
|
728
|
+
"tags": [],
|
|
729
|
+
"text": "Emitted event when checking validity"
|
|
730
|
+
},
|
|
731
|
+
"complexType": {
|
|
732
|
+
"original": "HTMLMgInputFileElement['valid']",
|
|
733
|
+
"resolved": "boolean",
|
|
734
|
+
"references": {
|
|
735
|
+
"HTMLMgInputFileElement": {
|
|
736
|
+
"location": "global",
|
|
737
|
+
"id": "global::HTMLMgInputFileElement"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
}];
|
|
742
|
+
}
|
|
743
|
+
static get methods() {
|
|
744
|
+
return {
|
|
745
|
+
"setFocus": {
|
|
746
|
+
"complexType": {
|
|
747
|
+
"signature": "() => Promise<void>",
|
|
748
|
+
"parameters": [],
|
|
749
|
+
"references": {
|
|
750
|
+
"Promise": {
|
|
751
|
+
"location": "global",
|
|
752
|
+
"id": "global::Promise"
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
"return": "Promise<void>"
|
|
756
|
+
},
|
|
757
|
+
"docs": {
|
|
758
|
+
"text": "Set focus on input add file button",
|
|
759
|
+
"tags": []
|
|
760
|
+
}
|
|
761
|
+
},
|
|
762
|
+
"displayError": {
|
|
763
|
+
"complexType": {
|
|
764
|
+
"signature": "() => Promise<void>",
|
|
765
|
+
"parameters": [],
|
|
766
|
+
"references": {
|
|
767
|
+
"Promise": {
|
|
768
|
+
"location": "global",
|
|
769
|
+
"id": "global::Promise"
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
"return": "Promise<void>"
|
|
773
|
+
},
|
|
774
|
+
"docs": {
|
|
775
|
+
"text": "Display input error if it exists.",
|
|
776
|
+
"tags": []
|
|
777
|
+
}
|
|
778
|
+
},
|
|
779
|
+
"setError": {
|
|
780
|
+
"complexType": {
|
|
781
|
+
"signature": "(valid: MgInputFile[\"valid\"], errorMessage?: string, errorMessageLock?: boolean) => Promise<void>",
|
|
782
|
+
"parameters": [{
|
|
783
|
+
"name": "valid",
|
|
784
|
+
"type": "boolean",
|
|
785
|
+
"docs": "- value indicating the validity"
|
|
786
|
+
}, {
|
|
787
|
+
"name": "errorMessage",
|
|
788
|
+
"type": "string",
|
|
789
|
+
"docs": "- the error message to display"
|
|
790
|
+
}, {
|
|
791
|
+
"name": "errorMessageLock",
|
|
792
|
+
"type": "boolean",
|
|
793
|
+
"docs": "- lock the error message and validity state"
|
|
794
|
+
}],
|
|
795
|
+
"references": {
|
|
796
|
+
"Promise": {
|
|
797
|
+
"location": "global",
|
|
798
|
+
"id": "global::Promise"
|
|
799
|
+
},
|
|
800
|
+
"MgInputFile": {
|
|
801
|
+
"location": "global",
|
|
802
|
+
"id": "global::MgInputFile"
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
"return": "Promise<void>"
|
|
806
|
+
},
|
|
807
|
+
"docs": {
|
|
808
|
+
"text": "Set an error and display a custom error message.\nThis method can be used to set the component's error state from its context by passing a boolean value to the `valid` parameter.\nIt must be paired with an error message to display for the given context.\nWhen used to set validity to `false`, you should use this method again to reset the validity to `true`.",
|
|
809
|
+
"tags": [{
|
|
810
|
+
"name": "param",
|
|
811
|
+
"text": "valid - value indicating the validity"
|
|
812
|
+
}, {
|
|
813
|
+
"name": "param",
|
|
814
|
+
"text": "errorMessage - the error message to display"
|
|
815
|
+
}, {
|
|
816
|
+
"name": "param",
|
|
817
|
+
"text": "errorMessageLock - lock the error message and validity state"
|
|
818
|
+
}]
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
"reset": {
|
|
822
|
+
"complexType": {
|
|
823
|
+
"signature": "() => Promise<void>",
|
|
824
|
+
"parameters": [],
|
|
825
|
+
"references": {
|
|
826
|
+
"Promise": {
|
|
827
|
+
"location": "global",
|
|
828
|
+
"id": "global::Promise"
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
"return": "Promise<void>"
|
|
832
|
+
},
|
|
833
|
+
"docs": {
|
|
834
|
+
"text": "Reset value, validity and error state",
|
|
835
|
+
"tags": []
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
static get elementRef() { return "element"; }
|
|
841
|
+
static get watchers() {
|
|
842
|
+
return [{
|
|
843
|
+
"propName": "value",
|
|
844
|
+
"methodName": "watchValue"
|
|
845
|
+
}, {
|
|
846
|
+
"propName": "multiple",
|
|
847
|
+
"methodName": "watchMultiple"
|
|
848
|
+
}, {
|
|
849
|
+
"propName": "value",
|
|
850
|
+
"methodName": "watchMultiple"
|
|
851
|
+
}, {
|
|
852
|
+
"propName": "accept",
|
|
853
|
+
"methodName": "watchAccept"
|
|
854
|
+
}, {
|
|
855
|
+
"propName": "required",
|
|
856
|
+
"methodName": "handleValidityChange"
|
|
857
|
+
}, {
|
|
858
|
+
"propName": "disabled",
|
|
859
|
+
"methodName": "handleValidityChange"
|
|
860
|
+
}, {
|
|
861
|
+
"propName": "disabled",
|
|
862
|
+
"methodName": "watchDisabled"
|
|
863
|
+
}, {
|
|
864
|
+
"propName": "helpText",
|
|
865
|
+
"methodName": "watchHelpText"
|
|
866
|
+
}, {
|
|
867
|
+
"propName": "accept",
|
|
868
|
+
"methodName": "watchHelpText"
|
|
869
|
+
}, {
|
|
870
|
+
"propName": "maxSize",
|
|
871
|
+
"methodName": "watchHelpText"
|
|
872
|
+
}, {
|
|
873
|
+
"propName": "files",
|
|
874
|
+
"methodName": "watchFiles"
|
|
875
|
+
}];
|
|
876
|
+
}
|
|
877
|
+
}
|