@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.
Files changed (47) hide show
  1. package/CUSTOMIZATION.md +272 -0
  2. package/README.md +59 -54
  3. package/package.json +19 -33
  4. package/src/component-recipes.js +39 -100
  5. package/src/control-recipe.css +21 -0
  6. package/src/generated-manifest.json +13 -160
  7. package/src/index.d.ts +10 -42
  8. package/src/index.js +10 -46
  9. package/src/instance-state.d.ts +16 -0
  10. package/src/instance-state.js +30 -24
  11. package/src/manifest.d.ts +5 -9
  12. package/src/manifest.js +6 -11
  13. package/src/open-button.css +120 -0
  14. package/src/open-button.d.ts +296 -898
  15. package/src/open-button.js +1130 -1436
  16. package/src/open-code-block.css +46 -0
  17. package/src/open-code-block.d.ts +158 -168
  18. package/src/open-code-block.js +224 -468
  19. package/src/open-dialog.css +137 -0
  20. package/src/open-dialog.d.ts +241 -424
  21. package/src/open-dialog.js +626 -903
  22. package/src/open-dropdown.css +28 -0
  23. package/src/open-dropdown.d.ts +195 -252
  24. package/src/open-dropdown.js +352 -494
  25. package/src/open-input.css +80 -0
  26. package/src/open-input.d.ts +404 -1420
  27. package/src/open-input.js +1789 -2170
  28. package/src/open-theme-toggle.css +53 -0
  29. package/src/open-theme-toggle.d.ts +171 -287
  30. package/src/open-theme-toggle.js +512 -801
  31. package/src/overlay-recipe.css +9 -0
  32. package/src/register.d.ts +4 -1
  33. package/src/register.js +19 -58
  34. package/src/surface-recipe.css +10 -0
  35. package/src/theme.css +206 -0
  36. package/THIRD_PARTY_NOTICES.md +0 -45
  37. package/src/open-badge.d.ts +0 -185
  38. package/src/open-badge.js +0 -296
  39. package/src/open-callout.d.ts +0 -402
  40. package/src/open-callout.js +0 -603
  41. package/src/open-card.d.ts +0 -168
  42. package/src/open-card.js +0 -310
  43. package/src/open-props-tokens.d.ts +0 -9
  44. package/src/open-props-tokens.js +0 -459
  45. package/src/open-tabs.d.ts +0 -218
  46. package/src/open-tabs.js +0 -401
  47. package/src/semantic-tokens.css +0 -413
@@ -1,806 +1,517 @@
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 } 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
- "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
- }
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
- "name": "theme",
584
- "attribute": "theme",
585
- "type": "string",
586
- "converter": "string",
587
- "reflect": false,
588
- "default": "dark"
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
- "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
- }
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
- "theme"
636
- ];
637
- const __compiledProps = {
638
- theme: {
639
- type: String,
640
- default: 'dark',
641
- reflect: false,
642
- attribute: "theme"
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
- 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(`
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 };