lkt-step-process 2.0.14 → 2.0.16
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/dist/build.d.ts +2 -2
- package/dist/build.js +198 -168
- package/dist/components/ButtonNav.vue.d.ts +1 -0
- package/dist/config/ButtonNavProps.d.ts +3 -1
- package/dist/lib-components/LktStepProcess.vue.d.ts +1575 -1040
- package/package.json +1 -1
- package/src/components/ButtonNav.vue +12 -5
- package/src/lib-components/LktStepProcess.vue +53 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
|
|
3
3
|
import { ButtonNavProps } from '../config/ButtonNavProps';
|
|
4
|
-
import { ref, SetupContext, useSlots } from 'vue';
|
|
4
|
+
import { computed, ref, SetupContext, useSlots } from 'vue';
|
|
5
5
|
import { DotConfig } from 'lkt-vue-kernel';
|
|
6
6
|
|
|
7
7
|
const props = withDefaults(defineProps<ButtonNavProps>(), {});
|
|
@@ -22,10 +22,16 @@
|
|
|
22
22
|
prevButtonRef.value.click();
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
const stepHasDotsInfo = computed(() => {
|
|
27
|
+
if (typeof props.currentStepConfig?.excludedFromTotalCount === 'function') return !props.currentStepConfig.excludedFromTotalCount();
|
|
28
|
+
if (typeof props.currentStepConfig?.excludedFromTotalCount === 'boolean') return !props.currentStepConfig.excludedFromTotalCount;
|
|
29
|
+
return true;
|
|
30
|
+
})
|
|
25
31
|
</script>
|
|
26
32
|
|
|
27
33
|
<template>
|
|
28
|
-
<div class="lkt-step-process--nav">
|
|
34
|
+
<div class="lkt-step-process--nav" v-if="prevButton || nextButton || (stepHasDotsInfo && (slots['nav-info'] || dots && amountOfSteps > 0))">
|
|
29
35
|
<lkt-button
|
|
30
36
|
ref="prevButtonRef"
|
|
31
37
|
v-if="prevButton"
|
|
@@ -34,11 +40,12 @@
|
|
|
34
40
|
class="is-prev-button"
|
|
35
41
|
/>
|
|
36
42
|
|
|
37
|
-
<div class="lkt-step-process--nav-info" v-if="slots['nav-info'] || dots && amountOfSteps > 0">
|
|
43
|
+
<div class="lkt-step-process--nav-info" v-if="stepHasDotsInfo && (slots['nav-info'] || dots && amountOfSteps > 0)">
|
|
38
44
|
<template v-if="slots['nav-info']">
|
|
39
45
|
<slot
|
|
40
46
|
name="nav-info"
|
|
41
47
|
v-bind="{
|
|
48
|
+
visibleStep: visibleStepIndex,
|
|
42
49
|
currentStep,
|
|
43
50
|
currentStepIndex,
|
|
44
51
|
amountOfSteps,
|
|
@@ -46,12 +53,12 @@
|
|
|
46
53
|
/>
|
|
47
54
|
</template>
|
|
48
55
|
|
|
49
|
-
<div class="lkt-step-process--dots" v-if="dots && amountOfSteps > 0">
|
|
56
|
+
<div class="lkt-step-process--dots" v-if="dots && amountOfSteps > 0 && stepHasDotsInfo">
|
|
50
57
|
<lkt-dot
|
|
51
58
|
v-for="n in amountOfSteps"
|
|
52
59
|
v-bind="<DotConfig>{
|
|
53
60
|
text: dotsNumbers ? n : '',
|
|
54
|
-
class: n ===
|
|
61
|
+
class: n === visibleStepIndex ? 'is-active' : '',
|
|
55
62
|
}"
|
|
56
63
|
/>
|
|
57
64
|
</div>
|
|
@@ -49,6 +49,20 @@
|
|
|
49
49
|
const currentStepIndex = computed(() => {
|
|
50
50
|
return stepsHaystack.value.findIndex((step: StepProcessStepConfig) => step.key === currentStep.value);
|
|
51
51
|
}),
|
|
52
|
+
visibleStepIndex = computed(() => {
|
|
53
|
+
let baseIndex = stepsHaystack.value.findIndex((step: StepProcessStepConfig) => step.key === currentStep.value);
|
|
54
|
+
let r = baseIndex;
|
|
55
|
+
for (let i = 0; i < baseIndex; ++i) {
|
|
56
|
+
let excluded = false,
|
|
57
|
+
excludedValue = stepsHaystack.value[i].excludedFromTotalCount;
|
|
58
|
+
|
|
59
|
+
if (typeof excludedValue === 'function') excluded = excludedValue() === true;
|
|
60
|
+
else if (typeof excludedValue === 'boolean') excluded = excludedValue === true;
|
|
61
|
+
|
|
62
|
+
if (excluded) --r;
|
|
63
|
+
}
|
|
64
|
+
return r + 1;
|
|
65
|
+
}),
|
|
52
66
|
currentStepConfig = computed(() => {
|
|
53
67
|
return stepsHaystack.value[currentStepIndex.value];
|
|
54
68
|
}),
|
|
@@ -146,7 +160,15 @@
|
|
|
146
160
|
return props.buttonNavPosition === ItemCrudButtonNavPosition.Bottom;
|
|
147
161
|
}),
|
|
148
162
|
computedAmountOfSteps = computed(() => {
|
|
149
|
-
|
|
163
|
+
let r = 0;
|
|
164
|
+
stepsHaystack.value.forEach(step => {
|
|
165
|
+
let excluded = false;
|
|
166
|
+
if (typeof step.excludedFromTotalCount === 'function') excluded = step.excludedFromTotalCount() === true;
|
|
167
|
+
else if (typeof step.excludedFromTotalCount === 'boolean') excluded = step.excludedFromTotalCount === true;
|
|
168
|
+
|
|
169
|
+
if (!excluded) ++r;
|
|
170
|
+
})
|
|
171
|
+
return r;
|
|
150
172
|
}),
|
|
151
173
|
computedButtonNavProps = computed(() => {
|
|
152
174
|
return <ButtonNavProps>{
|
|
@@ -154,7 +176,9 @@
|
|
|
154
176
|
prevButton: computedPrevButton.value,
|
|
155
177
|
nextButton: computedNextButton.value,
|
|
156
178
|
currentStep: currentStep.value,
|
|
179
|
+
currentStepConfig: currentStepConfig.value,
|
|
157
180
|
currentStepIndex: currentStepIndex.value,
|
|
181
|
+
visibleStepIndex: visibleStepIndex.value,
|
|
158
182
|
amountOfSteps: computedAmountOfSteps.value,
|
|
159
183
|
dots: props.dots,
|
|
160
184
|
dotsNumbers: props.dotsNumbers,
|
|
@@ -168,6 +192,8 @@
|
|
|
168
192
|
});
|
|
169
193
|
|
|
170
194
|
const onNext = (data: any) => {
|
|
195
|
+
let fromStep = currentStep.value;
|
|
196
|
+
|
|
171
197
|
let nextKey = stepsHaystack.value[currentStepIndex.value]?.nextKey;
|
|
172
198
|
let nextIndex = currentStepIndex.value + 1;
|
|
173
199
|
|
|
@@ -180,7 +206,16 @@
|
|
|
180
206
|
if (needle > -1) nextIndex = needle;
|
|
181
207
|
}
|
|
182
208
|
|
|
183
|
-
|
|
209
|
+
let toStep = stepsHaystack.value[nextIndex].key;
|
|
210
|
+
|
|
211
|
+
if (typeof currentStepConfig.value?.events?.leave === 'function') {
|
|
212
|
+
currentStepConfig.value?.events?.leave({to: toStep})
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
currentStep.value = toStep;
|
|
216
|
+
if (typeof currentStepConfig.value?.events?.enter === 'function') {
|
|
217
|
+
currentStepConfig.value?.events?.enter({from: fromStep})
|
|
218
|
+
}
|
|
184
219
|
if (currentStepIndex.value === (stepsHaystack.value.length - 1)) {
|
|
185
220
|
emit('finish', data);
|
|
186
221
|
|
|
@@ -189,6 +224,8 @@
|
|
|
189
224
|
}
|
|
190
225
|
},
|
|
191
226
|
onPrev = (data: any) => {
|
|
227
|
+
let fromStep = currentStep.value;
|
|
228
|
+
|
|
192
229
|
let prevKey = stepsHaystack.value[currentStepIndex.value]?.prevKey;
|
|
193
230
|
let nextIndex = currentStepIndex.value - 1;
|
|
194
231
|
|
|
@@ -201,7 +238,16 @@
|
|
|
201
238
|
if (needle > -1) nextIndex = needle;
|
|
202
239
|
}
|
|
203
240
|
|
|
204
|
-
|
|
241
|
+
let toStep = stepsHaystack.value[nextIndex].key;
|
|
242
|
+
|
|
243
|
+
if (typeof currentStepConfig.value?.events?.leave === 'function') {
|
|
244
|
+
currentStepConfig.value?.events?.leave({to: toStep})
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
currentStep.value = toStep;
|
|
248
|
+
if (typeof currentStepConfig.value?.events?.enter === 'function') {
|
|
249
|
+
currentStepConfig.value?.events?.enter({from: fromStep})
|
|
250
|
+
}
|
|
205
251
|
emit('prev', data);
|
|
206
252
|
},
|
|
207
253
|
canRenderStep = (stepKey:string) => {
|
|
@@ -273,10 +319,11 @@
|
|
|
273
319
|
ref="navRef"
|
|
274
320
|
v-bind="computedButtonNavProps"
|
|
275
321
|
>
|
|
276
|
-
<template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
|
|
322
|
+
<template #nav-info="{currentStep, currentStepIndex, amountOfSteps, visibleStep}" v-if="slots['nav-info']">
|
|
277
323
|
<slot
|
|
278
324
|
name="nav-info"
|
|
279
325
|
v-bind="{
|
|
326
|
+
visibleStep,
|
|
280
327
|
currentStep,
|
|
281
328
|
currentStepIndex,
|
|
282
329
|
amountOfSteps: computedAmountOfSteps,
|
|
@@ -301,10 +348,11 @@
|
|
|
301
348
|
ref="navRef"
|
|
302
349
|
v-bind="computedButtonNavProps"
|
|
303
350
|
>
|
|
304
|
-
<template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
|
|
351
|
+
<template #nav-info="{currentStep, currentStepIndex, amountOfSteps, visibleStep}" v-if="slots['nav-info']">
|
|
305
352
|
<slot
|
|
306
353
|
name="nav-info"
|
|
307
354
|
v-bind="{
|
|
355
|
+
visibleStep,
|
|
308
356
|
currentStep,
|
|
309
357
|
currentStepIndex,
|
|
310
358
|
amountOfSteps: computedAmountOfSteps,
|