umy-ui-table 1.2.0

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.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/lib/button.js +1 -0
  4. package/lib/icon.js +1 -0
  5. package/lib/index.js +1 -0
  6. package/lib/locale/format.js +56 -0
  7. package/lib/locale/index.js +72 -0
  8. package/lib/locale/lang/en.js +123 -0
  9. package/lib/locale/lang/zh-CN.js +119 -0
  10. package/lib/mixins/locale.js +17 -0
  11. package/lib/theme-chalk/base.css +0 -0
  12. package/lib/theme-chalk/button.css +1 -0
  13. package/lib/theme-chalk/fonts/element-icons.ttf +0 -0
  14. package/lib/theme-chalk/fonts/element-icons.woff +0 -0
  15. package/lib/theme-chalk/fonts/iconfont.1785562768224.ttf +0 -0
  16. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff +0 -0
  17. package/lib/theme-chalk/fonts/iconfont.1785562768224.woff2 +0 -0
  18. package/lib/theme-chalk/icon.css +1 -0
  19. package/lib/theme-chalk/index.css +1 -0
  20. package/lib/theme-chalk/u-table-column.css +0 -0
  21. package/lib/theme-chalk/u-table.css +1 -0
  22. package/lib/theme-chalk/ux-grid.css +1 -0
  23. package/lib/theme-chalk/ux-table-column.css +0 -0
  24. package/lib/u-table-column.js +1 -0
  25. package/lib/u-table.js +1 -0
  26. package/lib/umd/locale/en.js +139 -0
  27. package/lib/umd/locale/zh-CN.js +135 -0
  28. package/lib/umy-ui.common.js +1 -0
  29. package/lib/utils/svg.js +33 -0
  30. package/lib/utils/types.js +35 -0
  31. package/lib/utils/util.js +268 -0
  32. package/lib/ux-grid.js +1 -0
  33. package/lib/ux-table-column.js +1 -0
  34. package/package.json +117 -0
  35. package/packages/button/index.js +7 -0
  36. package/packages/button/src/button-group.vue +10 -0
  37. package/packages/button/src/button.vue +166 -0
  38. package/packages/checkbox/index.js +8 -0
  39. package/packages/checkbox/src/checkbox-button.vue +199 -0
  40. package/packages/checkbox/src/checkbox-group.vue +48 -0
  41. package/packages/checkbox/src/checkbox.vue +222 -0
  42. package/packages/checkbox-button/index.js +8 -0
  43. package/packages/checkbox-group/index.js +8 -0
  44. package/packages/icon/index.js +7 -0
  45. package/packages/icon/src/icon.vue +40 -0
  46. package/packages/input/index.js +2 -0
  47. package/packages/input/src/calcTextareaHeight.js +104 -0
  48. package/packages/input/src/input.vue +424 -0
  49. package/packages/option/index.js +2 -0
  50. package/packages/pagination/index.js +2 -0
  51. package/packages/pagination/src/pager.vue +163 -0
  52. package/packages/pagination/src/pagination.js +386 -0
  53. package/packages/scrollbar/index.js +8 -0
  54. package/packages/scrollbar/src/bar.js +92 -0
  55. package/packages/scrollbar/src/main.js +130 -0
  56. package/packages/scrollbar/src/util.js +34 -0
  57. package/packages/select/index.js +2 -0
  58. package/packages/select/src/navigation-mixin.js +54 -0
  59. package/packages/select/src/option-group.vue +60 -0
  60. package/packages/select/src/option.vue +163 -0
  61. package/packages/select/src/select-dropdown.vue +74 -0
  62. package/packages/select/src/select.vue +889 -0
  63. package/packages/table/index.js +8 -0
  64. package/packages/table/src/config.js +123 -0
  65. package/packages/table/src/dropdown.js +28 -0
  66. package/packages/table/src/filter-panel.vue +194 -0
  67. package/packages/table/src/layout-observer.js +68 -0
  68. package/packages/table/src/store/current.js +71 -0
  69. package/packages/table/src/store/expand.js +65 -0
  70. package/packages/table/src/store/helper.js +37 -0
  71. package/packages/table/src/store/index.js +145 -0
  72. package/packages/table/src/store/tree.js +208 -0
  73. package/packages/table/src/store/watcher.js +448 -0
  74. package/packages/table/src/table-body.js +493 -0
  75. package/packages/table/src/table-column.js +381 -0
  76. package/packages/table/src/table-footer.js +174 -0
  77. package/packages/table/src/table-header.js +537 -0
  78. package/packages/table/src/table-layout.js +231 -0
  79. package/packages/table/src/table.vue +741 -0
  80. package/packages/table/src/util.js +256 -0
  81. package/packages/tag/index.js +8 -0
  82. package/packages/tag/src/tag.vue +58 -0
  83. package/packages/tools/directives/mousewheel.js +18 -0
  84. package/packages/tools/directives/repeat-click.js +24 -0
  85. package/packages/tools/locale/format.js +46 -0
  86. package/packages/tools/locale/index.js +48 -0
  87. package/packages/tools/locale/lang/en.js +120 -0
  88. package/packages/tools/locale/lang/zh-CN.js +116 -0
  89. package/packages/tools/mixins/emitter.js +33 -0
  90. package/packages/tools/mixins/focus.js +9 -0
  91. package/packages/tools/mixins/locale.js +9 -0
  92. package/packages/tools/mixins/migrating.js +54 -0
  93. package/packages/tools/transitions/collapse-transition.js +77 -0
  94. package/packages/tools/utils/after-leave.js +27 -0
  95. package/packages/tools/utils/aria-dialog.js +90 -0
  96. package/packages/tools/utils/aria-utils.js +122 -0
  97. package/packages/tools/utils/clickoutside.js +76 -0
  98. package/packages/tools/utils/date-util.js +292 -0
  99. package/packages/tools/utils/date.js +368 -0
  100. package/packages/tools/utils/dom.js +227 -0
  101. package/packages/tools/utils/menu/aria-menubar.js +14 -0
  102. package/packages/tools/utils/menu/aria-menuitem.js +49 -0
  103. package/packages/tools/utils/menu/aria-submenu.js +59 -0
  104. package/packages/tools/utils/merge.js +15 -0
  105. package/packages/tools/utils/popper.js +1276 -0
  106. package/packages/tools/utils/popup/index.js +218 -0
  107. package/packages/tools/utils/popup/popup-manager.js +194 -0
  108. package/packages/tools/utils/resize-event.js +35 -0
  109. package/packages/tools/utils/scroll-into-view.js +27 -0
  110. package/packages/tools/utils/scrollbar-width.js +29 -0
  111. package/packages/tools/utils/shared.js +7 -0
  112. package/packages/tools/utils/svg.js +1 -0
  113. package/packages/tools/utils/types.js +28 -0
  114. package/packages/tools/utils/util.js +241 -0
  115. package/packages/tools/utils/vdom.js +5 -0
  116. package/packages/tools/utils/vue-popper.js +198 -0
  117. package/packages/tooltip/index.js +8 -0
  118. package/packages/tooltip/src/main.js +241 -0
  119. package/packages/u-table/index.js +4 -0
  120. package/packages/u-table/revise-el-table-mixins/index.js +10 -0
  121. package/packages/u-table/revise-el-table-mixins/table-extend.js +60 -0
  122. package/packages/u-table/revise-el-table-mixins/table.mixins.js +261 -0
  123. package/packages/u-table/revise-el-table-mixins/virtual-table-body-render.js +132 -0
  124. package/packages/u-table/src/u-table.vue +248 -0
  125. package/packages/u-table/u-table-mixins/index.js +483 -0
  126. package/packages/u-table/u-table-tree-mixins/methods.js +120 -0
  127. package/packages/u-table/u-table-tree-mixins/u-table-tree-mixins.js +161 -0
  128. package/packages/u-table-column/index.js +8 -0
  129. package/packages/utils/common.js +27 -0
  130. package/packages/ux-grid/index.js +6 -0
  131. package/packages/ux-grid/mixins/index.js +707 -0
  132. package/packages/ux-grid/src/interceptor.js +6 -0
  133. package/packages/ux-grid/src/ux-grid.vue +301 -0
  134. package/packages/ux-table-column/index.js +10 -0
  135. package/tools/locale/format.js +46 -0
  136. package/tools/locale/index.js +54 -0
  137. package/tools/locale/lang/en.js +120 -0
  138. package/tools/locale/lang/zh-CN.js +116 -0
  139. package/tools/mixins/locale.js +9 -0
  140. package/tools/utils/svg.js +1 -0
  141. package/tools/utils/types.js +28 -0
  142. package/tools/utils/util.js +241 -0
@@ -0,0 +1,161 @@
1
+ // 扩展el-table和pl-table
2
+ import { isArrayFn, typeIs } from "../../utils/common";
3
+ import methods from "./methods";
4
+ import XEUtils from "xe-utils/ctor";
5
+
6
+ export default {
7
+ props: {
8
+ treeConfig: [Boolean, Object], // 树形结构配置项
9
+ },
10
+ data() {
11
+ return {
12
+ treeExpandeds: [], // 已经展开的节点
13
+ copyPlTreeData: [], // 复制处理后的数据,这是有层级的
14
+ plTreeloading: false,
15
+ plTreeData: [], // 对原始数据进行操作的数组
16
+ };
17
+ },
18
+ computed: {
19
+ // pl-table树节点的配置
20
+ treeOpts() {
21
+ return Object.assign(
22
+ {
23
+ children: "children",
24
+ hasChildren: "hasChildren",
25
+ indent: 20,
26
+ trigger: "default",
27
+ lazy: false,
28
+ load: null,
29
+ expandAll: false,
30
+ },
31
+ this.treeConfig
32
+ );
33
+ },
34
+ },
35
+ methods: {
36
+ ...methods,
37
+ /**
38
+ * 默认行为只允许执行一次
39
+ */
40
+ handleDefaults() {
41
+ if (this.treeConfig) {
42
+ this.handleDefaultTreeExpand();
43
+ } else {
44
+ this.setTreeTableData();
45
+ }
46
+ },
47
+ /**
48
+ * 处理默认展开树节点
49
+ */
50
+ handleDefaultTreeExpand() {
51
+ let { treeConfig, treeOpts, plTreeData, rowId } = this;
52
+ if (treeConfig) {
53
+ let { expandAll, expandRowKeys } = treeOpts;
54
+ if (expandAll) {
55
+ this.setAllTreeExpansion();
56
+ } else if (isArrayFn(expandRowKeys) && expandRowKeys.length) {
57
+ let defExpandeds = [];
58
+ expandRowKeys.forEach((rowid) => {
59
+ let matchObj = XEUtils.findTree(plTreeData, (item) => rowid === XEUtils.get(item, rowId), treeOpts);
60
+ if (matchObj) {
61
+ defExpandeds.push(matchObj.item);
62
+ }
63
+ });
64
+ // 设置节点
65
+ this.setTreeExpansion(defExpandeds, true);
66
+ } else {
67
+ // 重新加载数据
68
+ this.setTreeTableData();
69
+ }
70
+ }
71
+ },
72
+ // 初始化树形数据(只会在数据变化调用一次)
73
+ plTreeInit(data) {
74
+ // 深拷贝数据
75
+ this.plTreeData = XEUtils.clone(data, true);
76
+ // 设置数据级别,计算第一列的左侧空间距
77
+ this.plTreeData.forEach((item) => {
78
+ this.setDataLevel(item, 0);
79
+ });
80
+ this.copyPlTreeData = XEUtils.clone(this.plTreeData, true);
81
+ // 初始化方法
82
+ this.handleDefaults();
83
+ return this.$nextTick();
84
+ },
85
+ //展开变化
86
+ triggerTreeExpandEvent(tabItem, type, event) {
87
+ const { trigger, children, hasChildren, lazy, load } = this.treeOpts;
88
+ if (trigger === type && this.useVirtual && this.rowId) {
89
+ // 是否属于懒加载节点
90
+ if (tabItem[hasChildren] && lazy && typeIs(load) === "function") {
91
+ // 开启旋转
92
+ this.plTreeloading = true;
93
+ load(tabItem, (data) => {
94
+ // 关闭旋转
95
+ this.plTreeloading = false;
96
+ // 关闭当前节点的加载状态
97
+ tabItem[hasChildren] = false;
98
+ data.forEach((item) => {
99
+ this.setDataLevel(item, tabItem.pl_table_level + 1);
100
+ });
101
+ tabItem[this.treeOpts.children] = data;
102
+ // 根据rowId, 获取当前数据中的row,不改变表格数据,改变复制的数据
103
+ let row = this.plTreeData.filter((item) => item[this.rowId] === tabItem[this.rowId])[0];
104
+ // row || children无子节点。不存在就返回
105
+ if (!row || !row[children]) return;
106
+ // 设置节点
107
+ this.setTreeExpansion(row, !row.pl_table_expand);
108
+ // 当树节点展开收起时会触发这个事件
109
+ this.$emit("toggle-tree-expand", tabItem, this.treeExpandeds, event);
110
+ });
111
+ } else {
112
+ // 根据rowId, 获取当前数据中的row,不改变表格数据,改变复制的数据
113
+ let row = this.plTreeData.filter((item) => item[this.rowId] === tabItem[this.rowId])[0];
114
+ // row || children无子节点。不存在就返回
115
+ if (!row || !row[children]) return;
116
+ // 设置节点
117
+ this.setTreeExpansion(row, !row.pl_table_expand);
118
+ // 当树节点展开收起时会触发这个事件
119
+ this.$emit("toggle-tree-expand", tabItem, this.treeExpandeds, event);
120
+ }
121
+ }
122
+ },
123
+ //迭代:设置数据级别
124
+ setDataLevel(data, level) {
125
+ //自定义数据的级别
126
+ data.pl_table_level = level;
127
+ if (isArrayFn(data[this.treeOpts.children])) {
128
+ data[this.treeOpts.children].forEach((childData) => {
129
+ this.setDataLevel(childData, level + 1);
130
+ });
131
+ }
132
+ },
133
+ // 获取当前row对应的层级level
134
+ getTreeLevel(row) {
135
+ const rowInfo = this.plTreeData.filter((item) => item[this.rowId] === row[this.rowId])[0];
136
+ return rowInfo.pl_table_level || 0;
137
+ },
138
+ // 从树结构中遍历数据(杜绝大量数据遍历)
139
+ eachTreeExpand(data) {
140
+ let treefullData = [];
141
+ if (!data) return treefullData;
142
+ let hasChildren = (obj) => obj[this.treeOpts.children] !== undefined && obj[this.treeOpts.children] !== null;
143
+ let recursionFiltra = (arr) =>
144
+ arr.forEach((obj) => {
145
+ treefullData.push(obj);
146
+ // 子节点存在展开,那么继续遍历(非常重要)
147
+ if (hasChildren(obj) && obj.pl_table_expand) {
148
+ recursionFiltra(obj[this.treeOpts.children]);
149
+ }
150
+ });
151
+ if (hasChildren(data)) {
152
+ recursionFiltra(data[this.treeOpts.children]);
153
+ }
154
+ return treefullData;
155
+ },
156
+ // 设置表格数据
157
+ setTreeTableData() {
158
+ this.store.commit("setData", this.plTreeData);
159
+ },
160
+ },
161
+ };
@@ -0,0 +1,8 @@
1
+ import UTableColumn from '../table/src/table-column';
2
+
3
+ /* istanbul ignore next */
4
+ UTableColumn.install = function(Vue) {
5
+ Vue.component(UTableColumn.name, UTableColumn);
6
+ };
7
+
8
+ export default UTableColumn;
@@ -0,0 +1,27 @@
1
+ // 类型判断:返回小写类型字符串,如 "boolean"、"function"、"array"、"string"、"number"
2
+ export function typeIs(obj) {
3
+ return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase();
4
+ }
5
+
6
+ // 判断是否为数组
7
+ export function isArrayFn(obj) {
8
+ return Array.isArray(obj);
9
+ }
10
+
11
+ // 数组去重,返回新数组(不修改原数组)
12
+ export function removal(arr) {
13
+ if (!isArrayFn(arr)) return arr;
14
+ return arr.filter((item, index) => arr.indexOf(item) === index);
15
+ }
16
+
17
+ // 解析高度:数字 / 纯数字字符串 / px 字符串 → 数字;百分比字符串 → 原样返回字符串;其他 → 0
18
+ export function parseHeight(height) {
19
+ if (typeof height === "number") return height;
20
+ if (typeof height === "string") {
21
+ const value = height.trim();
22
+ if (/^\d+(\.\d+)?$/.test(value)) return Number(value);
23
+ if (/^\d+(\.\d+)?px$/i.test(value)) return parseFloat(value);
24
+ if (value.indexOf("%") > -1) return value;
25
+ }
26
+ return 0;
27
+ }
@@ -0,0 +1,6 @@
1
+ import UxGrid from './src/ux-grid';
2
+ UxGrid.install = function(Vue) {
3
+ Vue.component(UxGrid.name, UxGrid);
4
+ };
5
+
6
+ export default UxGrid;