@kiva/kv-components 3.105.3 → 3.107.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/.eslintrc.cjs +1 -0
- package/CHANGELOG.md +22 -0
- package/dist/Alea.cjs +87 -0
- package/dist/Alea.js +63 -0
- package/dist/attrs.cjs +50 -0
- package/dist/attrs.js +26 -0
- package/dist/carousels.cjs +184 -0
- package/dist/carousels.js +147 -0
- package/dist/chunk-HV3AUBFT.js +15 -0
- package/dist/expander.cjs +78 -0
- package/dist/expander.js +53 -0
- package/dist/imageUtils.cjs +54 -0
- package/dist/imageUtils.js +29 -0
- package/dist/loanCard.cjs +222 -0
- package/dist/loanCard.js +200 -0
- package/dist/loanUtils.cjs +170 -0
- package/dist/loanUtils.js +128 -0
- package/dist/mapUtils.cjs +276 -0
- package/dist/mapUtils.js +248 -0
- package/dist/printing.cjs +42 -0
- package/dist/printing.js +17 -0
- package/dist/scrollLock.cjs +54 -0
- package/dist/scrollLock.js +27 -0
- package/dist/throttle.cjs +38 -0
- package/dist/throttle.js +6 -0
- package/dist/touchEvents.cjs +47 -0
- package/dist/touchEvents.js +21 -0
- package/dist/treemap.cjs +133 -0
- package/dist/treemap.js +109 -0
- package/package.json +12 -4
- package/utils/carousels.js +190 -0
- package/vue/KvCarousel.vue +33 -182
- package/vue/KvVerticalCarousel.vue +156 -0
- package/vue/stories/KvVerticalCarousel.stories.js +168 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<section
|
|
4
|
+
ref="rootEl"
|
|
5
|
+
aria-label="carousel"
|
|
6
|
+
class="kv-carousel tw-overflow-hidden tw-relative"
|
|
7
|
+
>
|
|
8
|
+
<!-- Carousel Content -->
|
|
9
|
+
<div
|
|
10
|
+
class="tw-flex tw-flex-col"
|
|
11
|
+
:style="`height: ${heightStyle}`"
|
|
12
|
+
@click.capture="onCarouselContainerClick"
|
|
13
|
+
>
|
|
14
|
+
<div
|
|
15
|
+
v-for="(slotName, index) in componentSlotKeys"
|
|
16
|
+
:key="index"
|
|
17
|
+
role="group"
|
|
18
|
+
:aria-label="`slide ${index + 1} of ${componentSlotKeys.length}`"
|
|
19
|
+
:aria-current="currentIndex === index ? 'true' : 'false'"
|
|
20
|
+
:aria-hidden="isAriaHidden(index)? 'true' : 'false'"
|
|
21
|
+
:tab-index="isAriaHidden(index) ? '-1' : false"
|
|
22
|
+
>
|
|
23
|
+
<slot
|
|
24
|
+
:name="slotName"
|
|
25
|
+
></slot>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</section>
|
|
29
|
+
<!-- Carousel Controls -->
|
|
30
|
+
<div
|
|
31
|
+
class="kv-carousel__controls tw-flex
|
|
32
|
+
tw-justify-between md:tw-justify-center tw-items-center tw-gap-2
|
|
33
|
+
tw-mt-2 tw-w-full"
|
|
34
|
+
>
|
|
35
|
+
<button
|
|
36
|
+
class="tw-text-primary
|
|
37
|
+
tw-rounded-full
|
|
38
|
+
tw-border-2 tw-border-primary
|
|
39
|
+
tw-h-4 tw-w-4
|
|
40
|
+
tw-flex tw-items-center tw-justify-center
|
|
41
|
+
disabled:tw-opacity-low disabled:tw-cursor-default"
|
|
42
|
+
:disabled="embla && !embla.canScrollPrev()"
|
|
43
|
+
@click="handleUserInteraction(previousIndex, 'click-left-arrow')"
|
|
44
|
+
>
|
|
45
|
+
<kv-material-icon
|
|
46
|
+
class="tw-w-4"
|
|
47
|
+
:icon="mdiChevronUp"
|
|
48
|
+
/>
|
|
49
|
+
<span class="tw-sr-only">Show previous slide</span>
|
|
50
|
+
</button>
|
|
51
|
+
<button
|
|
52
|
+
class="tw-text-primary
|
|
53
|
+
tw-rounded-full
|
|
54
|
+
tw-border-2 tw-border-primary
|
|
55
|
+
tw-h-4 tw-w-4
|
|
56
|
+
tw-flex tw-items-center tw-justify-center
|
|
57
|
+
disabled:tw-opacity-low disabled:tw-cursor-default"
|
|
58
|
+
:disabled="embla && !embla.canScrollNext()"
|
|
59
|
+
@click="handleUserInteraction(nextIndex, 'click-right-arrow')"
|
|
60
|
+
>
|
|
61
|
+
<kv-material-icon
|
|
62
|
+
class="tw-w-4"
|
|
63
|
+
:icon="mdiChevronDown"
|
|
64
|
+
/>
|
|
65
|
+
<span class="tw-sr-only">Show next slide</span>
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
import {
|
|
73
|
+
mdiChevronUp,
|
|
74
|
+
mdiChevronDown,
|
|
75
|
+
} from '@mdi/js';
|
|
76
|
+
import { carouselUtil } from '../utils/carousels';
|
|
77
|
+
import KvMaterialIcon from './KvMaterialIcon.vue';
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
components: {
|
|
81
|
+
KvMaterialIcon,
|
|
82
|
+
},
|
|
83
|
+
props: {
|
|
84
|
+
/**
|
|
85
|
+
* Height style declaration of the vertical carousel.
|
|
86
|
+
* */
|
|
87
|
+
heightStyle: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: '400px;',
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Options for the embla carousel - // https://davidcetinkaya.github.io/embla-carousel/api#options
|
|
93
|
+
* */
|
|
94
|
+
emblaOptions: {
|
|
95
|
+
type: Object,
|
|
96
|
+
default() {
|
|
97
|
+
return {};
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* The type of logic to implement when deciding how many slides
|
|
102
|
+
* to scroll when pressing the next/prev button
|
|
103
|
+
* `visible, auto`
|
|
104
|
+
* */
|
|
105
|
+
slidesToScroll: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: 'auto',
|
|
108
|
+
validator: (value) => ['visible', 'auto'].indexOf(value) !== -1,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
emits: [
|
|
112
|
+
'change',
|
|
113
|
+
'interact-carousel',
|
|
114
|
+
],
|
|
115
|
+
setup(props, { emit, slots }) {
|
|
116
|
+
const {
|
|
117
|
+
componentSlotKeys,
|
|
118
|
+
currentIndex,
|
|
119
|
+
embla,
|
|
120
|
+
goToSlide,
|
|
121
|
+
handleUserInteraction,
|
|
122
|
+
isAriaHidden,
|
|
123
|
+
nextIndex,
|
|
124
|
+
onCarouselContainerClick,
|
|
125
|
+
previousIndex,
|
|
126
|
+
reInit,
|
|
127
|
+
reInitVisible,
|
|
128
|
+
rootEl,
|
|
129
|
+
slideIndicatorCount,
|
|
130
|
+
slides,
|
|
131
|
+
} = carouselUtil(props, { emit, slots }, { axis: 'y' });
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
componentSlotKeys,
|
|
135
|
+
currentIndex,
|
|
136
|
+
embla,
|
|
137
|
+
goToSlide,
|
|
138
|
+
handleUserInteraction,
|
|
139
|
+
isAriaHidden,
|
|
140
|
+
mdiChevronDown,
|
|
141
|
+
mdiChevronUp,
|
|
142
|
+
nextIndex,
|
|
143
|
+
onCarouselContainerClick,
|
|
144
|
+
previousIndex,
|
|
145
|
+
reInit,
|
|
146
|
+
reInitVisible,
|
|
147
|
+
rootEl,
|
|
148
|
+
slideIndicatorCount,
|
|
149
|
+
slides,
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
</script>
|
|
154
|
+
|
|
155
|
+
<style scoped>
|
|
156
|
+
</style>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import KvVerticalCarousel from '../KvVerticalCarousel.vue';
|
|
2
|
+
import KvButton from '../KvButton.vue';
|
|
3
|
+
|
|
4
|
+
const randomHexColor = (index) => {
|
|
5
|
+
const defaultColor = '96d4b3';
|
|
6
|
+
const colorArray = [
|
|
7
|
+
'D5573B',
|
|
8
|
+
'885053',
|
|
9
|
+
'777DA7',
|
|
10
|
+
'94C9A9',
|
|
11
|
+
'C6ECAE',
|
|
12
|
+
'C490D1',
|
|
13
|
+
'A0D2DB',
|
|
14
|
+
'7D8CC4',
|
|
15
|
+
'726DA8',
|
|
16
|
+
];
|
|
17
|
+
return colorArray?.[index] || defaultColor;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// This is not an actual loan card template, just a vague
|
|
21
|
+
// approximation to make testing in the stories nicer
|
|
22
|
+
const generateLoanCardTemplate = (index) => {
|
|
23
|
+
const amounts = [
|
|
24
|
+
'100',
|
|
25
|
+
'2,255',
|
|
26
|
+
'50',
|
|
27
|
+
'41,900',
|
|
28
|
+
];
|
|
29
|
+
const cardCopy = [
|
|
30
|
+
'A loan of $5,450 helps a member to buy flour, eggs, lard, sugar, sweets and other...',
|
|
31
|
+
'A loan of $1,125 helps to face the financial problem of covering tuition fees.',
|
|
32
|
+
'A loan of $450 helps to purchase store goods for resale.',
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
return `
|
|
36
|
+
<div style="width: 336px">
|
|
37
|
+
<img src="https://placehold.co/336x252/${randomHexColor(index)}/000000" class="tw-w-full tw-rounded tw-mb-2">
|
|
38
|
+
<h3>Card Title</h3>
|
|
39
|
+
<h4 class="tw-my-1">$${amounts?.[index] || amounts?.[1]} to go</h4>
|
|
40
|
+
<p class="tw-mt-1 tw-mb-9">${cardCopy?.[index] || cardCopy?.[1]}</p>
|
|
41
|
+
<kv-button
|
|
42
|
+
variant="primary"
|
|
43
|
+
>
|
|
44
|
+
Read more
|
|
45
|
+
</kv-button>
|
|
46
|
+
</div>`;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const defaultCarouselSlides = `
|
|
50
|
+
<template #slide1>
|
|
51
|
+
<img src="https://placehold.co/400x150/${randomHexColor(1)}/000000">
|
|
52
|
+
</template>
|
|
53
|
+
<template #slide2>
|
|
54
|
+
<img src="https://placehold.co/400x150/${randomHexColor(2)}/000000">
|
|
55
|
+
</template>
|
|
56
|
+
<template #slide3>
|
|
57
|
+
<img src="https://placehold.co/400x150/${randomHexColor(3)}/000000">
|
|
58
|
+
</template>
|
|
59
|
+
<template #slide4>
|
|
60
|
+
<img src="https://placehold.co/400x150/${randomHexColor(4)}/000000">
|
|
61
|
+
</template>
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
title: 'KvVerticalCarousel',
|
|
66
|
+
component: KvVerticalCarousel,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const Default = () => ({
|
|
70
|
+
components: {
|
|
71
|
+
KvVerticalCarousel,
|
|
72
|
+
},
|
|
73
|
+
template: `
|
|
74
|
+
<div style="width: 400px;">
|
|
75
|
+
<kv-vertical-carousel height-style="310px" class="tw-w-full">
|
|
76
|
+
${defaultCarouselSlides}
|
|
77
|
+
</kv-vertical-carousel>
|
|
78
|
+
</div>
|
|
79
|
+
`,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const LoopFalse = () => ({
|
|
83
|
+
components: {
|
|
84
|
+
KvVerticalCarousel,
|
|
85
|
+
},
|
|
86
|
+
template: `
|
|
87
|
+
<div style="width: 400px;">
|
|
88
|
+
<kv-vertical-carousel height-style="400px" class="tw-w-full">
|
|
89
|
+
${defaultCarouselSlides}
|
|
90
|
+
</kv-vertical-carousel>
|
|
91
|
+
</div>
|
|
92
|
+
`,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
export const MultipleLoanCards = () => ({
|
|
96
|
+
components: {
|
|
97
|
+
KvVerticalCarousel,
|
|
98
|
+
KvButton,
|
|
99
|
+
},
|
|
100
|
+
template: `
|
|
101
|
+
<kv-vertical-carousel
|
|
102
|
+
:embla-options="{ loop: false }"
|
|
103
|
+
:multiple-slides-visible="true"
|
|
104
|
+
style="max-width: 600px;"
|
|
105
|
+
height-style="510px"
|
|
106
|
+
class="tw-w-full"
|
|
107
|
+
>
|
|
108
|
+
<template #slide1>
|
|
109
|
+
${generateLoanCardTemplate(1)}
|
|
110
|
+
</template>
|
|
111
|
+
<template #slide2>
|
|
112
|
+
${generateLoanCardTemplate(2)}
|
|
113
|
+
</template>
|
|
114
|
+
<template #slide3>
|
|
115
|
+
${generateLoanCardTemplate(3)}
|
|
116
|
+
</template>
|
|
117
|
+
<template #slide4>
|
|
118
|
+
${generateLoanCardTemplate(4)}
|
|
119
|
+
</template>
|
|
120
|
+
<template #slide5>
|
|
121
|
+
${generateLoanCardTemplate(5)}
|
|
122
|
+
</template>
|
|
123
|
+
</kv-vertical-carousel>
|
|
124
|
+
`,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const CustomStartIndex = () => ({
|
|
128
|
+
components: {
|
|
129
|
+
KvVerticalCarousel,
|
|
130
|
+
KvButton,
|
|
131
|
+
},
|
|
132
|
+
template: `
|
|
133
|
+
<kv-vertical-carousel
|
|
134
|
+
:embla-options="{ loop: false, align: 'center', startIndex: 1 }"
|
|
135
|
+
:multiple-slides-visible="true"
|
|
136
|
+
slides-to-scroll="visible"
|
|
137
|
+
style="max-width: 1072px;"
|
|
138
|
+
>
|
|
139
|
+
<template #slide1>
|
|
140
|
+
${generateLoanCardTemplate(1)}
|
|
141
|
+
</template>
|
|
142
|
+
<template #slide2>
|
|
143
|
+
${generateLoanCardTemplate(2)}
|
|
144
|
+
</template>
|
|
145
|
+
<template #slide3>
|
|
146
|
+
${generateLoanCardTemplate(3)}
|
|
147
|
+
</template>
|
|
148
|
+
<template #slide4>
|
|
149
|
+
${generateLoanCardTemplate(4)}
|
|
150
|
+
</template>
|
|
151
|
+
<template #slide5>
|
|
152
|
+
${generateLoanCardTemplate(5)}
|
|
153
|
+
</template>
|
|
154
|
+
<template #slide6>
|
|
155
|
+
${generateLoanCardTemplate(6)}
|
|
156
|
+
</template>
|
|
157
|
+
<template #slide7>
|
|
158
|
+
${generateLoanCardTemplate(7)}
|
|
159
|
+
</template>
|
|
160
|
+
<template #slide8>
|
|
161
|
+
${generateLoanCardTemplate(8)}
|
|
162
|
+
</template>
|
|
163
|
+
<template #slide9>
|
|
164
|
+
${generateLoanCardTemplate(9)}
|
|
165
|
+
</template>
|
|
166
|
+
</kv-vertical-carousel>
|
|
167
|
+
`,
|
|
168
|
+
});
|