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
package/README.md
CHANGED
|
@@ -10,12 +10,36 @@ npm i tuix-webcomponents
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
### React .tsx with SSR
|
|
14
|
+
|
|
15
|
+
```typescript jsx
|
|
16
|
+
import { loadFonts } from 'tuix-webcomponents';
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
|
|
20
|
+
// load fonts for SSR and CSR
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
loadFonts()
|
|
23
|
+
}, [])
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<tuix-text size="xl" type="headline" color="primary"></tuix-text>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### React .tsx without SSR
|
|
32
|
+
|
|
33
|
+
```typescript jsx
|
|
34
|
+
import { loadFonts } from 'tuix-webcomponents';
|
|
35
|
+
loadFonts()
|
|
17
36
|
|
|
18
|
-
|
|
37
|
+
function App() {
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<tuix-text size="xl" type="headline" color="primary"></tuix-text>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
19
43
|
```
|
|
20
44
|
|
|
21
45
|
## Linting and formatting
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
export { TuixText } from './tuix-text/TuixText.js';
|
|
2
|
+
export { TuixIcon } from './tuix-icon/TuixIcon.js';
|
|
3
|
+
export { TuixButton } from './tuix-button/TuixButton.js';
|
|
4
|
+
export { TuixPaper } from './tuix-paper/TuixPaper.js';
|
|
5
|
+
export { TuixIconButton } from './tuix-icon-button/TuixIconButton.js';
|
|
6
|
+
export { TuixLink } from './tuix-link/TuixLink.js';
|
|
7
|
+
export { TuixInput } from './tuix-input/TuixInput.js';
|
|
8
|
+
export { TuixDropdown } from './tuix-dropdown/TuixDropdown.js';
|
|
2
9
|
export declare function loadFonts(): void;
|
package/dist/src/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export { TuixText } from './tuix-text/TuixText.js';
|
|
2
|
+
export { TuixIcon } from './tuix-icon/TuixIcon.js';
|
|
3
|
+
export { TuixButton } from './tuix-button/TuixButton.js';
|
|
4
|
+
export { TuixPaper } from './tuix-paper/TuixPaper.js';
|
|
5
|
+
export { TuixIconButton } from './tuix-icon-button/TuixIconButton.js';
|
|
6
|
+
export { TuixLink } from './tuix-link/TuixLink.js';
|
|
7
|
+
export { TuixInput } from './tuix-input/TuixInput.js';
|
|
8
|
+
export { TuixDropdown } from './tuix-dropdown/TuixDropdown.js';
|
|
9
|
+
export function loadFonts() {
|
|
7
10
|
const link1 = document.createElement('link');
|
|
8
11
|
link1.rel = 'preconnect';
|
|
9
12
|
link1.href = 'https://fonts.googleapis.com';
|
|
@@ -18,5 +21,4 @@ function loadFonts() {
|
|
|
18
21
|
document.head.appendChild(link2);
|
|
19
22
|
document.head.appendChild(link3);
|
|
20
23
|
}
|
|
21
|
-
exports.loadFonts = loadFonts;
|
|
22
24
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE/D,MAAM,UAAU,SAAS;IACvB,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,KAAK,CAAC,GAAG,GAAG,YAAY,CAAC;IACzB,KAAK,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC5C,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,KAAK,CAAC,GAAG,GAAG,YAAY,CAAC;IACzB,KAAK,CAAC,IAAI,GAAG,2BAA2B,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC7C,KAAK,CAAC,GAAG,GAAG,YAAY,CAAC;IACzB,KAAK,CAAC,IAAI;QACR,2JAA2J,CAAC;IAC9J,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC","sourcesContent":["export { TuixText } from './tuix-text/TuixText.js';\nexport { TuixIcon } from './tuix-icon/TuixIcon.js';\nexport { TuixButton } from './tuix-button/TuixButton.js';\nexport { TuixPaper } from './tuix-paper/TuixPaper.js';\nexport { TuixIconButton } from './tuix-icon-button/TuixIconButton.js';\nexport { TuixLink } from './tuix-link/TuixLink.js';\nexport { TuixInput } from './tuix-input/TuixInput.js';\nexport { TuixDropdown } from './tuix-dropdown/TuixDropdown.js';\n\nexport function loadFonts() {\n const link1 = document.createElement('link');\n link1.rel = 'preconnect';\n link1.href = 'https://fonts.googleapis.com';\n const link2 = document.createElement('link');\n link2.rel = 'preconnect';\n link2.href = 'https://fonts.gstatic.com';\n const link3 = document.createElement('link');\n link3.rel = 'stylesheet';\n link3.href =\n 'https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap';\n document.head.appendChild(link1);\n document.head.appendChild(link2);\n document.head.appendChild(link3);\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import { IconName } from '../tuix-icon/enums/tuix-icon.enums';
|
|
3
|
+
import '../tuix-icon/TuixIcon.js';
|
|
4
|
+
import { MainVariant } from '../utils/mainVariant.enum';
|
|
5
|
+
export declare class TuixButton extends LitElement {
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
iconColor: string;
|
|
8
|
+
variant: MainVariant;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
iconRight?: IconName;
|
|
11
|
+
iconLeft?: IconName;
|
|
12
|
+
private _getIconColor;
|
|
13
|
+
private _handleClick;
|
|
14
|
+
private _iconTemplate;
|
|
15
|
+
getButtonStyles(): string;
|
|
16
|
+
protected render(): TemplateResult;
|
|
17
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { LitElement, css, html, nothing } from 'lit';
|
|
3
|
+
import { IconName, IconSizeVariant } from '../tuix-icon/enums/tuix-icon.enums';
|
|
4
|
+
import { buttonSizeStyles, buttonColorStyles } from './TuixButton.styles';
|
|
5
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
6
|
+
import '../tuix-icon/TuixIcon.js';
|
|
7
|
+
import { palette } from '../utils/colors';
|
|
8
|
+
import { MainVariant } from '../utils/mainVariant.enum';
|
|
9
|
+
import { buttonTextColor } from './enums/tuix-button.enums';
|
|
10
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
11
|
+
let TuixButton = class TuixButton extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.iconColor = '';
|
|
15
|
+
this.variant = MainVariant.PRIMARY;
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
}
|
|
18
|
+
_getIconColor() {
|
|
19
|
+
this.iconColor = buttonTextColor[this.variant];
|
|
20
|
+
if (this.disabled)
|
|
21
|
+
this.iconColor = palette.primary_300;
|
|
22
|
+
return this.iconColor;
|
|
23
|
+
}
|
|
24
|
+
_handleClick() {
|
|
25
|
+
this.dispatchEvent(new CustomEvent('click', { bubbles: true }));
|
|
26
|
+
}
|
|
27
|
+
_iconTemplate(iconName) {
|
|
28
|
+
let iconSize = IconSizeVariant.MEDIUM;
|
|
29
|
+
if (screen.width <= ScreenSizes.TABLET) {
|
|
30
|
+
iconSize = IconSizeVariant.SMALL;
|
|
31
|
+
}
|
|
32
|
+
return html `<tuix-icon
|
|
33
|
+
size="${iconSize}"
|
|
34
|
+
name="${iconName}"
|
|
35
|
+
color="${this._getIconColor()}"
|
|
36
|
+
></tuix-icon>`;
|
|
37
|
+
}
|
|
38
|
+
getButtonStyles() {
|
|
39
|
+
return `${this.variant}`;
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
return html `<button
|
|
43
|
+
@click=${this._handleClick}
|
|
44
|
+
class="button ${this.getButtonStyles()}"
|
|
45
|
+
?disabled="${this.disabled}"
|
|
46
|
+
>
|
|
47
|
+
<div class="container">
|
|
48
|
+
${this.iconLeft ? this._iconTemplate(this.iconLeft) : nothing}
|
|
49
|
+
<slot></slot>
|
|
50
|
+
${this.iconRight ? this._iconTemplate(this.iconRight) : nothing}
|
|
51
|
+
</div>
|
|
52
|
+
</button>`;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
TuixButton.styles = [
|
|
56
|
+
css `
|
|
57
|
+
.button {
|
|
58
|
+
padding: 16px 32px;
|
|
59
|
+
border-radius: 4px;
|
|
60
|
+
font-family: 'rubik', sans-serif;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
64
|
+
.button {
|
|
65
|
+
padding: 14px 32px;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
70
|
+
.button {
|
|
71
|
+
padding: 12px 24px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.container {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: row;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: 8px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
84
|
+
.container {
|
|
85
|
+
gap: 6px;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`,
|
|
89
|
+
buttonColorStyles,
|
|
90
|
+
buttonSizeStyles,
|
|
91
|
+
];
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: MainVariant })
|
|
94
|
+
], TuixButton.prototype, "variant", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
property({ type: Boolean })
|
|
97
|
+
], TuixButton.prototype, "disabled", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: IconName })
|
|
100
|
+
], TuixButton.prototype, "iconRight", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: IconName })
|
|
103
|
+
], TuixButton.prototype, "iconLeft", void 0);
|
|
104
|
+
TuixButton = __decorate([
|
|
105
|
+
customElement('tuix-button')
|
|
106
|
+
], TuixButton);
|
|
107
|
+
export { TuixButton };
|
|
108
|
+
//# sourceMappingURL=TuixButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TuixButton.js","sourceRoot":"","sources":["../../../src/tuix-button/TuixButton.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,UAAU;IAA1C;;QAuCE,cAAS,GAAG,EAAE,CAAC;QAGf,YAAO,GAAG,WAAW,CAAC,OAAO,CAAC;QAG9B,aAAQ,GAAG,KAAK,CAAC;IAkDnB,CAAC;IA1CS,aAAa;QACnB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;QAExD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAEO,aAAa,CAAC,QAAkB;QACtC,IAAI,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC;QAEtC,IAAI,MAAM,CAAC,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE;YACtC,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC;SAClC;QAED,OAAO,IAAI,CAAA;cACD,QAAQ;cACR,QAAoB;eACnB,IAAI,CAAC,aAAa,EAAE;kBACjB,CAAC;IACjB,CAAC;IAED,eAAe;QACb,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAES,MAAM;QACd,OAAO,IAAI,CAAA;eACA,IAAI,CAAC,YAAY;sBACV,IAAI,CAAC,eAAe,EAAE;mBACzB,IAAI,CAAC,QAAQ;;;UAGtB,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO;;UAE3D,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO;;cAEzD,CAAC;IACb,CAAC;;AA7FM,iBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;2CAOoC,WAAW,CAAC,MAAM;;;;;;2CAMlB,WAAW,CAAC,MAAM;;;;;;;;;;;;;;2CAclB,WAAW,CAAC,MAAM;;;;;KAKxD;IACD,iBAAiB;IACjB,gBAAgB;CACjB,AApCY,CAoCX;AAKF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;2CACF;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACX;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;6CACR;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;4CACT;AAnDT,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA+FtB;SA/FY,UAAU","sourcesContent":["import { LitElement, TemplateResult, css, html, nothing } from 'lit';\nimport { IconName, IconSizeVariant } from '../tuix-icon/enums/tuix-icon.enums';\nimport { buttonSizeStyles, buttonColorStyles } from './TuixButton.styles';\nimport { customElement, property } from 'lit/decorators.js';\nimport '../tuix-icon/TuixIcon.js';\nimport { palette } from '../utils/colors';\nimport { MainVariant } from '../utils/mainVariant.enum';\nimport { buttonTextColor } from './enums/tuix-button.enums';\nimport { ScreenSizes } from '../utils/screenSizes.enum';\n\n@customElement('tuix-button')\nexport class TuixButton extends LitElement {\n static styles = [\n css`\n .button {\n padding: 16px 32px;\n border-radius: 4px;\n font-family: 'rubik', sans-serif;\n }\n\n @media only screen and (max-width: ${ScreenSizes.TABLET}px) {\n .button {\n padding: 14px 32px;\n }\n }\n\n @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {\n .button {\n padding: 12px 24px;\n }\n }\n\n .container {\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n gap: 8px;\n }\n\n @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {\n .container {\n gap: 6px;\n }\n }\n `,\n buttonColorStyles,\n buttonSizeStyles,\n ];\n\n iconColor = '';\n\n @property({ type: MainVariant })\n variant = MainVariant.PRIMARY;\n\n @property({ type: Boolean })\n disabled = false;\n\n @property({ type: IconName })\n iconRight?: IconName;\n\n @property({ type: IconName })\n iconLeft?: IconName;\n\n private _getIconColor(): string {\n this.iconColor = buttonTextColor[this.variant];\n if (this.disabled) this.iconColor = palette.primary_300;\n\n return this.iconColor;\n }\n\n private _handleClick() {\n this.dispatchEvent(new CustomEvent('click', { bubbles: true }));\n }\n\n private _iconTemplate(iconName: IconName): TemplateResult {\n let iconSize = IconSizeVariant.MEDIUM;\n\n if (screen.width <= ScreenSizes.TABLET) {\n iconSize = IconSizeVariant.SMALL;\n }\n\n return html`<tuix-icon\n size=\"${iconSize}\"\n name=\"${iconName as IconName}\"\n color=\"${this._getIconColor()}\"\n ></tuix-icon>`;\n }\n\n getButtonStyles(): string {\n return `${this.variant}`;\n }\n\n protected render(): TemplateResult {\n return html`<button\n @click=${this._handleClick}\n class=\"button ${this.getButtonStyles()}\"\n ?disabled=\"${this.disabled}\"\n >\n <div class=\"container\">\n ${this.iconLeft ? this._iconTemplate(this.iconLeft) : nothing}\n <slot></slot>\n ${this.iconRight ? this._iconTemplate(this.iconRight) : nothing}\n </div>\n </button>`;\n }\n}\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { css, unsafeCSS } from 'lit';
|
|
2
|
+
import { palette } from '../utils/colors';
|
|
3
|
+
import { ScreenSizes } from '../utils/screenSizes.enum';
|
|
4
|
+
export const buttonSizeStyles = css `
|
|
5
|
+
.button {
|
|
6
|
+
font-size: 1.25rem;
|
|
7
|
+
font-weight: 400;
|
|
8
|
+
line-height: 1.5rem;
|
|
9
|
+
}
|
|
10
|
+
@media only screen and (max-width: ${ScreenSizes.TABLET}px) {
|
|
11
|
+
.button {
|
|
12
|
+
font-size: 1rem;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
line-height: 1.25rem;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
@media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
|
|
18
|
+
.button {
|
|
19
|
+
font-size: 0.875rem;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
line-height: 1rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
export const buttonColorStyles = css `
|
|
26
|
+
.button.primary {
|
|
27
|
+
background-color: ${unsafeCSS(palette.main)};
|
|
28
|
+
border: none;
|
|
29
|
+
color: ${unsafeCSS(palette.white)};
|
|
30
|
+
}
|
|
31
|
+
.button.primary:hover {
|
|
32
|
+
background-color: ${unsafeCSS(palette.primary_600)};
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
.button.primary:focus {
|
|
36
|
+
background-color: ${unsafeCSS(palette.primary_600)};
|
|
37
|
+
border: 2px solid ${unsafeCSS(palette.secondary)};
|
|
38
|
+
}
|
|
39
|
+
.button.primary:active {
|
|
40
|
+
background-color: ${unsafeCSS(palette.primary_800)};
|
|
41
|
+
border: none;
|
|
42
|
+
}
|
|
43
|
+
.button.primary:disabled {
|
|
44
|
+
background-color: ${unsafeCSS(palette.primary_100)};
|
|
45
|
+
color: ${unsafeCSS(palette.primary_300)};
|
|
46
|
+
cursor: not-allowed;
|
|
47
|
+
}
|
|
48
|
+
.button.secondary {
|
|
49
|
+
background-color: ${unsafeCSS(palette.white)};
|
|
50
|
+
border: 2px solid ${unsafeCSS(palette.main)};
|
|
51
|
+
color: ${unsafeCSS(palette.main)};
|
|
52
|
+
}
|
|
53
|
+
.button.secondary:hover {
|
|
54
|
+
background-color: ${unsafeCSS(palette.primary_100)};
|
|
55
|
+
border: 2px solid ${unsafeCSS(palette.main)};
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
}
|
|
58
|
+
.button.secondary:focus {
|
|
59
|
+
background-color: ${unsafeCSS(palette.primary_100)};
|
|
60
|
+
border: 2px solid ${unsafeCSS(palette.secondary)};
|
|
61
|
+
}
|
|
62
|
+
.button.secondary:active {
|
|
63
|
+
background-color: ${unsafeCSS(palette.primary_200)};
|
|
64
|
+
border: none;
|
|
65
|
+
color: ${unsafeCSS(palette.main)};
|
|
66
|
+
}
|
|
67
|
+
.button.secondary:disabled {
|
|
68
|
+
background-color: ${unsafeCSS(palette.primary_100)};
|
|
69
|
+
border: none;
|
|
70
|
+
color: ${unsafeCSS(palette.primary_300)};
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
//# sourceMappingURL=TuixButton.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TuixButton.styles.js","sourceRoot":"","sources":["../../../src/tuix-button/TuixButton.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;;;;;;uCAMI,WAAW,CAAC,MAAM;;;;;;;uCAOlB,WAAW,CAAC,MAAM;;;;;;;CAOxD,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;wBAEZ,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;;aAElC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;;;wBAGb,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;;;wBAI9B,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;wBAC9B,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;;;wBAG5B,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;;;wBAI9B,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;aACzC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;;;wBAInB,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;wBACxB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;aAClC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;;;wBAGZ,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;wBAC9B,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;;;;wBAIvB,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;wBAC9B,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;;;wBAG5B,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;aAEzC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;;;wBAGZ,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;aAEzC,SAAS,CAAC,OAAO,CAAC,WAAW,CAAC;;;CAG1C,CAAC","sourcesContent":["import { css, unsafeCSS } from 'lit';\nimport { palette } from '../utils/colors';\nimport { ScreenSizes } from '../utils/screenSizes.enum';\n\nexport const buttonSizeStyles = css`\n .button {\n font-size: 1.25rem;\n font-weight: 400;\n line-height: 1.5rem;\n }\n @media only screen and (max-width: ${ScreenSizes.TABLET}px) {\n .button {\n font-size: 1rem;\n font-weight: 400;\n line-height: 1.25rem;\n }\n }\n @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {\n .button {\n font-size: 0.875rem;\n font-weight: 400;\n line-height: 1rem;\n }\n }\n`;\n\nexport const buttonColorStyles = css`\n .button.primary {\n background-color: ${unsafeCSS(palette.main)};\n border: none;\n color: ${unsafeCSS(palette.white)};\n }\n .button.primary:hover {\n background-color: ${unsafeCSS(palette.primary_600)};\n cursor: pointer;\n }\n .button.primary:focus {\n background-color: ${unsafeCSS(palette.primary_600)};\n border: 2px solid ${unsafeCSS(palette.secondary)};\n }\n .button.primary:active {\n background-color: ${unsafeCSS(palette.primary_800)};\n border: none;\n }\n .button.primary:disabled {\n background-color: ${unsafeCSS(palette.primary_100)};\n color: ${unsafeCSS(palette.primary_300)};\n cursor: not-allowed;\n }\n .button.secondary {\n background-color: ${unsafeCSS(palette.white)};\n border: 2px solid ${unsafeCSS(palette.main)};\n color: ${unsafeCSS(palette.main)};\n }\n .button.secondary:hover {\n background-color: ${unsafeCSS(palette.primary_100)};\n border: 2px solid ${unsafeCSS(palette.main)};\n cursor: pointer;\n }\n .button.secondary:focus {\n background-color: ${unsafeCSS(palette.primary_100)};\n border: 2px solid ${unsafeCSS(palette.secondary)};\n }\n .button.secondary:active {\n background-color: ${unsafeCSS(palette.primary_200)};\n border: none;\n color: ${unsafeCSS(palette.main)};\n }\n .button.secondary:disabled {\n background-color: ${unsafeCSS(palette.primary_100)};\n border: none;\n color: ${unsafeCSS(palette.primary_300)};\n cursor: not-allowed;\n }\n`;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { palette } from '../../utils/colors';
|
|
2
|
+
import { MainVariant } from '../../utils/mainVariant.enum';
|
|
3
|
+
export const buttonTextColor = {
|
|
4
|
+
[MainVariant.PRIMARY]: palette.white,
|
|
5
|
+
[MainVariant.SECONDARY]: palette.main,
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=tuix-button.enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuix-button.enums.js","sourceRoot":"","sources":["../../../../src/tuix-button/enums/tuix-button.enums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,CAAC,MAAM,eAAe,GAAgC;IAC1D,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,KAAK;IACpC,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI;CACtC,CAAC","sourcesContent":["import { palette } from '../../utils/colors';\nimport { MainVariant } from '../../utils/mainVariant.enum';\n\nexport const buttonTextColor: Record<MainVariant, string> = {\n [MainVariant.PRIMARY]: palette.white,\n [MainVariant.SECONDARY]: palette.main,\n};\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { 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: undefined;
|
|
14
|
+
descriptionType: DescriptionType;
|
|
15
|
+
type: DropdownType;
|
|
16
|
+
private _value;
|
|
17
|
+
private _isOptionsVisible;
|
|
18
|
+
private _optionsContainer;
|
|
19
|
+
private _inputDropdown;
|
|
20
|
+
private _previousSelectedOption;
|
|
21
|
+
private _previousFocusedOption;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
disconnectedCallback(): void;
|
|
24
|
+
private _onEnterPress;
|
|
25
|
+
private _onKeyDownOption;
|
|
26
|
+
private _onKeyPressOption;
|
|
27
|
+
private _onMouseOverOption;
|
|
28
|
+
private _onClickOption;
|
|
29
|
+
protected _onInputSingle(e: CustomEvent): void;
|
|
30
|
+
protected _handleSelectEvent(event: MouseEvent | KeyboardEvent): void;
|
|
31
|
+
private _handleInputBase;
|
|
32
|
+
private _handleArrowDown;
|
|
33
|
+
private _handleArrowUp;
|
|
34
|
+
private _handleClickOutside;
|
|
35
|
+
private _focusTargetOption;
|
|
36
|
+
private _toggleOptions;
|
|
37
|
+
private _focusOptionsContainer;
|
|
38
|
+
private _unselectPreviousOption;
|
|
39
|
+
private _getOptionsContainerClasses;
|
|
40
|
+
private _triggerUpdateByExternalValueChange;
|
|
41
|
+
private _resetPreviousSelection;
|
|
42
|
+
private _getOptionsTemplate;
|
|
43
|
+
protected updated(changedProperties: Map<string, any>): void;
|
|
44
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
45
|
+
protected render(): TemplateResult;
|
|
46
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
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.description = undefined;
|
|
19
|
+
this.descriptionType = DescriptionType.TEXT;
|
|
20
|
+
this.type = DropdownType.SINGLE;
|
|
21
|
+
this._value = '';
|
|
22
|
+
this._isOptionsVisible = false;
|
|
23
|
+
this._previousSelectedOption = null;
|
|
24
|
+
this._previousFocusedOption = null;
|
|
25
|
+
this._handleClickOutside = (event) => {
|
|
26
|
+
if (!event.composedPath().includes(this)) {
|
|
27
|
+
this._isOptionsVisible = false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
window.addEventListener('click', this._handleClickOutside);
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
window.removeEventListener('click', this._handleClickOutside);
|
|
37
|
+
super.disconnectedCallback();
|
|
38
|
+
}
|
|
39
|
+
_onEnterPress(event) {
|
|
40
|
+
if (event.key === 'Enter') {
|
|
41
|
+
this._toggleOptions();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
_onKeyDownOption(event) {
|
|
45
|
+
switch (event.key) {
|
|
46
|
+
case 'ArrowDown':
|
|
47
|
+
return this._handleArrowDown();
|
|
48
|
+
case 'ArrowUp':
|
|
49
|
+
return this._handleArrowUp();
|
|
50
|
+
case 'Escape':
|
|
51
|
+
this._isOptionsVisible = false;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_onKeyPressOption(event) {
|
|
56
|
+
if (event.key === 'Enter') {
|
|
57
|
+
this._onClickOption(event);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
_onMouseOverOption(event) {
|
|
61
|
+
const optionTarget = event.target;
|
|
62
|
+
this._focusTargetOption(optionTarget);
|
|
63
|
+
}
|
|
64
|
+
_onClickOption(event) {
|
|
65
|
+
const optionTarget = event.target;
|
|
66
|
+
this._value = optionTarget.innerText;
|
|
67
|
+
this._isOptionsVisible = false;
|
|
68
|
+
this._unselectPreviousOption();
|
|
69
|
+
optionTarget.classList.add('t-option-selected');
|
|
70
|
+
this._previousSelectedOption = optionTarget;
|
|
71
|
+
this._handleSelectEvent(event);
|
|
72
|
+
}
|
|
73
|
+
_onInputSingle(e) {
|
|
74
|
+
this._handleInputBase(e, 'input-single');
|
|
75
|
+
}
|
|
76
|
+
_handleSelectEvent(event) {
|
|
77
|
+
const optionIndex = event.target.getAttribute('data-value');
|
|
78
|
+
const selectedValue = this.options[Number(optionIndex)];
|
|
79
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
80
|
+
detail: {
|
|
81
|
+
value: selectedValue,
|
|
82
|
+
},
|
|
83
|
+
bubbles: true,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
_handleInputBase(e, eventName) {
|
|
87
|
+
var _a;
|
|
88
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
89
|
+
detail: {
|
|
90
|
+
value: (_a = e.detail) === null || _a === void 0 ? void 0 : _a.value,
|
|
91
|
+
},
|
|
92
|
+
bubbles: true,
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
_handleArrowDown() {
|
|
96
|
+
var _a;
|
|
97
|
+
const nextOption = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.nextElementSibling;
|
|
98
|
+
if (nextOption) {
|
|
99
|
+
this._focusTargetOption(nextOption);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_handleArrowUp() {
|
|
103
|
+
var _a;
|
|
104
|
+
const previousOption = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.previousElementSibling;
|
|
105
|
+
if (previousOption) {
|
|
106
|
+
this._focusTargetOption(previousOption);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
_focusTargetOption(targetOption) {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
(_b = (_a = this._previousFocusedOption) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('t-option-hover');
|
|
112
|
+
targetOption === null || targetOption === void 0 ? void 0 : targetOption.classList.add('t-option-hover');
|
|
113
|
+
targetOption === null || targetOption === void 0 ? void 0 : targetOption.focus();
|
|
114
|
+
this._previousFocusedOption = targetOption;
|
|
115
|
+
}
|
|
116
|
+
_toggleOptions() {
|
|
117
|
+
if (this.disabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this._isOptionsVisible = !this._isOptionsVisible;
|
|
121
|
+
}
|
|
122
|
+
_focusOptionsContainer() {
|
|
123
|
+
var _a, _b, _c;
|
|
124
|
+
if (!this._isOptionsVisible || !this._optionsContainer) {
|
|
125
|
+
(_c = (_b = (_a = this._inputDropdown) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('input')) === null || _c === void 0 ? void 0 : _c.focus();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this._previousSelectedOption) {
|
|
129
|
+
this._focusTargetOption(this._previousSelectedOption);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const firstOption = this._optionsContainer
|
|
133
|
+
.firstElementChild;
|
|
134
|
+
if (firstOption) {
|
|
135
|
+
this._focusTargetOption(firstOption);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_unselectPreviousOption() {
|
|
140
|
+
var _a;
|
|
141
|
+
if (this._previousSelectedOption) {
|
|
142
|
+
(_a = this._previousSelectedOption.classList) === null || _a === void 0 ? void 0 : _a.remove('t-option-selected');
|
|
143
|
+
this._previousSelectedOption = null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
_getOptionsContainerClasses() {
|
|
147
|
+
return {
|
|
148
|
+
't-options-container': true,
|
|
149
|
+
show: this._isOptionsVisible,
|
|
150
|
+
't-with-description': !!this.descriptionType,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
_triggerUpdateByExternalValueChange() {
|
|
154
|
+
var _a;
|
|
155
|
+
this._unselectPreviousOption();
|
|
156
|
+
if (!this.value) {
|
|
157
|
+
this._value = '';
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const index = this.options.indexOf(this.value);
|
|
161
|
+
const optionTarget = (_a = this._optionsContainer) === null || _a === void 0 ? void 0 : _a.children[index];
|
|
162
|
+
optionTarget === null || optionTarget === void 0 ? void 0 : optionTarget.classList.add('t-option-selected');
|
|
163
|
+
this._previousSelectedOption = optionTarget || null;
|
|
164
|
+
this._value = optionTarget ? String(this.value) : '';
|
|
165
|
+
}
|
|
166
|
+
_resetPreviousSelection() {
|
|
167
|
+
this._value = '';
|
|
168
|
+
this._unselectPreviousOption();
|
|
169
|
+
}
|
|
170
|
+
_getOptionsTemplate() {
|
|
171
|
+
var _a;
|
|
172
|
+
return (_a = this.options) === null || _a === void 0 ? void 0 : _a.map((option, index) => {
|
|
173
|
+
return html `<div
|
|
174
|
+
class="t-dropdown-option"
|
|
175
|
+
@click="${this._onClickOption}"
|
|
176
|
+
data-value="${index}"
|
|
177
|
+
tabindex="0"
|
|
178
|
+
@keydown="${this._onKeyDownOption}"
|
|
179
|
+
@keypress="${this._onKeyPressOption}"
|
|
180
|
+
@mouseover="${this._onMouseOverOption}"
|
|
181
|
+
>
|
|
182
|
+
${option}
|
|
183
|
+
</div>`;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
updated(changedProperties) {
|
|
187
|
+
if (changedProperties.has('_isOptionsVisible')) {
|
|
188
|
+
this._focusOptionsContainer();
|
|
189
|
+
}
|
|
190
|
+
else if (changedProperties.has('value')) {
|
|
191
|
+
this._triggerUpdateByExternalValueChange();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
willUpdate(changedProperties) {
|
|
195
|
+
if (changedProperties.has('options')) {
|
|
196
|
+
this._resetPreviousSelection();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
render() {
|
|
200
|
+
return html `<div class="t-dropdown-full-container">
|
|
201
|
+
<div class="t-dropdown-container">
|
|
202
|
+
<tuix-input
|
|
203
|
+
.value="${this._value}"
|
|
204
|
+
class="t-input-dropdown"
|
|
205
|
+
iconRight="${this._isOptionsVisible
|
|
206
|
+
? IconName.CHEVRON_UP
|
|
207
|
+
: IconName.CHEVRON_DOWN}"
|
|
208
|
+
placeholder="${this.placeholder}"
|
|
209
|
+
title="${this.title}"
|
|
210
|
+
.description="${this.description}"
|
|
211
|
+
descriptionType="${this.descriptionType}"
|
|
212
|
+
?disabled="${this.disabled}"
|
|
213
|
+
?dark="${this.dark}"
|
|
214
|
+
?readonly="${this.type !== DropdownType.SEARCH}"
|
|
215
|
+
@click="${this._toggleOptions}"
|
|
216
|
+
@keypress="${this._onEnterPress}"
|
|
217
|
+
@input-single="${this._onInputSingle}"
|
|
218
|
+
>
|
|
219
|
+
</tuix-input>
|
|
220
|
+
</div>
|
|
221
|
+
<div class="${classMap(this._getOptionsContainerClasses())}">
|
|
222
|
+
${this._getOptionsTemplate()}
|
|
223
|
+
</div>
|
|
224
|
+
</div>`;
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
TuixDropdown.styles = [
|
|
228
|
+
dropdownHostStyles,
|
|
229
|
+
dropdownMainContainerStyles,
|
|
230
|
+
dropdownOptionStyles,
|
|
231
|
+
];
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ type: Object, reflect: true })
|
|
234
|
+
], TuixDropdown.prototype, "value", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ type: Array })
|
|
237
|
+
], TuixDropdown.prototype, "options", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: String })
|
|
240
|
+
], TuixDropdown.prototype, "placeholder", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: String })
|
|
243
|
+
], TuixDropdown.prototype, "title", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({ type: Boolean })
|
|
246
|
+
], TuixDropdown.prototype, "disabled", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property({ type: Boolean })
|
|
249
|
+
], TuixDropdown.prototype, "dark", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property({ type: String })
|
|
252
|
+
], TuixDropdown.prototype, "description", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
property({ type: DescriptionType })
|
|
255
|
+
], TuixDropdown.prototype, "descriptionType", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
property({ type: String })
|
|
258
|
+
], TuixDropdown.prototype, "type", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
state()
|
|
261
|
+
], TuixDropdown.prototype, "_value", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
state()
|
|
264
|
+
], TuixDropdown.prototype, "_isOptionsVisible", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
query('.t-options-container')
|
|
267
|
+
], TuixDropdown.prototype, "_optionsContainer", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
query('.t-dropdown-container .t-input-dropdown')
|
|
270
|
+
], TuixDropdown.prototype, "_inputDropdown", void 0);
|
|
271
|
+
TuixDropdown = __decorate([
|
|
272
|
+
customElement('tuix-dropdown')
|
|
273
|
+
], TuixDropdown);
|
|
274
|
+
export { TuixDropdown };
|
|
275
|
+
//# sourceMappingURL=TuixDropdown.js.map
|