@justeattakeaway/pie-switch 0.28.0 → 0.29.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/dist/index.js CHANGED
@@ -565,11 +565,9 @@ class p extends At(It(xt)) {
565
565
  renderSwitchLabel() {
566
566
  const { label: n, labelPlacement: c } = this;
567
567
  return n ? A`
568
- <label
569
- for="switch"
570
- data-test-id="switch-label-${c}">
568
+ <span data-test-id="switch-label-${c}">
571
569
  ${n}
572
- </label>` : A``;
570
+ </span>` : A``;
573
571
  }
574
572
  render() {
575
573
  const {
@@ -581,17 +579,16 @@ class p extends At(It(xt)) {
581
579
  isRTL: k
582
580
  } = this, M = "switch-description";
583
581
  return A`
584
- <div
582
+ <label
585
583
  class="c-switch-wrapper"
586
584
  ?isRTL=${k}
587
585
  ?disabled=${w}>
588
586
  ${n === "leading" ? this.renderSwitchLabel() : x}
589
- <label
587
+ <div
590
588
  data-test-id="switch-component"
591
589
  class="c-switch"
592
590
  ?checked=${h}>
593
591
  <input
594
- id="switch"
595
592
  data-test-id="switch-input"
596
593
  role="switch"
597
594
  type="checkbox"
@@ -605,10 +602,10 @@ class p extends At(It(xt)) {
605
602
  <div class="c-switch-control">
606
603
  ${h ? A`<icon-check></icon-check>` : x}
607
604
  </div>
608
- </label>
609
- ${c != null && c.describedBy ? A`<div id="${M}" data-test-id="${M}" class="c-switch-description">${c == null ? void 0 : c.describedBy}</div>` : x}
605
+ </div>
610
606
  ${n === "trailing" ? this.renderSwitchLabel() : x}
611
- </div>
607
+ ${c != null && c.describedBy ? A`<div id="${M}" data-test-id="${M}" class="c-switch-description">${c == null ? void 0 : c.describedBy}</div>` : x}
608
+ </label>
612
609
  `;
613
610
  }
614
611
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-switch",
3
3
  "description": "PIE Design System Switch built using Web Components",
4
- "version": "0.28.0",
4
+ "version": "0.29.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -12,6 +12,9 @@
12
12
  "dist",
13
13
  "**/*.d.ts"
14
14
  ],
15
+ "pieMetadata": {
16
+ "componentStatus": "alpha"
17
+ },
15
18
  "scripts": {
16
19
  "build": "run -T vite build",
17
20
  "build:react-wrapper": "npx build-react-wrapper",
package/src/index.ts CHANGED
@@ -158,11 +158,9 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
158
158
 
159
159
  if (label) {
160
160
  return html`
161
- <label
162
- for="switch"
163
- data-test-id="switch-label-${labelPlacement}">
161
+ <span data-test-id="switch-label-${labelPlacement}">
164
162
  ${label}
165
- </label>`;
163
+ </span>`;
166
164
  }
167
165
 
168
166
  return html``;
@@ -181,17 +179,16 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
181
179
  const switchId = 'switch-description';
182
180
 
183
181
  return html`
184
- <div
182
+ <label
185
183
  class="c-switch-wrapper"
186
184
  ?isRTL=${isRTL}
187
185
  ?disabled=${disabled}>
188
186
  ${labelPlacement === 'leading' ? this.renderSwitchLabel() : nothing}
189
- <label
187
+ <div
190
188
  data-test-id="switch-component"
191
189
  class="c-switch"
192
190
  ?checked=${checked}>
193
191
  <input
194
- id="switch"
195
192
  data-test-id="switch-input"
196
193
  role="switch"
197
194
  type="checkbox"
@@ -205,10 +202,10 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
205
202
  <div class="c-switch-control">
206
203
  ${checked ? html`<icon-check></icon-check>` : nothing}
207
204
  </div>
208
- </label>
209
- ${aria?.describedBy ? html`<div id="${switchId}" data-test-id="${switchId}" class="c-switch-description">${aria?.describedBy}</div>` : nothing}
205
+ </div>
210
206
  ${labelPlacement === 'trailing' ? this.renderSwitchLabel() : nothing}
211
- </div>
207
+ ${aria?.describedBy ? html`<div id="${switchId}" data-test-id="${switchId}" class="c-switch-description">${aria?.describedBy}</div>` : nothing}
208
+ </label>
212
209
  `;
213
210
  }
214
211
  }