tuix-webcomponents 0.0.21 → 0.0.24

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 (116) hide show
  1. package/README.md +110 -4
  2. package/dist/assets/tuix-styles.css +72 -0
  3. package/dist/src/index.d.ts +34 -1
  4. package/dist/src/index.js +26 -16
  5. package/dist/src/react/index.d.ts +42 -0
  6. package/dist/src/react/index.js +114 -0
  7. package/dist/src/tuix-button/TuixBaseButton.d.ts +17 -0
  8. package/dist/src/tuix-button/TuixBaseButton.js +60 -0
  9. package/dist/src/tuix-button/TuixButton.d.ts +11 -0
  10. package/dist/src/tuix-button/TuixButton.js +84 -0
  11. package/dist/src/tuix-button/TuixButton.styles.d.ts +3 -0
  12. package/dist/src/tuix-button/TuixButton.styles.js +107 -0
  13. package/dist/src/tuix-button/enums/tuix-button.enums.d.ts +2 -0
  14. package/dist/src/tuix-button/enums/tuix-button.enums.js +6 -0
  15. package/dist/src/tuix-button/interfaces/tuix-button.interface.d.ts +1 -0
  16. package/dist/src/tuix-button/interfaces/tuix-button.interface.js +1 -0
  17. package/dist/src/tuix-checkbox/TuixCheckbox.d.ts +17 -0
  18. package/dist/src/tuix-checkbox/TuixCheckbox.js +108 -0
  19. package/dist/src/tuix-checkbox/TuixCheckbox.styles.d.ts +4 -0
  20. package/dist/src/tuix-checkbox/TuixCheckbox.styles.js +132 -0
  21. package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.d.ts +21 -0
  22. package/dist/src/tuix-checkbox/enums/tuix-checkbox.enums.js +23 -0
  23. package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.d.ts +5 -0
  24. package/dist/src/tuix-checkbox/interfaces/tuix-checkbox.interface.js +1 -0
  25. package/dist/src/tuix-dropdown/TuixDropdown.d.ts +56 -0
  26. package/dist/src/tuix-dropdown/TuixDropdown.js +361 -0
  27. package/dist/src/tuix-dropdown/TuixDropdown.styles.d.ts +3 -0
  28. package/dist/src/tuix-dropdown/TuixDropdown.styles.js +125 -0
  29. package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.d.ts +4 -0
  30. package/dist/src/tuix-dropdown/enums/tuix-dropdown.enums.js +5 -0
  31. package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.d.ts +15 -0
  32. package/dist/src/tuix-dropdown/interfaces/tuix-dropdown.interface.js +1 -0
  33. package/dist/src/tuix-icon/TuixIcon.d.ts +15 -0
  34. package/dist/src/tuix-icon/TuixIcon.icons.d.ts +6 -0
  35. package/dist/src/tuix-icon/TuixIcon.icons.js +395 -0
  36. package/dist/src/tuix-icon/TuixIcon.js +79 -0
  37. package/dist/src/tuix-icon/enums/tuix-icon.enums.d.ts +89 -0
  38. package/dist/src/tuix-icon/enums/tuix-icon.enums.js +96 -0
  39. package/dist/src/tuix-icon-button/TuixIconButton.d.ts +9 -0
  40. package/dist/src/tuix-icon-button/TuixIconButton.js +51 -0
  41. package/dist/src/tuix-input/TuixInput.d.ts +52 -0
  42. package/dist/src/tuix-input/TuixInput.js +374 -0
  43. package/dist/src/tuix-input/TuixInput.styles.d.ts +8 -0
  44. package/dist/src/tuix-input/TuixInput.styles.js +296 -0
  45. package/dist/src/tuix-input/enums/tuix-input.enums.d.ts +38 -0
  46. package/dist/src/tuix-input/enums/tuix-input.enums.js +41 -0
  47. package/dist/src/tuix-input/interfaces/tuix-input.interface.d.ts +18 -0
  48. package/dist/src/tuix-input/interfaces/tuix-input.interface.js +5 -0
  49. package/dist/src/tuix-link/TuixLink.d.ts +15 -0
  50. package/dist/src/tuix-link/TuixLink.js +71 -0
  51. package/dist/src/tuix-link/TuixLink.styles.d.ts +2 -0
  52. package/dist/src/tuix-link/TuixLink.styles.js +55 -0
  53. package/dist/src/tuix-link/enums/linkTarget.enum.d.ts +6 -0
  54. package/dist/src/tuix-link/enums/linkTarget.enum.js +7 -0
  55. package/dist/src/tuix-modal/TuixModal.d.ts +11 -0
  56. package/dist/src/tuix-modal/TuixModal.js +65 -0
  57. package/dist/src/tuix-modal/TuixModal.styles.d.ts +2 -0
  58. package/dist/src/tuix-modal/TuixModal.styles.js +55 -0
  59. package/dist/src/tuix-paper/TuixPaper.d.ts +10 -0
  60. package/dist/src/tuix-paper/TuixPaper.js +46 -0
  61. package/dist/src/tuix-paper/TuixPaper.styles.d.ts +1 -0
  62. package/dist/src/tuix-paper/TuixPaper.styles.js +30 -0
  63. package/dist/src/tuix-paper/enums/tuix-paper.enum.d.ts +13 -0
  64. package/dist/src/tuix-paper/enums/tuix-paper.enum.js +15 -0
  65. package/dist/src/tuix-radio-button/TuixRadioButton.d.ts +17 -0
  66. package/dist/src/tuix-radio-button/TuixRadioButton.js +96 -0
  67. package/dist/src/tuix-radio-button/TuixRadioButton.styles.d.ts +5 -0
  68. package/dist/src/tuix-radio-button/TuixRadioButton.styles.js +135 -0
  69. package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.d.ts +3 -0
  70. package/dist/src/tuix-radio-button/interfaces/tuix-radio-button.interface.js +1 -0
  71. package/dist/src/tuix-table/TuixTable.d.ts +48 -0
  72. package/dist/src/tuix-table/TuixTable.js +369 -0
  73. package/dist/src/tuix-table/TuixTable.styles.d.ts +2 -0
  74. package/dist/src/tuix-table/TuixTable.styles.js +197 -0
  75. package/dist/src/tuix-table/interfaces/tuix-table.interface.d.ts +45 -0
  76. package/dist/src/tuix-table/interfaces/tuix-table.interface.js +1 -0
  77. package/dist/src/tuix-text/TuixText.d.ts +7 -5
  78. package/dist/src/tuix-text/TuixText.js +45 -137
  79. package/dist/src/tuix-text/TuixText.styles.d.ts +2 -0
  80. package/dist/src/tuix-text/TuixText.styles.js +195 -0
  81. package/dist/src/tuix-text/enums/tuix-text.enums.d.ts +36 -0
  82. package/dist/src/tuix-text/enums/tuix-text.enums.js +72 -0
  83. package/dist/src/tuix-toast/TuixToast.d.ts +18 -0
  84. package/dist/src/tuix-toast/TuixToast.js +103 -0
  85. package/dist/src/tuix-toast/TuixToast.styles.d.ts +3 -0
  86. package/dist/src/tuix-toast/TuixToast.styles.js +43 -0
  87. package/dist/src/tuix-toast/enums/tuix-toast.enums.d.ts +20 -0
  88. package/dist/src/tuix-toast/enums/tuix-toast.enums.js +59 -0
  89. package/dist/src/tuix-toggle-button/TuixToggleButton.d.ts +14 -0
  90. package/dist/src/tuix-toggle-button/TuixToggleButton.js +86 -0
  91. package/dist/src/tuix-toggle-button/TuixToggleButton.styles.d.ts +5 -0
  92. package/dist/src/tuix-toggle-button/TuixToggleButton.styles.js +134 -0
  93. package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.d.ts +2 -0
  94. package/dist/src/tuix-toggle-button/interfaces/tuix-toggle.interface.js +1 -0
  95. package/dist/src/utils/colors.d.ts +30 -10
  96. package/dist/src/utils/colors.js +31 -11
  97. package/dist/src/utils/darkColors.d.ts +32 -0
  98. package/dist/src/utils/darkColors.js +33 -0
  99. package/dist/src/utils/hex-rgb.d.ts +5 -0
  100. package/dist/src/utils/hex-rgb.js +15 -0
  101. package/dist/src/utils/interfaces/detail-value.interface.d.ts +3 -0
  102. package/dist/src/utils/interfaces/detail-value.interface.js +1 -0
  103. package/dist/src/utils/mainVariant.enum.d.ts +4 -0
  104. package/dist/src/utils/mainVariant.enum.js +5 -0
  105. package/dist/src/utils/screenSizes.enum.d.ts +4 -0
  106. package/dist/src/utils/screenSizes.enum.js +5 -0
  107. package/dist/src/utils/slottedClassName.d.ts +2 -0
  108. package/dist/src/utils/slottedClassName.js +1 -0
  109. package/package.json +118 -66
  110. package/dist/src/enums/tuix-text.enums.d.ts +0 -24
  111. package/dist/src/enums/tuix-text.enums.js +0 -29
  112. package/dist/src/enums/tuix-text.enums.js.map +0 -1
  113. package/dist/src/index.js.map +0 -1
  114. package/dist/src/tuix-text/TuixText.js.map +0 -1
  115. package/dist/src/utils/colors.js.map +0 -1
  116. package/dist/tsconfig.publish.tsbuildinfo +0 -1
@@ -0,0 +1,89 @@
1
+ export declare enum IconSizeVariant {
2
+ SMALL = "small",
3
+ MEDIUM = "medium",
4
+ LARGE = "large",
5
+ FULL = "full"
6
+ }
7
+ export declare const iconSize: Record<IconSizeVariant, string>;
8
+ export declare enum IconName {
9
+ ARROW_DOWN = "arrow-down",
10
+ ARROW_LEFT = "arrow-left",
11
+ ARROW_UP = "arrow-up",
12
+ ARROW_RIGHT = "arrow-right",
13
+ SEARCH = "search",
14
+ EYE_ON = "eye-on",
15
+ EYE_OFF = "eye-off",
16
+ EYE_CLOSE_LINE = "eye-close-line",
17
+ TRIANGLE_EXCLAMATION = "triangle-exclamation",
18
+ CIRCLE_X = "circle-x",
19
+ LOADER = "loader",
20
+ LOADER_CIRCLE = "loader-circle",
21
+ CIRCLE_CHECK = "circle-check",
22
+ CHEVRON_DOWN = "chevron-down",
23
+ CHEVRON_UP = "chevron-up",
24
+ CHEVRON_LEFT = "chevron-left",
25
+ CHEVRON_RIGHT = "chevron-right",
26
+ CHECK = "check",
27
+ NAV_HAMBURGUER = "nav-hamburguer",
28
+ SUN = "sun",
29
+ MOON = "moon",
30
+ BOOKMARK = "bookmark",
31
+ UPLOAD = "upload",
32
+ DOWNLOAD = "download",
33
+ MAP_PIN = "map-pin",
34
+ PHONE = "phone",
35
+ MAIL = "mail",
36
+ MAILS = "mails",
37
+ LAYERS = "layers",
38
+ SEND = "send",
39
+ FILE = "file",
40
+ FORMAT_LIST = "format-list",
41
+ SAVE = "save",
42
+ SQUARE_CODE = "square-code",
43
+ BRACES = "braces",
44
+ ADD_MAIL = "add-mail",
45
+ MAIL_LOGO = "mail-logo",
46
+ BUILDING = "building",
47
+ CODE = "code",
48
+ USER_PLUS = "user-plus",
49
+ FACEBOOK = "facebook",
50
+ TWITTER = "twitter",
51
+ LINKEDIN = "linkedin",
52
+ SHARE = "share",
53
+ COPY = "copy",
54
+ GOOGLE = "google",
55
+ BELL = "bell",
56
+ GEAR = "gear",
57
+ LOGOUT = "logout",
58
+ CIRCLE_EXCLAMATION = "circle-exclamation",
59
+ CAMERA = "camera",
60
+ PENCIL = "pencil",
61
+ X = "x",
62
+ PLUS = "plus",
63
+ INVOICE = "invoice",
64
+ DELETE = "delete",
65
+ TRIANGLE_ARROW_DOWN = "triangle-arrow-down",
66
+ USERS = "users",
67
+ CLOCK = "clock",
68
+ CHECK_CLOCK = "check-clock",
69
+ GLOBE = "globe",
70
+ CALENDAR = "calendar",
71
+ STATS = "stats",
72
+ HOLIDAYS = "holidays",
73
+ TRENDING_UP = "trending-up",
74
+ ARCHIVE = "archive",
75
+ ACCESS_TOKEN = "access-token",
76
+ RESIZE = "resize",
77
+ CHAT = "chat",
78
+ MESSAGE_CIRCLE = "message-circle",
79
+ BOOK = "book",
80
+ MORE_HORIZONTAL = "more-horizontal",
81
+ BOT = "bot",
82
+ SCROLL_DOWN = "scroll-down",
83
+ PLAY = "play",
84
+ EXTERNAL_LINK = "external-link",
85
+ TRIANGLE_RIGHT = "triangle-right",
86
+ FILE_PLUS = "file-plus",
87
+ FILE_TEXT = "file-text",
88
+ HIGHLIGHT = "highlight"
89
+ }
@@ -0,0 +1,96 @@
1
+ export var IconSizeVariant;
2
+ (function (IconSizeVariant) {
3
+ IconSizeVariant["SMALL"] = "small";
4
+ IconSizeVariant["MEDIUM"] = "medium";
5
+ IconSizeVariant["LARGE"] = "large";
6
+ IconSizeVariant["FULL"] = "full";
7
+ })(IconSizeVariant || (IconSizeVariant = {}));
8
+ export const iconSize = {
9
+ [IconSizeVariant.SMALL]: '16px',
10
+ [IconSizeVariant.MEDIUM]: '24px',
11
+ [IconSizeVariant.LARGE]: '32px',
12
+ [IconSizeVariant.FULL]: '100%',
13
+ };
14
+ export var IconName;
15
+ (function (IconName) {
16
+ IconName["ARROW_DOWN"] = "arrow-down";
17
+ IconName["ARROW_LEFT"] = "arrow-left";
18
+ IconName["ARROW_UP"] = "arrow-up";
19
+ IconName["ARROW_RIGHT"] = "arrow-right";
20
+ IconName["SEARCH"] = "search";
21
+ IconName["EYE_ON"] = "eye-on";
22
+ IconName["EYE_OFF"] = "eye-off";
23
+ IconName["EYE_CLOSE_LINE"] = "eye-close-line";
24
+ IconName["TRIANGLE_EXCLAMATION"] = "triangle-exclamation";
25
+ IconName["CIRCLE_X"] = "circle-x";
26
+ IconName["LOADER"] = "loader";
27
+ IconName["LOADER_CIRCLE"] = "loader-circle";
28
+ IconName["CIRCLE_CHECK"] = "circle-check";
29
+ IconName["CHEVRON_DOWN"] = "chevron-down";
30
+ IconName["CHEVRON_UP"] = "chevron-up";
31
+ IconName["CHEVRON_LEFT"] = "chevron-left";
32
+ IconName["CHEVRON_RIGHT"] = "chevron-right";
33
+ IconName["CHECK"] = "check";
34
+ IconName["NAV_HAMBURGUER"] = "nav-hamburguer";
35
+ IconName["SUN"] = "sun";
36
+ IconName["MOON"] = "moon";
37
+ IconName["BOOKMARK"] = "bookmark";
38
+ IconName["UPLOAD"] = "upload";
39
+ IconName["DOWNLOAD"] = "download";
40
+ IconName["MAP_PIN"] = "map-pin";
41
+ IconName["PHONE"] = "phone";
42
+ IconName["MAIL"] = "mail";
43
+ IconName["MAILS"] = "mails";
44
+ IconName["LAYERS"] = "layers";
45
+ IconName["SEND"] = "send";
46
+ IconName["FILE"] = "file";
47
+ IconName["FORMAT_LIST"] = "format-list";
48
+ IconName["SAVE"] = "save";
49
+ IconName["SQUARE_CODE"] = "square-code";
50
+ IconName["BRACES"] = "braces";
51
+ IconName["ADD_MAIL"] = "add-mail";
52
+ IconName["MAIL_LOGO"] = "mail-logo";
53
+ IconName["BUILDING"] = "building";
54
+ IconName["CODE"] = "code";
55
+ IconName["USER_PLUS"] = "user-plus";
56
+ IconName["FACEBOOK"] = "facebook";
57
+ IconName["TWITTER"] = "twitter";
58
+ IconName["LINKEDIN"] = "linkedin";
59
+ IconName["SHARE"] = "share";
60
+ IconName["COPY"] = "copy";
61
+ IconName["GOOGLE"] = "google";
62
+ IconName["BELL"] = "bell";
63
+ IconName["GEAR"] = "gear";
64
+ IconName["LOGOUT"] = "logout";
65
+ IconName["CIRCLE_EXCLAMATION"] = "circle-exclamation";
66
+ IconName["CAMERA"] = "camera";
67
+ IconName["PENCIL"] = "pencil";
68
+ IconName["X"] = "x";
69
+ IconName["PLUS"] = "plus";
70
+ IconName["INVOICE"] = "invoice";
71
+ IconName["DELETE"] = "delete";
72
+ IconName["TRIANGLE_ARROW_DOWN"] = "triangle-arrow-down";
73
+ IconName["USERS"] = "users";
74
+ IconName["CLOCK"] = "clock";
75
+ IconName["CHECK_CLOCK"] = "check-clock";
76
+ IconName["GLOBE"] = "globe";
77
+ IconName["CALENDAR"] = "calendar";
78
+ IconName["STATS"] = "stats";
79
+ IconName["HOLIDAYS"] = "holidays";
80
+ IconName["TRENDING_UP"] = "trending-up";
81
+ IconName["ARCHIVE"] = "archive";
82
+ IconName["ACCESS_TOKEN"] = "access-token";
83
+ IconName["RESIZE"] = "resize";
84
+ IconName["CHAT"] = "chat";
85
+ IconName["MESSAGE_CIRCLE"] = "message-circle";
86
+ IconName["BOOK"] = "book";
87
+ IconName["MORE_HORIZONTAL"] = "more-horizontal";
88
+ IconName["BOT"] = "bot";
89
+ IconName["SCROLL_DOWN"] = "scroll-down";
90
+ IconName["PLAY"] = "play";
91
+ IconName["EXTERNAL_LINK"] = "external-link";
92
+ IconName["TRIANGLE_RIGHT"] = "triangle-right";
93
+ IconName["FILE_PLUS"] = "file-plus";
94
+ IconName["FILE_TEXT"] = "file-text";
95
+ IconName["HIGHLIGHT"] = "highlight";
96
+ })(IconName || (IconName = {}));
@@ -0,0 +1,9 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
3
+ import { TuixBaseButton } from '../tuix-button/TuixBaseButton.js';
4
+ export declare class TuixIconButton extends TuixBaseButton {
5
+ static styles: import("lit").CSSResult[];
6
+ icon: IconName;
7
+ protected _updateIconColor(): void;
8
+ protected _buttonContent(): TemplateResult;
9
+ }
@@ -0,0 +1,51 @@
1
+ import { __decorate } from "tslib";
2
+ import { css, html } from 'lit';
3
+ import { IconName, IconSizeVariant } from '../tuix-icon/enums/tuix-icon.enums.js';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { ScreenSizes } from '../utils/screenSizes.enum.js';
6
+ import { buttonColorStyles, hostButtonStyles, } from '../tuix-button/TuixButton.styles.js';
7
+ import { TuixBaseButton } from '../tuix-button/TuixBaseButton.js';
8
+ let TuixIconButton = class TuixIconButton extends TuixBaseButton {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.icon = IconName.ARROW_DOWN;
12
+ }
13
+ static { this.styles = [
14
+ css `
15
+ .button {
16
+ padding: 16px;
17
+ border-radius: 4px;
18
+ border: none;
19
+ }
20
+
21
+ @media only screen and (max-width: ${ScreenSizes.TABLET}px) {
22
+ .button {
23
+ padding: 12px;
24
+ }
25
+ }
26
+
27
+ @media only screen and (max-width: ${ScreenSizes.MOBILE}px) {
28
+ .button {
29
+ padding: 8px;
30
+ }
31
+ }
32
+ `,
33
+ hostButtonStyles,
34
+ buttonColorStyles,
35
+ ]; }
36
+ _updateIconColor() {
37
+ if (!this.icon)
38
+ return;
39
+ this.iconColor = this._getTextColor();
40
+ }
41
+ _buttonContent() {
42
+ return html `${this._iconTemplate(this.icon, IconSizeVariant.MEDIUM)}`;
43
+ }
44
+ };
45
+ __decorate([
46
+ property({ type: IconName })
47
+ ], TuixIconButton.prototype, "icon", void 0);
48
+ TuixIconButton = __decorate([
49
+ customElement('tuix-icon-button')
50
+ ], TuixIconButton);
51
+ export { TuixIconButton };
@@ -0,0 +1,52 @@
1
+ import { LitElement, type TemplateResult, CSSResult, type PropertyValueMap } from 'lit';
2
+ import '../tuix-icon/TuixIcon.js';
3
+ import { IconName } from '../tuix-icon/enums/tuix-icon.enums.js';
4
+ import { DescriptionType, InputType } from './enums/tuix-input.enums.js';
5
+ export declare class TuixInput extends LitElement {
6
+ _inputId: string;
7
+ static styles: CSSResult[];
8
+ disabled: boolean;
9
+ iconRight?: IconName;
10
+ value: string;
11
+ placeholder: string;
12
+ title: string;
13
+ type: InputType;
14
+ maxlength?: number;
15
+ description?: string;
16
+ descriptionType: DescriptionType;
17
+ dark: boolean;
18
+ readonly: boolean;
19
+ autofocus: boolean;
20
+ private _inputElement;
21
+ private _type;
22
+ private _letterCounter;
23
+ private _previousType;
24
+ private _previousValue;
25
+ private _generalIconColorsLight;
26
+ private _generalIconColorsDark;
27
+ private _handleInputBase;
28
+ private _handleClickOnInput;
29
+ private _handleInput;
30
+ private _handleBlur;
31
+ private _handlePasswordIconClick;
32
+ private _formatIconSet;
33
+ private _updateLetterCounter;
34
+ private _getInputTextFeatureTemplate;
35
+ private _getInputSearchFeatureTemplate;
36
+ private _getInputPasswordFeatureTemplate;
37
+ private _getFeatureTemplateByInputType;
38
+ private _getInputElementClasses;
39
+ private _getInputContainerClasses;
40
+ private _getMainContainerClasses;
41
+ private _setIdInput;
42
+ private _getInputTemplate;
43
+ private _getLetterCounterTemplate;
44
+ private _hasLetterCounter;
45
+ private _getTextAreaTemplate;
46
+ private _getIconDescriptionTemplate;
47
+ private _getDescriptionTemplate;
48
+ private _hasValidDescriptionType;
49
+ private _getDescriptionContainerTemplate;
50
+ protected render(): TemplateResult;
51
+ protected updated(changedProperties: PropertyValueMap<unknown>): void;
52
+ }
@@ -0,0 +1,374 @@
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.js';
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
+ import { InputState, } from './interfaces/tuix-input.interface.js';
12
+ import { v4 as uuidv4 } from 'uuid';
13
+ let TuixInput = class TuixInput extends LitElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ this._inputId = this._setIdInput();
17
+ this.disabled = false;
18
+ this.value = '';
19
+ this.placeholder = '';
20
+ this.title = '';
21
+ this.type = InputType.TEXT;
22
+ this.descriptionType = DescriptionType.TEXT;
23
+ this.dark = false;
24
+ this.readonly = false;
25
+ this.autofocus = false;
26
+ this._type = this.type;
27
+ this._letterCounter = this.value?.length || 0;
28
+ this._previousType = this.type;
29
+ this._previousValue = '';
30
+ this._generalIconColorsLight = {
31
+ [InputState.INACTIVE]: Palette.BLACK,
32
+ [InputState.ACTIVE]: Palette.MAIN,
33
+ [InputState.DISABLED]: Palette.PRIMARY_300,
34
+ };
35
+ this._generalIconColorsDark = {
36
+ [InputState.INACTIVE]: DarkPalette.PRIMARY_100,
37
+ [InputState.ACTIVE]: DarkPalette.MAIN,
38
+ [InputState.DISABLED]: DarkPalette.PRIMARY_800,
39
+ };
40
+ }
41
+ static { this.styles = [
42
+ hostStyles,
43
+ inputComponentStyles,
44
+ inputFontStyles,
45
+ inputColorStyles,
46
+ inputTitleStyles,
47
+ inputIconStyles,
48
+ inputSearchStyles,
49
+ inputDescriptionStyles,
50
+ ]; }
51
+ _handleInputBase(e, eventName) {
52
+ this.dispatchEvent(new CustomEvent(eventName, {
53
+ detail: {
54
+ // The listener is on the input itself, so the target is always one
55
+ // of the two; the fallback keeps the detail a string, which is what
56
+ // `CustomEventTuixInput` promises, rather than `false`.
57
+ value: e.target instanceof HTMLInputElement ||
58
+ e.target instanceof HTMLTextAreaElement
59
+ ? e.target.value
60
+ : '',
61
+ },
62
+ bubbles: true,
63
+ }));
64
+ }
65
+ _handleClickOnInput() {
66
+ if (this.disabled)
67
+ return;
68
+ this.dispatchEvent(new CustomEvent('on-click', {
69
+ bubbles: true,
70
+ }));
71
+ }
72
+ _handleInput(e) {
73
+ this._handleInputBase(e, 'on-change');
74
+ this._updateLetterCounter();
75
+ }
76
+ _handleBlur(e) {
77
+ this._handleInputBase(e, 'on-blur');
78
+ }
79
+ _handlePasswordIconClick() {
80
+ if (this._type === InputType.PASSWORD) {
81
+ this._type = InputType.TEXT;
82
+ this._inputElement.setAttribute('type', InputType.TEXT);
83
+ }
84
+ else {
85
+ this._type = InputType.PASSWORD;
86
+ this._inputElement.setAttribute('type', InputType.PASSWORD);
87
+ }
88
+ }
89
+ _formatIconSet({ iconName, colorByState, location = InputIconLocation.RIGHT, clickHandler = undefined, }) {
90
+ const iconSetContainerClasses = {
91
+ 't-icon-set-container': true,
92
+ 't-icon-click': !!clickHandler,
93
+ [`t-icon-${location}`]: true,
94
+ };
95
+ return html `<div
96
+ class="${classMap(iconSetContainerClasses)}"
97
+ @click="${clickHandler}"
98
+ >
99
+ ${Object.entries(colorByState).map(([state, color]) => html `<tuix-icon
100
+ size="${IconSizeVariant.FULL}"
101
+ name="${iconName}"
102
+ color="${color}"
103
+ class="t-icon-${state}"
104
+ ></tuix-icon>`)}
105
+ </div>`;
106
+ }
107
+ _updateLetterCounter() {
108
+ if (this.maxlength != undefined && this.type === InputType.TEXT_AREA) {
109
+ this._letterCounter = Number(this._inputElement.value?.length);
110
+ }
111
+ }
112
+ _getInputTextFeatureTemplate() {
113
+ return html `${this.iconRight
114
+ ? this._formatIconSet({
115
+ iconName: this.iconRight,
116
+ colorByState: this.dark
117
+ ? this._generalIconColorsDark
118
+ : this._generalIconColorsLight,
119
+ })
120
+ : nothing}`;
121
+ }
122
+ _getInputSearchFeatureTemplate() {
123
+ const searchIconColorsLight = {
124
+ [InputState.INACTIVE]: Palette.BLACK,
125
+ [InputState.ACTIVE]: Palette.BLACK,
126
+ [InputState.DISABLED]: Palette.PRIMARY_300,
127
+ };
128
+ const searchIconColorsDark = {
129
+ [InputState.INACTIVE]: DarkPalette.PRIMARY_100,
130
+ [InputState.ACTIVE]: DarkPalette.PRIMARY_100,
131
+ [InputState.DISABLED]: DarkPalette.PRIMARY_800,
132
+ };
133
+ return html `${this._formatIconSet({
134
+ iconName: IconName.SEARCH,
135
+ colorByState: this.dark ? searchIconColorsDark : searchIconColorsLight,
136
+ location: InputIconLocation.LEFT,
137
+ })}`;
138
+ }
139
+ _getInputPasswordFeatureTemplate() {
140
+ return html `${this._formatIconSet({
141
+ iconName: this._type === InputType.PASSWORD
142
+ ? IconName.EYE_CLOSE_LINE
143
+ : IconName.EYE_ON,
144
+ colorByState: this.dark
145
+ ? this._generalIconColorsDark
146
+ : this._generalIconColorsLight,
147
+ clickHandler: this._handlePasswordIconClick,
148
+ })} `;
149
+ }
150
+ _getFeatureTemplateByInputType() {
151
+ switch (this.type) {
152
+ case InputType.SEARCH:
153
+ return this._getInputSearchFeatureTemplate();
154
+ case InputType.TEXT:
155
+ return this._getInputTextFeatureTemplate();
156
+ case InputType.PASSWORD:
157
+ return this._getInputPasswordFeatureTemplate();
158
+ default:
159
+ return html `${nothing}`;
160
+ }
161
+ }
162
+ _getInputElementClasses() {
163
+ const hasIconRight = this.type === InputType.PASSWORD || this.type === InputType.TEXT
164
+ ? !!this.iconRight
165
+ : false;
166
+ return {
167
+ 't-input': true,
168
+ 't-textarea': this.type === InputType.TEXT_AREA,
169
+ 'with-title': !!this.title,
170
+ 'with-icon-right': hasIconRight,
171
+ [`with-${this.descriptionType}`]: this.descriptionType !== DescriptionType.TEXT,
172
+ };
173
+ }
174
+ _getInputContainerClasses() {
175
+ return {
176
+ 't-input-container': true,
177
+ 't-textarea-container': this.type === InputType.TEXT_AREA,
178
+ };
179
+ }
180
+ _getMainContainerClasses() {
181
+ return {
182
+ 't-textarea-main-container': this.type === InputType.TEXT_AREA,
183
+ };
184
+ }
185
+ _setIdInput() {
186
+ return uuidv4();
187
+ }
188
+ _getInputTemplate() {
189
+ return html `<input
190
+ id=${this._inputId}
191
+ type="text"
192
+ class="${classMap(this._getInputElementClasses())}"
193
+ ?disabled="${this.disabled}"
194
+ ?readonly="${this.readonly}"
195
+ .value="${this.value}"
196
+ .type="${this.type}"
197
+ placeholder="${this.placeholder || ' '}"
198
+ maxlength="${this.maxlength}"
199
+ @input="${this._handleInput}"
200
+ @blur="${this._handleBlur}"
201
+ >
202
+ </input>
203
+ ${this.title
204
+ ? html `<label for=${this._inputId} class="t-title"
205
+ >${this.title}</label
206
+ >`
207
+ : nothing}
208
+ ${this._getFeatureTemplateByInputType()}
209
+ `;
210
+ }
211
+ _getLetterCounterTemplate() {
212
+ if (!this._hasLetterCounter()) {
213
+ return html `${nothing}`;
214
+ }
215
+ return html `<div class="t-letter-counter">
216
+ ${this.maxlength
217
+ ? html `${this._letterCounter}/${this.maxlength}`
218
+ : nothing}
219
+ </div> `;
220
+ }
221
+ _hasLetterCounter() {
222
+ return (this.type === InputType.TEXT_AREA &&
223
+ typeof this.maxlength === 'number' &&
224
+ this.maxlength >= 0);
225
+ }
226
+ _getTextAreaTemplate() {
227
+ return html `<textarea
228
+ id="${this._inputId}"
229
+ class="${classMap(this._getInputElementClasses())}"
230
+ ?disabled="${this.disabled}"
231
+ ?readonly="${this.readonly}"
232
+ .value="${this.value}"
233
+ placeholder="${this.placeholder}"
234
+ maxlength="${this.maxlength}"
235
+ @input="${this._handleInput}"
236
+ @blur="${this._handleBlur}"
237
+ ></textarea>
238
+ ${this.title
239
+ ? html `<label for=${this._inputId} class="t-title"
240
+ >${this.title}</label
241
+ >`
242
+ : nothing} `;
243
+ }
244
+ _getIconDescriptionTemplate() {
245
+ if (!this.descriptionType ||
246
+ this.descriptionType === DescriptionType.TEXT) {
247
+ return html `${nothing}`;
248
+ }
249
+ return html `<tuix-icon
250
+ size="${IconSizeVariant.SMALL}"
251
+ name="${IconByDescriptionType[this.descriptionType]}"
252
+ color="${this.dark
253
+ ? IconDescriptionColorDark[this.descriptionType]
254
+ : IconDescriptionColorLight[this.descriptionType]}"
255
+ >
256
+ </tuix-icon>`;
257
+ }
258
+ _getDescriptionTemplate() {
259
+ const isValidDescriptionType = this._hasValidDescriptionType();
260
+ if (!isValidDescriptionType) {
261
+ return html `<div></div>`;
262
+ }
263
+ const defaultDescription = {
264
+ [DescriptionType.WARNING]: 'Warning',
265
+ [DescriptionType.ERROR]: 'Error',
266
+ [DescriptionType.SUCCESS]: 'Success',
267
+ [DescriptionType.LOADING]: 'Loading',
268
+ [DescriptionType.TEXT]: '',
269
+ };
270
+ return html `<div class="t-input-description">
271
+ ${this._getIconDescriptionTemplate()}
272
+ <span
273
+ >${this.description ?? defaultDescription[this.descriptionType]}</span
274
+ >
275
+ </div>`;
276
+ }
277
+ _hasValidDescriptionType() {
278
+ return Object.values(DescriptionType).includes(this.descriptionType);
279
+ }
280
+ _getDescriptionContainerTemplate() {
281
+ const hasLetterCounter = this._hasLetterCounter();
282
+ const hasDescription = this._hasValidDescriptionType() &&
283
+ (this.descriptionType === DescriptionType.TEXT
284
+ ? !!this.description
285
+ : true);
286
+ if (!hasLetterCounter && !hasDescription) {
287
+ return html `${nothing}`;
288
+ }
289
+ return html `<div class="t-input-description-container">
290
+ ${this._getDescriptionTemplate()} ${this._getLetterCounterTemplate()}
291
+ </div>`;
292
+ }
293
+ render() {
294
+ if (this._previousType !== this.type) {
295
+ this._previousType = this.type;
296
+ this._type = this.type;
297
+ }
298
+ if (this._previousValue !== this.value) {
299
+ this._previousValue = this.value;
300
+ this._letterCounter = this.value.length;
301
+ }
302
+ return html `<div class="${classMap(this._getMainContainerClasses())}">
303
+ <div
304
+ class="${classMap(this._getInputContainerClasses())}"
305
+ @click="${this._handleClickOnInput}"
306
+ >
307
+ ${this.type === InputType.TEXT_AREA
308
+ ? this._getTextAreaTemplate()
309
+ : this._getInputTemplate()}
310
+ </div>
311
+ ${this._getDescriptionContainerTemplate()}
312
+ </div>`;
313
+ }
314
+ updated(changedProperties) {
315
+ for (const [propName] of changedProperties) {
316
+ if (this.disabled || this.readonly)
317
+ break;
318
+ if (String(propName) !== 'autofocus')
319
+ continue;
320
+ if (this.autofocus) {
321
+ this._inputElement.focus();
322
+ }
323
+ }
324
+ }
325
+ };
326
+ __decorate([
327
+ property({ type: Boolean, reflect: true })
328
+ ], TuixInput.prototype, "disabled", void 0);
329
+ __decorate([
330
+ property({ type: IconName })
331
+ ], TuixInput.prototype, "iconRight", void 0);
332
+ __decorate([
333
+ property({ type: String })
334
+ ], TuixInput.prototype, "value", void 0);
335
+ __decorate([
336
+ property({ type: String })
337
+ ], TuixInput.prototype, "placeholder", void 0);
338
+ __decorate([
339
+ property({ type: String })
340
+ ], TuixInput.prototype, "title", void 0);
341
+ __decorate([
342
+ property({ type: InputType })
343
+ ], TuixInput.prototype, "type", void 0);
344
+ __decorate([
345
+ property({ type: Number })
346
+ ], TuixInput.prototype, "maxlength", void 0);
347
+ __decorate([
348
+ property({ type: String })
349
+ ], TuixInput.prototype, "description", void 0);
350
+ __decorate([
351
+ property({ type: DescriptionType })
352
+ ], TuixInput.prototype, "descriptionType", void 0);
353
+ __decorate([
354
+ property({ type: Boolean, reflect: true })
355
+ ], TuixInput.prototype, "dark", void 0);
356
+ __decorate([
357
+ property({ type: Boolean })
358
+ ], TuixInput.prototype, "readonly", void 0);
359
+ __decorate([
360
+ property({ type: Boolean, reflect: true })
361
+ ], TuixInput.prototype, "autofocus", void 0);
362
+ __decorate([
363
+ query('.t-input-container .t-input')
364
+ ], TuixInput.prototype, "_inputElement", void 0);
365
+ __decorate([
366
+ state()
367
+ ], TuixInput.prototype, "_type", void 0);
368
+ __decorate([
369
+ state()
370
+ ], TuixInput.prototype, "_letterCounter", void 0);
371
+ TuixInput = __decorate([
372
+ customElement('tuix-input')
373
+ ], TuixInput);
374
+ export { TuixInput };
@@ -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;