@openelement/ui 1.0.0-alpha.1 → 1.0.0-alpha.11
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/CUSTOMIZATION.md +272 -0
- package/README.md +59 -54
- package/package.json +19 -33
- package/src/component-recipes.js +39 -100
- package/src/control-recipe.css +21 -0
- package/src/generated-manifest.json +13 -160
- package/src/index.d.ts +10 -42
- package/src/index.js +10 -46
- package/src/instance-state.d.ts +16 -0
- package/src/instance-state.js +30 -24
- package/src/manifest.d.ts +5 -9
- package/src/manifest.js +6 -11
- package/src/open-button.css +120 -0
- package/src/open-button.d.ts +296 -898
- package/src/open-button.js +1130 -1436
- package/src/open-code-block.css +46 -0
- package/src/open-code-block.d.ts +158 -168
- package/src/open-code-block.js +224 -468
- package/src/open-dialog.css +137 -0
- package/src/open-dialog.d.ts +241 -424
- package/src/open-dialog.js +626 -903
- package/src/open-dropdown.css +28 -0
- package/src/open-dropdown.d.ts +195 -252
- package/src/open-dropdown.js +352 -494
- package/src/open-input.css +80 -0
- package/src/open-input.d.ts +404 -1420
- package/src/open-input.js +1789 -2170
- package/src/open-theme-toggle.css +53 -0
- package/src/open-theme-toggle.d.ts +171 -287
- package/src/open-theme-toggle.js +512 -801
- package/src/overlay-recipe.css +9 -0
- package/src/register.d.ts +4 -1
- package/src/register.js +19 -58
- package/src/surface-recipe.css +10 -0
- package/src/theme.css +206 -0
- package/THIRD_PARTY_NOTICES.md +0 -45
- package/src/open-badge.d.ts +0 -185
- package/src/open-badge.js +0 -296
- package/src/open-callout.d.ts +0 -402
- package/src/open-callout.js +0 -603
- package/src/open-card.d.ts +0 -168
- package/src/open-card.js +0 -310
- package/src/open-props-tokens.d.ts +0 -9
- package/src/open-props-tokens.js +0 -459
- package/src/open-tabs.d.ts +0 -218
- package/src/open-tabs.js +0 -401
- package/src/semantic-tokens.css +0 -413
package/src/open-theme-toggle.js
CHANGED
|
@@ -1,806 +1,517 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { readInstanceState, writeInstanceState } from "./instance-state.js";
|
|
2
|
+
import { log } from "./component-recipes.js";
|
|
3
|
+
import { OpenElement } from "@openelement/element";
|
|
4
|
+
import openThemeToggleStyles from "./open-theme-toggle.css";
|
|
5
|
+
//#region src/open-theme-toggle.tsx
|
|
5
6
|
const __partProgram = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
0
|
|
375
|
-
],
|
|
376
|
-
"node": "e0"
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
],
|
|
380
|
-
"regions": [],
|
|
381
|
-
"dependencies": [
|
|
382
|
-
{
|
|
383
|
-
"signal": "theme",
|
|
384
|
-
"owner": {
|
|
385
|
-
"kind": "part",
|
|
386
|
-
"index": 0
|
|
387
|
-
},
|
|
388
|
-
"location": "p0"
|
|
389
|
-
}
|
|
390
|
-
],
|
|
391
|
-
"locations": [
|
|
392
|
-
{
|
|
393
|
-
"id": "e0",
|
|
394
|
-
"kind": "element",
|
|
395
|
-
"tag": "button",
|
|
396
|
-
"path": [
|
|
397
|
-
0
|
|
398
|
-
]
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
"id": "p0",
|
|
402
|
-
"kind": "sink",
|
|
403
|
-
"part": 0,
|
|
404
|
-
"node": "e0",
|
|
405
|
-
"path": [
|
|
406
|
-
0
|
|
407
|
-
]
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
"id": "p1",
|
|
411
|
-
"kind": "sink",
|
|
412
|
-
"part": 1,
|
|
413
|
-
"node": "e0",
|
|
414
|
-
"path": [
|
|
415
|
-
0
|
|
416
|
-
]
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
"id": "e1",
|
|
420
|
-
"kind": "element",
|
|
421
|
-
"tag": "svg",
|
|
422
|
-
"path": [
|
|
423
|
-
0,
|
|
424
|
-
0
|
|
425
|
-
]
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
"id": "e2",
|
|
429
|
-
"kind": "element",
|
|
430
|
-
"tag": "circle",
|
|
431
|
-
"path": [
|
|
432
|
-
0,
|
|
433
|
-
0,
|
|
434
|
-
0
|
|
435
|
-
]
|
|
436
|
-
},
|
|
437
|
-
{
|
|
438
|
-
"id": "e3",
|
|
439
|
-
"kind": "element",
|
|
440
|
-
"tag": "line",
|
|
441
|
-
"path": [
|
|
442
|
-
0,
|
|
443
|
-
0,
|
|
444
|
-
1
|
|
445
|
-
]
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
"id": "e4",
|
|
449
|
-
"kind": "element",
|
|
450
|
-
"tag": "line",
|
|
451
|
-
"path": [
|
|
452
|
-
0,
|
|
453
|
-
0,
|
|
454
|
-
2
|
|
455
|
-
]
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
"id": "e5",
|
|
459
|
-
"kind": "element",
|
|
460
|
-
"tag": "line",
|
|
461
|
-
"path": [
|
|
462
|
-
0,
|
|
463
|
-
0,
|
|
464
|
-
3
|
|
465
|
-
]
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
"id": "e6",
|
|
469
|
-
"kind": "element",
|
|
470
|
-
"tag": "line",
|
|
471
|
-
"path": [
|
|
472
|
-
0,
|
|
473
|
-
0,
|
|
474
|
-
4
|
|
475
|
-
]
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
"id": "e7",
|
|
479
|
-
"kind": "element",
|
|
480
|
-
"tag": "line",
|
|
481
|
-
"path": [
|
|
482
|
-
0,
|
|
483
|
-
0,
|
|
484
|
-
5
|
|
485
|
-
]
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
"id": "e8",
|
|
489
|
-
"kind": "element",
|
|
490
|
-
"tag": "line",
|
|
491
|
-
"path": [
|
|
492
|
-
0,
|
|
493
|
-
0,
|
|
494
|
-
6
|
|
495
|
-
]
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
"id": "e9",
|
|
499
|
-
"kind": "element",
|
|
500
|
-
"tag": "line",
|
|
501
|
-
"path": [
|
|
502
|
-
0,
|
|
503
|
-
0,
|
|
504
|
-
7
|
|
505
|
-
]
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
"id": "e10",
|
|
509
|
-
"kind": "element",
|
|
510
|
-
"tag": "line",
|
|
511
|
-
"path": [
|
|
512
|
-
0,
|
|
513
|
-
0,
|
|
514
|
-
8
|
|
515
|
-
]
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
"id": "e11",
|
|
519
|
-
"kind": "element",
|
|
520
|
-
"tag": "svg",
|
|
521
|
-
"path": [
|
|
522
|
-
0,
|
|
523
|
-
1
|
|
524
|
-
]
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
"id": "e12",
|
|
528
|
-
"kind": "element",
|
|
529
|
-
"tag": "path",
|
|
530
|
-
"path": [
|
|
531
|
-
0,
|
|
532
|
-
1,
|
|
533
|
-
0
|
|
534
|
-
]
|
|
535
|
-
}
|
|
536
|
-
],
|
|
537
|
-
"metadata": {
|
|
538
|
-
"tag": "open-theme-toggle",
|
|
539
|
-
"className": "OpenThemeToggle",
|
|
540
|
-
"sourceFile": "open-theme-toggle.tsx",
|
|
541
|
-
"properties": [
|
|
542
|
-
{
|
|
543
|
-
"name": "theme",
|
|
544
|
-
"attribute": "theme",
|
|
545
|
-
"type": "string",
|
|
546
|
-
"converter": "string",
|
|
547
|
-
"reflect": false,
|
|
548
|
-
"default": "dark"
|
|
549
|
-
}
|
|
550
|
-
],
|
|
551
|
-
"observedAttributes": [
|
|
552
|
-
"theme"
|
|
553
|
-
],
|
|
554
|
-
"cem": {
|
|
555
|
-
"tagName": "open-theme-toggle",
|
|
556
|
-
"className": "OpenThemeToggle",
|
|
557
|
-
"declaration": {
|
|
558
|
-
"name": "OpenThemeToggle",
|
|
559
|
-
"module": "open-theme-toggle.tsx"
|
|
560
|
-
},
|
|
561
|
-
"attributes": [
|
|
562
|
-
{
|
|
563
|
-
"name": "theme",
|
|
564
|
-
"fieldName": "theme",
|
|
565
|
-
"type": "string",
|
|
566
|
-
"reflect": false
|
|
567
|
-
}
|
|
568
|
-
],
|
|
569
|
-
"members": [
|
|
570
|
-
{
|
|
571
|
-
"name": "theme",
|
|
572
|
-
"fieldName": "theme",
|
|
573
|
-
"type": "string",
|
|
574
|
-
"attribute": "theme",
|
|
575
|
-
"reflect": false
|
|
576
|
-
}
|
|
577
|
-
]
|
|
578
|
-
}
|
|
579
|
-
}
|
|
7
|
+
"version": 1,
|
|
8
|
+
"tag": "open-theme-toggle",
|
|
9
|
+
"root": {
|
|
10
|
+
"id": "root",
|
|
11
|
+
"kind": "shadow-open",
|
|
12
|
+
"nodes": ["e0"]
|
|
13
|
+
},
|
|
14
|
+
"template": [{
|
|
15
|
+
"k": "el",
|
|
16
|
+
"id": "e0",
|
|
17
|
+
"tag": "button",
|
|
18
|
+
"attrs": [
|
|
19
|
+
["type", "button"],
|
|
20
|
+
["class", "theme-toggle"],
|
|
21
|
+
["part", "toggle"],
|
|
22
|
+
["aria-label", "Toggle theme"]
|
|
23
|
+
],
|
|
24
|
+
"children": [{
|
|
25
|
+
"k": "el",
|
|
26
|
+
"id": "e1",
|
|
27
|
+
"tag": "svg",
|
|
28
|
+
"attrs": [
|
|
29
|
+
["class", "icon-sun"],
|
|
30
|
+
["part", "icon-sun"],
|
|
31
|
+
["viewBox", "0 0 16 16"],
|
|
32
|
+
["fill", "none"],
|
|
33
|
+
["stroke", "currentColor"],
|
|
34
|
+
["stroke-width", "1.2"],
|
|
35
|
+
["stroke-linecap", "round"]
|
|
36
|
+
],
|
|
37
|
+
"children": [
|
|
38
|
+
{
|
|
39
|
+
"k": "el",
|
|
40
|
+
"id": "e2",
|
|
41
|
+
"tag": "circle",
|
|
42
|
+
"attrs": [
|
|
43
|
+
["cx", "8"],
|
|
44
|
+
["cy", "8"],
|
|
45
|
+
["r", "3"]
|
|
46
|
+
],
|
|
47
|
+
"children": []
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"k": "el",
|
|
51
|
+
"id": "e3",
|
|
52
|
+
"tag": "line",
|
|
53
|
+
"attrs": [
|
|
54
|
+
["x1", "8"],
|
|
55
|
+
["y1", "1"],
|
|
56
|
+
["x2", "8"],
|
|
57
|
+
["y2", "3"]
|
|
58
|
+
],
|
|
59
|
+
"children": []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"k": "el",
|
|
63
|
+
"id": "e4",
|
|
64
|
+
"tag": "line",
|
|
65
|
+
"attrs": [
|
|
66
|
+
["x1", "8"],
|
|
67
|
+
["y1", "13"],
|
|
68
|
+
["x2", "8"],
|
|
69
|
+
["y2", "15"]
|
|
70
|
+
],
|
|
71
|
+
"children": []
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"k": "el",
|
|
75
|
+
"id": "e5",
|
|
76
|
+
"tag": "line",
|
|
77
|
+
"attrs": [
|
|
78
|
+
["x1", "1"],
|
|
79
|
+
["y1", "8"],
|
|
80
|
+
["x2", "3"],
|
|
81
|
+
["y2", "8"]
|
|
82
|
+
],
|
|
83
|
+
"children": []
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"k": "el",
|
|
87
|
+
"id": "e6",
|
|
88
|
+
"tag": "line",
|
|
89
|
+
"attrs": [
|
|
90
|
+
["x1", "13"],
|
|
91
|
+
["y1", "8"],
|
|
92
|
+
["x2", "15"],
|
|
93
|
+
["y2", "8"]
|
|
94
|
+
],
|
|
95
|
+
"children": []
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"k": "el",
|
|
99
|
+
"id": "e7",
|
|
100
|
+
"tag": "line",
|
|
101
|
+
"attrs": [
|
|
102
|
+
["x1", "3.05"],
|
|
103
|
+
["y1", "3.05"],
|
|
104
|
+
["x2", "4.46"],
|
|
105
|
+
["y2", "4.46"]
|
|
106
|
+
],
|
|
107
|
+
"children": []
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"k": "el",
|
|
111
|
+
"id": "e8",
|
|
112
|
+
"tag": "line",
|
|
113
|
+
"attrs": [
|
|
114
|
+
["x1", "11.54"],
|
|
115
|
+
["y1", "11.54"],
|
|
116
|
+
["x2", "12.95"],
|
|
117
|
+
["y2", "12.95"]
|
|
118
|
+
],
|
|
119
|
+
"children": []
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"k": "el",
|
|
123
|
+
"id": "e9",
|
|
124
|
+
"tag": "line",
|
|
125
|
+
"attrs": [
|
|
126
|
+
["x1", "3.05"],
|
|
127
|
+
["y1", "12.95"],
|
|
128
|
+
["x2", "4.46"],
|
|
129
|
+
["y2", "11.54"]
|
|
130
|
+
],
|
|
131
|
+
"children": []
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"k": "el",
|
|
135
|
+
"id": "e10",
|
|
136
|
+
"tag": "line",
|
|
137
|
+
"attrs": [
|
|
138
|
+
["x1", "11.54"],
|
|
139
|
+
["y1", "4.46"],
|
|
140
|
+
["x2", "12.95"],
|
|
141
|
+
["y2", "3.05"]
|
|
142
|
+
],
|
|
143
|
+
"children": []
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}, {
|
|
147
|
+
"k": "el",
|
|
148
|
+
"id": "e11",
|
|
149
|
+
"tag": "svg",
|
|
150
|
+
"attrs": [
|
|
151
|
+
["class", "icon-moon"],
|
|
152
|
+
["part", "icon-moon"],
|
|
153
|
+
["viewBox", "0 0 16 16"],
|
|
154
|
+
["fill", "none"],
|
|
155
|
+
["stroke", "currentColor"],
|
|
156
|
+
["stroke-width", "1.2"],
|
|
157
|
+
["stroke-linecap", "round"]
|
|
158
|
+
],
|
|
159
|
+
"children": [{
|
|
160
|
+
"k": "el",
|
|
161
|
+
"id": "e12",
|
|
162
|
+
"tag": "path",
|
|
163
|
+
"attrs": [["d", "M13.5 9.14A5.5 5.5 0 0 1 6.86 2.5 5.5 5.5 0 1 0 13.5 9.14Z"]],
|
|
164
|
+
"children": []
|
|
165
|
+
}]
|
|
166
|
+
}]
|
|
167
|
+
}],
|
|
168
|
+
"parts": [{
|
|
169
|
+
"k": "attr",
|
|
170
|
+
"signal": "theme",
|
|
171
|
+
"name": "data-theme",
|
|
172
|
+
"path": [0],
|
|
173
|
+
"index": 0,
|
|
174
|
+
"location": {
|
|
175
|
+
"id": "p0",
|
|
176
|
+
"kind": "sink",
|
|
177
|
+
"path": [0],
|
|
178
|
+
"node": "e0"
|
|
179
|
+
}
|
|
180
|
+
}, {
|
|
181
|
+
"k": "event",
|
|
182
|
+
"event": "click",
|
|
183
|
+
"handler": "handleToggle",
|
|
184
|
+
"action": {
|
|
185
|
+
"kind": "method",
|
|
186
|
+
"name": "handleToggle"
|
|
187
|
+
},
|
|
188
|
+
"path": [0],
|
|
189
|
+
"index": 1,
|
|
190
|
+
"location": {
|
|
191
|
+
"id": "p1",
|
|
192
|
+
"kind": "sink",
|
|
193
|
+
"path": [0],
|
|
194
|
+
"node": "e0"
|
|
195
|
+
}
|
|
196
|
+
}],
|
|
197
|
+
"regions": [],
|
|
198
|
+
"dependencies": [{
|
|
199
|
+
"signal": "theme",
|
|
200
|
+
"owner": {
|
|
201
|
+
"kind": "part",
|
|
202
|
+
"index": 0
|
|
203
|
+
},
|
|
204
|
+
"location": "p0"
|
|
205
|
+
}],
|
|
206
|
+
"locations": [
|
|
207
|
+
{
|
|
208
|
+
"id": "e0",
|
|
209
|
+
"kind": "element",
|
|
210
|
+
"tag": "button",
|
|
211
|
+
"path": [0]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "p0",
|
|
215
|
+
"kind": "sink",
|
|
216
|
+
"part": 0,
|
|
217
|
+
"node": "e0",
|
|
218
|
+
"path": [0]
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"id": "p1",
|
|
222
|
+
"kind": "sink",
|
|
223
|
+
"part": 1,
|
|
224
|
+
"node": "e0",
|
|
225
|
+
"path": [0]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"id": "e1",
|
|
229
|
+
"kind": "element",
|
|
230
|
+
"tag": "svg",
|
|
231
|
+
"path": [0, 0]
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"id": "e2",
|
|
235
|
+
"kind": "element",
|
|
236
|
+
"tag": "circle",
|
|
237
|
+
"path": [
|
|
238
|
+
0,
|
|
239
|
+
0,
|
|
240
|
+
0
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"id": "e3",
|
|
245
|
+
"kind": "element",
|
|
246
|
+
"tag": "line",
|
|
247
|
+
"path": [
|
|
248
|
+
0,
|
|
249
|
+
0,
|
|
250
|
+
1
|
|
251
|
+
]
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"id": "e4",
|
|
255
|
+
"kind": "element",
|
|
256
|
+
"tag": "line",
|
|
257
|
+
"path": [
|
|
258
|
+
0,
|
|
259
|
+
0,
|
|
260
|
+
2
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"id": "e5",
|
|
265
|
+
"kind": "element",
|
|
266
|
+
"tag": "line",
|
|
267
|
+
"path": [
|
|
268
|
+
0,
|
|
269
|
+
0,
|
|
270
|
+
3
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "e6",
|
|
275
|
+
"kind": "element",
|
|
276
|
+
"tag": "line",
|
|
277
|
+
"path": [
|
|
278
|
+
0,
|
|
279
|
+
0,
|
|
280
|
+
4
|
|
281
|
+
]
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
"id": "e7",
|
|
285
|
+
"kind": "element",
|
|
286
|
+
"tag": "line",
|
|
287
|
+
"path": [
|
|
288
|
+
0,
|
|
289
|
+
0,
|
|
290
|
+
5
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"id": "e8",
|
|
295
|
+
"kind": "element",
|
|
296
|
+
"tag": "line",
|
|
297
|
+
"path": [
|
|
298
|
+
0,
|
|
299
|
+
0,
|
|
300
|
+
6
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"id": "e9",
|
|
305
|
+
"kind": "element",
|
|
306
|
+
"tag": "line",
|
|
307
|
+
"path": [
|
|
308
|
+
0,
|
|
309
|
+
0,
|
|
310
|
+
7
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"id": "e10",
|
|
315
|
+
"kind": "element",
|
|
316
|
+
"tag": "line",
|
|
317
|
+
"path": [
|
|
318
|
+
0,
|
|
319
|
+
0,
|
|
320
|
+
8
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"id": "e11",
|
|
325
|
+
"kind": "element",
|
|
326
|
+
"tag": "svg",
|
|
327
|
+
"path": [0, 1]
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
"id": "e12",
|
|
331
|
+
"kind": "element",
|
|
332
|
+
"tag": "path",
|
|
333
|
+
"path": [
|
|
334
|
+
0,
|
|
335
|
+
1,
|
|
336
|
+
0
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
],
|
|
340
|
+
"metadata": {
|
|
341
|
+
"tag": "open-theme-toggle",
|
|
342
|
+
"className": "OpenThemeToggle",
|
|
343
|
+
"sourceFile": "open-theme-toggle.tsx",
|
|
344
|
+
"properties": [{
|
|
345
|
+
"name": "theme",
|
|
346
|
+
"attribute": "theme",
|
|
347
|
+
"type": "string",
|
|
348
|
+
"converter": "string",
|
|
349
|
+
"reflect": false,
|
|
350
|
+
"default": "dark"
|
|
351
|
+
}],
|
|
352
|
+
"observedAttributes": ["theme"],
|
|
353
|
+
"cem": {
|
|
354
|
+
"tagName": "open-theme-toggle",
|
|
355
|
+
"className": "OpenThemeToggle",
|
|
356
|
+
"declaration": {
|
|
357
|
+
"name": "OpenThemeToggle",
|
|
358
|
+
"module": "open-theme-toggle.tsx"
|
|
359
|
+
},
|
|
360
|
+
"attributes": [{
|
|
361
|
+
"name": "theme",
|
|
362
|
+
"fieldName": "theme",
|
|
363
|
+
"type": "string",
|
|
364
|
+
"reflect": false
|
|
365
|
+
}],
|
|
366
|
+
"members": [{
|
|
367
|
+
"name": "theme",
|
|
368
|
+
"fieldName": "theme",
|
|
369
|
+
"type": "string",
|
|
370
|
+
"attribute": "theme",
|
|
371
|
+
"reflect": false
|
|
372
|
+
}]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
580
375
|
};
|
|
581
|
-
const __compiledProperties = [
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
];
|
|
376
|
+
const __compiledProperties = [{
|
|
377
|
+
"name": "theme",
|
|
378
|
+
"attribute": "theme",
|
|
379
|
+
"type": "string",
|
|
380
|
+
"converter": "string",
|
|
381
|
+
"reflect": false,
|
|
382
|
+
"default": "dark"
|
|
383
|
+
}];
|
|
591
384
|
const __elementMetadata = {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
"name": "theme",
|
|
626
|
-
"fieldName": "theme",
|
|
627
|
-
"type": "string",
|
|
628
|
-
"attribute": "theme",
|
|
629
|
-
"reflect": false
|
|
630
|
-
}
|
|
631
|
-
]
|
|
632
|
-
}
|
|
385
|
+
"tag": "open-theme-toggle",
|
|
386
|
+
"className": "OpenThemeToggle",
|
|
387
|
+
"sourceFile": "open-theme-toggle.tsx",
|
|
388
|
+
"properties": [{
|
|
389
|
+
"name": "theme",
|
|
390
|
+
"attribute": "theme",
|
|
391
|
+
"type": "string",
|
|
392
|
+
"converter": "string",
|
|
393
|
+
"reflect": false,
|
|
394
|
+
"default": "dark"
|
|
395
|
+
}],
|
|
396
|
+
"observedAttributes": ["theme"],
|
|
397
|
+
"cem": {
|
|
398
|
+
"tagName": "open-theme-toggle",
|
|
399
|
+
"className": "OpenThemeToggle",
|
|
400
|
+
"declaration": {
|
|
401
|
+
"name": "OpenThemeToggle",
|
|
402
|
+
"module": "open-theme-toggle.tsx"
|
|
403
|
+
},
|
|
404
|
+
"attributes": [{
|
|
405
|
+
"name": "theme",
|
|
406
|
+
"fieldName": "theme",
|
|
407
|
+
"type": "string",
|
|
408
|
+
"reflect": false
|
|
409
|
+
}],
|
|
410
|
+
"members": [{
|
|
411
|
+
"name": "theme",
|
|
412
|
+
"fieldName": "theme",
|
|
413
|
+
"type": "string",
|
|
414
|
+
"attribute": "theme",
|
|
415
|
+
"reflect": false
|
|
416
|
+
}]
|
|
417
|
+
}
|
|
633
418
|
};
|
|
634
|
-
const __observedAttributes = [
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
419
|
+
const __observedAttributes = ["theme"];
|
|
420
|
+
const __compiledProps = { theme: {
|
|
421
|
+
type: String,
|
|
422
|
+
default: "dark",
|
|
423
|
+
reflect: false,
|
|
424
|
+
attribute: "theme"
|
|
425
|
+
} };
|
|
426
|
+
var OpenThemeToggle = class extends OpenElement {
|
|
427
|
+
static __partProgram = __partProgram;
|
|
428
|
+
static __compiledProperties = __compiledProperties;
|
|
429
|
+
static __elementMetadata = __elementMetadata;
|
|
430
|
+
static props = __compiledProps;
|
|
431
|
+
static observedAttributes = __observedAttributes;
|
|
432
|
+
static delegatesFocus = true;
|
|
433
|
+
static styles = [openThemeToggleStyles];
|
|
434
|
+
theme = "dark";
|
|
435
|
+
connectedCallback() {
|
|
436
|
+
super.connectedCallback();
|
|
437
|
+
this._requestAnimationFrame(() => this.initTheme());
|
|
438
|
+
}
|
|
439
|
+
onDsdHydrated() {
|
|
440
|
+
this._requestAnimationFrame(() => this.initTheme());
|
|
441
|
+
}
|
|
442
|
+
initTheme() {
|
|
443
|
+
if (readInstanceState(this, "initDone", () => false)) return;
|
|
444
|
+
writeInstanceState(this, "initDone", true);
|
|
445
|
+
const themeAttr = this.getAttribute("theme");
|
|
446
|
+
if (themeAttr === "light") this.theme = "light";
|
|
447
|
+
else if (themeAttr === "dark") this.theme = "dark";
|
|
448
|
+
else {
|
|
449
|
+
const docTheme = document.documentElement?.dataset?.theme;
|
|
450
|
+
if (docTheme === "light") this.theme = "light";
|
|
451
|
+
else if (docTheme === "dark") this.theme = "dark";
|
|
452
|
+
else {
|
|
453
|
+
let resolved = false;
|
|
454
|
+
try {
|
|
455
|
+
const saved = localStorage.getItem("open-theme");
|
|
456
|
+
if (saved === "light") {
|
|
457
|
+
this.theme = "light";
|
|
458
|
+
resolved = true;
|
|
459
|
+
} else if (saved === "dark") {
|
|
460
|
+
this.theme = "dark";
|
|
461
|
+
resolved = true;
|
|
462
|
+
}
|
|
463
|
+
} catch (e) {
|
|
464
|
+
log.debug("localStorage read unavailable:", e);
|
|
465
|
+
}
|
|
466
|
+
if (!resolved && globalThis.matchMedia) this.theme = globalThis.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
this.applyTheme(this.theme);
|
|
470
|
+
}
|
|
471
|
+
applyTheme(theme) {
|
|
472
|
+
const changed = readInstanceState(this, "lastPropagated", () => void 0) !== theme;
|
|
473
|
+
this.theme = theme;
|
|
474
|
+
this.setAttribute("data-theme", theme);
|
|
475
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
476
|
+
if (document.documentElement.style) document.documentElement.style.colorScheme = theme;
|
|
477
|
+
try {
|
|
478
|
+
const root = this.getRootNode();
|
|
479
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && root.host) root.host.setAttribute("data-theme", theme);
|
|
480
|
+
} catch (e) {
|
|
481
|
+
log.debug("root theme propagation unavailable:", e);
|
|
482
|
+
}
|
|
483
|
+
if (changed) {
|
|
484
|
+
writeInstanceState(this, "lastPropagated", theme);
|
|
485
|
+
this.dispatchThemeChange(theme);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
persistTheme(theme) {
|
|
489
|
+
try {
|
|
490
|
+
localStorage.setItem("open-theme", theme);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
log.debug("theme persistence unavailable:", e);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
handleToggle() {
|
|
496
|
+
const theme = this.theme === "light" ? "dark" : "light";
|
|
497
|
+
this.applyTheme(theme);
|
|
498
|
+
this.persistTheme(theme);
|
|
499
|
+
}
|
|
500
|
+
dispatchThemeChange(theme) {
|
|
501
|
+
try {
|
|
502
|
+
if (typeof CustomEvent !== "undefined" && typeof globalThis.dispatchEvent === "function") globalThis.dispatchEvent(new CustomEvent("open:theme-change", { detail: { theme } }));
|
|
503
|
+
} catch (e) {
|
|
504
|
+
log.debug("theme event dispatch unavailable:", e);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
attributeChangedCallback(name, old, val) {
|
|
508
|
+
super.attributeChangedCallback(name, old, val);
|
|
509
|
+
if (old === val) return;
|
|
510
|
+
if (name === "theme" && val) this.applyTheme(val === "light" ? "light" : "dark");
|
|
511
|
+
}
|
|
512
|
+
render() {
|
|
513
|
+
throw new Error("[open:compiled-element] open-theme-toggle is compiled to a Part Program; the runtime JSX render path is not available.");
|
|
514
|
+
}
|
|
644
515
|
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
static __compiledProperties = __compiledProperties;
|
|
648
|
-
static __elementMetadata = __elementMetadata;
|
|
649
|
-
static props = __compiledProps;
|
|
650
|
-
static observedAttributes = __observedAttributes;
|
|
651
|
-
static delegatesFocus = true;
|
|
652
|
-
static styles = [
|
|
653
|
-
recipe(`
|
|
654
|
-
:host {
|
|
655
|
-
display: inline-block;
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
.theme-toggle {
|
|
659
|
-
display: inline-flex;
|
|
660
|
-
align-items: center;
|
|
661
|
-
justify-content: center;
|
|
662
|
-
width: 38px; height: 38px; padding: 0;
|
|
663
|
-
border: var(--border-size-1) solid color-mix(in srgb, var(--border) 72%, var(--brand));
|
|
664
|
-
border-radius: var(--radius-round);
|
|
665
|
-
background: color-mix(in srgb, var(--bg-elevated) 76%, transparent);
|
|
666
|
-
color: var(--text-muted);
|
|
667
|
-
box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gray-0) 70%, transparent);
|
|
668
|
-
cursor: pointer;
|
|
669
|
-
transition: all var(--ease-2) var(--duration-2);
|
|
670
|
-
}
|
|
671
|
-
.theme-toggle:hover {
|
|
672
|
-
color: var(--text-primary);
|
|
673
|
-
border-color: var(--brand-light);
|
|
674
|
-
background: color-mix(in srgb, var(--brand-pale) 42%, var(--bg-elevated));
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
.theme-toggle:focus-visible {
|
|
678
|
-
outline: var(--focus-size, 2px) solid var(--focus-ring, var(--brand-light));
|
|
679
|
-
outline-offset: var(--focus-offset, 2px);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
.theme-toggle svg {
|
|
683
|
-
width: 16px;
|
|
684
|
-
height: 16px;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
.theme-toggle .icon-sun {
|
|
688
|
-
display: block;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
.theme-toggle .icon-moon {
|
|
692
|
-
display: none;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
.theme-toggle[data-theme='light'] .icon-sun {
|
|
696
|
-
display: none;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
.theme-toggle[data-theme='light'] .icon-moon {
|
|
700
|
-
display: block;
|
|
701
|
-
}
|
|
702
|
-
`)
|
|
703
|
-
];
|
|
704
|
-
theme = 'dark';
|
|
705
|
-
connectedCallback() {
|
|
706
|
-
super.connectedCallback();
|
|
707
|
-
this._requestAnimationFrame(()=>this.initTheme());
|
|
708
|
-
}
|
|
709
|
-
onDsdHydrated() {
|
|
710
|
-
this._requestAnimationFrame(()=>this.initTheme());
|
|
711
|
-
}
|
|
712
|
-
initTheme() {
|
|
713
|
-
if (readInstanceState(this, 'initDone', ()=>false)) return;
|
|
714
|
-
writeInstanceState(this, 'initDone', true);
|
|
715
|
-
const themeAttr = this.getAttribute('theme');
|
|
716
|
-
if (themeAttr === 'light') {
|
|
717
|
-
this.theme = 'light';
|
|
718
|
-
} else if (themeAttr === 'dark') {
|
|
719
|
-
this.theme = 'dark';
|
|
720
|
-
} else {
|
|
721
|
-
const docTheme = document.documentElement?.dataset?.theme;
|
|
722
|
-
if (docTheme === 'light') {
|
|
723
|
-
this.theme = 'light';
|
|
724
|
-
} else if (docTheme === 'dark') {
|
|
725
|
-
this.theme = 'dark';
|
|
726
|
-
} else {
|
|
727
|
-
let resolved = false;
|
|
728
|
-
try {
|
|
729
|
-
const saved = localStorage.getItem('open-theme');
|
|
730
|
-
if (saved === 'light') {
|
|
731
|
-
this.theme = 'light';
|
|
732
|
-
resolved = true;
|
|
733
|
-
} else if (saved === 'dark') {
|
|
734
|
-
this.theme = 'dark';
|
|
735
|
-
resolved = true;
|
|
736
|
-
}
|
|
737
|
-
} catch (e) {
|
|
738
|
-
log.debug('localStorage read unavailable:', e);
|
|
739
|
-
}
|
|
740
|
-
if (!resolved && globalThis.matchMedia) {
|
|
741
|
-
this.theme = globalThis.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
this.applyTheme(this.theme);
|
|
746
|
-
}
|
|
747
|
-
applyTheme(theme) {
|
|
748
|
-
const changed = readInstanceState(this, 'lastPropagated', ()=>undefined) !== theme;
|
|
749
|
-
this.theme = theme;
|
|
750
|
-
this.setAttribute('data-theme', theme);
|
|
751
|
-
document.documentElement.setAttribute('data-theme', theme);
|
|
752
|
-
if (document.documentElement.style) document.documentElement.style.colorScheme = theme;
|
|
753
|
-
try {
|
|
754
|
-
const root = this.getRootNode();
|
|
755
|
-
if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot && root.host) {
|
|
756
|
-
root.host.setAttribute('data-theme', theme);
|
|
757
|
-
}
|
|
758
|
-
} catch (e) {
|
|
759
|
-
log.debug('root theme propagation unavailable:', e);
|
|
760
|
-
}
|
|
761
|
-
// Apply + dispatch only. Persistence to localStorage happens exclusively
|
|
762
|
-
// in handleToggle (#804): writing on the init path would lock the
|
|
763
|
-
// resolved theme on first visit and override future OS-level switches.
|
|
764
|
-
if (changed) {
|
|
765
|
-
writeInstanceState(this, 'lastPropagated', theme);
|
|
766
|
-
this.dispatchThemeChange(theme);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
persistTheme(theme) {
|
|
770
|
-
try {
|
|
771
|
-
localStorage.setItem('open-theme', theme);
|
|
772
|
-
} catch (e) {
|
|
773
|
-
log.debug('theme persistence unavailable:', e);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
handleToggle() {
|
|
777
|
-
const theme = this.theme === 'light' ? 'dark' : 'light';
|
|
778
|
-
this.applyTheme(theme);
|
|
779
|
-
// Only an explicit user toggle persists the choice (#804).
|
|
780
|
-
this.persistTheme(theme);
|
|
781
|
-
}
|
|
782
|
-
dispatchThemeChange(theme) {
|
|
783
|
-
try {
|
|
784
|
-
if (typeof CustomEvent !== 'undefined' && typeof globalThis.dispatchEvent === 'function') {
|
|
785
|
-
globalThis.dispatchEvent(new CustomEvent('open:theme-change', {
|
|
786
|
-
detail: {
|
|
787
|
-
theme
|
|
788
|
-
}
|
|
789
|
-
}));
|
|
790
|
-
}
|
|
791
|
-
} catch (e) {
|
|
792
|
-
log.debug('theme event dispatch unavailable:', e);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
attributeChangedCallback(name, old, val) {
|
|
796
|
-
super.attributeChangedCallback(name, old, val);
|
|
797
|
-
if (old === val) return;
|
|
798
|
-
if (name === 'theme' && val) {
|
|
799
|
-
this.applyTheme(val === 'light' ? 'light' : 'dark');
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
render() {
|
|
803
|
-
throw new Error('[open:compiled-element] open-theme-toggle is compiled to a Part Program; the runtime JSX render path is not available in 0.44.');
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
export { __partProgram, __elementMetadata };
|
|
516
|
+
//#endregion
|
|
517
|
+
export { OpenThemeToggle, __elementMetadata, __partProgram };
|