87 lines
2.8 KiB
JavaScript
87 lines
2.8 KiB
JavaScript
import {
|
|
getCurrentInstance,
|
|
toKebabCase
|
|
} from "./chunk-I4KGD5X4.js";
|
|
import {
|
|
computed,
|
|
effectScope,
|
|
onScopeDispose,
|
|
ref,
|
|
toRaw,
|
|
watch
|
|
} from "./chunk-PD2AWGJV.js";
|
|
|
|
// node_modules/vuetify/lib/composables/toggleScope.mjs
|
|
function useToggleScope(source, fn) {
|
|
let scope;
|
|
function start() {
|
|
scope = effectScope();
|
|
scope.run(() => fn.length ? fn(() => {
|
|
scope == null ? void 0 : scope.stop();
|
|
start();
|
|
}) : fn());
|
|
}
|
|
watch(source, (active) => {
|
|
if (active && !scope) {
|
|
start();
|
|
} else if (!active) {
|
|
scope == null ? void 0 : scope.stop();
|
|
scope = void 0;
|
|
}
|
|
}, {
|
|
immediate: true
|
|
});
|
|
onScopeDispose(() => {
|
|
scope == null ? void 0 : scope.stop();
|
|
});
|
|
}
|
|
|
|
// node_modules/vuetify/lib/composables/proxiedModel.mjs
|
|
function useProxiedModel(props, prop, defaultValue) {
|
|
let transformIn = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : (v) => v;
|
|
let transformOut = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : (v) => v;
|
|
const vm = getCurrentInstance("useProxiedModel");
|
|
const internal = ref(props[prop] !== void 0 ? props[prop] : defaultValue);
|
|
const kebabProp = toKebabCase(prop);
|
|
const checkKebab = kebabProp !== prop;
|
|
const isControlled = checkKebab ? computed(() => {
|
|
var _a, _b, _c, _d;
|
|
void props[prop];
|
|
return !!((((_a = vm.vnode.props) == null ? void 0 : _a.hasOwnProperty(prop)) || ((_b = vm.vnode.props) == null ? void 0 : _b.hasOwnProperty(kebabProp))) && (((_c = vm.vnode.props) == null ? void 0 : _c.hasOwnProperty(`onUpdate:${prop}`)) || ((_d = vm.vnode.props) == null ? void 0 : _d.hasOwnProperty(`onUpdate:${kebabProp}`))));
|
|
}) : computed(() => {
|
|
var _a, _b;
|
|
void props[prop];
|
|
return !!(((_a = vm.vnode.props) == null ? void 0 : _a.hasOwnProperty(prop)) && ((_b = vm.vnode.props) == null ? void 0 : _b.hasOwnProperty(`onUpdate:${prop}`)));
|
|
});
|
|
useToggleScope(() => !isControlled.value, () => {
|
|
watch(() => props[prop], (val) => {
|
|
internal.value = val;
|
|
});
|
|
});
|
|
const model = computed({
|
|
get() {
|
|
const externalValue = props[prop];
|
|
return transformIn(isControlled.value ? externalValue : internal.value);
|
|
},
|
|
set(internalValue) {
|
|
const newValue = transformOut(internalValue);
|
|
const value = toRaw(isControlled.value ? props[prop] : internal.value);
|
|
if (value === newValue || transformIn(value) === internalValue) {
|
|
return;
|
|
}
|
|
internal.value = newValue;
|
|
vm == null ? void 0 : vm.emit(`update:${prop}`, newValue);
|
|
}
|
|
});
|
|
Object.defineProperty(model, "externalValue", {
|
|
get: () => isControlled.value ? props[prop] : internal.value
|
|
});
|
|
return model;
|
|
}
|
|
|
|
export {
|
|
useToggleScope,
|
|
useProxiedModel
|
|
};
|
|
//# sourceMappingURL=chunk-PVQHDZXM.js.map
|