tuix-webcomponents 0.67.0 → 0.69.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/src/index.d.ts +36 -0
- package/dist/src/index.js +42 -0
- package/dist/src/tuix-button/TuixBaseButton.d.ts +17 -0
- package/dist/src/tuix-button/TuixBaseButton.js +60 -0
- package/dist/src/tuix-button/TuixButton.d.ts +11 -0
- package/dist/src/tuix-button/TuixButton.js +84 -0
- package/dist/src/tuix-button/TuixButton.styles.d.ts +3 -0
- package/dist/src/tuix-button/TuixButton.styles.js +107 -0
- package/dist/src/tuix-button/enums/tuix-button.enums.d.ts +2 -0
- package/dist/src/tuix-button/enums/tuix-button.enums.js +6 -0
- package/dist/src/tuix-button/interfaces/tuix-button.interface.d.ts +1 -0
- package/dist/src/tuix-button/interfaces/tuix-button.interface.js +1 -0
- package/dist/src/tuix-checkbox/TuixCheckbox.d.ts +15 -0
- package/dist/src/tuix-checkbox/TuixCheckbox.js +106 -0
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.d.ts +4 -0
- package/dist/src/tuix-checkbox/TuixCheckbox.styles.js +132 -0
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +21 -0
- package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.js +23 -0
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +5 -0
- package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js +1 -0
- package/dist/src/tuix-dropdown/TuixDropdown.d.ts +55 -0
- package/dist/src/tuix-dropdown/TuixDropdown.js +360 -0
- package/dist/src/tuix-dropdown/TuixDropdown.styles.d.ts +3 -0
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js +125 -0
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +4 -0
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js +5 -0
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +15 -0
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +1 -0
- package/dist/src/tuix-icon/TuixIcon.d.ts +15 -0
- package/dist/src/tuix-icon/TuixIcon.icons.d.ts +6 -0
- package/dist/src/tuix-icon/TuixIcon.icons.js +290 -0
- package/dist/src/tuix-icon/TuixIcon.js +79 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +62 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +69 -0
- package/dist/src/tuix-icon-button/TuixIconButton.d.ts +9 -0
- package/dist/src/tuix-icon-button/TuixIconButton.js +51 -0
- package/dist/src/tuix-input/TuixInput.d.ts +52 -0
- package/dist/src/tuix-input/TuixInput.js +370 -0
- package/dist/src/tuix-input/TuixInput.styles.d.ts +8 -0
- package/dist/src/tuix-input/TuixInput.styles.js +295 -0
- package/dist/src/tuix-input/enums/tuix-input.enums.d.ts +38 -0
- package/dist/src/tuix-input/enums/tuix-input.enums.js +41 -0
- package/dist/src/tuix-input/interfaces/tuix-input.interface.d.ts +18 -0
- package/dist/src/tuix-input/interfaces/tuix-input.interface.js +5 -0
- package/dist/src/tuix-link/TuixLink.d.ts +15 -0
- package/dist/src/tuix-link/TuixLink.js +71 -0
- package/dist/src/tuix-link/TuixLink.styles.d.ts +2 -0
- package/dist/src/tuix-link/TuixLink.styles.js +55 -0
- package/dist/src/tuix-link/enums/linkTarget.enum.d.ts +6 -0
- package/dist/src/tuix-link/enums/linkTarget.enum.js +7 -0
- package/dist/src/tuix-modal/TuixModal.d.ts +9 -0
- package/dist/src/tuix-modal/TuixModal.js +63 -0
- package/dist/src/tuix-modal/TuixModal.styles.d.ts +2 -0
- package/dist/src/tuix-modal/TuixModal.styles.js +55 -0
- package/dist/src/tuix-paper/TuixPaper.d.ts +10 -0
- package/dist/src/tuix-paper/TuixPaper.js +46 -0
- package/dist/src/tuix-paper/TuixPaper.styles.d.ts +1 -0
- package/dist/src/tuix-paper/TuixPaper.styles.js +30 -0
- package/dist/src/tuix-paper/enums/tuix-paper.enum.d.ts +13 -0
- package/dist/src/tuix-paper/enums/tuix-paper.enum.js +15 -0
- package/dist/src/tuix-radio-button/TuixRadioButton.d.ts +16 -0
- package/dist/src/tuix-radio-button/TuixRadioButton.js +95 -0
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.d.ts +5 -0
- package/dist/src/tuix-radio-button/TuixRadioButton.styles.js +135 -0
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +3 -0
- package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js +1 -0
- package/dist/src/tuix-table/TuixTable.d.ts +46 -0
- package/dist/src/tuix-table/TuixTable.js +367 -0
- package/dist/src/tuix-table/TuixTable.styles.d.ts +2 -0
- package/dist/src/tuix-table/TuixTable.styles.js +197 -0
- package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +45 -0
- package/dist/src/tuix-table/interfaces/tuix-table.interface.js +1 -0
- package/dist/src/tuix-text/TuixText.d.ts +12 -0
- package/dist/src/tuix-text/TuixText.js +66 -0
- package/dist/src/tuix-text/TuixText.styles.d.ts +2 -0
- package/dist/src/tuix-text/TuixText.styles.js +158 -0
- package/dist/src/tuix-text/enums/tuix-text.enums.d.ts +31 -0
- package/dist/src/tuix-text/enums/tuix-text.enums.js +63 -0
- package/dist/src/tuix-toast/TuixToast.d.ts +15 -0
- package/dist/src/tuix-toast/TuixToast.js +100 -0
- package/dist/src/tuix-toast/TuixToast.styles.d.ts +3 -0
- package/dist/src/tuix-toast/TuixToast.styles.js +43 -0
- package/dist/src/tuix-toast/enums/tuix-toast.enums.d.ts +20 -0
- package/dist/src/tuix-toast/enums/tuix-toast.enums.js +59 -0
- package/dist/src/tuix-toggle-button/TuixToggleButton.d.ts +13 -0
- package/dist/src/tuix-toggle-button/TuixToggleButton.js +85 -0
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.d.ts +5 -0
- package/dist/src/tuix-toggle-button/TuixToggleButton.styles.js +134 -0
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +2 -0
- package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js +1 -0
- package/dist/src/utils/colors.d.ts +29 -0
- package/dist/src/utils/colors.js +30 -0
- package/dist/src/utils/darkColors.d.ts +31 -0
- package/dist/src/utils/darkColors.js +32 -0
- package/dist/src/utils/hex-rgb.d.ts +5 -0
- package/dist/src/utils/hex-rgb.js +15 -0
- package/dist/src/utils/interfaces/detail-value.interface.d.ts +3 -0
- package/dist/src/utils/interfaces/detail-value.interface.js +1 -0
- package/dist/src/utils/mainVariant.enum.d.ts +4 -0
- package/dist/src/utils/mainVariant.enum.js +5 -0
- package/dist/src/utils/screenSizes.enum.d.ts +4 -0
- package/dist/src/utils/screenSizes.enum.js +5 -0
- package/dist/src/utils/slottedClassName.d.ts +2 -0
- package/dist/src/utils/slottedClassName.js +1 -0
- package/dist/tsconfig.publish.tsbuildinfo +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Palette } from '../../utils/colors';
|
|
2
|
+
import { DarkPalette } from '../../utils/darkColors';
|
|
3
|
+
export declare enum CheckboxIconMode {
|
|
4
|
+
DEFAULT = "default",
|
|
5
|
+
DISABLED = "disabled",
|
|
6
|
+
ERROR = "error"
|
|
7
|
+
}
|
|
8
|
+
export declare enum CheckboxLabelSide {
|
|
9
|
+
LEFT = "left",
|
|
10
|
+
RIGHT = "right"
|
|
11
|
+
}
|
|
12
|
+
export declare const CheckboxIconColorLight: {
|
|
13
|
+
default: Palette;
|
|
14
|
+
disabled: Palette;
|
|
15
|
+
error: Palette;
|
|
16
|
+
};
|
|
17
|
+
export declare const CheckboxIconColorDark: {
|
|
18
|
+
default: DarkPalette;
|
|
19
|
+
disabled: DarkPalette;
|
|
20
|
+
error: DarkPalette;
|
|
21
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Palette } from '../../utils/colors';
|
|
2
|
+
import { DarkPalette } from '../../utils/darkColors';
|
|
3
|
+
export var CheckboxIconMode;
|
|
4
|
+
(function (CheckboxIconMode) {
|
|
5
|
+
CheckboxIconMode["DEFAULT"] = "default";
|
|
6
|
+
CheckboxIconMode["DISABLED"] = "disabled";
|
|
7
|
+
CheckboxIconMode["ERROR"] = "error";
|
|
8
|
+
})(CheckboxIconMode || (CheckboxIconMode = {}));
|
|
9
|
+
export var CheckboxLabelSide;
|
|
10
|
+
(function (CheckboxLabelSide) {
|
|
11
|
+
CheckboxLabelSide["LEFT"] = "left";
|
|
12
|
+
CheckboxLabelSide["RIGHT"] = "right";
|
|
13
|
+
})(CheckboxLabelSide || (CheckboxLabelSide = {}));
|
|
14
|
+
export const CheckboxIconColorLight = {
|
|
15
|
+
[CheckboxIconMode.DEFAULT]: Palette.WHITE,
|
|
16
|
+
[CheckboxIconMode.DISABLED]: Palette.PRIMARY_300,
|
|
17
|
+
[CheckboxIconMode.ERROR]: Palette.WHITE,
|
|
18
|
+
};
|
|
19
|
+
export const CheckboxIconColorDark = {
|
|
20
|
+
[CheckboxIconMode.DEFAULT]: DarkPalette.WHITE,
|
|
21
|
+
[CheckboxIconMode.DISABLED]: DarkPalette.PRIMARY_100,
|
|
22
|
+
[CheckboxIconMode.ERROR]: DarkPalette.WHITE,
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues, type TemplateResult } from 'lit';
|
|
2
|
+
import type { TuixDropdownExtendedOption, TuixDropdownOption } from './interfaces/tuix-dropdown.interface';
|
|
3
|
+
import { DescriptionType } from '../tuix-input/enums/tuix-input.enums';
|
|
4
|
+
import { DropdownType } from './enums/tuix-dropdown.enums';
|
|
5
|
+
export declare class TuixDropdown extends LitElement {
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
value?: TuixDropdownOption;
|
|
8
|
+
options: TuixDropdownOption[];
|
|
9
|
+
placeholder: string;
|
|
10
|
+
title: string;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
dark: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
descriptionType: DescriptionType;
|
|
15
|
+
type: DropdownType;
|
|
16
|
+
private _value;
|
|
17
|
+
private _isOptionsVisible;
|
|
18
|
+
private _searchingOption;
|
|
19
|
+
_extendedOptions: TuixDropdownExtendedOption[];
|
|
20
|
+
private _optionsContainer;
|
|
21
|
+
private _inputDropdown;
|
|
22
|
+
private _previousSelectedOption;
|
|
23
|
+
private _previousFocusedOption;
|
|
24
|
+
connectedCallback(): void;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
private _onEnterPress;
|
|
27
|
+
private _onKeyDownOption;
|
|
28
|
+
private _onKeyPressOption;
|
|
29
|
+
private _onMouseOverOption;
|
|
30
|
+
private _onClickOption;
|
|
31
|
+
protected _onInputSingle(e: CustomEvent): void;
|
|
32
|
+
protected _handleSelectEvent(event: MouseEvent | KeyboardEvent): void;
|
|
33
|
+
private _handleBlur;
|
|
34
|
+
private _getOptionName;
|
|
35
|
+
private _getOptionValue;
|
|
36
|
+
private _findIndex;
|
|
37
|
+
private _handleInputBase;
|
|
38
|
+
private _extendOptionsList;
|
|
39
|
+
private _handleArrowDown;
|
|
40
|
+
private _handleArrowUp;
|
|
41
|
+
private _handleClickOutside;
|
|
42
|
+
private _focusTargetOption;
|
|
43
|
+
private _toggleOptions;
|
|
44
|
+
private _focusOptionsContainer;
|
|
45
|
+
private _unselectPreviousOption;
|
|
46
|
+
private _hasCompleteDescription;
|
|
47
|
+
private _getOptionsContainerClasses;
|
|
48
|
+
private _triggerUpdateByExternalValueChange;
|
|
49
|
+
private _resetPreviousSelection;
|
|
50
|
+
private _getOptionsTemplate;
|
|
51
|
+
protected updated(changedProperties: Map<string, any>): void;
|
|
52
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
53
|
+
protected firstUpdated(changedProperties: PropertyValues<this>): void;
|
|
54
|
+
protected render(): TemplateResult;
|
|
55
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
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';
|
|
6
|
+
import { dropdownHostStyles, dropdownMainContainerStyles, dropdownOptionStyles, } from './TuixDropdown.styles';
|
|
7
|
+
import { DescriptionType } from '../tuix-input/enums/tuix-input.enums';
|
|
8
|
+
import { DropdownType } from './enums/tuix-dropdown.enums';
|
|
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
|
+
static { this.styles = [
|
|
33
|
+
dropdownHostStyles,
|
|
34
|
+
dropdownMainContainerStyles,
|
|
35
|
+
dropdownOptionStyles,
|
|
36
|
+
]; }
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
window.addEventListener('click', this._handleClickOutside);
|
|
40
|
+
this.addEventListener('blur', this._handleBlur.bind(this));
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
window.removeEventListener('click', this._handleClickOutside);
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
}
|
|
46
|
+
_onEnterPress(event) {
|
|
47
|
+
if (event.key === 'Enter') {
|
|
48
|
+
this._toggleOptions();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
_onKeyDownOption(event) {
|
|
52
|
+
switch (event.key) {
|
|
53
|
+
case 'ArrowDown':
|
|
54
|
+
return this._handleArrowDown();
|
|
55
|
+
case 'ArrowUp':
|
|
56
|
+
return this._handleArrowUp();
|
|
57
|
+
case 'Escape':
|
|
58
|
+
this._isOptionsVisible = false;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
_onKeyPressOption(event) {
|
|
63
|
+
if (event.key === 'Enter') {
|
|
64
|
+
this._onClickOption(event);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_onMouseOverOption(event) {
|
|
68
|
+
const optionTarget = event.target;
|
|
69
|
+
this._focusTargetOption(optionTarget);
|
|
70
|
+
}
|
|
71
|
+
_onClickOption(event) {
|
|
72
|
+
const optionTarget = event.target;
|
|
73
|
+
this._value = optionTarget.innerText;
|
|
74
|
+
this._isOptionsVisible = false;
|
|
75
|
+
this._unselectPreviousOption();
|
|
76
|
+
optionTarget.classList.add('t-option-selected');
|
|
77
|
+
this._previousSelectedOption = optionTarget;
|
|
78
|
+
this._handleSelectEvent(event);
|
|
79
|
+
}
|
|
80
|
+
_onInputSingle(e) {
|
|
81
|
+
this._handleInputBase(e, 'input-single');
|
|
82
|
+
}
|
|
83
|
+
_handleSelectEvent(event) {
|
|
84
|
+
const optionIndex = event.target.getAttribute('data-value');
|
|
85
|
+
const selectedValue = this.options[Number(optionIndex)];
|
|
86
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
87
|
+
detail: {
|
|
88
|
+
value: this._getOptionValue(selectedValue),
|
|
89
|
+
},
|
|
90
|
+
bubbles: true,
|
|
91
|
+
}));
|
|
92
|
+
if (this.type === DropdownType.SEARCH) {
|
|
93
|
+
this._extendOptionsList(this._getOptionName(selectedValue));
|
|
94
|
+
this._searchingOption = false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
_handleBlur() {
|
|
98
|
+
if (this.type === DropdownType.SEARCH && this._searchingOption) {
|
|
99
|
+
const optionIndex = this._previousSelectedOption?.getAttribute('data-value');
|
|
100
|
+
const selectedValue = typeof optionIndex === 'string'
|
|
101
|
+
? this.options[Number(optionIndex)]
|
|
102
|
+
: '';
|
|
103
|
+
this._value = this._getOptionName(selectedValue);
|
|
104
|
+
this._extendOptionsList();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
_getOptionName(option) {
|
|
108
|
+
return String(typeof option === 'object' ? option?.name : option);
|
|
109
|
+
}
|
|
110
|
+
_getOptionValue(option) {
|
|
111
|
+
return typeof option === 'object' ? option.value : option;
|
|
112
|
+
}
|
|
113
|
+
_findIndex(option) {
|
|
114
|
+
return this._extendedOptions.findIndex(opt => opt.value === this._getOptionValue(option));
|
|
115
|
+
}
|
|
116
|
+
_handleInputBase(e, eventName) {
|
|
117
|
+
if (!this._searchingOption) {
|
|
118
|
+
this._searchingOption = true;
|
|
119
|
+
}
|
|
120
|
+
this._extendOptionsList(e.detail.value);
|
|
121
|
+
this._isOptionsVisible = true;
|
|
122
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
123
|
+
detail: {
|
|
124
|
+
value: e.detail.value,
|
|
125
|
+
},
|
|
126
|
+
bubbles: true,
|
|
127
|
+
}));
|
|
128
|
+
this._value = e.detail.value;
|
|
129
|
+
}
|
|
130
|
+
_extendOptionsList(value = '') {
|
|
131
|
+
value = value.trim();
|
|
132
|
+
this._extendedOptions = this.options.map(option => {
|
|
133
|
+
const optionName = this._getOptionName(option);
|
|
134
|
+
return {
|
|
135
|
+
name: optionName,
|
|
136
|
+
value: this._getOptionValue(option),
|
|
137
|
+
filtered: this.type === DropdownType.SEARCH &&
|
|
138
|
+
value !== '' &&
|
|
139
|
+
!optionName.toLowerCase().includes(value.toLowerCase()),
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
_handleArrowDown() {
|
|
144
|
+
const nextOption = this._previousFocusedOption
|
|
145
|
+
?.nextElementSibling;
|
|
146
|
+
if (nextOption) {
|
|
147
|
+
this._focusTargetOption(nextOption);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
_handleArrowUp() {
|
|
151
|
+
const previousOption = this._previousFocusedOption
|
|
152
|
+
?.previousElementSibling;
|
|
153
|
+
if (previousOption) {
|
|
154
|
+
this._focusTargetOption(previousOption);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
_focusTargetOption(targetOption, extrict = true) {
|
|
158
|
+
this._previousFocusedOption?.classList?.remove('t-option-hover');
|
|
159
|
+
targetOption?.classList.add('t-option-hover');
|
|
160
|
+
if (extrict) {
|
|
161
|
+
targetOption?.focus();
|
|
162
|
+
}
|
|
163
|
+
this._previousFocusedOption = targetOption;
|
|
164
|
+
}
|
|
165
|
+
_toggleOptions() {
|
|
166
|
+
if (this.disabled) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this._isOptionsVisible = !this._isOptionsVisible;
|
|
170
|
+
if (this._isOptionsVisible &&
|
|
171
|
+
this.type === DropdownType.SEARCH &&
|
|
172
|
+
this._previousSelectedOption) {
|
|
173
|
+
this._optionsContainer?.scrollTo({
|
|
174
|
+
top: this._previousSelectedOption.offsetTop,
|
|
175
|
+
behavior: 'auto',
|
|
176
|
+
});
|
|
177
|
+
this._inputDropdown?.shadowRoot?.querySelector('input')?.select();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
_focusOptionsContainer() {
|
|
181
|
+
if (this.type === DropdownType.SEARCH) {
|
|
182
|
+
if (this._previousSelectedOption) {
|
|
183
|
+
this._focusTargetOption(this._previousSelectedOption, false);
|
|
184
|
+
}
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!this._isOptionsVisible || !this._optionsContainer) {
|
|
188
|
+
this._inputDropdown?.shadowRoot?.querySelector('input')?.focus();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this._previousSelectedOption) {
|
|
192
|
+
this._focusTargetOption(this._previousSelectedOption);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const firstOption = this._optionsContainer
|
|
196
|
+
.firstElementChild;
|
|
197
|
+
if (firstOption) {
|
|
198
|
+
this._focusTargetOption(firstOption);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
_unselectPreviousOption() {
|
|
203
|
+
if (this._previousSelectedOption) {
|
|
204
|
+
this._previousSelectedOption.classList?.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
|
+
this._unselectPreviousOption();
|
|
224
|
+
if (!this.value) {
|
|
225
|
+
this._value = '';
|
|
226
|
+
this._extendOptionsList();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const index = this._findIndex(this.value);
|
|
230
|
+
if (this.type === DropdownType.SEARCH) {
|
|
231
|
+
this._extendOptionsList('');
|
|
232
|
+
}
|
|
233
|
+
if (index < 0) {
|
|
234
|
+
this._value = '';
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const optionTarget = this._optionsContainer?.children[index];
|
|
238
|
+
optionTarget?.classList.add('t-option-selected');
|
|
239
|
+
this._previousSelectedOption = optionTarget || null;
|
|
240
|
+
this._value = optionTarget ? this._getOptionName(this.options[index]) : '';
|
|
241
|
+
}
|
|
242
|
+
_resetPreviousSelection() {
|
|
243
|
+
this._value = '';
|
|
244
|
+
this._unselectPreviousOption();
|
|
245
|
+
}
|
|
246
|
+
_getOptionsTemplate() {
|
|
247
|
+
if (this.type === DropdownType.SINGLE || this._searchingOption === false) {
|
|
248
|
+
this._extendOptionsList();
|
|
249
|
+
}
|
|
250
|
+
return this._extendedOptions?.map((option, index) => {
|
|
251
|
+
return html `<div
|
|
252
|
+
class="${classMap({
|
|
253
|
+
't-dropdown-option': true,
|
|
254
|
+
't-option-filtered': option.filtered,
|
|
255
|
+
})}"
|
|
256
|
+
@click="${this._onClickOption}"
|
|
257
|
+
data-value="${index}"
|
|
258
|
+
tabindex="0"
|
|
259
|
+
@keydown="${this._onKeyDownOption}"
|
|
260
|
+
@keypress="${this._onKeyPressOption}"
|
|
261
|
+
@mouseover="${this._onMouseOverOption}"
|
|
262
|
+
>
|
|
263
|
+
${option.name}
|
|
264
|
+
</div>`;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
updated(changedProperties) {
|
|
268
|
+
if (changedProperties.has('_isOptionsVisible')) {
|
|
269
|
+
this._focusOptionsContainer();
|
|
270
|
+
}
|
|
271
|
+
else if (changedProperties.has('value')) {
|
|
272
|
+
this._triggerUpdateByExternalValueChange();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
willUpdate(changedProperties) {
|
|
276
|
+
if (changedProperties.has('options')) {
|
|
277
|
+
this._resetPreviousSelection();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
firstUpdated(changedProperties) {
|
|
281
|
+
super.firstUpdated(changedProperties);
|
|
282
|
+
this._triggerUpdateByExternalValueChange();
|
|
283
|
+
}
|
|
284
|
+
render() {
|
|
285
|
+
return html `<div class="t-dropdown-full-container">
|
|
286
|
+
<div class="t-dropdown-container">
|
|
287
|
+
<tuix-input
|
|
288
|
+
.value="${this._value}"
|
|
289
|
+
class="t-input-dropdown"
|
|
290
|
+
iconRight="${this._isOptionsVisible
|
|
291
|
+
? IconName.CHEVRON_UP
|
|
292
|
+
: IconName.CHEVRON_DOWN}"
|
|
293
|
+
placeholder="${this.placeholder}"
|
|
294
|
+
title="${this.title}"
|
|
295
|
+
.description="${this.description}"
|
|
296
|
+
descriptionType="${this.descriptionType}"
|
|
297
|
+
?disabled="${this.disabled}"
|
|
298
|
+
?dark="${this.dark}"
|
|
299
|
+
?readonly="${this.type !== DropdownType.SEARCH}"
|
|
300
|
+
@on-click="${this._toggleOptions}"
|
|
301
|
+
@keypress="${this._onEnterPress}"
|
|
302
|
+
@on-change="${this._onInputSingle}"
|
|
303
|
+
>
|
|
304
|
+
</tuix-input>
|
|
305
|
+
</div>
|
|
306
|
+
<div class="${classMap(this._getOptionsContainerClasses())}">
|
|
307
|
+
${this._getOptionsTemplate()}
|
|
308
|
+
</div>
|
|
309
|
+
</div>`;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
__decorate([
|
|
313
|
+
property({ type: Object })
|
|
314
|
+
], TuixDropdown.prototype, "value", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
property({ type: Array })
|
|
317
|
+
], TuixDropdown.prototype, "options", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
property({ type: String })
|
|
320
|
+
], TuixDropdown.prototype, "placeholder", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
property({ type: String })
|
|
323
|
+
], TuixDropdown.prototype, "title", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
property({ type: Boolean, reflect: true })
|
|
326
|
+
], TuixDropdown.prototype, "disabled", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
property({ type: Boolean, reflect: true })
|
|
329
|
+
], TuixDropdown.prototype, "dark", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
property({ type: String })
|
|
332
|
+
], TuixDropdown.prototype, "description", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
property({ type: DescriptionType })
|
|
335
|
+
], TuixDropdown.prototype, "descriptionType", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
property({ type: String })
|
|
338
|
+
], TuixDropdown.prototype, "type", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
state()
|
|
341
|
+
], TuixDropdown.prototype, "_value", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
state()
|
|
344
|
+
], TuixDropdown.prototype, "_isOptionsVisible", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
state()
|
|
347
|
+
], TuixDropdown.prototype, "_searchingOption", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
state()
|
|
350
|
+
], TuixDropdown.prototype, "_extendedOptions", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
query('.t-options-container')
|
|
353
|
+
], TuixDropdown.prototype, "_optionsContainer", void 0);
|
|
354
|
+
__decorate([
|
|
355
|
+
query('.t-dropdown-container .t-input-dropdown')
|
|
356
|
+
], TuixDropdown.prototype, "_inputDropdown", void 0);
|
|
357
|
+
TuixDropdown = __decorate([
|
|
358
|
+
customElement('tuix-dropdown')
|
|
359
|
+
], TuixDropdown);
|
|
360
|
+
export { TuixDropdown };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
|
2
|
+
import { hostStyles } from '../tuix-input/TuixInput.styles';
|
|
3
|
+
import { Palette } from '../utils/colors';
|
|
4
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
5
|
+
import { DarkPalette } from '../utils/darkColors';
|
|
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
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CustomEventTuixInput } from '../../tuix-input/interfaces/tuix-input.interface';
|
|
2
|
+
import { type DetailValue } from '../../utils/interfaces/detail-value.interface';
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { IconName, IconSizeVariant } from './enums/tuix-icon.enums';
|
|
3
|
+
import { TextVariant } from '../tuix-text/enums/tuix-text.enums';
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { IconName } from './enums/tuix-icon.enums';
|
|
3
|
+
export declare const iconTemplate: (name?: IconName, color?: string, fill?: string) => ReturnType<typeof html>;
|
|
4
|
+
type IconContentMapType = Record<IconName, string>;
|
|
5
|
+
export declare const iconContentMap: IconContentMapType;
|
|
6
|
+
export {};
|