@lion/ui 0.8.3 → 0.8.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/core/src/ScopedElementsMixin.js +3 -3
- package/components/form-core/src/FormControlMixin.js +1 -1
- package/components/form-core/src/validate/ValidateMixin.js +9 -4
- package/components/form-core/src/validate/Validator.js +17 -3
- package/components/form-core/test/validate/Validator.test.js +8 -0
- package/custom-elements.json +477 -1
- package/dist-types/components/core/src/ScopedElementsMixin.d.ts +4 -4
- package/dist-types/components/form-core/src/validate/ValidateMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/Validator.d.ts +16 -6
- package/dist-types/components/form-core/src/validate/Validator.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +1 -1
- package/dist-types/components/input-file/src/LionInputFile.d.ts +1 -1
- package/dist-types/components/input-file/src/LionSelectedFileList.d.ts +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +1 -1
- package/dist-types/components/switch/src/LionSwitch.d.ts +1 -1
- package/dist-types/exports/types/form-core.d.ts +1 -0
- package/dist-types/exports/types/form-core.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- 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/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/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/select/use-cases.md +61 -1
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- 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/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 +2 -2
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- 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/ajax/overview.md +22 -1
- 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/types/form-core.ts +1 -0
- package/package.json +1 -1
|
@@ -21,9 +21,9 @@ export function supportsScopedRegistry() {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* This file is combination of '@open-wc/scoped-elements@v3/lit-element.js' and '@open-wc/scoped-elements@v3/html-element.js'.
|
|
25
|
-
*
|
|
26
|
-
* This can be a great help for ssr scenarios, allowing elements to be consumed without needing knowledge about
|
|
24
|
+
* This file is a combination of '@open-wc/scoped-elements@v3/lit-element.js' and '@open-wc/scoped-elements@v3/html-element.js'.
|
|
25
|
+
* To make the polyfill an opt-in, some code from '@open-wc/scoped-elements@v2' is added as well.
|
|
26
|
+
* This can be a great help for ssr scenarios, allowing elements to be consumed without needing knowledge about internal
|
|
27
27
|
* consumption.
|
|
28
28
|
* (N.B. at this point in time, this is limited to the scenario where there's one version of lion on the page).
|
|
29
29
|
*
|
|
@@ -274,7 +274,7 @@ const FormControlMixinImplementation = superclass =>
|
|
|
274
274
|
super.updated(changedProperties);
|
|
275
275
|
|
|
276
276
|
if (changedProperties.has('disabled')) {
|
|
277
|
-
this._inputNode?.setAttribute('aria-disabled', this.disabled
|
|
277
|
+
this._inputNode?.setAttribute('aria-disabled', `${Boolean(this.disabled)}`);
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
if (changedProperties.has('_ariaLabelledNodes')) {
|
|
@@ -10,10 +10,10 @@ import { SyncUpdatableMixin } from '../utils/SyncUpdatableMixin.js';
|
|
|
10
10
|
import { LionValidationFeedback } from './LionValidationFeedback.js';
|
|
11
11
|
import { ResultValidator as MetaValidator } from './ResultValidator.js';
|
|
12
12
|
import { Unparseable } from './Unparseable.js';
|
|
13
|
-
import { Validator } from './Validator.js';
|
|
14
13
|
import { Required } from './validators/Required.js';
|
|
15
14
|
import { FormControlMixin } from '../FormControlMixin.js';
|
|
16
|
-
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
16
|
+
import { Validator } from './Validator.js';
|
|
17
17
|
// TODO: [v1] make all @readOnly => @readonly and actually make sure those values cannot be set
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -460,7 +460,9 @@ export const ValidateMixinImplementation = superclass =>
|
|
|
460
460
|
|
|
461
461
|
if (isEmpty) {
|
|
462
462
|
const hasSingleValue = !(/** @type {* & ValidateHost} */ (this)._isFormOrFieldset);
|
|
463
|
-
const requiredValidator = this._allValidators.find(
|
|
463
|
+
const requiredValidator = this._allValidators.find(
|
|
464
|
+
v => /** @type {typeof Validator} */ (v.constructor)?.validatorName === 'Required',
|
|
465
|
+
);
|
|
464
466
|
if (requiredValidator) {
|
|
465
467
|
this.__syncValidationResult = [{ validator: requiredValidator, outcome: true }];
|
|
466
468
|
}
|
|
@@ -685,7 +687,10 @@ export const ValidateMixinImplementation = superclass =>
|
|
|
685
687
|
}
|
|
686
688
|
|
|
687
689
|
for (const validatorToSetup of this._allValidators) {
|
|
688
|
-
|
|
690
|
+
// disable dot notation to avoid the renaming for the prop during build/minification
|
|
691
|
+
const validatorCtor = /** @type {typeof Validator} */ (validatorToSetup.constructor);
|
|
692
|
+
// eslint-disable-next-line dot-notation
|
|
693
|
+
if (validatorCtor['_$isValidator$'] === undefined) {
|
|
689
694
|
// throws in constructor are not visible to end user so we do both
|
|
690
695
|
const errorType = Array.isArray(validatorToSetup) ? 'array' : typeof validatorToSetup;
|
|
691
696
|
const errorMessage = `Validators array only accepts class instances of Validator. Type "${errorType}" found. This may be caused by having multiple installations of "@lion/ui/form-core.js".`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../../types/validate/index.js').FeedbackMessageData} FeedbackMessageData
|
|
3
|
-
* @typedef {import('../../types/validate/index.js').ValidatorParam} ValidatorParam
|
|
4
|
-
* @typedef {import('../../types/validate/index.js').ValidatorConfig} ValidatorConfig
|
|
5
3
|
* @typedef {import('../../types/validate/index.js').ValidatorOutcome} ValidatorOutcome
|
|
6
|
-
* @typedef {import('../../types/validate/index.js').
|
|
4
|
+
* @typedef {import('../../types/validate/index.js').ValidatorConfig} ValidatorConfig
|
|
5
|
+
* @typedef {import('../../types/validate/index.js').ValidatorParam} ValidatorParam
|
|
7
6
|
* @typedef {import('../../types/validate/index.js').ValidationType} ValidationType
|
|
7
|
+
* @typedef {import('../../types/validate/index.js').ValidatorName} ValidatorName
|
|
8
8
|
* @typedef {import('../FormControlMixin.js').FormControlHost} FormControlHost
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -32,8 +32,22 @@ export class Validator extends EventTarget {
|
|
|
32
32
|
* @type {ValidationType}
|
|
33
33
|
*/
|
|
34
34
|
this.type = config?.type || 'error';
|
|
35
|
+
/**
|
|
36
|
+
* Disable dot notation to avoid the renaming for the prop during build/minification
|
|
37
|
+
*/
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
/**
|
|
41
|
+
* This unique marker allows us to identify Validator instances across different lion versions.
|
|
42
|
+
* It's meant to be used as a replacement for an instanceof check.
|
|
43
|
+
*
|
|
44
|
+
* N.B. it's important to keep the bracket notation, as `static _$isValidator$ = true;` will
|
|
45
|
+
* be renamed during minification and that leads to different names across different
|
|
46
|
+
* lion versions.
|
|
47
|
+
* @type {boolean}
|
|
48
|
+
*/
|
|
49
|
+
static ['_$isValidator$'] = true;
|
|
50
|
+
|
|
37
51
|
/**
|
|
38
52
|
* The name under which validation results get registered. For convenience and predictability, this
|
|
39
53
|
* should always be the same as the constructor name (since it will be obfuscated in js builds,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable dot-notation */
|
|
1
2
|
import { LitElement } from 'lit';
|
|
2
3
|
import { defineCE, expect, fixture, html, unsafeStatic } from '@open-wc/testing';
|
|
3
4
|
import sinon from 'sinon';
|
|
@@ -187,6 +188,13 @@ describe('Validator', () => {
|
|
|
187
188
|
expect(disconnectSpy.calledWith(el)).to.equal(true);
|
|
188
189
|
});
|
|
189
190
|
|
|
191
|
+
it('adds static ["_$isValidator$"] property as a marker to identify the Validator class across different lion versions (as instanceof cannot be used)', async () => {
|
|
192
|
+
const myValidator = new Validator();
|
|
193
|
+
|
|
194
|
+
expect(myValidator.constructor['_$isValidator$']).to.exist;
|
|
195
|
+
expect(myValidator.constructor['_$isValidator$']).to.be.true;
|
|
196
|
+
});
|
|
197
|
+
|
|
190
198
|
describe('Types', () => {
|
|
191
199
|
it('has type "error" by default', async () => {
|
|
192
200
|
expect(new Validator().type).to.equal('error');
|