lkt-table 2.0.6 → 2.0.8

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.
@@ -0,0 +1,14 @@
1
+ import { ButtonConfig, LktObject } from "lkt-vue-kernel";
2
+ type __VLS_Props = {
3
+ config: ButtonConfig;
4
+ item: LktObject;
5
+ disabled?: boolean;
6
+ };
7
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ click: (...args: any[]) => void;
9
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ onClick?: ((...args: any[]) => any) | undefined;
11
+ }>, {
12
+ disabled: boolean;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { ButtonConfig, LktObject } from "lkt-vue-kernel";
2
+ type __VLS_Props = {
3
+ config: ButtonConfig;
4
+ item: LktObject;
5
+ disabled?: boolean;
6
+ };
7
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ click: (...args: any[]) => void;
9
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ onClick?: ((...args: any[]) => any) | undefined;
11
+ }>, {
12
+ disabled: boolean;
13
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
+ export default _default;
@@ -1,7 +1,7 @@
1
1
  import { canRenderColumn, colPreferSlot, getColumnClasses, getColumnDisplayContent, getHorizontalColSpan } from "../functions/table-functions";
2
2
  import LktTableCell from "./LktTableCell.vue";
3
- import DropButton from "./DropButton.vue";
4
- import EditButton from "./EditButton.vue";
3
+ import DropButtonComponent from "./DropButtonComponent.vue";
4
+ import EditButtonComponent from "./EditButtonComponent.vue";
5
5
  import { ButtonConfig, Column, LktObject, ValidTableRowTypeValue } from "lkt-vue-kernel";
6
6
  declare const slots: Readonly<{
7
7
  [name: string]: import("vue").Slot<any> | undefined;
@@ -33,24 +33,24 @@ declare const canItem: boolean;
33
33
  declare const onClick: ($event: any) => void, onShow: ($event: any, i: any) => void, classes: import("vue").ComputedRef<string>, hasNavButtonSlot: import("vue").ComputedRef<boolean>, navButtonSlot: import("vue").ComputedRef<string | import("vue").Component>, onClickUp: () => void, onClickDown: () => void, onClickDrop: () => void, onClickEdit: () => void;
34
34
  declare const canRenderDragIndicator: import("vue").ComputedRef<any>;
35
35
  declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
36
- declare var __VLS_24: `item-${number}`, __VLS_25: {
36
+ declare var __VLS_26: `item-${number}`, __VLS_27: {
37
37
  item: LktObject;
38
38
  index: number;
39
- }, __VLS_27: {
39
+ }, __VLS_29: {
40
40
  item: LktObject;
41
41
  index: number;
42
- }, __VLS_30: string, __VLS_31: {
42
+ }, __VLS_32: string, __VLS_33: {
43
43
  value: any;
44
44
  item: LktObject;
45
45
  column: Column;
46
46
  i: number;
47
47
  };
48
48
  type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
49
- [K in NonNullable<typeof __VLS_24>]?: (props: typeof __VLS_25) => any;
49
+ [K in NonNullable<typeof __VLS_26>]?: (props: typeof __VLS_27) => any;
50
50
  } & {
51
- [K in NonNullable<typeof __VLS_30>]?: (props: typeof __VLS_31) => any;
51
+ [K in NonNullable<typeof __VLS_32>]?: (props: typeof __VLS_33) => any;
52
52
  } & {
53
- item?: (props: typeof __VLS_27) => any;
53
+ item?: (props: typeof __VLS_29) => any;
54
54
  }>;
55
55
  declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
56
56
  canRenderColumn: typeof canRenderColumn;
@@ -59,8 +59,8 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
59
59
  getColumnDisplayContent: typeof getColumnDisplayContent;
60
60
  getHorizontalColSpan: typeof getHorizontalColSpan;
61
61
  LktTableCell: typeof LktTableCell;
62
- DropButton: typeof DropButton;
63
- EditButton: typeof EditButton;
62
+ DropButtonComponent: typeof DropButtonComponent;
63
+ EditButtonComponent: typeof EditButtonComponent;
64
64
  slots: typeof slots;
65
65
  Item: typeof Item;
66
66
  canCustomItem: typeof canCustomItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-table",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -50,17 +50,18 @@
50
50
  "sortablejs": "^1.15.6"
51
51
  },
52
52
  "peerDependencies": {
53
- "lkt-button": "^2.0.7",
53
+ "lkt-button": "^2.0.8",
54
54
  "lkt-data-state": "^1.0.11",
55
55
  "lkt-date-tools": "^1.0.4",
56
- "lkt-field": "^1.0.0",
56
+ "lkt-field": "^1.2.1",
57
57
  "lkt-http-client": "^1.0.34",
58
- "lkt-i18n": "^1.0.6",
58
+ "lkt-i18n": "^1.1.0",
59
59
  "lkt-loader": "^1.2.0",
60
- "lkt-paginator": "^1.3.3",
60
+ "lkt-paginator": "^1.4.1",
61
61
  "lkt-string-tools": "^1.1.0",
62
- "lkt-vue-kernel": "^1.0.35",
62
+ "lkt-vue-kernel": "^1.0.42",
63
63
  "vue": "^3.3",
64
- "vue-router": "^4.2.5"
64
+ "vue-router": "^4.2.5",
65
+ "vue3-carousel": "^0.14.0"
65
66
  }
66
67
  }
@@ -3,7 +3,10 @@ import {computed} from "vue";
3
3
  import {Settings} from "../settings/Settings";
4
4
  import {ButtonConfig, LktObject} from "lkt-vue-kernel";
5
5
 
6
- const emit = defineEmits(['click', 'append']);
6
+ const emit = defineEmits([
7
+ 'click',
8
+ 'append'
9
+ ]);
7
10
 
8
11
  const props = withDefaults(defineProps<{
9
12
  config?: ButtonConfig
@@ -1,12 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import {computed} from "vue";
3
3
  import {Settings} from "../settings/Settings";
4
- import {ButtonConfig} from "lkt-vue-kernel";
4
+ import {ButtonConfig, LktObject, prepareResourceData} from "lkt-vue-kernel";
5
5
 
6
- const emit = defineEmits(['click']);
6
+ const emit = defineEmits([
7
+ 'click'
8
+ ]);
7
9
 
8
10
  const props = withDefaults(defineProps<{
9
- config?: ButtonConfig
11
+ config: ButtonConfig
12
+ item: LktObject
10
13
  disabled?: boolean
11
14
  }>(), {
12
15
  disabled: false,
@@ -14,19 +17,21 @@ const props = withDefaults(defineProps<{
14
17
 
15
18
  const hasButtonSlot = computed(() => Settings.dropButtonSlot !== ''),
16
19
  buttonSlot = computed(() => Settings.dropButtonSlot);
20
+
21
+ const computedResourceData = computed(() => {
22
+ return prepareResourceData(props.config.resourceData, props.item);
23
+ })
17
24
  </script>
18
25
 
19
26
  <template>
20
27
  <lkt-button
21
28
  palette="table-delete"
22
29
  v-bind="props.config"
23
- :icon="hasButtonSlot ? '' : config?.icon"
24
- :text="hasButtonSlot ? '' : config?.text"
25
30
  :disabled="disabled"
26
- @click.prevent.stop="emit('click')">
31
+ :resource-data="computedResourceData"
32
+ @click.prevent.stop="emit('click', $event)">
27
33
  <template v-if="hasButtonSlot">
28
- <component
29
- :is="buttonSlot"/>
34
+ <component :is="buttonSlot"/>
30
35
  </template>
31
36
  </lkt-button>
32
37
  </template>
@@ -1,32 +1,37 @@
1
1
  <script setup lang="ts">
2
2
  import {computed} from "vue";
3
3
  import {Settings} from "../settings/Settings";
4
- import {ButtonConfig} from "lkt-vue-kernel";
4
+ import {ButtonConfig, LktObject, prepareResourceData} from "lkt-vue-kernel";
5
5
 
6
- const emit = defineEmits(['click']);
6
+ const emit = defineEmits([
7
+ 'click'
8
+ ]);
7
9
 
8
10
  const props = withDefaults(defineProps<{
9
- config?: ButtonConfig
11
+ config: ButtonConfig
12
+ item: LktObject
10
13
  disabled?: boolean
11
14
  }>(), {
12
15
  disabled: false,
13
16
  });
14
17
 
15
18
  const hasButtonSlot = computed(() => Settings.editButtonSlot !== ''),
16
- buttonSlot = computed(() => Settings.editButtonSlot)
19
+ buttonSlot = computed(() => Settings.editButtonSlot);
20
+
21
+ const computedResourceData = computed(() => {
22
+ return prepareResourceData(props.config.resourceData, props.item);
23
+ })
17
24
  </script>
18
25
 
19
26
  <template>
20
27
  <lkt-button
21
- palette="table-delete"
28
+ palette="table-edit"
22
29
  v-bind="props.config"
23
- :icon="hasButtonSlot ? '' : config?.icon"
24
- :text="hasButtonSlot ? '' : config?.text"
25
30
  :disabled="disabled"
31
+ :resource-data="computedResourceData"
26
32
  @click.prevent.stop="emit('click')">
27
33
  <template v-if="hasButtonSlot">
28
- <component
29
- :is="buttonSlot"/>
34
+ <component :is="buttonSlot"/>
30
35
  </template>
31
36
  </lkt-button>
32
37
  </template>
@@ -4,7 +4,10 @@ import LktTableCell from "./LktTableCell.vue";
4
4
  import {ref, watch} from "vue";
5
5
  import {LktObject, Column} from "lkt-vue-kernel";
6
6
 
7
- const emit = defineEmits(['update:modelValue', 'click']);
7
+ const emit = defineEmits([
8
+ 'update:modelValue',
9
+ 'click'
10
+ ]);
8
11
 
9
12
  const props = withDefaults(defineProps<{
10
13
  modelValue: LktObject
@@ -3,7 +3,9 @@ import {getColumnDisplayContent} from "../functions/table-functions";
3
3
  import {computed, ref, watch} from "vue";
4
4
  import {Column, ColumnType, LktObject} from "lkt-vue-kernel";
5
5
 
6
- const emit = defineEmits(['update:modelValue']);
6
+ const emit = defineEmits([
7
+ 'update:modelValue'
8
+ ]);
7
9
 
8
10
  const props = withDefaults(defineProps<{
9
11
  modelValue: LktObject
@@ -9,13 +9,20 @@ import {
9
9
  import LktTableCell from "./LktTableCell.vue";
10
10
  import {computed, ref, useSlots, watch} from "vue";
11
11
  import {Settings} from "../settings/Settings";
12
- import DropButton from "./DropButton.vue";
13
- import EditButton from "./EditButton.vue";
12
+ import DropButtonComponent from "./DropButtonComponent.vue";
13
+ import EditButtonComponent from "./EditButtonComponent.vue";
14
14
  import {replaceAll} from "lkt-string-tools";
15
15
  import {ButtonConfig, Column, LktObject, TableRowType, ValidTableRowTypeValue} from "lkt-vue-kernel";
16
16
 
17
17
  const slots = useSlots();
18
- const emit = defineEmits(['update:modelValue', 'click', 'show', 'item-up', 'item-down', 'item-drop']);
18
+ const emit = defineEmits([
19
+ 'update:modelValue',
20
+ 'click',
21
+ 'show',
22
+ 'item-up',
23
+ 'item-down',
24
+ 'item-drop'
25
+ ]);
19
26
 
20
27
  const props = withDefaults(defineProps<{
21
28
  modelValue: LktObject
@@ -148,8 +155,8 @@ const canRenderDragIndicator = computed(() => {
148
155
  </div>
149
156
  </td>
150
157
  <td v-if="displayHiddenColumnsIndicator"
151
- v-on:click="onShow($event, i)" data-role="show-more"
152
- v-bind:class="hiddenIsVisible ? 'state-open' : ''"/>
158
+ @click="onShow($event, i)" data-role="show-more"
159
+ :class="hiddenIsVisible ? 'state-open' : ''"/>
153
160
  <template v-if="canCustomItem && slots[`item-${i}`]">
154
161
  <td :key="'td' + i" :colspan="visibleColumns.length">
155
162
  <slot
@@ -173,7 +180,7 @@ const canRenderDragIndicator = computed(() => {
173
180
  :colspan="getHorizontalColSpan(column,Item)"
174
181
  :title="getColumnDisplayContent (column, Item, i, visibleColumns)"
175
182
  :class="getColumnClasses(column)"
176
- v-on:click="onClick($event)"
183
+ @click="onClick($event)"
177
184
  >
178
185
  <template v-if="!!$slots[column.key] && colPreferSlot(column, Item)">
179
186
  <slot :name="column.key"
@@ -194,13 +201,15 @@ const canRenderDragIndicator = computed(() => {
194
201
  </td>
195
202
  </template>
196
203
  <td v-if="canDrop && editModeEnabled" class="lkt-table-col-drop">
197
- <drop-button
204
+ <drop-button-component
198
205
  :config="dropButton"
206
+ :item="Item"
199
207
  @click="onClickDrop"/>
200
208
  </td>
201
209
  <td v-if="canEdit && editModeEnabled" class="lkt-table-col-edit">
202
- <edit-button
210
+ <edit-button-component
203
211
  :config="editButton"
212
+ :item="Item"
204
213
  @click="onClickEdit"/>
205
214
  </td>
206
215
  </tr>
@@ -3,7 +3,9 @@ import {getColumnClasses, getVerticalColSpan} from "../functions/table-functions
3
3
  import {Column, extractI18nValue, LktObject, LktSettings, SortDirection} from "lkt-vue-kernel";
4
4
  import {computed} from "vue";
5
5
 
6
- const emit = defineEmits(['click']);
6
+ const emit = defineEmits([
7
+ 'click'
8
+ ]);
7
9
 
8
10
  const props = withDefaults(defineProps<{
9
11
  column: Column,
@@ -1,4 +1,5 @@
1
1
  <script lang="ts" setup>
2
+ import {Carousel, Slide, Navigation, Pagination} from "vue3-carousel";
2
3
  import {defaultTableSorter, getColumnByKey, getDefaultSortColumn} from "../functions/table-functions";
3
4
  import LktTableRow from "../components/LktTableRow.vue";
4
5
  import {computed, nextTick, onMounted, ref, useSlots, watch} from "vue";
@@ -68,12 +69,14 @@ const Page = ref(props.paginator?.modelValue),
68
69
  dataState = ref(<DataState>new DataState({items: Items.value}, props.dataStateConfig)),
69
70
  editModeEnabled = ref(props.editMode),
70
71
  updateTimeStamp = ref(0),
71
- sortableContainer = ref(<HTMLElement | null>null)
72
+ sortableContainer = ref(<HTMLElement | null>null),
73
+ currentSlide = ref(1)
72
74
  ;
73
75
 
74
76
  const safeSaveButton = ref(ensureButtonConfig(props.saveButton, LktSettings.defaultSaveButton));
75
77
  const safeCreateButton = ref(ensureButtonConfig(props.createButton, LktSettings.defaultCreateButton));
76
78
  const safeEditModeButton = ref(ensureButtonConfig(props.editModeButton, LktSettings.defaultEditModeButton));
79
+ const safeDropModeButton = ref(ensureButtonConfig(props.dropButton, LktSettings.defaultDropButton));
77
80
 
78
81
  const dataStateChanged = ref(false);
79
82
 
@@ -155,6 +158,11 @@ const emptyColumns = computed(() => {
155
158
  for (let k in slots) if (columnKeys.value.indexOf(k) !== -1) r.push(k);
156
159
  return r;
157
160
  }),
161
+ slides = computed((): LktObject => {
162
+ let r = [];
163
+ for (let k in slots) if (k.indexOf('slide-') !== -1) r.push(k);
164
+ return r;
165
+ }),
158
166
  showSaveButton = computed(() => {
159
167
  if (props.hiddenSave) return false;
160
168
  if (isLoading.value) return false;
@@ -515,9 +523,9 @@ const hasEmptySlot = computed(() => {
515
523
  v-bind="safeSaveButton"
516
524
  :disabled="saveIsDisabled"
517
525
  :modal-data="computedSaveResourceData"
518
- v-on:loading="onButtonLoading"
519
- v-on:loaded="onButtonLoaded"
520
- v-on:click="onSave">
526
+ @loading="onButtonLoading"
527
+ @loaded="onButtonLoaded"
528
+ @click="onSave">
521
529
  <slot v-if="!!slots['button-save']"
522
530
  name="button-save"
523
531
  :items="Items"
@@ -598,7 +606,7 @@ const hasEmptySlot = computed(() => {
598
606
  v-show="canDisplayItem(Items[i], i)"
599
607
  :key="getRowKey(item, i)"
600
608
  :i="i"
601
- :drop-button="dropButton"
609
+ :drop-button="safeDropModeButton"
602
610
  :edit-button="editButton"
603
611
  :display-hidden-columns-indicator="displayHiddenColumnsIndicator"
604
612
  :is-draggable="isDraggable(item)"
@@ -615,11 +623,11 @@ const hasEmptySlot = computed(() => {
615
623
  :row-display-type="rowDisplayType"
616
624
  :render-drag="computedRenderDrag"
617
625
  :disabled-drag="computedDisabledDrag"
618
- v-on:click="onClick"
619
- v-on:show="show"
620
- v-on:item-up="onItemUp"
621
- v-on:item-down="onItemDown"
622
- v-on:item-drop="onItemDrop"
626
+ @click="onClick"
627
+ @show="show"
628
+ @item-up="onItemUp"
629
+ @item-down="onItemDown"
630
+ @item-drop="onItemDrop"
623
631
  >
624
632
  <template v-if="slots[`item-${i}`]" v-slot:[`item-${i}`]="row">
625
633
  <slot
@@ -661,8 +669,8 @@ const hasEmptySlot = computed(() => {
661
669
  :hidden-is-visible="isVisible(i)"
662
670
  :edit-mode-enabled="editModeEnabled"
663
671
  :has-inline-edit-perm="hasInlineEditPerm"
664
- v-on:click="onClick"
665
- v-on:show="show"
672
+ @click="onClick"
673
+ @show="show"
666
674
  >
667
675
  <template
668
676
  v-for="column in colSlots"
@@ -724,6 +732,48 @@ const hasEmptySlot = computed(() => {
724
732
  </li>
725
733
  </template>
726
734
  </component>
735
+
736
+ <div v-else-if="type === TableType.Carousel"
737
+ ref="tableBody"
738
+ :id="'lkt-table-body-' + uniqueId"
739
+ class="lkt-table-items-container"
740
+ :class="itemsContainerClass">
741
+ <carousel
742
+ v-model="currentSlide"
743
+ v-bind="carousel"
744
+ >
745
+ <template v-for="(slide, i) in slides" :key="slide">
746
+ <slide :index="i">
747
+ <div class="lkt-carousel-slide">
748
+ <slot :name="slide"/>
749
+ </div>
750
+ </slide>
751
+ </template>
752
+
753
+ <template v-for="(item, i) in Items" :key="slide">
754
+ <slide :index="i">
755
+ <div class="lkt-carousel-slide">
756
+ <slot name="item"
757
+ v-bind:[slotItemVar]="item"
758
+ v-bind:index="i"
759
+ v-bind:editing="editModeEnabled"
760
+ v-bind:can-create="hasCreatePerm"
761
+ v-bind:can-read="hasReadPerm"
762
+ v-bind:can-update="hasUpdatePerm"
763
+ v-bind:can-drop="hasDropPerm"
764
+ v-bind:is-loading="isLoading"
765
+ v-bind:do-drop="() => onItemDrop(i)"
766
+ />
767
+ </div>
768
+ </slide>
769
+ </template>
770
+
771
+ <template #addons>
772
+ <Navigation />
773
+ <Pagination />
774
+ </template>
775
+ </carousel>
776
+ </div>
727
777
  </div>
728
778
 
729
779
  <div class="lkt-table-empty" v-if="!isLoading && Items.length === 0">