descriptions.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 = 135);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 135:
  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__cell': true,
  124. 'el-descriptions-item__label': true,
  125. 'has-colon': elDescriptions.border ? false : elDescriptions.colon,
  126. 'is-bordered-label': elDescriptions.border
  127. }, _ref[item.labelClassName] = true, _ref),
  128. style: item.labelStyle,
  129. attrs: { colSpan: item.props.span
  130. }
  131. },
  132. [item.label]
  133. );
  134. })]
  135. ), h(
  136. 'tr',
  137. { 'class': 'el-descriptions-row' },
  138. [row.map(function (item) {
  139. return h(
  140. 'td',
  141. {
  142. 'class': ['el-descriptions-item__cell', 'el-descriptions-item__content', item.contentClassName],
  143. style: item.contentStyle,
  144. attrs: { colSpan: item.props.span
  145. }
  146. },
  147. [item.slots.default]
  148. );
  149. })]
  150. )]);
  151. }
  152. if (elDescriptions.border) {
  153. return h('tbody', [h(
  154. 'tr',
  155. { 'class': 'el-descriptions-row' },
  156. [row.map(function (item) {
  157. var _ref2;
  158. return [h(
  159. 'th',
  160. {
  161. 'class': (_ref2 = {
  162. 'el-descriptions-item__cell': true,
  163. 'el-descriptions-item__label': true,
  164. 'is-bordered-label': elDescriptions.border
  165. }, _ref2[item.labelClassName] = true, _ref2),
  166. style: item.labelStyle,
  167. attrs: { colSpan: '1'
  168. }
  169. },
  170. [item.label]
  171. ), h(
  172. 'td',
  173. {
  174. 'class': ['el-descriptions-item__cell', 'el-descriptions-item__content', item.contentClassName],
  175. style: item.contentStyle,
  176. attrs: { colSpan: item.props.span * 2 - 1
  177. }
  178. },
  179. [item.slots.default]
  180. )];
  181. })]
  182. )]);
  183. }
  184. return h('tbody', [h(
  185. 'tr',
  186. { 'class': 'el-descriptions-row' },
  187. [row.map(function (item) {
  188. var _ref3;
  189. return h(
  190. 'td',
  191. { 'class': 'el-descriptions-item el-descriptions-item__cell', attrs: { colSpan: item.props.span }
  192. },
  193. [h(
  194. 'div',
  195. { 'class': 'el-descriptions-item__container' },
  196. [h(
  197. 'span',
  198. {
  199. 'class': (_ref3 = {
  200. 'el-descriptions-item__label': true,
  201. 'has-colon': elDescriptions.colon
  202. }, _ref3[item.labelClassName] = true, _ref3),
  203. style: item.labelStyle
  204. },
  205. [item.label]
  206. ), h(
  207. 'span',
  208. {
  209. 'class': ['el-descriptions-item__content', item.contentClassName],
  210. style: item.contentStyle
  211. },
  212. [item.slots.default]
  213. )]
  214. )]
  215. );
  216. })]
  217. )]);
  218. }
  219. });
  220. // EXTERNAL MODULE: external "element-ui/lib/utils/types"
  221. var types_ = __webpack_require__(17);
  222. // CONCATENATED MODULE: ./packages/descriptions/src/index.js
  223. 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; };
  224. var _components;
  225. /* harmony default export */ var src = ({
  226. name: 'ElDescriptions',
  227. components: (_components = {}, _components[descriptions_row.name] = descriptions_row, _components),
  228. props: {
  229. border: {
  230. type: Boolean,
  231. default: false
  232. },
  233. column: {
  234. type: Number,
  235. default: 3
  236. },
  237. direction: {
  238. type: String,
  239. default: 'horizontal'
  240. },
  241. size: {
  242. type: String
  243. // validator: isValidComponentSize,
  244. },
  245. title: {
  246. type: String,
  247. default: ''
  248. },
  249. extra: {
  250. type: String,
  251. default: ''
  252. },
  253. labelStyle: {
  254. type: Object
  255. },
  256. contentStyle: {
  257. type: Object
  258. },
  259. labelClassName: {
  260. type: String,
  261. default: ''
  262. },
  263. contentClassName: {
  264. type: String,
  265. default: ''
  266. },
  267. colon: {
  268. type: Boolean,
  269. default: true
  270. }
  271. },
  272. computed: {
  273. descriptionsSize: function descriptionsSize() {
  274. return this.size || (this.$ELEMENT || {}).size;
  275. }
  276. },
  277. provide: function provide() {
  278. return {
  279. elDescriptions: this
  280. };
  281. },
  282. methods: {
  283. getOptionProps: function getOptionProps(vnode) {
  284. if (vnode.componentOptions) {
  285. var componentOptions = vnode.componentOptions;
  286. var _componentOptions$pro = componentOptions.propsData,
  287. propsData = _componentOptions$pro === undefined ? {} : _componentOptions$pro,
  288. _componentOptions$Cto = componentOptions.Ctor,
  289. Ctor = _componentOptions$Cto === undefined ? {} : _componentOptions$Cto;
  290. var props = (Ctor.options || {}).props || {};
  291. var res = {};
  292. for (var k in props) {
  293. var v = props[k];
  294. var defaultValue = v.default;
  295. if (defaultValue !== undefined) {
  296. res[k] = Object(types_["isFunction"])(defaultValue) ? defaultValue.call(vnode) : defaultValue;
  297. }
  298. }
  299. return src_extends({}, res, propsData);
  300. }
  301. return {};
  302. },
  303. getSlots: function getSlots(vnode) {
  304. var _this = this;
  305. var componentOptions = vnode.componentOptions || {};
  306. var children = vnode.children || componentOptions.children || [];
  307. var slots = {};
  308. children.forEach(function (child) {
  309. if (!_this.isEmptyElement(child)) {
  310. var name = child.data && child.data.slot || 'default';
  311. slots[name] = slots[name] || [];
  312. if (child.tag === 'template') {
  313. slots[name].push(child.children);
  314. } else {
  315. slots[name].push(child);
  316. }
  317. }
  318. });
  319. return src_extends({}, slots);
  320. },
  321. isEmptyElement: function isEmptyElement(c) {
  322. return !(c.tag || c.text && c.text.trim() !== '');
  323. },
  324. filledNode: function filledNode(node, span, count) {
  325. var isLast = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  326. if (!node.props) {
  327. node.props = {};
  328. }
  329. if (span > count) {
  330. node.props.span = count;
  331. }
  332. if (isLast) {
  333. // set the max span, cause of the last td
  334. node.props.span = count;
  335. }
  336. return node;
  337. },
  338. getRows: function getRows() {
  339. var _this2 = this;
  340. var children = (this.$slots.default || []).filter(function (vnode) {
  341. return vnode.tag && vnode.componentOptions && vnode.componentOptions.Ctor.options.name === 'ElDescriptionsItem';
  342. });
  343. var nodes = children.map(function (vnode) {
  344. return {
  345. props: _this2.getOptionProps(vnode),
  346. slots: _this2.getSlots(vnode),
  347. vnode: vnode
  348. };
  349. });
  350. var rows = [];
  351. var temp = [];
  352. var count = this.column;
  353. nodes.forEach(function (node, index) {
  354. var span = node.props.span || 1;
  355. if (index === children.length - 1) {
  356. temp.push(_this2.filledNode(node, span, count, true));
  357. rows.push(temp);
  358. return;
  359. }
  360. if (span < count) {
  361. count -= span;
  362. temp.push(node);
  363. } else {
  364. temp.push(_this2.filledNode(node, span, count));
  365. rows.push(temp);
  366. count = _this2.column;
  367. temp = [];
  368. }
  369. });
  370. return rows;
  371. }
  372. },
  373. render: function render() {
  374. var h = arguments[0];
  375. var title = this.title,
  376. extra = this.extra,
  377. border = this.border,
  378. descriptionsSize = this.descriptionsSize,
  379. $slots = this.$slots;
  380. var rows = this.getRows();
  381. return h(
  382. 'div',
  383. { 'class': 'el-descriptions' },
  384. [title || extra || $slots.title || $slots.extra ? h(
  385. 'div',
  386. { 'class': 'el-descriptions__header' },
  387. [h(
  388. 'div',
  389. { 'class': 'el-descriptions__title' },
  390. [$slots.title ? $slots.title : title]
  391. ), h(
  392. 'div',
  393. { 'class': 'el-descriptions__extra' },
  394. [$slots.extra ? $slots.extra : extra]
  395. )]
  396. ) : null, h(
  397. 'div',
  398. { 'class': 'el-descriptions__body' },
  399. [h(
  400. 'table',
  401. { 'class': ['el-descriptions__table', { 'is-bordered': border }, descriptionsSize ? 'el-descriptions--' + descriptionsSize : ''] },
  402. [rows.map(function (row) {
  403. return h(descriptions_row, {
  404. attrs: { row: row }
  405. });
  406. })]
  407. )]
  408. )]
  409. );
  410. }
  411. });
  412. // CONCATENATED MODULE: ./packages/descriptions/index.js
  413. /* istanbul ignore next */
  414. src.install = function install(Vue) {
  415. Vue.component(src.name, src);
  416. };
  417. /* harmony default export */ var descriptions = __webpack_exports__["default"] = (src);
  418. /***/ }),
  419. /***/ 17:
  420. /***/ (function(module, exports) {
  421. module.exports = require("element-ui/lib/utils/types");
  422. /***/ })
  423. /******/ });