tuix-webcomponents 0.0.20 → 0.0.22
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 +29 -5
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.js +9 -7
- package/dist/src/index.js.map +1 -1
- package/dist/src/tuix-button/TuixButton.d.ts +17 -0
- package/dist/src/tuix-button/TuixButton.js +108 -0
- package/dist/src/tuix-button/TuixButton.js.map +1 -0
- package/dist/src/tuix-button/TuixButton.styles.d.ts +2 -0
- package/dist/src/tuix-button/TuixButton.styles.js +74 -0
- package/dist/src/tuix-button/TuixButton.styles.js.map +1 -0
- package/dist/src/tuix-button/enums/tuix-button.enums.d.ts +2 -0
- package/dist/src/tuix-button/enums/tuix-button.enums.js +7 -0
- package/dist/src/tuix-button/enums/tuix-button.enums.js.map +1 -0
- package/dist/src/tuix-dropdown/TuixDropdown.d.ts +46 -0
- package/dist/src/tuix-dropdown/TuixDropdown.js +275 -0
- package/dist/src/tuix-dropdown/TuixDropdown.js.map +1 -0
- package/dist/src/tuix-dropdown/TuixDropdown.styles.d.ts +3 -0
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js +85 -0
- package/dist/src/tuix-dropdown/TuixDropdown.styles.js.map +1 -0
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +10 -0
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js +13 -0
- package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js.map +1 -0
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +1 -0
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +2 -0
- package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js.map +1 -0
- package/dist/src/tuix-icon/TuixIcon.d.ts +11 -0
- package/dist/src/tuix-icon/TuixIcon.icons.d.ts +6 -0
- package/dist/src/tuix-icon/TuixIcon.icons.js +103 -0
- package/dist/src/tuix-icon/TuixIcon.icons.js.map +1 -0
- package/dist/src/tuix-icon/TuixIcon.js +65 -0
- package/dist/src/tuix-icon/TuixIcon.js.map +1 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +43 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js +52 -0
- package/dist/src/tuix-icon/enums/tuix-icon.enums.js.map +1 -0
- package/dist/src/tuix-icon-button/TuixIconButton.d.ts +14 -0
- package/dist/src/tuix-icon-button/TuixIconButton.js +80 -0
- package/dist/src/tuix-icon-button/TuixIconButton.js.map +1 -0
- package/dist/src/tuix-input/TuixInput.d.ts +46 -0
- package/dist/src/tuix-input/TuixInput.js +327 -0
- package/dist/src/tuix-input/TuixInput.js.map +1 -0
- package/dist/src/tuix-input/TuixInput.styles.d.ts +8 -0
- package/dist/src/tuix-input/TuixInput.styles.js +307 -0
- package/dist/src/tuix-input/TuixInput.styles.js.map +1 -0
- package/dist/src/tuix-input/enums/tuix-input.enums.d.ts +36 -0
- package/dist/src/tuix-input/enums/tuix-input.enums.js +42 -0
- package/dist/src/tuix-input/enums/tuix-input.enums.js.map +1 -0
- package/dist/src/tuix-input/interfaces/tuix-input.interface.d.ts +13 -0
- package/dist/src/tuix-input/interfaces/tuix-input.interface.js +2 -0
- package/dist/src/tuix-input/interfaces/tuix-input.interface.js.map +1 -0
- package/dist/src/tuix-link/TuixLink.d.ts +11 -0
- package/dist/src/tuix-link/TuixLink.js +72 -0
- package/dist/src/tuix-link/TuixLink.js.map +1 -0
- package/dist/src/tuix-link/enums/linkTarget.enum.d.ts +6 -0
- package/dist/src/tuix-link/enums/linkTarget.enum.js +8 -0
- package/dist/src/tuix-link/enums/linkTarget.enum.js.map +1 -0
- package/dist/src/tuix-paper/TuixPaper.d.ts +7 -0
- package/dist/src/tuix-paper/TuixPaper.js +40 -0
- package/dist/src/tuix-paper/TuixPaper.js.map +1 -0
- package/dist/src/tuix-paper/enums/tuix-paper.enum.d.ts +7 -0
- package/dist/src/tuix-paper/enums/tuix-paper.enum.js +9 -0
- package/dist/src/tuix-paper/enums/tuix-paper.enum.js.map +1 -0
- package/dist/src/tuix-text/TuixText.d.ts +3 -4
- package/dist/src/tuix-text/TuixText.js +23 -144
- package/dist/src/tuix-text/TuixText.js.map +1 -1
- package/dist/src/tuix-text/TuixText.styles.d.ts +1 -0
- package/dist/src/tuix-text/TuixText.styles.js +114 -0
- package/dist/src/tuix-text/TuixText.styles.js.map +1 -0
- package/dist/src/{enums → tuix-text/enums}/tuix-text.enums.d.ts +6 -8
- package/dist/src/tuix-text/enums/tuix-text.enums.js +25 -0
- package/dist/src/tuix-text/enums/tuix-text.enums.js.map +1 -0
- package/dist/src/utils/colors.d.ts +12 -10
- package/dist/src/utils/colors.js +42 -10
- package/dist/src/utils/colors.js.map +1 -1
- package/dist/src/utils/darkColors.d.ts +1 -0
- package/dist/src/utils/darkColors.js +11 -0
- package/dist/src/utils/darkColors.js.map +1 -0
- package/dist/src/utils/hex-rgb.d.ts +5 -0
- package/dist/src/utils/hex-rgb.js +16 -0
- package/dist/src/utils/hex-rgb.js.map +1 -0
- package/dist/src/utils/mainVariant.enum.d.ts +4 -0
- package/dist/src/utils/mainVariant.enum.js +6 -0
- package/dist/src/utils/mainVariant.enum.js.map +1 -0
- package/dist/src/utils/screenSizes.enum.d.ts +4 -0
- package/dist/src/utils/screenSizes.enum.js +7 -0
- package/dist/src/utils/screenSizes.enum.js.map +1 -0
- package/dist/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +17 -6
- package/dist/src/enums/tuix-text.enums.js +0 -32
- package/dist/src/enums/tuix-text.enums.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import '../tuix-icon/TuixIcon.js';
|
|
3
|
+
import { IconName } from '../tuix-icon/enums/tuix-icon.enums';
|
|
4
|
+
import { DescriptionType, InputType } from './enums/tuix-input.enums.js';
|
|
5
|
+
export declare class TuixInput extends LitElement {
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
iconRight?: IconName;
|
|
9
|
+
value: string;
|
|
10
|
+
placeholder: string;
|
|
11
|
+
title: string;
|
|
12
|
+
type: InputType;
|
|
13
|
+
maxlength: undefined;
|
|
14
|
+
description: undefined;
|
|
15
|
+
descriptionType: DescriptionType;
|
|
16
|
+
dark: boolean;
|
|
17
|
+
readonly: boolean;
|
|
18
|
+
private _inputElement;
|
|
19
|
+
private _type;
|
|
20
|
+
private _letterCounter;
|
|
21
|
+
private _previousType;
|
|
22
|
+
private _preivousValue;
|
|
23
|
+
private _generalIconColorsLight;
|
|
24
|
+
private _generalIconColorsDark;
|
|
25
|
+
private _handleInputBase;
|
|
26
|
+
private _handleInput;
|
|
27
|
+
private _handleChange;
|
|
28
|
+
private _handlePasswordIconClick;
|
|
29
|
+
private _formatIconSet;
|
|
30
|
+
private _updateLetterCounter;
|
|
31
|
+
private _getInputTextFeatureTemplate;
|
|
32
|
+
private _getInputSearchFeatureTemplate;
|
|
33
|
+
private _getInputPasswordFeatureTemplate;
|
|
34
|
+
private _getFeatureTemplateByInputType;
|
|
35
|
+
private _getInputElementClasses;
|
|
36
|
+
private _getInputContainerClasses;
|
|
37
|
+
private _getInputTemplate;
|
|
38
|
+
private _getLetterCounterTemplate;
|
|
39
|
+
private _hasLetterCounter;
|
|
40
|
+
private _getTextAreaTemplate;
|
|
41
|
+
private _getIconDescriptionTemplate;
|
|
42
|
+
private _getDescriptionTemplate;
|
|
43
|
+
private _hasValidDescriptionType;
|
|
44
|
+
private _getDescriptionContainerTemplate;
|
|
45
|
+
protected render(): TemplateResult;
|
|
46
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, html, nothing } from 'lit';
|
|
3
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import '../tuix-icon/TuixIcon.js';
|
|
6
|
+
import { IconName, IconSizeVariant } from '../tuix-icon/enums/tuix-icon.enums';
|
|
7
|
+
import { palette } from '../utils/colors.js';
|
|
8
|
+
import { darkPalette } from '../utils/darkColors.js';
|
|
9
|
+
import { hostStyles, inputColorStyles, inputComponentStyles, inputDescriptionStyles, inputFontStyles, inputIconStyles, inputSearchStyles, inputTitleStyles, } from './TuixInput.styles.js';
|
|
10
|
+
import { DescriptionType, IconByDescriptionType, IconDescriptionColorDark, IconDescriptionColorLight, InputIconLocation, InputType, } from './enums/tuix-input.enums.js';
|
|
11
|
+
let TuixInput = class TuixInput extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
var _a;
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.disabled = false;
|
|
16
|
+
this.value = '';
|
|
17
|
+
this.placeholder = '';
|
|
18
|
+
this.title = '';
|
|
19
|
+
this.type = InputType.TEXT;
|
|
20
|
+
this.maxlength = undefined;
|
|
21
|
+
this.description = undefined;
|
|
22
|
+
this.descriptionType = DescriptionType.TEXT;
|
|
23
|
+
this.dark = false;
|
|
24
|
+
this.readonly = false;
|
|
25
|
+
this._type = this.type;
|
|
26
|
+
this._letterCounter = ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
27
|
+
this._previousType = this.type;
|
|
28
|
+
this._preivousValue = '';
|
|
29
|
+
this._generalIconColorsLight = {
|
|
30
|
+
inactive: palette.black,
|
|
31
|
+
active: palette.main,
|
|
32
|
+
disabled: palette.primary_300,
|
|
33
|
+
};
|
|
34
|
+
this._generalIconColorsDark = {
|
|
35
|
+
inactive: darkPalette.primary_100,
|
|
36
|
+
active: darkPalette.main,
|
|
37
|
+
disabled: darkPalette.primary_800,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
_handleInputBase(e, eventName) {
|
|
41
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
42
|
+
detail: {
|
|
43
|
+
value: e.target.value,
|
|
44
|
+
},
|
|
45
|
+
bubbles: true,
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
_handleInput(e) {
|
|
49
|
+
this._handleInputBase(e, 'input-single');
|
|
50
|
+
this._updateLetterCounter();
|
|
51
|
+
}
|
|
52
|
+
_handleChange(e) {
|
|
53
|
+
this._handleInputBase(e, 'change');
|
|
54
|
+
}
|
|
55
|
+
_handlePasswordIconClick() {
|
|
56
|
+
if (this._type === InputType.PASSWORD) {
|
|
57
|
+
this._type = InputType.TEXT;
|
|
58
|
+
this._inputElement.setAttribute('type', InputType.TEXT);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this._type = InputType.PASSWORD;
|
|
62
|
+
this._inputElement.setAttribute('type', InputType.PASSWORD);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
_formatIconSet({ iconName, colorByState, location = InputIconLocation.RIGHT, clickHandler = undefined, }) {
|
|
66
|
+
const iconSetContainerClasses = {
|
|
67
|
+
't-icon-set-container': true,
|
|
68
|
+
't-icon-click': !!clickHandler,
|
|
69
|
+
[`t-icon-${location}`]: true,
|
|
70
|
+
};
|
|
71
|
+
return html `<div
|
|
72
|
+
class="${classMap(iconSetContainerClasses)}"
|
|
73
|
+
@click="${clickHandler}"
|
|
74
|
+
>
|
|
75
|
+
${Object.entries(colorByState).map(([state, color]) => html `<tuix-icon
|
|
76
|
+
size="${IconSizeVariant.FULL}"
|
|
77
|
+
name="${iconName}"
|
|
78
|
+
color="${color}"
|
|
79
|
+
class="t-icon-${state}"
|
|
80
|
+
></tuix-icon>`)}
|
|
81
|
+
</div>`;
|
|
82
|
+
}
|
|
83
|
+
_updateLetterCounter() {
|
|
84
|
+
var _a;
|
|
85
|
+
if (this.maxlength != undefined && this.type === InputType.TEXT_AREA) {
|
|
86
|
+
this._letterCounter = (_a = this._inputElement.value) === null || _a === void 0 ? void 0 : _a.length;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
_getInputTextFeatureTemplate() {
|
|
90
|
+
return html `${this.iconRight
|
|
91
|
+
? this._formatIconSet({
|
|
92
|
+
iconName: this.iconRight,
|
|
93
|
+
colorByState: this.dark
|
|
94
|
+
? this._generalIconColorsDark
|
|
95
|
+
: this._generalIconColorsLight,
|
|
96
|
+
})
|
|
97
|
+
: nothing}`;
|
|
98
|
+
}
|
|
99
|
+
_getInputSearchFeatureTemplate() {
|
|
100
|
+
const searchIconColorsLight = {
|
|
101
|
+
inactive: palette.black,
|
|
102
|
+
active: palette.black,
|
|
103
|
+
disabled: palette.primary_300,
|
|
104
|
+
};
|
|
105
|
+
const searchIconColorsDark = {
|
|
106
|
+
inactive: darkPalette.primary_100,
|
|
107
|
+
active: darkPalette.primary_100,
|
|
108
|
+
disabled: darkPalette.primary_800,
|
|
109
|
+
};
|
|
110
|
+
return html `${this._formatIconSet({
|
|
111
|
+
iconName: IconName.SEARCH,
|
|
112
|
+
colorByState: this.dark ? searchIconColorsDark : searchIconColorsLight,
|
|
113
|
+
location: InputIconLocation.LEFT,
|
|
114
|
+
})}`;
|
|
115
|
+
}
|
|
116
|
+
_getInputPasswordFeatureTemplate() {
|
|
117
|
+
return html `${this._formatIconSet({
|
|
118
|
+
iconName: this._type === InputType.PASSWORD
|
|
119
|
+
? IconName.EYE_CLOSE_LINE
|
|
120
|
+
: IconName.EYE_ON,
|
|
121
|
+
colorByState: this.dark
|
|
122
|
+
? this._generalIconColorsDark
|
|
123
|
+
: this._generalIconColorsLight,
|
|
124
|
+
clickHandler: this._handlePasswordIconClick,
|
|
125
|
+
})} `;
|
|
126
|
+
}
|
|
127
|
+
_getFeatureTemplateByInputType() {
|
|
128
|
+
switch (this.type) {
|
|
129
|
+
case InputType.SEARCH:
|
|
130
|
+
return this._getInputSearchFeatureTemplate();
|
|
131
|
+
case InputType.TEXT:
|
|
132
|
+
return this._getInputTextFeatureTemplate();
|
|
133
|
+
case InputType.PASSWORD:
|
|
134
|
+
return this._getInputPasswordFeatureTemplate();
|
|
135
|
+
default:
|
|
136
|
+
return html `${nothing}`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_getInputElementClasses() {
|
|
140
|
+
const hasIconRight = this.type === InputType.PASSWORD || this.type === InputType.TEXT
|
|
141
|
+
? !!this.iconRight
|
|
142
|
+
: false;
|
|
143
|
+
return {
|
|
144
|
+
't-input': true,
|
|
145
|
+
'with-title': !!this.title,
|
|
146
|
+
'with-icon-right': hasIconRight,
|
|
147
|
+
[`with-${this.descriptionType}`]: this.descriptionType !== DescriptionType.TEXT,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
_getInputContainerClasses() {
|
|
151
|
+
return {
|
|
152
|
+
't-input-container': true,
|
|
153
|
+
't-textarea-container': this.type === InputType.TEXT_AREA,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
_getInputTemplate() {
|
|
157
|
+
return html `<input
|
|
158
|
+
type="text"
|
|
159
|
+
class="${classMap(this._getInputElementClasses())}"
|
|
160
|
+
?disabled="${this.disabled}"
|
|
161
|
+
?readonly="${this.readonly}"
|
|
162
|
+
.value="${this.value}"
|
|
163
|
+
.type="${this.type}"
|
|
164
|
+
placeholder="${this.placeholder || ' '}"
|
|
165
|
+
maxlength="${this.maxlength}"
|
|
166
|
+
@input="${this._handleInput}"
|
|
167
|
+
@change="${this._handleChange}"
|
|
168
|
+
>
|
|
169
|
+
</input>
|
|
170
|
+
${this.title ? html `<div class="t-title">${this.title}</div>` : nothing}
|
|
171
|
+
${this._getFeatureTemplateByInputType()}
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
_getLetterCounterTemplate() {
|
|
175
|
+
if (!this._hasLetterCounter()) {
|
|
176
|
+
return html `${nothing}`;
|
|
177
|
+
}
|
|
178
|
+
return html `<div class="t-letter-counter">
|
|
179
|
+
${this.maxlength
|
|
180
|
+
? html `${this._letterCounter}/${this.maxlength}`
|
|
181
|
+
: nothing}
|
|
182
|
+
</div> `;
|
|
183
|
+
}
|
|
184
|
+
_hasLetterCounter() {
|
|
185
|
+
return (this.type === InputType.TEXT_AREA &&
|
|
186
|
+
typeof this.maxlength === 'number' &&
|
|
187
|
+
this.maxlength >= 0);
|
|
188
|
+
}
|
|
189
|
+
_getTextAreaTemplate() {
|
|
190
|
+
return html `<textarea
|
|
191
|
+
class="${classMap(this._getInputElementClasses())}"
|
|
192
|
+
?disabled="${this.disabled}"
|
|
193
|
+
?readonly="${this.readonly}"
|
|
194
|
+
.value="${this.value}"
|
|
195
|
+
placeholder="${this.placeholder}"
|
|
196
|
+
maxlength="${this.maxlength}"
|
|
197
|
+
@input="${this._handleInput}"
|
|
198
|
+
@change="${this._handleChange}"
|
|
199
|
+
></textarea>
|
|
200
|
+
${this.title
|
|
201
|
+
? html `<div class="t-title">${this.title}</div>`
|
|
202
|
+
: nothing} `;
|
|
203
|
+
}
|
|
204
|
+
_getIconDescriptionTemplate() {
|
|
205
|
+
if (!this.descriptionType ||
|
|
206
|
+
this.descriptionType === DescriptionType.TEXT) {
|
|
207
|
+
return html `${nothing}`;
|
|
208
|
+
}
|
|
209
|
+
return html `<tuix-icon
|
|
210
|
+
size="${IconSizeVariant.SMALL}"
|
|
211
|
+
name="${IconByDescriptionType[this.descriptionType]}"
|
|
212
|
+
color="${this.dark
|
|
213
|
+
? IconDescriptionColorDark[this.descriptionType]
|
|
214
|
+
: IconDescriptionColorLight[this.descriptionType]}"
|
|
215
|
+
>
|
|
216
|
+
</tuix-icon>`;
|
|
217
|
+
}
|
|
218
|
+
_getDescriptionTemplate() {
|
|
219
|
+
var _a;
|
|
220
|
+
const isValidDescriptionType = this._hasValidDescriptionType();
|
|
221
|
+
if (!isValidDescriptionType) {
|
|
222
|
+
return html `<div></div>`;
|
|
223
|
+
}
|
|
224
|
+
const defaultDescription = {
|
|
225
|
+
[DescriptionType.WARNING]: 'Warning',
|
|
226
|
+
[DescriptionType.ERROR]: 'Error',
|
|
227
|
+
[DescriptionType.SUCCESS]: 'Success',
|
|
228
|
+
[DescriptionType.LOADING]: 'Loading',
|
|
229
|
+
[DescriptionType.TEXT]: '',
|
|
230
|
+
};
|
|
231
|
+
return html `<div class="t-input-description">
|
|
232
|
+
${this._getIconDescriptionTemplate()}
|
|
233
|
+
<span
|
|
234
|
+
>${(_a = this.description) !== null && _a !== void 0 ? _a : defaultDescription[this.descriptionType]}</span
|
|
235
|
+
>
|
|
236
|
+
</div>`;
|
|
237
|
+
}
|
|
238
|
+
_hasValidDescriptionType() {
|
|
239
|
+
return Object.values(DescriptionType).includes(this.descriptionType);
|
|
240
|
+
}
|
|
241
|
+
_getDescriptionContainerTemplate() {
|
|
242
|
+
const hasLetterCounter = this._hasLetterCounter();
|
|
243
|
+
const hasDescription = this._hasValidDescriptionType() &&
|
|
244
|
+
(this.descriptionType === DescriptionType.TEXT
|
|
245
|
+
? !!this.description
|
|
246
|
+
: true);
|
|
247
|
+
if (!hasLetterCounter && !hasDescription) {
|
|
248
|
+
return html `${nothing}`;
|
|
249
|
+
}
|
|
250
|
+
return html `<div class="t-input-description-container">
|
|
251
|
+
${this._getDescriptionTemplate()} ${this._getLetterCounterTemplate()}
|
|
252
|
+
</div>`;
|
|
253
|
+
}
|
|
254
|
+
render() {
|
|
255
|
+
if (this._previousType !== this.type) {
|
|
256
|
+
this._previousType = this.type;
|
|
257
|
+
this._type = this.type;
|
|
258
|
+
}
|
|
259
|
+
if (this._preivousValue !== this.value) {
|
|
260
|
+
this._preivousValue = this.value;
|
|
261
|
+
this._letterCounter = this.value.length;
|
|
262
|
+
}
|
|
263
|
+
return html `<div class="${classMap(this._getInputContainerClasses())}">
|
|
264
|
+
${this.type === InputType.TEXT_AREA
|
|
265
|
+
? this._getTextAreaTemplate()
|
|
266
|
+
: this._getInputTemplate()}
|
|
267
|
+
</div>
|
|
268
|
+
${this._getDescriptionContainerTemplate()} `;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
TuixInput.styles = [
|
|
272
|
+
hostStyles,
|
|
273
|
+
inputComponentStyles,
|
|
274
|
+
inputFontStyles,
|
|
275
|
+
inputColorStyles,
|
|
276
|
+
inputTitleStyles,
|
|
277
|
+
inputIconStyles,
|
|
278
|
+
inputSearchStyles,
|
|
279
|
+
inputDescriptionStyles,
|
|
280
|
+
];
|
|
281
|
+
__decorate([
|
|
282
|
+
property({ type: Boolean })
|
|
283
|
+
], TuixInput.prototype, "disabled", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
property({ type: IconName })
|
|
286
|
+
], TuixInput.prototype, "iconRight", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
property({ type: String })
|
|
289
|
+
], TuixInput.prototype, "value", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
property({ type: String })
|
|
292
|
+
], TuixInput.prototype, "placeholder", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
property({ type: String })
|
|
295
|
+
], TuixInput.prototype, "title", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
property({ type: InputType })
|
|
298
|
+
], TuixInput.prototype, "type", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
property({ type: Number, reflect: true })
|
|
301
|
+
], TuixInput.prototype, "maxlength", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
property({ type: String })
|
|
304
|
+
], TuixInput.prototype, "description", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
property({ type: DescriptionType })
|
|
307
|
+
], TuixInput.prototype, "descriptionType", void 0);
|
|
308
|
+
__decorate([
|
|
309
|
+
property({ type: Boolean })
|
|
310
|
+
], TuixInput.prototype, "dark", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
property({ type: Boolean })
|
|
313
|
+
], TuixInput.prototype, "readonly", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
query('.t-input-container .t-input')
|
|
316
|
+
], TuixInput.prototype, "_inputElement", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
state()
|
|
319
|
+
], TuixInput.prototype, "_type", void 0);
|
|
320
|
+
__decorate([
|
|
321
|
+
state()
|
|
322
|
+
], TuixInput.prototype, "_letterCounter", void 0);
|
|
323
|
+
TuixInput = __decorate([
|
|
324
|
+
customElement('tuix-input')
|
|
325
|
+
], TuixInput);
|
|
326
|
+
export { TuixInput };
|
|
327
|
+
//# sourceMappingURL=TuixInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TuixInput.js","sourceRoot":"","sources":["../../../src/tuix-input/TuixInput.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,SAAS,GACV,MAAM,6BAA6B,CAAC;AAOrC,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAAzC;;;QAaE,aAAQ,GAAG,KAAK,CAAC;QAMjB,UAAK,GAAG,EAAE,CAAC;QAGX,gBAAW,GAAG,EAAE,CAAC;QAGjB,UAAK,GAAG,EAAE,CAAC;QAGX,SAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAGtB,cAAS,GAAG,SAAS,CAAC;QAGtB,gBAAW,GAAG,SAAS,CAAC;QAGxB,oBAA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GtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4CACpB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACH;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;kDACG;AAGvC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uCACf;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACX;AAGT;IADP,KAAK,CAAC,6BAA6B,CAAC;gDACI;AAGjC;IADP,KAAK,EAAE;wCACkB;AAGlB;IADP,KAAK,EAAE;iDACyC;AApDtC,SAAS;IADrB,aAAa,CAAC,YAAY,CAAC;GACf,SAAS,CA8UrB;SA9UY,SAAS","sourcesContent":["import { LitElement, TemplateResult, html, nothing } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport '../tuix-icon/TuixIcon.js';\nimport { IconName, IconSizeVariant } from '../tuix-icon/enums/tuix-icon.enums';\nimport { palette } from '../utils/colors.js';\nimport { darkPalette } from '../utils/darkColors.js';\nimport {\n hostStyles,\n inputColorStyles,\n inputComponentStyles,\n inputDescriptionStyles,\n inputFontStyles,\n inputIconStyles,\n inputSearchStyles,\n inputTitleStyles,\n} from './TuixInput.styles.js';\nimport {\n DescriptionType,\n IconByDescriptionType,\n IconDescriptionColorDark,\n IconDescriptionColorLight,\n InputIconLocation,\n InputType,\n} from './enums/tuix-input.enums.js';\nimport {\n FormatIconSetParams,\n InputIconColors,\n} from './interfaces/tuix-input.interface.js';\n\n@customElement('tuix-input')\nexport class TuixInput extends LitElement {\n static styles = [\n hostStyles,\n inputComponentStyles,\n inputFontStyles,\n inputColorStyles,\n inputTitleStyles,\n inputIconStyles,\n inputSearchStyles,\n inputDescriptionStyles,\n ];\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: IconName })\n iconRight?: IconName;\n\n @property({ type: String })\n value = '';\n\n @property({ type: String })\n placeholder = '';\n\n @property({ type: String })\n title = '';\n\n @property({ type: InputType })\n type = InputType.TEXT;\n\n @property({ type: Number, reflect: true })\n maxlength = undefined;\n\n @property({ type: String })\n description = undefined;\n\n @property({ type: DescriptionType })\n descriptionType = DescriptionType.TEXT;\n\n @property({ type: Boolean })\n dark = false;\n\n @property({ type: Boolean })\n readonly = false;\n\n @query('.t-input-container .t-input')\n private _inputElement!: HTMLInputElement;\n\n @state()\n private _type = this.type;\n\n @state()\n private _letterCounter = this.value?.length || 0;\n\n private _previousType = this.type;\n\n private _preivousValue = '';\n\n private _generalIconColorsLight: InputIconColors = {\n inactive: palette.black,\n active: palette.main,\n disabled: palette.primary_300,\n };\n\n private _generalIconColorsDark: InputIconColors = {\n inactive: darkPalette.primary_100,\n active: darkPalette.main,\n disabled: darkPalette.primary_800,\n };\n\n private _handleInputBase(e: InputEvent, eventName: string) {\n this.dispatchEvent(\n new CustomEvent(eventName, {\n detail: {\n value: (e.target as HTMLInputElement).value,\n },\n bubbles: true,\n })\n );\n }\n\n private _handleInput(e: InputEvent) {\n this._handleInputBase(e, 'input-single');\n this._updateLetterCounter();\n }\n\n private _handleChange(e: InputEvent) {\n this._handleInputBase(e, 'change');\n }\n\n private _handlePasswordIconClick() {\n if (this._type === InputType.PASSWORD) {\n this._type = InputType.TEXT;\n this._inputElement.setAttribute('type', InputType.TEXT);\n } else {\n this._type = InputType.PASSWORD;\n this._inputElement.setAttribute('type', InputType.PASSWORD);\n }\n }\n\n private _formatIconSet({\n iconName,\n colorByState,\n location = InputIconLocation.RIGHT,\n clickHandler = undefined,\n }: FormatIconSetParams) {\n const iconSetContainerClasses = {\n 't-icon-set-container': true,\n 't-icon-click': !!clickHandler,\n [`t-icon-${location}`]: true,\n };\n return html`<div\n class=\"${classMap(iconSetContainerClasses)}\"\n @click=\"${clickHandler}\"\n >\n ${Object.entries(colorByState).map(\n ([state, color]) => html`<tuix-icon\n size=\"${IconSizeVariant.FULL}\"\n name=\"${iconName}\"\n color=\"${color}\"\n class=\"t-icon-${state}\"\n ></tuix-icon>`\n )}\n </div>`;\n }\n\n private _updateLetterCounter() {\n if (this.maxlength != undefined && this.type === InputType.TEXT_AREA) {\n this._letterCounter = this._inputElement.value?.length;\n }\n }\n\n private _getInputTextFeatureTemplate(): TemplateResult {\n return html`${this.iconRight\n ? this._formatIconSet({\n iconName: this.iconRight,\n colorByState: this.dark\n ? this._generalIconColorsDark\n : this._generalIconColorsLight,\n })\n : nothing}`;\n }\n\n private _getInputSearchFeatureTemplate(): TemplateResult {\n const searchIconColorsLight: InputIconColors = {\n inactive: palette.black,\n active: palette.black,\n disabled: palette.primary_300,\n };\n const searchIconColorsDark: InputIconColors = {\n inactive: darkPalette.primary_100,\n active: darkPalette.primary_100,\n disabled: darkPalette.primary_800,\n };\n return html`${this._formatIconSet({\n iconName: IconName.SEARCH,\n colorByState: this.dark ? searchIconColorsDark : searchIconColorsLight,\n location: InputIconLocation.LEFT,\n })}`;\n }\n\n private _getInputPasswordFeatureTemplate(): TemplateResult {\n return html`${this._formatIconSet({\n iconName:\n this._type === InputType.PASSWORD\n ? IconName.EYE_CLOSE_LINE\n : IconName.EYE_ON,\n colorByState: this.dark\n ? this._generalIconColorsDark\n : this._generalIconColorsLight,\n clickHandler: this._handlePasswordIconClick,\n })} `;\n }\n\n private _getFeatureTemplateByInputType(): TemplateResult {\n switch (this.type) {\n case InputType.SEARCH:\n return this._getInputSearchFeatureTemplate();\n case InputType.TEXT:\n return this._getInputTextFeatureTemplate();\n case InputType.PASSWORD:\n return this._getInputPasswordFeatureTemplate();\n default:\n return html`${nothing}`;\n }\n }\n\n private _getInputElementClasses() {\n const hasIconRight =\n this.type === InputType.PASSWORD || this.type === InputType.TEXT\n ? !!this.iconRight\n : false;\n return {\n 't-input': true,\n 'with-title': !!this.title,\n 'with-icon-right': hasIconRight,\n [`with-${this.descriptionType}`]:\n this.descriptionType !== DescriptionType.TEXT,\n };\n }\n\n private _getInputContainerClasses() {\n return {\n 't-input-container': true,\n 't-textarea-container': this.type === InputType.TEXT_AREA,\n };\n }\n\n private _getInputTemplate(): TemplateResult {\n return html`<input\n type=\"text\"\n class=\"${classMap(this._getInputElementClasses())}\"\n ?disabled=\"${this.disabled}\"\n ?readonly=\"${this.readonly}\"\n .value=\"${this.value}\"\n .type=\"${this.type}\"\n placeholder=\"${this.placeholder || ' '}\"\n maxlength=\"${this.maxlength}\"\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n >\n </input>\n ${this.title ? html`<div class=\"t-title\">${this.title}</div>` : nothing}\n ${this._getFeatureTemplateByInputType()}\n `;\n }\n\n private _getLetterCounterTemplate(): TemplateResult {\n if (!this._hasLetterCounter()) {\n return html`${nothing}`;\n }\n return html`<div class=\"t-letter-counter\">\n ${this.maxlength\n ? html`${this._letterCounter}/${this.maxlength}`\n : nothing}\n </div> `;\n }\n\n private _hasLetterCounter(): boolean {\n return (\n this.type === InputType.TEXT_AREA &&\n typeof this.maxlength === 'number' &&\n this.maxlength >= 0\n );\n }\n\n private _getTextAreaTemplate(): TemplateResult {\n return html`<textarea\n class=\"${classMap(this._getInputElementClasses())}\"\n ?disabled=\"${this.disabled}\"\n ?readonly=\"${this.readonly}\"\n .value=\"${this.value}\"\n placeholder=\"${this.placeholder}\"\n maxlength=\"${this.maxlength}\"\n @input=\"${this._handleInput}\"\n @change=\"${this._handleChange}\"\n ></textarea>\n ${this.title\n ? html`<div class=\"t-title\">${this.title}</div>`\n : nothing} `;\n }\n\n private _getIconDescriptionTemplate(): TemplateResult {\n if (\n !this.descriptionType ||\n this.descriptionType === DescriptionType.TEXT\n ) {\n return html`${nothing}`;\n }\n return html`<tuix-icon\n size=\"${IconSizeVariant.SMALL}\"\n name=\"${IconByDescriptionType[this.descriptionType]}\"\n color=\"${this.dark\n ? IconDescriptionColorDark[this.descriptionType]\n : IconDescriptionColorLight[this.descriptionType]}\"\n >\n </tuix-icon>`;\n }\n\n private _getDescriptionTemplate(): TemplateResult {\n const isValidDescriptionType = this._hasValidDescriptionType();\n if (!isValidDescriptionType) {\n return html`<div></div>`;\n }\n const defaultDescription = {\n [DescriptionType.WARNING]: 'Warning',\n [DescriptionType.ERROR]: 'Error',\n [DescriptionType.SUCCESS]: 'Success',\n [DescriptionType.LOADING]: 'Loading',\n [DescriptionType.TEXT]: '',\n };\n return html`<div class=\"t-input-description\">\n ${this._getIconDescriptionTemplate()}\n <span\n >${this.description ?? defaultDescription[this.descriptionType]}</span\n >\n </div>`;\n }\n\n private _hasValidDescriptionType(): boolean {\n return Object.values(DescriptionType).includes(this.descriptionType);\n }\n\n private _getDescriptionContainerTemplate(): TemplateResult {\n const hasLetterCounter = this._hasLetterCounter();\n const hasDescription =\n this._hasValidDescriptionType() &&\n (this.descriptionType === DescriptionType.TEXT\n ? !!this.description\n : true);\n if (!hasLetterCounter && !hasDescription) {\n return html`${nothing}`;\n }\n return html`<div class=\"t-input-description-container\">\n ${this._getDescriptionTemplate()} ${this._getLetterCounterTemplate()}\n </div>`;\n }\n\n protected render(): TemplateResult {\n if (this._previousType !== this.type) {\n this._previousType = this.type;\n this._type = this.type;\n }\n if (this._preivousValue !== this.value) {\n this._preivousValue = this.value;\n this._letterCounter = this.value.length;\n }\n return html`<div class=\"${classMap(this._getInputContainerClasses())}\">\n ${this.type === InputType.TEXT_AREA\n ? this._getTextAreaTemplate()\n : this._getInputTemplate()}\n </div>\n ${this._getDescriptionContainerTemplate()} `;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const hostStyles: import("lit").CSSResult;
|
|
2
|
+
export declare const inputComponentStyles: import("lit").CSSResult;
|
|
3
|
+
export declare const inputFontStyles: import("lit").CSSResult;
|
|
4
|
+
export declare const inputColorStyles: import("lit").CSSResult;
|
|
5
|
+
export declare const inputTitleStyles: import("lit").CSSResult;
|
|
6
|
+
export declare const inputIconStyles: import("lit").CSSResult;
|
|
7
|
+
export declare const inputSearchStyles: import("lit").CSSResult;
|
|
8
|
+
export declare const inputDescriptionStyles: import("lit").CSSResult;
|