@weni/unnnic-system 3.2.9-alpha.12 → 3.2.9-alpha.13
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/dist/components/Button/Button.vue.d.ts.map +1 -1
- package/dist/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/TemplatePreview/TemplatePreview.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/{es-66126ef1.mjs → es-5aa232c1.mjs} +1 -1
- package/dist/{index-f6e9b879.mjs → index-69d07468.mjs} +353 -352
- package/dist/{pt-br-3b5a8852.mjs → pt-br-5f8a4e67.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +1 -1
- package/dist/unnnic.umd.js +7 -7
- package/package.json +2 -2
- package/src/components/Button/Button.vue +7 -4
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +1 -2
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +60 -61
- package/src/components/Chip/Chip.vue +1 -1
- package/src/components/Input/BaseInput.vue +4 -4
- package/src/components/Input/Input.vue +1 -1
- package/src/components/Input/TextInput.vue +2 -3
- package/src/components/ModalDialog/ModalDialog.vue +29 -26
- package/src/components/Popover/__tests__/Popover.spec.js +18 -18
- package/src/components/Popover/index.vue +93 -78
- package/src/components/Select/SelectOption.vue +43 -37
- package/src/components/Select/__tests__/Select.spec.js +41 -36
- package/src/components/Select/__tests__/SelectItem.spec.js +35 -15
- package/src/components/Select/__tests__/SelectOption.spec.js +6 -3
- package/src/components/Select/index.vue +192 -142
- package/src/components/TemplatePreview/TemplatePreview.vue +30 -27
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +11 -11
- package/src/components/TemplatePreview/types.d.ts +3 -3
- package/src/stories/Button.stories.js +1 -7
- package/src/stories/Input.stories.js +4 -4
- package/src/stories/Popover.stories.js +9 -9
- package/src/stories/Select.stories.js +39 -39
- package/src/stories/TemplatePreview.stories.js +27 -27
- package/src/stories/TemplatePreviewModal.stories.js +31 -31
|
@@ -1,29 +1,55 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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>
|
|
27
53
|
</template>
|
|
28
54
|
|
|
29
55
|
<script setup lang="ts">
|
|
@@ -34,162 +60,186 @@ import UnnnicSelectOption from './SelectOption.vue';
|
|
|
34
60
|
import UnnnicI18n from '../../mixins/i18n';
|
|
35
61
|
|
|
36
62
|
defineOptions({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})
|
|
63
|
+
name: 'UnnnicSelect',
|
|
64
|
+
mixins: [UnnnicI18n],
|
|
65
|
+
});
|
|
40
66
|
|
|
41
67
|
interface SelectProps {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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;
|
|
60
86
|
}
|
|
61
87
|
|
|
62
88
|
const props = withDefaults(defineProps<SelectProps>(), {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
})
|
|
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
|
+
});
|
|
74
100
|
|
|
75
101
|
const emit = defineEmits<{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}>()
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
|
+
'update:modelValue': [value: any];
|
|
104
|
+
'update:search': [value: string];
|
|
105
|
+
}>();
|
|
80
106
|
|
|
81
|
-
const openPopover = ref(false)
|
|
107
|
+
const openPopover = ref(false);
|
|
82
108
|
|
|
83
109
|
watch(openPopover, () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
+
});
|
|
95
124
|
|
|
96
125
|
const handleKeyDown = (event) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
if (key === 'ArrowDown') {
|
|
107
|
-
if(focusedOptionIndex.value === filteredOptions.value.length - 1) return
|
|
108
|
-
focusedOptionIndex.value++
|
|
109
|
-
scrollToOption(focusedOptionIndex.value)
|
|
110
|
-
}
|
|
111
|
-
if (key === 'Enter') {
|
|
112
|
-
handleSelectOption(filteredOptions.value[focusedOptionIndex.value])
|
|
113
|
-
}
|
|
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);
|
|
114
134
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
};
|
|
127
160
|
|
|
128
161
|
const calculatedMaxHeight = computed(() => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
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
|
+
});
|
|
137
171
|
|
|
138
172
|
const selectedItem = computed(() => {
|
|
139
|
-
|
|
173
|
+
if (props.returnObject) return props.modelValue;
|
|
140
174
|
|
|
141
|
-
|
|
142
|
-
|
|
175
|
+
return props.options.find(
|
|
176
|
+
(option) => option[props.itemValue] === props.modelValue,
|
|
177
|
+
);
|
|
178
|
+
});
|
|
143
179
|
|
|
144
180
|
const inputValue = computed(() => {
|
|
145
|
-
|
|
146
|
-
})
|
|
181
|
+
return selectedItem.value?.[props.itemLabel];
|
|
182
|
+
});
|
|
147
183
|
|
|
148
184
|
const handleSelectOption = (option) => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
};
|
|
154
197
|
|
|
155
198
|
const handleSearch = (value: string) => {
|
|
156
|
-
|
|
157
|
-
}
|
|
199
|
+
emit('update:search', value);
|
|
200
|
+
};
|
|
158
201
|
|
|
159
202
|
const filteredOptions = computed(() => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
+
});
|
|
165
215
|
</script>
|
|
166
216
|
|
|
167
217
|
<style lang="scss" scoped>
|
|
168
218
|
@use '@/assets/scss/unnnic' as *;
|
|
169
219
|
|
|
170
220
|
:deep(.unnnic-select__input) {
|
|
171
|
-
|
|
221
|
+
cursor: pointer;
|
|
172
222
|
}
|
|
173
223
|
|
|
174
224
|
:deep(.unnnic-select__input-search) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
225
|
+
> .icon-left {
|
|
226
|
+
color: $unnnic-color-fg-base;
|
|
227
|
+
}
|
|
178
228
|
}
|
|
179
229
|
|
|
180
230
|
:deep(.unnnic-select__input) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
231
|
+
> .icon-right {
|
|
232
|
+
color: $unnnic-color-fg-base;
|
|
233
|
+
}
|
|
184
234
|
}
|
|
185
235
|
|
|
186
236
|
.unnnic-select {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
237
|
+
&__content {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
padding: 0;
|
|
241
|
+
margin: 0;
|
|
242
|
+
gap: $unnnic-space-1;
|
|
243
|
+
}
|
|
194
244
|
}
|
|
195
|
-
</style>
|
|
245
|
+
</style>
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
}`"
|
|
14
14
|
>
|
|
15
15
|
<img
|
|
16
|
-
class="unnnic-template-preview__header__media__preview"
|
|
17
16
|
v-if="
|
|
18
17
|
template?.header.type === 'MEDIA' &&
|
|
19
18
|
template?.header.mediaType === 'IMAGE'
|
|
20
19
|
"
|
|
20
|
+
class="unnnic-template-preview__header__media__preview"
|
|
21
21
|
:src="template.header.src || imagePreview"
|
|
22
22
|
/>
|
|
23
23
|
<template
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
/>
|
|
51
51
|
</template>
|
|
52
52
|
<h1
|
|
53
|
-
class="unnnic-template-preview__header__text__preview"
|
|
54
53
|
v-else-if="template?.header.type === 'TEXT'"
|
|
54
|
+
class="unnnic-template-preview__header__text__preview"
|
|
55
55
|
>
|
|
56
56
|
{{ template.header.text }}
|
|
57
57
|
</h1>
|
|
@@ -75,7 +75,10 @@
|
|
|
75
75
|
{{ template?.footer }}
|
|
76
76
|
</footer>
|
|
77
77
|
</section>
|
|
78
|
-
<footer
|
|
78
|
+
<footer
|
|
79
|
+
v-if="hasButtons"
|
|
80
|
+
class="unnnic-template-preview__buttons"
|
|
81
|
+
>
|
|
79
82
|
<section
|
|
80
83
|
v-for="(button, index) in template?.buttons"
|
|
81
84
|
:key="`button-${index}`"
|
|
@@ -96,15 +99,15 @@
|
|
|
96
99
|
</template>
|
|
97
100
|
|
|
98
101
|
<script lang="ts" setup>
|
|
99
|
-
import { computed } from
|
|
102
|
+
import { computed } from 'vue';
|
|
100
103
|
|
|
101
|
-
import type { Template } from
|
|
104
|
+
import type { Template } from './types';
|
|
102
105
|
|
|
103
|
-
import imagePreview from
|
|
104
|
-
import documentPreview from
|
|
105
|
-
import videoPreview from
|
|
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';
|
|
106
109
|
|
|
107
|
-
import UnnnicIcon from
|
|
110
|
+
import UnnnicIcon from '../Icon.vue';
|
|
108
111
|
|
|
109
112
|
interface Props {
|
|
110
113
|
template?: Template | null;
|
|
@@ -115,30 +118,30 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
115
118
|
});
|
|
116
119
|
|
|
117
120
|
const hasHeader = computed(
|
|
118
|
-
() => props.template?.header && props.template.header.type
|
|
121
|
+
() => props.template?.header && props.template.header.type,
|
|
119
122
|
);
|
|
120
123
|
const hasHeaderMedia = computed(
|
|
121
|
-
() => !!props.template?.header && props.template.header.type ===
|
|
124
|
+
() => !!props.template?.header && props.template.header.type === 'MEDIA',
|
|
122
125
|
);
|
|
123
126
|
const hasBody = computed(
|
|
124
|
-
() => !!props.template?.body && props.template.body.length > 0
|
|
127
|
+
() => !!props.template?.body && props.template.body.length > 0,
|
|
125
128
|
);
|
|
126
129
|
const hasFooter = computed(
|
|
127
|
-
() => !!props.template?.footer && props.template.footer.length > 0
|
|
130
|
+
() => !!props.template?.footer && props.template.footer.length > 0,
|
|
128
131
|
);
|
|
129
132
|
const hasButtons = computed(
|
|
130
|
-
() => !!props.template?.buttons && props.template.buttons.length > 0
|
|
133
|
+
() => !!props.template?.buttons && props.template.buttons.length > 0,
|
|
131
134
|
);
|
|
132
135
|
const parsedBody = computed(() => {
|
|
133
|
-
if (!hasBody.value) return
|
|
136
|
+
if (!hasBody.value) return '';
|
|
134
137
|
|
|
135
138
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
136
139
|
const result = props
|
|
137
|
-
.template!.body!.replaceAll(
|
|
138
|
-
.replaceAll(/(?:\*)([^*<\n]+)(?:\*)/g,
|
|
139
|
-
.replaceAll(/(?:_)([^_<\n]+)(?:_)/g,
|
|
140
|
-
.replaceAll(/(?:~)([^~<\n]+)(?:~)/g,
|
|
141
|
-
.replaceAll(/(?:```)([^```<\n]+)(?:```)/g,
|
|
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>')
|
|
142
145
|
.replaceAll(/{{.*?}}/g, (match) => `<strong>${match}</strong>`);
|
|
143
146
|
|
|
144
147
|
return result;
|
|
@@ -146,19 +149,19 @@ const parsedBody = computed(() => {
|
|
|
146
149
|
|
|
147
150
|
const getButtonIcon = (buttonType) => {
|
|
148
151
|
const buttonMapper = {
|
|
149
|
-
PHONE_NUMBER:
|
|
150
|
-
URL:
|
|
151
|
-
COPY_CODE:
|
|
152
|
-
FLOW:
|
|
153
|
-
QUICK_REPLY:
|
|
152
|
+
PHONE_NUMBER: 'phone',
|
|
153
|
+
URL: 'open_in_new',
|
|
154
|
+
COPY_CODE: 'content_copy',
|
|
155
|
+
FLOW: '',
|
|
156
|
+
QUICK_REPLY: 'reply',
|
|
154
157
|
};
|
|
155
158
|
|
|
156
|
-
return buttonMapper[buttonType] ||
|
|
159
|
+
return buttonMapper[buttonType] || '';
|
|
157
160
|
};
|
|
158
161
|
</script>
|
|
159
162
|
|
|
160
163
|
<style lang="scss" scoped>
|
|
161
|
-
@use
|
|
164
|
+
@use '@/assets/scss/unnnic' as *;
|
|
162
165
|
|
|
163
166
|
.unnnic-template-preview {
|
|
164
167
|
display: flex;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<UnnnicModalDialog
|
|
3
|
-
:
|
|
4
|
-
@update:modelValue="$event === false && $emit('close')"
|
|
3
|
+
:modelValue="modelValue"
|
|
5
4
|
:title="defaultTranslations.title[props.locale]"
|
|
6
|
-
:
|
|
5
|
+
:showCloseIcon="true"
|
|
7
6
|
class="unnnic-template-preview-modal"
|
|
7
|
+
@update:model-value="$event === false && $emit('close')"
|
|
8
8
|
>
|
|
9
9
|
<UnnnicTemplatePreview :template="template" />
|
|
10
10
|
</UnnnicModalDialog>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
|
-
import UnnnicTemplatePreview from
|
|
15
|
-
import UnnnicModalDialog from
|
|
14
|
+
import UnnnicTemplatePreview from './TemplatePreview.vue';
|
|
15
|
+
import UnnnicModalDialog from '../ModalDialog/ModalDialog.vue';
|
|
16
16
|
|
|
17
|
-
import type { Template } from
|
|
17
|
+
import type { Template } from './types';
|
|
18
18
|
|
|
19
19
|
const defaultTranslations = {
|
|
20
20
|
title: {
|
|
21
|
-
|
|
22
|
-
en:
|
|
23
|
-
es:
|
|
21
|
+
'pt-br': 'Visualizar modelo',
|
|
22
|
+
en: 'Template preview',
|
|
23
|
+
es: 'Vista previa de plantilla',
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
26
|
|
|
@@ -31,7 +31,7 @@ interface Props {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const props = withDefaults(defineProps<Props>(), {
|
|
34
|
-
locale:
|
|
34
|
+
locale: 'en',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
defineEmits<{
|
|
@@ -40,7 +40,7 @@ defineEmits<{
|
|
|
40
40
|
</script>
|
|
41
41
|
|
|
42
42
|
<style lang="scss" scoped>
|
|
43
|
-
@use
|
|
43
|
+
@use '@/assets/scss/unnnic' as *;
|
|
44
44
|
|
|
45
45
|
:deep(.unnnic-modal-dialog__container__content) {
|
|
46
46
|
display: flex;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export interface Template {
|
|
2
2
|
header: {
|
|
3
|
-
type:
|
|
4
|
-
mediaType?:
|
|
3
|
+
type: 'TEXT' | 'MEDIA';
|
|
4
|
+
mediaType?: 'IMAGE' | 'VIDEO' | 'DOCUMENT';
|
|
5
5
|
text?: string | null;
|
|
6
6
|
src?: string | null;
|
|
7
7
|
};
|
|
8
8
|
body?: string;
|
|
9
9
|
footer?: string;
|
|
10
10
|
buttons?: Array<{
|
|
11
|
-
type:
|
|
11
|
+
type: 'QUICK_REPLY' | 'PHONE_NUMBER';
|
|
12
12
|
text: string;
|
|
13
13
|
countryCode?: string;
|
|
14
14
|
phoneNumber?: string;
|
|
@@ -36,13 +36,7 @@ export default {
|
|
|
36
36
|
argTypes: {
|
|
37
37
|
type: {
|
|
38
38
|
control: { type: 'select' },
|
|
39
|
-
options: [
|
|
40
|
-
'primary',
|
|
41
|
-
'secondary',
|
|
42
|
-
'tertiary',
|
|
43
|
-
'warning',
|
|
44
|
-
'attention',
|
|
45
|
-
],
|
|
39
|
+
options: ['primary', 'secondary', 'tertiary', 'warning', 'attention'],
|
|
46
40
|
},
|
|
47
41
|
size: {
|
|
48
42
|
control: { type: 'select' },
|
|
@@ -95,10 +95,10 @@ export const Normal = {
|
|
|
95
95
|
type: 'normal',
|
|
96
96
|
placeholder: 'Placeholder',
|
|
97
97
|
showClear: true,
|
|
98
|
-
iconLeft:
|
|
99
|
-
iconRight:
|
|
98
|
+
iconLeft: 'expand-8-1',
|
|
99
|
+
iconRight: 'messaging-we-chat-3',
|
|
100
100
|
iconLeftClickable: true,
|
|
101
|
-
iconRightClickable: false
|
|
101
|
+
iconRightClickable: false,
|
|
102
102
|
},
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -107,7 +107,7 @@ export const NormalSm = {
|
|
|
107
107
|
size: 'sm',
|
|
108
108
|
type: 'normal',
|
|
109
109
|
placeholder: 'Placeholder',
|
|
110
|
-
showClear: true
|
|
110
|
+
showClear: true,
|
|
111
111
|
},
|
|
112
112
|
};
|
|
113
113
|
|
|
@@ -6,9 +6,9 @@ export default {
|
|
|
6
6
|
render: (args) => ({
|
|
7
7
|
components: { UnnnicPopover },
|
|
8
8
|
setup() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
return {
|
|
10
|
+
args,
|
|
11
|
+
};
|
|
12
12
|
},
|
|
13
13
|
template: `
|
|
14
14
|
<div>
|
|
@@ -28,12 +28,12 @@ export default {
|
|
|
28
28
|
|
|
29
29
|
export const Default = {
|
|
30
30
|
args: {
|
|
31
|
-
modelValue: false
|
|
32
|
-
}
|
|
31
|
+
modelValue: false,
|
|
32
|
+
},
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export const WithModelValue = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
36
|
+
args: {
|
|
37
|
+
modelValue: true,
|
|
38
|
+
},
|
|
39
|
+
};
|