@openelement/ui 1.0.0-alpha.10 → 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.
- package/CUSTOMIZATION.md +3 -3
- package/package.json +2 -22
- package/src/component-recipes.js +2 -60
- package/src/control-recipe.css +21 -0
- package/src/generated-manifest.json +1 -158
- package/src/index.d.ts +1 -5
- package/src/index.js +1 -5
- package/src/open-button.css +120 -0
- package/src/open-button.js +4 -118
- package/src/open-code-block.css +46 -0
- package/src/open-code-block.js +3 -44
- package/src/open-dialog.css +137 -0
- package/src/open-dialog.js +3 -135
- package/src/open-dropdown.css +28 -0
- package/src/open-dropdown.js +4 -26
- package/src/open-input.css +80 -0
- package/src/open-input.js +4 -78
- package/src/open-theme-toggle.css +53 -0
- package/src/open-theme-toggle.js +3 -51
- package/src/overlay-recipe.css +9 -0
- package/src/register.js +1 -9
- package/src/surface-recipe.css +10 -0
- package/src/theme.css +3 -2
- package/src/open-badge.d.ts +0 -139
- package/src/open-badge.js +0 -242
- package/src/open-callout.d.ts +0 -261
- package/src/open-callout.js +0 -502
- package/src/open-card.d.ts +0 -138
- package/src/open-card.js +0 -244
- package/src/open-tabs.d.ts +0 -190
- package/src/open-tabs.js +0 -331
package/src/open-tabs.js
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
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
|
-
const __partProgram = {
|
|
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
|
-
}
|
|
137
|
-
};
|
|
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
|
-
}];
|
|
153
|
-
const __elementMetadata = {
|
|
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
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const __observedAttributes = [];
|
|
197
|
-
const __compiledProps = {
|
|
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
|
-
}
|
|
210
|
-
};
|
|
211
|
-
var OpenTabs = class extends OpenElement {
|
|
212
|
-
static __partProgram = __partProgram;
|
|
213
|
-
static __compiledProperties = __compiledProperties;
|
|
214
|
-
static __elementMetadata = __elementMetadata;
|
|
215
|
-
static props = __compiledProps;
|
|
216
|
-
static observedAttributes = __observedAttributes;
|
|
217
|
-
static styles = [recipe(`
|
|
218
|
-
:host {
|
|
219
|
-
display: block;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.tabs {
|
|
223
|
-
display: flex;
|
|
224
|
-
gap: calc(var(--spacing) * 1);
|
|
225
|
-
padding: calc(var(--spacing) * 1);
|
|
226
|
-
border-bottom: 1px solid color-mix(in srgb, var(--color-border) 78%, var(--color-primary));
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
::slotted([slot='tab']) {
|
|
230
|
-
padding: calc(var(--spacing) * 2) calc(var(--spacing) * 4);
|
|
231
|
-
border-color: transparent;
|
|
232
|
-
background: transparent;
|
|
233
|
-
color: var(--color-muted-foreground);
|
|
234
|
-
cursor: pointer;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
::slotted([slot='tab']:hover) {
|
|
238
|
-
color: var(--color-foreground);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
::slotted(.tab-active) {
|
|
242
|
-
color: var(--color-foreground);
|
|
243
|
-
background: color-mix(in srgb, var(--color-primary) 14%, transparent);
|
|
244
|
-
border-color: color-mix(in srgb, color-mix(in srgb, var(--color-foreground) 25%, var(--color-border)) 62%, var(--color-primary));
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
::slotted([slot='panel']) {
|
|
248
|
-
padding-block: calc(var(--spacing) * 4);
|
|
249
|
-
color: var(--color-muted-foreground);
|
|
250
|
-
}
|
|
251
|
-
`)];
|
|
252
|
-
active = 0;
|
|
253
|
-
tabsId = "";
|
|
254
|
-
onDsdHydrated() {
|
|
255
|
-
this.activate();
|
|
256
|
-
}
|
|
257
|
-
onCsrRendered() {
|
|
258
|
-
this.activate();
|
|
259
|
-
}
|
|
260
|
-
disconnectedCallback() {
|
|
261
|
-
readInstanceState(this, "decorateEffect", () => void 0)?.();
|
|
262
|
-
writeInstanceState(this, "decorateEffect", void 0);
|
|
263
|
-
super.disconnectedCallback();
|
|
264
|
-
}
|
|
265
|
-
activate() {
|
|
266
|
-
if (this.tabsId === "") this.tabsId = `open-tabs-${nextInstanceId()}`;
|
|
267
|
-
const off = effect(() => {
|
|
268
|
-
this.active;
|
|
269
|
-
this.decorate();
|
|
270
|
-
});
|
|
271
|
-
writeInstanceState(this, "decorateEffect", off);
|
|
272
|
-
}
|
|
273
|
-
tabs() {
|
|
274
|
-
return [...this.querySelectorAll("[slot=\"tab\"]")];
|
|
275
|
-
}
|
|
276
|
-
count() {
|
|
277
|
-
return Math.min(this.tabs().length, this.querySelectorAll("[slot=\"panel\"]").length);
|
|
278
|
-
}
|
|
279
|
-
select(idx) {
|
|
280
|
-
this.active = idx;
|
|
281
|
-
}
|
|
282
|
-
onKeydown(e) {
|
|
283
|
-
const count = this.count();
|
|
284
|
-
if (count === 0) return;
|
|
285
|
-
const key = e.key;
|
|
286
|
-
const next = key === "Home" ? 0 : key === "End" ? count - 1 : key === "ArrowLeft" ? (this.active - 1 + count) % count : key === "ArrowRight" ? (this.active + 1) % count : void 0;
|
|
287
|
-
if (next === void 0) return;
|
|
288
|
-
e.preventDefault();
|
|
289
|
-
this.select(next);
|
|
290
|
-
const tab = this.tabs()[next];
|
|
291
|
-
if (tab && typeof tab.focus === "function") tab.focus();
|
|
292
|
-
}
|
|
293
|
-
decorate() {
|
|
294
|
-
const tabs = this.tabs();
|
|
295
|
-
const panels = [...this.querySelectorAll("[slot=\"panel\"]")];
|
|
296
|
-
const count = Math.min(tabs.length, panels.length);
|
|
297
|
-
const active = this.active;
|
|
298
|
-
const prefix = this.tabsId;
|
|
299
|
-
const wired = readInstanceState(this, "wiredTabs", () => /* @__PURE__ */ new WeakSet());
|
|
300
|
-
tabs.forEach((tab, i) => {
|
|
301
|
-
const enabled = i < count;
|
|
302
|
-
tab.setAttribute("role", "tab");
|
|
303
|
-
tab.setAttribute("id", `${prefix}-tab-${i}`);
|
|
304
|
-
tab.setAttribute("aria-selected", i === active && enabled ? "true" : "false");
|
|
305
|
-
tab.setAttribute("aria-controls", `${prefix}-panel-${i}`);
|
|
306
|
-
tab.setAttribute("tabindex", i === active ? "0" : "-1");
|
|
307
|
-
tab.classList.toggle("tab-active", i === active);
|
|
308
|
-
if (enabled) tab.removeAttribute("aria-disabled");
|
|
309
|
-
else tab.setAttribute("aria-disabled", "true");
|
|
310
|
-
if (!wired.has(tab)) {
|
|
311
|
-
wired.add(tab);
|
|
312
|
-
tab.addEventListener("click", () => {
|
|
313
|
-
const idx = this.tabs().indexOf(tab);
|
|
314
|
-
if (idx >= 0 && idx < this.count()) this.select(idx);
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
panels.forEach((panel, i) => {
|
|
319
|
-
panel.setAttribute("role", "tabpanel");
|
|
320
|
-
panel.setAttribute("id", `${prefix}-panel-${i}`);
|
|
321
|
-
panel.setAttribute("aria-labelledby", `${prefix}-tab-${i}`);
|
|
322
|
-
if (i === active) panel.removeAttribute("hidden");
|
|
323
|
-
else panel.setAttribute("hidden", "");
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
render() {
|
|
327
|
-
throw new Error("[open:compiled-element] open-tabs is compiled to a Part Program; the runtime JSX render path is not available.");
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
//#endregion
|
|
331
|
-
export { OpenTabs, __elementMetadata, __partProgram };
|