@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,474 +1,230 @@
1
- // <auto-generated by open:compiled-element; v0.44.0-alpha.1 - do not edit>
2
- import { OpenElement } from '@openelement/element';
3
- import { CODE_BLOCK_CONSTANTS, log, recipe } from './component-recipes.js';
4
- import { readInstanceState, writeInstanceState } from './instance-state.js';
1
+ import { CODE_BLOCK_CONSTANTS, log } from "./component-recipes.js";
2
+ import { OpenElement } from "@openelement/element";
3
+ import openCodeBlockStyles from "./open-code-block.css";
4
+ //#region src/open-code-block.tsx
5
5
  const __partProgram = {
6
- "version": 1,
7
- "tag": "open-code-block",
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
- [
22
- "style",
23
- "display:contents"
24
- ]
25
- ],
26
- "children": [
27
- {
28
- "k": "el",
29
- "id": "e1",
30
- "tag": "slot",
31
- "attrs": [],
32
- "children": []
33
- },
34
- {
35
- "k": "el",
36
- "id": "e2",
37
- "tag": "button",
38
- "attrs": [
39
- [
40
- "type",
41
- "button"
42
- ],
43
- [
44
- "class",
45
- "copy-btn"
46
- ],
47
- [
48
- "part",
49
- "copy"
50
- ]
51
- ],
52
- "children": [
53
- {
54
- "k": "part",
55
- "id": "p1",
56
- "index": 1
57
- }
58
- ]
59
- }
60
- ]
61
- }
62
- ],
63
- "parts": [
64
- {
65
- "k": "event",
66
- "event": "click",
67
- "handler": "copy",
68
- "action": {
69
- "kind": "method",
70
- "name": "copy"
71
- },
72
- "path": [
73
- 0,
74
- 1
75
- ],
76
- "index": 0,
77
- "location": {
78
- "id": "p0",
79
- "kind": "sink",
80
- "path": [
81
- 0,
82
- 1
83
- ],
84
- "node": "e2"
85
- }
86
- },
87
- {
88
- "k": "text",
89
- "signal": "copyLabel",
90
- "index": 1,
91
- "location": {
92
- "id": "p1",
93
- "kind": "anchor",
94
- "path": [
95
- 0,
96
- 1,
97
- 0
98
- ]
99
- }
100
- }
101
- ],
102
- "regions": [],
103
- "dependencies": [
104
- {
105
- "signal": "copyLabel",
106
- "owner": {
107
- "kind": "part",
108
- "index": 1
109
- },
110
- "location": "p1"
111
- }
112
- ],
113
- "locations": [
114
- {
115
- "id": "e0",
116
- "kind": "element",
117
- "tag": "div",
118
- "path": [
119
- 0
120
- ]
121
- },
122
- {
123
- "id": "e1",
124
- "kind": "element",
125
- "tag": "slot",
126
- "path": [
127
- 0,
128
- 0
129
- ]
130
- },
131
- {
132
- "id": "e2",
133
- "kind": "element",
134
- "tag": "button",
135
- "path": [
136
- 0,
137
- 1
138
- ]
139
- },
140
- {
141
- "id": "p0",
142
- "kind": "sink",
143
- "part": 0,
144
- "node": "e2",
145
- "path": [
146
- 0,
147
- 1
148
- ]
149
- },
150
- {
151
- "id": "p1",
152
- "kind": "anchor",
153
- "part": 1,
154
- "path": [
155
- 0,
156
- 1,
157
- 0
158
- ]
159
- }
160
- ],
161
- "metadata": {
162
- "tag": "open-code-block",
163
- "className": "OpenCodeBlock",
164
- "sourceFile": "open-code-block.tsx",
165
- "properties": [
166
- {
167
- "name": "copyLabel",
168
- "attribute": null,
169
- "type": "string",
170
- "converter": "string",
171
- "reflect": false,
172
- "default": "Copy"
173
- }
174
- ],
175
- "observedAttributes": [],
176
- "cem": {
177
- "tagName": "open-code-block",
178
- "className": "OpenCodeBlock",
179
- "declaration": {
180
- "name": "OpenCodeBlock",
181
- "module": "open-code-block.tsx"
182
- },
183
- "attributes": [],
184
- "members": [
185
- {
186
- "name": "copyLabel",
187
- "fieldName": "copyLabel",
188
- "type": "string",
189
- "attribute": null,
190
- "reflect": false
191
- }
192
- ]
193
- }
194
- }
6
+ "version": 1,
7
+ "tag": "open-code-block",
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": [["style", "display:contents"]],
18
+ "children": [{
19
+ "k": "el",
20
+ "id": "e1",
21
+ "tag": "slot",
22
+ "attrs": [],
23
+ "children": []
24
+ }, {
25
+ "k": "el",
26
+ "id": "e2",
27
+ "tag": "button",
28
+ "attrs": [
29
+ ["type", "button"],
30
+ ["class", "copy-btn"],
31
+ ["part", "copy"]
32
+ ],
33
+ "children": [{
34
+ "k": "part",
35
+ "id": "p1",
36
+ "index": 1
37
+ }]
38
+ }]
39
+ }],
40
+ "parts": [{
41
+ "k": "event",
42
+ "event": "click",
43
+ "handler": "copy",
44
+ "action": {
45
+ "kind": "method",
46
+ "name": "copy"
47
+ },
48
+ "path": [0, 1],
49
+ "index": 0,
50
+ "location": {
51
+ "id": "p0",
52
+ "kind": "sink",
53
+ "path": [0, 1],
54
+ "node": "e2"
55
+ }
56
+ }, {
57
+ "k": "text",
58
+ "signal": "copyLabel",
59
+ "index": 1,
60
+ "location": {
61
+ "id": "p1",
62
+ "kind": "anchor",
63
+ "path": [
64
+ 0,
65
+ 1,
66
+ 0
67
+ ]
68
+ }
69
+ }],
70
+ "regions": [],
71
+ "dependencies": [{
72
+ "signal": "copyLabel",
73
+ "owner": {
74
+ "kind": "part",
75
+ "index": 1
76
+ },
77
+ "location": "p1"
78
+ }],
79
+ "locations": [
80
+ {
81
+ "id": "e0",
82
+ "kind": "element",
83
+ "tag": "div",
84
+ "path": [0]
85
+ },
86
+ {
87
+ "id": "e1",
88
+ "kind": "element",
89
+ "tag": "slot",
90
+ "path": [0, 0]
91
+ },
92
+ {
93
+ "id": "e2",
94
+ "kind": "element",
95
+ "tag": "button",
96
+ "path": [0, 1]
97
+ },
98
+ {
99
+ "id": "p0",
100
+ "kind": "sink",
101
+ "part": 0,
102
+ "node": "e2",
103
+ "path": [0, 1]
104
+ },
105
+ {
106
+ "id": "p1",
107
+ "kind": "anchor",
108
+ "part": 1,
109
+ "path": [
110
+ 0,
111
+ 1,
112
+ 0
113
+ ]
114
+ }
115
+ ],
116
+ "metadata": {
117
+ "tag": "open-code-block",
118
+ "className": "OpenCodeBlock",
119
+ "sourceFile": "open-code-block.tsx",
120
+ "properties": [{
121
+ "name": "copyLabel",
122
+ "attribute": null,
123
+ "type": "string",
124
+ "converter": "string",
125
+ "reflect": false,
126
+ "default": "Copy"
127
+ }],
128
+ "observedAttributes": [],
129
+ "cem": {
130
+ "tagName": "open-code-block",
131
+ "className": "OpenCodeBlock",
132
+ "declaration": {
133
+ "name": "OpenCodeBlock",
134
+ "module": "open-code-block.tsx"
135
+ },
136
+ "attributes": [],
137
+ "members": [{
138
+ "name": "copyLabel",
139
+ "fieldName": "copyLabel",
140
+ "type": "string",
141
+ "attribute": null,
142
+ "reflect": false
143
+ }]
144
+ }
145
+ }
195
146
  };
196
- const __compiledProperties = [
197
- {
198
- "name": "copyLabel",
199
- "attribute": null,
200
- "type": "string",
201
- "converter": "string",
202
- "reflect": false,
203
- "default": "Copy"
204
- }
205
- ];
147
+ const __compiledProperties = [{
148
+ "name": "copyLabel",
149
+ "attribute": null,
150
+ "type": "string",
151
+ "converter": "string",
152
+ "reflect": false,
153
+ "default": "Copy"
154
+ }];
206
155
  const __elementMetadata = {
207
- "tag": "open-code-block",
208
- "className": "OpenCodeBlock",
209
- "sourceFile": "open-code-block.tsx",
210
- "properties": [
211
- {
212
- "name": "copyLabel",
213
- "attribute": null,
214
- "type": "string",
215
- "converter": "string",
216
- "reflect": false,
217
- "default": "Copy"
218
- }
219
- ],
220
- "observedAttributes": [],
221
- "cem": {
222
- "tagName": "open-code-block",
223
- "className": "OpenCodeBlock",
224
- "declaration": {
225
- "name": "OpenCodeBlock",
226
- "module": "open-code-block.tsx"
227
- },
228
- "attributes": [],
229
- "members": [
230
- {
231
- "name": "copyLabel",
232
- "fieldName": "copyLabel",
233
- "type": "string",
234
- "attribute": null,
235
- "reflect": false
236
- }
237
- ]
238
- }
156
+ "tag": "open-code-block",
157
+ "className": "OpenCodeBlock",
158
+ "sourceFile": "open-code-block.tsx",
159
+ "properties": [{
160
+ "name": "copyLabel",
161
+ "attribute": null,
162
+ "type": "string",
163
+ "converter": "string",
164
+ "reflect": false,
165
+ "default": "Copy"
166
+ }],
167
+ "observedAttributes": [],
168
+ "cem": {
169
+ "tagName": "open-code-block",
170
+ "className": "OpenCodeBlock",
171
+ "declaration": {
172
+ "name": "OpenCodeBlock",
173
+ "module": "open-code-block.tsx"
174
+ },
175
+ "attributes": [],
176
+ "members": [{
177
+ "name": "copyLabel",
178
+ "fieldName": "copyLabel",
179
+ "type": "string",
180
+ "attribute": null,
181
+ "reflect": false
182
+ }]
183
+ }
239
184
  };
240
185
  const __observedAttributes = [];
241
- const __compiledProps = {
242
- copyLabel: {
243
- type: String,
244
- default: 'Copy',
245
- reflect: false,
246
- attribute: false
247
- }
186
+ const __compiledProps = { copyLabel: {
187
+ type: String,
188
+ default: "Copy",
189
+ reflect: false,
190
+ attribute: false
191
+ } };
192
+ var OpenCodeBlock = class extends OpenElement {
193
+ static __partProgram = __partProgram;
194
+ static __compiledProperties = __compiledProperties;
195
+ static __elementMetadata = __elementMetadata;
196
+ static props = __compiledProps;
197
+ static observedAttributes = __observedAttributes;
198
+ static styles = [openCodeBlockStyles];
199
+ copyLabel = "Copy";
200
+ getCodeText() {
201
+ return this.textContent || "";
202
+ }
203
+ async copy() {
204
+ try {
205
+ const text = this.getCodeText();
206
+ await navigator.clipboard.writeText(text);
207
+ this.copyLabel = "Copied!";
208
+ this._internals?.states.add("copied");
209
+ this._internals?.states.delete("failed");
210
+ this._setTimeout(() => {
211
+ this.copyLabel = "Copy";
212
+ this._internals?.states.delete("copied");
213
+ }, CODE_BLOCK_CONSTANTS.copyFeedbackMs);
214
+ } catch (e) {
215
+ log.warn("Clipboard write failed:", e);
216
+ this.copyLabel = "Failed";
217
+ this._internals?.states.add("failed");
218
+ this._internals?.states.delete("copied");
219
+ this._setTimeout(() => {
220
+ this.copyLabel = "Copy";
221
+ this._internals?.states.delete("failed");
222
+ }, CODE_BLOCK_CONSTANTS.copyFeedbackMs);
223
+ }
224
+ }
225
+ render() {
226
+ throw new Error("[open:compiled-element] open-code-block is compiled to a Part Program; the runtime JSX render path is not available.");
227
+ }
248
228
  };
249
- export class OpenCodeBlock extends OpenElement {
250
- static __partProgram = __partProgram;
251
- static __compiledProperties = __compiledProperties;
252
- static __elementMetadata = __elementMetadata;
253
- static props = __compiledProps;
254
- static observedAttributes = __observedAttributes;
255
- static styles = [
256
- recipe(`
257
- :host {
258
- display: block;
259
- position: relative;
260
- }
261
-
262
- pre {
263
- margin: 0;
264
- padding: var(--size-5);
265
- /* Clear the copy chip (top var(--size-2) + ~25px tall) so the first line
266
- never runs underneath it. */
267
- padding-block-start: calc(var(--size-5) + var(--size-4));
268
- background: var(--bg-code);
269
- border: var(--border-size-1) solid var(--code-border);
270
- border-radius: var(--radius-2);
271
- overflow-x: auto;
272
- font-family: var(--font-mono);
273
- font-size: var(--font-size-0);
274
- line-height: var(--font-lineheight-4);
275
- color: var(--code-text);
276
- scrollbar-width: thin;
277
- scrollbar-color: var(--brand-subtle) transparent;
278
- white-space: pre-wrap;
279
- word-break: break-word;
280
- }
281
-
282
- ::slotted(pre) {
283
- margin: 0;
284
- padding: var(--size-5);
285
- padding-block-start: calc(var(--size-5) + var(--size-4));
286
- background: var(--bg-code);
287
- border: var(--border-size-1) solid var(--code-border);
288
- border-radius: var(--radius-2);
289
- overflow-x: auto;
290
- font-family: var(--font-mono);
291
- font-size: var(--font-size-0);
292
- line-height: var(--font-lineheight-4);
293
- color: var(--code-text);
294
- scrollbar-width: thin;
295
- scrollbar-color: var(--brand-subtle) transparent;
296
- }
297
-
298
- .lang-badge {
299
- position: absolute;
300
- top: var(--size-2);
301
- left: var(--size-3);
302
- font-size: var(--font-size-00);
303
- font-weight: var(--font-weight-7);
304
- text-transform: uppercase;
305
- letter-spacing: var(--font-letterspacing-5);
306
- color: var(--code-text);
307
- pointer-events: none;
308
- }
309
-
310
- .copy-btn {
311
- position: absolute;
312
- top: var(--size-2);
313
- right: var(--size-2);
314
- background: var(--brand-subtle);
315
- color: var(--code-text);
316
- padding: var(--size-1) var(--size-3);
317
- font-size: var(--font-size-00);
318
- font-family: var(--font-sans);
319
- font-weight: var(--font-weight-6);
320
- border: 0.5px solid transparent;
321
- cursor: pointer;
322
- border-radius: var(--radius-1);
323
- transition: all var(--ease-2) var(--duration-2);
324
- z-index: 1;
325
- letter-spacing: var(--font-letterspacing-4);
326
- }
327
-
328
- /* No ink override on hover: --on-brand is the ink for a brand *fill*, and
329
- this chip's hover surface is a translucent brand tint instead, so the
330
- chip keeps the code surface's --code-text ink. */
331
- .copy-btn:hover {
332
- background: var(--brand-glow);
333
- border-color: var(--brand);
334
- }
335
-
336
- :host(:state(copied)) .copy-btn {
337
- color: #22c55e;
338
- border-color: rgba(34,197,94,0.3);
339
- background: rgba(34,197,94,0.08);
340
- }
341
-
342
- :host(:state(failed)) .copy-btn {
343
- color: var(--error);
344
- border-color: var(--error);
345
- }
346
-
347
- /* Comment gray: #7d8590 (5.2:1 on --bg-code) — #6a737d was 4.0:1. */
348
- .token.cdata, .token.comment, .token.doctype, .token.prolog { color: #7d8590; }
349
- .token.punctuation { color: #8b949e; }
350
- .token.namespace { opacity: 0.7; }
351
- .token.boolean, .token.constant, .token.deleted, .token.number, .token.property, .token.symbol, .token.tag { color: #79c0ff; }
352
- .token.attr-name, .token.builtin, .token.char, .token.inserted, .token.selector, .token.string { color: #a5d6ff; }
353
- .token.entity, .token.operator, .token.url, .language-css .token.string, .style .token.string { color: #d2a8ff; }
354
- .token.atrule, .token.attr-value, .token.keyword { color: #ff7b72; }
355
- .token.class-name, .token.function { color: #d2a8ff; }
356
- .token.important, .token.regex, .token.variable { color: #ffa657; }
357
- .token.bold, .token.important { font-weight: 700; }
358
- .token.italic { font-style: italic; }
359
- .token.entity { cursor: help; }
360
- `)
361
- ];
362
- copyLabel = 'Copy';
363
- onDsdHydrated() {
364
- this.tryHighlight();
365
- }
366
- onCsrRendered() {
367
- this.tryHighlight();
368
- }
369
- disconnectedCallback() {
370
- // Compiled-kernel ownership: restore the program's static structure before
371
- // teardown so a reconnect re-claims cleanly (the injected highlight <pre>
372
- // and the copy-label text are imperative writes, not program content).
373
- const slot = this.shadowRoot?.querySelector('slot');
374
- if (!slot) {
375
- const root = this.shadowRoot;
376
- const highlighted = root?.querySelector('pre');
377
- if (root && highlighted) {
378
- const restored = root.ownerDocument.createElement('slot');
379
- highlighted.replaceWith(restored);
380
- }
381
- const lightPre = this.querySelector('pre');
382
- if (lightPre) lightPre.style.display = '';
383
- writeInstanceState(this, 'highlighted', false);
384
- }
385
- super.disconnectedCallback();
386
- }
387
- prismGlobal() {
388
- return globalThis.Prism;
389
- }
390
- tryHighlight() {
391
- const p = this.prismGlobal();
392
- if (typeof p === 'undefined') {
393
- // Prism not loaded yet: backoff 10, 20, 40, ..., 500ms cap.
394
- this.scheduleRetry(10, 500);
395
- return;
396
- }
397
- const pre = this.querySelector(':scope > pre') || Array.from(this.children).find((c)=>c.tagName === 'PRE');
398
- if (!pre) return;
399
- const codeEl = pre.querySelector('code');
400
- if (!codeEl) return;
401
- let lang = 'typescript';
402
- const classes = codeEl.classList;
403
- for(let i = 0; i < classes.length; i++){
404
- if (classes[i].startsWith('language-')) {
405
- lang = classes[i].slice(9);
406
- break;
407
- }
408
- }
409
- const raw = codeEl.textContent || '';
410
- const grammar = p.languages?.[lang];
411
- if (!grammar) {
412
- // Grammar not registered yet: backoff 20, 40, 80, ..., 1000ms cap.
413
- this.scheduleRetry(20, 1000);
414
- return;
415
- }
416
- writeInstanceState(this, 'highlightRetries', 0);
417
- const highlightedHtml = p.highlight(raw, grammar, lang);
418
- this.injectHighlighted(highlightedHtml, lang);
419
- }
420
- scheduleRetry(base, cap) {
421
- const retries = readInstanceState(this, 'highlightRetries', ()=>0);
422
- if (retries >= CODE_BLOCK_CONSTANTS.maxHighlightRetries) return;
423
- writeInstanceState(this, 'highlightRetries', retries + 1);
424
- const delay = Math.min(base * Math.pow(2, Math.min(retries + 1, 6)), cap);
425
- this._setTimeout(()=>this.tryHighlight(), delay);
426
- }
427
- injectHighlighted(html, lang) {
428
- if (!this.shadowRoot || readInstanceState(this, 'highlighted', ()=>false)) return;
429
- writeInstanceState(this, 'highlighted', true);
430
- const slot = this.shadowRoot.querySelector('slot');
431
- if (!slot) return;
432
- const highlightedPre = document.createElement('pre');
433
- const highlightedCode = document.createElement('code');
434
- highlightedCode.className = `language-${lang}`;
435
- highlightedCode.innerHTML = html;
436
- highlightedPre.appendChild(highlightedCode);
437
- slot.replaceWith(highlightedPre);
438
- const lightPre = this.querySelector('pre');
439
- if (lightPre) lightPre.style.display = 'none';
440
- }
441
- getCodeText() {
442
- if (this.shadowRoot) {
443
- const shadowCode = this.shadowRoot.querySelector('pre code');
444
- if (shadowCode) return shadowCode.textContent || '';
445
- }
446
- return this.textContent || '';
447
- }
448
- async copy() {
449
- try {
450
- const text = this.getCodeText();
451
- await navigator.clipboard.writeText(text);
452
- this.copyLabel = 'Copied!';
453
- this._internals?.states.add('copied');
454
- this._internals?.states.delete('failed');
455
- this._setTimeout(()=>{
456
- this.copyLabel = 'Copy';
457
- this._internals?.states.delete('copied');
458
- }, CODE_BLOCK_CONSTANTS.copyFeedbackMs);
459
- } catch (e) {
460
- log.warn('Clipboard write failed:', e);
461
- this.copyLabel = 'Failed';
462
- this._internals?.states.add('failed');
463
- this._internals?.states.delete('copied');
464
- this._setTimeout(()=>{
465
- this.copyLabel = 'Copy';
466
- this._internals?.states.delete('failed');
467
- }, CODE_BLOCK_CONSTANTS.copyFeedbackMs);
468
- }
469
- }
470
- render() {
471
- throw new Error('[open:compiled-element] open-code-block is compiled to a Part Program; the runtime JSX render path is not available in 0.44.');
472
- }
473
- }
474
- export { __partProgram, __elementMetadata };
229
+ //#endregion
230
+ export { OpenCodeBlock, __elementMetadata, __partProgram };