@lion/ui 0.1.5 → 0.2.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/components/accordion/src/LionAccordion.js +2 -2
- package/components/accordion/test/lion-accordion.test.js +31 -0
- package/components/calendar/src/LionCalendar.js +13 -3
- package/components/combobox/src/LionCombobox.js +107 -14
- package/components/combobox/src/validators.js +18 -0
- package/components/combobox/test/lion-combobox.test.js +286 -184
- package/components/combobox/test/validators.test.js +62 -0
- package/components/combobox/test-helpers/combobox-helpers.js +125 -0
- package/components/form-core/types/choice-group/ChoiceGroupMixinTypes.ts +4 -3
- package/components/input-datepicker/src/LionInputDatepicker.js +9 -1
- package/components/input-iban/translations/de.js +1 -1
- package/components/listbox/src/ListboxMixin.js +6 -0
- package/components/listbox/test-suites/ListboxMixin.suite.js +15 -8
- package/components/overlays/src/OverlayController.js +27 -7
- package/components/overlays/test/OverlayController.test.js +16 -2
- package/components/switch/src/LionSwitch.js +0 -3
- package/components/switch/src/LionSwitchButton.js +14 -1
- package/components/switch/test/lion-switch-button.test.js +15 -1
- package/components/switch/test/lion-switch.test.js +21 -6
- package/components/validate-messages/src/loadDefaultFeedbackMessagesNoSideEffects.js +11 -8
- package/components/validate-messages/translations/bg.js +4 -0
- package/components/validate-messages/translations/cs.js +2 -0
- package/components/validate-messages/translations/de.js +4 -0
- package/components/validate-messages/translations/en.js +2 -0
- package/components/validate-messages/translations/es.js +4 -0
- package/components/validate-messages/translations/fr.js +4 -0
- package/components/validate-messages/translations/hu.js +2 -0
- package/components/validate-messages/translations/it.js +4 -0
- package/components/validate-messages/translations/nl.js +4 -0
- package/components/validate-messages/translations/pl.js +2 -0
- package/components/validate-messages/translations/ro.js +4 -0
- package/components/validate-messages/translations/ru.js +4 -0
- package/components/validate-messages/translations/sk.js +2 -0
- package/components/validate-messages/translations/uk.js +4 -0
- package/components/validate-messages/translations/zh.js +2 -0
- package/custom-elements.json +1365 -34
- package/dist-types/components/calendar/src/LionCalendar.d.ts +2 -0
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
- package/dist-types/components/combobox/src/LionCombobox.d.ts +37 -13
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/combobox/src/validators.d.ts +13 -0
- package/dist-types/components/combobox/src/validators.d.ts.map +1 -0
- package/dist-types/components/combobox/test/lion-combobox.test.d.ts +0 -2
- package/dist-types/components/combobox/test/lion-combobox.test.d.ts.map +1 -1
- package/dist-types/components/combobox/test/validators.test.d.ts +2 -0
- package/dist-types/components/combobox/test/validators.test.d.ts.map +1 -0
- package/dist-types/components/combobox/test-helpers/combobox-helpers.d.ts +41 -0
- package/dist-types/components/combobox/test-helpers/combobox-helpers.d.ts.map +1 -0
- package/dist-types/components/form-core/types/choice-group/ChoiceGroupMixinTypes.d.ts +4 -3
- package/dist-types/components/form-core/types/choice-group/ChoiceGroupMixinTypes.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +4 -0
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/listbox/src/ListboxMixin.d.ts.map +1 -1
- package/dist-types/components/listbox/test-suites/ListboxMixin.suite.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts +2 -0
- package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
- package/dist-types/components/switch/src/LionSwitch.d.ts +0 -1
- package/dist-types/components/switch/src/LionSwitch.d.ts.map +1 -1
- package/dist-types/components/switch/src/LionSwitchButton.d.ts +3 -0
- package/dist-types/components/switch/src/LionSwitchButton.d.ts.map +1 -1
- package/dist-types/components/switch/test/lion-switch.test.d.ts +1 -1
- package/dist-types/components/switch/test/lion-switch.test.d.ts.map +1 -1
- package/dist-types/components/validate-messages/src/loadDefaultFeedbackMessagesNoSideEffects.d.ts.map +1 -1
- package/dist-types/components/validate-messages/translations/bg-BG.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/bg.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/cs-CZ.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/cs.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/de-DE.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/de.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/en-AU.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/en-GB.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/en-PH.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/en-US.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/en.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/es-ES.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/es.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/fr-BE.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/fr-FR.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/fr.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/hu-HU.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/hu.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/it-IT.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/it.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/nl-BE.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/nl-NL.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/nl.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/pl-PL.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/pl.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/ro-RO.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/ro.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/ru-RU.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/ru.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/sk-SK.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/sk.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/uk-UA.d.ts +2 -0
- package/dist-types/components/validate-messages/translations/uk.d.ts +3 -0
- package/dist-types/components/validate-messages/translations/zh.d.ts +3 -0
- package/dist-types/exports/combobox-test-helpers.d.ts +2 -0
- package/dist-types/exports/combobox-test-helpers.d.ts.map +1 -0
- package/dist-types/exports/combobox.d.ts +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/checkbox-group/use-cases.md +1 -0
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +12 -2
- package/docs/components/combobox/use-cases.md +36 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select-rich/overview.md +7 -10
- package/docs/components/select-rich/use-cases.md +54 -69
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -10
- package/docs/fundamentals/systems/overlays/rationale.md +3 -6
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/combobox-test-helpers.js +1 -0
- package/exports/combobox.js +1 -0
- package/package.json +1 -1
|
@@ -171,12 +171,12 @@ export class LionAccordion extends LitElement {
|
|
|
171
171
|
|
|
172
172
|
const invokers = /** @type {HTMLElement[]} */ ([
|
|
173
173
|
...Array.from(existingInvokers),
|
|
174
|
-
...Array.from(this.querySelectorAll('[slot="invoker"]')),
|
|
174
|
+
...Array.from(this.querySelectorAll(':scope > [slot="invoker"]')),
|
|
175
175
|
]);
|
|
176
176
|
|
|
177
177
|
const contents = /** @type {HTMLElement[]} */ ([
|
|
178
178
|
...Array.from(existingContent),
|
|
179
|
-
...Array.from(this.querySelectorAll('[slot="content"]')),
|
|
179
|
+
...Array.from(this.querySelectorAll(':scope > [slot="content"]')),
|
|
180
180
|
]);
|
|
181
181
|
|
|
182
182
|
if (invokers.length !== contents.length) {
|
|
@@ -126,6 +126,37 @@ describe('<lion-accordion>', () => {
|
|
|
126
126
|
);
|
|
127
127
|
stub.restore();
|
|
128
128
|
});
|
|
129
|
+
|
|
130
|
+
it('does not select any elements with slot="invoker" and slot="content" inside slotted elements', async () => {
|
|
131
|
+
const stub = sinon.stub(console, 'warn');
|
|
132
|
+
const el = /** @type {LionAccordion} */ (
|
|
133
|
+
await fixture(html`
|
|
134
|
+
<lion-accordion>
|
|
135
|
+
<h2 slot="invoker">
|
|
136
|
+
<button>invoker 1</button>
|
|
137
|
+
<button slot="invoker">Nested invoker</button>
|
|
138
|
+
</h2>
|
|
139
|
+
<h2 slot="invoker"><button>invoker 2</button></h2>
|
|
140
|
+
<div slot="content">
|
|
141
|
+
content 1
|
|
142
|
+
<p slot="content">Nested content 1</p>
|
|
143
|
+
</div>
|
|
144
|
+
<div slot="content">
|
|
145
|
+
content 2
|
|
146
|
+
<p slot="content">Nested content 2</p>
|
|
147
|
+
</div>
|
|
148
|
+
</lion-accordion>
|
|
149
|
+
`)
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const invokers = Array.from(getInvokers(el));
|
|
153
|
+
const contents = Array.from(getContents(el));
|
|
154
|
+
|
|
155
|
+
expect(stub.called).to.be.false;
|
|
156
|
+
expect(invokers.length).to.equal(contents.length);
|
|
157
|
+
|
|
158
|
+
stub.restore();
|
|
159
|
+
});
|
|
129
160
|
});
|
|
130
161
|
|
|
131
162
|
describe('Accordion navigation', () => {
|
|
@@ -523,11 +523,16 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
523
523
|
@click=${clickDateDelegation}
|
|
524
524
|
?disabled=${disabled}
|
|
525
525
|
>
|
|
526
|
-
|
|
526
|
+
${this._previousIconTemplate()}
|
|
527
527
|
</button>
|
|
528
528
|
`;
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
+
// eslint-disable-next-line class-methods-use-this
|
|
532
|
+
_previousIconTemplate() {
|
|
533
|
+
return html`<`;
|
|
534
|
+
}
|
|
535
|
+
|
|
531
536
|
/**
|
|
532
537
|
* @param {string} type
|
|
533
538
|
* @param {string} nextMonth
|
|
@@ -554,11 +559,16 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
554
559
|
@click=${clickDateDelegation}
|
|
555
560
|
?disabled=${disabled}
|
|
556
561
|
>
|
|
557
|
-
|
|
562
|
+
${this._nextIconTemplate()}
|
|
558
563
|
</button>
|
|
559
564
|
`;
|
|
560
565
|
}
|
|
561
566
|
|
|
567
|
+
// eslint-disable-next-line class-methods-use-this
|
|
568
|
+
_nextIconTemplate() {
|
|
569
|
+
return html`>`;
|
|
570
|
+
}
|
|
571
|
+
|
|
562
572
|
/**
|
|
563
573
|
*
|
|
564
574
|
* @param {string} mode
|
|
@@ -743,7 +753,7 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
743
753
|
const isDayButton = /** @param {HTMLElement} el */ el =>
|
|
744
754
|
el.classList.contains('calendar__day-button');
|
|
745
755
|
|
|
746
|
-
const el = /** @type {HTMLElement & { date: Date }} */ (ev.
|
|
756
|
+
const el = /** @type {HTMLElement & { date: Date }} */ (ev.composedPath()[0]);
|
|
747
757
|
if (isDayButton(el)) {
|
|
748
758
|
this.__dateSelectedByUser(el.date);
|
|
749
759
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { browserDetection } from '@lion/ui/core.js';
|
|
2
|
+
import { Unparseable } from '@lion/ui/form-core.js';
|
|
2
3
|
import { LionListbox } from '@lion/ui/listbox.js';
|
|
3
4
|
import { LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
|
|
4
5
|
import { OverlayMixin, withDropdownConfig } from '@lion/ui/overlays.js';
|
|
5
6
|
import { css, html } from 'lit';
|
|
6
7
|
import { makeMatchingTextBold, unmakeMatchingTextBold } from './utils/makeMatchingTextBold.js';
|
|
8
|
+
import { MatchesOption } from './validators.js';
|
|
7
9
|
|
|
8
10
|
const matchA11ySpanReverseFns = new WeakMap();
|
|
9
11
|
|
|
@@ -12,12 +14,12 @@ const matchA11ySpanReverseFns = new WeakMap();
|
|
|
12
14
|
// on Listbox or ListNavigationWithActiveDescendantMixin
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
* @typedef {import('
|
|
16
|
-
* @typedef {import('
|
|
17
|
-
* @typedef {import('
|
|
18
|
-
* @typedef {import('
|
|
19
|
-
* @typedef {import('
|
|
20
|
-
* @typedef {import('
|
|
17
|
+
* @typedef {import('@lion/ui/listbox.js').LionOption} LionOption
|
|
18
|
+
* @typedef {import('@lion/ui/listbox.js').LionOptions} LionOptions
|
|
19
|
+
* @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
|
|
20
|
+
* @typedef {import('@lion/ui/types/core.js').SlotsMap} SlotsMap
|
|
21
|
+
* @typedef {import('@lion/ui/types/form-core.js').ChoiceInputHost} ChoiceInputHost
|
|
22
|
+
* @typedef {import('@lion/ui/types/form-core.js').FormControlHost} FormControlHost
|
|
21
23
|
* @typedef {import('../types/SelectionDisplay.js').SelectionDisplay} SelectionDisplay
|
|
22
24
|
*/
|
|
23
25
|
|
|
@@ -38,6 +40,9 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
38
40
|
type: Boolean,
|
|
39
41
|
attribute: 'show-all-on-empty',
|
|
40
42
|
},
|
|
43
|
+
requireOptionMatch: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
},
|
|
41
46
|
__shouldAutocompleteNextUpdate: Boolean,
|
|
42
47
|
};
|
|
43
48
|
}
|
|
@@ -141,6 +146,60 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
141
146
|
];
|
|
142
147
|
}
|
|
143
148
|
|
|
149
|
+
/**
|
|
150
|
+
* @override ChoiceGroupMixin
|
|
151
|
+
*/
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
get modelValue() {
|
|
154
|
+
const choiceGroupModelValue = super.modelValue;
|
|
155
|
+
if (choiceGroupModelValue !== '') {
|
|
156
|
+
return choiceGroupModelValue;
|
|
157
|
+
}
|
|
158
|
+
// Since the FormatMixin can't be applied to a [FormGroup](https://github.com/ing-bank/lion/blob/master/packages/ui/components/form-core/src/form-group/FormGroupMixin.js)
|
|
159
|
+
// atm, we treat it in a way analogue to InteractionStateMixin (basically same apis, w/o Mixin applied).
|
|
160
|
+
// Hence, modelValue has no reactivity by default and we need to call parser manually here...
|
|
161
|
+
return this.parser(this.value);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Duplicating from ChoiceGroupMixin, because you cannot independently inherit/override getter + setter.
|
|
165
|
+
// If you override one, gotta override the other, they go in pairs.
|
|
166
|
+
/**
|
|
167
|
+
* @override ChoiceGroupMixin
|
|
168
|
+
*/
|
|
169
|
+
set modelValue(value) {
|
|
170
|
+
super.modelValue = value;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* We define the value getter/setter below as also defined in LionField (via FormatMixin).
|
|
175
|
+
* Since FormatMixin is meant for Formgroups/ChoiceGroup it's not applied on Combobox;
|
|
176
|
+
* Combobox is somewhat of a hybrid between a ChoiceGroup and LionField, therefore we copy over
|
|
177
|
+
* some of the LionField members to align with its interface.
|
|
178
|
+
*
|
|
179
|
+
* The view value. Will be delegated to `._inputNode.value`
|
|
180
|
+
*/
|
|
181
|
+
get value() {
|
|
182
|
+
return this._inputNode?.value || this.__value || '';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** @param {string} value */
|
|
186
|
+
set value(value) {
|
|
187
|
+
// if not yet connected to dom can't change the value
|
|
188
|
+
if (this._inputNode) {
|
|
189
|
+
this._inputNode.value = value;
|
|
190
|
+
/** @type {string | undefined} */
|
|
191
|
+
this.__value = undefined;
|
|
192
|
+
} else {
|
|
193
|
+
this.__value = value;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
reset() {
|
|
198
|
+
super.reset();
|
|
199
|
+
// @ts-ignore _initialModelValue comes from ListboxMixin
|
|
200
|
+
this.value = this._initialModelValue;
|
|
201
|
+
}
|
|
202
|
+
|
|
144
203
|
/**
|
|
145
204
|
* @enhance FormControlMixin - add slot[name=selection-display]
|
|
146
205
|
* @protected
|
|
@@ -256,7 +315,7 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
256
315
|
* @protected
|
|
257
316
|
*/
|
|
258
317
|
get _inputNode() {
|
|
259
|
-
if (this._ariaVersion === '1.1') {
|
|
318
|
+
if (this._ariaVersion === '1.1' && this._comboboxNode) {
|
|
260
319
|
return /** @type {HTMLInputElement} */ (this._comboboxNode.querySelector('input'));
|
|
261
320
|
}
|
|
262
321
|
return /** @type {HTMLInputElement} */ (this._comboboxNode);
|
|
@@ -327,7 +386,11 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
327
386
|
* By default, the listbox closes on empty, similar to wai-aria example and <datalist>
|
|
328
387
|
*/
|
|
329
388
|
this.showAllOnEmpty = false;
|
|
330
|
-
|
|
389
|
+
/**
|
|
390
|
+
* If set to false, the value is allowed to not match any of the options.
|
|
391
|
+
* We set the default to true for backwards compatibility
|
|
392
|
+
*/
|
|
393
|
+
this.requireOptionMatch = true;
|
|
331
394
|
/**
|
|
332
395
|
* @configure ListboxMixin: the wai-aria pattern and <datalist> rotate
|
|
333
396
|
*/
|
|
@@ -336,7 +399,7 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
336
399
|
* @configure ListboxMixin: the wai-aria pattern and <datalist> have selection follow focus
|
|
337
400
|
*/
|
|
338
401
|
this.selectionFollowsFocus = true;
|
|
339
|
-
|
|
402
|
+
this.defaultValidators.push(new MatchesOption());
|
|
340
403
|
/**
|
|
341
404
|
* For optimal support, we allow aria v1.1 on newer browsers
|
|
342
405
|
* @type {'1.1'|'1.0'}
|
|
@@ -422,6 +485,18 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
422
485
|
}
|
|
423
486
|
}
|
|
424
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Converts viewValue to modelValue
|
|
490
|
+
* @param {string} value - viewValue: the formatted value inside <input>
|
|
491
|
+
* @returns {*} modelValue
|
|
492
|
+
*/
|
|
493
|
+
parser(value) {
|
|
494
|
+
if (this.requireOptionMatch && this.checkedIndex === -1 && value !== '') {
|
|
495
|
+
return new Unparseable(value);
|
|
496
|
+
}
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
|
|
425
500
|
/**
|
|
426
501
|
* When textbox value doesn't match checkedIndex anymore, update accordingly...
|
|
427
502
|
* @protected
|
|
@@ -432,7 +507,7 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
432
507
|
if (!this.multipleChoice && !autoselect && checkedElement) {
|
|
433
508
|
const textboxValue = this._getTextboxValueFromOption(checkedElement);
|
|
434
509
|
if (!this._inputNode.value.startsWith(textboxValue)) {
|
|
435
|
-
this.
|
|
510
|
+
this.setCheckedIndex(-1);
|
|
436
511
|
}
|
|
437
512
|
}
|
|
438
513
|
}
|
|
@@ -480,6 +555,15 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
480
555
|
if (typeof this._selectionDisplayNode?.onComboboxElementUpdated === 'function') {
|
|
481
556
|
this._selectionDisplayNode.onComboboxElementUpdated(changedProperties);
|
|
482
557
|
}
|
|
558
|
+
|
|
559
|
+
if (changedProperties.has('requireOptionMatch') || changedProperties.has('multipleChoice')) {
|
|
560
|
+
if (!this.requireOptionMatch && this.multipleChoice) {
|
|
561
|
+
// TODO implement !requireOptionMatch and multipleChoice flow
|
|
562
|
+
throw new Error(
|
|
563
|
+
"multipleChoice and requireOptionMatch=false can't be used at the same time (yet).",
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
483
567
|
}
|
|
484
568
|
|
|
485
569
|
/**
|
|
@@ -557,7 +641,13 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
557
641
|
*/
|
|
558
642
|
// eslint-disable-next-line class-methods-use-this
|
|
559
643
|
_getTextboxValueFromOption(option) {
|
|
560
|
-
|
|
644
|
+
if (option) {
|
|
645
|
+
return option.choiceValue;
|
|
646
|
+
}
|
|
647
|
+
if (this.modelValue instanceof Unparseable) {
|
|
648
|
+
return this.modelValue.viewValue;
|
|
649
|
+
}
|
|
650
|
+
return this.modelValue;
|
|
561
651
|
}
|
|
562
652
|
|
|
563
653
|
/**
|
|
@@ -814,7 +904,8 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
814
904
|
|
|
815
905
|
if (isInlineAutoFillCandidate) {
|
|
816
906
|
const textboxValue = this._getTextboxValueFromOption(option);
|
|
817
|
-
const stringValues =
|
|
907
|
+
const stringValues =
|
|
908
|
+
textboxValue && typeof textboxValue === 'string' && typeof curValue === 'string';
|
|
818
909
|
const beginsWith =
|
|
819
910
|
stringValues && textboxValue.toLowerCase().indexOf(curValue.toLowerCase()) === 0;
|
|
820
911
|
// We only can do proper inline autofilling when the beginning of the word matches
|
|
@@ -862,7 +953,8 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
862
953
|
// [7]. If no autofill took place, we are left with the previously matched option; correct this
|
|
863
954
|
if (autoselect && !hasAutoFilled && !this.multipleChoice) {
|
|
864
955
|
// This means there is no match for checkedIndex
|
|
865
|
-
this.
|
|
956
|
+
this.setCheckedIndex(-1);
|
|
957
|
+
this.modelValue = this.parser(inputValue);
|
|
866
958
|
}
|
|
867
959
|
|
|
868
960
|
// [8]. These values will help computing autofill intentions next autocomplete cycle
|
|
@@ -1090,6 +1182,7 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
1090
1182
|
|
|
1091
1183
|
clear() {
|
|
1092
1184
|
super.clear();
|
|
1093
|
-
this.
|
|
1185
|
+
this.value = '';
|
|
1186
|
+
this.__shouldAutocompleteNextUpdate = true;
|
|
1094
1187
|
}
|
|
1095
1188
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { Unparseable, Validator } from '@lion/ui/form-core.js';
|
|
3
|
+
|
|
4
|
+
export class MatchesOption extends Validator {
|
|
5
|
+
static get validatorName() {
|
|
6
|
+
return 'MatchesOption';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {unknown} [value]
|
|
11
|
+
* @param {string | undefined} [options]
|
|
12
|
+
* @param {{ node: any }} [config]
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line class-methods-use-this
|
|
15
|
+
execute(value, options, config) {
|
|
16
|
+
return config?.node.modelValue instanceof Unparseable;
|
|
17
|
+
}
|
|
18
|
+
}
|