@weni/unnnic-system 3.2.1 → 3.2.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 (121) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/Accordion/Accordion.vue.d.ts +13 -72
  3. package/dist/components/Alert/Alert.vue.d.ts +28 -146
  4. package/dist/components/Alert/Version1dot1.vue.d.ts +14 -73
  5. package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +13 -72
  6. package/dist/components/AudioRecorder/AudioPlayer.vue.d.ts +13 -72
  7. package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +39 -216
  8. package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +13 -72
  9. package/dist/components/Banner/Banner.vue.d.ts +13 -72
  10. package/dist/components/Banner/InfoBanner.vue.d.ts +13 -72
  11. package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +13 -72
  12. package/dist/components/Button/Button.vue.d.ts +21 -180
  13. package/dist/components/Button/Button.vue.d.ts.map +1 -1
  14. package/dist/components/Button/ButtonIcon.vue.d.ts +13 -72
  15. package/dist/components/Button/types.d.ts +16 -0
  16. package/dist/components/Button/types.d.ts.map +1 -0
  17. package/dist/components/Card/AccountCard.vue.d.ts +13 -72
  18. package/dist/components/Card/BlankCard.vue.d.ts +13 -72
  19. package/dist/components/Card/Card.vue.d.ts +107 -579
  20. package/dist/components/Card/CardCompany.vue.d.ts +40 -217
  21. package/dist/components/Card/CardData.vue.d.ts +13 -72
  22. package/dist/components/Card/CardStatusesContainer.vue.d.ts +26 -144
  23. package/dist/components/Card/ContentCard.vue.d.ts +13 -72
  24. package/dist/components/Card/DashCard.vue.d.ts +26 -144
  25. package/dist/components/Card/MarketplaceCard.vue.d.ts +13 -72
  26. package/dist/components/Card/SimpleCard.vue.d.ts +13 -72
  27. package/dist/components/Card/StatusCard.vue.d.ts +13 -72
  28. package/dist/components/Card/TitleCard.vue.d.ts +14 -73
  29. package/dist/components/CardImage/CardImage.vue.d.ts +39 -216
  30. package/dist/components/CardInformation/CardInformation.vue.d.ts +26 -144
  31. package/dist/components/CardProject/CardProject.vue.d.ts +14 -73
  32. package/dist/components/Carousel/Carousel.vue.d.ts +55 -291
  33. package/dist/components/Carousel/TagCarousel.vue.d.ts +53 -289
  34. package/dist/components/ChartBar/ChartBar.vue.d.ts +57 -252
  35. package/dist/components/ChatText/ChatText.vue.d.ts +13 -72
  36. package/dist/components/ChatsContact/ChatsContact.vue.d.ts +79 -433
  37. package/dist/components/ChatsDashboardTagLive/ChatsDashboardTagLive.vue.d.ts +13 -72
  38. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +112 -291
  39. package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts.map +1 -1
  40. package/dist/components/ChatsMessage/ChatsMessageStatusBackdrop.vue.d.ts +26 -144
  41. package/dist/components/ChatsMessage/ChatsMessageText.vue.d.ts +42 -3
  42. package/dist/components/ChatsMessage/ChatsMessageText.vue.d.ts.map +1 -1
  43. package/dist/components/ChatsNavbar/ChatsNavbar.vue.d.ts +13 -72
  44. package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +13 -72
  45. package/dist/components/Checkbox/Checkbox.vue.d.ts +13 -72
  46. package/dist/components/DateFilter/DateFilter.vue.d.ts +17 -76
  47. package/dist/components/DatePicker/DatePicker.vue.d.ts +45 -181
  48. package/dist/components/Disclaimer/Disclaimer.vue.d.ts +5 -110
  49. package/dist/components/Disclaimer/Disclaimer.vue.d.ts.map +1 -1
  50. package/dist/components/Disclaimer/types.d.ts +7 -0
  51. package/dist/components/Disclaimer/types.d.ts.map +1 -0
  52. package/dist/components/Drawer/Drawer.vue.d.ts +57 -252
  53. package/dist/components/Dropdown/LanguageSelect.vue.d.ts +26 -144
  54. package/dist/components/Flag.vue.d.ts +13 -72
  55. package/dist/components/FormElement/FormElement.vue.d.ts +13 -72
  56. package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
  57. package/dist/components/Icon/types.d.ts +13 -0
  58. package/dist/components/Icon/types.d.ts.map +1 -0
  59. package/dist/components/Icon.vue.d.ts +15 -72
  60. package/dist/components/Icon.vue.d.ts.map +1 -1
  61. package/dist/components/IconLoading/IconLoading.vue.d.ts +13 -72
  62. package/dist/components/ImportCard/ImportCard.vue.d.ts +57 -252
  63. package/dist/components/Input/BaseInput.vue.d.ts +1 -1
  64. package/dist/components/Input/Input.vue.d.ts +17 -76
  65. package/dist/components/Input/Input.vue.d.ts.map +1 -1
  66. package/dist/components/Input/TextInput.vue.d.ts +16 -75
  67. package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +63 -258
  68. package/dist/components/InputNext/InputNext.vue.d.ts +14 -73
  69. package/dist/components/Modal/Modal.vue.d.ts +13 -72
  70. package/dist/components/ModalDialog/ModalDialog.vue.d.ts +58 -253
  71. package/dist/components/ModalNext/ModalNext.vue.d.ts +74 -328
  72. package/dist/components/ModalUpload/ModalUpload.vue.d.ts +114 -504
  73. package/dist/components/MultiSelect/MultiSelect.vue.d.ts +13 -72
  74. package/dist/components/Pagination/Pagination.vue.d.ts +44 -180
  75. package/dist/components/ProgressBar/ProgressBar.vue.d.ts +13 -72
  76. package/dist/components/SelectSmart/SelectSmart.vue.d.ts +83 -437
  77. package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +40 -217
  78. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +13 -72
  79. package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
  80. package/dist/components/SelectTime/index.vue.d.ts +16 -75
  81. package/dist/components/Slider/Slider.vue.d.ts +13 -72
  82. package/dist/components/StarRating/StarRating.vue.d.ts +13 -72
  83. package/dist/components/Switch/Switch.vue.d.ts +15 -74
  84. package/dist/components/Tab/Tab.vue.d.ts +13 -72
  85. package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
  86. package/dist/components/TableNext/TablePagination.vue.d.ts +44 -180
  87. package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +13 -72
  88. package/dist/components/Tag/BrandTag.vue.d.ts +13 -72
  89. package/dist/components/Tag/DefaultTag.vue.d.ts +13 -72
  90. package/dist/components/Tag/IndicatorTag.vue.d.ts +13 -72
  91. package/dist/components/Tag/Tag.vue.d.ts +40 -217
  92. package/dist/components/TextArea/TextArea.vue.d.ts +14 -73
  93. package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
  94. package/dist/components/Tour/Tour.vue.d.ts +44 -180
  95. package/dist/components/Tour/TourPopover.vue.d.ts +44 -180
  96. package/dist/components/UploadArea/UploadArea.vue.d.ts +57 -252
  97. package/dist/components/index.d.ts +13873 -7950
  98. package/dist/components/index.d.ts.map +1 -1
  99. package/dist/{es-a01fbef6.mjs → es-cc886436.mjs} +1 -1
  100. package/dist/{index-653c8f92.mjs → index-d36790a8.mjs} +5832 -5834
  101. package/dist/{pt-br-8c017501.mjs → pt-br-5f433748.mjs} +1 -1
  102. package/dist/style.css +1 -1
  103. package/dist/unnnic.mjs +177 -90
  104. package/dist/unnnic.umd.js +40 -40
  105. package/package.json +2 -2
  106. package/src/components/Button/Button.vue +99 -128
  107. package/src/components/Button/types.ts +23 -0
  108. package/src/components/ChatsMessage/ChatsMessage.vue +15 -0
  109. package/src/components/ChatsMessage/ChatsMessageText.vue +58 -4
  110. package/src/components/Checkbox/__tests__/Checkbox.spec.js +3 -3
  111. package/src/components/Disclaimer/Disclaimer.vue +27 -25
  112. package/src/components/Disclaimer/__tests__/Disclaimer.spec.js +24 -10
  113. package/src/components/Disclaimer/types.ts +7 -0
  114. package/src/components/Icon/types.ts +114 -0
  115. package/src/components/Icon.vue +44 -76
  116. package/src/components/Switch/__tests__/Switch.spec.js +9 -9
  117. package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +5 -5
  118. package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +9 -9
  119. package/src/components/__tests__/Icon.spec.js +32 -18
  120. package/src/components/index.ts +93 -0
  121. package/src/stories/ChatsMessage.stories.js +7 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weni/unnnic-system",
3
- "version": "3.2.1",
3
+ "version": "3.2.3",
4
4
  "type": "commonjs",
5
5
  "files": [
6
6
  "dist",
@@ -100,4 +100,4 @@
100
100
  "vue-eslint-parser": "^9.4.2",
101
101
  "vue-tsc": "^3.0.5"
102
102
  }
103
- }
103
+ }
@@ -30,7 +30,7 @@
30
30
  :size="iconSize"
31
31
  :filled="iconsFilled"
32
32
  :class="{ 'unnnic-button__icon-left': hasText }"
33
- :style="{ visibility: loading ? 'hidden' : null }"
33
+ :style="{ visibility: loading ? 'hidden' : 'visible' }"
34
34
  :next="next"
35
35
  data-testid="icon-left"
36
36
  />
@@ -39,7 +39,7 @@
39
39
  v-if="iconCenter"
40
40
  :icon="iconCenter"
41
41
  :scheme="iconScheme"
42
- :style="{ visibility: loading ? 'hidden' : null }"
42
+ :style="{ visibility: loading ? 'hidden' : 'visible' }"
43
43
  :size="iconSize"
44
44
  :filled="iconsFilled"
45
45
  :next="next"
@@ -49,7 +49,7 @@
49
49
  <span
50
50
  v-if="!float"
51
51
  class="unnnic-button__label"
52
- :style="{ visibility: loading ? 'hidden' : null }"
52
+ :style="{ visibility: loading ? 'hidden' : 'visible' }"
53
53
  data-testid="button-label"
54
54
  >
55
55
  <slot /> {{ text }}
@@ -62,145 +62,116 @@
62
62
  :size="iconSize"
63
63
  :filled="iconsFilled"
64
64
  :class="{ 'unnnic-button__icon-right': hasText }"
65
- :style="{ visibility: loading ? 'hidden' : null }"
65
+ :style="{ visibility: loading ? 'hidden' : 'visible' }"
66
66
  :next="next"
67
67
  data-testid="icon-right"
68
68
  />
69
69
  </button>
70
70
  </template>
71
71
 
72
- <script>
72
+ <script setup lang="ts">
73
+ import { computed, watch, useSlots } from 'vue';
73
74
  import UnnnicIcon from '../Icon.vue';
75
+ import type { ButtonProps, ButtonSize, ButtonType } from './types';
76
+ import type { SchemeColor } from '../Icon/types';
74
77
 
75
- export default {
78
+ defineOptions({
76
79
  name: 'UnnnicButton',
77
- components: {
78
- UnnnicIcon,
79
- },
80
- props: {
81
- size: {
82
- type: String,
83
- default: 'large',
84
- },
85
- text: {
86
- type: String,
87
- default: '',
88
- },
89
- type: {
90
- type: String,
91
- default: 'primary',
92
- },
93
- float: {
94
- type: Boolean,
95
- default: false,
96
- },
97
- iconLeft: {
98
- type: String,
99
- default: '',
100
- },
101
- iconRight: {
102
- type: String,
103
- default: '',
104
- },
105
- iconCenter: {
106
- type: String,
107
- default: '',
108
- },
109
- iconsFilled: {
110
- type: Boolean,
111
- default: false,
112
- },
113
- next: {
114
- type: Boolean,
115
- default: false,
116
- },
117
-
118
- disabled: {
119
- type: Boolean,
120
- default: false,
121
- },
122
-
123
- loading: {
124
- type: Boolean,
125
- default: false,
126
- },
127
- },
128
- computed: {
129
- buttonDisabled() {
130
- return this.disabled || this.loading;
131
- },
132
-
133
- iconSize() {
134
- if (this.size === 'small') return 'sm';
135
- return 'md';
136
- },
137
- hasText() {
138
- if (this.$slots.default) return true;
139
- return this.text && this.text.length > 0;
140
- },
141
- iconScheme() {
142
- if (this.buttonDisabled) {
143
- return 'neutral-clean';
144
- }
80
+ });
81
+
82
+ export type { ButtonProps, ButtonSize, ButtonType };
83
+
84
+ const props = withDefaults(defineProps<ButtonProps>(), {
85
+ size: 'large',
86
+ text: '',
87
+ type: 'primary',
88
+ float: false,
89
+ iconLeft: '',
90
+ iconRight: '',
91
+ iconCenter: '',
92
+ iconsFilled: false,
93
+ next: false,
94
+ disabled: false,
95
+ loading: false,
96
+ });
97
+
98
+ const slots = useSlots();
99
+
100
+ const buttonDisabled = computed(() => {
101
+ return props.disabled || props.loading;
102
+ });
103
+
104
+ const iconSize = computed(() => {
105
+ if (props.size === 'small') return 'sm';
106
+ return 'md';
107
+ });
108
+
109
+ const hasText = computed(() => {
110
+ if (slots.default) return true;
111
+ return props.text && props.text.length > 0;
112
+ });
113
+
114
+ const iconScheme = computed((): SchemeColor => {
115
+ if (buttonDisabled.value) {
116
+ return 'neutral-clean';
117
+ }
145
118
 
146
- const typeToSchemeMap = {
147
- primary: 'neutral-white',
148
- secondary: 'neutral-dark',
149
- tertiary: 'neutral-dark',
150
- warning: 'neutral-white',
151
- attention: 'neutral-white',
152
- };
153
-
154
- return typeToSchemeMap[this.type] || '';
155
- },
156
-
157
- isSizePropValid() {
158
- return (
159
- this.size === 'large' ||
160
- (!this.float && this.size === 'small') ||
161
- (this.float && this.size === 'extra-large')
162
- );
163
- },
164
- isTypePropValid() {
165
- const validTypes = [
166
- 'primary',
167
- 'secondary',
168
- 'tertiary',
169
- 'alternative',
170
- 'warning',
171
- 'attention',
172
- ];
173
- return validTypes.includes(this.type);
174
- },
175
- },
176
- watch: {
177
- $props: {
178
- deep: true,
179
- immediate: true,
180
- handler() {
181
- this.validateProps();
182
- },
183
- },
184
- },
185
- methods: {
186
- validateProps() {
187
- if (!this.isSizePropValid || !this.isTypePropValid) {
188
- let errorMessage = 'TypeError:';
119
+ const typeToSchemeMap: Record<ButtonType, SchemeColor> = {
120
+ primary: 'neutral-white',
121
+ secondary: 'neutral-dark',
122
+ tertiary: 'neutral-dark',
123
+ alternative: 'neutral-white',
124
+ warning: 'neutral-white',
125
+ attention: 'neutral-white',
126
+ };
127
+
128
+ return typeToSchemeMap[props.type] || 'neutral-white';
129
+ });
130
+
131
+ const isSizePropValid = computed(() => {
132
+ return (
133
+ props.size === 'large' ||
134
+ (!props.float && props.size === 'small') ||
135
+ (props.float && props.size === 'extra-large')
136
+ );
137
+ });
138
+
139
+ const isTypePropValid = computed(() => {
140
+ const validTypes: ButtonType[] = [
141
+ 'primary',
142
+ 'secondary',
143
+ 'tertiary',
144
+ 'alternative',
145
+ 'warning',
146
+ 'attention',
147
+ ];
148
+ return validTypes.includes(props.type);
149
+ });
150
+
151
+ const validateProps = () => {
152
+ if (!isSizePropValid.value || !isTypePropValid.value) {
153
+ let errorMessage = 'TypeError:';
154
+
155
+ if (!isSizePropValid.value) {
156
+ errorMessage += ' Invalid size prop.';
157
+ errorMessage += ` Please provide 'large', 'small' (only if float prop is false), or 'extra-large' (only if float prop is true).`;
158
+ }
189
159
 
190
- if (!this.isSizePropValid) {
191
- errorMessage += ' Invalid size prop.';
192
- errorMessage += ` Please provide 'large', 'small' (only if float prop is false), or 'extra-large' (only if float prop is true).`;
193
- }
160
+ if (!isTypePropValid.value) {
161
+ errorMessage += ' Invalid type prop.';
162
+ }
194
163
 
195
- if (!this.isTypePropValid) {
196
- errorMessage += ' Invalid type prop.';
197
- }
164
+ throw new Error(errorMessage);
165
+ }
166
+ };
198
167
 
199
- throw new Error(errorMessage);
200
- }
201
- },
168
+ watch(
169
+ () => props,
170
+ () => {
171
+ validateProps();
202
172
  },
203
- };
173
+ { deep: true, immediate: true }
174
+ );
204
175
  </script>
205
176
 
206
177
  <style lang="scss" scoped>
@@ -0,0 +1,23 @@
1
+ export type ButtonSize = 'small' | 'large' | 'extra-large';
2
+
3
+ export type ButtonType =
4
+ | 'primary'
5
+ | 'secondary'
6
+ | 'tertiary'
7
+ | 'alternative'
8
+ | 'warning'
9
+ | 'attention';
10
+
11
+ export interface ButtonProps {
12
+ size?: ButtonSize;
13
+ text?: string;
14
+ type?: ButtonType;
15
+ float?: boolean;
16
+ iconLeft?: string;
17
+ iconRight?: string;
18
+ iconCenter?: string;
19
+ iconsFilled?: boolean;
20
+ next?: boolean;
21
+ disabled?: boolean;
22
+ loading?: boolean;
23
+ }
@@ -3,6 +3,7 @@
3
3
  class="unnnic-chats-message"
4
4
  :class="{
5
5
  sent: type === 'sent',
6
+ automatic: automatic,
6
7
  sending: status === 'sending',
7
8
  'is-document': isDocument,
8
9
  'is-media': isMedia,
@@ -45,7 +46,9 @@
45
46
  />
46
47
  <UnnnicChatsMessageText
47
48
  v-if="isText"
49
+ :locale="locale"
48
50
  :text="slotText"
51
+ :isAutomatic="automatic"
49
52
  />
50
53
  <div
51
54
  v-if="isDocument"
@@ -156,6 +159,10 @@ export default {
156
159
  },
157
160
  mixins: [UnnnicI18n],
158
161
  props: {
162
+ locale: {
163
+ type: String,
164
+ default: 'en',
165
+ },
159
166
  enableReply: {
160
167
  type: Boolean,
161
168
  default: false,
@@ -171,6 +178,10 @@ export default {
171
178
  return ['received', 'sent'].includes(type);
172
179
  },
173
180
  },
181
+ automatic: {
182
+ type: Boolean,
183
+ default: false,
184
+ },
174
185
  time: {
175
186
  type: Date,
176
187
  required: true,
@@ -323,6 +334,10 @@ $defaultLineHeight: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
323
334
 
324
335
  &.sent {
325
336
  background-color: #cff8f4;
337
+
338
+ &.automatic {
339
+ background-color: $unnnic-color-aux-blue-50;
340
+ }
326
341
  }
327
342
 
328
343
  &.sending {
@@ -1,18 +1,45 @@
1
1
  <template>
2
- <p
3
- class="unnnic-chats-message__text"
4
- v-html="formattedText"
5
- />
2
+ <section class="unnnic-chats-message__text__container">
3
+ <p
4
+ class="unnnic-chats-message__text"
5
+ v-html="formattedText"
6
+ />
7
+ <p v-if="isAutomatic" class="unnnic-chats-message__text--automatic">
8
+ {{ i18n('automatic_message') }}
9
+ </p>
10
+ </section>
6
11
  </template>
7
12
 
8
13
  <script>
14
+ import UnnnicI18n from '../../mixins/i18n';
15
+
9
16
  export default {
10
17
  name: 'ChatsMessageText',
18
+ mixins: [UnnnicI18n],
11
19
  props: {
20
+ locale: {
21
+ type: String,
22
+ default: 'en',
23
+ },
12
24
  text: {
13
25
  type: String,
14
26
  required: true,
15
27
  },
28
+ isAutomatic: {
29
+ type: Boolean,
30
+ default: false,
31
+ },
32
+ },
33
+ data() {
34
+ return {
35
+ defaultTranslations: {
36
+ automatic_message: {
37
+ 'pt-br': 'Mensagem de abertura automática',
38
+ en: 'Automatic Opening Message',
39
+ es: 'Mensaje de apertura automático',
40
+ },
41
+ },
42
+ };
16
43
  },
17
44
  computed: {
18
45
  formattedText() {
@@ -78,3 +105,30 @@ export default {
78
105
  },
79
106
  };
80
107
  </script>
108
+
109
+ <style lang="scss" scoped>
110
+ @use '@/assets/scss/unnnic' as *;
111
+
112
+ * {
113
+ padding: 0;
114
+ margin: 0;
115
+ }
116
+
117
+ .unnnic-chats-message__text {
118
+ &__container {
119
+ display: flex;
120
+ flex-direction: column;
121
+ gap: $unnnic-spacing-sm;
122
+ padding: $unnnic-spacing-nano 0;
123
+ font-size: $unnnic-font-size-body-gt;
124
+ color: $unnnic-color-neutral-dark;
125
+ line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
126
+ word-break: break-word;
127
+ }
128
+ &--automatic {
129
+ font-size: $unnnic-font-size-body-md;
130
+ line-height: $unnnic-line-height-caption-1;
131
+ color: $unnnic-color-aux-blue-500;
132
+ }
133
+ }
134
+ </style>
@@ -24,7 +24,7 @@ describe('Checkbox', () => {
24
24
 
25
25
  it('should checkbox emit change events', async () => {
26
26
  wrapper = createWrapper();
27
- const checkbox = wrapper.findComponent({ name: 'Icon' });
27
+ const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
28
28
 
29
29
  // click false to true
30
30
  await checkbox.trigger('click');
@@ -44,14 +44,14 @@ describe('Checkbox', () => {
44
44
 
45
45
  it('should checkbox disabled', async () => {
46
46
  wrapper = createWrapper({ disabled: true });
47
- const checkbox = wrapper.findComponent({ name: 'Icon' });
47
+ const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
48
48
  await checkbox.trigger('click');
49
49
  expect(wrapper.emitted('change')).eq(undefined);
50
50
  });
51
51
 
52
52
  it('should define sizes', async () => {
53
53
  wrapper = createWrapper({ size: 'sm', textRight: 'Label' });
54
- const checkbox = wrapper.findComponent({ name: 'Icon' });
54
+ const checkbox = wrapper.findComponent({ name: 'UnnnicIcon' });
55
55
  const label = wrapper.find('.unnnic-checkbox__label');
56
56
 
57
57
  // sm
@@ -15,36 +15,38 @@
15
15
  </section>
16
16
  </template>
17
17
 
18
- <script>
18
+ <script setup lang="ts">
19
19
  import icons from '../../utils/iconList';
20
20
  import colors from '../../utils/colorsList';
21
+ import UnnnicIcon from '../Icon.vue';
22
+ import type { DisclaimerProps } from './types';
21
23
 
22
- import unnnicIcon from '../Icon.vue';
23
-
24
- export default {
24
+ defineOptions({
25
25
  name: 'UnnnicDisclaimer',
26
- components: { unnnicIcon },
27
- props: {
28
- text: {
29
- type: String,
30
- required: true,
31
- },
32
- icon: {
33
- type: String,
34
- default: 'alert-circle-1-1',
35
- validator(value) {
36
- return icons.includes(value);
37
- },
38
- },
39
- iconColor: {
40
- type: String,
41
- default: 'neutral-darkest',
42
- validator(value) {
43
- return colors.includes(value);
44
- },
45
- },
46
- },
26
+ });
27
+
28
+ export type { DisclaimerProps };
29
+
30
+ const props = withDefaults(defineProps<DisclaimerProps>(), {
31
+ icon: 'alert-circle-1-1',
32
+ iconColor: 'neutral-darkest',
33
+ });
34
+
35
+ const validateIcon = (value: string): boolean => {
36
+ return icons.includes(value);
37
+ };
38
+
39
+ const validateIconColor = (value: string): boolean => {
40
+ return colors.includes(value);
47
41
  };
42
+
43
+ if (!validateIcon(props.icon as string)) {
44
+ console.warn(`Invalid icon prop: ${props.icon}`);
45
+ }
46
+
47
+ if (!validateIconColor(props.iconColor as string)) {
48
+ console.warn(`Invalid iconColor prop: ${props.iconColor}`);
49
+ }
48
50
  </script>
49
51
 
50
52
  <style lang="scss" scoped>
@@ -38,21 +38,35 @@ describe('Disclaimer', () => {
38
38
  const iconComponent = wrapper.findComponent(
39
39
  '[data-testid="disclaimer-icon"]',
40
40
  );
41
- expect(iconComponent.props('icon')).toBe(Disclaimer.props.icon.default);
42
- expect(iconComponent.props('scheme')).toBe(
43
- Disclaimer.props.iconColor.default,
44
- );
41
+ expect(iconComponent.props('icon')).toBe('alert-circle-1-1');
42
+ expect(iconComponent.props('scheme')).toBe('neutral-darkest');
45
43
  });
46
44
 
47
45
  it('validates the icon prop correctly', () => {
48
- const validator = Disclaimer.props.icon.validator;
49
- expect(validator('alert-circle-1-1')).toBe(true);
50
- expect(validator('invalid-icon')).toBe(false);
46
+ const wrapperValid = mount(Disclaimer, {
47
+ props: { text: 'Test', icon: 'alert-circle-1-1' },
48
+ global: { components: { UnnnicIcon: Icon } },
49
+ });
50
+ expect(wrapperValid.exists()).toBe(true);
51
+
52
+ const wrapperInvalid = mount(Disclaimer, {
53
+ props: { text: 'Test', icon: 'invalid-icon' },
54
+ global: { components: { UnnnicIcon: Icon } },
55
+ });
56
+ expect(wrapperInvalid.exists()).toBe(true);
51
57
  });
52
58
 
53
59
  it('validates the iconColor prop correctly', () => {
54
- const validator = Disclaimer.props.iconColor.validator;
55
- expect(validator('neutral-darkest')).toBe(true);
56
- expect(validator('invalid-color')).toBe(false);
60
+ const wrapperValid = mount(Disclaimer, {
61
+ props: { text: 'Test', iconColor: 'neutral-darkest' },
62
+ global: { components: { UnnnicIcon: Icon } },
63
+ });
64
+ expect(wrapperValid.exists()).toBe(true);
65
+
66
+ const wrapperInvalid = mount(Disclaimer, {
67
+ props: { text: 'Test', iconColor: 'invalid-color' },
68
+ global: { components: { UnnnicIcon: Icon } },
69
+ });
70
+ expect(wrapperInvalid.exists()).toBe(true);
57
71
  });
58
72
  });
@@ -0,0 +1,7 @@
1
+ import type { SchemeColor } from '../Icon/types';
2
+
3
+ export interface DisclaimerProps {
4
+ text: string;
5
+ icon?: string;
6
+ iconColor?: SchemeColor;
7
+ }