@kiva/kv-components 10.5.0 → 10.5.1

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.
@@ -1,250 +1,223 @@
1
- import P from "./KvIntroductionLoanCard2.js";
2
- import { KV_INTRODUCTION_LOAN_CARD_FRAGMENT as ot, KV_INTRODUCTION_LOAN_CARD_USER_FRAGMENT as at } from "./KvIntroductionLoanCard2.js";
3
- import { resolveComponent as i, openBlock as e, createElementBlock as n, normalizeStyle as R, normalizeClass as _, createElementVNode as d, createBlock as o, resolveDynamicComponent as g, withCtx as w, createVNode as s, Suspense as A, toDisplayString as f, createTextVNode as p, createCommentVNode as c, Fragment as T, renderList as I } from "vue";
4
- import "./KvIntroductionLoanCard.css";
5
- import B from "../_virtual/_plugin-vue_export-helper.js";
6
- const D = { class: "tw-grow" }, z = { class: "loan-card-active-hover" }, V = {
7
- key: 1,
8
- style: { height: "11rem" },
9
- class: "tw-relative tw-overflow-hidden"
10
- }, O = { key: 0 }, S = {
11
- class: "tw-absolute tw-bottom-1 tw-left-1 tw-text-primary tw-bg-white tw-rounded tw-p-1 tw-mb-0 tw-text-label tw-flex tw-items-center tw-h-3 !tw-capitalize",
12
- style: { padding: "2px 6px", "max-width": "calc(100% - 1rem)" }
13
- }, E = ["id"], F = {
14
- key: 3,
15
- class: "tw-flex tw-justify-center tw-gap-2"
16
- }, U = {
17
- key: 0,
18
- class: "tw-w-full",
19
- style: { height: "5.5rem" }
20
- }, W = { key: 1 }, j = { class: "tw-px-2" }, K = {
21
- key: 0,
22
- class: "tw-w-full tw-pr-1"
23
- }, G = { class: "tw-flex tw-justify-between" }, H = {
24
- key: 2,
25
- class: "tw-bg-eco-green-1 tw-text-action tw-text-center tw-py-1.5",
26
- style: { "font-weight": "bold", "font-size": "13px", "border-radius": "8px" }
1
+ import a from "graphql-tag";
2
+ import F from "numeral";
3
+ import { LOAN_CALLOUTS_FRAGMENT as k, LOAN_GEOCODE_FRAGMENT as B, LOAN_PROGRESS_FRAGMENT as E, loanCardComputedProperties as G, loanCardMethods as b, useLocationTruncation as I } from "../utils/loanCard.js";
4
+ import S from "./KvLoanBookmark2.js";
5
+ import D from "./KvLoanUse2.js";
6
+ import P from "./KvBorrowerImage.js";
7
+ import U from "./KvLoanProgressGroup.js";
8
+ import $ from "./KvLoanCallouts.js";
9
+ import w from "./KvLoanTag2.js";
10
+ import V from "./KvMaterialIcon.js";
11
+ import W from "./KvLoadingPlaceholder.js";
12
+ import q from "./KvFlag.js";
13
+ import H from "./KvTooltip.js";
14
+ import { KV_LOAN_BOOKMARK_FRAGMENT as r } from "./KvLoanBookmark.js";
15
+ import { KV_LOAN_TAG_FRAGMENT as j } from "./KvLoanTag.js";
16
+ import { KV_LOAN_USE_FRAGMENT as x } from "./KvLoanUse.js";
17
+ const mo = a`
18
+ fragment KvIntroductionLoanCard on LoanBasic {
19
+ id
20
+ image {
21
+ id
22
+ hash # for imageHash
23
+ }
24
+ lenders(limit: 0) {
25
+ totalCount # for lendersNumber
26
+ }
27
+ loanFundraisingInfo {
28
+ id
29
+ fundedAmount # for amountLent
30
+ }
31
+ name # for borrowerName
32
+ status # for isFunded
33
+ ...KvLoanBookmark
34
+ ...KvLoanTag
35
+ ...KvLoanUse
36
+ ...LoanCallouts
37
+ ...LoanGeocode
38
+ ...LoanProgress
39
+ }
40
+ ${r}
41
+ ${j}
42
+ ${x}
43
+ ${k}
44
+ ${B}
45
+ ${E}
46
+ `, fo = a`
47
+ fragment KvIntroductionLoanCardUser on LoanBasic {
48
+ id
49
+ ...KvLoanBookmark
50
+ }
51
+ ${r}
52
+ `, co = {
53
+ name: "KvIntroductionLoanCard",
54
+ components: {
55
+ KvBorrowerImage: P,
56
+ KvLoadingPlaceholder: W,
57
+ KvLoanUse: D,
58
+ KvLoanProgressGroup: U,
59
+ KvMaterialIcon: V,
60
+ KvLoanTag: w,
61
+ KvLoanCallouts: $,
62
+ KvFlag: q,
63
+ KvLoanBookmark: S,
64
+ KvTooltip: H
65
+ },
66
+ props: {
67
+ loanId: {
68
+ type: Number,
69
+ default: void 0
70
+ },
71
+ loan: {
72
+ type: Object,
73
+ default: null
74
+ },
75
+ customLoanDetails: {
76
+ type: Boolean,
77
+ default: !1
78
+ },
79
+ categoryPageName: {
80
+ type: String,
81
+ default: ""
82
+ },
83
+ customCallouts: {
84
+ type: Array,
85
+ default: () => []
86
+ },
87
+ kvTrackFunction: {
88
+ type: Function,
89
+ required: !0
90
+ },
91
+ photoPath: {
92
+ type: String,
93
+ required: !0
94
+ },
95
+ errorMsg: {
96
+ type: String,
97
+ default: ""
98
+ },
99
+ externalLinks: {
100
+ type: Boolean,
101
+ default: !1
102
+ },
103
+ route: {
104
+ type: Object,
105
+ default: void 0
106
+ },
107
+ useFullWidth: {
108
+ type: Boolean,
109
+ default: !1
110
+ },
111
+ isVisitor: {
112
+ type: Boolean,
113
+ default: !0
114
+ },
115
+ isBookmarked: {
116
+ type: Boolean,
117
+ default: !1
118
+ },
119
+ customHref: {
120
+ type: String,
121
+ default: ""
122
+ },
123
+ enableMultiMatching: {
124
+ type: Boolean,
125
+ default: !1
126
+ }
127
+ },
128
+ emits: [
129
+ "toggle-bookmark"
130
+ ],
131
+ setup(o, { emit: t }) {
132
+ const {
133
+ allDataLoaded: e,
134
+ borrowerName: n,
135
+ city: i,
136
+ countryName: s,
137
+ countryCode: u,
138
+ distributionModel: l,
139
+ formattedLocation: m,
140
+ fundraisingPercent: d,
141
+ hasProgressData: f,
142
+ imageHash: c,
143
+ isLoading: p,
144
+ loanAmount: L,
145
+ loanBorrowerCount: g,
146
+ loanCallouts: A,
147
+ loanStatus: h,
148
+ loanUse: N,
149
+ mdiMapMarker: _,
150
+ readMorePath: v,
151
+ state: K,
152
+ tag: y,
153
+ unreservedAmount: C,
154
+ sharesAvailable: O
155
+ } = G(o, !0), {
156
+ clickReadMore: T
157
+ } = b(o, t), {
158
+ locationRef: M,
159
+ isLocationTruncated: R
160
+ } = I();
161
+ return {
162
+ allDataLoaded: e,
163
+ borrowerName: n,
164
+ city: i,
165
+ countryName: s,
166
+ countryCode: u,
167
+ distributionModel: l,
168
+ formattedLocation: m,
169
+ fundraisingPercent: d,
170
+ hasProgressData: f,
171
+ imageHash: c,
172
+ isLoading: p,
173
+ loanAmount: L,
174
+ loanBorrowerCount: g,
175
+ loanCallouts: A,
176
+ loanStatus: h,
177
+ loanUse: N,
178
+ mdiMapMarker: _,
179
+ readMorePath: v,
180
+ state: K,
181
+ tag: y,
182
+ unreservedAmount: C,
183
+ sharesAvailable: O,
184
+ clickReadMore: T,
185
+ locationRef: M,
186
+ isLocationTruncated: R
187
+ };
188
+ },
189
+ computed: {
190
+ cardWidth() {
191
+ return this.useFullWidth ? "100%" : "20.5rem";
192
+ },
193
+ imageAspectRatio() {
194
+ return 5 / 8;
195
+ },
196
+ imageDefaultWidth() {
197
+ return 480;
198
+ },
199
+ imageSizes() {
200
+ return [
201
+ { width: this.imageDefaultWidth, viewSize: 375 }
202
+ ];
203
+ },
204
+ lendersNumber() {
205
+ var o, t;
206
+ return ((t = (o = this.loan) == null ? void 0 : o.lenders) == null ? void 0 : t.totalCount) ?? 0;
207
+ },
208
+ amountLent() {
209
+ var t, e;
210
+ const o = ((e = (t = this.loan) == null ? void 0 : t.loanFundraisingInfo) == null ? void 0 : e.fundedAmount) ?? 0;
211
+ return F(o).format("$0,0");
212
+ },
213
+ isFunded() {
214
+ var o;
215
+ return ((o = this.loan) == null ? void 0 : o.status) === "funded" || this.hasProgressData && !this.sharesAvailable;
216
+ }
217
+ }
27
218
  };
28
- function q(k, a, m, t, J, h) {
29
- const r = i("kv-loading-placeholder"), u = i("kv-borrower-image"), y = i("kv-flag"), b = i("kv-tooltip"), v = i("kv-loan-bookmark"), x = i("kv-loan-callouts"), C = i("kv-loan-use"), L = i("kv-loan-progress-group"), M = i("kv-loan-tag");
30
- return e(), n("div", {
31
- class: _(["tw-flex tw-flex-col tw-bg-white tw-rounded tw-w-full tw-pb-2", { "tw-pointer-events-none": t.isLoading }]),
32
- "data-testid": "loan-card",
33
- style: R([{ "box-shadow": "0px 4px 8px 0px rgba(0, 0, 0, 0.38)" }, { minWidth: "230px", maxWidth: h.cardWidth }])
34
- }, [
35
- d("div", D, [
36
- d("div", z, [
37
- t.isLoading ? (e(), o(r, {
38
- key: 0,
39
- class: "tw-w-full tw-rounded-t",
40
- style: { height: "11rem" }
41
- })) : (e(), n("div", V, [
42
- (e(), o(g(t.tag), {
43
- to: t.readMorePath,
44
- href: t.readMorePath,
45
- class: "tw-flex",
46
- "aria-label": "Borrower image",
47
- onClick: a[0] || (a[0] = (l) => t.clickReadMore("Photo", l))
48
- }, {
49
- default: w(() => [
50
- s(u, {
51
- class: "tw-relative tw-w-full tw-bg-black tw-rounded-t borrower-image tw-bg-clip-content",
52
- alt: `Photo of ${t.borrowerName}`,
53
- "aspect-ratio": h.imageAspectRatio,
54
- "default-image": { width: h.imageDefaultWidth },
55
- hash: t.imageHash,
56
- images: h.imageSizes,
57
- "photo-path": m.photoPath
58
- }, null, 8, ["alt", "aspect-ratio", "default-image", "hash", "images", "photo-path"]),
59
- t.countryName ? (e(), n("div", O, [
60
- d("p", S, [
61
- (e(), o(A, null, {
62
- default: w(() => [
63
- s(y, {
64
- class: "tw-ml-0.5 tw-mr-1 tw-flex-shrink-0",
65
- country: t.countryCode,
66
- name: t.countryName,
67
- "width-override": "16px",
68
- "hide-border": ""
69
- }, null, 8, ["country", "name"])
70
- ]),
71
- _: 1
72
- })),
73
- d("span", {
74
- id: `loan-location-${m.loanId}`,
75
- ref: "locationRef",
76
- class: "tw-truncate tw-min-w-0",
77
- style: { "margin-top": "0.125rem" }
78
- }, f(t.formattedLocation), 9, E),
79
- t.isLocationTruncated ? (e(), o(b, {
80
- key: 0,
81
- controller: `loan-location-${m.loanId}`,
82
- "max-width": "250px"
83
- }, {
84
- default: w(() => [
85
- p(f(t.formattedLocation), 1)
86
- ]),
87
- _: 1
88
- }, 8, ["controller"])) : c("", !0)
89
- ])
90
- ])) : c("", !0)
91
- ]),
92
- _: 1
93
- }, 8, ["to", "href"])),
94
- m.isVisitor ? c("", !0) : (e(), o(v, {
95
- key: 0,
96
- "loan-id": m.loanId,
97
- "is-bookmarked": m.isBookmarked,
98
- class: "loan-bookmark tw-absolute tw-right-1.5 tw-top-0",
99
- "data-testid": "loan-card-bookmark",
100
- onToggleBookmark: a[1] || (a[1] = (l) => k.$emit("toggle-bookmark"))
101
- }, null, 8, ["loan-id", "is-bookmarked"]))
102
- ])),
103
- t.isLoading || typeof t.loanCallouts > "u" ? (e(), o(r, {
104
- key: 2,
105
- class: "tw-mt-1 tw-mx-auto",
106
- style: { width: "60%", height: "1.75rem", "border-radius": "500rem" }
107
- })) : c("", !0),
108
- (e(), o(g(t.tag), {
109
- to: t.readMorePath,
110
- href: t.readMorePath,
111
- "aria-label": "Borrower name",
112
- class: "!tw-text-primary tw-no-underline",
113
- onClick: a[2] || (a[2] = (l) => t.clickReadMore("Name", l))
114
- }, {
115
- default: w(() => [
116
- d("h3", {
117
- class: _(["loan-card-name tw-text-title", { "tw-text-center": t.borrowerName.length < 20 }]),
118
- style: { "font-size": "28px" }
119
- }, f(t.borrowerName), 3)
120
- ]),
121
- _: 1
122
- }, 8, ["to", "href"])),
123
- t.isLoading ? (e(), n("div", F, [
124
- t.isLoading || typeof t.loanCallouts > "u" ? (e(), o(r, {
125
- key: 0,
126
- class: "tw-mt-0.5 tw-mb-1",
127
- style: { width: "20%", height: "1.65rem", "border-radius": "500rem" }
128
- })) : c("", !0),
129
- t.isLoading || typeof t.loanCallouts > "u" ? (e(), o(r, {
130
- key: 1,
131
- class: "tw-mt-0.5 tw-mb-1",
132
- style: { width: "20%", height: "1.65rem", "border-radius": "500rem" }
133
- })) : c("", !0),
134
- t.isLoading || typeof t.loanCallouts > "u" ? (e(), o(r, {
135
- key: 2,
136
- class: "tw-mt-0.5 tw-mb-1",
137
- style: { width: "20%", height: "1.65rem", "border-radius": "500rem" }
138
- })) : c("", !0)
139
- ])) : (e(), o(g(t.tag), {
140
- key: 4,
141
- to: t.readMorePath,
142
- href: t.readMorePath,
143
- class: "tw-flex tw-no-underline hover:tw-no-underline focus:tw-no-underline tw-justify-center",
144
- "aria-label": "Loan tag",
145
- onClick: a[3] || (a[3] = (l) => t.clickReadMore("Tag", l))
146
- }, {
147
- default: w(() => [
148
- s(x, {
149
- callouts: t.loanCallouts,
150
- "add-bg-color": !1,
151
- class: "loan-callouts"
152
- }, null, 8, ["callouts"])
153
- ]),
154
- _: 1
155
- }, 8, ["to", "href"])),
156
- (e(), o(g(t.tag), {
157
- to: t.readMorePath,
158
- href: t.readMorePath,
159
- class: "loan-card-use tw-text-primary tw-no-underline",
160
- "aria-label": "Loan use",
161
- onClick: a[4] || (a[4] = (l) => t.clickReadMore("Use", l))
162
- }, {
163
- default: w(() => [
164
- d("div", {
165
- class: _(["tw-pt-0.5 tw-px-2", { "tw-mb-1.5": !t.isLoading }])
166
- }, [
167
- t.isLoading ? (e(), n("div", U, [
168
- (e(!0), n(T, null, I([...Array(3)], (l, N) => (e(), n("div", {
169
- key: N,
170
- class: "tw-h-2 tw-mb-1"
171
- }, [
172
- s(r)
173
- ]))), 128))
174
- ])) : (e(), n("div", W, [
175
- s(C, {
176
- use: t.loanUse,
177
- "loan-amount": t.loanAmount,
178
- status: t.loanStatus,
179
- "borrower-count": t.loanBorrowerCount,
180
- name: t.borrowerName,
181
- "distribution-model": t.distributionModel,
182
- "hide-loan-amount": "",
183
- class: "!tw-line-clamp-3"
184
- }, null, 8, ["use", "loan-amount", "status", "borrower-count", "name", "distribution-model"])
185
- ]))
186
- ], 2)
187
- ]),
188
- _: 1
189
- }, 8, ["to", "href"]))
190
- ])
191
- ]),
192
- d("div", j, [
193
- t.hasProgressData ? c("", !0) : (e(), n("div", K, [
194
- d("div", G, [
195
- s(r, {
196
- class: "tw-mb-0.5",
197
- style: { width: "20%", height: "1.3rem" }
198
- }),
199
- s(r, {
200
- class: "tw-mb-0.5",
201
- style: { width: "20%", height: "1.3rem" }
202
- })
203
- ]),
204
- s(r, {
205
- class: "tw-rounded",
206
- style: { width: "100%", height: "0.5rem" }
207
- })
208
- ])),
209
- d("div", null, [
210
- t.sharesAvailable ? (e(), o(g(t.tag), {
211
- key: 0,
212
- to: t.readMorePath,
213
- href: t.readMorePath,
214
- class: "loan-card-progress tw-mt-1",
215
- "aria-label": "Loan progress",
216
- onClick: a[5] || (a[5] = (l) => t.clickReadMore("Progress", l))
217
- }, {
218
- default: w(() => [
219
- s(L, {
220
- id: "loanProgress",
221
- "money-left": t.unreservedAmount,
222
- "amount-goal": t.loanAmount,
223
- "progress-percent": t.fundraisingPercent,
224
- class: "tw-text-secondary"
225
- }, null, 8, ["money-left", "amount-goal", "progress-percent"])
226
- ]),
227
- _: 1
228
- }, 8, ["to", "href"])) : c("", !0)
229
- ]),
230
- t.isLoading ? (e(), o(r, {
231
- key: 1,
232
- class: "tw-rounded tw-mx-auto tw-mt-2",
233
- style: { width: "9rem", height: "1rem" }
234
- })) : h.isFunded ? (e(), n("div", H, " 🎉 Fully funded! ")) : (e(), o(M, {
235
- key: 3,
236
- loan: m.loan,
237
- "use-expanded-styles": !0,
238
- "enable-multi-matching": m.enableMultiMatching,
239
- style: { "font-size": "15px" },
240
- class: "tw-text-center tw-pt-2"
241
- }, null, 8, ["loan", "enable-multi-matching"]))
242
- ])
243
- ], 6);
244
- }
245
- const $ = /* @__PURE__ */ B(P, [["render", q], ["__scopeId", "data-v-2e03cf82"]]);
246
219
  export {
247
- ot as KV_INTRODUCTION_LOAN_CARD_FRAGMENT,
248
- at as KV_INTRODUCTION_LOAN_CARD_USER_FRAGMENT,
249
- $ as default
220
+ mo as KV_INTRODUCTION_LOAN_CARD_FRAGMENT,
221
+ fo as KV_INTRODUCTION_LOAN_CARD_USER_FRAGMENT,
222
+ co as default
250
223
  };