@lion/ui 0.8.4 → 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.
Files changed (62) hide show
  1. package/components/form-core/src/FormControlMixin.js +1 -1
  2. package/components/form-core/src/validate/ValidateMixin.js +9 -4
  3. package/components/form-core/src/validate/Validator.js +17 -3
  4. package/components/form-core/test/validate/Validator.test.js +8 -0
  5. package/custom-elements.json +476 -0
  6. package/dist-types/components/form-core/src/validate/ValidateMixin.d.ts.map +1 -1
  7. package/dist-types/components/form-core/src/validate/Validator.d.ts +16 -6
  8. package/dist-types/components/form-core/src/validate/Validator.d.ts.map +1 -1
  9. package/dist-types/tsconfig.tsbuildinfo +1 -1
  10. package/docs/components/checkbox-group/overview.md +2 -2
  11. package/docs/components/collapsible/overview.md +1 -1
  12. package/docs/components/combobox/overview.md +1 -1
  13. package/docs/components/combobox/use-cases.md +1 -1
  14. package/docs/components/dialog/overview.md +1 -1
  15. package/docs/components/fieldset/overview.md +5 -5
  16. package/docs/components/form/overview.md +3 -3
  17. package/docs/components/icon/use-cases.md +1 -1
  18. package/docs/components/input/overview.md +1 -1
  19. package/docs/components/input-amount/overview.md +3 -3
  20. package/docs/components/input-date/overview.md +3 -3
  21. package/docs/components/input-datepicker/overview.md +5 -5
  22. package/docs/components/input-email/overview.md +2 -2
  23. package/docs/components/input-file/overview.md +1 -1
  24. package/docs/components/input-iban/overview.md +2 -2
  25. package/docs/components/input-range/overview.md +2 -2
  26. package/docs/components/input-stepper/overview.md +1 -1
  27. package/docs/components/input-tel/overview.md +1 -1
  28. package/docs/components/input-tel/use-cases.md +6 -6
  29. package/docs/components/input-tel-dropdown/overview.md +1 -1
  30. package/docs/components/listbox/use-cases.md +1 -1
  31. package/docs/components/radio-group/overview.md +3 -3
  32. package/docs/components/select/use-cases.md +1 -1
  33. package/docs/components/select-rich/use-cases.md +1 -1
  34. package/docs/components/tabs/examples.md +1 -1
  35. package/docs/fundamentals/index.md +4 -4
  36. package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
  37. package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
  38. package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
  39. package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
  40. package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
  41. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  42. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  43. package/docs/fundamentals/rationales/accessibility.md +1 -1
  44. package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
  45. package/docs/fundamentals/systems/core/overview.md +1 -1
  46. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  47. package/docs/fundamentals/systems/form/model-value.md +1 -1
  48. package/docs/fundamentals/systems/form/overview.md +28 -28
  49. package/docs/fundamentals/systems/form/validate.md +2 -2
  50. package/docs/fundamentals/systems/localize/overview.md +4 -4
  51. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  52. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  53. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  54. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  55. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  56. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  57. package/docs/guides/how-to/create-a-form.md +4 -4
  58. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  59. package/docs/guides/index.md +8 -8
  60. package/docs/guides/principles/index.md +5 -5
  61. package/docs/guides/principles/styling.md +1 -1
  62. package/package.json +1 -1
@@ -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.toString());
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(v => v instanceof Required);
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
- if (!(validatorToSetup instanceof Validator)) {
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').ValidatorName} ValidatorName
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');