bitboss-ui 2.0.21 → 2.0.22
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/index107.js +5 -5
- package/dist/index115.js +1 -1
- package/dist/index117.js +5 -5
- package/dist/index119.js +1 -1
- package/dist/index123.js +1 -1
- package/dist/index124.js +1 -1
- package/dist/index125.js +1 -1
- package/dist/index127.js +1 -1
- package/dist/index129.js +2 -2
- package/dist/index130.js +1 -1
- package/dist/index14.js +1 -1
- package/dist/index16.js +3 -3
- package/dist/index18.js +2 -2
- package/dist/index199.js +81 -2
- package/dist/index199.js.map +1 -1
- package/dist/index20.js +14 -14
- package/dist/index200.js +8 -5
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +3 -16
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +2 -16
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +44 -19
- package/dist/index203.js.map +1 -1
- package/dist/index205.js +13 -27
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +158 -3
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +84 -2
- package/dist/index207.js.map +1 -1
- package/dist/index209.js +3 -249
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +35 -52
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +5 -43
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +7 -5
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +281 -49
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +14 -124
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +13 -120
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +19 -2
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +19 -35
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +25 -172
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +3 -6
- package/dist/index219.js.map +1 -1
- package/dist/index22.js +15 -15
- package/dist/index220.js +2 -44
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +252 -0
- package/dist/index221.js.map +1 -0
- package/dist/index222.js +52 -13
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +44 -5
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +5 -369
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +48 -80
- package/dist/index225.js.map +1 -1
- package/dist/index226.js +2 -3
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +4 -7
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +2 -158
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +125 -83
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +126 -0
- package/dist/index230.js.map +1 -0
- package/dist/index231.js +2 -2
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +174 -4
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +5 -2
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +369 -3
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +2 -2
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +2 -18
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +17 -105
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +109 -0
- package/dist/index238.js.map +1 -0
- package/dist/index24.js +5 -5
- package/dist/{index239.js → index240.js} +2 -2
- package/dist/{index239.js.map → index240.js.map} +1 -1
- package/dist/index244.js +6 -3
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +15 -8
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +9 -23
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +3 -281
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +9 -6
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +23 -2
- package/dist/index249.js.map +1 -1
- package/dist/index250.js +224 -2
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +3 -2
- package/dist/index251.js.map +1 -1
- package/dist/index253.js +7 -2
- package/dist/index253.js.map +1 -1
- package/dist/index254.js +3 -2
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +12 -2
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +9 -2
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +9 -2
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +17 -2
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +2 -28
- package/dist/index259.js.map +1 -1
- package/dist/index26.js +1 -1
- package/dist/index260.js +61 -17
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +8 -0
- package/dist/index261.js.map +1 -0
- package/dist/index262.js +429 -5
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +89 -6
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +6 -16
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +2 -2
- package/dist/index266.js +2 -126
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +2 -431
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +2 -3
- package/dist/index268.js.map +1 -1
- package/dist/{index252.js → index269.js} +1 -1
- package/dist/index269.js.map +1 -0
- package/dist/index270.js +2 -22
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +5 -0
- package/dist/index271.js.map +1 -0
- package/dist/index272.js +2 -89
- package/dist/index272.js.map +1 -1
- package/dist/index273.js +2 -200
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +2 -436
- package/dist/index274.js.map +1 -1
- package/dist/index275.js +26 -125
- package/dist/index275.js.map +1 -1
- package/dist/index276.js +22 -3
- package/dist/index276.js.map +1 -1
- package/dist/index278.js +199 -8
- package/dist/index278.js.map +1 -1
- package/dist/index279.js +4 -9
- package/dist/index279.js.map +1 -1
- package/dist/index28.js +3 -3
- package/dist/index280.js +2 -17
- package/dist/index280.js.map +1 -1
- package/dist/index281.js +126 -4
- package/dist/index281.js.map +1 -1
- package/dist/index282.js +22 -9
- package/dist/index282.js.map +1 -1
- package/dist/index284.js +436 -2
- package/dist/index284.js.map +1 -1
- package/dist/index285.js +126 -65
- package/dist/index285.js.map +1 -1
- package/dist/index286.js +1 -1
- package/dist/index287.js +1 -1
- package/dist/index288.js +2 -2
- package/dist/index289.js +15 -5
- package/dist/index289.js.map +1 -1
- package/dist/index290.js +4 -15
- package/dist/index290.js.map +1 -1
- package/dist/index291.js +4 -79
- package/dist/index291.js.map +1 -1
- package/dist/index292.js +62 -0
- package/dist/index292.js.map +1 -0
- package/dist/index293.js +79 -7
- package/dist/index293.js.map +1 -1
- package/dist/index295.js +2 -4
- package/dist/index295.js.map +1 -1
- package/dist/index296.js +11 -4
- package/dist/index296.js.map +1 -1
- package/dist/index297.js +34 -58
- package/dist/index297.js.map +1 -1
- package/dist/index298.js +6 -6
- package/dist/index298.js.map +1 -1
- package/dist/index299.js +18 -34
- package/dist/index299.js.map +1 -1
- package/dist/index30.js +2 -2
- package/dist/index300.js +46 -10
- package/dist/index300.js.map +1 -1
- package/dist/index301.js +6 -46
- package/dist/index301.js.map +1 -1
- package/dist/index302.js +480 -2
- package/dist/index302.js.map +1 -1
- package/dist/index304.js +424 -0
- package/dist/index304.js.map +1 -0
- package/dist/index305.js +42 -416
- package/dist/index305.js.map +1 -1
- package/dist/index306.js +2 -47
- package/dist/index306.js.map +1 -1
- package/dist/index32.js +2 -2
- package/dist/index34.js +3 -3
- package/dist/index36.js +13 -13
- package/dist/index38.js +4 -4
- package/dist/index40.js +2 -2
- package/dist/index42.js +2 -2
- package/dist/index44.js +6 -6
- package/dist/index46.js +2 -2
- package/dist/index48.js +2 -2
- package/dist/index54.js +1 -1
- package/dist/index56.js +1 -1
- package/dist/index72.js +3 -3
- package/dist/index76.js +2 -2
- package/dist/index78.js +1 -1
- package/dist/index81.js +2 -2
- package/dist/index83.js +76 -65
- package/dist/index83.js.map +1 -1
- package/dist/index85.js +3 -3
- package/dist/index87.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index204.js +0 -22
- package/dist/index204.js.map +0 -1
- package/dist/index208.js +0 -11
- package/dist/index208.js.map +0 -1
- package/dist/index241.js +0 -5
- package/dist/index241.js.map +0 -1
- package/dist/index252.js.map +0 -1
- package/dist/index277.js +0 -15
- package/dist/index277.js.map +0 -1
- package/dist/index283.js +0 -227
- package/dist/index283.js.map +0 -1
- package/dist/index294.js +0 -22
- package/dist/index294.js.map +0 -1
- package/dist/index303.js +0 -483
- package/dist/index303.js.map +0 -1
- package/dist/index307.js +0 -5
- package/dist/index307.js.map +0 -1
package/dist/index205.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index205.js","sources":["../
|
1
|
+
{"version":3,"file":"index205.js","sources":["../src/components/CommonInputOuterContainer.vue"],"sourcesContent":["<template>\n\t<span class=\"bb-common-input-outer-container\">\n\t\t<slot name=\"prepend-outer\" />\n\t\t<slot />\n\t\t<slot name=\"append-outer\" />\n\t</span>\n</template>\n\n<script setup lang=\"ts\"></script>\n\n<style lang=\"postcss\">\n@import '@/assets/css/CommonInputInnerContainer';\n</style>\n"],"names":["_sfc_render","_ctx","_cache","_openBlock","_createElementBlock","_hoisted_1","_renderSlot"],"mappings":";;;;AACC,SAAAA,EAAAC,GAAAC,GAAA;SAC8BC,EAAA,GAAAC,EAAA,QAAAC,GAAA;AAAA,IAC7BC,EAAQL,EAAA,QAAA,eAAA;AAAA,IACRK,EAA4BL,EAAA,QAAA,SAAA;AAAA;;;;"}
|
package/dist/index206.js
CHANGED
@@ -1,6 +1,161 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import { ref as a, computed as r, onBeforeMount as Y, onBeforeUnmount as Z, watch as H, nextTick as N } from "vue";
|
2
|
+
import { last as _ } from "./index220.js";
|
3
|
+
import { useArray as Q } from "./index255.js";
|
4
|
+
import { uniqBy as $ } from "./index256.js";
|
5
|
+
import { useItemValue as ee } from "./index257.js";
|
6
|
+
import { useItemText as te } from "./index258.js";
|
7
|
+
import { hash as v } from "./index219.js";
|
8
|
+
import { isNotNil as q } from "./index131.js";
|
9
|
+
import { waitFor as le } from "./index211.js";
|
10
|
+
import { isNil as oe } from "./index126.js";
|
11
|
+
const he = (l) => {
|
12
|
+
const i = a(""), F = a(), u = (e) => {
|
13
|
+
F.value = e, l.emit("update:modelValue", e);
|
14
|
+
}, d = a([]), {
|
15
|
+
array: k,
|
16
|
+
add: E,
|
17
|
+
remove: P,
|
18
|
+
set: y
|
19
|
+
} = Q(), {
|
20
|
+
array: S,
|
21
|
+
add: j,
|
22
|
+
remove: J
|
23
|
+
} = Q(), { getItemText: L } = te(), { getItemValue: U } = ee(), O = (e) => {
|
24
|
+
const t = !!(l.disabled.value || e.disabled), o = L(e, l.itemText), n = U(e, l.itemValue);
|
25
|
+
if (n === void 0)
|
26
|
+
throw new Error(
|
27
|
+
'The result of extracting "value" from option was undefined. Affected item is ' + JSON.stringify(e) + " please check itemValue property is correct."
|
28
|
+
);
|
29
|
+
const X = v(n);
|
30
|
+
return {
|
31
|
+
item: e,
|
32
|
+
text: o,
|
33
|
+
value: n,
|
34
|
+
valueHash: X,
|
35
|
+
disabled: t,
|
36
|
+
selected: !1
|
37
|
+
};
|
38
|
+
}, T = (e) => (e.selected = q(b.value[e.valueHash]), e), V = r(() => {
|
39
|
+
const e = [].concat(
|
40
|
+
d.value.map((t) => T(O(t))),
|
41
|
+
S.value.map(T),
|
42
|
+
k.value.map(T)
|
43
|
+
);
|
44
|
+
return $(e, (t) => t.valueHash);
|
45
|
+
}), z = (e) => {
|
46
|
+
l.multiple ? (u(l.modelValue.value.concat(e.value)), l.stash && E(e), l.resetQueryOnOptionSelected && s()) : (l.stash && y(e), u(e.value), N(() => s()));
|
47
|
+
}, G = async (e) => {
|
48
|
+
if (J((t) => t.valueHash !== e.valueHash), P((t) => t.valueHash !== e.valueHash), l.multiple) {
|
49
|
+
const t = { ...b.value };
|
50
|
+
delete t[e.valueHash], u(Object.values(t));
|
51
|
+
} else
|
52
|
+
u(null), await N(), s();
|
53
|
+
}, b = r(() => {
|
54
|
+
const e = {}, t = [].concat(l.modelValue.value);
|
55
|
+
for (let o = 0; o < t.length; o++) {
|
56
|
+
const n = t[o];
|
57
|
+
e[v(n)] = n;
|
58
|
+
}
|
59
|
+
return e;
|
60
|
+
}), g = async ({ prefill: e = !1 }) => {
|
61
|
+
let t = [];
|
62
|
+
if (Array.isArray(l.items.value))
|
63
|
+
t = l.items.value;
|
64
|
+
else if (typeof l.items.value == "function") {
|
65
|
+
const o = ++c.value;
|
66
|
+
try {
|
67
|
+
t = await l.items.value(
|
68
|
+
i.value,
|
69
|
+
e,
|
70
|
+
l.modelValue.value
|
71
|
+
), o < c.value && (await le(() => o === c.value), t = d.value);
|
72
|
+
} catch (n) {
|
73
|
+
console.error(n);
|
74
|
+
}
|
75
|
+
c.value--;
|
76
|
+
}
|
77
|
+
d.value = t;
|
78
|
+
}, B = r(() => {
|
79
|
+
const e = {};
|
80
|
+
for (let t = 0; t < V.value.length; t++) {
|
81
|
+
const o = V.value[t], { valueHash: n } = o;
|
82
|
+
e[n] = o;
|
83
|
+
}
|
84
|
+
return {
|
85
|
+
get: (t) => e[v(t)]
|
86
|
+
};
|
87
|
+
}), f = r(() => [].concat(l.modelValue.value).reduce((e, t) => {
|
88
|
+
const o = B.value.get(t);
|
89
|
+
return o && e.push(o), e;
|
90
|
+
}, [])), C = (e) => q(B.value.get(e)), s = () => {
|
91
|
+
if (l.multiple) {
|
92
|
+
i.value = "";
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
let e;
|
96
|
+
f.value && (e = _(f.value)), i.value = (e == null ? void 0 : e.text) || "";
|
97
|
+
}, K = () => {
|
98
|
+
const e = i.value.trim(), t = O(e);
|
99
|
+
j(t), s();
|
100
|
+
}, c = a(0), M = r(() => [].concat(l.modelValue.value).reduce(
|
101
|
+
(e, t) => (C(t) ? e.coherent.push(t) : e.incoherent.push(t), e),
|
102
|
+
{ coherent: [], incoherent: [] }
|
103
|
+
)), A = r(() => l.multiple && !l.modelValue.value.length || !l.multiple && oe(l.modelValue.value) ? !0 : !M.value.incoherent.length), R = () => {
|
104
|
+
l.enforceCoherence && !A.value && (l.multiple ? u(M.value.coherent) : u(null));
|
105
|
+
}, p = a(!1), I = a(!1), m = async () => {
|
106
|
+
I.value = !0, await g({ prefill: !0 }), R(), s(), p.value = !0, I.value = !1;
|
107
|
+
};
|
108
|
+
Y(async () => {
|
109
|
+
l.prefill && (await m(), l.stash && y(...f.value));
|
110
|
+
});
|
111
|
+
let h;
|
112
|
+
const W = () => {
|
113
|
+
h && clearTimeout(h), h = setTimeout(async () => {
|
114
|
+
try {
|
115
|
+
await g({ prefill: !1 });
|
116
|
+
} catch (e) {
|
117
|
+
console.error(e);
|
118
|
+
}
|
119
|
+
}, l.queryDebounceTime);
|
120
|
+
};
|
121
|
+
Z(() => clearTimeout(h));
|
122
|
+
let x;
|
123
|
+
H(
|
124
|
+
() => l.modelValue.value,
|
125
|
+
() => {
|
126
|
+
A.value || (x && clearTimeout(x), x = setTimeout(async () => {
|
127
|
+
m();
|
128
|
+
}, l.modelValueDebounceTime));
|
129
|
+
}
|
130
|
+
);
|
131
|
+
let w;
|
132
|
+
const D = async (e, t) => {
|
133
|
+
v(t) !== v(e) && p.value && (w && clearTimeout(w), w = setTimeout(async () => {
|
134
|
+
await m();
|
135
|
+
}, l.depsDebounceTime));
|
136
|
+
};
|
137
|
+
return H(() => l.items.value, D), H(() => l.dependencies.value, D), {
|
138
|
+
addCurrentQueryToManualItems: K,
|
139
|
+
alignQueryToState: s,
|
140
|
+
getOptions: g,
|
141
|
+
hasPrefilled: p,
|
142
|
+
innerLoading: c,
|
143
|
+
isPrefilling: I,
|
144
|
+
manualItems: S,
|
145
|
+
options: V,
|
146
|
+
prefillItems: m,
|
147
|
+
query: i,
|
148
|
+
searchByQuery: W,
|
149
|
+
selectedOptions: f,
|
150
|
+
selectOption: z,
|
151
|
+
setStash: y,
|
152
|
+
unselectOption: G,
|
153
|
+
updateModelValue: u,
|
154
|
+
valueIsSelected: C,
|
155
|
+
internalItems: d
|
156
|
+
};
|
157
|
+
};
|
3
158
|
export {
|
4
|
-
|
159
|
+
he as useOptions
|
5
160
|
};
|
6
161
|
//# sourceMappingURL=index206.js.map
|
package/dist/index206.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index206.js","sources":["../src/utilities/functions/hash.ts"],"sourcesContent":["import { hash as _h } from 'object-code';\n\nexport const hash = (value: any, prefix = 'bb') => {\n\treturn `${prefix}${_h(value)}`;\n};\n"],"names":["hash","value","prefix","_h"],"mappings":";AAEO,MAAMA,IAAO,CAACC,GAAYC,IAAS,SAClC,GAAGA,CAAM,GAAGC,EAAGF,CAAK,CAAC;"}
|
1
|
+
{"version":3,"file":"index206.js","sources":["../src/composables/useOptions.ts"],"sourcesContent":["import {\n\tcomputed,\n\tnextTick,\n\tonBeforeMount,\n\tonBeforeUnmount,\n\tref,\n\twatch,\n\ttype Ref,\n} from 'vue';\nimport type { Option as BaseOption } from '@/types/Option';\nimport { last } from '@/utilities/functions/last';\nimport { useArray } from './useArray';\nimport { uniqBy } from '@/utilities/functions/uniqBy';\nimport { useItemValue } from './useItemValue';\nimport { useItemText } from './useItemText';\nimport { hash } from '@/utilities/functions/hash';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { waitFor } from '@/utilities/functions/waitFor';\nimport { isNil } from '@/utilities/functions/isNil';\n\ntype Options = {\n\tmultiple: boolean;\n\tstash: boolean;\n\titemText: string | ((item: any) => string) | undefined;\n\titemValue: string | ((item: any) => string) | undefined;\n\tmodelValue: Ref<any>;\n\tresetQueryOnOptionSelected: boolean;\n\temit: any;\n\titems: Ref<any>;\n\tenforceCoherence: boolean;\n\tprefill: boolean;\n\tmodelValueDebounceTime: number;\n\tdepsDebounceTime: number;\n\tdependencies: Ref<any[]>;\n\tqueryDebounceTime: number;\n\tdisabled: Ref<boolean>;\n};\n\nexport const useOptions = (params: Options) => {\n\tconst query = ref<string>('');\n\n\tconst lastEmittedValue = ref();\n\tconst updateModelValue = (value: any) => {\n\t\tlastEmittedValue.value = value;\n\t\tparams.emit('update:modelValue', value);\n\t};\n\n\tconst internalItems = ref<any[]>([]);\n\tconst {\n\t\tarray: innerStash,\n\t\tadd: addToStash,\n\t\tremove: removeFromStash,\n\t\tset: setStash,\n\t} = useArray<BaseOption>();\n\n\tconst {\n\t\tarray: manualItems,\n\t\tadd: addToManualItems,\n\t\tremove: removeFromManualItems,\n\t} = useArray<BaseOption>();\n\n\tconst { getItemText } = useItemText();\n\tconst { getItemValue } = useItemValue();\n\tconst createOption = (item: any): BaseOption => {\n\t\tconst disabled = !!(params.disabled.value || item.disabled);\n\t\tconst text = getItemText(item, params.itemText);\n\t\tconst value = getItemValue(item, params.itemValue);\n\n\t\t// Undefined is not supported\n\t\tif (value === undefined)\n\t\t\tthrow new Error(\n\t\t\t\t'The result of extracting \"value\" from option was undefined. Affected item is ' +\n\t\t\t\t\tJSON.stringify(item) +\n\t\t\t\t\t' please check itemValue property is correct.'\n\t\t\t);\n\t\tconst valueHash = hash(value);\n\t\tconst selected = false;\n\t\treturn {\n\t\t\titem,\n\t\t\ttext,\n\t\t\tvalue,\n\t\t\tvalueHash,\n\t\t\tdisabled,\n\t\t\tselected,\n\t\t};\n\t};\n\n\tconst setSelected = (o: BaseOption) => {\n\t\to.selected = isNotNil(modelValueIndexedByHash.value[o.valueHash]);\n\t\treturn o;\n\t};\n\tconst options = computed<BaseOption[]>(() => {\n\t\tconst base = ([] as BaseOption[]).concat(\n\t\t\tinternalItems.value.map((item) => {\n\t\t\t\treturn setSelected(createOption(item));\n\t\t\t}),\n\t\t\tmanualItems.value.map(setSelected),\n\t\t\tinnerStash.value.map(setSelected)\n\t\t);\n\t\treturn uniqBy(base, (o) => o.valueHash);\n\t});\n\n\tconst selectOption = (option: BaseOption) => {\n\t\tif (params.multiple) {\n\t\t\tupdateModelValue(params.modelValue.value.concat(option.value));\n\t\t\tif (params.stash) {\n\t\t\t\taddToStash(option);\n\t\t\t}\n\n\t\t\tif (params.resetQueryOnOptionSelected) {\n\t\t\t\talignQueryToState();\n\t\t\t}\n\t\t} else {\n\t\t\tif (params.stash) {\n\t\t\t\tsetStash(option);\n\t\t\t}\n\t\t\tupdateModelValue(option.value);\n\t\t\tnextTick(() => alignQueryToState());\n\t\t}\n\t};\n\tconst unselectOption = async (option: BaseOption) => {\n\t\tremoveFromManualItems((o) => o.valueHash !== option.valueHash);\n\t\tremoveFromStash((o) => o.valueHash !== option.valueHash);\n\t\tif (params.multiple) {\n\t\t\tconst copy = { ...modelValueIndexedByHash.value };\n\t\t\tdelete copy[option.valueHash];\n\t\t\tupdateModelValue(Object.values(copy));\n\t\t} else {\n\t\t\tupdateModelValue(null);\n\t\t\tawait nextTick();\n\t\t\talignQueryToState();\n\t\t}\n\t};\n\n\t/**\n\t * Indexes modelValue to a map of hash - value pairs so we can easily track which values are selected\n\t */\n\tconst modelValueIndexedByHash = computed(() => {\n\t\tconst map: Record<string, any> = {};\n\t\tconst arr = [].concat(params.modelValue.value);\n\t\tfor (let index = 0; index < arr.length; index++) {\n\t\t\tconst element = arr[index];\n\t\t\tmap[hash(element)] = element;\n\t\t}\n\t\treturn map;\n\t});\n\n\tconst getOptions = async ({ prefill = false }) => {\n\t\tlet items: any[] = [];\n\t\tif (Array.isArray(params.items.value)) {\n\t\t\titems = params.items.value;\n\t\t} else {\n\t\t\tif (typeof params.items.value === 'function') {\n\t\t\t\tconst order = ++innerLoading.value;\n\t\t\t\ttry {\n\t\t\t\t\titems = await params.items.value(\n\t\t\t\t\t\tquery.value,\n\t\t\t\t\t\tprefill,\n\t\t\t\t\t\tparams.modelValue.value\n\t\t\t\t\t);\n\t\t\t\t\t// If by the time this resolves another call has already been made discard this result\n\t\t\t\t\tif (order < innerLoading.value) {\n\t\t\t\t\t\tawait waitFor(() => order === innerLoading.value);\n\t\t\t\t\t\titems = internalItems.value;\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t\tinnerLoading.value--;\n\t\t\t}\n\t\t}\n\t\tinternalItems.value = items as any;\n\t};\n\n\t/**\n\t * Indexes options by their hash so they can be retrieved\n\t */\n\tconst optionsIndexedByHash = computed(() => {\n\t\tconst map: Record<string, BaseOption> = {};\n\t\tfor (let index = 0; index < options.value.length; index++) {\n\t\t\tconst element = options.value[index];\n\t\t\tconst { valueHash } = element;\n\t\t\tmap[valueHash] = element;\n\t\t}\n\t\treturn {\n\t\t\tget: (value: any) => {\n\t\t\t\treturn map[hash(value)];\n\t\t\t},\n\t\t};\n\t});\n\n\t/**\n\t * For every item in modelValue find the linked option if it exists.\n\t * This is used to display chips.\n\t */\n\tconst selectedOptions = computed(() => {\n\t\treturn [].concat(params.modelValue.value).reduce((acc, h) => {\n\t\t\tconst found = optionsIndexedByHash.value.get(h);\n\t\t\tif (found) {\n\t\t\t\tacc.push(found);\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] as BaseOption[]);\n\t});\n\n\tconst valueIsSelected = (value: any) =>\n\t\tisNotNil(optionsIndexedByHash.value.get(value));\n\n\tconst alignQueryToState = () => {\n\t\tif (params.multiple) {\n\t\t\tquery.value = '';\n\t\t\treturn;\n\t\t}\n\t\tlet option: BaseOption | undefined;\n\t\tif (selectedOptions.value) {\n\t\t\toption = last(selectedOptions.value);\n\t\t}\n\t\tquery.value = option?.text || '';\n\t};\n\n\t/**\n\t * Add an option to the manual items and then reset the query\n\t */\n\tconst addCurrentQueryToManualItems = () => {\n\t\tconst text = query.value.trim();\n\t\tconst option = createOption(text);\n\t\taddToManualItems(option);\n\t\talignQueryToState();\n\t};\n\n\t/**\n\t * Use a number accumulator because if the fn takes 5 seconds\n\t * and after 2 seconds another search is run\n\t * When the first returns the second is still out for 2 seconds\n\t * and we want to track them both.\n\t * Debounce will not be enough.\n\t */\n\tconst innerLoading = ref(0);\n\n\t/**\n\t * Coherent values are values that have an option they can be linked to.\n\t * Divide coherent and incoherent values.\n\t */\n\n\tconst coherenceStatus = computed(() => {\n\t\treturn [].concat(params.modelValue.value).reduce(\n\t\t\t(acc, curr) => {\n\t\t\t\tif (valueIsSelected(curr)) {\n\t\t\t\t\tacc.coherent.push(curr);\n\t\t\t\t} else {\n\t\t\t\t\tacc.incoherent.push(curr);\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{ coherent: [], incoherent: [] }\n\t\t);\n\t});\n\n\t/**\n\t * Model value is considered coherent when:\n\t * - multiple mode is empty\n\t * - single mode is null\n\t */\n\tconst modelValueIsCoherent = computed(() => {\n\t\tif (params.multiple && !params.modelValue.value.length) return true;\n\t\telse if (!params.multiple && isNil(params.modelValue.value)) return true;\n\t\treturn !coherenceStatus.value.incoherent.length;\n\t});\n\n\t/**\n\t * Realign selection state to the passed settings.\n\t * If modelValue has any value that is not coherent while\n\t * coherence is enforced the value should be removed\n\t */\n\tconst alignToCoherenceSettings = () => {\n\t\tif (params.enforceCoherence && !modelValueIsCoherent.value) {\n\t\t\tif (!params.multiple) updateModelValue(null);\n\t\t\telse updateModelValue(coherenceStatus.value.coherent);\n\t\t}\n\t};\n\n\t/**\n\t * Prefilling is the phase where the component understands it needs\n\t * to update its inner items due to a change in state, whether dependencies have changed, items or modelValue have changed.\n\t * It can be intended as the component aligning itself to what state is passed to it.\n\t */\n\tconst hasPrefilled = ref(false);\n\tconst isPrefilling = ref(false);\n\tconst prefillItems = async () => {\n\t\tisPrefilling.value = true;\n\t\tawait getOptions({ prefill: true });\n\t\talignToCoherenceSettings();\n\t\talignQueryToState();\n\t\thasPrefilled.value = true;\n\t\tisPrefilling.value = false;\n\t};\n\n\tonBeforeMount(async () => {\n\t\tif (params.prefill) {\n\t\t\tawait prefillItems();\n\t\t\tif (params.stash) {\n\t\t\t\tsetStash(...selectedOptions.value);\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * Triggered on input when items is a function.\n\t */\n\n\tlet timeout: ReturnType<typeof setTimeout>;\n\tconst searchByQuery = () => {\n\t\tif (timeout) clearTimeout(timeout);\n\t\ttimeout = setTimeout(async () => {\n\t\t\ttry {\n\t\t\t\tawait getOptions({ prefill: false });\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(error);\n\t\t\t}\n\t\t}, params.queryDebounceTime);\n\t};\n\tonBeforeUnmount(() => clearTimeout(timeout));\n\n\t/**\n\t * When modelValue changes split behavior for single and multiple selection:\n\t */\n\tlet modelValueTimeout: ReturnType<typeof setTimeout>;\n\twatch(\n\t\t() => params.modelValue.value,\n\t\t() => {\n\t\t\tif (modelValueIsCoherent.value) return;\n\t\t\tif (modelValueTimeout) clearTimeout(modelValueTimeout);\n\t\t\tmodelValueTimeout = setTimeout(async () => {\n\t\t\t\tprefillItems();\n\t\t\t}, params.modelValueDebounceTime);\n\t\t}\n\t);\n\n\t/**\n\t * START DEPENDENCY HANDLING\n\t * Explicit dependencies (props.dependencies) and implicit dependencies (props.items)\n\t * need to trigger a pipeline of realignment whenever they change\n\t */\n\tlet depsTimeout: ReturnType<typeof setTimeout>;\n\n\tconst handleDependencyChange = async (current: any, previous: any) => {\n\t\t// Circumvent arrays defined in the template by the parent triggering the watcher\n\t\tif (hash(previous) === hash(current)) return;\n\t\t// Do not track until prefill completes\n\t\tif (!hasPrefilled.value) return;\n\t\tif (depsTimeout) clearTimeout(depsTimeout);\n\t\tdepsTimeout = setTimeout(async () => {\n\t\t\tawait prefillItems();\n\t\t}, params.depsDebounceTime);\n\t};\n\n\t/**\n\t * This is triggered to refresh static items whenever the passed array changes.\n\t * If the parent defines an array in the template this is triggered\n\t * at every render so we take counter measures\n\t * Even if the entire array changes all the previously selected values are still in the stash.\n\t */\n\twatch(() => params.items.value, handleDependencyChange);\n\n\t/**\n\t * When dependencies change\n\t * If the input has not been prefilled yet just return\n\t * Check dependencies are the same by value and not reference\n\t * Otherwise we search again for options as they might be different base on dependencies.\n\t * If coherence is enforced we set the state accordingly\n\t */\n\twatch(() => params.dependencies.value, handleDependencyChange);\n\n\t/**\n\t * END DEPENDENCIES HANDLING\n\t */\n\n\treturn {\n\t\taddCurrentQueryToManualItems,\n\t\talignQueryToState,\n\t\tgetOptions,\n\t\thasPrefilled,\n\t\tinnerLoading,\n\t\tisPrefilling,\n\t\tmanualItems,\n\t\toptions,\n\t\tprefillItems,\n\t\tquery,\n\t\tsearchByQuery,\n\t\tselectedOptions,\n\t\tselectOption,\n\t\tsetStash,\n\t\tunselectOption,\n\t\tupdateModelValue,\n\t\tvalueIsSelected,\n\t\tinternalItems,\n\t};\n};\n"],"names":["useOptions","params","query","ref","lastEmittedValue","updateModelValue","value","internalItems","innerStash","addToStash","removeFromStash","setStash","useArray","manualItems","addToManualItems","removeFromManualItems","getItemText","useItemText","getItemValue","useItemValue","createOption","item","disabled","text","valueHash","hash","setSelected","o","isNotNil","modelValueIndexedByHash","options","computed","base","uniqBy","selectOption","option","alignQueryToState","nextTick","unselectOption","copy","map","arr","index","element","getOptions","prefill","items","order","innerLoading","waitFor","error","optionsIndexedByHash","selectedOptions","acc","h","found","valueIsSelected","last","addCurrentQueryToManualItems","coherenceStatus","curr","modelValueIsCoherent","isNil","alignToCoherenceSettings","hasPrefilled","isPrefilling","prefillItems","onBeforeMount","timeout","searchByQuery","onBeforeUnmount","modelValueTimeout","watch","depsTimeout","handleDependencyChange","current","previous"],"mappings":";;;;;;;;;;AAsCa,MAAAA,KAAa,CAACC,MAAoB;AACxC,QAAAC,IAAQC,EAAY,EAAE,GAEtBC,IAAmBD,KACnBE,IAAmB,CAACC,MAAe;AACxC,IAAAF,EAAiB,QAAQE,GAClBL,EAAA,KAAK,qBAAqBK,CAAK;AAAA,EAAA,GAGjCC,IAAgBJ,EAAW,CAAA,CAAE,GAC7B;AAAA,IACL,OAAOK;AAAA,IACP,KAAKC;AAAA,IACL,QAAQC;AAAA,IACR,KAAKC;AAAA,MACFC,EAAqB,GAEnB;AAAA,IACL,OAAOC;AAAA,IACP,KAAKC;AAAA,IACL,QAAQC;AAAA,MACLH,EAAqB,GAEnB,EAAE,aAAAI,MAAgBC,MAClB,EAAE,cAAAC,MAAiBC,MACnBC,IAAe,CAACC,MAA0B;AAC/C,UAAMC,IAAW,CAAC,EAAErB,EAAO,SAAS,SAASoB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jE,EAAO,gBAAgB;AAAA,EAAA;AAS3B,SAAAuE,EAAM,MAAMvE,EAAO,MAAM,OAAOyE,CAAsB,GAStDF,EAAM,MAAMvE,EAAO,aAAa,OAAOyE,CAAsB,GAMtD;AAAA,IACN,8BAAAhB;AAAA,IACA,mBAAAtB;AAAA,IACA,YAAAQ;AAAA,IACA,cAAAoB;AAAA,IACA,cAAAhB;AAAA,IACA,cAAAiB;AAAA,IACA,aAAApD;AAAA,IACA,SAAAiB;AAAA,IACA,cAAAoC;AAAA,IACA,OAAAhE;AAAA,IACA,eAAAmE;AAAA,IACA,iBAAAjB;AAAA,IACA,cAAAlB;AAAA,IACA,UAAAvB;AAAA,IACA,gBAAA2B;AAAA,IACA,kBAAAjC;AAAA,IACA,iBAAAmD;AAAA,IACA,eAAAjD;AAAA,EAAA;AAEF;"}
|
package/dist/index207.js
CHANGED
@@ -1,5 +1,87 @@
|
|
1
|
-
|
1
|
+
import { defineComponent as b, openBlock as n, createElementBlock as s, normalizeClass as r, createElementVNode as l, renderSlot as t, createTextVNode as o, toDisplayString as d, createCommentVNode as h, Fragment as c, renderList as m } from "vue";
|
2
|
+
const p = { class: "bb-cr-container__container" }, u = {
|
3
|
+
key: 0,
|
4
|
+
class: "bb-cr-container__loading-container"
|
5
|
+
}, g = {
|
6
|
+
key: 1,
|
7
|
+
class: "bb-cr-container__no-data-container"
|
8
|
+
}, _ = /* @__PURE__ */ b({
|
9
|
+
__name: "OptionsContainer",
|
10
|
+
props: {
|
11
|
+
direction: {},
|
12
|
+
hasErrors: { type: Boolean },
|
13
|
+
hideLabel: { type: Boolean },
|
14
|
+
loadingText: {},
|
15
|
+
loading: { type: Boolean },
|
16
|
+
noDataText: {},
|
17
|
+
options: {}
|
18
|
+
},
|
19
|
+
setup(k) {
|
20
|
+
return (a, $) => (n(), s("span", {
|
21
|
+
ref: "container",
|
22
|
+
class: r(["bb-cr-container", {
|
23
|
+
"bb-cr-container--errors": a.hasErrors,
|
24
|
+
"bb-cr-container--horizontal": a.direction === "horizontal",
|
25
|
+
"bb-cr-container--vertical": a.direction === "vertical"
|
26
|
+
}])
|
27
|
+
}, [
|
28
|
+
l("span", p, [
|
29
|
+
t(a.$slots, "prepend"),
|
30
|
+
!a.options.length && a.loading ? (n(), s("span", u, [
|
31
|
+
t(a.$slots, "loading", {}, () => [
|
32
|
+
o(d(a.loadingText), 1)
|
33
|
+
])
|
34
|
+
])) : a.options.length ? h("", !0) : (n(), s("span", g, [
|
35
|
+
t(a.$slots, "no-data", {}, () => [
|
36
|
+
o(d(a.noDataText), 1)
|
37
|
+
])
|
38
|
+
])),
|
39
|
+
(n(!0), s(c, null, m(a.options, (e, i) => (n(), s(c, {
|
40
|
+
key: (e == null ? void 0 : e.id) || i
|
41
|
+
}, [
|
42
|
+
t(a.$slots, "option:prepend", {
|
43
|
+
id: e.valueHash,
|
44
|
+
checked: !!e.selected,
|
45
|
+
disabled: !!e.disabled,
|
46
|
+
item: e.item,
|
47
|
+
text: e.text
|
48
|
+
}),
|
49
|
+
l("label", {
|
50
|
+
class: r(["bb-cr-container-option", { "bb-base-radio-selected": e.selected }])
|
51
|
+
}, [
|
52
|
+
t(a.$slots, "input", {
|
53
|
+
index: i,
|
54
|
+
option: e
|
55
|
+
}),
|
56
|
+
l("span", {
|
57
|
+
class: r({
|
58
|
+
"bb-cr-container-option__text": !0,
|
59
|
+
"bb-cr-container-option__text--hidden": a.hideLabel
|
60
|
+
})
|
61
|
+
}, [
|
62
|
+
t(a.$slots, "label", {
|
63
|
+
checked: !!e.selected,
|
64
|
+
item: e.item,
|
65
|
+
text: e.text
|
66
|
+
}, () => [
|
67
|
+
o(d(e.text), 1)
|
68
|
+
])
|
69
|
+
], 2)
|
70
|
+
], 2),
|
71
|
+
t(a.$slots, "option:append", {
|
72
|
+
id: e.valueHash,
|
73
|
+
checked: !!e.selected,
|
74
|
+
disabled: !!e.disabled,
|
75
|
+
item: e.item,
|
76
|
+
text: e.text
|
77
|
+
})
|
78
|
+
], 64))), 128)),
|
79
|
+
t(a.$slots, "append")
|
80
|
+
])
|
81
|
+
], 2));
|
82
|
+
}
|
83
|
+
});
|
2
84
|
export {
|
3
|
-
|
85
|
+
_ as default
|
4
86
|
};
|
5
87
|
//# sourceMappingURL=index207.js.map
|
package/dist/index207.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index207.js","sources":[
|
1
|
+
{"version":3,"file":"index207.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index209.js
CHANGED
@@ -1,252 +1,6 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
import { identity as be } from "./index216.js";
|
4
|
-
import { isNotNil as me } from "./index131.js";
|
5
|
-
import { last as ge } from "./index207.js";
|
6
|
-
import { sort as T } from "./index294.js";
|
7
|
-
import b from "./index200.js";
|
8
|
-
import he from "./index212.js";
|
9
|
-
const ye = ["onKeydown"], _e = { class: "bb-base-date-picker__header-container" }, ke = ["abbr"], Oe = ["id", "disabled", "tabindex"], Ce = /* @__PURE__ */ de({
|
10
|
-
__name: "BaseDatePickerInputDaySelector",
|
11
|
-
props: {
|
12
|
-
cursor: {},
|
13
|
-
current: { type: Boolean },
|
14
|
-
disabled: { type: Boolean },
|
15
|
-
firstDayOfWeek: {},
|
16
|
-
modelValue: {},
|
17
|
-
max: {},
|
18
|
-
min: {},
|
19
|
-
selectable: { type: Function },
|
20
|
-
range: { type: Boolean },
|
21
|
-
multiple: { type: Boolean },
|
22
|
-
readonly: { type: Boolean }
|
23
|
-
},
|
24
|
-
emits: ["update:modelValue", "update:cursor"],
|
25
|
-
setup(E, { emit: N }) {
|
26
|
-
const a = E, s = N, g = A(null), x = b().startOf("day"), m = _(() => {
|
27
|
-
let e = 1 / 0, r = -1 / 0, o = {};
|
28
|
-
return a.modelValue && [].concat(a.modelValue).filter(be).map((i) => b(i).startOf("day")).map((i) => i.valueOf()).forEach((i, h) => {
|
29
|
-
i < e && (e = i), i > r && (r = i), o[i] = h;
|
30
|
-
}), {
|
31
|
-
min: e,
|
32
|
-
max: r,
|
33
|
-
index: (t) => o[t.valueOf()],
|
34
|
-
selected: (t) => me(o[t.valueOf()]),
|
35
|
-
isFirstOfRange: (t) => t.valueOf() === e,
|
36
|
-
isLastOfRange: (t) => t.valueOf() === r,
|
37
|
-
isBetween: (t) => t.valueOf() > e && t.valueOf() < r
|
38
|
-
};
|
39
|
-
}), R = _(() => new Array(7).fill("").map((e, r) => b().day((r + a.firstDayOfWeek) % 7)).map((e) => ({
|
40
|
-
accessibleLabel: e.format("dddd"),
|
41
|
-
label: e.format("dd").slice(0, 1).toUpperCase(),
|
42
|
-
id: e.toISOString(),
|
43
|
-
original: e
|
44
|
-
}))), v = _(() => {
|
45
|
-
const e = a.cursor.year().toString(), r = a.cursor.month().toString();
|
46
|
-
let t = a.cursor.clone().startOf("month").clone().startOf("week"), h = a.cursor.clone().endOf("month").clone().endOf("week"), Y = b(a.cursor).startOf("day"), D = [];
|
47
|
-
for (let n = t; n.isBefore(h); n = n.add(1, "day"))
|
48
|
-
D.push(n.clone());
|
49
|
-
const Z = D.map((n) => {
|
50
|
-
const y = n.toISOString(), ee = n.week().toString();
|
51
|
-
let te = m.value.selected(n);
|
52
|
-
const B = a.range && m.value.isFirstOfRange(n), I = a.range && m.value.isLastOfRange(n), re = a.range && !B && !I && m.value.isBetween(n), ae = n.month().toString() === r && n.year().toString() === e, oe = n.isSame(x), ne = n.isSame(Y), se = d(n), ie = n.get("D").toString();
|
53
|
-
return {
|
54
|
-
buttonId: "date_" + y,
|
55
|
-
current: ne,
|
56
|
-
disabled: se,
|
57
|
-
first: B,
|
58
|
-
highlighted: ae,
|
59
|
-
id: y,
|
60
|
-
label: ie,
|
61
|
-
last: I,
|
62
|
-
middle: re,
|
63
|
-
original: n,
|
64
|
-
selected: te,
|
65
|
-
slotName: y,
|
66
|
-
today: oe,
|
67
|
-
week: ee
|
68
|
-
};
|
69
|
-
});
|
70
|
-
return pe(Z, 7);
|
71
|
-
}), d = (e) => {
|
72
|
-
let r = !0;
|
73
|
-
return a.min && r && (r = e.isSameOrAfter(b(a.min).startOf("day"))), a.max && r && (r = e.isSameOrBefore(b(a.max).startOf("day"))), typeof a.selectable == "function" && r && (r = a.selectable(e.toDate())), !r;
|
74
|
-
}, w = A("left"), K = (e, r) => {
|
75
|
-
e && r && (w.value = e.isBefore(r) ? "left" : "right");
|
76
|
-
};
|
77
|
-
le(
|
78
|
-
() => a.cursor,
|
79
|
-
(e, r) => {
|
80
|
-
K(e, r);
|
81
|
-
}
|
82
|
-
);
|
83
|
-
const V = (e) => s("update:cursor", e), l = async () => {
|
84
|
-
if (!g.value) return;
|
85
|
-
await fe();
|
86
|
-
const e = ge([
|
87
|
-
...g.value.querySelectorAll(
|
88
|
-
".bb-base-date-picker__date--current button"
|
89
|
-
)
|
90
|
-
]);
|
91
|
-
e instanceof HTMLElement && e.focus();
|
92
|
-
}, F = (e) => {
|
93
|
-
if (!a.readonly && e.target instanceof HTMLButtonElement) {
|
94
|
-
const [, r] = e.target.id.split("_"), o = b(r);
|
95
|
-
if (a.cursor.month() !== o.month()) {
|
96
|
-
V(o);
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
const t = v.value.flat().find((i) => i.id === r);
|
100
|
-
if (t.disabled) return;
|
101
|
-
V(o), H(t);
|
102
|
-
}
|
103
|
-
}, H = (e) => {
|
104
|
-
a.range ? P(e) : a.multiple ? U(e) : W(e);
|
105
|
-
}, P = (e) => {
|
106
|
-
if (!Array.isArray(a.modelValue)) return;
|
107
|
-
const r = e.original.toISOString();
|
108
|
-
if (a.modelValue.length !== 1) s("update:modelValue", [r]);
|
109
|
-
else {
|
110
|
-
const o = T([a.modelValue[0], e.original.toISOString()]);
|
111
|
-
s("update:modelValue", o);
|
112
|
-
}
|
113
|
-
}, U = (e) => {
|
114
|
-
if (Array.isArray(a.modelValue))
|
115
|
-
if (e.selected) {
|
116
|
-
const r = e.original.toISOString(), o = a.modelValue.filter((t) => t !== r);
|
117
|
-
s("update:modelValue", o);
|
118
|
-
} else {
|
119
|
-
const r = T([...a.modelValue, e.original.toISOString()]);
|
120
|
-
s("update:modelValue", r);
|
121
|
-
}
|
122
|
-
}, W = (e) => {
|
123
|
-
e.selected ? s("update:modelValue", null) : s("update:modelValue", e.original.toISOString());
|
124
|
-
}, $ = () => {
|
125
|
-
const e = a.cursor.clone().add(1, "day");
|
126
|
-
d(e) || (s("update:cursor", e), l());
|
127
|
-
}, j = () => {
|
128
|
-
const e = a.cursor.clone().subtract(1, "day");
|
129
|
-
d(e) || (s("update:cursor", e), l());
|
130
|
-
}, q = () => {
|
131
|
-
const e = a.cursor.clone().subtract(1, "week");
|
132
|
-
d(e) || (s("update:cursor", e), l());
|
133
|
-
}, z = () => {
|
134
|
-
const e = a.cursor.clone().add(1, "week");
|
135
|
-
d(e) || (s("update:cursor", e), l());
|
136
|
-
}, G = () => {
|
137
|
-
const e = a.cursor.clone().endOf("week");
|
138
|
-
d(e) || (s("update:cursor", e), l());
|
139
|
-
}, J = () => {
|
140
|
-
const e = a.cursor.clone().startOf("week");
|
141
|
-
d(e) || (s("update:cursor", e), l());
|
142
|
-
}, Q = (e) => {
|
143
|
-
if (e.shiftKey) {
|
144
|
-
const r = a.cursor.clone().subtract(1, "year");
|
145
|
-
if (d(r)) return;
|
146
|
-
s("update:cursor", r);
|
147
|
-
} else {
|
148
|
-
const r = a.cursor.clone().subtract(1, "month");
|
149
|
-
if (d(r)) return;
|
150
|
-
s("update:cursor", r);
|
151
|
-
}
|
152
|
-
l();
|
153
|
-
}, X = (e) => {
|
154
|
-
if (e.shiftKey) {
|
155
|
-
const r = a.cursor.clone().add(1, "year");
|
156
|
-
if (d(r)) return;
|
157
|
-
s("update:cursor", r);
|
158
|
-
} else {
|
159
|
-
const r = a.cursor.clone().add(1, "month");
|
160
|
-
if (d(r)) return;
|
161
|
-
s("update:cursor", r);
|
162
|
-
}
|
163
|
-
l();
|
164
|
-
};
|
165
|
-
return (e, r) => (c(), u("div", {
|
166
|
-
ref_key: "calendar",
|
167
|
-
ref: g,
|
168
|
-
class: k(["bb-base-date-picker__days-selector", { "bb-base-date-picker__days-selector--hidden": !e.current }]),
|
169
|
-
onKeydown: [
|
170
|
-
f(p(z, ["prevent"]), ["down"]),
|
171
|
-
f(p(G, ["prevent"]), ["end"]),
|
172
|
-
f(p(J, ["prevent"]), ["home"]),
|
173
|
-
f(p(j, ["prevent"]), ["left"]),
|
174
|
-
f(p(X, ["prevent"]), ["page-down"]),
|
175
|
-
f(p(Q, ["prevent"]), ["page-up"]),
|
176
|
-
f(p($, ["prevent"]), ["right"]),
|
177
|
-
f(p(q, ["prevent"]), ["up"])
|
178
|
-
]
|
179
|
-
}, [
|
180
|
-
ce(he, {
|
181
|
-
direction: w.value,
|
182
|
-
gap: 30
|
183
|
-
}, {
|
184
|
-
default: ue(() => [
|
185
|
-
(c(), u("div", {
|
186
|
-
key: e.cursor.month().toString(),
|
187
|
-
class: "bb-base-date-picker__month"
|
188
|
-
}, [
|
189
|
-
M("div", _e, [
|
190
|
-
(c(!0), u(O, null, S(R.value, (o) => (c(), u("div", {
|
191
|
-
key: o.id,
|
192
|
-
abbr: o.accessibleLabel,
|
193
|
-
class: "bb-base-date-picker__header-cell"
|
194
|
-
}, C(o.label), 9, ke))), 128))
|
195
|
-
]),
|
196
|
-
(c(!0), u(O, null, S(v.value, (o) => (c(), u("div", {
|
197
|
-
key: o[0].id,
|
198
|
-
class: "bb-base-date-picker__week"
|
199
|
-
}, [
|
200
|
-
(c(!0), u(O, null, S(o, (t) => (c(), u("div", {
|
201
|
-
key: t.id,
|
202
|
-
class: k({
|
203
|
-
"bb-base-date-picker__date--current": t.current,
|
204
|
-
"bb-base-date-picker__date--disabled": e.disabled || t.disabled,
|
205
|
-
"bb-base-date-picker__date--first": t.first,
|
206
|
-
"bb-base-date-picker__date--highlighted": t.highlighted,
|
207
|
-
"bb-base-date-picker__date--last": t.last,
|
208
|
-
"bb-base-date-picker__date--middle": t.middle,
|
209
|
-
"bb-base-date-picker__date--selected": t.selected,
|
210
|
-
"bb-base-date-picker__date--today": t.today,
|
211
|
-
"bb-base-date-picker__date": !0
|
212
|
-
})
|
213
|
-
}, [
|
214
|
-
M("button", {
|
215
|
-
id: t.buttonId,
|
216
|
-
class: k("bb-base-date-picker__date-button"),
|
217
|
-
disabled: e.disabled || t.disabled,
|
218
|
-
tabindex: Number(t.current) - 1,
|
219
|
-
type: "button",
|
220
|
-
onClick: F
|
221
|
-
}, C(t.label), 9, Oe),
|
222
|
-
L(e.$slots, "day", {
|
223
|
-
first: t.first,
|
224
|
-
highlighted: t.highlighted,
|
225
|
-
item: t.original,
|
226
|
-
label: t.label,
|
227
|
-
last: t.last,
|
228
|
-
middle: t.middle,
|
229
|
-
selected: t.selected
|
230
|
-
}),
|
231
|
-
L(e.$slots, t.slotName, {
|
232
|
-
first: t.first,
|
233
|
-
highlighted: t.highlighted,
|
234
|
-
item: t.original,
|
235
|
-
label: t.label,
|
236
|
-
last: t.last,
|
237
|
-
middle: t.middle,
|
238
|
-
selected: t.selected
|
239
|
-
})
|
240
|
-
], 2))), 128))
|
241
|
-
]))), 128))
|
242
|
-
]))
|
243
|
-
]),
|
244
|
-
_: 3
|
245
|
-
}, 8, ["direction"])
|
246
|
-
], 42, ye));
|
247
|
-
}
|
248
|
-
});
|
1
|
+
import t from "./index263.js";
|
2
|
+
const r = t;
|
249
3
|
export {
|
250
|
-
|
4
|
+
r as throttle
|
251
5
|
};
|
252
6
|
//# sourceMappingURL=index209.js.map
|
package/dist/index209.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index209.js","sources":["../src/components/BaseDatePicker/BaseDatePickerInputDaySelector.vue"],"sourcesContent":["<template>\n\t<div\n\t\tref=\"calendar\"\n\t\tclass=\"bb-base-date-picker__days-selector\"\n\t\t:class=\"{ 'bb-base-date-picker__days-selector--hidden': !current }\"\n\t\t@keydown.prevent.down=\"onArrowDown\"\n\t\t@keydown.prevent.end=\"onEnd\"\n\t\t@keydown.prevent.home=\"onHome\"\n\t\t@keydown.prevent.left=\"onArrowLeft\"\n\t\t@keydown.prevent.page-down=\"onPageDown\"\n\t\t@keydown.prevent.page-up=\"onPageUp\"\n\t\t@keydown.prevent.right=\"onArrowRight\"\n\t\t@keydown.prevent.up=\"onArrowUp\"\n\t>\n\t\t<SlideTransition :direction=\"direction\" :gap=\"30\">\n\t\t\t<div :key=\"cursor.month().toString()\" class=\"bb-base-date-picker__month\">\n\t\t\t\t<div class=\"bb-base-date-picker__header-container\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tv-for=\"header in mappedHeaders\"\n\t\t\t\t\t\t:key=\"header.id\"\n\t\t\t\t\t\t:abbr=\"header.accessibleLabel\"\n\t\t\t\t\t\tclass=\"bb-base-date-picker__header-cell\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{{ header.label }}\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tv-for=\"week in dates\"\n\t\t\t\t\t:key=\"week[0].id\"\n\t\t\t\t\tclass=\"bb-base-date-picker__week\"\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\tv-for=\"cell in week\"\n\t\t\t\t\t\t:key=\"cell.id\"\n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'bb-base-date-picker__date--current': cell.current,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--disabled': disabled || cell.disabled,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--first': cell.first,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--highlighted': cell.highlighted,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--last': cell.last,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--middle': cell.middle,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--selected': cell.selected,\n\t\t\t\t\t\t\t'bb-base-date-picker__date--today': cell.today,\n\t\t\t\t\t\t\t'bb-base-date-picker__date': true,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t:id=\"cell.buttonId\"\n\t\t\t\t\t\t\t:class=\"'bb-base-date-picker__date-button'\"\n\t\t\t\t\t\t\t:disabled=\"disabled || cell.disabled\"\n\t\t\t\t\t\t\t:tabindex=\"Number(cell.current) - 1\"\n\t\t\t\t\t\t\t:type=\"'button'\"\n\t\t\t\t\t\t\t@click=\"onButtonClick\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{{ cell.label }}\n\t\t\t\t\t\t</button>\n\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t:first=\"cell.first\"\n\t\t\t\t\t\t\t:highlighted=\"cell.highlighted\"\n\t\t\t\t\t\t\t:item=\"cell.original\"\n\t\t\t\t\t\t\t:label=\"cell.label\"\n\t\t\t\t\t\t\t:last=\"cell.last\"\n\t\t\t\t\t\t\t:middle=\"cell.middle\"\n\t\t\t\t\t\t\t:name=\"'day'\"\n\t\t\t\t\t\t\t:selected=\"cell.selected\"\n\t\t\t\t\t\t></slot>\n\t\t\t\t\t\t<slot\n\t\t\t\t\t\t\t:first=\"cell.first\"\n\t\t\t\t\t\t\t:highlighted=\"cell.highlighted\"\n\t\t\t\t\t\t\t:item=\"cell.original\"\n\t\t\t\t\t\t\t:label=\"cell.label\"\n\t\t\t\t\t\t\t:last=\"cell.last\"\n\t\t\t\t\t\t\t:middle=\"cell.middle\"\n\t\t\t\t\t\t\t:name=\"cell.slotName\"\n\t\t\t\t\t\t\t:selected=\"cell.selected\"\n\t\t\t\t\t\t></slot>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</SlideTransition>\n\t</div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { chunk } from '@/utilities/functions/chunk';\nimport { identity } from '@/utilities/functions/identity';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { last } from '@/utilities/functions/last';\nimport { nextTick } from 'vue';\nimport { ref } from 'vue';\nimport { sort } from '@/utilities/functions/sort';\nimport { watch } from 'vue';\nimport dayjs from 'dayjs';\nimport SlideTransition from '../Transitions/Slide.vue';\nimport type { Dayjs } from 'dayjs';\n\ntype Props = {\n\tcursor: Dayjs;\n\tcurrent: boolean;\n\tdisabled: boolean;\n\tfirstDayOfWeek: number;\n\t/**\n\t * Used by v-model. Can be null, a single string, or an array of strings based on whether a range or single date is needed\n\t */\n\tmodelValue: string | string[] | null;\n\tmax?: Date | string | number;\n\tmin?: Date | string | number;\n\tselectable?: (date: Date) => boolean;\n\trange?: boolean;\n\tmultiple?: boolean;\n\treadonly?: boolean;\n};\nconst props = defineProps<Props>();\n\nconst emit = defineEmits<{\n\t(event: 'update:modelValue', value: any): void;\n\t(event: 'update:cursor', value: Dayjs): void;\n}>();\n\nconst calendar = ref<HTMLElement | null>(null);\n\nconst today = dayjs().startOf('day');\n\nconst modelValueMetadata = computed(() => {\n\tlet min = Infinity;\n\tlet max = -Infinity;\n\tlet selected: { [key: number]: number } = {};\n\n\tif (props.modelValue) {\n\t\tconst arr = ([] as (string | Date)[])\n\t\t\t.concat(props.modelValue)\n\t\t\t.filter(identity)\n\t\t\t.map((value) => dayjs(value).startOf('day'))\n\t\t\t.map((date) => date.valueOf());\n\t\tarr.forEach((item, index) => {\n\t\t\tif (item < min) min = item;\n\t\t\tif (item > max) max = item;\n\t\t\tselected[item] = index;\n\t\t});\n\t}\n\treturn {\n\t\tmin,\n\t\tmax,\n\t\tindex: (date: Dayjs) => selected[date.valueOf()],\n\t\tselected: (date: Dayjs) => isNotNil(selected[date.valueOf()]),\n\t\tisFirstOfRange: (date: Dayjs) => date.valueOf() === min,\n\t\tisLastOfRange: (date: Dayjs) => date.valueOf() === max,\n\t\tisBetween: (date: Dayjs) => date.valueOf() > min && date.valueOf() < max,\n\t};\n});\n\nconst mappedHeaders = computed(() => {\n\treturn (\n\t\tnew Array(7)\n\t\t\t.fill('')\n\t\t\t// Sort days based on first day of the week\n\t\t\t.map((_, index) => dayjs().day((index + props.firstDayOfWeek) % 7))\n\t\t\t.map((day) => {\n\t\t\t\treturn {\n\t\t\t\t\taccessibleLabel: day.format('dddd'),\n\t\t\t\t\tlabel: day.format('dd').slice(0, 1).toUpperCase(),\n\t\t\t\t\tid: day.toISOString(),\n\t\t\t\t\toriginal: day,\n\t\t\t\t};\n\t\t\t})\n\t);\n});\n\ntype Cell = {\n\tbuttonId: string;\n\tcurrent: boolean;\n\tdisabled: boolean;\n\tfirst: boolean;\n\thighlighted: boolean;\n\tid: string;\n\tlabel: string;\n\tlast: boolean;\n\tmiddle: boolean;\n\toriginal: Dayjs;\n\tselected: boolean;\n\tslotName: string;\n\tweek: string;\n\ttoday: boolean;\n};\n\nconst dates = computed<Cell[][]>(() => {\n\tconst year = props.cursor.year().toString();\n\tconst month = props.cursor.month().toString();\n\tlet startOfMonth = props.cursor.clone().startOf('month');\n\tlet firstValueToDisplay = startOfMonth.clone().startOf('week');\n\tlet endOfMonth = props.cursor.clone().endOf('month');\n\tlet lastValueToDisplay = endOfMonth.clone().endOf('week');\n\tlet currentAtMidnight = dayjs(props.cursor).startOf('day');\n\tlet datesInPage: Dayjs[] = [];\n\tfor (\n\t\tlet index = firstValueToDisplay;\n\t\tindex.isBefore(lastValueToDisplay);\n\t\tindex = index.add(1, 'day')\n\t) {\n\t\tdatesInPage.push(index.clone());\n\t}\n\tconst mapped = datesInPage.map<Cell>((date) => {\n\t\tconst id = date.toISOString();\n\t\tconst week = date.week().toString();\n\t\tlet selected = modelValueMetadata.value.selected(date);\n\n\t\tconst first = props.range && modelValueMetadata.value.isFirstOfRange(date);\n\t\tconst last = props.range && modelValueMetadata.value.isLastOfRange(date);\n\t\tconst middle =\n\t\t\tprops.range &&\n\t\t\t!first &&\n\t\t\t!last &&\n\t\t\tmodelValueMetadata.value.isBetween(date);\n\t\tconst highlighted =\n\t\t\tdate.month().toString() === month && date.year().toString() === year;\n\t\tconst isToday = date.isSame(today);\n\t\tconst current = date.isSame(currentAtMidnight);\n\t\tconst disabled = isDateDisabled(date);\n\t\tconst label = date.get('D').toString();\n\t\tconst buttonId = 'date_' + id;\n\n\t\treturn {\n\t\t\tbuttonId,\n\t\t\tcurrent,\n\t\t\tdisabled,\n\t\t\tfirst,\n\t\t\thighlighted,\n\t\t\tid,\n\t\t\tlabel,\n\t\t\tlast,\n\t\t\tmiddle,\n\t\t\toriginal: date,\n\t\t\tselected,\n\t\t\tslotName: id,\n\t\t\ttoday: isToday,\n\t\t\tweek,\n\t\t};\n\t});\n\treturn chunk(mapped, 7);\n});\n\nconst isDateDisabled = (date: Dayjs) => {\n\tlet passing = true;\n\tif (props.min) {\n\t\tpassing &&= date.isSameOrAfter(dayjs(props.min).startOf('day'));\n\t}\n\tif (props.max) {\n\t\tpassing &&= date.isSameOrBefore(dayjs(props.max).startOf('day'));\n\t}\n\tif (typeof props.selectable === 'function') {\n\t\tpassing &&= props.selectable(date.toDate());\n\t}\n\treturn !passing;\n};\n\nconst direction = ref<'left' | 'right'>('left');\nconst setSlideDirection = (\n\tcurrent: Dayjs | undefined,\n\tprevious: Dayjs | undefined\n) => {\n\tif (current && previous) {\n\t\tdirection.value = current.isBefore(previous) ? 'left' : 'right';\n\t}\n};\n\nwatch(\n\t() => props.cursor,\n\t(current, previous) => {\n\t\tsetSlideDirection(current, previous);\n\t}\n);\n\nconst updateCursor = (date: Dayjs) => emit('update:cursor', date);\n\nconst focusOnCursor = async () => {\n\tif (!calendar.value) return;\n\tawait nextTick();\n\tconst el = last([\n\t\t...calendar.value.querySelectorAll(\n\t\t\t'.bb-base-date-picker__date--current button'\n\t\t),\n\t]);\n\tif (el instanceof HTMLElement) {\n\t\tel.focus();\n\t}\n};\n\nconst onButtonClick = (event: MouseEvent) => {\n\tif (props.readonly) return;\n\tif (event.target instanceof HTMLButtonElement) {\n\t\tconst [, id] = event.target.id.split('_');\n\t\tconst d = dayjs(id);\n\t\tif (props.cursor.month() !== d.month()) {\n\t\t\tupdateCursor(d);\n\t\t\treturn;\n\t\t}\n\t\tconst date = dates.value.flat().find((el) => el.id === id)!;\n\t\tif (date.disabled) return;\n\t\tupdateCursor(d);\n\t\tonDateSelected(date);\n\t}\n};\n\nconst onDateSelected = (date: Cell) => {\n\tif (props.range) onDateSelectedRange(date);\n\telse if (props.multiple) onDateSelectedMultiple(date);\n\telse onDateSelectedSingle(date);\n};\n\nconst onDateSelectedRange = (date: Cell) => {\n\tif (!Array.isArray(props.modelValue)) return;\n\tconst value = date.original.toISOString();\n\tif (props.modelValue.length !== 1) emit('update:modelValue', [value]);\n\telse {\n\t\tconst arr = sort([props.modelValue[0], date.original.toISOString()]);\n\t\temit('update:modelValue', arr);\n\t}\n};\nconst onDateSelectedMultiple = (date: Cell) => {\n\tif (!Array.isArray(props.modelValue)) return;\n\tif (date.selected) {\n\t\tconst asString = date.original.toISOString();\n\t\tconst valueToEmit = props.modelValue.filter((el) => el !== asString);\n\t\temit('update:modelValue', valueToEmit);\n\t} else {\n\t\tconst arr = sort([...props.modelValue, date.original.toISOString()]);\n\t\temit('update:modelValue', arr);\n\t}\n};\nconst onDateSelectedSingle = (date: Cell) => {\n\tif (date.selected) emit('update:modelValue', null);\n\telse emit('update:modelValue', date.original.toISOString());\n};\n\nconst onArrowRight = () => {\n\tconst date = props.cursor.clone().add(1, 'day');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onArrowLeft = () => {\n\tconst date = props.cursor.clone().subtract(1, 'day');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onArrowUp = () => {\n\tconst date = props.cursor.clone().subtract(1, 'week');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onArrowDown = () => {\n\tconst date = props.cursor.clone().add(1, 'week');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onEnd = () => {\n\tconst date = props.cursor.clone().endOf('week');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onHome = () => {\n\tconst date = props.cursor.clone().startOf('week');\n\tif (isDateDisabled(date)) return;\n\temit('update:cursor', date);\n\tfocusOnCursor();\n};\nconst onPageUp = (event: KeyboardEvent) => {\n\tif (event.shiftKey) {\n\t\tconst date = props.cursor.clone().subtract(1, 'year');\n\t\tif (isDateDisabled(date)) return;\n\t\temit('update:cursor', date);\n\t} else {\n\t\tconst date = props.cursor.clone().subtract(1, 'month');\n\t\tif (isDateDisabled(date)) return;\n\t\temit('update:cursor', date);\n\t}\n\tfocusOnCursor();\n};\nconst onPageDown = (event: KeyboardEvent) => {\n\tif (event.shiftKey) {\n\t\tconst date = props.cursor.clone().add(1, 'year');\n\t\tif (isDateDisabled(date)) return;\n\t\temit('update:cursor', date);\n\t} else {\n\t\tconst date = props.cursor.clone().add(1, 'month');\n\t\tif (isDateDisabled(date)) return;\n\t\temit('update:cursor', date);\n\t}\n\tfocusOnCursor();\n};\n</script>\n\n<style lang=\"postcss\"></style>\n"],"names":["props","__props","emit","__emit","calendar","ref","today","dayjs","modelValueMetadata","computed","min","max","selected","identity","value","date","item","index","isNotNil","mappedHeaders","_","day","dates","year","month","firstValueToDisplay","lastValueToDisplay","currentAtMidnight","datesInPage","mapped","id","week","first","last","middle","highlighted","isToday","current","disabled","isDateDisabled","label","chunk","passing","direction","setSlideDirection","previous","watch","updateCursor","focusOnCursor","nextTick","el","onButtonClick","event","d","onDateSelected","onDateSelectedRange","onDateSelectedMultiple","arr","sort","asString","valueToEmit","onDateSelectedSingle","onArrowRight","onArrowLeft","onArrowUp","onArrowDown","onEnd","onHome","onPageUp","onPageDown"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiHA,UAAMA,IAAQC,GAERC,IAAOC,GAKPC,IAAWC,EAAwB,IAAI,GAEvCC,IAAQ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,SAAS,GAAG,OAAO;AACjD,YAAAuC,EAAexB,CAAI,EAAG;AAC1B,QAAAb,EAAK,iBAAiBa,CAAI;AAAA,MAC3B;AACc,MAAAiC;IAAA,GAETqB,IAAa,CAACjB,MAAyB;AAC5C,UAAIA,EAAM,UAAU;AACnB,cAAMrC,IAAOf,EAAM,OAAO,MAAQ,EAAA,IAAI,GAAG,MAAM;AAC3C,YAAAuC,EAAexB,CAAI,EAAG;AAC1B,QAAAb,EAAK,iBAAiBa,CAAI;AAAA,MAAA,OACpB;AACN,cAAMA,IAAOf,EAAM,OAAO,MAAQ,EAAA,IAAI,GAAG,OAAO;AAC5C,YAAAuC,EAAexB,CAAI,EAAG;AAC1B,QAAAb,EAAK,iBAAiBa,CAAI;AAAA,MAC3B;AACc,MAAAiC;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
1
|
+
{"version":3,"file":"index209.js","sources":["../src/utilities/functions/throttle.ts"],"sourcesContent":["import t from 'lodash.throttle';\n\nexport const throttle = t;\n"],"names":["throttle"],"mappings":";AAEO,MAAMA,IAAW;"}
|