145 lines
5.8 KiB
JavaScript
145 lines
5.8 KiB
JavaScript
import { Dt as mergeProps, Kn as ref, M as Fragment, Qn as toRef, W as createBaseVNode, ar as normalizeClass, cn as useId, et as createVNode, sr as normalizeStyle } from "./vue.runtime.esm-bundler-BvoXUmaf.js";
|
|
import { E as filterInputAttrs, ot as SUPPORTS_MATCH_MEDIA, r as genericComponent, u as propsFactory } from "./defineComponent-D5UWd5Vb.js";
|
|
import { t as useRender } from "./useRender-DB_YiTtB.js";
|
|
import { t as VIcon } from "./VIcon-DqvHH35X.js";
|
|
import { t as useProxiedModel } from "./proxiedModel-BOZtsMxA.js";
|
|
import { t as VDefaultsProvider } from "./VDefaultsProvider-C3Dl0By9.js";
|
|
import { c as VScaleTransition } from "./transitions-llwxsiay.js";
|
|
import { t as forwardRefs } from "./forwardRefs-C50LZ3ti.js";
|
|
import { t as VProgressCircular } from "./VProgressCircular-z2FRmexp.js";
|
|
import { r as useLoader, t as LoaderSlot } from "./loader-Dn_UJdiG.js";
|
|
import { a as useFocus, n as VInput, r as makeVInputProps } from "./VLabel-BK6j7Ce3.js";
|
|
import { n as makeVSelectionControlProps, t as VSelectionControl } from "./VSelectionControl-DGk6dNy-.js";
|
|
import "/Users/thackmaster/Development/routie2/frontend/node_modules/vuetify/lib/components/VSwitch/VSwitch.css";
|
|
//#region node_modules/vuetify/lib/components/VSwitch/VSwitch.js
|
|
var makeVSwitchProps = propsFactory({
|
|
indeterminate: Boolean,
|
|
inset: Boolean,
|
|
flat: Boolean,
|
|
loading: {
|
|
type: [Boolean, String],
|
|
default: false
|
|
},
|
|
...makeVInputProps(),
|
|
...makeVSelectionControlProps()
|
|
}, "VSwitch");
|
|
var VSwitch = genericComponent()({
|
|
name: "VSwitch",
|
|
inheritAttrs: false,
|
|
props: makeVSwitchProps(),
|
|
emits: {
|
|
"update:focused": (focused) => true,
|
|
"update:modelValue": (value) => true,
|
|
"update:indeterminate": (value) => true
|
|
},
|
|
setup(props, { attrs, slots }) {
|
|
const indeterminate = useProxiedModel(props, "indeterminate");
|
|
const model = useProxiedModel(props, "modelValue");
|
|
const { loaderClasses } = useLoader(props);
|
|
const { isFocused, focus, blur } = useFocus(props);
|
|
const control = ref();
|
|
const inputRef = ref();
|
|
const isForcedColorsModeActive = SUPPORTS_MATCH_MEDIA && window.matchMedia("(forced-colors: active)").matches;
|
|
const loaderColor = toRef(() => {
|
|
return typeof props.loading === "string" && props.loading !== "" ? props.loading : props.color;
|
|
});
|
|
const uid = useId();
|
|
const id = toRef(() => props.id || `switch-${uid}`);
|
|
function onChange() {
|
|
if (indeterminate.value) indeterminate.value = false;
|
|
}
|
|
function onTrackClick(e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
control.value?.input?.click();
|
|
}
|
|
useRender(() => {
|
|
const [rootAttrs, controlAttrs] = filterInputAttrs(attrs);
|
|
const inputProps = VInput.filterProps(props);
|
|
const controlProps = VSelectionControl.filterProps(props);
|
|
return createVNode(VInput, mergeProps({
|
|
"ref": inputRef,
|
|
"class": [
|
|
"v-switch",
|
|
{ "v-switch--flat": props.flat },
|
|
{ "v-switch--inset": props.inset },
|
|
{ "v-switch--indeterminate": indeterminate.value },
|
|
loaderClasses.value,
|
|
props.class
|
|
]
|
|
}, rootAttrs, inputProps, {
|
|
"modelValue": model.value,
|
|
"onUpdate:modelValue": ($event) => model.value = $event,
|
|
"id": id.value,
|
|
"focused": isFocused.value,
|
|
"style": props.style
|
|
}), {
|
|
...slots,
|
|
default: ({ id, messagesId, isDisabled, isReadonly, isValid }) => {
|
|
const slotProps = {
|
|
model,
|
|
isValid
|
|
};
|
|
return createVNode(VSelectionControl, mergeProps({ "ref": control }, controlProps, {
|
|
"modelValue": model.value,
|
|
"onUpdate:modelValue": [($event) => model.value = $event, onChange],
|
|
"id": id.value,
|
|
"aria-describedby": messagesId.value,
|
|
"type": "checkbox",
|
|
"aria-checked": indeterminate.value ? "mixed" : void 0,
|
|
"disabled": isDisabled.value,
|
|
"readonly": isReadonly.value,
|
|
"onFocus": focus,
|
|
"onBlur": blur
|
|
}, controlAttrs), {
|
|
...slots,
|
|
default: ({ backgroundColorClasses, backgroundColorStyles }) => createBaseVNode("div", {
|
|
"class": normalizeClass(["v-switch__track", !isForcedColorsModeActive ? backgroundColorClasses.value : void 0]),
|
|
"style": normalizeStyle(backgroundColorStyles.value),
|
|
"onClick": onTrackClick
|
|
}, [slots["track-true"] && createBaseVNode("div", {
|
|
"key": "prepend",
|
|
"class": "v-switch__track-true"
|
|
}, [slots["track-true"](slotProps)]), slots["track-false"] && createBaseVNode("div", {
|
|
"key": "append",
|
|
"class": "v-switch__track-false"
|
|
}, [slots["track-false"](slotProps)])]),
|
|
input: ({ inputNode, icon, backgroundColorClasses, backgroundColorStyles }) => createBaseVNode(Fragment, null, [inputNode, createBaseVNode("div", {
|
|
"class": normalizeClass([
|
|
"v-switch__thumb",
|
|
{ "v-switch__thumb--filled": icon || props.loading },
|
|
props.inset || isForcedColorsModeActive ? void 0 : backgroundColorClasses.value
|
|
]),
|
|
"style": normalizeStyle(props.inset ? void 0 : backgroundColorStyles.value)
|
|
}, [slots.thumb ? createVNode(VDefaultsProvider, { "defaults": { VIcon: {
|
|
icon,
|
|
size: "x-small"
|
|
} } }, { default: () => [slots.thumb({
|
|
...slotProps,
|
|
icon
|
|
})] }) : createVNode(VScaleTransition, null, { default: () => [!props.loading ? icon && createVNode(VIcon, {
|
|
"key": String(icon),
|
|
"icon": icon,
|
|
"size": "x-small"
|
|
}, null) : createVNode(LoaderSlot, {
|
|
"name": "v-switch",
|
|
"active": true,
|
|
"color": isValid.value === false ? void 0 : loaderColor.value
|
|
}, { default: (slotProps) => slots.loader ? slots.loader(slotProps) : createVNode(VProgressCircular, {
|
|
"active": slotProps.isActive,
|
|
"color": slotProps.color,
|
|
"indeterminate": true,
|
|
"size": "16",
|
|
"width": "2"
|
|
}, null) })] })])])
|
|
});
|
|
}
|
|
});
|
|
});
|
|
return forwardRefs({}, inputRef);
|
|
}
|
|
});
|
|
//#endregion
|
|
export { VSwitch };
|
|
|
|
//# sourceMappingURL=vuetify_components_VSwitch.js.map
|