vue2-components-plus 1.0.68 → 1.0.70

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.
@@ -290,15 +290,15 @@ function registerDirective(Vue2) {
290
290
  Vue2.directive("enterClick", enterClickDirective);
291
291
  Vue2.directive("enter-click", enterClickDirective);
292
292
  }
293
- let ThemeVar$1 = class ThemeVar {
294
- };
295
- ThemeVar$1.VARS = {};
296
- function loadCssVars$1() {
293
+ class ThemeVar {
294
+ }
295
+ ThemeVar.VARS = {};
296
+ function loadCssVars() {
297
297
  if (typeof document === "undefined") {
298
- return ThemeVar$1.VARS;
298
+ return ThemeVar.VARS;
299
299
  }
300
- if (Object.keys(ThemeVar$1.VARS).length > 0) {
301
- return ThemeVar$1.VARS;
300
+ if (Object.keys(ThemeVar.VARS).length > 0) {
301
+ return ThemeVar.VARS;
302
302
  }
303
303
  const variables = {};
304
304
  Array.from(document.styleSheets || []).forEach((sheet) => {
@@ -317,7 +317,7 @@ function loadCssVars$1() {
317
317
  });
318
318
  });
319
319
  });
320
- ThemeVar$1.VARS = variables;
320
+ ThemeVar.VARS = variables;
321
321
  return variables;
322
322
  }
323
323
  function toKebabCase$1(value) {
@@ -1060,37 +1060,7 @@ var __component__$5 = /* @__PURE__ */ normalizeComponent(
1060
1060
  null
1061
1061
  );
1062
1062
  const NsForm = __component__$5.exports;
1063
- class ThemeVar2 {
1064
- }
1065
- ThemeVar2.VARS = {};
1066
- function loadCssVars() {
1067
- if (typeof document === "undefined") {
1068
- return ThemeVar2.VARS;
1069
- }
1070
- if (Object.keys(ThemeVar2.VARS).length > 0) {
1071
- return ThemeVar2.VARS;
1072
- }
1073
- const variables = {};
1074
- Array.from(document.styleSheets || []).forEach((sheet) => {
1075
- let cssRules = [];
1076
- try {
1077
- cssRules = Array.from(sheet.cssRules || []);
1078
- } catch (error) {
1079
- cssRules = [];
1080
- }
1081
- cssRules.forEach((rule) => {
1082
- if (rule.selectorText !== ":root") {
1083
- return;
1084
- }
1085
- Array.from(rule.style || []).filter((name) => name.indexOf("--matrix-") === 0).forEach((name) => {
1086
- variables[name] = rule.style.getPropertyValue(name).trim();
1087
- });
1088
- });
1089
- });
1090
- ThemeVar2.VARS = variables;
1091
- return variables;
1092
- }
1093
- const DynamicFormTitle_vue_vue_type_style_index_0_scoped_29c80ec1_lang = "";
1063
+ const DynamicFormTitle_vue_vue_type_style_index_0_scoped_5d766a25_lang = "";
1094
1064
  const _sfc_main$4 = {
1095
1065
  name: "NsFormTitle",
1096
1066
  props: {
@@ -1116,7 +1086,7 @@ var __component__$4 = /* @__PURE__ */ normalizeComponent(
1116
1086
  _sfc_staticRenderFns$4,
1117
1087
  false,
1118
1088
  null,
1119
- "29c80ec1",
1089
+ "5d766a25",
1120
1090
  null,
1121
1091
  null
1122
1092
  );
@@ -1530,8 +1500,175 @@ const RESERVED_KEYS = [
1530
1500
  "imageHeight",
1531
1501
  "linkText"
1532
1502
  ];
1503
+ function getColumnProps(column) {
1504
+ const props = __spreadValues({}, column);
1505
+ RESERVED_KEYS.forEach((key) => delete props[key]);
1506
+ return props;
1507
+ }
1508
+ function getRenderer(slotRenderers, name) {
1509
+ return name ? slotRenderers[name] : null;
1510
+ }
1511
+ function getCellValue(row, column) {
1512
+ return column.prop ? row[column.prop] : void 0;
1513
+ }
1514
+ function isVisible(config, row) {
1515
+ if (typeof config.show === "function") {
1516
+ return config.show(row) !== false;
1517
+ }
1518
+ if (config.show === void 0) {
1519
+ return true;
1520
+ }
1521
+ return !!config.show;
1522
+ }
1523
+ function isDisabled(config, row) {
1524
+ return typeof config.disabled === "function" ? !!config.disabled(row) : !!config.disabled;
1525
+ }
1526
+ function emit(listeners, name, ...args) {
1527
+ const handler = listeners && listeners[name];
1528
+ if (!handler) {
1529
+ return;
1530
+ }
1531
+ if (Array.isArray(handler)) {
1532
+ handler.forEach((fn) => typeof fn === "function" && fn(...args));
1533
+ return;
1534
+ }
1535
+ if (typeof handler === "function") {
1536
+ handler(...args);
1537
+ }
1538
+ }
1539
+ function resolveEnumText(column, value) {
1540
+ const enumList = column.enum || column.options || [];
1541
+ if (!Array.isArray(enumList)) {
1542
+ return value;
1543
+ }
1544
+ const matched = enumList.find((item) => item.value === value);
1545
+ return matched ? matched.label : value;
1546
+ }
1547
+ function renderActionButtons(h, scope, column, slotRenderers, listeners) {
1548
+ const buttons = Array.isArray(column.buttons) ? column.buttons : [];
1549
+ return buttons.filter((button) => isVisible(button, scope.row)).map((button, index2) => {
1550
+ const slotRenderer = getRenderer(slotRenderers, button.slot);
1551
+ if (slotRenderer) {
1552
+ return slotRenderer(__spreadProps(__spreadValues({}, scope), { row: scope.row, column, button }));
1553
+ }
1554
+ return h(
1555
+ "el-button",
1556
+ {
1557
+ key: button.label || index2,
1558
+ props: {
1559
+ size: button.size || "mini",
1560
+ type: button.link ? "text" : button.type || "text",
1561
+ icon: typeof button.icon === "string" ? button.icon : void 0,
1562
+ disabled: isDisabled(button, scope.row)
1563
+ },
1564
+ on: {
1565
+ click: () => {
1566
+ if (typeof button.handler === "function") {
1567
+ button.handler(scope.row, scope.$index);
1568
+ }
1569
+ emit(listeners, "button-click", scope.row, column, button);
1570
+ }
1571
+ }
1572
+ },
1573
+ [button.label]
1574
+ );
1575
+ });
1576
+ }
1577
+ function renderTag(h, scope, column) {
1578
+ const cellValue = getCellValue(scope.row, column);
1579
+ const tagType = typeof column.tagType === "function" ? column.tagType(scope.row, cellValue) : column.tagType;
1580
+ const text = typeof column.formatter === "function" ? column.formatter(scope.row, column, cellValue) : resolveEnumText(column, cellValue);
1581
+ return h("el-tag", { props: { type: tagType || "info", size: column.tagSize || "small" } }, [text]);
1582
+ }
1583
+ function renderImage(h, scope, column) {
1584
+ const src = getCellValue(scope.row, column);
1585
+ if (!src) {
1586
+ return "-";
1587
+ }
1588
+ return h("img", {
1589
+ style: {
1590
+ width: column.imageWidth || "40px",
1591
+ height: column.imageHeight || "40px",
1592
+ objectFit: "cover",
1593
+ borderRadius: "4px"
1594
+ },
1595
+ attrs: {
1596
+ src,
1597
+ alt: column.label || "image"
1598
+ }
1599
+ });
1600
+ }
1601
+ function renderLink(h, scope, column, slotRenderers, listeners) {
1602
+ const renderer = getRenderer(slotRenderers, column.slot);
1603
+ if (renderer) {
1604
+ return renderer(scope);
1605
+ }
1606
+ const cellValue = getCellValue(scope.row, column);
1607
+ return h(
1608
+ "el-button",
1609
+ {
1610
+ props: {
1611
+ type: "text"
1612
+ },
1613
+ on: {
1614
+ click: () => emit(listeners, "link-click", scope.row, column)
1615
+ }
1616
+ },
1617
+ [column.linkText || cellValue || "-"]
1618
+ );
1619
+ }
1620
+ function renderDefaultCell(h, scope, column, slotRenderers, listeners) {
1621
+ const renderer = getRenderer(slotRenderers, column.slot);
1622
+ if (renderer) {
1623
+ return renderer(scope);
1624
+ }
1625
+ if (column.type === "action") {
1626
+ return h("div", { class: "ns-table-column__actions" }, renderActionButtons(h, scope, column, slotRenderers, listeners));
1627
+ }
1628
+ if (column.type === "tag") {
1629
+ return renderTag(h, scope, column);
1630
+ }
1631
+ if (column.type === "image") {
1632
+ return renderImage(h, scope, column);
1633
+ }
1634
+ if (column.type === "link") {
1635
+ return renderLink(h, scope, column, slotRenderers, listeners);
1636
+ }
1637
+ const cellValue = getCellValue(scope.row, column);
1638
+ if (typeof column.formatter === "function") {
1639
+ return column.formatter(scope.row, column, cellValue);
1640
+ }
1641
+ if (column.enum) {
1642
+ return resolveEnumText(column, cellValue);
1643
+ }
1644
+ return cellValue === void 0 || cellValue === null || cellValue === "" ? "-" : cellValue;
1645
+ }
1646
+ function renderColumn(h, column, slotRenderers, listeners) {
1647
+ const children = Array.isArray(column.children) ? column.children.map(
1648
+ (child, index2) => h(TableColumn, {
1649
+ key: child.prop || child.label || index2,
1650
+ props: {
1651
+ column: child,
1652
+ slotRenderers
1653
+ },
1654
+ on: listeners
1655
+ })
1656
+ ) : [];
1657
+ const headerRenderer = getRenderer(slotRenderers, column.headerSlot);
1658
+ return h(
1659
+ "el-table-column",
1660
+ {
1661
+ props: getColumnProps(column),
1662
+ scopedSlots: children.length ? headerRenderer ? { header: headerRenderer } : void 0 : __spreadValues({
1663
+ default: (scope) => renderDefaultCell(h, scope, column, slotRenderers, listeners)
1664
+ }, headerRenderer ? { header: headerRenderer } : {})
1665
+ },
1666
+ children
1667
+ );
1668
+ }
1533
1669
  const TableColumn = {
1534
1670
  name: "NsTableColumn",
1671
+ functional: true,
1535
1672
  props: {
1536
1673
  column: {
1537
1674
  type: Object,
@@ -1542,166 +1679,8 @@ const TableColumn = {
1542
1679
  default: () => ({})
1543
1680
  }
1544
1681
  },
1545
- methods: {
1546
- getColumnProps(column) {
1547
- const props = __spreadValues({}, column);
1548
- RESERVED_KEYS.forEach((key) => delete props[key]);
1549
- return props;
1550
- },
1551
- getRenderer(name) {
1552
- return name ? this.slotRenderers[name] : null;
1553
- },
1554
- getCellValue(row, column) {
1555
- return column.prop ? row[column.prop] : void 0;
1556
- },
1557
- isVisible(config, row) {
1558
- if (typeof config.show === "function") {
1559
- return config.show(row) !== false;
1560
- }
1561
- if (config.show === void 0) {
1562
- return true;
1563
- }
1564
- return !!config.show;
1565
- },
1566
- isDisabled(config, row) {
1567
- return typeof config.disabled === "function" ? !!config.disabled(row) : !!config.disabled;
1568
- },
1569
- renderActionButtons(h, scope, column) {
1570
- const buttons = Array.isArray(column.buttons) ? column.buttons : [];
1571
- return buttons.filter((button) => this.isVisible(button, scope.row)).map((button, index2) => {
1572
- const slotRenderer = this.getRenderer(button.slot);
1573
- if (slotRenderer) {
1574
- return slotRenderer(__spreadProps(__spreadValues({}, scope), { row: scope.row, column, button }));
1575
- }
1576
- return h(
1577
- "el-button",
1578
- {
1579
- key: button.label || index2,
1580
- props: {
1581
- size: button.size || "mini",
1582
- type: button.link ? "text" : button.type || "text",
1583
- icon: typeof button.icon === "string" ? button.icon : void 0,
1584
- disabled: this.isDisabled(button, scope.row)
1585
- },
1586
- on: {
1587
- click: () => {
1588
- if (typeof button.handler === "function") {
1589
- button.handler(scope.row, scope.$index);
1590
- }
1591
- this.$emit("button-click", scope.row, column, button);
1592
- }
1593
- }
1594
- },
1595
- [button.label]
1596
- );
1597
- });
1598
- },
1599
- renderTag(h, scope, column) {
1600
- const cellValue = this.getCellValue(scope.row, column);
1601
- const tagType = typeof column.tagType === "function" ? column.tagType(scope.row, cellValue) : column.tagType;
1602
- const text = typeof column.formatter === "function" ? column.formatter(scope.row, column, cellValue) : this.resolveEnumText(column, cellValue);
1603
- return h("el-tag", { props: { type: tagType || "info", size: column.tagSize || "small" } }, [text]);
1604
- },
1605
- renderImage(h, scope, column) {
1606
- const src = this.getCellValue(scope.row, column);
1607
- if (!src) {
1608
- return "-";
1609
- }
1610
- return h("img", {
1611
- style: {
1612
- width: column.imageWidth || "40px",
1613
- height: column.imageHeight || "40px",
1614
- objectFit: "cover",
1615
- borderRadius: "4px"
1616
- },
1617
- attrs: {
1618
- src,
1619
- alt: column.label || "image"
1620
- }
1621
- });
1622
- },
1623
- renderLink(h, scope, column) {
1624
- const renderer = this.getRenderer(column.slot);
1625
- if (renderer) {
1626
- return renderer(scope);
1627
- }
1628
- const cellValue = this.getCellValue(scope.row, column);
1629
- return h(
1630
- "el-button",
1631
- {
1632
- props: {
1633
- type: "text"
1634
- },
1635
- on: {
1636
- click: () => this.$emit("link-click", scope.row, column)
1637
- }
1638
- },
1639
- [column.linkText || cellValue || "-"]
1640
- );
1641
- },
1642
- resolveEnumText(column, value) {
1643
- const enumList = column.enum || column.options || [];
1644
- if (!Array.isArray(enumList)) {
1645
- return value;
1646
- }
1647
- const matched = enumList.find((item) => item.value === value);
1648
- return matched ? matched.label : value;
1649
- },
1650
- renderDefaultCell(h, scope, column) {
1651
- const renderer = this.getRenderer(column.slot);
1652
- if (renderer) {
1653
- return renderer(scope);
1654
- }
1655
- if (column.type === "action") {
1656
- return h("div", { class: "ns-table-column__actions" }, this.renderActionButtons(h, scope, column));
1657
- }
1658
- if (column.type === "tag") {
1659
- return this.renderTag(h, scope, column);
1660
- }
1661
- if (column.type === "image") {
1662
- return this.renderImage(h, scope, column);
1663
- }
1664
- if (column.type === "link") {
1665
- return this.renderLink(h, scope, column);
1666
- }
1667
- const cellValue = this.getCellValue(scope.row, column);
1668
- if (typeof column.formatter === "function") {
1669
- return column.formatter(scope.row, column, cellValue);
1670
- }
1671
- if (column.enum) {
1672
- return this.resolveEnumText(column, cellValue);
1673
- }
1674
- return cellValue === void 0 || cellValue === null || cellValue === "" ? "-" : cellValue;
1675
- },
1676
- renderColumn(h, column) {
1677
- const children = Array.isArray(column.children) ? column.children.map(
1678
- (child, index2) => h(TableColumn, {
1679
- key: child.prop || child.label || index2,
1680
- props: {
1681
- column: child,
1682
- slotRenderers: this.slotRenderers
1683
- },
1684
- on: {
1685
- "link-click": (...args) => this.$emit("link-click", ...args),
1686
- "button-click": (...args) => this.$emit("button-click", ...args)
1687
- }
1688
- })
1689
- ) : [];
1690
- const headerRenderer = this.getRenderer(column.headerSlot);
1691
- return h(
1692
- "el-table-column",
1693
- {
1694
- props: this.getColumnProps(column),
1695
- scopedSlots: children.length ? headerRenderer ? { header: headerRenderer } : void 0 : __spreadValues({
1696
- default: (scope) => this.renderDefaultCell(h, scope, column)
1697
- }, headerRenderer ? { header: headerRenderer } : {})
1698
- },
1699
- children
1700
- );
1701
- }
1702
- },
1703
- render(h) {
1704
- return this.renderColumn(h, this.column);
1682
+ render(h, ctx) {
1683
+ return renderColumn(h, ctx.props.column, ctx.props.slotRenderers || {}, ctx.listeners || {});
1705
1684
  }
1706
1685
  };
1707
1686
  const TableColumn$1 = TableColumn;
@@ -1732,7 +1711,7 @@ function resetPagination(pagination) {
1732
1711
  pagination.pageSize = 10;
1733
1712
  return pagination;
1734
1713
  }
1735
- const PageTable_vue_vue_type_style_index_0_scoped_9ad56349_lang = "";
1714
+ const PageTable_vue_vue_type_style_index_0_scoped_31eeea22_lang = "";
1736
1715
  const RESERVED_LISTENERS = ["add", "selection-change", "sort-change", "row-click", "size-change", "current-change", "link-click"];
1737
1716
  const _sfc_main$2 = {
1738
1717
  name: "NsTable",
@@ -1865,7 +1844,9 @@ const _sfc_main$2 = {
1865
1844
  },
1866
1845
  data() {
1867
1846
  return {
1868
- internalPagination: createPagination()
1847
+ internalPagination: createPagination(),
1848
+ resizeObserver: null,
1849
+ layoutTimer: null
1869
1850
  };
1870
1851
  },
1871
1852
  computed: {
@@ -1884,12 +1865,9 @@ const _sfc_main$2 = {
1884
1865
  return listeners;
1885
1866
  },
1886
1867
  resolvedHeight() {
1887
- if (this.height !== void 0) {
1868
+ if (this.height !== void 0 && this.height !== null && this.height !== "") {
1888
1869
  return this.height;
1889
1870
  }
1890
- if (this.autoHeight && this.maxHeight === void 0) {
1891
- return "100%";
1892
- }
1893
1871
  return void 0;
1894
1872
  },
1895
1873
  resolvedMaxHeight() {
@@ -1915,9 +1893,63 @@ const _sfc_main$2 = {
1915
1893
  }
1916
1894
  },
1917
1895
  immediate: true
1896
+ },
1897
+ tableData: {
1898
+ handler() {
1899
+ this.scheduleLayout();
1900
+ },
1901
+ deep: true,
1902
+ immediate: true
1903
+ },
1904
+ columns: {
1905
+ handler() {
1906
+ this.scheduleLayout();
1907
+ },
1908
+ deep: true,
1909
+ immediate: true
1910
+ }
1911
+ },
1912
+ mounted() {
1913
+ this.scheduleLayout();
1914
+ this.initResizeObserver();
1915
+ },
1916
+ beforeDestroy() {
1917
+ if (this.resizeObserver) {
1918
+ this.resizeObserver.disconnect();
1919
+ this.resizeObserver = null;
1920
+ }
1921
+ if (this.layoutTimer) {
1922
+ clearTimeout(this.layoutTimer);
1923
+ this.layoutTimer = null;
1918
1924
  }
1919
1925
  },
1920
1926
  methods: {
1927
+ scheduleLayout() {
1928
+ this.$nextTick(() => {
1929
+ this.doLayout();
1930
+ if (this.layoutTimer) {
1931
+ clearTimeout(this.layoutTimer);
1932
+ }
1933
+ this.layoutTimer = setTimeout(() => {
1934
+ this.doLayout();
1935
+ this.layoutTimer = null;
1936
+ }, 50);
1937
+ });
1938
+ },
1939
+ initResizeObserver() {
1940
+ if (typeof ResizeObserver === "undefined") {
1941
+ return;
1942
+ }
1943
+ this.resizeObserver = new ResizeObserver(() => {
1944
+ this.scheduleLayout();
1945
+ });
1946
+ if (this.$el) {
1947
+ this.resizeObserver.observe(this.$el);
1948
+ }
1949
+ if (this.$el && this.$el.parentElement) {
1950
+ this.resizeObserver.observe(this.$el.parentElement);
1951
+ }
1952
+ },
1921
1953
  handleAdd() {
1922
1954
  this.$emit("add");
1923
1955
  },
@@ -2061,7 +2093,7 @@ var __component__$2 = /* @__PURE__ */ normalizeComponent(
2061
2093
  _sfc_staticRenderFns$2,
2062
2094
  false,
2063
2095
  null,
2064
- "9ad56349",
2096
+ "31eeea22",
2065
2097
  null,
2066
2098
  null
2067
2099
  );
@@ -2649,7 +2681,7 @@ const _sfc_main = {
2649
2681
  }
2650
2682
  },
2651
2683
  mounted() {
2652
- loadCssVars$1();
2684
+ loadCssVars();
2653
2685
  this.visible = true;
2654
2686
  this.updateModalStyle();
2655
2687
  this.syncDialogInstance();
@@ -3153,7 +3185,7 @@ function install2(Vue2, options = {}) {
3153
3185
  }
3154
3186
  });
3155
3187
  setExternalApp(Vue2, options);
3156
- loadCssVars$1();
3188
+ loadCssVars();
3157
3189
  if (Vue2 && Vue2.prototype) {
3158
3190
  Vue2.prototype.$NsDialog = NsDialog;
3159
3191
  Vue2.prototype.$closeAllNsDialog = closeAllNsDialog;