lkt-step-process 2.0.14 → 2.0.15

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.14",
3
+ "version": "2.0.15",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "module": "./dist/build.js",
@@ -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 === (currentStepIndex + 1) ? 'is-active' : '',
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
- return stepsHaystack.value.length;
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,
@@ -273,10 +297,11 @@
273
297
  ref="navRef"
274
298
  v-bind="computedButtonNavProps"
275
299
  >
276
- <template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
300
+ <template #nav-info="{currentStep, currentStepIndex, amountOfSteps, visibleStep}" v-if="slots['nav-info']">
277
301
  <slot
278
302
  name="nav-info"
279
303
  v-bind="{
304
+ visibleStep,
280
305
  currentStep,
281
306
  currentStepIndex,
282
307
  amountOfSteps: computedAmountOfSteps,
@@ -301,10 +326,11 @@
301
326
  ref="navRef"
302
327
  v-bind="computedButtonNavProps"
303
328
  >
304
- <template #nav-info="{currentStep, currentStepIndex, amountOfSteps}" v-if="slots['nav-info']">
329
+ <template #nav-info="{currentStep, currentStepIndex, amountOfSteps, visibleStep}" v-if="slots['nav-info']">
305
330
  <slot
306
331
  name="nav-info"
307
332
  v-bind="{
333
+ visibleStep,
308
334
  currentStep,
309
335
  currentStepIndex,
310
336
  amountOfSteps: computedAmountOfSteps,