@weni/unnnic-system 3.5.3-alpha.1 → 3.6.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.
- package/CHANGELOG.md +18 -1
- package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
- package/dist/components/Alert/Alert.vue.d.ts +117 -18
- package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
- package/dist/components/Alert/Version1dot1.vue.d.ts +38 -2
- package/dist/components/Alert/Version1dot1.vue.d.ts.map +1 -1
- package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +2 -2
- package/dist/components/AudioRecorder/AudioPlayer.vue.d.ts +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +5 -5
- package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +2 -2
- package/dist/components/Banner/Banner.vue.d.ts +1 -1
- package/dist/components/Banner/InfoBanner.vue.d.ts +1 -1
- package/dist/components/Breadcrumb/Breadcrumb.vue.d.ts +1 -1
- package/dist/components/Button/Button.vue.d.ts +1 -1
- package/dist/components/Button/Button.vue.d.ts.map +1 -1
- package/dist/components/Button/ButtonIcon.vue.d.ts +1 -1
- package/dist/components/Button/types.d.ts +1 -1
- package/dist/components/Button/types.d.ts.map +1 -1
- package/dist/components/Card/AccountCard.vue.d.ts +3 -3
- package/dist/components/Card/BlankCard.vue.d.ts +1 -1
- package/dist/components/Card/Card.vue.d.ts +21 -21
- package/dist/components/Card/CardCompany.vue.d.ts +8 -8
- package/dist/components/Card/CardData.vue.d.ts +1 -1
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +4 -4
- package/dist/components/Card/ContentCard.vue.d.ts +2 -2
- package/dist/components/Card/DashCard.vue.d.ts +4 -4
- package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
- package/dist/components/Card/MarketplaceCard.vue.d.ts +2 -2
- package/dist/components/Card/SimpleCard.vue.d.ts +3 -3
- package/dist/components/Card/StatusCard.vue.d.ts +2 -2
- package/dist/components/Card/TitleCard.vue.d.ts +2 -2
- package/dist/components/CardImage/CardImage.vue.d.ts +31 -24
- package/dist/components/CardInformation/CardInformation.vue.d.ts +4 -4
- package/dist/components/CardProject/CardProject.vue.d.ts +3 -3
- package/dist/components/Carousel/Carousel.vue.d.ts +11 -11
- package/dist/components/Carousel/TagCarousel.vue.d.ts +9 -9
- package/dist/components/ChartBar/ChartBar.vue.d.ts +5 -5
- package/dist/components/ChartLine/ChartLine.vue.d.ts +1 -1
- package/dist/components/ChatText/ChatText.vue.d.ts +2 -2
- package/dist/components/ChatsContact/ChatsContact.vue.d.ts +38 -31
- package/dist/components/ChatsDashboardTagLive/ChatsDashboardTagLive.vue.d.ts +1 -1
- package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts +1 -1
- package/dist/components/ChatsHeader/ChatsHeader.vue.d.ts.map +1 -1
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +5 -5
- package/dist/components/ChatsMessage/ChatsMessageStatusBackdrop.vue.d.ts +2 -2
- package/dist/components/ChatsNavbar/ChatsNavbar.vue.d.ts +1 -1
- package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +2 -2
- package/dist/components/Checkbox/Checkbox.vue.d.ts +26 -19
- package/dist/components/Checkbox/Checkbox.vue.d.ts.map +1 -1
- package/dist/components/Comment/Comment.vue.d.ts +1 -1
- package/dist/components/DataArea/DataArea.vue.d.ts +2 -2
- package/dist/components/DataTable/index.vue.d.ts +1 -1
- package/dist/components/DataTable/index.vue.d.ts.map +1 -1
- package/dist/components/DateFilter/DateFilter.vue.d.ts +29 -176
- package/dist/components/DatePicker/DatePicker.vue.d.ts +3 -3
- package/dist/components/Drawer/Drawer.vue.d.ts +4 -4
- package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
- package/dist/components/Dropdown/LanguageSelect.vue.d.ts +3 -3
- package/dist/components/Flag.vue.d.ts +2 -2
- package/dist/components/FormElement/FormElement.vue.d.ts +30 -38
- package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
- package/dist/components/Icon.vue.d.ts +1 -1
- package/dist/components/Icon.vue.d.ts.map +1 -1
- package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
- package/dist/components/ImportCard/ImportCard.vue.d.ts +4 -4
- package/dist/components/Input/BaseInput.vue.d.ts +1 -32
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +29 -176
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +14 -83
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +33 -180
- package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
- package/dist/components/Label/Label.vue.d.ts +15 -9
- package/dist/components/Label/Label.vue.d.ts.map +1 -1
- package/dist/components/Modal/Modal.vue.d.ts +2 -2
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +6 -6
- package/dist/components/ModalNext/ModalNext.vue.d.ts +34 -181
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +8 -8
- package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +14 -20
- package/dist/components/Pagination/Pagination.vue.d.ts +3 -3
- package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
- package/dist/components/Radio/Radio.vue.d.ts +6 -8
- package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +51 -113
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +8 -8
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +27 -20
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts.map +1 -1
- package/dist/components/SelectTime/index.vue.d.ts +14 -83
- package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +2 -2
- package/dist/components/Slider/Slider.vue.d.ts +2 -2
- package/dist/components/StarRating/StarRating.vue.d.ts +1 -1
- package/dist/components/Switch/Switch.vue.d.ts +21 -55
- package/dist/components/Switch/Switch.vue.d.ts.map +1 -1
- package/dist/components/Tab/Tab.vue.d.ts +2 -13
- package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
- package/dist/components/TableNext/TablePagination.vue.d.ts +3 -3
- package/dist/components/TabsExpanded/TabsExpanded.vue.d.ts +1 -1
- package/dist/components/Tag/BrandTag.vue.d.ts +2 -2
- package/dist/components/Tag/DefaultTag.vue.d.ts +2 -2
- package/dist/components/Tag/IndicatorTag.vue.d.ts +2 -2
- package/dist/components/Tag/Tag.vue.d.ts +8 -8
- package/dist/components/TextArea/TextArea.vue.d.ts +30 -38
- package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
- package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
- package/dist/components/Tour/Tour.vue.d.ts +3 -3
- package/dist/components/Tour/TourPopover.vue.d.ts +3 -3
- package/dist/components/UploadArea/UploadArea.vue.d.ts +4 -4
- package/dist/components/index.d.ts +1184 -2540
- package/dist/components/index.d.ts.map +1 -1
- package/dist/{es-1c7253d4.mjs → es-92fbe460.mjs} +1 -1
- package/dist/{index-ff0a404c.mjs → index-0da47957.mjs} +10936 -18388
- package/dist/locales/en.json.d.ts +1 -2
- package/dist/locales/es.json.d.ts +1 -2
- package/dist/locales/pt_br.json.d.ts +1 -2
- package/dist/{pt-br-316f1627.mjs → pt-br-c29b6c9a.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +148 -157
- package/dist/unnnic.umd.js +51 -53
- package/dist/utils/call.d.ts +1 -2
- package/dist/utils/call.d.ts.map +1 -1
- package/package.json +2 -4
- package/src/components/Alert/Alert.vue +135 -26
- package/src/components/Alert/AlertBanner.vue +182 -0
- package/src/components/Alert/AlertCaller.vue +49 -0
- package/src/components/Alert/Version1dot1.vue +36 -0
- package/src/components/Alert/__tests__/Alert.spec.js +45 -2
- package/src/components/Alert/__tests__/AlertBanner.spec.js +89 -0
- package/src/components/Alert/__tests__/AlertCaller.spec.js +98 -0
- package/src/components/Alert/__tests__/Version1dot1.spec.js +21 -0
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +7 -11
- package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
- package/src/components/Button/Button.vue +107 -64
- package/src/components/Button/types.ts +1 -0
- package/src/components/Checkbox/Checkbox.vue +64 -98
- package/src/components/Checkbox/__tests__/Checkbox.spec.js +21 -6
- package/src/components/FormElement/FormElement.vue +91 -51
- package/src/components/Icon.vue +1 -23
- package/src/components/Input/BaseInput.vue +14 -31
- package/src/components/Input/Input.scss +21 -19
- package/src/components/Input/Input.vue +30 -94
- package/src/components/Input/TextInput.vue +58 -82
- package/src/components/Input/__test__/TextInput.spec.js +5 -5
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +3 -16
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +1 -7
- package/src/components/Label/Label.vue +21 -52
- package/src/components/Label/__tests__/Label.spec.js +1 -1
- package/src/components/Label/__tests__/__snapshots__/Label.spec.js.snap +1 -1
- package/src/components/Radio/Radio.vue +67 -80
- package/src/components/Radio/__test__/Radio.spec.js +20 -14
- package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -3
- package/src/components/Switch/Switch.vue +97 -120
- package/src/components/Switch/__tests__/Switch.spec.js +75 -8
- package/src/components/Switch/__tests__/__snapshots__/Switch.spec.js.snap +6 -5
- package/src/components/Tab/Tab.vue +23 -37
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -1
- package/src/components/TableNext/__test__/__snapshots__/TableNext.spec.js.snap +2 -2
- package/src/components/TableNext/__test__/__snapshots__/TablePagination.spec.js.snap +2 -2
- package/src/components/TextArea/TextArea.vue +9 -13
- package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +2 -7
- package/src/components/index.ts +9 -30
- package/src/locales/en.json +1 -2
- package/src/locales/es.json +1 -2
- package/src/locales/pt_br.json +1 -2
- package/src/stories/Alert.stories.js +67 -6
- package/src/stories/Button.stories.js +17 -2
- package/src/stories/Checkbox.stories.js +4 -11
- package/src/stories/Icon.stories.js +15 -24
- package/src/stories/Input.stories.js +3 -16
- package/src/stories/Label.stories.js +0 -7
- package/src/stories/Switch.stories.js +5 -10
- package/src/stories/Tab.stories.js +4 -11
- package/src/types/scheme-colors.d.ts +0 -1
- package/src/utils/call.js +18 -46
- package/dist/assets/tokens/iconSizeTokens.d.ts +0 -2
- package/dist/assets/tokens/iconSizeTokens.d.ts.map +0 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts +0 -28
- package/dist/components/CheckboxGroup/CheckboxGroup.vue.d.ts.map +0 -1
- package/dist/components/Toast/Toast.vue.d.ts +0 -16
- package/dist/components/Toast/Toast.vue.d.ts.map +0 -1
- package/dist/components/Toast/ToastManager.d.ts +0 -14
- package/dist/components/Toast/ToastManager.d.ts.map +0 -1
- package/dist/components/Toast/types.d.ts +0 -35
- package/dist/components/Toast/types.d.ts.map +0 -1
- package/dist/components/ui/popover/Popover.vue.d.ts +0 -23
- package/dist/components/ui/popover/Popover.vue.d.ts.map +0 -1
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +0 -43
- package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +0 -1
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts +0 -19
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/popover/index.d.ts +0 -5
- package/dist/components/ui/popover/index.d.ts.map +0 -1
- package/src/assets/icons/checkbox-checked-disabled.svg +0 -3
- package/src/assets/icons/checkbox-checked.svg +0 -3
- package/src/assets/icons/checkbox-less-disabled.svg +0 -3
- package/src/assets/icons/checkbox-less.svg +0 -3
- package/src/assets/icons/radio-checked.svg +0 -3
- package/src/assets/icons/switch-checked-disabled.svg +0 -3
- package/src/assets/icons/switch-checked.svg +0 -3
- package/src/assets/tokens/iconSizeTokens.ts +0 -10
- package/src/components/CheckboxGroup/CheckboxGroup.vue +0 -96
- package/src/components/Popover/__tests__/Popover.spec.js +0 -147
- package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +0 -8
- package/src/components/Popover/index.vue +0 -146
- package/src/components/RadioGroup/RadioGroup.vue +0 -142
- package/src/components/Select/SelectOption.vue +0 -65
- package/src/components/Select/__tests__/Select.spec.js +0 -412
- package/src/components/Select/__tests__/SelectItem.spec.js +0 -330
- package/src/components/Select/__tests__/SelectOption.spec.js +0 -174
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +0 -97
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +0 -15
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +0 -25
- package/src/components/Select/index.vue +0 -245
- package/src/components/Toast/Toast.vue +0 -246
- package/src/components/Toast/ToastManager.ts +0 -110
- package/src/components/Toast/__tests__/Toast.spec.js +0 -284
- package/src/components/Toast/__tests__/ToastManager.spec.js +0 -294
- package/src/components/Toast/types.ts +0 -57
- package/src/components/ui/popover/Popover.vue +0 -19
- package/src/components/ui/popover/PopoverContent.vue +0 -98
- package/src/components/ui/popover/PopoverTrigger.vue +0 -23
- package/src/components/ui/popover/index.ts +0 -4
- package/src/stories/CheckboxGroup.stories.js +0 -105
- package/src/stories/Popover.stories.js +0 -306
- package/src/stories/RadioGroup.stories.js +0 -144
- package/src/stories/Select.stories.js +0 -158
- package/src/stories/Toast.mdx +0 -123
- package/src/stories/Toast.stories.js +0 -126
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
<!-- eslint-disable vue/multi-word-component-names -->
|
|
2
2
|
<template>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<slot />
|
|
23
|
-
</p>
|
|
24
|
-
</label>
|
|
25
|
-
</section>
|
|
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>
|
|
26
22
|
</template>
|
|
27
23
|
|
|
28
24
|
<script setup>
|
|
29
|
-
import {
|
|
30
|
-
import
|
|
25
|
+
import { computed } from 'vue';
|
|
26
|
+
import UnnnicIcon from '../Icon.vue';
|
|
31
27
|
|
|
32
28
|
const props = defineProps({
|
|
33
29
|
modelValue: {
|
|
@@ -42,88 +38,79 @@ const props = defineProps({
|
|
|
42
38
|
type: Boolean,
|
|
43
39
|
default: false,
|
|
44
40
|
},
|
|
45
|
-
|
|
41
|
+
size: {
|
|
46
42
|
type: String,
|
|
47
|
-
default: '',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
default: '',
|
|
43
|
+
default: 'md',
|
|
44
|
+
validator(value) {
|
|
45
|
+
return ['md', 'sm'].includes(value);
|
|
46
|
+
},
|
|
52
47
|
},
|
|
53
48
|
});
|
|
54
49
|
|
|
55
50
|
const emit = defineEmits(['update:modelValue']);
|
|
56
51
|
|
|
57
|
-
const
|
|
58
|
-
|
|
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
|
+
});
|
|
59
69
|
|
|
60
70
|
function click() {
|
|
61
71
|
if (!props.disabled) {
|
|
62
72
|
emit('update:modelValue', props.value);
|
|
63
|
-
|
|
64
|
-
if (contextModelValue) {
|
|
65
|
-
contextModelValue.value = props.value;
|
|
66
|
-
}
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
const computedModelValue = computed(() => {
|
|
71
|
-
return contextModelValue?.value || props.modelValue;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const computedName = computed(() => {
|
|
75
|
-
return contextName?.value || props.name;
|
|
76
|
-
});
|
|
77
75
|
</script>
|
|
78
76
|
|
|
79
77
|
<style lang="scss" scoped>
|
|
80
78
|
@use '@/assets/scss/unnnic' as *;
|
|
81
79
|
|
|
82
|
-
$radio-size: 21px;
|
|
83
|
-
|
|
84
80
|
.unnnic-radio-container {
|
|
85
81
|
display: inline-flex;
|
|
86
|
-
|
|
82
|
+
align-items: center;
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
align-items: center;
|
|
91
|
-
gap: $unnnic-space-2;
|
|
84
|
+
&:not(.disabled) {
|
|
85
|
+
cursor: pointer;
|
|
92
86
|
}
|
|
93
87
|
|
|
94
|
-
.unnnic-radio {
|
|
95
|
-
|
|
96
|
-
|
|
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;
|
|
88
|
+
&--sm .unnnic-radio {
|
|
89
|
+
margin: $unnnic-spacing-stack-nano $unnnic-spacing-inline-nano;
|
|
90
|
+
}
|
|
104
91
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
background-repeat: no-repeat;
|
|
111
|
-
}
|
|
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
|
+
}
|
|
112
97
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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;
|
|
117
104
|
}
|
|
118
105
|
|
|
119
|
-
.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
106
|
+
&--sm .label {
|
|
107
|
+
font-size: $unnnic-font-size-body-md;
|
|
108
|
+
line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
|
|
109
|
+
}
|
|
123
110
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
&--md .label {
|
|
112
|
+
font-size: $unnnic-font-size-body-gt;
|
|
113
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
|
|
127
114
|
}
|
|
128
115
|
}
|
|
129
116
|
</style>
|
|
@@ -33,35 +33,41 @@ describe('Radio.vue', () => {
|
|
|
33
33
|
expect(wrapper.exists()).toBe(true);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
test('renders
|
|
37
|
-
const
|
|
38
|
-
expect(
|
|
39
|
-
expect(
|
|
40
|
-
expect(
|
|
41
|
-
expect(
|
|
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');
|
|
42
49
|
});
|
|
43
50
|
|
|
44
51
|
test('applies disabled class when disabled prop is true', async () => {
|
|
45
52
|
await wrapper.setProps({ disabled: true });
|
|
46
|
-
expect(wrapper.
|
|
47
|
-
'unnnic-radio__label--disabled',
|
|
48
|
-
);
|
|
53
|
+
expect(wrapper.classes()).toContain('disabled');
|
|
49
54
|
});
|
|
50
55
|
|
|
51
56
|
test('icon changes based on valueName', async () => {
|
|
52
57
|
await wrapper.setProps({ modelValue: 'option1' });
|
|
53
|
-
const
|
|
54
|
-
expect(
|
|
58
|
+
const unnnicIcon = wrapper.findComponent(UnnnicIcon);
|
|
59
|
+
expect(unnnicIcon.props('icon')).toBe('radio-selected');
|
|
55
60
|
});
|
|
56
61
|
|
|
57
62
|
test('icon and color change when disabled is true', async () => {
|
|
58
63
|
await wrapper.setProps({ disabled: true });
|
|
59
|
-
const
|
|
60
|
-
expect(
|
|
64
|
+
const unnnicIcon = wrapper.findComponent(UnnnicIcon);
|
|
65
|
+
expect(unnnicIcon.props('icon')).toBe('radio-disable');
|
|
66
|
+
expect(unnnicIcon.props('scheme')).toBe('brand-sec');
|
|
61
67
|
});
|
|
62
68
|
|
|
63
69
|
test('emits update:modelValue with correct value when clicked and not disabled', async () => {
|
|
64
|
-
await wrapper.
|
|
70
|
+
await wrapper.trigger('click');
|
|
65
71
|
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
66
72
|
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['option1']);
|
|
67
73
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
3
|
exports[`Radio.vue > matches the snapshot 1`] = `
|
|
4
|
-
"<
|
|
5
|
-
<
|
|
6
|
-
</label></
|
|
4
|
+
"<div data-v-38c6bf5e="" class="unnnic-radio-container unnnic-radio-container--md"><svg data-v-26446d8e="" data-v-38c6bf5e="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon--size-svg-md unnnic-icon__size--md unnnic-icon-scheme--neutral-cleanest unnnic-radio" data-testid="custom-icon">
|
|
5
|
+
<circle cx="20" cy="20.0005" r="14.5" stroke="#3B414D" class="primary-stroke"></circle>
|
|
6
|
+
</svg><span data-v-38c6bf5e="" class="label">Option 1</span></div>"
|
|
7
7
|
`;
|
|
@@ -1,55 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
v-if="
|
|
5
|
-
|
|
6
|
-
:
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<div class="unnnic-switch">
|
|
3
|
+
<div
|
|
4
|
+
v-if="textLeft"
|
|
5
|
+
data-test-id="switch-text-left"
|
|
6
|
+
:class="[
|
|
7
|
+
'unnnic-switch__label',
|
|
8
|
+
'unnnic-switch__label__left',
|
|
9
|
+
`unnnic-switch__label__${size}`,
|
|
10
|
+
]"
|
|
11
|
+
>
|
|
12
|
+
{{ textLeft }}
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<UnnnicIcon
|
|
16
|
+
:class="{ 'unnnic-switch__icon': true, active: isActive }"
|
|
17
|
+
:icon="currentIcon"
|
|
18
|
+
:size="iconSize"
|
|
19
|
+
:scheme="iconScheme"
|
|
20
|
+
:lineHeight="iconLineHeight"
|
|
21
|
+
:disabled="disabled"
|
|
22
|
+
:clickable="!disabled"
|
|
23
|
+
data-test-id="switch-icon"
|
|
24
|
+
@click="toggleState"
|
|
9
25
|
/>
|
|
10
26
|
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/>
|
|
20
|
-
|
|
21
|
-
<p
|
|
22
|
-
v-if="option || textLeft || textRight"
|
|
23
|
-
:class="[
|
|
24
|
-
'unnnic-switch__option',
|
|
25
|
-
{ 'unnnic-switch__option--disabled': disabled },
|
|
26
|
-
]"
|
|
27
|
-
data-testid="switch-option"
|
|
28
|
-
>
|
|
29
|
-
{{ option }}
|
|
30
|
-
{{ textLeft }}
|
|
31
|
-
{{ textRight }}
|
|
32
|
-
</p>
|
|
33
|
-
</label>
|
|
34
|
-
|
|
35
|
-
<p
|
|
36
|
-
v-if="helper"
|
|
37
|
-
class="unnnic-switch__helper"
|
|
27
|
+
<div
|
|
28
|
+
v-if="textRight"
|
|
29
|
+
data-test-id="switch-text-right"
|
|
30
|
+
:class="[
|
|
31
|
+
'unnnic-switch__label',
|
|
32
|
+
'unnnic-switch__label__right',
|
|
33
|
+
`unnnic-switch__label__${size}`,
|
|
34
|
+
]"
|
|
38
35
|
>
|
|
39
|
-
{{
|
|
40
|
-
</
|
|
41
|
-
</
|
|
36
|
+
{{ textRight }}
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
42
39
|
</template>
|
|
43
40
|
|
|
44
41
|
<script>
|
|
45
|
-
import
|
|
46
|
-
import UnnnicLabel from '../Label/Label.vue';
|
|
42
|
+
import UnnnicIcon from '../Icon.vue';
|
|
47
43
|
|
|
48
44
|
export default {
|
|
49
45
|
name: 'UnnnicSwitch',
|
|
50
|
-
components: {
|
|
51
|
-
UnnnicLabel,
|
|
52
|
-
},
|
|
46
|
+
components: { UnnnicIcon },
|
|
53
47
|
props: {
|
|
54
48
|
size: {
|
|
55
49
|
type: String,
|
|
@@ -58,32 +52,6 @@ export default {
|
|
|
58
52
|
return ['small', 'medium'].indexOf(value) !== -1;
|
|
59
53
|
},
|
|
60
54
|
},
|
|
61
|
-
|
|
62
|
-
label: {
|
|
63
|
-
type: String,
|
|
64
|
-
default: '',
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
labelTooltip: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: '',
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
labelUseHtmlTooltip: {
|
|
73
|
-
type: Boolean,
|
|
74
|
-
default: false,
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
option: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: '',
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
helper: {
|
|
83
|
-
type: String,
|
|
84
|
-
default: '',
|
|
85
|
-
},
|
|
86
|
-
|
|
87
55
|
textLeft: {
|
|
88
56
|
type: String,
|
|
89
57
|
default: '',
|
|
@@ -110,6 +78,33 @@ export default {
|
|
|
110
78
|
isActive: false,
|
|
111
79
|
};
|
|
112
80
|
},
|
|
81
|
+
computed: {
|
|
82
|
+
currentIcon() {
|
|
83
|
+
if (this.disabled) {
|
|
84
|
+
return this.isActive
|
|
85
|
+
? 'switch-selected-disabled'
|
|
86
|
+
: 'switch-default-disabled';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return 'switch-default';
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
iconSize() {
|
|
93
|
+
return this.size === 'small' ? 'sm' : 'md';
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
iconScheme() {
|
|
97
|
+
if (this.disabled) {
|
|
98
|
+
return 'neutral-soft';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this.isActive === false ? 'neutral-soft' : 'brand-weni';
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
iconLineHeight() {
|
|
105
|
+
return this.size === 'small' ? 'sm' : '';
|
|
106
|
+
},
|
|
107
|
+
},
|
|
113
108
|
|
|
114
109
|
watch: {
|
|
115
110
|
modelValue: {
|
|
@@ -121,8 +116,6 @@ export default {
|
|
|
121
116
|
},
|
|
122
117
|
|
|
123
118
|
methods: {
|
|
124
|
-
pick,
|
|
125
|
-
|
|
126
119
|
toggleState() {
|
|
127
120
|
if (!this.disabled) {
|
|
128
121
|
if (this.useVModel) {
|
|
@@ -140,67 +133,51 @@ export default {
|
|
|
140
133
|
<style lang="scss" scoped>
|
|
141
134
|
@use '@/assets/scss/unnnic' as *;
|
|
142
135
|
|
|
143
|
-
|
|
144
|
-
$switch-height: 20px;
|
|
145
|
-
|
|
146
|
-
.unnnic-switch-wrapper {
|
|
136
|
+
.unnnic-switch {
|
|
147
137
|
display: flex;
|
|
148
|
-
flex-direction:
|
|
138
|
+
flex-direction: row;
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
}
|
|
140
|
+
&__label {
|
|
141
|
+
font-family: $unnnic-font-family-secondary;
|
|
142
|
+
font-weight: $unnnic-font-weight-regular;
|
|
143
|
+
color: $unnnic-color-neutral-dark;
|
|
156
144
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
width: $switch-width;
|
|
160
|
-
height: $switch-height;
|
|
161
|
-
margin: 0;
|
|
162
|
-
background-color: $unnnic-color-bg-muted;
|
|
163
|
-
border-radius: $unnnic-radius-3;
|
|
164
|
-
box-sizing: border-box;
|
|
165
|
-
outline: none;
|
|
166
|
-
|
|
167
|
-
background-image: url('@/assets/icons/switch-checked.svg');
|
|
168
|
-
background-repeat: no-repeat;
|
|
169
|
-
background-position: 4px center;
|
|
170
|
-
|
|
171
|
-
transition:
|
|
172
|
-
200ms linear background-position,
|
|
173
|
-
200ms linear background-color;
|
|
174
|
-
|
|
175
|
-
&:checked {
|
|
176
|
-
background-color: $unnnic-color-bg-active;
|
|
177
|
-
background-position: 20px center;
|
|
178
|
-
}
|
|
145
|
+
margin: $unnnic-spacing-stack-nano 0;
|
|
146
|
+
margin-right: $unnnic-inline-nano;
|
|
179
147
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
148
|
+
&__small {
|
|
149
|
+
font-size: $unnnic-font-size-body-md;
|
|
150
|
+
line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
|
|
151
|
+
}
|
|
184
152
|
|
|
185
|
-
|
|
186
|
-
|
|
153
|
+
&__medium {
|
|
154
|
+
font-size: $unnnic-font-size-body-gt;
|
|
155
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-md;
|
|
156
|
+
}
|
|
187
157
|
}
|
|
188
158
|
|
|
189
|
-
&
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
159
|
+
&__icon {
|
|
160
|
+
align-self: center;
|
|
161
|
+
margin: $unnnic-spacing-stack-nano $unnnic-inline-nano;
|
|
162
|
+
|
|
163
|
+
:deep(#default-circle) {
|
|
164
|
+
transition: 0.2s linear transform;
|
|
165
|
+
}
|
|
193
166
|
|
|
194
|
-
|
|
195
|
-
|
|
167
|
+
&.active {
|
|
168
|
+
:deep(#default-circle) {
|
|
169
|
+
transform: translateX(45%);
|
|
170
|
+
}
|
|
196
171
|
}
|
|
197
172
|
}
|
|
173
|
+
}
|
|
198
174
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
175
|
+
.unnnic-icon__size {
|
|
176
|
+
&--md {
|
|
177
|
+
width: 3 * $unnnic-font-size;
|
|
178
|
+
}
|
|
179
|
+
&--sm {
|
|
180
|
+
width: 2 * $unnnic-font-size;
|
|
204
181
|
}
|
|
205
182
|
}
|
|
206
183
|
</style>
|
|
@@ -12,26 +12,93 @@ describe('Switch', () => {
|
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
wrapper = createWrapper({ modelValue: false });
|
|
14
14
|
});
|
|
15
|
+
it('should render the component correctly with default props', () => {
|
|
16
|
+
expect(wrapper.exists()).toBe(true);
|
|
17
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).exists()).toBe(true);
|
|
18
|
+
expect(wrapper.text()).toBe('');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should render the left text (textLeft) when provided', async () => {
|
|
22
|
+
await wrapper.setProps({ textLeft: 'Left Text' });
|
|
23
|
+
|
|
24
|
+
// This check ensures that the icon is placed before the switch text
|
|
25
|
+
const switchChildren = wrapper.findComponent(Switch).element.children;
|
|
26
|
+
expect(switchChildren[0].getAttribute('data-test-id')).toBe(
|
|
27
|
+
'switch-text-left',
|
|
28
|
+
);
|
|
29
|
+
expect(switchChildren[1].getAttribute('data-test-id')).toBe('switch-icon');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render the right text (textRight) when provided', async () => {
|
|
33
|
+
await wrapper.setProps({ textRight: 'Right Text' });
|
|
34
|
+
|
|
35
|
+
// This check ensures that the icon is placed after the switch text
|
|
36
|
+
const switchChildren = wrapper.findComponent(Switch).element.children;
|
|
37
|
+
expect(switchChildren[0].getAttribute('data-test-id')).toBe('switch-icon');
|
|
38
|
+
expect(switchChildren[1].getAttribute('data-test-id')).toBe(
|
|
39
|
+
'switch-text-right',
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should render the correct icon when the switch is disabled/enabled', async () => {
|
|
44
|
+
await wrapper.setProps({ disabled: true });
|
|
45
|
+
const disabledIconComponent = wrapper.findComponent({ name: 'UnnnicIcon' });
|
|
46
|
+
expect(disabledIconComponent.props('icon')).toBe('switch-default-disabled');
|
|
15
47
|
|
|
16
|
-
|
|
17
|
-
|
|
48
|
+
await wrapper.setProps({ modelValue: true });
|
|
49
|
+
const enabledIconComponent = wrapper.findComponent({ name: 'UnnnicIcon' });
|
|
50
|
+
expect(enabledIconComponent.props('icon')).toBe('switch-selected-disabled');
|
|
51
|
+
});
|
|
18
52
|
|
|
19
|
-
|
|
20
|
-
expect(
|
|
53
|
+
it('should render the correct icon based on the isActive state', async () => {
|
|
54
|
+
expect(wrapper.vm.isActive).toBe(false);
|
|
55
|
+
await wrapper.setProps({ modelValue: true });
|
|
56
|
+
expect(wrapper.vm.isActive).toBe(true);
|
|
57
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('icon')).toBe(
|
|
58
|
+
'switch-default',
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should render the correct icon size based on the size prop', async () => {
|
|
63
|
+
await wrapper.setProps({ size: 'small' });
|
|
64
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('size')).toBe(
|
|
65
|
+
'sm',
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
await wrapper.setProps({ size: 'medium' });
|
|
69
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('size')).toBe(
|
|
70
|
+
'md',
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should change the icon color based on the state', async () => {
|
|
75
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('scheme')).toBe(
|
|
76
|
+
'neutral-soft',
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await wrapper.setProps({ modelValue: true });
|
|
80
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('scheme')).toBe(
|
|
81
|
+
'brand-weni',
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
await wrapper.setProps({ disabled: true });
|
|
85
|
+
expect(wrapper.findComponent({ name: 'UnnnicIcon' }).props('scheme')).toBe(
|
|
86
|
+
'neutral-soft',
|
|
87
|
+
);
|
|
21
88
|
});
|
|
22
89
|
|
|
23
90
|
it('should toggle isActive state and emit the correct event when toggleState is called', async () => {
|
|
24
91
|
const initialIsActive = wrapper.vm.isActive;
|
|
25
|
-
const
|
|
26
|
-
await
|
|
92
|
+
const switchIcon = wrapper.findComponent('[ data-test-id="switch-icon"]');
|
|
93
|
+
await switchIcon.trigger('click');
|
|
27
94
|
expect(wrapper.emitted('update:model-value')).toBeTruthy();
|
|
28
95
|
expect(wrapper.vm.isActive).toBe(!initialIsActive);
|
|
29
96
|
});
|
|
30
97
|
|
|
31
98
|
it('should not change state when disabled is true', async () => {
|
|
32
99
|
await wrapper.setProps({ disabled: true });
|
|
33
|
-
const
|
|
34
|
-
await
|
|
100
|
+
const switchIcon = wrapper.findComponent('[ data-test-id="switch-icon"]');
|
|
101
|
+
await switchIcon.trigger('click');
|
|
35
102
|
expect(wrapper.emitted('update:model-value')).toBeFalsy();
|
|
36
103
|
expect(wrapper.vm.isActive).toBe(false);
|
|
37
104
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
3
|
exports[`Switch > should match the snapshot 1`] = `
|
|
4
|
-
"<
|
|
5
|
-
<!--v-if--><
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
"<div data-v-e4356c9d="" class="unnnic-switch">
|
|
5
|
+
<!--v-if--><svg data-v-3d58a7dd="" data-v-26446d8e="" data-v-e4356c9d="" id="default" width="80" height="40" viewBox="0 0 80 40" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon--size-svg-md unnnic-icon__size--md unnnic--clickable unnnic-icon-scheme--neutral-soft unnnic-switch__icon" data-testid="custom-icon" lineHeight="" disabled="false" data-test-id="switch-icon">
|
|
6
|
+
<rect data-v-3d58a7dd="" x="4.20013" y="2.10046" width="71.6" height="35.8" rx="17.9" class="primary"></rect>
|
|
7
|
+
<circle data-v-3d58a7dd="" id="default-circle" cx="22.5" cy="20.0005" r="12.5" fill="white"></circle>
|
|
8
|
+
</svg>
|
|
8
9
|
<!--v-if-->
|
|
9
|
-
</
|
|
10
|
+
</div>"
|
|
10
11
|
`;
|