@jetlinks-web/components 2.0.37 → 2.1.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 (74) 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 +368 -0
  9. package/es/EditTable/EditTable.js +412 -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 +214 -0
  24. package/es/EditTable/style/index.js +1 -0
  25. package/es/EditTable/style/index.less +38 -0
  26. package/es/EditTable/style/table.less +42 -0
  27. package/es/EditTable/utils.js +97 -0
  28. package/es/Ellipsis/style/index.js +1 -0
  29. package/es/FullPage/FullPage.js +1 -1
  30. package/es/Search/Advanced/SaveHistory.js +1 -1
  31. package/es/Search/Item.js +1 -1
  32. package/es/Search/Search.js +1 -1
  33. package/es/components.js +3 -1
  34. package/es/style/index.css +287 -0
  35. package/es/style/index.less +9 -7
  36. package/es/style.js +3 -1
  37. package/lib/CardSelect/style/index.js +3 -0
  38. package/lib/CheckButton/style/index.js +3 -0
  39. package/lib/DragModal/DragModal.js +307 -0
  40. package/lib/DragModal/index.js +12 -0
  41. package/lib/DragModal/style/index.css +81 -0
  42. package/lib/DragModal/style/index.js +3 -0
  43. package/lib/DragModal/style/index.less +96 -0
  44. package/lib/EditTable/Body.js +368 -0
  45. package/lib/EditTable/EditTable.js +412 -0
  46. package/lib/EditTable/Header.js +242 -0
  47. package/lib/EditTable/components/ContextMenu/Menu.js +154 -0
  48. package/lib/EditTable/components/ContextMenu/index.js +88 -0
  49. package/lib/EditTable/components/Search/Search.js +290 -0
  50. package/lib/EditTable/components/Search/index.js +13 -0
  51. package/lib/EditTable/consts.js +13 -0
  52. package/lib/EditTable/hooks/index.js +79 -0
  53. package/lib/EditTable/hooks/useResizeObserver.js +38 -0
  54. package/lib/EditTable/hooks/useValidate.js +94 -0
  55. package/lib/EditTable/index.js +16 -0
  56. package/lib/EditTable/props.js +56 -0
  57. package/lib/EditTable/style/body.less +76 -0
  58. package/lib/EditTable/style/header.less +77 -0
  59. package/lib/EditTable/style/index.css +214 -0
  60. package/lib/EditTable/style/index.js +3 -0
  61. package/lib/EditTable/style/index.less +38 -0
  62. package/lib/EditTable/style/table.less +42 -0
  63. package/lib/EditTable/utils.js +104 -0
  64. package/lib/Ellipsis/style/index.js +3 -0
  65. package/lib/FullPage/FullPage.js +1 -1
  66. package/lib/Search/Advanced/SaveHistory.js +1 -1
  67. package/lib/Search/Item.js +1 -1
  68. package/lib/Search/Search.js +1 -1
  69. package/lib/components.js +14 -0
  70. package/lib/style/components.less +2 -0
  71. package/lib/style/index.css +287 -0
  72. package/lib/style/index.less +9 -7
  73. package/lib/style.js +3 -1
  74. package/package.json +3 -1
@@ -0,0 +1,412 @@
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
+ "serial": "props",
19
+ "validateRowKey": "props",
20
+ "FULL_SCREEN": "setup-maybe-ref",
21
+ "RIGHT_MENU": "setup-maybe-ref",
22
+ "TABLE_DATA_SOURCE": "setup-maybe-ref",
23
+ "TABLE_ERROR": "setup-maybe-ref",
24
+ "TABLE_TOOL": "setup-maybe-ref",
25
+ "TABLE_WRAPPER": "setup-maybe-ref",
26
+ "handleColumnsWidth": "setup-maybe-ref",
27
+ "useResizeObserver": "setup-maybe-ref",
28
+ "useValidate": "setup-maybe-ref",
29
+ "useFormContext": "setup-maybe-ref",
30
+ "tableProps": "setup-maybe-ref",
31
+ "Header": "setup-const",
32
+ "Body": "setup-const",
33
+ "useFullscreen": "setup-maybe-ref",
34
+ "provide": "setup-const",
35
+ "useAttrs": "setup-const",
36
+ "useSlots": "setup-const",
37
+ "ref": "setup-const",
38
+ "reactive": "setup-const",
39
+ "defineOptions": "setup-const",
40
+ "bodyProps": "setup-maybe-ref",
41
+ "defaultProps": "setup-maybe-ref",
42
+ "findIndex": "setup-maybe-ref",
43
+ "get": "setup-maybe-ref",
44
+ "sortBy": "setup-maybe-ref",
45
+ "emit": "setup-const",
46
+ "props": "setup-reactive-const",
47
+ "slots": "setup-maybe-ref",
48
+ "attrs": "setup-maybe-ref",
49
+ "myColumns": "setup-ref",
50
+ "tableWrapper": "setup-ref",
51
+ "tableBody": "setup-ref",
52
+ "horizontalScrollRef": "setup-ref",
53
+ "scrollMap": "setup-reactive-const",
54
+ "tableStyle": "setup-reactive-const",
55
+ "fields": "setup-const",
56
+ "fieldsErrMap": "setup-ref",
57
+ "sortData": "setup-reactive-const",
58
+ "_dataSource": "setup-maybe-ref",
59
+ "isFullscreen": "setup-maybe-ref",
60
+ "toggle": "setup-maybe-ref",
61
+ "rules": "setup-maybe-ref",
62
+ "validateItem": "setup-maybe-ref",
63
+ "validate": "setup-maybe-ref",
64
+ "errorMap": "setup-maybe-ref",
65
+ "addField": "setup-const",
66
+ "removeField": "setup-const",
67
+ "findField": "setup-const",
68
+ "removeFieldError": "setup-const",
69
+ "addFieldError": "setup-const",
70
+ "scrollWidth": "setup-maybe-ref",
71
+ "onHorizontalScroll": "setup-const",
72
+ "onResize": "setup-const",
73
+ "onScrollDown": "setup-const",
74
+ "rightMenu": "setup-const",
75
+ "scrollToById": "setup-const",
76
+ "scrollToByIndex": "setup-const",
77
+ "getTableWrapperRef": "setup-const"
78
+ } */
79
+ import { unref as _unref, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeStyle as _normalizeStyle, createVNode as _createVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, withCtx as _withCtx, renderList as _renderList, createSlots as _createSlots, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, normalizeClass as _normalizeClass } from "vue";
80
+ const _hoisted_1 = { class: "jetlinks-edit-table-extra" };
81
+ const _hoisted_2 = { class: "jetlinks-edit-table" };
82
+ const _hoisted_3 = {
83
+ key: 0,
84
+ class: "jetlinks-edit-table-horizontal-scroll"
85
+ };
86
+ import { FULL_SCREEN, RIGHT_MENU, TABLE_DATA_SOURCE, TABLE_ERROR, TABLE_TOOL, TABLE_WRAPPER } from './consts';
87
+ import { handleColumnsWidth } from './utils';
88
+ import { useResizeObserver, useValidate, useFormContext } from './hooks';
89
+ import { tableProps } from 'ant-design-vue/lib/table';
90
+ import Header from './header.js';
91
+ import Body from './body.js';
92
+ import { useFullscreen } from '@vueuse/core';
93
+ import { provide, useAttrs, useSlots, ref, reactive, } from 'vue';
94
+ import { bodyProps, defaultProps } from "./props";
95
+ import { findIndex, get, sortBy } from 'lodash-es';
96
+ const __sfc_main__ = Object.assign({
97
+ name: 'JEditTable'
98
+ }, {
99
+ props: {
100
+ ...tableProps(),
101
+ ...defaultProps(),
102
+ ...bodyProps(),
103
+ serial: {
104
+ type: [Object, Boolean],
105
+ default: () => ({})
106
+ },
107
+ validateRowKey: {
108
+ type: Boolean,
109
+ default: false
110
+ },
111
+ },
112
+ emits: ['scrollDown', 'rightMenuClick', 'editChange', 'searchVisibleChange'],
113
+ setup(__props, { expose: __expose, emit: __emit }) {
114
+ const emit = __emit;
115
+ const props = __props;
116
+ const slots = useSlots();
117
+ const attrs = useAttrs();
118
+ const myColumns = ref([]);
119
+ const tableWrapper = ref();
120
+ const tableBody = ref();
121
+ const horizontalScrollRef = ref();
122
+ const scrollMap = reactive({
123
+ x: 0,
124
+ y: 0,
125
+ down: undefined
126
+ });
127
+ const tableStyle = reactive({
128
+ width: '100%',
129
+ height: props.height
130
+ });
131
+ const fields = {};
132
+ const fieldsErrMap = ref({});
133
+ const sortData = reactive({
134
+ key: undefined,
135
+ order: undefined,
136
+ orderKeys: [],
137
+ dataIndex: undefined
138
+ });
139
+ const _dataSource = computed(() => {
140
+ const sortDataSource = sortData.key ?
141
+ sortBy(props.dataSource, (val) => {
142
+ if (!val.id)
143
+ return 99999999;
144
+ const index = findIndex(sortData.orderKeys, val2 => get(val, sortData.key) === val2);
145
+ return sortData.order === 'desc' ? index : ~index + 1;
146
+ }) : props.dataSource;
147
+ sortDataSource.forEach((item, index) => {
148
+ item.__dataIndex = index;
149
+ item.__serial = index + 1;
150
+ });
151
+ return sortDataSource;
152
+ });
153
+ useResizeObserver(tableWrapper, onResize);
154
+ const { isFullscreen, toggle } = useFullscreen(tableWrapper);
155
+ const { rules, validateItem, validate, errorMap } = useValidate(_dataSource, props.columns, props.rowKey, {
156
+ onError: (err) => {
157
+ fieldsErrMap.value = {};
158
+ const errMap = {};
159
+ // 显示全部err红标
160
+ err.forEach((item, errIndex) => {
161
+ item.forEach((e, eIndex) => {
162
+ const field = findField(e.__dataIndex, e.field);
163
+ const _eventKey = field ? field.eventKey : `${e.__dataIndex}-${e.field}`;
164
+ if (field) {
165
+ field.showErrorTip(e.message);
166
+ }
167
+ errMap[_eventKey] = e.message;
168
+ if (errIndex === 0 && eIndex === 0) {
169
+ setTimeout(() => {
170
+ tableBody.value.scrollTo(e.__serial - 1);
171
+ }, 10);
172
+ }
173
+ });
174
+ });
175
+ fieldsErrMap.value = errMap;
176
+ },
177
+ onSuccess: () => {
178
+ fieldsErrMap.value = {};
179
+ },
180
+ onEdit: () => {
181
+ emit('editChange', true);
182
+ },
183
+ validateRowKey: props.validateRowKey
184
+ });
185
+ provide(TABLE_WRAPPER, tableWrapper);
186
+ provide(FULL_SCREEN, isFullscreen);
187
+ provide(RIGHT_MENU, { click: rightMenu, getPopupContainer: () => tableWrapper.value });
188
+ provide(TABLE_ERROR, fieldsErrMap);
189
+ provide(TABLE_DATA_SOURCE, _dataSource);
190
+ provide(TABLE_TOOL, {
191
+ scrollTo: (record) => {
192
+ setTimeout(() => {
193
+ tableBody.value.scrollTo(record.__serial);
194
+ }, 10);
195
+ },
196
+ selected: (keys) => {
197
+ tableBody.value.updateSelectedKeys(keys);
198
+ },
199
+ order: (type, key, orderKeys, dataIndex) => {
200
+ sortData.key = key;
201
+ sortData.order = type;
202
+ sortData.orderKeys = orderKeys;
203
+ sortData.dataIndex = dataIndex;
204
+ },
205
+ cleanOrder: () => {
206
+ sortData.key = undefined;
207
+ sortData.order = undefined;
208
+ sortData.orderKeys = [];
209
+ sortData.dataIndex = undefined;
210
+ },
211
+ searchVisible: (v) => {
212
+ emit('searchVisibleChange', v);
213
+ },
214
+ scrollMap,
215
+ sortData,
216
+ columns: myColumns
217
+ });
218
+ const addField = (key, field) => {
219
+ fields[key] = field;
220
+ };
221
+ const removeField = (key) => {
222
+ delete fields[key];
223
+ };
224
+ function findField(index, name) {
225
+ const fieldId = Object.keys(fields).find(key => {
226
+ const { names } = fields[key];
227
+ return names[0] === index && names[1] === name;
228
+ });
229
+ return fields[fieldId];
230
+ }
231
+ function removeFieldError(key) {
232
+ delete fieldsErrMap.value[key];
233
+ }
234
+ function addFieldError(key, message) {
235
+ fieldsErrMap.value[key] = message;
236
+ }
237
+ const scrollWidth = computed(() => {
238
+ let _width = 0;
239
+ if (props.dataSource.length * props.cellHeight) {
240
+ _width = 17;
241
+ }
242
+ if (_optionalChain([tableBody, 'access', _2 => _2.value, 'optionalAccess', _3 => _3.getViewScrollRef])) {
243
+ const viewScrollDom = _optionalChain([tableBody, 'access', _4 => _4.value, 'optionalAccess', _5 => _5.getViewScrollRef, 'call', _6 => _6()]);
244
+ const bodyContainer = viewScrollDom.querySelector('.jetlinks-edit-table-body-container');
245
+ _width = viewScrollDom.offsetWidth - bodyContainer.offsetWidth;
246
+ }
247
+ return _width;
248
+ });
249
+ const onHorizontalScroll = () => {
250
+ if (!horizontalScrollRef.value)
251
+ return;
252
+ const { clientWidth, scrollLeft, scrollWidth } = horizontalScrollRef.value;
253
+ scrollMap.x = scrollLeft;
254
+ if (clientWidth + scrollLeft >= scrollWidth) {
255
+ scrollMap.down = 'right';
256
+ }
257
+ else if (scrollLeft === 0) {
258
+ scrollMap.down = undefined;
259
+ }
260
+ else {
261
+ scrollMap.down = 'left';
262
+ }
263
+ };
264
+ function onResize({ width = 0, height }) {
265
+ const _width = width - scrollWidth.value;
266
+ tableStyle.width = width || '100%';
267
+ let newColumns = [...props.columns];
268
+ if (props.serial) {
269
+ const options = Object.assign({
270
+ title: '序号',
271
+ width: 66,
272
+ fixed: 'left'
273
+ }, props.serial);
274
+ const serial = {
275
+ dataIndex: '__serial',
276
+ title: options.title,
277
+ customRender: (customData) => {
278
+ if (_optionalChain([props, 'access', _7 => _7.serial, 'optionalAccess', _8 => _8.customRender])) {
279
+ return _optionalChain([props, 'access', _9 => _9.serial, 'optionalAccess', _10 => _10.customRender, 'call', _11 => _11(customData)]);
280
+ }
281
+ return customData.index + 1;
282
+ },
283
+ width: options.width,
284
+ fixed: options.fixed
285
+ };
286
+ newColumns = [serial, ...props.columns];
287
+ }
288
+ myColumns.value = handleColumnsWidth(newColumns, _width, _optionalChain([props, 'access', _12 => _12.scroll, 'optionalAccess', _13 => _13.x]));
289
+ }
290
+ const onScrollDown = (len) => {
291
+ emit('scrollDown', len);
292
+ };
293
+ function rightMenu(menuType, record, copyValue) {
294
+ emit('rightMenuClick', menuType, record, copyValue);
295
+ }
296
+ const scrollToById = (key) => {
297
+ const _index = _dataSource.value.findIndex(item => item[props.rowKey] === key);
298
+ tableBody.value.scrollTo(_index);
299
+ };
300
+ const scrollToByIndex = (index) => {
301
+ tableBody.value.scrollTo(index);
302
+ };
303
+ const getTableWrapperRef = () => {
304
+ return tableWrapper.value;
305
+ };
306
+ watch(() => scrollWidth.value, () => {
307
+ onResize({ width: tableStyle.width });
308
+ });
309
+ useFormContext({
310
+ dataSource: computed(() => {
311
+ return props.dataSource;
312
+ }),
313
+ errorMap,
314
+ rules,
315
+ addField,
316
+ removeField,
317
+ removeFieldError,
318
+ addFieldError,
319
+ validateItem
320
+ });
321
+ __expose({
322
+ validate,
323
+ tableWrapper,
324
+ scrollToById,
325
+ scrollToByIndex,
326
+ getTableWrapperRef,
327
+ });
328
+ return (_ctx, _cache) => {
329
+ return (_openBlock(), _createElementBlock("div", {
330
+ class: _normalizeClass({
331
+ 'jetlinks-edit-table-wrapper': true,
332
+ 'table-full-screen': _unref(isFullscreen)
333
+ }),
334
+ ref_key: "tableWrapper",
335
+ ref: tableWrapper
336
+ }, [
337
+ _createElementVNode("div", _hoisted_1, [
338
+ _renderSlot(_ctx.$slots, "extra", {
339
+ isFullscreen: _unref(isFullscreen),
340
+ fullScreenToggle: _unref(toggle)
341
+ })
342
+ ]),
343
+ _createElementVNode("div", _hoisted_2, [
344
+ _createElementVNode("div", {
345
+ class: "jetlinks-edit-table-header",
346
+ style: _normalizeStyle([{ "height": "50px" }, { paddingRight: _unref(scrollWidth) + 'px' }])
347
+ }, [
348
+ _createVNode(Header, {
349
+ columns: myColumns.value,
350
+ style: _normalizeStyle({ width: tableStyle.width }),
351
+ rowKey: _ctx.rowKey
352
+ }, null, 8 /* PROPS */, ["columns", "style", "rowKey"]),
353
+ _createElementVNode("div", {
354
+ class: "jetlinks-edit-table-header-scroll-hidden",
355
+ style: _normalizeStyle({ width: _unref(scrollWidth) + 'px' })
356
+ }, null, 4 /* STYLE */)
357
+ ], 4 /* STYLE */),
358
+ _createElementVNode("div", {
359
+ class: "jetlinks-edit-table-body",
360
+ style: _normalizeStyle({ width: tableStyle.width, height: `${_ctx.height}px` })
361
+ }, [
362
+ _createVNode(Body, {
363
+ ref_key: "tableBody",
364
+ ref: tableBody,
365
+ dataSource: _unref(_dataSource),
366
+ columns: myColumns.value,
367
+ cellHeight: _ctx.cellHeight,
368
+ height: _ctx.height,
369
+ disableMenu: _ctx.disableMenu,
370
+ rowKey: _ctx.rowKey,
371
+ rowSelection: _ctx.rowSelection,
372
+ onScrollDown: onScrollDown
373
+ }, _createSlots({ _: 2 /* DYNAMIC */ }, [
374
+ _renderList(_unref(slots), (_, name) => {
375
+ return {
376
+ name: name,
377
+ fn: _withCtx((slotData) => [
378
+ _renderSlot(_ctx.$slots, name, _normalizeProps(_guardReactiveProps(slotData || {})))
379
+ ])
380
+ };
381
+ })
382
+ ]), 1032 /* PROPS, DYNAMIC_SLOTS */, ["dataSource", "columns", "cellHeight", "height", "disableMenu", "rowKey", "rowSelection"]),
383
+ _renderSlot(_ctx.$slots, "bodyExtra")
384
+ ], 4 /* STYLE */),
385
+ (_optionalChain([_ctx, 'access', _14 => _14.scroll, 'optionalAccess', _15 => _15.x]))
386
+ ? (_openBlock(), _createElementBlock("div", _hoisted_3, [
387
+ _createElementVNode("div", {
388
+ class: "jetlinks-edit-table-horizontal-scroll-viewport",
389
+ ref_key: "horizontalScrollRef",
390
+ ref: horizontalScrollRef,
391
+ onScroll: onHorizontalScroll
392
+ }, [
393
+ _createElementVNode("div", {
394
+ style: _normalizeStyle({
395
+ width: _ctx.scroll.x + 'px',
396
+ minWidth: _ctx.scroll.x + 'px',
397
+ maxWidth: _ctx.scroll.x + 'px'
398
+ })
399
+ }, null, 4 /* STYLE */)
400
+ ], 544 /* NEED_HYDRATION, NEED_PATCH */),
401
+ _createElementVNode("div", {
402
+ class: "jetlinks-edit-table-horizontal-scroll-hidden",
403
+ style: _normalizeStyle({ width: _unref(scrollWidth) + 'px' })
404
+ }, null, 4 /* STYLE */)
405
+ ]))
406
+ : _createCommentVNode("v-if", true)
407
+ ])
408
+ ], 2 /* CLASS */));
409
+ };
410
+ }
411
+ });
412
+ export default __sfc_main__;
@@ -0,0 +1,242 @@
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
+ "serial": "props",
19
+ "style": "props",
20
+ "SearchModal": "setup-maybe-ref",
21
+ "reactive": "setup-const",
22
+ "defineOptions": "setup-const",
23
+ "computed": "setup-const",
24
+ "defaultProps": "setup-maybe-ref",
25
+ "handleColumnFixed": "setup-maybe-ref",
26
+ "useTableTool": "setup-maybe-ref",
27
+ "props": "setup-reactive-const",
28
+ "tableTool": "setup-maybe-ref",
29
+ "columnFixedMap": "setup-ref",
30
+ "searchData": "setup-reactive-const",
31
+ "showFilter": "setup-const"
32
+ } */
33
+ import { unref as _unref, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, createCommentVNode as _createCommentVNode, resolveComponent as _resolveComponent, createBlock as _createBlock, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle } from "vue";
34
+ const _hoisted_1 = ["id"];
35
+ const _hoisted_2 = { class: "table-header-cell-title" };
36
+ const _hoisted_3 = {
37
+ key: 0,
38
+ class: "header-cell-required"
39
+ };
40
+ const _hoisted_4 = {
41
+ key: 0,
42
+ class: "table-header-cell-trigger"
43
+ };
44
+ const _hoisted_5 = ["id"];
45
+ const _hoisted_6 = { class: "table-header-cell-title" };
46
+ const _hoisted_7 = {
47
+ key: 0,
48
+ class: "header-cell-required"
49
+ };
50
+ const _hoisted_8 = {
51
+ key: 0,
52
+ class: "table-header-cell-trigger"
53
+ };
54
+ const _hoisted_9 = ["id"];
55
+ const _hoisted_10 = { class: "table-header-cell-title" };
56
+ const _hoisted_11 = {
57
+ key: 0,
58
+ class: "header-cell-required"
59
+ };
60
+ const _hoisted_12 = {
61
+ key: 0,
62
+ class: "table-header-cell-trigger"
63
+ };
64
+ import { Search as SearchModal } from './components/Search';
65
+ import { reactive, computed } from 'vue';
66
+ import { defaultProps } from "./props";
67
+ import { handleColumnFixed } from "./utils";
68
+ import { useTableTool } from "./hooks";
69
+ const __sfc_main__ = Object.assign({
70
+ name: 'JEditTableHeader'
71
+ }, {
72
+ props: {
73
+ ...defaultProps(),
74
+ serial: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+ style: {
79
+ type: Object,
80
+ default: undefined
81
+ }
82
+ },
83
+ setup(__props) {
84
+ const props = __props;
85
+ const tableTool = useTableTool();
86
+ const columnFixedMap = computed(() => {
87
+ return handleColumnFixed(props.columns);
88
+ });
89
+ const searchData = reactive({
90
+ visible: false,
91
+ key: undefined
92
+ });
93
+ const showFilter = (key) => {
94
+ searchData.visible = true;
95
+ searchData.key = key;
96
+ };
97
+ return (_ctx, _cache) => {
98
+ const _component_AIcon = _resolveComponent("AIcon");
99
+ return (_openBlock(), _createElementBlock(_Fragment, null, [
100
+ _createElementVNode("div", {
101
+ class: "jetlinks-edit-table-header-container",
102
+ style: _normalizeStyle(__props.style)
103
+ }, [
104
+ (columnFixedMap.value.left.keys.length)
105
+ ? (_openBlock(), _createElementBlock("div", {
106
+ key: 0,
107
+ class: "jetlinks-header-left",
108
+ style: _normalizeStyle({
109
+ maxWidth: columnFixedMap.value.left.width + 'px',
110
+ minWidth: columnFixedMap.value.left.width + 'px',
111
+ width: columnFixedMap.value.left.width + 'px',
112
+ boxShadow: _unref(tableTool).scrollMap.x ? '0 0 12px 0 rgba(0 ,0, 0, .2)' : ''
113
+ })
114
+ }, [
115
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.left.keys, (item, index) => {
116
+ return (_openBlock(), _createElementBlock("div", {
117
+ class: "jetlinks-edit-table-header-cell",
118
+ id: item.dataIndex,
119
+ style: _normalizeStyle({ width: `${item._width}px` })
120
+ }, [
121
+ _createElementVNode("div", {
122
+ class: _normalizeClass({ 'jetlinks-edit-table-header-cell-box': true, 'header-cell-box-tool': !!(item.sort || item.filter) })
123
+ }, [
124
+ _createElementVNode("div", _hoisted_2, [
125
+ _createElementVNode("span", null, _toDisplayString(item.title), 1 /* TEXT */),
126
+ (_optionalChain([item, 'access', _ => _.form, 'optionalAccess', _2 => _2.required]))
127
+ ? (_openBlock(), _createElementBlock("span", _hoisted_3, "*"))
128
+ : _createCommentVNode("v-if", true)
129
+ ]),
130
+ (!!(item.filter))
131
+ ? (_openBlock(), _createElementBlock("div", _hoisted_4, [
132
+ (item.filter)
133
+ ? (_openBlock(), _createBlock(_component_AIcon, {
134
+ key: 0,
135
+ type: "SearchOutlined",
136
+ style: { "color": "rgba(0,0,0, 0.25)" },
137
+ onClick: () => { showFilter(item.filter.key || item.dataIndex); }
138
+ }, null, 8 /* PROPS */, ["onClick"]))
139
+ : _createCommentVNode("v-if", true)
140
+ ]))
141
+ : _createCommentVNode("v-if", true)
142
+ ], 2 /* CLASS */)
143
+ ], 12 /* STYLE, PROPS */, _hoisted_1));
144
+ }), 256 /* UNKEYED_FRAGMENT */))
145
+ ], 4 /* STYLE */))
146
+ : _createCommentVNode("v-if", true),
147
+ _createElementVNode("div", {
148
+ class: "jetlinks-header-center",
149
+ style: _normalizeStyle({ webkitTransform: `translate3d(-${_unref(tableTool).scrollMap.x}px, 0, 0)` })
150
+ }, [
151
+ _createElementVNode("div", {
152
+ style: _normalizeStyle({ width: columnFixedMap.value.center.width + 'px' })
153
+ }, [
154
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.center.keys, (item, index) => {
155
+ return (_openBlock(), _createElementBlock("div", {
156
+ class: "jetlinks-edit-table-header-cell",
157
+ id: item.dataIndex,
158
+ style: _normalizeStyle({ width: `${item._width}px` })
159
+ }, [
160
+ _createElementVNode("div", {
161
+ class: _normalizeClass({ 'jetlinks-edit-table-header-cell-box': true, 'header-cell-box-tool': !!(item.sort || item.filter) })
162
+ }, [
163
+ _createElementVNode("div", _hoisted_6, [
164
+ _createElementVNode("span", null, _toDisplayString(item.title), 1 /* TEXT */),
165
+ (_optionalChain([item, 'access', _3 => _3.form, 'optionalAccess', _4 => _4.required]))
166
+ ? (_openBlock(), _createElementBlock("span", _hoisted_7, "*"))
167
+ : _createCommentVNode("v-if", true)
168
+ ]),
169
+ (!!(item.filter))
170
+ ? (_openBlock(), _createElementBlock("div", _hoisted_8, [
171
+ (item.filter)
172
+ ? (_openBlock(), _createBlock(_component_AIcon, {
173
+ key: 0,
174
+ type: "SearchOutlined",
175
+ style: { "color": "rgba(0,0,0, 0.25)" },
176
+ onClick: () => { showFilter(item.filter.key || item.dataIndex); }
177
+ }, null, 8 /* PROPS */, ["onClick"]))
178
+ : _createCommentVNode("v-if", true)
179
+ ]))
180
+ : _createCommentVNode("v-if", true)
181
+ ], 2 /* CLASS */)
182
+ ], 12 /* STYLE, PROPS */, _hoisted_5));
183
+ }), 256 /* UNKEYED_FRAGMENT */))
184
+ ], 4 /* STYLE */)
185
+ ], 4 /* STYLE */),
186
+ (columnFixedMap.value.right.keys.length)
187
+ ? (_openBlock(), _createElementBlock("div", {
188
+ key: 1,
189
+ class: "jetlinks-header-right",
190
+ style: _normalizeStyle({
191
+ maxWidth: columnFixedMap.value.right.width + 'px',
192
+ minWidth: columnFixedMap.value.right.width + 'px',
193
+ width: columnFixedMap.value.right.width + 'px',
194
+ boxShadow: _unref(tableTool).scrollMap.down !== 'right' ? '0 0 12px 0 rgba(0 ,0, 0, .2)' : ''
195
+ })
196
+ }, [
197
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(columnFixedMap.value.right.keys, (item, index) => {
198
+ return (_openBlock(), _createElementBlock("div", {
199
+ class: "jetlinks-edit-table-header-cell",
200
+ id: item.dataIndex,
201
+ style: _normalizeStyle({ width: `${item._width}px` })
202
+ }, [
203
+ _createElementVNode("div", {
204
+ class: _normalizeClass({ 'jetlinks-edit-table-header-cell-box': true, 'header-cell-box-tool': !!(item.sort || item.filter) })
205
+ }, [
206
+ _createElementVNode("div", _hoisted_10, [
207
+ _createElementVNode("span", null, _toDisplayString(item.title), 1 /* TEXT */),
208
+ (_optionalChain([item, 'access', _5 => _5.form, 'optionalAccess', _6 => _6.required]))
209
+ ? (_openBlock(), _createElementBlock("span", _hoisted_11, "*"))
210
+ : _createCommentVNode("v-if", true)
211
+ ]),
212
+ (!!(item.filter))
213
+ ? (_openBlock(), _createElementBlock("div", _hoisted_12, [
214
+ (item.filter)
215
+ ? (_openBlock(), _createBlock(_component_AIcon, {
216
+ key: 0,
217
+ type: "SearchOutlined",
218
+ style: { "color": "rgba(0,0,0, 0.25)" },
219
+ onClick: () => { showFilter(item.filter.key || item.dataIndex); }
220
+ }, null, 8 /* PROPS */, ["onClick"]))
221
+ : _createCommentVNode("v-if", true)
222
+ ]))
223
+ : _createCommentVNode("v-if", true)
224
+ ], 2 /* CLASS */)
225
+ ], 12 /* STYLE, PROPS */, _hoisted_9));
226
+ }), 256 /* UNKEYED_FRAGMENT */))
227
+ ], 4 /* STYLE */))
228
+ : _createCommentVNode("v-if", true)
229
+ ], 4 /* STYLE */),
230
+ (searchData.visible)
231
+ ? (_openBlock(), _createBlock(_unref(SearchModal), {
232
+ key: 0,
233
+ searchKey: searchData.key,
234
+ rowKey: _ctx.rowKey,
235
+ onClose: _cache[0] || (_cache[0] = $event => (searchData.visible = false))
236
+ }, null, 8 /* PROPS */, ["searchKey", "rowKey"]))
237
+ : _createCommentVNode("v-if", true)
238
+ ], 64 /* STABLE_FRAGMENT */));
239
+ };
240
+ }
241
+ });
242
+ export default __sfc_main__;