@brandup/ui-dropdown 1.0.39 → 1.0.41

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/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.41",
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.41",
34
+ "@brandup/ui-kit": "^1.0.41"
35
35
  },
36
36
  "files": [
37
37
  "source",
@@ -141,23 +141,7 @@
141
141
  position: relative;
142
142
  overflow-y: scroll;
143
143
  padding-right: 5px;
144
- scrollbar-width: 6px;
145
-
146
- &::-webkit-scrollbar {
147
- width: 6px;
148
- height: 5px;
149
- background: none;
150
- }
151
-
152
- &::-webkit-scrollbar-track {
153
- border-radius: 3px;
154
- background-color: transparent;
155
- }
156
-
157
- &::-webkit-scrollbar-thumb {
158
- background-color: #8696a0;
159
- border-radius: 3px;
160
- }
144
+ // полоса прокрутки — общая, от .ui-scrollable кита
161
145
 
162
146
  & li {
163
147
  padding: calc(var(--input-padding-lr) / 2) var(--input-padding-lr);
@@ -1,5 +1,6 @@
1
1
  import { InputControl } from "@brandup/ui-input";
2
2
  import { DOM } from "@brandup/ui";
3
+ import { SCROLLABLE_CLASS } from "@brandup/ui-kit";
3
4
  import { detectLanguage, transcriptText } from "./utils/utilities";
4
5
 
5
6
  import "./dropdown.less"; // стили компонента
@@ -44,14 +45,14 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
44
45
  readonly searchOn: number | boolean;
45
46
 
46
47
  constructor(selectElem: HTMLSelectElement) {
47
- const placeholder = selectElem.getAttribute("data-placeholder") || "Select";
48
- const emptyText = selectElem.getAttribute("data-emptytext") || "Empty list";
49
- const searchPlaceholder = selectElem.getAttribute("data-search-placeholder") || "Search";
50
- const searchEmpty = selectElem.getAttribute("data-search-empty") || "Not found";
51
- const cancelText = selectElem.getAttribute("data-cancel") || "Cancel";
48
+ const placeholder = selectElem.dataset.placeholder || "Select";
49
+ const emptyText = selectElem.dataset.emptytext || "Empty list";
50
+ const searchPlaceholder = selectElem.dataset.searchPlaceholder || "Search";
51
+ const searchEmpty = selectElem.dataset.searchEmpty || "Not found";
52
+ const cancelText = selectElem.dataset.cancel || "Cancel";
52
53
 
53
54
  let searchOn: number | boolean = 15;
54
- const se = selectElem.getAttribute("data-search-on");
55
+ const se = selectElem.dataset.searchOn;
55
56
  if (se) {
56
57
  switch (se.toLowerCase()) {
57
58
  case "true":
@@ -80,7 +81,7 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
80
81
  cancelButton.textContent = cancelText;
81
82
 
82
83
  const searchInput = DOM.tag("input", { type: "search", maxlength: 50, placeholder: searchPlaceholder });
83
- const listElem = DOM.tag("ul");
84
+ const listElem = DOM.tag("ul", { class: SCROLLABLE_CLASS });
84
85
 
85
86
  const popupElem = DOM.tag("div", { class: "popup", tabindex: 0 }, [
86
87
  DOM.tag("div", { class: "content" }, [
@@ -486,19 +487,15 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
486
487
  return (selected && selected.own.firstElementChild?.textContent?.trim()) || null;
487
488
  }
488
489
 
490
+ // Правила проверяет браузер по атрибутам самого select; контрол отражает результат классом.
491
+ // Обязательность закрывает нативный required — для этого у пустого пункта value должно
492
+ // быть пустым, как и требует стандарт.
489
493
  override validate(): boolean {
490
- const value = this.getValue();
491
- let isInvalid = !this.__valueElem.validity.valid;
494
+ const isValid = super.validate();
492
495
 
493
- if (this.required && !value) isInvalid = true;
496
+ this.element.classList.toggle("invalid", !isValid);
494
497
 
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;
498
+ return isValid;
502
499
  }
503
500
 
504
501
  override destroy(): void {