@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.
- package/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/accordion.d.ts +561 -0
- package/dist/accordion.js +24 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +7 -0
- package/dist/alert-dialog.d.ts +231 -0
- package/dist/alert-dialog.js +33 -0
- package/dist/async-options.d.ts +18 -0
- package/dist/async-options.js +40 -0
- package/dist/autocomplete.d.ts +384 -0
- package/dist/autocomplete.js +344 -0
- package/dist/avatar.d.ts +40 -0
- package/dist/avatar.js +28 -0
- package/dist/button.d.ts +52 -0
- package/dist/button.js +43 -0
- package/dist/calendar-context.d.ts +10 -0
- package/dist/calendar-context.js +7 -0
- package/dist/calendar.d.ts +311 -0
- package/dist/calendar.js +349 -0
- package/dist/carousel.d.ts +236 -0
- package/dist/carousel.js +204 -0
- package/dist/checkbox.d.ts +211 -0
- package/dist/checkbox.js +151 -0
- package/dist/children.d.ts +41 -0
- package/dist/children.js +135 -0
- package/dist/collapsible.d.ts +54 -0
- package/dist/collapsible.js +18 -0
- package/dist/color-picker.d.ts +187 -0
- package/dist/color-picker.js +158 -0
- package/dist/color.d.ts +2 -0
- package/dist/color.js +21 -0
- package/dist/combobox.d.ts +517 -0
- package/dist/combobox.js +531 -0
- package/dist/command.d.ts +322 -0
- package/dist/command.js +345 -0
- package/dist/controller-target.d.ts +49 -0
- package/dist/controller-target.js +112 -0
- package/dist/create-parts.d.ts +126 -0
- package/dist/create-parts.js +206 -0
- package/dist/date-input.d.ts +133 -0
- package/dist/date-input.js +31 -0
- package/dist/date-picker.d.ts +328 -0
- package/dist/date-picker.js +354 -0
- package/dist/date.d.ts +2 -0
- package/dist/date.js +59 -0
- package/dist/dialog-parts.d.ts +259 -0
- package/dist/dialog-parts.js +300 -0
- package/dist/dialog.d.ts +251 -0
- package/dist/dialog.js +25 -0
- package/dist/drawer.d.ts +304 -0
- package/dist/drawer.js +373 -0
- package/dist/editor-context.d.ts +4 -0
- package/dist/editor-context.js +5 -0
- package/dist/field-context.d.ts +26 -0
- package/dist/field-context.js +44 -0
- package/dist/field.d.ts +154 -0
- package/dist/field.js +240 -0
- package/dist/file-input.d.ts +212 -0
- package/dist/file-input.js +255 -0
- package/dist/form-inputs.d.ts +16 -0
- package/dist/form-inputs.js +25 -0
- package/dist/gesture.d.ts +1 -0
- package/dist/gesture.js +15 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +11 -0
- package/dist/hover-card.d.ts +137 -0
- package/dist/hover-card.js +153 -0
- package/dist/image-cropper.d.ts +74 -0
- package/dist/image-cropper.js +36 -0
- package/dist/image.d.ts +2 -0
- package/dist/image.js +5 -0
- package/dist/index.d.ts +59 -0
- package/dist/index.js +60 -0
- package/dist/input.d.ts +120 -0
- package/dist/input.js +73 -0
- package/dist/item-icon.d.ts +34 -0
- package/dist/item-icon.js +63 -0
- package/dist/label.d.ts +16 -0
- package/dist/label.js +8 -0
- package/dist/lifecycle.d.ts +11 -0
- package/dist/lifecycle.js +91 -0
- package/dist/list-items.d.ts +38 -0
- package/dist/list-items.js +59 -0
- package/dist/list-text.d.ts +7 -0
- package/dist/list-text.js +15 -0
- package/dist/listbox.d.ts +273 -0
- package/dist/listbox.js +126 -0
- package/dist/menu.d.ts +678 -0
- package/dist/menu.js +607 -0
- package/dist/menubar-context.d.ts +5 -0
- package/dist/menubar-context.js +5 -0
- package/dist/menubar.d.ts +61 -0
- package/dist/menubar.js +48 -0
- package/dist/meter.d.ts +41 -0
- package/dist/meter.js +37 -0
- package/dist/navigation-menu.d.ts +228 -0
- package/dist/navigation-menu.js +195 -0
- package/dist/number-input.d.ts +176 -0
- package/dist/number-input.js +231 -0
- package/dist/number.d.ts +2 -0
- package/dist/number.js +39 -0
- package/dist/nuxt/entries.json +977 -0
- package/dist/nuxt/module.d.ts +18 -0
- package/dist/nuxt/module.js +31 -0
- package/dist/nuxt/registrations.d.ts +22 -0
- package/dist/nuxt/registrations.js +22 -0
- package/dist/observe.d.ts +2 -0
- package/dist/observe.js +7 -0
- package/dist/otp-input.d.ts +142 -0
- package/dist/otp-input.js +130 -0
- package/dist/overlays.d.ts +40 -0
- package/dist/overlays.js +118 -0
- package/dist/pagination.d.ts +201 -0
- package/dist/pagination.js +146 -0
- package/dist/password-input.d.ts +144 -0
- package/dist/password-input.js +134 -0
- package/dist/popover.d.ts +211 -0
- package/dist/popover.js +258 -0
- package/dist/popup.d.ts +60 -0
- package/dist/popup.js +89 -0
- package/dist/preferences.d.ts +44 -0
- package/dist/preferences.js +102 -0
- package/dist/primitive.d.ts +2 -0
- package/dist/primitive.js +11 -0
- package/dist/progress.d.ts +41 -0
- package/dist/progress.js +37 -0
- package/dist/radio.d.ts +164 -0
- package/dist/radio.js +145 -0
- package/dist/rating.d.ts +149 -0
- package/dist/rating.js +146 -0
- package/dist/renderless.d.ts +4 -0
- package/dist/renderless.js +28 -0
- package/dist/resizable.d.ts +54 -0
- package/dist/resizable.js +22 -0
- package/dist/scroll-area.d.ts +72 -0
- package/dist/scroll-area.js +77 -0
- package/dist/segmented-control.d.ts +151 -0
- package/dist/segmented-control.js +110 -0
- package/dist/segmented-input.d.ts +76 -0
- package/dist/segmented-input.js +115 -0
- package/dist/select.d.ts +458 -0
- package/dist/select.js +468 -0
- package/dist/separator.d.ts +14 -0
- package/dist/separator.js +8 -0
- package/dist/shortcuts.d.ts +32 -0
- package/dist/shortcuts.js +56 -0
- package/dist/slider.d.ts +65 -0
- package/dist/slider.js +194 -0
- package/dist/switch.d.ts +103 -0
- package/dist/switch.js +71 -0
- package/dist/tabs.d.ts +338 -0
- package/dist/tabs.js +27 -0
- package/dist/text-control.d.ts +89 -0
- package/dist/text-control.js +51 -0
- package/dist/text-match.d.ts +2 -0
- package/dist/text-match.js +7 -0
- package/dist/textarea.d.ts +106 -0
- package/dist/textarea.js +68 -0
- package/dist/time-input.d.ts +131 -0
- package/dist/time-input.js +32 -0
- package/dist/timeline.d.ts +81 -0
- package/dist/timeline.js +30 -0
- package/dist/toast-parts.d.ts +203 -0
- package/dist/toast-parts.js +270 -0
- package/dist/toast.d.ts +2 -0
- package/dist/toast.js +21 -0
- package/dist/toggle-props.d.ts +22 -0
- package/dist/toggle-props.js +14 -0
- package/dist/toggle.d.ts +199 -0
- package/dist/toggle.js +129 -0
- package/dist/token-input.d.ts +136 -0
- package/dist/token-input.js +214 -0
- package/dist/toolbar-context.d.ts +7 -0
- package/dist/toolbar-context.js +20 -0
- package/dist/toolbar.d.ts +120 -0
- package/dist/toolbar.js +77 -0
- package/dist/tooltip.d.ts +160 -0
- package/dist/tooltip.js +224 -0
- package/dist/tree.d.ts +300 -0
- package/dist/tree.js +209 -0
- package/dist/trigger-menu.d.ts +452 -0
- package/dist/trigger-menu.js +254 -0
- package/dist/use-primitive.d.ts +132 -0
- package/dist/use-primitive.js +462 -0
- package/dist/waterfall.d.ts +201 -0
- package/dist/waterfall.js +171 -0
- package/docs/README.md +89 -0
- package/docs/agents.md +1523 -0
- package/docs/components/accordion.md +1369 -0
- package/docs/components/alert-dialog.md +799 -0
- package/docs/components/autocomplete.md +1857 -0
- package/docs/components/avatar.md +272 -0
- package/docs/components/button.md +435 -0
- package/docs/components/calendar.md +1589 -0
- package/docs/components/carousel.md +1171 -0
- package/docs/components/checkbox.md +1008 -0
- package/docs/components/collapsible.md +536 -0
- package/docs/components/color-picker.md +706 -0
- package/docs/components/combobox.md +3504 -0
- package/docs/components/command.md +1481 -0
- package/docs/components/date-input.md +536 -0
- package/docs/components/date-picker.md +1244 -0
- package/docs/components/dialog.md +1397 -0
- package/docs/components/drawer.md +1166 -0
- package/docs/components/field.md +538 -0
- package/docs/components/file-input.md +611 -0
- package/docs/components/hover-card.md +505 -0
- package/docs/components/image-cropper.md +556 -0
- package/docs/components/input.md +306 -0
- package/docs/components/label.md +203 -0
- package/docs/components/listbox.md +1004 -0
- package/docs/components/menu.md +1229 -0
- package/docs/components/menubar.md +443 -0
- package/docs/components/meter.md +315 -0
- package/docs/components/navigation-menu.md +1523 -0
- package/docs/components/number-input.md +1029 -0
- package/docs/components/otp-input.md +512 -0
- package/docs/components/pagination.md +613 -0
- package/docs/components/password-input.md +649 -0
- package/docs/components/popover.md +1448 -0
- package/docs/components/preferences.md +208 -0
- package/docs/components/progress.md +423 -0
- package/docs/components/radio.md +785 -0
- package/docs/components/rating.md +416 -0
- package/docs/components/resizable.md +910 -0
- package/docs/components/scroll-area.md +915 -0
- package/docs/components/segmented-control.md +435 -0
- package/docs/components/select.md +2015 -0
- package/docs/components/separator.md +229 -0
- package/docs/components/slider.md +1084 -0
- package/docs/components/switch.md +565 -0
- package/docs/components/tabs.md +944 -0
- package/docs/components/textarea.md +299 -0
- package/docs/components/time-input.md +224 -0
- package/docs/components/timeline.md +654 -0
- package/docs/components/toast.md +1224 -0
- package/docs/components/toggle.md +500 -0
- package/docs/components/token-input.md +953 -0
- package/docs/components/toolbar.md +739 -0
- package/docs/components/tooltip.md +818 -0
- package/docs/components/tree.md +1306 -0
- package/docs/components/trigger-menu.md +1223 -0
- package/docs/components/waterfall.md +717 -0
- package/docs/controllers.md +71 -0
- package/docs/core.md +8027 -0
- package/docs/custom-parts.md +89 -0
- package/docs/first-component.md +83 -0
- package/docs/forms.md +122 -0
- package/docs/installation.md +72 -0
- package/docs/introduction.md +32 -0
- package/docs/lists-and-menus.md +122 -0
- package/docs/llms.txt +1502 -0
- package/docs/parts-and-composition.md +85 -0
- package/docs/popups.md +108 -0
- package/docs/rendering.md +56 -0
- package/docs/server-rendering.md +180 -0
- package/docs/state-and-events.md +100 -0
- package/docs/styling-and-animation.md +148 -0
- package/docs/utilities/async-options.md +348 -0
- package/docs/utilities/shortcuts.md +159 -0
- package/package.json +352 -3
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
// src/combobox.ts
|
|
2
|
+
import {
|
|
3
|
+
combobox as comboboxPrimitive
|
|
4
|
+
} from "@ui-sdk/core/combobox";
|
|
5
|
+
import {
|
|
6
|
+
comboboxChips,
|
|
7
|
+
comboboxCreate,
|
|
8
|
+
comboboxItemIcons,
|
|
9
|
+
comboboxSelectAll,
|
|
10
|
+
selectAllKey
|
|
11
|
+
} from "@ui-sdk/core/renderer";
|
|
12
|
+
import {
|
|
13
|
+
defineComponent,
|
|
14
|
+
h,
|
|
15
|
+
inject,
|
|
16
|
+
provide
|
|
17
|
+
} from "vue";
|
|
18
|
+
import {
|
|
19
|
+
hasChild,
|
|
20
|
+
learnLabels,
|
|
21
|
+
NotPlaced,
|
|
22
|
+
notLabel,
|
|
23
|
+
slotContent,
|
|
24
|
+
usePlaceContent,
|
|
25
|
+
usePlacedContent
|
|
26
|
+
} from "./children.js";
|
|
27
|
+
import { useFieldControl } from "./field-context.js";
|
|
28
|
+
import { defineItemIcon, defineValueIcon } from "./item-icon.js";
|
|
29
|
+
import { markSegments, slotText } from "./list-text.js";
|
|
30
|
+
import {
|
|
31
|
+
containerProp,
|
|
32
|
+
provideSheetHeader,
|
|
33
|
+
renderPopup,
|
|
34
|
+
sheetViewport,
|
|
35
|
+
useControllerEntry,
|
|
36
|
+
useInSheetHeader,
|
|
37
|
+
useSheetHeader
|
|
38
|
+
} from "./popup.js";
|
|
39
|
+
import { ListItems } from "./list-items.js";
|
|
40
|
+
import {
|
|
41
|
+
createParts,
|
|
42
|
+
withElement
|
|
43
|
+
} from "./create-parts.js";
|
|
44
|
+
import {
|
|
45
|
+
defaultSlot,
|
|
46
|
+
optionalBoolean,
|
|
47
|
+
orModel,
|
|
48
|
+
provideProps,
|
|
49
|
+
useHandle,
|
|
50
|
+
usePart,
|
|
51
|
+
usePrimitive,
|
|
52
|
+
useScope
|
|
53
|
+
} from "./use-primitive.js";
|
|
54
|
+
import { FormInputs } from "./form-inputs.js";
|
|
55
|
+
import { renderless } from "./renderless.js";
|
|
56
|
+
import { readOnlyOf } from "./text-control.js";
|
|
57
|
+
import { createComboboxController } from "@ui-sdk/core/combobox";
|
|
58
|
+
var ContainerKey = /* @__PURE__ */ Symbol("combobox-container");
|
|
59
|
+
var useCombobox = () => useHandle(comboboxPrimitive);
|
|
60
|
+
var parts = createParts(comboboxPrimitive, {
|
|
61
|
+
label: "label",
|
|
62
|
+
trigger: "button",
|
|
63
|
+
item: "div",
|
|
64
|
+
"item-indicator": "span",
|
|
65
|
+
group: "div",
|
|
66
|
+
"group-label": "div",
|
|
67
|
+
separator: "div",
|
|
68
|
+
status: "div",
|
|
69
|
+
clear: "button",
|
|
70
|
+
arrow: "div"
|
|
71
|
+
});
|
|
72
|
+
var anyValue = { type: null };
|
|
73
|
+
var Combobox = /* @__PURE__ */ renderless(
|
|
74
|
+
defineComponent({
|
|
75
|
+
name: "Combobox",
|
|
76
|
+
props: {
|
|
77
|
+
value: anyValue,
|
|
78
|
+
modelValue: anyValue,
|
|
79
|
+
defaultValue: anyValue,
|
|
80
|
+
query: { type: String, default: void 0 },
|
|
81
|
+
defaultQuery: { type: String, default: void 0 },
|
|
82
|
+
open: optionalBoolean,
|
|
83
|
+
defaultOpen: optionalBoolean,
|
|
84
|
+
multiple: optionalBoolean,
|
|
85
|
+
maxSelected: Number,
|
|
86
|
+
items: Array,
|
|
87
|
+
emptyItems: Array,
|
|
88
|
+
filter: {
|
|
89
|
+
type: [String, Boolean, Function],
|
|
90
|
+
default: void 0
|
|
91
|
+
},
|
|
92
|
+
announcement: Function,
|
|
93
|
+
itemToValue: Function,
|
|
94
|
+
itemToLabel: Function,
|
|
95
|
+
isItemEqualToValue: Function,
|
|
96
|
+
autoHighlight: {
|
|
97
|
+
type: [Boolean, String],
|
|
98
|
+
default: void 0
|
|
99
|
+
},
|
|
100
|
+
keepQuery: optionalBoolean,
|
|
101
|
+
pendingAnnouncement: String,
|
|
102
|
+
allowCustomValue: optionalBoolean,
|
|
103
|
+
status: String,
|
|
104
|
+
loop: optionalBoolean,
|
|
105
|
+
modal: {
|
|
106
|
+
type: [Boolean, String],
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
presentation: String,
|
|
110
|
+
disabled: optionalBoolean,
|
|
111
|
+
readOnly: optionalBoolean,
|
|
112
|
+
required: optionalBoolean,
|
|
113
|
+
name: String,
|
|
114
|
+
form: String,
|
|
115
|
+
controller: Object,
|
|
116
|
+
dismissible: optionalBoolean,
|
|
117
|
+
debug: optionalBoolean,
|
|
118
|
+
container: containerProp
|
|
119
|
+
},
|
|
120
|
+
emits: {
|
|
121
|
+
"update:value": (_value) => true,
|
|
122
|
+
"update:modelValue": (_value) => true,
|
|
123
|
+
valueChange: (_value, _details) => true,
|
|
124
|
+
"update:query": (_query) => true,
|
|
125
|
+
queryChange: (_query, _details) => true,
|
|
126
|
+
"update:open": (_open) => true,
|
|
127
|
+
openChange: (_open, _details) => true,
|
|
128
|
+
openChangeComplete: (_open) => true,
|
|
129
|
+
dismissAttempt: (_details) => true,
|
|
130
|
+
highlight: (_value, _details) => true,
|
|
131
|
+
loadMore: () => true
|
|
132
|
+
},
|
|
133
|
+
setup(props, { slots, attrs, emit }) {
|
|
134
|
+
const field = useFieldControl();
|
|
135
|
+
provide(ContainerKey, () => props.container);
|
|
136
|
+
const combobox = usePrimitive(comboboxPrimitive, () => ({
|
|
137
|
+
...props,
|
|
138
|
+
value: orModel(props.value, props.modelValue),
|
|
139
|
+
container: void 0,
|
|
140
|
+
name: props.name ?? field?.name(),
|
|
141
|
+
disabled: props.disabled || field?.disabled(),
|
|
142
|
+
readOnly: readOnlyOf(props, attrs),
|
|
143
|
+
onValueChange: (value, details) => {
|
|
144
|
+
emit("valueChange", value, details);
|
|
145
|
+
if (details.canceled) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
emit("update:value", value);
|
|
149
|
+
emit("update:modelValue", value);
|
|
150
|
+
},
|
|
151
|
+
onQueryChange: (query, details) => {
|
|
152
|
+
emit("queryChange", query, details);
|
|
153
|
+
if (!details.canceled) {
|
|
154
|
+
emit("update:query", query);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
onOpenChange: (open, details) => {
|
|
158
|
+
emit("openChange", open, details);
|
|
159
|
+
if (!details.canceled) {
|
|
160
|
+
emit("update:open", open);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
onOpenChangeComplete: (open) => emit("openChangeComplete", open),
|
|
164
|
+
onDismissAttempt: (details) => emit("dismissAttempt", details),
|
|
165
|
+
onHighlight: (value, details) => emit("highlight", value, details),
|
|
166
|
+
onLoadMore: () => emit("loadMore")
|
|
167
|
+
}));
|
|
168
|
+
useControllerEntry(() => props.controller, combobox);
|
|
169
|
+
provideSheetHeader();
|
|
170
|
+
const placed = usePlacedContent();
|
|
171
|
+
return () => {
|
|
172
|
+
const children = slots.default?.() ?? [];
|
|
173
|
+
learnLabels(combobox.api.internal, children, itemDecorations);
|
|
174
|
+
const own = !props.items || placed() || hasChild(children, ComboboxContent);
|
|
175
|
+
return [
|
|
176
|
+
children,
|
|
177
|
+
props.items && !own && h(NotPlaced, () => h(ComboboxContent)),
|
|
178
|
+
h(FormInputs, { handle: combobox })
|
|
179
|
+
];
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
);
|
|
184
|
+
var ComboboxLabel = parts.Label;
|
|
185
|
+
var ComboboxChips = /* @__PURE__ */ withElement(
|
|
186
|
+
"div",
|
|
187
|
+
/* @__PURE__ */ defineComponent({
|
|
188
|
+
name: "ComboboxChips",
|
|
189
|
+
inheritAttrs: false,
|
|
190
|
+
slots: Object,
|
|
191
|
+
setup() {
|
|
192
|
+
const combobox = useCombobox();
|
|
193
|
+
combobox.instance.use(comboboxChips);
|
|
194
|
+
return usePart(combobox, "chips");
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
);
|
|
198
|
+
var ComboboxChipsOverflow = /* @__PURE__ */ withElement(
|
|
199
|
+
"span",
|
|
200
|
+
/* @__PURE__ */ defineComponent({
|
|
201
|
+
name: "ComboboxChipsOverflow",
|
|
202
|
+
inheritAttrs: false,
|
|
203
|
+
slots: Object,
|
|
204
|
+
setup(_, { slots }) {
|
|
205
|
+
const combobox = useCombobox();
|
|
206
|
+
combobox.instance.use(comboboxChips);
|
|
207
|
+
return usePart(combobox, "chips-overflow", void 0, void 0, {
|
|
208
|
+
tag: "span",
|
|
209
|
+
children: (state) => slotContent(slots.default, { state }) ?? `+${state.count} more`
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
);
|
|
214
|
+
var ComboboxInput = withElement(
|
|
215
|
+
"input",
|
|
216
|
+
defineComponent({
|
|
217
|
+
name: "ComboboxInput",
|
|
218
|
+
inheritAttrs: false,
|
|
219
|
+
slots: Object,
|
|
220
|
+
setup(_, { attrs }) {
|
|
221
|
+
const field = useFieldControl(attrs);
|
|
222
|
+
const inHeader = useInSheetHeader();
|
|
223
|
+
const part = usePart(comboboxPrimitive, "input", void 0, void 0, {
|
|
224
|
+
tag: "input",
|
|
225
|
+
extend: field?.props
|
|
226
|
+
});
|
|
227
|
+
return () => {
|
|
228
|
+
const element = part();
|
|
229
|
+
return element && inHeader(element);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
);
|
|
234
|
+
var ComboboxTrigger = parts.Trigger;
|
|
235
|
+
var ComboboxContent = withElement(
|
|
236
|
+
"div",
|
|
237
|
+
defineComponent({
|
|
238
|
+
name: "ComboboxContent",
|
|
239
|
+
inheritAttrs: false,
|
|
240
|
+
props: {
|
|
241
|
+
side: String,
|
|
242
|
+
align: String,
|
|
243
|
+
sideOffset: Number,
|
|
244
|
+
alignOffset: Number,
|
|
245
|
+
collisionPadding: Number,
|
|
246
|
+
arrowPadding: Number,
|
|
247
|
+
anchor: [Object, String],
|
|
248
|
+
keepMounted: optionalBoolean,
|
|
249
|
+
container: containerProp
|
|
250
|
+
},
|
|
251
|
+
slots: Object,
|
|
252
|
+
setup(props, { slots }) {
|
|
253
|
+
usePlaceContent();
|
|
254
|
+
const combobox = useCombobox();
|
|
255
|
+
const inherited = inject(ContainerKey, () => void 0);
|
|
256
|
+
const content = () => {
|
|
257
|
+
const { container, ...content2 } = props;
|
|
258
|
+
return content2;
|
|
259
|
+
};
|
|
260
|
+
const header = useSheetHeader(combobox);
|
|
261
|
+
const part = usePart(combobox, "content", content, void 0, {
|
|
262
|
+
tag: "div",
|
|
263
|
+
children: (state) => [
|
|
264
|
+
header(),
|
|
265
|
+
defaultSlot(
|
|
266
|
+
slots,
|
|
267
|
+
state,
|
|
268
|
+
() => combobox.state.items && h(ComboboxList)
|
|
269
|
+
)
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
return () => {
|
|
273
|
+
const element = part();
|
|
274
|
+
if (!element) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
return renderPopup(
|
|
278
|
+
sheetViewport(combobox, element),
|
|
279
|
+
props.container ?? inherited()
|
|
280
|
+
);
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
var ComboboxList = withElement(
|
|
286
|
+
"div",
|
|
287
|
+
defineComponent({
|
|
288
|
+
name: "ComboboxList",
|
|
289
|
+
inheritAttrs: false,
|
|
290
|
+
slots: Object,
|
|
291
|
+
setup(_, { slots }) {
|
|
292
|
+
const combobox = useCombobox();
|
|
293
|
+
return usePart(combobox, "list", void 0, void 0, {
|
|
294
|
+
tag: "div",
|
|
295
|
+
children: (state) => defaultSlot(
|
|
296
|
+
slots,
|
|
297
|
+
state,
|
|
298
|
+
() => combobox.state.items && h(ComboboxItems, { items: state.items })
|
|
299
|
+
)
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
})
|
|
303
|
+
);
|
|
304
|
+
var ComboboxItem = parts.Item;
|
|
305
|
+
var ComboboxItemIndicator = parts.ItemIndicator;
|
|
306
|
+
var ComboboxItemText = withElement(
|
|
307
|
+
"span",
|
|
308
|
+
defineComponent({
|
|
309
|
+
name: "ComboboxItemText",
|
|
310
|
+
inheritAttrs: false,
|
|
311
|
+
slots: Object,
|
|
312
|
+
setup(_, { slots }) {
|
|
313
|
+
const item = useScope(comboboxPrimitive)?.around.item;
|
|
314
|
+
if (!item) {
|
|
315
|
+
throw new Error(
|
|
316
|
+
"<ComboboxItemText> must be used inside <ComboboxItem>."
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
let text = "";
|
|
320
|
+
let own;
|
|
321
|
+
let ownText;
|
|
322
|
+
const part = usePart(
|
|
323
|
+
comboboxPrimitive,
|
|
324
|
+
"item-text",
|
|
325
|
+
() => ({ id: item().value, text }),
|
|
326
|
+
void 0,
|
|
327
|
+
{
|
|
328
|
+
tag: "span",
|
|
329
|
+
children: (state) => own && ownText === void 0 ? own : markSegments(state.segments)
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
return () => {
|
|
333
|
+
own = slotContent(slots.default, { state: part.state });
|
|
334
|
+
ownText = slotText(own);
|
|
335
|
+
text = ownText ?? (item().label ?? item().value);
|
|
336
|
+
return part();
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
})
|
|
340
|
+
);
|
|
341
|
+
var ComboboxSelectAll = /* @__PURE__ */ withElement(
|
|
342
|
+
"div",
|
|
343
|
+
/* @__PURE__ */ defineComponent({
|
|
344
|
+
name: "ComboboxSelectAll",
|
|
345
|
+
inheritAttrs: false,
|
|
346
|
+
slots: Object,
|
|
347
|
+
setup() {
|
|
348
|
+
const combobox = useCombobox();
|
|
349
|
+
combobox.instance.use(comboboxSelectAll);
|
|
350
|
+
const part = {
|
|
351
|
+
id: selectAllKey(
|
|
352
|
+
useScope(comboboxPrimitive)?.around.group?.().id
|
|
353
|
+
)
|
|
354
|
+
};
|
|
355
|
+
return usePart(combobox, "select-all", () => part);
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
var ComboboxItemIcon = /* @__PURE__ */ notLabel(
|
|
360
|
+
/* @__PURE__ */ defineItemIcon(
|
|
361
|
+
"ComboboxItemIcon",
|
|
362
|
+
comboboxPrimitive,
|
|
363
|
+
"item-icon",
|
|
364
|
+
comboboxItemIcons
|
|
365
|
+
)
|
|
366
|
+
);
|
|
367
|
+
var itemDecorations = /* @__PURE__ */ new Set([ComboboxItemIndicator]);
|
|
368
|
+
var ComboboxValueIcon = /* @__PURE__ */ defineValueIcon(
|
|
369
|
+
"ComboboxValueIcon",
|
|
370
|
+
comboboxPrimitive,
|
|
371
|
+
comboboxItemIcons
|
|
372
|
+
);
|
|
373
|
+
var ComboboxGroup = parts.Group;
|
|
374
|
+
var ComboboxGroupLabel = parts.GroupLabel;
|
|
375
|
+
var ComboboxSeparator = parts.Separator;
|
|
376
|
+
var ComboboxCreate = /* @__PURE__ */ (() => withElement(
|
|
377
|
+
"div",
|
|
378
|
+
defineComponent({
|
|
379
|
+
name: "ComboboxCreate",
|
|
380
|
+
inheritAttrs: false,
|
|
381
|
+
props: {
|
|
382
|
+
// A function prop beside the emit, so a returned Promise marks the option pending.
|
|
383
|
+
onCreate: Function,
|
|
384
|
+
minLength: Number
|
|
385
|
+
},
|
|
386
|
+
slots: Object,
|
|
387
|
+
setup(props, { slots }) {
|
|
388
|
+
const combobox = useCombobox();
|
|
389
|
+
combobox.instance.use(comboboxCreate);
|
|
390
|
+
const part = () => ({
|
|
391
|
+
onCreate: props.onCreate,
|
|
392
|
+
minLength: props.minLength
|
|
393
|
+
});
|
|
394
|
+
return usePart(combobox, "create", part, void 0, {
|
|
395
|
+
tag: "div",
|
|
396
|
+
children: (state) => slotContent(slots.default, { state }) ?? `Create \u201C${state.query}\u201D`
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
})
|
|
400
|
+
))();
|
|
401
|
+
var ComboboxEmpty = withElement(
|
|
402
|
+
"div",
|
|
403
|
+
defineComponent({
|
|
404
|
+
name: "ComboboxEmpty",
|
|
405
|
+
inheritAttrs: false,
|
|
406
|
+
slots: Object,
|
|
407
|
+
setup(_, { slots }) {
|
|
408
|
+
return usePart(comboboxPrimitive, "empty", void 0, void 0, {
|
|
409
|
+
tag: "div",
|
|
410
|
+
children: (state) => state.empty ? slots.default?.({ state }) : null
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
var ComboboxStatus = parts.Status;
|
|
416
|
+
var ComboboxClear = parts.Clear;
|
|
417
|
+
var ComboboxValue = /* @__PURE__ */ renderless(
|
|
418
|
+
defineComponent({
|
|
419
|
+
name: "ComboboxValue",
|
|
420
|
+
props: {
|
|
421
|
+
maxLabels: Number,
|
|
422
|
+
getMoreLabel: Function
|
|
423
|
+
},
|
|
424
|
+
slots: Object,
|
|
425
|
+
setup(props, { slots }) {
|
|
426
|
+
const { state } = usePart(comboboxPrimitive, "value", () => ({
|
|
427
|
+
maxLabels: props.maxLabels,
|
|
428
|
+
getMoreLabel: props.getMoreLabel
|
|
429
|
+
}));
|
|
430
|
+
return () => slotContent(slots.default, { state, value: state.value }) ?? (state.label || null);
|
|
431
|
+
}
|
|
432
|
+
})
|
|
433
|
+
);
|
|
434
|
+
var ComboboxChip = /* @__PURE__ */ (() => withElement(
|
|
435
|
+
"div",
|
|
436
|
+
defineComponent({
|
|
437
|
+
name: "ComboboxChip",
|
|
438
|
+
inheritAttrs: false,
|
|
439
|
+
props: {
|
|
440
|
+
value: { type: null, required: true }
|
|
441
|
+
},
|
|
442
|
+
slots: Object,
|
|
443
|
+
setup(props, { slots }) {
|
|
444
|
+
const combobox = useCombobox();
|
|
445
|
+
combobox.instance.use(comboboxChips);
|
|
446
|
+
provideProps(comboboxPrimitive, "chip", () => ({ value: props.value }));
|
|
447
|
+
const part = () => ({
|
|
448
|
+
id: combobox.api.internal.keyOf(props.value),
|
|
449
|
+
value: props.value
|
|
450
|
+
});
|
|
451
|
+
return usePart(combobox, "chip", part, void 0, {
|
|
452
|
+
tag: "div",
|
|
453
|
+
children: (state) => slotContent(slots.default, { state }) ?? state.label
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
))();
|
|
458
|
+
var ComboboxChipRemove = /* @__PURE__ */ withElement(
|
|
459
|
+
"button",
|
|
460
|
+
/* @__PURE__ */ defineComponent({
|
|
461
|
+
name: "ComboboxChipRemove",
|
|
462
|
+
inheritAttrs: false,
|
|
463
|
+
slots: Object,
|
|
464
|
+
setup() {
|
|
465
|
+
const combobox = useCombobox();
|
|
466
|
+
combobox.instance.use(comboboxChips);
|
|
467
|
+
const chip = useScope(comboboxPrimitive)?.around.chip;
|
|
468
|
+
if (!chip) {
|
|
469
|
+
throw new Error(
|
|
470
|
+
"<ComboboxChipRemove> must be used inside <ComboboxChip>."
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
const value = () => chip().value;
|
|
474
|
+
const part = () => ({
|
|
475
|
+
id: combobox.api.internal.keyOf(value()),
|
|
476
|
+
value: value()
|
|
477
|
+
});
|
|
478
|
+
return usePart(combobox, "chip-remove", part, void 0, "button");
|
|
479
|
+
}
|
|
480
|
+
})
|
|
481
|
+
);
|
|
482
|
+
var ComboboxArrow = parts.Arrow;
|
|
483
|
+
var ComboboxItems = defineComponent({
|
|
484
|
+
name: "ComboboxItems",
|
|
485
|
+
props: {
|
|
486
|
+
items: { type: Array, required: true }
|
|
487
|
+
},
|
|
488
|
+
setup(props) {
|
|
489
|
+
const combobox = useCombobox();
|
|
490
|
+
return () => h(ListItems, {
|
|
491
|
+
items: props.items,
|
|
492
|
+
parts: listParts,
|
|
493
|
+
keyOf: combobox.api.internal.keyOf
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
var listParts = {
|
|
498
|
+
Item: ComboboxItem,
|
|
499
|
+
Group: ComboboxGroup,
|
|
500
|
+
GroupLabel: ComboboxGroupLabel,
|
|
501
|
+
Separator: ComboboxSeparator
|
|
502
|
+
};
|
|
503
|
+
export {
|
|
504
|
+
Combobox,
|
|
505
|
+
ComboboxArrow,
|
|
506
|
+
ComboboxChip,
|
|
507
|
+
ComboboxChipRemove,
|
|
508
|
+
ComboboxChips,
|
|
509
|
+
ComboboxChipsOverflow,
|
|
510
|
+
ComboboxClear,
|
|
511
|
+
ComboboxContent,
|
|
512
|
+
ComboboxCreate,
|
|
513
|
+
ComboboxEmpty,
|
|
514
|
+
ComboboxGroup,
|
|
515
|
+
ComboboxGroupLabel,
|
|
516
|
+
ComboboxInput,
|
|
517
|
+
ComboboxItem,
|
|
518
|
+
ComboboxItemIcon,
|
|
519
|
+
ComboboxItemIndicator,
|
|
520
|
+
ComboboxItemText,
|
|
521
|
+
ComboboxItems,
|
|
522
|
+
ComboboxLabel,
|
|
523
|
+
ComboboxList,
|
|
524
|
+
ComboboxSelectAll,
|
|
525
|
+
ComboboxSeparator,
|
|
526
|
+
ComboboxStatus,
|
|
527
|
+
ComboboxTrigger,
|
|
528
|
+
ComboboxValue,
|
|
529
|
+
ComboboxValueIcon,
|
|
530
|
+
createComboboxController
|
|
531
|
+
};
|