UNPKG

zmp-vue

Version:

Build full featured iOS & Android apps using ZMP & Vue

78 lines (62 loc) 2.3 kB
"use strict"; exports.__esModule = true; exports.default = void 0; var _vue = require("vue"); var _button = _interopRequireDefault(require("../components/button")); var _constants = require("../../common/constants"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function render(_ctx, _cache) { var _class; var _component_Button = (0, _vue.resolveComponent)("Button"); return (0, _vue.openBlock)(), (0, _vue.createBlock)(_component_Button, (0, _vue.mergeProps)(_ctx.$props, { class: (_class = {}, _class[_ctx.buttonTypeClass] = true, _class['zmp-btn-responsive'] = _ctx.responsive, _class) }), (0, _vue.createSlots)({ _: 2 }, [(0, _vue.renderList)(_ctx.$slots, function (_, slot) { return { name: slot, fn: (0, _vue.withCtx)(function (scope) { return [(0, _vue.renderSlot)(_ctx.$slots, slot, scope)]; }) }; })]), 1040, ["class"]); } var _default = { name: 'zmp-button', render: render, components: { Button: _button.default }, props: _extends({}, _button.default.props, { typeName: { type: String, default: '' }, responsive: Boolean }), emits: _button.default.emits, setup: function setup(props) { var buttonTypeClass = (0, _vue.computed)(function () { var classPrefix = 'zmp-btn'; switch (props.typeName) { case _constants.BUTTON_TYPE.PRIMARY: return classPrefix + "-primary"; case _constants.BUTTON_TYPE.SECONDARY: return classPrefix + "-secondary"; case _constants.BUTTON_TYPE.DESTRUCTIVE: return classPrefix + "-destructive"; case _constants.BUTTON_TYPE.TERTIARY: return classPrefix + "-tertiary"; case _constants.BUTTON_TYPE.GHOST: return classPrefix + "-ghost"; default: return ''; } }); return { buttonTypeClass: buttonTypeClass }; } }; exports.default = _default;