@lion/ui 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/combobox/src/LionCombobox.js +35 -22
- package/components/combobox/test/lion-combobox.test.js +109 -66
- package/components/form/src/LionForm.js +11 -2
- package/components/form/test/lion-form.test.js +21 -2
- package/components/form-core/src/FormControlMixin.js +0 -9
- package/components/form-core/src/localizeNamespaceLoader.js +75 -0
- package/components/form-core/src/registration/FormRegisteringMixin.js +28 -0
- package/components/form-core/src/validate/LionValidationFeedback.js +36 -2
- package/components/form-core/test/validate/lion-validation-feedback.test.js +30 -2
- package/components/form-core/test-suites/FormRegistrationMixins.suite.js +17 -0
- package/components/form-core/test-suites/ValidateMixin.suite.js +1 -1
- package/components/form-core/translations/bg-BG.js +5 -0
- package/components/form-core/translations/bg.js +6 -0
- package/components/form-core/translations/cs-CZ.js +5 -0
- package/components/form-core/translations/cs.js +6 -0
- package/components/form-core/translations/de-DE.js +5 -0
- package/components/form-core/translations/de.js +6 -0
- package/components/form-core/translations/en-AU.js +5 -0
- package/components/form-core/translations/en-GB.js +5 -0
- package/components/form-core/translations/en-US.js +5 -0
- package/components/form-core/translations/en.js +6 -0
- package/components/form-core/translations/es-ES.js +5 -0
- package/components/form-core/translations/es.js +6 -0
- package/components/form-core/translations/fr-BE.js +5 -0
- package/components/form-core/translations/fr-FR.js +5 -0
- package/components/form-core/translations/fr.js +6 -0
- package/components/form-core/translations/hu-HU.js +5 -0
- package/components/form-core/translations/hu.js +6 -0
- package/components/form-core/translations/it-IT.js +5 -0
- package/components/form-core/translations/it.js +6 -0
- package/components/form-core/translations/nl-BE.js +5 -0
- package/components/form-core/translations/nl-NL.js +5 -0
- package/components/form-core/translations/nl.js +6 -0
- package/components/form-core/translations/pl-PL.js +5 -0
- package/components/form-core/translations/pl.js +6 -0
- package/components/form-core/translations/ro-RO.js +5 -0
- package/components/form-core/translations/ro.js +6 -0
- package/components/form-core/translations/ru-RU.js +5 -0
- package/components/form-core/translations/ru.js +6 -0
- package/components/form-core/translations/sk-SK.js +5 -0
- package/components/form-core/translations/sk.js +6 -0
- package/components/form-core/translations/uk-UA.js +5 -0
- package/components/form-core/translations/uk.js +6 -0
- package/components/form-core/translations/zh.js +6 -0
- package/components/form-core/types/FormControlMixinTypes.ts +0 -4
- package/components/form-core/types/registration/FormRegisteringMixinTypes.ts +17 -4
- package/components/input-amount/test/lion-input-amount.test.js +3 -0
- package/components/input-file/src/LionInputFile.js +88 -30
- package/components/input-file/test/lion-input-file.test.js +102 -6
- package/components/input-file/test/lion-selected-file-list.test.js +2 -1
- package/components/input-file/translations/bg.js +3 -0
- package/components/input-file/translations/cs.js +3 -0
- package/components/input-file/translations/de.js +3 -0
- package/components/input-file/translations/en.js +3 -0
- package/components/input-file/translations/es.js +3 -0
- package/components/input-file/translations/fr.js +3 -0
- package/components/input-file/translations/hu.js +3 -0
- package/components/input-file/translations/it.js +3 -0
- package/components/input-file/translations/nl.js +3 -0
- package/components/input-file/translations/pl.js +3 -0
- package/components/input-file/translations/ro.js +3 -0
- package/components/input-file/translations/ru.js +3 -0
- package/components/input-file/translations/sk.js +3 -0
- package/components/input-file/translations/uk.js +3 -0
- package/components/input-file/translations/zh.js +3 -0
- package/components/overlays/src/OverlayMixin.js +8 -1
- package/components/switch/src/LionSwitch.js +10 -0
- package/components/tabs/src/LionTabs.js +10 -0
- package/components/tabs/test/lion-tabs.test.js +49 -38
- package/custom-elements.json +85378 -74680
- package/dist-types/components/combobox/src/LionCombobox.d.ts +12 -8
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/form/src/LionForm.d.ts.map +1 -1
- package/dist-types/components/form/test/lion-form.test.d.ts.map +1 -1
- package/dist-types/components/form-core/src/FormControlMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/LionField.d.ts +1 -1
- package/dist-types/components/form-core/src/localizeNamespaceLoader.d.ts +2 -0
- package/dist-types/components/form-core/src/localizeNamespaceLoader.d.ts.map +1 -0
- package/dist-types/components/form-core/src/registration/FormRegisteringMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts +5 -6
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts.map +1 -1
- package/dist-types/components/form-core/test-suites/FormRegistrationMixins.suite.d.ts.map +1 -1
- package/dist-types/components/form-core/translations/bg-BG.d.ts +8 -0
- package/dist-types/components/form-core/translations/bg-BG.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/bg.d.ts +8 -0
- package/dist-types/components/form-core/translations/bg.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/cs-CZ.d.ts +8 -0
- package/dist-types/components/form-core/translations/cs-CZ.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/cs.d.ts +8 -0
- package/dist-types/components/form-core/translations/cs.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/de-DE.d.ts +8 -0
- package/dist-types/components/form-core/translations/de-DE.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/de.d.ts +8 -0
- package/dist-types/components/form-core/translations/de.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/en-AU.d.ts +8 -0
- package/dist-types/components/form-core/translations/en-AU.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/en-GB.d.ts +8 -0
- package/dist-types/components/form-core/translations/en-GB.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/en-US.d.ts +8 -0
- package/dist-types/components/form-core/translations/en-US.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/en.d.ts +8 -0
- package/dist-types/components/form-core/translations/en.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/es-ES.d.ts +8 -0
- package/dist-types/components/form-core/translations/es-ES.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/es.d.ts +8 -0
- package/dist-types/components/form-core/translations/es.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/fr-BE.d.ts +8 -0
- package/dist-types/components/form-core/translations/fr-BE.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/fr-FR.d.ts +8 -0
- package/dist-types/components/form-core/translations/fr-FR.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/fr.d.ts +8 -0
- package/dist-types/components/form-core/translations/fr.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/hu-HU.d.ts +8 -0
- package/dist-types/components/form-core/translations/hu-HU.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/hu.d.ts +8 -0
- package/dist-types/components/form-core/translations/hu.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/it-IT.d.ts +8 -0
- package/dist-types/components/form-core/translations/it-IT.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/it.d.ts +8 -0
- package/dist-types/components/form-core/translations/it.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/nl-BE.d.ts +8 -0
- package/dist-types/components/form-core/translations/nl-BE.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/nl-NL.d.ts +8 -0
- package/dist-types/components/form-core/translations/nl-NL.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/nl.d.ts +8 -0
- package/dist-types/components/form-core/translations/nl.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/pl-PL.d.ts +8 -0
- package/dist-types/components/form-core/translations/pl-PL.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/pl.d.ts +8 -0
- package/dist-types/components/form-core/translations/pl.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/ro-RO.d.ts +8 -0
- package/dist-types/components/form-core/translations/ro-RO.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/ro.d.ts +8 -0
- package/dist-types/components/form-core/translations/ro.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/ru-RU.d.ts +8 -0
- package/dist-types/components/form-core/translations/ru-RU.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/ru.d.ts +8 -0
- package/dist-types/components/form-core/translations/ru.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/sk-SK.d.ts +8 -0
- package/dist-types/components/form-core/translations/sk-SK.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/sk.d.ts +8 -0
- package/dist-types/components/form-core/translations/sk.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/uk-UA.d.ts +8 -0
- package/dist-types/components/form-core/translations/uk-UA.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/uk.d.ts +8 -0
- package/dist-types/components/form-core/translations/uk.d.ts.map +1 -0
- package/dist-types/components/form-core/translations/zh.d.ts +8 -0
- package/dist-types/components/form-core/translations/zh.d.ts.map +1 -0
- package/dist-types/components/form-core/types/FormControlMixinTypes.d.ts +0 -4
- package/dist-types/components/form-core/types/FormControlMixinTypes.d.ts.map +1 -1
- package/dist-types/components/form-core/types/registration/FormRegisteringMixinTypes.d.ts +14 -4
- package/dist-types/components/form-core/types/registration/FormRegisteringMixinTypes.d.ts.map +1 -1
- package/dist-types/components/input-file/src/LionInputFile.d.ts +12 -6
- package/dist-types/components/input-file/src/LionInputFile.d.ts.map +1 -1
- package/dist-types/components/input-file/translations/bg-BG.d.ts +3 -0
- package/dist-types/components/input-file/translations/bg.d.ts +3 -0
- package/dist-types/components/input-file/translations/cs-CZ.d.ts +3 -0
- package/dist-types/components/input-file/translations/cs.d.ts +3 -0
- package/dist-types/components/input-file/translations/de-DE.d.ts +3 -0
- package/dist-types/components/input-file/translations/de.d.ts +3 -0
- package/dist-types/components/input-file/translations/en-AU.d.ts +3 -0
- package/dist-types/components/input-file/translations/en-GB.d.ts +3 -0
- package/dist-types/components/input-file/translations/en-PH.d.ts +3 -0
- package/dist-types/components/input-file/translations/en-US.d.ts +3 -0
- package/dist-types/components/input-file/translations/en.d.ts +3 -0
- package/dist-types/components/input-file/translations/es-ES.d.ts +3 -0
- package/dist-types/components/input-file/translations/es.d.ts +3 -0
- package/dist-types/components/input-file/translations/fr-BE.d.ts +3 -0
- package/dist-types/components/input-file/translations/fr-FR.d.ts +3 -0
- package/dist-types/components/input-file/translations/fr.d.ts +3 -0
- package/dist-types/components/input-file/translations/hu-HU.d.ts +3 -0
- package/dist-types/components/input-file/translations/hu.d.ts +3 -0
- package/dist-types/components/input-file/translations/it-IT.d.ts +3 -0
- package/dist-types/components/input-file/translations/it.d.ts +3 -0
- package/dist-types/components/input-file/translations/nl-BE.d.ts +3 -0
- package/dist-types/components/input-file/translations/nl-NL.d.ts +3 -0
- package/dist-types/components/input-file/translations/nl.d.ts +3 -0
- package/dist-types/components/input-file/translations/pl-PL.d.ts +3 -0
- package/dist-types/components/input-file/translations/pl.d.ts +3 -0
- package/dist-types/components/input-file/translations/ro-RO.d.ts +3 -0
- package/dist-types/components/input-file/translations/ro.d.ts +3 -0
- package/dist-types/components/input-file/translations/ru-RU.d.ts +3 -0
- package/dist-types/components/input-file/translations/ru.d.ts +3 -0
- package/dist-types/components/input-file/translations/sk-SK.d.ts +3 -0
- package/dist-types/components/input-file/translations/sk.d.ts +3 -0
- package/dist-types/components/input-file/translations/uk-UA.d.ts +3 -0
- package/dist-types/components/input-file/translations/uk.d.ts +3 -0
- package/dist-types/components/input-file/translations/zh-CN.d.ts +3 -0
- package/dist-types/components/input-file/translations/zh.d.ts +3 -0
- package/dist-types/components/listbox/src/LionOption.d.ts +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/switch/src/LionSwitch.d.ts.map +1 -1
- package/dist-types/components/tabs/src/LionTabs.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/api-table.md +31 -0
- package/docs/components/button/api-table.md +104 -0
- package/docs/components/calendar/api-table.md +44 -0
- package/docs/components/checkbox-group/api-table.md +564 -0
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/api-table.md +36 -0
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/api-table.md +256 -0
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/api-table.md +45 -0
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/drawer/api-table.md +45 -0
- package/docs/components/fieldset/api-table.md +163 -0
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/api-table.md +1 -0
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/api-table.md +29 -0
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/api-table.md +187 -0
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/api-table.md +196 -0
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/api-table.md +188 -0
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/api-table.md +234 -0
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/api-table.md +187 -0
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-file/api-table.md +272 -0
- package/docs/components/input-file/overview.md +1 -1
- package/docs/components/input-iban/api-table.md +187 -0
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/api-table.md +198 -0
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/api-table.md +205 -0
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/api-table.md +202 -0
- 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/api-table.md +213 -0
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/listbox/api-table.md +293 -0
- package/docs/components/listbox/use-cases.md +1 -1
- package/docs/components/pagination/api-table.md +33 -0
- package/docs/components/progress-indicator/api-table.md +36 -0
- package/docs/components/radio-group/api-table.md +378 -0
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select/api-table.md +181 -0
- package/docs/components/select/use-cases.md +1 -1
- package/docs/components/select-rich/api-table.md +288 -0
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/steps/api-table.md +80 -0
- package/docs/components/switch/api-table.md +229 -0
- package/docs/components/tabs/api-table.md +32 -0
- package/docs/components/tabs/examples.md +1 -1
- package/docs/components/textarea/api-table.md +192 -0
- package/docs/components/tooltip/api-table.md +53 -0
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
- package/docs/fundamentals/systems/core/api-table.md +34 -0
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/api-table.md +166 -0
- 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 +2 -2
- package/docs/fundamentals/systems/localize/api-table.md +65 -0
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/api-table.md +168 -0
- 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/package.json +5 -4
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { html, LitElement } from 'lit';
|
|
1
|
+
import { css, html, LitElement } from 'lit';
|
|
2
|
+
import { LocalizeMixin } from '@lion/ui/localize-no-side-effects.js';
|
|
3
|
+
import { localizeNamespaceLoader } from '../localizeNamespaceLoader.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @typedef {import('./Validator.js').Validator} Validator
|
|
@@ -6,17 +8,46 @@ import { html, LitElement } from 'lit';
|
|
|
6
8
|
* @typedef {import('../../types/validate/ValidateMixinTypes.js').FeedbackMessage} FeedbackMessage
|
|
7
9
|
*/
|
|
8
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} string
|
|
13
|
+
*/
|
|
14
|
+
const capitalize = string => `${string[0].toUpperCase()}${string.slice(1)}`;
|
|
15
|
+
|
|
9
16
|
/**
|
|
10
17
|
* @desc Takes care of accessible rendering of error messages
|
|
11
18
|
* Should be used in conjunction with FormControl having ValidateMixin applied
|
|
12
19
|
*/
|
|
13
|
-
export class LionValidationFeedback extends LitElement {
|
|
20
|
+
export class LionValidationFeedback extends LocalizeMixin(LitElement) {
|
|
14
21
|
static get properties() {
|
|
15
22
|
return {
|
|
16
23
|
feedbackData: { attribute: false },
|
|
17
24
|
};
|
|
18
25
|
}
|
|
19
26
|
|
|
27
|
+
static localizeNamespaces = [
|
|
28
|
+
{ 'lion-form-core': localizeNamespaceLoader },
|
|
29
|
+
...super.localizeNamespaces,
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
static get styles() {
|
|
33
|
+
return [
|
|
34
|
+
css`
|
|
35
|
+
.validation-feedback__type {
|
|
36
|
+
position: absolute;
|
|
37
|
+
width: 1px;
|
|
38
|
+
height: 1px;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
clip-path: inset(100%);
|
|
41
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
border: 0;
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
20
51
|
/**
|
|
21
52
|
* @overridable
|
|
22
53
|
* @param {Object} opts
|
|
@@ -58,6 +89,9 @@ export class LionValidationFeedback extends LitElement {
|
|
|
58
89
|
${this.feedbackData &&
|
|
59
90
|
this.feedbackData.map(
|
|
60
91
|
({ message, type, validator }) => html`
|
|
92
|
+
<div class="validation-feedback__type">
|
|
93
|
+
${this._localizeManager.msg(`lion-form-core:validation${capitalize(type)}`)}
|
|
94
|
+
</div>
|
|
61
95
|
${this._messageTemplate({ message, type, validator })}
|
|
62
96
|
`,
|
|
63
97
|
)}
|
|
@@ -14,10 +14,10 @@ describe('lion-validation-feedback', () => {
|
|
|
14
14
|
const el = /** @type {LionValidationFeedback} */ (
|
|
15
15
|
await fixture(html`<lion-validation-feedback></lion-validation-feedback>`)
|
|
16
16
|
);
|
|
17
|
-
expect(el).
|
|
17
|
+
expect(el.shadowRoot?.textContent).to.not.include('hello');
|
|
18
18
|
el.feedbackData = [{ message: 'hello', type: 'error', validator: new AlwaysInvalid() }];
|
|
19
19
|
await el.updateComplete;
|
|
20
|
-
expect(el).
|
|
20
|
+
expect(el.shadowRoot?.textContent).to.include('hello');
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('renders the validation type attribute', async () => {
|
|
@@ -73,4 +73,32 @@ describe('lion-validation-feedback', () => {
|
|
|
73
73
|
|
|
74
74
|
clock.restore();
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
it('shares to the user the type of validation feedback', async () => {
|
|
78
|
+
const el = /** @type {LionValidationFeedback} */ (
|
|
79
|
+
await fixture(html`<lion-validation-feedback></lion-validation-feedback>`)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
el.feedbackData = [{ message: 'hello', type: 'error', validator: new AlwaysInvalid() }];
|
|
83
|
+
await el.updateComplete;
|
|
84
|
+
|
|
85
|
+
const validationFeedbackType = el.shadowRoot?.querySelector('.validation-feedback__type');
|
|
86
|
+
expect(validationFeedbackType?.textContent?.trim()).to.equal('Error');
|
|
87
|
+
|
|
88
|
+
el.feedbackData = [{ message: 'hello', type: 'info', validator: new AlwaysInvalid() }];
|
|
89
|
+
await el.updateComplete;
|
|
90
|
+
|
|
91
|
+
expect(validationFeedbackType?.textContent?.trim()).to.equal('Info');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('accessibility', () => {
|
|
95
|
+
it('passes a11y audit when with a message', async () => {
|
|
96
|
+
const el = /** @type {LionValidationFeedback} */ (
|
|
97
|
+
await fixture(html`<lion-validation-feedback></lion-validation-feedback>`)
|
|
98
|
+
);
|
|
99
|
+
el.feedbackData = [{ message: 'hello', type: 'error', validator: new AlwaysInvalid() }];
|
|
100
|
+
await el.updateComplete;
|
|
101
|
+
await expect(el).to.be.accessible();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
76
104
|
});
|
|
@@ -310,6 +310,23 @@ export const runRegistrationSuite = customConfig => {
|
|
|
310
310
|
expect(eventSpy).to.have.been.calledOnce;
|
|
311
311
|
expect(eventSpy.getCall(0).args[0].composed).to.equal(false);
|
|
312
312
|
});
|
|
313
|
+
it('accepts a name attribute and converts the values provided to a string', async () => {
|
|
314
|
+
const elAttr = /** @type {RegisteringClass} */ (
|
|
315
|
+
await fixture(html`<${childTag} name=${5}></${childTag}>`)
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
expect(elAttr.hasAttribute('name')).to.be.true;
|
|
319
|
+
expect(elAttr.name).to.be.a('string');
|
|
320
|
+
expect(elAttr.name).to.equal('5', 'as an attribute');
|
|
321
|
+
|
|
322
|
+
const elProp = /** @type {RegisteringClass} */ (
|
|
323
|
+
await fixture(html`<${childTag} .name=${5}></${childTag}>`)
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
expect(elProp.hasAttribute('name')).to.be.true;
|
|
327
|
+
expect(elProp.name).to.be.a('string');
|
|
328
|
+
expect(elProp.name).to.equal('5', 'as a property');
|
|
329
|
+
});
|
|
313
330
|
});
|
|
314
331
|
describe('FormRegistrarPortalMixin', () => {
|
|
315
332
|
it('forwards registrations to the .registrationTarget', async () => {
|
|
@@ -800,7 +800,7 @@ export function runValidateMixinSuite(customConfig) {
|
|
|
800
800
|
expect(el.hasFeedbackFor).to.deep.equal(['error']);
|
|
801
801
|
const { _feedbackNode } = getFormControlMembers(el);
|
|
802
802
|
await el.updateComplete;
|
|
803
|
-
await
|
|
803
|
+
await _feedbackNode.updateComplete;
|
|
804
804
|
const messageHtmlNode = _feedbackNode.shadowRoot?.querySelector(`#${messageHtmlId}`);
|
|
805
805
|
expect(messageHtmlNode?.outerHTML).to.equal(messageHtml);
|
|
806
806
|
expect(messageHtmlNode?.tagName).to.equal('DIV');
|
|
@@ -43,10 +43,6 @@ export declare interface HTMLElementWithValue extends HTMLElement {
|
|
|
43
43
|
export declare class FormControlHost {
|
|
44
44
|
static get styles(): CSSResultArray;
|
|
45
45
|
static get properties(): {
|
|
46
|
-
name: {
|
|
47
|
-
type: StringConstructor;
|
|
48
|
-
reflect: boolean;
|
|
49
|
-
};
|
|
50
46
|
readOnly: {
|
|
51
47
|
type: BooleanConstructor;
|
|
52
48
|
attribute: string;
|
|
@@ -4,10 +4,13 @@ import { LitElement } from 'lit';
|
|
|
4
4
|
import { FormRegistrarHost } from './FormRegistrarMixinTypes.js';
|
|
5
5
|
|
|
6
6
|
export declare class FormRegisteringHost {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
static get properties(): {
|
|
8
|
+
name: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
reflect: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* To encourage accessibility best practices, `form-element-register` events
|
|
13
16
|
* do not pierce through shadow roots. This forces the developer to create form groups and fieldsets that
|
|
@@ -17,12 +20,22 @@ export declare class FormRegisteringHost {
|
|
|
17
20
|
*/
|
|
18
21
|
allowCrossRootRegistration: boolean;
|
|
19
22
|
|
|
23
|
+
/**
|
|
24
|
+
* The name the element will be registered with to the .formElements collection
|
|
25
|
+
* of the parent. Also, it serves as the key of key/value pairs in
|
|
26
|
+
* modelValue/serializedValue objects
|
|
27
|
+
*/
|
|
28
|
+
get name(): string;
|
|
29
|
+
set name(arg: any);
|
|
30
|
+
|
|
20
31
|
/**
|
|
21
32
|
* The registrar this FormControl registers to, Usually a descendant of FormGroup or
|
|
22
33
|
* ChoiceGroup
|
|
23
34
|
*/
|
|
24
35
|
protected _parentFormGroup: FormRegistrarHost | undefined;
|
|
25
36
|
|
|
37
|
+
private __name: string;
|
|
38
|
+
|
|
26
39
|
private __unregisterFormElement: void;
|
|
27
40
|
}
|
|
28
41
|
|
|
@@ -195,6 +195,9 @@ describe('<lion-input-amount>', () => {
|
|
|
195
195
|
expect(el.formattedValue).to.equal('123.45');
|
|
196
196
|
localize.locale = 'nl-NL';
|
|
197
197
|
await el.updateComplete;
|
|
198
|
+
// TODO find out why the localize needs to be loaded for the feedbackNode
|
|
199
|
+
// @ts-ignore [allow-protected] in test
|
|
200
|
+
await el._feedbackNode.localizeNamespacesLoaded;
|
|
198
201
|
expect(el.formattedValue).to.equal('123,45');
|
|
199
202
|
});
|
|
200
203
|
|
|
@@ -77,6 +77,7 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
77
77
|
>
|
|
78
78
|
${this.buttonLabel}
|
|
79
79
|
</button>`,
|
|
80
|
+
after: () => html`<div data-description></div>`,
|
|
80
81
|
'selected-file-list': () => ({
|
|
81
82
|
template: html`
|
|
82
83
|
<lion-selected-file-list
|
|
@@ -105,8 +106,7 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/**
|
|
108
|
-
* The
|
|
109
|
-
* When no light dom defined via [slot=help-text], this value will be used
|
|
109
|
+
* The label of the button
|
|
110
110
|
* @type {string}
|
|
111
111
|
*/
|
|
112
112
|
get buttonLabel() {
|
|
@@ -176,6 +176,11 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
176
176
|
|
|
177
177
|
/** @private */
|
|
178
178
|
this.__duplicateFileNamesValidator = new DuplicateFileNames({ show: false });
|
|
179
|
+
/**
|
|
180
|
+
* @private
|
|
181
|
+
* @type {FileList | null}
|
|
182
|
+
*/
|
|
183
|
+
this.__previouslyParsedFiles = null;
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
/**
|
|
@@ -283,8 +288,20 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
283
288
|
* @returns {InputFile[]} parsedValue
|
|
284
289
|
*/
|
|
285
290
|
parser() {
|
|
286
|
-
//
|
|
287
|
-
|
|
291
|
+
// parser is called twice for one user event; one for 'user-input-change', another for 'change'
|
|
292
|
+
if (this.__previouslyParsedFiles === this._inputNode.files) {
|
|
293
|
+
return this.modelValue;
|
|
294
|
+
}
|
|
295
|
+
this.__previouslyParsedFiles = this._inputNode.files;
|
|
296
|
+
|
|
297
|
+
const files = this._inputNode.files
|
|
298
|
+
? /** @type {InputFile[]} */ (Array.from(this._inputNode.files))
|
|
299
|
+
: [];
|
|
300
|
+
if (this.multiple) {
|
|
301
|
+
return [...(this.modelValue ?? []), ...files];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return files;
|
|
288
305
|
}
|
|
289
306
|
|
|
290
307
|
/**
|
|
@@ -332,8 +349,6 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
332
349
|
super.firstUpdated(changedProperties);
|
|
333
350
|
|
|
334
351
|
this.__setupFileValidators();
|
|
335
|
-
// We need to update our light dom
|
|
336
|
-
this._enhanceSelectedList();
|
|
337
352
|
|
|
338
353
|
// TODO: if there's no inputNode by now, we should either throw an error or add a slot change listener
|
|
339
354
|
if (this._inputNode) {
|
|
@@ -443,6 +458,7 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
443
458
|
this._selectedFilesMetaData = [...this._selectedFilesMetaData];
|
|
444
459
|
}
|
|
445
460
|
});
|
|
461
|
+
this._updateUploadButtonDescription();
|
|
446
462
|
}
|
|
447
463
|
}
|
|
448
464
|
|
|
@@ -482,16 +498,17 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
482
498
|
}
|
|
483
499
|
|
|
484
500
|
this._inputNode.files = ev.dataTransfer.files;
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
501
|
+
|
|
502
|
+
if (this.multiple) {
|
|
503
|
+
const computedFiles = this.__computeNewAddedFiles(
|
|
504
|
+
/** @type {InputFile[]} */ (Array.from(ev.dataTransfer.files)),
|
|
505
|
+
);
|
|
506
|
+
this.modelValue = [...(this.modelValue ?? []), ...computedFiles];
|
|
507
|
+
} else {
|
|
508
|
+
this.modelValue = /** @type {InputFile[]} */ (Array.from(ev.dataTransfer.files));
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
this._processFiles(/** @type {InputFile[]} */ (Array.from(ev.dataTransfer.files)));
|
|
495
512
|
}
|
|
496
513
|
|
|
497
514
|
/**
|
|
@@ -521,20 +538,6 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
521
538
|
ev.target.value = ''; // eslint-disable-line no-param-reassign
|
|
522
539
|
}
|
|
523
540
|
|
|
524
|
-
/**
|
|
525
|
-
* @protected
|
|
526
|
-
*/
|
|
527
|
-
_enhanceSelectedList() {
|
|
528
|
-
/**
|
|
529
|
-
* @type {LionSelectedFileList | null}
|
|
530
|
-
*/
|
|
531
|
-
const selectedFileList = this.querySelector('[slot="selected-file-list"]');
|
|
532
|
-
if (selectedFileList) {
|
|
533
|
-
selectedFileList.setAttribute('id', `selected-file-list-${this._inputId}`);
|
|
534
|
-
this.addToAriaDescribedBy(selectedFileList, { idPrefix: 'selected-file-list' });
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
541
|
/**
|
|
539
542
|
* @protected
|
|
540
543
|
*/
|
|
@@ -739,6 +742,46 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
739
742
|
fileObj.validationFeedback?.push(errorObj);
|
|
740
743
|
}
|
|
741
744
|
|
|
745
|
+
/**
|
|
746
|
+
* Description for screen readers connected to the button about how many files have been updated
|
|
747
|
+
* @protected
|
|
748
|
+
*/
|
|
749
|
+
_updateUploadButtonDescription() {
|
|
750
|
+
const erroneousFilesNames = /** @type {string[]} */ ([]);
|
|
751
|
+
let errorMessage;
|
|
752
|
+
|
|
753
|
+
this._selectedFilesMetaData.forEach(file => {
|
|
754
|
+
if (file.status === 'FAIL') {
|
|
755
|
+
errorMessage = file.validationFeedback ? file.validationFeedback[0].message.toString() : '';
|
|
756
|
+
erroneousFilesNames.push(/** @type {string} */ (file.systemFile.name));
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
const selectedFiles = this.querySelector('[slot="after"]');
|
|
761
|
+
if (selectedFiles) {
|
|
762
|
+
if (!this._selectedFilesMetaData || this._selectedFilesMetaData.length === 0) {
|
|
763
|
+
selectedFiles.textContent = /** @type {string} */ (
|
|
764
|
+
this.msgLit('lion-input-file:noFilesSelected')
|
|
765
|
+
);
|
|
766
|
+
} else if (this._selectedFilesMetaData.length === 1) {
|
|
767
|
+
selectedFiles.textContent = /** @type {string} */ (
|
|
768
|
+
errorMessage || this._selectedFilesMetaData[0].systemFile.name
|
|
769
|
+
);
|
|
770
|
+
} else {
|
|
771
|
+
selectedFiles.textContent = `${this.msgLit('lion-input-file:numberOfFiles', {
|
|
772
|
+
numberOfFiles: this._selectedFilesMetaData.length,
|
|
773
|
+
})} ${
|
|
774
|
+
errorMessage
|
|
775
|
+
? this.msgLit('lion-input-file:generalValidatorMessage', {
|
|
776
|
+
validatorMessage: errorMessage,
|
|
777
|
+
listOfErroneousFiles: erroneousFilesNames.join(', '),
|
|
778
|
+
})
|
|
779
|
+
: ''
|
|
780
|
+
}`;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
742
785
|
/**
|
|
743
786
|
* @private
|
|
744
787
|
* @param {InputFile} removedFile
|
|
@@ -755,6 +798,7 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
755
798
|
}
|
|
756
799
|
this._inputNode.value = '';
|
|
757
800
|
this._handleErrors();
|
|
801
|
+
this._updateUploadButtonDescription();
|
|
758
802
|
}
|
|
759
803
|
|
|
760
804
|
/**
|
|
@@ -847,6 +891,7 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
847
891
|
_inputGroupInputTemplate() {
|
|
848
892
|
return html`
|
|
849
893
|
<slot name="input"> </slot>
|
|
894
|
+
<slot name="after"> </slot>
|
|
850
895
|
${this.enableDropZone && this._isDragAndDropSupported
|
|
851
896
|
? this._dropZoneTemplate()
|
|
852
897
|
: html`
|
|
@@ -891,6 +936,19 @@ export class LionInputFile extends ScopedElementsMixin(LocalizeMixin(LionField))
|
|
|
891
936
|
border: dashed 2px black;
|
|
892
937
|
padding: 24px 0;
|
|
893
938
|
}
|
|
939
|
+
|
|
940
|
+
.input-group__container ::slotted([slot='after']) {
|
|
941
|
+
position: absolute;
|
|
942
|
+
width: 1px;
|
|
943
|
+
height: 1px;
|
|
944
|
+
overflow: hidden;
|
|
945
|
+
clip-path: inset(100%);
|
|
946
|
+
clip: rect(1px, 1px, 1px, 1px);
|
|
947
|
+
white-space: nowrap;
|
|
948
|
+
border: 0;
|
|
949
|
+
margin: 0;
|
|
950
|
+
padding: 0;
|
|
951
|
+
}
|
|
894
952
|
`,
|
|
895
953
|
];
|
|
896
954
|
}
|