@triptease/tt-combobox 5.0.3

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.
@@ -0,0 +1,276 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: flex;
5
+ flex-direction: var(--tt-combobox-flex-direction, row);
6
+ align-items: var(--tt-combobox-align-items, center);
7
+ justify-content: var(--tt-combobox-justify-content, initial);
8
+ align-content: var(--tt-combobox-align-content, initial);
9
+ gap: var(--tt-combobox-gap, 0.5rem);
10
+ font-size: var(--tt-combobox-font-size, var(--font-size-200));
11
+ color: var(--tt-combobox-color, var(--color-text-400));
12
+ }
13
+
14
+ :host([disabled]) .tt-combobox-container {
15
+ border-color: var(--tt-combobox-disabled-border-color, var(--color-border-200));
16
+ color: var(--tt-combobox-disabled-color, var(--color-text-200));
17
+ background-color: var(--tt-combobox-disabled-background-color, var(--color-surface-200));
18
+ pointer-events: none;
19
+ }
20
+
21
+ .tt-combobox-container:focus-within {
22
+ outline: 5px auto Highlight;
23
+ outline: 5px auto -webkit-focus-ring-color;
24
+ }
25
+
26
+ .tt-combobox-container:hover {
27
+ background-color: var(--tt-combobox-hover-background-color, var(--color-surface-300));
28
+ }
29
+
30
+ :host([invalid]) .tt-combobox-container,
31
+ :host(:state(interacted):invalid) .tt-combobox-container {
32
+ outline: 1px solid var(--color-alert-400,red);
33
+ }
34
+
35
+ .errormessage {
36
+ visibility: hidden;
37
+ display: flex;
38
+ align-items: center;
39
+ gap: var(--space-scale-0-5);
40
+ color: var(--color-alert-400, red);
41
+
42
+ &[data-hidden] {
43
+ display: none;
44
+ }
45
+ }
46
+
47
+ .errormessage svg path {
48
+ fill: var(--color-alert-400, red);
49
+ height: 20px;
50
+ }
51
+
52
+ .tt-combobox-container:has([role="combobox"][aria-invalid="true"]) ~ .errormessage {
53
+ visibility: visible;
54
+ }
55
+
56
+ :has([role="combobox"][aria-invalid="true"]) ::slotted([slot="error"]) {
57
+ color: var(--color-alert-400,darkred);
58
+ font-size: var(--font-size-100);
59
+ margin: 0;
60
+ font-weight: var(--font-weight-regular);
61
+ line-height: 1.2;
62
+ }
63
+
64
+ slot[name="option"]::slotted(*) {
65
+ display: none;
66
+ }
67
+
68
+ * {
69
+ box-sizing: border-box;
70
+ font-family: var(--font-family-sans);
71
+ cursor: inherit;
72
+ }
73
+
74
+ .tt-combobox-container {
75
+ position: relative;
76
+ max-width: var(--tt-combobox-max-width, 300px);
77
+ min-width: var(--tt-combobox-min-width, 250px);
78
+ display: flex;
79
+ flex-direction: row;
80
+ align-items: center;
81
+ border-radius: var(--border-radius);
82
+ border-color: var(--tt-combobox-border-color, var(--color-border-400));
83
+ border-style: solid;
84
+ border-width: var(--tt-combobox-border-width, 1px);
85
+ background-color: var(--tt-combobox-background-color, var(--color-surface-100));
86
+ padding: 0.5rem;
87
+ gap: 0.25rem;
88
+ //width: 100%;
89
+ }
90
+
91
+ [role="listbox"] {
92
+ display: none;
93
+ }
94
+
95
+ [role="combobox"] {
96
+ width: 100%;
97
+ border-style: none;
98
+ background-color: transparent;
99
+ font-size: var(--tt-combobox-font-size, var(--font-size-200));
100
+ }
101
+
102
+ .hide-caret {
103
+ caret-color: transparent;
104
+ }
105
+
106
+ [role="combobox"]::placeholder {
107
+ color: var(--tt-combobox-placeholder-color, var(--color-text-300));
108
+ font-family: var(--font-family-inter);
109
+ font-size: var(--tt-combobox-font-size, var(--font-size-200));
110
+ }
111
+
112
+ :host([disabled]) [role="combobox"]::placeholder {
113
+ color: var(--tt-combobox-disabled-placeholder-color, var(--color-text-200));
114
+ }
115
+
116
+ [role="combobox"]:placeholder-shown {
117
+ text-overflow: ellipsis;
118
+ overflow: clip;
119
+ }
120
+
121
+ [role="combobox"]:focus {
122
+ outline: none;
123
+ }
124
+
125
+ [role="combobox"] ~ button {
126
+ appearance: none;
127
+ padding: 0;
128
+ border-width: 0;
129
+ background-color: transparent;
130
+ aspect-ratio: 1;
131
+ }
132
+
133
+ [role="combobox"] ~ button svg {
134
+ transition: transform 0.2s ease-in-out;
135
+ color: var(--tt-combobox-dropdown-color, var(--color-text-400));
136
+ }
137
+
138
+ [role="combobox"][aria-expanded="true"] ~ button svg {
139
+ transform: rotate(180deg);
140
+ }
141
+
142
+ [role="combobox"][aria-expanded="true"] ~ [role="listbox"] {
143
+ display: block;
144
+ width: max-content;
145
+ max-width: var(--tt-combobox-list-max-width, 35ch);
146
+ min-width: 100%;
147
+ background-color: var(--color-surface-100);
148
+ border: 1px solid var(--tt-combobox-border-color, var(--color-border-300));
149
+ border-radius: var(--border-radius);
150
+ box-shadow: var(--box-shadow-lg);
151
+ padding: 0;
152
+ position: absolute;
153
+ top: var(--tt-combobox-top, calc(100% + 0.5rem));
154
+ left: var(--tt-combobox-left, 0);
155
+ right: var(--tt-combobox-right, unset);
156
+ bottom: var(--tt-combobox-bottom, unset);
157
+ z-index: 2;
158
+ margin: 0;
159
+ list-style: none;
160
+ max-height: var(--tt-combobox-max-height, 400px);
161
+ overflow-y: auto;
162
+
163
+
164
+ li {
165
+ display: flex;
166
+ padding: 0.5rem;
167
+ box-sizing: border-box;
168
+ text-align: left;
169
+ text-overflow: ellipsis;
170
+ text-wrap: nowrap;
171
+ align-items: center;
172
+ gap: 0.25rem;
173
+ max-width: 100%;
174
+ width: 100%;
175
+ overflow-y: visible;
176
+ flex: 1;
177
+
178
+
179
+ input[type="checkbox"] {
180
+ width: var(--checkbox-size, var(--space-scale-2));
181
+ aspect-ratio: 1;
182
+ flex: 0 0 auto;
183
+ }
184
+
185
+ span {
186
+ overflow: hidden;
187
+ text-overflow: ellipsis;
188
+ white-space: nowrap;
189
+ flex: 1;
190
+ line-height: 1.1;
191
+ }
192
+
193
+ &.no-results {
194
+ display: none;
195
+ }
196
+
197
+ &[aria-hidden="true"] {
198
+ visibility: hidden;
199
+ display: none;
200
+ }
201
+ }
202
+
203
+ &:not(:has([role="option"]:not([data-value="select-all"]))) {
204
+ .no-results {
205
+ display: flex;
206
+ }
207
+
208
+ .select-all {
209
+ display: none;
210
+ }
211
+ }
212
+
213
+
214
+ }
215
+
216
+ slot[name="icon"] {
217
+ display: inline-block;
218
+ max-width: var(--tt-combobox-icon-size,1rem);
219
+ aspect-ratio: 1;
220
+ }
221
+
222
+ [role="option"].select-all {
223
+ border-bottom: 1px solid var(--color-border-300);
224
+ }
225
+
226
+ [aria-multiselectable="false"] [role="option"][aria-selected="true"] {
227
+ color: var(--color-primary-400);
228
+ font-weight: var(--font-weight-medium);
229
+ }
230
+
231
+ [role="option"]:is(:hover, [data-active="true"]) {
232
+ background-color: var(--color-surface-300);
233
+
234
+ &:first-child {
235
+ border-top-left-radius: var(--border-radius);
236
+ border-top-right-radius: var(--border-radius);
237
+ }
238
+
239
+ &:last-child {
240
+ border-bottom-left-radius: var(--border-radius);
241
+ border-bottom-right-radius: var(--border-radius);
242
+ }
243
+ }
244
+
245
+ [role="option"]:hover {
246
+ cursor: pointer;
247
+ }
248
+
249
+ [role="option"][aria-disabled="true"] {
250
+ pointer-events: none;
251
+ opacity: 0.5;
252
+ }
253
+
254
+ [role="listbox"][aria-multiselectable="true"] [role="option"] input[type="checkbox"] {
255
+ accent-color: var(--color-primary-400);
256
+ width: var(--checkbox-size, var(--space-scale-2));
257
+ aspect-ratio: 1;
258
+ pointer-events: none;
259
+ }
260
+
261
+ [role="listbox"][aria-multiselectable="true"] [role="option"][aria-disabled="true"] input[type="checkbox"] {
262
+ pointer-events: none;
263
+ }
264
+
265
+ label {
266
+ font-size: var(--tt-combobox-label-font-size, inherit);
267
+ color: var(--tt-combobox-label-color, inherit);
268
+ font-weight: var(--tt-combobox-label-font-weight, inherit);
269
+
270
+ &[data-hidden] {
271
+ display: none;
272
+ }
273
+
274
+ }
275
+ `;
276
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiRvB,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles= css`\n :host {\n display: flex;\n flex-direction: var(--tt-combobox-flex-direction, row);\n align-items: var(--tt-combobox-align-items, center);\n justify-content: var(--tt-combobox-justify-content, initial);\n align-content: var(--tt-combobox-align-content, initial);\n gap: var(--tt-combobox-gap, 0.5rem);\n font-size: var(--tt-combobox-font-size, var(--font-size-200));\n color: var(--tt-combobox-color, var(--color-text-400));\n }\n\n :host([disabled]) .tt-combobox-container {\n border-color: var(--tt-combobox-disabled-border-color, var(--color-border-200));\n color: var(--tt-combobox-disabled-color, var(--color-text-200));\n background-color: var(--tt-combobox-disabled-background-color, var(--color-surface-200));\n pointer-events: none;\n }\n\n .tt-combobox-container:focus-within {\n outline: 5px auto Highlight;\n outline: 5px auto -webkit-focus-ring-color;\n }\n\n .tt-combobox-container:hover {\n background-color: var(--tt-combobox-hover-background-color, var(--color-surface-300));\n }\n\n :host([invalid]) .tt-combobox-container,\n :host(:state(interacted):invalid) .tt-combobox-container {\n outline: 1px solid var(--color-alert-400,red);\n }\n\n .errormessage {\n visibility: hidden;\n display: flex;\n align-items: center;\n gap: var(--space-scale-0-5);\n color: var(--color-alert-400, red);\n\n &[data-hidden] {\n display: none;\n }\n }\n\n .errormessage svg path {\n fill: var(--color-alert-400, red);\n height: 20px;\n }\n\n .tt-combobox-container:has([role=\"combobox\"][aria-invalid=\"true\"]) ~ .errormessage {\n visibility: visible;\n }\n\n :has([role=\"combobox\"][aria-invalid=\"true\"]) ::slotted([slot=\"error\"]) {\n color: var(--color-alert-400,darkred);\n font-size: var(--font-size-100);\n margin: 0;\n font-weight: var(--font-weight-regular);\n line-height: 1.2;\n }\n\n slot[name=\"option\"]::slotted(*) {\n display: none;\n }\n\n * {\n box-sizing: border-box;\n font-family: var(--font-family-sans);\n cursor: inherit;\n }\n\n .tt-combobox-container {\n position: relative;\n max-width: var(--tt-combobox-max-width, 300px);\n min-width: var(--tt-combobox-min-width, 250px);\n display: flex;\n flex-direction: row;\n align-items: center;\n border-radius: var(--border-radius);\n border-color: var(--tt-combobox-border-color, var(--color-border-400));\n border-style: solid;\n border-width: var(--tt-combobox-border-width, 1px);\n background-color: var(--tt-combobox-background-color, var(--color-surface-100));\n padding: 0.5rem;\n gap: 0.25rem;\n //width: 100%;\n }\n\n [role=\"listbox\"] {\n display: none;\n }\n\n [role=\"combobox\"] {\n width: 100%;\n border-style: none;\n background-color: transparent;\n font-size: var(--tt-combobox-font-size, var(--font-size-200));\n }\n\n .hide-caret {\n caret-color: transparent;\n }\n\n [role=\"combobox\"]::placeholder {\n color: var(--tt-combobox-placeholder-color, var(--color-text-300));\n font-family: var(--font-family-inter);\n font-size: var(--tt-combobox-font-size, var(--font-size-200));\n }\n\n :host([disabled]) [role=\"combobox\"]::placeholder {\n color: var(--tt-combobox-disabled-placeholder-color, var(--color-text-200));\n }\n\n [role=\"combobox\"]:placeholder-shown {\n text-overflow: ellipsis;\n overflow: clip;\n }\n\n [role=\"combobox\"]:focus {\n outline: none;\n }\n\n [role=\"combobox\"] ~ button {\n appearance: none;\n padding: 0;\n border-width: 0;\n background-color: transparent;\n aspect-ratio: 1;\n }\n\n [role=\"combobox\"] ~ button svg {\n transition: transform 0.2s ease-in-out;\n color: var(--tt-combobox-dropdown-color, var(--color-text-400));\n }\n\n [role=\"combobox\"][aria-expanded=\"true\"] ~ button svg {\n transform: rotate(180deg);\n }\n\n [role=\"combobox\"][aria-expanded=\"true\"] ~ [role=\"listbox\"] {\n display: block;\n width: max-content;\n max-width: var(--tt-combobox-list-max-width, 35ch);\n min-width: 100%;\n background-color: var(--color-surface-100);\n border: 1px solid var(--tt-combobox-border-color, var(--color-border-300));\n border-radius: var(--border-radius);\n box-shadow: var(--box-shadow-lg);\n padding: 0;\n position: absolute;\n top: var(--tt-combobox-top, calc(100% + 0.5rem));\n left: var(--tt-combobox-left, 0);\n right: var(--tt-combobox-right, unset);\n bottom: var(--tt-combobox-bottom, unset);\n z-index: 2;\n margin: 0;\n list-style: none;\n max-height: var(--tt-combobox-max-height, 400px);\n overflow-y: auto;\n\n\n li {\n display: flex;\n padding: 0.5rem;\n box-sizing: border-box;\n text-align: left;\n text-overflow: ellipsis;\n text-wrap: nowrap;\n align-items: center;\n gap: 0.25rem;\n max-width: 100%;\n width: 100%;\n overflow-y: visible;\n flex: 1;\n\n\n input[type=\"checkbox\"] {\n width: var(--checkbox-size, var(--space-scale-2));\n aspect-ratio: 1;\n flex: 0 0 auto;\n }\n\n span {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex: 1;\n line-height: 1.1;\n }\n\n &.no-results {\n display: none;\n }\n\n &[aria-hidden=\"true\"] {\n visibility: hidden;\n display: none;\n }\n }\n\n &:not(:has([role=\"option\"]:not([data-value=\"select-all\"]))) {\n .no-results {\n display: flex;\n }\n\n .select-all {\n display: none;\n }\n }\n\n\n }\n\n slot[name=\"icon\"] {\n display: inline-block;\n max-width: var(--tt-combobox-icon-size,1rem);\n aspect-ratio: 1;\n }\n\n [role=\"option\"].select-all {\n border-bottom: 1px solid var(--color-border-300);\n }\n\n [aria-multiselectable=\"false\"] [role=\"option\"][aria-selected=\"true\"] {\n color: var(--color-primary-400);\n font-weight: var(--font-weight-medium);\n }\n\n [role=\"option\"]:is(:hover, [data-active=\"true\"]) {\n background-color: var(--color-surface-300);\n\n &:first-child {\n border-top-left-radius: var(--border-radius);\n border-top-right-radius: var(--border-radius);\n }\n\n &:last-child {\n border-bottom-left-radius: var(--border-radius);\n border-bottom-right-radius: var(--border-radius);\n }\n }\n\n [role=\"option\"]:hover {\n cursor: pointer;\n }\n\n [role=\"option\"][aria-disabled=\"true\"] {\n pointer-events: none;\n opacity: 0.5;\n }\n\n [role=\"listbox\"][aria-multiselectable=\"true\"] [role=\"option\"] input[type=\"checkbox\"] {\n accent-color: var(--color-primary-400);\n width: var(--checkbox-size, var(--space-scale-2));\n aspect-ratio: 1;\n pointer-events: none;\n }\n\n [role=\"listbox\"][aria-multiselectable=\"true\"] [role=\"option\"][aria-disabled=\"true\"] input[type=\"checkbox\"] {\n pointer-events: none;\n }\n\n label {\n font-size: var(--tt-combobox-label-font-size, inherit);\n color: var(--tt-combobox-label-color, inherit);\n font-weight: var(--tt-combobox-label-font-weight, inherit);\n\n &[data-hidden] {\n display: none;\n }\n\n }\n`;\n"]}
@@ -0,0 +1,2 @@
1
+ import { TtCombobox } from './TtCombobox.js';
2
+ export { TtCombobox };
@@ -0,0 +1,6 @@
1
+ import { TtCombobox } from './TtCombobox.js';
2
+ if (!window.customElements.get('tt-combobox')) {
3
+ window.customElements.define('tt-combobox', TtCombobox);
4
+ }
5
+ export { TtCombobox };
6
+ //# sourceMappingURL=tt-combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-combobox.js","sourceRoot":"","sources":["../../src/tt-combobox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { TtCombobox } from './TtCombobox.js';\n\nif (!window.customElements.get('tt-combobox')) {\n window.customElements.define('tt-combobox', TtCombobox);\n}\n\nexport { TtCombobox };\n"]}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@triptease/tt-combobox",
3
+ "description": "Webcomponent tt-combobox following open-wc recommendations",
4
+ "license": "MIT",
5
+ "author": "@triptease",
6
+ "version": "5.0.3",
7
+ "type": "module",
8
+ "main": "dist/src/index.js",
9
+ "module": "dist/src/index.js",
10
+ "exports": {
11
+ ".": "./dist/src/index.js",
12
+ "./tt-combobox.js": "./dist/src/tt-combobox.js"
13
+ },
14
+ "scripts": {
15
+ "analyze": "cem analyze --litelement",
16
+ "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"web-dev-server\"",
17
+ "build": "yarn build:node && yarn build:web && npm run analyze -- --exclude dist",
18
+ "build:node": "tsc",
19
+ "build:web": "node ../../scripts/esbuild.mjs",
20
+ "prepublish": "tsc && npm run analyze -- --exclude dist",
21
+ "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
22
+ "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
23
+ "prepare": "husky",
24
+ "test": "tsc && wtr --coverage",
25
+ "test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
26
+ },
27
+ "dependencies": {
28
+ "@triptease/icons": "^1.0.2",
29
+ "lit": "^3.1.4"
30
+ },
31
+ "devDependencies": {
32
+ "@custom-elements-manifest/analyzer": "^0.10.3",
33
+ "@open-wc/eslint-config": "^12.0.3",
34
+ "@open-wc/testing": "^4.0.0",
35
+ "@types/mocha": "^10.0.7",
36
+ "@typescript-eslint/eslint-plugin": "^7.16.0",
37
+ "@typescript-eslint/parser": "^7.16.0",
38
+ "@web/dev-server": "^0.4.6",
39
+ "@web/test-runner": "^0.18.2",
40
+ "concurrently": "^8.2.2",
41
+ "eslint": "^8.57.0",
42
+ "eslint-config-prettier": "^9.1.0",
43
+ "husky": "^9.0.11",
44
+ "lint-staged": "^15.2.7",
45
+ "prettier": "^3.3.2",
46
+ "tslib": "^2.6.3",
47
+ "typescript": "^5.5.3"
48
+ },
49
+ "customElements": "custom-elements.json",
50
+ "eslintConfig": {
51
+ "parser": "@typescript-eslint/parser",
52
+ "extends": [
53
+ "@open-wc",
54
+ "prettier"
55
+ ],
56
+ "plugins": [
57
+ "@typescript-eslint"
58
+ ],
59
+ "rules": {
60
+ "no-unused-vars": "off",
61
+ "@typescript-eslint/no-unused-vars": [
62
+ "error"
63
+ ],
64
+ "import/no-unresolved": "off",
65
+ "import/extensions": [
66
+ "error",
67
+ "always",
68
+ {
69
+ "ignorePackages": true
70
+ }
71
+ ]
72
+ }
73
+ },
74
+ "prettier": {
75
+ "singleQuote": true,
76
+ "arrowParens": "avoid"
77
+ },
78
+ "lint-staged": {
79
+ "*.ts": [
80
+ "eslint --fix",
81
+ "prettier --write"
82
+ ]
83
+ }
84
+ }