@kiva/kv-components 3.106.0 → 3.107.0
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/.eslintrc.cjs +1 -0
- package/CHANGELOG.md +11 -0
- package/dist/Alea.cjs +87 -0
- package/dist/Alea.js +63 -0
- package/dist/attrs.cjs +50 -0
- package/dist/attrs.js +26 -0
- package/dist/carousels.cjs +184 -0
- package/dist/carousels.js +147 -0
- package/dist/chunk-HV3AUBFT.js +15 -0
- package/dist/expander.cjs +78 -0
- package/dist/expander.js +53 -0
- package/dist/imageUtils.cjs +54 -0
- package/dist/imageUtils.js +29 -0
- package/dist/loanCard.cjs +222 -0
- package/dist/loanCard.js +200 -0
- package/dist/loanUtils.cjs +170 -0
- package/dist/loanUtils.js +128 -0
- package/dist/mapUtils.cjs +276 -0
- package/dist/mapUtils.js +248 -0
- package/dist/printing.cjs +42 -0
- package/dist/printing.js +17 -0
- package/dist/scrollLock.cjs +54 -0
- package/dist/scrollLock.js +27 -0
- package/dist/throttle.cjs +38 -0
- package/dist/throttle.js +6 -0
- package/dist/touchEvents.cjs +47 -0
- package/dist/touchEvents.js +21 -0
- package/dist/treemap.cjs +133 -0
- package/dist/treemap.js +109 -0
- package/package.json +12 -4
- package/vue/KvVerticalCarousel.vue +1 -1
package/dist/expander.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// utils/expander.js
|
|
2
|
+
function setInitialStyle(el, { property, delay, easing }) {
|
|
3
|
+
el.style.overflow = "hidden";
|
|
4
|
+
el.style.transition = `${property} ${delay}ms ${easing}`;
|
|
5
|
+
}
|
|
6
|
+
function unsetStyles(el, { property }) {
|
|
7
|
+
el.style[property] = null;
|
|
8
|
+
el.style.overflow = null;
|
|
9
|
+
el.style.transition = null;
|
|
10
|
+
}
|
|
11
|
+
function expand(el, {
|
|
12
|
+
easing = "ease",
|
|
13
|
+
delay = 500,
|
|
14
|
+
done = () => {
|
|
15
|
+
},
|
|
16
|
+
from = 0,
|
|
17
|
+
property = "height"
|
|
18
|
+
}) {
|
|
19
|
+
setInitialStyle(el, { property, delay, easing });
|
|
20
|
+
el.style[property] = "auto";
|
|
21
|
+
el.style.display = null;
|
|
22
|
+
const propValue = window.getComputedStyle(el).getPropertyValue(property);
|
|
23
|
+
el.style[property] = from;
|
|
24
|
+
el.addEventListener("transitionend", function listener() {
|
|
25
|
+
unsetStyles(el, { property });
|
|
26
|
+
done();
|
|
27
|
+
el.removeEventListener("transitionend", listener, true);
|
|
28
|
+
}, true);
|
|
29
|
+
void el.offsetWidth;
|
|
30
|
+
el.style[property] = propValue;
|
|
31
|
+
}
|
|
32
|
+
function collapse(el, {
|
|
33
|
+
easing = "ease",
|
|
34
|
+
delay = 500,
|
|
35
|
+
done = () => {
|
|
36
|
+
},
|
|
37
|
+
to = 0,
|
|
38
|
+
property = "height"
|
|
39
|
+
}) {
|
|
40
|
+
setInitialStyle(el, { property, delay, easing });
|
|
41
|
+
el.style[property] = window.getComputedStyle(el).getPropertyValue(property);
|
|
42
|
+
el.addEventListener("transitionend", function listener() {
|
|
43
|
+
unsetStyles(el, { property });
|
|
44
|
+
done();
|
|
45
|
+
el.removeEventListener("transitionend", listener, true);
|
|
46
|
+
}, true);
|
|
47
|
+
void el.offsetWidth;
|
|
48
|
+
el.style[property] = to;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
collapse,
|
|
52
|
+
expand
|
|
53
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// utils/imageUtils.js
|
|
20
|
+
var imageUtils_exports = {};
|
|
21
|
+
__export(imageUtils_exports, {
|
|
22
|
+
isLegacyPlaceholderAvatar: () => isLegacyPlaceholderAvatar,
|
|
23
|
+
randomizedUserAvatarClass: () => randomizedUserAvatarClass
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(imageUtils_exports);
|
|
26
|
+
function isLegacyPlaceholderAvatar(filename) {
|
|
27
|
+
if (!filename) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
let filenameCleaned = filename.toString();
|
|
31
|
+
if (filenameCleaned.includes(".")) {
|
|
32
|
+
[filenameCleaned] = filenameCleaned.split(".");
|
|
33
|
+
}
|
|
34
|
+
const defaultProfileIds = ["726677", "315726", "4d844ac2c0b77a8a522741b908ea5c32"];
|
|
35
|
+
return defaultProfileIds.includes(filenameCleaned);
|
|
36
|
+
}
|
|
37
|
+
function randomizedUserAvatarClass() {
|
|
38
|
+
const userCardStyleOptions = [
|
|
39
|
+
{ color: "tw-text-action", bg: "tw-bg-brand-100" },
|
|
40
|
+
{ color: "tw-text-black", bg: "tw-bg-brand-100" },
|
|
41
|
+
{ color: "tw-text-white", bg: "tw-bg-action" },
|
|
42
|
+
{ color: "tw-text-brand-100", bg: "tw-bg-action" },
|
|
43
|
+
{ color: "tw-text-primary-inverse", bg: "tw-bg-action" },
|
|
44
|
+
{ color: "tw-text-white", bg: "tw-bg-black" },
|
|
45
|
+
{ color: "tw-text-action", bg: "tw-bg-black" }
|
|
46
|
+
];
|
|
47
|
+
const randomStyle = userCardStyleOptions[Math.floor(Math.random() * userCardStyleOptions.length)];
|
|
48
|
+
return `${randomStyle.color} ${randomStyle.bg}`;
|
|
49
|
+
}
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
isLegacyPlaceholderAvatar,
|
|
53
|
+
randomizedUserAvatarClass
|
|
54
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// utils/imageUtils.js
|
|
2
|
+
function isLegacyPlaceholderAvatar(filename) {
|
|
3
|
+
if (!filename) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
let filenameCleaned = filename.toString();
|
|
7
|
+
if (filenameCleaned.includes(".")) {
|
|
8
|
+
[filenameCleaned] = filenameCleaned.split(".");
|
|
9
|
+
}
|
|
10
|
+
const defaultProfileIds = ["726677", "315726", "4d844ac2c0b77a8a522741b908ea5c32"];
|
|
11
|
+
return defaultProfileIds.includes(filenameCleaned);
|
|
12
|
+
}
|
|
13
|
+
function randomizedUserAvatarClass() {
|
|
14
|
+
const userCardStyleOptions = [
|
|
15
|
+
{ color: "tw-text-action", bg: "tw-bg-brand-100" },
|
|
16
|
+
{ color: "tw-text-black", bg: "tw-bg-brand-100" },
|
|
17
|
+
{ color: "tw-text-white", bg: "tw-bg-action" },
|
|
18
|
+
{ color: "tw-text-brand-100", bg: "tw-bg-action" },
|
|
19
|
+
{ color: "tw-text-primary-inverse", bg: "tw-bg-action" },
|
|
20
|
+
{ color: "tw-text-white", bg: "tw-bg-black" },
|
|
21
|
+
{ color: "tw-text-action", bg: "tw-bg-black" }
|
|
22
|
+
];
|
|
23
|
+
const randomStyle = userCardStyleOptions[Math.floor(Math.random() * userCardStyleOptions.length)];
|
|
24
|
+
return `${randomStyle.color} ${randomStyle.bg}`;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
isLegacyPlaceholderAvatar,
|
|
28
|
+
randomizedUserAvatarClass
|
|
29
|
+
};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// utils/loanCard.js
|
|
20
|
+
var loanCard_exports = {};
|
|
21
|
+
__export(loanCard_exports, {
|
|
22
|
+
loanCardComputedProperties: () => loanCardComputedProperties,
|
|
23
|
+
loanCardMethods: () => loanCardMethods
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(loanCard_exports);
|
|
26
|
+
var import_vue_demi = require("vue-demi");
|
|
27
|
+
var import_js = require("@mdi/js");
|
|
28
|
+
var LSE_LOAN_KEY = "N/A";
|
|
29
|
+
var ECO_FRIENDLY_KEY = "ECO-FRIENDLY";
|
|
30
|
+
var SUSTAINABLE_AG_KEY = "SUSTAINABLE AG";
|
|
31
|
+
var SINGLE_PARENT_KEY = "SINGLE PARENT";
|
|
32
|
+
var REFUGEE_KEY = "REFUGEES/DISPLACED";
|
|
33
|
+
var findCalloutData = (tags, tagName) => (tags == null ? void 0 : tags.find((t) => t.name.replace("#", "").toUpperCase() === tagName.toUpperCase())) ?? {};
|
|
34
|
+
function loanCardComputedProperties(props, hideUnitedStatesText = false) {
|
|
35
|
+
const {
|
|
36
|
+
externalLinks,
|
|
37
|
+
customLoanDetails,
|
|
38
|
+
loanId,
|
|
39
|
+
loan,
|
|
40
|
+
categoryPageName,
|
|
41
|
+
customCallouts
|
|
42
|
+
} = (0, import_vue_demi.toRefs)(props);
|
|
43
|
+
const tag = (0, import_vue_demi.computed)(() => externalLinks.value ? "a" : "router-link");
|
|
44
|
+
const readMorePath = (0, import_vue_demi.computed)(() => customLoanDetails.value ? "" : `/lend/${loanId.value}`);
|
|
45
|
+
const isLoading = (0, import_vue_demi.computed)(() => !loanId.value || !loan.value);
|
|
46
|
+
const borrowerName = (0, import_vue_demi.computed)(() => {
|
|
47
|
+
var _a;
|
|
48
|
+
return ((_a = loan.value) == null ? void 0 : _a.name) || "";
|
|
49
|
+
});
|
|
50
|
+
const countryName = (0, import_vue_demi.computed)(() => {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.name) || "";
|
|
53
|
+
});
|
|
54
|
+
const countryCode = (0, import_vue_demi.computed)(() => {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.isoCode) || "";
|
|
57
|
+
});
|
|
58
|
+
const city = (0, import_vue_demi.computed)(() => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.city) || "";
|
|
61
|
+
});
|
|
62
|
+
const state = (0, import_vue_demi.computed)(() => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.state) || "";
|
|
65
|
+
});
|
|
66
|
+
const distributionModel = (0, import_vue_demi.computed)(() => {
|
|
67
|
+
var _a;
|
|
68
|
+
return ((_a = loan.value) == null ? void 0 : _a.distributionModel) || "";
|
|
69
|
+
});
|
|
70
|
+
const imageHash = (0, import_vue_demi.computed)(() => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.image) == null ? void 0 : _b.hash) ?? "";
|
|
73
|
+
});
|
|
74
|
+
const hasProgressData = (0, import_vue_demi.computed)(() => {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return typeof ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) !== "undefined" && typeof ((_b = loan.value) == null ? void 0 : _b.fundraisingPercent) !== "undefined";
|
|
77
|
+
});
|
|
78
|
+
const allDataLoaded = (0, import_vue_demi.computed)(() => !isLoading.value && hasProgressData.value);
|
|
79
|
+
const fundraisingPercent = (0, import_vue_demi.computed)(() => {
|
|
80
|
+
var _a;
|
|
81
|
+
return ((_a = loan.value) == null ? void 0 : _a.fundraisingPercent) ?? 0;
|
|
82
|
+
});
|
|
83
|
+
const unreservedAmount = (0, import_vue_demi.computed)(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
const stringAmount = ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) ?? "0";
|
|
86
|
+
return Number(stringAmount);
|
|
87
|
+
});
|
|
88
|
+
const formattedLocation = (0, import_vue_demi.computed)(() => {
|
|
89
|
+
if (distributionModel.value === "direct") {
|
|
90
|
+
const countryText = hideUnitedStatesText && countryName.value.toLowerCase() === "united states" ? "" : `, ${countryName.value}`;
|
|
91
|
+
return `${city.value}, ${state.value}${countryText}`;
|
|
92
|
+
}
|
|
93
|
+
if (countryName.value === "Puerto Rico") {
|
|
94
|
+
return `${city.value}, PR`;
|
|
95
|
+
}
|
|
96
|
+
return countryName.value;
|
|
97
|
+
});
|
|
98
|
+
const loanUse = (0, import_vue_demi.computed)(() => {
|
|
99
|
+
var _a;
|
|
100
|
+
return ((_a = loan.value) == null ? void 0 : _a.use) ?? "";
|
|
101
|
+
});
|
|
102
|
+
const loanStatus = (0, import_vue_demi.computed)(() => {
|
|
103
|
+
var _a;
|
|
104
|
+
return ((_a = loan.value) == null ? void 0 : _a.status) ?? "";
|
|
105
|
+
});
|
|
106
|
+
const loanAmount = (0, import_vue_demi.computed)(() => {
|
|
107
|
+
var _a;
|
|
108
|
+
return ((_a = loan.value) == null ? void 0 : _a.loanAmount) ?? "0";
|
|
109
|
+
});
|
|
110
|
+
const loanBorrowerCount = (0, import_vue_demi.computed)(() => {
|
|
111
|
+
var _a;
|
|
112
|
+
return ((_a = loan.value) == null ? void 0 : _a.borrowerCount) ?? 0;
|
|
113
|
+
});
|
|
114
|
+
const loanCallouts = (0, import_vue_demi.computed)(() => {
|
|
115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
116
|
+
const callouts = [];
|
|
117
|
+
const activityName = ((_b = (_a = loan.value) == null ? void 0 : _a.activity) == null ? void 0 : _b.name) ?? "";
|
|
118
|
+
const activityId = ((_d = (_c = loan.value) == null ? void 0 : _c.activity) == null ? void 0 : _d.id) ?? null;
|
|
119
|
+
const sectorName = ((_f = (_e = loan.value) == null ? void 0 : _e.sector) == null ? void 0 : _f.name) ?? "";
|
|
120
|
+
const sectorId = ((_h = (_g = loan.value) == null ? void 0 : _g.sector) == null ? void 0 : _h.id) ?? null;
|
|
121
|
+
const tags = ((_j = (_i = loan.value) == null ? void 0 : _i.tags) == null ? void 0 : _j.filter((loantag) => loantag.charAt(0) === "#").map((loantag) => loantag.substring(1))) ?? [];
|
|
122
|
+
const themes = ((_k = loan.value) == null ? void 0 : _k.themes) ?? [];
|
|
123
|
+
const categories = {
|
|
124
|
+
ecoFriendly: !!tags.filter((t) => t.toUpperCase() === ECO_FRIENDLY_KEY || t.toUpperCase() === SUSTAINABLE_AG_KEY).length,
|
|
125
|
+
refugeesIdps: !!themes.filter((t) => t.toUpperCase() === REFUGEE_KEY).length,
|
|
126
|
+
singleParents: !!tags.filter((t) => t.toUpperCase() === SINGLE_PARENT_KEY).length
|
|
127
|
+
};
|
|
128
|
+
const isLseLoan = (_m = (_l = loan.value) == null ? void 0 : _l.partnerName) == null ? void 0 : _m.toUpperCase().includes(LSE_LOAN_KEY);
|
|
129
|
+
const tagsData = ((_n = loan.value) == null ? void 0 : _n.tagsData) ?? [];
|
|
130
|
+
const themesData = ((_o = loan.value) == null ? void 0 : _o.themesData) ?? [];
|
|
131
|
+
if (isLseLoan && tags.length) {
|
|
132
|
+
const position = Math.floor(Math.random() * tags.length);
|
|
133
|
+
const p1Tag = tags[position];
|
|
134
|
+
const tagData = findCalloutData(tagsData, p1Tag);
|
|
135
|
+
const id = (tagData == null ? void 0 : tagData.id) ?? null;
|
|
136
|
+
callouts.push({ label: p1Tag, type: "tag", id });
|
|
137
|
+
}
|
|
138
|
+
if (!categoryPageName.value) {
|
|
139
|
+
if (categories.ecoFriendly && !callouts.find((c) => c.label.toUpperCase() === ECO_FRIENDLY_KEY || c.label.toUpperCase() === SUSTAINABLE_AG_KEY)) {
|
|
140
|
+
callouts.push({ label: "Eco-friendly", type: "tag", id: 9 });
|
|
141
|
+
} else if (categories.refugeesIdps) {
|
|
142
|
+
callouts.push({ label: "Refugees and IDPs", type: "attribute", id: 28 });
|
|
143
|
+
} else if (categories.singleParents && !callouts.find((c) => c.label.toUpperCase() === SINGLE_PARENT_KEY)) {
|
|
144
|
+
callouts.push({ label: "Single Parent", type: "tag", id: 17 });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (activityName && activityId && ((_p = categoryPageName.value) == null ? void 0 : _p.toUpperCase()) !== activityName.toUpperCase()) {
|
|
148
|
+
callouts.push({ id: activityId, label: activityName, type: "activity" });
|
|
149
|
+
}
|
|
150
|
+
if (sectorName && sectorId && activityName.toUpperCase() !== sectorName.toUpperCase() && sectorName.toUpperCase() !== ((_q = categoryPageName.value) == null ? void 0 : _q.toUpperCase()) && callouts.length < 2) {
|
|
151
|
+
callouts.push({ id: sectorId, label: sectorName, type: "sector" });
|
|
152
|
+
}
|
|
153
|
+
if (!!tags.length && callouts.length < 2) {
|
|
154
|
+
const position = Math.floor(Math.random() * tags.length);
|
|
155
|
+
const p4Tag = tags[position];
|
|
156
|
+
const tagData = findCalloutData(tagsData, p4Tag);
|
|
157
|
+
const id = (tagData == null ? void 0 : tagData.id) ?? null;
|
|
158
|
+
if (!callouts.filter((c) => c.label.toUpperCase() === p4Tag.toUpperCase()).length) {
|
|
159
|
+
callouts.push({ label: p4Tag, type: "tag", id });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!!themes.length && callouts.length < 2) {
|
|
163
|
+
const position = Math.floor(Math.random() * themes.length);
|
|
164
|
+
const theme = themes[position];
|
|
165
|
+
const themeData = findCalloutData(themesData, theme);
|
|
166
|
+
const id = (themeData == null ? void 0 : themeData.id) ?? null;
|
|
167
|
+
if (!callouts.filter((c) => c.label.toUpperCase() === theme.toUpperCase()).length && theme.toUpperCase() !== ((_r = categoryPageName.value) == null ? void 0 : _r.toUpperCase())) {
|
|
168
|
+
callouts.push({ label: theme, type: "attribute", id });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (isLseLoan && callouts.length > 1)
|
|
172
|
+
return [callouts.shift()];
|
|
173
|
+
const customTags = ((_s = customCallouts.value) == null ? void 0 : _s.map((c) => ({ label: c }))) ?? [];
|
|
174
|
+
callouts.push(...customTags);
|
|
175
|
+
return callouts;
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
tag,
|
|
179
|
+
readMorePath,
|
|
180
|
+
isLoading,
|
|
181
|
+
borrowerName,
|
|
182
|
+
countryName,
|
|
183
|
+
countryCode,
|
|
184
|
+
city,
|
|
185
|
+
state,
|
|
186
|
+
distributionModel,
|
|
187
|
+
imageHash,
|
|
188
|
+
hasProgressData,
|
|
189
|
+
allDataLoaded,
|
|
190
|
+
fundraisingPercent,
|
|
191
|
+
unreservedAmount,
|
|
192
|
+
formattedLocation,
|
|
193
|
+
loanUse,
|
|
194
|
+
loanStatus,
|
|
195
|
+
loanAmount,
|
|
196
|
+
loanBorrowerCount,
|
|
197
|
+
mdiMapMarker: import_js.mdiMapMarker,
|
|
198
|
+
loanCallouts
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function loanCardMethods(props, emit) {
|
|
202
|
+
const {
|
|
203
|
+
loanId,
|
|
204
|
+
customLoanDetails,
|
|
205
|
+
kvTrackFunction
|
|
206
|
+
} = (0, import_vue_demi.toRefs)(props);
|
|
207
|
+
function clickReadMore(target, event) {
|
|
208
|
+
kvTrackFunction.value("Lending", "click-Read more", target, loanId.value);
|
|
209
|
+
if (customLoanDetails.value) {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
emit("show-loan-details");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
clickReadMore
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
219
|
+
0 && (module.exports = {
|
|
220
|
+
loanCardComputedProperties,
|
|
221
|
+
loanCardMethods
|
|
222
|
+
});
|
package/dist/loanCard.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// utils/loanCard.js
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
toRefs
|
|
5
|
+
} from "vue-demi";
|
|
6
|
+
import { mdiMapMarker } from "@mdi/js";
|
|
7
|
+
var LSE_LOAN_KEY = "N/A";
|
|
8
|
+
var ECO_FRIENDLY_KEY = "ECO-FRIENDLY";
|
|
9
|
+
var SUSTAINABLE_AG_KEY = "SUSTAINABLE AG";
|
|
10
|
+
var SINGLE_PARENT_KEY = "SINGLE PARENT";
|
|
11
|
+
var REFUGEE_KEY = "REFUGEES/DISPLACED";
|
|
12
|
+
var findCalloutData = (tags, tagName) => (tags == null ? void 0 : tags.find((t) => t.name.replace("#", "").toUpperCase() === tagName.toUpperCase())) ?? {};
|
|
13
|
+
function loanCardComputedProperties(props, hideUnitedStatesText = false) {
|
|
14
|
+
const {
|
|
15
|
+
externalLinks,
|
|
16
|
+
customLoanDetails,
|
|
17
|
+
loanId,
|
|
18
|
+
loan,
|
|
19
|
+
categoryPageName,
|
|
20
|
+
customCallouts
|
|
21
|
+
} = toRefs(props);
|
|
22
|
+
const tag = computed(() => externalLinks.value ? "a" : "router-link");
|
|
23
|
+
const readMorePath = computed(() => customLoanDetails.value ? "" : `/lend/${loanId.value}`);
|
|
24
|
+
const isLoading = computed(() => !loanId.value || !loan.value);
|
|
25
|
+
const borrowerName = computed(() => {
|
|
26
|
+
var _a;
|
|
27
|
+
return ((_a = loan.value) == null ? void 0 : _a.name) || "";
|
|
28
|
+
});
|
|
29
|
+
const countryName = computed(() => {
|
|
30
|
+
var _a, _b, _c;
|
|
31
|
+
return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.name) || "";
|
|
32
|
+
});
|
|
33
|
+
const countryCode = computed(() => {
|
|
34
|
+
var _a, _b, _c;
|
|
35
|
+
return ((_c = (_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.country) == null ? void 0 : _c.isoCode) || "";
|
|
36
|
+
});
|
|
37
|
+
const city = computed(() => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.city) || "";
|
|
40
|
+
});
|
|
41
|
+
const state = computed(() => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.geocode) == null ? void 0 : _b.state) || "";
|
|
44
|
+
});
|
|
45
|
+
const distributionModel = computed(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
return ((_a = loan.value) == null ? void 0 : _a.distributionModel) || "";
|
|
48
|
+
});
|
|
49
|
+
const imageHash = computed(() => {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
return ((_b = (_a = loan.value) == null ? void 0 : _a.image) == null ? void 0 : _b.hash) ?? "";
|
|
52
|
+
});
|
|
53
|
+
const hasProgressData = computed(() => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
return typeof ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) !== "undefined" && typeof ((_b = loan.value) == null ? void 0 : _b.fundraisingPercent) !== "undefined";
|
|
56
|
+
});
|
|
57
|
+
const allDataLoaded = computed(() => !isLoading.value && hasProgressData.value);
|
|
58
|
+
const fundraisingPercent = computed(() => {
|
|
59
|
+
var _a;
|
|
60
|
+
return ((_a = loan.value) == null ? void 0 : _a.fundraisingPercent) ?? 0;
|
|
61
|
+
});
|
|
62
|
+
const unreservedAmount = computed(() => {
|
|
63
|
+
var _a;
|
|
64
|
+
const stringAmount = ((_a = loan.value) == null ? void 0 : _a.unreservedAmount) ?? "0";
|
|
65
|
+
return Number(stringAmount);
|
|
66
|
+
});
|
|
67
|
+
const formattedLocation = computed(() => {
|
|
68
|
+
if (distributionModel.value === "direct") {
|
|
69
|
+
const countryText = hideUnitedStatesText && countryName.value.toLowerCase() === "united states" ? "" : `, ${countryName.value}`;
|
|
70
|
+
return `${city.value}, ${state.value}${countryText}`;
|
|
71
|
+
}
|
|
72
|
+
if (countryName.value === "Puerto Rico") {
|
|
73
|
+
return `${city.value}, PR`;
|
|
74
|
+
}
|
|
75
|
+
return countryName.value;
|
|
76
|
+
});
|
|
77
|
+
const loanUse = computed(() => {
|
|
78
|
+
var _a;
|
|
79
|
+
return ((_a = loan.value) == null ? void 0 : _a.use) ?? "";
|
|
80
|
+
});
|
|
81
|
+
const loanStatus = computed(() => {
|
|
82
|
+
var _a;
|
|
83
|
+
return ((_a = loan.value) == null ? void 0 : _a.status) ?? "";
|
|
84
|
+
});
|
|
85
|
+
const loanAmount = computed(() => {
|
|
86
|
+
var _a;
|
|
87
|
+
return ((_a = loan.value) == null ? void 0 : _a.loanAmount) ?? "0";
|
|
88
|
+
});
|
|
89
|
+
const loanBorrowerCount = computed(() => {
|
|
90
|
+
var _a;
|
|
91
|
+
return ((_a = loan.value) == null ? void 0 : _a.borrowerCount) ?? 0;
|
|
92
|
+
});
|
|
93
|
+
const loanCallouts = computed(() => {
|
|
94
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
95
|
+
const callouts = [];
|
|
96
|
+
const activityName = ((_b = (_a = loan.value) == null ? void 0 : _a.activity) == null ? void 0 : _b.name) ?? "";
|
|
97
|
+
const activityId = ((_d = (_c = loan.value) == null ? void 0 : _c.activity) == null ? void 0 : _d.id) ?? null;
|
|
98
|
+
const sectorName = ((_f = (_e = loan.value) == null ? void 0 : _e.sector) == null ? void 0 : _f.name) ?? "";
|
|
99
|
+
const sectorId = ((_h = (_g = loan.value) == null ? void 0 : _g.sector) == null ? void 0 : _h.id) ?? null;
|
|
100
|
+
const tags = ((_j = (_i = loan.value) == null ? void 0 : _i.tags) == null ? void 0 : _j.filter((loantag) => loantag.charAt(0) === "#").map((loantag) => loantag.substring(1))) ?? [];
|
|
101
|
+
const themes = ((_k = loan.value) == null ? void 0 : _k.themes) ?? [];
|
|
102
|
+
const categories = {
|
|
103
|
+
ecoFriendly: !!tags.filter((t) => t.toUpperCase() === ECO_FRIENDLY_KEY || t.toUpperCase() === SUSTAINABLE_AG_KEY).length,
|
|
104
|
+
refugeesIdps: !!themes.filter((t) => t.toUpperCase() === REFUGEE_KEY).length,
|
|
105
|
+
singleParents: !!tags.filter((t) => t.toUpperCase() === SINGLE_PARENT_KEY).length
|
|
106
|
+
};
|
|
107
|
+
const isLseLoan = (_m = (_l = loan.value) == null ? void 0 : _l.partnerName) == null ? void 0 : _m.toUpperCase().includes(LSE_LOAN_KEY);
|
|
108
|
+
const tagsData = ((_n = loan.value) == null ? void 0 : _n.tagsData) ?? [];
|
|
109
|
+
const themesData = ((_o = loan.value) == null ? void 0 : _o.themesData) ?? [];
|
|
110
|
+
if (isLseLoan && tags.length) {
|
|
111
|
+
const position = Math.floor(Math.random() * tags.length);
|
|
112
|
+
const p1Tag = tags[position];
|
|
113
|
+
const tagData = findCalloutData(tagsData, p1Tag);
|
|
114
|
+
const id = (tagData == null ? void 0 : tagData.id) ?? null;
|
|
115
|
+
callouts.push({ label: p1Tag, type: "tag", id });
|
|
116
|
+
}
|
|
117
|
+
if (!categoryPageName.value) {
|
|
118
|
+
if (categories.ecoFriendly && !callouts.find((c) => c.label.toUpperCase() === ECO_FRIENDLY_KEY || c.label.toUpperCase() === SUSTAINABLE_AG_KEY)) {
|
|
119
|
+
callouts.push({ label: "Eco-friendly", type: "tag", id: 9 });
|
|
120
|
+
} else if (categories.refugeesIdps) {
|
|
121
|
+
callouts.push({ label: "Refugees and IDPs", type: "attribute", id: 28 });
|
|
122
|
+
} else if (categories.singleParents && !callouts.find((c) => c.label.toUpperCase() === SINGLE_PARENT_KEY)) {
|
|
123
|
+
callouts.push({ label: "Single Parent", type: "tag", id: 17 });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (activityName && activityId && ((_p = categoryPageName.value) == null ? void 0 : _p.toUpperCase()) !== activityName.toUpperCase()) {
|
|
127
|
+
callouts.push({ id: activityId, label: activityName, type: "activity" });
|
|
128
|
+
}
|
|
129
|
+
if (sectorName && sectorId && activityName.toUpperCase() !== sectorName.toUpperCase() && sectorName.toUpperCase() !== ((_q = categoryPageName.value) == null ? void 0 : _q.toUpperCase()) && callouts.length < 2) {
|
|
130
|
+
callouts.push({ id: sectorId, label: sectorName, type: "sector" });
|
|
131
|
+
}
|
|
132
|
+
if (!!tags.length && callouts.length < 2) {
|
|
133
|
+
const position = Math.floor(Math.random() * tags.length);
|
|
134
|
+
const p4Tag = tags[position];
|
|
135
|
+
const tagData = findCalloutData(tagsData, p4Tag);
|
|
136
|
+
const id = (tagData == null ? void 0 : tagData.id) ?? null;
|
|
137
|
+
if (!callouts.filter((c) => c.label.toUpperCase() === p4Tag.toUpperCase()).length) {
|
|
138
|
+
callouts.push({ label: p4Tag, type: "tag", id });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!!themes.length && callouts.length < 2) {
|
|
142
|
+
const position = Math.floor(Math.random() * themes.length);
|
|
143
|
+
const theme = themes[position];
|
|
144
|
+
const themeData = findCalloutData(themesData, theme);
|
|
145
|
+
const id = (themeData == null ? void 0 : themeData.id) ?? null;
|
|
146
|
+
if (!callouts.filter((c) => c.label.toUpperCase() === theme.toUpperCase()).length && theme.toUpperCase() !== ((_r = categoryPageName.value) == null ? void 0 : _r.toUpperCase())) {
|
|
147
|
+
callouts.push({ label: theme, type: "attribute", id });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (isLseLoan && callouts.length > 1)
|
|
151
|
+
return [callouts.shift()];
|
|
152
|
+
const customTags = ((_s = customCallouts.value) == null ? void 0 : _s.map((c) => ({ label: c }))) ?? [];
|
|
153
|
+
callouts.push(...customTags);
|
|
154
|
+
return callouts;
|
|
155
|
+
});
|
|
156
|
+
return {
|
|
157
|
+
tag,
|
|
158
|
+
readMorePath,
|
|
159
|
+
isLoading,
|
|
160
|
+
borrowerName,
|
|
161
|
+
countryName,
|
|
162
|
+
countryCode,
|
|
163
|
+
city,
|
|
164
|
+
state,
|
|
165
|
+
distributionModel,
|
|
166
|
+
imageHash,
|
|
167
|
+
hasProgressData,
|
|
168
|
+
allDataLoaded,
|
|
169
|
+
fundraisingPercent,
|
|
170
|
+
unreservedAmount,
|
|
171
|
+
formattedLocation,
|
|
172
|
+
loanUse,
|
|
173
|
+
loanStatus,
|
|
174
|
+
loanAmount,
|
|
175
|
+
loanBorrowerCount,
|
|
176
|
+
mdiMapMarker,
|
|
177
|
+
loanCallouts
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function loanCardMethods(props, emit) {
|
|
181
|
+
const {
|
|
182
|
+
loanId,
|
|
183
|
+
customLoanDetails,
|
|
184
|
+
kvTrackFunction
|
|
185
|
+
} = toRefs(props);
|
|
186
|
+
function clickReadMore(target, event) {
|
|
187
|
+
kvTrackFunction.value("Lending", "click-Read more", target, loanId.value);
|
|
188
|
+
if (customLoanDetails.value) {
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
emit("show-loan-details");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
clickReadMore
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
loanCardComputedProperties,
|
|
199
|
+
loanCardMethods
|
|
200
|
+
};
|