evui 3.4.18 → 3.4.20

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.4.18",
3
+ "version": "3.4.20",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -147,6 +147,5 @@ export function mobileCheck() {
147
147
  navigator.userAgent,
148
148
  )
149
149
  || 'ontouchstart' in window
150
- || navigator.maxTouchPoints
151
150
  );
152
151
  }
@@ -13,6 +13,13 @@
13
13
  class="filtering"
14
14
  :style="{ width: `${filteringItemsWidth}px` }"
15
15
  >
16
+ <div
17
+ v-if="isFiltering && !Object.keys(filteringItemsByColumn).length"
18
+ class="filtering-items filtering-items--used"
19
+ >
20
+ <ev-icon icon="ev-icon-filter-list" />
21
+ <span>Filter</span>
22
+ </div>
16
23
  <div
17
24
  v-if="isFiltering && Object.keys(filteringItemsByColumn).length"
18
25
  ref="filteringItemsRef"
@@ -521,7 +528,7 @@ import {
521
528
  nextTick,
522
529
  ref,
523
530
  provide,
524
- onBeforeMount,
531
+ onBeforeMount, onUnmounted,
525
532
  } from 'vue';
526
533
  import { clickoutside } from '@/directives/clickoutside';
527
534
  import { cloneDeep } from 'lodash-es';
@@ -620,6 +627,7 @@ export default {
620
627
  const borderStyle = computed(() => (props.option.style?.border || ''));
621
628
  const highlightIdx = computed(() => (props.option.style?.highlight ?? -1));
622
629
  const rowMinHeight = props.option.rowMinHeight || 35;
630
+ const filteringItemsWidth = ref(0);
623
631
  const elementInfo = reactive({
624
632
  body: null,
625
633
  header: null,
@@ -660,9 +668,9 @@ export default {
660
668
  movedColumns: [],
661
669
  originColumns: computed(() => props.columns.map((column, index) => ({ index, ...column }))),
662
670
  orderedColumns: computed(() => {
663
- const columns = stores.filteredColumns.length
664
- ? stores.filteredColumns : stores.originColumns;
665
- return stores.movedColumns.length ? stores.movedColumns : columns;
671
+ const columns = stores.movedColumns.length
672
+ ? stores.movedColumns : stores.originColumns;
673
+ return stores.filteredColumns.length ? stores.filteredColumns : columns;
666
674
  }),
667
675
  });
668
676
  const pageInfo = reactive({
@@ -868,17 +876,39 @@ export default {
868
876
 
869
877
  provide('toolbarWrapper', toolbarWrapper);
870
878
 
871
- const filteringItemsWidth = ref(0);
879
+ const onMouseWheel = (e) => {
880
+ if (e.type === 'wheel') {
881
+ contextInfo.menu?.hide(e);
882
+ }
883
+ if (e.type === 'scroll' && !e.target.classList?.contains('table-body')
884
+ && !e.target.offsetParent?.classList?.contains('ev-grid-column-setting')
885
+ && !e.target.offsetParent?.classList?.contains('ev-text-field-wrapper')) {
886
+ contextInfo.columnMenu?.hide(e);
887
+ columnSettingInfo.isShowColumnSetting = false;
888
+ filterInfo.isShowFilterSetting = false;
889
+ }
890
+ };
891
+
872
892
  onMounted(() => {
873
893
  calculatedColumn();
874
894
  setStore(props.rows);
895
+ document.addEventListener('wheel', onMouseWheel, { capture: false });
896
+ document.addEventListener('scroll', onMouseWheel, { capture: true });
897
+ });
898
+
899
+ onUnmounted(() => {
900
+ document.removeEventListener('wheel', onMouseWheel);
901
+ document.removeEventListener('scroll', onMouseWheel);
875
902
  });
903
+
876
904
  onActivated(() => {
877
905
  onResize();
878
906
  });
907
+
879
908
  onUpdated(() => {
880
909
  filteringItemsWidth.value = elementInfo['grid-wrapper']?.offsetWidth / 1.5 || 0;
881
910
  });
911
+
882
912
  watch(
883
913
  () => props.columns,
884
914
  () => {
@@ -26,7 +26,7 @@ export default {
26
26
  }
27
27
  .gridToolbar > .column-setting__icon {
28
28
  float: right;
29
- margin: 0 5px;
29
+ margin: 10px 5px;
30
30
  cursor: pointer;
31
31
  &:hover {
32
32
  opacity: 0.6;
@@ -316,7 +316,9 @@
316
316
  border: 1px solid #198FFF;
317
317
  color: #198FFF;
318
318
  i {
319
- vertical-align: middle;
319
+ &:not(.filtering-items-expand) {
320
+ vertical-align: middle;
321
+ }
320
322
  }
321
323
  }
322
324
  &--title {
@@ -1154,16 +1154,22 @@ export const columnSettingEvent = (params) => {
1154
1154
  }
1155
1155
  onResize();
1156
1156
  };
1157
- const onApplyColumn = (columns) => {
1158
- columnSettingInfo.hiddenColumn = '';
1157
+ const onApplyColumn = (columnNames) => {
1158
+ const columns = stores.orderedColumns.filter(col => !col.hide);
1159
+ const isSameColumn = columnNames.length === columns.length
1160
+ && columns.every(col => columnNames.includes(col.field));
1161
+
1162
+ if (isSameColumn) {
1163
+ return;
1164
+ }
1165
+
1159
1166
  stores.filteredColumns = stores.originColumns
1160
- .filter(col => columns.includes(col.field) || !col.caption);
1167
+ .filter(col => columnNames.includes(col.field) || !col.caption);
1168
+ columnSettingInfo.hiddenColumn = '';
1161
1169
  setFilteringColumn();
1162
1170
  };
1163
1171
  const setColumnHidden = (val) => {
1164
- const columns = (columnSettingInfo.isFilteringColumn
1165
- ? stores.filteredColumns : stores.originColumns)
1166
- .filter(col => !col.hide);
1172
+ const columns = stores.orderedColumns.filter(col => !col.hide);
1167
1173
 
1168
1174
  if (columns.length === 1) {
1169
1175
  return;
@@ -1180,10 +1186,18 @@ export const dragEvent = ({ stores }) => {
1180
1186
  const setColumnMoving = (currentIndex, droppedIndex) => {
1181
1187
  const oldIndex = parseInt(currentIndex, 10);
1182
1188
  const newPositionIndex = parseInt(droppedIndex, 10);
1183
- const columns = stores.filteredColumns.length ? stores.filteredColumns : stores.orderedColumns;
1189
+
1190
+ const columns = [...stores.orderedColumns];
1184
1191
  const movedColumn = columns[oldIndex];
1192
+
1185
1193
  columns.splice(oldIndex, 1);
1186
- stores.movedColumns = columns.splice(newPositionIndex, 0, movedColumn);
1194
+ columns.splice(newPositionIndex, 0, movedColumn);
1195
+
1196
+ if (stores.filteredColumns.length) {
1197
+ stores.filteredColumns = columns;
1198
+ } else {
1199
+ stores.movedColumns = columns;
1200
+ }
1187
1201
  };
1188
1202
  const onDragStart = (e) => {
1189
1203
  e.dataTransfer.setData('text/plain', e.currentTarget.dataset.index);
@@ -237,7 +237,18 @@
237
237
  </template>
238
238
 
239
239
  <script>
240
- import { reactive, toRefs, computed, watch, onMounted, onActivated, nextTick, ref, provide } from 'vue';
240
+ import {
241
+ reactive,
242
+ toRefs,
243
+ computed,
244
+ watch,
245
+ onActivated,
246
+ nextTick,
247
+ ref,
248
+ provide,
249
+ onMounted,
250
+ onUnmounted,
251
+ } from 'vue';
241
252
  import treeGridNode from './TreeGridNode';
242
253
  import Toolbar from './treeGrid.toolbar';
243
254
  import GridPagination from '../grid/grid.pagination';
@@ -545,9 +556,28 @@ export default {
545
556
 
546
557
  provide('toolbarWrapper', toolbarWrapper);
547
558
 
559
+ const onMouseWheel = (e) => {
560
+ if (e.type === 'wheel') {
561
+ contextInfo.menu?.hide(e);
562
+ }
563
+ if (e.type === 'scroll' && !e.target.classList?.contains('table-body')
564
+ && !e.target.offsetParent?.classList?.contains('ev-grid-column-setting')) {
565
+ contextInfo.columnMenu?.hide(e);
566
+ columnSettingInfo.isShowColumnSetting = false;
567
+ }
568
+ };
569
+
548
570
  onMounted(() => {
549
571
  stores.treeStore = setTreeNodeStore();
572
+ document.addEventListener('wheel', onMouseWheel, { capture: false });
573
+ document.addEventListener('scroll', onMouseWheel, { capture: true });
550
574
  });
575
+
576
+ onUnmounted(() => {
577
+ document.removeEventListener('wheel', onMouseWheel);
578
+ document.removeEventListener('scroll', onMouseWheel);
579
+ });
580
+
551
581
  onActivated(() => {
552
582
  onResize();
553
583
  });
@@ -26,7 +26,7 @@ export default {
26
26
  }
27
27
  .tree-grid-toolbar > .column-setting__icon {
28
28
  float: right;
29
- margin: 0 5px;
29
+ margin: 10px 5px;
30
30
  cursor: pointer;
31
31
  &:hover {
32
32
  opacity: 0.6;