tuix-webcomponents 0.65.0 → 0.67.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.
Files changed (107) hide show
  1. package/README.md +2 -2
  2. package/package.json +8 -8
  3. package/package-build/src/index.d.ts +0 -36
  4. package/package-build/src/index.js +0 -42
  5. package/package-build/src/tuix-button/TuixBaseButton.d.ts +0 -17
  6. package/package-build/src/tuix-button/TuixBaseButton.js +0 -60
  7. package/package-build/src/tuix-button/TuixButton.d.ts +0 -11
  8. package/package-build/src/tuix-button/TuixButton.js +0 -84
  9. package/package-build/src/tuix-button/TuixButton.styles.d.ts +0 -3
  10. package/package-build/src/tuix-button/TuixButton.styles.js +0 -107
  11. package/package-build/src/tuix-button/enums/tuix-button.enums.d.ts +0 -2
  12. package/package-build/src/tuix-button/enums/tuix-button.enums.js +0 -6
  13. package/package-build/src/tuix-button/interfaces/tuix-button.interface.d.ts +0 -1
  14. package/package-build/src/tuix-button/interfaces/tuix-button.interface.js +0 -1
  15. package/package-build/src/tuix-checkbox/TuixCheckbox.d.ts +0 -15
  16. package/package-build/src/tuix-checkbox/TuixCheckbox.js +0 -106
  17. package/package-build/src/tuix-checkbox/TuixCheckbox.styles.d.ts +0 -4
  18. package/package-build/src/tuix-checkbox/TuixCheckbox.styles.js +0 -132
  19. package/package-build/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +0 -21
  20. package/package-build/src/tuix-checkbox/enums/tuix-checkbox.enums.js +0 -23
  21. package/package-build/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +0 -5
  22. package/package-build/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js +0 -1
  23. package/package-build/src/tuix-dropdown/TuixDropdown.d.ts +0 -55
  24. package/package-build/src/tuix-dropdown/TuixDropdown.js +0 -360
  25. package/package-build/src/tuix-dropdown/TuixDropdown.styles.d.ts +0 -3
  26. package/package-build/src/tuix-dropdown/TuixDropdown.styles.js +0 -125
  27. package/package-build/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +0 -4
  28. package/package-build/src/tuix-dropdown/enums/tuix-dropdown.enums.js +0 -5
  29. package/package-build/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +0 -15
  30. package/package-build/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +0 -1
  31. package/package-build/src/tuix-icon/TuixIcon.d.ts +0 -15
  32. package/package-build/src/tuix-icon/TuixIcon.icons.d.ts +0 -6
  33. package/package-build/src/tuix-icon/TuixIcon.icons.js +0 -290
  34. package/package-build/src/tuix-icon/TuixIcon.js +0 -79
  35. package/package-build/src/tuix-icon/enums/tuix-icon.enums.d.ts +0 -62
  36. package/package-build/src/tuix-icon/enums/tuix-icon.enums.js +0 -69
  37. package/package-build/src/tuix-icon-button/TuixIconButton.d.ts +0 -9
  38. package/package-build/src/tuix-icon-button/TuixIconButton.js +0 -51
  39. package/package-build/src/tuix-input/TuixInput.d.ts +0 -52
  40. package/package-build/src/tuix-input/TuixInput.js +0 -370
  41. package/package-build/src/tuix-input/TuixInput.styles.d.ts +0 -8
  42. package/package-build/src/tuix-input/TuixInput.styles.js +0 -295
  43. package/package-build/src/tuix-input/enums/tuix-input.enums.d.ts +0 -38
  44. package/package-build/src/tuix-input/enums/tuix-input.enums.js +0 -41
  45. package/package-build/src/tuix-input/interfaces/tuix-input.interface.d.ts +0 -18
  46. package/package-build/src/tuix-input/interfaces/tuix-input.interface.js +0 -5
  47. package/package-build/src/tuix-link/TuixLink.d.ts +0 -15
  48. package/package-build/src/tuix-link/TuixLink.js +0 -71
  49. package/package-build/src/tuix-link/TuixLink.styles.d.ts +0 -2
  50. package/package-build/src/tuix-link/TuixLink.styles.js +0 -55
  51. package/package-build/src/tuix-link/enums/linkTarget.enum.d.ts +0 -6
  52. package/package-build/src/tuix-link/enums/linkTarget.enum.js +0 -7
  53. package/package-build/src/tuix-modal/TuixModal.d.ts +0 -9
  54. package/package-build/src/tuix-modal/TuixModal.js +0 -63
  55. package/package-build/src/tuix-modal/TuixModal.styles.d.ts +0 -2
  56. package/package-build/src/tuix-modal/TuixModal.styles.js +0 -55
  57. package/package-build/src/tuix-paper/TuixPaper.d.ts +0 -10
  58. package/package-build/src/tuix-paper/TuixPaper.js +0 -46
  59. package/package-build/src/tuix-paper/TuixPaper.styles.d.ts +0 -1
  60. package/package-build/src/tuix-paper/TuixPaper.styles.js +0 -30
  61. package/package-build/src/tuix-paper/enums/tuix-paper.enum.d.ts +0 -13
  62. package/package-build/src/tuix-paper/enums/tuix-paper.enum.js +0 -15
  63. package/package-build/src/tuix-radio-button/TuixRadioButton.d.ts +0 -16
  64. package/package-build/src/tuix-radio-button/TuixRadioButton.js +0 -95
  65. package/package-build/src/tuix-radio-button/TuixRadioButton.styles.d.ts +0 -5
  66. package/package-build/src/tuix-radio-button/TuixRadioButton.styles.js +0 -135
  67. package/package-build/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +0 -3
  68. package/package-build/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js +0 -1
  69. package/package-build/src/tuix-table/TuixTable.d.ts +0 -46
  70. package/package-build/src/tuix-table/TuixTable.js +0 -367
  71. package/package-build/src/tuix-table/TuixTable.styles.d.ts +0 -2
  72. package/package-build/src/tuix-table/TuixTable.styles.js +0 -197
  73. package/package-build/src/tuix-table/interfaces/tuix-table.interface.d.ts +0 -45
  74. package/package-build/src/tuix-table/interfaces/tuix-table.interface.js +0 -1
  75. package/package-build/src/tuix-text/TuixText.d.ts +0 -12
  76. package/package-build/src/tuix-text/TuixText.js +0 -66
  77. package/package-build/src/tuix-text/TuixText.styles.d.ts +0 -2
  78. package/package-build/src/tuix-text/TuixText.styles.js +0 -158
  79. package/package-build/src/tuix-text/enums/tuix-text.enums.d.ts +0 -31
  80. package/package-build/src/tuix-text/enums/tuix-text.enums.js +0 -63
  81. package/package-build/src/tuix-toast/TuixToast.d.ts +0 -15
  82. package/package-build/src/tuix-toast/TuixToast.js +0 -100
  83. package/package-build/src/tuix-toast/TuixToast.styles.d.ts +0 -3
  84. package/package-build/src/tuix-toast/TuixToast.styles.js +0 -43
  85. package/package-build/src/tuix-toast/enums/tuix-toast.enums.d.ts +0 -20
  86. package/package-build/src/tuix-toast/enums/tuix-toast.enums.js +0 -59
  87. package/package-build/src/tuix-toggle-button/TuixToggleButton.d.ts +0 -13
  88. package/package-build/src/tuix-toggle-button/TuixToggleButton.js +0 -85
  89. package/package-build/src/tuix-toggle-button/TuixToggleButton.styles.d.ts +0 -5
  90. package/package-build/src/tuix-toggle-button/TuixToggleButton.styles.js +0 -134
  91. package/package-build/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +0 -2
  92. package/package-build/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js +0 -1
  93. package/package-build/src/utils/colors.d.ts +0 -29
  94. package/package-build/src/utils/colors.js +0 -30
  95. package/package-build/src/utils/darkColors.d.ts +0 -31
  96. package/package-build/src/utils/darkColors.js +0 -32
  97. package/package-build/src/utils/hex-rgb.d.ts +0 -5
  98. package/package-build/src/utils/hex-rgb.js +0 -15
  99. package/package-build/src/utils/interfaces/detail-value.interface.d.ts +0 -3
  100. package/package-build/src/utils/interfaces/detail-value.interface.js +0 -1
  101. package/package-build/src/utils/mainVariant.enum.d.ts +0 -4
  102. package/package-build/src/utils/mainVariant.enum.js +0 -5
  103. package/package-build/src/utils/screenSizes.enum.d.ts +0 -4
  104. package/package-build/src/utils/screenSizes.enum.js +0 -5
  105. package/package-build/src/utils/slottedClassName.d.ts +0 -2
  106. package/package-build/src/utils/slottedClassName.js +0 -1
  107. package/package-build/tsconfig.publish.tsbuildinfo +0 -1
@@ -1,132 +0,0 @@
1
- import { css, unsafeCSS } from 'lit';
2
- import { Palette } from '../utils/colors';
3
- import { DarkPalette } from '../utils/darkColors';
4
- import { ScreenSizes } from '../utils/screenSizes.enum';
5
- export const hostStyles = css `
6
- :host {
7
- --t-main-color-tuix: ${unsafeCSS(Palette.MAIN)};
8
- --t-bg-color-primary: ${unsafeCSS(Palette.WHITE)};
9
- --t-bg-color-disabled: ${unsafeCSS(Palette.PRIMARY_100)};
10
- --t-text-color-error: ${unsafeCSS(Palette.ERROR)};
11
- --t-stroke-color-focus: ${unsafeCSS(Palette.SECONDARY)};
12
- --t-stroke-color-grey: ${unsafeCSS(Palette.PRIMARY_300)};
13
- --t-text-color-label: ${unsafeCSS(Palette.BLACK)};
14
- --t-label-right-default-justify: flex-start;
15
- --t-label-left-default-justify: space-between;
16
- }
17
- :host([dark]) {
18
- --t-main-color-tuix: ${unsafeCSS(DarkPalette.MAIN)};
19
- --t-bg-color-primary: ${unsafeCSS(DarkPalette.BLACK)};
20
- --t-bg-color-disabled: ${unsafeCSS(DarkPalette.PRIMARY_800)};
21
- --t-text-color-error: ${unsafeCSS(DarkPalette.ERROR)};
22
- --t-stroke-color-focus: ${unsafeCSS(DarkPalette.SECONDARY)};
23
- --t-stroke-color-grey: ${unsafeCSS(DarkPalette.PRIMARY_100)};
24
- --t-text-color-label: ${unsafeCSS(DarkPalette.WHITE)};
25
- }
26
- `;
27
- export const checkboxContainerStyles = css `
28
- .t-checkbox-full-container {
29
- display: flex;
30
- justify-content: var(--t-label-right-default-justify, flex-start);
31
- cursor: pointer;
32
- -webkit-user-select: none;
33
- -moz-user-select: none;
34
- -ms-user-select: none;
35
- user-select: none;
36
- }
37
- :host([disabled]) .t-checkbox-full-container {
38
- cursor: not-allowed;
39
- }
40
- .t-checkbox-container {
41
- --t-checkbox-size-box: 1.5rem;
42
- --t-checkbox-shadow-width: 2px;
43
- --t-checkbox-border-radius: 0.25rem;
44
- display: block;
45
- position: relative;
46
- height: var(--t-checkbox-size-box);
47
- width: var(--t-checkbox-size-box);
48
- min-width: var(--t-checkbox-size-box);
49
- }
50
- .t-checkbox-container .t-checkbox {
51
- position: absolute;
52
- opacity: 0;
53
- height: 0;
54
- width: 0;
55
- }
56
- @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
57
- .t-checkbox-container {
58
- --t-checkbox-size-box: 1rem;
59
- --t-checkbox-shadow-width: 1px;
60
- --t-checkbox-border-radius: 0.125rem;
61
- margin-top: 1px;
62
- }
63
- }
64
- `;
65
- export const checkboxCheckmarkStyles = css `
66
- .t-checkbox-container .t-checkbox-checkmark {
67
- position: absolute;
68
- top: 0;
69
- left: 0;
70
- display: flex;
71
- height: var(--t-checkbox-size-box);
72
- width: var(--t-checkbox-size-box);
73
- border-radius: var(--t-checkbox-border-radius);
74
- background-color: var(--t-bg-color-primary);
75
- border: 1px solid var(--t-stroke-color-grey);
76
- box-sizing: border-box;
77
- }
78
- .t-checkbox-container .t-checkbox-checkmark tuix-icon {
79
- margin: auto;
80
- display: none;
81
- width: calc(var(--t-checkbox-size-box) - 0.5rem);
82
- height: calc(var(--t-checkbox-size-box) - 0.5rem);
83
- }
84
- .t-checkbox-container .t-checkbox:checked ~ .t-checkbox-checkmark {
85
- background-color: var(--t-main-color-tuix);
86
- border: none;
87
- }
88
- .t-checkbox-container .t-checkbox:focus ~ .t-checkbox-checkmark {
89
- box-shadow: 0 0 0px var(--t-checkbox-shadow-width)
90
- var(--t-stroke-color-focus);
91
- border: 1px solid var(--t-main-color-tuix);
92
- }
93
- .t-checkbox-container .t-checkbox:checked ~ .t-checkbox-checkmark tuix-icon {
94
- display: block;
95
- }
96
- .t-checkbox-full-container:hover .t-checkbox-container .t-checkbox-checkmark {
97
- border: 1px solid var(--t-main-color-tuix);
98
- }
99
- .t-checkbox-full-container.t-with-error
100
- .t-checkbox-container
101
- .t-checkbox-checkmark {
102
- border: 1px solid var(--t-text-color-error);
103
- }
104
- .t-checkbox-full-container.t-with-error
105
- .t-checkbox-container
106
- .t-checkbox:checked
107
- ~ .t-checkbox-checkmark {
108
- background-color: var(--t-text-color-error);
109
- border: none;
110
- }
111
-
112
- .t-checkbox-container .t-checkbox:disabled ~ .t-checkbox-checkmark {
113
- background-color: var(--t-bg-color-disabled);
114
- border: none;
115
- box-shadow: none;
116
- }
117
- `;
118
- export const checkboxLabelStyles = css `
119
- .t-checkbox-label {
120
- display: block;
121
- color: var(--t-text-color-label);
122
- margin-left: 0.625rem;
123
- }
124
- .t-checkbox-full-container.t-with-label-left {
125
- flex-direction: row-reverse;
126
- justify-content: var(--t-label-left-default-justify, space-between);
127
- }
128
- .t-checkbox-full-container.t-with-label-left .t-checkbox-label {
129
- margin-right: 0.625rem;
130
- margin-left: 0;
131
- }
132
- `;
@@ -1,21 +0,0 @@
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
- };
@@ -1,23 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
1
- import { type DetailValue } from '../../utils/interfaces/detail-value.interface';
2
- export interface DetailValueCheckbox extends DetailValue<boolean> {
3
- label?: string;
4
- }
5
- export type CustomEventTuixCheckbox = CustomEvent<DetailValueCheckbox>;
@@ -1,55 +0,0 @@
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
- }
@@ -1,360 +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';
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 };
@@ -1,3 +0,0 @@
1
- export declare const dropdownHostStyles: import("lit").CSSResult;
2
- export declare const dropdownMainContainerStyles: import("lit").CSSResult;
3
- export declare const dropdownOptionStyles: import("lit").CSSResult;