UNPKG

tdesign-vue

Version:
181 lines (173 loc) 7.76 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var helper = require('../_chunks/dep-4009cfe4.js'); var _defineProperty = require('@babel/runtime/helpers/defineProperty'); var Vue = require('vue'); var utils_helper = require('../utils/helper.js'); var utils_renderTnode = require('../utils/render-tnode.js'); var radio_props = require('./props.js'); var utils_event = require('../utils/event.js'); var configProvider_configReceiver = require('../config-provider/config-receiver.js'); var utils_mixins = require('../utils/mixins.js'); require('@babel/runtime/helpers/objectWithoutProperties'); require('@babel/runtime/helpers/slicedToArray'); require('../_chunks/dep-9c5b91d3.js'); require('../_chunks/dep-9a74c2be.js'); require('../_chunks/dep-689d381f.js'); require('../_chunks/dep-3b2292ce.js'); require('@babel/runtime/helpers/typeof'); require('../_chunks/dep-10fcb46d.js'); require('../_chunks/dep-803744d9.js'); require('../_chunks/dep-ba7f5924.js'); require('../_chunks/dep-84027b7f.js'); require('../_chunks/dep-49400b00.js'); require('../_chunks/dep-f1081d8e.js'); require('@babel/runtime/helpers/readOnlyError'); require('@vue/composition-api'); require('../_chunks/dep-2c592e99.js'); require('../_chunks/dep-8eddb350.js'); require('../_common/js/global-config/default-config.js'); require('../_common/js/global-config/locale/zh_CN.js'); require('../_chunks/dep-0c37520c.js'); require('../_chunks/dep-c13dcbfd.js'); require('dayjs'); require('../_chunks/dep-6f4e680e.js'); require('../_chunks/dep-bb0ececf.js'); require('../_chunks/dep-6eba4d23.js'); require('../_chunks/dep-010db548.js'); require('../_chunks/dep-8d206316.js'); require('../_chunks/dep-2bc87cc8.js'); require('../_chunks/dep-f77d6ad5.js'); require('../_chunks/dep-9dae8101.js'); require('../_chunks/dep-7c84d9a0.js'); require('../_chunks/dep-733a2279.js'); require('../_chunks/dep-d844c9ed.js'); require('../_chunks/dep-c05a9033.js'); require('../_chunks/dep-efe55b82.js'); require('../_chunks/dep-7da70ee1.js'); require('../_chunks/dep-124386d4.js'); require('../_chunks/dep-f5b14344.js'); require('../_chunks/dep-36c2788b.js'); require('../_chunks/dep-fa353fbb.js'); require('../_chunks/dep-d66ab3a4.js'); require('../_chunks/dep-d4d8c513.js'); require('../_common/js/global-config/t.js'); require('../_chunks/dep-a2217d56.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty); var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var classPrefixMixins = configProvider_configReceiver.getClassPrefixMixins("radio"); var _Radio = utils_mixins["default"](Vue__default["default"], classPrefixMixins).extend({ name: "TRadio", inheritAttrs: false, props: _objectSpread({}, radio_props["default"]), inject: { radioGroup: { "default": void 0 }, radioButton: { "default": void 0 } }, data: function data() { return { formDisabled: void 0 }; }, render: function render() { var _this$radioGroup, _this$value; var h = arguments[0]; var radioGroup = this.radioGroup, radioButton = this.radioButton; var tChecked = this.getChecked(); var tDisabled = this.getDisabled(); var prefixCls = radioButton ? "".concat(this.componentName, "-button") : this.componentName; var inputClass = ["".concat(prefixCls), _defineProperty__default["default"](_defineProperty__default["default"]({}, this.commonStatusClassName.checked, tChecked), this.commonStatusClassName.disabled, tDisabled)]; var allowUncheck = this.allowUncheck || ((_this$radioGroup = this.radioGroup) === null || _this$radioGroup === void 0 ? void 0 : _this$radioGroup.allowUncheck); return h("label", { "class": inputClass, "on": { "click": this.handleRadioClick }, "attrs": { "tabindex": tDisabled ? void 0 : "0" } }, [h("input", helper.helper([{ "attrs": { "type": "radio", "name": this.name || (radioGroup === null || radioGroup === void 0 ? void 0 : radioGroup.name) || void 0, "disabled": tDisabled, "tabindex": "-1", "data-value": typeof this.value === "string" ? "'".concat(this.value, "'") : this.value, "data-allow-uncheck": allowUncheck || void 0 }, "class": "".concat(prefixCls, "__former"), "domProps": { "value": (_this$value = this.value) !== null && _this$value !== void 0 ? _this$value : void 0, "checked": tChecked }, "on": { "click": this.onInputClick } }, { "on": _objectSpread({}, utils_helper.omit(this.$listeners, ["change", "click"])) }])), h("span", { "class": "".concat(prefixCls, "__input") }), h("span", { "class": "".concat(prefixCls, "__label") }, [utils_renderTnode.renderContent(this, "default", "label")])]); }, methods: { getChecked: function getChecked() { var _this$radioGroup2; return this.checked || this.value !== void 0 && ((_this$radioGroup2 = this.radioGroup) === null || _this$radioGroup2 === void 0 ? void 0 : _this$radioGroup2.value) === this.value; }, getDisabled: function getDisabled() { var _ref2, _this$radioGroup3; return Boolean((_ref2 = this.formDisabled || this.disabled) !== null && _ref2 !== void 0 ? _ref2 : (_this$radioGroup3 = this.radioGroup) === null || _this$radioGroup3 === void 0 ? void 0 : _this$radioGroup3.disabled); }, getReadonly: function getReadonly() { var _this$readonly, _this$radioGroup4; return Boolean((_this$readonly = this.readonly) !== null && _this$readonly !== void 0 ? _this$readonly : (_this$radioGroup4 = this.radioGroup) === null || _this$radioGroup4 === void 0 ? void 0 : _this$radioGroup4.readonly); }, onInputClick: function onInputClick(e) { e.stopPropagation(); }, handleRadioClick: function handleRadioClick(e) { var tDisabled = this.getDisabled(); var tReadonly = this.getReadonly(); if (tDisabled || tReadonly) return; this.$emit("click", { e: e }); this.checkRadio(e); }, checkRadio: function checkRadio(e) { var _this$radioGroup5; var tChecked = this.getChecked(); var allowUncheck = this.allowUncheck || ((_this$radioGroup5 = this.radioGroup) === null || _this$radioGroup5 === void 0 ? void 0 : _this$radioGroup5.allowUncheck); if (tChecked && !allowUncheck) return; if (this.radioGroup) { var value = tChecked && allowUncheck ? void 0 : this.value; this.radioGroup.handleRadioChange(value, { e: e, name: this.radioGroup.name }); } else { var _value = allowUncheck ? !tChecked : true; utils_event.emitEvent(this, "change", _value, { e: e }); } } } }); exports["default"] = _Radio; //# sourceMappingURL=radio.js.map