@openelement/ui 1.0.0-alpha.6 → 1.0.0-alpha.7
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.
- package/package.json +2 -2
- package/src/component-recipes.js +60 -60
- package/src/generated-manifest.json +1 -1
- package/src/index.d.ts +15 -43
- package/src/index.js +15 -50
- package/src/instance-state.d.ts +16 -2
- package/src/instance-state.js +30 -24
- package/src/manifest.d.ts +5 -9
- package/src/manifest.js +6 -11
- package/src/open-badge.d.ts +113 -159
- package/src/open-badge.js +200 -239
- package/src/open-button.d.ts +296 -898
- package/src/open-button.js +1150 -1322
- package/src/open-callout.d.ts +225 -366
- package/src/open-callout.js +488 -569
- package/src/open-card.d.ts +114 -144
- package/src/open-card.js +197 -251
- package/src/open-code-block.d.ts +165 -168
- package/src/open-code-block.js +315 -366
- package/src/open-dialog.d.ts +241 -424
- package/src/open-dialog.js +643 -823
- package/src/open-dropdown.d.ts +195 -252
- package/src/open-dropdown.js +368 -471
- package/src/open-input.d.ts +404 -1420
- package/src/open-input.js +1809 -2095
- package/src/open-props-tokens.d.ts +5 -5
- package/src/open-props-tokens.js +12 -7
- package/src/open-tabs.d.ts +163 -191
- package/src/open-tabs.js +306 -361
- package/src/open-theme-toggle.d.ts +171 -287
- package/src/open-theme-toggle.js +530 -754
- package/src/register.d.ts +4 -1
- package/src/register.js +27 -58
package/src/open-tabs.js
CHANGED
|
@@ -1,283 +1,236 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { readInstanceState, writeInstanceState } from "./instance-state.js";
|
|
2
|
+
import { nextInstanceId, recipe } from "./component-recipes.js";
|
|
3
|
+
import { OpenElement, effect } from "@openelement/element";
|
|
4
|
+
//#region src/open-tabs.tsx
|
|
5
5
|
const __partProgram = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
1
|
|
138
|
-
]
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
"metadata": {
|
|
142
|
-
"tag": "open-tabs",
|
|
143
|
-
"className": "OpenTabs",
|
|
144
|
-
"sourceFile": "open-tabs.tsx",
|
|
145
|
-
"properties": [
|
|
146
|
-
{
|
|
147
|
-
"name": "active",
|
|
148
|
-
"attribute": null,
|
|
149
|
-
"type": "number",
|
|
150
|
-
"converter": "number",
|
|
151
|
-
"reflect": false,
|
|
152
|
-
"default": 0
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
"name": "tabsId",
|
|
156
|
-
"attribute": null,
|
|
157
|
-
"type": "string",
|
|
158
|
-
"converter": "string",
|
|
159
|
-
"reflect": false,
|
|
160
|
-
"default": ""
|
|
161
|
-
}
|
|
162
|
-
],
|
|
163
|
-
"observedAttributes": [],
|
|
164
|
-
"cem": {
|
|
165
|
-
"tagName": "open-tabs",
|
|
166
|
-
"className": "OpenTabs",
|
|
167
|
-
"declaration": {
|
|
168
|
-
"name": "OpenTabs",
|
|
169
|
-
"module": "open-tabs.tsx"
|
|
170
|
-
},
|
|
171
|
-
"attributes": [],
|
|
172
|
-
"members": [
|
|
173
|
-
{
|
|
174
|
-
"name": "active",
|
|
175
|
-
"fieldName": "active",
|
|
176
|
-
"type": "number",
|
|
177
|
-
"attribute": null,
|
|
178
|
-
"reflect": false
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"name": "tabsId",
|
|
182
|
-
"fieldName": "tabsId",
|
|
183
|
-
"type": "string",
|
|
184
|
-
"attribute": null,
|
|
185
|
-
"reflect": false
|
|
186
|
-
}
|
|
187
|
-
]
|
|
188
|
-
}
|
|
189
|
-
}
|
|
6
|
+
"version": 1,
|
|
7
|
+
"tag": "open-tabs",
|
|
8
|
+
"root": {
|
|
9
|
+
"id": "root",
|
|
10
|
+
"kind": "shadow-open",
|
|
11
|
+
"nodes": ["e0"]
|
|
12
|
+
},
|
|
13
|
+
"template": [{
|
|
14
|
+
"k": "el",
|
|
15
|
+
"id": "e0",
|
|
16
|
+
"tag": "div",
|
|
17
|
+
"attrs": [],
|
|
18
|
+
"children": [{
|
|
19
|
+
"k": "el",
|
|
20
|
+
"id": "e1",
|
|
21
|
+
"tag": "div",
|
|
22
|
+
"attrs": [["class", "tabs"], ["role", "tablist"]],
|
|
23
|
+
"children": [{
|
|
24
|
+
"k": "el",
|
|
25
|
+
"id": "e2",
|
|
26
|
+
"tag": "slot",
|
|
27
|
+
"attrs": [["name", "tab"]],
|
|
28
|
+
"children": []
|
|
29
|
+
}]
|
|
30
|
+
}, {
|
|
31
|
+
"k": "el",
|
|
32
|
+
"id": "e3",
|
|
33
|
+
"tag": "slot",
|
|
34
|
+
"attrs": [["name", "panel"]],
|
|
35
|
+
"children": []
|
|
36
|
+
}]
|
|
37
|
+
}],
|
|
38
|
+
"parts": [{
|
|
39
|
+
"k": "event",
|
|
40
|
+
"event": "keydown",
|
|
41
|
+
"handler": "onKeydown",
|
|
42
|
+
"action": {
|
|
43
|
+
"kind": "method",
|
|
44
|
+
"name": "onKeydown"
|
|
45
|
+
},
|
|
46
|
+
"path": [0, 0],
|
|
47
|
+
"index": 0,
|
|
48
|
+
"location": {
|
|
49
|
+
"id": "p0",
|
|
50
|
+
"kind": "sink",
|
|
51
|
+
"path": [0, 0],
|
|
52
|
+
"node": "e1"
|
|
53
|
+
}
|
|
54
|
+
}],
|
|
55
|
+
"regions": [],
|
|
56
|
+
"dependencies": [],
|
|
57
|
+
"locations": [
|
|
58
|
+
{
|
|
59
|
+
"id": "e0",
|
|
60
|
+
"kind": "element",
|
|
61
|
+
"tag": "div",
|
|
62
|
+
"path": [0]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "e1",
|
|
66
|
+
"kind": "element",
|
|
67
|
+
"tag": "div",
|
|
68
|
+
"path": [0, 0]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "p0",
|
|
72
|
+
"kind": "sink",
|
|
73
|
+
"part": 0,
|
|
74
|
+
"node": "e1",
|
|
75
|
+
"path": [0, 0]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "e2",
|
|
79
|
+
"kind": "element",
|
|
80
|
+
"tag": "slot",
|
|
81
|
+
"path": [
|
|
82
|
+
0,
|
|
83
|
+
0,
|
|
84
|
+
0
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "e3",
|
|
89
|
+
"kind": "element",
|
|
90
|
+
"tag": "slot",
|
|
91
|
+
"path": [0, 1]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"metadata": {
|
|
95
|
+
"tag": "open-tabs",
|
|
96
|
+
"className": "OpenTabs",
|
|
97
|
+
"sourceFile": "open-tabs.tsx",
|
|
98
|
+
"properties": [{
|
|
99
|
+
"name": "active",
|
|
100
|
+
"attribute": null,
|
|
101
|
+
"type": "number",
|
|
102
|
+
"converter": "number",
|
|
103
|
+
"reflect": false,
|
|
104
|
+
"default": 0
|
|
105
|
+
}, {
|
|
106
|
+
"name": "tabsId",
|
|
107
|
+
"attribute": null,
|
|
108
|
+
"type": "string",
|
|
109
|
+
"converter": "string",
|
|
110
|
+
"reflect": false,
|
|
111
|
+
"default": ""
|
|
112
|
+
}],
|
|
113
|
+
"observedAttributes": [],
|
|
114
|
+
"cem": {
|
|
115
|
+
"tagName": "open-tabs",
|
|
116
|
+
"className": "OpenTabs",
|
|
117
|
+
"declaration": {
|
|
118
|
+
"name": "OpenTabs",
|
|
119
|
+
"module": "open-tabs.tsx"
|
|
120
|
+
},
|
|
121
|
+
"attributes": [],
|
|
122
|
+
"members": [{
|
|
123
|
+
"name": "active",
|
|
124
|
+
"fieldName": "active",
|
|
125
|
+
"type": "number",
|
|
126
|
+
"attribute": null,
|
|
127
|
+
"reflect": false
|
|
128
|
+
}, {
|
|
129
|
+
"name": "tabsId",
|
|
130
|
+
"fieldName": "tabsId",
|
|
131
|
+
"type": "string",
|
|
132
|
+
"attribute": null,
|
|
133
|
+
"reflect": false
|
|
134
|
+
}]
|
|
135
|
+
}
|
|
136
|
+
}
|
|
190
137
|
};
|
|
191
|
-
const __compiledProperties = [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"default": ""
|
|
207
|
-
}
|
|
208
|
-
];
|
|
138
|
+
const __compiledProperties = [{
|
|
139
|
+
"name": "active",
|
|
140
|
+
"attribute": null,
|
|
141
|
+
"type": "number",
|
|
142
|
+
"converter": "number",
|
|
143
|
+
"reflect": false,
|
|
144
|
+
"default": 0
|
|
145
|
+
}, {
|
|
146
|
+
"name": "tabsId",
|
|
147
|
+
"attribute": null,
|
|
148
|
+
"type": "string",
|
|
149
|
+
"converter": "string",
|
|
150
|
+
"reflect": false,
|
|
151
|
+
"default": ""
|
|
152
|
+
}];
|
|
209
153
|
const __elementMetadata = {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
"type": "string",
|
|
252
|
-
"attribute": null,
|
|
253
|
-
"reflect": false
|
|
254
|
-
}
|
|
255
|
-
]
|
|
256
|
-
}
|
|
154
|
+
"tag": "open-tabs",
|
|
155
|
+
"className": "OpenTabs",
|
|
156
|
+
"sourceFile": "open-tabs.tsx",
|
|
157
|
+
"properties": [{
|
|
158
|
+
"name": "active",
|
|
159
|
+
"attribute": null,
|
|
160
|
+
"type": "number",
|
|
161
|
+
"converter": "number",
|
|
162
|
+
"reflect": false,
|
|
163
|
+
"default": 0
|
|
164
|
+
}, {
|
|
165
|
+
"name": "tabsId",
|
|
166
|
+
"attribute": null,
|
|
167
|
+
"type": "string",
|
|
168
|
+
"converter": "string",
|
|
169
|
+
"reflect": false,
|
|
170
|
+
"default": ""
|
|
171
|
+
}],
|
|
172
|
+
"observedAttributes": [],
|
|
173
|
+
"cem": {
|
|
174
|
+
"tagName": "open-tabs",
|
|
175
|
+
"className": "OpenTabs",
|
|
176
|
+
"declaration": {
|
|
177
|
+
"name": "OpenTabs",
|
|
178
|
+
"module": "open-tabs.tsx"
|
|
179
|
+
},
|
|
180
|
+
"attributes": [],
|
|
181
|
+
"members": [{
|
|
182
|
+
"name": "active",
|
|
183
|
+
"fieldName": "active",
|
|
184
|
+
"type": "number",
|
|
185
|
+
"attribute": null,
|
|
186
|
+
"reflect": false
|
|
187
|
+
}, {
|
|
188
|
+
"name": "tabsId",
|
|
189
|
+
"fieldName": "tabsId",
|
|
190
|
+
"type": "string",
|
|
191
|
+
"attribute": null,
|
|
192
|
+
"reflect": false
|
|
193
|
+
}]
|
|
194
|
+
}
|
|
257
195
|
};
|
|
258
196
|
const __observedAttributes = [];
|
|
259
197
|
const __compiledProps = {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
198
|
+
active: {
|
|
199
|
+
type: Number,
|
|
200
|
+
default: 0,
|
|
201
|
+
reflect: false,
|
|
202
|
+
attribute: false
|
|
203
|
+
},
|
|
204
|
+
tabsId: {
|
|
205
|
+
type: String,
|
|
206
|
+
default: "",
|
|
207
|
+
reflect: false,
|
|
208
|
+
attribute: false
|
|
209
|
+
}
|
|
272
210
|
};
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
211
|
+
var OpenTabs = class extends OpenElement {
|
|
212
|
+
constructor(..._args) {
|
|
213
|
+
super(..._args);
|
|
214
|
+
this.active = 0;
|
|
215
|
+
this.tabsId = "";
|
|
216
|
+
}
|
|
217
|
+
static {
|
|
218
|
+
this.__partProgram = __partProgram;
|
|
219
|
+
}
|
|
220
|
+
static {
|
|
221
|
+
this.__compiledProperties = __compiledProperties;
|
|
222
|
+
}
|
|
223
|
+
static {
|
|
224
|
+
this.__elementMetadata = __elementMetadata;
|
|
225
|
+
}
|
|
226
|
+
static {
|
|
227
|
+
this.props = __compiledProps;
|
|
228
|
+
}
|
|
229
|
+
static {
|
|
230
|
+
this.observedAttributes = __observedAttributes;
|
|
231
|
+
}
|
|
232
|
+
static {
|
|
233
|
+
this.styles = [recipe(`
|
|
281
234
|
:host {
|
|
282
235
|
display: block;
|
|
283
236
|
}
|
|
@@ -311,91 +264,83 @@ export class OpenTabs extends OpenElement {
|
|
|
311
264
|
padding-block: var(--size-4);
|
|
312
265
|
color: var(--text-secondary);
|
|
313
266
|
}
|
|
314
|
-
`)
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
else panel.setAttribute('hidden', '');
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
render() {
|
|
398
|
-
throw new Error('[open:compiled-element] open-tabs is compiled to a Part Program; the runtime JSX render path is not available.');
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
export { __partProgram, __elementMetadata };
|
|
267
|
+
`)];
|
|
268
|
+
}
|
|
269
|
+
onDsdHydrated() {
|
|
270
|
+
this.activate();
|
|
271
|
+
}
|
|
272
|
+
onCsrRendered() {
|
|
273
|
+
this.activate();
|
|
274
|
+
}
|
|
275
|
+
disconnectedCallback() {
|
|
276
|
+
readInstanceState(this, "decorateEffect", () => void 0)?.();
|
|
277
|
+
writeInstanceState(this, "decorateEffect", void 0);
|
|
278
|
+
super.disconnectedCallback();
|
|
279
|
+
}
|
|
280
|
+
activate() {
|
|
281
|
+
if (this.tabsId === "") this.tabsId = `open-tabs-${nextInstanceId()}`;
|
|
282
|
+
const off = effect(() => {
|
|
283
|
+
this.active;
|
|
284
|
+
this.decorate();
|
|
285
|
+
});
|
|
286
|
+
writeInstanceState(this, "decorateEffect", off);
|
|
287
|
+
}
|
|
288
|
+
tabs() {
|
|
289
|
+
return [...this.querySelectorAll("[slot=\"tab\"]")];
|
|
290
|
+
}
|
|
291
|
+
count() {
|
|
292
|
+
return Math.min(this.tabs().length, this.querySelectorAll("[slot=\"panel\"]").length);
|
|
293
|
+
}
|
|
294
|
+
select(idx) {
|
|
295
|
+
this.active = idx;
|
|
296
|
+
}
|
|
297
|
+
onKeydown(e) {
|
|
298
|
+
const count = this.count();
|
|
299
|
+
if (count === 0) return;
|
|
300
|
+
const key = e.key;
|
|
301
|
+
const next = key === "Home" ? 0 : key === "End" ? count - 1 : key === "ArrowLeft" ? (this.active - 1 + count) % count : key === "ArrowRight" ? (this.active + 1) % count : void 0;
|
|
302
|
+
if (next === void 0) return;
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
this.select(next);
|
|
305
|
+
const tab = this.tabs()[next];
|
|
306
|
+
if (tab && typeof tab.focus === "function") tab.focus();
|
|
307
|
+
}
|
|
308
|
+
decorate() {
|
|
309
|
+
const tabs = this.tabs();
|
|
310
|
+
const panels = [...this.querySelectorAll("[slot=\"panel\"]")];
|
|
311
|
+
const count = Math.min(tabs.length, panels.length);
|
|
312
|
+
const active = this.active;
|
|
313
|
+
const prefix = this.tabsId;
|
|
314
|
+
const wired = readInstanceState(this, "wiredTabs", () => /* @__PURE__ */ new WeakSet());
|
|
315
|
+
tabs.forEach((tab, i) => {
|
|
316
|
+
const enabled = i < count;
|
|
317
|
+
tab.setAttribute("role", "tab");
|
|
318
|
+
tab.setAttribute("id", `${prefix}-tab-${i}`);
|
|
319
|
+
tab.setAttribute("aria-selected", i === active && enabled ? "true" : "false");
|
|
320
|
+
tab.setAttribute("aria-controls", `${prefix}-panel-${i}`);
|
|
321
|
+
tab.setAttribute("tabindex", i === active ? "0" : "-1");
|
|
322
|
+
tab.classList.toggle("tab-active", i === active);
|
|
323
|
+
if (enabled) tab.removeAttribute("aria-disabled");
|
|
324
|
+
else tab.setAttribute("aria-disabled", "true");
|
|
325
|
+
if (!wired.has(tab)) {
|
|
326
|
+
wired.add(tab);
|
|
327
|
+
tab.addEventListener("click", () => {
|
|
328
|
+
const idx = this.tabs().indexOf(tab);
|
|
329
|
+
if (idx >= 0 && idx < this.count()) this.select(idx);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
panels.forEach((panel, i) => {
|
|
334
|
+
panel.setAttribute("role", "tabpanel");
|
|
335
|
+
panel.setAttribute("id", `${prefix}-panel-${i}`);
|
|
336
|
+
panel.setAttribute("aria-labelledby", `${prefix}-tab-${i}`);
|
|
337
|
+
if (i === active) panel.removeAttribute("hidden");
|
|
338
|
+
else panel.setAttribute("hidden", "");
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
render() {
|
|
342
|
+
throw new Error("[open:compiled-element] open-tabs is compiled to a Part Program; the runtime JSX render path is not available.");
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
//#endregion
|
|
346
|
+
export { OpenTabs, __elementMetadata, __partProgram };
|