lkt-table 2.0.3 → 2.0.4

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,7 +30,6 @@ 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 () => {}>>;
@@ -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.4",
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.0.8",
62
+ "lkt-vue-kernel": "^1.0.31",
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>
@@ -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
  }),
@@ -544,10 +543,9 @@ const hasEmptySlot = computed(() => {
544
543
 
545
544
  <div class="switch-edition-mode">
546
545
  <lkt-field
547
- type="switch"
546
+ v-bind="safeEditModeButton"
548
547
  v-show="showSwitchButton"
549
- v-model="editModeEnabled"
550
- :label="computedEditModeText"/>
548
+ v-model="editModeEnabled"/>
551
549
  </div>
552
550
  </div>
553
551
 
@@ -599,6 +597,8 @@ const hasEmptySlot = computed(() => {
599
597
  v-show="canDisplayItem(Items[i], i)"
600
598
  :key="getRowKey(item, i)"
601
599
  :i="i"
600
+ :drop-button="dropButton"
601
+ :edit-button="editButton"
602
602
  :display-hidden-columns-indicator="displayHiddenColumnsIndicator"
603
603
  :is-draggable="isDraggable(item)"
604
604
  :sortable="computedDragModeEnabled"
@@ -609,9 +609,6 @@ const hasEmptySlot = computed(() => {
609
609
  :latest-row="i+1 === amountOfItems"
610
610
  :can-drop="hasDropPerm && editModeEnabled"
611
611
  :can-edit="hasEditPerm && hasUpdatePerm && editModeEnabled"
612
- :edit-text="editText"
613
- :edit-icon="editIcon"
614
- :edit-link="editLink"
615
612
  :edit-mode-enabled="editModeEnabled"
616
613
  :has-inline-edit-perm="hasInlineEditPerm"
617
614
  :row-display-type="rowDisplayType"