@lion/ui 0.0.12 → 0.0.13

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.
Files changed (157) hide show
  1. package/components/accordion/src/LionAccordion.js +22 -9
  2. package/components/accordion/test/lion-accordion.test.js +29 -32
  3. package/components/input-tel/translations/bg.js +3 -1
  4. package/components/input-tel/translations/cs.js +3 -1
  5. package/components/input-tel/translations/de.js +3 -1
  6. package/components/input-tel/translations/en.js +3 -1
  7. package/components/input-tel/translations/es.js +3 -1
  8. package/components/input-tel/translations/fr.js +3 -1
  9. package/components/input-tel/translations/hu.js +3 -1
  10. package/components/input-tel/translations/it.js +3 -1
  11. package/components/input-tel/translations/nl.js +3 -1
  12. package/components/input-tel/translations/pl.js +3 -1
  13. package/components/input-tel/translations/ro.js +3 -1
  14. package/components/input-tel/translations/ru.js +3 -1
  15. package/components/input-tel/translations/sk.js +3 -1
  16. package/components/input-tel/translations/uk.js +3 -1
  17. package/components/input-tel/translations/zh.js +3 -1
  18. package/components/input-tel-dropdown/src/LionInputTelDropdown.js +5 -5
  19. package/components/listbox/src/ListboxMixin.js +0 -4
  20. package/components/listbox/types/ListboxMixinTypes.ts +1 -4
  21. package/components/overlays/src/OverlayController.js +14 -25
  22. package/components/overlays/src/utils/adopt-styles.js +136 -0
  23. package/components/overlays/test/OverlayController.test.js +8 -55
  24. package/components/overlays/test/local-positioning.test.js +1 -1
  25. package/components/overlays/test/utils-tests/adopt-styles.test.js +177 -0
  26. package/components/overlays/test-helpers/createShadowHost.js +16 -0
  27. package/components/overlays/{test/utils-tests/local-positioning-helpers.js → test-helpers/normalizeTransformStyle.js} +0 -0
  28. package/components/select-rich/src/LionSelectRich.js +12 -6
  29. package/components/select-rich/test/lion-select-rich.test.js +25 -1
  30. package/custom-elements.json +416 -111
  31. package/dist-types/components/accordion/src/LionAccordion.d.ts.map +1 -1
  32. package/dist-types/components/input-tel/translations/bg-BG.d.ts +3 -1
  33. package/dist-types/components/input-tel/translations/bg.d.ts +3 -1
  34. package/dist-types/components/input-tel/translations/cs-CZ.d.ts +3 -1
  35. package/dist-types/components/input-tel/translations/cs.d.ts +3 -1
  36. package/dist-types/components/input-tel/translations/de-DE.d.ts +3 -1
  37. package/dist-types/components/input-tel/translations/de.d.ts +3 -1
  38. package/dist-types/components/input-tel/translations/en-AU.d.ts +3 -1
  39. package/dist-types/components/input-tel/translations/en-GB.d.ts +3 -1
  40. package/dist-types/components/input-tel/translations/en-US.d.ts +3 -1
  41. package/dist-types/components/input-tel/translations/en.d.ts +3 -1
  42. package/dist-types/components/input-tel/translations/es-ES.d.ts +3 -1
  43. package/dist-types/components/input-tel/translations/es.d.ts +3 -1
  44. package/dist-types/components/input-tel/translations/fr-BE.d.ts +3 -1
  45. package/dist-types/components/input-tel/translations/fr-FR.d.ts +3 -1
  46. package/dist-types/components/input-tel/translations/fr.d.ts +3 -1
  47. package/dist-types/components/input-tel/translations/hu-HU.d.ts +3 -1
  48. package/dist-types/components/input-tel/translations/hu.d.ts +3 -1
  49. package/dist-types/components/input-tel/translations/it-IT.d.ts +3 -1
  50. package/dist-types/components/input-tel/translations/it.d.ts +3 -1
  51. package/dist-types/components/input-tel/translations/nl-BE.d.ts +3 -1
  52. package/dist-types/components/input-tel/translations/nl-NL.d.ts +3 -1
  53. package/dist-types/components/input-tel/translations/nl.d.ts +3 -1
  54. package/dist-types/components/input-tel/translations/pl-PL.d.ts +3 -1
  55. package/dist-types/components/input-tel/translations/pl.d.ts +3 -1
  56. package/dist-types/components/input-tel/translations/ro-RO.d.ts +3 -1
  57. package/dist-types/components/input-tel/translations/ro.d.ts +3 -1
  58. package/dist-types/components/input-tel/translations/ru-RU.d.ts +3 -1
  59. package/dist-types/components/input-tel/translations/ru.d.ts +3 -1
  60. package/dist-types/components/input-tel/translations/sk-SK.d.ts +3 -1
  61. package/dist-types/components/input-tel/translations/sk.d.ts +3 -1
  62. package/dist-types/components/input-tel/translations/uk-UA.d.ts +3 -1
  63. package/dist-types/components/input-tel/translations/uk.d.ts +3 -1
  64. package/dist-types/components/input-tel/translations/zh.d.ts +3 -1
  65. package/dist-types/components/listbox/src/ListboxMixin.d.ts.map +1 -1
  66. package/dist-types/components/listbox/types/ListboxMixinTypes.d.ts +1 -2
  67. package/dist-types/components/listbox/types/ListboxMixinTypes.d.ts.map +1 -1
  68. package/dist-types/components/overlays/src/OverlayController.d.ts +5 -1
  69. package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
  70. package/dist-types/components/overlays/src/utils/adopt-styles.d.ts +24 -0
  71. package/dist-types/components/overlays/src/utils/adopt-styles.d.ts.map +1 -0
  72. package/dist-types/components/overlays/test/OverlayController.test.d.ts.map +1 -1
  73. package/dist-types/components/overlays/test/utils-tests/adopt-styles.test.d.ts +2 -0
  74. package/dist-types/components/overlays/test/utils-tests/adopt-styles.test.d.ts.map +1 -0
  75. package/dist-types/components/overlays/test-helpers/createShadowHost.d.ts +8 -0
  76. package/dist-types/components/overlays/test-helpers/createShadowHost.d.ts.map +1 -0
  77. package/dist-types/components/overlays/{test/utils-tests/local-positioning-helpers.d.ts → test-helpers/normalizeTransformStyle.d.ts} +1 -1
  78. package/dist-types/components/overlays/test-helpers/normalizeTransformStyle.d.ts.map +1 -0
  79. package/dist-types/components/select-rich/src/LionSelectRich.d.ts +8 -8
  80. package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
  81. package/dist-types/tsconfig.tsbuildinfo +1 -1
  82. package/docs/components/button/use-cases.md +2 -0
  83. package/docs/components/checkbox-group/overview.md +2 -2
  84. package/docs/components/collapsible/overview.md +1 -1
  85. package/docs/components/combobox/overview.md +1 -1
  86. package/docs/components/combobox/src/demo-selection-display.js +1 -1
  87. package/docs/components/combobox/use-cases.md +1 -1
  88. package/docs/components/dialog/overview.md +1 -1
  89. package/docs/components/dialog/src/demoStyle.js +18 -0
  90. package/docs/components/fieldset/overview.md +5 -5
  91. package/docs/components/form/overview.md +3 -3
  92. package/docs/components/icon/use-cases.md +1 -1
  93. package/docs/components/input/overview.md +1 -1
  94. package/docs/components/input-amount/overview.md +3 -3
  95. package/docs/components/input-date/overview.md +3 -3
  96. package/docs/components/input-datepicker/overview.md +5 -5
  97. package/docs/components/input-email/overview.md +2 -2
  98. package/docs/components/input-iban/overview.md +2 -2
  99. package/docs/components/input-range/overview.md +2 -2
  100. package/docs/components/input-stepper/overview.md +1 -1
  101. package/docs/components/input-tel/overview.md +1 -1
  102. package/docs/components/input-tel/use-cases.md +6 -6
  103. package/docs/components/input-tel-dropdown/overview.md +1 -1
  104. package/docs/components/radio-group/overview.md +3 -3
  105. package/docs/components/select-rich/use-cases.md +30 -24
  106. package/docs/components/tabs/examples.md +1 -1
  107. package/docs/fundamentals/index.md +4 -4
  108. package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
  109. package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
  110. package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
  111. package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
  112. package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
  113. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  114. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  115. package/docs/fundamentals/systems/core/overview.md +1 -1
  116. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  117. package/docs/fundamentals/systems/form/model-value.md +1 -1
  118. package/docs/fundamentals/systems/form/overview.md +28 -28
  119. package/docs/fundamentals/systems/form/validate.md +1 -1
  120. package/docs/fundamentals/systems/localize/overview.md +4 -4
  121. package/docs/fundamentals/systems/overlays/assets/demo-el-using-overlaymixin.mjs +0 -16
  122. package/docs/fundamentals/systems/overlays/configuration.md +18 -32
  123. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  124. package/docs/fundamentals/systems/overlays/use-cases.md +5 -5
  125. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  126. package/docs/fundamentals/tools/singleton-manager/.gitignore +1 -0
  127. package/docs/fundamentals/tools/singleton-manager/example-complex/demo-app.js +93 -0
  128. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/overlays/index.js +30 -0
  129. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/overlays/instance.js +4 -0
  130. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/page-a/page-a.js +35 -0
  131. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/page-b/node_modules/overlays/index.js +30 -0
  132. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/page-b/node_modules/overlays/instance.js +4 -0
  133. package/docs/fundamentals/tools/singleton-manager/example-complex/node_modules/page-b/page-b.js +49 -0
  134. package/docs/fundamentals/tools/singleton-manager/example-complex/overlayCompatibility.js +70 -0
  135. package/docs/fundamentals/tools/singleton-manager/example-fail/demo-app.js +91 -0
  136. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/overlays/index.js +30 -0
  137. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/overlays/instance.js +3 -0
  138. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/page-a/page-a.js +34 -0
  139. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/page-b/node_modules/overlays/index.js +30 -0
  140. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/page-b/node_modules/overlays/instance.js +3 -0
  141. package/docs/fundamentals/tools/singleton-manager/example-fail/node_modules/page-b/page-b.js +34 -0
  142. package/docs/fundamentals/tools/singleton-manager/example-success/demo-app.js +93 -0
  143. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/overlays/index.js +30 -0
  144. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/overlays/instance.js +4 -0
  145. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/page-a/page-a.js +34 -0
  146. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/page-b/node_modules/overlays/index.js +30 -0
  147. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/page-b/node_modules/overlays/instance.js +4 -0
  148. package/docs/fundamentals/tools/singleton-manager/example-success/node_modules/page-b/page-b.js +34 -0
  149. package/docs/fundamentals/tools/singleton-manager/example-success/overlayCompatibility.js +23 -0
  150. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  151. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  152. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  153. package/docs/guides/index.md +8 -8
  154. package/docs/guides/principles/index.md +5 -5
  155. package/docs/guides/principles/styling.md +1 -1
  156. package/package.json +2 -2
  157. package/dist-types/components/overlays/test/utils-tests/local-positioning-helpers.d.ts.map +0 -1
@@ -44,21 +44,21 @@ export class LionAccordion extends LitElement {
44
44
  flex-direction: column;
45
45
  }
46
46
 
47
- .accordion [slot='invoker'] {
47
+ .accordion ::slotted(.invoker) {
48
48
  margin: 0;
49
49
  }
50
50
 
51
- .accordion [slot='invoker'][expanded] {
51
+ .accordion ::slotted(.invoker)[expanded] {
52
52
  font-weight: bold;
53
53
  }
54
54
 
55
- .accordion [slot='content'] {
55
+ .accordion ::slotted(.content) {
56
56
  margin: 0;
57
57
  visibility: hidden;
58
58
  display: none;
59
59
  }
60
60
 
61
- .accordion [slot='content'][expanded] {
61
+ .accordion ::slotted(.content[expanded]) {
62
62
  visibility: visible;
63
63
  display: block;
64
64
  }
@@ -159,9 +159,15 @@ export class LionAccordion extends LitElement {
159
159
  * @private
160
160
  */
161
161
  __setupStore() {
162
- const accordion = this.shadowRoot?.querySelector('slot[name=_accordion]');
163
- const existingInvokers = accordion ? accordion.querySelectorAll('[slot=invoker]') : [];
164
- const existingContent = accordion ? accordion.querySelectorAll('[slot=content]') : [];
162
+ const accordion = /** @type {HTMLSlotElement} */ (
163
+ this.shadowRoot?.querySelector('slot[name=_accordion]')
164
+ );
165
+ const existingInvokers = accordion
166
+ ? accordion.assignedElements().filter(child => child.classList.contains('invoker'))
167
+ : [];
168
+ const existingContent = accordion
169
+ ? accordion.assignedElements().filter(child => child.classList.contains('content'))
170
+ : [];
165
171
 
166
172
  const invokers = /** @type {HTMLElement[]} */ ([
167
173
  ...Array.from(existingInvokers),
@@ -212,14 +218,21 @@ export class LionAccordion extends LitElement {
212
218
  const invokers = /** @type {HTMLElement[]} */ (
213
219
  Array.from(this.children).filter(child => child.slot === 'invoker')
214
220
  );
221
+
215
222
  const contents = /** @type {HTMLElement[]} */ (
216
223
  Array.from(this.children).filter(child => child.slot === 'content')
217
224
  );
225
+
218
226
  const accordion = this.shadowRoot?.querySelector('slot[name=_accordion]');
227
+
219
228
  if (accordion) {
220
229
  invokers.forEach((invoker, index) => {
221
- accordion.insertAdjacentElement('beforeend', invoker);
222
- accordion.insertAdjacentElement('beforeend', contents[index]);
230
+ invoker.classList.add('invoker');
231
+ // eslint-disable-next-line no-param-reassign
232
+ invoker.slot = '_accordion';
233
+
234
+ contents[index].classList.add('content');
235
+ contents[index].slot = '_accordion';
223
236
  });
224
237
  }
225
238
  }
@@ -23,27 +23,27 @@ const basicAccordion = html`
23
23
  * @param {Element} el
24
24
  */
25
25
  function getAccordionChildren(el) {
26
- const slot = el.shadowRoot?.querySelector('slot[name=_accordion]');
26
+ if (el.shadowRoot) {
27
+ const slot = el.shadowRoot?.querySelector('slot[name=_accordion]');
27
28
 
28
- return slot ? slot.children : [];
29
+ return slot && slot instanceof HTMLSlotElement ? slot.assignedElements() : [];
30
+ }
31
+
32
+ return [];
29
33
  }
30
34
 
31
35
  /**
32
36
  * @param {Element} el
33
37
  */
34
38
  function getInvokers(el) {
35
- const slot = el.shadowRoot?.querySelector('slot[name=_accordion]');
36
-
37
- return slot ? slot.querySelectorAll('[slot=invoker]') : [];
39
+ return getAccordionChildren(el).filter(child => child.classList.contains('invoker'));
38
40
  }
39
41
 
40
42
  /**
41
43
  * @param {Element} el
42
44
  */
43
45
  function getContents(el) {
44
- const slot = el.shadowRoot?.querySelector('slot[name=_accordion]');
45
-
46
- return slot ? slot.querySelectorAll('[slot=content]') : [];
46
+ return getAccordionChildren(el).filter(child => child.classList.contains('content'));
47
47
  }
48
48
 
49
49
  describe('<lion-accordion>', () => {
@@ -68,14 +68,14 @@ describe('<lion-accordion>', () => {
68
68
 
69
69
  expect(
70
70
  Array.from(getAccordionChildren(el)).find(
71
- child => child.slot === 'invoker' && child.hasAttribute('expanded'),
71
+ child => child.className === 'invoker' && child.hasAttribute('expanded'),
72
72
  )?.textContent,
73
73
  ).to.equal('invoker 2');
74
74
 
75
75
  el.expanded = [0];
76
76
  expect(
77
77
  Array.from(getAccordionChildren(el)).find(
78
- child => child.slot === 'invoker' && child.hasAttribute('expanded'),
78
+ child => child.className === 'invoker' && child.hasAttribute('expanded'),
79
79
  )?.textContent,
80
80
  ).to.equal('invoker 1');
81
81
  });
@@ -146,17 +146,16 @@ describe('<lion-accordion>', () => {
146
146
  `)
147
147
  );
148
148
  expect(el.focusedIndex).to.equal(1);
149
+
149
150
  expect(
150
- Array.from(getAccordionChildren(el)).find(
151
- child => child.slot === 'invoker' && child.firstElementChild?.hasAttribute('focused'),
152
- )?.textContent,
151
+ Array.from(getInvokers(el)).find(child => child.firstElementChild?.hasAttribute('focused'))
152
+ ?.textContent,
153
153
  ).to.equal('invoker 2');
154
154
 
155
155
  el.focusedIndex = 0;
156
156
  expect(
157
- Array.from(getAccordionChildren(el)).find(
158
- child => child.slot === 'invoker' && child.firstElementChild?.hasAttribute('focused'),
159
- )?.textContent,
157
+ Array.from(getInvokers(el)).find(child => child.firstElementChild?.hasAttribute('focused'))
158
+ ?.textContent,
160
159
  ).to.equal('invoker 1');
161
160
  });
162
161
 
@@ -360,14 +359,10 @@ describe('<lion-accordion>', () => {
360
359
  await el.updateComplete;
361
360
 
362
361
  expect(
363
- Array.from(getAccordionChildren(el)).find(
364
- child => child.slot === 'invoker' && child.hasAttribute('expanded'),
365
- )?.textContent,
362
+ Array.from(getInvokers(el)).find(child => child.hasAttribute('expanded'))?.textContent,
366
363
  ).to.equal('invoker 5');
367
364
  expect(
368
- Array.from(getAccordionChildren(el)).find(
369
- child => child.slot === 'content' && child.hasAttribute('expanded'),
370
- )?.textContent,
365
+ Array.from(getContents(el)).find(child => child.hasAttribute('expanded'))?.textContent,
371
366
  ).to.equal('content 5');
372
367
  });
373
368
 
@@ -410,11 +405,13 @@ describe('<lion-accordion>', () => {
410
405
  <div slot="content">content 2</div>
411
406
  </lion-accordion>
412
407
  `);
408
+
409
+ // console.log(getAccordionChildren(el));
413
410
  expect(
414
- Array.from(getAccordionChildren(el)).find(child => child.slot === 'content'),
411
+ Array.from(getAccordionChildren(el)).find(child => child.classList.contains('content')),
415
412
  ).to.not.have.attribute('tabindex');
416
413
  expect(
417
- Array.from(getAccordionChildren(el)).find(child => child.slot === 'content'),
414
+ Array.from(getAccordionChildren(el)).find(child => child.classList.contains('content')),
418
415
  ).to.not.have.attribute('tabindex');
419
416
  });
420
417
 
@@ -445,10 +442,10 @@ describe('<lion-accordion>', () => {
445
442
  <div slot="content">content</div>
446
443
  </lion-accordion>
447
444
  `);
448
- expect(
449
- Array.from(getAccordionChildren(el)).find(child => child.slot === 'invoker')
450
- ?.firstElementChild,
451
- ).to.have.attribute('aria-expanded', 'false');
445
+ expect(Array.from(getInvokers(el))[0]?.firstElementChild).to.have.attribute(
446
+ 'aria-expanded',
447
+ 'false',
448
+ );
452
449
  });
453
450
 
454
451
  it('adds aria-expanded="true" to invoker when its content is expanded', async () => {
@@ -461,10 +458,10 @@ describe('<lion-accordion>', () => {
461
458
  `)
462
459
  );
463
460
  el.expanded = [0];
464
- expect(
465
- Array.from(getAccordionChildren(el)).find(child => child.slot === 'invoker')
466
- ?.firstElementChild,
467
- ).to.have.attribute('aria-expanded', 'true');
461
+ expect(Array.from(getInvokers(el))[0]?.firstElementChild).to.have.attribute(
462
+ 'aria-expanded',
463
+ 'true',
464
+ );
468
465
  });
469
466
  });
470
467
 
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Избор на държава',
2
+ allCountries: 'Всички държави',
3
3
  phoneNumber: 'Телефонен номер',
4
+ selectCountry: 'Избор на държава',
5
+ suggestedCountries: 'Предложени държави',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Vybrat zemi',
2
+ allCountries: 'Všechny země',
3
3
  phoneNumber: 'Telefonní číslo',
4
+ selectCountry: 'Vybrat zemi',
5
+ suggestedCountries: 'Navrhované země',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Land auswählen',
2
+ allCountries: 'Alle Länder',
3
3
  phoneNumber: 'Telefonnummer',
4
+ selectCountry: 'Land auswählen',
5
+ suggestedCountries: 'Vorgeschlagene Länder',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Select country',
2
+ allCountries: 'All countries',
3
3
  phoneNumber: 'Phone number',
4
+ selectCountry: 'Select country',
5
+ suggestedCountries: 'Suggested countries',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Seleccione país',
2
+ allCountries: 'Pays suggérés',
3
3
  phoneNumber: 'Número de teléfono',
4
+ selectCountry: 'Seleccione país',
5
+ suggestedCountries: 'Países sugeridos',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Sélectionnez un pays',
2
+ allCountries: 'Tous les pays',
3
3
  phoneNumber: 'Numéro de téléphone',
4
+ selectCountry: 'Sélectionnez un pays',
5
+ suggestedCountries: 'Pays suggérés',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Ország kiválasztása',
2
+ allCountries: 'Minden ország',
3
3
  phoneNumber: 'Telefonszám',
4
+ selectCountry: 'Ország kiválasztása',
5
+ suggestedCountries: 'Javasolt országok',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Selezionare il paese',
2
+ allCountries: 'Tutti i paesi',
3
3
  phoneNumber: 'Numero di telefono',
4
+ selectCountry: 'Selezionare il paese',
5
+ suggestedCountries: 'Paesi consigliati',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Selecteer land',
2
+ allCountries: 'Alle landen',
3
3
  phoneNumber: 'Telefoonnummer',
4
+ selectCountry: 'Selecteer land',
5
+ suggestedCountries: 'Voor gestelde landen',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Wybierz kraj',
2
+ allCountries: 'Wszystkie kraje',
3
3
  phoneNumber: 'Numer telefonu',
4
+ selectCountry: 'Wybierz kraj',
5
+ suggestedCountries: 'Sugerowane kraje',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Selectare țară',
2
+ allCountries: 'Toate țările',
3
3
  phoneNumber: 'Număr de telefon',
4
+ selectCountry: 'Selectare țară',
5
+ suggestedCountries: 'Țări sugerate',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Выбрать страну',
2
+ allCountries: 'Все страны',
3
3
  phoneNumber: 'Номер телефона',
4
+ selectCountry: 'Выбрать страну',
5
+ suggestedCountries: 'Предлагаемые страны',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Zvoliť krajinu',
2
+ allCountries: 'Všetky krajiny',
3
3
  phoneNumber: 'Telefónne číslo',
4
+ selectCountry: 'Zvoliť krajinu',
5
+ suggestedCountries: 'Odporúčané krajiny',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: 'Вибрати країну',
2
+ allCountries: 'Усі країни',
3
3
  phoneNumber: 'Номер телефону',
4
+ selectCountry: 'Вибрати країну',
5
+ suggestedCountries: 'Запропоновані країни',
4
6
  };
@@ -1,4 +1,6 @@
1
1
  export default {
2
- selectCountry: '选择国家/地区',
2
+ allCountries: '所有国家/地区',
3
3
  phoneNumber: '电话号码',
4
+ selectCountry: '选择国家/地区',
5
+ suggestedCountries: '建议的国家/地区',
4
6
  };
@@ -92,9 +92,9 @@ export class LionInputTelDropdown extends LionInputTel {
92
92
  },
93
93
  labels: {
94
94
  selectCountry: localize.msg('lion-input-tel:selectCountry'),
95
- // TODO: add translations
96
- allCountries: this._allCountriesLabel || 'All countries',
97
- preferredCountries: this._preferredCountriesLabel || 'Suggested countries',
95
+ allCountries: this._allCountriesLabel || localize.msg('lion-input-tel:allCountries'),
96
+ preferredCountries:
97
+ this._preferredCountriesLabel || localize.msg('lion-input-tel:suggestedCountries'),
98
98
  },
99
99
  },
100
100
  };
@@ -125,10 +125,10 @@ export class LionInputTelDropdown extends LionInputTel {
125
125
  >
126
126
  ${data?.regionMetaListPreferred?.length
127
127
  ? html`
128
- <optgroup label="${refs?.dropdown?.labels?._preferredCountries}">
128
+ <optgroup label="${refs?.dropdown?.labels?.preferredCountries}">
129
129
  ${data.regionMetaListPreferred.map(renderOption)}
130
130
  </optgroup>
131
- <optgroup label="${refs?.dropdown?.labels?._allCountries}">
131
+ <optgroup label="${refs?.dropdown?.labels?.allCountries}">
132
132
  ${data?.regionMetaList?.map(renderOption)}
133
133
  </optgroup>
134
134
  `
@@ -384,10 +384,6 @@ const ListboxMixinImplementation = superclass =>
384
384
  updated(changedProperties) {
385
385
  super.updated(changedProperties);
386
386
 
387
- if (this.formElements.length === 1) {
388
- this.singleOption = true;
389
- }
390
-
391
387
  if (changedProperties.has('disabled')) {
392
388
  if (this.disabled) {
393
389
  this.__requestOptionsToBeDisabled();
@@ -11,7 +11,7 @@ import { LionOption } from '../src/LionOption.js';
11
11
  export declare class ListboxHost {
12
12
  static get styles(): CSSResultArray;
13
13
  /**
14
- * When true, will synchronize activedescendant and selected element on
14
+ * When true, will synchronize active descendant and selected element on
15
15
  * arrow key navigation.
16
16
  * This behavior can usually be seen on <select> on the Windows platform.
17
17
  * Note that this behavior cannot be used when multiple-choice is true.
@@ -31,9 +31,6 @@ export declare class ListboxHost {
31
31
 
32
32
  public hasNoDefaultSelected: boolean;
33
33
 
34
- public singleOption: boolean;
35
- // protected _invokerNode: HTMLElement;
36
-
37
34
  public checkedIndex: number | number[];
38
35
 
39
36
  public activeIndex: number;
@@ -1,7 +1,7 @@
1
- import { adoptStyles } from 'lit';
2
1
  import { overlays } from './singleton.js';
3
2
  import { containFocus } from './utils/contain-focus.js';
4
3
  import { overlayShadowDomStyle } from './overlayShadowDomStyle.js';
4
+ import { _adoptStyleUtils } from './utils/adopt-styles.js';
5
5
 
6
6
  /**
7
7
  * @typedef {import('@lion/ui/types/overlays.js').OverlayConfig} OverlayConfig
@@ -13,22 +13,6 @@ import { overlayShadowDomStyle } from './overlayShadowDomStyle.js';
13
13
  * @typedef {'setup'|'init'|'teardown'|'before-show'|'show'|'hide'|'add'|'remove'} OverlayPhase
14
14
  */
15
15
 
16
- const rootNodeStylesMap = new WeakSet();
17
-
18
- /**
19
- * Returns element that adopts stylesheet
20
- * @param {Element} shadowOrBodyEl
21
- * @returns {ShadowRoot}
22
- */
23
- function getRootNodeOrBodyElThatAdoptsStylesheet(shadowOrBodyEl) {
24
- const rootNode = /** @type {* & DocumentOrShadowRoot} */ (shadowOrBodyEl.getRootNode());
25
- if (rootNode === document) {
26
- // @ts-ignore
27
- return document.body;
28
- }
29
- return rootNode;
30
- }
31
-
32
16
  /**
33
17
  * From:
34
18
  * - wrappingDialogNodeL1: `<dialog role="none"/>`
@@ -207,7 +191,7 @@ export class OverlayController extends EventTarget {
207
191
 
208
192
  this.manager.add(this);
209
193
  /** @protected */
210
- this._contentId = `overlay-content--${Math.random().toString(36).substr(2, 10)}`;
194
+ this._contentId = `overlay-content--${Math.random().toString(36).slice(2, 10)}`;
211
195
  /** @private */
212
196
  this.__originalAttrs = new Map();
213
197
  this.updateConfig(config);
@@ -536,16 +520,20 @@ export class OverlayController extends EventTarget {
536
520
  OverlayController.popperModule = preloadPopper();
537
521
  }
538
522
  }
539
- this.__initOverlayStyles();
523
+ this.__handleOverlayStyles({ phase: 'init' });
540
524
  this._handleFeatures({ phase: 'init' });
541
525
  }
542
526
 
543
- __initOverlayStyles() {
544
- const rootNode = getRootNodeOrBodyElThatAdoptsStylesheet(this.contentWrapperNode);
545
- if (!rootNodeStylesMap.has(rootNode)) {
546
- // TODO: ideally we should also support a teardown
547
- adoptStyles(rootNode, [...(rootNode.adoptedStyleSheets || []), overlayShadowDomStyle]);
548
- rootNodeStylesMap.add(rootNode);
527
+ /**
528
+ * @param {{ phase: OverlayPhase }} config
529
+ * @private
530
+ */
531
+ __handleOverlayStyles({ phase }) {
532
+ const rootNode = /** @type {ShadowRoot} */ (this.contentWrapperNode?.getRootNode());
533
+ if (phase === 'init') {
534
+ _adoptStyleUtils.adoptStyle(rootNode, overlayShadowDomStyle);
535
+ } else if (phase === 'teardown') {
536
+ _adoptStyleUtils.adoptStyle(rootNode, overlayShadowDomStyle, { teardown: true });
549
537
  }
550
538
  }
551
539
 
@@ -1284,6 +1272,7 @@ export class OverlayController extends EventTarget {
1284
1272
  }
1285
1273
 
1286
1274
  teardown() {
1275
+ this.__handleOverlayStyles({ phase: 'teardown' });
1287
1276
  this._handleFeatures({ phase: 'teardown' });
1288
1277
  }
1289
1278
 
@@ -0,0 +1,136 @@
1
+ // See: https://github.com/ing-bank/lion/issues/1880
2
+
3
+ /**
4
+ * @typedef {import('lit').CSSResult|CSSStyleSheet} AdoptableStyle
5
+ * @typedef {(renderRoot:DocumentOrShadowRoot, style: AdoptableStyle, opts?: {teardown?: boolean}) => void} AdoptStyleFn
6
+ * @typedef {(renderRoot:DocumentOrShadowRoot, styles: AdoptableStyle[], opts?: {teardown?: boolean}) => void} AdoptStylesFn
7
+ */
8
+
9
+ // Shared protected object that can be spied/mocked in tests
10
+ export const _adoptStyleUtils = {
11
+ // Mocking Document.prototype.adoptedStyleSheets seemed impossible
12
+ supportsAdoptingStyleSheets:
13
+ window.ShadowRoot &&
14
+ // @ts-ignore
15
+ (window.ShadyCSS === undefined || window.ShadyCSS.nativeShadow) &&
16
+ 'adoptedStyleSheets' in Document.prototype &&
17
+ 'replace' in CSSStyleSheet.prototype,
18
+ /** @type {AdoptStyleFn} */
19
+ // @ts-ignore
20
+ adoptStyle: undefined,
21
+ /** @type {AdoptStylesFn} */
22
+ // @ts-ignore
23
+ adoptStyles: undefined,
24
+ };
25
+
26
+ const styleCache = new Map();
27
+
28
+ /**
29
+ * @param {CSSStyleSheet} cssStyleSheet
30
+ */
31
+ export function serializeConstructableStylesheet(cssStyleSheet) {
32
+ return Array.from(cssStyleSheet.cssRules)
33
+ .map(r => r.cssText)
34
+ .join('');
35
+ }
36
+
37
+ /**
38
+ * @param {DocumentOrShadowRoot} renderRoot
39
+ * @param {AdoptableStyle} style
40
+ * @param {{teardown?: boolean}} opts
41
+ */
42
+ function adoptStyleWhenAdoptedStylesheetsNotSupported(
43
+ renderRoot,
44
+ style,
45
+ { teardown = false } = {},
46
+ ) {
47
+ const adoptRoot = /** @type {ShadowRoot|Document['body']} */ (
48
+ renderRoot === document ? document.body : renderRoot
49
+ );
50
+ // @ts-ignore
51
+ const styleText = style.cssText || serializeConstructableStylesheet(style);
52
+
53
+ if (!teardown) {
54
+ const styleEl = document.createElement('style');
55
+ // keep notation, so it's not renamed in minification/build
56
+ // eslint-disable-next-line dot-notation
57
+ const nonce = window['litNonce'];
58
+ if (nonce !== undefined) {
59
+ styleEl.setAttribute('nonce', nonce);
60
+ }
61
+ styleEl.textContent = styleText;
62
+ adoptRoot.appendChild(styleEl);
63
+ } else {
64
+ const foundStyleEls = Array.from(adoptRoot.querySelectorAll('style'));
65
+
66
+ for (const foundStyleEl of foundStyleEls) {
67
+ if (foundStyleEl.textContent === styleText) {
68
+ foundStyleEl.remove();
69
+ break;
70
+ }
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @param {DocumentOrShadowRoot} renderRoot
77
+ * @param {AdoptableStyle} style
78
+ * @param {{teardown?: boolean}} opts
79
+ */
80
+ function handleCache(renderRoot, style, { teardown = false } = {}) {
81
+ let haltFurtherExecution = false;
82
+ if (!styleCache.has(renderRoot)) {
83
+ styleCache.set(renderRoot, []);
84
+ }
85
+ const addedStylesForRoot = styleCache.get(renderRoot);
86
+ const foundStyle = addedStylesForRoot.find(
87
+ (/** @type {import("lit").CSSResultOrNative} */ addedStyle) => style === addedStyle,
88
+ );
89
+
90
+ if (foundStyle && teardown) {
91
+ addedStylesForRoot.splice(addedStylesForRoot.indexOf(style), 1);
92
+ } else if (!foundStyle && !teardown) {
93
+ addedStylesForRoot.push(style);
94
+ } else if ((foundStyle && !teardown) || (!foundStyle && teardown)) {
95
+ // Already removed or added. We're done
96
+ haltFurtherExecution = true;
97
+ }
98
+
99
+ return { haltFurtherExecution };
100
+ }
101
+
102
+ /** @type {AdoptStyleFn} */
103
+ export function adoptStyle(renderRoot, style, { teardown = false } = {}) {
104
+ const { haltFurtherExecution } = handleCache(renderRoot, style, { teardown });
105
+ if (haltFurtherExecution) {
106
+ return;
107
+ }
108
+
109
+ if (!_adoptStyleUtils.supportsAdoptingStyleSheets) {
110
+ adoptStyleWhenAdoptedStylesheetsNotSupported(renderRoot, style, { teardown });
111
+ return;
112
+ }
113
+
114
+ const sheet = style instanceof CSSStyleSheet ? style : style.styleSheet;
115
+ if (!sheet) {
116
+ throw new Error(`Please provide a CSSResultOrNative style`);
117
+ }
118
+
119
+ if (!teardown) {
120
+ // @ts-ignore
121
+ // eslint-disable-next-line no-param-reassign
122
+ renderRoot.adoptedStyleSheets.push(sheet);
123
+ } else if (renderRoot.adoptedStyleSheets.includes(sheet)) {
124
+ renderRoot.adoptedStyleSheets.splice(renderRoot.adoptedStyleSheets.indexOf(sheet), 1);
125
+ }
126
+ }
127
+
128
+ /** @type {AdoptStylesFn} */
129
+ export function adoptStyles(renderRoot, styles, { teardown = false } = {}) {
130
+ for (const style of styles) {
131
+ _adoptStyleUtils.adoptStyle(renderRoot, style, { teardown });
132
+ }
133
+ }
134
+
135
+ _adoptStyleUtils.adoptStyle = adoptStyle;
136
+ _adoptStyleUtils.adoptStyles = adoptStyles;