@statistikzh/leu 0.0.2 → 0.2.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 (59) hide show
  1. package/.github/workflows/release-please.yml +20 -1
  2. package/CHANGELOG.md +30 -0
  3. package/README.md +27 -2
  4. package/babel.config.json +3 -0
  5. package/dist/{Button-83c6df93.js → Button.js} +58 -50
  6. package/dist/ButtonGroup.js +75 -0
  7. package/dist/Checkbox.js +60 -57
  8. package/dist/CheckboxGroup.js +35 -41
  9. package/dist/{Chip-60af1402.js → Chip-389013ff.js} +12 -13
  10. package/dist/ChipGroup.js +27 -34
  11. package/dist/ChipLink.js +18 -19
  12. package/dist/ChipRemovable.js +9 -13
  13. package/dist/ChipSelectable.js +42 -44
  14. package/dist/Dropdown.js +75 -0
  15. package/dist/Input.js +120 -122
  16. package/dist/Menu.js +40 -0
  17. package/dist/MenuItem.js +171 -0
  18. package/dist/Pagination.js +193 -0
  19. package/dist/Radio.js +26 -22
  20. package/dist/RadioGroup.js +75 -105
  21. package/dist/Select.js +125 -343
  22. package/dist/Table.js +294 -8
  23. package/dist/defineElement-ba770aed.js +44 -0
  24. package/dist/icon-03e86700.js +136 -0
  25. package/dist/index.js +14 -9
  26. package/dist/leu-button-group.js +8 -0
  27. package/dist/leu-button.js +7 -0
  28. package/dist/leu-checkbox-group.js +1 -1
  29. package/dist/leu-checkbox.js +2 -2
  30. package/dist/leu-chip-group.js +1 -1
  31. package/dist/leu-chip-link.js +2 -2
  32. package/dist/leu-chip-removable.js +3 -3
  33. package/dist/leu-chip-selectable.js +2 -2
  34. package/dist/leu-dropdown.js +10 -0
  35. package/dist/leu-input.js +2 -2
  36. package/dist/leu-menu-item.js +6 -0
  37. package/dist/leu-menu.js +5 -0
  38. package/dist/leu-pagination.js +8 -0
  39. package/dist/leu-radio-group.js +1 -1
  40. package/dist/leu-radio.js +1 -1
  41. package/dist/leu-select.js +5 -3
  42. package/dist/leu-table.js +5 -4
  43. package/dist/theme.css +7 -7
  44. package/index.js +7 -3
  45. package/package.json +3 -1
  46. package/rollup.config.js +26 -9
  47. package/src/components/accordion/Accordion.js +102 -0
  48. package/src/components/accordion/accordion.css +160 -0
  49. package/src/components/accordion/leu-accordion.js +3 -0
  50. package/src/components/accordion/stories/accordion.stories.js +55 -0
  51. package/src/components/accordion/test/accordion.test.js +22 -0
  52. package/src/components/input/Input.js +10 -0
  53. package/src/components/menu/menu.css +9 -3
  54. package/src/components/select/Select.js +28 -8
  55. package/src/styles/custom-properties.css +7 -7
  56. package/.github/workflows/publish.yml +0 -19
  57. package/dist/Table-72d305d7.js +0 -506
  58. package/dist/defineElement-47d4f665.js +0 -15
  59. package/dist/icon-b68c7e1e.js +0 -202
package/dist/ChipGroup.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
  display: flex;
@@ -13,7 +13,7 @@ var css_248z = css`:host {
13
13
  const SELECTION_MODES = {
14
14
  single: "single",
15
15
  multiple: "multiple",
16
- none: "none",
16
+ none: "none"
17
17
  };
18
18
 
19
19
  /**
@@ -21,57 +21,50 @@ const SELECTION_MODES = {
21
21
  * @tagname leu-chip-group
22
22
  */
23
23
  class LeuChipGroup extends LitElement {
24
- static styles = css_248z
25
-
26
- static properties = {
27
- selectionMode: { type: String, attribute: "selection-mode" },
28
- }
29
-
30
24
  constructor() {
31
25
  super();
32
26
 
33
27
  /** @internal */
28
+ /** @internal */
29
+ _defineProperty(this, "handleInput", e => {
30
+ if (this.selectionMode === SELECTION_MODES.single) {
31
+ this.items.forEach(item => {
32
+ item.selected = item === e.target; // eslint-disable-line no-param-reassign
33
+ });
34
+ }
35
+ });
36
+ /** @internal */
37
+ _defineProperty(this, "handleSlotChange", e => {
38
+ const slot = e.target;
39
+ const items = slot.assignedElements({
40
+ flatten: true
41
+ });
42
+ this.items = items;
43
+ });
34
44
  this.items = [];
35
45
  }
36
-
37
46
  connectedCallback() {
38
47
  super.connectedCallback();
39
-
40
48
  this.addEventListener("input", this.handleInput);
41
49
  }
42
-
43
50
  disconnectedCallback() {
44
51
  super.disconnectedCallback();
45
-
46
52
  this.removeEventListener("input", this.handleInput);
47
53
  }
48
-
49
54
  get value() {
50
- return this.items.filter((i) => i.selected).map((i) => i.value)
51
- }
52
-
53
- /** @internal */
54
- handleInput = (e) => {
55
- if (this.selectionMode === SELECTION_MODES.single) {
56
- this.items.forEach((item) => {
57
- item.selected = item === e.target; // eslint-disable-line no-param-reassign
58
- });
59
- }
60
- }
61
-
62
- /** @internal */
63
- handleSlotChange = (e) => {
64
- const slot = e.target;
65
- const items = slot.assignedElements({ flatten: true });
66
-
67
- this.items = items;
55
+ return this.items.filter(i => i.selected).map(i => i.value);
68
56
  }
69
-
70
57
  render() {
71
- return html`<slot @slotchange=${this.handleSlotChange}></slot>`
58
+ return html`<slot @slotchange=${this.handleSlotChange}></slot>`;
72
59
  }
73
60
  }
74
-
61
+ _defineProperty(LeuChipGroup, "styles", css_248z);
62
+ _defineProperty(LeuChipGroup, "properties", {
63
+ selectionMode: {
64
+ type: String,
65
+ attribute: "selection-mode"
66
+ }
67
+ });
75
68
  function defineChipGroupElements() {
76
69
  defineElement("chip-group", LeuChipGroup);
77
70
  }
package/dist/ChipLink.js CHANGED
@@ -1,10 +1,10 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
1
2
  import { html } from 'lit';
2
- import { d as defineElement } from './defineElement-47d4f665.js';
3
- import { L as LeuChipBase } from './Chip-60af1402.js';
3
+ import { L as LeuChipBase } from './Chip-389013ff.js';
4
4
 
5
5
  const SIZES = {
6
6
  regular: "regular",
7
- large: "large",
7
+ large: "large"
8
8
  };
9
9
 
10
10
  /**
@@ -12,33 +12,32 @@ const SIZES = {
12
12
  * @tagname leu-chip-link
13
13
  */
14
14
  class LeuChipLink extends LeuChipBase {
15
- static properties = {
16
- ...LeuChipBase.properties,
17
-
18
- /**
19
- * The size of the chip
20
- * @type {keyof typeof SIZES}
21
- */
22
- size: { type: String },
23
-
24
- href: { type: String, reflect: true },
25
- }
26
-
27
15
  constructor() {
28
16
  super();
29
-
30
17
  this.inverted = false;
31
18
  this.size = SIZES.regular;
32
19
  this.href = "";
33
20
  }
34
-
35
21
  render() {
36
22
  return html`<a href=${this.href} class="button">
37
23
  <span class="label"><slot></slot></span>
38
- </a>`
24
+ </a>`;
39
25
  }
40
26
  }
41
-
27
+ _defineProperty(LeuChipLink, "properties", {
28
+ ...LeuChipBase.properties,
29
+ /**
30
+ * The size of the chip
31
+ * @type {keyof typeof SIZES}
32
+ */
33
+ size: {
34
+ type: String
35
+ },
36
+ href: {
37
+ type: String,
38
+ reflect: true
39
+ }
40
+ });
42
41
  function defineChipLinkElements() {
43
42
  defineElement("chip-link", LeuChipLink);
44
43
  }
@@ -1,7 +1,7 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
1
2
  import { html } from 'lit';
2
- import { d as defineElement } from './defineElement-47d4f665.js';
3
- import { L as LeuChipBase } from './Chip-60af1402.js';
4
- import { I as Icon } from './icon-b68c7e1e.js';
3
+ import { L as LeuChipBase } from './Chip-389013ff.js';
4
+ import { I as Icon } from './icon-03e86700.js';
5
5
 
6
6
  /**
7
7
  * @slot - The content of the chip
@@ -9,33 +9,29 @@ import { I as Icon } from './icon-b68c7e1e.js';
9
9
  * @fires remove - Dispatched when the user clicks on the chip
10
10
  */
11
11
  class LeuChipRemovable extends LeuChipBase {
12
- static properties = {
13
- ...LeuChipBase.properties,
14
- }
15
-
16
12
  constructor() {
17
13
  super();
18
14
 
19
15
  /** @internal */
20
16
  this._removeIcon = Icon("close", 16);
21
17
  }
22
-
23
18
  handleClick() {
24
19
  const customEvent = new CustomEvent("remove", {
25
20
  bubble: true,
26
- composed: true,
21
+ composed: true
27
22
  });
28
23
  this.dispatchEvent(customEvent);
29
24
  }
30
-
31
25
  render() {
32
- return html`<button @click=${(e) => this.handleClick(e)} class="button">
26
+ return html`<button @click=${e => this.handleClick(e)} class="button">
33
27
  <span class="label"><slot></slot></span>
34
28
  <div class="icon">${this._removeIcon}</div>
35
- </button>`
29
+ </button>`;
36
30
  }
37
31
  }
38
-
32
+ _defineProperty(LeuChipRemovable, "properties", {
33
+ ...LeuChipBase.properties
34
+ });
39
35
  function defineChipRemovableElements() {
40
36
  defineElement("chip-removable", LeuChipRemovable);
41
37
  }
@@ -1,15 +1,14 @@
1
+ import { _ as _defineProperty, d as defineElement } from './defineElement-ba770aed.js';
1
2
  import { html } from 'lit';
2
- import { d as defineElement } from './defineElement-47d4f665.js';
3
- import { L as LeuChipBase } from './Chip-60af1402.js';
3
+ import { L as LeuChipBase } from './Chip-389013ff.js';
4
4
 
5
5
  const SIZES = {
6
6
  small: "small",
7
- regular: "regular",
7
+ regular: "regular"
8
8
  };
9
-
10
9
  const VARIANTS = {
11
10
  default: "default",
12
- radio: "radio",
11
+ radio: "radio"
13
12
  };
14
13
 
15
14
  /**
@@ -18,73 +17,72 @@ const VARIANTS = {
18
17
  * @tagname leu-chip-selectable
19
18
  */
20
19
  class LeuChipSelectable extends LeuChipBase {
21
- static properties = {
22
- ...LeuChipBase.properties,
23
-
24
- /**
25
- * The size of the chip. Not supported for radio variant.
26
- * @type {keyof typeof SIZES}
27
- * @default "regular"
28
- */
29
- size: { type: String },
30
-
31
- /**
32
- * The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
33
- * - `default`: The chip behaves like a toggle button.
34
- * - `radio`: The chip behaves like a radio button.
35
- *
36
- * @type {keyof typeof VARIANTS}
37
- * @default "default"
38
- */
39
- variant: { type: String },
40
-
41
- selected: { type: Boolean, reflect: true },
42
- value: { type: String },
43
- }
44
-
45
20
  constructor() {
46
21
  super();
47
22
  this.size = SIZES.regular;
48
23
  this.variant = VARIANTS.toggle;
49
24
  this.selected = false;
50
-
51
25
  if (this.variant === VARIANTS.radio && this.size === SIZES.small) {
52
26
  console.warn("Small size has no effect on radio variant");
53
27
  }
54
28
  }
55
-
56
29
  handleClick() {
57
30
  let nextSelectedState = this.selected;
58
-
59
31
  if (this.variant === VARIANTS.radio) {
60
32
  nextSelectedState = true;
61
33
  } else {
62
34
  nextSelectedState = !this.selected;
63
35
  }
64
-
65
36
  if (nextSelectedState !== this.selected) {
66
37
  this.selected = nextSelectedState;
67
- this.dispatchEvent(
68
- new CustomEvent("input", {
69
- detail: { selected: this.selected },
70
- bubbles: true,
71
- composed: true,
72
- })
73
- );
38
+ this.dispatchEvent(new CustomEvent("input", {
39
+ detail: {
40
+ selected: this.selected
41
+ },
42
+ bubbles: true,
43
+ composed: true
44
+ }));
74
45
  }
75
46
  }
76
-
77
47
  render() {
78
48
  return html`<button
79
- @click=${(e) => this.handleClick(e)}
49
+ @click=${e => this.handleClick(e)}
80
50
  class="button"
81
51
  aria-selected=${this.selected ? "true" : "false"}
82
52
  >
83
53
  <span class="label"><slot></slot></span>
84
- </button>`
54
+ </button>`;
85
55
  }
86
56
  }
87
-
57
+ _defineProperty(LeuChipSelectable, "properties", {
58
+ ...LeuChipBase.properties,
59
+ /**
60
+ * The size of the chip. Not supported for radio variant.
61
+ * @type {keyof typeof SIZES}
62
+ * @default "regular"
63
+ */
64
+ size: {
65
+ type: String
66
+ },
67
+ /**
68
+ * The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
69
+ * - `default`: The chip behaves like a toggle button.
70
+ * - `radio`: The chip behaves like a radio button.
71
+ *
72
+ * @type {keyof typeof VARIANTS}
73
+ * @default "default"
74
+ */
75
+ variant: {
76
+ type: String
77
+ },
78
+ selected: {
79
+ type: Boolean,
80
+ reflect: true
81
+ },
82
+ value: {
83
+ type: String
84
+ }
85
+ });
88
86
  function defineChipSelectableElements() {
89
87
  defineElement("chip-selectable", LeuChipSelectable);
90
88
  }
@@ -0,0 +1,75 @@
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 { defineMenuElements } from './Menu.js';
5
+ import { defineMenuItemElements } from './MenuItem.js';
6
+ import 'lit/directives/class-map.js';
7
+ import './icon-03e86700.js';
8
+
9
+ var css_248z = css`:host,
10
+ :host * {
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ :host {
15
+ position: relative;
16
+ }
17
+
18
+ .content {
19
+ overflow: hidden;
20
+ box-shadow: var(--leu-box-shadow-short);
21
+ border-radius: 2px;
22
+
23
+ position: absolute;
24
+ top: calc(100% + 0.5rem);
25
+ }
26
+ `;
27
+
28
+ /**
29
+ * @tagname leu-dropdown
30
+ */
31
+ class LeuDropdown extends LitElement {
32
+ constructor() {
33
+ super();
34
+ this.label = "";
35
+ this.expanded = false;
36
+ }
37
+ handleClick() {
38
+ this.expanded = !this.expanded;
39
+ }
40
+ render() {
41
+ return html`
42
+ <leu-button
43
+ icon="download"
44
+ variant="ghost"
45
+ label=${this.label}
46
+ expanded=${this.expanded ? "open" : "closed"}
47
+ aria-expanded=${this.expanded ? "true" : "false"}
48
+ aria-controls="content"
49
+ ?active=${this.expanded}
50
+ @click=${this.handleClick}
51
+ ></leu-button>
52
+ <div id="content" class="content" ?hidden=${!this.expanded}>
53
+ <slot></slot>
54
+ </div>
55
+ `;
56
+ }
57
+ }
58
+ _defineProperty(LeuDropdown, "styles", css_248z);
59
+ _defineProperty(LeuDropdown, "properties", {
60
+ label: {
61
+ type: String
62
+ },
63
+ expanded: {
64
+ type: Boolean,
65
+ reflect: true
66
+ }
67
+ });
68
+ function defineDropdownElements() {
69
+ defineElement("dropdown", LeuDropdown);
70
+ defineButtonElements();
71
+ defineMenuElements();
72
+ defineMenuItemElements();
73
+ }
74
+
75
+ export { LeuDropdown, defineDropdownElements };