element-ui
Version:
A Component Library for Vue.js.
648 lines (562 loc) • 16.5 kB
JavaScript
module.exports =
/******/ (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, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 174);
/******/ })
/************************************************************************/
/******/ ({
/***/ 16:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/checkbox");
/***/ }),
/***/ 174:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _tableColumn = __webpack_require__(175);
var _tableColumn2 = _interopRequireDefault(_tableColumn);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* istanbul ignore next */
_tableColumn2.default.install = function (Vue) {
Vue.component(_tableColumn2.default.name, _tableColumn2.default);
};
exports.default = _tableColumn2.default;
/***/ }),
/***/ 175:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _checkbox = __webpack_require__(16);
var _checkbox2 = _interopRequireDefault(_checkbox);
var _tag = __webpack_require__(25);
var _tag2 = _interopRequireDefault(_tag);
var _merge = __webpack_require__(9);
var _merge2 = _interopRequireDefault(_merge);
var _util = __webpack_require__(3);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var columnIdSeed = 1;
var defaults = {
default: {
order: ''
},
selection: {
width: 48,
minWidth: 48,
realWidth: 48,
order: '',
className: 'el-table-column--selection'
},
expand: {
width: 48,
minWidth: 48,
realWidth: 48,
order: ''
},
index: {
width: 48,
minWidth: 48,
realWidth: 48,
order: ''
}
};
var forced = {
selection: {
renderHeader: function renderHeader(h, _ref) {
var store = _ref.store;
return h(
'el-checkbox',
{
attrs: {
disabled: store.states.data && store.states.data.length === 0,
indeterminate: store.states.selection.length > 0 && !this.isAllSelected,
value: this.isAllSelected },
nativeOn: {
'click': this.toggleAllSelection
}
},
[]
);
},
renderCell: function renderCell(h, _ref2) {
var row = _ref2.row,
column = _ref2.column,
store = _ref2.store,
$index = _ref2.$index;
return h(
'el-checkbox',
{
nativeOn: {
'click': function click(event) {
return event.stopPropagation();
}
},
attrs: {
value: store.isSelected(row),
disabled: column.selectable ? !column.selectable.call(null, row, $index) : false
},
on: {
'input': function input() {
store.commit('rowSelectedChanged', row);
}
}
},
[]
);
},
sortable: false,
resizable: false
},
index: {
renderHeader: function renderHeader(h, _ref3) {
var column = _ref3.column;
return column.label || '#';
},
renderCell: function renderCell(h, _ref4) {
var $index = _ref4.$index,
column = _ref4.column;
var i = $index + 1;
var index = column.index;
if (typeof index === 'number') {
i = $index + index;
} else if (typeof index === 'function') {
i = index($index);
}
return h(
'div',
null,
[i]
);
},
sortable: false
},
expand: {
renderHeader: function renderHeader(h, _ref5) {
var column = _ref5.column;
return column.label || '';
},
renderCell: function renderCell(h, _ref6, proxy) {
var row = _ref6.row,
store = _ref6.store;
var expanded = store.states.expandRows.indexOf(row) > -1;
return h(
'div',
{ 'class': 'el-table__expand-icon ' + (expanded ? 'el-table__expand-icon--expanded' : ''),
on: {
'click': function click(e) {
return proxy.handleExpandClick(row, e);
}
}
},
[h(
'i',
{ 'class': 'el-icon el-icon-arrow-right' },
[]
)]
);
},
sortable: false,
resizable: false,
className: 'el-table__expand-column'
}
};
var getDefaultColumn = function getDefaultColumn(type, options) {
var column = {};
(0, _merge2.default)(column, defaults[type || 'default']);
for (var name in options) {
if (options.hasOwnProperty(name)) {
var value = options[name];
if (typeof value !== 'undefined') {
column[name] = value;
}
}
}
if (!column.minWidth) {
column.minWidth = 80;
}
column.realWidth = column.width === undefined ? column.minWidth : column.width;
return column;
};
var DEFAULT_RENDER_CELL = function DEFAULT_RENDER_CELL(h, _ref7) {
var row = _ref7.row,
column = _ref7.column,
$index = _ref7.$index;
var property = column.property;
var value = property && (0, _util.getPropByPath)(row, property).v;
if (column && column.formatter) {
return column.formatter(row, column, value, $index);
}
return value;
};
var parseWidth = function parseWidth(width) {
if (width !== undefined) {
width = parseInt(width, 10);
if (isNaN(width)) {
width = null;
}
}
return width;
};
var parseMinWidth = function parseMinWidth(minWidth) {
if (minWidth !== undefined) {
minWidth = parseInt(minWidth, 10);
if (isNaN(minWidth)) {
minWidth = 80;
}
}
return minWidth;
};
exports.default = {
name: 'ElTableColumn',
props: {
type: {
type: String,
default: 'default'
},
label: String,
className: String,
labelClassName: String,
property: String,
prop: String,
width: {},
minWidth: {},
renderHeader: Function,
sortable: {
type: [String, Boolean],
default: false
},
sortMethod: Function,
sortBy: [String, Function, Array],
resizable: {
type: Boolean,
default: true
},
context: {},
columnKey: String,
align: String,
headerAlign: String,
showTooltipWhenOverflow: Boolean,
showOverflowTooltip: Boolean,
fixed: [Boolean, String],
formatter: Function,
selectable: Function,
reserveSelection: Boolean,
filterMethod: Function,
filteredValue: Array,
filters: Array,
filterPlacement: String,
filterMultiple: {
type: Boolean,
default: true
},
index: [Number, Function],
sortOrders: {
type: Array,
default: function _default() {
return ['ascending', 'descending', null];
},
validator: function validator(val) {
return val.every(function (order) {
return ['ascending', 'descending', null].indexOf(order) > -1;
});
}
}
},
data: function data() {
return {
isSubColumn: false,
columns: []
};
},
beforeCreate: function beforeCreate() {
this.row = {};
this.column = {};
this.$index = 0;
},
components: {
ElCheckbox: _checkbox2.default,
ElTag: _tag2.default
},
computed: {
owner: function owner() {
var parent = this.$parent;
while (parent && !parent.tableId) {
parent = parent.$parent;
}
return parent;
},
columnOrTableParent: function columnOrTableParent() {
var parent = this.$parent;
while (parent && !parent.tableId && !parent.columnId) {
parent = parent.$parent;
}
return parent;
}
},
created: function created() {
var _this = this;
this.customRender = this.$options.render;
this.$options.render = function (h) {
return h('div', _this.$slots.default);
};
var parent = this.columnOrTableParent;
var owner = this.owner;
this.isSubColumn = owner !== parent;
this.columnId = (parent.tableId || parent.columnId) + '_column_' + columnIdSeed++;
var type = this.type;
var width = parseWidth(this.width);
var minWidth = parseMinWidth(this.minWidth);
var isColumnGroup = false;
var column = getDefaultColumn(type, {
id: this.columnId,
columnKey: this.columnKey,
label: this.label,
className: this.className,
labelClassName: this.labelClassName,
property: this.prop || this.property,
type: type,
renderCell: null,
renderHeader: this.renderHeader,
minWidth: minWidth,
width: width,
isColumnGroup: isColumnGroup,
context: this.context,
align: this.align ? 'is-' + this.align : null,
headerAlign: this.headerAlign ? 'is-' + this.headerAlign : this.align ? 'is-' + this.align : null,
sortable: this.sortable === '' ? true : this.sortable,
sortMethod: this.sortMethod,
sortBy: this.sortBy,
resizable: this.resizable,
showOverflowTooltip: this.showOverflowTooltip || this.showTooltipWhenOverflow,
formatter: this.formatter,
selectable: this.selectable,
reserveSelection: this.reserveSelection,
fixed: this.fixed === '' ? true : this.fixed,
filterMethod: this.filterMethod,
filters: this.filters,
filterable: this.filters && this.filters.length || this.filterMethod,
filterMultiple: this.filterMultiple,
filterOpened: false,
filteredValue: this.filteredValue || [],
filterPlacement: this.filterPlacement || '',
index: this.index,
sortOrders: this.sortOrders
});
var source = forced[type] || {};
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
var value = source[prop];
if (value !== undefined) {
column[prop] = prop === 'className' ? column[prop] + ' ' + value : value;
}
}
}
this.columnConfig = column;
var renderCell = column.renderCell;
var _self = this;
if (type === 'expand') {
owner.renderExpanded = function (h, data) {
return _self.$scopedSlots.default ? _self.$scopedSlots.default(data) : _self.$slots.default;
};
column.renderCell = function (h, data) {
return h(
'div',
{ 'class': 'cell' },
[renderCell(h, data, this._renderProxy)]
);
};
return;
}
column.renderCell = function (h, data) {
if (_self.$scopedSlots.default) {
renderCell = function renderCell() {
return _self.$scopedSlots.default(data);
};
}
if (!renderCell) {
renderCell = DEFAULT_RENDER_CELL;
}
return _self.showOverflowTooltip || _self.showTooltipWhenOverflow ? h(
'div',
{ 'class': 'cell el-tooltip', style: { width: (data.column.realWidth || data.column.width) - 1 + 'px' } },
[renderCell(h, data)]
) : h(
'div',
{ 'class': 'cell' },
[renderCell(h, data)]
);
};
},
destroyed: function destroyed() {
if (!this.$parent) return;
var parent = this.$parent;
this.owner.store.commit('removeColumn', this.columnConfig, this.isSubColumn ? parent.columnConfig : null);
},
watch: {
label: function label(newVal) {
if (this.columnConfig) {
this.columnConfig.label = newVal;
}
},
prop: function prop(newVal) {
if (this.columnConfig) {
this.columnConfig.property = newVal;
}
},
property: function property(newVal) {
if (this.columnConfig) {
this.columnConfig.property = newVal;
}
},
filters: function filters(newVal) {
if (this.columnConfig) {
this.columnConfig.filters = newVal;
}
},
filterMultiple: function filterMultiple(newVal) {
if (this.columnConfig) {
this.columnConfig.filterMultiple = newVal;
}
},
align: function align(newVal) {
if (this.columnConfig) {
this.columnConfig.align = newVal ? 'is-' + newVal : null;
if (!this.headerAlign) {
this.columnConfig.headerAlign = newVal ? 'is-' + newVal : null;
}
}
},
headerAlign: function headerAlign(newVal) {
if (this.columnConfig) {
this.columnConfig.headerAlign = 'is-' + (newVal ? newVal : this.align);
}
},
width: function width(newVal) {
if (this.columnConfig) {
this.columnConfig.width = parseWidth(newVal);
this.owner.store.scheduleLayout();
}
},
minWidth: function minWidth(newVal) {
if (this.columnConfig) {
this.columnConfig.minWidth = parseMinWidth(newVal);
this.owner.store.scheduleLayout();
}
},
fixed: function fixed(newVal) {
if (this.columnConfig) {
this.columnConfig.fixed = newVal;
this.owner.store.scheduleLayout(true);
}
},
sortable: function sortable(newVal) {
if (this.columnConfig) {
this.columnConfig.sortable = newVal;
}
},
index: function index(newVal) {
if (this.columnConfig) {
this.columnConfig.index = newVal;
}
},
formatter: function formatter(newVal) {
if (this.columnConfig) {
this.columnConfig.formatter = newVal;
}
},
className: function className(newVal) {
if (this.columnConfig) {
this.columnConfig.className = newVal;
}
},
labelClassName: function labelClassName(newVal) {
if (this.columnConfig) {
this.columnConfig.labelClassName = newVal;
}
}
},
mounted: function mounted() {
var owner = this.owner;
var parent = this.columnOrTableParent;
var columnIndex = void 0;
if (!this.isSubColumn) {
columnIndex = [].indexOf.call(parent.$refs.hiddenColumns.children, this.$el);
} else {
columnIndex = [].indexOf.call(parent.$el.children, this.$el);
}
owner.store.commit('insertColumn', this.columnConfig, columnIndex, this.isSubColumn ? parent.columnConfig : null);
}
};
/***/ }),
/***/ 25:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/tag");
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/util");
/***/ }),
/***/ 9:
/***/ (function(module, exports) {
module.exports = require("element-ui/lib/utils/merge");
/***/ })
/******/ });