@jetlinks-web/components 2.0.36 → 2.0.38

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 (78) hide show
  1. package/es/CardSelect/style/index.js +1 -0
  2. package/es/CheckButton/style/index.js +1 -0
  3. package/es/DragModal/DragModal.js +307 -0
  4. package/es/DragModal/index.js +5 -0
  5. package/es/DragModal/style/index.css +81 -0
  6. package/es/DragModal/style/index.js +1 -0
  7. package/es/DragModal/style/index.less +96 -0
  8. package/es/EditTable/Body.js +365 -0
  9. package/es/EditTable/EditTable.js +401 -0
  10. package/es/EditTable/Header.js +242 -0
  11. package/es/EditTable/components/ContextMenu/Menu.js +154 -0
  12. package/es/EditTable/components/ContextMenu/index.js +81 -0
  13. package/es/EditTable/components/Search/Search.js +290 -0
  14. package/es/EditTable/components/Search/index.js +1 -0
  15. package/es/EditTable/consts.js +7 -0
  16. package/es/EditTable/hooks/index.js +40 -0
  17. package/es/EditTable/hooks/useResizeObserver.js +31 -0
  18. package/es/EditTable/hooks/useValidate.js +87 -0
  19. package/es/EditTable/index.js +9 -0
  20. package/es/EditTable/props.js +50 -0
  21. package/es/EditTable/style/body.less +76 -0
  22. package/es/EditTable/style/header.less +77 -0
  23. package/es/EditTable/style/index.css +219 -0
  24. package/es/EditTable/style/index.js +1 -0
  25. package/es/EditTable/style/index.less +42 -0
  26. package/es/EditTable/style/table.less +42 -0
  27. package/es/EditTable/utils.js +98 -0
  28. package/es/Ellipsis/style/index.js +1 -0
  29. package/es/FullPage/FullPage.js +1 -1
  30. package/es/ProTable/Content.js +5 -2
  31. package/es/ProTable/style/ProTable.less +134 -134
  32. package/es/Search/Advanced/SaveHistory.js +1 -1
  33. package/es/Search/Item.js +1 -1
  34. package/es/Search/Search.js +1 -1
  35. package/es/components.js +3 -1
  36. package/es/style/index.css +292 -3
  37. package/es/style/index.less +9 -7
  38. package/es/style.js +3 -1
  39. package/lib/CardSelect/style/index.js +3 -0
  40. package/lib/CheckButton/style/index.js +3 -0
  41. package/lib/DragModal/DragModal.js +307 -0
  42. package/lib/DragModal/index.js +12 -0
  43. package/lib/DragModal/style/index.css +81 -0
  44. package/lib/DragModal/style/index.js +3 -0
  45. package/lib/DragModal/style/index.less +96 -0
  46. package/lib/EditTable/Body.js +365 -0
  47. package/lib/EditTable/EditTable.js +401 -0
  48. package/lib/EditTable/Header.js +242 -0
  49. package/lib/EditTable/components/ContextMenu/Menu.js +154 -0
  50. package/lib/EditTable/components/ContextMenu/index.js +88 -0
  51. package/lib/EditTable/components/Search/Search.js +290 -0
  52. package/lib/EditTable/components/Search/index.js +13 -0
  53. package/lib/EditTable/consts.js +13 -0
  54. package/lib/EditTable/hooks/index.js +79 -0
  55. package/lib/EditTable/hooks/useResizeObserver.js +38 -0
  56. package/lib/EditTable/hooks/useValidate.js +94 -0
  57. package/lib/EditTable/index.js +16 -0
  58. package/lib/EditTable/props.js +56 -0
  59. package/lib/EditTable/style/body.less +76 -0
  60. package/lib/EditTable/style/header.less +77 -0
  61. package/lib/EditTable/style/index.css +219 -0
  62. package/lib/EditTable/style/index.js +3 -0
  63. package/lib/EditTable/style/index.less +42 -0
  64. package/lib/EditTable/style/table.less +42 -0
  65. package/lib/EditTable/utils.js +105 -0
  66. package/lib/Ellipsis/style/index.js +3 -0
  67. package/lib/FullPage/FullPage.js +1 -1
  68. package/lib/ProTable/Content.js +5 -2
  69. package/lib/ProTable/style/ProTable.less +134 -134
  70. package/lib/Search/Advanced/SaveHistory.js +1 -1
  71. package/lib/Search/Item.js +1 -1
  72. package/lib/Search/Search.js +1 -1
  73. package/lib/components.js +14 -0
  74. package/lib/style/components.less +2 -0
  75. package/lib/style/index.css +292 -3
  76. package/lib/style/index.less +9 -7
  77. package/lib/style.js +3 -1
  78. package/package.json +5 -3
@@ -0,0 +1,365 @@
1
+ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) {
2
+ const op = ops[i];
3
+ const fn = ops[i + 1];
4
+ i += 2;
5
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
6
+ return undefined;
7
+ }
8
+ if (op === 'access' || op === 'optionalAccess') {
9
+ lastAccessLHS = value;
10
+ value = fn(value);
11
+ }
12
+ else if (op === 'call' || op === 'optionalCall') {
13
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
14
+ lastAccessLHS = undefined;
15
+ }
16
+ } return value; }
17
+ /* Analyzed bindings: {
18
+ "groupKey": "props",
19
+ "ContextMenu": "setup-maybe-ref",
20
+ "useRightMenuContext": "setup-maybe-ref",
21
+ "useTableTool": "setup-maybe-ref",
22
+ "randomString": "setup-maybe-ref",
23
+ "bodyProps": "setup-maybe-ref",
24
+ "defaultProps": "setup-maybe-ref",
25
+ "ref": "setup-const",
26
+ "reactive": "setup-const",
27
+ "computed": "setup-const",
28
+ "watch": "setup-const",
29
+ "onMounted": "setup-const",
30
+ "onBeforeUnmount": "setup-const",
31
+ "handleColumnFixed": "setup-maybe-ref",
32
+ "props": "setup-reactive-const",
33
+ "emit": "setup-const",
34
+ "viewScrollRef": "setup-ref",
35
+ "virtualRang": "setup-reactive-const",
36
+ "containerStyle": "setup-ref",
37
+ "context": "setup-maybe-ref",
38
+ "tableTool": "setup-maybe-ref",
39
+ "selectedRowKeys": "setup-ref",
40
+ "hoverKeys": "setup-ref",
41
+ "scrollLock": "setup-ref",
42
+ "menuInstance": "setup-let",
43
+ "maxLen": "setup-ref",
44
+ "virtualData": "setup-ref",
45
+ "columnFixedMap": "setup-ref",
46
+ "onScroll": "setup-const",
47
+ "scrollTo": "setup-const",
48
+ "showContextMenu": "setup-const",
49
+ "rowClick": "setup-const",
50
+ "updateSelectedKeys": "setup-const"
51
+ } */
52
+ import { normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, createVNode as _createVNode } from "vue";
53
+ const _hoisted_1 = {
54
+ class: "jetlinks-edit-table-body-container",
55
+ style: { position: 'relative' }
56
+ };
57
+ const _hoisted_2 = ["data-row-key", "onContextmenu", "onClick", "onMouseover"];
58
+ const _hoisted_3 = { class: "body-cell-box" };
59
+ const _hoisted_4 = ["data-row-key", "onContextmenu", "onClick", "onMouseover"];
60
+ const _hoisted_5 = { class: "body-cell-box" };
61
+ const _hoisted_6 = ["data-row-key", "onContextmenu", "onClick", "onMouseover"];
62
+ const _hoisted_7 = { class: "body-cell-box" };
63
+ const _hoisted_8 = { class: "jetlinks-edit-table-body-empty" };
64
+ import ContextMenu from './components/ContextMenu';
65
+ import { useRightMenuContext, useTableTool } from "./hooks";
66
+ import { randomString } from "@jetlinks-web/utils";
67
+ import { bodyProps, defaultProps } from "./props";
68
+ import { ref, reactive, computed, watch, onMounted, onBeforeUnmount } from 'vue';
69
+ import { handleColumnFixed } from "./utils";
70
+ const __sfc_main__ = Object.assign({
71
+ name: 'JEditTableBody'
72
+ }, {
73
+ props: {
74
+ ...defaultProps(),
75
+ ...bodyProps(),
76
+ groupKey: {
77
+ type: [String, Number],
78
+ default: undefined
79
+ }
80
+ },
81
+ emits: ['update:dataSource', 'scrollDown'],
82
+ setup(__props, { expose: __expose, emit: __emit }) {
83
+ const props = __props;
84
+ const emit = __emit;
85
+ const viewScrollRef = ref();
86
+ const virtualRang = reactive({
87
+ start: 0,
88
+ end: 15
89
+ });
90
+ const containerStyle = ref(0);
91
+ const context = useRightMenuContext();
92
+ const tableTool = useTableTool();
93
+ const selectedRowKeys = ref([]);
94
+ const hoverKeys = ref();
95
+ const scrollLock = ref(false);
96
+ let menuInstance;
97
+ const maxLen = computed(() => {
98
+ return Math.trunc(props.height / props.cellHeight);
99
+ });
100
+ const virtualData = computed(() => props.dataSource.slice(virtualRang.start, virtualRang.end));
101
+ const columnFixedMap = computed(() => {
102
+ return handleColumnFixed(props.columns);
103
+ });
104
+ const onScroll = () => {
105
+ if (!viewScrollRef.value)
106
+ return;
107
+ const height = viewScrollRef.value.scrollTop;
108
+ const clientHeight = viewScrollRef.value.clientHeight;
109
+ const scrollHeight = viewScrollRef.value.scrollHeight;
110
+ const _index = Math.round(height / props.cellHeight) - 1;
111
+ const start = _index < 0 ? 0 : _index;
112
+ const end = start + maxLen.value + 4;
113
+ if (height + clientHeight >= props.dataSource.length * props.cellHeight && !scrollLock.value) { // 滚动到底
114
+ emit('scrollDown');
115
+ scrollLock.value = true;
116
+ }
117
+ virtualRang.start = start;
118
+ virtualRang.end = end;
119
+ // updateVirtualData(start, end)
120
+ };
121
+ const scrollTo = (index) => {
122
+ if (viewScrollRef.value) {
123
+ let top = index * props.cellHeight;
124
+ viewScrollRef.value.scrollTop = top;
125
+ }
126
+ };
127
+ const showContextMenu = (e, record, _index) => {
128
+ e.preventDefault();
129
+ if (!props.disableMenu) {
130
+ record = {
131
+ ...record,
132
+ __index: _index
133
+ };
134
+ menuInstance = ContextMenu(e, record, context);
135
+ }
136
+ };
137
+ const rowClick = (record) => {
138
+ if (_optionalChain([props, 'access', _ => _.rowSelection, 'optionalAccess', _2 => _2.selectedRowKeys])) {
139
+ const rowSet = new Set(selectedRowKeys.value);
140
+ const key = record[props.rowKey];
141
+ const selected = !rowSet.has(key);
142
+ if (selected) {
143
+ rowSet.delete(key);
144
+ }
145
+ else {
146
+ rowSet.add(key);
147
+ }
148
+ _optionalChain([props, 'access', _3 => _3.rowSelection, 'access', _4 => _4.onSelect, 'optionalCall', _5 => _5(record, selected)]);
149
+ selectedRowKeys.value = [...rowSet.values()];
150
+ }
151
+ };
152
+ const updateSelectedKeys = (keys) => {
153
+ selectedRowKeys.value = keys;
154
+ };
155
+ watch(() => JSON.stringify(_optionalChain([props, 'access', _6 => _6.rowSelection, 'optionalAccess', _7 => _7.selectedRowKeys])), (val) => {
156
+ selectedRowKeys.value = JSON.parse(val || '[]');
157
+ }, { immediate: true });
158
+ watch(() => props.dataSource, (val, oldVal) => {
159
+ props.dataSource.forEach((item, index) => {
160
+ if (!item.__key) {
161
+ item.__key = randomString();
162
+ }
163
+ });
164
+ }, {
165
+ immediate: true,
166
+ deep: true
167
+ });
168
+ watch(() => props.dataSource.length, () => {
169
+ scrollLock.value = false;
170
+ containerStyle.value = {
171
+ height: props.dataSource.length * props.cellHeight + 'px'
172
+ };
173
+ if (props.dataSource.length <= maxLen.value || props.dataSource.length === 0) {
174
+ emit('scrollDown', maxLen.value - props.dataSource.length + 3);
175
+ }
176
+ }, { immediate: true });
177
+ // watch(() => props.height, () => {
178
+ // updateView()
179
+ // })
180
+ onMounted(() => {
181
+ nextTick(() => {
182
+ onScroll();
183
+ });
184
+ });
185
+ onBeforeUnmount(() => {
186
+ _optionalChain([menuInstance, 'optionalAccess', _8 => _8.destroy, 'call', _9 => _9()]);
187
+ _optionalChain([menuInstance, 'optionalAccess', _10 => _10.cleanCopy, 'call', _11 => _11()]);
188
+ });
189
+ __expose({
190
+ scrollTo,
191
+ updateSelectedKeys
192
+ });
193
+ return (_ctx, _cache) => {
194
+ const _component_j_empty = _resolveComponent("j-empty");
195
+ return (_ctx.dataSource.length)
196
+ ? (_openBlock(), _createElementBlock("div", {
197
+ key: 0,
198
+ class: "jetlinks-edit-table-body-viewport",
199
+ style: _normalizeStyle({ ..._ctx.style, height: _ctx.height + 'px' }),
200
+ ref_key: "viewScrollRef",
201
+ ref: viewScrollRef,
202
+ onScroll: onScroll
203
+ }, [
204
+ _createElementVNode("div", _hoisted_1, [
205
+ _createElementVNode("div", {
206
+ class: "jetlinks-edit-scrollbar",
207
+ style: _normalizeStyle(containerStyle.value)
208
+ }, null, 4 /* STYLE */),
209
+ (columnFixedMap.value.left.keys.length)
210
+ ? (_openBlock(), _createElementBlock("div", {
211
+ key: 0,
212
+ class: "jetlinks-edit-table-left",
213
+ style: _normalizeStyle({
214
+ webkitTransform: `translate3d(0, ${virtualRang.start * props.cellHeight}px, 0)`,
215
+ maxWidth: columnFixedMap.value.left.width + 'px',
216
+ minWidth: columnFixedMap.value.left.width + 'px',
217
+ width: columnFixedMap.value.left.width + 'px',
218
+ boxShadow: _unref(tableTool).scrollMap.x ? '0 0 12px 0 rgba(0 ,0, 0, .2)' : ''
219
+ })
220
+ }, [
221
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(virtualData.value, (item, index) => {
222
+ return (_openBlock(), _createElementBlock("div", {
223
+ class: _normalizeClass({
224
+ 'jetlinks-edit-table-row': true,
225
+ 'jetlinks-edit-table-row-selected': _optionalChain([selectedRowKeys, 'access', _12 => _12.value, 'optionalAccess', _13 => _13.includes, 'call', _14 => _14(item[_ctx.rowKey] || virtualRang.start + index + 1)]),
226
+ 'jetlinks-edit-table-row-hover': hoverKeys.value === (item[_ctx.rowKey] || virtualRang.start + index + 1)
227
+ }),
228
+ key: 'left' + index,
229
+ style: _normalizeStyle({ height: `${_ctx.cellHeight}px` }),
230
+ "data-row-key": item[_ctx.rowKey] || virtualRang.start + index + 1,
231
+ onContextmenu: _withModifiers((e) => showContextMenu(e, item, virtualRang.start + index), ["right"]),
232
+ onClick: _withModifiers(() => rowClick(item), ["stop"]),
233
+ onMouseover: $event => (hoverKeys.value = (item[_ctx.rowKey] || virtualRang.start + index + 1)),
234
+ onMouseleave: _cache[0] || (_cache[0] = $event => (hoverKeys.value = undefined))
235
+ }, [
236
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.left.keys, (column) => {
237
+ return (_openBlock(), _createElementBlock("div", {
238
+ class: "jetlinks-edit-table-cell",
239
+ style: _normalizeStyle({
240
+ width: `${column._width}px`,
241
+ })
242
+ }, [
243
+ _createElementVNode("div", _hoisted_3, [
244
+ _renderSlot(_ctx.$slots, column.dataIndex, {
245
+ record: item,
246
+ index: item.__dataIndex,
247
+ column: column
248
+ }, () => [
249
+ _createTextVNode(_toDisplayString(column.dataIndex === '__serial' ? virtualRang.start + index + 1 : item[column.dataIndex]), 1 /* TEXT */)
250
+ ])
251
+ ])
252
+ ], 4 /* STYLE */));
253
+ }), 256 /* UNKEYED_FRAGMENT */))
254
+ ], 46 /* CLASS, STYLE, PROPS, NEED_HYDRATION */, _hoisted_2));
255
+ }), 128 /* KEYED_FRAGMENT */))
256
+ ], 4 /* STYLE */))
257
+ : _createCommentVNode("v-if", true),
258
+ _createElementVNode("div", {
259
+ class: "jetlinks-edit-table-center",
260
+ style: _normalizeStyle({
261
+ webkitTransform: `translate3d(-${_unref(tableTool).scrollMap.x}px, ${virtualRang.start * props.cellHeight}px, 0)`
262
+ })
263
+ }, [
264
+ _createElementVNode("div", {
265
+ style: _normalizeStyle({ width: columnFixedMap.value.center.width + 'px' })
266
+ }, [
267
+ (virtualData.value.length)
268
+ ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(virtualData.value, (item, index) => {
269
+ return (_openBlock(), _createElementBlock("div", {
270
+ class: _normalizeClass({
271
+ 'jetlinks-edit-table-row': true,
272
+ 'jetlinks-edit-table-row-selected': _optionalChain([selectedRowKeys, 'access', _15 => _15.value, 'optionalAccess', _16 => _16.includes, 'call', _17 => _17(item[_ctx.rowKey] || virtualRang.start + index + 1)]),
273
+ 'jetlinks-edit-table-row-hover': hoverKeys.value === (item[_ctx.rowKey] || virtualRang.start + index + 1)
274
+ }),
275
+ key: 'center' + index,
276
+ style: _normalizeStyle({ height: `${_ctx.cellHeight}px`, }),
277
+ "data-row-key": item[_ctx.rowKey] || virtualRang.start + index + 1,
278
+ onContextmenu: _withModifiers((e) => showContextMenu(e, item, virtualRang.start + index), ["right"]),
279
+ onClick: _withModifiers(() => rowClick(item), ["stop"]),
280
+ onMouseover: $event => (hoverKeys.value = (item[_ctx.rowKey] || virtualRang.start + index + 1)),
281
+ onMouseleave: _cache[1] || (_cache[1] = $event => (hoverKeys.value = undefined))
282
+ }, [
283
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.center.keys, (column) => {
284
+ return (_openBlock(), _createElementBlock("div", {
285
+ class: "jetlinks-edit-table-cell",
286
+ style: _normalizeStyle({
287
+ width: `${column._width}px`,
288
+ })
289
+ }, [
290
+ _createElementVNode("div", _hoisted_5, [
291
+ _renderSlot(_ctx.$slots, column.dataIndex, {
292
+ record: item,
293
+ index: item.__dataIndex,
294
+ column: column
295
+ }, () => [
296
+ _createTextVNode(_toDisplayString(column.dataIndex === '__serial' ? virtualRang.start + index + 1 : item[column.dataIndex]), 1 /* TEXT */)
297
+ ])
298
+ ])
299
+ ], 4 /* STYLE */));
300
+ }), 256 /* UNKEYED_FRAGMENT */))
301
+ ], 46 /* CLASS, STYLE, PROPS, NEED_HYDRATION */, _hoisted_4));
302
+ }), 128 /* KEYED_FRAGMENT */))
303
+ : _createCommentVNode("v-if", true)
304
+ ], 4 /* STYLE */)
305
+ ], 4 /* STYLE */),
306
+ (columnFixedMap.value.right.keys.length)
307
+ ? (_openBlock(), _createElementBlock("div", {
308
+ key: 1,
309
+ class: "jetlinks-edit-table-right",
310
+ style: _normalizeStyle({
311
+ webkitTransform: `translate3d(0, ${virtualRang.start * props.cellHeight}px, 0)`,
312
+ maxWidth: columnFixedMap.value.right.width + 'px',
313
+ minWidth: columnFixedMap.value.right.width + 'px',
314
+ width: columnFixedMap.value.right.width + 'px',
315
+ boxShadow: _unref(tableTool).scrollMap.down !== 'right' ? '0 0 12px 0 rgba(0 ,0, 0, .2)' : ''
316
+ })
317
+ }, [
318
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(virtualData.value, (item, index) => {
319
+ return (_openBlock(), _createElementBlock("div", {
320
+ class: _normalizeClass({
321
+ 'jetlinks-edit-table-row': true,
322
+ 'jetlinks-edit-table-row-selected': _optionalChain([selectedRowKeys, 'access', _18 => _18.value, 'optionalAccess', _19 => _19.includes, 'call', _20 => _20(item[_ctx.rowKey] || virtualRang.start + index + 1)]),
323
+ 'jetlinks-edit-table-row-hover': hoverKeys.value === (item[_ctx.rowKey] || virtualRang.start + index + 1)
324
+ }),
325
+ key: 'right' + index,
326
+ style: _normalizeStyle({ height: `${_ctx.cellHeight}px` }),
327
+ "data-row-key": item[_ctx.rowKey] || virtualRang.start + index + 1,
328
+ onContextmenu: _withModifiers((e) => showContextMenu(e, item, virtualRang.start + index), ["right"]),
329
+ onClick: _withModifiers(() => rowClick(item), ["stop"]),
330
+ onMouseover: $event => (hoverKeys.value = (item[_ctx.rowKey] || virtualRang.start + index + 1)),
331
+ onMouseleave: _cache[2] || (_cache[2] = $event => (hoverKeys.value = undefined))
332
+ }, [
333
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.right.keys, (column) => {
334
+ return (_openBlock(), _createElementBlock("div", {
335
+ class: "jetlinks-edit-table-cell",
336
+ style: _normalizeStyle({
337
+ width: `${column._width}px`,
338
+ })
339
+ }, [
340
+ _createElementVNode("div", _hoisted_7, [
341
+ _renderSlot(_ctx.$slots, column.dataIndex, {
342
+ record: item,
343
+ index: item.__dataIndex,
344
+ column: column
345
+ }, () => [
346
+ _createTextVNode(_toDisplayString(column.dataIndex === '__serial' ? virtualRang.start + index + 1 : item[column.dataIndex]), 1 /* TEXT */)
347
+ ])
348
+ ])
349
+ ], 4 /* STYLE */));
350
+ }), 256 /* UNKEYED_FRAGMENT */))
351
+ ], 46 /* CLASS, STYLE, PROPS, NEED_HYDRATION */, _hoisted_6));
352
+ }), 128 /* KEYED_FRAGMENT */))
353
+ ], 4 /* STYLE */))
354
+ : _createCommentVNode("v-if", true)
355
+ ])
356
+ ], 36 /* STYLE, NEED_HYDRATION */))
357
+ : _renderSlot(_ctx.$slots, "empty", { key: 1 }, () => [
358
+ _createElementVNode("div", _hoisted_8, [
359
+ _createVNode(_component_j_empty)
360
+ ])
361
+ ]);
362
+ };
363
+ }
364
+ });
365
+ export default __sfc_main__;