@kiva/kv-components 10.4.1 → 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,255 +1,298 @@
1
- import N from "./KvClassicLoanCard2.js";
2
- import { KV_CLASSIC_LOAN_CARD_FRAGMENT as ae, KV_CLASSIC_LOAN_CARD_USER_FRAGMET as oe } from "./KvClassicLoanCard2.js";
3
- import { resolveComponent as i, openBlock as a, createElementBlock as s, normalizeStyle as T, normalizeClass as r, createElementVNode as d, createBlock as n, resolveDynamicComponent as v, withCtx as g, createVNode as w, toDisplayString as b, createTextVNode as V, createCommentVNode as c, Fragment as R, renderList as S } from "vue";
4
- import "./KvClassicLoanCard.css";
5
- import F from "../_virtual/_plugin-vue_export-helper.js";
6
- const I = { class: "tw-grow" }, E = { class: "loan-card-active-hover" }, K = {
7
- key: 1,
8
- class: "tw-relative"
9
- }, z = { key: 0 }, W = {
10
- 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",
11
- style: { padding: "2px 6px", "text-transform": "capitalize", "max-width": "calc(100% - 1rem)" }
12
- }, U = ["id"], j = { class: "tw-mb-1.5 tw-pt-1" }, G = { key: 1 }, H = {
13
- key: 0,
14
- class: "tw-w-full tw-pt-1 tw-pr-1"
15
- }, O = {
16
- key: 0,
17
- class: "tw-text-center tw-w-full tw-mt-1 tw-font-medium"
18
- }, q = {
19
- key: 1,
20
- class: "tw-pt-1.5"
1
+ import a from "graphql-tag";
2
+ import S from "numeral";
3
+ import { LOAN_CALLOUTS_FRAGMENT as M, LOAN_GEOCODE_FRAGMENT as k, LOAN_PROGRESS_FRAGMENT as F, loanCardComputedProperties as R, loanCardMethods as w, useLocationTruncation as E } from "../utils/loanCard.js";
4
+ import b from "./KvLoanUse2.js";
5
+ import O from "./KvBorrowerImage.js";
6
+ import G from "./KvLoanProgressGroup.js";
7
+ import D from "./KvLoanCallouts.js";
8
+ import P from "./KvLendCta2.js";
9
+ import I from "./KvLoanBookmark2.js";
10
+ import V from "./KvLoanTag2.js";
11
+ import $ from "./KvMaterialIcon.js";
12
+ import U from "./KvLoadingPlaceholder.js";
13
+ import z from "./KvLoanTeamPick.js";
14
+ import W from "./KvLoanActivities2.js";
15
+ import x from "./KvTooltip.js";
16
+ import { KV_LEND_CTA_FRAGMENT as H, KV_LEND_CTA_USER_FRAGMENT as j } from "./KvLendCta.js";
17
+ import { KV_LOAN_ACTIVITIES_FRAGMENT as q } from "./KvLoanActivities.js";
18
+ import { KV_LOAN_TAG_FRAGMENT as J } from "./KvLoanTag.js";
19
+ import { KV_LOAN_USE_FRAGMENT as Q } from "./KvLoanUse.js";
20
+ import { KV_LOAN_BOOKMARK_FRAGMENT as X } from "./KvLoanBookmark.js";
21
+ const ve = a`
22
+ fragment KvClassicLoanCard on LoanBasic {
23
+ id
24
+ gender
25
+ image {
26
+ id
27
+ hash # for imageHash
28
+ }
29
+ lenders(limit: 0) {
30
+ totalCount # for lendersNumber
31
+ }
32
+ loanFundraisingInfo {
33
+ id
34
+ fundedAmount # for amountLent
35
+ }
36
+ name # for borrowerName
37
+ ...KvLendCta
38
+ ...KvLoanActivities
39
+ ...KvLoanTag
40
+ ...KvLoanUse
41
+ ...LoanCallouts
42
+ ...LoanGeocode
43
+ ...LoanProgress
44
+ }
45
+ ${H}
46
+ ${q}
47
+ ${J}
48
+ ${Q}
49
+ ${M}
50
+ ${k}
51
+ ${F}
52
+ `, ye = a`
53
+ fragment KvClassicLoanCardUser on LoanBasic {
54
+ id
55
+ ...KvLendCtaUser
56
+ ...KvLoanBookmark
57
+ }
58
+ ${j}
59
+ ${X}
60
+ `, Ce = {
61
+ name: "KvClassicLoanCard",
62
+ components: {
63
+ KvBorrowerImage: O,
64
+ KvLoadingPlaceholder: U,
65
+ KvLoanUse: b,
66
+ KvLoanProgressGroup: G,
67
+ KvMaterialIcon: $,
68
+ KvLendCta: P,
69
+ KvLoanTag: V,
70
+ KvLoanCallouts: D,
71
+ KvLoanBookmark: I,
72
+ KvLoanTeamPick: z,
73
+ KvLoanActivities: W,
74
+ KvTooltip: x
75
+ },
76
+ props: {
77
+ loanId: {
78
+ type: Number,
79
+ default: void 0
80
+ },
81
+ loan: {
82
+ type: Object,
83
+ default: null
84
+ },
85
+ customLoanDetails: {
86
+ type: Boolean,
87
+ default: !1
88
+ },
89
+ showTags: {
90
+ type: Boolean,
91
+ default: !1
92
+ },
93
+ categoryPageName: {
94
+ type: String,
95
+ default: ""
96
+ },
97
+ enableFiveDollarsNotes: {
98
+ type: Boolean,
99
+ default: !1
100
+ },
101
+ isAdding: {
102
+ type: Boolean,
103
+ default: !1
104
+ },
105
+ isVisitor: {
106
+ type: Boolean,
107
+ default: !0
108
+ },
109
+ basketItems: {
110
+ type: Array,
111
+ default: () => []
112
+ },
113
+ isBookmarked: {
114
+ type: Boolean,
115
+ default: !1
116
+ },
117
+ kvTrackFunction: {
118
+ type: Function,
119
+ required: !0
120
+ },
121
+ photoPath: {
122
+ type: String,
123
+ required: !0
124
+ },
125
+ showViewLoan: {
126
+ type: Boolean,
127
+ default: !1
128
+ },
129
+ externalLinks: {
130
+ type: Boolean,
131
+ default: !1
132
+ },
133
+ route: {
134
+ type: Object,
135
+ default: void 0
136
+ },
137
+ userBalance: {
138
+ type: String,
139
+ default: void 0
140
+ },
141
+ getCookie: {
142
+ type: Function,
143
+ default: void 0
144
+ },
145
+ setCookie: {
146
+ type: Function,
147
+ default: void 0
148
+ },
149
+ fiveDollarsSelected: {
150
+ type: Boolean,
151
+ default: !1
152
+ },
153
+ customCallouts: {
154
+ type: Array,
155
+ default: () => []
156
+ },
157
+ useFullWidth: {
158
+ type: Boolean,
159
+ default: !1
160
+ },
161
+ largeCard: {
162
+ type: Boolean,
163
+ default: !1
164
+ },
165
+ isTeamPick: {
166
+ type: Boolean,
167
+ default: !1
168
+ },
169
+ combinedActivities: {
170
+ type: Array,
171
+ default: () => []
172
+ },
173
+ errorMsg: {
174
+ type: String,
175
+ default: ""
176
+ },
177
+ primaryButtonText: {
178
+ type: String,
179
+ default: "Lend"
180
+ },
181
+ secondaryButtonHandler: {
182
+ type: Function,
183
+ default: void 0
184
+ },
185
+ secondaryButtonText: {
186
+ type: String,
187
+ default: "Checkout now"
188
+ },
189
+ showContributors: {
190
+ type: Boolean,
191
+ default: !1
192
+ },
193
+ customHref: {
194
+ type: String,
195
+ default: ""
196
+ },
197
+ enableMultiMatching: {
198
+ type: Boolean,
199
+ default: !1
200
+ }
201
+ },
202
+ emits: [
203
+ "toggle-bookmark",
204
+ "jump-filter-page",
205
+ "add-to-basket",
206
+ "remove-from-basket"
207
+ ],
208
+ setup(e, { emit: t }) {
209
+ const {
210
+ allDataLoaded: o,
211
+ borrowerName: r,
212
+ city: n,
213
+ countryName: i,
214
+ distributionModel: l,
215
+ formattedLocation: s,
216
+ fundraisingPercent: d,
217
+ hasProgressData: u,
218
+ imageHash: m,
219
+ isLoading: f,
220
+ loanAmount: p,
221
+ loanBorrowerCount: c,
222
+ loanCallouts: L,
223
+ loanStatus: g,
224
+ loanUse: A,
225
+ mdiMapMarker: v,
226
+ readMorePath: y,
227
+ state: C,
228
+ tag: h,
229
+ unreservedAmount: _,
230
+ sharesAvailable: K
231
+ } = R(e), {
232
+ clickReadMore: N
233
+ } = w(e, t), {
234
+ locationRef: T,
235
+ isLocationTruncated: B
236
+ } = E();
237
+ return {
238
+ allDataLoaded: o,
239
+ borrowerName: r,
240
+ city: n,
241
+ countryName: i,
242
+ distributionModel: l,
243
+ formattedLocation: s,
244
+ fundraisingPercent: d,
245
+ hasProgressData: u,
246
+ imageHash: m,
247
+ isLoading: f,
248
+ loanAmount: p,
249
+ loanBorrowerCount: c,
250
+ loanCallouts: L,
251
+ loanStatus: g,
252
+ loanUse: A,
253
+ mdiMapMarker: v,
254
+ readMorePath: y,
255
+ state: C,
256
+ tag: h,
257
+ unreservedAmount: _,
258
+ sharesAvailable: K,
259
+ clickReadMore: N,
260
+ locationRef: T,
261
+ isLocationTruncated: B
262
+ };
263
+ },
264
+ computed: {
265
+ cardWidth() {
266
+ return this.useFullWidth ? "100%" : "374px";
267
+ },
268
+ imageAspectRatio() {
269
+ return this.largeCard ? 5 / 8 : 3 / 4;
270
+ },
271
+ imageDefaultWidth() {
272
+ return this.largeCard ? 480 : 336;
273
+ },
274
+ imageSizes() {
275
+ return this.largeCard ? [{ width: 480 }] : [
276
+ { width: this.imageDefaultWidth, viewSize: 1024 },
277
+ { width: this.imageDefaultWidth, viewSize: 768 },
278
+ { width: 416, viewSize: 480 },
279
+ { width: 374, viewSize: 414 },
280
+ { width: 335, viewSize: 375 }
281
+ ];
282
+ },
283
+ lendersNumber() {
284
+ var e, t;
285
+ return ((t = (e = this.loan) == null ? void 0 : e.lenders) == null ? void 0 : t.totalCount) ?? 0;
286
+ },
287
+ amountLent() {
288
+ var t, o;
289
+ const e = ((o = (t = this.loan) == null ? void 0 : t.loanFundraisingInfo) == null ? void 0 : o.fundedAmount) ?? 0;
290
+ return S(e).format("$0,0");
291
+ }
292
+ }
21
293
  };
22
- function J(u, o, e, t, Q, m) {
23
- const k = i("kv-loading-placeholder"), h = i("kv-borrower-image"), f = i("kv-material-icon"), _ = i("kv-tooltip"), y = i("kv-loan-team-pick"), x = i("kv-loan-bookmark"), C = i("kv-loan-tag"), L = i("kv-loan-use"), A = i("kv-loan-callouts"), M = i("kv-loan-progress-group"), P = i("kv-lend-cta"), B = i("KvLoanActivities");
24
- return a(), s("div", {
25
- class: r(["tw-flex tw-flex-col tw-bg-white tw-rounded tw-w-full tw-pb-1", { "tw-p-1": !e.largeCard, "tw-pointer-events-none": t.isLoading }]),
26
- "data-testid": "loan-card",
27
- style: T([{ "box-shadow": "0 4px 12px rgba(0, 0, 0, 0.08)" }, { minWidth: "230px", maxWidth: m.cardWidth }])
28
- }, [
29
- d("div", I, [
30
- d("div", E, [
31
- t.isLoading ? (a(), n(k, {
32
- key: 0,
33
- class: r(["tw-mb-1 tw-w-full", { "tw-rounded-t tw-rounded-b-none": e.largeCard, "!tw-rounded-sm": !e.largeCard }]),
34
- style: { height: "15rem" }
35
- }, null, 8, ["class"])) : (a(), s("div", K, [
36
- (a(), n(v(t.tag), {
37
- to: t.readMorePath,
38
- href: t.readMorePath,
39
- class: "tw-flex",
40
- "aria-label": "Borrower image",
41
- onClick: o[0] || (o[0] = (l) => t.clickReadMore("Photo", l))
42
- }, {
43
- default: g(() => [
44
- w(h, {
45
- class: r(["tw-relative tw-w-full tw-bg-black tw-bg-clip-content", { "tw-rounded-t": e.largeCard, "tw-rounded-sm": !e.largeCard }]),
46
- alt: `Photo of ${t.borrowerName}`,
47
- "aspect-ratio": m.imageAspectRatio,
48
- "default-image": { width: m.imageDefaultWidth },
49
- hash: t.imageHash,
50
- images: m.imageSizes,
51
- "photo-path": e.photoPath
52
- }, null, 8, ["class", "alt", "aspect-ratio", "default-image", "hash", "images", "photo-path"]),
53
- t.countryName ? (a(), s("div", z, [
54
- d("p", W, [
55
- w(f, {
56
- class: "tw-h-2 tw-w-2 tw-flex-shrink-0",
57
- icon: t.mdiMapMarker
58
- }, null, 8, ["icon"]),
59
- d("span", {
60
- id: `loan-location-${e.loanId}`,
61
- ref: "locationRef",
62
- class: "tw-truncate tw-min-w-0",
63
- style: { "margin-top": "0.125rem" }
64
- }, b(t.formattedLocation), 9, U),
65
- t.isLocationTruncated ? (a(), n(_, {
66
- key: 0,
67
- controller: `loan-location-${e.loanId}`,
68
- "max-width": "250px"
69
- }, {
70
- default: g(() => [
71
- V(b(t.formattedLocation), 1)
72
- ]),
73
- _: 1
74
- }, 8, ["controller"])) : c("", !0)
75
- ])
76
- ])) : c("", !0)
77
- ]),
78
- _: 1
79
- }, 8, ["to", "href"])),
80
- e.isTeamPick ? (a(), n(y, {
81
- key: 0,
82
- class: r(["tw-absolute", { "tw-right-6": !e.isVisitor, "tw-right-0": e.isVisitor }]),
83
- style: { top: "-6px" },
84
- "data-testid": "loan-card-teampick"
85
- }, null, 8, ["class"])) : c("", !0),
86
- e.isVisitor ? c("", !0) : (a(), n(x, {
87
- key: 1,
88
- "loan-id": e.loanId,
89
- "is-bookmarked": e.isBookmarked,
90
- class: "tw-absolute tw-right-1",
91
- style: { top: "-6px" },
92
- "data-testid": "loan-card-bookmark",
93
- onToggleBookmark: o[1] || (o[1] = (l) => u.$emit("toggle-bookmark"))
94
- }, null, 8, ["loan-id", "is-bookmarked"]))
95
- ])),
96
- (a(), n(v(t.tag), {
97
- to: t.readMorePath,
98
- href: t.readMorePath,
99
- class: r(["tw-flex tw-no-underline hover:tw-no-underline focus:tw-no-underline", { "tw-px-1": e.largeCard }]),
100
- "aria-label": "Loan tag",
101
- onClick: o[2] || (o[2] = (l) => t.clickReadMore("Tag", l))
102
- }, {
103
- default: g(() => [
104
- e.showTags && !t.isLoading ? (a(), n(C, {
105
- key: 0,
106
- loan: e.loan,
107
- "enable-multi-matching": e.enableMultiMatching
108
- }, null, 8, ["loan", "enable-multi-matching"])) : c("", !0)
109
- ]),
110
- _: 1
111
- }, 8, ["to", "href", "class"])),
112
- (a(), n(v(t.tag), {
113
- to: t.readMorePath,
114
- href: t.readMorePath,
115
- class: "loan-card-use tw-no-underline tw-text-primary",
116
- "aria-label": "Loan use",
117
- onClick: o[3] || (o[3] = (l) => t.clickReadMore("Use", l))
118
- }, {
119
- default: g(() => [
120
- d("div", j, [
121
- t.isLoading ? (a(), s("div", {
122
- key: 0,
123
- class: r(["tw-w-full", { "tw-px-1": e.largeCard }]),
124
- style: { height: "5.5rem" }
125
- }, [
126
- (a(!0), s(R, null, S([...Array(4)], (l, D) => (a(), s("div", {
127
- key: D,
128
- class: "tw-h-2 tw-mb-1"
129
- }, [
130
- w(k)
131
- ]))), 128))
132
- ], 2)) : (a(), s("div", G, [
133
- w(L, {
134
- use: t.loanUse,
135
- "loan-amount": t.loanAmount,
136
- status: t.loanStatus,
137
- "borrower-count": t.loanBorrowerCount,
138
- name: t.borrowerName,
139
- "distribution-model": t.distributionModel,
140
- class: r({ "tw-px-1": e.largeCard })
141
- }, null, 8, ["use", "loan-amount", "status", "borrower-count", "name", "distribution-model", "class"])
142
- ]))
143
- ])
144
- ]),
145
- _: 1
146
- }, 8, ["to", "href"]))
147
- ]),
148
- t.isLoading || typeof t.loanCallouts > "u" ? (a(), n(k, {
149
- key: 0,
150
- class: r(["tw-mt-1.5 tw-mb-1", { "tw-mx-1": e.largeCard }]),
151
- style: { width: "60%", height: "1.75rem", "border-radius": "500rem" }
152
- }, null, 8, ["class"])) : (a(), n(A, {
153
- key: 1,
154
- callouts: t.loanCallouts,
155
- class: r(["tw-mt-1.5", { "tw-px-1": e.largeCard }]),
156
- onClick: o[4] || (o[4] = (l) => u.$emit("jump-filter-page", l))
157
- }, null, 8, ["callouts", "class"]))
158
- ]),
159
- d("div", {
160
- class: r(["tw-flex tw-justify-between tw-mt-2", { "tw-px-1": e.largeCard }])
161
- }, [
162
- t.hasProgressData ? c("", !0) : (a(), s("div", H, [
163
- w(k, {
164
- class: "tw-mb-0.5",
165
- style: { width: "70%", height: "1.3rem" }
166
- }),
167
- w(k, {
168
- class: "tw-rounded",
169
- style: { width: "70%", height: "0.5rem" }
170
- })
171
- ])),
172
- d("div", null, [
173
- t.sharesAvailable ? (a(), n(v(t.tag), {
174
- key: 0,
175
- to: t.readMorePath,
176
- href: t.readMorePath,
177
- class: "loan-card-progress tw-no-underline tw-mt-1",
178
- "aria-label": "Loan progress",
179
- onClick: o[5] || (o[5] = (l) => t.clickReadMore("Progress", l))
180
- }, {
181
- default: g(() => [
182
- w(M, {
183
- id: "loanProgress",
184
- "money-left": t.unreservedAmount,
185
- "progress-percent": t.fundraisingPercent,
186
- class: "tw-text-black"
187
- }, null, 8, ["money-left", "progress-percent"])
188
- ]),
189
- _: 1
190
- }, 8, ["to", "href"])) : c("", !0)
191
- ]),
192
- t.allDataLoaded ? (a(), n(P, {
193
- key: 2,
194
- loan: e.loan,
195
- "unreserved-amount": t.unreservedAmount,
196
- "basket-items": e.basketItems,
197
- "is-loading": t.isLoading,
198
- "is-adding": e.isAdding,
199
- "enable-five-dollars-notes": e.enableFiveDollarsNotes,
200
- "five-dollars-selected": e.fiveDollarsSelected,
201
- "kv-track-function": e.kvTrackFunction,
202
- "show-view-loan": e.showViewLoan,
203
- "custom-loan-details": e.customLoanDetails,
204
- "external-links": e.externalLinks,
205
- route: e.route,
206
- "user-balance": e.userBalance,
207
- "get-cookie": e.getCookie,
208
- "set-cookie": e.setCookie,
209
- "is-visitor": e.isVisitor,
210
- "primary-button-text": e.primaryButtonText,
211
- "secondary-button-text": e.secondaryButtonText,
212
- "secondary-button-handler": e.secondaryButtonHandler,
213
- class: r(["tw-mt-auto", { "tw-w-full": !t.sharesAvailable }]),
214
- onAddToBasket: o[6] || (o[6] = (l) => u.$emit("add-to-basket", l)),
215
- onShowLoanDetails: o[7] || (o[7] = (l) => t.clickReadMore("ViewLoan", l)),
216
- onRemoveFromBasket: o[8] || (o[8] = (l) => u.$emit("remove-from-basket", l))
217
- }, null, 8, ["loan", "unreserved-amount", "basket-items", "is-loading", "is-adding", "enable-five-dollars-notes", "five-dollars-selected", "kv-track-function", "show-view-loan", "custom-loan-details", "external-links", "route", "user-balance", "get-cookie", "set-cookie", "is-visitor", "primary-button-text", "secondary-button-text", "secondary-button-handler", "class"])) : (a(), n(k, {
218
- key: 1,
219
- class: "tw-rounded tw-self-start",
220
- style: { width: "9rem", height: "3rem" }
221
- }))
222
- ], 2),
223
- e.showContributors && m.lendersNumber && m.amountLent ? (a(), s("div", O, [
224
- d("p", null, b(m.lendersNumber) + " people contributed " + b(m.amountLent), 1)
225
- ])) : c("", !0),
226
- e.combinedActivities.length > 0 ? (a(), s("div", q, [
227
- o[10] || (o[10] = d("hr", { class: "tw-border-tertiary tw-mb-1 tw-w-5/6 tw-mx-auto" }, null, -1)),
228
- w(B, {
229
- loan: e.loan,
230
- "combined-activities": e.combinedActivities,
231
- "kv-track-function": e.kvTrackFunction,
232
- "basket-items": e.basketItems,
233
- "is-adding": e.isAdding,
234
- "enable-five-dollars-notes": e.enableFiveDollarsNotes,
235
- "five-dollars-selected": e.fiveDollarsSelected,
236
- "show-view-loan": e.showViewLoan,
237
- "custom-loan-details": e.customLoanDetails,
238
- "external-links": e.externalLinks,
239
- route: e.route,
240
- "user-balance": e.userBalance,
241
- "get-cookie": e.getCookie,
242
- "set-cookie": e.setCookie,
243
- "error-msg": e.errorMsg,
244
- "is-visitor": e.isVisitor,
245
- onAddToBasket: o[9] || (o[9] = (l) => u.$emit("add-to-basket", l))
246
- }, null, 8, ["loan", "combined-activities", "kv-track-function", "basket-items", "is-adding", "enable-five-dollars-notes", "five-dollars-selected", "show-view-loan", "custom-loan-details", "external-links", "route", "user-balance", "get-cookie", "set-cookie", "error-msg", "is-visitor"])
247
- ])) : c("", !0)
248
- ], 6);
249
- }
250
- const $ = /* @__PURE__ */ F(N, [["render", J], ["__scopeId", "data-v-44561e04"]]);
251
294
  export {
252
- ae as KV_CLASSIC_LOAN_CARD_FRAGMENT,
253
- oe as KV_CLASSIC_LOAN_CARD_USER_FRAGMET,
254
- $ as default
295
+ ve as KV_CLASSIC_LOAN_CARD_FRAGMENT,
296
+ ye as KV_CLASSIC_LOAN_CARD_USER_FRAGMET,
297
+ Ce as default
255
298
  };