classcard-ui 0.2.1484 → 0.2.1486

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 (212) hide show
  1. package/README.md +24 -24
  2. package/dist/classcard-ui.common.js +122 -108
  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 +122 -108
  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 +84 -84
  10. package/src/App.vue +16 -16
  11. package/src/colorConfig.js +52 -52
  12. package/src/components/CAlertModal/CAlertModal.vue +179 -179
  13. package/src/components/CAlertModal/index.js +3 -3
  14. package/src/components/CAlerts/CAlerts.vue +114 -114
  15. package/src/components/CAlerts/index.js +2 -2
  16. package/src/components/CAnchorTabs/CAnchorTabs.vue +100 -100
  17. package/src/components/CAnchorTabs/index.js +2 -2
  18. package/src/components/CAnchorTag/CAnchorTag.vue +84 -84
  19. package/src/components/CAnchorTag/index.js +2 -2
  20. package/src/components/CAvatar/CAvatar.vue +232 -225
  21. package/src/components/CAvatar/index.js +2 -2
  22. package/src/components/CAvatarGroup/CAvatarGroup.vue +213 -213
  23. package/src/components/CAvatarGroup/index.js +2 -2
  24. package/src/components/CBasicTable/CBasicTable.vue +184 -184
  25. package/src/components/CBasicTable/index.js +2 -2
  26. package/src/components/CBreadcrumbs/CBreadcrumbs.vue +38 -38
  27. package/src/components/CBreadcrumbs/index.js +2 -2
  28. package/src/components/CButton/CButton.vue +239 -239
  29. package/src/components/CButton/index.js +2 -2
  30. package/src/components/CButtonGroup/CButtonGroup.vue +155 -155
  31. package/src/components/CButtonGroup/index.js +2 -2
  32. package/src/components/CButtonIcon/CButtonIcon.vue +166 -166
  33. package/src/components/CButtonIcon/index.js +2 -2
  34. package/src/components/CButtonLink/CButtonLink.vue +43 -43
  35. package/src/components/CButtonLink/index.js +2 -2
  36. package/src/components/CButtonSelect/CButtonSelect.vue +186 -186
  37. package/src/components/CButtonSelect/index.js +2 -2
  38. package/src/components/CButtonSelectBorder/CButtonSelectBorder.vue +265 -265
  39. package/src/components/CButtonSelectBorder/index.js +3 -3
  40. package/src/components/CButtonWithDropdown/CButtonWithDropdown.vue +152 -152
  41. package/src/components/CButtonWithDropdown/index.js +2 -2
  42. package/src/components/CCalendar/CCalendar.vue +443 -443
  43. package/src/components/CCalendar/index.js +3 -3
  44. package/src/components/CCard/CCard.vue +53 -53
  45. package/src/components/CCard/index.js +2 -2
  46. package/src/components/CCheckbox/CCheckbox.vue +200 -200
  47. package/src/components/CCheckbox/index.js +2 -2
  48. package/src/components/CCircularButton/CCircularButton.vue +57 -57
  49. package/src/components/CCircularButton/index.js +2 -2
  50. package/src/components/CCollapsibleSection/CCollapsibleSection.vue +121 -121
  51. package/src/components/CCollapsibleSection/index.js +2 -2
  52. package/src/components/CColorDots/CColorDots.vue +52 -52
  53. package/src/components/CColorDots/index.js +3 -3
  54. package/src/components/CConfirmActionModal/CConfirmActionModal.vue +253 -253
  55. package/src/components/CConfirmActionModal/index.js +3 -3
  56. package/src/components/CDatepicker/CDatepicker.vue +235 -235
  57. package/src/components/CDatepicker/index.js +2 -2
  58. package/src/components/CDualSelect/CDualSelect.vue +193 -193
  59. package/src/components/CDualSelect/index.js +2 -2
  60. package/src/components/CEditor/CEditor.vue +114 -114
  61. package/src/components/CEditor/index.js +2 -2
  62. package/src/components/CFormSectionHeading/CFormSectionHeading.vue +76 -76
  63. package/src/components/CFormSectionHeading/index.js +2 -2
  64. package/src/components/CGroupedFilterDropdown/CGroupedFilterDropdown.vue +331 -331
  65. package/src/components/CGroupedFilterDropdown/index.js +2 -2
  66. package/src/components/CGroupedSelect/CGroupedSelect.vue +366 -366
  67. package/src/components/CGroupedSelect/index.js +3 -3
  68. package/src/components/CIcon/CIcon.vue +112 -112
  69. package/src/components/CIcon/index.js +2 -2
  70. package/src/components/CIconDropdown/CIconDropdown.vue +206 -206
  71. package/src/components/CIconDropdown/index.js +2 -2
  72. package/src/components/CIconSelect/CIconSelect.vue +182 -182
  73. package/src/components/CIconSelect/index.js +3 -3
  74. package/src/components/CInput/CInput.vue +173 -173
  75. package/src/components/CInput/index.js +2 -2
  76. package/src/components/CInputAddon/CInputAddon.vue +297 -297
  77. package/src/components/CInputAddon/index.js +2 -2
  78. package/src/components/CInputEmail/CInputEmail.vue +107 -107
  79. package/src/components/CInputEmail/index.js +2 -2
  80. package/src/components/CInsetTabs/CInsetTabs.vue +141 -141
  81. package/src/components/CInsetTabs/index.js +3 -3
  82. package/src/components/CLinearProgressBar/CLinearProgressBar.vue +35 -35
  83. package/src/components/CLinearProgressBar/index.js +2 -2
  84. package/src/components/CModalHeading/CModalHeading.vue +22 -22
  85. package/src/components/CModalHeading/index.js +2 -2
  86. package/src/components/CModuleHelpLinks/CModuleHelpLinks.vue +88 -88
  87. package/src/components/CModuleHelpLinks/index.js +3 -3
  88. package/src/components/CMultiselect/CMultiselect.vue +1298 -1298
  89. package/src/components/CMultiselect/index.js +2 -2
  90. package/src/components/CMultiselectr/CMultiselectr.vue +44 -44
  91. package/src/components/CMultiselectr/index.js +2 -2
  92. package/src/components/CPageHeading/CPageHeading.vue +83 -83
  93. package/src/components/CPageHeading/index.js +2 -2
  94. package/src/components/CPagination/CPagination.vue +239 -239
  95. package/src/components/CPagination/index.js +2 -2
  96. package/src/components/CPhoneNumber/CPhoneNumber.vue +213 -213
  97. package/src/components/CPhoneNumber/index.js +2 -2
  98. package/src/components/CProgress/CProgress.vue +91 -91
  99. package/src/components/CProgress/index.js +2 -2
  100. package/src/components/CRadio/CRadio.vue +197 -197
  101. package/src/components/CRadio/index.js +2 -2
  102. package/src/components/CRadioGroup/CRadioGroup.vue +96 -96
  103. package/src/components/CRadioGroup/index.js +2 -2
  104. package/src/components/CRangeSlider/CRangeSlider.vue +55 -55
  105. package/src/components/CRangeSlider/index.js +2 -2
  106. package/src/components/CReorderableStackedList/CReorderableStackedList.vue +94 -94
  107. package/src/components/CReorderableStackedList/index.js +2 -2
  108. package/src/components/CSelect/CSelect.vue +1216 -1216
  109. package/src/components/CSelect/index.js +2 -2
  110. package/src/components/CSmallTimeline/CSmallTimeline.vue +40 -40
  111. package/src/components/CSmallTimeline/index.js +2 -2
  112. package/src/components/CStackedList/CStackedList.vue +162 -162
  113. package/src/components/CStackedList/index.js +2 -2
  114. package/src/components/CStats/CStats.vue +157 -157
  115. package/src/components/CStats/index.js +2 -2
  116. package/src/components/CSwitch/CSwitch.vue +200 -200
  117. package/src/components/CSwitch/index.js +2 -2
  118. package/src/components/CTabLazy/CTabLazy.vue +83 -83
  119. package/src/components/CTabLazy/index.js +2 -2
  120. package/src/components/CTable/CTable.vue +1114 -1114
  121. package/src/components/CTable/index.js +2 -2
  122. package/src/components/CTabs/CTabs.vue +250 -250
  123. package/src/components/CTabs/index.js +2 -2
  124. package/src/components/CTag/CTag.vue +109 -109
  125. package/src/components/CTag/index.js +2 -2
  126. package/src/components/CTextarea/CTextarea.vue +118 -118
  127. package/src/components/CTextarea/index.js +2 -2
  128. package/src/components/CTimeline/CTimeline.vue +237 -237
  129. package/src/components/CTimeline/index.js +2 -2
  130. package/src/components/CToolTip/CToolTip.vue +108 -108
  131. package/src/components/CToolTip/index.js +3 -3
  132. package/src/components/CUpload/CUpload.vue +332 -331
  133. package/src/components/CUpload/index.js +2 -2
  134. package/src/components/NumberAnimator.vue +112 -112
  135. package/src/components/index.js +58 -58
  136. package/src/helper.js +8 -8
  137. package/src/icons.js +833 -833
  138. package/src/main.js +22 -22
  139. package/src/stories/CAlertModal.stories.js +30 -30
  140. package/src/stories/CAlerts.stories.js +39 -39
  141. package/src/stories/CAnchorTabs.stories.js +29 -29
  142. package/src/stories/CAnchorTag.stories.js +38 -38
  143. package/src/stories/CAvatar.stories.js +38 -38
  144. package/src/stories/CAvatarGroup.stories.js +136 -136
  145. package/src/stories/CBasicTable.stories.js +316 -316
  146. package/src/stories/CBreadcrumbs.stories.js +24 -24
  147. package/src/stories/CButton.stories.js +49 -49
  148. package/src/stories/CButtonGroup.stories.js +43 -43
  149. package/src/stories/CButtonIcon.stories.js +27 -27
  150. package/src/stories/CButtonLink.stories.js +24 -24
  151. package/src/stories/CButtonSelect.stories.js +44 -44
  152. package/src/stories/CButtonSelectBorder.stories.js +56 -56
  153. package/src/stories/CButtonWithDropdown.stories.js +41 -41
  154. package/src/stories/CCalendar.stories.js +16 -16
  155. package/src/stories/CCard.stories.js +30 -30
  156. package/src/stories/CCheckbox.stories.js +38 -38
  157. package/src/stories/CCircularButton.stories.js +29 -29
  158. package/src/stories/CCollapsibleSection.stories.js +29 -29
  159. package/src/stories/CColorDots.stories.js +37 -37
  160. package/src/stories/CConfirmActionModal.stories.js +67 -67
  161. package/src/stories/CDatepicker.stories.js +31 -31
  162. package/src/stories/CDualSelect.stories.js +29 -29
  163. package/src/stories/CEditor.stories.js +30 -30
  164. package/src/stories/CFormSectionHeading.stories.js +37 -37
  165. package/src/stories/CGroupedFilterDropdown.stories.js +131 -131
  166. package/src/stories/CGroupedSelect.stories.js +103 -103
  167. package/src/stories/CIcon.stories.js +31 -31
  168. package/src/stories/CIconDropdown.stories.js +52 -52
  169. package/src/stories/CIconSelect.stories.js +45 -45
  170. package/src/stories/CInput.stories.js +36 -36
  171. package/src/stories/CInputAddon.stories.js +37 -37
  172. package/src/stories/CInputEmail.stories.js +27 -27
  173. package/src/stories/CInsetTabs.stories.js +48 -48
  174. package/src/stories/CLinearProgressBar.stories.js +22 -22
  175. package/src/stories/CModalHeading.stories.js +25 -25
  176. package/src/stories/CModuleHelpLinks.stories.js +25 -25
  177. package/src/stories/CMultiselect.stories.js +146 -146
  178. package/src/stories/CMultiselectr.stories.js +23 -23
  179. package/src/stories/CPageHeading.stories.js +32 -32
  180. package/src/stories/CPagination.stories.js +30 -30
  181. package/src/stories/CPhoneNumber.stories.js +37 -37
  182. package/src/stories/CProgress.stories.js +23 -23
  183. package/src/stories/CRadio.stories.js +44 -44
  184. package/src/stories/CRadioGroup.stories.js +51 -51
  185. package/src/stories/CRangeSlider.stories.js +23 -23
  186. package/src/stories/CReorderableStackedList.stories.js +23 -23
  187. package/src/stories/CSelect.stories.js +157 -157
  188. package/src/stories/CSmallTimeline.stories.js +26 -26
  189. package/src/stories/CStackedList.stories.js +37 -37
  190. package/src/stories/CStats.stories.js +53 -53
  191. package/src/stories/CSwitch.stories.js +28 -28
  192. package/src/stories/CTabLazy.stories.js +42 -42
  193. package/src/stories/CTable.stories.js +203 -203
  194. package/src/stories/CTabs.stories.js +36 -36
  195. package/src/stories/CTag.stories.js +37 -37
  196. package/src/stories/CTextarea.stories.js +32 -32
  197. package/src/stories/CTimeline.stories.js +26 -26
  198. package/src/stories/CToolTip.stories.js +27 -27
  199. package/src/stories/CUpload.stories.js +36 -36
  200. package/src/stories/Introduction.stories.mdx +207 -207
  201. package/src/stories/Page.vue +88 -88
  202. package/src/stories/assets/code-brackets.svg +0 -0
  203. package/src/stories/assets/colors.svg +0 -0
  204. package/src/stories/assets/comments.svg +0 -0
  205. package/src/stories/assets/direction.svg +0 -0
  206. package/src/stories/assets/flow.svg +0 -0
  207. package/src/stories/assets/plugin.svg +0 -0
  208. package/src/stories/assets/repo.svg +0 -0
  209. package/src/stories/assets/stackalt.svg +0 -0
  210. package/src/stories/header.css +26 -26
  211. package/src/stories/page.css +69 -69
  212. package/src/stories/utils.css +32 -32
@@ -1,1298 +1,1298 @@
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
- <div class="relative">
15
- <v-select
16
- ref="vselect"
17
- :class="[
18
- 'disabled:custom-disabled-state absolute inline-block h-full w-full text-sm',
19
- isMultiple && showOverFlowCount ? 'c-multiselect--capped-pills' : '',
20
- ]"
21
- :placeholder="placeholder"
22
- :multiple="isMultiple"
23
- :taggable="isTaggable"
24
- :push-tags="pushTags"
25
- :filterable="filterable"
26
- @keydown.native="handleKeydown"
27
- v-model="value"
28
- :options="isGrouped ? groupedArray : options"
29
- @input="setSelectedOptions"
30
- @search="fetchOptions"
31
- @search:focus="$emit('search:focus')"
32
- @option:selecting="handleSingleSelect"
33
- @option:selected="($event) => (addCheckBox ? null : $event)"
34
- @option:deselected="($event) => (addCheckBox ? null : $event)"
35
- :label="optionLabel"
36
- :clearable="clearable"
37
- :loading="loading"
38
- :id="id"
39
- @open="onOpen"
40
- @close="onClose"
41
- :disabled="isDisabled"
42
- :selectable="
43
- isGrouped
44
- ? (option) => (option.header ? false : getDisableOptions(option))
45
- : (option) => getDisableOptions(option)
46
- "
47
- :closeOnSelect="addCheckBox ? false : isGrouped ? false : true"
48
- >
49
- <template #open-indicator="{ attributes }">
50
- <span
51
- v-bind="attributes"
52
- :style="!shouldIconRotate ? 'transform:none;' : ''"
53
- >
54
- <c-icon
55
- v-if="icon"
56
- :name="icon.name"
57
- :type="icon.type"
58
- class="h-5 w-5 text-gray-400"
59
- />
60
- <c-icon
61
- v-else
62
- name="chevron-down"
63
- type="solid"
64
- class="h-5 w-5 text-gray-400"
65
- />
66
- </span>
67
- </template>
68
- <template
69
- #selected-option-container="{ option, deselect, multiple, disabled }"
70
- >
71
- <template v-for="row in [getPillRow(option)]">
72
- <div
73
- v-if="row && row.showPill"
74
- :key="row.slotKey"
75
- class="vs__selected vs__selected--capped inline-flex items-center gap-1.5"
76
- >
77
- <p
78
- v-if="!option.header"
79
- :class="[
80
- 'vs__selected-inner inline-flex min-w-0 max-w-[120px] items-center gap-1.5 rounded bg-gray-100 px-2 py-1 text-gray-800',
81
- isDisabled ? 'text-gray-500' : '',
82
- ]"
83
- >
84
- <c-icon
85
- v-if="option.icon"
86
- :name="option.icon.name"
87
- :type="option.icon.type"
88
- :class="[
89
- 'h-4 w-4 flex-shrink-0 text-gray-400',
90
- option.icon.optionIconClass,
91
- ]"
92
- />
93
- <c-avatar
94
- v-if="option.image && displaySelectedOptionAvatar"
95
- :size="
96
- option.description && showAdditionalText
97
- ? 'extrasmall'
98
- : 'extraextrasmall'
99
- "
100
- :image="option.image"
101
- :rounded="true"
102
- :description="option.description"
103
- class="flex-shrink-0"
104
- ></c-avatar>
105
- <c-avatar
106
- v-else-if="option.initials && displaySelectedOptionAvatar"
107
- size="extraextrasmall"
108
- :nameInitials="option.initials"
109
- :description="option.description"
110
- :rounded="true"
111
- :isDynamicallyColored="true"
112
- class="flex-shrink-0"
113
- ></c-avatar>
114
- <span class="min-w-0 flex-1 truncate">{{ row.label }}</span>
115
- <button
116
- v-if="multiple"
117
- type="button"
118
- class="flex h-2 w-2 flex-shrink-0 items-center justify-center rounded text-gray-400 focus:outline-none"
119
- :disabled="disabled"
120
- :title="`Deselect ${row.label}`"
121
- :aria-label="`Deselect ${row.label}`"
122
- @click.stop.prevent="deselect(option)"
123
- >
124
- <span class="text-base leading-none" aria-hidden="true"
125
- >×</span
126
- >
127
- </button>
128
- </p>
129
- <span
130
- v-if="row.showOverflowBadge"
131
- class="vs__selected-overflow inline-flex w-max rounded bg-gray-100 px-2 py-1 text-gray-800"
132
- aria-live="polite"
133
- >
134
- +{{ selectedOverflowCount }}
135
- </span>
136
- </div>
137
- </template>
138
- </template>
139
- <!-- eslint-disable-next-line vue/no-unused-vars -->
140
- <template #no-options="{ search, searching, loading }">
141
- <span v-if="search.length < 1"
142
- >Start typing to search for options...</span
143
- >
144
- <span v-else>No options found, try searching something else.</span>
145
- </template>
146
- <template #spinner="{ loading }">
147
- <svg
148
- class="h-5 w-5 animate-spin text-gray-400"
149
- xmlns="http://www.w3.org/2000/svg"
150
- fill="none"
151
- viewBox="0 0 24 24"
152
- v-if="loading"
153
- >
154
- <circle
155
- class="opacity-25"
156
- cx="12"
157
- cy="12"
158
- r="10"
159
- stroke="currentColor"
160
- stroke-width="4"
161
- ></circle>
162
- <path
163
- class="opacity-75"
164
- fill="currentColor"
165
- 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"
166
- ></path>
167
- </svg>
168
- </template>
169
- <template v-slot:option="option">
170
- <slot
171
- v-if="$scopedSlots['custom-option']"
172
- name="custom-option"
173
- :option="option"
174
- />
175
- <template v-else>
176
- <div v-if="!isGrouped">
177
- <div v-if="option.hasNoData" class="dropdown-menu-bordered"></div>
178
- <div v-else class="mt-1 flex h-full w-full items-center">
179
- <div @click.stop v-if="addCheckBox" class="flex-shrink-0">
180
- <c-checkbox
181
- :value="isChecked(option)"
182
- @onChange="handleSingleSelect(option)"
183
- />
184
- </div>
185
- <p v-if="showOptionImage" class="flex-shrink-0">
186
- <c-avatar
187
- v-if="option[imageLabel]"
188
- :size="
189
- option.description && showAdditionalText
190
- ? 'extrasmall'
191
- : 'extraextrasmall'
192
- "
193
- :image="option[imageLabel]"
194
- :rounded="true"
195
- :description="option.description"
196
- class="mr-2"
197
- ></c-avatar>
198
- <c-avatar
199
- v-if="
200
- !option.icon && !option[imageLabel] && option.initials
201
- "
202
- :size="
203
- option.description && showAdditionalText
204
- ? 'extrasmall'
205
- : 'extraextrasmall'
206
- "
207
- :nameInitials="option.initials"
208
- :description="option.description"
209
- :rounded="true"
210
- :isDynamicallyColored="true"
211
- class="mr-2"
212
- ></c-avatar>
213
- <c-icon
214
- v-if="
215
- option.icon && !option[imageLabel] && !option.initials
216
- "
217
- :name="option.icon.name"
218
- :type="option.icon.type"
219
- :class="`mr-2 h-5 w-5 text-gray-400 ${
220
- option.icon.optionIconClass
221
- ? option.icon.optionIconClass
222
- : ''
223
- }`"
224
- cursorType="cursor-pointer"
225
- />
226
- </p>
227
- <div class="w-full">
228
- <div
229
- :class="`flex items-center justify-between ${checkboxWrapperClass}`"
230
- >
231
- <div :class="`flex items-center ${tagWrapperClass}`">
232
- <p>
233
- {{
234
- option[optionLabelSecondary]
235
- ? option[optionLabelSecondary]
236
- : option[optionLabel]
237
- }}
238
- </p>
239
- <div class="ml-3">
240
- <c-tag
241
- v-if="tags && option.info && option.info !== ''"
242
- :label="option.info"
243
- color="gray"
244
- ></c-tag>
245
- <span v-else class="-ml-3 text-gray-300">
246
- &nbsp;{{ option.info }}
247
- </span>
248
- </div>
249
- </div>
250
- </div>
251
- <p
252
- class="text-xs"
253
- v-if="option.description && showAdditionalText"
254
- >
255
- {{ option.description }}
256
- </p>
257
- </div>
258
- </div>
259
- </div>
260
- <div
261
- v-if="isGrouped"
262
- :class="[
263
- option.header
264
- ? 'sticky-group-header -mx-4 -my-2 bg-gray-200 px-3 py-2'
265
- : '',
266
- ]"
267
- >
268
- <v-list-subheader
269
- v-if="option.header"
270
- class="flex items-center gap-1 text-gray-900"
271
- >
272
- <c-icon
273
- v-if="option.icon"
274
- :name="option.icon.name"
275
- :type="option.icon.type"
276
- :class="`${
277
- option.icon.headerIconClass
278
- ? option.icon.headerIconClass
279
- : 'h-4 w-4'
280
- } text-gray-400`"
281
- />
282
- {{ option.header }}
283
- </v-list-subheader>
284
- <div
285
- :class="[
286
- 'mt-1 flex h-full w-full',
287
- option.description ? 'items-start' : 'items-center',
288
- ]"
289
- >
290
- <div @click.stop v-if="addCheckBox && !option.header">
291
- <c-checkbox
292
- :value="isChecked(option)"
293
- @onChange="handleSingleSelect(option)"
294
- />
295
- </div>
296
- <div v-if="!option.header && showOptionImage">
297
- <c-avatar
298
- v-if="option.image"
299
- size="extraextrasmall"
300
- :image="option.image"
301
- :rounded="true"
302
- :description="option.description"
303
- class="mr-2"
304
- ></c-avatar>
305
- <c-avatar
306
- v-else
307
- size="extraextrasmall"
308
- :nameInitials="option.initials"
309
- :description="option.description"
310
- :rounded="true"
311
- :isDynamicallyColored="true"
312
- class="mr-2"
313
- ></c-avatar>
314
- </div>
315
- <div class="w-full">
316
- <div class="flex items-center">
317
- <p>
318
- {{
319
- option[optionLabelSecondary]
320
- ? option[optionLabelSecondary]
321
- : option[optionLabel]
322
- }}
323
- </p>
324
- <div class="ml-3">
325
- <span
326
- v-if="tags && option.info && option.info !== ''"
327
- class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
328
- >
329
- {{ option.info }}
330
- </span>
331
- <span v-else class="text-gray-300">
332
- {{ option.info }}
333
- </span>
334
- </div>
335
- </div>
336
-
337
- <p class="text-xs" v-if="option.description">
338
- {{ option.description }}
339
- </p>
340
- </div>
341
- </div>
342
- </div>
343
- </template>
344
- </template>
345
- <template #list-footer="{ search }">
346
- <li ref="load" class="loader" v-show="hasNextPage">
347
- Loading more options...
348
- </li>
349
-
350
- <!-- Footer buttons when footer buttons are visible -->
351
- <div
352
- v-if="showFooterButton || showFooterButton2"
353
- :class="[
354
- 'group sticky bottom-0 mt-1 bg-white',
355
- showFooterButton && showFooterButton2 ? 'space-y-2' : '',
356
- ]"
357
- >
358
- <li
359
- v-if="showFooterButton"
360
- :class="footerBtnClasses"
361
- class="cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
362
- :id="getActionIDFn(footerButtonText)"
363
- role="option"
364
- @click="$emit('footerButtonClick')"
365
- >
366
- <div class="flex items-center">
367
- <svg
368
- xmlns="http://www.w3.org/2000/svg"
369
- class="h-6 w-6 flex-shrink-0 text-gray-400"
370
- viewBox="0 0 20 20"
371
- fill="currentColor"
372
- >
373
- <path
374
- fill-rule="evenodd"
375
- 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"
376
- clip-rule="evenodd"
377
- />
378
- </svg>
379
- <span class="ml-3 block truncate font-semibold">
380
- {{ footerButtonText }}
381
- </span>
382
- </div>
383
- </li>
384
- <li
385
- v-if="showFooterButton2"
386
- class="cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
387
- :class="footerBtnClasses2"
388
- :id="getActionIDFn(footerButtonText2)"
389
- role="option"
390
- @click="$emit('footerButtonClick2')"
391
- >
392
- <div class="flex items-center">
393
- <svg
394
- xmlns="http://www.w3.org/2000/svg"
395
- class="h-6 w-6 flex-shrink-0 text-gray-400"
396
- viewBox="0 0 20 20"
397
- fill="currentColor"
398
- >
399
- <path
400
- fill-rule="evenodd"
401
- 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"
402
- clip-rule="evenodd"
403
- />
404
- </svg>
405
- <span class="ml-3 block truncate font-semibold">
406
- {{ footerButtonText2 }}
407
- </span>
408
- </div>
409
- </li>
410
- </div>
411
-
412
- <!-- Create option button when showCreateOption is true and there is a search term -->
413
- <div
414
- v-if="
415
- showCreateOption &&
416
- showCreateOptionAfterSearch &&
417
- search &&
418
- search.trim()
419
- "
420
- ref="createOption"
421
- class="sticky z-10 flex min-h-[44px] items-start gap-3 bg-white px-3 py-2 shadow-lg ring-1 ring-gray-900 ring-opacity-5"
422
- :style="footerStickyStyles.create"
423
- >
424
- <span class="word-break flex-1 text-sm text-gray-700">{{
425
- search
426
- }}</span>
427
-
428
- <button
429
- type="button"
430
- :id="id + '_create_button'"
431
- @mousedown="handleCreateOption($event, search)"
432
- class="flex items-center gap-1 text-sm text-indigo-700"
433
- >
434
- <c-icon
435
- type="solid"
436
- name="plus-circle-solid-v2"
437
- class="h-5 w-5 text-indigo-600"
438
- viewBox="0 0 24 24"
439
- ></c-icon>
440
- Create
441
- </button>
442
- </div>
443
-
444
- <!-- Other option checkbox when otherOption is true -->
445
- <div
446
- v-if="otherOption"
447
- ref="otherOption"
448
- class="sticky z-10 border-t border-gray-100 bg-gray-50 px-3 py-2"
449
- :style="footerStickyStyles.other"
450
- >
451
- <div class="flex" @mousedown.prevent.stop>
452
- <c-checkbox
453
- :value="isChecked(otherOption)"
454
- @onChange="handleOtherOptionChange"
455
- />
456
- <div class="flex-1" @click.stop="handleOtherOptionChange">
457
- <p class="text-sm font-medium text-gray-700">
458
- {{ otherOption[optionLabel] }}
459
- </p>
460
- <p class="mt-1 text-sm text-gray-500">
461
- {{ otherOption.description }}
462
- </p>
463
- </div>
464
- </div>
465
- </div>
466
-
467
- <!-- Clear all button when multiple is true and there are selected values -->
468
- <button
469
- v-if="isMultiple && hasSelectedValues"
470
- ref="clearAllButton"
471
- type="button"
472
- class="sticky z-10 w-full border-t border-gray-200 bg-gray-50 px-4 py-3 text-left text-sm text-gray-500 hover:text-gray-900 focus:outline-none"
473
- :style="footerStickyStyles.clear"
474
- :id="id + '_clear_all_button'"
475
- aria-label="Clear all selections"
476
- @mousedown.prevent.stop="handleClearAll"
477
- >
478
- Clear all
479
- </button>
480
- </template>
481
- </v-select>
482
- <button
483
- class="z-100 absolute top-2.5 right-10"
484
- :id="id + '_close_button'"
485
- v-if="showCloseButton && (value == null || value.length == 0)"
486
- @click.stop="handleCrossClick"
487
- >
488
- <c-icon
489
- name="close"
490
- type="outline-v2"
491
- class="h-4 w-4 text-gray-400"
492
- cursorType="cursor-pointer"
493
- />
494
- </button>
495
- </div>
496
- <p v-if="subLabel" class="mt-2 text-sm text-gray-500">{{ subLabel }}</p>
497
- <p
498
- v-if="!isValidate && errorMessage"
499
- class="mt-2 text-left text-sm text-red-600"
500
- >
501
- {{ errorMessage }}
502
- </p>
503
- <p v-if="helpText && isValidate == true" class="mt-2 text-sm text-gray-500">
504
- {{ helpText }}
505
- </p>
506
- </div>
507
- </template>
508
- <script>
509
- import vSelect from "vue-select";
510
- import CAvatar from "../CAvatar/CAvatar.vue";
511
- import CIcon from "../CIcon/CIcon.vue";
512
- import CCheckbox from "../CCheckbox/CCheckbox.vue";
513
- import { debounce } from "lodash-es";
514
- import "vue-select/dist/vue-select.css";
515
- import { getActionID } from "../../helper";
516
- import CTag from "../CTag/CTag.vue";
517
- export default {
518
- name: "CMultiselect",
519
- components: { vSelect, CAvatar, CCheckbox, CIcon, CTag },
520
- props: {
521
- id: {
522
- type: String,
523
- },
524
- clearInput: {
525
- type: Boolean,
526
- default: false,
527
- },
528
- options: {
529
- type: Array,
530
- required: true,
531
- },
532
- extraDetails: {
533
- type: Boolean,
534
- default: false,
535
- },
536
- displaySelectedOptionAvatar: {
537
- type: Boolean,
538
- default: false,
539
- },
540
- showFooterButton: {
541
- type: Boolean,
542
- default: false,
543
- },
544
- footerButtonText: {
545
- type: String,
546
- default: "",
547
- },
548
- label: String,
549
- isRequired: {
550
- type: Boolean,
551
- },
552
- subLabel: String,
553
- placeholder: {
554
- type: String,
555
- },
556
- // whether multiple fields are allowed or not
557
- isMultiple: {
558
- type: Boolean,
559
- },
560
- // append newly created tags in options
561
- pushTags: {
562
- type: Boolean,
563
- },
564
- // whether to allow user to create new options
565
- isTaggable: {
566
- type: Boolean,
567
- },
568
- getOptions: {
569
- // function to emit on search{
570
- type: Function,
571
- },
572
- customiseOption: {
573
- type: Boolean,
574
- },
575
- // whether to show profile picture in option
576
- showOptionImage: {
577
- type: Boolean,
578
- },
579
- // the name of the option to render in the selectpicker
580
- optionLabel: {
581
- type: String,
582
- },
583
- // the name of the option to render in the selectpicker
584
- optionLabelSecondary: {
585
- type: String,
586
- },
587
- selectedOptionLabel: {
588
- type: String,
589
- },
590
- // the key to compare the options when addCheckBox is true
591
- primaryComparisonKey: {
592
- type: String,
593
- default: "id",
594
- },
595
- // action to trigger after selecting option from dropdown
596
- onSelectOptions: {
597
- type: Function,
598
- },
599
- optionsSelected: {
600
- type: [Array, Object],
601
- },
602
- filterable: {
603
- type: Boolean,
604
- default: false,
605
- },
606
- clearable: {
607
- type: Boolean,
608
- default: true,
609
- },
610
- isValidate: {
611
- type: Boolean,
612
- default: true,
613
- },
614
- errorMessage: {
615
- type: String,
616
- },
617
- loading: {
618
- type: Boolean,
619
- default: false,
620
- },
621
- hasNextPage: {
622
- type: Boolean,
623
- default: false,
624
- },
625
- isDisabled: {
626
- type: Boolean,
627
- default: false,
628
- },
629
- // text adjacent to label of dropdown to provide hint about field
630
- hint: { type: String },
631
- helpText: {
632
- type: String,
633
- },
634
- tags: {
635
- type: Boolean,
636
- default: false,
637
- },
638
- isGrouped: {
639
- type: Boolean,
640
- default: false,
641
- },
642
- //to show the additional text, default true to prevent failure at any other place
643
- showAdditionalText: {
644
- type: Boolean,
645
- default: true,
646
- },
647
- addCheckBox: {
648
- type: Boolean,
649
- default: false,
650
- },
651
- showSelectedAvatar: {
652
- type: Boolean,
653
- default: false,
654
- },
655
- icon: {
656
- type: Object,
657
- },
658
- footerBtnClasses: {
659
- type: String,
660
- },
661
- shouldIconRotate: {
662
- type: Boolean,
663
- default: true,
664
- },
665
- imageLabel: {
666
- type: String,
667
- default: "image",
668
- },
669
- showFooterButton2: {
670
- type: Boolean,
671
- default: false,
672
- },
673
- footerButtonText2: {
674
- type: String,
675
- default: "",
676
- },
677
- footerBtnClasses2: {
678
- type: String,
679
- },
680
- showCloseButton: {
681
- type: Boolean,
682
- default: false,
683
- },
684
- showCreateOption: {
685
- type: Boolean,
686
- default: false,
687
- },
688
- otherOption: {
689
- type: Object,
690
- },
691
- tagWrapperClass: {
692
- type: String,
693
- default: "",
694
- },
695
- checkboxWrapperClass: {
696
- type: String,
697
- default: "",
698
- },
699
- // Enables/disables chip insert animation flow (phase 1 + phase 2 sweep).
700
- chipAnimationEnabled: {
701
- type: Boolean,
702
- default: false,
703
- },
704
- // When true, render all selected pills and hide "+N" overflow counter.
705
- showOverFlowCount: {
706
- type: Boolean,
707
- default: true,
708
- },
709
- },
710
- computed: {
711
- groupedArray() {
712
- const groups = {};
713
-
714
- this.options.forEach((x) => {
715
- // create empty object if it doesn't exists.
716
- groups[x.category] = groups[x.category] || {
717
- text: x.category,
718
- list: [],
719
- ...(x.icon ? { icon: x.icon } : {}),
720
- };
721
-
722
- groups[x.category].list.push(x);
723
- });
724
-
725
- // The flattened list of items that holds items as well as unique headers
726
- const flattened = [];
727
-
728
- // Iterate over all the unique categories and
729
- // then flatten into a list that v-select needs.
730
- Object.keys(groups).forEach((categoryId) => {
731
- const category = groups[categoryId];
732
- const categoryName = category.text;
733
-
734
- // Create a group
735
- flattened.push({
736
- header: categoryName,
737
- ...(category.icon ? { icon: category.icon } : {}),
738
- });
739
-
740
- // Add all the items followed by category header
741
- flattened.push(...category.list);
742
- });
743
-
744
- return flattened;
745
- },
746
- showCreateOptionAfterSearch() {
747
- if (!this.showCreateOption) return false;
748
-
749
- // Get current search term from v-select
750
- const vSelectRef = this.$refs.vselect;
751
- const search = (vSelectRef && vSelectRef.search) || "";
752
- const term = search.trim().toLowerCase();
753
- if (!term) return false;
754
-
755
- // Check if any options exactly match the search term
756
- const hasExactMatch = this.options.some((option) => {
757
- const label = option[this.optionLabel];
758
- return label && String(label).toLowerCase() === term;
759
- });
760
-
761
- return !hasExactMatch;
762
- },
763
- /*
764
- This function is used to get the remaining count of options that are not shown in the dropdown.
765
- */
766
- selectedOverflowCount() {
767
- if (!this.isMultiple || !this.showOverFlowCount) return 0;
768
- const totalSelectedOptions = Array.isArray(this.value)
769
- ? this.value.length
770
- : 0;
771
- return totalSelectedOptions > 2 ? totalSelectedOptions - 2 : 0;
772
- },
773
- hasSelectedValues() {
774
- return Array.isArray(this.value) && this.value.length > 0;
775
- },
776
- /**
777
- * Pre-built pill rows keyed by `value[i]` and by vue-select option key.
778
- * Recomputes only when selection / multi / overflow-relevant state changes — not on dropdown hover.
779
- * Index comes from `value` order (same order vue-select uses for selected-option-container).
780
- */
781
- pillRowsBySlotLookup() {
782
- if (!Array.isArray(this.value)) {
783
- return { byRef: new Map(), byKey: new Map() };
784
- }
785
- const byRef = new Map();
786
- const byKey = new Map();
787
- const overflow = this.selectedOverflowCount;
788
-
789
- this.value.forEach((item, index) => {
790
- const label = this.getDisplayLabelForOption(item);
791
- const key = this.getVueSelectOptionKey(item);
792
- const slotKey = `slot-${index}-${String(key)}`;
793
- const meta = { index, key, label, slotKey };
794
- const showPill = this.isMultiple;
795
- const showOverflowBadge =
796
- this.isMultiple &&
797
- this.showOverFlowCount &&
798
- index === 1 &&
799
- overflow > 0;
800
- const row = {
801
- meta,
802
- showPill,
803
- showOverflowBadge,
804
- label,
805
- slotKey,
806
- };
807
- byRef.set(item, row);
808
- if (!byKey.has(key)) {
809
- byKey.set(key, row);
810
- }
811
- });
812
- return { byRef, byKey };
813
- },
814
- /**
815
- * Sticky `bottom` offsets so create → other → clear stack without overlap.
816
- * DOM order is create (top of sticky group), other, clear (anchored to dropdown bottom).
817
- */
818
- footerStickyStyles() {
819
- const clearH = Number(this.footerMetaData.clearAllHeight) || 0;
820
- const otherH = Number(this.footerMetaData.otherOptionHeight) || 0;
821
- return {
822
- create: { bottom: `${clearH + otherH}px` },
823
- other: { bottom: `${clearH}px` },
824
- clear: { bottom: "0px" },
825
- };
826
- },
827
- },
828
- data() {
829
- return {
830
- loaderSearching: true,
831
- value:
832
- this.optionsSelected && this.optionsSelected.length
833
- ? this.optionsSelected
834
- : [],
835
- observer: null,
836
- chipAnimationTimeout: null,
837
- chipAnimationCycle: 0,
838
- hasMounted: false,
839
- footerMetaData: {
840
- clearAllHeight: 0,
841
- otherOptionHeight: 0,
842
- createOptionHeight: 0,
843
- },
844
- };
845
- },
846
- methods: {
847
- clearChipAnimationTimeout() {
848
- if (this.chipAnimationTimeout) {
849
- clearTimeout(this.chipAnimationTimeout);
850
- this.chipAnimationTimeout = null;
851
- }
852
- },
853
- startChipInsertAnimation(insertedCount) {
854
- if (!this.isMultiple || !this.chipAnimationEnabled || !insertedCount)
855
- return;
856
-
857
- this.clearChipAnimationTimeout();
858
- // Increment a cycle token so any previously scheduled async animation work
859
- // can detect it is stale and bail out.
860
- this.chipAnimationCycle += 1;
861
- const animationCycle = this.chipAnimationCycle;
862
- this.$nextTick(() => {
863
- // Guard against race conditions: if another insert happened before this
864
- // tick runs, skip this stale cycle.
865
- if (animationCycle !== this.chipAnimationCycle || !this.$refs.vselect)
866
- return;
867
-
868
- const vSelectEl = this.$refs.vselect.$el;
869
- if (!vSelectEl) return;
870
-
871
- requestAnimationFrame(() => {
872
- // Re-check at frame time because DOM work is deferred one more step.
873
- if (animationCycle !== this.chipAnimationCycle) return;
874
-
875
- const chipElements = Array.from(
876
- vSelectEl.querySelectorAll(".vs__selected"),
877
- );
878
- const chipsToAnimate = chipElements.slice(-insertedCount);
879
-
880
- if (!chipsToAnimate.length) {
881
- return;
882
- }
883
-
884
- const staggerMs = chipsToAnimate.length > 1 ? 80 : 0;
885
- chipsToAnimate.forEach((chipEl, index) => {
886
- chipEl.classList.remove("chip-entering");
887
- void chipEl.offsetWidth;
888
- chipEl.style.setProperty(
889
- "--chip-enter-delay",
890
- `${index * staggerMs}ms`,
891
- );
892
- chipEl.classList.add("chip-entering");
893
- });
894
-
895
- const totalPhaseOneDuration =
896
- (chipsToAnimate.length - 1) * staggerMs + 320;
897
- this.chipAnimationTimeout = setTimeout(() => {
898
- if (animationCycle !== this.chipAnimationCycle) return;
899
- chipsToAnimate.forEach((chipEl) => {
900
- chipEl.classList.remove("chip-entering");
901
- chipEl.style.removeProperty("--chip-enter-delay");
902
- });
903
- }, totalPhaseOneDuration);
904
- });
905
- });
906
- },
907
- getActionIDFn(name) {
908
- return getActionID(name, this.id);
909
- },
910
- handleCrossClick(event) {
911
- event.preventDefault();
912
- this.$emit("hide-multiselect-dropdown");
913
- },
914
- fetchOptions(search, loaderSearching) {
915
- this.emitGetOptions(search, loaderSearching);
916
-
917
- this._updateFooterHeights();
918
- },
919
- emitGetOptions: debounce(function (search, loaderSearching) {
920
- this.$emit("getOptions", search.trim(), loaderSearching);
921
- }, 300),
922
- setSelectedOptions(params) {
923
- //this prevents animation to run, we have a watcher that will instate value correctly
924
- if (!this.chipAnimationEnabled) {
925
- this.value = params;
926
- }
927
- this.$emit("onSelectOptions", params);
928
- if (this.clearInput) {
929
- this.value = [];
930
- this.$nextTick(() => {
931
- if (this.$refs.vselect) {
932
- this.$refs.vselect.search = "";
933
- }
934
- });
935
- }
936
- },
937
- async onOpen() {
938
- if (this.hasNextPage) {
939
- await this.$nextTick();
940
- if (this.$refs ? this.$refs.load : false && this.observer) {
941
- this.observer.observe(this.$refs.load);
942
- } else {
943
- setTimeout(() => {
944
- this.onOpen();
945
- }, 500);
946
- }
947
- }
948
- this.emitGetOptions("", true);
949
- },
950
- onClose() {
951
- if (this.observer) {
952
- this.observer.disconnect();
953
- }
954
- },
955
- async infiniteScroll([{ isIntersecting }]) {
956
- if (isIntersecting) {
957
- this.emitLoadNextPage();
958
- }
959
- },
960
- /*
961
- This function is used to create a unique key for the option.
962
- */
963
- createUniqueKeyForOption(sortable) {
964
- const ordered = {};
965
- Object.keys(sortable)
966
- .sort()
967
- .forEach((key) => {
968
- ordered[key] = sortable[key];
969
- });
970
- return JSON.stringify(ordered);
971
- },
972
- /*
973
- This function is used to get the key of the option for the selected pills.
974
- Aligns with vue-select default getOptionKey.
975
- Reference: https://vue-select.org/api/props.html#getoptionkey
976
- */
977
- getVueSelectOptionKey(option) {
978
- if (typeof option !== "object" || option === null) {
979
- return option;
980
- }
981
- try {
982
- return Object.prototype.hasOwnProperty.call(option, "id")
983
- ? option.id
984
- : this.createUniqueKeyForOption(option);
985
- } catch (e) {
986
- return String(option);
987
- }
988
- },
989
- getDisplayLabelForOption(option) {
990
- if (!option) return "";
991
- if (this.selectedOptionLabel && option[this.selectedOptionLabel]) {
992
- return option[this.selectedOptionLabel];
993
- }
994
- if (this.optionLabelSecondary && option[this.optionLabelSecondary]) {
995
- return option[this.optionLabelSecondary];
996
- }
997
- if (this.optionLabel && option[this.optionLabel]) {
998
- return option[this.optionLabel];
999
- }
1000
- return "";
1001
- },
1002
- /**
1003
- * Easy lookup for each selected-option slot.
1004
- */
1005
- getPillRow(option) {
1006
- const { byRef, byKey } = this.pillRowsBySlotLookup;
1007
- if (byRef.has(option)) {
1008
- return byRef.get(option);
1009
- }
1010
- const k = this.getVueSelectOptionKey(option);
1011
- return byKey.get(k) || null;
1012
- },
1013
- handleClearAll() {
1014
- this.value = [];
1015
- this.$emit("onSelectOptions", []);
1016
- this.$nextTick(() => {
1017
- if (this.$refs.vselect) {
1018
- this.$refs.vselect.search = "";
1019
- }
1020
- });
1021
- },
1022
- isChecked(option) {
1023
- return this.value.some(
1024
- (item) =>
1025
- item[this.primaryComparisonKey] === option[this.primaryComparisonKey],
1026
- )
1027
- ? 1
1028
- : 0;
1029
- },
1030
- handleSingleSelect(option) {
1031
- if (this.addCheckBox) {
1032
- if (this.isChecked(option) === 1) {
1033
- this.value = this.value.filter(
1034
- (item) =>
1035
- item[this.primaryComparisonKey] !==
1036
- option[this.primaryComparisonKey],
1037
- );
1038
- } else {
1039
- this.value = [...this.value, option];
1040
- }
1041
- this.$emit("onSelectOptions", this.value);
1042
-
1043
- return false;
1044
- }
1045
- },
1046
- handleOtherOptionChange() {
1047
- const isSelected = this.isChecked(this.otherOption) === 1;
1048
- if (isSelected) {
1049
- this.value = this.value.filter(
1050
- (item) =>
1051
- item[this.primaryComparisonKey] !==
1052
- this.otherOption[this.primaryComparisonKey],
1053
- );
1054
- } else {
1055
- this.value = [...this.value, this.otherOption];
1056
- }
1057
- this.$emit("onSelectOptions", this.value);
1058
-
1059
- this.$nextTick(() => {
1060
- if (this.$refs.vselect) {
1061
- this.$refs.vselect.open = false;
1062
- this.$refs.vselect.search = "";
1063
- }
1064
-
1065
- const input = this.$refs.vselect.$el.querySelector("input");
1066
- if (input) {
1067
- input.blur();
1068
- }
1069
- });
1070
- },
1071
- getDisableOptions(option) {
1072
- if (!option) return true;
1073
- if (option.header) return false;
1074
- if (option.isDisabled || option.disabled) return false;
1075
- return true;
1076
- },
1077
-
1078
- // a function that will set the location when the component has mounted and the location is passed after that
1079
- forceSetData(params) {
1080
- this.value = params;
1081
- },
1082
- emitLoadNextPage: debounce(function () {
1083
- this.$emit("loadNextPage");
1084
- }, 300),
1085
- handleCreateOption(event, searchText) {
1086
- event.preventDefault();
1087
-
1088
- this.$emit("handleCreateOption", {
1089
- event,
1090
- searchText: searchText.trim(),
1091
- });
1092
- this.$refs.vselect.open = false;
1093
- this.$refs.vselect.search = "";
1094
-
1095
- this.$nextTick(() => {
1096
- const input = this.$refs.vselect.$el.querySelector("input");
1097
- if (input) {
1098
- input.blur();
1099
- }
1100
- });
1101
- },
1102
- handleKeydown(event) {
1103
- if (event.key === "Enter") {
1104
- event.preventDefault();
1105
- event.stopPropagation();
1106
-
1107
- const vSelectRef = this.$refs.vselect;
1108
- const search = (vSelectRef && vSelectRef.search) || "";
1109
-
1110
- if (
1111
- this.showCreateOption &&
1112
- this.showCreateOptionAfterSearch &&
1113
- search &&
1114
- search.trim()
1115
- ) {
1116
- this.handleCreateOption(event, search.trim());
1117
- }
1118
- }
1119
- },
1120
- _updateFooterHeights() {
1121
- this.$nextTick(() => {
1122
- const createEl = this.$refs.createOption;
1123
- const otherEl = this.$refs.otherOption;
1124
- const clearEl = this.$refs.clearAllButton;
1125
-
1126
- this.footerMetaData = {
1127
- createOptionHeight: createEl ? createEl.offsetHeight : 0,
1128
- otherOptionHeight: otherEl ? otherEl.offsetHeight : 0,
1129
- clearAllHeight: clearEl ? clearEl.offsetHeight : 0,
1130
- };
1131
- });
1132
- },
1133
- },
1134
- watch: {
1135
- optionsSelected: {
1136
- handler(newVal, oldVal) {
1137
- this.value = newVal;
1138
- if (!this.hasMounted) return;
1139
- if (!this.isMultiple || !this.chipAnimationEnabled) return;
1140
- const newLength = Array.isArray(newVal) ? newVal.length : 0;
1141
- const oldLength = Array.isArray(oldVal) ? oldVal.length : 0;
1142
- const insertedCount = Math.max(0, newLength - oldLength);
1143
- if (insertedCount > 0) {
1144
- this.startChipInsertAnimation(insertedCount);
1145
- }
1146
- },
1147
- deep: true,
1148
- },
1149
- value() {
1150
- this._updateFooterHeights();
1151
- },
1152
- },
1153
- mounted() {
1154
- this.hasMounted = true;
1155
- this.observer = new IntersectionObserver(this.infiniteScroll);
1156
- },
1157
- beforeDestroy() {
1158
- this.clearChipAnimationTimeout();
1159
- if (this.observer) {
1160
- this.observer.disconnect();
1161
- this.observer = null;
1162
- }
1163
- },
1164
- };
1165
- </script>
1166
- <style>
1167
- .v-select {
1168
- @apply cursor-pointer;
1169
- }
1170
-
1171
- .vs__dropdown-toggle {
1172
- @apply min-h-9 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-left shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 sm:text-sm;
1173
- }
1174
-
1175
- .vs__selected-options {
1176
- @apply flex items-center gap-1.5 p-0;
1177
- }
1178
-
1179
- .c-multiselect--capped-pills .vs__selected-options {
1180
- @apply min-w-0 flex-nowrap overflow-hidden;
1181
- }
1182
-
1183
- /* Hide 3rd+ chips if they still mount (key mismatch); keeps one row */
1184
- .c-multiselect--capped-pills
1185
- .vs__selected-options
1186
- > .vs__selected:nth-child(n + 3) {
1187
- display: none !important;
1188
- }
1189
-
1190
- .vs--open .vs__dropdown-toggle {
1191
- border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
1192
- @apply rounded-b-md;
1193
- }
1194
- .vs__selected {
1195
- @apply m-0 !bg-transparent !p-0 text-gray-700;
1196
- border: 1px solid transparent;
1197
- transition: background-color 220ms ease, border-color 220ms ease,
1198
- color 220ms ease;
1199
- }
1200
-
1201
- .vs__selected.chip-entering {
1202
- background-color: #f0f9ff;
1203
- border-color: #7dd3fc;
1204
- color: #0284c7;
1205
- animation: chip-entry-pop 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
1206
- animation-delay: var(--chip-enter-delay, 0ms);
1207
- }
1208
-
1209
- .vs__selected.chip-entering .vs__selected-inner {
1210
- background-color: #f0f9ff;
1211
- border-color: #7dd3fc;
1212
- color: #0284c7;
1213
- }
1214
-
1215
- @keyframes chip-entry-pop {
1216
- 0% {
1217
- opacity: 0;
1218
- transform: translateY(6px) scale(0.94);
1219
- }
1220
- 70% {
1221
- opacity: 1;
1222
- transform: translateY(-1px) scale(1.01);
1223
- }
1224
- 100% {
1225
- opacity: 1;
1226
- transform: translateY(0) scale(1);
1227
- }
1228
- }
1229
- .extra:hover {
1230
- color: white;
1231
- }
1232
- .vs__search,
1233
- .vs__search:focus {
1234
- @apply m-0 p-0;
1235
- }
1236
- .vs__search::placeholder {
1237
- @apply text-gray-500;
1238
- }
1239
- .vs__actions {
1240
- @apply p-0;
1241
- }
1242
- .vs__dropdown-menu {
1243
- @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;
1244
- }
1245
-
1246
- .dropdown-menu-bordered {
1247
- @apply border-b border-gray-200;
1248
- }
1249
-
1250
- .vs__dropdown-menu li {
1251
- min-height: fit-content;
1252
- }
1253
-
1254
- .vs__dropdown-menu li:has(.sticky-group-header) {
1255
- @apply sticky top-0 z-10 bg-gray-200;
1256
- }
1257
-
1258
- /* Remove li padding if it contains a bordered option */
1259
- .vs__dropdown-menu li:has(.dropdown-menu-bordered) {
1260
- padding: 0 !important;
1261
- }
1262
-
1263
- .vs__dropdown-option {
1264
- @apply whitespace-normal !px-3 !py-2 text-gray-700;
1265
- }
1266
-
1267
- .vs__dropdown-toggle.vs__dropdown-option--highlight {
1268
- @apply bg-indigo-700 text-white;
1269
- }
1270
-
1271
- .vs__dropdown-option--highlight {
1272
- @apply bg-indigo-700 text-white;
1273
- }
1274
-
1275
- .vs__dropdown-option--disabled {
1276
- @apply cursor-not-allowed !border-gray-200 !bg-gray-50 !text-gray-500 opacity-100 shadow-none;
1277
- }
1278
-
1279
- .vs__dropdown-option--disabled * {
1280
- @apply text-gray-500;
1281
- }
1282
-
1283
- .vs__dropdown-menu li {
1284
- @apply opacity-100;
1285
- }
1286
-
1287
- .v-list-subheader {
1288
- @apply pointer-events-none opacity-100;
1289
- }
1290
-
1291
- .vs__no-options {
1292
- @apply px-4 py-3 text-sm text-gray-500;
1293
- }
1294
-
1295
- .vs__deselect {
1296
- @apply m-0;
1297
- }
1298
- </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
+ <div class="relative">
15
+ <v-select
16
+ ref="vselect"
17
+ :class="[
18
+ 'disabled:custom-disabled-state absolute inline-block h-full w-full text-sm',
19
+ isMultiple && showOverFlowCount ? 'c-multiselect--capped-pills' : '',
20
+ ]"
21
+ :placeholder="placeholder"
22
+ :multiple="isMultiple"
23
+ :taggable="isTaggable"
24
+ :push-tags="pushTags"
25
+ :filterable="filterable"
26
+ @keydown.native="handleKeydown"
27
+ v-model="value"
28
+ :options="isGrouped ? groupedArray : options"
29
+ @input="setSelectedOptions"
30
+ @search="fetchOptions"
31
+ @search:focus="$emit('search:focus')"
32
+ @option:selecting="handleSingleSelect"
33
+ @option:selected="($event) => (addCheckBox ? null : $event)"
34
+ @option:deselected="($event) => (addCheckBox ? null : $event)"
35
+ :label="optionLabel"
36
+ :clearable="clearable"
37
+ :loading="loading"
38
+ :id="id"
39
+ @open="onOpen"
40
+ @close="onClose"
41
+ :disabled="isDisabled"
42
+ :selectable="
43
+ isGrouped
44
+ ? (option) => (option.header ? false : getDisableOptions(option))
45
+ : (option) => getDisableOptions(option)
46
+ "
47
+ :closeOnSelect="addCheckBox ? false : isGrouped ? false : true"
48
+ >
49
+ <template #open-indicator="{ attributes }">
50
+ <span
51
+ v-bind="attributes"
52
+ :style="!shouldIconRotate ? 'transform:none;' : ''"
53
+ >
54
+ <c-icon
55
+ v-if="icon"
56
+ :name="icon.name"
57
+ :type="icon.type"
58
+ class="h-5 w-5 text-gray-400"
59
+ />
60
+ <c-icon
61
+ v-else
62
+ name="chevron-down"
63
+ type="solid"
64
+ class="h-5 w-5 text-gray-400"
65
+ />
66
+ </span>
67
+ </template>
68
+ <template
69
+ #selected-option-container="{ option, deselect, multiple, disabled }"
70
+ >
71
+ <template v-for="row in [getPillRow(option)]">
72
+ <div
73
+ v-if="row && row.showPill"
74
+ :key="row.slotKey"
75
+ class="vs__selected vs__selected--capped inline-flex items-center gap-1.5"
76
+ >
77
+ <p
78
+ v-if="!option.header"
79
+ :class="[
80
+ 'vs__selected-inner inline-flex min-w-0 max-w-[120px] items-center gap-1.5 rounded bg-gray-100 px-2 py-1 text-gray-800',
81
+ isDisabled ? 'text-gray-500' : '',
82
+ ]"
83
+ >
84
+ <c-icon
85
+ v-if="option.icon"
86
+ :name="option.icon.name"
87
+ :type="option.icon.type"
88
+ :class="[
89
+ 'h-4 w-4 flex-shrink-0 text-gray-400',
90
+ option.icon.optionIconClass,
91
+ ]"
92
+ />
93
+ <c-avatar
94
+ v-if="option.image && displaySelectedOptionAvatar"
95
+ :size="
96
+ option.description && showAdditionalText
97
+ ? 'extrasmall'
98
+ : 'extraextrasmall'
99
+ "
100
+ :image="option.image"
101
+ :rounded="true"
102
+ :description="option.description"
103
+ class="flex-shrink-0"
104
+ ></c-avatar>
105
+ <c-avatar
106
+ v-else-if="option.initials && displaySelectedOptionAvatar"
107
+ size="extraextrasmall"
108
+ :nameInitials="option.initials"
109
+ :description="option.description"
110
+ :rounded="true"
111
+ :isDynamicallyColored="true"
112
+ class="flex-shrink-0"
113
+ ></c-avatar>
114
+ <span class="min-w-0 flex-1 truncate">{{ row.label }}</span>
115
+ <button
116
+ v-if="multiple"
117
+ type="button"
118
+ class="flex h-2 w-2 flex-shrink-0 items-center justify-center rounded text-gray-400 focus:outline-none"
119
+ :disabled="disabled"
120
+ :title="`Deselect ${row.label}`"
121
+ :aria-label="`Deselect ${row.label}`"
122
+ @click.stop.prevent="deselect(option)"
123
+ >
124
+ <span class="text-base leading-none" aria-hidden="true"
125
+ >×</span
126
+ >
127
+ </button>
128
+ </p>
129
+ <span
130
+ v-if="row.showOverflowBadge"
131
+ class="vs__selected-overflow inline-flex w-max rounded bg-gray-100 px-2 py-1 text-gray-800"
132
+ aria-live="polite"
133
+ >
134
+ +{{ selectedOverflowCount }}
135
+ </span>
136
+ </div>
137
+ </template>
138
+ </template>
139
+ <!-- eslint-disable-next-line vue/no-unused-vars -->
140
+ <template #no-options="{ search, searching, loading }">
141
+ <span v-if="search.length < 1"
142
+ >Start typing to search for options...</span
143
+ >
144
+ <span v-else>No options found, try searching something else.</span>
145
+ </template>
146
+ <template #spinner="{ loading }">
147
+ <svg
148
+ class="h-5 w-5 animate-spin text-gray-400"
149
+ xmlns="http://www.w3.org/2000/svg"
150
+ fill="none"
151
+ viewBox="0 0 24 24"
152
+ v-if="loading"
153
+ >
154
+ <circle
155
+ class="opacity-25"
156
+ cx="12"
157
+ cy="12"
158
+ r="10"
159
+ stroke="currentColor"
160
+ stroke-width="4"
161
+ ></circle>
162
+ <path
163
+ class="opacity-75"
164
+ fill="currentColor"
165
+ 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"
166
+ ></path>
167
+ </svg>
168
+ </template>
169
+ <template v-slot:option="option">
170
+ <slot
171
+ v-if="$scopedSlots['custom-option']"
172
+ name="custom-option"
173
+ :option="option"
174
+ />
175
+ <template v-else>
176
+ <div v-if="!isGrouped">
177
+ <div v-if="option.hasNoData" class="dropdown-menu-bordered"></div>
178
+ <div v-else class="mt-1 flex h-full w-full items-center">
179
+ <div @click.stop v-if="addCheckBox" class="flex-shrink-0">
180
+ <c-checkbox
181
+ :value="isChecked(option)"
182
+ @onChange="handleSingleSelect(option)"
183
+ />
184
+ </div>
185
+ <p v-if="showOptionImage" class="flex-shrink-0">
186
+ <c-avatar
187
+ v-if="option[imageLabel]"
188
+ :size="
189
+ option.description && showAdditionalText
190
+ ? 'extrasmall'
191
+ : 'extraextrasmall'
192
+ "
193
+ :image="option[imageLabel]"
194
+ :rounded="true"
195
+ :description="option.description"
196
+ class="mr-2"
197
+ ></c-avatar>
198
+ <c-avatar
199
+ v-if="
200
+ !option.icon && !option[imageLabel] && option.initials
201
+ "
202
+ :size="
203
+ option.description && showAdditionalText
204
+ ? 'extrasmall'
205
+ : 'extraextrasmall'
206
+ "
207
+ :nameInitials="option.initials"
208
+ :description="option.description"
209
+ :rounded="true"
210
+ :isDynamicallyColored="true"
211
+ class="mr-2"
212
+ ></c-avatar>
213
+ <c-icon
214
+ v-if="
215
+ option.icon && !option[imageLabel] && !option.initials
216
+ "
217
+ :name="option.icon.name"
218
+ :type="option.icon.type"
219
+ :class="`mr-2 h-5 w-5 text-gray-400 ${
220
+ option.icon.optionIconClass
221
+ ? option.icon.optionIconClass
222
+ : ''
223
+ }`"
224
+ cursorType="cursor-pointer"
225
+ />
226
+ </p>
227
+ <div class="w-full">
228
+ <div
229
+ :class="`flex items-center justify-between ${checkboxWrapperClass}`"
230
+ >
231
+ <div :class="`flex items-center ${tagWrapperClass}`">
232
+ <p>
233
+ {{
234
+ option[optionLabelSecondary]
235
+ ? option[optionLabelSecondary]
236
+ : option[optionLabel]
237
+ }}
238
+ </p>
239
+ <div class="ml-3">
240
+ <c-tag
241
+ v-if="tags && option.info && option.info !== ''"
242
+ :label="option.info"
243
+ color="gray"
244
+ ></c-tag>
245
+ <span v-else class="-ml-3 text-gray-300">
246
+ &nbsp;{{ option.info }}
247
+ </span>
248
+ </div>
249
+ </div>
250
+ </div>
251
+ <p
252
+ class="text-xs"
253
+ v-if="option.description && showAdditionalText"
254
+ >
255
+ {{ option.description }}
256
+ </p>
257
+ </div>
258
+ </div>
259
+ </div>
260
+ <div
261
+ v-if="isGrouped"
262
+ :class="[
263
+ option.header
264
+ ? 'sticky-group-header -mx-4 -my-2 bg-gray-200 px-3 py-2'
265
+ : '',
266
+ ]"
267
+ >
268
+ <v-list-subheader
269
+ v-if="option.header"
270
+ class="flex items-center gap-1 text-gray-900"
271
+ >
272
+ <c-icon
273
+ v-if="option.icon"
274
+ :name="option.icon.name"
275
+ :type="option.icon.type"
276
+ :class="`${
277
+ option.icon.headerIconClass
278
+ ? option.icon.headerIconClass
279
+ : 'h-4 w-4'
280
+ } text-gray-400`"
281
+ />
282
+ {{ option.header }}
283
+ </v-list-subheader>
284
+ <div
285
+ :class="[
286
+ 'mt-1 flex h-full w-full',
287
+ option.description ? 'items-start' : 'items-center',
288
+ ]"
289
+ >
290
+ <div @click.stop v-if="addCheckBox && !option.header">
291
+ <c-checkbox
292
+ :value="isChecked(option)"
293
+ @onChange="handleSingleSelect(option)"
294
+ />
295
+ </div>
296
+ <div v-if="!option.header && showOptionImage">
297
+ <c-avatar
298
+ v-if="option.image"
299
+ size="extraextrasmall"
300
+ :image="option.image"
301
+ :rounded="true"
302
+ :description="option.description"
303
+ class="mr-2"
304
+ ></c-avatar>
305
+ <c-avatar
306
+ v-else
307
+ size="extraextrasmall"
308
+ :nameInitials="option.initials"
309
+ :description="option.description"
310
+ :rounded="true"
311
+ :isDynamicallyColored="true"
312
+ class="mr-2"
313
+ ></c-avatar>
314
+ </div>
315
+ <div class="w-full">
316
+ <div class="flex items-center">
317
+ <p>
318
+ {{
319
+ option[optionLabelSecondary]
320
+ ? option[optionLabelSecondary]
321
+ : option[optionLabel]
322
+ }}
323
+ </p>
324
+ <div class="ml-3">
325
+ <span
326
+ v-if="tags && option.info && option.info !== ''"
327
+ class="inline-flex rounded-md bg-gray-400 px-2 py-px text-sm leading-5 text-white"
328
+ >
329
+ {{ option.info }}
330
+ </span>
331
+ <span v-else class="text-gray-300">
332
+ {{ option.info }}
333
+ </span>
334
+ </div>
335
+ </div>
336
+
337
+ <p class="text-xs" v-if="option.description">
338
+ {{ option.description }}
339
+ </p>
340
+ </div>
341
+ </div>
342
+ </div>
343
+ </template>
344
+ </template>
345
+ <template #list-footer="{ search }">
346
+ <li ref="load" class="loader" v-show="hasNextPage">
347
+ Loading more options...
348
+ </li>
349
+
350
+ <!-- Footer buttons when footer buttons are visible -->
351
+ <div
352
+ v-if="showFooterButton || showFooterButton2"
353
+ :class="[
354
+ 'group sticky bottom-0 mt-1 bg-white',
355
+ showFooterButton && showFooterButton2 ? 'space-y-2' : '',
356
+ ]"
357
+ >
358
+ <li
359
+ v-if="showFooterButton"
360
+ :class="footerBtnClasses"
361
+ class="cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
362
+ :id="getActionIDFn(footerButtonText)"
363
+ role="option"
364
+ @click="$emit('footerButtonClick')"
365
+ >
366
+ <div class="flex items-center">
367
+ <svg
368
+ xmlns="http://www.w3.org/2000/svg"
369
+ class="h-6 w-6 flex-shrink-0 text-gray-400"
370
+ viewBox="0 0 20 20"
371
+ fill="currentColor"
372
+ >
373
+ <path
374
+ fill-rule="evenodd"
375
+ 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"
376
+ clip-rule="evenodd"
377
+ />
378
+ </svg>
379
+ <span class="ml-3 block truncate font-semibold">
380
+ {{ footerButtonText }}
381
+ </span>
382
+ </div>
383
+ </li>
384
+ <li
385
+ v-if="showFooterButton2"
386
+ class="cursor-pointer select-none bg-gray-50 py-2 pl-3 pr-9 text-gray-700 hover:bg-gray-100 hover:text-gray-900"
387
+ :class="footerBtnClasses2"
388
+ :id="getActionIDFn(footerButtonText2)"
389
+ role="option"
390
+ @click="$emit('footerButtonClick2')"
391
+ >
392
+ <div class="flex items-center">
393
+ <svg
394
+ xmlns="http://www.w3.org/2000/svg"
395
+ class="h-6 w-6 flex-shrink-0 text-gray-400"
396
+ viewBox="0 0 20 20"
397
+ fill="currentColor"
398
+ >
399
+ <path
400
+ fill-rule="evenodd"
401
+ 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"
402
+ clip-rule="evenodd"
403
+ />
404
+ </svg>
405
+ <span class="ml-3 block truncate font-semibold">
406
+ {{ footerButtonText2 }}
407
+ </span>
408
+ </div>
409
+ </li>
410
+ </div>
411
+
412
+ <!-- Create option button when showCreateOption is true and there is a search term -->
413
+ <div
414
+ v-if="
415
+ showCreateOption &&
416
+ showCreateOptionAfterSearch &&
417
+ search &&
418
+ search.trim()
419
+ "
420
+ ref="createOption"
421
+ class="sticky z-10 flex min-h-[44px] items-start gap-3 bg-white px-3 py-2 shadow-lg ring-1 ring-gray-900 ring-opacity-5"
422
+ :style="footerStickyStyles.create"
423
+ >
424
+ <span class="word-break flex-1 text-sm text-gray-700">{{
425
+ search
426
+ }}</span>
427
+
428
+ <button
429
+ type="button"
430
+ :id="id + '_create_button'"
431
+ @mousedown="handleCreateOption($event, search)"
432
+ class="flex items-center gap-1 text-sm text-indigo-700"
433
+ >
434
+ <c-icon
435
+ type="solid"
436
+ name="plus-circle-solid-v2"
437
+ class="h-5 w-5 text-indigo-600"
438
+ viewBox="0 0 24 24"
439
+ ></c-icon>
440
+ Create
441
+ </button>
442
+ </div>
443
+
444
+ <!-- Other option checkbox when otherOption is true -->
445
+ <div
446
+ v-if="otherOption"
447
+ ref="otherOption"
448
+ class="sticky z-10 border-t border-gray-100 bg-gray-50 px-3 py-2"
449
+ :style="footerStickyStyles.other"
450
+ >
451
+ <div class="flex" @mousedown.prevent.stop>
452
+ <c-checkbox
453
+ :value="isChecked(otherOption)"
454
+ @onChange="handleOtherOptionChange"
455
+ />
456
+ <div class="flex-1" @click.stop="handleOtherOptionChange">
457
+ <p class="text-sm font-medium text-gray-700">
458
+ {{ otherOption[optionLabel] }}
459
+ </p>
460
+ <p class="mt-1 text-sm text-gray-500">
461
+ {{ otherOption.description }}
462
+ </p>
463
+ </div>
464
+ </div>
465
+ </div>
466
+
467
+ <!-- Clear all button when multiple is true and there are selected values -->
468
+ <button
469
+ v-if="isMultiple && hasSelectedValues"
470
+ ref="clearAllButton"
471
+ type="button"
472
+ class="sticky z-10 w-full border-t border-gray-200 bg-gray-50 px-4 py-3 text-left text-sm text-gray-500 hover:text-gray-900 focus:outline-none"
473
+ :style="footerStickyStyles.clear"
474
+ :id="id + '_clear_all_button'"
475
+ aria-label="Clear all selections"
476
+ @mousedown.prevent.stop="handleClearAll"
477
+ >
478
+ Clear all
479
+ </button>
480
+ </template>
481
+ </v-select>
482
+ <button
483
+ class="z-100 absolute top-2.5 right-10"
484
+ :id="id + '_close_button'"
485
+ v-if="showCloseButton && (value == null || value.length == 0)"
486
+ @click.stop="handleCrossClick"
487
+ >
488
+ <c-icon
489
+ name="close"
490
+ type="outline-v2"
491
+ class="h-4 w-4 text-gray-400"
492
+ cursorType="cursor-pointer"
493
+ />
494
+ </button>
495
+ </div>
496
+ <p v-if="subLabel" class="mt-2 text-sm text-gray-500">{{ subLabel }}</p>
497
+ <p
498
+ v-if="!isValidate && errorMessage"
499
+ class="mt-2 text-left text-sm text-red-600"
500
+ >
501
+ {{ errorMessage }}
502
+ </p>
503
+ <p v-if="helpText && isValidate == true" class="mt-2 text-sm text-gray-500">
504
+ {{ helpText }}
505
+ </p>
506
+ </div>
507
+ </template>
508
+ <script>
509
+ import vSelect from "vue-select";
510
+ import CAvatar from "../CAvatar/CAvatar.vue";
511
+ import CIcon from "../CIcon/CIcon.vue";
512
+ import CCheckbox from "../CCheckbox/CCheckbox.vue";
513
+ import { debounce } from "lodash-es";
514
+ import "vue-select/dist/vue-select.css";
515
+ import { getActionID } from "../../helper";
516
+ import CTag from "../CTag/CTag.vue";
517
+ export default {
518
+ name: "CMultiselect",
519
+ components: { vSelect, CAvatar, CCheckbox, CIcon, CTag },
520
+ props: {
521
+ id: {
522
+ type: String,
523
+ },
524
+ clearInput: {
525
+ type: Boolean,
526
+ default: false,
527
+ },
528
+ options: {
529
+ type: Array,
530
+ required: true,
531
+ },
532
+ extraDetails: {
533
+ type: Boolean,
534
+ default: false,
535
+ },
536
+ displaySelectedOptionAvatar: {
537
+ type: Boolean,
538
+ default: false,
539
+ },
540
+ showFooterButton: {
541
+ type: Boolean,
542
+ default: false,
543
+ },
544
+ footerButtonText: {
545
+ type: String,
546
+ default: "",
547
+ },
548
+ label: String,
549
+ isRequired: {
550
+ type: Boolean,
551
+ },
552
+ subLabel: String,
553
+ placeholder: {
554
+ type: String,
555
+ },
556
+ // whether multiple fields are allowed or not
557
+ isMultiple: {
558
+ type: Boolean,
559
+ },
560
+ // append newly created tags in options
561
+ pushTags: {
562
+ type: Boolean,
563
+ },
564
+ // whether to allow user to create new options
565
+ isTaggable: {
566
+ type: Boolean,
567
+ },
568
+ getOptions: {
569
+ // function to emit on search{
570
+ type: Function,
571
+ },
572
+ customiseOption: {
573
+ type: Boolean,
574
+ },
575
+ // whether to show profile picture in option
576
+ showOptionImage: {
577
+ type: Boolean,
578
+ },
579
+ // the name of the option to render in the selectpicker
580
+ optionLabel: {
581
+ type: String,
582
+ },
583
+ // the name of the option to render in the selectpicker
584
+ optionLabelSecondary: {
585
+ type: String,
586
+ },
587
+ selectedOptionLabel: {
588
+ type: String,
589
+ },
590
+ // the key to compare the options when addCheckBox is true
591
+ primaryComparisonKey: {
592
+ type: String,
593
+ default: "id",
594
+ },
595
+ // action to trigger after selecting option from dropdown
596
+ onSelectOptions: {
597
+ type: Function,
598
+ },
599
+ optionsSelected: {
600
+ type: [Array, Object],
601
+ },
602
+ filterable: {
603
+ type: Boolean,
604
+ default: false,
605
+ },
606
+ clearable: {
607
+ type: Boolean,
608
+ default: true,
609
+ },
610
+ isValidate: {
611
+ type: Boolean,
612
+ default: true,
613
+ },
614
+ errorMessage: {
615
+ type: String,
616
+ },
617
+ loading: {
618
+ type: Boolean,
619
+ default: false,
620
+ },
621
+ hasNextPage: {
622
+ type: Boolean,
623
+ default: false,
624
+ },
625
+ isDisabled: {
626
+ type: Boolean,
627
+ default: false,
628
+ },
629
+ // text adjacent to label of dropdown to provide hint about field
630
+ hint: { type: String },
631
+ helpText: {
632
+ type: String,
633
+ },
634
+ tags: {
635
+ type: Boolean,
636
+ default: false,
637
+ },
638
+ isGrouped: {
639
+ type: Boolean,
640
+ default: false,
641
+ },
642
+ //to show the additional text, default true to prevent failure at any other place
643
+ showAdditionalText: {
644
+ type: Boolean,
645
+ default: true,
646
+ },
647
+ addCheckBox: {
648
+ type: Boolean,
649
+ default: false,
650
+ },
651
+ showSelectedAvatar: {
652
+ type: Boolean,
653
+ default: false,
654
+ },
655
+ icon: {
656
+ type: Object,
657
+ },
658
+ footerBtnClasses: {
659
+ type: String,
660
+ },
661
+ shouldIconRotate: {
662
+ type: Boolean,
663
+ default: true,
664
+ },
665
+ imageLabel: {
666
+ type: String,
667
+ default: "image",
668
+ },
669
+ showFooterButton2: {
670
+ type: Boolean,
671
+ default: false,
672
+ },
673
+ footerButtonText2: {
674
+ type: String,
675
+ default: "",
676
+ },
677
+ footerBtnClasses2: {
678
+ type: String,
679
+ },
680
+ showCloseButton: {
681
+ type: Boolean,
682
+ default: false,
683
+ },
684
+ showCreateOption: {
685
+ type: Boolean,
686
+ default: false,
687
+ },
688
+ otherOption: {
689
+ type: Object,
690
+ },
691
+ tagWrapperClass: {
692
+ type: String,
693
+ default: "",
694
+ },
695
+ checkboxWrapperClass: {
696
+ type: String,
697
+ default: "",
698
+ },
699
+ // Enables/disables chip insert animation flow (phase 1 + phase 2 sweep).
700
+ chipAnimationEnabled: {
701
+ type: Boolean,
702
+ default: false,
703
+ },
704
+ // When true, render all selected pills and hide "+N" overflow counter.
705
+ showOverFlowCount: {
706
+ type: Boolean,
707
+ default: true,
708
+ },
709
+ },
710
+ computed: {
711
+ groupedArray() {
712
+ const groups = {};
713
+
714
+ this.options.forEach((x) => {
715
+ // create empty object if it doesn't exists.
716
+ groups[x.category] = groups[x.category] || {
717
+ text: x.category,
718
+ list: [],
719
+ ...(x.icon ? { icon: x.icon } : {}),
720
+ };
721
+
722
+ groups[x.category].list.push(x);
723
+ });
724
+
725
+ // The flattened list of items that holds items as well as unique headers
726
+ const flattened = [];
727
+
728
+ // Iterate over all the unique categories and
729
+ // then flatten into a list that v-select needs.
730
+ Object.keys(groups).forEach((categoryId) => {
731
+ const category = groups[categoryId];
732
+ const categoryName = category.text;
733
+
734
+ // Create a group
735
+ flattened.push({
736
+ header: categoryName,
737
+ ...(category.icon ? { icon: category.icon } : {}),
738
+ });
739
+
740
+ // Add all the items followed by category header
741
+ flattened.push(...category.list);
742
+ });
743
+
744
+ return flattened;
745
+ },
746
+ showCreateOptionAfterSearch() {
747
+ if (!this.showCreateOption) return false;
748
+
749
+ // Get current search term from v-select
750
+ const vSelectRef = this.$refs.vselect;
751
+ const search = (vSelectRef && vSelectRef.search) || "";
752
+ const term = search.trim().toLowerCase();
753
+ if (!term) return false;
754
+
755
+ // Check if any options exactly match the search term
756
+ const hasExactMatch = this.options.some((option) => {
757
+ const label = option[this.optionLabel];
758
+ return label && String(label).toLowerCase() === term;
759
+ });
760
+
761
+ return !hasExactMatch;
762
+ },
763
+ /*
764
+ This function is used to get the remaining count of options that are not shown in the dropdown.
765
+ */
766
+ selectedOverflowCount() {
767
+ if (!this.isMultiple || !this.showOverFlowCount) return 0;
768
+ const totalSelectedOptions = Array.isArray(this.value)
769
+ ? this.value.length
770
+ : 0;
771
+ return totalSelectedOptions > 2 ? totalSelectedOptions - 2 : 0;
772
+ },
773
+ hasSelectedValues() {
774
+ return Array.isArray(this.value) && this.value.length > 0;
775
+ },
776
+ /**
777
+ * Pre-built pill rows keyed by `value[i]` and by vue-select option key.
778
+ * Recomputes only when selection / multi / overflow-relevant state changes — not on dropdown hover.
779
+ * Index comes from `value` order (same order vue-select uses for selected-option-container).
780
+ */
781
+ pillRowsBySlotLookup() {
782
+ if (!Array.isArray(this.value)) {
783
+ return { byRef: new Map(), byKey: new Map() };
784
+ }
785
+ const byRef = new Map();
786
+ const byKey = new Map();
787
+ const overflow = this.selectedOverflowCount;
788
+
789
+ this.value.forEach((item, index) => {
790
+ const label = this.getDisplayLabelForOption(item);
791
+ const key = this.getVueSelectOptionKey(item);
792
+ const slotKey = `slot-${index}-${String(key)}`;
793
+ const meta = { index, key, label, slotKey };
794
+ const showPill = this.isMultiple;
795
+ const showOverflowBadge =
796
+ this.isMultiple &&
797
+ this.showOverFlowCount &&
798
+ index === 1 &&
799
+ overflow > 0;
800
+ const row = {
801
+ meta,
802
+ showPill,
803
+ showOverflowBadge,
804
+ label,
805
+ slotKey,
806
+ };
807
+ byRef.set(item, row);
808
+ if (!byKey.has(key)) {
809
+ byKey.set(key, row);
810
+ }
811
+ });
812
+ return { byRef, byKey };
813
+ },
814
+ /**
815
+ * Sticky `bottom` offsets so create → other → clear stack without overlap.
816
+ * DOM order is create (top of sticky group), other, clear (anchored to dropdown bottom).
817
+ */
818
+ footerStickyStyles() {
819
+ const clearH = Number(this.footerMetaData.clearAllHeight) || 0;
820
+ const otherH = Number(this.footerMetaData.otherOptionHeight) || 0;
821
+ return {
822
+ create: { bottom: `${clearH + otherH}px` },
823
+ other: { bottom: `${clearH}px` },
824
+ clear: { bottom: "0px" },
825
+ };
826
+ },
827
+ },
828
+ data() {
829
+ return {
830
+ loaderSearching: true,
831
+ value:
832
+ this.optionsSelected && this.optionsSelected.length
833
+ ? this.optionsSelected
834
+ : [],
835
+ observer: null,
836
+ chipAnimationTimeout: null,
837
+ chipAnimationCycle: 0,
838
+ hasMounted: false,
839
+ footerMetaData: {
840
+ clearAllHeight: 0,
841
+ otherOptionHeight: 0,
842
+ createOptionHeight: 0,
843
+ },
844
+ };
845
+ },
846
+ methods: {
847
+ clearChipAnimationTimeout() {
848
+ if (this.chipAnimationTimeout) {
849
+ clearTimeout(this.chipAnimationTimeout);
850
+ this.chipAnimationTimeout = null;
851
+ }
852
+ },
853
+ startChipInsertAnimation(insertedCount) {
854
+ if (!this.isMultiple || !this.chipAnimationEnabled || !insertedCount)
855
+ return;
856
+
857
+ this.clearChipAnimationTimeout();
858
+ // Increment a cycle token so any previously scheduled async animation work
859
+ // can detect it is stale and bail out.
860
+ this.chipAnimationCycle += 1;
861
+ const animationCycle = this.chipAnimationCycle;
862
+ this.$nextTick(() => {
863
+ // Guard against race conditions: if another insert happened before this
864
+ // tick runs, skip this stale cycle.
865
+ if (animationCycle !== this.chipAnimationCycle || !this.$refs.vselect)
866
+ return;
867
+
868
+ const vSelectEl = this.$refs.vselect.$el;
869
+ if (!vSelectEl) return;
870
+
871
+ requestAnimationFrame(() => {
872
+ // Re-check at frame time because DOM work is deferred one more step.
873
+ if (animationCycle !== this.chipAnimationCycle) return;
874
+
875
+ const chipElements = Array.from(
876
+ vSelectEl.querySelectorAll(".vs__selected"),
877
+ );
878
+ const chipsToAnimate = chipElements.slice(-insertedCount);
879
+
880
+ if (!chipsToAnimate.length) {
881
+ return;
882
+ }
883
+
884
+ const staggerMs = chipsToAnimate.length > 1 ? 80 : 0;
885
+ chipsToAnimate.forEach((chipEl, index) => {
886
+ chipEl.classList.remove("chip-entering");
887
+ void chipEl.offsetWidth;
888
+ chipEl.style.setProperty(
889
+ "--chip-enter-delay",
890
+ `${index * staggerMs}ms`,
891
+ );
892
+ chipEl.classList.add("chip-entering");
893
+ });
894
+
895
+ const totalPhaseOneDuration =
896
+ (chipsToAnimate.length - 1) * staggerMs + 320;
897
+ this.chipAnimationTimeout = setTimeout(() => {
898
+ if (animationCycle !== this.chipAnimationCycle) return;
899
+ chipsToAnimate.forEach((chipEl) => {
900
+ chipEl.classList.remove("chip-entering");
901
+ chipEl.style.removeProperty("--chip-enter-delay");
902
+ });
903
+ }, totalPhaseOneDuration);
904
+ });
905
+ });
906
+ },
907
+ getActionIDFn(name) {
908
+ return getActionID(name, this.id);
909
+ },
910
+ handleCrossClick(event) {
911
+ event.preventDefault();
912
+ this.$emit("hide-multiselect-dropdown");
913
+ },
914
+ fetchOptions(search, loaderSearching) {
915
+ this.emitGetOptions(search, loaderSearching);
916
+
917
+ this._updateFooterHeights();
918
+ },
919
+ emitGetOptions: debounce(function (search, loaderSearching) {
920
+ this.$emit("getOptions", search.trim(), loaderSearching);
921
+ }, 300),
922
+ setSelectedOptions(params) {
923
+ //this prevents animation to run, we have a watcher that will instate value correctly
924
+ if (!this.chipAnimationEnabled) {
925
+ this.value = params;
926
+ }
927
+ this.$emit("onSelectOptions", params);
928
+ if (this.clearInput) {
929
+ this.value = [];
930
+ this.$nextTick(() => {
931
+ if (this.$refs.vselect) {
932
+ this.$refs.vselect.search = "";
933
+ }
934
+ });
935
+ }
936
+ },
937
+ async onOpen() {
938
+ if (this.hasNextPage) {
939
+ await this.$nextTick();
940
+ if (this.$refs ? this.$refs.load : false && this.observer) {
941
+ this.observer.observe(this.$refs.load);
942
+ } else {
943
+ setTimeout(() => {
944
+ this.onOpen();
945
+ }, 500);
946
+ }
947
+ }
948
+ this.emitGetOptions("", true);
949
+ },
950
+ onClose() {
951
+ if (this.observer) {
952
+ this.observer.disconnect();
953
+ }
954
+ },
955
+ async infiniteScroll([{ isIntersecting }]) {
956
+ if (isIntersecting) {
957
+ this.emitLoadNextPage();
958
+ }
959
+ },
960
+ /*
961
+ This function is used to create a unique key for the option.
962
+ */
963
+ createUniqueKeyForOption(sortable) {
964
+ const ordered = {};
965
+ Object.keys(sortable)
966
+ .sort()
967
+ .forEach((key) => {
968
+ ordered[key] = sortable[key];
969
+ });
970
+ return JSON.stringify(ordered);
971
+ },
972
+ /*
973
+ This function is used to get the key of the option for the selected pills.
974
+ Aligns with vue-select default getOptionKey.
975
+ Reference: https://vue-select.org/api/props.html#getoptionkey
976
+ */
977
+ getVueSelectOptionKey(option) {
978
+ if (typeof option !== "object" || option === null) {
979
+ return option;
980
+ }
981
+ try {
982
+ return Object.prototype.hasOwnProperty.call(option, "id")
983
+ ? option.id
984
+ : this.createUniqueKeyForOption(option);
985
+ } catch (e) {
986
+ return String(option);
987
+ }
988
+ },
989
+ getDisplayLabelForOption(option) {
990
+ if (!option) return "";
991
+ if (this.selectedOptionLabel && option[this.selectedOptionLabel]) {
992
+ return option[this.selectedOptionLabel];
993
+ }
994
+ if (this.optionLabelSecondary && option[this.optionLabelSecondary]) {
995
+ return option[this.optionLabelSecondary];
996
+ }
997
+ if (this.optionLabel && option[this.optionLabel]) {
998
+ return option[this.optionLabel];
999
+ }
1000
+ return "";
1001
+ },
1002
+ /**
1003
+ * Easy lookup for each selected-option slot.
1004
+ */
1005
+ getPillRow(option) {
1006
+ const { byRef, byKey } = this.pillRowsBySlotLookup;
1007
+ if (byRef.has(option)) {
1008
+ return byRef.get(option);
1009
+ }
1010
+ const k = this.getVueSelectOptionKey(option);
1011
+ return byKey.get(k) || null;
1012
+ },
1013
+ handleClearAll() {
1014
+ this.value = [];
1015
+ this.$emit("onSelectOptions", []);
1016
+ this.$nextTick(() => {
1017
+ if (this.$refs.vselect) {
1018
+ this.$refs.vselect.search = "";
1019
+ }
1020
+ });
1021
+ },
1022
+ isChecked(option) {
1023
+ return this.value.some(
1024
+ (item) =>
1025
+ item[this.primaryComparisonKey] === option[this.primaryComparisonKey],
1026
+ )
1027
+ ? 1
1028
+ : 0;
1029
+ },
1030
+ handleSingleSelect(option) {
1031
+ if (this.addCheckBox) {
1032
+ if (this.isChecked(option) === 1) {
1033
+ this.value = this.value.filter(
1034
+ (item) =>
1035
+ item[this.primaryComparisonKey] !==
1036
+ option[this.primaryComparisonKey],
1037
+ );
1038
+ } else {
1039
+ this.value = [...this.value, option];
1040
+ }
1041
+ this.$emit("onSelectOptions", this.value);
1042
+
1043
+ return false;
1044
+ }
1045
+ },
1046
+ handleOtherOptionChange() {
1047
+ const isSelected = this.isChecked(this.otherOption) === 1;
1048
+ if (isSelected) {
1049
+ this.value = this.value.filter(
1050
+ (item) =>
1051
+ item[this.primaryComparisonKey] !==
1052
+ this.otherOption[this.primaryComparisonKey],
1053
+ );
1054
+ } else {
1055
+ this.value = [...this.value, this.otherOption];
1056
+ }
1057
+ this.$emit("onSelectOptions", this.value);
1058
+
1059
+ this.$nextTick(() => {
1060
+ if (this.$refs.vselect) {
1061
+ this.$refs.vselect.open = false;
1062
+ this.$refs.vselect.search = "";
1063
+ }
1064
+
1065
+ const input = this.$refs.vselect.$el.querySelector("input");
1066
+ if (input) {
1067
+ input.blur();
1068
+ }
1069
+ });
1070
+ },
1071
+ getDisableOptions(option) {
1072
+ if (!option) return true;
1073
+ if (option.header) return false;
1074
+ if (option.isDisabled || option.disabled) return false;
1075
+ return true;
1076
+ },
1077
+
1078
+ // a function that will set the location when the component has mounted and the location is passed after that
1079
+ forceSetData(params) {
1080
+ this.value = params;
1081
+ },
1082
+ emitLoadNextPage: debounce(function () {
1083
+ this.$emit("loadNextPage");
1084
+ }, 300),
1085
+ handleCreateOption(event, searchText) {
1086
+ event.preventDefault();
1087
+
1088
+ this.$emit("handleCreateOption", {
1089
+ event,
1090
+ searchText: searchText.trim(),
1091
+ });
1092
+ this.$refs.vselect.open = false;
1093
+ this.$refs.vselect.search = "";
1094
+
1095
+ this.$nextTick(() => {
1096
+ const input = this.$refs.vselect.$el.querySelector("input");
1097
+ if (input) {
1098
+ input.blur();
1099
+ }
1100
+ });
1101
+ },
1102
+ handleKeydown(event) {
1103
+ if (event.key === "Enter") {
1104
+ event.preventDefault();
1105
+ event.stopPropagation();
1106
+
1107
+ const vSelectRef = this.$refs.vselect;
1108
+ const search = (vSelectRef && vSelectRef.search) || "";
1109
+
1110
+ if (
1111
+ this.showCreateOption &&
1112
+ this.showCreateOptionAfterSearch &&
1113
+ search &&
1114
+ search.trim()
1115
+ ) {
1116
+ this.handleCreateOption(event, search.trim());
1117
+ }
1118
+ }
1119
+ },
1120
+ _updateFooterHeights() {
1121
+ this.$nextTick(() => {
1122
+ const createEl = this.$refs.createOption;
1123
+ const otherEl = this.$refs.otherOption;
1124
+ const clearEl = this.$refs.clearAllButton;
1125
+
1126
+ this.footerMetaData = {
1127
+ createOptionHeight: createEl ? createEl.offsetHeight : 0,
1128
+ otherOptionHeight: otherEl ? otherEl.offsetHeight : 0,
1129
+ clearAllHeight: clearEl ? clearEl.offsetHeight : 0,
1130
+ };
1131
+ });
1132
+ },
1133
+ },
1134
+ watch: {
1135
+ optionsSelected: {
1136
+ handler(newVal, oldVal) {
1137
+ this.value = newVal;
1138
+ if (!this.hasMounted) return;
1139
+ if (!this.isMultiple || !this.chipAnimationEnabled) return;
1140
+ const newLength = Array.isArray(newVal) ? newVal.length : 0;
1141
+ const oldLength = Array.isArray(oldVal) ? oldVal.length : 0;
1142
+ const insertedCount = Math.max(0, newLength - oldLength);
1143
+ if (insertedCount > 0) {
1144
+ this.startChipInsertAnimation(insertedCount);
1145
+ }
1146
+ },
1147
+ deep: true,
1148
+ },
1149
+ value() {
1150
+ this._updateFooterHeights();
1151
+ },
1152
+ },
1153
+ mounted() {
1154
+ this.hasMounted = true;
1155
+ this.observer = new IntersectionObserver(this.infiniteScroll);
1156
+ },
1157
+ beforeDestroy() {
1158
+ this.clearChipAnimationTimeout();
1159
+ if (this.observer) {
1160
+ this.observer.disconnect();
1161
+ this.observer = null;
1162
+ }
1163
+ },
1164
+ };
1165
+ </script>
1166
+ <style>
1167
+ .v-select {
1168
+ @apply cursor-pointer;
1169
+ }
1170
+
1171
+ .vs__dropdown-toggle {
1172
+ @apply min-h-9 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-left shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 sm:text-sm;
1173
+ }
1174
+
1175
+ .vs__selected-options {
1176
+ @apply flex items-center gap-1.5 p-0;
1177
+ }
1178
+
1179
+ .c-multiselect--capped-pills .vs__selected-options {
1180
+ @apply min-w-0 flex-nowrap overflow-hidden;
1181
+ }
1182
+
1183
+ /* Hide 3rd+ chips if they still mount (key mismatch); keeps one row */
1184
+ .c-multiselect--capped-pills
1185
+ .vs__selected-options
1186
+ > .vs__selected:nth-child(n + 3) {
1187
+ display: none !important;
1188
+ }
1189
+
1190
+ .vs--open .vs__dropdown-toggle {
1191
+ border-bottom-color: rgba(212, 212, 216, var(--tw-border-opacity));
1192
+ @apply rounded-b-md;
1193
+ }
1194
+ .vs__selected {
1195
+ @apply m-0 !bg-transparent !p-0 text-gray-700;
1196
+ border: 1px solid transparent;
1197
+ transition: background-color 220ms ease, border-color 220ms ease,
1198
+ color 220ms ease;
1199
+ }
1200
+
1201
+ .vs__selected.chip-entering {
1202
+ background-color: #f0f9ff;
1203
+ border-color: #7dd3fc;
1204
+ color: #0284c7;
1205
+ animation: chip-entry-pop 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
1206
+ animation-delay: var(--chip-enter-delay, 0ms);
1207
+ }
1208
+
1209
+ .vs__selected.chip-entering .vs__selected-inner {
1210
+ background-color: #f0f9ff;
1211
+ border-color: #7dd3fc;
1212
+ color: #0284c7;
1213
+ }
1214
+
1215
+ @keyframes chip-entry-pop {
1216
+ 0% {
1217
+ opacity: 0;
1218
+ transform: translateY(6px) scale(0.94);
1219
+ }
1220
+ 70% {
1221
+ opacity: 1;
1222
+ transform: translateY(-1px) scale(1.01);
1223
+ }
1224
+ 100% {
1225
+ opacity: 1;
1226
+ transform: translateY(0) scale(1);
1227
+ }
1228
+ }
1229
+ .extra:hover {
1230
+ color: white;
1231
+ }
1232
+ .vs__search,
1233
+ .vs__search:focus {
1234
+ @apply m-0 p-0;
1235
+ }
1236
+ .vs__search::placeholder {
1237
+ @apply text-gray-500;
1238
+ }
1239
+ .vs__actions {
1240
+ @apply p-0;
1241
+ }
1242
+ .vs__dropdown-menu {
1243
+ @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;
1244
+ }
1245
+
1246
+ .dropdown-menu-bordered {
1247
+ @apply border-b border-gray-200;
1248
+ }
1249
+
1250
+ .vs__dropdown-menu li {
1251
+ min-height: fit-content;
1252
+ }
1253
+
1254
+ .vs__dropdown-menu li:has(.sticky-group-header) {
1255
+ @apply sticky top-0 z-10 bg-gray-200;
1256
+ }
1257
+
1258
+ /* Remove li padding if it contains a bordered option */
1259
+ .vs__dropdown-menu li:has(.dropdown-menu-bordered) {
1260
+ padding: 0 !important;
1261
+ }
1262
+
1263
+ .vs__dropdown-option {
1264
+ @apply whitespace-normal !px-3 !py-2 text-gray-700;
1265
+ }
1266
+
1267
+ .vs__dropdown-toggle.vs__dropdown-option--highlight {
1268
+ @apply bg-indigo-700 text-white;
1269
+ }
1270
+
1271
+ .vs__dropdown-option--highlight {
1272
+ @apply bg-indigo-700 text-white;
1273
+ }
1274
+
1275
+ .vs__dropdown-option--disabled {
1276
+ @apply cursor-not-allowed !border-gray-200 !bg-gray-50 !text-gray-500 opacity-100 shadow-none;
1277
+ }
1278
+
1279
+ .vs__dropdown-option--disabled * {
1280
+ @apply text-gray-500;
1281
+ }
1282
+
1283
+ .vs__dropdown-menu li {
1284
+ @apply opacity-100;
1285
+ }
1286
+
1287
+ .v-list-subheader {
1288
+ @apply pointer-events-none opacity-100;
1289
+ }
1290
+
1291
+ .vs__no-options {
1292
+ @apply px-4 py-3 text-sm text-gray-500;
1293
+ }
1294
+
1295
+ .vs__deselect {
1296
+ @apply m-0;
1297
+ }
1298
+ </style>