@mdsfe/mds-ui
Version:
A set of enterprise-class Vue UI components.
546 lines (502 loc) • 17.5 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("./icon"));
else if(typeof define === 'function' && define.amd)
define(["./icon"], factory);
else {
var a = typeof exports === 'object' ? factory(require("./icon")) : factory(root["./icon"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(window, function(__WEBPACK_EXTERNAL_MODULE__7__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/dist/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 137);
/******/ })
/************************************************************************/
/******/ ({
/***/ 137:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./components/style/index.less
var style = __webpack_require__(142);
// EXTERNAL MODULE: ./components/steps/style/index.less
var steps_style = __webpack_require__(223);
// CONCATENATED MODULE: ./components/steps/style/index.js
// EXTERNAL MODULE: external "babel-runtime/helpers/defineProperty"
var defineProperty_ = __webpack_require__(3);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
// CONCATENATED MODULE: ./components/steps/steps.js
/* harmony default export */ var steps = ({
name: 'MdsSteps',
props: {
prefixCls: {
type: String,
default: 'mds-steps'
},
current: {
type: Number,
default: 0
},
direction: {
type: String,
default: 'horizontal',
validator: function validator(value) {
return ['horizontal', 'vertical'].indexOf(value) !== -1;
}
},
iconPrefix: {
type: String,
default: 'mds'
},
progressDot: {
type: Boolean,
default: false
},
space: {
type: [String, Number],
default: ''
},
spaceMargin: {
type: Number,
default: 8
},
size: {
type: String,
default: 'default'
},
status: {
type: String,
default: 'process'
},
simple: Boolean
},
data: function data() {
return {
lastStepOffsetWidth: 0
};
},
methods: {
calcStepOffsetWidth: function calcStepOffsetWidth(dom) {
var lastStepOffsetWidth = (dom.lastChild.offsetWidth || 0) + 1;
this.lastStepOffsetWidth = lastStepOffsetWidth;
},
updateChildern: function updateChildern() {
// const lastIndex = this.$children.length - 1
this.$children.forEach(function (component, index) {
// const itemWidth = (this.direction === 'vertical' || index === lastIndex) ? '' : `${100 / lastIndex}%`
// const adjustMarginRight = (this.direction === 'vertical' || index === lastIndex) ? 0 : -Math.round(this.lastStepOffsetWidth / lastIndex + 1)
// component.itemWidth = itemWidth
// component.adjustMarginRight = adjustMarginRight
// component.stepNumber = index + 1
// if (this.status === 'error' && index === this.current - 1) {
// component.isNextError = true
// } else {
// component.isNextError = false
// }
// if (index === this.current) {
// component.defaultstatus = this.status
// } else if (index < this.current) {
// component.defaultstatus = 'finish'
// } else {
// component.defaultstatus = 'wait'
// }
});
}
},
computed: {
classes: function classes() {
var prefixCls = this.prefixCls;
if (this.simple) {
return [prefixCls, prefixCls + '--simple', defineProperty_default()({}, prefixCls + '-' + this.size, !!this.size)];
} else {
var _ref2;
var adjustedlabelPlacement = this.progressDot ? 'vertical' : 'horizontal';
return [prefixCls, prefixCls + '-' + this.direction, (_ref2 = {}, defineProperty_default()(_ref2, prefixCls + '-' + this.size, !!this.size), defineProperty_default()(_ref2, prefixCls + '-dot', this.progressDot), defineProperty_default()(_ref2, prefixCls + '-label-' + adjustedlabelPlacement, this.direction === 'horizontal'), _ref2)];
}
}
},
render: function render(h) {
return h(
'div',
{ 'class': this.classes, key: this.current },
[this.$slots.default]
);
}
});
// step.map((vnode, index) => {
// const props = vnode.componentOptions.propsData
// const itemWidth = (this.direction === 'vertical' || index === lastIndex) ? '' : `${100 / lastIndex}%`
// const adjustMarginRight = (this.direction === 'vertical' || index === lastIndex) ? 0 : -Math.round(this.lastStepOffsetWidth / lastIndex + 1)
// props.stepNumber = index + 1
// props.itemWidth = itemWidth
// props.adjustMarginRight = adjustMarginRight
// if (this.status === 'error' && index === this.current - 1) {
// vnode.data.staticClass += `${this.prefixCls}-next-error`
// }
// if (!props.status) {
// if (index === this.current) {
// props.status = this.status
// } else if (index < this.current) {
// props.status = 'finish'
// } else {
// props.status = 'wait'
// }
// }
// return vnode
// })
// EXTERNAL MODULE: external "./icon"
var external_icon_ = __webpack_require__(7);
var external_icon_default = /*#__PURE__*/__webpack_require__.n(external_icon_);
// CONCATENATED MODULE: ./components/steps/step.js
/* harmony default export */ var step = ({
name: 'MdsStep',
props: {
prefixCls: {
type: String,
default: 'mds-steps'
},
description: String,
title: String,
icon: String,
status: String
},
data: function data() {
return {
defaultstatus: '',
size: 'default',
stepNumber: undefined,
isNextError: false,
maxWidth: '',
paddingLeft: 0,
paddingRight: 0,
paddingTop: 0,
paddingBottom: 0,
flexBasis: ''
};
},
computed: {
classes: function classes() {
var prefixCls = this.prefixCls;
if (this.simple) {
var _ref;
return [prefixCls + '-simple', prefixCls + '-status-' + this.currentstatus, (_ref = {}, defineProperty_default()(_ref, prefixCls + '-custom', !!this.$slots.icon), defineProperty_default()(_ref, prefixCls + '-next-error', this.isNextError), _ref)];
} else {
var _ref2;
return [prefixCls + '-item', prefixCls + '-status-' + this.currentstatus, (_ref2 = {}, defineProperty_default()(_ref2, prefixCls + '-custom', !!this.$slots.icon), defineProperty_default()(_ref2, prefixCls + '-next-error', this.isNextError), _ref2)];
}
},
style: function style() {
return {
flexBasis: this.flexBasis,
maxWidth: this.maxWidth
};
},
tailStyle: function tailStyle() {
return {
paddingLeft: this.paddingLeft,
paddingRight: this.paddingRight,
paddingTop: this.paddingTop,
paddingBottom: this.paddingBottom
};
},
iconClasses: function iconClasses() {
var _ref3;
var prefixCls = this.prefixCls;
var iconPrefix = this.iconPrefix;
return [prefixCls + '-icon', iconPrefix + 'icon', (_ref3 = {}, defineProperty_default()(_ref3, iconPrefix + 'icon-' + this.icon, this.icon), defineProperty_default()(_ref3, iconPrefix + 'icon-line-check', !this.icon && this.currentstatus === 'finish'), defineProperty_default()(_ref3, iconPrefix + 'icon-cross', !this.icon && this.currentstatus === 'error'), _ref3)];
},
progressDot: function progressDot() {
return this.$parent.progressDot;
},
iconPrefix: function iconPrefix() {
return this.$parent.iconPrefix;
},
parentstatus: function parentstatus() {
return this.$parent.status;
},
currentstatus: function currentstatus() {
return this.status || this.defaultstatus;
},
simple: function simple() {
return this.$parent.simple;
}
},
components: {
MdsIcon: external_icon_default.a
},
beforeUpdate: function beforeUpdate() {
this.calcItemWidth();
},
mounted: function mounted() {
this.calcItemWidth();
},
methods: {
calcItemWidth: function calcItemWidth() {
var parentNode = this.$el.parentNode;
var brotherChildNodes = parentNode.childNodes;
var validChildNodes = Array.prototype.slice.call(brotherChildNodes).filter(function (node) {
return node.nodeType === 1;
});
var lastIndex = validChildNodes.length - 1;
var isLastChild = validChildNodes[lastIndex] === this.$el;
var direction = this.$parent.direction;
var index = validChildNodes.indexOf(this.$el);
var space = this.$parent.space;
var size = this.$parent.size === 'default' ? 32 : 24;
var spaceMargin = this.$parent.spaceMargin;
this.size = size;
this.stepNumber = index + 1;
if (isLastChild) {
if (direction === 'horizontal') {
this.maxWidth = 100 / validChildNodes.length + '%';
}
} else {
this.flexBasis = space ? space[space.length - 1] === '%' ? space : parseFloat(space) + 'px' : 100 / lastIndex + '%';
}
if (direction === 'vertical') {
this.paddingTop = spaceMargin + size + 'px';
this.paddingBottom = spaceMargin + 'px';
} else {
this.paddingLeft = spaceMargin + size + 'px';
this.paddingRight = spaceMargin + 'px';
}
this.isNextError = this.parentstatus === 'error' && index === this.$parent.current - 1;
this.defaultstatus = index === this.$parent.current ? this.parentstatus : index < this.$parent.current ? 'finish' : 'wait';
}
},
render: function render(h) {
var _this = this;
var prefixCls = this.prefixCls;
if (this.simple) {
var renderIcon = function renderIcon() {
var iconDot = h('span', { 'class': prefixCls + '-icon-dot' });
if (_this.progressDot) {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[iconDot]
);
} else if (_this.$slots.icon) {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[_this.$slots.icon]
);
} else if (_this.icon || _this.currentstatus === 'finish' || _this.currentstatus === 'error') {
return h('span', { 'class': _this.iconClasses });
} else {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[_this.stepNumber]
);
}
};
return h(
'div',
{ 'class': this.classes, style: this.style },
[h(
'div',
{ 'class': prefixCls + '-tail', style: this.tailStyle },
[h('mds-icon', {
attrs: { type: 'line-caret-right' }
})]
), h(
'div',
{ 'class': prefixCls + '-step' },
[h(
'div',
{ 'class': prefixCls + '-head' },
[h(
'div',
{ 'class': prefixCls + '-head-inner' },
[renderIcon()]
)]
), h(
'div',
{ 'class': prefixCls + '-main' },
[h(
'div',
{ 'class': prefixCls + '-title' },
[h('div', [this.$slots.title || this.title]), h(
'div',
{ 'class': prefixCls + '--simple-icon' },
[h('mds-icon', {
attrs: { type: 'line-caret-right' }
})]
)]
)]
)]
)]
);
} else {
var _renderIcon = function _renderIcon() {
var iconDot = h('span', { 'class': prefixCls + '-icon-dot' });
if (_this.progressDot) {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[iconDot]
);
} else if (_this.$slots.icon) {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[_this.$slots.icon]
);
} else if (_this.icon || _this.currentstatus === 'finish' || _this.currentstatus === 'error') {
return h('span', { 'class': _this.iconClasses });
} else {
return h(
'span',
{ 'class': prefixCls + '-icon' },
[_this.stepNumber]
);
}
};
return h(
'div',
{ 'class': this.classes, style: this.style },
[h(
'div',
{ 'class': prefixCls + '-tail', style: this.tailStyle },
[h('i')]
), h(
'div',
{ 'class': prefixCls + '-step' },
[h(
'div',
{ 'class': prefixCls + '-head' },
[h(
'div',
{ 'class': prefixCls + '-head-inner' },
[_renderIcon()]
)]
), h(
'div',
{ 'class': prefixCls + '-main' },
[h(
'div',
{ 'class': prefixCls + '-title' },
[this.$slots.title || this.title]
), this.description ? h(
'div',
{ 'class': prefixCls + '-description' },
[this.description]
) : '']
)]
)]
);
}
}
});
// CONCATENATED MODULE: ./components/steps/index.js
steps.Step = step;
/* istanbul ignore next */
steps.install = function (Vue) {
Vue.component(steps.name, steps);
Vue.component(step.name, step);
};
/* harmony default export */ var components_steps = __webpack_exports__["default"] = (steps);
/***/ }),
/***/ 142:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 223:
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
module.exports = require("babel-runtime/helpers/defineProperty");
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__7__;
/***/ })
/******/ });
});