classcard-ui 0.2.666 → 0.2.671

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 (174) hide show
  1. package/dist/classcard-ui.common.js +69 -81
  2. package/dist/classcard-ui.common.js.map +1 -1
  3. package/dist/classcard-ui.umd.js +69 -81
  4. package/dist/classcard-ui.umd.js.map +1 -1
  5. package/dist/classcard-ui.umd.min.js +1 -1
  6. package/dist/classcard-ui.umd.min.js.map +1 -1
  7. package/package.json +6 -7
  8. package/src/App.vue +0 -16
  9. package/src/components/CAlerts/CAlerts.vue +0 -70
  10. package/src/components/CAlerts/index.js +0 -3
  11. package/src/components/CAnchorTabs/CAnchorTabs.vue +0 -96
  12. package/src/components/CAnchorTabs/index.js +0 -3
  13. package/src/components/CAnchorTag/CAnchorTag.vue +0 -62
  14. package/src/components/CAnchorTag/index.js +0 -3
  15. package/src/components/CAvatar/CAvatar.vue +0 -112
  16. package/src/components/CAvatar/index.js +0 -3
  17. package/src/components/CAvatarGroup/CAvatarGroup.vue +0 -145
  18. package/src/components/CAvatarGroup/index.js +0 -3
  19. package/src/components/CBasicTable/CBasicTable.vue +0 -184
  20. package/src/components/CBasicTable/index.js +0 -3
  21. package/src/components/CBreadcrumbs/CBreadcrumbs.vue +0 -38
  22. package/src/components/CBreadcrumbs/index.js +0 -3
  23. package/src/components/CButton/CButton.vue +0 -147
  24. package/src/components/CButton/index.js +0 -3
  25. package/src/components/CButtonGroup/CButtonGroup.vue +0 -116
  26. package/src/components/CButtonGroup/index.js +0 -3
  27. package/src/components/CButtonIcon/CButtonIcon.vue +0 -91
  28. package/src/components/CButtonIcon/index.js +0 -3
  29. package/src/components/CButtonLink/CButtonLink.vue +0 -39
  30. package/src/components/CButtonLink/index.js +0 -3
  31. package/src/components/CButtonSelect/CButtonSelect.vue +0 -103
  32. package/src/components/CButtonSelect/index.js +0 -3
  33. package/src/components/CButtonWithDropdown/CButtonWithDropdown.vue +0 -168
  34. package/src/components/CButtonWithDropdown/index.js +0 -3
  35. package/src/components/CCalendar/CCalendar.vue +0 -401
  36. package/src/components/CCalendar/index.js +0 -3
  37. package/src/components/CCard/CCard.vue +0 -49
  38. package/src/components/CCard/index.js +0 -3
  39. package/src/components/CCheckbox/CCheckbox.vue +0 -70
  40. package/src/components/CCheckbox/index.js +0 -3
  41. package/src/components/CCollapsibleSection/CCollapsibleSection.vue +0 -99
  42. package/src/components/CCollapsibleSection/index.js +0 -3
  43. package/src/components/CColorDots/CColorDots.vue +0 -35
  44. package/src/components/CColorDots/index.js +0 -3
  45. package/src/components/CConfirmActionModal/CConfirmActionModal.vue +0 -120
  46. package/src/components/CConfirmActionModal/index.js +0 -3
  47. package/src/components/CDatepicker/CDatepicker.vue +0 -139
  48. package/src/components/CDatepicker/index.js +0 -3
  49. package/src/components/CDualSelect/CDualSelect.vue +0 -193
  50. package/src/components/CDualSelect/index.js +0 -3
  51. package/src/components/CEditor/CEditor.vue +0 -96
  52. package/src/components/CEditor/index.js +0 -3
  53. package/src/components/CFormSectionHeading/CFormSectionHeading.vue +0 -53
  54. package/src/components/CFormSectionHeading/index.js +0 -3
  55. package/src/components/CGroupedSelect/CGroupedSelect.vue +0 -217
  56. package/src/components/CGroupedSelect/index.js +0 -3
  57. package/src/components/CIcon/CIcon.vue +0 -77
  58. package/src/components/CIcon/index.js +0 -3
  59. package/src/components/CIconDropdown/CIconDropdown.vue +0 -111
  60. package/src/components/CIconDropdown/index.js +0 -3
  61. package/src/components/CInput/CInput.vue +0 -120
  62. package/src/components/CInput/index.js +0 -3
  63. package/src/components/CInputAddon/CInputAddon.vue +0 -202
  64. package/src/components/CInputAddon/index.js +0 -3
  65. package/src/components/CInputEmail/CInputEmail.vue +0 -93
  66. package/src/components/CInputEmail/index.js +0 -3
  67. package/src/components/CModalHeading/CModalHeading.vue +0 -22
  68. package/src/components/CModalHeading/index.js +0 -3
  69. package/src/components/CModuleHelpLinks/CModuleHelpLinks.vue +0 -39
  70. package/src/components/CModuleHelpLinks/index.js +0 -3
  71. package/src/components/CMultiselect/CMultiselect.vue +0 -333
  72. package/src/components/CMultiselect/index.js +0 -3
  73. package/src/components/CMultiselectr/CMultiselectr.vue +0 -44
  74. package/src/components/CMultiselectr/index.js +0 -3
  75. package/src/components/CPageHeading/CPageHeading.vue +0 -56
  76. package/src/components/CPageHeading/index.js +0 -3
  77. package/src/components/CPagination/CPagination.vue +0 -202
  78. package/src/components/CPagination/index.js +0 -3
  79. package/src/components/CPhoneNumber/CPhoneNumber.vue +0 -81
  80. package/src/components/CPhoneNumber/index.js +0 -3
  81. package/src/components/CRadio/CRadio.vue +0 -106
  82. package/src/components/CRadio/index.js +0 -3
  83. package/src/components/CRangeSlider/CRangeSlider.vue +0 -55
  84. package/src/components/CRangeSlider/index.js +0 -3
  85. package/src/components/CReorderableStackedList/CReorderableStackedList.vue +0 -94
  86. package/src/components/CReorderableStackedList/index.js +0 -3
  87. package/src/components/CSelect/CSelect.vue +0 -343
  88. package/src/components/CSelect/index.js +0 -3
  89. package/src/components/CSmallTimeline/CSmallTimeline.vue +0 -40
  90. package/src/components/CSmallTimeline/index.js +0 -3
  91. package/src/components/CStackedList/CStackedList.vue +0 -132
  92. package/src/components/CStackedList/index.js +0 -3
  93. package/src/components/CStats/CStats.vue +0 -111
  94. package/src/components/CStats/index.js +0 -3
  95. package/src/components/CSwitch/CSwitch.vue +0 -140
  96. package/src/components/CSwitch/index.js +0 -3
  97. package/src/components/CTable/CTable.vue +0 -536
  98. package/src/components/CTable/index.js +0 -3
  99. package/src/components/CTabs/CTabs.vue +0 -111
  100. package/src/components/CTabs/index.js +0 -3
  101. package/src/components/CTag/CTag.vue +0 -36
  102. package/src/components/CTag/index.js +0 -3
  103. package/src/components/CTextarea/CTextarea.vue +0 -95
  104. package/src/components/CTextarea/index.js +0 -3
  105. package/src/components/CTimeline/CTimeline.vue +0 -237
  106. package/src/components/CTimeline/index.js +0 -3
  107. package/src/components/CUpload/CUpload.vue +0 -231
  108. package/src/components/CUpload/index.js +0 -3
  109. package/src/components/index.js +0 -48
  110. package/src/icons.js +0 -275
  111. package/src/main.js +0 -22
  112. package/src/stories/CAlerts.stories.js +0 -37
  113. package/src/stories/CAnchorTabs.stories.js +0 -29
  114. package/src/stories/CAnchorTag.stories.js +0 -36
  115. package/src/stories/CAvatar.stories.js +0 -38
  116. package/src/stories/CAvatarGroup.stories.js +0 -100
  117. package/src/stories/CBasicTable.stories.js +0 -316
  118. package/src/stories/CBreadcrumbs.stories.js +0 -24
  119. package/src/stories/CButton.stories.js +0 -46
  120. package/src/stories/CButtonGroup.stories.js +0 -33
  121. package/src/stories/CButtonIcon.stories.js +0 -27
  122. package/src/stories/CButtonLink.stories.js +0 -24
  123. package/src/stories/CButtonSelect.stories.js +0 -32
  124. package/src/stories/CButtonWithDropdown.stories.js +0 -41
  125. package/src/stories/CCalendar.stories.js +0 -16
  126. package/src/stories/CCard.stories.js +0 -30
  127. package/src/stories/CCheckbox.stories.js +0 -29
  128. package/src/stories/CCollapsibleSection.stories.js +0 -28
  129. package/src/stories/CColorDots.stories.js +0 -28
  130. package/src/stories/CConfirmActionModal.stories.js +0 -59
  131. package/src/stories/CDatepicker.stories.js +0 -30
  132. package/src/stories/CDualSelect.stories.js +0 -29
  133. package/src/stories/CEditor.stories.js +0 -30
  134. package/src/stories/CFormSectionHeading.stories.js +0 -34
  135. package/src/stories/CGroupedSelect.stories.js +0 -69
  136. package/src/stories/CIcon.stories.js +0 -26
  137. package/src/stories/CIconDropdown.stories.js +0 -40
  138. package/src/stories/CInput.stories.js +0 -36
  139. package/src/stories/CInputAddon.stories.js +0 -37
  140. package/src/stories/CInputEmail.stories.js +0 -27
  141. package/src/stories/CModalHeading.stories.js +0 -25
  142. package/src/stories/CModuleHelpLinks.stories.js +0 -25
  143. package/src/stories/CMultiselect.stories.js +0 -97
  144. package/src/stories/CMultiselectr.stories.js +0 -23
  145. package/src/stories/CPageHeading.stories.js +0 -32
  146. package/src/stories/CPagination.stories.js +0 -30
  147. package/src/stories/CPhoneNumber.stories.js +0 -29
  148. package/src/stories/CRadio.stories.js +0 -36
  149. package/src/stories/CRangeSlider.stories.js +0 -23
  150. package/src/stories/CReorderableStackedList.stories.js +0 -23
  151. package/src/stories/CSelect.stories.js +0 -50
  152. package/src/stories/CSmallTimeline.stories.js +0 -26
  153. package/src/stories/CStackedList.stories.js +0 -37
  154. package/src/stories/CStats.stories.js +0 -33
  155. package/src/stories/CSwitch.stories.js +0 -28
  156. package/src/stories/CTable.stories.js +0 -77
  157. package/src/stories/CTabs.stories.js +0 -33
  158. package/src/stories/CTag.stories.js +0 -23
  159. package/src/stories/CTextarea.stories.js +0 -32
  160. package/src/stories/CTimeline.stories.js +0 -26
  161. package/src/stories/CUpload.stories.js +0 -36
  162. package/src/stories/Introduction.stories.mdx +0 -207
  163. package/src/stories/Page.vue +0 -88
  164. package/src/stories/assets/code-brackets.svg +0 -1
  165. package/src/stories/assets/colors.svg +0 -1
  166. package/src/stories/assets/comments.svg +0 -1
  167. package/src/stories/assets/direction.svg +0 -1
  168. package/src/stories/assets/flow.svg +0 -1
  169. package/src/stories/assets/plugin.svg +0 -1
  170. package/src/stories/assets/repo.svg +0 -1
  171. package/src/stories/assets/stackalt.svg +0 -1
  172. package/src/stories/header.css +0 -26
  173. package/src/stories/page.css +0 -69
  174. package/src/stories/utils.css +0 -18
@@ -1,81 +0,0 @@
1
- <template>
2
- <div>
3
- <div class="flex items-center">
4
- <!-- label of phone field -->
5
- <label class="text-sm text-gray-900">{{ label }}</label>
6
- <!-- asterisk sign to render if field is required -->
7
- <p v-if="isRequired" class="ml-1 text-red-600">*</p>
8
- </div>
9
- <div class="mt-1 w-full shadow-sm">
10
- <vue-tel-input v-bind="bindProps" :autoFormat="false" v-model="value"></vue-tel-input>
11
- </div>
12
- <p v-if="!isValidate" class="mt-1 text-sm text-red-600">
13
- {{ errorMessage }}
14
- </p>
15
- </div>
16
- </template>
17
- <script>
18
- import { VueTelInput } from "vue-tel-input";
19
- export default {
20
- name: "CPhoneNumber",
21
- components: {
22
- VueTelInput,
23
- },
24
- props: {
25
- // eslint-disable-next-line vue/require-prop-type-constructor
26
- phone: {
27
- type: String,
28
- },
29
- label: String,
30
- isValidate: {
31
- type: Boolean,
32
- default: true,
33
- },
34
- isRequired: {
35
- type: Boolean,
36
- default: false,
37
- },
38
- errorMessage: {
39
- type: String,
40
- },
41
- },
42
- data() {
43
- return {
44
- value: this.phone,
45
- bindProps: {
46
- placeholder: "",
47
- inputClasses: ["px-3", "py-2", "text-sm"],
48
- inputId: "c-phone",
49
- wrapperClasses: "c-phone-wrapper",
50
- showDialCode: false,
51
- enabledCountryCode: false,
52
- mode: "international",
53
- validCharactersOnly: true,
54
- },
55
- };
56
- },
57
- watch: {
58
- value(newVal) {
59
- this.$emit("onChange", newVal);
60
- },
61
- },
62
- };
63
- </script>
64
- <style>
65
- .vue-tel-input {
66
- border: 1px solid #d1d5db !important;
67
- @apply text-gray-900;
68
- }
69
-
70
- #c-phone {
71
- border-top-right-radius: 0.375rem;
72
- border-bottom-right-radius: 0.375rem;
73
- }
74
- .c-phone-wrapper {
75
- border-radius: 0.375rem !important;
76
- }
77
- .vti__dropdown:hover {
78
- border-top-left-radius: 0.375rem;
79
- border-bottom-left-radius: 0.375rem;
80
- }
81
- </style>
@@ -1,3 +0,0 @@
1
- import CPhoneNumber from './CPhoneNumber.vue'
2
-
3
- export default CPhoneNumber
@@ -1,106 +0,0 @@
1
- <template>
2
- <div>
3
- <div class="-space-y-px rounded-md bg-white" :class="customWrapperClasses">
4
- <div
5
- v-for="(item, index) in items"
6
- class="relative pb-4 first:rounded-t-md last:rounded-b-md"
7
- v-bind:key="item[labelName]"
8
- :class="customClasses ? classes(item, index) : ''"
9
- >
10
- <div class="flex items-start">
11
- <input
12
- type="radio"
13
- :value="item.value"
14
- :name="name"
15
- v-model="selectedItem"
16
- @click="onChange(item.value)"
17
- class="mt-0.5 h-4 w-4 cursor-pointer border-gray-300 text-indigo-600 focus:ring-indigo-500 disabled:opacity-50"
18
- :disabled="isDisabled"
19
- />
20
- <label class="ml-3 flex cursor-pointer flex-col" @click="onChange(item.value)">
21
- <span
22
- class="block text-sm font-medium text-gray-900"
23
- :class="customClasses && item.value === selectedItem ? 'text-indigo-900' : ''"
24
- >
25
- {{ item[labelName] }}
26
- </span>
27
- <span
28
- class="block text-sm"
29
- :class="
30
- customClasses && item.value === selectedItem ? 'text-indigo-700' : 'text-gray-500'
31
- "
32
- >
33
- {{ item.description }}
34
- </span>
35
- </label>
36
- </div>
37
- <slot v-if="item.value === selectedItem" :name="item.value" />
38
- </div>
39
- </div>
40
- </div>
41
- </template>
42
-
43
- <script>
44
- export default {
45
- name: "CRadio",
46
- props: {
47
- items: {
48
- type: Array,
49
- required: true,
50
- },
51
- selectedOption: {
52
- type: String,
53
- },
54
- isDisabled: {
55
- type: Boolean,
56
- },
57
- customClasses: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- customWrapperClasses: {
62
- type: String,
63
- },
64
- name: {
65
- type: String,
66
- required: true,
67
- },
68
- labelName: {
69
- type: String,
70
- default: "label",
71
- },
72
- },
73
- data() {
74
- return {
75
- selectedItem: this.selectedOption,
76
- };
77
- },
78
- methods: {
79
- onChange(selectedValue) {
80
- if (!this.isDisabled) {
81
- this.$emit("onChange", selectedValue);
82
- this.selectedItem = selectedValue;
83
- }
84
- },
85
- classes(item, index) {
86
- let classForRadio = "";
87
- if (item.value === this.selectedItem && index === 0) {
88
- classForRadio = "border p-4 border-indigo-200 rounded-t-md bg-indigo-50";
89
- } else if (item.value === this.selectedItem && index === this.items.length - 1) {
90
- classForRadio = "border p-4 border-indigo-200 rounded-b-md bg-indigo-50";
91
- } else if (item.value === this.selectedItem && 0 < index < this.items.length - 1) {
92
- classForRadio = "border p-4 border-indigo-200 bg-indigo-50";
93
- } else {
94
- classForRadio = "border p-4 border-gray-200";
95
- }
96
-
97
- return classForRadio;
98
- },
99
- },
100
- watch: {
101
- selectedOption() {
102
- this.selectedItem = this.selectedOption;
103
- },
104
- },
105
- };
106
- </script>
@@ -1,3 +0,0 @@
1
- import CRadio from './CRadio.vue'
2
-
3
- export default CRadio
@@ -1,55 +0,0 @@
1
- <template>
2
- <div class="flex w-64 m-auto items-center h-32 justify-center">
3
- <div class="py-1 relative min-w-full">
4
- <div class="h-2 bg-gray-200 rounded-full">
5
- <div
6
- class="absolute h-2 rounded-full bg-teal-600 w-0"
7
- style="width: 58.5714%;"
8
- ></div>
9
- <div
10
- class="absolute h-4 flex items-center justify-center w-4 rounded-full bg-white shadow border border-gray-300 -ml-2 top-0 cursor-pointer"
11
- unselectable="on"
12
- onselectstart="return false;"
13
- style="left: 58.5714%;"
14
- >
15
- <div class="relative -mt-2 w-1">
16
- <div
17
- class="absolute z-40 opacity-100 bottom-100 mb-2 left-0 min-w-full"
18
- style="margin-left: -20.5px;"
19
- >
20
- <div class="relative shadow-md">
21
- <div
22
- class="bg-black -mt-8 text-white truncate text-xs rounded py-1 px-4"
23
- >
24
- 92
25
- </div>
26
- <svg
27
- class="absolute text-black w-full h-2 left-0 top-100"
28
- x="0px"
29
- y="0px"
30
- viewBox="0 0 255 255"
31
- xml:space="preserve"
32
- >
33
- <polygon
34
- class="fill-current"
35
- points="0,0 127.5,127.5 255,0"
36
- ></polygon>
37
- </svg>
38
- </div>
39
- </div>
40
- </div>
41
- </div>
42
- <div class="absolute text-gray-800 -ml-1 bottom-0 left-0 -mb-6">10</div>
43
- <div class="absolute text-gray-800 -mr-1 bottom-0 right-0 -mb-6">
44
- 150
45
- </div>
46
- </div>
47
- </div>
48
- </div>
49
- </template>
50
- <script>
51
- export default {
52
- name: "CRangeSlider",
53
- props: {},
54
- };
55
- </script>
@@ -1,3 +0,0 @@
1
- import CRangeSlider from './CRangeSlider.vue'
2
-
3
- export default CRangeSlider
@@ -1,94 +0,0 @@
1
- <template>
2
- <div>
3
- <ul>
4
- <li
5
- v-for="items in listItems"
6
- v-bind:key="items.size"
7
- class="flex items-center py-3"
8
- :class="{ 'cursor-pointer': items.collapse }"
9
- v-on="items.collapse ? { click: () => collapseList() } : null"
10
- >
11
- <c-icon
12
- v-if="items.collapse"
13
- :name="showSection ? 'chevron-down' : 'chevron-right'"
14
- type="solid"
15
- class="mt-3 mr-3 h-5 w-5 flex-none text-gray-900"
16
- ></c-icon>
17
- <c-icon
18
- v-if="items.reorder"
19
- name="menu-solid"
20
- type="solid"
21
- :cursorType="cursorType"
22
- class="handle mr-3 h-5 w-5 flex-none text-gray-500"
23
- ></c-icon>
24
- <c-avatar
25
- :size="items.size"
26
- :rounded="items.rounded"
27
- :image="items.image"
28
- :imageClasses="items.imageClasses"
29
- class="flex-none"
30
- ></c-avatar>
31
- <div class="flex min-w-0 flex-1 items-center justify-between">
32
- <div class="ml-3 min-w-0 flex-1">
33
- <div>
34
- <div class="-m-1 flex flex-wrap items-center">
35
- <p class="m-1 text-sm font-medium text-gray-900">
36
- {{ items.heading }}
37
- </p>
38
- <c-tag v-if="items.tag" label="Active" class="m-1"></c-tag>
39
- <c-tag v-if="items.tag" label="Inactive" class="m-1"></c-tag>
40
- <c-tag v-if="items.tag" label="Tag 1" class="m-1"></c-tag>
41
- <c-tag v-if="items.tag" label="Tag 2" class="m-1"></c-tag>
42
- </div>
43
- <p class="mt-1 text-sm text-gray-500">{{ items.description }}</p>
44
- <div v-if="showSection" class="mt-3">
45
- <slot></slot>
46
- </div>
47
- </div>
48
- </div>
49
- <div class="flex flex-none items-center">
50
- <slot name="icons"></slot>
51
- <button
52
- type="button"
53
- v-if="items.listIcon"
54
- @click="$emit('remove')"
55
- class="focus:outline-none"
56
- >
57
- <!-- slot for delete icons -->
58
- <slot name="removeIcons"></slot>
59
- </button>
60
- </div>
61
- </div>
62
- </li>
63
- </ul>
64
- </div>
65
- </template>
66
- <script>
67
- import CAvatar from "../CAvatar/CAvatar.vue";
68
- import CTag from "../CTag/CTag.vue";
69
- import CIcon from "../CIcon/CIcon.vue";
70
- export default {
71
- name: "CReorderableStackedList",
72
- components: { CAvatar, CTag, CIcon },
73
- props: {
74
- listItems: {
75
- type: Array,
76
- required: true,
77
- },
78
- cursorType: {
79
- type: String,
80
- default: "cursor-move",
81
- },
82
- },
83
- data() {
84
- return {
85
- showSection: false,
86
- };
87
- },
88
- methods: {
89
- collapseList() {
90
- this.showSection = !this.showSection;
91
- },
92
- },
93
- };
94
- </script>
@@ -1,3 +0,0 @@
1
- import CReorderableStackedList from './CReorderableStackedList.vue'
2
-
3
- export default CReorderableStackedList
@@ -1,343 +0,0 @@
1
- <template>
2
- <div>
3
- <div class="flex w-full items-center justify-between" v-if="label">
4
- <div class="flex items-center">
5
- <!-- label of select field -->
6
- <label class="block 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
-
15
- <div class="relative">
16
- <div class="relative truncate" :class="label ? 'mt-1' : ''">
17
- <input
18
- type="text"
19
- v-model="selectSearch"
20
- @click="toggleDropdown = !toggleDropdown"
21
- @focus="type == 'tertiary' ? (showFocus = true) : ''"
22
- @blur="close()"
23
- @keyup="search()"
24
- aria-haspopup="listbox"
25
- aria-expanded="true"
26
- aria-labelledby="listbox-label"
27
- :class="{ ...classes, [inputClasses]: true }"
28
- class="relative w-full cursor-pointer rounded-md py-2 pl-3 pr-10 text-left text-sm focus:outline-none disabled:opacity-50 sm:text-sm"
29
- :disabled="isDisabled"
30
- autocomplete="off"
31
- />
32
-
33
- <div
34
- class="pointer-events-none absolute inset-0 left-3 flex h-[38px] items-center overflow-hidden pr-10"
35
- >
36
- <div class="flex items-center truncate" :style="selectedOptionStyles">
37
- <div v-if="showImage && !selectSearch && value">
38
- <c-avatar
39
- v-if="value.photo"
40
- size="extraextrasmall"
41
- :image="value.photo"
42
- :rounded="true"
43
- ></c-avatar>
44
- <c-avatar
45
- v-else
46
- size="extraextrasmall"
47
- :nameInitials="value.initials"
48
- :rounded="true"
49
- :isDynamicallyColored="coloredAvatars"
50
- ></c-avatar>
51
- </div>
52
- <c-icon
53
- v-if="icon && !showImage"
54
- :class="icon.class"
55
- :name="icon.name"
56
- :type="icon.type"
57
- >
58
- </c-icon>
59
- <p :class="showImage ? 'ml-3' : ''" class="block truncate text-sm">
60
- {{
61
- selectedValue
62
- ? selectedValue
63
- : !selectSearch || selectSearch == ""
64
- ? placeholder
65
- : null
66
- }}
67
- </p>
68
- </div>
69
- </div>
70
- <div class="pointer-events-none absolute top-2 right-3 flex">
71
- <div
72
- v-if="type == 'tertiary' ? showFocus : true"
73
- class="pointer-events-none right-0 flex items-center"
74
- >
75
- <c-icon
76
- name="selector"
77
- type="solid"
78
- class="h-5 w-5 text-gray-400"
79
- ></c-icon>
80
- </div>
81
- </div>
82
- </div>
83
- <transition
84
- enter-active-class="transition ease-out duration-100"
85
- enter-class="transform opacity-0 scale-95"
86
- enter-to-class="transform opacity-100 scale-100"
87
- leave-active-class="transition ease-in duration-75"
88
- leave-class="transform opacity-100 scale-100"
89
- leave-to-class="transform opacity-0 scale-95"
90
- >
91
- <div
92
- v-if="toggleDropdown && !isDisabled"
93
- class="absolute z-10 mt-1 w-full rounded-md bg-white shadow-lg"
94
- >
95
- <ul
96
- tabindex="-1"
97
- role="listbox"
98
- aria-labelledby="listbox-label"
99
- class="max-h-60 overflow-auto rounded-md py-1 text-base ring-1 ring-gray-900 ring-opacity-5 focus:outline-none sm:text-sm"
100
- >
101
- <li
102
- v-if="addAction"
103
- @mousedown="actionEvent($event)"
104
- class="relative flex cursor-pointer select-none py-2 pl-3 pr-9 text-indigo-500 hover:bg-indigo-100 hover:text-indigo-700"
105
- >
106
- <c-icon
107
- type="outline"
108
- class="mr-1 h-5 w-5 text-indigo-400 group-hover:text-indigo-500"
109
- name="plus"
110
- ></c-icon>
111
- {{ addAction.label }}
112
- </li>
113
- <li
114
- v-for="(option, index) in renderOptions"
115
- :key="index"
116
- id="listbox-option-0"
117
- role="option"
118
- :ref="`option-${String(index)}`"
119
- @mousedown="handleSelect($event, option)"
120
- class="relative cursor-pointer select-none py-2 pl-3 pr-9 text-gray-900 hover:bg-indigo-700 hover:text-white"
121
- :class="option.isDisabled ? 'pointer-events-none opacity-50' : ''"
122
- >
123
- <span class="flex items-center">
124
- <div v-if="option.showImage">
125
- <c-avatar
126
- v-if="option.photo"
127
- size="extraextrasmall"
128
- :image="option.photo"
129
- :rounded="true"
130
- ></c-avatar>
131
- <c-avatar
132
- v-else
133
- size="extraextrasmall"
134
- :nameInitials="option.initials"
135
- :rounded="true"
136
- :isDynamicallyColored="coloredAvatars"
137
- ></c-avatar>
138
- </div>
139
- <c-icon
140
- class="flex-none"
141
- v-if="option.showIcon && option.icon"
142
- :class="option.icon.class"
143
- :name="option.icon.name"
144
- :type="option.icon.type"
145
- >
146
- </c-icon>
147
- <span
148
- :class="option.photo || option.initials ? 'ml-3' : ''"
149
- class="list-options block break-words font-normal"
150
- >{{ option[renderOptionName] }}
151
- </span>
152
- </span>
153
-
154
- <span
155
- class="absolute inset-y-0 right-0 flex items-center pr-4 text-indigo-600"
156
- >
157
- <c-icon
158
- id="list-icon"
159
- v-show="showSelectedValue"
160
- name="check"
161
- type="solid"
162
- class="h-5 w-5"
163
- ></c-icon>
164
- </span>
165
- </li>
166
- </ul>
167
- </div>
168
- </transition>
169
- <!-- validation error message -->
170
- <p v-if="!isValidate" class="mt-2 text-left text-sm text-red-600">
171
- {{ errorMessage }}
172
- </p>
173
- <p v-if="helpText" class="mt-2 text-sm text-gray-500">
174
- {{ helpText }}
175
- </p>
176
- </div>
177
- </div>
178
- </template>
179
- <script>
180
- import CIcon from "../CIcon/CIcon.vue";
181
- import CAvatar from "../CAvatar/CAvatar.vue";
182
- import { isNumber } from "lodash";
183
- export default {
184
- name: "CSelect",
185
- components: { CIcon, CAvatar },
186
- props: {
187
- // label of selectpicker
188
- label: {
189
- type: String,
190
- },
191
- // placeholder in selectpicker
192
- placeholder: {
193
- type: String,
194
- },
195
- // list to render in dropdown
196
- options: {
197
- type: Array,
198
- required: true,
199
- },
200
- // show the avatars with different colors
201
- coloredAvatars: {
202
- type: Boolean,
203
- },
204
- // text below dropdown to describe more about the field
205
- helpText: {
206
- type: String,
207
- },
208
- // text adjacent to label of dropdown to provide hint about field
209
- hint: { type: String },
210
- // to show if image is present along with dropdown option
211
- showImage: { type: Boolean },
212
- // whether the select field is mandatory or not
213
- isRequired: {
214
- type: Boolean,
215
- },
216
- // validation is passed or not
217
- isValidate: { type: Boolean, default: true },
218
- // will truncate the text in input field
219
- selectedOptionStyles: {
220
- type: String,
221
- },
222
- // validation error message
223
- errorMessage: {
224
- type: String,
225
- },
226
- // perform action on first option in dropdown
227
- addAction: { type: Object },
228
- // icons in dropdown list
229
- icon: { type: Object },
230
- // value to set as default option in dropdown
231
- value: { type: [Object, String], default: null },
232
- // type of dropdown - gray,tertiary or default
233
- type: {
234
- type: String,
235
- },
236
- // name of the field in array to that contains text to render in dropdown
237
- renderOptionName: {
238
- type: String,
239
- default: "option",
240
- },
241
- // whether to disable the selectpicker
242
- isDisabled: {
243
- type: Boolean,
244
- default: false,
245
- },
246
- inputClasses: {
247
- type: String,
248
- default: "",
249
- },
250
- },
251
- data() {
252
- return {
253
- toggleDropdown: false,
254
- selectedValue: null,
255
- showSelectedValue: false,
256
- showFocus: false,
257
- selectSearch: null,
258
- renderOptions: this.options,
259
- };
260
- },
261
- computed: {
262
- classes() {
263
- return {
264
- "text-gray-900 border border-gray-200 hover:bg-gray-200 bg-gray-100 focus:ring-2 focus:border-gray-200 focus:ring-gray-200 focus:ring-offset-2 shadow-sm":
265
- this.type == "gray",
266
- "bg-white border border-gray-200 hover:bg-indigo-100 text-indigo-600 hover:text-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-200":
267
- this.type == "tertiary",
268
- "border border-gray-300 focus:ring-indigo-500 focus:border-indigo-500 bg-white shadow-sm focus:ring-1":
269
- this.type == null,
270
- };
271
- },
272
- },
273
- methods: {
274
- handleSelect(event, option) {
275
- this.selectSearch = null;
276
- this.selectedValue = option[this.renderOptionName];
277
- this.$emit("onChangeValue", option);
278
- this.toggleDropdown = false;
279
- },
280
- actionEvent(event) {
281
- this.$emit("listAction", event);
282
- },
283
- close() {
284
- this.selectSearch = null;
285
- this.toggleDropdown = false;
286
- this.type === "tertiary" ? (this.showFocus = false) : "";
287
- this.renderOptions = this.options;
288
- },
289
- search() {
290
- this.selectedValue = null;
291
- if (!this.selectSearch || this.selectSearch == "") {
292
- this.renderOptions = this.options;
293
- return;
294
- }
295
- let options = [...this.options];
296
- this.renderOptions = options.filter((option) => {
297
- isNumber(option[this.renderOptionName])
298
- ? (option[this.renderOptionName] =
299
- option[this.renderOptionName].toString())
300
- : "";
301
- return option[this.renderOptionName]
302
- .toLowerCase()
303
- .includes(this.selectSearch.toLowerCase());
304
- });
305
- },
306
- async scrollOptionIntoView(refName) {
307
- await this.$nextTick();
308
- this.$refs[refName][0].scrollIntoView({
309
- behavior: "smooth",
310
- block: "center",
311
- });
312
- },
313
- },
314
- watch: {
315
- value() {
316
- this.selectedValue =
317
- this.value !== null && this.value[this.renderOptionName]
318
- ? this.value[this.renderOptionName]
319
- : this.value;
320
- },
321
- options() {
322
- this.renderOptions = this.options;
323
- },
324
- toggleDropdown(newValue) {
325
- if (newValue) {
326
- let index = this.renderOptions.findIndex(
327
- (option) => option[this.renderOptionName] === this.selectedValue
328
- );
329
- if (index !== -1) {
330
- let refName = `option-${String(index)}`;
331
- this.scrollOptionIntoView(refName);
332
- }
333
- }
334
- },
335
- },
336
- mounted() {
337
- this.selectedValue =
338
- this.value !== null && this.value[this.renderOptionName]
339
- ? this.value[this.renderOptionName]
340
- : this.value;
341
- },
342
- };
343
- </script>