@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,542 @@
|
|
|
1
|
+
import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
|
|
2
|
+
import { css, LitElement, html, nothing } from 'lit';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
|
+
import { I as Icon } from './icon-03e86700.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Thanks Shoelace!
|
|
9
|
+
* Source: https://github.com/shoelace-style/shoelace/blob/next/src/internal/slot.ts
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A reactive controller that determines when slots exist.
|
|
14
|
+
* @typedef {import("lit").ReactiveController} ReactiveController
|
|
15
|
+
* @implements {ReactiveController}
|
|
16
|
+
*/
|
|
17
|
+
class HasSlotController {
|
|
18
|
+
constructor(host, slotNames) {
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
* @param {Event} event
|
|
22
|
+
*/
|
|
23
|
+
_defineProperty(this, "handleSlotChange", event => {
|
|
24
|
+
const slot = event.target;
|
|
25
|
+
if (slot instanceof HTMLSlotElement && (this.slotNames.includes("[default]") && !slot.name || slot.name && this.slotNames.includes(slot.name))) {
|
|
26
|
+
this.host.requestUpdate();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.host = host;
|
|
30
|
+
host.addController(this);
|
|
31
|
+
this.slotNames = slotNames;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @private
|
|
36
|
+
* @returns {Boolean}
|
|
37
|
+
*/
|
|
38
|
+
hasDefaultSlot() {
|
|
39
|
+
return [...this.host.childNodes].some(node => {
|
|
40
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent.trim() !== "") {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
if (node.nodeType === node.ELEMENT_NODE) {
|
|
44
|
+
const el = node;
|
|
45
|
+
|
|
46
|
+
// If it doesn't have a slot attribute, it's part of the default slot
|
|
47
|
+
if (!el.hasAttribute("slot")) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @param {String} name
|
|
58
|
+
* @returns {Boolean}
|
|
59
|
+
*/
|
|
60
|
+
hasNamedSlot(name) {
|
|
61
|
+
return this.host.querySelector(`:scope > [slot="${name}"]`) !== null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {String} slotName
|
|
66
|
+
* @returns {Boolean}
|
|
67
|
+
*/
|
|
68
|
+
test(slotName) {
|
|
69
|
+
return slotName === "[default]" ? this.hasDefaultSlot() : this.hasNamedSlot(slotName);
|
|
70
|
+
}
|
|
71
|
+
hostConnected() {
|
|
72
|
+
this.host.shadowRoot.addEventListener("slotchange", this.handleSlotChange);
|
|
73
|
+
}
|
|
74
|
+
hostDisconnected() {
|
|
75
|
+
this.host.shadowRoot.removeEventListener("slotchange", this.handleSlotChange);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
var css_248z = css`:host {
|
|
80
|
+
display: inline-block;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
button {
|
|
84
|
+
font-family: var(--leu-font-family-black);
|
|
85
|
+
text-align: center;
|
|
86
|
+
-webkit-appearance: none;
|
|
87
|
+
-moz-appearance: none;
|
|
88
|
+
appearance: none;
|
|
89
|
+
transition: background 0.1s ease;
|
|
90
|
+
cursor: pointer;
|
|
91
|
+
border: 1px solid transparent;
|
|
92
|
+
border-radius: 2px;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
-moz-column-gap: 8px;
|
|
96
|
+
column-gap: 8px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
button.round {
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
button:disabled {
|
|
104
|
+
cursor: not-allowed;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
button:focus-visible {
|
|
108
|
+
border: 1px solid var(--leu-color-black-0);
|
|
109
|
+
outline: 2px solid var(--leu-color-func-cyan);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
button.inverted:focus-visible {
|
|
113
|
+
border: 1px solid var(--leu-color-black-100);
|
|
114
|
+
outline: 2px solid var(--leu-color-black-0);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:host([fluid]) button {
|
|
118
|
+
width: 100%;
|
|
119
|
+
justify-content: center;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* size - regular */
|
|
123
|
+
|
|
124
|
+
button.regular {
|
|
125
|
+
padding: 12px 24px;
|
|
126
|
+
font-size: 16px;
|
|
127
|
+
line-height: 24px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
button.regular.icon {
|
|
131
|
+
padding: 12px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* size - small */
|
|
135
|
+
|
|
136
|
+
button.small {
|
|
137
|
+
padding: 6px 24px;
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
line-height: 20px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
button.small.icon {
|
|
143
|
+
padding: 8px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* primary */
|
|
147
|
+
|
|
148
|
+
button.primary {
|
|
149
|
+
color: var(--leu-color-black-0);
|
|
150
|
+
background: var(--leu-color-black-100);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
button.primary:hover {
|
|
154
|
+
color: var(--leu-color-black-0);
|
|
155
|
+
background: var(--leu-color-black-transp-80);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
button.primary.active {
|
|
159
|
+
color: var(--leu-color-black-0);
|
|
160
|
+
background: var(--leu-color-black-100);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
button.primary.active:hover {
|
|
164
|
+
background: var(--leu-color-black-transp-80);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
button.primary:disabled {
|
|
168
|
+
color: var(--leu-color-black-0);
|
|
169
|
+
background: var(--leu-color-black-transp-20);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/* secondary */
|
|
173
|
+
|
|
174
|
+
button.secondary {
|
|
175
|
+
color: var(--leu-color-black-transp-60);
|
|
176
|
+
background: var(--leu-color-black-transp-10);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
button.secondary:hover {
|
|
180
|
+
color: var(--leu-color-black-100);
|
|
181
|
+
background: var(--leu-color-black-transp-20);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
button.secondary.active {
|
|
185
|
+
color: var(--leu-color-black-0);
|
|
186
|
+
background: var(--leu-color-black-100);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
button.secondary.active:hover {
|
|
190
|
+
background: var(--leu-color-black-transp-80);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
button.secondary:disabled {
|
|
194
|
+
color: var(--leu-color-black-transp-20);
|
|
195
|
+
background: var(--leu-color-black-transp-5);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* ghost */
|
|
199
|
+
|
|
200
|
+
button.ghost {
|
|
201
|
+
background: transparent;
|
|
202
|
+
padding: 0 0.5rem;
|
|
203
|
+
color: var(--leu-color-black-60);
|
|
204
|
+
font-family: var(--leu-font-family-regular);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
button.ghost:hover {
|
|
208
|
+
color: var(--leu-color-black-100);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
button.ghost.active {
|
|
212
|
+
color: var(--leu-color-black-100);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
button.ghost:disabled {
|
|
216
|
+
color: var(--leu-color-black-20);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* primary + inverted */
|
|
220
|
+
|
|
221
|
+
button.primary.inverted {
|
|
222
|
+
color: var(--leu-color-black-100);
|
|
223
|
+
background: var(--leu-color-black-0);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
button.primary.inverted:hover {
|
|
227
|
+
color: var(--leu-color-black-100);
|
|
228
|
+
background: var(--leu-color-white-transp-70);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
button.primary.inverted.active {
|
|
232
|
+
color: var(--leu-color-black-0);
|
|
233
|
+
background: var(--leu-color-black-100);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
button.primary.inverted:disabled {
|
|
237
|
+
color: var(--leu-color-black-40);
|
|
238
|
+
background: var(--leu-color-white-transp-70);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* secondary + inverted */
|
|
242
|
+
|
|
243
|
+
button.secondary.inverted {
|
|
244
|
+
color: var(--leu-color-black-0);
|
|
245
|
+
background: var(--leu-color-black-transp-20);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
button.secondary.inverted:hover {
|
|
249
|
+
color: var(--leu-color-black-0);
|
|
250
|
+
background: var(--leu-color-black-transp-40);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
button.secondary.inverted.active {
|
|
254
|
+
color: var(--leu-color-black-100);
|
|
255
|
+
background: var(--leu-color-black-0);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
button.secondary.inverted:disabled {
|
|
259
|
+
color: var(--leu-color-white-transp-70);
|
|
260
|
+
background: var(--leu-color-black-transp-10);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* ghost + inverted */
|
|
264
|
+
|
|
265
|
+
button.ghost.inverted {
|
|
266
|
+
color: var(--leu-color-black-0);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
button.ghost.inverted:hover {
|
|
270
|
+
color: var(--leu-color-white-transp-70);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
button.ghost.inverted.active {
|
|
274
|
+
color: var(--leu-color-black-0);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
button.ghost.inverted:disabled {
|
|
278
|
+
color: var(--leu-color-black-20);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* icon-wrapper */
|
|
282
|
+
|
|
283
|
+
.icon-wrapper svg {
|
|
284
|
+
display: block;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.ghost .icon-wrapper--before, .ghost .icon-wrapper--after {
|
|
288
|
+
padding: 0.5rem;
|
|
289
|
+
border-radius: 50%;
|
|
290
|
+
background: var(--leu-color-black-transp-10);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.ghost.active .icon-wrapper--before, .ghost.active .icon-wrapper--after {
|
|
294
|
+
background: var(--leu-color-black-100);
|
|
295
|
+
color: var(--leu-color-black-0);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.ghost:disabled .icon-wrapper--before {
|
|
299
|
+
background: var(--leu-color-black-transp-5);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.ghost:disabled .icon-wrapper--after {
|
|
303
|
+
background: var(--leu-color-black-transp-5);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* inverted */
|
|
307
|
+
|
|
308
|
+
.ghost.inverted .icon-wrapper--before, .ghost.inverted .icon-wrapper--after {
|
|
309
|
+
background: var(--leu-color-black-transp-20);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.ghost.inverted:hover .icon-wrapper--before, .ghost.inverted:hover .icon-wrapper--after {
|
|
313
|
+
background: var(--leu-color-black-transp-40);
|
|
314
|
+
color: var(--leu-color-black-0);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.ghost.inverted:disabled .icon-wrapper--before {
|
|
318
|
+
background: var(--leu-color-black-transp-20);
|
|
319
|
+
color: var(--leu-color-white-transp-70);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.ghost.inverted:disabled .icon-wrapper--after {
|
|
323
|
+
background: var(--leu-color-black-transp-20);
|
|
324
|
+
color: var(--leu-color-white-transp-70);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.ghost.active.inverted .icon-wrapper--before, .ghost.active.inverted .icon-wrapper--after {
|
|
328
|
+
background: var(--leu-color-black-0);
|
|
329
|
+
color: var(--leu-color-black-100);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/* Expanded icon */
|
|
333
|
+
|
|
334
|
+
.icon-wrapper--expanded {
|
|
335
|
+
transition: transform 0.1s ease;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
:host([expanded="open"]) .icon-wrapper--expanded {
|
|
339
|
+
transform: rotate(180deg);
|
|
340
|
+
}
|
|
341
|
+
`;
|
|
342
|
+
|
|
343
|
+
/*
|
|
344
|
+
Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=4-1444&mode=design&t=xu5Vii8jXKKCKDez-0
|
|
345
|
+
Live Demo: zh.ch
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
const BUTTON_VARIANTS = ["primary", "secondary", "ghost"];
|
|
349
|
+
Object.freeze(BUTTON_VARIANTS);
|
|
350
|
+
const BUTTON_SIZES = ["regular", "small"];
|
|
351
|
+
Object.freeze(BUTTON_SIZES);
|
|
352
|
+
const BUTTON_TYPES = ["button", "submit", "reset"];
|
|
353
|
+
Object.freeze(BUTTON_TYPES);
|
|
354
|
+
const BUTTON_EXPANDED_OPTIONS = ["true", "false"];
|
|
355
|
+
Object.freeze(BUTTON_EXPANDED_OPTIONS);
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* All roles that are associated with a aria-checked attribute
|
|
359
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
|
|
360
|
+
*/
|
|
361
|
+
const ARIA_ROLES_CHECKED = ["checkbox", "menuitemcheckbox", "menuitemradio", "option", "radio", "switch"];
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* All roles that are associated with a aria-selected attribute
|
|
365
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected
|
|
366
|
+
*/
|
|
367
|
+
const ARIA_ROLES_SELECTED = ["gridcell", "option", "row", "tab", "columnheader", "rowheader", "treeitem"];
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @tagname leu-button
|
|
371
|
+
*/
|
|
372
|
+
class LeuButton extends LitElement {
|
|
373
|
+
constructor() {
|
|
374
|
+
super();
|
|
375
|
+
/** @type {string} */
|
|
376
|
+
/**
|
|
377
|
+
* @internal
|
|
378
|
+
*/
|
|
379
|
+
_defineProperty(this, "hasSlotController", new HasSlotController(this, ["[default]"]));
|
|
380
|
+
this.label = null;
|
|
381
|
+
/** @type {string} */
|
|
382
|
+
this.icon = null;
|
|
383
|
+
/** @type {("before" | "after")} - Only taken into account if Label and no Icon is set */
|
|
384
|
+
this.iconPosition = "before";
|
|
385
|
+
/** @type {string} */
|
|
386
|
+
this.size = "regular";
|
|
387
|
+
/** @type {string} */
|
|
388
|
+
this.variant = "primary";
|
|
389
|
+
/** @type {"button" | "submit" | "reset"} */
|
|
390
|
+
this.type = "button";
|
|
391
|
+
|
|
392
|
+
/** @type {boolean} */
|
|
393
|
+
this.disabled = false;
|
|
394
|
+
/** @type {boolean} - Only taken into account if no Label and an Icon is set */
|
|
395
|
+
this.round = false;
|
|
396
|
+
/** @type {boolean} */
|
|
397
|
+
this.active = false;
|
|
398
|
+
/** @type {boolean} - will be used on dark Background */
|
|
399
|
+
this.inverted = false;
|
|
400
|
+
|
|
401
|
+
/** @type {boolean} - Alters the shape of the button to be full width of its parent container */
|
|
402
|
+
this.fluid = false;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Only taken into account if variant is "ghost"
|
|
406
|
+
* @type {("true" | "false" | undefined)}
|
|
407
|
+
*/
|
|
408
|
+
this.expanded = undefined;
|
|
409
|
+
}
|
|
410
|
+
getIconSize() {
|
|
411
|
+
return this.size === "small" || this.variant === "ghost" ? 16 : 24;
|
|
412
|
+
}
|
|
413
|
+
renderIconBefore() {
|
|
414
|
+
if (this.icon && this.iconPosition === "before") {
|
|
415
|
+
return html`<div class="icon-wrapper icon-wrapper--before">
|
|
416
|
+
${Icon(this.icon, this.getIconSize())}
|
|
417
|
+
</div>`;
|
|
418
|
+
}
|
|
419
|
+
return nothing;
|
|
420
|
+
}
|
|
421
|
+
renderIconAfter() {
|
|
422
|
+
if (this.icon && this.iconPosition === "after") {
|
|
423
|
+
return html`<div class="icon-wrapper icon-wrapper--after">
|
|
424
|
+
${Icon(this.icon, this.getIconSize())}
|
|
425
|
+
</div>`;
|
|
426
|
+
}
|
|
427
|
+
return nothing;
|
|
428
|
+
}
|
|
429
|
+
renderExpandingIcon() {
|
|
430
|
+
if (typeof this.expanded !== "undefined" && this.variant === "ghost") {
|
|
431
|
+
return html`<div class="icon-wrapper icon-wrapper--expanded">
|
|
432
|
+
${Icon("angleDropDown", 24)}
|
|
433
|
+
</div>`;
|
|
434
|
+
}
|
|
435
|
+
return nothing;
|
|
436
|
+
}
|
|
437
|
+
getAriaAttributes() {
|
|
438
|
+
const attributes = {
|
|
439
|
+
role: this.componentRole,
|
|
440
|
+
label: this.label
|
|
441
|
+
};
|
|
442
|
+
if (this.componentRole) {
|
|
443
|
+
if (ARIA_ROLES_CHECKED.includes(this.componentRole)) {
|
|
444
|
+
attributes.checked = this.active ? "true" : "false";
|
|
445
|
+
} else if (ARIA_ROLES_SELECTED.includes(this.componentRole)) {
|
|
446
|
+
attributes.selected = this.active ? "true" : "false";
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return attributes;
|
|
450
|
+
}
|
|
451
|
+
render() {
|
|
452
|
+
const hasContent = this.hasSlotController.test("[default]");
|
|
453
|
+
const aria = this.getAriaAttributes();
|
|
454
|
+
const cssClasses = {
|
|
455
|
+
icon: !hasContent && this.icon,
|
|
456
|
+
round: !hasContent && this.icon && this.round,
|
|
457
|
+
active: this.active,
|
|
458
|
+
inverted: this.inverted,
|
|
459
|
+
[this.variant]: true,
|
|
460
|
+
[this.size]: true
|
|
461
|
+
};
|
|
462
|
+
return html`
|
|
463
|
+
<button
|
|
464
|
+
aria-label=${ifDefined(aria.label)}
|
|
465
|
+
aria-selected=${ifDefined(aria.selected)}
|
|
466
|
+
aria-checked=${ifDefined(aria.checked)}
|
|
467
|
+
role=${ifDefined(aria.role)}
|
|
468
|
+
class=${classMap(cssClasses)}
|
|
469
|
+
?disabled=${this.disabled}
|
|
470
|
+
type=${this.type}
|
|
471
|
+
>
|
|
472
|
+
${this.renderIconBefore()}
|
|
473
|
+
<slot></slot>
|
|
474
|
+
${this.renderIconAfter()} ${this.renderExpandingIcon()}
|
|
475
|
+
</button>
|
|
476
|
+
`;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
_defineProperty(LeuButton, "styles", css_248z);
|
|
480
|
+
/**
|
|
481
|
+
* @internal
|
|
482
|
+
*/
|
|
483
|
+
_defineProperty(LeuButton, "shadowRootOptions", {
|
|
484
|
+
...LitElement.shadowRootOptions,
|
|
485
|
+
delegatesFocus: true
|
|
486
|
+
});
|
|
487
|
+
_defineProperty(LeuButton, "properties", {
|
|
488
|
+
label: {
|
|
489
|
+
type: String,
|
|
490
|
+
reflect: true
|
|
491
|
+
},
|
|
492
|
+
icon: {
|
|
493
|
+
type: String,
|
|
494
|
+
reflect: true
|
|
495
|
+
},
|
|
496
|
+
iconPosition: {
|
|
497
|
+
type: String,
|
|
498
|
+
reflect: true
|
|
499
|
+
},
|
|
500
|
+
size: {
|
|
501
|
+
type: String,
|
|
502
|
+
reflect: true
|
|
503
|
+
},
|
|
504
|
+
variant: {
|
|
505
|
+
type: String,
|
|
506
|
+
reflect: true
|
|
507
|
+
},
|
|
508
|
+
type: {
|
|
509
|
+
type: String,
|
|
510
|
+
reflect: true
|
|
511
|
+
},
|
|
512
|
+
componentRole: {
|
|
513
|
+
type: String,
|
|
514
|
+
reflect: true
|
|
515
|
+
},
|
|
516
|
+
disabled: {
|
|
517
|
+
type: Boolean,
|
|
518
|
+
reflect: true
|
|
519
|
+
},
|
|
520
|
+
round: {
|
|
521
|
+
type: Boolean,
|
|
522
|
+
reflect: true
|
|
523
|
+
},
|
|
524
|
+
active: {
|
|
525
|
+
type: Boolean,
|
|
526
|
+
reflect: true
|
|
527
|
+
},
|
|
528
|
+
inverted: {
|
|
529
|
+
type: Boolean,
|
|
530
|
+
reflect: true
|
|
531
|
+
},
|
|
532
|
+
expanded: {
|
|
533
|
+
type: String,
|
|
534
|
+
reflect: true
|
|
535
|
+
},
|
|
536
|
+
fluid: {
|
|
537
|
+
type: Boolean,
|
|
538
|
+
reflect: true
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
export { BUTTON_VARIANTS as B, HasSlotController as H, LeuButton as L, BUTTON_SIZES as a, BUTTON_TYPES as b, BUTTON_EXPANDED_OPTIONS as c };
|
package/dist/Button.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["Button.js"],"names":[],"mappings":""}
|