UNPKG

tdesign-mobile-vue

Version:
112 lines (108 loc) 4.39 kB
/** * tdesign v1.7.0 * (c) 2024 TDesign Group * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, computed, withDirectives, createVNode, resolveDirective, mergeProps } from 'vue'; import { Loading } from '../loading/index.js'; import ButtonProps from './props.js'; import config from '../config.js'; import { useFormDisabled } from '../form/hooks.js'; import { usePrefixClass } from '../hooks/useClass.js'; import { useTNodeJSX, useContent } from '../hooks/tnode.js'; import Hover from '../shared/hover.js'; import '../loading/loading.js'; import '../loading/icon/gradient.js'; import '../_common/js/loading/circle-adapter.js'; import '../_common/js/utils/set-style.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '@babel/runtime/helpers/slicedToArray'; import 'lodash/isString'; import 'lodash/isNull'; import 'lodash/isUndefined'; import 'lodash/isNumber'; import 'lodash/isArray'; import '../loading/icon/spinner.js'; import '../loading/props.js'; import '../shared/dom.js'; import 'lodash/isFunction'; import '../loading/plugin.js'; import 'lodash/merge'; import 'lodash/camelCase'; import 'lodash/kebabCase'; import '../hooks/render-tnode.js'; import 'lodash/isEmpty'; import 'lodash/isObject'; import '../config-provider/useConfig.js'; import 'lodash/cloneDeep'; import '../config-provider/context.js'; import 'lodash/mergeWith'; import '../_common/js/global-config/mobile/default-config.js'; import '../_common/js/global-config/mobile/locale/zh_CN.js'; import '../_chunks/dep-d5364bc4.js'; import '@babel/runtime/helpers/typeof'; import '../_chunks/dep-eb734424.js'; import 'dayjs'; import '../shared/component.js'; import 'lodash/isBoolean'; var prefix = config.prefix; var _Button = defineComponent({ name: "".concat(prefix, "-button"), directives: { Hover: Hover }, props: ButtonProps, setup: function setup(props) { var buttonClass = usePrefixClass("button"); var renderTNodeJSX = useTNodeJSX(); var renderTNodeContent = useContent(); var isDisabled = useFormDisabled(); var hoverDisabled = computed(function () { return isDisabled.value || props.loading; }); var buttonClasses = computed(function () { return ["".concat(buttonClass.value), "".concat(buttonClass.value, "--size-").concat(props.size), "".concat(buttonClass.value, "--").concat(props.variant), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(buttonClass.value, "--").concat(props.theme), props.theme), "".concat(buttonClass.value, "--").concat(props.shape), props.shape), "".concat(buttonClass.value, "--ghost"), props.ghost), "".concat(buttonClass.value, "--block"), props.block), "".concat(buttonClass.value, "--disabled"), isDisabled.value), "".concat(buttonClass.value, "--loading"), props.loading)]; }); var handleClick = function handleClick(e) { if (!props.loading && !isDisabled.value) { var _props$onClick; (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e); } else { e.stopPropagation(); } }; return function () { var suffix = renderTNodeJSX("suffix"); var readerIcon = function readerIcon() { if (props.loading) { return createVNode(Loading, mergeProps({ "inherit-color": true }, props.loadingProps), null); } return renderTNodeJSX("icon"); }; var readerContent = function readerContent() { var content = renderTNodeContent("default", "content"); return createVNode("span", { "class": "".concat(buttonClass.value, "__content") }, [content]); }; return withDirectives(createVNode("button", { "class": buttonClasses.value, "role": "button", "type": props.type, "disabled": isDisabled.value, "aria-disabled": isDisabled.value, "onClick": handleClick }, [readerIcon(), readerContent(), suffix]), [[resolveDirective("hover"), { className: "".concat(buttonClass.value, "--hover"), disabledHover: hoverDisabled.value }]]); }; } }); export { _Button as default }; //# sourceMappingURL=button.js.map