@aurodesignsystem/auro-formkit 3.3.0-beta.2 → 3.3.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/CHANGELOG.md +23 -0
- package/components/checkbox/README.md +1 -1
- package/components/checkbox/demo/api.md +1 -0
- package/components/checkbox/demo/api.min.js +34 -5
- package/components/checkbox/demo/index.min.js +34 -5
- package/components/checkbox/demo/readme.md +1 -1
- package/components/checkbox/dist/auro-checkbox-group.d.ts +7 -0
- package/components/checkbox/dist/auro-checkbox.d.ts +6 -0
- package/components/checkbox/dist/index.js +34 -5
- package/components/checkbox/dist/registered.js +34 -5
- package/components/combobox/README.md +1 -1
- package/components/combobox/demo/api.min.js +77 -57
- package/components/combobox/demo/index.min.js +77 -57
- package/components/combobox/demo/readme.md +1 -1
- package/components/combobox/dist/auro-combobox.d.ts +2 -10
- package/components/combobox/dist/index.js +77 -57
- package/components/combobox/dist/registered.js +77 -57
- package/components/counter/README.md +1 -1
- package/components/counter/demo/api.min.js +12 -5
- package/components/counter/demo/index.min.js +12 -5
- package/components/counter/demo/readme.md +1 -1
- package/components/counter/dist/index.js +12 -5
- package/components/counter/dist/registered.js +12 -5
- package/components/datepicker/README.md +1 -1
- package/components/datepicker/demo/api.min.js +54 -34
- package/components/datepicker/demo/index.min.js +54 -34
- package/components/datepicker/demo/readme.md +1 -1
- package/components/datepicker/dist/auro-datepicker.d.ts +8 -0
- package/components/datepicker/dist/index.js +54 -34
- package/components/datepicker/dist/registered.js +54 -34
- package/components/dropdown/README.md +1 -1
- package/components/dropdown/demo/readme.md +1 -1
- package/components/form/README.md +1 -1
- package/components/form/demo/readme.md +1 -1
- package/components/input/README.md +1 -1
- package/components/input/demo/api.min.js +26 -14
- package/components/input/demo/index.min.js +26 -14
- package/components/input/demo/readme.md +1 -1
- package/components/input/dist/base-input.d.ts +8 -0
- package/components/input/dist/index.js +26 -14
- package/components/input/dist/registered.js +26 -14
- package/components/menu/README.md +1 -1
- package/components/menu/demo/readme.md +1 -1
- package/components/radio/README.md +1 -1
- package/components/radio/demo/api.md +1 -0
- package/components/radio/demo/api.min.js +33 -9
- package/components/radio/demo/index.min.js +33 -9
- package/components/radio/demo/readme.md +1 -1
- package/components/radio/dist/auro-radio-group.d.ts +8 -0
- package/components/radio/dist/auro-radio.d.ts +5 -0
- package/components/radio/dist/index.js +33 -9
- package/components/radio/dist/registered.js +33 -9
- package/components/select/README.md +1 -1
- package/components/select/demo/api.min.js +25 -15
- package/components/select/demo/index.min.js +25 -15
- package/components/select/demo/readme.md +1 -1
- package/components/select/dist/auro-select.d.ts +8 -0
- package/components/select/dist/index.js +25 -15
- package/components/select/dist/registered.js +25 -15
- package/package.json +1 -1
|
@@ -541,6 +541,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
541
541
|
reset(elem) {
|
|
542
542
|
elem.validity = undefined;
|
|
543
543
|
elem.value = undefined;
|
|
544
|
+
elem.touched = false;
|
|
544
545
|
|
|
545
546
|
// Resets the second value of the datepicker in range state
|
|
546
547
|
if (elem.valueEnd) {
|
|
@@ -678,7 +679,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
678
679
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
679
680
|
|
|
680
681
|
// Guard Clause: if the value is too short
|
|
681
|
-
if (elem.value
|
|
682
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
682
683
|
|
|
683
684
|
elem.validity = 'tooShort';
|
|
684
685
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -748,11 +749,17 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
748
749
|
this.getAuroInputs(elem);
|
|
749
750
|
|
|
750
751
|
// Validate only if noValidate is not true and the input does not have focus
|
|
751
|
-
|
|
752
|
+
let validationShouldRun =
|
|
753
|
+
force ||
|
|
754
|
+
(!elem.contains(document.activeElement) &&
|
|
755
|
+
(elem.touched ||
|
|
756
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
757
|
+
elem.validateOnInput;
|
|
752
758
|
|
|
753
759
|
if (elem.hasAttribute('error')) {
|
|
754
760
|
elem.validity = 'customError';
|
|
755
761
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
762
|
+
validationShouldRun = false;
|
|
756
763
|
} else if (validationShouldRun) {
|
|
757
764
|
elem.validity = 'valid';
|
|
758
765
|
elem.errorMessage = '';
|
|
@@ -773,7 +780,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
773
780
|
}
|
|
774
781
|
}
|
|
775
782
|
|
|
776
|
-
if (!hasValue && elem.required) {
|
|
783
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
777
784
|
elem.validity = 'valueMissing';
|
|
778
785
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
779
786
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -784,7 +791,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
784
791
|
}
|
|
785
792
|
}
|
|
786
793
|
|
|
787
|
-
if (this.auroInputElements?.length > 0) {
|
|
794
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
788
795
|
elem.validity = this.auroInputElements[0].validity;
|
|
789
796
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
790
797
|
|
|
@@ -863,7 +870,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
863
870
|
}
|
|
864
871
|
}
|
|
865
872
|
} else {
|
|
866
|
-
elem.errorMessage =
|
|
873
|
+
elem.errorMessage = '';
|
|
867
874
|
}
|
|
868
875
|
}
|
|
869
876
|
};
|
|
@@ -9064,6 +9071,7 @@ class AuroFormValidation {
|
|
|
9064
9071
|
reset(elem) {
|
|
9065
9072
|
elem.validity = undefined;
|
|
9066
9073
|
elem.value = undefined;
|
|
9074
|
+
elem.touched = false;
|
|
9067
9075
|
|
|
9068
9076
|
// Resets the second value of the datepicker in range state
|
|
9069
9077
|
if (elem.valueEnd) {
|
|
@@ -9201,7 +9209,7 @@ class AuroFormValidation {
|
|
|
9201
9209
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
9202
9210
|
|
|
9203
9211
|
// Guard Clause: if the value is too short
|
|
9204
|
-
if (elem.value
|
|
9212
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
9205
9213
|
|
|
9206
9214
|
elem.validity = 'tooShort';
|
|
9207
9215
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -9271,11 +9279,17 @@ class AuroFormValidation {
|
|
|
9271
9279
|
this.getAuroInputs(elem);
|
|
9272
9280
|
|
|
9273
9281
|
// Validate only if noValidate is not true and the input does not have focus
|
|
9274
|
-
|
|
9282
|
+
let validationShouldRun =
|
|
9283
|
+
force ||
|
|
9284
|
+
(!elem.contains(document.activeElement) &&
|
|
9285
|
+
(elem.touched ||
|
|
9286
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
9287
|
+
elem.validateOnInput;
|
|
9275
9288
|
|
|
9276
9289
|
if (elem.hasAttribute('error')) {
|
|
9277
9290
|
elem.validity = 'customError';
|
|
9278
9291
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
9292
|
+
validationShouldRun = false;
|
|
9279
9293
|
} else if (validationShouldRun) {
|
|
9280
9294
|
elem.validity = 'valid';
|
|
9281
9295
|
elem.errorMessage = '';
|
|
@@ -9296,7 +9310,7 @@ class AuroFormValidation {
|
|
|
9296
9310
|
}
|
|
9297
9311
|
}
|
|
9298
9312
|
|
|
9299
|
-
if (!hasValue && elem.required) {
|
|
9313
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
9300
9314
|
elem.validity = 'valueMissing';
|
|
9301
9315
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
9302
9316
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -9307,7 +9321,7 @@ class AuroFormValidation {
|
|
|
9307
9321
|
}
|
|
9308
9322
|
}
|
|
9309
9323
|
|
|
9310
|
-
if (this.auroInputElements?.length > 0) {
|
|
9324
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
9311
9325
|
elem.validity = this.auroInputElements[0].validity;
|
|
9312
9326
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
9313
9327
|
|
|
@@ -9386,7 +9400,7 @@ class AuroFormValidation {
|
|
|
9386
9400
|
}
|
|
9387
9401
|
}
|
|
9388
9402
|
} else {
|
|
9389
|
-
elem.errorMessage =
|
|
9403
|
+
elem.errorMessage = '';
|
|
9390
9404
|
}
|
|
9391
9405
|
}
|
|
9392
9406
|
}
|
|
@@ -9437,6 +9451,7 @@ class BaseInput extends LitElement {
|
|
|
9437
9451
|
* @returns {void}
|
|
9438
9452
|
*/
|
|
9439
9453
|
privateDefaults() {
|
|
9454
|
+
this.touched = false;
|
|
9440
9455
|
this.util = new AuroInputUtilities();
|
|
9441
9456
|
this.validation = new AuroFormValidation();
|
|
9442
9457
|
this.inputIconName = undefined;
|
|
@@ -9798,6 +9813,18 @@ class BaseInput extends LitElement {
|
|
|
9798
9813
|
validity: {
|
|
9799
9814
|
type: String,
|
|
9800
9815
|
reflect: true
|
|
9816
|
+
},
|
|
9817
|
+
|
|
9818
|
+
/**
|
|
9819
|
+
* Indicates whether the input is in a dirty state (has been interacted with).
|
|
9820
|
+
* @type {boolean}
|
|
9821
|
+
* @default false
|
|
9822
|
+
* @private
|
|
9823
|
+
*/
|
|
9824
|
+
touched: {
|
|
9825
|
+
type: Boolean,
|
|
9826
|
+
reflect: true,
|
|
9827
|
+
attribute: false
|
|
9801
9828
|
}
|
|
9802
9829
|
};
|
|
9803
9830
|
}
|
|
@@ -10084,15 +10111,7 @@ class BaseInput extends LitElement {
|
|
|
10084
10111
|
*/
|
|
10085
10112
|
handleFocusin() {
|
|
10086
10113
|
|
|
10087
|
-
|
|
10088
|
-
* The input is considered to be in it's initial state based on
|
|
10089
|
-
* if this.value === undefined. The first time we interact with the
|
|
10090
|
-
* input manually, by applying focusin, we need to flag the
|
|
10091
|
-
* input as no longer in the initial state.
|
|
10092
|
-
*/
|
|
10093
|
-
if (this.value === undefined) {
|
|
10094
|
-
this.value = '';
|
|
10095
|
-
}
|
|
10114
|
+
this.touched = true;
|
|
10096
10115
|
}
|
|
10097
10116
|
|
|
10098
10117
|
/**
|
|
@@ -12726,14 +12745,6 @@ class AuroCombobox extends LitElement {
|
|
|
12726
12745
|
reflect: true
|
|
12727
12746
|
},
|
|
12728
12747
|
|
|
12729
|
-
/**
|
|
12730
|
-
* @private
|
|
12731
|
-
*/
|
|
12732
|
-
isDropdownFullscreen: {
|
|
12733
|
-
type: Boolean,
|
|
12734
|
-
reflect: false
|
|
12735
|
-
},
|
|
12736
|
-
|
|
12737
12748
|
/**
|
|
12738
12749
|
* @private
|
|
12739
12750
|
* specifies the currently active option
|
|
@@ -12768,6 +12779,14 @@ class AuroCombobox extends LitElement {
|
|
|
12768
12779
|
* @returns {void}
|
|
12769
12780
|
*/
|
|
12770
12781
|
handleMenuOptions() {
|
|
12782
|
+
// Reset menu matchword UI
|
|
12783
|
+
this.menu.updateItemsState(new Map([
|
|
12784
|
+
[
|
|
12785
|
+
'matchWord',
|
|
12786
|
+
true
|
|
12787
|
+
]
|
|
12788
|
+
]));
|
|
12789
|
+
|
|
12771
12790
|
this.generateOptionsArray();
|
|
12772
12791
|
this.availableOptions = [];
|
|
12773
12792
|
|
|
@@ -12875,8 +12894,6 @@ class AuroCombobox extends LitElement {
|
|
|
12875
12894
|
return;
|
|
12876
12895
|
}
|
|
12877
12896
|
|
|
12878
|
-
this.isDropdownFullscreen = this.dropdown.isBibFullscreen;
|
|
12879
|
-
|
|
12880
12897
|
if (!this.dropdown.isPopoverVisible && this.input.value && this.input.value.length > 0) {
|
|
12881
12898
|
if (this.menu.getAttribute('loading') || (this.availableOptions && this.availableOptions.length > 0) || this.noMatchOption !== undefined) { // eslint-disable-line no-extra-parens
|
|
12882
12899
|
if (this.menu.hasAttribute('loading') && !this.menu.hasLoadingPlaceholder) {
|
|
@@ -12903,6 +12920,13 @@ class AuroCombobox extends LitElement {
|
|
|
12903
12920
|
// Listen for the dropdown to be shown or hidden
|
|
12904
12921
|
this.dropdown.addEventListener("auroDropdown-toggled", (ev) => {
|
|
12905
12922
|
this.dropdownOpen = ev.detail.expanded;
|
|
12923
|
+
|
|
12924
|
+
// wait a frame in case the bib gets hide immediately after showing because there is no value
|
|
12925
|
+
setTimeout(this.transportInput);
|
|
12926
|
+
});
|
|
12927
|
+
|
|
12928
|
+
this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
|
|
12929
|
+
this.showBib();
|
|
12906
12930
|
});
|
|
12907
12931
|
|
|
12908
12932
|
// this.dropdown.addEventListener('auroDropdown-show', () => {
|
|
@@ -12921,19 +12945,10 @@ class AuroCombobox extends LitElement {
|
|
|
12921
12945
|
this.hideBib = this.hideBib.bind(this);
|
|
12922
12946
|
this.bibtemplate.addEventListener('close-click', this.hideBib);
|
|
12923
12947
|
|
|
12924
|
-
this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
|
|
12925
|
-
this.showBib();
|
|
12926
|
-
});
|
|
12927
|
-
|
|
12928
12948
|
this.transportInput = this.transportInput.bind(this);
|
|
12929
|
-
this.dropdown.addEventListener('auroDropdown-toggled', () => {
|
|
12930
|
-
// wait a frame in case the bib gets hide immediately after showing because there is no value
|
|
12931
|
-
setTimeout(this.transportInput);
|
|
12932
|
-
});
|
|
12933
12949
|
|
|
12934
|
-
this.dropdown.addEventListener('auroDropdown-strategy-change', (
|
|
12950
|
+
this.dropdown.addEventListener('auroDropdown-strategy-change', () => {
|
|
12935
12951
|
// event when the strategy(bib mode) is changed between fullscreen and floating
|
|
12936
|
-
this.isDropdownFullscreen = event.detail.strategy === 'fullscreen';
|
|
12937
12952
|
setTimeout(this.transportInput);
|
|
12938
12953
|
});
|
|
12939
12954
|
}
|
|
@@ -13029,20 +13044,17 @@ class AuroCombobox extends LitElement {
|
|
|
13029
13044
|
* @private
|
|
13030
13045
|
* Dispatches input's keyboard events from host
|
|
13031
13046
|
* This allows key events from the input to be handled by the parent.
|
|
13032
|
-
* @param {
|
|
13047
|
+
* @param {Event} event - The keyboard event.
|
|
13033
13048
|
*/
|
|
13034
|
-
|
|
13049
|
+
bubbleUpInputEvent(event) {
|
|
13050
|
+
// Do not need to bubble events if the input is not in bib.
|
|
13035
13051
|
if (event.currentTarget.parentNode !== this.dropdown) {
|
|
13052
|
+
// prevents browsers to move cursor in input element.
|
|
13036
13053
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
13037
13054
|
event.preventDefault();
|
|
13038
13055
|
}
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
key: event.key,
|
|
13042
|
-
code: event.code,
|
|
13043
|
-
repeat: event.repeat,
|
|
13044
|
-
});
|
|
13045
|
-
this.dispatchEvent(ke);
|
|
13056
|
+
const dupEvent = new event.constructor(event.type, event);
|
|
13057
|
+
this.dispatchEvent(dupEvent);
|
|
13046
13058
|
}
|
|
13047
13059
|
}
|
|
13048
13060
|
|
|
@@ -13053,14 +13065,22 @@ class AuroCombobox extends LitElement {
|
|
|
13053
13065
|
*/
|
|
13054
13066
|
configureInput() {
|
|
13055
13067
|
// When input is in bibtemplate, make the event to be fired at combobox element
|
|
13056
|
-
this.
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13068
|
+
this.bubbleUpInputEvent = this.bubbleUpInputEvent.bind(this);
|
|
13069
|
+
|
|
13070
|
+
const events = [
|
|
13071
|
+
'input',
|
|
13072
|
+
'keydown',
|
|
13073
|
+
'keyup'
|
|
13074
|
+
];
|
|
13075
|
+
events.forEach((eventType) => {
|
|
13076
|
+
this.input.addEventListener(eventType, this.bubbleUpInputEvent);
|
|
13077
|
+
});
|
|
13060
13078
|
|
|
13061
13079
|
this.addEventListener('keyup', (evt) => {
|
|
13062
13080
|
if (evt.key.length === 1 || evt.key === 'Backspace' || evt.key === 'Delete') {
|
|
13063
|
-
this.
|
|
13081
|
+
if (!this.dropdown.isPopoverVisible) {
|
|
13082
|
+
this.showBib();
|
|
13083
|
+
}
|
|
13064
13084
|
}
|
|
13065
13085
|
});
|
|
13066
13086
|
|
|
@@ -13121,8 +13141,8 @@ class AuroCombobox extends LitElement {
|
|
|
13121
13141
|
const inputHelpText = this.input.shadowRoot.querySelector('auro-helptext, [auro-helptext');
|
|
13122
13142
|
const inputAlertIcon = this.input.shadowRoot.querySelector(".alertNotification");
|
|
13123
13143
|
|
|
13124
|
-
if (this.dropdown.isPopoverVisible && this.
|
|
13125
|
-
if (this.input.parentNode
|
|
13144
|
+
if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
|
|
13145
|
+
if (this.input.parentNode === this.dropdown) {
|
|
13126
13146
|
// keep the trigger size the same even after input gets removed
|
|
13127
13147
|
const parentSize = window.getComputedStyle(this.dropdown.trigger);
|
|
13128
13148
|
this.dropdown.trigger.style.height = parentSize.height;
|
|
@@ -13208,7 +13228,7 @@ class AuroCombobox extends LitElement {
|
|
|
13208
13228
|
}
|
|
13209
13229
|
|
|
13210
13230
|
// Force dropdown bib to hide if input value has no matching suggestions
|
|
13211
|
-
if ((!this.availableOptions || this.availableOptions.length === 0) && !this.
|
|
13231
|
+
if ((!this.availableOptions || this.availableOptions.length === 0) && !this.dropdown.isBibFullscreen) {
|
|
13212
13232
|
this.hideBib();
|
|
13213
13233
|
}
|
|
13214
13234
|
}
|
|
@@ -13231,7 +13251,7 @@ class AuroCombobox extends LitElement {
|
|
|
13231
13251
|
if (evt.key === 'Tab') {
|
|
13232
13252
|
this.hideBib();
|
|
13233
13253
|
|
|
13234
|
-
if (this.dropdown.isPopoverVisible && this.
|
|
13254
|
+
if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
|
|
13235
13255
|
// if bib is open in fullscreen, just close the bib and do not move the focus to the next focasable element
|
|
13236
13256
|
evt.preventDefault();
|
|
13237
13257
|
}
|
|
@@ -541,6 +541,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
541
541
|
reset(elem) {
|
|
542
542
|
elem.validity = undefined;
|
|
543
543
|
elem.value = undefined;
|
|
544
|
+
elem.touched = false;
|
|
544
545
|
|
|
545
546
|
// Resets the second value of the datepicker in range state
|
|
546
547
|
if (elem.valueEnd) {
|
|
@@ -678,7 +679,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
678
679
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
679
680
|
|
|
680
681
|
// Guard Clause: if the value is too short
|
|
681
|
-
if (elem.value
|
|
682
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
682
683
|
|
|
683
684
|
elem.validity = 'tooShort';
|
|
684
685
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -748,11 +749,17 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
748
749
|
this.getAuroInputs(elem);
|
|
749
750
|
|
|
750
751
|
// Validate only if noValidate is not true and the input does not have focus
|
|
751
|
-
|
|
752
|
+
let validationShouldRun =
|
|
753
|
+
force ||
|
|
754
|
+
(!elem.contains(document.activeElement) &&
|
|
755
|
+
(elem.touched ||
|
|
756
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
757
|
+
elem.validateOnInput;
|
|
752
758
|
|
|
753
759
|
if (elem.hasAttribute('error')) {
|
|
754
760
|
elem.validity = 'customError';
|
|
755
761
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
762
|
+
validationShouldRun = false;
|
|
756
763
|
} else if (validationShouldRun) {
|
|
757
764
|
elem.validity = 'valid';
|
|
758
765
|
elem.errorMessage = '';
|
|
@@ -773,7 +780,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
773
780
|
}
|
|
774
781
|
}
|
|
775
782
|
|
|
776
|
-
if (!hasValue && elem.required) {
|
|
783
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
777
784
|
elem.validity = 'valueMissing';
|
|
778
785
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
779
786
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -784,7 +791,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
784
791
|
}
|
|
785
792
|
}
|
|
786
793
|
|
|
787
|
-
if (this.auroInputElements?.length > 0) {
|
|
794
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
788
795
|
elem.validity = this.auroInputElements[0].validity;
|
|
789
796
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
790
797
|
|
|
@@ -863,7 +870,7 @@ let AuroFormValidation$1 = class AuroFormValidation {
|
|
|
863
870
|
}
|
|
864
871
|
}
|
|
865
872
|
} else {
|
|
866
|
-
elem.errorMessage =
|
|
873
|
+
elem.errorMessage = '';
|
|
867
874
|
}
|
|
868
875
|
}
|
|
869
876
|
};
|
|
@@ -9064,6 +9071,7 @@ class AuroFormValidation {
|
|
|
9064
9071
|
reset(elem) {
|
|
9065
9072
|
elem.validity = undefined;
|
|
9066
9073
|
elem.value = undefined;
|
|
9074
|
+
elem.touched = false;
|
|
9067
9075
|
|
|
9068
9076
|
// Resets the second value of the datepicker in range state
|
|
9069
9077
|
if (elem.valueEnd) {
|
|
@@ -9201,7 +9209,7 @@ class AuroFormValidation {
|
|
|
9201
9209
|
} else if (elem.type === 'date' && elem.value?.length > 0) {
|
|
9202
9210
|
|
|
9203
9211
|
// Guard Clause: if the value is too short
|
|
9204
|
-
if (elem.value
|
|
9212
|
+
if (elem.value?.length < elem.lengthForType) {
|
|
9205
9213
|
|
|
9206
9214
|
elem.validity = 'tooShort';
|
|
9207
9215
|
elem.errorMessage = elem.setCustomValidityForType || elem.setCustomValidity || '';
|
|
@@ -9271,11 +9279,17 @@ class AuroFormValidation {
|
|
|
9271
9279
|
this.getAuroInputs(elem);
|
|
9272
9280
|
|
|
9273
9281
|
// Validate only if noValidate is not true and the input does not have focus
|
|
9274
|
-
|
|
9282
|
+
let validationShouldRun =
|
|
9283
|
+
force ||
|
|
9284
|
+
(!elem.contains(document.activeElement) &&
|
|
9285
|
+
(elem.touched ||
|
|
9286
|
+
(!elem.touched && typeof elem.value !== "undefined"))) ||
|
|
9287
|
+
elem.validateOnInput;
|
|
9275
9288
|
|
|
9276
9289
|
if (elem.hasAttribute('error')) {
|
|
9277
9290
|
elem.validity = 'customError';
|
|
9278
9291
|
elem.errorMessage = elem.setCustomValidityCustomError || elem.error || elem.setCustomValidity || '';
|
|
9292
|
+
validationShouldRun = false;
|
|
9279
9293
|
} else if (validationShouldRun) {
|
|
9280
9294
|
elem.validity = 'valid';
|
|
9281
9295
|
elem.errorMessage = '';
|
|
@@ -9296,7 +9310,7 @@ class AuroFormValidation {
|
|
|
9296
9310
|
}
|
|
9297
9311
|
}
|
|
9298
9312
|
|
|
9299
|
-
if (!hasValue && elem.required) {
|
|
9313
|
+
if (!hasValue && elem.required && elem.touched) {
|
|
9300
9314
|
elem.validity = 'valueMissing';
|
|
9301
9315
|
elem.errorMessage = elem.setCustomValidityValueMissing || elem.setCustomValidity || '';
|
|
9302
9316
|
} else if (this.runtimeUtils.elementMatch(elem, 'auro-input')) {
|
|
@@ -9307,7 +9321,7 @@ class AuroFormValidation {
|
|
|
9307
9321
|
}
|
|
9308
9322
|
}
|
|
9309
9323
|
|
|
9310
|
-
if (this.auroInputElements?.length > 0) {
|
|
9324
|
+
if (this.auroInputElements?.length > 0 && elem.validity !== "valueMissing") {
|
|
9311
9325
|
elem.validity = this.auroInputElements[0].validity;
|
|
9312
9326
|
elem.errorMessage = this.auroInputElements[0].errorMessage;
|
|
9313
9327
|
|
|
@@ -9386,7 +9400,7 @@ class AuroFormValidation {
|
|
|
9386
9400
|
}
|
|
9387
9401
|
}
|
|
9388
9402
|
} else {
|
|
9389
|
-
elem.errorMessage =
|
|
9403
|
+
elem.errorMessage = '';
|
|
9390
9404
|
}
|
|
9391
9405
|
}
|
|
9392
9406
|
}
|
|
@@ -9437,6 +9451,7 @@ class BaseInput extends LitElement {
|
|
|
9437
9451
|
* @returns {void}
|
|
9438
9452
|
*/
|
|
9439
9453
|
privateDefaults() {
|
|
9454
|
+
this.touched = false;
|
|
9440
9455
|
this.util = new AuroInputUtilities();
|
|
9441
9456
|
this.validation = new AuroFormValidation();
|
|
9442
9457
|
this.inputIconName = undefined;
|
|
@@ -9798,6 +9813,18 @@ class BaseInput extends LitElement {
|
|
|
9798
9813
|
validity: {
|
|
9799
9814
|
type: String,
|
|
9800
9815
|
reflect: true
|
|
9816
|
+
},
|
|
9817
|
+
|
|
9818
|
+
/**
|
|
9819
|
+
* Indicates whether the input is in a dirty state (has been interacted with).
|
|
9820
|
+
* @type {boolean}
|
|
9821
|
+
* @default false
|
|
9822
|
+
* @private
|
|
9823
|
+
*/
|
|
9824
|
+
touched: {
|
|
9825
|
+
type: Boolean,
|
|
9826
|
+
reflect: true,
|
|
9827
|
+
attribute: false
|
|
9801
9828
|
}
|
|
9802
9829
|
};
|
|
9803
9830
|
}
|
|
@@ -10084,15 +10111,7 @@ class BaseInput extends LitElement {
|
|
|
10084
10111
|
*/
|
|
10085
10112
|
handleFocusin() {
|
|
10086
10113
|
|
|
10087
|
-
|
|
10088
|
-
* The input is considered to be in it's initial state based on
|
|
10089
|
-
* if this.value === undefined. The first time we interact with the
|
|
10090
|
-
* input manually, by applying focusin, we need to flag the
|
|
10091
|
-
* input as no longer in the initial state.
|
|
10092
|
-
*/
|
|
10093
|
-
if (this.value === undefined) {
|
|
10094
|
-
this.value = '';
|
|
10095
|
-
}
|
|
10114
|
+
this.touched = true;
|
|
10096
10115
|
}
|
|
10097
10116
|
|
|
10098
10117
|
/**
|
|
@@ -12726,14 +12745,6 @@ class AuroCombobox extends LitElement {
|
|
|
12726
12745
|
reflect: true
|
|
12727
12746
|
},
|
|
12728
12747
|
|
|
12729
|
-
/**
|
|
12730
|
-
* @private
|
|
12731
|
-
*/
|
|
12732
|
-
isDropdownFullscreen: {
|
|
12733
|
-
type: Boolean,
|
|
12734
|
-
reflect: false
|
|
12735
|
-
},
|
|
12736
|
-
|
|
12737
12748
|
/**
|
|
12738
12749
|
* @private
|
|
12739
12750
|
* specifies the currently active option
|
|
@@ -12768,6 +12779,14 @@ class AuroCombobox extends LitElement {
|
|
|
12768
12779
|
* @returns {void}
|
|
12769
12780
|
*/
|
|
12770
12781
|
handleMenuOptions() {
|
|
12782
|
+
// Reset menu matchword UI
|
|
12783
|
+
this.menu.updateItemsState(new Map([
|
|
12784
|
+
[
|
|
12785
|
+
'matchWord',
|
|
12786
|
+
true
|
|
12787
|
+
]
|
|
12788
|
+
]));
|
|
12789
|
+
|
|
12771
12790
|
this.generateOptionsArray();
|
|
12772
12791
|
this.availableOptions = [];
|
|
12773
12792
|
|
|
@@ -12875,8 +12894,6 @@ class AuroCombobox extends LitElement {
|
|
|
12875
12894
|
return;
|
|
12876
12895
|
}
|
|
12877
12896
|
|
|
12878
|
-
this.isDropdownFullscreen = this.dropdown.isBibFullscreen;
|
|
12879
|
-
|
|
12880
12897
|
if (!this.dropdown.isPopoverVisible && this.input.value && this.input.value.length > 0) {
|
|
12881
12898
|
if (this.menu.getAttribute('loading') || (this.availableOptions && this.availableOptions.length > 0) || this.noMatchOption !== undefined) { // eslint-disable-line no-extra-parens
|
|
12882
12899
|
if (this.menu.hasAttribute('loading') && !this.menu.hasLoadingPlaceholder) {
|
|
@@ -12903,6 +12920,13 @@ class AuroCombobox extends LitElement {
|
|
|
12903
12920
|
// Listen for the dropdown to be shown or hidden
|
|
12904
12921
|
this.dropdown.addEventListener("auroDropdown-toggled", (ev) => {
|
|
12905
12922
|
this.dropdownOpen = ev.detail.expanded;
|
|
12923
|
+
|
|
12924
|
+
// wait a frame in case the bib gets hide immediately after showing because there is no value
|
|
12925
|
+
setTimeout(this.transportInput);
|
|
12926
|
+
});
|
|
12927
|
+
|
|
12928
|
+
this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
|
|
12929
|
+
this.showBib();
|
|
12906
12930
|
});
|
|
12907
12931
|
|
|
12908
12932
|
// this.dropdown.addEventListener('auroDropdown-show', () => {
|
|
@@ -12921,19 +12945,10 @@ class AuroCombobox extends LitElement {
|
|
|
12921
12945
|
this.hideBib = this.hideBib.bind(this);
|
|
12922
12946
|
this.bibtemplate.addEventListener('close-click', this.hideBib);
|
|
12923
12947
|
|
|
12924
|
-
this.dropdown.addEventListener('auroDropdown-triggerClick', () => {
|
|
12925
|
-
this.showBib();
|
|
12926
|
-
});
|
|
12927
|
-
|
|
12928
12948
|
this.transportInput = this.transportInput.bind(this);
|
|
12929
|
-
this.dropdown.addEventListener('auroDropdown-toggled', () => {
|
|
12930
|
-
// wait a frame in case the bib gets hide immediately after showing because there is no value
|
|
12931
|
-
setTimeout(this.transportInput);
|
|
12932
|
-
});
|
|
12933
12949
|
|
|
12934
|
-
this.dropdown.addEventListener('auroDropdown-strategy-change', (
|
|
12950
|
+
this.dropdown.addEventListener('auroDropdown-strategy-change', () => {
|
|
12935
12951
|
// event when the strategy(bib mode) is changed between fullscreen and floating
|
|
12936
|
-
this.isDropdownFullscreen = event.detail.strategy === 'fullscreen';
|
|
12937
12952
|
setTimeout(this.transportInput);
|
|
12938
12953
|
});
|
|
12939
12954
|
}
|
|
@@ -13029,20 +13044,17 @@ class AuroCombobox extends LitElement {
|
|
|
13029
13044
|
* @private
|
|
13030
13045
|
* Dispatches input's keyboard events from host
|
|
13031
13046
|
* This allows key events from the input to be handled by the parent.
|
|
13032
|
-
* @param {
|
|
13047
|
+
* @param {Event} event - The keyboard event.
|
|
13033
13048
|
*/
|
|
13034
|
-
|
|
13049
|
+
bubbleUpInputEvent(event) {
|
|
13050
|
+
// Do not need to bubble events if the input is not in bib.
|
|
13035
13051
|
if (event.currentTarget.parentNode !== this.dropdown) {
|
|
13052
|
+
// prevents browsers to move cursor in input element.
|
|
13036
13053
|
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
13037
13054
|
event.preventDefault();
|
|
13038
13055
|
}
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
key: event.key,
|
|
13042
|
-
code: event.code,
|
|
13043
|
-
repeat: event.repeat,
|
|
13044
|
-
});
|
|
13045
|
-
this.dispatchEvent(ke);
|
|
13056
|
+
const dupEvent = new event.constructor(event.type, event);
|
|
13057
|
+
this.dispatchEvent(dupEvent);
|
|
13046
13058
|
}
|
|
13047
13059
|
}
|
|
13048
13060
|
|
|
@@ -13053,14 +13065,22 @@ class AuroCombobox extends LitElement {
|
|
|
13053
13065
|
*/
|
|
13054
13066
|
configureInput() {
|
|
13055
13067
|
// When input is in bibtemplate, make the event to be fired at combobox element
|
|
13056
|
-
this.
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13068
|
+
this.bubbleUpInputEvent = this.bubbleUpInputEvent.bind(this);
|
|
13069
|
+
|
|
13070
|
+
const events = [
|
|
13071
|
+
'input',
|
|
13072
|
+
'keydown',
|
|
13073
|
+
'keyup'
|
|
13074
|
+
];
|
|
13075
|
+
events.forEach((eventType) => {
|
|
13076
|
+
this.input.addEventListener(eventType, this.bubbleUpInputEvent);
|
|
13077
|
+
});
|
|
13060
13078
|
|
|
13061
13079
|
this.addEventListener('keyup', (evt) => {
|
|
13062
13080
|
if (evt.key.length === 1 || evt.key === 'Backspace' || evt.key === 'Delete') {
|
|
13063
|
-
this.
|
|
13081
|
+
if (!this.dropdown.isPopoverVisible) {
|
|
13082
|
+
this.showBib();
|
|
13083
|
+
}
|
|
13064
13084
|
}
|
|
13065
13085
|
});
|
|
13066
13086
|
|
|
@@ -13121,8 +13141,8 @@ class AuroCombobox extends LitElement {
|
|
|
13121
13141
|
const inputHelpText = this.input.shadowRoot.querySelector('auro-helptext, [auro-helptext');
|
|
13122
13142
|
const inputAlertIcon = this.input.shadowRoot.querySelector(".alertNotification");
|
|
13123
13143
|
|
|
13124
|
-
if (this.dropdown.isPopoverVisible && this.
|
|
13125
|
-
if (this.input.parentNode
|
|
13144
|
+
if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
|
|
13145
|
+
if (this.input.parentNode === this.dropdown) {
|
|
13126
13146
|
// keep the trigger size the same even after input gets removed
|
|
13127
13147
|
const parentSize = window.getComputedStyle(this.dropdown.trigger);
|
|
13128
13148
|
this.dropdown.trigger.style.height = parentSize.height;
|
|
@@ -13208,7 +13228,7 @@ class AuroCombobox extends LitElement {
|
|
|
13208
13228
|
}
|
|
13209
13229
|
|
|
13210
13230
|
// Force dropdown bib to hide if input value has no matching suggestions
|
|
13211
|
-
if ((!this.availableOptions || this.availableOptions.length === 0) && !this.
|
|
13231
|
+
if ((!this.availableOptions || this.availableOptions.length === 0) && !this.dropdown.isBibFullscreen) {
|
|
13212
13232
|
this.hideBib();
|
|
13213
13233
|
}
|
|
13214
13234
|
}
|
|
@@ -13231,7 +13251,7 @@ class AuroCombobox extends LitElement {
|
|
|
13231
13251
|
if (evt.key === 'Tab') {
|
|
13232
13252
|
this.hideBib();
|
|
13233
13253
|
|
|
13234
|
-
if (this.dropdown.isPopoverVisible && this.
|
|
13254
|
+
if (this.dropdown.isPopoverVisible && this.dropdown.isBibFullscreen) {
|
|
13235
13255
|
// if bib is open in fullscreen, just close the bib and do not move the focus to the next focasable element
|
|
13236
13256
|
evt.preventDefault();
|
|
13237
13257
|
}
|
|
@@ -110,7 +110,7 @@ The use of any Auro custom element has a dependency on the [Auro Design Tokens](
|
|
|
110
110
|
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
|
|
111
111
|
|
|
112
112
|
```html
|
|
113
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.2
|
|
113
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-formkit@3.3.0-beta.2/auro-counter/+esm"></script>
|
|
114
114
|
```
|
|
115
115
|
<!-- AURO-GENERATED-CONTENT:END -->
|
|
116
116
|
|