@krumio/trailhand-ui 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/components/action-menu/action-menu.js +12 -12
- package/dist/components/button/button.d.ts +4 -0
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +38 -22
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/checkbox/checkbox.d.ts +31 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.js +234 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.d.ts.map +1 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/checkbox/index.js.map +1 -0
- package/dist/components/data-table/data-table.js +30 -30
- package/dist/components/icon/icon.d.ts +3 -3
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +5 -15
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/progress-bar/progress-bar.js +12 -12
- package/dist/components/selector/index.d.ts +2 -0
- package/dist/components/selector/index.d.ts.map +1 -0
- package/dist/components/selector/index.js +2 -0
- package/dist/components/selector/index.js.map +1 -0
- package/dist/components/selector/selector.d.ts +33 -0
- package/dist/components/selector/selector.d.ts.map +1 -0
- package/dist/components/selector/selector.js +225 -0
- package/dist/components/selector/selector.js.map +1 -0
- package/dist/components/text-input/index.d.ts +2 -0
- package/dist/components/text-input/index.d.ts.map +1 -0
- package/dist/components/text-input/index.js +2 -0
- package/dist/components/text-input/index.js.map +1 -0
- package/dist/components/text-input/text-input.d.ts +36 -0
- package/dist/components/text-input/text-input.d.ts.map +1 -0
- package/dist/components/text-input/text-input.js +216 -0
- package/dist/components/text-input/text-input.js.map +1 -0
- package/dist/components/th-tag/th-tag.js +15 -15
- package/dist/components/toggle-switch/toggle-switch.js +3 -3
- package/dist/styles/colors.css +160 -103
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -31,22 +31,22 @@ Trailhand UI includes a design system with CSS custom properties. Import `colors
|
|
|
31
31
|
|
|
32
32
|
```css
|
|
33
33
|
/* Available variables */
|
|
34
|
-
--color-primary: #3d98d3;
|
|
35
|
-
--color-white: #FFFFFF;
|
|
36
|
-
--color-black: #000000;
|
|
34
|
+
--th-color-primary: #3d98d3;
|
|
35
|
+
--th-color-white: #FFFFFF;
|
|
36
|
+
--th-color-black: #000000;
|
|
37
37
|
|
|
38
38
|
/* Greyscale */
|
|
39
|
-
--color-grey-100 through --color-grey-800
|
|
39
|
+
--th-color-grey-100 through --th-color-grey-800
|
|
40
40
|
|
|
41
41
|
/* Semantic aliases */
|
|
42
|
-
--color-text-primary: #212121;
|
|
43
|
-
--color-text-secondary: #636363;
|
|
44
|
-
--color-text-muted: #8D8D8D;
|
|
45
|
-
--color-background: #FFFFFF;
|
|
46
|
-
--color-border: #D7D7D7;
|
|
47
|
-
--color-error: #9F3A3A;
|
|
48
|
-
--color-success: #30AC66;
|
|
49
|
-
--color-warning: #D3C255;
|
|
42
|
+
--th-color-text-primary: #212121;
|
|
43
|
+
--th-color-text-secondary: #636363;
|
|
44
|
+
--th-color-text-muted: #8D8D8D;
|
|
45
|
+
--th-color-background: #FFFFFF;
|
|
46
|
+
--th-color-border: #D7D7D7;
|
|
47
|
+
--th-color-error: #9F3A3A;
|
|
48
|
+
--th-color-success: #30AC66;
|
|
49
|
+
--th-color-warning: #D3C255;
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
### Theming
|
|
@@ -55,7 +55,7 @@ Override any variable to customize the look:
|
|
|
55
55
|
|
|
56
56
|
```css
|
|
57
57
|
:root {
|
|
58
|
-
--color-primary: #your-brand-color;
|
|
58
|
+
--th-color-primary: #your-brand-color;
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -216,17 +216,17 @@ ActionMenu.styles = css `
|
|
|
216
216
|
width: 32px;
|
|
217
217
|
height: 32px;
|
|
218
218
|
padding: 0;
|
|
219
|
-
border: 1px solid var(--border, var(--color-border, #D7D7D7));
|
|
219
|
+
border: 1px solid var(--border, var(--th-color-border, #D7D7D7));
|
|
220
220
|
border-radius: 4px;
|
|
221
|
-
background-color: var(--body-bg, var(--color-white, #FFFFFF));
|
|
222
|
-
color: var(--body-text, var(--color-text-primary, #212121));
|
|
221
|
+
background-color: var(--body-bg, var(--th-color-white, #FFFFFF));
|
|
222
|
+
color: var(--body-text, var(--th-color-text-primary, #212121));
|
|
223
223
|
cursor: pointer;
|
|
224
224
|
transition: all 0.2s;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
.action-menu__button:hover:not(:disabled) {
|
|
228
|
-
background-color: var(--sortable-table-row-hover-bg, var(--color-grey-100, #FAFAFA));
|
|
229
|
-
border-color: var(--link, var(--color-primary, #3d98d3));
|
|
228
|
+
background-color: var(--sortable-table-row-hover-bg, var(--th-color-grey-100, #FAFAFA));
|
|
229
|
+
border-color: var(--link, var(--th-color-primary, #3d98d3));
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
.action-menu__button:disabled {
|
|
@@ -245,8 +245,8 @@ ActionMenu.styles = css `
|
|
|
245
245
|
top: 100%;
|
|
246
246
|
margin-top: 4px;
|
|
247
247
|
min-width: 180px;
|
|
248
|
-
background-color: var(--body-bg, var(--color-white, #FFFFFF));
|
|
249
|
-
border: 1px solid var(--border, var(--color-border, #D7D7D7));
|
|
248
|
+
background-color: var(--body-bg, var(--th-color-white, #FFFFFF));
|
|
249
|
+
border: 1px solid var(--border, var(--th-color-border, #D7D7D7));
|
|
250
250
|
border-radius: 4px;
|
|
251
251
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
252
252
|
z-index: 1000;
|
|
@@ -281,7 +281,7 @@ ActionMenu.styles = css `
|
|
|
281
281
|
padding: 0.5rem 1rem;
|
|
282
282
|
border: none;
|
|
283
283
|
background: none;
|
|
284
|
-
color: var(--body-text, var(--color-text-primary, #212121));
|
|
284
|
+
color: var(--body-text, var(--th-color-text-primary, #212121));
|
|
285
285
|
font-size: 14px;
|
|
286
286
|
text-align: left;
|
|
287
287
|
cursor: pointer;
|
|
@@ -289,7 +289,7 @@ ActionMenu.styles = css `
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
.action-menu__action:hover:not(:disabled) {
|
|
292
|
-
background-color: var(--sortable-table-row-hover-bg, var(--color-grey-100, #FAFAFA));
|
|
292
|
+
background-color: var(--sortable-table-row-hover-bg, var(--th-color-grey-100, #FAFAFA));
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
.action-menu__action:disabled {
|
|
@@ -298,7 +298,7 @@ ActionMenu.styles = css `
|
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
.action-menu__action--danger {
|
|
301
|
-
color: var(--error, var(--color-error, #9F3A3A));
|
|
301
|
+
color: var(--error, var(--th-color-error, #9F3A3A));
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
.action-menu__action--danger:hover:not(:disabled) {
|
|
@@ -308,13 +308,13 @@ ActionMenu.styles = css `
|
|
|
308
308
|
.action-menu__divider {
|
|
309
309
|
height: 1px;
|
|
310
310
|
margin: 0.5rem 0;
|
|
311
|
-
background-color: var(--border, var(--color-border, #D7D7D7));
|
|
311
|
+
background-color: var(--border, var(--th-color-border, #D7D7D7));
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
.action-menu__empty {
|
|
315
315
|
padding: 1rem;
|
|
316
316
|
text-align: center;
|
|
317
|
-
color: var(--muted, var(--color-text-muted, #8D8D8D));
|
|
317
|
+
color: var(--muted, var(--th-color-text-muted, #8D8D8D));
|
|
318
318
|
font-size: 13px;
|
|
319
319
|
}
|
|
320
320
|
`;
|
|
@@ -7,14 +7,18 @@ export interface ButtonProps {
|
|
|
7
7
|
name: string;
|
|
8
8
|
}
|
|
9
9
|
export declare class Button extends LitElement {
|
|
10
|
+
static formAssociated: boolean;
|
|
10
11
|
variant: 'primary' | 'secondary' | 'alternate' | 'destructive' | 'confirmation';
|
|
11
12
|
size: 'small' | 'medium' | 'large';
|
|
12
13
|
name: string;
|
|
13
14
|
disabled: boolean;
|
|
14
15
|
type: 'button' | 'submit' | 'reset';
|
|
16
|
+
private internals;
|
|
17
|
+
constructor();
|
|
15
18
|
static styles: import("lit").CSSResult;
|
|
16
19
|
updated(): void;
|
|
17
20
|
private handleClick;
|
|
21
|
+
formDisabledCallback(disabled: boolean): void;
|
|
18
22
|
render(): TemplateResult;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAG5D,MAAM,WAAW,WAAW;IAC1B,OAAO,EACH,SAAS,GACT,WAAW,GACX,WAAW,GACX,aAAa,GACb,cAAc,CAAC;IACnB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,MAAO,SAAQ,UAAU;IACpC,MAAM,CAAC,cAAc,UAAQ;IAG7B,OAAO,EACH,SAAS,GACT,WAAW,GACX,WAAW,GACX,aAAa,GACb,cAAc,CAAa;IAG/B,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAG9C,IAAI,SAAM;IAGV,QAAQ,UAAS;IAGjB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAY;IAE/C,OAAO,CAAC,SAAS,CAAmB;;IAOpC,OAAgB,MAAM,0BAwGpB;IAEF,OAAO;IAQP,OAAO,CAAC,WAAW;IAiCnB,oBAAoB,CAAC,QAAQ,EAAE,OAAO;IAI7B,MAAM,IAAI,cAAc;CAuBlC"}
|
|
@@ -6,15 +6,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { LitElement, html, css } from 'lit';
|
|
8
8
|
import { property } from 'lit/decorators.js';
|
|
9
|
-
import { styleMap } from 'lit/directives/style-map.js';
|
|
10
9
|
export class Button extends LitElement {
|
|
11
10
|
constructor() {
|
|
12
|
-
super(
|
|
11
|
+
super();
|
|
13
12
|
this.variant = 'primary';
|
|
14
13
|
this.size = 'medium';
|
|
15
14
|
this.name = '';
|
|
16
15
|
this.disabled = false;
|
|
17
16
|
this.type = 'button';
|
|
17
|
+
this.internals = this.attachInternals();
|
|
18
18
|
}
|
|
19
19
|
updated() {
|
|
20
20
|
if (this.disabled) {
|
|
@@ -30,6 +30,20 @@ export class Button extends LitElement {
|
|
|
30
30
|
e.stopPropagation();
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
+
// Handle form submission for type="submit"
|
|
34
|
+
if (this.type === 'submit') {
|
|
35
|
+
const form = this.internals.form;
|
|
36
|
+
if (form) {
|
|
37
|
+
// Request form submission
|
|
38
|
+
form.requestSubmit();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (this.type === 'reset') {
|
|
42
|
+
const form = this.internals.form;
|
|
43
|
+
if (form) {
|
|
44
|
+
form.reset();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
33
47
|
this.dispatchEvent(new CustomEvent('button-click', {
|
|
34
48
|
bubbles: true,
|
|
35
49
|
composed: true,
|
|
@@ -39,14 +53,15 @@ export class Button extends LitElement {
|
|
|
39
53
|
},
|
|
40
54
|
}));
|
|
41
55
|
}
|
|
56
|
+
formDisabledCallback(disabled) {
|
|
57
|
+
this.disabled = disabled;
|
|
58
|
+
}
|
|
42
59
|
render() {
|
|
43
|
-
const styles = {};
|
|
44
60
|
return html `
|
|
45
61
|
<button
|
|
46
62
|
type=${this.type}
|
|
47
63
|
class="trailhand-button trailhand-button--${this
|
|
48
64
|
.variant} trailhand-button--${this.size}"
|
|
49
|
-
style=${styleMap(styles)}
|
|
50
65
|
?disabled=${this.disabled}
|
|
51
66
|
@click=${this.handleClick}
|
|
52
67
|
>
|
|
@@ -65,6 +80,7 @@ export class Button extends LitElement {
|
|
|
65
80
|
`;
|
|
66
81
|
}
|
|
67
82
|
}
|
|
83
|
+
Button.formAssociated = true;
|
|
68
84
|
Button.styles = css `
|
|
69
85
|
:host {
|
|
70
86
|
display: inline-block;
|
|
@@ -86,55 +102,55 @@ Button.styles = css `
|
|
|
86
102
|
|
|
87
103
|
.trailhand-button:disabled {
|
|
88
104
|
cursor: not-allowed;
|
|
89
|
-
background-color: var(--button-disabled-bg, #e0e0e0);
|
|
90
|
-
color: var(--button-disabled-color, #a8a8a8);
|
|
105
|
+
background-color: var(--th-button-disabled-bg, #e0e0e0);
|
|
106
|
+
color: var(--th-button-disabled-color, #a8a8a8);
|
|
91
107
|
border: none;
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
.trailhand-button--primary {
|
|
95
|
-
color: var(--button-primary-color, #fff);
|
|
96
|
-
background-color: var(--button-primary-bg, #005cb9);
|
|
111
|
+
color: var(--th-button-primary-color, #fff);
|
|
112
|
+
background-color: var(--th-button-primary-bg, #005cb9);
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
.trailhand-button--primary:not(:disabled):hover {
|
|
100
|
-
background-color: var(--button-primary-bg-hover, #00478e);
|
|
116
|
+
background-color: var(--th-button-primary-bg-hover, #00478e);
|
|
101
117
|
}
|
|
102
118
|
|
|
103
119
|
.trailhand-button--secondary {
|
|
104
|
-
color: var(--button-secondary-color, #005cb9);
|
|
105
|
-
background-color: var(--button-secondary-bg, #ffffff);
|
|
106
|
-
border: 1px solid var(--button-secondary-border, #005cb9);
|
|
120
|
+
color: var(--th-button-secondary-color, #005cb9);
|
|
121
|
+
background-color: var(--th-button-secondary-bg, #ffffff);
|
|
122
|
+
border: 1px solid var(--th-button-secondary-border, #005cb9);
|
|
107
123
|
}
|
|
108
124
|
|
|
109
125
|
.trailhand-button--secondary:not(:disabled):hover {
|
|
110
|
-
background-color: var(--button-secondary-bg-hover, #f5faff);
|
|
126
|
+
background-color: var(--th-button-secondary-bg-hover, #f5faff);
|
|
111
127
|
}
|
|
112
128
|
|
|
113
129
|
.trailhand-button--alternate {
|
|
114
|
-
color: var(--button-alternate-color, #ffffff);
|
|
115
|
-
background-color: var(--button-alternate-bg, #3492f1);
|
|
130
|
+
color: var(--th-button-alternate-color, #ffffff);
|
|
131
|
+
background-color: var(--th-button-alternate-bg, #3492f1);
|
|
116
132
|
}
|
|
117
133
|
|
|
118
134
|
.trailhand-button--alternate:not(:disabled):hover {
|
|
119
|
-
background-color: var(--button-alternate-bg-hover, #156ec8);
|
|
135
|
+
background-color: var(--th-button-alternate-bg-hover, #156ec8);
|
|
120
136
|
}
|
|
121
137
|
|
|
122
138
|
.trailhand-button--destructive {
|
|
123
|
-
color: var(--button-destructive-color, #fff);
|
|
124
|
-
background-color: var(--button-destructive-bg, #9f3a3a);
|
|
139
|
+
color: var(--th-button-destructive-color, #fff);
|
|
140
|
+
background-color: var(--th-button-destructive-bg, #9f3a3a);
|
|
125
141
|
}
|
|
126
142
|
|
|
127
143
|
.trailhand-button--destructive:not(:disabled):hover {
|
|
128
|
-
background-color: var(--button-destructive-bg-hover, #731616);
|
|
144
|
+
background-color: var(--th-button-destructive-bg-hover, #731616);
|
|
129
145
|
}
|
|
130
146
|
|
|
131
147
|
.trailhand-button--confirmation {
|
|
132
|
-
color: var(--button-confirmation-color, #fff);
|
|
133
|
-
background-color: var(--button-confirmation-bg, #30ac66);
|
|
148
|
+
color: var(--th-button-confirmation-color, #fff);
|
|
149
|
+
background-color: var(--th-button-confirmation-bg, #30ac66);
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
.trailhand-button--confirmation:not(:disabled):hover {
|
|
137
|
-
background-color: var(--button-confirmation-bg-hover, #0f8240);
|
|
153
|
+
background-color: var(--th-button-confirmation-bg-hover, #0f8240);
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
.trailhand-button--small {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/button/button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"button.js","sourceRoot":"","sources":["../../../src/components/button/button.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAe7C,MAAM,OAAO,MAAO,SAAQ,UAAU;IAyBpC;QACE,KAAK,EAAE,CAAC;QAtBV,YAAO,GAKc,SAAS,CAAC;QAG/B,SAAI,GAAiC,QAAQ,CAAC;QAG9C,SAAI,GAAG,EAAE,CAAC;QAGV,aAAQ,GAAG,KAAK,CAAC;QAGjB,SAAI,GAAkC,QAAQ,CAAC;QAM7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAC1C,CAAC;IA4GD,OAAO;QACL,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,CAAQ;QAC1B,IAAI,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwG3B,AAxGqB,CAwGpB;AAlIF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAMI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACmB;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAC1B;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACoB;AAyLjD,cAAc,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
import '../icon/icon';
|
|
3
|
+
export interface CheckboxProps {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
indeterminate: boolean;
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
size: 'small' | 'medium' | 'large';
|
|
10
|
+
}
|
|
11
|
+
export declare class Checkbox extends LitElement {
|
|
12
|
+
static formAssociated: boolean;
|
|
13
|
+
checked: boolean;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
indeterminate: boolean;
|
|
16
|
+
name: string;
|
|
17
|
+
value: string;
|
|
18
|
+
size: 'small' | 'medium' | 'large';
|
|
19
|
+
private internals;
|
|
20
|
+
constructor();
|
|
21
|
+
static styles: import("lit").CSSResult;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
private emitChangeEvent;
|
|
24
|
+
private handleChange;
|
|
25
|
+
private updateFormValue;
|
|
26
|
+
formResetCallback(): void;
|
|
27
|
+
formDisableCallback(disabled: boolean): void;
|
|
28
|
+
updated(changedProperties: Map<string, any>): void;
|
|
29
|
+
render(): TemplateResult;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D,OAAO,cAAc,CAAC;AAEtB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,qBAAa,QAAS,SAAQ,UAAU;IACtC,MAAM,CAAC,cAAc,UAAQ;IAG7B,OAAO,UAAS;IAGhB,QAAQ,UAAS;IAGjB,aAAa,UAAS;IAGtB,IAAI,SAAM;IAGV,KAAK,SAAQ;IAGb,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAG9C,OAAO,CAAC,SAAS,CAAmB;;IAOpC,MAAM,CAAC,MAAM,0BAsGX;IAEF,iBAAiB;IASjB,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,eAAe;IAQvB,iBAAiB;IAMjB,mBAAmB,CAAC,QAAQ,EAAE,OAAO;IAIrC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;IAa3C,MAAM,IAAI,cAAc;CA4BzB"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, css } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import '../icon/icon';
|
|
10
|
+
export class Checkbox extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
this.checked = false;
|
|
14
|
+
this.disabled = false;
|
|
15
|
+
this.indeterminate = false;
|
|
16
|
+
this.name = '';
|
|
17
|
+
this.value = 'on';
|
|
18
|
+
this.size = 'medium';
|
|
19
|
+
this.internals = this.attachInternals();
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback();
|
|
23
|
+
// Check if we're in a disabled fieldset on initial connection
|
|
24
|
+
const fieldset = this.closest('fieldset');
|
|
25
|
+
if (fieldset?.disabled) {
|
|
26
|
+
this.disabled = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
emitChangeEvent() {
|
|
30
|
+
// emit native change events for form integration
|
|
31
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
32
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
33
|
+
// emit a custom event with the current state of the checkbox
|
|
34
|
+
this.dispatchEvent(new CustomEvent('checkbox-change', {
|
|
35
|
+
bubbles: true,
|
|
36
|
+
composed: true,
|
|
37
|
+
detail: {
|
|
38
|
+
checked: this.checked,
|
|
39
|
+
indeterminate: this.indeterminate,
|
|
40
|
+
name: this.name,
|
|
41
|
+
value: this.value,
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
handleChange(e) {
|
|
46
|
+
if (this.disabled)
|
|
47
|
+
return;
|
|
48
|
+
const input = e.target;
|
|
49
|
+
this.checked = input.checked;
|
|
50
|
+
this.indeterminate = false;
|
|
51
|
+
this.updateFormValue();
|
|
52
|
+
this.emitChangeEvent();
|
|
53
|
+
}
|
|
54
|
+
updateFormValue() {
|
|
55
|
+
if (this.checked) {
|
|
56
|
+
this.internals.setFormValue(this.value);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.internals.setFormValue(null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
formResetCallback() {
|
|
63
|
+
this.checked = false;
|
|
64
|
+
this.indeterminate = false;
|
|
65
|
+
this.updateFormValue();
|
|
66
|
+
}
|
|
67
|
+
formDisableCallback(disabled) {
|
|
68
|
+
this.disabled = disabled;
|
|
69
|
+
}
|
|
70
|
+
updated(changedProperties) {
|
|
71
|
+
// Update form value whenever checked or value changes
|
|
72
|
+
if (changedProperties.has('checked') || changedProperties.has('value')) {
|
|
73
|
+
this.updateFormValue();
|
|
74
|
+
}
|
|
75
|
+
// Sync indeterminate to native input
|
|
76
|
+
if (changedProperties.has('indeterminate')) {
|
|
77
|
+
const input = this.shadowRoot?.querySelector('input');
|
|
78
|
+
if (input)
|
|
79
|
+
input.indeterminate = this.indeterminate;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
return html `
|
|
84
|
+
<label class="wrapper">
|
|
85
|
+
<input
|
|
86
|
+
type="checkbox"
|
|
87
|
+
.checked=${this.checked}
|
|
88
|
+
.indeterminate=${this.indeterminate}
|
|
89
|
+
?disabled=${this.disabled}
|
|
90
|
+
aria-checked=${this.indeterminate
|
|
91
|
+
? 'mixed'
|
|
92
|
+
: this.checked
|
|
93
|
+
? 'true'
|
|
94
|
+
: 'false'}
|
|
95
|
+
@change=${this.handleChange}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
<span class="control">
|
|
99
|
+
<trailhand-icon
|
|
100
|
+
name=${this.indeterminate ? 'minus' : 'check'}
|
|
101
|
+
></trailhand-icon>
|
|
102
|
+
</span>
|
|
103
|
+
|
|
104
|
+
<span class="label">
|
|
105
|
+
<slot></slot>
|
|
106
|
+
</span>
|
|
107
|
+
</label>
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
Checkbox.formAssociated = true;
|
|
112
|
+
Checkbox.styles = css `
|
|
113
|
+
:host {
|
|
114
|
+
display: inline-block;
|
|
115
|
+
font-family: 'Montserrat', system-ui, sans-serif;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.wrapper {
|
|
119
|
+
display: flex;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: flex-start;
|
|
122
|
+
gap: 8px;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
font-weight: 500;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Hide native checkbox */
|
|
128
|
+
input {
|
|
129
|
+
position: absolute;
|
|
130
|
+
opacity: 0;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.label {
|
|
135
|
+
color: var(--th-color-text-primary, #000000);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Custom box */
|
|
139
|
+
.control {
|
|
140
|
+
width: 16px;
|
|
141
|
+
height: 16px;
|
|
142
|
+
border-radius: 4px;
|
|
143
|
+
border: 1.5px solid var(--th-checkbox-border, #d7d7d7);
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
transition: all 0.15s ease;
|
|
148
|
+
background-color: transparent;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.control trailhand-icon {
|
|
152
|
+
opacity: 0;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Size */
|
|
156
|
+
:host([size='small']) .control {
|
|
157
|
+
width: 12px;
|
|
158
|
+
height: 12px;
|
|
159
|
+
}
|
|
160
|
+
:host([size='small']) .wrapper {
|
|
161
|
+
font-size: 12px;
|
|
162
|
+
}
|
|
163
|
+
:host([size='medium']) .control {
|
|
164
|
+
width: 14px;
|
|
165
|
+
height: 14px;
|
|
166
|
+
}
|
|
167
|
+
:host([size='medium']) .wrapper {
|
|
168
|
+
font-size: 14px;
|
|
169
|
+
}
|
|
170
|
+
:host([size='large']) .control {
|
|
171
|
+
width: 16px;
|
|
172
|
+
height: 16px;
|
|
173
|
+
}
|
|
174
|
+
:host([size='large']) .wrapper {
|
|
175
|
+
font-size: 16px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/* Focus */
|
|
179
|
+
input:focus-visible + .control {
|
|
180
|
+
outline: 2px solid var(--th-checkbox-checked-bg, #005cb9);
|
|
181
|
+
outline-offset: 2px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* Checked state */
|
|
185
|
+
:host([checked]) .control {
|
|
186
|
+
background: var(--th-checkbox-checked-bg, #005cb9);
|
|
187
|
+
border-color: var(--th-checkbox-checked-bg, #005cb9);
|
|
188
|
+
color: white;
|
|
189
|
+
}
|
|
190
|
+
:host([checked]) .control trailhand-icon[name='check'] {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Indeterminate state */
|
|
195
|
+
:host([indeterminate]) .control {
|
|
196
|
+
background: var(--th-checkbox-checked-bg, #005cb9);
|
|
197
|
+
border-color: var(--th-checkbox-checked-bg, #005cb9);
|
|
198
|
+
color: white;
|
|
199
|
+
}
|
|
200
|
+
:host([indeterminate]) .control trailhand-icon[name='minus'] {
|
|
201
|
+
opacity: 1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Disabled */
|
|
205
|
+
:host([disabled]) .control {
|
|
206
|
+
background: var(--th-checkbox-disabled-bg, #e0e0e0);
|
|
207
|
+
border-color: var(--th-checkbox-disabled-border, #c0c0c0);
|
|
208
|
+
color: var(--th-checkbox-disabled-check, #8d8d8d);
|
|
209
|
+
}
|
|
210
|
+
:host([disabled]) .wrapper {
|
|
211
|
+
color: var(--th-checkbox-disabled-check, #8d8d8d);
|
|
212
|
+
cursor: not-allowed;
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ type: Boolean, reflect: true })
|
|
217
|
+
], Checkbox.prototype, "checked", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property({ type: Boolean, reflect: true })
|
|
220
|
+
], Checkbox.prototype, "disabled", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property({ type: Boolean, reflect: true })
|
|
223
|
+
], Checkbox.prototype, "indeterminate", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
property({ type: String })
|
|
226
|
+
], Checkbox.prototype, "name", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property({ type: String })
|
|
229
|
+
], Checkbox.prototype, "value", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: String })
|
|
232
|
+
], Checkbox.prototype, "size", void 0);
|
|
233
|
+
customElements.define('trailhand-checkbox', Checkbox);
|
|
234
|
+
//# sourceMappingURL=checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.js","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,cAAc,CAAC;AAWtB,MAAM,OAAO,QAAS,SAAQ,UAAU;IAwBtC;QACE,KAAK,EAAE,CAAC;QArBV,YAAO,GAAG,KAAK,CAAC;QAGhB,aAAQ,GAAG,KAAK,CAAC;QAGjB,kBAAa,GAAG,KAAK,CAAC;QAGtB,SAAI,GAAG,EAAE,CAAC;QAGV,UAAK,GAAG,IAAI,CAAC;QAGb,SAAI,GAAiC,QAAQ,CAAC;QAO5C,IAAI,CAAC,SAAS,GAAG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AAC,CAAC,CAAC,OAAO;;;;;;;;KAQpD,CAAC;IACJ,CAAC;;AAvOM,uBAAc,GAAG,IAAI,AAAP,CAAQ;AA4BtB,eAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsGlB,AAtGY,CAsGX;AA/HF;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAC3B;AAGhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAC1B;AAGjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACrB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACd;AAGb;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACmB;AAwNhD,cAAc,CAAC,MAAM,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/checkbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|