lkt-step-process 1.2.1 → 2.0.0
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 +131 -186
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-step-process",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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,153 @@
|
|
|
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
|
+
nextDisabled = computed(() => {
|
|
50
|
+
return currentStepIndex.value === (stepsHaystack.value.length - 1);
|
|
51
|
+
}),
|
|
52
|
+
computedPrevButton = computed(() => {
|
|
53
|
+
let r: ButtonConfig = { ...props.prevButton };
|
|
54
|
+
if (currentStepConfig.value?.prevButton) {
|
|
55
|
+
r = { ...r, ...currentStepConfig.value?.prevButton };
|
|
46
56
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return
|
|
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
|
-
|
|
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(' ');
|
|
57
|
+
if (typeof r.disabled === 'undefined') {
|
|
58
|
+
r.disabled = prevDisabled.value;
|
|
59
|
+
}
|
|
60
|
+
return r;
|
|
61
|
+
}),
|
|
62
|
+
computedNextButton = computed(() => {
|
|
63
|
+
let r: ButtonConfig = { ...props.nextButton };
|
|
64
|
+
if (currentStepConfig.value?.nextButton) {
|
|
65
|
+
r = { ...r, ...currentStepConfig.value?.nextButton };
|
|
66
|
+
}
|
|
67
|
+
if (typeof r.disabled === 'undefined') {
|
|
68
|
+
r.disabled = nextDisabled.value;
|
|
69
|
+
}
|
|
70
|
+
return r;
|
|
71
|
+
}),
|
|
72
|
+
prevHidden = computed(() => {
|
|
73
|
+
if (typeof currentStepConfig.value?.prevHidden === 'function') {
|
|
74
|
+
return currentStepConfig.value.prevHidden(currentStepConfig.value, stepsHaystack.value);
|
|
75
|
+
}
|
|
76
|
+
if (typeof currentStepConfig.value?.prevHidden === 'boolean') {
|
|
77
|
+
return currentStepConfig.value.prevHidden;
|
|
78
|
+
}
|
|
79
|
+
return currentStepIndex.value === 0;
|
|
80
|
+
}),
|
|
81
|
+
nextHidden = computed(() => {
|
|
82
|
+
if (typeof currentStepConfig.value?.nextHidden === 'function') {
|
|
83
|
+
return currentStepConfig.value.nextHidden(currentStepConfig.value, stepsHaystack.value);
|
|
84
|
+
}
|
|
85
|
+
if (typeof currentStepConfig.value?.nextHidden === 'boolean') {
|
|
86
|
+
return currentStepConfig.value.nextHidden;
|
|
87
|
+
}
|
|
88
|
+
return currentStepIndex.value === (stepsHaystack.value.length - 1);
|
|
89
|
+
}),
|
|
90
|
+
classes = computed(() => {
|
|
91
|
+
const r = [];
|
|
92
|
+
if (currentStep.value) r.push(`step-${currentStep.value}`);
|
|
93
|
+
return r.join(' ');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const onNext = (data: any) => {
|
|
97
|
+
currentStep.value = stepsHaystack.value[currentStepIndex.value + 1].key;
|
|
98
|
+
if (currentStepIndex.value === (stepsHaystack.value.length - 1)) {
|
|
99
|
+
emit('finish', data);
|
|
100
|
+
|
|
101
|
+
} else {
|
|
102
|
+
emit('next', data);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
onPrev = (data: any) => {
|
|
106
|
+
currentStep.value = stepsHaystack.value[currentStepIndex.value - 1].key;
|
|
107
|
+
emit('prev', data);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
defineExpose({
|
|
112
|
+
goNext: () => {
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
nextButtonRef.value.click();
|
|
115
|
+
},
|
|
116
|
+
goPrev: () => {
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
prevButtonRef.value.click();
|
|
119
|
+
},
|
|
120
|
+
startLoader: () => isLoading.value = true,
|
|
121
|
+
stopLoader: () => isLoading.value = false,
|
|
136
122
|
});
|
|
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
123
|
</script>
|
|
166
124
|
|
|
167
125
|
<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>
|
|
126
|
+
<article class="lkt-step-process" :class="classes">
|
|
127
|
+
<lkt-header v-if="header && Object.keys(header).length > 0" v-bind="header" />
|
|
128
|
+
|
|
175
129
|
<div class="lkt-step-process-buttons">
|
|
176
130
|
<lkt-button
|
|
177
|
-
|
|
131
|
+
ref="prevButtonRef"
|
|
178
132
|
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
|
-
|
|
133
|
+
v-bind="computedPrevButton"
|
|
134
|
+
v-on:click="onPrev"
|
|
135
|
+
/>
|
|
186
136
|
<lkt-button
|
|
187
|
-
|
|
137
|
+
ref="nextButtonRef"
|
|
188
138
|
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>
|
|
139
|
+
v-bind="computedNextButton"
|
|
140
|
+
v-on:click="onNext"
|
|
141
|
+
/>
|
|
197
142
|
</div>
|
|
198
143
|
|
|
199
144
|
<div class="lkt-step-process_content" v-if="!isLoading">
|
|
200
145
|
<div class="lkt-grid-1">
|
|
201
146
|
<div v-for="step in slotsSteps" v-show="step === currentStep">
|
|
202
|
-
<slot :name="'step-'+step" v-bind:config="
|
|
147
|
+
<slot :name="'step-'+step" v-bind:config="stepsHaystack" />
|
|
203
148
|
</div>
|
|
204
149
|
</div>
|
|
205
150
|
</div>
|
|
206
|
-
<lkt-loader v-if="isLoading"/>
|
|
151
|
+
<lkt-loader v-if="isLoading" />
|
|
207
152
|
</article>
|
|
208
153
|
</template>
|