wj-elements 0.1.136 → 0.1.137
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/dist/dark.css +223 -0
- package/dist/infinite-scroll.element-XVJukzjy.js +272 -0
- package/dist/infinite-scroll.element-XVJukzjy.js.map +1 -0
- package/dist/light.css +534 -0
- package/dist/list.element-Ce1vIm1O.js +50 -0
- package/dist/list.element-Ce1vIm1O.js.map +1 -0
- package/dist/localize.js +70 -0
- package/dist/localize.js.map +1 -0
- package/dist/popup.element-tyYxow0p.js +1623 -0
- package/dist/popup.element-tyYxow0p.js.map +1 -0
- package/dist/router-links-CJnOdbas.js +150 -0
- package/dist/router-links-CJnOdbas.js.map +1 -0
- package/dist/styles.css +849 -0
- package/dist/wje-accordion-item.js +113 -0
- package/dist/wje-accordion-item.js.map +1 -0
- package/dist/wje-accordion.js +122 -0
- package/dist/wje-accordion.js.map +1 -0
- package/dist/wje-animation.js +4326 -0
- package/dist/wje-animation.js.map +1 -0
- package/dist/wje-aside.js +55 -0
- package/dist/wje-aside.js.map +1 -0
- package/dist/wje-avatar.js +90 -0
- package/dist/wje-avatar.js.map +1 -0
- package/dist/wje-badge.js +71 -0
- package/dist/wje-badge.js.map +1 -0
- package/dist/wje-breadcrumb.js +195 -0
- package/dist/wje-breadcrumb.js.map +1 -0
- package/dist/wje-breadcrumbs.js +140 -0
- package/dist/wje-breadcrumbs.js.map +1 -0
- package/dist/wje-button-group.js +85 -0
- package/dist/wje-button-group.js.map +1 -0
- package/dist/wje-button.js +352 -0
- package/dist/wje-button.js.map +1 -0
- package/dist/wje-card-content.js +48 -0
- package/dist/wje-card-content.js.map +1 -0
- package/dist/wje-card-controls.js +48 -0
- package/dist/wje-card-controls.js.map +1 -0
- package/dist/wje-card-header.js +48 -0
- package/dist/wje-card-header.js.map +1 -0
- package/dist/wje-card-subtitle.js +55 -0
- package/dist/wje-card-subtitle.js.map +1 -0
- package/dist/wje-card-title.js +55 -0
- package/dist/wje-card-title.js.map +1 -0
- package/dist/wje-card.js +56 -0
- package/dist/wje-card.js.map +1 -0
- package/dist/wje-carousel-item.js +63 -0
- package/dist/wje-carousel-item.js.map +1 -0
- package/dist/wje-carousel.js +380 -0
- package/dist/wje-carousel.js.map +1 -0
- package/dist/wje-checkbox.js +540 -0
- package/dist/wje-checkbox.js.map +1 -0
- package/dist/wje-chip.js +76 -0
- package/dist/wje-chip.js.map +1 -0
- package/dist/wje-col.js +38 -0
- package/dist/wje-col.js.map +1 -0
- package/dist/wje-color-picker.js +1339 -0
- package/dist/wje-color-picker.js.map +1 -0
- package/dist/wje-container.js +56 -0
- package/dist/wje-container.js.map +1 -0
- package/dist/wje-copy-button.js +218 -0
- package/dist/wje-copy-button.js.map +1 -0
- package/dist/wje-dialog.js +249 -0
- package/dist/wje-dialog.js.map +1 -0
- package/dist/wje-divider.js +55 -0
- package/dist/wje-divider.js.map +1 -0
- package/dist/wje-dropdown.js +194 -0
- package/dist/wje-dropdown.js.map +1 -0
- package/dist/wje-element.js +967 -0
- package/dist/wje-element.js.map +1 -0
- package/dist/wje-fetchAndParseCSS.js +60 -0
- package/dist/wje-fetchAndParseCSS.js.map +1 -0
- package/dist/wje-file-upload-item.js +140 -0
- package/dist/wje-file-upload-item.js.map +1 -0
- package/dist/wje-file-upload.js +552 -0
- package/dist/wje-file-upload.js.map +1 -0
- package/dist/wje-footer.js +52 -0
- package/dist/wje-footer.js.map +1 -0
- package/dist/wje-form.js +53 -0
- package/dist/wje-form.js.map +1 -0
- package/dist/wje-format-digital.js +146 -0
- package/dist/wje-format-digital.js.map +1 -0
- package/dist/wje-grid.js +54 -0
- package/dist/wje-grid.js.map +1 -0
- package/dist/wje-header.js +56 -0
- package/dist/wje-header.js.map +1 -0
- package/dist/wje-icon-picker.js +349 -0
- package/dist/wje-icon-picker.js.map +1 -0
- package/dist/wje-icon.js +191 -0
- package/dist/wje-icon.js.map +1 -0
- package/dist/wje-img-comparer.js +131 -0
- package/dist/wje-img-comparer.js.map +1 -0
- package/dist/wje-img.js +80 -0
- package/dist/wje-img.js.map +1 -0
- package/dist/wje-infinite-scroll.js +6 -0
- package/dist/wje-infinite-scroll.js.map +1 -0
- package/dist/wje-input-file.js +111 -0
- package/dist/wje-input-file.js.map +1 -0
- package/dist/wje-input.js +452 -0
- package/dist/wje-input.js.map +1 -0
- package/dist/wje-item.js +88 -0
- package/dist/wje-item.js.map +1 -0
- package/dist/wje-kanban.js +462 -0
- package/dist/wje-kanban.js.map +1 -0
- package/dist/wje-label.js +53 -0
- package/dist/wje-label.js.map +1 -0
- package/dist/wje-list.js +6 -0
- package/dist/wje-list.js.map +1 -0
- package/dist/wje-main.js +52 -0
- package/dist/wje-main.js.map +1 -0
- package/dist/wje-masonry.js +267 -0
- package/dist/wje-masonry.js.map +1 -0
- package/dist/wje-master.js +687 -0
- package/dist/wje-master.js.map +1 -0
- package/dist/wje-menu-button.js +60 -0
- package/dist/wje-menu-button.js.map +1 -0
- package/dist/wje-menu-item.js +545 -0
- package/dist/wje-menu-item.js.map +1 -0
- package/dist/wje-menu-label.js +55 -0
- package/dist/wje-menu-label.js.map +1 -0
- package/dist/wje-menu.js +72 -0
- package/dist/wje-menu.js.map +1 -0
- package/dist/wje-option.js +112 -0
- package/dist/wje-option.js.map +1 -0
- package/dist/wje-options.js +355 -0
- package/dist/wje-options.js.map +1 -0
- package/dist/wje-orgchart-group.js +72 -0
- package/dist/wje-orgchart-group.js.map +1 -0
- package/dist/wje-orgchart-item.js +98 -0
- package/dist/wje-orgchart-item.js.map +1 -0
- package/dist/wje-orgchart.js +49 -0
- package/dist/wje-orgchart.js.map +1 -0
- package/dist/wje-popup.js +6 -0
- package/dist/wje-popup.js.map +1 -0
- package/dist/wje-progress-bar.js +213 -0
- package/dist/wje-progress-bar.js.map +1 -0
- package/dist/wje-qr-code.js +2892 -0
- package/dist/wje-qr-code.js.map +1 -0
- package/dist/wje-radio-group.js +228 -0
- package/dist/wje-radio-group.js.map +1 -0
- package/dist/wje-radio.js +106 -0
- package/dist/wje-radio.js.map +1 -0
- package/dist/wje-rate.js +300 -0
- package/dist/wje-rate.js.map +1 -0
- package/dist/wje-relative-time.js +115 -0
- package/dist/wje-relative-time.js.map +1 -0
- package/dist/wje-reorder-dropzone.js +49 -0
- package/dist/wje-reorder-dropzone.js.map +1 -0
- package/dist/wje-reorder-handle.js +218 -0
- package/dist/wje-reorder-handle.js.map +1 -0
- package/dist/wje-reorder-item.js +61 -0
- package/dist/wje-reorder-item.js.map +1 -0
- package/dist/wje-reorder.js +281 -0
- package/dist/wje-reorder.js.map +1 -0
- package/dist/wje-route.js +43 -0
- package/dist/wje-route.js.map +1 -0
- package/dist/wje-router-link.js +64 -0
- package/dist/wje-router-link.js.map +1 -0
- package/dist/wje-router-outlet.js +192 -0
- package/dist/wje-router-outlet.js.map +1 -0
- package/dist/wje-routerx.js +1437 -0
- package/dist/wje-routerx.js.map +1 -0
- package/dist/wje-row.js +49 -0
- package/dist/wje-row.js.map +1 -0
- package/dist/wje-select.js +630 -0
- package/dist/wje-select.js.map +1 -0
- package/dist/wje-slider.js +221 -0
- package/dist/wje-slider.js.map +1 -0
- package/dist/wje-sliding-container.js +474 -0
- package/dist/wje-sliding-container.js.map +1 -0
- package/dist/wje-split-view.js +153 -0
- package/dist/wje-split-view.js.map +1 -0
- package/dist/wje-status.js +61 -0
- package/dist/wje-status.js.map +1 -0
- package/dist/wje-step.js +50 -0
- package/dist/wje-step.js.map +1 -0
- package/dist/wje-stepper.js +231 -0
- package/dist/wje-stepper.js.map +1 -0
- package/dist/wje-store.js +401 -0
- package/dist/wje-store.js.map +1 -0
- package/dist/wje-tab-group.js +137 -0
- package/dist/wje-tab-group.js.map +1 -0
- package/dist/wje-tab-panel.js +46 -0
- package/dist/wje-tab-panel.js.map +1 -0
- package/dist/wje-tab.js +59 -0
- package/dist/wje-tab.js.map +1 -0
- package/dist/wje-textarea.js +373 -0
- package/dist/wje-textarea.js.map +1 -0
- package/dist/wje-thumbnail.js +54 -0
- package/dist/wje-thumbnail.js.map +1 -0
- package/dist/wje-toast.js +334 -0
- package/dist/wje-toast.js.map +1 -0
- package/dist/wje-toggle.js +125 -0
- package/dist/wje-toggle.js.map +1 -0
- package/dist/wje-toolbar-action.js +72 -0
- package/dist/wje-toolbar-action.js.map +1 -0
- package/dist/wje-toolbar.js +63 -0
- package/dist/wje-toolbar.js.map +1 -0
- package/dist/wje-tooltip.js +166 -0
- package/dist/wje-tooltip.js.map +1 -0
- package/dist/wje-visually-hidden.js +55 -0
- package/dist/wje-visually-hidden.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import WJElement, { event } from "./wje-element.js";
|
|
5
|
+
const styles = `/*
|
|
6
|
+
[ Checkbox ]
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
:host {
|
|
10
|
+
display: block;
|
|
11
|
+
margin-top: var(--wje-checkbox-margin-top);
|
|
12
|
+
margin-bottom: var(--wje-checkbox-margin-bottom);
|
|
13
|
+
margin-inline: var(--wje-checkbox-margin-inline);
|
|
14
|
+
line-height: 100%;
|
|
15
|
+
padding-left: 0;
|
|
16
|
+
|
|
17
|
+
label {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
position: relative;
|
|
22
|
+
padding-left: calc(var(--wje-checkbox-size) + 0.5rem);
|
|
23
|
+
/*min-width: var(--wje-checkbox-size);*/
|
|
24
|
+
min-height: var(--wje-checkbox-size);
|
|
25
|
+
margin-bottom: 0;
|
|
26
|
+
&:before {
|
|
27
|
+
content: '';
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: var(--wje-checkbox-size);
|
|
30
|
+
height: var(--wje-checkbox-size);
|
|
31
|
+
left: 0;
|
|
32
|
+
-webkit-box-sizing: inherit;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
background-color: var(--wje-color-contrast-0);
|
|
35
|
+
border-width: 1px;
|
|
36
|
+
border-style: solid;
|
|
37
|
+
border-color: var(--wje-color-contrast-3);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.native-checkbox {
|
|
43
|
+
label {
|
|
44
|
+
&:hover {
|
|
45
|
+
color: var(--wje-color-contrast-11);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:before {
|
|
49
|
+
border-radius: var(--wje-checkbox-border-radius);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
input[type='checkbox'] {
|
|
54
|
+
position: absolute;
|
|
55
|
+
margin: 0;
|
|
56
|
+
z-index: -1;
|
|
57
|
+
width: 16px;
|
|
58
|
+
height: 16px;
|
|
59
|
+
opacity: 0;
|
|
60
|
+
display: none;
|
|
61
|
+
& + label {
|
|
62
|
+
&::after {
|
|
63
|
+
content: '';
|
|
64
|
+
position: absolute;
|
|
65
|
+
left: 0;
|
|
66
|
+
border-right: 0 solid transparent;
|
|
67
|
+
border-bottom: 0 solid transparent;
|
|
68
|
+
width: var(--wje-checkbox-size);
|
|
69
|
+
height: var(--wje-checkbox-size);
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
input[type='checkbox']:checked + label::after {
|
|
76
|
+
content: '';
|
|
77
|
+
mask-image: var(--wje-checkbox-checkmark);
|
|
78
|
+
mask-size: var(--wje-checkbox-size);
|
|
79
|
+
background-color: var(--wje-color-primary-9);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Disabled */
|
|
83
|
+
input[type='checkbox'][disabled] {
|
|
84
|
+
& + label {
|
|
85
|
+
cursor: not-allowed !important;
|
|
86
|
+
color: var(--wje-color-contrast-8);
|
|
87
|
+
opacity: 0.58;
|
|
88
|
+
|
|
89
|
+
&:before {
|
|
90
|
+
background: var(--wje-color-contrast-2);
|
|
91
|
+
}
|
|
92
|
+
&:after {
|
|
93
|
+
background: transparent;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
input[type='checkbox']:checked[disabled] {
|
|
99
|
+
& + label {
|
|
100
|
+
cursor: not-allowed !important;
|
|
101
|
+
color: var(--wje-color-contrast-8);
|
|
102
|
+
opacity: 0.58;
|
|
103
|
+
|
|
104
|
+
&:before {
|
|
105
|
+
background: var(--wje-color-contrast-2);
|
|
106
|
+
}
|
|
107
|
+
&:after {
|
|
108
|
+
background: var(--wje-color-contrast-5);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* Indeterminate */
|
|
114
|
+
input[type='checkbox']:not(:checked):indeterminate {
|
|
115
|
+
& + label {
|
|
116
|
+
&:after {
|
|
117
|
+
content: '';
|
|
118
|
+
mask-image: var(--wje-checkbox-interminate);
|
|
119
|
+
mask-size: var(--wje-checkbox-size);
|
|
120
|
+
background-color: var(--wje-color-primary-9);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:host([variant='circle']) {
|
|
127
|
+
label {
|
|
128
|
+
&:after {
|
|
129
|
+
border-radius: 99px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&:before {
|
|
133
|
+
border-radius: 99px;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
:host([placement='end']) {
|
|
139
|
+
label {
|
|
140
|
+
padding-left: 0;
|
|
141
|
+
padding-right: 26px;
|
|
142
|
+
|
|
143
|
+
&:before {
|
|
144
|
+
right: 0;
|
|
145
|
+
left: auto;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
input[type='checkbox']:checked {
|
|
150
|
+
& + label {
|
|
151
|
+
position: relative;
|
|
152
|
+
|
|
153
|
+
&::after {
|
|
154
|
+
position: absolute;
|
|
155
|
+
right: 0;
|
|
156
|
+
left: auto;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/*Colors*/
|
|
163
|
+
|
|
164
|
+
:host([color='primary']) {
|
|
165
|
+
input[type='checkbox']:checked + label::after,
|
|
166
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
167
|
+
background-color: var(--wje-color-contrast-0);
|
|
168
|
+
}
|
|
169
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
170
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
171
|
+
border-color: var(--wje-color-primary-9);
|
|
172
|
+
background-color: var(--wje-color-primary-9);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:host([color='complete']) {
|
|
177
|
+
input[type='checkbox']:checked + label::after,
|
|
178
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
179
|
+
background-color: var(--wje-color-contrast-0);
|
|
180
|
+
}
|
|
181
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
182
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
183
|
+
border-color: var(--wje-color-complete-9);
|
|
184
|
+
background-color: var(--wje-color-complete-9);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
:host([color='success']) {
|
|
189
|
+
input[type='checkbox']:checked + label::after,
|
|
190
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
191
|
+
background-color: var(--wje-color-contrast-0);
|
|
192
|
+
}
|
|
193
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
194
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
195
|
+
border-color: var(--wje-color-success-9);
|
|
196
|
+
background-color: var(--wje-color-success-9);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
:host([color='warning']) {
|
|
201
|
+
input[type='checkbox']:checked + label::after,
|
|
202
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
203
|
+
background-color: var(--wje-color-contrast-0);
|
|
204
|
+
}
|
|
205
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
206
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
207
|
+
border-color: var(--wje-color-warning-9);
|
|
208
|
+
background-color: var(--wje-color-warning-9);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
:host([color='danger']) {
|
|
213
|
+
input[type='checkbox']:checked + label::after,
|
|
214
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
215
|
+
background-color: var(--wje-color-contrast-0);
|
|
216
|
+
}
|
|
217
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
218
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
219
|
+
border-color: var(--wje-color-danger-9);
|
|
220
|
+
background-color: var(--wje-color-danger-9);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
:host([color='info']) {
|
|
225
|
+
input[type='checkbox']:checked + label::after,
|
|
226
|
+
input[type='checkbox']:indeterminate + label:after {
|
|
227
|
+
background-color: var(--wje-color-contrast-0);
|
|
228
|
+
}
|
|
229
|
+
:is(input[type='checkbox']:checked + label)::before,
|
|
230
|
+
:is(input[type='checkbox']:indeterminate + label)::before {
|
|
231
|
+
border-color: var(--wje-color-info-9);
|
|
232
|
+
background-color: var(--wje-color-info-9);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/*input[type="checkbox"]:checked + label {*/
|
|
237
|
+
/* .info > *::after,*/
|
|
238
|
+
/* .danger > *::after,*/
|
|
239
|
+
/* .complete > *::after,*/
|
|
240
|
+
/* .primary > *::after,*/
|
|
241
|
+
/* .success > *::after {*/
|
|
242
|
+
/* background: var(--wje-white-check-icon);*/
|
|
243
|
+
/* }*/
|
|
244
|
+
/*}*/
|
|
245
|
+
|
|
246
|
+
/*input[type="checkbox"]:indeterminate + label {*/
|
|
247
|
+
/* .info > *::after,*/
|
|
248
|
+
/* .danger > *::after,*/
|
|
249
|
+
/* .complete > *::after,*/
|
|
250
|
+
/* .primary > *::after,*/
|
|
251
|
+
/* .success > *::after {*/
|
|
252
|
+
/* background-color: var(--wje-color-contrast-0);*/
|
|
253
|
+
/* }*/
|
|
254
|
+
/*}*/
|
|
255
|
+
|
|
256
|
+
/* hide focus style if not from keyboard navigation */
|
|
257
|
+
/*.js-focus-visible .native-checkbox input[type="checkbox"]:focus:not(.focus-visible) + label:before {*/
|
|
258
|
+
/* box-shadow: none;*/
|
|
259
|
+
/*}*/
|
|
260
|
+
|
|
261
|
+
/*input[type="checkbox"] {*/
|
|
262
|
+
/* accent-color: var(--wje-color-primary) !important;*/
|
|
263
|
+
/* font-size: 50px;*/
|
|
264
|
+
/*}*/
|
|
265
|
+
`;
|
|
266
|
+
class Checkbox extends WJElement {
|
|
267
|
+
/**
|
|
268
|
+
* Checkbox constructor method.
|
|
269
|
+
*/
|
|
270
|
+
constructor() {
|
|
271
|
+
super();
|
|
272
|
+
/**
|
|
273
|
+
* The class name for the Checkbox.
|
|
274
|
+
*/
|
|
275
|
+
__publicField(this, "className", "Checkbox");
|
|
276
|
+
this.internals = this.attachInternals();
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Setter for the value attribute.
|
|
280
|
+
* @param {string} value The value to set.
|
|
281
|
+
*/
|
|
282
|
+
set value(value) {
|
|
283
|
+
this.internals.setFormValue(value);
|
|
284
|
+
if (this.input) this.input.value = value;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Getter for the value attribute.
|
|
288
|
+
* @returns {string} The value of the attribute.
|
|
289
|
+
*/
|
|
290
|
+
get value() {
|
|
291
|
+
var _a;
|
|
292
|
+
return ((_a = this.input) == null ? void 0 : _a.value) || "";
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Getter for the customErrorDisplay attribute.
|
|
296
|
+
* @returns {boolean} Whether the attribute is present.
|
|
297
|
+
*/
|
|
298
|
+
get customErrorDisplay() {
|
|
299
|
+
return this.hasAttribute("custom-error-display");
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Getter for the validateOnChange attribute.
|
|
303
|
+
* @returns {boolean} Whether the attribute is present.
|
|
304
|
+
*/
|
|
305
|
+
get validateOnChange() {
|
|
306
|
+
return this.hasAttribute("validate-on-change");
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Setter for the invalid attribute.
|
|
310
|
+
* @param {boolean} isInvalid Whether the input is invalid.
|
|
311
|
+
*/
|
|
312
|
+
set invalid(isInvalid) {
|
|
313
|
+
if (isInvalid) this.setAttribute("invalid", "");
|
|
314
|
+
else this.removeAttribute("invalid");
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Getter for the invalid attribute.
|
|
318
|
+
* @returns {boolean} Whether the attribute is present.
|
|
319
|
+
*/
|
|
320
|
+
get invalid() {
|
|
321
|
+
return this.hasAttribute("invalid");
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Getter for the form attribute.
|
|
325
|
+
* @returns {HTMLFormElement} The form the input is associated with.
|
|
326
|
+
*/
|
|
327
|
+
get form() {
|
|
328
|
+
return this.internals.form;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Getter for the name attribute.
|
|
332
|
+
* @returns {string} The name of the input.
|
|
333
|
+
*/
|
|
334
|
+
get name() {
|
|
335
|
+
return this.getAttribute("name");
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Getter for the type attribute.
|
|
339
|
+
* @returns {string} The type of the input.
|
|
340
|
+
*/
|
|
341
|
+
get type() {
|
|
342
|
+
return this.localName;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Getter for the validity attribute.
|
|
346
|
+
* @returns {ValidityState} The validity state of the input.
|
|
347
|
+
*/
|
|
348
|
+
get validity() {
|
|
349
|
+
return this.internals.validity;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Getter for the validationMessage attribute.
|
|
353
|
+
* @returns {string} The validation message of the input.
|
|
354
|
+
*/
|
|
355
|
+
get validationMessage() {
|
|
356
|
+
return this.internals.validationMessage;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Getter for the willValidate attribute.
|
|
360
|
+
* @returns {boolean} Whether the input will be validated.
|
|
361
|
+
*/
|
|
362
|
+
get willValidate() {
|
|
363
|
+
return this.internals.willValidate;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Getter for the defaultValue attribute.
|
|
367
|
+
* This method retrieves the 'value' attribute of the custom input element.
|
|
368
|
+
* The 'value' attribute represents the default value of the input element.
|
|
369
|
+
* If the 'value' attribute is not set, it returns an empty string.
|
|
370
|
+
* @returns {string} The default value of the input element.
|
|
371
|
+
*/
|
|
372
|
+
get defaultValue() {
|
|
373
|
+
return this.getAttribute("value") ?? "";
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Setter for the defaultValue attribute.
|
|
377
|
+
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
378
|
+
* The 'value' attribute represents the default value of the input element.
|
|
379
|
+
* @param {string} value The value to set as the default value.
|
|
380
|
+
*/
|
|
381
|
+
set defaultValue(value) {
|
|
382
|
+
this.setAttribute("value", value);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Set checked attribute.
|
|
386
|
+
* @param {boolean} value true if the toggle is checked, false otherwise
|
|
387
|
+
*/
|
|
388
|
+
set disabled(value) {
|
|
389
|
+
if (value) this.setAttribute("disabled", "");
|
|
390
|
+
else this.removeAttribute("disabled");
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get disabled attribute value.
|
|
394
|
+
* @returns {boolean} true if the toggle is disabled, false otherwise
|
|
395
|
+
*/
|
|
396
|
+
get disabled() {
|
|
397
|
+
return this.hasAttribute("disabled");
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Set checked attribute.
|
|
401
|
+
* @param {boolean} value true if the toggle is checked, false otherwise
|
|
402
|
+
*/
|
|
403
|
+
set checked(value) {
|
|
404
|
+
if (value) this.setAttribute("checked", "");
|
|
405
|
+
else this.removeAttribute("checked");
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get checked attribute.
|
|
409
|
+
* @returns {boolean} true if the toggle is checked, false otherwise
|
|
410
|
+
*/
|
|
411
|
+
get checked() {
|
|
412
|
+
return this.hasAttribute("checked");
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Getter for the CSS stylesheet.
|
|
416
|
+
* @returns {string} The CSS stylesheet.
|
|
417
|
+
*/
|
|
418
|
+
static get cssStyleSheet() {
|
|
419
|
+
return styles;
|
|
420
|
+
}
|
|
421
|
+
static get observedAttributes() {
|
|
422
|
+
return ["checked", "disabled", "value"];
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Sets up the attributes for the checkbox.
|
|
426
|
+
*/
|
|
427
|
+
setupAttributes() {
|
|
428
|
+
this.isShadowRoot = "open";
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Draws the checkbox element.
|
|
432
|
+
* @returns {DocumentFragment} The created fragment.
|
|
433
|
+
*/
|
|
434
|
+
draw() {
|
|
435
|
+
let fragment = document.createDocumentFragment();
|
|
436
|
+
let native = document.createElement("div");
|
|
437
|
+
native.setAttribute("part", "native");
|
|
438
|
+
native.classList.add("native-checkbox");
|
|
439
|
+
let input = document.createElement("input");
|
|
440
|
+
input.type = "checkbox";
|
|
441
|
+
input.id = "checkbox";
|
|
442
|
+
input.name = this.name || "checkbox";
|
|
443
|
+
input.checked = this.hasAttribute("checked");
|
|
444
|
+
input.disabled = this.hasAttribute("disabled");
|
|
445
|
+
input.indeterminate = this.hasAttribute("indeterminate");
|
|
446
|
+
let label = document.createElement("label");
|
|
447
|
+
label.htmlFor = "checkbox";
|
|
448
|
+
label.innerHTML = "<slot></slot>";
|
|
449
|
+
native.appendChild(input);
|
|
450
|
+
native.appendChild(label);
|
|
451
|
+
this.input = input;
|
|
452
|
+
fragment.appendChild(native);
|
|
453
|
+
return fragment;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Adds an event listener after drawing the checkbox.
|
|
457
|
+
*/
|
|
458
|
+
afterDraw() {
|
|
459
|
+
if (!this.disabled) {
|
|
460
|
+
this.input.addEventListener("input", (e) => {
|
|
461
|
+
this.value = e.target.checked;
|
|
462
|
+
this.checked = e.target.checked;
|
|
463
|
+
event.dispatchCustomEvent(this, "wje-toggle:input");
|
|
464
|
+
});
|
|
465
|
+
this.input.addEventListener("change", (e) => {
|
|
466
|
+
this.value = e.target.checked;
|
|
467
|
+
this.checked = e.target.checked;
|
|
468
|
+
event.dispatchCustomEvent(this, "wje-toggle:change");
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Removes the event listener when the checkbox is disconnected.
|
|
474
|
+
*/
|
|
475
|
+
beforeDisconnect() {
|
|
476
|
+
event.removeElement(this.input);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* @summary Callback function that is called when the custom element is associated with a form.
|
|
480
|
+
* This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
|
|
481
|
+
* @param {HTMLFormElement} form The form the custom element is associated with.
|
|
482
|
+
*/
|
|
483
|
+
formAssociatedCallback(form) {
|
|
484
|
+
form == null ? void 0 : form.addEventListener("submit", () => {
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
|
|
489
|
+
* This method is responsible for resetting the value of the custom input element to its default value.
|
|
490
|
+
* It also resets the form value and validity state in the form internals.
|
|
491
|
+
* @function
|
|
492
|
+
*/
|
|
493
|
+
formResetCallback() {
|
|
494
|
+
this.value = this.defaultValue;
|
|
495
|
+
this.internals.setFormValue(this.defaultValue);
|
|
496
|
+
this.internals.setValidity({});
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
|
|
500
|
+
* This method is responsible for restoring the value of the custom input element to its saved state.
|
|
501
|
+
* It also restores the form value and validity state in the form internals to their saved states.
|
|
502
|
+
* @param {object} state The saved state of the custom input element.
|
|
503
|
+
* @function
|
|
504
|
+
*/
|
|
505
|
+
formStateRestoreCallback(state) {
|
|
506
|
+
this.value = state.value;
|
|
507
|
+
this.internals.setFormValue(state.value);
|
|
508
|
+
this.internals.setValidity({});
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
|
|
512
|
+
* This method is responsible for saving the value of the custom input element.
|
|
513
|
+
* @returns {object} The saved state of the custom input element.
|
|
514
|
+
* @function
|
|
515
|
+
*/
|
|
516
|
+
formStateSaveCallback() {
|
|
517
|
+
return {
|
|
518
|
+
value: this.value
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
|
|
523
|
+
* This method is not implemented yet.
|
|
524
|
+
* @param {boolean} disabled The new disabled state of the custom input element.
|
|
525
|
+
* @function
|
|
526
|
+
*/
|
|
527
|
+
formDisabledCallback(disabled) {
|
|
528
|
+
console.warn("formDisabledCallback not implemented yet");
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Whether the input is associated with a form.
|
|
533
|
+
* @type {boolean}
|
|
534
|
+
*/
|
|
535
|
+
__publicField(Checkbox, "formAssociated", true);
|
|
536
|
+
WJElement.define("wje-checkbox", Checkbox);
|
|
537
|
+
export {
|
|
538
|
+
Checkbox as default
|
|
539
|
+
};
|
|
540
|
+
//# sourceMappingURL=wje-checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-checkbox:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments WJElement\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n * //@fires wje-checkbox:change - Dispatched when the checkbox state changes;\n */\nexport default class Checkbox extends WJElement {\n /**\n * Checkbox constructor method.\n */\n constructor() {\n super();\n this.internals = this.attachInternals();\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.internals.setFormValue(value);\n\n if (this.input) this.input.value = value;\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.input?.value || '';\n }\n\n /**\n * Getter for the customErrorDisplay attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get customErrorDisplay() {\n return this.hasAttribute('custom-error-display');\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n /**\n * Setter for the invalid attribute.\n * @param {boolean} isInvalid Whether the input is invalid.\n */\n set invalid(isInvalid) {\n if (isInvalid) this.setAttribute('invalid', '');\n else this.removeAttribute('invalid');\n }\n\n /**\n * Getter for the invalid attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get invalid() {\n return this.hasAttribute('invalid');\n }\n\n /**\n * Getter for the form attribute.\n * @returns {HTMLFormElement} The form the input is associated with.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string} The name of the input.\n */\n get name() {\n return this.getAttribute('name');\n }\n\n /**\n * Getter for the type attribute.\n * @returns {string} The type of the input.\n */\n get type() {\n return this.localName;\n }\n\n /**\n * Getter for the validity attribute.\n * @returns {ValidityState} The validity state of the input.\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Getter for the validationMessage attribute.\n * @returns {string} The validation message of the input.\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Getter for the willValidate attribute.\n * @returns {boolean} Whether the input will be validated.\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n /**\n * Getter for the defaultValue attribute.\n * This method retrieves the 'value' attribute of the custom input element.\n * The 'value' attribute represents the default value of the input element.\n * If the 'value' attribute is not set, it returns an empty string.\n * @returns {string} The default value of the input element.\n */\n get defaultValue() {\n return this.getAttribute('value') ?? '';\n }\n\n /**\n * Setter for the defaultValue attribute.\n * This method sets the 'value' attribute of the custom input element to the provided value.\n * The 'value' attribute represents the default value of the input element.\n * @param {string} value The value to set as the default value.\n */\n set defaultValue(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set disabled(value) {\n if (value) this.setAttribute('disabled', '');\n else this.removeAttribute('disabled');\n }\n\n /**\n * Get disabled attribute value.\n * @returns {boolean} true if the toggle is disabled, false otherwise\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set checked(value) {\n if (value) this.setAttribute('checked', '');\n else this.removeAttribute('checked');\n }\n\n /**\n * Get checked attribute.\n * @returns {boolean} true if the toggle is checked, false otherwise\n */\n get checked() {\n return this.hasAttribute('checked');\n }\n\n /**\n * The class name for the Checkbox.\n */\n className = 'Checkbox';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n static get observedAttributes() {\n return ['checked', 'disabled', 'value'];\n }\n\n /**\n * Whether the input is associated with a form.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * Sets up the attributes for the checkbox.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the checkbox element.\n * @returns {DocumentFragment} The created fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-checkbox');\n\n let input = document.createElement('input');\n input.type = 'checkbox';\n input.id = 'checkbox';\n input.name = this.name || 'checkbox';\n input.checked = this.hasAttribute('checked');\n input.disabled = this.hasAttribute('disabled');\n input.indeterminate = this.hasAttribute('indeterminate');\n\n let label = document.createElement('label');\n label.htmlFor = 'checkbox';\n label.innerHTML = '<slot></slot>';\n\n native.appendChild(input);\n native.appendChild(label);\n\n this.input = input;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Adds an event listener after drawing the checkbox.\n */\n afterDraw() {\n if (!this.disabled) {\n this.input.addEventListener('input', (e) => {\n this.value = e.target.checked;\n this.checked = e.target.checked;\n event.dispatchCustomEvent(this, 'wje-toggle:input');\n });\n\n this.input.addEventListener('change', (e) => {\n this.value = e.target.checked;\n this.checked = e.target.checked;\n event.dispatchCustomEvent(this, 'wje-toggle:change');\n });\n }\n }\n\n /**\n * Removes the event listener when the checkbox is disconnected.\n */\n beforeDisconnect() {\n event.removeElement(this.input);\n }\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n form?.addEventListener('submit', () => {\n // this.validateInput();\n // this.propagateValidation();\n });\n }\n\n /**\n * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.\n * This method is responsible for resetting the value of the custom input element to its default value.\n * It also resets the form value and validity state in the form internals.\n * @function\n */\n formResetCallback() {\n // Set the value of the custom input element to its default value\n this.value = this.defaultValue;\n // Reset the form value in the form internals to the default value\n this.internals.setFormValue(this.defaultValue);\n // Reset the validity state in the form internals\n this.internals.setValidity({});\n }\n\n /**\n * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.\n * This method is responsible for restoring the value of the custom input element to its saved state.\n * It also restores the form value and validity state in the form internals to their saved states.\n * @param {object} state The saved state of the custom input element.\n * @function\n */\n formStateRestoreCallback(state) {\n // Set the value of the custom input element to its saved value\n this.value = state.value;\n // Restore the form value in the form internals to the saved value\n this.internals.setFormValue(state.value);\n // Restore the validity state in the form internals to the saved state\n this.internals.setValidity({});\n }\n\n /**\n * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.\n * This method is responsible for saving the value of the custom input element.\n * @returns {object} The saved state of the custom input element.\n * @function\n */\n formStateSaveCallback() {\n return {\n value: this.value,\n };\n }\n\n /**\n * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.\n * This method is not implemented yet.\n * @param {boolean} disabled The new disabled state of the custom input element.\n * @function\n */\n formDisabledCallback(disabled) {\n console.warn('formDisabledCallback not implemented yet');\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AQ,KAAK;AAElB,SAAK,UAAU,aAAa,KAAK,YAAY;AAE7C,SAAK,UAAU,YAAY,EAAE;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,yBAAyB,OAAO;AAE5B,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,aAAa,MAAM,KAAK;AAEvC,SAAK,UAAU,YAAY,EAAE;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,wBAAwB;AACpB,WAAO;AAAA,MACH,OAAO,KAAK;AAAA,IACf;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,qBAAqB,UAAU;AAC3B,YAAQ,KAAK,0CAA0C;AAAA,EAC/D;AACA;AAAA;AAAA;AAAA;AAAA;AApII,cAxLiB,UAwLV,kBAAiB;ACrM5B,UAAU,OAAO,gBAAgB,QAAQ;"}
|
package/dist/wje-chip.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import WJElement, { event } from "./wje-element.js";
|
|
5
|
+
const styles = "/*\n[ WJ Chip ]\n*/\n\n.native-chip {\n display: inline-flex;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n letter-spacing: -0.006em;\n margin: 0;\n padding: 0.5rem 0.75rem;\n text-align: center;\n cursor: pointer;\n white-space: nowrap;\n text-shadow: none;\n box-shadow: none;\n border: 0 none;\n line-height: 14px;\n min-height: 28px;\n height: 28px;\n width: 100%;\n max-width: fit-content;\n min-width: 28px;\n position: relative;\n transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);\n border-radius: var(--wje-border-radius-pill);\n overflow: hidden;\n vertical-align: middle;\n box-sizing: border-box;\n}\n\n:host(.focus) {\n box-shadow: none;\n}\n\n:host(.wje-active) .native-chip {\n border: 1px solid var(--wje-color-primary-11);\n background-color: var(--wje-color-contrast-3);\n color: var(--wje-color);\n}\n\n:host(:focus, :active:focus, .wje-active:focus) {\n outline: none !important;\n}\n\n.check {\n display: none;\n}\n\n:host([active]) {\n .check {\n display: block;\n margin-inline: 4px 0;\n }\n}\n\n:host([disabled]) {\n opacity: 0.5;\n border: 0;\n pointer-events: none;\n cursor: not-allowed;\n}\n\n::slotted(wje-avatar) {\n width: 22px;\n height: 22px;\n}\n\n::slotted(wje-avatar:first-child) {\n margin-inline: -8px 8px;\n margin-top: -4px;\n margin-bottom: -4px;\n}\n\n::slotted(wje-icon:first-child) {\n margin: -4px 8px -4px -4px;\n}\n\n::slotted(wje-icon:last-child) {\n margin: -4px -4px -4px 8px;\n}\n\nwje-button {\n --wje-button-border-radius: 50%;\n --wje-button-margin-inline: 0.25rem -0.5rem;\n --wje-padding-top: 0.15rem;\n --wje-padding-start: 0.15rem;\n --wje-padding-end: 0.15rem;\n --wje-padding-bottom: 0.15rem;\n}\n\n/*BG - TEXT*/\n.native-chip.wje-color-primary {\n background-color: var(--wje-color-primary-1);\n color: var(--wje-color-primary-9);\n}\n\n.native-chip.wje-color-complete {\n background-color: var(--wje-color-complete-1);\n color: var(--wje-color-complete-9);\n}\n\n.native-chip.wje-color-success {\n background-color: var(--wje-color-success-1);\n color: var(--wje-color-success-9);\n}\n\n.native-chip.wje-color-warning {\n background-color: var(--wje-color-warning-2);\n color: var(--wje-color-warning-11);\n}\n\n.native-chip.wje-color-danger {\n background-color: var(--wje-color-danger-1);\n color: var(--wje-color-danger-9);\n}\n\n.native-chip.wje-color-info {\n background-color: var(--wje-color-info-1);\n color: var(--wje-color-info-9);\n}\n\n.native-chip.wje-color-default {\n background-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n}\n\n/*HOVER*/\n@media (any-hover: hover) {\n .native-chip.wje-color-primary:hover {\n background-color: var(--wje-color-primary-4);\n color: var(--wje-color-primary-10);\n }\n\n .native-chip.wje-color-complete:hover {\n background-color: var(--wje-color-complete-4);\n color: var(--wje-color-complete-10);\n }\n\n .native-chip.wje-color-success:hover {\n background-color: var(--wje-color-success-4);\n color: var(--wje-color-success-10);\n }\n\n .native-chip.wje-color-warning:hover {\n background-color: var(--wje-color-warning-4);\n color: var(--wje-color-warning-11);\n }\n\n .native-chip.wje-color-danger:hover {\n background-color: var(--wje-color-danger-4);\n color: var(--wje-color-danger-10);\n }\n\n .native-chip.wje-color-info:hover {\n background-color: var(--wje-color-info-4);\n color: var(--wje-color-info-10);\n }\n\n .native-chip.wje-color-default:hover {\n background-color: var(--wje-color-contrast-4);\n color: var(--wje-color-contrast-11);\n }\n}\n";
|
|
6
|
+
class Chip extends WJElement {
|
|
7
|
+
/**
|
|
8
|
+
* Chip constructor method.
|
|
9
|
+
*/
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
/**
|
|
13
|
+
* Class name for the Chip element.
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
__publicField(this, "className", "Chip");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Getter for the CSS stylesheet.
|
|
20
|
+
* @returns {*}
|
|
21
|
+
*/
|
|
22
|
+
static get cssStyleSheet() {
|
|
23
|
+
return styles;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Getter for the observed attributes.
|
|
27
|
+
*/
|
|
28
|
+
setupAttributes() {
|
|
29
|
+
this.isShadowRoot = "open";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Draws the Chip element.
|
|
33
|
+
* @returns {DocumentFragment}
|
|
34
|
+
*/
|
|
35
|
+
draw() {
|
|
36
|
+
let fragment = document.createDocumentFragment();
|
|
37
|
+
let native = document.createElement("div");
|
|
38
|
+
native.classList.add("native-chip");
|
|
39
|
+
let slot = document.createElement("slot");
|
|
40
|
+
let remove = document.createElement("wje-button");
|
|
41
|
+
remove.setAttribute("part", "remove");
|
|
42
|
+
remove.setAttribute("fill", "link");
|
|
43
|
+
remove.setAttribute("color", this.color || "default");
|
|
44
|
+
remove.innerHTML = `<wje-icon name="x"></wje-icon>`;
|
|
45
|
+
let active = document.createElement("wje-icon");
|
|
46
|
+
active.setAttribute("name", "check");
|
|
47
|
+
active.classList.add("check");
|
|
48
|
+
if (this.hasAttribute("color")) native.classList.add("wje-color-" + this.color, "wje-color");
|
|
49
|
+
else native.classList.add("wje-color-default", "wje-color");
|
|
50
|
+
if (this.disabled) this.classList.add("wje-disabled");
|
|
51
|
+
if (this.outline) this.classList.add("wje-outline");
|
|
52
|
+
native.appendChild(slot);
|
|
53
|
+
native.appendChild(active);
|
|
54
|
+
if (this.hasAttribute("removable")) native.appendChild(remove);
|
|
55
|
+
fragment.appendChild(native);
|
|
56
|
+
this.removeElement = remove;
|
|
57
|
+
return fragment;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Getter for the observed attributes.
|
|
61
|
+
*/
|
|
62
|
+
afterDraw() {
|
|
63
|
+
event.addListener(this.removeElement, "click", "wje:chip-remove", null, { stopPropagation: true });
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Before disconnect event for the Chip element.
|
|
67
|
+
*/
|
|
68
|
+
beforeDisconnect() {
|
|
69
|
+
event.removeListener(this.removeElement, "click", "wje:chip-remove");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
WJElement.define("wje-chip", Chip);
|
|
73
|
+
export {
|
|
74
|
+
Chip as default
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=wje-chip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wje-chip.js","sources":["../packages/wje-chip/chip.element.js","../packages/wje-chip/chip.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-chip:remove\".\n * It is triggered when the remove button is clicked, which happens when the chip is removed.\n * The event is dispatched on the current instance of the Chip class.\n * @documentation https://elements.webjet.sk/components/chip\n * @status stable\n * @augments WJElement\n * @slot - The chip main content.\n * @csspart native - The component's native wrapper.\n * //@fires wje-chip:remove - Dispatched when the chip is removed;\n */\nexport default class Chip extends WJElement {\n /**\n * Chip constructor method.\n */\n constructor() {\n super();\n }\n\n /**\n * Class name for the Chip element.\n * @type {string}\n */\n className = 'Chip';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Chip element.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-chip');\n\n let slot = document.createElement('slot');\n\n let remove = document.createElement('wje-button');\n remove.setAttribute('part', 'remove');\n remove.setAttribute('fill', 'link');\n remove.setAttribute('color', this.color || 'default');\n remove.innerHTML = `<wje-icon name=\"x\"></wje-icon>`;\n\n let active = document.createElement('wje-icon');\n active.setAttribute('name', 'check');\n active.classList.add('check');\n\n // Add color\n if (this.hasAttribute('color')) native.classList.add('wje-color-' + this.color, 'wje-color');\n else native.classList.add('wje-color-default', 'wje-color');\n\n if (this.disabled) this.classList.add('wje-disabled');\n\n if (this.outline) this.classList.add('wje-outline');\n\n native.appendChild(slot);\n native.appendChild(active);\n\n if (this.hasAttribute('removable')) native.appendChild(remove);\n\n fragment.appendChild(native);\n\n this.removeElement = remove;\n return fragment;\n }\n\n /**\n * Getter for the observed attributes.\n */\n afterDraw() {\n event.addListener(this.removeElement, 'click', 'wje:chip-remove', null, { stopPropagation: true });\n }\n\n /**\n * Before disconnect event for the Chip element.\n */\n beforeDisconnect() {\n event.removeListener(this.removeElement, 'click', 'wje:chip-remove');\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Chip from './chip.element.js';\n\n// export * from \"./chip.element.js\";\nexport default Chip;\n\nWJElement.define('wje-chip', Chip);\n"],"names":[],"mappings":";;;;;AAce,MAAM,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,UAAU,IAAI,aAAa;AAElC,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,QAAI,SAAS,SAAS,cAAc,YAAY;AAChD,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,aAAa,QAAQ,MAAM;AAClC,WAAO,aAAa,SAAS,KAAK,SAAS,SAAS;AACpD,WAAO,YAAY;AAEnB,QAAI,SAAS,SAAS,cAAc,UAAU;AAC9C,WAAO,aAAa,QAAQ,OAAO;AACnC,WAAO,UAAU,IAAI,OAAO;AAG5B,QAAI,KAAK,aAAa,OAAO,EAAG,QAAO,UAAU,IAAI,eAAe,KAAK,OAAO,WAAW;AAAA,QACtF,QAAO,UAAU,IAAI,qBAAqB,WAAW;AAE1D,QAAI,KAAK,SAAU,MAAK,UAAU,IAAI,cAAc;AAEpD,QAAI,KAAK,QAAS,MAAK,UAAU,IAAI,aAAa;AAElD,WAAO,YAAY,IAAI;AACvB,WAAO,YAAY,MAAM;AAEzB,QAAI,KAAK,aAAa,WAAW,EAAG,QAAO,YAAY,MAAM;AAE7D,aAAS,YAAY,MAAM;AAE3B,SAAK,gBAAgB;AACrB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY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