@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.
- package/.eslintrc.json +8 -0
- package/.github/workflows/ci.yml +78 -0
- package/.github/workflows/deploy-github-pages.yaml +2 -1
- package/.github/workflows/release-please.yml +2 -1
- package/.nvmrc +1 -0
- package/.prettierignore +1 -0
- package/.storybook/main.js +19 -3
- package/CHANGELOG.md +16 -0
- package/custom-elements-manifest.config.js +2 -2
- package/dist/Accordion.d.ts +1 -1
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +2 -4
- package/dist/Button.d.ts +2 -2
- package/dist/Button.js +2 -2
- package/dist/ButtonGroup.d.ts +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +2 -3
- package/dist/CheckboxGroup.d.ts +1 -1
- package/dist/CheckboxGroup.d.ts.map +1 -1
- package/dist/CheckboxGroup.js +1 -3
- package/dist/Chip.d.ts +1 -1
- package/dist/Chip.d.ts.map +1 -1
- package/dist/Chip.js +1 -3
- package/dist/ChipGroup.d.ts +1 -1
- package/dist/ChipGroup.d.ts.map +1 -1
- package/dist/ChipGroup.js +2 -2
- package/dist/ChipLink.js +1 -1
- package/dist/ChipRemovable.js +1 -1
- package/dist/ChipSelectable.js +1 -1
- package/dist/Dialog.d.ts +1 -1
- package/dist/Dialog.d.ts.map +1 -1
- package/dist/Dialog.js +3 -5
- package/dist/Dropdown.d.ts +1 -1
- package/dist/Dropdown.js +3 -3
- package/dist/Icon.d.ts +2 -98
- package/dist/Icon.d.ts.map +1 -1
- package/dist/Icon.js +1 -1
- package/dist/Input.d.ts +7 -2
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +15 -8
- package/dist/{LeuElement-b670d77c.d.ts → LeuElement-BjGpKQpe.d.ts} +1 -1
- package/dist/LeuElement-BjGpKQpe.d.ts.map +1 -0
- package/dist/{LeuElement-b670d77c.js → LeuElement-BjGpKQpe.js} +2 -2
- package/dist/Menu.d.ts +2 -2
- package/dist/Menu.js +1 -1
- package/dist/MenuItem.d.ts +3 -3
- package/dist/MenuItem.js +1 -1
- package/dist/Pagination.d.ts +1 -1
- package/dist/Pagination.js +3 -3
- package/dist/Popup.d.ts +2 -2
- package/dist/Popup.d.ts.map +1 -1
- package/dist/Popup.js +1 -3
- package/dist/Radio.d.ts +1 -1
- package/dist/Radio.d.ts.map +1 -1
- package/dist/Radio.js +1 -3
- package/dist/RadioGroup.d.ts +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +1 -3
- package/dist/Range.d.ts +1 -1
- package/dist/Range.d.ts.map +1 -1
- package/dist/Range.js +17 -19
- package/dist/ScrollTop.d.ts +1 -1
- package/dist/ScrollTop.d.ts.map +1 -1
- package/dist/ScrollTop.js +27 -3
- package/dist/Select.d.ts +3 -3
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +6 -4
- package/dist/Spinner.d.ts +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Table.d.ts +1 -1
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +3 -4
- package/dist/VisuallyHidden.d.ts +1 -1
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +3 -5
- package/dist/{hasSlotController-c09741c5.d.ts → hasSlotController-DvFw2NdC.d.ts} +1 -1
- package/dist/hasSlotController-DvFw2NdC.d.ts.map +1 -0
- package/dist/{hasSlotController-c09741c5.js → hasSlotController-DvFw2NdC.js} +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +5 -7
- package/dist/leu-accordion.js +1 -1
- package/dist/leu-button-group.js +1 -1
- package/dist/leu-button.js +2 -2
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.js +1 -1
- package/dist/leu-chip-group.js +1 -1
- package/dist/leu-chip-link.js +1 -1
- package/dist/leu-chip-removable.js +1 -1
- package/dist/leu-chip-selectable.js +1 -1
- package/dist/leu-dialog.js +2 -2
- package/dist/leu-dropdown.js +2 -2
- package/dist/leu-icon.js +1 -1
- package/dist/leu-input.js +1 -1
- package/dist/leu-menu-item.js +1 -1
- package/dist/leu-menu.js +1 -1
- package/dist/leu-pagination.js +2 -2
- package/dist/leu-popup.js +1 -1
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.js +1 -1
- package/dist/leu-range.js +1 -1
- package/dist/leu-scroll-top.js +2 -3
- package/dist/leu-select.js +2 -2
- package/dist/leu-spinner.js +1 -1
- package/dist/leu-table.js +2 -2
- package/dist/leu-visually-hidden.js +1 -1
- package/dist/theme.css +143 -107
- package/dist/vscode.html-custom-data.json +3 -32
- package/dist/vue/index.d.ts +11 -77
- package/dist/web-types.json +246 -242
- package/index.js +0 -1
- package/package.json +55 -51
- package/rollup.config.js +3 -3
- package/scripts/generate-component/generate.js +5 -5
- package/src/components/accordion/test/accordion.test.js +24 -20
- package/src/components/button/Button.js +1 -1
- package/src/components/button/stories/button.stories.js +43 -45
- package/src/components/button/test/button.test.js +10 -10
- package/src/components/button-group/ButtonGroup.js +1 -1
- package/src/components/button-group/stories/button-group.stories.js +2 -2
- package/src/components/checkbox/checkbox.css +1 -0
- package/src/components/chip/ChipSelectable.js +1 -1
- package/src/components/chip/stories/chip-group.stories.js +4 -4
- package/src/components/chip/test/chip-group.test.js +25 -33
- package/src/components/chip/test/chip-link.test.js +5 -5
- package/src/components/chip/test/chip-removable.test.js +6 -8
- package/src/components/chip/test/chip-selectable.test.js +9 -11
- package/src/components/dialog/test/dialog.test.js +1 -1
- package/src/components/dropdown/test/dropdown.test.js +12 -13
- package/src/components/input/Input.js +25 -17
- package/src/components/input/stories/input.stories.js +0 -2
- package/src/components/input/test/input.test.js +26 -0
- package/src/components/menu/stories/menu-item.stories.js +2 -0
- package/src/components/menu/test/menu-item.test.js +3 -2
- package/src/components/menu/test/menu.test.js +24 -22
- package/src/components/pagination/Pagination.js +1 -1
- package/src/components/pagination/pagination.css +1 -1
- package/src/components/pagination/stories/pagination.stories.js +2 -1
- package/src/components/pagination/test/pagination.test.js +8 -6
- package/src/components/popup/Popup.js +4 -4
- package/src/components/popup/test/popup.test.js +6 -8
- package/src/components/radio/RadioGroup.js +2 -2
- package/src/components/range/Range.js +20 -21
- package/src/components/select/Select.js +6 -1
- package/src/components/select/stories/select.stories.js +1 -1
- package/src/components/select/test/select.test.js +18 -16
- package/src/components/table/Table.js +4 -4
- package/src/components/table/test/table.test.js +3 -2
- package/src/components/visually-hidden/test/visually-hidden.test.js +6 -8
- package/src/lib/LeuElement.js +2 -2
- package/src/lib/hasSlotController.js +1 -1
- package/src/styles/style.stories.js +3 -1
- package/tsconfig.build.json +4 -3
- package/web-dev-server.config.mjs +1 -0
- package/web-test-runner.config.mjs +1 -1
- package/.github/workflows/test.yml +0 -38
- package/.storybook/preview-head.html +0 -2
- package/dist/Breadcrumb.d.ts +0 -69
- package/dist/Breadcrumb.d.ts.map +0 -1
- package/dist/Breadcrumb.js +0 -391
- package/dist/LeuElement-b670d77c.d.ts.map +0 -1
- package/dist/hasSlotController-c09741c5.d.ts.map +0 -1
- package/dist/leu-breadcrumb.d.ts +0 -3
- package/dist/leu-breadcrumb.d.ts.map +0 -1
- package/dist/leu-breadcrumb.js +0 -17
- package/dist/utils-65469421.d.ts +0 -16
- package/dist/utils-65469421.d.ts.map +0 -1
- package/dist/utils-65469421.js +0 -35
- package/src/components/breadcrumb/Breadcrumb.js +0 -324
- package/src/components/breadcrumb/breadcrumb.css +0 -98
- package/src/components/breadcrumb/leu-breadcrumb.js +0 -5
- package/src/components/breadcrumb/stories/breadcrumb.stories.js +0 -73
- package/src/components/breadcrumb/test/breadcrumb.test.js +0 -141
|
@@ -4,9 +4,9 @@ import { fixture, expect } from "@open-wc/testing"
|
|
|
4
4
|
import "../leu-chip-link.js"
|
|
5
5
|
|
|
6
6
|
async function defaultFixture() {
|
|
7
|
-
return fixture(
|
|
8
|
-
|
|
9
|
-
)
|
|
7
|
+
return fixture(html`
|
|
8
|
+
<leu-chip-link href="https://zh.ch/daten">Daten</leu-chip-link>
|
|
9
|
+
`)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
describe("LeuChipLink", () => {
|
|
@@ -38,7 +38,7 @@ describe("LeuChipLink", () => {
|
|
|
38
38
|
const el = await defaultFixture()
|
|
39
39
|
|
|
40
40
|
expect(el.shadowRoot.querySelector("a").getAttribute("href")).to.equal(
|
|
41
|
-
"https://zh.ch/daten"
|
|
41
|
+
"https://zh.ch/daten",
|
|
42
42
|
)
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ describe("LeuChipLink", () => {
|
|
|
48
48
|
el.focus()
|
|
49
49
|
|
|
50
50
|
expect(el.shadowRoot.querySelector("a")).to.equal(
|
|
51
|
-
el.shadowRoot.activeElement
|
|
51
|
+
el.shadowRoot.activeElement,
|
|
52
52
|
)
|
|
53
53
|
})
|
|
54
54
|
})
|
|
@@ -6,13 +6,11 @@ import { ifDefined } from "lit/directives/if-defined.js"
|
|
|
6
6
|
import "../leu-chip-removable.js"
|
|
7
7
|
|
|
8
8
|
async function defaultFixture(args = {}) {
|
|
9
|
-
return fixture(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`
|
|
15
|
-
)
|
|
9
|
+
return fixture(html`
|
|
10
|
+
<leu-chip-removable value=${ifDefined(args.value)}
|
|
11
|
+
>${args.label ?? "Daten"}</leu-chip-removable
|
|
12
|
+
>
|
|
13
|
+
`)
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
describe("LeuChipRemovable", () => {
|
|
@@ -54,7 +52,7 @@ describe("LeuChipRemovable", () => {
|
|
|
54
52
|
el.focus()
|
|
55
53
|
|
|
56
54
|
expect(el.shadowRoot.querySelector("button")).to.equal(
|
|
57
|
-
el.shadowRoot.activeElement
|
|
55
|
+
el.shadowRoot.activeElement,
|
|
58
56
|
)
|
|
59
57
|
})
|
|
60
58
|
|
|
@@ -6,16 +6,14 @@ import { sendKeys } from "@web/test-runner-commands"
|
|
|
6
6
|
import "../leu-chip-selectable.js"
|
|
7
7
|
|
|
8
8
|
async function defaultFixture(args = {}) {
|
|
9
|
-
return fixture(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`
|
|
18
|
-
)
|
|
9
|
+
return fixture(html`
|
|
10
|
+
<leu-chip-selectable
|
|
11
|
+
value=${ifDefined(args.value)}
|
|
12
|
+
variant=${ifDefined(args.variant)}
|
|
13
|
+
?checked=${args.checked}
|
|
14
|
+
>Publikationen</leu-chip-selectable
|
|
15
|
+
>
|
|
16
|
+
`)
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
describe("LeuChipSelectable", () => {
|
|
@@ -49,7 +47,7 @@ describe("LeuChipSelectable", () => {
|
|
|
49
47
|
el.focus()
|
|
50
48
|
|
|
51
49
|
expect(el.shadowRoot.querySelector("button")).to.equal(
|
|
52
|
-
el.shadowRoot.activeElement
|
|
50
|
+
el.shadowRoot.activeElement,
|
|
53
51
|
)
|
|
54
52
|
})
|
|
55
53
|
|
|
@@ -4,19 +4,18 @@ import { fixture, expect, elementUpdated } from "@open-wc/testing"
|
|
|
4
4
|
import "../leu-dropdown.js"
|
|
5
5
|
|
|
6
6
|
async function defaultFixture(args = { expanded: false }) {
|
|
7
|
-
return fixture(
|
|
8
|
-
label="Download"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</leu-dropdown>`)
|
|
7
|
+
return fixture(
|
|
8
|
+
html` <leu-dropdown label="Download" ?expanded=${args.expanded}>
|
|
9
|
+
<leu-menu>
|
|
10
|
+
<leu-menu-item>Als CSV Tabelle</leu-menu-item>
|
|
11
|
+
<leu-menu-item>Als XLS Tabelle</leu-menu-item>
|
|
12
|
+
<hr />
|
|
13
|
+
<leu-menu-item>Als PNG exportieren</leu-menu-item>
|
|
14
|
+
<leu-menu-item>Als SVG exportieren</leu-menu-item>
|
|
15
|
+
<leu-menu-item>Als PDF exportieren</leu-menu-item>
|
|
16
|
+
</leu-menu>
|
|
17
|
+
</leu-dropdown>`,
|
|
18
|
+
)
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
describe("LeuDropdown", () => {
|
|
@@ -244,10 +244,10 @@ export class LeuInput extends LeuElement {
|
|
|
244
244
|
this._inputRef.value.focus()
|
|
245
245
|
|
|
246
246
|
this.dispatchEvent(
|
|
247
|
-
new CustomEvent("input", { bubbles: true, composed: true })
|
|
247
|
+
new CustomEvent("input", { bubbles: true, composed: true }),
|
|
248
248
|
)
|
|
249
249
|
this.dispatchEvent(
|
|
250
|
-
new CustomEvent("change", { bubbles: true, composed: true })
|
|
250
|
+
new CustomEvent("change", { bubbles: true, composed: true }),
|
|
251
251
|
)
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -296,24 +296,42 @@ export class LeuInput extends LeuElement {
|
|
|
296
296
|
|
|
297
297
|
validationMessages.tooLong = LeuInput.resolveErrorMessage(
|
|
298
298
|
tooLong,
|
|
299
|
-
this.maxlength
|
|
299
|
+
this.maxlength,
|
|
300
300
|
)
|
|
301
301
|
validationMessages.tooShort = LeuInput.resolveErrorMessage(
|
|
302
302
|
tooShort,
|
|
303
|
-
this.minlength
|
|
303
|
+
this.minlength,
|
|
304
304
|
)
|
|
305
305
|
validationMessages.rangeOverflow = LeuInput.resolveErrorMessage(
|
|
306
306
|
rangeOverflow,
|
|
307
|
-
this.max
|
|
307
|
+
this.max,
|
|
308
308
|
)
|
|
309
309
|
validationMessages.rangeUnderflow = LeuInput.resolveErrorMessage(
|
|
310
310
|
rangeUnderflow,
|
|
311
|
-
this.min
|
|
311
|
+
this.min,
|
|
312
312
|
)
|
|
313
313
|
|
|
314
314
|
return validationMessages
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
+
isInvalid() {
|
|
318
|
+
if (this.error) {
|
|
319
|
+
return true
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return this._validity === null || this.novalidate
|
|
323
|
+
? false
|
|
324
|
+
: !this._validity.valid
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Check input validation
|
|
329
|
+
* @returns {boolean} if valid or not
|
|
330
|
+
*/
|
|
331
|
+
checkValidity() {
|
|
332
|
+
return this._inputRef.value?.checkValidity() ?? false
|
|
333
|
+
}
|
|
334
|
+
|
|
317
335
|
/**
|
|
318
336
|
* Creates an error list with an item for the given validity state.
|
|
319
337
|
* @returns {import("lit").TemplateResult | nothing}
|
|
@@ -337,7 +355,7 @@ export class LeuInput extends LeuElement {
|
|
|
337
355
|
return html`
|
|
338
356
|
<ul class="error" aria-errormessage=${`input-${this.getId()}`}>
|
|
339
357
|
${errorMessages.map(
|
|
340
|
-
(message) => html`<li class="error-message">${message}</li
|
|
358
|
+
(message) => html`<li class="error-message">${message}</li>`,
|
|
341
359
|
)}
|
|
342
360
|
</ul>
|
|
343
361
|
`
|
|
@@ -377,16 +395,6 @@ export class LeuInput extends LeuElement {
|
|
|
377
395
|
return nothing
|
|
378
396
|
}
|
|
379
397
|
|
|
380
|
-
isInvalid() {
|
|
381
|
-
if (this.error) {
|
|
382
|
-
return true
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
return this._validity === null || this.novalidate
|
|
386
|
-
? false
|
|
387
|
-
: !this._validity.valid
|
|
388
|
-
}
|
|
389
|
-
|
|
390
398
|
render() {
|
|
391
399
|
const isInvalid = this.isInvalid()
|
|
392
400
|
|
|
@@ -469,4 +469,30 @@ describe("LeuInput", () => {
|
|
|
469
469
|
|
|
470
470
|
expect(el.valueAsNumber).to.be.NaN
|
|
471
471
|
})
|
|
472
|
+
|
|
473
|
+
it("check input is valid", async () => {
|
|
474
|
+
{
|
|
475
|
+
const el = await defaultFixture({ label: "Länge", type: "number" })
|
|
476
|
+
el.focus()
|
|
477
|
+
|
|
478
|
+
await sendKeys({ type: "text" })
|
|
479
|
+
expect(el.checkValidity()).to.be.false
|
|
480
|
+
|
|
481
|
+
await elementUpdated(el)
|
|
482
|
+
const error = el.shadowRoot.querySelector(".error")
|
|
483
|
+
expect(error).not.to.be.null
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
{
|
|
487
|
+
const el = await defaultFixture({ label: "Länge", type: "number" })
|
|
488
|
+
el.focus()
|
|
489
|
+
|
|
490
|
+
await sendKeys({ type: "123" })
|
|
491
|
+
expect(el.checkValidity()).to.be.true
|
|
492
|
+
|
|
493
|
+
await elementUpdated(el)
|
|
494
|
+
const error = el.shadowRoot.querySelector(".error")
|
|
495
|
+
expect(error).to.be.null
|
|
496
|
+
}
|
|
497
|
+
})
|
|
472
498
|
})
|
|
@@ -23,6 +23,7 @@ export default {
|
|
|
23
23
|
},
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/* eslint-disable no-nested-ternary */
|
|
26
27
|
function Template(args) {
|
|
27
28
|
return html`
|
|
28
29
|
<leu-menu-item
|
|
@@ -45,6 +46,7 @@ function Template(args) {
|
|
|
45
46
|
</leu-menu-item>
|
|
46
47
|
`
|
|
47
48
|
}
|
|
49
|
+
/* eslint-enable no-nested-ternary */
|
|
48
50
|
|
|
49
51
|
export const Regular = Template.bind({})
|
|
50
52
|
|
|
@@ -185,7 +185,7 @@ describe("LeuMenuItem", () => {
|
|
|
185
185
|
expect(el.getValue()).to.equal("download-01")
|
|
186
186
|
})
|
|
187
187
|
|
|
188
|
-
it("renders a
|
|
188
|
+
it("renders a placeholder icon when the menu item is part of multiple selection but not active", async () => {
|
|
189
189
|
const el = await defaultFixture({
|
|
190
190
|
label: "Download",
|
|
191
191
|
multipleSelection: true,
|
|
@@ -193,13 +193,14 @@ describe("LeuMenuItem", () => {
|
|
|
193
193
|
|
|
194
194
|
const icon = el.shadowRoot.querySelector("leu-icon")
|
|
195
195
|
expect(icon).to.exist
|
|
196
|
-
expect(icon).to.have.attribute("name", "
|
|
196
|
+
expect(icon).to.have.attribute("name", "")
|
|
197
197
|
})
|
|
198
198
|
|
|
199
199
|
it("renders a check icon when the menu item is part of multiple selection and is active", async () => {
|
|
200
200
|
const el = await defaultFixture({
|
|
201
201
|
label: "Download",
|
|
202
202
|
multipleSelection: true,
|
|
203
|
+
active: true,
|
|
203
204
|
})
|
|
204
205
|
|
|
205
206
|
const icon = el.shadowRoot.querySelector("leu-icon")
|
|
@@ -8,29 +8,31 @@ import "../leu-menu-item.js"
|
|
|
8
8
|
import "../../icon/leu-icon.js"
|
|
9
9
|
|
|
10
10
|
async function defaultFixture(args = {}) {
|
|
11
|
-
return fixture(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<leu-menu-item
|
|
16
|
-
><leu-icon slot="before"></leu-icon>Menu Item 1</leu-menu-item
|
|
11
|
+
return fixture(
|
|
12
|
+
html` <leu-menu
|
|
13
|
+
role=${ifDefined(args.role)}
|
|
14
|
+
selects=${ifDefined(args.selects)}
|
|
17
15
|
>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
<leu-menu-item
|
|
17
|
+
><leu-icon slot="before"></leu-icon>Menu Item 1</leu-menu-item
|
|
18
|
+
>
|
|
19
|
+
<leu-menu-item active
|
|
20
|
+
><leu-icon slot="before" name="check"></leu-icon>Menu Item
|
|
21
|
+
2</leu-menu-item
|
|
22
|
+
>
|
|
23
|
+
<leu-menu-item
|
|
24
|
+
><leu-icon slot="before"></leu-icon>Menu Item 3</leu-menu-item
|
|
25
|
+
>
|
|
26
|
+
<hr />
|
|
27
|
+
<leu-menu-item
|
|
28
|
+
><leu-icon name="pin" slot="before"></leu-icon>Menu Item 3<slot
|
|
29
|
+
name="after"
|
|
30
|
+
>CH</slot
|
|
31
|
+
></leu-menu-item
|
|
32
|
+
>
|
|
33
|
+
<leu-menu-item>Menu Item 4</leu-menu-item>
|
|
34
|
+
</leu-menu>`,
|
|
35
|
+
)
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
describe("LeuMenu", () => {
|
|
@@ -6,6 +6,7 @@ import "../leu-pagination.js"
|
|
|
6
6
|
// https://stackoverflow.com/questions/72566428/storybook-angular-how-to-dynamically-update-args-from-the-template
|
|
7
7
|
import { UPDATE_STORY_ARGS } from "@storybook/core-events" // eslint-disable-line
|
|
8
8
|
import { ifDefined } from "lit/directives/if-defined.js"
|
|
9
|
+
|
|
9
10
|
function updateStorybookArgss(id, args) {
|
|
10
11
|
const channel = window.__STORYBOOK_ADDONS_CHANNEL__
|
|
11
12
|
channel.emit(UPDATE_STORY_ARGS, {
|
|
@@ -72,7 +73,7 @@ export default {
|
|
|
72
73
|
|
|
73
74
|
function Template(
|
|
74
75
|
{ startIndex, endIndex, onPageChange, itemsPerPage, defaultPage },
|
|
75
|
-
{ id }
|
|
76
|
+
{ id },
|
|
76
77
|
) {
|
|
77
78
|
return html`
|
|
78
79
|
${items
|
|
@@ -7,12 +7,14 @@ import { spy } from "sinon"
|
|
|
7
7
|
import "../leu-pagination.js"
|
|
8
8
|
|
|
9
9
|
async function defaultFixture(args = {}) {
|
|
10
|
-
return fixture(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
return fixture(
|
|
11
|
+
html`<leu-pagination
|
|
12
|
+
numOfItems=${ifDefined(args.numOfItems)}
|
|
13
|
+
itemsPerPage=${ifDefined(args.itemsPerPage)}
|
|
14
|
+
defaultPage=${ifDefined(args.defaultPage)}
|
|
15
|
+
>
|
|
16
|
+
</leu-pagination>`,
|
|
17
|
+
)
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
describe("LeuPagination", () => {
|
|
@@ -130,7 +130,7 @@ export class LeuPopup extends LeuElement {
|
|
|
130
130
|
? `${rects.reference.height}px`
|
|
131
131
|
: ""
|
|
132
132
|
},
|
|
133
|
-
})
|
|
133
|
+
}),
|
|
134
134
|
)
|
|
135
135
|
} else {
|
|
136
136
|
// Cleanup styles if we're not matching width/height
|
|
@@ -159,7 +159,7 @@ export class LeuPopup extends LeuElement {
|
|
|
159
159
|
if (setMaxHeight) {
|
|
160
160
|
this.style.setProperty(
|
|
161
161
|
"--auto-size-available-height",
|
|
162
|
-
`${availableHeight}px
|
|
162
|
+
`${availableHeight}px`,
|
|
163
163
|
)
|
|
164
164
|
} else {
|
|
165
165
|
this.style.removeProperty("--auto-size-available-height")
|
|
@@ -168,13 +168,13 @@ export class LeuPopup extends LeuElement {
|
|
|
168
168
|
if (setMaxWidth) {
|
|
169
169
|
this.style.setProperty(
|
|
170
170
|
"--auto-size-available-width",
|
|
171
|
-
`${availableWidth}px
|
|
171
|
+
`${availableWidth}px`,
|
|
172
172
|
)
|
|
173
173
|
} else {
|
|
174
174
|
this.style.removeProperty("--auto-size-available-width")
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
|
-
})
|
|
177
|
+
}),
|
|
178
178
|
)
|
|
179
179
|
} else {
|
|
180
180
|
// Cleanup styles if we're not auto-sizing
|
|
@@ -4,14 +4,12 @@ import { fixture, expect } from "@open-wc/testing"
|
|
|
4
4
|
import "../leu-popup.js"
|
|
5
5
|
|
|
6
6
|
async function defaultFixture() {
|
|
7
|
-
return fixture(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`
|
|
14
|
-
)
|
|
7
|
+
return fixture(html`
|
|
8
|
+
<leu-popup
|
|
9
|
+
><div slot="anchor"></div>
|
|
10
|
+
<p>Popup content</p></leu-popup
|
|
11
|
+
>
|
|
12
|
+
`)
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
describe("LeuPopup", () => {
|
|
@@ -143,10 +143,10 @@ export class LeuRadioGroup extends LeuElement {
|
|
|
143
143
|
|
|
144
144
|
initializeIndex() {
|
|
145
145
|
const index = this.items.findIndex(
|
|
146
|
-
(item) => item.hasAttribute("checked") && !item.hasAttribute("disabled")
|
|
146
|
+
(item) => item.hasAttribute("checked") && !item.hasAttribute("disabled"),
|
|
147
147
|
)
|
|
148
148
|
const nextEnabledIndex = this.items.findIndex(
|
|
149
|
-
(item) => !item.hasAttribute("disabled")
|
|
149
|
+
(item) => !item.hasAttribute("disabled"),
|
|
150
150
|
)
|
|
151
151
|
|
|
152
152
|
this._currentIndex = index >= 0 ? index : nextEnabledIndex
|
|
@@ -96,7 +96,7 @@ export class LeuRange extends LeuElement {
|
|
|
96
96
|
|
|
97
97
|
get valueAsArray() {
|
|
98
98
|
return Array.from(this.shadowRoot.querySelectorAll("input")).map(
|
|
99
|
-
(input) => input.valueAsNumber
|
|
99
|
+
(input) => input.valueAsNumber,
|
|
100
100
|
)
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -205,30 +205,29 @@ export class LeuRange extends LeuElement {
|
|
|
205
205
|
class="output"
|
|
206
206
|
for="input-${type}"
|
|
207
207
|
value=${defaultValue[index]}
|
|
208
|
-
></output
|
|
208
|
+
></output>`,
|
|
209
209
|
)}
|
|
210
210
|
</div>
|
|
211
211
|
<div class="inputs">
|
|
212
212
|
${inputs.map(
|
|
213
|
-
(type, index) =>
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
`
|
|
213
|
+
(type, index) => html`
|
|
214
|
+
<input
|
|
215
|
+
@input=${(e) => this._handleInput(index, e)}
|
|
216
|
+
@pointerdown=${multiple && !disabled && index === 0
|
|
217
|
+
? this._handlePointerDown
|
|
218
|
+
: undefined}
|
|
219
|
+
type="range"
|
|
220
|
+
class="range range--${type}"
|
|
221
|
+
id="input-${type}"
|
|
222
|
+
name=${this.name}
|
|
223
|
+
min=${this.min}
|
|
224
|
+
max=${this.max}
|
|
225
|
+
step=${this.step}
|
|
226
|
+
aria-label=${multiple ? RANGE_LABELS[index] : undefined}
|
|
227
|
+
?disabled=${disabled}
|
|
228
|
+
.value=${defaultValue[index].toString()}
|
|
229
|
+
/>
|
|
230
|
+
`,
|
|
232
231
|
)}
|
|
233
232
|
</div>
|
|
234
233
|
</div>
|
|
@@ -171,6 +171,10 @@ export class LeuSelect extends LeuElement {
|
|
|
171
171
|
const menuItems = menu.getMenuItems()
|
|
172
172
|
let hasFilterResults = false
|
|
173
173
|
|
|
174
|
+
if (changed.value && this.value.length === 0) {
|
|
175
|
+
this._displayValue = ""
|
|
176
|
+
}
|
|
177
|
+
|
|
174
178
|
/* eslint-disable no-param-reassign */
|
|
175
179
|
menuItems.forEach((menuItem) => {
|
|
176
180
|
if (changed.multiple) {
|
|
@@ -474,10 +478,11 @@ export class LeuSelect extends LeuElement {
|
|
|
474
478
|
ref=${ref(this._menuRef)}
|
|
475
479
|
role="listbox"
|
|
476
480
|
aria-multiselectable=${ifDefined(
|
|
477
|
-
this.multiple ? "true" : undefined
|
|
481
|
+
this.multiple ? "true" : undefined,
|
|
478
482
|
)}
|
|
479
483
|
class="menu"
|
|
480
484
|
@click=${this._handleMenuItemClick}
|
|
485
|
+
aria-labelledby="select-label"
|
|
481
486
|
>
|
|
482
487
|
<slot></slot>
|
|
483
488
|
</leu-menu>
|
|
@@ -8,16 +8,18 @@ import "../../menu/leu-menu-item.js"
|
|
|
8
8
|
import { MUNICIPALITIES } from "./fixtures.js"
|
|
9
9
|
|
|
10
10
|
async function defaultFixture(args = {}) {
|
|
11
|
-
return fixture(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
return fixture(
|
|
12
|
+
html`<leu-select
|
|
13
|
+
label=${ifDefined(args.label)}
|
|
14
|
+
.value=${args.value ?? []}
|
|
15
|
+
?clearable=${args.clearable}
|
|
16
|
+
?disabled=${args.disabled}
|
|
17
|
+
?filterable=${args.filterable}
|
|
18
|
+
?multiple=${args.multiple}
|
|
19
|
+
>
|
|
20
|
+
${args.options.map((o) => html`<leu-menu-item>${o}</leu-menu-item>`)}
|
|
21
|
+
</leu-select> `,
|
|
22
|
+
)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
describe("LeuSelect", () => {
|
|
@@ -114,7 +116,7 @@ describe("LeuSelect", () => {
|
|
|
114
116
|
const menuItems = Array.from(el.querySelectorAll("leu-menu-item"))
|
|
115
117
|
|
|
116
118
|
const menuItem = menuItems.find(
|
|
117
|
-
(item) => item.textContent === "Affoltern am Albis"
|
|
119
|
+
(item) => item.textContent === "Affoltern am Albis",
|
|
118
120
|
)
|
|
119
121
|
|
|
120
122
|
expect(menuItem).to.have.attribute("active")
|
|
@@ -204,7 +206,7 @@ describe("LeuSelect", () => {
|
|
|
204
206
|
|
|
205
207
|
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
206
208
|
const visibleMenuItems = Array.from(menuItems).filter(
|
|
207
|
-
(menuItem) => !menuItem.hidden
|
|
209
|
+
(menuItem) => !menuItem.hidden,
|
|
208
210
|
)
|
|
209
211
|
expect(visibleMenuItems.length).to.equal(6)
|
|
210
212
|
})
|
|
@@ -231,7 +233,7 @@ describe("LeuSelect", () => {
|
|
|
231
233
|
|
|
232
234
|
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
233
235
|
const visibleMenuItems = Array.from(menuItems).filter(
|
|
234
|
-
(menuItem) => !menuItem.hidden
|
|
236
|
+
(menuItem) => !menuItem.hidden,
|
|
235
237
|
)
|
|
236
238
|
|
|
237
239
|
expect(visibleMenuItems.length).to.equal(MUNICIPALITIES.length)
|
|
@@ -296,7 +298,7 @@ describe("LeuSelect", () => {
|
|
|
296
298
|
toggleButton.click()
|
|
297
299
|
|
|
298
300
|
const menuItem = Array.from(el.querySelectorAll("leu-menu-item")).find(
|
|
299
|
-
(item) => item.textContent === "Maur"
|
|
301
|
+
(item) => item.textContent === "Maur",
|
|
300
302
|
)
|
|
301
303
|
menuItem.click()
|
|
302
304
|
|
|
@@ -331,7 +333,7 @@ describe("LeuSelect", () => {
|
|
|
331
333
|
toggleButton.click()
|
|
332
334
|
|
|
333
335
|
const menuItem = Array.from(el.querySelectorAll("leu-menu-item")).find(
|
|
334
|
-
(item) => item.textContent === "Hedingen"
|
|
336
|
+
(item) => item.textContent === "Hedingen",
|
|
335
337
|
)
|
|
336
338
|
menuItem.click()
|
|
337
339
|
|
|
@@ -350,7 +352,7 @@ describe("LeuSelect", () => {
|
|
|
350
352
|
toggleButton.click()
|
|
351
353
|
|
|
352
354
|
const menuItem = Array.from(el.querySelectorAll("leu-menu-item")).find(
|
|
353
|
-
(item) => item.textContent === "Hedingen"
|
|
355
|
+
(item) => item.textContent === "Hedingen",
|
|
354
356
|
)
|
|
355
357
|
menuItem.click()
|
|
356
358
|
|