UNPKG

vue-admin-core

Version:
105 lines (100 loc) 3.71 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue$1 = require('@formily/vue'); var vue = require('vue'); require('../../__builtins__/shared/index.js'); require('../../preview-text/index.js'); var elementPlus = require('element-plus'); require('../../../components/config-provider/index.js'); var lodashEs = require('lodash-es'); var transformComponent = require('../../__builtins__/shared/transform-component.js'); var useGlobalConfig = require('../../../components/config-provider/src/hooks/use-global-config.js'); var resolveComponent = require('../../__builtins__/shared/resolve-component.js'); var index = require('../../preview-text/src/index.js'); var utils = require('../../__builtins__/shared/utils.js'); const TransformElRadioGroup = transformComponent.transformComponent(elementPlus.ElRadioGroup, { change: "input" }); const RadioGroupOption = vue.defineComponent({ name: "FRadioGroup", props: { options: { type: Array, default: () => [] }, optionType: { type: String, default: "default" }, props: { type: Object, default: () => ({ children: "children", label: "label", value: "value", disabled: "disabled" }) } }, setup(customProps, { attrs, slots }) { const config = useGlobalConfig.useGlobalConfig(); const label = vue.computed(() => customProps.props.label || "label"); const value = vue.computed(() => customProps.props.value || "value"); const options = vue.computed(() => customProps.options || []); return () => { const OptionType = customProps.optionType === "button" ? elementPlus.ElRadioButton : elementPlus.ElRadio; const children = options.value.length !== 0 ? { default: () => options.value.map((option) => { var _a, _b, _c, _d; if (typeof option === "string") { return vue.h( OptionType, { label: option }, { default: () => { var _a2; return [resolveComponent.resolveComponent((_a2 = slots == null ? void 0 : slots.option) != null ? _a2 : option, { option })]; } } ); } else { return vue.h( OptionType, { ...option, value: void 0, label: option[value.value] || option[config.value.dictValueKey], disabled: lodashEs.isFunction((_a = customProps.props) == null ? void 0 : _a.disabled) ? (_b = customProps.props) == null ? void 0 : _b.disabled(option) : ((_c = customProps.props) == null ? void 0 : _c.disabled) ? option[(_d = customProps.props) == null ? void 0 : _d.disabled] : false }, { default: () => { var _a2; return [ resolveComponent.resolveComponent( (_a2 = slots == null ? void 0 : slots.option) != null ? _a2 : option[label.value] || option[config.value.dictLabelKey], { option } ) ]; } } ); } }) } : slots; return vue.h(TransformElRadioGroup, attrs, children); }; } }); const RadioGroup = vue$1.connect( RadioGroupOption, vue$1.mapProps({ dataSource: "options", value: "modelValue" }), vue$1.mapReadPretty(index.PreviewText.Select) ); const Radio = utils.composeExport(elementPlus.ElRadio, { Group: RadioGroup }); exports.Radio = Radio; exports.default = Radio; //# sourceMappingURL=index.js.map