@weni/unnnic-system 3.12.3-alpha.5 → 3.12.3
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 +10 -0
- 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 +18 -92
- package/dist/components/AudioRecorder/AudioRecorder.vue.d.ts +36 -184
- 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 +29 -103
- package/dist/components/Card/CardCompany.vue.d.ts +2 -2
- package/dist/components/Card/CardStatusesContainer.vue.d.ts +19 -93
- 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 +18 -92
- package/dist/components/Card/StatusCard.vue.d.ts +1 -1
- package/dist/components/Card/TitleCard.vue.d.ts +18 -92
- package/dist/components/CardImage/CardImage.vue.d.ts +5 -5
- package/dist/components/CardInformation/CardInformation.vue.d.ts +19 -93
- 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 +24 -98
- package/dist/components/ChartLine/ChartLine.vue.d.ts +18 -92
- package/dist/components/ChatText/ChatText.vue.d.ts +18 -92
- package/dist/components/ChatsContact/ChatsContact.vue.d.ts +6 -6
- package/dist/components/ChatsMessage/ChatsMessage.vue.d.ts +18 -92
- 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 +18 -92
- 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 +16 -122
- package/dist/components/Disclaimer/Disclaimer.vue.d.ts +3 -6
- package/dist/components/Disclaimer/Disclaimer.vue.d.ts.map +1 -1
- package/dist/components/Disclaimer/DisclaimerV2.vue.d.ts +8 -0
- package/dist/components/Disclaimer/DisclaimerV2.vue.d.ts.map +1 -0
- package/dist/components/Disclaimer/types-v2.d.ts +7 -0
- package/dist/components/Disclaimer/types-v2.d.ts.map +1 -0
- package/dist/components/Disclaimer/types.d.ts +3 -6
- package/dist/components/Disclaimer/types.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.vue.d.ts +207 -37
- 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 +0 -31
- package/dist/components/Input/BaseInput.vue.d.ts.map +1 -1
- package/dist/components/Input/Input.vue.d.ts +15 -121
- package/dist/components/Input/Input.vue.d.ts.map +1 -1
- package/dist/components/Input/TextInput.vue.d.ts +4 -73
- 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 +35 -209
- package/dist/components/ModalDialog/ModalDialog.vue.d.ts.map +1 -1
- package/dist/components/ModalNext/ModalNext.vue.d.ts +21 -127
- package/dist/components/ModalUpload/ModalUpload.vue.d.ts +12 -12
- package/dist/components/MoodRating/MoodRating.vue.d.ts +18 -92
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts +163 -0
- package/dist/components/MultiSelect/MultiSelect.vue.d.ts.map +1 -0
- package/dist/components/Pagination/Pagination.vue.d.ts +6 -6
- package/dist/components/Radio/Radio.vue.d.ts +6 -6
- package/dist/components/SelectSmart/SelectSmart.vue.d.ts +13 -82
- 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 +5 -74
- package/dist/components/Slider/Slider.vue.d.ts +18 -92
- package/dist/components/Switch/Switch.vue.d.ts +3 -3
- package/dist/components/Tab/Tab.vue.d.ts +18 -92
- 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 +18 -92
- 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/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/{es-a9e51a05.mjs → es-c19444c0.mjs} +1 -1
- package/dist/{index-ade761d4.mjs → index-93b45359.mjs} +51889 -54741
- package/dist/locales/en.json.d.ts +1 -3
- package/dist/locales/es.json.d.ts +1 -3
- package/dist/locales/pt_br.json.d.ts +1 -3
- package/dist/{pt-br-5395459d.mjs → pt-br-23dc9ca6.mjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +206 -234
- package/dist/unnnic.umd.js +44 -48
- package/package.json +2 -3
- package/src/assets/scss/scheme-colors.scss +223 -223
- package/src/assets/scss/tailwind.scss +0 -8
- package/src/components/Alert/__tests__/__snapshots__/Alert.spec.js.snap +1 -1
- package/src/components/Checkbox/Checkbox.vue +1 -1
- package/src/components/Disclaimer/Disclaimer.vue +42 -136
- package/src/components/Disclaimer/DisclaimerV2.vue +171 -0
- package/src/components/Disclaimer/__tests__/Disclaimer.spec.js +45 -70
- package/src/components/Disclaimer/__tests__/DisclaimerV2.spec.js +68 -0
- package/src/components/Disclaimer/types-v2.ts +12 -0
- package/src/components/Disclaimer/types.ts +3 -12
- package/src/components/Drawer/Drawer.vue +269 -190
- package/src/components/Drawer/__tests__/Drawer.spec.js +46 -37
- package/src/components/Drawer/__tests__/__snapshots__/Drawer.spec.js.snap +19 -18
- package/src/components/Input/BaseInput.vue +5 -25
- package/src/components/Input/Input.scss +3 -2
- package/src/components/Input/Input.vue +1 -24
- package/src/components/Input/TextInput.vue +25 -64
- package/src/components/Input/__test__/TextInput.spec.js +1 -1
- package/src/components/Input/__test__/__snapshots__/Input.spec.js.snap +1 -5
- package/src/components/Input/__test__/__snapshots__/TextInput.spec.js.snap +1 -7
- package/src/components/ModalDialog/ModalDialog.vue +148 -64
- package/src/components/ModalDialog/__tests__/ModalDialog.spec.js +221 -11
- package/src/components/ModalDialog/__tests__/__snapshots__/ModalDialog.spec.js.snap +22 -1
- package/src/components/MultiSelect/MultiSelect.vue +297 -0
- package/src/components/Tab/__test__/__snapshots__/Tab.spec.js.snap +1 -3
- package/src/components/Toast/Toast.vue +9 -16
- package/src/components/ToolTip/ToolTip.vue +177 -25
- package/src/components/ToolTip/__tests__/ToolTip.spec.js +61 -339
- package/src/components/index.ts +11 -63
- package/src/components/ui/popover/PopoverContent.vue +2 -19
- package/src/components/ui/popover/PopoverOption.vue +0 -4
- package/src/components/ui/popover/PopoverTrigger.vue +1 -5
- package/src/locales/en.json +1 -3
- package/src/locales/es.json +1 -3
- package/src/locales/pt_br.json +1 -3
- package/src/stories/Disclaimer.stories.js +12 -53
- package/src/stories/DisclaimerV2.stories.js +51 -0
- package/src/stories/Drawer.stories.js +1 -1
- package/src/stories/Input.mdx +0 -3
- package/src/stories/ModalDialog.mdx +0 -3
- package/src/stories/ModalDialog.stories.js +1 -1
- package/src/stories/MultiSelect.stories.js +46 -142
- package/dist/components/MultiSelect/MultSelectOption.vue.d.ts +0 -17
- package/dist/components/MultiSelect/MultSelectOption.vue.d.ts.map +0 -1
- package/dist/components/MultiSelect/index.vue.d.ts +0 -44
- package/dist/components/MultiSelect/index.vue.d.ts.map +0 -1
- package/dist/components/Select/index.vue.d.ts +0 -44
- package/dist/components/Select/index.vue.d.ts.map +0 -1
- package/dist/components/index.d.ts +0 -23912
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/ui/dialog/Dialog.vue.d.ts +0 -23
- package/dist/components/ui/dialog/Dialog.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogClose.vue.d.ts +0 -21
- package/dist/components/ui/dialog/DialogClose.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogContent.vue.d.ts +0 -43
- package/dist/components/ui/dialog/DialogContent.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts +0 -25
- package/dist/components/ui/dialog/DialogFooter.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts +0 -29
- package/dist/components/ui/dialog/DialogHeader.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts +0 -23
- package/dist/components/ui/dialog/DialogTitle.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts +0 -19
- package/dist/components/ui/dialog/DialogTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/dialog/index.d.ts +0 -8
- package/dist/components/ui/dialog/index.d.ts.map +0 -1
- package/dist/components/ui/drawer/Drawer.vue.d.ts +0 -35
- package/dist/components/ui/drawer/Drawer.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts +0 -21
- package/dist/components/ui/drawer/DrawerClose.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts +0 -43
- package/dist/components/ui/drawer/DrawerContent.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts +0 -23
- package/dist/components/ui/drawer/DrawerDescription.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts +0 -22
- package/dist/components/ui/drawer/DrawerFooter.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts +0 -25
- package/dist/components/ui/drawer/DrawerHeader.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts +0 -8
- package/dist/components/ui/drawer/DrawerOverlay.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts +0 -23
- package/dist/components/ui/drawer/DrawerTitle.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts +0 -19
- package/dist/components/ui/drawer/DrawerTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/drawer/index.d.ts +0 -11
- package/dist/components/ui/drawer/index.d.ts.map +0 -1
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts +0 -23
- package/dist/components/ui/tooltip/Tooltip.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts +0 -31
- package/dist/components/ui/tooltip/TooltipContent.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts +0 -19
- package/dist/components/ui/tooltip/TooltipTrigger.vue.d.ts.map +0 -1
- package/dist/components/ui/tooltip/index.d.ts +0 -4
- package/dist/components/ui/tooltip/index.d.ts.map +0 -1
- package/dist/lib/layer-manager.d.ts +0 -16
- package/dist/lib/layer-manager.d.ts.map +0 -1
- package/src/components/MultiSelect/MultSelectOption.vue +0 -49
- package/src/components/MultiSelect/__tests__/MultiSelect.spec.js +0 -556
- package/src/components/MultiSelect/__tests__/MultiSelectOption.spec.js +0 -229
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelect.spec.js.snap +0 -87
- package/src/components/MultiSelect/__tests__/__snapshots__/MultiSelectOption.spec.js.snap +0 -51
- package/src/components/MultiSelect/index.vue +0 -225
- package/src/components/Select/__tests__/Select.spec.js +0 -422
- package/src/components/Select/__tests__/SelectItem.spec.js +0 -330
- package/src/components/Select/__tests__/__snapshots__/Popover.spec.js.snap +0 -8
- package/src/components/Select/__tests__/__snapshots__/Select.spec.js.snap +0 -71
- package/src/components/Select/__tests__/__snapshots__/SelectItem.spec.js.snap +0 -15
- package/src/components/Select/__tests__/__snapshots__/SelectOption.spec.js.snap +0 -25
- package/src/components/Select/__tests__/__snapshots__/SelectPopover.spec.js.snap +0 -8
- package/src/components/Select/index.vue +0 -298
- package/src/components/ui/dialog/Dialog.vue +0 -19
- package/src/components/ui/dialog/DialogClose.vue +0 -29
- package/src/components/ui/dialog/DialogContent.vue +0 -140
- package/src/components/ui/dialog/DialogFooter.vue +0 -50
- package/src/components/ui/dialog/DialogHeader.vue +0 -83
- package/src/components/ui/dialog/DialogTitle.vue +0 -38
- package/src/components/ui/dialog/DialogTrigger.vue +0 -16
- package/src/components/ui/dialog/index.ts +0 -7
- package/src/components/ui/drawer/Drawer.vue +0 -27
- package/src/components/ui/drawer/DrawerClose.vue +0 -31
- package/src/components/ui/drawer/DrawerContent.vue +0 -111
- package/src/components/ui/drawer/DrawerDescription.vue +0 -40
- package/src/components/ui/drawer/DrawerFooter.vue +0 -38
- package/src/components/ui/drawer/DrawerHeader.vue +0 -57
- package/src/components/ui/drawer/DrawerOverlay.vue +0 -33
- package/src/components/ui/drawer/DrawerTitle.vue +0 -37
- package/src/components/ui/drawer/DrawerTrigger.vue +0 -31
- package/src/components/ui/drawer/index.ts +0 -10
- package/src/components/ui/tooltip/Tooltip.vue +0 -21
- package/src/components/ui/tooltip/TooltipContent.vue +0 -74
- package/src/components/ui/tooltip/TooltipTrigger.vue +0 -26
- package/src/components/ui/tooltip/index.ts +0 -3
- package/src/lib/layer-manager.ts +0 -92
- package/src/stories/Dialog.stories.js +0 -832
- package/src/stories/DrawerNext.stories.js +0 -611
- package/src/stories/LayerManager.docs.mdx +0 -40
- package/src/stories/LayerManager.stories.js +0 -364
- package/src/stories/Select.stories.js +0 -158
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { mount } from '@vue/test-utils';
|
|
2
|
-
import { beforeEach, describe, expect, test, afterEach } from 'vitest';
|
|
3
|
-
import MultiSelectOption from '../MultSelectOption.vue';
|
|
4
|
-
|
|
5
|
-
const createWrapper = (props = {}) => {
|
|
6
|
-
return mount(MultiSelectOption, { props });
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe('MultiSelectOption.vue', () => {
|
|
10
|
-
let wrapper;
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
wrapper = createWrapper({
|
|
14
|
-
label: 'Test Option',
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
if (wrapper) {
|
|
20
|
-
wrapper.unmount();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('renders correctly', () => {
|
|
25
|
-
expect(wrapper.exists()).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('applies the correct base CSS class', () => {
|
|
29
|
-
expect(wrapper.classes()).toContain('unnnic-multi-select-option');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('renders UnnnicCheckbox component', () => {
|
|
33
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
34
|
-
expect(checkbox.exists()).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('passes label prop to checkbox', () => {
|
|
38
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
39
|
-
expect(checkbox.props('label')).toBe('Test Option');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('props validation', () => {
|
|
43
|
-
test('validates required label prop', () => {
|
|
44
|
-
const wrapper = createWrapper({ label: 'Required Label' });
|
|
45
|
-
expect(wrapper.props('label')).toBe('Required Label');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('validates optional disabled prop with default value', () => {
|
|
49
|
-
expect(wrapper.props('disabled')).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('validates optional active prop with default value', () => {
|
|
53
|
-
expect(wrapper.props('active')).toBe(false);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('validates optional focused prop with default value', () => {
|
|
57
|
-
expect(wrapper.props('focused')).toBe(false);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
describe('disabled state', () => {
|
|
62
|
-
test('passes disabled prop to checkbox when disabled is true', async () => {
|
|
63
|
-
await wrapper.setProps({ disabled: true });
|
|
64
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
65
|
-
expect(checkbox.props('disabled')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('passes disabled prop to checkbox when disabled is false', async () => {
|
|
69
|
-
await wrapper.setProps({ disabled: false });
|
|
70
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
71
|
-
expect(checkbox.props('disabled')).toBe(false);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
describe('active state', () => {
|
|
76
|
-
test('passes active prop to checkbox modelValue when active is true', async () => {
|
|
77
|
-
await wrapper.setProps({ active: true });
|
|
78
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
79
|
-
expect(checkbox.props('modelValue')).toBe(true);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('passes active prop to checkbox modelValue when active is false', async () => {
|
|
83
|
-
await wrapper.setProps({ active: false });
|
|
84
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
85
|
-
expect(checkbox.props('modelValue')).toBe(false);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('events', () => {
|
|
90
|
-
test('emits update:modelValue when checkbox emits update:model-value', async () => {
|
|
91
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
92
|
-
|
|
93
|
-
await checkbox.vm.$emit('update:model-value', true);
|
|
94
|
-
|
|
95
|
-
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
96
|
-
expect(wrapper.emitted('update:modelValue')[0][0]).toBe(true);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('emits update:modelValue with toggled value when active is false', async () => {
|
|
100
|
-
await wrapper.setProps({ active: false });
|
|
101
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
102
|
-
|
|
103
|
-
await checkbox.vm.$emit('update:model-value', true);
|
|
104
|
-
|
|
105
|
-
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
106
|
-
expect(wrapper.emitted('update:modelValue')[0][0]).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('emits update:modelValue with toggled value when active is true', async () => {
|
|
110
|
-
await wrapper.setProps({ active: true });
|
|
111
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
112
|
-
|
|
113
|
-
await checkbox.vm.$emit('update:model-value', false);
|
|
114
|
-
|
|
115
|
-
expect(wrapper.emitted('update:modelValue')).toBeTruthy();
|
|
116
|
-
expect(wrapper.emitted('update:modelValue')[0][0]).toBe(false);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe('combined states', () => {
|
|
121
|
-
test('can be both active and disabled', async () => {
|
|
122
|
-
await wrapper.setProps({ active: true, disabled: true });
|
|
123
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
124
|
-
|
|
125
|
-
expect(checkbox.props('modelValue')).toBe(true);
|
|
126
|
-
expect(checkbox.props('disabled')).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('renders correctly with all props', async () => {
|
|
130
|
-
await wrapper.setProps({
|
|
131
|
-
label: 'Complex Option',
|
|
132
|
-
active: true,
|
|
133
|
-
disabled: false,
|
|
134
|
-
focused: true,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
138
|
-
expect(checkbox.props('label')).toBe('Complex Option');
|
|
139
|
-
expect(checkbox.props('modelValue')).toBe(true);
|
|
140
|
-
expect(checkbox.props('disabled')).toBe(false);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe('component structure', () => {
|
|
145
|
-
test('has correct component name', () => {
|
|
146
|
-
expect(wrapper.vm.$options.name).toBe('UnnnicMultiSelectOption');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test('renders a div element', () => {
|
|
150
|
-
expect(wrapper.element.tagName).toBe('DIV');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test('contains UnnnicCheckbox component', () => {
|
|
154
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
155
|
-
expect(checkbox.exists()).toBe(true);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
describe('edge cases', () => {
|
|
160
|
-
test('handles empty label', async () => {
|
|
161
|
-
await wrapper.setProps({ label: '' });
|
|
162
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
163
|
-
expect(checkbox.props('label')).toBe('');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('handles long label text', async () => {
|
|
167
|
-
const longText =
|
|
168
|
-
'This is a very long label text that should be handled properly by the component';
|
|
169
|
-
await wrapper.setProps({ label: longText });
|
|
170
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
171
|
-
expect(checkbox.props('label')).toBe(longText);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test('handles special characters in label', async () => {
|
|
175
|
-
const specialText = 'Option with special chars: @#$%^&*()';
|
|
176
|
-
await wrapper.setProps({ label: specialText });
|
|
177
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
178
|
-
expect(checkbox.props('label')).toBe(specialText);
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test('handles rapid state changes', async () => {
|
|
182
|
-
await wrapper.setProps({ active: true });
|
|
183
|
-
await wrapper.setProps({ active: false });
|
|
184
|
-
await wrapper.setProps({ active: true });
|
|
185
|
-
|
|
186
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
187
|
-
expect(checkbox.props('modelValue')).toBe(true);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
describe('accessibility', () => {
|
|
192
|
-
test('checkbox receives disabled state for accessibility', async () => {
|
|
193
|
-
await wrapper.setProps({ disabled: true });
|
|
194
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
195
|
-
expect(checkbox.props('disabled')).toBe(true);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
test('checkbox receives label for accessibility', () => {
|
|
199
|
-
const checkbox = wrapper.findComponent({ name: 'UnnnicCheckbox' });
|
|
200
|
-
expect(checkbox.props('label')).toBe('Test Option');
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
describe('snapshot testing', () => {
|
|
205
|
-
test('matches snapshot with default props', () => {
|
|
206
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test('matches snapshot with active state', async () => {
|
|
210
|
-
await wrapper.setProps({ active: true });
|
|
211
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
test('matches snapshot with disabled state', async () => {
|
|
215
|
-
await wrapper.setProps({ disabled: true });
|
|
216
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
test('matches snapshot with both active and disabled states', async () => {
|
|
220
|
-
await wrapper.setProps({ active: true, disabled: true });
|
|
221
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('matches snapshot with focused state', async () => {
|
|
225
|
-
await wrapper.setProps({ focused: true });
|
|
226
|
-
expect(wrapper.html()).toMatchSnapshot();
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with default props 1`] = `
|
|
4
|
-
"<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
|
|
5
|
-
<section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
|
|
6
|
-
<!--v-if-->
|
|
7
|
-
<div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
|
|
8
|
-
<!--v-if-->
|
|
9
|
-
<section data-v-a0d36167="" class="icon-right-container">
|
|
10
|
-
<!--v-if--><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant icon-right" data-testid="material-icon" translate="no">keyboard_arrow_down</span>
|
|
11
|
-
</section>
|
|
12
|
-
</div>
|
|
13
|
-
<!--v-if-->
|
|
14
|
-
</section>
|
|
15
|
-
</button>
|
|
16
|
-
<!--teleport start-->
|
|
17
|
-
<!--teleport end-->
|
|
18
|
-
</div>"
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with disabled state 1`] = `
|
|
22
|
-
"<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
|
|
23
|
-
<section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form-element--disabled unnnic-form md unnnic-multi-select__input" data-testid="form-element">
|
|
24
|
-
<!--v-if-->
|
|
25
|
-
<div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="" disabled="">
|
|
26
|
-
<!--v-if-->
|
|
27
|
-
<section data-v-a0d36167="" class="icon-right-container">
|
|
28
|
-
<!--v-if--><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-muted unnnic-icon-size--ant unnnic-icon__size--ant icon-right" data-testid="material-icon" translate="no">keyboard_arrow_down</span>
|
|
29
|
-
</section>
|
|
30
|
-
</div>
|
|
31
|
-
<!--v-if-->
|
|
32
|
-
</section>
|
|
33
|
-
</button>
|
|
34
|
-
<!--teleport start-->
|
|
35
|
-
<!--teleport end-->
|
|
36
|
-
</div>"
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with multiple selected values 1`] = `
|
|
40
|
-
"<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
|
|
41
|
-
<section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
|
|
42
|
-
<!--v-if-->
|
|
43
|
-
<div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right input--has-clear-icon use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="true" type="text" readonly="" value="Option 1, Option 2">
|
|
44
|
-
<!--v-if-->
|
|
45
|
-
<section data-v-a0d36167="" class="icon-right-container"><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant unnnic--clickable icon-clear" data-testid="material-icon" translate="no">close</span><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant icon-right" data-testid="material-icon" translate="no">keyboard_arrow_down</span></section>
|
|
46
|
-
</div>
|
|
47
|
-
<!--v-if-->
|
|
48
|
-
</section>
|
|
49
|
-
</button>
|
|
50
|
-
<!--teleport start-->
|
|
51
|
-
<!--teleport end-->
|
|
52
|
-
</div>"
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with search enabled 1`] = `
|
|
56
|
-
"<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
|
|
57
|
-
<section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
|
|
58
|
-
<!--v-if-->
|
|
59
|
-
<div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="false" type="text" readonly="" value="">
|
|
60
|
-
<!--v-if-->
|
|
61
|
-
<section data-v-a0d36167="" class="icon-right-container">
|
|
62
|
-
<!--v-if--><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant icon-right" data-testid="material-icon" translate="no">keyboard_arrow_down</span>
|
|
63
|
-
</section>
|
|
64
|
-
</div>
|
|
65
|
-
<!--v-if-->
|
|
66
|
-
</section>
|
|
67
|
-
</button>
|
|
68
|
-
<!--teleport start-->
|
|
69
|
-
<!--teleport end-->
|
|
70
|
-
</div>"
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
exports[`UnnnicMultiSelect.vue > snapshot testing > matches snapshot with selected values 1`] = `
|
|
74
|
-
"<div data-v-03c7fb50="" class="unnnic-multi-select"><button data-v-9d52eef8="" data-v-03c7fb50="" class="unnnic-popover-trigger" id="reka-popover-trigger-v-0" type="button" aria-haspopup="dialog" aria-expanded="false" aria-controls="" data-state="closed">
|
|
75
|
-
<section data-v-9f8d6c86="" data-v-d890ad85="" data-v-03c7fb50="" class="unnnic-form-element unnnic-form md unnnic-multi-select__input" data-testid="form-element">
|
|
76
|
-
<!--v-if-->
|
|
77
|
-
<div data-v-a0d36167="" data-v-d890ad85="" class="text-input size--md unnnic-multi-select__input unnnic-form-input" hascloudycolor="false" mask=""><input data-v-86533b41="" data-v-a0d36167="" class="unnnic-multi-select__input unnnic-form-input input-itself input size-md normal input--has-icon-right input--has-clear-icon use-focus-prop unnnic-multi-select__input unnnic-form-input input-itself" hascloudycolor="false" placeholder="" iconleft="" iconright="keyboard_arrow_down" iconleftclickable="false" iconrightclickable="false" showclear="true" type="text" readonly="" value="Option 1">
|
|
78
|
-
<!--v-if-->
|
|
79
|
-
<section data-v-a0d36167="" class="icon-right-container"><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant unnnic--clickable icon-clear" data-testid="material-icon" translate="no">close</span><span data-v-26446d8e="" data-v-a0d36167="" class="unnnic-icon material-symbols-rounded unnnic-icon-scheme--fg-base unnnic-icon-size--ant unnnic-icon__size--ant icon-right" data-testid="material-icon" translate="no">keyboard_arrow_down</span></section>
|
|
80
|
-
</div>
|
|
81
|
-
<!--v-if-->
|
|
82
|
-
</section>
|
|
83
|
-
</button>
|
|
84
|
-
<!--teleport start-->
|
|
85
|
-
<!--teleport end-->
|
|
86
|
-
</div>"
|
|
87
|
-
`;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`MultiSelectOption.vue > snapshot testing > matches snapshot with active state 1`] = `
|
|
4
|
-
"<div data-v-d2b97c58="" class="unnnic-multi-select-option">
|
|
5
|
-
<section data-v-18939422="" data-v-d2b97c58="" class="unnnic-checkbox"><label data-v-18939422="" class="unnnic-checkbox__input-wrapper"><input data-v-18939422="" class="unnnic-checkbox__input" type="checkbox" checked="">
|
|
6
|
-
<p data-v-18939422="" class="unnnic-checkbox__label" data-testid="checkbox-text-right">Test Option</p>
|
|
7
|
-
</label>
|
|
8
|
-
<!--v-if-->
|
|
9
|
-
</section>
|
|
10
|
-
</div>"
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
exports[`MultiSelectOption.vue > snapshot testing > matches snapshot with both active and disabled states 1`] = `
|
|
14
|
-
"<div data-v-d2b97c58="" class="unnnic-multi-select-option">
|
|
15
|
-
<section data-v-18939422="" data-v-d2b97c58="" class="unnnic-checkbox"><label data-v-18939422="" class="unnnic-checkbox__input-wrapper unnnic-checkbox__input-wrapper--disabled"><input data-v-18939422="" class="unnnic-checkbox__input" type="checkbox" disabled="" checked="">
|
|
16
|
-
<p data-v-18939422="" class="unnnic-checkbox__label unnnic-checkbox__label--disabled" data-testid="checkbox-text-right">Test Option</p>
|
|
17
|
-
</label>
|
|
18
|
-
<!--v-if-->
|
|
19
|
-
</section>
|
|
20
|
-
</div>"
|
|
21
|
-
`;
|
|
22
|
-
|
|
23
|
-
exports[`MultiSelectOption.vue > snapshot testing > matches snapshot with default props 1`] = `
|
|
24
|
-
"<div data-v-d2b97c58="" class="unnnic-multi-select-option">
|
|
25
|
-
<section data-v-18939422="" data-v-d2b97c58="" class="unnnic-checkbox"><label data-v-18939422="" class="unnnic-checkbox__input-wrapper"><input data-v-18939422="" class="unnnic-checkbox__input" type="checkbox">
|
|
26
|
-
<p data-v-18939422="" class="unnnic-checkbox__label" data-testid="checkbox-text-right">Test Option</p>
|
|
27
|
-
</label>
|
|
28
|
-
<!--v-if-->
|
|
29
|
-
</section>
|
|
30
|
-
</div>"
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
exports[`MultiSelectOption.vue > snapshot testing > matches snapshot with disabled state 1`] = `
|
|
34
|
-
"<div data-v-d2b97c58="" class="unnnic-multi-select-option">
|
|
35
|
-
<section data-v-18939422="" data-v-d2b97c58="" class="unnnic-checkbox"><label data-v-18939422="" class="unnnic-checkbox__input-wrapper unnnic-checkbox__input-wrapper--disabled"><input data-v-18939422="" class="unnnic-checkbox__input" type="checkbox" disabled="">
|
|
36
|
-
<p data-v-18939422="" class="unnnic-checkbox__label unnnic-checkbox__label--disabled" data-testid="checkbox-text-right">Test Option</p>
|
|
37
|
-
</label>
|
|
38
|
-
<!--v-if-->
|
|
39
|
-
</section>
|
|
40
|
-
</div>"
|
|
41
|
-
`;
|
|
42
|
-
|
|
43
|
-
exports[`MultiSelectOption.vue > snapshot testing > matches snapshot with focused state 1`] = `
|
|
44
|
-
"<div data-v-d2b97c58="" class="unnnic-multi-select-option">
|
|
45
|
-
<section data-v-18939422="" data-v-d2b97c58="" class="unnnic-checkbox"><label data-v-18939422="" class="unnnic-checkbox__input-wrapper"><input data-v-18939422="" class="unnnic-checkbox__input" type="checkbox">
|
|
46
|
-
<p data-v-18939422="" class="unnnic-checkbox__label" data-testid="checkbox-text-right">Test Option</p>
|
|
47
|
-
</label>
|
|
48
|
-
<!--v-if-->
|
|
49
|
-
</section>
|
|
50
|
-
</div>"
|
|
51
|
-
`;
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="unnnic-multi-select">
|
|
3
|
-
<Popover
|
|
4
|
-
:open="openPopover"
|
|
5
|
-
@update:open="openPopover = $event"
|
|
6
|
-
>
|
|
7
|
-
<PopoverTrigger>
|
|
8
|
-
<UnnnicInput
|
|
9
|
-
:modelValue="inputValue"
|
|
10
|
-
class="unnnic-multi-select__input"
|
|
11
|
-
readonly
|
|
12
|
-
useFocusProp
|
|
13
|
-
:focus="openPopover"
|
|
14
|
-
:size="props.size"
|
|
15
|
-
:placeholder="props.placeholder"
|
|
16
|
-
:label="props.label"
|
|
17
|
-
:errors="props.errors"
|
|
18
|
-
:message="props.message"
|
|
19
|
-
:iconRight="openPopover ? 'keyboard_arrow_up' : 'keyboard_arrow_down'"
|
|
20
|
-
:disabled="props.disabled"
|
|
21
|
-
:showClear="!!selectedItems.length"
|
|
22
|
-
@clear="emit('update:modelValue', [])"
|
|
23
|
-
/>
|
|
24
|
-
</PopoverTrigger>
|
|
25
|
-
<PopoverContent
|
|
26
|
-
align="start"
|
|
27
|
-
:style="{ maxHeight: calculatedMaxHeight, overflow: 'auto' }"
|
|
28
|
-
>
|
|
29
|
-
<div class="unnnic-multi-select__content">
|
|
30
|
-
<UnnnicInput
|
|
31
|
-
v-if="props.enableSearch"
|
|
32
|
-
class="unnnic-multi-select__input-search"
|
|
33
|
-
:modelValue="props.search"
|
|
34
|
-
:placeholder="$t('search')"
|
|
35
|
-
iconLeft="search"
|
|
36
|
-
@update:model-value="handleSearch"
|
|
37
|
-
/>
|
|
38
|
-
<div class="unnnic-multi-select__options">
|
|
39
|
-
<UnnnicMultiSelectOption
|
|
40
|
-
v-for="(option, index) in filteredOptions"
|
|
41
|
-
:key="option[props.itemValue]"
|
|
42
|
-
:data-option-index="index"
|
|
43
|
-
:label="option[props.itemLabel]"
|
|
44
|
-
:active="getActivatedOptionStatus(option)"
|
|
45
|
-
:focused="focusedOptionIndex === index"
|
|
46
|
-
:disabled="option.disabled"
|
|
47
|
-
@update:model-value="handleSelectOption(option, $event)"
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</PopoverContent>
|
|
52
|
-
</Popover>
|
|
53
|
-
</div>
|
|
54
|
-
</template>
|
|
55
|
-
|
|
56
|
-
<script setup lang="ts">
|
|
57
|
-
import { computed, ref } from 'vue';
|
|
58
|
-
|
|
59
|
-
import { Popover, PopoverTrigger, PopoverContent } from '../ui/popover';
|
|
60
|
-
import UnnnicInput from '../Input/Input.vue';
|
|
61
|
-
import UnnnicMultiSelectOption from './MultSelectOption.vue';
|
|
62
|
-
|
|
63
|
-
defineOptions({
|
|
64
|
-
name: 'UnnnicMultiSelect',
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
interface MultiSelectProps {
|
|
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<MultiSelectProps>(), {
|
|
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
|
-
label: '',
|
|
100
|
-
errors: '',
|
|
101
|
-
message: '',
|
|
102
|
-
search: '',
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const openPopover = ref(false);
|
|
106
|
-
|
|
107
|
-
const calculatedMaxHeight = computed(() => {
|
|
108
|
-
if (!props.options || props.options.length === 0) return 'unset';
|
|
109
|
-
const popoverSearchGap = props.enableSearch ? 16 : 0;
|
|
110
|
-
const popoverGap = 24;
|
|
111
|
-
const fieldsHeight = 22 * props.optionsLines;
|
|
112
|
-
const size = fieldsHeight + (popoverGap * props.optionsLines - 2);
|
|
113
|
-
return `${props.enableSearch ? size + 51 + popoverSearchGap : size}px`;
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const emit = defineEmits<{
|
|
117
|
-
'update:modelValue': [unknown[]];
|
|
118
|
-
'update:search': [string];
|
|
119
|
-
}>();
|
|
120
|
-
|
|
121
|
-
const focusedOptionIndex = ref<number>(-1);
|
|
122
|
-
|
|
123
|
-
const selectedItems = computed(() => {
|
|
124
|
-
if (props.returnObject) return props.modelValue;
|
|
125
|
-
|
|
126
|
-
const modelValueValues = props.returnObject
|
|
127
|
-
? props.modelValue.map((item) => item[props.itemValue])
|
|
128
|
-
: props.modelValue;
|
|
129
|
-
|
|
130
|
-
return props.options.filter((option) =>
|
|
131
|
-
modelValueValues.includes(option[props.itemValue]),
|
|
132
|
-
);
|
|
133
|
-
});
|
|
134
|
-
const inputValue = computed(() => {
|
|
135
|
-
return selectedItems.value.map((item) => item[props.itemLabel]).join(', ');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
const filteredOptions = computed(() => {
|
|
139
|
-
if (!props.enableSearch || !props.search) return props.options;
|
|
140
|
-
|
|
141
|
-
return props.options.filter(
|
|
142
|
-
(option) =>
|
|
143
|
-
option[props.itemLabel]
|
|
144
|
-
.toLowerCase()
|
|
145
|
-
.includes(props.search?.toLowerCase()) ||
|
|
146
|
-
option[props.itemValue]
|
|
147
|
-
.toLowerCase()
|
|
148
|
-
.includes(props.search?.toLowerCase()),
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
const handleSearch = (value: string) => {
|
|
153
|
-
emit('update:search', value);
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const getActivatedOptionStatus = (option: (typeof props.options)[number]) => {
|
|
157
|
-
if (props.returnObject) {
|
|
158
|
-
return props.modelValue.find(
|
|
159
|
-
(item) => item[props.itemValue] === option[props.itemValue],
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return props.modelValue.includes(option[props.itemValue]);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const handleSelectOption = (
|
|
166
|
-
option: (typeof props.options)[number],
|
|
167
|
-
selected: boolean,
|
|
168
|
-
) => {
|
|
169
|
-
if (selected) {
|
|
170
|
-
emit(
|
|
171
|
-
'update:modelValue',
|
|
172
|
-
props.returnObject
|
|
173
|
-
? [...props.modelValue, option]
|
|
174
|
-
: [...props.modelValue, option[props.itemValue]],
|
|
175
|
-
);
|
|
176
|
-
} else {
|
|
177
|
-
emit(
|
|
178
|
-
'update:modelValue',
|
|
179
|
-
props.returnObject
|
|
180
|
-
? props.modelValue.filter(
|
|
181
|
-
(item) => item[props.itemValue] !== option[props.itemValue],
|
|
182
|
-
)
|
|
183
|
-
: props.modelValue.filter((item) => item !== option[props.itemValue]),
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
</script>
|
|
188
|
-
|
|
189
|
-
<style lang="scss" scoped>
|
|
190
|
-
@use '@/assets/scss/unnnic' as *;
|
|
191
|
-
|
|
192
|
-
:deep(.unnnic-multi-select__input) {
|
|
193
|
-
cursor: pointer;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
:deep(.unnnic-multi-select__input-search) {
|
|
197
|
-
> .icon-left {
|
|
198
|
-
color: $unnnic-color-fg-base;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
:deep(.unnnic-multi-select__input) {
|
|
203
|
-
> .icon-right {
|
|
204
|
-
color: $unnnic-color-fg-base;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.unnnic-multi-select {
|
|
209
|
-
&__content {
|
|
210
|
-
display: flex;
|
|
211
|
-
flex-direction: column;
|
|
212
|
-
padding: 0;
|
|
213
|
-
margin: 0;
|
|
214
|
-
gap: $unnnic-space-4;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
&__options {
|
|
218
|
-
padding: 0;
|
|
219
|
-
margin: 0;
|
|
220
|
-
display: flex;
|
|
221
|
-
flex-direction: column;
|
|
222
|
-
gap: $unnnic-space-6;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
</style>
|