lkt-step-process 2.0.9 → 2.0.11

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-step-process",
3
- "version": "2.0.9",
3
+ "version": "2.0.11",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -13,7 +13,10 @@
13
13
  "./theme/default": "./theme/default.css"
14
14
  },
15
15
  "types": "./dist/index.d.ts",
16
- "files": ["dist/*", "src/**/*.vue"],
16
+ "files": [
17
+ "dist/*",
18
+ "src/**/*.vue"
19
+ ],
17
20
  "license": "MIT",
18
21
  "sideEffects": false,
19
22
  "scripts": {
@@ -32,10 +32,9 @@
32
32
  v-show="!isLoading"
33
33
  v-bind="prevButton"
34
34
  class="is-prev-button"
35
- @click="emit('prev')"
36
35
  />
37
36
 
38
- <div class="lkt-step-process--nav-info">
37
+ <div class="lkt-step-process--nav-info" v-if="slots['nav-info'] || dots && amountOfSteps > 0">
39
38
  <template v-if="slots['nav-info']">
40
39
  <slot
41
40
  name="nav-info"
@@ -65,7 +64,6 @@
65
64
  v-show="!isLoading"
66
65
  v-bind="nextButton"
67
66
  class="is-next-button"
68
- @click="emit('next')"
69
67
  />
70
68
  </div>
71
69
  </template>
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, onMounted, ref, useSlots, watch } from 'vue';
3
3
  import {
4
- ButtonConfig,
4
+ ButtonConfig, ClickEventArgs,
5
5
  getDefaultValues,
6
6
  ItemCrudButtonNavPosition,
7
7
  ItemCrudButtonNavVisibility,
@@ -70,7 +70,24 @@
70
70
  if (typeof r.disabled === 'undefined') {
71
71
  r.disabled = prevDisabled.value;
72
72
  }
73
- return r;
73
+
74
+ const clientClickEvent = r.events?.click;
75
+
76
+ return {
77
+ ...r,
78
+ events: {
79
+ ...r.events,
80
+ click: (data: ClickEventArgs) => {
81
+
82
+ if (typeof clientClickEvent === 'function') clientClickEvent(data);
83
+
84
+ if (data.httpResponse?.success === false) {
85
+ return;
86
+ }
87
+ onPrev(data);
88
+ }
89
+ }
90
+ };
74
91
  }),
75
92
  computedNextButton = computed(() => {
76
93
  if (currentStepConfig.value?.nextButton === false) {
@@ -90,7 +107,24 @@
90
107
  if (typeof currentStepConfig.value?.nextButton === 'object') {
91
108
  r = { ...r, ...currentStepConfig.value?.nextButton };
92
109
  }
93
- return r;
110
+
111
+ const clientClickEvent = r.events?.click;
112
+
113
+ return {
114
+ ...r,
115
+ events: {
116
+ ...r.events,
117
+ click: (data: ClickEventArgs) => {
118
+
119
+ if (typeof clientClickEvent === 'function') clientClickEvent(data);
120
+
121
+ if (data.httpResponse?.success === false) {
122
+ return;
123
+ }
124
+ onNext(data);
125
+ }
126
+ }
127
+ };
94
128
  }),
95
129
  classes = computed(() => {
96
130
  const r = [];
@@ -119,6 +153,12 @@
119
153
  dots: props.dots,
120
154
  dotsNumbers: props.dotsNumbers,
121
155
  };
156
+ }),
157
+ computedHasButtonNavContent = computed(() => {
158
+ return typeof computedPrevButton.value === 'object'
159
+ || typeof computedNextButton.value === 'object'
160
+ || props.dots
161
+ || typeof slots['nav-info'] !== 'undefined';
122
162
  });
123
163
 
124
164
  const onNext = (data: any) => {
@@ -139,11 +179,11 @@
139
179
  defineExpose({
140
180
  goNext: () => {
141
181
  // @ts-ignore
142
- navRef.value.click();
182
+ navRef.value.goNext();
143
183
  },
144
184
  goPrev: () => {
145
185
  // @ts-ignore
146
- navRef.value.click();
186
+ navRef.value.goPrev();
147
187
  },
148
188
  startLoader: () => isLoading.value = true,
149
189
  stopLoader: () => isLoading.value = false,
@@ -159,10 +199,9 @@
159
199
  <lkt-header v-if="header && Object.keys(header).length > 0" v-bind="header" />
160
200
 
161
201
  <button-nav
162
- v-if="computedRenderTopButtonNav"
202
+ v-if="computedRenderTopButtonNav && computedHasButtonNavContent"
203
+ ref="navRef"
163
204
  v-bind="computedButtonNavProps"
164
- @prev="onPrev"
165
- @next="onNext"
166
205
  >
167
206
  <template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
168
207
  <slot
@@ -188,10 +227,9 @@
188
227
  <lkt-loader v-if="isLoading" />
189
228
 
190
229
  <button-nav
191
- v-if="computedRenderBottomButtonNav"
230
+ v-if="computedRenderBottomButtonNav && computedHasButtonNavContent"
231
+ ref="navRef"
192
232
  v-bind="computedButtonNavProps"
193
- @prev="onPrev"
194
- @next="onNext"
195
233
  >
196
234
  <template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
197
235
  <slot