@six-group/ui-library 0.0.0-insider.9277796 → 0.0.0-insider.a358260
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/dist/cjs/six-checkbox.cjs.entry.js +57 -46
- package/dist/cjs/six-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/six-input.cjs.entry.js +107 -81
- package/dist/cjs/six-input.cjs.entry.js.map +1 -1
- package/dist/cjs/six-radio.cjs.entry.js +56 -51
- package/dist/cjs/six-radio.cjs.entry.js.map +1 -1
- package/dist/cjs/six-range.cjs.entry.js +114 -75
- package/dist/cjs/six-range.cjs.entry.js.map +1 -1
- package/dist/cjs/six-select.cjs.entry.js +298 -239
- package/dist/cjs/six-select.cjs.entry.js.map +1 -1
- package/dist/cjs/six-textarea.cjs.entry.js +97 -74
- package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
- package/dist/cjs/slot-ad537f24.js.map +1 -1
- package/dist/collection/components/six-checkbox/six-checkbox.js +62 -49
- package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
- package/dist/collection/components/six-input/six-input.js +130 -117
- package/dist/collection/components/six-input/six-input.js.map +1 -1
- package/dist/collection/components/six-radio/six-radio.js +60 -53
- package/dist/collection/components/six-radio/six-radio.js.map +1 -1
- package/dist/collection/components/six-range/six-range.js +121 -76
- package/dist/collection/components/six-range/six-range.js.map +1 -1
- package/dist/collection/components/six-select/six-select.js +248 -240
- package/dist/collection/components/six-select/six-select.js.map +1 -1
- package/dist/collection/components/six-select/util.js +52 -0
- package/dist/collection/components/six-select/util.js.map +1 -0
- package/dist/collection/components/six-textarea/six-textarea.js +115 -105
- package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
- package/dist/collection/utils/slot.js.map +1 -1
- package/dist/components/six-checkbox.js +57 -46
- package/dist/components/six-checkbox.js.map +1 -1
- package/dist/components/six-input2.js +107 -81
- package/dist/components/six-input2.js.map +1 -1
- package/dist/components/six-radio.js +56 -51
- package/dist/components/six-radio.js.map +1 -1
- package/dist/components/six-range.js +114 -75
- package/dist/components/six-range.js.map +1 -1
- package/dist/components/six-select.js +299 -240
- package/dist/components/six-select.js.map +1 -1
- package/dist/components/six-textarea.js +97 -74
- package/dist/components/six-textarea.js.map +1 -1
- package/dist/components/slot.js.map +1 -1
- package/dist/components.json +51 -41
- package/dist/esm/six-checkbox.entry.js +57 -46
- package/dist/esm/six-checkbox.entry.js.map +1 -1
- package/dist/esm/six-input.entry.js +107 -81
- package/dist/esm/six-input.entry.js.map +1 -1
- package/dist/esm/six-radio.entry.js +56 -51
- package/dist/esm/six-radio.entry.js.map +1 -1
- package/dist/esm/six-range.entry.js +114 -75
- package/dist/esm/six-range.entry.js.map +1 -1
- package/dist/esm/six-select.entry.js +299 -240
- package/dist/esm/six-select.entry.js.map +1 -1
- package/dist/esm/six-textarea.entry.js +97 -74
- package/dist/esm/six-textarea.entry.js.map +1 -1
- package/dist/esm/slot-6f3984c7.js.map +1 -1
- package/dist/types/components/six-checkbox/six-checkbox.d.ts +21 -17
- package/dist/types/components/six-input/six-input.d.ts +27 -36
- package/dist/types/components/six-radio/six-radio.d.ts +10 -11
- package/dist/types/components/six-range/six-range.d.ts +24 -20
- package/dist/types/components/six-select/six-select.d.ts +35 -40
- package/dist/types/components/six-select/util.d.ts +7 -0
- package/dist/types/components/six-textarea/six-textarea.d.ts +22 -31
- package/dist/types/components.d.ts +20 -28
- package/dist/types/utils/testing.d.ts +1 -1
- package/dist/ui-library/p-163f2bb0.entry.js +2 -0
- package/dist/ui-library/p-163f2bb0.entry.js.map +1 -0
- package/dist/ui-library/{p-14f20bbb.entry.js → p-394a2a12.entry.js} +2 -2
- package/dist/ui-library/p-394a2a12.entry.js.map +1 -0
- package/dist/ui-library/{p-7e0cc4ae.entry.js → p-3c635d0a.entry.js} +2 -2
- package/dist/ui-library/p-3c635d0a.entry.js.map +1 -0
- package/dist/ui-library/p-5a25d6fb.entry.js +2 -0
- package/dist/ui-library/p-5a25d6fb.entry.js.map +1 -0
- package/dist/ui-library/{p-90dc6af4.entry.js → p-97cc839c.entry.js} +2 -2
- package/dist/ui-library/p-97cc839c.entry.js.map +1 -0
- package/dist/ui-library/p-b4dfb7cf.js.map +1 -1
- package/dist/ui-library/p-f604e067.entry.js +2 -0
- package/dist/ui-library/p-f604e067.entry.js.map +1 -0
- package/dist/ui-library/ui-library.esm.js +1 -1
- package/package.json +13 -14
- package/dist/ui-library/p-0d79b0c6.entry.js +0 -2
- package/dist/ui-library/p-0d79b0c6.entry.js.map +0 -1
- package/dist/ui-library/p-14f20bbb.entry.js.map +0 -1
- package/dist/ui-library/p-7e0cc4ae.entry.js.map +0 -1
- package/dist/ui-library/p-835c3ff7.entry.js +0 -2
- package/dist/ui-library/p-835c3ff7.entry.js.map +0 -1
- package/dist/ui-library/p-90dc6af4.entry.js.map +0 -1
- package/dist/ui-library/p-edc96efc.entry.js +0 -2
- package/dist/ui-library/p-edc96efc.entry.js.map +0 -1
|
@@ -1,9 +1,61 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-5c0f6628.js';
|
|
2
|
-
import {
|
|
2
|
+
import { h as hasSlot, a as getTextContent } from './slot-6f3984c7.js';
|
|
3
3
|
import { F as FormControl } from './form-control-3b440ea1.js';
|
|
4
4
|
import { E as EventListeners } from './event-listeners-570a24ea.js';
|
|
5
5
|
import { D as DEFAULT_DEBOUNCE_FAST, a as debounce } from './execution-control-1a60d709.js';
|
|
6
6
|
|
|
7
|
+
function getValue(value, multiple, menuItems) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
if (multiple) {
|
|
10
|
+
if (Array.isArray(value)) {
|
|
11
|
+
return getSelectedValues(value, menuItems);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return getSelectedValuesFromString(value, menuItems);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return (_b = (_a = getSelectedMenuItem(value, menuItems)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '';
|
|
18
|
+
}
|
|
19
|
+
function isValidValue(value, multiple, menuItems) {
|
|
20
|
+
if (value === '') {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (multiple) {
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
if (value.length === 0) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return getSelectedValues(value, menuItems).length === value.length;
|
|
29
|
+
}
|
|
30
|
+
return getSelectedValuesFromString(value, menuItems).length > 0;
|
|
31
|
+
}
|
|
32
|
+
return getSelectedMenuItem(value, menuItems) != null;
|
|
33
|
+
}
|
|
34
|
+
function valueEquals(a, b) {
|
|
35
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
36
|
+
return a.length === b.length && a.every((element, index) => element === b[index]);
|
|
37
|
+
}
|
|
38
|
+
else if (typeof a === 'string' && typeof b === 'string') {
|
|
39
|
+
return a === b;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function isValueEmpty(value) {
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return value.length === 0;
|
|
46
|
+
}
|
|
47
|
+
return value === '';
|
|
48
|
+
}
|
|
49
|
+
function getSelectedValues(values, menuItems) {
|
|
50
|
+
return menuItems.filter((menuItem) => values.includes(menuItem.value)).map((menuItem) => menuItem.value);
|
|
51
|
+
}
|
|
52
|
+
function getSelectedValuesFromString(value, menuItems) {
|
|
53
|
+
return menuItems.filter((menuItem) => value === menuItem.value).map((menuItem) => menuItem.value);
|
|
54
|
+
}
|
|
55
|
+
function getSelectedMenuItem(value, menuItems) {
|
|
56
|
+
return menuItems.find((item) => value === item.value);
|
|
57
|
+
}
|
|
58
|
+
|
|
7
59
|
const sixSelectCss = ":host{position:relative;box-sizing:border-box}:host *,:host *:before,:host *:after{box-sizing:inherit}.form-control .form-control__label{display:none}.form-control .form-control__help-text{display:none}.form-control .form-control__error-text{display:none}.form-control--has-label .form-control__label{display:inline-block;color:var(--six-input-label-color);font-weight:var(--six-font-weight-bold);margin-bottom:var(--six-spacing-x-small)}.form-control--has-label .form-control__label__required::after{color:var(--six-color-danger-800);content:\"*\"}.form-control--has-label.form-control--small .form-control__label{font-size:var(--six-input-label-font-size-small)}.form-control--has-label.form-control--medium .form-control__label{font-size:var(--six-input-label-font-size-medium)}.form-control--has-label.form-control--large .form-control_label{font-size:var(--six-input-label-font-size-large)}.form-control--has-help-text .form-control__help-text{display:block;color:var(--six-input-help-text-color);margin-top:var(--six-spacing-x-small)}.form-control--has-help-text .form-control__help-text ::slotted(*){margin-top:var(--six-spacing-xxx-small)}.form-control--has-help-text.form-control--small .form-control__help-text{font-size:var(--six-input-help-text-font-size-small)}.form-control--has-help-text.form-control--medium .form-control__help-text{font-size:var(--six-input-help-text-font-size-medium)}.form-control--has-help-text.form-control--large .form-control__help-text{font-size:var(--six-input-help-text-font-size-large)}.form-control--has-error-text .form-control__error-text{display:block;color:var(--six-color-danger-800);margin-top:var(--six-spacing-xxx-small)}.form-control--has-error-text .form-control__error-text ::slotted(*){margin-top:var(--six-spacing-xxx-small)}.form-control--has-error-text.form-control--small .form-control__error-text{font-size:var(--six-input-help-text-font-size-small)}.form-control--has-error-text.form-control--medium .form-control__error-text{font-size:var(--six-input-help-text-font-size-medium)}.form-control--has-error-text.form-control--large .form-control__error-text{font-size:var(--six-input-help-text-font-size-large)}.form-control--disabled .form-control__help-text{color:var(--six-input-help-text-color-disabled)}.form-control--disabled .form-control__label{color:var(--six-input-label-color-disabled)}.form-control--invalid:not(.form-control--disabled) .form-control__label{color:var(--six-input-label-color)}:host{display:block}.select{display:block}.select__box{display:inline-flex;align-items:center;justify-content:start;position:relative;width:100%;font-family:var(--six-font-family);font-weight:var(--six-input-font-weight);font-size:var(--six-input-font-size-medium);letter-spacing:var(--six-input-letter-spacing);background-color:var(--six-input-background-color);border:solid var(--six-border-width) var(--six-input-border-color);vertical-align:middle;overflow:hidden;transition:var(--six-transition-fast) color, var(--six-transition-fast) border, var(--six-transition-fast) box-shadow;cursor:pointer}.select__box--line{border:none;border-bottom:solid var(--six-border-width) var(--six-input-border-color)}.select__box--autocomplete{border:none;overflow:initial}.select:not(.select--disabled) .select__box:hover{background-color:var(--six-input-background-color-hover);color:var(--six-input-color-hover);border-bottom-color:var(--six-input-border-color-hover)}.select:not(.select--disabled) .select__box:hover:not(.select__box--line){border-color:var(--six-input-border-color-hover)}.select:not(.select--disabled) .select__box:focus{background-color:var(--six-input-background-color-focus);outline:none;color:var(--six-input-color-focus);border-bottom-color:var(--six-input-border-color-focus);box-shadow:0 1px 0 0 var(--six-input-border-color-focus)}.select:not(.select--disabled) .select__box:focus:not(.select__box--line){border-color:var(--six-input-border-color-focus);box-shadow:var(--six-input-focus-shadow)}.select--disabled .select__box{background-color:var(--six-input-background-color-disabled);color:var(--six-input-color-disabled);cursor:not-allowed;outline:none}.select--disabled .select__box:not(.select__box--line){border-color:var(--six-input-border-color-disabled)}.select--disabled .select__tags,.select--disabled .select__clear{pointer-events:none}.select--invalid:not(.select--disabled):not(.select--focused) .select__box{border-bottom-color:var(--six-input-border-color-danger)}.select--invalid:not(.select--disabled):not(.select--focused) .select__box:not(.input--line){border-color:var(--six-input-border-color-danger)}.select__label{flex-shrink:1;flex-grow:1;align-items:center;user-select:none;width:0;scrollbar-width:none;-ms-overflow-style:none;overflow-x:auto;overflow-y:hidden;white-space:nowrap}.select__label::-webkit-scrollbar{width:0;height:0}.select__clear{flex-shrink:0;flex-grow:0;display:inline}.select__icon{flex-shrink:0;flex-grow:0;display:inline;transition:var(--six-transition-medium) transform ease}.select--open .select__icon{transform:rotate(-180deg)}.select--placeholder-visible .select__label{color:var(--six-input-placeholder-color)}.select--disabled.select--placeholder-visible .select__label{color:var(--six-input-placeholder-color-disabled)}.select__tags{display:inline-flex;align-items:center;flex-wrap:wrap;justify-content:left;margin-left:var(--six-spacing-xx-small)}.select__hidden-select{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}.select__input{position:absolute;top:0;left:0;width:100%;height:100%}.select--small .select__box{border-radius:var(--six-input-border-radius-small);font-size:var(--six-input-font-size-small);min-height:var(--six-height-small)}.select--small .select__box--line{border:none;border-bottom:solid var(--six-border-width) var(--six-input-border-color)}.select--small .select__label{margin:0 var(--six-input-spacing-small)}.select--small .select__clear{margin-right:var(--six-spacing-xxx-small)}.select--small .select__icon{margin-right:var(--six-spacing-x-small)}.select--small .select__tags{padding-bottom:2px}.select--small .select__tags six-tag{padding-top:2px}.select--small .select__tags six-tag:not(:last-of-type){margin-right:var(--six-spacing-xx-small)}.select--small.select--has-tags .select__label{margin-left:0}.select--medium .select__box{border-radius:var(--six-input-border-radius-medium);font-size:var(--six-input-font-size-medium);min-height:var(--six-height-medium)}.select--medium .select__box--line{border:none;border-bottom:solid var(--six-border-width) var(--six-input-border-color)}.select--medium .select__label{margin:0 var(--six-input-spacing-medium)}.select--medium .select__clear{margin-right:var(--six-spacing-xxx-small)}.select--medium .select__icon{margin-right:var(--six-spacing-x-small)}.select--medium .select__tags{padding-bottom:3px}.select--medium .select__tags six-tag{padding-top:3px}.select--medium .select__tags six-tag:not(:last-of-type){margin-right:var(--six-spacing-xx-small)}.select--medium.select--has-tags .select__label{margin-left:0}.select--large .select__box{border-radius:var(--six-input-border-radius-large);font-size:var(--six-input-font-size-large);min-height:var(--six-height-large)}.select--large .select__box--line{border:none;border-bottom:solid var(--six-border-width) var(--six-input-border-color)}.select--large .select__label{margin:0 var(--six-input-spacing-large)}.select--large .select__clear{margin-right:var(--six-spacing-xxx-small)}.select--large .select__icon{margin-right:var(--six-spacing-x-small)}.select--large .select__tags{padding-bottom:4px}.select--large .select__tags six-tag{padding-top:4px}.select--large .select__tags six-tag:not(:last-of-type){margin-right:var(--six-spacing-xx-small)}.select--large.select--has-tags .select__label{margin-left:0}.select--pill.select--small .select__box{border-radius:var(--six-height-small)}.select--pill.select--medium .select__box{border-radius:var(--six-height-medium)}.select--pill.select--large .select__box{border-radius:var(--six-height-large)}.select__menu{max-width:50vw;width:fit-content}.select__menu--filtered{width:100% !important}.select__menu--hidden{display:none}six-icon-button::part(base){padding-top:0;padding-bottom:0}";
|
|
8
60
|
|
|
9
61
|
let id = 0;
|
|
@@ -17,9 +69,120 @@ const SixSelect = class {
|
|
|
17
69
|
this.labelId = `select-label-${id}`;
|
|
18
70
|
this.helpTextId = `select-help-text-${id}`;
|
|
19
71
|
this.errorTextId = `select-error-text-${id}`;
|
|
72
|
+
this.touched = false;
|
|
20
73
|
this.customErrorText = '';
|
|
21
74
|
this.customValidation = false;
|
|
22
75
|
this.eventListeners = new EventListeners();
|
|
76
|
+
this.handleBlur = () => {
|
|
77
|
+
this.hasFocus = false;
|
|
78
|
+
this.sixBlur.emit();
|
|
79
|
+
};
|
|
80
|
+
this.handleFocus = () => {
|
|
81
|
+
this.hasFocus = true;
|
|
82
|
+
this.sixFocus.emit();
|
|
83
|
+
};
|
|
84
|
+
this.handleInvalid = () => {
|
|
85
|
+
this.invalid = true;
|
|
86
|
+
};
|
|
87
|
+
this.handleClearClick = (event) => {
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
this.clearValues();
|
|
90
|
+
};
|
|
91
|
+
this.handleSelectAll = (event) => {
|
|
92
|
+
const nonFilteredItems = this.getItems().filter((item) => item.style.display !== 'none');
|
|
93
|
+
const keyName = event.key;
|
|
94
|
+
const keyCode = event.code;
|
|
95
|
+
if (keyName === 'Control') {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (this.isOpen && this.multiple && keyCode === 'KeyA' && event.ctrlKey) {
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
const hasDeselectedOptions = nonFilteredItems.some((opt) => !opt.disabled && !opt.checked);
|
|
101
|
+
nonFilteredItems
|
|
102
|
+
.filter((option) => !option.disabled)
|
|
103
|
+
.forEach((option) => (option.checked = hasDeselectedOptions));
|
|
104
|
+
const checkedItems = nonFilteredItems.filter((option) => option.checked).map((option) => option.value);
|
|
105
|
+
this.value = hasDeselectedOptions ? checkedItems : [];
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
this.handleKeyDown = async (event) => {
|
|
109
|
+
var _a;
|
|
110
|
+
const target = event.target;
|
|
111
|
+
const items = this.getItems();
|
|
112
|
+
const firstItem = items[0];
|
|
113
|
+
const lastItem = items[items.length - 1];
|
|
114
|
+
// Ignore key presses on tags
|
|
115
|
+
if (target.tagName.toLowerCase() === 'six-tag') {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// Tabbing out of the control closes it
|
|
119
|
+
if (event.key === 'Tab') {
|
|
120
|
+
if (this.isOpen && this.dropdown != null) {
|
|
121
|
+
await this.dropdown.hide();
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
// Up/down opens the menu
|
|
126
|
+
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
127
|
+
event.preventDefault();
|
|
128
|
+
// Show the menu if it's not already open
|
|
129
|
+
if (!this.isOpen && this.dropdown != null) {
|
|
130
|
+
await this.dropdown.show();
|
|
131
|
+
}
|
|
132
|
+
// Focus on a menu item
|
|
133
|
+
if (event.key === 'ArrowDown' && firstItem) {
|
|
134
|
+
firstItem.setFocus();
|
|
135
|
+
}
|
|
136
|
+
else if (event.key === 'ArrowUp' && lastItem) {
|
|
137
|
+
lastItem.setFocus();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// All other keys open the menu and initiate type to select
|
|
141
|
+
if (!this.isOpen && this.dropdown != null) {
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
await this.dropdown.show();
|
|
145
|
+
await ((_a = this.menu) === null || _a === void 0 ? void 0 : _a.typeToSelect(event.key));
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
this.handleLabelClick = () => {
|
|
149
|
+
var _a;
|
|
150
|
+
(_a = this.box) === null || _a === void 0 ? void 0 : _a.focus();
|
|
151
|
+
};
|
|
152
|
+
this.handleMenuShow = (event) => {
|
|
153
|
+
var _a;
|
|
154
|
+
if (this.disabled) {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
this.resizeMenu();
|
|
159
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.host);
|
|
160
|
+
this.isOpen = true;
|
|
161
|
+
};
|
|
162
|
+
this.handleMenuHide = () => {
|
|
163
|
+
var _a;
|
|
164
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.host);
|
|
165
|
+
this.isOpen = false;
|
|
166
|
+
};
|
|
167
|
+
this.handleSlotChange = () => {
|
|
168
|
+
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
169
|
+
this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
|
|
170
|
+
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
171
|
+
this.update();
|
|
172
|
+
};
|
|
173
|
+
this.handleTagInteraction = (event) => {
|
|
174
|
+
// Don't toggle the menu when a tag's clear button is activated
|
|
175
|
+
const path = event.composedPath();
|
|
176
|
+
const clearButton = path.find((el) => {
|
|
177
|
+
if (el instanceof HTMLElement) {
|
|
178
|
+
const element = el;
|
|
179
|
+
return element.classList.contains('tag__clear');
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
if (clearButton) {
|
|
183
|
+
event.stopPropagation();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
23
186
|
this.hasFocus = false;
|
|
24
187
|
this.hasHelpTextSlot = false;
|
|
25
188
|
this.hasErrorTextSlot = false;
|
|
@@ -55,7 +218,7 @@ const SixSelect = class {
|
|
|
55
218
|
this.defaultValue = undefined;
|
|
56
219
|
}
|
|
57
220
|
handleDisabledChange() {
|
|
58
|
-
if (this.disabled && this.isOpen) {
|
|
221
|
+
if (this.disabled && this.isOpen && this.dropdown != null) {
|
|
59
222
|
this.dropdown.hide();
|
|
60
223
|
}
|
|
61
224
|
}
|
|
@@ -63,94 +226,159 @@ const SixSelect = class {
|
|
|
63
226
|
this.handleSlotChange();
|
|
64
227
|
}
|
|
65
228
|
handleMultipleChange() {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
229
|
+
this.update();
|
|
230
|
+
}
|
|
231
|
+
handleValueChange(newValue, oldValue) {
|
|
232
|
+
var _a;
|
|
233
|
+
let items = (_a = this.options) !== null && _a !== void 0 ? _a : this.getItems();
|
|
234
|
+
// normalize invalid values. This will re-trigger this watch handler
|
|
235
|
+
if (!isValidValue(newValue, this.multiple, items)) {
|
|
236
|
+
this.value = getValue(newValue, this.multiple, items);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// avoid re-triggering if old and new values are equal. Needed because
|
|
240
|
+
// watch does a shallow comparison only.
|
|
241
|
+
if (valueEquals(getValue(oldValue, this.multiple, items), getValue(newValue, this.multiple, items))) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
this.update();
|
|
245
|
+
this.sixChange.emit({ value: this.value, isSelected: true });
|
|
70
246
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
247
|
+
update() {
|
|
248
|
+
var _a;
|
|
249
|
+
const items = this.getItems();
|
|
250
|
+
this.value = getValue(this.value, this.multiple, (_a = this.options) !== null && _a !== void 0 ? _a : items);
|
|
251
|
+
if (!Array.isArray(this.value)) {
|
|
252
|
+
// Sync checked states
|
|
253
|
+
items.forEach((item) => (item.checked = false));
|
|
254
|
+
const item = items.find((item) => this.value.includes(item.value));
|
|
255
|
+
if (item != null) {
|
|
256
|
+
item.checked = true;
|
|
257
|
+
}
|
|
258
|
+
// Sync input element content
|
|
259
|
+
this.displayLabel = this.extractLabelForSelectedItem([this.value], items);
|
|
260
|
+
this.displayTags = [];
|
|
261
|
+
const hasSelection = !isValueEmpty(this.value);
|
|
262
|
+
if (hasSelection) {
|
|
263
|
+
this.touched = true;
|
|
264
|
+
}
|
|
265
|
+
if (this.inputElement && this.touched) {
|
|
266
|
+
if (!this.autocomplete) {
|
|
267
|
+
this.inputElement.value = hasSelection ? this.displayLabel : '';
|
|
268
|
+
}
|
|
269
|
+
else if (hasSelection) {
|
|
270
|
+
this.inputElement.value = this.value;
|
|
271
|
+
}
|
|
272
|
+
this.inputElement.checkValidity().then((valid) => (this.invalid = !valid));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
// Sync checked states
|
|
277
|
+
items.forEach((item) => (item.checked = this.value.includes(item.value)));
|
|
278
|
+
// Sync display label
|
|
279
|
+
const checkedItems = [];
|
|
280
|
+
this.value.forEach((val) => items.map((item) => (item.value === val ? checkedItems.push(item) : null)));
|
|
281
|
+
this.displayTags = checkedItems.map((item) => {
|
|
282
|
+
return (h("six-tag", { exportparts: "base:tag", type: "primary", size: this.size, pill: this.pill, clearable: true, onClick: this.handleTagInteraction, onKeyDown: this.handleTagInteraction, "onSix-tag-clear": (event) => {
|
|
283
|
+
event.stopPropagation();
|
|
284
|
+
if (!this.disabled) {
|
|
285
|
+
this.toggleItem(item);
|
|
286
|
+
}
|
|
287
|
+
} }, this.getItemLabel(item)));
|
|
288
|
+
});
|
|
289
|
+
if (this.maxTagsVisible > 0 && this.displayTags.length > this.maxTagsVisible) {
|
|
290
|
+
const total = this.displayTags.length;
|
|
291
|
+
this.displayLabel = '';
|
|
292
|
+
this.displayTags = this.displayTags.slice(0, this.maxTagsVisible);
|
|
293
|
+
this.displayTags.push(h("six-tag", { exportparts: "base:tag", type: "info", size: this.size }, "+", total - this.maxTagsVisible));
|
|
294
|
+
}
|
|
295
|
+
// Sync input element content
|
|
296
|
+
const hasSelection = !isValueEmpty(this.value);
|
|
297
|
+
if (hasSelection) {
|
|
298
|
+
this.touched = true;
|
|
299
|
+
}
|
|
300
|
+
if (this.inputElement && this.touched) {
|
|
301
|
+
if (!this.autocomplete) {
|
|
302
|
+
this.inputElement.value = hasSelection ? this.displayLabel : '';
|
|
303
|
+
}
|
|
304
|
+
else if (hasSelection) {
|
|
305
|
+
this.inputElement.value = this.value.join(',');
|
|
306
|
+
}
|
|
307
|
+
this.inputElement.checkValidity().then((valid) => (this.invalid = !valid));
|
|
308
|
+
}
|
|
75
309
|
}
|
|
76
310
|
}
|
|
77
311
|
connectedCallback() {
|
|
312
|
+
var _a;
|
|
78
313
|
if (this.virtualScroll && this.options === null) {
|
|
79
314
|
console.error('Options must be defined when using virtual scrolling');
|
|
80
315
|
}
|
|
81
|
-
|
|
82
|
-
this.handleFocus = this.handleFocus.bind(this);
|
|
83
|
-
this.handleClearClick = this.handleClearClick.bind(this);
|
|
84
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
85
|
-
this.handleSelectAll = this.handleSelectAll.bind(this);
|
|
86
|
-
this.handleLabelClick = this.handleLabelClick.bind(this);
|
|
87
|
-
this.handleMenuHide = this.handleMenuHide.bind(this);
|
|
88
|
-
this.handleMenuShow = this.handleMenuShow.bind(this);
|
|
89
|
-
this.handleMenuSelect = this.handleMenuSelect.bind(this);
|
|
90
|
-
this.handleSlotChange = this.handleSlotChange.bind(this);
|
|
91
|
-
this.handleInvalid = this.handleInvalid.bind(this);
|
|
92
|
-
this.handleTagInteraction = this.handleTagInteraction.bind(this);
|
|
93
|
-
this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
|
|
316
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
|
|
94
317
|
}
|
|
95
318
|
componentWillLoad() {
|
|
96
319
|
this.handleSlotChange();
|
|
97
|
-
if (this.multiple && this.value) {
|
|
98
|
-
this.value = this.getValueAsArray();
|
|
99
|
-
}
|
|
100
320
|
}
|
|
101
321
|
componentDidLoad() {
|
|
322
|
+
const inputElement = this.inputElement;
|
|
323
|
+
if (inputElement == null) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
102
326
|
this.resizeObserver = new ResizeObserver(() => this.resizeMenu());
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
|
|
107
|
-
this.customErrorText = await this.input.getValidationMessage();
|
|
327
|
+
this.eventListeners.add(inputElement, 'invalid', async (event) => {
|
|
328
|
+
if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
|
|
329
|
+
this.customErrorText = await inputElement.getValidationMessage();
|
|
108
330
|
}
|
|
109
331
|
event.preventDefault();
|
|
110
332
|
});
|
|
111
|
-
this.eventListeners.add(
|
|
112
|
-
const enteredValue =
|
|
333
|
+
this.eventListeners.add(inputElement, 'six-input-input', debounce((event) => {
|
|
334
|
+
const enteredValue = inputElement.value;
|
|
113
335
|
this.clearValues();
|
|
114
336
|
this.sixChange.emit({ value: enteredValue, isSelected: false });
|
|
115
337
|
event.stopPropagation();
|
|
116
338
|
}, this.inputDebounce));
|
|
117
|
-
this.input.value = this.hasSelection() ? this.displayLabel : '';
|
|
118
339
|
}
|
|
119
340
|
disconnectedCallback() {
|
|
120
|
-
|
|
341
|
+
var _a;
|
|
342
|
+
(_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
|
|
121
343
|
this.eventListeners.removeAll();
|
|
122
344
|
}
|
|
123
345
|
/** Checks for validity and shows the browser's validation message if the control is invalid. */
|
|
124
346
|
async reportValidity() {
|
|
125
|
-
|
|
347
|
+
var _a;
|
|
348
|
+
return (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.reportValidity();
|
|
126
349
|
}
|
|
127
350
|
/** Checks for validity. */
|
|
128
351
|
async checkValidity() {
|
|
129
|
-
|
|
352
|
+
var _a;
|
|
353
|
+
return (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.isValid();
|
|
130
354
|
}
|
|
131
355
|
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
|
132
356
|
async setCustomValidity(message) {
|
|
133
357
|
this.customErrorText = '';
|
|
134
358
|
this.customValidation = message !== '';
|
|
135
|
-
this.
|
|
136
|
-
|
|
359
|
+
if (this.inputElement != null) {
|
|
360
|
+
await this.inputElement.setCustomValidity(message);
|
|
361
|
+
this.invalid = !(await this.inputElement.checkValidity());
|
|
362
|
+
}
|
|
137
363
|
}
|
|
138
364
|
/** Resets the formcontrol */
|
|
139
365
|
async reset() {
|
|
366
|
+
var _a;
|
|
140
367
|
this.clearValues();
|
|
141
368
|
this.customErrorText = '';
|
|
142
369
|
this.customValidation = false;
|
|
143
|
-
this.
|
|
370
|
+
await ((_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.setCustomValidity(''));
|
|
144
371
|
this.invalid = false;
|
|
145
372
|
}
|
|
146
373
|
getItemLabel(item) {
|
|
147
|
-
|
|
148
|
-
|
|
374
|
+
var _a, _b;
|
|
375
|
+
const slot = (_a = item.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot:not([name])');
|
|
376
|
+
if (slot != null) {
|
|
149
377
|
return getTextContent(slot);
|
|
150
378
|
}
|
|
151
379
|
else {
|
|
152
380
|
// bugfix/COMSLI-203-six-select-value-is-not-updated-if-the-slot-is-changed
|
|
153
|
-
return item.textContent;
|
|
381
|
+
return (_b = item.textContent) !== null && _b !== void 0 ? _b : '';
|
|
154
382
|
}
|
|
155
383
|
}
|
|
156
384
|
getItems() {
|
|
@@ -162,192 +390,18 @@ const SixSelect = class {
|
|
|
162
390
|
hasMenuItems() {
|
|
163
391
|
return this.getItems().length > 0;
|
|
164
392
|
}
|
|
165
|
-
getValueAsStringArray() {
|
|
166
|
-
const values = this.getValueAsArray();
|
|
167
|
-
// enforce that the values are converted to 'string' before the value is compared
|
|
168
|
-
return values.map(String);
|
|
169
|
-
}
|
|
170
|
-
getValueAsArray() {
|
|
171
|
-
return Array.isArray(this.value) ? this.value : [this.value];
|
|
172
|
-
}
|
|
173
|
-
handleBlur() {
|
|
174
|
-
this.hasFocus = false;
|
|
175
|
-
this.sixBlur.emit();
|
|
176
|
-
}
|
|
177
|
-
handleFocus() {
|
|
178
|
-
this.hasFocus = true;
|
|
179
|
-
this.sixFocus.emit();
|
|
180
|
-
}
|
|
181
|
-
handleInvalid() {
|
|
182
|
-
this.invalid = true;
|
|
183
|
-
}
|
|
184
|
-
handleClearClick(event) {
|
|
185
|
-
event.stopPropagation();
|
|
186
|
-
this.clearValues();
|
|
187
|
-
}
|
|
188
393
|
clearValues() {
|
|
189
394
|
var _a;
|
|
190
395
|
this.value = (_a = this.defaultValue) !== null && _a !== void 0 ? _a : (this.multiple ? [] : '');
|
|
191
|
-
this.
|
|
192
|
-
}
|
|
193
|
-
handleSelectAll(event) {
|
|
194
|
-
const nonFilteredItems = this.getItems().filter((item) => item.style.display !== 'none');
|
|
195
|
-
const keyName = event.key;
|
|
196
|
-
const keyCode = event.code;
|
|
197
|
-
if (keyName === 'Control') {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (this.isOpen && this.multiple && keyCode === 'KeyA' && event.ctrlKey) {
|
|
201
|
-
event.preventDefault();
|
|
202
|
-
const hasDeselectedOptions = nonFilteredItems.some((opt) => !opt.disabled && !opt.checked);
|
|
203
|
-
nonFilteredItems
|
|
204
|
-
.filter((option) => !option.disabled)
|
|
205
|
-
.forEach((option) => (option.checked = hasDeselectedOptions));
|
|
206
|
-
const checkedItems = nonFilteredItems.filter((option) => option.checked).map((option) => option.value);
|
|
207
|
-
this.value = hasDeselectedOptions ? checkedItems : [];
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
handleKeyDown(event) {
|
|
211
|
-
const target = event.target;
|
|
212
|
-
const items = this.getItems();
|
|
213
|
-
const firstItem = items[0];
|
|
214
|
-
const lastItem = items[items.length - 1];
|
|
215
|
-
// Ignore key presses on tags
|
|
216
|
-
if (target.tagName.toLowerCase() === 'six-tag') {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
// Tabbing out of the control closes it
|
|
220
|
-
if (event.key === 'Tab') {
|
|
221
|
-
if (this.isOpen) {
|
|
222
|
-
this.dropdown.hide();
|
|
223
|
-
}
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
// Up/down opens the menu
|
|
227
|
-
if (['ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
228
|
-
event.preventDefault();
|
|
229
|
-
// Show the menu if it's not already open
|
|
230
|
-
if (!this.isOpen) {
|
|
231
|
-
this.dropdown.show();
|
|
232
|
-
}
|
|
233
|
-
// Focus on a menu item
|
|
234
|
-
if (event.key === 'ArrowDown' && firstItem) {
|
|
235
|
-
firstItem.setFocus();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (event.key === 'ArrowUp' && lastItem) {
|
|
239
|
-
lastItem.setFocus();
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// All other keys open the menu and initiate type to select
|
|
244
|
-
if (!this.isOpen) {
|
|
245
|
-
event.stopPropagation();
|
|
246
|
-
event.preventDefault();
|
|
247
|
-
this.dropdown.show();
|
|
248
|
-
this.menu.typeToSelect(event.key);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
handleLabelClick() {
|
|
252
|
-
this.box.focus();
|
|
253
|
-
}
|
|
254
|
-
handleMenuSelect(event) {
|
|
255
|
-
const item = event.detail.item;
|
|
256
|
-
if (this.multiple) {
|
|
257
|
-
if (this.value == null || this.value === '') {
|
|
258
|
-
this.value = [];
|
|
259
|
-
}
|
|
260
|
-
else if (!Array.isArray(this.value)) {
|
|
261
|
-
this.value = [this.value];
|
|
262
|
-
}
|
|
263
|
-
this.value = this.value.includes(item.value)
|
|
264
|
-
? this.value.filter((v) => v !== item.value)
|
|
265
|
-
: [...this.value, item.value];
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
this.value = item.value;
|
|
269
|
-
}
|
|
270
|
-
this.syncItemsFromValue();
|
|
396
|
+
this.update();
|
|
271
397
|
}
|
|
272
|
-
|
|
273
|
-
if (this.
|
|
274
|
-
event.preventDefault();
|
|
398
|
+
async resizeMenu() {
|
|
399
|
+
if (this.menu == null || this.box == null) {
|
|
275
400
|
return;
|
|
276
401
|
}
|
|
277
|
-
this.resizeMenu();
|
|
278
|
-
this.resizeObserver.observe(this.host);
|
|
279
|
-
this.isOpen = true;
|
|
280
|
-
}
|
|
281
|
-
handleMenuHide() {
|
|
282
|
-
this.resizeObserver.unobserve(this.host);
|
|
283
|
-
this.isOpen = false;
|
|
284
|
-
}
|
|
285
|
-
handleSlotChange() {
|
|
286
|
-
this.hasHelpTextSlot = hasSlot(this.host, 'help-text');
|
|
287
|
-
this.hasErrorTextSlot = hasSlot(this.host, 'error-text');
|
|
288
|
-
this.hasLabelSlot = hasSlot(this.host, 'label');
|
|
289
|
-
this.syncItemsFromValue();
|
|
290
|
-
}
|
|
291
|
-
handleTagInteraction(event) {
|
|
292
|
-
// Don't toggle the menu when a tag's clear button is activated
|
|
293
|
-
const path = event.composedPath();
|
|
294
|
-
const clearButton = path.find((el) => {
|
|
295
|
-
if (el instanceof HTMLElement) {
|
|
296
|
-
const element = el;
|
|
297
|
-
return element.classList.contains('tag__clear');
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
if (clearButton) {
|
|
301
|
-
event.stopPropagation();
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
resizeMenu() {
|
|
305
402
|
this.menu.style.minWidth = `${this.box.clientWidth}px`;
|
|
306
403
|
if (this.dropdown) {
|
|
307
|
-
this.dropdown.reposition();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
syncItemsFromValue() {
|
|
311
|
-
const items = this.getItems();
|
|
312
|
-
const value = this.getValueAsStringArray();
|
|
313
|
-
// Sync checked states
|
|
314
|
-
items.forEach((item) => (item.checked = value.includes(item.value)));
|
|
315
|
-
// Sync display label
|
|
316
|
-
if (this.multiple) {
|
|
317
|
-
const checkedItems = [];
|
|
318
|
-
value.forEach((val) => items.map((item) => (item.value === val ? checkedItems.push(item) : null)));
|
|
319
|
-
this.displayTags = checkedItems.map((item) => {
|
|
320
|
-
return (h("six-tag", { exportparts: "base:tag", type: "primary", size: this.size, pill: this.pill, clearable: true, onClick: this.handleTagInteraction, onKeyDown: this.handleTagInteraction, "onSix-tag-clear": (event) => {
|
|
321
|
-
event.stopPropagation();
|
|
322
|
-
if (!this.disabled) {
|
|
323
|
-
item.checked = false;
|
|
324
|
-
this.syncValueFromItems();
|
|
325
|
-
}
|
|
326
|
-
} }, this.getItemLabel(item)));
|
|
327
|
-
});
|
|
328
|
-
if (this.maxTagsVisible > 0 && this.displayTags.length > this.maxTagsVisible) {
|
|
329
|
-
const total = this.displayTags.length;
|
|
330
|
-
this.displayLabel = '';
|
|
331
|
-
this.displayTags = this.displayTags.slice(0, this.maxTagsVisible);
|
|
332
|
-
this.displayTags.push(h("six-tag", { exportparts: "base:tag", type: "info", size: this.size }, "+", total - this.maxTagsVisible));
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
this.displayLabel = this.extractLabelForSelectedItem(value, items);
|
|
337
|
-
this.displayTags = [];
|
|
338
|
-
}
|
|
339
|
-
const hasSelection = this.hasSelection();
|
|
340
|
-
if (hasSelection) {
|
|
341
|
-
this.touched = true;
|
|
342
|
-
}
|
|
343
|
-
if (this.input && this.touched) {
|
|
344
|
-
if (!this.autocomplete) {
|
|
345
|
-
this.input.value = hasSelection ? this.displayLabel : '';
|
|
346
|
-
}
|
|
347
|
-
else if (hasSelection) {
|
|
348
|
-
this.input.value = Array.isArray(this.value) ? this.value.join(',') : this.value;
|
|
349
|
-
}
|
|
350
|
-
this.invalid = !this.input.checkValidity();
|
|
404
|
+
await this.dropdown.reposition();
|
|
351
405
|
}
|
|
352
406
|
}
|
|
353
407
|
extractLabelForSelectedItem(value, items) {
|
|
@@ -361,23 +415,34 @@ const SixSelect = class {
|
|
|
361
415
|
const checkedItem = items.find((item) => item.value === value[0]);
|
|
362
416
|
return checkedItem ? this.getItemLabel(checkedItem) : '';
|
|
363
417
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
418
|
+
toggleItem(item) {
|
|
419
|
+
var _a;
|
|
420
|
+
const value = getValue(this.value, this.multiple, (_a = this.options) !== null && _a !== void 0 ? _a : this.getItems());
|
|
421
|
+
if (Array.isArray(value)) {
|
|
422
|
+
const itemFound = value.find((v) => v === item.value);
|
|
423
|
+
if (itemFound == null) {
|
|
424
|
+
this.value = [...this.value, item.value];
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
this.value = value.filter((v) => v !== item.value);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
if (item.value === value) {
|
|
432
|
+
this.value = '';
|
|
433
|
+
}
|
|
434
|
+
else {
|
|
435
|
+
this.value = item.value;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
373
438
|
}
|
|
374
439
|
displayError() {
|
|
375
440
|
return this.invalid && (!this.errorOnBlur || (!this.hasFocus && !this.isOpen));
|
|
376
441
|
}
|
|
377
442
|
render() {
|
|
378
443
|
var _a;
|
|
379
|
-
const hasSelection = this.
|
|
380
|
-
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.customErrorText ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: this.size, onLabelClick: this.handleLabelClick, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("six-dropdown", { part: "base", ref: (el) => (this.dropdown = el), hoist: this.hoist, closeOnSelect: !this.multiple, containingElement: this.host, disableHideOnEnterAndSpace: this.autocomplete, class: {
|
|
444
|
+
const hasSelection = !isValueEmpty(this.value);
|
|
445
|
+
return (h(FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, errorTextId: this.errorTextId, errorText: this.customErrorText != null ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, size: this.size, onLabelClick: this.handleLabelClick, disabled: this.disabled, required: this.required, displayError: this.displayError() }, h("six-dropdown", { part: "base", ref: (el) => (this.dropdown = el), hoist: this.hoist, closeOnSelect: !this.multiple, containingElement: this.host, disableHideOnEnterAndSpace: this.autocomplete, class: {
|
|
381
446
|
select: true,
|
|
382
447
|
'select--open': this.isOpen,
|
|
383
448
|
'select--empty': ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) === 0,
|
|
@@ -396,20 +461,14 @@ const SixSelect = class {
|
|
|
396
461
|
select__box: true,
|
|
397
462
|
'select__box--line': this.line,
|
|
398
463
|
'select__box--autocomplete': this.autocomplete,
|
|
399
|
-
}, role: "combobox", "aria-labelledby": this.labelId, "aria-describedby": this.helpTextId, "aria-haspopup": "true", "aria-expanded": this.isOpen ? 'true' : 'false', tabIndex: this.disabled ? -1 : 0, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown }, h("span", { class: "select__label" }, this.displayTags.length ? (h("span", { part: "tags", class: "select__tags" }, this.displayTags)) : (this.displayLabel || this.placeholder)), this.clearable && hasSelection && (h("six-icon-button", { exportparts: "base:clear-button", class: "select__clear", name: "clear", size: "small", onClick: this.handleClearClick, tabindex: "-1" })), this.hasMenuItems() && (h("span", { part: "icon", class: "select__icon" }, h("six-icon", { size: "medium" }, "expand_more"))), h("six-input", { ref: (el) => (this.
|
|
464
|
+
}, role: "combobox", "aria-labelledby": this.labelId, "aria-describedby": this.helpTextId, "aria-haspopup": "true", "aria-expanded": this.isOpen ? 'true' : 'false', tabIndex: this.disabled ? -1 : 0, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyDown: this.handleKeyDown }, h("span", { class: "select__label" }, this.displayTags.length ? (h("span", { part: "tags", class: "select__tags" }, this.displayTags)) : (this.displayLabel || this.placeholder)), this.clearable && hasSelection && (h("six-icon-button", { exportparts: "base:clear-button", class: "select__clear", name: "clear", size: "small", onClick: this.handleClearClick, tabindex: "-1" })), this.hasMenuItems() && (h("span", { part: "icon", class: "select__icon" }, h("six-icon", { size: "medium" }, "expand_more"))), h("six-input", { ref: (el) => (this.inputElement = el), class: {
|
|
400
465
|
select__input: true,
|
|
401
466
|
'select__hidden-select': !this.autocomplete,
|
|
402
467
|
}, "aria-hidden": "true", required: this.required, onInvalid: this.handleInvalid, onFocus: this.handleFocus, clearable: this.clearable, placeholder: this.placeholder, pill: this.pill, disabled: this.disabled, size: this.size, tabIndex: -1 })), h("six-menu", { ref: (el) => (this.menu = el), part: "menu", class: {
|
|
403
468
|
select__menu: true,
|
|
404
469
|
'select__menu--filtered': this.filter || this.asyncFilter,
|
|
405
470
|
'select__menu--hidden': !this.hasMenuItems(),
|
|
406
|
-
}, "onSix-menu-item-selected": this.
|
|
407
|
-
}
|
|
408
|
-
hasSelection() {
|
|
409
|
-
if (this.multiple) {
|
|
410
|
-
return Array.isArray(this.value) ? this.value.length > 0 : false;
|
|
411
|
-
}
|
|
412
|
-
return this.value !== '';
|
|
471
|
+
}, "onSix-menu-item-selected": (event) => this.toggleItem(event.detail.item), items: this.options, virtualScroll: this.virtualScroll, "remove-box-shadow": true }, h("slot", { onSlotchange: this.handleSlotChange })))));
|
|
413
472
|
}
|
|
414
473
|
get host() { return getElement(this); }
|
|
415
474
|
static get watchers() { return {
|