@weni/unnnic-system 3.2.9-alpha.11 → 3.2.9-alpha.12
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-dcef703d.js → es-66126ef1.mjs} +1 -1
- package/dist/{index-6ddf8580.js → index-f6e9b879.mjs} +15 -15
- package/dist/{pt-br-485ef253.js → pt-br-3b5a8852.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/{unnnic.js → unnnic.mjs} +1 -1
- package/dist/{unnnic.umd.cjs → unnnic.umd.js} +5 -5
- package/package.json +2 -2
- package/src/components/Button/Button.vue +4 -7
- package/src/components/ChartFunnel/DefaultFunnel/ChartDefaultFunnelBase.vue +2 -1
- package/src/components/ChartFunnel/SvgFunnel/ChartFunnelTwoRows.vue +61 -60
- 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 +3 -2
- package/src/components/ModalDialog/ModalDialog.vue +26 -29
- package/src/components/Popover/__tests__/Popover.spec.js +18 -18
- package/src/components/Popover/index.vue +78 -93
- package/src/components/Select/SelectOption.vue +37 -43
- package/src/components/Select/__tests__/Select.spec.js +36 -41
- package/src/components/Select/__tests__/SelectItem.spec.js +15 -35
- package/src/components/Select/__tests__/SelectOption.spec.js +3 -6
- package/src/components/Select/index.vue +142 -192
- package/src/components/TemplatePreview/TemplatePreview.vue +25 -28
- package/src/components/TemplatePreview/TemplatePreviewModal.vue +10 -10
- package/src/components/TemplatePreview/types.d.ts +3 -3
- package/src/stories/Button.stories.js +7 -1
- 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,55 +1,29 @@
|
|
|
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
|
-
|
|
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:modelValue="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>
|
|
2
|
+
<div class="unnnic-select" @keydown="handleKeyDown">
|
|
3
|
+
<UnnnicPopover v-model="openPopover" :popover-balloon-props="{ maxHeight: calculatedMaxHeight }">
|
|
4
|
+
<template #trigger>
|
|
5
|
+
<UnnnicInput :model-value="inputValue" class="unnnic-select__input" readonly
|
|
6
|
+
:forceActiveStatus="openPopover" :size="props.size" :placeholder="props.placeholder"
|
|
7
|
+
:label="props.label" :errors="props.errors" :message="props.message"
|
|
8
|
+
:iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'" :disabled="props.disabled"
|
|
9
|
+
showClear @clear="emit('update:modelValue', '')"
|
|
10
|
+
/>
|
|
11
|
+
</template>
|
|
12
|
+
<template #content>
|
|
13
|
+
<div class="unnnic-select__content">
|
|
14
|
+
<UnnnicInput v-if="props.enableSearch" class="unnnic-select__input-search"
|
|
15
|
+
:modelValue="props.search" :placeholder="$t('search')" iconLeft="search"
|
|
16
|
+
@update:modelValue="handleSearch" />
|
|
17
|
+
<UnnnicSelectOption v-for="(option, index) in filteredOptions" :key="option[props.itemValue]"
|
|
18
|
+
:data-option-index="index"
|
|
19
|
+
:label="option[props.itemLabel]"
|
|
20
|
+
:active="option[props.itemValue] === selectedItem?.[props.itemValue]"
|
|
21
|
+
:focused="focusedOptionIndex === index"
|
|
22
|
+
:disabled="option.disabled" @click="handleSelectOption(option)" />
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
</UnnnicPopover>
|
|
26
|
+
</div>
|
|
53
27
|
</template>
|
|
54
28
|
|
|
55
29
|
<script setup lang="ts">
|
|
@@ -60,186 +34,162 @@ import UnnnicSelectOption from './SelectOption.vue';
|
|
|
60
34
|
import UnnnicI18n from '../../mixins/i18n';
|
|
61
35
|
|
|
62
36
|
defineOptions({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
37
|
+
name: "UnnnicSelect",
|
|
38
|
+
mixins: [UnnnicI18n]
|
|
39
|
+
})
|
|
66
40
|
|
|
67
41
|
interface SelectProps {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
options: Array<{ [key: string]: any }>;
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
modelValue: any;
|
|
46
|
+
returnObject?: boolean;
|
|
47
|
+
itemLabel?: string;
|
|
48
|
+
itemValue?: string;
|
|
49
|
+
placeholder?: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
type?: 'normal' | 'error';
|
|
52
|
+
errors?: string | Array<string>;
|
|
53
|
+
message?: string;
|
|
54
|
+
size?: 'sm' | 'md';
|
|
55
|
+
optionsLines?: number;
|
|
56
|
+
enableSearch?: boolean;
|
|
57
|
+
search?: string;
|
|
58
|
+
locale?: string;
|
|
59
|
+
disabled?: boolean;
|
|
86
60
|
}
|
|
87
61
|
|
|
88
62
|
const props = withDefaults(defineProps<SelectProps>(), {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
63
|
+
size: 'md',
|
|
64
|
+
type: 'normal',
|
|
65
|
+
placeholder: '',
|
|
66
|
+
optionsLines: 5,
|
|
67
|
+
returnObject: false,
|
|
68
|
+
itemLabel: 'label',
|
|
69
|
+
itemValue: 'value',
|
|
70
|
+
locale: 'en',
|
|
71
|
+
enableSearch: false,
|
|
72
|
+
disabled: false,
|
|
73
|
+
})
|
|
100
74
|
|
|
101
75
|
const emit = defineEmits<{
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}>()
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
'update:modelValue': [value: any]
|
|
78
|
+
'update:search': [value: string]
|
|
79
|
+
}>()
|
|
106
80
|
|
|
107
|
-
const openPopover = ref(false)
|
|
81
|
+
const openPopover = ref(false)
|
|
108
82
|
|
|
109
83
|
watch(openPopover, () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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);
|
|
84
|
+
if (!openPopover.value) {
|
|
85
|
+
handleSearch('')
|
|
86
|
+
} else {
|
|
87
|
+
focusedOptionIndex.value = -1
|
|
139
88
|
}
|
|
140
|
-
|
|
141
|
-
|
|
89
|
+
|
|
90
|
+
if(openPopover.value && props.modelValue) {
|
|
91
|
+
const selectedOptionIndex = props.options.findIndex(option => option[props.itemValue] === selectedItem.value[props.itemValue])
|
|
92
|
+
scrollToOption(selectedOptionIndex, "instant", 'center')
|
|
142
93
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const handleKeyDown = (event) => {
|
|
97
|
+
const { key } = event
|
|
98
|
+
const validKeys = ['ArrowUp', 'ArrowDown', 'Enter']
|
|
99
|
+
if (validKeys.includes(key)) {
|
|
100
|
+
event.preventDefault()
|
|
101
|
+
if (key === 'ArrowUp') {
|
|
102
|
+
if(focusedOptionIndex.value === 0) return
|
|
103
|
+
focusedOptionIndex.value--
|
|
104
|
+
scrollToOption(focusedOptionIndex.value)
|
|
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
|
+
}
|
|
157
114
|
}
|
|
158
|
-
|
|
159
|
-
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const focusedOptionIndex = ref<number>(-1)
|
|
118
|
+
|
|
119
|
+
const scrollToOption = (index: number, behavior: 'smooth' | 'instant' = 'smooth', block: 'center' | 'start' | 'end' | 'nearest' = 'center') => {
|
|
120
|
+
nextTick(() => {
|
|
121
|
+
const option = document.querySelector(`[data-option-index="${index}"]`)
|
|
122
|
+
if (option) {
|
|
123
|
+
option.scrollIntoView({ behavior, block })
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
160
127
|
|
|
161
128
|
const calculatedMaxHeight = computed(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
129
|
+
if (!props.options || props.options.length === 0) return 'unset'
|
|
130
|
+
const popoverPadding = 32
|
|
131
|
+
const popoverGap = 4
|
|
132
|
+
// 37 = 21px (height) + 16px (padding)
|
|
133
|
+
const fieldsHeight = (37 * props.optionsLines)
|
|
134
|
+
const size = fieldsHeight + popoverPadding + (popoverGap * props.optionsLines - 2)
|
|
135
|
+
return `${props.enableSearch ? size + 54 : size}px`
|
|
136
|
+
})
|
|
171
137
|
|
|
172
138
|
const selectedItem = computed(() => {
|
|
173
|
-
|
|
139
|
+
if (props.returnObject) return props.modelValue
|
|
174
140
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
);
|
|
178
|
-
});
|
|
141
|
+
return props.options.find(option => option[props.itemValue] === props.modelValue)
|
|
142
|
+
})
|
|
179
143
|
|
|
180
144
|
const inputValue = computed(() => {
|
|
181
|
-
|
|
182
|
-
})
|
|
145
|
+
return selectedItem.value?.[props.itemLabel]
|
|
146
|
+
})
|
|
183
147
|
|
|
184
148
|
const handleSelectOption = (option) => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
option.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
emit(
|
|
192
|
-
'update:modelValue',
|
|
193
|
-
props.returnObject ? option : option[props.itemValue],
|
|
194
|
-
);
|
|
195
|
-
openPopover.value = false;
|
|
196
|
-
};
|
|
149
|
+
if (option[props.itemValue] === selectedItem.value?.[props.itemValue] || option.disabled) return
|
|
150
|
+
|
|
151
|
+
emit('update:modelValue', props.returnObject ? option : option[props.itemValue])
|
|
152
|
+
openPopover.value = false
|
|
153
|
+
}
|
|
197
154
|
|
|
198
155
|
const handleSearch = (value: string) => {
|
|
199
|
-
|
|
200
|
-
}
|
|
156
|
+
emit('update:search', value)
|
|
157
|
+
}
|
|
201
158
|
|
|
202
159
|
const filteredOptions = computed(() => {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.toLowerCase()
|
|
209
|
-
.includes(props.search?.toLowerCase()) ||
|
|
210
|
-
option[props.itemValue]
|
|
211
|
-
.toLowerCase()
|
|
212
|
-
.includes(props.search?.toLowerCase()),
|
|
213
|
-
);
|
|
214
|
-
});
|
|
160
|
+
if (!props.enableSearch || !props.search) return props.options
|
|
161
|
+
|
|
162
|
+
return props.options.filter(option => option[props.itemLabel].toLowerCase().includes(props.search?.toLowerCase()) || option[props.itemValue].toLowerCase().includes(props.search?.toLowerCase()))
|
|
163
|
+
})
|
|
164
|
+
|
|
215
165
|
</script>
|
|
216
166
|
|
|
217
167
|
<style lang="scss" scoped>
|
|
218
168
|
@use '@/assets/scss/unnnic' as *;
|
|
219
169
|
|
|
220
170
|
:deep(.unnnic-select__input) {
|
|
221
|
-
|
|
171
|
+
cursor: pointer;
|
|
222
172
|
}
|
|
223
173
|
|
|
224
174
|
:deep(.unnnic-select__input-search) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
175
|
+
>.icon-left {
|
|
176
|
+
color: $unnnic-color-fg-base;
|
|
177
|
+
}
|
|
228
178
|
}
|
|
229
179
|
|
|
230
180
|
:deep(.unnnic-select__input) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
181
|
+
>.icon-right {
|
|
182
|
+
color: $unnnic-color-fg-base;
|
|
183
|
+
}
|
|
234
184
|
}
|
|
235
185
|
|
|
236
186
|
.unnnic-select {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
187
|
+
&__content {
|
|
188
|
+
display: flex;
|
|
189
|
+
flex-direction: column;
|
|
190
|
+
padding: 0;
|
|
191
|
+
margin: 0;
|
|
192
|
+
gap: $unnnic-space-1;
|
|
193
|
+
}
|
|
244
194
|
}
|
|
245
|
-
</style>
|
|
195
|
+
</style>
|
|
@@ -75,10 +75,7 @@
|
|
|
75
75
|
{{ template?.footer }}
|
|
76
76
|
</footer>
|
|
77
77
|
</section>
|
|
78
|
-
<footer
|
|
79
|
-
v-if="hasButtons"
|
|
80
|
-
class="unnnic-template-preview__buttons"
|
|
81
|
-
>
|
|
78
|
+
<footer v-if="hasButtons" class="unnnic-template-preview__buttons">
|
|
82
79
|
<section
|
|
83
80
|
v-for="(button, index) in template?.buttons"
|
|
84
81
|
:key="`button-${index}`"
|
|
@@ -99,15 +96,15 @@
|
|
|
99
96
|
</template>
|
|
100
97
|
|
|
101
98
|
<script lang="ts" setup>
|
|
102
|
-
import { computed } from
|
|
99
|
+
import { computed } from "vue";
|
|
103
100
|
|
|
104
|
-
import type { Template } from
|
|
101
|
+
import type { Template } from "./types";
|
|
105
102
|
|
|
106
|
-
import imagePreview from
|
|
107
|
-
import documentPreview from
|
|
108
|
-
import videoPreview from
|
|
103
|
+
import imagePreview from "../../assets/img/previews/image-preview.png";
|
|
104
|
+
import documentPreview from "../../assets/img/previews/doc-preview.png";
|
|
105
|
+
import videoPreview from "../../assets/img/previews/video-preview.png";
|
|
109
106
|
|
|
110
|
-
import UnnnicIcon from
|
|
107
|
+
import UnnnicIcon from "../Icon.vue";
|
|
111
108
|
|
|
112
109
|
interface Props {
|
|
113
110
|
template?: Template | null;
|
|
@@ -118,30 +115,30 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
118
115
|
});
|
|
119
116
|
|
|
120
117
|
const hasHeader = computed(
|
|
121
|
-
() => props.template?.header && props.template.header.type
|
|
118
|
+
() => props.template?.header && props.template.header.type
|
|
122
119
|
);
|
|
123
120
|
const hasHeaderMedia = computed(
|
|
124
|
-
() => !!props.template?.header && props.template.header.type ===
|
|
121
|
+
() => !!props.template?.header && props.template.header.type === "MEDIA"
|
|
125
122
|
);
|
|
126
123
|
const hasBody = computed(
|
|
127
|
-
() => !!props.template?.body && props.template.body.length > 0
|
|
124
|
+
() => !!props.template?.body && props.template.body.length > 0
|
|
128
125
|
);
|
|
129
126
|
const hasFooter = computed(
|
|
130
|
-
() => !!props.template?.footer && props.template.footer.length > 0
|
|
127
|
+
() => !!props.template?.footer && props.template.footer.length > 0
|
|
131
128
|
);
|
|
132
129
|
const hasButtons = computed(
|
|
133
|
-
() => !!props.template?.buttons && props.template.buttons.length > 0
|
|
130
|
+
() => !!props.template?.buttons && props.template.buttons.length > 0
|
|
134
131
|
);
|
|
135
132
|
const parsedBody = computed(() => {
|
|
136
|
-
if (!hasBody.value) return
|
|
133
|
+
if (!hasBody.value) return "";
|
|
137
134
|
|
|
138
135
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
139
136
|
const result = props
|
|
140
|
-
.template!.body!.replaceAll(
|
|
141
|
-
.replaceAll(/(?:\*)([^*<\n]+)(?:\*)/g,
|
|
142
|
-
.replaceAll(/(?:_)([^_<\n]+)(?:_)/g,
|
|
143
|
-
.replaceAll(/(?:~)([^~<\n]+)(?:~)/g,
|
|
144
|
-
.replaceAll(/(?:```)([^```<\n]+)(?:```)/g,
|
|
137
|
+
.template!.body!.replaceAll("\n", "<br/>")
|
|
138
|
+
.replaceAll(/(?:\*)([^*<\n]+)(?:\*)/g, "<strong>$1</strong>")
|
|
139
|
+
.replaceAll(/(?:_)([^_<\n]+)(?:_)/g, "<i>$1</i>")
|
|
140
|
+
.replaceAll(/(?:~)([^~<\n]+)(?:~)/g, "<s>$1</s>")
|
|
141
|
+
.replaceAll(/(?:```)([^```<\n]+)(?:```)/g, "<tt>$1</tt>")
|
|
145
142
|
.replaceAll(/{{.*?}}/g, (match) => `<strong>${match}</strong>`);
|
|
146
143
|
|
|
147
144
|
return result;
|
|
@@ -149,19 +146,19 @@ const parsedBody = computed(() => {
|
|
|
149
146
|
|
|
150
147
|
const getButtonIcon = (buttonType) => {
|
|
151
148
|
const buttonMapper = {
|
|
152
|
-
PHONE_NUMBER:
|
|
153
|
-
URL:
|
|
154
|
-
COPY_CODE:
|
|
155
|
-
FLOW:
|
|
156
|
-
QUICK_REPLY:
|
|
149
|
+
PHONE_NUMBER: "phone",
|
|
150
|
+
URL: "open_in_new",
|
|
151
|
+
COPY_CODE: "content_copy",
|
|
152
|
+
FLOW: "",
|
|
153
|
+
QUICK_REPLY: "reply",
|
|
157
154
|
};
|
|
158
155
|
|
|
159
|
-
return buttonMapper[buttonType] ||
|
|
156
|
+
return buttonMapper[buttonType] || "";
|
|
160
157
|
};
|
|
161
158
|
</script>
|
|
162
159
|
|
|
163
160
|
<style lang="scss" scoped>
|
|
164
|
-
@use
|
|
161
|
+
@use "@/assets/scss/unnnic" as *;
|
|
165
162
|
|
|
166
163
|
.unnnic-template-preview {
|
|
167
164
|
display: flex;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<UnnnicModalDialog
|
|
3
|
-
:
|
|
3
|
+
:model-value="modelValue"
|
|
4
4
|
@update:modelValue="$event === false && $emit('close')"
|
|
5
5
|
:title="defaultTranslations.title[props.locale]"
|
|
6
|
-
:
|
|
6
|
+
:show-close-icon="true"
|
|
7
7
|
class="unnnic-template-preview-modal"
|
|
8
8
|
>
|
|
9
9
|
<UnnnicTemplatePreview :template="template" />
|
|
@@ -11,16 +11,16 @@
|
|
|
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,7 +36,13 @@ export default {
|
|
|
36
36
|
argTypes: {
|
|
37
37
|
type: {
|
|
38
38
|
control: { type: 'select' },
|
|
39
|
-
options: [
|
|
39
|
+
options: [
|
|
40
|
+
'primary',
|
|
41
|
+
'secondary',
|
|
42
|
+
'tertiary',
|
|
43
|
+
'warning',
|
|
44
|
+
'attention',
|
|
45
|
+
],
|
|
40
46
|
},
|
|
41
47
|
size: {
|
|
42
48
|
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
|
+
}
|