classcard-ui 0.2.605 → 0.2.608

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