bitboss-ui 0.2.9 → 0.2.11
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/components/BaseButton/BaseButton.vue.d.ts +4 -2
- package/dist/components/BaseCheckbox/BaseCheckbox.vue.d.ts +4 -2
- package/dist/components/BaseCheckboxGroup/BaseCheckboxGroup.vue.d.ts +63 -3
- package/dist/components/BaseDatePicker/BaseDatePicker.vue.d.ts +22 -2
- package/dist/components/BaseDatePickerInput/BaseDatePickerInput.vue.d.ts +27 -2
- package/dist/components/BaseDialog/BaseDialog.vue.d.ts +2 -2
- package/dist/components/BaseInputContainer/BaseInputContainer.vue.d.ts +2 -2
- package/dist/components/BaseNumberInput/BaseNumberInput.vue.d.ts +2 -2
- package/dist/components/BaseRadio/BaseRadio.vue.d.ts +4 -2
- package/dist/components/BaseRadioGroup/BaseRadioGroup.vue.d.ts +63 -3
- package/dist/components/BaseRating/BaseRating.vue.d.ts +2 -2
- package/dist/components/BaseSelect/BaseSelect.vue.d.ts +3 -3
- package/dist/components/BaseSlider/BaseSlider.vue.d.ts +2 -2
- package/dist/components/BaseSwitch/BaseSwitch.vue.d.ts +2 -2
- package/dist/components/BaseSwitchGroup/BaseSwitchGroup.vue.d.ts +63 -3
- package/dist/components/BaseTag/BaseTag.vue.d.ts +2 -2
- package/dist/components/BaseTextInput/BaseTextInput.vue.d.ts +2 -2
- package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +2 -2
- package/dist/components/BbAccordion/BbAccordion.vue.d.ts +11 -2
- package/dist/components/BbAlert/BbAlert.vue.d.ts +9 -2
- package/dist/components/BbAvatar/BbAvatar.vue.d.ts +4 -2
- package/dist/components/BbBadge/BbBadge.vue.d.ts +5 -2
- package/dist/components/BbBreadcrumbs/BbBreadcrumbs.vue.d.ts +23 -2
- package/dist/components/BbButton/BbButton.vue.d.ts +4 -2
- package/dist/components/BbCheckbox/BbCheckbox.vue.d.ts +10 -2
- package/dist/components/BbCheckboxGroup/BbCheckboxGroup.vue.d.ts +75 -3
- package/dist/components/BbChip/BbChip.vue.d.ts +4 -2
- package/dist/components/BbCollapsible/BbCollapsible.vue.d.ts +4 -2
- package/dist/components/BbConfirm/BbConfirm.vue.d.ts +1 -1
- package/dist/components/BbDatePickerInput/BbDatePickerInput.vue.d.ts +35 -2
- package/dist/components/BbDialog/BbDialog.vue.d.ts +2 -2
- package/dist/components/BbDropdown/BbDropdown.vue.d.ts +80 -2
- package/dist/components/BbDropdownButton/BbDropdownButton.vue.d.ts +92 -2
- package/dist/components/BbDropzone/BbDropzone.vue.d.ts +7 -2
- package/dist/components/BbHover/BbHover.vue.d.ts +9 -2
- package/dist/components/BbIcon/BbIcon.vue.d.ts +1 -1
- package/dist/components/BbIntersection/BbIntersection.vue.d.ts +8 -2
- package/dist/components/BbNumberInput/BbNumberInput.vue.d.ts +7 -2
- package/dist/components/BbOffCanvas/BbOffCanvas.vue.d.ts +2 -2
- package/dist/components/BbPagination/BbPagination.vue.d.ts +11 -2
- package/dist/components/BbPopover/BbPopover.vue.d.ts +21 -2
- package/dist/components/BbProgress/BbProgress.vue.d.ts +1 -1
- package/dist/components/BbRadio/BbRadio.vue.d.ts +10 -2
- package/dist/components/BbRadioGroup/BbRadioGroup.vue.d.ts +75 -3
- package/dist/components/BbRating/BbRating.vue.d.ts +7 -2
- package/dist/components/BbRatio/BbRatio.vue.d.ts +4 -2
- package/dist/components/BbSelect/BbSelect.vue.d.ts +3 -3
- package/dist/components/BbSlider/BbSlider.vue.d.ts +7 -2
- package/dist/components/BbSmoothHeight/BbSmoothHeight.vue.d.ts +2 -2
- package/dist/components/BbSpinner/BbSpinner.vue.d.ts +1 -1
- package/dist/components/BbSwitch/BbSwitch.vue.d.ts +10 -2
- package/dist/components/BbSwitchGroup/BbSwitchGroup.vue.d.ts +75 -3
- package/dist/components/BbTab/BbTab.vue.d.ts +29 -5
- package/dist/components/BbTable/BbTable.vue.d.ts +38 -2
- package/dist/components/BbTag/BbTag.vue.d.ts +2 -2
- package/dist/components/BbTextInput/BbTextInput.vue.d.ts +7 -2
- package/dist/components/BbTextarea/BbTextarea.vue.d.ts +7 -2
- package/dist/components/BbToast/BbToast.vue.d.ts +1 -1
- package/dist/components/BbToast/BbToastMessage.vue.d.ts +1 -1
- package/dist/components/BbTooltip/BbTooltip.vue.d.ts +2 -2
- package/dist/components/BbTree/BbTree.vue.d.ts +2 -2
- package/dist/index101.js +3 -3
- package/dist/index103.js +2 -2
- package/dist/index109.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index111.js +5 -6
- package/dist/index111.js.map +1 -1
- package/dist/index113.js +1 -1
- package/dist/index115.js +7 -7
- package/dist/index115.js.map +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.js +1 -1
- package/dist/index118.js +1 -1
- package/dist/index119.js +1 -1
- package/dist/index121.js +1 -1
- package/dist/index125.js +1 -1
- package/dist/index126.js +1 -1
- package/dist/index128.js +2 -2
- package/dist/index128.js.map +1 -1
- package/dist/index15.js +8 -8
- package/dist/index17.js +25 -25
- package/dist/index19.js +3 -3
- package/dist/index195.js +2 -2
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +2 -4
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +2 -2
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +2 -5
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +5 -16
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +10 -10
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +15 -18
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +18 -19
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +15 -24
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +29 -8
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +8 -2
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +2 -351
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +4 -2
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +378 -6
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +126 -361
- package/dist/index209.js.map +1 -1
- package/dist/index21.js +2 -2
- package/dist/index210.js +174 -3
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +23 -35
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +371 -8
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +3 -134
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +3 -2
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +3 -186
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +35 -23
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +6 -2
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +2 -235
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +10 -3
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +235 -3
- package/dist/index220.js.map +1 -1
- package/dist/index222.js +67 -62
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +1 -1
- package/dist/index225.js +1 -1
- package/dist/index226.js +295 -4
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +5 -294
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +2 -6
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +2 -2
- package/dist/index23.js +2 -2
- package/dist/index23.js.map +1 -1
- package/dist/index234.js +4 -2
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +2 -117
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +111 -100
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +105 -68
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +224 -2
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +258 -2
- package/dist/index239.js.map +1 -1
- package/dist/index240.js +426 -153
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +89 -2
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +67 -433
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +161 -88
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +2 -200
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +2 -2
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +2 -224
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +200 -258
- package/dist/index247.js.map +1 -1
- package/dist/index25.js +2 -2
- package/dist/index251.js +1 -1
- package/dist/index252.js +1 -1
- package/dist/index253.js +2 -2
- package/dist/index29.js +3 -3
- package/dist/index31.js +52 -52
- package/dist/index31.js.map +1 -1
- package/dist/index33.js +2 -2
- package/dist/index35.js +2 -2
- package/dist/index43.js +5 -5
- package/dist/index43.js.map +1 -1
- package/dist/index47.js +1 -1
- package/dist/index49.js +1 -1
- package/dist/index65.js +5 -5
- package/dist/index69.js +30 -30
- package/dist/index69.js.map +1 -1
- package/dist/index72.js +1 -1
- package/dist/index75.js +1 -1
- package/dist/index79.js +5 -5
- package/dist/index8.js +56 -56
- package/dist/index8.js.map +1 -1
- package/dist/index81.js +1 -1
- package/dist/style.css +1 -1
- package/dist/utilities/functions/cloneDeep.d.ts +1 -1
- package/package.json +2 -2
package/dist/index69.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { defineComponent as H, ref as h, watch as
|
|
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
2
|
import { findInTree as X } from "./index224.js";
|
|
3
3
|
import { useId as ee } from "./index7.js";
|
|
4
4
|
import te from "./index118.js";
|
|
5
5
|
import "./index182.js";
|
|
6
|
-
const re = ["
|
|
6
|
+
const re = ["accept", "autofocus", "disabled", "multiple"], ae = {
|
|
7
7
|
class: "bb-dropzone__submittable-label",
|
|
8
8
|
"aria-hidden": "true"
|
|
9
|
-
},
|
|
9
|
+
}, oe = ["id", "name", "multiple", "disabled"], le = { class: "bb-dropzone__errors" }, de = /* @__PURE__ */ H({
|
|
10
10
|
__name: "BbDropzone",
|
|
11
11
|
props: {
|
|
12
12
|
autofocus: {},
|
|
@@ -23,16 +23,16 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
23
23
|
tag: { default: "div" }
|
|
24
24
|
},
|
|
25
25
|
emits: ["blur", "error", "focus", "update:modelValue"],
|
|
26
|
-
setup(
|
|
26
|
+
setup(F, { emit: D }) {
|
|
27
27
|
let y;
|
|
28
|
-
const r =
|
|
28
|
+
const r = F, l = D, p = h(null);
|
|
29
29
|
if (r.accept && !Array.isArray(r.accept))
|
|
30
30
|
throw new Error("Property accept is not an array");
|
|
31
31
|
if (r.multiple && !Array.isArray(r.modelValue))
|
|
32
32
|
throw new Error(
|
|
33
33
|
"Component is set to multiple but modelValue is not an array"
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
M(
|
|
36
36
|
() => r.modelValue,
|
|
37
37
|
() => {
|
|
38
38
|
let e = new DataTransfer();
|
|
@@ -42,7 +42,7 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
42
42
|
const c = h([]), C = m(
|
|
43
43
|
() => c.value.join(",")
|
|
44
44
|
);
|
|
45
|
-
|
|
45
|
+
M(
|
|
46
46
|
() => r.accept,
|
|
47
47
|
async () => {
|
|
48
48
|
if (r.accept) {
|
|
@@ -66,17 +66,17 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
66
66
|
},
|
|
67
67
|
{ immediate: !0 }
|
|
68
68
|
);
|
|
69
|
-
const b = r.id || `${ee().id.value}`, V = `bb_dz_${b}`,
|
|
69
|
+
const b = r.id || `${ee().id.value}`, V = `bb_dz_${b}`, n = h(!1);
|
|
70
70
|
let v;
|
|
71
71
|
const I = m(() => ({
|
|
72
72
|
"bb-dropzone": !0,
|
|
73
73
|
"bb-dropzone--errors": q.value,
|
|
74
|
-
"bb-dropzone--dragging":
|
|
74
|
+
"bb-dropzone--dragging": n.value
|
|
75
75
|
})), L = m(() => ({
|
|
76
|
-
dragging:
|
|
76
|
+
dragging: n.value,
|
|
77
77
|
id: b
|
|
78
78
|
})), P = (e) => {
|
|
79
|
-
if (
|
|
79
|
+
if (n.value = !1, e.dataTransfer) {
|
|
80
80
|
e.stopImmediatePropagation();
|
|
81
81
|
let t;
|
|
82
82
|
if (t = Array.from(e.dataTransfer.files), t = T(t), r.multiple ? Array.isArray(r.modelValue) && l("update:modelValue", [...r.modelValue, ...t]) : (t = t[0], l("update:modelValue", t)), e.currentTarget instanceof HTMLLabelElement) {
|
|
@@ -97,10 +97,10 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
97
97
|
return l("error", f.maxSize(t)), !1;
|
|
98
98
|
let o = !1;
|
|
99
99
|
return r.modelValue && (Array.isArray(r.modelValue) ? o = r.modelValue.some(
|
|
100
|
-
(s) =>
|
|
101
|
-
) : o =
|
|
100
|
+
(s) => S(s, t)
|
|
101
|
+
) : o = S(r.modelValue, t)), o ? (l("error", f.uniqueness(t)), !1) : r.accept && !c.value.some((i) => {
|
|
102
102
|
let u = !1;
|
|
103
|
-
return
|
|
103
|
+
return i.includes("*") ? u = u || i.split("/")[0] === t.type.split("/")[0] : u = u || i === t.type, u;
|
|
104
104
|
}) ? (l("error", f.accept(t)), !1) : r.maxFiles && Array.isArray(r.modelValue) && r.modelValue.length + a + 1 > r.maxFiles ? (l(
|
|
105
105
|
"error",
|
|
106
106
|
f.maxFiles(t, r.modelValue.length + a + 1)
|
|
@@ -116,17 +116,17 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
116
116
|
a && (a.id === V ? B() : E());
|
|
117
117
|
}
|
|
118
118
|
}, B = () => {
|
|
119
|
-
clearTimeout(v),
|
|
119
|
+
clearTimeout(v), n.value = !0;
|
|
120
120
|
}, E = () => {
|
|
121
121
|
v = setTimeout(() => {
|
|
122
|
-
|
|
122
|
+
n.value = !1;
|
|
123
123
|
}, 100);
|
|
124
124
|
}, A = (e, t = 2) => {
|
|
125
125
|
if (!e)
|
|
126
126
|
return "0 B";
|
|
127
|
-
const a = 1024, o = t || 0, s = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
|
128
|
-
return parseFloat((e / Math.pow(a,
|
|
129
|
-
},
|
|
127
|
+
const a = 1024, o = t || 0, s = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], i = Math.floor(Math.log(e) / Math.log(a));
|
|
128
|
+
return parseFloat((e / Math.pow(a, i)).toFixed(o)) + " " + s[i];
|
|
129
|
+
}, S = (e, t) => !["name", "size", "lastModified", "type"].some((o) => e[o] !== t[o]), f = {
|
|
130
130
|
maxSize: (e) => {
|
|
131
131
|
if (r.maxSize)
|
|
132
132
|
return {
|
|
@@ -157,14 +157,14 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
157
157
|
totalFiles: t,
|
|
158
158
|
filename: e.name
|
|
159
159
|
})
|
|
160
|
-
},
|
|
161
|
-
() => !!
|
|
160
|
+
}, w = m(() => r.errors ? [].concat(r.errors) : []), q = m(
|
|
161
|
+
() => !!w.value.length || r.hasErrors
|
|
162
162
|
);
|
|
163
163
|
return (e, t) => (z(), N(R(e.tag), {
|
|
164
164
|
class: j(I.value),
|
|
165
165
|
id: V
|
|
166
166
|
}, {
|
|
167
|
-
default:
|
|
167
|
+
default: _(() => [
|
|
168
168
|
d("label", {
|
|
169
169
|
onDrop: g(P, ["prevent"]),
|
|
170
170
|
onDragenter: g(B, ["prevent"]),
|
|
@@ -180,10 +180,10 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
180
180
|
onChange: $,
|
|
181
181
|
onFocus: t[0] || (t[0] = (a) => e.$emit("focus", a)),
|
|
182
182
|
onBlur: t[1] || (t[1] = (a) => e.$emit("blur", a))
|
|
183
|
-
}, null, 40,
|
|
183
|
+
}, null, 40, re),
|
|
184
184
|
G(e.$slots, "default", K(O(L.value)))
|
|
185
|
-
],
|
|
186
|
-
d("label",
|
|
185
|
+
], 32),
|
|
186
|
+
d("label", ae, [
|
|
187
187
|
U(" Server files "),
|
|
188
188
|
d("input", {
|
|
189
189
|
class: "bb-dropzone__submittable-input",
|
|
@@ -194,12 +194,12 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
194
194
|
ref: p,
|
|
195
195
|
multiple: e.multiple,
|
|
196
196
|
disabled: e.disabled
|
|
197
|
-
}, null, 8,
|
|
197
|
+
}, null, 8, oe)
|
|
198
198
|
]),
|
|
199
|
-
d("span",
|
|
199
|
+
d("span", le, [
|
|
200
200
|
Z(te, { tag: "span" }, {
|
|
201
|
-
default:
|
|
202
|
-
(z(!0),
|
|
201
|
+
default: _(() => [
|
|
202
|
+
(z(!0), x(J, null, Q(w.value, (a) => (z(), x("span", {
|
|
203
203
|
class: "bb-dropzone__error",
|
|
204
204
|
key: a
|
|
205
205
|
}, W(a), 1))), 128))
|
|
@@ -213,6 +213,6 @@ const re = ["onDrop", "onDragenter", "onDragover", "onDragleave"], ae = ["accept
|
|
|
213
213
|
}
|
|
214
214
|
});
|
|
215
215
|
export {
|
|
216
|
-
|
|
216
|
+
de as default
|
|
217
217
|
};
|
|
218
218
|
//# sourceMappingURL=index69.js.map
|
package/dist/index69.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index69.js","sources":["../src/components/BbDropzone/BbDropzone.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { createElementVNode as _createElementVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, renderSlot as _renderSlot, withModifiers as _withModifiers, unref as _unref, createTextVNode as _createTextVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, withCtx as _withCtx, createVNode as _createVNode, resolveDynamicComponent as _resolveDynamicComponent, normalizeClass as _normalizeClass, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = [\"onDrop\", \"onDragenter\", \"onDragover\", \"onDragleave\"]\nconst _hoisted_2 = [\"accept\", \"autofocus\", \"disabled\", \"multiple\"]\nconst _hoisted_3 = {\n class: \"bb-dropzone__submittable-label\",\n \"aria-hidden\": \"true\"\n}\nconst _hoisted_4 = [\"id\", \"name\", \"multiple\", \"disabled\"]\nconst _hoisted_5 = { class: \"bb-dropzone__errors\" }\n\nimport { computed, ref, watch } from \"vue\";\nimport { findInTree } from \"@/utilities/functions/findInTree\";\nimport { useId } from \"@/composables/useId\";\nimport BbSmoothHeight from \"../BbSmoothHeight/BbSmoothHeight.vue\";\nimport type { CommonProps, NonVoidElementTag } from \"@/types/CommonProps\";\n\nexport type DropZoneError = ReturnType<\n (typeof createError)[keyof typeof createError]\n>;\n\nexport type BbDropzoneProps = Pick<CommonProps, \n'autofocus' |\n'disabled' |\n'errors' |\n'hasErrors' |\n'id' |\n'multiple' |\n'name'\n> & {\n /**\n * Array of mime-types or extensions to filter selectable files.\n */\n accept?: string[];\n /**\n * Maximum number of acceptable files\n */\n maxFiles?: number;\n /**\n * Max size of the files in bytes.\n */\n maxSize?: number;\n /**\n * Used by v-model.\n */\n modelValue: any;\n} & NonVoidElementTag\n\n// This is the dynamic import for mime\nexport type BbDropzoneEvents = {\n (e: \"blur\", event: FocusEvent): void;\n (e: \"error\", data: DropZoneError): void;\n (e: \"focus\", event: FocusEvent): void;\n (e: \"update:modelValue\", data: any): void;\n};\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbDropzone',\n props: {\n autofocus: {},\n disabled: { type: Boolean },\n errors: {},\n hasErrors: { type: Boolean },\n id: {},\n multiple: { type: Boolean },\n name: {},\n accept: {},\n maxFiles: {},\n maxSize: {},\n modelValue: {},\n tag: { default: \"div\" }\n },\n emits: [\"blur\", \"error\", \"focus\", \"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nlet mime: any;\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst submittable = ref<any | null>(null);\n\nif (props.accept) {\n if (!Array.isArray(props.accept)) {\n throw new Error(\"Property accept is not an array\");\n }\n}\nif (props.multiple) {\n if (!Array.isArray(props.modelValue)) {\n throw new Error(\n \"Component is set to multiple but modelValue is not an array\"\n );\n }\n}\n\n/** Allow dropzone to be submittable (this is flimsy and might break) */\nwatch(\n () => props.modelValue,\n () => {\n let container = new DataTransfer();\n if (Array.isArray(props.modelValue)) {\n if (props.modelValue.length) {\n props.modelValue.forEach((file) => container.items.add(file));\n }\n } else {\n if (props.modelValue) container.items.add(props.modelValue);\n }\n if (submittable.value) {\n if (container.items.length) {\n submittable.value.files = container.files;\n } else {\n submittable.value.files = null;\n }\n }\n }\n);\n\nconst acceptedMimeTypes = ref<string[]>([]);\nconst acceptedMimeTypesString = computed(() =>\n acceptedMimeTypes.value.join(\",\")\n);\nwatch(\n () => props.accept,\n async () => {\n if (props.accept) {\n let accumulated = [];\n for (let i = 0; i < props.accept.length; i++) {\n const element = props.accept[i];\n if (element.includes(\"/\")) accumulated.push(element);\n else {\n if (!mime) mime = await import(\"mime\");\n const foundMime = mime.getType(element);\n if (!foundMime) {\n throw new Error(\n `Could not detect the correct mime associated with ${element}`\n );\n }\n accumulated.push(foundMime);\n }\n }\n acceptedMimeTypes.value = accumulated;\n }\n },\n { immediate: true }\n);\n\n/**\n * Component state\n */\nconst id = props.id || `${useId().id.value}`;\nconst containerId = `bb_dz_${id}`;\n\nconst dragging = ref(false);\n// Add a timeout to prevent browser flickering\nlet draggingTimeout: ReturnType<typeof setTimeout>;\n\nconst classes = computed(() => {\n return {\n \"bb-dropzone\": true,\n \"bb-dropzone--errors\": hasErrors.value,\n \"bb-dropzone--dragging\": dragging.value,\n };\n});\nconst slotAttributes = computed(() => {\n return {\n dragging: dragging.value,\n id: id,\n };\n});\n\n/**\n * Component handlers\n */\nconst onDrop = (event: DragEvent) => {\n dragging.value = false;\n\n if (event.dataTransfer) {\n event.stopImmediatePropagation();\n let files;\n files = Array.from(event.dataTransfer.files);\n files = parseFiles(files);\n if (props.multiple) {\n if (Array.isArray(props.modelValue)) {\n emit(\"update:modelValue\", [...props.modelValue, ...files]);\n }\n } else {\n files = files[0];\n emit(\"update:modelValue\", files);\n }\n if (event.currentTarget instanceof HTMLLabelElement) {\n const innerInput = event.currentTarget.querySelector(\"input[type=file]\");\n if (innerInput instanceof HTMLInputElement) {\n innerInput.focus();\n }\n }\n }\n};\nconst onChange = (event: Event) => {\n if (event.target instanceof HTMLInputElement) {\n if (event.target.files) {\n let files;\n files = parseFiles(Array.from(event.target.files));\n if (props.multiple) {\n if (Array.isArray(props.modelValue)) {\n emit(\"update:modelValue\", [...props.modelValue, ...files]);\n }\n } else {\n files = files[0];\n emit(\"update:modelValue\", files);\n }\n }\n event.target.value = \"\";\n event.target.files = null;\n }\n};\n\nconst parseFiles = (files: File[]) => {\n return files.filter((file, index) => {\n // Sizecheck\n if (props.maxSize) {\n let passing = file.size <= props.maxSize;\n if (!passing) {\n emit(\"error\", createError.maxSize(file));\n return false;\n }\n }\n // Uniqueness check\n let alreadyExists = false;\n if (props.modelValue) {\n if (Array.isArray(props.modelValue)) {\n alreadyExists = props.modelValue.some((current) =>\n compareFiles(current, file)\n );\n } else {\n alreadyExists = compareFiles(props.modelValue, file);\n }\n }\n if (alreadyExists) {\n emit(\"error\", createError.uniqueness(file));\n return false;\n }\n // Mime type check\n if (props.accept) {\n const mimePassed = acceptedMimeTypes.value.some((mime) => {\n let found = false;\n if (mime.includes(\"*\"))\n found = found || mime.split(\"/\")[0] === file.type.split(\"/\")[0];\n else found = found || mime === file.type;\n return found;\n });\n if (!mimePassed) {\n emit(\"error\", createError.accept(file));\n return false;\n }\n }\n // Max files check\n if (props.maxFiles) {\n if (Array.isArray(props.modelValue)) {\n if (props.modelValue.length + index + 1 > props.maxFiles) {\n emit(\n \"error\",\n createError.maxFiles(file, props.modelValue.length + index + 1)\n );\n return false;\n }\n }\n }\n return true;\n });\n};\n\nconst onDragOver = (event: Event) => {\n // Find the closest dropzone in case of nested dropzones\n const target = event.target;\n if (target instanceof HTMLElement) {\n const closestDropzone = findInTree([target], \"parentElement\", (el) =>\n el.classList.contains(\"bb-dropzone\")\n );\n if (closestDropzone) {\n /* When dragging over this dropzone set as dragging */\n if (closestDropzone.id === containerId) {\n setDragging();\n /* When dragging over a nested dropzone do not highlight this dropzone */\n } else {\n unsetDragging();\n }\n }\n }\n};\n\nconst setDragging = () => {\n clearTimeout(draggingTimeout);\n dragging.value = true;\n};\n\nconst unsetDragging = () => {\n draggingTimeout = setTimeout(() => {\n dragging.value = false;\n }, 100);\n};\n\nconst bytesToUnit = (bytes: number, decimals = 2) => {\n if (!bytes) return \"0 B\";\n const k = 1024;\n const dm = decimals || 0;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + \" \" + sizes[i];\n};\n\n/**\n * Returns true if files are identical by the properties that are accessible\n * @param file The file to check\n * @param otherFile The file to check against\n */\nconst compareFiles = (file: File, otherFile: File) => {\n const properties: (keyof File)[] = [\"name\", \"size\", \"lastModified\", \"type\"];\n return !properties.some((key) => file[key] !== otherFile[key]);\n};\n\n/**\n * Helper that creates errors based on component properties\n */\nconst createError = {\n maxSize: (file: File) => {\n // Todo update to isNil\n if (props.maxSize) {\n return {\n type: \"maxSize\",\n file: file,\n formattedMaxSize: bytesToUnit(+props.maxSize),\n formattedSize: bytesToUnit(file.size),\n filename: file.name,\n } as const;\n } else throw new Error('Requested to create an error for maxSize without providing a maxSize.')\n },\n uniqueness: (file: File) => {\n return {\n type: \"uniqueness\",\n file: file,\n filename: file.name,\n } as const;\n },\n accept: (file: File) => {\n return {\n type: \"accept\",\n file: file,\n acceptedMimeTypes: acceptedMimeTypes.value,\n mimeType: file.type,\n filename: file.name,\n } as const;\n },\n maxFiles: (file: File, totalFiles: number) => {\n return {\n type: \"maxFiles\",\n file: file,\n maxFiles: props.maxFiles,\n totalFiles,\n filename: file.name,\n } as const;\n },\n};\n\nconst computedErrors = computed(() => {\n return props.errors ? ([] as string[]).concat(props.errors) : [];\n});\n\nconst hasErrors = computed(\n () => Boolean(computedErrors.value.length) || props.hasErrors\n);\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createBlock(_resolveDynamicComponent(_ctx.tag), {\n class: _normalizeClass(classes.value),\n id: containerId\n }, {\n default: _withCtx(() => [\n _createElementVNode(\"label\", {\n onDrop: _withModifiers(onDrop, [\"prevent\"]),\n onDragenter: _withModifiers(setDragging, [\"prevent\"]),\n onDragover: _withModifiers(onDragOver, [\"prevent\"]),\n onDragleave: _withModifiers(unsetDragging, [\"prevent\"])\n }, [\n _createElementVNode(\"input\", {\n type: \"file\",\n accept: acceptedMimeTypesString.value,\n autofocus: _ctx.autofocus,\n disabled: _ctx.disabled,\n multiple: _ctx.multiple,\n onChange: onChange,\n onFocus: _cache[0] || (_cache[0] = (event) => _ctx.$emit('focus', event)),\n onBlur: _cache[1] || (_cache[1] = (event) => _ctx.$emit('blur', event))\n }, null, 40, _hoisted_2),\n _renderSlot(_ctx.$slots, \"default\", _normalizeProps(_guardReactiveProps(slotAttributes.value)))\n ], 40, _hoisted_1),\n _createElementVNode(\"label\", _hoisted_3, [\n _createTextVNode(\" Server files \"),\n _createElementVNode(\"input\", {\n class: \"bb-dropzone__submittable-input\",\n type: \"file\",\n id: _unref(id),\n name: _ctx.name,\n ref_key: \"submittable\",\n ref: submittable,\n multiple: _ctx.multiple,\n disabled: _ctx.disabled\n }, null, 8, _hoisted_4)\n ]),\n _createElementVNode(\"span\", _hoisted_5, [\n _createVNode(BbSmoothHeight, { tag: \"span\" }, {\n default: _withCtx(() => [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(computedErrors.value, (error) => {\n return (_openBlock(), _createElementBlock(\"span\", {\n class: \"bb-dropzone__error\",\n key: error\n }, _toDisplayString(error), 1))\n }), 128))\n ]),\n _: 1\n })\n ])\n ]),\n _: 3\n }, 8, [\"class\"]))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_sfc_main","_defineComponent","__props","__emit","mime","props","emit","submittable","ref","watch","container","file","acceptedMimeTypes","acceptedMimeTypesString","computed","accumulated","i","element","foundMime","id","useId","containerId","dragging","draggingTimeout","classes","hasErrors","slotAttributes","onDrop","event","files","parseFiles","innerInput","onChange","index","createError","alreadyExists","current","compareFiles","found","onDragOver","target","closestDropzone","findInTree","el","setDragging","unsetDragging","bytesToUnit","bytes","decimals","k","dm","sizes","otherFile","key","totalFiles","computedErrors","_ctx","_cache","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_withCtx","_createElementVNode","_withModifiers","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode","_unref","_createVNode","BbSmoothHeight","_createElementBlock","_Fragment","_renderList","error","_toDisplayString"],"mappings":";;;;;AAGA,MAAMA,KAAa,CAAC,UAAU,eAAe,cAAc,aAAa,GAClEC,KAAa,CAAC,UAAU,aAAa,YAAY,UAAU,GAC3DC,KAAa;AAAA,EACjB,OAAO;AAAA,EACP,eAAe;AACjB,GACMC,KAAa,CAAC,MAAM,QAAQ,YAAY,UAAU,GAClDC,KAAa,EAAE,OAAO,yBA+CAC,KAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,WAAW,CAAC;AAAA,IACZ,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC1B,QAAQ,CAAC;AAAA,IACT,WAAW,EAAE,MAAM,QAAQ;AAAA,IAC3B,IAAI,CAAC;AAAA,IACL,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC1B,MAAM,CAAC;AAAA,IACP,QAAQ,CAAC;A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;AAAA,UAAA,CACJ;AAAA,QAAA,CACF;AAAA,MAAA,CACF;AAAA,MACD,GAAG;AAAA,IAAA,GACF,GAAG,CAAC,OAAO,CAAC;AAAA,EAEjB;AAEA,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index69.js","sources":["../src/components/BbDropzone/BbDropzone.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { createElementVNode as _createElementVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, renderSlot as _renderSlot, withModifiers as _withModifiers, unref as _unref, createTextVNode as _createTextVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, withCtx as _withCtx, createVNode as _createVNode, resolveDynamicComponent as _resolveDynamicComponent, normalizeClass as _normalizeClass, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = [\"accept\", \"autofocus\", \"disabled\", \"multiple\"]\nconst _hoisted_2 = {\n class: \"bb-dropzone__submittable-label\",\n \"aria-hidden\": \"true\"\n}\nconst _hoisted_3 = [\"id\", \"name\", \"multiple\", \"disabled\"]\nconst _hoisted_4 = { class: \"bb-dropzone__errors\" }\n\nimport { computed, ref, watch } from \"vue\";\nimport { findInTree } from \"@/utilities/functions/findInTree\";\nimport { useId } from \"@/composables/useId\";\nimport BbSmoothHeight from \"../BbSmoothHeight/BbSmoothHeight.vue\";\nimport type { CommonProps, NonVoidElementTag } from \"@/types/CommonProps\";\n\nexport type DropZoneError = ReturnType<\n (typeof createError)[keyof typeof createError]\n>;\n\nexport type BbDropzoneProps = Pick<CommonProps, \n'autofocus' |\n'disabled' |\n'errors' |\n'hasErrors' |\n'id' |\n'multiple' |\n'name'\n> & {\n /**\n * Array of mime-types or extensions to filter selectable files.\n */\n accept?: string[];\n /**\n * Maximum number of acceptable files\n */\n maxFiles?: number;\n /**\n * Max size of the files in bytes.\n */\n maxSize?: number;\n /**\n * Used by v-model.\n */\n modelValue: any;\n} & NonVoidElementTag\n\n// This is the dynamic import for mime\nexport type BbDropzoneEvents = {\n (e: \"blur\", event: FocusEvent): void;\n (e: \"error\", data: DropZoneError): void;\n (e: \"focus\", event: FocusEvent): void;\n (e: \"update:modelValue\", data: any): void;\n};\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbDropzone',\n props: {\n autofocus: {},\n disabled: { type: Boolean },\n errors: {},\n hasErrors: { type: Boolean },\n id: {},\n multiple: { type: Boolean },\n name: {},\n accept: {},\n maxFiles: {},\n maxSize: {},\n modelValue: {},\n tag: { default: \"div\" }\n },\n emits: [\"blur\", \"error\", \"focus\", \"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nlet mime: any;\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst submittable = ref<any | null>(null);\n\nif (props.accept) {\n if (!Array.isArray(props.accept)) {\n throw new Error(\"Property accept is not an array\");\n }\n}\nif (props.multiple) {\n if (!Array.isArray(props.modelValue)) {\n throw new Error(\n \"Component is set to multiple but modelValue is not an array\"\n );\n }\n}\n\n/** Allow dropzone to be submittable (this is flimsy and might break) */\nwatch(\n () => props.modelValue,\n () => {\n let container = new DataTransfer();\n if (Array.isArray(props.modelValue)) {\n if (props.modelValue.length) {\n props.modelValue.forEach((file) => container.items.add(file));\n }\n } else {\n if (props.modelValue) container.items.add(props.modelValue);\n }\n if (submittable.value) {\n if (container.items.length) {\n submittable.value.files = container.files;\n } else {\n submittable.value.files = null;\n }\n }\n }\n);\n\nconst acceptedMimeTypes = ref<string[]>([]);\nconst acceptedMimeTypesString = computed(() =>\n acceptedMimeTypes.value.join(\",\")\n);\nwatch(\n () => props.accept,\n async () => {\n if (props.accept) {\n let accumulated = [];\n for (let i = 0; i < props.accept.length; i++) {\n const element = props.accept[i];\n if (element.includes(\"/\")) accumulated.push(element);\n else {\n if (!mime) mime = await import(\"mime\");\n const foundMime = mime.getType(element);\n if (!foundMime) {\n throw new Error(\n `Could not detect the correct mime associated with ${element}`\n );\n }\n accumulated.push(foundMime);\n }\n }\n acceptedMimeTypes.value = accumulated;\n }\n },\n { immediate: true }\n);\n\n/**\n * Component state\n */\nconst id = props.id || `${useId().id.value}`;\nconst containerId = `bb_dz_${id}`;\n\nconst dragging = ref(false);\n// Add a timeout to prevent browser flickering\nlet draggingTimeout: ReturnType<typeof setTimeout>;\n\nconst classes = computed(() => {\n return {\n \"bb-dropzone\": true,\n \"bb-dropzone--errors\": hasErrors.value,\n \"bb-dropzone--dragging\": dragging.value,\n };\n});\nconst slotAttributes = computed(() => {\n return {\n dragging: dragging.value,\n id: id,\n };\n});\n\n/**\n * Component handlers\n */\nconst onDrop = (event: DragEvent) => {\n dragging.value = false;\n\n if (event.dataTransfer) {\n event.stopImmediatePropagation();\n let files;\n files = Array.from(event.dataTransfer.files);\n files = parseFiles(files);\n if (props.multiple) {\n if (Array.isArray(props.modelValue)) {\n emit(\"update:modelValue\", [...props.modelValue, ...files]);\n }\n } else {\n files = files[0];\n emit(\"update:modelValue\", files);\n }\n if (event.currentTarget instanceof HTMLLabelElement) {\n const innerInput = event.currentTarget.querySelector(\"input[type=file]\");\n if (innerInput instanceof HTMLInputElement) {\n innerInput.focus();\n }\n }\n }\n};\nconst onChange = (event: Event) => {\n if (event.target instanceof HTMLInputElement) {\n if (event.target.files) {\n let files;\n files = parseFiles(Array.from(event.target.files));\n if (props.multiple) {\n if (Array.isArray(props.modelValue)) {\n emit(\"update:modelValue\", [...props.modelValue, ...files]);\n }\n } else {\n files = files[0];\n emit(\"update:modelValue\", files);\n }\n }\n event.target.value = \"\";\n event.target.files = null;\n }\n};\n\nconst parseFiles = (files: File[]) => {\n return files.filter((file, index) => {\n // Sizecheck\n if (props.maxSize) {\n let passing = file.size <= props.maxSize;\n if (!passing) {\n emit(\"error\", createError.maxSize(file));\n return false;\n }\n }\n // Uniqueness check\n let alreadyExists = false;\n if (props.modelValue) {\n if (Array.isArray(props.modelValue)) {\n alreadyExists = props.modelValue.some((current) =>\n compareFiles(current, file)\n );\n } else {\n alreadyExists = compareFiles(props.modelValue, file);\n }\n }\n if (alreadyExists) {\n emit(\"error\", createError.uniqueness(file));\n return false;\n }\n // Mime type check\n if (props.accept) {\n const mimePassed = acceptedMimeTypes.value.some((mime) => {\n let found = false;\n if (mime.includes(\"*\"))\n found = found || mime.split(\"/\")[0] === file.type.split(\"/\")[0];\n else found = found || mime === file.type;\n return found;\n });\n if (!mimePassed) {\n emit(\"error\", createError.accept(file));\n return false;\n }\n }\n // Max files check\n if (props.maxFiles) {\n if (Array.isArray(props.modelValue)) {\n if (props.modelValue.length + index + 1 > props.maxFiles) {\n emit(\n \"error\",\n createError.maxFiles(file, props.modelValue.length + index + 1)\n );\n return false;\n }\n }\n }\n return true;\n });\n};\n\nconst onDragOver = (event: Event) => {\n // Find the closest dropzone in case of nested dropzones\n const target = event.target;\n if (target instanceof HTMLElement) {\n const closestDropzone = findInTree([target], \"parentElement\", (el) =>\n el.classList.contains(\"bb-dropzone\")\n );\n if (closestDropzone) {\n /* When dragging over this dropzone set as dragging */\n if (closestDropzone.id === containerId) {\n setDragging();\n /* When dragging over a nested dropzone do not highlight this dropzone */\n } else {\n unsetDragging();\n }\n }\n }\n};\n\nconst setDragging = () => {\n clearTimeout(draggingTimeout);\n dragging.value = true;\n};\n\nconst unsetDragging = () => {\n draggingTimeout = setTimeout(() => {\n dragging.value = false;\n }, 100);\n};\n\nconst bytesToUnit = (bytes: number, decimals = 2) => {\n if (!bytes) return \"0 B\";\n const k = 1024;\n const dm = decimals || 0;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\", \"ZB\", \"YB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + \" \" + sizes[i];\n};\n\n/**\n * Returns true if files are identical by the properties that are accessible\n * @param file The file to check\n * @param otherFile The file to check against\n */\nconst compareFiles = (file: File, otherFile: File) => {\n const properties: (keyof File)[] = [\"name\", \"size\", \"lastModified\", \"type\"];\n return !properties.some((key) => file[key] !== otherFile[key]);\n};\n\n/**\n * Helper that creates errors based on component properties\n */\nconst createError = {\n maxSize: (file: File) => {\n // Todo update to isNil\n if (props.maxSize) {\n return {\n type: \"maxSize\",\n file: file,\n formattedMaxSize: bytesToUnit(+props.maxSize),\n formattedSize: bytesToUnit(file.size),\n filename: file.name,\n } as const;\n } else throw new Error('Requested to create an error for maxSize without providing a maxSize.')\n },\n uniqueness: (file: File) => {\n return {\n type: \"uniqueness\",\n file: file,\n filename: file.name,\n } as const;\n },\n accept: (file: File) => {\n return {\n type: \"accept\",\n file: file,\n acceptedMimeTypes: acceptedMimeTypes.value,\n mimeType: file.type,\n filename: file.name,\n } as const;\n },\n maxFiles: (file: File, totalFiles: number) => {\n return {\n type: \"maxFiles\",\n file: file,\n maxFiles: props.maxFiles,\n totalFiles,\n filename: file.name,\n } as const;\n },\n};\n\nconst computedErrors = computed(() => {\n return props.errors ? ([] as string[]).concat(props.errors) : [];\n});\n\nconst hasErrors = computed(\n () => Boolean(computedErrors.value.length) || props.hasErrors\n);\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createBlock(_resolveDynamicComponent(_ctx.tag), {\n class: _normalizeClass(classes.value),\n id: containerId\n }, {\n default: _withCtx(() => [\n _createElementVNode(\"label\", {\n onDrop: _withModifiers(onDrop, [\"prevent\"]),\n onDragenter: _withModifiers(setDragging, [\"prevent\"]),\n onDragover: _withModifiers(onDragOver, [\"prevent\"]),\n onDragleave: _withModifiers(unsetDragging, [\"prevent\"])\n }, [\n _createElementVNode(\"input\", {\n type: \"file\",\n accept: acceptedMimeTypesString.value,\n autofocus: _ctx.autofocus,\n disabled: _ctx.disabled,\n multiple: _ctx.multiple,\n onChange: onChange,\n onFocus: _cache[0] || (_cache[0] = (event) => _ctx.$emit('focus', event)),\n onBlur: _cache[1] || (_cache[1] = (event) => _ctx.$emit('blur', event))\n }, null, 40, _hoisted_1),\n _renderSlot(_ctx.$slots, \"default\", _normalizeProps(_guardReactiveProps(slotAttributes.value)))\n ], 32),\n _createElementVNode(\"label\", _hoisted_2, [\n _createTextVNode(\" Server files \"),\n _createElementVNode(\"input\", {\n class: \"bb-dropzone__submittable-input\",\n type: \"file\",\n id: _unref(id),\n name: _ctx.name,\n ref_key: \"submittable\",\n ref: submittable,\n multiple: _ctx.multiple,\n disabled: _ctx.disabled\n }, null, 8, _hoisted_3)\n ]),\n _createElementVNode(\"span\", _hoisted_4, [\n _createVNode(BbSmoothHeight, { tag: \"span\" }, {\n default: _withCtx(() => [\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(computedErrors.value, (error) => {\n return (_openBlock(), _createElementBlock(\"span\", {\n class: \"bb-dropzone__error\",\n key: error\n }, _toDisplayString(error), 1))\n }), 128))\n ]),\n _: 1\n })\n ])\n ]),\n _: 3\n }, 8, [\"class\"]))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_sfc_main","_defineComponent","__props","__emit","mime","props","emit","submittable","ref","watch","container","file","acceptedMimeTypes","acceptedMimeTypesString","computed","accumulated","i","element","foundMime","id","useId","containerId","dragging","draggingTimeout","classes","hasErrors","slotAttributes","onDrop","event","files","parseFiles","innerInput","onChange","index","createError","alreadyExists","current","compareFiles","found","onDragOver","target","closestDropzone","findInTree","el","setDragging","unsetDragging","bytesToUnit","bytes","decimals","k","dm","sizes","otherFile","key","totalFiles","computedErrors","_ctx","_cache","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeClass","_withCtx","_createElementVNode","_withModifiers","_renderSlot","_normalizeProps","_guardReactiveProps","_createTextVNode","_unref","_createVNode","BbSmoothHeight","_createElementBlock","_Fragment","_renderList","error","_toDisplayString"],"mappings":";;;;;AAGA,MAAMA,KAAa,CAAC,UAAU,aAAa,YAAY,UAAU,GAC3DC,KAAa;AAAA,EACjB,OAAO;AAAA,EACP,eAAe;AACjB,GACMC,KAAa,CAAC,MAAM,QAAQ,YAAY,UAAU,G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AAE,KAAK,UAAU;AAAA,YAC5C,SAAST,EAAS,MAAM;AAAA,eACrBJ,EAAW,EAAI,GAAGc,EAAoBC,GAAW,MAAMC,EAAYnB,EAAe,OAAO,CAACoB,OACjFjB,EAAA,GAAcc,EAAoB,QAAQ;AAAA,gBAChD,OAAO;AAAA,gBACP,KAAKG;AAAA,cACJ,GAAAC,EAAiBD,CAAK,GAAG,CAAC,EAC9B,GAAG,GAAG;AAAA,YAAA,CACR;AAAA,YACD,GAAG;AAAA,UAAA,CACJ;AAAA,QAAA,CACF;AAAA,MAAA,CACF;AAAA,MACD,GAAG;AAAA,IAAA,GACF,GAAG,CAAC,OAAO,CAAC;AAAA,EAEjB;AAEA,CAAC;"}
|
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 "./
|
|
2
|
+
import { throttle as c } from "./index215.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 "./
|
|
2
|
+
import { useFocusTrap as oe } from "./index216.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/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
2
|
import { useFloating as K, arrow as Q } from "./index222.js";
|
|
3
|
-
import { useFocusTrap as W } from "./
|
|
3
|
+
import { useFocusTrap as W } from "./index216.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 } from "./
|
|
9
|
-
import {
|
|
8
|
+
import { autoUpdate as Z, flip as ee, shift as oe } from "./index208.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",
|
|
@@ -64,8 +64,8 @@ const ae = ["id"], re = { class: "bb-popover__bubble" }, ne = /* @__PURE__ */ s(
|
|
|
64
64
|
whileElementsMounted: Z,
|
|
65
65
|
middleware: [
|
|
66
66
|
ee(),
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
te(o.offset),
|
|
68
|
+
oe({ padding: o.padding }),
|
|
69
69
|
Q({
|
|
70
70
|
element: _,
|
|
71
71
|
padding: o.arrowPadding
|
package/dist/index8.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { reactive as L, watch as f, toValue as Y, computed as
|
|
1
|
+
import { reactive as L, watch as f, toValue as Y, computed as y, provide as D } from "vue";
|
|
2
2
|
import { mapValues as G } from "./index127.js";
|
|
3
3
|
import { useStepper as H } from "./index128.js";
|
|
4
4
|
import { useRoute as Q } from "./index129.js";
|
|
5
5
|
import { useRouter as X } from "./index130.js";
|
|
6
|
-
import { isNotNil as
|
|
6
|
+
import { isNotNil as l } from "./index124.js";
|
|
7
7
|
const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[\s\S]+))/, J = (i) => {
|
|
8
8
|
var r, u;
|
|
9
9
|
const e = i.match(R);
|
|
10
10
|
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
|
-
},
|
|
11
|
+
}, ne = (i) => {
|
|
12
12
|
if (!i.name)
|
|
13
13
|
throw new Error(
|
|
14
14
|
"You need to provide a unique name for the current wizard instance to be used to save data"
|
|
@@ -18,29 +18,29 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
18
18
|
throw new Error(
|
|
19
19
|
"Navigation is enabled but could not retrieve the router instance in useWizard."
|
|
20
20
|
);
|
|
21
|
-
const
|
|
21
|
+
const a = L(
|
|
22
22
|
b && sessionStorage.getItem(i.name) ? Object.assign(
|
|
23
23
|
{},
|
|
24
24
|
i.initialState,
|
|
25
25
|
JSON.parse(sessionStorage.getItem(i.name))
|
|
26
26
|
) : i.initialState
|
|
27
27
|
);
|
|
28
|
-
b && f(
|
|
29
|
-
sessionStorage.setItem(i.name, JSON.stringify(
|
|
28
|
+
b && f(a, () => {
|
|
29
|
+
sessionStorage.setItem(i.name, JSON.stringify(a));
|
|
30
30
|
});
|
|
31
|
-
const W = Y(i.steps), o =
|
|
31
|
+
const W = Y(i.steps), o = y(
|
|
32
32
|
() => Object.entries(W).reduce(
|
|
33
|
-
(t, [s,
|
|
33
|
+
(t, [s, n]) => (n.condition && !n.condition(a) || (t[s] = { ...n, key: s }), t),
|
|
34
34
|
{}
|
|
35
35
|
)
|
|
36
|
-
), m =
|
|
36
|
+
), m = y(
|
|
37
37
|
() => G(o.value, (t) => ({
|
|
38
38
|
...t,
|
|
39
|
-
isValid: t.isValid ? t.isValid(
|
|
39
|
+
isValid: t.isValid ? t.isValid(a) : !0
|
|
40
40
|
}))
|
|
41
41
|
);
|
|
42
|
-
let
|
|
43
|
-
if (u &&
|
|
42
|
+
let p = null;
|
|
43
|
+
if (u && l(e.value)) {
|
|
44
44
|
let t = null;
|
|
45
45
|
if (q === "query")
|
|
46
46
|
e.value.query.step && (t = e.value.query.step);
|
|
@@ -48,15 +48,15 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
48
48
|
const s = J(e.value.fullPath);
|
|
49
49
|
s && (t = s);
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
p = t;
|
|
52
52
|
}
|
|
53
|
-
if (
|
|
53
|
+
if (p)
|
|
54
54
|
for (const t in o.value) {
|
|
55
|
-
if (t ===
|
|
55
|
+
if (t === p)
|
|
56
56
|
break;
|
|
57
57
|
const s = m.value[t];
|
|
58
58
|
if (!s || !s.isValid) {
|
|
59
|
-
|
|
59
|
+
p = null;
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -67,10 +67,10 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
67
67
|
goToPrevious: N,
|
|
68
68
|
goTo: d,
|
|
69
69
|
index: $,
|
|
70
|
-
at:
|
|
71
|
-
get:
|
|
72
|
-
goBackTo:
|
|
73
|
-
isAfter:
|
|
70
|
+
at: O,
|
|
71
|
+
get: x,
|
|
72
|
+
goBackTo: k,
|
|
73
|
+
isAfter: w,
|
|
74
74
|
isBefore: P,
|
|
75
75
|
isCurrent: j,
|
|
76
76
|
isFirst: A,
|
|
@@ -82,18 +82,18 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
82
82
|
stepNames: U
|
|
83
83
|
} = H(
|
|
84
84
|
m,
|
|
85
|
-
|
|
86
|
-
),
|
|
85
|
+
p || Object.values(o.value)[0].key
|
|
86
|
+
), c = y(() => Object.keys(o.value)[$.value]);
|
|
87
87
|
if (D(Z, {
|
|
88
88
|
goToNext: V,
|
|
89
89
|
goToPrevious: N,
|
|
90
90
|
current: T,
|
|
91
|
-
data:
|
|
91
|
+
data: a,
|
|
92
92
|
steps: S,
|
|
93
|
-
at:
|
|
94
|
-
get:
|
|
95
|
-
goBackTo:
|
|
96
|
-
isAfter:
|
|
93
|
+
at: O,
|
|
94
|
+
get: x,
|
|
95
|
+
goBackTo: k,
|
|
96
|
+
isAfter: w,
|
|
97
97
|
isBefore: P,
|
|
98
98
|
isCurrent: j,
|
|
99
99
|
isFirst: A,
|
|
@@ -106,11 +106,11 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
106
106
|
}), u)
|
|
107
107
|
if (q === "query")
|
|
108
108
|
f(
|
|
109
|
-
|
|
109
|
+
c,
|
|
110
110
|
() => {
|
|
111
|
-
|
|
111
|
+
l(r) && l(e.value) && r.push({
|
|
112
112
|
...e,
|
|
113
|
-
query: { ...e.value.query, step:
|
|
113
|
+
query: { ...e.value.query, step: c.value ?? null }
|
|
114
114
|
});
|
|
115
115
|
},
|
|
116
116
|
{ immediate: !0 }
|
|
@@ -123,39 +123,39 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
123
123
|
if (t) {
|
|
124
124
|
const s = t;
|
|
125
125
|
if (s in o.value) {
|
|
126
|
-
const
|
|
126
|
+
const n = s, v = Object.keys(o.value);
|
|
127
127
|
v.slice(
|
|
128
128
|
0,
|
|
129
|
-
v.indexOf(
|
|
129
|
+
v.indexOf(n)
|
|
130
130
|
).every(
|
|
131
131
|
(B) => {
|
|
132
|
-
var
|
|
133
|
-
return (
|
|
132
|
+
var g;
|
|
133
|
+
return (g = m.value[B]) == null ? void 0 : g.isValid;
|
|
134
134
|
}
|
|
135
|
-
) && d(
|
|
135
|
+
) && d(n);
|
|
136
136
|
}
|
|
137
137
|
} else
|
|
138
138
|
d(S.value[0]);
|
|
139
139
|
}
|
|
140
140
|
);
|
|
141
141
|
else {
|
|
142
|
-
const t =
|
|
143
|
-
if (
|
|
142
|
+
const t = y(() => {
|
|
143
|
+
if (l(e.value))
|
|
144
144
|
return J(e.value.fullPath);
|
|
145
145
|
});
|
|
146
146
|
f(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
c,
|
|
148
|
+
(s) => {
|
|
149
|
+
l(e.value) && l(r) && (e.value.path.includes("step") ? r.push({
|
|
150
150
|
query: e.value.query,
|
|
151
151
|
path: e.value.path.replace(
|
|
152
152
|
R,
|
|
153
|
-
`step/${
|
|
153
|
+
`step/${s}`
|
|
154
154
|
)
|
|
155
|
-
}) :
|
|
155
|
+
}) : r.push({
|
|
156
156
|
query: e.value.query,
|
|
157
157
|
// Normalizes paths with / and without
|
|
158
|
-
path: (e.value.path + `/step/${
|
|
158
|
+
path: (e.value.path + `/step/${s}`).replace(
|
|
159
159
|
"//",
|
|
160
160
|
"/"
|
|
161
161
|
),
|
|
@@ -166,17 +166,17 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
166
166
|
), f(
|
|
167
167
|
() => t.value,
|
|
168
168
|
(s) => {
|
|
169
|
-
if (s) {
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const v =
|
|
169
|
+
if (s && s !== c.value) {
|
|
170
|
+
const n = s;
|
|
171
|
+
if (n in o.value) {
|
|
172
|
+
const v = n, h = Object.keys(o.value);
|
|
173
173
|
h.slice(
|
|
174
174
|
0,
|
|
175
175
|
h.indexOf(v)
|
|
176
176
|
).every(
|
|
177
|
-
(
|
|
177
|
+
(g) => {
|
|
178
178
|
var E;
|
|
179
|
-
return (E = o.value[
|
|
179
|
+
return (E = o.value[g]) == null ? void 0 : E.isValid;
|
|
180
180
|
}
|
|
181
181
|
) && d(v);
|
|
182
182
|
}
|
|
@@ -190,12 +190,12 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
190
190
|
goToNext: V,
|
|
191
191
|
goToPrevious: N,
|
|
192
192
|
goTo: d,
|
|
193
|
-
key:
|
|
194
|
-
data:
|
|
195
|
-
at:
|
|
196
|
-
get:
|
|
197
|
-
goBackTo:
|
|
198
|
-
isAfter:
|
|
193
|
+
key: c,
|
|
194
|
+
data: a,
|
|
195
|
+
at: O,
|
|
196
|
+
get: x,
|
|
197
|
+
goBackTo: k,
|
|
198
|
+
isAfter: w,
|
|
199
199
|
isBefore: P,
|
|
200
200
|
isCurrent: j,
|
|
201
201
|
isFirst: A,
|
|
@@ -208,7 +208,7 @@ const Z = Symbol(), R = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>[
|
|
|
208
208
|
};
|
|
209
209
|
};
|
|
210
210
|
export {
|
|
211
|
-
|
|
211
|
+
ne as useWizard,
|
|
212
212
|
Z as wizardInjectionKey
|
|
213
213
|
};
|
|
214
214
|
//# sourceMappingURL=index8.js.map
|
package/dist/index8.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { computed, provide, reactive, watch, toValue } 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\";\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 /**\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 ? Object.assign(\n {},\n params.initialState,\n JSON.parse(sessionStorage.getItem(params.name)!)\n )\n : params.initialState\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 async () => {\n if (isNotNil(route.value) && isNotNil(router)) {\n if (route.value.path.includes(\"step\")) {\n await router.push({\n query: route.value.query,\n path: route.value.path.replace(\n regexMatchStep,\n `step/${key.value}`\n ),\n });\n } else {\n await router.push({\n query: route.value.query,\n // Normalizes paths with / and without\n path: (route.value.path + `/step/${key.value}`).replace(\n \"//\",\n \"/\"\n ),\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) {\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","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":";;;;;;AAQO,MAAMA,IAAqB,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,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"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { computed, provide, reactive, watch, toValue } 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\";\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 /**\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 ? Object.assign(\n {},\n params.initialState,\n JSON.parse(sessionStorage.getItem(params.name)!)\n )\n : params.initialState\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(\n regexMatchStep,\n `step/${value}`\n ),\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 \"//\",\n \"/\"\n ),\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","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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A,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;"}
|
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 "./
|
|
2
|
+
import { clamp as p } from "./index195.js";
|
|
3
3
|
import { getAsPercentageBetween as d } from "./index121.js";
|
|
4
4
|
const v = /* @__PURE__ */ a({
|
|
5
5
|
__name: "BbProgress",
|