@ui-sdk/vue 0.0.0-stage → 0.1.0-beta.1

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 (262) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -2
  3. package/dist/accordion.d.ts +561 -0
  4. package/dist/accordion.js +24 -0
  5. package/dist/agent.d.ts +2 -0
  6. package/dist/agent.js +7 -0
  7. package/dist/alert-dialog.d.ts +231 -0
  8. package/dist/alert-dialog.js +33 -0
  9. package/dist/async-options.d.ts +18 -0
  10. package/dist/async-options.js +40 -0
  11. package/dist/autocomplete.d.ts +384 -0
  12. package/dist/autocomplete.js +344 -0
  13. package/dist/avatar.d.ts +40 -0
  14. package/dist/avatar.js +28 -0
  15. package/dist/button.d.ts +52 -0
  16. package/dist/button.js +43 -0
  17. package/dist/calendar-context.d.ts +10 -0
  18. package/dist/calendar-context.js +7 -0
  19. package/dist/calendar.d.ts +311 -0
  20. package/dist/calendar.js +349 -0
  21. package/dist/carousel.d.ts +236 -0
  22. package/dist/carousel.js +204 -0
  23. package/dist/checkbox.d.ts +211 -0
  24. package/dist/checkbox.js +151 -0
  25. package/dist/children.d.ts +41 -0
  26. package/dist/children.js +135 -0
  27. package/dist/collapsible.d.ts +54 -0
  28. package/dist/collapsible.js +18 -0
  29. package/dist/color-picker.d.ts +187 -0
  30. package/dist/color-picker.js +158 -0
  31. package/dist/color.d.ts +2 -0
  32. package/dist/color.js +21 -0
  33. package/dist/combobox.d.ts +517 -0
  34. package/dist/combobox.js +531 -0
  35. package/dist/command.d.ts +322 -0
  36. package/dist/command.js +345 -0
  37. package/dist/controller-target.d.ts +49 -0
  38. package/dist/controller-target.js +112 -0
  39. package/dist/create-parts.d.ts +126 -0
  40. package/dist/create-parts.js +206 -0
  41. package/dist/date-input.d.ts +133 -0
  42. package/dist/date-input.js +31 -0
  43. package/dist/date-picker.d.ts +328 -0
  44. package/dist/date-picker.js +354 -0
  45. package/dist/date.d.ts +2 -0
  46. package/dist/date.js +59 -0
  47. package/dist/dialog-parts.d.ts +259 -0
  48. package/dist/dialog-parts.js +300 -0
  49. package/dist/dialog.d.ts +251 -0
  50. package/dist/dialog.js +25 -0
  51. package/dist/drawer.d.ts +304 -0
  52. package/dist/drawer.js +373 -0
  53. package/dist/editor-context.d.ts +4 -0
  54. package/dist/editor-context.js +5 -0
  55. package/dist/field-context.d.ts +26 -0
  56. package/dist/field-context.js +44 -0
  57. package/dist/field.d.ts +154 -0
  58. package/dist/field.js +240 -0
  59. package/dist/file-input.d.ts +212 -0
  60. package/dist/file-input.js +255 -0
  61. package/dist/form-inputs.d.ts +16 -0
  62. package/dist/form-inputs.js +25 -0
  63. package/dist/gesture.d.ts +1 -0
  64. package/dist/gesture.js +15 -0
  65. package/dist/history.d.ts +2 -0
  66. package/dist/history.js +11 -0
  67. package/dist/hover-card.d.ts +137 -0
  68. package/dist/hover-card.js +153 -0
  69. package/dist/image-cropper.d.ts +74 -0
  70. package/dist/image-cropper.js +36 -0
  71. package/dist/image.d.ts +2 -0
  72. package/dist/image.js +5 -0
  73. package/dist/index.d.ts +59 -0
  74. package/dist/index.js +60 -0
  75. package/dist/input.d.ts +120 -0
  76. package/dist/input.js +73 -0
  77. package/dist/item-icon.d.ts +34 -0
  78. package/dist/item-icon.js +63 -0
  79. package/dist/label.d.ts +16 -0
  80. package/dist/label.js +8 -0
  81. package/dist/lifecycle.d.ts +11 -0
  82. package/dist/lifecycle.js +91 -0
  83. package/dist/list-items.d.ts +38 -0
  84. package/dist/list-items.js +59 -0
  85. package/dist/list-text.d.ts +7 -0
  86. package/dist/list-text.js +15 -0
  87. package/dist/listbox.d.ts +273 -0
  88. package/dist/listbox.js +126 -0
  89. package/dist/menu.d.ts +678 -0
  90. package/dist/menu.js +607 -0
  91. package/dist/menubar-context.d.ts +5 -0
  92. package/dist/menubar-context.js +5 -0
  93. package/dist/menubar.d.ts +61 -0
  94. package/dist/menubar.js +48 -0
  95. package/dist/meter.d.ts +41 -0
  96. package/dist/meter.js +37 -0
  97. package/dist/navigation-menu.d.ts +228 -0
  98. package/dist/navigation-menu.js +195 -0
  99. package/dist/number-input.d.ts +176 -0
  100. package/dist/number-input.js +231 -0
  101. package/dist/number.d.ts +2 -0
  102. package/dist/number.js +39 -0
  103. package/dist/nuxt/entries.json +977 -0
  104. package/dist/nuxt/module.d.ts +18 -0
  105. package/dist/nuxt/module.js +31 -0
  106. package/dist/nuxt/registrations.d.ts +22 -0
  107. package/dist/nuxt/registrations.js +22 -0
  108. package/dist/observe.d.ts +2 -0
  109. package/dist/observe.js +7 -0
  110. package/dist/otp-input.d.ts +142 -0
  111. package/dist/otp-input.js +130 -0
  112. package/dist/overlays.d.ts +40 -0
  113. package/dist/overlays.js +118 -0
  114. package/dist/pagination.d.ts +201 -0
  115. package/dist/pagination.js +146 -0
  116. package/dist/password-input.d.ts +144 -0
  117. package/dist/password-input.js +134 -0
  118. package/dist/popover.d.ts +211 -0
  119. package/dist/popover.js +258 -0
  120. package/dist/popup.d.ts +60 -0
  121. package/dist/popup.js +89 -0
  122. package/dist/preferences.d.ts +44 -0
  123. package/dist/preferences.js +102 -0
  124. package/dist/primitive.d.ts +2 -0
  125. package/dist/primitive.js +11 -0
  126. package/dist/progress.d.ts +41 -0
  127. package/dist/progress.js +37 -0
  128. package/dist/radio.d.ts +164 -0
  129. package/dist/radio.js +145 -0
  130. package/dist/rating.d.ts +149 -0
  131. package/dist/rating.js +146 -0
  132. package/dist/renderless.d.ts +4 -0
  133. package/dist/renderless.js +28 -0
  134. package/dist/resizable.d.ts +54 -0
  135. package/dist/resizable.js +22 -0
  136. package/dist/scroll-area.d.ts +72 -0
  137. package/dist/scroll-area.js +77 -0
  138. package/dist/segmented-control.d.ts +151 -0
  139. package/dist/segmented-control.js +110 -0
  140. package/dist/segmented-input.d.ts +76 -0
  141. package/dist/segmented-input.js +115 -0
  142. package/dist/select.d.ts +458 -0
  143. package/dist/select.js +468 -0
  144. package/dist/separator.d.ts +14 -0
  145. package/dist/separator.js +8 -0
  146. package/dist/shortcuts.d.ts +32 -0
  147. package/dist/shortcuts.js +56 -0
  148. package/dist/slider.d.ts +65 -0
  149. package/dist/slider.js +194 -0
  150. package/dist/switch.d.ts +103 -0
  151. package/dist/switch.js +71 -0
  152. package/dist/tabs.d.ts +338 -0
  153. package/dist/tabs.js +27 -0
  154. package/dist/text-control.d.ts +89 -0
  155. package/dist/text-control.js +51 -0
  156. package/dist/text-match.d.ts +2 -0
  157. package/dist/text-match.js +7 -0
  158. package/dist/textarea.d.ts +106 -0
  159. package/dist/textarea.js +68 -0
  160. package/dist/time-input.d.ts +131 -0
  161. package/dist/time-input.js +32 -0
  162. package/dist/timeline.d.ts +81 -0
  163. package/dist/timeline.js +30 -0
  164. package/dist/toast-parts.d.ts +203 -0
  165. package/dist/toast-parts.js +270 -0
  166. package/dist/toast.d.ts +2 -0
  167. package/dist/toast.js +21 -0
  168. package/dist/toggle-props.d.ts +22 -0
  169. package/dist/toggle-props.js +14 -0
  170. package/dist/toggle.d.ts +199 -0
  171. package/dist/toggle.js +129 -0
  172. package/dist/token-input.d.ts +136 -0
  173. package/dist/token-input.js +214 -0
  174. package/dist/toolbar-context.d.ts +7 -0
  175. package/dist/toolbar-context.js +20 -0
  176. package/dist/toolbar.d.ts +120 -0
  177. package/dist/toolbar.js +77 -0
  178. package/dist/tooltip.d.ts +160 -0
  179. package/dist/tooltip.js +224 -0
  180. package/dist/tree.d.ts +300 -0
  181. package/dist/tree.js +209 -0
  182. package/dist/trigger-menu.d.ts +452 -0
  183. package/dist/trigger-menu.js +254 -0
  184. package/dist/use-primitive.d.ts +132 -0
  185. package/dist/use-primitive.js +462 -0
  186. package/dist/waterfall.d.ts +201 -0
  187. package/dist/waterfall.js +171 -0
  188. package/docs/README.md +89 -0
  189. package/docs/agents.md +1523 -0
  190. package/docs/components/accordion.md +1369 -0
  191. package/docs/components/alert-dialog.md +799 -0
  192. package/docs/components/autocomplete.md +1857 -0
  193. package/docs/components/avatar.md +272 -0
  194. package/docs/components/button.md +435 -0
  195. package/docs/components/calendar.md +1589 -0
  196. package/docs/components/carousel.md +1171 -0
  197. package/docs/components/checkbox.md +1008 -0
  198. package/docs/components/collapsible.md +536 -0
  199. package/docs/components/color-picker.md +706 -0
  200. package/docs/components/combobox.md +3504 -0
  201. package/docs/components/command.md +1481 -0
  202. package/docs/components/date-input.md +536 -0
  203. package/docs/components/date-picker.md +1244 -0
  204. package/docs/components/dialog.md +1397 -0
  205. package/docs/components/drawer.md +1166 -0
  206. package/docs/components/field.md +538 -0
  207. package/docs/components/file-input.md +611 -0
  208. package/docs/components/hover-card.md +505 -0
  209. package/docs/components/image-cropper.md +556 -0
  210. package/docs/components/input.md +306 -0
  211. package/docs/components/label.md +203 -0
  212. package/docs/components/listbox.md +1004 -0
  213. package/docs/components/menu.md +1229 -0
  214. package/docs/components/menubar.md +443 -0
  215. package/docs/components/meter.md +315 -0
  216. package/docs/components/navigation-menu.md +1523 -0
  217. package/docs/components/number-input.md +1029 -0
  218. package/docs/components/otp-input.md +512 -0
  219. package/docs/components/pagination.md +613 -0
  220. package/docs/components/password-input.md +649 -0
  221. package/docs/components/popover.md +1448 -0
  222. package/docs/components/preferences.md +208 -0
  223. package/docs/components/progress.md +423 -0
  224. package/docs/components/radio.md +785 -0
  225. package/docs/components/rating.md +416 -0
  226. package/docs/components/resizable.md +910 -0
  227. package/docs/components/scroll-area.md +915 -0
  228. package/docs/components/segmented-control.md +435 -0
  229. package/docs/components/select.md +2015 -0
  230. package/docs/components/separator.md +229 -0
  231. package/docs/components/slider.md +1084 -0
  232. package/docs/components/switch.md +565 -0
  233. package/docs/components/tabs.md +944 -0
  234. package/docs/components/textarea.md +299 -0
  235. package/docs/components/time-input.md +224 -0
  236. package/docs/components/timeline.md +654 -0
  237. package/docs/components/toast.md +1224 -0
  238. package/docs/components/toggle.md +500 -0
  239. package/docs/components/token-input.md +953 -0
  240. package/docs/components/toolbar.md +739 -0
  241. package/docs/components/tooltip.md +818 -0
  242. package/docs/components/tree.md +1306 -0
  243. package/docs/components/trigger-menu.md +1223 -0
  244. package/docs/components/waterfall.md +717 -0
  245. package/docs/controllers.md +71 -0
  246. package/docs/core.md +8027 -0
  247. package/docs/custom-parts.md +89 -0
  248. package/docs/first-component.md +83 -0
  249. package/docs/forms.md +122 -0
  250. package/docs/installation.md +72 -0
  251. package/docs/introduction.md +32 -0
  252. package/docs/lists-and-menus.md +122 -0
  253. package/docs/llms.txt +1502 -0
  254. package/docs/parts-and-composition.md +85 -0
  255. package/docs/popups.md +108 -0
  256. package/docs/rendering.md +56 -0
  257. package/docs/server-rendering.md +180 -0
  258. package/docs/state-and-events.md +100 -0
  259. package/docs/styling-and-animation.md +148 -0
  260. package/docs/utilities/async-options.md +348 -0
  261. package/docs/utilities/shortcuts.md +159 -0
  262. package/package.json +352 -3
package/dist/menu.js ADDED
@@ -0,0 +1,607 @@
1
+ // src/menu.ts
2
+ import {
3
+ formatShortcut
4
+ } from "@ui-sdk/core";
5
+ import {
6
+ menu as menuPrimitive
7
+ } from "@ui-sdk/core/menu";
8
+ import {
9
+ menuCheckable,
10
+ menuContextTrigger,
11
+ menuItemIcons
12
+ } from "@ui-sdk/core/renderer";
13
+ import {
14
+ defineComponent,
15
+ h,
16
+ inject,
17
+ provide,
18
+ useId
19
+ } from "vue";
20
+ import {
21
+ hasChild,
22
+ NotPlaced,
23
+ usePlaceContent,
24
+ usePlacedContent
25
+ } from "./children.js";
26
+ import { defineItemIcon } from "./item-icon.js";
27
+ import { MenubarKey } from "./menubar-context.js";
28
+ import {
29
+ containerProp,
30
+ renderPopup,
31
+ renderUnbound,
32
+ sheetViewport,
33
+ useConnectedPart,
34
+ useControllerEntry,
35
+ useControllerTarget,
36
+ usePopupContainer,
37
+ withPayload
38
+ } from "./popup.js";
39
+ import { createParts, withElement } from "./create-parts.js";
40
+ import {
41
+ optionalBoolean,
42
+ orModel,
43
+ provideProps,
44
+ useHandle,
45
+ usePart,
46
+ usePrimitive,
47
+ useScope
48
+ } from "./use-primitive.js";
49
+ import { renderless } from "./renderless.js";
50
+ import { createMenuController } from "@ui-sdk/core/menu";
51
+ var ContainerKey = /* @__PURE__ */ Symbol("menu-container");
52
+ var ItemKey = /* @__PURE__ */ Symbol("menu-item");
53
+ var useMenu = () => useHandle(menuPrimitive);
54
+ var useGroup = () => {
55
+ const around = useScope(menuPrimitive)?.around;
56
+ return around?.["radio-group"]?.().name ?? around?.group?.().id;
57
+ };
58
+ var parts = createParts(menuPrimitive, { shortcut: "span", separator: "div" });
59
+ var Menu = /* @__PURE__ */ renderless(
60
+ defineComponent({
61
+ name: "Menu",
62
+ props: {
63
+ open: optionalBoolean,
64
+ modelValue: optionalBoolean,
65
+ defaultOpen: optionalBoolean,
66
+ items: Array,
67
+ itemShortcuts: optionalBoolean,
68
+ loop: optionalBoolean,
69
+ delay: Number,
70
+ presentation: String,
71
+ modal: {
72
+ type: [Boolean, String],
73
+ default: void 0
74
+ },
75
+ controller: Object,
76
+ dismissible: optionalBoolean,
77
+ pendingAnnouncement: String,
78
+ debug: optionalBoolean,
79
+ container: containerProp,
80
+ // A function prop beside the emits, so a returned Promise marks the item pending.
81
+ onAction: Function
82
+ },
83
+ emits: {
84
+ "update:open": (_open) => true,
85
+ "update:modelValue": (_open) => true,
86
+ openChange: (_open, _details) => true,
87
+ openChangeComplete: (_open) => true,
88
+ dismissAttempt: (_details) => true,
89
+ payloadChange: (_payload, _details) => true,
90
+ checkedChange: (_checked, _details) => true,
91
+ valueChange: (_value, _details) => true
92
+ },
93
+ setup(props, { slots, emit }) {
94
+ provide(ContainerKey, () => props.container);
95
+ const menubar = inject(MenubarKey, null);
96
+ provide(MenubarKey, null);
97
+ const menu = usePrimitive(menuPrimitive, () => ({
98
+ ...props,
99
+ open: orModel(props.open, props.modelValue),
100
+ container: void 0,
101
+ menubar: menubar ? () => menubar.api : void 0,
102
+ onOpenChange: (open, details) => {
103
+ emit("openChange", open, details);
104
+ if (details.canceled) {
105
+ return;
106
+ }
107
+ emit("update:open", open);
108
+ emit("update:modelValue", open);
109
+ },
110
+ onOpenChangeComplete: (open) => emit("openChangeComplete", open),
111
+ onDismissAttempt: (details) => emit("dismissAttempt", details),
112
+ onPayloadChange: (payload, details) => emit("payloadChange", payload, details),
113
+ onCheckedChange: (checked, details) => emit("checkedChange", checked, details),
114
+ onValueChange: (value, details) => emit("valueChange", value, details)
115
+ }));
116
+ useControllerEntry(() => props.controller, menu);
117
+ const placed = usePlacedContent();
118
+ return () => {
119
+ const children = slots.default?.() ?? [];
120
+ const own = !props.items || placed() || hasChild(children, MenuContent);
121
+ return [
122
+ children,
123
+ props.items && !own && h(
124
+ NotPlaced,
125
+ () => h(MenuContent, null, () => h(MenuItems, { items: props.items }))
126
+ )
127
+ ];
128
+ };
129
+ }
130
+ })
131
+ );
132
+ function triggerPart(name, slot, tag, feature) {
133
+ return withElement(
134
+ tag,
135
+ defineComponent({
136
+ name,
137
+ inheritAttrs: false,
138
+ props: {
139
+ disabled: optionalBoolean,
140
+ focusableWhenDisabled: optionalBoolean,
141
+ payload: null,
142
+ // A keyboard shortcut that opens the menu, like "mod+j". Root triggers only.
143
+ shortcut: String,
144
+ // Connects a trigger outside the menu to the menu with this controller.
145
+ controller: Object
146
+ },
147
+ slots: Object,
148
+ setup(props, { slots, attrs }) {
149
+ const connected = useControllerTarget(
150
+ menuPrimitive,
151
+ () => props.controller
152
+ );
153
+ const id = useId();
154
+ const part = () => ({
155
+ id,
156
+ disabled: props.disabled,
157
+ focusableWhenDisabled: props.focusableWhenDisabled,
158
+ payload: props.payload,
159
+ shortcut: props.shortcut
160
+ });
161
+ return useConnectedPart(
162
+ connected,
163
+ (menu) => {
164
+ if (feature) {
165
+ menu.instance.use(feature);
166
+ }
167
+ return usePart(menu, slot, part, void 0, tag);
168
+ },
169
+ // Until the menu it names mounts, a trigger outside the menu is a plain element.
170
+ () => renderUnbound(
171
+ tag,
172
+ {
173
+ ...tag === "button" && {
174
+ type: "button",
175
+ disabled: props.disabled && !props.focusableWhenDisabled,
176
+ "aria-disabled": props.disabled && props.focusableWhenDisabled || void 0
177
+ },
178
+ ...attrs
179
+ },
180
+ { slots, state: { open: false, disabled: !!props.disabled } }
181
+ )
182
+ );
183
+ }
184
+ })
185
+ );
186
+ }
187
+ var MenuTrigger = triggerPart("MenuTrigger", "trigger", "button");
188
+ var MenuContextTrigger = /* @__PURE__ */ triggerPart(
189
+ "MenuContextTrigger",
190
+ "context-trigger",
191
+ "div",
192
+ menuContextTrigger
193
+ );
194
+ var MenuContent = withPayload(
195
+ withElement(
196
+ "div",
197
+ defineComponent({
198
+ name: "MenuContent",
199
+ inheritAttrs: false,
200
+ props: {
201
+ side: String,
202
+ align: String,
203
+ sideOffset: Number,
204
+ alignOffset: Number,
205
+ collisionPadding: Number,
206
+ arrowPadding: Number,
207
+ anchor: [Object, String],
208
+ finalFocus: [String, Object, Function],
209
+ keepMounted: optionalBoolean,
210
+ // Renders the popup into this element instead of in place. Submenus stay
211
+ // inside their parent's popup.
212
+ container: containerProp
213
+ },
214
+ slots: Object,
215
+ setup(props) {
216
+ usePlaceContent();
217
+ const menu = useMenu();
218
+ const fromRoot = inject(ContainerKey, () => void 0);
219
+ const target = usePopupContainer(() => props.container ?? fromRoot());
220
+ const position = () => {
221
+ const { container, ...position2 } = props;
222
+ return position2;
223
+ };
224
+ const part = usePart(menu, "content", position);
225
+ return () => {
226
+ const element = part();
227
+ if (!element) {
228
+ return null;
229
+ }
230
+ return menu.api.root() !== menu.api ? element : renderPopup(sheetViewport(menu, element), target());
231
+ };
232
+ }
233
+ })
234
+ )
235
+ );
236
+ var MenuShortcut = parts.Shortcut;
237
+ var MenuItem = withElement(
238
+ "div",
239
+ defineComponent({
240
+ name: "MenuItem",
241
+ inheritAttrs: false,
242
+ props: {
243
+ value: String,
244
+ label: String,
245
+ disabled: optionalBoolean,
246
+ shortcut: String,
247
+ closeOnSelect: optionalBoolean,
248
+ destructive: optionalBoolean,
249
+ // A function prop beside the emit, so a returned Promise marks the item pending.
250
+ onSelect: Function
251
+ },
252
+ slots: Object,
253
+ setup(props, { slots }) {
254
+ const menu = useMenu();
255
+ const id = useId();
256
+ const item = () => ({ ...props, id });
257
+ return usePart(menu, "item", item, void 0, {
258
+ tag: "div",
259
+ children: (state) => [
260
+ slots.default?.({ state }),
261
+ props.shortcut && h(
262
+ MenuShortcut,
263
+ null,
264
+ () => formatShortcut(props.shortcut, menu.state.apple)
265
+ )
266
+ ]
267
+ });
268
+ }
269
+ })
270
+ );
271
+ var MenuCheckboxItem = /* @__PURE__ */ withElement(
272
+ "div",
273
+ /* @__PURE__ */ defineComponent({
274
+ name: "MenuCheckboxItem",
275
+ inheritAttrs: false,
276
+ props: {
277
+ value: { type: String, required: true },
278
+ label: String,
279
+ disabled: optionalBoolean,
280
+ checked: optionalBoolean,
281
+ modelValue: optionalBoolean,
282
+ defaultChecked: optionalBoolean,
283
+ closeOnSelect: optionalBoolean
284
+ },
285
+ emits: {
286
+ "update:checked": (_checked) => true,
287
+ "update:modelValue": (_checked) => true,
288
+ checkedChange: (_checked, _details) => true
289
+ },
290
+ slots: Object,
291
+ setup(props, { emit }) {
292
+ const menu = useMenu();
293
+ menu.instance.use(menuCheckable);
294
+ provide(ItemKey, () => ({ item: "checkbox-item", itemKey: props.value }));
295
+ const item = () => ({
296
+ ...props,
297
+ checked: orModel(props.checked, props.modelValue),
298
+ onCheckedChange: (checked, details) => {
299
+ emit("checkedChange", checked, details);
300
+ if (details.canceled) {
301
+ return;
302
+ }
303
+ emit("update:checked", checked);
304
+ emit("update:modelValue", checked);
305
+ }
306
+ });
307
+ return usePart(menu, "checkbox-item", item);
308
+ }
309
+ })
310
+ );
311
+ var MenuRadioGroup = /* @__PURE__ */ withElement(
312
+ "div",
313
+ /* @__PURE__ */ defineComponent({
314
+ name: "MenuRadioGroup",
315
+ inheritAttrs: false,
316
+ props: {
317
+ // Identifies the group in the menu's `valueChange`. Defaults to a generated id.
318
+ name: String,
319
+ value: { type: String, default: void 0 },
320
+ modelValue: {
321
+ type: String,
322
+ default: void 0
323
+ },
324
+ defaultValue: {
325
+ type: String,
326
+ default: void 0
327
+ }
328
+ },
329
+ emits: {
330
+ "update:value": (_value) => true,
331
+ "update:modelValue": (_value) => true,
332
+ valueChange: (_value, _details) => true
333
+ },
334
+ slots: Object,
335
+ setup(props, { emit }) {
336
+ const menu = useMenu();
337
+ menu.instance.use(menuCheckable);
338
+ const generated = useId();
339
+ const name = props.name ?? generated;
340
+ provideProps(menuPrimitive, "radio-group", () => ({ name }));
341
+ const group = () => ({
342
+ value: orModel(props.value, props.modelValue),
343
+ defaultValue: props.defaultValue,
344
+ id: name,
345
+ name,
346
+ onValueChange: (value, details) => {
347
+ emit("valueChange", value, details);
348
+ if (details.canceled) {
349
+ return;
350
+ }
351
+ emit("update:value", value);
352
+ emit("update:modelValue", value);
353
+ }
354
+ });
355
+ return usePart(menu, "radio-group", group);
356
+ }
357
+ })
358
+ );
359
+ var MenuRadioItem = /* @__PURE__ */ withElement(
360
+ "div",
361
+ /* @__PURE__ */ defineComponent({
362
+ name: "MenuRadioItem",
363
+ inheritAttrs: false,
364
+ props: {
365
+ value: { type: String, required: true },
366
+ label: String,
367
+ disabled: optionalBoolean,
368
+ closeOnSelect: optionalBoolean
369
+ },
370
+ slots: Object,
371
+ setup(props) {
372
+ const menu = useMenu();
373
+ menu.instance.use(menuCheckable);
374
+ const group = useScope(menuPrimitive)?.around["radio-group"]?.().name;
375
+ if (!group) {
376
+ throw new Error("<MenuRadioItem> must be used inside <MenuRadioGroup>.");
377
+ }
378
+ provide(ItemKey, () => ({
379
+ item: "radio-item",
380
+ itemKey: props.value,
381
+ group
382
+ }));
383
+ const item = () => ({ ...props, group });
384
+ return usePart(menu, "radio-item", item);
385
+ }
386
+ })
387
+ );
388
+ var MenuItemIndicator = /* @__PURE__ */ withElement(
389
+ "span",
390
+ /* @__PURE__ */ defineComponent({
391
+ name: "MenuItemIndicator",
392
+ inheritAttrs: false,
393
+ props: { keepMounted: optionalBoolean },
394
+ slots: Object,
395
+ setup(props) {
396
+ const menu = useMenu();
397
+ menu.instance.use(menuCheckable);
398
+ const id = useId();
399
+ const item = inject(ItemKey, null);
400
+ if (!item) {
401
+ throw new Error(
402
+ "<MenuItemIndicator> must be used inside a checkbox or radio item."
403
+ );
404
+ }
405
+ const indicator = () => ({
406
+ id,
407
+ ...item(),
408
+ keepMounted: props.keepMounted
409
+ });
410
+ return usePart(menu, "item-indicator", indicator, void 0, "span");
411
+ }
412
+ })
413
+ );
414
+ var MenuItemIcon = /* @__PURE__ */ defineItemIcon(
415
+ "MenuItemIcon",
416
+ menuPrimitive,
417
+ "item-icon",
418
+ menuItemIcons
419
+ );
420
+ var MenuGroup = withElement(
421
+ "div",
422
+ defineComponent({
423
+ name: "MenuGroup",
424
+ inheritAttrs: false,
425
+ slots: Object,
426
+ setup() {
427
+ const id = useId();
428
+ provideProps(menuPrimitive, "group", () => ({ id }));
429
+ return usePart(menuPrimitive, "group", () => ({ id }));
430
+ }
431
+ })
432
+ );
433
+ var MenuGroupLabel = withElement(
434
+ "div",
435
+ defineComponent({
436
+ name: "MenuGroupLabel",
437
+ inheritAttrs: false,
438
+ slots: Object,
439
+ setup() {
440
+ const group = useGroup();
441
+ if (!group) {
442
+ throw new Error(
443
+ "<MenuGroupLabel> must be used inside <MenuGroup> or <MenuRadioGroup>."
444
+ );
445
+ }
446
+ return usePart(menuPrimitive, "group-label", () => ({ id: group, group }));
447
+ }
448
+ })
449
+ );
450
+ var MenuSeparator = parts.Separator;
451
+ var MenuSub = /* @__PURE__ */ renderless(
452
+ defineComponent({
453
+ name: "MenuSub",
454
+ props: {
455
+ open: optionalBoolean,
456
+ modelValue: optionalBoolean,
457
+ defaultOpen: optionalBoolean,
458
+ delay: Number,
459
+ loop: optionalBoolean,
460
+ controller: Object,
461
+ debug: optionalBoolean
462
+ },
463
+ emits: {
464
+ "update:open": (_open) => true,
465
+ "update:modelValue": (_open) => true,
466
+ openChange: (_open, _details) => true,
467
+ openChangeComplete: (_open) => true
468
+ },
469
+ setup(props, { slots, emit }) {
470
+ const parent = useMenu();
471
+ usePrimitive(menuPrimitive, () => ({
472
+ ...props,
473
+ open: orModel(props.open, props.modelValue),
474
+ parent: parent.api,
475
+ onOpenChange: (open, details) => {
476
+ emit("openChange", open, details);
477
+ if (details.canceled) {
478
+ return;
479
+ }
480
+ emit("update:open", open);
481
+ emit("update:modelValue", open);
482
+ },
483
+ onOpenChangeComplete: (open) => emit("openChangeComplete", open)
484
+ }));
485
+ return () => slots.default?.();
486
+ }
487
+ })
488
+ );
489
+ var MenuSubTrigger = withElement(
490
+ "div",
491
+ defineComponent({
492
+ name: "MenuSubTrigger",
493
+ inheritAttrs: false,
494
+ props: { disabled: optionalBoolean },
495
+ slots: Object,
496
+ setup(props) {
497
+ return usePart(menuPrimitive, "trigger", () => ({
498
+ disabled: props.disabled
499
+ }));
500
+ }
501
+ })
502
+ );
503
+ var MenuSubContent = MenuContent;
504
+ var MenuItems = /* @__PURE__ */ renderless(
505
+ defineComponent({
506
+ name: "MenuItems",
507
+ props: {
508
+ items: { type: Array, required: true }
509
+ },
510
+ setup(props) {
511
+ const render = (items) => items.map((entry, index) => {
512
+ const item = typeof entry === "string" ? { value: entry, label: entry } : entry;
513
+ switch (item.type) {
514
+ case void 0:
515
+ case "item":
516
+ return h(
517
+ MenuItem,
518
+ {
519
+ key: item.value,
520
+ value: item.value,
521
+ disabled: item.disabled,
522
+ shortcut: item.shortcut,
523
+ closeOnSelect: item.closeOnSelect,
524
+ destructive: item.destructive
525
+ },
526
+ () => item.label
527
+ );
528
+ case "separator":
529
+ return h(MenuSeparator, { key: `separator-${index}` });
530
+ case "group":
531
+ return h(MenuGroup, { key: `group-${index}` }, () => [
532
+ item.label && h(MenuGroupLabel, null, () => item.label),
533
+ ...render(item.items)
534
+ ]);
535
+ case "checkbox":
536
+ return h(
537
+ MenuCheckboxItem,
538
+ {
539
+ key: item.value,
540
+ value: item.value,
541
+ disabled: item.disabled,
542
+ checked: item.checked,
543
+ defaultChecked: item.defaultChecked,
544
+ closeOnSelect: item.closeOnSelect
545
+ },
546
+ () => item.label
547
+ );
548
+ case "radio-group":
549
+ return h(
550
+ MenuRadioGroup,
551
+ {
552
+ key: item.name,
553
+ name: item.name,
554
+ value: item.value,
555
+ defaultValue: item.defaultValue
556
+ },
557
+ () => [
558
+ item.label && h(MenuGroupLabel, null, () => item.label),
559
+ ...item.items.map(
560
+ (radio) => h(
561
+ MenuRadioItem,
562
+ {
563
+ key: radio.value,
564
+ value: radio.value,
565
+ disabled: radio.disabled
566
+ },
567
+ () => radio.label
568
+ )
569
+ )
570
+ ]
571
+ );
572
+ case "submenu":
573
+ return h(MenuSub, { key: `submenu-${index}` }, () => [
574
+ h(
575
+ MenuSubTrigger,
576
+ { disabled: item.disabled },
577
+ () => item.label
578
+ ),
579
+ h(MenuSubContent, null, () => render(item.items))
580
+ ]);
581
+ }
582
+ });
583
+ return () => render(props.items);
584
+ }
585
+ })
586
+ );
587
+ export {
588
+ Menu,
589
+ MenuCheckboxItem,
590
+ MenuContent,
591
+ MenuContextTrigger,
592
+ MenuGroup,
593
+ MenuGroupLabel,
594
+ MenuItem,
595
+ MenuItemIcon,
596
+ MenuItemIndicator,
597
+ MenuItems,
598
+ MenuRadioGroup,
599
+ MenuRadioItem,
600
+ MenuSeparator,
601
+ MenuShortcut,
602
+ MenuSub,
603
+ MenuSubContent,
604
+ MenuSubTrigger,
605
+ MenuTrigger,
606
+ createMenuController
607
+ };
@@ -0,0 +1,5 @@
1
+ import type { menubar } from "@ui-sdk/core/menubar";
2
+ import type { InjectionKey } from "vue";
3
+ import type { PrimitiveHandle } from "./use-primitive.js";
4
+ declare const MenubarKey: InjectionKey<PrimitiveHandle<typeof menubar> | null>;
5
+ export { MenubarKey };
@@ -0,0 +1,5 @@
1
+ // src/menubar-context.ts
2
+ var MenubarKey = /* @__PURE__ */ Symbol("menubar");
3
+ export {
4
+ MenubarKey
5
+ };
@@ -0,0 +1,61 @@
1
+ import { type MenubarController, type MenubarOrientation } from "@ui-sdk/core/menubar";
2
+ import { type PropType } from "vue";
3
+ import { type PartSlots } from "./use-primitive.js";
4
+ /**
5
+ * A row of menus, like a desktop app's: one tab stop, arrow keys between the
6
+ * triggers and between open menus. Each `Menu` inside joins it.
7
+ * @stable
8
+ */
9
+ declare const Menubar: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
10
+ orientation: PropType<MenubarOrientation>;
11
+ loop: {
12
+ type: BooleanConstructor;
13
+ default: undefined;
14
+ };
15
+ disabled: {
16
+ type: BooleanConstructor;
17
+ default: undefined;
18
+ };
19
+ modal: {
20
+ type: PropType<boolean | "pointer">;
21
+ default: undefined;
22
+ };
23
+ controller: PropType<MenubarController>;
24
+ debug: {
25
+ type: BooleanConstructor;
26
+ default: undefined;
27
+ };
28
+ }>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
29
+ [key: string]: any;
30
+ }> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
31
+ [key: string]: any;
32
+ }>[] | null) & {
33
+ state: NoInfer<import("@ui-sdk/core/menubar").MenubarState>;
34
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
35
+ orientation: PropType<MenubarOrientation>;
36
+ loop: {
37
+ type: BooleanConstructor;
38
+ default: undefined;
39
+ };
40
+ disabled: {
41
+ type: BooleanConstructor;
42
+ default: undefined;
43
+ };
44
+ modal: {
45
+ type: PropType<boolean | "pointer">;
46
+ default: undefined;
47
+ };
48
+ controller: PropType<MenubarController>;
49
+ debug: {
50
+ type: BooleanConstructor;
51
+ default: undefined;
52
+ };
53
+ }>> & Readonly<{}>, {
54
+ disabled: boolean;
55
+ debug: boolean;
56
+ loop: boolean;
57
+ modal: boolean | "pointer";
58
+ }, PartSlots<import("@ui-sdk/core/menubar").MenubarPrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
59
+ export { createMenubarController } from "@ui-sdk/core/menubar";
60
+ export type { MenubarApi, MenubarController, MenubarMember, MenubarOptions, MenubarOrientation, MenubarPrimitive, MenubarState, } from "@ui-sdk/core/menubar";
61
+ export { Menubar };