@mgdis/mg-components 6.17.0 → 6.19.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-DCZEYvlH.js → index-Bp6wZzau.js} +5 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +438 -212
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +2 -2
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +93 -80
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +35 -26
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-D7jmj_lh.js} +7 -0
- package/dist/cjs/mg-loader.cjs.entry.js +2 -2
- package/dist/cjs/mg-progress.cjs.entry.js +2 -2
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +5 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
- 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-checkbox/mg-input-checkbox.js +36 -16
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +98 -78
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +41 -25
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +60 -40
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +35 -33
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
- 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 +404 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
- 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 +40 -9
- 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/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-fieldset.d.ts +11 -0
- package/dist/components/mg-fieldset.js +209 -0
- package/dist/components/mg-form.js +4 -3
- package/dist/components/mg-icon2.js +1 -1
- package/dist/components/mg-illustrated-message.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +29 -16
- package/dist/components/mg-input-combobox.js +92 -79
- package/dist/components/mg-input-date.js +34 -22
- package/dist/components/mg-input-numeric.js +25 -12
- package/dist/components/mg-input-password.js +23 -12
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +33 -24
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +51 -39
- package/dist/components/mg-input-textarea.js +28 -33
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +119 -19
- package/dist/components/mg-item-more2.js +5 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-message2.js +2 -2
- package/dist/components/mg-modal.js +3 -3
- package/dist/components/mg-panel.js +37 -8
- package/dist/components/mg-popover-content2.js +2 -2
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/esm/{index-T6kOJXP1.js → index-BluNKQ3L.js} +5 -1
- package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +439 -213
- package/dist/esm/mg-alert.entry.js +3 -3
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +94 -81
- package/dist/esm/mg-input-rich-text-editor.entry.js +36 -27
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-DDnrE1hD.js} +6 -1
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-progress.entry.js +3 -3
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-016bd291.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-186a6139.entry.js} +1 -1
- package/dist/mg-components/p-66a1cb83.entry.js +1 -0
- package/dist/mg-components/p-6efd819f.entry.js +1 -0
- package/dist/mg-components/{p-c5da335e.entry.js → p-916dfb6d.entry.js} +1 -1
- package/dist/mg-components/p-BluNKQ3L.js +2 -0
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-DDnrE1hD.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-d2c72f09.entry.js} +1 -1
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-d5a276eb.entry.js} +1 -1
- package/dist/types/assets/icons/index.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +8 -7
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -8
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
- package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
- package/dist/types/components.d.ts +168 -18
- package/ide/intellij/web-types.json +289 -22
- package/ide/vscode/css-custom-data.json +7 -3
- package/ide/vscode/html-custom-data.json +300 -8
- package/package.json +18 -18
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-T6kOJXP1.js +0 -2
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -10,7 +10,7 @@ const sizes = ['small', 'medium', 'large'];
|
|
|
10
10
|
*/
|
|
11
11
|
const directions = ['vertical', 'horizontal'];
|
|
12
12
|
|
|
13
|
-
const mgIllustratedMessageCss = "/*!\n * @prop --mg-c-illustrated-message-spacing-vertical: Defines the vertical padding of the illustrated message. Default value: `--mg-b-size-40`.\n */.mg-c-illustrated-message{display:flex;max-width:calc(60*var(--mg-b-size-8));box-sizing:border-box;flex-direction:column;justify-content:center;padding:var(--mg-c-illustrated-message-spacing-vertical) var(--mg-b-size-16);margin:auto;gap:var(--mg-b-size-16) var(--mg-b-size-64);text-align:center}.mg-c-illustrated-message__illustration{max-height:calc(15*var(--mg-b-size-8))}.mg-c-illustrated-message__illustration ::slotted([slot=illustration]){width:100%;max-width:100%;height:auto;max-height:calc(15*var(--mg-b-size-8))}.mg-c-illustrated-message__slots{display:flex;flex-direction:column;gap:var(--mg-b-size-
|
|
13
|
+
const mgIllustratedMessageCss = "/*!\n * @prop --mg-c-illustrated-message-spacing-vertical: Defines the vertical padding of the illustrated message. Default value: `--mg-b-size-40`.\n */.mg-c-illustrated-message{display:flex;max-width:calc(60*var(--mg-b-size-8));box-sizing:border-box;flex-direction:column;justify-content:center;padding:var(--mg-c-illustrated-message-spacing-vertical) var(--mg-b-size-16);margin:auto;gap:var(--mg-b-size-16) var(--mg-b-size-64);text-align:center}.mg-c-illustrated-message__illustration{max-height:calc(15*var(--mg-b-size-8))}.mg-c-illustrated-message__illustration ::slotted([slot=illustration]){width:100%;max-width:100%;max-width:calc(15*var(--mg-b-size-8));height:auto;max-height:calc(15*var(--mg-b-size-8))}.mg-c-illustrated-message__slots{display:flex;flex-direction:column;gap:var(--mg-b-size-8)}.mg-c-illustrated-message__slots ::slotted([slot=title]){margin:0;font-family:var(--mg-b-font-family) !important;font-size:var(--mg-b-font-size-h2) !important;font-weight:400 !important}.mg-c-illustrated-message__slots ::slotted([slot=details]){margin:0}.mg-c-illustrated-message.mg-c-illustrated-message--size-small{--mg-c-illustrated-message-spacing-vertical: var(--mg-b-size-24)}.mg-c-illustrated-message.mg-c-illustrated-message--size-small .mg-c-illustrated-message__slots{gap:calc(var(--mg-b-size-4)/2)}.mg-c-illustrated-message.mg-c-illustrated-message--size-small .mg-c-illustrated-message__illustration{max-height:var(--mg-b-size-64)}.mg-c-illustrated-message.mg-c-illustrated-message--size-small .mg-c-illustrated-message__illustration ::slotted([slot=illustration]){max-height:var(--mg-b-size-64)}.mg-c-illustrated-message.mg-c-illustrated-message--size-large .mg-c-illustrated-message__illustration{max-height:calc(23*var(--mg-b-size-8))}.mg-c-illustrated-message.mg-c-illustrated-message--size-large .mg-c-illustrated-message__illustration ::slotted([slot=illustration]){max-height:calc(23*var(--mg-b-size-8))}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal{max-width:unset}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal .mg-c-illustrated-message__slots{max-width:calc(60*var(--mg-b-size-8))}@container (width > 52.8rem){.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal{flex-direction:row;align-items:center;column-gap:var(--mg-b-size-48);text-align:left}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal .mg-c-illustrated-message__slots{max-width:unset}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal .mg-c-illustrated-message__illustration{max-width:fit-content;flex:1 0 auto}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal.mg-c-illustrated-message--size-small{column-gap:var(--mg-b-size-24)}.mg-c-illustrated-message.mg-c-illustrated-message--direction-horizontal.mg-c-illustrated-message--size-large{column-gap:var(--mg-b-size-64)}}:host{display:block;container-type:inline-size}\n";
|
|
14
14
|
|
|
15
15
|
const MgIllustratedMessage$1 = /*@__PURE__*/ proxyCustomElement(class MgIllustratedMessage extends HTMLElement {
|
|
16
16
|
constructor(registerHost) {
|
|
@@ -92,7 +92,7 @@ const MgIllustratedMessage$1 = /*@__PURE__*/ proxyCustomElement(class MgIllustra
|
|
|
92
92
|
* @returns HTML Element
|
|
93
93
|
*/
|
|
94
94
|
render() {
|
|
95
|
-
return (h("div", { key: '
|
|
95
|
+
return (h("div", { key: 'c9d8c8bfd2792b1cf5e78ab9d168d597b20e9a1e', class: this.classCollection.join() }, h("div", { key: 'cc8fa03147b9e59e6e8e015be9ed2b8dddd92ded', class: "mg-c-illustrated-message__illustration" }, h("slot", { key: '83a4ec2223c4e74511beb7c0abfa10e77cee425d', name: "illustration" })), h("div", { key: 'dbb4d13ca5324cab889fa2acc9b9b22522d7a8ec', class: "mg-c-illustrated-message__slots" }, h("slot", { key: '9e74d84becf29539ec9c37e8ad1e317714f3c86c', name: "title" }), h("slot", { key: 'ae97d25c19b76ca092560d2555ebd6a87f542ffe', name: "details" }))));
|
|
96
96
|
}
|
|
97
97
|
get element() { return this; }
|
|
98
98
|
static get watchers() { return {
|
|
@@ -88,7 +88,7 @@ const MgInputCheckboxPaginated = /*@__PURE__*/ proxyCustomElement(class MgInputC
|
|
|
88
88
|
render() {
|
|
89
89
|
const listId = formatID(this.messages.label);
|
|
90
90
|
const tabId = 'tab-info';
|
|
91
|
-
return (h(Host, { key: '
|
|
91
|
+
return (h(Host, { key: '233ab4fca3f4a3121bc60650ac2f8ae06d47e6e5' }, h("slot", { key: '7d1af8c712928c06953743fc5c182e51d9a6256b', name: "header-action" }), h("div", { key: '95641bd218e36422a6b5b4ead8dd5498e8ac5fa4', class: "mg-c-input__tabs-content" }, h("p", { key: '34814dd1afc9f871cd032500b931e692d63cbd25', id: tabId, class: { 'mg-c-input__popover-info': true, 'mg-u-visually-hidden': this.items.length !== 0 }, "aria-live": this.items.length !== 0 ? 'polite' : undefined }, this.items.length === 0 ? this.messages.noValue : this.messages.values.replace('{count}', this.items.length.toString())), this.items.length > 0 && (h(MgInputCheckboxList, { key: '621077f291a401737157ad0cd9b9348537ef8bdc', checkboxes: this.items, labelledby: tabId, id: listId, disabled: this.disabled, name: this.name, invalid: this.invalid })), this.hasNext() && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, "full-width": true, onClick: this.handleLoadMore, "aria-controls": listId }, h("mg-icon", { key: 'cb00bbeb1575475b184cc9623db6c4cefc56c26a', icon: "chevron-down" }), this.messages.showMore)))));
|
|
92
92
|
}
|
|
93
93
|
static get watchers() { return {
|
|
94
94
|
"checkboxes": ["watchCheckboxes"],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { C as ClassList, m as cleanString, i as isValidString, t as toString } from './index2.js';
|
|
3
3
|
import { d as defineCustomElement$9, a as MgInputCheckboxList } from './mg-input-checkbox-paginated2.js';
|
|
4
|
-
import { d as defineCustomElement$a, b as classFieldset,
|
|
4
|
+
import { d as defineCustomElement$a, b as classFieldset, f as classVerticalList, c as classReadonly, a as classDisabled } from './mg-input2.js';
|
|
5
5
|
import { i as initLocales } from './index3.js';
|
|
6
6
|
import { d as defineCustomElement$4, S as Status } from './mg-tabs2.js';
|
|
7
7
|
import { d as defineCustomElement$f } from './mg-badge2.js';
|
|
@@ -48,6 +48,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
48
48
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
49
49
|
// hasDisplayedError (triggered by blur event)
|
|
50
50
|
this.hasDisplayedError = false;
|
|
51
|
+
this.customErrorMessage = { lock: false };
|
|
51
52
|
this.mode = 'custom';
|
|
52
53
|
// style
|
|
53
54
|
this.baseClassName = 'mg-c-input--checkbox';
|
|
@@ -265,17 +266,20 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
265
266
|
};
|
|
266
267
|
/**
|
|
267
268
|
* Set input error message
|
|
268
|
-
* @param
|
|
269
|
-
* @param errorMessage - errorMessage override
|
|
269
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
270
270
|
*/
|
|
271
|
-
this.setErrorMessage = (
|
|
271
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
272
272
|
// Set error message
|
|
273
273
|
this.errorMessage = undefined;
|
|
274
|
-
if (
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
if (!this.valid) {
|
|
275
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
276
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
277
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
278
|
+
}
|
|
279
|
+
// required
|
|
280
|
+
else if (!this.validateRequired()) {
|
|
278
281
|
this.errorMessage = this.messages.errors.required;
|
|
282
|
+
}
|
|
279
283
|
}
|
|
280
284
|
};
|
|
281
285
|
/**
|
|
@@ -369,7 +373,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
369
373
|
this.checkValidity();
|
|
370
374
|
if (this.hasDisplayedError) {
|
|
371
375
|
this.hasDisplayedError = prop !== 'required';
|
|
372
|
-
this.setErrorMessage(
|
|
376
|
+
this.setErrorMessage();
|
|
373
377
|
}
|
|
374
378
|
this.setButtonTextKey();
|
|
375
379
|
}
|
|
@@ -433,17 +437,22 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
433
437
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
434
438
|
* @param valid - value indicating the validity
|
|
435
439
|
* @param errorMessage - the error message to display
|
|
440
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
436
441
|
*/
|
|
437
|
-
async setError(valid, errorMessage) {
|
|
442
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
438
443
|
if (typeof valid !== 'boolean') {
|
|
439
444
|
throw new Error('<mg-input-checkbox> method "setError()" param "valid" must be a boolean.');
|
|
440
445
|
}
|
|
441
|
-
else if (!isValidString(errorMessage)) {
|
|
446
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
442
447
|
throw new Error('<mg-input-checkbox> method "setError()" param "errorMessage" must be a string.');
|
|
443
448
|
}
|
|
444
449
|
else {
|
|
450
|
+
this.customErrorMessage = {
|
|
451
|
+
lock: valid ? false : errorMessageLock,
|
|
452
|
+
message: valid ? undefined : errorMessage,
|
|
453
|
+
};
|
|
445
454
|
this.setValidity(valid);
|
|
446
|
-
this.setErrorMessage(
|
|
455
|
+
this.setErrorMessage(true);
|
|
447
456
|
this.hasDisplayedError = this.invalid;
|
|
448
457
|
}
|
|
449
458
|
}
|
|
@@ -461,6 +470,8 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
461
470
|
// - Keep everything in sync both inside and outside the component
|
|
462
471
|
return new Promise(resolve => {
|
|
463
472
|
requestAnimationFrame(() => {
|
|
473
|
+
// unlock validity check by reseting customErrorMessage
|
|
474
|
+
this.customErrorMessage = { lock: false };
|
|
464
475
|
this.checkValidity();
|
|
465
476
|
this.errorMessage = undefined;
|
|
466
477
|
this.hasDisplayedError = false;
|
|
@@ -474,11 +485,13 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
474
485
|
* @param newValue - valid new value
|
|
475
486
|
*/
|
|
476
487
|
setValidity(newValue) {
|
|
477
|
-
const
|
|
478
|
-
this.
|
|
488
|
+
const oldValue = this.valid;
|
|
489
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
490
|
+
this.valid = newValue;
|
|
491
|
+
}
|
|
479
492
|
this.invalid = !this.valid;
|
|
480
493
|
// We need to send valid event even if it is the same value
|
|
481
|
-
if (this.valid !==
|
|
494
|
+
if (this.valid !== oldValue)
|
|
482
495
|
this.inputValid.emit(this.valid);
|
|
483
496
|
}
|
|
484
497
|
/**
|
|
@@ -597,7 +610,7 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCheckbox
|
|
|
597
610
|
else {
|
|
598
611
|
inputContent = this.renderCheckboxMulti();
|
|
599
612
|
}
|
|
600
|
-
return (h("mg-input", { key: '
|
|
613
|
+
return (h("mg-input", { key: '5addea288b5c87fec33a56449d14f861aefd465d', label: this.label, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, tooltip: this.tooltip, tooltipPosition: this.readonly && readonlyValue.length === 0 ? 'label' : this.tooltipPosition, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined }, inputContent));
|
|
601
614
|
}
|
|
602
615
|
get element() { return this; }
|
|
603
616
|
static get watchers() { return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
-
import { P as Paginate, C as ClassList,
|
|
2
|
+
import { P as Paginate, C as ClassList, t as toString, e as Cursor, n as nextTick, h as Page, j as getObjectValueFromKey, d as allItemsAreString, i as isValidString, k as isObject, f as formatID } from './index2.js';
|
|
3
3
|
import { d as defineCustomElement$8, c as classReadonly, a as classDisabled, w as widths } from './mg-input2.js';
|
|
4
4
|
import { i as initLocales } from './index3.js';
|
|
5
5
|
import { K as Keys } from './events.utils.js';
|
|
@@ -13,7 +13,7 @@ import { d as defineCustomElement$4 } from './mg-popover-content2.js';
|
|
|
13
13
|
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
14
14
|
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
15
15
|
|
|
16
|
-
const mgInputComboboxCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-
|
|
16
|
+
const mgInputComboboxCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__popover-info{padding:var(--mg-b-size-8);margin:0;color:var(--mg-b-color-neutral-90);text-align:center}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-full .mg-c-input__input-group-container{width:100%;flex-grow:1}.mg-c-input.mg-c-input--width-2.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-4.mg-c-input--display-character-left .mg-c-input__input-group-container,.mg-c-input.mg-c-input--width-16.mg-c-input--display-character-left .mg-c-input__input-group-container{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16.mg-c-input--text.mg-c-input--display-character-left .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input.mg-c-input--combobox mg-popover{--mg-c-card-overflow:hidden;--mg-c-popover-padding-vertical:0;--mg-c-popover-padding-horizontal:0}.mg-c-input.mg-c-input--combobox .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--combobox .mg-c-input__box{cursor:pointer}.mg-c-input.mg-c-input--combobox .mg-c-input__popover-container{display:flex;min-width:var(--mg-c-input-list-width);max-height:calc(50*var(--mg-b-size-8) - var(--mg-b-size-32));flex-direction:column;gap:var(--mg-b-size-4);overflow-y:scroll}.mg-c-input.mg-c-input--combobox .mg-c-input__load-more{padding:0 var(--mg-b-size-8) var(--mg-b-size-4)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list{padding:0;margin:0;cursor:pointer;list-style:none}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item{display:flex;padding:var(--mg-b-size-8)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item:hover,.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--focus-visible{background-color:var(--mg-b-color-neutral-20)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected{font-weight:700}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected mg-icon{margin-left:auto}.mg-c-input.mg-c-input--combobox.mg-c-input--width-2 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-24) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-4 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-48) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-16 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + calc(23 * var(--mg-b-size-8)) + var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full mg-popover{--mg-c-popover-max-width:var(--mg-c-input-list-width, var(--mg-c-popover-max-width))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__input-group-container{display:flex;width:100%}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__box{flex:1}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box{padding-right:calc(var(--mg-b-size-min-height) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box-append{position:absolute;top:0;right:0}";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Check if object is an item
|
|
@@ -38,7 +38,7 @@ const isFetchmappings = (value) => {
|
|
|
38
38
|
const { request, response } = value;
|
|
39
39
|
if ([request, response].some(property => !isObject(property)))
|
|
40
40
|
return false;
|
|
41
|
-
const isValidRequest = typeof request.filter === 'string';
|
|
41
|
+
const isValidRequest = typeof request.filter === 'string' && (request.filterTransform === undefined || typeof request.filterTransform === 'function');
|
|
42
42
|
const isValidResponse = typeof response === 'object' &&
|
|
43
43
|
typeof response.total === 'string' &&
|
|
44
44
|
typeof response.items === 'string' &&
|
|
@@ -63,13 +63,9 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
63
63
|
this.showMore = createEvent(this, "load-more", 7);
|
|
64
64
|
this.inputValid = createEvent(this, "input-valid", 7);
|
|
65
65
|
this.fetchError = createEvent(this, "fetch-error", 7);
|
|
66
|
-
/************
|
|
67
|
-
* Internal *
|
|
68
|
-
************/
|
|
69
|
-
// Classes
|
|
70
|
-
this.classFocus = 'mg-u-is-focused';
|
|
71
66
|
// hasDisplayedError (triggered by blur event)
|
|
72
67
|
this.hasDisplayedError = false;
|
|
68
|
+
this.customErrorMessage = { lock: false };
|
|
73
69
|
/**
|
|
74
70
|
* Input name
|
|
75
71
|
* If not set the value equals the identifier
|
|
@@ -124,7 +120,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
124
120
|
* @param event - option element click event
|
|
125
121
|
*/
|
|
126
122
|
this.handleOptionClick = (event) => {
|
|
127
|
-
this.setValue(this.options.items.find(option =>
|
|
123
|
+
this.setValue(this.options.items.find(option => toString(option.value) === event.target.dataset.value));
|
|
128
124
|
this.popoverDisplay = false;
|
|
129
125
|
};
|
|
130
126
|
/**
|
|
@@ -204,7 +200,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
204
200
|
// override keys actions
|
|
205
201
|
switch (event.key) {
|
|
206
202
|
case Keys.TAB:
|
|
207
|
-
case Keys.ENTER:
|
|
203
|
+
case Keys.ENTER: {
|
|
208
204
|
guard = event.key === Keys.ENTER;
|
|
209
205
|
const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
|
|
210
206
|
// Sets the value to the content of the focused option in the listbox.
|
|
@@ -214,12 +210,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
214
210
|
// Closes the popover.
|
|
215
211
|
this.popoverDisplay = false;
|
|
216
212
|
break;
|
|
213
|
+
}
|
|
217
214
|
case Keys.DOWN:
|
|
218
215
|
case Keys.ARROWDOWN:
|
|
219
216
|
case Keys.UP:
|
|
220
|
-
case Keys.ARROWUP:
|
|
217
|
+
case Keys.ARROWUP: {
|
|
221
218
|
guard = true;
|
|
222
|
-
if (this.isLoading ||
|
|
219
|
+
if (this.isLoading || this.page.total === 0) {
|
|
223
220
|
this.popoverDisplay = true;
|
|
224
221
|
break;
|
|
225
222
|
}
|
|
@@ -250,12 +247,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
250
247
|
// open popover
|
|
251
248
|
this.popoverDisplay = true;
|
|
252
249
|
break;
|
|
250
|
+
}
|
|
253
251
|
case Keys.LEFT:
|
|
254
252
|
case Keys.ARROWLEFT:
|
|
255
253
|
case Keys.HOME:
|
|
256
254
|
case Keys.RIGHT:
|
|
257
255
|
case Keys.ARROWRIGHT:
|
|
258
|
-
case Keys.END:
|
|
256
|
+
case Keys.END: {
|
|
259
257
|
// skip process if visual focus is not in popover
|
|
260
258
|
if (!isItem(this.option))
|
|
261
259
|
break;
|
|
@@ -275,8 +273,9 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
275
273
|
this.input.setSelectionRange(index, index);
|
|
276
274
|
}
|
|
277
275
|
break;
|
|
276
|
+
}
|
|
278
277
|
case Keys.ESC:
|
|
279
|
-
case Keys.ESCAPE:
|
|
278
|
+
case Keys.ESCAPE: {
|
|
280
279
|
guard = true;
|
|
281
280
|
if (this.popoverDisplay) {
|
|
282
281
|
// If the popover is displayed, closes it.
|
|
@@ -290,10 +289,12 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
290
289
|
this.option = null;
|
|
291
290
|
}
|
|
292
291
|
break;
|
|
293
|
-
|
|
292
|
+
}
|
|
293
|
+
default: {
|
|
294
294
|
// Remove visual focus from popover options
|
|
295
295
|
this.option = null;
|
|
296
296
|
break;
|
|
297
|
+
}
|
|
297
298
|
}
|
|
298
299
|
if (guard) {
|
|
299
300
|
event.stopPropagation();
|
|
@@ -339,40 +340,41 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
339
340
|
};
|
|
340
341
|
/**
|
|
341
342
|
* Set input error message
|
|
342
|
-
* @param
|
|
343
|
+
* @param fromSetErrorContext - context come from `setError` method
|
|
343
344
|
*/
|
|
344
|
-
this.setErrorMessage = (
|
|
345
|
+
this.setErrorMessage = (fromSetErrorContext = false) => {
|
|
345
346
|
// Set error message
|
|
346
347
|
this.errorMessage = undefined;
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
this.
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
348
|
+
if (!this.valid) {
|
|
349
|
+
// Does have a new custom error message OR does have a custom error message locked
|
|
350
|
+
if (fromSetErrorContext || (this.customErrorMessage.lock && this.customErrorMessage.message !== undefined)) {
|
|
351
|
+
this.errorMessage = this.customErrorMessage.message;
|
|
352
|
+
}
|
|
353
|
+
// required
|
|
354
|
+
else if (this.input.validity.valueMissing) {
|
|
355
|
+
this.errorMessage = this.messages.errors.required;
|
|
356
|
+
}
|
|
354
357
|
}
|
|
355
358
|
};
|
|
356
359
|
/**
|
|
357
|
-
* Get
|
|
358
|
-
* @returns
|
|
360
|
+
* Get first page with filter applied
|
|
361
|
+
* @returns first page with filter applied
|
|
359
362
|
*/
|
|
360
|
-
this.
|
|
363
|
+
this.getFirstPage = () => this.options.getPage(0, option => this.filter === '' || option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
|
|
361
364
|
/**
|
|
362
365
|
* Loading wrapper with a given action
|
|
363
366
|
* @param action - wrapped loading action
|
|
364
367
|
* @returns promisified action
|
|
365
368
|
*/
|
|
366
369
|
this.loadingWrapper = (action) => {
|
|
370
|
+
var _a;
|
|
367
371
|
let promise;
|
|
368
372
|
let index;
|
|
369
373
|
// cache initial loading action if not defined
|
|
370
|
-
|
|
371
|
-
this.loadingAction = action.name;
|
|
372
|
-
}
|
|
374
|
+
(_a = this.loadingAction) !== null && _a !== void 0 ? _a : (this.loadingAction = action.name);
|
|
373
375
|
// update index
|
|
374
376
|
if (Boolean(this.option) && this.loadingAction !== 'load-more') {
|
|
375
|
-
index = this.page.items.findIndex(option => option.value
|
|
377
|
+
index = this.page.items.findIndex(option => toString(option.value) === toString(this.option.value));
|
|
376
378
|
}
|
|
377
379
|
else if (this.loadingAction === 'load-more') {
|
|
378
380
|
index = this.page.items.length - this.page.baseIndex;
|
|
@@ -402,7 +404,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
402
404
|
return promise()
|
|
403
405
|
.then(() => {
|
|
404
406
|
// parse full items list from options
|
|
405
|
-
const options = this.options.items.filter(this.
|
|
407
|
+
const options = this.filter === '' ? this.options.items : this.options.items.filter(option => option.title.includes(this.filter));
|
|
406
408
|
// update visual focus
|
|
407
409
|
if (action.name !== 'load-data') {
|
|
408
410
|
index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
|
|
@@ -425,14 +427,14 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
425
427
|
*/
|
|
426
428
|
this.goToNextPage = () => {
|
|
427
429
|
this.showMore.emit();
|
|
428
|
-
if (
|
|
430
|
+
if (this.fetchurl !== undefined) {
|
|
429
431
|
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
430
|
-
if (
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
432
|
+
if (nextPage !== undefined) {
|
|
433
|
+
// merge items from current page and next page
|
|
434
|
+
const items = [...this.page.items, ...nextPage.items];
|
|
435
|
+
// create new options pagination withe merged items
|
|
436
|
+
this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
|
|
437
|
+
}
|
|
436
438
|
});
|
|
437
439
|
}
|
|
438
440
|
else {
|
|
@@ -449,16 +451,16 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
449
451
|
* @returns promise
|
|
450
452
|
*/
|
|
451
453
|
this.updatePage = async () => {
|
|
452
|
-
if (
|
|
454
|
+
if (this.fetchurl !== undefined) {
|
|
453
455
|
return this.getOptions().then(page => {
|
|
454
|
-
if (
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
if (page !== undefined) {
|
|
457
|
+
// reset current options pagination from API response
|
|
458
|
+
this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
459
|
+
}
|
|
458
460
|
});
|
|
459
461
|
}
|
|
460
462
|
else {
|
|
461
|
-
this.page = this.
|
|
463
|
+
this.page = this.getFirstPage();
|
|
462
464
|
}
|
|
463
465
|
};
|
|
464
466
|
/**
|
|
@@ -467,8 +469,9 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
467
469
|
* @returns new page from url
|
|
468
470
|
*/
|
|
469
471
|
this.getOptions = async (url = this.fetchurl) => {
|
|
470
|
-
// add text filter
|
|
471
|
-
const
|
|
472
|
+
// add text filter to url
|
|
473
|
+
const filter = typeof this.fetchmappings.request.filterTransform === 'function' ? this.fetchmappings.request.filterTransform(this.filter) : this.filter;
|
|
474
|
+
const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(filter));
|
|
472
475
|
try {
|
|
473
476
|
const response = await fetch(updateUrl, this.fetchoptions);
|
|
474
477
|
if (!response.ok) {
|
|
@@ -476,10 +479,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
476
479
|
return;
|
|
477
480
|
}
|
|
478
481
|
const json = await response.json();
|
|
479
|
-
const items = getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) =>
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
482
|
+
const items = getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => {
|
|
483
|
+
var _a;
|
|
484
|
+
return ({
|
|
485
|
+
title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
|
|
486
|
+
value: (_a = getObjectValueFromKey(item, this.fetchmappings.response.itemValue)) !== null && _a !== void 0 ? _a : item,
|
|
487
|
+
});
|
|
488
|
+
});
|
|
483
489
|
const total = Number(getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
|
|
484
490
|
let next = getObjectValueFromKey(json, this.fetchmappings.response.next);
|
|
485
491
|
if (URL.canParse(updateUrl) && Boolean(next) && !URL.canParse(next)) {
|
|
@@ -500,11 +506,11 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
500
506
|
this.valueChange.emit(newValue);
|
|
501
507
|
}
|
|
502
508
|
watchItems(newValue) {
|
|
503
|
-
if (
|
|
509
|
+
if (this.fetchurl !== undefined && newValue === undefined) {
|
|
504
510
|
// skip newValue check
|
|
505
511
|
return;
|
|
506
512
|
}
|
|
507
|
-
else if (
|
|
513
|
+
else if (this.fetchurl !== undefined && newValue !== undefined) {
|
|
508
514
|
throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
|
|
509
515
|
}
|
|
510
516
|
// Empty options
|
|
@@ -524,7 +530,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
524
530
|
}
|
|
525
531
|
}
|
|
526
532
|
watchIdentifier(newValue) {
|
|
527
|
-
if (
|
|
533
|
+
if (isValidString(newValue)) {
|
|
528
534
|
this.popoverId = `${newValue}-popover`;
|
|
529
535
|
this.element.dataset.mgPopoverGuard = this.popoverId;
|
|
530
536
|
}
|
|
@@ -564,7 +570,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
564
570
|
this.classCollection = new ClassList(this.classCollection.classes);
|
|
565
571
|
}
|
|
566
572
|
watchFetchUrl(newValue) {
|
|
567
|
-
if (
|
|
573
|
+
if (newValue !== undefined) {
|
|
568
574
|
this.loadingWrapper({ name: 'load-data' });
|
|
569
575
|
}
|
|
570
576
|
}
|
|
@@ -572,20 +578,17 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
572
578
|
if (this.fetchurl && newValue && !isObject(newValue)) {
|
|
573
579
|
throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${toString(newValue)}.`);
|
|
574
580
|
}
|
|
575
|
-
else {
|
|
576
|
-
new Request(this.fetchurl, newValue);
|
|
577
|
-
}
|
|
578
581
|
}
|
|
579
582
|
watchFetchMappings(newValue) {
|
|
580
|
-
if (
|
|
583
|
+
if (this.fetchurl !== undefined && !isObject(newValue)) {
|
|
581
584
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
|
|
582
585
|
}
|
|
583
|
-
else if (
|
|
586
|
+
else if (newValue !== undefined && !isFetchmappings(newValue)) {
|
|
584
587
|
throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${toString(newValue)}.`);
|
|
585
588
|
}
|
|
586
589
|
}
|
|
587
|
-
watchOptions(
|
|
588
|
-
this.page =
|
|
590
|
+
watchOptions() {
|
|
591
|
+
this.page = this.getFirstPage();
|
|
589
592
|
}
|
|
590
593
|
watchFilter(newValue) {
|
|
591
594
|
this.loadingWrapper({ name: 'load-data' });
|
|
@@ -593,7 +596,6 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
593
596
|
}
|
|
594
597
|
watchPopoverDisplay(newValue) {
|
|
595
598
|
if (newValue) {
|
|
596
|
-
this.classCollection.add(this.classFocus);
|
|
597
599
|
this.input.focus();
|
|
598
600
|
}
|
|
599
601
|
else {
|
|
@@ -601,7 +603,6 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
601
603
|
this.option = null;
|
|
602
604
|
// reset filter with value
|
|
603
605
|
this.filter = this.getValueTitle();
|
|
604
|
-
this.classCollection.delete(this.classFocus);
|
|
605
606
|
this.handlerInProgress = 'blur';
|
|
606
607
|
this.displayError().finally(() => {
|
|
607
608
|
// reset guard
|
|
@@ -642,17 +643,22 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
642
643
|
* When used to set validity to `false`, you should use this method again to reset the validity to `true`.
|
|
643
644
|
* @param valid - value indicating the validity
|
|
644
645
|
* @param errorMessage - the error message to display
|
|
646
|
+
* @param errorMessageLock - lock the error message and validity state
|
|
645
647
|
*/
|
|
646
|
-
async setError(valid, errorMessage) {
|
|
648
|
+
async setError(valid, errorMessage, errorMessageLock = false) {
|
|
647
649
|
if (typeof valid !== 'boolean') {
|
|
648
650
|
throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
|
|
649
651
|
}
|
|
650
|
-
else if (!isValidString(errorMessage)) {
|
|
652
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
651
653
|
throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
|
|
652
654
|
}
|
|
653
655
|
else {
|
|
656
|
+
this.customErrorMessage = {
|
|
657
|
+
lock: valid ? false : errorMessageLock,
|
|
658
|
+
message: valid ? undefined : errorMessage,
|
|
659
|
+
};
|
|
654
660
|
this.setValidity(valid);
|
|
655
|
-
this.setErrorMessage(
|
|
661
|
+
this.setErrorMessage(true);
|
|
656
662
|
this.hasDisplayedError = this.invalid;
|
|
657
663
|
}
|
|
658
664
|
}
|
|
@@ -672,6 +678,8 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
672
678
|
// - Keep everything in sync both inside and outside the component
|
|
673
679
|
return new Promise(resolve => {
|
|
674
680
|
requestAnimationFrame(() => {
|
|
681
|
+
// unlock validity check by reseting customErrorMessage
|
|
682
|
+
this.customErrorMessage = { lock: false };
|
|
675
683
|
this.checkValidity();
|
|
676
684
|
this.errorMessage = undefined;
|
|
677
685
|
this.hasDisplayedError = false;
|
|
@@ -700,11 +708,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
700
708
|
* @param newValue - valid new value
|
|
701
709
|
*/
|
|
702
710
|
setValidity(newValue) {
|
|
703
|
-
const
|
|
704
|
-
this.
|
|
711
|
+
const oldValue = this.valid;
|
|
712
|
+
if (!this.customErrorMessage.lock || (this.customErrorMessage.message !== undefined && !newValue)) {
|
|
713
|
+
this.valid = newValue;
|
|
714
|
+
}
|
|
705
715
|
this.invalid = !this.valid;
|
|
706
716
|
// We need to send valid event even if it is the same value
|
|
707
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !==
|
|
717
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValue))
|
|
708
718
|
this.inputValid.emit(this.valid);
|
|
709
719
|
}
|
|
710
720
|
/*************
|
|
@@ -720,13 +730,13 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
720
730
|
// Validate
|
|
721
731
|
this.watchIdentifier(this.identifier);
|
|
722
732
|
this.watchItems(this.items);
|
|
723
|
-
if (
|
|
733
|
+
if (this.fetchurl !== undefined) {
|
|
724
734
|
this.watchFetchOptions(this.fetchoptions);
|
|
725
735
|
this.watchFetchMappings(this.fetchmappings);
|
|
726
736
|
this.loadingWrapper({ name: 'load-data' });
|
|
727
737
|
}
|
|
728
738
|
this.watchValue(this.value);
|
|
729
|
-
this.watchOptions(
|
|
739
|
+
this.watchOptions();
|
|
730
740
|
this.watchMgWidth(this.mgWidth);
|
|
731
741
|
this.watchReadonly(this.readonly);
|
|
732
742
|
this.watchDisabled(this.disabled);
|
|
@@ -747,14 +757,17 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
747
757
|
const readonlyValue = this.getValueTitle();
|
|
748
758
|
const withResetButton = this.value && !this.disabled;
|
|
749
759
|
let popoverContent;
|
|
750
|
-
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
|
|
760
|
+
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0) {
|
|
751
761
|
popoverContent = 'list';
|
|
752
|
-
|
|
762
|
+
}
|
|
763
|
+
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
|
|
753
764
|
popoverContent = 'notfound';
|
|
754
|
-
|
|
765
|
+
}
|
|
766
|
+
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
|
|
755
767
|
popoverContent = 'notavailable';
|
|
768
|
+
}
|
|
756
769
|
let activeDescendant;
|
|
757
|
-
if (
|
|
770
|
+
if (((_d = this.option) === null || _d === void 0 ? void 0 : _d.value) !== undefined) {
|
|
758
771
|
activeDescendant = this.option.value;
|
|
759
772
|
}
|
|
760
773
|
else if (typeof this.value === 'string') {
|
|
@@ -763,8 +776,8 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
763
776
|
else {
|
|
764
777
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
765
778
|
}
|
|
766
|
-
return (h("mg-input", { key: '
|
|
767
|
-
'--mg-c-input-list-width':
|
|
779
|
+
return (h("mg-input", { key: 'fd5a59f1e0bf31342a3bf935a60a2877e5df1772', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? popoverContent : undefined, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
|
|
780
|
+
'--mg-c-input-list-width': ((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) > 0 ? `${this.input.offsetWidth}px` : undefined,
|
|
768
781
|
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
769
782
|
if (el !== null)
|
|
770
783
|
this.input = el;
|
|
@@ -778,7 +791,7 @@ const MgInputCombobox$1 = /*@__PURE__*/ proxyCustomElement(class MgInputCombobox
|
|
|
778
791
|
'mg-c-input__input-list-item': true,
|
|
779
792
|
'mg-c-input__input-list-item--focus-visible': JSON.stringify((_a = this.option) === null || _a === void 0 ? void 0 : _a.value) === JSON.stringify(option.value),
|
|
780
793
|
'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
|
|
781
|
-
}, key: option.title, id: formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
|
|
794
|
+
}, key: option.title, id: formatID(option.value), "aria-selected": this.isCurrentOption(option).toString(), "data-value": toString(option.value), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
|
|
782
795
|
})),
|
|
783
796
|
this.isLoading && h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
|
|
784
797
|
this.page.next && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, disabled: this.isLoading, "full-width": true, "disable-on-click": true, onClick: this.handleLoadMoreButton, "aria-controls": listId, ref: (el) => {
|