loseta 0.17.0 → 0.18.0

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 (48) hide show
  1. package/README.md +33 -8
  2. package/dist/commands/add.d.ts +8 -0
  3. package/dist/commands/add.js +60 -15
  4. package/dist/commands/add.js.map +1 -1
  5. package/dist/commands/init.js +2 -1
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/config.d.ts +7 -0
  8. package/dist/config.js +13 -0
  9. package/dist/config.js.map +1 -1
  10. package/dist/imports.d.ts +4 -0
  11. package/dist/imports.js +30 -2
  12. package/dist/imports.js.map +1 -1
  13. package/dist/install.d.ts +23 -3
  14. package/dist/install.js +84 -5
  15. package/dist/install.js.map +1 -1
  16. package/dist/style-switch.js +2 -1
  17. package/dist/style-switch.js.map +1 -1
  18. package/dist/types.d.ts +11 -0
  19. package/dist/ui.js +4 -1
  20. package/dist/ui.js.map +1 -1
  21. package/package.json +4 -3
  22. package/registry/behaviors/code-block.js +106 -0
  23. package/registry/behaviors/combobox.js +237 -0
  24. package/registry/behaviors/command.js +105 -0
  25. package/registry/behaviors/core.js +302 -0
  26. package/registry/behaviors/dialog.js +97 -0
  27. package/registry/behaviors/listbox.js +135 -0
  28. package/registry/behaviors/menu.js +586 -0
  29. package/registry/behaviors/popover.js +127 -0
  30. package/registry/behaviors/select.js +196 -0
  31. package/registry/behaviors/tabs.js +95 -0
  32. package/registry/behaviors/toast.js +137 -0
  33. package/registry/components/code-block.css +19 -0
  34. package/registry/examples/alert-dialog.html +21 -21
  35. package/registry/examples/button-group.html +3 -3
  36. package/registry/examples/code-block.html +10 -4
  37. package/registry/examples/combobox.html +2 -0
  38. package/registry/examples/command.html +17 -17
  39. package/registry/examples/context-menu.html +18 -18
  40. package/registry/examples/dialog.html +15 -15
  41. package/registry/examples/drawer.html +22 -22
  42. package/registry/examples/select.html +7 -0
  43. package/registry/examples/sheet.html +23 -23
  44. package/registry/examples/sidebar.html +11 -11
  45. package/registry/examples/toast.html +11 -0
  46. package/registry/primitives/dialog-shell.css +5 -0
  47. package/registry/registry.json +196 -1
  48. package/registry/schema.json +17 -0
@@ -0,0 +1,196 @@
1
+ // @ts-check
2
+
3
+ import {
4
+ emit,
5
+ init,
6
+ on,
7
+ onDocument,
8
+ panelFor,
9
+ typeaheadTarget
10
+ } from "./core.js";
11
+ import {
12
+ firstOption,
13
+ highlight,
14
+ lastOption,
15
+ listboxIn,
16
+ moveHighlight,
17
+ resetFilter,
18
+ selectOption,
19
+ selectedOptions,
20
+ visibleOptions
21
+ } from "./listbox.js";
22
+
23
+ /** @param {HTMLElement} control */
24
+ function rootOf(control) {
25
+ return control.closest(".select") ?? control.parentElement ?? control;
26
+ }
27
+
28
+ /** @param {HTMLElement} control */
29
+ function parts(control) {
30
+ const panel = panelFor(control);
31
+ const listbox = panel ? listboxIn(panel) : null;
32
+ return { panel, listbox };
33
+ }
34
+
35
+ /** @param {HTMLElement} control */
36
+ function isExpanded(control) {
37
+ return control.getAttribute("aria-expanded") === "true";
38
+ }
39
+
40
+ /** @param {HTMLElement} control @param {boolean} open */
41
+ function setExpanded(control, open) {
42
+ const { panel } = parts(control);
43
+ control.setAttribute("aria-expanded", String(open));
44
+ if (panel) panel.setAttribute("aria-hidden", String(!open));
45
+ }
46
+
47
+ /** @param {HTMLElement} control */
48
+ function openSelect(control) {
49
+ const { panel, listbox } = parts(control);
50
+ if (!panel || !listbox) return;
51
+
52
+ resetFilter(listbox);
53
+ setExpanded(control, true);
54
+
55
+ const selected = selectedOptions(listbox)[0] ?? firstOption(listbox);
56
+ highlight(listbox, selected, control);
57
+ }
58
+
59
+ /** @param {HTMLElement} control @param {boolean} focusTrigger */
60
+ function closeSelect(control, focusTrigger) {
61
+ const { listbox } = parts(control);
62
+ setExpanded(control, false);
63
+ if (listbox) highlight(listbox, null, control);
64
+ if (focusTrigger) control.focus();
65
+ }
66
+
67
+ /** @param {HTMLElement} control @param {Element} option */
68
+ function choose(control, option) {
69
+ const { listbox } = parts(control);
70
+ if (!listbox) return;
71
+
72
+ const values = selectOption(listbox, option, false);
73
+ const value = values[0] ?? "";
74
+ const root = rootOf(control);
75
+ const valueSlot = root.querySelector("[data-slot='value']");
76
+ if (valueSlot instanceof HTMLElement) {
77
+ valueSlot.textContent = value;
78
+ valueSlot.removeAttribute("data-placeholder");
79
+ }
80
+
81
+ const hidden = root.querySelector("input[data-slot='input']");
82
+ if (hidden instanceof HTMLInputElement) hidden.value = value;
83
+
84
+ emit(root, "change", { value });
85
+ closeSelect(control, true);
86
+ }
87
+
88
+ on("click", ".select [role='combobox']", (event, target) => {
89
+ if (!(target instanceof HTMLElement)) return;
90
+ if (isExpanded(target)) {
91
+ closeSelect(target, true);
92
+ } else {
93
+ openSelect(target);
94
+ }
95
+ event.preventDefault();
96
+ return true;
97
+ });
98
+
99
+ on("click", ".select [role='option']", (event, target) => {
100
+ if (!(target instanceof HTMLElement) || target.getAttribute("aria-disabled") === "true") {
101
+ return;
102
+ }
103
+ const control = target.closest(".select")?.querySelector("[role='combobox']");
104
+ if (control instanceof HTMLElement) choose(control, target);
105
+ event.preventDefault();
106
+ return true;
107
+ });
108
+
109
+ on("keydown", ".select [role='combobox']", (event, target) => {
110
+ if (!(event instanceof KeyboardEvent) || !(target instanceof HTMLElement)) return;
111
+ const { listbox } = parts(target);
112
+ if (!listbox) return;
113
+ const expanded = isExpanded(target);
114
+
115
+ if (event.key === "Escape") {
116
+ if (!expanded) return;
117
+ closeSelect(target, true);
118
+ event.preventDefault();
119
+ return true;
120
+ }
121
+
122
+ if (!expanded) {
123
+ const opens =
124
+ event.key === "ArrowDown" ||
125
+ event.key === "ArrowUp" ||
126
+ event.key === "Enter" ||
127
+ event.key === " ";
128
+ if (opens) {
129
+ openSelect(target);
130
+ if (event.key === "ArrowUp") {
131
+ highlight(listbox, lastOption(listbox), target);
132
+ }
133
+ event.preventDefault();
134
+ return true;
135
+ }
136
+
137
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
138
+ openSelect(target);
139
+ const match = typeaheadTarget(listbox, event.key, visibleOptions(listbox), null);
140
+ if (match) highlight(listbox, match, target);
141
+ event.preventDefault();
142
+ return true;
143
+ }
144
+ return;
145
+ }
146
+
147
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
148
+ const next = moveHighlight(listbox, event.key === "ArrowDown" ? 1 : -1);
149
+ if (next) highlight(listbox, next, target);
150
+ event.preventDefault();
151
+ return true;
152
+ }
153
+
154
+ if (event.key === "Home" || event.key === "End") {
155
+ highlight(listbox, event.key === "Home" ? firstOption(listbox) : lastOption(listbox), target);
156
+ event.preventDefault();
157
+ return true;
158
+ }
159
+
160
+ if (event.key === "Enter" || event.key === " ") {
161
+ const option = listbox.querySelector("[data-highlighted]");
162
+ if (option instanceof HTMLElement) choose(target, option);
163
+ event.preventDefault();
164
+ return true;
165
+ }
166
+
167
+ if (event.key === "Tab") {
168
+ closeSelect(target, false);
169
+ return;
170
+ }
171
+
172
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
173
+ const current = listbox.querySelector("[data-highlighted]");
174
+ const match = typeaheadTarget(
175
+ listbox,
176
+ event.key,
177
+ visibleOptions(listbox),
178
+ current instanceof Element ? current : null
179
+ );
180
+ if (match) highlight(listbox, match, target);
181
+ event.preventDefault();
182
+ return true;
183
+ }
184
+ }, 25);
185
+
186
+ onDocument("pointerdown", (event) => {
187
+ if (!(event.target instanceof Node)) return;
188
+ for (const control of document.querySelectorAll(".select [role='combobox']")) {
189
+ if (!(control instanceof HTMLElement) || !isExpanded(control)) continue;
190
+ const root = rootOf(control);
191
+ if (root.contains(event.target)) continue;
192
+ closeSelect(control, false);
193
+ }
194
+ });
195
+
196
+ init();
@@ -0,0 +1,95 @@
1
+ // @ts-check
2
+
3
+ import {
4
+ emit,
5
+ firstEnabled,
6
+ init,
7
+ isDisabled,
8
+ lastEnabled,
9
+ nextEnabled,
10
+ on,
11
+ panelFor
12
+ } from "./core.js";
13
+
14
+ const TAB_SELECTOR = "[role='tab']";
15
+
16
+ /** @param {Element} tab */
17
+ function tablistOf(tab) {
18
+ const tablist = tab.closest("[role='tablist']");
19
+ return tablist instanceof HTMLElement ? tablist : null;
20
+ }
21
+
22
+ /** @param {Element} tablist */
23
+ function tabsOf(tablist) {
24
+ return [...tablist.querySelectorAll(TAB_SELECTOR)].filter(
25
+ (tab) => tab.closest("[role='tablist']") === tablist
26
+ );
27
+ }
28
+
29
+ /** @param {Element} tab */
30
+ function rootOf(tab) {
31
+ return tab.closest(".tabs") ?? tablistOf(tab) ?? tab;
32
+ }
33
+
34
+ /**
35
+ * @param {Element} tab
36
+ * @param {boolean} focus
37
+ */
38
+ function selectTab(tab, focus) {
39
+ const tablist = tablistOf(tab);
40
+ if (!tablist) return;
41
+
42
+ const tabs = tabsOf(tablist);
43
+ for (const candidate of tabs) {
44
+ const selected = candidate === tab;
45
+ candidate.setAttribute("aria-selected", String(selected));
46
+ candidate.setAttribute("tabindex", selected ? "0" : "-1");
47
+
48
+ const panel = panelFor(candidate);
49
+ if (panel instanceof HTMLElement) {
50
+ panel.hidden = !selected;
51
+ }
52
+ }
53
+
54
+ emit(rootOf(tab), "change", { value: tab.id });
55
+ if (focus && tab instanceof HTMLElement) tab.focus();
56
+ }
57
+
58
+ on("click", ".tabs [role='tab']", (event, target) => {
59
+ if (!(target instanceof HTMLElement) || isDisabled(target)) return;
60
+ selectTab(target, false);
61
+ event.preventDefault();
62
+ return true;
63
+ });
64
+
65
+ on("keydown", ".tabs [role='tab']", (event, target) => {
66
+ if (!(event instanceof KeyboardEvent)) return;
67
+ if (!(target instanceof HTMLElement)) return;
68
+ const tablist = tablistOf(target);
69
+ if (!tablist) return;
70
+
71
+ const tabs = tabsOf(tablist);
72
+ const vertical = tablist.getAttribute("aria-orientation") === "vertical";
73
+ const nextKey = vertical ? "ArrowDown" : "ArrowRight";
74
+ const previousKey = vertical ? "ArrowUp" : "ArrowLeft";
75
+
76
+ if (event.key === nextKey || event.key === previousKey) {
77
+ const next = nextEnabled(
78
+ tabs,
79
+ target,
80
+ event.key === nextKey ? 1 : -1
81
+ );
82
+ if (next instanceof HTMLElement) selectTab(next, true);
83
+ event.preventDefault();
84
+ return true;
85
+ }
86
+
87
+ if (event.key === "Home" || event.key === "End") {
88
+ const next = event.key === "Home" ? firstEnabled(tabs) : lastEnabled(tabs);
89
+ if (next instanceof HTMLElement) selectTab(next, true);
90
+ event.preventDefault();
91
+ return true;
92
+ }
93
+ });
94
+
95
+ init();
@@ -0,0 +1,137 @@
1
+ // @ts-check
2
+
3
+ import { emit, init, on } from "./core.js";
4
+
5
+ const DEFAULT_DURATION = 5000;
6
+
7
+ /**
8
+ * @typedef {object} ToastState
9
+ * @property {number} duration
10
+ * @property {number} remaining
11
+ * @property {number} startedAt
12
+ * @property {number} timer
13
+ * @property {boolean} paused
14
+ */
15
+
16
+ /** @type {WeakMap<HTMLElement, ToastState>} */
17
+ const states = new WeakMap();
18
+
19
+ /** @param {Element} toast */
20
+ function durationOf(toast) {
21
+ const raw = toast.getAttribute("data-duration");
22
+ if (raw === null) return DEFAULT_DURATION;
23
+ const value = Number(raw);
24
+ return Number.isFinite(value) ? Math.max(0, value) : DEFAULT_DURATION;
25
+ }
26
+
27
+ /** @param {HTMLElement} toast */
28
+ function startTimer(toast) {
29
+ const state = states.get(toast);
30
+ if (!state || state.duration === 0) return;
31
+ state.startedAt = Date.now();
32
+ state.paused = false;
33
+ state.timer = window.setTimeout(() => dismiss(toast, "timeout"), state.remaining);
34
+ }
35
+
36
+ /** @param {HTMLElement} toast */
37
+ function arm(toast) {
38
+ if (states.has(toast) || toast.hasAttribute("hidden")) return;
39
+ const duration = durationOf(toast);
40
+ states.set(toast, {
41
+ duration,
42
+ remaining: duration,
43
+ startedAt: 0,
44
+ timer: 0,
45
+ paused: false
46
+ });
47
+ startTimer(toast);
48
+ }
49
+
50
+ /** @param {HTMLElement} toast */
51
+ function pause(toast) {
52
+ const state = states.get(toast);
53
+ if (!state || state.paused || state.duration === 0) return;
54
+ window.clearTimeout(state.timer);
55
+ state.remaining = Math.max(0, state.remaining - (Date.now() - state.startedAt));
56
+ state.paused = true;
57
+ }
58
+
59
+ /** @param {HTMLElement} toast */
60
+ function resume(toast) {
61
+ const state = states.get(toast);
62
+ if (!state || !state.paused || state.duration === 0) return;
63
+ startTimer(toast);
64
+ }
65
+
66
+ /** @param {HTMLElement} toast @param {"timeout" | "close"} reason */
67
+ function dismiss(toast, reason) {
68
+ const state = states.get(toast);
69
+ if (state) {
70
+ window.clearTimeout(state.timer);
71
+ states.delete(toast);
72
+ }
73
+ toast.hidden = true;
74
+ emit(toast, "dismiss", { reason });
75
+ }
76
+
77
+ /** @param {ParentNode} root */
78
+ function armAll(root) {
79
+ for (const toast of root.querySelectorAll(".toast")) {
80
+ if (toast instanceof HTMLElement) arm(toast);
81
+ }
82
+ }
83
+
84
+ on("click", ".toast [data-slot='close']", (event, target) => {
85
+ if (!(target instanceof HTMLElement)) return;
86
+ const toast = target.closest(".toast");
87
+ if (!(toast instanceof HTMLElement)) return;
88
+ dismiss(toast, "close");
89
+ event.preventDefault();
90
+ return true;
91
+ });
92
+
93
+ on("pointerover", ".toast", (_event, target) => {
94
+ if (!(target instanceof HTMLElement)) return;
95
+ pause(target);
96
+ });
97
+
98
+ on("pointerout", ".toast", (event, target) => {
99
+ if (!(target instanceof HTMLElement)) return;
100
+ const next = event instanceof PointerEvent ? event.relatedTarget : null;
101
+ if (next instanceof Node && target.contains(next)) return;
102
+ resume(target);
103
+ });
104
+
105
+ on("focusin", ".toast", (_event, target) => {
106
+ if (!(target instanceof HTMLElement)) return;
107
+ pause(target);
108
+ });
109
+
110
+ on("focusout", ".toast", (event, target) => {
111
+ if (!(target instanceof HTMLElement) || !(event instanceof FocusEvent)) return;
112
+ const next = event.relatedTarget;
113
+ if (next instanceof Node && target.contains(next)) return;
114
+ resume(target);
115
+ });
116
+
117
+ init();
118
+
119
+ if (typeof document !== "undefined") {
120
+ const armExisting = () => armAll(document);
121
+ if (document.readyState === "loading") {
122
+ document.addEventListener("DOMContentLoaded", armExisting, { once: true });
123
+ } else {
124
+ armExisting();
125
+ }
126
+
127
+ const observer = new MutationObserver((records) => {
128
+ for (const record of records) {
129
+ for (const node of record.addedNodes) {
130
+ if (!(node instanceof Element)) continue;
131
+ if (node.matches(".toast")) arm(/** @type {HTMLElement} */ (node));
132
+ armAll(node);
133
+ }
134
+ }
135
+ });
136
+ observer.observe(document.documentElement, { childList: true, subtree: true });
137
+ }
@@ -8,6 +8,25 @@
8
8
  flex-direction: column;
9
9
  overflow: hidden;
10
10
 
11
+ [data-slot='copy-icon'],
12
+ [data-slot='check-icon'] {
13
+ display: inline-flex;
14
+ }
15
+
16
+ [data-slot='check-icon'] {
17
+ display: none;
18
+ }
19
+
20
+ [data-slot='copy'][data-copied] {
21
+ [data-slot='copy-icon'] {
22
+ display: none;
23
+ }
24
+
25
+ [data-slot='check-icon'] {
26
+ display: inline-flex;
27
+ }
28
+ }
29
+
11
30
  > header {
12
31
  display: flex;
13
32
  min-width: 0;
@@ -1,5 +1,5 @@
1
1
  <!-- Default -->
2
- <button type="button" class="btn" data-variant="outline">
2
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-default">
3
3
  Open alert dialog
4
4
  </button>
5
5
 
@@ -12,14 +12,14 @@
12
12
  </p>
13
13
  </header>
14
14
  <footer>
15
- <button type="button" class="btn" data-variant="outline">Cancel</button>
16
- <button type="button" class="btn">Continue</button>
15
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Cancel</button>
16
+ <button type="button" class="btn" data-close-dialog>Continue</button>
17
17
  </footer>
18
18
  </div>
19
19
  </dialog>
20
20
 
21
21
  <!-- Destructive -->
22
- <button type="button" class="btn" data-variant="destructive">
22
+ <button type="button" class="btn" data-variant="destructive" data-open-dialog="demo-alert-dialog-destructive">
23
23
  Delete chat
24
24
  </button>
25
25
 
@@ -33,14 +33,14 @@
33
33
  </p>
34
34
  </header>
35
35
  <footer>
36
- <button type="button" class="btn" data-variant="outline">Cancel</button>
37
- <button type="button" class="btn" data-variant="destructive">Delete</button>
36
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Cancel</button>
37
+ <button type="button" class="btn" data-variant="destructive" data-close-dialog>Delete</button>
38
38
  </footer>
39
39
  </div>
40
40
  </dialog>
41
41
 
42
42
  <!-- Small -->
43
- <button type="button" class="btn" data-variant="outline">
43
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-small">
44
44
  Show small alert dialog
45
45
  </button>
46
46
 
@@ -53,14 +53,14 @@
53
53
  </p>
54
54
  </header>
55
55
  <footer>
56
- <button type="button" class="btn" data-variant="outline">Don't allow</button>
57
- <button type="button" class="btn">Allow</button>
56
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Don't allow</button>
57
+ <button type="button" class="btn" data-close-dialog>Allow</button>
58
58
  </footer>
59
59
  </div>
60
60
  </dialog>
61
61
 
62
62
  <!-- Media -->
63
- <button type="button" class="btn" data-variant="outline">
63
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-media">
64
64
  Share project
65
65
  </button>
66
66
 
@@ -74,14 +74,14 @@
74
74
  </p>
75
75
  </header>
76
76
  <footer>
77
- <button type="button" class="btn" data-variant="outline">Cancel</button>
78
- <button type="button" class="btn">Share</button>
77
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Cancel</button>
78
+ <button type="button" class="btn" data-close-dialog>Share</button>
79
79
  </footer>
80
80
  </div>
81
81
  </dialog>
82
82
 
83
83
  <!-- Small with media -->
84
- <button type="button" class="btn" data-variant="outline">
84
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-small-media">
85
85
  Show small media alert
86
86
  </button>
87
87
 
@@ -95,14 +95,14 @@
95
95
  </p>
96
96
  </header>
97
97
  <footer>
98
- <button type="button" class="btn" data-variant="outline">Don't allow</button>
99
- <button type="button" class="btn">Allow</button>
98
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Don't allow</button>
99
+ <button type="button" class="btn" data-close-dialog>Allow</button>
100
100
  </footer>
101
101
  </div>
102
102
  </dialog>
103
103
 
104
104
  <!-- With image -->
105
- <button type="button" class="btn" data-variant="outline">
105
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-image">
106
106
  Remove teammate
107
107
  </button>
108
108
 
@@ -116,15 +116,15 @@
116
116
  </p>
117
117
  </header>
118
118
  <footer>
119
- <button type="button" class="btn" data-variant="outline">Cancel</button>
120
- <button type="button" class="btn" data-variant="destructive">Remove</button>
119
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>Cancel</button>
120
+ <button type="button" class="btn" data-variant="destructive" data-close-dialog>Remove</button>
121
121
  </footer>
122
122
  </div>
123
123
  </dialog>
124
124
 
125
125
  <!-- Right-to-left -->
126
126
  <div dir="rtl" lang="ar" style="display: flex; flex-wrap: wrap; gap: 0.5rem">
127
- <button type="button" class="btn" data-variant="outline">
127
+ <button type="button" class="btn" data-variant="outline" data-open-dialog="demo-alert-dialog-rtl">
128
128
  إظهار الحوار
129
129
  </button>
130
130
 
@@ -138,8 +138,8 @@
138
138
  </p>
139
139
  </header>
140
140
  <footer>
141
- <button type="button" class="btn" data-variant="outline">عدم السماح</button>
142
- <button type="button" class="btn">السماح</button>
141
+ <button type="button" class="btn" data-variant="outline" data-close-dialog>عدم السماح</button>
142
+ <button type="button" class="btn" data-close-dialog>السماح</button>
143
143
  </footer>
144
144
  </div>
145
145
  </dialog>
@@ -83,10 +83,10 @@
83
83
  <div class="btn-group" role="group" aria-label="Copilot">
84
84
  <button type="button" class="btn" data-variant="outline"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-icon="inline-start"><path d="M12 8V4H8"/><rect width="16" height="12" x="4" y="8" rx="2"/><path d="M2 14h2"/><path d="M20 14h2"/><path d="M15 13v2"/><path d="M9 13v2"/></svg>Copilot</button>
85
85
  <div class="popover">
86
- <button type="button" class="btn" data-variant="outline" data-size="icon" aria-expanded="false" aria-label="Start a new task"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></button>
87
- <div data-popover data-side="bottom" data-align="end" aria-hidden="true">
86
+ <button type="button" class="btn" data-variant="outline" data-size="icon" aria-haspopup="dialog" aria-expanded="false" aria-controls="demo-button-group-task-panel" aria-label="Start a new task"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg></button>
87
+ <div data-popover data-side="bottom" data-align="end" id="demo-button-group-task-panel" role="dialog" tabindex="-1" aria-hidden="true" aria-labelledby="demo-button-group-task-title">
88
88
  <header>
89
- <h3 data-slot="title">Start a new task</h3>
89
+ <h3 data-slot="title" id="demo-button-group-task-title">Start a new task</h3>
90
90
  <p data-slot="description">Describe your task in natural language.</p>
91
91
  </header>
92
92
  <div class="field">
@@ -8,7 +8,7 @@
8
8
  <header>
9
9
  <span data-slot="title">app/api/chat/route.ts</span>
10
10
  <div data-slot="actions">
11
- <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" aria-label="Copy code"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></button>
11
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="copy" aria-label="Copy code"><span data-slot="copy-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></span><span data-slot="check-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></button>
12
12
  </div>
13
13
  </header>
14
14
  <pre dir="ltr" tabindex="0"><code>import { streamText } from "ai";
@@ -28,6 +28,9 @@ export async function POST(request: Request) {
28
28
  <div class="code-block">
29
29
  <header>
30
30
  <span data-slot="title">app/dashboard/page.tsx</span>
31
+ <div data-slot="actions">
32
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="copy" aria-label="Copy code"><span data-slot="copy-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></span><span data-slot="check-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></button>
33
+ </div>
31
34
  </header>
32
35
  <pre data-line-numbers style="--line-start: 12" dir="ltr" tabindex="0"><code><span data-slot="line"><span data-slot="line-content"> if (!session) {</span></span>
33
36
  <span data-slot="line"><span data-slot="line-content"> redirect("/login");</span></span>
@@ -45,6 +48,9 @@ export async function POST(request: Request) {
45
48
  <div class="code-block">
46
49
  <header>
47
50
  <span data-slot="title">components/greeting.tsx</span>
51
+ <div data-slot="actions">
52
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="copy" aria-label="Copy code"><span data-slot="copy-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></span><span data-slot="check-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></button>
53
+ </div>
48
54
  </header>
49
55
  <pre dir="ltr" tabindex="0"><code><span data-slot="line"><span data-slot="line-content">export function Greeting({ name }: { name: string }) {</span></span>
50
56
  <span data-slot="line"><span data-slot="line-content"> return &lt;p&gt;Hello, {name}&lt;/p&gt;;</span></span>
@@ -59,8 +65,8 @@ export async function POST(request: Request) {
59
65
  <header>
60
66
  <span data-slot="title">Error</span>
61
67
  <div data-slot="actions">
62
- <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" aria-label="Wrap lines" aria-pressed="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" x2="21" y1="6" y2="6"/><path d="M3 12h15a3 3 0 1 1 0 6h-4"/><polyline points="16 16 14 18 16 20"/><line x1="3" x2="10" y1="18" y2="18"/></svg></button>
63
- <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" aria-label="Copy output"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></button>
68
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="wrap" aria-label="Wrap lines" aria-pressed="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" x2="21" y1="6" y2="6"/><path d="M3 12h15a3 3 0 1 1 0 6h-4"/><polyline points="16 16 14 18 16 20"/><line x1="3" x2="10" y1="18" y2="18"/></svg></button>
69
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="copy" aria-label="Copy output"><span data-slot="copy-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></span><span data-slot="check-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></button>
64
70
  </div>
65
71
  </header>
66
72
  <pre data-wrap dir="ltr" tabindex="0"><code>TypeError: The model "anthropic/claude-sonnet-4.5" returned an error: Request too large. The prompt is 212,431 tokens but the context window is 200,000 tokens.</code></pre>
@@ -69,7 +75,7 @@ export async function POST(request: Request) {
69
75
  <!-- Floating actions -->
70
76
  <div class="code-block">
71
77
  <div data-slot="actions">
72
- <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" aria-label="Copy output"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></button>
78
+ <button class="btn" data-variant="ghost" data-size="icon-xs" type="button" data-slot="copy" aria-label="Copy output"><span data-slot="copy-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg></span><span data-slot="check-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5"/></svg></span></button>
73
79
  </div>
74
80
  <pre dir="ltr" tabindex="0"><code>$ pnpm add ai @ai-sdk/react zod
75
81
  Packages: +14
@@ -1,6 +1,7 @@
1
1
  <!-- Default -->
2
2
  <div class="combobox">
3
3
  <input role="combobox" aria-expanded="false" aria-controls="combobox-default-panel" aria-autocomplete="list" placeholder="Select a framework..." aria-label="Select a framework">
4
+ <input type="hidden" data-slot="input" name="value">
4
5
  <div data-popover data-side="bottom" aria-hidden="true" id="combobox-default-panel">
5
6
  <div role="listbox" aria-label="Frameworks">
6
7
  <div role="option" aria-selected="false"><span data-slot="text">React</span></div>
@@ -14,6 +15,7 @@
14
15
  <!-- Single -->
15
16
  <div class="combobox">
16
17
  <input role="combobox" aria-expanded="false" aria-controls="combobox-fruit-panel" aria-autocomplete="list" placeholder="Search fruit..." aria-label="Search fruit">
18
+ <input type="hidden" data-slot="input" name="value">
17
19
  <button type="button" class="btn" data-variant="ghost" data-size="icon-xs" data-slot="clear" aria-label="Clear">×</button>
18
20
  <div data-popover data-side="bottom" aria-hidden="true" id="combobox-fruit-panel">
19
21
  <div role="listbox" aria-label="Fruit">