UNPKG

vxe-design

Version:

A PC-based visual designer based on Vxe UI, used for building zero-code and low-code platforms

347 lines (346 loc) 13.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultPCStyleFormComponent = exports.DefaultMobileStyleFormComponent = void 0; var _vue = require("vue"); var _comp = require("../../ui/src/comp"); var _core = require("@vxe-ui/core"); const { getI18n } = _core.VxeUI; const getBoldOptions = () => { return [{ label: getI18n('vxe.formDesign.styleSetting.fontNormal'), value: false }, { label: getI18n('vxe.formDesign.styleSetting.fontBold'), value: true }]; }; const getColonOptions = () => { return [{ label: getI18n('vxe.formDesign.styleSetting.colonVisible'), value: true }, { label: getI18n('vxe.formDesign.styleSetting.colonHidden'), value: false }]; }; const getAlignOptions = () => { return [{ label: getI18n('vxe.formDesign.styleSetting.alignLeft'), value: '' }, { label: getI18n('vxe.formDesign.styleSetting.alignRight'), value: 'right' }]; }; const getWidthUnitOptions = () => { return [{ label: getI18n('vxe.formDesign.styleSetting.unitPx'), value: '' }, { label: getI18n('vxe.formDesign.styleSetting.unitPct'), value: '%' }]; }; const getWidthAutoOptions = () => { return [{ label: '自适应', value: true }, { label: '固定', value: false }]; }; const renderLayoutOption = (formData, field, type, changeEvent) => { const isVertical = type === 'vertical'; return (0, _vue.h)('div', { class: ['vxe-form-design--widget-form-item-option', `is--${type}`, { 'is--active': isVertical ? formData[field] : !formData[field] }], onClick() { formData[field] = isVertical; changeEvent(); } }, [(0, _vue.h)('div', { class: 'vxe-form-design--widget-form-item-option-row' }), (0, _vue.h)('div', { class: 'vxe-form-design--widget-form-item-option-row' }), (0, _vue.h)('div', {}, isVertical ? getI18n('vxe.formDesign.styleSetting.verticalLayout') : getI18n('vxe.formDesign.styleSetting.horizontalLayout'))]); }; const DefaultPCStyleFormComponent = exports.DefaultPCStyleFormComponent = (0, _comp.defineVxeComponent)({ name: 'DefaultPCStyleForm', props: { formData: { type: Object, default: () => ({}) } }, emits: [], setup(props) { const VxeUIFormComponent = _core.VxeUI.getComponent('vxe-form'); const VxeUIFormItemComponent = _core.VxeUI.getComponent('vxe-form-item'); const VxeUINumberInputComponent = _core.VxeUI.getComponent('vxe-number-input'); const VxeUIRadioGroupComponent = _core.VxeUI.getComponent('vxe-radio-group'); const VxeUISelectComponent = _core.VxeUI.getComponent('vxe-select'); const $xeFormDesign = (0, _vue.inject)('$xeFormDesign', null); const verticalField = 'pcVertical'; const refBoldOpts = (0, _vue.ref)(getBoldOptions()); const refColonOpts = (0, _vue.ref)(getColonOptions()); const refAlignOpts = (0, _vue.ref)(getAlignOptions()); const refWidthAutoOpts = (0, _vue.ref)(getWidthAutoOptions()); const refWidthUnitOpts = (0, _vue.ref)(getWidthUnitOptions()); const refreshPreview = () => { if ($xeFormDesign) { $xeFormDesign.refreshPreviewView(); } }; const changeLayoutEvent = () => { const { formData } = props; if (!formData.pcTitleWidth) { formData.pcTitleWidth = 100; } refreshPreview(); }; return () => { const { formData } = props; return (0, _vue.h)(VxeUIFormComponent, { data: formData, span: 24, vertical: true, titleBold: true }, { default() { return [(0, _vue.h)(VxeUIFormItemComponent, { title: getI18n('vxe.formDesign.styleSetting.layoutTitle'), field: verticalField }, { default() { return [(0, _vue.h)('div', { class: 'vxe-form-design--widget-form-item-layout' }, [renderLayoutOption(formData, verticalField, 'vertical', changeLayoutEvent), renderLayoutOption(formData, verticalField, 'horizontal', changeLayoutEvent)])]; } }), (0, _vue.h)(VxeUIFormItemComponent, { title: getI18n('vxe.formDesign.styleSetting.styleTitle') }, { default() { const propVns = [(0, _vue.h)('div', { key: 'tb', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.boldTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.pcTitleBold, options: refBoldOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleBold = val; } })]), (0, _vue.h)('div', { key: 'tc', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.colonTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.pcTitleColon, options: refColonOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleColon = val; } })])]; if (formData.pcVertical) { // } else { propVns.push((0, _vue.h)('div', { key: 'ta', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.alignTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.pcTitleAlign, options: refAlignOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleAlign = val; } })]), (0, _vue.h)('div', { key: 'twa', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.widthTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.pcTitleAutoWidth, options: refWidthAutoOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleAutoWidth = val; } })])); if (!formData.pcTitleAutoWidth) { propVns.push((0, _vue.h)('div', { key: 'tw', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)(VxeUINumberInputComponent, { class: 'vxe-form-design--widget-form-item-prop-width', modelValue: formData.pcTitleWidth, type: 'integer', onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleWidth = val; } }), (0, _vue.h)(VxeUISelectComponent, { class: 'vxe-form-design--widget-form-item-prop-unit', modelValue: formData.pcTitleWidthUnit, options: refWidthUnitOpts.value, transfer: true, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.pcTitleWidthUnit = val; } })])); } } return propVns; } })]; } }); }; } }); const DefaultMobileStyleFormComponent = exports.DefaultMobileStyleFormComponent = (0, _comp.defineVxeComponent)({ name: 'DefaultMobileStyleForm', props: { formData: { type: Object, default: () => ({}) } }, emits: [], setup(props) { const VxeUIFormComponent = _core.VxeUI.getComponent('vxe-form'); const VxeUIFormItemComponent = _core.VxeUI.getComponent('vxe-form-item'); const VxeUINumberInputComponent = _core.VxeUI.getComponent('vxe-number-input'); const VxeUIRadioGroupComponent = _core.VxeUI.getComponent('vxe-radio-group'); const VxeUISelectComponent = _core.VxeUI.getComponent('vxe-select'); const $xeFormDesign = (0, _vue.inject)('$xeFormDesign', null); const verticalField = 'mobileVertical'; const refBoldOpts = (0, _vue.ref)(getBoldOptions()); const refColonOpts = (0, _vue.ref)(getColonOptions()); const refAlignOpts = (0, _vue.ref)(getAlignOptions()); const refWidthAutoOpts = (0, _vue.ref)(getWidthAutoOptions()); const refWidthUnitOpts = (0, _vue.ref)(getWidthUnitOptions()); const refreshPreview = () => { if ($xeFormDesign) { $xeFormDesign.refreshPreviewView(); } }; const changeLayoutEvent = () => { const { formData } = props; if (!formData.mobileTitleWidth) { formData.mobileTitleWidth = 100; } refreshPreview(); }; return () => { const { formData } = props; return (0, _vue.h)(VxeUIFormComponent, { data: formData, span: 24, vertical: true, titleBold: true }, { default() { return [(0, _vue.h)(VxeUIFormItemComponent, { title: getI18n('vxe.formDesign.styleSetting.layoutTitle'), field: verticalField }, { default() { return [(0, _vue.h)('div', { class: 'vxe-form-design--widget-form-item-layout' }, [renderLayoutOption(formData, verticalField, 'vertical', changeLayoutEvent), renderLayoutOption(formData, verticalField, 'horizontal', changeLayoutEvent)])]; } }), (0, _vue.h)(VxeUIFormItemComponent, { title: getI18n('vxe.formDesign.styleSetting.styleTitle') }, { default() { const propVns = [(0, _vue.h)('div', { key: 'tb', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.boldTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.mobileTitleBold, options: refBoldOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleBold = val; } })]), (0, _vue.h)('div', { key: 'tc', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.colonTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.mobileTitleColon, options: refColonOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleColon = val; } })])]; if (formData.mobileVertical) { // } else { propVns.push((0, _vue.h)('div', { key: 'ta', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.alignTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.mobileTitleAlign, options: refAlignOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleAlign = val; } })]), (0, _vue.h)('div', { key: 'twa', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)('span', {}, getI18n('vxe.formDesign.styleSetting.widthTitle')), (0, _vue.h)(VxeUIRadioGroupComponent, { modelValue: formData.mobileTitleAutoWidth, options: refWidthAutoOpts.value, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleAutoWidth = val; } })])); if (!formData.mobileTitleAutoWidth) { propVns.push((0, _vue.h)('div', { key: 'wt', class: 'vxe-form-design--widget-form-item-prop-list' }, [(0, _vue.h)(VxeUINumberInputComponent, { class: 'vxe-form-design--widget-form-item-prop-width', modelValue: formData.mobileTitleWidth, type: 'integer', onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleWidth = val; } }), (0, _vue.h)(VxeUISelectComponent, { class: 'vxe-form-design--widget-form-item-prop-unit', modelValue: formData.mobileTitleWidthUnit, options: refWidthUnitOpts.value, transfer: true, onChange: refreshPreview, 'onUpdate:modelValue'(val) { formData.mobileTitleWidthUnit = val; } })])); } } return propVns; } })]; } }); }; } });