tav-ui
Version:
141 lines (138 loc) • 5.54 kB
JavaScript
import { defineComponent, computed, resolveComponent, openBlock, createBlock, normalizeProps, mergeProps, withCtx, createElementVNode, normalizeStyle, createVNode, renderSlot, createTextVNode, toDisplayString, createCommentVNode } from 'vue';
import { Form, Col } from 'ant-design-vue';
import { propTypes } from '../../../../utils/propTypes2.mjs';
import { TaBasicArrow } from '../../../basic-arrow/index2.mjs';
import { TaButton } from '../../../button/index2.mjs';
import '../../../../locales/index2.mjs';
import { useFormContext } from '../hooks/useFormContext2.mjs';
import _export_sfc from '../../../../../_virtual/plugin-vue_export-helper.mjs';
import { tavI18n } from '../../../../locales/transfer2.mjs';
const _sfc_main = defineComponent({
name: "BasicFormAction",
components: {
FormItem: Form.Item,
Button: TaButton,
BasicArrow: TaBasicArrow,
ACol: Col
},
props: {
showActionButtonGroup: propTypes.bool.def(true),
showResetButton: propTypes.bool.def(true),
showSubmitButton: propTypes.bool.def(true),
showAdvancedButton: propTypes.bool.def(true),
resetButtonOptions: {
type: Object,
default: () => ({})
},
submitButtonOptions: {
type: Object,
default: () => ({})
},
actionColOptions: {
type: Object,
default: () => ({})
},
actionSpan: propTypes.number.def(6),
isAdvanced: propTypes.bool,
hideAdvanceBtn: propTypes.bool
},
emits: ["toggle-advanced"],
setup(props, { emit }) {
const actionColOpt = computed(() => {
const { showAdvancedButton, actionSpan: span, actionColOptions } = props;
const actionSpan = 24 - span;
const advancedSpanObj = showAdvancedButton ? { span: actionSpan < 6 ? 24 : actionSpan } : {};
const actionColOpt2 = {
style: { textAlign: "right" },
span: showAdvancedButton ? 6 : 4,
...advancedSpanObj,
...actionColOptions
};
return actionColOpt2;
});
const getResetBtnOptions = computed(() => {
return Object.assign({
text: tavI18n("Tav.common.resetText")
}, props.resetButtonOptions);
});
const getSubmitBtnOptions = computed(() => {
return Object.assign({
text: tavI18n("Tav.common.queryText")
}, props.submitButtonOptions);
});
function toggleAdvanced() {
emit("toggle-advanced");
}
return {
tavI18n,
actionColOpt,
getResetBtnOptions,
getSubmitBtnOptions,
toggleAdvanced,
...useFormContext()
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_Button = resolveComponent("Button");
const _component_BasicArrow = resolveComponent("BasicArrow");
const _component_FormItem = resolveComponent("FormItem");
const _component_a_col = resolveComponent("a-col");
return _ctx.showActionButtonGroup ? (openBlock(), createBlock(_component_a_col, normalizeProps(mergeProps({ key: 0 }, _ctx.actionColOpt)), {
default: withCtx(() => [
createElementVNode("div", {
style: normalizeStyle([{ "width": "100%" }, { textAlign: _ctx.actionColOpt.style.textAlign }])
}, [
createVNode(_component_FormItem, null, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "resetBefore"),
_ctx.showResetButton ? (openBlock(), createBlock(_component_Button, mergeProps({
key: 0,
type: "default",
class: "mr-2"
}, _ctx.getResetBtnOptions, { onClick: _ctx.resetAction }), {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.getResetBtnOptions.text), 1)
]),
_: 1
}, 16, ["onClick"])) : createCommentVNode("v-if", true),
renderSlot(_ctx.$slots, "submitBefore"),
_ctx.showSubmitButton ? (openBlock(), createBlock(_component_Button, mergeProps({
key: 1,
type: "primary",
class: "mr-2"
}, _ctx.getSubmitBtnOptions, { onClick: _ctx.submitAction }), {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.getSubmitBtnOptions.text), 1)
]),
_: 1
}, 16, ["onClick"])) : createCommentVNode("v-if", true),
renderSlot(_ctx.$slots, "advanceBefore"),
_ctx.showAdvancedButton && !_ctx.hideAdvanceBtn ? (openBlock(), createBlock(_component_Button, {
key: 2,
type: "link",
size: "small",
onClick: _ctx.toggleAdvanced
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(_ctx.isAdvanced ? _ctx.tavI18n("Tav.common.openText") : _ctx.tavI18n("Tav.common.closeText")) + " ", 1),
createVNode(_component_BasicArrow, {
class: "ml-1",
expand: !_ctx.isAdvanced,
up: ""
}, null, 8, ["expand"])
]),
_: 1
}, 8, ["onClick"])) : createCommentVNode("v-if", true),
renderSlot(_ctx.$slots, "advanceAfter")
]),
_: 3
})
], 4)
]),
_: 3
}, 16)) : createCommentVNode("v-if", true);
}
var FormAction = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/form/src/components/FormAction.vue"]]);
export { FormAction as default };
//# sourceMappingURL=FormAction2.mjs.map