evui 3.2.1 → 3.3.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evui",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -105,13 +105,20 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
105
105
  }
106
106
  });
107
107
 
108
- const redrawChart = () => {
109
- if (evChart && 'resize' in evChart && isInit) {
110
- evChart.resize();
108
+ const redraw = () => {
109
+ if (evChart && isInit) {
110
+ evChart.update({
111
+ updateSeries: true,
112
+ updateSelTip: { update: true, keepDomain: false },
113
+ });
111
114
  }
112
115
  };
113
116
 
114
- const onResize = debounce(redrawChart, props.resizeTimeout);
117
+ const onResize = debounce(() => {
118
+ if (evChart && 'resize' in evChart && isInit) {
119
+ evChart.resize();
120
+ }
121
+ }, props.resizeTimeout);
115
122
 
116
123
  const selectItemByLabel = (label) => {
117
124
  evChart.selectItemByLabel(label);
@@ -121,6 +128,7 @@ import { onMounted, onBeforeUnmount, watch, onDeactivated } from 'vue';
121
128
  wrapper,
122
129
  wrapperStyle,
123
130
  onResize,
131
+ redraw,
124
132
  selectItemByLabel,
125
133
  };
126
134
  },
@@ -48,7 +48,9 @@ const modules = {
48
48
  this.overlayClear();
49
49
 
50
50
  if (Object.keys(hitInfo.items).length) {
51
- this.drawItemsHighlight(hitInfo, ctx);
51
+ if (this.options.type !== 'scatter' || tooltip.use) {
52
+ this.drawItemsHighlight(hitInfo, ctx);
53
+ }
52
54
 
53
55
  if (tooltip.use) {
54
56
  this.setTooltipLayoutPosition(hitInfo, e);
@@ -95,7 +97,7 @@ const modules = {
95
97
  */
96
98
  this.onDblClick = (e) => {
97
99
  const selectItem = this.options.selectItem;
98
- const args = {};
100
+ const args = { e };
99
101
 
100
102
  if (selectItem.use) {
101
103
  const offset = this.getMousePosition(e);
@@ -120,8 +122,7 @@ const modules = {
120
122
  * @returns {undefined}
121
123
  */
122
124
  this.onClick = (e) => {
123
- const args = {};
124
-
125
+ const args = { e };
125
126
  if (this.options.selectItem.use) {
126
127
  const offset = this.getMousePosition(e);
127
128
  const hitInfo = this.findClickedData(offset);
@@ -134,7 +135,9 @@ const modules = {
134
135
  }
135
136
 
136
137
  if (typeof this.listeners.click === 'function') {
137
- this.listeners.click(args);
138
+ if (!this.dragInfoBackup) {
139
+ this.listeners.click(args);
140
+ }
138
141
  }
139
142
  };
140
143
 
@@ -254,11 +257,12 @@ const modules = {
254
257
  *
255
258
  * @returns {undefined}
256
259
  */
257
- const dragEnd = () => {
260
+ const dragEnd = (e) => {
258
261
  const dragInfo = this.dragInfo;
259
262
 
260
- if (dragInfo?.isMove) {
263
+ if (dragInfo?.isMove && dragInfo?.width > 1 && dragInfo?.height > 1) {
261
264
  const args = {
265
+ e,
262
266
  data: this.findSelectedItems(dragInfo),
263
267
  range: this.getSelectionRage(dragInfo),
264
268
  };
@@ -577,10 +581,10 @@ const modules = {
577
581
  const yMax = dataRangeY.graphMin + graphHeight * (1 - yMaxRatio);
578
582
 
579
583
  return {
580
- xMin: +parseFloat(xMin).toFixed(3),
581
- xMax: +parseFloat(xMax).toFixed(3),
582
- yMin: +parseFloat(yMin).toFixed(3),
583
- yMax: +parseFloat(yMax).toFixed(3),
584
+ xMin: Math.max(+parseFloat(xMin).toFixed(3), dataRangeX.graphMin),
585
+ xMax: Math.min(+parseFloat(xMax).toFixed(3), dataRangeX.graphMax),
586
+ yMin: Math.max(+parseFloat(yMin).toFixed(3), dataRangeY.graphMin),
587
+ yMax: Math.min(+parseFloat(yMax).toFixed(3), dataRangeY.graphMax),
584
588
  };
585
589
  },
586
590
 
@@ -9,12 +9,15 @@ const modules = {
9
9
  this.legendDOM.className = 'ev-chart-legend';
10
10
  this.legendBoxDOM = document.createElement('div');
11
11
  this.legendBoxDOM.className = 'ev-chart-legend-box';
12
- this.resizeDOM = document.createElement('div');
13
- this.resizeDOM.className = 'ev-chart-resize-bar';
14
- this.ghostDOM = document.createElement('div');
15
- this.ghostDOM.className = 'ev-chart-resize-ghost';
16
12
 
17
- this.wrapperDOM.appendChild(this.resizeDOM);
13
+ if (this.options?.legend?.allowResize) {
14
+ this.resizeDOM = document.createElement('div');
15
+ this.resizeDOM.className = 'ev-chart-resize-bar';
16
+ this.ghostDOM = document.createElement('div');
17
+ this.ghostDOM.className = 'ev-chart-resize-ghost';
18
+ this.wrapperDOM.appendChild(this.resizeDOM);
19
+ }
20
+
18
21
  this.legendDOM.appendChild(this.legendBoxDOM);
19
22
  this.wrapperDOM.appendChild(this.legendDOM);
20
23
  },
@@ -212,10 +215,12 @@ const modules = {
212
215
  this.legendBoxDOM.addEventListener('click', this.onLegendBoxClick);
213
216
  this.legendBoxDOM.addEventListener('mouseover', this.onLegendBoxOver);
214
217
  this.legendBoxDOM.addEventListener('mouseleave', this.onLegendBoxLeave);
215
- this.resizeDOM.addEventListener('mousedown', this.onResizeMouseDown);
216
218
 
217
- this.mouseMove = this.onMouseMove.bind(this); // resizing function
218
- this.mouseUp = this.onMouseUp.bind(this); // resizing function
219
+ if (this.resizeDOM) {
220
+ this.resizeDOM.addEventListener('mousedown', this.onResizeMouseDown);
221
+ this.mouseMove = this.onMouseMove.bind(this); // resizing function
222
+ this.mouseUp = this.onMouseUp.bind(this); // resizing function
223
+ }
219
224
  },
220
225
 
221
226
  /**
@@ -338,14 +343,16 @@ const modules = {
338
343
  legendStyle.width = `${chartRect.width}px`;
339
344
  legendStyle.height = `${opt.legend.height + 4}px`; // 4 resize bar size
340
345
 
341
- resizeStyle.top = `${positionTop}px`;
342
- resizeStyle.right = '';
343
- resizeStyle.bottom = '';
344
- resizeStyle.left = '';
346
+ if (resizeStyle) {
347
+ resizeStyle.top = `${positionTop}px`;
348
+ resizeStyle.right = '';
349
+ resizeStyle.bottom = '';
350
+ resizeStyle.left = '';
345
351
 
346
- resizeStyle.width = `${chartRect.width}px`;
347
- resizeStyle.height = '4px';
348
- resizeStyle.cursor = 'row-resize';
352
+ resizeStyle.width = `${chartRect.width}px`;
353
+ resizeStyle.height = '4px';
354
+ resizeStyle.cursor = 'row-resize';
355
+ }
349
356
  break;
350
357
  case 'right':
351
358
  wrapperStyle.padding = `${title}px ${opt.legend.width}px 0 0`;
@@ -363,14 +370,16 @@ const modules = {
363
370
  legendStyle.width = `${opt.legend.width}px`;
364
371
  legendStyle.height = `${chartRect.height}px`;
365
372
 
366
- resizeStyle.top = `${title}px`;
367
- resizeStyle.right = `${opt.legend.width}px`;
368
- resizeStyle.bottom = '';
369
- resizeStyle.left = '';
373
+ if (resizeStyle) {
374
+ resizeStyle.top = `${title}px`;
375
+ resizeStyle.right = `${opt.legend.width}px`;
376
+ resizeStyle.bottom = '';
377
+ resizeStyle.left = '';
370
378
 
371
- resizeStyle.width = '4px';
372
- resizeStyle.height = `${chartRect.height}px`;
373
- resizeStyle.cursor = 'col-resize';
379
+ resizeStyle.width = '4px';
380
+ resizeStyle.height = `${chartRect.height}px`;
381
+ resizeStyle.cursor = 'col-resize';
382
+ }
374
383
  break;
375
384
  case 'bottom':
376
385
  wrapperStyle.padding = `${title}px 0 ${opt.legend.height}px 0`;
@@ -387,14 +396,16 @@ const modules = {
387
396
  legendStyle.width = `${chartRect.width}px`;
388
397
  legendStyle.height = `${opt.legend.height + 4}px`; // 4 resize bar size
389
398
 
390
- resizeStyle.top = '';
391
- resizeStyle.right = '';
392
- resizeStyle.bottom = `${opt.legend.height}px`;
393
- resizeStyle.left = '';
399
+ if (resizeStyle) {
400
+ resizeStyle.top = '';
401
+ resizeStyle.right = '';
402
+ resizeStyle.bottom = `${opt.legend.height}px`;
403
+ resizeStyle.left = '';
394
404
 
395
- resizeStyle.width = `${chartRect.width}px`;
396
- resizeStyle.height = '4px';
397
- resizeStyle.cursor = 'row-resize';
405
+ resizeStyle.width = `${chartRect.width}px`;
406
+ resizeStyle.height = '4px';
407
+ resizeStyle.cursor = 'row-resize';
408
+ }
398
409
  break;
399
410
  case 'left':
400
411
  wrapperStyle.padding = `${title}px 0 0 ${opt.legend.width}px`;
@@ -413,14 +424,16 @@ const modules = {
413
424
  legendStyle.width = `${opt.legend.width}px`;
414
425
  legendStyle.height = `${chartRect.height}px`;
415
426
 
416
- resizeStyle.top = `${title}px`;
417
- resizeStyle.right = '';
418
- resizeStyle.bottom = '';
419
- resizeStyle.left = `${opt.legend.width}px`;
427
+ if (resizeStyle) {
428
+ resizeStyle.top = `${title}px`;
429
+ resizeStyle.right = '';
430
+ resizeStyle.bottom = '';
431
+ resizeStyle.left = `${opt.legend.width}px`;
420
432
 
421
- resizeStyle.width = '4px';
422
- resizeStyle.height = `${chartRect.height}px`;
423
- resizeStyle.cursor = 'col-resize';
433
+ resizeStyle.width = '4px';
434
+ resizeStyle.height = `${chartRect.height}px`;
435
+ resizeStyle.cursor = 'col-resize';
436
+ }
424
437
  break;
425
438
  default:
426
439
  break;
@@ -599,12 +612,13 @@ const modules = {
599
612
  * @returns {undefined}
600
613
  */
601
614
  showLegend() {
602
- if (!this.resizeDOM || !this.legendDOM) {
603
- return;
615
+ if (this.resizeDOM) {
616
+ this.resizeDOM.style.display = 'block';
604
617
  }
605
618
 
606
- this.resizeDOM.style.display = 'block';
607
- this.legendDOM.style.display = 'block';
619
+ if (this.legendDOM) {
620
+ this.legendDOM.style.display = 'block';
621
+ }
608
622
  },
609
623
 
610
624
  /**
@@ -619,13 +633,15 @@ const modules = {
619
633
  const legendStyle = this.legendDOM?.style;
620
634
  const title = opt?.title?.show ? opt?.title?.height : 0;
621
635
 
622
- if (!resizeStyle || !legendStyle || !wrapperStyle) {
636
+ if (!legendStyle || !wrapperStyle) {
623
637
  return;
624
638
  }
625
639
 
626
- resizeStyle.display = 'none';
627
- legendStyle.display = 'none';
640
+ if (resizeStyle) {
641
+ resizeStyle.display = 'none';
642
+ }
628
643
 
644
+ legendStyle.display = 'none';
629
645
  legendStyle.width = '0';
630
646
  legendStyle.height = '0';
631
647
  wrapperStyle.padding = `${title}px 0 0 0`;
@@ -27,6 +27,7 @@ const DEFAULT_OPTIONS = {
27
27
  inactive: '#aaa',
28
28
  width: 140,
29
29
  height: 24,
30
+ allowResize: false,
30
31
  },
31
32
  itemHighlight: true,
32
33
  seriesHighlight: true,
@@ -99,11 +100,13 @@ export const useModel = () => {
99
100
  const { emit } = getCurrentInstance();
100
101
 
101
102
  const getNormalizedOptions = (options) => {
102
- if (options.type === 'scatter') {
103
- DEFAULT_OPTIONS.tooltip.use = false;
103
+ const normalizedOptions = defaultsDeep({}, options, DEFAULT_OPTIONS);
104
+
105
+ if (options.type === 'scatter' && !options?.tooltip) {
106
+ normalizedOptions.tooltip.use = false;
104
107
  }
105
108
 
106
- return defaultsDeep({}, options, DEFAULT_OPTIONS);
109
+ return normalizedOptions;
107
110
  };
108
111
  const getNormalizedData = data => defaultsDeep(data, DEFAULT_DATA);
109
112
 
@@ -341,7 +341,7 @@ export default {
341
341
  items: [],
342
342
  },
343
343
  isSearch: false,
344
- searchWord: '',
344
+ searchValue: computed(() => (props.option.searchValue || '')),
345
345
  });
346
346
  const stores = reactive({
347
347
  viewStore: [],
@@ -512,7 +512,7 @@ export default {
512
512
  (value) => {
513
513
  setStore(value);
514
514
  if (filterInfo.isSearch) {
515
- onSearch(filterInfo.searchWord);
515
+ onSearch(filterInfo.searchValue);
516
516
  }
517
517
  },
518
518
  );
@@ -522,17 +522,15 @@ export default {
522
522
  checkInfo.checkedRows = checkedList;
523
523
  checkInfo.isHeaderChecked = false;
524
524
  checkInfo.checkedIndex.clear();
525
- if (checkedList.length) {
526
- const store = stores.store;
525
+ const store = stores.store;
526
+ if (store.length) {
527
527
  store.forEach((row) => {
528
528
  row[ROW_CHECK_INDEX] = checkedList.includes(row[ROW_DATA_INDEX]);
529
529
  if (row[ROW_CHECK_INDEX]) {
530
530
  checkInfo.checkedIndex.add(row[ROW_INDEX]);
531
531
  }
532
532
  });
533
- if (checkedList.length === store.length) {
534
- checkInfo.isHeaderChecked = true;
535
- }
533
+ checkInfo.isHeaderChecked = checkedList.length === store.length;
536
534
  }
537
535
  updateVScroll();
538
536
  },
@@ -583,6 +581,12 @@ export default {
583
581
  setStore([], false);
584
582
  },
585
583
  );
584
+ watch(
585
+ () => filterInfo.searchValue,
586
+ (value) => {
587
+ onSearch(value?.value ?? value);
588
+ }, { immediate: true },
589
+ );
586
590
  const isFilterButton = field => filterInfo.isFiltering && field !== 'db-icon' && field !== 'user-icon';
587
591
  return {
588
592
  showHeader,
@@ -710,7 +710,6 @@ export const filterEvent = (params) => {
710
710
  }
711
711
  timer = setTimeout(() => {
712
712
  filterInfo.isSearch = false;
713
- filterInfo.searchWord = searchWord;
714
713
  if (searchWord) {
715
714
  stores.searchStore = stores.store.filter((row) => {
716
715
  let isShow = false;
@@ -242,6 +242,7 @@ export default {
242
242
  resizeLine: null,
243
243
  'grid-wrapper': null,
244
244
  });
245
+ const searchValue = computed(() => (props.option.searchValue || ''));
245
246
  const stores = reactive({
246
247
  treeStore: [],
247
248
  viewStore: [],
@@ -341,18 +342,20 @@ export default {
341
342
  });
342
343
  watch(
343
344
  () => props.checked,
344
- (value) => {
345
+ (checkedList) => {
345
346
  let store = stores.treeStore;
346
347
  if (stores.searchStore.length > 0) {
347
348
  store = stores.searchStore;
348
349
  }
349
- const isCheck = store.every(n => n.checked === true);
350
+ checkInfo.checkedRows = checkedList;
350
351
  checkInfo.isHeaderChecked = false;
351
- checkInfo.checkedRows = value;
352
- for (let ix = 0; ix < store.length; ix++) {
353
- store[ix].checked = value.includes(store[ix]);
352
+ if (store.length) {
353
+ store.forEach((row) => {
354
+ row.checked = checkedList.includes(row);
355
+ });
356
+ checkInfo.isHeaderChecked = store.every(n => n.checked === true);
354
357
  }
355
- checkInfo.isHeaderChecked = isCheck;
358
+ updateVScroll();
356
359
  },
357
360
  );
358
361
  watch(
@@ -394,6 +397,12 @@ export default {
394
397
  onResize();
395
398
  },
396
399
  );
400
+ watch(
401
+ () => searchValue.value,
402
+ (value) => {
403
+ onSearch(value?.value ?? value);
404
+ }, { immediate: true },
405
+ );
397
406
  const gridStyle = computed(() => ({
398
407
  width: resizeInfo.gridWidth,
399
408
  height: resizeInfo.gridHeight,
@@ -655,10 +655,27 @@ export const filterEvent = (params) => {
655
655
  }
656
656
  const { parent } = data;
657
657
  parent.show = true;
658
- parent.expand = true;
659
658
  parent.isFilter = true;
660
659
  makeParentShow(parent);
661
660
  };
661
+ const makeChildShow = (data) => {
662
+ if (!data?.children) {
663
+ return;
664
+ }
665
+ const { children } = data;
666
+ children.forEach((node) => {
667
+ const childNode = node;
668
+ if (childNode.parent.show && childNode.parent.expand) {
669
+ childNode.show = true;
670
+ } else {
671
+ childNode.show = false;
672
+ }
673
+ childNode.isFilter = true;
674
+ if (childNode.hasChild) {
675
+ makeChildShow(childNode);
676
+ }
677
+ });
678
+ };
662
679
  let timer = null;
663
680
  const onSearch = (searchWord) => {
664
681
  if (timer) {
@@ -695,19 +712,28 @@ export const filterEvent = (params) => {
695
712
  });
696
713
  filterStores.forEach((row) => {
697
714
  row.show = true;
715
+ if (row.parent && !row.parent.expand) {
716
+ row.show = false;
717
+ }
698
718
  row.isFilter = true;
699
719
  makeParentShow(row);
720
+ makeChildShow(row);
700
721
  });
701
722
  } else {
702
723
  store.forEach((row) => {
703
724
  row.show = true;
704
725
  row.isFilter = false;
705
726
  });
727
+ store.forEach((row) => {
728
+ if (row.hasChild) {
729
+ makeChildShow(row);
730
+ }
731
+ });
706
732
  }
707
733
  if (stores.searchStore.length > 0) {
708
734
  store = stores.searchStore;
709
735
  }
710
- const isCheck = store.every(n => n.checked === true);
736
+ const isCheck = store.length > 0 && store.every(n => n.checked === true);
711
737
  checkInfo.isHeaderChecked = isCheck;
712
738
  calculatedColumn();
713
739
  updateVScroll();
@@ -433,8 +433,8 @@ const useMouseEvent = (param) => {
433
433
  setDragStyle({
434
434
  top: `${tempTop}px`,
435
435
  left: `${tempLeft}px`,
436
- width: props.width,
437
- height: props.height,
436
+ width: dragStyle.width ?? props.width,
437
+ height: dragStyle.height ?? props.height,
438
438
  });
439
439
  } else if (props.resizable && clickedInfo.pressedSpot === 'border') {
440
440
  resizeWindow(e);