@weni/unnnic-system 3.9.4-alpha.4 → 3.10.0

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 (254) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
  3. package/dist/components/Alert/Alert.vue.d.ts +116 -17
  4. package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
  5. package/dist/components/Alert/Version1dot1.vue.d.ts +38 -2
  6. package/dist/components/Alert/Version1dot1.vue.d.ts.map +1 -1
  7. package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +2 -2
  8. package/dist/components/AudioRecorder/AudioPlayer.vue.d.ts +1 -1
  9. package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +5 -5
  10. package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +3 -3
  11. package/dist/components/Banner/Banner.vue.d.ts +1 -1
  12. package/dist/components/Banner/InfoBanner.vue.d.ts +1 -1
  13. package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +1 -1
  14. package/dist/components/Button/Button.vue.d.ts +1 -1
  15. package/dist/components/Button/Button.vue.d.ts.map +1 -1
  16. package/dist/components/Button/ButtonIcon.vue.d.ts +1 -1
  17. package/dist/components/Button/types.d.ts +1 -1
  18. package/dist/components/Button/types.d.ts.map +1 -1
  19. package/dist/components/Card/AccountCard.vue.d.ts +5 -5
  20. package/dist/components/Card/BlankCard.vue.d.ts +1 -1
  21. package/dist/components/Card/Card.vue.d.ts +27 -27
  22. package/dist/components/Card/CardCompany.vue.d.ts +414 -11
  23. package/dist/components/Card/CardData.vue.d.ts +1 -1
  24. package/dist/components/Card/CardStatusesContainer.vue.d.ts +5 -5
  25. package/dist/components/Card/ContentCard.vue.d.ts +3 -3
  26. package/dist/components/Card/DashCard.vue.d.ts +5 -5
  27. package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
  28. package/dist/components/Card/MarketplaceCard.vue.d.ts +2 -2
  29. package/dist/components/Card/SimpleCard.vue.d.ts +3 -3
  30. package/dist/components/Card/StatusCard.vue.d.ts +2 -2
  31. package/dist/components/Card/TitleCard.vue.d.ts +3 -3
  32. package/dist/components/CardImage/CardImage.vue.d.ts +31 -24
  33. package/dist/components/CardInformation/CardInformation.vue.d.ts +5 -5
  34. package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
  35. package/dist/components/Carousel/Carousel.vue.d.ts +416 -13
  36. package/dist/components/Carousel/TagCarousel.vue.d.ts +415 -12
  37. package/dist/components/ChartBar/ChartBar.vue.d.ts +5 -5
  38. package/dist/components/ChartLine/ChartLine.vue.d.ts +1 -1
  39. package/dist/components/ChatText/ChatText.vue.d.ts +2 -2
  40. package/dist/components/ChatsContact/ChatsContact.vue.d.ts +446 -21
  41. package/dist/components/ChatsDashboardTagLive/ChatsDashboardTagLive.vue.d.ts +1 -1
  42. package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts +1 -1
  43. package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts.map +1 -1
  44. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +5 -5
  45. package/dist/components/ChatsMessage/ChatsMessageStatusBackdrop.vue.d.ts +2 -2
  46. package/dist/components/ChatsNavbar/ChatsNavbar.vue.d.ts +1 -1
  47. package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +2 -2
  48. package/dist/components/Checkbox/Checkbox.vue.d.ts +26 -19
  49. package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
  50. package/dist/components/Comment/Comment.vue.d.ts +1 -1
  51. package/dist/components/DataArea/DataArea.vue.d.ts +2 -2
  52. package/dist/components/DataTable/index.vue.d.ts +1 -1
  53. package/dist/components/DataTable/index.vue.d.ts.map +1 -1
  54. package/dist/components/DateFilter/DateFilter.vue.d.ts +41 -251
  55. package/dist/components/DatePicker/DatePicker.vue.d.ts +4 -4
  56. package/dist/components/Drawer/Drawer.vue.d.ts +4 -4
  57. package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
  58. package/dist/components/Dropdown/LanguageSelect.vue.d.ts +3 -3
  59. package/dist/components/Flag.vue.d.ts +2 -2
  60. package/dist/components/FormElement/FormElement.vue.d.ts +28 -51
  61. package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
  62. package/dist/components/Icon.vue.d.ts +1 -1
  63. package/dist/components/Icon.vue.d.ts.map +1 -1
  64. package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
  65. package/dist/components/ImportCard/ImportCard.vue.d.ts +4 -4
  66. package/dist/components/Input/BaseInput.vue.d.ts +2 -33
  67. package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
  68. package/dist/components/Input/Input.vue.d.ts +41 -251
  69. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  70. package/dist/components/Input/TextInput.vue.d.ts +25 -85
  71. package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
  72. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +46 -256
  73. package/dist/components/InputNext/InputNext.vue.d.ts +5 -5
  74. package/dist/components/Label/Label.vue.d.ts +15 -9
  75. package/dist/components/Label/Label.vue.d.ts.map +1 -1
  76. package/dist/components/Modal/Modal.vue.d.ts +2 -2
  77. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +6 -6
  78. package/dist/components/ModalNext/ModalNext.vue.d.ts +46 -256
  79. package/dist/components/ModalUpload/ModalUpload.vue.d.ts +9 -9
  80. package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
  81. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +14 -26
  82. package/dist/components/Pagination/Pagination.vue.d.ts +3 -3
  83. package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
  84. package/dist/components/Radio/Radio.vue.d.ts +6 -10
  85. package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
  86. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +470 -120
  87. package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +414 -11
  88. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +28 -21
  89. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
  90. package/dist/components/SelectTime/index.vue.d.ts +25 -85
  91. package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +1 -1
  92. package/dist/components/Slider/Slider.vue.d.ts +2 -2
  93. package/dist/components/StarRating/StarRating.vue.d.ts +1 -1
  94. package/dist/components/Switch/Switch.vue.d.ts +21 -55
  95. package/dist/components/Switch/Switch.vue.d.ts.map +1 -1
  96. package/dist/components/Tab/Tab.vue.d.ts +2 -13
  97. package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
  98. package/dist/components/TableNext/TablePagination.vue.d.ts +3 -3
  99. package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
  100. package/dist/components/Tag/BrandTag.vue.d.ts +51 -0
  101. package/dist/components/Tag/BrandTag.vue.d.ts.map +1 -0
  102. package/dist/components/Tag/DefaultTag.vue.d.ts +83 -4
  103. package/dist/components/Tag/DefaultTag.vue.d.ts.map +1 -1
  104. package/dist/components/Tag/IndicatorTag.vue.d.ts +151 -0
  105. package/dist/components/Tag/IndicatorTag.vue.d.ts.map +1 -0
  106. package/dist/components/Tag/Tag.vue.d.ts +414 -12
  107. package/dist/components/Tag/Tag.vue.d.ts.map +1 -1
  108. package/dist/components/Tag/TagNext.vue.d.ts +24 -0
  109. package/dist/components/Tag/TagNext.vue.d.ts.map +1 -0
  110. package/dist/components/TextArea/TextArea.vue.d.ts +33 -78
  111. package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
  112. package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
  113. package/dist/components/Tour/Tour.vue.d.ts +3 -3
  114. package/dist/components/Tour/TourPopover.vue.d.ts +3 -3
  115. package/dist/components/UploadArea/UploadArea.vue.d.ts +4 -4
  116. package/dist/components/index.d.ts +7677 -6315
  117. package/dist/components/index.d.ts.map +1 -1
  118. package/dist/components/ui/popover/PopoverContent.vue.d.ts +1 -1
  119. package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -1
  120. package/dist/{es-bdfb773f.mjs → es-4b899f97.mjs} +1 -1
  121. package/dist/{index-8ce04c5b.mjs → index-23489897.mjs} +8813 -9354
  122. package/dist/locales/en.json.d.ts +1 -2
  123. package/dist/locales/es.json.d.ts +1 -2
  124. package/dist/locales/pt_br.json.d.ts +1 -2
  125. package/dist/{pt-br-4befdd13.mjs → pt-br-5a914a63.mjs} +1 -1
  126. package/dist/style.css +1 -1
  127. package/dist/unnnic.mjs +173 -181
  128. package/dist/unnnic.umd.js +36 -35
  129. package/dist/utils/call.d.ts +1 -2
  130. package/dist/utils/call.d.ts.map +1 -1
  131. package/package.json +2 -2
  132. package/src/assets/scss/scheme-colors.scss +223 -309
  133. package/src/components/Alert/Alert.vue +135 -26
  134. package/src/components/Alert/AlertBanner.vue +182 -0
  135. package/src/components/Alert/AlertCaller.vue +49 -0
  136. package/src/components/Alert/Version1dot1.vue +36 -0
  137. package/src/components/Alert/__tests__/Alert.spec.js +45 -2
  138. package/src/components/Alert/__tests__/AlertBanner.spec.js +89 -0
  139. package/src/components/Alert/__tests__/AlertCaller.spec.js +98 -0
  140. package/src/components/Alert/__tests__/Version1dot1.spec.js +21 -0
  141. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +7 -11
  142. package/src/components/Alert/__tests__/__snapshots__/AlertBanner.spec.js.snap +2 -2
  143. package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +1 -1
  144. package/src/components/Button/Button.vue +117 -67
  145. package/src/components/Button/types.ts +1 -0
  146. package/src/components/ChatsContact/ChatsContact.vue +6 -10
  147. package/src/components/Checkbox/Checkbox.vue +65 -117
  148. package/src/components/Checkbox/__tests__/Checkbox.spec.js +21 -6
  149. package/src/components/FormElement/FormElement.vue +93 -63
  150. package/src/components/Icon.vue +0 -2
  151. package/src/components/Input/BaseInput.vue +14 -33
  152. package/src/components/Input/Input.scss +22 -22
  153. package/src/components/Input/Input.vue +56 -79
  154. package/src/components/Input/TextInput.vue +65 -81
  155. package/src/components/Input/__test__/Input.spec.js +33 -13
  156. package/src/components/Input/__test__/TextInput.spec.js +8 -6
  157. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +4 -17
  158. package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +1 -7
  159. package/src/components/Label/Label.vue +21 -52
  160. package/src/components/Label/__tests__/Label.spec.js +1 -1
  161. package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +1 -1
  162. package/src/components/Radio/Radio.vue +66 -118
  163. package/src/components/Radio/__test__/Radio.spec.js +20 -14
  164. package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -4
  165. package/src/components/SelectSmart/SelectSmart.vue +3 -4
  166. package/src/components/Switch/Switch.vue +91 -132
  167. package/src/components/Switch/__tests__/Switch.spec.js +75 -8
  168. package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +6 -5
  169. package/src/components/Tab/Tab.vue +23 -37
  170. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
  171. package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +2 -2
  172. package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +2 -2
  173. package/src/components/Tag/BrandTag.vue +96 -0
  174. package/src/components/Tag/DefaultTag.vue +107 -51
  175. package/src/components/Tag/IndicatorTag.vue +107 -0
  176. package/src/components/Tag/Tag.vue +79 -32
  177. package/src/components/Tag/TagNext.vue +60 -0
  178. package/src/components/TextArea/TextArea.vue +12 -41
  179. package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +3 -11
  180. package/src/components/index.ts +17 -33
  181. package/src/locales/en.json +1 -2
  182. package/src/locales/es.json +1 -2
  183. package/src/locales/pt_br.json +1 -2
  184. package/src/stories/Alert.stories.js +67 -6
  185. package/src/stories/Button.stories.js +39 -29
  186. package/src/stories/Checkbox.stories.js +4 -11
  187. package/src/stories/Input.stories.js +76 -71
  188. package/src/stories/Label.stories.js +0 -7
  189. package/src/stories/Radio.stories.js +1 -28
  190. package/src/stories/Switch.stories.js +5 -10
  191. package/src/stories/Tab.stories.js +4 -11
  192. package/src/stories/Tag.stories.js +43 -24
  193. package/src/stories/TextArea.stories.js +2 -14
  194. package/src/types/scheme-colors.d.ts +0 -1
  195. package/src/utils/call.js +18 -46
  196. package/dist/assets/tokens/colors.json.d.ts +0 -376
  197. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +0 -28
  198. package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +0 -1
  199. package/dist/components/PageHeader/PageHeader.vue.d.ts +0 -28
  200. package/dist/components/PageHeader/PageHeader.vue.d.ts.map +0 -1
  201. package/dist/components/PageHeader/index.d.ts +0 -3
  202. package/dist/components/PageHeader/index.d.ts.map +0 -1
  203. package/dist/components/PageHeader/types.d.ts +0 -9
  204. package/dist/components/PageHeader/types.d.ts.map +0 -1
  205. package/dist/components/Tag/types.d.ts +0 -18
  206. package/dist/components/Tag/types.d.ts.map +0 -1
  207. package/dist/components/Toast/Toast.vue.d.ts +0 -16
  208. package/dist/components/Toast/Toast.vue.d.ts.map +0 -1
  209. package/dist/components/Toast/ToastManager.d.ts +0 -14
  210. package/dist/components/Toast/ToastManager.d.ts.map +0 -1
  211. package/dist/components/Toast/types.d.ts +0 -35
  212. package/dist/components/Toast/types.d.ts.map +0 -1
  213. package/src/assets/icons/checkbox-checked-disabled.svg +0 -3
  214. package/src/assets/icons/checkbox-checked.svg +0 -3
  215. package/src/assets/icons/checkbox-less-disabled.svg +0 -3
  216. package/src/assets/icons/checkbox-less.svg +0 -3
  217. package/src/assets/icons/radio-checked.svg +0 -3
  218. package/src/assets/icons/switch-checked-disabled.svg +0 -3
  219. package/src/assets/icons/switch-checked.svg +0 -3
  220. package/src/components/CheckboxGroup/CheckboxGroup.vue +0 -96
  221. package/src/components/MultiSelectV2/MultSelectOption.vue +0 -67
  222. package/src/components/MultiSelectV2/__tests__/MultiSelect.spec.js +0 -556
  223. package/src/components/MultiSelectV2/__tests__/MultiSelectOption.spec.js +0 -229
  224. package/src/components/MultiSelectV2/__tests__/__snapshots__/MultiSelect.spec.js.snap +0 -121
  225. package/src/components/MultiSelectV2/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +0 -51
  226. package/src/components/MultiSelectV2/index.vue +0 -221
  227. package/src/components/PageHeader/PageHeader.vue +0 -148
  228. package/src/components/PageHeader/index.ts +0 -2
  229. package/src/components/PageHeader/types.ts +0 -10
  230. package/src/components/Popover/__tests__/Popover.spec.js +0 -147
  231. package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +0 -8
  232. package/src/components/Popover/index.vue +0 -146
  233. package/src/components/RadioGroup/RadioGroup.vue +0 -142
  234. package/src/components/Select/SelectOption.vue +0 -65
  235. package/src/components/Select/__tests__/Select.spec.js +0 -412
  236. package/src/components/Select/__tests__/SelectItem.spec.js +0 -330
  237. package/src/components/Select/__tests__/SelectOption.spec.js +0 -174
  238. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +0 -97
  239. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +0 -15
  240. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +0 -25
  241. package/src/components/Select/index.vue +0 -249
  242. package/src/components/Tag/types.ts +0 -19
  243. package/src/components/Toast/Toast.vue +0 -246
  244. package/src/components/Toast/ToastManager.ts +0 -110
  245. package/src/components/Toast/__tests__/Toast.spec.js +0 -291
  246. package/src/components/Toast/__tests__/ToastManager.spec.js +0 -294
  247. package/src/components/Toast/types.ts +0 -57
  248. package/src/stories/CheckboxGroup.stories.js +0 -105
  249. package/src/stories/MultiSelectV2.stories.js +0 -158
  250. package/src/stories/PageHeader.stories.js +0 -330
  251. package/src/stories/RadioGroup.stories.js +0 -144
  252. package/src/stories/Select.stories.js +0 -158
  253. package/src/stories/Toast.mdx +0 -123
  254. package/src/stories/Toast.stories.js +0 -126
@@ -1,249 +0,0 @@
1
- <template>
2
- <div
3
- class="unnnic-select"
4
- @keydown="handleKeyDown"
5
- >
6
- <UnnnicPopover
7
- v-model="openPopover"
8
- :popoverBalloonProps="{ maxHeight: calculatedMaxHeight }"
9
- >
10
- <template #trigger>
11
- <UnnnicInput
12
- :modelValue="inputValue"
13
- class="unnnic-select__input"
14
- readonly
15
- :forceActiveStatus="openPopover"
16
- :size="props.size"
17
- :placeholder="props.placeholder"
18
- :label="props.label"
19
- :errors="props.errors"
20
- :message="props.message"
21
- :iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
22
- :disabled="props.disabled"
23
- showClear
24
- @clear="emit('update:modelValue', '')"
25
- />
26
- </template>
27
- <template #content>
28
- <div class="unnnic-select__content">
29
- <UnnnicInput
30
- v-if="props.enableSearch"
31
- class="unnnic-select__input-search"
32
- :modelValue="props.search"
33
- :placeholder="$t('search')"
34
- iconLeft="search"
35
- @update:model-value="handleSearch"
36
- />
37
- <UnnnicSelectOption
38
- v-for="(option, index) in filteredOptions"
39
- :key="option[props.itemValue]"
40
- :data-option-index="index"
41
- :label="option[props.itemLabel]"
42
- :active="
43
- option[props.itemValue] === selectedItem?.[props.itemValue]
44
- "
45
- :focused="focusedOptionIndex === index"
46
- :disabled="option.disabled"
47
- @click="handleSelectOption(option)"
48
- />
49
- </div>
50
- </template>
51
- </UnnnicPopover>
52
- </div>
53
- </template>
54
-
55
- <script setup lang="ts">
56
- import { computed, ref, watch, nextTick } from 'vue';
57
- import UnnnicInput from '../Input/Input.vue';
58
- import UnnnicPopover from '../Popover/index.vue';
59
- import UnnnicSelectOption from './SelectOption.vue';
60
- import UnnnicI18n from '../../mixins/i18n';
61
-
62
- defineOptions({
63
- name: 'UnnnicSelect',
64
- mixins: [UnnnicI18n],
65
- });
66
-
67
- interface SelectProps {
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- options: Array<{ [key: string]: any }>;
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
- modelValue: any;
72
- returnObject?: boolean;
73
- itemLabel?: string;
74
- itemValue?: string;
75
- placeholder?: string;
76
- label?: string;
77
- type?: 'normal' | 'error';
78
- errors?: string | Array<string>;
79
- message?: string;
80
- size?: 'sm' | 'md';
81
- optionsLines?: number;
82
- enableSearch?: boolean;
83
- search?: string;
84
- locale?: string;
85
- disabled?: boolean;
86
- }
87
-
88
- const props = withDefaults(defineProps<SelectProps>(), {
89
- size: 'md',
90
- type: 'normal',
91
- placeholder: '',
92
- optionsLines: 5,
93
- returnObject: false,
94
- itemLabel: 'label',
95
- itemValue: 'value',
96
- locale: 'en',
97
- enableSearch: false,
98
- disabled: false,
99
- label: '',
100
- errors: '',
101
- message: '',
102
- search: '',
103
- });
104
-
105
- const emit = defineEmits<{
106
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
107
- 'update:modelValue': [value: any];
108
- 'update:search': [value: string];
109
- }>();
110
-
111
- const openPopover = ref(false);
112
-
113
- watch(openPopover, () => {
114
- if (!openPopover.value) {
115
- handleSearch('');
116
- } else {
117
- focusedOptionIndex.value = -1;
118
- }
119
-
120
- if (openPopover.value && props.modelValue) {
121
- const selectedOptionIndex = props.options.findIndex(
122
- (option) =>
123
- option[props.itemValue] === selectedItem.value?.[props.itemValue],
124
- );
125
- scrollToOption(selectedOptionIndex, 'instant', 'center');
126
- }
127
- });
128
-
129
- const handleKeyDown = (event) => {
130
- const { key } = event;
131
- const validKeys = ['ArrowUp', 'ArrowDown', 'Enter'];
132
- if (validKeys.includes(key)) {
133
- event.preventDefault();
134
- if (key === 'ArrowUp') {
135
- if (focusedOptionIndex.value === 0) return;
136
- focusedOptionIndex.value--;
137
- scrollToOption(focusedOptionIndex.value);
138
- }
139
- if (key === 'ArrowDown') {
140
- if (focusedOptionIndex.value === filteredOptions.value.length - 1) return;
141
- focusedOptionIndex.value++;
142
- scrollToOption(focusedOptionIndex.value);
143
- }
144
- if (key === 'Enter') {
145
- handleSelectOption(filteredOptions.value[focusedOptionIndex.value]);
146
- }
147
- }
148
- };
149
-
150
- const focusedOptionIndex = ref<number>(-1);
151
-
152
- const scrollToOption = (
153
- index: number,
154
- behavior: 'smooth' | 'instant' = 'smooth',
155
- block: 'center' | 'start' | 'end' | 'nearest' = 'center',
156
- ) => {
157
- nextTick(() => {
158
- const option = document.querySelector(`[data-option-index="${index}"]`);
159
- if (option) {
160
- option.scrollIntoView({ behavior, block });
161
- }
162
- });
163
- };
164
-
165
- const calculatedMaxHeight = computed(() => {
166
- if (!props.options || props.options.length === 0) return 'unset';
167
- const popoverPadding = 32;
168
- const popoverGap = 4;
169
- // 37 = 21px (height) + 16px (padding)
170
- const fieldsHeight = 37 * props.optionsLines;
171
- const size =
172
- fieldsHeight + popoverPadding + (popoverGap * props.optionsLines - 2);
173
- return `${props.enableSearch ? size + 54 : size}px`;
174
- });
175
-
176
- const selectedItem = computed(() => {
177
- if (props.returnObject) return props.modelValue;
178
-
179
- return props.options.find(
180
- (option) => option[props.itemValue] === props.modelValue,
181
- );
182
- });
183
-
184
- const inputValue = computed(() => {
185
- return selectedItem.value?.[props.itemLabel];
186
- });
187
-
188
- const handleSelectOption = (option) => {
189
- if (
190
- option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
191
- option.disabled
192
- )
193
- return;
194
-
195
- emit(
196
- 'update:modelValue',
197
- props.returnObject ? option : option[props.itemValue],
198
- );
199
- openPopover.value = false;
200
- };
201
-
202
- const handleSearch = (value: string) => {
203
- emit('update:search', value);
204
- };
205
-
206
- const filteredOptions = computed(() => {
207
- if (!props.enableSearch || !props.search) return props.options;
208
-
209
- return props.options.filter(
210
- (option) =>
211
- option[props.itemLabel]
212
- .toLowerCase()
213
- .includes(props.search?.toLowerCase()) ||
214
- option[props.itemValue]
215
- .toLowerCase()
216
- .includes(props.search?.toLowerCase()),
217
- );
218
- });
219
- </script>
220
-
221
- <style lang="scss" scoped>
222
- @use '@/assets/scss/unnnic' as *;
223
-
224
- :deep(.unnnic-select__input) {
225
- cursor: pointer;
226
- }
227
-
228
- :deep(.unnnic-select__input-search) {
229
- > .icon-left {
230
- color: $unnnic-color-fg-base;
231
- }
232
- }
233
-
234
- :deep(.unnnic-select__input) {
235
- > .icon-right {
236
- color: $unnnic-color-fg-base;
237
- }
238
- }
239
-
240
- .unnnic-select {
241
- &__content {
242
- display: flex;
243
- flex-direction: column;
244
- padding: 0;
245
- margin: 0;
246
- gap: $unnnic-space-1;
247
- }
248
- }
249
- </style>
@@ -1,19 +0,0 @@
1
- export type TagType = 'default' | 'brand' | 'next';
2
- export type TagSize = 'small' | 'medium';
3
-
4
- export interface TagProps {
5
- type?: TagType;
6
- size?: TagSize;
7
- text?: string;
8
- disabled?: boolean;
9
- scheme?: string;
10
- leftIcon?: string;
11
- hasCloseIcon?: boolean;
12
- }
13
-
14
- export interface DefaultTagProps {
15
- text?: string;
16
- size?: TagSize;
17
- scheme?: string;
18
- leftIcon?: string;
19
- }
@@ -1,246 +0,0 @@
1
- <template>
2
- <Transition
3
- name="toast-slide"
4
- appear
5
- data-testid="toast-transition"
6
- @after-leave="$emit('destroy')"
7
- >
8
- <aside
9
- v-if="isVisible"
10
- :class="['unnnic-toast', `unnnic-toast--${type}`]"
11
- :role="type === 'error' ? 'alert' : 'status'"
12
- :aria-live="type === 'error' ? 'assertive' : 'polite'"
13
- data-testid="toast"
14
- >
15
- <section
16
- class="unnnic-toast__content"
17
- data-testid="toast-content"
18
- >
19
- <header
20
- class="unnnic-toast__header"
21
- data-testid="toast-header"
22
- >
23
- <UnnnicIcon
24
- :icon="typeConfig.icon"
25
- :scheme="typeConfig.scheme"
26
- size="ant"
27
- data-testid="toast-type-icon"
28
- />
29
-
30
- <h3
31
- class="unnnic-toast__title"
32
- data-testid="toast-title"
33
- >
34
- {{ title }}
35
- </h3>
36
-
37
- <UnnnicIcon
38
- icon="close"
39
- scheme="neutral-dark"
40
- size="ant"
41
- clickable
42
- class="unnnic-toast__close"
43
- data-testid="toast-close-icon"
44
- @click="handleClose"
45
- @keydown.enter="handleClose"
46
- />
47
- </header>
48
-
49
- <p
50
- v-if="description"
51
- data-testid="toast-text"
52
- class="unnnic-toast__text"
53
- >
54
- {{ description }}
55
- </p>
56
- </section>
57
-
58
- <UnnnicButton
59
- v-if="button"
60
- type="tertiary"
61
- :text="button.text"
62
- class="unnnic-toast__action-button"
63
- data-testid="toast-action-button"
64
- @click="handleAction"
65
- @keydown.enter="handleAction"
66
- @keydown.space.prevent="handleAction"
67
- />
68
- </aside>
69
- </Transition>
70
- </template>
71
-
72
- <script setup lang="ts">
73
- import { ref, computed, onMounted, onUnmounted } from 'vue';
74
-
75
- import UnnnicIcon from '@/components/Icon.vue';
76
- import UnnnicButton from '@/components/Button/Button.vue';
77
-
78
- import type { ToastProps, ToastEmits } from './types';
79
- import type { SchemeColor } from '@/types/scheme-colors';
80
-
81
- defineOptions({
82
- name: 'UnnnicToast',
83
- });
84
-
85
- const props = withDefaults(defineProps<ToastProps>(), {
86
- title: '',
87
- description: '',
88
- button: undefined,
89
- timeout: 5000,
90
- type: 'informational',
91
- });
92
-
93
- const emit = defineEmits<ToastEmits>();
94
-
95
- const isVisible = ref(false);
96
- let timeoutId: number | null = null;
97
-
98
- const typeConfig = computed(() => {
99
- const configMap = {
100
- informational: { icon: 'info', scheme: 'blue-500' },
101
- attention: { icon: 'error', scheme: 'yellow-500' },
102
- success: { icon: 'check_circle', scheme: 'green-500' },
103
- error: { icon: 'cancel', scheme: 'red-500' },
104
- };
105
-
106
- return configMap[props.type || 'informational'] as {
107
- icon: string;
108
- scheme: SchemeColor;
109
- };
110
- });
111
-
112
- const handleClose = () => {
113
- isVisible.value = false;
114
- emit('close');
115
- };
116
-
117
- const handleAction = () => {
118
- if (props.button?.action) {
119
- props.button.action();
120
- }
121
- };
122
-
123
- const startTimeout = () => {
124
- if (props.timeout > 0) {
125
- timeoutId = window.setTimeout(() => {
126
- handleClose();
127
- }, props.timeout);
128
- }
129
- };
130
-
131
- const stopTimeout = () => {
132
- if (timeoutId) {
133
- window.clearTimeout(timeoutId);
134
- timeoutId = null;
135
- }
136
- };
137
-
138
- onMounted(() => {
139
- isVisible.value = true;
140
- startTimeout();
141
- });
142
-
143
- onUnmounted(() => {
144
- stopTimeout();
145
- });
146
- </script>
147
-
148
- <style lang="scss" scoped>
149
- @use '@/assets/scss/unnnic' as *;
150
-
151
- .unnnic-toast {
152
- position: fixed;
153
- bottom: $unnnic-space-4;
154
- right: $unnnic-space-4;
155
- z-index: 9999;
156
-
157
- display: flex;
158
- align-items: flex-end;
159
- flex-direction: column;
160
- gap: $unnnic-space-2;
161
-
162
- min-width: 250px;
163
- max-width: 450px;
164
- padding: $unnnic-space-4;
165
-
166
- border-radius: $unnnic-radius-2;
167
- box-shadow: $unnnic-shadow-2;
168
- border: 1px solid $unnnic-color-border-base;
169
-
170
- &--informational {
171
- border-color: $unnnic-color-border-info;
172
- background-color: $unnnic-color-bg-info;
173
- }
174
-
175
- &--attention {
176
- border-color: $unnnic-color-border-warning;
177
- background-color: $unnnic-color-bg-warning;
178
- }
179
-
180
- &--success {
181
- border-color: $unnnic-color-border-success;
182
- background-color: $unnnic-color-bg-success;
183
- }
184
-
185
- &--error {
186
- border-color: $unnnic-color-border-critical;
187
- background-color: $unnnic-color-bg-critical;
188
- }
189
-
190
- &__content,
191
- &__header {
192
- width: 100%;
193
-
194
- display: flex;
195
- }
196
-
197
- &__content {
198
- flex-direction: column;
199
- gap: $unnnic-space-1;
200
- }
201
-
202
- &__header {
203
- align-items: center;
204
- gap: $unnnic-space-2;
205
- }
206
-
207
- &__title {
208
- flex: 1;
209
-
210
- margin: 0;
211
-
212
- font: $unnnic-font-action;
213
- color: $unnnic-color-fg-emphasized;
214
- }
215
-
216
- &__text {
217
- margin: 0;
218
- margin-left: $unnnic-space-7;
219
-
220
- font: $unnnic-font-caption-2;
221
- color: $unnnic-color-fg-emphasized;
222
- }
223
- }
224
-
225
- // Animations
226
- .toast-slide-enter-active,
227
- .toast-slide-leave-active {
228
- transition: all 0.3s ease;
229
- }
230
-
231
- .toast-slide-enter-from {
232
- transform: translateY(100%);
233
- opacity: 0;
234
- }
235
-
236
- .toast-slide-leave-to {
237
- transform: translateY(100%);
238
- opacity: 0;
239
- }
240
-
241
- .toast-slide-enter-to,
242
- .toast-slide-leave-from {
243
- transform: translateY(0);
244
- opacity: 1;
245
- }
246
- </style>
@@ -1,110 +0,0 @@
1
- import { createApp } from 'vue';
2
- import Toast from './Toast.vue';
3
- import type {
4
- ToastProps,
5
- ToastInstance,
6
- ToastOptions,
7
- ToastCall,
8
- } from './types';
9
-
10
- class ToastManager implements ToastManager {
11
- private toasts: Map<string, ToastInstance> = new Map();
12
- private container: HTMLElement | null = null;
13
- private nextId = 0;
14
-
15
- private createContainer(): HTMLElement {
16
- if (this.container) {
17
- return this.container;
18
- }
19
-
20
- this.container = document.createElement('div');
21
- this.container.setAttribute('unnnic-toast-container', 'true');
22
-
23
- document.body.appendChild(this.container);
24
- return this.container;
25
- }
26
-
27
- private generateId(): string {
28
- return `toast-${++this.nextId}`;
29
- }
30
-
31
- show(props: ToastProps): ToastInstance {
32
- const id = this.generateId();
33
- const container = this.createContainer();
34
-
35
- const toastWrapper = document.createElement('div');
36
-
37
- // Create promise that resolves when toast is destroyed
38
- let resolvePromise: () => void;
39
- const promise = new Promise<void>((resolve) => {
40
- resolvePromise = resolve;
41
- });
42
-
43
- const app = createApp(Toast, {
44
- ...props,
45
- onClose: () => {
46
- this.close(id);
47
- },
48
- onDestroy: () => {
49
- app.unmount();
50
- toastWrapper.remove();
51
- resolvePromise(); // Resolve the promise when toast is destroyed
52
- },
53
- });
54
-
55
- app.mount(toastWrapper);
56
- container.appendChild(toastWrapper);
57
-
58
- const toastInstance: ToastInstance = {
59
- id,
60
- props,
61
- close: () => this.close(id),
62
- promise,
63
- };
64
-
65
- this.toasts.set(id, toastInstance);
66
- return toastInstance;
67
- }
68
-
69
- close(id: string): void {
70
- const toast = this.toasts.get(id);
71
- if (toast) {
72
- this.toasts.delete(id);
73
- }
74
- }
75
- }
76
-
77
- const toastManager = new ToastManager();
78
-
79
- export const toast: ToastCall = {
80
- info: (title: string, description?: string, options?: ToastOptions) =>
81
- toastManager.show({
82
- title,
83
- description,
84
- ...options,
85
- type: 'informational',
86
- }).promise,
87
- success: (title: string, description?: string, options?: ToastOptions) =>
88
- toastManager.show({
89
- title,
90
- description,
91
- ...options,
92
- type: 'success',
93
- }).promise,
94
- attention: (title: string, description?: string, options?: ToastOptions) =>
95
- toastManager.show({
96
- title,
97
- description,
98
- ...options,
99
- type: 'attention',
100
- }).promise,
101
- error: (title: string, description?: string, options?: ToastOptions) =>
102
- toastManager.show({
103
- title,
104
- description,
105
- ...options,
106
- type: 'error',
107
- }).promise,
108
- };
109
-
110
- export default toastManager;