@statistikzh/leu 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/deploy-github-pages.yaml +33 -0
- package/.storybook/main.js +27 -1
- package/.storybook/manager-head.html +1 -0
- package/.storybook/manager.js +9 -0
- package/.storybook/preview-head.html +1 -1
- package/.storybook/preview.js +59 -5
- package/.storybook/static/logo.svg +19 -0
- package/.storybook/theme.js +7 -0
- package/CHANGELOG.md +43 -0
- package/README.md +1 -1
- package/dist/Button.js +39 -30
- package/dist/ButtonGroup.js +5 -7
- package/dist/Checkbox.js +107 -88
- package/dist/CheckboxGroup.js +43 -38
- package/dist/{Chip-389013ff.js → Chip-dac7337d.js} +7 -2
- package/dist/ChipGroup.js +4 -6
- package/dist/ChipLink.js +6 -8
- package/dist/ChipRemovable.js +4 -7
- package/dist/ChipSelectable.js +10 -10
- package/dist/Dropdown.js +57 -27
- package/dist/Input.js +59 -43
- package/dist/Menu.js +2 -5
- package/dist/MenuItem.js +34 -17
- package/dist/Pagination.js +57 -55
- package/dist/Radio.js +13 -10
- package/dist/RadioGroup.js +43 -40
- package/dist/Select.js +57 -44
- package/dist/Table.js +147 -125
- package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
- package/dist/defineElement-47d4f665.js +15 -0
- package/dist/index.js +29 -19
- package/dist/leu-button-group.js +7 -3
- package/dist/leu-button.js +6 -3
- package/dist/leu-checkbox-group.js +6 -3
- package/dist/leu-checkbox.js +6 -3
- package/dist/leu-chip-group.js +6 -3
- package/dist/leu-chip-link.js +7 -4
- package/dist/leu-chip-removable.js +7 -4
- package/dist/leu-chip-selectable.js +7 -4
- package/dist/leu-dropdown.js +13 -3
- package/dist/leu-input.js +7 -3
- package/dist/leu-menu-item.js +8 -3
- package/dist/leu-menu.js +6 -3
- package/dist/leu-pagination.js +8 -3
- package/dist/leu-popup-4bf6f1f4.js +216 -0
- package/dist/leu-radio-group.js +6 -3
- package/dist/leu-radio.js +6 -3
- package/dist/leu-select.js +14 -3
- package/dist/leu-table.js +9 -3
- package/package.json +29 -12
- package/scripts/generate-component/templates/[Name].js +0 -5
- package/scripts/generate-component/templates/[name].css +1 -1
- package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
- package/src/components/accordion/Accordion.js +3 -9
- package/src/components/accordion/leu-accordion.js +5 -2
- package/src/components/accordion/stories/accordion.stories.js +7 -4
- package/src/components/accordion/test/accordion.test.js +92 -2
- package/src/components/breadcrumb/Breadcrumb.js +310 -0
- package/src/components/breadcrumb/breadcrumb.css +114 -0
- package/src/components/breadcrumb/leu-breadcrumb.js +6 -0
- package/src/components/breadcrumb/stories/breadcrumb.stories.js +73 -0
- package/src/components/breadcrumb/test/breadcrumb.test.js +141 -0
- package/src/components/button/Button.js +22 -27
- package/src/components/button/button.css +3 -3
- package/src/components/button/leu-button.js +5 -2
- package/src/components/button/stories/button.stories.js +58 -37
- package/src/components/button/test/button.test.js +112 -2
- package/src/components/button-group/ButtonGroup.js +1 -7
- package/src/components/button-group/leu-button-group.js +5 -2
- package/src/components/button-group/stories/button-group.stories.js +6 -0
- package/src/components/button-group/test/button-group.test.js +79 -3
- package/src/components/checkbox/Checkbox.js +9 -89
- package/src/components/checkbox/CheckboxGroup.js +9 -39
- package/src/components/checkbox/checkbox-group.css +29 -0
- package/src/components/checkbox/checkbox.css +76 -0
- package/src/components/checkbox/leu-checkbox-group.js +5 -2
- package/src/components/checkbox/leu-checkbox.js +5 -2
- package/src/components/checkbox/stories/checkbox-group.stories.js +44 -21
- package/src/components/checkbox/stories/checkbox.stories.js +7 -1
- package/src/components/checkbox/test/checkbox-group.test.js +124 -0
- package/src/components/checkbox/test/checkbox.test.js +72 -59
- package/src/components/chip/Chip.js +2 -1
- package/src/components/chip/ChipGroup.js +1 -6
- package/src/components/chip/ChipLink.js +2 -8
- package/src/components/chip/ChipRemovable.js +1 -6
- package/src/components/chip/ChipSelectable.js +4 -9
- package/src/components/chip/exports.js +4 -10
- package/src/components/chip/leu-chip-group.js +5 -2
- package/src/components/chip/leu-chip-link.js +5 -2
- package/src/components/chip/leu-chip-removable.js +5 -2
- package/src/components/chip/leu-chip-selectable.js +5 -2
- package/src/components/chip/stories/chip-group.stories.js +18 -6
- package/src/components/chip/stories/chip-link.stories.js +16 -4
- package/src/components/chip/stories/chip-removable.stories.js +15 -4
- package/src/components/chip/stories/chip-selectable.stories.js +13 -3
- package/src/components/chip/test/chip-group.test.js +124 -0
- package/src/components/chip/test/chip-link.test.js +58 -0
- package/src/components/chip/test/chip-removable.test.js +79 -0
- package/src/components/chip/test/chip-selectable.test.js +95 -0
- package/src/components/chip/test/chip.test.js +1 -1
- package/src/components/dropdown/Dropdown.js +53 -25
- package/src/components/dropdown/dropdown.css +1 -2
- package/src/components/dropdown/leu-dropdown.js +5 -2
- package/src/components/dropdown/stories/dropdown.stories.js +11 -5
- package/src/components/dropdown/test/dropdown.test.js +6 -6
- package/src/components/icon/icon.js +1 -1
- package/src/components/icon/test/icon.test.js +66 -0
- package/src/components/input/Input.js +33 -39
- package/src/components/input/input.css +9 -6
- package/src/components/input/leu-input.js +5 -2
- package/src/components/input/stories/input.stories.js +8 -2
- package/src/components/input/test/input.test.js +431 -4
- package/src/components/menu/Menu.js +0 -5
- package/src/components/menu/MenuItem.js +22 -15
- package/src/components/menu/leu-menu-item.js +5 -2
- package/src/components/menu/leu-menu.js +5 -2
- package/src/components/menu/menu-item.css +5 -2
- package/src/components/menu/stories/menu-item.stories.js +13 -4
- package/src/components/menu/stories/menu.stories.js +11 -5
- package/src/components/menu/test/menu-item.test.js +180 -0
- package/src/components/menu/test/menu.test.js +10 -2
- package/src/components/pagination/Pagination.js +53 -65
- package/src/components/pagination/leu-pagination.js +5 -2
- package/src/components/pagination/stories/pagination.stories.js +17 -9
- package/src/components/pagination/test/pagination.test.js +191 -5
- package/src/components/popup/Popup.js +200 -0
- package/src/components/popup/leu-popup.js +6 -0
- package/src/components/popup/popup.css +27 -0
- package/src/components/popup/stories/popup.stories.js +58 -0
- package/src/components/popup/test/popup.test.js +29 -0
- package/src/components/radio/Radio.js +5 -10
- package/src/components/radio/RadioGroup.js +7 -39
- package/src/components/radio/leu-radio-group.js +5 -2
- package/src/components/radio/leu-radio.js +5 -2
- package/src/components/radio/radio-group.css +29 -0
- package/src/components/radio/stories/radio-group.stories.js +38 -19
- package/src/components/radio/stories/radio.stories.js +7 -1
- package/src/components/radio/test/radio-group.test.js +86 -0
- package/src/components/radio/test/radio.test.js +108 -17
- package/src/components/select/Select.js +35 -32
- package/src/components/select/leu-select.js +5 -2
- package/src/components/select/select.css +13 -13
- package/src/components/select/stories/select.stories.js +15 -168
- package/src/components/select/test/fixtures.js +162 -0
- package/src/components/select/test/select.test.js +236 -12
- package/src/components/table/Table.js +48 -123
- package/src/components/table/leu-table.js +5 -2
- package/src/components/table/stories/table.stories.js +20 -10
- package/src/components/table/table.css +99 -0
- package/src/components/table/test/table.test.js +1 -1
- package/src/lib/utils.js +17 -0
- package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
- package/web-test-runner.config.mjs +15 -2
package/dist/RadioGroup.js
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import { _ as _defineProperty
|
|
1
|
+
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
|
|
2
2
|
import { css, LitElement, html } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
|
|
5
|
+
var css_248z = css`:host {
|
|
6
|
+
--group-font-regular: var(--leu-font-regular);
|
|
7
|
+
--group-font-black: var(--leu-font-black);
|
|
8
|
+
|
|
9
|
+
font-family: var(--leu-font-regular);
|
|
10
|
+
|
|
11
|
+
font-family: var(--group-font-regular);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.fieldset {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: flex-start;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
gap: 0.5rem 1rem;
|
|
19
|
+
|
|
20
|
+
border: none;
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.fieldset--vertical {
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: 1rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.legend {
|
|
30
|
+
font-family: var(--group-font-black);
|
|
31
|
+
font-size: 1.125rem;
|
|
32
|
+
line-height: 1.5;
|
|
33
|
+
|
|
34
|
+
margin-bottom: 0.5rem;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
5
38
|
/**
|
|
6
39
|
* @tagname leu-radio-group
|
|
7
40
|
*/
|
|
@@ -73,7 +106,6 @@ class LeuRadioGroup extends LitElement {
|
|
|
73
106
|
item.checked = item === selectingItem; // eslint-disable-line no-param-reassign
|
|
74
107
|
});
|
|
75
108
|
}
|
|
76
|
-
|
|
77
109
|
selectNextItem(startingIndex, direction) {
|
|
78
110
|
let selected = false;
|
|
79
111
|
for (let index = 0; index < this.items.length; index += 1) {
|
|
@@ -97,7 +129,6 @@ class LeuRadioGroup extends LitElement {
|
|
|
97
129
|
}
|
|
98
130
|
});
|
|
99
131
|
}
|
|
100
|
-
|
|
101
132
|
handleItems() {
|
|
102
133
|
this.items = [...this.querySelectorAll(":scope > *:not([slot])")];
|
|
103
134
|
this.initializeIndex();
|
|
@@ -115,50 +146,22 @@ class LeuRadioGroup extends LitElement {
|
|
|
115
146
|
};
|
|
116
147
|
return html`
|
|
117
148
|
<fieldset class=${classMap(fieldsetClasses)}>
|
|
118
|
-
<legend class="legend"
|
|
149
|
+
<legend class="legend">${this.label}</legend>
|
|
119
150
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
120
151
|
</fieldset>
|
|
121
152
|
`;
|
|
122
153
|
}
|
|
123
154
|
}
|
|
124
|
-
_defineProperty(LeuRadioGroup, "styles",
|
|
125
|
-
:host {
|
|
126
|
-
--group-font-regular: var(--leu-font-regular);
|
|
127
|
-
--group-font-black: var(--leu-font-black);
|
|
128
|
-
|
|
129
|
-
font-family: var(--group-font-regular);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.fieldset {
|
|
133
|
-
display: flex;
|
|
134
|
-
align-items: flex-start;
|
|
135
|
-
flex-wrap: wrap;
|
|
136
|
-
gap: 0.5rem 1rem;
|
|
137
|
-
|
|
138
|
-
border: none;
|
|
139
|
-
padding: 0;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.fieldset--vertical {
|
|
143
|
-
flex-direction: column;
|
|
144
|
-
gap: 1rem;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.legend {
|
|
148
|
-
font-family: var(--group-font-black);
|
|
149
|
-
font-size: 1.125rem;
|
|
150
|
-
line-height: 1.5;
|
|
151
|
-
|
|
152
|
-
margin-bottom: 0.5rem;
|
|
153
|
-
}
|
|
154
|
-
`);
|
|
155
|
+
_defineProperty(LeuRadioGroup, "styles", css_248z);
|
|
155
156
|
_defineProperty(LeuRadioGroup, "properties", {
|
|
156
157
|
orientation: {
|
|
157
|
-
type: String
|
|
158
|
+
type: String,
|
|
159
|
+
reflect: true
|
|
160
|
+
},
|
|
161
|
+
label: {
|
|
162
|
+
type: String,
|
|
163
|
+
reflect: true
|
|
158
164
|
}
|
|
159
165
|
});
|
|
160
|
-
function defineRadioGroupElements() {
|
|
161
|
-
defineElement("radio-group", LeuRadioGroup);
|
|
162
|
-
}
|
|
163
166
|
|
|
164
|
-
export { LeuRadioGroup
|
|
167
|
+
export { LeuRadioGroup };
|
package/dist/Select.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import { _ as _defineProperty
|
|
1
|
+
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
|
|
2
2
|
import { css, LitElement, html, nothing } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { map } from 'lit/directives/map.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
7
7
|
import { I as Icon } from './icon-03e86700.js';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
8
|
+
import './leu-button.js';
|
|
9
|
+
import './leu-menu.js';
|
|
10
|
+
import './leu-menu-item.js';
|
|
11
|
+
import './leu-input.js';
|
|
12
|
+
import './leu-popup-4bf6f1f4.js';
|
|
13
|
+
import './defineElement-47d4f665.js';
|
|
14
|
+
import './Button.js';
|
|
15
|
+
import './Menu.js';
|
|
16
|
+
import './MenuItem.js';
|
|
17
|
+
import 'lit/static-html.js';
|
|
18
|
+
import './Input.js';
|
|
19
|
+
import 'lit/directives/live.js';
|
|
20
|
+
import '@floating-ui/dom';
|
|
12
21
|
|
|
13
22
|
/**
|
|
14
23
|
* Thanks Shoelace!
|
|
@@ -262,18 +271,22 @@ var css_248z = css`:host,
|
|
|
262
271
|
}
|
|
263
272
|
|
|
264
273
|
.select-menu-container {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
274
|
+
position: static;
|
|
275
|
+
overflow: auto;
|
|
276
|
+
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
|
|
268
280
|
width: 100%;
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
max-height: var(--auto-size-available-height);
|
|
282
|
+
|
|
271
283
|
padding: 0;
|
|
272
284
|
margin: 0;
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
|
|
286
|
+
border: none;
|
|
287
|
+
border-radius: 1px;
|
|
288
|
+
background-color: white;
|
|
275
289
|
box-shadow: var(--select-box-shadow-regular), var(--select-box-shadow-short);
|
|
276
|
-
overflow: auto;
|
|
277
290
|
}
|
|
278
291
|
|
|
279
292
|
.select-menu {
|
|
@@ -281,11 +294,7 @@ var css_248z = css`:host,
|
|
|
281
294
|
padding: 0;
|
|
282
295
|
margin: 0;
|
|
283
296
|
overflow: auto;
|
|
284
|
-
max-height:
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.select-menu.multiple {
|
|
288
|
-
max-height: 21rem;
|
|
297
|
+
max-height: 100%;
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
.before,
|
|
@@ -325,7 +334,8 @@ class LeuSelect extends LitElement {
|
|
|
325
334
|
attribute: "open"
|
|
326
335
|
},
|
|
327
336
|
label: {
|
|
328
|
-
type: String
|
|
337
|
+
type: String,
|
|
338
|
+
reflect: true
|
|
329
339
|
},
|
|
330
340
|
options: {
|
|
331
341
|
type: Array
|
|
@@ -350,7 +360,6 @@ class LeuSelect extends LitElement {
|
|
|
350
360
|
reflect: true
|
|
351
361
|
},
|
|
352
362
|
optionFilter: {
|
|
353
|
-
type: String,
|
|
354
363
|
state: true
|
|
355
364
|
}
|
|
356
365
|
};
|
|
@@ -533,14 +542,15 @@ class LeuSelect extends LitElement {
|
|
|
533
542
|
before=${ifDefined(beforeIcon)}
|
|
534
543
|
@click=${() => this.selectOption(option)}
|
|
535
544
|
role="option"
|
|
545
|
+
label=${LeuSelect.getOptionLabel(option)}
|
|
536
546
|
?active=${isSelected}
|
|
537
547
|
aria-selected=${isSelected}
|
|
538
548
|
>
|
|
539
|
-
${LeuSelect.getOptionLabel(option)}
|
|
540
549
|
</leu-menu-item>`;
|
|
541
|
-
}) : html`<leu-menu-item
|
|
542
|
-
|
|
543
|
-
|
|
550
|
+
}) : html`<leu-menu-item
|
|
551
|
+
label=${this.optionFilter === "" ? "Keine Optionen" : "Keine Resultate"}
|
|
552
|
+
disabled
|
|
553
|
+
></leu-menu-item>`}
|
|
544
554
|
</leu-menu>
|
|
545
555
|
`;
|
|
546
556
|
}
|
|
@@ -552,8 +562,8 @@ class LeuSelect extends LitElement {
|
|
|
552
562
|
@input=${this.handleFilterInput}
|
|
553
563
|
clearable
|
|
554
564
|
ref=${ref(this.optionFilterRef)}
|
|
555
|
-
|
|
556
|
-
>`;
|
|
565
|
+
label="Nach Stichwort filtern"
|
|
566
|
+
></leu-input>`;
|
|
557
567
|
}
|
|
558
568
|
return nothing;
|
|
559
569
|
}
|
|
@@ -587,6 +597,7 @@ class LeuSelect extends LitElement {
|
|
|
587
597
|
aria-expanded="${this.open}"
|
|
588
598
|
role="combobox"
|
|
589
599
|
ref=${ref(this.toggleButtonRef)}
|
|
600
|
+
slot="anchor"
|
|
590
601
|
>
|
|
591
602
|
<span class="label" id="select-label">${this.label}</span>
|
|
592
603
|
<span class="value"> ${this.getDisplayValue(this.value)} </span>
|
|
@@ -615,27 +626,29 @@ class LeuSelect extends LitElement {
|
|
|
615
626
|
aria-labelledby="select-label"
|
|
616
627
|
@keydown=${this.handleKeyDown}
|
|
617
628
|
>
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
629
|
+
<leu-popup
|
|
630
|
+
?active=${this.open}
|
|
631
|
+
placement="bottom-start"
|
|
632
|
+
flip
|
|
633
|
+
matchSize="width"
|
|
634
|
+
autoSize="height"
|
|
635
|
+
autoSizePadding="8"
|
|
623
636
|
>
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
637
|
+
${this.renderToggleButton()}
|
|
638
|
+
<dialog
|
|
639
|
+
id="select-dialog"
|
|
640
|
+
class="select-menu-container"
|
|
641
|
+
?open=${this.open}
|
|
642
|
+
>
|
|
643
|
+
<slot name="before" class="before"></slot>
|
|
644
|
+
${this.renderFilterInput()} ${this.renderMenu()}
|
|
645
|
+
${this.renderApplyButton()}
|
|
646
|
+
<slot name="after" class="after"></slot>
|
|
647
|
+
</dialog>
|
|
648
|
+
</leu-popup>
|
|
629
649
|
</div> `;
|
|
630
650
|
}
|
|
631
651
|
}
|
|
632
652
|
_defineProperty(LeuSelect, "styles", css_248z);
|
|
633
|
-
function defineSelectElements() {
|
|
634
|
-
defineButtonElements();
|
|
635
|
-
defineMenuElements();
|
|
636
|
-
defineMenuItemElements();
|
|
637
|
-
defineInputElements();
|
|
638
|
-
defineElement("select", LeuSelect);
|
|
639
|
-
}
|
|
640
653
|
|
|
641
|
-
export { LeuSelect
|
|
654
|
+
export { LeuSelect };
|
package/dist/Table.js
CHANGED
|
@@ -1,12 +1,118 @@
|
|
|
1
|
-
import { _ as _defineProperty
|
|
1
|
+
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
|
|
2
2
|
import { css, LitElement, html, nothing } from 'lit';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
5
5
|
import { createRef, ref } from 'lit/directives/ref.js';
|
|
6
6
|
import { I as Icon } from './icon-03e86700.js';
|
|
7
|
-
import
|
|
7
|
+
import './leu-pagination.js';
|
|
8
|
+
import './defineElement-47d4f665.js';
|
|
9
|
+
import './Pagination.js';
|
|
10
|
+
import 'lit/directives/live.js';
|
|
11
|
+
import './leu-button.js';
|
|
8
12
|
import './Button.js';
|
|
9
13
|
|
|
14
|
+
var css_248z = css`:host {
|
|
15
|
+
position: relative;
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
div.scroll {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
width: 100%;
|
|
22
|
+
overflow: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
div.shadow {
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
top: 0;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
z-index: 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
div.pagination {
|
|
36
|
+
height: calc(100% - 66px);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
table {
|
|
40
|
+
width: 100%;
|
|
41
|
+
border-spacing: 0;
|
|
42
|
+
color: rgba(0, 0, 0, 0.6);
|
|
43
|
+
font-size: 16px;
|
|
44
|
+
font-family: var(--leu-font-regular);
|
|
45
|
+
line-height: 1.5;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
td {
|
|
49
|
+
padding: 12px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
th {
|
|
53
|
+
padding: 16px 16px 8px;
|
|
54
|
+
text-align: left;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
font-weight: normal;
|
|
57
|
+
font-family: var(--leu-font-black);
|
|
58
|
+
background: var(--table-even-row-bg);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
td:first-child,
|
|
62
|
+
th:first-child {
|
|
63
|
+
left: 0;
|
|
64
|
+
background: inherit;
|
|
65
|
+
z-index: 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
tr {
|
|
69
|
+
background: #fff;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
tbody tr:nth-child(odd) {
|
|
73
|
+
background: var(--leu-color-black-5);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
button {
|
|
77
|
+
background: none;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
line-height: 1.5;
|
|
80
|
+
padding: 0;
|
|
81
|
+
border: 0;
|
|
82
|
+
width: 100%;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: flex-center;
|
|
85
|
+
font-size: inherit;
|
|
86
|
+
font-family: inherit;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
thead svg {
|
|
90
|
+
display: inline-block;
|
|
91
|
+
color: var(--leu-color-accent-blue);
|
|
92
|
+
padding: 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
table.sticky td:first-child,
|
|
96
|
+
table.sticky th:first-child {
|
|
97
|
+
position: sticky;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
div.shadow-left table.sticky td:first-child,
|
|
101
|
+
div.shadow-left table.sticky th:first-child {
|
|
102
|
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
|
|
103
|
+
-webkit-clip-path: inset(0 -15px 0 0);
|
|
104
|
+
clip-path: inset(0 -15px 0 0);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
div.shadow-left {
|
|
108
|
+
box-shadow: inset 5px 0 5px -5px rgba(0, 0, 0, 0.5);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
div.shadow-right {
|
|
112
|
+
box-shadow: inset -5px 0 5px -5px rgba(0, 0, 0, 0.5);
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
|
|
10
116
|
/**
|
|
11
117
|
* @tagname leu-table
|
|
12
118
|
*/
|
|
@@ -20,7 +126,7 @@ class LeuTable extends LitElement {
|
|
|
20
126
|
/** @type {boolean} */
|
|
21
127
|
this.firstColumnSticky = false;
|
|
22
128
|
/** @type {number} */
|
|
23
|
-
this.
|
|
129
|
+
this.itemsPerPage = null;
|
|
24
130
|
/** @type {number} */
|
|
25
131
|
this.sortIndex = null;
|
|
26
132
|
/** @type {boolean} */
|
|
@@ -38,13 +144,25 @@ class LeuTable extends LitElement {
|
|
|
38
144
|
this._shadowRight = false;
|
|
39
145
|
/** @internal */
|
|
40
146
|
this._scrollRef = createRef();
|
|
147
|
+
|
|
41
148
|
/** @internal */
|
|
42
|
-
this.
|
|
43
|
-
|
|
44
|
-
|
|
149
|
+
this._page = 1;
|
|
150
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
151
|
+
this.shadowToggle(this._scrollRef.value);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
disconnectedCallback() {
|
|
155
|
+
this._resizeObserver.disconnect();
|
|
156
|
+
}
|
|
157
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
158
|
+
super.attributeChangedCallback(name, oldVal, newVal);
|
|
159
|
+
if (name === "itemsperpage" || name === "data") {
|
|
160
|
+
this._page = 1;
|
|
161
|
+
}
|
|
45
162
|
}
|
|
46
163
|
firstUpdated() {
|
|
47
164
|
this.shadowToggle(this._scrollRef.value);
|
|
165
|
+
this._resizeObserver.observe(this._scrollRef.value);
|
|
48
166
|
}
|
|
49
167
|
shadowToggle(target) {
|
|
50
168
|
this._shadowLeft = target.scrollLeftMax > 0 && target.scrollLeft > 0;
|
|
@@ -91,7 +209,7 @@ class LeuTable extends LitElement {
|
|
|
91
209
|
return this.data.sort(this.sortOrderAsc ? col.sort.asc : col.sort.desc);
|
|
92
210
|
}
|
|
93
211
|
get _data() {
|
|
94
|
-
return this.
|
|
212
|
+
return this.itemsPerPage && this.itemsPerPage > 0 ? this._sortedData.slice((this._page - 1) * this.itemsPerPage, this._page * this.itemsPerPage) : this._sortedData;
|
|
95
213
|
}
|
|
96
214
|
render() {
|
|
97
215
|
const scrollClasses = {
|
|
@@ -101,12 +219,12 @@ class LeuTable extends LitElement {
|
|
|
101
219
|
const shadowClassesLeft = {
|
|
102
220
|
shadow: true,
|
|
103
221
|
"shadow-left": !this.firstColumnSticky && this._shadowLeft,
|
|
104
|
-
pagination: this.
|
|
222
|
+
pagination: this.itemsPerPage > 0
|
|
105
223
|
};
|
|
106
224
|
const shadowClassesRight = {
|
|
107
225
|
shadow: true,
|
|
108
226
|
"shadow-right": this._shadowRight,
|
|
109
|
-
pagination: this.
|
|
227
|
+
pagination: this.itemsPerPage > 0
|
|
110
228
|
};
|
|
111
229
|
const stickyClass = {
|
|
112
230
|
sticky: this.firstColumnSticky
|
|
@@ -142,17 +260,13 @@ class LeuTable extends LitElement {
|
|
|
142
260
|
<div class=${classMap(shadowClassesRight)}></div>
|
|
143
261
|
</div>
|
|
144
262
|
|
|
145
|
-
${this.
|
|
263
|
+
${this.itemsPerPage > 0 ? html`
|
|
146
264
|
<leu-pagination
|
|
147
|
-
.
|
|
148
|
-
.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
// after render
|
|
153
|
-
setTimeout(() => {
|
|
154
|
-
this.shadowToggle(this._scrollRef.value);
|
|
155
|
-
}, 0);
|
|
265
|
+
.numOfItems=${this._sortedData.length}
|
|
266
|
+
.itemsPerPage=${this.itemsPerPage}
|
|
267
|
+
page=${this._page}
|
|
268
|
+
@leu:pagechange=${e => {
|
|
269
|
+
this._page = e.detail.page;
|
|
156
270
|
}}
|
|
157
271
|
>
|
|
158
272
|
</leu-pagination>
|
|
@@ -160,93 +274,7 @@ class LeuTable extends LitElement {
|
|
|
160
274
|
`;
|
|
161
275
|
}
|
|
162
276
|
}
|
|
163
|
-
_defineProperty(LeuTable, "styles",
|
|
164
|
-
:host {
|
|
165
|
-
position: relative;
|
|
166
|
-
display: block;
|
|
167
|
-
}
|
|
168
|
-
div.scroll {
|
|
169
|
-
display: inline-block;
|
|
170
|
-
width: 100%;
|
|
171
|
-
overflow: auto;
|
|
172
|
-
}
|
|
173
|
-
div.shadow {
|
|
174
|
-
position: absolute;
|
|
175
|
-
left: 0;
|
|
176
|
-
top: 0;
|
|
177
|
-
width: 100%;
|
|
178
|
-
height: 100%;
|
|
179
|
-
pointer-events: none;
|
|
180
|
-
z-index: 1;
|
|
181
|
-
}
|
|
182
|
-
div.pagination {
|
|
183
|
-
height: calc(100% - 66px);
|
|
184
|
-
}
|
|
185
|
-
table {
|
|
186
|
-
width: 100%;
|
|
187
|
-
border-spacing: 0;
|
|
188
|
-
color: rgb(0 0 0 / 60%);
|
|
189
|
-
font-size: 16px;
|
|
190
|
-
font-family: var(--leu-font-regular);
|
|
191
|
-
line-height: 1.5;
|
|
192
|
-
}
|
|
193
|
-
td {
|
|
194
|
-
padding: 12px;
|
|
195
|
-
}
|
|
196
|
-
th {
|
|
197
|
-
padding: 16px 16px 8px;
|
|
198
|
-
text-align: left;
|
|
199
|
-
font-size: 12px;
|
|
200
|
-
font-weight: normal;
|
|
201
|
-
font-family: var(--leu-font-black);
|
|
202
|
-
background: var(--table-even-row-bg);
|
|
203
|
-
}
|
|
204
|
-
td:first-child,
|
|
205
|
-
th:first-child {
|
|
206
|
-
left: 0;
|
|
207
|
-
background: inherit;
|
|
208
|
-
z-index: 1;
|
|
209
|
-
}
|
|
210
|
-
tr {
|
|
211
|
-
background: #fff;
|
|
212
|
-
}
|
|
213
|
-
tbody tr:nth-child(odd) {
|
|
214
|
-
background: var(--leu-color-black-5);
|
|
215
|
-
}
|
|
216
|
-
button {
|
|
217
|
-
background: none;
|
|
218
|
-
cursor: pointer;
|
|
219
|
-
line-height: 1.5;
|
|
220
|
-
padding: 0;
|
|
221
|
-
border: 0;
|
|
222
|
-
width: 100%;
|
|
223
|
-
display: flex;
|
|
224
|
-
align-items: flex-center;
|
|
225
|
-
font-size: inherit;
|
|
226
|
-
font-family: inherit;
|
|
227
|
-
}
|
|
228
|
-
thead svg {
|
|
229
|
-
display: inline-block;
|
|
230
|
-
color: var(--leu-color-accent-blue);
|
|
231
|
-
padding: 0;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
table.sticky td:first-child,
|
|
235
|
-
table.sticky th:first-child {
|
|
236
|
-
position: sticky;
|
|
237
|
-
}
|
|
238
|
-
div.shadow-left table.sticky td:first-child,
|
|
239
|
-
div.shadow-left table.sticky th:first-child {
|
|
240
|
-
box-shadow: 0 0 5px rgb(0 0 0 / 50%);
|
|
241
|
-
clip-path: inset(0 -15px 0 0);
|
|
242
|
-
}
|
|
243
|
-
div.shadow-left {
|
|
244
|
-
box-shadow: inset 5px 0 5px -5px rgb(0 0 0 / 50%);
|
|
245
|
-
}
|
|
246
|
-
div.shadow-right {
|
|
247
|
-
box-shadow: inset -5px 0 5px -5px rgb(0 0 0 / 50%);
|
|
248
|
-
}
|
|
249
|
-
`);
|
|
277
|
+
_defineProperty(LeuTable, "styles", css_248z);
|
|
250
278
|
_defineProperty(LeuTable, "properties", {
|
|
251
279
|
columns: {
|
|
252
280
|
type: Array
|
|
@@ -255,40 +283,34 @@ _defineProperty(LeuTable, "properties", {
|
|
|
255
283
|
type: Array
|
|
256
284
|
},
|
|
257
285
|
firstColumnSticky: {
|
|
258
|
-
type: Boolean
|
|
286
|
+
type: Boolean,
|
|
287
|
+
reflect: true
|
|
259
288
|
},
|
|
260
|
-
|
|
261
|
-
type: Number
|
|
289
|
+
itemsPerPage: {
|
|
290
|
+
type: Number,
|
|
291
|
+
reflect: true
|
|
262
292
|
},
|
|
263
293
|
sortIndex: {
|
|
264
|
-
type: Number
|
|
294
|
+
type: Number,
|
|
295
|
+
reflect: true
|
|
265
296
|
},
|
|
266
297
|
sortOrderAsc: {
|
|
267
|
-
type: Boolean
|
|
298
|
+
type: Boolean,
|
|
299
|
+
reflect: true
|
|
268
300
|
},
|
|
269
301
|
width: {
|
|
270
|
-
type: Number
|
|
302
|
+
type: Number,
|
|
303
|
+
reflect: true
|
|
271
304
|
},
|
|
272
305
|
_shadowLeft: {
|
|
273
|
-
type: Boolean,
|
|
274
306
|
state: true
|
|
275
307
|
},
|
|
276
308
|
_shadowRight: {
|
|
277
|
-
type: Boolean,
|
|
278
|
-
state: true
|
|
279
|
-
},
|
|
280
|
-
_min: {
|
|
281
|
-
type: Number,
|
|
282
309
|
state: true
|
|
283
310
|
},
|
|
284
|
-
|
|
285
|
-
type: Number,
|
|
311
|
+
_page: {
|
|
286
312
|
state: true
|
|
287
313
|
}
|
|
288
314
|
});
|
|
289
|
-
function defineTableElements() {
|
|
290
|
-
definePaginationElements();
|
|
291
|
-
defineElement("table", LeuTable);
|
|
292
|
-
}
|
|
293
315
|
|
|
294
|
-
export { LeuTable
|
|
316
|
+
export { LeuTable };
|
|
@@ -27,18 +27,4 @@ function _toPropertyKey(arg) {
|
|
|
27
27
|
return typeof key === "symbol" ? key : String(key);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
* Adds a definition for a custom element to the custom element
|
|
32
|
-
* registry if it isn't defined before. Prefixes the name with `leu-`.
|
|
33
|
-
* @param {string} name
|
|
34
|
-
* @param {HTMLElement} constructor
|
|
35
|
-
*/
|
|
36
|
-
function defineElement(name, constructor) {
|
|
37
|
-
if (!customElements.get(`leu-${name}`)) {
|
|
38
|
-
customElements.define(`leu-${name}`, constructor);
|
|
39
|
-
} else {
|
|
40
|
-
console.info(`leu-${name} is already defined`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { _defineProperty as _, defineElement as d };
|
|
30
|
+
export { _defineProperty as _ };
|
|
@@ -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 };
|