@kiva/kv-components 3.82.1 → 3.83.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.83.0](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.82.1...@kiva/kv-components@3.83.0) (2024-06-07)
7
+
8
+
9
+ ### Features
10
+
11
+ * implement custom loan details on loan card ([#416](https://github.com/kiva/kv-ui-elements/issues/416)) ([13a7a39](https://github.com/kiva/kv-ui-elements/commit/13a7a39ed9d073aa3ee7319b69c6b46f26d45d5b))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.82.1](https://github.com/kiva/kv-ui-elements/compare/@kiva/kv-components@3.82.0...@kiva/kv-components@3.82.1) (2024-06-03)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiva/kv-components",
3
- "version": "3.82.1",
3
+ "version": "3.83.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -75,5 +75,5 @@
75
75
  "optional": true
76
76
  }
77
77
  },
78
- "gitHead": "cde8d379527232294da84dde985729ec92479c65"
78
+ "gitHead": "a248af9b1215451e5b121939976b5340cf3b00bd"
79
79
  }
package/utils/loanCard.js CHANGED
@@ -179,22 +179,26 @@ export function loanCardComputedProperties(props) {
179
179
  };
180
180
  }
181
181
 
182
- export function loanCardMethods(props) {
182
+ export function loanCardMethods(props, emit) {
183
183
  const {
184
184
  loanId,
185
185
  customLoanDetails,
186
186
  kvTrackFunction,
187
187
  } = toRefs(props);
188
188
 
189
- function showLoanDetails(e) {
189
+ function showLoanDetails(event) {
190
190
  if (customLoanDetails.value) {
191
- e.preventDefault();
192
- this.$emit('show-loan-details');
191
+ event.preventDefault();
192
+ emit('show-loan-details');
193
193
  }
194
194
  }
195
195
 
196
- function clickReadMore(target) {
196
+ function clickReadMore(target, event) {
197
197
  kvTrackFunction.value('Lending', 'click-Read more', target, loanId.value);
198
+ if (customLoanDetails.value) {
199
+ event.preventDefault();
200
+ emit('show-loan-details');
201
+ }
198
202
  }
199
203
 
200
204
  return {
@@ -25,7 +25,7 @@
25
25
  :href="readMorePath"
26
26
  class="tw-flex"
27
27
  aria-label="Borrower image"
28
- @click="clickReadMore('Photo')"
28
+ @click.native="clickReadMore('Photo', $event)"
29
29
  >
30
30
  <kv-borrower-image
31
31
  class="
@@ -93,7 +93,7 @@
93
93
  class="tw-flex hover:tw-no-underline focus:tw-no-underline"
94
94
  :class="{ 'tw-px-1': largeCard }"
95
95
  aria-label="Loan tag"
96
- @click="clickReadMore('Tag')"
96
+ @click.native="clickReadMore('Tag', $event)"
97
97
  >
98
98
  <kv-loan-tag
99
99
  v-if="showTags && !isLoading"
@@ -108,7 +108,7 @@
108
108
  :href="readMorePath"
109
109
  class="loan-card-use tw-text-primary"
110
110
  aria-label="Loan use"
111
- @click="clickReadMore('Use')"
111
+ @click.native="clickReadMore('Use', $event)"
112
112
  >
113
113
  <!-- Loan use -->
114
114
  <div class="tw-mb-1.5 tw-pt-1">
@@ -187,7 +187,7 @@
187
187
  :href="readMorePath"
188
188
  class="loan-card-progress tw-mt-1"
189
189
  aria-label="Loan progress"
190
- @click="clickReadMore('Progress')"
190
+ @click.native="clickReadMore('Progress', $event)"
191
191
  >
192
192
  <kv-loan-progress-group
193
193
  id="loanProgress"
@@ -229,7 +229,7 @@
229
229
  class="tw-mt-auto"
230
230
  :class="{ 'tw-w-full' : unreservedAmount <= 0 }"
231
231
  @add-to-basket="$emit('add-to-basket', $event)"
232
- @show-loan-details="clickReadMore('ViewLoan')"
232
+ @show-loan-details="clickReadMore('ViewLoan', $event)"
233
233
  @remove-from-basket="$emit('remove-from-basket', $event)"
234
234
  />
235
235
  </div>
@@ -429,7 +429,7 @@ export default {
429
429
  default: false,
430
430
  },
431
431
  },
432
- setup(props) {
432
+ setup(props, { emit }) {
433
433
  const {
434
434
  allDataLoaded,
435
435
  borrowerName,
@@ -456,7 +456,7 @@ export default {
456
456
  const {
457
457
  clickReadMore,
458
458
  showLoanDetails,
459
- } = loanCardMethods(props);
459
+ } = loanCardMethods(props, emit);
460
460
 
461
461
  return {
462
462
  allDataLoaded,
@@ -35,7 +35,7 @@
35
35
  :href="readMorePath"
36
36
  class="tw-flex"
37
37
  aria-label="Borrower image"
38
- @click="clickReadMore('Photo')"
38
+ @click.native="clickReadMore('Photo', $event)"
39
39
  >
40
40
  <kv-borrower-image
41
41
  class="
@@ -102,7 +102,7 @@
102
102
  :href="readMorePath"
103
103
  class="tw-flex hover:tw-no-underline focus:tw-no-underline"
104
104
  aria-label="Loan tag"
105
- @click="clickReadMore('Tag')"
105
+ @click.native="clickReadMore('Tag', $event)"
106
106
  >
107
107
  <kv-loan-tag
108
108
  v-if="showTags && !isLoading"
@@ -182,7 +182,7 @@
182
182
  :href="readMorePath"
183
183
  class="loan-card-progress tw-mt-1 tw-flex-grow"
184
184
  aria-label="Loan progress"
185
- @click="clickReadMore('Progress')"
185
+ @click.native="clickReadMore('Progress', $event)"
186
186
  >
187
187
  <kv-loan-progress-group
188
188
  id="loanProgress"
@@ -220,7 +220,7 @@
220
220
  class="tw-mt-auto tw-self-end"
221
221
  :class="{'tw-flex-grow' : unreservedAmount === 0, 'tw-flex-shrink-0' : unreservedAmount > 0}"
222
222
  @add-to-basket="$emit('add-to-basket', $event)"
223
- @show-loan-details="clickReadMore('ViewLoan')"
223
+ @show-loan-details="clickReadMore('ViewLoan', $event)"
224
224
  />
225
225
  </div>
226
226
  </div>
@@ -338,7 +338,7 @@ export default {
338
338
  default: false,
339
339
  },
340
340
  },
341
- setup(props) {
341
+ setup(props, { emit }) {
342
342
  const {
343
343
  allDataLoaded,
344
344
  borrowerName,
@@ -365,7 +365,7 @@ export default {
365
365
  const {
366
366
  clickReadMore,
367
367
  showLoanDetails,
368
- } = loanCardMethods(props);
368
+ } = loanCardMethods(props, emit);
369
369
 
370
370
  return {
371
371
  allDataLoaded,
@@ -37,9 +37,15 @@ const story = (args) => {
37
37
  :primary-button-text="primaryButtonText"
38
38
  :secondary-button-text="secondaryButtonText"
39
39
  :secondary-button-handler="secondaryButtonHandler"
40
+ @show-loan-details="showLoanDetails"
40
41
  />
41
42
  </div>
42
43
  `,
44
+ methods: {
45
+ showLoanDetails() {
46
+ console.log('show-loan-details');
47
+ },
48
+ },
43
49
  });
44
50
  template.args = args;
45
51
  return template;
@@ -421,6 +427,18 @@ export const SupportAgain = story({
421
427
  photoPath,
422
428
  });
423
429
 
430
+ export const CustomShowLoanDetails = story({
431
+ loanId: loan.id,
432
+ loan: {
433
+ ...loan,
434
+ userProperties: { lentTo: true },
435
+ },
436
+ primaryButtonText: 'Support',
437
+ kvTrackFunction,
438
+ photoPath,
439
+ customLoanDetails: true,
440
+ });
441
+
424
442
  export const RemoveButton = story({
425
443
  loanId: loan.id,
426
444
  loan,
@@ -428,7 +446,7 @@ export const RemoveButton = story({
428
446
  photoPath,
429
447
  basketItems: [{ id: loan.id, __typename: 'LoanReservation' }],
430
448
  secondaryButtonText: 'Remove Loan',
431
- secondaryButtonHandler: () => {},
449
+ secondaryButtonHandler: () => { },
432
450
  });
433
451
 
434
452
  export const ContributorsAndAmount = story({