UNPKG

tdesign-mobile-vue

Version:
61 lines (57 loc) 2.76 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ import { getCurrentInstance, ref } from 'vue'; import { k as kebabCase_1 } from '../../_chunks/dep-6917b9bc.mjs'; import '../../_chunks/dep-8bf3054e.mjs'; import '../../_chunks/dep-b437ef0b.mjs'; import '../../_chunks/dep-8140c29b.mjs'; import '../../_chunks/dep-3d249f65.mjs'; import '../../_chunks/dep-620d73f7.mjs'; import '../../_chunks/dep-0d52e58f.mjs'; import '../../_chunks/dep-019e292f.mjs'; import '../../_chunks/dep-32364550.mjs'; import '../../_chunks/dep-a836a38c.mjs'; import '../../_chunks/dep-9b2de386.mjs'; function useVModel(value, modelValue, defaultValue, onChange) { var propName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "value"; var _getCurrentInstance = getCurrentInstance(), emit = _getCurrentInstance.emit, vnode = _getCurrentInstance.vnode; var internalValue = ref(); internalValue.value = defaultValue; var vProps = vnode.props || {}; var isVM = Object.prototype.hasOwnProperty.call(vProps, "modelValue") || Object.prototype.hasOwnProperty.call(vProps, "model-value"); var isVMP = Object.prototype.hasOwnProperty.call(vProps, propName) || Object.prototype.hasOwnProperty.call(vProps, kebabCase_1(propName)); if (isVMP || typeof value.value !== "undefined") { return [value, function (newValue) { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } emit === null || emit === void 0 || emit.apply(void 0, ["update:".concat(propName), newValue].concat(args)); onChange === null || onChange === void 0 || onChange.apply(void 0, [newValue].concat(args)); }]; } if (isVM || typeof modelValue.value !== "undefined") { return [modelValue, function (newValue) { for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } emit === null || emit === void 0 || emit.apply(void 0, ["update:modelValue", newValue].concat(args)); onChange === null || onChange === void 0 || onChange.apply(void 0, [newValue].concat(args)); }]; } return [internalValue, function (newValue) { internalValue.value = newValue; for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { args[_key3 - 1] = arguments[_key3]; } onChange === null || onChange === void 0 || onChange.apply(void 0, [newValue].concat(args)); }]; } var UPDATE_MODEL = "update:modelValue"; var UPDATE_VALUE = "update:value"; export { UPDATE_MODEL, UPDATE_VALUE, useVModel }; //# sourceMappingURL=index.mjs.map