@lion/ui 0.1.0 → 0.1.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.
Files changed (158) hide show
  1. package/components/calendar/src/LionCalendar.js +2 -3
  2. package/components/calendar/test/lion-calendar.test.js +5 -3
  3. package/components/form-core/src/validate/ValidateMixin.js +7 -3
  4. package/components/form-core/src/validate/validators/DateValidators.js +1 -1
  5. package/components/form-core/test/lion-field.test.js +4 -2
  6. package/components/form-core/test/validate/DateValidators.test.js +1 -1
  7. package/components/form-core/test-suites/FormatMixin.suite.js +1 -1
  8. package/components/form-core/test-suites/ValidateMixinFeedbackPart.suite.js +6 -4
  9. package/components/form-integrations/test/form-group-methods.test.js +3 -3
  10. package/components/form-integrations/test/form-integrations.test.js +3 -3
  11. package/components/form-integrations/test/form-validation-integrations.test.js +11 -10
  12. package/components/form-integrations/test/helpers/umbrella-form.js +3 -3
  13. package/components/input-amount/src/LionInputAmount.js +2 -2
  14. package/components/input-amount/src/formatters.js +5 -1
  15. package/components/input-amount/src/parsers.js +1 -1
  16. package/components/input-amount/test/formatters.test.js +5 -3
  17. package/components/input-date/src/LionInputDate.js +1 -1
  18. package/components/input-date/test/lion-input-date.test.js +91 -43
  19. package/components/input-datepicker/src/LionInputDatepicker.js +1 -1
  20. package/components/input-email/src/LionInputEmail.js +1 -1
  21. package/components/input-iban/src/LionInputIban.js +1 -1
  22. package/components/input-iban/src/validators.js +14 -8
  23. package/components/input-range/src/LionInputRange.js +1 -1
  24. package/components/input-tel/src/LionInputTel.js +3 -3
  25. package/components/input-tel/test-suites/LionInputTel.suite.js +3 -2
  26. package/components/input-tel-dropdown/src/LionInputTelDropdown.js +7 -4
  27. package/components/localize/src/LocalizeManager.js +19 -3
  28. package/components/localize/src/LocalizeMixin.js +24 -9
  29. package/components/localize/src/date/formatDate.js +4 -3
  30. package/components/localize/src/date/parseDate.js +5 -3
  31. package/components/localize/src/getLocalizeManager.js +74 -0
  32. package/components/localize/src/number/formatNumber.js +5 -4
  33. package/components/localize/src/number/getCurrencyName.js +3 -2
  34. package/components/localize/src/number/parseNumber.js +3 -2
  35. package/components/localize/src/number/utils/emptyStringWhenNumberNan.js +3 -2
  36. package/components/localize/src/singleton.js +6 -9
  37. package/components/localize/src/utils/getLocale.js +3 -8
  38. package/components/localize/test/LocalizeManager.test.js +19 -2
  39. package/components/localize/test/LocalizeMixin.test.js +17 -15
  40. package/components/localize/test/date/formatDate.test.js +25 -24
  41. package/components/localize/test/date/getDateFormatBasedOnLocale.test.js +8 -3
  42. package/components/localize/test/date/parseDate.test.js +22 -7
  43. package/components/localize/test/getLocalizeManager.test.js +31 -0
  44. package/components/localize/test/localize.test.js +5 -4
  45. package/components/localize/test/number/formatNumber.test.js +31 -29
  46. package/components/localize/test/number/formatNumberToParts.test.js +5 -3
  47. package/components/localize/test/number/getCurrencyName.test.js +1 -1
  48. package/components/localize/test/number/parseNumber.test.js +37 -19
  49. package/components/localize/test/side-effect-free-entrypoint.test.js +38 -0
  50. package/components/localize/test-helpers/localizeTearDown.js +5 -4
  51. package/components/localize/types/LocalizeMixinTypes.ts +8 -1
  52. package/components/pagination/src/LionPagination.js +1 -1
  53. package/components/progress-indicator/src/LionProgressIndicator.js +3 -2
  54. package/components/select/src/LionSelect.js +15 -0
  55. package/components/select/test/lion-select.test.js +25 -0
  56. package/components/select-rich/src/LionSelectRich.js +6 -0
  57. package/components/select-rich/test/lion-select-rich.test.js +33 -0
  58. package/components/validate-messages/src/loadDefaultFeedbackMessages.js +2 -2
  59. package/components/validate-messages/test/loadDefaultFeedbackMessagesNoSideEffects.js +6 -4
  60. package/custom-elements.json +740 -15
  61. package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
  62. package/dist-types/components/form-core/src/validate/ValidateMixin.d.ts.map +1 -1
  63. package/dist-types/components/form-core/test-suites/ValidateMixinFeedbackPart.suite.d.ts.map +1 -1
  64. package/dist-types/components/input-amount/src/formatters.d.ts.map +1 -1
  65. package/dist-types/components/input-date/src/LionInputDate.d.ts +1 -1
  66. package/dist-types/components/input-iban/src/validators.d.ts.map +1 -1
  67. package/dist-types/components/input-tel/test-suites/LionInputTel.suite.d.ts.map +1 -1
  68. package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
  69. package/dist-types/components/localize/src/LocalizeManager.d.ts +6 -2
  70. package/dist-types/components/localize/src/LocalizeManager.d.ts.map +1 -1
  71. package/dist-types/components/localize/src/LocalizeMixin.d.ts.map +1 -1
  72. package/dist-types/components/localize/src/date/formatDate.d.ts.map +1 -1
  73. package/dist-types/components/localize/src/date/parseDate.d.ts.map +1 -1
  74. package/dist-types/components/localize/src/getLocalizeManager.d.ts +60 -0
  75. package/dist-types/components/localize/src/getLocalizeManager.d.ts.map +1 -0
  76. package/dist-types/components/localize/src/number/formatNumber.d.ts.map +1 -1
  77. package/dist-types/components/localize/src/number/getCurrencyName.d.ts.map +1 -1
  78. package/dist-types/components/localize/src/number/parseNumber.d.ts.map +1 -1
  79. package/dist-types/components/localize/src/number/utils/emptyStringWhenNumberNan.d.ts.map +1 -1
  80. package/dist-types/components/localize/src/singleton.d.ts +5 -3
  81. package/dist-types/components/localize/src/singleton.d.ts.map +1 -1
  82. package/dist-types/components/localize/src/utils/getLocale.d.ts.map +1 -1
  83. package/dist-types/components/localize/test/getLocalizeManager.test.d.ts +2 -0
  84. package/dist-types/components/localize/test/getLocalizeManager.test.d.ts.map +1 -0
  85. package/dist-types/components/localize/test/side-effect-free-entrypoint.test.d.ts +2 -0
  86. package/dist-types/components/localize/test/side-effect-free-entrypoint.test.d.ts.map +1 -0
  87. package/dist-types/components/localize/test-helpers/localizeTearDown.d.ts.map +1 -1
  88. package/dist-types/components/localize/types/LocalizeMixinTypes.d.ts +2 -0
  89. package/dist-types/components/localize/types/LocalizeMixinTypes.d.ts.map +1 -1
  90. package/dist-types/components/progress-indicator/src/LionProgressIndicator.d.ts.map +1 -1
  91. package/dist-types/components/select/src/LionSelect.d.ts +1 -0
  92. package/dist-types/components/select/src/LionSelect.d.ts.map +1 -1
  93. package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
  94. package/dist-types/exports/localize-no-side-effects.d.ts +18 -0
  95. package/dist-types/exports/types/core.d.ts +3 -0
  96. package/dist-types/exports/types/core.d.ts.map +1 -1
  97. package/dist-types/exports/types/form-core.d.ts +16 -0
  98. package/dist-types/exports/types/form-core.d.ts.map +1 -1
  99. package/dist-types/exports/types/localize.d.ts +1 -0
  100. package/dist-types/exports/types/localize.d.ts.map +1 -1
  101. package/dist-types/exports/types/overlays.d.ts +1 -0
  102. package/dist-types/exports/types/overlays.d.ts.map +1 -1
  103. package/dist-types/tsconfig.tsbuildinfo +1 -1
  104. package/docs/components/checkbox-group/overview.md +2 -2
  105. package/docs/components/collapsible/overview.md +1 -1
  106. package/docs/components/combobox/overview.md +1 -1
  107. package/docs/components/combobox/use-cases.md +1 -1
  108. package/docs/components/dialog/overview.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/overview.md +1 -1
  114. package/docs/components/input-amount/overview.md +3 -3
  115. package/docs/components/input-date/overview.md +3 -3
  116. package/docs/components/input-datepicker/overview.md +5 -5
  117. package/docs/components/input-email/overview.md +2 -2
  118. package/docs/components/input-iban/overview.md +2 -2
  119. package/docs/components/input-range/overview.md +2 -2
  120. package/docs/components/input-stepper/overview.md +1 -1
  121. package/docs/components/input-tel/overview.md +1 -1
  122. package/docs/components/input-tel/use-cases.md +6 -6
  123. package/docs/components/input-tel-dropdown/overview.md +1 -1
  124. package/docs/components/radio-group/overview.md +3 -3
  125. package/docs/components/select-rich/use-cases.md +1 -1
  126. package/docs/components/tabs/examples.md +1 -1
  127. package/docs/fundamentals/index.md +4 -4
  128. package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
  129. package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
  130. package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
  131. package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
  132. package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
  133. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  134. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  135. package/docs/fundamentals/systems/core/overview.md +1 -1
  136. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  137. package/docs/fundamentals/systems/form/model-value.md +1 -1
  138. package/docs/fundamentals/systems/form/overview.md +28 -28
  139. package/docs/fundamentals/systems/form/use-cases.md +3 -3
  140. package/docs/fundamentals/systems/form/validate.md +1 -1
  141. package/docs/fundamentals/systems/localize/overview.md +4 -4
  142. package/docs/fundamentals/systems/overlays/assets/umbrella-form.js +3 -3
  143. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  144. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  145. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  146. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  147. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  148. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  149. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  150. package/docs/guides/index.md +8 -8
  151. package/docs/guides/principles/index.md +5 -5
  152. package/docs/guides/principles/styling.md +1 -1
  153. package/exports/localize-no-side-effects.js +19 -0
  154. package/exports/types/core.ts +3 -0
  155. package/exports/types/form-core.ts +16 -0
  156. package/exports/types/localize.ts +1 -0
  157. package/exports/types/overlays.ts +1 -0
  158. package/package.json +1 -1
@@ -3,10 +3,9 @@ import { html, LitElement } from 'lit';
3
3
  import {
4
4
  getMonthNames,
5
5
  getWeekdayNames,
6
- localize,
7
6
  LocalizeMixin,
8
7
  normalizeDateTime,
9
- } from '@lion/ui/localize.js';
8
+ } from '@lion/ui/localize-no-side-effects.js';
10
9
 
11
10
  import { calendarStyle } from './calendarStyle.js';
12
11
  import { createDay } from './utils/createDay.js';
@@ -862,6 +861,6 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
862
861
  * @private
863
862
  */
864
863
  __getLocale() {
865
- return this.locale || localize.locale;
864
+ return this.locale || this._localizeManager.locale;
866
865
  }
867
866
  }
@@ -1,5 +1,5 @@
1
1
  import { html } from 'lit';
2
- import { localize } from '@lion/ui/localize.js';
2
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
3
3
  import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
4
4
  import { expect, fixture as _fixture } from '@open-wc/testing';
5
5
  import sinon from 'sinon';
@@ -15,6 +15,8 @@ import { CalendarObject, DayObject } from '@lion/ui/calendar-test-helpers.js';
15
15
  const fixture = /** @type {(arg: TemplateResult) => Promise<LionCalendar>} */ (_fixture);
16
16
 
17
17
  describe('<lion-calendar>', () => {
18
+ const localizeManager = getLocalizeManager();
19
+
18
20
  beforeEach(() => {
19
21
  localizeTearDown();
20
22
  });
@@ -1348,7 +1350,7 @@ describe('<lion-calendar>', () => {
1348
1350
  await el.updateComplete;
1349
1351
  expect(elObj.activeMonth).to.equal('décembre');
1350
1352
 
1351
- localize.locale = 'cs-CZ';
1353
+ localizeManager.locale = 'cs-CZ';
1352
1354
  await el.updateComplete;
1353
1355
  expect(elObj.activeMonth).to.equal('décembre');
1354
1356
 
@@ -1391,7 +1393,7 @@ describe('<lion-calendar>', () => {
1391
1393
  'Sat',
1392
1394
  ]);
1393
1395
 
1394
- localize.locale = 'nl-NL';
1396
+ localizeManager.locale = 'nl-NL';
1395
1397
  await el.localizeNamespacesLoaded;
1396
1398
  await el.updateComplete;
1397
1399
  expect(elObj.nextMonthButtonEl?.getAttribute('aria-label')).to.equal(
@@ -3,7 +3,7 @@ import { SlotMixin, DisabledMixin } from '@lion/ui/core.js';
3
3
  import { ScopedElementsMixin } from '@open-wc/scoped-elements';
4
4
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
5
5
  // TODO: make form-core independent from localize
6
- import { localize } from '@lion/ui/localize.js';
6
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
7
7
  import { AsyncQueue } from '../utils/AsyncQueue.js';
8
8
  import { pascalCase } from '../utils/pascalCase.js';
9
9
  import { SyncUpdatableMixin } from '../utils/SyncUpdatableMixin.js';
@@ -262,12 +262,16 @@ export const ValidateMixinImplementation = superclass =>
262
262
 
263
263
  connectedCallback() {
264
264
  super.connectedCallback();
265
- localize.addEventListener('localeChanged', this._updateFeedbackComponent);
265
+
266
+ const localizeManager = getLocalizeManager();
267
+ localizeManager.addEventListener('localeChanged', this._updateFeedbackComponent);
266
268
  }
267
269
 
268
270
  disconnectedCallback() {
269
271
  super.disconnectedCallback();
270
- localize.removeEventListener('localeChanged', this._updateFeedbackComponent);
272
+
273
+ const localizeManager = getLocalizeManager();
274
+ localizeManager.removeEventListener('localeChanged', this._updateFeedbackComponent);
271
275
  }
272
276
 
273
277
  /**
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable max-classes-per-file */
2
2
  // TODO: move to input-datepicker?
3
- import { normalizeDateTime } from '@lion/ui/localize.js';
3
+ import { normalizeDateTime } from '@lion/ui/localize-no-side-effects.js';
4
4
  import { Validator } from '../Validator.js';
5
5
 
6
6
  /**
@@ -2,7 +2,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
2
2
  import { Required, Validator } from '@lion/ui/form-core.js';
3
3
  import '@lion/ui/define/lion-field.js';
4
4
  import { getFormControlMembers } from '@lion/ui/form-core-test-helpers.js';
5
- import { localize } from '@lion/ui/localize.js';
5
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
6
6
  import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
7
7
  import {
8
8
  expect,
@@ -52,6 +52,8 @@ function getSlot(el, slot) {
52
52
  }
53
53
 
54
54
  describe('<lion-field>', () => {
55
+ const localizeManager = getLocalizeManager();
56
+
55
57
  it(`puts a unique id "${tagString}-[hash]" on the native input`, async () => {
56
58
  const el = /** @type {LionField} */ (await fixture(html`<${tag}>${inputSlot}</${tag}>`));
57
59
  // @ts-ignore allow protected accessors in tests
@@ -219,7 +221,7 @@ describe('<lion-field>', () => {
219
221
  beforeEach(() => {
220
222
  // Reset and preload validation translations
221
223
  localizeTearDown();
222
- localize.addData('en-GB', 'lion-validate', {
224
+ localizeManager.addData('en-GB', 'lion-validate', {
223
225
  error: {
224
226
  hasX: 'This is error message for hasX',
225
227
  },
@@ -1,6 +1,6 @@
1
1
  import { expect } from '@open-wc/testing';
2
2
 
3
- import { normalizeDateTime } from '@lion/ui/localize.js';
3
+ import { normalizeDateTime } from '@lion/ui/localize-no-side-effects.js';
4
4
  import { IsDate, MinDate, MaxDate, MinMaxDate, IsDateDisabled } from '@lion/ui/form-core.js';
5
5
 
6
6
  describe('Date Validation', () => {
@@ -1,5 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
- import { parseDate } from '@lion/ui/localize.js';
2
+ import { parseDate } from '@lion/ui/localize-no-side-effects.js';
3
3
  import { aTimeout, defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
4
4
  import sinon from 'sinon';
5
5
  import { Unparseable, Validator, FormatMixin } from '@lion/ui/form-core.js';
@@ -1,5 +1,5 @@
1
1
  import { LitElement } from 'lit';
2
- import { localize } from '@lion/ui/localize.js';
2
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
3
3
  import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
4
4
  import { defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
5
5
  import { getFormControlMembers, AlwaysInvalid } from '@lion/ui/form-core-test-helpers.js';
@@ -18,6 +18,8 @@ import {
18
18
  */
19
19
 
20
20
  export function runValidateMixinFeedbackPart() {
21
+ const localizeManager = getLocalizeManager();
22
+
21
23
  describe('Validity Feedback', () => {
22
24
  beforeEach(() => {
23
25
  localizeTearDown();
@@ -65,7 +67,7 @@ export function runValidateMixinFeedbackPart() {
65
67
 
66
68
  AlwaysInvalid.getMessage = async () => 'Message for AlwaysInvalid';
67
69
  MinLength.getMessage = async () =>
68
- localize.locale === 'de-DE' ? 'Nachricht für MinLength' : 'Message for MinLength';
70
+ localizeManager.locale === 'de-DE' ? 'Nachricht für MinLength' : 'Message for MinLength';
69
71
  ContainsLowercaseA.getMessage = async () => 'Message for ContainsLowercaseA';
70
72
  ContainsCat.getMessage = async () => 'Message for ContainsCat';
71
73
 
@@ -341,8 +343,8 @@ export function runValidateMixinFeedbackPart() {
341
343
  expect(_feedbackNode.feedbackData?.length).to.equal(1);
342
344
  expect(_feedbackNode.feedbackData?.[0].message).to.equal('Message for MinLength');
343
345
 
344
- localize.locale = 'de-DE';
345
- await localize.loadingComplete;
346
+ localizeManager.locale = 'de-DE';
347
+ await localizeManager.loadingComplete;
346
348
  await el.feedbackComplete;
347
349
  expect(_feedbackNode.feedbackData?.[0].message).to.equal('Nachricht für MinLength');
348
350
  });
@@ -45,7 +45,7 @@ import '@lion/ui/define/lion-validation-feedback.js';
45
45
  */
46
46
 
47
47
  const fullyPrefilledSerializedValue = {
48
- full_name: { first_name: 'Lorem', last_name: 'Ipsum' },
48
+ fullName: { firstName: 'Lorem', lastName: 'Ipsum' },
49
49
  date: '2000-12-12',
50
50
  datepicker: '2020-12-12',
51
51
  bio: 'Lorem',
@@ -69,7 +69,7 @@ const fullyPrefilledSerializedValue = {
69
69
  };
70
70
 
71
71
  const fullyChangedSerializedValue = {
72
- full_name: { first_name: 'LoremChanged', last_name: 'IpsumChanged' },
72
+ fullName: { firstName: 'LoremChanged', lastName: 'IpsumChanged' },
73
73
  date: '1999-12-12',
74
74
  datepicker: '1986-12-12',
75
75
  bio: 'LoremChanged',
@@ -177,7 +177,7 @@ describe(`Submitting/Resetting/Clearing Form`, async () => {
177
177
  await elementUpdated(formEl);
178
178
  await formEl.updateComplete;
179
179
  expect(formEl.serializedValue).to.eql({
180
- full_name: { first_name: '', last_name: '' },
180
+ fullName: { firstName: '', lastName: '' },
181
181
  date: '',
182
182
  datepicker: '',
183
183
  bio: '',
@@ -29,7 +29,7 @@ describe('Form Integrations', () => {
29
29
  const formEl = el._lionFormNode;
30
30
 
31
31
  expect(formEl.serializedValue).to.eql({
32
- full_name: { first_name: '', last_name: '' },
32
+ fullName: { firstName: '', lastName: '' },
33
33
  date: '2000-12-12',
34
34
  datepicker: '2020-12-12',
35
35
  bio: '',
@@ -62,7 +62,7 @@ describe('Form Integrations', () => {
62
62
  await inputTelDropdownEl?.updateComplete;
63
63
 
64
64
  expect(formEl.formattedValue).to.eql({
65
- full_name: { first_name: '', last_name: '' },
65
+ fullName: { firstName: '', lastName: '' },
66
66
  date: '12/12/2000',
67
67
  datepicker: '12/12/2020',
68
68
  bio: '',
@@ -91,7 +91,7 @@ describe('Form Integrations', () => {
91
91
  await fixture(
92
92
  html`<umbrella-form
93
93
  .serializedValue="${{
94
- full_name: { first_name: '', last_name: '' },
94
+ fullName: { firstName: '', lastName: '' },
95
95
  date: '2000-12-12',
96
96
  datepicker: '2020-12-12',
97
97
  bio: '',
@@ -1,12 +1,13 @@
1
1
  import { DefaultSuccess, Required, Validator } from '@lion/ui/form-core.js';
2
2
  import { getFormControlMembers } from '@lion/ui/form-core-test-helpers.js';
3
3
  import { LionInput } from '@lion/ui/input.js';
4
- import { localize } from '@lion/ui/localize.js';
4
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
5
5
  import { loadDefaultFeedbackMessages } from '@lion/ui/validate-messages.js';
6
6
  import { defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
7
7
  import sinon from 'sinon';
8
8
 
9
9
  describe('Form Validation Integrations', () => {
10
+ const localizeManager = getLocalizeManager();
10
11
  const lightDom = '';
11
12
  before(() => {
12
13
  loadDefaultFeedbackMessages();
@@ -126,11 +127,11 @@ describe('Form Validation Integrations', () => {
126
127
  }
127
128
 
128
129
  async updateLabel() {
129
- this.label = localize.msg('test-default-label:label');
130
+ this.label = localizeManager.msg('test-default-label:label');
130
131
  }
131
132
 
132
133
  async setDefaultLabel() {
133
- localize.loadNamespace({
134
+ localizeManager.loadNamespace({
134
135
  'test-default-label': /** @param {string} locale */ async locale => {
135
136
  switch (locale) {
136
137
  case 'nl-NL':
@@ -143,11 +144,11 @@ describe('Form Validation Integrations', () => {
143
144
  this.boundUpdateLabel = this.updateLabel.bind(this);
144
145
 
145
146
  // localeChanged is fired AFTER localize has finished loading missing translations
146
- // so no need to await localize.loadingComplete
147
- localize.addEventListener('localeChanged', this.boundUpdateLabel);
147
+ // so no need to await localizeManager.loadingComplete
148
+ localizeManager.addEventListener('localeChanged', this.boundUpdateLabel);
148
149
 
149
150
  // Wait for it to complete when updating the label for the first time
150
- await localize.loadingComplete;
151
+ await localizeManager.loadingComplete;
151
152
  this.boundUpdateLabel();
152
153
  }
153
154
  }
@@ -167,15 +168,15 @@ describe('Form Validation Integrations', () => {
167
168
  const { _feedbackNode } = getFormControlMembers(el);
168
169
  expect(_feedbackNode.feedbackData?.[0].message).to.equal('Please enter a(n) Text.');
169
170
 
170
- localize.locale = 'nl-NL';
171
- await localize.loadingComplete;
171
+ localizeManager.locale = 'nl-NL';
172
+ await localizeManager.loadingComplete;
172
173
  await el.updateComplete;
173
174
  await el.feedbackComplete;
174
175
  expect(el.label).to.equal('Tekst');
175
176
  expect(_feedbackNode.feedbackData?.[0].message).to.equal('Vul een Tekst in.');
176
177
 
177
- localize.locale = 'en-GB';
178
- await localize.loadingComplete;
178
+ localizeManager.locale = 'en-GB';
179
+ await localizeManager.loadingComplete;
179
180
  await el.updateComplete;
180
181
  await el.feedbackComplete;
181
182
  expect(el.label).to.equal('Text');
@@ -50,14 +50,14 @@ export class UmbrellaForm extends LitElement {
50
50
  return html`
51
51
  <lion-form .serializedValue="${this.__serializedValue}">
52
52
  <form>
53
- <lion-fieldset name="full_name">
53
+ <lion-fieldset name="fullName">
54
54
  <lion-input
55
- name="first_name"
55
+ name="firstName"
56
56
  label="First Name"
57
57
  .validators="${[new Required()]}"
58
58
  ></lion-input>
59
59
  <lion-input
60
- name="last_name"
60
+ name="lastName"
61
61
  label="Last Name"
62
62
  .validators="${[new Required()]}"
63
63
  ></lion-input>
@@ -1,6 +1,6 @@
1
1
  import { css } from 'lit';
2
2
  import { LionInput } from '@lion/ui/input.js';
3
- import { getCurrencyName, localize, LocalizeMixin } from '@lion/ui/localize.js';
3
+ import { getCurrencyName, LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
4
4
  import { IsNumber } from '@lion/ui/form-core.js';
5
5
  import { formatAmount, formatCurrencyLabel } from './formatters.js';
6
6
  import { parseAmount } from './parsers.js';
@@ -201,7 +201,7 @@ export class LionInputAmount extends LocalizeMixin(LionInput) {
201
201
  }
202
202
 
203
203
  get __currencyLabel() {
204
- return this.currency ? formatCurrencyLabel(this.currency, localize.locale) : '';
204
+ return this.currency ? formatCurrencyLabel(this.currency, this._localizeManager.locale) : '';
205
205
  }
206
206
 
207
207
  __reformat() {
@@ -1,4 +1,8 @@
1
- import { formatNumber, getFractionDigits, normalizeCurrencyLabel } from '@lion/ui/localize.js';
1
+ import {
2
+ formatNumber,
3
+ getFractionDigits,
4
+ normalizeCurrencyLabel,
5
+ } from '@lion/ui/localize-no-side-effects.js';
2
6
 
3
7
  /**
4
8
  * @typedef {import('../../localize/types/LocalizeMixinTypes.js').FormatNumberOptions} FormatOptions
@@ -1,4 +1,4 @@
1
- import { parseNumber, getFractionDigits } from '@lion/ui/localize.js';
1
+ import { parseNumber, getFractionDigits } from '@lion/ui/localize-no-side-effects.js';
2
2
 
3
3
  /**
4
4
  * @typedef {import('../../localize/types/LocalizeMixinTypes.js').FormatNumberOptions} FormatOptions
@@ -1,10 +1,12 @@
1
1
  import { expect } from '@open-wc/testing';
2
- import { localize } from '@lion/ui/localize.js';
2
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
3
3
  import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
4
4
 
5
5
  import { formatAmount } from '@lion/ui/input-amount.js';
6
6
 
7
7
  describe('formatAmount()', () => {
8
+ const localizeManager = getLocalizeManager();
9
+
8
10
  afterEach(() => {
9
11
  localizeTearDown();
10
12
  });
@@ -67,9 +69,9 @@ describe('formatAmount()', () => {
67
69
  });
68
70
 
69
71
  it('fallbacks to global locale and EUR by default', async () => {
70
- localize.locale = 'en-GB';
72
+ localizeManager.locale = 'en-GB';
71
73
  expect(formatAmount(12345678)).to.equal('12,345,678.00');
72
- localize.locale = 'nl-NL';
74
+ localizeManager.locale = 'nl-NL';
73
75
  expect(formatAmount(12345678)).to.equal('12.345.678,00');
74
76
  });
75
77
  });
@@ -1,6 +1,6 @@
1
1
  import { IsDate } from '@lion/ui/form-core.js';
2
2
  import { LionInput } from '@lion/ui/input.js';
3
- import { formatDate, LocalizeMixin, parseDate } from '@lion/ui/localize.js';
3
+ import { formatDate, LocalizeMixin, parseDate } from '@lion/ui/localize-no-side-effects.js';
4
4
 
5
5
  /**
6
6
  * @param {Date|number} date
@@ -1,7 +1,7 @@
1
1
  import { html } from 'lit';
2
- import { localize } from '@lion/ui/localize.js';
2
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
3
3
  import { localizeTearDown } from '@lion/ui/localize-test-helpers.js';
4
- import { MaxDate } from '@lion/ui/form-core.js';
4
+ import { MinDate, MaxDate } from '@lion/ui/form-core.js';
5
5
  import { expect, fixture as _fixture } from '@open-wc/testing';
6
6
  import { getInputMembers } from '@lion/ui/input-test-helpers.js';
7
7
  import '@lion/ui/define/lion-input-date.js';
@@ -13,6 +13,8 @@ import '@lion/ui/define/lion-input-date.js';
13
13
  const fixture = /** @type {(arg: TemplateResult) => Promise<LionInputDate>} */ (_fixture);
14
14
 
15
15
  describe('<lion-input-date>', () => {
16
+ const localizeManager = getLocalizeManager();
17
+
16
18
  beforeEach(() => {
17
19
  localizeTearDown();
18
20
  });
@@ -65,49 +67,95 @@ describe('<lion-input-date>', () => {
65
67
  expect(el.validationStates.error).not.to.have.property('MaxDate');
66
68
  });
67
69
 
68
- it('uses formatOptions.locale', async () => {
69
- const el = await fixture(html`
70
- <lion-input-date
71
- .formatOptions="${{ locale: 'en-GB' }}"
72
- .modelValue=${new Date('2017/06/15')}
73
- ></lion-input-date>
74
- `);
75
- expect(el.formattedValue).to.equal('15/06/2017');
76
-
77
- const el2 = await fixture(html`
78
- <lion-input-date
79
- .formatOptions="${{ locale: 'en-US' }}"
80
- .modelValue=${new Date('2017/06/15')}
81
- ></lion-input-date>
82
- `);
83
- expect(el2.formattedValue).to.equal('06/15/2017');
84
- });
85
-
86
- it('uses global locale when formatOptions.locale is not defined', async () => {
87
- localize.locale = 'fr-FR';
88
- const el = await fixture(html`
89
- <lion-input-date .modelValue=${new Date('2017/06/15')}></lion-input-date>
90
- `);
91
- expect(el.formattedValue).to.equal('15/06/2017');
92
-
93
- localize.locale = 'en-US';
94
- const el2 = await fixture(html`
95
- <lion-input-date .modelValue=${new Date('2017/06/15')}></lion-input-date>
96
- `);
97
- expect(el2.formattedValue).to.equal('06/15/2017');
70
+ describe('locale', () => {
71
+ it('uses formatOptions.locale', async () => {
72
+ const el = await fixture(html`
73
+ <lion-input-date
74
+ .formatOptions="${{ locale: 'en-GB' }}"
75
+ .modelValue=${new Date('2017/06/15')}
76
+ ></lion-input-date>
77
+ `);
78
+ expect(el.formattedValue).to.equal('15/06/2017');
79
+
80
+ const el2 = await fixture(html`
81
+ <lion-input-date
82
+ .formatOptions="${{ locale: 'en-US' }}"
83
+ .modelValue=${new Date('2017/06/15')}
84
+ ></lion-input-date>
85
+ `);
86
+ expect(el2.formattedValue).to.equal('06/15/2017');
87
+ });
88
+
89
+ it('uses global locale when formatOptions.locale is not defined', async () => {
90
+ localizeManager.locale = 'fr-FR';
91
+ const el = await fixture(html`
92
+ <lion-input-date .modelValue=${new Date('2017/06/15')}></lion-input-date>
93
+ `);
94
+ expect(el.formattedValue).to.equal('15/06/2017');
95
+
96
+ localizeManager.locale = 'en-US';
97
+ const el2 = await fixture(html`
98
+ <lion-input-date .modelValue=${new Date('2017/06/15')}></lion-input-date>
99
+ `);
100
+ expect(el2.formattedValue).to.equal('06/15/2017');
101
+ });
102
+
103
+ it('ignores global locale change if formatOptions.locale is provided', async () => {
104
+ const el = await fixture(html`
105
+ <lion-input-date
106
+ .modelValue=${new Date('2017/06/15')}
107
+ .formatOptions="${{ locale: 'en-GB' }}"
108
+ ></lion-input-date>
109
+ `);
110
+ expect(el.formattedValue).to.equal('15/06/2017'); // british
111
+ localizeManager.locale = 'en-US';
112
+ await el.updateComplete;
113
+ expect(el.formattedValue).to.equal('15/06/2017'); // should stay british
114
+ });
98
115
  });
99
116
 
100
- it('ignores global locale change if formatOptions.locale is provided', async () => {
101
- const el = await fixture(html`
102
- <lion-input-date
103
- .modelValue=${new Date('2017/06/15')}
104
- .formatOptions="${{ locale: 'en-GB' }}"
105
- ></lion-input-date>
106
- `);
107
- expect(el.formattedValue).to.equal('15/06/2017'); // british
108
- localize.locale = 'en-US';
109
- await el.updateComplete;
110
- expect(el.formattedValue).to.equal('15/06/2017'); // should stay british
117
+ describe('timezones', async () => {
118
+ const dateAmsterdam = new Date(
119
+ new Date('2017/06/15').toLocaleString('en-US', { timeZone: 'Europe/Amsterdam' }),
120
+ );
121
+ const dateManila = new Date(
122
+ new Date('2017/06/15').toLocaleString('en-US', { timeZone: 'Asia/Manila' }),
123
+ );
124
+ const dateNewYork = new Date(
125
+ new Date('2017/06/15').toLocaleString('en-US', { timeZone: 'America/New_York' }),
126
+ );
127
+
128
+ it('works with different timezones', async () => {
129
+ const el = await fixture(html`
130
+ <lion-input-date .modelValue=${dateAmsterdam}></lion-input-date>
131
+ `);
132
+ expect(el.formattedValue).to.equal('15/06/2017', 'Europe/Amsterdam');
133
+
134
+ el.modelValue = dateManila;
135
+ expect(el.formattedValue).to.equal('15/06/2017', 'Asia/Manila');
136
+
137
+ el.modelValue = dateNewYork;
138
+ expect(el.formattedValue).to.equal('14/06/2017', 'America/New_York');
139
+ });
140
+
141
+ it('validators work with different timezones', async () => {
142
+ const el = await fixture(html`
143
+ <lion-input-date
144
+ .modelValue=${new Date('2017/06/15')}
145
+ .validators=${[new MinDate(new Date('2017/06/14'))]}
146
+ ></lion-input-date>
147
+ `);
148
+ expect(el.formattedValue).to.equal('15/06/2017', 'Europe/Amsterdam');
149
+ expect(el.hasFeedbackFor).not.to.include('error', 'Europe/Amsterdam');
150
+
151
+ el.modelValue = dateManila;
152
+ expect(el.formattedValue).to.equal('15/06/2017', 'Asia/Manila');
153
+ expect(el.hasFeedbackFor).not.to.include('error', 'Asia/Manila');
154
+
155
+ el.modelValue = dateNewYork;
156
+ expect(el.formattedValue).to.equal('14/06/2017', 'America/New_York');
157
+ expect(el.hasFeedbackFor).not.to.include('error', 'America/New_York');
158
+ });
111
159
  });
112
160
 
113
161
  it('is accessible', async () => {
@@ -10,7 +10,7 @@ import {
10
10
  withModalDialogConfig,
11
11
  ArrowMixin,
12
12
  } from '@lion/ui/overlays.js';
13
- import { LocalizeMixin } from '@lion/ui/localize.js';
13
+ import { LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
14
14
  import { localizeNamespaceLoader } from './localizeNamespaceLoader.js';
15
15
 
16
16
  /**
@@ -1,6 +1,6 @@
1
1
  import { IsEmail } from '@lion/ui/form-core.js';
2
2
  import { LionInput } from '@lion/ui/input.js';
3
- import { LocalizeMixin } from '@lion/ui/localize.js';
3
+ import { LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
4
4
 
5
5
  /**
6
6
  * LionInputEmail: extension of lion-input
@@ -1,4 +1,4 @@
1
- import { LocalizeMixin } from '@lion/ui/localize.js';
1
+ import { LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
2
2
  import { LionInput } from '@lion/ui/input.js';
3
3
  import { formatIBAN } from './formatters.js';
4
4
  import { parseIBAN } from './parsers.js';
@@ -1,15 +1,16 @@
1
1
  /* eslint-disable max-classes-per-file, import/no-extraneous-dependencies */
2
2
 
3
- import { localize } from '@lion/ui/localize.js';
3
+ import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
4
4
  import { Unparseable, Validator } from '@lion/ui/form-core.js';
5
5
  import { isValidIBAN } from 'ibantools';
6
6
 
7
7
  let loaded = false;
8
8
  const loadTranslations = async () => {
9
+ const localizeManager = getLocalizeManager();
9
10
  if (loaded) {
10
11
  return;
11
12
  }
12
- await localize.loadNamespace(
13
+ await localizeManager.loadNamespace(
13
14
  {
14
15
  'lion-validate+iban': /** @param {string} locale */ locale => {
15
16
  switch (locale) {
@@ -86,7 +87,7 @@ const loadTranslations = async () => {
86
87
  }
87
88
  },
88
89
  },
89
- { locale: localize.locale },
90
+ { locale: localizeManager.locale },
90
91
  );
91
92
  loaded = true;
92
93
  };
@@ -113,8 +114,9 @@ export class IsIBAN extends Validator {
113
114
  * @returns {Promise<string|Element>}
114
115
  */
115
116
  static async getMessage(data) {
117
+ const localizeManager = getLocalizeManager();
116
118
  await loadTranslations();
117
- return localize.msg('lion-validate+iban:error.IsIBAN', data);
119
+ return localizeManager.msg('lion-validate+iban:error.IsIBAN', data);
118
120
  }
119
121
  }
120
122
 
@@ -156,11 +158,13 @@ export class IsCountryIBAN extends IsIBAN {
156
158
  * @returns {Promise<string|Element>}
157
159
  */
158
160
  static async getMessage(data) {
161
+ const localizeManager = getLocalizeManager();
162
+
159
163
  await loadTranslations();
160
164
  // If modelValue is Unparseable, the IsIBAN message is the more appropriate feedback
161
165
  return data?.modelValue instanceof Unparseable
162
- ? localize.msg('lion-validate+iban:error.IsIBAN', data)
163
- : localize.msg('lion-validate+iban:error.IsCountryIBAN', data);
166
+ ? localizeManager.msg('lion-validate+iban:error.IsIBAN', data)
167
+ : localizeManager.msg('lion-validate+iban:error.IsCountryIBAN', data);
164
168
  }
165
169
  }
166
170
 
@@ -203,6 +207,8 @@ export class IsNotCountryIBAN extends IsIBAN {
203
207
  * @returns {Promise<string|Element>}
204
208
  */
205
209
  static async getMessage(data) {
210
+ const localizeManager = getLocalizeManager();
211
+
206
212
  await loadTranslations();
207
213
  const _data = {
208
214
  ...data,
@@ -211,7 +217,7 @@ export class IsNotCountryIBAN extends IsIBAN {
211
217
  };
212
218
  // If modelValue is Unparseable, the IsIBAN message is the more appropriate feedback
213
219
  return data?.modelValue instanceof Unparseable
214
- ? localize.msg('lion-validate+iban:error.IsIBAN', _data)
215
- : localize.msg('lion-validate+iban:error.IsNotCountryIBAN', _data);
220
+ ? localizeManager.msg('lion-validate+iban:error.IsIBAN', _data)
221
+ : localizeManager.msg('lion-validate+iban:error.IsNotCountryIBAN', _data);
216
222
  }
217
223
  }
@@ -2,7 +2,7 @@
2
2
  import { css, html } from 'lit';
3
3
  import { ScopedStylesController } from '@lion/ui/core.js';
4
4
  import { LionInput } from '@lion/ui/input.js';
5
- import { formatNumber } from '@lion/ui/localize.js';
5
+ import { formatNumber } from '@lion/ui/localize-no-side-effects.js';
6
6
 
7
7
  /**
8
8
  * @typedef {import('lit').CSSResult} CSSResult