descriptions.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "/dist/";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 134);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 134:
  90. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91. "use strict";
  92. __webpack_require__.r(__webpack_exports__);
  93. // CONCATENATED MODULE: ./packages/descriptions/src/descriptions-row.js
  94. 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; };
  95. /* harmony default export */ var descriptions_row = ({
  96. name: 'ElDescriptionsRow',
  97. props: {
  98. row: {
  99. type: Array
  100. }
  101. },
  102. inject: ['elDescriptions'],
  103. render: function render(h) {
  104. var elDescriptions = this.elDescriptions;
  105. var row = (this.row || []).map(function (item) {
  106. return _extends({}, item, {
  107. label: item.slots.label || item.props.label
  108. }, ['labelClassName', 'contentClassName', 'labelStyle', 'contentStyle'].reduce(function (res, key) {
  109. res[key] = item.props[key] || elDescriptions[key];
  110. return res;
  111. }, {}));
  112. });
  113. if (elDescriptions.direction === 'vertical') {
  114. return h('tbody', [h(
  115. 'tr',
  116. { 'class': 'el-descriptions-row' },
  117. [row.map(function (item) {
  118. var _ref;
  119. return h(
  120. 'th',
  121. {
  122. 'class': (_ref = {
  123. 'el-descriptions-item__label': true,
  124. 'has-colon': elDescriptions.border ? false : elDescriptions.colon,
  125. 'is-bordered-label': elDescriptions.border
  126. }, _ref[item.labelClassName] = true, _ref),
  127. style: item.labelStyle,
  128. attrs: { colSpan: item.props.span
  129. }
  130. },
  131. [item.label]
  132. );
  133. })]
  134. ), h(
  135. 'tr',
  136. { 'class': 'el-descriptions-row' },
  137. [row.map(function (item) {
  138. var _h;
  139. return h(
  140. 'td',
  141. (_h = {
  142. 'class': 'el-descriptions-item__content'
  143. }, _h['class'] = ['el-descriptions-item__content', item.contentClassName], _h.style = item.contentStyle, _h.attrs = {
  144. colSpan: item.props.span
  145. }, _h),
  146. [item.slots.default]
  147. );
  148. })]
  149. )]);
  150. }
  151. if (elDescriptions.border) {
  152. return h('tbody', [h(
  153. 'tr',
  154. { 'class': 'el-descriptions-row' },
  155. [row.map(function (item) {
  156. var _ref2;
  157. return [h(
  158. 'th',
  159. {
  160. 'class': (_ref2 = {
  161. 'el-descriptions-item__label': true,
  162. 'is-bordered-label': elDescriptions.border
  163. }, _ref2[item.labelClassName] = true, _ref2),
  164. style: item.labelStyle,
  165. attrs: { colSpan: '1'
  166. }
  167. },
  168. [item.label]
  169. ), h(
  170. 'td',
  171. {
  172. 'class': ['el-descriptions-item__content', item.contentClassName],
  173. style: item.contentStyle,
  174. attrs: { colSpan: item.props.span * 2 - 1
  175. }
  176. },
  177. [item.slots.default]
  178. )];
  179. })]
  180. )]);
  181. }
  182. return h('tbody', [h(
  183. 'tr',
  184. { 'class': 'el-descriptions-row' },
  185. [row.map(function (item) {
  186. var _ref3;
  187. return h(
  188. 'td',
  189. { 'class': 'el-descriptions-item', attrs: { colSpan: item.props.span }
  190. },
  191. [h(
  192. 'div',
  193. { 'class': 'el-descriptions-item__container' },
  194. [h(
  195. 'span',
  196. {
  197. 'class': (_ref3 = {
  198. 'el-descriptions-item__label': true,
  199. 'has-colon': elDescriptions.colon
  200. }, _ref3[item.labelClassName] = true, _ref3),
  201. style: item.labelStyle
  202. },
  203. [item.props.label]
  204. ), h(
  205. 'span',
  206. {
  207. 'class': ['el-descriptions-item__content', item.contentClassName],
  208. style: item.contentStyle
  209. },
  210. [item.slots.default]
  211. )]
  212. )]
  213. );
  214. })]
  215. )]);
  216. }
  217. });
  218. // EXTERNAL MODULE: external "element-ui/lib/utils/types"
  219. var types_ = __webpack_require__(17);
  220. // CONCATENATED MODULE: ./packages/descriptions/src/index.js
  221. var src_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; };
  222. var _components;
  223. /* harmony default export */ var src = ({
  224. name: 'ElDescriptions',
  225. components: (_components = {}, _components[descriptions_row.name] = descriptions_row, _components),
  226. props: {
  227. border: {
  228. type: Boolean,
  229. default: false
  230. },
  231. column: {
  232. type: Number,
  233. default: 3
  234. },
  235. direction: {
  236. type: String,
  237. default: 'horizontal'
  238. },
  239. size: {
  240. type: String
  241. // validator: isValidComponentSize,
  242. },
  243. title: {
  244. type: String,
  245. default: ''
  246. },
  247. extra: {
  248. type: String,
  249. default: ''
  250. },
  251. labelStyle: {
  252. type: Object
  253. },
  254. contentStyle: {
  255. type: Object
  256. },
  257. labelClassName: {
  258. type: String,
  259. default: ''
  260. },
  261. contentClassName: {
  262. type: String,
  263. default: ''
  264. },
  265. colon: {
  266. type: Boolean,
  267. default: true
  268. }
  269. },
  270. computed: {
  271. descriptionsSize: function descriptionsSize() {
  272. return this.size || (this.$ELEMENT || {}).size;
  273. }
  274. },
  275. provide: function provide() {
  276. return {
  277. elDescriptions: this
  278. };
  279. },
  280. methods: {
  281. getOptionProps: function getOptionProps(vnode) {
  282. if (vnode.componentOptions) {
  283. var componentOptions = vnode.componentOptions;
  284. var _componentOptions$pro = componentOptions.propsData,
  285. propsData = _componentOptions$pro === undefined ? {} : _componentOptions$pro,
  286. _componentOptions$Cto = componentOptions.Ctor,
  287. Ctor = _componentOptions$Cto === undefined ? {} : _componentOptions$Cto;
  288. var props = (Ctor.options || {}).props || {};
  289. var res = {};
  290. for (var k in props) {
  291. var v = props[k];
  292. var defaultValue = v.default;
  293. if (defaultValue !== undefined) {
  294. res[k] = Object(types_["isFunction"])(defaultValue) ? defaultValue.call(vnode) : defaultValue;
  295. }
  296. }
  297. return src_extends({}, res, propsData);
  298. }
  299. return {};
  300. },
  301. getSlots: function getSlots(vnode) {
  302. var _this = this;
  303. var componentOptions = vnode.componentOptions || {};
  304. var children = vnode.children || componentOptions.children || [];
  305. var slots = {};
  306. children.forEach(function (child) {
  307. if (!_this.isEmptyElement(child)) {
  308. var name = child.data && child.data.slot || 'default';
  309. slots[name] = slots[name] || [];
  310. if (child.tag === 'template') {
  311. slots[name].push(child.children);
  312. } else {
  313. slots[name].push(child);
  314. }
  315. }
  316. });
  317. return src_extends({}, slots);
  318. },
  319. isEmptyElement: function isEmptyElement(c) {
  320. return !(c.tag || c.text && c.text.trim() !== '');
  321. },
  322. filledNode: function filledNode(node, span, count) {
  323. var isLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  324. if (!node.props) {
  325. node.props = {};
  326. }
  327. if (span > count) {
  328. node.props.span = count;
  329. }
  330. if (isLast) {
  331. // set the max span, cause of the last td
  332. node.props.span = count;
  333. }
  334. return node;
  335. },
  336. getRows: function getRows() {
  337. var _this2 = this;
  338. var children = (this.$slots.default || []).filter(function (vnode) {
  339. return vnode.tag && vnode.componentOptions && vnode.componentOptions.Ctor.options.name === 'ElDescriptionsItem';
  340. });
  341. var nodes = children.map(function (vnode) {
  342. return {
  343. props: _this2.getOptionProps(vnode),
  344. slots: _this2.getSlots(vnode),
  345. vnode: vnode
  346. };
  347. });
  348. var rows = [];
  349. var temp = [];
  350. var count = this.column;
  351. nodes.forEach(function (node, index) {
  352. var span = node.props.span || 1;
  353. if (index === children.length - 1) {
  354. temp.push(_this2.filledNode(node, span, count, true));
  355. rows.push(temp);
  356. return;
  357. }
  358. if (span < count) {
  359. count -= span;
  360. temp.push(node);
  361. } else {
  362. temp.push(_this2.filledNode(node, span, count));
  363. rows.push(temp);
  364. count = _this2.column;
  365. temp = [];
  366. }
  367. });
  368. return rows;
  369. }
  370. },
  371. render: function render() {
  372. var h = arguments[0];
  373. var title = this.title,
  374. extra = this.extra,
  375. border = this.border,
  376. descriptionsSize = this.descriptionsSize,
  377. $slots = this.$slots;
  378. var rows = this.getRows();
  379. return h(
  380. 'div',
  381. { 'class': 'el-descriptions' },
  382. [title || extra || $slots.title || $slots.extra ? h(
  383. 'div',
  384. { 'class': 'el-descriptions__header' },
  385. [h(
  386. 'div',
  387. { 'class': 'el-descriptions__title' },
  388. [$slots.title ? $slots.title : title]
  389. ), h(
  390. 'div',
  391. { 'class': 'el-descriptions__extra' },
  392. [$slots.extra ? $slots.extra : extra]
  393. )]
  394. ) : null, h(
  395. 'div',
  396. { 'class': 'el-descriptions__body' },
  397. [h(
  398. 'table',
  399. { 'class': [{ 'is-bordered': border }, descriptionsSize ? 'el-descriptions--' + descriptionsSize : ''] },
  400. [rows.map(function (row) {
  401. return h(descriptions_row, {
  402. attrs: { row: row }
  403. });
  404. })]
  405. )]
  406. )]
  407. );
  408. }
  409. });
  410. // CONCATENATED MODULE: ./packages/descriptions/index.js
  411. /* istanbul ignore next */
  412. src.install = function install(Vue) {
  413. Vue.component(src.name, src);
  414. };
  415. /* harmony default export */ var descriptions = __webpack_exports__["default"] = (src);
  416. /***/ }),
  417. /***/ 17:
  418. /***/ (function(module, exports) {
  419. module.exports = require("element-ui/lib/utils/types");
  420. /***/ })
  421. /******/ });