bitboss-ui 2.0.7 → 2.0.9
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/index.js +139 -138
- package/dist/index.js.map +1 -1
- package/dist/index10.js +7 -78
- package/dist/index10.js.map +1 -1
- package/dist/{index100.js → index101.js} +3 -3
- package/dist/{index100.js.map → index101.js.map} +1 -1
- package/dist/{index102.js → index103.js} +3 -3
- package/dist/{index102.js.map → index103.js.map} +1 -1
- package/dist/{index104.js → index105.js} +8 -8
- package/dist/{index104.js.map → index105.js.map} +1 -1
- package/dist/{index106.js → index107.js} +9 -9
- package/dist/{index106.js.map → index107.js.map} +1 -1
- package/dist/{index108.js → index109.js} +3 -3
- package/dist/{index108.js.map → index109.js.map} +1 -1
- package/dist/index11.js +74 -35
- package/dist/index11.js.map +1 -1
- package/dist/{index110.js → index111.js} +3 -3
- package/dist/{index110.js.map → index111.js.map} +1 -1
- package/dist/{index112.js → index113.js} +3 -3
- package/dist/{index112.js.map → index113.js.map} +1 -1
- package/dist/{index114.js → index115.js} +3 -3
- package/dist/{index114.js.map → index115.js.map} +1 -1
- package/dist/{index116.js → index117.js} +8 -8
- package/dist/{index116.js.map → index117.js.map} +1 -1
- package/dist/{index118.js → index119.js} +2 -2
- package/dist/{index118.js.map → index119.js.map} +1 -1
- package/dist/index12.js +36 -189
- package/dist/index12.js.map +1 -1
- package/dist/index121.js +34 -38
- package/dist/index121.js.map +1 -1
- package/dist/index122.js +38 -38
- package/dist/index122.js.map +1 -1
- package/dist/index123.js +39 -42
- package/dist/index123.js.map +1 -1
- package/dist/index124.js +43 -31
- package/dist/index124.js.map +1 -1
- package/dist/index125.js +35 -2
- package/dist/index125.js.map +1 -1
- package/dist/index126.js +2 -21
- package/dist/index126.js.map +1 -1
- package/dist/index127.js +21 -2
- package/dist/index127.js.map +1 -1
- package/dist/index128.js +2 -312
- package/dist/index128.js.map +1 -1
- package/dist/index129.js +309 -21
- package/dist/index129.js.map +1 -1
- package/dist/index13.js +189 -78
- package/dist/index13.js.map +1 -1
- package/dist/index130.js +24 -2
- package/dist/index130.js.map +1 -1
- package/dist/index131.js +2 -5
- package/dist/index131.js.map +1 -1
- package/dist/index132.js +5 -9
- package/dist/index132.js.map +1 -1
- package/dist/index133.js +8 -5
- package/dist/index133.js.map +1 -1
- package/dist/index134.js +6 -3
- package/dist/index134.js.map +1 -1
- package/dist/index135.js +1 -1
- package/dist/index136.js +1 -1
- package/dist/index137.js +1 -1
- package/dist/index138.js +1 -1
- package/dist/index139.js +1 -1
- package/dist/index14.js +85 -0
- package/dist/index14.js.map +1 -0
- package/dist/index140.js +1 -1
- package/dist/index141.js +1 -1
- package/dist/index142.js +1 -1
- package/dist/index143.js +1 -1
- package/dist/index144.js +1 -1
- package/dist/index145.js +1 -1
- package/dist/index146.js +1 -1
- package/dist/index147.js +1 -1
- package/dist/index148.js +1 -1
- package/dist/index149.js +1 -1
- package/dist/index150.js +1 -1
- package/dist/index151.js +1 -1
- package/dist/index152.js +1 -1
- package/dist/index153.js +1 -1
- package/dist/index154.js +1 -1
- package/dist/index155.js +1 -1
- package/dist/index156.js +1 -1
- package/dist/index157.js +1 -1
- package/dist/index158.js +1 -1
- package/dist/index159.js +1 -1
- package/dist/{index15.js → index16.js} +4 -4
- package/dist/{index15.js.map → index16.js.map} +1 -1
- package/dist/index160.js +2 -2
- package/dist/{index162.js → index161.js} +1 -1
- package/dist/index161.js.map +1 -0
- package/dist/index163.js +6 -0
- package/dist/index163.js.map +1 -0
- package/dist/index165.js +1 -1
- package/dist/index166.js +1 -1
- package/dist/index167.js +1 -1
- package/dist/index168.js +1 -1
- package/dist/index169.js +1 -1
- package/dist/index170.js +2 -2
- package/dist/index171.js +6 -0
- package/dist/index171.js.map +1 -0
- package/dist/index173.js +2 -3
- package/dist/index173.js.map +1 -1
- package/dist/index174.js +1 -1
- package/dist/index175.js +1 -1
- package/dist/index176.js +1 -1
- package/dist/index177.js +1 -1
- package/dist/index178.js +1 -1
- package/dist/index179.js +1 -1
- package/dist/{index17.js → index18.js} +4 -4
- package/dist/{index17.js.map → index18.js.map} +1 -1
- package/dist/index180.js +1 -1
- package/dist/index181.js +1 -1
- package/dist/index182.js +1 -1
- package/dist/index183.js +1 -1
- package/dist/index184.js +1 -1
- package/dist/{index186.js → index185.js} +1 -1
- package/dist/index185.js.map +1 -0
- package/dist/index187.js +6 -0
- package/dist/index187.js.map +1 -0
- package/dist/index189.js +1 -1
- package/dist/index190.js +1 -1
- package/dist/index191.js +1 -1
- package/dist/index192.js +1 -1
- package/dist/index193.js +1 -1
- package/dist/index194.js +1 -1
- package/dist/index195.js +1 -1
- package/dist/index196.js +1 -1
- package/dist/index197.js +1 -1
- package/dist/index198.js +3 -81
- package/dist/index198.js.map +1 -1
- package/dist/{index19.js → index20.js} +19 -18
- package/dist/{index19.js.map → index20.js.map} +1 -1
- package/dist/index200.js +126 -2
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +5 -4
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +123 -2
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +19 -8
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +14 -124
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +16 -5
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +2 -123
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +2 -19
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +35 -16
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +172 -14
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +6 -2
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +44 -2
- package/dist/index211.js.map +1 -1
- package/dist/index213.js +12 -173
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +5 -6
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +369 -43
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +161 -0
- package/dist/index216.js.map +1 -0
- package/dist/index217.js +84 -13
- package/dist/index217.js.map +1 -1
- package/dist/index219.js +67 -355
- package/dist/index219.js.map +1 -1
- package/dist/{index21.js → index22.js} +21 -21
- package/dist/{index21.js.map → index22.js.map} +1 -1
- package/dist/index220.js +8 -19
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +3 -27
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +2 -3
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +4 -249
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +2 -52
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +3 -44
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +7 -5
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +19 -49
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +27 -3
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +3 -3
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +249 -7
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +50 -156
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +38 -78
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +8 -0
- package/dist/index233.js.map +1 -0
- package/dist/index234.js +49 -2
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +2 -18
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +2 -106
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +21 -0
- package/dist/index237.js.map +1 -0
- package/dist/index238.js +53 -47
- package/dist/index238.js.map +1 -1
- package/dist/{index23.js → index24.js} +8 -8
- package/dist/{index23.js.map → index24.js.map} +1 -1
- package/dist/index240.js +100 -2
- package/dist/index240.js.map +1 -1
- package/dist/index242.js +9 -2
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +2 -3
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +3 -6
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +12 -16
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +8 -8
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +9 -23
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +17 -9
- package/dist/index248.js.map +1 -1
- package/dist/index257.js +1 -1
- package/dist/index258.js +1 -1
- package/dist/{index25.js → index26.js} +6 -6
- package/dist/{index25.js.map → index26.js.map} +1 -1
- package/dist/index263.js +224 -2
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +4 -2
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +9 -2
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +5 -1
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +16 -2
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +9 -2
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +23 -28
- package/dist/index269.js.map +1 -1
- package/dist/index270.js +199 -21
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +439 -0
- package/dist/index271.js.map +1 -0
- package/dist/index272.js +121 -218
- package/dist/index272.js.map +1 -1
- package/dist/index274.js +5 -200
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +2 -436
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +2 -127
- package/dist/index276.js.map +1 -1
- package/dist/index277.js +2 -5
- package/dist/index277.js.map +1 -1
- package/dist/index278.js +2 -2
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +2 -9
- package/dist/index279.js.map +1 -1
- package/dist/{index27.js → index28.js} +3 -3
- package/dist/{index27.js.map → index28.js.map} +1 -1
- package/dist/index280.js +2 -69
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +28 -3
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +22 -12
- package/dist/index282.js.map +1 -1
- package/dist/index284.js +2 -17
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +68 -2
- package/dist/index285.js.map +1 -1
- package/dist/index287.js +3 -211
- package/dist/index287.js.map +1 -1
- package/dist/index288.js +211 -15
- package/dist/index288.js.map +1 -1
- package/dist/index289.js +15 -4
- package/dist/index289.js.map +1 -1
- package/dist/index290.js +11 -4
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +34 -58
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +4 -35
- package/dist/index292.js.map +1 -1
- package/dist/index293.js +4 -7
- package/dist/index293.js.map +1 -1
- package/dist/index294.js +57 -17
- package/dist/index294.js.map +1 -1
- package/dist/index295.js +2 -7
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +7 -2
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +6 -10
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +17 -45
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +50 -0
- package/dist/index299.js.map +1 -0
- package/dist/{index29.js → index30.js} +3 -3
- package/dist/{index29.js.map → index30.js.map} +1 -1
- package/dist/index301.js +416 -42
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +50 -0
- package/dist/index302.js.map +1 -0
- package/dist/{index31.js → index32.js} +4 -4
- package/dist/{index31.js.map → index32.js.map} +1 -1
- package/dist/{index33.js → index34.js} +5 -5
- package/dist/{index33.js.map → index34.js.map} +1 -1
- package/dist/{index35.js → index36.js} +23 -22
- package/dist/{index35.js.map → index36.js.map} +1 -1
- package/dist/{index37.js → index38.js} +7 -7
- package/dist/{index37.js.map → index38.js.map} +1 -1
- package/dist/{index39.js → index40.js} +3 -3
- package/dist/{index39.js.map → index40.js.map} +1 -1
- package/dist/{index41.js → index42.js} +4 -4
- package/dist/{index41.js.map → index42.js.map} +1 -1
- package/dist/{index43.js → index44.js} +12 -11
- package/dist/{index43.js.map → index44.js.map} +1 -1
- package/dist/{index45.js → index46.js} +4 -4
- package/dist/{index45.js.map → index46.js.map} +1 -1
- package/dist/{index47.js → index48.js} +3 -3
- package/dist/{index47.js.map → index48.js.map} +1 -1
- package/dist/index5.js +14 -40
- package/dist/index5.js.map +1 -1
- package/dist/{index49.js → index50.js} +4 -4
- package/dist/{index49.js.map → index50.js.map} +1 -1
- package/dist/{index51.js → index52.js} +3 -3
- package/dist/{index51.js.map → index52.js.map} +1 -1
- package/dist/{index53.js → index54.js} +3 -3
- package/dist/{index53.js.map → index54.js.map} +1 -1
- package/dist/{index55.js → index56.js} +3 -3
- package/dist/{index55.js.map → index56.js.map} +1 -1
- package/dist/{index57.js → index58.js} +2 -2
- package/dist/{index57.js.map → index58.js.map} +1 -1
- package/dist/index6.js +38 -76
- package/dist/index6.js.map +1 -1
- package/dist/{index59.js → index60.js} +14 -13
- package/dist/{index59.js.map → index60.js.map} +1 -1
- package/dist/{index61.js → index62.js} +3 -3
- package/dist/{index61.js.map → index62.js.map} +1 -1
- package/dist/{index63.js → index64.js} +3 -3
- package/dist/{index63.js.map → index64.js.map} +1 -1
- package/dist/{index65.js → index66.js} +5 -5
- package/dist/{index65.js.map → index66.js.map} +1 -1
- package/dist/{index67.js → index68.js} +3 -3
- package/dist/{index67.js.map → index68.js.map} +1 -1
- package/dist/index7.js +78 -62
- package/dist/index7.js.map +1 -1
- package/dist/{index69.js → index70.js} +2 -2
- package/dist/{index69.js.map → index70.js.map} +1 -1
- package/dist/{index71.js → index72.js} +9 -9
- package/dist/{index71.js.map → index72.js.map} +1 -1
- package/dist/{index73.js → index74.js} +3 -3
- package/dist/{index73.js.map → index74.js.map} +1 -1
- package/dist/{index75.js → index76.js} +5 -5
- package/dist/{index75.js.map → index76.js.map} +1 -1
- package/dist/index78.js +37 -120
- package/dist/index78.js.map +1 -1
- package/dist/index79.js +130 -0
- package/dist/index79.js.map +1 -0
- package/dist/index8.js +60 -18
- package/dist/index8.js.map +1 -1
- package/dist/{index80.js → index81.js} +5 -5
- package/dist/{index80.js.map → index81.js.map} +1 -1
- package/dist/{index82.js → index83.js} +25 -24
- package/dist/{index82.js.map → index83.js.map} +1 -1
- package/dist/{index84.js → index85.js} +7 -7
- package/dist/{index84.js.map → index85.js.map} +1 -1
- package/dist/{index86.js → index87.js} +2 -2
- package/dist/{index86.js.map → index87.js.map} +1 -1
- package/dist/{index88.js → index89.js} +3 -3
- package/dist/{index88.js.map → index89.js.map} +1 -1
- package/dist/index9.js +19 -7
- package/dist/index9.js.map +1 -1
- package/dist/{index90.js → index91.js} +3 -3
- package/dist/{index90.js.map → index91.js.map} +1 -1
- package/dist/{index92.js → index93.js} +3 -3
- package/dist/{index92.js.map → index93.js.map} +1 -1
- package/dist/{index94.js → index95.js} +1 -1
- package/dist/index95.js.map +1 -0
- package/dist/{index96.js → index97.js} +3 -3
- package/dist/{index96.js.map → index97.js.map} +1 -1
- package/dist/{index98.js → index99.js} +3 -3
- package/dist/{index98.js.map → index99.js.map} +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index120.js +0 -43
- package/dist/index120.js.map +0 -1
- package/dist/index162.js.map +0 -1
- package/dist/index164.js +0 -6
- package/dist/index164.js.map +0 -1
- package/dist/index172.js +0 -5
- package/dist/index172.js.map +0 -1
- package/dist/index186.js.map +0 -1
- package/dist/index188.js +0 -6
- package/dist/index188.js.map +0 -1
- package/dist/index212.js +0 -38
- package/dist/index212.js.map +0 -1
- package/dist/index218.js +0 -8
- package/dist/index218.js.map +0 -1
- package/dist/index241.js +0 -13
- package/dist/index241.js.map +0 -1
- package/dist/index283.js +0 -12
- package/dist/index283.js.map +0 -1
- package/dist/index300.js +0 -424
- package/dist/index300.js.map +0 -1
- package/dist/index4.js +0 -17
- package/dist/index4.js.map +0 -1
- package/dist/index77.js +0 -47
- package/dist/index77.js.map +0 -1
- package/dist/index94.js.map +0 -1
package/dist/index7.js
CHANGED
|
@@ -1,65 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
1
|
+
import { ref as u, watch as c, reactive as x, computed as f } from "vue";
|
|
2
|
+
import { isNil as l } from "./index126.js";
|
|
3
|
+
let r = [];
|
|
4
|
+
const i = u(null);
|
|
5
|
+
c(
|
|
6
|
+
() => i.value,
|
|
7
|
+
() => {
|
|
8
|
+
typeof i.value == "boolean" && (r.forEach((s) => s()), r = []);
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
const o = {
|
|
12
|
+
actions: !0,
|
|
13
|
+
description: "",
|
|
14
|
+
loading: !1,
|
|
15
|
+
no: !0,
|
|
16
|
+
noText: "",
|
|
17
|
+
open: !1,
|
|
18
|
+
size: "sm",
|
|
19
|
+
text: "",
|
|
20
|
+
theme: "default",
|
|
21
|
+
title: "",
|
|
22
|
+
yes: !0,
|
|
23
|
+
yesText: ""
|
|
24
|
+
}, d = {
|
|
25
|
+
actions: !0,
|
|
26
|
+
description: "",
|
|
27
|
+
no: !0,
|
|
28
|
+
noText: "Annulla",
|
|
29
|
+
text: "",
|
|
30
|
+
theme: "default",
|
|
31
|
+
title: "",
|
|
32
|
+
yes: !0,
|
|
33
|
+
yesText: "OK"
|
|
34
|
+
}, e = x({
|
|
35
|
+
...o
|
|
36
|
+
}), m = f(() => [
|
|
37
|
+
{
|
|
38
|
+
text: e.noText,
|
|
39
|
+
handler: () => {
|
|
40
|
+
i.value = !1;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
text: e.yesText,
|
|
45
|
+
handler: () => {
|
|
46
|
+
i.value = !0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]), y = () => ({
|
|
50
|
+
/**
|
|
51
|
+
* The confirm function. It accepts a set of options defining
|
|
52
|
+
* the behavior of the modal and returns `Promise<boolean>`
|
|
53
|
+
* when the user accepts, declines, or ignores the modal.
|
|
54
|
+
*/
|
|
55
|
+
confirm: (s) => {
|
|
56
|
+
i.value = null;
|
|
57
|
+
const n = { ...d, ...s }, t = { ...o };
|
|
58
|
+
return t.title = n.title, t.text = n.text, n.description && (t.description = n.description), n.noText && (t.noText = n.noText), n.yesText && (t.yesText = n.yesText), n.size && (t.size = n.size), n.theme && (t.theme = n.theme), l(n.yes) || (t.yes = !!n.yes), l(n.no) || (t.no = !!n.no), l(n.actions) || (t.actions = !!n.actions), e.actions = t.actions, e.description = t.description, e.no = t.no, e.noText = t.noText, e.open = !0, e.size = t.size, e.text = t.text, e.theme = t.theme, e.title = t.title, e.yes = t.yes, e.yesText = t.yesText, new Promise((a) => {
|
|
59
|
+
r.push(() => a(i.value));
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Sets the state of the confirm to loading and displays a spinner.
|
|
64
|
+
*/
|
|
65
|
+
setLoading: (s = !0) => {
|
|
66
|
+
e.loading = s;
|
|
67
|
+
},
|
|
68
|
+
/**
|
|
69
|
+
* Closes the confirmation modal. It is a manual operation
|
|
70
|
+
* so you can update the state while the modal is still open.
|
|
71
|
+
*/
|
|
72
|
+
close: () => (e.description = o.description, e.loading = o.loading, e.noText = o.noText, e.open = o.open, e.text = o.text, e.theme = o.theme, e.title = o.title, e.yesText = o.yesText, i.value = !1, Promise.resolve().then(() => {
|
|
73
|
+
i.value = null;
|
|
74
|
+
}))
|
|
75
|
+
});
|
|
62
76
|
export {
|
|
63
|
-
|
|
77
|
+
m as actions,
|
|
78
|
+
e as state,
|
|
79
|
+
y as useConfirm
|
|
64
80
|
};
|
|
65
81
|
//# sourceMappingURL=index7.js.map
|
package/dist/index7.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index7.js","sources":["../src/composables/
|
|
1
|
+
{"version":3,"file":"index7.js","sources":["../src/composables/useConfirm.ts"],"sourcesContent":["import { computed, reactive, ref, watch } from 'vue';\nimport { isNil } from '@/utilities/functions/isNil';\nimport type { Sizes } from '@/components/BaseDialog/BaseDialog.vue';\n\ntype State = {\n\tdescription: string;\n\ttheme: string;\n\tloading: boolean;\n\tnoText: string;\n\topen: boolean;\n\ttext: string;\n\ttitle: string;\n\tyesText: string;\n\tyes: boolean;\n\tno: boolean;\n\tactions: boolean;\n\tsize: keyof Sizes;\n};\n\ntype UserOptions = {\n\t/**\n\t * Boolean that sets whether to display or hide the buttons.\n\t * Confirms without actions can only be dismissed by clicking on the overlay or the close button.\n\t */\n\tactions?: State['actions'];\n\t/**\n\t * Description of the content of the modal for accessibility purposes.\n\t */\n\tdescription?: State['description'];\n\t/**\n\t * Boolean that defines whether to display or hide the \"No\" action.\n\t */\n\tno?: State['no'];\n\t/**\n\t * Text content of the \"No\" action.\n\t */\n\tnoText?: State['noText'];\n\t/**\n\t * Text content of the modal.\n\t */\n\ttext: State['text'];\n\t/**\n\t * The name of the theme it applies a css class to BbConfirm for styling.\n\t */\n\ttheme?: State['theme'];\n\t/**\n\t * Tittle of the modal\n\t */\n\ttitle: State['title'];\n\t/**\n\t * Boolean that defines whether to display or hide the \"Yes\" action.\n\t */\n\tyes?: State['yes'];\n\t/**\n\t * Text content of the \"Yes\" action.\n\t */\n\tyesText?: State['yesText'];\n\t/**\n\t * Size of the confirm modal. Use any sizes valid for `BbModal`.\n\t */\n\tsize?: State['size'];\n};\n\n// Stash all instances of current dialogs\nlet subscribers: ((...args: any[]) => any)[] = [];\n\nconst value = ref<boolean | null>(null);\n\nwatch(\n\t() => value.value,\n\t() => {\n\t\tif (typeof value.value === 'boolean') {\n\t\t\t// Every time a dialog is resolved resolve all dialogs\n\t\t\tsubscribers.forEach((fn) => fn());\n\t\t\tsubscribers = [];\n\t\t}\n\t}\n);\n\nconst defaultState: State = {\n\tactions: true,\n\tdescription: '',\n\tloading: false,\n\tno: true,\n\tnoText: '',\n\topen: false,\n\tsize: 'sm',\n\ttext: '',\n\ttheme: 'default',\n\ttitle: '',\n\tyes: true,\n\tyesText: '',\n};\nconst defaultOption: UserOptions = {\n\tactions: true,\n\tdescription: '',\n\tno: true,\n\tnoText: 'Annulla',\n\ttext: '',\n\ttheme: 'default',\n\ttitle: '',\n\tyes: true,\n\tyesText: 'OK',\n};\n\nexport const state = reactive<State>({\n\t...defaultState,\n});\n\nexport const actions = computed(() => [\n\t{\n\t\ttext: state.noText,\n\t\thandler: () => {\n\t\t\tvalue.value = false;\n\t\t},\n\t},\n\t{\n\t\ttext: state.yesText,\n\t\thandler: () => {\n\t\t\tvalue.value = true;\n\t\t},\n\t},\n]);\n\nexport const useConfirm = () => {\n\treturn {\n\t\t/**\n\t\t * The confirm function. It accepts a set of options defining\n\t\t * the behavior of the modal and returns `Promise<boolean>`\n\t\t * when the user accepts, declines, or ignores the modal.\n\t\t */\n\t\tconfirm: (options: UserOptions) => {\n\t\t\tvalue.value = null;\n\t\t\tconst newOptions = { ...defaultOption, ...options };\n\t\t\tconst newState = { ...defaultState };\n\t\t\tnewState.title = newOptions.title;\n\t\t\tnewState.text = newOptions.text;\n\t\t\tif (newOptions.description) newState.description = newOptions.description;\n\t\t\tif (newOptions.noText) newState.noText = newOptions.noText;\n\t\t\tif (newOptions.yesText) newState.yesText = newOptions.yesText;\n\t\t\tif (newOptions.size) newState.size = newOptions.size;\n\t\t\tif (newOptions.theme) newState.theme = newOptions.theme;\n\t\t\tif (!isNil(newOptions.yes)) newState.yes = !!newOptions.yes;\n\t\t\tif (!isNil(newOptions.no)) newState.no = !!newOptions.no;\n\t\t\tif (!isNil(newOptions.actions)) newState.actions = !!newOptions.actions;\n\n\t\t\tstate.actions = newState.actions;\n\t\t\tstate.description = newState.description;\n\t\t\tstate.no = newState.no;\n\t\t\tstate.noText = newState.noText;\n\t\t\tstate.open = true;\n\t\t\tstate.size = newState.size;\n\t\t\tstate.text = newState.text;\n\t\t\tstate.theme = newState.theme;\n\t\t\tstate.title = newState.title;\n\t\t\tstate.yes = newState.yes;\n\t\t\tstate.yesText = newState.yesText;\n\n\t\t\treturn new Promise<boolean>((resolve) => {\n\t\t\t\tsubscribers.push(() => resolve(value.value as boolean));\n\t\t\t});\n\t\t},\n\t\t/**\n\t\t * Sets the state of the confirm to loading and displays a spinner.\n\t\t */\n\t\tsetLoading: (value: boolean = true) => {\n\t\t\tstate.loading = value;\n\t\t},\n\t\t/**\n\t\t * Closes the confirmation modal. It is a manual operation\n\t\t * so you can update the state while the modal is still open.\n\t\t */\n\t\tclose: () => {\n\t\t\tstate.description = defaultState.description;\n\t\t\tstate.loading = defaultState.loading;\n\t\t\tstate.noText = defaultState.noText;\n\t\t\tstate.open = defaultState.open;\n\t\t\tstate.text = defaultState.text;\n\t\t\tstate.theme = defaultState.theme;\n\t\t\tstate.title = defaultState.title;\n\t\t\tstate.yesText = defaultState.yesText;\n\t\t\tvalue.value = false;\n\t\t\treturn Promise.resolve().then(() => {\n\t\t\t\tvalue.value = null;\n\t\t\t});\n\t\t},\n\t};\n};\n"],"names":["subscribers","value","ref","watch","fn","defaultState","defaultOption","state","reactive","actions","computed","useConfirm","options","newOptions","newState","isNil","resolve"],"mappings":";;AAgEA,IAAIA,IAA2C,CAAA;AAE/C,MAAMC,IAAQC,EAAoB,IAAI;AAEtCC;AAAA,EACC,MAAMF,EAAM;AAAA,EACZ,MAAM;AACD,IAAA,OAAOA,EAAM,SAAU,cAE1BD,EAAY,QAAQ,CAACI,MAAOA,EAAI,CAAA,GAChCJ,IAAc,CAAA;AAAA,EAEhB;AACD;AAEA,MAAMK,IAAsB;AAAA,EA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AAA,KAAK,CAAC,CAACD,EAAW,KACjDE,EAAMF,EAAW,OAAO,MAAYC,EAAA,UAAU,CAAC,CAACD,EAAW,UAEhEN,EAAM,UAAUO,EAAS,SACzBP,EAAM,cAAcO,EAAS,aAC7BP,EAAM,KAAKO,EAAS,IACpBP,EAAM,SAASO,EAAS,QACxBP,EAAM,OAAO,IACbA,EAAM,OAAOO,EAAS,MACtBP,EAAM,OAAOO,EAAS,MACtBP,EAAM,QAAQO,EAAS,OACvBP,EAAM,QAAQO,EAAS,OACvBP,EAAM,MAAMO,EAAS,KACrBP,EAAM,UAAUO,EAAS,SAElB,IAAI,QAAiB,CAACE,MAAY;AACxC,MAAAhB,EAAY,KAAK,MAAMgB,EAAQf,EAAM,KAAgB,CAAC;AAAA,IAAA,CACtD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,YAAY,CAACA,IAAiB,OAAS;AACtC,IAAAM,EAAM,UAAUN;AAAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,OACNM,EAAM,cAAcF,EAAa,aACjCE,EAAM,UAAUF,EAAa,SAC7BE,EAAM,SAASF,EAAa,QAC5BE,EAAM,OAAOF,EAAa,MAC1BE,EAAM,OAAOF,EAAa,MAC1BE,EAAM,QAAQF,EAAa,OAC3BE,EAAM,QAAQF,EAAa,OAC3BE,EAAM,UAAUF,EAAa,SAC7BJ,EAAM,QAAQ,IACP,QAAQ,UAAU,KAAK,MAAM;AACnC,IAAAA,EAAM,QAAQ;AAAA,EAAA,CACd;AACF;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as d, computed as u, openBlock as m, createBlock as f, mergeProps as y, withCtx as l, renderSlot as t, normalizeProps as a, guardReactiveProps as r } from "vue";
|
|
2
|
-
import $ from "./
|
|
2
|
+
import $ from "./index24.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
const b = /* @__PURE__ */ d({
|
|
5
5
|
__name: "BbDialog",
|
|
@@ -58,4 +58,4 @@ const b = /* @__PURE__ */ d({
|
|
|
58
58
|
export {
|
|
59
59
|
b as default
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=
|
|
61
|
+
//# sourceMappingURL=index70.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index70.js","sources":["../src/components/BbDialog/BbDialog.vue"],"sourcesContent":["<template>\n\t<!-- Events need to be propagated manually -->\n\t<BaseDialog\n\t\tv-bind=\"$props\"\n\t\t:overlay-classes=\"overlayClasses\"\n\t\t@hidden=\"() => $emit('hidden')\"\n\t\t@shown=\"() => $emit('shown')\"\n\t\t@update:model-value=\"(value: boolean) => $emit('update:modelValue', value)\"\n\t\t><template #close=\"data\"><slot name=\"close\" v-bind=\"data\" /></template\n\t\t><template #default=\"data\"><slot name=\"default\" v-bind=\"data\" /></template\n\t\t><template #description=\"data\"\n\t\t\t><slot name=\"description\" v-bind=\"data\" /></template\n\t\t><template #footer=\"data\"><slot name=\"footer\" v-bind=\"data\" /></template\n\t\t><template #header=\"data\"><slot name=\"header\" v-bind=\"data\" /></template\n\t\t><template #title=\"data\"><slot name=\"title\" v-bind=\"data\" /></template>\n\t</BaseDialog>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport BaseDialog from '../BaseDialog/BaseDialog.vue';\nimport type { Classes } from '@/types/Classes';\nimport type {\n\tBaseDialogProps,\n\tBaseDialogEvents,\n\tBaseDialogSlots,\n} from '../BaseDialog/BaseDialog.vue';\nexport type {\n\tBaseDialogProps as BbDialogProps,\n\tBaseDialogEvents as BbDialogEvents,\n\tSizes,\n} from '../BaseDialog/BaseDialog.vue';\n\nconst props = withDefaults(defineProps<BaseDialogProps>(), {\n\tshowClose: true,\n});\n\ndefineEmits<BaseDialogEvents>();\n\ndefineSlots<BaseDialogSlots>();\n\nconst overlayClasses = computed<Classes>(() => {\n\tlet base: Classes = ['bb-dialog'];\n\tif (props.overlayClasses) {\n\t\tbase = base.concat(props.overlayClasses);\n\t}\n\treturn base;\n});\n</script>\n<style lang=\"postcss\">\n@import '@/assets/css/BbDialog';\n</style>\n"],"names":["props","__props","overlayClasses","computed","base"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,UAAMA,IAAQC,GAQRC,IAAiBC,EAAkB,MAAM;AAC1C,UAAAC,IAAgB,CAAC,WAAW;AAChC,aAAIJ,EAAM,mBACFI,IAAAA,EAAK,OAAOJ,EAAM,cAAc,IAEjCI;AAAA,IAAA,CACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { defineComponent as Y, computed as M, ref as v, openBlock as D, createElementBlock as H, mergeProps as I, createElementVNode as $, renderSlot as _, normalizeProps as Z, guardReactiveProps as ee, unref as c, createBlock as te, Teleport as oe, normalizeClass as ne, normalizeStyle as z, Fragment as N, renderList as ae, createVNode as le, withCtx as se, createCommentVNode as ie } from "vue";
|
|
2
|
-
import { findRightIndex as S } from "./
|
|
3
|
-
import { useFloating as re, arrow as ue } from "./
|
|
4
|
-
import { useId as de } from "./
|
|
5
|
-
import { wait as U } from "./
|
|
6
|
-
import { useIntersectionObserver as ce } from "./
|
|
7
|
-
import fe from "./
|
|
2
|
+
import { findRightIndex as S } from "./index268.js";
|
|
3
|
+
import { useFloating as re, arrow as ue } from "./index200.js";
|
|
4
|
+
import { useId as de } from "./index9.js";
|
|
5
|
+
import { wait as U } from "./index128.js";
|
|
6
|
+
import { useIntersectionObserver as ce } from "./index129.js";
|
|
7
|
+
import fe from "./index14.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import V from "./
|
|
10
|
-
import { autoUpdate as pe, flip as be, offset as me, shift as ve } from "./
|
|
9
|
+
import V from "./index269.js";
|
|
10
|
+
import { autoUpdate as pe, flip as be, offset as me, shift as ve } from "./index215.js";
|
|
11
11
|
const we = ["id", "aria-labelledby"], ye = { class: "bb-dropdown__items-container" }, He = /* @__PURE__ */ Y({
|
|
12
12
|
__name: "BbDropdown",
|
|
13
13
|
props: {
|
|
@@ -311,4 +311,4 @@ const we = ["id", "aria-labelledby"], ye = { class: "bb-dropdown__items-containe
|
|
|
311
311
|
export {
|
|
312
312
|
He as default
|
|
313
313
|
};
|
|
314
|
-
//# sourceMappingURL=
|
|
314
|
+
//# sourceMappingURL=index72.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index71.js","sources":["../src/components/BbDropdown/BbDropdown.vue"],"sourcesContent":["<template>\n\t<span class=\"bb-dropdown\" v-bind=\"attributes\">\n\t\t<span ref=\"wrapper\" class=\"bb-dropdown__wrapper\">\n\t\t\t<slot\n\t\t\t\tname=\"activator\"\n\t\t\t\tv-bind=\"{\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t'aria-expanded': open,\n\t\t\t\t\t\t'aria-controls': `menu_${id}`,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tonClick,\n\t\t\t\t\t\tonKeydown,\n\t\t\t\t\t\tdisabled,\n\t\t\t\t\t},\n\t\t\t\t\tclosed: closed,\n\t\t\t\t\tclosing: closing,\n\t\t\t\t\tdisabled: disabled,\n\t\t\t\t\topen: open,\n\t\t\t\t\topening: opening,\n\t\t\t\t\tplacement: placement,\n\t\t\t\t}\"\n\t\t\t></slot>\n\t\t</span>\n\t\t<teleport v-if=\"hasOpenedOnce || eager\" to=\"body\">\n\t\t\t<span\n\t\t\t\t:id=\"`menu_${id}`\"\n\t\t\t\tref=\"content\"\n\t\t\t\t:aria-labelledby=\"id\"\n\t\t\t\taria-role=\"menu\"\n\t\t\t\tclass=\"bb-dropdown__bubble-container\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t[`bb-dropdown__bubble-container--${placement}`]: true,\n\t\t\t\t\t[`bb-dropdown__bubble-container--${theme}`]: theme,\n\t\t\t\t\t'bb-dropdown__bubble-container--hidden': closed,\n\t\t\t\t\t'bb-dropdown__bubble-container--closing': closing,\n\t\t\t\t\t'bb-dropdown__bubble-container--opening': opening,\n\t\t\t\t\t'bb-dropdown__bubble-container--open': open,\n\t\t\t\t}\"\n\t\t\t\t:style=\"{\n\t\t\t\t\t...floatingStyles,\n\t\t\t\t\ttransitionDuration: `${props.transitionDuration}ms`,\n\t\t\t\t}\"\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tref=\"bubblearrow\"\n\t\t\t\t\tclass=\"bb-dropdown__arrow\"\n\t\t\t\t\tv-bind=\"arrowAttributes\"\n\t\t\t\t></span>\n\t\t\t\t<span class=\"bb-dropdown__bubble\" :style=\"{ width: `${width}px` }\">\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t\tname=\"prepend\"\n\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t></slot>\n\t\t\t\t\t<span class=\"bb-dropdown__items-container\">\n\t\t\t\t\t\t<template v-for=\"(item, index) in mappedItems\" :key=\"item.key\">\n\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t:item=\"items[index]\"\n\t\t\t\t\t\t\t\t:name=\"`item:prepend`\"\n\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t\t<BaseButton\n\t\t\t\t\t\t\t\t:aria-role=\"'menuitem'\"\n\t\t\t\t\t\t\t\tclass=\"bb-dropdown__item\"\n\t\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t\t'bb-dropdown__item--first': index === 0,\n\t\t\t\t\t\t\t\t\t'bb-dropdown__item--last': index === items.length - 1,\n\t\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t\t:data-dropdown-item=\"true\"\n\t\t\t\t\t\t\t\tv-bind=\"item\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t\t:item=\"item\"\n\t\t\t\t\t\t\t\t\t:name=\"item.key\"\n\t\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t\t\t:item=\"item\"\n\t\t\t\t\t\t\t\t\t\tname=\"item\"\n\t\t\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t\t\t</slot>\n\t\t\t\t\t\t\t</BaseButton>\n\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t:item=\"items[index]\"\n\t\t\t\t\t\t\t\t:name=\"`item:append`\"\n\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t</template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t\tname=\"append\"\n\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t></slot>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</teleport>\n\t</span>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { findRightIndex } from '@/utilities/functions/findRightIndex';\nimport {\n\tuseFloating,\n\tautoUpdate,\n\tflip,\n\tshift,\n\tarrow,\n\toffset,\n} from '@floating-ui/vue';\nimport { useId } from '@/composables/useId';\nimport { wait } from '@/utilities/functions/wait';\nimport { useIntersectionObserver } from '@vueuse/core';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport selectors from 'focusable-selectors';\nimport type { BaseButtonProps } from '../BaseButton/BaseButton.vue';\nimport type { CommonProps } from '@/types/CommonProps';\n\nexport type BbDropdownProps = Pick<\n\tCommonProps,\n\t| 'arrowPadding'\n\t| 'block'\n\t| 'disabled'\n\t| 'eager'\n\t| 'id'\n\t| 'offset'\n\t| 'padding'\n\t| 'placement'\n\t| 'theme'\n\t| 'transitionDuration'\n> & {\n\t/**\n\t * Array used to render each dropdown button.\n\t * They can act as `button`, as `a`, or as `router-link`\n\t * as they are based on the functionality provided by\n\t * `BaseButton`\n\t */\n\titems: Item[];\n\t/**\n\t * Width of the dropdown in pixels.\n\t */\n\twidth?: number;\n};\n\ndefineSlots<\n\t{\n\t\tactivator?: (props: {\n\t\t\tprops: {\n\t\t\t\t'aria-expanded': boolean;\n\t\t\t\t'aria-controls': string;\n\t\t\t\tid: string;\n\t\t\t\tonClick: MappedItem['onClick'];\n\t\t\t\tonKeydown: MappedItem['onKeydown'];\n\t\t\t\tdisabled?: BbDropdownProps['disabled'];\n\t\t\t};\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t\tprepend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t\t'item:prepend'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\titem?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\t'item:append'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\tappend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t} & {\n\t\t[key: string]: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t}\n>();\n\nexport type Item = Omit<BaseButtonProps, 'block' | 'tag' | 'type'> & {\n\t/**\n\t * Click handler of the item.\n\t */\n\tonClick?: (...args: any[]) => any;\n\t/**\n\t * Key used to identify the element.\n\t */\n\tkey: string;\n};\n\nexport type MappedItem = Item & {\n\t/**\n\t * Identifier of the element among it's siblings.\n\t */\n\tid: string;\n\t/**\n\t * Keydown event used to handle accessibility.\n\t */\n\tonKeydown: (event: KeyboardEvent) => void;\n};\n\nconst props = withDefaults(defineProps<BbDropdownProps>(), {\n\tarrowPadding: 10,\n\tplacement: 'bottom',\n\ttheme: 'default',\n\ttransitionDuration: 150,\n\twidth: 200,\n\tpadding: 6,\n\toffset: 3,\n});\n\nconst id = props.id ?? `bb_${useId().id.value}`;\n\nconst mappedItems = computed<MappedItem[]>(() => {\n\tlet firstFocusableIndex: number = props.items.findIndex((el) => !el.disabled);\n\tlet lastFocusableIndex: number = findRightIndex(\n\t\tprops.items,\n\t\t(item) => !item.disabled\n\t);\n\n\treturn props.items.map((item, index) => {\n\t\tconst itemid = `${id}-item-${item.key}`;\n\t\tconst { onClick: handler, ...rest } = item;\n\n\t\t/* Id a click handler has been passed close the dropdown\n\t\t * return focus and run the handler\n\t\t */\n\t\tconst onClick = async () => {\n\t\t\tawait closeDropdown();\n\t\t\tconst nextElement = document.querySelector(`#${id}`);\n\t\t\tif (!nextElement) return;\n\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\tnextElement.focus();\n\t\t\t}\n\t\t\tif (handler) handler();\n\t\t};\n\n\t\t/**\n\t\t * On keydown\n\t\t * arrow down move to the next focusable element if it's not the last\n\t\t * arrow up move to the previous focusable element if it's not the first\n\t\t * on tab search the next focusable element after the button that opens the dropdown\n\t\t * if an element is found focus on that\n\t\t * (the menu is attached to body so it's not in order)\n\t\t */\n\t\tconst onKeydown = (event: KeyboardEvent) => {\n\t\t\tif (\n\t\t\t\tevent.target instanceof HTMLElement &&\n\t\t\t\tevent.target.dataset['dropdownItem']\n\t\t\t) {\n\t\t\t\tif (!content.value) return;\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif (content.value && index !== lastFocusableIndex) {\n\t\t\t\t\t\tconst option = content.value.querySelector(\n\t\t\t\t\t\t\tselectors.map((selector) => `#${itemid} ~ ${selector}`).join(',')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\t\t\toption.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (event.key === 'ArrowUp') {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif (content.value && index !== firstFocusableIndex) {\n\t\t\t\t\t\tconst indexOfPrevious = findRightIndex(props.items, (item, i) => {\n\t\t\t\t\t\t\treturn i < index && !item.disabled;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst options = Array.from(\n\t\t\t\t\t\t\tcontent.value.querySelectorAll(`.bb-dropdown__item`)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst option = options[indexOfPrevious];\n\n\t\t\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\t\t\toption.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (event.key === 'Tab') {\n\t\t\t\t\tif (index === lastFocusableIndex && !event.shiftKey) {\n\t\t\t\t\t\tconst selector = selectors.join(',');\n\t\t\t\t\t\tconst focusableElements = Array.from(\n\t\t\t\t\t\t\tdocument.querySelectorAll(selector)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst indexOfButton = focusableElements.findIndex(\n\t\t\t\t\t\t\t(el) => el.id === id\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst nextElement = focusableElements[indexOfButton + 1];\n\t\t\t\t\t\tif (!nextElement) return;\n\t\t\t\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tcloseDropdown();\n\t\t\t\t\t\t\tnextElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (index === firstFocusableIndex && event.shiftKey) {\n\t\t\t\t\t\tconst nextElement = document.querySelector(`#${id}`);\n\t\t\t\t\t\tif (!nextElement) return;\n\t\t\t\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tnextElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\t...rest,\n\t\t\tdisabled: rest.disabled || props.disabled,\n\t\t\tid: itemid,\n\t\t\tonClick,\n\t\t\tonKeydown,\n\t\t};\n\t});\n});\n\nconst wrapper = ref<HTMLElement>();\nconst content = ref<HTMLElement>();\nconst bubblearrow = ref<HTMLElement>();\n\nconst { floatingStyles, placement, middlewareData } = useFloating(\n\twrapper,\n\tcontent,\n\t{\n\t\tplacement: props.placement,\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tflip(),\n\t\t\toffset(props.offset),\n\t\t\tshift({ padding: props.padding }),\n\t\t\tarrow({\n\t\t\t\telement: bubblearrow,\n\t\t\t\tpadding: props.arrowPadding,\n\t\t\t}),\n\t\t],\n\t}\n);\n\nuseIntersectionObserver(\n\twrapper,\n\t([{ intersectionRatio }]) => {\n\t\tif (intersectionRatio !== 1 && open.value) closeDropdown();\n\t},\n\t{ threshold: [0, 1] }\n);\n\nconst opening = ref(false);\nconst open = ref(false);\nconst closing = ref(false);\nconst closed = ref(true);\n\nconst arrowAttributes = computed(() => {\n\tif (middlewareData.value.arrow) {\n\t\tconst { x, y } = middlewareData.value.arrow;\n\t\treturn {\n\t\t\tstyle: {\n\t\t\t\tleft: `${x}px`,\n\t\t\t\ttop: `${y}px`,\n\t\t\t},\n\t\t};\n\t}\n\treturn undefined;\n});\n\n/* On click of the trigger attach elements */\nconst onClick = () => {\n\tif (opening.value || closing.value) return;\n\tif (open.value) {\n\t\tcloseDropdown();\n\t} else {\n\t\topenDropdown();\n\t}\n};\n\nconst onKeydown = async (event: KeyboardEvent) => {\n\tlet firstFocusableIndex: number = props.items.findIndex((el) => !el.disabled);\n\tlet lastFocusableIndex: number = findRightIndex(\n\t\tprops.items,\n\t\t(item) => !item.disabled\n\t);\n\tif (event.key === 'ArrowDown') {\n\t\tevent.preventDefault();\n\t\tif (closing.value || opening.value) return;\n\t\tif (closed.value) {\n\t\t\tawait openDropdown();\n\t\t}\n\t\tif (\n\t\t\tcontent.value &&\n\t\t\tmappedItems.value.length &&\n\t\t\tfirstFocusableIndex !== -1\n\t\t) {\n\t\t\tconst idToFocus = mappedItems.value[firstFocusableIndex].id;\n\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\toption.focus();\n\t\t\t}\n\t\t}\n\t} else if (event.key === 'ArrowUp') {\n\t\tevent.preventDefault();\n\t\tif (closing.value || opening.value) return;\n\t\tif (closed.value) {\n\t\t\tawait openDropdown();\n\t\t}\n\t\tif (\n\t\t\tcontent.value &&\n\t\t\tmappedItems.value.length &&\n\t\t\tlastFocusableIndex !== -1\n\t\t) {\n\t\t\tconst idToFocus = mappedItems.value[lastFocusableIndex].id;\n\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\toption.focus();\n\t\t\t}\n\t\t}\n\t} else if (event.key === 'Tab') {\n\t\tif (open.value && !event.shiftKey) {\n\t\t\tevent.preventDefault();\n\t\t\tif (\n\t\t\t\tcontent.value &&\n\t\t\t\tmappedItems.value.length &&\n\t\t\t\tfirstFocusableIndex !== -1\n\t\t\t) {\n\t\t\t\tconst idToFocus = mappedItems.value[firstFocusableIndex].id;\n\t\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\toption.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst onClickDocument = (event: Event) => {\n\tconst target = event.target;\n\tif (!target) return;\n\tif (target instanceof HTMLElement) {\n\t\tlet isOutside = true;\n\n\t\tif (wrapper.value) {\n\t\t\tif (wrapper.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\t\tif (content.value) {\n\t\t\tif (content.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\n\t\tif (isOutside) {\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\n\nconst onDocumentFocus = (event: FocusEvent) => {\n\tconst target = event.target;\n\tif (!target) return;\n\tif (target instanceof HTMLElement) {\n\t\tlet isOutside = true;\n\n\t\tif (wrapper.value) {\n\t\t\tif (wrapper.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\t\tif (content.value) {\n\t\t\tif (content.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\n\t\tif (isOutside) {\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\n\nconst onEsc = (event: KeyboardEvent) => {\n\tif (open.value) {\n\t\tif (event.key === 'Escape') {\n\t\t\tif (document.activeElement?.id !== id) {\n\t\t\t\tconst button = document.querySelector(`#${id}`);\n\t\t\t\tif (button instanceof HTMLElement) {\n\t\t\t\t\tbutton.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\nconst hasOpenedOnce = ref(false);\nconst openDropdown = async () => {\n\thasOpenedOnce.value = true;\n\tclosed.value = false;\n\tclosing.value = false;\n\topening.value = true;\n\tawait wait(50);\n\topen.value = true;\n\topening.value = false;\n\t/* Attach listeners to document so we don't have to track them one by one */\n\tdocument.addEventListener('click', onClickDocument, { passive: true });\n\tdocument.addEventListener('focusin', onDocumentFocus, { passive: true });\n\tdocument.addEventListener('keydown', onEsc, { passive: true });\n};\n\nconst closeDropdown = async () => {\n\topen.value = false;\n\topening.value = false;\n\tclosing.value = true;\n\tawait wait(props.transitionDuration);\n\tclosing.value = false;\n\tclosed.value = true;\n\tdocument.removeEventListener('click', onClickDocument);\n\tdocument.removeEventListener('focusin', onDocumentFocus);\n\tdocument.removeEventListener('keydown', onEsc);\n};\n\nconst attributes = computed(() => {\n\tconst classes = {\n\t\t'bb-dropdown--block': props.block,\n\t\t[`bb-dropdown--theme-${props.theme}`]: props.theme,\n\t};\n\treturn {\n\t\tclass: classes,\n\t};\n});\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbDropdown';\n</style>\n"],"names":["props","__props","id","useId","mappedItems","computed","firstFocusableIndex","el","lastFocusableIndex","findRightIndex","item","index","itemid","handler","rest","onClick","closeDropdown","nextElement","onKeydown","event","content","option","selectors","selector","indexOfPrevious","i","focusableElements","indexOfButton","wrapper","ref","bubblearrow","floatingStyles","placement","middlewareData","useFloating","autoUpdate","flip","offset","shift","arrow","useIntersectionObserver","intersectionRatio","open","opening","closing","closed","arrowAttributes","x","y","openDropdown","idToFocus","onClickDocument","target","isOutside","onDocumentFocus","onEsc","_a","button","hasOpenedOnce","wait","attributes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8RA,UAAMA,IAAQC,GAURC,IAAKF,EAAM,MAAM,MAAMG,KA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;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index72.js","sources":["../src/components/BbDropdown/BbDropdown.vue"],"sourcesContent":["<template>\n\t<span class=\"bb-dropdown\" v-bind=\"attributes\">\n\t\t<span ref=\"wrapper\" class=\"bb-dropdown__wrapper\">\n\t\t\t<slot\n\t\t\t\tname=\"activator\"\n\t\t\t\tv-bind=\"{\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t'aria-expanded': open,\n\t\t\t\t\t\t'aria-controls': `menu_${id}`,\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tonClick,\n\t\t\t\t\t\tonKeydown,\n\t\t\t\t\t\tdisabled,\n\t\t\t\t\t},\n\t\t\t\t\tclosed: closed,\n\t\t\t\t\tclosing: closing,\n\t\t\t\t\tdisabled: disabled,\n\t\t\t\t\topen: open,\n\t\t\t\t\topening: opening,\n\t\t\t\t\tplacement: placement,\n\t\t\t\t}\"\n\t\t\t></slot>\n\t\t</span>\n\t\t<teleport v-if=\"hasOpenedOnce || eager\" to=\"body\">\n\t\t\t<span\n\t\t\t\t:id=\"`menu_${id}`\"\n\t\t\t\tref=\"content\"\n\t\t\t\t:aria-labelledby=\"id\"\n\t\t\t\taria-role=\"menu\"\n\t\t\t\tclass=\"bb-dropdown__bubble-container\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t[`bb-dropdown__bubble-container--${placement}`]: true,\n\t\t\t\t\t[`bb-dropdown__bubble-container--${theme}`]: theme,\n\t\t\t\t\t'bb-dropdown__bubble-container--hidden': closed,\n\t\t\t\t\t'bb-dropdown__bubble-container--closing': closing,\n\t\t\t\t\t'bb-dropdown__bubble-container--opening': opening,\n\t\t\t\t\t'bb-dropdown__bubble-container--open': open,\n\t\t\t\t}\"\n\t\t\t\t:style=\"{\n\t\t\t\t\t...floatingStyles,\n\t\t\t\t\ttransitionDuration: `${props.transitionDuration}ms`,\n\t\t\t\t}\"\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tref=\"bubblearrow\"\n\t\t\t\t\tclass=\"bb-dropdown__arrow\"\n\t\t\t\t\tv-bind=\"arrowAttributes\"\n\t\t\t\t></span>\n\t\t\t\t<span class=\"bb-dropdown__bubble\" :style=\"{ width: `${width}px` }\">\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t\tname=\"prepend\"\n\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t></slot>\n\t\t\t\t\t<span class=\"bb-dropdown__items-container\">\n\t\t\t\t\t\t<template v-for=\"(item, index) in mappedItems\" :key=\"item.key\">\n\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t:item=\"items[index]\"\n\t\t\t\t\t\t\t\t:name=\"`item:prepend`\"\n\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t\t<BaseButton\n\t\t\t\t\t\t\t\t:aria-role=\"'menuitem'\"\n\t\t\t\t\t\t\t\tclass=\"bb-dropdown__item\"\n\t\t\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t\t\t'bb-dropdown__item--first': index === 0,\n\t\t\t\t\t\t\t\t\t'bb-dropdown__item--last': index === items.length - 1,\n\t\t\t\t\t\t\t\t}\"\n\t\t\t\t\t\t\t\t:data-dropdown-item=\"true\"\n\t\t\t\t\t\t\t\tv-bind=\"item\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t\t:item=\"item\"\n\t\t\t\t\t\t\t\t\t:name=\"item.key\"\n\t\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t\t\t:item=\"item\"\n\t\t\t\t\t\t\t\t\t\tname=\"item\"\n\t\t\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t\t\t</slot>\n\t\t\t\t\t\t\t</BaseButton>\n\t\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t\t:disabled=\"item.disabled\"\n\t\t\t\t\t\t\t\t:index=\"index\"\n\t\t\t\t\t\t\t\t:item=\"items[index]\"\n\t\t\t\t\t\t\t\t:name=\"`item:append`\"\n\t\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t\t\t:text=\"item.text\"\n\t\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t</template>\n\t\t\t\t\t</span>\n\t\t\t\t\t<slot\n\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t\tname=\"append\"\n\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t></slot>\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</teleport>\n\t</span>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { findRightIndex } from '@/utilities/functions/findRightIndex';\nimport {\n\tuseFloating,\n\tautoUpdate,\n\tflip,\n\tshift,\n\tarrow,\n\toffset,\n} from '@floating-ui/vue';\nimport { useId } from '@/composables/useId';\nimport { wait } from '@/utilities/functions/wait';\nimport { useIntersectionObserver } from '@vueuse/core';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport selectors from 'focusable-selectors';\nimport type { BaseButtonProps } from '../BaseButton/BaseButton.vue';\nimport type { CommonProps } from '@/types/CommonProps';\n\nexport type BbDropdownProps = Pick<\n\tCommonProps,\n\t| 'arrowPadding'\n\t| 'block'\n\t| 'disabled'\n\t| 'eager'\n\t| 'id'\n\t| 'offset'\n\t| 'padding'\n\t| 'placement'\n\t| 'theme'\n\t| 'transitionDuration'\n> & {\n\t/**\n\t * Array used to render each dropdown button.\n\t * They can act as `button`, as `a`, or as `router-link`\n\t * as they are based on the functionality provided by\n\t * `BaseButton`\n\t */\n\titems: Item[];\n\t/**\n\t * Width of the dropdown in pixels.\n\t */\n\twidth?: number;\n};\n\ndefineSlots<\n\t{\n\t\tactivator?: (props: {\n\t\t\tprops: {\n\t\t\t\t'aria-expanded': boolean;\n\t\t\t\t'aria-controls': string;\n\t\t\t\tid: string;\n\t\t\t\tonClick: MappedItem['onClick'];\n\t\t\t\tonKeydown: MappedItem['onKeydown'];\n\t\t\t\tdisabled?: BbDropdownProps['disabled'];\n\t\t\t};\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t\tprepend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t\t'item:prepend'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\titem?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\t'item:append'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\tappend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t}) => any;\n\t} & {\n\t\t[key: string]: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t}\n>();\n\nexport type Item = Omit<BaseButtonProps, 'block' | 'tag' | 'type'> & {\n\t/**\n\t * Click handler of the item.\n\t */\n\tonClick?: (...args: any[]) => any;\n\t/**\n\t * Key used to identify the element.\n\t */\n\tkey: string;\n};\n\nexport type MappedItem = Item & {\n\t/**\n\t * Identifier of the element among it's siblings.\n\t */\n\tid: string;\n\t/**\n\t * Keydown event used to handle accessibility.\n\t */\n\tonKeydown: (event: KeyboardEvent) => void;\n};\n\nconst props = withDefaults(defineProps<BbDropdownProps>(), {\n\tarrowPadding: 10,\n\tplacement: 'bottom',\n\ttheme: 'default',\n\ttransitionDuration: 150,\n\twidth: 200,\n\tpadding: 6,\n\toffset: 3,\n});\n\nconst id = props.id ?? `bb_${useId().id.value}`;\n\nconst mappedItems = computed<MappedItem[]>(() => {\n\tlet firstFocusableIndex: number = props.items.findIndex((el) => !el.disabled);\n\tlet lastFocusableIndex: number = findRightIndex(\n\t\tprops.items,\n\t\t(item) => !item.disabled\n\t);\n\n\treturn props.items.map((item, index) => {\n\t\tconst itemid = `${id}-item-${item.key}`;\n\t\tconst { onClick: handler, ...rest } = item;\n\n\t\t/* Id a click handler has been passed close the dropdown\n\t\t * return focus and run the handler\n\t\t */\n\t\tconst onClick = async () => {\n\t\t\tawait closeDropdown();\n\t\t\tconst nextElement = document.querySelector(`#${id}`);\n\t\t\tif (!nextElement) return;\n\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\tnextElement.focus();\n\t\t\t}\n\t\t\tif (handler) handler();\n\t\t};\n\n\t\t/**\n\t\t * On keydown\n\t\t * arrow down move to the next focusable element if it's not the last\n\t\t * arrow up move to the previous focusable element if it's not the first\n\t\t * on tab search the next focusable element after the button that opens the dropdown\n\t\t * if an element is found focus on that\n\t\t * (the menu is attached to body so it's not in order)\n\t\t */\n\t\tconst onKeydown = (event: KeyboardEvent) => {\n\t\t\tif (\n\t\t\t\tevent.target instanceof HTMLElement &&\n\t\t\t\tevent.target.dataset['dropdownItem']\n\t\t\t) {\n\t\t\t\tif (!content.value) return;\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif (content.value && index !== lastFocusableIndex) {\n\t\t\t\t\t\tconst option = content.value.querySelector(\n\t\t\t\t\t\t\tselectors.map((selector) => `#${itemid} ~ ${selector}`).join(',')\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\t\t\toption.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (event.key === 'ArrowUp') {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif (content.value && index !== firstFocusableIndex) {\n\t\t\t\t\t\tconst indexOfPrevious = findRightIndex(props.items, (item, i) => {\n\t\t\t\t\t\t\treturn i < index && !item.disabled;\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst options = Array.from(\n\t\t\t\t\t\t\tcontent.value.querySelectorAll(`.bb-dropdown__item`)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst option = options[indexOfPrevious];\n\n\t\t\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\t\t\toption.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (event.key === 'Tab') {\n\t\t\t\t\tif (index === lastFocusableIndex && !event.shiftKey) {\n\t\t\t\t\t\tconst selector = selectors.join(',');\n\t\t\t\t\t\tconst focusableElements = Array.from(\n\t\t\t\t\t\t\tdocument.querySelectorAll(selector)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst indexOfButton = focusableElements.findIndex(\n\t\t\t\t\t\t\t(el) => el.id === id\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst nextElement = focusableElements[indexOfButton + 1];\n\t\t\t\t\t\tif (!nextElement) return;\n\t\t\t\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tcloseDropdown();\n\t\t\t\t\t\t\tnextElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (index === firstFocusableIndex && event.shiftKey) {\n\t\t\t\t\t\tconst nextElement = document.querySelector(`#${id}`);\n\t\t\t\t\t\tif (!nextElement) return;\n\t\t\t\t\t\telse if (nextElement instanceof HTMLElement) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tnextElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\treturn {\n\t\t\t...rest,\n\t\t\tdisabled: rest.disabled || props.disabled,\n\t\t\tid: itemid,\n\t\t\tonClick,\n\t\t\tonKeydown,\n\t\t};\n\t});\n});\n\nconst wrapper = ref<HTMLElement>();\nconst content = ref<HTMLElement>();\nconst bubblearrow = ref<HTMLElement>();\n\nconst { floatingStyles, placement, middlewareData } = useFloating(\n\twrapper,\n\tcontent,\n\t{\n\t\tplacement: props.placement,\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tflip(),\n\t\t\toffset(props.offset),\n\t\t\tshift({ padding: props.padding }),\n\t\t\tarrow({\n\t\t\t\telement: bubblearrow,\n\t\t\t\tpadding: props.arrowPadding,\n\t\t\t}),\n\t\t],\n\t}\n);\n\nuseIntersectionObserver(\n\twrapper,\n\t([{ intersectionRatio }]) => {\n\t\tif (intersectionRatio !== 1 && open.value) closeDropdown();\n\t},\n\t{ threshold: [0, 1] }\n);\n\nconst opening = ref(false);\nconst open = ref(false);\nconst closing = ref(false);\nconst closed = ref(true);\n\nconst arrowAttributes = computed(() => {\n\tif (middlewareData.value.arrow) {\n\t\tconst { x, y } = middlewareData.value.arrow;\n\t\treturn {\n\t\t\tstyle: {\n\t\t\t\tleft: `${x}px`,\n\t\t\t\ttop: `${y}px`,\n\t\t\t},\n\t\t};\n\t}\n\treturn undefined;\n});\n\n/* On click of the trigger attach elements */\nconst onClick = () => {\n\tif (opening.value || closing.value) return;\n\tif (open.value) {\n\t\tcloseDropdown();\n\t} else {\n\t\topenDropdown();\n\t}\n};\n\nconst onKeydown = async (event: KeyboardEvent) => {\n\tlet firstFocusableIndex: number = props.items.findIndex((el) => !el.disabled);\n\tlet lastFocusableIndex: number = findRightIndex(\n\t\tprops.items,\n\t\t(item) => !item.disabled\n\t);\n\tif (event.key === 'ArrowDown') {\n\t\tevent.preventDefault();\n\t\tif (closing.value || opening.value) return;\n\t\tif (closed.value) {\n\t\t\tawait openDropdown();\n\t\t}\n\t\tif (\n\t\t\tcontent.value &&\n\t\t\tmappedItems.value.length &&\n\t\t\tfirstFocusableIndex !== -1\n\t\t) {\n\t\t\tconst idToFocus = mappedItems.value[firstFocusableIndex].id;\n\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\toption.focus();\n\t\t\t}\n\t\t}\n\t} else if (event.key === 'ArrowUp') {\n\t\tevent.preventDefault();\n\t\tif (closing.value || opening.value) return;\n\t\tif (closed.value) {\n\t\t\tawait openDropdown();\n\t\t}\n\t\tif (\n\t\t\tcontent.value &&\n\t\t\tmappedItems.value.length &&\n\t\t\tlastFocusableIndex !== -1\n\t\t) {\n\t\t\tconst idToFocus = mappedItems.value[lastFocusableIndex].id;\n\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\toption.focus();\n\t\t\t}\n\t\t}\n\t} else if (event.key === 'Tab') {\n\t\tif (open.value && !event.shiftKey) {\n\t\t\tevent.preventDefault();\n\t\t\tif (\n\t\t\t\tcontent.value &&\n\t\t\t\tmappedItems.value.length &&\n\t\t\t\tfirstFocusableIndex !== -1\n\t\t\t) {\n\t\t\t\tconst idToFocus = mappedItems.value[firstFocusableIndex].id;\n\t\t\t\tconst option = content.value.querySelector(`#${idToFocus}`);\n\t\t\t\tif (option && option instanceof HTMLElement) {\n\t\t\t\t\toption.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst onClickDocument = (event: Event) => {\n\tconst target = event.target;\n\tif (!target) return;\n\tif (target instanceof HTMLElement) {\n\t\tlet isOutside = true;\n\n\t\tif (wrapper.value) {\n\t\t\tif (wrapper.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\t\tif (content.value) {\n\t\t\tif (content.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\n\t\tif (isOutside) {\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\n\nconst onDocumentFocus = (event: FocusEvent) => {\n\tconst target = event.target;\n\tif (!target) return;\n\tif (target instanceof HTMLElement) {\n\t\tlet isOutside = true;\n\n\t\tif (wrapper.value) {\n\t\t\tif (wrapper.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\t\tif (content.value) {\n\t\t\tif (content.value.contains(target)) {\n\t\t\t\tisOutside = false;\n\t\t\t}\n\t\t}\n\n\t\tif (isOutside) {\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\n\nconst onEsc = (event: KeyboardEvent) => {\n\tif (open.value) {\n\t\tif (event.key === 'Escape') {\n\t\t\tif (document.activeElement?.id !== id) {\n\t\t\t\tconst button = document.querySelector(`#${id}`);\n\t\t\t\tif (button instanceof HTMLElement) {\n\t\t\t\t\tbutton.focus();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcloseDropdown();\n\t\t}\n\t}\n};\nconst hasOpenedOnce = ref(false);\nconst openDropdown = async () => {\n\thasOpenedOnce.value = true;\n\tclosed.value = false;\n\tclosing.value = false;\n\topening.value = true;\n\tawait wait(50);\n\topen.value = true;\n\topening.value = false;\n\t/* Attach listeners to document so we don't have to track them one by one */\n\tdocument.addEventListener('click', onClickDocument, { passive: true });\n\tdocument.addEventListener('focusin', onDocumentFocus, { passive: true });\n\tdocument.addEventListener('keydown', onEsc, { passive: true });\n};\n\nconst closeDropdown = async () => {\n\topen.value = false;\n\topening.value = false;\n\tclosing.value = true;\n\tawait wait(props.transitionDuration);\n\tclosing.value = false;\n\tclosed.value = true;\n\tdocument.removeEventListener('click', onClickDocument);\n\tdocument.removeEventListener('focusin', onDocumentFocus);\n\tdocument.removeEventListener('keydown', onEsc);\n};\n\nconst attributes = computed(() => {\n\tconst classes = {\n\t\t'bb-dropdown--block': props.block,\n\t\t[`bb-dropdown--theme-${props.theme}`]: props.theme,\n\t};\n\treturn {\n\t\tclass: classes,\n\t};\n});\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbDropdown';\n</style>\n"],"names":["props","__props","id","useId","mappedItems","computed","firstFocusableIndex","el","lastFocusableIndex","findRightIndex","item","index","itemid","handler","rest","onClick","closeDropdown","nextElement","onKeydown","event","content","option","selectors","selector","indexOfPrevious","i","focusableElements","indexOfButton","wrapper","ref","bubblearrow","floatingStyles","placement","middlewareData","useFloating","autoUpdate","flip","offset","shift","arrow","useIntersectionObserver","intersectionRatio","open","opening","closing","closed","arrowAttributes","x","y","openDropdown","idToFocus","onClickDocument","target","isOutside","onDocumentFocus","onEsc","_a","button","hasOpenedOnce","wait","attributes"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8RA,UAAMA,IAAQC,GAURC,IAAKF,EAAM,MAAM,MAAMG,KAAQ,GAAG,KAAK,IAEvCC,IAAcC,EAAuB,MAAM;AAC5C,UAAAC,IAA8BN,EAAM,MAAM,UAAU,CAACO,MAAO,CAACA,EAAG,QAAQ,GACxEC,IAA6BC;AAAA,QAChCT,EAAM;AAAA,QACN,CAACU,MAAS,CAACA,EAAK;AAAA,MAAA;AAGjB,aAAOV,E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EAAO,MAAM;AAAA,QAEf;AACc,QAAAzC;MACf;AAAA,IACD,GAEK0C,IAAgB7B,EAAI,EAAK,GACzBoB,IAAe,YAAY;AAChC,MAAAS,EAAc,QAAQ,IACtBb,EAAO,QAAQ,IACfD,EAAQ,QAAQ,IAChBD,EAAQ,QAAQ,IAChB,MAAMgB,EAAK,EAAE,GACbjB,EAAK,QAAQ,IACbC,EAAQ,QAAQ,IAEhB,SAAS,iBAAiB,SAASQ,GAAiB,EAAE,SAAS,IAAM,GACrE,SAAS,iBAAiB,WAAWG,GAAiB,EAAE,SAAS,IAAM,GACvE,SAAS,iBAAiB,WAAWC,GAAO,EAAE,SAAS,IAAM;AAAA,IAAA,GAGxDvC,IAAgB,YAAY;AACjC,MAAA0B,EAAK,QAAQ,IACbC,EAAQ,QAAQ,IAChBC,EAAQ,QAAQ,IACV,MAAAe,EAAK3D,EAAM,kBAAkB,GACnC4C,EAAQ,QAAQ,IAChBC,EAAO,QAAQ,IACN,SAAA,oBAAoB,SAASM,CAAe,GAC5C,SAAA,oBAAoB,WAAWG,CAAe,GAC9C,SAAA,oBAAoB,WAAWC,CAAK;AAAA,IAAA,GAGxCK,IAAavD,EAAS,OAKpB;AAAA,MACN,OALe;AAAA,QACf,sBAAsBL,EAAM;AAAA,QAC5B,CAAC,sBAAsBA,EAAM,KAAK,EAAE,GAAGA,EAAM;AAAA,MAAA;AAAA,IAGtC,EAER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as c, computed as v, openBlock as B, createElementBlock as k, normalizeClass as y, createVNode as l, mergeProps as h, withCtx as o, renderSlot as d, createSlots as C, createElementVNode as m, toDisplayString as P, normalizeProps as n, guardReactiveProps as a, renderList as D } from "vue";
|
|
2
|
-
import g from "./
|
|
2
|
+
import g from "./index14.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import L from "./
|
|
4
|
+
import L from "./index72.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
const S = { class: "bb-dropdown-button__dropdown-label" }, _ = /* @__PURE__ */ m("svg", {
|
|
7
7
|
class: "bb-dropdown-button__dropdown-chevron",
|
|
@@ -127,4 +127,4 @@ const S = { class: "bb-dropdown-button__dropdown-label" }, _ = /* @__PURE__ */ m
|
|
|
127
127
|
export {
|
|
128
128
|
R as default
|
|
129
129
|
};
|
|
130
|
-
//# sourceMappingURL=
|
|
130
|
+
//# sourceMappingURL=index74.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index74.js","sources":["../src/components/BbDropdownButton/BbDropdownButton.vue"],"sourcesContent":["<template>\n\t<span\n\t\tclass=\"bb-dropdown-button\"\n\t\t:class=\"{\n\t\t\t'bb-dropdown-button--block': block,\n\t\t\t[`bb-dropdown-button--theme-${props.theme}`]: props.theme,\n\t\t}\"\n\t>\n\t\t<BaseButton v-bind=\"mainBtn\" class=\"bb-dropdown-button__main-btn\">\n\t\t\t<slot\n\t\t\t\t:disabled=\"mainBtn.disabled\"\n\t\t\t\tname=\"left-btn\"\n\t\t\t\t:text=\"mainBtn.text\"\n\t\t\t></slot>\n\t\t</BaseButton>\n\t\t<BbDropdown\n\t\t\t:id=\"id\"\n\t\t\t:arrow-padding=\"arrowPadding\"\n\t\t\t:disabled=\"disabled\"\n\t\t\t:eager=\"eager\"\n\t\t\t:items=\"items\"\n\t\t\t:offset=\"offset\"\n\t\t\t:padding=\"padding\"\n\t\t\t:placement=\"placement\"\n\t\t\t:theme=\"theme\"\n\t\t\t:transition-duration=\"transitionDuration\"\n\t\t\t:width=\"width\"\n\t\t>\n\t\t\t<template\n\t\t\t\t#activator=\"{\n\t\t\t\t\tprops,\n\t\t\t\t\topening,\n\t\t\t\t\topen,\n\t\t\t\t\tclosed,\n\t\t\t\t\tclosing,\n\t\t\t\t\tdisabled,\n\t\t\t\t\tplacement,\n\t\t\t\t}\"\n\t\t\t>\n\t\t\t\t<slot\n\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\tname=\"activator\"\n\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t:props=\"props\"\n\t\t\t\t>\n\t\t\t\t\t<BaseButton v-bind=\"props\" class=\"bb-dropdown-button__dropdown-btn\">\n\t\t\t\t\t\t<span class=\"bb-dropdown-button__dropdown-label\"\n\t\t\t\t\t\t\t>{{ open || opening ? 'Chiudi' : 'Apri' }} il menu</span\n\t\t\t\t\t\t>\n\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t:closed=\"closed\"\n\t\t\t\t\t\t\t:closing=\"closing\"\n\t\t\t\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t\t\t\tname=\"right-btn\"\n\t\t\t\t\t\t\t:open=\"open\"\n\t\t\t\t\t\t\t:opening=\"opening\"\n\t\t\t\t\t\t\t:placement=\"placement\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\t\tclass=\"bb-dropdown-button__dropdown-chevron\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\t\td=\"M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6l1.41 1.41Z\"\n\t\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t\t/></svg></slot></BaseButton></slot\n\t\t\t></template>\n\t\t\t<template #prepend=\"data\"><slot name=\"prepend\" v-bind=\"data\" /></template>\n\t\t\t<template #item:prepend=\"data\">\n\t\t\t\t<slot name=\"item:prepend\" v-bind=\"data\" />\n\t\t\t</template>\n\t\t\t<template #item=\"data\"><slot name=\"item\" v-bind=\"data\" /></template>\n\t\t\t<template v-for=\"item in items\" #[item.key]=\"data\">\n\t\t\t\t<slot :name=\"item.key\" v-bind=\"data\" />\n\t\t\t</template>\n\t\t\t<template #item:append=\"data\">\n\t\t\t\t<slot name=\"item:append\" v-bind=\"data\" />\n\t\t\t</template>\n\t\t\t<template #append=\"data\"><slot name=\"append\" v-bind=\"data\" /></template>\n\t\t</BbDropdown>\n\t</span>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport BbDropdown from '../BbDropdown/BbDropdown.vue';\nimport type { BbDropdownProps, MappedItem } from '../BbDropdown/BbDropdown.vue';\n\nexport type BbDropdownButtonProps = Pick<\n\tBbDropdownProps,\n\t| 'arrowPadding'\n\t| 'block'\n\t| 'disabled'\n\t| 'eager'\n\t| 'id'\n\t| 'items'\n\t| 'offset'\n\t| 'padding'\n\t| 'placement'\n\t| 'theme'\n\t| 'transitionDuration'\n\t| 'width'\n>;\n\nconst props = withDefaults(defineProps<BbDropdownButtonProps>(), {\n\ttheme: 'default',\n});\n\ndefineSlots<\n\t{\n\t\t'left-btn'?: (props: {\n\t\t\tdisabled?: boolean;\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\tactivator?: (props: {\n\t\t\tprops: {\n\t\t\t\t'aria-expanded': boolean;\n\t\t\t\t'aria-controls': string;\n\t\t\t\tid: string;\n\t\t\t\tonClick: MappedItem['onClick'];\n\t\t\t\tonKeydown: MappedItem['onKeydown'];\n\t\t\t\tdisabled?: BbDropdownButtonProps['disabled'];\n\t\t\t};\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t}) => any;\n\t\tprepend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t}) => any;\n\t\t'item:prepend'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownButtonProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\titem?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownButtonProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\t'item:append'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownButtonProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t\tappend?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t}) => any;\n\t\t'right-btn'?: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: boolean;\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t}) => any;\n\t} & {\n\t\t[key: string]: (props: {\n\t\t\tclosed: boolean;\n\t\t\tclosing: boolean;\n\t\t\tdisabled?: MappedItem['disabled'];\n\t\t\tindex: number;\n\t\t\titem: BbDropdownButtonProps['items'][number];\n\t\t\topen: boolean;\n\t\t\topening: boolean;\n\t\t\tplacement: BbDropdownButtonProps['placement'];\n\t\t\ttext: MappedItem['text'];\n\t\t}) => any;\n\t}\n>();\n\nconst mainBtn = computed(() => {\n\tconst base = { ...props.items[0] };\n\tbase.disabled = base.disabled || props.disabled;\n\treturn base;\n});\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbDropdownButton';\n</style>\n"],"names":["props","__props","mainBtn","computed","base"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GA,UAAMA,IAAQC,GAkGRC,IAAUC,EAAS,MAAM;AAC9B,YAAMC,IAAO,EAAE,GAAGJ,EAAM,MAAM,CAAC,EAAE;AAC5B,aAAAI,EAAA,WAAWA,EAAK,YAAYJ,EAAM,UAChCI;AAAA,IAAA,CACP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as j, ref as g, watch as x, computed as m, openBlock as V, createBlock as G, resolveDynamicComponent as K, normalizeClass as O, withCtx as M, createElementVNode as c, withModifiers as y, renderSlot as U, normalizeProps as Y, guardReactiveProps as Z, createTextVNode as J, unref as Q, createVNode as W, createElementBlock as F, Fragment as X, renderList as ee, toDisplayString as te } from "vue";
|
|
2
|
-
import { findInTree as ae } from "./
|
|
3
|
-
import { useId as re } from "./
|
|
4
|
-
import oe from "./
|
|
2
|
+
import { findInTree as ae } from "./index267.js";
|
|
3
|
+
import { useId as re } from "./index9.js";
|
|
4
|
+
import oe from "./index124.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
const le = ["accept", "autofocus", "disabled", "multiple"], se = {
|
|
7
7
|
"aria-hidden": "true",
|
|
@@ -56,7 +56,7 @@ const le = ["accept", "autofocus", "disabled", "multiple"], se = {
|
|
|
56
56
|
const r = t.accept[a];
|
|
57
57
|
if (r.includes("/")) e.push(r);
|
|
58
58
|
else {
|
|
59
|
-
b || (b = (await import("./
|
|
59
|
+
b || (b = (await import("./index266.js")).default);
|
|
60
60
|
const o = b.getType(r);
|
|
61
61
|
if (!o)
|
|
62
62
|
throw new Error(
|
|
@@ -221,4 +221,4 @@ const le = ["accept", "autofocus", "disabled", "multiple"], se = {
|
|
|
221
221
|
export {
|
|
222
222
|
fe as default
|
|
223
223
|
};
|
|
224
|
-
//# sourceMappingURL=
|
|
224
|
+
//# sourceMappingURL=index76.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index75.js","sources":["../src/components/BbDropzone/BbDropzone.vue"],"sourcesContent":["<template>\n\t<component :is=\"tag\" :id=\"containerId\" :class=\"classes\">\n\t\t<label\n\t\t\t@dragenter.prevent=\"setDragging\"\n\t\t\t@dragleave.prevent=\"unsetDragging\"\n\t\t\t@dragover.prevent=\"onDragOver\"\n\t\t\t@drop.prevent=\"onDrop\"\n\t\t>\n\t\t\t<input\n\t\t\t\t:accept=\"acceptedMimeTypesString\"\n\t\t\t\t:autofocus=\"autofocus\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:multiple=\"multiple\"\n\t\t\t\ttype=\"file\"\n\t\t\t\t@blur=\"onBlur\"\n\t\t\t\t@change=\"onChange\"\n\t\t\t\t@focus=\"onFocus\"\n\t\t\t/>\n\t\t\t<slot v-bind=\"slotAttributes\"></slot>\n\t\t</label>\n\t\t<label aria-hidden=\"true\" class=\"bb-dropzone__submittable-label\">\n\t\t\tServer files\n\t\t\t<input\n\t\t\t\t:id=\"id\"\n\t\t\t\tref=\"submittable\"\n\t\t\t\tclass=\"bb-dropzone__submittable-input\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:multiple=\"multiple\"\n\t\t\t\t:name=\"name\"\n\t\t\t\ttype=\"file\"\n\t\t\t/>\n\t\t</label>\n\n\t\t<span class=\"bb-dropzone__errors\">\n\t\t\t<BbSmoothHeight tag=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tv-for=\"error in computedErrors\"\n\t\t\t\t\t:key=\"error\"\n\t\t\t\t\tclass=\"bb-dropzone__error\"\n\t\t\t\t\t>{{ error }}</span\n\t\t\t\t>\n\t\t\t</BbSmoothHeight>\n\t\t</span>\n\t</component>\n</template>\n\n<script setup lang=\"ts\">\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\t(typeof createError)[keyof typeof createError]\n>;\n\nexport type BbDropzoneProps = Pick<\n\tCommonProps,\n\t'autofocus' | 'disabled' | 'errors' | 'hasErrors' | 'id' | 'multiple' | 'name'\n> & {\n\t/**\n\t * Array of mime-types or extensions to filter selectable files.\n\t */\n\taccept?: string[];\n\t/**\n\t * Maximum number of acceptable files\n\t */\n\tmaxFiles?: number;\n\t/**\n\t * Max size of the files in bytes.\n\t */\n\tmaxSize?: number;\n\t/**\n\t * Used by v-model.\n\t */\n\tmodelValue: any;\n} & NonVoidElementTag;\n\n// This is the dynamic import for mime\nlet mime: any;\n\nconst props = withDefaults(defineProps<BbDropzoneProps>(), {\n\ttag: 'div',\n});\n\nexport type BbDropzoneEvents = {\n\t(e: 'blur', event: FocusEvent): void;\n\t(e: 'error', data: DropZoneError): void;\n\t(e: 'focus', event: FocusEvent): void;\n\t(e: 'update:modelValue', data: any): void;\n};\nconst emit = defineEmits<BbDropzoneEvents>();\n\ndefineSlots<{\n\tdefault?: (props: { dragging: boolean; focused: boolean; id: string }) => any;\n}>();\n\nconst submittable = ref<any | null>(null);\n\nif (props.accept) {\n\tif (!Array.isArray(props.accept)) {\n\t\tthrow new Error('Property accept is not an array');\n\t}\n}\nif (props.multiple) {\n\tif (!Array.isArray(props.modelValue)) {\n\t\tthrow new Error(\n\t\t\t'Component is set to multiple but modelValue is not an array'\n\t\t);\n\t}\n}\n\nconst hasFocus = ref(false);\nconst onFocus = (event: FocusEvent) => {\n\thasFocus.value = true;\n\temit('focus', event);\n};\nconst onBlur = (event: FocusEvent) => {\n\thasFocus.value = false;\n\temit('blur', event);\n};\n\n/** Allow dropzone to be submittable (this is flimsy and might break) */\nwatch(\n\t() => props.modelValue,\n\t() => {\n\t\tlet container = new DataTransfer();\n\t\tif (Array.isArray(props.modelValue)) {\n\t\t\tif (props.modelValue.length) {\n\t\t\t\tprops.modelValue.forEach((file) => container.items.add(file));\n\t\t\t}\n\t\t} else {\n\t\t\tif (props.modelValue) container.items.add(props.modelValue);\n\t\t}\n\t\tif (submittable.value) {\n\t\t\tif (container.items.length) {\n\t\t\t\tsubmittable.value.files = container.files;\n\t\t\t} else {\n\t\t\t\tsubmittable.value.files = null;\n\t\t\t}\n\t\t}\n\t}\n);\n\nconst acceptedMimeTypes = ref<string[]>([]);\nconst acceptedMimeTypesString = computed(() =>\n\tacceptedMimeTypes.value.join(',')\n);\nwatch(\n\t() => props.accept,\n\tasync () => {\n\t\tif (props.accept) {\n\t\t\tlet accumulated = [];\n\t\t\tfor (let i = 0; i < props.accept.length; i++) {\n\t\t\t\tconst element = props.accept[i];\n\t\t\t\tif (element.includes('/')) accumulated.push(element);\n\t\t\t\telse {\n\t\t\t\t\tif (!mime) {\n\t\t\t\t\t\tconst mod = await import('mime');\n\t\t\t\t\t\tmime = mod.default;\n\t\t\t\t\t}\n\t\t\t\t\tconst foundMime = mime.getType(element);\n\t\t\t\t\tif (!foundMime) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Could not detect the correct mime associated with ${element}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\taccumulated.push(foundMime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tacceptedMimeTypes.value = accumulated;\n\t\t}\n\t},\n\t{ 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\treturn {\n\t\t'bb-dropzone': true,\n\t\t'bb-dropzone--errors': hasErrors.value,\n\t\t'bb-dropzone--dragging': dragging.value,\n\t};\n});\nconst slotAttributes = computed(() => {\n\treturn {\n\t\tdragging: dragging.value,\n\t\tfocused: hasFocus.value,\n\t\tid: id,\n\t};\n});\n\n/**\n * Component handlers\n */\nconst onDrop = (event: DragEvent) => {\n\tdragging.value = false;\n\n\tif (event.dataTransfer) {\n\t\tevent.stopImmediatePropagation();\n\t\tlet files;\n\t\tfiles = Array.from(event.dataTransfer.files);\n\t\tfiles = parseFiles(files);\n\t\tif (props.multiple) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\temit('update:modelValue', [...props.modelValue, ...files]);\n\t\t\t}\n\t\t} else {\n\t\t\tfiles = files[0];\n\t\t\temit('update:modelValue', files);\n\t\t}\n\t\tif (event.currentTarget instanceof HTMLLabelElement) {\n\t\t\tconst innerInput = event.currentTarget.querySelector('input[type=file]');\n\t\t\tif (innerInput instanceof HTMLInputElement) {\n\t\t\t\tinnerInput.focus();\n\t\t\t}\n\t\t}\n\t}\n};\nconst onChange = (event: Event) => {\n\tif (event.target instanceof HTMLInputElement) {\n\t\tif (event.target.files) {\n\t\t\tlet files;\n\t\t\tfiles = parseFiles(Array.from(event.target.files));\n\t\t\tif (props.multiple) {\n\t\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\t\temit('update:modelValue', [...props.modelValue, ...files]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles = files[0];\n\t\t\t\temit('update:modelValue', files);\n\t\t\t}\n\t\t}\n\t\tevent.target.value = '';\n\t\tevent.target.files = null;\n\t}\n};\n\nconst parseFiles = (files: File[]) => {\n\treturn files.filter((file, index) => {\n\t\t// Sizecheck\n\t\tif (props.maxSize) {\n\t\t\tlet passing = file.size <= props.maxSize;\n\t\t\tif (!passing) {\n\t\t\t\temit('error', createError.maxSize(file));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// Uniqueness check\n\t\tlet alreadyExists = false;\n\t\tif (props.modelValue) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\talreadyExists = props.modelValue.some((current) =>\n\t\t\t\t\tcompareFiles(current, file)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\talreadyExists = compareFiles(props.modelValue, file);\n\t\t\t}\n\t\t}\n\t\tif (alreadyExists) {\n\t\t\temit('error', createError.uniqueness(file));\n\t\t\treturn false;\n\t\t}\n\t\t// Mime type check\n\t\tif (props.accept) {\n\t\t\tconst mimePassed = acceptedMimeTypes.value.some((mime) => {\n\t\t\t\tlet found = false;\n\t\t\t\tif (mime.includes('*'))\n\t\t\t\t\tfound = found || mime.split('/')[0] === file.type.split('/')[0];\n\t\t\t\telse found = found || mime === file.type;\n\t\t\t\treturn found;\n\t\t\t});\n\t\t\tif (!mimePassed) {\n\t\t\t\temit('error', createError.accept(file));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// Max files check\n\t\tif (props.maxFiles) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\tif (props.modelValue.length + index + 1 > props.maxFiles) {\n\t\t\t\t\temit(\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\tcreateError.maxFiles(file, props.modelValue.length + index + 1)\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n};\n\nconst onDragOver = (event: Event) => {\n\t// Find the closest dropzone in case of nested dropzones\n\tconst target = event.target;\n\tif (target instanceof HTMLElement) {\n\t\tconst closestDropzone = findInTree([target], 'parentElement', (el) =>\n\t\t\tel.classList.contains('bb-dropzone')\n\t\t);\n\t\tif (closestDropzone) {\n\t\t\t/* When dragging over this dropzone set as dragging */\n\t\t\tif (closestDropzone.id === containerId) {\n\t\t\t\tsetDragging();\n\t\t\t\t/* When dragging over a nested dropzone do not highlight this dropzone */\n\t\t\t} else {\n\t\t\t\tunsetDragging();\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst setDragging = () => {\n\tclearTimeout(draggingTimeout);\n\tdragging.value = true;\n};\n\nconst unsetDragging = () => {\n\tdraggingTimeout = setTimeout(() => {\n\t\tdragging.value = false;\n\t}, 100);\n};\n\nconst bytesToUnit = (bytes: number, decimals = 2) => {\n\tif (!bytes) return '0 B';\n\tconst k = 1024;\n\tconst dm = decimals || 0;\n\tconst sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\treturn 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\tconst properties: (keyof File)[] = ['name', 'size', 'lastModified', 'type'];\n\treturn !properties.some((key) => file[key] !== otherFile[key]);\n};\n\n/**\n * Helper that creates errors based on component properties\n */\nconst createError = {\n\tmaxSize: (file: File) => {\n\t\t// Todo update to isNil\n\t\tif (props.maxSize) {\n\t\t\treturn {\n\t\t\t\ttype: 'maxSize',\n\t\t\t\tfile: file,\n\t\t\t\tformattedMaxSize: bytesToUnit(+props.maxSize),\n\t\t\t\tformattedSize: bytesToUnit(file.size),\n\t\t\t\tfilename: file.name,\n\t\t\t} as const;\n\t\t} else\n\t\t\tthrow new Error(\n\t\t\t\t'Requested to create an error for maxSize without providing a maxSize.'\n\t\t\t);\n\t},\n\tuniqueness: (file: File) => {\n\t\treturn {\n\t\t\ttype: 'uniqueness',\n\t\t\tfile: file,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n\taccept: (file: File) => {\n\t\treturn {\n\t\t\ttype: 'accept',\n\t\t\tfile: file,\n\t\t\tacceptedMimeTypes: acceptedMimeTypes.value,\n\t\t\tmimeType: file.type,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n\tmaxFiles: (file: File, totalFiles: number) => {\n\t\treturn {\n\t\t\ttype: 'maxFiles',\n\t\t\tfile: file,\n\t\t\tmaxFiles: props.maxFiles,\n\t\t\ttotalFiles,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n};\n\nconst computedErrors = computed(() => {\n\treturn props.errors ? ([] as string[]).concat(props.errors) : [];\n});\n\nconst hasErrors = computed(\n\t() => Boolean(computedErrors.value.length) || props.hasErrors\n);\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbDropzone';\n</style>\n"],"names":["mime","props","__props","emit","__emit","submittable","ref","hasFocus","onFocus","event","onBlur","watch","container","file","acceptedMimeTypes","acceptedMimeTypesString","computed","accumulated","i","element","foundMime","id","useId","containerId","dragging","draggingTimeout","classes","hasErrors","slotAttributes","onDrop","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgFI,QAAAA;AAEJ,UAAMC,IAAQC,GAURC,IAAOC,GAMPC,IAAcC,EAAgB,IAAI;AAExC,QAAIL,EAAM,UACL,CAAC,MAAM,QAAQA,EAAM,MAAM;AACxB,YAAA,IAAI,MAAM,iCAAiC;AAGnD,QAAIA,EAAM,YACL,CAAC,MAAM,QAAQA,EAAM,UAAU;AAClC,YAAM,IAAI;AAAA,QACT;AAAA,MAAA;AAKG,UAAAM,IAAWD,EAAI,EAAK,GACpBE,IAAU,CAACC,M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AAA,QACN,MAAAA;AAAA,QACA,UAAUA,EAAK;AAAA,MAAA;AAAA,MAGjB,QAAQ,CAACA,OACD;AAAA,QACN,MAAM;AAAA,QACN,MAAAA;AAAA,QACA,mBAAmBC,EAAkB;AAAA,QACrC,UAAUD,EAAK;AAAA,QACf,UAAUA,EAAK;AAAA,MAAA;AAAA,MAGjB,UAAU,CAACA,GAAY0C,OACf;AAAA,QACN,MAAM;AAAA,QACN,MAAA1C;AAAA,QACA,UAAUZ,EAAM;AAAA,QAChB,YAAAsD;AAAA,QACA,UAAU1C,EAAK;AAAA,MAAA;AAAA,IAEjB,GAGK2C,IAAiBxC,EAAS,MACxBf,EAAM,SAAU,CAAC,EAAe,OAAOA,EAAM,MAAM,IAAI,EAC9D,GAEK0B,IAAYX;AAAA,MACjB,MAAM,EAAQwC,EAAe,MAAM,UAAWvD,EAAM;AAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index76.js","sources":["../src/components/BbDropzone/BbDropzone.vue"],"sourcesContent":["<template>\n\t<component :is=\"tag\" :id=\"containerId\" :class=\"classes\">\n\t\t<label\n\t\t\t@dragenter.prevent=\"setDragging\"\n\t\t\t@dragleave.prevent=\"unsetDragging\"\n\t\t\t@dragover.prevent=\"onDragOver\"\n\t\t\t@drop.prevent=\"onDrop\"\n\t\t>\n\t\t\t<input\n\t\t\t\t:accept=\"acceptedMimeTypesString\"\n\t\t\t\t:autofocus=\"autofocus\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:multiple=\"multiple\"\n\t\t\t\ttype=\"file\"\n\t\t\t\t@blur=\"onBlur\"\n\t\t\t\t@change=\"onChange\"\n\t\t\t\t@focus=\"onFocus\"\n\t\t\t/>\n\t\t\t<slot v-bind=\"slotAttributes\"></slot>\n\t\t</label>\n\t\t<label aria-hidden=\"true\" class=\"bb-dropzone__submittable-label\">\n\t\t\tServer files\n\t\t\t<input\n\t\t\t\t:id=\"id\"\n\t\t\t\tref=\"submittable\"\n\t\t\t\tclass=\"bb-dropzone__submittable-input\"\n\t\t\t\t:disabled=\"disabled\"\n\t\t\t\t:multiple=\"multiple\"\n\t\t\t\t:name=\"name\"\n\t\t\t\ttype=\"file\"\n\t\t\t/>\n\t\t</label>\n\n\t\t<span class=\"bb-dropzone__errors\">\n\t\t\t<BbSmoothHeight tag=\"span\">\n\t\t\t\t<span\n\t\t\t\t\tv-for=\"error in computedErrors\"\n\t\t\t\t\t:key=\"error\"\n\t\t\t\t\tclass=\"bb-dropzone__error\"\n\t\t\t\t\t>{{ error }}</span\n\t\t\t\t>\n\t\t\t</BbSmoothHeight>\n\t\t</span>\n\t</component>\n</template>\n\n<script setup lang=\"ts\">\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\t(typeof createError)[keyof typeof createError]\n>;\n\nexport type BbDropzoneProps = Pick<\n\tCommonProps,\n\t'autofocus' | 'disabled' | 'errors' | 'hasErrors' | 'id' | 'multiple' | 'name'\n> & {\n\t/**\n\t * Array of mime-types or extensions to filter selectable files.\n\t */\n\taccept?: string[];\n\t/**\n\t * Maximum number of acceptable files\n\t */\n\tmaxFiles?: number;\n\t/**\n\t * Max size of the files in bytes.\n\t */\n\tmaxSize?: number;\n\t/**\n\t * Used by v-model.\n\t */\n\tmodelValue: any;\n} & NonVoidElementTag;\n\n// This is the dynamic import for mime\nlet mime: any;\n\nconst props = withDefaults(defineProps<BbDropzoneProps>(), {\n\ttag: 'div',\n});\n\nexport type BbDropzoneEvents = {\n\t(e: 'blur', event: FocusEvent): void;\n\t(e: 'error', data: DropZoneError): void;\n\t(e: 'focus', event: FocusEvent): void;\n\t(e: 'update:modelValue', data: any): void;\n};\nconst emit = defineEmits<BbDropzoneEvents>();\n\ndefineSlots<{\n\tdefault?: (props: { dragging: boolean; focused: boolean; id: string }) => any;\n}>();\n\nconst submittable = ref<any | null>(null);\n\nif (props.accept) {\n\tif (!Array.isArray(props.accept)) {\n\t\tthrow new Error('Property accept is not an array');\n\t}\n}\nif (props.multiple) {\n\tif (!Array.isArray(props.modelValue)) {\n\t\tthrow new Error(\n\t\t\t'Component is set to multiple but modelValue is not an array'\n\t\t);\n\t}\n}\n\nconst hasFocus = ref(false);\nconst onFocus = (event: FocusEvent) => {\n\thasFocus.value = true;\n\temit('focus', event);\n};\nconst onBlur = (event: FocusEvent) => {\n\thasFocus.value = false;\n\temit('blur', event);\n};\n\n/** Allow dropzone to be submittable (this is flimsy and might break) */\nwatch(\n\t() => props.modelValue,\n\t() => {\n\t\tlet container = new DataTransfer();\n\t\tif (Array.isArray(props.modelValue)) {\n\t\t\tif (props.modelValue.length) {\n\t\t\t\tprops.modelValue.forEach((file) => container.items.add(file));\n\t\t\t}\n\t\t} else {\n\t\t\tif (props.modelValue) container.items.add(props.modelValue);\n\t\t}\n\t\tif (submittable.value) {\n\t\t\tif (container.items.length) {\n\t\t\t\tsubmittable.value.files = container.files;\n\t\t\t} else {\n\t\t\t\tsubmittable.value.files = null;\n\t\t\t}\n\t\t}\n\t}\n);\n\nconst acceptedMimeTypes = ref<string[]>([]);\nconst acceptedMimeTypesString = computed(() =>\n\tacceptedMimeTypes.value.join(',')\n);\nwatch(\n\t() => props.accept,\n\tasync () => {\n\t\tif (props.accept) {\n\t\t\tlet accumulated = [];\n\t\t\tfor (let i = 0; i < props.accept.length; i++) {\n\t\t\t\tconst element = props.accept[i];\n\t\t\t\tif (element.includes('/')) accumulated.push(element);\n\t\t\t\telse {\n\t\t\t\t\tif (!mime) {\n\t\t\t\t\t\tconst mod = await import('mime');\n\t\t\t\t\t\tmime = mod.default;\n\t\t\t\t\t}\n\t\t\t\t\tconst foundMime = mime.getType(element);\n\t\t\t\t\tif (!foundMime) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Could not detect the correct mime associated with ${element}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\taccumulated.push(foundMime);\n\t\t\t\t}\n\t\t\t}\n\t\t\tacceptedMimeTypes.value = accumulated;\n\t\t}\n\t},\n\t{ 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\treturn {\n\t\t'bb-dropzone': true,\n\t\t'bb-dropzone--errors': hasErrors.value,\n\t\t'bb-dropzone--dragging': dragging.value,\n\t};\n});\nconst slotAttributes = computed(() => {\n\treturn {\n\t\tdragging: dragging.value,\n\t\tfocused: hasFocus.value,\n\t\tid: id,\n\t};\n});\n\n/**\n * Component handlers\n */\nconst onDrop = (event: DragEvent) => {\n\tdragging.value = false;\n\n\tif (event.dataTransfer) {\n\t\tevent.stopImmediatePropagation();\n\t\tlet files;\n\t\tfiles = Array.from(event.dataTransfer.files);\n\t\tfiles = parseFiles(files);\n\t\tif (props.multiple) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\temit('update:modelValue', [...props.modelValue, ...files]);\n\t\t\t}\n\t\t} else {\n\t\t\tfiles = files[0];\n\t\t\temit('update:modelValue', files);\n\t\t}\n\t\tif (event.currentTarget instanceof HTMLLabelElement) {\n\t\t\tconst innerInput = event.currentTarget.querySelector('input[type=file]');\n\t\t\tif (innerInput instanceof HTMLInputElement) {\n\t\t\t\tinnerInput.focus();\n\t\t\t}\n\t\t}\n\t}\n};\nconst onChange = (event: Event) => {\n\tif (event.target instanceof HTMLInputElement) {\n\t\tif (event.target.files) {\n\t\t\tlet files;\n\t\t\tfiles = parseFiles(Array.from(event.target.files));\n\t\t\tif (props.multiple) {\n\t\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\t\temit('update:modelValue', [...props.modelValue, ...files]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfiles = files[0];\n\t\t\t\temit('update:modelValue', files);\n\t\t\t}\n\t\t}\n\t\tevent.target.value = '';\n\t\tevent.target.files = null;\n\t}\n};\n\nconst parseFiles = (files: File[]) => {\n\treturn files.filter((file, index) => {\n\t\t// Sizecheck\n\t\tif (props.maxSize) {\n\t\t\tlet passing = file.size <= props.maxSize;\n\t\t\tif (!passing) {\n\t\t\t\temit('error', createError.maxSize(file));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// Uniqueness check\n\t\tlet alreadyExists = false;\n\t\tif (props.modelValue) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\talreadyExists = props.modelValue.some((current) =>\n\t\t\t\t\tcompareFiles(current, file)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\talreadyExists = compareFiles(props.modelValue, file);\n\t\t\t}\n\t\t}\n\t\tif (alreadyExists) {\n\t\t\temit('error', createError.uniqueness(file));\n\t\t\treturn false;\n\t\t}\n\t\t// Mime type check\n\t\tif (props.accept) {\n\t\t\tconst mimePassed = acceptedMimeTypes.value.some((mime) => {\n\t\t\t\tlet found = false;\n\t\t\t\tif (mime.includes('*'))\n\t\t\t\t\tfound = found || mime.split('/')[0] === file.type.split('/')[0];\n\t\t\t\telse found = found || mime === file.type;\n\t\t\t\treturn found;\n\t\t\t});\n\t\t\tif (!mimePassed) {\n\t\t\t\temit('error', createError.accept(file));\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\t// Max files check\n\t\tif (props.maxFiles) {\n\t\t\tif (Array.isArray(props.modelValue)) {\n\t\t\t\tif (props.modelValue.length + index + 1 > props.maxFiles) {\n\t\t\t\t\temit(\n\t\t\t\t\t\t'error',\n\t\t\t\t\t\tcreateError.maxFiles(file, props.modelValue.length + index + 1)\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n};\n\nconst onDragOver = (event: Event) => {\n\t// Find the closest dropzone in case of nested dropzones\n\tconst target = event.target;\n\tif (target instanceof HTMLElement) {\n\t\tconst closestDropzone = findInTree([target], 'parentElement', (el) =>\n\t\t\tel.classList.contains('bb-dropzone')\n\t\t);\n\t\tif (closestDropzone) {\n\t\t\t/* When dragging over this dropzone set as dragging */\n\t\t\tif (closestDropzone.id === containerId) {\n\t\t\t\tsetDragging();\n\t\t\t\t/* When dragging over a nested dropzone do not highlight this dropzone */\n\t\t\t} else {\n\t\t\t\tunsetDragging();\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst setDragging = () => {\n\tclearTimeout(draggingTimeout);\n\tdragging.value = true;\n};\n\nconst unsetDragging = () => {\n\tdraggingTimeout = setTimeout(() => {\n\t\tdragging.value = false;\n\t}, 100);\n};\n\nconst bytesToUnit = (bytes: number, decimals = 2) => {\n\tif (!bytes) return '0 B';\n\tconst k = 1024;\n\tconst dm = decimals || 0;\n\tconst sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\treturn 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\tconst properties: (keyof File)[] = ['name', 'size', 'lastModified', 'type'];\n\treturn !properties.some((key) => file[key] !== otherFile[key]);\n};\n\n/**\n * Helper that creates errors based on component properties\n */\nconst createError = {\n\tmaxSize: (file: File) => {\n\t\t// Todo update to isNil\n\t\tif (props.maxSize) {\n\t\t\treturn {\n\t\t\t\ttype: 'maxSize',\n\t\t\t\tfile: file,\n\t\t\t\tformattedMaxSize: bytesToUnit(+props.maxSize),\n\t\t\t\tformattedSize: bytesToUnit(file.size),\n\t\t\t\tfilename: file.name,\n\t\t\t} as const;\n\t\t} else\n\t\t\tthrow new Error(\n\t\t\t\t'Requested to create an error for maxSize without providing a maxSize.'\n\t\t\t);\n\t},\n\tuniqueness: (file: File) => {\n\t\treturn {\n\t\t\ttype: 'uniqueness',\n\t\t\tfile: file,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n\taccept: (file: File) => {\n\t\treturn {\n\t\t\ttype: 'accept',\n\t\t\tfile: file,\n\t\t\tacceptedMimeTypes: acceptedMimeTypes.value,\n\t\t\tmimeType: file.type,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n\tmaxFiles: (file: File, totalFiles: number) => {\n\t\treturn {\n\t\t\ttype: 'maxFiles',\n\t\t\tfile: file,\n\t\t\tmaxFiles: props.maxFiles,\n\t\t\ttotalFiles,\n\t\t\tfilename: file.name,\n\t\t} as const;\n\t},\n};\n\nconst computedErrors = computed(() => {\n\treturn props.errors ? ([] as string[]).concat(props.errors) : [];\n});\n\nconst hasErrors = computed(\n\t() => Boolean(computedErrors.value.length) || props.hasErrors\n);\n</script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/BbDropzone';\n</style>\n"],"names":["mime","props","__props","emit","__emit","submittable","ref","hasFocus","onFocus","event","onBlur","watch","container","file","acceptedMimeTypes","acceptedMimeTypesString","computed","accumulated","i","element","foundMime","id","useId","containerId","dragging","draggingTimeout","classes","hasErrors","slotAttributes","onDrop","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgFI,QAAAA;AAEJ,UAAMC,IAAQC,GAURC,IAAOC,GAMPC,IAAcC,EAAgB,IAAI;AAExC,QAAIL,EAAM,UACL,CAAC,MAAM,QAAQA,EAAM,MAAM;AACxB,YAAA,IAAI,MAAM,iCAAiC;AAGnD,QAAIA,EAAM,YAC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