83f059c831c897910dd007ad41c2a05afd99191d4c53bcbdd0ce35397c2af26905d16a268b0a124d69e6309d0ad540c4fb0054bdeb14c1f96665c6cabbd5c0 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var vue = require('vue');
  4. var index = require('../../checkbox/index.js');
  5. var index$1 = require('../../icon/index.js');
  6. var iconsVue = require('@element-plus/icons-vue');
  7. var types = require('../../../utils/types.js');
  8. var shared = require('@vue/shared');
  9. var objects = require('../../../utils/objects.js');
  10. const defaultClassNames = {
  11. selection: "table-column--selection",
  12. expand: "table__expand-column"
  13. };
  14. const cellStarts = {
  15. default: {
  16. order: ""
  17. },
  18. selection: {
  19. width: 48,
  20. minWidth: 48,
  21. realWidth: 48,
  22. order: ""
  23. },
  24. expand: {
  25. width: 48,
  26. minWidth: 48,
  27. realWidth: 48,
  28. order: ""
  29. },
  30. index: {
  31. width: 48,
  32. minWidth: 48,
  33. realWidth: 48,
  34. order: ""
  35. }
  36. };
  37. const getDefaultClassName = (type) => {
  38. return defaultClassNames[type] || "";
  39. };
  40. const cellForced = {
  41. selection: {
  42. renderHeader({
  43. store,
  44. column
  45. }) {
  46. var _a;
  47. function isDisabled() {
  48. return store.states.data.value && store.states.data.value.length === 0;
  49. }
  50. return vue.h(index.ElCheckbox, {
  51. disabled: isDisabled(),
  52. size: store.states.tableSize.value,
  53. indeterminate: store.states.selection.value.length > 0 && !store.states.isAllSelected.value,
  54. "onUpdate:modelValue": (_a = store.toggleAllSelection) != null ? _a : void 0,
  55. modelValue: store.states.isAllSelected.value,
  56. ariaLabel: column.label
  57. });
  58. },
  59. renderCell({
  60. row,
  61. column,
  62. store,
  63. $index
  64. }) {
  65. return vue.h(index.ElCheckbox, {
  66. disabled: column.selectable ? !column.selectable.call(null, row, $index) : false,
  67. size: store.states.tableSize.value,
  68. onChange: () => {
  69. store.commit("rowSelectedChanged", row);
  70. },
  71. onClick: (event) => event.stopPropagation(),
  72. modelValue: store.isSelected(row),
  73. ariaLabel: column.label
  74. });
  75. },
  76. sortable: false,
  77. resizable: false
  78. },
  79. index: {
  80. renderHeader({
  81. column
  82. }) {
  83. return column.label || "#";
  84. },
  85. renderCell({
  86. column,
  87. $index
  88. }) {
  89. let i = $index + 1;
  90. const index = column.index;
  91. if (types.isNumber(index)) {
  92. i = $index + index;
  93. } else if (shared.isFunction(index)) {
  94. i = index($index);
  95. }
  96. return vue.h("div", {}, [i]);
  97. },
  98. sortable: false
  99. },
  100. expand: {
  101. renderHeader({
  102. column
  103. }) {
  104. return column.label || "";
  105. },
  106. renderCell({
  107. column,
  108. row,
  109. store,
  110. expanded
  111. }) {
  112. const { ns } = store;
  113. const classes = [ns.e("expand-icon")];
  114. if (!column.renderExpand && expanded) {
  115. classes.push(ns.em("expand-icon", "expanded"));
  116. }
  117. const callback = function(e) {
  118. e.stopPropagation();
  119. store.toggleRowExpansion(row);
  120. };
  121. return vue.h("div", {
  122. class: classes,
  123. onClick: callback
  124. }, {
  125. default: () => {
  126. if (column.renderExpand) {
  127. return [
  128. column.renderExpand({
  129. expanded
  130. })
  131. ];
  132. }
  133. return [
  134. vue.h(index$1.ElIcon, null, {
  135. default: () => {
  136. return [vue.h(iconsVue.ArrowRight)];
  137. }
  138. })
  139. ];
  140. }
  141. });
  142. },
  143. sortable: false,
  144. resizable: false
  145. }
  146. };
  147. function defaultRenderCell({
  148. row,
  149. column,
  150. $index
  151. }) {
  152. var _a;
  153. const property = column.property;
  154. const value = property && objects.getProp(row, property).value;
  155. if (column && column.formatter) {
  156. return column.formatter(row, column, value, $index);
  157. }
  158. return ((_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) || "";
  159. }
  160. function treeCellPrefix({
  161. row,
  162. treeNode,
  163. store
  164. }, createPlaceholder = false) {
  165. const { ns } = store;
  166. if (!treeNode) {
  167. if (createPlaceholder) {
  168. return [
  169. vue.h("span", {
  170. class: ns.e("placeholder")
  171. })
  172. ];
  173. }
  174. return null;
  175. }
  176. const ele = [];
  177. const callback = function(e) {
  178. e.stopPropagation();
  179. if (treeNode.loading) {
  180. return;
  181. }
  182. store.loadOrToggle(row);
  183. };
  184. if (treeNode.indent) {
  185. ele.push(vue.h("span", {
  186. class: ns.e("indent"),
  187. style: { "padding-left": `${treeNode.indent}px` }
  188. }));
  189. }
  190. if (types.isBoolean(treeNode.expanded) && !treeNode.noLazyChildren) {
  191. const expandClasses = [
  192. ns.e("expand-icon"),
  193. treeNode.expanded ? ns.em("expand-icon", "expanded") : ""
  194. ];
  195. let icon = iconsVue.ArrowRight;
  196. if (treeNode.loading) {
  197. icon = iconsVue.Loading;
  198. }
  199. ele.push(vue.h("div", {
  200. class: expandClasses,
  201. onClick: callback
  202. }, {
  203. default: () => {
  204. return [
  205. vue.h(index$1.ElIcon, { class: { [ns.is("loading")]: treeNode.loading } }, {
  206. default: () => [vue.h(icon)]
  207. })
  208. ];
  209. }
  210. }));
  211. } else {
  212. ele.push(vue.h("span", {
  213. class: ns.e("placeholder")
  214. }));
  215. }
  216. return ele;
  217. }
  218. exports.cellForced = cellForced;
  219. exports.cellStarts = cellStarts;
  220. exports.defaultRenderCell = defaultRenderCell;
  221. exports.getDefaultClassName = getDefaultClassName;
  222. exports.treeCellPrefix = treeCellPrefix;
  223. //# sourceMappingURL=config.js.map