@vc-shell/framework 1.0.261 → 1.0.263

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.
@@ -95,7 +95,7 @@
95
95
  clearable
96
96
  name="table_search"
97
97
  :model-value="searchValue"
98
- @update:model-value="$emit('search:change', $event)"
98
+ @update:model-value="$emit('search:change', $event as string)"
99
99
  >
100
100
  <template #prepend-inner="{ focus }">
101
101
  <VcIcon
@@ -204,12 +204,13 @@
204
204
  >
205
205
  <div class="vc-table__header-row tw-flex tw-flex-row">
206
206
  <div
207
- v-if="editing && multiselect && items && items.length"
208
- class="tw-flex-1 tw-flex tw-items-center tw-justify-center tw-w-[28px] tw-max-w-[28px] tw-min-w-[28px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
207
+ v-if="multiselect && items && items.length"
208
+ class="tw-flex-1 tw-flex tw-items-center tw-justify-center tw-w-[36px] tw-max-w-[36px] tw-min-w-[36px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
209
209
  >
210
210
  <div class="tw-flex tw-justify-center tw-items-center">
211
211
  <VcCheckbox
212
212
  v-model="headerCheckbox"
213
+ size="m"
213
214
  @click.stop
214
215
  ></VcCheckbox>
215
216
  </div>
@@ -237,7 +238,7 @@
237
238
  @drop="onColumnHeaderDrop($event, item)"
238
239
  @click="handleHeaderClick(item)"
239
240
  >
240
- <div
241
+ <!-- <div
241
242
  v-if="!editing && multiselect && index === 0 && items && items.length"
242
243
  class="tw-flex tw-pl-5 tw-items-center tw-justify-center tw-w-auto tw-bg-[#f9f9f9] tw-box-border tw-select-none tw-overflow-hidden tw-z-[1] tw-shrink-0"
243
244
  >
@@ -248,7 +249,7 @@
248
249
  @click.stop
249
250
  ></VcCheckbox>
250
251
  </div>
251
- </div>
252
+ </div> -->
252
253
  <div class="tw-flex tw-items-center tw-flex-nowrap tw-truncate tw-px-3 tw-font-bold">
253
254
  <div class="tw-truncate">
254
255
  <span
@@ -361,13 +362,14 @@
361
362
  @mouseover="showActions(itemIndex)"
362
363
  >
363
364
  <div
364
- v-if="editing && multiselect && typeof item === 'object'"
365
- class="tw-w-[28px] tw-max-w-[28px] tw-min-w-[28px] tw-relative tw-flex-1 tw-flex tw-items-center tw-justify-center"
365
+ v-if="multiselect && typeof item === 'object'"
366
+ class="tw-w-[36px] tw-max-w-[36px] tw-min-w-[36px] tw-relative tw-flex-1 tw-flex tw-items-center tw-justify-center"
366
367
  @click.stop
367
368
  >
368
369
  <div class="tw-flex tw-justify-center tw-items-center">
369
370
  <VcCheckbox
370
371
  :model-value="isSelected(item)"
372
+ size="m"
371
373
  @update:model-value="rowCheckbox(item)"
372
374
  ></VcCheckbox>
373
375
  </div>
@@ -382,11 +384,26 @@
382
384
  :style="{ maxWidth: cell.width, width: cell.width }"
383
385
  >
384
386
  <div class="tw-truncate tw-w-full">
385
- <renderCellSlot
387
+ <!-- <renderCellSlot
388
+ :item="item"
389
+ :cell="cell"
390
+ :index="itemIndex"
391
+ /> -->
392
+ <slot
393
+ :name="`item_${cell.id}`"
386
394
  :item="item"
387
395
  :cell="cell"
388
396
  :index="itemIndex"
389
- />
397
+ >
398
+ <VcTableCell
399
+ :item="item as TableItem"
400
+ :cell="cell"
401
+ :index="itemIndex"
402
+ :editing="editing"
403
+ @update="$emit('onEditComplete', { event: $event, index: itemIndex })"
404
+ @blur="$emit('onCellBlur', $event)"
405
+ ></VcTableCell>
406
+ </slot>
390
407
  </div>
391
408
  </div>
392
409
  <div
@@ -595,7 +612,7 @@ const props = withDefaults(
595
612
  const emit = defineEmits<{
596
613
  paginationClick: [page: number];
597
614
  selectionChanged: [values: T[]];
598
- "search:change": [value: string | number | Date | null | undefined];
615
+ "search:change": [value: string | undefined];
599
616
  headerClick: [item: ITableColumns];
600
617
  itemClick: [item: T];
601
618
  "scroll:ptr": [];
@@ -645,7 +662,7 @@ const draggedColumn = ref();
645
662
  const draggedElement = ref<HTMLElement>();
646
663
  const dropPosition = ref();
647
664
  const columnsInit = ref(true);
648
- const isHovered = ref(undefined) as Ref<{ item: T; state: boolean } | undefined>;
665
+ // const isHovered = ref(undefined) as Ref<{ item: T; state: boolean } | undefined>;
649
666
 
650
667
  // row reordering variables
651
668
  const draggedRow = ref<T>();
@@ -669,70 +686,70 @@ const sortField = computed(() => {
669
686
 
670
687
  const hasClickListener = typeof instance?.vnode.props?.["onItemClick"] === "function";
671
688
 
672
- const renderCellSlot = ({ item, cell, index }: { item: T; cell: ITableColumns; index: number }) => {
673
- const isSlotExist = slots[`item_${cell.id}`];
674
-
675
- const isFirstCell = filteredCols.value.indexOf(cell) === 0;
676
-
677
- const isRowSelected = selection.value.includes(item);
678
-
679
- const checkboxComponent = h(
680
- "div",
681
- {
682
- class: "tw-absolute tw-z-10 tw-top-0 tw-bottom-0 tw-left-[20px] tw-right-0 tw-flex tw-items-center",
683
- },
684
- h(VcCheckbox, {
685
- class: "",
686
- size: "m",
687
- modelValue: selection.value.includes(item),
688
- onClick: (e: Event) => e.stopPropagation(),
689
- onMouseover: () => (isHovered.value = { state: true, item: item }),
690
- onMouseout: () => (isHovered.value = { state: false, item: item }),
691
- "onUpdate:modelValue": () => {
692
- rowCheckbox(item);
693
- },
694
- }),
695
- );
696
-
697
- const checkboxVisibilityHandler =
698
- !props.editing &&
699
- props.multiselect &&
700
- props.items &&
701
- props.items.length &&
702
- ((isFirstCell && selectedRowIndex.value === index) || (isRowSelected && isFirstCell));
703
-
704
- return h("div", { class: "" }, [
705
- checkboxVisibilityHandler ? checkboxComponent : undefined,
706
- h(
707
- "div",
708
- {
709
- class: checkboxVisibilityHandler
710
- ? isHovered.value?.item === item && isHovered.value.state
711
- ? "tw-opacity-5"
712
- : "tw-opacity-15"
713
- : "",
714
- },
715
- !isSlotExist
716
- ? h(VcTableCell, {
717
- cell,
718
-
719
- item: item as TableItem,
720
- index,
721
- editing: props.editing,
722
- onUpdate: (event) => {
723
- emit("onEditComplete", { event, index });
724
- },
725
- onBlur: (event) => emit("onCellBlur", event),
726
- })
727
- : slots[`item_${cell.id}`]?.({ item, cell, index }),
728
- ),
729
- ]);
730
- };
731
-
732
- const calculateElWidth = (id: string) => {
733
- const el = document.getElementById(id);
734
- return el ? el.offsetWidth : 0;
735
- };
689
+ // const renderCellSlot = ({ item, cell, index }: { item: T; cell: ITableColumns; index: number }) => {
690
+ // const isSlotExist = slots[`item_${cell.id}`];
691
+
692
+ // const isFirstCell = filteredCols.value.indexOf(cell) === 0;
693
+
694
+ // const isRowSelected = isSelected(item);
695
+
696
+ // const checkboxComponent = h(
697
+ // "div",
698
+ // {
699
+ // class: "tw-absolute tw-z-10 tw-top-0 tw-bottom-0 tw-left-[20px] tw-right-0 tw-flex tw-items-center",
700
+ // },
701
+ // h(VcCheckbox, {
702
+ // class: "",
703
+ // size: "m",
704
+ // modelValue: isSelected(item),
705
+ // onClick: (e: Event) => e.stopPropagation(),
706
+ // onMouseover: () => (isHovered.value = { state: true, item: item }),
707
+ // onMouseout: () => (isHovered.value = { state: false, item: item }),
708
+ // "onUpdate:modelValue": () => {
709
+ // rowCheckbox(item);
710
+ // },
711
+ // }),
712
+ // );
713
+
714
+ // const checkboxVisibilityHandler =
715
+ // !props.editing &&
716
+ // props.multiselect &&
717
+ // props.items &&
718
+ // props.items.length &&
719
+ // ((isFirstCell && selectedRowIndex.value === index) || (isRowSelected && isFirstCell));
720
+
721
+ // return h("div", { class: "" }, [
722
+ // checkboxVisibilityHandler ? checkboxComponent : undefined,
723
+ // h(
724
+ // "div",
725
+ // {
726
+ // class: checkboxVisibilityHandler
727
+ // ? isHovered.value?.item === item && isHovered.value.state
728
+ // ? "tw-opacity-5"
729
+ // : "tw-opacity-15"
730
+ // : "",
731
+ // },
732
+ // !isSlotExist
733
+ // ? h(VcTableCell, {
734
+ // cell,
735
+
736
+ // item: item as TableItem,
737
+ // index,
738
+ // editing: props.editing,
739
+ // onUpdate: (event) => {
740
+ // emit("onEditComplete", { event, index });
741
+ // },
742
+ // onBlur: (event) => emit("onCellBlur", event),
743
+ // })
744
+ // : slots[`item_${cell.id}`]?.({ item, cell, index }),
745
+ // ),
746
+ // ]);
747
+ // };
748
+
749
+ // const calculateElWidth = (id: string) => {
750
+ // const el = document.getElementById(id);
751
+ // return el ? el.offsetWidth : 0;
752
+ // };
736
753
 
737
754
  const allColumns = ref([]) as Ref<ITableColumns[]>;
738
755
 
@@ -897,14 +914,15 @@ function handleSelectAll() {
897
914
  }
898
915
 
899
916
  function isSelected(item: T) {
900
- return selection.value.indexOf(item) > -1;
917
+ return !!selection.value.find((x) => _.isEqual(x, item));
901
918
  }
902
919
 
903
920
  function rowCheckbox(item: T) {
904
921
  const clear = item;
905
- const index = selection.value.indexOf(clear);
906
- if (index > -1) {
907
- selection.value = selection.value.filter((x) => x !== clear);
922
+ const isExist = selection.value.find((x) => _.isEqual(x, clear));
923
+
924
+ if (isExist) {
925
+ selection.value = selection.value.filter((x) => !_.isEqual(x, clear));
908
926
  } else {
909
927
  selection.value.push(clear);
910
928
  }