UNPKG

@fe6/water-pro

Version:

An enterprise-class UI design language and Vue-based implementation

113 lines (92 loc) 4.54 kB
import { createVNode as _createVNode } from "vue"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /** @format */ import { defineComponent } from 'vue'; import { LoadingOutlined } from '@ant-design/icons-vue'; import { BasicTitle } from '../basic-title'; import { BasicArrow } from '../basic-arrow'; import useConfigInject from '../_util/hooks/useConfigInject'; import PropTypes from '../_util/vue-types'; import { getSlot } from '../_util/props-util'; import { tuple } from '../_util/type'; export default defineComponent({ inheritAttrs: false, props: { title: PropTypes.string, show: PropTypes.bool, expanable: PropTypes.bool, loading: PropTypes.bool, prefixCls: PropTypes.string, mode: PropTypes.oneOf(tuple('simple', 'default')).def('default'), headerClassName: PropTypes.string }, emits: ['expand'], setup: function setup(props) { var _useConfigInject = useConfigInject('container-collapse', props), prefixClsNew = _useConfigInject.prefixCls; return { prefixClsNew: prefixClsNew }; }, render: function render() { var _ref, _this = this; var titleNode = this.title; var children = getSlot(this); if (children.length > 0) { titleNode = children.slice(); } var loadingNode = null; if (this.loading) { loadingNode = _createVNode(LoadingOutlined, null, null); } var slotDatas = { status: this.show }; var actionNode = null; var actionChildren = getSlot(this, 'action', slotDatas); if (actionChildren.length > 0) { actionNode = actionChildren.slice(); } var arrowNode = null; if (!this.loading && this.expanable) { arrowNode = _createVNode(BasicArrow, { "top": this.show, "helpMessage": this.show ? '收起' : '展开', "expand": !this.show }, null); var iconChildren = getSlot(this, 'icon', slotDatas); if (iconChildren.length) { arrowNode = iconChildren; } } var actionAfterDefaultNode = _createVNode("div", { "class": "".concat(this.prefixClsNew, "-action ").concat(this.prefixClsNew, "-action-").concat(this.mode).concat(this.headerClassName ? " ".concat(this.headerClassName) : '') }, [actionNode, loadingNode, arrowNode]); var actionBeforeDefaultNode = _createVNode("div", { "class": "".concat(this.prefixClsNew, "-action ").concat(this.prefixClsNew, "-action-").concat(this.mode).concat(this.headerClassName ? " ".concat(this.headerClassName) : '') }, [arrowNode, actionNode, loadingNode]); var afterActionNode = null; if (this.mode === 'default') { afterActionNode = actionAfterDefaultNode; } var beforeActionNode = null; if (this.mode === 'simple') { beforeActionNode = actionBeforeDefaultNode; } return _createVNode("div", { "class": ["".concat(this.prefixClsNew, "-header"), (_ref = {}, _defineProperty(_ref, "".concat(this.prefixClsNew, "-header-active"), this.show), _defineProperty(_ref, "".concat(this.prefixClsNew, "-header-only"), !this.expanable), _ref), "".concat(this.prefixClsNew, "-header-").concat(this.mode)], "onClick": function onClick() { return _this.$emit('expand'); } }, [beforeActionNode, _createVNode(BasicTitle, _objectSpread({ "class": "".concat(this.prefixClsNew, "-header-title") }, this.$attrs), { default: function _default() { return [titleNode]; } }), afterActionNode]); } });