@brandup/ui-dropdown 1.0.36 → 1.0.39

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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Установка
8
8
 
9
- ```
9
+ ```bash
10
10
  npm i @brandup/ui-dropdown
11
11
  ```
12
12
 
@@ -35,7 +35,7 @@ dropdown.on(CHANGE_EVENT, (data: ChangeEventData) => {
35
35
  ## Data-атрибуты
36
36
 
37
37
  | Атрибут | По умолчанию | Описание |
38
- |---|---|---|
38
+ | --- | --- | --- |
39
39
  | `data-placeholder` | `"Select"` | Текст при отсутствии выбранного значения |
40
40
  | `data-emptytext` | `"Empty list"` | Текст при пустом списке опций |
41
41
  | `data-search-placeholder` | `"Search"` | Плейсхолдер строки поиска |
@@ -48,7 +48,7 @@ dropdown.on(CHANGE_EVENT, (data: ChangeEventData) => {
48
48
  ### Методы (унаследованы от InputControl)
49
49
 
50
50
  | Метод | Описание |
51
- |---|---|
51
+ | --- | --- |
52
52
  | `validate(): boolean` | Проверяет значение через нативный `checkValidity()` |
53
53
  | `focus(): void` | Устанавливает фокус |
54
54
  | `destroy(): void` | Восстанавливает исходный `<select>` и освобождает ресурсы |
@@ -56,7 +56,7 @@ dropdown.on(CHANGE_EVENT, (data: ChangeEventData) => {
56
56
  ### Свойства
57
57
 
58
58
  | Свойство | Тип | Описание |
59
- |---|---|---|
59
+ | --- | --- | --- |
60
60
  | `placeholder` | `string` | Текст-заглушка |
61
61
  | `emptyText` | `string` | Текст при пустом списке |
62
62
  | `searchOn` | `number \| boolean` | Настройка отображения строки поиска |
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.36",
27
+ "version": "1.0.39",
28
28
  "main": "source/index.ts",
29
29
  "types": "source/index.ts",
30
30
  "dependencies": {
31
- "@brandup/ui": "^2.0.5",
32
- "@brandup/ui-helpers": "^2.0.5",
33
- "@brandup/ui-input": "^1.0.36",
34
- "@brandup/ui-kit": "^1.0.36"
31
+ "@brandup/ui": "^2.0.7",
32
+ "@brandup/ui-helpers": "^2.0.7",
33
+ "@brandup/ui-input": "^1.0.39",
34
+ "@brandup/ui-kit": "^1.0.39"
35
35
  },
36
36
  "files": [
37
37
  "source",
@@ -44,8 +44,6 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
44
44
  readonly searchOn: number | boolean;
45
45
 
46
46
  constructor(selectElem: HTMLSelectElement) {
47
- selectElem.classList.add(INPUT_CLASS);
48
-
49
47
  const placeholder = selectElem.getAttribute("data-placeholder") || "Select";
50
48
  const emptyText = selectElem.getAttribute("data-emptytext") || "Empty list";
51
49
  const searchPlaceholder = selectElem.getAttribute("data-search-placeholder") || "Search";
@@ -97,12 +95,12 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
97
95
  ]),
98
96
  ]);
99
97
 
100
- const container = DOM.tag("div", { class: [ROOT_CLASS].concat(Array.from(selectElem.classList)) }, [
98
+ const container = DOM.tag("div", { class: ROOT_CLASS }, [
101
99
  DOM.tag("button", { class: "view", command: "open-popup" }, [textElem, arrowBottomIcon]),
102
100
  popupElem,
103
101
  ]);
104
102
 
105
- container.classList.remove(INPUT_CLASS);
103
+ DropDown.prepareValueElem(selectElem, container, INPUT_CLASS);
106
104
 
107
105
  if (selectElem.nextElementSibling) {
108
106
  const nextElem = selectElem.nextElementSibling as HTMLElement;
@@ -112,7 +110,8 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
112
110
  selectElem.insertAdjacentElement("beforebegin", container);
113
111
  container.insertAdjacentElement("beforeend", selectElem);
114
112
 
115
- super("BrandUp.DropDown", container, selectElem);
113
+ // класс вернёт базовый класс при destroy — без этого поле осталось бы скрытым
114
+ super("BrandUp.DropDown", container, selectElem, { class: INPUT_CLASS });
116
115
 
117
116
  this.placeholder = placeholder;
118
117
  this.emptyText = emptyText;
@@ -505,10 +504,7 @@ class DropDown extends InputControl<HTMLSelectElement, DropDownEvents> {
505
504
  override destroy(): void {
506
505
  this.__closePopup();
507
506
 
508
- this.element.insertAdjacentElement("afterend", this.__valueElem);
509
- this.element.remove();
510
-
511
- super.destroy();
507
+ super.destroy(); // снимет слушатели формы и вернёт поле-носитель в исходный вид
512
508
  }
513
509
  }
514
510