@ctrliq/quantic-components 1.61.4 → 1.62.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/combobox/index.d.ts +2 -0
- package/dist/combobox/index.js +48 -8
- package/dist/combobox/index.stories.d.ts +3 -0
- package/dist/combobox/index.stories.js +37 -0
- package/dist/field/combobox/combobox-field.component.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/meta/index.js.map +1 -1
- package/dist/quantic-components.js +50 -9
- package/dist/quantic-components.js.map +1 -1
- package/dist/quantic-components.min.js +4 -3
- package/dist/quantic-components.min.js.map +1 -1
- package/dist/splitter/splitter-group.component.js +1 -1
- package/dist/types/combobox/index.d.ts +2 -0
- package/dist/types/combobox/index.stories.d.ts +3 -0
- package/package.json +1 -1
|
@@ -52579,6 +52579,7 @@
|
|
|
52579
52579
|
this.required = false;
|
|
52580
52580
|
this.invalid = false;
|
|
52581
52581
|
this.emptyLabel = 'No results';
|
|
52582
|
+
this.allowCustomValue = false;
|
|
52582
52583
|
this._open = false;
|
|
52583
52584
|
this._inputValue = '';
|
|
52584
52585
|
this._activeIndex = -1;
|
|
@@ -52587,11 +52588,17 @@
|
|
|
52587
52588
|
this.internals = this.attachInternals();
|
|
52588
52589
|
}
|
|
52589
52590
|
updated(changedProperties) {
|
|
52590
|
-
|
|
52591
|
+
const valueChanged = changedProperties.has('value');
|
|
52592
|
+
const optionsChanged = changedProperties.has('options');
|
|
52593
|
+
const customValueChanged = changedProperties.has('allowCustomValue');
|
|
52594
|
+
if (valueChanged || customValueChanged || (optionsChanged && !this._open)) {
|
|
52591
52595
|
const selected = this.options.find((o) => o.value === this.value);
|
|
52592
52596
|
if (selected) {
|
|
52593
52597
|
this._inputValue = selected.label;
|
|
52594
52598
|
}
|
|
52599
|
+
else if (this.allowCustomValue) {
|
|
52600
|
+
this._inputValue = this.value;
|
|
52601
|
+
}
|
|
52595
52602
|
else {
|
|
52596
52603
|
this._inputValue = '';
|
|
52597
52604
|
}
|
|
@@ -52646,15 +52653,34 @@
|
|
|
52646
52653
|
await this.updateComplete;
|
|
52647
52654
|
this.positionListbox();
|
|
52648
52655
|
}
|
|
52649
|
-
closeList() {
|
|
52656
|
+
closeList(commit = false) {
|
|
52650
52657
|
if (!this._open)
|
|
52651
52658
|
return;
|
|
52652
52659
|
this._open = false;
|
|
52653
52660
|
this._activeIndex = -1;
|
|
52654
52661
|
this.cleanup?.();
|
|
52655
52662
|
this.cleanup = undefined;
|
|
52656
|
-
|
|
52657
|
-
|
|
52663
|
+
if (this.allowCustomValue && commit) {
|
|
52664
|
+
this.commitCustomValue();
|
|
52665
|
+
}
|
|
52666
|
+
else {
|
|
52667
|
+
const selected = this.options.find((o) => o.value === this.value);
|
|
52668
|
+
this._inputValue =
|
|
52669
|
+
selected?.label ?? (this.allowCustomValue ? this.value : '');
|
|
52670
|
+
}
|
|
52671
|
+
}
|
|
52672
|
+
commitCustomValue() {
|
|
52673
|
+
const trimmed = this._inputValue.trim();
|
|
52674
|
+
this._inputValue = trimmed;
|
|
52675
|
+
if (trimmed === this.value)
|
|
52676
|
+
return;
|
|
52677
|
+
this.value = trimmed;
|
|
52678
|
+
this.internals.setFormValue(trimmed);
|
|
52679
|
+
this.dispatchEvent(new CustomEvent('value-changed', {
|
|
52680
|
+
detail: { value: trimmed },
|
|
52681
|
+
bubbles: true,
|
|
52682
|
+
composed: true,
|
|
52683
|
+
}));
|
|
52658
52684
|
}
|
|
52659
52685
|
positionListbox() {
|
|
52660
52686
|
const listbox = this._listboxRef.value;
|
|
@@ -52741,18 +52767,23 @@
|
|
|
52741
52767
|
this.selectOption(opt);
|
|
52742
52768
|
}
|
|
52743
52769
|
}
|
|
52770
|
+
else if (this.allowCustomValue && this._inputValue.trim()) {
|
|
52771
|
+
e.preventDefault();
|
|
52772
|
+
this.closeList(true);
|
|
52773
|
+
this.commitCustomValue();
|
|
52774
|
+
}
|
|
52744
52775
|
break;
|
|
52745
52776
|
case 'Escape':
|
|
52746
52777
|
e.preventDefault();
|
|
52747
52778
|
this.closeList();
|
|
52748
52779
|
break;
|
|
52749
52780
|
case 'Tab':
|
|
52750
|
-
this.closeList();
|
|
52781
|
+
this.closeList(true);
|
|
52751
52782
|
break;
|
|
52752
52783
|
}
|
|
52753
52784
|
}
|
|
52754
52785
|
handleBlur() {
|
|
52755
|
-
this.closeList();
|
|
52786
|
+
this.closeList(true);
|
|
52756
52787
|
this.dispatchEvent(new Event('blur', { bubbles: true, composed: true }));
|
|
52757
52788
|
}
|
|
52758
52789
|
handleFocus() {
|
|
@@ -52777,7 +52808,7 @@
|
|
|
52777
52808
|
this.value = state;
|
|
52778
52809
|
this.internals.setFormValue(state);
|
|
52779
52810
|
const selected = this.options.find((o) => o.value === state);
|
|
52780
|
-
this._inputValue = selected?.label ?? '';
|
|
52811
|
+
this._inputValue = selected?.label ?? (this.allowCustomValue ? state : '');
|
|
52781
52812
|
}
|
|
52782
52813
|
formDisabledCallback(disabled) {
|
|
52783
52814
|
this.disabled = disabled;
|
|
@@ -53244,6 +53275,15 @@
|
|
|
53244
53275
|
description: 'Text shown in the listbox when no options match the input.',
|
|
53245
53276
|
})
|
|
53246
53277
|
], exports.Combobox.prototype, "emptyLabel", void 0);
|
|
53278
|
+
__decorate([
|
|
53279
|
+
prop({
|
|
53280
|
+
type: 'boolean',
|
|
53281
|
+
default: 'false',
|
|
53282
|
+
description: 'When true, the user can type a value that does not match any option. ' +
|
|
53283
|
+
'The typed text is preserved on blur/Enter and surfaced through the value-changed event. ' +
|
|
53284
|
+
'When false (default), only values from the options list are accepted.',
|
|
53285
|
+
})
|
|
53286
|
+
], exports.Combobox.prototype, "allowCustomValue", void 0);
|
|
53247
53287
|
__decorate([
|
|
53248
53288
|
prop({
|
|
53249
53289
|
type: '(option: ComboboxOption, inputValue: string) => boolean',
|
|
@@ -53261,7 +53301,7 @@
|
|
|
53261
53301
|
], exports.Combobox.prototype, "_activeIndex", void 0);
|
|
53262
53302
|
exports.Combobox = __decorate([
|
|
53263
53303
|
event('value-changed', {
|
|
53264
|
-
description: 'Fired when the user selects an option from the list.',
|
|
53304
|
+
description: 'Fired when the user selects an option from the list, or commits a custom value when allowCustomValue is enabled.',
|
|
53265
53305
|
detail: '{ value: string }',
|
|
53266
53306
|
}),
|
|
53267
53307
|
event('input-changed', {
|
|
@@ -60027,6 +60067,7 @@
|
|
|
60027
60067
|
.options=${this.options}
|
|
60028
60068
|
.size=${this.size}
|
|
60029
60069
|
.emptyLabel=${this.emptyLabel}
|
|
60070
|
+
.allowCustomValue=${this.allowCustomValue}
|
|
60030
60071
|
.filterFn=${this.filterFn}
|
|
60031
60072
|
?disabled=${this.disabled}
|
|
60032
60073
|
?required=${this.required}
|
|
@@ -66408,7 +66449,7 @@
|
|
|
66408
66449
|
}
|
|
66409
66450
|
updated(changed) {
|
|
66410
66451
|
super.updated(changed);
|
|
66411
|
-
if (changed.has('split')
|
|
66452
|
+
if (changed.has('split')) {
|
|
66412
66453
|
this.sizes = parseSplit(this.split, this.panes.length);
|
|
66413
66454
|
this.applySizes();
|
|
66414
66455
|
}
|