@lion/ui 0.11.4 → 0.11.6

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 (171) hide show
  1. package/components/calendar/src/LionCalendar.js +3 -0
  2. package/components/calendar/translations/tr.js +11 -0
  3. package/components/form-core/src/localizeNamespaceLoader.js +4 -0
  4. package/components/form-core/src/validate/ValidateMixin.js +6 -6
  5. package/components/form-core/test-suites/ValidateMixin.suite.js +116 -1
  6. package/components/form-core/translations/tr-TR.js +5 -0
  7. package/components/form-core/translations/tr.js +6 -0
  8. package/components/input-datepicker/src/localizeNamespaceLoader.js +7 -1
  9. package/components/input-datepicker/translations/tr-TR.js +5 -0
  10. package/components/input-datepicker/translations/tr.js +3 -0
  11. package/components/input-file/src/LionInputFile.js +39 -11
  12. package/components/input-file/src/LionSelectedFileList.js +0 -1
  13. package/components/input-file/test/lion-input-file.test.js +98 -4
  14. package/components/input-file/translations/bg.js +1 -1
  15. package/components/input-file/translations/cs.js +1 -1
  16. package/components/input-file/translations/de.js +6 -1
  17. package/components/input-file/translations/en.js +6 -2
  18. package/components/input-file/translations/es.js +1 -1
  19. package/components/input-file/translations/fr.js +1 -1
  20. package/components/input-file/translations/hu.js +1 -1
  21. package/components/input-file/translations/it.js +1 -1
  22. package/components/input-file/translations/nl.js +6 -1
  23. package/components/input-file/translations/pl.js +1 -1
  24. package/components/input-file/translations/ro.js +1 -1
  25. package/components/input-file/translations/ru.js +7 -3
  26. package/components/input-file/translations/sk.js +1 -1
  27. package/components/input-file/translations/uk.js +1 -1
  28. package/components/input-file/translations/zh.js +1 -1
  29. package/components/input-stepper/src/LionInputStepper.js +19 -3
  30. package/components/input-stepper/test/lion-input-stepper.test.js +94 -0
  31. package/components/input-tel/src/LionInputTel.js +15 -2
  32. package/components/input-tel/test-suites/LionInputTel.suite.js +26 -1
  33. package/components/input-tel-dropdown/src/LionInputTelDropdown.js +3 -16
  34. package/components/input-tel-dropdown/src/regionCodeToLocale.js +10 -0
  35. package/components/input-tel-dropdown/test/regionCodeToLocale.test.js +10 -0
  36. package/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.js +69 -1
  37. package/components/overlays/translations/tr-TR.js +5 -0
  38. package/components/overlays/translations/tr.js +4 -0
  39. package/components/pagination/src/LionPagination.js +2 -0
  40. package/components/pagination/translations/tr.js +6 -0
  41. package/components/validate-messages/src/getLocalizedMessage.js +4 -0
  42. package/components/validate-messages/translations/tr-TR.js +13 -0
  43. package/components/validate-messages/translations/tr.js +56 -0
  44. package/custom-elements.json +123 -55
  45. package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
  46. package/dist-types/components/calendar/translations/tr.d.ts +11 -0
  47. package/dist-types/components/calendar/translations/tr.d.ts.map +1 -0
  48. package/dist-types/components/form-core/src/localizeNamespaceLoader.d.ts.map +1 -1
  49. package/dist-types/components/form-core/test-suites/ValidateMixin.suite.d.ts.map +1 -1
  50. package/dist-types/components/form-core/translations/tr-TR.d.ts +8 -0
  51. package/dist-types/components/form-core/translations/tr-TR.d.ts.map +1 -0
  52. package/dist-types/components/form-core/translations/tr.d.ts +8 -0
  53. package/dist-types/components/form-core/translations/tr.d.ts.map +1 -0
  54. package/dist-types/components/input-datepicker/src/localizeNamespaceLoader.d.ts.map +1 -1
  55. package/dist-types/components/input-datepicker/translations/tr-TR.d.ts +5 -0
  56. package/dist-types/components/input-datepicker/translations/tr-TR.d.ts.map +1 -0
  57. package/dist-types/components/input-datepicker/translations/tr.d.ts +5 -0
  58. package/dist-types/components/input-datepicker/translations/tr.d.ts.map +1 -0
  59. package/dist-types/components/input-file/src/LionInputFile.d.ts +1 -0
  60. package/dist-types/components/input-file/src/LionInputFile.d.ts.map +1 -1
  61. package/dist-types/components/input-file/src/LionSelectedFileList.d.ts.map +1 -1
  62. package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts +1 -1
  63. package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts.map +1 -1
  64. package/dist-types/components/input-file/test/lion-input-file.test.d.ts.map +1 -1
  65. package/dist-types/components/input-file/translations/de-DE.d.ts +5 -0
  66. package/dist-types/components/input-file/translations/de.d.ts +5 -0
  67. package/dist-types/components/input-file/translations/en-AU.d.ts +5 -1
  68. package/dist-types/components/input-file/translations/en-GB.d.ts +5 -1
  69. package/dist-types/components/input-file/translations/en-PH.d.ts +5 -1
  70. package/dist-types/components/input-file/translations/en-US.d.ts +5 -1
  71. package/dist-types/components/input-file/translations/en.d.ts +5 -1
  72. package/dist-types/components/input-file/translations/nl-BE.d.ts +5 -0
  73. package/dist-types/components/input-file/translations/nl-NL.d.ts +5 -0
  74. package/dist-types/components/input-file/translations/nl.d.ts +5 -0
  75. package/dist-types/components/input-file/translations/ru-RU.d.ts +5 -1
  76. package/dist-types/components/input-file/translations/ru.d.ts +5 -1
  77. package/dist-types/components/input-stepper/src/LionInputStepper.d.ts.map +1 -1
  78. package/dist-types/components/input-tel/src/LionInputTel.d.ts +8 -0
  79. package/dist-types/components/input-tel/src/LionInputTel.d.ts.map +1 -1
  80. package/dist-types/components/input-tel/test-suites/LionInputTel.suite.d.ts.map +1 -1
  81. package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts +0 -10
  82. package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
  83. package/dist-types/components/input-tel-dropdown/src/regionCodeToLocale.d.ts +7 -0
  84. package/dist-types/components/input-tel-dropdown/src/regionCodeToLocale.d.ts.map +1 -0
  85. package/dist-types/components/input-tel-dropdown/test/regionCodeToLocale.test.d.ts +2 -0
  86. package/dist-types/components/input-tel-dropdown/test/regionCodeToLocale.test.d.ts.map +1 -0
  87. package/dist-types/components/input-tel-dropdown/test-suites/LionInputTelDropdown.suite.d.ts.map +1 -1
  88. package/dist-types/components/overlays/translations/tr-TR.d.ts +6 -0
  89. package/dist-types/components/overlays/translations/tr-TR.d.ts.map +1 -0
  90. package/dist-types/components/overlays/translations/tr.d.ts +6 -0
  91. package/dist-types/components/overlays/translations/tr.d.ts.map +1 -0
  92. package/dist-types/components/pagination/src/LionPagination.d.ts.map +1 -1
  93. package/dist-types/components/pagination/translations/tr.d.ts +8 -0
  94. package/dist-types/components/pagination/translations/tr.d.ts.map +1 -0
  95. package/dist-types/components/validate-messages/src/getLocalizedMessage.d.ts.map +1 -1
  96. package/dist-types/components/validate-messages/translations/tr-TR.d.ts +55 -0
  97. package/dist-types/components/validate-messages/translations/tr-TR.d.ts.map +1 -0
  98. package/dist-types/components/validate-messages/translations/tr.d.ts +73 -0
  99. package/dist-types/components/validate-messages/translations/tr.d.ts.map +1 -0
  100. package/dist-types/tsconfig.tsbuildinfo +1 -1
  101. package/docs/components/checkbox-group/api-table.md +3 -3
  102. package/docs/components/checkbox-group/overview.md +2 -2
  103. package/docs/components/collapsible/overview.md +1 -1
  104. package/docs/components/combobox/api-table.md +1 -1
  105. package/docs/components/combobox/overview.md +1 -1
  106. package/docs/components/combobox/use-cases.md +1 -1
  107. package/docs/components/dialog/overview.md +1 -1
  108. package/docs/components/fieldset/api-table.md +1 -1
  109. package/docs/components/fieldset/overview.md +5 -5
  110. package/docs/components/form/overview.md +3 -3
  111. package/docs/components/form/use-cases.md +2 -2
  112. package/docs/components/icon/use-cases.md +1 -1
  113. package/docs/components/input/api-table.md +1 -1
  114. package/docs/components/input/overview.md +1 -1
  115. package/docs/components/input-amount/api-table.md +1 -1
  116. package/docs/components/input-amount/overview.md +3 -3
  117. package/docs/components/input-date/api-table.md +1 -1
  118. package/docs/components/input-date/overview.md +3 -3
  119. package/docs/components/input-datepicker/api-table.md +1 -1
  120. package/docs/components/input-datepicker/overview.md +5 -5
  121. package/docs/components/input-email/api-table.md +1 -1
  122. package/docs/components/input-email/overview.md +2 -2
  123. package/docs/components/input-file/api-table.md +3 -2
  124. package/docs/components/input-file/overview.md +1 -1
  125. package/docs/components/input-iban/api-table.md +1 -1
  126. package/docs/components/input-iban/overview.md +2 -2
  127. package/docs/components/input-range/api-table.md +1 -1
  128. package/docs/components/input-range/overview.md +2 -2
  129. package/docs/components/input-stepper/api-table.md +1 -1
  130. package/docs/components/input-stepper/overview.md +1 -1
  131. package/docs/components/input-stepper/use-cases.md +16 -0
  132. package/docs/components/input-tel/api-table.md +3 -1
  133. package/docs/components/input-tel/overview.md +1 -1
  134. package/docs/components/input-tel/use-cases.md +6 -6
  135. package/docs/components/input-tel-dropdown/api-table.md +3 -3
  136. package/docs/components/input-tel-dropdown/overview.md +1 -1
  137. package/docs/components/listbox/api-table.md +1 -1
  138. package/docs/components/listbox/use-cases.md +1 -1
  139. package/docs/components/radio-group/api-table.md +2 -2
  140. package/docs/components/radio-group/overview.md +3 -3
  141. package/docs/components/select/api-table.md +1 -1
  142. package/docs/components/select/use-cases.md +1 -1
  143. package/docs/components/select-rich/api-table.md +1 -1
  144. package/docs/components/select-rich/use-cases.md +1 -1
  145. package/docs/components/switch/api-table.md +1 -1
  146. package/docs/components/tabs/examples.md +1 -1
  147. package/docs/components/textarea/api-table.md +1 -1
  148. package/docs/fundamentals/index.md +4 -4
  149. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  150. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  151. package/docs/fundamentals/rationales/accessibility.md +1 -1
  152. package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
  153. package/docs/fundamentals/systems/core/overview.md +1 -1
  154. package/docs/fundamentals/systems/form/api-table.md +1 -1
  155. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  156. package/docs/fundamentals/systems/form/model-value.md +1 -1
  157. package/docs/fundamentals/systems/form/overview.md +28 -28
  158. package/docs/fundamentals/systems/form/validate.md +2 -2
  159. package/docs/fundamentals/systems/localize/overview.md +4 -4
  160. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  161. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  162. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  163. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  164. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  165. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  166. package/docs/guides/how-to/create-a-form.md +4 -4
  167. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  168. package/docs/guides/index.md +8 -8
  169. package/docs/guides/principles/index.md +5 -5
  170. package/docs/guides/principles/styling.md +1 -1
  171. package/package.json +1 -1
@@ -4,7 +4,7 @@ export default {
4
4
  allowedFileValidatorComplex:
5
5
  'Nahrajte súbor {allowedTypesArray} alebo {allowedTypesLastItem} s maximálnou veľkosťou {maxSize}.',
6
6
  dragAndDropText: 'Súbory presuňte sem alebo',
7
- fileNameDescriptionLabel: 'Názov súboru: {fileName}',
7
+ fileNameDescriptionLabel: 'Názov súboru: ',
8
8
  generalValidatorMessage: '"{validatorMessage}", pre {listOfErroneousFiles}.',
9
9
  noFilesSelected: 'Neboli vybrané žiadne súbory.',
10
10
  numberOfFiles: 'Počet súborov: {numberOfFiles}.',
@@ -4,7 +4,7 @@ export default {
4
4
  allowedFileValidatorComplex:
5
5
  'Завантажте файл {allowedTypesArray} або {allowedTypesLastItem} розміром до {maxSize}.',
6
6
  dragAndDropText: 'Перетягніть файли сюди або',
7
- fileNameDescriptionLabel: 'Ім’я файлу: {fileName}',
7
+ fileNameDescriptionLabel: 'Ім’я файлу: ',
8
8
  generalValidatorMessage: '"{validatorMessage}", для {listOfErroneousFiles}.',
9
9
  noFilesSelected: 'Не вибрано жодного файлу.',
10
10
  numberOfFiles: '{numberOfFiles} файли(-ів).',
@@ -4,7 +4,7 @@ export default {
4
4
  allowedFileValidatorComplex:
5
5
  '请上传最大 {maxSize} 的 {allowedTypesArray} 或 {allowedTypesLastItem} 文件。',
6
6
  dragAndDropText: '将您的文件拖放到此处,或',
7
- fileNameDescriptionLabel: '文件名: {fileName}',
7
+ fileNameDescriptionLabel: '文件名: ',
8
8
  generalValidatorMessage: '"{validatorMessage}", 例如 {listOfErroneousFiles}。',
9
9
  noFilesSelected: '未选择任何文件。',
10
10
  numberOfFiles: '{numberOfFiles} 个文件。',
@@ -266,7 +266,15 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
266
266
  */
267
267
  __increment() {
268
268
  const { step, min, max } = this.values;
269
- const newValue = this.currentValue + step;
269
+ const stepMin = min !== Infinity ? min : 0;
270
+
271
+ let newValue = this.currentValue + step;
272
+
273
+ if ((this.currentValue + stepMin) % step !== 0) {
274
+ // If the value is not aligned to step, align it to the nearest step
275
+ newValue = Math.floor(this.currentValue / step) * step + step + (stepMin % step);
276
+ }
277
+
270
278
  if (newValue <= max || max === Infinity) {
271
279
  this.modelValue = newValue < min && min !== Infinity ? `${min}` : `${newValue}`;
272
280
  this.__toggleSpinnerButtonsState();
@@ -279,8 +287,16 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
279
287
  * @private
280
288
  */
281
289
  __decrement() {
282
- const { step, min, max } = this.values;
283
- const newValue = this.currentValue - step;
290
+ const { step, max, min } = this.values;
291
+ const stepMin = min !== Infinity ? min : 0;
292
+
293
+ let newValue = this.currentValue - step;
294
+
295
+ if ((this.currentValue + stepMin) % step !== 0) {
296
+ // If the value is not aligned to step, align it to the nearest step
297
+ newValue = Math.floor(this.currentValue / step) * step + (stepMin % step);
298
+ }
299
+
284
300
  if (newValue >= min || min === Infinity) {
285
301
  this.modelValue = newValue > max && max !== Infinity ? `${max}` : `${newValue}`;
286
302
  this.__toggleSpinnerButtonsState();
@@ -265,6 +265,100 @@ describe('<lion-input-stepper>', () => {
265
265
  await nextFrame();
266
266
  expect(incrementButton?.getAttribute('disabled')).to.equal('true');
267
267
  });
268
+
269
+ describe('It align to steps', () => {
270
+ it('aligns the value to the nearest step when incrementing', async () => {
271
+ let el = await fixture(
272
+ html`<lion-input-stepper step="10" min="0" max="100" value="55"></lion-input-stepper>`,
273
+ );
274
+ let incrementButton = el.querySelector('[slot=suffix]');
275
+ incrementButton?.dispatchEvent(new Event('click'));
276
+ await el.updateComplete;
277
+ expect(el.modelValue).to.equal(60, 'Fail + : (0 > 100 by 10; val 55)');
278
+
279
+ // min 1
280
+ el = await fixture(
281
+ html`<lion-input-stepper step="10" min="1" max="100" value="55"></lion-input-stepper>`,
282
+ );
283
+ incrementButton = el.querySelector('[slot=suffix]');
284
+ incrementButton?.dispatchEvent(new Event('click'));
285
+ await el.updateComplete;
286
+ expect(el.modelValue).to.equal(61, 'Fail + : (1 > 100 by 10; val 55)');
287
+
288
+ // min 34
289
+ el = await fixture(
290
+ html`<lion-input-stepper step="10" min="34" max="100" value="55"></lion-input-stepper>`,
291
+ );
292
+ incrementButton = el.querySelector('[slot=suffix]');
293
+ incrementButton?.dispatchEvent(new Event('click'));
294
+ await el.updateComplete;
295
+ expect(el.modelValue).to.equal(64, 'Fail + : (34 > 100 by 10; val 55)');
296
+
297
+ // min -23
298
+ el = await fixture(
299
+ html`<lion-input-stepper step="10" min="-23" max="100" value="55"></lion-input-stepper>`,
300
+ );
301
+ incrementButton = el.querySelector('[slot=suffix]');
302
+ incrementButton?.dispatchEvent(new Event('click'));
303
+ await el.updateComplete;
304
+ expect(el.modelValue).to.equal(57, 'Fail + : (-23 > 100 by 10; val 55)'); // -23 > -13 > -3 > 7 > ... > 57
305
+
306
+ // min -23
307
+ el = await fixture(
308
+ html`<lion-input-stepper step="10" min="-23" max="100" value="-9"></lion-input-stepper>`,
309
+ );
310
+ incrementButton = el.querySelector('[slot=suffix]');
311
+ incrementButton?.dispatchEvent(new Event('click'));
312
+ await el.updateComplete;
313
+ expect(el.modelValue).to.equal(-3, 'Fail + : (-23 > 100 by 10; val 55)'); // -23 > -13 > -3 > 7
314
+ });
315
+
316
+ it('aligns the value to the nearest step when decrementing', async () => {
317
+ let el = await fixture(
318
+ html`<lion-input-stepper step="10" min="0" max="100" value="55"></lion-input-stepper>`,
319
+ );
320
+ let decrementButton = el.querySelector('[slot=prefix]');
321
+ decrementButton?.dispatchEvent(new Event('click'));
322
+ await el.updateComplete;
323
+ expect(el.modelValue).to.equal(50, 'Fail - : (0 > 100 by 10; val 55)');
324
+
325
+ // min 1
326
+ el = await fixture(
327
+ html`<lion-input-stepper step="10" min="1" max="100" value="55"></lion-input-stepper>`,
328
+ );
329
+ decrementButton = el.querySelector('[slot=prefix]');
330
+ decrementButton?.dispatchEvent(new Event('click'));
331
+ await el.updateComplete;
332
+ expect(el.modelValue).to.equal(51, 'Fail - : (1 > 100 by 10; val 55)');
333
+
334
+ // min 34
335
+ el = await fixture(
336
+ html`<lion-input-stepper step="10" min="34" max="100" value="55"></lion-input-stepper>`,
337
+ );
338
+ decrementButton = el.querySelector('[slot=prefix]');
339
+ decrementButton?.dispatchEvent(new Event('click'));
340
+ await el.updateComplete;
341
+ expect(el.modelValue).to.equal(54, 'Fail - : (34 > 100 by 10; val 55)');
342
+
343
+ // min -23
344
+ el = await fixture(
345
+ html`<lion-input-stepper step="10" min="-23" max="100" value="55"></lion-input-stepper>`,
346
+ );
347
+ decrementButton = el.querySelector('[slot=prefix]');
348
+ decrementButton?.dispatchEvent(new Event('click'));
349
+ await el.updateComplete;
350
+ expect(el.modelValue).to.equal(47, 'Fail - : (-23 > 100 by 10; val 55)'); // -23 > -13 > -3 > 7 > ... > 47
351
+
352
+ // min -23
353
+ el = await fixture(
354
+ html`<lion-input-stepper step="10" min="-23" max="100" value="-9"></lion-input-stepper>`,
355
+ );
356
+ decrementButton = el.querySelector('[slot=prefix]');
357
+ decrementButton?.dispatchEvent(new Event('click'));
358
+ await el.updateComplete;
359
+ expect(el.modelValue).to.equal(-13, 'Fail - : (-23 > 100 by 10; val 55)'); // -23 > -13 > -3 > 7
360
+ });
361
+ });
268
362
  });
269
363
 
270
364
  describe('Accessibility', () => {
@@ -27,6 +27,7 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
27
27
  formatStrategy: { type: String, attribute: 'format-strategy' },
28
28
  formatCountryCodeStyle: { type: String, attribute: 'format-country-code-style' },
29
29
  activeRegion: { type: String },
30
+ preferredRegions: { type: Array },
30
31
  _phoneUtil: { type: Object, state: true },
31
32
  };
32
33
 
@@ -156,6 +157,12 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
156
157
  */
157
158
  this.allowedRegions = [];
158
159
 
160
+ /**
161
+ * Regions that will be shown on top of the dropdown
162
+ * @type {RegionCode[]}
163
+ */
164
+ this.preferredRegions = [];
165
+
159
166
  /** @private */
160
167
  this.__isPhoneNumberValidatorInstance = new PhoneNumber();
161
168
  /** @configures ValidateMixin */
@@ -326,13 +333,19 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
326
333
  return;
327
334
  }
328
335
 
329
- // 3. Try to get the region from locale
336
+ // 3. Get the first region in the list of preferred regions
337
+ if (this.preferredRegions?.length > 0) {
338
+ this._setActiveRegion(this.preferredRegions[0]);
339
+ return;
340
+ }
341
+
342
+ // 4. Try to get the region from locale
330
343
  if (this._langIso && this._allowedOrAllRegions.includes(this._langIso)) {
331
344
  this._setActiveRegion(this._langIso);
332
345
  return;
333
346
  }
334
347
 
335
- // 4. Not derivable
348
+ // 5. Not derivable
336
349
  this._setActiveRegion(undefined);
337
350
  }
338
351
  }
@@ -100,6 +100,20 @@ function runActiveRegionTests({ tag, phoneUtilLoadedAfterInit }) {
100
100
  expect(el.activeRegion).to.equal('NL');
101
101
  });
102
102
 
103
+ it('.modelValue takes precedence over .preferredRegions when both preconfigured and .modelValue updated', async () => {
104
+ const el = await fixture(
105
+ html` <${tag} .preferredRegions="${[
106
+ 'DE',
107
+ 'BE',
108
+ ]}" .modelValue="${'+31612345678'}" ></${tag}> `,
109
+ );
110
+ if (resolvePhoneUtilLoaded) {
111
+ resolvePhoneUtilLoaded(undefined);
112
+ await el.updateComplete;
113
+ }
114
+ expect(el.activeRegion).to.equal('NL');
115
+ });
116
+
103
117
  it('deducts it from value when modelValue is unparseable', async () => {
104
118
  const modelValue = new Unparseable('+316');
105
119
  const el = await fixture(html` <${tag} .modelValue=${modelValue}></${tag}> `);
@@ -122,7 +136,18 @@ function runActiveRegionTests({ tag, phoneUtilLoadedAfterInit }) {
122
136
  expect(el.activeRegion).to.equal('NL');
123
137
  });
124
138
 
125
- // 3. **locale**: try to get the region from locale (`html[lang]` attribute)
139
+ // 3. **preferred-region**: get the first element in the preferred regions list
140
+ it('deducts it from the .preferredRegions when provided', async () => {
141
+ const el = await fixture(html` <${tag} .preferredRegions="${['DE', 'NL']}"></${tag}> `);
142
+ if (resolvePhoneUtilLoaded) {
143
+ resolvePhoneUtilLoaded(undefined);
144
+ await el.updateComplete;
145
+ }
146
+ // Region code for country code '+49' is 'DE'
147
+ expect(el.activeRegion).to.equal('DE');
148
+ });
149
+
150
+ // 4. **locale**: try to get the region from locale (`html[lang]` attribute)
126
151
  it('automatically bases it on current locale when nothing preconfigured', async () => {
127
152
  const el = await fixture(html` <${tag}></${tag}> `);
128
153
  if (resolvePhoneUtilLoaded) {
@@ -4,6 +4,7 @@ import { ref, createRef } from 'lit/directives/ref.js';
4
4
  import { LionInputTel } from '@lion/ui/input-tel.js';
5
5
  import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
6
6
  import { getFlagSymbol } from './getFlagSymbol.js';
7
+ import { regionCodeToLocale } from './regionCodeToLocale.js';
7
8
 
8
9
  /**
9
10
  * Note: one could consider to implement LionInputTelDropdown as a
@@ -41,14 +42,6 @@ import { getFlagSymbol } from './getFlagSymbol.js';
41
42
  * `e164` format that contains all info (both region code and national phone number).
42
43
  */
43
44
  export class LionInputTelDropdown extends LionInputTel {
44
- /**
45
- * @configure LitElement
46
- * @type {any}
47
- */
48
- static properties = {
49
- preferredRegions: { type: Array },
50
- };
51
-
52
45
  refs = {
53
46
  /** @type {DropdownRef} */
54
47
  dropdown: /** @type {DropdownRef} */ (createRef()),
@@ -193,8 +186,7 @@ export class LionInputTelDropdown extends LionInputTel {
193
186
  onLocaleUpdated() {
194
187
  super.onLocaleUpdated();
195
188
 
196
- // @ts-expect-error relatively new platform api
197
- this.__namesForLocale = new Intl.DisplayNames([this._langIso], {
189
+ this.__namesForLocale = new Intl.DisplayNames([this._localizeManager.locale], {
198
190
  type: 'region',
199
191
  });
200
192
  this.__createRegionMeta();
@@ -214,11 +206,6 @@ export class LionInputTelDropdown extends LionInputTel {
214
206
  constructor() {
215
207
  super();
216
208
 
217
- /**
218
- * Regions that will be shown on top of the dropdown
219
- * @type {string[]}
220
- */
221
- this.preferredRegions = [];
222
209
  /**
223
210
  * Group label for all countries, when preferredCountries are shown
224
211
  * @protected
@@ -408,7 +395,7 @@ export class LionInputTelDropdown extends LionInputTel {
408
395
  this.__regionMetaListPreferred = [];
409
396
  this._allowedOrAllRegions.forEach(regionCode => {
410
397
  // @ts-ignore relatively new platform api
411
- const namesForRegion = new Intl.DisplayNames([regionCode.toLowerCase()], {
398
+ const namesForRegion = new Intl.DisplayNames([regionCodeToLocale(regionCode)], {
412
399
  type: 'region',
413
400
  });
414
401
  const countryCode =
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get the full locale for a region.
3
+ * As we don't know the language for that region, we first set it as 'und', which stands for 'undetermined'.
4
+ * @param {string} regionCode
5
+ */
6
+ export function regionCodeToLocale(regionCode) {
7
+ const locale = new Intl.Locale('und', { region: regionCode }); // Set language as undetermined.
8
+ const maximizedLocale = locale.maximize(); // Determine the most likely full locale for a region with an undetermined language.
9
+ return maximizedLocale.baseName;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { expect } from '@open-wc/testing';
2
+ import { regionCodeToLocale } from '../src/regionCodeToLocale.js';
3
+
4
+ describe('regionCodeToLocale', () => {
5
+ it('returns the most likely locale basename for a region', () => {
6
+ expect(regionCodeToLocale('NL')).to.equal('nl-Latn-NL');
7
+ expect(regionCodeToLocale('FR')).to.equal('fr-Latn-FR');
8
+ expect(regionCodeToLocale('DE')).to.equal('de-Latn-DE');
9
+ });
10
+ });
@@ -133,7 +133,7 @@ export function runInputTelDropdownSuite({ klass } = { klass: LionInputTelDropdo
133
133
  countryCode: 63,
134
134
  flagSymbol: '🇵🇭',
135
135
  nameForLocale: 'Philippines',
136
- nameForRegion: 'Philippines',
136
+ nameForRegion: 'Pilipinas',
137
137
  regionCode: 'PH',
138
138
  },
139
139
  ],
@@ -239,6 +239,74 @@ export function runInputTelDropdownSuite({ klass } = { klass: LionInputTelDropdo
239
239
  restorePhoneUtilManager();
240
240
  spy.restore();
241
241
  });
242
+
243
+ it('has the correct nameForLocale, based on browser language', async () => {
244
+ const el = fixtureSync(html` <${tag}
245
+ .modelValue="${'+31612345678'}"
246
+ .allowedRegions="${['NL', 'PH']}"
247
+ .preferredRegions="${['PH']}"
248
+ ></${tag}> `);
249
+ const spy = sinon.spy(
250
+ /** @type {typeof LionInputTelDropdown} */ (el.constructor).templates,
251
+ 'dropdown',
252
+ );
253
+ // @ts-ignore
254
+ const originalLocale = el._localizeManager.locale;
255
+ // @ts-ignore
256
+ el._localizeManager.locale = 'fr-BE';
257
+ await el.updateComplete;
258
+ const dropdownNode = el.refs.dropdown.value;
259
+ const templateDataForDropdown = /** @type {TemplateDataForDropdownInputTel} */ (
260
+ spy.args[0][0]
261
+ );
262
+ expect(templateDataForDropdown).to.eql(
263
+ /** @type {TemplateDataForDropdownInputTel} */ ({
264
+ data: {
265
+ activeRegion: 'NL',
266
+ regionMetaList: [
267
+ {
268
+ countryCode: 31,
269
+ flagSymbol: '🇳🇱',
270
+ nameForLocale: 'Pays-Bas',
271
+ nameForRegion: 'Nederland',
272
+ regionCode: 'NL',
273
+ },
274
+ ],
275
+ regionMetaListPreferred: [
276
+ {
277
+ countryCode: 63,
278
+ flagSymbol: '🇵🇭',
279
+ nameForLocale: 'Philippines',
280
+ nameForRegion: 'Pilipinas',
281
+ regionCode: 'PH',
282
+ },
283
+ ],
284
+ },
285
+ refs: {
286
+ dropdown: {
287
+ labels: {
288
+ allCountries: 'Tous les pays',
289
+ preferredCountries: 'Pays suggérés',
290
+ selectCountry: 'Sélectionnez un pays',
291
+ },
292
+ listeners: {
293
+ // @ts-expect-error [allow-protected]
294
+ change: el._onDropdownValueChange,
295
+ // @ts-expect-error [allow-protected]
296
+ 'model-value-changed': el._onDropdownValueChange,
297
+ },
298
+ props: { style: 'height: 100%;' },
299
+ ref: { value: dropdownNode },
300
+ },
301
+ // @ts-expect-error [allow-protected]
302
+ input: el._inputNode,
303
+ },
304
+ }),
305
+ );
306
+ spy.restore();
307
+ // @ts-ignore
308
+ el._localizeManager.locale = originalLocale; // restore the locale back to original
309
+ });
242
310
  });
243
311
 
244
312
  describe('On dropdown value change', () => {
@@ -0,0 +1,5 @@
1
+ import tr from './tr.js';
2
+
3
+ export default {
4
+ ...tr,
5
+ };
@@ -0,0 +1,4 @@
1
+ export default {
2
+ back: 'Geri',
3
+ close: 'Kapat',
4
+ };
@@ -73,6 +73,8 @@ export class LionPagination extends LocalizeMixin(LitElement) {
73
73
  return import('@lion/ui/pagination-translations/ru.js');
74
74
  case 'sk-SK':
75
75
  return import('@lion/ui/pagination-translations/sk.js');
76
+ case 'tr-TR':
77
+ return import('@lion/ui/pagination-translations/tr.js');
76
78
  case 'uk-UA':
77
79
  return import('@lion/ui/pagination-translations/uk.js');
78
80
  case 'zh-CN':
@@ -0,0 +1,6 @@
1
+ export default {
2
+ label: 'Sayfa gezintisi',
3
+ previous: 'Önceki sayfa',
4
+ next: 'Sonraki sayfa',
5
+ page: '{page}. sayfa',
6
+ };
@@ -85,6 +85,10 @@ export async function loadValidateNamespace({ localize }) {
85
85
  return import('@lion/ui/validate-messages-translations/sk-SK.js');
86
86
  case 'sk':
87
87
  return import('@lion/ui/validate-messages-translations/sk.js');
88
+ case 'tr-TR':
89
+ return import('@lion/ui/validate-messages-translations/tr-TR.js');
90
+ case 'tr':
91
+ return import('@lion/ui/validate-messages-translations/tr.js');
88
92
  case 'uk-UA':
89
93
  return import('@lion/ui/validate-messages-translations/uk-UA.js');
90
94
  case 'uk':
@@ -0,0 +1,13 @@
1
+ import tr from './tr.js';
2
+
3
+ export default {
4
+ ...tr,
5
+ error: {
6
+ ...tr.error,
7
+ IsDate: 'Lütfen geçerli bir tarih girin (GG/AA/YYYY).',
8
+ },
9
+ warning: {
10
+ ...tr.warning,
11
+ IsDate: 'Lütfen geçerli bir tarih girin (GG/AA/YYYY).',
12
+ },
13
+ };
@@ -0,0 +1,56 @@
1
+ export default {
2
+ error: {
3
+ Required: '{fieldName} alanını doldurun.',
4
+ _RequiredUpload: '{fieldName} dosyasını yükleyin.',
5
+ _RequiredSelect: '{fieldName} seçin.',
6
+ EqualsLength: '{fieldName} alanı tam olarak {params} karakter olmalıdır.',
7
+ MinLength: '{fieldName} alanı en az {params} karakter olmalıdır.',
8
+ MaxLength: '{fieldName} alanı en fazla {params} karakter olmalıdır.',
9
+ MinMaxLength: '{fieldName} alanı {params.min} ile {params.max} karakter arasında olmalıdır.',
10
+ Pattern: 'Geçerli bir {fieldName} girin.',
11
+ IsNumber: 'Geçerli bir {fieldName} girin.',
12
+ MinNumber: '{fieldName}, {params} veya daha büyük olmalıdır.',
13
+ MaxNumber: '{fieldName}, {params} veya daha küçük olmalıdır.',
14
+ MinMaxNumber: '{fieldName}, {params.min} ile {params.max} arasında olmalıdır.',
15
+ IsDate: 'Geçerli bir tarih girin (GG/AA/YYYY).',
16
+ MinDate: '{fieldName}, {params, date, YYYYMMDD} veya daha sonraki bir tarih olmalıdır.',
17
+ MaxDate: '{fieldName}, {params, date, YYYYMMDD} veya daha önceki bir tarih olmalıdır.',
18
+ MinMaxDate:
19
+ '{fieldName}, {params.min, date, YYYYMMDD} ile {params.max, date, YYYYMMDD} arasında olmalıdır.',
20
+ IsDateDisabled: 'Bu tarih kullanılamaz. Lütfen başka bir tarih seçin.',
21
+ IsEmail: 'Geçerli bir {fieldName} girin ("ad@örnek.com" formatında).',
22
+ MatchesOption: 'Eşleşen sonuç bulunamadı. Farklı bir anahtar kelime ya da kategori deneyin.',
23
+ },
24
+ warning: {
25
+ Required: '{fieldName} alanını doldurun.',
26
+ _RequiredUpload: '{fieldName} dosyasını yükleyin.',
27
+ _RequiredSelect: '{fieldName} seçin.',
28
+ EqualsLength: '{fieldName} alanı tam olarak {params} karakter olmalıdır.',
29
+ MinLength: '{fieldName} alanı en az {params} karakter olmalıdır.',
30
+ MaxLength: '{fieldName} alanı en fazla {params} karakter olmalıdır.',
31
+ MinMaxLength: '{fieldName} alanı {params.min} ile {params.max} karakter arasında olmalıdır.',
32
+ IsNumber: 'Geçerli bir {fieldName} girin.',
33
+ MinNumber: '{fieldName}, {params} veya daha büyük olmalıdır.',
34
+ MaxNumber: '{fieldName}, {params} veya daha küçük olmalıdır.',
35
+ MinMaxNumber: '{fieldName}, {params.min} ile {params.max} arasında olmalıdır.',
36
+ IsDate: 'Geçerli bir tarih girin (GG/AA/YYYY).',
37
+ MinDate: '{fieldName}, {params, date, YYYYMMDD} veya daha sonraki bir tarih olmalıdır.',
38
+ MaxDate: '{fieldName}, {params, date, YYYYMMDD} veya daha önceki bir tarih olmalıdır.',
39
+ MinMaxDate:
40
+ '{fieldName}, {params.min, date, YYYYMMDD} ile {params.max, date, YYYYMMDD} arasında olmalıdır.',
41
+ IsDateDisabled: 'Bu tarih kullanılamaz. Lütfen başka bir tarih seçin.',
42
+ IsEmail: 'Geçerli bir {fieldName} girin ("ad@örnek.com" formatında).',
43
+ MatchesOption: 'Eşleşen sonuç bulunamadı. Farklı bir anahtar kelime ya da kategori deneyin.',
44
+ },
45
+ success: {
46
+ DefaultOk: 'Tamam',
47
+ RandomOk:
48
+ 'success.DefaultOk,success.Correct,success.Succeeded,success.Ok,success.ThisIsRight,success.Changed,success.OkCorrect',
49
+ Correct: 'Doğru',
50
+ Succeeded: 'Başarılı',
51
+ Ok: 'Tamam!',
52
+ ThisIsRight: 'Bu doğru.',
53
+ Changed: 'Değiştirildi!',
54
+ OkCorrect: 'Tamam, doğru.',
55
+ },
56
+ };