@touchvue/ui 0.0.1-alpha.2 → 1.0.0-beta.2

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 (141) hide show
  1. package/package.json +82 -34
  2. package/README.md +0 -70
  3. package/es/components/article/index.js +0 -66
  4. package/es/components/article/index.js.map +0 -1
  5. package/es/components/box/index.js +0 -98
  6. package/es/components/box/index.js.map +0 -1
  7. package/es/components/button/index.js +0 -96
  8. package/es/components/button/index.js.map +0 -1
  9. package/es/components/calendar/index.js +0 -44
  10. package/es/components/calendar/index.js.map +0 -1
  11. package/es/components/card/index.js +0 -290
  12. package/es/components/card/index.js.map +0 -1
  13. package/es/components/checkbox/index.js +0 -97
  14. package/es/components/checkbox/index.js.map +0 -1
  15. package/es/components/datepicker/index.js +0 -44
  16. package/es/components/datepicker/index.js.map +0 -1
  17. package/es/components/form/index.js +0 -303
  18. package/es/components/form/index.js.map +0 -1
  19. package/es/components/grid/index.js +0 -253
  20. package/es/components/grid/index.js.map +0 -1
  21. package/es/components/header/index.js +0 -233
  22. package/es/components/header/index.js.map +0 -1
  23. package/es/components/icon/index.js +0 -98
  24. package/es/components/icon/index.js.map +0 -1
  25. package/es/components/input/index.js +0 -436
  26. package/es/components/input/index.js.map +0 -1
  27. package/es/components/line/index.js +0 -100
  28. package/es/components/line/index.js.map +0 -1
  29. package/es/components/msg/index.js +0 -322
  30. package/es/components/msg/index.js.map +0 -1
  31. package/es/components/padding/index.js +0 -92
  32. package/es/components/padding/index.js.map +0 -1
  33. package/es/components/page/index.js +0 -334
  34. package/es/components/page/index.js.map +0 -1
  35. package/es/components/select/index.js +0 -218
  36. package/es/components/select/index.js.map +0 -1
  37. package/es/components/space/index.js +0 -88
  38. package/es/components/space/index.js.map +0 -1
  39. package/es/components/step/index.js +0 -127
  40. package/es/components/step/index.js.map +0 -1
  41. package/es/components/switch/index.js +0 -120
  42. package/es/components/switch/index.js.map +0 -1
  43. package/es/components/tab/index.js +0 -227
  44. package/es/components/tab/index.js.map +0 -1
  45. package/es/components/table/index.js +0 -893
  46. package/es/components/table/index.js.map +0 -1
  47. package/es/directives/dis/index.js +0 -32
  48. package/es/directives/dis/index.js.map +0 -1
  49. package/es/directives/size/index.js +0 -23
  50. package/es/directives/size/index.js.map +0 -1
  51. package/es/hooks/index.js +0 -2
  52. package/es/hooks/index.js.map +0 -1
  53. package/es/index.js +0 -4209
  54. package/es/index.js.map +0 -1
  55. package/es/utils/index.js +0 -90
  56. package/es/utils/index.js.map +0 -1
  57. package/lib/components/article/index.js +0 -70
  58. package/lib/components/article/index.js.map +0 -1
  59. package/lib/components/box/index.js +0 -102
  60. package/lib/components/box/index.js.map +0 -1
  61. package/lib/components/button/index.js +0 -98
  62. package/lib/components/button/index.js.map +0 -1
  63. package/lib/components/calendar/index.js +0 -46
  64. package/lib/components/calendar/index.js.map +0 -1
  65. package/lib/components/card/index.js +0 -292
  66. package/lib/components/card/index.js.map +0 -1
  67. package/lib/components/checkbox/index.js +0 -99
  68. package/lib/components/checkbox/index.js.map +0 -1
  69. package/lib/components/datepicker/index.js +0 -46
  70. package/lib/components/datepicker/index.js.map +0 -1
  71. package/lib/components/form/index.js +0 -306
  72. package/lib/components/form/index.js.map +0 -1
  73. package/lib/components/grid/index.js +0 -256
  74. package/lib/components/grid/index.js.map +0 -1
  75. package/lib/components/header/index.js +0 -235
  76. package/lib/components/header/index.js.map +0 -1
  77. package/lib/components/icon/index.js +0 -101
  78. package/lib/components/icon/index.js.map +0 -1
  79. package/lib/components/input/index.js +0 -438
  80. package/lib/components/input/index.js.map +0 -1
  81. package/lib/components/line/index.js +0 -102
  82. package/lib/components/line/index.js.map +0 -1
  83. package/lib/components/msg/index.js +0 -324
  84. package/lib/components/msg/index.js.map +0 -1
  85. package/lib/components/padding/index.js +0 -94
  86. package/lib/components/padding/index.js.map +0 -1
  87. package/lib/components/page/index.js +0 -336
  88. package/lib/components/page/index.js.map +0 -1
  89. package/lib/components/select/index.js +0 -220
  90. package/lib/components/select/index.js.map +0 -1
  91. package/lib/components/space/index.js +0 -90
  92. package/lib/components/space/index.js.map +0 -1
  93. package/lib/components/step/index.js +0 -129
  94. package/lib/components/step/index.js.map +0 -1
  95. package/lib/components/switch/index.js +0 -122
  96. package/lib/components/switch/index.js.map +0 -1
  97. package/lib/components/tab/index.js +0 -230
  98. package/lib/components/tab/index.js.map +0 -1
  99. package/lib/components/table/index.js +0 -898
  100. package/lib/components/table/index.js.map +0 -1
  101. package/lib/directives/dis/index.js +0 -34
  102. package/lib/directives/dis/index.js.map +0 -1
  103. package/lib/directives/size/index.js +0 -25
  104. package/lib/directives/size/index.js.map +0 -1
  105. package/lib/hooks/index.js +0 -3
  106. package/lib/hooks/index.js.map +0 -1
  107. package/lib/index.js +0 -4251
  108. package/lib/index.js.map +0 -1
  109. package/lib/utils/index.js +0 -99
  110. package/lib/utils/index.js.map +0 -1
  111. package/theme/components/article/index.css +0 -1
  112. package/theme/components/box/index.css +0 -1
  113. package/theme/components/button/index.css +0 -1
  114. package/theme/components/calendar/index.css +0 -0
  115. package/theme/components/card/index.css +0 -1
  116. package/theme/components/checkbox/index.css +0 -1
  117. package/theme/components/datepicker/index.css +0 -0
  118. package/theme/components/form/index.css +0 -1
  119. package/theme/components/grid/index.css +0 -1
  120. package/theme/components/header/index.css +0 -1
  121. package/theme/components/icon/index.css +0 -1
  122. package/theme/components/input/index.css +0 -1
  123. package/theme/components/line/index.css +0 -1
  124. package/theme/components/msg/index.css +0 -1
  125. package/theme/components/padding/index.css +0 -1
  126. package/theme/components/space/index.css +0 -1
  127. package/theme/components/step/index.css +0 -1
  128. package/theme/components/switch/index.css +0 -1
  129. package/theme/components/tab/index.css +0 -1
  130. package/theme/components/table/index.css +0 -1
  131. package/theme/img/default.png +0 -0
  132. package/theme/img/icon-type-fill.ttf +0 -0
  133. package/theme/img/icon.ttf +0 -0
  134. package/theme/img/loading-in.png +0 -0
  135. package/theme/img/loading-out.png +0 -0
  136. package/theme/img/msg/error-bg.png +0 -0
  137. package/theme/img/msg/error-icon.png +0 -0
  138. package/theme/img/msg/success-bg.png +0 -0
  139. package/theme/img/msg/success-icon.png +0 -0
  140. package/theme/index.css +0 -1
  141. package/theme/skin/default.css +0 -1
@@ -1,893 +0,0 @@
1
- import { defineComponent, computed, ref, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, Fragment, renderList, createVNode, toDisplayString, createCommentVNode, renderSlot, createTextVNode, onMounted, watch, withCtx, inject, unref, createBlock, withDirectives, withModifiers, vShow } from 'vue';
2
-
3
- const _hoisted_1$3 = { class: "to-table-table" };
4
- const _hoisted_2$2 = { class: "to-table-head" };
5
- const _hoisted_3$1 = { class: "to-table-head-row" };
6
- const _hoisted_4$1 = { class: "to-table-body" };
7
- const _hoisted_5$1 = ["onClick"];
8
- var _sfc_main$3 = /* @__PURE__ */ defineComponent({
9
- ...{
10
- name: "ToTable"
11
- },
12
- __name: "table",
13
- props: {
14
- columns: { type: Array, required: false, default: () => [] },
15
- data: { type: Array, required: false, default: () => [] },
16
- height: { type: [Number, String], required: false, default: "" }
17
- },
18
- setup(__props) {
19
- const props = __props;
20
- const flatData = computed(() => flattenTree(props.data));
21
- const expandedSet = ref(/* @__PURE__ */ new Set());
22
- let uid = 0;
23
- function flattenTree(data, level = 0, parentId) {
24
- const result = [];
25
- for (const item of data) {
26
- const id = uid++;
27
- const { children, ...rest } = item;
28
- result.push({ ...rest, id, parentId, level });
29
- if (children && Array.isArray(children)) {
30
- result.push(...flattenTree(children, level + 1, id));
31
- }
32
- }
33
- return result;
34
- }
35
- function isVisible(item, all) {
36
- let parentId = item.parentId;
37
- while (parentId !== void 0) {
38
- if (!expandedSet.value.has(parentId))
39
- return false;
40
- const parent = all.find((n) => n.id === parentId);
41
- parentId = parent == null ? void 0 : parent.parentId;
42
- }
43
- return true;
44
- }
45
- const visibleRows = computed(
46
- () => flatData.value.filter((item) => item.level === 0 || isVisible(item, flatData.value))
47
- );
48
- function toggleExpand(row) {
49
- if (expandedSet.value.has(row.id)) {
50
- expandedSet.value.delete(row.id);
51
- } else {
52
- expandedSet.value.add(row.id);
53
- }
54
- }
55
- function hasChildren(row) {
56
- return flatData.value.some((item) => item.parentId === row.id);
57
- }
58
- const setClass = computed(() => {
59
- const classes = [];
60
- if (props.height === "full")
61
- classes.push("height-full");
62
- return classes;
63
- });
64
- const setTdClass = (column) => {
65
- return computed(() => {
66
- const classes = [];
67
- if (column.type === "action")
68
- classes.push("is-action");
69
- return classes;
70
- });
71
- };
72
- const setStyle = computed(() => {
73
- const obj = {};
74
- if (props.height && props.height !== "full") {
75
- obj.height = isNaN(Number(props.height)) ? String(props.height) : `${props.height}em`;
76
- }
77
- return obj;
78
- });
79
- return (_ctx, _cache) => {
80
- const _component_ToCheckbox = resolveComponent("ToCheckbox");
81
- return openBlock(), createElementBlock(
82
- "div",
83
- {
84
- class: normalizeClass(["to-table", setClass.value]),
85
- style: normalizeStyle(setStyle.value)
86
- },
87
- [
88
- createElementVNode("table", _hoisted_1$3, [
89
- createElementVNode("thead", _hoisted_2$2, [
90
- createElementVNode("tr", _hoisted_3$1, [
91
- (openBlock(true), createElementBlock(
92
- Fragment,
93
- null,
94
- renderList(_ctx.columns, (column) => {
95
- return openBlock(), createElementBlock(
96
- Fragment,
97
- null,
98
- [
99
- column.type === "check" ? (openBlock(), createElementBlock("th", {
100
- key: column.prop + "check",
101
- class: "to-table-th is-check"
102
- }, [
103
- createVNode(_component_ToCheckbox)
104
- ])) : (openBlock(), createElementBlock(
105
- "th",
106
- {
107
- class: "to-table-th",
108
- key: column.prop
109
- },
110
- toDisplayString(column.label),
111
- 1
112
- /* TEXT */
113
- ))
114
- ],
115
- 64
116
- /* STABLE_FRAGMENT */
117
- );
118
- }),
119
- 256
120
- /* UNKEYED_FRAGMENT */
121
- ))
122
- ])
123
- ]),
124
- createElementVNode("tbody", _hoisted_4$1, [
125
- (openBlock(true), createElementBlock(
126
- Fragment,
127
- null,
128
- renderList(visibleRows.value, (row, rowIndex) => {
129
- return openBlock(), createElementBlock("tr", {
130
- class: "to-table-body-row",
131
- key: rowIndex
132
- }, [
133
- (openBlock(true), createElementBlock(
134
- Fragment,
135
- null,
136
- renderList(_ctx.columns, (column) => {
137
- return openBlock(), createElementBlock(
138
- Fragment,
139
- null,
140
- [
141
- column.type === "check" ? (openBlock(), createElementBlock("td", {
142
- key: column.prop + "check",
143
- class: "to-table-td is-check"
144
- }, [
145
- createVNode(_component_ToCheckbox)
146
- ])) : (openBlock(), createElementBlock(
147
- "td",
148
- {
149
- class: normalizeClass(["to-table-td", setTdClass(column).value]),
150
- key: column.prop,
151
- style: normalizeStyle({ paddingLeft: column.toggler && row.level ? `${row.level + 2}em` : "" })
152
- },
153
- [
154
- hasChildren(row) && column.toggler ? (openBlock(), createElementBlock("span", {
155
- key: 0,
156
- onClick: ($event) => toggleExpand(row),
157
- class: normalizeClass(["to-table-toggle", {
158
- "is-expand": expandedSet.value.has(row.id)
159
- }])
160
- }, null, 10, _hoisted_5$1)) : createCommentVNode("v-if", true),
161
- renderSlot(_ctx.$slots, column.prop, {
162
- row,
163
- index: rowIndex
164
- }, () => [
165
- column.prop ? (openBlock(), createElementBlock(
166
- Fragment,
167
- { key: 0 },
168
- [
169
- createTextVNode(
170
- toDisplayString(row[column.prop]),
171
- 1
172
- /* TEXT */
173
- )
174
- ],
175
- 64
176
- /* STABLE_FRAGMENT */
177
- )) : createCommentVNode("v-if", true)
178
- ])
179
- ],
180
- 6
181
- /* CLASS, STYLE */
182
- ))
183
- ],
184
- 64
185
- /* STABLE_FRAGMENT */
186
- );
187
- }),
188
- 256
189
- /* UNKEYED_FRAGMENT */
190
- ))
191
- ]);
192
- }),
193
- 128
194
- /* KEYED_FRAGMENT */
195
- ))
196
- ])
197
- ])
198
- ],
199
- 6
200
- /* CLASS, STYLE */
201
- );
202
- };
203
- }
204
- });
205
-
206
- var _export_sfc = (sfc, props) => {
207
- const target = sfc.__vccOpts || sfc;
208
- for (const [key, val] of props) {
209
- target[key] = val;
210
- }
211
- return target;
212
- };
213
-
214
- var Table = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__file", "/Users/wangding/WorkSpace/AsiaInfo/projects/\u524D\u7AEF\u6846\u67B6/touch-vue3-ui/packages/components/table/src/table.vue"]]);
215
-
216
- const _hoisted_1$2 = { class: "config" };
217
- var _sfc_main$2 = /* @__PURE__ */ defineComponent({
218
- ...{
219
- name: "ToTableConfig"
220
- },
221
- __name: "table-config",
222
- props: {
223
- data: { type: Array, default: () => [] }
224
- },
225
- emits: ["change"],
226
- setup(__props, { emit: __emit }) {
227
- const props = __props;
228
- const emit = __emit;
229
- const checked = ref([]);
230
- const configData = ref([]);
231
- const configIconRef = ref();
232
- const floatRef = ref();
233
- function setConfigData() {
234
- const data = JSON.parse(JSON.stringify(props.data));
235
- function setData(data2, path) {
236
- data2.forEach((dataItem, dataIndex) => {
237
- if (dataItem.type === "selection" || dataItem.type === "radio") {
238
- dataItem.label = "\u9009\u62E9\u5668";
239
- }
240
- if (dataItem.type === "action") {
241
- data2.splice(dataIndex, 1);
242
- }
243
- dataItem.path = path ? path.concat(dataItem.label) : [dataItem.label];
244
- if (dataItem.children) {
245
- setData(dataItem.children, dataItem.path);
246
- }
247
- });
248
- }
249
- setData(data);
250
- configData.value = data;
251
- }
252
- function setChecked() {
253
- const arr = [];
254
- function setData(data) {
255
- data.forEach((dataItem) => {
256
- if (dataItem.show !== false) {
257
- if (dataItem.type === "selection") {
258
- arr.push("\u9009\u62E9\u5668");
259
- } else {
260
- arr.push(dataItem.label);
261
- }
262
- }
263
- if (dataItem.children) {
264
- setData(dataItem.children);
265
- }
266
- });
267
- }
268
- setData(props.data);
269
- checked.value = arr;
270
- }
271
- function flex() {
272
- var _a, _b;
273
- (_b = floatRef.value) == null ? void 0 : _b.set((_a = configIconRef.value) == null ? void 0 : _a.$el);
274
- }
275
- function check(checkedKeys, checkedNodes, node, checkedFlag) {
276
- const data = JSON.parse(JSON.stringify(props.data));
277
- function checkData(data2) {
278
- data2.forEach((dataItem) => {
279
- if (dataItem.type === "selection") {
280
- dataItem.show = checkedKeys.includes("\u9009\u62E9\u5668");
281
- } else {
282
- dataItem.show = checkedKeys.includes(dataItem.label) || dataItem.type === "action";
283
- }
284
- if (dataItem.children) {
285
- checkData(dataItem.children);
286
- }
287
- });
288
- }
289
- function setChildrenHide(data2, setHide) {
290
- data2.forEach((dataItem) => {
291
- if (setHide) {
292
- dataItem.show = false;
293
- checked.value = checked.value.filter((item) => item !== dataItem.label);
294
- }
295
- if (dataItem.children) {
296
- setChildrenHide(dataItem.children, dataItem.label === node.label || setHide);
297
- }
298
- });
299
- }
300
- function setChildrenAndParentShow(data2, setShow) {
301
- data2.forEach((dataItem) => {
302
- if (setShow || node.path.includes(dataItem.label)) {
303
- dataItem.show = true;
304
- if (!checked.value.includes(dataItem.label)) {
305
- checked.value.push(dataItem.label);
306
- }
307
- }
308
- if (dataItem.children) {
309
- setChildrenAndParentShow(dataItem.children, dataItem.label === node.label || setShow);
310
- }
311
- });
312
- }
313
- checkData(data);
314
- if (!checkedFlag) {
315
- setChildrenHide(data, false);
316
- checked.value = checked.value.filter((item) => item !== node.label);
317
- } else {
318
- setChildrenAndParentShow(data, false);
319
- checked.value.push(node.label);
320
- }
321
- emit("change", data);
322
- }
323
- onMounted(() => {
324
- setConfigData();
325
- setChecked();
326
- });
327
- watch(() => props.data, () => {
328
- setConfigData();
329
- setChecked();
330
- });
331
- return (_ctx, _cache) => {
332
- const _component_to_icon = resolveComponent("to-icon");
333
- const _component_to_tree = resolveComponent("to-tree");
334
- const _component_to_scroll = resolveComponent("to-scroll");
335
- const _component_to_float = resolveComponent("to-float");
336
- return openBlock(), createElementBlock("div", _hoisted_1$2, [
337
- createVNode(
338
- _component_to_icon,
339
- {
340
- ref: "configIcon",
341
- value: "config",
342
- color: "info",
343
- mode: "none",
344
- link: "",
345
- fillet: "round",
346
- onClick: _cache[0] || (_cache[0] = () => {
347
- var _a;
348
- return (_a = floatRef.value.value) == null ? void 0 : _a.toggle(configIconRef.value.value);
349
- })
350
- },
351
- null,
352
- 512
353
- /* NEED_PATCH */
354
- ),
355
- createVNode(
356
- _component_to_float,
357
- {
358
- ref_key: "floatRef",
359
- ref: floatRef,
360
- width: "18",
361
- lazy: false
362
- },
363
- {
364
- default: withCtx(() => [
365
- createVNode(_component_to_scroll, { padding: "0.5" }, {
366
- default: withCtx(() => [
367
- createVNode(_component_to_tree, {
368
- "show-checkbox": "",
369
- "check-strictly": "",
370
- expand: "",
371
- "check-on-click-node": "",
372
- data: configData.value,
373
- "value-text": "label",
374
- "checked-keys": checked.value,
375
- onCheckChange: check,
376
- onNodeExpand: flex,
377
- onNodeCollapse: flex
378
- }, null, 8, ["data", "checked-keys"])
379
- ]),
380
- _: 1
381
- /* STABLE */
382
- })
383
- ]),
384
- _: 1
385
- /* STABLE */
386
- },
387
- 512
388
- /* NEED_PATCH */
389
- )
390
- ]);
391
- };
392
- }
393
- });
394
-
395
- var TableConfig = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__file", "/Users/wangding/WorkSpace/AsiaInfo/projects/\u524D\u7AEF\u6846\u67B6/touch-vue3-ui/packages/components/table/src/table-config.vue"]]);
396
-
397
- const _hoisted_1$1 = { ref: "row" };
398
- const _hoisted_2$1 = ["rowspan", "colspan"];
399
- const _hoisted_3 = ["rowspan", "colspan"];
400
- const _hoisted_4 = ["rowspan", "colspan", "onClick"];
401
- const _hoisted_5 = ["rowspan", "colspan"];
402
- const _hoisted_6 = ["rowspan", "colspan", "onClick"];
403
- var _sfc_main$1 = /* @__PURE__ */ defineComponent({
404
- ...{
405
- name: "ToTableHead"
406
- },
407
- __name: "table-head",
408
- props: {
409
- name: { type: String, default: "" },
410
- start: { type: Number, default: null },
411
- end: { type: Number, default: null },
412
- data: { type: Array, default: () => [] },
413
- configurable: Boolean
414
- },
415
- emits: ["select-all", "column-change"],
416
- setup(__props, { emit: __emit }) {
417
- const t = (str) => str;
418
- const props = __props;
419
- const emit = __emit;
420
- const ToTable = inject("ToTable");
421
- const showColumn = (column, columnIndex) => {
422
- console.log(columnIndex);
423
- if (column.show === false)
424
- return false;
425
- if (["selection", "radio", "action"].includes(column.type))
426
- return true;
427
- if (ToTable.showColumns || ToTable.showColumns === 0) {
428
- if (!isNaN(ToTable.showColumns)) {
429
- const index = ToTable.normalColumn.findIndex((item) => column.prop === item.prop);
430
- return index !== -1 && index < Number(ToTable.showColumns);
431
- } else {
432
- return ToTable.showColumns.split(",").includes(column.prop);
433
- }
434
- }
435
- return true;
436
- };
437
- function countLeafNodes(tree) {
438
- if (!tree || tree.length === 0)
439
- return 0;
440
- let leafCount = 0;
441
- for (let i = 0; i < tree.length; i++) {
442
- if (tree[i].show !== false) {
443
- if (!tree[i].children || tree[i].children.length === 0 || tree[i].children.every((child) => child.show === false)) {
444
- leafCount += 1;
445
- } else {
446
- leafCount += countLeafNodes(tree[i].children);
447
- }
448
- }
449
- }
450
- return leafCount;
451
- }
452
- const tableData = computed(() => {
453
- const result = [];
454
- let maxDepth = 0;
455
- function calculateMaxDepth(heads, depth = 1) {
456
- heads.forEach((head) => {
457
- if (head.children) {
458
- calculateMaxDepth(head.children, depth + 1);
459
- }
460
- });
461
- maxDepth = Math.max(maxDepth, depth);
462
- }
463
- calculateMaxDepth(props.data);
464
- function generateTableData(heads, depth = 0, rowIndex = 0) {
465
- if (!result[rowIndex])
466
- result[rowIndex] = [];
467
- heads.forEach((head) => {
468
- const cell = Object.assign({}, head, { rowspan: 1, colspan: 1 });
469
- if (head.children && !head.children.every((child) => child.show === false)) {
470
- cell.colspan = countLeafNodes(head.children);
471
- result[rowIndex].push(cell);
472
- generateTableData(head.children, depth + 1, rowIndex + 1);
473
- } else {
474
- cell.rowspan = maxDepth - depth;
475
- result[rowIndex].push(cell);
476
- }
477
- });
478
- }
479
- generateTableData(JSON.parse(JSON.stringify(props.data)));
480
- return result;
481
- });
482
- function checkAllChange(checked) {
483
- emit("select-all", checked);
484
- }
485
- function configChange(data) {
486
- emit("column-change", data);
487
- }
488
- return (_ctx, _cache) => {
489
- const _component_to_checkbox = resolveComponent("to-checkbox");
490
- const _component_to_icon = resolveComponent("to-icon");
491
- return openBlock(), createElementBlock(
492
- "thead",
493
- _hoisted_1$1,
494
- [
495
- (openBlock(true), createElementBlock(
496
- Fragment,
497
- null,
498
- renderList(tableData.value, (titem, tindex) => {
499
- return openBlock(), createElementBlock("tr", { key: tindex }, [
500
- (openBlock(true), createElementBlock(
501
- Fragment,
502
- null,
503
- renderList(titem, (item, index) => {
504
- return openBlock(), createElementBlock(
505
- Fragment,
506
- null,
507
- [
508
- showColumn(item, index) ? (openBlock(), createElementBlock(
509
- Fragment,
510
- { key: 0 },
511
- [
512
- unref(ToTable).isNeedSelectAll && item.type === "selection" ? (openBlock(), createElementBlock("th", {
513
- key: index + "_selection",
514
- class: normalizeClass(["selection", [item.sortable === true ? "sort" : "", "checkbox"]]),
515
- rowspan: item.rowspan || 1,
516
- colspan: item.colspan || 1
517
- }, [
518
- createVNode(_component_to_checkbox, {
519
- value: unref(ToTable).isSelectAll && unref(ToTable).iData.length > 0,
520
- onChange: checkAllChange
521
- }, null, 8, ["value"])
522
- ], 10, _hoisted_2$1)) : item.type === "radio" ? (openBlock(), createElementBlock("th", {
523
- key: index + "_radio",
524
- class: normalizeClass(["radio", [item.sortable === true ? "sort" : "", "index"]]),
525
- rowspan: item.rowspan || 1,
526
- colspan: item.colspan || 1
527
- }, toDisplayString(t("to.common.select")), 11, _hoisted_3)) : item.type === "index" ? (openBlock(), createElementBlock("th", {
528
- key: index + "_index",
529
- rowspan: item.rowspan || 1,
530
- colspan: item.colspan || 1,
531
- class: normalizeClass([item.sortable === true ? "sort" : "", "index"]),
532
- onClick: ($event) => unref(ToTable).handleTableHeadCellClick(item, index, $event)
533
- }, [
534
- item.sortable === true ? (openBlock(), createElementBlock(
535
- Fragment,
536
- { key: 0 },
537
- [
538
- item.orderType == "asc" ? (openBlock(), createBlock(_component_to_icon, {
539
- key: 0,
540
- value: "fold"
541
- })) : createCommentVNode("v-if", true),
542
- item.orderType == "desc" ? (openBlock(), createBlock(_component_to_icon, {
543
- key: 1,
544
- value: "unfold"
545
- })) : createCommentVNode("v-if", true)
546
- ],
547
- 64
548
- /* STABLE_FRAGMENT */
549
- )) : createCommentVNode("v-if", true),
550
- createElementVNode(
551
- "span",
552
- null,
553
- toDisplayString(unref(ToTable).indexColumnName || item.label),
554
- 1
555
- /* TEXT */
556
- )
557
- ], 10, _hoisted_4)) : item.type === "action" && __props.configurable && unref(ToTable).hasAction ? (openBlock(), createElementBlock("th", {
558
- key: index + "_action",
559
- rowspan: item.rowspan || 1,
560
- colspan: item.colspan || 1,
561
- class: "configTh action"
562
- }, [
563
- createVNode(TableConfig, {
564
- data: unref(ToTable).columns,
565
- onChange: configChange
566
- }, null, 8, ["data"])
567
- ], 8, _hoisted_5)) : !(item.type === "action" && unref(ToTable).contextAction) ? (openBlock(), createElementBlock("th", {
568
- key: index + "_other",
569
- rowspan: item.rowspan || 1,
570
- colspan: item.colspan || 1,
571
- class: normalizeClass([item.sortable === true ? "sort" : "", item.type === "action" ? "action" : ""]),
572
- onClick: ($event) => unref(ToTable).handleTableHeadCellClick(item, index, $event)
573
- }, [
574
- item.sortable === true ? (openBlock(), createElementBlock(
575
- "span",
576
- {
577
- key: 0,
578
- class: normalizeClass(["to-table-sorticon", `type-${item.orderType}`])
579
- },
580
- [
581
- createVNode(_component_to_icon, {
582
- value: "fold",
583
- type: "fill"
584
- }),
585
- createVNode(_component_to_icon, {
586
- value: "unfold",
587
- type: "fill"
588
- })
589
- ],
590
- 2
591
- /* CLASS */
592
- )) : createCommentVNode("v-if", true),
593
- renderSlot(_ctx.$slots, item.prop + "_th", {
594
- column: item,
595
- index
596
- }, () => [
597
- createElementVNode(
598
- "span",
599
- null,
600
- toDisplayString(item.label),
601
- 1
602
- /* TEXT */
603
- )
604
- ])
605
- ], 10, _hoisted_6)) : createCommentVNode("v-if", true)
606
- ],
607
- 64
608
- /* STABLE_FRAGMENT */
609
- )) : createCommentVNode("v-if", true)
610
- ],
611
- 64
612
- /* STABLE_FRAGMENT */
613
- );
614
- }),
615
- 256
616
- /* UNKEYED_FRAGMENT */
617
- ))
618
- ]);
619
- }),
620
- 128
621
- /* KEYED_FRAGMENT */
622
- ))
623
- ],
624
- 512
625
- /* NEED_PATCH */
626
- );
627
- };
628
- }
629
- });
630
-
631
- var TableHead = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/Users/wangding/WorkSpace/AsiaInfo/projects/\u524D\u7AEF\u6846\u67B6/touch-vue3-ui/packages/components/table/src/table-head.vue"]]);
632
-
633
- const _hoisted_1 = ["data-index", "onContextmenu"];
634
- const _hoisted_2 = { key: 0 };
635
- var _sfc_main = /* @__PURE__ */ defineComponent({
636
- ...{
637
- name: "ToTableBody"
638
- },
639
- __name: "table-body",
640
- props: {
641
- columnData: { type: Array, default: () => [] },
642
- data: { type: Array, default: () => [] }
643
- },
644
- setup(__props) {
645
- const props = __props;
646
- const ToTable = inject("ToTable");
647
- const isClick = ref(false);
648
- const isDblClick = ref(false);
649
- const clickTimer = ref(null);
650
- const showColumn = (column, columnIndex) => {
651
- console.log(columnIndex);
652
- if (column.show === false)
653
- return false;
654
- if (ToTable.type === "v") {
655
- if (["key", "desc", "icon", "state", "selection", "radio", "action"].includes(column.type))
656
- return false;
657
- } else {
658
- if (["selection", "radio", "action"].includes(column.type))
659
- return true;
660
- }
661
- if (ToTable.showColumns) {
662
- if (!isNaN(ToTable.showColumns)) {
663
- const index = ToTable.normalColumn.findIndex((item) => column.prop === item.prop);
664
- return index !== -1 && index < Number(ToTable.showColumns);
665
- } else {
666
- return ToTable.showColumns.split(",").includes(column.prop);
667
- }
668
- }
669
- return true;
670
- };
671
- const setClass = (column) => {
672
- const arr = [];
673
- if (column.type === "key")
674
- arr.push("key");
675
- if (column.type === "action")
676
- arr.push("action");
677
- if (column.type === "edit")
678
- arr.push("edit");
679
- if (column.type === "desc")
680
- arr.push("desc");
681
- if (column.wrap)
682
- arr.push("wrap");
683
- if (column.className)
684
- arr.push(...column.className.split(","));
685
- return arr;
686
- };
687
- console.log(setClass);
688
- const setTrClass = (dataItem) => {
689
- const arr = [];
690
- if (dataItem._on)
691
- arr.push("on");
692
- if (dataItem._hover)
693
- arr.push("hover");
694
- if (dataItem._active)
695
- arr.push("active");
696
- if (dataItem._className)
697
- arr.push(...dataItem._className.split(","));
698
- return arr;
699
- };
700
- const setTrStyle = computed(() => {
701
- const obj = {};
702
- if (ToTable.space)
703
- obj.marginTop = `${ToTable.space}em`;
704
- return obj;
705
- });
706
- const tableData = computed(() => {
707
- const result = [];
708
- function traverse(headers) {
709
- headers.forEach((header) => {
710
- if (header.children && !header.children.every((child) => child.show === false)) {
711
- traverse(header.children);
712
- } else {
713
- result.push(header);
714
- }
715
- });
716
- }
717
- traverse(props.columnData);
718
- return result;
719
- });
720
- function toggleFold(item, index) {
721
- if (!item._showChild) {
722
- item._showChild = true;
723
- } else {
724
- item._showChild = false;
725
- }
726
- for (let i = index + 1; i < props.data.length; i++) {
727
- const el = props.data[i];
728
- if (item._showChild) {
729
- if (el._level === item._level + 1) {
730
- el._show = true;
731
- } else if (el._level <= item._level) {
732
- break;
733
- }
734
- } else {
735
- if (el._level === item._level + 1) {
736
- hide(el, i);
737
- } else if (el._level <= item._level) {
738
- break;
739
- }
740
- }
741
- }
742
- function hide(tr, index2) {
743
- tr._show = false;
744
- tr._showChild = false;
745
- if (tr._hasChild) {
746
- for (let i = index2 + 1; i < props.data.length; i++) {
747
- const el = props.data[i];
748
- if (el._level === tr._level + 1) {
749
- hide(el, i);
750
- } else {
751
- break;
752
- }
753
- }
754
- }
755
- }
756
- ToTable.adjust();
757
- }
758
- console.log(toggleFold);
759
- function clickHandle(event) {
760
- const path = event.composedPath ? event.composedPath() : event.path;
761
- if (ToTable.$listeners && (ToTable.$listeners["row-dblclick"] || ToTable.$listeners["cell-dblclick"])) {
762
- clickTimer.value = window.setTimeout(() => {
763
- if (!isDblClick.value) {
764
- isClick.value = true;
765
- ToTable.handleTableClick(event, path);
766
- const timer = window.setTimeout(() => {
767
- isClick.value = false;
768
- clearTimeout(timer);
769
- }, 300);
770
- } else {
771
- isDblClick.value = false;
772
- }
773
- if (clickTimer.value)
774
- clearTimeout(clickTimer.value);
775
- }, 300);
776
- } else {
777
- ToTable.handleTableClick(event);
778
- }
779
- }
780
- function dbclickHandle(event) {
781
- if (!isClick.value) {
782
- isDblClick.value = true;
783
- ToTable.handleTableDblClick(event);
784
- } else {
785
- isClick.value = false;
786
- }
787
- }
788
- return (_ctx, _cache) => {
789
- return openBlock(), createElementBlock(
790
- "tbody",
791
- {
792
- ref: "tbody",
793
- onClick: clickHandle,
794
- onMouseover: _cache[0] || (_cache[0] = //@ts-ignore
795
- (...args) => unref(ToTable).handleTableMouseover && unref(ToTable).handleTableMouseover(...args)),
796
- onMouseout: _cache[1] || (_cache[1] = //@ts-ignore
797
- (...args) => unref(ToTable).handleTableMouseout && unref(ToTable).handleTableMouseout(...args)),
798
- onMousedown: _cache[2] || (_cache[2] = //@ts-ignore
799
- (...args) => unref(ToTable).handleTableMousedown && unref(ToTable).handleTableMousedown(...args)),
800
- onTouchstart: _cache[3] || (_cache[3] = //@ts-ignore
801
- (...args) => unref(ToTable).handleTableMousedown && unref(ToTable).handleTableMousedown(...args)),
802
- onTouchmove: _cache[4] || (_cache[4] = //@ts-ignore
803
- (...args) => unref(ToTable).handleTableMousemove && unref(ToTable).handleTableMousemove(...args)),
804
- onMouseup: _cache[5] || (_cache[5] = //@ts-ignore
805
- (...args) => unref(ToTable).handleTableMouseup && unref(ToTable).handleTableMouseup(...args)),
806
- onTouchend: _cache[6] || (_cache[6] = //@ts-ignore
807
- (...args) => unref(ToTable).handleTableMouseup && unref(ToTable).handleTableMouseup(...args)),
808
- onDblclick: dbclickHandle
809
- },
810
- [
811
- (openBlock(true), createElementBlock(
812
- Fragment,
813
- null,
814
- renderList(__props.data, (dataItem, dataIndex) => {
815
- return withDirectives((openBlock(), createElementBlock("tr", {
816
- key: dataIndex,
817
- class: normalizeClass(setTrClass(dataItem)),
818
- style: normalizeStyle(setTrStyle.value),
819
- "data-index": dataIndex,
820
- onContextmenu: withModifiers(($event) => unref(ToTable).handleTableRowRightClick(dataItem, dataIndex, $event), ["prevent"])
821
- }, [
822
- unref(ToTable).type === "v" ? (openBlock(), createElementBlock("td", _hoisted_2, [
823
- renderSlot(_ctx.$slots, "v", {
824
- row: dataItem,
825
- index: dataIndex
826
- }, () => [
827
- createCommentVNode(" ... \u4FDD\u6301\u539F\u6709\u7ED3\u6784 ... ")
828
- ])
829
- ])) : (openBlock(true), createElementBlock(
830
- Fragment,
831
- { key: 1 },
832
- renderList(tableData.value, (column, columnIndex) => {
833
- return openBlock(), createElementBlock(
834
- Fragment,
835
- null,
836
- [
837
- showColumn(column, columnIndex) ? (openBlock(), createElementBlock(
838
- Fragment,
839
- { key: 0 },
840
- [
841
- createCommentVNode(" ... \u4FDD\u6301\u539F\u6709\u7ED3\u6784 ... ")
842
- ],
843
- 64
844
- /* STABLE_FRAGMENT */
845
- )) : createCommentVNode("v-if", true)
846
- ],
847
- 64
848
- /* STABLE_FRAGMENT */
849
- );
850
- }),
851
- 256
852
- /* UNKEYED_FRAGMENT */
853
- ))
854
- ], 46, _hoisted_1)), [
855
- [vShow, dataItem._show]
856
- ]);
857
- }),
858
- 128
859
- /* KEYED_FRAGMENT */
860
- ))
861
- ],
862
- 544
863
- /* NEED_HYDRATION, NEED_PATCH */
864
- );
865
- };
866
- }
867
- });
868
-
869
- var TableBody = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/Users/wangding/WorkSpace/AsiaInfo/projects/\u524D\u7AEF\u6846\u67B6/touch-vue3-ui/packages/components/table/src/table-body.vue"]]);
870
-
871
- const withInstall = (main, extra) => {
872
- main.install = (app) => {
873
- for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
874
- app.component(comp.name, comp);
875
- }
876
- };
877
- if (extra) {
878
- for (const [key, comp] of Object.entries(extra)) {
879
- main[key] = comp;
880
- }
881
- }
882
- return main;
883
- };
884
-
885
- navigator.userAgent.toLowerCase();
886
-
887
- const ToTable = withInstall(Table);
888
- const ToTableHead = withInstall(TableHead);
889
- const ToTableBody = withInstall(TableBody);
890
- const ToTableConfig = withInstall(TableConfig);
891
-
892
- export { ToTable, ToTableBody, ToTableConfig, ToTableHead };
893
- //# sourceMappingURL=index.js.map