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