mt-ui-components-vue3
Version:
玛果添实UI组件库(Vue3)
109 lines • 4.05 kB
JavaScript
function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
const op = ops[i];
const fn = ops[i + 1];
i += 2;
if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
return undefined;
}
if (op === 'access' || op === 'optionalAccess') {
lastAccessLHS = value;
value = fn(value);
}
else if (op === 'call' || op === 'optionalCall') {
value = fn((...args) => value.call(lastAccessLHS, ...args));
lastAccessLHS = undefined;
}
} return value; }
/* Analyzed bindings: {
"value": "props",
"placement": "props",
"inject": "setup-const",
"reactive": "setup-const",
"ref": "setup-const",
"watch": "setup-const",
"Form": "setup-maybe-ref",
"PopconfirmModal": "setup-maybe-ref",
"DataItem": "setup-const",
"Icon": "setup-const",
"FULL_CODE": "setup-maybe-ref",
"emit": "setup-const",
"props": "setup-reactive-const",
"formRef": "setup-ref",
"fullRef": "setup-maybe-ref",
"formData": "setup-reactive-const",
"cancel": "setup-const",
"confirm": "setup-const"
} */
import { defineComponent as _defineComponent } from 'vue';
import { unref as _unref, createVNode as _createVNode, withCtx as _withCtx, renderSlot as _renderSlot, openBlock as _openBlock, createBlock as _createBlock } from "vue";
import { inject, reactive, ref, watch } from 'vue';
import { Form, PopconfirmModal } from '../../../components';
import DataItem from './DataItem.js';
import Icon from '../Icon.js';
import { FULL_CODE } from '../../index';
const __sfc_main__ = _defineComponent({
props: {
value: {
type: String,
default: undefined,
},
placement: {
type: String,
default: 'top',
},
},
emits: ["update:value", "confirm", "cancel"],
setup(__props, { emit }) {
const props = __props;
const formRef = ref();
const fullRef = inject(FULL_CODE);
const formData = reactive({
format: props.value,
});
const cancel = () => {
_optionalChain([formRef, 'access', _2 => _2.value, 'optionalAccess', _3 => _3.resetFields, 'call', _4 => _4()]);
formData.format = props.value;
emit('cancel');
};
const confirm = () => {
emit('update:value', formData.format);
emit('confirm', formData.format);
};
watch(() => props.value, () => {
formData.format = props.value;
});
return (_ctx, _cache) => {
return (_openBlock(), _createBlock(_unref(PopconfirmModal), {
"body-style": "padding-top:4px; width: 260px;",
placement: __props.placement,
"get-popup-container": (node) => _unref(fullRef) || node,
onConfirm: confirm,
onCancel: cancel
}, {
content: _withCtx(() => [
_createVNode(_unref(Form), {
ref_key: "formRef",
ref: formRef,
model: formData,
layout: "vertical"
}, {
default: _withCtx(() => [
_createVNode(DataItem, {
value: formData.format,
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((formData.format) = $event))
}, null, 8 /* PROPS */, ["value"])
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["model"])
]),
default: _withCtx(() => [
_renderSlot(_ctx.$slots, "default", {}, () => [
_createVNode(Icon)
])
]),
_: 3 /* FORWARDED */
}, 8 /* PROPS */, ["placement", "get-popup-container"]));
};
}
});
export default __sfc_main__;