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

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,10 +1,9 @@
1
1
  import { closestFormOf, syncDisabledState } from "./component-recipes.js";
2
2
  import { OpenElement, computed } from "@openelement/element";
3
- import controlRecipe from "./control-recipe.css";
4
3
  import openButtonStyles from "./open-button.css";
5
4
  //#region src/open-button.tsx
6
5
  const __partProgram = {
7
- "version": 1,
6
+ "version": 2,
8
7
  "tag": "open-button",
9
8
  "root": {
10
9
  "id": "root",
@@ -17,183 +16,160 @@ const __partProgram = {
17
16
  "tag": "span",
18
17
  "attrs": [["style", "display:contents"]],
19
18
  "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
- }]
19
+ "k": "part",
20
+ "id": "p7",
21
+ "index": 7
43
22
  }]
44
23
  }],
45
24
  "parts": [
46
25
  {
47
- "k": "attr",
48
- "signal": "linkHref",
49
- "name": "href",
50
- "path": [0, 0],
26
+ "k": "event",
27
+ "event": "click",
28
+ "handler": "handleClick",
29
+ "action": {
30
+ "kind": "method",
31
+ "name": "handleClick"
32
+ },
33
+ "path": [0],
51
34
  "index": 0,
52
35
  "location": {
53
36
  "id": "p0",
54
37
  "kind": "sink",
55
- "path": [0, 0],
56
- "node": "e1"
38
+ "path": [0],
39
+ "node": "e0"
57
40
  }
58
41
  },
59
42
  {
60
43
  "k": "attr",
61
- "signal": "linkTarget",
62
- "name": "target",
63
- "path": [0, 0],
44
+ "signal": "type",
45
+ "name": "type",
46
+ "path": [0],
64
47
  "index": 1,
65
48
  "location": {
66
49
  "id": "p1",
67
50
  "kind": "sink",
68
- "path": [0, 0],
51
+ "path": [0],
69
52
  "node": "e1"
70
53
  }
71
54
  },
72
55
  {
73
- "k": "attr",
74
- "signal": "linkRel",
75
- "name": "rel",
76
- "path": [0, 0],
56
+ "k": "bool",
57
+ "signal": "disabled",
58
+ "name": "disabled",
59
+ "path": [0],
77
60
  "index": 2,
78
61
  "location": {
79
62
  "id": "p2",
80
63
  "kind": "sink",
81
- "path": [0, 0],
64
+ "path": [0],
82
65
  "node": "e1"
83
66
  }
84
67
  },
85
68
  {
86
69
  "k": "attr",
87
- "signal": "linkAriaDisabled",
88
- "name": "aria-disabled",
89
- "path": [0, 0],
70
+ "signal": "linkHref",
71
+ "name": "href",
72
+ "path": [0],
90
73
  "index": 3,
91
74
  "location": {
92
75
  "id": "p3",
93
76
  "kind": "sink",
94
- "path": [0, 0],
95
- "node": "e1"
77
+ "path": [0],
78
+ "node": "e3"
96
79
  }
97
80
  },
98
81
  {
99
- "k": "bool",
100
- "signal": "buttonMode",
101
- "name": "hidden",
102
- "path": [0, 0],
82
+ "k": "attr",
83
+ "signal": "linkTarget",
84
+ "name": "target",
85
+ "path": [0],
103
86
  "index": 4,
104
87
  "location": {
105
88
  "id": "p4",
106
89
  "kind": "sink",
107
- "path": [0, 0],
108
- "node": "e1"
90
+ "path": [0],
91
+ "node": "e3"
109
92
  }
110
93
  },
111
94
  {
112
- "k": "event",
113
- "event": "click",
114
- "handler": "handleClick",
115
- "action": {
116
- "kind": "method",
117
- "name": "handleClick"
118
- },
119
- "path": [0, 0],
95
+ "k": "attr",
96
+ "signal": "linkRel",
97
+ "name": "rel",
98
+ "path": [0],
120
99
  "index": 5,
121
100
  "location": {
122
101
  "id": "p5",
123
102
  "kind": "sink",
124
- "path": [0, 0],
125
- "node": "e1"
103
+ "path": [0],
104
+ "node": "e3"
126
105
  }
127
106
  },
128
107
  {
129
108
  "k": "attr",
130
- "signal": "type",
131
- "name": "type",
132
- "path": [0, 1],
109
+ "signal": "linkAriaDisabled",
110
+ "name": "aria-disabled",
111
+ "path": [0],
133
112
  "index": 6,
134
113
  "location": {
135
114
  "id": "p6",
136
115
  "kind": "sink",
137
- "path": [0, 1],
116
+ "path": [0],
138
117
  "node": "e3"
139
118
  }
140
119
  },
141
120
  {
142
- "k": "bool",
143
- "signal": "disabled",
144
- "name": "disabled",
145
- "path": [0, 1],
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
+ }],
146
154
  "index": 7,
147
155
  "location": {
148
156
  "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"
157
+ "kind": "anchor",
158
+ "path": [0, 0]
182
159
  }
183
160
  }
184
161
  ],
185
- "regions": [],
162
+ "blocks": [{
163
+ "id": "r7",
164
+ "index": 7,
165
+ "kind": "when",
166
+ "anchor": "p7",
167
+ "end": "p7:end",
168
+ "source": "p7"
169
+ }],
186
170
  "dependencies": [
187
171
  {
188
- "signal": "linkHref",
189
- "owner": {
190
- "kind": "part",
191
- "index": 0
192
- },
193
- "location": "p0"
194
- },
195
- {
196
- "signal": "linkTarget",
172
+ "signal": "type",
197
173
  "owner": {
198
174
  "kind": "part",
199
175
  "index": 1
@@ -201,7 +177,7 @@ const __partProgram = {
201
177
  "location": "p1"
202
178
  },
203
179
  {
204
- "signal": "linkRel",
180
+ "signal": "disabled",
205
181
  "owner": {
206
182
  "kind": "part",
207
183
  "index": 2
@@ -209,7 +185,7 @@ const __partProgram = {
209
185
  "location": "p2"
210
186
  },
211
187
  {
212
- "signal": "linkAriaDisabled",
188
+ "signal": "linkHref",
213
189
  "owner": {
214
190
  "kind": "part",
215
191
  "index": 3
@@ -217,7 +193,7 @@ const __partProgram = {
217
193
  "location": "p3"
218
194
  },
219
195
  {
220
- "signal": "buttonMode",
196
+ "signal": "linkTarget",
221
197
  "owner": {
222
198
  "kind": "part",
223
199
  "index": 4
@@ -225,28 +201,28 @@ const __partProgram = {
225
201
  "location": "p4"
226
202
  },
227
203
  {
228
- "signal": "type",
204
+ "signal": "linkRel",
229
205
  "owner": {
230
206
  "kind": "part",
231
- "index": 6
207
+ "index": 5
232
208
  },
233
- "location": "p6"
209
+ "location": "p5"
234
210
  },
235
211
  {
236
- "signal": "disabled",
212
+ "signal": "linkAriaDisabled",
237
213
  "owner": {
238
214
  "kind": "part",
239
- "index": 7
215
+ "index": 6
240
216
  },
241
- "location": "p7"
217
+ "location": "p6"
242
218
  },
243
219
  {
244
- "signal": "linkMode",
220
+ "signal": "buttonMode",
245
221
  "owner": {
246
- "kind": "part",
247
- "index": 8
222
+ "kind": "region",
223
+ "index": 7
248
224
  },
249
- "location": "p8"
225
+ "location": "p7"
250
226
  }
251
227
  ],
252
228
  "locations": [
@@ -256,107 +232,84 @@ const __partProgram = {
256
232
  "tag": "span",
257
233
  "path": [0]
258
234
  },
259
- {
260
- "id": "e1",
261
- "kind": "element",
262
- "tag": "a",
263
- "path": [0, 0]
264
- },
265
235
  {
266
236
  "id": "p0",
267
237
  "kind": "sink",
268
238
  "part": 0,
269
- "node": "e1",
270
- "path": [0, 0]
239
+ "node": "e0",
240
+ "path": [0]
241
+ },
242
+ {
243
+ "id": "e1",
244
+ "kind": "element",
245
+ "tag": "button",
246
+ "path": [0]
271
247
  },
272
248
  {
273
249
  "id": "p1",
274
250
  "kind": "sink",
275
251
  "part": 1,
276
252
  "node": "e1",
277
- "path": [0, 0]
253
+ "path": [0]
278
254
  },
279
255
  {
280
256
  "id": "p2",
281
257
  "kind": "sink",
282
258
  "part": 2,
283
259
  "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]
260
+ "path": [0]
306
261
  },
307
262
  {
308
263
  "id": "e2",
309
264
  "kind": "element",
310
265
  "tag": "slot",
311
- "path": [
312
- 0,
313
- 0,
314
- 0
315
- ]
266
+ "path": [0, 0]
316
267
  },
317
268
  {
318
269
  "id": "e3",
319
270
  "kind": "element",
320
- "tag": "button",
321
- "path": [0, 1]
271
+ "tag": "a",
272
+ "path": [0]
322
273
  },
323
274
  {
324
- "id": "p6",
275
+ "id": "p3",
325
276
  "kind": "sink",
326
- "part": 6,
277
+ "part": 3,
327
278
  "node": "e3",
328
- "path": [0, 1]
279
+ "path": [0]
329
280
  },
330
281
  {
331
- "id": "p7",
282
+ "id": "p4",
332
283
  "kind": "sink",
333
- "part": 7,
284
+ "part": 4,
334
285
  "node": "e3",
335
- "path": [0, 1]
286
+ "path": [0]
336
287
  },
337
288
  {
338
- "id": "p8",
289
+ "id": "p5",
339
290
  "kind": "sink",
340
- "part": 8,
291
+ "part": 5,
341
292
  "node": "e3",
342
- "path": [0, 1]
293
+ "path": [0]
343
294
  },
344
295
  {
345
- "id": "p9",
296
+ "id": "p6",
346
297
  "kind": "sink",
347
- "part": 9,
298
+ "part": 6,
348
299
  "node": "e3",
349
- "path": [0, 1]
300
+ "path": [0]
350
301
  },
351
302
  {
352
303
  "id": "e4",
353
304
  "kind": "element",
354
305
  "tag": "slot",
355
- "path": [
356
- 0,
357
- 1,
358
- 0
359
- ]
306
+ "path": [0, 0]
307
+ },
308
+ {
309
+ "id": "p7",
310
+ "kind": "anchor",
311
+ "part": 7,
312
+ "path": [0, 0]
360
313
  }
361
314
  ],
362
315
  "metadata": {
@@ -412,16 +365,6 @@ const __partProgram = {
412
365
  "reflect": true,
413
366
  "default": "button"
414
367
  },
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
368
  {
426
369
  "name": "buttonMode",
427
370
  "attribute": null,
@@ -569,13 +512,6 @@ const __partProgram = {
569
512
  "attribute": "type",
570
513
  "reflect": true
571
514
  },
572
- {
573
- "name": "linkMode",
574
- "fieldName": "linkMode",
575
- "type": "boolean",
576
- "attribute": null,
577
- "reflect": false
578
- },
579
515
  {
580
516
  "name": "buttonMode",
581
517
  "fieldName": "buttonMode",
@@ -664,16 +600,6 @@ const __compiledProperties = [
664
600
  "reflect": true,
665
601
  "default": "button"
666
602
  },
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
603
  {
678
604
  "name": "buttonMode",
679
605
  "attribute": null,
@@ -778,16 +704,6 @@ const __elementMetadata = {
778
704
  "reflect": true,
779
705
  "default": "button"
780
706
  },
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
707
  {
792
708
  "name": "buttonMode",
793
709
  "attribute": null,
@@ -935,13 +851,6 @@ const __elementMetadata = {
935
851
  "attribute": "type",
936
852
  "reflect": true
937
853
  },
938
- {
939
- "name": "linkMode",
940
- "fieldName": "linkMode",
941
- "type": "boolean",
942
- "attribute": null,
943
- "reflect": false
944
- },
945
854
  {
946
855
  "name": "buttonMode",
947
856
  "fieldName": "buttonMode",
@@ -1025,12 +934,6 @@ const __compiledProps = {
1025
934
  reflect: true,
1026
935
  attribute: "type"
1027
936
  },
1028
- linkMode: {
1029
- type: Object,
1030
- default: void 0,
1031
- reflect: false,
1032
- attribute: false
1033
- },
1034
937
  buttonMode: {
1035
938
  type: Object,
1036
939
  default: void 0,
@@ -1070,15 +973,37 @@ var OpenButton = class extends OpenElement {
1070
973
  static observedAttributes = __observedAttributes;
1071
974
  static delegatesFocus = true;
1072
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
+ ];
1073
999
  static __computedFields = {
1074
- linkMode: (__s) => computed(() => __s.href.value !== ""),
1075
1000
  buttonMode: (__s) => computed(() => __s.href.value === ""),
1076
1001
  linkHref: (__s) => computed(() => __s.disabled.value || __s.href.value === "" ? null : __s.href.value),
1077
1002
  linkTarget: (__s) => computed(() => __s.target.value === "" ? null : __s.target.value),
1078
1003
  linkRel: (__s) => computed(() => __s.target.value === "_blank" ? "noopener noreferrer" : null),
1079
1004
  linkAriaDisabled: (__s) => computed(() => __s.disabled.value ? "true" : null)
1080
1005
  };
1081
- static styles = [controlRecipe, openButtonStyles];
1006
+ static styles = [openButtonStyles];
1082
1007
  variant = "default";
1083
1008
  size = "md";
1084
1009
  disabled = false;
@@ -1,46 +1,26 @@
1
- /* open-code-block — authored component styles, ported verbatim from the pre-#1558
2
- * recipe() sheet (the alpha.9 design system). The #1558 migration had
3
- * replaced this with a placeholder shell under the false note that the
4
- * component "carried no authored styles"; it did — this is that sheet. */
5
- :host {
6
- display: block;
7
- position: relative;
8
- }
1
+ /* open-code-block — the irreducible authored rules (alpha15 S lane).
2
+ *
3
+ * The chip's presentation is authored as Tailwind utilities on the button in
4
+ * open-code-block.tsx: the compiler admits every static class token and the
5
+ * build compiles the component stylesheet (theme + utilities) into the shadow
6
+ * root. What stays here, and why (CUSTOMIZATION.md -> "Why the residue is CSS"):
7
+ * the host box, and the `:state()`-scoped copy feedback — the state lives on the
8
+ * HOST, so the `:host(:state(...))` selector is what ties the rule to it (its
9
+ * utility spelling, `[:host(:state(copied))_&]:text-success`, compiles, and the
10
+ * owned rule reads better). Both feedback rules read role table colors, so they
11
+ * follow a consumer's retheme and re-seat in forced-colors. */
12
+ :host {
13
+ display: block;
14
+ position: relative;
15
+ }
9
16
 
10
- .copy-btn {
11
- position: absolute;
12
- top: calc(var(--spacing) * 2);
13
- right: calc(var(--spacing) * 2);
14
- background: color-mix(in srgb, var(--color-primary) 14%, transparent);
15
- color: var(--color-foreground);
16
- padding: calc(var(--spacing) * 1) calc(var(--spacing) * 3);
17
- font-size: var(--text-xs);
18
- font-family: var(--font-sans);
19
- font-weight: var(--font-weight-semibold);
20
- border: 0.5px solid transparent;
21
- cursor: pointer;
22
- border-radius: var(--radius-md);
23
- transition: all var(--ease-in-out) var(--default-transition-duration);
24
- z-index: 1;
25
- letter-spacing: var(--tracking-wider);
26
- }
17
+ :host(:state(copied)) .copy-btn {
18
+ color: var(--color-success);
19
+ border-color: color-mix(in srgb, var(--color-success) 30%, transparent);
20
+ background: color-mix(in srgb, var(--color-success) 8%, transparent);
21
+ }
27
22
 
28
- /* No ink override on hover: the primary-foreground ink belongs to a brand
29
- *fill*, and this chip's hover surface is a translucent brand tint
30
- instead, so the chip keeps the code surface's ink. */
31
- .copy-btn:hover {
32
- background: color-mix(in srgb, var(--color-primary) 23%, transparent);
33
- border-color: var(--color-primary);
34
- }
35
-
36
- :host(:state(copied)) .copy-btn {
37
- color: #22c55e;
38
- border-color: rgba(34,197,94,0.3);
39
- background: rgba(34,197,94,0.08);
40
- }
41
-
42
- :host(:state(failed)) .copy-btn {
43
- color: var(--color-destructive);
44
- border-color: var(--color-destructive);
45
- }
46
-
23
+ :host(:state(failed)) .copy-btn {
24
+ color: var(--color-destructive);
25
+ border-color: var(--color-destructive);
26
+ }