classcard-ui 0.2.1068 → 0.2.1069

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 (190) hide show
  1. package/README.md +24 -24
  2. package/dist/classcard-ui.common.js +76 -65
  3. package/dist/classcard-ui.common.js.map +1 -1
  4. package/dist/classcard-ui.umd.js +76 -65
  5. package/dist/classcard-ui.umd.js.map +1 -1
  6. package/dist/classcard-ui.umd.min.js +1 -1
  7. package/dist/classcard-ui.umd.min.js.map +1 -1
  8. package/package.json +82 -82
  9. package/src/App.vue +16 -16
  10. package/src/components/CAlerts/CAlerts.vue +70 -70
  11. package/src/components/CAlerts/index.js +2 -2
  12. package/src/components/CAnchorTabs/CAnchorTabs.vue +96 -96
  13. package/src/components/CAnchorTabs/index.js +2 -2
  14. package/src/components/CAnchorTag/CAnchorTag.vue +62 -62
  15. package/src/components/CAnchorTag/index.js +2 -2
  16. package/src/components/CAvatar/CAvatar.vue +212 -212
  17. package/src/components/CAvatar/index.js +2 -2
  18. package/src/components/CAvatarGroup/CAvatarGroup.vue +145 -145
  19. package/src/components/CAvatarGroup/index.js +2 -2
  20. package/src/components/CBasicTable/CBasicTable.vue +184 -184
  21. package/src/components/CBasicTable/index.js +2 -2
  22. package/src/components/CBreadcrumbs/CBreadcrumbs.vue +38 -38
  23. package/src/components/CBreadcrumbs/index.js +2 -2
  24. package/src/components/CButton/CButton.vue +152 -152
  25. package/src/components/CButton/index.js +2 -2
  26. package/src/components/CButtonGroup/CButtonGroup.vue +118 -118
  27. package/src/components/CButtonGroup/index.js +2 -2
  28. package/src/components/CButtonIcon/CButtonIcon.vue +117 -117
  29. package/src/components/CButtonIcon/index.js +2 -2
  30. package/src/components/CButtonLink/CButtonLink.vue +39 -39
  31. package/src/components/CButtonLink/index.js +2 -2
  32. package/src/components/CButtonSelect/CButtonSelect.vue +134 -134
  33. package/src/components/CButtonSelect/index.js +2 -2
  34. package/src/components/CButtonSelectBorder/CButtonSelectBorder.vue +135 -135
  35. package/src/components/CButtonSelectBorder/index.js +3 -3
  36. package/src/components/CButtonWithDropdown/CButtonWithDropdown.vue +135 -135
  37. package/src/components/CButtonWithDropdown/index.js +2 -2
  38. package/src/components/CCalendar/CCalendar.vue +410 -410
  39. package/src/components/CCalendar/index.js +3 -3
  40. package/src/components/CCard/CCard.vue +49 -49
  41. package/src/components/CCard/index.js +2 -2
  42. package/src/components/CCheckbox/CCheckbox.vue +123 -123
  43. package/src/components/CCheckbox/index.js +2 -2
  44. package/src/components/CCircularButton/CCircularButton.vue +53 -53
  45. package/src/components/CCircularButton/index.js +2 -2
  46. package/src/components/CCollapsibleSection/CCollapsibleSection.vue +101 -101
  47. package/src/components/CCollapsibleSection/index.js +2 -2
  48. package/src/components/CColorDots/CColorDots.vue +51 -51
  49. package/src/components/CColorDots/index.js +3 -3
  50. package/src/components/CConfirmActionModal/CConfirmActionModal.vue +180 -180
  51. package/src/components/CConfirmActionModal/index.js +3 -3
  52. package/src/components/CDatepicker/CDatepicker.vue +201 -201
  53. package/src/components/CDatepicker/index.js +2 -2
  54. package/src/components/CDualSelect/CDualSelect.vue +193 -193
  55. package/src/components/CDualSelect/index.js +2 -2
  56. package/src/components/CEditor/CEditor.vue +98 -98
  57. package/src/components/CEditor/index.js +2 -2
  58. package/src/components/CFormSectionHeading/CFormSectionHeading.vue +53 -53
  59. package/src/components/CFormSectionHeading/index.js +2 -2
  60. package/src/components/CGroupedSelect/CGroupedSelect.vue +245 -245
  61. package/src/components/CGroupedSelect/index.js +3 -3
  62. package/src/components/CIcon/CIcon.vue +91 -91
  63. package/src/components/CIcon/index.js +2 -2
  64. package/src/components/CIconDropdown/CIconDropdown.vue +146 -146
  65. package/src/components/CIconDropdown/index.js +2 -2
  66. package/src/components/CInput/CInput.vue +134 -134
  67. package/src/components/CInput/index.js +2 -2
  68. package/src/components/CInputAddon/CInputAddon.vue +228 -228
  69. package/src/components/CInputAddon/index.js +2 -2
  70. package/src/components/CInputEmail/CInputEmail.vue +93 -93
  71. package/src/components/CInputEmail/index.js +2 -2
  72. package/src/components/CInsetTabs/CInsetTabs.vue +88 -88
  73. package/src/components/CInsetTabs/index.js +3 -3
  74. package/src/components/CModalHeading/CModalHeading.vue +22 -22
  75. package/src/components/CModalHeading/index.js +2 -2
  76. package/src/components/CModuleHelpLinks/CModuleHelpLinks.vue +70 -70
  77. package/src/components/CModuleHelpLinks/index.js +3 -3
  78. package/src/components/CMultiselect/CMultiselect.vue +615 -615
  79. package/src/components/CMultiselect/index.js +2 -2
  80. package/src/components/CMultiselectr/CMultiselectr.vue +44 -44
  81. package/src/components/CMultiselectr/index.js +2 -2
  82. package/src/components/CPageHeading/CPageHeading.vue +56 -56
  83. package/src/components/CPageHeading/index.js +2 -2
  84. package/src/components/CPagination/CPagination.vue +233 -233
  85. package/src/components/CPagination/index.js +2 -2
  86. package/src/components/CPhoneNumber/CPhoneNumber.vue +114 -114
  87. package/src/components/CPhoneNumber/index.js +2 -2
  88. package/src/components/CProgress/CProgress.vue +57 -57
  89. package/src/components/CProgress/index.js +2 -2
  90. package/src/components/CRadio/CRadio.vue +126 -126
  91. package/src/components/CRadio/index.js +2 -2
  92. package/src/components/CRangeSlider/CRangeSlider.vue +55 -55
  93. package/src/components/CRangeSlider/index.js +2 -2
  94. package/src/components/CReorderableStackedList/CReorderableStackedList.vue +94 -94
  95. package/src/components/CReorderableStackedList/index.js +2 -2
  96. package/src/components/CSelect/CSelect.vue +539 -530
  97. package/src/components/CSelect/index.js +2 -2
  98. package/src/components/CSmallTimeline/CSmallTimeline.vue +40 -40
  99. package/src/components/CSmallTimeline/index.js +2 -2
  100. package/src/components/CStackedList/CStackedList.vue +150 -150
  101. package/src/components/CStackedList/index.js +2 -2
  102. package/src/components/CStats/CStats.vue +116 -116
  103. package/src/components/CStats/index.js +2 -2
  104. package/src/components/CSwitch/CSwitch.vue +176 -176
  105. package/src/components/CSwitch/index.js +2 -2
  106. package/src/components/CTabLazy/CTabLazy.vue +63 -63
  107. package/src/components/CTabLazy/index.js +2 -2
  108. package/src/components/CTable/CTable.vue +671 -671
  109. package/src/components/CTable/index.js +2 -2
  110. package/src/components/CTabs/CTabs.vue +169 -169
  111. package/src/components/CTabs/index.js +2 -2
  112. package/src/components/CTag/CTag.vue +59 -59
  113. package/src/components/CTag/index.js +2 -2
  114. package/src/components/CTextarea/CTextarea.vue +107 -107
  115. package/src/components/CTextarea/index.js +2 -2
  116. package/src/components/CTimeline/CTimeline.vue +237 -237
  117. package/src/components/CTimeline/index.js +2 -2
  118. package/src/components/CUpload/CUpload.vue +267 -267
  119. package/src/components/CUpload/index.js +2 -2
  120. package/src/components/index.js +53 -53
  121. package/src/icons.js +453 -453
  122. package/src/main.js +22 -22
  123. package/src/stories/CAlerts.stories.js +37 -37
  124. package/src/stories/CAnchorTabs.stories.js +29 -29
  125. package/src/stories/CAnchorTag.stories.js +36 -36
  126. package/src/stories/CAvatar.stories.js +38 -38
  127. package/src/stories/CAvatarGroup.stories.js +100 -100
  128. package/src/stories/CBasicTable.stories.js +316 -316
  129. package/src/stories/CBreadcrumbs.stories.js +24 -24
  130. package/src/stories/CButton.stories.js +47 -47
  131. package/src/stories/CButtonGroup.stories.js +33 -33
  132. package/src/stories/CButtonIcon.stories.js +27 -27
  133. package/src/stories/CButtonLink.stories.js +24 -24
  134. package/src/stories/CButtonSelect.stories.js +41 -41
  135. package/src/stories/CButtonSelectBorder.stories.js +48 -48
  136. package/src/stories/CButtonWithDropdown.stories.js +41 -41
  137. package/src/stories/CCalendar.stories.js +16 -16
  138. package/src/stories/CCard.stories.js +30 -30
  139. package/src/stories/CCheckbox.stories.js +29 -29
  140. package/src/stories/CCircularButton.stories.js +29 -29
  141. package/src/stories/CCollapsibleSection.stories.js +28 -28
  142. package/src/stories/CColorDots.stories.js +28 -28
  143. package/src/stories/CConfirmActionModal.stories.js +59 -59
  144. package/src/stories/CDatepicker.stories.js +30 -30
  145. package/src/stories/CDualSelect.stories.js +29 -29
  146. package/src/stories/CEditor.stories.js +30 -30
  147. package/src/stories/CFormSectionHeading.stories.js +34 -34
  148. package/src/stories/CGroupedSelect.stories.js +71 -71
  149. package/src/stories/CIcon.stories.js +28 -28
  150. package/src/stories/CIconDropdown.stories.js +45 -45
  151. package/src/stories/CInput.stories.js +36 -36
  152. package/src/stories/CInputAddon.stories.js +37 -37
  153. package/src/stories/CInputEmail.stories.js +27 -27
  154. package/src/stories/CInsetTabs.stories.js +38 -38
  155. package/src/stories/CModalHeading.stories.js +25 -25
  156. package/src/stories/CModuleHelpLinks.stories.js +25 -25
  157. package/src/stories/CMultiselect.stories.js +167 -167
  158. package/src/stories/CMultiselectr.stories.js +23 -23
  159. package/src/stories/CPageHeading.stories.js +32 -32
  160. package/src/stories/CPagination.stories.js +30 -30
  161. package/src/stories/CPhoneNumber.stories.js +29 -29
  162. package/src/stories/CProgress.stories.js +23 -23
  163. package/src/stories/CRadio.stories.js +36 -36
  164. package/src/stories/CRangeSlider.stories.js +23 -23
  165. package/src/stories/CReorderableStackedList.stories.js +23 -23
  166. package/src/stories/CSelect.stories.js +109 -109
  167. package/src/stories/CSmallTimeline.stories.js +26 -26
  168. package/src/stories/CStackedList.stories.js +37 -37
  169. package/src/stories/CStats.stories.js +33 -33
  170. package/src/stories/CSwitch.stories.js +28 -28
  171. package/src/stories/CTabLazy.stories.js +26 -26
  172. package/src/stories/CTable.stories.js +169 -169
  173. package/src/stories/CTabs.stories.js +36 -36
  174. package/src/stories/CTag.stories.js +34 -34
  175. package/src/stories/CTextarea.stories.js +32 -32
  176. package/src/stories/CTimeline.stories.js +26 -26
  177. package/src/stories/CUpload.stories.js +36 -36
  178. package/src/stories/Introduction.stories.mdx +207 -207
  179. package/src/stories/Page.vue +88 -88
  180. package/src/stories/assets/code-brackets.svg +0 -0
  181. package/src/stories/assets/colors.svg +0 -0
  182. package/src/stories/assets/comments.svg +0 -0
  183. package/src/stories/assets/direction.svg +0 -0
  184. package/src/stories/assets/flow.svg +0 -0
  185. package/src/stories/assets/plugin.svg +0 -0
  186. package/src/stories/assets/repo.svg +0 -0
  187. package/src/stories/assets/stackalt.svg +0 -0
  188. package/src/stories/header.css +26 -26
  189. package/src/stories/page.css +69 -69
  190. package/src/stories/utils.css +17 -17
@@ -1,615 +1,615 @@
1
- <template>
2
- <div>
3
- <div class="mb-1 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">{{
7
- label
8
- }}</label>
9
- <!-- asterisk sign to render if field is required -->
10
- <p v-if="isRequired" class="ml-1 text-red-600">*</p>
11
- </div>
12
- <span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
13
- </div>
14
- <v-select
15
- class="disabled-opacity-50 disabled-pointer-events-none disabled-cursor-default absolute inline-block h-full w-full text-sm"
16
- :placeholder="placeholder"
17
- :multiple="isMultiple"
18
- :taggable="isTaggable"
19
- :push-tags="pushTags"
20
- :filterable="filterable"
21
- v-model="value"
22
- :options="isGrouped ? groupedArray : options"
23
- @input="setSelectedOptions"
24
- @search="fetchOptions"
25
- @search:focus="$emit('search:focus')"
26
- @option:selecting="handleSingleSelect"
27
- :label="optionLabel"
28
- :clearable="clearable"
29
- :loading="loading"
30
- @open="onOpen"
31
- @close="onClose"
32
- :disabled="isDisabled"
33
- :selectable="
34
- isGrouped
35
- ? (groupedArray) =>
36
- groupedArray.header ? groupedArray.disabled : true
37
- : (options) => getDisableOptions(options)
38
- "
39
- >
40
- <template #open-indicator="{ attributes }">
41
- <span
42
- v-bind="attributes"
43
- :style="!shouldIconRotate ? 'transform:none;' : ''"
44
- >
45
- <c-icon
46
- v-if="icon"
47
- :name="icon.name"
48
- :type="icon.type"
49
- class="h-5 w-5 text-gray-400"
50
- />
51
- <c-icon
52
- v-else
53
- :name="'chevron-down-outline-v2'"
54
- :type="'outline-v2'"
55
- class="h-4 w-4 text-gray-400"
56
- viewBox="0 0 24 24"
57
- />
58
- </span>
59
- </template>
60
- <!--Selected option slot-->
61
- <template v-if="addCheckBox" #selected-option-container="{ option }">
62
- <div class="flex items-center justify-center truncate bg-white">
63
- <div
64
- v-if="getIndex(option) == 0"
65
- class="flex items-center overflow-hidden"
66
- >
67
- <c-avatar
68
- v-if="option[imageLabel]"
69
- :size="'extraextrasmall'"
70
- :image="option[imageLabel]"
71
- :rounded="true"
72
- ></c-avatar>
73
- <c-avatar
74
- v-if="option.initials && !option.icon && !option[imageLabel]"
75
- :size="'extraextrasmall'"
76
- :nameInitials="option.initials"
77
- :rounded="true"
78
- :isDynamicallyColored="true"
79
- ></c-avatar>
80
- <c-icon
81
- v-if="option.icon && !option[imageLabel] && !option.initials"
82
- :name="option.icon.name"
83
- :type="option.icon.type"
84
- class="h-5 w-5 text-gray-400"
85
- />
86
- <span class="text-start ml-2 inline-block truncate text-sm">{{
87
- option[optionLabel]
88
- }}</span>
89
- </div>
90
- <div v-if="getIndex(option) == 1" class="ml-1 flex items-center">
91
- +{{ value.length - 1 }}
92
- </div>
93
- </div>
94
- </template>
95
- <!-- eslint-disable-next-line vue/no-unused-vars -->
96
- <template #no-options="{ search, searching, loading }">
97
- <span v-if="search.length < 1"
98
- >Start typing to search for options...</span
99
- >
100
- <span v-else>No options found, try searching something else.</span>
101
- </template>
102
- <template #spinner="{ loading }">
103
- <svg
104
- class="h-5 w-5 animate-spin text-gray-400"
105
- xmlns="http://www.w3.org/2000/svg"
106
- fill="none"
107
- viewBox="0 0 24 24"
108
- v-if="loading"
109
- >
110
- <circle
111
- class="opacity-25"
112
- cx="12"
113
- cy="12"
114
- r="10"
115
- stroke="currentColor"
116
- stroke-width="4"
117
- ></circle>
118
- <path
119
- class="opacity-75"
120
- fill="currentColor"
121
- 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"
122
- ></path>
123
- </svg>
124
- </template>
125
- <template slot="option" slot-scope="option">
126
- <slot
127
- name="custom-option"
128
- v-bind:option="isGrouped ? option : groupedArray"
129
- ></slot>
130
- </template>
131
- <template v-slot:option="option">
132
- <div v-if="!isGrouped">
133
- <div :class="`mt-1 flex h-full w-full items-center hover:text-white`">
134
- <p v-if="showOptionImage" class="flex-shrink-0">
135
- <c-avatar
136
- v-if="option[imageLabel]"
137
- :size="
138
- option.description && showAdditionalText
139
- ? 'extrasmall'
140
- : 'extraextrasmall'
141
- "
142
- :image="option[imageLabel]"
143
- :rounded="true"
144
- :description="option.description"
145
- class="mr-2"
146
- ></c-avatar>
147
- <c-avatar
148
- v-if="!option.icon && !option[imageLabel] && option.initials"
149
- :size="
150
- option.description && showAdditionalText
151
- ? 'extrasmall'
152
- : 'extraextrasmall'
153
- "
154
- :nameInitials="option.initials"
155
- :description="option.description"
156
- :rounded="true"
157
- :isDynamicallyColored="true"
158
- class="mr-2"
159
- ></c-avatar>
160
- <c-icon
161
- v-if="option.icon && !option[imageLabel] && !option.initials"
162
- :name="option.icon.name"
163
- :type="option.icon.type"
164
- class="mr-2 h-5 w-5 text-gray-400"
165
- />
166
- </p>
167
- <div class="w-full hover:text-white">
168
- <div class="flex items-center justify-between">
169
- <div class="flex items-center">
170
- <p>{{ option[optionLabel] }}</p>
171
- <div class="ml-3">
172
- <span
173
- v-if="tags && option.info && option.info !== ''"
174
- class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
175
- >
176
- {{ option.info }}
177
- </span>
178
- <span v-else class="-ml-3 text-gray-300">
179
- &nbsp;{{ option.info }}
180
- </span>
181
- </div>
182
- </div>
183
- <c-checkbox v-if="addCheckBox" :value="isChecked(option)" />
184
- </div>
185
- <p
186
- class="text-xs"
187
- v-if="option.description && showAdditionalText"
188
- >
189
- {{ option.description }}
190
- </p>
191
- </div>
192
- </div>
193
- </div>
194
- <div v-if="isGrouped">
195
- <v-list-subheader v-if="groupedArray.header">
196
- {{ groupedArray.header }}
197
- </v-list-subheader>
198
- <div
199
- :class="`mt-1 flex h-full w-full hover:text-white ${
200
- groupedArray.description ? 'items-start' : 'items-center'
201
- }`"
202
- >
203
- <div v-if="!groupedArray.header && showOptionImage">
204
- <c-avatar
205
- v-if="groupedArray.image"
206
- size="extraextrasmall"
207
- :image="groupedArray.image"
208
- :rounded="true"
209
- :description="groupedArray.description"
210
- class="mr-2"
211
- ></c-avatar>
212
- <c-avatar
213
- v-else
214
- size="extraextrasmall"
215
- :nameInitials="groupedArray.initials"
216
- :description="groupedArray.description"
217
- :rounded="true"
218
- :isDynamicallyColored="true"
219
- class="mr-2"
220
- ></c-avatar>
221
- </div>
222
- <div class="w-full hover:text-white">
223
- <div class="flex items-center">
224
- <p>{{ groupedArray[optionLabel] }}</p>
225
- <div class="ml-3">
226
- <span
227
- v-if="tags && groupedArray.info && groupedArray.info !== ''"
228
- class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
229
- >
230
- {{ groupedArray.info }}
231
- </span>
232
- <span v-else class="text-gray-300">
233
- {{ groupedArray.info }}
234
- </span>
235
- </div>
236
- </div>
237
-
238
- <p class="text-xs" v-if="groupedArray.description">
239
- {{ groupedArray.description }}
240
- </p>
241
- </div>
242
- </div>
243
- </div>
244
- </template>
245
- <template #list-footer>
246
- <li ref="load" class="loader" v-show="hasNextPage">
247
- Loading more options...
248
- </li>
249
- <li
250
- v-if="showFooterButton"
251
- 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"
252
- :class="footerBtnClasses"
253
- id="listbox-option-0"
254
- role="option"
255
- @click="$emit('footerButtonClick')"
256
- >
257
- <div class="flex items-center">
258
- <svg
259
- xmlns="http://www.w3.org/2000/svg"
260
- class="h-6 w-6 flex-shrink-0 text-gray-400"
261
- viewBox="0 0 20 20"
262
- fill="currentColor"
263
- >
264
- <path
265
- fill-rule="evenodd"
266
- 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"
267
- clip-rule="evenodd"
268
- />
269
- </svg>
270
- <span class="ml-3 block truncate font-semibold">
271
- {{ footerButtonText }}
272
- </span>
273
- </div>
274
- </li>
275
- </template>
276
- </v-select>
277
-
278
- <p v-if="subLabel" class="mt-1 text-sm text-gray-500">{{ subLabel }}</p>
279
- <p v-if="!isValidate" class="mt-1 text-sm text-red-600">
280
- {{ errorMessage }}
281
- </p>
282
- <p v-if="helpText && isValidate == true" class="mt-1 text-sm text-gray-500">
283
- {{ helpText }}
284
- </p>
285
- </div>
286
- </template>
287
- <script>
288
- import vSelect from "vue-select";
289
- import CAvatar from "../CAvatar/CAvatar.vue";
290
- import CIcon from "../CIcon/CIcon.vue";
291
- import CCheckbox from "../CCheckbox/CCheckbox.vue";
292
- import { debounce } from "lodash-es";
293
- // import Fuse from "fuse.js";
294
- import "vue-select/dist/vue-select.css";
295
- export default {
296
- name: "CMultiselect",
297
- components: { vSelect, CAvatar, CCheckbox, CIcon },
298
- props: {
299
- options: {
300
- type: Array,
301
- required: true,
302
- },
303
- extraDetails: {
304
- type: Boolean,
305
- default: false,
306
- },
307
- showFooterButton: {
308
- type: Boolean,
309
- default: false,
310
- },
311
- footerButtonText: {
312
- type: String,
313
- default: "",
314
- },
315
- label: String,
316
- isRequired: {
317
- type: Boolean,
318
- },
319
- subLabel: String,
320
- placeholder: {
321
- type: String,
322
- },
323
- // whether multiple fields are allowed or not
324
- isMultiple: {
325
- type: Boolean,
326
- },
327
- // append newly created tags in options
328
- pushTags: {
329
- type: Boolean,
330
- },
331
- // whether to allow user to create new options
332
- isTaggable: {
333
- type: Boolean,
334
- },
335
- getOptions: {
336
- // function to emit on search{
337
- type: Function,
338
- },
339
- customiseOption: {
340
- type: Boolean,
341
- },
342
- // whether to show profile picture in option
343
- showOptionImage: {
344
- type: Boolean,
345
- },
346
- // the name of the option to render in the selectpicker
347
- optionLabel: {
348
- type: String,
349
- },
350
- // action to trigger after selecting option from dropdown
351
- onSelectOptions: {
352
- type: Function,
353
- },
354
- optionsSelected: {
355
- type: [Array, Object],
356
- },
357
- filterable: {
358
- type: Boolean,
359
- default: false,
360
- },
361
- clearable: {
362
- type: Boolean,
363
- default: true,
364
- },
365
- isValidate: {
366
- type: Boolean,
367
- default: true,
368
- },
369
- errorMessage: {
370
- type: String,
371
- },
372
- loading: {
373
- type: Boolean,
374
- default: false,
375
- },
376
- hasNextPage: {
377
- type: Boolean,
378
- default: false,
379
- },
380
- isDisabled: {
381
- type: Boolean,
382
- default: false,
383
- },
384
- // text adjacent to label of dropdown to provide hint about field
385
- hint: { type: String },
386
- helpText: {
387
- type: String,
388
- },
389
- tags: {
390
- type: Boolean,
391
- default: false,
392
- },
393
- isGrouped: {
394
- type: Boolean,
395
- default: false,
396
- },
397
- //to show the additional text, default true to prevent failure at any other place
398
- showAdditionalText: {
399
- type: Boolean,
400
- default: true,
401
- },
402
- addCheckBox: {
403
- type: Boolean,
404
- default: false,
405
- },
406
- showSelectedAvatar: {
407
- type: Boolean,
408
- default: false,
409
- },
410
- icon: {
411
- type: Object,
412
- },
413
- footerBtnClasses: {
414
- type: String,
415
- },
416
- shouldIconRotate: {
417
- type: Boolean,
418
- default: true,
419
- },
420
- imageLabel: {
421
- type: String,
422
- default: "image",
423
- },
424
- },
425
- computed: {
426
- groupedArray() {
427
- const groups = {};
428
-
429
- this.options.forEach((x) => {
430
- // create empty object if it doesn't exists.
431
- groups[x.category] = groups[x.category] || {
432
- text: x.category,
433
- list: [],
434
- };
435
-
436
- groups[x.category].list.push(x);
437
- });
438
-
439
- // The flattened list of items that holds items as well as unique headers
440
- const flattened = [];
441
-
442
- // Iterate over all the unique categories and
443
- // then flatten into a list that v-select needs.
444
- Object.keys(groups).forEach((categoryId) => {
445
- const category = groups[categoryId];
446
- const categoryName = category.text;
447
-
448
- // Create a group
449
- flattened.push({ header: categoryName });
450
-
451
- // Add all the items followed by category header
452
- flattened.push(...category.list);
453
- });
454
-
455
- return flattened;
456
- },
457
- },
458
- data() {
459
- return {
460
- loaderSearching: true,
461
- value:
462
- this.optionsSelected && this.optionsSelected.length
463
- ? this.optionsSelected
464
- : [],
465
- observer: null,
466
- };
467
- },
468
- methods: {
469
- fetchOptions(search, loaderSearching) {
470
- this.emitGetOptions(search, loaderSearching);
471
- },
472
- emitGetOptions: debounce(function (search, loaderSearching) {
473
- this.$emit("getOptions", search, loaderSearching);
474
- }, 300),
475
- setSelectedOptions(params) {
476
- this.value = params;
477
- this.$emit("onSelectOptions", params);
478
- },
479
- async onOpen() {
480
- if (this.hasNextPage) {
481
- await this.$nextTick();
482
- if (this.$refs?.load && this.observer) {
483
- this.observer.observe(this.$refs.load);
484
- } else {
485
- setTimeout(() => {
486
- this.onOpen();
487
- }, 500);
488
- }
489
- }
490
- this.emitGetOptions("", true);
491
- },
492
- onClose() {
493
- this.observer.disconnect();
494
- },
495
- async infiniteScroll([{ isIntersecting }]) {
496
- if (isIntersecting) {
497
- this.emitLoadNextPage();
498
- }
499
- },
500
- getIndex(option) {
501
- return this.value.findIndex((item) => item.id == option.id);
502
- },
503
- isChecked(option) {
504
- return this.value.findIndex((item) => item.id == option.id) == -1 ? 0 : 1;
505
- },
506
-
507
- handleSingleSelect(option) {
508
- if (this.addCheckBox) {
509
- if (this.isChecked(option) == 1) {
510
- if (this.value.length == 1) {
511
- // if there only one option selected dont allow to deselect it
512
- return;
513
- }
514
- this.value = this.value.filter((item) => item.id != option.id);
515
- this.$emit("onSelectOptions", this.value);
516
- } else {
517
- this.$emit("onSingleSelectOption", option);
518
- }
519
- }
520
- },
521
- getDisableOptions(options) {
522
- if (this.addCheckBox && options.isDisabled) {
523
- return !options.isDisabled;
524
- } else {
525
- return options.header ? options.disabled : true;
526
- }
527
- },
528
-
529
- // a function that will set the location when the component has mounted and the location is passed after that
530
- forceSetData(params) {
531
- this.value = params;
532
- },
533
- emitLoadNextPage: debounce(function () {
534
- this.$emit("loadNextPage");
535
- }, 300),
536
- },
537
- watch: {
538
- optionsSelected: {
539
- handler() {
540
- this.value = this.optionsSelected;
541
- },
542
- deep: true,
543
- },
544
- },
545
- mounted() {
546
- this.observer = new IntersectionObserver(this.infiniteScroll);
547
- },
548
- };
549
- </script>
550
- <style>
551
- .disabled {
552
- pointer-events: none;
553
- color: #bfcbd9;
554
- cursor: not-allowed;
555
- background-image: none;
556
- background-color: #eef1f6;
557
- border-color: #d1dbe5;
558
- }
559
- .v-select {
560
- @apply cursor-pointer;
561
- }
562
- .vs__dropdown-toggle {
563
- @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;
564
- padding-top: 0.35rem;
565
- padding-bottom: 0.35rem;
566
- }
567
- .vs__selected-options {
568
- @apply overflow-hidden;
569
- flex-wrap: nowrap;
570
- }
571
- .vs--open .vs__dropdown-toggle {
572
- border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
573
- @apply rounded-b-md;
574
- }
575
- .vs__selected {
576
- @apply m-0 mr-1 border-none py-0 pl-1.5 pr-1.5;
577
- margin-bottom: 2px;
578
- }
579
- .extra:hover {
580
- color: white;
581
- }
582
- .vs__selected-options {
583
- @apply pl-0;
584
- padding-top: 0.5px;
585
- padding-bottom: 1px;
586
- }
587
- .vs__search,
588
- .vs__search:focus {
589
- @apply m-0 p-0;
590
- }
591
- .vs__actions {
592
- @apply pt-0 pr-3;
593
- }
594
- .vs__dropdown-menu {
595
- @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;
596
- }
597
- .vs__dropdown-option {
598
- @apply whitespace-normal py-2;
599
- }
600
-
601
- .vs__dropdown-toggle.vs__dropdown-option--highlight {
602
- @apply bg-indigo-700 text-white;
603
- }
604
-
605
- .vs__dropdown-option--highlight {
606
- @apply bg-indigo-700 text-white;
607
- }
608
- .vs__dropdown-option--disabled {
609
- pointer-events: none;
610
- }
611
-
612
- .vs__dropdown-toggle {
613
- height: 100%;
614
- }
615
- </style>
1
+ <template>
2
+ <div>
3
+ <div class="mb-1 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">{{
7
+ label
8
+ }}</label>
9
+ <!-- asterisk sign to render if field is required -->
10
+ <p v-if="isRequired" class="ml-1 text-red-600">*</p>
11
+ </div>
12
+ <span v-if="hint" class="text-sm text-gray-500">{{ hint }}</span>
13
+ </div>
14
+ <v-select
15
+ class="disabled-opacity-50 disabled-pointer-events-none disabled-cursor-default absolute inline-block h-full w-full text-sm"
16
+ :placeholder="placeholder"
17
+ :multiple="isMultiple"
18
+ :taggable="isTaggable"
19
+ :push-tags="pushTags"
20
+ :filterable="filterable"
21
+ v-model="value"
22
+ :options="isGrouped ? groupedArray : options"
23
+ @input="setSelectedOptions"
24
+ @search="fetchOptions"
25
+ @search:focus="$emit('search:focus')"
26
+ @option:selecting="handleSingleSelect"
27
+ :label="optionLabel"
28
+ :clearable="clearable"
29
+ :loading="loading"
30
+ @open="onOpen"
31
+ @close="onClose"
32
+ :disabled="isDisabled"
33
+ :selectable="
34
+ isGrouped
35
+ ? (groupedArray) =>
36
+ groupedArray.header ? groupedArray.disabled : true
37
+ : (options) => getDisableOptions(options)
38
+ "
39
+ >
40
+ <template #open-indicator="{ attributes }">
41
+ <span
42
+ v-bind="attributes"
43
+ :style="!shouldIconRotate ? 'transform:none;' : ''"
44
+ >
45
+ <c-icon
46
+ v-if="icon"
47
+ :name="icon.name"
48
+ :type="icon.type"
49
+ class="h-5 w-5 text-gray-400"
50
+ />
51
+ <c-icon
52
+ v-else
53
+ :name="'chevron-down-outline-v2'"
54
+ :type="'outline-v2'"
55
+ class="h-4 w-4 text-gray-400"
56
+ viewBox="0 0 24 24"
57
+ />
58
+ </span>
59
+ </template>
60
+ <!--Selected option slot-->
61
+ <template v-if="addCheckBox" #selected-option-container="{ option }">
62
+ <div class="flex items-center justify-center truncate bg-white">
63
+ <div
64
+ v-if="getIndex(option) == 0"
65
+ class="flex items-center overflow-hidden"
66
+ >
67
+ <c-avatar
68
+ v-if="option[imageLabel]"
69
+ :size="'extraextrasmall'"
70
+ :image="option[imageLabel]"
71
+ :rounded="true"
72
+ ></c-avatar>
73
+ <c-avatar
74
+ v-if="option.initials && !option.icon && !option[imageLabel]"
75
+ :size="'extraextrasmall'"
76
+ :nameInitials="option.initials"
77
+ :rounded="true"
78
+ :isDynamicallyColored="true"
79
+ ></c-avatar>
80
+ <c-icon
81
+ v-if="option.icon && !option[imageLabel] && !option.initials"
82
+ :name="option.icon.name"
83
+ :type="option.icon.type"
84
+ class="h-5 w-5 text-gray-400"
85
+ />
86
+ <span class="text-start ml-2 inline-block truncate text-sm">{{
87
+ option[optionLabel]
88
+ }}</span>
89
+ </div>
90
+ <div v-if="getIndex(option) == 1" class="ml-1 flex items-center">
91
+ +{{ value.length - 1 }}
92
+ </div>
93
+ </div>
94
+ </template>
95
+ <!-- eslint-disable-next-line vue/no-unused-vars -->
96
+ <template #no-options="{ search, searching, loading }">
97
+ <span v-if="search.length < 1"
98
+ >Start typing to search for options...</span
99
+ >
100
+ <span v-else>No options found, try searching something else.</span>
101
+ </template>
102
+ <template #spinner="{ loading }">
103
+ <svg
104
+ class="h-5 w-5 animate-spin text-gray-400"
105
+ xmlns="http://www.w3.org/2000/svg"
106
+ fill="none"
107
+ viewBox="0 0 24 24"
108
+ v-if="loading"
109
+ >
110
+ <circle
111
+ class="opacity-25"
112
+ cx="12"
113
+ cy="12"
114
+ r="10"
115
+ stroke="currentColor"
116
+ stroke-width="4"
117
+ ></circle>
118
+ <path
119
+ class="opacity-75"
120
+ fill="currentColor"
121
+ 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"
122
+ ></path>
123
+ </svg>
124
+ </template>
125
+ <template slot="option" slot-scope="option">
126
+ <slot
127
+ name="custom-option"
128
+ v-bind:option="isGrouped ? option : groupedArray"
129
+ ></slot>
130
+ </template>
131
+ <template v-slot:option="option">
132
+ <div v-if="!isGrouped">
133
+ <div :class="`mt-1 flex h-full w-full items-center hover:text-white`">
134
+ <p v-if="showOptionImage" class="flex-shrink-0">
135
+ <c-avatar
136
+ v-if="option[imageLabel]"
137
+ :size="
138
+ option.description && showAdditionalText
139
+ ? 'extrasmall'
140
+ : 'extraextrasmall'
141
+ "
142
+ :image="option[imageLabel]"
143
+ :rounded="true"
144
+ :description="option.description"
145
+ class="mr-2"
146
+ ></c-avatar>
147
+ <c-avatar
148
+ v-if="!option.icon && !option[imageLabel] && option.initials"
149
+ :size="
150
+ option.description && showAdditionalText
151
+ ? 'extrasmall'
152
+ : 'extraextrasmall'
153
+ "
154
+ :nameInitials="option.initials"
155
+ :description="option.description"
156
+ :rounded="true"
157
+ :isDynamicallyColored="true"
158
+ class="mr-2"
159
+ ></c-avatar>
160
+ <c-icon
161
+ v-if="option.icon && !option[imageLabel] && !option.initials"
162
+ :name="option.icon.name"
163
+ :type="option.icon.type"
164
+ class="mr-2 h-5 w-5 text-gray-400"
165
+ />
166
+ </p>
167
+ <div class="w-full hover:text-white">
168
+ <div class="flex items-center justify-between">
169
+ <div class="flex items-center">
170
+ <p>{{ option[optionLabel] }}</p>
171
+ <div class="ml-3">
172
+ <span
173
+ v-if="tags && option.info && option.info !== ''"
174
+ class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
175
+ >
176
+ {{ option.info }}
177
+ </span>
178
+ <span v-else class="-ml-3 text-gray-300">
179
+ &nbsp;{{ option.info }}
180
+ </span>
181
+ </div>
182
+ </div>
183
+ <c-checkbox v-if="addCheckBox" :value="isChecked(option)" />
184
+ </div>
185
+ <p
186
+ class="text-xs"
187
+ v-if="option.description && showAdditionalText"
188
+ >
189
+ {{ option.description }}
190
+ </p>
191
+ </div>
192
+ </div>
193
+ </div>
194
+ <div v-if="isGrouped">
195
+ <v-list-subheader v-if="groupedArray.header">
196
+ {{ groupedArray.header }}
197
+ </v-list-subheader>
198
+ <div
199
+ :class="`mt-1 flex h-full w-full hover:text-white ${
200
+ groupedArray.description ? 'items-start' : 'items-center'
201
+ }`"
202
+ >
203
+ <div v-if="!groupedArray.header && showOptionImage">
204
+ <c-avatar
205
+ v-if="groupedArray.image"
206
+ size="extraextrasmall"
207
+ :image="groupedArray.image"
208
+ :rounded="true"
209
+ :description="groupedArray.description"
210
+ class="mr-2"
211
+ ></c-avatar>
212
+ <c-avatar
213
+ v-else
214
+ size="extraextrasmall"
215
+ :nameInitials="groupedArray.initials"
216
+ :description="groupedArray.description"
217
+ :rounded="true"
218
+ :isDynamicallyColored="true"
219
+ class="mr-2"
220
+ ></c-avatar>
221
+ </div>
222
+ <div class="w-full hover:text-white">
223
+ <div class="flex items-center">
224
+ <p>{{ groupedArray[optionLabel] }}</p>
225
+ <div class="ml-3">
226
+ <span
227
+ v-if="tags && groupedArray.info && groupedArray.info !== ''"
228
+ class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
229
+ >
230
+ {{ groupedArray.info }}
231
+ </span>
232
+ <span v-else class="text-gray-300">
233
+ {{ groupedArray.info }}
234
+ </span>
235
+ </div>
236
+ </div>
237
+
238
+ <p class="text-xs" v-if="groupedArray.description">
239
+ {{ groupedArray.description }}
240
+ </p>
241
+ </div>
242
+ </div>
243
+ </div>
244
+ </template>
245
+ <template #list-footer>
246
+ <li ref="load" class="loader" v-show="hasNextPage">
247
+ Loading more options...
248
+ </li>
249
+ <li
250
+ v-if="showFooterButton"
251
+ 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"
252
+ :class="footerBtnClasses"
253
+ id="listbox-option-0"
254
+ role="option"
255
+ @click="$emit('footerButtonClick')"
256
+ >
257
+ <div class="flex items-center">
258
+ <svg
259
+ xmlns="http://www.w3.org/2000/svg"
260
+ class="h-6 w-6 flex-shrink-0 text-gray-400"
261
+ viewBox="0 0 20 20"
262
+ fill="currentColor"
263
+ >
264
+ <path
265
+ fill-rule="evenodd"
266
+ 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"
267
+ clip-rule="evenodd"
268
+ />
269
+ </svg>
270
+ <span class="ml-3 block truncate font-semibold">
271
+ {{ footerButtonText }}
272
+ </span>
273
+ </div>
274
+ </li>
275
+ </template>
276
+ </v-select>
277
+
278
+ <p v-if="subLabel" class="mt-1 text-sm text-gray-500">{{ subLabel }}</p>
279
+ <p v-if="!isValidate" class="mt-1 text-sm text-red-600">
280
+ {{ errorMessage }}
281
+ </p>
282
+ <p v-if="helpText && isValidate == true" class="mt-1 text-sm text-gray-500">
283
+ {{ helpText }}
284
+ </p>
285
+ </div>
286
+ </template>
287
+ <script>
288
+ import vSelect from "vue-select";
289
+ import CAvatar from "../CAvatar/CAvatar.vue";
290
+ import CIcon from "../CIcon/CIcon.vue";
291
+ import CCheckbox from "../CCheckbox/CCheckbox.vue";
292
+ import { debounce } from "lodash-es";
293
+ // import Fuse from "fuse.js";
294
+ import "vue-select/dist/vue-select.css";
295
+ export default {
296
+ name: "CMultiselect",
297
+ components: { vSelect, CAvatar, CCheckbox, CIcon },
298
+ props: {
299
+ options: {
300
+ type: Array,
301
+ required: true,
302
+ },
303
+ extraDetails: {
304
+ type: Boolean,
305
+ default: false,
306
+ },
307
+ showFooterButton: {
308
+ type: Boolean,
309
+ default: false,
310
+ },
311
+ footerButtonText: {
312
+ type: String,
313
+ default: "",
314
+ },
315
+ label: String,
316
+ isRequired: {
317
+ type: Boolean,
318
+ },
319
+ subLabel: String,
320
+ placeholder: {
321
+ type: String,
322
+ },
323
+ // whether multiple fields are allowed or not
324
+ isMultiple: {
325
+ type: Boolean,
326
+ },
327
+ // append newly created tags in options
328
+ pushTags: {
329
+ type: Boolean,
330
+ },
331
+ // whether to allow user to create new options
332
+ isTaggable: {
333
+ type: Boolean,
334
+ },
335
+ getOptions: {
336
+ // function to emit on search{
337
+ type: Function,
338
+ },
339
+ customiseOption: {
340
+ type: Boolean,
341
+ },
342
+ // whether to show profile picture in option
343
+ showOptionImage: {
344
+ type: Boolean,
345
+ },
346
+ // the name of the option to render in the selectpicker
347
+ optionLabel: {
348
+ type: String,
349
+ },
350
+ // action to trigger after selecting option from dropdown
351
+ onSelectOptions: {
352
+ type: Function,
353
+ },
354
+ optionsSelected: {
355
+ type: [Array, Object],
356
+ },
357
+ filterable: {
358
+ type: Boolean,
359
+ default: false,
360
+ },
361
+ clearable: {
362
+ type: Boolean,
363
+ default: true,
364
+ },
365
+ isValidate: {
366
+ type: Boolean,
367
+ default: true,
368
+ },
369
+ errorMessage: {
370
+ type: String,
371
+ },
372
+ loading: {
373
+ type: Boolean,
374
+ default: false,
375
+ },
376
+ hasNextPage: {
377
+ type: Boolean,
378
+ default: false,
379
+ },
380
+ isDisabled: {
381
+ type: Boolean,
382
+ default: false,
383
+ },
384
+ // text adjacent to label of dropdown to provide hint about field
385
+ hint: { type: String },
386
+ helpText: {
387
+ type: String,
388
+ },
389
+ tags: {
390
+ type: Boolean,
391
+ default: false,
392
+ },
393
+ isGrouped: {
394
+ type: Boolean,
395
+ default: false,
396
+ },
397
+ //to show the additional text, default true to prevent failure at any other place
398
+ showAdditionalText: {
399
+ type: Boolean,
400
+ default: true,
401
+ },
402
+ addCheckBox: {
403
+ type: Boolean,
404
+ default: false,
405
+ },
406
+ showSelectedAvatar: {
407
+ type: Boolean,
408
+ default: false,
409
+ },
410
+ icon: {
411
+ type: Object,
412
+ },
413
+ footerBtnClasses: {
414
+ type: String,
415
+ },
416
+ shouldIconRotate: {
417
+ type: Boolean,
418
+ default: true,
419
+ },
420
+ imageLabel: {
421
+ type: String,
422
+ default: "image",
423
+ },
424
+ },
425
+ computed: {
426
+ groupedArray() {
427
+ const groups = {};
428
+
429
+ this.options.forEach((x) => {
430
+ // create empty object if it doesn't exists.
431
+ groups[x.category] = groups[x.category] || {
432
+ text: x.category,
433
+ list: [],
434
+ };
435
+
436
+ groups[x.category].list.push(x);
437
+ });
438
+
439
+ // The flattened list of items that holds items as well as unique headers
440
+ const flattened = [];
441
+
442
+ // Iterate over all the unique categories and
443
+ // then flatten into a list that v-select needs.
444
+ Object.keys(groups).forEach((categoryId) => {
445
+ const category = groups[categoryId];
446
+ const categoryName = category.text;
447
+
448
+ // Create a group
449
+ flattened.push({ header: categoryName });
450
+
451
+ // Add all the items followed by category header
452
+ flattened.push(...category.list);
453
+ });
454
+
455
+ return flattened;
456
+ },
457
+ },
458
+ data() {
459
+ return {
460
+ loaderSearching: true,
461
+ value:
462
+ this.optionsSelected && this.optionsSelected.length
463
+ ? this.optionsSelected
464
+ : [],
465
+ observer: null,
466
+ };
467
+ },
468
+ methods: {
469
+ fetchOptions(search, loaderSearching) {
470
+ this.emitGetOptions(search, loaderSearching);
471
+ },
472
+ emitGetOptions: debounce(function (search, loaderSearching) {
473
+ this.$emit("getOptions", search, loaderSearching);
474
+ }, 300),
475
+ setSelectedOptions(params) {
476
+ this.value = params;
477
+ this.$emit("onSelectOptions", params);
478
+ },
479
+ async onOpen() {
480
+ if (this.hasNextPage) {
481
+ await this.$nextTick();
482
+ if (this.$refs?.load && this.observer) {
483
+ this.observer.observe(this.$refs.load);
484
+ } else {
485
+ setTimeout(() => {
486
+ this.onOpen();
487
+ }, 500);
488
+ }
489
+ }
490
+ this.emitGetOptions("", true);
491
+ },
492
+ onClose() {
493
+ this.observer.disconnect();
494
+ },
495
+ async infiniteScroll([{ isIntersecting }]) {
496
+ if (isIntersecting) {
497
+ this.emitLoadNextPage();
498
+ }
499
+ },
500
+ getIndex(option) {
501
+ return this.value.findIndex((item) => item.id == option.id);
502
+ },
503
+ isChecked(option) {
504
+ return this.value.findIndex((item) => item.id == option.id) == -1 ? 0 : 1;
505
+ },
506
+
507
+ handleSingleSelect(option) {
508
+ if (this.addCheckBox) {
509
+ if (this.isChecked(option) == 1) {
510
+ if (this.value.length == 1) {
511
+ // if there only one option selected dont allow to deselect it
512
+ return;
513
+ }
514
+ this.value = this.value.filter((item) => item.id != option.id);
515
+ this.$emit("onSelectOptions", this.value);
516
+ } else {
517
+ this.$emit("onSingleSelectOption", option);
518
+ }
519
+ }
520
+ },
521
+ getDisableOptions(options) {
522
+ if (this.addCheckBox && options.isDisabled) {
523
+ return !options.isDisabled;
524
+ } else {
525
+ return options.header ? options.disabled : true;
526
+ }
527
+ },
528
+
529
+ // a function that will set the location when the component has mounted and the location is passed after that
530
+ forceSetData(params) {
531
+ this.value = params;
532
+ },
533
+ emitLoadNextPage: debounce(function () {
534
+ this.$emit("loadNextPage");
535
+ }, 300),
536
+ },
537
+ watch: {
538
+ optionsSelected: {
539
+ handler() {
540
+ this.value = this.optionsSelected;
541
+ },
542
+ deep: true,
543
+ },
544
+ },
545
+ mounted() {
546
+ this.observer = new IntersectionObserver(this.infiniteScroll);
547
+ },
548
+ };
549
+ </script>
550
+ <style>
551
+ .disabled {
552
+ pointer-events: none;
553
+ color: #bfcbd9;
554
+ cursor: not-allowed;
555
+ background-image: none;
556
+ background-color: #eef1f6;
557
+ border-color: #d1dbe5;
558
+ }
559
+ .v-select {
560
+ @apply cursor-pointer;
561
+ }
562
+ .vs__dropdown-toggle {
563
+ @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;
564
+ padding-top: 0.35rem;
565
+ padding-bottom: 0.35rem;
566
+ }
567
+ .vs__selected-options {
568
+ @apply overflow-hidden;
569
+ flex-wrap: nowrap;
570
+ }
571
+ .vs--open .vs__dropdown-toggle {
572
+ border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
573
+ @apply rounded-b-md;
574
+ }
575
+ .vs__selected {
576
+ @apply m-0 mr-1 border-none py-0 pl-1.5 pr-1.5;
577
+ margin-bottom: 2px;
578
+ }
579
+ .extra:hover {
580
+ color: white;
581
+ }
582
+ .vs__selected-options {
583
+ @apply pl-0;
584
+ padding-top: 0.5px;
585
+ padding-bottom: 1px;
586
+ }
587
+ .vs__search,
588
+ .vs__search:focus {
589
+ @apply m-0 p-0;
590
+ }
591
+ .vs__actions {
592
+ @apply pt-0 pr-3;
593
+ }
594
+ .vs__dropdown-menu {
595
+ @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;
596
+ }
597
+ .vs__dropdown-option {
598
+ @apply whitespace-normal py-2;
599
+ }
600
+
601
+ .vs__dropdown-toggle.vs__dropdown-option--highlight {
602
+ @apply bg-indigo-700 text-white;
603
+ }
604
+
605
+ .vs__dropdown-option--highlight {
606
+ @apply bg-indigo-700 text-white;
607
+ }
608
+ .vs__dropdown-option--disabled {
609
+ pointer-events: none;
610
+ }
611
+
612
+ .vs__dropdown-toggle {
613
+ height: 100%;
614
+ }
615
+ </style>