bitboss-ui 0.2.12 → 0.2.14

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 (240) hide show
  1. package/dist/composables/useWizard.d.ts +44 -15
  2. package/dist/index101.js +3 -3
  3. package/dist/index103.js +2 -2
  4. package/dist/index109.js +1 -1
  5. package/dist/index11.js +2 -2
  6. package/dist/index111.js +4 -4
  7. package/dist/index113.js +1 -1
  8. package/dist/index116.js +1 -1
  9. package/dist/index117.js +1 -1
  10. package/dist/index118.js +1 -1
  11. package/dist/index119.js +1 -1
  12. package/dist/index121.js +1 -1
  13. package/dist/index125.js +1 -1
  14. package/dist/index126.js +1 -1
  15. package/dist/index127.js +24 -2
  16. package/dist/index127.js.map +1 -1
  17. package/dist/index128.js +2 -70
  18. package/dist/index128.js.map +1 -1
  19. package/dist/index131.js +70 -3
  20. package/dist/index131.js.map +1 -1
  21. package/dist/index132.js +2 -2
  22. package/dist/index133.js +2 -2
  23. package/dist/index134.js +2 -2
  24. package/dist/index135.js +2 -2
  25. package/dist/index136.js +2 -2
  26. package/dist/index137.js +2 -2
  27. package/dist/index138.js +2 -2
  28. package/dist/index139.js +2 -2
  29. package/dist/index140.js +2 -2
  30. package/dist/index141.js +2 -2
  31. package/dist/index142.js +2 -2
  32. package/dist/index143.js +2 -2
  33. package/dist/index144.js +2 -2
  34. package/dist/index145.js +2 -2
  35. package/dist/index146.js +2 -2
  36. package/dist/index147.js +2 -2
  37. package/dist/index148.js +2 -2
  38. package/dist/index149.js +2 -2
  39. package/dist/index15.js +8 -8
  40. package/dist/index150.js +2 -2
  41. package/dist/index151.js +2 -2
  42. package/dist/index152.js +2 -2
  43. package/dist/index153.js +2 -2
  44. package/dist/index154.js +2 -2
  45. package/dist/index155.js +2 -2
  46. package/dist/index156.js +2 -2
  47. package/dist/index157.js +3 -2
  48. package/dist/index157.js.map +1 -1
  49. package/dist/index158.js +2 -3
  50. package/dist/index158.js.map +1 -1
  51. package/dist/index159.js +3 -2
  52. package/dist/index159.js.map +1 -1
  53. package/dist/index160.js +2 -3
  54. package/dist/index160.js.map +1 -1
  55. package/dist/index161.js +2 -2
  56. package/dist/index162.js +2 -2
  57. package/dist/index163.js +2 -2
  58. package/dist/index164.js +2 -2
  59. package/dist/index165.js +2 -2
  60. package/dist/index166.js +3 -2
  61. package/dist/index166.js.map +1 -1
  62. package/dist/index167.js +2 -3
  63. package/dist/index167.js.map +1 -1
  64. package/dist/index168.js +3 -2
  65. package/dist/index168.js.map +1 -1
  66. package/dist/index169.js +2 -2
  67. package/dist/index17.js +9 -9
  68. package/dist/index170.js +2 -3
  69. package/dist/index170.js.map +1 -1
  70. package/dist/index171.js +2 -2
  71. package/dist/index172.js +2 -2
  72. package/dist/index173.js +2 -2
  73. package/dist/index174.js +2 -2
  74. package/dist/index175.js +2 -2
  75. package/dist/index176.js +2 -2
  76. package/dist/index177.js +2 -2
  77. package/dist/index178.js +2 -2
  78. package/dist/index179.js +2 -2
  79. package/dist/index180.js +2 -2
  80. package/dist/index181.js +2 -2
  81. package/dist/index182.js +3 -2
  82. package/dist/index182.js.map +1 -1
  83. package/dist/index183.js +2 -3
  84. package/dist/index183.js.map +1 -1
  85. package/dist/index184.js +3 -2
  86. package/dist/index184.js.map +1 -1
  87. package/dist/index185.js +2 -3
  88. package/dist/index185.js.map +1 -1
  89. package/dist/index186.js +2 -2
  90. package/dist/index187.js +2 -2
  91. package/dist/index188.js +2 -2
  92. package/dist/index189.js +2 -2
  93. package/dist/index19.js +3 -3
  94. package/dist/index190.js +2 -2
  95. package/dist/index191.js +2 -2
  96. package/dist/index192.js +2 -2
  97. package/dist/index193.js +2 -2
  98. package/dist/index194.js +2 -2
  99. package/dist/index195.js +3 -2
  100. package/dist/index195.js.map +1 -1
  101. package/dist/index196.js +2 -378
  102. package/dist/index196.js.map +1 -1
  103. package/dist/index197.js +2 -134
  104. package/dist/index197.js.map +1 -1
  105. package/dist/index198.js +4 -5
  106. package/dist/index198.js.map +1 -1
  107. package/dist/index199.js +5 -19
  108. package/dist/index199.js.map +1 -1
  109. package/dist/index200.js +16 -2
  110. package/dist/index200.js.map +1 -1
  111. package/dist/index201.js +16 -2
  112. package/dist/index201.js.map +1 -1
  113. package/dist/index202.js +17 -172
  114. package/dist/index202.js.map +1 -1
  115. package/dist/index203.js +20 -23
  116. package/dist/index203.js.map +1 -1
  117. package/dist/index204.js +27 -371
  118. package/dist/index204.js.map +1 -1
  119. package/dist/index205.js +8 -3
  120. package/dist/index205.js.map +1 -1
  121. package/dist/index206.js +2 -35
  122. package/dist/index206.js.map +1 -1
  123. package/dist/index207.js +378 -6
  124. package/dist/index207.js.map +1 -1
  125. package/dist/index208.js +134 -2
  126. package/dist/index208.js.map +1 -1
  127. package/dist/index209.js +2 -4
  128. package/dist/index209.js.map +1 -1
  129. package/dist/index21.js +3 -3
  130. package/dist/index210.js +165 -226
  131. package/dist/index210.js.map +1 -1
  132. package/dist/index211.js +23 -2
  133. package/dist/index211.js.map +1 -1
  134. package/dist/index212.js +371 -14
  135. package/dist/index212.js.map +1 -1
  136. package/dist/index213.js +3 -16
  137. package/dist/index213.js.map +1 -1
  138. package/dist/index214.js +3 -20
  139. package/dist/index214.js.map +1 -1
  140. package/dist/index215.js +235 -29
  141. package/dist/index215.js.map +1 -1
  142. package/dist/index216.js +2 -8
  143. package/dist/index216.js.map +1 -1
  144. package/dist/index217.js +3 -10
  145. package/dist/index217.js.map +1 -1
  146. package/dist/index218.js +35 -2
  147. package/dist/index218.js.map +1 -1
  148. package/dist/index219.js +6 -3
  149. package/dist/index219.js.map +1 -1
  150. package/dist/index220.js +2 -3
  151. package/dist/index220.js.map +1 -1
  152. package/dist/index221.js +9 -27
  153. package/dist/index221.js.map +1 -1
  154. package/dist/index222.js +8 -12
  155. package/dist/index222.js.map +1 -1
  156. package/dist/index223.js +119 -7
  157. package/dist/index223.js.map +1 -1
  158. package/dist/index224.js +25 -118
  159. package/dist/index224.js.map +1 -1
  160. package/dist/index225.js +13 -79
  161. package/dist/index225.js.map +1 -1
  162. package/dist/index226.js +79 -2
  163. package/dist/index226.js.map +1 -1
  164. package/dist/index227.js +4 -6
  165. package/dist/index227.js.map +1 -1
  166. package/dist/index228.js +295 -2
  167. package/dist/index228.js.map +1 -1
  168. package/dist/index229.js +5 -294
  169. package/dist/index229.js.map +1 -1
  170. package/dist/index23.js +1 -1
  171. package/dist/index232.js +2 -117
  172. package/dist/index232.js.map +1 -1
  173. package/dist/index233.js +2 -106
  174. package/dist/index233.js.map +1 -1
  175. package/dist/index234.js +2 -435
  176. package/dist/index234.js.map +1 -1
  177. package/dist/index235.js +2 -89
  178. package/dist/index235.js.map +1 -1
  179. package/dist/index236.js +2 -162
  180. package/dist/index236.js.map +1 -1
  181. package/dist/index237.js +117 -2
  182. package/dist/index237.js.map +1 -1
  183. package/dist/index238.js +105 -68
  184. package/dist/index238.js.map +1 -1
  185. package/dist/index239.js +2 -2
  186. package/dist/index239.js.map +1 -1
  187. package/dist/index240.js +224 -200
  188. package/dist/index240.js.map +1 -1
  189. package/dist/index241.js +258 -4
  190. package/dist/index241.js.map +1 -1
  191. package/dist/index242.js +429 -32
  192. package/dist/index242.js.map +1 -1
  193. package/dist/index243.js +89 -2
  194. package/dist/index243.js.map +1 -1
  195. package/dist/index244.js +200 -2
  196. package/dist/index244.js.map +1 -1
  197. package/dist/index245.js +162 -2
  198. package/dist/index245.js.map +1 -1
  199. package/dist/index246.js +2 -2
  200. package/dist/index247.js +2 -2
  201. package/dist/index247.js.map +1 -1
  202. package/dist/index248.js +69 -2
  203. package/dist/index248.js.map +1 -1
  204. package/dist/index249.js +2 -224
  205. package/dist/index249.js.map +1 -1
  206. package/dist/index25.js +2 -2
  207. package/dist/index250.js +38 -258
  208. package/dist/index250.js.map +1 -1
  209. package/dist/index251.js +2 -2
  210. package/dist/index251.js.map +1 -1
  211. package/dist/index252.js +2 -2
  212. package/dist/index252.js.map +1 -1
  213. package/dist/index253.js +15 -3
  214. package/dist/index253.js.map +1 -1
  215. package/dist/index254.js +3 -2
  216. package/dist/index254.js.map +1 -1
  217. package/dist/index255.js +5 -0
  218. package/dist/index255.js.map +1 -0
  219. package/dist/index256.js +5 -0
  220. package/dist/index256.js.map +1 -0
  221. package/dist/index29.js +3 -3
  222. package/dist/index31.js +8 -8
  223. package/dist/index33.js +2 -2
  224. package/dist/index35.js +2 -2
  225. package/dist/index43.js +1 -1
  226. package/dist/index45.js +2 -2
  227. package/dist/index47.js +1 -1
  228. package/dist/index49.js +1 -1
  229. package/dist/index59.js +1 -1
  230. package/dist/index65.js +5 -5
  231. package/dist/index69.js +3 -3
  232. package/dist/index72.js +1 -1
  233. package/dist/index75.js +1 -1
  234. package/dist/index77.js +1 -1
  235. package/dist/index79.js +4 -4
  236. package/dist/index8.js +85 -101
  237. package/dist/index8.js.map +1 -1
  238. package/dist/index81.js +1 -1
  239. package/dist/style.css +1 -1
  240. package/package.json +1 -1
package/dist/index69.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { defineComponent as H, ref as h, watch as M, computed as m, openBlock as z, createBlock as N, resolveDynamicComponent as R, normalizeClass as j, withCtx as _, createElementVNode as d, withModifiers as g, renderSlot as G, normalizeProps as K, guardReactiveProps as O, createTextVNode as U, unref as Y, createVNode as Z, createElementBlock as x, Fragment as J, renderList as Q, toDisplayString as W } from "vue";
2
- import { findInTree as X } from "./index222.js";
2
+ import { findInTree as X } from "./index225.js";
3
3
  import { useId as ee } from "./index7.js";
4
4
  import te from "./index118.js";
5
- import "./index182.js";
5
+ import "./index183.js";
6
6
  const re = ["accept", "autofocus", "disabled", "multiple"], ae = {
7
7
  class: "bb-dropzone__submittable-label",
8
8
  "aria-hidden": "true"
@@ -52,7 +52,7 @@ const re = ["accept", "autofocus", "disabled", "multiple"], ae = {
52
52
  if (a.includes("/"))
53
53
  e.push(a);
54
54
  else {
55
- y || (y = await import("./index221.js").then((s) => s.i));
55
+ y || (y = await import("./index224.js").then((s) => s.i));
56
56
  const o = y.getType(a);
57
57
  if (!o)
58
58
  throw new Error(
package/dist/index72.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as h, ref as t, onMounted as m, onBeforeUnmount as p, openBlock as g, createBlock as b, resolveDynamicComponent as w, withCtx as _, renderSlot as I } from "vue";
2
- import { throttle as c } from "./index205.js";
2
+ import { throttle as c } from "./index217.js";
3
3
  const M = /* @__PURE__ */ h({
4
4
  __name: "BbIntersection",
5
5
  props: {
package/dist/index75.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as q, ref as s, useAttrs as G, computed as m, onMounted as J, watch as Q, onBeforeUnmount as X, openBlock as y, createBlock as Y, Teleport as Z, createElementVNode as o, mergeProps as N, createElementBlock as w, renderSlot as l, createTextVNode as ee, toDisplayString as z, createCommentVNode as B, nextTick as te } from "vue";
2
- import { useFocusTrap as oe } from "./index206.js";
2
+ import { useFocusTrap as oe } from "./index218.js";
3
3
  import { useId as L } from "./index7.js";
4
4
  import { wait as O } from "./index122.js";
5
5
  const se = { class: "bb-offcanvas-close" }, ae = { class: "bb-offcanvas-close__content" }, ne = { class: "bb-offcanvas-close__label" }, le = /* @__PURE__ */ o("span", { class: "bb-offcanvas-close__icon" }, [
package/dist/index77.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as x, computed as y, ref as p, onMounted as A, onBeforeUnmount as B, openBlock as V, createElementBlock as k, createElementVNode as u, renderSlot as g, createTextVNode as b, Fragment as E, renderList as P, normalizeClass as W, toDisplayString as h, nextTick as z } from "vue";
2
- import R from "./index225.js";
2
+ import R from "./index226.js";
3
3
  const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["onClick", "disabled"], D = ["disabled"], O = /* @__PURE__ */ x({
4
4
  __name: "BbPagination",
5
5
  props: {
package/dist/index79.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { defineComponent as N, ref as a, computed as C, openBlock as f, createElementBlock as $, mergeProps as T, createElementVNode as s, renderSlot as B, normalizeProps as V, guardReactiveProps as I, unref as m, createBlock as P, Teleport as R, normalizeClass as U, normalizeStyle as j, withCtx as G, createCommentVNode as D, nextTick as J } from "vue";
2
- import { useFloating as K, arrow as Q } from "./index224.js";
3
- import { useFocusTrap as W } from "./index206.js";
2
+ import { useFloating as K, arrow as Q } from "./index223.js";
3
+ import { useFocusTrap as W } from "./index218.js";
4
4
  import { useId as X } from "./index7.js";
5
5
  import { wait as E } from "./index122.js";
6
6
  import Y from "./index9.js";
7
7
  import "./index10.js";
8
- import { autoUpdate as Z, flip as ee, shift as oe } from "./index196.js";
9
- import { offset as te } from "./index204.js";
8
+ import { autoUpdate as Z, flip as ee, shift as oe } from "./index207.js";
9
+ import { offset as te } from "./index212.js";
10
10
  const ae = ["id"], re = { class: "bb-popover__bubble" }, ne = /* @__PURE__ */ s("span", { class: "bb-popover__close-label" }, "Chiudi", -1), se = /* @__PURE__ */ s("svg", {
11
11
  viewBox: "0 0 24 24",
12
12
  fill: "none",
package/dist/index8.js CHANGED
@@ -1,50 +1,51 @@
1
- import { unref as Y, reactive as D, watch as f, toValue as G, computed as g, provide as H } from "vue";
2
- import { mapValues as Q } from "./index127.js";
3
- import { useStepper as X } from "./index128.js";
1
+ import { copy as D } from "./index127.js";
2
+ import { reactive as G, watch as f, toValue as H, computed as g, provide as Q } from "vue";
3
+ import { isNotNil as a } from "./index124.js";
4
+ import { mapValues as X } from "./index128.js";
4
5
  import { useRoute as Z } from "./index129.js";
5
6
  import { useRouter as _ } from "./index130.js";
6
- import { isNotNil as l } from "./index124.js";
7
- const ee = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[\s\S]+))/, J = (i) => {
7
+ import { useStepper as ee } from "./index131.js";
8
+ const te = Symbol(), x = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[\s\S]+))/, O = (i) => {
8
9
  var r, u;
9
- const e = i.match(R);
10
+ const e = i.match(x);
10
11
  return ((r = e == null ? void 0 : e.groups) == null ? void 0 : r.step) ?? ((u = e == null ? void 0 : e.groups) == null ? void 0 : u.step2) ?? null;
11
- }, ae = (i) => {
12
+ }, le = (i) => {
12
13
  if (!i.name)
13
14
  throw new Error(
14
15
  "You need to provide a unique name for the current wizard instance to be used to save data"
15
16
  );
16
- const e = Z(), r = _(), u = i.useNavigation ?? !0, q = i.navigationMode ?? "query", T = i.persist ?? !0;
17
+ const e = Z(), r = _(), u = i.useNavigation ?? !0, h = i.navigationMode ?? "query", q = i.persist ?? !0;
17
18
  if (u && (!e.value || !r))
18
19
  throw new Error(
19
20
  "Navigation is enabled but could not retrieve the router instance in useWizard."
20
21
  );
21
- const V = { ...Y(i.initialState) }, a = D(
22
- T && sessionStorage.getItem(i.name) ? {
23
- ...V,
22
+ const b = D(i.initialState), l = G(
23
+ q && sessionStorage.getItem(i.name) ? {
24
+ ...b,
24
25
  ...JSON.parse(sessionStorage.getItem(i.name))
25
- } : V
26
+ } : b
26
27
  );
27
- T && f(a, () => {
28
- sessionStorage.setItem(i.name, JSON.stringify(a));
28
+ q && f(l, () => {
29
+ sessionStorage.setItem(i.name, JSON.stringify(l));
29
30
  });
30
- const W = G(i.steps), o = g(
31
- () => Object.entries(W).reduce(
32
- (t, [s, n]) => (n.condition && !n.condition(a) || (t[s] = { ...n, key: s }), t),
31
+ const w = H(i.steps), o = g(
32
+ () => Object.entries(w).reduce(
33
+ (t, [s, n]) => (n.condition && !n.condition(l) || (t[s] = { ...n, key: s }), t),
33
34
  {}
34
35
  )
35
36
  ), m = g(
36
- () => Q(o.value, (t) => ({
37
+ () => X(o.value, (t) => ({
37
38
  ...t,
38
- isValid: t.isValid ? t.isValid(a) : !0
39
+ isValid: t.isValid ? t.isValid(l) : !0
39
40
  }))
40
41
  );
41
42
  let p = null;
42
- if (u && l(e.value)) {
43
+ if (u && a(e.value)) {
43
44
  let t = null;
44
- if (q === "query")
45
+ if (h === "query")
45
46
  e.value.query.step && (t = e.value.query.step);
46
47
  else {
47
- const s = J(e.value.fullPath);
48
+ const s = O(e.value.fullPath);
48
49
  s && (t = s);
49
50
  }
50
51
  p = t;
@@ -60,54 +61,56 @@ const ee = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
60
61
  }
61
62
  }
62
63
  const {
63
- steps: S,
64
- current: b,
65
- goToNext: N,
66
- goToPrevious: x,
64
+ steps: T,
65
+ current: P,
66
+ goToNext: j,
67
+ goToPrevious: A,
67
68
  goTo: d,
68
- index: $,
69
- at: O,
70
- get: k,
71
- goBackTo: w,
72
- isAfter: P,
73
- isBefore: j,
74
- isCurrent: A,
75
- isFirst: K,
76
- isLast: z,
77
- isNext: F,
78
- isPrevious: I,
79
- next: M,
80
- previous: U,
81
- stepNames: B
82
- } = X(
69
+ index: K,
70
+ at: z,
71
+ get: F,
72
+ goBackTo: I,
73
+ isAfter: M,
74
+ isBefore: U,
75
+ isCurrent: B,
76
+ isFirst: C,
77
+ isLast: E,
78
+ isNext: J,
79
+ isPrevious: R,
80
+ next: W,
81
+ previous: $,
82
+ stepNames: L
83
+ } = ee(
83
84
  m,
84
85
  p || Object.values(o.value)[0].key
85
- ), c = g(() => Object.keys(o.value)[$.value]);
86
- if (H(ee, {
87
- goToNext: N,
88
- goToPrevious: x,
89
- current: b,
90
- data: a,
91
- steps: S,
92
- at: O,
93
- get: k,
94
- goBackTo: w,
95
- isAfter: P,
96
- isBefore: j,
97
- isCurrent: A,
98
- isFirst: K,
99
- isLast: z,
100
- isNext: F,
101
- isPrevious: I,
102
- next: M,
103
- previous: U,
104
- stepNames: B
105
- }), u)
106
- if (q === "query")
86
+ ), c = g(() => Object.keys(o.value)[K.value]), V = {
87
+ at: z,
88
+ current: P,
89
+ data: l,
90
+ get: F,
91
+ goBackTo: I,
92
+ goTo: d,
93
+ goToNext: j,
94
+ goToPrevious: A,
95
+ isAfter: M,
96
+ isBefore: U,
97
+ isCurrent: B,
98
+ isFirst: C,
99
+ isLast: E,
100
+ isNext: J,
101
+ isPrevious: R,
102
+ key: c,
103
+ next: W,
104
+ previous: $,
105
+ stepNames: L,
106
+ steps: T
107
+ };
108
+ if (Q(te, V), u)
109
+ if (h === "query")
107
110
  f(
108
111
  c,
109
112
  () => {
110
- l(r) && l(e.value) && r.push({
113
+ a(r) && a(e.value) && r.push({
111
114
  ...e,
112
115
  query: { ...e.value.query, step: c.value ?? null }
113
116
  });
@@ -127,27 +130,29 @@ const ee = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
127
130
  0,
128
131
  v.indexOf(n)
129
132
  ).every(
130
- (C) => {
133
+ (N) => {
131
134
  var y;
132
- return (y = m.value[C]) == null ? void 0 : y.isValid;
135
+ return (y = m.value[N]) == null ? void 0 : y.isValid;
133
136
  }
134
137
  ) && d(n);
135
138
  }
136
- } else
137
- d(S.value[0]);
139
+ } else {
140
+ const s = Object.keys(T)[0];
141
+ d(s);
142
+ }
138
143
  }
139
144
  );
140
145
  else {
141
146
  const t = g(() => {
142
- if (l(e.value))
143
- return J(e.value.fullPath);
147
+ if (a(e.value))
148
+ return O(e.value.fullPath);
144
149
  });
145
150
  f(
146
151
  c,
147
152
  (s) => {
148
- l(e.value) && l(r) && (e.value.path.includes("step") ? r.push({
153
+ a(e.value) && a(r) && (e.value.path.includes("step") ? r.push({
149
154
  query: e.value.query,
150
- path: e.value.path.replace(R, `step/${s}`)
155
+ path: e.value.path.replace(x, `step/${s}`)
151
156
  }) : r.push({
152
157
  query: e.value.query,
153
158
  // Normalizes paths with / and without
@@ -162,14 +167,14 @@ const ee = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
162
167
  if (s && s !== c.value) {
163
168
  const n = s;
164
169
  if (n in o.value) {
165
- const v = n, h = Object.keys(o.value);
166
- h.slice(
170
+ const v = n, S = Object.keys(o.value);
171
+ S.slice(
167
172
  0,
168
- h.indexOf(v)
173
+ S.indexOf(v)
169
174
  ).every(
170
175
  (y) => {
171
- var E;
172
- return (E = o.value[y]) == null ? void 0 : E.isValid;
176
+ var k;
177
+ return (k = o.value[y]) == null ? void 0 : k.isValid;
173
178
  }
174
179
  ) && d(v);
175
180
  }
@@ -177,31 +182,10 @@ const ee = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
177
182
  }
178
183
  );
179
184
  }
180
- return {
181
- steps: S,
182
- current: b,
183
- goToNext: N,
184
- goToPrevious: x,
185
- goTo: d,
186
- key: c,
187
- data: a,
188
- at: O,
189
- get: k,
190
- goBackTo: w,
191
- isAfter: P,
192
- isBefore: j,
193
- isCurrent: A,
194
- isFirst: K,
195
- isLast: z,
196
- isNext: F,
197
- isPrevious: I,
198
- next: M,
199
- previous: U,
200
- stepNames: B
201
- };
185
+ return V;
202
186
  };
203
187
  export {
204
- ae as useWizard,
205
- ee as wizardInjectionKey
188
+ le as useWizard,
189
+ te as wizardInjectionKey
206
190
  };
207
191
  //# sourceMappingURL=index8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { computed, provide, reactive, watch, toValue, unref } from \"vue\";\nimport { mapValues } from \"@/utilities/functions/mapValues\";\nimport { useStepper } from \"@vueuse/core\";\nimport { useRoute } from \"./useRoute\";\nimport { useRouter } from \"./useRouter\";\nimport type { ComputedRef, MaybeRef } from \"vue\";\nimport { isNotNil } from \"@/utilities/functions/isNotNil\";\nimport { cloneDeep } from \"@/utilities/functions/cloneDeep\";\n\nexport const wizardInjectionKey = Symbol();\nexport type Step<U> = {\n /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * It determines if the validation has passed for the step.\n */\n isValid?: (state: U) => boolean;\n /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * Steps that do not pass the condition are removed.\n */\n condition?: (state: U) => boolean;\n [key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = Pick<\n ReturnType<typeof useWizard<T>>,\n | \"data\"\n | \"goToNext\"\n | \"goToPrevious\"\n | \"current\"\n | \"steps\"\n | \"at\"\n | \"get\"\n | \"goBackTo\"\n | \"isAfter\"\n | \"isBefore\"\n | \"isCurrent\"\n | \"isFirst\"\n | \"isLast\"\n | \"isNext\"\n | \"isPrevious\"\n | \"next\"\n | \"previous\"\n | \"stepNames\"\n>;\n\nconst regexMatchStep =\n /((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 const match = url.match(regexMatchStep);\n return match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n /**\n * The steps definition for the wizard\n */\n steps: MaybeRef<Record<string, Step<T>>>;\n /**\n * Name of the wizard used to persist state\n */\n name: string;\n /**\n * Initial set of data to be made available throughout\n */\n initialState: T;\n /**\n * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n */\n navigationMode?: \"query\" | \"route\";\n /**\n * Whether to use navigation at all. When disabled no query or URL is changed.\n */\n useNavigation?: boolean;\n /**\n *\n */\n persist?: boolean;\n}) => {\n if (!params.name) {\n throw new Error(\n \"You need to provide a unique name for the current wizard instance to be used to save data\"\n );\n }\n const route = useRoute();\n const router = useRouter();\n\n const useNavigation = params.useNavigation ?? true;\n const navigationMode = params.navigationMode ?? \"query\";\n const persist = params.persist ?? true;\n\n if (useNavigation && (!route.value || !router)) {\n throw new Error(\n \"Navigation is enabled but could not retrieve the router instance in useWizard.\"\n );\n }\n\n const initialStateCopy = { ...unref(params.initialState) };\n /**\n * Initial state is either read from session storage or the one provided\n */\n const innerState = reactive<typeof params.initialState>(\n persist && sessionStorage.getItem(params.name)\n ? {\n ...initialStateCopy,\n ...JSON.parse(sessionStorage.getItem(params.name)!),\n }\n : initialStateCopy\n );\n\n if (persist) {\n /**\n * Every time the state changes save it to sessionStorage\n */\n watch(innerState, () => {\n sessionStorage.setItem(params.name, JSON.stringify(innerState));\n });\n }\n\n /**\n * Steps can be passed as ref so we need to unwrap them\n */\n const unwrappedSteps = toValue(params.steps);\n const filteredSteps = computed(() =>\n Object.entries(unwrappedSteps).reduce(\n (acc: typeof unwrappedSteps, [key, step]) => {\n if (step.condition) {\n if (!step.condition(innerState as T)) {\n return acc;\n }\n }\n acc[key] = { ...step, key };\n return acc;\n },\n {}\n )\n );\n\n /**\n * Steps can have a isValid function that receives the current state\n * but we don't want to have to call it every single time so we call it once here\n */\n const mappedSteps = computed(() =>\n mapValues(filteredSteps.value, (step) => {\n return {\n ...step,\n isValid: step.isValid ? step.isValid(innerState as T) : true,\n };\n })\n );\n\n /**\n * Get the initial step from the query.\n * If it exists check that every step before it is also valid\n * so user cannot manually jump by changing the URL\n */\n let initialStep = null;\n if (useNavigation && isNotNil(route.value)) {\n let step: string | null = null;\n if (navigationMode === \"query\") {\n if (route.value.query.step) {\n step = route.value.query.step as string;\n }\n } else {\n const stepFromUrl = extractStepFromUrl(route.value.fullPath);\n if (stepFromUrl) {\n step = stepFromUrl;\n }\n }\n initialStep = step;\n }\n\n if (initialStep) {\n for (const stepName in filteredSteps.value) {\n if (stepName === initialStep) break;\n const current = mappedSteps.value[stepName];\n if (!current || !current.isValid) {\n initialStep = null;\n break;\n }\n }\n }\n\n /**\n * Define the state of the wizard\n * A few data come from useStepper\n */\n const {\n steps,\n current,\n goToNext,\n goToPrevious,\n goTo,\n index,\n at,\n get,\n goBackTo,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n next,\n previous,\n stepNames,\n } = useStepper(\n mappedSteps as any,\n initialStep || Object.values(filteredSteps.value)[0].key\n );\n\n const key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n /**\n * Complete state object\n */\n const state = {\n goToNext,\n goToPrevious,\n current: current as ComputedRef<Step<T> & { isValid: boolean }>,\n data: innerState,\n steps,\n at,\n get,\n goBackTo,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n next,\n previous,\n stepNames,\n };\n\n provide(wizardInjectionKey, state);\n\n if (useNavigation) {\n if (navigationMode === \"query\") {\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n () => {\n if (isNotNil(router) && isNotNil(route.value)) {\n router.push({\n ...route,\n query: { ...route.value.query, step: key.value ?? null },\n });\n }\n },\n { immediate: true }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => route.value?.query.step,\n (value) => {\n if (value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => mappedSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n } else {\n goTo(steps.value[0]);\n }\n }\n );\n } else {\n const stepFromUrl = computed(() => {\n if (isNotNil(route.value)) {\n return extractStepFromUrl(route.value.fullPath);\n }\n });\n\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n (value) => {\n if (isNotNil(route.value) && isNotNil(router)) {\n if (route.value.path.includes(\"step\")) {\n router.push({\n query: route.value.query,\n path: route.value.path.replace(regexMatchStep, `step/${value}`),\n });\n } else {\n router.push({\n query: route.value.query,\n // Normalizes paths with / and without\n path: (route.value.path + `/step/${value}`).replace(\"//\", \"/\"),\n replace: true,\n });\n }\n }\n },\n { immediate: true, flush: \"post\" }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => stepFromUrl.value,\n (value) => {\n if (value && value !== key.value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => filteredSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n }\n }\n );\n }\n }\n\n return {\n steps,\n current: current as ComputedRef<Step<T> & { isValid: boolean }>,\n goToNext,\n goToPrevious,\n goTo,\n key,\n data: innerState,\n at,\n get,\n goBackTo,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n next,\n previous,\n stepNames,\n };\n};\n"],"names":["wizardInjectionKey","regexMatchStep","extractStepFromUrl","url","match","_a","_b","useWizard","params","route","useRoute","router","useRouter","useNavigation","navigationMode","persist","initialStateCopy","unref","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","provide","value","stepAsString","stepAsKey","stepKeys"],"mappings":";;;;;;AASO,MAAMA,KAAqB,OAAO,GAwCnCC,IACJ,mEAKIC,IAAqB,CAACC,MAAgB;;AACpC,QAAAC,IAAQD,EAAI,MAAMF,CAAc;AACtC,WAAOI,IAAAD,KAAA,gBAAAA,EAAO,WAAP,gBAAAC,EAAe,WAAQC,IAAAF,KAAA,gBAAAA,EAAO,WAAP,gBAAAE,EAAe,UAAS;AACxD,GACaC,KAAY,CAAmBC,MA0BtC;AACA,MAAA,CAACA,EAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAGJ,QAAMC,IAAQC,KACRC,IAASC,KAETC,IAAgBL,EAAO,iBAAiB,IACxCM,IAAiBN,EAAO,kBAAkB,SAC1CO,IAAUP,EAAO,WAAW;AAElC,MAAIK,MAAkB,CAACJ,EAAM,SAAS,CAACE;AACrC,UAAM,IA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AM,GAAG;AAAA,YAC7D,SAAS;AAAA,UAAA,CACV;AAAA,QAGP;AAAA,QACA,EAAE,WAAW,IAAM,OAAO,OAAO;AAAA,MAAA,GAMnCnC;AAAA,QACE,MAAMY,EAAY;AAAA,QAClB,CAACuB,MAAU;AACL,cAAAA,KAASA,MAAU7B,EAAI,OAAO;AAChC,kBAAM8B,IAAeD;AACjB,gBAAAC,KAAgBjC,EAAc,OAAO;AACvC,oBAAMkC,IAAYD,GACZE,IAAW,OAAO,KAAKnC,EAAc,KAAK;AAQhD,cAP2BmC,EAAS;AAAA,gBAClC;AAAA,gBACAA,EAAS,QAAQD,CAAS;AAAA,cAAA,EAEQ;AAAA,gBAClC,CAAC/B,MAAAA;;AAAQ,0BAAArB,IAAAkB,EAAc,MAAMG,CAAG,MAAvB,gBAAArB,EAA0B;AAAA;AAAA,cAAA,KAGnCiC,EAAKmB,CAAS;AAAA,YAElB;AAAA,UACF;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAGK,SAAA;AAAA,IACL,OAAAtB;AAAA,IACA,SAAAD;AAAA,IACA,UAAAE;AAAA,IACA,cAAAC;AAAA,IACA,MAAAC;AAAA,IACA,KAAAZ;AAAA,IACA,MAAMR;AAAA,IACN,IAAAsB;AAAA,IACA,KAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,MAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { cloneDeep } from \"@/utilities/functions/cloneDeep\";\nimport { computed, provide, reactive, watch, toValue } 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 /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * It determines if the validation has passed for the step.\n */\n isValid?: (state: U) => boolean;\n /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * Steps that do not pass the condition are removed.\n */\n condition?: (state: U) => boolean;\n [key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = Pick<\n ReturnType<typeof useWizard<T>>,\n | \"data\"\n | \"goToNext\"\n | \"goToPrevious\"\n | \"current\"\n | \"steps\"\n | \"at\"\n | \"get\"\n | \"goBackTo\"\n | \"isAfter\"\n | \"isBefore\"\n | \"isCurrent\"\n | \"isFirst\"\n | \"isLast\"\n | \"isNext\"\n | \"isPrevious\"\n | \"next\"\n | \"previous\"\n | \"stepNames\"\n>;\n\nconst regexMatchStep =\n /((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 const match = url.match(regexMatchStep);\n return match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n /**\n * The steps definition for the wizard\n */\n steps: MaybeRef<Record<string, Step<T>>>;\n /**\n * Name of the wizard used to persist state\n */\n name: string;\n /**\n * Initial set of data to be made available throughout\n */\n initialState: T;\n /**\n * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n */\n navigationMode?: \"query\" | \"route\";\n /**\n * Whether to use navigation at all. When disabled no query or URL is changed.\n */\n useNavigation?: boolean;\n /**\n *\n */\n persist?: boolean;\n}) => {\n if (!params.name) {\n throw new Error(\n \"You need to provide a unique name for the current wizard instance to be used to save data\"\n );\n }\n const route = useRoute();\n const router = useRouter();\n\n const useNavigation = params.useNavigation ?? true;\n const navigationMode = params.navigationMode ?? \"query\";\n const persist = params.persist ?? true;\n\n if (useNavigation && (!route.value || !router)) {\n throw new Error(\n \"Navigation is enabled but could not retrieve the router instance in useWizard.\"\n );\n }\n\n const initialStateCopy = cloneDeep(params.initialState);\n /**\n * Initial state is either read from session storage or the one provided\n */\n const innerState = reactive<typeof params.initialState>(\n persist && sessionStorage.getItem(params.name)\n ? {\n ...initialStateCopy,\n ...JSON.parse(sessionStorage.getItem(params.name)!),\n }\n : initialStateCopy\n );\n\n if (persist) {\n /**\n * Every time the state changes save it to sessionStorage\n */\n watch(innerState, () => {\n sessionStorage.setItem(params.name, JSON.stringify(innerState));\n });\n }\n\n /**\n * Steps can be passed as ref so we need to unwrap them\n */\n const unwrappedSteps = toValue(params.steps);\n const filteredSteps = computed(() =>\n Object.entries(unwrappedSteps).reduce(\n (acc: typeof unwrappedSteps, [key, step]) => {\n if (step.condition) {\n if (!step.condition(innerState as T)) {\n return acc;\n }\n }\n acc[key] = { ...step, key };\n return acc;\n },\n {}\n )\n );\n\n /**\n * Steps can have a isValid function that receives the current state\n * but we don't want to have to call it every single time so we call it once here\n */\n const mappedSteps = computed(() =>\n mapValues(filteredSteps.value, (step) => {\n return {\n ...step,\n isValid: step.isValid ? step.isValid(innerState as T) : true,\n };\n })\n );\n\n /**\n * Get the initial step from the query.\n * If it exists check that every step before it is also valid\n * so user cannot manually jump by changing the URL\n */\n let initialStep = null;\n if (useNavigation && isNotNil(route.value)) {\n let step: string | null = null;\n if (navigationMode === \"query\") {\n if (route.value.query.step) {\n step = route.value.query.step as string;\n }\n } else {\n const stepFromUrl = extractStepFromUrl(route.value.fullPath);\n if (stepFromUrl) {\n step = stepFromUrl;\n }\n }\n initialStep = step;\n }\n\n if (initialStep) {\n for (const stepName in filteredSteps.value) {\n if (stepName === initialStep) break;\n const current = mappedSteps.value[stepName];\n if (!current || !current.isValid) {\n initialStep = null;\n break;\n }\n }\n }\n\n /**\n * Define the state of the wizard\n * A few data come from useStepper\n */\n const {\n steps,\n current,\n goToNext,\n goToPrevious,\n goTo,\n index,\n at,\n get,\n goBackTo,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n next,\n previous,\n stepNames,\n } = useStepper(\n mappedSteps,\n initialStep || Object.values(filteredSteps.value)[0].key\n );\n\n const key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n /**\n * Complete state object\n */\n const state = {\n at,\n current: current as ComputedRef<Step<T> & { isValid: boolean }>,\n data: innerState,\n get,\n goBackTo,\n goTo,\n goToNext,\n goToPrevious,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n key,\n next,\n previous,\n stepNames,\n steps,\n };\n\n provide(wizardInjectionKey, state);\n\n if (useNavigation) {\n if (navigationMode === \"query\") {\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n () => {\n if (isNotNil(router) && isNotNil(route.value)) {\n router.push({\n ...route,\n query: { ...route.value.query, step: key.value ?? null },\n });\n }\n },\n { immediate: true }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => route.value?.query.step,\n (value) => {\n if (value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => mappedSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n } else {\n const key = Object.keys(steps)[0];\n goTo(key);\n }\n }\n );\n } else {\n const stepFromUrl = computed(() => {\n if (isNotNil(route.value)) {\n return extractStepFromUrl(route.value.fullPath);\n }\n });\n\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n (value) => {\n if (isNotNil(route.value) && isNotNil(router)) {\n if (route.value.path.includes(\"step\")) {\n router.push({\n query: route.value.query,\n path: route.value.path.replace(regexMatchStep, `step/${value}`),\n });\n } else {\n router.push({\n query: route.value.query,\n // Normalizes paths with / and without\n path: (route.value.path + `/step/${value}`).replace(\"//\", \"/\"),\n replace: true,\n });\n }\n }\n },\n { immediate: true, flush: \"post\" }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => stepFromUrl.value,\n (value) => {\n if (value && value !== key.value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => filteredSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n }\n }\n );\n }\n }\n\n return 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,GAwCnCC,IACJ,mEAKIC,IAAqB,CAACC,MAAgB;;AACpC,QAAAC,IAAQD,EAAI,MAAMF,CAAc;AACtC,WAAOI,IAAAD,KAAA,gBAAAA,EAAO,WAAP,gBAAAC,EAAe,WAAQC,IAAAF,KAAA,gBAAAA,EAAO,WAAP,gBAAAE,EAAe,UAAS;AACxD,GACaC,KAAY,C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EAAStB,EAAM,KAAK,KAAKsB,EAASpB,CAAM,MACtCF,EAAM,MAAM,KAAK,SAAS,MAAM,IAClCE,EAAO,KAAK;AAAA,YACV,OAAOF,EAAM,MAAM;AAAA,YACnB,MAAMA,EAAM,MAAM,KAAK,QAAQR,GAAgB,QAAQuD,CAAK,EAAE;AAAA,UAAA,CAC/D,IAED7C,EAAO,KAAK;AAAA,YACV,OAAOF,EAAM,MAAM;AAAA;AAAA,YAEnB,OAAOA,EAAM,MAAM,OAAO,SAAS+C,CAAK,IAAI,QAAQ,MAAM,GAAG;AAAA,YAC7D,SAAS;AAAA,UAAA,CACV;AAAA,QAGP;AAAA,QACA,EAAE,WAAW,IAAM,OAAO,OAAO;AAAA,MAAA,GAMnCpC;AAAA,QACE,MAAMY,EAAY;AAAA,QAClB,CAACwB,MAAU;AACL,cAAAA,KAASA,MAAU9B,EAAI,OAAO;AAChC,kBAAM+B,IAAeD;AACjB,gBAAAC,KAAgBlC,EAAc,OAAO;AACvC,oBAAMmC,IAAYD,GACZE,IAAW,OAAO,KAAKpC,EAAc,KAAK;AAQhD,cAP2BoC,EAAS;AAAA,gBAClC;AAAA,gBACAA,EAAS,QAAQD,CAAS;AAAA,cAAA,EAEQ;AAAA,gBAClC,CAAChC,MAAAA;;AAAQ,0BAAArB,IAAAkB,EAAc,MAAMG,CAAG,MAAvB,gBAAArB,EAA0B;AAAA;AAAA,cAAA,KAGnCiC,EAAKoB,CAAS;AAAA,YAElB;AAAA,UACF;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAGK,SAAAJ;AACT;"}
package/dist/index81.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as a, computed as l, openBlock as s, createElementBlock as n, normalizeClass as m, createElementVNode as i, normalizeStyle as c } from "vue";
2
- import { clamp as p } from "./index195.js";
2
+ import { clamp as p } from "./index196.js";
3
3
  import { getAsPercentageBetween as d } from "./index121.js";
4
4
  const v = /* @__PURE__ */ a({
5
5
  __name: "BbProgress",