classcard-ui 0.2.705 → 0.2.708
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/README.md +24 -24
- package/dist/classcard-ui.common.js +68 -75
- package/dist/classcard-ui.common.js.map +1 -1
- package/dist/classcard-ui.umd.js +68 -75
- package/dist/classcard-ui.umd.js.map +1 -1
- package/dist/classcard-ui.umd.min.js +1 -1
- package/dist/classcard-ui.umd.min.js.map +1 -1
- package/package.json +81 -81
- package/src/App.vue +16 -16
- package/src/components/CAlerts/CAlerts.vue +70 -70
- package/src/components/CAlerts/index.js +2 -2
- package/src/components/CAnchorTabs/CAnchorTabs.vue +96 -96
- package/src/components/CAnchorTabs/index.js +2 -2
- package/src/components/CAnchorTag/CAnchorTag.vue +62 -62
- package/src/components/CAnchorTag/index.js +2 -2
- package/src/components/CAvatar/CAvatar.vue +112 -112
- package/src/components/CAvatar/index.js +2 -2
- package/src/components/CAvatarGroup/CAvatarGroup.vue +145 -145
- package/src/components/CAvatarGroup/index.js +2 -2
- package/src/components/CBasicTable/CBasicTable.vue +184 -184
- package/src/components/CBasicTable/index.js +2 -2
- package/src/components/CBreadcrumbs/CBreadcrumbs.vue +38 -38
- package/src/components/CBreadcrumbs/index.js +2 -2
- package/src/components/CButton/CButton.vue +147 -147
- package/src/components/CButton/index.js +2 -2
- package/src/components/CButtonGroup/CButtonGroup.vue +116 -116
- package/src/components/CButtonGroup/index.js +2 -2
- package/src/components/CButtonIcon/CButtonIcon.vue +91 -91
- package/src/components/CButtonIcon/index.js +2 -2
- package/src/components/CButtonLink/CButtonLink.vue +39 -39
- package/src/components/CButtonLink/index.js +2 -2
- package/src/components/CButtonSelect/CButtonSelect.vue +103 -103
- package/src/components/CButtonSelect/index.js +2 -2
- package/src/components/CButtonWithDropdown/CButtonWithDropdown.vue +168 -168
- package/src/components/CButtonWithDropdown/index.js +2 -2
- package/src/components/CCalendar/CCalendar.vue +401 -401
- package/src/components/CCalendar/index.js +3 -3
- package/src/components/CCard/CCard.vue +49 -49
- package/src/components/CCard/index.js +2 -2
- package/src/components/CCheckbox/CCheckbox.vue +70 -70
- package/src/components/CCheckbox/index.js +2 -2
- package/src/components/CCollapsibleSection/CCollapsibleSection.vue +99 -99
- package/src/components/CCollapsibleSection/index.js +2 -2
- package/src/components/CColorDots/CColorDots.vue +35 -35
- package/src/components/CColorDots/index.js +3 -3
- package/src/components/CConfirmActionModal/CConfirmActionModal.vue +120 -120
- package/src/components/CConfirmActionModal/index.js +3 -3
- package/src/components/CDatepicker/CDatepicker.vue +139 -139
- package/src/components/CDatepicker/index.js +2 -2
- package/src/components/CDualSelect/CDualSelect.vue +193 -193
- package/src/components/CDualSelect/index.js +2 -2
- package/src/components/CEditor/CEditor.vue +96 -96
- package/src/components/CEditor/index.js +2 -2
- package/src/components/CFormSectionHeading/CFormSectionHeading.vue +53 -53
- package/src/components/CFormSectionHeading/index.js +2 -2
- package/src/components/CGroupedSelect/CGroupedSelect.vue +217 -217
- package/src/components/CGroupedSelect/index.js +3 -3
- package/src/components/CIcon/CIcon.vue +77 -77
- package/src/components/CIcon/index.js +2 -2
- package/src/components/CIconDropdown/CIconDropdown.vue +111 -111
- package/src/components/CIconDropdown/index.js +2 -2
- package/src/components/CInput/CInput.vue +120 -120
- package/src/components/CInput/index.js +2 -2
- package/src/components/CInputAddon/CInputAddon.vue +202 -202
- package/src/components/CInputAddon/index.js +2 -2
- package/src/components/CInputEmail/CInputEmail.vue +93 -93
- package/src/components/CInputEmail/index.js +2 -2
- package/src/components/CModalHeading/CModalHeading.vue +22 -22
- package/src/components/CModalHeading/index.js +2 -2
- package/src/components/CModuleHelpLinks/CModuleHelpLinks.vue +39 -39
- package/src/components/CModuleHelpLinks/index.js +3 -3
- package/src/components/CMultiselect/CMultiselect.vue +339 -339
- package/src/components/CMultiselect/index.js +2 -2
- package/src/components/CMultiselectr/CMultiselectr.vue +44 -44
- package/src/components/CMultiselectr/index.js +2 -2
- package/src/components/CPageHeading/CPageHeading.vue +56 -56
- package/src/components/CPageHeading/index.js +2 -2
- package/src/components/CPagination/CPagination.vue +202 -202
- package/src/components/CPagination/index.js +2 -2
- package/src/components/CPhoneNumber/CPhoneNumber.vue +81 -81
- package/src/components/CPhoneNumber/index.js +2 -2
- package/src/components/CRadio/CRadio.vue +106 -106
- package/src/components/CRadio/index.js +2 -2
- package/src/components/CRangeSlider/CRangeSlider.vue +55 -55
- package/src/components/CRangeSlider/index.js +2 -2
- package/src/components/CReorderableStackedList/CReorderableStackedList.vue +94 -94
- package/src/components/CReorderableStackedList/index.js +2 -2
- package/src/components/CSelect/CSelect.vue +348 -343
- package/src/components/CSelect/index.js +2 -2
- package/src/components/CSmallTimeline/CSmallTimeline.vue +40 -40
- package/src/components/CSmallTimeline/index.js +2 -2
- package/src/components/CStackedList/CStackedList.vue +132 -132
- package/src/components/CStackedList/index.js +2 -2
- package/src/components/CStats/CStats.vue +111 -111
- package/src/components/CStats/index.js +2 -2
- package/src/components/CSwitch/CSwitch.vue +140 -140
- package/src/components/CSwitch/index.js +2 -2
- package/src/components/CTable/CTable.vue +536 -536
- package/src/components/CTable/index.js +2 -2
- package/src/components/CTabs/CTabs.vue +111 -111
- package/src/components/CTabs/index.js +2 -2
- package/src/components/CTag/CTag.vue +36 -36
- package/src/components/CTag/index.js +2 -2
- package/src/components/CTextarea/CTextarea.vue +95 -95
- package/src/components/CTextarea/index.js +2 -2
- package/src/components/CTimeline/CTimeline.vue +237 -237
- package/src/components/CTimeline/index.js +2 -2
- package/src/components/CUpload/CUpload.vue +231 -231
- package/src/components/CUpload/index.js +2 -2
- package/src/components/index.js +48 -48
- package/src/icons.js +285 -285
- package/src/main.js +22 -22
- package/src/stories/CAlerts.stories.js +37 -37
- package/src/stories/CAnchorTabs.stories.js +29 -29
- package/src/stories/CAnchorTag.stories.js +36 -36
- package/src/stories/CAvatar.stories.js +38 -38
- package/src/stories/CAvatarGroup.stories.js +100 -100
- package/src/stories/CBasicTable.stories.js +316 -316
- package/src/stories/CBreadcrumbs.stories.js +24 -24
- package/src/stories/CButton.stories.js +46 -46
- package/src/stories/CButtonGroup.stories.js +33 -33
- package/src/stories/CButtonIcon.stories.js +27 -27
- package/src/stories/CButtonLink.stories.js +24 -24
- package/src/stories/CButtonSelect.stories.js +32 -32
- package/src/stories/CButtonWithDropdown.stories.js +41 -41
- package/src/stories/CCalendar.stories.js +16 -16
- package/src/stories/CCard.stories.js +30 -30
- package/src/stories/CCheckbox.stories.js +29 -29
- package/src/stories/CCollapsibleSection.stories.js +28 -28
- package/src/stories/CColorDots.stories.js +28 -28
- package/src/stories/CConfirmActionModal.stories.js +59 -59
- package/src/stories/CDatepicker.stories.js +30 -30
- package/src/stories/CDualSelect.stories.js +29 -29
- package/src/stories/CEditor.stories.js +30 -30
- package/src/stories/CFormSectionHeading.stories.js +34 -34
- package/src/stories/CGroupedSelect.stories.js +69 -69
- package/src/stories/CIcon.stories.js +26 -26
- package/src/stories/CIconDropdown.stories.js +39 -39
- package/src/stories/CInput.stories.js +36 -36
- package/src/stories/CInputAddon.stories.js +37 -37
- package/src/stories/CInputEmail.stories.js +27 -27
- package/src/stories/CModalHeading.stories.js +25 -25
- package/src/stories/CModuleHelpLinks.stories.js +25 -25
- package/src/stories/CMultiselect.stories.js +97 -97
- package/src/stories/CMultiselectr.stories.js +23 -23
- package/src/stories/CPageHeading.stories.js +32 -32
- package/src/stories/CPagination.stories.js +30 -30
- package/src/stories/CPhoneNumber.stories.js +29 -29
- package/src/stories/CRadio.stories.js +36 -36
- package/src/stories/CRangeSlider.stories.js +23 -23
- package/src/stories/CReorderableStackedList.stories.js +23 -23
- package/src/stories/CSelect.stories.js +50 -50
- package/src/stories/CSmallTimeline.stories.js +26 -26
- package/src/stories/CStackedList.stories.js +37 -37
- package/src/stories/CStats.stories.js +33 -33
- package/src/stories/CSwitch.stories.js +28 -28
- package/src/stories/CTable.stories.js +77 -77
- package/src/stories/CTabs.stories.js +33 -33
- package/src/stories/CTag.stories.js +23 -23
- package/src/stories/CTextarea.stories.js +32 -32
- package/src/stories/CTimeline.stories.js +26 -26
- package/src/stories/CUpload.stories.js +36 -36
- package/src/stories/Introduction.stories.mdx +207 -207
- package/src/stories/Page.vue +88 -88
- package/src/stories/assets/code-brackets.svg +0 -0
- package/src/stories/assets/colors.svg +0 -0
- package/src/stories/assets/comments.svg +0 -0
- package/src/stories/assets/direction.svg +0 -0
- package/src/stories/assets/flow.svg +0 -0
- package/src/stories/assets/plugin.svg +0 -0
- package/src/stories/assets/repo.svg +0 -0
- package/src/stories/assets/stackalt.svg +0 -0
- package/src/stories/header.css +26 -26
- package/src/stories/page.css +69 -69
- package/src/stories/utils.css +17 -17
|
@@ -1,339 +1,339 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="flex w-full items-center justify-between" v-if="label">
|
|
4
|
-
<div class="flex items-center">
|
|
5
|
-
<!-- label of multiselect field -->
|
|
6
|
-
<label v-if="label" class="text-sm font-medium text-gray-900">{{ label }}</label>
|
|
7
|
-
<!-- asterisk sign to render if field is required -->
|
|
8
|
-
<p v-if="isRequired" class="ml-1 text-red-600">*</p>
|
|
9
|
-
</div>
|
|
10
|
-
<span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
|
|
11
|
-
</div>
|
|
12
|
-
<v-select
|
|
13
|
-
class="disabled-opacity-50 disabled-pointer-events-none disabled-cursor-default mt-1 text-sm"
|
|
14
|
-
:placeholder="placeholder"
|
|
15
|
-
:multiple="isMultiple"
|
|
16
|
-
:taggable="isTaggable"
|
|
17
|
-
:push-tags="pushTags"
|
|
18
|
-
:filterable="filterable"
|
|
19
|
-
v-model="value"
|
|
20
|
-
:options="options"
|
|
21
|
-
@input="setSelectedOptions"
|
|
22
|
-
@search="fetchOptions"
|
|
23
|
-
@search:focus="$emit('search:focus')"
|
|
24
|
-
:label="optionLabel"
|
|
25
|
-
:clearable="clearable"
|
|
26
|
-
:loading="loading"
|
|
27
|
-
@open="onOpen"
|
|
28
|
-
@close="onClose"
|
|
29
|
-
:disabled="isDisabled"
|
|
30
|
-
>
|
|
31
|
-
<template #open-indicator="{ attributes }">
|
|
32
|
-
<span v-bind="attributes">
|
|
33
|
-
<svg
|
|
34
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
-
class="h-5 w-5 cursor-pointer text-gray-400"
|
|
36
|
-
viewBox="0 0 20 20"
|
|
37
|
-
fill="currentColor"
|
|
38
|
-
>
|
|
39
|
-
<path
|
|
40
|
-
fill-rule="evenodd"
|
|
41
|
-
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
42
|
-
clip-rule="evenodd"
|
|
43
|
-
/>
|
|
44
|
-
</svg>
|
|
45
|
-
</span>
|
|
46
|
-
</template>
|
|
47
|
-
<!-- eslint-disable-next-line vue/no-unused-vars -->
|
|
48
|
-
<template #no-options="{ search, searching, loading }">
|
|
49
|
-
<span v-if="search.length < 1">Start typing to search for options...</span>
|
|
50
|
-
<span v-else>No options found, try searching something else.</span>
|
|
51
|
-
</template>
|
|
52
|
-
<template #spinner="{ loading }">
|
|
53
|
-
<svg
|
|
54
|
-
class="h-5 w-5 animate-spin text-gray-400"
|
|
55
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
56
|
-
fill="none"
|
|
57
|
-
viewBox="0 0 24 24"
|
|
58
|
-
v-if="loading"
|
|
59
|
-
>
|
|
60
|
-
<circle
|
|
61
|
-
class="opacity-25"
|
|
62
|
-
cx="12"
|
|
63
|
-
cy="12"
|
|
64
|
-
r="10"
|
|
65
|
-
stroke="currentColor"
|
|
66
|
-
stroke-width="4"
|
|
67
|
-
></circle>
|
|
68
|
-
<path
|
|
69
|
-
class="opacity-75"
|
|
70
|
-
fill="currentColor"
|
|
71
|
-
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
72
|
-
></path>
|
|
73
|
-
</svg>
|
|
74
|
-
</template>
|
|
75
|
-
<template slot="option" slot-scope="option">
|
|
76
|
-
<slot name="custom-option" v-bind:option="option"></slot>
|
|
77
|
-
</template>
|
|
78
|
-
<template v-if="showOptionImage" v-slot:option="option">
|
|
79
|
-
<div :class="`flex w-full ${option.description ? 'items-start' : 'items-center'}`">
|
|
80
|
-
<c-avatar
|
|
81
|
-
v-if="option.image"
|
|
82
|
-
size="extraextrasmall"
|
|
83
|
-
:image="option.image"
|
|
84
|
-
:rounded="true"
|
|
85
|
-
:description="option.description"
|
|
86
|
-
class="mr-2"
|
|
87
|
-
></c-avatar>
|
|
88
|
-
<c-avatar
|
|
89
|
-
v-else
|
|
90
|
-
size="extraextrasmall"
|
|
91
|
-
:nameInitials="option.initials"
|
|
92
|
-
:description="option.description"
|
|
93
|
-
:rounded="true"
|
|
94
|
-
class="mr-2"
|
|
95
|
-
></c-avatar>
|
|
96
|
-
<div class="w-full">
|
|
97
|
-
<p>{{ option[optionLabel] }}</p>
|
|
98
|
-
<p class="text-xs" v-if="option.description">
|
|
99
|
-
{{ option.description }}
|
|
100
|
-
</p>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</template>
|
|
104
|
-
<template #list-footer>
|
|
105
|
-
<li ref="load" class="loader" v-show="hasNextPage">Loading more options...</li>
|
|
106
|
-
<li
|
|
107
|
-
v-if="showFooterButton"
|
|
108
|
-
class="group sticky bottom-0 mt-1 cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
|
|
109
|
-
id="listbox-option-0"
|
|
110
|
-
role="option"
|
|
111
|
-
@click="$emit('footerButtonClick')"
|
|
112
|
-
>
|
|
113
|
-
<div class="flex items-center">
|
|
114
|
-
<svg
|
|
115
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
116
|
-
class="h-6 w-6 flex-shrink-0 text-gray-400"
|
|
117
|
-
viewBox="0 0 20 20"
|
|
118
|
-
fill="currentColor"
|
|
119
|
-
>
|
|
120
|
-
<path
|
|
121
|
-
fill-rule="evenodd"
|
|
122
|
-
d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2H7a1 1 0 100 2h2v2a1 1 0 102 0v-2h2a1 1 0 100-2h-2V7z"
|
|
123
|
-
clip-rule="evenodd"
|
|
124
|
-
/>
|
|
125
|
-
</svg>
|
|
126
|
-
<span class="ml-3 block truncate font-semibold">
|
|
127
|
-
{{ footerButtonText }}
|
|
128
|
-
</span>
|
|
129
|
-
</div>
|
|
130
|
-
</li>
|
|
131
|
-
</template>
|
|
132
|
-
</v-select>
|
|
133
|
-
|
|
134
|
-
<p v-if="subLabel" class="mt-1 text-sm text-gray-500">{{ subLabel }}</p>
|
|
135
|
-
<p v-if="!isValidate" class="mt-1 text-sm text-red-600">
|
|
136
|
-
{{ errorMessage }}
|
|
137
|
-
</p>
|
|
138
|
-
<p v-if="helpText && isValidate == true" class="mt-1 text-sm text-gray-500">
|
|
139
|
-
{{ helpText }}
|
|
140
|
-
</p>
|
|
141
|
-
</div>
|
|
142
|
-
</template>
|
|
143
|
-
<script>
|
|
144
|
-
import vSelect from "vue-select";
|
|
145
|
-
import CAvatar from "../CAvatar/CAvatar.vue";
|
|
146
|
-
import { debounce } from "lodash-es";
|
|
147
|
-
// import Fuse from "fuse.js";
|
|
148
|
-
import "vue-select/dist/vue-select.css";
|
|
149
|
-
export default {
|
|
150
|
-
name: "CMultiselect",
|
|
151
|
-
components: { vSelect, CAvatar },
|
|
152
|
-
props: {
|
|
153
|
-
options: {
|
|
154
|
-
type: Array,
|
|
155
|
-
required: true,
|
|
156
|
-
},
|
|
157
|
-
showFooterButton: {
|
|
158
|
-
type: Boolean,
|
|
159
|
-
default: false,
|
|
160
|
-
},
|
|
161
|
-
footerButtonText: {
|
|
162
|
-
type: String,
|
|
163
|
-
default: "",
|
|
164
|
-
},
|
|
165
|
-
label: String,
|
|
166
|
-
isRequired: {
|
|
167
|
-
type: Boolean,
|
|
168
|
-
},
|
|
169
|
-
subLabel: String,
|
|
170
|
-
placeholder: {
|
|
171
|
-
type: String,
|
|
172
|
-
default: "Start typing... (min 2 characters) to search options",
|
|
173
|
-
},
|
|
174
|
-
// whether multiple fields are allowed or not
|
|
175
|
-
isMultiple: {
|
|
176
|
-
type: Boolean,
|
|
177
|
-
},
|
|
178
|
-
// append newly created tags in options
|
|
179
|
-
pushTags: {
|
|
180
|
-
type: Boolean,
|
|
181
|
-
},
|
|
182
|
-
// whether to allow user to create new options
|
|
183
|
-
isTaggable: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
},
|
|
186
|
-
getOptions: {
|
|
187
|
-
// function to emit on search{
|
|
188
|
-
type: Function,
|
|
189
|
-
},
|
|
190
|
-
customiseOption: {
|
|
191
|
-
type: Boolean,
|
|
192
|
-
},
|
|
193
|
-
// whether to show profile picture in option
|
|
194
|
-
showOptionImage: {
|
|
195
|
-
type: Boolean,
|
|
196
|
-
},
|
|
197
|
-
// the name of the option to render in the selectpicker
|
|
198
|
-
optionLabel: {
|
|
199
|
-
type: String,
|
|
200
|
-
},
|
|
201
|
-
// action to trigger after selecting option from dropdown
|
|
202
|
-
onSelectOptions: {
|
|
203
|
-
type: Function,
|
|
204
|
-
},
|
|
205
|
-
optionsSelected: {
|
|
206
|
-
type: [Array, Object],
|
|
207
|
-
},
|
|
208
|
-
filterable: {
|
|
209
|
-
type: Boolean,
|
|
210
|
-
default: false,
|
|
211
|
-
},
|
|
212
|
-
clearable: {
|
|
213
|
-
type: Boolean,
|
|
214
|
-
default: true,
|
|
215
|
-
},
|
|
216
|
-
isValidate: {
|
|
217
|
-
type: Boolean,
|
|
218
|
-
default: true,
|
|
219
|
-
},
|
|
220
|
-
errorMessage: {
|
|
221
|
-
type: String,
|
|
222
|
-
},
|
|
223
|
-
loading: {
|
|
224
|
-
type: Boolean,
|
|
225
|
-
default: false,
|
|
226
|
-
},
|
|
227
|
-
hasNextPage: {
|
|
228
|
-
type: Boolean,
|
|
229
|
-
default: false,
|
|
230
|
-
},
|
|
231
|
-
isDisabled: {
|
|
232
|
-
type: Boolean,
|
|
233
|
-
default: false,
|
|
234
|
-
},
|
|
235
|
-
// text adjacent to label of dropdown to provide hint about field
|
|
236
|
-
hint: { type: String },
|
|
237
|
-
helpText: {
|
|
238
|
-
type: String,
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
computed: {},
|
|
242
|
-
data() {
|
|
243
|
-
return {
|
|
244
|
-
loaderSearching: true,
|
|
245
|
-
value: this.optionsSelected && this.optionsSelected.length ? this.optionsSelected : [],
|
|
246
|
-
observer: null,
|
|
247
|
-
};
|
|
248
|
-
},
|
|
249
|
-
methods: {
|
|
250
|
-
fetchOptions(search, loaderSearching) {
|
|
251
|
-
this.emitGetOptions(search, loaderSearching);
|
|
252
|
-
},
|
|
253
|
-
emitGetOptions: debounce(function (search, loaderSearching) {
|
|
254
|
-
this.$emit("getOptions", search, loaderSearching);
|
|
255
|
-
}, 300),
|
|
256
|
-
setSelectedOptions(params) {
|
|
257
|
-
this.value = params;
|
|
258
|
-
this.$emit("onSelectOptions", params);
|
|
259
|
-
},
|
|
260
|
-
async onOpen() {
|
|
261
|
-
if (this.hasNextPage) {
|
|
262
|
-
await this.$nextTick();
|
|
263
|
-
if (this.$refs?.load && this.observer) {
|
|
264
|
-
this.observer.observe(this.$refs.load);
|
|
265
|
-
} else {
|
|
266
|
-
setTimeout(() => {
|
|
267
|
-
this.onOpen();
|
|
268
|
-
}, 500);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
this.emitGetOptions("", true);
|
|
272
|
-
},
|
|
273
|
-
onClose() {
|
|
274
|
-
this.observer.disconnect();
|
|
275
|
-
},
|
|
276
|
-
async infiniteScroll([{ isIntersecting }]) {
|
|
277
|
-
if (isIntersecting) {
|
|
278
|
-
this.emitLoadNextPage();
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
emitLoadNextPage: debounce(function () {
|
|
282
|
-
this.$emit("loadNextPage");
|
|
283
|
-
}, 300),
|
|
284
|
-
},
|
|
285
|
-
watch: {
|
|
286
|
-
optionsSelected() {
|
|
287
|
-
this.value = this.optionsSelected;
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
mounted() {
|
|
291
|
-
this.observer = new IntersectionObserver(this.infiniteScroll);
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
</script>
|
|
295
|
-
<style>
|
|
296
|
-
.v-select {
|
|
297
|
-
@apply cursor-pointer;
|
|
298
|
-
}
|
|
299
|
-
.vs__dropdown-toggle {
|
|
300
|
-
@apply focus:outline-none w-full rounded-md border border-gray-300 bg-white pl-3 text-left shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 sm:text-sm;
|
|
301
|
-
padding-top: 0.4rem;
|
|
302
|
-
padding-bottom: 0.4rem;
|
|
303
|
-
}
|
|
304
|
-
.vs__selected-options {
|
|
305
|
-
@apply flex-wrap overflow-hidden;
|
|
306
|
-
}
|
|
307
|
-
.vs--open .vs__dropdown-toggle {
|
|
308
|
-
border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
|
|
309
|
-
@apply rounded-b-md;
|
|
310
|
-
}
|
|
311
|
-
.vs__selected {
|
|
312
|
-
@apply m-0 mr-1 border-none py-0 pl-1.5 pr-1.5;
|
|
313
|
-
margin-bottom: 2px;
|
|
314
|
-
}
|
|
315
|
-
.vs__selected-options {
|
|
316
|
-
@apply pl-0;
|
|
317
|
-
padding-top: 0.5px;
|
|
318
|
-
padding-bottom: 1px;
|
|
319
|
-
}
|
|
320
|
-
.vs__search,
|
|
321
|
-
.vs__search:focus {
|
|
322
|
-
@apply m-0 p-0;
|
|
323
|
-
}
|
|
324
|
-
.vs__actions {
|
|
325
|
-
@apply pt-0 pr-3;
|
|
326
|
-
}
|
|
327
|
-
.vs__dropdown-menu {
|
|
328
|
-
@apply focus:outline-none mt-2 max-h-60 overflow-auto rounded-md bg-white py-0 text-base shadow-lg ring-1 ring-opacity-5 sm:text-sm;
|
|
329
|
-
}
|
|
330
|
-
.vs__dropdown-option {
|
|
331
|
-
@apply py-2;
|
|
332
|
-
}
|
|
333
|
-
.vs__dropdown-toggle.vs__dropdown-option--highlight {
|
|
334
|
-
@apply bg-indigo-700 text-white;
|
|
335
|
-
}
|
|
336
|
-
.vs__dropdown-option--highlight {
|
|
337
|
-
@apply bg-indigo-700 text-white;
|
|
338
|
-
}
|
|
339
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="flex w-full items-center justify-between" v-if="label">
|
|
4
|
+
<div class="flex items-center">
|
|
5
|
+
<!-- label of multiselect field -->
|
|
6
|
+
<label v-if="label" class="text-sm font-medium text-gray-900">{{ label }}</label>
|
|
7
|
+
<!-- asterisk sign to render if field is required -->
|
|
8
|
+
<p v-if="isRequired" class="ml-1 text-red-600">*</p>
|
|
9
|
+
</div>
|
|
10
|
+
<span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
|
|
11
|
+
</div>
|
|
12
|
+
<v-select
|
|
13
|
+
class="disabled-opacity-50 disabled-pointer-events-none disabled-cursor-default mt-1 text-sm"
|
|
14
|
+
:placeholder="placeholder"
|
|
15
|
+
:multiple="isMultiple"
|
|
16
|
+
:taggable="isTaggable"
|
|
17
|
+
:push-tags="pushTags"
|
|
18
|
+
:filterable="filterable"
|
|
19
|
+
v-model="value"
|
|
20
|
+
:options="options"
|
|
21
|
+
@input="setSelectedOptions"
|
|
22
|
+
@search="fetchOptions"
|
|
23
|
+
@search:focus="$emit('search:focus')"
|
|
24
|
+
:label="optionLabel"
|
|
25
|
+
:clearable="clearable"
|
|
26
|
+
:loading="loading"
|
|
27
|
+
@open="onOpen"
|
|
28
|
+
@close="onClose"
|
|
29
|
+
:disabled="isDisabled"
|
|
30
|
+
>
|
|
31
|
+
<template #open-indicator="{ attributes }">
|
|
32
|
+
<span v-bind="attributes">
|
|
33
|
+
<svg
|
|
34
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
+
class="h-5 w-5 cursor-pointer text-gray-400"
|
|
36
|
+
viewBox="0 0 20 20"
|
|
37
|
+
fill="currentColor"
|
|
38
|
+
>
|
|
39
|
+
<path
|
|
40
|
+
fill-rule="evenodd"
|
|
41
|
+
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
42
|
+
clip-rule="evenodd"
|
|
43
|
+
/>
|
|
44
|
+
</svg>
|
|
45
|
+
</span>
|
|
46
|
+
</template>
|
|
47
|
+
<!-- eslint-disable-next-line vue/no-unused-vars -->
|
|
48
|
+
<template #no-options="{ search, searching, loading }">
|
|
49
|
+
<span v-if="search.length < 1">Start typing to search for options...</span>
|
|
50
|
+
<span v-else>No options found, try searching something else.</span>
|
|
51
|
+
</template>
|
|
52
|
+
<template #spinner="{ loading }">
|
|
53
|
+
<svg
|
|
54
|
+
class="h-5 w-5 animate-spin text-gray-400"
|
|
55
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
56
|
+
fill="none"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
v-if="loading"
|
|
59
|
+
>
|
|
60
|
+
<circle
|
|
61
|
+
class="opacity-25"
|
|
62
|
+
cx="12"
|
|
63
|
+
cy="12"
|
|
64
|
+
r="10"
|
|
65
|
+
stroke="currentColor"
|
|
66
|
+
stroke-width="4"
|
|
67
|
+
></circle>
|
|
68
|
+
<path
|
|
69
|
+
class="opacity-75"
|
|
70
|
+
fill="currentColor"
|
|
71
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
72
|
+
></path>
|
|
73
|
+
</svg>
|
|
74
|
+
</template>
|
|
75
|
+
<template slot="option" slot-scope="option">
|
|
76
|
+
<slot name="custom-option" v-bind:option="option"></slot>
|
|
77
|
+
</template>
|
|
78
|
+
<template v-if="showOptionImage" v-slot:option="option">
|
|
79
|
+
<div :class="`flex w-full ${option.description ? 'items-start' : 'items-center'}`">
|
|
80
|
+
<c-avatar
|
|
81
|
+
v-if="option.image"
|
|
82
|
+
size="extraextrasmall"
|
|
83
|
+
:image="option.image"
|
|
84
|
+
:rounded="true"
|
|
85
|
+
:description="option.description"
|
|
86
|
+
class="mr-2"
|
|
87
|
+
></c-avatar>
|
|
88
|
+
<c-avatar
|
|
89
|
+
v-else
|
|
90
|
+
size="extraextrasmall"
|
|
91
|
+
:nameInitials="option.initials"
|
|
92
|
+
:description="option.description"
|
|
93
|
+
:rounded="true"
|
|
94
|
+
class="mr-2"
|
|
95
|
+
></c-avatar>
|
|
96
|
+
<div class="w-full">
|
|
97
|
+
<p>{{ option[optionLabel] }}</p>
|
|
98
|
+
<p class="text-xs" v-if="option.description">
|
|
99
|
+
{{ option.description }}
|
|
100
|
+
</p>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
104
|
+
<template #list-footer>
|
|
105
|
+
<li ref="load" class="loader" v-show="hasNextPage">Loading more options...</li>
|
|
106
|
+
<li
|
|
107
|
+
v-if="showFooterButton"
|
|
108
|
+
class="group sticky bottom-0 mt-1 cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
|
|
109
|
+
id="listbox-option-0"
|
|
110
|
+
role="option"
|
|
111
|
+
@click="$emit('footerButtonClick')"
|
|
112
|
+
>
|
|
113
|
+
<div class="flex items-center">
|
|
114
|
+
<svg
|
|
115
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
116
|
+
class="h-6 w-6 flex-shrink-0 text-gray-400"
|
|
117
|
+
viewBox="0 0 20 20"
|
|
118
|
+
fill="currentColor"
|
|
119
|
+
>
|
|
120
|
+
<path
|
|
121
|
+
fill-rule="evenodd"
|
|
122
|
+
d="M10 18a8 8 0 100-16 8 8 0 000 16zm1-11a1 1 0 10-2 0v2H7a1 1 0 100 2h2v2a1 1 0 102 0v-2h2a1 1 0 100-2h-2V7z"
|
|
123
|
+
clip-rule="evenodd"
|
|
124
|
+
/>
|
|
125
|
+
</svg>
|
|
126
|
+
<span class="ml-3 block truncate font-semibold">
|
|
127
|
+
{{ footerButtonText }}
|
|
128
|
+
</span>
|
|
129
|
+
</div>
|
|
130
|
+
</li>
|
|
131
|
+
</template>
|
|
132
|
+
</v-select>
|
|
133
|
+
|
|
134
|
+
<p v-if="subLabel" class="mt-1 text-sm text-gray-500">{{ subLabel }}</p>
|
|
135
|
+
<p v-if="!isValidate" class="mt-1 text-sm text-red-600">
|
|
136
|
+
{{ errorMessage }}
|
|
137
|
+
</p>
|
|
138
|
+
<p v-if="helpText && isValidate == true" class="mt-1 text-sm text-gray-500">
|
|
139
|
+
{{ helpText }}
|
|
140
|
+
</p>
|
|
141
|
+
</div>
|
|
142
|
+
</template>
|
|
143
|
+
<script>
|
|
144
|
+
import vSelect from "vue-select";
|
|
145
|
+
import CAvatar from "../CAvatar/CAvatar.vue";
|
|
146
|
+
import { debounce } from "lodash-es";
|
|
147
|
+
// import Fuse from "fuse.js";
|
|
148
|
+
import "vue-select/dist/vue-select.css";
|
|
149
|
+
export default {
|
|
150
|
+
name: "CMultiselect",
|
|
151
|
+
components: { vSelect, CAvatar },
|
|
152
|
+
props: {
|
|
153
|
+
options: {
|
|
154
|
+
type: Array,
|
|
155
|
+
required: true,
|
|
156
|
+
},
|
|
157
|
+
showFooterButton: {
|
|
158
|
+
type: Boolean,
|
|
159
|
+
default: false,
|
|
160
|
+
},
|
|
161
|
+
footerButtonText: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: "",
|
|
164
|
+
},
|
|
165
|
+
label: String,
|
|
166
|
+
isRequired: {
|
|
167
|
+
type: Boolean,
|
|
168
|
+
},
|
|
169
|
+
subLabel: String,
|
|
170
|
+
placeholder: {
|
|
171
|
+
type: String,
|
|
172
|
+
default: "Start typing... (min 2 characters) to search options",
|
|
173
|
+
},
|
|
174
|
+
// whether multiple fields are allowed or not
|
|
175
|
+
isMultiple: {
|
|
176
|
+
type: Boolean,
|
|
177
|
+
},
|
|
178
|
+
// append newly created tags in options
|
|
179
|
+
pushTags: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
},
|
|
182
|
+
// whether to allow user to create new options
|
|
183
|
+
isTaggable: {
|
|
184
|
+
type: Boolean,
|
|
185
|
+
},
|
|
186
|
+
getOptions: {
|
|
187
|
+
// function to emit on search{
|
|
188
|
+
type: Function,
|
|
189
|
+
},
|
|
190
|
+
customiseOption: {
|
|
191
|
+
type: Boolean,
|
|
192
|
+
},
|
|
193
|
+
// whether to show profile picture in option
|
|
194
|
+
showOptionImage: {
|
|
195
|
+
type: Boolean,
|
|
196
|
+
},
|
|
197
|
+
// the name of the option to render in the selectpicker
|
|
198
|
+
optionLabel: {
|
|
199
|
+
type: String,
|
|
200
|
+
},
|
|
201
|
+
// action to trigger after selecting option from dropdown
|
|
202
|
+
onSelectOptions: {
|
|
203
|
+
type: Function,
|
|
204
|
+
},
|
|
205
|
+
optionsSelected: {
|
|
206
|
+
type: [Array, Object],
|
|
207
|
+
},
|
|
208
|
+
filterable: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
default: false,
|
|
211
|
+
},
|
|
212
|
+
clearable: {
|
|
213
|
+
type: Boolean,
|
|
214
|
+
default: true,
|
|
215
|
+
},
|
|
216
|
+
isValidate: {
|
|
217
|
+
type: Boolean,
|
|
218
|
+
default: true,
|
|
219
|
+
},
|
|
220
|
+
errorMessage: {
|
|
221
|
+
type: String,
|
|
222
|
+
},
|
|
223
|
+
loading: {
|
|
224
|
+
type: Boolean,
|
|
225
|
+
default: false,
|
|
226
|
+
},
|
|
227
|
+
hasNextPage: {
|
|
228
|
+
type: Boolean,
|
|
229
|
+
default: false,
|
|
230
|
+
},
|
|
231
|
+
isDisabled: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
default: false,
|
|
234
|
+
},
|
|
235
|
+
// text adjacent to label of dropdown to provide hint about field
|
|
236
|
+
hint: { type: String },
|
|
237
|
+
helpText: {
|
|
238
|
+
type: String,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
computed: {},
|
|
242
|
+
data() {
|
|
243
|
+
return {
|
|
244
|
+
loaderSearching: true,
|
|
245
|
+
value: this.optionsSelected && this.optionsSelected.length ? this.optionsSelected : [],
|
|
246
|
+
observer: null,
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
methods: {
|
|
250
|
+
fetchOptions(search, loaderSearching) {
|
|
251
|
+
this.emitGetOptions(search, loaderSearching);
|
|
252
|
+
},
|
|
253
|
+
emitGetOptions: debounce(function (search, loaderSearching) {
|
|
254
|
+
this.$emit("getOptions", search, loaderSearching);
|
|
255
|
+
}, 300),
|
|
256
|
+
setSelectedOptions(params) {
|
|
257
|
+
this.value = params;
|
|
258
|
+
this.$emit("onSelectOptions", params);
|
|
259
|
+
},
|
|
260
|
+
async onOpen() {
|
|
261
|
+
if (this.hasNextPage) {
|
|
262
|
+
await this.$nextTick();
|
|
263
|
+
if (this.$refs?.load && this.observer) {
|
|
264
|
+
this.observer.observe(this.$refs.load);
|
|
265
|
+
} else {
|
|
266
|
+
setTimeout(() => {
|
|
267
|
+
this.onOpen();
|
|
268
|
+
}, 500);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.emitGetOptions("", true);
|
|
272
|
+
},
|
|
273
|
+
onClose() {
|
|
274
|
+
this.observer.disconnect();
|
|
275
|
+
},
|
|
276
|
+
async infiniteScroll([{ isIntersecting }]) {
|
|
277
|
+
if (isIntersecting) {
|
|
278
|
+
this.emitLoadNextPage();
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
emitLoadNextPage: debounce(function () {
|
|
282
|
+
this.$emit("loadNextPage");
|
|
283
|
+
}, 300),
|
|
284
|
+
},
|
|
285
|
+
watch: {
|
|
286
|
+
optionsSelected() {
|
|
287
|
+
this.value = this.optionsSelected;
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
mounted() {
|
|
291
|
+
this.observer = new IntersectionObserver(this.infiniteScroll);
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
</script>
|
|
295
|
+
<style>
|
|
296
|
+
.v-select {
|
|
297
|
+
@apply cursor-pointer;
|
|
298
|
+
}
|
|
299
|
+
.vs__dropdown-toggle {
|
|
300
|
+
@apply focus:outline-none w-full rounded-md border border-gray-300 bg-white pl-3 text-left shadow-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 sm:text-sm;
|
|
301
|
+
padding-top: 0.4rem;
|
|
302
|
+
padding-bottom: 0.4rem;
|
|
303
|
+
}
|
|
304
|
+
.vs__selected-options {
|
|
305
|
+
@apply flex-wrap overflow-hidden;
|
|
306
|
+
}
|
|
307
|
+
.vs--open .vs__dropdown-toggle {
|
|
308
|
+
border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
|
|
309
|
+
@apply rounded-b-md;
|
|
310
|
+
}
|
|
311
|
+
.vs__selected {
|
|
312
|
+
@apply m-0 mr-1 border-none py-0 pl-1.5 pr-1.5;
|
|
313
|
+
margin-bottom: 2px;
|
|
314
|
+
}
|
|
315
|
+
.vs__selected-options {
|
|
316
|
+
@apply pl-0;
|
|
317
|
+
padding-top: 0.5px;
|
|
318
|
+
padding-bottom: 1px;
|
|
319
|
+
}
|
|
320
|
+
.vs__search,
|
|
321
|
+
.vs__search:focus {
|
|
322
|
+
@apply m-0 p-0;
|
|
323
|
+
}
|
|
324
|
+
.vs__actions {
|
|
325
|
+
@apply pt-0 pr-3;
|
|
326
|
+
}
|
|
327
|
+
.vs__dropdown-menu {
|
|
328
|
+
@apply focus:outline-none mt-2 max-h-60 overflow-auto rounded-md bg-white py-0 text-base shadow-lg ring-1 ring-opacity-5 sm:text-sm;
|
|
329
|
+
}
|
|
330
|
+
.vs__dropdown-option {
|
|
331
|
+
@apply py-2;
|
|
332
|
+
}
|
|
333
|
+
.vs__dropdown-toggle.vs__dropdown-option--highlight {
|
|
334
|
+
@apply bg-indigo-700 text-white;
|
|
335
|
+
}
|
|
336
|
+
.vs__dropdown-option--highlight {
|
|
337
|
+
@apply bg-indigo-700 text-white;
|
|
338
|
+
}
|
|
339
|
+
</style>
|