@kiva/kv-components 10.5.0 → 10.6.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.
@@ -1,125 +1,46 @@
1
- import { differenceInDays as r, parseISO as s } from "date-fns";
2
- import u from "graphql-tag";
3
- import l from "numeral";
4
- import d from "./KvCountdownTimer.js";
5
- import m from "./KvTooltip.js";
6
- const h = "N/A", a = {
7
- almostFunded: "almost-funded",
8
- endingSoon: "ending-soon",
9
- matchedLoan: "matched-loan",
10
- lseLoan: "lse-loan"
11
- }, y = u`
12
- fragment KvLoanTag on LoanBasic {
13
- id
14
- loanFundraisingInfo {
15
- id
16
- fundedAmount
17
- reservedAmount
18
- }
19
- loanAmount
20
- matchRatio
21
- matchingText
22
- simultaneousMatching {
23
- managedAccountId
24
- displayName
25
- ratio
26
- }
27
- plannedExpirationDate
28
- ... on LoanPartner {
29
- partnerName
30
- }
31
- }
32
- `, L = {
33
- name: "KvLoanTag",
34
- components: {
35
- KvCountdownTimer: d,
36
- KvTooltip: m
37
- },
38
- props: {
39
- loan: {
40
- type: Object,
41
- required: !0
42
- },
43
- useExpandedStyles: {
44
- type: Boolean,
45
- default: !1
46
- },
47
- enableMultiMatching: {
48
- type: Boolean,
49
- default: !1
50
- }
51
- },
52
- computed: {
53
- deadline() {
54
- var t;
55
- return s((t = this.loan) == null ? void 0 : t.plannedExpirationDate);
56
- },
57
- isLseLoan() {
58
- var t, n;
59
- return ((n = (t = this.loan) == null ? void 0 : t.partnerName) == null ? void 0 : n.toUpperCase().includes(h)) ?? !1;
60
- },
61
- amountLeft() {
62
- var e, o;
63
- const t = ((e = this.loan) == null ? void 0 : e.loanFundraisingInfo) ?? { fundedAmount: 0, reservedAmount: 0 }, { fundedAmount: n, reservedAmount: i } = t;
64
- return l((o = this.loan) == null ? void 0 : o.loanAmount).subtract(n).subtract(i).value();
65
- },
66
- multiMatchingOrgs() {
67
- var t;
68
- return ((t = this.loan) == null ? void 0 : t.simultaneousMatching) ?? [];
69
- },
70
- isMultipleMatch() {
71
- return this.enableMultiMatching && this.multiMatchingOrgs.length > 1;
72
- },
73
- totalMatchRatio() {
74
- return this.multiMatchingOrgs.reduce((t, n) => t + n.ratio, 1);
75
- },
76
- variation() {
77
- var i, e;
78
- const t = !!((i = this.loan) != null && i.matchingText), n = this.enableMultiMatching && this.multiMatchingOrgs.length > 0;
79
- return t || n ? a.matchedLoan : this.isLseLoan ? a.lseLoan : r(s((e = this.loan) == null ? void 0 : e.plannedExpirationDate), Date.now()) <= 3 ? a.endingSoon : this.amountLeft < 100 && this.amountLeft >= 0 ? a.almostFunded : null;
80
- },
81
- tagText() {
82
- var t;
83
- switch (this.variation) {
84
- case a.lseLoan:
85
- return `${this.useExpandedStyles ? "⚡ " : ""}High community impact`;
86
- case a.almostFunded:
87
- return `${this.useExpandedStyles ? "💸 " : ""}Almost funded`;
88
- case a.matchedLoan: {
89
- if (this.enableMultiMatching && this.multiMatchingOrgs.length === 1) {
90
- const n = this.multiMatchingOrgs[0];
91
- return `${this.useExpandedStyles ? "🤝 " : ""}${n.ratio + 1}x matching by ${this.orgDisplayName(n)}`;
92
- }
93
- return `${this.useExpandedStyles ? "🤝 " : ""}${this.matchRatio + 1}x matching by ${(t = this.loan) == null ? void 0 : t.matchingText}`;
94
- }
95
- default:
96
- return `${this.useExpandedStyles ? "⏰ " : ""}Ending soon: `;
97
- }
98
- },
99
- tagColor() {
100
- if (this.useExpandedStyles)
101
- switch (this.variation) {
102
- case a.almostFunded:
103
- return "#AF741C";
104
- case a.endingSoon:
105
- return "#CE2626";
106
- default:
107
- return "#2B7C5F";
108
- }
109
- return "#CE4A00";
110
- },
111
- matchRatio() {
112
- var t;
113
- return (t = this.loan) == null ? void 0 : t.matchRatio;
114
- }
115
- },
116
- methods: {
117
- orgDisplayName(t) {
118
- return t.displayName && t.displayName !== "Anonymous" ? t.displayName : "a Kiva supporter";
119
- }
120
- }
121
- };
1
+ import h from "./KvLoanTag.js";
2
+ import { KV_LOAN_TAG_FRAGMENT as L } from "./KvLoanTag.js";
3
+ import { resolveComponent as d, openBlock as e, createElementBlock as r, normalizeStyle as _, normalizeClass as w, Fragment as o, createTextVNode as m, toDisplayString as a, createElementVNode as l, createVNode as p, withCtx as y, renderList as k, createBlock as f, createCommentVNode as s } from "vue";
4
+ import x from "../_virtual/_plugin-vue_export-helper.js";
5
+ const v = ["id"], M = { class: "tw-whitespace-nowrap tw-pb-0.5" };
6
+ function N(b, i, c, C, T, t) {
7
+ const u = d("kv-tooltip"), g = d("kv-countdown-timer");
8
+ return t.variation ? (e(), r("div", {
9
+ key: 0,
10
+ class: w(["tw-text-small tw-font-medium tw-pt-0.5", { "tw-line-clamp-1": !t.isMultipleMatch }]),
11
+ style: _({ color: t.tagColor })
12
+ }, [
13
+ t.isMultipleMatch ? (e(), r(o, { key: 0 }, [
14
+ m(a(t.totalMatchRatio) + "x match by ", 1),
15
+ l("span", {
16
+ id: `matching-orgs-${c.loan.id}`,
17
+ class: "tw-underline tw-decoration-dotted tw-cursor-pointer"
18
+ }, a(t.multiMatchingOrgs.length) + " organizations", 9, v),
19
+ p(u, {
20
+ controller: `matching-orgs-${c.loan.id}`,
21
+ "max-width": "320px"
22
+ }, {
23
+ default: y(() => [
24
+ l("p", M, " Your contribution is matched by " + a(t.multiMatchingOrgs.length) + " partners ", 1),
25
+ i[0] || (i[0] = l("hr", { class: "tw-border-caution-highlight tw-py-0.5" }, null, -1)),
26
+ (e(!0), r(o, null, k(t.multiMatchingOrgs, (n) => (e(), r("p", {
27
+ key: n.managedAccountId,
28
+ class: "tw-m-0"
29
+ }, a(n.ratio) + ":1 matching by " + a(t.orgDisplayName(n)), 1))), 128))
30
+ ]),
31
+ _: 1
32
+ }, 8, ["controller"])
33
+ ], 64)) : (e(), r(o, { key: 1 }, [
34
+ m(a(t.tagText) + " ", 1),
35
+ t.variation === "ending-soon" ? (e(), f(g, {
36
+ key: 0,
37
+ deadline: t.deadline
38
+ }, null, 8, ["deadline"])) : s("", !0)
39
+ ], 64))
40
+ ], 6)) : s("", !0);
41
+ }
42
+ const z = /* @__PURE__ */ x(h, [["render", N]]);
122
43
  export {
123
- y as KV_LOAN_TAG_FRAGMENT,
124
- L as default
44
+ L as KV_LOAN_TAG_FRAGMENT,
45
+ z as default
125
46
  };
@@ -1,16 +1,113 @@
1
- import o from "./KvLoanUse2.js";
2
- import { KV_LOAN_USE_FRAGMENT as E } from "./KvLoanUse2.js";
3
- import { openBlock as r, createElementBlock as n } from "vue";
4
- import t from "../_virtual/_plugin-vue_export-helper.js";
5
- const c = ["innerHTML"];
6
- function s(_, p, a, l, m, e) {
7
- return r(), n("p", {
8
- class: "tw-line-clamp-4",
9
- innerHTML: e.loanUse
10
- }, null, 8, c);
11
- }
12
- const u = /* @__PURE__ */ t(o, [["render", s]]);
1
+ import u from "graphql-tag";
2
+ import l from "numeral";
3
+ import { truncateStringByWords as i } from "../utils/loanUtils.js";
4
+ const r = "direct", o = (e) => e.charAt(0).toUpperCase() + e.slice(1), t = (e) => e.charAt(0).toLowerCase() + e.slice(1), m = u`
5
+ fragment KvLoanUse on LoanBasic {
6
+ id
7
+ anonymizationLevel
8
+ use
9
+ loanAmount
10
+ status
11
+ borrowerCount
12
+ name
13
+ distributionModel
14
+ whySpecial
15
+ }
16
+ `, f = {
17
+ name: "KvLoanUse",
18
+ props: {
19
+ anonymizationLevel: {
20
+ type: String,
21
+ default: "none"
22
+ },
23
+ use: {
24
+ type: String,
25
+ default: ""
26
+ },
27
+ loanAmount: {
28
+ type: String,
29
+ default: ""
30
+ },
31
+ status: {
32
+ type: String,
33
+ default: ""
34
+ },
35
+ borrowerCount: {
36
+ type: Number,
37
+ default: 1
38
+ },
39
+ name: {
40
+ type: String,
41
+ default: ""
42
+ },
43
+ distributionModel: {
44
+ type: String,
45
+ default: r
46
+ },
47
+ whySpecial: {
48
+ type: String,
49
+ default: ""
50
+ },
51
+ hideLoanAmount: {
52
+ type: Boolean,
53
+ default: !1
54
+ },
55
+ // Unlike hideLoanAmount, this drops the name and country too and never shows a read-more link.
56
+ hideBorrowerDetails: {
57
+ type: Boolean,
58
+ default: !1
59
+ },
60
+ boldName: {
61
+ type: Boolean,
62
+ default: !1
63
+ },
64
+ country: {
65
+ type: String,
66
+ default: ""
67
+ },
68
+ useIndicativeHelpText: {
69
+ type: Boolean,
70
+ default: !1
71
+ },
72
+ showReadMore: {
73
+ type: Boolean,
74
+ default: !1
75
+ },
76
+ truncateWordsNumber: {
77
+ type: Number,
78
+ default: 0
79
+ }
80
+ },
81
+ computed: {
82
+ helpLanguage() {
83
+ return this.status === "fundraising" || this.status === "inactive" || this.status === "reviewed" ? "helps" : "helped";
84
+ },
85
+ isDirect() {
86
+ return this.distributionModel === r;
87
+ },
88
+ whySpecialSentence() {
89
+ return this.whySpecial ? ` This loan is special because ${t(this.whySpecial)}` : "";
90
+ },
91
+ nameSpan() {
92
+ return this.boldName ? this.country ? `<span class="data-hj-suppress tw-font-medium">${this.name} in ${this.country}</span>` : `<span class="data-hj-suppress tw-font-medium">${this.name}</span>` : `<span class="data-hj-suppress">${this.name}</span>`;
93
+ },
94
+ loanUse() {
95
+ if (this.anonymizationLevel === "full" || this.use.length === 0)
96
+ return "For the borrower's privacy, this loan has been made anonymous.";
97
+ if (this.hideBorrowerDetails)
98
+ return `${o(this.helpLanguage)} ${t(this.use)}${this.whySpecialSentence}`;
99
+ if (this.hideLoanAmount) {
100
+ const n = this.useIndicativeHelpText ? this.helpLanguage : "Help";
101
+ let a = `${o(n)} ${this.nameSpan} ${t(this.use)} ${this.whySpecialSentence}`;
102
+ return this.showReadMore && (a = `${i(a, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), a;
103
+ }
104
+ const e = this.borrowerCount > 1;
105
+ let s = `${l(this.loanAmount).format("$0,0")} ${this.isDirect ? "to" : this.helpLanguage} ${e ? "a member of " : ""}${this.nameSpan} ${this.isDirect ? `${this.helpLanguage} ` : ""}${t(this.use)}${this.whySpecialSentence}`;
106
+ return this.showReadMore && (s = `${i(s, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), s;
107
+ }
108
+ }
109
+ };
13
110
  export {
14
- E as KV_LOAN_USE_FRAGMENT,
15
- u as default
111
+ m as KV_LOAN_USE_FRAGMENT,
112
+ f as default
16
113
  };
@@ -1,113 +1,16 @@
1
- import u from "graphql-tag";
2
- import l from "numeral";
3
- import { truncateStringByWords as i } from "../utils/loanUtils.js";
4
- const r = "direct", o = (e) => e.charAt(0).toUpperCase() + e.slice(1), t = (e) => e.charAt(0).toLowerCase() + e.slice(1), m = u`
5
- fragment KvLoanUse on LoanBasic {
6
- id
7
- anonymizationLevel
8
- use
9
- loanAmount
10
- status
11
- borrowerCount
12
- name
13
- distributionModel
14
- whySpecial
15
- }
16
- `, f = {
17
- name: "KvLoanUse",
18
- props: {
19
- anonymizationLevel: {
20
- type: String,
21
- default: "none"
22
- },
23
- use: {
24
- type: String,
25
- default: ""
26
- },
27
- loanAmount: {
28
- type: String,
29
- default: ""
30
- },
31
- status: {
32
- type: String,
33
- default: ""
34
- },
35
- borrowerCount: {
36
- type: Number,
37
- default: 1
38
- },
39
- name: {
40
- type: String,
41
- default: ""
42
- },
43
- distributionModel: {
44
- type: String,
45
- default: r
46
- },
47
- whySpecial: {
48
- type: String,
49
- default: ""
50
- },
51
- hideLoanAmount: {
52
- type: Boolean,
53
- default: !1
54
- },
55
- // Unlike hideLoanAmount, this drops the name and country too and never shows a read-more link.
56
- hideBorrowerDetails: {
57
- type: Boolean,
58
- default: !1
59
- },
60
- boldName: {
61
- type: Boolean,
62
- default: !1
63
- },
64
- country: {
65
- type: String,
66
- default: ""
67
- },
68
- useIndicativeHelpText: {
69
- type: Boolean,
70
- default: !1
71
- },
72
- showReadMore: {
73
- type: Boolean,
74
- default: !1
75
- },
76
- truncateWordsNumber: {
77
- type: Number,
78
- default: 0
79
- }
80
- },
81
- computed: {
82
- helpLanguage() {
83
- return this.status === "fundraising" || this.status === "inactive" || this.status === "reviewed" ? "helps" : "helped";
84
- },
85
- isDirect() {
86
- return this.distributionModel === r;
87
- },
88
- whySpecialSentence() {
89
- return this.whySpecial ? ` This loan is special because ${t(this.whySpecial)}` : "";
90
- },
91
- nameSpan() {
92
- return this.boldName ? this.country ? `<span class="data-hj-suppress tw-font-medium">${this.name} in ${this.country}</span>` : `<span class="data-hj-suppress tw-font-medium">${this.name}</span>` : `<span class="data-hj-suppress">${this.name}</span>`;
93
- },
94
- loanUse() {
95
- if (this.anonymizationLevel === "full" || this.use.length === 0)
96
- return "For the borrower's privacy, this loan has been made anonymous.";
97
- if (this.hideBorrowerDetails)
98
- return `${o(this.helpLanguage)} ${t(this.use)}${this.whySpecialSentence}`;
99
- if (this.hideLoanAmount) {
100
- const n = this.useIndicativeHelpText ? this.helpLanguage : "Help";
101
- let a = `${o(n)} ${this.nameSpan} ${t(this.use)} ${this.whySpecialSentence}`;
102
- return this.showReadMore && (a = `${i(a, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), a;
103
- }
104
- const e = this.borrowerCount > 1;
105
- let s = `${l(this.loanAmount).format("$0,0")} ${this.isDirect ? "to" : this.helpLanguage} ${e ? "a member of " : ""}${this.nameSpan} ${this.isDirect ? `${this.helpLanguage} ` : ""}${t(this.use)}${this.whySpecialSentence}`;
106
- return this.showReadMore && (s = `${i(s, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), s;
107
- }
108
- }
109
- };
1
+ import o from "./KvLoanUse.js";
2
+ import { KV_LOAN_USE_FRAGMENT as E } from "./KvLoanUse.js";
3
+ import { openBlock as r, createElementBlock as n } from "vue";
4
+ import t from "../_virtual/_plugin-vue_export-helper.js";
5
+ const c = ["innerHTML"];
6
+ function s(_, p, a, l, m, e) {
7
+ return r(), n("p", {
8
+ class: "tw-line-clamp-4",
9
+ innerHTML: e.loanUse
10
+ }, null, 8, c);
11
+ }
12
+ const u = /* @__PURE__ */ t(o, [["render", s]]);
110
13
  export {
111
- m as KV_LOAN_USE_FRAGMENT,
112
- f as default
14
+ E as KV_LOAN_USE_FRAGMENT,
15
+ u as default
113
16
  };
@@ -153,6 +153,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
153
153
  type: BooleanConstructor;
154
154
  default: boolean;
155
155
  };
156
+ preventBackgroundClose: {
157
+ type: BooleanConstructor;
158
+ default: boolean;
159
+ };
160
+ closeButtonShowDelay: {
161
+ type: NumberConstructor;
162
+ default: number;
163
+ };
156
164
  }>, {
157
165
  mdiClose: string;
158
166
  role: import('vue').ComputedRef<"alertdialog" | "dialog">;
@@ -163,6 +171,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
163
171
  hide: (closedBy?: string) => void;
164
172
  show: () => void;
165
173
  controlsRef: import('vue').Ref<any, any>;
174
+ closeButtonClasses: import('vue').ComputedRef<(string | {
175
+ 'tw-invisible tw-opacity-0': boolean;
176
+ })[]>;
166
177
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "lightbox-closed"[], "lightbox-closed", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
167
178
  blurBackground: {
168
179
  type: BooleanConstructor;
@@ -185,6 +196,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
185
196
  type: BooleanConstructor;
186
197
  default: boolean;
187
198
  };
199
+ preventBackgroundClose: {
200
+ type: BooleanConstructor;
201
+ default: boolean;
202
+ };
203
+ closeButtonShowDelay: {
204
+ type: NumberConstructor;
205
+ default: number;
206
+ };
188
207
  }>> & Readonly<{
189
208
  "onLightbox-closed"?: (...args: any[]) => any;
190
209
  }>, {
@@ -192,6 +211,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
192
211
  visible: boolean;
193
212
  preventClose: boolean;
194
213
  blurBackground: boolean;
214
+ preventBackgroundClose: boolean;
215
+ closeButtonShowDelay: number;
195
216
  }, {}, {
196
217
  KvMaterialIcon: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
197
218
  icon: {
@@ -196,6 +196,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
196
196
  type: BooleanConstructor;
197
197
  default: boolean;
198
198
  };
199
+ preventBackgroundClose: {
200
+ type: BooleanConstructor;
201
+ default: boolean;
202
+ };
203
+ closeButtonShowDelay: {
204
+ type: NumberConstructor;
205
+ default: number;
206
+ };
199
207
  }>, {
200
208
  mdiClose: string;
201
209
  role: import('vue').ComputedRef<"alertdialog" | "dialog">;
@@ -206,6 +214,9 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
206
214
  hide: (closedBy?: string) => void;
207
215
  show: () => void;
208
216
  controlsRef: import('vue').Ref<any, any>;
217
+ closeButtonClasses: import('vue').ComputedRef<(string | {
218
+ 'tw-invisible tw-opacity-0': boolean;
219
+ })[]>;
209
220
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "lightbox-closed"[], "lightbox-closed", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
210
221
  blurBackground: {
211
222
  type: BooleanConstructor;
@@ -228,6 +239,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
228
239
  type: BooleanConstructor;
229
240
  default: boolean;
230
241
  };
242
+ preventBackgroundClose: {
243
+ type: BooleanConstructor;
244
+ default: boolean;
245
+ };
246
+ closeButtonShowDelay: {
247
+ type: NumberConstructor;
248
+ default: number;
249
+ };
231
250
  }>> & Readonly<{
232
251
  "onLightbox-closed"?: (...args: any[]) => any;
233
252
  }>, {
@@ -235,6 +254,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
235
254
  visible: boolean;
236
255
  preventClose: boolean;
237
256
  blurBackground: boolean;
257
+ preventBackgroundClose: boolean;
258
+ closeButtonShowDelay: number;
238
259
  }, {}, {
239
260
  KvMaterialIcon: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
240
261
  icon: {