@mgdis/mg-components 6.15.0 → 6.16.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/events.utils-D5SAtkpQ.js +25 -0
- package/dist/cjs/{index-BGxkpQwi.js → index-T3-qWqFE.js} +2 -2
- package/dist/cjs/{index-iUZvsp-F.js → index-YM1EJx9X.js} +8 -20
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +68 -305
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-input-combobox.cjs.entry.js +78 -140
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +3 -3
- package/dist/cjs/{mg-input.conf-CwjEAih3.js → mg-input.conf-WTsvDfpC.js} +0 -7
- package/dist/cjs/mg-loader.cjs.entry.js +2 -2
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +0 -6
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +22 -93
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +13 -69
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +54 -136
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +10 -63
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +6 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -142
- package/dist/collection/locales/en/messages.json +3 -8
- package/dist/collection/locales/fr/messages.json +3 -8
- package/dist/components/index2.js +1 -1
- package/dist/components/index3.js +8 -20
- package/dist/components/mg-details.js +97 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -2
- package/dist/components/mg-input-checkbox.js +19 -63
- package/dist/components/mg-input-combobox.js +60 -130
- package/dist/components/mg-input-date.js +1 -7
- package/dist/components/mg-input-numeric.js +1 -7
- package/dist/components/mg-input-password.js +2 -8
- package/dist/components/mg-input-radio.js +12 -53
- package/dist/components/mg-input-rich-text-editor.js +1 -7
- package/dist/components/mg-input-select2.js +8 -44
- package/dist/components/mg-input-text2.js +2 -8
- package/dist/components/mg-input-textarea.js +2 -8
- package/dist/components/mg-input-toggle.js +11 -96
- package/dist/components/mg-input2.js +22 -99
- package/dist/components/mg-pagination.js +2 -8
- package/dist/components/mg-panel.js +7 -13
- package/dist/esm/events.utils-yMGqY8YG.js +23 -0
- package/dist/esm/{index-CKB-AnCZ.js → index-Bab8_u8S.js} +8 -20
- package/dist/esm/{index-DhAOnZJn.js → index-JHj_9FSs.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +64 -301
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-input-combobox.entry.js +59 -121
- package/dist/esm/mg-input-rich-text-editor.entry.js +3 -3
- package/dist/esm/{mg-input.conf-BAUTlb6r.js → mg-input.conf-CNgv8hc5.js} +1 -7
- package/dist/esm/mg-loader.entry.js +2 -2
- package/dist/esm/mg-progress.entry.js +1 -1
- package/dist/mg-components/locales/en/messages.json +3 -8
- package/dist/mg-components/locales/fr/messages.json +3 -8
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-420daa1e.entry.js → p-42a90251.entry.js} +1 -1
- package/dist/mg-components/p-54156253.entry.js +1 -0
- package/dist/mg-components/{p-47e19783.entry.js → p-658f828c.entry.js} +1 -1
- package/dist/mg-components/{p-67af6274.entry.js → p-82455ac7.entry.js} +1 -1
- package/dist/mg-components/p-Bab8_u8S.js +1 -0
- package/dist/mg-components/p-CNgv8hc5.js +1 -0
- package/dist/mg-components/{p-DhAOnZJn.js → p-JHj_9FSs.js} +1 -1
- package/dist/mg-components/p-abbd151c.entry.js +1 -0
- package/dist/mg-components/{p-a0fa44cf.entry.js → p-c85b5d10.entry.js} +1 -1
- package/dist/mg-components/p-yMGqY8YG.js +1 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +0 -13
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +4 -15
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +3 -21
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +2 -16
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -40
- package/dist/types/components.d.ts +7 -63
- package/ide/intellij/web-types.json +10 -136
- package/ide/vscode/html-custom-data.json +6 -104
- package/package.json +20 -20
- package/dist/cjs/mg-input.utils-D-ASK4ua.js +0 -49
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.utils.js +0 -21
- package/dist/components/mg-details2.js +0 -99
- package/dist/components/mg-input.utils.js +0 -24
- package/dist/esm/mg-input.utils-BYI03zSi.js +0 -46
- package/dist/mg-components/p-31856cff.entry.js +0 -1
- package/dist/mg-components/p-698dfc6c.entry.js +0 -1
- package/dist/mg-components/p-BAUTlb6r.js +0 -1
- package/dist/mg-components/p-CKB-AnCZ.js +0 -1
- package/dist/mg-components/p-PuX-pdL4.js +0 -1
- package/dist/types/components/molecules/inputs/mg-input/mg-input.utils.d.ts +0 -8
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-T3-qWqFE.js');
|
|
4
4
|
var index$1 = require('./index-CpENFzEo.js');
|
|
5
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
6
|
-
var index$2 = require('./index-
|
|
7
|
-
var
|
|
5
|
+
var mgInput_conf = require('./mg-input.conf-WTsvDfpC.js');
|
|
6
|
+
var index$2 = require('./index-YM1EJx9X.js');
|
|
7
|
+
var events_utils = require('./events.utils-D5SAtkpQ.js');
|
|
8
8
|
|
|
9
|
-
const mgInputComboboxCss = ".mg-c-
|
|
9
|
+
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__with-character-left>mg-icon:first-of-type,.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__with-character-left .mg-c-input__box,.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-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.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__with-character-left:not(:has(textarea)) .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__with-character-left:not(:has(textarea)) .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__with-character-left:not(:has(textarea)) .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}";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Check if object is an item
|
|
@@ -137,12 +137,10 @@ const MgInputCombobox = class {
|
|
|
137
137
|
*/
|
|
138
138
|
this.handleFilterInput = () => {
|
|
139
139
|
this.checkValidity();
|
|
140
|
-
if (this.hasDisplayedError)
|
|
140
|
+
if (this.hasDisplayedError)
|
|
141
141
|
this.setErrorMessage();
|
|
142
|
-
|
|
143
|
-
if (!this.popoverDisplay) {
|
|
142
|
+
if (!this.popoverDisplay)
|
|
144
143
|
this.popoverDisplay = true;
|
|
145
|
-
}
|
|
146
144
|
// update filter with debounce to prevent filter update overload
|
|
147
145
|
if (!this.debounce) {
|
|
148
146
|
this.debounce = true;
|
|
@@ -188,31 +186,33 @@ const MgInputCombobox = class {
|
|
|
188
186
|
* @param event - keyboard event
|
|
189
187
|
*/
|
|
190
188
|
this.handleFilterKeydown = (event) => {
|
|
189
|
+
var _a;
|
|
191
190
|
if (this.disabled || event.ctrlKey || event.shiftKey)
|
|
192
191
|
return;
|
|
193
192
|
let guard = false;
|
|
194
193
|
// override keys actions
|
|
195
194
|
switch (event.key) {
|
|
196
|
-
case
|
|
197
|
-
case
|
|
198
|
-
guard = event.key ===
|
|
199
|
-
const option = this.option
|
|
195
|
+
case events_utils.Keys.TAB:
|
|
196
|
+
case events_utils.Keys.ENTER:
|
|
197
|
+
guard = event.key === events_utils.Keys.ENTER;
|
|
198
|
+
const option = (_a = this.option) !== null && _a !== void 0 ? _a : this.options.items.find(this.isCurrentOption);
|
|
200
199
|
// Sets the value to the content of the focused option in the listbox.
|
|
201
|
-
if (this.popoverDisplay)
|
|
200
|
+
if (this.popoverDisplay) {
|
|
202
201
|
this.setValue(option);
|
|
202
|
+
}
|
|
203
203
|
// Closes the popover.
|
|
204
204
|
this.popoverDisplay = false;
|
|
205
205
|
break;
|
|
206
|
-
case
|
|
207
|
-
case
|
|
208
|
-
case
|
|
209
|
-
case
|
|
206
|
+
case events_utils.Keys.DOWN:
|
|
207
|
+
case events_utils.Keys.ARROWDOWN:
|
|
208
|
+
case events_utils.Keys.UP:
|
|
209
|
+
case events_utils.Keys.ARROWUP:
|
|
210
210
|
guard = true;
|
|
211
211
|
if (this.isLoading || !(this.page.total > 0)) {
|
|
212
212
|
this.popoverDisplay = true;
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
|
-
if (Boolean(event.altKey) && [
|
|
215
|
+
if (Boolean(event.altKey) && [events_utils.Keys.DOWN, events_utils.Keys.ARROWDOWN].includes(event.key)) {
|
|
216
216
|
// Opens the popover without moving focus or changing selection.
|
|
217
217
|
this.popoverDisplay = true;
|
|
218
218
|
break;
|
|
@@ -220,14 +220,14 @@ const MgInputCombobox = class {
|
|
|
220
220
|
// define cursor
|
|
221
221
|
let cursor;
|
|
222
222
|
const isNavigationStart = this.popoverDisplay && isItem(this.option);
|
|
223
|
-
if ([
|
|
223
|
+
if ([events_utils.Keys.DOWN, events_utils.Keys.ARROWDOWN].includes(event.key)) {
|
|
224
224
|
// If the filter is not empty and the popover is displayed, moves visual focus to the first suggested value.
|
|
225
225
|
// If the filter is empty and the popover is not displayed, opens the popover and moves visual focus to the first option.
|
|
226
226
|
// Moves visual focus to the next option.
|
|
227
227
|
// If visual focus is on the last option, moves visual focus to the first option.
|
|
228
228
|
cursor = isNavigationStart ? index$1.Cursor.NEXT : index$1.Cursor.FIRST;
|
|
229
229
|
}
|
|
230
|
-
else if ([
|
|
230
|
+
else if ([events_utils.Keys.UP, events_utils.Keys.ARROWUP].includes(event.key)) {
|
|
231
231
|
// If the filter is not empty and the popover is displayed, moves visual focus to the last suggested value.
|
|
232
232
|
// If the filter is empty, first opens the popover if it is not already displayed and then moves visual focus to the last option.
|
|
233
233
|
// Moves visual focus to the previous option.
|
|
@@ -239,12 +239,12 @@ const MgInputCombobox = class {
|
|
|
239
239
|
// open popover
|
|
240
240
|
this.popoverDisplay = true;
|
|
241
241
|
break;
|
|
242
|
-
case
|
|
243
|
-
case
|
|
244
|
-
case
|
|
245
|
-
case
|
|
246
|
-
case
|
|
247
|
-
case
|
|
242
|
+
case events_utils.Keys.LEFT:
|
|
243
|
+
case events_utils.Keys.ARROWLEFT:
|
|
244
|
+
case events_utils.Keys.HOME:
|
|
245
|
+
case events_utils.Keys.RIGHT:
|
|
246
|
+
case events_utils.Keys.ARROWRIGHT:
|
|
247
|
+
case events_utils.Keys.END:
|
|
248
248
|
// skip process if visual focus is not in popover
|
|
249
249
|
if (!isItem(this.option))
|
|
250
250
|
break;
|
|
@@ -252,11 +252,11 @@ const MgInputCombobox = class {
|
|
|
252
252
|
// Remove visual focus from popover options
|
|
253
253
|
this.option = null;
|
|
254
254
|
let index;
|
|
255
|
-
if (
|
|
255
|
+
if (events_utils.Keys.HOME === event.key) {
|
|
256
256
|
// Moves visual focus to the textbox and places the editing cursor at the beginning of the field.
|
|
257
257
|
index = 0;
|
|
258
258
|
}
|
|
259
|
-
else if (
|
|
259
|
+
else if (events_utils.Keys.END === event.key) {
|
|
260
260
|
// Moves visual focus to the textbox and places the editing cursor at the end of the field.
|
|
261
261
|
index = this.filter.length;
|
|
262
262
|
}
|
|
@@ -264,8 +264,8 @@ const MgInputCombobox = class {
|
|
|
264
264
|
this.input.setSelectionRange(index, index);
|
|
265
265
|
}
|
|
266
266
|
break;
|
|
267
|
-
case
|
|
268
|
-
case
|
|
267
|
+
case events_utils.Keys.ESC:
|
|
268
|
+
case events_utils.Keys.ESCAPE:
|
|
269
269
|
guard = true;
|
|
270
270
|
if (this.popoverDisplay) {
|
|
271
271
|
// If the popover is displayed, closes it.
|
|
@@ -320,46 +320,27 @@ const MgInputCombobox = class {
|
|
|
320
320
|
else
|
|
321
321
|
return '';
|
|
322
322
|
};
|
|
323
|
-
/**
|
|
324
|
-
* Test if component has no value error message displayed
|
|
325
|
-
* @returns truthy if compent display no value error message
|
|
326
|
-
*/
|
|
327
|
-
this.hasNoValueError = () => this.customError === mgInput_conf.CustomError.NoValue;
|
|
328
323
|
/**
|
|
329
324
|
* Check if input is valid
|
|
330
325
|
*/
|
|
331
326
|
this.checkValidity = () => {
|
|
332
|
-
|
|
333
|
-
this.setValidity(this.readonly || this.disabled);
|
|
327
|
+
this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
|
|
334
328
|
};
|
|
335
329
|
/**
|
|
336
330
|
* Set input error message
|
|
331
|
+
* @param errorMessage - errorMessage override
|
|
337
332
|
*/
|
|
338
|
-
this.setErrorMessage = () => {
|
|
333
|
+
this.setErrorMessage = (errorMessage) => {
|
|
339
334
|
// Set error message
|
|
340
335
|
this.errorMessage = undefined;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
this.errorMessage = this.messages.errors.noValue;
|
|
349
|
-
}
|
|
350
|
-
// required
|
|
351
|
-
else if (this.input.validity.valueMissing) {
|
|
352
|
-
this.errorMessage = this.messages.errors.required;
|
|
353
|
-
}
|
|
336
|
+
// Does have a custom error message
|
|
337
|
+
if (!this.valid && errorMessage !== undefined) {
|
|
338
|
+
this.errorMessage = errorMessage;
|
|
339
|
+
}
|
|
340
|
+
// required
|
|
341
|
+
else if (!this.valid && this.input.validity.valueMissing) {
|
|
342
|
+
this.errorMessage = this.messages.errors.required;
|
|
354
343
|
}
|
|
355
|
-
};
|
|
356
|
-
/**
|
|
357
|
-
* Reset error message
|
|
358
|
-
*/
|
|
359
|
-
this.resetErrorMessage = () => {
|
|
360
|
-
this.checkValidity();
|
|
361
|
-
this.errorMessage = undefined;
|
|
362
|
-
this.hasDisplayedError = false;
|
|
363
344
|
};
|
|
364
345
|
/**
|
|
365
346
|
* Get filtered options from `filter` input value
|
|
@@ -433,14 +414,14 @@ const MgInputCombobox = class {
|
|
|
433
414
|
*/
|
|
434
415
|
this.goToNextPage = () => {
|
|
435
416
|
this.showMore.emit();
|
|
436
|
-
if (this.fetchurl
|
|
417
|
+
if (Boolean(this.fetchurl)) {
|
|
437
418
|
return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
|
|
438
|
-
if (
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
419
|
+
if (!Boolean(nextPage))
|
|
420
|
+
return;
|
|
421
|
+
// merge items from current page and next page
|
|
422
|
+
const items = [...this.page.items, ...nextPage.items];
|
|
423
|
+
// create new options pagination withe merged items
|
|
424
|
+
this.options = new index$1.Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
|
|
444
425
|
});
|
|
445
426
|
}
|
|
446
427
|
else {
|
|
@@ -457,20 +438,12 @@ const MgInputCombobox = class {
|
|
|
457
438
|
* @returns promise
|
|
458
439
|
*/
|
|
459
440
|
this.updatePage = async () => {
|
|
460
|
-
if (this.fetchurl
|
|
441
|
+
if (Boolean(this.fetchurl)) {
|
|
461
442
|
return this.getOptions().then(page => {
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (this.filter.length === 0 && page.total === 0) {
|
|
467
|
-
this.displayError();
|
|
468
|
-
}
|
|
469
|
-
// force to reset error when noValueError is displaied
|
|
470
|
-
else if (this.invalid && this.hasNoValueError()) {
|
|
471
|
-
this.resetErrorMessage();
|
|
472
|
-
}
|
|
473
|
-
}
|
|
443
|
+
if (!Boolean(page))
|
|
444
|
+
return;
|
|
445
|
+
// reset current options pagination from API response
|
|
446
|
+
this.options = new index$1.Paginate(page.items, { total: page.total, next: page.next, top: page.top });
|
|
474
447
|
});
|
|
475
448
|
}
|
|
476
449
|
else {
|
|
@@ -489,16 +462,14 @@ const MgInputCombobox = class {
|
|
|
489
462
|
const response = await fetch(updateUrl, this.fetchoptions);
|
|
490
463
|
if (!response.ok) {
|
|
491
464
|
this.fetchError.emit(new Error(`${response.status} - ${response.statusText}`));
|
|
492
|
-
this.displayError();
|
|
493
465
|
return;
|
|
494
466
|
}
|
|
495
467
|
const json = await response.json();
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
value: index$1.getObjectValueFromKey(item, this.fetchmappings.response.itemValue, item),
|
|
468
|
+
const items = index$1.getObjectValueFromKey(json, this.fetchmappings.response.items).map((item) => ({
|
|
469
|
+
title: index$1.getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
|
|
470
|
+
value: this.fetchmappings.response.itemValue !== undefined ? index$1.getObjectValueFromKey(item, this.fetchmappings.response.itemValue) : item,
|
|
500
471
|
}));
|
|
501
|
-
const total = Number(index$1.getObjectValueFromKey(json, this.fetchmappings.response.total,
|
|
472
|
+
const total = Number(index$1.getObjectValueFromKey(json, this.fetchmappings.response.total, 0));
|
|
502
473
|
let next = index$1.getObjectValueFromKey(json, this.fetchmappings.response.next);
|
|
503
474
|
if (URL.canParse(updateUrl) && Boolean(next) && !URL.canParse(next)) {
|
|
504
475
|
const previousUrl = new URL(updateUrl);
|
|
@@ -510,7 +481,6 @@ const MgInputCombobox = class {
|
|
|
510
481
|
}
|
|
511
482
|
catch (error) {
|
|
512
483
|
this.fetchError.emit(error);
|
|
513
|
-
this.displayError();
|
|
514
484
|
}
|
|
515
485
|
};
|
|
516
486
|
}
|
|
@@ -519,35 +489,24 @@ const MgInputCombobox = class {
|
|
|
519
489
|
this.valueChange.emit(newValue);
|
|
520
490
|
}
|
|
521
491
|
watchItems(newValue) {
|
|
522
|
-
|
|
523
|
-
if (![undefined, null].includes(this.fetchurl) && [undefined, null].includes(newValue)) {
|
|
492
|
+
if (Boolean(this.fetchurl) && !Boolean(newValue)) {
|
|
524
493
|
// skip newValue check
|
|
525
494
|
return;
|
|
526
495
|
}
|
|
527
|
-
|
|
528
|
-
else if (![undefined, null].includes(this.fetchurl) && Array.isArray(newValue)) {
|
|
496
|
+
else if (Boolean(this.fetchurl) && Boolean(newValue)) {
|
|
529
497
|
throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${index$1.toString(newValue)}.`);
|
|
530
498
|
}
|
|
531
|
-
// Empty
|
|
532
|
-
else if (
|
|
499
|
+
// Empty options
|
|
500
|
+
else if (Array.isArray(newValue) && newValue.length === 0) {
|
|
533
501
|
this.options = new index$1.Paginate([]);
|
|
534
|
-
this.displayError();
|
|
535
502
|
}
|
|
536
503
|
// String array
|
|
537
504
|
else if (index$1.allItemsAreString(newValue)) {
|
|
538
505
|
this.options = new index$1.Paginate(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
|
|
539
|
-
// force to reset error when noValueError is displayed
|
|
540
|
-
if (this.invalid && this.hasNoValueError()) {
|
|
541
|
-
this.resetErrorMessage();
|
|
542
|
-
}
|
|
543
506
|
}
|
|
544
507
|
// Object array
|
|
545
508
|
else if (isItems(newValue)) {
|
|
546
509
|
this.options = new index$1.Paginate(newValue, { total: newValue.length });
|
|
547
|
-
// force to reset error when noValueError is displayed
|
|
548
|
-
if (this.invalid && this.hasNoValueError()) {
|
|
549
|
-
this.resetErrorMessage();
|
|
550
|
-
}
|
|
551
510
|
}
|
|
552
511
|
else {
|
|
553
512
|
throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${index$1.toString(newValue)}.`);
|
|
@@ -615,7 +574,7 @@ const MgInputCombobox = class {
|
|
|
615
574
|
}
|
|
616
575
|
}
|
|
617
576
|
watchOptions(newValue) {
|
|
618
|
-
this.page = newValue.getPage(0, this.filter
|
|
577
|
+
this.page = newValue.getPage(0, Boolean(this.filter) ? this.optionsFilter : undefined);
|
|
619
578
|
}
|
|
620
579
|
watchFilter(newValue) {
|
|
621
580
|
this.loadingWrapper({ name: 'load-data' });
|
|
@@ -681,8 +640,8 @@ const MgInputCombobox = class {
|
|
|
681
640
|
throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
|
|
682
641
|
}
|
|
683
642
|
else {
|
|
684
|
-
this.setValidity(valid
|
|
685
|
-
this.setErrorMessage();
|
|
643
|
+
this.setValidity(valid);
|
|
644
|
+
this.setErrorMessage(valid ? undefined : errorMessage);
|
|
686
645
|
this.hasDisplayedError = this.invalid;
|
|
687
646
|
}
|
|
688
647
|
}
|
|
@@ -702,7 +661,9 @@ const MgInputCombobox = class {
|
|
|
702
661
|
// - Keep everything in sync both inside and outside the component
|
|
703
662
|
return new Promise(resolve => {
|
|
704
663
|
requestAnimationFrame(() => {
|
|
705
|
-
this.
|
|
664
|
+
this.checkValidity();
|
|
665
|
+
this.errorMessage = undefined;
|
|
666
|
+
this.hasDisplayedError = false;
|
|
706
667
|
resolve();
|
|
707
668
|
});
|
|
708
669
|
});
|
|
@@ -725,34 +686,15 @@ const MgInputCombobox = class {
|
|
|
725
686
|
}
|
|
726
687
|
/**
|
|
727
688
|
* Method to set validity values
|
|
728
|
-
* @param
|
|
729
|
-
* @param customErrorMessage - custom error message
|
|
689
|
+
* @param newValue - valid new value
|
|
730
690
|
*/
|
|
731
|
-
setValidity(
|
|
732
|
-
var _a;
|
|
691
|
+
setValidity(newValue) {
|
|
733
692
|
const oldValidValue = this.valid;
|
|
734
|
-
|
|
735
|
-
// Set custom validity
|
|
736
|
-
if (!valid && this.input !== undefined) {
|
|
737
|
-
// custom errror, start by reset it
|
|
738
|
-
this.customError = undefined;
|
|
739
|
-
if (index$1.isValidString(customErrorMessage)) {
|
|
740
|
-
this.customError = customErrorMessage;
|
|
741
|
-
}
|
|
742
|
-
// no value
|
|
743
|
-
else if ((this.fetchurl === undefined ? ((_a = this.items) !== null && _a !== void 0 ? _a : []).length : this.page.total) === 0) {
|
|
744
|
-
this.customError = mgInput_conf.CustomError.NoValue;
|
|
745
|
-
}
|
|
746
|
-
// get new input validity from validity state
|
|
747
|
-
valid = this.input.checkValidity() && this.customError === undefined;
|
|
748
|
-
}
|
|
749
|
-
// set valid/invalid props
|
|
750
|
-
this.valid = valid;
|
|
693
|
+
this.valid = newValue;
|
|
751
694
|
this.invalid = !this.valid;
|
|
752
695
|
// We need to send valid event even if it is the same value
|
|
753
|
-
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
|
|
696
|
+
if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
|
|
754
697
|
this.inputValid.emit(this.valid);
|
|
755
|
-
}
|
|
756
698
|
}
|
|
757
699
|
/*************
|
|
758
700
|
* Lifecycle *
|
|
@@ -793,19 +735,15 @@ const MgInputCombobox = class {
|
|
|
793
735
|
const listId = `${this.identifier}-list`;
|
|
794
736
|
const readonlyValue = this.getValueTitle();
|
|
795
737
|
const withResetButton = this.value && !this.disabled;
|
|
796
|
-
const disabled = this.disabled || this.hasNoValueError();
|
|
797
738
|
let popoverContent;
|
|
798
|
-
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
|
|
739
|
+
if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
|
|
799
740
|
popoverContent = 'list';
|
|
800
|
-
|
|
801
|
-
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && this.filter.length > 0) {
|
|
741
|
+
else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && Boolean(this.filter))
|
|
802
742
|
popoverContent = 'notfound';
|
|
803
|
-
|
|
804
|
-
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0) {
|
|
743
|
+
else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
|
|
805
744
|
popoverContent = 'notavailable';
|
|
806
|
-
}
|
|
807
745
|
let activeDescendant;
|
|
808
|
-
if (
|
|
746
|
+
if (Boolean((_d = this.option) === null || _d === void 0 ? void 0 : _d.value)) {
|
|
809
747
|
activeDescendant = this.option.value;
|
|
810
748
|
}
|
|
811
749
|
else if (typeof this.value === 'string') {
|
|
@@ -814,12 +752,12 @@ const MgInputCombobox = class {
|
|
|
814
752
|
else {
|
|
815
753
|
activeDescendant = (_e = this.value) === null || _e === void 0 ? void 0 : _e.value;
|
|
816
754
|
}
|
|
817
|
-
return (index.h("mg-input", { key: '
|
|
755
|
+
return (index.h("mg-input", { key: '79e5263cd3b1c0fa0b3f386a547f2bdd48a33b28', 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 && index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (index.h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
|
|
818
756
|
'--mg-c-input-list-width': Boolean((_f = this.input) === null || _f === void 0 ? void 0 : _f.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
|
|
819
|
-
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, index.h("div", { class: "mg-c-input__input-group-container" }, index.h("mg-icon", { icon: "magnifying-glass" }), index.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: 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": index$1.formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
757
|
+
}, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, index.h("div", { class: "mg-c-input__input-group-container" }, index.h("mg-icon", { icon: "magnifying-glass" }), index.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": index$1.formatID(activeDescendant), onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
|
|
820
758
|
if (el !== null)
|
|
821
759
|
this.input = el;
|
|
822
|
-
} }), withResetButton ? (index.h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton
|
|
760
|
+
} }), withResetButton ? (index.h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, index.h("mg-icon", { icon: "cross" }))) : (index.h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, index.h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` })))), index.h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
|
|
823
761
|
// eslint-disable-next-line jsx-a11y/role-supports-aria-props
|
|
824
762
|
index.h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
|
|
825
763
|
var _a;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$1 = require('./index-
|
|
3
|
+
var index$1 = require('./index-T3-qWqFE.js');
|
|
4
4
|
var index = require('./index-CpENFzEo.js');
|
|
5
|
-
var mgInput_conf = require('./mg-input.conf-
|
|
6
|
-
var index$2 = require('./index-
|
|
5
|
+
var mgInput_conf = require('./mg-input.conf-WTsvDfpC.js');
|
|
6
|
+
var index$2 = require('./index-YM1EJx9X.js');
|
|
7
7
|
|
|
8
8
|
/** Detect free variable `global` from Node.js. */
|
|
9
9
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -12,14 +12,7 @@ const classFieldset = 'mg-c-input--fieldset';
|
|
|
12
12
|
const classDisabled = 'mg-c-input--disabled';
|
|
13
13
|
const classReadonly = 'mg-c-input--readonly';
|
|
14
14
|
const classVerticalList = 'mg-c-input--vertical-list';
|
|
15
|
-
/**
|
|
16
|
-
* Define cutom errors
|
|
17
|
-
*/
|
|
18
|
-
const CustomError = {
|
|
19
|
-
NoValue: 'noValue',
|
|
20
|
-
};
|
|
21
15
|
|
|
22
|
-
exports.CustomError = CustomError;
|
|
23
16
|
exports.classDisabled = classDisabled;
|
|
24
17
|
exports.classFieldset = classFieldset;
|
|
25
18
|
exports.classReadonly = classReadonly;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var index$2 = require('./index-
|
|
3
|
+
var index = require('./index-T3-qWqFE.js');
|
|
4
|
+
var index$2 = require('./index-YM1EJx9X.js');
|
|
5
5
|
var index$1 = require('./index-CpENFzEo.js');
|
|
6
6
|
|
|
7
7
|
const mgLoaderCss = ".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}}:host{display:block}.mg-c-loader{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:var(--mg-b-size-4);text-align:center}";
|
|
@@ -10,9 +10,3 @@ export const classFieldset = 'mg-c-input--fieldset';
|
|
|
10
10
|
export const classDisabled = 'mg-c-input--disabled';
|
|
11
11
|
export const classReadonly = 'mg-c-input--readonly';
|
|
12
12
|
export const classVerticalList = 'mg-c-input--vertical-list';
|
|
13
|
-
/**
|
|
14
|
-
* Define cutom errors
|
|
15
|
-
*/
|
|
16
|
-
export const CustomError = {
|
|
17
|
-
NoValue: 'noValue',
|
|
18
|
-
};
|