@lion/ui 0.4.0 → 0.4.2
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/calendar/src/LionCalendar.js +4 -2
- package/components/combobox/src/LionCombobox.js +3 -1
- package/components/combobox/test/lion-combobox.test.js +28 -0
- package/components/combobox/test-helpers/combobox-helpers.js +15 -21
- package/components/input-amount/src/LionInputAmount.js +5 -2
- package/components/input-amount/test/lion-input-amount.test.js +21 -0
- package/components/overlays/src/utils/adopt-styles.js +1 -1
- package/custom-elements.json +516 -250
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/combobox/test-helpers/combobox-helpers.d.ts.map +1 -1
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts +2 -2
- package/dist-types/components/input-amount/src/LionInputAmount.d.ts.map +1 -1
- package/dist-types/exports/types/calendar.d.ts +2 -0
- package/dist-types/exports/types/calendar.d.ts.map +1 -0
- package/dist-types/exports/types/combobox.d.ts +2 -0
- package/dist-types/exports/types/combobox.d.ts.map +1 -0
- package/dist-types/exports/types/listbox.d.ts +3 -0
- package/dist-types/exports/types/listbox.d.ts.map +1 -0
- package/dist-types/exports/types/localize.d.ts +1 -4
- package/dist-types/exports/types/localize.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -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-file/overview.md +1 -1
- 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/use-cases.md +1 -1
- package/docs/components/steps/overview.md +2 -4
- 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/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
- 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 -5
- 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/create-a-form.md +4 -4
- 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/types/calendar.ts +1 -0
- package/exports/types/combobox.ts +1 -0
- package/exports/types/listbox.ts +2 -0
- package/exports/types/localize.ts +13 -4
- package/package.json +1 -1
|
@@ -799,7 +799,7 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
799
799
|
* @private
|
|
800
800
|
*/
|
|
801
801
|
__clickDateDelegation(ev) {
|
|
802
|
-
const el = /** @type {HTMLElement & { date: Date }} */ (ev.
|
|
802
|
+
const el = /** @type {HTMLElement & { date: Date }} */ (ev.composedPath()[0]);
|
|
803
803
|
if (isDayButton(el) && !isDisabledDayButton(el)) {
|
|
804
804
|
this.__dateSelectedByUser(el.date);
|
|
805
805
|
}
|
|
@@ -866,7 +866,9 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
866
866
|
switch (ev.key) {
|
|
867
867
|
case ' ':
|
|
868
868
|
case 'Enter':
|
|
869
|
-
this.__dayButtonSelection(
|
|
869
|
+
this.__dayButtonSelection(
|
|
870
|
+
/** @type {HTMLElement & { date: Date }} */ (ev.composedPath()[0]),
|
|
871
|
+
);
|
|
870
872
|
break;
|
|
871
873
|
case 'ArrowUp':
|
|
872
874
|
this.__modifyDate(-7, { dateType: '__focusedDate', type: 'Date' });
|
|
@@ -849,7 +849,9 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
|
|
849
849
|
* @protected
|
|
850
850
|
*/
|
|
851
851
|
_handleAutocompletion() {
|
|
852
|
-
const
|
|
852
|
+
const isSelectionEmpty = this._inputNode.selectionStart === this._inputNode.selectionEnd;
|
|
853
|
+
const hasSelection =
|
|
854
|
+
!isSelectionEmpty && this._inputNode.value.length !== this._inputNode.selectionStart;
|
|
853
855
|
|
|
854
856
|
const inputValue = this._inputNode.value;
|
|
855
857
|
const inputSelectionStart = this._inputNode.selectionStart;
|
|
@@ -1610,6 +1610,34 @@ describe('lion-combobox', () => {
|
|
|
1610
1610
|
expect(el.checkedIndex).to.equal(0);
|
|
1611
1611
|
});
|
|
1612
1612
|
|
|
1613
|
+
it('filters options correctly when changing the middle of the word', async () => {
|
|
1614
|
+
const el = /** @type {LionCombobox} */ (
|
|
1615
|
+
await fixture(html`
|
|
1616
|
+
<lion-combobox name="foo" autocomplete="list" match-mode="all">
|
|
1617
|
+
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
1618
|
+
<lion-option .choiceValue="${'Chard'}">Chard</lion-option>
|
|
1619
|
+
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
1620
|
+
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
1621
|
+
</lion-combobox>
|
|
1622
|
+
`)
|
|
1623
|
+
);
|
|
1624
|
+
|
|
1625
|
+
const { _inputNode } = getComboboxMembers(el);
|
|
1626
|
+
|
|
1627
|
+
mimicUserTyping(el, 'char');
|
|
1628
|
+
expect(_inputNode.value).to.equal('char');
|
|
1629
|
+
await el.updateComplete; // Char
|
|
1630
|
+
|
|
1631
|
+
expect(getFilteredOptionValues(el)).to.eql(['Chard']);
|
|
1632
|
+
|
|
1633
|
+
_inputNode.setSelectionRange(3, 3);
|
|
1634
|
+
await mimicUserTypingAdvanced(el, ['Backspace', 'i', 'c', 'o']);
|
|
1635
|
+
await el.updateComplete; // Chicor
|
|
1636
|
+
|
|
1637
|
+
expect(_inputNode.value).to.equal('chicor');
|
|
1638
|
+
expect(getFilteredOptionValues(el)).to.eql(['Chicory']);
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1613
1641
|
it('computation of "user intends autofill" works correctly afer autofill', async () => {
|
|
1614
1642
|
const el = /** @type {LionCombobox} */ (
|
|
1615
1643
|
await fixture(html`
|
|
@@ -63,39 +63,33 @@ export function mimicKeyPress(el, key) {
|
|
|
63
63
|
export async function mimicUserTypingAdvanced(el, values) {
|
|
64
64
|
const { _inputNode } = getComboboxMembers(el);
|
|
65
65
|
_inputNode.dispatchEvent(new Event('focusin', { bubbles: true }));
|
|
66
|
+
let cursorPosition = _inputNode.selectionStart || 0;
|
|
66
67
|
|
|
67
68
|
for (const key of values) {
|
|
68
69
|
// eslint-disable-next-line no-await-in-loop, no-loop-func
|
|
69
70
|
await new Promise(resolve => {
|
|
70
|
-
const
|
|
71
|
+
const selectionStart = _inputNode.selectionStart || 0;
|
|
72
|
+
const selectionEnd = _inputNode.selectionEnd || 0;
|
|
73
|
+
const hasSelection = selectionStart !== selectionEnd;
|
|
71
74
|
|
|
72
75
|
if (key === 'Backspace') {
|
|
73
76
|
if (hasSelection) {
|
|
74
77
|
_inputNode.value =
|
|
75
|
-
_inputNode.value.slice(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
_inputNode.value.slice(
|
|
80
|
-
|
|
81
|
-
_inputNode.value.length,
|
|
82
|
-
);
|
|
83
|
-
} else {
|
|
84
|
-
_inputNode.value = _inputNode.value.slice(0, -1);
|
|
78
|
+
_inputNode.value.slice(0, selectionStart) + _inputNode.value.slice(selectionEnd);
|
|
79
|
+
cursorPosition = selectionStart;
|
|
80
|
+
} else if (cursorPosition > 0) {
|
|
81
|
+
_inputNode.value =
|
|
82
|
+
_inputNode.value.slice(0, cursorPosition - 1) + _inputNode.value.slice(cursorPosition);
|
|
83
|
+
cursorPosition -= 1;
|
|
85
84
|
}
|
|
86
85
|
} else if (hasSelection) {
|
|
87
86
|
_inputNode.value =
|
|
88
|
-
_inputNode.value.slice(
|
|
89
|
-
|
|
90
|
-
_inputNode.selectionStart ? _inputNode.selectionStart : undefined,
|
|
91
|
-
) +
|
|
92
|
-
key +
|
|
93
|
-
_inputNode.value.slice(
|
|
94
|
-
_inputNode.selectionEnd ? _inputNode.selectionEnd : undefined,
|
|
95
|
-
_inputNode.value.length,
|
|
96
|
-
);
|
|
87
|
+
_inputNode.value.slice(0, selectionStart) + key + _inputNode.value.slice(selectionEnd);
|
|
88
|
+
cursorPosition = selectionStart + key.length;
|
|
97
89
|
} else {
|
|
98
|
-
_inputNode.value
|
|
90
|
+
_inputNode.value =
|
|
91
|
+
_inputNode.value.slice(0, cursorPosition) + key + _inputNode.value.slice(cursorPosition);
|
|
92
|
+
cursorPosition += 1;
|
|
99
93
|
}
|
|
100
94
|
|
|
101
95
|
mimicKeyPress(_inputNode, key);
|
|
@@ -159,6 +159,9 @@ export class LionInputAmount extends LocalizeMixin(LionInput) {
|
|
|
159
159
|
if (currency) {
|
|
160
160
|
if (!this.__currencyDisplayNodeIsConnected) {
|
|
161
161
|
this.appendChild(this.__currencyDisplayNode);
|
|
162
|
+
this.addToAriaLabelledBy(this.__currencyDisplayNode, {
|
|
163
|
+
idPrefix: this._currencyDisplayNodeSlot,
|
|
164
|
+
});
|
|
162
165
|
this.__currencyDisplayNodeIsConnected = true;
|
|
163
166
|
}
|
|
164
167
|
this.__currencyDisplayNode.textContent = this.__currencyLabel;
|
|
@@ -182,11 +185,11 @@ export class LionInputAmount extends LocalizeMixin(LionInput) {
|
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
/**
|
|
185
|
-
* @returns the current currency display node
|
|
188
|
+
* @returns {HTMLElement | undefined} the current currency display node
|
|
186
189
|
* @private
|
|
187
190
|
*/
|
|
188
191
|
get __currencyDisplayNode() {
|
|
189
|
-
const node = Array.from(this.children).find(
|
|
192
|
+
const node = /** @type {HTMLElement[]} */ (Array.from(this.children)).find(
|
|
190
193
|
child => child.slot === this._currencyDisplayNodeSlot,
|
|
191
194
|
);
|
|
192
195
|
if (node) {
|
|
@@ -308,6 +308,27 @@ describe('<lion-input-amount>', () => {
|
|
|
308
308
|
expect(_inputNode.getAttribute('aria-labelledby')).to.contain(label?.id);
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
+
it('adds currency id to aria-labelledby of input when currency switches from undefined', async () => {
|
|
312
|
+
const el = /** @type {LionInputAmount} */ (
|
|
313
|
+
await fixture(`<lion-input-amount></lion-input-amount>`)
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
el.currency = 'EUR';
|
|
317
|
+
|
|
318
|
+
let resolved = await el.updateComplete;
|
|
319
|
+
while (!resolved) {
|
|
320
|
+
resolved = await el.updateComplete;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const label = /** @type {HTMLElement[]} */ (Array.from(el.children)).find(
|
|
324
|
+
child => child.slot === 'after',
|
|
325
|
+
);
|
|
326
|
+
const { _inputNode } = getInputMembers(/** @type {* & LionInput} */ (el));
|
|
327
|
+
|
|
328
|
+
expect(label?.id).not.equal('');
|
|
329
|
+
expect(_inputNode.getAttribute('aria-labelledby')).to.contain(label?.id);
|
|
330
|
+
});
|
|
331
|
+
|
|
311
332
|
it('adds an aria-label to currency slot', async () => {
|
|
312
333
|
const el = /** @type {LionInputAmount} */ (
|
|
313
334
|
await fixture(`<lion-input-amount currency="EUR"></lion-input-amount>`)
|
|
@@ -119,7 +119,7 @@ export function adoptStyle(renderRoot, style, { teardown = false } = {}) {
|
|
|
119
119
|
if (!teardown) {
|
|
120
120
|
// @ts-ignore
|
|
121
121
|
// eslint-disable-next-line no-param-reassign
|
|
122
|
-
renderRoot.adoptedStyleSheets.
|
|
122
|
+
renderRoot.adoptedStyleSheets = [...renderRoot.adoptedStyleSheets, sheet];
|
|
123
123
|
} else if (renderRoot.adoptedStyleSheets.includes(sheet)) {
|
|
124
124
|
renderRoot.adoptedStyleSheets.splice(renderRoot.adoptedStyleSheets.indexOf(sheet), 1);
|
|
125
125
|
}
|