@lion/ui 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -11
- package/components/combobox/src/LionCombobox.js +4 -1
- package/components/combobox/test/lion-combobox-integrations.test.js +23 -0
- package/components/combobox/test/lion-combobox.test.js +20 -0
- package/components/core/src/ScopedStylesController.js +7 -10
- package/components/core/test-helpers/getCachedFixture.js +55 -0
- package/components/form-core/src/validate/LionValidationFeedback.js +2 -2
- package/components/form-core/src/validate/ValidateMixin.js +3 -3
- package/components/form-core/test/validate/lion-validation-feedback.test.js +2 -2
- package/components/form-core/test-suites/ValidateMixin.suite.js +23 -11
- package/components/form-core/translations/bg.js +4 -4
- package/components/form-core/translations/cs.js +4 -4
- package/components/form-core/translations/de.js +4 -4
- package/components/form-core/translations/en.js +4 -4
- package/components/form-core/translations/es.js +4 -4
- package/components/form-core/translations/fr.js +4 -4
- package/components/form-core/translations/hu.js +4 -4
- package/components/form-core/translations/it.js +4 -4
- package/components/form-core/translations/nl.js +4 -4
- package/components/form-core/translations/pl.js +4 -4
- package/components/form-core/translations/ro.js +4 -4
- package/components/form-core/translations/ru.js +4 -4
- package/components/form-core/translations/sk.js +4 -4
- package/components/form-core/translations/uk.js +4 -4
- package/components/form-core/translations/zh.js +4 -4
- package/components/input-amount/src/parsers.js +3 -2
- package/components/input-amount/test/parsers.test.js +6 -0
- package/components/input-amount-dropdown/src/currencyUtil.js +1 -1
- package/components/input-file/src/localizeNamespaceLoader.js +4 -0
- package/components/input-file/translations/bg.js +5 -0
- package/components/input-file/translations/cs.js +5 -0
- package/components/input-file/translations/es.js +5 -0
- package/components/input-file/translations/fr.js +5 -0
- package/components/input-file/translations/hu.js +5 -0
- package/components/input-file/translations/id-ID.js +5 -0
- package/components/input-file/translations/id.js +19 -0
- package/components/input-file/translations/it.js +5 -0
- package/components/input-file/translations/pl.js +5 -0
- package/components/input-file/translations/ro.js +5 -0
- package/components/input-file/translations/sk.js +5 -0
- package/components/input-file/translations/uk.js +5 -0
- package/components/input-file/translations/zh.js +5 -0
- package/components/input-stepper/src/LionInputStepper.js +48 -52
- package/components/input-stepper/test/lion-input-stepper-integrations.test.js +2 -19
- package/components/input-stepper/test/lion-input-stepper.test.js +2 -476
- package/components/input-stepper/test-suites/lion-input-stepper.integration.suite.js +19 -0
- package/components/input-stepper/test-suites/lion-input-stepper.suite.js +673 -0
- package/components/listbox/src/ListboxMixin.js +0 -1
- package/components/listbox/test-suites/ListboxMixin.suite.js +71 -2
- package/components/overlays/src/OverlayController.js +3 -0
- package/components/overlays/src/OverlaysManager.js +9 -2
- package/components/overlays/test/OverlayController.test.js +22 -9
- package/components/overlays/test/OverlaysManager.test.js +16 -0
- package/components/pagination/src/LionPagination.js +2 -1
- package/components/pagination/test/lion-pagination.test.js +41 -0
- package/components/validate-messages/translations/it.js +2 -2
- package/custom-elements.json +281 -179
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/core/src/ScopedStylesController.d.ts +1 -2
- package/dist-types/components/core/src/ScopedStylesController.d.ts.map +1 -1
- package/dist-types/components/core/test-helpers/getCachedFixture.d.ts +14 -0
- package/dist-types/components/core/test-helpers/getCachedFixture.d.ts.map +1 -0
- package/dist-types/components/form-core/test-suites/ValidateMixin.suite.d.ts.map +1 -1
- package/dist-types/components/form-integrations/test/helpers/helpers.d.ts +3 -3
- package/dist-types/components/form-integrations/test/helpers/helpers.d.ts.map +1 -1
- package/dist-types/components/input-amount/src/parsers.d.ts.map +1 -1
- package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts +1 -1
- package/dist-types/components/input-file/src/localizeNamespaceLoader.d.ts.map +1 -1
- package/dist-types/components/input-file/translations/bg-BG.d.ts +5 -0
- package/dist-types/components/input-file/translations/bg.d.ts +5 -0
- package/dist-types/components/input-file/translations/cs-CZ.d.ts +5 -0
- package/dist-types/components/input-file/translations/cs.d.ts +5 -0
- package/dist-types/components/input-file/translations/es-ES.d.ts +5 -0
- package/dist-types/components/input-file/translations/es.d.ts +5 -0
- package/dist-types/components/input-file/translations/fr-BE.d.ts +5 -0
- package/dist-types/components/input-file/translations/fr-FR.d.ts +5 -0
- package/dist-types/components/input-file/translations/fr.d.ts +5 -0
- package/dist-types/components/input-file/translations/hu-HU.d.ts +5 -0
- package/dist-types/components/input-file/translations/hu.d.ts +5 -0
- package/dist-types/components/input-file/translations/id-ID.d.ts +20 -0
- package/dist-types/components/input-file/translations/id-ID.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/id.d.ts +20 -0
- package/dist-types/components/input-file/translations/id.d.ts.map +1 -0
- package/dist-types/components/input-file/translations/it-IT.d.ts +5 -0
- package/dist-types/components/input-file/translations/it.d.ts +5 -0
- package/dist-types/components/input-file/translations/pl-PL.d.ts +5 -0
- package/dist-types/components/input-file/translations/pl.d.ts +5 -0
- package/dist-types/components/input-file/translations/ro-RO.d.ts +5 -0
- package/dist-types/components/input-file/translations/ro.d.ts +5 -0
- package/dist-types/components/input-file/translations/sk-SK.d.ts +5 -0
- package/dist-types/components/input-file/translations/sk.d.ts +5 -0
- package/dist-types/components/input-file/translations/uk-UA.d.ts +5 -0
- package/dist-types/components/input-file/translations/uk.d.ts +5 -0
- package/dist-types/components/input-file/translations/zh-CN.d.ts +5 -0
- package/dist-types/components/input-file/translations/zh.d.ts +5 -0
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts +4 -20
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts.map +1 -1
- package/dist-types/components/input-stepper/test/lion-input-stepper.test.d.ts +1 -2
- package/dist-types/components/input-stepper/test/lion-input-stepper.test.d.ts.map +1 -1
- package/dist-types/components/input-stepper/test-suites/lion-input-stepper.integration.suite.d.ts +3 -0
- package/dist-types/components/input-stepper/test-suites/lion-input-stepper.integration.suite.d.ts.map +1 -0
- package/dist-types/components/input-stepper/test-suites/lion-input-stepper.suite.d.ts +4 -0
- package/dist-types/components/input-stepper/test-suites/lion-input-stepper.suite.d.ts.map +1 -0
- package/dist-types/components/listbox/src/ListboxMixin.d.ts.map +1 -1
- package/dist-types/components/listbox/test-suites/ListboxMixin.suite.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts +4 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/pagination/src/LionPagination.d.ts.map +1 -1
- package/dist-types/exports/input-stepper-suites.d.ts +6 -0
- package/dist-types/exports/input-stepper-suites.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/checkbox-group/use-cases.md +3 -9
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/form/use-cases.md +2 -2
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-file/overview.md +1 -1
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/api-table.md +2 -3
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/listbox/use-cases.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/radio-group/use-cases.md +3 -9
- package/docs/components/select/overview.md +1 -1
- package/docs/components/select/use-cases.md +6 -6
- package/docs/components/select-rich/use-cases.md +2 -2
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +2 -2
- package/docs/fundamentals/systems/core/api-table.md +3 -4
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +38 -30
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/api-table.md +1 -1
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/create-a-form.md +4 -4
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/input-stepper-suites.js +11 -0
- package/input-stepper-suites.js +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
</p>
|
|
27
27
|
|
|
28
28
|
<p align="center">
|
|
29
|
-
<a href="https://lion
|
|
29
|
+
<a href="https://lion.js.org">Website</a>
|
|
30
30
|
·
|
|
31
|
-
<a href="https://lion
|
|
31
|
+
<a href="https://lion.js.org/fundamentals/">Fundamentals</a>
|
|
32
32
|
·
|
|
33
|
-
<a href="https://lion
|
|
33
|
+
<a href="https://lion.js.org/guides/">Guides</a>
|
|
34
34
|
·
|
|
35
|
-
<a href="https://lion
|
|
35
|
+
<a href="https://lion.js.org/components/">Components</a>
|
|
36
36
|
·
|
|
37
|
-
<a href="https://lion
|
|
37
|
+
<a href="https://lion.js.org/blog/">Blog</a>
|
|
38
38
|
</p>
|
|
39
39
|
|
|
40
40
|
**Lion is a set of highly performant, accessible and flexible Web Components.!**
|
|
@@ -44,16 +44,45 @@ They provide an unopinionated, white-label layer that can be extended to your ow
|
|
|
44
44
|
- **High Performance:** Focused on great performance in all relevant browsers with a minimal number of dependencies.
|
|
45
45
|
- **Accessibility:** Aimed at compliance with the WCAG 2.2 AA standard to create components that are accessible for everybody.
|
|
46
46
|
- **Flexibility:** Provides solutions through Web Components and JavaScript classes which can be used, adopted and extended to fit all needs.
|
|
47
|
-
- **Modern Code:** Lion is
|
|
47
|
+
- **Modern Code:** Lion is distributed as pure es modules.
|
|
48
48
|
- **Exposes functions/classes and Web Components:** Ships a functionality in it's most appropriate form.
|
|
49
49
|
|
|
50
50
|
> Note: Our demos may look a little bland but that is on purpose. They only come with functional stylings.
|
|
51
51
|
> This makes sense as the main use case is to extend those components and if you do you do not want to override existing stylings.
|
|
52
52
|
|
|
53
53
|
<p align="center">
|
|
54
|
-
<a href="https://lion
|
|
54
|
+
<a href="https://lion.js.org/guides/"><strong>Explore the Lion Guides ▶</strong></a>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
|
+
<details>
|
|
58
|
+
<summary><h2>Table of Contents</h2></summary>
|
|
59
|
+
<ul>
|
|
60
|
+
<li><a href="#astro-migration"> Astro migration </a>
|
|
61
|
+
<ul>
|
|
62
|
+
<li><a href="#astro-how-to"> Astro how to </a></li>
|
|
63
|
+
<li><a href="#issues-which-are-not-caused-by-the-migration-not-to-be-fixed-now"> Issues which are not caused by migration </a></li>
|
|
64
|
+
</ul>
|
|
65
|
+
</li>
|
|
66
|
+
<li><a href="#how-to-install"> Installation </a></li>
|
|
67
|
+
<li><a href="#how-to-use"> How to use </a>
|
|
68
|
+
<ul>
|
|
69
|
+
<li><a href="#extend-a-web-component"> Extend a web component </a></li>
|
|
70
|
+
<li><a href="#use-a-javascript-system"> Use a JavaScript system </a></li>
|
|
71
|
+
<li><a href="#use-a-web-component"> Use a Web Component </a></li>
|
|
72
|
+
</ul>
|
|
73
|
+
</li>
|
|
74
|
+
<li><a href="#issues"> Issues </a></li>
|
|
75
|
+
<li><a href="#feature-requests"> Feature request </a></li>
|
|
76
|
+
<li><a href="#content"> Content </a></li>
|
|
77
|
+
<li><a href="#technologies"> Technologies </a></li>
|
|
78
|
+
<li><a href="#rationale"> Rationale </a></li>
|
|
79
|
+
<li><a href="#coding-guidelines"> Coding guidelines </a></li>
|
|
80
|
+
<li><a href="#how-to-contribute"> How to contribute </a></li>
|
|
81
|
+
<li><a href="#site-deployment"> Site deployment </a></li>
|
|
82
|
+
<li><a href="#content"> Contact </a></li>
|
|
83
|
+
</ul>
|
|
84
|
+
</details>
|
|
85
|
+
|
|
57
86
|
## Astro migration
|
|
58
87
|
|
|
59
88
|
- Keep using `/docs` on the root level as we used it in the `master` branch. The documentation is copied into Astro related directories on `npm run start` and when when anything in `/docs` is updated.
|
|
@@ -62,7 +91,7 @@ They provide an unopinionated, white-label layer that can be extended to your ow
|
|
|
62
91
|
|
|
63
92
|
### Astro how to
|
|
64
93
|
|
|
65
|
-
- To start in dev mode run `
|
|
94
|
+
- To start in dev mode run `npm run start`
|
|
66
95
|
- To start in production mode:
|
|
67
96
|
- Run `npm run build`
|
|
68
97
|
- Run `npm run preview`
|
|
@@ -77,8 +106,6 @@ They provide an unopinionated, white-label layer that can be extended to your ow
|
|
|
77
106
|
|
|
78
107
|
Note. There is the same error on master. This issue is not caused by the migration
|
|
79
108
|
|
|
80
|
-
### TODO
|
|
81
|
-
|
|
82
109
|
## How to install
|
|
83
110
|
|
|
84
111
|
```bash
|
|
@@ -184,7 +211,7 @@ This means you only have to apply your own Design System: by delivering styles,
|
|
|
184
211
|
|
|
185
212
|
## Coding guidelines
|
|
186
213
|
|
|
187
|
-
Check out our [coding guidelines](https://lion
|
|
214
|
+
Check out our [coding guidelines](https://lion.js.org/guides/principles/definitions-and-terms/) for more detailed information.
|
|
188
215
|
|
|
189
216
|
## How to contribute
|
|
190
217
|
|
|
@@ -193,6 +220,14 @@ Check out our [coding guidelines](https://lion-web.netlify.app/guides/principles
|
|
|
193
220
|
Lion Web Components are only as good as its contributions.
|
|
194
221
|
Read our [contribution guide](https://github.com/ing-bank/lion/blob/master/CONTRIBUTING.md) and feel free to enhance/improve Lion. We keep feature requests closed while we're not working on them.
|
|
195
222
|
|
|
223
|
+
## Site deployment
|
|
224
|
+
|
|
225
|
+
We use [GitHub Pages](https://docs.github.com/en/pages) to host our static website. Collaborators with push permission to the repository branch [`gh-pages`](https://github.com/ing-bank/lion/tree/gh-pages) can trigger a deploy by simply running:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
npm run deploy
|
|
229
|
+
```
|
|
230
|
+
|
|
196
231
|
## Contact
|
|
197
232
|
|
|
198
233
|
Feel free to create a github issue for any feedback or questions you might have.
|
|
@@ -965,7 +965,10 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(CustomChoiceGroupMi
|
|
|
965
965
|
if (isInlineAutoFillCandidate) {
|
|
966
966
|
const textboxValue = this._getTextboxValueFromOption(option);
|
|
967
967
|
const stringValues =
|
|
968
|
-
|
|
968
|
+
typeof textboxValue === 'string' &&
|
|
969
|
+
textboxValue !== '' &&
|
|
970
|
+
typeof curValue === 'string' &&
|
|
971
|
+
curValue !== '';
|
|
969
972
|
const beginsWith =
|
|
970
973
|
stringValues && textboxValue.toLowerCase().indexOf(curValue.toLowerCase()) === 0;
|
|
971
974
|
// We only can do proper inline autofilling when the beginning of the word matches
|
|
@@ -1,9 +1,32 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
1
2
|
import { runListboxMixinSuite } from '@lion/ui/listbox-test-suites.js';
|
|
2
3
|
import '@lion/ui/define/lion-combobox.js';
|
|
3
4
|
import { runCustomChoiceGroupMixinSuite } from '../../form-core/test-suites/choice-group/CustomChoiceGroupMixin.suite.js';
|
|
5
|
+
import { LionCombobox } from '../src/LionCombobox.js';
|
|
6
|
+
import { ScopedStylesController } from '../../core/src/ScopedStylesController.js';
|
|
4
7
|
|
|
5
8
|
runListboxMixinSuite({ tagString: 'lion-combobox' });
|
|
6
9
|
runCustomChoiceGroupMixinSuite({
|
|
7
10
|
parentTagString: 'lion-combobox',
|
|
8
11
|
childTagString: 'lion-option',
|
|
9
12
|
});
|
|
13
|
+
|
|
14
|
+
// Test case for using ScopedStylesController inside the LionCombobox
|
|
15
|
+
class ComboboxWithScopedStyles extends LionCombobox {
|
|
16
|
+
static scopedStyles() {
|
|
17
|
+
return css`
|
|
18
|
+
p {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
this.scopedStylesController = new ScopedStylesController(this);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
customElements.define('combobox-with-scoped-styles', ComboboxWithScopedStyles);
|
|
31
|
+
|
|
32
|
+
runListboxMixinSuite({ tagString: 'combobox-with-scoped-styles' });
|
|
@@ -652,6 +652,26 @@ describe('lion-combobox', () => {
|
|
|
652
652
|
expect(visibleOptions().length).to.equal(0, 'after clear');
|
|
653
653
|
});
|
|
654
654
|
|
|
655
|
+
it('keeps interaction states on clear()', async () => {
|
|
656
|
+
const el = /** @type {LionCombobox} */ (
|
|
657
|
+
await fixture(html`
|
|
658
|
+
<lion-combobox name="foo">
|
|
659
|
+
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
|
660
|
+
<lion-option .choiceValue="${'Chard'}">Chard</lion-option>
|
|
661
|
+
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
|
662
|
+
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
|
663
|
+
</lion-combobox>
|
|
664
|
+
`)
|
|
665
|
+
);
|
|
666
|
+
await mimicUserTyping(el, 'a');
|
|
667
|
+
await el.updateComplete;
|
|
668
|
+
expect(el.dirty).to.equal(true);
|
|
669
|
+
|
|
670
|
+
el.clear();
|
|
671
|
+
await el.updateComplete;
|
|
672
|
+
expect(el.dirty).to.equal(true);
|
|
673
|
+
});
|
|
674
|
+
|
|
655
675
|
it('resets modelValue and textbox value on reset()', async () => {
|
|
656
676
|
const el = /** @type {LionCombobox} */ (
|
|
657
677
|
await fixture(html`
|
|
@@ -6,6 +6,8 @@ import { unsafeCSS, css } from 'lit';
|
|
|
6
6
|
* @implements {ReactiveController}
|
|
7
7
|
*/
|
|
8
8
|
export class ScopedStylesController {
|
|
9
|
+
#hasConnected = false;
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* @param {import('lit').CSSResult} scope
|
|
11
13
|
* @return {import('lit').CSSResultGroup}
|
|
@@ -26,12 +28,11 @@ export class ScopedStylesController {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
hostConnected() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.__teardownStyleTag();
|
|
31
|
+
if (!this.#hasConnected) {
|
|
32
|
+
this.host.classList.add(this.scopedClass);
|
|
33
|
+
this.__setupStyleTag();
|
|
34
|
+
this.#hasConnected = true;
|
|
35
|
+
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
__setupStyleTag() {
|
|
@@ -46,8 +47,4 @@ export class ScopedStylesController {
|
|
|
46
47
|
.toString();
|
|
47
48
|
this.host.insertBefore(this.__styleTag, this.host.childNodes[0]);
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
__teardownStyleTag() {
|
|
51
|
-
this.host.removeChild(this.__styleTag);
|
|
52
|
-
}
|
|
53
50
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineCE, fixture, html, unsafeStatic } from '@open-wc/testing';
|
|
2
|
+
import { LitElement, nothing } from 'lit';
|
|
3
|
+
import { cache } from 'lit/directives/cache.js';
|
|
4
|
+
import { createRef } from 'lit/directives/ref.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Helper to get a fixture with a cached render function and show/hide methods.
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {(ref: import('lit/directives/ref.js').Ref<T>) => import('lit').TemplateResult} render - The render function
|
|
10
|
+
* @returns {Promise<{ wrapper: LitElement, el: T | undefined, show: () => Promise<void>, hide: () => Promise<void> }>}
|
|
11
|
+
*/
|
|
12
|
+
export async function getCachedFixture(
|
|
13
|
+
/** @type {(ref: import('lit/directives/ref.js').Ref<any>) => import('lit').TemplateResult} */ render,
|
|
14
|
+
) {
|
|
15
|
+
class CachingWrapper extends LitElement {
|
|
16
|
+
static properties = {
|
|
17
|
+
_show: { type: Boolean },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this._show = true;
|
|
23
|
+
this.ref = createRef();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async show() {
|
|
27
|
+
this._show = true;
|
|
28
|
+
return this.updateComplete;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async hide() {
|
|
32
|
+
this._show = false;
|
|
33
|
+
return this.updateComplete;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
return html`${cache(this._show ? render(this.ref) : nothing)}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const customElementName = defineCE(CachingWrapper);
|
|
42
|
+
const customTag = unsafeStatic(customElementName);
|
|
43
|
+
|
|
44
|
+
const wrapper =
|
|
45
|
+
/** @type {LitElement & { ref: import('lit/directives/ref.js').Ref<any>, show(): Promise<void>, hide(): Promise<void> }} */ (
|
|
46
|
+
await fixture(html`<${customTag}></${customTag}>`)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
wrapper,
|
|
51
|
+
el: wrapper.ref.value,
|
|
52
|
+
show: async () => wrapper.show(),
|
|
53
|
+
hide: async () => wrapper.hide(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -87,11 +87,11 @@ export class LionValidationFeedback extends LocalizeMixin(LitElement) {
|
|
|
87
87
|
${this.feedbackData &&
|
|
88
88
|
this.feedbackData.map(
|
|
89
89
|
({ message, type, validator }) => html`
|
|
90
|
-
<
|
|
90
|
+
<span class="validation-feedback__type">
|
|
91
91
|
${message && type
|
|
92
92
|
? this._localizeManager.msg(`lion-form-core:validation${capitalize(type)}`)
|
|
93
93
|
: nothing}
|
|
94
|
-
</
|
|
94
|
+
</span>
|
|
95
95
|
${this._messageTemplate({ message, type, validator })}
|
|
96
96
|
`,
|
|
97
97
|
)}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this, camelcase, no-param-reassign, max-classes-per-file */
|
|
2
|
-
import {
|
|
2
|
+
import { DisabledMixin, SlotMixin } from '@lion/ui/core.js';
|
|
3
3
|
import { dedupeMixin } from '@open-wc/dedupe-mixin';
|
|
4
4
|
// TODO: make form-core independent from localize
|
|
5
5
|
import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
|
|
6
6
|
import { ScopedElementsMixin } from '../../../core/src/ScopedElementsMixin.js';
|
|
7
|
+
import { FormControlMixin } from '../FormControlMixin.js';
|
|
7
8
|
import { AsyncQueue } from '../utils/AsyncQueue.js';
|
|
8
9
|
import { pascalCase } from '../utils/pascalCase.js';
|
|
9
10
|
import { SyncUpdatableMixin } from '../utils/SyncUpdatableMixin.js';
|
|
10
11
|
import { LionValidationFeedback } from './LionValidationFeedback.js';
|
|
11
12
|
import { Unparseable } from './Unparseable.js';
|
|
12
|
-
import { FormControlMixin } from '../FormControlMixin.js';
|
|
13
13
|
// eslint-disable-next-line no-unused-vars
|
|
14
14
|
import { ResultValidator as MetaValidator } from './ResultValidator.js';
|
|
15
15
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -399,7 +399,7 @@ export const ValidateMixinImplementation = superclass =>
|
|
|
399
399
|
this.__validateCompleteResolve = resolve;
|
|
400
400
|
});
|
|
401
401
|
|
|
402
|
-
if (this.disabled) {
|
|
402
|
+
if (this.disabled || this.readOnly) {
|
|
403
403
|
this.__clearValidationResults();
|
|
404
404
|
this.__finishValidationPass();
|
|
405
405
|
this._updateFeedbackComponent();
|
|
@@ -61,12 +61,12 @@ describe('lion-validation-feedback', () => {
|
|
|
61
61
|
await el.updateComplete;
|
|
62
62
|
|
|
63
63
|
const validationFeedbackType = el.shadowRoot?.querySelector('.validation-feedback__type');
|
|
64
|
-
expect(validationFeedbackType?.textContent?.trim()).to.equal('Error');
|
|
64
|
+
expect(validationFeedbackType?.textContent?.trim()).to.equal('Error,');
|
|
65
65
|
|
|
66
66
|
el.feedbackData = [{ message: 'hello', type: 'info', validator: new AlwaysInvalid() }];
|
|
67
67
|
await el.updateComplete;
|
|
68
68
|
|
|
69
|
-
expect(validationFeedbackType?.textContent?.trim()).to.equal('Info');
|
|
69
|
+
expect(validationFeedbackType?.textContent?.trim()).to.equal('Info,');
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it('it does not share the type if there is no message', async () => {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { LitElement } from 'lit';
|
|
2
|
-
import { aTimeout, defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
|
|
3
1
|
import {
|
|
4
|
-
getFormControlMembers,
|
|
5
|
-
AsyncAlwaysInvalid,
|
|
6
|
-
AsyncAlwaysValid,
|
|
7
2
|
AlwaysInvalid,
|
|
8
3
|
AlwaysValid,
|
|
4
|
+
AsyncAlwaysInvalid,
|
|
5
|
+
AsyncAlwaysValid,
|
|
6
|
+
getFormControlMembers,
|
|
9
7
|
} from '@lion/ui/form-core-test-helpers.js';
|
|
10
|
-
import sinon from 'sinon';
|
|
11
8
|
import {
|
|
12
|
-
ResultValidator,
|
|
13
|
-
ValidateMixin,
|
|
14
9
|
EqualsLength,
|
|
15
|
-
Unparseable,
|
|
16
10
|
MaxLength,
|
|
17
11
|
MinLength,
|
|
18
|
-
Validator,
|
|
19
12
|
Required,
|
|
13
|
+
ResultValidator,
|
|
14
|
+
Unparseable,
|
|
15
|
+
ValidateMixin,
|
|
16
|
+
Validator,
|
|
20
17
|
} from '@lion/ui/form-core.js';
|
|
18
|
+
import { aTimeout, defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
|
|
19
|
+
import { LitElement } from 'lit';
|
|
20
|
+
import sinon from 'sinon';
|
|
21
21
|
|
|
22
|
-
import '@lion/ui/define/lion-validation-feedback.js';
|
|
23
22
|
import '@lion/ui/define/lion-field.js';
|
|
23
|
+
import '@lion/ui/define/lion-validation-feedback.js';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @typedef {import('@lion/ui/form-core.js').LionField} LionField
|
|
@@ -631,6 +631,18 @@ export function runValidateMixinSuite(customConfig) {
|
|
|
631
631
|
isCatValidator.param = 'Garfield';
|
|
632
632
|
expect(catSpy.callCount).to.equal(2);
|
|
633
633
|
});
|
|
634
|
+
|
|
635
|
+
it('Validators will not be called on readOnly fields', async () => {
|
|
636
|
+
const el = /** @type {ValidateElement} */ (
|
|
637
|
+
await fixture(html`
|
|
638
|
+
<${tag} .validators=${[new IsCat()]}>${lightDom}</${tag}>
|
|
639
|
+
`)
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
el.readOnly = true;
|
|
643
|
+
el.modelValue = 'dog';
|
|
644
|
+
expect(el.validationStates.error.IsCat).to.be.undefined;
|
|
645
|
+
});
|
|
634
646
|
});
|
|
635
647
|
|
|
636
648
|
describe('Async Validator Integration', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: '
|
|
3
|
-
validationWarning: '
|
|
4
|
-
validationSuccess: '
|
|
5
|
-
validationInfo: '
|
|
2
|
+
validationError: 'Грешка,',
|
|
3
|
+
validationWarning: 'Предупреждение,',
|
|
4
|
+
validationSuccess: 'Успех,',
|
|
5
|
+
validationInfo: 'Информация,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Chyba',
|
|
3
|
-
validationWarning: '
|
|
4
|
-
validationSuccess: 'Úspěch',
|
|
5
|
-
validationInfo: 'Informace',
|
|
2
|
+
validationError: 'Chyba,',
|
|
3
|
+
validationWarning: 'Varování,',
|
|
4
|
+
validationSuccess: 'Úspěch,',
|
|
5
|
+
validationInfo: 'Informace,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Fehler',
|
|
3
|
-
validationWarning: 'Warnhinweis',
|
|
4
|
-
validationSuccess: 'Erfolgreich',
|
|
5
|
-
validationInfo: 'Info',
|
|
2
|
+
validationError: 'Fehler,',
|
|
3
|
+
validationWarning: 'Warnhinweis,',
|
|
4
|
+
validationSuccess: 'Erfolgreich,',
|
|
5
|
+
validationInfo: 'Info,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Error',
|
|
3
|
-
validationWarning: 'Advertencia',
|
|
4
|
-
validationSuccess: 'Satisfactorio',
|
|
5
|
-
validationInfo: 'Información',
|
|
2
|
+
validationError: 'Error,',
|
|
3
|
+
validationWarning: 'Advertencia,',
|
|
4
|
+
validationSuccess: 'Satisfactorio,',
|
|
5
|
+
validationInfo: 'Información,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Erreur',
|
|
3
|
-
validationWarning: 'Avertissement',
|
|
4
|
-
validationSuccess: 'Succès',
|
|
5
|
-
validationInfo: 'Info',
|
|
2
|
+
validationError: 'Erreur,',
|
|
3
|
+
validationWarning: 'Avertissement,',
|
|
4
|
+
validationSuccess: 'Succès,',
|
|
5
|
+
validationInfo: 'Info,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Hiba',
|
|
3
|
-
validationWarning: 'Figyelmeztetés',
|
|
4
|
-
validationSuccess: 'Sikeres',
|
|
5
|
-
validationInfo: '
|
|
2
|
+
validationError: 'Hiba,',
|
|
3
|
+
validationWarning: 'Figyelmeztetés,',
|
|
4
|
+
validationSuccess: 'Sikeres,',
|
|
5
|
+
validationInfo: 'Információ,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Errore',
|
|
3
|
-
validationWarning: 'Avvertenza',
|
|
4
|
-
validationSuccess: 'Operazione riuscita',
|
|
5
|
-
validationInfo: 'Info',
|
|
2
|
+
validationError: 'Errore,',
|
|
3
|
+
validationWarning: 'Avvertenza,',
|
|
4
|
+
validationSuccess: 'Operazione riuscita,',
|
|
5
|
+
validationInfo: 'Info,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Fout',
|
|
3
|
-
validationWarning: 'Waarschuwing',
|
|
4
|
-
validationSuccess: 'Succes',
|
|
5
|
-
validationInfo: 'Informatie',
|
|
2
|
+
validationError: 'Fout,',
|
|
3
|
+
validationWarning: 'Waarschuwing,',
|
|
4
|
+
validationSuccess: 'Succes,',
|
|
5
|
+
validationInfo: 'Informatie,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Błąd',
|
|
3
|
-
validationWarning: 'Ostrzeżenie',
|
|
4
|
-
validationSuccess: 'Zrealizowano pomyślnie',
|
|
5
|
-
validationInfo: 'Informacja',
|
|
2
|
+
validationError: 'Błąd,',
|
|
3
|
+
validationWarning: 'Ostrzeżenie,',
|
|
4
|
+
validationSuccess: 'Zrealizowano pomyślnie,',
|
|
5
|
+
validationInfo: 'Informacja,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Eroare',
|
|
3
|
-
validationWarning: 'Atenție',
|
|
4
|
-
validationSuccess: 'Succes',
|
|
5
|
-
validationInfo: 'Informații',
|
|
2
|
+
validationError: 'Eroare,',
|
|
3
|
+
validationWarning: 'Atenție,',
|
|
4
|
+
validationSuccess: 'Succes,',
|
|
5
|
+
validationInfo: 'Informații,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: '
|
|
3
|
-
validationWarning: '
|
|
4
|
-
validationSuccess: '
|
|
5
|
-
validationInfo: '
|
|
2
|
+
validationError: 'Ошибка,',
|
|
3
|
+
validationWarning: 'Предупреждение,',
|
|
4
|
+
validationSuccess: 'Успешно,',
|
|
5
|
+
validationInfo: 'Информация,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: 'Chyba',
|
|
3
|
-
validationWarning: 'Varovanie',
|
|
4
|
-
validationSuccess: '
|
|
5
|
-
validationInfo: 'Info',
|
|
2
|
+
validationError: 'Chyba,',
|
|
3
|
+
validationWarning: 'Varovanie,',
|
|
4
|
+
validationSuccess: 'Úspešné,',
|
|
5
|
+
validationInfo: 'Info,',
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
validationError: '
|
|
3
|
-
validationWarning: '
|
|
4
|
-
validationSuccess: '
|
|
5
|
-
validationInfo: '
|
|
2
|
+
validationError: 'Помилка,',
|
|
3
|
+
validationWarning: 'Попередження,',
|
|
4
|
+
validationSuccess: 'Успішно,',
|
|
5
|
+
validationInfo: 'Інформація,',
|
|
6
6
|
};
|
|
@@ -31,14 +31,15 @@ function round(value, decimals) {
|
|
|
31
31
|
* @param {FormatNumberOptions} [givenOptions] Locale Options
|
|
32
32
|
*/
|
|
33
33
|
export function parseAmount(value, givenOptions) {
|
|
34
|
-
const
|
|
34
|
+
const trimmedValue = value.trim();
|
|
35
|
+
const unmatchedInput = trimmedValue.match(/[^0-9,.\-\u2212 ]/g);
|
|
35
36
|
// for the full paste behavior documentation:
|
|
36
37
|
// ./docs/components/input-amount/use-cases.md#paste-behavior
|
|
37
38
|
if (unmatchedInput && givenOptions?.mode !== 'pasted') {
|
|
38
39
|
return undefined;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const number = parseNumber(
|
|
42
|
+
const number = parseNumber(trimmedValue, givenOptions);
|
|
42
43
|
|
|
43
44
|
if (typeof number !== 'number' || Number.isNaN(number)) {
|
|
44
45
|
return undefined;
|
|
@@ -61,6 +61,12 @@ describe('parseAmount()', async () => {
|
|
|
61
61
|
expect(parseAmount('EUR 1,50', { mode: 'pasted' })).to.equal(1.5);
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
+
it('trim spaces when "pasted" mode used', async () => {
|
|
65
|
+
// Use case: there is a cell in Excel which is formatted as Accounting, Currency: Zl, Decimal 2
|
|
66
|
+
// and the whole cell is copied
|
|
67
|
+
expect(parseAmount(' 1,00 zł ', { mode: 'pasted' })).to.equal(1);
|
|
68
|
+
});
|
|
69
|
+
|
|
64
70
|
it('parses based on locale when "user-edited" mode used combined with viewValueStates "formatted"', async () => {
|
|
65
71
|
expect(parseAmount('123,456.78', { mode: 'auto' })).to.equal(123456.78);
|
|
66
72
|
expect(
|
|
@@ -36,6 +36,10 @@ export const localizeNamespaceLoader = /** @param {string} locale */ locale => {
|
|
|
36
36
|
return import('@lion/ui/input-file-translations/hu-HU.js');
|
|
37
37
|
case 'hu':
|
|
38
38
|
return import('@lion/ui/input-file-translations/hu.js');
|
|
39
|
+
case 'id-ID':
|
|
40
|
+
return import('@lion/ui/input-file-translations/id-ID.js');
|
|
41
|
+
case 'id':
|
|
42
|
+
return import('@lion/ui/input-file-translations/id.js');
|
|
39
43
|
case 'it-IT':
|
|
40
44
|
return import('@lion/ui/input-file-translations/it-IT.js');
|
|
41
45
|
case 'it':
|
|
@@ -7,6 +7,11 @@ export default {
|
|
|
7
7
|
fileNameDescriptionLabel: 'Име на файл: ',
|
|
8
8
|
generalValidatorMessage: '"{validatorMessage}", за {listOfErroneousFiles}.',
|
|
9
9
|
noFilesSelected: 'Не са избрани файлове.',
|
|
10
|
+
noFilesUploaded: 'Няма качени файлове.',
|
|
11
|
+
fileSelected: 'Избрани файл: ',
|
|
12
|
+
fileUploaded: 'Качване на файл: ',
|
|
13
|
+
filesSelected: 'Избрани файлове: {numberOfFiles} файла.',
|
|
14
|
+
filesUploaded: 'Качени файлове: {numberOfFiles} файла.',
|
|
10
15
|
numberOfFiles: '{numberOfFiles} файла.',
|
|
11
16
|
removeButtonLabel: 'Отстраняване на файла {fileName}',
|
|
12
17
|
selectTextDuplicateFileName: 'Файл със същото име на файл вече е налице.',
|