@weni/unnnic-system 3.12.2 → 3.12.3-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/dist/components/Alert/Alert.vue.d.ts +3 -3
- package/dist/components/Alert/Version1dot1.vue.d.ts +1 -1
- package/dist/components/AudioRecorder/AudioHandler.vue.d.ts +92 -18
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +184 -36
- package/dist/components/AvatarIcon/AvatarIcon.vue.d.ts +1 -1
- package/dist/components/Button/Button.vue.d.ts +2 -2
- package/dist/components/Card/AccountCard.vue.d.ts +2 -2
- package/dist/components/Card/Card.vue.d.ts +103 -29
- package/dist/components/Card/CardCompany.vue.d.ts +2 -2
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +93 -19
- package/dist/components/Card/ContentCard.vue.d.ts +1 -1
- package/dist/components/Card/DashCard.vue.d.ts +2 -2
- package/dist/components/Card/DefaultCard.vue.d.ts +1 -1
- package/dist/components/Card/MarketplaceCard.vue.d.ts +1 -1
- package/dist/components/Card/SimpleCard.vue.d.ts +92 -18
- package/dist/components/Card/StatusCard.vue.d.ts +1 -1
- package/dist/components/Card/TitleCard.vue.d.ts +92 -18
- package/dist/components/CardImage/CardImage.vue.d.ts +5 -5
- package/dist/components/CardInformation/CardInformation.vue.d.ts +93 -19
- package/dist/components/CardProject/CardProject.vue.d.ts +2 -2
- package/dist/components/Carousel/Carousel.vue.d.ts +2 -2
- package/dist/components/Carousel/TagCarousel.vue.d.ts +2 -2
- package/dist/components/ChartBar/ChartBar.vue.d.ts +98 -24
- package/dist/components/ChartLine/ChartLine.vue.d.ts +92 -18
- package/dist/components/ChatText/ChatText.vue.d.ts +92 -18
- package/dist/components/ChatsContact/ChatsContact.vue.d.ts +6 -6
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +92 -18
- package/dist/components/ChatsUserAvatar/ChatsUserAvatar.vue.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.vue.d.ts +3 -3
- package/dist/components/DataArea/DataArea.vue.d.ts +92 -18
- 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 +94 -15
- package/dist/components/Drawer/Drawer.vue.d.ts +37 -207
- package/dist/components/Drawer/Drawer.vue.d.ts.map +1 -1
- package/dist/components/Dropdown/Dropdown.vue.d.ts +1 -1
- package/dist/components/FormElement/FormElement.vue.d.ts +6 -6
- package/dist/components/ImportCard/ImportCard.vue.d.ts +6 -6
- package/dist/components/Input/BaseInput.vue.d.ts +22 -0
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +93 -14
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +54 -3
- package/dist/components/Input/TextInput.vue.d.ts.map +1 -1
- package/dist/components/InputNext/InputNext.vue.d.ts +4 -4
- package/dist/components/Label/Label.vue.d.ts +1 -1
- package/dist/components/Label/Label.vue.d.ts.map +1 -1
- package/dist/components/Modal/Modal.vue.d.ts +1 -1
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts +209 -35
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +99 -20
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +12 -12
- package/dist/components/MoodRating/MoodRating.vue.d.ts +92 -18
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +18 -18
- package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
- package/dist/components/Radio/Radio.vue.d.ts +6 -6
- package/dist/components/Select/index.vue.d.ts +44 -0
- package/dist/components/Select/index.vue.d.ts.map +1 -0
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +63 -12
- package/dist/components/SelectSmart/SelectSmartMultipleHeader.vue.d.ts +2 -2
- package/dist/components/SelectSmart/SelectSmartOption.vue.d.ts +5 -5
- package/dist/components/SelectTime/index.vue.d.ts +55 -4
- package/dist/components/Slider/Slider.vue.d.ts +92 -18
- package/dist/components/Switch/Switch.vue.d.ts +3 -3
- package/dist/components/Tab/Tab.vue.d.ts +92 -18
- package/dist/components/TableNext/TableBodyCell.vue.d.ts +2 -2
- package/dist/components/TableNext/TablePagination.vue.d.ts +6 -6
- package/dist/components/Tag/DefaultTag.vue.d.ts +1 -1
- package/dist/components/Tag/Tag.vue.d.ts +2 -2
- package/dist/components/TextArea/TextArea.vue.d.ts +8 -8
- package/dist/components/Toast/Toast.vue.d.ts +1 -1
- package/dist/components/Toast/Toast.vue.d.ts.map +1 -1
- package/dist/components/ToolTip/ToolTip.vue.d.ts +92 -18
- package/dist/components/ToolTip/ToolTip.vue.d.ts.map +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 +6 -6
- package/dist/components/ui/dialog/Dialog.vue.d.ts +23 -0
- package/dist/components/ui/dialog/Dialog.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +19 -0
- package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +43 -0
- package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +25 -0
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +29 -0
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +23 -0
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +19 -0
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +1 -0
- package/dist/components/ui/dialog/index.d.ts +8 -0
- package/dist/components/ui/dialog/index.d.ts.map +1 -0
- package/dist/components/ui/drawer/Drawer.vue.d.ts +35 -0
- package/dist/components/ui/drawer/Drawer.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts +19 -0
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +43 -0
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +23 -0
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +22 -0
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +25 -0
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +8 -0
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +23 -0
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts +19 -0
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts.map +1 -0
- package/dist/components/ui/drawer/index.d.ts +11 -0
- package/dist/components/ui/drawer/index.d.ts.map +1 -0
- package/dist/components/ui/popover/PopoverContent.vue.d.ts +2 -2
- package/dist/components/ui/popover/PopoverContent.vue.d.ts.map +1 -1
- package/dist/components/ui/popover/PopoverOption.vue.d.ts +1 -1
- package/dist/components/ui/popover/PopoverOption.vue.d.ts.map +1 -1
- package/dist/components/ui/popover/PopoverTrigger.vue.d.ts.map +1 -1
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts +23 -0
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts.map +1 -0
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +31 -0
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +1 -0
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts +19 -0
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts.map +1 -0
- package/dist/components/ui/tooltip/index.d.ts +4 -0
- package/dist/components/ui/tooltip/index.d.ts.map +1 -0
- package/dist/{es-40d7aad6.mjs → es-59933601.mjs} +1 -1
- package/dist/{index-56b50ff8.mjs → index-4fe9253b.mjs} +99820 -96757
- package/dist/lib/layer-manager.d.ts +16 -0
- package/dist/lib/layer-manager.d.ts.map +1 -0
- 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-e6e2313f.mjs → pt-br-10db3200.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +234 -204
- package/dist/unnnic.umd.js +48 -44
- package/package.json +3 -2
- package/src/assets/scss/scheme-colors.scss +223 -223
- package/src/assets/scss/tailwind.scss +8 -0
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
- package/src/components/Checkbox/Checkbox.vue +1 -1
- package/src/components/Drawer/Drawer.vue +190 -269
- package/src/components/Drawer/__tests__/Drawer.spec.js +37 -46
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +18 -19
- package/src/components/Input/BaseInput.vue +21 -2
- package/src/components/Input/Input.scss +2 -3
- package/src/components/Input/Input.vue +19 -1
- package/src/components/Input/TextInput.vue +58 -22
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +5 -1
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +7 -1
- package/src/components/ModalDialog/ModalDialog.vue +64 -148
- package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +11 -221
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +1 -22
- package/src/components/MultiSelectV2/MultSelectOption.vue +67 -0
- package/src/components/MultiSelectV2/__tests__/MultiSelect.spec.js +556 -0
- package/src/components/MultiSelectV2/__tests__/MultiSelectOption.spec.js +229 -0
- package/src/components/MultiSelectV2/__tests__/__snapshots__/MultiSelect.spec.js.snap +121 -0
- package/src/components/MultiSelectV2/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +51 -0
- package/src/components/MultiSelectV2/index.vue +224 -0
- package/src/components/Select/__tests__/Select.spec.js +422 -0
- package/src/components/Select/__tests__/SelectItem.spec.js +330 -0
- package/src/components/Select/__tests__/__snapshots__/Popover.spec.js.snap +8 -0
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +65 -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/__tests__/__snapshots__/SelectPopover.spec.js.snap +8 -0
- package/src/components/Select/index.vue +261 -0
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +3 -1
- package/src/components/Toast/Toast.vue +16 -9
- package/src/components/ToolTip/ToolTip.vue +25 -177
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +339 -61
- package/src/components/index.ts +60 -4
- package/src/components/ui/dialog/Dialog.vue +19 -0
- package/src/components/ui/dialog/DialogClose.vue +29 -0
- package/src/components/ui/dialog/DialogContent.vue +140 -0
- package/src/components/ui/dialog/DialogFooter.vue +50 -0
- package/src/components/ui/dialog/DialogHeader.vue +83 -0
- package/src/components/ui/dialog/DialogTitle.vue +38 -0
- package/src/components/ui/dialog/DialogTrigger.vue +16 -0
- package/src/components/ui/dialog/index.ts +7 -0
- package/src/components/ui/drawer/Drawer.vue +27 -0
- package/src/components/ui/drawer/DrawerClose.vue +37 -0
- package/src/components/ui/drawer/DrawerContent.vue +111 -0
- package/src/components/ui/drawer/DrawerDescription.vue +40 -0
- package/src/components/ui/drawer/DrawerFooter.vue +38 -0
- package/src/components/ui/drawer/DrawerHeader.vue +57 -0
- package/src/components/ui/drawer/DrawerOverlay.vue +33 -0
- package/src/components/ui/drawer/DrawerTitle.vue +37 -0
- package/src/components/ui/drawer/DrawerTrigger.vue +31 -0
- package/src/components/ui/drawer/index.ts +10 -0
- package/src/components/ui/popover/PopoverContent.vue +4 -2
- package/src/components/ui/popover/PopoverOption.vue +4 -0
- package/src/components/ui/popover/PopoverTrigger.vue +5 -1
- package/src/components/ui/tooltip/Tooltip.vue +21 -0
- package/src/components/ui/tooltip/TooltipContent.vue +74 -0
- package/src/components/ui/tooltip/TooltipTrigger.vue +26 -0
- package/src/components/ui/tooltip/index.ts +3 -0
- package/src/lib/layer-manager.ts +84 -0
- 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/Dialog.stories.js +832 -0
- package/src/stories/Drawer.stories.js +1 -1
- package/src/stories/DrawerNext.stories.js +611 -0
- package/src/stories/LayerManager.docs.mdx +40 -0
- package/src/stories/LayerManager.stories.js +364 -0
- package/src/stories/ModalDialog.mdx +3 -0
- package/src/stories/ModalDialog.stories.js +1 -1
- package/src/stories/MultiSelectV2.stories.js +158 -0
- package/src/stories/Select.stories.js +158 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="unnnic-select"
|
|
4
|
+
@keydown="handleKeyDown"
|
|
5
|
+
>
|
|
6
|
+
<Popover
|
|
7
|
+
:open="openPopover"
|
|
8
|
+
@update:open="openPopover = $event"
|
|
9
|
+
>
|
|
10
|
+
<PopoverTrigger>
|
|
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
|
+
</PopoverTrigger>
|
|
27
|
+
<PopoverContent
|
|
28
|
+
align="start"
|
|
29
|
+
:style="{
|
|
30
|
+
maxHeight: calculatedMaxHeight,
|
|
31
|
+
overflow: 'auto',
|
|
32
|
+
}"
|
|
33
|
+
>
|
|
34
|
+
<div class="unnnic-select__content">
|
|
35
|
+
<UnnnicInput
|
|
36
|
+
v-if="props.enableSearch"
|
|
37
|
+
class="unnnic-select__input-search"
|
|
38
|
+
:modelValue="props.search"
|
|
39
|
+
:placeholder="$t('search')"
|
|
40
|
+
iconLeft="search"
|
|
41
|
+
@update:model-value="handleSearch"
|
|
42
|
+
/>
|
|
43
|
+
<PopoverOption
|
|
44
|
+
v-for="(option, index) in filteredOptions"
|
|
45
|
+
:key="option[props.itemValue]"
|
|
46
|
+
:data-option-index="index"
|
|
47
|
+
data-testid="select-option"
|
|
48
|
+
:label="option[props.itemLabel]"
|
|
49
|
+
:active="
|
|
50
|
+
option[props.itemValue] === selectedItem?.[props.itemValue]
|
|
51
|
+
"
|
|
52
|
+
:focused="focusedOptionIndex === index"
|
|
53
|
+
:disabled="option.disabled"
|
|
54
|
+
@click="handleSelectOption(option)"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
</PopoverContent>
|
|
58
|
+
</Popover>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { computed, ref, watch, nextTick } from 'vue';
|
|
64
|
+
import UnnnicInput from '../Input/Input.vue';
|
|
65
|
+
|
|
66
|
+
import {
|
|
67
|
+
Popover,
|
|
68
|
+
PopoverTrigger,
|
|
69
|
+
PopoverContent,
|
|
70
|
+
PopoverOption,
|
|
71
|
+
} from '../ui/popover/index';
|
|
72
|
+
import UnnnicI18n from '../../mixins/i18n';
|
|
73
|
+
|
|
74
|
+
defineOptions({
|
|
75
|
+
name: 'UnnnicSelect',
|
|
76
|
+
mixins: [UnnnicI18n],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
interface SelectProps {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
options: Array<{ [key: string]: any }>;
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
modelValue: any;
|
|
84
|
+
returnObject?: boolean;
|
|
85
|
+
itemLabel?: string;
|
|
86
|
+
itemValue?: string;
|
|
87
|
+
placeholder?: string;
|
|
88
|
+
label?: string;
|
|
89
|
+
type?: 'normal' | 'error';
|
|
90
|
+
errors?: string | Array<string>;
|
|
91
|
+
message?: string;
|
|
92
|
+
size?: 'sm' | 'md';
|
|
93
|
+
optionsLines?: number;
|
|
94
|
+
enableSearch?: boolean;
|
|
95
|
+
search?: string;
|
|
96
|
+
locale?: string;
|
|
97
|
+
disabled?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const props = withDefaults(defineProps<SelectProps>(), {
|
|
101
|
+
size: 'md',
|
|
102
|
+
type: 'normal',
|
|
103
|
+
placeholder: '',
|
|
104
|
+
optionsLines: 5,
|
|
105
|
+
returnObject: false,
|
|
106
|
+
itemLabel: 'label',
|
|
107
|
+
itemValue: 'value',
|
|
108
|
+
locale: 'en',
|
|
109
|
+
enableSearch: false,
|
|
110
|
+
disabled: false,
|
|
111
|
+
label: '',
|
|
112
|
+
errors: '',
|
|
113
|
+
message: '',
|
|
114
|
+
search: '',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const emit = defineEmits<{
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
+
'update:modelValue': [value: any];
|
|
120
|
+
'update:search': [value: string];
|
|
121
|
+
}>();
|
|
122
|
+
|
|
123
|
+
const openPopover = ref(false);
|
|
124
|
+
|
|
125
|
+
watch(openPopover, () => {
|
|
126
|
+
if (!openPopover.value) {
|
|
127
|
+
handleSearch('');
|
|
128
|
+
} else {
|
|
129
|
+
focusedOptionIndex.value = -1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (openPopover.value && props.modelValue) {
|
|
133
|
+
const selectedOptionIndex = props.options.findIndex(
|
|
134
|
+
(option) =>
|
|
135
|
+
option[props.itemValue] === selectedItem.value?.[props.itemValue],
|
|
136
|
+
);
|
|
137
|
+
scrollToOption(selectedOptionIndex, 'instant', 'center');
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const handleKeyDown = (event) => {
|
|
142
|
+
const { key } = event;
|
|
143
|
+
const validKeys = ['ArrowUp', 'ArrowDown', 'Enter'];
|
|
144
|
+
if (validKeys.includes(key)) {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
if (key === 'ArrowUp') {
|
|
147
|
+
if (focusedOptionIndex.value === 0) return;
|
|
148
|
+
focusedOptionIndex.value--;
|
|
149
|
+
scrollToOption(focusedOptionIndex.value);
|
|
150
|
+
}
|
|
151
|
+
if (key === 'ArrowDown') {
|
|
152
|
+
if (focusedOptionIndex.value === filteredOptions.value.length - 1) return;
|
|
153
|
+
focusedOptionIndex.value++;
|
|
154
|
+
scrollToOption(focusedOptionIndex.value);
|
|
155
|
+
}
|
|
156
|
+
if (key === 'Enter') {
|
|
157
|
+
handleSelectOption(filteredOptions.value[focusedOptionIndex.value]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const focusedOptionIndex = ref<number>(-1);
|
|
163
|
+
|
|
164
|
+
const scrollToOption = (
|
|
165
|
+
index: number,
|
|
166
|
+
behavior: 'smooth' | 'instant' = 'smooth',
|
|
167
|
+
block: 'center' | 'start' | 'end' | 'nearest' = 'center',
|
|
168
|
+
) => {
|
|
169
|
+
nextTick(() => {
|
|
170
|
+
const option = document.querySelector(`[data-option-index="${index}"]`);
|
|
171
|
+
if (option) {
|
|
172
|
+
option.scrollIntoView?.({ behavior, block });
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const calculatedMaxHeight = computed(() => {
|
|
178
|
+
if (!props.options || props.options.length === 0) return 'unset';
|
|
179
|
+
const popoverPadding = 32;
|
|
180
|
+
const popoverGap = 4;
|
|
181
|
+
// 37 = 21px (height) + 16px (padding)
|
|
182
|
+
const fieldsHeight = 37 * props.optionsLines;
|
|
183
|
+
const size =
|
|
184
|
+
fieldsHeight + popoverPadding + (popoverGap * props.optionsLines - 2);
|
|
185
|
+
return `${props.enableSearch ? size + 54 : size}px`;
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const selectedItem = computed(() => {
|
|
189
|
+
if (props.returnObject) return props.modelValue;
|
|
190
|
+
|
|
191
|
+
return props.options.find(
|
|
192
|
+
(option) => option[props.itemValue] === props.modelValue,
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const inputValue = computed(() => {
|
|
197
|
+
return selectedItem.value?.[props.itemLabel];
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const handleSelectOption = (option) => {
|
|
201
|
+
if (
|
|
202
|
+
option[props.itemValue] === selectedItem.value?.[props.itemValue] ||
|
|
203
|
+
option.disabled
|
|
204
|
+
)
|
|
205
|
+
return;
|
|
206
|
+
|
|
207
|
+
emit(
|
|
208
|
+
'update:modelValue',
|
|
209
|
+
props.returnObject ? option : option[props.itemValue],
|
|
210
|
+
);
|
|
211
|
+
openPopover.value = false;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const handleSearch = (value: string) => {
|
|
215
|
+
emit('update:search', value);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const filteredOptions = computed(() => {
|
|
219
|
+
if (!props.enableSearch || !props.search) return props.options;
|
|
220
|
+
|
|
221
|
+
return props.options.filter(
|
|
222
|
+
(option) =>
|
|
223
|
+
option[props.itemLabel]
|
|
224
|
+
.toLowerCase()
|
|
225
|
+
.includes(props.search?.toLowerCase()) ||
|
|
226
|
+
option[props.itemValue]
|
|
227
|
+
.toLowerCase()
|
|
228
|
+
.includes(props.search?.toLowerCase()),
|
|
229
|
+
);
|
|
230
|
+
});
|
|
231
|
+
</script>
|
|
232
|
+
|
|
233
|
+
<style lang="scss" scoped>
|
|
234
|
+
@use '@/assets/scss/unnnic' as *;
|
|
235
|
+
|
|
236
|
+
:deep(.unnnic-select__input) {
|
|
237
|
+
cursor: pointer;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
:deep(.unnnic-select__input-search) {
|
|
241
|
+
> .icon-left {
|
|
242
|
+
color: $unnnic-color-fg-base;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
:deep(.unnnic-select__input) {
|
|
247
|
+
> .icon-right {
|
|
248
|
+
color: $unnnic-color-fg-base;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.unnnic-select {
|
|
253
|
+
&__content {
|
|
254
|
+
display: flex;
|
|
255
|
+
flex-direction: column;
|
|
256
|
+
padding: 0;
|
|
257
|
+
margin: 0;
|
|
258
|
+
gap: $unnnic-space-1;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
</style>
|
|
@@ -4,7 +4,9 @@ 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-
|
|
7
|
+
<li data-v-b4e39fac="" class="tab-head">tab1<div data-v-b3d24f2b="" class="unnnic-tooltip-trigger" data-testid="tooltip-trigger" data-state="closed" data-grace-area-trigger=""><span data-v-26446d8e="" data-v-b4e39fac="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--sm unnnic-icon__size--sm" data-testid="material-icon" translate="no">help</span></div>
|
|
8
|
+
<!--teleport start-->
|
|
9
|
+
<!--teleport end-->
|
|
8
10
|
</li>
|
|
9
11
|
<li data-v-b4e39fac="" class="tab-head tab-head--active">tab2
|
|
10
12
|
<!--v-if-->
|
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
>
|
|
8
8
|
<aside
|
|
9
9
|
v-if="isVisible"
|
|
10
|
-
:class="['unnnic-toast', `unnnic-toast--${
|
|
11
|
-
:role="
|
|
12
|
-
:aria-live="
|
|
10
|
+
:class="['unnnic-toast', `unnnic-toast--${validType}`]"
|
|
11
|
+
:role="validType === 'error' ? 'alert' : 'status'"
|
|
12
|
+
:aria-live="validType === 'error' ? 'assertive' : 'polite'"
|
|
13
13
|
data-testid="toast"
|
|
14
|
+
:style="{ zIndex: toastZIndex }"
|
|
14
15
|
>
|
|
15
16
|
<section
|
|
16
17
|
class="unnnic-toast__content"
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
>
|
|
23
24
|
<UnnnicIcon
|
|
24
25
|
:icon="typeConfig.icon"
|
|
25
|
-
:scheme="typeConfig.scheme"
|
|
26
|
+
:scheme="typeConfig.scheme as SchemeColor"
|
|
26
27
|
size="ant"
|
|
27
28
|
data-testid="toast-type-icon"
|
|
28
29
|
/>
|
|
@@ -74,6 +75,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue';
|
|
|
74
75
|
|
|
75
76
|
import UnnnicIcon from '@/components/Icon.vue';
|
|
76
77
|
import UnnnicButton from '@/components/Button/Button.vue';
|
|
78
|
+
import { useLayerZIndex } from '@/lib/layer-manager';
|
|
77
79
|
|
|
78
80
|
import type { ToastProps, ToastEmits } from './types';
|
|
79
81
|
import type { SchemeColor } from '@/types/scheme-colors';
|
|
@@ -95,6 +97,13 @@ const emit = defineEmits<ToastEmits>();
|
|
|
95
97
|
const isVisible = ref(false);
|
|
96
98
|
let timeoutId: number | null = null;
|
|
97
99
|
|
|
100
|
+
const validType = computed(() => {
|
|
101
|
+
if (['informational', 'attention', 'success', 'error'].includes(props.type)) {
|
|
102
|
+
return props.type;
|
|
103
|
+
}
|
|
104
|
+
return 'informational';
|
|
105
|
+
});
|
|
106
|
+
|
|
98
107
|
const typeConfig = computed(() => {
|
|
99
108
|
const configMap = {
|
|
100
109
|
informational: { icon: 'info', scheme: 'blue-500' },
|
|
@@ -103,12 +112,11 @@ const typeConfig = computed(() => {
|
|
|
103
112
|
error: { icon: 'cancel', scheme: 'red-500' },
|
|
104
113
|
};
|
|
105
114
|
|
|
106
|
-
return configMap[
|
|
107
|
-
icon: string;
|
|
108
|
-
scheme: SchemeColor;
|
|
109
|
-
};
|
|
115
|
+
return configMap[validType.value];
|
|
110
116
|
});
|
|
111
117
|
|
|
118
|
+
const toastZIndex = useLayerZIndex('toast');
|
|
119
|
+
|
|
112
120
|
const handleClose = () => {
|
|
113
121
|
isVisible.value = false;
|
|
114
122
|
emit('close');
|
|
@@ -152,7 +160,6 @@ onUnmounted(() => {
|
|
|
152
160
|
position: fixed;
|
|
153
161
|
bottom: $unnnic-space-4;
|
|
154
162
|
right: $unnnic-space-4;
|
|
155
|
-
z-index: 9999;
|
|
156
163
|
|
|
157
164
|
display: flex;
|
|
158
165
|
align-items: flex-end;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
:
|
|
5
|
-
|
|
6
|
-
'force-open': forceOpen,
|
|
7
|
-
}"
|
|
8
|
-
@mouseover="handleResize"
|
|
2
|
+
<Tooltip
|
|
3
|
+
:disabled="!(enabled || forceOpen)"
|
|
4
|
+
:open="forceOpen || undefined"
|
|
5
|
+
data-testid="tooltip-wrapper"
|
|
9
6
|
>
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
<TooltipTrigger data-testid="tooltip-trigger">
|
|
8
|
+
<slot />
|
|
9
|
+
</TooltipTrigger>
|
|
10
|
+
|
|
11
|
+
<TooltipContent
|
|
14
12
|
:class="['unnnic-tooltip-label', `unnnic-tooltip-label-${side}`]"
|
|
15
|
-
:style="{ maxWidth: maxWidth
|
|
16
|
-
|
|
13
|
+
:style="{ maxWidth: maxWidth }"
|
|
14
|
+
:side="side"
|
|
15
|
+
data-testid="tooltip-content"
|
|
17
16
|
>
|
|
18
17
|
<template v-if="enableHtml">
|
|
19
18
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
20
|
-
<section
|
|
19
|
+
<section
|
|
20
|
+
v-html="text"
|
|
21
|
+
data-testid="tooltip-html-content"
|
|
22
|
+
></section>
|
|
21
23
|
</template>
|
|
22
24
|
<template
|
|
23
25
|
v-for="(line, index) in text.split('\n')"
|
|
@@ -27,22 +29,20 @@
|
|
|
27
29
|
{{ line }}
|
|
28
30
|
<br />
|
|
29
31
|
</template>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<span
|
|
33
|
-
class="unnnic-tooltip-label-shortcut"
|
|
34
|
-
data-testid="tooltip-label-shortcut"
|
|
35
|
-
>
|
|
36
|
-
{{ shortcutText }}
|
|
37
|
-
</span>
|
|
38
|
-
</template>
|
|
39
|
-
</span>
|
|
40
|
-
</div>
|
|
32
|
+
</TooltipContent>
|
|
33
|
+
</Tooltip>
|
|
41
34
|
</template>
|
|
42
35
|
|
|
43
36
|
<script>
|
|
37
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip';
|
|
38
|
+
|
|
44
39
|
export default {
|
|
45
40
|
name: 'UnnnicTooltip',
|
|
41
|
+
components: {
|
|
42
|
+
Tooltip,
|
|
43
|
+
TooltipTrigger,
|
|
44
|
+
TooltipContent,
|
|
45
|
+
},
|
|
46
46
|
props: {
|
|
47
47
|
text: {
|
|
48
48
|
type: String,
|
|
@@ -67,162 +67,10 @@ export default {
|
|
|
67
67
|
type: String,
|
|
68
68
|
default: '',
|
|
69
69
|
},
|
|
70
|
-
shortcutText: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: null,
|
|
73
|
-
},
|
|
74
70
|
enableHtml: {
|
|
75
71
|
type: Boolean,
|
|
76
72
|
default: false,
|
|
77
73
|
},
|
|
78
74
|
},
|
|
79
|
-
data() {
|
|
80
|
-
return {
|
|
81
|
-
topPos: null,
|
|
82
|
-
leftPos: null,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
watch: {
|
|
86
|
-
side() {
|
|
87
|
-
this.getRightPost(this.$refs.tooltip);
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
mounted() {
|
|
91
|
-
this.handleResize();
|
|
92
|
-
|
|
93
|
-
window.addEventListener('scroll', this.handleResize);
|
|
94
|
-
window.addEventListener('resize', this.handleResize);
|
|
95
|
-
},
|
|
96
|
-
unmounted() {
|
|
97
|
-
window.removeEventListener('scroll', this.handleResize);
|
|
98
|
-
window.removeEventListener('resize', this.handleResize);
|
|
99
|
-
},
|
|
100
|
-
methods: {
|
|
101
|
-
handleResize() {
|
|
102
|
-
this.getRightPost(this.$refs.tooltip);
|
|
103
|
-
},
|
|
104
|
-
getRightPost(element) {
|
|
105
|
-
const elementPos = element.getBoundingClientRect();
|
|
106
|
-
|
|
107
|
-
if (element && this.$refs.label) {
|
|
108
|
-
if (this.side === 'right') {
|
|
109
|
-
this.leftPos = `${elementPos.x + elementPos.width + 8}px`;
|
|
110
|
-
this.topPos = `${elementPos.y + elementPos.height / 2 - this.$refs.label.offsetHeight / 2}px`;
|
|
111
|
-
} else if (this.side === 'left') {
|
|
112
|
-
this.leftPos = `${elementPos.x - this.$refs.label.offsetWidth - 8}px`;
|
|
113
|
-
this.topPos = `${elementPos.y + elementPos.height / 2 - this.$refs.label.offsetHeight / 2}px`;
|
|
114
|
-
} else if (this.side === 'top') {
|
|
115
|
-
this.leftPos = `${elementPos.x + elementPos.width / 2 - this.$refs.label.clientWidth / 2}px`;
|
|
116
|
-
this.topPos = `${elementPos.y - this.$refs.label.offsetHeight - 8}px`;
|
|
117
|
-
} else if (this.side === 'bottom') {
|
|
118
|
-
this.leftPos = `${elementPos.x + elementPos.width / 2 - this.$refs.label.clientWidth / 2}px`;
|
|
119
|
-
this.topPos = `${elementPos.y + elementPos.height + 8}px`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
75
|
};
|
|
125
76
|
</script>
|
|
126
|
-
|
|
127
|
-
<style lang="scss" scoped>
|
|
128
|
-
@use '@/assets/scss/unnnic' as *;
|
|
129
|
-
|
|
130
|
-
.unnnic-tooltip {
|
|
131
|
-
position: relative;
|
|
132
|
-
display: inline-block;
|
|
133
|
-
overflow-wrap: break-word;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.unnnic-tooltip-label {
|
|
137
|
-
z-index: 1;
|
|
138
|
-
visibility: hidden;
|
|
139
|
-
text-align: center;
|
|
140
|
-
position: fixed;
|
|
141
|
-
width: max-content;
|
|
142
|
-
min-width: 2 * $unnnic-font-size;
|
|
143
|
-
box-sizing: border-box;
|
|
144
|
-
width: auto;
|
|
145
|
-
display: flex;
|
|
146
|
-
justify-content: center;
|
|
147
|
-
gap: $unnnic-spacing-xs;
|
|
148
|
-
align-items: center;
|
|
149
|
-
|
|
150
|
-
background-color: $unnnic-color-neutral-black;
|
|
151
|
-
color: $unnnic-color-neutral-snow;
|
|
152
|
-
border-radius: $unnnic-border-radius-sm;
|
|
153
|
-
padding: $unnnic-inset-nano;
|
|
154
|
-
box-shadow: $unnnic-shadow-level-near;
|
|
155
|
-
font-size: $unnnic-font-size-body-md;
|
|
156
|
-
font-family: $unnnic-font-family-secondary;
|
|
157
|
-
font-weight: $unnnic-font-weight-regular;
|
|
158
|
-
line-height: ($unnnic-font-size-body-md + $unnnic-line-height-medium);
|
|
159
|
-
|
|
160
|
-
&::after {
|
|
161
|
-
content: '';
|
|
162
|
-
position: absolute;
|
|
163
|
-
border-width: 5px;
|
|
164
|
-
border-style: solid;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
&-top {
|
|
168
|
-
position: fixed;
|
|
169
|
-
&::after {
|
|
170
|
-
top: 100%;
|
|
171
|
-
left: 50%;
|
|
172
|
-
margin-left: -5px;
|
|
173
|
-
border-color: $unnnic-color-neutral-black transparent transparent
|
|
174
|
-
transparent;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
&-bottom {
|
|
179
|
-
position: fixed;
|
|
180
|
-
&::after {
|
|
181
|
-
bottom: 100%;
|
|
182
|
-
left: 50%;
|
|
183
|
-
margin-left: -5px;
|
|
184
|
-
border-color: transparent transparent $unnnic-color-neutral-black
|
|
185
|
-
transparent;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
&-right {
|
|
189
|
-
position: fixed;
|
|
190
|
-
&::after {
|
|
191
|
-
top: 50%;
|
|
192
|
-
right: 100%;
|
|
193
|
-
margin-top: -5px;
|
|
194
|
-
border-color: transparent $unnnic-color-neutral-black transparent
|
|
195
|
-
transparent;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
&-left {
|
|
199
|
-
position: fixed;
|
|
200
|
-
&::after {
|
|
201
|
-
top: 50%;
|
|
202
|
-
left: 100%;
|
|
203
|
-
margin-top: -5px;
|
|
204
|
-
border-color: transparent transparent transparent
|
|
205
|
-
$unnnic-color-neutral-black;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
&-shortcut {
|
|
210
|
-
background-color: $unnnic-color-neutral-darkest;
|
|
211
|
-
border-radius: $unnnic-border-radius-sm;
|
|
212
|
-
padding: calc($unnnic-inset-nano / 2) $unnnic-inset-nano;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.unnnic-tooltip.force-open {
|
|
217
|
-
.unnnic-tooltip-label {
|
|
218
|
-
visibility: visible;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.unnnic-tooltip:hover {
|
|
223
|
-
.unnnic-tooltip-label {
|
|
224
|
-
visibility: visible;
|
|
225
|
-
width: auto;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
</style>
|