@statistikzh/leu 0.5.1 → 0.6.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 (236) hide show
  1. package/.husky/commit-msg +0 -3
  2. package/.husky/pre-commit +0 -3
  3. package/CHANGELOG.md +40 -0
  4. package/dist/Accordion.d.ts +10 -9
  5. package/dist/Accordion.d.ts.map +1 -1
  6. package/dist/Accordion.js +12 -11
  7. package/dist/Breadcrumb.d.ts +4 -4
  8. package/dist/Breadcrumb.d.ts.map +1 -1
  9. package/dist/Breadcrumb.js +28 -26
  10. package/dist/{Button-5326c982.d.ts → Button-9692e403.d.ts} +10 -11
  11. package/dist/Button-9692e403.d.ts.map +1 -0
  12. package/dist/{Button-5326c982.js → Button-9692e403.js} +57 -67
  13. package/dist/Button.d.ts +1 -1
  14. package/dist/Button.js +3 -3
  15. package/dist/ButtonGroup.d.ts +2 -2
  16. package/dist/ButtonGroup.d.ts.map +1 -1
  17. package/dist/ButtonGroup.js +3 -3
  18. package/dist/Checkbox.d.ts +4 -3
  19. package/dist/Checkbox.d.ts.map +1 -1
  20. package/dist/Checkbox.js +14 -19
  21. package/dist/CheckboxGroup.d.ts +2 -2
  22. package/dist/CheckboxGroup.d.ts.map +1 -1
  23. package/dist/CheckboxGroup.js +4 -6
  24. package/dist/Chip.d.ts +2 -2
  25. package/dist/Chip.d.ts.map +1 -1
  26. package/dist/Chip.js +6 -13
  27. package/dist/ChipGroup.d.ts +9 -7
  28. package/dist/ChipGroup.d.ts.map +1 -1
  29. package/dist/ChipGroup.js +8 -5
  30. package/dist/ChipLink.d.ts +2 -1
  31. package/dist/ChipLink.d.ts.map +1 -1
  32. package/dist/ChipLink.js +4 -7
  33. package/dist/ChipRemovable.d.ts +0 -2
  34. package/dist/ChipRemovable.d.ts.map +1 -1
  35. package/dist/ChipRemovable.js +8 -11
  36. package/dist/ChipSelectable.d.ts +9 -1
  37. package/dist/ChipSelectable.d.ts.map +1 -1
  38. package/dist/ChipSelectable.js +12 -16
  39. package/dist/Dropdown.d.ts +9 -5
  40. package/dist/Dropdown.d.ts.map +1 -1
  41. package/dist/Dropdown.js +68 -32
  42. package/dist/Icon.d.ts +20 -0
  43. package/dist/Icon.d.ts.map +1 -0
  44. package/dist/{icon-03e86700.js → Icon.js} +61 -32
  45. package/dist/Input.d.ts +7 -16
  46. package/dist/Input.d.ts.map +1 -1
  47. package/dist/Input.js +24 -28
  48. package/dist/LeuElement-6de6f209.d.ts +7 -0
  49. package/dist/LeuElement-6de6f209.d.ts.map +1 -0
  50. package/dist/LeuElement-6de6f209.js +43 -0
  51. package/dist/Menu.d.ts +24 -2
  52. package/dist/Menu.d.ts.map +1 -1
  53. package/dist/Menu.js +120 -3
  54. package/dist/MenuItem.d.ts +28 -11
  55. package/dist/MenuItem.d.ts.map +1 -1
  56. package/dist/MenuItem.js +110 -63
  57. package/dist/Pagination.d.ts +10 -3
  58. package/dist/Pagination.d.ts.map +1 -1
  59. package/dist/Pagination.js +24 -21
  60. package/dist/Popup.d.ts +21 -3
  61. package/dist/Popup.d.ts.map +1 -1
  62. package/dist/Popup.js +44 -19
  63. package/dist/Radio.d.ts +4 -2
  64. package/dist/Radio.d.ts.map +1 -1
  65. package/dist/Radio.js +9 -16
  66. package/dist/RadioGroup.d.ts +2 -2
  67. package/dist/RadioGroup.d.ts.map +1 -1
  68. package/dist/RadioGroup.js +4 -6
  69. package/dist/ScrollTop.d.ts +2 -2
  70. package/dist/ScrollTop.d.ts.map +1 -1
  71. package/dist/ScrollTop.js +10 -8
  72. package/dist/Select.d.ts +75 -37
  73. package/dist/Select.d.ts.map +1 -1
  74. package/dist/Select.js +279 -183
  75. package/dist/Table.d.ts +2 -6
  76. package/dist/Table.d.ts.map +1 -1
  77. package/dist/Table.js +17 -18
  78. package/dist/VisuallyHidden.d.ts +2 -2
  79. package/dist/VisuallyHidden.d.ts.map +1 -1
  80. package/dist/VisuallyHidden.js +5 -7
  81. package/dist/index.d.ts +2 -2
  82. package/dist/index.js +5 -14
  83. package/dist/leu-accordion.d.ts.map +1 -1
  84. package/dist/leu-accordion.js +2 -3
  85. package/dist/leu-breadcrumb.d.ts.map +1 -1
  86. package/dist/leu-breadcrumb.js +4 -10
  87. package/dist/leu-button-group.d.ts.map +1 -1
  88. package/dist/leu-button-group.js +2 -3
  89. package/dist/leu-button.d.ts +1 -1
  90. package/dist/leu-button.d.ts.map +1 -1
  91. package/dist/leu-button.js +4 -5
  92. package/dist/leu-checkbox-group.d.ts.map +1 -1
  93. package/dist/leu-checkbox-group.js +2 -3
  94. package/dist/leu-checkbox.d.ts.map +1 -1
  95. package/dist/leu-checkbox.js +3 -4
  96. package/dist/leu-chip-group.d.ts.map +1 -1
  97. package/dist/leu-chip-group.js +2 -3
  98. package/dist/leu-chip-link.d.ts.map +1 -1
  99. package/dist/leu-chip-link.js +2 -3
  100. package/dist/leu-chip-removable.d.ts.map +1 -1
  101. package/dist/leu-chip-removable.js +3 -4
  102. package/dist/leu-chip-selectable.d.ts.map +1 -1
  103. package/dist/leu-chip-selectable.js +2 -3
  104. package/dist/leu-dropdown.d.ts.map +1 -1
  105. package/dist/leu-dropdown.js +5 -10
  106. package/dist/leu-icon.d.ts +3 -0
  107. package/dist/leu-icon.d.ts.map +1 -0
  108. package/dist/leu-icon.js +7 -0
  109. package/dist/leu-input.d.ts.map +1 -1
  110. package/dist/leu-input.js +3 -4
  111. package/dist/leu-menu-item.d.ts.map +1 -1
  112. package/dist/leu-menu-item.js +3 -5
  113. package/dist/leu-menu.d.ts.map +1 -1
  114. package/dist/leu-menu.js +5 -3
  115. package/dist/leu-pagination.d.ts.map +1 -1
  116. package/dist/leu-pagination.js +4 -7
  117. package/dist/leu-popup.d.ts.map +1 -1
  118. package/dist/leu-popup.js +2 -3
  119. package/dist/leu-radio-group.d.ts.map +1 -1
  120. package/dist/leu-radio-group.js +2 -3
  121. package/dist/leu-radio.d.ts.map +1 -1
  122. package/dist/leu-radio.js +2 -3
  123. package/dist/leu-scroll-top.d.ts.map +1 -1
  124. package/dist/leu-scroll-top.js +4 -6
  125. package/dist/leu-select.d.ts.map +1 -1
  126. package/dist/leu-select.js +5 -13
  127. package/dist/leu-table.d.ts.map +1 -1
  128. package/dist/leu-table.js +4 -8
  129. package/dist/leu-visually-hidden.d.ts.map +1 -1
  130. package/dist/leu-visually-hidden.js +2 -3
  131. package/dist/theme.css +2 -0
  132. package/dist/vscode.html-custom-data.json +116 -79
  133. package/dist/vue/index.d.ts +80 -76
  134. package/dist/web-types.json +405 -270
  135. package/package.json +9 -12
  136. package/scripts/generate-component/templates/[Name].js +6 -3
  137. package/scripts/generate-component/templates/test/[name].test.js +1 -1
  138. package/src/components/accordion/Accordion.js +13 -10
  139. package/src/components/accordion/leu-accordion.js +1 -2
  140. package/src/components/breadcrumb/Breadcrumb.js +31 -18
  141. package/src/components/breadcrumb/leu-breadcrumb.js +1 -2
  142. package/src/components/button/Button.js +45 -71
  143. package/src/components/button/button.css +11 -9
  144. package/src/components/button/leu-button.js +1 -2
  145. package/src/components/button/stories/button.stories.js +60 -19
  146. package/src/components/button/test/button.test.js +26 -63
  147. package/src/components/button-group/ButtonGroup.js +4 -2
  148. package/src/components/button-group/leu-button-group.js +1 -2
  149. package/src/components/checkbox/Checkbox.js +17 -11
  150. package/src/components/checkbox/CheckboxGroup.js +6 -3
  151. package/src/components/checkbox/leu-checkbox-group.js +1 -2
  152. package/src/components/checkbox/leu-checkbox.js +1 -2
  153. package/src/components/checkbox/stories/checkbox-group.stories.js +10 -26
  154. package/src/components/checkbox/stories/checkbox.stories.js +2 -7
  155. package/src/components/checkbox/test/checkbox-group.test.js +6 -21
  156. package/src/components/checkbox/test/checkbox.test.js +1 -12
  157. package/src/components/chip/Chip.js +5 -4
  158. package/src/components/chip/ChipGroup.js +10 -4
  159. package/src/components/chip/ChipLink.js +3 -7
  160. package/src/components/chip/ChipRemovable.js +8 -11
  161. package/src/components/chip/ChipSelectable.js +11 -17
  162. package/src/components/chip/chip.css +3 -4
  163. package/src/components/chip/leu-chip-group.js +1 -2
  164. package/src/components/chip/leu-chip-link.js +1 -2
  165. package/src/components/chip/leu-chip-removable.js +1 -2
  166. package/src/components/chip/leu-chip-selectable.js +1 -2
  167. package/src/components/chip/stories/chip-link.stories.js +3 -5
  168. package/src/components/chip/stories/chip-removable.stories.js +3 -4
  169. package/src/components/chip/stories/chip-selectable.stories.js +2 -2
  170. package/src/components/chip/test/chip-group.test.js +15 -30
  171. package/src/components/chip/test/chip-link.test.js +2 -6
  172. package/src/components/chip/test/chip-removable.test.js +4 -10
  173. package/src/components/chip/test/chip-selectable.test.js +3 -5
  174. package/src/components/dropdown/Dropdown.js +79 -26
  175. package/src/components/dropdown/leu-dropdown.js +1 -2
  176. package/src/components/dropdown/stories/dropdown.stories.js +30 -7
  177. package/src/components/dropdown/test/dropdown.test.js +5 -5
  178. package/src/components/icon/Icon.js +55 -0
  179. package/src/components/icon/icon.css +6 -0
  180. package/src/components/icon/leu-icon.js +5 -0
  181. package/src/components/icon/{icon.js → paths.js} +4 -37
  182. package/src/components/icon/stories/icon.stories.js +47 -0
  183. package/src/components/icon/test/icon.test.js +23 -40
  184. package/src/components/input/Input.js +21 -23
  185. package/src/components/input/input.css +4 -2
  186. package/src/components/input/leu-input.js +1 -2
  187. package/src/components/input/stories/input.stories.js +2 -2
  188. package/src/components/input/test/input.test.js +2 -0
  189. package/src/components/menu/Menu.js +143 -2
  190. package/src/components/menu/MenuItem.js +104 -52
  191. package/src/components/menu/leu-menu-item.js +1 -2
  192. package/src/components/menu/leu-menu.js +1 -2
  193. package/src/components/menu/menu-item.css +11 -4
  194. package/src/components/menu/stories/menu-item.stories.js +15 -4
  195. package/src/components/menu/stories/menu.stories.js +34 -7
  196. package/src/components/menu/test/menu-item.test.js +88 -82
  197. package/src/components/menu/test/menu.test.js +101 -8
  198. package/src/components/pagination/Pagination.js +27 -18
  199. package/src/components/pagination/leu-pagination.js +1 -2
  200. package/src/components/popup/Popup.js +39 -16
  201. package/src/components/popup/leu-popup.js +1 -2
  202. package/src/components/popup/popup.css +1 -0
  203. package/src/components/radio/Radio.js +12 -7
  204. package/src/components/radio/RadioGroup.js +6 -3
  205. package/src/components/radio/leu-radio-group.js +1 -2
  206. package/src/components/radio/leu-radio.js +1 -2
  207. package/src/components/radio/stories/radio-group.stories.js +5 -19
  208. package/src/components/radio/stories/radio.stories.js +2 -7
  209. package/src/components/radio/test/radio-group.test.js +6 -9
  210. package/src/components/radio/test/radio.test.js +3 -13
  211. package/src/components/scroll-top/ScrollTop.js +15 -5
  212. package/src/components/scroll-top/leu-scroll-top.js +1 -2
  213. package/src/components/select/Select.js +279 -175
  214. package/src/components/select/leu-select.js +1 -2
  215. package/src/components/select/select.css +20 -12
  216. package/src/components/select/stories/select.stories.js +16 -2
  217. package/src/components/select/test/select.test.js +191 -37
  218. package/src/components/table/Table.js +15 -9
  219. package/src/components/table/leu-table.js +1 -2
  220. package/src/components/table/table.css +3 -1
  221. package/src/components/visually-hidden/VisuallyHidden.js +6 -2
  222. package/src/components/visually-hidden/leu-visually-hidden.js +1 -2
  223. package/src/lib/LeuElement.js +23 -0
  224. package/src/lib/a11y.js +26 -0
  225. package/src/styles/custom-properties.css +2 -0
  226. package/web-test-runner.config.mjs +2 -0
  227. package/dist/Button-5326c982.d.ts.map +0 -1
  228. package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +0 -3
  229. package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +0 -1
  230. package/dist/_rollupPluginBabelHelpers-20f659f4.js +0 -30
  231. package/dist/defineElement-40372b4b.d.ts +0 -9
  232. package/dist/defineElement-40372b4b.d.ts.map +0 -1
  233. package/dist/defineElement-40372b4b.js +0 -15
  234. package/dist/icon-03e86700.d.ts +0 -11
  235. package/dist/icon-03e86700.d.ts.map +0 -1
  236. package/src/lib/defineElement.js +0 -13
package/dist/Menu.js CHANGED
@@ -1,5 +1,8 @@
1
- import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
2
- import { css, LitElement, html } from 'lit';
1
+ import { _ as _defineProperty, L as LeuElement } from './LeuElement-6de6f209.js';
2
+ import { css, html } from 'lit';
3
+ import { LeuMenuItem } from './MenuItem.js';
4
+ import 'lit/directives/if-defined.js';
5
+ import './Icon.js';
3
6
 
4
7
  var css_248z = css`:host,
5
8
  :host * {
@@ -24,14 +27,128 @@ var css_248z = css`:host,
24
27
  }
25
28
  `;
26
29
 
30
+ /**
31
+ * @typedef {'single' | 'multiple' | 'none'} SelectsType
32
+ */
33
+
27
34
  /**
28
35
  * @tagname leu-menu
36
+ * @property {SelectsType} selects - This has only an effect when the role is 'menu'. It defines which role the menu items will get. Default is 'none'.
29
37
  */
30
- class LeuMenu extends LitElement {
38
+ class LeuMenu extends LeuElement {
39
+ constructor() {
40
+ super();
41
+
42
+ /** @type {SelectsType} */
43
+ this.selects = "none";
44
+ this.value = undefined;
45
+ }
46
+ connectedCallback() {
47
+ super.connectedCallback();
48
+ if (!this.getAttribute("role")) {
49
+ this.setAttribute("role", "menu");
50
+ }
51
+ this.addEventListener("keydown", this._handleKeyDown);
52
+ }
53
+ disconnectedCallback() {
54
+ super.disconnectedCallback();
55
+ this.removeEventListener("keydown", this._handleKeyDown);
56
+ }
57
+ _handleSlotChange() {
58
+ this.setCurrentItem(0);
59
+ this._setMenuItemRoles();
60
+ }
61
+ _setMenuItemRoles() {
62
+ const menuRole = this.getAttribute("role");
63
+ let menuItemRole;
64
+ if (menuRole === "menu") {
65
+ if (this.selects === "multiple") {
66
+ menuItemRole = "menuitemcheckbox";
67
+ } else if (this.selects === "single") {
68
+ menuItemRole = "menuitemradio";
69
+ } else {
70
+ menuItemRole = "menuitem";
71
+ }
72
+ } else if (menuRole === "listbox") {
73
+ menuItemRole = "option";
74
+ }
75
+ if (menuItemRole) {
76
+ this.getMenuItems().forEach(menuItem => {
77
+ menuItem.componentRole = menuItemRole; // eslint-disable-line no-param-reassign
78
+ });
79
+ }
80
+ }
81
+
82
+ /**
83
+ *
84
+ * @returns {import("./MenuItem").LeuMenuItem[]}
85
+ */
86
+ getMenuItems() {
87
+ const slot = this.shadowRoot.querySelector("slot");
88
+ return slot.assignedElements({
89
+ flatten: true
90
+ }).filter(el => el instanceof LeuMenuItem);
91
+ }
92
+ getVisibleMenuItems() {
93
+ return this.getMenuItems().filter(menuItem => !menuItem.hidden);
94
+ }
95
+ _handleKeyDown(event) {
96
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
97
+ event.preventDefault();
98
+ const menuItems = this.getVisibleMenuItems();
99
+ let index = menuItems.findIndex(menuItem => menuItem.tabbable);
100
+ if (event.key === "ArrowDown") {
101
+ index += 1;
102
+ } else if (event.key === "ArrowUp") {
103
+ index -= 1;
104
+ } else if (event.key === "Home") {
105
+ index = 0;
106
+ } else if (event.key === "End") {
107
+ index = menuItems.length - 1;
108
+ }
109
+ this.focusItem(index);
110
+ }
111
+ }
112
+ setCurrentItem(index) {
113
+ const menuItems = this.getVisibleMenuItems();
114
+ let currentItem = null;
115
+ const currentItemIndex = (index + menuItems.length) % menuItems.length;
116
+ menuItems.forEach((menuItem, i) => {
117
+ if (i === currentItemIndex) {
118
+ currentItem = menuItem;
119
+ menuItem.tabbable = true; // eslint-disable-line no-param-reassign
120
+ } else {
121
+ menuItem.tabbable = false; // eslint-disable-line no-param-reassign
122
+ }
123
+ });
124
+ return currentItem;
125
+ }
126
+ focusItem(index) {
127
+ const currentItem = this.setCurrentItem(index);
128
+ currentItem.focus();
129
+ }
130
+ firstUpdated() {
131
+ this.setCurrentItem(0);
132
+ }
133
+ updated(changedProperties) {
134
+ if (changedProperties.has("selects")) {
135
+ this._setMenuItemRoles();
136
+ }
137
+ }
31
138
  render() {
32
139
  return html`<slot></slot>`;
33
140
  }
34
141
  }
35
142
  _defineProperty(LeuMenu, "styles", css_248z);
143
+ _defineProperty(LeuMenu, "shadowRootOptions", {
144
+ ...LeuElement.shadowRootOptions,
145
+ delegatesFocus: true
146
+ });
147
+ _defineProperty(LeuMenu, "properties", {
148
+ selects: {
149
+ type: String,
150
+ reflect: true
151
+ }
152
+ });
36
153
 
37
154
  export { LeuMenu };
@@ -1,21 +1,38 @@
1
+ export type MenuItemRole = "menuitem" | "menuitemcheckbox" | "menuitemradio" | "option" | "none";
2
+ /**
3
+ * @typedef {'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'none'} MenuItemRole
4
+ */
1
5
  /**
2
6
  * @tagname leu-menu-item
3
7
  * @slot - The label of the menu item
8
+ * @property {boolean} active - Defines if the item is selected or checked
9
+ * @property {boolean} disabled - Disables the underlying button or link
10
+ * @property {string} value - The value of the item. It must not contain commas. See `getValue()`
11
+ * @property {string} href - The href of the underlying link
12
+ * @property {boolean} tabbable - If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link
13
+ * @property {MenuItemRole} componentRole - The role of the item. This will be reflected as `role` to the underlying button or link. Default is `'menuitem'.`
4
14
  */
5
- export class LeuMenuItem extends LitElement {
6
- static getIconOrText(name: any): any;
15
+ export class LeuMenuItem extends LeuElement {
7
16
  active: boolean;
8
17
  disabled: boolean;
18
+ value: any;
19
+ href: any;
20
+ tabbable: any;
21
+ /** @type {MenuItemRole} */
22
+ componentRole: MenuItemRole;
23
+ _handleClick(event: any): void;
9
24
  /**
10
- * A programmatic way to highlight the menu item like it is hovered.
11
- * This is just a visual effect and does not change the active state.
25
+ * Returns the value of the item. If `value` is not set, it will return the inner text
26
+ * @returns {string}
12
27
  */
13
- highlighted: boolean;
14
- renderBefore(): typeof nothing | import("lit-html").TemplateResult;
15
- renderAfter(): typeof nothing | import("lit-html").TemplateResult;
16
- getTagName(): "button" | "a";
17
- render(): import("lit-html").TemplateResult;
28
+ getValue(): string;
29
+ _getAria(): {
30
+ disabled: boolean;
31
+ };
32
+ _getTabIndex(): 0 | -1;
33
+ _renderLink(content: any): import("lit-html").TemplateResult<1>;
34
+ _renderButton(content: any): import("lit-html").TemplateResult<1>;
35
+ render(): import("lit-html").TemplateResult<1>;
18
36
  }
19
- import { LitElement } from 'lit';
20
- import { nothing } from 'lit';
37
+ import { L as LeuElement } from './LeuElement-6de6f209.js';
21
38
  //# sourceMappingURL=MenuItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["MenuItem.js"],"names":[],"mappings":"AAsFA;;;GAGG;AACH;IAYE,qCAQC;IAjBC,gBAAmB;IACnB,kBAAqB;IAErB;;;OAGG;IACH,qBAAwB;IAW1B,mEAMC;IACD,kEAMC;IACD,6BAEC;IACD,4CAQC;CACF;2BAxIwC,KAAK;wBAAL,KAAK"}
1
+ {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["MenuItem.js"],"names":[],"mappings":"2BA8Fa,UAAU,GAAG,kBAAkB,GAAG,eAAe,GAAG,QAAQ,GAAG,MAAM;AADlF;;GAEG;AAEH;;;;;;;;;GASG;AACH;IAGI,gBAAmB;IACnB,kBAAqB;IACrB,WAAsB;IACtB,UAAqB;IACrB,cAAyB;IAEzB,2BAA2B;IAC3B,eADW,YAAY,CACQ;IAUjC,+BAKC;IAED;;;OAGG;IACH,YAFa,MAAM,CAIlB;IACD;;MAaC;IACD,uBAKC;IACD,gEAYC;IACD,kEAYC;IACD,+CAOC;CACF;gCAnMqD,0BAA0B"}
package/dist/MenuItem.js CHANGED
@@ -1,8 +1,7 @@
1
- import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
2
- import { css, LitElement, nothing } from 'lit';
3
- import { html, unsafeStatic } from 'lit/static-html.js';
1
+ import { _ as _defineProperty, L as LeuElement } from './LeuElement-6de6f209.js';
2
+ import { css, html } from 'lit';
4
3
  import { ifDefined } from 'lit/directives/if-defined.js';
5
- import { a as ICON_NAMES, I as Icon } from './icon-03e86700.js';
4
+ import { LeuIcon } from './Icon.js';
6
5
 
7
6
  var css_248z = css`:host,
8
7
  :host * {
@@ -12,9 +11,10 @@ var css_248z = css`:host,
12
11
  :host {
13
12
  --background: var(--leu-color-black-0);
14
13
  --background-hover: var(--leu-color-black-10);
15
- --background-active: var(--leu-color-func-cyan);
14
+ --background-active: var(--leu-color-accent-blue);
16
15
  --background-disabled: var(--leu-color-black-black-0);
17
16
  --color: var(--leu-color-black-transp-60);
17
+ --color-active: var(--leu-color-black-0);
18
18
  --color-disabled: var(--leu-color-black-transp-20);
19
19
  --font-regular: var(--leu-font-family-regular);
20
20
  --font-black: var(--leu-font-family-black);
@@ -38,6 +38,7 @@ var css_248z = css`:host,
38
38
 
39
39
  padding: 0.75rem;
40
40
 
41
+ font-family: inherit;
41
42
  font-size: 1rem;
42
43
  line-height: 1.5;
43
44
  text-align: left;
@@ -52,21 +53,27 @@ var css_248z = css`:host,
52
53
  }
53
54
 
54
55
  .button:hover,
55
- :host([highlighted]) .button {
56
+ .button:focus-visible {
56
57
  --background: var(--background-hover);
57
58
  }
58
59
 
60
+ /*
61
+ * These colors do not match with the design system (yet).
62
+ * But at least they are compliant with the WCAG AA contrast ratio.
63
+ */
64
+
59
65
  :host([active]) .button {
60
66
  --background: var(--background-active);
67
+ --color: var(--color-active);
61
68
  }
62
69
 
63
70
  :host([disabled]) .button {
64
71
  --background: var(--background-disabled);
65
72
  --color: var(--color-disabled);
66
- cursor: default;
73
+ cursor: not-allowed;
67
74
  }
68
75
 
69
- .before svg, .after svg {
76
+ .before leu-icon, .after leu-icon {
70
77
  display: block;
71
78
  }
72
79
 
@@ -84,102 +91,142 @@ var css_248z = css`:host,
84
91
  }
85
92
  `;
86
93
 
94
+ /**
95
+ * @typedef {'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'none'} MenuItemRole
96
+ */
97
+
87
98
  /**
88
99
  * @tagname leu-menu-item
89
100
  * @slot - The label of the menu item
101
+ * @property {boolean} active - Defines if the item is selected or checked
102
+ * @property {boolean} disabled - Disables the underlying button or link
103
+ * @property {string} value - The value of the item. It must not contain commas. See `getValue()`
104
+ * @property {string} href - The href of the underlying link
105
+ * @property {boolean} tabbable - If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link
106
+ * @property {MenuItemRole} componentRole - The role of the item. This will be reflected as `role` to the underlying button or link. Default is `'menuitem'.`
90
107
  */
91
- class LeuMenuItem extends LitElement {
108
+ class LeuMenuItem extends LeuElement {
92
109
  constructor() {
93
110
  super();
94
111
  this.active = false;
95
112
  this.disabled = false;
113
+ this.value = undefined;
114
+ this.href = undefined;
115
+ this.tabbable = undefined;
96
116
 
97
- /**
98
- * A programmatic way to highlight the menu item like it is hovered.
99
- * This is just a visual effect and does not change the active state.
100
- */
101
- this.highlighted = false;
117
+ /** @type {MenuItemRole} */
118
+ this.componentRole = "menuitem";
102
119
  }
103
- static getIconOrText(name) {
104
- if (ICON_NAMES.includes(name)) {
105
- return Icon(name);
106
- }
107
- if (name === "EMPTY") {
108
- return html`<div class="icon-placeholder"></div>`;
120
+ connectedCallback() {
121
+ super.connectedCallback();
122
+ this.addEventListener("click", this._handleClick, true);
123
+ }
124
+ disconnectedCallback() {
125
+ super.disconnectedCallback();
126
+ this.removeEventListener("click", this._handleClick, true);
127
+ }
128
+ _handleClick(event) {
129
+ if (this.disabled) {
130
+ event.stopPropagation();
131
+ event.preventDefault();
109
132
  }
110
- return name;
111
133
  }
112
- renderBefore() {
113
- if (this.before) {
114
- const content = LeuMenuItem.getIconOrText(this.before);
115
- return html`<span class="before">${content}</span>`;
134
+
135
+ /**
136
+ * Returns the value of the item. If `value` is not set, it will return the inner text
137
+ * @returns {string}
138
+ */
139
+ getValue() {
140
+ return this.value || this.innerText;
141
+ }
142
+ _getAria() {
143
+ const commonAttributes = {
144
+ disabled: this.disabled
145
+ };
146
+ if (this.href) {
147
+ return commonAttributes;
116
148
  }
117
- return nothing;
149
+ return {
150
+ ...commonAttributes,
151
+ checked: this.componentRole === "menuitemcheckbox" || this.componentRole === "menuitemradio" ? this.active : undefined,
152
+ selected: this.componentRole === "option" ? this.active : undefined,
153
+ role: this.componentRole === "none" ? undefined : this.componentRole
154
+ };
118
155
  }
119
- renderAfter() {
120
- if (this.after) {
121
- const content = LeuMenuItem.getIconOrText(this.after);
122
- return html`<span class="after">${content}</span>`;
156
+ _getTabIndex() {
157
+ if (typeof this.tabbable === "boolean") {
158
+ return this.tabbable ? 0 : -1;
123
159
  }
124
- return nothing;
160
+ return undefined;
161
+ }
162
+ _renderLink(content) {
163
+ const aria = this._getAria();
164
+ return html`<a
165
+ class="button"
166
+ href=${this.href}
167
+ aria-disabled=${ifDefined(aria.disabled)}
168
+ aria-checked=${ifDefined(aria.checked)}
169
+ aria-selected=${ifDefined(aria.selected)}
170
+ role=${ifDefined(aria.role)}
171
+ tabindex=${ifDefined(this._getTabIndex())}
172
+ >${content}</a
173
+ >`;
125
174
  }
126
- getTagName() {
127
- return this.href ? "a" : "button";
175
+ _renderButton(content) {
176
+ const aria = this._getAria();
177
+ return html`<button
178
+ class="button"
179
+ aria-disabled=${ifDefined(aria.disabled)}
180
+ aria-checked=${ifDefined(aria.checked)}
181
+ aria-selected=${ifDefined(aria.selected)}
182
+ role=${ifDefined(aria.role)}
183
+ tabindex=${ifDefined(this._getTabIndex())}
184
+ >
185
+ ${content}
186
+ </button>`;
128
187
  }
129
188
  render() {
130
- /* The eslint rules don't recognize html import from lit/static-html.js */
131
- /* eslint-disable lit/binding-positions, lit/no-invalid-html */
132
- return html`<${unsafeStatic(this.getTagName())} class="button" href=${ifDefined(this.href)} ?disabled=${this.disabled}>
133
- ${this.renderBefore()}<span class="label">${this.label}</span
134
- >${this.renderAfter()}
135
- </${unsafeStatic(this.getTagName())}>`;
136
- /* eslint-enable lit/binding-positions, lit/no-invalid-html */
189
+ const content = html`
190
+ <slot class="before" name="before"></slot>
191
+ <span class="label"><slot></slot></span>
192
+ <slot class="after" name="after"></slot>
193
+ `;
194
+ return this.href ? this._renderLink(content) : this._renderButton(content);
137
195
  }
138
196
  }
197
+ _defineProperty(LeuMenuItem, "dependencies", {
198
+ "leu-icon": LeuIcon
199
+ });
139
200
  _defineProperty(LeuMenuItem, "styles", css_248z);
140
201
  /**
141
202
  * @internal
142
203
  */
143
204
  _defineProperty(LeuMenuItem, "shadowRootOptions", {
144
- ...LitElement.shadowRootOptions,
205
+ ...LeuElement.shadowRootOptions,
145
206
  delegatesFocus: true
146
207
  });
147
208
  _defineProperty(LeuMenuItem, "properties", {
148
- /**
149
- * Can be either an icon name or a text
150
- * If no icon with this value is found, it will be displayed as text.
151
- * If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
152
- */
153
- before: {
154
- type: String,
155
- reflect: true
156
- },
157
- /**
158
- * Can be either an icon name or a text
159
- * If no icon with this value is found, it will be displayed as text
160
- * If the value is "EMPTY", an empty placeholder with the size of an icon will be displayed.
161
- */
162
- after: {
163
- type: String,
164
- reflect: true
165
- },
166
209
  active: {
167
210
  type: Boolean,
168
211
  reflect: true
169
212
  },
170
- highlighted: {
213
+ disabled: {
171
214
  type: Boolean,
172
215
  reflect: true
173
216
  },
174
- disabled: {
217
+ tabbable: {
175
218
  type: Boolean,
176
219
  reflect: true
177
220
  },
178
- label: {
221
+ href: {
222
+ type: String,
223
+ reflect: true
224
+ },
225
+ value: {
179
226
  type: String,
180
227
  reflect: true
181
228
  },
182
- href: {
229
+ componentRole: {
183
230
  type: String,
184
231
  reflect: true
185
232
  }
@@ -1,12 +1,19 @@
1
1
  /**
2
2
  * @tagname leu-pagination
3
3
  */
4
- export class LeuPagination extends LitElement {
4
+ export class LeuPagination extends LeuElement {
5
5
  /** @type {Number} */
6
6
  numOfItems: number;
7
7
  /** @type {Number} */
8
8
  itemsPerPage: number;
9
- /** @type {Number} */
9
+ /**
10
+ * Internal page state that contains an
11
+ * already clamped page number. Should only
12
+ * be accessed through the `page` getter and
13
+ * setter.
14
+ * @type {Number}
15
+ * @internal
16
+ */
10
17
  _page: number;
11
18
  attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
12
19
  set page(page: number);
@@ -23,5 +30,5 @@ export class LeuPagination extends LitElement {
23
30
  _handleKeyDown(event: any): void;
24
31
  render(): import("lit-html").TemplateResult<1>;
25
32
  }
26
- import { LitElement } from 'lit';
33
+ import { L as LeuElement } from './LeuElement-6de6f209.js';
27
34
  //# sourceMappingURL=Pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["Pagination.js"],"names":[],"mappings":"AA2EA;;GAEG;AACH;IAII,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,cAAc;IAEhB,oEAKC;IAID,uBAEC;IALD,mBAEC;IAID,yBAEC;IACD,uBAEC;IACD,uBAEC;IACD,wBAEC;IACD,uBAEC;IACD,8BAEC;IACD,6BAaC;IACD,gCAEC;IACD,+BAKC;IACD,iCASC;IACD,+CAsCC;CACF;2BA9LqC,KAAK"}
1
+ {"version":3,"file":"Pagination.d.ts","sourceRoot":"","sources":["Pagination.js"],"names":[],"mappings":"AAwEA;;GAEG;AACH;IAII,qBAAqB;IACrB,mBAAmB;IAEnB,qBAAqB;IACrB,qBAAqB;IAErB;;;;;;;OAOG;IACH,cAAc;IAEhB,oEAKC;IAID,uBAEC;IALD,mBAEC;IAID,yBAEC;IACD,uBAEC;IACD,uBAEC;IACD,wBAEC;IACD,uBAEC;IACD,8BAEC;IACD,6BAaC;IACD,gCAEC;IACD,+BAKC;IACD,iCASC;IACD,+CAsCC;CACF;gCArMqD,0BAA0B"}
@@ -1,14 +1,11 @@
1
- import { _ as _defineProperty } from './_rollupPluginBabelHelpers-20f659f4.js';
2
- import { css, LitElement, html } from 'lit';
1
+ import { _ as _defineProperty, L as LeuElement } from './LeuElement-6de6f209.js';
2
+ import { css, html } from 'lit';
3
3
  import { live } from 'lit/directives/live.js';
4
- import './leu-button.js';
5
- import './leu-visually-hidden.js';
6
- import './defineElement-40372b4b.js';
7
- import './Button-5326c982.js';
4
+ import { L as LeuButton } from './Button-9692e403.js';
5
+ import { LeuVisuallyHidden } from './VisuallyHidden.js';
6
+ import { LeuIcon } from './Icon.js';
8
7
  import 'lit/directives/class-map.js';
9
8
  import 'lit/directives/if-defined.js';
10
- import './icon-03e86700.js';
11
- import './VisuallyHidden.js';
12
9
 
13
10
  var css_248z = css`:host {
14
11
  margin-top: 16px;
@@ -76,15 +73,24 @@ const MIN_PAGE = 1;
76
73
  /**
77
74
  * @tagname leu-pagination
78
75
  */
79
- class LeuPagination extends LitElement {
76
+ class LeuPagination extends LeuElement {
80
77
  constructor() {
81
78
  super();
82
79
 
83
80
  /** @type {Number} */
84
81
  this.numOfItems = 1;
82
+
85
83
  /** @type {Number} */
86
84
  this.itemsPerPage = 1;
87
- /** @type {Number} */
85
+
86
+ /**
87
+ * Internal page state that contains an
88
+ * already clamped page number. Should only
89
+ * be accessed through the `page` getter and
90
+ * setter.
91
+ * @type {Number}
92
+ * @internal
93
+ */
88
94
  this._page = 1;
89
95
  }
90
96
  attributeChangedCallback(name, oldVal, newVal) {
@@ -169,33 +175,38 @@ class LeuPagination extends LitElement {
169
175
  <div class="label">von ${this._maxPage}</div>
170
176
  <div class="button-group">
171
177
  <leu-button
172
- icon="angleLeft"
173
178
  variant="secondary"
174
179
  label="Vorherige Seite"
175
180
  @click=${_ => {
176
181
  this._updatePage(this.page - 1);
177
182
  }}
178
183
  ?disabled=${this._isFirstPage()}
184
+ ><leu-icon name="angleLeft"></leu-icon
179
185
  ></leu-button>
180
186
  <leu-button
181
- icon="angleRight"
182
187
  variant="secondary"
183
188
  label="Nächste Seite"
184
189
  @click=${_ => {
185
190
  this._updatePage(this.page + 1);
186
191
  }}
187
192
  ?disabled=${this._isLastPage()}
193
+ ><leu-icon name="angleRight"></leu-icon
188
194
  ></leu-button>
189
195
  </div>
190
196
  `;
191
197
  }
192
198
  }
199
+ _defineProperty(LeuPagination, "dependencies", {
200
+ "leu-button": LeuButton,
201
+ "leu-icon": LeuIcon,
202
+ "leu-visually-hidden": LeuVisuallyHidden
203
+ });
193
204
  _defineProperty(LeuPagination, "styles", css_248z);
194
205
  /**
195
206
  * @internal
196
207
  */
197
208
  _defineProperty(LeuPagination, "shadowRootOptions", {
198
- ...LitElement.shadowRootOptions,
209
+ ...LeuElement.shadowRootOptions,
199
210
  delegatesFocus: true
200
211
  });
201
212
  _defineProperty(LeuPagination, "properties", {
@@ -211,14 +222,6 @@ _defineProperty(LeuPagination, "properties", {
211
222
  type: Number,
212
223
  reflect: true
213
224
  },
214
- /**
215
- * Internal page state that contains an
216
- * already clamped page number. Should only
217
- * be accessed through the `page` getter and
218
- * setter.
219
- * @type {Number}
220
- * @internal
221
- */
222
225
  _page: {
223
226
  state: true
224
227
  }
package/dist/Popup.d.ts CHANGED
@@ -1,18 +1,36 @@
1
+ export type Placement = "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
2
+ /**
3
+ * @typedef {"top"|"top-start"|"top-end"|"bottom"|"bottom-start"|"bottom-end"|"left"|"left-start"|"left-end"|"right"|"right-start"|"right-end"} Placement
4
+ */
1
5
  /**
2
6
  * @tagname leu-popup
3
7
  */
4
- export class LeuPopup extends LitElement {
8
+ export class LeuPopup extends LeuElement {
5
9
  anchorEl: any;
6
10
  cleanup: () => void;
7
11
  flip: boolean;
8
12
  shift: boolean;
13
+ active: boolean;
14
+ /** @type {Placement} */
15
+ placement: Placement;
16
+ /** @type {"width" | "height" | "both"} */
17
+ matchSize: "width" | "height" | "both";
18
+ /** @type {"width" | "height" | "both"} */
19
+ autoSize: "width" | "height" | "both";
20
+ shiftPadding: number;
21
+ autoSizePadding: number;
22
+ /** @type {string | HTMLElement} */
23
+ anchor: string | HTMLElement;
9
24
  updated(changedProperties: any): void;
10
- get popupEl(): Element;
25
+ /**
26
+ * @returns {HTMLElement | null}
27
+ */
28
+ get popupEl(): HTMLElement;
11
29
  start(): void;
12
30
  stop(): void;
13
31
  reposition(): void;
14
32
  handleAnchorChange(): void;
15
33
  render(): import("lit-html").TemplateResult<1>;
16
34
  }
17
- import { LitElement } from 'lit';
35
+ import { L as LeuElement } from './LeuElement-6de6f209.js';
18
36
  //# sourceMappingURL=Popup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["Popup.js"],"names":[],"mappings":"AAuCA;;GAEG;AACH;IAGI,cAAoB;IACpB,oBAAwB;IACxB,cAAiB;IACjB,eAAkB;IAMpB,sCAcC;IACD,uBAEC;IACD,cAKC;IACD,aAIC;IACD,mBAiEC;IACD,2BAiBC;IACD,+CAOC;CACF;2BA9KqC,KAAK"}
1
+ {"version":3,"file":"Popup.d.ts","sourceRoot":"","sources":["Popup.js"],"names":[],"mappings":"wBAuCa,KAAK,GAAC,WAAW,GAAC,SAAS,GAAC,QAAQ,GAAC,cAAc,GAAC,YAAY,GAAC,MAAM,GAAC,YAAY,GAAC,UAAU,GAAC,OAAO,GAAC,aAAa,GAAC,WAAW;AAD9I;;GAEG;AAEH;;GAEG;AACH;IAGI,cAAoB;IACpB,oBAAwB;IACxB,cAAiB;IACjB,eAAkB;IAClB,gBAAmB;IAEnB,wBAAwB;IACxB,WADW,SAAS,CACM;IAE1B,0CAA0C;IAC1C,WADW,OAAO,GAAG,QAAQ,GAAG,MAAM,CACZ;IAE1B,0CAA0C;IAC1C,UADW,OAAO,GAAG,QAAQ,GAAG,MAAM,CACb;IACzB,qBAAqB;IACrB,wBAAwB;IAExB,mCAAmC;IACnC,QADW,MAAM,GAAG,WAAW,CACR;IAMzB,sCAcC;IAED;;OAEG;IACH,2BAEC;IACD,cAKC;IACD,aAIC;IACD,mBAiEC;IACD,2BAiBC;IACD,+CAOC;CACF;gCArMqD,0BAA0B"}