@openelement/ui 1.0.0-alpha.5 → 1.0.0-alpha.7

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.
@@ -1,656 +1,452 @@
1
- // <auto-generated by open:compiled-element; v0.44.0-alpha.1 - do not edit>
2
- import { OpenElement } from '@openelement/element';
3
- import { log, recipe } from './component-recipes.js';
4
- import { readInstanceState, writeInstanceState } from './instance-state.js';
1
+ import { readInstanceState, writeInstanceState } from "./instance-state.js";
2
+ import { log, recipe } from "./component-recipes.js";
3
+ import { OpenElement } from "@openelement/element";
4
+ //#region src/open-theme-toggle.tsx
5
5
  const __partProgram = {
6
- "version": 1,
7
- "tag": "open-theme-toggle",
8
- "root": {
9
- "id": "root",
10
- "kind": "shadow-open",
11
- "nodes": [
12
- "e0"
13
- ]
14
- },
15
- "template": [
16
- {
17
- "k": "el",
18
- "id": "e0",
19
- "tag": "button",
20
- "attrs": [
21
- [
22
- "type",
23
- "button"
24
- ],
25
- [
26
- "class",
27
- "theme-toggle"
28
- ],
29
- [
30
- "part",
31
- "toggle"
32
- ],
33
- [
34
- "aria-label",
35
- "Toggle theme"
36
- ]
37
- ],
38
- "children": [
39
- {
40
- "k": "el",
41
- "id": "e1",
42
- "tag": "svg",
43
- "attrs": [
44
- [
45
- "class",
46
- "icon-sun"
47
- ],
48
- [
49
- "part",
50
- "icon-sun"
51
- ],
52
- [
53
- "viewBox",
54
- "0 0 16 16"
55
- ],
56
- [
57
- "fill",
58
- "none"
59
- ],
60
- [
61
- "stroke",
62
- "currentColor"
63
- ],
64
- [
65
- "stroke-width",
66
- "1.2"
67
- ],
68
- [
69
- "stroke-linecap",
70
- "round"
71
- ]
72
- ],
73
- "children": [
74
- {
75
- "k": "el",
76
- "id": "e2",
77
- "tag": "circle",
78
- "attrs": [
79
- [
80
- "cx",
81
- "8"
82
- ],
83
- [
84
- "cy",
85
- "8"
86
- ],
87
- [
88
- "r",
89
- "3"
90
- ]
91
- ],
92
- "children": []
93
- },
94
- {
95
- "k": "el",
96
- "id": "e3",
97
- "tag": "line",
98
- "attrs": [
99
- [
100
- "x1",
101
- "8"
102
- ],
103
- [
104
- "y1",
105
- "1"
106
- ],
107
- [
108
- "x2",
109
- "8"
110
- ],
111
- [
112
- "y2",
113
- "3"
114
- ]
115
- ],
116
- "children": []
117
- },
118
- {
119
- "k": "el",
120
- "id": "e4",
121
- "tag": "line",
122
- "attrs": [
123
- [
124
- "x1",
125
- "8"
126
- ],
127
- [
128
- "y1",
129
- "13"
130
- ],
131
- [
132
- "x2",
133
- "8"
134
- ],
135
- [
136
- "y2",
137
- "15"
138
- ]
139
- ],
140
- "children": []
141
- },
142
- {
143
- "k": "el",
144
- "id": "e5",
145
- "tag": "line",
146
- "attrs": [
147
- [
148
- "x1",
149
- "1"
150
- ],
151
- [
152
- "y1",
153
- "8"
154
- ],
155
- [
156
- "x2",
157
- "3"
158
- ],
159
- [
160
- "y2",
161
- "8"
162
- ]
163
- ],
164
- "children": []
165
- },
166
- {
167
- "k": "el",
168
- "id": "e6",
169
- "tag": "line",
170
- "attrs": [
171
- [
172
- "x1",
173
- "13"
174
- ],
175
- [
176
- "y1",
177
- "8"
178
- ],
179
- [
180
- "x2",
181
- "15"
182
- ],
183
- [
184
- "y2",
185
- "8"
186
- ]
187
- ],
188
- "children": []
189
- },
190
- {
191
- "k": "el",
192
- "id": "e7",
193
- "tag": "line",
194
- "attrs": [
195
- [
196
- "x1",
197
- "3.05"
198
- ],
199
- [
200
- "y1",
201
- "3.05"
202
- ],
203
- [
204
- "x2",
205
- "4.46"
206
- ],
207
- [
208
- "y2",
209
- "4.46"
210
- ]
211
- ],
212
- "children": []
213
- },
214
- {
215
- "k": "el",
216
- "id": "e8",
217
- "tag": "line",
218
- "attrs": [
219
- [
220
- "x1",
221
- "11.54"
222
- ],
223
- [
224
- "y1",
225
- "11.54"
226
- ],
227
- [
228
- "x2",
229
- "12.95"
230
- ],
231
- [
232
- "y2",
233
- "12.95"
234
- ]
235
- ],
236
- "children": []
237
- },
238
- {
239
- "k": "el",
240
- "id": "e9",
241
- "tag": "line",
242
- "attrs": [
243
- [
244
- "x1",
245
- "3.05"
246
- ],
247
- [
248
- "y1",
249
- "12.95"
250
- ],
251
- [
252
- "x2",
253
- "4.46"
254
- ],
255
- [
256
- "y2",
257
- "11.54"
258
- ]
259
- ],
260
- "children": []
261
- },
262
- {
263
- "k": "el",
264
- "id": "e10",
265
- "tag": "line",
266
- "attrs": [
267
- [
268
- "x1",
269
- "11.54"
270
- ],
271
- [
272
- "y1",
273
- "4.46"
274
- ],
275
- [
276
- "x2",
277
- "12.95"
278
- ],
279
- [
280
- "y2",
281
- "3.05"
282
- ]
283
- ],
284
- "children": []
285
- }
286
- ]
287
- },
288
- {
289
- "k": "el",
290
- "id": "e11",
291
- "tag": "svg",
292
- "attrs": [
293
- [
294
- "class",
295
- "icon-moon"
296
- ],
297
- [
298
- "part",
299
- "icon-moon"
300
- ],
301
- [
302
- "viewBox",
303
- "0 0 16 16"
304
- ],
305
- [
306
- "fill",
307
- "none"
308
- ],
309
- [
310
- "stroke",
311
- "currentColor"
312
- ],
313
- [
314
- "stroke-width",
315
- "1.2"
316
- ],
317
- [
318
- "stroke-linecap",
319
- "round"
320
- ]
321
- ],
322
- "children": [
323
- {
324
- "k": "el",
325
- "id": "e12",
326
- "tag": "path",
327
- "attrs": [
328
- [
329
- "d",
330
- "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"
331
- ]
332
- ],
333
- "children": []
334
- }
335
- ]
336
- }
337
- ]
338
- }
339
- ],
340
- "parts": [
341
- {
342
- "k": "attr",
343
- "signal": "theme",
344
- "name": "data-theme",
345
- "path": [
346
- 0
347
- ],
348
- "index": 0,
349
- "location": {
350
- "id": "p0",
351
- "kind": "sink",
352
- "path": [
353
- 0
354
- ],
355
- "node": "e0"
356
- }
357
- },
358
- {
359
- "k": "event",
360
- "event": "click",
361
- "handler": "handleToggle",
362
- "action": {
363
- "kind": "method",
364
- "name": "handleToggle"
365
- },
366
- "path": [
367
- 0
368
- ],
369
- "index": 1,
370
- "location": {
371
- "id": "p1",
372
- "kind": "sink",
373
- "path": [
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
- }
6
+ "version": 1,
7
+ "tag": "open-theme-toggle",
8
+ "root": {
9
+ "id": "root",
10
+ "kind": "shadow-open",
11
+ "nodes": ["e0"]
12
+ },
13
+ "template": [{
14
+ "k": "el",
15
+ "id": "e0",
16
+ "tag": "button",
17
+ "attrs": [
18
+ ["type", "button"],
19
+ ["class", "theme-toggle"],
20
+ ["part", "toggle"],
21
+ ["aria-label", "Toggle theme"]
22
+ ],
23
+ "children": [{
24
+ "k": "el",
25
+ "id": "e1",
26
+ "tag": "svg",
27
+ "attrs": [
28
+ ["class", "icon-sun"],
29
+ ["part", "icon-sun"],
30
+ ["viewBox", "0 0 16 16"],
31
+ ["fill", "none"],
32
+ ["stroke", "currentColor"],
33
+ ["stroke-width", "1.2"],
34
+ ["stroke-linecap", "round"]
35
+ ],
36
+ "children": [
37
+ {
38
+ "k": "el",
39
+ "id": "e2",
40
+ "tag": "circle",
41
+ "attrs": [
42
+ ["cx", "8"],
43
+ ["cy", "8"],
44
+ ["r", "3"]
45
+ ],
46
+ "children": []
47
+ },
48
+ {
49
+ "k": "el",
50
+ "id": "e3",
51
+ "tag": "line",
52
+ "attrs": [
53
+ ["x1", "8"],
54
+ ["y1", "1"],
55
+ ["x2", "8"],
56
+ ["y2", "3"]
57
+ ],
58
+ "children": []
59
+ },
60
+ {
61
+ "k": "el",
62
+ "id": "e4",
63
+ "tag": "line",
64
+ "attrs": [
65
+ ["x1", "8"],
66
+ ["y1", "13"],
67
+ ["x2", "8"],
68
+ ["y2", "15"]
69
+ ],
70
+ "children": []
71
+ },
72
+ {
73
+ "k": "el",
74
+ "id": "e5",
75
+ "tag": "line",
76
+ "attrs": [
77
+ ["x1", "1"],
78
+ ["y1", "8"],
79
+ ["x2", "3"],
80
+ ["y2", "8"]
81
+ ],
82
+ "children": []
83
+ },
84
+ {
85
+ "k": "el",
86
+ "id": "e6",
87
+ "tag": "line",
88
+ "attrs": [
89
+ ["x1", "13"],
90
+ ["y1", "8"],
91
+ ["x2", "15"],
92
+ ["y2", "8"]
93
+ ],
94
+ "children": []
95
+ },
96
+ {
97
+ "k": "el",
98
+ "id": "e7",
99
+ "tag": "line",
100
+ "attrs": [
101
+ ["x1", "3.05"],
102
+ ["y1", "3.05"],
103
+ ["x2", "4.46"],
104
+ ["y2", "4.46"]
105
+ ],
106
+ "children": []
107
+ },
108
+ {
109
+ "k": "el",
110
+ "id": "e8",
111
+ "tag": "line",
112
+ "attrs": [
113
+ ["x1", "11.54"],
114
+ ["y1", "11.54"],
115
+ ["x2", "12.95"],
116
+ ["y2", "12.95"]
117
+ ],
118
+ "children": []
119
+ },
120
+ {
121
+ "k": "el",
122
+ "id": "e9",
123
+ "tag": "line",
124
+ "attrs": [
125
+ ["x1", "3.05"],
126
+ ["y1", "12.95"],
127
+ ["x2", "4.46"],
128
+ ["y2", "11.54"]
129
+ ],
130
+ "children": []
131
+ },
132
+ {
133
+ "k": "el",
134
+ "id": "e10",
135
+ "tag": "line",
136
+ "attrs": [
137
+ ["x1", "11.54"],
138
+ ["y1", "4.46"],
139
+ ["x2", "12.95"],
140
+ ["y2", "3.05"]
141
+ ],
142
+ "children": []
143
+ }
144
+ ]
145
+ }, {
146
+ "k": "el",
147
+ "id": "e11",
148
+ "tag": "svg",
149
+ "attrs": [
150
+ ["class", "icon-moon"],
151
+ ["part", "icon-moon"],
152
+ ["viewBox", "0 0 16 16"],
153
+ ["fill", "none"],
154
+ ["stroke", "currentColor"],
155
+ ["stroke-width", "1.2"],
156
+ ["stroke-linecap", "round"]
157
+ ],
158
+ "children": [{
159
+ "k": "el",
160
+ "id": "e12",
161
+ "tag": "path",
162
+ "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"]],
163
+ "children": []
164
+ }]
165
+ }]
166
+ }],
167
+ "parts": [{
168
+ "k": "attr",
169
+ "signal": "theme",
170
+ "name": "data-theme",
171
+ "path": [0],
172
+ "index": 0,
173
+ "location": {
174
+ "id": "p0",
175
+ "kind": "sink",
176
+ "path": [0],
177
+ "node": "e0"
178
+ }
179
+ }, {
180
+ "k": "event",
181
+ "event": "click",
182
+ "handler": "handleToggle",
183
+ "action": {
184
+ "kind": "method",
185
+ "name": "handleToggle"
186
+ },
187
+ "path": [0],
188
+ "index": 1,
189
+ "location": {
190
+ "id": "p1",
191
+ "kind": "sink",
192
+ "path": [0],
193
+ "node": "e0"
194
+ }
195
+ }],
196
+ "regions": [],
197
+ "dependencies": [{
198
+ "signal": "theme",
199
+ "owner": {
200
+ "kind": "part",
201
+ "index": 0
202
+ },
203
+ "location": "p0"
204
+ }],
205
+ "locations": [
206
+ {
207
+ "id": "e0",
208
+ "kind": "element",
209
+ "tag": "button",
210
+ "path": [0]
211
+ },
212
+ {
213
+ "id": "p0",
214
+ "kind": "sink",
215
+ "part": 0,
216
+ "node": "e0",
217
+ "path": [0]
218
+ },
219
+ {
220
+ "id": "p1",
221
+ "kind": "sink",
222
+ "part": 1,
223
+ "node": "e0",
224
+ "path": [0]
225
+ },
226
+ {
227
+ "id": "e1",
228
+ "kind": "element",
229
+ "tag": "svg",
230
+ "path": [0, 0]
231
+ },
232
+ {
233
+ "id": "e2",
234
+ "kind": "element",
235
+ "tag": "circle",
236
+ "path": [
237
+ 0,
238
+ 0,
239
+ 0
240
+ ]
241
+ },
242
+ {
243
+ "id": "e3",
244
+ "kind": "element",
245
+ "tag": "line",
246
+ "path": [
247
+ 0,
248
+ 0,
249
+ 1
250
+ ]
251
+ },
252
+ {
253
+ "id": "e4",
254
+ "kind": "element",
255
+ "tag": "line",
256
+ "path": [
257
+ 0,
258
+ 0,
259
+ 2
260
+ ]
261
+ },
262
+ {
263
+ "id": "e5",
264
+ "kind": "element",
265
+ "tag": "line",
266
+ "path": [
267
+ 0,
268
+ 0,
269
+ 3
270
+ ]
271
+ },
272
+ {
273
+ "id": "e6",
274
+ "kind": "element",
275
+ "tag": "line",
276
+ "path": [
277
+ 0,
278
+ 0,
279
+ 4
280
+ ]
281
+ },
282
+ {
283
+ "id": "e7",
284
+ "kind": "element",
285
+ "tag": "line",
286
+ "path": [
287
+ 0,
288
+ 0,
289
+ 5
290
+ ]
291
+ },
292
+ {
293
+ "id": "e8",
294
+ "kind": "element",
295
+ "tag": "line",
296
+ "path": [
297
+ 0,
298
+ 0,
299
+ 6
300
+ ]
301
+ },
302
+ {
303
+ "id": "e9",
304
+ "kind": "element",
305
+ "tag": "line",
306
+ "path": [
307
+ 0,
308
+ 0,
309
+ 7
310
+ ]
311
+ },
312
+ {
313
+ "id": "e10",
314
+ "kind": "element",
315
+ "tag": "line",
316
+ "path": [
317
+ 0,
318
+ 0,
319
+ 8
320
+ ]
321
+ },
322
+ {
323
+ "id": "e11",
324
+ "kind": "element",
325
+ "tag": "svg",
326
+ "path": [0, 1]
327
+ },
328
+ {
329
+ "id": "e12",
330
+ "kind": "element",
331
+ "tag": "path",
332
+ "path": [
333
+ 0,
334
+ 1,
335
+ 0
336
+ ]
337
+ }
338
+ ],
339
+ "metadata": {
340
+ "tag": "open-theme-toggle",
341
+ "className": "OpenThemeToggle",
342
+ "sourceFile": "open-theme-toggle.tsx",
343
+ "properties": [{
344
+ "name": "theme",
345
+ "attribute": "theme",
346
+ "type": "string",
347
+ "converter": "string",
348
+ "reflect": false,
349
+ "default": "dark"
350
+ }],
351
+ "observedAttributes": ["theme"],
352
+ "cem": {
353
+ "tagName": "open-theme-toggle",
354
+ "className": "OpenThemeToggle",
355
+ "declaration": {
356
+ "name": "OpenThemeToggle",
357
+ "module": "open-theme-toggle.tsx"
358
+ },
359
+ "attributes": [{
360
+ "name": "theme",
361
+ "fieldName": "theme",
362
+ "type": "string",
363
+ "reflect": false
364
+ }],
365
+ "members": [{
366
+ "name": "theme",
367
+ "fieldName": "theme",
368
+ "type": "string",
369
+ "attribute": "theme",
370
+ "reflect": false
371
+ }]
372
+ }
373
+ }
580
374
  };
581
- const __compiledProperties = [
582
- {
583
- "name": "theme",
584
- "attribute": "theme",
585
- "type": "string",
586
- "converter": "string",
587
- "reflect": false,
588
- "default": "dark"
589
- }
590
- ];
375
+ const __compiledProperties = [{
376
+ "name": "theme",
377
+ "attribute": "theme",
378
+ "type": "string",
379
+ "converter": "string",
380
+ "reflect": false,
381
+ "default": "dark"
382
+ }];
591
383
  const __elementMetadata = {
592
- "tag": "open-theme-toggle",
593
- "className": "OpenThemeToggle",
594
- "sourceFile": "open-theme-toggle.tsx",
595
- "properties": [
596
- {
597
- "name": "theme",
598
- "attribute": "theme",
599
- "type": "string",
600
- "converter": "string",
601
- "reflect": false,
602
- "default": "dark"
603
- }
604
- ],
605
- "observedAttributes": [
606
- "theme"
607
- ],
608
- "cem": {
609
- "tagName": "open-theme-toggle",
610
- "className": "OpenThemeToggle",
611
- "declaration": {
612
- "name": "OpenThemeToggle",
613
- "module": "open-theme-toggle.tsx"
614
- },
615
- "attributes": [
616
- {
617
- "name": "theme",
618
- "fieldName": "theme",
619
- "type": "string",
620
- "reflect": false
621
- }
622
- ],
623
- "members": [
624
- {
625
- "name": "theme",
626
- "fieldName": "theme",
627
- "type": "string",
628
- "attribute": "theme",
629
- "reflect": false
630
- }
631
- ]
632
- }
633
- };
634
- const __observedAttributes = [
635
- "theme"
636
- ];
637
- const __compiledProps = {
638
- theme: {
639
- type: String,
640
- default: 'dark',
641
- reflect: false,
642
- attribute: "theme"
643
- }
384
+ "tag": "open-theme-toggle",
385
+ "className": "OpenThemeToggle",
386
+ "sourceFile": "open-theme-toggle.tsx",
387
+ "properties": [{
388
+ "name": "theme",
389
+ "attribute": "theme",
390
+ "type": "string",
391
+ "converter": "string",
392
+ "reflect": false,
393
+ "default": "dark"
394
+ }],
395
+ "observedAttributes": ["theme"],
396
+ "cem": {
397
+ "tagName": "open-theme-toggle",
398
+ "className": "OpenThemeToggle",
399
+ "declaration": {
400
+ "name": "OpenThemeToggle",
401
+ "module": "open-theme-toggle.tsx"
402
+ },
403
+ "attributes": [{
404
+ "name": "theme",
405
+ "fieldName": "theme",
406
+ "type": "string",
407
+ "reflect": false
408
+ }],
409
+ "members": [{
410
+ "name": "theme",
411
+ "fieldName": "theme",
412
+ "type": "string",
413
+ "attribute": "theme",
414
+ "reflect": false
415
+ }]
416
+ }
644
417
  };
645
- export class OpenThemeToggle extends OpenElement {
646
- static __partProgram = __partProgram;
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(`
418
+ const __observedAttributes = ["theme"];
419
+ const __compiledProps = { theme: {
420
+ type: String,
421
+ default: "dark",
422
+ reflect: false,
423
+ attribute: "theme"
424
+ } };
425
+ var OpenThemeToggle = class extends OpenElement {
426
+ constructor(..._args) {
427
+ super(..._args);
428
+ this.theme = "dark";
429
+ }
430
+ static {
431
+ this.__partProgram = __partProgram;
432
+ }
433
+ static {
434
+ this.__compiledProperties = __compiledProperties;
435
+ }
436
+ static {
437
+ this.__elementMetadata = __elementMetadata;
438
+ }
439
+ static {
440
+ this.props = __compiledProps;
441
+ }
442
+ static {
443
+ this.observedAttributes = __observedAttributes;
444
+ }
445
+ static {
446
+ this.delegatesFocus = true;
447
+ }
448
+ static {
449
+ this.styles = [recipe(`
654
450
  :host {
655
451
  display: inline-block;
656
452
  }
@@ -699,108 +495,88 @@ export class OpenThemeToggle extends OpenElement {
699
495
  .theme-toggle[data-theme='light'] .icon-moon {
700
496
  display: block;
701
497
  }
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 };
498
+ `)];
499
+ }
500
+ connectedCallback() {
501
+ super.connectedCallback();
502
+ this._requestAnimationFrame(() => this.initTheme());
503
+ }
504
+ onDsdHydrated() {
505
+ this._requestAnimationFrame(() => this.initTheme());
506
+ }
507
+ initTheme() {
508
+ if (readInstanceState(this, "initDone", () => false)) return;
509
+ writeInstanceState(this, "initDone", true);
510
+ const themeAttr = this.getAttribute("theme");
511
+ if (themeAttr === "light") this.theme = "light";
512
+ else if (themeAttr === "dark") this.theme = "dark";
513
+ else {
514
+ const docTheme = document.documentElement?.dataset?.theme;
515
+ if (docTheme === "light") this.theme = "light";
516
+ else if (docTheme === "dark") this.theme = "dark";
517
+ else {
518
+ let resolved = false;
519
+ try {
520
+ const saved = localStorage.getItem("open-theme");
521
+ if (saved === "light") {
522
+ this.theme = "light";
523
+ resolved = true;
524
+ } else if (saved === "dark") {
525
+ this.theme = "dark";
526
+ resolved = true;
527
+ }
528
+ } catch (e) {
529
+ log.debug("localStorage read unavailable:", e);
530
+ }
531
+ if (!resolved && globalThis.matchMedia) this.theme = globalThis.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
532
+ }
533
+ }
534
+ this.applyTheme(this.theme);
535
+ }
536
+ applyTheme(theme) {
537
+ const changed = readInstanceState(this, "lastPropagated", () => void 0) !== theme;
538
+ this.theme = theme;
539
+ this.setAttribute("data-theme", theme);
540
+ document.documentElement.setAttribute("data-theme", theme);
541
+ if (document.documentElement.style) document.documentElement.style.colorScheme = theme;
542
+ try {
543
+ const root = this.getRootNode();
544
+ if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && root.host) root.host.setAttribute("data-theme", theme);
545
+ } catch (e) {
546
+ log.debug("root theme propagation unavailable:", e);
547
+ }
548
+ if (changed) {
549
+ writeInstanceState(this, "lastPropagated", theme);
550
+ this.dispatchThemeChange(theme);
551
+ }
552
+ }
553
+ persistTheme(theme) {
554
+ try {
555
+ localStorage.setItem("open-theme", theme);
556
+ } catch (e) {
557
+ log.debug("theme persistence unavailable:", e);
558
+ }
559
+ }
560
+ handleToggle() {
561
+ const theme = this.theme === "light" ? "dark" : "light";
562
+ this.applyTheme(theme);
563
+ this.persistTheme(theme);
564
+ }
565
+ dispatchThemeChange(theme) {
566
+ try {
567
+ if (typeof CustomEvent !== "undefined" && typeof globalThis.dispatchEvent === "function") globalThis.dispatchEvent(new CustomEvent("open:theme-change", { detail: { theme } }));
568
+ } catch (e) {
569
+ log.debug("theme event dispatch unavailable:", e);
570
+ }
571
+ }
572
+ attributeChangedCallback(name, old, val) {
573
+ super.attributeChangedCallback(name, old, val);
574
+ if (old === val) return;
575
+ if (name === "theme" && val) this.applyTheme(val === "light" ? "light" : "dark");
576
+ }
577
+ render() {
578
+ throw new Error("[open:compiled-element] open-theme-toggle is compiled to a Part Program; the runtime JSX render path is not available.");
579
+ }
580
+ };
581
+ //#endregion
582
+ export { OpenThemeToggle, __elementMetadata, __partProgram };