lkt-step-process 1.2.1 → 2.0.1
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 +3 -3
- package/dist/build.js +110 -88
- package/dist/lib-components/LktStepProcess.vue.d.ts +2691 -185
- package/package.json +5 -5
- package/src/lib-components/LktStepProcess.vue +125 -186
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-step-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/build.js",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"vue-tsc": "^2.2.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"lkt-button": "^2.0.
|
|
37
|
+
"lkt-button": "^2.0.23",
|
|
38
38
|
"lkt-data-state": "^1.0.11",
|
|
39
|
-
"lkt-http-client": "^1.0
|
|
39
|
+
"lkt-http-client": "^1.1.0",
|
|
40
40
|
"lkt-http-info": "^1.1.1",
|
|
41
41
|
"lkt-loader": "^1.2.0",
|
|
42
|
-
"lkt-string-tools": "^1.0
|
|
43
|
-
"lkt-vue-kernel": "^1.0.
|
|
42
|
+
"lkt-string-tools": "^1.1.0",
|
|
43
|
+
"lkt-vue-kernel": "^1.0.87",
|
|
44
44
|
"path": "^0.12.7",
|
|
45
45
|
"vue": "^3.3.0"
|
|
46
46
|
}
|
|
@@ -1,208 +1,147 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {ref, useSlots,
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return r;
|
|
40
|
-
})
|
|
2
|
+
import { computed, ref, useSlots, watch } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
ButtonConfig,
|
|
5
|
+
getDefaultValues,
|
|
6
|
+
StepProcess,
|
|
7
|
+
StepProcessConfig,
|
|
8
|
+
StepProcessStepConfig,
|
|
9
|
+
} from 'lkt-vue-kernel';
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<StepProcessConfig>(), getDefaultValues(StepProcess));
|
|
12
|
+
|
|
13
|
+
const slots = useSlots();
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits([
|
|
16
|
+
'next',
|
|
17
|
+
'prev',
|
|
18
|
+
'finish',
|
|
19
|
+
'update:modelValue',
|
|
20
|
+
'update:loading',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const isLoading = ref(props.loading),
|
|
24
|
+
currentStep = ref(props.modelValue),
|
|
25
|
+
stepsHaystack = ref(props.steps),
|
|
26
|
+
prevButtonRef = ref(null),
|
|
27
|
+
nextButtonRef = ref(null);
|
|
28
|
+
|
|
29
|
+
watch(() => props.loading, (value) => isLoading.value = value);
|
|
30
|
+
watch(() => props.modelValue, (value) => currentStep.value = value);
|
|
31
|
+
watch(isLoading, (value) => emit('update:loading', value));
|
|
32
|
+
watch(currentStep, (value) => emit('update:modelValue', value));
|
|
33
|
+
|
|
34
|
+
const slotsSteps = computed(() => {
|
|
35
|
+
let r = [];
|
|
36
|
+
for (let k in slots) if (k.indexOf('step-') !== -1) r.push(k.substring(5));
|
|
37
|
+
return r;
|
|
38
|
+
});
|
|
41
39
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const currentStepIndex = computed(() => {
|
|
41
|
+
return stepsHaystack.value.findIndex((step: StepProcessStepConfig) => step.key === currentStep.value);
|
|
42
|
+
}),
|
|
43
|
+
currentStepConfig = computed(() => {
|
|
44
|
+
return stepsHaystack.value[currentStepIndex.value];
|
|
45
|
+
}),
|
|
46
|
+
prevDisabled = computed(() => {
|
|
47
|
+
return currentStepIndex.value === 0;
|
|
48
|
+
}),
|
|
49
|
+
computedPrevButton = computed(() => {
|
|
50
|
+
let r: ButtonConfig = { ...props.prevButton };
|
|
51
|
+
if (currentStepConfig.value?.prevButton) {
|
|
52
|
+
r = { ...r, ...currentStepConfig.value?.prevButton };
|
|
46
53
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return currentStepConfig.value.
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
return '';
|
|
111
|
-
}),
|
|
112
|
-
nextConfirm = computed(() => {
|
|
113
|
-
if (typeof currentStepConfig.value.nextConfirm === 'string') {
|
|
114
|
-
return currentStepConfig.value.nextConfirm;
|
|
115
|
-
}
|
|
116
|
-
return '';
|
|
117
|
-
}),
|
|
118
|
-
nextResource = computed(() => {
|
|
119
|
-
if (typeof currentStepConfig.value.nextResource === 'string') {
|
|
120
|
-
return currentStepConfig.value.nextResource;
|
|
121
|
-
}
|
|
122
|
-
return '';
|
|
123
|
-
}),
|
|
124
|
-
nextResourceData = computed(() => {
|
|
125
|
-
if (typeof currentStepConfig.value.nextResourceData === 'object') {
|
|
126
|
-
return currentStepConfig.value.nextResourceData;
|
|
127
|
-
}
|
|
128
|
-
return {};
|
|
129
|
-
}),
|
|
130
|
-
classes = computed(() => {
|
|
131
|
-
|
|
132
|
-
const r = ['lkt-step-process'];
|
|
133
|
-
|
|
134
|
-
if (currentStep.value) r.push(`step-${currentStep.value}`);
|
|
135
|
-
return r.join(' ');
|
|
54
|
+
if (typeof r.disabled === 'undefined') {
|
|
55
|
+
r.disabled = prevDisabled.value;
|
|
56
|
+
}
|
|
57
|
+
return r;
|
|
58
|
+
}),
|
|
59
|
+
computedNextButton = computed(() => {
|
|
60
|
+
let r: ButtonConfig = { ...props.nextButton };
|
|
61
|
+
if (currentStepConfig.value?.nextButton) {
|
|
62
|
+
r = { ...r, ...currentStepConfig.value?.nextButton };
|
|
63
|
+
}
|
|
64
|
+
return r;
|
|
65
|
+
}),
|
|
66
|
+
prevHidden = computed(() => {
|
|
67
|
+
if (typeof currentStepConfig.value?.prevHidden === 'function') {
|
|
68
|
+
return currentStepConfig.value.prevHidden(currentStepConfig.value, stepsHaystack.value);
|
|
69
|
+
}
|
|
70
|
+
if (typeof currentStepConfig.value?.prevHidden === 'boolean') {
|
|
71
|
+
return currentStepConfig.value.prevHidden;
|
|
72
|
+
}
|
|
73
|
+
return currentStepIndex.value === 0;
|
|
74
|
+
}),
|
|
75
|
+
nextHidden = computed(() => {
|
|
76
|
+
if (typeof currentStepConfig.value?.nextHidden === 'function') {
|
|
77
|
+
return currentStepConfig.value.nextHidden(currentStepConfig.value, stepsHaystack.value);
|
|
78
|
+
}
|
|
79
|
+
if (typeof currentStepConfig.value?.nextHidden === 'boolean') {
|
|
80
|
+
return currentStepConfig.value.nextHidden;
|
|
81
|
+
}
|
|
82
|
+
return currentStepConfig.value.nextButton === false;
|
|
83
|
+
}),
|
|
84
|
+
classes = computed(() => {
|
|
85
|
+
const r = [];
|
|
86
|
+
if (currentStep.value) r.push(`step-${currentStep.value}`);
|
|
87
|
+
return r.join(' ');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const onNext = (data: any) => {
|
|
91
|
+
currentStep.value = stepsHaystack.value[currentStepIndex.value + 1].key;
|
|
92
|
+
if (currentStepIndex.value === (stepsHaystack.value.length - 1)) {
|
|
93
|
+
emit('finish', data);
|
|
94
|
+
|
|
95
|
+
} else {
|
|
96
|
+
emit('next', data);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
onPrev = (data: any) => {
|
|
100
|
+
currentStep.value = stepsHaystack.value[currentStepIndex.value - 1].key;
|
|
101
|
+
emit('prev', data);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
defineExpose({
|
|
106
|
+
goNext: () => {
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
nextButtonRef.value.click();
|
|
109
|
+
},
|
|
110
|
+
goPrev: () => {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
prevButtonRef.value.click();
|
|
113
|
+
},
|
|
114
|
+
startLoader: () => isLoading.value = true,
|
|
115
|
+
stopLoader: () => isLoading.value = false,
|
|
136
116
|
});
|
|
137
|
-
|
|
138
|
-
const onNext = (data: any) => {
|
|
139
|
-
config.value.step = config.value.steps[currentStepIndex.value + 1].name;
|
|
140
|
-
if (currentStepIndex.value === (config.value.steps.length - 1)) {
|
|
141
|
-
emit('finish', data);
|
|
142
|
-
|
|
143
|
-
} else {
|
|
144
|
-
emit('next', data);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
onPrev = (data: any) => {
|
|
148
|
-
config.value.step = config.value.steps[currentStepIndex.value - 1].name;
|
|
149
|
-
emit('prev', data);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
defineExpose({
|
|
154
|
-
goNext: () => {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
nextButton.value.click()
|
|
157
|
-
},
|
|
158
|
-
goPrev: () => {
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
prevButton.value.click()
|
|
161
|
-
},
|
|
162
|
-
startLoader: () => isLoading.value = true,
|
|
163
|
-
stopLoader: () => isLoading.value = false,
|
|
164
|
-
});
|
|
165
117
|
</script>
|
|
166
118
|
|
|
167
119
|
<template>
|
|
168
|
-
<article :class="classes">
|
|
169
|
-
<header
|
|
170
|
-
|
|
171
|
-
<div class="lkt-step-process_header-slot">
|
|
172
|
-
<slot name="post-title" v-bind:config="config" v-bind:loading="isLoading"/>
|
|
173
|
-
</div>
|
|
174
|
-
</header>
|
|
120
|
+
<article class="lkt-step-process" :class="classes">
|
|
121
|
+
<lkt-header v-if="header && Object.keys(header).length > 0" v-bind="header" />
|
|
122
|
+
|
|
175
123
|
<div class="lkt-step-process-buttons">
|
|
176
124
|
<lkt-button
|
|
177
|
-
|
|
125
|
+
ref="prevButtonRef"
|
|
178
126
|
v-show="!isLoading && !prevHidden"
|
|
179
|
-
v-bind
|
|
180
|
-
v-
|
|
181
|
-
|
|
182
|
-
<slot v-if="!!slots['button-prev']" name="button-prev" v-bind:config="config"/>
|
|
183
|
-
<span v-else>Back</span>
|
|
184
|
-
</lkt-button>
|
|
185
|
-
|
|
127
|
+
v-bind="computedPrevButton"
|
|
128
|
+
v-on:click="onPrev"
|
|
129
|
+
/>
|
|
186
130
|
<lkt-button
|
|
187
|
-
|
|
131
|
+
ref="nextButtonRef"
|
|
188
132
|
v-show="!isLoading && !nextHidden"
|
|
189
|
-
v-bind
|
|
190
|
-
v-
|
|
191
|
-
|
|
192
|
-
v-bind:resource-data="nextResourceData"
|
|
193
|
-
v-on:click="onNext">
|
|
194
|
-
<slot v-if="!!slots['button-next']" name="button-next" v-bind:config="config"/>
|
|
195
|
-
<span v-else>Next</span>
|
|
196
|
-
</lkt-button>
|
|
133
|
+
v-bind="computedNextButton"
|
|
134
|
+
v-on:click="onNext"
|
|
135
|
+
/>
|
|
197
136
|
</div>
|
|
198
137
|
|
|
199
138
|
<div class="lkt-step-process_content" v-if="!isLoading">
|
|
200
139
|
<div class="lkt-grid-1">
|
|
201
140
|
<div v-for="step in slotsSteps" v-show="step === currentStep">
|
|
202
|
-
<slot :name="'step-'+step" v-bind:config="
|
|
141
|
+
<slot :name="'step-'+step" v-bind:config="stepsHaystack" />
|
|
203
142
|
</div>
|
|
204
143
|
</div>
|
|
205
144
|
</div>
|
|
206
|
-
<lkt-loader v-if="isLoading"/>
|
|
145
|
+
<lkt-loader v-if="isLoading" />
|
|
207
146
|
</article>
|
|
208
147
|
</template>
|