@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,501 +1,359 @@
1
- // <auto-generated by open:compiled-element; v0.44.0-alpha.1 - do not edit>
2
- import { computed, OpenElement } from '@openelement/element';
3
- import { deepActiveElement, nextInstanceId, overlayRecipe, recipe } from './component-recipes.js';
4
- import { readInstanceState, writeInstanceState } from './instance-state.js';
1
+ import { readInstanceState, writeInstanceState } from "./instance-state.js";
2
+ import { deepActiveElement, nextInstanceId } from "./component-recipes.js";
3
+ import { OpenElement, computed } from "@openelement/element";
4
+ import overlayRecipe from "./overlay-recipe.css";
5
+ import openDropdownStyles from "./open-dropdown.css";
6
+ //#region src/open-dropdown.tsx
5
7
  const __partProgram = {
6
- "version": 1,
7
- "tag": "open-dropdown",
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": "div",
20
- "attrs": [],
21
- "children": [
22
- {
23
- "k": "el",
24
- "id": "e1",
25
- "tag": "span",
26
- "attrs": [
27
- [
28
- "class",
29
- "trigger"
30
- ],
31
- [
32
- "part",
33
- "trigger"
34
- ]
35
- ],
36
- "children": [
37
- {
38
- "k": "el",
39
- "id": "e2",
40
- "tag": "slot",
41
- "attrs": [
42
- [
43
- "name",
44
- "trigger"
45
- ]
46
- ],
47
- "children": []
48
- }
49
- ]
50
- },
51
- {
52
- "k": "el",
53
- "id": "e3",
54
- "tag": "div",
55
- "attrs": [
56
- [
57
- "class",
58
- "overlay content"
59
- ],
60
- [
61
- "part",
62
- "content"
63
- ],
64
- [
65
- "popover",
66
- "auto"
67
- ]
68
- ],
69
- "children": [
70
- {
71
- "k": "el",
72
- "id": "e4",
73
- "tag": "slot",
74
- "attrs": [],
75
- "children": []
76
- }
77
- ]
78
- }
79
- ]
80
- }
81
- ],
82
- "parts": [
83
- {
84
- "k": "event",
85
- "event": "pointerdown",
86
- "handler": "onTriggerPointerDown",
87
- "action": {
88
- "kind": "method",
89
- "name": "onTriggerPointerDown"
90
- },
91
- "path": [
92
- 0,
93
- 0
94
- ],
95
- "index": 0,
96
- "location": {
97
- "id": "p0",
98
- "kind": "sink",
99
- "path": [
100
- 0,
101
- 0
102
- ],
103
- "node": "e1"
104
- }
105
- },
106
- {
107
- "k": "event",
108
- "event": "click",
109
- "handler": "toggle",
110
- "action": {
111
- "kind": "method",
112
- "name": "toggle"
113
- },
114
- "path": [
115
- 0,
116
- 0
117
- ],
118
- "index": 1,
119
- "location": {
120
- "id": "p1",
121
- "kind": "sink",
122
- "path": [
123
- 0,
124
- 0
125
- ],
126
- "node": "e1"
127
- }
128
- },
129
- {
130
- "k": "style",
131
- "signal": "anchorStyle",
132
- "path": [
133
- 0,
134
- 1
135
- ],
136
- "index": 2,
137
- "location": {
138
- "id": "p2",
139
- "kind": "sink",
140
- "path": [
141
- 0,
142
- 1
143
- ],
144
- "node": "e3"
145
- }
146
- }
147
- ],
148
- "regions": [],
149
- "dependencies": [
150
- {
151
- "signal": "anchorStyle",
152
- "owner": {
153
- "kind": "part",
154
- "index": 2
155
- },
156
- "location": "p2"
157
- }
158
- ],
159
- "locations": [
160
- {
161
- "id": "e0",
162
- "kind": "element",
163
- "tag": "div",
164
- "path": [
165
- 0
166
- ]
167
- },
168
- {
169
- "id": "e1",
170
- "kind": "element",
171
- "tag": "span",
172
- "path": [
173
- 0,
174
- 0
175
- ]
176
- },
177
- {
178
- "id": "p0",
179
- "kind": "sink",
180
- "part": 0,
181
- "node": "e1",
182
- "path": [
183
- 0,
184
- 0
185
- ]
186
- },
187
- {
188
- "id": "p1",
189
- "kind": "sink",
190
- "part": 1,
191
- "node": "e1",
192
- "path": [
193
- 0,
194
- 0
195
- ]
196
- },
197
- {
198
- "id": "e2",
199
- "kind": "element",
200
- "tag": "slot",
201
- "path": [
202
- 0,
203
- 0,
204
- 0
205
- ]
206
- },
207
- {
208
- "id": "e3",
209
- "kind": "element",
210
- "tag": "div",
211
- "path": [
212
- 0,
213
- 1
214
- ]
215
- },
216
- {
217
- "id": "p2",
218
- "kind": "sink",
219
- "part": 2,
220
- "node": "e3",
221
- "path": [
222
- 0,
223
- 1
224
- ]
225
- },
226
- {
227
- "id": "e4",
228
- "kind": "element",
229
- "tag": "slot",
230
- "path": [
231
- 0,
232
- 1,
233
- 0
234
- ]
235
- }
236
- ],
237
- "metadata": {
238
- "tag": "open-dropdown",
239
- "className": "OpenDropdown",
240
- "sourceFile": "open-dropdown.tsx",
241
- "properties": [
242
- {
243
- "name": "anchorName",
244
- "attribute": null,
245
- "type": "string",
246
- "converter": "string",
247
- "reflect": false,
248
- "default": ""
249
- },
250
- {
251
- "name": "anchorStyle",
252
- "attribute": null,
253
- "type": "string",
254
- "converter": "string",
255
- "reflect": false,
256
- "default": null,
257
- "computed": true,
258
- "deps": [
259
- "anchorName"
260
- ]
261
- }
262
- ],
263
- "observedAttributes": [],
264
- "cem": {
265
- "tagName": "open-dropdown",
266
- "className": "OpenDropdown",
267
- "declaration": {
268
- "name": "OpenDropdown",
269
- "module": "open-dropdown.tsx"
270
- },
271
- "attributes": [],
272
- "members": [
273
- {
274
- "name": "anchorName",
275
- "fieldName": "anchorName",
276
- "type": "string",
277
- "attribute": null,
278
- "reflect": false
279
- },
280
- {
281
- "name": "anchorStyle",
282
- "fieldName": "anchorStyle",
283
- "type": "string",
284
- "attribute": null,
285
- "reflect": false
286
- }
287
- ]
288
- }
289
- }
8
+ "version": 1,
9
+ "tag": "open-dropdown",
10
+ "root": {
11
+ "id": "root",
12
+ "kind": "shadow-open",
13
+ "nodes": ["e0"]
14
+ },
15
+ "template": [{
16
+ "k": "el",
17
+ "id": "e0",
18
+ "tag": "div",
19
+ "attrs": [],
20
+ "children": [{
21
+ "k": "el",
22
+ "id": "e1",
23
+ "tag": "span",
24
+ "attrs": [["class", "trigger"], ["part", "trigger"]],
25
+ "children": [{
26
+ "k": "el",
27
+ "id": "e2",
28
+ "tag": "slot",
29
+ "attrs": [["name", "trigger"]],
30
+ "children": []
31
+ }]
32
+ }, {
33
+ "k": "el",
34
+ "id": "e3",
35
+ "tag": "div",
36
+ "attrs": [
37
+ ["class", "overlay content"],
38
+ ["part", "content"],
39
+ ["popover", "auto"]
40
+ ],
41
+ "children": [{
42
+ "k": "el",
43
+ "id": "e4",
44
+ "tag": "slot",
45
+ "attrs": [],
46
+ "children": []
47
+ }]
48
+ }]
49
+ }],
50
+ "parts": [
51
+ {
52
+ "k": "event",
53
+ "event": "pointerdown",
54
+ "handler": "onTriggerPointerDown",
55
+ "action": {
56
+ "kind": "method",
57
+ "name": "onTriggerPointerDown"
58
+ },
59
+ "path": [0, 0],
60
+ "index": 0,
61
+ "location": {
62
+ "id": "p0",
63
+ "kind": "sink",
64
+ "path": [0, 0],
65
+ "node": "e1"
66
+ }
67
+ },
68
+ {
69
+ "k": "event",
70
+ "event": "click",
71
+ "handler": "toggle",
72
+ "action": {
73
+ "kind": "method",
74
+ "name": "toggle"
75
+ },
76
+ "path": [0, 0],
77
+ "index": 1,
78
+ "location": {
79
+ "id": "p1",
80
+ "kind": "sink",
81
+ "path": [0, 0],
82
+ "node": "e1"
83
+ }
84
+ },
85
+ {
86
+ "k": "style",
87
+ "signal": "anchorStyle",
88
+ "path": [0, 1],
89
+ "index": 2,
90
+ "location": {
91
+ "id": "p2",
92
+ "kind": "sink",
93
+ "path": [0, 1],
94
+ "node": "e3"
95
+ }
96
+ }
97
+ ],
98
+ "regions": [],
99
+ "dependencies": [{
100
+ "signal": "anchorStyle",
101
+ "owner": {
102
+ "kind": "part",
103
+ "index": 2
104
+ },
105
+ "location": "p2"
106
+ }],
107
+ "locations": [
108
+ {
109
+ "id": "e0",
110
+ "kind": "element",
111
+ "tag": "div",
112
+ "path": [0]
113
+ },
114
+ {
115
+ "id": "e1",
116
+ "kind": "element",
117
+ "tag": "span",
118
+ "path": [0, 0]
119
+ },
120
+ {
121
+ "id": "p0",
122
+ "kind": "sink",
123
+ "part": 0,
124
+ "node": "e1",
125
+ "path": [0, 0]
126
+ },
127
+ {
128
+ "id": "p1",
129
+ "kind": "sink",
130
+ "part": 1,
131
+ "node": "e1",
132
+ "path": [0, 0]
133
+ },
134
+ {
135
+ "id": "e2",
136
+ "kind": "element",
137
+ "tag": "slot",
138
+ "path": [
139
+ 0,
140
+ 0,
141
+ 0
142
+ ]
143
+ },
144
+ {
145
+ "id": "e3",
146
+ "kind": "element",
147
+ "tag": "div",
148
+ "path": [0, 1]
149
+ },
150
+ {
151
+ "id": "p2",
152
+ "kind": "sink",
153
+ "part": 2,
154
+ "node": "e3",
155
+ "path": [0, 1]
156
+ },
157
+ {
158
+ "id": "e4",
159
+ "kind": "element",
160
+ "tag": "slot",
161
+ "path": [
162
+ 0,
163
+ 1,
164
+ 0
165
+ ]
166
+ }
167
+ ],
168
+ "metadata": {
169
+ "tag": "open-dropdown",
170
+ "className": "OpenDropdown",
171
+ "sourceFile": "open-dropdown.tsx",
172
+ "properties": [{
173
+ "name": "anchorName",
174
+ "attribute": null,
175
+ "type": "string",
176
+ "converter": "string",
177
+ "reflect": false,
178
+ "default": ""
179
+ }, {
180
+ "name": "anchorStyle",
181
+ "attribute": null,
182
+ "type": "string",
183
+ "converter": "string",
184
+ "reflect": false,
185
+ "default": null,
186
+ "computed": true,
187
+ "deps": ["anchorName"]
188
+ }],
189
+ "observedAttributes": [],
190
+ "cem": {
191
+ "tagName": "open-dropdown",
192
+ "className": "OpenDropdown",
193
+ "declaration": {
194
+ "name": "OpenDropdown",
195
+ "module": "open-dropdown.tsx"
196
+ },
197
+ "attributes": [],
198
+ "members": [{
199
+ "name": "anchorName",
200
+ "fieldName": "anchorName",
201
+ "type": "string",
202
+ "attribute": null,
203
+ "reflect": false
204
+ }, {
205
+ "name": "anchorStyle",
206
+ "fieldName": "anchorStyle",
207
+ "type": "string",
208
+ "attribute": null,
209
+ "reflect": false
210
+ }]
211
+ }
212
+ }
290
213
  };
291
- const __compiledProperties = [
292
- {
293
- "name": "anchorName",
294
- "attribute": null,
295
- "type": "string",
296
- "converter": "string",
297
- "reflect": false,
298
- "default": ""
299
- },
300
- {
301
- "name": "anchorStyle",
302
- "attribute": null,
303
- "type": "string",
304
- "converter": "string",
305
- "reflect": false,
306
- "default": null,
307
- "computed": true,
308
- "deps": [
309
- "anchorName"
310
- ]
311
- }
312
- ];
214
+ const __compiledProperties = [{
215
+ "name": "anchorName",
216
+ "attribute": null,
217
+ "type": "string",
218
+ "converter": "string",
219
+ "reflect": false,
220
+ "default": ""
221
+ }, {
222
+ "name": "anchorStyle",
223
+ "attribute": null,
224
+ "type": "string",
225
+ "converter": "string",
226
+ "reflect": false,
227
+ "default": null,
228
+ "computed": true,
229
+ "deps": ["anchorName"]
230
+ }];
313
231
  const __elementMetadata = {
314
- "tag": "open-dropdown",
315
- "className": "OpenDropdown",
316
- "sourceFile": "open-dropdown.tsx",
317
- "properties": [
318
- {
319
- "name": "anchorName",
320
- "attribute": null,
321
- "type": "string",
322
- "converter": "string",
323
- "reflect": false,
324
- "default": ""
325
- },
326
- {
327
- "name": "anchorStyle",
328
- "attribute": null,
329
- "type": "string",
330
- "converter": "string",
331
- "reflect": false,
332
- "default": null,
333
- "computed": true,
334
- "deps": [
335
- "anchorName"
336
- ]
337
- }
338
- ],
339
- "observedAttributes": [],
340
- "cem": {
341
- "tagName": "open-dropdown",
342
- "className": "OpenDropdown",
343
- "declaration": {
344
- "name": "OpenDropdown",
345
- "module": "open-dropdown.tsx"
346
- },
347
- "attributes": [],
348
- "members": [
349
- {
350
- "name": "anchorName",
351
- "fieldName": "anchorName",
352
- "type": "string",
353
- "attribute": null,
354
- "reflect": false
355
- },
356
- {
357
- "name": "anchorStyle",
358
- "fieldName": "anchorStyle",
359
- "type": "string",
360
- "attribute": null,
361
- "reflect": false
362
- }
363
- ]
364
- }
232
+ "tag": "open-dropdown",
233
+ "className": "OpenDropdown",
234
+ "sourceFile": "open-dropdown.tsx",
235
+ "properties": [{
236
+ "name": "anchorName",
237
+ "attribute": null,
238
+ "type": "string",
239
+ "converter": "string",
240
+ "reflect": false,
241
+ "default": ""
242
+ }, {
243
+ "name": "anchorStyle",
244
+ "attribute": null,
245
+ "type": "string",
246
+ "converter": "string",
247
+ "reflect": false,
248
+ "default": null,
249
+ "computed": true,
250
+ "deps": ["anchorName"]
251
+ }],
252
+ "observedAttributes": [],
253
+ "cem": {
254
+ "tagName": "open-dropdown",
255
+ "className": "OpenDropdown",
256
+ "declaration": {
257
+ "name": "OpenDropdown",
258
+ "module": "open-dropdown.tsx"
259
+ },
260
+ "attributes": [],
261
+ "members": [{
262
+ "name": "anchorName",
263
+ "fieldName": "anchorName",
264
+ "type": "string",
265
+ "attribute": null,
266
+ "reflect": false
267
+ }, {
268
+ "name": "anchorStyle",
269
+ "fieldName": "anchorStyle",
270
+ "type": "string",
271
+ "attribute": null,
272
+ "reflect": false
273
+ }]
274
+ }
365
275
  };
366
276
  const __observedAttributes = [];
367
277
  const __compiledProps = {
368
- anchorName: {
369
- type: String,
370
- default: '',
371
- reflect: false,
372
- attribute: false
373
- },
374
- anchorStyle: {
375
- type: Object,
376
- default: undefined,
377
- reflect: false,
378
- attribute: false
379
- }
278
+ anchorName: {
279
+ type: String,
280
+ default: "",
281
+ reflect: false,
282
+ attribute: false
283
+ },
284
+ anchorStyle: {
285
+ type: Object,
286
+ default: void 0,
287
+ reflect: false,
288
+ attribute: false
289
+ }
380
290
  };
381
- export class OpenDropdown extends OpenElement {
382
- static __partProgram = __partProgram;
383
- static __compiledProperties = __compiledProperties;
384
- static __elementMetadata = __elementMetadata;
385
- static props = __compiledProps;
386
- static observedAttributes = __observedAttributes;
387
- static __computedFields = {
388
- anchorStyle: (__s)=>computed(()=>__s.anchorName.value === '' ? '' : `position-anchor: ${__s.anchorName.value}`)
389
- };
390
- static styles = [
391
- overlayRecipe,
392
- recipe(`
393
- :host {
394
- display: inline-block;
395
- }
396
-
397
- .trigger {
398
- display: contents;
399
- }
400
-
401
- .content {
402
- /* The base inset is the placement fallback for engines without CSS Anchor
403
- Positioning; it must stay present because Firefox's anchor resolution
404
- only applies anchor() longhands on top of an explicit inset. */
405
- position: absolute;
406
- inset: 100% auto auto 0;
407
- top: anchor(bottom);
408
- left: anchor(left);
409
- min-width: 12rem;
410
- /* The gap rides on margin-top: calc(anchor() + length) resolves without
411
- the added length in Firefox. */
412
- margin: var(--size-2) 0 0;
413
- padding: var(--size-2);
414
- font-family: var(--font-sans);
415
- }
416
- `)
417
- ];
418
- anchorName = '';
419
- onDsdHydrated() {
420
- this.syncAnchorName();
421
- this.watchFocusReturn();
422
- }
423
- onCsrRendered() {
424
- this.syncAnchorName();
425
- this.watchFocusReturn();
426
- }
427
- watchFocusReturn() {
428
- if (readInstanceState(this, 'focusWired', ()=>false)) return;
429
- writeInstanceState(this, 'focusWired', true);
430
- const content = this.shadowRoot?.querySelector('.content');
431
- if (!content) return;
432
- content.addEventListener('focusin', ()=>{
433
- writeInstanceState(this, 'popoverHadFocus', true);
434
- });
435
- // 'beforetoggle' fires synchronously before the open flip — therefore
436
- // before showPopover()'s focusing steps (an autofocus descendant) and
437
- // before any same-task programmatic .focus() into the popover (the
438
- // menu-button composition pattern). Resetting the record here, instead of
439
- // in the queued 'toggle' task, closes the race where focus entering the
440
- // popover within the opening task had its focusin record wiped, silently
441
- // disabling focus return. The same synchronous point also captures the
442
- // return-focus target for every open path, including direct showPopover()
443
- // calls that never pass through toggle().
444
- content.addEventListener('beforetoggle', (event)=>{
445
- if (event.newState !== 'open') return;
446
- writeInstanceState(this, 'popoverHadFocus', false);
447
- writeInstanceState(this, 'previouslyFocused', deepActiveElement());
448
- });
449
- content.addEventListener('toggle', (event)=>{
450
- const toggle = event;
451
- if (toggle.newState !== 'closed') return;
452
- const hadFocus = readInstanceState(this, 'popoverHadFocus', ()=>false);
453
- const previous = readInstanceState(this, 'previouslyFocused', ()=>null);
454
- writeInstanceState(this, 'previouslyFocused', null);
455
- if (!hadFocus || !previous?.isConnected) return;
456
- // The platform settles focus around the toggle event, not before it:
457
- // the same-tree native restore lands by itself (active === previous),
458
- // while the cross-shadow defect leaves focus inside the closing
459
- // popover or drops it to <body> — both mean "restore it ourselves".
460
- // A deliberate move (outside click) is neither and is left alone.
461
- queueMicrotask(()=>{
462
- if (!previous.isConnected) return;
463
- const active = deepActiveElement();
464
- if (active === previous) return;
465
- const focusInside = active !== null && (this.contains(active) || content.contains(active));
466
- const dropped = !active || active === document.body || active === document.documentElement;
467
- if (!focusInside && !dropped) return;
468
- previous.focus();
469
- });
470
- });
471
- }
472
- syncAnchorName() {
473
- if (this.anchorName === '') {
474
- this.anchorName = `--open-dropdown-trigger-${nextInstanceId()}`;
475
- }
476
- this.style.setProperty('anchor-name', this.anchorName);
477
- }
478
- onTriggerPointerDown() {
479
- const content = this.shadowRoot?.querySelector('.content');
480
- writeInstanceState(this, 'openAtPointerDown', content?.matches(':popover-open') ?? false);
481
- }
482
- toggle() {
483
- // A mouse click on the trigger is preceded by a pointerdown that natively
484
- // light-dismisses an open popover; the click that follows must not re-open
485
- // it. Keyboard/programmatic clicks have no pointerdown and toggle normally.
486
- const wasOpen = readInstanceState(this, 'openAtPointerDown', ()=>false);
487
- writeInstanceState(this, 'openAtPointerDown', false);
488
- if (wasOpen) return;
489
- const content = this.shadowRoot?.querySelector('.content');
490
- if (!content) return;
491
- // watchFocusReturn's synchronous 'beforetoggle' listener is the single
492
- // owner of the return-focus capture (#1226); it runs inside
493
- // togglePopover() before the open flip, so nothing can move focus between
494
- // this call and the capture.
495
- content.togglePopover();
496
- }
497
- render() {
498
- throw new Error('[open:compiled-element] open-dropdown is compiled to a Part Program; the runtime JSX render path is not available in 0.44.');
499
- }
500
- }
501
- export { __partProgram, __elementMetadata };
291
+ var OpenDropdown = class extends OpenElement {
292
+ static __partProgram = __partProgram;
293
+ static __compiledProperties = __compiledProperties;
294
+ static __elementMetadata = __elementMetadata;
295
+ static props = __compiledProps;
296
+ static observedAttributes = __observedAttributes;
297
+ static __computedFields = { anchorStyle: (__s) => computed(() => __s.anchorName.value === "" ? "" : `position-anchor: ${__s.anchorName.value}`) };
298
+ static styles = [overlayRecipe, openDropdownStyles];
299
+ anchorName = "";
300
+ onDsdHydrated() {
301
+ this.syncAnchorName();
302
+ this.watchFocusReturn();
303
+ }
304
+ onCsrRendered() {
305
+ this.syncAnchorName();
306
+ this.watchFocusReturn();
307
+ }
308
+ watchFocusReturn() {
309
+ if (readInstanceState(this, "focusWired", () => false)) return;
310
+ writeInstanceState(this, "focusWired", true);
311
+ const content = this.shadowRoot?.querySelector(".content");
312
+ if (!content) return;
313
+ content.addEventListener("focusin", () => {
314
+ writeInstanceState(this, "popoverHadFocus", true);
315
+ });
316
+ content.addEventListener("beforetoggle", (event) => {
317
+ if (event.newState !== "open") return;
318
+ writeInstanceState(this, "popoverHadFocus", false);
319
+ writeInstanceState(this, "previouslyFocused", deepActiveElement());
320
+ });
321
+ content.addEventListener("toggle", (event) => {
322
+ if (event.newState !== "closed") return;
323
+ const hadFocus = readInstanceState(this, "popoverHadFocus", () => false);
324
+ const previous = readInstanceState(this, "previouslyFocused", () => null);
325
+ writeInstanceState(this, "previouslyFocused", null);
326
+ if (!hadFocus || !previous?.isConnected) return;
327
+ queueMicrotask(() => {
328
+ if (!previous.isConnected) return;
329
+ const active = deepActiveElement();
330
+ if (active === previous) return;
331
+ const focusInside = active !== null && (this.contains(active) || content.contains(active));
332
+ const dropped = !active || active === document.body || active === document.documentElement;
333
+ if (!focusInside && !dropped) return;
334
+ previous.focus();
335
+ });
336
+ });
337
+ }
338
+ syncAnchorName() {
339
+ if (this.anchorName === "") this.anchorName = `--open-dropdown-trigger-${nextInstanceId()}`;
340
+ this.style.setProperty("anchor-name", this.anchorName);
341
+ }
342
+ onTriggerPointerDown() {
343
+ const content = this.shadowRoot?.querySelector(".content");
344
+ writeInstanceState(this, "openAtPointerDown", content?.matches(":popover-open") ?? false);
345
+ }
346
+ toggle() {
347
+ const wasOpen = readInstanceState(this, "openAtPointerDown", () => false);
348
+ writeInstanceState(this, "openAtPointerDown", false);
349
+ if (wasOpen) return;
350
+ const content = this.shadowRoot?.querySelector(".content");
351
+ if (!content) return;
352
+ content.togglePopover();
353
+ }
354
+ render() {
355
+ throw new Error("[open:compiled-element] open-dropdown is compiled to a Part Program; the runtime JSX render path is not available.");
356
+ }
357
+ };
358
+ //#endregion
359
+ export { OpenDropdown, __elementMetadata, __partProgram };