@statistikzh/leu 0.3.0 → 0.4.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 (153) hide show
  1. package/.github/workflows/deploy-github-pages.yaml +33 -0
  2. package/.storybook/main.js +27 -1
  3. package/.storybook/manager-head.html +1 -0
  4. package/.storybook/manager.js +9 -0
  5. package/.storybook/preview-head.html +1 -1
  6. package/.storybook/preview.js +59 -5
  7. package/.storybook/static/logo.svg +19 -0
  8. package/.storybook/theme.js +7 -0
  9. package/CHANGELOG.md +30 -0
  10. package/README.md +1 -1
  11. package/dist/Button.js +15 -18
  12. package/dist/ButtonGroup.js +5 -7
  13. package/dist/Checkbox.js +101 -84
  14. package/dist/CheckboxGroup.js +41 -37
  15. package/dist/{Chip-5f70d04f.js → Chip-dac7337d.js} +5 -1
  16. package/dist/ChipGroup.js +2 -5
  17. package/dist/ChipLink.js +4 -7
  18. package/dist/ChipRemovable.js +4 -7
  19. package/dist/ChipSelectable.js +4 -7
  20. package/dist/Dropdown.js +55 -26
  21. package/dist/Input.js +29 -28
  22. package/dist/Menu.js +2 -5
  23. package/dist/MenuItem.js +30 -15
  24. package/dist/Pagination.js +54 -54
  25. package/dist/Radio.js +7 -6
  26. package/dist/RadioGroup.js +41 -39
  27. package/dist/Select.js +55 -43
  28. package/dist/Table.js +137 -120
  29. package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
  30. package/dist/defineElement-47d4f665.js +15 -0
  31. package/dist/index.js +29 -19
  32. package/dist/leu-button-group.js +7 -3
  33. package/dist/leu-button.js +6 -3
  34. package/dist/leu-checkbox-group.js +6 -3
  35. package/dist/leu-checkbox.js +6 -3
  36. package/dist/leu-chip-group.js +6 -3
  37. package/dist/leu-chip-link.js +7 -4
  38. package/dist/leu-chip-removable.js +7 -4
  39. package/dist/leu-chip-selectable.js +7 -4
  40. package/dist/leu-dropdown.js +13 -3
  41. package/dist/leu-input.js +7 -3
  42. package/dist/leu-menu-item.js +8 -3
  43. package/dist/leu-menu.js +6 -3
  44. package/dist/leu-pagination.js +8 -3
  45. package/dist/leu-popup-4bf6f1f4.js +216 -0
  46. package/dist/leu-radio-group.js +6 -3
  47. package/dist/leu-radio.js +6 -3
  48. package/dist/leu-select.js +14 -3
  49. package/dist/leu-table.js +9 -3
  50. package/package.json +24 -12
  51. package/scripts/generate-component/templates/[Name].js +0 -5
  52. package/scripts/generate-component/templates/[name].css +1 -1
  53. package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
  54. package/src/components/accordion/Accordion.js +0 -6
  55. package/src/components/accordion/leu-accordion.js +5 -2
  56. package/src/components/accordion/stories/accordion.stories.js +7 -4
  57. package/src/components/accordion/test/accordion.test.js +92 -2
  58. package/src/components/breadcrumb/Breadcrumb.js +310 -0
  59. package/src/components/breadcrumb/breadcrumb.css +114 -0
  60. package/src/components/breadcrumb/leu-breadcrumb.js +6 -0
  61. package/src/components/breadcrumb/stories/breadcrumb.stories.js +73 -0
  62. package/src/components/breadcrumb/test/breadcrumb.test.js +141 -0
  63. package/src/components/button/Button.js +10 -15
  64. package/src/components/button/button.css +3 -3
  65. package/src/components/button/leu-button.js +5 -2
  66. package/src/components/button/stories/button.stories.js +58 -37
  67. package/src/components/button/test/button.test.js +112 -2
  68. package/src/components/button-group/ButtonGroup.js +1 -7
  69. package/src/components/button-group/leu-button-group.js +5 -2
  70. package/src/components/button-group/stories/button-group.stories.js +6 -0
  71. package/src/components/button-group/test/button-group.test.js +79 -3
  72. package/src/components/checkbox/Checkbox.js +6 -85
  73. package/src/components/checkbox/CheckboxGroup.js +8 -38
  74. package/src/components/checkbox/checkbox-group.css +29 -0
  75. package/src/components/checkbox/checkbox.css +76 -0
  76. package/src/components/checkbox/leu-checkbox-group.js +5 -2
  77. package/src/components/checkbox/leu-checkbox.js +5 -2
  78. package/src/components/checkbox/stories/checkbox-group.stories.js +44 -21
  79. package/src/components/checkbox/stories/checkbox.stories.js +7 -1
  80. package/src/components/checkbox/test/checkbox-group.test.js +124 -0
  81. package/src/components/checkbox/test/checkbox.test.js +72 -59
  82. package/src/components/chip/Chip.js +1 -0
  83. package/src/components/chip/ChipGroup.js +0 -5
  84. package/src/components/chip/ChipLink.js +1 -6
  85. package/src/components/chip/ChipRemovable.js +1 -6
  86. package/src/components/chip/ChipSelectable.js +1 -6
  87. package/src/components/chip/exports.js +4 -10
  88. package/src/components/chip/leu-chip-group.js +5 -2
  89. package/src/components/chip/leu-chip-link.js +5 -2
  90. package/src/components/chip/leu-chip-removable.js +5 -2
  91. package/src/components/chip/leu-chip-selectable.js +5 -2
  92. package/src/components/chip/stories/chip-group.stories.js +18 -6
  93. package/src/components/chip/stories/chip-link.stories.js +16 -4
  94. package/src/components/chip/stories/chip-removable.stories.js +15 -4
  95. package/src/components/chip/stories/chip-selectable.stories.js +13 -3
  96. package/src/components/chip/test/chip-group.test.js +124 -0
  97. package/src/components/chip/test/chip-link.test.js +58 -0
  98. package/src/components/chip/test/chip-removable.test.js +79 -0
  99. package/src/components/chip/test/chip-selectable.test.js +95 -0
  100. package/src/components/chip/test/chip.test.js +1 -1
  101. package/src/components/dropdown/Dropdown.js +52 -24
  102. package/src/components/dropdown/dropdown.css +1 -2
  103. package/src/components/dropdown/leu-dropdown.js +5 -2
  104. package/src/components/dropdown/stories/dropdown.stories.js +11 -5
  105. package/src/components/dropdown/test/dropdown.test.js +6 -6
  106. package/src/components/icon/icon.js +1 -1
  107. package/src/components/icon/test/icon.test.js +66 -0
  108. package/src/components/input/Input.js +18 -24
  109. package/src/components/input/input.css +9 -6
  110. package/src/components/input/leu-input.js +5 -2
  111. package/src/components/input/stories/input.stories.js +8 -2
  112. package/src/components/input/test/input.test.js +431 -4
  113. package/src/components/menu/Menu.js +0 -5
  114. package/src/components/menu/MenuItem.js +20 -13
  115. package/src/components/menu/leu-menu-item.js +5 -2
  116. package/src/components/menu/leu-menu.js +5 -2
  117. package/src/components/menu/menu-item.css +5 -2
  118. package/src/components/menu/stories/menu-item.stories.js +13 -4
  119. package/src/components/menu/stories/menu.stories.js +11 -5
  120. package/src/components/menu/test/menu-item.test.js +180 -0
  121. package/src/components/menu/test/menu.test.js +10 -2
  122. package/src/components/pagination/Pagination.js +53 -65
  123. package/src/components/pagination/leu-pagination.js +5 -2
  124. package/src/components/pagination/stories/pagination.stories.js +17 -9
  125. package/src/components/pagination/test/pagination.test.js +191 -5
  126. package/src/components/popup/Popup.js +200 -0
  127. package/src/components/popup/leu-popup.js +6 -0
  128. package/src/components/popup/popup.css +27 -0
  129. package/src/components/popup/stories/popup.stories.js +58 -0
  130. package/src/components/popup/test/popup.test.js +29 -0
  131. package/src/components/radio/Radio.js +2 -6
  132. package/src/components/radio/RadioGroup.js +6 -38
  133. package/src/components/radio/leu-radio-group.js +5 -2
  134. package/src/components/radio/leu-radio.js +5 -2
  135. package/src/components/radio/radio-group.css +29 -0
  136. package/src/components/radio/stories/radio-group.stories.js +38 -19
  137. package/src/components/radio/stories/radio.stories.js +7 -1
  138. package/src/components/radio/test/radio-group.test.js +86 -0
  139. package/src/components/radio/test/radio.test.js +108 -17
  140. package/src/components/select/Select.js +34 -31
  141. package/src/components/select/leu-select.js +5 -2
  142. package/src/components/select/select.css +13 -13
  143. package/src/components/select/stories/select.stories.js +15 -168
  144. package/src/components/select/test/fixtures.js +162 -0
  145. package/src/components/select/test/select.test.js +236 -12
  146. package/src/components/table/Table.js +43 -118
  147. package/src/components/table/leu-table.js +5 -2
  148. package/src/components/table/stories/table.stories.js +20 -10
  149. package/src/components/table/table.css +99 -0
  150. package/src/components/table/test/table.test.js +1 -1
  151. package/src/lib/utils.js +17 -0
  152. package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
  153. package/web-test-runner.config.mjs +15 -2
@@ -4,15 +4,17 @@ import "../leu-table.js"
4
4
  export default {
5
5
  title: "Table",
6
6
  component: "leu-table",
7
+ parameters: {
8
+ design: {
9
+ type: "figma",
10
+ url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=316-2445&mode=design&t=lzVrtq8lxYVJU5TB-11",
11
+ },
12
+ },
7
13
  }
8
14
 
9
- function Template({ itemsOnAPage }) {
15
+ function Template({ itemsPerPage }) {
10
16
  return html`
11
- <leu-table
12
- id="table"
13
- itemsOnAPage=${itemsOnAPage}
14
- style="max-width:500px;"
15
- ></leu-table>
17
+ <leu-table id="table" itemsPerPage=${itemsPerPage}></leu-table>
16
18
  <script>
17
19
  {
18
20
  const table = document.querySelector("leu-table[id=table]")
@@ -39,7 +41,10 @@ function Template({ itemsOnAPage }) {
39
41
  value: (row) => row.menge,
40
42
  style: (row) => {
41
43
  return {
42
- color: row.menge > 10 ? "green" : "red",
44
+ color:
45
+ row.menge > 10
46
+ ? "var(--leu-color-func-green)"
47
+ : "var(--leu-color-func-red)",
43
48
  }
44
49
  },
45
50
  sort: {
@@ -96,7 +101,7 @@ function Template({ itemsOnAPage }) {
96
101
 
97
102
  export const Regular = Template.bind({})
98
103
  Regular.argTypes = {
99
- itemsOnAPage: { type: "number" },
104
+ itemsPerPage: { type: "number" },
100
105
  columns: { table: { disable: true } },
101
106
  data: { table: { disable: true } },
102
107
  _columns: { table: { disable: true } },
@@ -108,9 +113,14 @@ Regular.argTypes = {
108
113
  _sortArrowDown: { table: { disable: true } },
109
114
  _sortArrowUp: { table: { disable: true } },
110
115
  _scrollRef: { table: { disable: true } },
111
- _itemsOnAPage: { table: { disable: true } },
116
+ _itemsPerPage: { table: { disable: true } },
112
117
  _sortedData: { table: { disable: true } },
113
118
  }
114
119
  Regular.args = {
115
- itemsOnAPage: null,
120
+ itemsPerPage: null,
121
+ }
122
+
123
+ export const Pagination = Template.bind({})
124
+ Pagination.args = {
125
+ itemsPerPage: 10,
116
126
  }
@@ -0,0 +1,99 @@
1
+ :host {
2
+ position: relative;
3
+ display: block;
4
+ }
5
+
6
+ div.scroll {
7
+ display: inline-block;
8
+ width: 100%;
9
+ overflow: auto;
10
+ }
11
+
12
+ div.shadow {
13
+ position: absolute;
14
+ left: 0;
15
+ top: 0;
16
+ width: 100%;
17
+ height: 100%;
18
+ pointer-events: none;
19
+ z-index: 1;
20
+ }
21
+
22
+ div.pagination {
23
+ height: calc(100% - 66px);
24
+ }
25
+
26
+ table {
27
+ width: 100%;
28
+ border-spacing: 0;
29
+ color: rgb(0 0 0 / 60%);
30
+ font-size: 16px;
31
+ font-family: var(--leu-font-regular);
32
+ line-height: 1.5;
33
+ }
34
+
35
+ td {
36
+ padding: 12px;
37
+ }
38
+
39
+ th {
40
+ padding: 16px 16px 8px;
41
+ text-align: left;
42
+ font-size: 12px;
43
+ font-weight: normal;
44
+ font-family: var(--leu-font-black);
45
+ background: var(--table-even-row-bg);
46
+ }
47
+
48
+ td:first-child,
49
+ th:first-child {
50
+ left: 0;
51
+ background: inherit;
52
+ z-index: 1;
53
+ }
54
+
55
+ tr {
56
+ background: #fff;
57
+ }
58
+
59
+ tbody tr:nth-child(odd) {
60
+ background: var(--leu-color-black-5);
61
+ }
62
+
63
+ button {
64
+ background: none;
65
+ cursor: pointer;
66
+ line-height: 1.5;
67
+ padding: 0;
68
+ border: 0;
69
+ width: 100%;
70
+ display: flex;
71
+ align-items: flex-center;
72
+ font-size: inherit;
73
+ font-family: inherit;
74
+ }
75
+
76
+ thead svg {
77
+ display: inline-block;
78
+ color: var(--leu-color-accent-blue);
79
+ padding: 0;
80
+ }
81
+
82
+ table.sticky td:first-child,
83
+ table.sticky th:first-child {
84
+ position: sticky;
85
+ }
86
+
87
+ div.shadow-left table.sticky td:first-child,
88
+ div.shadow-left table.sticky th:first-child {
89
+ box-shadow: 0 0 5px rgb(0 0 0 / 50%);
90
+ clip-path: inset(0 -15px 0 0);
91
+ }
92
+
93
+ div.shadow-left {
94
+ box-shadow: inset 5px 0 5px -5px rgb(0 0 0 / 50%);
95
+ }
96
+
97
+ div.shadow-right {
98
+ box-shadow: inset -5px 0 5px -5px rgb(0 0 0 / 50%);
99
+ }
@@ -23,7 +23,7 @@ async function defaultFixture() {
23
23
 
24
24
  describe("LeuTable", () => {
25
25
  it("is a defined element", async () => {
26
- const el = await customElements.get("leu-table")
26
+ const el = customElements.get("leu-table")
27
27
 
28
28
  await expect(el).not.to.be.undefined
29
29
  })
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Wrap a Function to nsure that time-consuming tasks do not fire so often
3
+ * @param {Function} func - Your function
4
+ * @param {Number} timeout - Default is 500 ms
5
+ * @returns {Function} - Your function wrapped in a timeout function
6
+ */
7
+ const debounce = function (func, timeout = 500) {
8
+ let timer = null
9
+ return (...args) => {
10
+ clearTimeout(timer)
11
+ timer = setTimeout(() => {
12
+ func.apply(this, args)
13
+ }, timeout)
14
+ }
15
+ }
16
+
17
+ export { debounce }
@@ -1,6 +1,5 @@
1
1
  import { fromRollup } from "@web/dev-server-rollup"
2
2
  import rollupJson from "@rollup/plugin-json"
3
- import { storybookPlugin } from "@web/dev-server-storybook"
4
3
 
5
4
  import { plugins as rollupPlugins } from "./rollup.config.js"
6
5
 
@@ -15,5 +14,5 @@ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
15
14
  "**/custom-elements.json": "js",
16
15
  "src/components/**/*.css": "js",
17
16
  },
18
- plugins: [storybookPlugin({ type: "web-components" }), ...plugins, json()],
17
+ plugins: [...plugins, json()],
19
18
  })
@@ -1,12 +1,12 @@
1
1
  import { playwrightLauncher } from "@web/test-runner-playwright"
2
- import { plugins as devServerPlugins } from "./web-dev-server-storybook.config.mjs"
2
+ import { plugins as wdsPlugins } from "./web-dev-server.config.mjs"
3
3
 
4
4
  const filteredLogs = ["Running in dev mode", "lit-html is in dev mode"]
5
5
 
6
6
  export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
7
7
  /** Test files to run */
8
8
  files: "src/components/**/*.test.js",
9
- plugins: devServerPlugins,
9
+ plugins: wdsPlugins,
10
10
  mimeTypes: {
11
11
  "src/components/**/*.css": "js",
12
12
  },
@@ -45,5 +45,18 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
45
45
  // playwrightLauncher({ product: "webkit" }),
46
46
  ],
47
47
 
48
+ testRunnerHtml: (testFramework) =>
49
+ `<html>
50
+ <head>
51
+ <meta charset="utf-8" />
52
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
53
+ <link rel="stylesheet" href="dist/theme.css" />
54
+ <link rel="stylesheet" href="https://www.web.statistik.zh.ch/leu/styles/fonts.css" />
55
+ </head>
56
+ <body>
57
+ <script type="module" src="${testFramework}"></script>
58
+ </body>
59
+ </html>`,
60
+
48
61
  // See documentation for all available options
49
62
  })