lkt-table 2.0.44 → 2.0.46

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": "lkt-table",
3
- "version": "2.0.44",
3
+ "version": "2.0.46",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -6,18 +6,26 @@ import {computed, nextTick, onMounted, ref, useSlots, watch} from "vue";
6
6
  import {
7
7
  AccordionConfig,
8
8
  ButtonConfig,
9
- ButtonType, CalendarConfig, CalendarEventConfig, CalendarItemConfig, ClickEventArgs,
10
- Column, ColumnConfig,
9
+ ButtonType,
10
+ CalendarConfig,
11
+ CalendarItemConfig,
12
+ ClickEventArgs,
13
+ Column,
14
+ ColumnConfig,
11
15
  ensureButtonConfig,
12
16
  extractI18nValue,
13
- getDefaultValues, HeaderConfig, ItemSlotComponentConfig,
17
+ getDefaultValues,
18
+ HeaderConfig,
19
+ ItemSlotComponentConfig,
14
20
  LktObject,
15
21
  LktSettings,
22
+ PaginatorConfig,
16
23
  PaginatorType,
17
24
  SortDirection,
18
25
  Table,
19
26
  TableConfig,
20
- TablePermission, TableRowType,
27
+ TablePermission,
28
+ TableRowType,
21
29
  TableType
22
30
  } from "lkt-vue-kernel";
23
31
  import {generateRandomString, replaceAll} from "lkt-string-tools";
@@ -26,7 +34,7 @@ import {HTTPResponse} from "lkt-http-client";
26
34
  import CreateButton from "../components/CreateButton.vue";
27
35
  import Sortable from 'sortablejs';
28
36
  import TableHeader from "../components/TableHeader.vue";
29
- import {date, time} from "lkt-date-tools";
37
+ import {date, findOldestAndNewestDateInObjects, time} from "lkt-date-tools";
30
38
  import {Settings} from "../settings/Settings";
31
39
  import LktTableCell from "../components/LktTableCell.vue";
32
40
 
@@ -71,7 +79,10 @@ const Page = ref(props.paginator?.modelValue),
71
79
  updateTimeStamp = ref(0),
72
80
  sortableContainer = ref(<HTMLElement | null>null),
73
81
  activeType = ref(props.type),
74
- currentSlide = ref(props.carousel?.currentSlide || 0)
82
+ currentSlide = ref(props.carousel?.currentSlide || 0),
83
+ timelineOldestDate = ref(<Date|undefined>undefined),
84
+ timelineNewestDate = ref(<Date|undefined>undefined),
85
+ timelineVisibleDate = ref(<Date|undefined>undefined)
75
86
  ;
76
87
 
77
88
  const safeSaveButton = ref(ensureButtonConfig(props.saveButton, LktSettings.defaultSaveButton)),
@@ -99,6 +110,12 @@ const onPerms = (r: string[]) => {
99
110
  rawItems = props.events.parseResults(rawItems);
100
111
  }
101
112
  Items.value = [...Items.value, ...rawItems];
113
+
114
+ if ([PaginatorType.TimelineAsc, PaginatorType.TimelineDesc, PaginatorType.TimelineAscDesc].includes(props.paginator?.type)) {
115
+ const dateRange = findOldestAndNewestDateInObjects(Items.value, props.paginator.dateKey);
116
+ timelineOldestDate.value = dateRange.oldest;
117
+ timelineNewestDate.value = dateRange.newest;
118
+ }
102
119
  }
103
120
  isLoading.value = false;
104
121
  firstLoadReady.value = true;
@@ -450,6 +467,10 @@ const getItemByEvent = (e: any) => {
450
467
  if (typeof props.itemContainerClass === 'function') return props.itemContainerClass(item, index);
451
468
  return props.itemContainerClass;
452
469
  },
470
+ getItemContainerStyle = (item: LktObject, index: number) => {
471
+ if (typeof props.itemContainerStyle === 'function') return props.itemContainerStyle(item, index);
472
+ return props.itemContainerStyle;
473
+ },
453
474
  getAccordionHeaderText = (item: LktObject, index: number) => {
454
475
  if (!computedAccordionHeaderColumn.value) return '';
455
476
 
@@ -584,8 +605,12 @@ const availableTypes = computed(() => {
584
605
 
585
606
  activeType.value = type;
586
607
 
587
- if (typeof props.switchableTypesButtons[type] === 'function') {
588
- props.switchableTypesButtons[type](args);
608
+ if (typeof props.switchableTypesButtons[type].events?.click === 'function') {
609
+ props.switchableTypesButtons[type].events.click(args);
610
+ }
611
+
612
+ if (typeof props.events?.viewChanged === 'function') {
613
+ props.events.viewChanged(type);
589
614
  }
590
615
  }
591
616
  }
@@ -671,6 +696,8 @@ const calendarEvents = {
671
696
  if (typeof props.calendar.events?.visibleMonthChanged === 'function') {
672
697
  props.calendar.events.visibleMonthChanged(args);
673
698
  }
699
+
700
+ timelineVisibleDate.value = args.visibleDate;
674
701
  })
675
702
  }
676
703
 
@@ -952,7 +979,9 @@ const calendarEvents = {
952
979
  v-if="!skipTableItemsContainer && canDisplayItem(item, i)"
953
980
  class="lkt-table-item"
954
981
  :class="getItemContainerClass(item, i)"
955
- :data-i="i">
982
+ :style="getItemContainerStyle(item, i)"
983
+ :data-i="i"
984
+ >
956
985
  <template v-if="computedItemSlotComponent">
957
986
  <component
958
987
  :is="computedItemSlotComponent"
@@ -1081,7 +1110,11 @@ const calendarEvents = {
1081
1110
  <template
1082
1111
  v-for="(item, i) in Items" :key="getRowKey(item, i)">
1083
1112
  <li class="lkt-table-item"
1084
- :class="getItemContainerClass(item, i)" v-if="canDisplayItem(item, i)" :data-i="i">
1113
+ :class="getItemContainerClass(item, i)"
1114
+ v-if="canDisplayItem(item, i)"
1115
+ :data-i="i"
1116
+ :style="getItemContainerStyle(item, i)"
1117
+ >
1085
1118
  <template v-if="computedItemSlotComponent">
1086
1119
  <component
1087
1120
  :is="computedItemSlotComponent"
@@ -1213,7 +1246,12 @@ const calendarEvents = {
1213
1246
  <lkt-paginator
1214
1247
  ref="paginatorRef"
1215
1248
  v-if="paginator && Object.keys(paginator).length > 0"
1216
- v-bind="paginator"
1249
+ v-bind="<PaginatorConfig>{
1250
+ ...paginator,
1251
+ timelineOldestDate,
1252
+ timelineNewestDate,
1253
+ timelineVisibleDate,
1254
+ }"
1217
1255
  v-model="Page"
1218
1256
  @loading="onLoading"
1219
1257
  @perms="onPerms"