@statistikzh/leu 0.13.1 → 0.14.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 (174) hide show
  1. package/.eslintrc.json +8 -0
  2. package/.github/workflows/ci.yml +78 -0
  3. package/.github/workflows/deploy-github-pages.yaml +2 -1
  4. package/.github/workflows/release-please.yml +2 -1
  5. package/.nvmrc +1 -0
  6. package/.prettierignore +1 -0
  7. package/.storybook/main.js +19 -3
  8. package/CHANGELOG.md +16 -0
  9. package/custom-elements-manifest.config.js +2 -2
  10. package/dist/Accordion.d.ts +1 -1
  11. package/dist/Accordion.d.ts.map +1 -1
  12. package/dist/Accordion.js +2 -4
  13. package/dist/Button.d.ts +2 -2
  14. package/dist/Button.js +2 -2
  15. package/dist/ButtonGroup.d.ts +1 -1
  16. package/dist/ButtonGroup.js +1 -1
  17. package/dist/Checkbox.d.ts +1 -1
  18. package/dist/Checkbox.d.ts.map +1 -1
  19. package/dist/Checkbox.js +2 -3
  20. package/dist/CheckboxGroup.d.ts +1 -1
  21. package/dist/CheckboxGroup.d.ts.map +1 -1
  22. package/dist/CheckboxGroup.js +1 -3
  23. package/dist/Chip.d.ts +1 -1
  24. package/dist/Chip.d.ts.map +1 -1
  25. package/dist/Chip.js +1 -3
  26. package/dist/ChipGroup.d.ts +1 -1
  27. package/dist/ChipGroup.d.ts.map +1 -1
  28. package/dist/ChipGroup.js +2 -2
  29. package/dist/ChipLink.js +1 -1
  30. package/dist/ChipRemovable.js +1 -1
  31. package/dist/ChipSelectable.js +1 -1
  32. package/dist/Dialog.d.ts +1 -1
  33. package/dist/Dialog.d.ts.map +1 -1
  34. package/dist/Dialog.js +3 -5
  35. package/dist/Dropdown.d.ts +1 -1
  36. package/dist/Dropdown.js +3 -3
  37. package/dist/Icon.d.ts +2 -98
  38. package/dist/Icon.d.ts.map +1 -1
  39. package/dist/Icon.js +1 -1
  40. package/dist/Input.d.ts +7 -2
  41. package/dist/Input.d.ts.map +1 -1
  42. package/dist/Input.js +15 -8
  43. package/dist/{LeuElement-b670d77c.d.ts → LeuElement-BjGpKQpe.d.ts} +1 -1
  44. package/dist/LeuElement-BjGpKQpe.d.ts.map +1 -0
  45. package/dist/{LeuElement-b670d77c.js → LeuElement-BjGpKQpe.js} +2 -2
  46. package/dist/Menu.d.ts +2 -2
  47. package/dist/Menu.js +1 -1
  48. package/dist/MenuItem.d.ts +3 -3
  49. package/dist/MenuItem.js +1 -1
  50. package/dist/Pagination.d.ts +1 -1
  51. package/dist/Pagination.js +3 -3
  52. package/dist/Popup.d.ts +2 -2
  53. package/dist/Popup.d.ts.map +1 -1
  54. package/dist/Popup.js +1 -3
  55. package/dist/Radio.d.ts +1 -1
  56. package/dist/Radio.d.ts.map +1 -1
  57. package/dist/Radio.js +1 -3
  58. package/dist/RadioGroup.d.ts +1 -1
  59. package/dist/RadioGroup.d.ts.map +1 -1
  60. package/dist/RadioGroup.js +1 -3
  61. package/dist/Range.d.ts +1 -1
  62. package/dist/Range.d.ts.map +1 -1
  63. package/dist/Range.js +17 -19
  64. package/dist/ScrollTop.d.ts +1 -1
  65. package/dist/ScrollTop.d.ts.map +1 -1
  66. package/dist/ScrollTop.js +27 -3
  67. package/dist/Select.d.ts +3 -3
  68. package/dist/Select.d.ts.map +1 -1
  69. package/dist/Select.js +6 -4
  70. package/dist/Spinner.d.ts +1 -1
  71. package/dist/Spinner.js +1 -1
  72. package/dist/Table.d.ts +1 -1
  73. package/dist/Table.d.ts.map +1 -1
  74. package/dist/Table.js +3 -4
  75. package/dist/VisuallyHidden.d.ts +1 -1
  76. package/dist/VisuallyHidden.d.ts.map +1 -1
  77. package/dist/VisuallyHidden.js +3 -5
  78. package/dist/{hasSlotController-c09741c5.d.ts → hasSlotController-DvFw2NdC.d.ts} +1 -1
  79. package/dist/hasSlotController-DvFw2NdC.d.ts.map +1 -0
  80. package/dist/{hasSlotController-c09741c5.js → hasSlotController-DvFw2NdC.js} +1 -1
  81. package/dist/index.d.ts +1 -2
  82. package/dist/index.js +5 -7
  83. package/dist/leu-accordion.js +1 -1
  84. package/dist/leu-button-group.js +1 -1
  85. package/dist/leu-button.js +2 -2
  86. package/dist/leu-checkbox-group.js +1 -1
  87. package/dist/leu-checkbox.js +1 -1
  88. package/dist/leu-chip-group.js +1 -1
  89. package/dist/leu-chip-link.js +1 -1
  90. package/dist/leu-chip-removable.js +1 -1
  91. package/dist/leu-chip-selectable.js +1 -1
  92. package/dist/leu-dialog.js +2 -2
  93. package/dist/leu-dropdown.js +2 -2
  94. package/dist/leu-icon.js +1 -1
  95. package/dist/leu-input.js +1 -1
  96. package/dist/leu-menu-item.js +1 -1
  97. package/dist/leu-menu.js +1 -1
  98. package/dist/leu-pagination.js +2 -2
  99. package/dist/leu-popup.js +1 -1
  100. package/dist/leu-radio-group.js +1 -1
  101. package/dist/leu-radio.js +1 -1
  102. package/dist/leu-range.js +1 -1
  103. package/dist/leu-scroll-top.js +2 -3
  104. package/dist/leu-select.js +2 -2
  105. package/dist/leu-spinner.js +1 -1
  106. package/dist/leu-table.js +2 -2
  107. package/dist/leu-visually-hidden.js +1 -1
  108. package/dist/theme.css +143 -107
  109. package/dist/vscode.html-custom-data.json +3 -32
  110. package/dist/vue/index.d.ts +11 -77
  111. package/dist/web-types.json +246 -242
  112. package/index.js +0 -1
  113. package/package.json +55 -51
  114. package/rollup.config.js +3 -3
  115. package/scripts/generate-component/generate.js +5 -5
  116. package/src/components/accordion/test/accordion.test.js +24 -20
  117. package/src/components/button/Button.js +1 -1
  118. package/src/components/button/stories/button.stories.js +43 -45
  119. package/src/components/button/test/button.test.js +10 -10
  120. package/src/components/button-group/ButtonGroup.js +1 -1
  121. package/src/components/button-group/stories/button-group.stories.js +2 -2
  122. package/src/components/checkbox/checkbox.css +1 -0
  123. package/src/components/chip/ChipSelectable.js +1 -1
  124. package/src/components/chip/stories/chip-group.stories.js +4 -4
  125. package/src/components/chip/test/chip-group.test.js +25 -33
  126. package/src/components/chip/test/chip-link.test.js +5 -5
  127. package/src/components/chip/test/chip-removable.test.js +6 -8
  128. package/src/components/chip/test/chip-selectable.test.js +9 -11
  129. package/src/components/dialog/test/dialog.test.js +1 -1
  130. package/src/components/dropdown/test/dropdown.test.js +12 -13
  131. package/src/components/input/Input.js +25 -17
  132. package/src/components/input/stories/input.stories.js +0 -2
  133. package/src/components/input/test/input.test.js +26 -0
  134. package/src/components/menu/stories/menu-item.stories.js +2 -0
  135. package/src/components/menu/test/menu-item.test.js +3 -2
  136. package/src/components/menu/test/menu.test.js +24 -22
  137. package/src/components/pagination/Pagination.js +1 -1
  138. package/src/components/pagination/pagination.css +1 -1
  139. package/src/components/pagination/stories/pagination.stories.js +2 -1
  140. package/src/components/pagination/test/pagination.test.js +8 -6
  141. package/src/components/popup/Popup.js +4 -4
  142. package/src/components/popup/test/popup.test.js +6 -8
  143. package/src/components/radio/RadioGroup.js +2 -2
  144. package/src/components/range/Range.js +20 -21
  145. package/src/components/select/Select.js +6 -1
  146. package/src/components/select/stories/select.stories.js +1 -1
  147. package/src/components/select/test/select.test.js +18 -16
  148. package/src/components/table/Table.js +4 -4
  149. package/src/components/table/test/table.test.js +3 -2
  150. package/src/components/visually-hidden/test/visually-hidden.test.js +6 -8
  151. package/src/lib/LeuElement.js +2 -2
  152. package/src/lib/hasSlotController.js +1 -1
  153. package/src/styles/style.stories.js +3 -1
  154. package/tsconfig.build.json +4 -3
  155. package/web-dev-server.config.mjs +1 -0
  156. package/web-test-runner.config.mjs +1 -1
  157. package/.github/workflows/test.yml +0 -38
  158. package/.storybook/preview-head.html +0 -2
  159. package/dist/Breadcrumb.d.ts +0 -69
  160. package/dist/Breadcrumb.d.ts.map +0 -1
  161. package/dist/Breadcrumb.js +0 -391
  162. package/dist/LeuElement-b670d77c.d.ts.map +0 -1
  163. package/dist/hasSlotController-c09741c5.d.ts.map +0 -1
  164. package/dist/leu-breadcrumb.d.ts +0 -3
  165. package/dist/leu-breadcrumb.d.ts.map +0 -1
  166. package/dist/leu-breadcrumb.js +0 -17
  167. package/dist/utils-65469421.d.ts +0 -16
  168. package/dist/utils-65469421.d.ts.map +0 -1
  169. package/dist/utils-65469421.js +0 -35
  170. package/src/components/breadcrumb/Breadcrumb.js +0 -324
  171. package/src/components/breadcrumb/breadcrumb.css +0 -98
  172. package/src/components/breadcrumb/leu-breadcrumb.js +0 -5
  173. package/src/components/breadcrumb/stories/breadcrumb.stories.js +0 -73
  174. package/src/components/breadcrumb/test/breadcrumb.test.js +0 -141
@@ -141,7 +141,7 @@ export class LeuTable extends LeuElement {
141
141
  return this.itemsPerPage && this.itemsPerPage > 0
142
142
  ? this._sortedData.slice(
143
143
  (this._page - 1) * this.itemsPerPage,
144
- this._page * this.itemsPerPage
144
+ this._page * this.itemsPerPage,
145
145
  )
146
146
  : this._sortedData
147
147
  }
@@ -214,7 +214,7 @@ export class LeuTable extends LeuElement {
214
214
  : nothing}
215
215
  </button>`
216
216
  : col.name}
217
- </th>`
217
+ </th>`,
218
218
  )}
219
219
  </tr>
220
220
  </thead>
@@ -226,9 +226,9 @@ export class LeuTable extends LeuElement {
226
226
  (col) =>
227
227
  html`<td style=${bodyStyle(col, row)}>
228
228
  ${col.value(row)}
229
- </td>`
229
+ </td>`,
230
230
  )}
231
- </tr>`
231
+ </tr>`,
232
232
  )}
233
233
  </tbody>
234
234
  </table>
@@ -17,8 +17,9 @@ const data = [
17
17
  ]
18
18
 
19
19
  async function defaultFixture() {
20
- return fixture(html`<leu-table .columns=${columns} .data=${data}>
21
- </leu-table>`)
20
+ return fixture(
21
+ html`<leu-table .columns=${columns} .data=${data}> </leu-table>`,
22
+ )
22
23
  }
23
24
 
24
25
  describe("LeuTable", () => {
@@ -4,13 +4,11 @@ import { fixture, expect } from "@open-wc/testing"
4
4
  import "../leu-visually-hidden.js"
5
5
 
6
6
  async function defaultFixture() {
7
- return fixture(
8
- html`
9
- <leu-visually-hidden>
10
- This is a text that shouldn't be visible but still accessible.
11
- </leu-visually-hidden>
12
- `
13
- )
7
+ return fixture(html`
8
+ <leu-visually-hidden>
9
+ This is a text that shouldn't be visible but still accessible.
10
+ </leu-visually-hidden>
11
+ `)
14
12
  }
15
13
 
16
14
  describe("LeuVisuallyHidden", () => {
@@ -30,7 +28,7 @@ describe("LeuVisuallyHidden", () => {
30
28
  const el = await defaultFixture()
31
29
 
32
30
  expect(el).dom.to.equal(
33
- "<leu-visually-hidden>This is a text that shouldn't be visible but still accessible.</leu-visually-hidden>"
31
+ "<leu-visually-hidden>This is a text that shouldn't be visible but still accessible.</leu-visually-hidden>",
34
32
  )
35
33
  })
36
34
  })
@@ -20,14 +20,14 @@ export class LeuElement extends LitElement {
20
20
 
21
21
  if (currentlyRegisteredConstructor !== constructor) {
22
22
  console.warn(
23
- `The custom element with the name <${name}> is already registered with a different constructor. This can happen when the same element has been loaded from different modules (e.g. multiple CDN requests or bundles).`
23
+ `The custom element with the name <${name}> is already registered with a different constructor. This can happen when the same element has been loaded from different modules (e.g. multiple CDN requests or bundles).`,
24
24
  )
25
25
  return
26
26
  }
27
27
 
28
28
  if (currentlyRegisteredConstructor.version !== constructor.version) {
29
29
  console.warn(
30
- `The custom element with the name <${name}> is already defined with the same constructor but a different version (${currentlyRegisteredConstructor.version}).`
30
+ `The custom element with the name <${name}> is already defined with the same constructor but a different version (${currentlyRegisteredConstructor.version}).`,
31
31
  )
32
32
  }
33
33
  }
@@ -65,7 +65,7 @@ export class HasSlotController {
65
65
  hostDisconnected() {
66
66
  this.host.shadowRoot.removeEventListener(
67
67
  "slotchange",
68
- this.handleSlotChange
68
+ this.handleSlotChange,
69
69
  )
70
70
  }
71
71
 
@@ -53,7 +53,9 @@ function Template() {
53
53
  .flat()
54
54
  .map(
55
55
  (columns) =>
56
- html`<div style="grid-column-end: span ${columns}">${columns}</div>`
56
+ html`<div style="grid-column-end: span ${columns}">
57
+ ${columns}
58
+ </div>`,
57
59
  )}
58
60
  </div>`
59
61
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "include": ["dist/**/*.js"],
3
- "exclude": ["node_modules", "dist/**/*.d.ts"],
2
+ "include": ["./dist/**/*.js"],
3
+ "exclude": ["./node_modules"],
4
4
  "compilerOptions": {
5
5
  // Tells TypeScript to read JS files, as
6
6
  // normally they are ignored as source files
@@ -16,6 +16,7 @@
16
16
  "outDir": "dist",
17
17
  // go to js file when using IDE functions like
18
18
  // "Go to Definition" in VSCode
19
- "declarationMap": true
19
+ "declarationMap": true,
20
+ "skipLibCheck": true
20
21
  }
21
22
  }
@@ -13,6 +13,7 @@ export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
13
13
  mimeTypes: {
14
14
  "**/custom-elements.json": "js",
15
15
  "src/components/**/*.css": "js",
16
+ ".storybook/static/*.css": "js",
16
17
  "src/styles/common-styles.css": "js",
17
18
  },
18
19
  plugins: [...plugins, json()],
@@ -1,7 +1,7 @@
1
1
  import { playwrightLauncher } from "@web/test-runner-playwright"
2
2
  import { plugins as wdsPlugins } from "./web-dev-server.config.mjs"
3
3
 
4
- const filteredLogs = ["Running in dev mode", "lit-html is in dev mode"]
4
+ const filteredLogs = ["Couldn't load preload assets", "Lit is in dev mode"]
5
5
 
6
6
  export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
7
7
  /** Test files to run */
@@ -1,38 +0,0 @@
1
- name: Test
2
-
3
- on: workflow_dispatch
4
-
5
- jobs:
6
- test:
7
- runs-on: ubuntu-latest
8
-
9
- steps:
10
- - name: Checkout code
11
- uses: actions/checkout@v4
12
-
13
- - name: Use Node.js
14
- uses: actions/setup-node@v3
15
- with:
16
- node-version: "18.x"
17
-
18
- - name: Install dependencies
19
- run: npm ci
20
-
21
- - name: Install Playwright browsers
22
- run: npx playwright install
23
-
24
- - name: Cache Playwright binaries
25
- uses: actions/cache@v3
26
- with:
27
- path: ~/.cache/ms-playwright
28
- key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
29
- restore-keys: |
30
- ${{ runner.os }}-playwright-
31
-
32
- - name: Run tests
33
- run: npm test
34
-
35
- - uses: actions/upload-artifact@v3
36
- with:
37
- name: coverage
38
- path: coverage/
@@ -1,2 +0,0 @@
1
- <link rel="stylesheet" href="theme.css" />
2
- <link rel="stylesheet" href="fonts.css" />
@@ -1,69 +0,0 @@
1
- /**
2
- * A Breadcrumb Navigation.
3
- *
4
- * The breadcrumbs can be displayed in two different layouts.
5
- * Only the back link (the last item / parent of the current page)
6
- * is displayed when…
7
- * - … the width of the container is smaller
8
- * than the BACK_ONLY_BREAKPOINT.
9
- * - … less then two breadcrumb items could be displayed
10
- * without overflowing the container.
11
- *
12
- * Otherwise as many items as possible are displayed in an inline list
13
- * without overflowing the container. The remaining items are displayed
14
- * in a dropdown menu.
15
- *
16
- * In order to determine the exact numbers of items that have to be
17
- * hidden inside the dropdown, all of them have to be rendered first.
18
- * 1. Render all items
19
- * 2. Calculate (measure) the number of items that can be displayed
20
- * without overflowing the container.
21
- * 3. Updating the state (_hiddeItems) which will trigger a rerender
22
- * 4. Render the items again with the new state.
23
- *
24
- * This results in multiple updates scheduled one after another. Lit
25
- * will also print a waring in the console beacause of that.
26
- * It's no a nice behaviour but the only one that works without
27
- * having duplicate and hidden markup to derive the sizes from that.
28
- *
29
- *
30
- * @prop {Array} items - Object array with { label, href }
31
- * @prop {boolean} inverted - invert color on dark background
32
- *
33
- * @tagname leu-breadcrumb
34
- */
35
- export class LeuBreadcrumb extends LeuElement {
36
- _lastContainerWidth: any;
37
- _showBackOnly: boolean;
38
- _isRecalculating: boolean;
39
- _hiddenItems: number;
40
- _isDropdownOpen: boolean;
41
- items: any[];
42
- /** @type {boolean} - will be used on dark Background */
43
- inverted: boolean;
44
- /** @internal */
45
- _containerRef: import("lit-html/directives/ref.js").Ref<Element>;
46
- resizeObserver: ResizeObserver;
47
- firstUpdated(): void;
48
- updated(changedProperties: any): Promise<void>;
49
- /** @internal */
50
- get _listItems(): any;
51
- /** @internal */
52
- get _dropdownItems(): any[];
53
- /**
54
- * Calculate the number of items that can be displayed
55
- * without overflowing the container.
56
- * @internal
57
- * @returns {void}
58
- */
59
- _checkWidth(): void;
60
- /**
61
- * Render the dropdown menu
62
- * @returns
63
- */
64
- renderDropdown(): import("lit-html").TemplateResult<1> | typeof nothing;
65
- render(): import("lit-html").TemplateResult<1> | typeof nothing;
66
- }
67
- import { L as LeuElement } from './LeuElement-b670d77c.js';
68
- import { nothing } from 'lit';
69
- //# sourceMappingURL=Breadcrumb.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Breadcrumb.d.ts","sourceRoot":"","sources":["Breadcrumb.js"],"names":[],"mappings":"AAoHA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH;IAOM,yBAA+C;IAO7C,uBAAyB;IACzB,0BAA6B;IAY7B,qBAAqB;IASvB,yBAA4C;IAW9C,aAAe;IACf,wDAAwD;IACxD,UADW,OAAO,CACG;IAErB,gBAAgB;IAChB,iEAAgC;IAehC,+BAEQ;IAEV,qBAEC;IACD,+CAOC;IAOD,gBAAgB;IAChB,sBAEC;IAED,gBAAgB;IAChB,4BAEC;IACD;;;;;OAKG;IACH,eAFa,IAAI,CA4BhB;IACD;;;OAGG;IACH,wEAqCC;IACD,gEAmCC;CACF;gCAtWqD,0BAA0B;wBAC7C,KAAK"}
@@ -1,391 +0,0 @@
1
- import { _ as _defineProperty, L as LeuElement } from './LeuElement-b670d77c.js';
2
- import { css, nothing, html } from 'lit';
3
- import { createRef, ref } from 'lit/directives/ref.js';
4
- import { classMap } from 'lit/directives/class-map.js';
5
- import { d as debounce } from './utils-65469421.js';
6
- import { LeuIcon } from './Icon.js';
7
- import { LeuMenu } from './Menu.js';
8
- import { LeuMenuItem } from './MenuItem.js';
9
- import { LeuPopup } from './Popup.js';
10
- import { LeuVisuallyHidden } from './VisuallyHidden.js';
11
- import 'lit/directives/if-defined.js';
12
- import '@floating-ui/dom';
13
-
14
- var css_248z = css`:host {
15
- --breadcrumb-font-regular: var(--leu-font-family-regular);
16
- --breadcrumb-font-black: var(--leu-font-family-black);
17
-
18
- font-family: var(--leu-font-family-regular);
19
-
20
- font-family: var(--breadcrumb-font-regular);
21
- line-height: 1.5;
22
- color: var(--leu-color-black-100);
23
- }
24
-
25
- :host([inverted]) {
26
- color: var(--leu-color-black-0);
27
- }
28
-
29
- .breadcrumbs__list {
30
- display: flex;
31
- align-items: center;
32
- list-style-type: none;
33
- margin: 0;
34
- padding: 0;
35
- }
36
-
37
- .breadcrumbs--back-only .breadcrumbs__list {
38
- overflow: hidden;
39
- }
40
-
41
- .breadcrumbs__item,
42
- .breadcrumbs__icon {
43
- align-items: center;
44
- display: flex;
45
- min-height: 1.875rem;
46
- white-space: nowrap;
47
- }
48
-
49
- .breadcrumbs__item:first-child:not(.breadcrumbs__item--back) {
50
- font-family: var(--breadcrumb-font-black);
51
- }
52
-
53
- .breadcrumbs__item--back {
54
- max-width: 100%;
55
- }
56
-
57
- .breadcrumbs__link {
58
- color: inherit;
59
- -webkit-text-decoration: none;
60
- text-decoration: none;
61
- transition: color 0.1s ease;
62
- white-space: nowrap;
63
- }
64
-
65
- .breadcrumbs__item--back .breadcrumbs__link {
66
- overflow: hidden;
67
- text-overflow: ellipsis;
68
- margin-right: 0.25rem;
69
- }
70
-
71
- .menu {
72
- background: none;
73
- color: inherit;
74
- cursor: pointer;
75
- border: 2px solid transparent;
76
- }
77
-
78
- .menu:focus-visible {
79
- outline: 2px solid var(--leu-color-func-cyan);
80
- outline-offset: 2px;
81
- }
82
-
83
- .dropdown {
84
- background-color: var(--leu-color-black-0);
85
- box-shadow: var(--leu-box-shadow-short);
86
- }
87
-
88
- .breadcrumbs {
89
- font-size: 1rem;
90
- }
91
-
92
- @media (min-width: 320px) {
93
- .breadcrumbs {
94
- font-size: calc(2.5vw + 8px);
95
- }
96
- }
97
-
98
- @media (min-width: 400px) {
99
- .breadcrumbs {
100
- font-size: 18px;
101
- }
102
- }
103
-
104
- @media (min-width: 1024px) {
105
- .breadcrumbs {
106
- font-size: calc(0.7813vw + 10px);
107
- }
108
- }
109
-
110
- @media (min-width: 1280px) {
111
- .breadcrumbs {
112
- font-size: 20px;
113
- }
114
- }
115
- `;
116
-
117
- /**
118
- * A Breadcrumb Navigation.
119
- *
120
- * The breadcrumbs can be displayed in two different layouts.
121
- * Only the back link (the last item / parent of the current page)
122
- * is displayed when…
123
- * - … the width of the container is smaller
124
- * than the BACK_ONLY_BREAKPOINT.
125
- * - … less then two breadcrumb items could be displayed
126
- * without overflowing the container.
127
- *
128
- * Otherwise as many items as possible are displayed in an inline list
129
- * without overflowing the container. The remaining items are displayed
130
- * in a dropdown menu.
131
- *
132
- * In order to determine the exact numbers of items that have to be
133
- * hidden inside the dropdown, all of them have to be rendered first.
134
- * 1. Render all items
135
- * 2. Calculate (measure) the number of items that can be displayed
136
- * without overflowing the container.
137
- * 3. Updating the state (_hiddeItems) which will trigger a rerender
138
- * 4. Render the items again with the new state.
139
- *
140
- * This results in multiple updates scheduled one after another. Lit
141
- * will also print a waring in the console beacause of that.
142
- * It's no a nice behaviour but the only one that works without
143
- * having duplicate and hidden markup to derive the sizes from that.
144
- *
145
- *
146
- * @prop {Array} items - Object array with { label, href }
147
- * @prop {boolean} inverted - invert color on dark background
148
- *
149
- * @tagname leu-breadcrumb
150
- */
151
- class LeuBreadcrumb extends LeuElement {
152
- constructor() {
153
- super();
154
- /** @type {Array} */
155
- _defineProperty(this, "_handleResize", async () => {
156
- const containerOffsetWidth = this._containerRef.value.offsetWidth;
157
- const sizeIsGrowing = containerOffsetWidth > this._lastContainerWidth;
158
- this._lastContainerWidth = containerOffsetWidth;
159
-
160
- /**
161
- * Show only the back link (parent of the current page)
162
- * when the width of the container is smaller than the BACK_ONLY_BREAKPOINT
163
- */
164
- if (containerOffsetWidth <= LeuBreadcrumb.BACK_ONLY_BREAKPOINT) {
165
- this._showBackOnly = true;
166
- this._isRecalculating = false;
167
- return;
168
- }
169
- this._showBackOnly = false;
170
-
171
- /**
172
- * In order to calculate how many items can be displayed
173
- * when the container is growing, all items have to
174
- * be marked as displayed (_hiddenItems = 0) and
175
- * rendered.
176
- */
177
- if (sizeIsGrowing && this._hiddenItems > 0) {
178
- this._hiddenItems = 0;
179
- this._isRecalculating = true;
180
- await this.updateComplete;
181
- }
182
- this._checkWidth();
183
- });
184
- /** @internal */
185
- _defineProperty(this, "_handleDropdownToggle", e => {
186
- e.stopPropagation();
187
- this._isDropdownOpen = !this._isDropdownOpen;
188
- if (this._isDropdownOpen) {
189
- window.addEventListener("click", this._closeDropdown);
190
- } else {
191
- window.removeEventListener("click", this._closeDropdown);
192
- }
193
- });
194
- _defineProperty(this, "_closeDropdown", () => {
195
- this._isDropdownOpen = false;
196
- window.removeEventListener("click", this._closeDropdown);
197
- });
198
- this.items = [];
199
- /** @type {boolean} - will be used on dark Background */
200
- this.inverted = false;
201
-
202
- /** @internal */
203
- this._containerRef = createRef();
204
- /** @internal */
205
- this._hiddenItems = 0;
206
- /** @internal */
207
- this._showBackOnly = null;
208
- /** @internal */
209
- this._lastContainerWidth = null;
210
- /**
211
- * @internal
212
- * Forces the toggle button to be rendered
213
- * so that all possible inline items will be measured.
214
- * */
215
- this._isRecalculating = true;
216
- /** @internal */
217
- this._isDropdownOpen = false;
218
- this.resizeObserver = new ResizeObserver(debounce(() => {
219
- this._handleResize();
220
- }, 500));
221
- }
222
- firstUpdated() {
223
- this.resizeObserver.observe(this._containerRef.value);
224
- }
225
- async updated(changedProperties) {
226
- if (changedProperties.has("items")) {
227
- this._hiddenItems = 0;
228
- this._isRecalculating = true;
229
- await this.updateComplete;
230
- this._checkWidth();
231
- }
232
- }
233
- disconnectedCallback() {
234
- super.disconnectedCallback();
235
- window.removeEventListener("click", this._closeDropdown);
236
- this.resizeObserver.disconnect();
237
- }
238
-
239
- /** @internal */
240
- get _listItems() {
241
- return this.items.toSpliced(1, this._hiddenItems);
242
- }
243
-
244
- /** @internal */
245
- get _dropdownItems() {
246
- return this.items.slice(1, 1 + this._hiddenItems);
247
- }
248
- /**
249
- * Calculate the number of items that can be displayed
250
- * without overflowing the container.
251
- * @internal
252
- * @returns {void}
253
- */
254
- _checkWidth() {
255
- const containerOffsetWidth = this._containerRef.value.offsetWidth;
256
- const containerScrollWidth = this._containerRef.value.scrollWidth;
257
- this._lastContainerWidth = containerOffsetWidth;
258
-
259
- /** When the container is not overflowing, nothing has to be done */
260
- if (containerOffsetWidth === containerScrollWidth) {
261
- this._isRecalculating = false;
262
- return;
263
- }
264
- const listItems = this._containerRef.value.querySelectorAll("li:not([data-dropdown-toggle])");
265
- const listItemWidths = [...listItems].map(o => o.offsetWidth);
266
- let hiddenItems = 0;
267
- let hiddenItemsWidth = 0;
268
-
269
- /**
270
- * Remove item by item until the sum of the remaining items
271
- * is smaller than the width of the container.
272
- * The first item will not be removed.
273
- */
274
- while (hiddenItems < listItemWidths.length && containerOffsetWidth < containerScrollWidth - hiddenItemsWidth) {
275
- hiddenItems += 1;
276
- hiddenItemsWidth = listItemWidths.slice(1, 1 + hiddenItems).reduce((sum, itemWidth) => sum + itemWidth, 0);
277
- }
278
- this._hiddenItems += hiddenItems;
279
- this._isRecalculating = false;
280
- }
281
- /**
282
- * Render the dropdown menu
283
- * @returns
284
- */
285
- renderDropdown() {
286
- if (this._dropdownItems.length === 0 && !this._isRecalculating) return nothing;
287
- return html`
288
- <li class="breadcrumbs__item" data-dropdown-toggle>
289
- <span class="breadcrumbs__icon"
290
- ><leu-icon name="angleRight"></leu-icon
291
- ></span>
292
- <leu-popup
293
- ?active=${this._isDropdownOpen}
294
- placement="bottom-start"
295
- shift
296
- shiftPadding="8"
297
- autoSize="width"
298
- autoSizePadding="8"
299
- >
300
- <button
301
- slot="anchor"
302
- class="menu"
303
- @click=${this._handleDropdownToggle}
304
- tabindex="0"
305
- >
306
- &hellip;
307
- </button>
308
- <div class="dropdown">
309
- ${html`
310
- <leu-menu>
311
- ${this._dropdownItems.map(item => html`
312
- <leu-menu-item href=${item.href}
313
- >${item.label}</leu-menu-item
314
- >
315
- `)}
316
- </leu-menu>
317
- `}
318
- </div>
319
- </leu-popup>
320
- </li>
321
- `;
322
- }
323
- render() {
324
- if (this.items.length < 2) return nothing;
325
- const parentItem = this.items[this.items.length - 2];
326
- const showBackOnly = this._showBackOnly || this.items.length - this._hiddenItems < 2;
327
- const wrapperClasses = {
328
- breadcrumbs: true,
329
- "breadcrumbs--back-only": showBackOnly
330
- };
331
- return html`
332
- <nav class=${classMap(wrapperClasses)}>
333
- <leu-visually-hidden><h2>Sie sind hier:</h2></leu-visually-hidden>
334
- <ol class="breadcrumbs__list" ref=${ref(this._containerRef)}>
335
- ${showBackOnly ? html` <li class="breadcrumbs__item breadcrumbs__item--back">
336
- <span class="breadcrumbs__icon"
337
- ><leu-icon name="arrowLeft"></leu-icon
338
- ></span>
339
- <a class="breadcrumbs__link" href=${parentItem.href}
340
- >${parentItem.label}</a
341
- >
342
- </li>` : this._listItems.map((item, index, list) => html`
343
- <li class="breadcrumbs__item">
344
- ${index > 0 ? html`<span class="breadcrumbs__icon"
345
- ><leu-icon name="angleRight"></leu-icon
346
- ></span>` // First list item doesn't have an arrow
347
- : nothing}
348
- ${index === list.length - 1 ? item.label // Last list item doesn't contain a link
349
- : html`<a class="breadcrumbs__link" href=${item.href}
350
- >${item.label}</a
351
- >`}
352
- </li>
353
- ${index === 0 ? this.renderDropdown() : nothing}
354
- `)}
355
- </ol>
356
- </nav>
357
- `;
358
- }
359
- }
360
- _defineProperty(LeuBreadcrumb, "dependencies", {
361
- "leu-icon": LeuIcon,
362
- "leu-menu": LeuMenu,
363
- "leu-menu-item": LeuMenuItem,
364
- "leu-popup": LeuPopup,
365
- "leu-visually-hidden": LeuVisuallyHidden
366
- });
367
- _defineProperty(LeuBreadcrumb, "styles", [LeuElement.styles, css_248z]);
368
- _defineProperty(LeuBreadcrumb, "properties", {
369
- items: {
370
- type: Array
371
- },
372
- inverted: {
373
- type: Boolean,
374
- reflect: true
375
- },
376
- _hiddenItems: {
377
- state: true
378
- },
379
- _showBackOnly: {
380
- state: true
381
- },
382
- _isRecalculating: {
383
- state: true
384
- },
385
- _isDropdownOpen: {
386
- state: true
387
- }
388
- });
389
- _defineProperty(LeuBreadcrumb, "BACK_ONLY_BREAKPOINT", 320);
390
-
391
- export { LeuBreadcrumb };
@@ -1 +0,0 @@
1
- {"version":3,"file":"LeuElement-b670d77c.d.ts","sourceRoot":"","sources":["LeuElement-b670d77c.js"],"names":[],"mappings":"AAgDA;IACE,8EAcC;CACF;AA9DD,sEAaC;2BAf+B,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"hasSlotController-c09741c5.d.ts","sourceRoot":"","sources":["hasSlotController-c09741c5.js"],"names":[],"mappings":";;;;iCASa,OAAO,KAAK,EAAE,kBAAkB;AAP7C;;;GAGG;AAEH;;;;GAIG;AACH;IACE,uCAcC;IAHC,UAAgB;IAEhB,eAA0B;IAG5B;;;OAGG;IACH,uBAeC;IAED;;;;OAIG;IACH,qBAEC;IAED;;;OAGG;IACH,gCAEC;IACD,sBAEC;IACD,yBAEC;CACF"}
@@ -1,3 +0,0 @@
1
- export { LeuBreadcrumb };
2
- import { LeuBreadcrumb } from './Breadcrumb.js';
3
- //# sourceMappingURL=leu-breadcrumb.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"leu-breadcrumb.d.ts","sourceRoot":"","sources":["leu-breadcrumb.js"],"names":[],"mappings":";8BAA8B,iBAAiB"}