@statistikzh/leu 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/.editorconfig +29 -0
  2. package/.eslintrc.json +27 -0
  3. package/.github/workflows/publish.yml +19 -0
  4. package/.github/workflows/release-please.yml +19 -0
  5. package/.github/workflows/test.yml +38 -0
  6. package/.husky/commit-msg +4 -0
  7. package/.husky/pre-commit +4 -0
  8. package/.prettierignore +1 -0
  9. package/.storybook/main.js +11 -0
  10. package/.storybook/preview-head.html +5 -0
  11. package/.storybook/preview.js +23 -0
  12. package/CHANGELOG.md +63 -0
  13. package/CODE_OF_CONDUCT.md +128 -0
  14. package/CONTRIBUTING.md +31 -0
  15. package/LICENSE +21 -0
  16. package/README.md +170 -0
  17. package/commitlint.config.cjs +1 -0
  18. package/dist/Button-83c6df93.js +403 -0
  19. package/dist/Checkbox.js +144 -0
  20. package/dist/CheckboxGroup.js +82 -0
  21. package/dist/Chip-60af1402.js +162 -0
  22. package/dist/ChipGroup.js +79 -0
  23. package/dist/ChipLink.js +46 -0
  24. package/dist/ChipRemovable.js +43 -0
  25. package/dist/ChipSelectable.js +92 -0
  26. package/dist/Input.js +686 -0
  27. package/dist/Radio.js +156 -0
  28. package/dist/RadioGroup.js +194 -0
  29. package/dist/Select.js +859 -0
  30. package/dist/Table-72d305d7.js +506 -0
  31. package/dist/Table.js +8 -0
  32. package/dist/defineElement-47d4f665.js +15 -0
  33. package/dist/icon-b68c7e1e.js +202 -0
  34. package/dist/index.js +21 -0
  35. package/dist/leu-checkbox-group.js +6 -0
  36. package/dist/leu-checkbox.js +6 -0
  37. package/dist/leu-chip-group.js +5 -0
  38. package/dist/leu-chip-link.js +6 -0
  39. package/dist/leu-chip-removable.js +7 -0
  40. package/dist/leu-chip-selectable.js +6 -0
  41. package/dist/leu-input.js +9 -0
  42. package/dist/leu-radio-group.js +6 -0
  43. package/dist/leu-radio.js +5 -0
  44. package/dist/leu-select.js +12 -0
  45. package/dist/leu-table.js +10 -0
  46. package/dist/theme.css +51 -0
  47. package/index.js +10 -0
  48. package/package.json +85 -0
  49. package/postcss.config.cjs +14 -0
  50. package/rollup.config.js +54 -0
  51. package/scripts/generate-component/generate.js +167 -0
  52. package/scripts/generate-component/templates/[Name].js +33 -0
  53. package/scripts/generate-component/templates/[name].css +11 -0
  54. package/scripts/generate-component/templates/[namespace]-[name].js +3 -0
  55. package/scripts/generate-component/templates/stories/[name].stories.js +13 -0
  56. package/scripts/generate-component/templates/test/[name].test.js +22 -0
  57. package/src/components/button/Button.js +150 -0
  58. package/src/components/button/button.css +232 -0
  59. package/src/components/button/leu-button.js +3 -0
  60. package/src/components/button/stories/button.stories.js +333 -0
  61. package/src/components/button/test/button.test.js +22 -0
  62. package/src/components/button-group/ButtonGroup.js +63 -0
  63. package/src/components/button-group/button-group.css +10 -0
  64. package/src/components/button-group/leu-button-group.js +3 -0
  65. package/src/components/button-group/stories/button-group.stories.js +41 -0
  66. package/src/components/button-group/test/button-group.test.js +22 -0
  67. package/src/components/checkbox/Checkbox.js +142 -0
  68. package/src/components/checkbox/CheckboxGroup.js +80 -0
  69. package/src/components/checkbox/leu-checkbox-group.js +3 -0
  70. package/src/components/checkbox/leu-checkbox.js +3 -0
  71. package/src/components/checkbox/stories/checkbox-group.stories.js +52 -0
  72. package/src/components/checkbox/stories/checkbox.stories.js +43 -0
  73. package/src/components/checkbox/test/checkbox.test.js +101 -0
  74. package/src/components/chip/Chip.js +24 -0
  75. package/src/components/chip/ChipGroup.js +71 -0
  76. package/src/components/chip/ChipLink.js +45 -0
  77. package/src/components/chip/ChipRemovable.js +42 -0
  78. package/src/components/chip/ChipSelectable.js +91 -0
  79. package/src/components/chip/chip-group.css +5 -0
  80. package/src/components/chip/chip.css +130 -0
  81. package/src/components/chip/exports.js +10 -0
  82. package/src/components/chip/leu-chip-group.js +3 -0
  83. package/src/components/chip/leu-chip-link.js +3 -0
  84. package/src/components/chip/leu-chip-removable.js +3 -0
  85. package/src/components/chip/leu-chip-selectable.js +3 -0
  86. package/src/components/chip/stories/chip-group.stories.js +99 -0
  87. package/src/components/chip/stories/chip-link.stories.js +37 -0
  88. package/src/components/chip/stories/chip-removable.stories.js +28 -0
  89. package/src/components/chip/stories/chip-selectable.stories.js +46 -0
  90. package/src/components/chip/test/chip.test.js +22 -0
  91. package/src/components/dropdown/Dropdown.js +55 -0
  92. package/src/components/dropdown/dropdown.css +17 -0
  93. package/src/components/dropdown/leu-dropdown.js +3 -0
  94. package/src/components/dropdown/stories/dropdown.stories.js +25 -0
  95. package/src/components/dropdown/test/dropdown.test.js +31 -0
  96. package/src/components/icon/icon.js +201 -0
  97. package/src/components/input/Input.js +421 -0
  98. package/src/components/input/input.css +231 -0
  99. package/src/components/input/leu-input.js +3 -0
  100. package/src/components/input/stories/input.stories.js +185 -0
  101. package/src/components/input/test/input.test.js +22 -0
  102. package/src/components/menu/Menu.js +18 -0
  103. package/src/components/menu/MenuItem.js +95 -0
  104. package/src/components/menu/leu-menu-item.js +3 -0
  105. package/src/components/menu/leu-menu.js +3 -0
  106. package/src/components/menu/menu-item.css +72 -0
  107. package/src/components/menu/menu.css +14 -0
  108. package/src/components/menu/stories/menu-item.stories.js +51 -0
  109. package/src/components/menu/stories/menu.stories.js +21 -0
  110. package/src/components/menu/test/menu.test.js +22 -0
  111. package/src/components/pagination/Pagination.js +152 -0
  112. package/src/components/pagination/leu-pagination.js +3 -0
  113. package/src/components/pagination/pagination.css +49 -0
  114. package/src/components/pagination/stories/pagination.stories.js +82 -0
  115. package/src/components/pagination/test/pagination.test.js +22 -0
  116. package/src/components/radio/Radio.js +62 -0
  117. package/src/components/radio/RadioGroup.js +193 -0
  118. package/src/components/radio/leu-radio-group.js +3 -0
  119. package/src/components/radio/leu-radio.js +3 -0
  120. package/src/components/radio/radio.css +76 -0
  121. package/src/components/radio/stories/radio-group.stories.js +49 -0
  122. package/src/components/radio/stories/radio.stories.js +48 -0
  123. package/src/components/radio/test/radio.test.js +38 -0
  124. package/src/components/select/Select.js +350 -0
  125. package/src/components/select/leu-select.js +3 -0
  126. package/src/components/select/select.css +215 -0
  127. package/src/components/select/stories/select.stories.js +302 -0
  128. package/src/components/select/test/select.test.js +29 -0
  129. package/src/components/table/Table.js +301 -0
  130. package/src/components/table/leu-table.js +3 -0
  131. package/src/components/table/stories/table.stories.js +116 -0
  132. package/src/components/table/test/table.test.js +36 -0
  133. package/src/lib/defineElement.js +13 -0
  134. package/src/lib/hasSlotController.js +85 -0
  135. package/src/styles/custom-media.css +5 -0
  136. package/src/styles/custom-properties.css +51 -0
  137. package/src/styles/theme.css +1 -0
  138. package/stat_zh.png +0 -0
  139. package/stylelint.config.mjs +21 -0
  140. package/web-dev-server-storybook.config.mjs +19 -0
  141. package/web-test-runner.config.mjs +49 -0
@@ -0,0 +1,403 @@
1
+ import { css, LitElement, html, nothing } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { I as Icon } from './icon-b68c7e1e.js';
4
+ import { d as defineElement } from './defineElement-47d4f665.js';
5
+
6
+ var css_248z = css`:host {
7
+ display: inline-block;
8
+ }
9
+
10
+ button {
11
+ font-family: var(--leu-font-black);
12
+ text-align: center;
13
+ -webkit-appearance: none;
14
+ -moz-appearance: none;
15
+ appearance: none;
16
+ transition: background 0.1s ease;
17
+ cursor: pointer;
18
+ border: 1px solid transparent;
19
+ border-radius: 2px;
20
+ display: flex;
21
+ align-items: center;
22
+ -moz-column-gap: 8px;
23
+ column-gap: 8px;
24
+ }
25
+
26
+ button.round {
27
+ border-radius: 50%;
28
+ }
29
+
30
+ button:disabled {
31
+ cursor: not-allowed;
32
+ }
33
+
34
+ button:focus-visible {
35
+ border: 1px solid var(--leu-color-black-0);
36
+ outline: 2px solid var(--leu-color-func-cyan);
37
+ }
38
+
39
+ button.inverted:focus-visible {
40
+ border: 1px solid var(--leu-color-black-100);
41
+ outline: 2px solid var(--leu-color-black-0);
42
+ }
43
+
44
+ :host([fluid]) button {
45
+ width: 100%;
46
+ justify-content: center;
47
+ }
48
+
49
+ /* size - normal */
50
+
51
+ button.normal {
52
+ padding: 12px 24px;
53
+ font-size: 16px;
54
+ line-height: 24px;
55
+ }
56
+
57
+ button.normal.icon {
58
+ padding: 12px;
59
+ }
60
+
61
+ /* size - small */
62
+
63
+ button.small {
64
+ padding: 6px 24px;
65
+ font-size: 14px;
66
+ line-height: 20px;
67
+ }
68
+
69
+ button.small.icon {
70
+ padding: 8px;
71
+ }
72
+
73
+ /* primary */
74
+
75
+ button.primary {
76
+ color: var(--leu-color-black-0);
77
+ background: var(--leu-color-black-100);
78
+ }
79
+
80
+ button.primary:hover {
81
+ color: var(--leu-color-black-0);
82
+ background: var(--leu-color-black-transp-80);
83
+ }
84
+
85
+ button.primary.active {
86
+ color: var(--leu-color-black-0);
87
+ background: var(--leu-color-black-100);
88
+ }
89
+
90
+ button.primary:disabled {
91
+ color: var(--leu-color-black-0);
92
+ background: var(--leu-color-black-transp-20);
93
+ }
94
+
95
+ /* secondary */
96
+
97
+ button.secondary {
98
+ color: var(--leu-color-black-transp-60);
99
+ background: var(--leu-color-black-transp-10);
100
+ }
101
+
102
+ button.secondary:hover {
103
+ color: var(--leu-color-black-100);
104
+ background: var(--leu-color-black-transp-20);
105
+ }
106
+
107
+ button.secondary.active {
108
+ color: var(--leu-color-black-0);
109
+ background: var(--leu-color-black-100);
110
+ }
111
+
112
+ button.secondary:disabled {
113
+ color: var(--leu-color-black-transp-20);
114
+ background: var(--leu-color-black-transp-5);
115
+ }
116
+
117
+ /* ghost */
118
+
119
+ button.ghost {
120
+ background: transparent;
121
+ padding: 0 0.5rem;
122
+ color: var(--leu-color-black-60);
123
+ font-family: var(--leu-font-regular);
124
+ }
125
+
126
+ button.ghost:hover {
127
+ color: var(--leu-color-black-100);
128
+ }
129
+
130
+ button.ghost.active {
131
+ color: var(--leu-color-black-100);
132
+ }
133
+
134
+ button.ghost:disabled {
135
+ color: var(--leu-color-black-20);
136
+ }
137
+
138
+ /* primary + inverted */
139
+
140
+ button.primary.inverted {
141
+ color: var(--leu-color-black-100);
142
+ background: var(--leu-color-black-0);
143
+ }
144
+
145
+ button.primary.inverted:hover {
146
+ color: var(--leu-color-black-100);
147
+ background: var(--leu-color-white-transp-70);
148
+ }
149
+
150
+ button.primary.inverted.active {
151
+ color: var(--leu-color-black-0);
152
+ background: var(--leu-color-black-100);
153
+ }
154
+
155
+ button.primary.inverted:disabled {
156
+ color: var(--leu-color-black-40);
157
+ background: var(--leu-color-white-transp-70);
158
+ }
159
+
160
+ /* secondary + inverted */
161
+
162
+ button.secondary.inverted {
163
+ color: var(--leu-color-black-0);
164
+ background: var(--leu-color-black-transp-20);
165
+ }
166
+
167
+ button.secondary.inverted:hover {
168
+ color: var(--leu-color-black-0);
169
+ background: var(--leu-color-black-transp-40);
170
+ }
171
+
172
+ button.secondary.inverted.active {
173
+ color: var(--leu-color-black-100);
174
+ background: var(--leu-color-black-0);
175
+ }
176
+
177
+ button.secondary.inverted:disabled {
178
+ color: var(--leu-color-white-transp-70);
179
+ background: var(--leu-color-black-transp-10);
180
+ }
181
+
182
+ /* ghost + inverted */
183
+
184
+ button.ghost.inverted {
185
+ color: var(--leu-color-black-0);
186
+ }
187
+
188
+ button.ghost.inverted:hover {
189
+ color: var(--leu-color-white-transp-70);
190
+ }
191
+
192
+ button.ghost.inverted.active {
193
+ color: var(--leu-color-black-0);
194
+ }
195
+
196
+ button.ghost.inverted:disabled {
197
+ color: var(--leu-color-black-20);
198
+ }
199
+
200
+ /* icon-wrapper */
201
+
202
+ .icon-wrapper svg {
203
+ display: block;
204
+ }
205
+
206
+ .ghost .icon-wrapper--before, .ghost .icon-wrapper--after {
207
+ padding: 0.5rem;
208
+ border-radius: 50%;
209
+ background: var(--leu-color-black-transp-10);
210
+ }
211
+
212
+ .ghost.active .icon-wrapper--before, .ghost.active .icon-wrapper--after {
213
+ background: var(--leu-color-black-100);
214
+ color: var(--leu-color-black-0);
215
+ }
216
+
217
+ .ghost:disabled .icon-wrapper--before {
218
+ background: var(--leu-color-black-transp-5);
219
+ }
220
+
221
+ .ghost:disabled .icon-wrapper--after {
222
+ background: var(--leu-color-black-transp-5);
223
+ }
224
+
225
+ /* inverted */
226
+
227
+ .ghost.inverted .icon-wrapper--before, .ghost.inverted .icon-wrapper--after {
228
+ background: var(--leu-color-black-transp-20);
229
+ }
230
+
231
+ .ghost.inverted:hover .icon-wrapper--before, .ghost.inverted:hover .icon-wrapper--after {
232
+ background: var(--leu-color-black-transp-40);
233
+ color: var(--leu-color-black-0);
234
+ }
235
+
236
+ .ghost.inverted:disabled .icon-wrapper--before {
237
+ background: var(--leu-color-black-transp-20);
238
+ color: var(--leu-color-white-transp-70);
239
+ }
240
+
241
+ .ghost.inverted:disabled .icon-wrapper--after {
242
+ background: var(--leu-color-black-transp-20);
243
+ color: var(--leu-color-white-transp-70);
244
+ }
245
+
246
+ .ghost.active.inverted .icon-wrapper--before, .ghost.active.inverted .icon-wrapper--after {
247
+ background: var(--leu-color-black-0);
248
+ color: var(--leu-color-black-100);
249
+ }
250
+
251
+ /* Expanded icon */
252
+
253
+ .icon-wrapper--expanded {
254
+ transition: transform 0.1s ease;
255
+ }
256
+
257
+ :host([expanded="open"]) .icon-wrapper--expanded {
258
+ transform: rotate(180deg);
259
+ }
260
+ `;
261
+
262
+ /*
263
+ Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=4-1444&mode=design&t=xu5Vii8jXKKCKDez-0
264
+ Live Demo: zh.ch
265
+ */
266
+
267
+ const BUTTON_VARIANTS = ["primary", "secondary", "ghost"];
268
+ Object.freeze(BUTTON_VARIANTS);
269
+
270
+ const BUTTON_SIZES = ["normal", "small"];
271
+ Object.freeze(BUTTON_SIZES);
272
+
273
+ const BUTTON_TYPES = ["button", "submit", "reset"];
274
+ Object.freeze(BUTTON_TYPES);
275
+
276
+ const BUTTON_EXPANDED_OPTIONS = ["open", "closed"];
277
+ Object.freeze(BUTTON_EXPANDED_OPTIONS);
278
+
279
+ /**
280
+ * @tagname leu-button
281
+ */
282
+ class LeuButton extends LitElement {
283
+ static styles = css_248z
284
+
285
+ /**
286
+ * @internal
287
+ */
288
+ static shadowRootOptions = {
289
+ ...LitElement.shadowRootOptions,
290
+ delegatesFocus: true,
291
+ }
292
+
293
+ static properties = {
294
+ label: { type: String },
295
+ icon: { type: String },
296
+ iconAfter: { type: String },
297
+ size: { type: String },
298
+ variant: { type: String },
299
+ type: { type: String },
300
+
301
+ disabled: { type: Boolean },
302
+ round: { type: Boolean },
303
+ active: { type: Boolean },
304
+ inverted: { type: Boolean },
305
+ expanded: { type: String },
306
+ fluid: { type: Boolean },
307
+ }
308
+
309
+ constructor() {
310
+ super();
311
+ /** @type {string} */
312
+ this.label = null;
313
+ /** @type {string} */
314
+ this.icon = null;
315
+ /** @type {string} - Only taken into account if Label and no Icon is set */
316
+ this.iconAfter = null;
317
+ /** @type {string} */
318
+ this.size = "normal";
319
+ /** @type {string} */
320
+ this.variant = "primary";
321
+ /** @type {string} */
322
+ this.type = "button";
323
+
324
+ /** @type {boolean} */
325
+ this.disabled = false;
326
+ /** @type {boolean} - Only taken into account if no Label and an Icon is set */
327
+ this.round = false;
328
+ /** @type {boolean} */
329
+ this.active = false;
330
+ /** @type {boolean} - will be used on dark Background */
331
+ this.inverted = false;
332
+
333
+ /** @type {boolean} - Alters the shape of the button to be full width of its parent container */
334
+ this.fluid = false;
335
+
336
+ /**
337
+ * Only taken into account if variant is "ghost"
338
+ * @type {("open" | "closed" | undefined)}
339
+ */
340
+ this.expanded = undefined;
341
+ }
342
+
343
+ getIconSize() {
344
+ return this.size === "small" || this.variant === "ghost" ? 16 : 24
345
+ }
346
+
347
+ renderIconBefore() {
348
+ if (this.icon) {
349
+ return html`<div class="icon-wrapper icon-wrapper--before">
350
+ ${Icon(this.icon, this.getIconSize())}
351
+ </div>`
352
+ }
353
+
354
+ return nothing
355
+ }
356
+
357
+ renderIconAfter() {
358
+ if (this.iconAfter && this.label && !this.icon) {
359
+ return html`<div class="icon-wrapper icon-wrapper--after">
360
+ ${Icon(this.iconAfter, this.getIconSize())}
361
+ </div>`
362
+ }
363
+
364
+ return nothing
365
+ }
366
+
367
+ renderExpandingIcon() {
368
+ if (typeof this.expanded !== "undefined" && this.variant === "ghost") {
369
+ return html`<div class="icon-wrapper icon-wrapper--expanded">
370
+ ${Icon("angleDropDown", 24)}
371
+ </div>`
372
+ }
373
+
374
+ return nothing
375
+ }
376
+
377
+ render() {
378
+ const cssClasses = {
379
+ icon: !this.label && this.icon && !this.iconAfter,
380
+ round: !this.label && this.icon && !this.iconAfter && this.round,
381
+ active: this.active,
382
+ inverted: this.inverted,
383
+ [this.variant]: true,
384
+ [this.size]: true,
385
+ };
386
+ return html`
387
+ <button
388
+ class=${classMap(cssClasses)}
389
+ ?disabled=${this.disabled}
390
+ type=${this.type}
391
+ >
392
+ ${this.renderIconBefore()} ${this.label} ${this.renderIconAfter()}
393
+ ${this.renderExpandingIcon()}
394
+ </button>
395
+ `
396
+ }
397
+ }
398
+
399
+ function defineButtonElements() {
400
+ defineElement("button", LeuButton);
401
+ }
402
+
403
+ export { BUTTON_VARIANTS as B, LeuButton as L, BUTTON_SIZES as a, BUTTON_TYPES as b, BUTTON_EXPANDED_OPTIONS as c, defineButtonElements as d };
@@ -0,0 +1,144 @@
1
+ import { LitElement, css, html } from 'lit';
2
+ import { I as Icon } from './icon-b68c7e1e.js';
3
+ import { d as defineElement } from './defineElement-47d4f665.js';
4
+
5
+ /**
6
+ * @tagname leu-checkbox
7
+ */
8
+ class LeuCheckbox extends LitElement {
9
+ static styles = css`
10
+ :host {
11
+ --checkbox-color: var(--leu-color-black-40);
12
+ --checkbox-color-disabled: var(--leu-color-black-20);
13
+ --checkbox-color-focus: var(--leu-color-func-cyan);
14
+
15
+ --checkbox-label-color: var(--leu-color-black-100);
16
+ --checkbox-label-color-disabled: var(--checkbox-color-disabled);
17
+
18
+ --checkbox-tick-color: var(--leu-color-black-0);
19
+
20
+ --checkbox-font-regular: var(--leu-font-regular);
21
+
22
+ position: relative;
23
+
24
+ display: inline-flex;
25
+ align-items: flex-start;
26
+ gap: 0.5rem;
27
+
28
+ font-family: var(--checkbox-font-regular);
29
+ }
30
+
31
+ .checkbox {
32
+ --_length: 1.5rem;
33
+ appearance: none;
34
+ cursor: pointer;
35
+
36
+ width: var(--_length);
37
+ height: var(--_length);
38
+ margin: 0;
39
+
40
+ border: 2px solid var(--checkbox-color);
41
+ border-radius: 2px;
42
+
43
+ flex: 1 0 var(--_length);
44
+
45
+ display: grid;
46
+ place-items: center;
47
+ }
48
+
49
+ .checkbox:checked {
50
+ background-color: var(--checkbox-color);
51
+ }
52
+
53
+ .checkbox:is(:hover, :checked, :focus) {
54
+ --checkbox-color: var(--checkbox-color-focus);
55
+ }
56
+
57
+ .checkbox:focus-visible {
58
+ outline: 2px solid var(--checkbox-color-focus);
59
+ outline-offset: 2px;
60
+ }
61
+
62
+ .checkbox:disabled {
63
+ --checkbox-color: var(--checkbox-color-disabled);
64
+ cursor: not-allowed;
65
+ }
66
+
67
+ .label {
68
+ cursor: pointer;
69
+ color: var(--checkbox-label-color);
70
+ font-size: 1rem;
71
+ line-height: 1.5;
72
+ }
73
+
74
+ .checkbox:disabled + .label {
75
+ --checkbox-label-color: var(--checkbox-label-color-disabled);
76
+ cursor: not-allowed;
77
+ }
78
+
79
+ .icon {
80
+ position: absolute;
81
+ top: 0;
82
+ left: 0;
83
+ color: var(--checkbox-tick-color);
84
+ pointer-events: none;
85
+ }
86
+ `
87
+
88
+ static shadowRootOptions = {
89
+ ...LitElement.shadowRootOptions,
90
+ delegatesFocus: true,
91
+ }
92
+
93
+ static properties = {
94
+ checked: { type: Boolean, reflect: true },
95
+ disabled: { type: Boolean, reflect: true },
96
+ identifier: { type: String },
97
+ value: { type: String },
98
+ name: { type: String },
99
+ }
100
+
101
+ constructor() {
102
+ super();
103
+ this.checked = false;
104
+ this.disabled = false;
105
+ this.tabIndex = 0;
106
+
107
+ this.checkIcon = Icon("check");
108
+ }
109
+
110
+ handleChange(event) {
111
+ this.checked = event.target.checked;
112
+
113
+ const customEvent = new CustomEvent(event.type, event);
114
+ this.dispatchEvent(customEvent);
115
+ }
116
+
117
+ handleInput(event) {
118
+ this.checked = event.target.checked;
119
+ }
120
+
121
+ render() {
122
+ return html`
123
+ <input
124
+ id=${this.identifier}
125
+ class="checkbox"
126
+ type="checkbox"
127
+ name="${this.name}"
128
+ @change=${this.handleChange}
129
+ @input=${this.handleInput}
130
+ .checked=${this.checked}
131
+ ?disabled=${this.disabled}
132
+ .value=${this.value}
133
+ />
134
+ <label for=${this.identifier} class="label"><slot></slot></label>
135
+ <div class="icon">${this.checkIcon}</div>
136
+ `
137
+ }
138
+ }
139
+
140
+ function defineCheckboxElements() {
141
+ defineElement("checkbox", LeuCheckbox);
142
+ }
143
+
144
+ export { LeuCheckbox, defineCheckboxElements };
@@ -0,0 +1,82 @@
1
+ import { LitElement, css, html } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { d as defineElement } from './defineElement-47d4f665.js';
4
+
5
+ /**
6
+ * @tagname leu-checkbox-group
7
+ */
8
+ class LeuCheckboxGroup extends LitElement {
9
+ static styles = css`
10
+ :host {
11
+ --group-font-regular: var(--leu-font-regular);
12
+ --group-font-black: var(--leu-font-black);
13
+
14
+ font-family: var(--group-font-regular);
15
+ }
16
+
17
+ .fieldset {
18
+ display: flex;
19
+ align-items: flex-start;
20
+ flex-wrap: wrap;
21
+ gap: 0.5rem 1rem;
22
+
23
+ border: none;
24
+ padding: 0;
25
+ }
26
+
27
+ .fieldset--vertical {
28
+ flex-direction: column;
29
+ gap: 1rem;
30
+ }
31
+
32
+ .legend {
33
+ font-family: var(--group-font-black);
34
+ font-size: 1.125rem;
35
+ line-height: 1.5;
36
+
37
+ margin-bottom: 0.5rem;
38
+ }
39
+ `
40
+
41
+ static properties = {
42
+ orientation: { type: String },
43
+ }
44
+
45
+ constructor() {
46
+ super();
47
+ this.orientation = "HORIZONTAL";
48
+ this.items = [];
49
+ }
50
+
51
+ get value() {
52
+ return this.items.filter((i) => i.checked).map((i) => i.value)
53
+ }
54
+
55
+ handleSlotChange() {
56
+ this.handleItems();
57
+ }
58
+
59
+ handleItems() {
60
+ this.items = [...this.querySelectorAll(":scope > *:not([slot])")];
61
+ }
62
+
63
+ render() {
64
+ const fieldsetClasses = {
65
+ fieldset: "true",
66
+ "fieldset--vertical": this.orientation === "VERTICAL",
67
+ };
68
+
69
+ return html`
70
+ <fieldset class=${classMap(fieldsetClasses)}>
71
+ <legend class="legend"><slot name="legend"></slot></legend>
72
+ <slot @slotchange=${this.handleSlotChange}></slot>
73
+ </fieldset>
74
+ `
75
+ }
76
+ }
77
+
78
+ function defineCheckboxGroupElements() {
79
+ defineElement("checkbox-group", LeuCheckboxGroup);
80
+ }
81
+
82
+ export { LeuCheckboxGroup, defineCheckboxGroupElements };