tuix-webcomponents 0.62.0 → 0.64.0
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 +2 -2
- package/dist/addon-visual-tests-assets/visual-test-illustration.mp4 +0 -0
- package/dist/assets/Color-AVL7NMMY-IH_JbDEF.js +1 -0
- package/dist/assets/DocsRenderer-PQXLIZUC-C0ZKNA9m.js +1286 -0
- package/dist/{src/tuix-icon/TuixIcon.icons.js → assets/TuixIconButton-eQtxZNXh.js} +203 -126
- package/dist/assets/TuixModal-BZFIHTi_.js +78 -0
- package/dist/assets/TuixToast-BhxwZIGo.js +62 -0
- package/dist/assets/_commonjsHelpers-CqkleIqs.js +1 -0
- package/dist/assets/axe-C59a3kt3.js +30 -0
- package/dist/assets/iframe-ClsPaEIM.js +1057 -0
- package/dist/assets/index-DBzYXxxs.js +1554 -0
- package/dist/assets/index-TjhCmV-u.js +1 -0
- package/dist/assets/matchers-7Z3WT2CE-CcSi9QFY.js +14 -0
- package/dist/assets/screenSizes.enum-C1IhC_dy.js +13 -0
- package/dist/assets/state-CLjydI9z.js +13 -0
- package/dist/assets/tuix-button.stories-Dm_yifox.js +30 -0
- package/dist/assets/tuix-checkbox.stories-DmzoygjC.js +44 -0
- package/dist/assets/tuix-dropdown-object-list.stories-Neeajtj-.js +56 -0
- package/dist/assets/tuix-dropdown.stories-B7ea8QAz.js +28 -0
- package/dist/assets/tuix-icon-button.stories-CgbOSRO4.js +21 -0
- package/dist/assets/tuix-icon.enums-DYTtwLZl.js +1 -0
- package/dist/assets/tuix-icon.stories-CjN2XsKx.js +19 -0
- package/dist/assets/tuix-input.stories-CD7onvw2.js +33 -0
- package/dist/assets/tuix-link.stories-CT7pzGlx.js +35 -0
- package/dist/assets/tuix-modal.stories-B6v3cOPq.js +39 -0
- package/dist/assets/tuix-paper.enum-DhmlUJB7.js +1 -0
- package/dist/assets/tuix-paper.stories-CLnRPHNK.js +31 -0
- package/dist/assets/tuix-radio-button.stories-BwkKC3a9.js +35 -0
- package/dist/assets/tuix-table.stories-Bn-aZa0J.js +65 -0
- package/dist/assets/tuix-text.enums-Ck8cVqZZ.js +1 -0
- package/dist/assets/tuix-text.stories-BNIqPsGD.js +29 -0
- package/dist/assets/tuix-toast.stories-CRYiLiHK.js +21 -0
- package/dist/assets/tuix-toggle-button.stories-CY6wlDnA.js +40 -0
- package/dist/favicon-wrapper.svg +46 -0
- package/dist/favicon.svg +1 -0
- package/dist/iframe.html +685 -0
- package/dist/index.html +160 -0
- package/dist/index.json +1 -0
- package/dist/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/nunito-sans-bold.woff2 +0 -0
- package/dist/nunito-sans-italic.woff2 +0 -0
- package/dist/nunito-sans-regular.woff2 +0 -0
- package/dist/project.json +1 -0
- package/dist/sb-addons/a11y-3/manager-bundle.js +5 -0
- package/dist/sb-addons/a11y-3/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/chromatic-com-storybook-1/manager-bundle.js +356 -0
- package/dist/sb-addons/chromatic-com-storybook-1/manager-bundle.js.LEGAL.txt +40 -0
- package/dist/sb-addons/docs-2/manager-bundle.js +151 -0
- package/dist/sb-addons/docs-2/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +971 -0
- package/dist/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-addons/vitest-4/manager-bundle.js +3 -0
- package/dist/sb-addons/vitest-4/manager-bundle.js.LEGAL.txt +0 -0
- package/dist/sb-common-assets/favicon-wrapper.svg +46 -0
- package/dist/sb-common-assets/favicon.svg +1 -0
- package/dist/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/dist/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/dist/sb-manager/globals-module-info.js +797 -0
- package/dist/sb-manager/globals-runtime.js +69679 -0
- package/dist/sb-manager/globals.js +34 -0
- package/dist/sb-manager/runtime.js +13195 -0
- package/package.json +77 -53
- package/dist/assets/tuix-styles.css +0 -58
- package/dist/src/index.d.ts +0 -36
- package/dist/src/index.js +0 -43
- package/dist/src/index.js.map +0 -1
- package/dist/src/tuix-button/TuixBaseButton.d.ts +0 -17
- package/dist/src/tuix-button/TuixBaseButton.js +0 -62
- package/dist/src/tuix-button/TuixBaseButton.js.map +0 -1
- package/dist/src/tuix-button/TuixButton.d.ts +0 -11
- package/dist/src/tuix-button/TuixButton.js +0 -85
- package/dist/src/tuix-button/TuixButton.js.map +0 -1
- package/dist/src/tuix-button/TuixButton.styles.d.ts +0 -3
- package/dist/src/tuix-button/TuixButton.styles.js +0 -108
- package/dist/src/tuix-button/TuixButton.styles.js.map +0 -1
- package/dist/src/tuix-button/enums/tuix-button.enums.d.ts +0 -2
- package/dist/src/tuix-button/enums/tuix-button.enums.js +0 -7
- package/dist/src/tuix-button/enums/tuix-button.enums.js.map +0 -1
- package/dist/src/tuix-button/interfaces/tuix-button.interface.d.ts +0 -1
- package/dist/src/tuix-button/interfaces/tuix-button.interface.js +0 -2
- package/dist/src/tuix-button/interfaces/tuix-button.interface.js.map +0 -1
- package/dist/src/tuix-checkbox/TuixCheckbox.d.ts +0 -15
- package/dist/src/tuix-checkbox/TuixCheckbox.js +0 -107
- package/dist/src/tuix-checkbox/TuixCheckbox.js.map +0 -1
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.d.ts +0 -4
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.js +0 -133
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.js.map +0 -1
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +0 -21
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.js +0 -24
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.js.map +0 -1
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +0 -5
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js +0 -2
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js.map +0 -1
- package/dist/src/tuix-dropdown/TuixDropdown.d.ts +0 -55
- package/dist/src/tuix-dropdown/TuixDropdown.js +0 -368
- package/dist/src/tuix-dropdown/TuixDropdown.js.map +0 -1
- package/dist/src/tuix-dropdown/TuixDropdown.styles.d.ts +0 -3
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js +0 -126
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js.map +0 -1
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +0 -4
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js +0 -6
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js.map +0 -1
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +0 -15
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +0 -2
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js.map +0 -1
- package/dist/src/tuix-icon/TuixIcon.d.ts +0 -15
- package/dist/src/tuix-icon/TuixIcon.icons.d.ts +0 -6
- package/dist/src/tuix-icon/TuixIcon.icons.js.map +0 -1
- package/dist/src/tuix-icon/TuixIcon.js +0 -81
- package/dist/src/tuix-icon/TuixIcon.js.map +0 -1
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +0 -62
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +0 -70
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js.map +0 -1
- package/dist/src/tuix-icon-button/TuixIconButton.d.ts +0 -9
- package/dist/src/tuix-icon-button/TuixIconButton.js +0 -52
- package/dist/src/tuix-icon-button/TuixIconButton.js.map +0 -1
- package/dist/src/tuix-input/TuixInput.d.ts +0 -52
- package/dist/src/tuix-input/TuixInput.js +0 -374
- package/dist/src/tuix-input/TuixInput.js.map +0 -1
- package/dist/src/tuix-input/TuixInput.styles.d.ts +0 -8
- package/dist/src/tuix-input/TuixInput.styles.js +0 -296
- package/dist/src/tuix-input/TuixInput.styles.js.map +0 -1
- package/dist/src/tuix-input/enums/tuix-input.enums.d.ts +0 -38
- package/dist/src/tuix-input/enums/tuix-input.enums.js +0 -42
- package/dist/src/tuix-input/enums/tuix-input.enums.js.map +0 -1
- package/dist/src/tuix-input/interfaces/tuix-input.interface.d.ts +0 -17
- package/dist/src/tuix-input/interfaces/tuix-input.interface.js +0 -7
- package/dist/src/tuix-input/interfaces/tuix-input.interface.js.map +0 -1
- package/dist/src/tuix-link/TuixLink.d.ts +0 -15
- package/dist/src/tuix-link/TuixLink.js +0 -72
- package/dist/src/tuix-link/TuixLink.js.map +0 -1
- package/dist/src/tuix-link/TuixLink.styles.d.ts +0 -2
- package/dist/src/tuix-link/TuixLink.styles.js +0 -56
- package/dist/src/tuix-link/TuixLink.styles.js.map +0 -1
- package/dist/src/tuix-link/enums/linkTarget.enum.d.ts +0 -6
- package/dist/src/tuix-link/enums/linkTarget.enum.js +0 -8
- package/dist/src/tuix-link/enums/linkTarget.enum.js.map +0 -1
- package/dist/src/tuix-modal/TuixModal.d.ts +0 -9
- package/dist/src/tuix-modal/TuixModal.js +0 -64
- package/dist/src/tuix-modal/TuixModal.js.map +0 -1
- package/dist/src/tuix-modal/TuixModal.styles.d.ts +0 -2
- package/dist/src/tuix-modal/TuixModal.styles.js +0 -56
- package/dist/src/tuix-modal/TuixModal.styles.js.map +0 -1
- package/dist/src/tuix-paper/TuixPaper.d.ts +0 -10
- package/dist/src/tuix-paper/TuixPaper.js +0 -47
- package/dist/src/tuix-paper/TuixPaper.js.map +0 -1
- package/dist/src/tuix-paper/TuixPaper.styles.d.ts +0 -1
- package/dist/src/tuix-paper/TuixPaper.styles.js +0 -31
- package/dist/src/tuix-paper/TuixPaper.styles.js.map +0 -1
- package/dist/src/tuix-paper/enums/tuix-paper.enum.d.ts +0 -13
- package/dist/src/tuix-paper/enums/tuix-paper.enum.js +0 -16
- package/dist/src/tuix-paper/enums/tuix-paper.enum.js.map +0 -1
- package/dist/src/tuix-radio-button/TuixRadioButton.d.ts +0 -16
- package/dist/src/tuix-radio-button/TuixRadioButton.js +0 -96
- package/dist/src/tuix-radio-button/TuixRadioButton.js.map +0 -1
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.d.ts +0 -5
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.js +0 -136
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.js.map +0 -1
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +0 -3
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js +0 -2
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js.map +0 -1
- package/dist/src/tuix-table/TuixTable.d.ts +0 -46
- package/dist/src/tuix-table/TuixTable.js +0 -373
- package/dist/src/tuix-table/TuixTable.js.map +0 -1
- package/dist/src/tuix-table/TuixTable.styles.d.ts +0 -2
- package/dist/src/tuix-table/TuixTable.styles.js +0 -198
- package/dist/src/tuix-table/TuixTable.styles.js.map +0 -1
- package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +0 -45
- package/dist/src/tuix-table/interfaces/tuix-table.interface.js +0 -2
- package/dist/src/tuix-table/interfaces/tuix-table.interface.js.map +0 -1
- package/dist/src/tuix-text/TuixText.d.ts +0 -12
- package/dist/src/tuix-text/TuixText.js +0 -67
- package/dist/src/tuix-text/TuixText.js.map +0 -1
- package/dist/src/tuix-text/TuixText.styles.d.ts +0 -2
- package/dist/src/tuix-text/TuixText.styles.js +0 -159
- package/dist/src/tuix-text/TuixText.styles.js.map +0 -1
- package/dist/src/tuix-text/enums/tuix-text.enums.d.ts +0 -31
- package/dist/src/tuix-text/enums/tuix-text.enums.js +0 -64
- package/dist/src/tuix-text/enums/tuix-text.enums.js.map +0 -1
- package/dist/src/tuix-toast/TuixToast.d.ts +0 -15
- package/dist/src/tuix-toast/TuixToast.js +0 -101
- package/dist/src/tuix-toast/TuixToast.js.map +0 -1
- package/dist/src/tuix-toast/TuixToast.styles.d.ts +0 -3
- package/dist/src/tuix-toast/TuixToast.styles.js +0 -44
- package/dist/src/tuix-toast/TuixToast.styles.js.map +0 -1
- package/dist/src/tuix-toast/enums/tuix-toast.enums.d.ts +0 -20
- package/dist/src/tuix-toast/enums/tuix-toast.enums.js +0 -60
- package/dist/src/tuix-toast/enums/tuix-toast.enums.js.map +0 -1
- package/dist/src/tuix-toggle-button/TuixToggleButton.d.ts +0 -13
- package/dist/src/tuix-toggle-button/TuixToggleButton.js +0 -86
- package/dist/src/tuix-toggle-button/TuixToggleButton.js.map +0 -1
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.d.ts +0 -5
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.js +0 -135
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.js.map +0 -1
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +0 -2
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js +0 -2
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js.map +0 -1
- package/dist/src/utils/colors.d.ts +0 -29
- package/dist/src/utils/colors.js +0 -31
- package/dist/src/utils/colors.js.map +0 -1
- package/dist/src/utils/darkColors.d.ts +0 -31
- package/dist/src/utils/darkColors.js +0 -33
- package/dist/src/utils/darkColors.js.map +0 -1
- package/dist/src/utils/hex-rgb.d.ts +0 -5
- package/dist/src/utils/hex-rgb.js +0 -16
- package/dist/src/utils/hex-rgb.js.map +0 -1
- package/dist/src/utils/interfaces/detail-value.interface.d.ts +0 -3
- package/dist/src/utils/interfaces/detail-value.interface.js +0 -2
- package/dist/src/utils/interfaces/detail-value.interface.js.map +0 -1
- package/dist/src/utils/mainVariant.enum.d.ts +0 -4
- package/dist/src/utils/mainVariant.enum.js +0 -6
- package/dist/src/utils/mainVariant.enum.js.map +0 -1
- package/dist/src/utils/screenSizes.enum.d.ts +0 -4
- package/dist/src/utils/screenSizes.enum.js +0 -6
- package/dist/src/utils/screenSizes.enum.js.map +0 -1
- package/dist/src/utils/slottedClassName.d.ts +0 -2
- package/dist/src/utils/slottedClassName.js +0 -2
- package/dist/src/utils/slottedClassName.js.map +0 -1
- package/dist/tsconfig.publish.tsbuildinfo +0 -1
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { LitElement, html } from 'lit';
|
|
3
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
-
import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
|
|
6
|
-
import { dropdownHostStyles, dropdownMainContainerStyles, dropdownOptionStyles, } from './TuixDropdown.styles.js';
|
|
7
|
-
import { DescriptionType } from '../tuix-input/enums/tuix-input.enums.js';
|
|
8
|
-
import { DropdownType } from './enums/tuix-dropdown.enums.js';
|
|
9
|
-
let TuixDropdown = class TuixDropdown extends LitElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments);
|
|
12
|
-
this.value = undefined;
|
|
13
|
-
this.options = [];
|
|
14
|
-
this.placeholder = '';
|
|
15
|
-
this.title = '';
|
|
16
|
-
this.disabled = false;
|
|
17
|
-
this.dark = false;
|
|
18
|
-
this.descriptionType = DescriptionType.TEXT;
|
|
19
|
-
this.type = DropdownType.SINGLE;
|
|
20
|
-
this._value = '';
|
|
21
|
-
this._isOptionsVisible = false;
|
|
22
|
-
this._searchingOption = false;
|
|
23
|
-
this._extendedOptions = [];
|
|
24
|
-
this._previousSelectedOption = null;
|
|
25
|
-
this._previousFocusedOption = null;
|
|
26
|
-
this._handleClickOutside = (event) => {
|
|
27
|
-
if (!event.composedPath().includes(this)) {
|
|
28
|
-
this._isOptionsVisible = false;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
connectedCallback() {
|
|
33
|
-
super.connectedCallback();
|
|
34
|
-
window.addEventListener('click', this._handleClickOutside);
|
|
35
|
-
this.addEventListener('blur', this._handleBlur.bind(this));
|
|
36
|
-
}
|
|
37
|
-
disconnectedCallback() {
|
|
38
|
-
window.removeEventListener('click', this._handleClickOutside);
|
|
39
|
-
super.disconnectedCallback();
|
|
40
|
-
}
|
|
41
|
-
_onEnterPress(event) {
|
|
42
|
-
if (event.key === 'Enter') {
|
|
43
|
-
this._toggleOptions();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
_onKeyDownOption(event) {
|
|
47
|
-
switch (event.key) {
|
|
48
|
-
case 'ArrowDown':
|
|
49
|
-
return this._handleArrowDown();
|
|
50
|
-
case 'ArrowUp':
|
|
51
|
-
return this._handleArrowUp();
|
|
52
|
-
case 'Escape':
|
|
53
|
-
this._isOptionsVisible = false;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
_onKeyPressOption(event) {
|
|
58
|
-
if (event.key === 'Enter') {
|
|
59
|
-
this._onClickOption(event);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
_onMouseOverOption(event) {
|
|
63
|
-
const optionTarget = event.target;
|
|
64
|
-
this._focusTargetOption(optionTarget);
|
|
65
|
-
}
|
|
66
|
-
_onClickOption(event) {
|
|
67
|
-
const optionTarget = event.target;
|
|
68
|
-
this._value = optionTarget.innerText;
|
|
69
|
-
this._isOptionsVisible = false;
|
|
70
|
-
this._unselectPreviousOption();
|
|
71
|
-
optionTarget.classList.add('t-option-selected');
|
|
72
|
-
this._previousSelectedOption = optionTarget;
|
|
73
|
-
this._handleSelectEvent(event);
|
|
74
|
-
}
|
|
75
|
-
_onInputSingle(e) {
|
|
76
|
-
this._handleInputBase(e, 'input-single');
|
|
77
|
-
}
|
|
78
|
-
_handleSelectEvent(event) {
|
|
79
|
-
const optionIndex = event.target.getAttribute('data-value');
|
|
80
|
-
const selectedValue = this.options[Number(optionIndex)];
|
|
81
|
-
this.dispatchEvent(new CustomEvent('select', {
|
|
82
|
-
detail: {
|
|
83
|
-
value: this._getOptionValue(selectedValue),
|
|
84
|
-
},
|
|
85
|
-
bubbles: true,
|
|
86
|
-
}));
|
|
87
|
-
if (this.type === DropdownType.SEARCH) {
|
|
88
|
-
this._extendOptionsList(this._getOptionName(selectedValue));
|
|
89
|
-
this._searchingOption = false;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
_handleBlur() {
|
|
93
|
-
var _a;
|
|
94
|
-
if (this.type === DropdownType.SEARCH && this._searchingOption) {
|
|
95
|
-
const optionIndex = (_a = this._previousSelectedOption) === null || _a === void 0 ? void 0 : _a.getAttribute('data-value');
|
|
96
|
-
const selectedValue = typeof optionIndex === 'string'
|
|
97
|
-
? this.options[Number(optionIndex)]
|
|
98
|
-
: '';
|
|
99
|
-
this._value = this._getOptionName(selectedValue);
|
|
100
|
-
this._extendOptionsList();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
_getOptionName(option) {
|
|
104
|
-
return String(typeof option === 'object' ? option === null || option === void 0 ? void 0 : option.name : option);
|
|
105
|
-
}
|
|
106
|
-
_getOptionValue(option) {
|
|
107
|
-
return typeof option === 'object' ? option.value : option;
|
|
108
|
-
}
|
|
109
|
-
_findIndex(option) {
|
|
110
|
-
return this._extendedOptions.findIndex(opt => opt.value === this._getOptionValue(option));
|
|
111
|
-
}
|
|
112
|
-
_handleInputBase(e, eventName) {
|
|
113
|
-
if (!this._searchingOption) {
|
|
114
|
-
this._searchingOption = true;
|
|
115
|
-
}
|
|
116
|
-
this._extendOptionsList(e.detail.value);
|
|
117
|
-
this._isOptionsVisible = true;
|
|
118
|
-
this.dispatchEvent(new CustomEvent(eventName, {
|
|
119
|
-
detail: {
|
|
120
|
-
value: e.detail.value,
|
|
121
|
-
},
|
|
122
|
-
bubbles: true,
|
|
123
|
-
}));
|
|
124
|
-
this._value = e.detail.value;
|
|
125
|
-
}
|
|
126
|
-
_extendOptionsList(value = '') {
|
|
127
|
-
value = value.trim();
|
|
128
|
-
this._extendedOptions = this.options.map(option => {
|
|
129
|
-
const optionName = this._getOptionName(option);
|
|
130
|
-
return {
|
|
131
|
-
name: optionName,
|
|
132
|
-
value: this._getOptionValue(option),
|
|
133
|
-
filtered: this.type === DropdownType.SEARCH &&
|
|
134
|
-
value !== '' &&
|
|
135
|
-
!optionName.toLowerCase().includes(value.toLowerCase()),
|
|
136
|
-
};
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
_handleArrowDown() {
|
|
140
|
-
var _a;
|
|
141
|
-
const nextOption = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.nextElementSibling;
|
|
142
|
-
if (nextOption) {
|
|
143
|
-
this._focusTargetOption(nextOption);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
_handleArrowUp() {
|
|
147
|
-
var _a;
|
|
148
|
-
const previousOption = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.previousElementSibling;
|
|
149
|
-
if (previousOption) {
|
|
150
|
-
this._focusTargetOption(previousOption);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
_focusTargetOption(targetOption, extrict = true) {
|
|
154
|
-
var _a, _b;
|
|
155
|
-
(_b = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('t-option-hover');
|
|
156
|
-
targetOption === null || targetOption === void 0 ? void 0 : targetOption.classList.add('t-option-hover');
|
|
157
|
-
if (extrict) {
|
|
158
|
-
targetOption === null || targetOption === void 0 ? void 0 : targetOption.focus();
|
|
159
|
-
}
|
|
160
|
-
this._previousFocusedOption = targetOption;
|
|
161
|
-
}
|
|
162
|
-
_toggleOptions() {
|
|
163
|
-
var _a, _b, _c, _d;
|
|
164
|
-
if (this.disabled) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
this._isOptionsVisible = !this._isOptionsVisible;
|
|
168
|
-
if (this._isOptionsVisible &&
|
|
169
|
-
this.type === DropdownType.SEARCH &&
|
|
170
|
-
this._previousSelectedOption) {
|
|
171
|
-
(_a = this._optionsContainer) === null || _a === void 0 ? void 0 : _a.scrollTo({
|
|
172
|
-
top: this._previousSelectedOption.offsetTop,
|
|
173
|
-
behavior: 'auto',
|
|
174
|
-
});
|
|
175
|
-
(_d = (_c = (_b = this._inputDropdown) === null || _b === void 0 ? void 0 : _b.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('input')) === null || _d === void 0 ? void 0 : _d.select();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
_focusOptionsContainer() {
|
|
179
|
-
var _a, _b, _c;
|
|
180
|
-
if (this.type === DropdownType.SEARCH) {
|
|
181
|
-
if (this._previousSelectedOption) {
|
|
182
|
-
this._focusTargetOption(this._previousSelectedOption, false);
|
|
183
|
-
}
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (!this._isOptionsVisible || !this._optionsContainer) {
|
|
187
|
-
(_c = (_b = (_a = this._inputDropdown) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('input')) === null || _c === void 0 ? void 0 : _c.focus();
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (this._previousSelectedOption) {
|
|
191
|
-
this._focusTargetOption(this._previousSelectedOption);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const firstOption = this._optionsContainer
|
|
195
|
-
.firstElementChild;
|
|
196
|
-
if (firstOption) {
|
|
197
|
-
this._focusTargetOption(firstOption);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
_unselectPreviousOption() {
|
|
202
|
-
var _a;
|
|
203
|
-
if (this._previousSelectedOption) {
|
|
204
|
-
(_a = this._previousSelectedOption.classList) === null || _a === void 0 ? void 0 : _a.remove('t-option-selected');
|
|
205
|
-
this._previousSelectedOption = null;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
_hasCompleteDescription() {
|
|
209
|
-
const isValidDescriptionType = Object.values(DescriptionType).includes(this.descriptionType);
|
|
210
|
-
return (isValidDescriptionType &&
|
|
211
|
-
(this.descriptionType === DescriptionType.TEXT
|
|
212
|
-
? !!this.description
|
|
213
|
-
: true));
|
|
214
|
-
}
|
|
215
|
-
_getOptionsContainerClasses() {
|
|
216
|
-
return {
|
|
217
|
-
't-options-container': true,
|
|
218
|
-
show: this._isOptionsVisible,
|
|
219
|
-
't-with-description': this._hasCompleteDescription(),
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
_triggerUpdateByExternalValueChange() {
|
|
223
|
-
var _a;
|
|
224
|
-
this._unselectPreviousOption();
|
|
225
|
-
if (!this.value) {
|
|
226
|
-
this._value = '';
|
|
227
|
-
this._extendOptionsList();
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const index = this._findIndex(this.value);
|
|
231
|
-
if (this.type === DropdownType.SEARCH) {
|
|
232
|
-
this._extendOptionsList('');
|
|
233
|
-
}
|
|
234
|
-
if (index < 0) {
|
|
235
|
-
this._value = '';
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
const optionTarget = (_a = this._optionsContainer) === null || _a === void 0 ? void 0 : _a.children[index];
|
|
239
|
-
optionTarget === null || optionTarget === void 0 ? void 0 : optionTarget.classList.add('t-option-selected');
|
|
240
|
-
this._previousSelectedOption = optionTarget || null;
|
|
241
|
-
this._value = optionTarget ? this._getOptionName(this.options[index]) : '';
|
|
242
|
-
}
|
|
243
|
-
_resetPreviousSelection() {
|
|
244
|
-
this._value = '';
|
|
245
|
-
this._unselectPreviousOption();
|
|
246
|
-
}
|
|
247
|
-
_getOptionsTemplate() {
|
|
248
|
-
var _a;
|
|
249
|
-
if (this.type === DropdownType.SINGLE || this._searchingOption === false) {
|
|
250
|
-
this._extendOptionsList();
|
|
251
|
-
}
|
|
252
|
-
return (_a = this._extendedOptions) === null || _a === void 0 ? void 0 : _a.map((option, index) => {
|
|
253
|
-
return html `<div
|
|
254
|
-
class="${classMap({
|
|
255
|
-
't-dropdown-option': true,
|
|
256
|
-
't-option-filtered': option.filtered,
|
|
257
|
-
})}"
|
|
258
|
-
@click="${this._onClickOption}"
|
|
259
|
-
data-value="${index}"
|
|
260
|
-
tabindex="0"
|
|
261
|
-
@keydown="${this._onKeyDownOption}"
|
|
262
|
-
@keypress="${this._onKeyPressOption}"
|
|
263
|
-
@mouseover="${this._onMouseOverOption}"
|
|
264
|
-
>
|
|
265
|
-
${option.name}
|
|
266
|
-
</div>`;
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
updated(changedProperties) {
|
|
270
|
-
if (changedProperties.has('_isOptionsVisible')) {
|
|
271
|
-
this._focusOptionsContainer();
|
|
272
|
-
}
|
|
273
|
-
else if (changedProperties.has('value')) {
|
|
274
|
-
this._triggerUpdateByExternalValueChange();
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
willUpdate(changedProperties) {
|
|
278
|
-
if (changedProperties.has('options')) {
|
|
279
|
-
this._resetPreviousSelection();
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
firstUpdated(changedProperties) {
|
|
283
|
-
super.firstUpdated(changedProperties);
|
|
284
|
-
this._triggerUpdateByExternalValueChange();
|
|
285
|
-
}
|
|
286
|
-
render() {
|
|
287
|
-
return html `<div class="t-dropdown-full-container">
|
|
288
|
-
<div class="t-dropdown-container">
|
|
289
|
-
<tuix-input
|
|
290
|
-
.value="${this._value}"
|
|
291
|
-
class="t-input-dropdown"
|
|
292
|
-
iconRight="${this._isOptionsVisible
|
|
293
|
-
? IconName.CHEVRON_UP
|
|
294
|
-
: IconName.CHEVRON_DOWN}"
|
|
295
|
-
placeholder="${this.placeholder}"
|
|
296
|
-
title="${this.title}"
|
|
297
|
-
.description="${this.description}"
|
|
298
|
-
descriptionType="${this.descriptionType}"
|
|
299
|
-
?disabled="${this.disabled}"
|
|
300
|
-
?dark="${this.dark}"
|
|
301
|
-
?readonly="${this.type !== DropdownType.SEARCH}"
|
|
302
|
-
@on-click="${this._toggleOptions}"
|
|
303
|
-
@keypress="${this._onEnterPress}"
|
|
304
|
-
@on-change="${this._onInputSingle}"
|
|
305
|
-
>
|
|
306
|
-
</tuix-input>
|
|
307
|
-
</div>
|
|
308
|
-
<div class="${classMap(this._getOptionsContainerClasses())}">
|
|
309
|
-
${this._getOptionsTemplate()}
|
|
310
|
-
</div>
|
|
311
|
-
</div>`;
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
TuixDropdown.styles = [
|
|
315
|
-
dropdownHostStyles,
|
|
316
|
-
dropdownMainContainerStyles,
|
|
317
|
-
dropdownOptionStyles,
|
|
318
|
-
];
|
|
319
|
-
__decorate([
|
|
320
|
-
property({ type: Object })
|
|
321
|
-
], TuixDropdown.prototype, "value", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
property({ type: Array })
|
|
324
|
-
], TuixDropdown.prototype, "options", void 0);
|
|
325
|
-
__decorate([
|
|
326
|
-
property({ type: String })
|
|
327
|
-
], TuixDropdown.prototype, "placeholder", void 0);
|
|
328
|
-
__decorate([
|
|
329
|
-
property({ type: String })
|
|
330
|
-
], TuixDropdown.prototype, "title", void 0);
|
|
331
|
-
__decorate([
|
|
332
|
-
property({ type: Boolean, reflect: true })
|
|
333
|
-
], TuixDropdown.prototype, "disabled", void 0);
|
|
334
|
-
__decorate([
|
|
335
|
-
property({ type: Boolean, reflect: true })
|
|
336
|
-
], TuixDropdown.prototype, "dark", void 0);
|
|
337
|
-
__decorate([
|
|
338
|
-
property({ type: String })
|
|
339
|
-
], TuixDropdown.prototype, "description", void 0);
|
|
340
|
-
__decorate([
|
|
341
|
-
property({ type: DescriptionType })
|
|
342
|
-
], TuixDropdown.prototype, "descriptionType", void 0);
|
|
343
|
-
__decorate([
|
|
344
|
-
property({ type: String })
|
|
345
|
-
], TuixDropdown.prototype, "type", void 0);
|
|
346
|
-
__decorate([
|
|
347
|
-
state()
|
|
348
|
-
], TuixDropdown.prototype, "_value", void 0);
|
|
349
|
-
__decorate([
|
|
350
|
-
state()
|
|
351
|
-
], TuixDropdown.prototype, "_isOptionsVisible", void 0);
|
|
352
|
-
__decorate([
|
|
353
|
-
state()
|
|
354
|
-
], TuixDropdown.prototype, "_searchingOption", void 0);
|
|
355
|
-
__decorate([
|
|
356
|
-
state()
|
|
357
|
-
], TuixDropdown.prototype, "_extendedOptions", void 0);
|
|
358
|
-
__decorate([
|
|
359
|
-
query('.t-options-container')
|
|
360
|
-
], TuixDropdown.prototype, "_optionsContainer", void 0);
|
|
361
|
-
__decorate([
|
|
362
|
-
query('.t-dropdown-container .t-input-dropdown')
|
|
363
|
-
], TuixDropdown.prototype, "_inputDropdown", void 0);
|
|
364
|
-
TuixDropdown = __decorate([
|
|
365
|
-
customElement('tuix-dropdown')
|
|
366
|
-
], TuixDropdown);
|
|
367
|
-
export { TuixDropdown };
|
|
368
|
-
//# sourceMappingURL=TuixDropdown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TuixDropdown.js","sourceRoot":"","sources":["../../../src/tuix-dropdown/TuixDropdown.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkC,IAAI,EAAE,MAAM,KAAK,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,UAAU;IAA5C;;QAQE,UAAK,GAAwB,SAAS,CAAC;QAGvC,YAA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aAAa,CAAC,eAAe,CAAC;GAClB,YAAY,CA4XxB;SA5XY,YAAY","sourcesContent":["import { LitElement, PropertyValues, TemplateResult, html } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\nimport { IconName } from '../tuix-icon/enums/tuix-icon.enums';\nimport {\n dropdownHostStyles,\n dropdownMainContainerStyles,\n dropdownOptionStyles,\n} from './TuixDropdown.styles';\nimport {\n TuixDropdownExtendedOption,\n TuixDropdownOption,\n TuixDropdownPlainOption,\n} from './interfaces/tuix-dropdown.interface';\nimport { DescriptionType } from '../tuix-input/enums/tuix-input.enums';\nimport { DropdownType } from './enums/tuix-dropdown.enums';\n\n@customElement('tuix-dropdown')\nexport class TuixDropdown extends LitElement {\n static styles = [\n dropdownHostStyles,\n dropdownMainContainerStyles,\n dropdownOptionStyles,\n ];\n\n @property({ type: Object })\n value?: TuixDropdownOption = undefined;\n\n @property({ type: Array })\n options: TuixDropdownOption[] = [];\n\n @property({ type: String })\n placeholder = '';\n\n @property({ type: String })\n title = '';\n\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @property({ type: Boolean, reflect: true })\n dark = false;\n\n @property({ type: String })\n description?: string;\n\n @property({ type: DescriptionType })\n descriptionType = DescriptionType.TEXT;\n\n @property({ type: String })\n type = DropdownType.SINGLE;\n\n @state()\n private _value = '';\n\n @state()\n private _isOptionsVisible = false;\n\n @state()\n private _searchingOption = false;\n\n @state()\n _extendedOptions: TuixDropdownExtendedOption[] = [];\n\n @query('.t-options-container')\n private _optionsContainer: HTMLElement | undefined;\n\n @query('.t-dropdown-container .t-input-dropdown')\n private _inputDropdown: HTMLElement | undefined;\n\n private _previousSelectedOption: HTMLElement | null = null;\n\n private _previousFocusedOption: HTMLElement | null = null;\n\n connectedCallback() {\n super.connectedCallback();\n window.addEventListener('click', this._handleClickOutside);\n this.addEventListener('blur', this._handleBlur.bind(this));\n }\n\n disconnectedCallback() {\n window.removeEventListener('click', this._handleClickOutside);\n super.disconnectedCallback();\n }\n\n private _onEnterPress(event: KeyboardEvent) {\n if (event.key === 'Enter') {\n this._toggleOptions();\n }\n }\n\n private _onKeyDownOption(event: KeyboardEvent) {\n switch (event.key) {\n case 'ArrowDown':\n return this._handleArrowDown();\n case 'ArrowUp':\n return this._handleArrowUp();\n case 'Escape':\n this._isOptionsVisible = false;\n break;\n }\n }\n\n private _onKeyPressOption(event: KeyboardEvent) {\n if (event.key === 'Enter') {\n this._onClickOption(event);\n }\n }\n\n private _onMouseOverOption(event: MouseEvent) {\n const optionTarget = event.target as HTMLElement;\n this._focusTargetOption(optionTarget);\n }\n\n private _onClickOption(event: MouseEvent | KeyboardEvent) {\n const optionTarget = event.target as HTMLElement;\n this._value = optionTarget.innerText;\n this._isOptionsVisible = false;\n this._unselectPreviousOption();\n optionTarget.classList.add('t-option-selected');\n this._previousSelectedOption = optionTarget;\n this._handleSelectEvent(event);\n }\n\n protected _onInputSingle(e: CustomEvent) {\n this._handleInputBase(e, 'input-single');\n }\n\n protected _handleSelectEvent(event: MouseEvent | KeyboardEvent) {\n const optionIndex = (event.target as HTMLOptionElement).getAttribute(\n 'data-value'\n );\n const selectedValue = this.options[Number(optionIndex)];\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: {\n value: this._getOptionValue(selectedValue),\n },\n bubbles: true,\n })\n );\n if (this.type === DropdownType.SEARCH) {\n this._extendOptionsList(this._getOptionName(selectedValue));\n this._searchingOption = false;\n }\n }\n\n private _handleBlur() {\n if (this.type === DropdownType.SEARCH && this._searchingOption) {\n const optionIndex =\n this._previousSelectedOption?.getAttribute('data-value');\n const selectedValue =\n typeof optionIndex === 'string'\n ? this.options[Number(optionIndex)]\n : '';\n this._value = this._getOptionName(selectedValue);\n this._extendOptionsList();\n }\n }\n\n private _getOptionName(option: TuixDropdownOption): string {\n return String(typeof option === 'object' ? option?.name : option);\n }\n\n private _getOptionValue(option: TuixDropdownOption): TuixDropdownPlainOption {\n return typeof option === 'object' ? option.value : option;\n }\n\n private _findIndex(option: TuixDropdownOption): number {\n return this._extendedOptions.findIndex(\n opt => opt.value === this._getOptionValue(option)\n );\n }\n\n private _handleInputBase(e: CustomEvent, eventName: string) {\n if (!this._searchingOption) {\n this._searchingOption = true;\n }\n this._extendOptionsList(e.detail.value);\n this._isOptionsVisible = true;\n this.dispatchEvent(\n new CustomEvent(eventName, {\n detail: {\n value: e.detail.value,\n },\n bubbles: true,\n })\n );\n this._value = e.detail.value;\n }\n\n private _extendOptionsList(value = '') {\n value = value.trim();\n this._extendedOptions = this.options.map(option => {\n const optionName = this._getOptionName(option);\n return {\n name: optionName,\n value: this._getOptionValue(option),\n filtered:\n this.type === DropdownType.SEARCH &&\n value !== '' &&\n !optionName.toLowerCase().includes(value.toLowerCase()),\n };\n });\n }\n\n private _handleArrowDown() {\n const nextOption = this._previousFocusedOption\n ?.nextElementSibling as HTMLElement;\n if (nextOption) {\n this._focusTargetOption(nextOption);\n }\n }\n\n private _handleArrowUp() {\n const previousOption = this._previousFocusedOption\n ?.previousElementSibling as HTMLElement;\n if (previousOption) {\n this._focusTargetOption(previousOption);\n }\n }\n\n private _handleClickOutside = (event: MouseEvent) => {\n if (!event.composedPath().includes(this)) {\n this._isOptionsVisible = false;\n }\n };\n\n private _focusTargetOption(targetOption: HTMLElement, extrict = true) {\n this._previousFocusedOption?.classList?.remove('t-option-hover');\n targetOption?.classList.add('t-option-hover');\n if (extrict) {\n targetOption?.focus();\n }\n this._previousFocusedOption = targetOption;\n }\n\n private _toggleOptions() {\n if (this.disabled) {\n return;\n }\n this._isOptionsVisible = !this._isOptionsVisible;\n if (\n this._isOptionsVisible &&\n this.type === DropdownType.SEARCH &&\n this._previousSelectedOption\n ) {\n this._optionsContainer?.scrollTo({\n top: this._previousSelectedOption.offsetTop,\n behavior: 'auto',\n });\n this._inputDropdown?.shadowRoot?.querySelector('input')?.select();\n }\n }\n\n private _focusOptionsContainer() {\n if (this.type === DropdownType.SEARCH) {\n if (this._previousSelectedOption) {\n this._focusTargetOption(this._previousSelectedOption, false);\n }\n return;\n }\n if (!this._isOptionsVisible || !this._optionsContainer) {\n this._inputDropdown?.shadowRoot?.querySelector('input')?.focus();\n return;\n }\n if (this._previousSelectedOption) {\n this._focusTargetOption(this._previousSelectedOption);\n } else {\n const firstOption = this._optionsContainer\n .firstElementChild as HTMLElement;\n if (firstOption) {\n this._focusTargetOption(firstOption);\n }\n }\n }\n\n private _unselectPreviousOption() {\n if (this._previousSelectedOption) {\n this._previousSelectedOption.classList?.remove('t-option-selected');\n this._previousSelectedOption = null;\n }\n }\n\n private _hasCompleteDescription(): boolean {\n const isValidDescriptionType = Object.values(DescriptionType).includes(\n this.descriptionType\n );\n return (\n isValidDescriptionType &&\n (this.descriptionType === DescriptionType.TEXT\n ? !!this.description\n : true)\n );\n }\n\n private _getOptionsContainerClasses(): ClassInfo {\n return {\n 't-options-container': true,\n show: this._isOptionsVisible,\n 't-with-description': this._hasCompleteDescription(),\n };\n }\n\n private _triggerUpdateByExternalValueChange() {\n this._unselectPreviousOption();\n if (!this.value) {\n this._value = '';\n this._extendOptionsList();\n return;\n }\n const index = this._findIndex(this.value);\n if (this.type === DropdownType.SEARCH) {\n this._extendOptionsList('');\n }\n if (index < 0) {\n this._value = '';\n return;\n }\n const optionTarget = this._optionsContainer?.children[index] as HTMLElement;\n optionTarget?.classList.add('t-option-selected');\n this._previousSelectedOption = optionTarget || null;\n this._value = optionTarget ? this._getOptionName(this.options[index]) : '';\n }\n\n private _resetPreviousSelection() {\n this._value = '';\n this._unselectPreviousOption();\n }\n\n private _getOptionsTemplate(): TemplateResult[] {\n if (this.type === DropdownType.SINGLE || this._searchingOption === false) {\n this._extendOptionsList();\n }\n return this._extendedOptions?.map((option, index) => {\n return html`<div\n class=\"${classMap({\n 't-dropdown-option': true,\n 't-option-filtered': option.filtered,\n })}\"\n @click=\"${this._onClickOption}\"\n data-value=\"${index}\"\n tabindex=\"0\"\n @keydown=\"${this._onKeyDownOption}\"\n @keypress=\"${this._onKeyPressOption}\"\n @mouseover=\"${this._onMouseOverOption}\"\n >\n ${option.name}\n </div>`;\n });\n }\n\n protected updated(changedProperties: Map<string, any>) {\n if (changedProperties.has('_isOptionsVisible')) {\n this._focusOptionsContainer();\n } else if (changedProperties.has('value')) {\n this._triggerUpdateByExternalValueChange();\n }\n }\n\n protected willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has('options')) {\n this._resetPreviousSelection();\n }\n }\n\n protected firstUpdated(changedProperties: PropertyValues<this>) {\n super.firstUpdated(changedProperties);\n this._triggerUpdateByExternalValueChange();\n }\n\n protected render(): TemplateResult {\n return html`<div class=\"t-dropdown-full-container\">\n <div class=\"t-dropdown-container\">\n <tuix-input\n .value=\"${this._value}\"\n class=\"t-input-dropdown\"\n iconRight=\"${this._isOptionsVisible\n ? IconName.CHEVRON_UP\n : IconName.CHEVRON_DOWN}\"\n placeholder=\"${this.placeholder}\"\n title=\"${this.title}\"\n .description=\"${this.description}\"\n descriptionType=\"${this.descriptionType}\"\n ?disabled=\"${this.disabled}\"\n ?dark=\"${this.dark}\"\n ?readonly=\"${this.type !== DropdownType.SEARCH}\"\n @on-click=\"${this._toggleOptions}\"\n @keypress=\"${this._onEnterPress}\"\n @on-change=\"${this._onInputSingle}\"\n >\n </tuix-input>\n </div>\n <div class=\"${classMap(this._getOptionsContainerClasses())}\">\n ${this._getOptionsTemplate()}\n </div>\n </div>`;\n }\n}\n"]}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { css, unsafeCSS } from 'lit';
|
|
2
|
-
import { hostStyles } from '../tuix-input/TuixInput.styles.js';
|
|
3
|
-
import { Palette } from '../utils/colors.js';
|
|
4
|
-
import { ScreenSizes } from '../utils/screenSizes.enum.js';
|
|
5
|
-
import { DarkPalette } from '../utils/darkColors.js';
|
|
6
|
-
export const dropdownHostStyles = css `
|
|
7
|
-
${hostStyles}
|
|
8
|
-
:host {
|
|
9
|
-
--t-field-color-option: ${unsafeCSS(Palette.WHITE)};
|
|
10
|
-
--t-field-color-main: ${unsafeCSS(Palette.MAIN)};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
:host .t-input-dropdown {
|
|
14
|
-
--t-field-font-weight: 300;
|
|
15
|
-
--t-field-font-size: 1rem;
|
|
16
|
-
--t-field-padding-x: 1rem;
|
|
17
|
-
--t-field-title-left-position: 1rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
21
|
-
:host .t-input-dropdown {
|
|
22
|
-
--t-field-font-size: 0.938rem;
|
|
23
|
-
--t-field-line-height: 1.125rem;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
28
|
-
:host .t-input-dropdown {
|
|
29
|
-
--t-field-font-size: 0.813rem;
|
|
30
|
-
--t-field-line-height: 1rem;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
:host([dark]) {
|
|
35
|
-
--t-field-color-option: ${unsafeCSS(DarkPalette.ELEVATION_2)};
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
export const dropdownMainContainerStyles = css `
|
|
39
|
-
.t-dropdown-full-container {
|
|
40
|
-
position: relative;
|
|
41
|
-
font-family: 'Rubik', sans-serif;
|
|
42
|
-
}
|
|
43
|
-
.t-dropdown-container .t-input-dropdown {
|
|
44
|
-
--t-field-input-cursor: pointer;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
export const dropdownOptionStyles = css `
|
|
48
|
-
.t-options-container {
|
|
49
|
-
width: 100%;
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: calc(100% + 2px);
|
|
52
|
-
left: 0;
|
|
53
|
-
border: none;
|
|
54
|
-
border-radius: 0 0 5px 5px;
|
|
55
|
-
background-color: var(--t-field-color-option);
|
|
56
|
-
visibility: collapse;
|
|
57
|
-
overflow-y: auto;
|
|
58
|
-
max-height: 250px;
|
|
59
|
-
color: var(--t-field-color-text);
|
|
60
|
-
box-shadow: 0px 2px 8px 0px ${unsafeCSS(Palette.SHADOW)};
|
|
61
|
-
z-index: 9999;
|
|
62
|
-
}
|
|
63
|
-
.t-options-container::-webkit-scrollbar {
|
|
64
|
-
width: 0.75rem;
|
|
65
|
-
}
|
|
66
|
-
.t-options-container::-webkit-scrollbar-track {
|
|
67
|
-
background-color: transparent;
|
|
68
|
-
}
|
|
69
|
-
.t-options-container::-webkit-scrollbar-thumb {
|
|
70
|
-
background-color: ${unsafeCSS(Palette.PRIMARY_100)};
|
|
71
|
-
border-radius: 0.25rem;
|
|
72
|
-
border: 0.188rem solid transparent;
|
|
73
|
-
background-clip: content-box;
|
|
74
|
-
}
|
|
75
|
-
.t-options-container.show {
|
|
76
|
-
visibility: visible;
|
|
77
|
-
}
|
|
78
|
-
.t-options-container.show.t-with-description {
|
|
79
|
-
top: calc(100% + 2px - 1.5rem);
|
|
80
|
-
}
|
|
81
|
-
@media only screen and (max-height: 500px) {
|
|
82
|
-
.t-options-container {
|
|
83
|
-
max-height: 50vh;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
.t-dropdown-option {
|
|
87
|
-
padding: var(--t-field-padding-y) 1rem;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
font-size: 1rem;
|
|
90
|
-
line-height: 1.25rem;
|
|
91
|
-
font-weight: 300;
|
|
92
|
-
-webkit-user-select: none;
|
|
93
|
-
-moz-user-select: none;
|
|
94
|
-
-ms-user-select: none;
|
|
95
|
-
user-select: none;
|
|
96
|
-
}
|
|
97
|
-
.t-dropdown-option.t-option-hover {
|
|
98
|
-
background-color: var(--t-field-color-form);
|
|
99
|
-
}
|
|
100
|
-
.t-dropdown-option.t-option-selected {
|
|
101
|
-
color: var(--t-field-color-main);
|
|
102
|
-
}
|
|
103
|
-
.t-dropdown-option.t-option-filtered {
|
|
104
|
-
display: none;
|
|
105
|
-
}
|
|
106
|
-
.t-dropdown-option:focus {
|
|
107
|
-
outline: none;
|
|
108
|
-
}
|
|
109
|
-
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
110
|
-
.t-dropdown-option {
|
|
111
|
-
font-size: 0.938rem;
|
|
112
|
-
line-height: 1.125rem;
|
|
113
|
-
--t-field-padding-y: 1.063rem;
|
|
114
|
-
--t-field-padding-top: 1.5rem;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
118
|
-
.t-dropdown-option {
|
|
119
|
-
font-size: 0.813rem;
|
|
120
|
-
line-height: 1rem;
|
|
121
|
-
--t-field-padding-y: 1rem;
|
|
122
|
-
--t-field-padding-top: 1.375rem;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
126
|
-
//# sourceMappingURL=TuixDropdown.styles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TuixDropdown.styles.js","sourceRoot":"","sources":["../../../src/tuix-dropdown/TuixDropdown.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;IACjC,UAAU;;8BAEgB,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;4BAC1B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;uCAUZ,WAAW,CAAC,MAAM;;;;;;;uCAOlB,WAAW,CAAC,MAAM;;;;;;;;8BAQ3B,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC;;CAE/D,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAA;;;;;;;;CAQ7C,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAA;;;;;;;;;;;;;kCAaL,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;;;;;;;;;;wBAUnC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAuCf,WAAW,CAAC,MAAM;;;;;;;;uCAQlB,WAAW,CAAC,MAAM;;;;;;;;CAQxD,CAAC","sourcesContent":["import { css, unsafeCSS } from 'lit';\nimport { hostStyles } from '../tuix-input/TuixInput.styles';\nimport { Palette } from '../utils/colors';\nimport { ScreenSizes } from '../utils/screenSizes.enum';\nimport { DarkPalette } from '../utils/darkColors';\n\nexport const dropdownHostStyles = css`\n ${hostStyles}\n :host {\n --t-field-color-option: ${unsafeCSS(Palette.WHITE)};\n --t-field-color-main: ${unsafeCSS(Palette.MAIN)};\n }\n\n :host .t-input-dropdown {\n --t-field-font-weight: 300;\n --t-field-font-size: 1rem;\n --t-field-padding-x: 1rem;\n --t-field-title-left-position: 1rem;\n }\n\n @media only screen and (max-width: ${ScreenSizes.TABLET}px) {\n :host .t-input-dropdown {\n --t-field-font-size: 0.938rem;\n --t-field-line-height: 1.125rem;\n }\n }\n\n @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {\n :host .t-input-dropdown {\n --t-field-font-size: 0.813rem;\n --t-field-line-height: 1rem;\n }\n }\n\n :host([dark]) {\n --t-field-color-option: ${unsafeCSS(DarkPalette.ELEVATION_2)};\n }\n`;\n\nexport const dropdownMainContainerStyles = css`\n .t-dropdown-full-container {\n position: relative;\n font-family: 'Rubik', sans-serif;\n }\n .t-dropdown-container .t-input-dropdown {\n --t-field-input-cursor: pointer;\n }\n`;\n\nexport const dropdownOptionStyles = css`\n .t-options-container {\n width: 100%;\n position: absolute;\n top: calc(100% + 2px);\n left: 0;\n border: none;\n border-radius: 0 0 5px 5px;\n background-color: var(--t-field-color-option);\n visibility: collapse;\n overflow-y: auto;\n max-height: 250px;\n color: var(--t-field-color-text);\n box-shadow: 0px 2px 8px 0px ${unsafeCSS(Palette.SHADOW)};\n z-index: 9999;\n }\n .t-options-container::-webkit-scrollbar {\n width: 0.75rem;\n }\n .t-options-container::-webkit-scrollbar-track {\n background-color: transparent;\n }\n .t-options-container::-webkit-scrollbar-thumb {\n background-color: ${unsafeCSS(Palette.PRIMARY_100)};\n border-radius: 0.25rem;\n border: 0.188rem solid transparent;\n background-clip: content-box;\n }\n .t-options-container.show {\n visibility: visible;\n }\n .t-options-container.show.t-with-description {\n top: calc(100% + 2px - 1.5rem);\n }\n @media only screen and (max-height: 500px) {\n .t-options-container {\n max-height: 50vh;\n }\n }\n .t-dropdown-option {\n padding: var(--t-field-padding-y) 1rem;\n cursor: pointer;\n font-size: 1rem;\n line-height: 1.25rem;\n font-weight: 300;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n }\n .t-dropdown-option.t-option-hover {\n background-color: var(--t-field-color-form);\n }\n .t-dropdown-option.t-option-selected {\n color: var(--t-field-color-main);\n }\n .t-dropdown-option.t-option-filtered {\n display: none;\n }\n .t-dropdown-option:focus {\n outline: none;\n }\n @media only screen and (max-width: ${ScreenSizes.TABLET}px) {\n .t-dropdown-option {\n font-size: 0.938rem;\n line-height: 1.125rem;\n --t-field-padding-y: 1.063rem;\n --t-field-padding-top: 1.5rem;\n }\n }\n @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {\n .t-dropdown-option {\n font-size: 0.813rem;\n line-height: 1rem;\n --t-field-padding-y: 1rem;\n --t-field-padding-top: 1.375rem;\n }\n }\n`;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuix-dropdown.enums.js","sourceRoot":"","sources":["../../../../src/tuix-dropdown/enums/tuix-dropdown.enums.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["export enum DropdownType {\n SINGLE = 'single',\n SEARCH = 'search',\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CustomEventTuixInput } from '../../tuix-input/interfaces/tuix-input.interface.js';
|
|
2
|
-
import { DetailValue } from '../../utils/interfaces/detail-value.interface.js';
|
|
3
|
-
export type TuixDropdownPlainOption = string | number | boolean;
|
|
4
|
-
export interface TuixDropdownObjectOption {
|
|
5
|
-
name: string;
|
|
6
|
-
value: TuixDropdownPlainOption;
|
|
7
|
-
}
|
|
8
|
-
export type TuixDropdownOption = TuixDropdownPlainOption | TuixDropdownObjectOption;
|
|
9
|
-
export interface TuixDropdownExtendedOption {
|
|
10
|
-
name: string;
|
|
11
|
-
value: TuixDropdownPlainOption;
|
|
12
|
-
filtered: boolean;
|
|
13
|
-
}
|
|
14
|
-
export type CustomEventTuixDropdownSelect<T extends TuixDropdownOption = TuixDropdownOption> = CustomEvent<DetailValue<T>>;
|
|
15
|
-
export type CustomEventTuixDropdownInput = CustomEventTuixInput;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tuix-dropdown.interface.js","sourceRoot":"","sources":["../../../../src/tuix-dropdown/interfaces/tuix-dropdown.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { CustomEventTuixInput } from '../../tuix-input/interfaces/tuix-input.interface';\nimport { DetailValue } from '../../utils/interfaces/detail-value.interface';\n\nexport type TuixDropdownPlainOption = string | number | boolean;\n\nexport interface TuixDropdownObjectOption {\n name: string;\n value: TuixDropdownPlainOption;\n}\n\nexport type TuixDropdownOption =\n | TuixDropdownPlainOption\n | TuixDropdownObjectOption;\n\nexport interface TuixDropdownExtendedOption {\n name: string;\n value: TuixDropdownPlainOption;\n filtered: boolean;\n}\n\nexport type CustomEventTuixDropdownSelect<\n T extends TuixDropdownOption = TuixDropdownOption\n> = CustomEvent<DetailValue<T>>;\n\nexport type CustomEventTuixDropdownInput = CustomEventTuixInput;\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
-
import { IconName, IconSizeVariant } from './enums/tuix-icon.enums.js';
|
|
3
|
-
import { TextVariant } from '../tuix-text/enums/tuix-text.enums.js';
|
|
4
|
-
export declare class TuixIcon extends LitElement {
|
|
5
|
-
static styles: import("lit").CSSResult;
|
|
6
|
-
name: IconName;
|
|
7
|
-
color?: string | TextVariant;
|
|
8
|
-
size: IconSizeVariant;
|
|
9
|
-
dark: boolean;
|
|
10
|
-
fill?: string | TextVariant;
|
|
11
|
-
private _getSelectedColor;
|
|
12
|
-
private _getSelectedFill;
|
|
13
|
-
private _getIconTemplate;
|
|
14
|
-
render(): TemplateResult<1>;
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
2
|
-
import { IconName } from './enums/tuix-icon.enums.js';
|
|
3
|
-
export declare const iconTemplate: (name?: IconName, color?: string, fill?: string) => TemplateResult;
|
|
4
|
-
type IconContentMapType = Record<IconName, string>;
|
|
5
|
-
export declare const iconContentMap: IconContentMapType;
|
|
6
|
-
export {};
|