zartui 2.0.80-beta.2 → 2.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/zart.js CHANGED
@@ -29376,18 +29376,23 @@ var tabbar_item_createNamespace = Object(utils["b" /* createNamespace */])('tabb
29376
29376
  })])]);
29377
29377
  }
29378
29378
  }));
29379
+ // CONCATENATED MODULE: ./es/table/type.js
29380
+ var SortOrderEnum;
29381
+
29382
+ (function (SortOrderEnum) {
29383
+ SortOrderEnum["ASCEND"] = "ascend";
29384
+ SortOrderEnum["DESCEND"] = "descend";
29385
+ })(SortOrderEnum || (SortOrderEnum = {}));
29379
29386
  // CONCATENATED MODULE: ./es/table/index.js
29380
29387
 
29381
29388
 
29382
29389
 
29390
+
29391
+
29383
29392
  var table_createNamespace = Object(utils["b" /* createNamespace */])('table'),
29384
29393
  table_createComponent = table_createNamespace[0],
29385
29394
  table_bem = table_createNamespace[1];
29386
29395
 
29387
- var defaultData = function defaultData() {
29388
- return {};
29389
- };
29390
-
29391
29396
  /* harmony default export */ var table = (table_createComponent({
29392
29397
  props: {
29393
29398
  headList: {
@@ -29398,269 +29403,199 @@ var defaultData = function defaultData() {
29398
29403
  type: Array,
29399
29404
  default: []
29400
29405
  },
29401
- outline: {
29406
+ bordered: {
29402
29407
  type: Boolean,
29403
29408
  default: true
29404
29409
  },
29405
- headColor: {
29406
- type: String,
29407
- default: "#000"
29408
- },
29409
- headBackground: {
29410
- type: String,
29411
- default: "#fafafa"
29412
- },
29413
- dataColor: {
29414
- type: String,
29415
- default: "#000"
29416
- },
29417
- dataBackground: {
29418
- type: String,
29419
- default: "#fff"
29420
- },
29421
- hideTableHead: {
29410
+ striped: {
29422
29411
  type: Boolean,
29423
29412
  default: false
29424
29413
  }
29425
29414
  },
29426
29415
  data: function data() {
29427
- return defaultData();
29416
+ return {
29417
+ pingedLeft: false,
29418
+ sortOrder: '',
29419
+ sortKey: ''
29420
+ };
29428
29421
  },
29429
29422
  computed: {
29430
- fixedColumnLeft: function fixedColumnLeft() {
29423
+ fixedColumn: function fixedColumn() {
29431
29424
  return this.headList.filter(function (v) {
29432
- return v.fixedLeft;
29425
+ return v.fixed;
29433
29426
  });
29434
29427
  },
29435
- fixedColumnRight: function fixedColumnRight() {
29436
- return this.headList.filter(function (v) {
29437
- return v.fixedRight;
29438
- });
29428
+ fixed: function fixed() {
29429
+ return this.fixedColumn.length > 0;
29439
29430
  },
29440
- resortHeadList: function resortHeadList() {
29441
- // 对表头数组重新排序,需要固定的表头向左对齐
29442
- return this.fixedColumnLeft.concat(this.headList.filter(function (v) {
29443
- return !v.fixedLeft && !v.fixedRight;
29444
- })).concat(this.fixedColumnRight);
29445
- },
29446
- hasSummary: function hasSummary() {
29447
- return this.headList.filter(function (v) {
29448
- return v.showSummary;
29449
- }).length > 0;
29450
- }
29451
- },
29452
- mounted: function mounted() {
29453
- var columnTotalWidth = 0;
29454
- this.headList.forEach(function (v, i) {
29455
- var dom = document.getElementById("tableHead" + i);
29456
-
29457
- if (dom) {
29458
- columnTotalWidth += dom.clientWidth || 0;
29459
- }
29460
- });
29461
- var box = document.getElementById("normalBoxID");
29462
- var boxWidth = 0;
29463
-
29464
- if (box) {
29465
- boxWidth = box.clientWidth;
29466
- }
29467
-
29468
- if (this.fixedColumnLeft && this.fixedColumnLeft.length || this.fixedColumnRight && this.fixedColumnRight.length) {
29469
- // 当表格横向出现滚动时,给固定列加一个box-shadow
29470
- var fixedBoxRight = document.getElementById("fixedRightBoxID");
29471
-
29472
- if (fixedBoxRight && columnTotalWidth > boxWidth) {
29473
- fixedBoxRight.classList.add("shadow");
29474
- }
29475
-
29476
- if (box) {
29477
- box.addEventListener("scroll", function (e) {
29478
- var fixedBoxLeft = document.getElementById("fixedLeftBoxID");
29479
-
29480
- if (fixedBoxLeft) {
29481
- if (e && e.target && e.target.scrollLeft > 0) {
29482
- fixedBoxLeft.classList.add("shadow");
29483
- } else {
29484
- fixedBoxLeft.classList.remove("shadow");
29485
- }
29486
- }
29487
-
29488
- if (fixedBoxRight) {
29489
- if (e && e.target && e.target.scrollLeft + e.target.clientWidth >= columnTotalWidth - 1) {
29490
- fixedBoxRight.classList.remove("shadow");
29491
- } else {
29492
- fixedBoxRight.classList.add("shadow");
29493
- }
29494
- }
29495
- });
29496
- }
29497
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
29498
-
29499
-
29500
- var fixedLeftIndexList = this.headList.map(function (v, i) {
29501
- if (v.fixedLeft) {
29502
- return "tableHead" + i;
29503
- } else {
29504
- return "";
29505
- }
29506
- }).filter(function (v) {
29507
- return v !== "";
29508
- });
29431
+ formatColumns: function formatColumns() {
29432
+ var _this = this;
29509
29433
 
29510
- if (fixedLeftIndexList.length > 0) {
29511
- fixedLeftIndexList.forEach(function (current, index) {
29512
- var fixedDom = document.getElementById("fixedHeadLeft" + index);
29513
- var normalDom = document.getElementById(current);
29434
+ var columns = [];
29435
+ var left = 0;
29436
+ this.headList.forEach(function (element, index) {
29437
+ var column = {};
29438
+ var preColumn = _this.headList[index - 1];
29439
+ var nextColumn = _this.headList[index + 1];
29514
29440
 
29515
- if (fixedDom && normalDom) {
29516
- fixedDom.style.width = normalDom.offsetWidth + "px";
29441
+ if (element.sorter && element.defaultSortOrder) {
29442
+ _this.sortOrder = element.defaultSortOrder || '';
29443
+ _this.sortKey = element.key;
29517
29444
  }
29518
- }, 0);
29519
- } // 获取需固定列的实际宽度,用于设置绝对定位元素的宽度
29520
-
29521
29445
 
29522
- var fixedRightIndexList = this.headList.map(function (v, i) {
29523
- if (v.fixedRight) {
29524
- return "tableHead" + i;
29525
- } else {
29526
- return "";
29527
- }
29528
- }).filter(function (v) {
29529
- return v !== "";
29530
- });
29531
-
29532
- if (fixedRightIndexList.length > 0) {
29533
- fixedRightIndexList.forEach(function (current, index) {
29534
- var fixedDom = document.getElementById("fixedHeadRight" + index);
29535
- var normalDom = document.getElementById(current);
29536
-
29537
- if (fixedDom && normalDom) {
29538
- fixedDom.style.width = normalDom.offsetWidth + "px";
29446
+ if (preColumn) {
29447
+ left += Number(preColumn.width.split('px')[0]);
29448
+ column.left = left + "px";
29449
+ } else {
29450
+ column.left = 0;
29539
29451
  }
29540
- }, 0); // 当存在右侧固定列,且列宽度不足以撑满容器时,将最后一列宽度拉长到填满
29541
29452
 
29542
- if (columnTotalWidth < boxWidth) {
29543
- var lastColumn = document.getElementById("tableHead" + (this.headList.length - 1));
29544
-
29545
- if (lastColumn) {
29546
- lastColumn.classList.add("widen");
29547
- lastColumn.style.width = "unset";
29548
- lastColumn.style.flex = "1";
29453
+ if (element.fixed && !nextColumn.fixed) {
29454
+ column.lastFixLeft = true;
29549
29455
  }
29550
- }
29456
+
29457
+ columns.push(_extends({}, element, column));
29458
+ });
29459
+ return columns;
29551
29460
  }
29552
29461
  },
29553
- watch: {},
29554
29462
  methods: {
29555
- genColumn: function genColumn(headObj, index, isFixed) {
29556
- var h = this.$createElement;
29557
-
29558
- var _ref = this,
29559
- slots = _ref.slots,
29560
- hideTableHead = _ref.hideTableHead;
29561
-
29562
- var headItemStyle = {
29563
- color: this.headColor,
29564
- background: this.headBackground
29565
- };
29566
- var dataStyle = {
29567
- color: this.dataColor,
29568
- background: this.dataBackground
29569
- };
29570
- var idName = "tableHead" + index;
29571
-
29572
- if (isFixed === "left") {
29573
- idName = "fixedHeadLeft" + index;
29463
+ onScroll: function onScroll(_ref) {
29464
+ var currentTarget = _ref.currentTarget,
29465
+ scrollLeft = _ref.scrollLeft;
29466
+ var mergedScrollLeft = typeof scrollLeft === 'number' ? scrollLeft : currentTarget.scrollLeft;
29467
+ this.pingedLeft = mergedScrollLeft > 0;
29468
+ },
29469
+ getNextSortOrder: function getNextSortOrder(type) {
29470
+ if (!type) {
29471
+ return SortOrderEnum.ASCEND;
29574
29472
  }
29575
29473
 
29576
- if (isFixed === "right") {
29577
- idName = "fixedHeadRight" + index;
29474
+ if (type === SortOrderEnum.ASCEND) {
29475
+ return SortOrderEnum.DESCEND;
29578
29476
  }
29579
29477
 
29580
- var headRender = slots("head" + headObj.id) || headObj.label;
29478
+ return '';
29479
+ },
29480
+ onHeaderClick: function onHeaderClick(data) {
29481
+ if (!data.sorter) return;
29482
+ this.sortOrder = this.getNextSortOrder(data.key === this.sortKey ? this.sortOrder : '');
29483
+ this.sortKey = data.key;
29484
+ this.$emit('sort', {
29485
+ order: this.sortOrder,
29486
+ key: data.key
29487
+ });
29488
+ },
29489
+ getHead: function getHead(colData) {
29490
+ var _this2 = this;
29491
+
29492
+ var h = this.$createElement;
29581
29493
 
29582
- if ((headObj.fixedLeft || headObj.fixedRight) && !isFixed) {
29583
- // 被固定列遮住的列不显示内容
29584
- headRender = "";
29494
+ if ((colData == null ? void 0 : colData.colSpan) !== 0) {
29495
+ return h("th", {
29496
+ "class": table_bem({
29497
+ 'fix-left': colData.fixed,
29498
+ 'left-last': colData.lastFixLeft && this.pingedLeft
29499
+ }),
29500
+ "style": {
29501
+ left: colData.fixed ? colData.left : ''
29502
+ },
29503
+ "attrs": {
29504
+ "colspan": (colData == null ? void 0 : colData.colSpan) !== 1 ? colData == null ? void 0 : colData.colSpan : null
29505
+ }
29506
+ }, [h("div", {
29507
+ "class": table_bem('head'),
29508
+ "on": {
29509
+ "click": function click() {
29510
+ return _this2.onHeaderClick(colData);
29511
+ }
29512
+ }
29513
+ }, [h("span", [colData.label]), colData.sorter ? h("span", {
29514
+ "class": table_bem('head-sort')
29515
+ }, [h(es_icon, {
29516
+ "class": [colData.key === this.sortKey && this.sortOrder === SortOrderEnum.ASCEND ? table_bem('sort-active') : ''],
29517
+ "attrs": {
29518
+ "name": "spinner-shrink",
29519
+ "size": "12"
29520
+ },
29521
+ "style": {
29522
+ marginBottom: '-3px'
29523
+ }
29524
+ }), h(es_icon, {
29525
+ "class": [colData.key === this.sortKey && this.sortOrder === SortOrderEnum.DESCEND ? table_bem('sort-active') : ''],
29526
+ "attrs": {
29527
+ "name": "spinner-expand",
29528
+ "size": "12"
29529
+ },
29530
+ "style": {
29531
+ marginTop: '-3px'
29532
+ }
29533
+ })]) : ''])]);
29585
29534
  }
29535
+ },
29536
+ onClick: function onClick() {},
29537
+ getBody: function getBody(rowData, rowIndex) {
29538
+ var _this3 = this;
29586
29539
 
29587
- return h("div", {
29588
- "class": [table_bem(isFixed ? "fixed-head" : "head"), isFixed ? BORDER_SURROUND : BORDER_RIGHT],
29589
- "attrs": {
29590
- "id": idName
29591
- },
29592
- "style": isFixed ? "" : headObj.width ? "width:" + headObj.width + ";" : ""
29593
- }, [h("div", {
29594
- "directives": [{
29595
- name: "show",
29596
- value: !hideTableHead
29597
- }],
29598
- "class": [table_bem("head-item"), BORDER_TOP_BOTTOM],
29599
- "style": headItemStyle
29600
- }, [headRender]), this.dataList.map(function (data) {
29601
- var hide = (headObj.fixedLeft || headObj.fixedRight) && !isFixed;
29540
+ var h = this.$createElement;
29541
+ return h("tr", [this.formatColumns.map(function (colData) {
29542
+ var _additionalCellProps, _additionalCellProps2, _additionalCellProps3, _additionalCellProps4, _additionalCellProps5, _additionalCellProps6;
29602
29543
 
29603
- if (hide) {
29604
- // 被固定列遮住的列不显示内容
29605
- return h("div", {
29606
- "class": [table_bem("table-data"), BORDER_BOTTOM],
29607
- "style": dataStyle
29608
- });
29609
- } else if (data[headObj.key] && data[headObj.key].id && slots("data" + data[headObj.key].id)) {
29610
- return slots("data" + data[headObj.key].id);
29611
- } else {
29612
- return h("div", {
29613
- "class": [table_bem("table-data"), BORDER_BOTTOM],
29614
- "style": dataStyle
29615
- }, [data[headObj.key]]);
29544
+ var additionalCellProps;
29545
+
29546
+ if (colData.customCell) {
29547
+ additionalCellProps = colData.customCell(rowData, rowIndex);
29616
29548
  }
29617
- }), this.hasSummary ? headObj.showSummary ? h("div", {
29618
- "class": [table_bem("head-item"), BORDER_BOTTOM],
29619
- "style": headItemStyle
29620
- }, [this.dataList.reduce(function (prev, curr) {
29621
- return prev + curr[headObj.key];
29622
- }, 0)]) : h("div", {
29623
- "class": [table_bem("head-item"), BORDER_BOTTOM],
29624
- "style": headItemStyle
29625
- }, [headObj.summaryLabel || ""]) : ""]);
29549
+
29550
+ var style = _extends({}, colData.style);
29551
+
29552
+ style.left = colData.fixed ? colData.left : '';
29553
+ return ((_additionalCellProps = additionalCellProps) == null ? void 0 : _additionalCellProps.rowSpan) !== 0 && ((_additionalCellProps2 = additionalCellProps) == null ? void 0 : _additionalCellProps2.colSpan) !== 0 && h("td", {
29554
+ "on": {
29555
+ "click": function click() {
29556
+ return colData.onClick && colData.onClick(rowData, rowIndex);
29557
+ }
29558
+ },
29559
+ "class": table_bem({
29560
+ 'fix-left': colData.fixed,
29561
+ 'left-last': colData.lastFixLeft && _this3.pingedLeft
29562
+ }),
29563
+ "attrs": {
29564
+ "colspan": ((_additionalCellProps3 = additionalCellProps) == null ? void 0 : _additionalCellProps3.colSpan) !== 1 ? (_additionalCellProps4 = additionalCellProps) == null ? void 0 : _additionalCellProps4.colSpan : null,
29565
+ "rowspan": ((_additionalCellProps5 = additionalCellProps) == null ? void 0 : _additionalCellProps5.rowSpan) !== 1 ? (_additionalCellProps6 = additionalCellProps) == null ? void 0 : _additionalCellProps6.rowSpan : null
29566
+ },
29567
+ "style": style
29568
+ }, [rowData[colData.key]]);
29569
+ })]);
29626
29570
  }
29627
29571
  },
29628
29572
  render: function render(h) {
29629
- var _this = this;
29573
+ var _this4 = this;
29630
29574
 
29631
- var showFixed = this.dataList && this.dataList.length;
29632
29575
  return h("div", {
29633
- "class": table_bem(["", this.outline ? "" : "no-border"])
29634
- }, [h("div", {
29635
- "attrs": {
29636
- "id": "normalBoxID"
29637
- },
29638
- "class": [table_bem("normal-box"), BORDER_LEFT]
29639
- }, [this.resortHeadList.map(function (x, i) {
29640
- return _this.genColumn(x, i);
29641
- })]), h("div", {
29642
- "directives": [{
29643
- name: "show",
29644
- value: showFixed
29645
- }],
29646
- "attrs": {
29647
- "id": "fixedLeftBoxID"
29648
- },
29649
- "class": table_bem("fixed-left-box")
29650
- }, [this.fixedColumnLeft.map(function (x, i) {
29651
- return _this.genColumn(x, i, "left");
29652
- })]), h("div", {
29653
- "directives": [{
29654
- name: "show",
29655
- value: showFixed
29656
- }],
29657
- "attrs": {
29658
- "id": "fixedRightBoxID"
29659
- },
29660
- "class": table_bem("fixed-right-box")
29661
- }, [this.fixedColumnRight.map(function (x, i) {
29662
- return _this.genColumn(x, i, "right");
29663
- })])]);
29576
+ "class": table_bem({
29577
+ fixed: this.fixed,
29578
+ bordered: this.bordered,
29579
+ striped: this.striped
29580
+ }),
29581
+ "on": {
29582
+ "scroll": this.onScroll
29583
+ }
29584
+ }, [h("table", [h("colgroup", [this.headList.map(function (item) {
29585
+ return h("col", {
29586
+ "style": {
29587
+ width: item.width
29588
+ }
29589
+ });
29590
+ })]), h("thead", {
29591
+ "class": table_bem('thead')
29592
+ }, [h("tr", [this.formatColumns.map(function (colData) {
29593
+ return _this4.getHead(colData);
29594
+ })])]), h("tbody", {
29595
+ "class": table_bem('tbody')
29596
+ }, [this.dataList.map(function (rowData, rowIndex) {
29597
+ return _this4.getBody(rowData, rowIndex);
29598
+ })])])]);
29664
29599
  }
29665
29600
  }));
29666
29601
  // CONCATENATED MODULE: ./es/tag/index.js
@@ -29754,7 +29689,7 @@ var timeline_createNamespace = Object(utils["b" /* createNamespace */])('timelin
29754
29689
  timeline_createComponent = timeline_createNamespace[0],
29755
29690
  timeline_bem = timeline_createNamespace[1];
29756
29691
 
29757
- var timeline_defaultData = function defaultData() {
29692
+ var defaultData = function defaultData() {
29758
29693
  return {
29759
29694
  isFold: false,
29760
29695
  computedProcesses: []
@@ -29805,7 +29740,7 @@ var timeline_defaultData = function defaultData() {
29805
29740
  }
29806
29741
  },
29807
29742
  data: function data() {
29808
- return timeline_defaultData();
29743
+ return defaultData();
29809
29744
  },
29810
29745
  computed: {},
29811
29746
  watch: {
@@ -30780,7 +30715,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
30780
30715
 
30781
30716
 
30782
30717
 
30783
- var version = '2.0.80-beta.2';
30718
+ var version = '2.0.81';
30784
30719
 
30785
30720
  function install(Vue) {
30786
30721
  var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, es_step, stepper, es_steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, timeline, es_toast, uploader];