lkt-table 2.0.3 → 2.0.5

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.
@@ -1,24 +1,13 @@
1
- import { LktObject } from "lkt-vue-kernel";
1
+ import { ButtonConfig } from "lkt-vue-kernel";
2
2
  type __VLS_Props = {
3
+ config?: ButtonConfig;
3
4
  disabled?: boolean;
4
- text: string;
5
- icon?: string;
6
- confirm?: string;
7
- link?: string;
8
- resource?: string;
9
- resourceData?: LktObject;
10
5
  };
11
6
  declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
7
  click: (...args: any[]) => void;
13
8
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
9
  onClick?: ((...args: any[]) => any) | undefined;
15
10
  }>, {
16
- link: string;
17
11
  disabled: boolean;
18
- resource: string;
19
- resourceData: LktObject;
20
- text: string;
21
- icon: string;
22
- confirm: string;
23
12
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
13
  export default _default;
@@ -8,6 +8,7 @@ declare const slots: Readonly<{
8
8
  }>;
9
9
  type __VLS_Props = {
10
10
  modelValue: LktObject;
11
+ editButton: ButtonConfig;
11
12
  dropButton: ButtonConfig;
12
13
  isDraggable: boolean;
13
14
  sortable: boolean;
@@ -22,9 +23,6 @@ type __VLS_Props = {
22
23
  i: number;
23
24
  visibleColumns: Column[];
24
25
  emptyColumns: string[];
25
- editText: string;
26
- editIcon: string;
27
- editLink: string;
28
26
  rowDisplayType: ValidTableRowTypeValue;
29
27
  renderDrag?: boolean | Function;
30
28
  disabledDrag?: boolean | Function;
@@ -32,28 +30,27 @@ type __VLS_Props = {
32
30
  declare const Item: import("vue").Ref<LktObject, LktObject>;
33
31
  declare const canCustomItem: boolean;
34
32
  declare const canItem: boolean;
35
- declare const parsedEditLink: import("vue").Ref<string, string>;
36
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;
37
34
  declare const canRenderDragIndicator: import("vue").ComputedRef<any>;
38
35
  declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
39
- declare var __VLS_26: `item-${number}`, __VLS_27: {
36
+ declare var __VLS_24: `item-${number}`, __VLS_25: {
40
37
  item: LktObject;
41
38
  index: number;
42
- }, __VLS_29: {
39
+ }, __VLS_27: {
43
40
  item: LktObject;
44
41
  index: number;
45
- }, __VLS_32: string, __VLS_33: {
42
+ }, __VLS_30: string, __VLS_31: {
46
43
  value: any;
47
44
  item: LktObject;
48
45
  column: Column;
49
46
  i: number;
50
47
  };
51
48
  type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
52
- [K in NonNullable<typeof __VLS_26>]?: (props: typeof __VLS_27) => any;
49
+ [K in NonNullable<typeof __VLS_24>]?: (props: typeof __VLS_25) => any;
53
50
  } & {
54
- [K in NonNullable<typeof __VLS_32>]?: (props: typeof __VLS_33) => any;
51
+ [K in NonNullable<typeof __VLS_30>]?: (props: typeof __VLS_31) => any;
55
52
  } & {
56
- item?: (props: typeof __VLS_29) => any;
53
+ item?: (props: typeof __VLS_27) => any;
57
54
  }>;
58
55
  declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
59
56
  canRenderColumn: typeof canRenderColumn;
@@ -68,7 +65,6 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
68
65
  Item: typeof Item;
69
66
  canCustomItem: typeof canCustomItem;
70
67
  canItem: typeof canItem;
71
- parsedEditLink: typeof parsedEditLink;
72
68
  onClick: typeof onClick;
73
69
  onShow: typeof onShow;
74
70
  classes: typeof classes;
@@ -107,9 +103,6 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
107
103
  canEdit: boolean;
108
104
  visibleColumns: Column[];
109
105
  emptyColumns: string[];
110
- editText: string;
111
- editIcon: string;
112
- editLink: string;
113
106
  rowDisplayType: ValidTableRowTypeValue;
114
107
  renderDrag: boolean | Function;
115
108
  disabledDrag: boolean | Function;
@@ -142,9 +135,6 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}
142
135
  canEdit: boolean;
143
136
  visibleColumns: Column[];
144
137
  emptyColumns: string[];
145
- editText: string;
146
- editIcon: string;
147
- editLink: string;
148
138
  rowDisplayType: ValidTableRowTypeValue;
149
139
  renderDrag: boolean | Function;
150
140
  disabledDrag: boolean | Function;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-table",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -50,16 +50,16 @@
50
50
  "sortablejs": "^1.15.6"
51
51
  },
52
52
  "peerDependencies": {
53
- "lkt-button": "^2.0",
54
- "lkt-data-state": "^1.0.10",
53
+ "lkt-button": "^2.0.7",
54
+ "lkt-data-state": "^1.0.11",
55
55
  "lkt-date-tools": "^1.0.4",
56
56
  "lkt-field": "^0.0.34",
57
- "lkt-http-client": "^1.0.19",
58
- "lkt-i18n": "^1.0.4",
59
- "lkt-loader": "^1.0.2",
60
- "lkt-paginator": "^1.3.0",
61
- "lkt-string-tools": "^1.0.3",
62
- "lkt-vue-kernel": "^1.0.4",
57
+ "lkt-http-client": "^1.0.34",
58
+ "lkt-i18n": "^1.0.6",
59
+ "lkt-loader": "^1.2.0",
60
+ "lkt-paginator": "^1.3.3",
61
+ "lkt-string-tools": "^1.1.0",
62
+ "lkt-vue-kernel": "^1.0.35",
63
63
  "vue": "^3.3",
64
64
  "vue-router": "^4.2.5"
65
65
  }
@@ -1,26 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import {computed} from "vue";
3
3
  import {Settings} from "../settings/Settings";
4
- import {LktObject} from "lkt-vue-kernel";
4
+ import {ButtonConfig} from "lkt-vue-kernel";
5
5
 
6
6
  const emit = defineEmits(['click']);
7
7
 
8
8
  const props = withDefaults(defineProps<{
9
+ config?: ButtonConfig
9
10
  disabled?: boolean
10
- text: string
11
- icon?: string
12
- confirm?: string
13
- link?: string
14
- resource?: string
15
- resourceData?: LktObject
16
11
  }>(), {
17
12
  disabled: false,
18
- text: '',
19
- icon: '',
20
- link: '',
21
- confirm: '',
22
- resource: '',
23
- resourceData: () => ({}),
24
13
  });
25
14
 
26
15
  const hasButtonSlot = computed(() => Settings.editButtonSlot !== ''),
@@ -30,13 +19,9 @@ const hasButtonSlot = computed(() => Settings.editButtonSlot !== ''),
30
19
  <template>
31
20
  <lkt-button
32
21
  palette="table-delete"
33
- :icon="hasButtonSlot ? '' : icon"
34
- :text="hasButtonSlot ? '' : text"
35
- :on-click-to="link"
36
- :is-anchor="link !== ''"
37
- :resource="resource"
38
- :resource-data="resourceData"
39
- :confirm-modal="confirm"
22
+ v-bind="props.config"
23
+ :icon="hasButtonSlot ? '' : config?.icon"
24
+ :text="hasButtonSlot ? '' : config?.text"
40
25
  :disabled="disabled"
41
26
  @click.prevent.stop="emit('click')">
42
27
  <template v-if="hasButtonSlot">
@@ -25,9 +25,6 @@ const item = ref(props.modelValue),
25
25
  value = ref(item.value[props.column.key]),
26
26
  inputElement = ref(null);
27
27
 
28
- let calculatedColumnType = props.column.type;
29
- if ([ColumnType.Integer, ColumnType.Float].includes(calculatedColumnType)) calculatedColumnType = ColumnType.Number;
30
-
31
28
  watch(value, (v) => {
32
29
  const payload = JSON.parse(JSON.stringify(item.value));
33
30
  payload[props.column.key] = v;
@@ -19,6 +19,7 @@ const emit = defineEmits(['update:modelValue', 'click', 'show', 'item-up', 'item
19
19
 
20
20
  const props = withDefaults(defineProps<{
21
21
  modelValue: LktObject
22
+ editButton: ButtonConfig
22
23
  dropButton: ButtonConfig
23
24
  isDraggable: boolean
24
25
  sortable: boolean
@@ -33,9 +34,6 @@ const props = withDefaults(defineProps<{
33
34
  i: number
34
35
  visibleColumns: Column[]
35
36
  emptyColumns: string[]
36
- editText: string
37
- editIcon: string
38
- editLink: string
39
37
  rowDisplayType: ValidTableRowTypeValue
40
38
  renderDrag?: boolean | Function
41
39
  disabledDrag?: boolean | Function
@@ -53,9 +51,6 @@ const props = withDefaults(defineProps<{
53
51
  i: 0,
54
52
  visibleColumns: () => [],
55
53
  emptyColumns: () => [],
56
- editText: '',
57
- editIcon: '',
58
- editLink: '',
59
54
  rowDisplayType: TableRowType.Auto,
60
55
  renderDrag: true,
61
56
  disabledDrag: true,
@@ -69,7 +64,7 @@ if (!calculatedRowDisplayType) calculatedRowDisplayType = TableRowType.Auto;
69
64
  const canCustomItem = [TableRowType.Auto, TableRowType.PreferCustomItem].includes(calculatedRowDisplayType);
70
65
  const canItem = [TableRowType.Auto, TableRowType.PreferItem].includes(calculatedRowDisplayType);
71
66
 
72
- const parsedEditLink = ref(props.editLink);
67
+ const parsedEditLink = ref(props.editButton.anchor?.to);
73
68
  for (let k in Item.value) parsedEditLink.value = replaceAll(parsedEditLink.value, ':' + k, Item.value[k]);
74
69
 
75
70
  const onClick = ($event: any) => emit('click', $event),
@@ -205,10 +200,7 @@ const canRenderDragIndicator = computed(() => {
205
200
  </td>
206
201
  <td v-if="canEdit && editModeEnabled" class="lkt-table-col-edit">
207
202
  <edit-button
208
- :resource-data="Item"
209
- :text="editText"
210
- :icon="editIcon"
211
- :link="parsedEditLink"
203
+ :config="editButton"
212
204
  @click="onClickEdit"/>
213
205
  </td>
214
206
  </tr>
@@ -1,8 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import {getColumnClasses, getVerticalColSpan} from "../functions/table-functions";
3
- import {Column, LktObject} from "lkt-vue-kernel";
3
+ import {Column, extractI18nValue, LktObject, LktSettings, SortDirection} from "lkt-vue-kernel";
4
4
  import {computed} from "vue";
5
- import {__} from "lkt-i18n";
6
5
 
7
6
  const emit = defineEmits(['click']);
8
7
 
@@ -33,10 +32,16 @@ const computedColSpan = computed(() => {
33
32
  return '';
34
33
  }),
35
34
  computedLabel = computed(() => {
36
- if (props.column.label.startsWith('__:')) {
37
- return __(props.column.label.substring(3));
35
+ return extractI18nValue(props.column.label);
36
+ }),
37
+ computedSortableIcon = computed(() => {
38
+ if (!computedSortable.value) return '';
39
+ if (props.sortBy === props.column.key) {
40
+ if (props.sortDirection === SortDirection.Asc) return LktSettings.defaultTableSortAscIcon;
41
+ if (props.sortDirection === SortDirection.Desc) return LktSettings.defaultTableSortDescIcon;
42
+ return '';
38
43
  }
39
- return props.column.label;
44
+ return '';
40
45
  });
41
46
 
42
47
  const onClick = () => emit('click', props.column)
@@ -51,6 +56,6 @@ const onClick = () => emit('click', props.column)
51
56
  :class="getColumnClasses(column)"
52
57
  v-on:click="onClick"
53
58
  >
54
- <div>{{ computedLabel }}</div>
59
+ <div>{{ computedLabel }} <i v-if="computedSortableIcon" :class="computedSortableIcon"/> </div>
55
60
  </th>
56
61
  </template>
@@ -9,7 +9,8 @@ import {
9
9
  extractI18nValue,
10
10
  getDefaultValues,
11
11
  LktObject,
12
- LktSettings, PaginatorType,
12
+ LktSettings,
13
+ PaginatorType,
13
14
  SortDirection,
14
15
  Table,
15
16
  TableConfig,
@@ -72,6 +73,7 @@ const Page = ref(props.paginator?.modelValue),
72
73
 
73
74
  const safeSaveButton = ref(ensureButtonConfig(props.saveButton, LktSettings.defaultSaveButton));
74
75
  const safeCreateButton = ref(ensureButtonConfig(props.createButton, LktSettings.defaultCreateButton));
76
+ const safeEditModeButton = ref(ensureButtonConfig(props.editModeButton, LktSettings.defaultEditModeButton));
75
77
 
76
78
  const dataStateChanged = ref(false);
77
79
 
@@ -195,9 +197,6 @@ const emptyColumns = computed(() => {
195
197
  computedTitle = computed(() => {
196
198
  return extractI18nValue(props.title);
197
199
  }),
198
- computedEditModeText = computed(() => {
199
- return extractI18nValue(props.editModeText);
200
- }),
201
200
  computedDragModeEnabled = computed(() => {
202
201
  return props.drag?.enabled;
203
202
  }),
@@ -264,6 +263,7 @@ const getItemByEvent = (e: any) => {
264
263
  });
265
264
  SortingDirection.value = SortingDirection.value === SortDirection.Asc ? SortDirection.Desc : SortDirection.Asc;
266
265
  SortBy.value = column.key;
266
+ updateTimeStamp.value = time();
267
267
  emit('sort', [SortBy.value, SortingDirection.value]);
268
268
  }
269
269
  },
@@ -544,10 +544,9 @@ const hasEmptySlot = computed(() => {
544
544
 
545
545
  <div class="switch-edition-mode">
546
546
  <lkt-field
547
- type="switch"
547
+ v-bind="safeEditModeButton"
548
548
  v-show="showSwitchButton"
549
- v-model="editModeEnabled"
550
- :label="computedEditModeText"/>
549
+ v-model="editModeEnabled"/>
551
550
  </div>
552
551
  </div>
553
552
 
@@ -576,7 +575,7 @@ const hasEmptySlot = computed(() => {
576
575
  :sort-direction="SortingDirection"
577
576
  :amount-of-columns="columns.length"
578
577
  :items="Items"
579
- v-on:click="sort(column)"
578
+ @click="sort(column)"
580
579
  />
581
580
  </template>
582
581
  <th
@@ -599,6 +598,8 @@ const hasEmptySlot = computed(() => {
599
598
  v-show="canDisplayItem(Items[i], i)"
600
599
  :key="getRowKey(item, i)"
601
600
  :i="i"
601
+ :drop-button="dropButton"
602
+ :edit-button="editButton"
602
603
  :display-hidden-columns-indicator="displayHiddenColumnsIndicator"
603
604
  :is-draggable="isDraggable(item)"
604
605
  :sortable="computedDragModeEnabled"
@@ -609,9 +610,6 @@ const hasEmptySlot = computed(() => {
609
610
  :latest-row="i+1 === amountOfItems"
610
611
  :can-drop="hasDropPerm && editModeEnabled"
611
612
  :can-edit="hasEditPerm && hasUpdatePerm && editModeEnabled"
612
- :edit-text="editText"
613
- :edit-icon="editIcon"
614
- :edit-link="editLink"
615
613
  :edit-mode-enabled="editModeEnabled"
616
614
  :has-inline-edit-perm="hasInlineEditPerm"
617
615
  :row-display-type="rowDisplayType"