descriptions.js 14 KB

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