bitboss-ui 0.2.56 → 0.2.57

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.
Files changed (138) hide show
  1. package/dist/index101.js +2 -2
  2. package/dist/index103.js +2 -2
  3. package/dist/index109.js +1 -1
  4. package/dist/index11.js +2 -2
  5. package/dist/index111.js +3 -3
  6. package/dist/index113.js +1 -1
  7. package/dist/index116.js +1 -1
  8. package/dist/index117.js +1 -1
  9. package/dist/index118.js +1 -1
  10. package/dist/index119.js +1 -1
  11. package/dist/index125.js +1 -1
  12. package/dist/index126.js +1 -1
  13. package/dist/index127.js +1 -1
  14. package/dist/index131.js +2 -2
  15. package/dist/index15.js +7 -7
  16. package/dist/index17.js +8 -8
  17. package/dist/index19.js +3 -3
  18. package/dist/index197.js +368 -5
  19. package/dist/index197.js.map +1 -1
  20. package/dist/index198.js +131 -13
  21. package/dist/index198.js.map +1 -1
  22. package/dist/index199.js +5 -16
  23. package/dist/index199.js.map +1 -1
  24. package/dist/index200.js +3 -3
  25. package/dist/index201.js +2 -20
  26. package/dist/index201.js.map +1 -1
  27. package/dist/index202.js +2 -29
  28. package/dist/index202.js.map +1 -1
  29. package/dist/index203.js +174 -8
  30. package/dist/index203.js.map +1 -1
  31. package/dist/index204.js +23 -2
  32. package/dist/index204.js.map +1 -1
  33. package/dist/index205.js +373 -3
  34. package/dist/index205.js.map +1 -1
  35. package/dist/index206.js +2 -35
  36. package/dist/index206.js.map +1 -1
  37. package/dist/index207.js +4 -6
  38. package/dist/index207.js.map +1 -1
  39. package/dist/index208.js +3 -2
  40. package/dist/index208.js.map +1 -1
  41. package/dist/index209.js +3 -4
  42. package/dist/index209.js.map +1 -1
  43. package/dist/index21.js +2 -2
  44. package/dist/index210.js +3 -235
  45. package/dist/index210.js.map +1 -1
  46. package/dist/index211.js +33 -366
  47. package/dist/index211.js.map +1 -1
  48. package/dist/index212.js +6 -134
  49. package/dist/index212.js.map +1 -1
  50. package/dist/index213.js +2 -2
  51. package/dist/index213.js.map +1 -1
  52. package/dist/index214.js +8 -172
  53. package/dist/index214.js.map +1 -1
  54. package/dist/index215.js +16 -23
  55. package/dist/index215.js.map +1 -1
  56. package/dist/index216.js +14 -371
  57. package/dist/index216.js.map +1 -1
  58. package/dist/index217.js +20 -3
  59. package/dist/index217.js.map +1 -1
  60. package/dist/index218.js +29 -3
  61. package/dist/index218.js.map +1 -1
  62. package/dist/index219.js +8 -10
  63. package/dist/index219.js.map +1 -1
  64. package/dist/index221.js +235 -2
  65. package/dist/index221.js.map +1 -1
  66. package/dist/index222.js +3 -3
  67. package/dist/index225.js +4 -4
  68. package/dist/index226.js +1 -1
  69. package/dist/index227.js +5 -294
  70. package/dist/index227.js.map +1 -1
  71. package/dist/index228.js +2 -6
  72. package/dist/index228.js.map +1 -1
  73. package/dist/index229.js +295 -2
  74. package/dist/index229.js.map +1 -1
  75. package/dist/index230.js +2 -2
  76. package/dist/index232.js +117 -2
  77. package/dist/index232.js.map +1 -1
  78. package/dist/index233.js +106 -2
  79. package/dist/index233.js.map +1 -1
  80. package/dist/index234.js +4 -2
  81. package/dist/index234.js.map +1 -1
  82. package/dist/index235.js +224 -2
  83. package/dist/index235.js.map +1 -1
  84. package/dist/index236.js +252 -429
  85. package/dist/index236.js.map +1 -1
  86. package/dist/index237.js +2 -89
  87. package/dist/index237.js.map +1 -1
  88. package/dist/index238.js +434 -3
  89. package/dist/index238.js.map +1 -1
  90. package/dist/index239.js +88 -159
  91. package/dist/index239.js.map +1 -1
  92. package/dist/index240.js +202 -1
  93. package/dist/index240.js.map +1 -1
  94. package/dist/index241.js +2 -69
  95. package/dist/index241.js.map +1 -1
  96. package/dist/index242.js +2 -5
  97. package/dist/index242.js.map +1 -1
  98. package/dist/index243.js +2 -200
  99. package/dist/index243.js.map +1 -1
  100. package/dist/index244.js +2 -224
  101. package/dist/index244.js.map +1 -1
  102. package/dist/index245.js +68 -257
  103. package/dist/index245.js.map +1 -1
  104. package/dist/index246.js +5 -2
  105. package/dist/index246.js.map +1 -1
  106. package/dist/index247.js +15 -2
  107. package/dist/index247.js.map +1 -1
  108. package/dist/index248.js +159 -116
  109. package/dist/index248.js.map +1 -1
  110. package/dist/index249.js +1 -108
  111. package/dist/index249.js.map +1 -1
  112. package/dist/index25.js +2 -2
  113. package/dist/index250.js +4 -15
  114. package/dist/index250.js.map +1 -1
  115. package/dist/index251.js +4 -4
  116. package/dist/index251.js.map +1 -1
  117. package/dist/index252.js +61 -4
  118. package/dist/index252.js.map +1 -1
  119. package/dist/index253.js +2 -61
  120. package/dist/index253.js.map +1 -1
  121. package/dist/index254.js +2 -3
  122. package/dist/index254.js.map +1 -1
  123. package/dist/index255.js +3 -2
  124. package/dist/index255.js.map +1 -1
  125. package/dist/index29.js +2 -2
  126. package/dist/index31.js +5 -5
  127. package/dist/index33.js +1 -1
  128. package/dist/index35.js +2 -2
  129. package/dist/index47.js +1 -1
  130. package/dist/index49.js +1 -1
  131. package/dist/index65.js +3 -3
  132. package/dist/index72.js +1 -1
  133. package/dist/index75.js +1 -1
  134. package/dist/index79.js +3 -3
  135. package/dist/index8.js +98 -101
  136. package/dist/index8.js.map +1 -1
  137. package/dist/style.css +1 -1
  138. package/package.json +1 -1
package/dist/index8.js CHANGED
@@ -1,127 +1,124 @@
1
- import { copy as G } from "./index127.js";
2
- import { onBeforeUnmount as H, reactive as Q, watch as v, toValue as X, computed as m, provide as Z } from "vue";
3
- import { isNotNil as u } from "./index124.js";
4
- import { mapValues as _ } from "./index128.js";
5
- import { useRoute as ee } from "./index129.js";
6
- import { useRouter as te } from "./index130.js";
7
- import { useStepper as se } from "./index131.js";
8
- const ie = Symbol(), w = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[\s\S]+))/, x = (i) => {
9
- var r, a;
10
- const e = i.match(w);
11
- return ((r = e == null ? void 0 : e.groups) == null ? void 0 : r.step) ?? ((a = e == null ? void 0 : e.groups) == null ? void 0 : a.step2) ?? null;
12
- }, ce = (i) => {
1
+ import { copy as D } from "./index127.js";
2
+ import { reactive as G, watch as v, toValue as H, computed as g, provide as Q } from "vue";
3
+ import { isNotNil as l } from "./index124.js";
4
+ import { mapValues as X } from "./index128.js";
5
+ import { useRoute as Z } from "./index129.js";
6
+ import { useRouter as _ } from "./index130.js";
7
+ import { useStepper as ee } from "./index131.js";
8
+ const te = Symbol(), x = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[\s\S]+))/, O = (i) => {
9
+ var o, a;
10
+ const e = i.match(x);
11
+ return ((o = e == null ? void 0 : e.groups) == null ? void 0 : o.step) ?? ((a = e == null ? void 0 : e.groups) == null ? void 0 : a.step2) ?? null;
12
+ }, le = (i) => {
13
13
  if (!i.name)
14
14
  throw new Error(
15
15
  "You need to provide a unique name for the current wizard instance to be used to save data"
16
16
  );
17
- const e = ee(), r = te();
18
- let a = !1;
19
- const g = i.useNavigation ?? !0, V = i.navigationMode ?? "query", q = i.persist ?? !0;
20
- if (g && (!e.value || !r))
17
+ const e = Z(), o = _(), a = i.useNavigation ?? !0, h = i.navigationMode ?? "query", V = i.persist ?? !0;
18
+ if (a && (!e.value || !o))
21
19
  throw new Error(
22
20
  "Navigation is enabled but could not retrieve the router instance in useWizard."
23
21
  );
24
- H(() => a = !0);
25
- const b = G(i.initialState), l = Q(
26
- q && sessionStorage.getItem(i.name) ? {
27
- ...b,
22
+ const q = D(i.initialState), p = G(
23
+ V && sessionStorage.getItem(i.name) ? {
24
+ ...q,
28
25
  ...JSON.parse(sessionStorage.getItem(i.name))
29
- } : b
26
+ } : q
30
27
  );
31
- q && v(l, () => {
32
- sessionStorage.setItem(i.name, JSON.stringify(l));
28
+ V && v(p, () => {
29
+ sessionStorage.setItem(i.name, JSON.stringify(p));
33
30
  });
34
- const P = X(i.steps), o = m(
35
- () => Object.entries(P).reduce(
36
- (t, [s, n]) => (n.condition && !n.condition(l) || (t[s] = { ...n, key: s }), t),
31
+ const w = H(i.steps), r = g(
32
+ () => Object.entries(w).reduce(
33
+ (t, [s, n]) => (n.condition && !n.condition(p) || (t[s] = { ...n, key: s }), t),
37
34
  {}
38
35
  )
39
- ), S = m(
40
- () => _(
41
- o.value,
36
+ ), m = g(
37
+ () => X(
38
+ r.value,
42
39
  (t) => typeof t.isValid == "function" ? {
43
40
  ...t,
44
- isValid: t.isValid(l)
41
+ isValid: t.isValid(p)
45
42
  } : {
46
43
  ...t,
47
44
  isValid: t.isValid ?? !0
48
45
  }
49
46
  )
50
47
  );
51
- let p = null;
52
- if (g && u(e.value)) {
48
+ let c = null;
49
+ if (a && l(e.value)) {
53
50
  let t = null;
54
- if (V === "query")
51
+ if (h === "query")
55
52
  e.value.query.step && (t = e.value.query.step);
56
53
  else {
57
- const s = x(e.value.fullPath);
54
+ const s = O(e.value.fullPath);
58
55
  s && (t = s);
59
56
  }
60
- p = t;
57
+ c = t;
61
58
  }
62
- if (p)
63
- for (const t in o.value) {
64
- if (t === p)
59
+ if (c)
60
+ for (const t in r.value) {
61
+ if (t === c)
65
62
  break;
66
- const s = S.value[t];
63
+ const s = m.value[t];
67
64
  if (!s || !s.isValid) {
68
- p = null;
65
+ c = null;
69
66
  break;
70
67
  }
71
68
  }
72
69
  const {
73
- steps: T,
74
- current: j,
75
- goToNext: A,
76
- goToPrevious: K,
70
+ steps: b,
71
+ current: P,
72
+ goToNext: j,
73
+ goToPrevious: A,
77
74
  goTo: d,
78
- index: U,
75
+ index: K,
79
76
  at: z,
80
77
  get: F,
81
78
  goBackTo: I,
82
- isAfter: B,
83
- isBefore: M,
84
- isCurrent: C,
85
- isFirst: E,
86
- isLast: J,
87
- isNext: R,
88
- isPrevious: W,
89
- next: $,
90
- previous: L,
91
- stepNames: Y
92
- } = se(
93
- S,
94
- p || Object.values(o.value)[0].key
95
- ), c = m(() => Object.keys(o.value)[U.value]), N = {
79
+ isAfter: M,
80
+ isBefore: U,
81
+ isCurrent: $,
82
+ isFirst: B,
83
+ isLast: C,
84
+ isNext: E,
85
+ isPrevious: J,
86
+ next: R,
87
+ previous: W,
88
+ stepNames: L
89
+ } = ee(
90
+ m,
91
+ c || Object.values(r.value)[0].key
92
+ ), u = g(() => Object.keys(r.value)[K.value]), T = {
96
93
  at: z,
97
- current: j,
98
- data: l,
94
+ current: P,
95
+ data: p,
99
96
  get: F,
100
97
  goBackTo: I,
101
98
  goTo: d,
102
- goToNext: A,
103
- goToPrevious: K,
104
- isAfter: B,
105
- isBefore: M,
106
- isCurrent: C,
107
- isFirst: E,
108
- isLast: J,
109
- isNext: R,
110
- isPrevious: W,
111
- key: c,
112
- next: $,
113
- previous: L,
114
- stepNames: Y,
115
- steps: T
99
+ goToNext: j,
100
+ goToPrevious: A,
101
+ isAfter: M,
102
+ isBefore: U,
103
+ isCurrent: $,
104
+ isFirst: B,
105
+ isLast: C,
106
+ isNext: E,
107
+ isPrevious: J,
108
+ key: u,
109
+ next: R,
110
+ previous: W,
111
+ stepNames: L,
112
+ steps: b
116
113
  };
117
- if (Z(ie, N), g)
118
- if (V === "query")
114
+ if (Q(te, T), a)
115
+ if (h === "query")
119
116
  v(
120
- c,
117
+ u,
121
118
  () => {
122
- u(r) && u(e.value) && r.push({
119
+ l(o) && l(e.value) && o.push({
123
120
  ...e,
124
- query: { ...e.value.query, step: c.value ?? null }
121
+ query: { ...e.value.query, step: u.value ?? null }
125
122
  });
126
123
  },
127
124
  { immediate: !0 }
@@ -133,36 +130,36 @@ const ie = Symbol(), w = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
133
130
  (t) => {
134
131
  if (t) {
135
132
  const s = t;
136
- if (s in o.value) {
137
- const n = s, f = Object.keys(o.value);
133
+ if (s in r.value) {
134
+ const n = s, f = Object.keys(r.value);
138
135
  f.slice(
139
136
  0,
140
137
  f.indexOf(n)
141
138
  ).every(
142
139
  (k) => {
143
140
  var y;
144
- return (y = S.value[k]) == null ? void 0 : y.isValid;
141
+ return (y = m.value[k]) == null ? void 0 : y.isValid;
145
142
  }
146
143
  ) && d(n);
147
144
  }
148
145
  } else {
149
- const s = Object.keys(T)[0];
146
+ const s = Object.keys(b)[0];
150
147
  d(s);
151
148
  }
152
149
  }
153
150
  );
154
151
  else {
155
- const t = m(() => {
156
- if (u(e.value))
157
- return x(e.value.fullPath);
152
+ const t = g(() => {
153
+ if (l(e.value))
154
+ return O(e.value.fullPath);
158
155
  });
159
156
  v(
160
- c,
157
+ u,
161
158
  (s) => {
162
- u(e.value) && u(r) && !a && (e.value.path.includes("step") ? r.push({
159
+ console.log(`key has changed to ${u}`, u), l(e.value) && l(o) && u && (e.value.path.includes("step") ? o.push({
163
160
  query: e.value.query,
164
- path: e.value.path.replace(w, `step/${s}`)
165
- }) : r.push({
161
+ path: e.value.path.replace(x, `step/${s}`)
162
+ }) : o.push({
166
163
  query: e.value.query,
167
164
  // Normalizes paths with / and without
168
165
  path: (e.value.path + `/step/${s}`).replace("//", "/"),
@@ -173,17 +170,17 @@ const ie = Symbol(), w = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
173
170
  ), v(
174
171
  () => t.value,
175
172
  (s) => {
176
- if (s && s !== c.value) {
173
+ if (s && s !== u.value) {
177
174
  const n = s;
178
- if (n in o.value) {
179
- const f = n, h = Object.keys(o.value);
180
- h.slice(
175
+ if (n in r.value) {
176
+ const f = n, S = Object.keys(r.value);
177
+ S.slice(
181
178
  0,
182
- h.indexOf(f)
179
+ S.indexOf(f)
183
180
  ).every(
184
181
  (y) => {
185
- var O;
186
- return (O = o.value[y]) == null ? void 0 : O.isValid;
182
+ var N;
183
+ return (N = r.value[y]) == null ? void 0 : N.isValid;
187
184
  }
188
185
  ) && d(f);
189
186
  }
@@ -191,10 +188,10 @@ const ie = Symbol(), w = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
191
188
  }
192
189
  );
193
190
  }
194
- return N;
191
+ return T;
195
192
  };
196
193
  export {
197
- ce as useWizard,
198
- ie as wizardInjectionKey
194
+ le as useWizard,
195
+ te as wizardInjectionKey
199
196
  };
200
197
  //# sourceMappingURL=index8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { cloneDeep } from '@/utilities/functions/cloneDeep';\nimport { computed, provide, reactive, watch, toValue, onBeforeUnmount } from 'vue';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { mapValues } from '@/utilities/functions/mapValues';\nimport { useRoute } from './useRoute';\nimport { useRouter } from './useRouter';\nimport { useStepper } from '@vueuse/core';\nimport type { ComputedRef, MaybeRef } from 'vue';\n\nexport const wizardInjectionKey = Symbol();\nexport type Step<U> = {\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * It determines if the validation has passed for the step.\n\t */\n\tisValid?: (state: U) => boolean | boolean;\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * Steps that do not pass the condition are removed.\n\t */\n\tcondition?: (state: U) => boolean;\n\t[key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = ReturnType<\n\ttypeof useWizard<T>\n>;\n\nconst regexMatchStep =\n\t/((step\\/)(?<step>[\\s\\S]+?)(?=[/?]))|((step\\/)(?<step2>[\\s\\S]+))/;\n/**\n * With a url that follows the rule xyz.com/anything/step/:nameofthestep[/?query]\n * will match the :nameofthestep substring\n */\nconst extractStepFromUrl = (url: string) => {\n\tconst match = url.match(regexMatchStep);\n\treturn match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n\t/**\n\t * The steps definition for the wizard\n\t */\n\tsteps: MaybeRef<Record<string, Step<T>>>;\n\t/**\n\t * Name of the wizard used to persist state\n\t */\n\tname: string;\n\t/**\n\t * Initial set of data to be made available throughout\n\t */\n\tinitialState: T;\n\t/**\n\t * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n\t * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n\t */\n\tnavigationMode?: 'query' | 'route';\n\t/**\n\t * Whether to use navigation at all. When disabled no query or URL is changed.\n\t */\n\tuseNavigation?: boolean;\n\t/**\n\t *\n\t */\n\tpersist?: boolean;\n}) => {\n\tif (!params.name) {\n\t\tthrow new Error(\n\t\t\t'You need to provide a unique name for the current wizard instance to be used to save data'\n\t\t);\n\t}\n\tconst route = useRoute();\n\tconst router = useRouter();\n\n\tlet isUnmounting = false;\n\n\tconst useNavigation = params.useNavigation ?? true;\n\tconst navigationMode = params.navigationMode ?? 'query';\n\tconst persist = params.persist ?? true;\n\n\tif (useNavigation && (!route.value || !router)) {\n\t\tthrow new Error(\n\t\t\t'Navigation is enabled but could not retrieve the router instance in useWizard.'\n\t\t);\n\t}\n\tonBeforeUnmount(() => isUnmounting = true)\n\n\tconst initialStateCopy = cloneDeep(params.initialState);\n\t/**\n\t * Initial state is either read from session storage or the one provided\n\t */\n\tconst innerState = reactive<typeof params.initialState>(\n\t\tpersist && sessionStorage.getItem(params.name)\n\t\t\t? {\n\t\t\t\t\t...initialStateCopy,\n\t\t\t\t\t...JSON.parse(sessionStorage.getItem(params.name)!),\n\t\t\t\t}\n\t\t\t: initialStateCopy\n\t);\n\n\tif (persist) {\n\t\t/**\n\t\t * Every time the state changes save it to sessionStorage\n\t\t */\n\t\twatch(innerState, () => {\n\t\t\tsessionStorage.setItem(params.name, JSON.stringify(innerState));\n\t\t});\n\t}\n\n\t/**\n\t * Steps can be passed as ref so we need to unwrap them\n\t */\n\tconst unwrappedSteps = toValue(params.steps);\n\tconst filteredSteps = computed(() =>\n\t\tObject.entries(unwrappedSteps).reduce(\n\t\t\t(acc: typeof unwrappedSteps, [key, step]) => {\n\t\t\t\tif (step.condition) {\n\t\t\t\t\tif (!step.condition(innerState as T)) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tacc[key] = { ...step, key };\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t)\n\t);\n\n\t/**\n\t * Steps can have a isValid function that receives the current state\n\t * but we don't want to have to call it every single time so we call it once here\n\t */\n\tconst mappedSteps = computed(() =>\n\t\tmapValues(\n\t\t\tfilteredSteps.value,\n\t\t\t(step): Omit<Step<T>, 'isValid'> & { isValid: boolean } => {\n\t\t\t\tif (typeof step.isValid === 'function') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...step,\n\t\t\t\t\t\tisValid: step.isValid(innerState as T),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tisValid: step.isValid ?? true,\n\t\t\t\t};\n\t\t\t}\n\t\t)\n\t);\n\n\t/**\n\t * Get the initial step from the query.\n\t * If it exists check that every step before it is also valid\n\t * so user cannot manually jump by changing the URL\n\t */\n\tlet initialStep = null;\n\tif (useNavigation && isNotNil(route.value)) {\n\t\tlet step: string | null = null;\n\t\tif (navigationMode === 'query') {\n\t\t\tif (route.value.query.step) {\n\t\t\t\tstep = route.value.query.step as string;\n\t\t\t}\n\t\t} else {\n\t\t\tconst stepFromUrl = extractStepFromUrl(route.value.fullPath);\n\t\t\tif (stepFromUrl) {\n\t\t\t\tstep = stepFromUrl;\n\t\t\t}\n\t\t}\n\t\tinitialStep = step;\n\t}\n\n\tif (initialStep) {\n\t\tfor (const stepName in filteredSteps.value) {\n\t\t\tif (stepName === initialStep) break;\n\t\t\tconst current = mappedSteps.value[stepName];\n\t\t\tif (!current || !current.isValid) {\n\t\t\t\tinitialStep = null;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Define the state of the wizard\n\t * A few data come from useStepper\n\t */\n\tconst {\n\t\tsteps,\n\t\tcurrent,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tgoTo,\n\t\tindex,\n\t\tat,\n\t\tget,\n\t\tgoBackTo,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t} = useStepper(\n\t\tmappedSteps,\n\t\tinitialStep || Object.values(filteredSteps.value)[0].key\n\t);\n\n\tconst key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n\t/**\n\t * Complete state object\n\t */\n\tconst state = {\n\t\tat,\n\t\tcurrent: current as ComputedRef<Step<T> & { isValid: boolean }>,\n\t\tdata: innerState,\n\t\tget,\n\t\tgoBackTo,\n\t\tgoTo,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tkey,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t\tsteps,\n\t};\n\n\tprovide(wizardInjectionKey, state);\n\n\tif (useNavigation) {\n\t\tif (navigationMode === 'query') {\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t() => {\n\t\t\t\t\tif (isNotNil(router) && isNotNil(route.value)) {\n\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t...route,\n\t\t\t\t\t\t\tquery: { ...route.value.query, step: key.value ?? null },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => route.value?.query.step,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => mappedSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst key = Object.keys(steps)[0];\n\t\t\t\t\t\tgoTo(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tconst stepFromUrl = computed(() => {\n\t\t\t\tif (isNotNil(route.value)) {\n\t\t\t\t\treturn extractStepFromUrl(route.value.fullPath);\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t});\n\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (isNotNil(route.value) && isNotNil(router) && !isUnmounting) {\n\t\t\t\t\t\tif (route.value.path.includes('step')) {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\tpath: route.value.path.replace(regexMatchStep, `step/${value}`),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\t// Normalizes paths with / and without\n\t\t\t\t\t\t\t\tpath: (route.value.path + `/step/${value}`).replace('//', '/'),\n\t\t\t\t\t\t\t\treplace: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true, flush: 'post' }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => stepFromUrl.value,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value && value !== key.value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => filteredSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\treturn state;\n};\n"],"names":["wizardInjectionKey","regexMatchStep","extractStepFromUrl","url","match","_a","_b","useWizard","params","route","useRoute","router","useRouter","isUnmounting","useNavigation","navigationMode","persist","onBeforeUnmount","initialStateCopy","cloneDeep","innerState","reactive","watch","unwrappedSteps","toValue","filteredSteps","computed","acc","key","step","mappedSteps","mapValues","initialStep","isNotNil","stepFromUrl","stepName","current","steps","goToNext","goToPrevious","goTo","index","at","get","goBackTo","isAfter","isBefore","isCurrent","isFirst","isLast","isNext","isPrevious","next","previous","stepNames","useStepper","state","provide","value","stepAsString","stepAsKey","stepKeys"],"mappings":";;;;;;;AASO,MAAMA,KAAqB,OAAO,GAsBnCC,IACL,mEAKKC,IAAqB,CAACC,MAAgB;;AACrC,QAAAC,IAAQD,EAAI,MAAMF,CAAc;AACtC,WAAOI,IAAAD,KAAA,gBAAAA,EAAO,WAAP,gBAAAC,EAAe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version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { cloneDeep } from '@/utilities/functions/cloneDeep';\nimport { computed, provide, reactive, watch, toValue, onBeforeUnmount } from 'vue';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { mapValues } from '@/utilities/functions/mapValues';\nimport { useRoute } from './useRoute';\nimport { useRouter } from './useRouter';\nimport { useStepper } from '@vueuse/core';\nimport type { ComputedRef, MaybeRef } from 'vue';\n\nexport const wizardInjectionKey = Symbol();\nexport type Step<U> = {\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * It determines if the validation has passed for the step.\n\t */\n\tisValid?: (state: U) => boolean | boolean;\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * Steps that do not pass the condition are removed.\n\t */\n\tcondition?: (state: U) => boolean;\n\t[key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = ReturnType<\n\ttypeof useWizard<T>\n>;\n\nconst regexMatchStep =\n\t/((step\\/)(?<step>[\\s\\S]+?)(?=[/?]))|((step\\/)(?<step2>[\\s\\S]+))/;\n/**\n * With a url that follows the rule xyz.com/anything/step/:nameofthestep[/?query]\n * will match the :nameofthestep substring\n */\nconst extractStepFromUrl = (url: string) => {\n\tconst match = url.match(regexMatchStep);\n\treturn match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n\t/**\n\t * The steps definition for the wizard\n\t */\n\tsteps: MaybeRef<Record<string, Step<T>>>;\n\t/**\n\t * Name of the wizard used to persist state\n\t */\n\tname: string;\n\t/**\n\t * Initial set of data to be made available throughout\n\t */\n\tinitialState: T;\n\t/**\n\t * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n\t * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n\t */\n\tnavigationMode?: 'query' | 'route';\n\t/**\n\t * Whether to use navigation at all. When disabled no query or URL is changed.\n\t */\n\tuseNavigation?: boolean;\n\t/**\n\t *\n\t */\n\tpersist?: boolean;\n}) => {\n\tif (!params.name) {\n\t\tthrow new Error(\n\t\t\t'You need to provide a unique name for the current wizard instance to be used to save data'\n\t\t);\n\t}\n\tconst route = useRoute();\n\tconst router = useRouter();\n\n\tconst useNavigation = params.useNavigation ?? true;\n\tconst navigationMode = params.navigationMode ?? 'query';\n\tconst persist = params.persist ?? true;\n\n\tif (useNavigation && (!route.value || !router)) {\n\t\tthrow new Error(\n\t\t\t'Navigation is enabled but could not retrieve the router instance in useWizard.'\n\t\t);\n\t}\n\n\tconst initialStateCopy = cloneDeep(params.initialState);\n\t/**\n\t * Initial state is either read from session storage or the one provided\n\t */\n\tconst innerState = reactive<typeof params.initialState>(\n\t\tpersist && sessionStorage.getItem(params.name)\n\t\t\t? {\n\t\t\t\t\t...initialStateCopy,\n\t\t\t\t\t...JSON.parse(sessionStorage.getItem(params.name)!),\n\t\t\t\t}\n\t\t\t: initialStateCopy\n\t);\n\n\tif (persist) {\n\t\t/**\n\t\t * Every time the state changes save it to sessionStorage\n\t\t */\n\t\twatch(innerState, () => {\n\t\t\tsessionStorage.setItem(params.name, JSON.stringify(innerState));\n\t\t});\n\t}\n\n\t/**\n\t * Steps can be passed as ref so we need to unwrap them\n\t */\n\tconst unwrappedSteps = toValue(params.steps);\n\tconst filteredSteps = computed(() =>\n\t\tObject.entries(unwrappedSteps).reduce(\n\t\t\t(acc: typeof unwrappedSteps, [key, step]) => {\n\t\t\t\tif (step.condition) {\n\t\t\t\t\tif (!step.condition(innerState as T)) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tacc[key] = { ...step, key };\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t)\n\t);\n\n\t/**\n\t * Steps can have a isValid function that receives the current state\n\t * but we don't want to have to call it every single time so we call it once here\n\t */\n\tconst mappedSteps = computed(() =>\n\t\tmapValues(\n\t\t\tfilteredSteps.value,\n\t\t\t(step): Omit<Step<T>, 'isValid'> & { isValid: boolean } => {\n\t\t\t\tif (typeof step.isValid === 'function') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...step,\n\t\t\t\t\t\tisValid: step.isValid(innerState as T),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tisValid: step.isValid ?? true,\n\t\t\t\t};\n\t\t\t}\n\t\t)\n\t);\n\n\t/**\n\t * Get the initial step from the query.\n\t * If it exists check that every step before it is also valid\n\t * so user cannot manually jump by changing the URL\n\t */\n\tlet initialStep = null;\n\tif (useNavigation && isNotNil(route.value)) {\n\t\tlet step: string | null = null;\n\t\tif (navigationMode === 'query') {\n\t\t\tif (route.value.query.step) {\n\t\t\t\tstep = route.value.query.step as string;\n\t\t\t}\n\t\t} else {\n\t\t\tconst stepFromUrl = extractStepFromUrl(route.value.fullPath);\n\t\t\tif (stepFromUrl) {\n\t\t\t\tstep = stepFromUrl;\n\t\t\t}\n\t\t}\n\t\tinitialStep = step;\n\t}\n\n\tif (initialStep) {\n\t\tfor (const stepName in filteredSteps.value) {\n\t\t\tif (stepName === initialStep) break;\n\t\t\tconst current = mappedSteps.value[stepName];\n\t\t\tif (!current || !current.isValid) {\n\t\t\t\tinitialStep = null;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Define the state of the wizard\n\t * A few data come from useStepper\n\t */\n\tconst {\n\t\tsteps,\n\t\tcurrent,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tgoTo,\n\t\tindex,\n\t\tat,\n\t\tget,\n\t\tgoBackTo,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t} = useStepper(\n\t\tmappedSteps,\n\t\tinitialStep || Object.values(filteredSteps.value)[0].key\n\t);\n\n\tconst key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n\t/**\n\t * Complete state object\n\t */\n\tconst state = {\n\t\tat,\n\t\tcurrent: current as ComputedRef<Step<T> & { isValid: boolean }>,\n\t\tdata: innerState,\n\t\tget,\n\t\tgoBackTo,\n\t\tgoTo,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tkey,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t\tsteps,\n\t};\n\n\tprovide(wizardInjectionKey, state);\n\n\tif (useNavigation) {\n\t\tif (navigationMode === 'query') {\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t() => {\n\t\t\t\t\tif (isNotNil(router) && isNotNil(route.value)) {\n\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t...route,\n\t\t\t\t\t\t\tquery: { ...route.value.query, step: key.value ?? null },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => route.value?.query.step,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => mappedSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst key = Object.keys(steps)[0];\n\t\t\t\t\t\tgoTo(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tconst stepFromUrl = computed(() => {\n\t\t\t\tif (isNotNil(route.value)) {\n\t\t\t\t\treturn extractStepFromUrl(route.value.fullPath);\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t});\n\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t(value) => {\n\t\t\t\t\t\tconsole.log(`key has changed to ${key}`, key)\n\t\t\t\t\tif (isNotNil(route.value) && isNotNil(router) && key) {\n\t\t\t\t\t\tif (route.value.path.includes('step')) {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\tpath: route.value.path.replace(regexMatchStep, `step/${value}`),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\t// Normalizes paths with / and without\n\t\t\t\t\t\t\t\tpath: (route.value.path + `/step/${value}`).replace('//', '/'),\n\t\t\t\t\t\t\t\treplace: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true, flush: 'post' }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => stepFromUrl.value,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value && value !== key.value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => filteredSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\treturn state;\n};\n"],"names":["wizardInjectionKey","regexMatchStep","extractStepFromUrl","url","match","_a","_b","useWizard","params","route","useRoute","router","useRouter","useNavigation","navigationMode","persist","initialStateCopy","cloneDeep","innerState","reactive","watch","unwrappedSteps","toValue","filteredSteps","computed","acc","key","step","mappedSteps","mapValues","initialStep","isNotNil","stepFromUrl","stepName","current","steps","goToNext","goToPrevious","goTo","index","at","get","goBackTo","isAfter","isBefore","isCurrent","isFirst","isLast","isNext","isPrevious","next","previous","stepNames","useStepper","state","provide","value","stepAsString","stepAsKey","stepKeys"],"mappings":";;;;;;;AASO,MAAMA,KAAqB,OAAO,GAsBnCC,IACL,mEAKKC,IAAqB,CAACC,MAAgB;;AACrC,QAAAC,IAAQD,EAAI,MAAMF,CAAc;AACtC,WAAOI,IAAAD,KAAA,gBAAAA,EAAO,WAAP,gBAAAC,EAAe,WAAQC,IAAAF,KAAA,gBAAAA,EAAO,WAAP,gBAAAE,EAAe,UAAS;AACvD,GACaC,KAAY,CAAmBC,MA0BtC;AACD,MAA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