@brandup/ui-dropdown 1.0.39 → 1.0.40

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 (2) hide show
  1. package/package.json +3 -3
  2. package/source/dropdown.ts +6 -10
package/package.json CHANGED
@@ -24,14 +24,14 @@
24
24
  "email": "it@brandup.online"
25
25
  },
26
26
  "license": "Apache-2.0",
27
- "version": "1.0.39",
27
+ "version": "1.0.40",
28
28
  "main": "source/index.ts",
29
29
  "types": "source/index.ts",
30
30
  "dependencies": {
31
31
  "@brandup/ui": "^2.0.7",
32
32
  "@brandup/ui-helpers": "^2.0.7",
33
- "@brandup/ui-input": "^1.0.39",
34
- "@brandup/ui-kit": "^1.0.39"
33
+ "@brandup/ui-input": "^1.0.40",
34
+ "@brandup/ui-kit": "^1.0.40"
35
35
  },
36
36
  "files": [
37
37
  "source",
@@ -486,19 +486,15 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
486
486
  return (selected && selected.own.firstElementChild?.textContent?.trim()) || null;
487
487
  }
488
488
 
489
+ // Правила проверяет браузер по атрибутам самого select; контрол отражает результат классом.
490
+ // Обязательность закрывает нативный required — для этого у пустого пункта value должно
491
+ // быть пустым, как и требует стандарт.
489
492
  override validate(): boolean {
490
- const value = this.getValue();
491
- let isInvalid = !this.__valueElem.validity.valid;
493
+ const isValid = super.validate();
492
494
 
493
- if (this.required && !value) isInvalid = true;
495
+ this.element.classList.toggle("invalid", !isValid);
494
496
 
495
- const clearInvalid = () => this.element.classList.remove("invalid");
496
-
497
- if (isInvalid) {
498
- this.element.classList.add("invalid");
499
- } else clearInvalid();
500
-
501
- return !isInvalid;
497
+ return isValid;
502
498
  }
503
499
 
504
500
  override destroy(): void {