UNPKG

yk-smart-ui-test

Version:

A Component Library for Vue.js.

1,659 lines (1,479 loc) 56.3 kB
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, { 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 = 168); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = require("vue"); /***/ }), /***/ 15: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getCell; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return orderBy; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getColumnById; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getColumnByKey; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getColumnByCell; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return getRowIdentity; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getKeysMap; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return mergeOptions; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return parseWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return parseMinWidth; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return parseHeight; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return compose; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return toggleRowStatus; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return walkTreeNode; }); /* harmony import */ var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var getCell = function getCell(event) { var cell = event.target; while (cell && cell.tagName.toUpperCase() !== 'HTML') { if (cell.tagName.toUpperCase() === 'TD') { return cell; } cell = cell.parentNode; } return null; }; var isObject = function isObject(obj) { return obj !== null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object'; }; var orderBy = function orderBy(array, sortKey, reverse, sortMethod, sortBy) { if (!sortKey && !sortMethod && (!sortBy || Array.isArray(sortBy) && !sortBy.length)) { return array; } if (typeof reverse === 'string') { reverse = reverse === 'descending' ? -1 : 1; } else { reverse = reverse && reverse < 0 ? -1 : 1; } var getKey = sortMethod ? null : function (value, index) { if (sortBy) { if (!Array.isArray(sortBy)) { sortBy = [sortBy]; } return sortBy.map(function (by) { if (typeof by === 'string') { return Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* getValueByPath */ "i"])(value, by); } else { return by(value, index, array); } }); } if (sortKey !== '$key') { if (isObject(value) && '$value' in value) value = value.$value; } return [isObject(value) ? Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* getValueByPath */ "i"])(value, sortKey) : value]; }; var compare = function compare(a, b) { if (sortMethod) { return sortMethod(a.value, b.value); } for (var i = 0, len = a.key.length; i < len; i++) { if (a.key[i] < b.key[i]) { return -1; } if (a.key[i] > b.key[i]) { return 1; } } return 0; }; return array.map(function (value, index) { return { value: value, index: index, key: getKey ? getKey(value, index) : null }; }).sort(function (a, b) { var order = compare(a, b); if (!order) { // make stable https://en.wikipedia.org/wiki/Sorting_algorithm#Stability order = a.index - b.index; } return order * reverse; }).map(function (item) { return item.value; }); }; var getColumnById = function getColumnById(table, columnId) { var column = null; table.columns.forEach(function (item) { if (item.id === columnId) { column = item; } }); return column; }; var getColumnByKey = function getColumnByKey(table, columnKey) { var column = null; for (var i = 0; i < table.columns.length; i++) { var item = table.columns[i]; if (item.columnKey === columnKey) { column = item; break; } } return column; }; var getColumnByCell = function getColumnByCell(table, cell) { var matches = (cell.className || '').match(/yk-table_[^\s]+/gm); if (matches) { return getColumnById(table, matches[0]); } return null; }; var getRowIdentity = function getRowIdentity(row, rowKey) { if (!row) throw new Error('row is required when get row identity'); if (typeof rowKey === 'string') { if (rowKey.indexOf('.') < 0) { return row[rowKey]; } var key = rowKey.split('.'); var current = row; for (var i = 0; i < key.length; i++) { current = current[key[i]]; } return current; } else if (typeof rowKey === 'function') { return rowKey.call(null, row); } }; var getKeysMap = function getKeysMap(array, rowKey) { var arrayMap = {}; (array || []).forEach(function (row, index) { arrayMap[getRowIdentity(row, rowKey)] = { row: row, index: index }; }); return arrayMap; }; function hasOwn(obj, key) { return Object.prototype.hasOwnProperty.call(obj, key); } function mergeOptions(defaults, config) { var options = {}; var key = void 0; for (key in defaults) { options[key] = defaults[key]; } for (key in config) { if (hasOwn(config, key)) { var value = config[key]; if (typeof value !== 'undefined') { options[key] = value; } } } return options; } function parseWidth(width) { if (width !== undefined) { width = parseInt(width, 10); if (isNaN(width)) { width = null; } } return width; } function parseMinWidth(minWidth) { if (typeof minWidth !== 'undefined') { minWidth = parseWidth(minWidth); if (isNaN(minWidth)) { minWidth = 80; } } return minWidth; }; function parseHeight(height) { if (typeof height === 'number') { return height; } if (typeof height === 'string') { if (/^\d+(?:px)?$/.test(height)) { return parseInt(height, 10); } else { return height; } } return null; } // https://github.com/reduxjs/redux/blob/master/src/compose.js function compose() { for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { funcs[_key] = arguments[_key]; } if (funcs.length === 0) { return function (arg) { return arg; }; } if (funcs.length === 1) { return funcs[0]; } return funcs.reduce(function (a, b) { return function () { return a(b.apply(undefined, arguments)); }; }); } function toggleRowStatus(statusArr, row, newVal) { var changed = false; var index = statusArr.indexOf(row); var included = index !== -1; var addRow = function addRow() { statusArr.push(row); changed = true; }; var removeRow = function removeRow() { statusArr.splice(index, 1); changed = true; }; if (typeof newVal === 'boolean') { if (newVal && !included) { addRow(); } else if (!newVal && included) { removeRow(); } } else { if (included) { removeRow(); } else { addRow(); } } return changed; } function walkTreeNode(root, cb) { var childrenKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children'; var lazyKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'hasChildren'; var isNil = function isNil(array) { return !(Array.isArray(array) && array.length); }; function _walker(parent, children, level) { cb(parent, children, level); children.forEach(function (item) { if (item[lazyKey]) { cb(item, null, level + 1); return; } var children = item[childrenKey]; if (!isNil(children)) { _walker(item, children, level + 1); } }); } root.forEach(function (item) { if (item[lazyKey]) { cb(item, null, 0); return; } var children = item[childrenKey]; if (!isNil(children)) { _walker(item, children, 0); } }); } /***/ }), /***/ 168: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXTERNAL MODULE: ./packages/table/src/config.js var config = __webpack_require__(40); // EXTERNAL MODULE: ./packages/table/src/util.js var util = __webpack_require__(15); // EXTERNAL MODULE: ./packages/checkbox/index.js + 5 modules var packages_checkbox = __webpack_require__(26); // CONCATENATED MODULE: ./packages/table/src/table-column.js var _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; }; var columnIdSeed = 1; /* harmony default export */ var table_column = ({ name: 'YkTableColumn', props: { type: { type: String, default: 'default' }, subheader: [String, Number], unit: [String, Number], label: String, className: String, labelClassName: String, property: String, prop: String, width: {}, minWidth: {}, renderHeader: Function, sortable: { type: [Boolean, String], default: false }, sortMethod: Function, sortBy: [String, Function, Array], resizable: { type: Boolean, default: true }, columnKey: String, align: String, headerAlign: String, showTooltipWhenOverflow: Boolean, showOverflowTooltip: { type: Boolean, default: true }, 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; }); } }, textEdit: false }, data: function data() { return { isSubColumn: false, columns: [] }; }, 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; }, realWidth: function realWidth() { return Object(util["l" /* parseWidth */])(this.width); }, realMinWidth: function realMinWidth() { return Object(util["k" /* parseMinWidth */])(this.minWidth); }, realAlign: function realAlign() { return this.align ? 'is-' + this.align : null; }, realHeaderAlign: function realHeaderAlign() { return this.headerAlign ? 'is-' + this.headerAlign : this.realAlign; } }, methods: { getPropsData: function getPropsData() { var _this = this; for (var _len = arguments.length, props = Array(_len), _key = 0; _key < _len; _key++) { props[_key] = arguments[_key]; } return props.reduce(function (prev, cur) { if (Array.isArray(cur)) { cur.forEach(function (key) { prev[key] = _this[key]; }); } return prev; }, {}); }, getColumnElIndex: function getColumnElIndex(children, child) { return [].indexOf.call(children, child); }, setColumnWidth: function setColumnWidth(column) { if (this.realWidth) { column.width = this.realWidth; } if (this.realMinWidth) { column.minWidth = this.realMinWidth; } if (!column.minWidth) { column.minWidth = 80; } column.realWidth = column.width === undefined ? column.minWidth : column.width; return column; }, setColumnForcedProps: function setColumnForcedProps(column) { // 对于特定类型的 column,某些属性不允许设置 var type = column.type; var source = config["a" /* cellForced */][type] || {}; Object.keys(source).forEach(function (prop) { var value = source[prop]; if (value !== undefined) { column[prop] = prop === 'className' ? column[prop] + ' ' + value : value; } }); return column; }, setColumnRenders: function setColumnRenders(column) { var _this2 = this; var h = this.$createElement; // renderHeader 属性不推荐使用。 if (this.renderHeader) { console.warn('[Element Warn][TableColumn]Comparing to render-header, scoped-slot header is easier to use. We recommend users to use scoped-slot header.'); } else if (column.type !== 'selection') { column.renderHeader = function (h, scope) { var renderHeader = _this2.$scopedSlots.header; return renderHeader ? renderHeader(scope) : column.label; }; } var originRenderCell = column.renderCell; // TODO: 这里的实现调整 if (column.type === 'expand') { // 对于展开行,renderCell 不允许配置的。在上一步中已经设置过,这里需要简单封装一下。 column.renderCell = function (h, data) { return h( 'div', { 'class': 'cell' }, [originRenderCell(h, data)] ); }; this.owner.renderExpanded = function (h, data) { return _this2.$scopedSlots.default ? _this2.$scopedSlots.default(data) : _this2.$slots.default; }; } else { originRenderCell = originRenderCell || config["c" /* defaultRenderCell */]; // 对 renderCell 进行包装 column.renderCell = function (h, data) { var children = null; if (_this2.$scopedSlots.default) { children = _this2.$scopedSlots.default(data); } else { children = originRenderCell(h, data); } var prefix = Object(config["d" /* treeCellPrefix */])(h, data); var props = { class: 'cell test', style: {} }; if (column.showOverflowTooltip) { props.class += ' yk-tooltip'; props.style = { width: (data.column.realWidth || data.column.width) - 1 + 'px' }; } return h( 'div', props, [prefix, children] ); }; } return column; }, registerNormalWatchers: function registerNormalWatchers() { var _this3 = this; var props = ['unit', 'subheaader', 'label', 'property', 'filters', 'filterMultiple', 'sortable', 'index', 'formatter', 'className', 'labelClassName', 'showOverflowTooltip']; // 一些属性具有别名 var aliases = { prop: 'property', realAlign: 'align', realHeaderAlign: 'headerAlign', realWidth: 'width' }; var allAliases = props.reduce(function (prev, cur) { prev[cur] = cur; return prev; }, aliases); Object.keys(allAliases).forEach(function (key) { var columnKey = aliases[key]; _this3.$watch(key, function (newVal) { _this3.columnConfig[columnKey] = newVal; }); }); }, registerComplexWatchers: function registerComplexWatchers() { var _this4 = this; var props = ['fixed']; var aliases = { realWidth: 'width', realMinWidth: 'minWidth' }; var allAliases = props.reduce(function (prev, cur) { prev[cur] = cur; return prev; }, aliases); Object.keys(allAliases).forEach(function (key) { var columnKey = aliases[key]; _this4.$watch(key, function (newVal) { _this4.columnConfig[columnKey] = newVal; var updateColumns = columnKey === 'fixed'; _this4.owner.store.scheduleLayout(updateColumns); }); }); } }, components: { YkCheckbox: packages_checkbox["default"] }, beforeCreate: function beforeCreate() { this.row = {}; this.column = {}; this.$index = 0; this.columnId = ''; }, created: function created() { var parent = this.columnOrTableParent; this.isSubColumn = this.owner !== parent; this.columnId = (parent.tableId || parent.columnId) + '_column_' + columnIdSeed++; var type = this.type || 'default'; var sortable = this.sortable === '' ? true : this.sortable; var defaults = _extends({}, config["b" /* cellStarts */][type], { id: this.columnId, type: type, property: this.prop || this.property, align: this.realAlign, headerAlign: this.realHeaderAlign, showOverflowTooltip: this.showOverflowTooltip || this.showTooltipWhenOverflow, // filter 相关属性 filterable: this.filters || this.filterMethod, filteredValue: [], filterPlacement: '', isColumnGroup: false, filterOpened: false, // sort 相关属性 sortable: sortable, // index 列 index: this.index, textEdit: this.textEdit }); var basicProps = ['unit', 'subheader', 'columnKey', 'label', 'className', 'labelClassName', 'type', 'renderHeader', 'formatter', 'fixed', 'resizable']; var sortProps = ['sortMethod', 'sortBy', 'sortOrders']; var selectProps = ['selectable', 'reserveSelection']; var filterProps = ['filterMethod', 'filters', 'filterMultiple', 'filterOpened', 'filteredValue', 'filterPlacement']; var column = this.getPropsData(basicProps, sortProps, selectProps, filterProps); column = Object(util["h" /* mergeOptions */])(defaults, column); // 注意 compose 中函数执行的顺序是从右到左 var chains = Object(util["a" /* compose */])(this.setColumnRenders, this.setColumnWidth, this.setColumnForcedProps); column = chains(column); this.columnConfig = column; // 注册 watcher this.registerNormalWatchers(); this.registerComplexWatchers(); }, mounted: function mounted() { var owner = this.owner; var parent = this.columnOrTableParent; var children = this.isSubColumn ? parent.$el.children : parent.$refs.hiddenColumns.children; var columnIndex = this.getColumnElIndex(children, this.$el); owner.store.commit('insertColumn', this.columnConfig, columnIndex, this.isSubColumn ? parent.columnConfig : null); }, destroyed: function destroyed() { if (!this.$parent) return; var parent = this.$parent; this.owner.store.commit('removeColumn', this.columnConfig, this.isSubColumn ? parent.columnConfig : null); }, render: function render(h) { // slots 也要渲染,需要计算合并表头 return h('div', this.$slots.default); } }); // CONCATENATED MODULE: ./packages/table-column/index.js /* istanbul ignore next */ table_column.install = function (Vue) { Vue.component(table_column.name, table_column); }; /* harmony default export */ var packages_table_column = __webpack_exports__["default"] = (table_column); /***/ }), /***/ 2: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; }); /* globals __VUE_SSR_CONTEXT__ */ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules). // This module is a runtime utility for cleaner component module output and will // be included in the final webpack user bundle. function normalizeComponent ( scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, /* server only */ shadowMode /* vue-cli only */ ) { // Vue.extend constructor export interop var options = typeof scriptExports === 'function' ? scriptExports.options : scriptExports // render functions if (render) { options.render = render options.staticRenderFns = staticRenderFns options._compiled = true } // functional template if (functionalTemplate) { options.functional = true } // scopedId if (scopeId) { options._scopeId = 'data-v-' + scopeId } var hook if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call (this.$vnode && this.$vnode.ssrContext) || // stateful (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__ } // inject component styles if (injectStyles) { injectStyles.call(this, context) } // register component module identifier for async chunk inferrence if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier) } } // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook } else if (injectStyles) { hook = shadowMode ? function () { injectStyles.call( this, (options.functional ? this.parent : this).$root.$options.shadowRoot ) } : injectStyles } if (hook) { if (options.functional) { // for template-only hot-reload because in that case the render fn doesn't // go through the normalizer options._injectStyles = hook // register for functional component in vue file var originalRender = options.render options.render = function renderWithStyleInjection (h, context) { hook.call(context) return originalRender(h, context) } } else { // inject component registration as beforeCreate hook var existing = options.beforeCreate options.beforeCreate = existing ? [].concat(existing, hook) : [hook] } } return { exports: scriptExports, options: options } } /***/ }), /***/ 26: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/_vue-loader@15.9.8@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.9.8@vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox.vue?vue&type=template&id=d0387074& var render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "label", { staticClass: "yk-checkbox", class: [ _vm.border && _vm.checkboxSize ? "yk-checkbox--" + _vm.checkboxSize : "", { "is-disabled": _vm.isDisabled }, { "is-bordered": _vm.border }, { "is-checked": _vm.isChecked }, ], attrs: { id: _vm.id }, }, [ _c( "span", { staticClass: "yk-checkbox__input", class: { "is-disabled": _vm.isDisabled, "is-checked": _vm.isChecked, "is-indeterminate": _vm.indeterminate, "is-focus": _vm.focus, }, attrs: { tabindex: _vm.indeterminate ? 0 : false, role: _vm.indeterminate ? "checkbox" : false, "aria-checked": _vm.indeterminate ? "mixed" : false, }, }, [ _c("span", { staticClass: "yk-checkbox__inner" }), _vm.trueLabel || _vm.falseLabel ? _c("input", { directives: [ { name: "model", rawName: "v-model", value: _vm.model, expression: "model", }, ], staticClass: "yk-checkbox__original", attrs: { type: "checkbox", "aria-hidden": _vm.indeterminate ? "true" : "false", name: _vm.name, disabled: _vm.isDisabled, "true-value": _vm.trueLabel, "false-value": _vm.falseLabel, }, domProps: { checked: Array.isArray(_vm.model) ? _vm._i(_vm.model, null) > -1 : _vm._q(_vm.model, _vm.trueLabel), }, on: { change: [ function ($event) { var $$a = _vm.model, $$el = $event.target, $$c = $$el.checked ? _vm.trueLabel : _vm.falseLabel if (Array.isArray($$a)) { var $$v = null, $$i = _vm._i($$a, $$v) if ($$el.checked) { $$i < 0 && (_vm.model = $$a.concat([$$v])) } else { $$i > -1 && (_vm.model = $$a .slice(0, $$i) .concat($$a.slice($$i + 1))) } } else { _vm.model = $$c } }, _vm.handleChange, ], focus: function ($event) { _vm.focus = true }, blur: function ($event) { _vm.focus = false }, }, }) : _c("input", { directives: [ { name: "model", rawName: "v-model", value: _vm.model, expression: "model", }, ], staticClass: "yk-checkbox__original", attrs: { type: "checkbox", "aria-hidden": _vm.indeterminate ? "true" : "false", disabled: _vm.isDisabled, name: _vm.name, }, domProps: { value: _vm.label, checked: Array.isArray(_vm.model) ? _vm._i(_vm.model, _vm.label) > -1 : _vm.model, }, on: { change: [ function ($event) { var $$a = _vm.model, $$el = $event.target, $$c = $$el.checked ? true : false if (Array.isArray($$a)) { var $$v = _vm.label, $$i = _vm._i($$a, $$v) if ($$el.checked) { $$i < 0 && (_vm.model = $$a.concat([$$v])) } else { $$i > -1 && (_vm.model = $$a .slice(0, $$i) .concat($$a.slice($$i + 1))) } } else { _vm.model = $$c } }, _vm.handleChange, ], focus: function ($event) { _vm.focus = true }, blur: function ($event) { _vm.focus = false }, }, }), ] ), _vm.$slots.default || _vm.label ? _c( "span", { staticClass: "yk-checkbox__label" }, [ _vm._t("default"), !_vm.$slots.default ? [_vm._v(_vm._s(_vm.label))] : _vm._e(), ], 2 ) : _vm._e(), ] ) } var staticRenderFns = [] render._withStripped = true // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=template&id=d0387074& // EXTERNAL MODULE: ./src/mixins/emitter.js var emitter = __webpack_require__(6); // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.9.8@vue-loader/lib??vue-loader-options!./packages/checkbox/src/checkbox.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var checkboxvue_type_script_lang_js_ = ({ name: 'YkCheckbox', mixins: [emitter["a" /* default */]], inject: { ykForm: { default: '' }, ykFormItem: { default: '' } }, componentName: 'YkCheckbox', data: function data() { return { selfModel: false, focus: false, isLimitExceeded: false }; }, computed: { model: { get: function get() { return this.isGroup ? this.store : this.value !== undefined ? this.value : this.selfModel; }, set: function set(val) { if (this.isGroup) { this.isLimitExceeded = false; this._checkboxGroup.min !== undefined && val.length < this._checkboxGroup.min && (this.isLimitExceeded = true); this._checkboxGroup.max !== undefined && val.length > this._checkboxGroup.max && (this.isLimitExceeded = true); this.isLimitExceeded === false && this.dispatch('YkCheckboxGroup', 'input', [val]); } else { this.$emit('input', val); this.selfModel = val; } } }, isChecked: function isChecked() { if ({}.toString.call(this.model) === '[object Boolean]') { return this.model; } else if (Array.isArray(this.model)) { return this.model.indexOf(this.label) > -1; } else if (this.model !== null && this.model !== undefined) { return this.model === this.trueLabel; } }, isGroup: function isGroup() { var parent = this.$parent; while (parent) { if (parent.$options.componentName !== 'YkCheckboxGroup') { parent = parent.$parent; } else { this._checkboxGroup = parent; return true; } } return false; }, store: function store() { return this._checkboxGroup ? this._checkboxGroup.value : this.value; }, /* used to make the isDisabled judgment under max/min props */ isLimitDisabled: function isLimitDisabled() { var _checkboxGroup = this._checkboxGroup, max = _checkboxGroup.max, min = _checkboxGroup.min; return !!(max || min) && this.model.length >= max && !this.isChecked || this.model.length <= min && this.isChecked; }, isDisabled: function isDisabled() { return this.isGroup ? this._checkboxGroup.disabled || this.disabled || (this.ykForm || {}).disabled || this.isLimitDisabled : this.disabled || (this.ykForm || {}).disabled; }, _ykFormItemSize: function _ykFormItemSize() { return (this.ykFormItem || {}).ykFormItemSize; }, checkboxSize: function checkboxSize() { var temCheckboxSize = this.size || this._ykFormItemSize || (this.$ELEMENT || {}).size; return this.isGroup ? this._checkboxGroup.checkboxGroupSize || temCheckboxSize : temCheckboxSize; } }, props: { value: {}, label: {}, indeterminate: Boolean, disabled: Boolean, checked: Boolean, name: String, trueLabel: [String, Number], falseLabel: [String, Number], id: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/ controls: String, /* 当indeterminate为真时,为controls提供相关连的checkbox的id,表明元素间的控制关系*/ border: Boolean, size: String }, methods: { addToStore: function addToStore() { if (Array.isArray(this.model) && this.model.indexOf(this.label) === -1) { this.model.push(this.label); } else { this.model = this.trueLabel || true; } }, handleChange: function handleChange(ev) { var _this = this; if (this.isLimitExceeded) return; var value = void 0; if (ev.target.checked) { value = this.trueLabel === undefined ? true : this.trueLabel; } else { value = this.falseLabel === undefined ? false : this.falseLabel; } this.$emit('change', value, ev); this.$nextTick(function () { if (_this.isGroup) { _this.dispatch('YkCheckboxGroup', 'change', [_this._checkboxGroup.value]); } }); } }, created: function created() { this.checked && this.addToStore(); }, mounted: function mounted() { // 为indeterminate元素 添加aria-controls 属性 if (this.indeterminate) { this.$el.setAttribute('aria-controls', this.controls); } }, watch: { value: function value(_value) { this.dispatch('YkFormItem', 'yk.form.change', _value); } } }); // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue?vue&type=script&lang=js& /* harmony default export */ var src_checkboxvue_type_script_lang_js_ = (checkboxvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/_vue-loader@15.9.8@vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(2); // CONCATENATED MODULE: ./packages/checkbox/src/checkbox.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( src_checkboxvue_type_script_lang_js_, render, staticRenderFns, false, null, null, null ) /* hot reload */ if (false) { var api; } component.options.__file = "packages/checkbox/src/checkbox.vue" /* harmony default export */ var src_checkbox = (component.exports); // CONCATENATED MODULE: ./packages/checkbox/index.js /* istanbul ignore next */ src_checkbox.install = function (Vue) { Vue.component(src_checkbox.name, src_checkbox); }; /* harmony default export */ var packages_checkbox = __webpack_exports__["default"] = (src_checkbox); /***/ }), /***/ 3: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return noop; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return hasOwn; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return toObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return getValueByPath; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return getPropByPath; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return generateId; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return valueEquals; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return escapeRegexpString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return arrayFindIndex; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return arrayFind; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return coerceTruthyValueToArray; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return isIE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return isEdge; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return isFirefox; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return autoprefixer; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return kebabCase; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return capitalize; }); /* unused harmony export looseEqual */ /* unused harmony export arrayEquals */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return isEqual; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return isEmpty; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return rafThrottle; }); /* unused harmony export objToArray */ /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var element_ui_src_utils_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var hasOwnProperty = Object.prototype.hasOwnProperty; function noop() {}; function hasOwn(obj, key) { return hasOwnProperty.call(obj, key); }; function extend(to, _from) { for (var key in _from) { to[key] = _from[key]; } return to; }; function toObject(arr) { var res = {}; for (var i = 0; i < arr.length; i++) { if (arr[i]) { extend(res, arr[i]); } } return res; }; var getValueByPath = function getValueByPath(object, prop) { prop = prop || ''; var paths = prop.split('.'); var current = object; var result = null; for (var i = 0, j = paths.length; i < j; i++) { var path = paths[i]; if (!current) break; if (i === j - 1) { result = current[path]; break; } current = current[path]; } return result; }; function getPropByPath(obj, path, strict) { var tempObj = obj; path = path.replace(/\[(\w+)\]/g, '.$1'); path = path.replace(/^\./, ''); var keyArr = path.split('.'); var i = 0; for (var len = keyArr.length; i < len - 1; ++i) { if (!tempObj && !strict) break; var key = keyArr[i]; if (key in tempObj) { tempObj = tempObj[key]; } else { if (strict) { throw new Error('please transfer a valid prop path to form item!'); } break; } } return { o: tempObj, k: keyArr[i], v: tempObj ? tempObj[keyArr[i]] : null }; }; var generateId = function generateId() { return Math.floor(Math.random() * 10000); }; var valueEquals = function valueEquals(a, b) { // see: https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript if (a === b) return true; if (!(a instanceof Array)) return false; if (!(b instanceof Array)) return false; if (a.length !== b.length) return false; for (var i = 0; i !== a.length; ++i) { if (a[i] !== b[i]) return false; } return true; }; var escapeRegexpString = function escapeRegexpString() { var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; return String(value).replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); }; // TODO: use native Array.find, Array.findIndex when IE support is dropped var arrayFindIndex = function arrayFindIndex(arr, pred) { for (var i = 0; i !== arr.length; ++i) { if (pred(arr[i])) { return i; } } return -1; }; var arrayFind = function arrayFind(arr, pred) { var idx = arrayFindIndex(arr, pred); return idx !== -1 ? arr[idx] : undefined; }; // coerce truthy value to array var coerceTruthyValueToArray = function coerceTruthyValueToArray(val) { if (Array.isArray(val)) { return val; } else if (val) { return [val]; } else { return []; } }; var isIE = function isIE() { return !vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer && !isNaN(Number(document.documentMode)); }; var isEdge = function isEdge() { return !vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer && navigator.userAgent.indexOf('Edge') > -1; }; var isFirefox = function isFirefox() { return !vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer && !!window.navigator.userAgent.match(/firefox/i); }; var autoprefixer = function autoprefixer(style) { if ((typeof style === 'undefined' ? 'undefined' : _typeof(style)) !== 'object') return style; var rules = ['transform', 'transition', 'animation']; var prefixes = ['ms-', 'webkit-']; rules.forEach(function (rule) { var value = style[rule]; if (rule && value) { prefixes.forEach(function (prefix) { style[prefix + rule] = value; }); } }); return style; }; var kebabCase = function kebabCase(str) { var hyphenateRE = /([^-])([A-Z])/g; return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase(); }; var capitalize = function capitalize(str) { if (!Object(element_ui_src_utils_types__WEBPACK_IMPORTED_MODULE_1__[/* isString */ "e"])(str)) return str; return str.charAt(0).toUpperCase() + str.slice(1); }; var looseEqual = function looseEqual(a, b) { var isObjectA = Object(element_ui_src_utils_types__WEBPACK_IMPORTED_MODULE_1__[/* isObject */ "d"])(a); var isObjectB = Object(element_ui_src_utils_types__WEBPACK_IMPORTED_MODULE_1__[/* isObject */ "d"])(b); if (isObjectA && isObjectB) { return JSON.stringify(a) === JSON.stringify(b); } else if (!isObjectA && !isObjectB) { return String(a) === String(b); } else { return false; } }; var arrayEquals = function arrayEquals(arrayA, arrayB) { arrayA = arrayA || []; arrayB = arrayB || []; if (arrayA.length !== arrayB.length) { return false; } for (var i = 0; i < arrayA.length; i++) { if (!looseEqual(arrayA[i], arrayB[i])) { return false; } } return true; }; var isEqual = function isEqual(value1, value2) { if (Array.isArray(value1) && Array.isArray(value2)) { return arrayEquals(value1, value2); } return looseEqual(value1, value2); }; var isEmpty = function isEmpty(val) { // null or undefined if (val == null) return true; if (typeof val === 'boolean') return false; if (typeof val === 'number') return !val; if (val instanceof Error) return val.message === ''; switch (Object.prototype.toString.call(val)) { // String or Array case '[object String]': case '[object Array]': return !val.length; // Map or Set or File case '[object File]': case '[object Map]': case '[object Set]': { return !val.size; } // Plain Object case '[object Object]': { return !Object.keys(val).length; } } return false; }; function rafThrottle(fn) { var locked = false; return function () { var _this = this; for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (locked) return; locked = true; window.requestAnimationFrame(function (_) { fn.apply(_this, args); locked = false; }); }; } function objToArray(obj) { if (Array.isArray(obj)) { return obj; } return isEmpty(obj) ? [] : [obj]; } /***/ }), /***/ 40: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return cellStarts; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cellForced; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return defaultRenderCell; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return treeCellPrefix; }); /* harmony import */ var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); var cellStarts = { default: { order: '' }, selection: { width: 48, minWidth: 48, realWidth: 48, order: '', className: 'yk-table-column--selection' }, expand: { width: 48, minWidth: 48, realWidth: 48, order: '' }, index: { width: 48, minWidth: 48, realWidth: 48, order: '' } }; // 这些选项不应该被覆盖 var cellForced = { selection: { renderHeader: function renderHeader(h, _ref) { var store = _ref.store; return h('yk-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('yk-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,