@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/rating.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// src/rating.ts
|
|
2
|
+
import {
|
|
3
|
+
rating,
|
|
4
|
+
ratingItemValues
|
|
5
|
+
} from "@ui-sdk/core/rating";
|
|
6
|
+
import {
|
|
7
|
+
defineComponent,
|
|
8
|
+
h,
|
|
9
|
+
inject,
|
|
10
|
+
provide
|
|
11
|
+
} from "vue";
|
|
12
|
+
import { withElement } from "./create-parts.js";
|
|
13
|
+
import { useFieldControl } from "./field-context.js";
|
|
14
|
+
import { readOnlyOf } from "./text-control.js";
|
|
15
|
+
import {
|
|
16
|
+
optionalBoolean,
|
|
17
|
+
orModel,
|
|
18
|
+
usePart,
|
|
19
|
+
usePrimitive,
|
|
20
|
+
useScope
|
|
21
|
+
} from "./use-primitive.js";
|
|
22
|
+
import { createRatingController } from "@ui-sdk/core/rating";
|
|
23
|
+
var ItemKey = /* @__PURE__ */ Symbol("rating-item");
|
|
24
|
+
var ItemScope = defineComponent({
|
|
25
|
+
name: "RatingItemScope",
|
|
26
|
+
props: {
|
|
27
|
+
index: { type: Number, required: true },
|
|
28
|
+
step: { type: Number, required: true }
|
|
29
|
+
},
|
|
30
|
+
setup(props, { slots }) {
|
|
31
|
+
provide(ItemKey, props);
|
|
32
|
+
return () => slots.default?.();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var Rating = withElement(
|
|
36
|
+
"div",
|
|
37
|
+
defineComponent({
|
|
38
|
+
name: "Rating",
|
|
39
|
+
inheritAttrs: false,
|
|
40
|
+
props: {
|
|
41
|
+
value: { type: Number, default: void 0 },
|
|
42
|
+
modelValue: {
|
|
43
|
+
type: Number,
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
defaultValue: {
|
|
47
|
+
type: Number,
|
|
48
|
+
default: void 0
|
|
49
|
+
},
|
|
50
|
+
max: { type: Number, default: 5 },
|
|
51
|
+
step: { type: Number, default: 1 },
|
|
52
|
+
deselectable: optionalBoolean,
|
|
53
|
+
disabled: optionalBoolean,
|
|
54
|
+
readOnly: optionalBoolean,
|
|
55
|
+
required: optionalBoolean,
|
|
56
|
+
name: String,
|
|
57
|
+
form: String,
|
|
58
|
+
loop: optionalBoolean,
|
|
59
|
+
getValueLabel: Function,
|
|
60
|
+
controller: Object,
|
|
61
|
+
debug: optionalBoolean
|
|
62
|
+
},
|
|
63
|
+
emits: {
|
|
64
|
+
"update:value": (_value) => true,
|
|
65
|
+
"update:modelValue": (_value) => true,
|
|
66
|
+
valueChange: (_value, _details) => true
|
|
67
|
+
},
|
|
68
|
+
slots: Object,
|
|
69
|
+
setup(props, { attrs, emit, slots }) {
|
|
70
|
+
const field = useFieldControl();
|
|
71
|
+
const control = usePrimitive(rating, () => ({
|
|
72
|
+
value: orModel(props.value, props.modelValue),
|
|
73
|
+
defaultValue: props.defaultValue,
|
|
74
|
+
max: props.max,
|
|
75
|
+
step: props.step,
|
|
76
|
+
deselectable: props.deselectable,
|
|
77
|
+
disabled: props.disabled || field?.disabled(),
|
|
78
|
+
readOnly: readOnlyOf(props, attrs),
|
|
79
|
+
required: props.required,
|
|
80
|
+
name: props.name ?? field?.name(),
|
|
81
|
+
form: props.form,
|
|
82
|
+
loop: props.loop,
|
|
83
|
+
getValueLabel: props.getValueLabel,
|
|
84
|
+
controller: props.controller,
|
|
85
|
+
debug: props.debug,
|
|
86
|
+
onValueChange: (value, details) => {
|
|
87
|
+
emit("valueChange", value, details);
|
|
88
|
+
if (details.canceled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
emit("update:value", value);
|
|
92
|
+
emit("update:modelValue", value);
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
95
|
+
const stars = (state) => Array.from(
|
|
96
|
+
{ length: props.max },
|
|
97
|
+
(_, at) => h(
|
|
98
|
+
ItemScope,
|
|
99
|
+
{ key: at, index: at + 1, step: props.step },
|
|
100
|
+
() => slots.default?.({ state }) ?? h(RatingItem)
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
return usePart(control, "root", void 0, void 0, {
|
|
104
|
+
tag: "div",
|
|
105
|
+
extend: field?.props,
|
|
106
|
+
children: stars
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
var RatingRadio = defineComponent({
|
|
112
|
+
name: "RatingRadio",
|
|
113
|
+
props: { value: { type: String, required: true } },
|
|
114
|
+
setup(props) {
|
|
115
|
+
const control = useScope(rating).handle;
|
|
116
|
+
const radio = () => ({ value: props.value });
|
|
117
|
+
const button = usePart(control, "radio", radio, () => ({}), "button");
|
|
118
|
+
return () => [button(), h("input", control.slot("input", radio()))];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var RatingItem = withElement(
|
|
122
|
+
"span",
|
|
123
|
+
defineComponent({
|
|
124
|
+
name: "RatingItem",
|
|
125
|
+
inheritAttrs: false,
|
|
126
|
+
slots: Object,
|
|
127
|
+
setup(_, { slots }) {
|
|
128
|
+
const item = inject(ItemKey, null);
|
|
129
|
+
if (!item) {
|
|
130
|
+
throw new Error("RatingItem must be used inside <Rating>.");
|
|
131
|
+
}
|
|
132
|
+
const radios = () => ratingItemValues(item.index, item.step).map(
|
|
133
|
+
(score) => h(RatingRadio, { key: score, value: String(score) })
|
|
134
|
+
);
|
|
135
|
+
return usePart(rating, "item", () => ({ index: item.index }), void 0, {
|
|
136
|
+
tag: "span",
|
|
137
|
+
children: (state) => [slots.default?.({ state }), radios()]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
export {
|
|
143
|
+
Rating,
|
|
144
|
+
RatingItem,
|
|
145
|
+
createRatingController
|
|
146
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/renderless.ts
|
|
2
|
+
import { warn } from "@ui-sdk/core/renderer";
|
|
3
|
+
var warned = /* @__PURE__ */ new Set();
|
|
4
|
+
function warnAttributes(name, attrs, read = []) {
|
|
5
|
+
const keys = Object.keys(attrs).filter((key) => !read.includes(key)).join(", ");
|
|
6
|
+
if (!keys || warned.has(`${name} ${keys}`)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
warned.add(`${name} ${keys}`);
|
|
10
|
+
warn(
|
|
11
|
+
`${name} renders no element, so it ignores ${keys}. Put them on one of its parts.`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
function renderless(component) {
|
|
15
|
+
const options = component;
|
|
16
|
+
const setup = options.setup;
|
|
17
|
+
options.inheritAttrs = false;
|
|
18
|
+
const read = options.props && "readOnly" in options.props ? ["readonly"] : [];
|
|
19
|
+
options.setup = (props, context) => {
|
|
20
|
+
warnAttributes(options.name ?? "This root", context.attrs, read);
|
|
21
|
+
return setup?.(props, context);
|
|
22
|
+
};
|
|
23
|
+
return component;
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
renderless,
|
|
27
|
+
warnAttributes
|
|
28
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The group: lays its panels out along its orientation. `v-model:layout` controls it.
|
|
3
|
+
* @stable
|
|
4
|
+
*/
|
|
5
|
+
declare const Resizable: import("./create-parts.js").ElementPart<new (props: Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/resizable").ResizablePrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, "onLayoutChange" | "onLayoutCommit"> & {
|
|
6
|
+
modelValue?: number[] | undefined;
|
|
7
|
+
} & {
|
|
8
|
+
"onUpdate:modelValue"?: ((value: number[]) => any) | undefined;
|
|
9
|
+
onLayoutChange?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutChangeDetails) => any) | undefined;
|
|
10
|
+
onLayoutCommit?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutCommitDetails) => any) | undefined;
|
|
11
|
+
"onUpdate:layout"?: ((value: number[]) => any) | undefined;
|
|
12
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps) => import("vue").CreateComponentPublicInstanceWithMixins<Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/resizable").ResizablePrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, "onLayoutChange" | "onLayoutCommit"> & {
|
|
13
|
+
modelValue?: number[] | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
"onUpdate:modelValue"?: ((value: number[]) => any) | undefined;
|
|
16
|
+
onLayoutChange?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutChangeDetails) => any) | undefined;
|
|
17
|
+
onLayoutCommit?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutCommitDetails) => any) | undefined;
|
|
18
|
+
"onUpdate:layout"?: ((value: number[]) => any) | undefined;
|
|
19
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
layoutChange: (layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutChangeDetails) => true;
|
|
21
|
+
layoutCommit: (layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutCommitDetails) => true;
|
|
22
|
+
} & {
|
|
23
|
+
"update:layout": (value: number[]) => true;
|
|
24
|
+
} & {
|
|
25
|
+
"update:modelValue": (value: number[]) => true;
|
|
26
|
+
}, import("vue").PublicProps, {}, false, {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/resizable").ResizableState>>, {}, {}, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
27
|
+
P: {};
|
|
28
|
+
B: {};
|
|
29
|
+
D: {};
|
|
30
|
+
C: {};
|
|
31
|
+
M: {};
|
|
32
|
+
Defaults: {};
|
|
33
|
+
}, Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/resizable").ResizablePrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, "onLayoutChange" | "onLayoutCommit"> & {
|
|
34
|
+
modelValue?: number[] | undefined;
|
|
35
|
+
} & {
|
|
36
|
+
"onUpdate:modelValue"?: ((value: number[]) => any) | undefined;
|
|
37
|
+
onLayoutChange?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutChangeDetails) => any) | undefined;
|
|
38
|
+
onLayoutCommit?: ((layout: number[], details: import("@ui-sdk/core/resizable").ResizableLayoutCommitDetails) => any) | undefined;
|
|
39
|
+
"onUpdate:layout"?: ((value: number[]) => any) | undefined;
|
|
40
|
+
}, {}, {}, {}, {}, {}>, "div">;
|
|
41
|
+
/**
|
|
42
|
+
* A panel. Its size is written to `--resizable-panel-size` on every frame of a
|
|
43
|
+
* drag, so it never renders for a resize unless its slot reads `size`.
|
|
44
|
+
* @stable
|
|
45
|
+
*/
|
|
46
|
+
declare const ResizablePanel: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/resizable").ResizablePanelProps> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/resizable").ResizablePanelState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/resizable").ResizablePanelProps> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/resizable").ResizablePanelState>>>, "div">;
|
|
47
|
+
/**
|
|
48
|
+
* The handle between two panels: a focusable separator to drag or move with keys.
|
|
49
|
+
* @stable
|
|
50
|
+
*/
|
|
51
|
+
declare const ResizableHandle: Pick<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/resizable").ResizableHandleProps> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/resizable").ResizableHandleState>>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<NoInfer<import("@ui-sdk/core/resizable").ResizableHandleProps> & import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/resizable").ResizableHandleState>>>, "div">;
|
|
52
|
+
export { createResizableController, resizableStorageKey, } from "@ui-sdk/core/resizable";
|
|
53
|
+
export type { ResizableApi, ResizableChangeOptions, ResizableController, ResizableHandleProps, ResizableHandleState, ResizableLayoutChangeDetails, ResizableLayoutChangeReason, ResizableLayoutCommitDetails, ResizableOptions, ResizablePanelProps, ResizablePanelState, ResizablePrimitive, ResizableSize, ResizableState, ResizableStorage, } from "@ui-sdk/core/resizable";
|
|
54
|
+
export { Resizable, ResizableHandle, ResizablePanel };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/resizable.ts
|
|
2
|
+
import { resizable } from "@ui-sdk/core/resizable";
|
|
3
|
+
import { createParts } from "./create-parts.js";
|
|
4
|
+
import {
|
|
5
|
+
createResizableController,
|
|
6
|
+
resizableStorageKey
|
|
7
|
+
} from "@ui-sdk/core/resizable";
|
|
8
|
+
var parts = createParts(resizable, {
|
|
9
|
+
root: "div",
|
|
10
|
+
panel: "div",
|
|
11
|
+
handle: "div"
|
|
12
|
+
});
|
|
13
|
+
var Resizable = parts.Root;
|
|
14
|
+
var ResizablePanel = parts.Panel;
|
|
15
|
+
var ResizableHandle = parts.Handle;
|
|
16
|
+
export {
|
|
17
|
+
Resizable,
|
|
18
|
+
ResizableHandle,
|
|
19
|
+
ResizablePanel,
|
|
20
|
+
createResizableController,
|
|
21
|
+
resizableStorageKey
|
|
22
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
3
|
+
type Orientation = "vertical" | "horizontal";
|
|
4
|
+
/**
|
|
5
|
+
* Groups the parts. The scrollbars are placed against it.
|
|
6
|
+
* @stable
|
|
7
|
+
*/
|
|
8
|
+
declare const ScrollArea: import("./create-parts.js").ElementPart<new (props: Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/scroll-area").ScrollAreaPrimitive> & 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/scroll-area").ScrollAreaPrimitive> & 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/scroll-area").ScrollAreaState>>, {}, {}, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
9
|
+
P: {};
|
|
10
|
+
B: {};
|
|
11
|
+
D: {};
|
|
12
|
+
C: {};
|
|
13
|
+
M: {};
|
|
14
|
+
Defaults: {};
|
|
15
|
+
}, Omit<import("@ui-sdk/core").OptionsOf<import("@ui-sdk/core/scroll-area").ScrollAreaPrimitive> & import("@ui-sdk/core/renderer").BaseSlotProps, never> & {}, {}, {}, {}, {}, {}>, "div">;
|
|
16
|
+
/**
|
|
17
|
+
* The native scroller. Keyboard, wheel, touch, find in page and screen readers scroll it.
|
|
18
|
+
* @stable
|
|
19
|
+
*/
|
|
20
|
+
declare const ScrollAreaViewport: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/scroll-area").ScrollAreaState>>>, 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/scroll-area").ScrollAreaState>>>, "div">;
|
|
21
|
+
/**
|
|
22
|
+
* Wraps the content inside the viewport.
|
|
23
|
+
* @stable
|
|
24
|
+
*/
|
|
25
|
+
declare const ScrollAreaContent: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/scroll-area").ScrollAreaState>>>, 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/scroll-area").ScrollAreaState>>>, "div">;
|
|
26
|
+
/**
|
|
27
|
+
* Where the two scrollbars meet.
|
|
28
|
+
* @stable
|
|
29
|
+
*/
|
|
30
|
+
declare const ScrollAreaCorner: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<{}>>, never> & import("./create-parts.js").ElementConstructor<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<{}>>, "div">;
|
|
31
|
+
/**
|
|
32
|
+
* A button that scrolls to the end, like "Jump to latest". Name it with its content.
|
|
33
|
+
* @stable
|
|
34
|
+
*/
|
|
35
|
+
declare const ScrollAreaScrollToEnd: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/scroll-area").ScrollAreaScrollToEndState>>>, 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/scroll-area").ScrollAreaScrollToEndState>>>, "button">;
|
|
36
|
+
/**
|
|
37
|
+
* A scrollbar for one axis, over the viewport's edge.
|
|
38
|
+
* @stable
|
|
39
|
+
*/
|
|
40
|
+
declare const ScrollAreaScrollbar: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
41
|
+
orientation: {
|
|
42
|
+
type: PropType<Orientation>;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
45
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}>[] | null) & {
|
|
50
|
+
state: NoInfer<import("@ui-sdk/core/scroll-area").ScrollAreaScrollbarState>;
|
|
51
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
52
|
+
orientation: {
|
|
53
|
+
type: PropType<Orientation>;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
}>> & Readonly<{}>, {
|
|
57
|
+
orientation: Orientation;
|
|
58
|
+
}, PartSlots<import("@ui-sdk/core/scroll-area").ScrollAreaPrimitive, "scrollbar">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
59
|
+
/**
|
|
60
|
+
* The part of the scrollbar that shows where the view is, and drags.
|
|
61
|
+
* @stable
|
|
62
|
+
*/
|
|
63
|
+
declare const ScrollAreaThumb: import("./create-parts.js").ElementPart<import("vue").DefineComponent<{}, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
}>[] | null) & {
|
|
68
|
+
state: NoInfer<import("@ui-sdk/core/scroll-area").ScrollAreaThumbState>;
|
|
69
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, PartSlots<import("@ui-sdk/core/scroll-area").ScrollAreaPrimitive, "thumb">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
70
|
+
export { createScrollAreaController } from "@ui-sdk/core/scroll-area";
|
|
71
|
+
export type { ScrollAreaController, ScrollAreaOptions, ScrollAreaPrimitive, ScrollAreaScrollOptions, ScrollAreaScrollToEndState, ScrollAreaScrollbarProps, ScrollAreaScrollbarState, ScrollAreaState, ScrollAreaThumbState, ScrollAreaType, } from "@ui-sdk/core/scroll-area";
|
|
72
|
+
export { ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaScrollbar, ScrollAreaScrollToEnd, ScrollAreaThumb, ScrollAreaViewport, };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/scroll-area.ts
|
|
2
|
+
import { scrollArea } from "@ui-sdk/core/scroll-area";
|
|
3
|
+
import {
|
|
4
|
+
computed,
|
|
5
|
+
defineComponent,
|
|
6
|
+
inject,
|
|
7
|
+
provide
|
|
8
|
+
} from "vue";
|
|
9
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
10
|
+
import { usePart } from "./use-primitive.js";
|
|
11
|
+
import { createScrollAreaController } from "@ui-sdk/core/scroll-area";
|
|
12
|
+
var OrientationKey = /* @__PURE__ */ Symbol(
|
|
13
|
+
"scroll-area-orientation"
|
|
14
|
+
);
|
|
15
|
+
var parts = createParts(scrollArea, {
|
|
16
|
+
root: "div",
|
|
17
|
+
viewport: "div",
|
|
18
|
+
content: "div",
|
|
19
|
+
corner: "div",
|
|
20
|
+
"scroll-to-end": "button"
|
|
21
|
+
});
|
|
22
|
+
var ScrollArea = parts.Root;
|
|
23
|
+
var ScrollAreaViewport = parts.Viewport;
|
|
24
|
+
var ScrollAreaContent = parts.Content;
|
|
25
|
+
var ScrollAreaCorner = parts.Corner;
|
|
26
|
+
var ScrollAreaScrollToEnd = parts.ScrollToEnd;
|
|
27
|
+
var ScrollAreaScrollbar = withElement(
|
|
28
|
+
"div",
|
|
29
|
+
defineComponent({
|
|
30
|
+
name: "ScrollAreaScrollbar",
|
|
31
|
+
inheritAttrs: false,
|
|
32
|
+
props: {
|
|
33
|
+
orientation: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "vertical"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
slots: Object,
|
|
39
|
+
setup(props) {
|
|
40
|
+
const scrollbar = computed(() => ({
|
|
41
|
+
id: props.orientation,
|
|
42
|
+
orientation: props.orientation
|
|
43
|
+
}));
|
|
44
|
+
provide(OrientationKey, () => props.orientation);
|
|
45
|
+
return usePart(scrollArea, "scrollbar", () => scrollbar.value);
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
var ScrollAreaThumb = withElement(
|
|
50
|
+
"div",
|
|
51
|
+
defineComponent({
|
|
52
|
+
name: "ScrollAreaThumb",
|
|
53
|
+
inheritAttrs: false,
|
|
54
|
+
slots: Object,
|
|
55
|
+
setup() {
|
|
56
|
+
const orientation = inject(
|
|
57
|
+
OrientationKey,
|
|
58
|
+
() => "vertical"
|
|
59
|
+
);
|
|
60
|
+
const thumb = computed(() => ({
|
|
61
|
+
id: orientation(),
|
|
62
|
+
orientation: orientation()
|
|
63
|
+
}));
|
|
64
|
+
return usePart(scrollArea, "thumb", () => thumb.value);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
export {
|
|
69
|
+
ScrollArea,
|
|
70
|
+
ScrollAreaContent,
|
|
71
|
+
ScrollAreaCorner,
|
|
72
|
+
ScrollAreaScrollToEnd,
|
|
73
|
+
ScrollAreaScrollbar,
|
|
74
|
+
ScrollAreaThumb,
|
|
75
|
+
ScrollAreaViewport,
|
|
76
|
+
createScrollAreaController
|
|
77
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type SegmentedControlController, type SegmentedControlOrientation, type SegmentedControlValueChangeReason } from "@ui-sdk/core/segmented-control";
|
|
3
|
+
import { type PropType } from "vue";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
/**
|
|
6
|
+
* A row of options where exactly one is on, like a radio group drawn as
|
|
7
|
+
* buttons, with an indicator that slides to the checked item.
|
|
8
|
+
* @experimental
|
|
9
|
+
*/
|
|
10
|
+
declare const SegmentedControl: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
11
|
+
value: {
|
|
12
|
+
type: PropType<string | null>;
|
|
13
|
+
default: undefined;
|
|
14
|
+
};
|
|
15
|
+
modelValue: {
|
|
16
|
+
type: PropType<string | null>;
|
|
17
|
+
default: undefined;
|
|
18
|
+
};
|
|
19
|
+
defaultValue: {
|
|
20
|
+
type: PropType<string | null>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
disabled: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
readOnly: {
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
default: undefined;
|
|
30
|
+
};
|
|
31
|
+
required: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: undefined;
|
|
34
|
+
};
|
|
35
|
+
name: StringConstructor;
|
|
36
|
+
form: StringConstructor;
|
|
37
|
+
loop: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
orientation: PropType<SegmentedControlOrientation>;
|
|
42
|
+
controller: PropType<SegmentedControlController>;
|
|
43
|
+
debug: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
}>, (() => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}>[] | null) & {
|
|
52
|
+
state: NoInfer<{
|
|
53
|
+
value: string | null;
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
readOnly: boolean;
|
|
56
|
+
required: boolean;
|
|
57
|
+
orientation: "horizontal" | "vertical";
|
|
58
|
+
}>;
|
|
59
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
60
|
+
"update:value": (_value: string | null) => true;
|
|
61
|
+
"update:modelValue": (_value: string | null) => true;
|
|
62
|
+
valueChange: (_value: string | null, _details: ChangeDetails<SegmentedControlValueChangeReason>) => true;
|
|
63
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
64
|
+
value: {
|
|
65
|
+
type: PropType<string | null>;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
modelValue: {
|
|
69
|
+
type: PropType<string | null>;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
defaultValue: {
|
|
73
|
+
type: PropType<string | null>;
|
|
74
|
+
default: undefined;
|
|
75
|
+
};
|
|
76
|
+
disabled: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
readOnly: {
|
|
81
|
+
type: BooleanConstructor;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
required: {
|
|
85
|
+
type: BooleanConstructor;
|
|
86
|
+
default: undefined;
|
|
87
|
+
};
|
|
88
|
+
name: StringConstructor;
|
|
89
|
+
form: StringConstructor;
|
|
90
|
+
loop: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: undefined;
|
|
93
|
+
};
|
|
94
|
+
orientation: PropType<SegmentedControlOrientation>;
|
|
95
|
+
controller: PropType<SegmentedControlController>;
|
|
96
|
+
debug: {
|
|
97
|
+
type: BooleanConstructor;
|
|
98
|
+
default: undefined;
|
|
99
|
+
};
|
|
100
|
+
}>> & Readonly<{
|
|
101
|
+
"onUpdate:modelValue"?: ((_value: string | null) => any) | undefined;
|
|
102
|
+
"onUpdate:value"?: ((_value: string | null) => any) | undefined;
|
|
103
|
+
onValueChange?: ((_value: string | null, _details: ChangeDetails<SegmentedControlValueChangeReason>) => any) | undefined;
|
|
104
|
+
}>, {
|
|
105
|
+
value: string | null;
|
|
106
|
+
disabled: boolean;
|
|
107
|
+
debug: boolean;
|
|
108
|
+
defaultValue: string | null;
|
|
109
|
+
required: boolean;
|
|
110
|
+
loop: boolean;
|
|
111
|
+
readOnly: boolean;
|
|
112
|
+
modelValue: string | null;
|
|
113
|
+
}, PartSlots<import("@ui-sdk/core/segmented-control").SegmentedControlPrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "div">;
|
|
114
|
+
/**
|
|
115
|
+
* One option, and the hidden native radio that takes part in the form.
|
|
116
|
+
* @experimental
|
|
117
|
+
*/
|
|
118
|
+
declare const SegmentedControlItem: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
119
|
+
value: {
|
|
120
|
+
type: StringConstructor;
|
|
121
|
+
required: true;
|
|
122
|
+
};
|
|
123
|
+
disabled: {
|
|
124
|
+
type: BooleanConstructor;
|
|
125
|
+
default: undefined;
|
|
126
|
+
};
|
|
127
|
+
}>, () => (import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
128
|
+
[key: string]: any;
|
|
129
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
130
|
+
[key: string]: any;
|
|
131
|
+
}>[] | null)[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
132
|
+
value: {
|
|
133
|
+
type: StringConstructor;
|
|
134
|
+
required: true;
|
|
135
|
+
};
|
|
136
|
+
disabled: {
|
|
137
|
+
type: BooleanConstructor;
|
|
138
|
+
default: undefined;
|
|
139
|
+
};
|
|
140
|
+
}>> & Readonly<{}>, {
|
|
141
|
+
disabled: boolean;
|
|
142
|
+
}, PartSlots<import("@ui-sdk/core/segmented-control").SegmentedControlPrimitive, "item">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "button">;
|
|
143
|
+
/**
|
|
144
|
+
* Sits behind the checked item. Its box comes from the
|
|
145
|
+
* `--segmented-control-indicator-*` variables, measured from the root.
|
|
146
|
+
* @experimental
|
|
147
|
+
*/
|
|
148
|
+
declare const SegmentedControlIndicator: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/segmented-control").SegmentedControlIndicatorState>>>, 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/segmented-control").SegmentedControlIndicatorState>>>, "span">;
|
|
149
|
+
export { createSegmentedControlController } from "@ui-sdk/core/segmented-control";
|
|
150
|
+
export type { SegmentedControlApi, SegmentedControlChangeOptions, SegmentedControlController, SegmentedControlIndicatorState, SegmentedControlItemProps, SegmentedControlItemState, SegmentedControlOptions, SegmentedControlOrientation, SegmentedControlPrimitive, SegmentedControlState, SegmentedControlValueChangeReason, } from "@ui-sdk/core/segmented-control";
|
|
151
|
+
export { SegmentedControl, SegmentedControlIndicator, SegmentedControlItem };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/segmented-control.ts
|
|
2
|
+
import {
|
|
3
|
+
segmentedControl
|
|
4
|
+
} from "@ui-sdk/core/segmented-control";
|
|
5
|
+
import { defineComponent, h } from "vue";
|
|
6
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
7
|
+
import { useFieldControl } from "./field-context.js";
|
|
8
|
+
import { readOnlyOf } from "./text-control.js";
|
|
9
|
+
import {
|
|
10
|
+
optionalBoolean,
|
|
11
|
+
orModel,
|
|
12
|
+
provideProps,
|
|
13
|
+
usePart,
|
|
14
|
+
usePrimitive,
|
|
15
|
+
useScope
|
|
16
|
+
} from "./use-primitive.js";
|
|
17
|
+
import { createSegmentedControlController } from "@ui-sdk/core/segmented-control";
|
|
18
|
+
var parts = createParts(segmentedControl, { indicator: "span" });
|
|
19
|
+
var SegmentedControl = withElement(
|
|
20
|
+
"div",
|
|
21
|
+
defineComponent({
|
|
22
|
+
name: "SegmentedControl",
|
|
23
|
+
inheritAttrs: false,
|
|
24
|
+
props: {
|
|
25
|
+
value: { type: String, default: void 0 },
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: void 0
|
|
29
|
+
},
|
|
30
|
+
defaultValue: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: void 0
|
|
33
|
+
},
|
|
34
|
+
disabled: optionalBoolean,
|
|
35
|
+
readOnly: optionalBoolean,
|
|
36
|
+
required: optionalBoolean,
|
|
37
|
+
name: String,
|
|
38
|
+
form: String,
|
|
39
|
+
loop: optionalBoolean,
|
|
40
|
+
orientation: String,
|
|
41
|
+
controller: Object,
|
|
42
|
+
debug: optionalBoolean
|
|
43
|
+
},
|
|
44
|
+
emits: {
|
|
45
|
+
"update:value": (_value) => true,
|
|
46
|
+
"update:modelValue": (_value) => true,
|
|
47
|
+
valueChange: (_value, _details) => true
|
|
48
|
+
},
|
|
49
|
+
slots: Object,
|
|
50
|
+
setup(props, { attrs, emit }) {
|
|
51
|
+
const field = useFieldControl();
|
|
52
|
+
const control = usePrimitive(segmentedControl, () => ({
|
|
53
|
+
value: orModel(props.value, props.modelValue),
|
|
54
|
+
defaultValue: props.defaultValue,
|
|
55
|
+
disabled: props.disabled || field?.disabled(),
|
|
56
|
+
readOnly: readOnlyOf(props, attrs),
|
|
57
|
+
required: props.required,
|
|
58
|
+
name: props.name ?? field?.name(),
|
|
59
|
+
form: props.form,
|
|
60
|
+
loop: props.loop,
|
|
61
|
+
orientation: props.orientation,
|
|
62
|
+
controller: props.controller,
|
|
63
|
+
debug: props.debug,
|
|
64
|
+
onValueChange: (value, details) => {
|
|
65
|
+
emit("valueChange", value, details);
|
|
66
|
+
if (details.canceled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
emit("update:value", value);
|
|
70
|
+
emit("update:modelValue", value);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
return usePart(control, "root", void 0, void 0, {
|
|
74
|
+
tag: "div",
|
|
75
|
+
extend: field?.props
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
var SegmentedControlItem = withElement(
|
|
81
|
+
"button",
|
|
82
|
+
defineComponent({
|
|
83
|
+
name: "SegmentedControlItem",
|
|
84
|
+
inheritAttrs: false,
|
|
85
|
+
props: {
|
|
86
|
+
value: { type: String, required: true },
|
|
87
|
+
disabled: optionalBoolean
|
|
88
|
+
},
|
|
89
|
+
slots: Object,
|
|
90
|
+
setup(props) {
|
|
91
|
+
const control = useScope(segmentedControl)?.handle;
|
|
92
|
+
if (!control) {
|
|
93
|
+
throw new Error(
|
|
94
|
+
"SegmentedControlItem must be used inside <SegmentedControl>."
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const item = () => ({ value: props.value, disabled: props.disabled });
|
|
98
|
+
provideProps(segmentedControl, "item", item);
|
|
99
|
+
const button = usePart(control, "item", item, void 0, "button");
|
|
100
|
+
return () => [button(), h("input", control.slot("input", item()))];
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
var SegmentedControlIndicator = parts.Indicator;
|
|
105
|
+
export {
|
|
106
|
+
SegmentedControl,
|
|
107
|
+
SegmentedControlIndicator,
|
|
108
|
+
SegmentedControlItem,
|
|
109
|
+
createSegmentedControlController
|
|
110
|
+
};
|