@openelement/ui 1.0.0-alpha.14 → 1.0.0-alpha.16

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 (43) hide show
  1. package/CUSTOMIZATION.md +106 -112
  2. package/README.md +19 -39
  3. package/custom-elements.json +369 -0
  4. package/package.json +3 -2
  5. package/src/button-machine.js +54 -0
  6. package/src/component-config.js +7 -0
  7. package/src/component-recipes.js +2 -24
  8. package/src/copy-feedback.js +32 -0
  9. package/src/dialog-machine.js +104 -0
  10. package/src/dropdown-machine.js +253 -0
  11. package/src/generated-manifest.json +135 -87
  12. package/src/index.d.ts +7 -8
  13. package/src/index.js +7 -8
  14. package/src/input-machine.js +33 -0
  15. package/src/open-button.css +119 -108
  16. package/src/open-button.d.ts +34 -342
  17. package/src/open-button.generated.js +592 -0
  18. package/src/open-button.js +115 -1140
  19. package/src/open-code-block.css +24 -44
  20. package/src/open-code-block.d.ts +15 -175
  21. package/src/open-code-block.generated.js +293 -0
  22. package/src/open-code-block.js +112 -224
  23. package/src/open-dialog.css +114 -127
  24. package/src/open-dialog.d.ts +22 -261
  25. package/src/open-dialog.generated.js +501 -0
  26. package/src/open-dialog.js +137 -632
  27. package/src/open-dropdown.css +26 -26
  28. package/src/open-dropdown.d.ts +15 -218
  29. package/src/open-dropdown.generated.js +211 -0
  30. package/src/open-dropdown.js +74 -355
  31. package/src/open-input.css +69 -74
  32. package/src/open-input.d.ts +34 -461
  33. package/src/open-input.generated.js +685 -0
  34. package/src/open-input.js +161 -1802
  35. package/src/open-theme-toggle.css +37 -47
  36. package/src/open-theme-toggle.d.ts +19 -190
  37. package/src/open-theme-toggle.generated.js +564 -0
  38. package/src/open-theme-toggle.js +209 -509
  39. package/src/theme-contract.js +40 -0
  40. package/src/theme.css +26 -8
  41. package/src/control-recipe.css +0 -21
  42. package/src/register.d.ts +0 -4
  43. package/src/register.js +0 -22
@@ -1,1144 +1,119 @@
1
- import { closestFormOf, syncDisabledState } from "./component-recipes.js";
2
- import { OpenElement, computed } from "@openelement/element";
3
- import controlRecipe from "./control-recipe.css";
4
- import openButtonStyles from "./open-button.css";
1
+ import { activateButton } from "./button-machine.js";
2
+ import { defineComponentConfig } from "./component-config.js";
3
+ import { jsx } from "@openelement/element/jsx-runtime";
5
4
  //#region src/open-button.tsx
6
- const __partProgram = {
7
- "version": 1,
8
- "tag": "open-button",
9
- "root": {
10
- "id": "root",
11
- "kind": "shadow-open",
12
- "nodes": ["e0"]
13
- },
14
- "template": [{
15
- "k": "el",
16
- "id": "e0",
17
- "tag": "span",
18
- "attrs": [["style", "display:contents"]],
19
- "children": [{
20
- "k": "el",
21
- "id": "e1",
22
- "tag": "a",
23
- "attrs": [["class", "control btn"], ["part", "control"]],
24
- "children": [{
25
- "k": "el",
26
- "id": "e2",
27
- "tag": "slot",
28
- "attrs": [],
29
- "children": []
30
- }]
31
- }, {
32
- "k": "el",
33
- "id": "e3",
34
- "tag": "button",
35
- "attrs": [["class", "control btn"], ["part", "control"]],
36
- "children": [{
37
- "k": "el",
38
- "id": "e4",
39
- "tag": "slot",
40
- "attrs": [],
41
- "children": []
42
- }]
43
- }]
44
- }],
45
- "parts": [
46
- {
47
- "k": "attr",
48
- "signal": "linkHref",
49
- "name": "href",
50
- "path": [0, 0],
51
- "index": 0,
52
- "location": {
53
- "id": "p0",
54
- "kind": "sink",
55
- "path": [0, 0],
56
- "node": "e1"
57
- }
58
- },
59
- {
60
- "k": "attr",
61
- "signal": "linkTarget",
62
- "name": "target",
63
- "path": [0, 0],
64
- "index": 1,
65
- "location": {
66
- "id": "p1",
67
- "kind": "sink",
68
- "path": [0, 0],
69
- "node": "e1"
70
- }
71
- },
72
- {
73
- "k": "attr",
74
- "signal": "linkRel",
75
- "name": "rel",
76
- "path": [0, 0],
77
- "index": 2,
78
- "location": {
79
- "id": "p2",
80
- "kind": "sink",
81
- "path": [0, 0],
82
- "node": "e1"
83
- }
84
- },
85
- {
86
- "k": "attr",
87
- "signal": "linkAriaDisabled",
88
- "name": "aria-disabled",
89
- "path": [0, 0],
90
- "index": 3,
91
- "location": {
92
- "id": "p3",
93
- "kind": "sink",
94
- "path": [0, 0],
95
- "node": "e1"
96
- }
97
- },
98
- {
99
- "k": "bool",
100
- "signal": "buttonMode",
101
- "name": "hidden",
102
- "path": [0, 0],
103
- "index": 4,
104
- "location": {
105
- "id": "p4",
106
- "kind": "sink",
107
- "path": [0, 0],
108
- "node": "e1"
109
- }
110
- },
111
- {
112
- "k": "event",
113
- "event": "click",
114
- "handler": "handleClick",
115
- "action": {
116
- "kind": "method",
117
- "name": "handleClick"
118
- },
119
- "path": [0, 0],
120
- "index": 5,
121
- "location": {
122
- "id": "p5",
123
- "kind": "sink",
124
- "path": [0, 0],
125
- "node": "e1"
126
- }
127
- },
128
- {
129
- "k": "attr",
130
- "signal": "type",
131
- "name": "type",
132
- "path": [0, 1],
133
- "index": 6,
134
- "location": {
135
- "id": "p6",
136
- "kind": "sink",
137
- "path": [0, 1],
138
- "node": "e3"
139
- }
140
- },
141
- {
142
- "k": "bool",
143
- "signal": "disabled",
144
- "name": "disabled",
145
- "path": [0, 1],
146
- "index": 7,
147
- "location": {
148
- "id": "p7",
149
- "kind": "sink",
150
- "path": [0, 1],
151
- "node": "e3"
152
- }
153
- },
154
- {
155
- "k": "bool",
156
- "signal": "linkMode",
157
- "name": "hidden",
158
- "path": [0, 1],
159
- "index": 8,
160
- "location": {
161
- "id": "p8",
162
- "kind": "sink",
163
- "path": [0, 1],
164
- "node": "e3"
165
- }
166
- },
167
- {
168
- "k": "event",
169
- "event": "click",
170
- "handler": "handleClick",
171
- "action": {
172
- "kind": "method",
173
- "name": "handleClick"
174
- },
175
- "path": [0, 1],
176
- "index": 9,
177
- "location": {
178
- "id": "p9",
179
- "kind": "sink",
180
- "path": [0, 1],
181
- "node": "e3"
182
- }
183
- }
184
- ],
185
- "regions": [],
186
- "dependencies": [
187
- {
188
- "signal": "linkHref",
189
- "owner": {
190
- "kind": "part",
191
- "index": 0
192
- },
193
- "location": "p0"
194
- },
195
- {
196
- "signal": "linkTarget",
197
- "owner": {
198
- "kind": "part",
199
- "index": 1
200
- },
201
- "location": "p1"
202
- },
203
- {
204
- "signal": "linkRel",
205
- "owner": {
206
- "kind": "part",
207
- "index": 2
208
- },
209
- "location": "p2"
210
- },
211
- {
212
- "signal": "linkAriaDisabled",
213
- "owner": {
214
- "kind": "part",
215
- "index": 3
216
- },
217
- "location": "p3"
218
- },
219
- {
220
- "signal": "buttonMode",
221
- "owner": {
222
- "kind": "part",
223
- "index": 4
224
- },
225
- "location": "p4"
226
- },
227
- {
228
- "signal": "type",
229
- "owner": {
230
- "kind": "part",
231
- "index": 6
232
- },
233
- "location": "p6"
234
- },
235
- {
236
- "signal": "disabled",
237
- "owner": {
238
- "kind": "part",
239
- "index": 7
240
- },
241
- "location": "p7"
242
- },
243
- {
244
- "signal": "linkMode",
245
- "owner": {
246
- "kind": "part",
247
- "index": 8
248
- },
249
- "location": "p8"
5
+ /**
6
+ * @openelement/ui - open-button
7
+ *
8
+ * Button or link control: an `href` value switches the compiled anchor branch
9
+ * (no-JS navigation survives SSR), `variant`/`size` pick the styled surface, and
10
+ * the disabled state follows the reflected host attribute.
11
+ *
12
+ * Experimental (owner ruling C1, #1468): internal implementation may change or
13
+ * be removed before 1.0; the declared `::part` names follow the
14
+ * CUSTOMIZATION.md contract (`::part` names never shrink).
15
+ *
16
+ * Generated authoring. The control is ONE `when` branch with a single default
17
+ * slot per branch: `href !== ''` picks `<a>`, otherwise `<button>`, so exactly
18
+ * one control element exists in any state and the slot carries no same-name
19
+ * competition. The earlier two-sibling shape (both controls always mounted,
20
+ * `hidden` sinks picking the visible one) measured broken in the PR #1611
21
+ * audit: same-name default slots assign by tree order — the first slot in the
22
+ * shadow tree wins regardless of visibility, and `hidden` is not a slot force —
23
+ * so button mode assigned the user's text into the HIDDEN anchor's slot,
24
+ * leaving the visible button blank with no accessible name. The single slot
25
+ * removes that competition outright. Clicks bubble from either branch to the
26
+ * delegated listener on the static display:contents wrapper, and
27
+ * `button-machine.ts` keeps the control semantics (open-click, form
28
+ * submit/reset, the #757 disabled guard). Variant/size styling follows the
29
+ * reflected host attributes (`:host([variant=...])` selectors). SSR semantics
30
+ * are unchanged: in link mode the server serializes a navigable `<a>`.
31
+ *
32
+ * Variants: default (outlined), primary (filled), ghost (no border), accent (gradient)
33
+ * Sizes: sm, md (default), lg
34
+ *
35
+ * @csspart control - The visible button or anchor element
36
+ *
37
+ * Usage:
38
+ * ```html
39
+ * <open-button>Click me</open-button>
40
+ * <open-button variant="primary">Submit</open-button>
41
+ * <open-button size="sm" disabled>Small</open-button>
42
+ * <open-button href="/guide">Navigate</open-button>
43
+ * ```
44
+ */
45
+ /**
46
+ * Platform facts for the generated element: shadow root with delegated focus,
47
+ * form association (the class lane's `formAssociated: true`, so `form.elements`
48
+ * membership and the effective-disabled custom state are unchanged), the
49
+ * authored stylesheet, and the six declared property rows — all reflected, the
50
+ * class lane's exact attribute surface.
51
+ */
52
+ const openElement = /* @__PURE__ */ defineComponentConfig({
53
+ root: "shadow",
54
+ delegatesFocus: true,
55
+ formAssociated: true,
56
+ styles: ["./open-button.css"],
57
+ properties: {
58
+ variant: {
59
+ default: "default",
60
+ reflect: true
61
+ },
62
+ size: {
63
+ default: "md",
64
+ reflect: true
65
+ },
66
+ disabled: {
67
+ default: false,
68
+ reflect: true
69
+ },
70
+ href: {
71
+ default: "",
72
+ reflect: true
73
+ },
74
+ target: {
75
+ default: "",
76
+ reflect: true
77
+ },
78
+ type: {
79
+ default: "button",
80
+ reflect: true
250
81
  }
251
- ],
252
- "locations": [
253
- {
254
- "id": "e0",
255
- "kind": "element",
256
- "tag": "span",
257
- "path": [0]
258
- },
259
- {
260
- "id": "e1",
261
- "kind": "element",
262
- "tag": "a",
263
- "path": [0, 0]
264
- },
265
- {
266
- "id": "p0",
267
- "kind": "sink",
268
- "part": 0,
269
- "node": "e1",
270
- "path": [0, 0]
271
- },
272
- {
273
- "id": "p1",
274
- "kind": "sink",
275
- "part": 1,
276
- "node": "e1",
277
- "path": [0, 0]
278
- },
279
- {
280
- "id": "p2",
281
- "kind": "sink",
282
- "part": 2,
283
- "node": "e1",
284
- "path": [0, 0]
285
- },
286
- {
287
- "id": "p3",
288
- "kind": "sink",
289
- "part": 3,
290
- "node": "e1",
291
- "path": [0, 0]
292
- },
293
- {
294
- "id": "p4",
295
- "kind": "sink",
296
- "part": 4,
297
- "node": "e1",
298
- "path": [0, 0]
299
- },
300
- {
301
- "id": "p5",
302
- "kind": "sink",
303
- "part": 5,
304
- "node": "e1",
305
- "path": [0, 0]
306
- },
307
- {
308
- "id": "e2",
309
- "kind": "element",
310
- "tag": "slot",
311
- "path": [
312
- 0,
313
- 0,
314
- 0
315
- ]
316
- },
317
- {
318
- "id": "e3",
319
- "kind": "element",
320
- "tag": "button",
321
- "path": [0, 1]
322
- },
323
- {
324
- "id": "p6",
325
- "kind": "sink",
326
- "part": 6,
327
- "node": "e3",
328
- "path": [0, 1]
329
- },
330
- {
331
- "id": "p7",
332
- "kind": "sink",
333
- "part": 7,
334
- "node": "e3",
335
- "path": [0, 1]
336
- },
337
- {
338
- "id": "p8",
339
- "kind": "sink",
340
- "part": 8,
341
- "node": "e3",
342
- "path": [0, 1]
343
- },
344
- {
345
- "id": "p9",
346
- "kind": "sink",
347
- "part": 9,
348
- "node": "e3",
349
- "path": [0, 1]
350
- },
351
- {
352
- "id": "e4",
353
- "kind": "element",
354
- "tag": "slot",
355
- "path": [
356
- 0,
357
- 1,
358
- 0
359
- ]
360
- }
361
- ],
362
- "metadata": {
363
- "tag": "open-button",
364
- "className": "OpenButton",
365
- "sourceFile": "open-button.tsx",
366
- "properties": [
367
- {
368
- "name": "variant",
369
- "attribute": "variant",
370
- "type": "string",
371
- "converter": "string",
372
- "reflect": true,
373
- "default": "default"
374
- },
375
- {
376
- "name": "size",
377
- "attribute": "size",
378
- "type": "string",
379
- "converter": "string",
380
- "reflect": true,
381
- "default": "md"
382
- },
383
- {
384
- "name": "disabled",
385
- "attribute": "disabled",
386
- "type": "boolean",
387
- "converter": "boolean",
388
- "reflect": true,
389
- "default": false
390
- },
391
- {
392
- "name": "href",
393
- "attribute": "href",
394
- "type": "string",
395
- "converter": "string",
396
- "reflect": true,
397
- "default": ""
398
- },
399
- {
400
- "name": "target",
401
- "attribute": "target",
402
- "type": "string",
403
- "converter": "string",
404
- "reflect": true,
405
- "default": ""
406
- },
407
- {
408
- "name": "type",
409
- "attribute": "type",
410
- "type": "string",
411
- "converter": "string",
412
- "reflect": true,
413
- "default": "button"
414
- },
415
- {
416
- "name": "linkMode",
417
- "attribute": null,
418
- "type": "boolean",
419
- "converter": "boolean",
420
- "reflect": false,
421
- "default": null,
422
- "computed": true,
423
- "deps": ["href"]
424
- },
425
- {
426
- "name": "buttonMode",
427
- "attribute": null,
428
- "type": "boolean",
429
- "converter": "boolean",
430
- "reflect": false,
431
- "default": null,
432
- "computed": true,
433
- "deps": ["href"]
434
- },
435
- {
436
- "name": "linkHref",
437
- "attribute": null,
438
- "type": "string",
439
- "converter": "string",
440
- "reflect": false,
441
- "default": null,
442
- "computed": true,
443
- "deps": ["disabled", "href"]
444
- },
445
- {
446
- "name": "linkTarget",
447
- "attribute": null,
448
- "type": "string",
449
- "converter": "string",
450
- "reflect": false,
451
- "default": null,
452
- "computed": true,
453
- "deps": ["target"]
454
- },
455
- {
456
- "name": "linkRel",
457
- "attribute": null,
458
- "type": "string",
459
- "converter": "string",
460
- "reflect": false,
461
- "default": null,
462
- "computed": true,
463
- "deps": ["target"]
464
- },
465
- {
466
- "name": "linkAriaDisabled",
467
- "attribute": null,
468
- "type": "string",
469
- "converter": "string",
470
- "reflect": false,
471
- "default": null,
472
- "computed": true,
473
- "deps": ["disabled"]
474
- }
475
- ],
476
- "observedAttributes": [
477
- "variant",
478
- "size",
479
- "disabled",
480
- "href",
481
- "target",
482
- "type"
483
- ],
484
- "cem": {
485
- "tagName": "open-button",
486
- "className": "OpenButton",
487
- "declaration": {
488
- "name": "OpenButton",
489
- "module": "open-button.tsx"
490
- },
491
- "attributes": [
492
- {
493
- "name": "variant",
494
- "fieldName": "variant",
495
- "type": "string",
496
- "reflect": true
497
- },
498
- {
499
- "name": "size",
500
- "fieldName": "size",
501
- "type": "string",
502
- "reflect": true
503
- },
504
- {
505
- "name": "disabled",
506
- "fieldName": "disabled",
507
- "type": "boolean",
508
- "reflect": true
509
- },
510
- {
511
- "name": "href",
512
- "fieldName": "href",
513
- "type": "string",
514
- "reflect": true
515
- },
516
- {
517
- "name": "target",
518
- "fieldName": "target",
519
- "type": "string",
520
- "reflect": true
521
- },
522
- {
523
- "name": "type",
524
- "fieldName": "type",
525
- "type": "string",
526
- "reflect": true
527
- }
528
- ],
529
- "members": [
530
- {
531
- "name": "variant",
532
- "fieldName": "variant",
533
- "type": "string",
534
- "attribute": "variant",
535
- "reflect": true
536
- },
537
- {
538
- "name": "size",
539
- "fieldName": "size",
540
- "type": "string",
541
- "attribute": "size",
542
- "reflect": true
543
- },
544
- {
545
- "name": "disabled",
546
- "fieldName": "disabled",
547
- "type": "boolean",
548
- "attribute": "disabled",
549
- "reflect": true
550
- },
551
- {
552
- "name": "href",
553
- "fieldName": "href",
554
- "type": "string",
555
- "attribute": "href",
556
- "reflect": true
557
- },
558
- {
559
- "name": "target",
560
- "fieldName": "target",
561
- "type": "string",
562
- "attribute": "target",
563
- "reflect": true
564
- },
565
- {
566
- "name": "type",
567
- "fieldName": "type",
568
- "type": "string",
569
- "attribute": "type",
570
- "reflect": true
571
- },
572
- {
573
- "name": "linkMode",
574
- "fieldName": "linkMode",
575
- "type": "boolean",
576
- "attribute": null,
577
- "reflect": false
578
- },
579
- {
580
- "name": "buttonMode",
581
- "fieldName": "buttonMode",
582
- "type": "boolean",
583
- "attribute": null,
584
- "reflect": false
585
- },
586
- {
587
- "name": "linkHref",
588
- "fieldName": "linkHref",
589
- "type": "string",
590
- "attribute": null,
591
- "reflect": false
592
- },
593
- {
594
- "name": "linkTarget",
595
- "fieldName": "linkTarget",
596
- "type": "string",
597
- "attribute": null,
598
- "reflect": false
599
- },
600
- {
601
- "name": "linkRel",
602
- "fieldName": "linkRel",
603
- "type": "string",
604
- "attribute": null,
605
- "reflect": false
606
- },
607
- {
608
- "name": "linkAriaDisabled",
609
- "fieldName": "linkAriaDisabled",
610
- "type": "string",
611
- "attribute": null,
612
- "reflect": false
613
- }
614
- ]
615
- }
616
- }
617
- };
618
- const __compiledProperties = [
619
- {
620
- "name": "variant",
621
- "attribute": "variant",
622
- "type": "string",
623
- "converter": "string",
624
- "reflect": true,
625
- "default": "default"
626
- },
627
- {
628
- "name": "size",
629
- "attribute": "size",
630
- "type": "string",
631
- "converter": "string",
632
- "reflect": true,
633
- "default": "md"
634
- },
635
- {
636
- "name": "disabled",
637
- "attribute": "disabled",
638
- "type": "boolean",
639
- "converter": "boolean",
640
- "reflect": true,
641
- "default": false
642
- },
643
- {
644
- "name": "href",
645
- "attribute": "href",
646
- "type": "string",
647
- "converter": "string",
648
- "reflect": true,
649
- "default": ""
650
- },
651
- {
652
- "name": "target",
653
- "attribute": "target",
654
- "type": "string",
655
- "converter": "string",
656
- "reflect": true,
657
- "default": ""
658
- },
659
- {
660
- "name": "type",
661
- "attribute": "type",
662
- "type": "string",
663
- "converter": "string",
664
- "reflect": true,
665
- "default": "button"
666
- },
667
- {
668
- "name": "linkMode",
669
- "attribute": null,
670
- "type": "boolean",
671
- "converter": "boolean",
672
- "reflect": false,
673
- "default": null,
674
- "computed": true,
675
- "deps": ["href"]
676
- },
677
- {
678
- "name": "buttonMode",
679
- "attribute": null,
680
- "type": "boolean",
681
- "converter": "boolean",
682
- "reflect": false,
683
- "default": null,
684
- "computed": true,
685
- "deps": ["href"]
686
- },
687
- {
688
- "name": "linkHref",
689
- "attribute": null,
690
- "type": "string",
691
- "converter": "string",
692
- "reflect": false,
693
- "default": null,
694
- "computed": true,
695
- "deps": ["disabled", "href"]
696
- },
697
- {
698
- "name": "linkTarget",
699
- "attribute": null,
700
- "type": "string",
701
- "converter": "string",
702
- "reflect": false,
703
- "default": null,
704
- "computed": true,
705
- "deps": ["target"]
706
- },
707
- {
708
- "name": "linkRel",
709
- "attribute": null,
710
- "type": "string",
711
- "converter": "string",
712
- "reflect": false,
713
- "default": null,
714
- "computed": true,
715
- "deps": ["target"]
716
- },
717
- {
718
- "name": "linkAriaDisabled",
719
- "attribute": null,
720
- "type": "string",
721
- "converter": "string",
722
- "reflect": false,
723
- "default": null,
724
- "computed": true,
725
- "deps": ["disabled"]
726
- }
727
- ];
728
- const __elementMetadata = {
729
- "tag": "open-button",
730
- "className": "OpenButton",
731
- "sourceFile": "open-button.tsx",
732
- "properties": [
733
- {
734
- "name": "variant",
735
- "attribute": "variant",
736
- "type": "string",
737
- "converter": "string",
738
- "reflect": true,
739
- "default": "default"
740
- },
741
- {
742
- "name": "size",
743
- "attribute": "size",
744
- "type": "string",
745
- "converter": "string",
746
- "reflect": true,
747
- "default": "md"
748
- },
749
- {
750
- "name": "disabled",
751
- "attribute": "disabled",
752
- "type": "boolean",
753
- "converter": "boolean",
754
- "reflect": true,
755
- "default": false
756
- },
757
- {
758
- "name": "href",
759
- "attribute": "href",
760
- "type": "string",
761
- "converter": "string",
762
- "reflect": true,
763
- "default": ""
764
- },
765
- {
766
- "name": "target",
767
- "attribute": "target",
768
- "type": "string",
769
- "converter": "string",
770
- "reflect": true,
771
- "default": ""
772
- },
773
- {
774
- "name": "type",
775
- "attribute": "type",
776
- "type": "string",
777
- "converter": "string",
778
- "reflect": true,
779
- "default": "button"
780
- },
781
- {
782
- "name": "linkMode",
783
- "attribute": null,
784
- "type": "boolean",
785
- "converter": "boolean",
786
- "reflect": false,
787
- "default": null,
788
- "computed": true,
789
- "deps": ["href"]
790
- },
791
- {
792
- "name": "buttonMode",
793
- "attribute": null,
794
- "type": "boolean",
795
- "converter": "boolean",
796
- "reflect": false,
797
- "default": null,
798
- "computed": true,
799
- "deps": ["href"]
800
- },
801
- {
802
- "name": "linkHref",
803
- "attribute": null,
804
- "type": "string",
805
- "converter": "string",
806
- "reflect": false,
807
- "default": null,
808
- "computed": true,
809
- "deps": ["disabled", "href"]
810
- },
811
- {
812
- "name": "linkTarget",
813
- "attribute": null,
814
- "type": "string",
815
- "converter": "string",
816
- "reflect": false,
817
- "default": null,
818
- "computed": true,
819
- "deps": ["target"]
820
- },
821
- {
822
- "name": "linkRel",
823
- "attribute": null,
824
- "type": "string",
825
- "converter": "string",
826
- "reflect": false,
827
- "default": null,
828
- "computed": true,
829
- "deps": ["target"]
830
- },
831
- {
832
- "name": "linkAriaDisabled",
833
- "attribute": null,
834
- "type": "string",
835
- "converter": "string",
836
- "reflect": false,
837
- "default": null,
838
- "computed": true,
839
- "deps": ["disabled"]
840
- }
841
- ],
842
- "observedAttributes": [
843
- "variant",
844
- "size",
845
- "disabled",
846
- "href",
847
- "target",
848
- "type"
849
- ],
850
- "cem": {
851
- "tagName": "open-button",
852
- "className": "OpenButton",
853
- "declaration": {
854
- "name": "OpenButton",
855
- "module": "open-button.tsx"
856
- },
857
- "attributes": [
858
- {
859
- "name": "variant",
860
- "fieldName": "variant",
861
- "type": "string",
862
- "reflect": true
863
- },
864
- {
865
- "name": "size",
866
- "fieldName": "size",
867
- "type": "string",
868
- "reflect": true
869
- },
870
- {
871
- "name": "disabled",
872
- "fieldName": "disabled",
873
- "type": "boolean",
874
- "reflect": true
875
- },
876
- {
877
- "name": "href",
878
- "fieldName": "href",
879
- "type": "string",
880
- "reflect": true
881
- },
882
- {
883
- "name": "target",
884
- "fieldName": "target",
885
- "type": "string",
886
- "reflect": true
887
- },
888
- {
889
- "name": "type",
890
- "fieldName": "type",
891
- "type": "string",
892
- "reflect": true
893
- }
894
- ],
895
- "members": [
896
- {
897
- "name": "variant",
898
- "fieldName": "variant",
899
- "type": "string",
900
- "attribute": "variant",
901
- "reflect": true
902
- },
903
- {
904
- "name": "size",
905
- "fieldName": "size",
906
- "type": "string",
907
- "attribute": "size",
908
- "reflect": true
909
- },
910
- {
911
- "name": "disabled",
912
- "fieldName": "disabled",
913
- "type": "boolean",
914
- "attribute": "disabled",
915
- "reflect": true
916
- },
917
- {
918
- "name": "href",
919
- "fieldName": "href",
920
- "type": "string",
921
- "attribute": "href",
922
- "reflect": true
923
- },
924
- {
925
- "name": "target",
926
- "fieldName": "target",
927
- "type": "string",
928
- "attribute": "target",
929
- "reflect": true
930
- },
931
- {
932
- "name": "type",
933
- "fieldName": "type",
934
- "type": "string",
935
- "attribute": "type",
936
- "reflect": true
937
- },
938
- {
939
- "name": "linkMode",
940
- "fieldName": "linkMode",
941
- "type": "boolean",
942
- "attribute": null,
943
- "reflect": false
944
- },
945
- {
946
- "name": "buttonMode",
947
- "fieldName": "buttonMode",
948
- "type": "boolean",
949
- "attribute": null,
950
- "reflect": false
951
- },
952
- {
953
- "name": "linkHref",
954
- "fieldName": "linkHref",
955
- "type": "string",
956
- "attribute": null,
957
- "reflect": false
958
- },
959
- {
960
- "name": "linkTarget",
961
- "fieldName": "linkTarget",
962
- "type": "string",
963
- "attribute": null,
964
- "reflect": false
965
- },
966
- {
967
- "name": "linkRel",
968
- "fieldName": "linkRel",
969
- "type": "string",
970
- "attribute": null,
971
- "reflect": false
972
- },
973
- {
974
- "name": "linkAriaDisabled",
975
- "fieldName": "linkAriaDisabled",
976
- "type": "string",
977
- "attribute": null,
978
- "reflect": false
979
- }
980
- ]
981
- }
982
- };
983
- const __observedAttributes = [
984
- "variant",
985
- "size",
986
- "disabled",
987
- "href",
988
- "target",
989
- "type"
990
- ];
991
- const __compiledProps = {
992
- variant: {
993
- type: String,
994
- default: "default",
995
- reflect: true,
996
- attribute: "variant"
997
- },
998
- size: {
999
- type: String,
1000
- default: "md",
1001
- reflect: true,
1002
- attribute: "size"
1003
- },
1004
- disabled: {
1005
- type: Boolean,
1006
- default: false,
1007
- reflect: true,
1008
- attribute: "disabled"
1009
- },
1010
- href: {
1011
- type: String,
1012
- default: "",
1013
- reflect: true,
1014
- attribute: "href"
1015
- },
1016
- target: {
1017
- type: String,
1018
- default: "",
1019
- reflect: true,
1020
- attribute: "target"
1021
- },
1022
- type: {
1023
- type: String,
1024
- default: "button",
1025
- reflect: true,
1026
- attribute: "type"
1027
- },
1028
- linkMode: {
1029
- type: Object,
1030
- default: void 0,
1031
- reflect: false,
1032
- attribute: false
1033
- },
1034
- buttonMode: {
1035
- type: Object,
1036
- default: void 0,
1037
- reflect: false,
1038
- attribute: false
1039
- },
1040
- linkHref: {
1041
- type: Object,
1042
- default: void 0,
1043
- reflect: false,
1044
- attribute: false
1045
- },
1046
- linkTarget: {
1047
- type: Object,
1048
- default: void 0,
1049
- reflect: false,
1050
- attribute: false
1051
- },
1052
- linkRel: {
1053
- type: Object,
1054
- default: void 0,
1055
- reflect: false,
1056
- attribute: false
1057
- },
1058
- linkAriaDisabled: {
1059
- type: Object,
1060
- default: void 0,
1061
- reflect: false,
1062
- attribute: false
1063
- }
1064
- };
1065
- var OpenButton = class extends OpenElement {
1066
- static __partProgram = __partProgram;
1067
- static __compiledProperties = __compiledProperties;
1068
- static __elementMetadata = __elementMetadata;
1069
- static props = __compiledProps;
1070
- static observedAttributes = __observedAttributes;
1071
- static delegatesFocus = true;
1072
- static formAssociated = true;
1073
- static __computedFields = {
1074
- linkMode: (__s) => computed(() => __s.href.value !== ""),
1075
- buttonMode: (__s) => computed(() => __s.href.value === ""),
1076
- linkHref: (__s) => computed(() => __s.disabled.value || __s.href.value === "" ? null : __s.href.value),
1077
- linkTarget: (__s) => computed(() => __s.target.value === "" ? null : __s.target.value),
1078
- linkRel: (__s) => computed(() => __s.target.value === "_blank" ? "noopener noreferrer" : null),
1079
- linkAriaDisabled: (__s) => computed(() => __s.disabled.value ? "true" : null)
1080
- };
1081
- static styles = [controlRecipe, openButtonStyles];
1082
- variant = "default";
1083
- size = "md";
1084
- disabled = false;
1085
- href = "";
1086
- target = "";
1087
- type = "button";
1088
- onDsdHydrated() {
1089
- this.syncInternals();
1090
- }
1091
- onCsrRendered() {
1092
- this.syncInternals();
1093
- }
1094
- attributeChangedCallback(name, old, val) {
1095
- try {
1096
- super.attributeChangedCallback(name, old, val);
1097
- if (old === val) return;
1098
- if (name === "disabled") this.syncInternals();
1099
- } catch (error) {
1100
- if (!this._captureError(error)) throw error;
1101
- }
1102
- }
1103
- syncInternals() {
1104
- syncDisabledState(this._internals, this.disabled);
1105
- }
1106
- handleClick(e) {
1107
- if (this.disabled) {
1108
- e.preventDefault();
1109
- return;
1110
- }
1111
- this.dispatchEvent(new CustomEvent("open-click", {
1112
- bubbles: true,
1113
- composed: true
1114
- }));
1115
- if (this.href !== "") return;
1116
- const form = this._internals?.form ?? closestFormOf(this);
1117
- if (!form) return;
1118
- if (this.type === "submit") this.submitForm(form);
1119
- else if (this.type === "reset") form.reset();
1120
- }
1121
- submitForm(form) {
1122
- const SubmitEventCtor = globalThis.SubmitEvent;
1123
- const submitEvent = SubmitEventCtor ? new SubmitEventCtor("submit", {
1124
- bubbles: true,
1125
- cancelable: true,
1126
- composed: true
1127
- }) : new Event("submit", {
1128
- bubbles: true,
1129
- cancelable: true,
1130
- composed: true
1131
- });
1132
- form.dispatchEvent(submitEvent);
1133
- if (!submitEvent.defaultPrevented) {
1134
- const formEl = form;
1135
- if (typeof formEl.requestSubmit === "function") formEl.requestSubmit();
1136
- else formEl.submit();
1137
- }
1138
- }
1139
- render() {
1140
- throw new Error("[open:compiled-element] open-button is compiled to a Part Program; the runtime JSX render path is not available.");
1141
82
  }
1142
- };
83
+ });
84
+ /** Button or link control with variant/size surfaces and form participation. */
85
+ function OpenButton(props) {
86
+ const hostOf = (event) => event.currentTarget.getRootNode().host;
87
+ return /* @__PURE__ */ jsx("span", {
88
+ style: "display:contents",
89
+ onClick: (event) => {
90
+ activateButton(hostOf(event), event, () => {
91
+ hostOf(event).dispatchEvent(new globalThis.CustomEvent("open-click", {
92
+ bubbles: true,
93
+ composed: true
94
+ }));
95
+ });
96
+ },
97
+ children: props.href === "" ? /* @__PURE__ */ jsx("button", {
98
+ type: "button",
99
+ class: "btn inline-flex items-center justify-center gap-2 font-sans font-extrabold no-underline cursor-pointer rounded-md whitespace-nowrap focus-visible:outline-2 focus-visible:outline-offset-[3px] focus-visible:outline-ring disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:pointer-events-none",
100
+ part: "control",
101
+ disabled: props.disabled,
102
+ children: /* @__PURE__ */ jsx("slot", {})
103
+ }) : /* @__PURE__ */ jsx("a", {
104
+ class: "btn inline-flex items-center justify-center gap-2 font-sans font-extrabold no-underline cursor-pointer rounded-md whitespace-nowrap focus-visible:outline-2 focus-visible:outline-offset-[3px] focus-visible:outline-ring aria-disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:pointer-events-none",
105
+ part: "control",
106
+ href: props.disabled ? null : props.href,
107
+ target: props.target === "" ? null : props.target,
108
+ rel: props.target === "_blank" ? "noopener noreferrer" : null,
109
+ "aria-disabled": props.disabled ? "true" : null,
110
+ children: /* @__PURE__ */ jsx("slot", {})
111
+ })
112
+ });
113
+ }
1143
114
  //#endregion
1144
- export { OpenButton, __elementMetadata, __partProgram };
115
+ export { OpenButton as default, openElement };
116
+
117
+ export { OpenButtonElement, OpenButton__ssrHost } from './open-button.generated.js';
118
+
119
+ // openElement:class-candidates ["aria-disabled:cursor-not-allowed","aria-disabled:opacity-50","aria-disabled:pointer-events-none","btn","cursor-pointer","disabled:cursor-not-allowed","disabled:opacity-50","disabled:pointer-events-none","focus-visible:outline-2","focus-visible:outline-offset-[3px]","focus-visible:outline-ring","font-extrabold","font-sans","gap-2","inline-flex","items-center","justify-center","no-underline","rounded-md","whitespace-nowrap"]