@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/select.js
ADDED
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
// src/select.ts
|
|
2
|
+
import {
|
|
3
|
+
selectAllKey,
|
|
4
|
+
selectItemIcons,
|
|
5
|
+
selectSelectAll
|
|
6
|
+
} from "@ui-sdk/core/renderer";
|
|
7
|
+
import {
|
|
8
|
+
select as selectPrimitive
|
|
9
|
+
} from "@ui-sdk/core/select";
|
|
10
|
+
import {
|
|
11
|
+
defineComponent,
|
|
12
|
+
h,
|
|
13
|
+
inject,
|
|
14
|
+
provide
|
|
15
|
+
} from "vue";
|
|
16
|
+
import {
|
|
17
|
+
hasChild,
|
|
18
|
+
learnLabels,
|
|
19
|
+
NotPlaced,
|
|
20
|
+
notLabel,
|
|
21
|
+
slotContent,
|
|
22
|
+
usePlaceContent,
|
|
23
|
+
usePlacedContent
|
|
24
|
+
} from "./children.js";
|
|
25
|
+
import { useFieldControl } from "./field-context.js";
|
|
26
|
+
import { defineItemIcon, defineValueIcon } from "./item-icon.js";
|
|
27
|
+
import { ListItems } from "./list-items.js";
|
|
28
|
+
import { markSegments, slotText } from "./list-text.js";
|
|
29
|
+
import {
|
|
30
|
+
containerProp,
|
|
31
|
+
provideConnected,
|
|
32
|
+
renderPopup,
|
|
33
|
+
renderUnbound,
|
|
34
|
+
useConnectedHandle,
|
|
35
|
+
useConnectedPart,
|
|
36
|
+
sheetViewport,
|
|
37
|
+
useControllerTarget,
|
|
38
|
+
useControllerEntry
|
|
39
|
+
} from "./popup.js";
|
|
40
|
+
import {
|
|
41
|
+
createParts,
|
|
42
|
+
withElement
|
|
43
|
+
} from "./create-parts.js";
|
|
44
|
+
import {
|
|
45
|
+
defaultSlot,
|
|
46
|
+
optionalBoolean,
|
|
47
|
+
orModel,
|
|
48
|
+
useHandle,
|
|
49
|
+
usePart,
|
|
50
|
+
usePrimitive,
|
|
51
|
+
useScope
|
|
52
|
+
} from "./use-primitive.js";
|
|
53
|
+
import { FormInputs } from "./form-inputs.js";
|
|
54
|
+
import { renderless } from "./renderless.js";
|
|
55
|
+
import { readOnlyOf } from "./text-control.js";
|
|
56
|
+
import { createSelectController } from "@ui-sdk/core/select";
|
|
57
|
+
var ContainerKey = /* @__PURE__ */ Symbol("select-container");
|
|
58
|
+
var useSelect = () => useHandle(selectPrimitive);
|
|
59
|
+
var parts = createParts(selectPrimitive, {
|
|
60
|
+
label: "div",
|
|
61
|
+
input: "input",
|
|
62
|
+
status: "div",
|
|
63
|
+
item: "div",
|
|
64
|
+
"item-indicator": "span",
|
|
65
|
+
group: "div",
|
|
66
|
+
"group-label": "div",
|
|
67
|
+
separator: "div",
|
|
68
|
+
clear: "button",
|
|
69
|
+
arrow: "div"
|
|
70
|
+
});
|
|
71
|
+
var anyValue = { type: null };
|
|
72
|
+
var Select = /* @__PURE__ */ renderless(
|
|
73
|
+
defineComponent({
|
|
74
|
+
name: "Select",
|
|
75
|
+
props: {
|
|
76
|
+
value: anyValue,
|
|
77
|
+
modelValue: anyValue,
|
|
78
|
+
defaultValue: anyValue,
|
|
79
|
+
open: optionalBoolean,
|
|
80
|
+
defaultOpen: optionalBoolean,
|
|
81
|
+
multiple: optionalBoolean,
|
|
82
|
+
items: Array,
|
|
83
|
+
emptyItems: Array,
|
|
84
|
+
query: { type: String, default: void 0 },
|
|
85
|
+
defaultQuery: String,
|
|
86
|
+
filter: {
|
|
87
|
+
type: [String, Boolean, Function],
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
status: String,
|
|
91
|
+
announcement: Function,
|
|
92
|
+
placeholder: String,
|
|
93
|
+
itemToValue: Function,
|
|
94
|
+
itemToLabel: Function,
|
|
95
|
+
isItemEqualToValue: Function,
|
|
96
|
+
loop: optionalBoolean,
|
|
97
|
+
modal: {
|
|
98
|
+
type: [Boolean, String],
|
|
99
|
+
default: void 0
|
|
100
|
+
},
|
|
101
|
+
presentation: String,
|
|
102
|
+
disabled: optionalBoolean,
|
|
103
|
+
readOnly: optionalBoolean,
|
|
104
|
+
required: optionalBoolean,
|
|
105
|
+
name: String,
|
|
106
|
+
form: String,
|
|
107
|
+
autoComplete: String,
|
|
108
|
+
controller: Object,
|
|
109
|
+
dismissible: optionalBoolean,
|
|
110
|
+
debug: optionalBoolean,
|
|
111
|
+
container: containerProp
|
|
112
|
+
},
|
|
113
|
+
emits: {
|
|
114
|
+
"update:value": (_value) => true,
|
|
115
|
+
"update:modelValue": (_value) => true,
|
|
116
|
+
valueChange: (_value, _details) => true,
|
|
117
|
+
"update:open": (_open) => true,
|
|
118
|
+
openChange: (_open, _details) => true,
|
|
119
|
+
openChangeComplete: (_open) => true,
|
|
120
|
+
dismissAttempt: (_details) => true,
|
|
121
|
+
highlight: (_value, _details) => true,
|
|
122
|
+
"update:query": (_query) => true,
|
|
123
|
+
queryChange: (_query, _details) => true,
|
|
124
|
+
loadMore: () => true
|
|
125
|
+
},
|
|
126
|
+
setup(props, { slots, attrs, emit }) {
|
|
127
|
+
const field = useFieldControl();
|
|
128
|
+
provide(ContainerKey, () => props.container);
|
|
129
|
+
const select = usePrimitive(selectPrimitive, () => ({
|
|
130
|
+
...props,
|
|
131
|
+
value: orModel(props.value, props.modelValue),
|
|
132
|
+
container: void 0,
|
|
133
|
+
name: props.name ?? field?.name(),
|
|
134
|
+
disabled: props.disabled || field?.disabled(),
|
|
135
|
+
readOnly: readOnlyOf(props, attrs),
|
|
136
|
+
onValueChange: (value, details) => {
|
|
137
|
+
emit("valueChange", value, details);
|
|
138
|
+
if (details.canceled) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
emit("update:value", value);
|
|
142
|
+
emit("update:modelValue", value);
|
|
143
|
+
},
|
|
144
|
+
onOpenChange: (open, details) => {
|
|
145
|
+
emit("openChange", open, details);
|
|
146
|
+
if (!details.canceled) {
|
|
147
|
+
emit("update:open", open);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
onOpenChangeComplete: (open) => emit("openChangeComplete", open),
|
|
151
|
+
onDismissAttempt: (details) => emit("dismissAttempt", details),
|
|
152
|
+
onHighlight: (value, details) => emit("highlight", value, details),
|
|
153
|
+
onQueryChange: (query, details) => {
|
|
154
|
+
emit("queryChange", query, details);
|
|
155
|
+
if (!details.canceled) {
|
|
156
|
+
emit("update:query", query);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
onLoadMore: () => emit("loadMore")
|
|
160
|
+
}));
|
|
161
|
+
useControllerEntry(() => props.controller, select);
|
|
162
|
+
const placed = usePlacedContent();
|
|
163
|
+
return () => {
|
|
164
|
+
const children = slots.default?.() ?? [];
|
|
165
|
+
learnLabels(select.api.internal, children, itemDecorations);
|
|
166
|
+
const own = !props.items || placed() || hasChild(children, SelectContent);
|
|
167
|
+
return [
|
|
168
|
+
children,
|
|
169
|
+
props.items && !own && h(NotPlaced, () => h(SelectContent)),
|
|
170
|
+
h(FormInputs, { handle: select })
|
|
171
|
+
];
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
var SelectLabel = parts.Label;
|
|
177
|
+
var SelectTrigger = withElement(
|
|
178
|
+
"button",
|
|
179
|
+
defineComponent({
|
|
180
|
+
name: "SelectTrigger",
|
|
181
|
+
inheritAttrs: false,
|
|
182
|
+
props: {
|
|
183
|
+
disabled: optionalBoolean,
|
|
184
|
+
// Connects a trigger outside the select to the select with this controller.
|
|
185
|
+
controller: Object
|
|
186
|
+
},
|
|
187
|
+
slots: Object,
|
|
188
|
+
setup(props, { slots, attrs }) {
|
|
189
|
+
const connected = useControllerTarget(
|
|
190
|
+
selectPrimitive,
|
|
191
|
+
() => props.controller
|
|
192
|
+
);
|
|
193
|
+
provideConnected(selectPrimitive, connected);
|
|
194
|
+
const field = useFieldControl(attrs);
|
|
195
|
+
return useConnectedPart(
|
|
196
|
+
connected,
|
|
197
|
+
(select) => usePart(
|
|
198
|
+
select,
|
|
199
|
+
"trigger",
|
|
200
|
+
() => ({
|
|
201
|
+
disabled: props.disabled,
|
|
202
|
+
named: !!field || attrs["aria-labelledby"] != null
|
|
203
|
+
}),
|
|
204
|
+
void 0,
|
|
205
|
+
{
|
|
206
|
+
tag: "button",
|
|
207
|
+
// Its content, or without any, the value.
|
|
208
|
+
children: (state) => slotContent(slots.default, { state }) ?? h(SelectValue),
|
|
209
|
+
extend: field?.props
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
// Until its select mounts, a trigger outside it is a plain button.
|
|
213
|
+
() => {
|
|
214
|
+
const state = {
|
|
215
|
+
open: false,
|
|
216
|
+
disabled: !!props.disabled,
|
|
217
|
+
readOnly: false,
|
|
218
|
+
required: false,
|
|
219
|
+
placeholder: true
|
|
220
|
+
};
|
|
221
|
+
return renderUnbound(
|
|
222
|
+
"button",
|
|
223
|
+
{ type: "button", ...attrs },
|
|
224
|
+
{ slots, state }
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
var unselected = {
|
|
232
|
+
value: null,
|
|
233
|
+
label: "",
|
|
234
|
+
labels: [],
|
|
235
|
+
placeholder: true
|
|
236
|
+
};
|
|
237
|
+
var SelectValue = withElement(
|
|
238
|
+
"span",
|
|
239
|
+
defineComponent({
|
|
240
|
+
name: "SelectValue",
|
|
241
|
+
inheritAttrs: false,
|
|
242
|
+
props: {
|
|
243
|
+
placeholder: String,
|
|
244
|
+
maxLabels: Number,
|
|
245
|
+
getMoreLabel: Function
|
|
246
|
+
},
|
|
247
|
+
slots: Object,
|
|
248
|
+
setup(props, { slots, attrs }) {
|
|
249
|
+
const part = () => ({
|
|
250
|
+
placeholder: props.placeholder,
|
|
251
|
+
maxLabels: props.maxLabels,
|
|
252
|
+
getMoreLabel: props.getMoreLabel
|
|
253
|
+
});
|
|
254
|
+
const content = (state, placeholder) => slotContent(slots.default, { state }) ?? (state.placeholder ? props.placeholder ?? placeholder ?? "" : state.label);
|
|
255
|
+
return useConnectedPart(
|
|
256
|
+
useConnectedHandle(selectPrimitive),
|
|
257
|
+
(select) => usePart(select, "value", part, void 0, {
|
|
258
|
+
tag: "span",
|
|
259
|
+
children: (state) => content(state, select.state.placeholder)
|
|
260
|
+
}),
|
|
261
|
+
// Inside a trigger outside its select, the placeholder until the select mounts.
|
|
262
|
+
() => renderUnbound("span", attrs, {
|
|
263
|
+
slots,
|
|
264
|
+
state: unselected,
|
|
265
|
+
children: content
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
);
|
|
271
|
+
var SelectContent = withElement(
|
|
272
|
+
"div",
|
|
273
|
+
defineComponent({
|
|
274
|
+
name: "SelectContent",
|
|
275
|
+
inheritAttrs: false,
|
|
276
|
+
props: {
|
|
277
|
+
side: String,
|
|
278
|
+
align: String,
|
|
279
|
+
sideOffset: Number,
|
|
280
|
+
alignOffset: Number,
|
|
281
|
+
collisionPadding: Number,
|
|
282
|
+
arrowPadding: Number,
|
|
283
|
+
anchor: [Object, String],
|
|
284
|
+
alignItemWithTrigger: optionalBoolean,
|
|
285
|
+
keepMounted: optionalBoolean,
|
|
286
|
+
container: containerProp
|
|
287
|
+
},
|
|
288
|
+
slots: Object,
|
|
289
|
+
setup(props, { slots }) {
|
|
290
|
+
usePlaceContent();
|
|
291
|
+
const select = useSelect();
|
|
292
|
+
const inherited = inject(ContainerKey, () => void 0);
|
|
293
|
+
const content = () => {
|
|
294
|
+
const { container, ...content2 } = props;
|
|
295
|
+
return content2;
|
|
296
|
+
};
|
|
297
|
+
const part = usePart(select, "content", content, void 0, {
|
|
298
|
+
tag: "div",
|
|
299
|
+
children: (state) => defaultSlot(
|
|
300
|
+
slots,
|
|
301
|
+
state,
|
|
302
|
+
() => select.state.items && h(SelectItems, { items: state.items })
|
|
303
|
+
)
|
|
304
|
+
});
|
|
305
|
+
return () => {
|
|
306
|
+
const element = part();
|
|
307
|
+
if (!element) {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
return renderPopup(
|
|
311
|
+
sheetViewport(select, element),
|
|
312
|
+
props.container ?? inherited()
|
|
313
|
+
);
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
var SelectList = withElement(
|
|
319
|
+
"div",
|
|
320
|
+
defineComponent({
|
|
321
|
+
name: "SelectList",
|
|
322
|
+
inheritAttrs: false,
|
|
323
|
+
slots: Object,
|
|
324
|
+
setup(_, { slots }) {
|
|
325
|
+
const select = useSelect();
|
|
326
|
+
return usePart(select, "list", void 0, void 0, {
|
|
327
|
+
tag: "div",
|
|
328
|
+
children: (state) => defaultSlot(
|
|
329
|
+
slots,
|
|
330
|
+
state,
|
|
331
|
+
() => select.state.items && h(SelectItems, { items: state.items })
|
|
332
|
+
)
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
var SelectInput = parts.Input;
|
|
338
|
+
var SelectEmpty = withElement(
|
|
339
|
+
"div",
|
|
340
|
+
defineComponent({
|
|
341
|
+
name: "SelectEmpty",
|
|
342
|
+
inheritAttrs: false,
|
|
343
|
+
slots: Object,
|
|
344
|
+
setup(_, { slots }) {
|
|
345
|
+
return usePart(selectPrimitive, "empty", void 0, void 0, {
|
|
346
|
+
tag: "div",
|
|
347
|
+
children: (state) => state.empty ? slots.default?.({ state }) : null
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
})
|
|
351
|
+
);
|
|
352
|
+
var SelectStatus = parts.Status;
|
|
353
|
+
var SelectItem = parts.Item;
|
|
354
|
+
var SelectItemIndicator = parts.ItemIndicator;
|
|
355
|
+
var SelectItemText = withElement(
|
|
356
|
+
"span",
|
|
357
|
+
defineComponent({
|
|
358
|
+
name: "SelectItemText",
|
|
359
|
+
inheritAttrs: false,
|
|
360
|
+
slots: Object,
|
|
361
|
+
setup(_, { slots }) {
|
|
362
|
+
const item = useScope(selectPrimitive)?.around.item;
|
|
363
|
+
if (!item) {
|
|
364
|
+
throw new Error("<SelectItemText> must be used inside <SelectItem>.");
|
|
365
|
+
}
|
|
366
|
+
let text = "";
|
|
367
|
+
let own;
|
|
368
|
+
let ownText;
|
|
369
|
+
const part = usePart(
|
|
370
|
+
selectPrimitive,
|
|
371
|
+
"item-text",
|
|
372
|
+
() => ({ id: item().value, text }),
|
|
373
|
+
void 0,
|
|
374
|
+
{
|
|
375
|
+
tag: "span",
|
|
376
|
+
children: (state) => own && ownText === void 0 ? own : markSegments(state.segments)
|
|
377
|
+
}
|
|
378
|
+
);
|
|
379
|
+
return () => {
|
|
380
|
+
own = slotContent(slots.default, { state: part.state });
|
|
381
|
+
ownText = slotText(own);
|
|
382
|
+
text = ownText ?? (item().label ?? item().value);
|
|
383
|
+
return part();
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
var SelectSelectAll = /* @__PURE__ */ withElement(
|
|
389
|
+
"div",
|
|
390
|
+
/* @__PURE__ */ defineComponent({
|
|
391
|
+
name: "SelectSelectAll",
|
|
392
|
+
inheritAttrs: false,
|
|
393
|
+
slots: Object,
|
|
394
|
+
setup() {
|
|
395
|
+
const select = useSelect();
|
|
396
|
+
select.instance.use(selectSelectAll);
|
|
397
|
+
const part = {
|
|
398
|
+
id: selectAllKey(
|
|
399
|
+
useScope(selectPrimitive)?.around.group?.().id
|
|
400
|
+
)
|
|
401
|
+
};
|
|
402
|
+
return usePart(select, "select-all", () => part);
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
);
|
|
406
|
+
var SelectItemIcon = /* @__PURE__ */ notLabel(
|
|
407
|
+
/* @__PURE__ */ defineItemIcon(
|
|
408
|
+
"SelectItemIcon",
|
|
409
|
+
selectPrimitive,
|
|
410
|
+
"item-icon",
|
|
411
|
+
selectItemIcons
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
var itemDecorations = /* @__PURE__ */ new Set([SelectItemIndicator]);
|
|
415
|
+
var SelectValueIcon = /* @__PURE__ */ defineValueIcon(
|
|
416
|
+
"SelectValueIcon",
|
|
417
|
+
selectPrimitive,
|
|
418
|
+
selectItemIcons
|
|
419
|
+
);
|
|
420
|
+
var SelectGroup = parts.Group;
|
|
421
|
+
var SelectGroupLabel = parts.GroupLabel;
|
|
422
|
+
var SelectSeparator = parts.Separator;
|
|
423
|
+
var SelectClear = parts.Clear;
|
|
424
|
+
var SelectArrow = parts.Arrow;
|
|
425
|
+
var SelectItems = defineComponent({
|
|
426
|
+
name: "SelectItems",
|
|
427
|
+
props: {
|
|
428
|
+
items: { type: Array, required: true }
|
|
429
|
+
},
|
|
430
|
+
setup(props) {
|
|
431
|
+
const select = useSelect();
|
|
432
|
+
return () => h(ListItems, {
|
|
433
|
+
items: props.items,
|
|
434
|
+
parts: listParts,
|
|
435
|
+
keyOf: select.api.internal.keyOf
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
var listParts = {
|
|
440
|
+
Item: SelectItem,
|
|
441
|
+
Group: SelectGroup,
|
|
442
|
+
GroupLabel: SelectGroupLabel,
|
|
443
|
+
Separator: SelectSeparator
|
|
444
|
+
};
|
|
445
|
+
export {
|
|
446
|
+
Select,
|
|
447
|
+
SelectArrow,
|
|
448
|
+
SelectClear,
|
|
449
|
+
SelectContent,
|
|
450
|
+
SelectEmpty,
|
|
451
|
+
SelectGroup,
|
|
452
|
+
SelectGroupLabel,
|
|
453
|
+
SelectInput,
|
|
454
|
+
SelectItem,
|
|
455
|
+
SelectItemIcon,
|
|
456
|
+
SelectItemIndicator,
|
|
457
|
+
SelectItemText,
|
|
458
|
+
SelectItems,
|
|
459
|
+
SelectLabel,
|
|
460
|
+
SelectList,
|
|
461
|
+
SelectSelectAll,
|
|
462
|
+
SelectSeparator,
|
|
463
|
+
SelectStatus,
|
|
464
|
+
SelectTrigger,
|
|
465
|
+
SelectValue,
|
|
466
|
+
SelectValueIcon,
|
|
467
|
+
createSelectController
|
|
468
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A line between groups of content, announced as a separator unless it's `decorative`.
|
|
3
|
+
* @stable
|
|
4
|
+
*/
|
|
5
|
+
declare const Separator: import("./create-parts.js").ElementPart<new (props: Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/separator").SeparatorPrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, never> & {} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) => import("vue").CreateComponentPublicInstanceWithMixins<Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/separator").SeparatorPrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, never> & {}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {}, import("vue").PublicProps, {}, false, {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/separator").SeparatorState>>, {}, {}, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
6
|
+
P: {};
|
|
7
|
+
B: {};
|
|
8
|
+
D: {};
|
|
9
|
+
C: {};
|
|
10
|
+
M: {};
|
|
11
|
+
Defaults: {};
|
|
12
|
+
}, Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/separator").SeparatorPrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, never> & {}, {}, {}, {}, {}, {}>, "div">;
|
|
13
|
+
export { Separator };
|
|
14
|
+
export type { SeparatorOptions, SeparatorOrientation, SeparatorPrimitive, SeparatorState, } from "@ui-sdk/core/separator";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ShortcutHandler, type ShortcutOptions } from "@ui-sdk/core/shortcuts";
|
|
2
|
+
import { type MaybeRefOrGetter } from "vue";
|
|
3
|
+
/**
|
|
4
|
+
* Options for `useShortcut`. `layer` also takes a template ref.
|
|
5
|
+
* @stable
|
|
6
|
+
*/
|
|
7
|
+
type UseShortcutOptions = Omit<ShortcutOptions, "layer"> & {
|
|
8
|
+
/** An element inside a popup, a ref or a getter of one. The shortcut belongs to that popup. */
|
|
9
|
+
layer?: MaybeRefOrGetter<Element | null | undefined>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Registers a keyboard shortcut for the life of the component, in the shared
|
|
13
|
+
* `shortcuts`. Keys can be a ref or a getter, and nothing registers for `null`.
|
|
14
|
+
* Options can be a ref or a getter too, like `() => ({ scope: props.scope })`,
|
|
15
|
+
* and it registers again when they change.
|
|
16
|
+
* @stable
|
|
17
|
+
*/
|
|
18
|
+
declare function useShortcut(keys: MaybeRefOrGetter<string | null | undefined>, handler: ShortcutHandler, options?: MaybeRefOrGetter<UseShortcutOptions>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Keys formatted for this platform, like `⌘S` on Apple platforms and `Ctrl+S`
|
|
21
|
+
* elsewhere, with the matching `aria-keyshortcuts`, as computed refs. The
|
|
22
|
+
* server and the first client render use the same platform, so hydration
|
|
23
|
+
* matches, and they update after mount. Keys can be a ref or a getter.
|
|
24
|
+
* @stable
|
|
25
|
+
*/
|
|
26
|
+
declare function useShortcutHint(keys: MaybeRefOrGetter<string>): {
|
|
27
|
+
text: import("vue").ComputedRef<string>;
|
|
28
|
+
ariaKeyshortcuts: import("vue").ComputedRef<string>;
|
|
29
|
+
};
|
|
30
|
+
export { ariaKeyshortcuts, formatShortcut, registerShortcut, shortcuts, } from "@ui-sdk/core/shortcuts";
|
|
31
|
+
export type { ShortcutHandler, ShortcutInfo, ShortcutKeys, ShortcutOptions, Shortcuts, } from "@ui-sdk/core/shortcuts";
|
|
32
|
+
export { useShortcut, useShortcutHint, type UseShortcutOptions };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/shortcuts.ts
|
|
2
|
+
import { initialApple, isApple } from "@ui-sdk/core/renderer";
|
|
3
|
+
import {
|
|
4
|
+
ariaKeyshortcuts,
|
|
5
|
+
formatShortcut,
|
|
6
|
+
shortcuts
|
|
7
|
+
} from "@ui-sdk/core/shortcuts";
|
|
8
|
+
import {
|
|
9
|
+
computed,
|
|
10
|
+
onMounted,
|
|
11
|
+
onScopeDispose,
|
|
12
|
+
shallowRef,
|
|
13
|
+
toValue,
|
|
14
|
+
watchEffect
|
|
15
|
+
} from "vue";
|
|
16
|
+
import {
|
|
17
|
+
ariaKeyshortcuts as ariaKeyshortcuts2,
|
|
18
|
+
formatShortcut as formatShortcut2,
|
|
19
|
+
registerShortcut,
|
|
20
|
+
shortcuts as shortcuts2
|
|
21
|
+
} from "@ui-sdk/core/shortcuts";
|
|
22
|
+
function useShortcut(keys, handler, options = {}) {
|
|
23
|
+
let off;
|
|
24
|
+
watchEffect(() => {
|
|
25
|
+
off?.();
|
|
26
|
+
off = void 0;
|
|
27
|
+
const current = toValue(keys);
|
|
28
|
+
if (!current || typeof document === "undefined") {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { layer, ...rest } = toValue(options);
|
|
32
|
+
off = shortcuts.register(current, handler, {
|
|
33
|
+
...rest,
|
|
34
|
+
layer: layer === void 0 ? void 0 : () => toValue(layer)
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
onScopeDispose(() => off?.());
|
|
38
|
+
}
|
|
39
|
+
function useShortcutHint(keys) {
|
|
40
|
+
const apple = shallowRef(initialApple());
|
|
41
|
+
onMounted(() => apple.value = isApple());
|
|
42
|
+
return {
|
|
43
|
+
text: computed(() => formatShortcut(toValue(keys), apple.value)),
|
|
44
|
+
ariaKeyshortcuts: computed(
|
|
45
|
+
() => ariaKeyshortcuts(toValue(keys), apple.value)
|
|
46
|
+
)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
ariaKeyshortcuts2 as ariaKeyshortcuts,
|
|
51
|
+
formatShortcut2 as formatShortcut,
|
|
52
|
+
registerShortcut,
|
|
53
|
+
shortcuts2 as shortcuts,
|
|
54
|
+
useShortcut,
|
|
55
|
+
useShortcutHint
|
|
56
|
+
};
|
package/dist/slider.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { StateOf } from "@ui-sdk/core";
|
|
2
|
+
import { slider as sliderPrimitive, type SliderOptions } from "@ui-sdk/core/slider";
|
|
3
|
+
import { type RootInstanceOf, type RootPropsOf } from "./create-parts.js";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
type Value = number | number[];
|
|
6
|
+
type SliderProps<V extends Value> = SliderOptions<V>;
|
|
7
|
+
type SliderComponent = new <V extends Value = Value>(props: RootPropsOf<SliderProps<V>, "div">) => RootInstanceOf<SliderProps<V>, StateOf<typeof sliderPrimitive, "root">, "div">;
|
|
8
|
+
/**
|
|
9
|
+
* The root: a group around the thumbs, and the hidden input the form submits.
|
|
10
|
+
* @stable
|
|
11
|
+
*/
|
|
12
|
+
declare const Slider: SliderComponent;
|
|
13
|
+
/**
|
|
14
|
+
* Where presses land. A press on the track moves the nearest thumb there.
|
|
15
|
+
* @stable
|
|
16
|
+
*/
|
|
17
|
+
declare const SliderControl: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, "div">;
|
|
18
|
+
/**
|
|
19
|
+
* The rail the thumbs move along. Positions are percentages of it.
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
declare const SliderTrack: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, "div">;
|
|
23
|
+
/**
|
|
24
|
+
* The filled part of the track: up to a single thumb, or between a range's thumbs.
|
|
25
|
+
* @stable
|
|
26
|
+
*/
|
|
27
|
+
declare const SliderIndicator: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/slider").SliderState>>>, "div">;
|
|
28
|
+
/**
|
|
29
|
+
* A thumb, with the native range input that takes focus inside it. Its
|
|
30
|
+
* `aria-label`, `aria-labelledby` and `aria-describedby` go to that input.
|
|
31
|
+
* @stable
|
|
32
|
+
*/
|
|
33
|
+
declare const SliderThumb: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
34
|
+
index: {
|
|
35
|
+
type: NumberConstructor;
|
|
36
|
+
default: number;
|
|
37
|
+
};
|
|
38
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
41
|
+
[key: string]: any;
|
|
42
|
+
}>[] | null) & {
|
|
43
|
+
state: NoInfer<import("@ui-sdk/core/slider").SliderThumbState>;
|
|
44
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
45
|
+
index: {
|
|
46
|
+
type: NumberConstructor;
|
|
47
|
+
default: number;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {
|
|
50
|
+
index: number;
|
|
51
|
+
}, PartSlots<import("@ui-sdk/core/slider").SliderPrimitive, "thumb">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
52
|
+
/**
|
|
53
|
+
* The formatted value, a range joined with an en dash. Content replaces it.
|
|
54
|
+
* @stable
|
|
55
|
+
*/
|
|
56
|
+
declare const SliderValue: import("./create-parts.js").ElementPart<import("vue").DefineComponent<{}, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}>[] | null) & {
|
|
61
|
+
state: NoInfer<import("@ui-sdk/core/slider").SliderValueState>;
|
|
62
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/slider").SliderPrimitive, "value">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "output">;
|
|
63
|
+
export { createSliderController } from "@ui-sdk/core/slider";
|
|
64
|
+
export type { NumberFormat, SliderApi, SliderChangeOptions, SliderController, SliderOptions, SliderPrimitive, SliderState, SliderThumbProps, SliderThumbState, SliderValueChangeDetails, SliderValueChangeReason, SliderValueCommitDetails, SliderValueState, } from "@ui-sdk/core/slider";
|
|
65
|
+
export { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack, SliderValue, };
|