@statistikzh/leu 0.0.2 → 0.1.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.
Files changed (48) hide show
  1. package/.github/workflows/release-please.yml +20 -1
  2. package/CHANGELOG.md +12 -0
  3. package/babel.config.json +3 -0
  4. package/dist/{Button-83c6df93.js → Button.js} +58 -50
  5. package/dist/ButtonGroup.js +75 -0
  6. package/dist/Checkbox.js +60 -57
  7. package/dist/CheckboxGroup.js +35 -41
  8. package/dist/{Chip-60af1402.js → Chip-389013ff.js} +12 -13
  9. package/dist/ChipGroup.js +27 -34
  10. package/dist/ChipLink.js +18 -19
  11. package/dist/ChipRemovable.js +9 -13
  12. package/dist/ChipSelectable.js +42 -44
  13. package/dist/Dropdown.js +75 -0
  14. package/dist/Input.js +112 -122
  15. package/dist/Menu.js +33 -0
  16. package/dist/MenuItem.js +171 -0
  17. package/dist/Pagination.js +193 -0
  18. package/dist/Radio.js +26 -22
  19. package/dist/RadioGroup.js +75 -105
  20. package/dist/Select.js +103 -337
  21. package/dist/Table.js +294 -8
  22. package/dist/defineElement-ba770aed.js +44 -0
  23. package/dist/icon-03e86700.js +136 -0
  24. package/dist/index.js +14 -9
  25. package/dist/leu-button-group.js +8 -0
  26. package/dist/leu-button.js +7 -0
  27. package/dist/leu-checkbox-group.js +1 -1
  28. package/dist/leu-checkbox.js +2 -2
  29. package/dist/leu-chip-group.js +1 -1
  30. package/dist/leu-chip-link.js +2 -2
  31. package/dist/leu-chip-removable.js +3 -3
  32. package/dist/leu-chip-selectable.js +2 -2
  33. package/dist/leu-dropdown.js +10 -0
  34. package/dist/leu-input.js +2 -2
  35. package/dist/leu-menu-item.js +6 -0
  36. package/dist/leu-menu.js +5 -0
  37. package/dist/leu-pagination.js +8 -0
  38. package/dist/leu-radio-group.js +1 -1
  39. package/dist/leu-radio.js +1 -1
  40. package/dist/leu-select.js +5 -3
  41. package/dist/leu-table.js +5 -4
  42. package/index.js +7 -3
  43. package/package.json +3 -1
  44. package/rollup.config.js +26 -9
  45. package/.github/workflows/publish.yml +0 -19
  46. package/dist/Table-72d305d7.js +0 -506
  47. package/dist/defineElement-47d4f665.js +0 -15
  48. package/dist/icon-b68c7e1e.js +0 -202
package/dist/Menu.js ADDED
@@ -0,0 +1,33 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
2
+ import { css, LitElement, html } from 'lit';
3
+
4
+ var css_248z = css`:host,
5
+ :host * {
6
+ box-sizing: border-box;
7
+ }
8
+
9
+ :host {
10
+ --menu-divider-color: var(--leu-color-black-transp-20);
11
+ }
12
+
13
+ :host ::slotted(hr) {
14
+ border: 0;
15
+ border-top: 1px solid var(--menu-divider-color);
16
+ margin: 0.5rem 0;
17
+ }
18
+ `;
19
+
20
+ /**
21
+ * @tagname leu-menu
22
+ */
23
+ class LeuMenu extends LitElement {
24
+ render() {
25
+ return html`<slot></slot>`;
26
+ }
27
+ }
28
+ _defineProperty(LeuMenu, "styles", css_248z);
29
+ function defineMenuElements() {
30
+ defineElement("menu", LeuMenu);
31
+ }
32
+
33
+ export { LeuMenu, defineMenuElements };
@@ -0,0 +1,171 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
2
+ import { css, LitElement, html, nothing } from 'lit';
3
+ import { a as ICON_NAMES, I as Icon } from './icon-03e86700.js';
4
+
5
+ var css_248z = css`:host,
6
+ :host * {
7
+ box-sizing: border-box;
8
+ }
9
+
10
+ :host {
11
+ --background: var(--leu-color-black-0);
12
+ --background-hover: var(--leu-color-black-10);
13
+ --background-active: var(--leu-color-func-cyan);
14
+ --background-disabled: var(--leu-color-black-0);
15
+ --color: var(--leu-color-black-transp-60);
16
+ --font-regular: var(--leu-font-regular);
17
+ --font-black: var(--leu-font-black);
18
+
19
+ font-family: var(--chip-font-regular);
20
+ }
21
+
22
+ .button {
23
+ -webkit-appearance: none;
24
+ -moz-appearance: none;
25
+ appearance: none;
26
+ border: none;
27
+ cursor: pointer;
28
+
29
+ display: flex;
30
+ align-items: center;
31
+ gap: 0.5rem;
32
+ width: 100%;
33
+
34
+ padding: 0.75rem;
35
+
36
+ font-size: 1rem;
37
+ line-height: 1.5;
38
+ text-align: left;
39
+
40
+ background: var(--background);
41
+ color: var(--color);
42
+ }
43
+
44
+ .button:focus-visible {
45
+ outline: 2px solid var(--leu-color-func-cyan);
46
+ outline-offset: 2px;
47
+ }
48
+
49
+ .button:hover,
50
+ :host([highlighted]) .button {
51
+ --background: var(--background-hover);
52
+ }
53
+
54
+ :host([active]) .button {
55
+ --background: var(--background-active);
56
+ }
57
+
58
+ :host([disabled]) .button {
59
+ --background: var(--background-disabled);
60
+ cursor: default;
61
+ }
62
+
63
+ .before svg, .after svg {
64
+ display: block;
65
+ }
66
+
67
+ .label {
68
+ flex: 1;
69
+ overflow: hidden;
70
+ text-overflow: ellipsis;
71
+ white-space: nowrap;
72
+ }
73
+
74
+ .icon-placeholder {
75
+ display: block;
76
+ width: 1.5rem;
77
+ aspect-ratio: 1;
78
+ }
79
+ `;
80
+
81
+ /**
82
+ * @tagname leu-menu-item
83
+ * @slot - The label of the menu item
84
+ */
85
+ class LeuMenuItem extends LitElement {
86
+ constructor() {
87
+ super();
88
+ this.active = false;
89
+ this.disabled = false;
90
+ this.before = "";
91
+ this.after = "";
92
+
93
+ /**
94
+ * A programmatic way to highlight the menu item like it is hovered.
95
+ * This is just a visual effect and does not change the active state.
96
+ */
97
+ this.highlighted = false;
98
+ }
99
+ static getIconOrText(name) {
100
+ if (ICON_NAMES.includes(name)) {
101
+ return Icon(name);
102
+ }
103
+ if (name === "EMPTY") {
104
+ return html`<div class="icon-placeholder"></div>`;
105
+ }
106
+ return name;
107
+ }
108
+ renderBefore() {
109
+ if (this.before !== "") {
110
+ const content = LeuMenuItem.getIconOrText(this.before);
111
+ return html`<span class="before">${content}</span>`;
112
+ }
113
+ return nothing;
114
+ }
115
+ renderAfter() {
116
+ if (this.after !== "") {
117
+ const content = LeuMenuItem.getIconOrText(this.after);
118
+ return html`<span class="after">${content}</span>`;
119
+ }
120
+ return nothing;
121
+ }
122
+ render() {
123
+ return html`<button class="button" ?disabled=${this.disabled}>
124
+ ${this.renderBefore()}<span class="label"><slot></slot></span
125
+ >${this.renderAfter()}
126
+ </button>`;
127
+ }
128
+ }
129
+ _defineProperty(LeuMenuItem, "styles", css_248z);
130
+ /**
131
+ * @internal
132
+ */
133
+ _defineProperty(LeuMenuItem, "shadowRootOptions", {
134
+ ...LitElement.shadowRootOptions,
135
+ delegatesFocus: true
136
+ });
137
+ _defineProperty(LeuMenuItem, "properties", {
138
+ /**
139
+ * Can be either an icon name or a text
140
+ * If no icon with this value is found, it will be displayed as text.
141
+ * If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
142
+ */
143
+ before: {
144
+ type: String
145
+ },
146
+ /**
147
+ * Can be either an icon name or a text
148
+ * If no icon with this value is found, it will be displayed as text
149
+ * If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
150
+ */
151
+ after: {
152
+ type: String
153
+ },
154
+ active: {
155
+ type: Boolean,
156
+ reflect: true
157
+ },
158
+ highlighted: {
159
+ type: Boolean,
160
+ reflect: true
161
+ },
162
+ disabled: {
163
+ type: Boolean,
164
+ reflect: true
165
+ }
166
+ });
167
+ function defineMenuItemElements() {
168
+ defineElement("menu-item", LeuMenuItem);
169
+ }
170
+
171
+ export { LeuMenuItem, defineMenuItemElements };
@@ -0,0 +1,193 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
2
+ import { css, LitElement, html } from 'lit';
3
+ import { defineButtonElements } from './Button.js';
4
+ import 'lit/directives/class-map.js';
5
+ import './icon-03e86700.js';
6
+
7
+ var css_248z = css`:host {
8
+ margin-top: 16px;
9
+ display: flex;
10
+ justify-content: end;
11
+ font-family: var(--leu-font-regular);
12
+ }
13
+
14
+ .input {
15
+ width: 50px;
16
+ padding: 0;
17
+ border: 2px solid var(--leu-color-black-40);
18
+ border-radius: 2px;
19
+ color: var(--leu-color-black-transp-60);
20
+ text-align: center;
21
+ font-size: 16px;
22
+ font-style: normal;
23
+ font-weight: 400;
24
+ line-height: 24px;
25
+ outline-offset: 2px;
26
+ }
27
+
28
+ /* no arrows: Chrome, Safari, Edge, Opera */
29
+
30
+ .input::-webkit-outer-spin-button,
31
+ .input::-webkit-inner-spin-button {
32
+ -webkit-appearance: none;
33
+ appearance: none;
34
+ margin: 0;
35
+ }
36
+
37
+ /* no arrows: Firefox */
38
+
39
+ .input[type="number"] {
40
+ -webkit-appearance: textfield;
41
+ -moz-appearance: textfield;
42
+ appearance: textfield;
43
+ }
44
+
45
+ .input:focus,
46
+ .input:hover {
47
+ border-color: var(--leu-color-func-cyan);
48
+ outline: none;
49
+ }
50
+
51
+ .input:focus-visible {
52
+ outline: 2px solid var(--leu-color-func-cyan);
53
+ }
54
+
55
+ .label {
56
+ margin: 0 16px;
57
+ line-height: 50px;
58
+ color: var(--leu-color-black-transp-60);
59
+ white-space: nowrap;
60
+ }
61
+ `;
62
+
63
+ const MIN_PAGE = 1;
64
+
65
+ /**
66
+ * @tagname leu-pagination
67
+ */
68
+ class LeuPagination extends LitElement {
69
+ constructor() {
70
+ super();
71
+ /** @type {number} */
72
+ this.page = 1;
73
+ /** @type {number} */
74
+ this.dataLength = 0;
75
+ /** @type {number} */
76
+ this.itemsOnAPage = 30;
77
+ }
78
+ get maxPage() {
79
+ return Math.ceil(this.dataLength / this.itemsOnAPage);
80
+ }
81
+ get firstPage() {
82
+ return this.page === MIN_PAGE;
83
+ }
84
+ get lastPage() {
85
+ return this.page === this.maxPage;
86
+ }
87
+ holdInRange(value) {
88
+ return Math.min(Math.max(value, MIN_PAGE), this.maxPage);
89
+ }
90
+ numberUpdate(number) {
91
+ this.page = this.holdInRange(number);
92
+ const min = (this.page - 1) * this.itemsOnAPage;
93
+ const max = Math.min(min + this.itemsOnAPage, this.dataLength);
94
+ this.dispatchEvent(new CustomEvent("range-updated", {
95
+ detail: {
96
+ min,
97
+ max
98
+ },
99
+ bubbles: false
100
+ }));
101
+ }
102
+ change(event) {
103
+ // target.value = this.page // eslint-disable-line
104
+ this.numberUpdate(parseInt(event.target.value, 10) || 0);
105
+ }
106
+ input(event) {
107
+ if (event.target.value !== "") {
108
+ event.preventDefault();
109
+ this.change(event);
110
+ }
111
+ }
112
+ keydown(event) {
113
+ const specialKeys = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Backspace", "Enter", "Tab"];
114
+ const numberKeys = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
115
+ if (!numberKeys.includes(event.key) && !specialKeys.includes(event.key)) {
116
+ event.preventDefault();
117
+ } else {
118
+ if (event.key === "ArrowUp") {
119
+ event.preventDefault();
120
+ this.numberUpdate(this.page + 1);
121
+ }
122
+ if (event.key === "ArrowDown") {
123
+ event.preventDefault();
124
+ this.numberUpdate(this.page - 1);
125
+ }
126
+ }
127
+ }
128
+ firstUpdated() {
129
+ this.numberUpdate(this.page);
130
+ }
131
+ requestUpdate(name, oldValue, newValue) {
132
+ if (name === "itemsOnAPage") {
133
+ this.numberUpdate(this.page);
134
+ }
135
+ return super.requestUpdate(name, oldValue, newValue);
136
+ }
137
+ render() {
138
+ return html`
139
+ <input
140
+ class="input"
141
+ .value=${this.page}
142
+ @input=${this.input}
143
+ @change=${this.change}
144
+ @keydown=${this.keydown}
145
+ type="number"
146
+ />
147
+ <div class="label">von ${this.maxPage}</div>
148
+ <leu-button
149
+ icon="angleLeft"
150
+ variant="secondary"
151
+ @click=${_ => {
152
+ this.numberUpdate(this.page - 1);
153
+ }}
154
+ ?disabled=${this.firstPage}
155
+ ></leu-button>
156
+ <leu-button
157
+ icon="angleRight"
158
+ variant="secondary"
159
+ @click=${_ => {
160
+ this.numberUpdate(this.page + 1);
161
+ }}
162
+ ?disabled=${this.lastPage}
163
+ style="margin-left:4px;"
164
+ ></leu-button>
165
+ `;
166
+ }
167
+ }
168
+ _defineProperty(LeuPagination, "styles", css_248z);
169
+ _defineProperty(LeuPagination, "events", {
170
+ range: {}
171
+ });
172
+ _defineProperty(LeuPagination, "properties", {
173
+ page: {
174
+ type: Number,
175
+ reflect: true
176
+ },
177
+ itemsOnAPage: {
178
+ type: Number
179
+ },
180
+ dataLength: {
181
+ type: Number
182
+ },
183
+ _minPage: {
184
+ type: Number,
185
+ state: true
186
+ }
187
+ });
188
+ function definePaginationElements() {
189
+ defineButtonElements();
190
+ defineElement("pagination", LeuPagination);
191
+ }
192
+
193
+ export { LeuPagination, definePaginationElements };
package/dist/Radio.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
1
2
  import { css, LitElement, html } from 'lit';
2
- import { d as defineElement } from './defineElement-47d4f665.js';
3
3
 
4
4
  var css_248z = css`:host {
5
5
  --radio-color: var(--leu-color-black-40);
@@ -98,39 +98,20 @@ var css_248z = css`:host {
98
98
  * @tagname leu-radio
99
99
  */
100
100
  class LeuRadio extends LitElement {
101
- static styles = css_248z
102
-
103
- static shadowRootOptions = {
104
- ...LitElement.shadowRootOptions,
105
- delegatesFocus: true,
106
- }
107
-
108
- static properties = {
109
- checked: { type: Boolean, reflect: true },
110
- disabled: { type: Boolean, reflect: true },
111
- identifier: { type: String },
112
- value: { type: String },
113
- name: { type: String },
114
- }
115
-
116
101
  constructor() {
117
102
  super();
118
103
  this.checked = false;
119
104
  this.disabled = false;
120
105
  this.tabIndex = 0;
121
106
  }
122
-
123
107
  handleChange(event) {
124
108
  this.checked = event.target.checked;
125
-
126
109
  const customEvent = new CustomEvent(event.type, event);
127
110
  this.dispatchEvent(customEvent);
128
111
  }
129
-
130
112
  handleInput(event) {
131
113
  this.checked = event.target.checked;
132
114
  }
133
-
134
115
  render() {
135
116
  return html`
136
117
  <input
@@ -145,10 +126,33 @@ class LeuRadio extends LitElement {
145
126
  .value=${this.value}
146
127
  />
147
128
  <label for=${this.identifier} class="label"><slot></slot></label>
148
- `
129
+ `;
149
130
  }
150
131
  }
151
-
132
+ _defineProperty(LeuRadio, "styles", css_248z);
133
+ _defineProperty(LeuRadio, "shadowRootOptions", {
134
+ ...LitElement.shadowRootOptions,
135
+ delegatesFocus: true
136
+ });
137
+ _defineProperty(LeuRadio, "properties", {
138
+ checked: {
139
+ type: Boolean,
140
+ reflect: true
141
+ },
142
+ disabled: {
143
+ type: Boolean,
144
+ reflect: true
145
+ },
146
+ identifier: {
147
+ type: String
148
+ },
149
+ value: {
150
+ type: String
151
+ },
152
+ name: {
153
+ type: String
154
+ }
155
+ });
152
156
  function defineRadioElements() {
153
157
  defineElement("radio", LeuRadio);
154
158
  }