@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,506 @@
1
+ import { css, LitElement, html, nothing } from 'lit';
2
+ import { classMap } from 'lit/directives/class-map.js';
3
+ import { styleMap } from 'lit/directives/style-map.js';
4
+ import { createRef, ref } from 'lit/directives/ref.js';
5
+ import { I as Icon } from './icon-b68c7e1e.js';
6
+ import { d as defineElement } from './defineElement-47d4f665.js';
7
+ import { d as defineButtonElements } from './Button-83c6df93.js';
8
+
9
+ var css_248z = css`:host {
10
+ margin-top: 16px;
11
+ display: flex;
12
+ justify-content: end;
13
+ font-family: var(--leu-font-regular);
14
+ }
15
+
16
+ .input {
17
+ width: 50px;
18
+ padding: 0;
19
+ border: 2px solid var(--leu-color-black-40);
20
+ border-radius: 2px;
21
+ color: var(--leu-color-black-transp-60);
22
+ text-align: center;
23
+ font-size: 16px;
24
+ font-style: normal;
25
+ font-weight: 400;
26
+ line-height: 24px;
27
+ outline-offset: 2px;
28
+ }
29
+
30
+ /* no arrows: Chrome, Safari, Edge, Opera */
31
+
32
+ .input::-webkit-outer-spin-button,
33
+ .input::-webkit-inner-spin-button {
34
+ -webkit-appearance: none;
35
+ appearance: none;
36
+ margin: 0;
37
+ }
38
+
39
+ /* no arrows: Firefox */
40
+
41
+ .input[type="number"] {
42
+ -webkit-appearance: textfield;
43
+ -moz-appearance: textfield;
44
+ appearance: textfield;
45
+ }
46
+
47
+ .input:focus,
48
+ .input:hover {
49
+ border-color: var(--leu-color-func-cyan);
50
+ outline: none;
51
+ }
52
+
53
+ .input:focus-visible {
54
+ outline: 2px solid var(--leu-color-func-cyan);
55
+ }
56
+
57
+ .label {
58
+ margin: 0 16px;
59
+ line-height: 50px;
60
+ color: var(--leu-color-black-transp-60);
61
+ white-space: nowrap;
62
+ }
63
+ `;
64
+
65
+ const MIN_PAGE = 1;
66
+
67
+ /**
68
+ * @tagname leu-pagination
69
+ */
70
+ class LeuPagination extends LitElement {
71
+ static styles = css_248z
72
+
73
+ static events = {
74
+ range: {},
75
+ }
76
+
77
+ static properties = {
78
+ page: { type: Number, reflect: true },
79
+ itemsOnAPage: { type: Number },
80
+ dataLength: { type: Number },
81
+
82
+ _minPage: { type: Number, state: true },
83
+ }
84
+
85
+ constructor() {
86
+ super();
87
+ /** @type {number} */
88
+ this.page = 1;
89
+ /** @type {number} */
90
+ this.dataLength = 0;
91
+ /** @type {number} */
92
+ this.itemsOnAPage = 30;
93
+ }
94
+
95
+ get maxPage() {
96
+ return Math.ceil(this.dataLength / this.itemsOnAPage)
97
+ }
98
+
99
+ get firstPage() {
100
+ return this.page === MIN_PAGE
101
+ }
102
+
103
+ get lastPage() {
104
+ return this.page === this.maxPage
105
+ }
106
+
107
+ holdInRange(value) {
108
+ return Math.min(Math.max(value, MIN_PAGE), this.maxPage)
109
+ }
110
+
111
+ numberUpdate(number) {
112
+ this.page = this.holdInRange(number);
113
+
114
+ const min = (this.page - 1) * this.itemsOnAPage;
115
+ const max = Math.min(min + this.itemsOnAPage, this.dataLength);
116
+ this.dispatchEvent(
117
+ new CustomEvent("range-updated", {
118
+ detail: {
119
+ min,
120
+ max,
121
+ },
122
+ bubbles: false,
123
+ })
124
+ );
125
+ }
126
+
127
+ change(event) {
128
+ // target.value = this.page // eslint-disable-line
129
+ this.numberUpdate(parseInt(event.target.value, 10) || 0);
130
+ }
131
+
132
+ input(event) {
133
+ if (event.target.value !== "") {
134
+ event.preventDefault();
135
+ this.change(event);
136
+ }
137
+ }
138
+
139
+ keydown(event) {
140
+ const specialKeys = [
141
+ "ArrowUp",
142
+ "ArrowDown",
143
+ "ArrowLeft",
144
+ "ArrowRight",
145
+ "Backspace",
146
+ "Enter",
147
+ "Tab",
148
+ ];
149
+ const numberKeys = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
150
+ if (!numberKeys.includes(event.key) && !specialKeys.includes(event.key)) {
151
+ event.preventDefault();
152
+ } else {
153
+ if (event.key === "ArrowUp") {
154
+ event.preventDefault();
155
+ this.numberUpdate(this.page + 1);
156
+ }
157
+ if (event.key === "ArrowDown") {
158
+ event.preventDefault();
159
+ this.numberUpdate(this.page - 1);
160
+ }
161
+ }
162
+ }
163
+
164
+ firstUpdated() {
165
+ this.numberUpdate(this.page);
166
+ }
167
+
168
+ requestUpdate(name, oldValue, newValue) {
169
+ if (name === "itemsOnAPage") {
170
+ this.numberUpdate(this.page);
171
+ }
172
+ return super.requestUpdate(name, oldValue, newValue)
173
+ }
174
+
175
+ render() {
176
+ return html`
177
+ <input
178
+ class="input"
179
+ .value=${this.page}
180
+ @input=${this.input}
181
+ @change=${this.change}
182
+ @keydown=${this.keydown}
183
+ type="number"
184
+ />
185
+ <div class="label">von ${this.maxPage}</div>
186
+ <leu-button
187
+ icon="angleLeft"
188
+ variant="secondary"
189
+ @click=${(_) => {
190
+ this.numberUpdate(this.page - 1);
191
+ }}
192
+ ?disabled=${this.firstPage}
193
+ ></leu-button>
194
+ <leu-button
195
+ icon="angleRight"
196
+ variant="secondary"
197
+ @click=${(_) => {
198
+ this.numberUpdate(this.page + 1);
199
+ }}
200
+ ?disabled=${this.lastPage}
201
+ style="margin-left:4px;"
202
+ ></leu-button>
203
+ `
204
+ }
205
+ }
206
+
207
+ function definePaginationElements() {
208
+ defineButtonElements();
209
+ defineElement("pagination", LeuPagination);
210
+ }
211
+
212
+ /**
213
+ * @tagname leu-table
214
+ */
215
+ class LeuTable extends LitElement {
216
+ static styles = css`
217
+ :host {
218
+ position: relative;
219
+ display: block;
220
+ }
221
+ div.scroll {
222
+ display: inline-block;
223
+ width: 100%;
224
+ overflow: auto;
225
+ }
226
+ div.shadow {
227
+ position: absolute;
228
+ left: 0;
229
+ top: 0;
230
+ width: 100%;
231
+ height: 100%;
232
+ pointer-events: none;
233
+ z-index: 1;
234
+ }
235
+ div.pagination {
236
+ height: calc(100% - 66px);
237
+ }
238
+ table {
239
+ width: 100%;
240
+ border-spacing: 0;
241
+ color: rgb(0 0 0 / 60%);
242
+ font-size: 16px;
243
+ font-family: var(--leu-font-regular);
244
+ line-height: 1.5;
245
+ }
246
+ td {
247
+ padding: 12px;
248
+ }
249
+ th {
250
+ padding: 16px 16px 8px;
251
+ text-align: left;
252
+ font-size: 12px;
253
+ font-weight: normal;
254
+ font-family: var(--leu-font-black);
255
+ background: var(--table-even-row-bg);
256
+ }
257
+ td:first-child,
258
+ th:first-child {
259
+ left: 0;
260
+ background: inherit;
261
+ z-index: 1;
262
+ }
263
+ tr {
264
+ background: #fff;
265
+ }
266
+ tbody tr:nth-child(odd) {
267
+ background: var(--leu-color-black-5);
268
+ }
269
+ button {
270
+ background: none;
271
+ cursor: pointer;
272
+ line-height: 1.5;
273
+ padding: 0;
274
+ border: 0;
275
+ width: 100%;
276
+ display: flex;
277
+ align-items: flex-center;
278
+ font-size: inherit;
279
+ font-family: inherit;
280
+ }
281
+ thead svg {
282
+ display: inline-block;
283
+ color: var(--leu-color-accent-blue);
284
+ padding: 0;
285
+ }
286
+
287
+ table.sticky td:first-child,
288
+ table.sticky th:first-child {
289
+ position: sticky;
290
+ }
291
+ div.shadow-left table.sticky td:first-child,
292
+ div.shadow-left table.sticky th:first-child {
293
+ box-shadow: 0 0 5px rgb(0 0 0 / 50%);
294
+ clip-path: inset(0 -15px 0 0);
295
+ }
296
+ div.shadow-left {
297
+ box-shadow: inset 5px 0 5px -5px rgb(0 0 0 / 50%);
298
+ }
299
+ div.shadow-right {
300
+ box-shadow: inset -5px 0 5px -5px rgb(0 0 0 / 50%);
301
+ }
302
+ `
303
+
304
+ static properties = {
305
+ columns: { type: Array },
306
+ data: { type: Array },
307
+ firstColumnSticky: { type: Boolean },
308
+ itemsOnAPage: { type: Number },
309
+ sortIndex: { type: Number },
310
+ sortOrderAsc: { type: Boolean },
311
+ width: { type: Number },
312
+
313
+ _shadowLeft: { type: Boolean, state: true },
314
+ _shadowRight: { type: Boolean, state: true },
315
+ _min: { type: Number, state: true },
316
+ _max: { type: Number, state: true },
317
+ }
318
+
319
+ constructor() {
320
+ super();
321
+ /** @type {array} */
322
+ this.columns = [];
323
+ /** @type {array} */
324
+ this.data = [];
325
+ /** @type {boolean} */
326
+ this.firstColumnSticky = false;
327
+ /** @type {number} */
328
+ this.itemsOnAPage = null;
329
+ /** @type {number} */
330
+ this.sortIndex = null;
331
+ /** @type {boolean} */
332
+ this.sortOrderAsc = false;
333
+ /** @type {number} */
334
+ this.width = null;
335
+
336
+ /** @internal */
337
+ this._sortArrowDown = Icon("arrowDown", 20);
338
+ /** @internal */
339
+ this._sortArrowUp = Icon("arrowUp", 20);
340
+ /** @internal */
341
+ this._shadowLeft = false;
342
+ /** @internal */
343
+ this._shadowRight = false;
344
+ /** @internal */
345
+ this._scrollRef = createRef();
346
+ /** @internal */
347
+ this._min = 0;
348
+ /** @internal */
349
+ this._max = null;
350
+ }
351
+
352
+ firstUpdated() {
353
+ this.shadowToggle(this._scrollRef.value);
354
+ }
355
+
356
+ shadowToggle(target) {
357
+ this._shadowLeft = target.scrollLeftMax > 0 && target.scrollLeft > 0;
358
+ this._shadowRight =
359
+ target.scrollLeftMax > 0 && target.scrollLeft < target.scrollLeftMax;
360
+ }
361
+
362
+ scrollEvent(event) {
363
+ this.shadowToggle(event.target);
364
+ }
365
+
366
+ isOnePropNotValid() {
367
+ if (!this._columns) {
368
+ return "Der Parameter 'columns' ist erforderlich !"
369
+ }
370
+ if (!this._sortedData) {
371
+ return "Der Parameter 'data' ist erforderlich !"
372
+ }
373
+ return null
374
+ }
375
+
376
+ isSorted(col) {
377
+ return this.sortIndex === this._columns.indexOf(col)
378
+ }
379
+
380
+ sortClick(col) {
381
+ const index = this._columns.indexOf(col);
382
+ if (this.sortIndex === index) {
383
+ this.sortOrderAsc = !this.sortOrderAsc;
384
+ } else {
385
+ this.sortIndex = index;
386
+ this.sortOrder = "asc";
387
+ }
388
+ }
389
+
390
+ sortArrowIcon() {
391
+ return html`${this.sortOrderAsc ? this._sortArrowDown : this._sortArrowUp}`
392
+ }
393
+
394
+ sortArrow(col) {
395
+ return html` ${this.isSorted(col) ? this.sortArrowIcon() : nothing} `
396
+ }
397
+
398
+ get _columns() {
399
+ return this.columns
400
+ }
401
+
402
+ get _sortedData() {
403
+ if (this.sortIndex === null || this.sortIndex === undefined) {
404
+ return this.data
405
+ }
406
+ const col = this._columns[this.sortIndex];
407
+ return this.data.sort(this.sortOrderAsc ? col.sort.asc : col.sort.desc)
408
+ }
409
+
410
+ get _data() {
411
+ return this.itemsOnAPage && this.itemsOnAPage > 0
412
+ ? this._sortedData.slice(this._min, this._max)
413
+ : this._sortedData
414
+ }
415
+
416
+ render() {
417
+ const scrollClasses = {
418
+ scroll: true,
419
+ "shadow-left": this.firstColumnSticky && this._shadowLeft,
420
+ };
421
+
422
+ const shadowClassesLeft = {
423
+ shadow: true,
424
+ "shadow-left": !this.firstColumnSticky && this._shadowLeft,
425
+ pagination: this.itemsOnAPage > 0,
426
+ };
427
+
428
+ const shadowClassesRight = {
429
+ shadow: true,
430
+ "shadow-right": this._shadowRight,
431
+ pagination: this.itemsOnAPage > 0,
432
+ };
433
+
434
+ const stickyClass = {
435
+ sticky: this.firstColumnSticky,
436
+ };
437
+
438
+ return html`
439
+ <div
440
+ class=${classMap(scrollClasses)}
441
+ @scroll="${this.scrollEvent}"
442
+ ref=${ref(this._scrollRef)}
443
+ >
444
+ <table class=${classMap(stickyClass)}>
445
+ <thead>
446
+ <tr>
447
+ ${this._columns.map(
448
+ (col) =>
449
+ html`<th>
450
+ ${col.sort
451
+ ? html`<button @click=${(_) => this.sortClick(col)}>
452
+ <span>${col.name}</span>
453
+ ${this.sortArrow(col)}
454
+ </button>`
455
+ : col.name}
456
+ </th>`
457
+ )}
458
+ </tr>
459
+ </thead>
460
+ <tbody>
461
+ ${this._data.map(
462
+ (row) =>
463
+ html`<tr>
464
+ ${this._columns.map(
465
+ (col) =>
466
+ html`<td
467
+ style=${col.style ? styleMap(col.style(row)) : nothing}
468
+ >
469
+ ${col.value(row)}
470
+ </td>`
471
+ )}
472
+ </tr>`
473
+ )}
474
+ </tbody>
475
+ </table>
476
+ <div class=${classMap(shadowClassesLeft)}></div>
477
+ <div class=${classMap(shadowClassesRight)}></div>
478
+ </div>
479
+
480
+ ${this.itemsOnAPage > 0
481
+ ? html`
482
+ <leu-pagination
483
+ .dataLength=${this._sortedData.length}
484
+ .itemsOnAPage=${this.itemsOnAPage}
485
+ @range-updated=${(e) => {
486
+ this._min = e.detail.min;
487
+ this._max = e.detail.max;
488
+ // after render
489
+ setTimeout(() => {
490
+ this.shadowToggle(this._scrollRef.value);
491
+ }, 0);
492
+ }}
493
+ >
494
+ </leu-pagination>
495
+ `
496
+ : nothing}
497
+ `
498
+ }
499
+ }
500
+
501
+ function defineTableElements() {
502
+ definePaginationElements();
503
+ defineElement("table", LeuTable);
504
+ }
505
+
506
+ export { LeuPagination as L, LeuTable as a, defineTableElements as b, definePaginationElements as d };
package/dist/Table.js ADDED
@@ -0,0 +1,8 @@
1
+ import 'lit';
2
+ import 'lit/directives/class-map.js';
3
+ import 'lit/directives/style-map.js';
4
+ import 'lit/directives/ref.js';
5
+ import './icon-b68c7e1e.js';
6
+ import './defineElement-47d4f665.js';
7
+ export { a as LeuTable, b as defineTableElements } from './Table-72d305d7.js';
8
+ import './Button-83c6df93.js';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Adds a definition for a custom element to the custom element
3
+ * registry if it isn't defined before. Prefixes the name with `leu-`.
4
+ * @param {string} name
5
+ * @param {HTMLElement} constructor
6
+ */
7
+ function defineElement(name, constructor) {
8
+ if (!customElements.get(`leu-${name}`)) {
9
+ customElements.define(`leu-${name}`, constructor);
10
+ } else {
11
+ console.info(`leu-${name} is already defined`);
12
+ }
13
+ }
14
+
15
+ export { defineElement as d };