@kiva/kv-components 8.0.1 → 8.1.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,6 +1,7 @@
1
- import s from "graphql-tag";
2
- import i from "numeral";
3
- const t = "direct", l = s`
1
+ import r from "graphql-tag";
2
+ import o from "numeral";
3
+ import { truncateStringByWords as a } from "../utils/loanUtils.js";
4
+ const n = "direct", d = r`
4
5
  fragment KvLoanUse on LoanBasic {
5
6
  id
6
7
  anonymizationLevel
@@ -12,7 +13,7 @@ const t = "direct", l = s`
12
13
  distributionModel
13
14
  whySpecial
14
15
  }
15
- `, u = {
16
+ `, m = {
16
17
  name: "KvLoanUse",
17
18
  props: {
18
19
  anonymizationLevel: {
@@ -41,7 +42,7 @@ const t = "direct", l = s`
41
42
  },
42
43
  distributionModel: {
43
44
  type: String,
44
- default: t
45
+ default: n
45
46
  },
46
47
  whySpecial: {
47
48
  type: String,
@@ -62,6 +63,14 @@ const t = "direct", l = s`
62
63
  useIndicativeHelpText: {
63
64
  type: Boolean,
64
65
  default: !1
66
+ },
67
+ showReadMore: {
68
+ type: Boolean,
69
+ default: !1
70
+ },
71
+ truncateWordsNumber: {
72
+ type: Number,
73
+ default: 0
65
74
  }
66
75
  },
67
76
  computed: {
@@ -69,7 +78,7 @@ const t = "direct", l = s`
69
78
  return this.status === "fundraising" || this.status === "inactive" || this.status === "reviewed" ? "helps" : "helped";
70
79
  },
71
80
  isDirect() {
72
- return this.distributionModel === t;
81
+ return this.distributionModel === n;
73
82
  },
74
83
  whySpecialSentence() {
75
84
  return this.whySpecial ? ` This loan is special because ${this.whySpecial.charAt(0).toLowerCase() + this.whySpecial.slice(1)}` : "";
@@ -81,15 +90,17 @@ const t = "direct", l = s`
81
90
  if (this.anonymizationLevel === "full" || this.use.length === 0)
82
91
  return "For the borrower's privacy, this loan has been made anonymous.";
83
92
  if (this.hideLoanAmount) {
84
- const e = this.useIndicativeHelpText ? this.helpLanguage : "Help";
85
- return `${e.charAt(0).toUpperCase() + e.slice(1)} ${this.nameSpan} ${this.use.charAt(0).toLowerCase() + this.use.slice(1)} ${this.whySpecialSentence}`;
93
+ const t = this.useIndicativeHelpText ? this.helpLanguage : "Help";
94
+ let s = `${t.charAt(0).toUpperCase() + t.slice(1)} ${this.nameSpan} ${this.use.charAt(0).toLowerCase() + this.use.slice(1)} ${this.whySpecialSentence}`;
95
+ return this.showReadMore && (s = `${a(s, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), s;
86
96
  }
87
- const a = this.borrowerCount > 1;
88
- return `${i(this.loanAmount).format("$0,0")} ${this.isDirect ? "to" : this.helpLanguage} ${a ? "a member of " : ""}${this.nameSpan} ${this.isDirect ? `${this.helpLanguage} ` : ""}${this.use.charAt(0).toLowerCase() + this.use.slice(1)}${this.whySpecialSentence}`;
97
+ const i = this.borrowerCount > 1;
98
+ let e = `${o(this.loanAmount).format("$0,0")} ${this.isDirect ? "to" : this.helpLanguage} ${i ? "a member of " : ""}${this.nameSpan} ${this.isDirect ? `${this.helpLanguage} ` : ""}${this.use.charAt(0).toLowerCase() + this.use.slice(1)}${this.whySpecialSentence}`;
99
+ return this.showReadMore && (e = `${a(e, this.truncateWordsNumber)} <span class=" tw-text-action tw-underline">read more</span>`), e;
89
100
  }
90
101
  }
91
102
  };
92
103
  export {
93
- l as KV_LOAN_USE_FRAGMENT,
94
- u as default
104
+ d as KV_LOAN_USE_FRAGMENT,
105
+ m as default
95
106
  };
@@ -335,6 +335,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
335
335
  type: BooleanConstructor;
336
336
  default: boolean;
337
337
  };
338
+ showReadMore: {
339
+ type: BooleanConstructor;
340
+ default: boolean;
341
+ };
342
+ truncateWordsNumber: {
343
+ type: NumberConstructor;
344
+ default: number;
345
+ };
338
346
  }>, {}, {}, {
339
347
  helpLanguage(): "helps" | "helped";
340
348
  isDirect(): boolean;
@@ -390,6 +398,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
390
398
  type: BooleanConstructor;
391
399
  default: boolean;
392
400
  };
401
+ showReadMore: {
402
+ type: BooleanConstructor;
403
+ default: boolean;
404
+ };
405
+ truncateWordsNumber: {
406
+ type: NumberConstructor;
407
+ default: number;
408
+ };
393
409
  }>> & Readonly<{}>, {
394
410
  name: string;
395
411
  use: string;
@@ -403,6 +419,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
403
419
  boldName: boolean;
404
420
  country: string;
405
421
  useIndicativeHelpText: boolean;
422
+ showReadMore: boolean;
423
+ truncateWordsNumber: number;
406
424
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
407
425
  KvLoanProgressGroup: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
408
426
  moneyLeft: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "8.0.1",
3
+ "version": "8.1.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -125,5 +125,5 @@
125
125
  "embla-carousel-fade",
126
126
  "popper.js"
127
127
  ],
128
- "gitHead": "af1fc57775a90ad1b0a11069fc84bcc4ab1e2031"
128
+ "gitHead": "75f4f4a2021b1484059f86d7d76eaa6322f25d5c"
129
129
  }