@statistikzh/leu 0.4.0 → 0.5.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/.storybook/preview.js +1 -2
- package/CHANGELOG.md +24 -0
- package/custom-elements-manifest.config.js +46 -0
- package/dist/Accordion.d.ts +31 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +257 -0
- package/dist/Breadcrumb.d.ts +69 -0
- package/dist/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumb.js +392 -0
- package/dist/Button-da11d064.d.ts +84 -0
- package/dist/Button-da11d064.d.ts.map +1 -0
- package/dist/Button-da11d064.js +542 -0
- package/dist/Button.d.ts +2 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +6 -420
- package/dist/ButtonGroup.d.ts +24 -0
- package/dist/ButtonGroup.d.ts.map +1 -0
- package/dist/ButtonGroup.js +70 -39
- package/dist/Checkbox.d.ts +13 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +2 -2
- package/dist/CheckboxGroup.d.ts +13 -0
- package/dist/CheckboxGroup.d.ts.map +1 -0
- package/dist/CheckboxGroup.js +3 -3
- package/dist/Chip.d.ts +5 -0
- package/dist/Chip.d.ts.map +1 -0
- package/dist/{Chip-dac7337d.js → Chip.js} +16 -5
- package/dist/ChipGroup.d.ts +28 -0
- package/dist/ChipGroup.d.ts.map +1 -0
- package/dist/ChipGroup.js +62 -5
- package/dist/ChipLink.d.ts +15 -0
- package/dist/ChipLink.d.ts.map +1 -0
- package/dist/ChipLink.js +1 -1
- package/dist/ChipRemovable.d.ts +13 -0
- package/dist/ChipRemovable.d.ts.map +1 -0
- package/dist/ChipRemovable.js +2 -2
- package/dist/ChipSelectable.d.ts +22 -0
- package/dist/ChipSelectable.d.ts.map +1 -0
- package/dist/ChipSelectable.js +5 -5
- package/dist/Dropdown.d.ts +15 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +25 -7
- package/dist/Input.d.ts +154 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +13 -7
- package/dist/Menu.d.ts +8 -0
- package/dist/Menu.d.ts.map +1 -0
- package/dist/MenuItem.d.ts +21 -0
- package/dist/MenuItem.d.ts.map +1 -0
- package/dist/MenuItem.js +3 -3
- package/dist/Pagination.d.ts +27 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +93 -61
- package/dist/Popup.d.ts +18 -0
- package/dist/Popup.d.ts.map +1 -0
- package/dist/{leu-popup-4bf6f1f4.js → Popup.js} +4 -5
- package/dist/Radio.d.ts +12 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.js +2 -2
- package/dist/RadioGroup.d.ts +20 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +3 -3
- package/dist/ScrollTop.d.ts +19 -0
- package/dist/ScrollTop.d.ts.map +1 -0
- package/dist/ScrollTop.js +122 -0
- package/dist/Select.d.ts +98 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +27 -82
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +7 -4
- package/dist/VisuallyHidden.d.ts +8 -0
- package/dist/VisuallyHidden.d.ts.map +1 -0
- package/dist/VisuallyHidden.js +28 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +3 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +1 -0
- package/dist/defineElement-40372b4b.d.ts +9 -0
- package/dist/defineElement-40372b4b.d.ts.map +1 -0
- package/dist/{defineElement-47d4f665.js → defineElement-40372b4b.js} +1 -1
- package/dist/icon-03e86700.d.ts +11 -0
- package/dist/icon-03e86700.d.ts.map +1 -0
- package/dist/index.js.d.ts +21 -0
- package/dist/index.js.d.ts.map +1 -0
- package/dist/{index.js → index.js.js} +14 -8
- package/dist/leu-accordion.d.ts +3 -0
- package/dist/leu-accordion.d.ts.map +1 -0
- package/dist/leu-accordion.js +9 -0
- package/dist/leu-breadcrumb.d.ts +3 -0
- package/dist/leu-breadcrumb.d.ts.map +1 -0
- package/dist/leu-breadcrumb.js +23 -0
- package/dist/leu-button-group.d.ts +3 -0
- package/dist/leu-button-group.d.ts.map +1 -0
- package/dist/leu-button-group.js +1 -5
- package/dist/leu-button.d.ts +3 -0
- package/dist/leu-button.d.ts.map +1 -0
- package/dist/leu-button.js +3 -2
- package/dist/leu-checkbox-group.d.ts +3 -0
- package/dist/leu-checkbox-group.d.ts.map +1 -0
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.d.ts +3 -0
- package/dist/leu-checkbox.d.ts.map +1 -0
- package/dist/leu-checkbox.js +1 -1
- package/dist/leu-chip-group.d.ts +3 -0
- package/dist/leu-chip-group.d.ts.map +1 -0
- package/dist/leu-chip-group.js +2 -1
- package/dist/leu-chip-link.d.ts +3 -0
- package/dist/leu-chip-link.d.ts.map +1 -0
- package/dist/leu-chip-link.js +2 -2
- package/dist/leu-chip-removable.d.ts +3 -0
- package/dist/leu-chip-removable.d.ts.map +1 -0
- package/dist/leu-chip-removable.js +2 -2
- package/dist/leu-chip-selectable.d.ts +3 -0
- package/dist/leu-chip-selectable.d.ts.map +1 -0
- package/dist/leu-chip-selectable.js +2 -2
- package/dist/leu-dropdown.d.ts +3 -0
- package/dist/leu-dropdown.d.ts.map +1 -0
- package/dist/leu-dropdown.js +5 -4
- package/dist/leu-input.d.ts +3 -0
- package/dist/leu-input.d.ts.map +1 -0
- package/dist/leu-input.js +1 -1
- package/dist/leu-menu-item.d.ts +3 -0
- package/dist/leu-menu-item.d.ts.map +1 -0
- package/dist/leu-menu-item.js +1 -1
- package/dist/leu-menu.d.ts +3 -0
- package/dist/leu-menu.d.ts.map +1 -0
- package/dist/leu-menu.js +1 -1
- package/dist/leu-pagination.d.ts +3 -0
- package/dist/leu-pagination.d.ts.map +1 -0
- package/dist/leu-pagination.js +5 -2
- package/dist/leu-popup.d.ts +3 -0
- package/dist/leu-popup.d.ts.map +1 -0
- package/dist/leu-popup.js +9 -0
- package/dist/leu-radio-group.d.ts +3 -0
- package/dist/leu-radio-group.d.ts.map +1 -0
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.d.ts +3 -0
- package/dist/leu-radio.d.ts.map +1 -0
- package/dist/leu-radio.js +1 -1
- package/dist/leu-scroll-top.d.ts +3 -0
- package/dist/leu-scroll-top.d.ts.map +1 -0
- package/dist/leu-scroll-top.js +14 -0
- package/dist/leu-select.d.ts +3 -0
- package/dist/leu-select.d.ts.map +1 -0
- package/dist/leu-select.js +4 -3
- package/dist/leu-table.d.ts +3 -0
- package/dist/leu-table.d.ts.map +1 -0
- package/dist/leu-table.js +5 -2
- package/dist/leu-visually-hidden.d.ts +3 -0
- package/dist/leu-visually-hidden.d.ts.map +1 -0
- package/dist/leu-visually-hidden.js +8 -0
- package/dist/theme.css +386 -2
- package/dist/utils-65469421.d.ts +16 -0
- package/dist/utils-65469421.d.ts.map +1 -0
- package/dist/utils-65469421.js +35 -0
- package/index.js +3 -0
- package/package.json +30 -12
- package/postcss.config.cjs +2 -0
- package/rollup.config.js +21 -40
- package/scripts/generate-component/templates/[name].css +2 -2
- package/scripts/postcss-leu-font-styles.cjs +160 -0
- package/src/components/accordion/accordion.css +2 -2
- package/src/components/accordion/stories/accordion.stories.js +2 -1
- package/src/components/accordion/test/accordion.test.js +4 -2
- package/src/components/breadcrumb/Breadcrumb.js +2 -1
- package/src/components/breadcrumb/breadcrumb.css +2 -13
- package/src/components/button/Button.js +69 -8
- package/src/components/button/button.css +10 -2
- package/src/components/button/stories/button.stories.js +43 -90
- package/src/components/button/test/button.test.js +90 -19
- package/src/components/button-group/ButtonGroup.js +76 -34
- package/src/components/button-group/stories/button-group.stories.js +13 -6
- package/src/components/button-group/test/button-group.test.js +38 -31
- package/src/components/checkbox/checkbox-group.css +2 -2
- package/src/components/checkbox/checkbox.css +1 -1
- package/src/components/chip/ChipGroup.js +42 -2
- package/src/components/chip/ChipRemovable.js +1 -1
- package/src/components/chip/ChipSelectable.js +4 -4
- package/src/components/chip/chip-group.css +12 -2
- package/src/components/chip/chip.css +14 -3
- package/src/components/chip/stories/chip-group.stories.js +100 -46
- package/src/components/chip/test/chip-removable.test.js +3 -3
- package/src/components/dropdown/Dropdown.js +23 -3
- package/src/components/input/Input.js +7 -4
- package/src/components/input/input.css +2 -2
- package/src/components/input/stories/input.stories.js +13 -0
- package/src/components/input/test/input.test.js +1 -0
- package/src/components/menu/menu-item.css +3 -3
- package/src/components/pagination/Pagination.js +91 -60
- package/src/components/pagination/pagination.css +6 -1
- package/src/components/pagination/stories/pagination.stories.js +15 -2
- package/src/components/pagination/test/pagination.test.js +15 -15
- package/src/components/popup/popup.css +2 -2
- package/src/components/popup/stories/popup.stories.js +1 -1
- package/src/components/radio/radio-group.css +2 -2
- package/src/components/radio/radio.css +1 -1
- package/src/components/scroll-top/ScrollTop.js +87 -0
- package/src/components/scroll-top/leu-scroll-top.js +6 -0
- package/src/components/scroll-top/scroll-top.css +34 -0
- package/src/components/scroll-top/stories/scroll-top.stories.js +217 -0
- package/src/components/scroll-top/test/scroll-top.test.js +22 -0
- package/src/components/select/Select.js +24 -6
- package/src/components/select/select.css +2 -2
- package/src/components/table/table.css +2 -2
- package/src/components/visually-hidden/VisuallyHidden.js +13 -0
- package/src/components/visually-hidden/leu-visually-hidden.js +6 -0
- package/src/components/visually-hidden/stories/visually-hidden.stories.js +22 -0
- package/src/components/visually-hidden/test/visually-hidden.test.js +36 -0
- package/src/components/visually-hidden/visually-hidden.css +10 -0
- package/src/lib/defineElement.js +1 -1
- package/src/lib/hasSlotController.js +5 -3
- package/src/lib/utils.js +21 -3
- package/src/styles/custom-properties.css +6 -2
- package/src/styles/font-definitions.json +202 -0
- package/stylelint.config.mjs +2 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
|
|
2
|
+
import { css, LitElement, nothing, html } from 'lit';
|
|
3
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { I as Icon } from './icon-03e86700.js';
|
|
6
|
+
import './leu-menu.js';
|
|
7
|
+
import './leu-menu-item.js';
|
|
8
|
+
import './leu-popup.js';
|
|
9
|
+
import './leu-visually-hidden.js';
|
|
10
|
+
import { d as debounce } from './utils-65469421.js';
|
|
11
|
+
import './defineElement-40372b4b.js';
|
|
12
|
+
import './Menu.js';
|
|
13
|
+
import './MenuItem.js';
|
|
14
|
+
import 'lit/static-html.js';
|
|
15
|
+
import 'lit/directives/if-defined.js';
|
|
16
|
+
import './Popup.js';
|
|
17
|
+
import '@floating-ui/dom';
|
|
18
|
+
import './VisuallyHidden.js';
|
|
19
|
+
|
|
20
|
+
var css_248z = css`:host,
|
|
21
|
+
:host * {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host {
|
|
26
|
+
--breadcrumb-font-regular: var(--leu-font-family-regular);
|
|
27
|
+
--breadcrumb-font-black: var(--leu-font-family-black);
|
|
28
|
+
|
|
29
|
+
font-family: var(--leu-font-family-regular);
|
|
30
|
+
|
|
31
|
+
font-family: var(--breadcrumb-font-regular);
|
|
32
|
+
line-height: 1.5;
|
|
33
|
+
color: var(--leu-color-black-100);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([inverted]) {
|
|
37
|
+
color: var(--leu-color-black-0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.breadcrumbs__list {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
list-style-type: none;
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.breadcrumbs--back-only .breadcrumbs__list {
|
|
49
|
+
overflow: hidden;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.breadcrumbs__item,
|
|
53
|
+
.breadcrumbs__icon {
|
|
54
|
+
align-items: center;
|
|
55
|
+
display: flex;
|
|
56
|
+
min-height: 1.875rem;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.breadcrumbs__item:first-child:not(.breadcrumbs__item--back) {
|
|
61
|
+
font-family: var(--breadcrumb-font-black);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.breadcrumbs__item--back {
|
|
65
|
+
max-width: 100%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.breadcrumbs__link {
|
|
69
|
+
color: inherit;
|
|
70
|
+
-webkit-text-decoration: none;
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
transition: color 0.1s ease;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.breadcrumbs__item--back .breadcrumbs__link {
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
text-overflow: ellipsis;
|
|
79
|
+
margin-right: 0.25rem;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.menu {
|
|
83
|
+
background: none;
|
|
84
|
+
color: inherit;
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
border: 2px solid transparent;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.menu:focus-visible {
|
|
90
|
+
outline: 2px solid var(--leu-color-func-cyan);
|
|
91
|
+
outline-offset: 2px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.dropdown {
|
|
95
|
+
background-color: var(--leu-color-black-0);
|
|
96
|
+
box-shadow: var(--leu-box-shadow-short);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.breadcrumbs {
|
|
100
|
+
font-size: 1rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@media (min-width: 320px) {
|
|
104
|
+
.breadcrumbs {
|
|
105
|
+
font-size: calc(2.5vw + 8px);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media (min-width: 400px) {
|
|
110
|
+
.breadcrumbs {
|
|
111
|
+
font-size: 18px;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media (min-width: 1024px) {
|
|
116
|
+
.breadcrumbs {
|
|
117
|
+
font-size: calc(0.7813vw + 10px);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@media (min-width: 1280px) {
|
|
122
|
+
.breadcrumbs {
|
|
123
|
+
font-size: 20px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A Breadcrumb Navigation.
|
|
130
|
+
*
|
|
131
|
+
* The breadcrumbs can be displayed in two different layouts.
|
|
132
|
+
* Only the back link (the last item / parent of the current page)
|
|
133
|
+
* is displayed when…
|
|
134
|
+
* - … the width of the container is smaller
|
|
135
|
+
* than the BACK_ONLY_BREAKPOINT.
|
|
136
|
+
* - … less then two breadcrumb items could be displayed
|
|
137
|
+
* without overflowing the container.
|
|
138
|
+
*
|
|
139
|
+
* Otherwise as many items as possible are displayed in an inline list
|
|
140
|
+
* without overflowing the container. The remaining items are displayed
|
|
141
|
+
* in a dropdown menu.
|
|
142
|
+
*
|
|
143
|
+
* In order to determine the exact numbers of items that have to be
|
|
144
|
+
* hidden inside the dropdown, all of them have to be rendered first.
|
|
145
|
+
* 1. Render all items
|
|
146
|
+
* 2. Calculate (measure) the number of items that can be displayed
|
|
147
|
+
* without overflowing the container.
|
|
148
|
+
* 3. Updating the state (_hiddeItems) which will trigger a rerender
|
|
149
|
+
* 4. Render the items again with the new state.
|
|
150
|
+
*
|
|
151
|
+
* This results in multiple updates scheduled one after another. Lit
|
|
152
|
+
* will also print a waring in the console beacause of that.
|
|
153
|
+
* It's no a nice behaviour but the only one that works without
|
|
154
|
+
* having duplicate and hidden markup to derive the sizes from that.
|
|
155
|
+
*
|
|
156
|
+
*
|
|
157
|
+
* @prop {Array} items - Object array with { label, href }
|
|
158
|
+
* @prop {Boolean} inverted - invert color on dark background
|
|
159
|
+
*
|
|
160
|
+
* @tagname leu-breadcrumb
|
|
161
|
+
*/
|
|
162
|
+
class LeuBreadcrumb extends LitElement {
|
|
163
|
+
constructor() {
|
|
164
|
+
super();
|
|
165
|
+
/** @type {Array} */
|
|
166
|
+
_defineProperty(this, "_handleResize", async () => {
|
|
167
|
+
const containerOffsetWidth = this._containerRef.value.offsetWidth;
|
|
168
|
+
const sizeIsGrowing = containerOffsetWidth > this._lastContainerWidth;
|
|
169
|
+
this._lastContainerWidth = containerOffsetWidth;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Show only the back link (parent of the current page)
|
|
173
|
+
* when the width of the container is smaller than the BACK_ONLY_BREAKPOINT
|
|
174
|
+
*/
|
|
175
|
+
if (containerOffsetWidth <= LeuBreadcrumb.BACK_ONLY_BREAKPOINT) {
|
|
176
|
+
this._showBackOnly = true;
|
|
177
|
+
this._isRecalculating = false;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
this._showBackOnly = false;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* In order to calculate how many items can be displayed
|
|
184
|
+
* when the container is growing, all items have to
|
|
185
|
+
* be marked as displayed (_hiddenItems = 0) and
|
|
186
|
+
* rendered.
|
|
187
|
+
*/
|
|
188
|
+
if (sizeIsGrowing && this._hiddenItems > 0) {
|
|
189
|
+
this._hiddenItems = 0;
|
|
190
|
+
this._isRecalculating = true;
|
|
191
|
+
await this.updateComplete;
|
|
192
|
+
}
|
|
193
|
+
this._checkWidth();
|
|
194
|
+
});
|
|
195
|
+
/** @internal */
|
|
196
|
+
_defineProperty(this, "_handleDropdownToggle", e => {
|
|
197
|
+
e.stopPropagation();
|
|
198
|
+
this._isDropdownOpen = !this._isDropdownOpen;
|
|
199
|
+
if (this._isDropdownOpen) {
|
|
200
|
+
window.addEventListener("click", this._closeDropdown);
|
|
201
|
+
} else {
|
|
202
|
+
window.removeEventListener("click", this._closeDropdown);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
_defineProperty(this, "_closeDropdown", () => {
|
|
206
|
+
this._isDropdownOpen = false;
|
|
207
|
+
window.removeEventListener("click", this._closeDropdown);
|
|
208
|
+
});
|
|
209
|
+
this.items = [];
|
|
210
|
+
/** @type {Boolean} - will be used on dark Background */
|
|
211
|
+
this.inverted = false;
|
|
212
|
+
|
|
213
|
+
/** @internal */
|
|
214
|
+
this._containerRef = createRef();
|
|
215
|
+
/** @internal */
|
|
216
|
+
this._hiddenItems = 0;
|
|
217
|
+
/** @internal */
|
|
218
|
+
this._showBackOnly = null;
|
|
219
|
+
/** @internal */
|
|
220
|
+
this._lastContainerWidth = null;
|
|
221
|
+
/**
|
|
222
|
+
* @internal
|
|
223
|
+
* Forces the toggle button to be rendered
|
|
224
|
+
* so that all possible inline items will be measured.
|
|
225
|
+
* */
|
|
226
|
+
this._isRecalculating = true;
|
|
227
|
+
/** @internal */
|
|
228
|
+
this._isDropdownOpen = false;
|
|
229
|
+
this.resizeObserver = new ResizeObserver(debounce(() => {
|
|
230
|
+
this._handleResize();
|
|
231
|
+
}, 500));
|
|
232
|
+
}
|
|
233
|
+
firstUpdated() {
|
|
234
|
+
this.resizeObserver.observe(this._containerRef.value);
|
|
235
|
+
}
|
|
236
|
+
async updated(changedProperties) {
|
|
237
|
+
if (changedProperties.has("items")) {
|
|
238
|
+
this._hiddenItems = 0;
|
|
239
|
+
this._isRecalculating = true;
|
|
240
|
+
await this.updateComplete;
|
|
241
|
+
this._checkWidth();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
disconnectedCallback() {
|
|
245
|
+
super.disconnectedCallback();
|
|
246
|
+
window.removeEventListener("click", this._closeDropdown);
|
|
247
|
+
this.resizeObserver.disconnect();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** @internal */
|
|
251
|
+
get _listItems() {
|
|
252
|
+
return this.items.toSpliced(1, this._hiddenItems);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** @internal */
|
|
256
|
+
get _dropdownItems() {
|
|
257
|
+
return this.items.slice(1, 1 + this._hiddenItems);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Calculate the number of items that can be displayed
|
|
261
|
+
* without overflowing the container.
|
|
262
|
+
* @internal
|
|
263
|
+
* @returns {void}
|
|
264
|
+
*/
|
|
265
|
+
_checkWidth() {
|
|
266
|
+
const containerOffsetWidth = this._containerRef.value.offsetWidth;
|
|
267
|
+
const containerScrollWidth = this._containerRef.value.scrollWidth;
|
|
268
|
+
this._lastContainerWidth = containerOffsetWidth;
|
|
269
|
+
|
|
270
|
+
/** When the container is not overflowing, nothing has to be done */
|
|
271
|
+
if (containerOffsetWidth === containerScrollWidth) {
|
|
272
|
+
this._isRecalculating = false;
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const listItems = this._containerRef.value.querySelectorAll("li:not([data-dropdown-toggle])");
|
|
276
|
+
const listItemWidths = [...listItems].map(o => o.offsetWidth);
|
|
277
|
+
let hiddenItems = 0;
|
|
278
|
+
let hiddenItemsWidth = 0;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Remove item by item until the sum of the remaining items
|
|
282
|
+
* is smaller than the width of the container.
|
|
283
|
+
* The first item will not be removed.
|
|
284
|
+
*/
|
|
285
|
+
while (hiddenItems < listItemWidths.length && containerOffsetWidth < containerScrollWidth - hiddenItemsWidth) {
|
|
286
|
+
hiddenItems += 1;
|
|
287
|
+
hiddenItemsWidth = listItemWidths.slice(1, 1 + hiddenItems).reduce((sum, itemWidth) => sum + itemWidth, 0);
|
|
288
|
+
}
|
|
289
|
+
this._hiddenItems += hiddenItems;
|
|
290
|
+
this._isRecalculating = false;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Render the dropdown menu
|
|
294
|
+
* @returns
|
|
295
|
+
*/
|
|
296
|
+
renderDropdown() {
|
|
297
|
+
if (this._dropdownItems.length === 0 && !this._isRecalculating) return nothing;
|
|
298
|
+
return html`
|
|
299
|
+
<li class="breadcrumbs__item" data-dropdown-toggle>
|
|
300
|
+
<span class="breadcrumbs__icon">${Icon("angleRight")}</span>
|
|
301
|
+
<leu-popup
|
|
302
|
+
?active=${this._isDropdownOpen}
|
|
303
|
+
placement="bottom-start"
|
|
304
|
+
shift
|
|
305
|
+
shiftPadding="8"
|
|
306
|
+
autoSize="width"
|
|
307
|
+
autoSizePadding="8"
|
|
308
|
+
>
|
|
309
|
+
<button
|
|
310
|
+
slot="anchor"
|
|
311
|
+
class="menu"
|
|
312
|
+
@click=${this._handleDropdownToggle}
|
|
313
|
+
tabindex="0"
|
|
314
|
+
>
|
|
315
|
+
…
|
|
316
|
+
</button>
|
|
317
|
+
<div class="dropdown">
|
|
318
|
+
${html`
|
|
319
|
+
<leu-menu>
|
|
320
|
+
${this._dropdownItems.map(item => html`
|
|
321
|
+
<leu-menu-item
|
|
322
|
+
label=${item.label}
|
|
323
|
+
href=${item.href}
|
|
324
|
+
></leu-menu-item>
|
|
325
|
+
`)}
|
|
326
|
+
</leu-menu>
|
|
327
|
+
`}
|
|
328
|
+
</div>
|
|
329
|
+
</leu-popup>
|
|
330
|
+
</li>
|
|
331
|
+
`;
|
|
332
|
+
}
|
|
333
|
+
render() {
|
|
334
|
+
if (this.items.length < 2) return nothing;
|
|
335
|
+
const parentItem = this.items[this.items.length - 2];
|
|
336
|
+
const showBackOnly = this._showBackOnly || this.items.length - this._hiddenItems < 2;
|
|
337
|
+
const wrapperClasses = {
|
|
338
|
+
breadcrumbs: true,
|
|
339
|
+
"breadcrumbs--back-only": showBackOnly
|
|
340
|
+
};
|
|
341
|
+
return html`
|
|
342
|
+
<nav class=${classMap(wrapperClasses)}>
|
|
343
|
+
<leu-visually-hidden><h2>Sie sind hier:</h2></leu-visually-hidden>
|
|
344
|
+
<ol class="breadcrumbs__list" ref=${ref(this._containerRef)}>
|
|
345
|
+
${showBackOnly ? html` <li class="breadcrumbs__item breadcrumbs__item--back">
|
|
346
|
+
<span class="breadcrumbs__icon">${Icon("arrowLeft")}</span>
|
|
347
|
+
<a class="breadcrumbs__link" href=${parentItem.href}
|
|
348
|
+
>${parentItem.label}</a
|
|
349
|
+
>
|
|
350
|
+
</li>` : this._listItems.map((item, index, list) => html`
|
|
351
|
+
<li class="breadcrumbs__item">
|
|
352
|
+
${index > 0 ? html`<span class="breadcrumbs__icon"
|
|
353
|
+
>${Icon("angleRight")}</span
|
|
354
|
+
>` // First list item doesn't have an arrow
|
|
355
|
+
: nothing}
|
|
356
|
+
${index === list.length - 1 ? item.label // Last list item doesn't contain a link
|
|
357
|
+
: html`<a class="breadcrumbs__link" href=${item.href}
|
|
358
|
+
>${item.label}</a
|
|
359
|
+
>`}
|
|
360
|
+
</li>
|
|
361
|
+
${index === 0 ? this.renderDropdown() : nothing}
|
|
362
|
+
`)}
|
|
363
|
+
</ol>
|
|
364
|
+
</nav>
|
|
365
|
+
`;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
_defineProperty(LeuBreadcrumb, "styles", css_248z);
|
|
369
|
+
_defineProperty(LeuBreadcrumb, "properties", {
|
|
370
|
+
items: {
|
|
371
|
+
type: Array
|
|
372
|
+
},
|
|
373
|
+
inverted: {
|
|
374
|
+
type: Boolean,
|
|
375
|
+
reflect: true
|
|
376
|
+
},
|
|
377
|
+
_hiddenItems: {
|
|
378
|
+
state: true
|
|
379
|
+
},
|
|
380
|
+
_showBackOnly: {
|
|
381
|
+
state: true
|
|
382
|
+
},
|
|
383
|
+
_isRecalculating: {
|
|
384
|
+
state: true
|
|
385
|
+
},
|
|
386
|
+
_isDropdownOpen: {
|
|
387
|
+
state: true
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
_defineProperty(LeuBreadcrumb, "BACK_ONLY_BREAKPOINT", 320);
|
|
391
|
+
|
|
392
|
+
export { LeuBreadcrumb };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reactive controller that determines when slots exist.
|
|
3
|
+
*/
|
|
4
|
+
export type ReactiveController = import("lit").ReactiveController;
|
|
5
|
+
declare const BUTTON_VARIANTS: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Thanks Shoelace!
|
|
8
|
+
* Source: https://github.com/shoelace-style/shoelace/blob/next/src/internal/slot.ts
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* A reactive controller that determines when slots exist.
|
|
12
|
+
* @typedef {import("lit").ReactiveController} ReactiveController
|
|
13
|
+
* @implements {ReactiveController}
|
|
14
|
+
*/
|
|
15
|
+
declare class HasSlotController implements ReactiveController {
|
|
16
|
+
constructor(host: any, slotNames: any);
|
|
17
|
+
host: any;
|
|
18
|
+
slotNames: any;
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
* @returns {Boolean}
|
|
22
|
+
*/
|
|
23
|
+
private hasDefaultSlot;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @param {String} name
|
|
27
|
+
* @returns {Boolean}
|
|
28
|
+
*/
|
|
29
|
+
private hasNamedSlot;
|
|
30
|
+
/**
|
|
31
|
+
* @param {String} slotName
|
|
32
|
+
* @returns {Boolean}
|
|
33
|
+
*/
|
|
34
|
+
test(slotName: string): boolean;
|
|
35
|
+
hostConnected(): void;
|
|
36
|
+
hostDisconnected(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @tagname leu-button
|
|
40
|
+
*/
|
|
41
|
+
declare class LeuButton extends LitElement {
|
|
42
|
+
label: any;
|
|
43
|
+
/** @type {string} */
|
|
44
|
+
icon: string;
|
|
45
|
+
/** @type {("before" | "after")} - Only taken into account if Label and no Icon is set */
|
|
46
|
+
iconPosition: ("before" | "after");
|
|
47
|
+
/** @type {string} */
|
|
48
|
+
size: string;
|
|
49
|
+
/** @type {string} */
|
|
50
|
+
variant: string;
|
|
51
|
+
/** @type {"button" | "submit" | "reset"} */
|
|
52
|
+
type: "button" | "submit" | "reset";
|
|
53
|
+
/** @type {boolean} */
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
/** @type {boolean} - Only taken into account if no Label and an Icon is set */
|
|
56
|
+
round: boolean;
|
|
57
|
+
/** @type {boolean} */
|
|
58
|
+
active: boolean;
|
|
59
|
+
/** @type {boolean} - will be used on dark Background */
|
|
60
|
+
inverted: boolean;
|
|
61
|
+
/** @type {boolean} - Alters the shape of the button to be full width of its parent container */
|
|
62
|
+
fluid: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Only taken into account if variant is "ghost"
|
|
65
|
+
* @type {("true" | "false" | undefined)}
|
|
66
|
+
*/
|
|
67
|
+
expanded: ("true" | "false" | undefined);
|
|
68
|
+
getIconSize(): 16 | 24;
|
|
69
|
+
renderIconBefore(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
70
|
+
renderIconAfter(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
71
|
+
renderExpandingIcon(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
72
|
+
getAriaAttributes(): {
|
|
73
|
+
role: any;
|
|
74
|
+
label: any;
|
|
75
|
+
};
|
|
76
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
77
|
+
}
|
|
78
|
+
declare const BUTTON_SIZES: string[];
|
|
79
|
+
declare const BUTTON_TYPES: string[];
|
|
80
|
+
declare const BUTTON_EXPANDED_OPTIONS: string[];
|
|
81
|
+
import { LitElement } from 'lit';
|
|
82
|
+
import { nothing } from 'lit';
|
|
83
|
+
export { BUTTON_VARIANTS as B, HasSlotController as H, LeuButton as L, BUTTON_SIZES as a, BUTTON_TYPES as b, BUTTON_EXPANDED_OPTIONS as c };
|
|
84
|
+
//# sourceMappingURL=Button-da11d064.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button-da11d064.d.ts","sourceRoot":"","sources":["Button-da11d064.js"],"names":[],"mappings":";;;iCAaa,OAAO,KAAK,EAAE,kBAAkB;AA8U7C,wCAA0D;AArV1D;;;GAGG;AAEH;;;;GAIG;AACH;IACE,uCAcC;IAHC,UAAgB;IAEhB,eAA0B;IAG5B;;;OAGG;IACH,uBAeC;IAED;;;;OAIG;IACH,qBAEC;IAED;;;OAGG;IACH,gCAEC;IACD,sBAEC;IACD,yBAEC;CACF;AAoSD;;GAEG;AACH;IAQI,WAAiB;IACjB,qBAAqB;IACrB,MADW,MAAM,CACD;IAChB,yFAAyF;IACzF,cADW,CAAC,QAAQ,GAAG,OAAO,CAAC,CACH;IAC5B,qBAAqB;IACrB,MADW,MAAM,CACI;IACrB,qBAAqB;IACrB,SADW,MAAM,CACO;IACxB,4CAA4C;IAC5C,MADW,QAAQ,GAAG,QAAQ,GAAG,OAAO,CACpB;IAEpB,sBAAsB;IACtB,UADW,OAAO,CACG;IACrB,+EAA+E;IAC/E,OADW,OAAO,CACA;IAClB,sBAAsB;IACtB,QADW,OAAO,CACC;IACnB,wDAAwD;IACxD,UADW,OAAO,CACG;IAErB,gGAAgG;IAChG,OADW,OAAO,CACA;IAElB;;;OAGG;IACH,UAFU,CAAC,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAEf;IAE3B,uBAEC;IACD,0EAOC;IACD,yEAOC;IACD,6EAOC;IACD;;;MAaC;IACD,+CA0BC;CACF;AAhID,qCAA0C;AAE1C,qCAAmD;AAEnD,gDAAkD;2BAhWH,KAAK;wBAAL,KAAK"}
|