@weni/unnnic-system 3.3.0 → 3.3.1-alpha.3

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 (206) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
  3. package/dist/components/Alert/Alert.vue.d.ts +18 -119
  4. package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
  5. package/dist/components/Alert/Version1dot1.vue.d.ts +2 -38
  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 +2 -2
  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 +2 -2
  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 +3 -3
  20. package/dist/components/Card/BlankCard.vue.d.ts +1 -1
  21. package/dist/components/Card/Card.vue.d.ts +21 -21
  22. package/dist/components/Card/CardCompany.vue.d.ts +8 -8
  23. package/dist/components/Card/CardData.vue.d.ts +1 -1
  24. package/dist/components/Card/CardStatusesContainer.vue.d.ts +4 -4
  25. package/dist/components/Card/ContentCard.vue.d.ts +2 -2
  26. package/dist/components/Card/DashCard.vue.d.ts +4 -4
  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 +2 -2
  32. package/dist/components/CardImage/CardImage.vue.d.ts +8 -8
  33. package/dist/components/CardInformation/CardInformation.vue.d.ts +4 -4
  34. package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
  35. package/dist/components/Carousel/Carousel.vue.d.ts +11 -11
  36. package/dist/components/Carousel/TagCarousel.vue.d.ts +9 -9
  37. package/dist/components/ChartBar/ChartBar.vue.d.ts +8 -8
  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 +15 -15
  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 +3 -3
  49. package/dist/components/Comment/Comment.vue.d.ts +1 -1
  50. package/dist/components/DataArea/DataArea.vue.d.ts +2 -2
  51. package/dist/components/DataTable/index.vue.d.ts +8 -1
  52. package/dist/components/DataTable/index.vue.d.ts.map +1 -1
  53. package/dist/components/DateFilter/DateFilter.vue.d.ts +176 -29
  54. package/dist/components/DatePicker/DatePicker.vue.d.ts +8 -8
  55. package/dist/components/Drawer/Drawer.vue.d.ts +7 -7
  56. package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
  57. package/dist/components/Dropdown/LanguageSelect.vue.d.ts +3 -3
  58. package/dist/components/Flag.vue.d.ts +2 -2
  59. package/dist/components/FormElement/FormElement.vue.d.ts +38 -32
  60. package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
  61. package/dist/components/Icon.vue.d.ts +1 -1
  62. package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
  63. package/dist/components/ImportCard/ImportCard.vue.d.ts +7 -7
  64. package/dist/components/Input/BaseInput.vue.d.ts +32 -1
  65. package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
  66. package/dist/components/Input/Input.vue.d.ts +176 -29
  67. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  68. package/dist/components/Input/TextInput.vue.d.ts +83 -14
  69. package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
  70. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +186 -39
  71. package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
  72. package/dist/components/Label/Label.vue.d.ts +9 -15
  73. package/dist/components/Label/Label.vue.d.ts.map +1 -1
  74. package/dist/components/Modal/Modal.vue.d.ts +2 -2
  75. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +9 -9
  76. package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
  77. package/dist/components/ModalNext/ModalNext.vue.d.ts +184 -37
  78. package/dist/components/ModalUpload/ModalUpload.vue.d.ts +14 -14
  79. package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
  80. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +20 -14
  81. package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
  82. package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
  83. package/dist/components/Radio/Radio.vue.d.ts +8 -6
  84. package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
  85. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +97 -28
  86. package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +8 -8
  87. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +4 -4
  88. package/dist/components/SelectTime/index.vue.d.ts +83 -14
  89. package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +1 -1
  90. package/dist/components/Slider/Slider.vue.d.ts +2 -2
  91. package/dist/components/StarRating/StarRating.vue.d.ts +1 -1
  92. package/dist/components/Switch/Switch.vue.d.ts +2 -2
  93. package/dist/components/Tab/Tab.vue.d.ts +13 -2
  94. package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
  95. package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
  96. package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
  97. package/dist/components/Tag/BrandTag.vue.d.ts +2 -2
  98. package/dist/components/Tag/DefaultTag.vue.d.ts +2 -2
  99. package/dist/components/Tag/IndicatorTag.vue.d.ts +2 -2
  100. package/dist/components/Tag/Tag.vue.d.ts +8 -8
  101. package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts +9 -0
  102. package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -0
  103. package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts +15 -0
  104. package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts.map +1 -0
  105. package/dist/components/TextArea/TextArea.vue.d.ts +38 -32
  106. package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
  107. package/dist/components/Toast/Toast.vue.d.ts +16 -0
  108. package/dist/components/Toast/Toast.vue.d.ts.map +1 -0
  109. package/dist/components/Toast/ToastManager.d.ts +14 -0
  110. package/dist/components/Toast/ToastManager.d.ts.map +1 -0
  111. package/dist/components/Toast/types.d.ts +35 -0
  112. package/dist/components/Toast/types.d.ts.map +1 -0
  113. package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
  114. package/dist/components/Tour/Tour.vue.d.ts +6 -6
  115. package/dist/components/Tour/TourPopover.vue.d.ts +6 -6
  116. package/dist/components/UploadArea/UploadArea.vue.d.ts +7 -7
  117. package/dist/components/index.d.ts +2136 -1114
  118. package/dist/components/index.d.ts.map +1 -1
  119. package/dist/{es-db7a2f44.mjs → es-94ab560e.mjs} +1 -1
  120. package/dist/{index-08caf833.mjs → index-5caf403e.mjs} +8790 -8436
  121. package/dist/locales/en.json.d.ts +2 -1
  122. package/dist/locales/es.json.d.ts +2 -1
  123. package/dist/locales/pt_br.json.d.ts +2 -1
  124. package/dist/{pt-br-88538a51.mjs → pt-br-3002df05.mjs} +1 -1
  125. package/dist/style.css +1 -1
  126. package/dist/unnnic.mjs +126 -120
  127. package/dist/unnnic.umd.js +42 -41
  128. package/dist/utils/call.d.ts +2 -1
  129. package/dist/utils/call.d.ts.map +1 -1
  130. package/package.json +2 -2
  131. package/src/assets/icons/radio-checked.svg +3 -0
  132. package/src/assets/img/previews/doc-preview.png +0 -0
  133. package/src/assets/img/previews/image-preview.png +0 -0
  134. package/src/assets/img/previews/video-preview.png +0 -0
  135. package/src/assets/scss/scheme-colors.scss +115 -111
  136. package/src/assets/tokens/colors.json +2 -2
  137. package/src/components/Alert/Alert.vue +26 -135
  138. package/src/components/Alert/Version1dot1.vue +0 -36
  139. package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +11 -7
  140. package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
  141. package/src/components/Button/Button.vue +60 -108
  142. package/src/components/Button/types.ts +0 -1
  143. package/src/components/DataTable/index.vue +25 -10
  144. package/src/components/FormElement/FormElement.vue +51 -91
  145. package/src/components/Input/BaseInput.vue +31 -14
  146. package/src/components/Input/Input.scss +19 -21
  147. package/src/components/Input/Input.vue +94 -30
  148. package/src/components/Input/TextInput.vue +82 -58
  149. package/src/components/Input/__test__/TextInput.spec.js +5 -5
  150. package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +16 -3
  151. package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
  152. package/src/components/Label/Label.vue +52 -21
  153. package/src/components/Label/__tests__/Label.spec.js +1 -1
  154. package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +1 -1
  155. package/src/components/ModalDialog/ModalDialog.vue +1 -0
  156. package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -1
  157. package/src/components/Popover/__tests__/Popover.spec.js +147 -0
  158. package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
  159. package/src/components/Popover/index.vue +146 -0
  160. package/src/components/Radio/Radio.vue +80 -67
  161. package/src/components/Radio/__test__/Radio.spec.js +14 -20
  162. package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -3
  163. package/src/components/RadioGroup/RadioGroup.vue +110 -0
  164. package/src/components/Select/SelectOption.vue +65 -0
  165. package/src/components/Select/__tests__/Select.spec.js +412 -0
  166. package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
  167. package/src/components/Select/__tests__/SelectOption.spec.js +174 -0
  168. package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +97 -0
  169. package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
  170. package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
  171. package/src/components/Select/index.vue +245 -0
  172. package/src/components/Tab/Tab.vue +37 -23
  173. package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
  174. package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +2 -2
  175. package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +2 -2
  176. package/src/components/TemplatePreview/TemplatePreview.vue +252 -0
  177. package/src/components/TemplatePreview/TemplatePreviewModal.vue +51 -0
  178. package/src/components/TemplatePreview/types.d.ts +16 -0
  179. package/src/components/TextArea/TextArea.vue +13 -9
  180. package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +7 -2
  181. package/src/components/Toast/Toast.vue +236 -0
  182. package/src/components/Toast/ToastManager.ts +110 -0
  183. package/src/components/Toast/types.ts +57 -0
  184. package/src/components/index.ts +18 -4
  185. package/src/locales/en.json +2 -1
  186. package/src/locales/es.json +2 -1
  187. package/src/locales/pt_br.json +2 -1
  188. package/src/stories/Alert.stories.js +6 -67
  189. package/src/stories/Button.stories.js +2 -17
  190. package/src/stories/DataTable.stories.js +60 -0
  191. package/src/stories/Input.stories.js +22 -3
  192. package/src/stories/Label.stories.js +7 -0
  193. package/src/stories/Popover.stories.js +39 -0
  194. package/src/stories/RadioGroup.stories.js +139 -0
  195. package/src/stories/Select.stories.js +158 -0
  196. package/src/stories/Tab.stories.js +11 -4
  197. package/src/stories/TemplatePreview.stories.js +94 -0
  198. package/src/stories/TemplatePreviewModal.stories.js +110 -0
  199. package/src/stories/Toast.mdx +123 -0
  200. package/src/stories/Toast.stories.js +126 -0
  201. package/src/types/scheme-colors.d.ts +120 -14
  202. package/src/utils/call.js +46 -18
  203. package/src/components/Alert/AlertBanner.vue +0 -182
  204. package/src/components/Alert/AlertCaller.vue +0 -49
  205. package/src/components/Alert/__tests__/AlertBanner.spec.js +0 -89
  206. package/src/components/Alert/__tests__/AlertCaller.spec.js +0 -98
@@ -1,34 +1,65 @@
1
1
  <template>
2
- <p class="unnnic-label__label">{{ fullySanitize(label) }}</p>
2
+ <section class="unnnic-label">
3
+ <p class="unnnic-label__label">{{ fullySanitize(props.label) }}</p>
4
+ <UnnnicToolTip
5
+ v-if="tooltip"
6
+ enabled
7
+ :text="tooltip"
8
+ :enableHtml="props.useHtmlTooltip"
9
+ >
10
+ <UnnnicIcon
11
+ icon="help"
12
+ size="sm"
13
+ scheme="fg-base"
14
+ />
15
+ </UnnnicToolTip>
16
+ </section>
3
17
  </template>
4
18
 
5
- <script>
6
- import { fullySanitize } from '../../utils/sanitize';
7
- export default {
19
+ <script setup lang="ts">
20
+ import { fullySanitize } from '@/utils/sanitize';
21
+
22
+ import UnnnicToolTip from '../ToolTip/ToolTip.vue';
23
+ import UnnnicIcon from '../Icon.vue';
24
+
25
+ defineOptions({
8
26
  name: 'UnnnicLabel',
9
- props: {
10
- label: {
11
- type: String,
12
- default: null,
13
- },
14
- },
15
- methods: {
16
- fullySanitize,
17
- },
18
- };
27
+ });
28
+
29
+ export interface LabelProps {
30
+ label?: string;
31
+ tooltip?: string;
32
+ useHtmlTooltip?: boolean;
33
+ }
34
+
35
+ const props = withDefaults(defineProps<LabelProps>(), {
36
+ label: '',
37
+ tooltip: '',
38
+ useHtmlTooltip: false,
39
+ });
19
40
  </script>
20
41
 
21
- <style lang="scss">
42
+ <style lang="scss" scoped>
22
43
  @use '@/assets/scss/unnnic' as *;
23
44
 
45
+ * {
46
+ box-sizing: border-box;
47
+ padding: $unnnic-space-0;
48
+ margin: $unnnic-space-0;
49
+ }
50
+
24
51
  .unnnic-label {
52
+ display: flex;
53
+ align-items: center;
54
+ gap: $unnnic-space-2;
55
+ color: $unnnic-color-fg-base;
56
+
25
57
  &__label {
26
- font-family: $unnnic-font-family-secondary;
27
- font-weight: $unnnic-font-weight-regular;
28
- line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
29
- font-size: $unnnic-font-size-body-gt;
30
- color: $unnnic-color-neutral-cloudy;
31
- margin: $unnnic-spacing-stack-xs 0;
58
+ font: $unnnic-font-body;
59
+ }
60
+
61
+ :deep(.unnnic-tooltip) {
62
+ display: flex;
32
63
  }
33
64
  }
34
65
  </style>
@@ -24,7 +24,7 @@ describe('Label', () => {
24
24
  });
25
25
 
26
26
  it('applies the correct classes and styles', () => {
27
- const label = wrapper.findComponent('.unnnic-label__label');
27
+ const label = wrapper.find('.unnnic-label__label');
28
28
  expect(label.html()).toMatchSnapshot();
29
29
  });
30
30
  });
@@ -1,3 +1,3 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
- exports[`Label > applies the correct classes and styles 1`] = `"<p class="unnnic-label__label">Label Test</p>"`;
3
+ exports[`Label > applies the correct classes and styles 1`] = `"<p data-v-7f222291="" class="unnnic-label__label">Label Test</p>"`;
@@ -49,6 +49,7 @@
49
49
  data-testid="close-icon"
50
50
  icon="close"
51
51
  clickable
52
+ scheme="neutral-cloudy"
52
53
  @click="close()"
53
54
  />
54
55
  </header>
@@ -11,7 +11,7 @@ exports[`ModalDialog.vue > Elements rendering > matches the snapshot 1`] = `
11
11
  <unnnic-icon-stub data-v-68ebadeb="" filled="false" next="false" icon="test-icon" clickable="false" size="md" scheme="neutral-darkest" data-testid="title-icon" class="unnnic-modal-dialog__container__title-icon"></unnnic-icon-stub>
12
12
  <h1 data-v-68ebadeb="" class="unnnic-modal-dialog__container__title-text" data-testid="title-text">Test Title</h1>
13
13
  </section>
14
- <unnnic-icon-stub data-v-68ebadeb="" filled="false" next="false" icon="close" clickable="true" size="md" scheme="neutral-darkest" data-testid="close-icon"></unnnic-icon-stub>
14
+ <unnnic-icon-stub data-v-68ebadeb="" filled="false" next="false" icon="close" clickable="true" size="md" scheme="neutral-cloudy" data-testid="close-icon"></unnnic-icon-stub>
15
15
  </header>
16
16
  <section data-v-68ebadeb="" class="unnnic-modal-dialog__container__content"></section>
17
17
  <section data-v-68ebadeb="" data-testid="actions-section" class="unnnic-modal-dialog__container__actions">
@@ -0,0 +1,147 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { beforeEach, describe, expect, afterEach, test, vi } from 'vitest';
3
+ import UnnnicPopover from '@/components/Popover/index.vue';
4
+
5
+ vi.mock('@vueuse/core', () => ({
6
+ onClickOutside: vi.fn(),
7
+ useResizeObserver: vi.fn(),
8
+ }));
9
+
10
+ describe('UnnnicPopover.vue', () => {
11
+ let wrapper;
12
+
13
+ const defaultSlots = {
14
+ trigger: '<button data-testid="trigger-button">Click me</button>',
15
+ content: '<div data-testid="popover-content">Popover content</div>',
16
+ };
17
+
18
+ const mountWrapper = (props) => {
19
+ return mount(UnnnicPopover, {
20
+ slots: defaultSlots,
21
+ props: {
22
+ ...props,
23
+ },
24
+ });
25
+ };
26
+
27
+ beforeEach(() => {
28
+ wrapper = mountWrapper();
29
+ });
30
+
31
+ afterEach(() => {
32
+ wrapper?.unmount();
33
+ });
34
+
35
+ test('renders correctly', () => {
36
+ expect(wrapper.exists()).toBe(true);
37
+ expect(wrapper.find('.unnnic-popover').exists()).toBe(true);
38
+ });
39
+
40
+ test('renders trigger slot', () => {
41
+ const trigger = wrapper.find('[data-testid="popover-trigger"]');
42
+ const triggerButton = wrapper.find('[data-testid="trigger-button"]');
43
+
44
+ expect(trigger.exists()).toBe(true);
45
+ expect(triggerButton.exists()).toBe(true);
46
+ expect(triggerButton.text()).toBe('Click me');
47
+ });
48
+
49
+ test('renders content slot inside balloon', async () => {
50
+ wrapper.vm.open = true;
51
+ await wrapper.vm.$nextTick();
52
+ const balloon = wrapper.find('[data-testid="popover-balloon"]');
53
+ const content = wrapper.find('[data-testid="popover-content"]');
54
+
55
+ expect(balloon.exists()).toBe(true);
56
+ expect(content.exists()).toBe(true);
57
+ expect(content.text()).toBe('Popover content');
58
+ });
59
+
60
+ test('balloon is hidden by default', () => {
61
+ const balloon = wrapper.find('[data-testid="popover-balloon"]');
62
+ expect(balloon.exists()).toBe(false);
63
+ });
64
+
65
+ test('toggles balloon visibility when trigger is clicked', async () => {
66
+ const trigger = wrapper.find('[data-testid="popover-trigger"]');
67
+
68
+ let balloon = wrapper.find('[data-testid="popover-balloon"]');
69
+
70
+ expect(balloon.exists()).toBe(false);
71
+
72
+ await trigger.trigger('click');
73
+ await wrapper.vm.$nextTick();
74
+
75
+ balloon = wrapper.find('[data-testid="popover-balloon"]');
76
+
77
+ expect(balloon.exists()).toBe(true);
78
+ });
79
+
80
+ test('uses modelValue when provided', async () => {
81
+ const wrapper = mountWrapper({ modelValue: true });
82
+ const balloon = wrapper.find('[data-testid="popover-balloon"]');
83
+ expect(balloon.isVisible()).toBe(true);
84
+ });
85
+
86
+ test('emits update:modelValue when open state changes', async () => {
87
+ await wrapper.setProps({ modelValue: false });
88
+
89
+ const trigger = wrapper.find('[data-testid="popover-trigger"]');
90
+ await trigger.trigger('click');
91
+
92
+ expect(wrapper.emitted('update:modelValue')).toBeTruthy();
93
+ expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
94
+ });
95
+
96
+ test('does not emit update:modelValue when modelValue is undefined', async () => {
97
+ const trigger = wrapper.find('[data-testid="popover-trigger"]');
98
+ await trigger.trigger('click');
99
+
100
+ expect(wrapper.emitted('update:modelValue')).toBeFalsy();
101
+ });
102
+
103
+ test('exposes open ref', () => {
104
+ expect(wrapper.vm.open).toBeDefined();
105
+ expect(typeof wrapper.vm.open).toBe('boolean');
106
+ });
107
+
108
+ test('open ref can be controlled programmatically', async () => {
109
+ wrapper.vm.open = true;
110
+ await wrapper.vm.$nextTick();
111
+
112
+ const balloon = wrapper.find('[data-testid="popover-balloon"]');
113
+ expect(balloon.isVisible()).toBe(true);
114
+ });
115
+
116
+ test('persistent prop prevents closing on outside click', async () => {
117
+ await wrapper.setProps({ persistent: true });
118
+
119
+ const { onClickOutside } = await import('@vueuse/core');
120
+ const mockOnClickOutside = vi.mocked(onClickOutside);
121
+
122
+ const callback = mockOnClickOutside.mock.calls[0][1];
123
+
124
+ wrapper.vm.open = true;
125
+ await wrapper.vm.$nextTick();
126
+
127
+ callback();
128
+
129
+ const balloon = wrapper.find('[data-testid="popover-balloon"]');
130
+ expect(balloon.isVisible()).toBe(true);
131
+ });
132
+
133
+ test('applies correct CSS classes', async () => {
134
+ wrapper.vm.open = true;
135
+ await wrapper.vm.$nextTick();
136
+
137
+ const popover = wrapper.find('.unnnic-popover');
138
+ const balloon = wrapper.find('.unnnic-popover__balloon');
139
+
140
+ expect(popover.exists()).toBe(true);
141
+ expect(balloon.exists()).toBe(true);
142
+ });
143
+
144
+ test('matches the snapshot', () => {
145
+ expect(wrapper.html()).toMatchSnapshot();
146
+ });
147
+ });
@@ -0,0 +1,8 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`UnnnicPopover.vue > matches the snapshot 1`] = `
4
+ "<section data-v-5a3125ac="" class="unnnic-popover">
5
+ <div data-v-5a3125ac="" class="unnnic-popover__trigger" data-testid="popover-trigger"><button data-testid="trigger-button">Click me</button></div>
6
+ <!--v-if-->
7
+ </section>"
8
+ `;
@@ -0,0 +1,146 @@
1
+ <template>
2
+ <section
3
+ ref="popover"
4
+ class="unnnic-popover"
5
+ >
6
+ <div
7
+ class="unnnic-popover__trigger"
8
+ data-testid="popover-trigger"
9
+ @click="toggleOpen()"
10
+ >
11
+ <slot name="trigger" />
12
+ </div>
13
+ <div
14
+ v-if="open"
15
+ class="unnnic-popover__balloon"
16
+ data-testid="popover-balloon"
17
+ >
18
+ <slot name="content" />
19
+ </div>
20
+ </section>
21
+ </template>
22
+
23
+ <script setup lang="ts">
24
+ import { computed, onMounted, ref, useTemplateRef, watch } from 'vue';
25
+ import { onClickOutside, useResizeObserver } from '@vueuse/core';
26
+
27
+ const target = useTemplateRef<HTMLDivElement>('popover');
28
+
29
+ const popoverWidth = ref<string>('');
30
+
31
+ useResizeObserver(target, (entries) => {
32
+ const entry = entries[0];
33
+ const { width } = entry.contentRect;
34
+ popoverWidth.value = `${width}px`;
35
+ });
36
+
37
+ onClickOutside(target, () => {
38
+ if (props.persistent) return;
39
+ open.value = false;
40
+ });
41
+
42
+ defineOptions({
43
+ name: 'UnnnicPopover',
44
+ });
45
+
46
+ interface PopoverBalloonProps {
47
+ width?: string;
48
+ height?: string;
49
+ maxHeight?: string;
50
+ }
51
+
52
+ interface PopoverProps {
53
+ modelValue?: boolean;
54
+ persistent?: boolean;
55
+ popoverBalloonProps?: PopoverBalloonProps;
56
+ }
57
+
58
+ const props = withDefaults(defineProps<PopoverProps>(), {
59
+ modelValue: undefined,
60
+ persistent: false,
61
+ });
62
+
63
+ const emit = defineEmits<{
64
+ 'update:modelValue': [value: boolean];
65
+ }>();
66
+
67
+ const useModelValue = computed(() => props.modelValue !== undefined);
68
+
69
+ const open = ref<boolean>(
70
+ useModelValue.value ? Boolean(props.modelValue) : false,
71
+ );
72
+
73
+ const toggleOpen = () => {
74
+ open.value = !open.value;
75
+ };
76
+
77
+ const calculatedPopoverWidth = computed(() => {
78
+ return props.popoverBalloonProps?.width || popoverWidth.value;
79
+ });
80
+
81
+ const popoverHeight = computed(() => {
82
+ return props.popoverBalloonProps?.height || 'unset';
83
+ });
84
+
85
+ const popoverMaxHeight = computed(() => {
86
+ return props.popoverBalloonProps?.maxHeight || 'unset';
87
+ });
88
+
89
+ onMounted(() => {
90
+ if (useModelValue.value) {
91
+ open.value = Boolean(props.modelValue);
92
+ }
93
+ });
94
+
95
+ watch(open, (value) => {
96
+ if (useModelValue.value) {
97
+ emit('update:modelValue', value);
98
+ }
99
+ });
100
+
101
+ watch(
102
+ () => props.modelValue,
103
+ (value) => {
104
+ open.value = !!value;
105
+ },
106
+ );
107
+ </script>
108
+
109
+ <style lang="scss" scoped>
110
+ @use '@/assets/scss/unnnic' as *;
111
+
112
+ * {
113
+ margin: 0;
114
+ padding: 0;
115
+ box-sizing: border-box;
116
+ }
117
+
118
+ .unnnic-popover {
119
+ &__balloon {
120
+ border-radius: $unnnic-radius-2;
121
+ padding: $unnnic-space-4;
122
+ background: $unnnic-color-bg-base;
123
+ box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.16);
124
+ // margin-top: $unnnic-space-1;
125
+ position: fixed;
126
+ width: v-bind(calculatedPopoverWidth);
127
+ height: v-bind(popoverHeight);
128
+ max-height: v-bind(popoverMaxHeight);
129
+ overflow: auto;
130
+
131
+ &::-webkit-scrollbar {
132
+ width: $unnnic-spacing-inline-nano;
133
+ }
134
+
135
+ &::-webkit-scrollbar-thumb {
136
+ background: $unnnic-color-neutral-cleanest;
137
+ border-radius: $unnnic-border-radius-pill;
138
+ }
139
+
140
+ &::-webkit-scrollbar-track {
141
+ background: $unnnic-color-neutral-soft;
142
+ border-radius: $unnnic-border-radius-pill;
143
+ }
144
+ }
145
+ }
146
+ </style>
@@ -1,29 +1,33 @@
1
1
  <!-- eslint-disable vue/multi-word-component-names -->
2
2
  <template>
3
- <div
4
- :class="[
5
- 'unnnic-radio-container',
6
- `unnnic-radio-container--${size}`,
7
- disabled ? 'disabled' : null,
8
- ]"
9
- @click="click"
10
- >
11
- <UnnnicIcon
12
- class="unnnic-radio"
13
- :icon="icon"
14
- :scheme="color"
15
- :size="size"
16
- />
17
-
18
- <span class="label">
19
- <slot />
20
- </span>
21
- </div>
3
+ <section class="unnnic-radio-container">
4
+ <label>
5
+ <input
6
+ class="unnnic-radio"
7
+ type="radio"
8
+ :disabled="disabled"
9
+ :checked="computedModelValue === value"
10
+ @change="click"
11
+ :name="computedName"
12
+ v-bind="pick($attrs, ['id'])"
13
+ />
14
+
15
+ <p
16
+ :class="[
17
+ 'unnnic-radio__label',
18
+ { 'unnnic-radio__label--disabled': disabled },
19
+ ]"
20
+ >
21
+ {{ label }}
22
+ <slot />
23
+ </p>
24
+ </label>
25
+ </section>
22
26
  </template>
23
27
 
24
28
  <script setup>
25
- import { computed } from 'vue';
26
- import UnnnicIcon from '../Icon.vue';
29
+ import { pick } from 'lodash';
30
+ import { inject, computed } from 'vue';
27
31
 
28
32
  const props = defineProps({
29
33
  modelValue: {
@@ -38,79 +42,88 @@ const props = defineProps({
38
42
  type: Boolean,
39
43
  default: false,
40
44
  },
41
- size: {
45
+ label: {
42
46
  type: String,
43
- default: 'md',
44
- validator(value) {
45
- return ['md', 'sm'].includes(value);
46
- },
47
+ default: '',
48
+ },
49
+ name: {
50
+ type: String,
51
+ default: '',
47
52
  },
48
53
  });
49
54
 
50
55
  const emit = defineEmits(['update:modelValue']);
51
56
 
52
- const valueName = computed(() =>
53
- props.modelValue === props.value ? 'selected' : 'default',
54
- );
55
- const icon = computed(
56
- () =>
57
- ({
58
- selected: 'radio-selected',
59
- default: props.disabled ? 'radio-disable' : 'radio-default',
60
- })[valueName.value],
61
- );
62
- const color = computed(() => {
63
- if (props.disabled) {
64
- return 'brand-sec';
65
- }
66
-
67
- return valueName.value === 'selected' ? 'brand-weni' : 'neutral-cleanest';
68
- });
57
+ const contextModelValue = inject('contextModelValue', undefined);
58
+ const contextName = inject('contextName', undefined);
69
59
 
70
60
  function click() {
71
61
  if (!props.disabled) {
72
62
  emit('update:modelValue', props.value);
63
+
64
+ if (contextModelValue) {
65
+ contextModelValue.value = props.value;
66
+ }
73
67
  }
74
68
  }
69
+
70
+ const computedModelValue = computed(() => {
71
+ return contextModelValue?.value || props.modelValue;
72
+ });
73
+
74
+ const computedName = computed(() => {
75
+ return contextName?.value || props.name;
76
+ });
75
77
  </script>
76
78
 
77
79
  <style lang="scss" scoped>
78
80
  @use '@/assets/scss/unnnic' as *;
79
81
 
82
+ $radio-size: 21px;
83
+
80
84
  .unnnic-radio-container {
81
85
  display: inline-flex;
82
- align-items: center;
86
+ flex-direction: column;
83
87
 
84
- &:not(.disabled) {
85
- cursor: pointer;
88
+ label {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: $unnnic-space-2;
86
92
  }
87
93
 
88
- &--sm .unnnic-radio {
89
- margin: $unnnic-spacing-stack-nano $unnnic-spacing-inline-nano;
90
- }
94
+ .unnnic-radio {
95
+ appearance: none;
96
+ width: $radio-size;
97
+ height: $radio-size;
98
+ margin: 0;
99
+ background-color: $unnnic-color-bg-base;
100
+ border: 1px solid $unnnic-color-border-base;
101
+ border-radius: $unnnic-radius-full;
102
+ box-sizing: border-box;
103
+ outline: none;
91
104
 
92
- &--md .unnnic-radio {
93
- margin: $unnnic-spacing-stack-nano 0;
94
- margin-left: $unnnic-spacing-inline-nano;
95
- margin-right: $unnnic-spacing-inline-xs;
96
- }
105
+ &:checked {
106
+ border-width: 0;
107
+ background-color: $unnnic-color-bg-active;
108
+ background-image: url('@/assets/icons/radio-checked.svg');
109
+ background-position: center;
110
+ background-repeat: no-repeat;
111
+ }
97
112
 
98
- .label {
99
- font-family: $unnnic-font-family-secondary;
100
- font-weight: $unnnic-font-weight-regular;
101
- color: $unnnic-color-neutral-darkest;
102
- margin: $unnnic-spacing-stack-nano 0;
103
- margin-right: $unnnic-spacing-inline-nano;
113
+ &:disabled {
114
+ background-color: $unnnic-color-bg-muted;
115
+ border: 1px solid $unnnic-color-border-muted;
116
+ }
104
117
  }
105
118
 
106
- &--sm .label {
107
- font-size: $unnnic-font-size-body-md;
108
- line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
109
- }
119
+ .unnnic-radio__label {
120
+ margin: 0;
121
+ font: $unnnic-font-body;
122
+ color: $unnnic-color-fg-emphasized;
110
123
 
111
- &--md .label {
112
- font-size: $unnnic-font-size-body-gt;
113
- line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
124
+ &--disabled {
125
+ color: $unnnic-color-fg-muted;
126
+ }
114
127
  }
115
128
  }
116
129
  </style>
@@ -33,41 +33,35 @@ describe('Radio.vue', () => {
33
33
  expect(wrapper.exists()).toBe(true);
34
34
  });
35
35
 
36
- test('renders UnnnicIcon component with correct props', () => {
37
- const unnnicIcon = wrapper.findComponent(UnnnicIcon);
38
- expect(unnnicIcon.exists()).toBe(true);
39
- expect(unnnicIcon.props('icon')).toBe('radio-default');
40
- expect(unnnicIcon.props('scheme')).toBe('neutral-cleanest');
41
- expect(unnnicIcon.props('size')).toBe('md');
42
- });
43
-
44
- test('applies the correct size class', async () => {
45
- expect(wrapper.classes()).toContain('unnnic-radio-container--md');
46
-
47
- await wrapper.setProps({ size: 'sm' });
48
- expect(wrapper.classes()).toContain('unnnic-radio-container--sm');
36
+ test('renders input with correct attributes', () => {
37
+ const input = wrapper.find('input');
38
+ expect(input.exists()).toBe(true);
39
+ expect(input.attributes('type')).toBe('radio');
40
+ expect(input.attributes('disabled')).toBe(undefined);
41
+ expect(input.attributes('checked')).toBe(undefined);
49
42
  });
50
43
 
51
44
  test('applies disabled class when disabled prop is true', async () => {
52
45
  await wrapper.setProps({ disabled: true });
53
- expect(wrapper.classes()).toContain('disabled');
46
+ expect(wrapper.find('.unnnic-radio__label').classes()).toContain(
47
+ 'unnnic-radio__label--disabled',
48
+ );
54
49
  });
55
50
 
56
51
  test('icon changes based on valueName', async () => {
57
52
  await wrapper.setProps({ modelValue: 'option1' });
58
- const unnnicIcon = wrapper.findComponent(UnnnicIcon);
59
- expect(unnnicIcon.props('icon')).toBe('radio-selected');
53
+ const input = wrapper.find('input');
54
+ expect(input.attributes()).toHaveProperty('checked');
60
55
  });
61
56
 
62
57
  test('icon and color change when disabled is true', async () => {
63
58
  await wrapper.setProps({ disabled: true });
64
- const unnnicIcon = wrapper.findComponent(UnnnicIcon);
65
- expect(unnnicIcon.props('icon')).toBe('radio-disable');
66
- expect(unnnicIcon.props('scheme')).toBe('brand-sec');
59
+ const input = wrapper.find('input');
60
+ expect(input.attributes()).toHaveProperty('disabled');
67
61
  });
68
62
 
69
63
  test('emits update:modelValue with correct value when clicked and not disabled', async () => {
70
- await wrapper.trigger('click');
64
+ await wrapper.find('input').trigger('change');
71
65
  expect(wrapper.emitted('update:modelValue')).toBeTruthy();
72
66
  expect(wrapper.emitted('update:modelValue')[0]).toEqual(['option1']);
73
67
  });