@kiva/kv-components 3.109.4 → 4.0.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.
Files changed (75) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/babel.config.cjs +12 -0
  3. package/dist/components/.storybook/main.js +6 -7
  4. package/dist/components/.storybook/preview.js +9 -17
  5. package/dist/components/KvIntroductionLoanCard.vue +8 -6
  6. package/dist/components/stories/KvActivityRow.stories.js +4 -2
  7. package/dist/components/stories/KvBorrowerImage.stories.js +3 -9
  8. package/dist/components/stories/KvButton.stories.js +17 -19
  9. package/dist/components/stories/KvCartModal.stories.js +2 -5
  10. package/dist/components/stories/KvClassicLoanCard.stories.js +3 -25
  11. package/dist/components/stories/KvContentfulImg.stories.js +28 -51
  12. package/dist/components/stories/KvCountdownTimer.stories.js +3 -2
  13. package/dist/components/stories/KvFlag.stories.js +5 -3
  14. package/dist/components/stories/KvIntroductionLoanCard.stories.js +5 -9
  15. package/dist/components/stories/KvLendCta.stories.js +3 -14
  16. package/dist/components/stories/KvLightbox.stories.js +23 -19
  17. package/dist/components/stories/KvLineGraph.stories.js +3 -2
  18. package/dist/components/stories/KvLoadingSpinner.stories.js +10 -12
  19. package/dist/components/stories/KvLoanActivities.stories.js +3 -4
  20. package/dist/components/stories/KvLoanBookmark.stories.js +3 -2
  21. package/dist/components/stories/KvLoanCallouts.stories.js +3 -2
  22. package/dist/components/stories/KvLoanProgressGroup.stories.js +5 -5
  23. package/dist/components/stories/KvLoanTag.stories.js +3 -2
  24. package/dist/components/stories/KvLoanUse.stories.js +3 -9
  25. package/dist/components/stories/KvMap.stories.js +3 -16
  26. package/dist/components/stories/KvMaterialIcon.stories.js +12 -6
  27. package/dist/components/stories/KvPagination.stories.js +3 -7
  28. package/dist/components/stories/KvPieChart.stories.js +3 -3
  29. package/dist/components/stories/KvProgressBar.stories.js +3 -8
  30. package/dist/components/stories/KvSideSheet.stories.js +2 -1
  31. package/dist/components/stories/KvTextLink.stories.js +5 -9
  32. package/dist/components/stories/KvThemeProvider.stories.js +6 -7
  33. package/dist/components/stories/KvToast.stories.js +10 -16
  34. package/dist/components/stories/KvTreeMapChart.stories.js +3 -3
  35. package/dist/components/stories/KvWideLoanCard.stories.js +3 -17
  36. package/dist/components/stories/StyleguidePrimitives.stories.js +104 -105
  37. package/jest.config.cjs +47 -0
  38. package/package.json +24 -27
  39. package/tests/unit/specs/components/KvButton.spec.js +2 -2
  40. package/tests/unit/specs/components/KvTextLink.spec.js +2 -2
  41. package/tests/unit/utils/addVueRouter.js +9 -15
  42. package/vue/.storybook/main.js +6 -7
  43. package/vue/.storybook/preview.js +9 -17
  44. package/vue/KvIntroductionLoanCard.vue +8 -6
  45. package/vue/stories/KvActivityRow.stories.js +4 -2
  46. package/vue/stories/KvBorrowerImage.stories.js +3 -9
  47. package/vue/stories/KvButton.stories.js +17 -19
  48. package/vue/stories/KvCartModal.stories.js +2 -5
  49. package/vue/stories/KvClassicLoanCard.stories.js +3 -25
  50. package/vue/stories/KvContentfulImg.stories.js +28 -51
  51. package/vue/stories/KvCountdownTimer.stories.js +3 -2
  52. package/vue/stories/KvFlag.stories.js +5 -3
  53. package/vue/stories/KvIntroductionLoanCard.stories.js +5 -9
  54. package/vue/stories/KvLendCta.stories.js +3 -14
  55. package/vue/stories/KvLightbox.stories.js +23 -19
  56. package/vue/stories/KvLineGraph.stories.js +3 -2
  57. package/vue/stories/KvLoadingSpinner.stories.js +10 -12
  58. package/vue/stories/KvLoanActivities.stories.js +3 -4
  59. package/vue/stories/KvLoanBookmark.stories.js +3 -2
  60. package/vue/stories/KvLoanCallouts.stories.js +3 -2
  61. package/vue/stories/KvLoanProgressGroup.stories.js +5 -5
  62. package/vue/stories/KvLoanTag.stories.js +3 -2
  63. package/vue/stories/KvLoanUse.stories.js +3 -9
  64. package/vue/stories/KvMap.stories.js +3 -16
  65. package/vue/stories/KvMaterialIcon.stories.js +12 -6
  66. package/vue/stories/KvPagination.stories.js +3 -7
  67. package/vue/stories/KvPieChart.stories.js +3 -3
  68. package/vue/stories/KvProgressBar.stories.js +3 -8
  69. package/vue/stories/KvSideSheet.stories.js +2 -1
  70. package/vue/stories/KvTextLink.stories.js +5 -9
  71. package/vue/stories/KvThemeProvider.stories.js +6 -7
  72. package/vue/stories/KvToast.stories.js +10 -16
  73. package/vue/stories/KvTreeMapChart.stories.js +3 -3
  74. package/vue/stories/KvWideLoanCard.stories.js +3 -17
  75. package/vue/stories/StyleguidePrimitives.stories.js +104 -105
@@ -6,14 +6,14 @@ export default {
6
6
  };
7
7
 
8
8
  const story = (args) => {
9
- const template = (_args, { argTypes }) => ({
9
+ const template = (templateArgs, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
11
11
  components: { KvLoanProgressGroup },
12
+ setup() { return { args: { ...templateArgs } }; },
12
13
  template: `
13
14
  <div style="width: 200px">
14
15
  <kv-loan-progress-group
15
- :money-left="moneyLeft"
16
- :progress-percent="progressPercent"
16
+ v-bind="args"
17
17
  />
18
18
  </div>
19
19
  `,
@@ -24,6 +24,6 @@ const story = (args) => {
24
24
 
25
25
  export const Default = story();
26
26
 
27
- export const LowAmount = story({ moneyLeft: 5, progressPercent: 0.9 });
27
+ export const LowAmount = story({ moneyLeft: '5', progressPercent: 0.9 });
28
28
 
29
- export const HighAmount = story({ moneyLeft: 150, progressPercent: 0.5 });
29
+ export const HighAmount = story({ moneyLeft: '150', progressPercent: 0.5 });
@@ -7,15 +7,16 @@ export default {
7
7
  };
8
8
 
9
9
  const story = (args) => {
10
- const template = (_args, { argTypes }) => ({
10
+ const template = (templateArgs, { argTypes }) => ({
11
11
  props: Object.keys(argTypes),
12
12
  components: {
13
13
  KvLoanTag,
14
14
  KvCountdownTimer,
15
15
  },
16
+ setup() { return { args: { ...templateArgs } }; },
16
17
  template: `
17
18
  <kv-loan-tag
18
- :loan="loan"
19
+ v-bind="args"
19
20
  />
20
21
  `,
21
22
  });
@@ -6,19 +6,13 @@ export default {
6
6
  };
7
7
 
8
8
  const story = (args) => {
9
- const template = (_args, { argTypes }) => ({
9
+ const template = (templateArgs, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
11
11
  components: { KvLoanUse },
12
+ setup() { return { args: { ...templateArgs } }; },
12
13
  template: `
13
14
  <kv-loan-use
14
- :anonymization-level="anonymizationLevel"
15
- :use="use"
16
- :loan-amount="loanAmount"
17
- :status="status"
18
- :borrower-count="borrowerCount"
19
- :name="name"
20
- :distribution-model="distributionModel"
21
- :why-special="whySpecial"
15
+ v-bind="args"
22
16
  />
23
17
  `,
24
18
  });
@@ -18,26 +18,13 @@ export default {
18
18
  },
19
19
  };
20
20
 
21
- const Template = (args, { argTypes }) => ({
21
+ const Template = (templateArgs, { argTypes }) => ({
22
22
  props: Object.keys(argTypes),
23
23
  components: { KvMap },
24
+ setup() { return { args: { ...templateArgs } }; },
24
25
  template: `<kv-map
25
26
  class="tw-rounded tw-overflow-hidden"
26
- :auto-zoom-delay="autoZoomDelay"
27
- :height="height"
28
- :lat="lat"
29
- :long="long"
30
- :initial-zoom="initialZoom"
31
- :map-id="mapId"
32
- :use-leaflet="useLeaflet"
33
- :width="width"
34
- :zoom-level="zoomLevel"
35
- :advanced-animation="advancedAnimation"
36
- :show-zoom-control="showZoomControl"
37
- :allow-dragging="allowDragging"
38
- :show-labels="showLabels"
39
- :countries-data="countriesData"
40
- :show-fundraising-loans="showFundraisingLoans"
27
+ v-bind="args"
41
28
  />`,
42
29
  });
43
30
 
@@ -49,9 +49,10 @@ Default.args = {
49
49
  icon: mdiCart,
50
50
  };
51
51
 
52
- export const Common = (args, { argTypes }) => ({
52
+ export const Common = (templateArgs, { argTypes }) => ({
53
53
  props: Object.keys(argTypes),
54
54
  components: { KvMaterialIcon },
55
+ setup() { return { args: { ...templateArgs } }; },
55
56
  template: `
56
57
  <div class="tw-flex tw-gap-1">
57
58
  <kv-material-icon
@@ -100,9 +101,10 @@ export const Common = (args, { argTypes }) => ({
100
101
  },
101
102
  });
102
103
 
103
- export const Colored = (args, { argTypes }) => ({
104
+ export const Colored = (templateArgs, { argTypes }) => ({
104
105
  props: Object.keys(argTypes),
105
106
  components: { KvMaterialIcon },
107
+ setup() { return { args: { ...templateArgs } }; },
106
108
  template: `
107
109
  <div>
108
110
  <p class="tw-mb-2">Use text-color to set the icon color</p>
@@ -123,9 +125,10 @@ export const Colored = (args, { argTypes }) => ({
123
125
  },
124
126
  });
125
127
 
126
- export const InlineWithText = (args, { argTypes }) => ({
128
+ export const InlineWithText = (templateArgs, { argTypes }) => ({
127
129
  props: Object.keys(argTypes),
128
130
  components: { KvMaterialIcon },
131
+ setup() { return { args: { ...templateArgs } }; },
129
132
  template: `
130
133
  <a href="#" class="tw-inline-flex">
131
134
  <span class="tw-text-h4">He went thataway</span>
@@ -138,9 +141,10 @@ export const InlineWithText = (args, { argTypes }) => ({
138
141
  },
139
142
  });
140
143
 
141
- export const Sizing = (args, { argTypes }) => ({
144
+ export const Sizing = (templateArgs, { argTypes }) => ({
142
145
  props: Object.keys(argTypes),
143
146
  components: { KvMaterialIcon },
147
+ setup() { return { args: { ...templateArgs } }; },
144
148
  template: `
145
149
  <div>
146
150
  <p class="tw-mb-2">Icons can be sized using any of the standard sizing classes (.tw-w-2, .tw-w-3, .tw-w-full, etc.). By default they are 24 x 24 (.tw-w-3).</p>
@@ -156,9 +160,10 @@ export const Sizing = (args, { argTypes }) => ({
156
160
  },
157
161
  });
158
162
 
159
- export const WithAccessibleText = (args, { argTypes }) => ({
163
+ export const WithAccessibleText = (templateArgs, { argTypes }) => ({
160
164
  props: Object.keys(argTypes),
161
165
  components: { KvMaterialIcon },
166
+ setup() { return { args: { ...templateArgs } }; },
162
167
  template: `
163
168
  <div>
164
169
  <p class="tw-mb-2">If you don't include text and your icon is not decorative, be sure to include screen-reader text</p>
@@ -174,9 +179,10 @@ export const WithAccessibleText = (args, { argTypes }) => ({
174
179
  },
175
180
  });
176
181
 
177
- export const StarsDemo = (args, { argTypes }) => ({
182
+ export const StarsDemo = (templateArgs, { argTypes }) => ({
178
183
  props: Object.keys(argTypes),
179
184
  components: { KvMaterialIcon },
185
+ setup() { return { args: { ...templateArgs } }; },
180
186
  template: `
181
187
  <div class="tw-flex">
182
188
  <button
@@ -6,16 +6,12 @@ export default {
6
6
  };
7
7
 
8
8
  const story = (args) => {
9
- const template = (_args, { argTypes }) => ({
9
+ const template = (templateArgs, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
11
11
  components: { KvPagination },
12
+ setup() { return { args: { ...templateArgs } }; },
12
13
  template: `<kv-pagination
13
- :limit="limit"
14
- :total="total"
15
- :offset="offset"
16
- :extra-pages="extraPages"
17
- :kv-track-function="kvTrackMock"
18
- :track-event-category="trackEventCategory"
14
+ v-bind="args"
19
15
  />`,
20
16
  methods: {
21
17
  kvTrackMock(
@@ -12,18 +12,18 @@ export default {
12
12
  },
13
13
  };
14
14
 
15
- const Template = (args, {
15
+ const Template = (templateArgs, {
16
16
  argTypes,
17
17
  }) => ({
18
18
  props: Object.keys(argTypes),
19
+ setup() { return { args: { ...templateArgs } }; },
19
20
  components: {
20
21
  KvPieChart,
21
22
  },
22
23
  template: `
23
24
  <div>
24
25
  <kv-pie-chart
25
- :values="values"
26
- :loading="loading"
26
+ v-bind="args"
27
27
  />
28
28
  </div>`,
29
29
  });
@@ -13,18 +13,13 @@ export default {
13
13
  },
14
14
  };
15
15
 
16
- const Template = (args, { argTypes }) => ({
16
+ const Template = (templateArgs, { argTypes }) => ({
17
17
  props: Object.keys(argTypes),
18
18
  components: { KvProgressBar },
19
+ setup() { return { args: { ...templateArgs } }; },
19
20
  template: `
20
21
  <kv-progress-bar
21
- :aria-label="ariaLabel"
22
- :min="min"
23
- :max="max"
24
- :value="value"
25
- :variant="variant"
26
- :bg-variant="bgVariant"
27
-
22
+ v-bind="args"
28
23
  ></kv-progress-bar>`,
29
24
  });
30
25
 
@@ -14,6 +14,7 @@ const Template = (args, {
14
14
  KvSideSheet,
15
15
  KvButton,
16
16
  },
17
+ setup() { return { args }; },
17
18
  template: `
18
19
  <div>
19
20
  <kv-button @click="isVisible = true">Show Side Sheet</kv-button>
@@ -47,4 +48,4 @@ const Template = (args, {
47
48
  },
48
49
  });
49
50
 
50
- export const Default = Template.bind({});
51
+ export const Default = Template.bind({ visible: false });
@@ -11,23 +11,19 @@ export default {
11
11
  },
12
12
  argTypes: {
13
13
  state: {
14
- control: {
15
- type: 'select',
16
- options: ['', 'disabled'],
17
- },
14
+ control: 'select',
15
+ options: ['', 'disabled'],
18
16
  },
19
17
  },
20
18
  };
21
19
 
22
- const Template = (args, { argTypes }) => ({
20
+ const Template = (templateArgs, { argTypes }) => ({
23
21
  props: Object.keys(argTypes),
24
22
  components: { KvTextLink },
23
+ setup() { return { args: { ...templateArgs } }; },
25
24
  template: `
26
25
  <kv-text-link
27
- :state="state"
28
- :href="href"
29
- :to="to"
30
- :icon="icon"
26
+ v-bind="args"
31
27
  @click="onClick"
32
28
  >
33
29
  Find a borrower
@@ -32,15 +32,13 @@ export default {
32
32
  title: 'KvThemeProvider',
33
33
  component: KvThemeProvider,
34
34
  args: {
35
- theme: '',
35
+ theme: {},
36
36
  customTheme: null,
37
37
  },
38
38
  argTypes: {
39
39
  theme: {
40
- control: {
41
- type: 'select',
42
- options: ['', 'dark', 'darkGreen', 'mint'],
43
- },
40
+ control: 'select',
41
+ options: ['', 'dark', 'darkGreen', 'mint'],
44
42
  },
45
43
  },
46
44
  };
@@ -117,7 +115,7 @@ const demoTemplate = `
117
115
  </div>
118
116
  `;
119
117
 
120
- const Template = (args, {
118
+ const Template = (templateArgs, {
121
119
  argTypes,
122
120
  }) => ({
123
121
  props: Object.keys(argTypes),
@@ -128,6 +126,7 @@ const Template = (args, {
128
126
  KvTextLink,
129
127
  KvThemeProvider,
130
128
  },
129
+ setup() { return { args: { ...templateArgs } }; },
131
130
  data() {
132
131
  return {
133
132
  bgVariables: buildTailwindClasses('background'),
@@ -141,7 +140,7 @@ const Template = (args, {
141
140
  };
142
141
  },
143
142
  template: `
144
- <kv-theme-provider :theme="theme">
143
+ <kv-theme-provider v-bind="args">
145
144
  ${demoTemplate}
146
145
  </kv-theme-provider>`,
147
146
  });
@@ -11,30 +11,22 @@ export default {
11
11
  },
12
12
  argTypes: {
13
13
  message: {
14
- control: {
15
- type: 'text',
16
- },
14
+ control: 'text',
17
15
  },
18
16
  type: {
19
17
  options: ['confirmation', 'warning', 'error'],
20
- control: {
21
- type: 'select',
22
- },
18
+ control: 'select',
23
19
  },
24
20
  persist: {
25
- control: {
26
- type: 'boolean',
27
- },
21
+ control: 'boolean',
28
22
  },
29
23
  hideDelay: {
30
- control: {
31
- type: 'number',
32
- },
24
+ control: 'number',
33
25
  },
34
26
  },
35
27
  };
36
28
 
37
- const Template = (args, {
29
+ const Template = (templateArgs, {
38
30
  argTypes,
39
31
  }) => ({
40
32
  props: Object.keys(argTypes),
@@ -42,9 +34,10 @@ const Template = (args, {
42
34
  KvToast,
43
35
  KvButton,
44
36
  },
37
+ setup() { return { args: { ...templateArgs } }; },
45
38
  template: `
46
39
  <div>
47
- <kv-button @click="showToast(message, type, persist, hideDelay)">Show Toast</kv-button>
40
+ <kv-button @click="showToast(message, args.type, persist, hideDelay)">Show Toast</kv-button>
48
41
 
49
42
  <!-- div below is a kludge for storybook docs -->
50
43
  <div class="tw-fixed tw-z-toast tw-inset-0 tw-pointer-events-none">
@@ -80,7 +73,7 @@ persist.args = { persist: true };
80
73
  export const hideDelay = Template.bind({});
81
74
  hideDelay.args = { hideDelay: 10000 };
82
75
 
83
- const KivaLogoTemplate = (args, {
76
+ const KivaLogoTemplate = (templateArgs, {
84
77
  argTypes,
85
78
  }) => ({
86
79
  props: Object.keys(argTypes),
@@ -88,9 +81,10 @@ const KivaLogoTemplate = (args, {
88
81
  KvToast,
89
82
  KvButton,
90
83
  },
84
+ setup() { return { args: { ...templateArgs } }; },
91
85
  template: `
92
86
  <div>
93
- <kv-button @click="showToast(message, type, persist)">Show Toast</kv-button>
87
+ <kv-button @click="showToast(message, args.type, persist)">Show Toast</kv-button>
94
88
 
95
89
  <!-- div below is a kludge for storybook docs -->
96
90
  <div class="tw-fixed tw-z-toast tw-inset-0 tw-pointer-events-none">
@@ -12,18 +12,18 @@ export default {
12
12
  },
13
13
  };
14
14
 
15
- const Template = (args, {
15
+ const Template = (templateArgs, {
16
16
  argTypes,
17
17
  }) => ({
18
18
  props: Object.keys(argTypes),
19
19
  components: {
20
20
  KvTreeMapChart,
21
21
  },
22
+ setup() { return { args: { ...templateArgs } }; },
22
23
  template: `
23
24
  <div>
24
25
  <kv-tree-map-chart
25
- :values="values"
26
- :loading="loading"
26
+ v-bind="args"
27
27
  />
28
28
  </div>`,
29
29
  });
@@ -6,28 +6,14 @@ export default {
6
6
  };
7
7
 
8
8
  const story = (args) => {
9
- const template = (_args, { argTypes }) => ({
9
+ const template = (templateArgs, { argTypes }) => ({
10
10
  props: Object.keys(argTypes),
11
11
  components: { KvWideLoanCard },
12
+ setup() { return { args: { ...templateArgs } }; },
12
13
  template: `
13
14
  <div style="max-width: 800px;">
14
15
  <kv-wide-loan-card
15
- :loanId="loanId"
16
- :loan="loan"
17
- :custom-loan-details="customLoanDetails"
18
- :show-tags="showTags"
19
- :category-page-name="categoryPageName"
20
- :enable-five-dollars-notes="enableFiveDollarsNotes"
21
- :five-dollars-selected="fiveDollarsSelected"
22
- :is-adding="isAdding"
23
- :is-visitor="isVisitor"
24
- :basket-items="basketItems"
25
- :is-bookmarked="isBookmarked"
26
- :kv-track-function="kvTrackFunction"
27
- :photo-path="photoPath"
28
- :show-view-loan="showViewLoan"
29
- :custom-callouts="customCallouts"
30
- :enable-huge-amount="enableHugeAmount"
16
+ v-bind="args"
31
17
  />
32
18
  </div>
33
19
  `,