@rcarls/rc-switch 0.4.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/README.md +12 -0
- package/dist/custom-elements.json +526 -0
- package/dist/rc-switch-98TbWbUy.js +256 -0
- package/dist/rc-switch-98TbWbUy.js.map +1 -0
- package/dist/rc-switch-define.js +3 -0
- package/dist/rc-switch-define.js.map +1 -0
- package/dist/rc-switch.js +5 -0
- package/dist/rc-switch.js.map +1 -0
- package/dist/types/packages/rc-switch/src/define.d.ts +1 -0
- package/dist/types/packages/rc-switch/src/index.d.ts +2 -0
- package/dist/types/packages/rc-switch/src/rc-switch.d.ts +109 -0
- package/dist/types/packages/rc-switch/src/rc-switch.styles.d.ts +2 -0
- package/dist/types/packages/rc-switch/src/rc-switch.test.d.ts +0 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @rcarls/rc-switch
|
|
2
|
+
|
|
3
|
+
Switch wrapper that enhances a native checkbox input.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<rc-switch>
|
|
7
|
+
<input id="notifications" name="notifications" type="checkbox" />
|
|
8
|
+
</rc-switch>
|
|
9
|
+
<label for="notifications">Notifications</label>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The native checkbox remains connected for labels, forms, validation, and no-JavaScript fallback.
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/define.ts",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "custom-element-definition",
|
|
12
|
+
"name": "rc-switch",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "RCSwitch",
|
|
15
|
+
"module": "/src/rc-switch.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"kind": "javascript-module",
|
|
22
|
+
"path": "src/index.ts",
|
|
23
|
+
"declarations": [],
|
|
24
|
+
"exports": [
|
|
25
|
+
{
|
|
26
|
+
"kind": "js",
|
|
27
|
+
"name": "RCSwitch",
|
|
28
|
+
"declaration": {
|
|
29
|
+
"name": "default",
|
|
30
|
+
"module": "./rc-switch.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "js",
|
|
35
|
+
"name": "RCSwitchChangeDetail",
|
|
36
|
+
"declaration": {
|
|
37
|
+
"name": "RCSwitchChangeDetail",
|
|
38
|
+
"module": "./rc-switch.js"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"kind": "javascript-module",
|
|
45
|
+
"path": "src/rc-switch.ts",
|
|
46
|
+
"declarations": [
|
|
47
|
+
{
|
|
48
|
+
"kind": "class",
|
|
49
|
+
"description": "Switch wrapper that enhances a direct native checkbox input.",
|
|
50
|
+
"name": "RCSwitch",
|
|
51
|
+
"cssProperties": [
|
|
52
|
+
{
|
|
53
|
+
"description": "Track inline size. No built-in default; a theme must set this for the switch to render with a visible size.",
|
|
54
|
+
"name": "--rc-switch-track-inline-size"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"description": "Track block size. No built-in default; a theme must set this for the switch to render with a visible size.",
|
|
58
|
+
"name": "--rc-switch-track-block-size"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"description": "Slotted native checkbox `appearance`.",
|
|
62
|
+
"name": "--rc-switch-native-appearance",
|
|
63
|
+
"default": "revert"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"description": "Slotted native checkbox inline size.",
|
|
67
|
+
"name": "--rc-switch-native-inline-size",
|
|
68
|
+
"default": "revert"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"description": "Slotted native checkbox block size.",
|
|
72
|
+
"name": "--rc-switch-native-block-size",
|
|
73
|
+
"default": "revert"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"description": "Slotted native checkbox margin.",
|
|
77
|
+
"name": "--rc-switch-native-margin",
|
|
78
|
+
"default": "revert"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"description": "Slotted native checkbox opacity.",
|
|
82
|
+
"name": "--rc-switch-native-opacity",
|
|
83
|
+
"default": "revert"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"description": "Display of the track/thumb/icon decoration. Themes set this to `block` (or similar) to opt into the decorated switch look.",
|
|
87
|
+
"name": "--rc-switch-decoration-display",
|
|
88
|
+
"default": "none"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"description": "Track border.",
|
|
92
|
+
"name": "--rc-switch-track-border",
|
|
93
|
+
"default": "2px solid ButtonBorder"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"description": "Track and thumb border radius.",
|
|
97
|
+
"name": "--rc-switch-track-radius",
|
|
98
|
+
"default": "9999px"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"description": "Unselected track background.",
|
|
102
|
+
"name": "--rc-switch-track-bg",
|
|
103
|
+
"default": "ButtonFace"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"description": "Track/thumb/icon transition duration.",
|
|
107
|
+
"name": "--rc-switch-duration",
|
|
108
|
+
"default": "150ms"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"description": "Track/thumb/icon transition easing.",
|
|
112
|
+
"name": "--rc-switch-easing",
|
|
113
|
+
"default": "ease"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"description": "Unselected thumb inline and block size.",
|
|
117
|
+
"name": "--rc-switch-thumb-size",
|
|
118
|
+
"default": "1rem"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"description": "Thumb and icon inline start offset within the track.",
|
|
122
|
+
"name": "--rc-switch-thumb-offset",
|
|
123
|
+
"default": "0.375rem"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"description": "Thumb border radius.",
|
|
127
|
+
"name": "--rc-switch-thumb-radius",
|
|
128
|
+
"default": "9999px"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"description": "Unselected thumb background.",
|
|
132
|
+
"name": "--rc-switch-thumb-bg",
|
|
133
|
+
"default": "ButtonText"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"description": "Selected/deselected icon container size.",
|
|
137
|
+
"name": "--rc-switch-icon-size",
|
|
138
|
+
"default": "1rem"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"description": "Icon color.",
|
|
142
|
+
"name": "--rc-switch-icon-color",
|
|
143
|
+
"default": "Canvas"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"description": "Display of the active icon container when `icons` or `show-only-selected-icon` is set.",
|
|
147
|
+
"name": "--rc-switch-icon-display",
|
|
148
|
+
"default": "none"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"description": "Selected track border color.",
|
|
152
|
+
"name": "--rc-switch-selected-track-border-color",
|
|
153
|
+
"default": "Highlight"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"description": "Selected track background.",
|
|
157
|
+
"name": "--rc-switch-selected-track-bg",
|
|
158
|
+
"default": "Highlight"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"description": "Selected thumb inline and block size.",
|
|
162
|
+
"name": "--rc-switch-selected-thumb-size",
|
|
163
|
+
"default": "1.5rem"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"description": "Selected thumb background.",
|
|
167
|
+
"name": "--rc-switch-selected-thumb-bg",
|
|
168
|
+
"default": "HighlightText"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"description": "Inline-axis translation applied to the thumb and icons when selected.",
|
|
172
|
+
"name": "--rc-switch-thumb-translate",
|
|
173
|
+
"default": "1.125rem"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"description": "Track focus ring, shown on focus-within.",
|
|
177
|
+
"name": "--rc-switch-focus-ring",
|
|
178
|
+
"default": "2px solid Highlight"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"description": "Track focus ring offset.",
|
|
182
|
+
"name": "--rc-switch-focus-ring-offset",
|
|
183
|
+
"default": "2px"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"description": "Host opacity while `disabled`.",
|
|
187
|
+
"name": "--rc-switch-disabled-opacity",
|
|
188
|
+
"default": "0.5"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"cssParts": [
|
|
192
|
+
{
|
|
193
|
+
"description": "Visual switch track.",
|
|
194
|
+
"name": "track"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"description": "Visual switch thumb.",
|
|
198
|
+
"name": "thumb"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"description": "Optional selected-state icon container.",
|
|
202
|
+
"name": "selected-icon"
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"description": "Optional deselected-state icon container.",
|
|
206
|
+
"name": "deselected-icon"
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
"slots": [
|
|
210
|
+
{
|
|
211
|
+
"description": "A direct native `<input type=\"checkbox\">` child.",
|
|
212
|
+
"name": ""
|
|
213
|
+
}
|
|
214
|
+
],
|
|
215
|
+
"members": [
|
|
216
|
+
{
|
|
217
|
+
"kind": "field",
|
|
218
|
+
"name": "_checked",
|
|
219
|
+
"type": {
|
|
220
|
+
"text": "boolean | undefined"
|
|
221
|
+
},
|
|
222
|
+
"privacy": "private"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
"kind": "field",
|
|
226
|
+
"name": "_defaultChecked",
|
|
227
|
+
"type": {
|
|
228
|
+
"text": "boolean"
|
|
229
|
+
},
|
|
230
|
+
"privacy": "private",
|
|
231
|
+
"default": "false"
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"kind": "field",
|
|
235
|
+
"name": "_checkedInitialized",
|
|
236
|
+
"type": {
|
|
237
|
+
"text": "boolean"
|
|
238
|
+
},
|
|
239
|
+
"privacy": "private",
|
|
240
|
+
"default": "false"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"kind": "field",
|
|
244
|
+
"name": "_$input",
|
|
245
|
+
"type": {
|
|
246
|
+
"text": "HTMLInputElement | null"
|
|
247
|
+
},
|
|
248
|
+
"privacy": "private",
|
|
249
|
+
"default": "null"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"kind": "field",
|
|
253
|
+
"name": "_inputObserver",
|
|
254
|
+
"type": {
|
|
255
|
+
"text": "MutationObserver | null"
|
|
256
|
+
},
|
|
257
|
+
"privacy": "private",
|
|
258
|
+
"default": "null"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"kind": "field",
|
|
262
|
+
"name": "_$form",
|
|
263
|
+
"type": {
|
|
264
|
+
"text": "HTMLFormElement | null"
|
|
265
|
+
},
|
|
266
|
+
"privacy": "private",
|
|
267
|
+
"default": "null"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"kind": "field",
|
|
271
|
+
"name": "_roleOwned",
|
|
272
|
+
"type": {
|
|
273
|
+
"text": "boolean"
|
|
274
|
+
},
|
|
275
|
+
"privacy": "private",
|
|
276
|
+
"default": "false"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"kind": "field",
|
|
280
|
+
"name": "_disabledOwned",
|
|
281
|
+
"type": {
|
|
282
|
+
"text": "boolean"
|
|
283
|
+
},
|
|
284
|
+
"privacy": "private",
|
|
285
|
+
"default": "false"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"kind": "field",
|
|
289
|
+
"name": "_slotMicrotaskQueued",
|
|
290
|
+
"type": {
|
|
291
|
+
"text": "boolean"
|
|
292
|
+
},
|
|
293
|
+
"privacy": "private",
|
|
294
|
+
"default": "false"
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
"kind": "field",
|
|
298
|
+
"name": "checked",
|
|
299
|
+
"type": {
|
|
300
|
+
"text": "boolean"
|
|
301
|
+
},
|
|
302
|
+
"description": "Current checked state. Host writes are silent.",
|
|
303
|
+
"attribute": "checked",
|
|
304
|
+
"reflects": true
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"kind": "field",
|
|
308
|
+
"name": "defaultChecked",
|
|
309
|
+
"type": {
|
|
310
|
+
"text": "boolean"
|
|
311
|
+
},
|
|
312
|
+
"description": "Initial checked state for uncontrolled usage.",
|
|
313
|
+
"attribute": "default-checked"
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"kind": "field",
|
|
317
|
+
"name": "disabled",
|
|
318
|
+
"type": {
|
|
319
|
+
"text": "boolean"
|
|
320
|
+
},
|
|
321
|
+
"default": "false",
|
|
322
|
+
"description": "Mirror disabled state to the native checkbox.",
|
|
323
|
+
"attribute": "disabled",
|
|
324
|
+
"reflects": true
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"kind": "field",
|
|
328
|
+
"name": "icons",
|
|
329
|
+
"type": {
|
|
330
|
+
"text": "boolean"
|
|
331
|
+
},
|
|
332
|
+
"default": "false",
|
|
333
|
+
"description": "Show selected and deselected icon affordance containers.",
|
|
334
|
+
"attribute": "icons",
|
|
335
|
+
"reflects": true
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
"kind": "field",
|
|
339
|
+
"name": "showOnlySelectedIcon",
|
|
340
|
+
"type": {
|
|
341
|
+
"text": "boolean"
|
|
342
|
+
},
|
|
343
|
+
"default": "false",
|
|
344
|
+
"description": "Show only the selected icon affordance container.",
|
|
345
|
+
"attribute": "show-only-selected-icon",
|
|
346
|
+
"reflects": true
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"kind": "method",
|
|
350
|
+
"name": "_handleSlotChange",
|
|
351
|
+
"privacy": "private",
|
|
352
|
+
"return": {
|
|
353
|
+
"type": {
|
|
354
|
+
"text": "void"
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"kind": "method",
|
|
360
|
+
"name": "_syncNativeInput",
|
|
361
|
+
"privacy": "private",
|
|
362
|
+
"return": {
|
|
363
|
+
"type": {
|
|
364
|
+
"text": "void"
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"kind": "field",
|
|
370
|
+
"name": "_handleNativeChange",
|
|
371
|
+
"privacy": "private",
|
|
372
|
+
"readonly": true
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"kind": "method",
|
|
376
|
+
"name": "_syncFromNative",
|
|
377
|
+
"privacy": "private",
|
|
378
|
+
"return": {
|
|
379
|
+
"type": {
|
|
380
|
+
"text": "void"
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"kind": "method",
|
|
386
|
+
"name": "_applyNativeSemantics",
|
|
387
|
+
"privacy": "private",
|
|
388
|
+
"return": {
|
|
389
|
+
"type": {
|
|
390
|
+
"text": "void"
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"kind": "method",
|
|
396
|
+
"name": "_applyChecked",
|
|
397
|
+
"privacy": "private",
|
|
398
|
+
"return": {
|
|
399
|
+
"type": {
|
|
400
|
+
"text": "void"
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
"parameters": [
|
|
404
|
+
{
|
|
405
|
+
"name": "writeDefault",
|
|
406
|
+
"type": {
|
|
407
|
+
"text": "boolean"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
]
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
"kind": "method",
|
|
414
|
+
"name": "_applyDisabled",
|
|
415
|
+
"privacy": "private",
|
|
416
|
+
"return": {
|
|
417
|
+
"type": {
|
|
418
|
+
"text": "void"
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
"kind": "method",
|
|
424
|
+
"name": "_setForm",
|
|
425
|
+
"privacy": "private",
|
|
426
|
+
"return": {
|
|
427
|
+
"type": {
|
|
428
|
+
"text": "void"
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
"parameters": [
|
|
432
|
+
{
|
|
433
|
+
"name": "$form",
|
|
434
|
+
"type": {
|
|
435
|
+
"text": "HTMLFormElement | null"
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"kind": "field",
|
|
442
|
+
"name": "_handleFormReset",
|
|
443
|
+
"privacy": "private",
|
|
444
|
+
"readonly": true
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
"events": [
|
|
448
|
+
{
|
|
449
|
+
"description": "Fired after user interaction changes the checked state.",
|
|
450
|
+
"name": "rc-switch-change"
|
|
451
|
+
}
|
|
452
|
+
],
|
|
453
|
+
"attributes": [
|
|
454
|
+
{
|
|
455
|
+
"description": "Current checked state. Host writes are silent.",
|
|
456
|
+
"name": "checked",
|
|
457
|
+
"type": {
|
|
458
|
+
"text": "boolean"
|
|
459
|
+
},
|
|
460
|
+
"fieldName": "checked"
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
"description": "Initial checked state for uncontrolled usage.",
|
|
464
|
+
"name": "default-checked",
|
|
465
|
+
"type": {
|
|
466
|
+
"text": "boolean"
|
|
467
|
+
},
|
|
468
|
+
"fieldName": "defaultChecked"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"description": "Mirror disabled state to the native checkbox.",
|
|
472
|
+
"name": "disabled",
|
|
473
|
+
"type": {
|
|
474
|
+
"text": "boolean"
|
|
475
|
+
},
|
|
476
|
+
"default": "false",
|
|
477
|
+
"fieldName": "disabled"
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"description": "Show selected and deselected icon affordance containers.",
|
|
481
|
+
"name": "icons",
|
|
482
|
+
"type": {
|
|
483
|
+
"text": "boolean"
|
|
484
|
+
},
|
|
485
|
+
"default": "false",
|
|
486
|
+
"fieldName": "icons"
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
"description": "Show only the selected icon affordance container.",
|
|
490
|
+
"name": "show-only-selected-icon",
|
|
491
|
+
"type": {
|
|
492
|
+
"text": "boolean"
|
|
493
|
+
},
|
|
494
|
+
"default": "false",
|
|
495
|
+
"fieldName": "showOnlySelectedIcon"
|
|
496
|
+
}
|
|
497
|
+
],
|
|
498
|
+
"superclass": {
|
|
499
|
+
"name": "LitElement",
|
|
500
|
+
"package": "lit"
|
|
501
|
+
},
|
|
502
|
+
"tagName": "rc-switch",
|
|
503
|
+
"customElement": true
|
|
504
|
+
}
|
|
505
|
+
],
|
|
506
|
+
"exports": [
|
|
507
|
+
{
|
|
508
|
+
"kind": "js",
|
|
509
|
+
"name": "RCSwitch",
|
|
510
|
+
"declaration": {
|
|
511
|
+
"name": "RCSwitch",
|
|
512
|
+
"module": "src/rc-switch.ts"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"kind": "js",
|
|
517
|
+
"name": "default",
|
|
518
|
+
"declaration": {
|
|
519
|
+
"name": "RCSwitch",
|
|
520
|
+
"module": "src/rc-switch.ts"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
]
|
|
526
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { css as l, LitElement as u, html as p } from "lit";
|
|
2
|
+
import { property as r } from "lit/decorators.js";
|
|
3
|
+
const v = l`
|
|
4
|
+
:host {
|
|
5
|
+
display: inline-grid;
|
|
6
|
+
inline-size: var(--rc-switch-track-inline-size);
|
|
7
|
+
block-size: var(--rc-switch-track-block-size);
|
|
8
|
+
position: relative;
|
|
9
|
+
color-scheme: inherit;
|
|
10
|
+
vertical-align: middle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
:host([hidden]) {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
::slotted(input[type='checkbox']) {
|
|
18
|
+
appearance: var(--rc-switch-native-appearance, revert);
|
|
19
|
+
grid-area: 1 / 1;
|
|
20
|
+
inline-size: var(--rc-switch-native-inline-size, revert);
|
|
21
|
+
block-size: var(--rc-switch-native-block-size, revert);
|
|
22
|
+
margin: var(--rc-switch-native-margin, revert);
|
|
23
|
+
opacity: var(--rc-switch-native-opacity, revert);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[part='track'],
|
|
27
|
+
[part='thumb'],
|
|
28
|
+
[part='selected-icon'],
|
|
29
|
+
[part='deselected-icon'] {
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
grid-area: 1 / 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[part='track'] {
|
|
35
|
+
display: var(--rc-switch-decoration-display, none);
|
|
36
|
+
border: var(--rc-switch-track-border, 2px solid ButtonBorder);
|
|
37
|
+
border-radius: var(--rc-switch-track-radius, 9999px);
|
|
38
|
+
background: var(--rc-switch-track-bg, ButtonFace);
|
|
39
|
+
transition:
|
|
40
|
+
background-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),
|
|
41
|
+
border-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[part='thumb'] {
|
|
45
|
+
display: var(--rc-switch-decoration-display, none);
|
|
46
|
+
align-self: center;
|
|
47
|
+
justify-self: start;
|
|
48
|
+
inline-size: var(--rc-switch-thumb-size, 1rem);
|
|
49
|
+
block-size: var(--rc-switch-thumb-size, 1rem);
|
|
50
|
+
margin-inline-start: var(--rc-switch-thumb-offset, 0.375rem);
|
|
51
|
+
border-radius: var(--rc-switch-thumb-radius, 9999px);
|
|
52
|
+
background: var(--rc-switch-thumb-bg, ButtonText);
|
|
53
|
+
transform: translateX(0);
|
|
54
|
+
transition:
|
|
55
|
+
background-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),
|
|
56
|
+
inline-size var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),
|
|
57
|
+
block-size var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),
|
|
58
|
+
transform var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[part='selected-icon'],
|
|
62
|
+
[part='deselected-icon'] {
|
|
63
|
+
place-self: center start;
|
|
64
|
+
display: none;
|
|
65
|
+
inline-size: var(--rc-switch-icon-size, 1rem);
|
|
66
|
+
block-size: var(--rc-switch-icon-size, 1rem);
|
|
67
|
+
margin-inline-start: var(--rc-switch-thumb-offset, 0.375rem);
|
|
68
|
+
color: var(--rc-switch-icon-color, Canvas);
|
|
69
|
+
transform: translateX(0);
|
|
70
|
+
transition: transform var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host([icons]) [part='deselected-icon'],
|
|
74
|
+
:host([icons][checked]) [part='selected-icon'],
|
|
75
|
+
:host([show-only-selected-icon][checked]) [part='selected-icon'] {
|
|
76
|
+
display: var(--rc-switch-icon-display, none);
|
|
77
|
+
place-items: center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([icons][checked]) [part='deselected-icon'],
|
|
81
|
+
:host([show-only-selected-icon]) [part='deselected-icon'] {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
:host([checked]) [part='track'] {
|
|
86
|
+
border-color: var(--rc-switch-selected-track-border-color, Highlight);
|
|
87
|
+
background: var(--rc-switch-selected-track-bg, Highlight);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
:host([checked]) [part='thumb'] {
|
|
91
|
+
inline-size: var(--rc-switch-selected-thumb-size, 1.5rem);
|
|
92
|
+
block-size: var(--rc-switch-selected-thumb-size, 1.5rem);
|
|
93
|
+
background: var(--rc-switch-selected-thumb-bg, HighlightText);
|
|
94
|
+
transform: translateX(var(--rc-switch-thumb-translate, 1.125rem));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:host([checked]) [part='selected-icon'],
|
|
98
|
+
:host([checked]) [part='deselected-icon'] {
|
|
99
|
+
transform: translateX(var(--rc-switch-thumb-translate, 1.125rem));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:host(:focus-within) [part='track'] {
|
|
103
|
+
outline: var(--rc-switch-focus-ring, 2px solid Highlight);
|
|
104
|
+
outline-offset: var(--rc-switch-focus-ring-offset, 2px);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([disabled]) {
|
|
108
|
+
opacity: var(--rc-switch-disabled-opacity, 0.5);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@media (prefers-reduced-motion: reduce) {
|
|
112
|
+
[part='track'],
|
|
113
|
+
[part='thumb'],
|
|
114
|
+
[part='selected-icon'],
|
|
115
|
+
[part='deselected-icon'] {
|
|
116
|
+
transition-duration: 0ms;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@media (forced-colors: active) {
|
|
121
|
+
[part='track'] {
|
|
122
|
+
forced-color-adjust: none;
|
|
123
|
+
border-color: ButtonText;
|
|
124
|
+
background: ButtonFace;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([checked]) [part='track'] {
|
|
128
|
+
border-color: Highlight;
|
|
129
|
+
background: Highlight;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[part='thumb'] {
|
|
133
|
+
background: ButtonText;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host([checked]) [part='thumb'] {
|
|
137
|
+
background: HighlightText;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
var k = Object.defineProperty, b = Object.getOwnPropertyDescriptor, c = (d, e, t, a) => {
|
|
142
|
+
for (var i = a > 1 ? void 0 : a ? b(e, t) : e, n = d.length - 1, h; n >= 0; n--)
|
|
143
|
+
(h = d[n]) && (i = (a ? h(e, t, i) : h(i)) || i);
|
|
144
|
+
return a && i && k(e, t, i), i;
|
|
145
|
+
};
|
|
146
|
+
const o = class o extends u {
|
|
147
|
+
constructor() {
|
|
148
|
+
super(...arguments), this._defaultChecked = !1, this._checkedInitialized = !1, this._$input = null, this._inputObserver = null, this._$form = null, this._roleOwned = !1, this._disabledOwned = !1, this._slotMicrotaskQueued = !1, this.disabled = !1, this.icons = !1, this.showOnlySelectedIcon = !1, this._handleNativeChange = () => {
|
|
149
|
+
this._syncFromNative(), this.dispatchEvent(
|
|
150
|
+
new CustomEvent("rc-switch-change", {
|
|
151
|
+
bubbles: !0,
|
|
152
|
+
composed: !0,
|
|
153
|
+
detail: { checked: this.checked }
|
|
154
|
+
})
|
|
155
|
+
);
|
|
156
|
+
}, this._handleFormReset = () => {
|
|
157
|
+
queueMicrotask(() => this._syncFromNative());
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
get checked() {
|
|
161
|
+
return this._checked ?? this._defaultChecked;
|
|
162
|
+
}
|
|
163
|
+
set checked(e) {
|
|
164
|
+
const t = this.checked;
|
|
165
|
+
this._checked = e, this._checkedInitialized = !0, this._applyChecked(!1), this.requestUpdate("checked", t);
|
|
166
|
+
}
|
|
167
|
+
get defaultChecked() {
|
|
168
|
+
return this._defaultChecked;
|
|
169
|
+
}
|
|
170
|
+
set defaultChecked(e) {
|
|
171
|
+
const t = this._defaultChecked;
|
|
172
|
+
this._defaultChecked = e, !this._checkedInitialized && this._checked === void 0 && (this._applyChecked(!1), this.requestUpdate("checked", t)), this.requestUpdate("defaultChecked", t);
|
|
173
|
+
}
|
|
174
|
+
disconnectedCallback() {
|
|
175
|
+
this._inputObserver?.disconnect(), this._inputObserver = null, this._setForm(null), super.disconnectedCallback();
|
|
176
|
+
}
|
|
177
|
+
firstUpdated() {
|
|
178
|
+
this._syncNativeInput();
|
|
179
|
+
}
|
|
180
|
+
updated(e) {
|
|
181
|
+
e.has("disabled") && this._applyDisabled();
|
|
182
|
+
}
|
|
183
|
+
render() {
|
|
184
|
+
return p`
|
|
185
|
+
<span part="track" aria-hidden="true"></span>
|
|
186
|
+
<span part="thumb" aria-hidden="true"></span>
|
|
187
|
+
<span part="selected-icon" aria-hidden="true"><slot name="selected-icon">✓</slot></span>
|
|
188
|
+
<span part="deselected-icon" aria-hidden="true"><slot name="deselected-icon">–</slot></span>
|
|
189
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
_handleSlotChange() {
|
|
193
|
+
this._slotMicrotaskQueued || (this._slotMicrotaskQueued = !0, queueMicrotask(() => {
|
|
194
|
+
this._slotMicrotaskQueued = !1, this.isConnected && this._syncNativeInput();
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
_syncNativeInput() {
|
|
198
|
+
const e = this.querySelector(':scope > input[type="checkbox"]');
|
|
199
|
+
if (e === this._$input) {
|
|
200
|
+
this._applyNativeSemantics(), this._applyChecked(!1), this._applyDisabled();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this._$input?.removeEventListener("change", this._handleNativeChange), this._inputObserver?.disconnect(), this._inputObserver = null, this._$input = e, this._roleOwned = !1, this._disabledOwned = !1, this._setForm(e?.form ?? null), e && (!this._checkedInitialized && this._checked === void 0 && (this._defaultChecked = e.defaultChecked || e.checked, this._checked = e.checked), e.addEventListener("change", this._handleNativeChange), this._inputObserver = new MutationObserver(() => {
|
|
204
|
+
this._applyNativeSemantics(), this._syncFromNative();
|
|
205
|
+
}), this._inputObserver.observe(e, {
|
|
206
|
+
attributeFilter: ["checked", "disabled", "role"]
|
|
207
|
+
})), this._applyNativeSemantics(), this._applyChecked(!1), this._applyDisabled();
|
|
208
|
+
}
|
|
209
|
+
_syncFromNative() {
|
|
210
|
+
const e = this._$input;
|
|
211
|
+
if (!e)
|
|
212
|
+
return;
|
|
213
|
+
const t = this.checked;
|
|
214
|
+
this._checked = e.checked, this._checkedInitialized = !0, this.toggleAttribute("checked", e.checked), this.requestUpdate("checked", t);
|
|
215
|
+
}
|
|
216
|
+
_applyNativeSemantics() {
|
|
217
|
+
const e = this._$input;
|
|
218
|
+
e && (e.hasAttribute("role") ? this._roleOwned && e.getAttribute("role") !== "switch" && (this._roleOwned = !1) : (e.setAttribute("role", "switch"), this._roleOwned = !0));
|
|
219
|
+
}
|
|
220
|
+
_applyChecked(e) {
|
|
221
|
+
const t = this._$input;
|
|
222
|
+
if (!t) {
|
|
223
|
+
this.toggleAttribute("checked", this.checked);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
t.checked = this.checked, e && (t.defaultChecked = this._defaultChecked), this.toggleAttribute("checked", t.checked);
|
|
227
|
+
}
|
|
228
|
+
_applyDisabled() {
|
|
229
|
+
const e = this._$input;
|
|
230
|
+
e && (this.disabled ? (e.disabled || (this._disabledOwned = !0), e.disabled = !0) : this._disabledOwned && (e.disabled = !1, this._disabledOwned = !1));
|
|
231
|
+
}
|
|
232
|
+
_setForm(e) {
|
|
233
|
+
this._$form?.removeEventListener("reset", this._handleFormReset), this._$form = e, this._$form?.addEventListener("reset", this._handleFormReset);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
o.styles = v;
|
|
237
|
+
let s = o;
|
|
238
|
+
c([
|
|
239
|
+
r({ type: Boolean, reflect: !0 })
|
|
240
|
+
], s.prototype, "checked", 1);
|
|
241
|
+
c([
|
|
242
|
+
r({ type: Boolean, attribute: "default-checked" })
|
|
243
|
+
], s.prototype, "defaultChecked", 1);
|
|
244
|
+
c([
|
|
245
|
+
r({ type: Boolean, reflect: !0 })
|
|
246
|
+
], s.prototype, "disabled", 2);
|
|
247
|
+
c([
|
|
248
|
+
r({ type: Boolean, reflect: !0 })
|
|
249
|
+
], s.prototype, "icons", 2);
|
|
250
|
+
c([
|
|
251
|
+
r({ type: Boolean, attribute: "show-only-selected-icon", reflect: !0 })
|
|
252
|
+
], s.prototype, "showOnlySelectedIcon", 2);
|
|
253
|
+
export {
|
|
254
|
+
s as R
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=rc-switch-98TbWbUy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rc-switch-98TbWbUy.js","sources":["../src/rc-switch.styles.ts","../src/rc-switch.ts"],"sourcesContent":["import { css } from 'lit';\n\nexport const switchStyles = css`\n :host {\n display: inline-grid;\n inline-size: var(--rc-switch-track-inline-size);\n block-size: var(--rc-switch-track-block-size);\n position: relative;\n color-scheme: inherit;\n vertical-align: middle;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n ::slotted(input[type='checkbox']) {\n appearance: var(--rc-switch-native-appearance, revert);\n grid-area: 1 / 1;\n inline-size: var(--rc-switch-native-inline-size, revert);\n block-size: var(--rc-switch-native-block-size, revert);\n margin: var(--rc-switch-native-margin, revert);\n opacity: var(--rc-switch-native-opacity, revert);\n }\n\n [part='track'],\n [part='thumb'],\n [part='selected-icon'],\n [part='deselected-icon'] {\n pointer-events: none;\n grid-area: 1 / 1;\n }\n\n [part='track'] {\n display: var(--rc-switch-decoration-display, none);\n border: var(--rc-switch-track-border, 2px solid ButtonBorder);\n border-radius: var(--rc-switch-track-radius, 9999px);\n background: var(--rc-switch-track-bg, ButtonFace);\n transition:\n background-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),\n border-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);\n }\n\n [part='thumb'] {\n display: var(--rc-switch-decoration-display, none);\n align-self: center;\n justify-self: start;\n inline-size: var(--rc-switch-thumb-size, 1rem);\n block-size: var(--rc-switch-thumb-size, 1rem);\n margin-inline-start: var(--rc-switch-thumb-offset, 0.375rem);\n border-radius: var(--rc-switch-thumb-radius, 9999px);\n background: var(--rc-switch-thumb-bg, ButtonText);\n transform: translateX(0);\n transition:\n background-color var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),\n inline-size var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),\n block-size var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease),\n transform var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);\n }\n\n [part='selected-icon'],\n [part='deselected-icon'] {\n place-self: center start;\n display: none;\n inline-size: var(--rc-switch-icon-size, 1rem);\n block-size: var(--rc-switch-icon-size, 1rem);\n margin-inline-start: var(--rc-switch-thumb-offset, 0.375rem);\n color: var(--rc-switch-icon-color, Canvas);\n transform: translateX(0);\n transition: transform var(--rc-switch-duration, 150ms) var(--rc-switch-easing, ease);\n }\n\n :host([icons]) [part='deselected-icon'],\n :host([icons][checked]) [part='selected-icon'],\n :host([show-only-selected-icon][checked]) [part='selected-icon'] {\n display: var(--rc-switch-icon-display, none);\n place-items: center;\n }\n\n :host([icons][checked]) [part='deselected-icon'],\n :host([show-only-selected-icon]) [part='deselected-icon'] {\n display: none;\n }\n\n :host([checked]) [part='track'] {\n border-color: var(--rc-switch-selected-track-border-color, Highlight);\n background: var(--rc-switch-selected-track-bg, Highlight);\n }\n\n :host([checked]) [part='thumb'] {\n inline-size: var(--rc-switch-selected-thumb-size, 1.5rem);\n block-size: var(--rc-switch-selected-thumb-size, 1.5rem);\n background: var(--rc-switch-selected-thumb-bg, HighlightText);\n transform: translateX(var(--rc-switch-thumb-translate, 1.125rem));\n }\n\n :host([checked]) [part='selected-icon'],\n :host([checked]) [part='deselected-icon'] {\n transform: translateX(var(--rc-switch-thumb-translate, 1.125rem));\n }\n\n :host(:focus-within) [part='track'] {\n outline: var(--rc-switch-focus-ring, 2px solid Highlight);\n outline-offset: var(--rc-switch-focus-ring-offset, 2px);\n }\n\n :host([disabled]) {\n opacity: var(--rc-switch-disabled-opacity, 0.5);\n }\n\n @media (prefers-reduced-motion: reduce) {\n [part='track'],\n [part='thumb'],\n [part='selected-icon'],\n [part='deselected-icon'] {\n transition-duration: 0ms;\n }\n }\n\n @media (forced-colors: active) {\n [part='track'] {\n forced-color-adjust: none;\n border-color: ButtonText;\n background: ButtonFace;\n }\n\n :host([checked]) [part='track'] {\n border-color: Highlight;\n background: Highlight;\n }\n\n [part='thumb'] {\n background: ButtonText;\n }\n\n :host([checked]) [part='thumb'] {\n background: HighlightText;\n }\n }\n`;\n\nexport default switchStyles;\n","import { LitElement, html } from 'lit';\nimport type { PropertyValues } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport switchStyles from './rc-switch.styles.js';\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'rc-switch': RCSwitch;\n }\n\n interface HTMLElementEventMap {\n 'rc-switch-change': CustomEvent<RCSwitchChangeDetail>;\n }\n}\n\n/** Detail payload for `rc-switch-change`. */\nexport interface RCSwitchChangeDetail {\n /** Current checked state after user interaction. */\n checked: boolean;\n}\n\n/**\n * Switch wrapper that enhances a direct native checkbox input.\n *\n * @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-switch rc-switch docs}\n * @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/switch/ WAI-ARIA switch pattern}\n *\n * @slot - A direct native `<input type=\"checkbox\">` child.\n *\n * @fires rc-switch-change - Fired after user interaction changes the checked state.\n *\n * @csspart track - Visual switch track.\n * @csspart thumb - Visual switch thumb.\n * @csspart selected-icon - Optional selected-state icon container.\n * @csspart deselected-icon - Optional deselected-state icon container.\n *\n * @attr checked - Current checked state. Host writes are silent.\n * @attr default-checked - Initial checked state for uncontrolled usage.\n * @attr disabled - Mirrors disabled state to the native checkbox.\n * @attr icons - Shows both selected and deselected icon containers.\n * @attr show-only-selected-icon - Shows only the selected icon container.\n *\n * @cssprop [--rc-switch-track-inline-size] - Track inline size. No built-in default; a theme\n * must set this for the switch to render with a visible size.\n * @cssprop [--rc-switch-track-block-size] - Track block size. No built-in default; a theme must\n * set this for the switch to render with a visible size.\n * @cssprop [--rc-switch-native-appearance=revert] - Slotted native checkbox `appearance`.\n * @cssprop [--rc-switch-native-inline-size=revert] - Slotted native checkbox inline size.\n * @cssprop [--rc-switch-native-block-size=revert] - Slotted native checkbox block size.\n * @cssprop [--rc-switch-native-margin=revert] - Slotted native checkbox margin.\n * @cssprop [--rc-switch-native-opacity=revert] - Slotted native checkbox opacity.\n * @cssprop [--rc-switch-decoration-display=none] - Display of the track/thumb/icon decoration.\n * Themes set this to `block` (or similar) to opt into the decorated switch look.\n * @cssprop [--rc-switch-track-border=2px solid ButtonBorder] - Track border.\n * @cssprop [--rc-switch-track-radius=9999px] - Track and thumb border radius.\n * @cssprop [--rc-switch-track-bg=ButtonFace] - Unselected track background.\n * @cssprop [--rc-switch-duration=150ms] - Track/thumb/icon transition duration.\n * @cssprop [--rc-switch-easing=ease] - Track/thumb/icon transition easing.\n * @cssprop [--rc-switch-thumb-size=1rem] - Unselected thumb inline and block size.\n * @cssprop [--rc-switch-thumb-offset=0.375rem] - Thumb and icon inline start offset within the\n * track.\n * @cssprop [--rc-switch-thumb-radius=9999px] - Thumb border radius.\n * @cssprop [--rc-switch-thumb-bg=ButtonText] - Unselected thumb background.\n * @cssprop [--rc-switch-icon-size=1rem] - Selected/deselected icon container size.\n * @cssprop [--rc-switch-icon-color=Canvas] - Icon color.\n * @cssprop [--rc-switch-icon-display=none] - Display of the active icon container when `icons`\n * or `show-only-selected-icon` is set.\n * @cssprop [--rc-switch-selected-track-border-color=Highlight] - Selected track border color.\n * @cssprop [--rc-switch-selected-track-bg=Highlight] - Selected track background.\n * @cssprop [--rc-switch-selected-thumb-size=1.5rem] - Selected thumb inline and block size.\n * @cssprop [--rc-switch-selected-thumb-bg=HighlightText] - Selected thumb background.\n * @cssprop [--rc-switch-thumb-translate=1.125rem] - Inline-axis translation applied to the thumb\n * and icons when selected.\n * @cssprop [--rc-switch-focus-ring=2px solid Highlight] - Track focus ring, shown on\n * focus-within.\n * @cssprop [--rc-switch-focus-ring-offset=2px] - Track focus ring offset.\n * @cssprop [--rc-switch-disabled-opacity=0.5] - Host opacity while `disabled`.\n */\nexport class RCSwitch extends LitElement {\n static override styles = switchStyles;\n\n private _checked: boolean | undefined;\n private _defaultChecked = false;\n private _checkedInitialized = false;\n private _$input: HTMLInputElement | null = null;\n private _inputObserver: MutationObserver | null = null;\n private _$form: HTMLFormElement | null = null;\n private _roleOwned = false;\n private _disabledOwned = false;\n private _slotMicrotaskQueued = false;\n\n /** Current checked state. Host writes are silent. */\n @property({ type: Boolean, reflect: true })\n get checked(): boolean {\n return this._checked ?? this._defaultChecked;\n }\n\n set checked(value: boolean | undefined) {\n const oldValue = this.checked;\n\n this._checked = value;\n this._checkedInitialized = true;\n this._applyChecked(false);\n this.requestUpdate('checked', oldValue);\n }\n\n /** Initial checked state for uncontrolled usage. */\n @property({ type: Boolean, attribute: 'default-checked' })\n get defaultChecked(): boolean {\n return this._defaultChecked;\n }\n\n set defaultChecked(value: boolean) {\n const oldValue = this._defaultChecked;\n\n this._defaultChecked = value;\n\n if (!this._checkedInitialized && this._checked === undefined) {\n this._applyChecked(false);\n this.requestUpdate('checked', oldValue);\n }\n\n this.requestUpdate('defaultChecked', oldValue);\n }\n\n /** Mirror disabled state to the native checkbox. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** Show selected and deselected icon affordance containers. */\n @property({ type: Boolean, reflect: true })\n icons = false;\n\n /** Show only the selected icon affordance container. */\n @property({ type: Boolean, attribute: 'show-only-selected-icon', reflect: true })\n showOnlySelectedIcon = false;\n\n override disconnectedCallback(): void {\n this._inputObserver?.disconnect();\n this._inputObserver = null;\n this._setForm(null);\n super.disconnectedCallback();\n }\n\n protected override firstUpdated(): void {\n this._syncNativeInput();\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (changed.has('disabled')) {\n this._applyDisabled();\n }\n }\n\n protected override render() {\n return html`\n <span part=\"track\" aria-hidden=\"true\"></span>\n <span part=\"thumb\" aria-hidden=\"true\"></span>\n <span part=\"selected-icon\" aria-hidden=\"true\"><slot name=\"selected-icon\">✓</slot></span>\n <span part=\"deselected-icon\" aria-hidden=\"true\"><slot name=\"deselected-icon\">–</slot></span>\n <slot @slotchange=${this._handleSlotChange}></slot>\n `;\n }\n\n private _handleSlotChange(): void {\n if (this._slotMicrotaskQueued) {\n return;\n }\n\n this._slotMicrotaskQueued = true;\n\n queueMicrotask(() => {\n this._slotMicrotaskQueued = false;\n\n if (this.isConnected) {\n this._syncNativeInput();\n }\n });\n }\n\n private _syncNativeInput(): void {\n const $nextInput = this.querySelector<HTMLInputElement>(':scope > input[type=\"checkbox\"]');\n\n if (!$nextInput && import.meta.env.DEV) {\n console.warn(\n '[rc-switch] No direct child <input type=\"checkbox\"> found. Place a native checkbox inside <rc-switch>.',\n this,\n );\n }\n\n if ($nextInput === this._$input) {\n this._applyNativeSemantics();\n this._applyChecked(false);\n this._applyDisabled();\n\n return;\n }\n\n this._$input?.removeEventListener('change', this._handleNativeChange);\n this._inputObserver?.disconnect();\n this._inputObserver = null;\n this._$input = $nextInput;\n this._roleOwned = false;\n this._disabledOwned = false;\n this._setForm($nextInput?.form ?? null);\n\n if ($nextInput) {\n if (!this._checkedInitialized && this._checked === undefined) {\n this._defaultChecked = $nextInput.defaultChecked || $nextInput.checked;\n this._checked = $nextInput.checked;\n }\n\n $nextInput.addEventListener('change', this._handleNativeChange);\n\n this._inputObserver = new MutationObserver(() => {\n this._applyNativeSemantics();\n this._syncFromNative();\n });\n\n this._inputObserver.observe($nextInput, {\n attributeFilter: ['checked', 'disabled', 'role'],\n });\n }\n\n this._applyNativeSemantics();\n this._applyChecked(false);\n this._applyDisabled();\n }\n\n private readonly _handleNativeChange = (): void => {\n this._syncFromNative();\n\n this.dispatchEvent(\n new CustomEvent<RCSwitchChangeDetail>('rc-switch-change', {\n bubbles: true,\n composed: true,\n detail: { checked: this.checked },\n }),\n );\n };\n\n private _syncFromNative(): void {\n const $input = this._$input;\n\n if (!$input) {\n return;\n }\n\n const oldValue = this.checked;\n\n this._checked = $input.checked;\n this._checkedInitialized = true;\n this.toggleAttribute('checked', $input.checked);\n this.requestUpdate('checked', oldValue);\n }\n\n private _applyNativeSemantics(): void {\n const $input = this._$input;\n\n if (!$input) {\n return;\n }\n\n if (!$input.hasAttribute('role')) {\n $input.setAttribute('role', 'switch');\n this._roleOwned = true;\n } else if (this._roleOwned && $input.getAttribute('role') !== 'switch') {\n this._roleOwned = false;\n }\n }\n\n private _applyChecked(writeDefault: boolean): void {\n const $input = this._$input;\n\n if (!$input) {\n this.toggleAttribute('checked', this.checked);\n\n return;\n }\n\n $input.checked = this.checked;\n\n if (writeDefault) {\n $input.defaultChecked = this._defaultChecked;\n }\n\n this.toggleAttribute('checked', $input.checked);\n }\n\n private _applyDisabled(): void {\n const $input = this._$input;\n\n if (!$input) {\n return;\n }\n\n if (this.disabled) {\n if (!$input.disabled) {\n this._disabledOwned = true;\n }\n\n $input.disabled = true;\n } else if (this._disabledOwned) {\n $input.disabled = false;\n this._disabledOwned = false;\n }\n }\n\n private _setForm($form: HTMLFormElement | null): void {\n this._$form?.removeEventListener('reset', this._handleFormReset);\n this._$form = $form;\n this._$form?.addEventListener('reset', this._handleFormReset);\n }\n\n private readonly _handleFormReset = (): void => {\n queueMicrotask(() => this._syncFromNative());\n };\n}\n\nexport default RCSwitch;\n"],"names":["switchStyles","css","_RCSwitch","LitElement","value","oldValue","changed","html","$nextInput","$input","writeDefault","$form","RCSwitch","__decorateClass","property"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rc-switch-define.js","sources":["../src/define.ts"],"sourcesContent":["import RCSwitch from './rc-switch.js';\n\ncustomElements.get('rc-switch') || customElements.define('rc-switch', RCSwitch);\n"],"names":["RCSwitch"],"mappings":";AAEA,eAAe,IAAI,WAAW,KAAK,eAAe,OAAO,aAAaA,CAAQ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rc-switch.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'rc-switch': RCSwitch;
|
|
5
|
+
}
|
|
6
|
+
interface HTMLElementEventMap {
|
|
7
|
+
'rc-switch-change': CustomEvent<RCSwitchChangeDetail>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Detail payload for `rc-switch-change`. */
|
|
11
|
+
export interface RCSwitchChangeDetail {
|
|
12
|
+
/** Current checked state after user interaction. */
|
|
13
|
+
checked: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Switch wrapper that enhances a direct native checkbox input.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://richardcarls.github.io/rc-webcomponents/components/rc-switch rc-switch docs}
|
|
19
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/switch/ WAI-ARIA switch pattern}
|
|
20
|
+
*
|
|
21
|
+
* @slot - A direct native `<input type="checkbox">` child.
|
|
22
|
+
*
|
|
23
|
+
* @fires rc-switch-change - Fired after user interaction changes the checked state.
|
|
24
|
+
*
|
|
25
|
+
* @csspart track - Visual switch track.
|
|
26
|
+
* @csspart thumb - Visual switch thumb.
|
|
27
|
+
* @csspart selected-icon - Optional selected-state icon container.
|
|
28
|
+
* @csspart deselected-icon - Optional deselected-state icon container.
|
|
29
|
+
*
|
|
30
|
+
* @attr checked - Current checked state. Host writes are silent.
|
|
31
|
+
* @attr default-checked - Initial checked state for uncontrolled usage.
|
|
32
|
+
* @attr disabled - Mirrors disabled state to the native checkbox.
|
|
33
|
+
* @attr icons - Shows both selected and deselected icon containers.
|
|
34
|
+
* @attr show-only-selected-icon - Shows only the selected icon container.
|
|
35
|
+
*
|
|
36
|
+
* @cssprop [--rc-switch-track-inline-size] - Track inline size. No built-in default; a theme
|
|
37
|
+
* must set this for the switch to render with a visible size.
|
|
38
|
+
* @cssprop [--rc-switch-track-block-size] - Track block size. No built-in default; a theme must
|
|
39
|
+
* set this for the switch to render with a visible size.
|
|
40
|
+
* @cssprop [--rc-switch-native-appearance=revert] - Slotted native checkbox `appearance`.
|
|
41
|
+
* @cssprop [--rc-switch-native-inline-size=revert] - Slotted native checkbox inline size.
|
|
42
|
+
* @cssprop [--rc-switch-native-block-size=revert] - Slotted native checkbox block size.
|
|
43
|
+
* @cssprop [--rc-switch-native-margin=revert] - Slotted native checkbox margin.
|
|
44
|
+
* @cssprop [--rc-switch-native-opacity=revert] - Slotted native checkbox opacity.
|
|
45
|
+
* @cssprop [--rc-switch-decoration-display=none] - Display of the track/thumb/icon decoration.
|
|
46
|
+
* Themes set this to `block` (or similar) to opt into the decorated switch look.
|
|
47
|
+
* @cssprop [--rc-switch-track-border=2px solid ButtonBorder] - Track border.
|
|
48
|
+
* @cssprop [--rc-switch-track-radius=9999px] - Track and thumb border radius.
|
|
49
|
+
* @cssprop [--rc-switch-track-bg=ButtonFace] - Unselected track background.
|
|
50
|
+
* @cssprop [--rc-switch-duration=150ms] - Track/thumb/icon transition duration.
|
|
51
|
+
* @cssprop [--rc-switch-easing=ease] - Track/thumb/icon transition easing.
|
|
52
|
+
* @cssprop [--rc-switch-thumb-size=1rem] - Unselected thumb inline and block size.
|
|
53
|
+
* @cssprop [--rc-switch-thumb-offset=0.375rem] - Thumb and icon inline start offset within the
|
|
54
|
+
* track.
|
|
55
|
+
* @cssprop [--rc-switch-thumb-radius=9999px] - Thumb border radius.
|
|
56
|
+
* @cssprop [--rc-switch-thumb-bg=ButtonText] - Unselected thumb background.
|
|
57
|
+
* @cssprop [--rc-switch-icon-size=1rem] - Selected/deselected icon container size.
|
|
58
|
+
* @cssprop [--rc-switch-icon-color=Canvas] - Icon color.
|
|
59
|
+
* @cssprop [--rc-switch-icon-display=none] - Display of the active icon container when `icons`
|
|
60
|
+
* or `show-only-selected-icon` is set.
|
|
61
|
+
* @cssprop [--rc-switch-selected-track-border-color=Highlight] - Selected track border color.
|
|
62
|
+
* @cssprop [--rc-switch-selected-track-bg=Highlight] - Selected track background.
|
|
63
|
+
* @cssprop [--rc-switch-selected-thumb-size=1.5rem] - Selected thumb inline and block size.
|
|
64
|
+
* @cssprop [--rc-switch-selected-thumb-bg=HighlightText] - Selected thumb background.
|
|
65
|
+
* @cssprop [--rc-switch-thumb-translate=1.125rem] - Inline-axis translation applied to the thumb
|
|
66
|
+
* and icons when selected.
|
|
67
|
+
* @cssprop [--rc-switch-focus-ring=2px solid Highlight] - Track focus ring, shown on
|
|
68
|
+
* focus-within.
|
|
69
|
+
* @cssprop [--rc-switch-focus-ring-offset=2px] - Track focus ring offset.
|
|
70
|
+
* @cssprop [--rc-switch-disabled-opacity=0.5] - Host opacity while `disabled`.
|
|
71
|
+
*/
|
|
72
|
+
export declare class RCSwitch extends LitElement {
|
|
73
|
+
static styles: import('lit').CSSResult;
|
|
74
|
+
private _checked;
|
|
75
|
+
private _defaultChecked;
|
|
76
|
+
private _checkedInitialized;
|
|
77
|
+
private _$input;
|
|
78
|
+
private _inputObserver;
|
|
79
|
+
private _$form;
|
|
80
|
+
private _roleOwned;
|
|
81
|
+
private _disabledOwned;
|
|
82
|
+
private _slotMicrotaskQueued;
|
|
83
|
+
/** Current checked state. Host writes are silent. */
|
|
84
|
+
get checked(): boolean;
|
|
85
|
+
set checked(value: boolean | undefined);
|
|
86
|
+
/** Initial checked state for uncontrolled usage. */
|
|
87
|
+
get defaultChecked(): boolean;
|
|
88
|
+
set defaultChecked(value: boolean);
|
|
89
|
+
/** Mirror disabled state to the native checkbox. */
|
|
90
|
+
disabled: boolean;
|
|
91
|
+
/** Show selected and deselected icon affordance containers. */
|
|
92
|
+
icons: boolean;
|
|
93
|
+
/** Show only the selected icon affordance container. */
|
|
94
|
+
showOnlySelectedIcon: boolean;
|
|
95
|
+
disconnectedCallback(): void;
|
|
96
|
+
protected firstUpdated(): void;
|
|
97
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
98
|
+
protected render(): import('lit').TemplateResult<1>;
|
|
99
|
+
private _handleSlotChange;
|
|
100
|
+
private _syncNativeInput;
|
|
101
|
+
private readonly _handleNativeChange;
|
|
102
|
+
private _syncFromNative;
|
|
103
|
+
private _applyNativeSemantics;
|
|
104
|
+
private _applyChecked;
|
|
105
|
+
private _applyDisabled;
|
|
106
|
+
private _setForm;
|
|
107
|
+
private readonly _handleFormReset;
|
|
108
|
+
}
|
|
109
|
+
export default RCSwitch;
|
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rcarls/rc-switch",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "0.4.0",
|
|
7
|
+
"description": "Switch wrapper that enhances a native checkbox input.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/richardcarls/rc-webcomponents.git",
|
|
11
|
+
"directory": "packages/rc-switch"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://richardcarls.github.io/rc-webcomponents/components/rc-switch",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"module": "./dist/rc-switch.js",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/types/packages/rc-switch/src/index.d.ts",
|
|
24
|
+
"default": "./dist/rc-switch.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./define": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/types/packages/rc-switch/src/define.d.ts",
|
|
30
|
+
"default": "./dist/rc-switch-define.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/types/packages/rc-switch/src/index.d.ts",
|
|
35
|
+
"sideEffects": [
|
|
36
|
+
"./dist/rc-switch-define.js"
|
|
37
|
+
],
|
|
38
|
+
"customElements": "dist/custom-elements.json",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc && vite build && cem analyze",
|
|
41
|
+
"cem:analyze": "cem analyze",
|
|
42
|
+
"preview": "vite preview",
|
|
43
|
+
"test:browser": "vitest --run",
|
|
44
|
+
"test:browser:chrome": "vitest --run --project=chromium",
|
|
45
|
+
"test:browser:firefox": "vitest --run --project=firefox"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@custom-elements-manifest/analyzer": "0.11.0",
|
|
49
|
+
"@vitest/browser-playwright": "4.1.5",
|
|
50
|
+
"lit": "^3.0.0",
|
|
51
|
+
"playwright": "^1.56.0",
|
|
52
|
+
"rollup": "^4.60.2",
|
|
53
|
+
"typescript": "~5.9.3",
|
|
54
|
+
"vite": "^7.1.7",
|
|
55
|
+
"vite-plugin-dts": "^4.5.4",
|
|
56
|
+
"vitest": "^4.0.6",
|
|
57
|
+
"vitest-browser-lit": "^1.0.1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"lit": "^3.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|