UNPKG

mt-ui-components-vue3

Version:

玛果添实UI组件库(Vue3)

109 lines 4.07 kB
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", "watch": "setup-const", "reactive": "setup-const", "inject": "setup-const", "ref": "setup-const", "PopconfirmModal": "setup-maybe-ref", "Form": "setup-maybe-ref", "StringItem": "setup-const", "Icon": "setup-const", "FULL_CODE": "setup-maybe-ref", "emit": "setup-const", "props": "setup-reactive-const", "fullRef": "setup-maybe-ref", "formRef": "setup-ref", "formData": "setup-reactive-const", "confirm": "setup-const", "cancel": "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 { watch, reactive, inject, ref } from 'vue'; import { PopconfirmModal, Form } from '../../../components'; import StringItem from './StringItem.js'; import Icon from '../Icon.js'; import { FULL_CODE } from '../../index'; const __sfc_main__ = _defineComponent({ props: { value: { type: Number, default: undefined, }, placement: { type: String, default: 'top', }, }, emits: ['update:value', 'confirm', 'cancel'], setup(__props, { emit }) { const props = __props; const fullRef = inject(FULL_CODE); const formRef = ref(); const formData = reactive({ maxLength: props.value, }); const confirm = () => { emit('update:value', formData.maxLength); emit('confirm', formData.maxLength); }; const cancel = () => { _optionalChain([formRef, 'access', _2 => _2.value, 'optionalAccess', _3 => _3.resetFields, 'call', _4 => _4()]); formData.maxLength = props.value; emit('cancel'); }; watch(() => props.value, () => { formData.maxLength = props.value; }); return (_ctx, _cache) => { return (_openBlock(), _createBlock(_unref(PopconfirmModal), { "body-style": "padding-top:4px;", placement: __props.placement, "get-popup-container": (node) => _unref(fullRef) || node, onConfirm: confirm, onCancel: cancel }, { content: _withCtx(() => [ _createVNode(_unref(Form), { ref_key: "formRef", ref: formRef, layout: "vertical", model: formData }, { default: _withCtx(() => [ _createVNode(StringItem, { value: formData.maxLength, "onUpdate:value": _cache[0] || (_cache[0] = ($event) => ((formData.maxLength) = $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__;