@weni/unnnic-system 3.2.9 → 3.3.1-alpha.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 +13 -0
- package/dist/components/Accordion/Accordion.vue.d.ts +1 -1
- package/dist/components/Alert/Alert.vue.d.ts +18 -119
- package/dist/components/Alert/Alert.vue.d.ts.map +1 -1
- package/dist/components/Alert/Version1dot1.vue.d.ts +2 -38
- 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 +2 -2
- 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 +8 -8
- 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 +8 -8
- package/dist/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue.d.ts.map +1 -1
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts +43 -0
- package/dist/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue.d.ts.map +1 -0
- 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 +15 -15
- 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 +3 -3
- 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 +8 -1
- package/dist/components/DataTable/index.vue.d.ts.map +1 -1
- package/dist/components/DateFilter/DateFilter.vue.d.ts +176 -29
- package/dist/components/DatePicker/DatePicker.vue.d.ts +8 -8
- package/dist/components/Drawer/Drawer.vue.d.ts +7 -7
- 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 +38 -32
- package/dist/components/FormElement/FormElement.vue.d.ts.map +1 -1
- package/dist/components/Icon.vue.d.ts +1 -1
- package/dist/components/IconLoading/IconLoading.vue.d.ts +1 -1
- package/dist/components/ImportCard/ImportCard.vue.d.ts +7 -7
- package/dist/components/Input/BaseInput.vue.d.ts +32 -1
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +176 -29
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +83 -14
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputDatePicker/InputDatePicker.vue.d.ts +186 -39
- package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
- package/dist/components/Label/Label.vue.d.ts +9 -15
- 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 +9 -9
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +184 -37
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +14 -14
- package/dist/components/MoodRating/MoodRating.vue.d.ts +1 -1
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +20 -14
- package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
- package/dist/components/ProgressBar/ProgressBar.vue.d.ts +1 -1
- package/dist/components/Radio/Radio.vue.d.ts +8 -6
- package/dist/components/Radio/Radio.vue.d.ts.map +1 -1
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +97 -28
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +8 -8
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +4 -4
- package/dist/components/SelectTime/index.vue.d.ts +83 -14
- package/dist/components/SkeletonLoading/skeletonTheme.vue.d.ts +1 -1
- 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 +2 -2
- package/dist/components/Tab/Tab.vue.d.ts +13 -2
- package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
- package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
- 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/TemplatePreview/TemplatePreview.vue.d.ts +9 -0
- package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -0
- package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts +15 -0
- package/dist/components/TemplatePreview/TemplatePreviewModal.vue.d.ts.map +1 -0
- package/dist/components/TextArea/TextArea.vue.d.ts +38 -32
- package/dist/components/TextArea/TextArea.vue.d.ts.map +1 -1
- package/dist/components/Toast/Toast.vue.d.ts +16 -0
- package/dist/components/Toast/Toast.vue.d.ts.map +1 -0
- package/dist/components/Toast/ToastManager.d.ts +14 -0
- package/dist/components/Toast/ToastManager.d.ts.map +1 -0
- package/dist/components/Toast/types.d.ts +35 -0
- package/dist/components/Toast/types.d.ts.map +1 -0
- package/dist/components/ToolTip/ToolTip.vue.d.ts +1 -1
- package/dist/components/Tour/Tour.vue.d.ts +6 -6
- package/dist/components/Tour/TourPopover.vue.d.ts +6 -6
- package/dist/components/UploadArea/UploadArea.vue.d.ts +7 -7
- package/dist/components/index.d.ts +2136 -1114
- package/dist/components/index.d.ts.map +1 -1
- package/dist/{es-1ca6f2cf.mjs → es-94ab560e.mjs} +1 -1
- package/dist/{index-ca7d12b1.mjs → index-5caf403e.mjs} +8860 -8453
- package/dist/locales/en.json.d.ts +2 -1
- package/dist/locales/es.json.d.ts +2 -1
- package/dist/locales/pt_br.json.d.ts +2 -1
- package/dist/{pt-br-2d5000b1.mjs → pt-br-3002df05.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +126 -120
- package/dist/unnnic.umd.js +42 -41
- package/dist/utils/call.d.ts +2 -1
- package/dist/utils/call.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/assets/icons/radio-checked.svg +3 -0
- package/src/assets/img/previews/doc-preview.png +0 -0
- package/src/assets/img/previews/image-preview.png +0 -0
- package/src/assets/img/previews/video-preview.png +0 -0
- package/src/assets/scss/scheme-colors.scss +115 -111
- package/src/assets/tokens/colors.json +2 -2
- package/src/components/Alert/Alert.vue +26 -135
- package/src/components/Alert/Version1dot1.vue +0 -36
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +11 -7
- package/src/components/Alert/__tests__/__snapshots__/Version1dot1.spec.js.snap +2 -2
- package/src/components/Button/Button.vue +60 -108
- package/src/components/Button/types.ts +0 -1
- package/src/components/ChartFunnel/ChartFunnel.vue +4 -0
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +8 -2
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelBaseRow.vue +1 -1
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +64 -0
- package/src/components/DataTable/index.vue +25 -10
- package/src/components/FormElement/FormElement.vue +51 -91
- package/src/components/Input/BaseInput.vue +31 -14
- package/src/components/Input/Input.scss +19 -21
- package/src/components/Input/Input.vue +94 -30
- package/src/components/Input/TextInput.vue +82 -58
- package/src/components/Input/__test__/TextInput.spec.js +5 -5
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +16 -3
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
- package/src/components/Label/Label.vue +52 -21
- 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/ModalDialog/ModalDialog.vue +1 -0
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -1
- package/src/components/Popover/__tests__/Popover.spec.js +147 -0
- package/src/components/Popover/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
- package/src/components/Popover/index.vue +146 -0
- package/src/components/Radio/Radio.vue +80 -67
- package/src/components/Radio/__test__/Radio.spec.js +14 -20
- package/src/components/Radio/__test__/__snapshots__/Radio.spec.js.snap +3 -3
- package/src/components/RadioGroup/RadioGroup.vue +110 -0
- package/src/components/Select/SelectOption.vue +65 -0
- package/src/components/Select/__tests__/Select.spec.js +412 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
- package/src/components/Select/__tests__/SelectOption.spec.js +174 -0
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +97 -0
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +15 -0
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +25 -0
- package/src/components/Select/index.vue +245 -0
- package/src/components/Tab/Tab.vue +37 -23
- 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/TemplatePreview/TemplatePreview.vue +252 -0
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +51 -0
- package/src/components/TemplatePreview/types.d.ts +16 -0
- package/src/components/TextArea/TextArea.vue +13 -9
- package/src/components/TextArea/__test__/__snapshots__/TextArea.spec.js.snap +7 -2
- package/src/components/Toast/Toast.vue +236 -0
- package/src/components/Toast/ToastManager.ts +110 -0
- package/src/components/Toast/types.ts +57 -0
- package/src/components/index.ts +18 -4
- package/src/locales/en.json +2 -1
- package/src/locales/es.json +2 -1
- package/src/locales/pt_br.json +2 -1
- package/src/stories/Alert.stories.js +6 -67
- package/src/stories/Button.stories.js +2 -17
- package/src/stories/ChartFunnel.stories.js +19 -0
- package/src/stories/DataTable.stories.js +60 -0
- package/src/stories/Input.stories.js +22 -3
- package/src/stories/Label.stories.js +7 -0
- package/src/stories/Popover.stories.js +39 -0
- package/src/stories/RadioGroup.stories.js +139 -0
- package/src/stories/Select.stories.js +158 -0
- package/src/stories/Tab.stories.js +11 -4
- package/src/stories/TemplatePreview.stories.js +94 -0
- package/src/stories/TemplatePreviewModal.stories.js +110 -0
- package/src/stories/Toast.mdx +123 -0
- package/src/stories/Toast.stories.js +126 -0
- package/src/types/scheme-colors.d.ts +120 -14
- package/src/utils/call.js +46 -18
- package/src/components/Alert/AlertBanner.vue +0 -182
- package/src/components/Alert/AlertCaller.vue +0 -49
- package/src/components/Alert/__tests__/AlertBanner.spec.js +0 -89
- package/src/components/Alert/__tests__/AlertCaller.spec.js +0 -98
|
@@ -0,0 +1,245 @@
|
|
|
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
|
+
});
|
|
100
|
+
|
|
101
|
+
const emit = defineEmits<{
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
'update:modelValue': [value: any];
|
|
104
|
+
'update:search': [value: string];
|
|
105
|
+
}>();
|
|
106
|
+
|
|
107
|
+
const openPopover = ref(false);
|
|
108
|
+
|
|
109
|
+
watch(openPopover, () => {
|
|
110
|
+
if (!openPopover.value) {
|
|
111
|
+
handleSearch('');
|
|
112
|
+
} else {
|
|
113
|
+
focusedOptionIndex.value = -1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (openPopover.value && props.modelValue) {
|
|
117
|
+
const selectedOptionIndex = props.options.findIndex(
|
|
118
|
+
(option) =>
|
|
119
|
+
option[props.itemValue] === selectedItem.value[props.itemValue],
|
|
120
|
+
);
|
|
121
|
+
scrollToOption(selectedOptionIndex, 'instant', 'center');
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const handleKeyDown = (event) => {
|
|
126
|
+
const { key } = event;
|
|
127
|
+
const validKeys = ['ArrowUp', 'ArrowDown', 'Enter'];
|
|
128
|
+
if (validKeys.includes(key)) {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
if (key === 'ArrowUp') {
|
|
131
|
+
if (focusedOptionIndex.value === 0) return;
|
|
132
|
+
focusedOptionIndex.value--;
|
|
133
|
+
scrollToOption(focusedOptionIndex.value);
|
|
134
|
+
}
|
|
135
|
+
if (key === 'ArrowDown') {
|
|
136
|
+
if (focusedOptionIndex.value === filteredOptions.value.length - 1) return;
|
|
137
|
+
focusedOptionIndex.value++;
|
|
138
|
+
scrollToOption(focusedOptionIndex.value);
|
|
139
|
+
}
|
|
140
|
+
if (key === 'Enter') {
|
|
141
|
+
handleSelectOption(filteredOptions.value[focusedOptionIndex.value]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const focusedOptionIndex = ref<number>(-1);
|
|
147
|
+
|
|
148
|
+
const scrollToOption = (
|
|
149
|
+
index: number,
|
|
150
|
+
behavior: 'smooth' | 'instant' = 'smooth',
|
|
151
|
+
block: 'center' | 'start' | 'end' | 'nearest' = 'center',
|
|
152
|
+
) => {
|
|
153
|
+
nextTick(() => {
|
|
154
|
+
const option = document.querySelector(`[data-option-index="${index}"]`);
|
|
155
|
+
if (option) {
|
|
156
|
+
option.scrollIntoView({ behavior, block });
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const calculatedMaxHeight = computed(() => {
|
|
162
|
+
if (!props.options || props.options.length === 0) return 'unset';
|
|
163
|
+
const popoverPadding = 32;
|
|
164
|
+
const popoverGap = 4;
|
|
165
|
+
// 37 = 21px (height) + 16px (padding)
|
|
166
|
+
const fieldsHeight = 37 * props.optionsLines;
|
|
167
|
+
const size =
|
|
168
|
+
fieldsHeight + popoverPadding + (popoverGap * props.optionsLines - 2);
|
|
169
|
+
return `${props.enableSearch ? size + 54 : size}px`;
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const selectedItem = computed(() => {
|
|
173
|
+
if (props.returnObject) return props.modelValue;
|
|
174
|
+
|
|
175
|
+
return props.options.find(
|
|
176
|
+
(option) => option[props.itemValue] === props.modelValue,
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const inputValue = computed(() => {
|
|
181
|
+
return selectedItem.value?.[props.itemLabel];
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const handleSelectOption = (option) => {
|
|
185
|
+
if (
|
|
186
|
+
option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
|
|
187
|
+
option.disabled
|
|
188
|
+
)
|
|
189
|
+
return;
|
|
190
|
+
|
|
191
|
+
emit(
|
|
192
|
+
'update:modelValue',
|
|
193
|
+
props.returnObject ? option : option[props.itemValue],
|
|
194
|
+
);
|
|
195
|
+
openPopover.value = false;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const handleSearch = (value: string) => {
|
|
199
|
+
emit('update:search', value);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const filteredOptions = computed(() => {
|
|
203
|
+
if (!props.enableSearch || !props.search) return props.options;
|
|
204
|
+
|
|
205
|
+
return props.options.filter(
|
|
206
|
+
(option) =>
|
|
207
|
+
option[props.itemLabel]
|
|
208
|
+
.toLowerCase()
|
|
209
|
+
.includes(props.search?.toLowerCase()) ||
|
|
210
|
+
option[props.itemValue]
|
|
211
|
+
.toLowerCase()
|
|
212
|
+
.includes(props.search?.toLowerCase()),
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<style lang="scss" scoped>
|
|
218
|
+
@use '@/assets/scss/unnnic' as *;
|
|
219
|
+
|
|
220
|
+
:deep(.unnnic-select__input) {
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
:deep(.unnnic-select__input-search) {
|
|
225
|
+
> .icon-left {
|
|
226
|
+
color: $unnnic-color-fg-base;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
:deep(.unnnic-select__input) {
|
|
231
|
+
> .icon-right {
|
|
232
|
+
color: $unnnic-color-fg-base;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.unnnic-select {
|
|
237
|
+
&__content {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
padding: 0;
|
|
241
|
+
margin: 0;
|
|
242
|
+
gap: $unnnic-space-1;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
</style>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
class="tab-head"
|
|
10
10
|
:class="{
|
|
11
11
|
'tab-head--active': localValue === tab,
|
|
12
|
+
'tab-head--disabled': disabledTabs?.includes(tab),
|
|
12
13
|
}"
|
|
13
14
|
@click="change(tab)"
|
|
14
15
|
>
|
|
@@ -20,10 +21,9 @@
|
|
|
20
21
|
side="bottom"
|
|
21
22
|
>
|
|
22
23
|
<UnnnicIcon
|
|
23
|
-
icon="
|
|
24
|
+
icon="help"
|
|
24
25
|
:size="size === 'sm' ? 'xs' : 'sm'"
|
|
25
|
-
|
|
26
|
-
scheme="neutral-cleanest"
|
|
26
|
+
scheme="fg-base"
|
|
27
27
|
/>
|
|
28
28
|
</UnnnicToolTip>
|
|
29
29
|
</li>
|
|
@@ -65,6 +65,13 @@ export default {
|
|
|
65
65
|
tabs: {
|
|
66
66
|
type: Array,
|
|
67
67
|
default: null,
|
|
68
|
+
validator: (tabs) => {
|
|
69
|
+
return tabs.every((tab) => typeof tab === 'string') && tabs.length <= 5;
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
disabledTabs: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: null,
|
|
68
75
|
},
|
|
69
76
|
},
|
|
70
77
|
emits: ['change'],
|
|
@@ -105,6 +112,10 @@ export default {
|
|
|
105
112
|
return '';
|
|
106
113
|
},
|
|
107
114
|
change(value) {
|
|
115
|
+
if (this.disabledTabs?.includes(value)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
this.localValue = value;
|
|
109
120
|
this.$emit('change', this.localValue);
|
|
110
121
|
},
|
|
@@ -119,18 +130,15 @@ export default {
|
|
|
119
130
|
display: flex;
|
|
120
131
|
align-items: flex-start;
|
|
121
132
|
justify-content: space-between;
|
|
122
|
-
color: $unnnic-color-
|
|
123
|
-
font
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
127
|
-
margin-bottom: $unnnic-inset-sm;
|
|
128
|
-
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-neutral-soft;
|
|
133
|
+
color: $unnnic-color-fg-base;
|
|
134
|
+
font: $unnnic-font-action;
|
|
135
|
+
margin-bottom: $unnnic-space-4;
|
|
136
|
+
border-bottom: $unnnic-border-width-thinner solid $unnnic-color-border-base;
|
|
129
137
|
}
|
|
130
138
|
|
|
131
139
|
.tab-content {
|
|
132
140
|
display: flex;
|
|
133
|
-
gap: $unnnic-
|
|
141
|
+
gap: $unnnic-space-6;
|
|
134
142
|
|
|
135
143
|
margin: 0;
|
|
136
144
|
padding: 0;
|
|
@@ -139,27 +147,24 @@ export default {
|
|
|
139
147
|
|
|
140
148
|
.tab-head {
|
|
141
149
|
display: flex;
|
|
142
|
-
gap: $unnnic-
|
|
150
|
+
gap: $unnnic-space-2;
|
|
143
151
|
align-items: center;
|
|
144
152
|
|
|
145
153
|
cursor: pointer;
|
|
146
|
-
|
|
154
|
+
padding: $unnnic-space-2 $unnnic-space-4;
|
|
147
155
|
|
|
148
156
|
.unnnic-tooltip {
|
|
149
157
|
display: flex;
|
|
150
158
|
}
|
|
151
159
|
|
|
152
160
|
&:hover {
|
|
153
|
-
color: $unnnic-color-
|
|
161
|
+
color: $unnnic-color-fg-emphasized;
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
.tab-head--active {
|
|
158
|
-
|
|
159
|
-
font
|
|
160
|
-
color: $unnnic-color-neutral-black;
|
|
161
|
-
font-size: $unnnic-font-size-body-lg;
|
|
162
|
-
line-height: ($unnnic-font-size-body-lg + $unnnic-line-height-medium);
|
|
166
|
+
color: $unnnic-color-fg-emphasized;
|
|
167
|
+
font: $unnnic-font-action;
|
|
163
168
|
transition: 0.4s;
|
|
164
169
|
|
|
165
170
|
position: relative;
|
|
@@ -168,14 +173,23 @@ export default {
|
|
|
168
173
|
content: '';
|
|
169
174
|
|
|
170
175
|
position: absolute;
|
|
171
|
-
bottom:
|
|
172
|
-
left:
|
|
176
|
+
bottom: 0;
|
|
177
|
+
left: 0;
|
|
173
178
|
|
|
174
179
|
display: block;
|
|
175
180
|
|
|
176
|
-
width:
|
|
181
|
+
width: 100%;
|
|
177
182
|
|
|
178
|
-
border-bottom: $unnnic-border-width-thin solid $unnnic-color-
|
|
183
|
+
border-bottom: $unnnic-border-width-thin solid $unnnic-color-border-active;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.tab-head--disabled {
|
|
188
|
+
color: $unnnic-color-fg-muted;
|
|
189
|
+
cursor: default;
|
|
190
|
+
|
|
191
|
+
&:hover {
|
|
192
|
+
color: $unnnic-color-fg-muted;
|
|
179
193
|
}
|
|
180
194
|
}
|
|
181
195
|
|
|
@@ -4,7 +4,7 @@ exports[`Tab.vue > matches the snapshot 1`] = `
|
|
|
4
4
|
"<div data-v-b4e39fac="" class="tab size-md">
|
|
5
5
|
<header data-v-b4e39fac="" class="tab-header">
|
|
6
6
|
<ul data-v-b4e39fac="" class="tab-content">
|
|
7
|
-
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--
|
|
7
|
+
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-bf0cf546="" data-v-b4e39fac="" class="unnnic-tooltip"><span data-v-26446d8e="" data-v-b4e39fac="" class="material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm" data-testid="material-icon" translate="no">help</span><span data-v-bf0cf546="" class="unnnic-tooltip-label unnnic-tooltip-label-bottom" data-testid="tooltip-label" style="left: 0px; top: 8px;">Tooltip text <br data-v-bf0cf546=""><!--v-if--></span></div>
|
|
8
8
|
</li>
|
|
9
9
|
<li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
|
|
10
10
|
<!--v-if-->
|
|
@@ -42,7 +42,7 @@ exports[`TableNext.vue > matches the snapshot 1`] = `
|
|
|
42
42
|
<p data-v-e29458bb="" class="table-pagination__count" data-testid="count">1 - 1 of 1</p>
|
|
43
43
|
<div data-v-0eeff8cb="" data-v-e29458bb="" class="pagination"><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="previous-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
44
44
|
<!--v-if-->
|
|
45
|
-
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--
|
|
45
|
+
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--ant unnnic-icon-scheme--neutral-clean" data-testid="icon-center" style="visibility: visible;">
|
|
46
46
|
<path d="M26.8368 35.0005C26.5868 35.0005 26.3506 34.903 26.1743 34.7255L12.7743 21.3255C12.4206 20.9717 12.2256 20.5017 12.2256 20.0017C12.2256 19.5017 12.4193 19.0305 12.7731 18.6767L26.1743 5.27549C26.3506 5.09799 26.5868 5.00049 26.8368 5.00049C27.0868 5.00049 27.3231 5.09799 27.4993 5.27549C27.6768 5.45174 27.7743 5.68799 27.7743 5.93799C27.7743 6.18799 27.6768 6.42424 27.4993 6.60049L14.0993 20.0005L27.4993 33.4005C27.6768 33.578 27.7743 33.813 27.7743 34.063C27.7743 34.313 27.6768 34.5492 27.4993 34.7255C27.3218 34.9017 27.0868 35.0005 26.8368 35.0005Z" fill="#3B414D" class="primary"></path>
|
|
47
47
|
</svg><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
48
48
|
<!--v-if-->
|
|
@@ -53,7 +53,7 @@ exports[`TableNext.vue > matches the snapshot 1`] = `
|
|
|
53
53
|
<!--v-if-->
|
|
54
54
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="next-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
55
55
|
<!--v-if-->
|
|
56
|
-
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--
|
|
56
|
+
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--ant unnnic-icon-scheme--neutral-clean" data-testid="icon-center" style="visibility: visible;">
|
|
57
57
|
<path d="M13.1635 35.0005C12.9135 35.0005 12.6772 34.903 12.501 34.7255C12.136 34.3605 12.136 33.7655 12.501 33.3992L25.901 20.0005L12.501 6.60049C12.3235 6.42424 12.226 6.18799 12.226 5.93799C12.226 5.68799 12.3235 5.45174 12.501 5.27549C12.6772 5.09799 12.9135 5.00049 13.1635 5.00049C13.4135 5.00049 13.6497 5.09799 13.826 5.27549L27.226 18.6755C27.956 19.4055 27.9572 20.5942 27.2272 21.3242L13.826 34.7255C13.6497 34.903 13.4135 35.0005 13.1635 35.0005Z" fill="#3B414D" class="primary"></path>
|
|
58
58
|
</svg><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
59
59
|
<!--v-if-->
|
|
@@ -5,7 +5,7 @@ exports[`TablePagination.vue > matches the snapshot 1`] = `
|
|
|
5
5
|
<p data-v-e29458bb="" class="table-pagination__count" data-testid="count">1 - 10 of 100</p>
|
|
6
6
|
<div data-v-0eeff8cb="" data-v-e29458bb="" class="pagination"><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="previous-button" disabled="" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
7
7
|
<!--v-if-->
|
|
8
|
-
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--
|
|
8
|
+
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--ant unnnic-icon-scheme--neutral-clean" data-testid="icon-center" style="visibility: visible;">
|
|
9
9
|
<path d="M26.8368 35.0005C26.5868 35.0005 26.3506 34.903 26.1743 34.7255L12.7743 21.3255C12.4206 20.9717 12.2256 20.5017 12.2256 20.0017C12.2256 19.5017 12.4193 19.0305 12.7731 18.6767L26.1743 5.27549C26.3506 5.09799 26.5868 5.00049 26.8368 5.00049C27.0868 5.00049 27.3231 5.09799 27.4993 5.27549C27.6768 5.45174 27.7743 5.68799 27.7743 5.93799C27.7743 6.18799 27.6768 6.42424 27.4993 6.60049L14.0993 20.0005L27.4993 33.4005C27.6768 33.578 27.7743 33.813 27.7743 34.063C27.7743 34.313 27.6768 34.5492 27.4993 34.7255C27.3218 34.9017 27.0868 35.0005 26.8368 35.0005Z" fill="#3B414D" class="primary"></path>
|
|
10
10
|
</svg><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
11
11
|
<!--v-if-->
|
|
@@ -36,7 +36,7 @@ exports[`TablePagination.vue > matches the snapshot 1`] = `
|
|
|
36
36
|
<!--v-if-->
|
|
37
37
|
</button><button data-v-ceff2a60="" data-v-0eeff8cb="" data-test="next-button" class="unnnic-button unnnic-button--size-small unnnic-button--tertiary unnnic-button--icon-on-center">
|
|
38
38
|
<!--v-if-->
|
|
39
|
-
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--
|
|
39
|
+
<!--v-if--><svg data-v-26446d8e="" data-v-ceff2a60="" width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="unnnic-icon unnnic-icon__size--ant unnnic-icon-scheme--neutral-dark" data-testid="icon-center" style="visibility: visible;">
|
|
40
40
|
<path d="M13.1635 35.0005C12.9135 35.0005 12.6772 34.903 12.501 34.7255C12.136 34.3605 12.136 33.7655 12.501 33.3992L25.901 20.0005L12.501 6.60049C12.3235 6.42424 12.226 6.18799 12.226 5.93799C12.226 5.68799 12.3235 5.45174 12.501 5.27549C12.6772 5.09799 12.9135 5.00049 13.1635 5.00049C13.4135 5.00049 13.6497 5.09799 13.826 5.27549L27.226 18.6755C27.956 19.4055 27.9572 20.5942 27.2272 21.3242L13.826 34.7255C13.6497 34.903 13.4135 35.0005 13.1635 35.0005Z" fill="#3B414D" class="primary"></path>
|
|
41
41
|
</svg><span data-v-ceff2a60="" class="unnnic-button__label" style="visibility: visible;" data-testid="button-label"> </span>
|
|
42
42
|
<!--v-if-->
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section class="unnnic-template-preview">
|
|
3
|
+
<section
|
|
4
|
+
:class="[
|
|
5
|
+
'unnnic-template-preview__content',
|
|
6
|
+
{ 'unnnic-template-preview__content--has-media': hasHeaderMedia },
|
|
7
|
+
]"
|
|
8
|
+
>
|
|
9
|
+
<header
|
|
10
|
+
v-if="hasHeader"
|
|
11
|
+
:class="`unnnic-template-preview__header__${
|
|
12
|
+
template?.header.type === 'TEXT' ? 'text' : 'media'
|
|
13
|
+
}`"
|
|
14
|
+
>
|
|
15
|
+
<img
|
|
16
|
+
v-if="
|
|
17
|
+
template?.header.type === 'MEDIA' &&
|
|
18
|
+
template?.header.mediaType === 'IMAGE'
|
|
19
|
+
"
|
|
20
|
+
class="unnnic-template-preview__header__media__preview"
|
|
21
|
+
:src="template.header.src || imagePreview"
|
|
22
|
+
/>
|
|
23
|
+
<template
|
|
24
|
+
v-else-if="
|
|
25
|
+
template?.header.type === 'MEDIA' &&
|
|
26
|
+
template?.header.mediaType === 'VIDEO'
|
|
27
|
+
"
|
|
28
|
+
>
|
|
29
|
+
<video
|
|
30
|
+
v-if="template.header.src"
|
|
31
|
+
class="unnnic-template-preview__header__media__preview"
|
|
32
|
+
:src="template.header.src"
|
|
33
|
+
controls
|
|
34
|
+
/>
|
|
35
|
+
<img
|
|
36
|
+
v-else
|
|
37
|
+
class="unnnic-template-preview__header__media__preview"
|
|
38
|
+
:src="videoPreview"
|
|
39
|
+
/>
|
|
40
|
+
</template>
|
|
41
|
+
<template
|
|
42
|
+
v-else-if="
|
|
43
|
+
template?.header.type === 'MEDIA' &&
|
|
44
|
+
template?.header.mediaType === 'DOCUMENT'
|
|
45
|
+
"
|
|
46
|
+
>
|
|
47
|
+
<img
|
|
48
|
+
class="unnnic-template-preview__header__media__preview"
|
|
49
|
+
:src="documentPreview"
|
|
50
|
+
/>
|
|
51
|
+
</template>
|
|
52
|
+
<h1
|
|
53
|
+
v-else-if="template?.header.type === 'TEXT'"
|
|
54
|
+
class="unnnic-template-preview__header__text__preview"
|
|
55
|
+
>
|
|
56
|
+
{{ template.header.text }}
|
|
57
|
+
</h1>
|
|
58
|
+
</header>
|
|
59
|
+
<section
|
|
60
|
+
v-if="hasBody"
|
|
61
|
+
:class="[
|
|
62
|
+
'unnnic-template-preview__body',
|
|
63
|
+
{ 'unnnic-template-preview__body--has-media': hasHeaderMedia },
|
|
64
|
+
]"
|
|
65
|
+
>
|
|
66
|
+
<section v-html="parsedBody"></section>
|
|
67
|
+
</section>
|
|
68
|
+
<footer
|
|
69
|
+
v-if="hasFooter"
|
|
70
|
+
:class="[
|
|
71
|
+
'unnnic-template-preview__footer',
|
|
72
|
+
{ 'unnnic-template-preview__footer--has-media': hasHeaderMedia },
|
|
73
|
+
]"
|
|
74
|
+
>
|
|
75
|
+
{{ template?.footer }}
|
|
76
|
+
</footer>
|
|
77
|
+
</section>
|
|
78
|
+
<footer
|
|
79
|
+
v-if="hasButtons"
|
|
80
|
+
class="unnnic-template-preview__buttons"
|
|
81
|
+
>
|
|
82
|
+
<section
|
|
83
|
+
v-for="(button, index) in template?.buttons"
|
|
84
|
+
:key="`button-${index}`"
|
|
85
|
+
class="unnnic-template-preview__buttons__button"
|
|
86
|
+
>
|
|
87
|
+
<UnnnicIcon
|
|
88
|
+
class="unnnic-template-preview__buttons__button__icon"
|
|
89
|
+
:icon="getButtonIcon(button.type)"
|
|
90
|
+
scheme="aux-blue-500"
|
|
91
|
+
size="ant"
|
|
92
|
+
/>
|
|
93
|
+
<p class="unnnic-template-preview__buttons__button__text">
|
|
94
|
+
{{ button.text }}
|
|
95
|
+
</p>
|
|
96
|
+
</section>
|
|
97
|
+
</footer>
|
|
98
|
+
</section>
|
|
99
|
+
</template>
|
|
100
|
+
|
|
101
|
+
<script lang="ts" setup>
|
|
102
|
+
import { computed } from 'vue';
|
|
103
|
+
|
|
104
|
+
import type { Template } from './types';
|
|
105
|
+
|
|
106
|
+
import imagePreview from '../../assets/img/previews/image-preview.png';
|
|
107
|
+
import documentPreview from '../../assets/img/previews/doc-preview.png';
|
|
108
|
+
import videoPreview from '../../assets/img/previews/video-preview.png';
|
|
109
|
+
|
|
110
|
+
import UnnnicIcon from '../Icon.vue';
|
|
111
|
+
|
|
112
|
+
interface Props {
|
|
113
|
+
template?: Template | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
117
|
+
template: null,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const hasHeader = computed(
|
|
121
|
+
() => props.template?.header && props.template.header.type,
|
|
122
|
+
);
|
|
123
|
+
const hasHeaderMedia = computed(
|
|
124
|
+
() => !!props.template?.header && props.template.header.type === 'MEDIA',
|
|
125
|
+
);
|
|
126
|
+
const hasBody = computed(
|
|
127
|
+
() => !!props.template?.body && props.template.body.length > 0,
|
|
128
|
+
);
|
|
129
|
+
const hasFooter = computed(
|
|
130
|
+
() => !!props.template?.footer && props.template.footer.length > 0,
|
|
131
|
+
);
|
|
132
|
+
const hasButtons = computed(
|
|
133
|
+
() => !!props.template?.buttons && props.template.buttons.length > 0,
|
|
134
|
+
);
|
|
135
|
+
const parsedBody = computed(() => {
|
|
136
|
+
if (!hasBody.value) return '';
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
139
|
+
const result = props
|
|
140
|
+
.template!.body!.replaceAll('\n', '<br/>')
|
|
141
|
+
.replaceAll(/(?:\*)([^*<\n]+)(?:\*)/g, '<strong>$1</strong>')
|
|
142
|
+
.replaceAll(/(?:_)([^_<\n]+)(?:_)/g, '<i>$1</i>')
|
|
143
|
+
.replaceAll(/(?:~)([^~<\n]+)(?:~)/g, '<s>$1</s>')
|
|
144
|
+
.replaceAll(/(?:```)([^```<\n]+)(?:```)/g, '<tt>$1</tt>')
|
|
145
|
+
.replaceAll(/{{.*?}}/g, (match) => `<strong>${match}</strong>`);
|
|
146
|
+
|
|
147
|
+
return result;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const getButtonIcon = (buttonType) => {
|
|
151
|
+
const buttonMapper = {
|
|
152
|
+
PHONE_NUMBER: 'phone',
|
|
153
|
+
URL: 'open_in_new',
|
|
154
|
+
COPY_CODE: 'content_copy',
|
|
155
|
+
FLOW: '',
|
|
156
|
+
QUICK_REPLY: 'reply',
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
return buttonMapper[buttonType] || '';
|
|
160
|
+
};
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<style lang="scss" scoped>
|
|
164
|
+
@use '@/assets/scss/unnnic' as *;
|
|
165
|
+
|
|
166
|
+
.unnnic-template-preview {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
box-shadow: $unnnic-shadow-level-near;
|
|
170
|
+
background-color: $unnnic-color-background-white;
|
|
171
|
+
width: 368px;
|
|
172
|
+
border-radius: $unnnic-border-radius-md;
|
|
173
|
+
|
|
174
|
+
&__content {
|
|
175
|
+
display: flex;
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
gap: $unnnic-space-3;
|
|
178
|
+
padding: $unnnic-space-4 $unnnic-space-3;
|
|
179
|
+
|
|
180
|
+
&--has-media {
|
|
181
|
+
padding: $unnnic-space-1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&__header {
|
|
186
|
+
&__text {
|
|
187
|
+
&__preview {
|
|
188
|
+
font-family: $unnnic-font-family-secondary;
|
|
189
|
+
font-weight: $unnnic-font-weight-bold;
|
|
190
|
+
font-size: $unnnic-font-size-body-gt;
|
|
191
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
|
|
192
|
+
color: $unnnic-color-neutral-dark;
|
|
193
|
+
|
|
194
|
+
margin: $unnnic-space-0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&__media {
|
|
199
|
+
&__preview {
|
|
200
|
+
width: 100%;
|
|
201
|
+
object-fit: cover;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&__body {
|
|
207
|
+
font-family: $unnnic-font-family-secondary;
|
|
208
|
+
font-weight: $unnnic-font-weight-regular;
|
|
209
|
+
font-size: $unnnic-font-size-body-gt;
|
|
210
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
|
|
211
|
+
color: $unnnic-color-neutral-cloudy;
|
|
212
|
+
|
|
213
|
+
&--has-media {
|
|
214
|
+
padding: $unnnic-space-0 $unnnic-space-2;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&__footer {
|
|
219
|
+
font-family: $unnnic-font-family-secondary;
|
|
220
|
+
font-weight: $unnnic-font-weight-regular;
|
|
221
|
+
font-size: $unnnic-font-size-body-md;
|
|
222
|
+
line-height: $unnnic-font-size-body-md + $unnnic-line-height-medium;
|
|
223
|
+
color: $unnnic-color-neutral-clean;
|
|
224
|
+
|
|
225
|
+
&--has-media {
|
|
226
|
+
padding: $unnnic-space-0 $unnnic-space-3 $unnnic-space-2;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
&__buttons {
|
|
231
|
+
font-family: $unnnic-font-family-secondary;
|
|
232
|
+
font-weight: $unnnic-font-weight-bold;
|
|
233
|
+
font-size: $unnnic-font-size-body-gt;
|
|
234
|
+
line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
|
|
235
|
+
|
|
236
|
+
&__button {
|
|
237
|
+
margin: 0;
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
justify-content: center;
|
|
241
|
+
gap: $unnnic-space-2;
|
|
242
|
+
padding: $unnnic-space-3;
|
|
243
|
+
border-top: 1px solid $unnnic-color-neutral-light;
|
|
244
|
+
|
|
245
|
+
&__text {
|
|
246
|
+
color: $unnnic-color-aux-blue-500;
|
|
247
|
+
margin: $unnnic-space-0;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
</style>
|