@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/slider.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// src/slider.ts
|
|
2
|
+
import {
|
|
3
|
+
slider as sliderPrimitive
|
|
4
|
+
} from "@ui-sdk/core/slider";
|
|
5
|
+
import {
|
|
6
|
+
computed,
|
|
7
|
+
defineComponent,
|
|
8
|
+
h,
|
|
9
|
+
inject,
|
|
10
|
+
provide
|
|
11
|
+
} from "vue";
|
|
12
|
+
import { slotContent } from "./children.js";
|
|
13
|
+
import { useFieldControl, useFieldControlId } from "./field-context.js";
|
|
14
|
+
import {
|
|
15
|
+
createParts,
|
|
16
|
+
withElement
|
|
17
|
+
} from "./create-parts.js";
|
|
18
|
+
import {
|
|
19
|
+
optionalBoolean,
|
|
20
|
+
orModel,
|
|
21
|
+
useHandle,
|
|
22
|
+
usePart,
|
|
23
|
+
usePrimitive
|
|
24
|
+
} from "./use-primitive.js";
|
|
25
|
+
import { createSliderController } from "@ui-sdk/core/slider";
|
|
26
|
+
var ThumbFieldKey = /* @__PURE__ */ Symbol("slider-field");
|
|
27
|
+
var useSlider = () => useHandle(sliderPrimitive);
|
|
28
|
+
var parts = createParts(sliderPrimitive, {
|
|
29
|
+
control: "div",
|
|
30
|
+
track: "div",
|
|
31
|
+
indicator: "div"
|
|
32
|
+
});
|
|
33
|
+
var SliderInput = defineComponent({
|
|
34
|
+
name: "SliderInput",
|
|
35
|
+
setup() {
|
|
36
|
+
const slider = useSlider();
|
|
37
|
+
return () => h("input", slider.slot("input"));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
var Slider = defineComponent({
|
|
41
|
+
name: "Slider",
|
|
42
|
+
inheritAttrs: false,
|
|
43
|
+
props: {
|
|
44
|
+
value: { type: [Number, Array], default: void 0 },
|
|
45
|
+
modelValue: {
|
|
46
|
+
type: [Number, Array],
|
|
47
|
+
default: void 0
|
|
48
|
+
},
|
|
49
|
+
defaultValue: {
|
|
50
|
+
type: [Number, Array],
|
|
51
|
+
default: void 0
|
|
52
|
+
},
|
|
53
|
+
min: Number,
|
|
54
|
+
max: Number,
|
|
55
|
+
step: Number,
|
|
56
|
+
largeStep: Number,
|
|
57
|
+
minStepsBetweenThumbs: Number,
|
|
58
|
+
orientation: String,
|
|
59
|
+
disabled: optionalBoolean,
|
|
60
|
+
readOnly: optionalBoolean,
|
|
61
|
+
required: optionalBoolean,
|
|
62
|
+
name: String,
|
|
63
|
+
form: String,
|
|
64
|
+
format: [Object, Function],
|
|
65
|
+
locale: String,
|
|
66
|
+
controller: Object,
|
|
67
|
+
debug: optionalBoolean
|
|
68
|
+
},
|
|
69
|
+
emits: {
|
|
70
|
+
"update:value": (_value) => true,
|
|
71
|
+
"update:modelValue": (_value) => true,
|
|
72
|
+
valueChange: (_value, _details) => true,
|
|
73
|
+
valueCommit: (_value, _details) => true
|
|
74
|
+
},
|
|
75
|
+
slots: Object,
|
|
76
|
+
setup(props, { slots, emit }) {
|
|
77
|
+
const field = useFieldControl();
|
|
78
|
+
const controlId = useFieldControlId();
|
|
79
|
+
const model = () => orModel(props.value, props.modelValue);
|
|
80
|
+
const slider = usePrimitive(sliderPrimitive, () => ({
|
|
81
|
+
value: model(),
|
|
82
|
+
defaultValue: props.defaultValue,
|
|
83
|
+
min: props.min,
|
|
84
|
+
max: props.max,
|
|
85
|
+
step: props.step,
|
|
86
|
+
largeStep: props.largeStep,
|
|
87
|
+
minStepsBetweenThumbs: props.minStepsBetweenThumbs,
|
|
88
|
+
orientation: props.orientation,
|
|
89
|
+
disabled: props.disabled || field?.disabled(),
|
|
90
|
+
readOnly: props.readOnly,
|
|
91
|
+
required: props.required,
|
|
92
|
+
name: props.name ?? field?.name(),
|
|
93
|
+
form: props.form,
|
|
94
|
+
format: props.format,
|
|
95
|
+
locale: props.locale,
|
|
96
|
+
controller: props.controller,
|
|
97
|
+
thumbInputId: controlId,
|
|
98
|
+
debug: props.debug,
|
|
99
|
+
onValueChange: (value, details) => {
|
|
100
|
+
emit("valueChange", value, details);
|
|
101
|
+
if (details.canceled) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
emit("update:value", value);
|
|
105
|
+
emit("update:modelValue", value);
|
|
106
|
+
},
|
|
107
|
+
onValueCommit: (value, details) => emit("valueCommit", value, details)
|
|
108
|
+
}));
|
|
109
|
+
const isRange = computed(() => {
|
|
110
|
+
const shape = model() ?? props.defaultValue;
|
|
111
|
+
return Array.isArray(shape) && shape.length > 1;
|
|
112
|
+
});
|
|
113
|
+
provide(ThumbFieldKey, () => isRange.value ? null : field);
|
|
114
|
+
return usePart(slider, "root", void 0, void 0, {
|
|
115
|
+
tag: "div",
|
|
116
|
+
children: (state) => [slots.default?.({ state }), h(SliderInput)],
|
|
117
|
+
extend: (root) => isRange.value && field ? field.props(root) : root
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var SliderControl = parts.Control;
|
|
122
|
+
var SliderTrack = parts.Track;
|
|
123
|
+
var SliderIndicator = parts.Indicator;
|
|
124
|
+
var inputAttributes = ["aria-label", "aria-labelledby", "aria-describedby"];
|
|
125
|
+
var SliderThumbInput = defineComponent({
|
|
126
|
+
name: "SliderThumbInput",
|
|
127
|
+
inheritAttrs: false,
|
|
128
|
+
props: { index: { type: Number, required: true } },
|
|
129
|
+
setup(props, { attrs }) {
|
|
130
|
+
const slider = useSlider();
|
|
131
|
+
const thumbField = inject(ThumbFieldKey, () => null);
|
|
132
|
+
return () => {
|
|
133
|
+
const input = slider.slot(
|
|
134
|
+
"thumb-input",
|
|
135
|
+
{ index: props.index, id: String(props.index) },
|
|
136
|
+
attrs
|
|
137
|
+
);
|
|
138
|
+
const field = thumbField();
|
|
139
|
+
return h("input", field ? field.props(input) : input);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
var SliderThumb = withElement(
|
|
144
|
+
"div",
|
|
145
|
+
defineComponent({
|
|
146
|
+
name: "SliderThumb",
|
|
147
|
+
inheritAttrs: false,
|
|
148
|
+
props: { index: { type: Number, default: 0 } },
|
|
149
|
+
slots: Object,
|
|
150
|
+
setup(props, { slots, attrs }) {
|
|
151
|
+
const thumb = () => ({ index: props.index, id: String(props.index) });
|
|
152
|
+
let named = {};
|
|
153
|
+
const own = () => {
|
|
154
|
+
const rest = {};
|
|
155
|
+
named = {};
|
|
156
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
157
|
+
;
|
|
158
|
+
(inputAttributes.includes(key) ? named : rest)[key] = value;
|
|
159
|
+
}
|
|
160
|
+
return rest;
|
|
161
|
+
};
|
|
162
|
+
return usePart(useSlider(), "thumb", thumb, own, {
|
|
163
|
+
tag: "div",
|
|
164
|
+
children: (state) => [
|
|
165
|
+
slots.default?.({ state }),
|
|
166
|
+
h(SliderThumbInput, { index: props.index, ...named })
|
|
167
|
+
]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
var SliderValue = withElement(
|
|
173
|
+
"output",
|
|
174
|
+
defineComponent({
|
|
175
|
+
name: "SliderValue",
|
|
176
|
+
inheritAttrs: false,
|
|
177
|
+
slots: Object,
|
|
178
|
+
setup(_, { slots }) {
|
|
179
|
+
return usePart(useSlider(), "value", void 0, void 0, {
|
|
180
|
+
tag: "output",
|
|
181
|
+
children: (state) => slotContent(slots.default, { state }) ?? state.text
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
export {
|
|
187
|
+
Slider,
|
|
188
|
+
SliderControl,
|
|
189
|
+
SliderIndicator,
|
|
190
|
+
SliderThumb,
|
|
191
|
+
SliderTrack,
|
|
192
|
+
SliderValue,
|
|
193
|
+
createSliderController
|
|
194
|
+
};
|
package/dist/switch.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ChangeDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type SwitchCheckedChangeReason, type SwitchController } from "@ui-sdk/core/switch";
|
|
3
|
+
import { type PropType } from "vue";
|
|
4
|
+
import { type PartSlots } from "./use-primitive.js";
|
|
5
|
+
/**
|
|
6
|
+
* A control that turns a setting on or off, with the hidden native input that takes part in the form.
|
|
7
|
+
* @stable
|
|
8
|
+
*/
|
|
9
|
+
declare const Switch: import("./create-parts.js").ElementPart<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
disabled: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: undefined;
|
|
13
|
+
};
|
|
14
|
+
readOnly: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: undefined;
|
|
17
|
+
};
|
|
18
|
+
required: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
name: StringConstructor;
|
|
23
|
+
value: StringConstructor;
|
|
24
|
+
form: StringConstructor;
|
|
25
|
+
debug: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
checked: {
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
modelValue: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
defaultChecked: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
controller: PropType<SwitchController>;
|
|
42
|
+
}>, () => (import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}>[] | null)[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
47
|
+
"update:checked": (_checked: boolean) => true;
|
|
48
|
+
"update:modelValue": (_checked: boolean) => true;
|
|
49
|
+
checkedChange: (_checked: boolean, _details: ChangeDetails<SwitchCheckedChangeReason>) => true;
|
|
50
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
51
|
+
disabled: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: undefined;
|
|
54
|
+
};
|
|
55
|
+
readOnly: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: undefined;
|
|
58
|
+
};
|
|
59
|
+
required: {
|
|
60
|
+
type: BooleanConstructor;
|
|
61
|
+
default: undefined;
|
|
62
|
+
};
|
|
63
|
+
name: StringConstructor;
|
|
64
|
+
value: StringConstructor;
|
|
65
|
+
form: StringConstructor;
|
|
66
|
+
debug: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
checked: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
74
|
+
modelValue: {
|
|
75
|
+
type: BooleanConstructor;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
defaultChecked: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
default: undefined;
|
|
81
|
+
};
|
|
82
|
+
controller: PropType<SwitchController>;
|
|
83
|
+
}>> & Readonly<{
|
|
84
|
+
"onUpdate:modelValue"?: ((_checked: boolean) => any) | undefined;
|
|
85
|
+
"onUpdate:checked"?: ((_checked: boolean) => any) | undefined;
|
|
86
|
+
onCheckedChange?: ((_checked: boolean, _details: ChangeDetails<import("@ui-sdk/core/checkbox").CheckboxCheckedChangeReason>) => any) | undefined;
|
|
87
|
+
}>, {
|
|
88
|
+
disabled: boolean;
|
|
89
|
+
debug: boolean;
|
|
90
|
+
checked: boolean;
|
|
91
|
+
required: boolean;
|
|
92
|
+
readOnly: boolean;
|
|
93
|
+
defaultChecked: boolean;
|
|
94
|
+
modelValue: boolean;
|
|
95
|
+
}, PartSlots<import("@ui-sdk/core/switch").SwitchPrimitive, "root">, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, "button">;
|
|
96
|
+
/**
|
|
97
|
+
* The thumb that slides along the switch as it turns on or off.
|
|
98
|
+
* @stable
|
|
99
|
+
*/
|
|
100
|
+
declare const SwitchThumb: Pick<import("vue").DefineSetupFnComponent<Omit<import("@ui-sdk/core/renderer").BaseSlotProps, never>, {} & {}, import("./use-primitive.js").StateSlots<NoInfer<import("@ui-sdk/core/switch").SwitchState>>>, 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/switch").SwitchState>>>, "span">;
|
|
101
|
+
export { createSwitchController } from "@ui-sdk/core/switch";
|
|
102
|
+
export type { SwitchApi, SwitchCheckedChangeReason, SwitchController, SwitchOptions, SwitchPrimitive, SwitchState, SwitchThumbState, } from "@ui-sdk/core/switch";
|
|
103
|
+
export { Switch, SwitchThumb };
|
package/dist/switch.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/switch.ts
|
|
2
|
+
import {
|
|
3
|
+
switchPrimitive
|
|
4
|
+
} from "@ui-sdk/core/switch";
|
|
5
|
+
import { defineComponent, h } from "vue";
|
|
6
|
+
import { useFieldControl } from "./field-context.js";
|
|
7
|
+
import { toggleProps } from "./toggle-props.js";
|
|
8
|
+
import { createParts, withElement } from "./create-parts.js";
|
|
9
|
+
import {
|
|
10
|
+
optionalBoolean,
|
|
11
|
+
orModel,
|
|
12
|
+
usePart,
|
|
13
|
+
usePrimitive
|
|
14
|
+
} from "./use-primitive.js";
|
|
15
|
+
import { readOnlyOf } from "./text-control.js";
|
|
16
|
+
import { createSwitchController } from "@ui-sdk/core/switch";
|
|
17
|
+
var parts = createParts(switchPrimitive, { thumb: "span" });
|
|
18
|
+
var Switch = withElement(
|
|
19
|
+
"button",
|
|
20
|
+
defineComponent({
|
|
21
|
+
name: "Switch",
|
|
22
|
+
inheritAttrs: false,
|
|
23
|
+
props: {
|
|
24
|
+
checked: optionalBoolean,
|
|
25
|
+
modelValue: optionalBoolean,
|
|
26
|
+
defaultChecked: optionalBoolean,
|
|
27
|
+
controller: Object,
|
|
28
|
+
...toggleProps
|
|
29
|
+
},
|
|
30
|
+
emits: {
|
|
31
|
+
"update:checked": (_checked) => true,
|
|
32
|
+
"update:modelValue": (_checked) => true,
|
|
33
|
+
checkedChange: (_checked, _details) => true
|
|
34
|
+
},
|
|
35
|
+
slots: Object,
|
|
36
|
+
setup(props, { attrs, emit }) {
|
|
37
|
+
const field = useFieldControl();
|
|
38
|
+
const control = usePrimitive(switchPrimitive, () => ({
|
|
39
|
+
checked: orModel(props.checked, props.modelValue),
|
|
40
|
+
defaultChecked: props.defaultChecked,
|
|
41
|
+
disabled: props.disabled || field?.disabled(),
|
|
42
|
+
readOnly: readOnlyOf(props, attrs),
|
|
43
|
+
required: props.required,
|
|
44
|
+
name: props.name ?? field?.name(),
|
|
45
|
+
value: props.value,
|
|
46
|
+
form: props.form,
|
|
47
|
+
controller: props.controller,
|
|
48
|
+
debug: props.debug,
|
|
49
|
+
onCheckedChange: (checked, details) => {
|
|
50
|
+
emit("checkedChange", checked, details);
|
|
51
|
+
if (details.canceled) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
emit("update:checked", checked);
|
|
55
|
+
emit("update:modelValue", checked);
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
const root = usePart(control, "root", void 0, void 0, {
|
|
59
|
+
tag: "button",
|
|
60
|
+
extend: field?.props
|
|
61
|
+
});
|
|
62
|
+
return () => [root(), h("input", control.slot("input"))];
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
);
|
|
66
|
+
var SwitchThumb = parts.Thumb;
|
|
67
|
+
export {
|
|
68
|
+
Switch,
|
|
69
|
+
SwitchThumb,
|
|
70
|
+
createSwitchController
|
|
71
|
+
};
|