@justeattakeaway/pie-switch 0.28.1 → 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 +7 -10
- package/package.json +1 -1
- package/src/index.ts +7 -10
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
|
-
</
|
|
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
|
-
<
|
|
582
|
+
<label
|
|
585
583
|
class="c-switch-wrapper"
|
|
586
584
|
?isRTL=${k}
|
|
587
585
|
?disabled=${w}>
|
|
588
586
|
${n === "leading" ? this.renderSwitchLabel() : x}
|
|
589
|
-
<
|
|
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
|
-
</
|
|
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
|
-
|
|
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
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
|
-
</
|
|
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
|
-
<
|
|
182
|
+
<label
|
|
185
183
|
class="c-switch-wrapper"
|
|
186
184
|
?isRTL=${isRTL}
|
|
187
185
|
?disabled=${disabled}>
|
|
188
186
|
${labelPlacement === 'leading' ? this.renderSwitchLabel() : nothing}
|
|
189
|
-
<
|
|
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
|
-
</
|
|
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
|
-
|
|
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
|
}
|