classcard-ui 0.2.774 → 0.2.775

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