@statistikzh/leu 0.10.0 → 0.11.1

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 (151) hide show
  1. package/.github/workflows/deploy-github-pages.yaml +2 -2
  2. package/.github/workflows/release-please.yml +1 -1
  3. package/CHANGELOG.md +15 -0
  4. package/dist/Accordion.d.ts +1 -1
  5. package/dist/Accordion.d.ts.map +1 -1
  6. package/dist/Accordion.js +22 -30
  7. package/dist/Breadcrumb.d.ts +1 -1
  8. package/dist/Breadcrumb.d.ts.map +1 -1
  9. package/dist/Breadcrumb.js +3 -8
  10. package/dist/Button.d.ts +1 -1
  11. package/dist/Button.js +3 -3
  12. package/dist/ButtonGroup.d.ts +1 -1
  13. package/dist/ButtonGroup.d.ts.map +1 -1
  14. package/dist/ButtonGroup.js +3 -8
  15. package/dist/Checkbox.d.ts +1 -1
  16. package/dist/Checkbox.js +2 -2
  17. package/dist/CheckboxGroup.d.ts +1 -1
  18. package/dist/CheckboxGroup.js +2 -2
  19. package/dist/Chip.d.ts +1 -1
  20. package/dist/Chip.d.ts.map +1 -1
  21. package/dist/Chip.js +3 -5
  22. package/dist/ChipGroup.d.ts +1 -1
  23. package/dist/ChipGroup.js +2 -2
  24. package/dist/ChipLink.js +1 -1
  25. package/dist/ChipRemovable.js +1 -1
  26. package/dist/ChipSelectable.js +1 -1
  27. package/dist/Dialog.d.ts +1 -1
  28. package/dist/Dialog.d.ts.map +1 -1
  29. package/dist/Dialog.js +3 -7
  30. package/dist/Dropdown.d.ts +1 -1
  31. package/dist/Dropdown.d.ts.map +1 -1
  32. package/dist/Dropdown.js +4 -9
  33. package/dist/Icon.d.ts +1 -1
  34. package/dist/Icon.js +2 -2
  35. package/dist/Input.d.ts +1 -1
  36. package/dist/Input.d.ts.map +1 -1
  37. package/dist/Input.js +3 -8
  38. package/dist/{LeuElement-6fbc0dee.d.ts → LeuElement-e092765a.d.ts} +1 -1
  39. package/dist/LeuElement-e092765a.d.ts.map +1 -0
  40. package/dist/{LeuElement-6fbc0dee.js → LeuElement-e092765a.js} +10 -2
  41. package/dist/Menu.d.ts +1 -1
  42. package/dist/Menu.d.ts.map +1 -1
  43. package/dist/Menu.js +3 -8
  44. package/dist/MenuItem.d.ts +1 -1
  45. package/dist/MenuItem.d.ts.map +1 -1
  46. package/dist/MenuItem.js +3 -8
  47. package/dist/Pagination.d.ts +1 -1
  48. package/dist/Pagination.js +3 -3
  49. package/dist/Popup.d.ts +1 -1
  50. package/dist/Popup.d.ts.map +1 -1
  51. package/dist/Popup.js +3 -8
  52. package/dist/Radio.d.ts +1 -1
  53. package/dist/Radio.js +2 -2
  54. package/dist/RadioGroup.d.ts +1 -1
  55. package/dist/RadioGroup.js +2 -2
  56. package/dist/Range.d.ts +60 -0
  57. package/dist/Range.d.ts.map +1 -0
  58. package/dist/Range.js +413 -0
  59. package/dist/ScrollTop.d.ts +1 -1
  60. package/dist/ScrollTop.js +3 -3
  61. package/dist/Select.d.ts +1 -1
  62. package/dist/Select.d.ts.map +1 -1
  63. package/dist/Select.js +4 -9
  64. package/dist/Spinner.d.ts +1 -1
  65. package/dist/Spinner.js +2 -2
  66. package/dist/Table.d.ts +1 -1
  67. package/dist/Table.js +3 -3
  68. package/dist/VisuallyHidden.d.ts +1 -1
  69. package/dist/VisuallyHidden.js +2 -2
  70. package/dist/{hasSlotController-04d0dfa2.d.ts → hasSlotController-d1f26756.d.ts} +1 -1
  71. package/dist/{hasSlotController-04d0dfa2.d.ts.map → hasSlotController-d1f26756.d.ts.map} +1 -1
  72. package/dist/{hasSlotController-04d0dfa2.js → hasSlotController-d1f26756.js} +1 -1
  73. package/dist/index.js +2 -2
  74. package/dist/leu-accordion.js +1 -1
  75. package/dist/leu-breadcrumb.js +1 -1
  76. package/dist/leu-button-group.js +1 -1
  77. package/dist/leu-button.js +2 -2
  78. package/dist/leu-checkbox-group.js +1 -1
  79. package/dist/leu-checkbox.js +1 -1
  80. package/dist/leu-chip-group.js +1 -1
  81. package/dist/leu-chip-link.js +1 -1
  82. package/dist/leu-chip-removable.js +1 -1
  83. package/dist/leu-chip-selectable.js +1 -1
  84. package/dist/leu-dialog.js +2 -2
  85. package/dist/leu-dropdown.js +2 -2
  86. package/dist/leu-icon.js +1 -1
  87. package/dist/leu-input.js +1 -1
  88. package/dist/leu-menu-item.js +1 -1
  89. package/dist/leu-menu.js +1 -1
  90. package/dist/leu-pagination.js +2 -2
  91. package/dist/leu-popup.js +1 -1
  92. package/dist/leu-radio-group.js +1 -1
  93. package/dist/leu-radio.js +1 -1
  94. package/dist/leu-range.d.ts +3 -0
  95. package/dist/leu-range.d.ts.map +1 -0
  96. package/dist/leu-range.js +7 -0
  97. package/dist/leu-scroll-top.js +2 -2
  98. package/dist/leu-select.js +2 -2
  99. package/dist/leu-spinner.js +1 -1
  100. package/dist/leu-table.js +2 -2
  101. package/dist/leu-visually-hidden.js +1 -1
  102. package/dist/vscode.html-custom-data.json +130 -110
  103. package/dist/vue/index.d.ts +194 -153
  104. package/dist/web-types.json +243 -199
  105. package/package.json +1 -1
  106. package/scripts/generate-component/templates/[Name].js +1 -1
  107. package/scripts/generate-component/templates/[name].css +0 -5
  108. package/src/components/accordion/Accordion.js +10 -6
  109. package/src/components/accordion/accordion.css +9 -22
  110. package/src/components/breadcrumb/Breadcrumb.js +1 -1
  111. package/src/components/breadcrumb/breadcrumb.css +0 -5
  112. package/src/components/button/Button.js +1 -1
  113. package/src/components/button-group/ButtonGroup.js +1 -1
  114. package/src/components/button-group/button-group.css +0 -5
  115. package/src/components/checkbox/Checkbox.js +1 -1
  116. package/src/components/checkbox/CheckboxGroup.js +1 -1
  117. package/src/components/chip/Chip.js +1 -1
  118. package/src/components/chip/ChipGroup.js +1 -1
  119. package/src/components/chip/chip.css +0 -2
  120. package/src/components/dialog/Dialog.js +1 -1
  121. package/src/components/dialog/dialog.css +0 -5
  122. package/src/components/dropdown/Dropdown.js +1 -1
  123. package/src/components/dropdown/dropdown.css +0 -5
  124. package/src/components/icon/Icon.js +1 -1
  125. package/src/components/input/Input.js +1 -1
  126. package/src/components/input/input.css +0 -5
  127. package/src/components/menu/Menu.js +1 -1
  128. package/src/components/menu/MenuItem.js +1 -1
  129. package/src/components/menu/menu-item.css +0 -5
  130. package/src/components/menu/menu.css +0 -5
  131. package/src/components/pagination/Pagination.js +1 -1
  132. package/src/components/popup/Popup.js +1 -1
  133. package/src/components/popup/popup.css +0 -5
  134. package/src/components/radio/Radio.js +1 -1
  135. package/src/components/radio/RadioGroup.js +1 -1
  136. package/src/components/range/Range.js +237 -0
  137. package/src/components/range/leu-range.js +5 -0
  138. package/src/components/range/range.css +180 -0
  139. package/src/components/range/stories/range-slider.stories.js +142 -0
  140. package/src/components/range/test/range-test.js +24 -0
  141. package/src/components/scroll-top/ScrollTop.js +1 -1
  142. package/src/components/select/Select.js +1 -1
  143. package/src/components/select/select.css +0 -5
  144. package/src/components/spinner/Spinner.js +1 -1
  145. package/src/components/table/Table.js +1 -1
  146. package/src/components/visually-hidden/VisuallyHidden.js +1 -1
  147. package/src/lib/LeuElement.js +3 -0
  148. package/src/styles/common-styles.css +5 -0
  149. package/src/styles/style.stories.js +1 -0
  150. package/web-dev-server.config.mjs +1 -0
  151. package/dist/LeuElement-6fbc0dee.d.ts.map +0 -1
@@ -1,10 +1,5 @@
1
1
  @import url("../../styles/custom-media.css");
2
2
 
3
- :host,
4
- :host * {
5
- box-sizing: border-box;
6
- }
7
-
8
3
  :host {
9
4
  --accordion-font-regular: var(--leu-font-family-regular);
10
5
  --accordion-font-black: var(--leu-font-family-black);
@@ -19,17 +14,9 @@
19
14
 
20
15
  --transition: 0.1s ease;
21
16
 
22
- font-family: var(--chip-font-regular);
17
+ font-family: var(--accordion-font-regular);
23
18
 
24
19
  position: relative;
25
- display: grid;
26
- grid-template-rows: auto 0fr;
27
-
28
- transition: grid-template-rows var(--transition);
29
- }
30
-
31
- :host([open]) {
32
- grid-template-rows: auto 1fr;
33
20
  }
34
21
 
35
22
  .heading {
@@ -115,15 +102,18 @@
115
102
  flex-grow: 1;
116
103
  }
117
104
 
105
+ .contentwrapper {
106
+ display: grid;
107
+ grid-template-rows: 1fr;
108
+ transition: grid-template-rows var(--transition);
109
+ }
110
+
118
111
  .content {
119
112
  overflow: hidden;
120
- transition: visibility var(--transition), opacity var(--transition);
121
113
  }
122
114
 
123
- .content[hidden] {
124
- display: block;
125
- visibility: hidden;
126
- opacity: 0;
115
+ .contentwrapper[hidden] {
116
+ grid-template-rows: 0fr;
127
117
  }
128
118
 
129
119
  slot[name="content"] {
@@ -140,9 +130,6 @@ slot[name="content"] {
140
130
  }
141
131
 
142
132
  .divider {
143
- position: absolute;
144
- top: 100%;
145
- left: 0;
146
133
 
147
134
  width: 100%;
148
135
  height: 1px;
@@ -55,7 +55,7 @@ export class LeuBreadcrumb extends LeuElement {
55
55
  "leu-visually-hidden": LeuVisuallyHidden,
56
56
  }
57
57
 
58
- static styles = styles
58
+ static styles = [LeuElement.styles, styles]
59
59
 
60
60
  static properties = {
61
61
  items: { type: Array },
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  --breadcrumb-font-regular: var(--leu-font-family-regular);
8
3
  --breadcrumb-font-black: var(--leu-font-family-black);
@@ -41,7 +41,7 @@ export class LeuButton extends LeuElement {
41
41
  "leu-icon": LeuIcon,
42
42
  }
43
43
 
44
- static styles = styles
44
+ static styles = [LeuElement.styles, styles]
45
45
 
46
46
  /**
47
47
  * @internal
@@ -11,7 +11,7 @@ import styles from "./button-group.css"
11
11
  * @fires input - When the value of the group changes by clicking a button
12
12
  */
13
13
  export class LeuButtonGroup extends LeuElement {
14
- static styles = styles
14
+ static styles = [LeuElement.styles, styles]
15
15
 
16
16
  constructor() {
17
17
  super()
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  .group {
7
2
  display: flex;
8
3
  gap: 0.5rem;
@@ -14,7 +14,7 @@ export class LeuCheckbox extends LeuElement {
14
14
  "leu-icon": LeuIcon,
15
15
  }
16
16
 
17
- static styles = styles
17
+ static styles = [LeuElement.styles, styles]
18
18
 
19
19
  /** @internal */
20
20
  static shadowRootOptions = {
@@ -10,7 +10,7 @@ import styles from "./checkbox-group.css"
10
10
  * @tagname leu-checkbox-group
11
11
  */
12
12
  export class LeuCheckboxGroup extends LeuElement {
13
- static styles = styles
13
+ static styles = [LeuElement.styles, styles]
14
14
 
15
15
  static properties = {
16
16
  orientation: { type: String, reflect: true },
@@ -6,7 +6,7 @@ import styles from "./chip.css"
6
6
  /* Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=21161-184433&mode=design&t=Kjo5VDiqivihn8dh-11 */
7
7
 
8
8
  export class LeuChipBase extends LeuElement {
9
- static styles = styles
9
+ static styles = [LeuElement.styles, styles]
10
10
 
11
11
  /** @internal */
12
12
  static shadowRootOptions = {
@@ -19,7 +19,7 @@ export const SELECTION_MODES = Object.freeze({
19
19
  * @tagname leu-chip-group
20
20
  */
21
21
  export class LeuChipGroup extends LeuElement {
22
- static styles = styles
22
+ static styles = [LeuElement.styles, styles]
23
23
 
24
24
  static properties = {
25
25
  inverted: { type: Boolean, reflect: true },
@@ -1,5 +1,3 @@
1
- :host,
2
- :host *,
3
1
  :host *::before,
4
2
  :host *::after {
5
3
  box-sizing: border-box;
@@ -19,7 +19,7 @@ export class LeuDialog extends LeuElement {
19
19
  "leu-icon": LeuIcon,
20
20
  }
21
21
 
22
- static styles = styles
22
+ static styles = [LeuElement.styles, styles]
23
23
 
24
24
  static shadowRootOptions = {
25
25
  ...LeuElement.shadowRootOptions,
@@ -2,11 +2,6 @@
2
2
 
3
3
  /* figma https://www.figma.com/design/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?node-id=21161-186812&t=8VgDy9avMRG5aL7s-0 */
4
4
 
5
- :host,
6
- :host * {
7
- box-sizing: border-box;
8
- }
9
-
10
5
  :host {
11
6
  --dialog-font-regular: var(--leu-font-family-regular);
12
7
  --dialog-font-black: var(--leu-font-family-black);
@@ -23,7 +23,7 @@ export class LeuDropdown extends LeuElement {
23
23
  "leu-popup": LeuPopup,
24
24
  }
25
25
 
26
- static styles = styles
26
+ static styles = [LeuElement.styles, styles]
27
27
 
28
28
  static properties = {
29
29
  label: { type: String, reflect: true },
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  position: relative;
8
3
  }
@@ -17,7 +17,7 @@ import { paths } from "./paths.js"
17
17
  * @cssprop --leu-icon-size - The size of the icon.
18
18
  */
19
19
  export class LeuIcon extends LeuElement {
20
- static styles = styles
20
+ static styles = [LeuElement.styles, styles]
21
21
 
22
22
  static properties = {
23
23
  name: { type: String, reflect: true },
@@ -70,7 +70,7 @@ export class LeuInput extends LeuElement {
70
70
  "leu-icon": LeuIcon,
71
71
  }
72
72
 
73
- static styles = styles
73
+ static styles = [LeuElement.styles, styles]
74
74
 
75
75
  /**
76
76
  * @internal
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  --input-color: var(--leu-color-black-100);
8
3
  --input-color-disabled: var(--leu-color-black-20);
@@ -16,7 +16,7 @@ import styles from "./menu.css"
16
16
  * @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'.
17
17
  */
18
18
  export class LeuMenu extends LeuElement {
19
- static styles = styles
19
+ static styles = [LeuElement.styles, styles]
20
20
 
21
21
  static shadowRootOptions = {
22
22
  ...LeuElement.shadowRootOptions,
@@ -27,7 +27,7 @@ export class LeuMenuItem extends LeuElement {
27
27
  "leu-icon": LeuIcon,
28
28
  }
29
29
 
30
- static styles = styles
30
+ static styles = [LeuElement.styles, styles]
31
31
 
32
32
  /**
33
33
  * @internal
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  --background: var(--leu-color-black-0);
8
3
  --background-hover: var(--leu-color-black-10);
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  --menu-divider-color: var(--leu-color-black-transp-20);
8
3
  }
@@ -21,7 +21,7 @@ export class LeuPagination extends LeuElement {
21
21
  "leu-visually-hidden": LeuVisuallyHidden,
22
22
  }
23
23
 
24
- static styles = styles
24
+ static styles = [LeuElement.styles, styles]
25
25
 
26
26
  /**
27
27
  * @internal
@@ -20,7 +20,7 @@ import styles from "./popup.css"
20
20
  * @tagname leu-popup
21
21
  */
22
22
  export class LeuPopup extends LeuElement {
23
- static styles = styles
23
+ static styles = [LeuElement.styles, styles]
24
24
 
25
25
  static shadowRootOptions = {
26
26
  ...LeuElement.shadowRootOptions,
@@ -1,8 +1,3 @@
1
- :host,
2
- :host * {
3
- box-sizing: border-box;
4
- }
5
-
6
1
  :host {
7
2
  --popup-font-regular: var(--leu-font-family-regular);
8
3
  --popup-font-black: var(--leu-font-family-black);
@@ -9,7 +9,7 @@ import styles from "./radio.css"
9
9
  * @tagname leu-radio
10
10
  */
11
11
  export class LeuRadio extends LeuElement {
12
- static styles = styles
12
+ static styles = [LeuElement.styles, styles]
13
13
 
14
14
  /** @internal */
15
15
  static shadowRootOptions = {
@@ -10,7 +10,7 @@ import styles from "./radio-group.css"
10
10
  * @tagname leu-radio-group
11
11
  */
12
12
  export class LeuRadioGroup extends LeuElement {
13
- static styles = styles
13
+ static styles = [LeuElement.styles, styles]
14
14
 
15
15
  static properties = {
16
16
  orientation: { type: String, reflect: true },
@@ -0,0 +1,237 @@
1
+ import { html } from "lit"
2
+
3
+ import styles from "./range.css"
4
+ import { LeuElement } from "../../lib/LeuElement.js"
5
+
6
+ const defaultValueConverter = {
7
+ fromAttribute(value) {
8
+ return value.split(",").map((v) => Number(v.trim()))
9
+ },
10
+ toAttribute(value) {
11
+ return value.join(",")
12
+ },
13
+ }
14
+
15
+ const RANGE_LABELS = ["Von", "Bis"]
16
+
17
+ /**
18
+ * @tagname leu-range
19
+ */
20
+ export class LeuRange extends LeuElement {
21
+ static styles = [LeuElement.styles, styles]
22
+
23
+ static shadowRootOptions = {
24
+ ...LeuElement.shadowRootOptions,
25
+ delegatesFocus: true,
26
+ }
27
+
28
+ static properties = {
29
+ defaultValue: { converter: defaultValueConverter, attribute: "value" },
30
+ min: { type: Number, reflect: true },
31
+ max: { type: Number, reflect: true },
32
+ step: { type: Number, reflect: true },
33
+ name: { type: String, reflect: true },
34
+ label: { type: String, reflect: true },
35
+ disabled: { type: Boolean, reflect: true },
36
+ multiple: { type: Boolean, reflect: true },
37
+ }
38
+
39
+ constructor() {
40
+ super()
41
+ this.defaultValue = [50]
42
+ this.min = 0
43
+ this.max = 100
44
+ this.step = 1
45
+ this.name = ""
46
+ this.label = ""
47
+ this.disabled = false
48
+ this.multiple = false
49
+ }
50
+
51
+ updated() {
52
+ this._updateStyles()
53
+ }
54
+
55
+ _updateStyles() {
56
+ const normalizedRange = this._getNormalizedRange()
57
+ this.style.setProperty("--low", normalizedRange[0].toString())
58
+ this.style.setProperty("--high", normalizedRange[1].toString())
59
+
60
+ const inputs = this.multiple
61
+ ? [this._getBaseInput(), this._getGhostInput()]
62
+ : [this._getBaseInput()]
63
+
64
+ inputs.forEach((input) => {
65
+ /** @type {HTMLOutputElement} */
66
+ const output = this.shadowRoot.querySelector(`.output[for=${input.id}]`)
67
+ const normalizedValue = this._getNormalizedValue(input.valueAsNumber)
68
+ output.style.setProperty("--value", normalizedValue.toString())
69
+ output.value = input.value
70
+ })
71
+ }
72
+
73
+ get value() {
74
+ const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
75
+ return inputs.map((input) => input.value).join(",")
76
+ }
77
+
78
+ /**
79
+ * Sets the value of the underlying input element(s).
80
+ * The value has to be an array if "multiple" range is used.
81
+ * Otherwise it has to be a string.
82
+ * @param {string | Array} value
83
+ */
84
+ set value(value) {
85
+ if (this.multiple && Array.isArray(value)) {
86
+ const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
87
+ value.forEach((v, i) => {
88
+ inputs[i].value = v
89
+ })
90
+ this._updateStyles()
91
+ } else if (!this.multiple) {
92
+ this._getBaseInput().value = value
93
+ this._updateStyles()
94
+ }
95
+ }
96
+
97
+ get valueAsArray() {
98
+ return Array.from(this.shadowRoot.querySelectorAll("input")).map(
99
+ (input) => input.valueAsNumber
100
+ )
101
+ }
102
+
103
+ get valueLow() {
104
+ const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
105
+
106
+ if (this.multiple) {
107
+ return inputs.map((input) => input.valueAsNumber).sort((a, b) => a - b)[0]
108
+ }
109
+
110
+ return inputs[0].value
111
+ }
112
+
113
+ get valueHigh() {
114
+ const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
115
+
116
+ if (this.multiple) {
117
+ return inputs.map((input) => input.valueAsNumber).sort((a, b) => a - b)[1]
118
+ }
119
+
120
+ return inputs[0].value
121
+ }
122
+
123
+ /**
124
+ * @returns {HTMLInputElement | null}
125
+ */
126
+ _getBaseInput() {
127
+ return this.shadowRoot.querySelector(".range--base")
128
+ }
129
+
130
+ /**
131
+ * @returns {HTMLInputElement | null}
132
+ */
133
+ _getGhostInput() {
134
+ return this.shadowRoot.querySelector(".range--ghost")
135
+ }
136
+
137
+ /**
138
+ *
139
+ * @param {number} _index
140
+ * @param {InputEvent & {target: HTMLInputElement}} _e
141
+ */
142
+ _handleInput(_index, _e) {
143
+ this._updateStyles()
144
+ }
145
+
146
+ /**
147
+ *
148
+ * @param {number} value
149
+ * @returns {number}
150
+ */
151
+ _getNormalizedValue(value) {
152
+ return (value - this.min) / (this.max - this.min)
153
+ }
154
+
155
+ _getNormalizedRange() {
156
+ if (this.multiple) {
157
+ return this.valueAsArray
158
+ .map((value) => this._getNormalizedValue(value))
159
+ .sort((a, b) => a - b)
160
+ }
161
+
162
+ return [0, this._getNormalizedValue(this.valueAsArray[0])]
163
+ }
164
+
165
+ /**
166
+ * Determine if the "click" (pointer event) is closer the
167
+ * the value of the other input element. Swap the values if this is the case.
168
+ * @param {PointerEvent & {target: HTMLInputElement}} e
169
+ */
170
+ _handlePointerDown(e) {
171
+ const clickValue =
172
+ this.min + ((this.max - this.min) * e.offsetX) / this.offsetWidth
173
+ const middleValue = (this.valueAsArray[0] + this.valueAsArray[1]) / 2
174
+
175
+ if (
176
+ (e.target.valueAsNumber === this.valueLow) ===
177
+ clickValue > middleValue
178
+ ) {
179
+ /**
180
+ * As the pointerdown event is fired before the input event, we first overwrite the value
181
+ * of the input element that was not clicked on. The active input element will update itself.
182
+ */
183
+ // this._value = [e.target.valueAsNumber, e.target.valueAsNumber]
184
+ this._getGhostInput().value = e.target.value
185
+ }
186
+ }
187
+
188
+ render() {
189
+ const inputs = this.multiple ? ["base", "ghost"] : ["base"]
190
+
191
+ const { multiple, disabled, label, defaultValue } = this
192
+
193
+ return html`
194
+ <div
195
+ role=${multiple ? "group" : undefined}
196
+ aria-labelledby=${multiple ? "group-label" : undefined}
197
+ >
198
+ ${multiple
199
+ ? html`<span id="group-label" class="label">${label}</span>`
200
+ : html`<label for="input-base" class="label">${label}</label>`}
201
+ <div class="outputs">
202
+ ${inputs.map(
203
+ (type, index) =>
204
+ html`<output
205
+ class="output"
206
+ for="input-${type}"
207
+ value=${defaultValue[index]}
208
+ ></output>`
209
+ )}
210
+ </div>
211
+ <div class="inputs">
212
+ ${inputs.map(
213
+ (type, index) =>
214
+ html`
215
+ <input
216
+ @input=${(e) => this._handleInput(index, e)}
217
+ @pointerdown=${multiple && !disabled && index === 0
218
+ ? this._handlePointerDown
219
+ : undefined}
220
+ type="range"
221
+ class="range range--${type}"
222
+ id="input-${type}"
223
+ name=${this.name}
224
+ min=${this.min}
225
+ max=${this.max}
226
+ step=${this.step}
227
+ aria-label=${multiple ? RANGE_LABELS[index] : undefined}
228
+ ?disabled=${disabled}
229
+ .value=${defaultValue[index].toString()}
230
+ />
231
+ `
232
+ )}
233
+ </div>
234
+ </div>
235
+ `
236
+ }
237
+ }
@@ -0,0 +1,5 @@
1
+ import { LeuRange } from "./Range.js"
2
+
3
+ export { LeuRange }
4
+
5
+ LeuRange.define("leu-range")