@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
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// src/toast-parts.ts
|
|
2
|
+
import {
|
|
3
|
+
createToaster as createCoreToaster,
|
|
4
|
+
toast as coreToast,
|
|
5
|
+
toastRegion
|
|
6
|
+
} from "@ui-sdk/core/toast";
|
|
7
|
+
import {
|
|
8
|
+
defineComponent,
|
|
9
|
+
h,
|
|
10
|
+
inject,
|
|
11
|
+
onBeforeUpdate,
|
|
12
|
+
provide,
|
|
13
|
+
shallowRef,
|
|
14
|
+
useId
|
|
15
|
+
} from "vue";
|
|
16
|
+
import { slotContent } from "./children.js";
|
|
17
|
+
import { withElement } from "./create-parts.js";
|
|
18
|
+
import { containerProp, renderPopup } from "./popup.js";
|
|
19
|
+
import {
|
|
20
|
+
optionalBoolean,
|
|
21
|
+
usePart,
|
|
22
|
+
usePrimitive
|
|
23
|
+
} from "./use-primitive.js";
|
|
24
|
+
var ToastKey = /* @__PURE__ */ Symbol("toast");
|
|
25
|
+
function useToast(part) {
|
|
26
|
+
const context = inject(ToastKey, null);
|
|
27
|
+
if (!context) {
|
|
28
|
+
throw new Error(`${part} must be used inside <Toast>, in a <ToastRegion>.`);
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
var ToastScope = defineComponent({
|
|
33
|
+
name: "ToastScope",
|
|
34
|
+
props: {
|
|
35
|
+
region: { type: Object, required: true },
|
|
36
|
+
toast: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
setup(props, { slots }) {
|
|
42
|
+
provide(ToastKey, { region: props.region, toast: () => props.toast });
|
|
43
|
+
return () => slots.default?.();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
var regionProps = {
|
|
47
|
+
toaster: Function,
|
|
48
|
+
side: String,
|
|
49
|
+
align: String,
|
|
50
|
+
maxVisible: Number,
|
|
51
|
+
expanded: optionalBoolean,
|
|
52
|
+
// `null` turns the shortcut off.
|
|
53
|
+
shortcut: { type: String, default: void 0 },
|
|
54
|
+
pendingAnnouncement: String,
|
|
55
|
+
debug: optionalBoolean,
|
|
56
|
+
container: containerProp
|
|
57
|
+
};
|
|
58
|
+
function createRegion(placed) {
|
|
59
|
+
return withElement(
|
|
60
|
+
"section",
|
|
61
|
+
defineComponent({
|
|
62
|
+
name: placed ? "ToastRegion" : "HostedToastRegion",
|
|
63
|
+
inheritAttrs: false,
|
|
64
|
+
props: regionProps,
|
|
65
|
+
slots: Object,
|
|
66
|
+
setup(props, { slots, attrs }) {
|
|
67
|
+
const label = shallowRef(attrs["aria-label"]);
|
|
68
|
+
onBeforeUpdate(
|
|
69
|
+
() => label.value = attrs["aria-label"]
|
|
70
|
+
);
|
|
71
|
+
const region = usePrimitive(
|
|
72
|
+
toastRegion,
|
|
73
|
+
() => ({
|
|
74
|
+
toaster: props.toaster,
|
|
75
|
+
side: props.side,
|
|
76
|
+
align: props.align,
|
|
77
|
+
maxVisible: props.maxVisible,
|
|
78
|
+
expanded: props.expanded,
|
|
79
|
+
shortcut: props.shortcut,
|
|
80
|
+
pendingAnnouncement: props.pendingAnnouncement,
|
|
81
|
+
debug: props.debug,
|
|
82
|
+
placed,
|
|
83
|
+
label: label.value
|
|
84
|
+
})
|
|
85
|
+
);
|
|
86
|
+
let list;
|
|
87
|
+
const part = usePart(
|
|
88
|
+
region,
|
|
89
|
+
"region",
|
|
90
|
+
void 0,
|
|
91
|
+
() => {
|
|
92
|
+
const { "aria-label": _, ...rest } = attrs;
|
|
93
|
+
return rest;
|
|
94
|
+
},
|
|
95
|
+
{ tag: "section", children: () => list }
|
|
96
|
+
);
|
|
97
|
+
return () => {
|
|
98
|
+
const toasts = part.state.toasts;
|
|
99
|
+
list = h(
|
|
100
|
+
"ol",
|
|
101
|
+
region.slot("list"),
|
|
102
|
+
toasts.map(
|
|
103
|
+
(item) => h(
|
|
104
|
+
ToastScope,
|
|
105
|
+
{ key: item.toast.id, region, toast: item.toast },
|
|
106
|
+
() => slots.default ? slots.default({ toast: item.toast, item }) : h(DataToast, { toast: item.toast })
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
const element = part();
|
|
111
|
+
return element && renderPopup(element, props.container);
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
var ToastRegion = createRegion(true);
|
|
118
|
+
var HostedToastRegion = createRegion(false);
|
|
119
|
+
var DataToast = defineComponent({
|
|
120
|
+
name: "DataToast",
|
|
121
|
+
props: {
|
|
122
|
+
toast: {
|
|
123
|
+
type: Object,
|
|
124
|
+
required: true
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
setup(props) {
|
|
128
|
+
return () => {
|
|
129
|
+
const { toast: toast2 } = props;
|
|
130
|
+
return h(Toast, null, () => [
|
|
131
|
+
h("div", [
|
|
132
|
+
toast2.title != null ? h(ToastTitle) : null,
|
|
133
|
+
toast2.description != null ? h(ToastDescription) : null
|
|
134
|
+
]),
|
|
135
|
+
toast2.action ? h(ToastAction) : null,
|
|
136
|
+
toast2.cancel ? h(
|
|
137
|
+
ToastClose,
|
|
138
|
+
{ action: toast2.cancel.onCancel },
|
|
139
|
+
() => toast2.cancel.label
|
|
140
|
+
) : null
|
|
141
|
+
]);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
var Toast = withElement(
|
|
146
|
+
"li",
|
|
147
|
+
defineComponent({
|
|
148
|
+
name: "Toast",
|
|
149
|
+
inheritAttrs: false,
|
|
150
|
+
slots: Object,
|
|
151
|
+
setup() {
|
|
152
|
+
const { region, toast: toast2 } = useToast("Toast");
|
|
153
|
+
return usePart(
|
|
154
|
+
region,
|
|
155
|
+
"root",
|
|
156
|
+
() => ({ id: toast2().id }),
|
|
157
|
+
void 0,
|
|
158
|
+
"li"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
);
|
|
163
|
+
function contentPart(name, slot) {
|
|
164
|
+
return withElement(
|
|
165
|
+
"div",
|
|
166
|
+
defineComponent({
|
|
167
|
+
name,
|
|
168
|
+
inheritAttrs: false,
|
|
169
|
+
slots: Object,
|
|
170
|
+
setup(_, { slots }) {
|
|
171
|
+
const { region, toast: toast2 } = useToast(name);
|
|
172
|
+
let content;
|
|
173
|
+
const part = usePart(
|
|
174
|
+
region,
|
|
175
|
+
slot,
|
|
176
|
+
() => ({ id: toast2().id }),
|
|
177
|
+
void 0,
|
|
178
|
+
{
|
|
179
|
+
tag: "div",
|
|
180
|
+
children: () => content
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
return () => {
|
|
184
|
+
content = slotContent(slots.default, { state: part.state }) ?? toast2()[slot];
|
|
185
|
+
return content == null ? null : part();
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
var ToastTitle = contentPart("ToastTitle", "title");
|
|
192
|
+
var ToastDescription = contentPart("ToastDescription", "description");
|
|
193
|
+
var ToastAction = withElement(
|
|
194
|
+
"button",
|
|
195
|
+
defineComponent({
|
|
196
|
+
name: "ToastAction",
|
|
197
|
+
inheritAttrs: false,
|
|
198
|
+
props: {
|
|
199
|
+
// Runs instead of the toast's own `action.onAction`. `@action="undo"` binds here.
|
|
200
|
+
onAction: Function,
|
|
201
|
+
// Whether pressing it dismisses the toast. Defaults to the toast's `action.dismiss`, else true.
|
|
202
|
+
dismiss: optionalBoolean
|
|
203
|
+
},
|
|
204
|
+
slots: Object,
|
|
205
|
+
setup(props, { slots, attrs }) {
|
|
206
|
+
const { region, toast: toast2 } = useToast("ToastAction");
|
|
207
|
+
const id = useId();
|
|
208
|
+
const part = () => ({
|
|
209
|
+
id,
|
|
210
|
+
toast: toast2().id,
|
|
211
|
+
onAction: props.onAction,
|
|
212
|
+
dismiss: props.dismiss
|
|
213
|
+
});
|
|
214
|
+
const element = () => {
|
|
215
|
+
const href = toast2().action?.href;
|
|
216
|
+
return href ? { href, ...attrs } : { type: "button", ...attrs };
|
|
217
|
+
};
|
|
218
|
+
const render = usePart(region, "action", part, element, {
|
|
219
|
+
get tag() {
|
|
220
|
+
return toast2().action?.href ? "a" : "button";
|
|
221
|
+
},
|
|
222
|
+
children: (state) => slotContent(slots.default, { state }) ?? toast2().action?.label
|
|
223
|
+
});
|
|
224
|
+
return () => !toast2().action && !props.onAction ? null : render();
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
var ToastClose = withElement(
|
|
229
|
+
"button",
|
|
230
|
+
defineComponent({
|
|
231
|
+
name: "ToastClose",
|
|
232
|
+
inheritAttrs: false,
|
|
233
|
+
props: {
|
|
234
|
+
// Runs before the toast closes. A returned Promise keeps it open and pending until it settles.
|
|
235
|
+
action: Function,
|
|
236
|
+
// `@action="save"` binds here, so the part gets the handler's Promise.
|
|
237
|
+
onAction: Function
|
|
238
|
+
},
|
|
239
|
+
slots: Object,
|
|
240
|
+
setup(props, { attrs }) {
|
|
241
|
+
const { region, toast: toast2 } = useToast("ToastClose");
|
|
242
|
+
const id = useId();
|
|
243
|
+
const part = () => ({
|
|
244
|
+
id,
|
|
245
|
+
toast: toast2().id,
|
|
246
|
+
action: props.action ?? props.onAction
|
|
247
|
+
});
|
|
248
|
+
return usePart(
|
|
249
|
+
region,
|
|
250
|
+
"close",
|
|
251
|
+
part,
|
|
252
|
+
() => ({ type: "button", ...attrs }),
|
|
253
|
+
"button"
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
var toast = coreToast;
|
|
259
|
+
var createToaster = createCoreToaster;
|
|
260
|
+
export {
|
|
261
|
+
HostedToastRegion,
|
|
262
|
+
Toast,
|
|
263
|
+
ToastAction,
|
|
264
|
+
ToastClose,
|
|
265
|
+
ToastDescription,
|
|
266
|
+
ToastRegion,
|
|
267
|
+
ToastTitle,
|
|
268
|
+
createToaster,
|
|
269
|
+
toast
|
|
270
|
+
};
|
package/dist/toast.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { Toast as ToastData, ToastAction as ToastActionData, ToastActionDetails, ToastActionProps, ToastButtonState, ToastCancel, ToastCloseProps, ToastDismissDetails, ToastDismissReason, Toaster, ToastItem, ToastOptions, ToastPauseReason, ToastRegionOptions, ToastRegionPrimitive, ToastRegionState, ToastState, ToastType, } from "@ui-sdk/core/toast";
|
|
2
|
+
export { createToaster, toast, Toast, ToastAction, ToastClose, type ToastContent, ToastDescription, ToastRegion, ToastTitle, } from "./toast-parts.js";
|
package/dist/toast.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/toast.ts
|
|
2
|
+
import {
|
|
3
|
+
createToaster,
|
|
4
|
+
toast,
|
|
5
|
+
Toast,
|
|
6
|
+
ToastAction,
|
|
7
|
+
ToastClose,
|
|
8
|
+
ToastDescription,
|
|
9
|
+
ToastRegion,
|
|
10
|
+
ToastTitle
|
|
11
|
+
} from "./toast-parts.js";
|
|
12
|
+
export {
|
|
13
|
+
Toast,
|
|
14
|
+
ToastAction,
|
|
15
|
+
ToastClose,
|
|
16
|
+
ToastDescription,
|
|
17
|
+
ToastRegion,
|
|
18
|
+
ToastTitle,
|
|
19
|
+
createToaster,
|
|
20
|
+
toast
|
|
21
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const toggleProps: {
|
|
2
|
+
disabled: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: undefined;
|
|
5
|
+
};
|
|
6
|
+
readOnly: {
|
|
7
|
+
type: BooleanConstructor;
|
|
8
|
+
default: undefined;
|
|
9
|
+
};
|
|
10
|
+
required: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
name: StringConstructor;
|
|
15
|
+
value: StringConstructor;
|
|
16
|
+
form: StringConstructor;
|
|
17
|
+
debug: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: undefined;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export { toggleProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/toggle-props.ts
|
|
2
|
+
import { optionalBoolean } from "./use-primitive.js";
|
|
3
|
+
var toggleProps = {
|
|
4
|
+
disabled: optionalBoolean,
|
|
5
|
+
readOnly: optionalBoolean,
|
|
6
|
+
required: optionalBoolean,
|
|
7
|
+
name: String,
|
|
8
|
+
value: String,
|
|
9
|
+
form: String,
|
|
10
|
+
debug: optionalBoolean
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
toggleProps
|
|
14
|
+
};
|
package/dist/toggle.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type ToggleController, type ToggleGroupController, type ToggleGroupOrientation, type ToggleGroupValueChangeReason, type TogglePressedChangeReason } from "@ui-sdk/core/toggle";
|
|
3
|
+
import { type PropType } from "vue";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
/**
|
|
6
|
+
* A button that stays pressed. Inside a ToggleGroup, the group decides whether it's pressed.
|
|
7
|
+
* @stable
|
|
8
|
+
*/
|
|
9
|
+
declare const Toggle: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
pressed: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
defaultPressed: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
value: StringConstructor;
|
|
23
|
+
disabled: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
focusableWhenDisabled: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
controller: PropType<ToggleController>;
|
|
32
|
+
debug: {
|
|
33
|
+
type: BooleanConstructor;
|
|
34
|
+
default: undefined;
|
|
35
|
+
};
|
|
36
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}>[] | null) & {
|
|
41
|
+
state: NoInfer<import("@ui-sdk/core/toggle").ToggleState>;
|
|
42
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
43
|
+
"update:pressed": (_pressed: boolean) => true;
|
|
44
|
+
"update:modelValue": (_pressed: boolean) => true;
|
|
45
|
+
pressedChange: (_pressed: boolean, _details: ChangeDetails<TogglePressedChangeReason>) => true;
|
|
46
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
47
|
+
pressed: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
modelValue: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
defaultPressed: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
value: StringConstructor;
|
|
60
|
+
disabled: {
|
|
61
|
+
type: BooleanConstructor;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
focusableWhenDisabled: {
|
|
65
|
+
type: BooleanConstructor;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
controller: PropType<ToggleController>;
|
|
69
|
+
debug: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: undefined;
|
|
72
|
+
};
|
|
73
|
+
}>> & Readonly<{
|
|
74
|
+
"onUpdate:modelValue"?: ((_pressed: boolean) => any) | undefined;
|
|
75
|
+
"onUpdate:pressed"?: ((_pressed: boolean) => any) | undefined;
|
|
76
|
+
onPressedChange?: ((_pressed: boolean, _details: ChangeDetails<TogglePressedChangeReason>) => any) | undefined;
|
|
77
|
+
}>, {
|
|
78
|
+
disabled: boolean;
|
|
79
|
+
debug: boolean;
|
|
80
|
+
focusableWhenDisabled: boolean;
|
|
81
|
+
pressed: boolean;
|
|
82
|
+
modelValue: boolean;
|
|
83
|
+
defaultPressed: boolean;
|
|
84
|
+
}, PartSlots<import("@ui-sdk/core/toggle").TogglePrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "button">;
|
|
85
|
+
/**
|
|
86
|
+
* An icon inside a toggle. A toggle with only an icon needs an `aria-label`.
|
|
87
|
+
* Screen readers skip it, and `mirror` flips it in right-to-left text.
|
|
88
|
+
* @stable
|
|
89
|
+
*/
|
|
90
|
+
declare const ToggleIcon: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/renderer").ItemIconProps & {
|
|
91
|
+
item?: string;
|
|
92
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<{
|
|
93
|
+
mirror: boolean;
|
|
94
|
+
}>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/renderer").ItemIconProps & {
|
|
95
|
+
item?: string;
|
|
96
|
+
}> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<{
|
|
97
|
+
mirror: boolean;
|
|
98
|
+
}>>>, "span">;
|
|
99
|
+
/**
|
|
100
|
+
* Toggles that share one value, with one tab stop and arrow keys between them.
|
|
101
|
+
* @stable
|
|
102
|
+
*/
|
|
103
|
+
declare const ToggleGroup: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
104
|
+
value: {
|
|
105
|
+
type: PropType<string[]>;
|
|
106
|
+
default: undefined;
|
|
107
|
+
};
|
|
108
|
+
modelValue: {
|
|
109
|
+
type: PropType<string[]>;
|
|
110
|
+
default: undefined;
|
|
111
|
+
};
|
|
112
|
+
defaultValue: {
|
|
113
|
+
type: PropType<string[]>;
|
|
114
|
+
default: undefined;
|
|
115
|
+
};
|
|
116
|
+
multiple: {
|
|
117
|
+
type: BooleanConstructor;
|
|
118
|
+
default: undefined;
|
|
119
|
+
};
|
|
120
|
+
deselectable: {
|
|
121
|
+
type: BooleanConstructor;
|
|
122
|
+
default: undefined;
|
|
123
|
+
};
|
|
124
|
+
disabled: {
|
|
125
|
+
type: BooleanConstructor;
|
|
126
|
+
default: undefined;
|
|
127
|
+
};
|
|
128
|
+
orientation: PropType<ToggleGroupOrientation>;
|
|
129
|
+
loop: {
|
|
130
|
+
type: BooleanConstructor;
|
|
131
|
+
default: undefined;
|
|
132
|
+
};
|
|
133
|
+
controller: PropType<ToggleGroupController>;
|
|
134
|
+
debug: {
|
|
135
|
+
type: BooleanConstructor;
|
|
136
|
+
default: undefined;
|
|
137
|
+
};
|
|
138
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
139
|
+
[key: string]: any;
|
|
140
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
}>[] | null) & {
|
|
143
|
+
state: NoInfer<import("@ui-sdk/core/toggle").ToggleGroupState<string>>;
|
|
144
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
145
|
+
"update:value": (_value: string[]) => true;
|
|
146
|
+
"update:modelValue": (_value: string[]) => true;
|
|
147
|
+
valueChange: (_value: string[], _details: ChangeDetails<ToggleGroupValueChangeReason>) => true;
|
|
148
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
149
|
+
value: {
|
|
150
|
+
type: PropType<string[]>;
|
|
151
|
+
default: undefined;
|
|
152
|
+
};
|
|
153
|
+
modelValue: {
|
|
154
|
+
type: PropType<string[]>;
|
|
155
|
+
default: undefined;
|
|
156
|
+
};
|
|
157
|
+
defaultValue: {
|
|
158
|
+
type: PropType<string[]>;
|
|
159
|
+
default: undefined;
|
|
160
|
+
};
|
|
161
|
+
multiple: {
|
|
162
|
+
type: BooleanConstructor;
|
|
163
|
+
default: undefined;
|
|
164
|
+
};
|
|
165
|
+
deselectable: {
|
|
166
|
+
type: BooleanConstructor;
|
|
167
|
+
default: undefined;
|
|
168
|
+
};
|
|
169
|
+
disabled: {
|
|
170
|
+
type: BooleanConstructor;
|
|
171
|
+
default: undefined;
|
|
172
|
+
};
|
|
173
|
+
orientation: PropType<ToggleGroupOrientation>;
|
|
174
|
+
loop: {
|
|
175
|
+
type: BooleanConstructor;
|
|
176
|
+
default: undefined;
|
|
177
|
+
};
|
|
178
|
+
controller: PropType<ToggleGroupController>;
|
|
179
|
+
debug: {
|
|
180
|
+
type: BooleanConstructor;
|
|
181
|
+
default: undefined;
|
|
182
|
+
};
|
|
183
|
+
}>> & Readonly<{
|
|
184
|
+
"onUpdate:modelValue"?: ((_value: string[]) => any) | undefined;
|
|
185
|
+
"onUpdate:value"?: ((_value: string[]) => any) | undefined;
|
|
186
|
+
onValueChange?: ((_value: string[], _details: ChangeDetails<ToggleGroupValueChangeReason>) => any) | undefined;
|
|
187
|
+
}>, {
|
|
188
|
+
value: string[];
|
|
189
|
+
disabled: boolean;
|
|
190
|
+
debug: boolean;
|
|
191
|
+
multiple: boolean;
|
|
192
|
+
defaultValue: string[];
|
|
193
|
+
loop: boolean;
|
|
194
|
+
deselectable: boolean;
|
|
195
|
+
modelValue: string[];
|
|
196
|
+
}, PartSlots<import("@ui-sdk/core/toggle").ToggleGroupPrimitive, "group">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
197
|
+
export { createToggleController, createToggleGroupController, } from "@ui-sdk/core/toggle";
|
|
198
|
+
export type { ToggleApi, ToggleChangeOptions, ToggleController, ToggleGroupApi, ToggleGroupChangeOptions, ToggleGroupController, ToggleGroupOptions, ToggleGroupOrientation, ToggleGroupPrimitive, ToggleGroupState, ToggleGroupValueChangeReason, ToggleIconProps, ToggleIconState, ToggleOptions, TogglePressedChangeReason, TogglePrimitive, ToggleState, } from "@ui-sdk/core/toggle";
|
|
199
|
+
export { Toggle, ToggleGroup, ToggleIcon };
|
package/dist/toggle.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// src/toggle.ts
|
|
2
|
+
import {
|
|
3
|
+
toggle as togglePrimitive,
|
|
4
|
+
toggleGroup as toggleGroupPrimitive
|
|
5
|
+
} from "@ui-sdk/core/toggle";
|
|
6
|
+
import {
|
|
7
|
+
defineComponent,
|
|
8
|
+
inject,
|
|
9
|
+
provide
|
|
10
|
+
} from "vue";
|
|
11
|
+
import { useToolbarScope } from "./toolbar-context.js";
|
|
12
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
13
|
+
import {
|
|
14
|
+
optionalBoolean,
|
|
15
|
+
orModel,
|
|
16
|
+
usePart,
|
|
17
|
+
usePrimitive
|
|
18
|
+
} from "./use-primitive.js";
|
|
19
|
+
import {
|
|
20
|
+
createToggleController,
|
|
21
|
+
createToggleGroupController
|
|
22
|
+
} from "@ui-sdk/core/toggle";
|
|
23
|
+
var parts = createParts(togglePrimitive, { icon: "span" });
|
|
24
|
+
var ToggleGroupKey = /* @__PURE__ */ Symbol("toggle-group");
|
|
25
|
+
var Toggle = withElement(
|
|
26
|
+
"button",
|
|
27
|
+
defineComponent({
|
|
28
|
+
name: "Toggle",
|
|
29
|
+
inheritAttrs: false,
|
|
30
|
+
props: {
|
|
31
|
+
pressed: optionalBoolean,
|
|
32
|
+
modelValue: optionalBoolean,
|
|
33
|
+
defaultPressed: optionalBoolean,
|
|
34
|
+
value: String,
|
|
35
|
+
disabled: optionalBoolean,
|
|
36
|
+
focusableWhenDisabled: optionalBoolean,
|
|
37
|
+
controller: Object,
|
|
38
|
+
debug: optionalBoolean
|
|
39
|
+
},
|
|
40
|
+
emits: {
|
|
41
|
+
"update:pressed": (_pressed) => true,
|
|
42
|
+
"update:modelValue": (_pressed) => true,
|
|
43
|
+
pressedChange: (_pressed, _details) => true
|
|
44
|
+
},
|
|
45
|
+
slots: Object,
|
|
46
|
+
setup(props, { emit }) {
|
|
47
|
+
const group = inject(ToggleGroupKey, null);
|
|
48
|
+
const toolbar = useToolbarScope();
|
|
49
|
+
const toggle = usePrimitive(togglePrimitive, () => ({
|
|
50
|
+
pressed: orModel(props.pressed, props.modelValue),
|
|
51
|
+
defaultPressed: props.defaultPressed,
|
|
52
|
+
value: props.value,
|
|
53
|
+
disabled: props.disabled,
|
|
54
|
+
focusableWhenDisabled: props.focusableWhenDisabled,
|
|
55
|
+
group: group ? () => group.api : void 0,
|
|
56
|
+
toolbar: toolbar.value,
|
|
57
|
+
controller: props.controller,
|
|
58
|
+
debug: props.debug,
|
|
59
|
+
onPressedChange: (pressed, details) => {
|
|
60
|
+
emit("pressedChange", pressed, details);
|
|
61
|
+
if (details.canceled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
emit("update:pressed", pressed);
|
|
65
|
+
emit("update:modelValue", pressed);
|
|
66
|
+
}
|
|
67
|
+
}));
|
|
68
|
+
return usePart(toggle, "root", void 0, void 0, "button");
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
var ToggleIcon = parts.Icon;
|
|
73
|
+
var ToggleGroup = /* @__PURE__ */ withElement(
|
|
74
|
+
"div",
|
|
75
|
+
/* @__PURE__ */ defineComponent({
|
|
76
|
+
name: "ToggleGroup",
|
|
77
|
+
inheritAttrs: false,
|
|
78
|
+
props: {
|
|
79
|
+
value: { type: Array, default: void 0 },
|
|
80
|
+
modelValue: { type: Array, default: void 0 },
|
|
81
|
+
defaultValue: { type: Array, default: void 0 },
|
|
82
|
+
multiple: optionalBoolean,
|
|
83
|
+
deselectable: optionalBoolean,
|
|
84
|
+
disabled: optionalBoolean,
|
|
85
|
+
orientation: String,
|
|
86
|
+
loop: optionalBoolean,
|
|
87
|
+
controller: Object,
|
|
88
|
+
debug: optionalBoolean
|
|
89
|
+
},
|
|
90
|
+
emits: {
|
|
91
|
+
"update:value": (_value) => true,
|
|
92
|
+
"update:modelValue": (_value) => true,
|
|
93
|
+
valueChange: (_value, _details) => true
|
|
94
|
+
},
|
|
95
|
+
slots: Object,
|
|
96
|
+
setup(props, { emit }) {
|
|
97
|
+
const toolbar = useToolbarScope();
|
|
98
|
+
const group = usePrimitive(toggleGroupPrimitive, () => ({
|
|
99
|
+
toolbar: toolbar.value,
|
|
100
|
+
value: orModel(props.value, props.modelValue),
|
|
101
|
+
defaultValue: props.defaultValue,
|
|
102
|
+
multiple: props.multiple,
|
|
103
|
+
deselectable: props.deselectable,
|
|
104
|
+
disabled: props.disabled,
|
|
105
|
+
orientation: props.orientation,
|
|
106
|
+
loop: props.loop,
|
|
107
|
+
controller: props.controller,
|
|
108
|
+
debug: props.debug,
|
|
109
|
+
onValueChange: (value, details) => {
|
|
110
|
+
emit("valueChange", value, details);
|
|
111
|
+
if (details.canceled) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
emit("update:value", value);
|
|
115
|
+
emit("update:modelValue", value);
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
provide(ToggleGroupKey, group);
|
|
119
|
+
return usePart(group, "group", void 0, void 0, "div");
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
export {
|
|
124
|
+
Toggle,
|
|
125
|
+
ToggleGroup,
|
|
126
|
+
ToggleIcon,
|
|
127
|
+
createToggleController,
|
|
128
|
+
createToggleGroupController
|
|
129
|
+
};
|