@eturnity/eturnity_reusable_components 7.12.7 → 7.16.0-qa-25.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/.prettierrc +6 -6
- package/.storybook/main.js +8 -8
- package/.storybook/preview.js +46 -46
- package/README.md +29 -29
- package/babel.config.js +4 -4
- package/package.json +66 -66
- package/postcss.config.js +6 -6
- package/public/index.html +17 -17
- package/src/App.vue +109 -109
- package/src/assets/icons/arrow_down.svg +3 -3
- package/src/assets/icons/arrow_up_red.svg +3 -3
- package/src/assets/icons/black_spinner.svg +35 -35
- package/src/assets/icons/delete_icon.svg +11 -11
- package/src/assets/icons/delete_icon_gray.svg +11 -11
- package/src/assets/icons/drag_icon.svg +8 -8
- package/src/assets/icons/external_icon.svg +6 -6
- package/src/assets/icons/language_icon.svg +6 -6
- package/src/assets/icons/pdf_icon.svg +6 -6
- package/src/assets/icons/plus_button.svg +4 -4
- package/src/assets/icons/search_icon_black.svg +3 -3
- package/src/assets/icons/subposition_icon.svg +3 -3
- package/src/assets/icons/subposition_marker.svg +3 -3
- package/src/assets/icons/warning_icon.svg +3 -3
- package/src/assets/svgIcons/2d_active.svg +7 -7
- package/src/assets/svgIcons/2d_inactive.svg +8 -8
- package/src/assets/svgIcons/3d_active.svg +7 -7
- package/src/assets/svgIcons/3d_inactive.svg +8 -8
- package/src/assets/svgIcons/_readme.md +7 -7
- package/src/assets/svgIcons/accept.svg +5 -5
- package/src/assets/svgIcons/activate_panels_active.svg +22 -22
- package/src/assets/svgIcons/activate_panels_inactive.svg +20 -20
- package/src/assets/svgIcons/add_icon-1.svg +3 -3
- package/src/assets/svgIcons/add_icon.svg +4 -4
- package/src/assets/svgIcons/address_book.svg +3 -3
- package/src/assets/svgIcons/after_sale_as_a_service.svg +6 -6
- package/src/assets/svgIcons/all_good.svg +3 -3
- package/src/assets/svgIcons/angle_active.svg +5 -5
- package/src/assets/svgIcons/angle_inactive.svg +4 -4
- package/src/assets/svgIcons/area_active.svg +11 -11
- package/src/assets/svgIcons/area_inactive.svg +26 -26
- package/src/assets/svgIcons/areas_tool.svg +14 -14
- package/src/assets/svgIcons/arrow_down.svg +3 -3
- package/src/assets/svgIcons/arrow_left.svg +4 -4
- package/src/assets/svgIcons/arrow_right.svg +4 -4
- package/src/assets/svgIcons/arrow_up.svg +3 -3
- package/src/assets/svgIcons/attachment.svg +3 -3
- package/src/assets/svgIcons/base_layer.svg +3 -3
- package/src/assets/svgIcons/battery.svg +3 -3
- package/src/assets/svgIcons/bell.svg +3 -3
- package/src/assets/svgIcons/bold.svg +3 -3
- package/src/assets/svgIcons/bom.svg +3 -3
- package/src/assets/svgIcons/bom_generation.svg +10 -10
- package/src/assets/svgIcons/bookmaker.svg +3 -3
- package/src/assets/svgIcons/bubble.svg +3 -3
- package/src/assets/svgIcons/bug.svg +5 -5
- package/src/assets/svgIcons/bullet_list.svg +8 -8
- package/src/assets/svgIcons/calendar.svg +7 -7
- package/src/assets/svgIcons/calendar_icon.svg +7 -7
- package/src/assets/svgIcons/call.svg +3 -3
- package/src/assets/svgIcons/camera.svg +3 -3
- package/src/assets/svgIcons/car.svg +3 -3
- package/src/assets/svgIcons/cart.svg +3 -3
- package/src/assets/svgIcons/checkbox.svg +3 -3
- package/src/assets/svgIcons/clear_formatting.svg +7 -7
- package/src/assets/svgIcons/clickable_info.svg +4 -4
- package/src/assets/svgIcons/clip.svg +3 -3
- package/src/assets/svgIcons/clock.svg +17 -17
- package/src/assets/svgIcons/close_for_modals,_tool_tips.svg +4 -4
- package/src/assets/svgIcons/co_branding.svg +5 -5
- package/src/assets/svgIcons/collapse.svg +4 -4
- package/src/assets/svgIcons/collections.svg +3 -3
- package/src/assets/svgIcons/component_library.svg +7 -7
- package/src/assets/svgIcons/context_menu-1.svg +6 -6
- package/src/assets/svgIcons/context_menu-2.svg +5 -5
- package/src/assets/svgIcons/context_menu.svg +5 -5
- package/src/assets/svgIcons/context_menu_tabs.svg +5 -5
- package/src/assets/svgIcons/cross.svg +4 -4
- package/src/assets/svgIcons/current_variant.svg +4 -4
- package/src/assets/svgIcons/dashboard.svg +3 -3
- package/src/assets/svgIcons/deadline.svg +4 -4
- package/src/assets/svgIcons/deal_flow.svg +5 -5
- package/src/assets/svgIcons/delete.svg +4 -4
- package/src/assets/svgIcons/delete_area_active.svg +16 -16
- package/src/assets/svgIcons/delete_area_inactive.svg +15 -15
- package/src/assets/svgIcons/direction_active-1.svg +12 -12
- package/src/assets/svgIcons/direction_active.svg +5 -5
- package/src/assets/svgIcons/direction_arrow.svg +4 -4
- package/src/assets/svgIcons/direction_inactive.svg +4 -4
- package/src/assets/svgIcons/dislike.svg +3 -3
- package/src/assets/svgIcons/distance_tool.svg +8 -8
- package/src/assets/svgIcons/distances_active.svg +9 -9
- package/src/assets/svgIcons/distances_inactive.svg +8 -8
- package/src/assets/svgIcons/distort_tool.svg +10 -10
- package/src/assets/svgIcons/distort_tool2.svg +16 -16
- package/src/assets/svgIcons/document.svg +3 -3
- package/src/assets/svgIcons/documents.svg +4 -4
- package/src/assets/svgIcons/downarrow.svg +3 -3
- package/src/assets/svgIcons/download.svg +4 -4
- package/src/assets/svgIcons/draggable_corner.svg +5 -5
- package/src/assets/svgIcons/draw_tool.svg +3 -3
- package/src/assets/svgIcons/duplicate-1.svg +8 -8
- package/src/assets/svgIcons/duplicate-2.svg +5 -5
- package/src/assets/svgIcons/duplicate.svg +4 -4
- package/src/assets/svgIcons/e-mobility_configurator.svg +6 -6
- package/src/assets/svgIcons/e_signature.svg +5 -5
- package/src/assets/svgIcons/edit_button.svg +3 -3
- package/src/assets/svgIcons/email.svg +3 -3
- package/src/assets/svgIcons/ems-1.svg +3 -3
- package/src/assets/svgIcons/ems.svg +3 -3
- package/src/assets/svgIcons/end_of_the_list.svg +5 -5
- package/src/assets/svgIcons/erase.svg +4 -4
- package/src/assets/svgIcons/external_icon.svg +5 -5
- package/src/assets/svgIcons/fav_icon.svg +4 -4
- package/src/assets/svgIcons/finance.svg +3 -3
- package/src/assets/svgIcons/financing_for_pv-1.svg +5 -5
- package/src/assets/svgIcons/financing_for_pv-2.svg +3 -3
- package/src/assets/svgIcons/financing_for_pv.svg +6 -6
- package/src/assets/svgIcons/finish-1.svg +4 -4
- package/src/assets/svgIcons/finish.svg +3 -3
- package/src/assets/svgIcons/flatten.svg +11 -11
- package/src/assets/svgIcons/folder.svg +3 -3
- package/src/assets/svgIcons/free_technology.svg +5 -5
- package/src/assets/svgIcons/heat_calc.svg +7 -7
- package/src/assets/svgIcons/house.svg +3 -3
- package/src/assets/svgIcons/info.svg +3 -3
- package/src/assets/svgIcons/initial_situation.svg +3 -3
- package/src/assets/svgIcons/integrations.svg +3 -3
- package/src/assets/svgIcons/intro-tour-1.svg +3 -3
- package/src/assets/svgIcons/intro-tour.svg +3 -3
- package/src/assets/svgIcons/inverter-1.svg +5 -5
- package/src/assets/svgIcons/inverter.svg +3 -3
- package/src/assets/svgIcons/italic.svg +3 -3
- package/src/assets/svgIcons/key.svg +3 -3
- package/src/assets/svgIcons/layers_close.svg +4 -4
- package/src/assets/svgIcons/layers_open.svg +4 -4
- package/src/assets/svgIcons/lead_marketplace.svg +6 -6
- package/src/assets/svgIcons/lead_provider.svg +4 -4
- package/src/assets/svgIcons/length_in_2d_active.svg +12 -12
- package/src/assets/svgIcons/length_in_2d_inctive.svg +13 -13
- package/src/assets/svgIcons/light_bulb.svg +3 -3
- package/src/assets/svgIcons/like.svg +3 -3
- package/src/assets/svgIcons/line_graph.svg +3 -3
- package/src/assets/svgIcons/local_subsidies.svg +18 -18
- package/src/assets/svgIcons/location.svg +3 -3
- package/src/assets/svgIcons/lock.svg +3 -3
- package/src/assets/svgIcons/logout.svg +3 -3
- package/src/assets/svgIcons/loop.svg +3 -3
- package/src/assets/svgIcons/lunch.svg +4 -4
- package/src/assets/svgIcons/magic_tool.svg +6 -6
- package/src/assets/svgIcons/map_icon.svg +5 -5
- package/src/assets/svgIcons/map_settings.svg +3 -3
- package/src/assets/svgIcons/margin_tool.svg +4 -4
- package/src/assets/svgIcons/meeting.svg +6 -6
- package/src/assets/svgIcons/move_copy.svg +4 -4
- package/src/assets/svgIcons/new_area_inactive.svg +11 -11
- package/src/assets/svgIcons/next.svg +4 -4
- package/src/assets/svgIcons/not_equal_to.svg +3 -3
- package/src/assets/svgIcons/numbered_list.svg +6 -6
- package/src/assets/svgIcons/obstacle_tool.svg +9 -9
- package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -3
- package/src/assets/svgIcons/offset_tool.svg +8 -8
- package/src/assets/svgIcons/outline_tool.svg +11 -11
- package/src/assets/svgIcons/pan_tool.svg +12 -12
- package/src/assets/svgIcons/panels_tool.svg +8 -8
- package/src/assets/svgIcons/pen_tool.svg +4 -4
- package/src/assets/svgIcons/picker_tool.svg +4 -4
- package/src/assets/svgIcons/picture.svg +3 -3
- package/src/assets/svgIcons/pin.svg +5 -5
- package/src/assets/svgIcons/presentation.svg +3 -3
- package/src/assets/svgIcons/previous.svg +4 -4
- package/src/assets/svgIcons/profile-1.svg +4 -4
- package/src/assets/svgIcons/profile.svg +4 -4
- package/src/assets/svgIcons/profitability.svg +3 -3
- package/src/assets/svgIcons/project_analysis.svg +4 -4
- package/src/assets/svgIcons/project_settings.svg +4 -4
- package/src/assets/svgIcons/pv.svg +3 -3
- package/src/assets/svgIcons/quotations.svg +6 -6
- package/src/assets/svgIcons/redo.svg +6 -6
- package/src/assets/svgIcons/resizer.svg +5 -5
- package/src/assets/svgIcons/roof_layer.svg +3 -3
- package/src/assets/svgIcons/rotate_tool.svg +3 -3
- package/src/assets/svgIcons/rotate_view.svg +5 -5
- package/src/assets/svgIcons/ruler_tool.svg +3 -3
- package/src/assets/svgIcons/run_simulation.svg +3 -3
- package/src/assets/svgIcons/scaling_tool.svg +8 -8
- package/src/assets/svgIcons/search.svg +3 -3
- package/src/assets/svgIcons/security.svg +3 -3
- package/src/assets/svgIcons/settings.svg +3 -3
- package/src/assets/svgIcons/show_in_a_new_tab.svg +12 -12
- package/src/assets/svgIcons/smartphone.svg +4 -4
- package/src/assets/svgIcons/solar_calc.svg +13 -13
- package/src/assets/svgIcons/sorting.svg +4 -4
- package/src/assets/svgIcons/split.svg +94 -94
- package/src/assets/svgIcons/start_of_the_list.svg +5 -5
- package/src/assets/svgIcons/strikethrough.svg +4 -4
- package/src/assets/svgIcons/subscriptions.svg +3 -3
- package/src/assets/svgIcons/subsidies-1.svg +5 -5
- package/src/assets/svgIcons/subsidies-2.svg +3 -3
- package/src/assets/svgIcons/subsidies.svg +3 -3
- package/src/assets/svgIcons/subtract_icon.svg +3 -3
- package/src/assets/svgIcons/suitcase.svg +3 -3
- package/src/assets/svgIcons/template_icon_not_clickable.svg +6 -6
- package/src/assets/svgIcons/transfer.svg +4 -4
- package/src/assets/svgIcons/trim_tool.svg +4 -4
- package/src/assets/svgIcons/truck.svg +3 -3
- package/src/assets/svgIcons/underlined.svg +3 -3
- package/src/assets/svgIcons/undo.svg +6 -6
- package/src/assets/svgIcons/uparrow.svg +3 -3
- package/src/assets/svgIcons/update.svg +3 -3
- package/src/assets/svgIcons/upload_avatar-1.svg +12 -12
- package/src/assets/svgIcons/upload_avatar.svg +5 -5
- package/src/assets/svgIcons/upload_image.svg +8 -8
- package/src/assets/svgIcons/upload_image_tool.svg +7 -7
- package/src/assets/svgIcons/variants.svg +6 -6
- package/src/assets/svgIcons/vertical_tool.svg +3 -3
- package/src/assets/svgIcons/virtual_storage.svg +4 -4
- package/src/assets/svgIcons/warning.svg +4 -4
- package/src/assets/svgIcons/way.svg +5 -5
- package/src/assets/svgIcons/wifi.svg +3 -3
- package/src/assets/svgIcons/winter.svg +3 -3
- package/src/assets/svgIcons/workflow_template.svg +11 -11
- package/src/assets/theme.js +41 -41
- package/src/components/addNewButton/AddNewButton.stories.js +24 -24
- package/src/components/addNewButton/index.vue +62 -62
- package/src/components/buttons/buttonIcon/index.vue +142 -142
- package/src/components/buttons/closeButton/CloseButton.stories.js +29 -29
- package/src/components/buttons/closeButton/index.vue +61 -61
- package/src/components/buttons/mainButton/index.vue +107 -107
- package/src/components/deleteIcon/DeleteIcon.stories.js +29 -29
- package/src/components/deleteIcon/index.vue +61 -61
- package/src/components/draggableInputHandle/index.vue +47 -47
- package/src/components/dropdown/Dropdown.stories.js +54 -54
- package/src/components/dropdown/index.vue +118 -118
- package/src/components/errorMessage/index.vue +59 -59
- package/src/components/filter/filterSettings.vue +650 -650
- package/src/components/filter/index.vue +143 -143
- package/src/components/filter/parentDropdown.vue +91 -91
- package/src/components/icon/Icons.stories.js +41 -41
- package/src/components/icon/iconCollection.vue +68 -68
- package/src/components/icon/index.vue +116 -116
- package/src/components/iconWrapper/index.vue +156 -156
- package/src/components/infoCard/index.vue +35 -35
- package/src/components/infoText/index.vue +160 -160
- package/src/components/inputs/checkbox/Checkbox.stories.js +57 -57
- package/src/components/inputs/checkbox/index.vue +187 -187
- package/src/components/inputs/inputNumber/InputNumber.stories.js +150 -150
- package/src/components/inputs/inputNumber/index.vue +714 -717
- package/src/components/inputs/inputNumberQuestion/index.vue +215 -215
- package/src/components/inputs/inputText/InputText.stories.js +75 -75
- package/src/components/inputs/inputText/index.vue +359 -359
- package/src/components/inputs/radioButton/RadioButton.stories.js +58 -58
- package/src/components/inputs/radioButton/index.vue +267 -267
- package/src/components/inputs/searchInput/SearchInput.stories.js +40 -40
- package/src/components/inputs/searchInput/index.vue +133 -133
- package/src/components/inputs/select/index.vue +627 -627
- package/src/components/inputs/select/option/index.vue +111 -111
- package/src/components/inputs/select/select.stories.js +59 -59
- package/src/components/inputs/slider/index.vue +126 -126
- package/src/components/inputs/switchField/index.vue +256 -256
- package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +127 -127
- package/src/components/inputs/textAreaInput/index.vue +200 -200
- package/src/components/inputs/toggle/Toggle.stories.js +77 -77
- package/src/components/inputs/toggle/index.vue +288 -288
- package/src/components/label/index.vue +103 -103
- package/src/components/modals/modal/index.vue +192 -192
- package/src/components/modals/modal/modal.stories.js +31 -31
- package/src/components/navigationTabs/index.vue +105 -105
- package/src/components/pageSubtitle/index.vue +61 -61
- package/src/components/pageTitle/index.vue +73 -73
- package/src/components/pagination/index.vue +144 -144
- package/src/components/progressBar/index.vue +125 -125
- package/src/components/projectMarker/index.vue +291 -291
- package/src/components/sideMenu/index.vue +270 -270
- package/src/components/spinner/index.vue +71 -71
- package/src/components/tableDropdown/index.vue +637 -637
- package/src/components/tables/mainTable/exampleNested.vue +328 -328
- package/src/components/tables/mainTable/index.vue +446 -446
- package/src/components/tables/viewTable/index.vue +195 -195
- package/src/components/threeDots/index.vue +393 -393
- package/src/components/videoThumbnail/index.vue +107 -107
- package/src/components/videoThumbnail/videoThumbnail.stories.js +35 -35
- package/src/helpers/numberConverter.js +103 -103
- package/src/helpers/translateLang.js +127 -127
- package/src/main.js +13 -13
@@ -1,627 +1,627 @@
|
|
1
|
-
<template>
|
2
|
-
<Container
|
3
|
-
:selectWidth="selectWidth"
|
4
|
-
@mouseenter="mouseEnterHandler"
|
5
|
-
@mouseleave="mouseLeaveHandler"
|
6
|
-
>
|
7
|
-
<input-wrapper
|
8
|
-
:hasLabel="!!label && label.length > 0"
|
9
|
-
:alignItems="alignItems"
|
10
|
-
>
|
11
|
-
<label-wrapper v-if="label" :data-id="labelDataId">
|
12
|
-
<input-label
|
13
|
-
:fontColor="
|
14
|
-
labelFontColor || colorMode == 'dark' ? 'white' : 'eturnityGrey'
|
15
|
-
"
|
16
|
-
:fontSize="fontSize"
|
17
|
-
>{{ label }}
|
18
|
-
<optionalLabel v-if="labelOptional">
|
19
|
-
({{ $gettext('Optional') }})</optionalLabel
|
20
|
-
>
|
21
|
-
</input-label>
|
22
|
-
<info-text
|
23
|
-
v-if="infoTextMessage"
|
24
|
-
:text="infoTextMessage"
|
25
|
-
:size="infoTextSize"
|
26
|
-
/>
|
27
|
-
</label-wrapper>
|
28
|
-
<select-button-wrapper :disabled="disabled">
|
29
|
-
<selectButton
|
30
|
-
ref="select"
|
31
|
-
@click="toggleDropdown"
|
32
|
-
:selectHeight="selectHeight"
|
33
|
-
:height="height"
|
34
|
-
:selectMinHeight="selectMinHeight"
|
35
|
-
:bgColor="
|
36
|
-
buttonBgColor || colorMode == 'dark' ? 'transparentBlack1' : 'white'
|
37
|
-
"
|
38
|
-
:fontColor="
|
39
|
-
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
40
|
-
"
|
41
|
-
:hasError="hasError"
|
42
|
-
:isSearchBarVisible="isSearchBarVisible"
|
43
|
-
:disabled="disabled"
|
44
|
-
@keydown.native="onKeyDown"
|
45
|
-
:showBorder="showBorder"
|
46
|
-
:data-id="dataId"
|
47
|
-
:paddingLeft="paddingLeft"
|
48
|
-
>
|
49
|
-
<draggableInputHandle
|
50
|
-
v-if="isDraggable && !isSearchBarVisible"
|
51
|
-
:height="selectHeight"
|
52
|
-
/>
|
53
|
-
<inputText
|
54
|
-
v-if="isSearchBarVisible"
|
55
|
-
ref="searchInput"
|
56
|
-
tabindex="0"
|
57
|
-
inputHeight="34px"
|
58
|
-
:noBorder="true"
|
59
|
-
:fontSize="fontSize"
|
60
|
-
backgroundColor="transparent"
|
61
|
-
:fontColor="
|
62
|
-
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
63
|
-
"
|
64
|
-
:value="textSearch"
|
65
|
-
@keydown.stop="onKeyDown"
|
66
|
-
@input-change="searchChange"
|
67
|
-
@click.native.stop
|
68
|
-
/>
|
69
|
-
<selector
|
70
|
-
v-else
|
71
|
-
:showBorder="showBorder"
|
72
|
-
:selectWidth="selectWidth"
|
73
|
-
:paddingLeft="paddingLeft"
|
74
|
-
>
|
75
|
-
<slot name="selector" :selectedValue="selectedValue"></slot>
|
76
|
-
</selector>
|
77
|
-
<Caret @click.stop="toggleCaretDropdown">
|
78
|
-
<icon
|
79
|
-
v-if="isDropdownOpen"
|
80
|
-
name="arrow_up"
|
81
|
-
size="12px"
|
82
|
-
:color="
|
83
|
-
caretColor || colorMode == 'dark'
|
84
|
-
? 'white'
|
85
|
-
: 'transparentBlack1'
|
86
|
-
"
|
87
|
-
/>
|
88
|
-
<icon
|
89
|
-
v-else
|
90
|
-
name="arrow_down"
|
91
|
-
size="12px"
|
92
|
-
:color="
|
93
|
-
caretColor || colorMode == 'dark'
|
94
|
-
? 'white'
|
95
|
-
: 'transparentBlack1'
|
96
|
-
"
|
97
|
-
/>
|
98
|
-
</Caret>
|
99
|
-
</selectButton>
|
100
|
-
<DropdownWrapper>
|
101
|
-
<selectDropdown
|
102
|
-
ref="dropdown"
|
103
|
-
v-show="isDropdownOpen"
|
104
|
-
:hoveredIndex="hoveredIndex"
|
105
|
-
:hoveredValue="hoveredValue"
|
106
|
-
:isActive="isActive"
|
107
|
-
:optionWidth="optionWidth"
|
108
|
-
:hoveredBgColor="colorMode == 'dark' ? '#000000' : dropdownBgColor"
|
109
|
-
:bgColor="colorMode == 'dark' ? 'black' : dropdownBgColor"
|
110
|
-
:fontColor="
|
111
|
-
dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
|
112
|
-
"
|
113
|
-
:selectedValue="selectedValue"
|
114
|
-
@option-selected="optionSelected"
|
115
|
-
@option-hovered="optionHovered"
|
116
|
-
@mouseleave="optionLeave"
|
117
|
-
>
|
118
|
-
<slot name="dropdown"></slot>
|
119
|
-
</selectDropdown>
|
120
|
-
</DropdownWrapper>
|
121
|
-
</select-button-wrapper>
|
122
|
-
</input-wrapper>
|
123
|
-
</Container>
|
124
|
-
</template>
|
125
|
-
|
126
|
-
<script>
|
127
|
-
//How to use it
|
128
|
-
// <Select
|
129
|
-
// hoverDropdown="true"
|
130
|
-
// selectWidth="100%"
|
131
|
-
// optionWidth="50%"
|
132
|
-
// label="that is a label"
|
133
|
-
// alignItems="vertical"
|
134
|
-
// label-data-id="test-label0data-id"
|
135
|
-
// data-id="test-data-id"
|
136
|
-
// >
|
137
|
-
// <template #selector="{selectedValue}">
|
138
|
-
// value selected: {{selectedValue}}
|
139
|
-
// </template>
|
140
|
-
// <template #dropdown>
|
141
|
-
// <Option value="1">value one</Option>
|
142
|
-
// <Option value="2">value two</Option>
|
143
|
-
// <Option value="3">value three</Option>
|
144
|
-
// <Option value="4">value four</Option>
|
145
|
-
// </template>
|
146
|
-
// </Select>
|
147
|
-
|
148
|
-
import styled from 'vue-styled-components'
|
149
|
-
import InfoText from '../../infoText'
|
150
|
-
import icon from '../../icon'
|
151
|
-
import inputText from '../inputText'
|
152
|
-
import draggableInputHandle from '../../draggableInputHandle'
|
153
|
-
|
154
|
-
const CARET_WIDTH = '30px'
|
155
|
-
const BORDER_WIDTH = '1px'
|
156
|
-
|
157
|
-
const Caret = styled.div`
|
158
|
-
display: flex;
|
159
|
-
align-items: center;
|
160
|
-
justify-content: center;
|
161
|
-
width: ${CARET_WIDTH};
|
162
|
-
min-width: ${CARET_WIDTH};
|
163
|
-
height: 100%;
|
164
|
-
align-items: stretch;
|
165
|
-
cursor: pointer;
|
166
|
-
margin-left: auto;
|
167
|
-
`
|
168
|
-
|
169
|
-
const selectorProps = {
|
170
|
-
selectWidth: String,
|
171
|
-
paddingLeft: String,
|
172
|
-
showBorder: Boolean
|
173
|
-
}
|
174
|
-
const Selector = styled('div', selectorProps)`
|
175
|
-
${(props) => props.selectWidth === '100%' ? 'width: 100%;' : `width: calc(${props.selectWidth} -
|
176
|
-
(
|
177
|
-
${CARET_WIDTH} +
|
178
|
-
${props.paddingLeft}
|
179
|
-
${props.showBorder ? `+ (${BORDER_WIDTH} * 2)` : ''}
|
180
|
-
)
|
181
|
-
);
|
182
|
-
white-space: nowrap;
|
183
|
-
text-overflow: ellipsis;
|
184
|
-
overflow: hidden;`
|
185
|
-
}
|
186
|
-
`
|
187
|
-
|
188
|
-
const labelAttrs = { fontSize: String, fontColor: String }
|
189
|
-
const InputLabel = styled('div', labelAttrs)`
|
190
|
-
color: ${(props) =>
|
191
|
-
props.theme.colors[props.fontColor]
|
192
|
-
? props.theme.colors[props.fontColor]
|
193
|
-
: props.fontColor};
|
194
|
-
font-size: ${(props) => props.fontSize};
|
195
|
-
font-weight: 700;
|
196
|
-
`
|
197
|
-
const optionalLabel = styled.span`
|
198
|
-
font-weight: 300;
|
199
|
-
`
|
200
|
-
const inputProps = { selectWidth: String, optionWidth: String }
|
201
|
-
const Container = styled('div', inputProps)`
|
202
|
-
width: ${(props) => props.selectWidth};
|
203
|
-
position: relative;
|
204
|
-
display: inline-block;
|
205
|
-
`
|
206
|
-
const LabelWrapper = styled.div`
|
207
|
-
display: inline-grid;
|
208
|
-
grid-template-columns: auto auto;
|
209
|
-
grid-gap: 12px;
|
210
|
-
align-items: center;
|
211
|
-
justify-content: start;
|
212
|
-
`
|
213
|
-
|
214
|
-
const SelectButtonWrapperAttrs = {
|
215
|
-
disabled: Boolean
|
216
|
-
}
|
217
|
-
const SelectButtonWrapper = styled('div', SelectButtonWrapperAttrs)`
|
218
|
-
${(props) => (props.disabled ? 'cursor: not-allowed' : 'cursor: pointer')};
|
219
|
-
`
|
220
|
-
|
221
|
-
const selectButtonAttrs = {
|
222
|
-
bgColor: String,
|
223
|
-
fontColor: String,
|
224
|
-
hasError: Boolean,
|
225
|
-
disabled: Boolean,
|
226
|
-
selectHeight: String,
|
227
|
-
height: String,
|
228
|
-
selectMinHeight: String,
|
229
|
-
isSearchBarVisible: Boolean,
|
230
|
-
showBorder: Boolean,
|
231
|
-
paddingLeft: String
|
232
|
-
}
|
233
|
-
const selectButton = styled('div', selectButtonAttrs)`
|
234
|
-
position: relative;
|
235
|
-
box-sizing: border-box;
|
236
|
-
border-radius: 4px;
|
237
|
-
${(props) =>
|
238
|
-
props.isSearchBarVisible ? '' : `padding-left: ${props.paddingLeft}`};
|
239
|
-
text-align: left;
|
240
|
-
min-height: ${(props) =>
|
241
|
-
props.selectHeight
|
242
|
-
? props.selectHeight
|
243
|
-
: props.selectMinHeight
|
244
|
-
? props.selectMinHeight
|
245
|
-
: props.height
|
246
|
-
? props.height
|
247
|
-
: '36px'};
|
248
|
-
display: flex;
|
249
|
-
align-items: center;
|
250
|
-
max-height: ${(props) => props.selectHeight};
|
251
|
-
${({ showBorder, theme, hasError }) =>
|
252
|
-
showBorder &&
|
253
|
-
`
|
254
|
-
border: ${BORDER_WIDTH} solid ${
|
255
|
-
hasError ? theme.colors.red : theme.colors.grey4
|
256
|
-
}
|
257
|
-
`}
|
258
|
-
background-color:${(props) =>
|
259
|
-
props.disabled
|
260
|
-
? props.theme.colors.grey5
|
261
|
-
: props.theme.colors[props.bgColor]
|
262
|
-
? props.theme.colors[props.bgColor]
|
263
|
-
: props.bgColor};
|
264
|
-
color: ${(props) =>
|
265
|
-
props.theme.colors[props.fontColor]
|
266
|
-
? props.theme.colors[props.fontColor]
|
267
|
-
: props.fontColor};
|
268
|
-
${(props) => (props.disabled ? 'pointer-events: none' : '')};
|
269
|
-
overflow: hidden;
|
270
|
-
& > .handle {
|
271
|
-
border-right: ${(props) =>
|
272
|
-
props.hasError ? props.theme.colors.red : props.theme.colors.grey4}
|
273
|
-
1px solid;
|
274
|
-
}
|
275
|
-
`
|
276
|
-
const selectDropdownAttrs = {
|
277
|
-
hoveredBgColor: String,
|
278
|
-
bgColor: String,
|
279
|
-
fontColor: String,
|
280
|
-
optionWidth: String,
|
281
|
-
hoveredIndex: Number,
|
282
|
-
hoveredValue: Number | String,
|
283
|
-
selectedValue: Number | String
|
284
|
-
}
|
285
|
-
const selectDropdown = styled('div', selectDropdownAttrs)`
|
286
|
-
box-sizing: border-box;
|
287
|
-
z-index: ${(props) => (props.isActive ? '2' : '1')};
|
288
|
-
position: absolute;
|
289
|
-
top: 5px;
|
290
|
-
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
291
|
-
border-radius: 4px;
|
292
|
-
display: flex;
|
293
|
-
flex-direction: column;
|
294
|
-
align-items: flex-start;
|
295
|
-
padding: 0px;
|
296
|
-
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
297
|
-
width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
|
298
|
-
background-color: ${(props) =>
|
299
|
-
props.theme.colors[props.bgColor]
|
300
|
-
? props.theme.colors[props.bgColor]
|
301
|
-
: props.bgColor};
|
302
|
-
color: ${(props) =>
|
303
|
-
props.theme.colors[props.fontColor]
|
304
|
-
? props.theme.colors[props.fontColor]
|
305
|
-
: props.fontColor};
|
306
|
-
max-height: 300px;
|
307
|
-
overflow-y: auto;
|
308
|
-
& > div[data-value='${(props) => props.hoveredValue}'] {
|
309
|
-
background-color: ${(props) =>
|
310
|
-
props.theme.colors[props.hoveredBgColor]
|
311
|
-
? props.theme.colors[props.hoveredBgColor]
|
312
|
-
: props.hoveredBgColor};
|
313
|
-
}
|
314
|
-
`
|
315
|
-
const DropdownWrapper = styled('div')`
|
316
|
-
position: relative;
|
317
|
-
`
|
318
|
-
const inputAttrs = { alignItems: String, hasLabel: Boolean }
|
319
|
-
const InputWrapper = styled('div', inputAttrs)`
|
320
|
-
position: relative;
|
321
|
-
display: grid;
|
322
|
-
align-items: center;
|
323
|
-
gap: 8px;
|
324
|
-
grid-template-columns: ${(props) =>
|
325
|
-
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
326
|
-
`
|
327
|
-
export default {
|
328
|
-
name: 'RCselect',
|
329
|
-
|
330
|
-
props: {
|
331
|
-
value: {
|
332
|
-
required: false,
|
333
|
-
default: null
|
334
|
-
},
|
335
|
-
fontSize: {
|
336
|
-
required: false,
|
337
|
-
default: '13px'
|
338
|
-
},
|
339
|
-
label: {
|
340
|
-
required: false
|
341
|
-
},
|
342
|
-
labelOptional: {
|
343
|
-
required: false,
|
344
|
-
default: false
|
345
|
-
},
|
346
|
-
labelDataId: {
|
347
|
-
required: false,
|
348
|
-
default: ''
|
349
|
-
},
|
350
|
-
infoTextMessage: {
|
351
|
-
required: false
|
352
|
-
},
|
353
|
-
selectWidth: {
|
354
|
-
type: String,
|
355
|
-
required: false,
|
356
|
-
default: '100%'
|
357
|
-
},
|
358
|
-
selectHeight: {
|
359
|
-
type: String,
|
360
|
-
required: false,
|
361
|
-
default: null
|
362
|
-
},
|
363
|
-
height: {
|
364
|
-
required: false,
|
365
|
-
default: null
|
366
|
-
},
|
367
|
-
selectMinHeight: {
|
368
|
-
required: false,
|
369
|
-
default: '36px'
|
370
|
-
},
|
371
|
-
optionWidth: {
|
372
|
-
required: false,
|
373
|
-
default: null
|
374
|
-
},
|
375
|
-
hoverDropdown: {
|
376
|
-
required: false,
|
377
|
-
default: false
|
378
|
-
},
|
379
|
-
dropdownAutoClose: {
|
380
|
-
required: false,
|
381
|
-
default: false
|
382
|
-
},
|
383
|
-
alignItems: {
|
384
|
-
required: false,
|
385
|
-
default: 'horizontal'
|
386
|
-
},
|
387
|
-
buttonBgColor: {
|
388
|
-
required: false
|
389
|
-
},
|
390
|
-
buttonFontColor: {
|
391
|
-
required: false
|
392
|
-
},
|
393
|
-
dropdownBgColor: {
|
394
|
-
required: false,
|
395
|
-
default: 'grey5'
|
396
|
-
},
|
397
|
-
dropdownFontColor: {
|
398
|
-
required: false
|
399
|
-
},
|
400
|
-
caretColor: {
|
401
|
-
required: false
|
402
|
-
},
|
403
|
-
labelFontColor: {
|
404
|
-
required: false
|
405
|
-
},
|
406
|
-
colorMode: {
|
407
|
-
required: false,
|
408
|
-
default: 'light'
|
409
|
-
},
|
410
|
-
isSearchable: {
|
411
|
-
required: false,
|
412
|
-
default: true
|
413
|
-
},
|
414
|
-
hasError: {
|
415
|
-
required: false,
|
416
|
-
default: false
|
417
|
-
},
|
418
|
-
disabled: {
|
419
|
-
required: false,
|
420
|
-
default: false
|
421
|
-
},
|
422
|
-
isAutoSearch: {
|
423
|
-
required: false,
|
424
|
-
default: true
|
425
|
-
},
|
426
|
-
showBorder: {
|
427
|
-
required: false,
|
428
|
-
default: true
|
429
|
-
},
|
430
|
-
infoTextSize: {
|
431
|
-
required: false,
|
432
|
-
default: '14px'
|
433
|
-
},
|
434
|
-
dataId: {
|
435
|
-
type: String,
|
436
|
-
default: ''
|
437
|
-
},
|
438
|
-
isDraggable: {
|
439
|
-
type: Boolean,
|
440
|
-
default: false
|
441
|
-
}
|
442
|
-
},
|
443
|
-
|
444
|
-
components: {
|
445
|
-
selectButton,
|
446
|
-
SelectButtonWrapper,
|
447
|
-
selectDropdown,
|
448
|
-
Container,
|
449
|
-
InputLabel,
|
450
|
-
LabelWrapper,
|
451
|
-
optionalLabel,
|
452
|
-
InfoText,
|
453
|
-
InputWrapper,
|
454
|
-
DropdownWrapper,
|
455
|
-
icon,
|
456
|
-
Caret,
|
457
|
-
Selector,
|
458
|
-
inputText,
|
459
|
-
draggableInputHandle
|
460
|
-
},
|
461
|
-
|
462
|
-
data() {
|
463
|
-
return {
|
464
|
-
selectedValue: null,
|
465
|
-
paddingLeft: this.isDraggable ? '30px' : '15px',
|
466
|
-
isDropdownOpen: false,
|
467
|
-
isActive: false,
|
468
|
-
textSearch: '',
|
469
|
-
hoveredIndex: 0,
|
470
|
-
hoveredValue: null,
|
471
|
-
isClickOutsideActive: false
|
472
|
-
}
|
473
|
-
},
|
474
|
-
mounted() {
|
475
|
-
this.selectedValue = this.value
|
476
|
-
document.addEventListener('click', this.clickOutside)
|
477
|
-
},
|
478
|
-
beforeDestroy() {
|
479
|
-
document.removeEventListener('click', this.clickOutside)
|
480
|
-
},
|
481
|
-
methods: {
|
482
|
-
focus() {
|
483
|
-
this.isActive = true
|
484
|
-
},
|
485
|
-
blur() {
|
486
|
-
this.isActive = false
|
487
|
-
},
|
488
|
-
toggleDropdown() {
|
489
|
-
this.isDropdownOpen = !this.isDropdownOpen
|
490
|
-
},
|
491
|
-
toggleCaretDropdown() {
|
492
|
-
this.isDropdownOpen = !this.isDropdownOpen
|
493
|
-
},
|
494
|
-
openDropdown() {
|
495
|
-
this.focus()
|
496
|
-
this.isDropdownOpen = true
|
497
|
-
},
|
498
|
-
closeDropdown() {
|
499
|
-
this.blur()
|
500
|
-
this.isDropdownOpen = false
|
501
|
-
},
|
502
|
-
optionSelected(e) {
|
503
|
-
this.selectedValue = e
|
504
|
-
this.closeDropdown()
|
505
|
-
this.blur()
|
506
|
-
this.$emit('input-change', e)
|
507
|
-
},
|
508
|
-
optionHovered(e) {
|
509
|
-
this.hoveredValue = e
|
510
|
-
},
|
511
|
-
mouseEnterHandler() {
|
512
|
-
if (this.hoverDropdown) {
|
513
|
-
this.focus()
|
514
|
-
this.isDropdownOpen = true
|
515
|
-
}
|
516
|
-
},
|
517
|
-
mouseLeaveHandler() {
|
518
|
-
if (this.hoverDropdown) {
|
519
|
-
this.blur()
|
520
|
-
}
|
521
|
-
},
|
522
|
-
optionLeave() {
|
523
|
-
if (this.dropdownAutoClose) {
|
524
|
-
this.isDropdownOpen = false
|
525
|
-
}
|
526
|
-
},
|
527
|
-
searchChange(value) {
|
528
|
-
this.textSearch = value
|
529
|
-
this.$emit('search-change', value)
|
530
|
-
this.$refs.dropdown.$children
|
531
|
-
.map((component) => component.$el)
|
532
|
-
.forEach((el) => {
|
533
|
-
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
534
|
-
el.style.display = 'none'
|
535
|
-
} else {
|
536
|
-
el.style.display = 'inherit'
|
537
|
-
}
|
538
|
-
})
|
539
|
-
},
|
540
|
-
clickOutside(event) {
|
541
|
-
const dropdownRef = this.$refs.dropdown
|
542
|
-
// we need to prevent closing on selecting an option, because in the case of
|
543
|
-
// a disabled option, we don't want to close the dropdown
|
544
|
-
if (!this.isClickOutsideActive) return
|
545
|
-
if (
|
546
|
-
this.$refs.select.$el == event.target ||
|
547
|
-
this.$refs.select.$el.contains(event.target) ||
|
548
|
-
event.target.parentNode === dropdownRef.$el
|
549
|
-
) {
|
550
|
-
return
|
551
|
-
} else {
|
552
|
-
this.closeDropdown()
|
553
|
-
}
|
554
|
-
},
|
555
|
-
onKeyDown(e) {
|
556
|
-
if (e.key == 'ArrowDown') {
|
557
|
-
this.onArrowPress(1)
|
558
|
-
} else if (e.key == 'ArrowUp') {
|
559
|
-
this.onArrowPress(-1)
|
560
|
-
} else if (e.key == 'Enter') {
|
561
|
-
const optionHoveredComponent =
|
562
|
-
this.$refs.dropdown.$children[
|
563
|
-
(this.hoveredIndex - 1 + this.optionLength) % this.optionLength
|
564
|
-
]
|
565
|
-
this.optionSelected(optionHoveredComponent.$el.dataset.value)
|
566
|
-
}
|
567
|
-
},
|
568
|
-
onArrowPress(dir) {
|
569
|
-
let newHoveredElem
|
570
|
-
const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
|
571
|
-
`[data-value="${this.hoveredValue}"]`
|
572
|
-
)
|
573
|
-
if (currentHoveredElem) {
|
574
|
-
if (dir > 0) {
|
575
|
-
newHoveredElem = currentHoveredElem.nextElementSibling
|
576
|
-
} else {
|
577
|
-
newHoveredElem = currentHoveredElem.previousElementSibling
|
578
|
-
}
|
579
|
-
if (newHoveredElem) {
|
580
|
-
this.hoveredValue = newHoveredElem.getAttribute('data-value')
|
581
|
-
const topPos = newHoveredElem.offsetTop
|
582
|
-
this.$refs.dropdown.$el.scrollTop = topPos
|
583
|
-
}
|
584
|
-
}
|
585
|
-
},
|
586
|
-
clearSearch() {
|
587
|
-
this.textSearch = ''
|
588
|
-
}
|
589
|
-
},
|
590
|
-
computed: {
|
591
|
-
optionLength() {
|
592
|
-
if (this.isDropdownOpen) {
|
593
|
-
return this.$refs.dropdown.$el.childElementCount
|
594
|
-
}
|
595
|
-
|
596
|
-
return 0
|
597
|
-
},
|
598
|
-
isSearchBarVisible() {
|
599
|
-
return this.isSearchable && this.isDropdownOpen
|
600
|
-
}
|
601
|
-
},
|
602
|
-
watch: {
|
603
|
-
value(val) {
|
604
|
-
this.selectedValue = val
|
605
|
-
},
|
606
|
-
isDropdownOpen(val) {
|
607
|
-
this.$emit('is-dropdown-open', val)
|
608
|
-
if (val) {
|
609
|
-
setTimeout(() => {
|
610
|
-
this.isClickOutsideActive = true
|
611
|
-
}, 10)
|
612
|
-
} else {
|
613
|
-
setTimeout(() => {
|
614
|
-
this.isClickOutsideActive = false
|
615
|
-
}, 10)
|
616
|
-
}
|
617
|
-
if (val && this.isSearchable) {
|
618
|
-
this.$nextTick(() => {
|
619
|
-
if (this.$refs.searchInput) {
|
620
|
-
this.$refs.searchInput.$el.querySelector('input').focus()
|
621
|
-
}
|
622
|
-
})
|
623
|
-
}
|
624
|
-
}
|
625
|
-
}
|
626
|
-
}
|
627
|
-
</script>
|
1
|
+
<template>
|
2
|
+
<Container
|
3
|
+
:selectWidth="selectWidth"
|
4
|
+
@mouseenter="mouseEnterHandler"
|
5
|
+
@mouseleave="mouseLeaveHandler"
|
6
|
+
>
|
7
|
+
<input-wrapper
|
8
|
+
:hasLabel="!!label && label.length > 0"
|
9
|
+
:alignItems="alignItems"
|
10
|
+
>
|
11
|
+
<label-wrapper v-if="label" :data-id="labelDataId">
|
12
|
+
<input-label
|
13
|
+
:fontColor="
|
14
|
+
labelFontColor || colorMode == 'dark' ? 'white' : 'eturnityGrey'
|
15
|
+
"
|
16
|
+
:fontSize="fontSize"
|
17
|
+
>{{ label }}
|
18
|
+
<optionalLabel v-if="labelOptional">
|
19
|
+
({{ $gettext('Optional') }})</optionalLabel
|
20
|
+
>
|
21
|
+
</input-label>
|
22
|
+
<info-text
|
23
|
+
v-if="infoTextMessage"
|
24
|
+
:text="infoTextMessage"
|
25
|
+
:size="infoTextSize"
|
26
|
+
/>
|
27
|
+
</label-wrapper>
|
28
|
+
<select-button-wrapper :disabled="disabled">
|
29
|
+
<selectButton
|
30
|
+
ref="select"
|
31
|
+
@click="toggleDropdown"
|
32
|
+
:selectHeight="selectHeight"
|
33
|
+
:height="height"
|
34
|
+
:selectMinHeight="selectMinHeight"
|
35
|
+
:bgColor="
|
36
|
+
buttonBgColor || colorMode == 'dark' ? 'transparentBlack1' : 'white'
|
37
|
+
"
|
38
|
+
:fontColor="
|
39
|
+
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
40
|
+
"
|
41
|
+
:hasError="hasError"
|
42
|
+
:isSearchBarVisible="isSearchBarVisible"
|
43
|
+
:disabled="disabled"
|
44
|
+
@keydown.native="onKeyDown"
|
45
|
+
:showBorder="showBorder"
|
46
|
+
:data-id="dataId"
|
47
|
+
:paddingLeft="paddingLeft"
|
48
|
+
>
|
49
|
+
<draggableInputHandle
|
50
|
+
v-if="isDraggable && !isSearchBarVisible"
|
51
|
+
:height="selectHeight"
|
52
|
+
/>
|
53
|
+
<inputText
|
54
|
+
v-if="isSearchBarVisible"
|
55
|
+
ref="searchInput"
|
56
|
+
tabindex="0"
|
57
|
+
inputHeight="34px"
|
58
|
+
:noBorder="true"
|
59
|
+
:fontSize="fontSize"
|
60
|
+
backgroundColor="transparent"
|
61
|
+
:fontColor="
|
62
|
+
buttonFontColor || colorMode == 'dark' ? 'white' : 'black'
|
63
|
+
"
|
64
|
+
:value="textSearch"
|
65
|
+
@keydown.stop="onKeyDown"
|
66
|
+
@input-change="searchChange"
|
67
|
+
@click.native.stop
|
68
|
+
/>
|
69
|
+
<selector
|
70
|
+
v-else
|
71
|
+
:showBorder="showBorder"
|
72
|
+
:selectWidth="selectWidth"
|
73
|
+
:paddingLeft="paddingLeft"
|
74
|
+
>
|
75
|
+
<slot name="selector" :selectedValue="selectedValue"></slot>
|
76
|
+
</selector>
|
77
|
+
<Caret @click.stop="toggleCaretDropdown">
|
78
|
+
<icon
|
79
|
+
v-if="isDropdownOpen"
|
80
|
+
name="arrow_up"
|
81
|
+
size="12px"
|
82
|
+
:color="
|
83
|
+
caretColor || colorMode == 'dark'
|
84
|
+
? 'white'
|
85
|
+
: 'transparentBlack1'
|
86
|
+
"
|
87
|
+
/>
|
88
|
+
<icon
|
89
|
+
v-else
|
90
|
+
name="arrow_down"
|
91
|
+
size="12px"
|
92
|
+
:color="
|
93
|
+
caretColor || colorMode == 'dark'
|
94
|
+
? 'white'
|
95
|
+
: 'transparentBlack1'
|
96
|
+
"
|
97
|
+
/>
|
98
|
+
</Caret>
|
99
|
+
</selectButton>
|
100
|
+
<DropdownWrapper>
|
101
|
+
<selectDropdown
|
102
|
+
ref="dropdown"
|
103
|
+
v-show="isDropdownOpen"
|
104
|
+
:hoveredIndex="hoveredIndex"
|
105
|
+
:hoveredValue="hoveredValue"
|
106
|
+
:isActive="isActive"
|
107
|
+
:optionWidth="optionWidth"
|
108
|
+
:hoveredBgColor="colorMode == 'dark' ? '#000000' : dropdownBgColor"
|
109
|
+
:bgColor="colorMode == 'dark' ? 'black' : dropdownBgColor"
|
110
|
+
:fontColor="
|
111
|
+
dropdownFontColor || colorMode == 'dark' ? 'white' : 'black'
|
112
|
+
"
|
113
|
+
:selectedValue="selectedValue"
|
114
|
+
@option-selected="optionSelected"
|
115
|
+
@option-hovered="optionHovered"
|
116
|
+
@mouseleave="optionLeave"
|
117
|
+
>
|
118
|
+
<slot name="dropdown"></slot>
|
119
|
+
</selectDropdown>
|
120
|
+
</DropdownWrapper>
|
121
|
+
</select-button-wrapper>
|
122
|
+
</input-wrapper>
|
123
|
+
</Container>
|
124
|
+
</template>
|
125
|
+
|
126
|
+
<script>
|
127
|
+
//How to use it
|
128
|
+
// <Select
|
129
|
+
// hoverDropdown="true"
|
130
|
+
// selectWidth="100%"
|
131
|
+
// optionWidth="50%"
|
132
|
+
// label="that is a label"
|
133
|
+
// alignItems="vertical"
|
134
|
+
// label-data-id="test-label0data-id"
|
135
|
+
// data-id="test-data-id"
|
136
|
+
// >
|
137
|
+
// <template #selector="{selectedValue}">
|
138
|
+
// value selected: {{selectedValue}}
|
139
|
+
// </template>
|
140
|
+
// <template #dropdown>
|
141
|
+
// <Option value="1">value one</Option>
|
142
|
+
// <Option value="2">value two</Option>
|
143
|
+
// <Option value="3">value three</Option>
|
144
|
+
// <Option value="4">value four</Option>
|
145
|
+
// </template>
|
146
|
+
// </Select>
|
147
|
+
|
148
|
+
import styled from 'vue-styled-components'
|
149
|
+
import InfoText from '../../infoText'
|
150
|
+
import icon from '../../icon'
|
151
|
+
import inputText from '../inputText'
|
152
|
+
import draggableInputHandle from '../../draggableInputHandle'
|
153
|
+
|
154
|
+
const CARET_WIDTH = '30px'
|
155
|
+
const BORDER_WIDTH = '1px'
|
156
|
+
|
157
|
+
const Caret = styled.div`
|
158
|
+
display: flex;
|
159
|
+
align-items: center;
|
160
|
+
justify-content: center;
|
161
|
+
width: ${CARET_WIDTH};
|
162
|
+
min-width: ${CARET_WIDTH};
|
163
|
+
height: 100%;
|
164
|
+
align-items: stretch;
|
165
|
+
cursor: pointer;
|
166
|
+
margin-left: auto;
|
167
|
+
`
|
168
|
+
|
169
|
+
const selectorProps = {
|
170
|
+
selectWidth: String,
|
171
|
+
paddingLeft: String,
|
172
|
+
showBorder: Boolean
|
173
|
+
}
|
174
|
+
const Selector = styled('div', selectorProps)`
|
175
|
+
${(props) => props.selectWidth === '100%' ? 'width: 100%;' : `width: calc(${props.selectWidth} -
|
176
|
+
(
|
177
|
+
${CARET_WIDTH} +
|
178
|
+
${props.paddingLeft}
|
179
|
+
${props.showBorder ? `+ (${BORDER_WIDTH} * 2)` : ''}
|
180
|
+
)
|
181
|
+
);
|
182
|
+
white-space: nowrap;
|
183
|
+
text-overflow: ellipsis;
|
184
|
+
overflow: hidden;`
|
185
|
+
}
|
186
|
+
`
|
187
|
+
|
188
|
+
const labelAttrs = { fontSize: String, fontColor: String }
|
189
|
+
const InputLabel = styled('div', labelAttrs)`
|
190
|
+
color: ${(props) =>
|
191
|
+
props.theme.colors[props.fontColor]
|
192
|
+
? props.theme.colors[props.fontColor]
|
193
|
+
: props.fontColor};
|
194
|
+
font-size: ${(props) => props.fontSize};
|
195
|
+
font-weight: 700;
|
196
|
+
`
|
197
|
+
const optionalLabel = styled.span`
|
198
|
+
font-weight: 300;
|
199
|
+
`
|
200
|
+
const inputProps = { selectWidth: String, optionWidth: String }
|
201
|
+
const Container = styled('div', inputProps)`
|
202
|
+
width: ${(props) => props.selectWidth};
|
203
|
+
position: relative;
|
204
|
+
display: inline-block;
|
205
|
+
`
|
206
|
+
const LabelWrapper = styled.div`
|
207
|
+
display: inline-grid;
|
208
|
+
grid-template-columns: auto auto;
|
209
|
+
grid-gap: 12px;
|
210
|
+
align-items: center;
|
211
|
+
justify-content: start;
|
212
|
+
`
|
213
|
+
|
214
|
+
const SelectButtonWrapperAttrs = {
|
215
|
+
disabled: Boolean
|
216
|
+
}
|
217
|
+
const SelectButtonWrapper = styled('div', SelectButtonWrapperAttrs)`
|
218
|
+
${(props) => (props.disabled ? 'cursor: not-allowed' : 'cursor: pointer')};
|
219
|
+
`
|
220
|
+
|
221
|
+
const selectButtonAttrs = {
|
222
|
+
bgColor: String,
|
223
|
+
fontColor: String,
|
224
|
+
hasError: Boolean,
|
225
|
+
disabled: Boolean,
|
226
|
+
selectHeight: String,
|
227
|
+
height: String,
|
228
|
+
selectMinHeight: String,
|
229
|
+
isSearchBarVisible: Boolean,
|
230
|
+
showBorder: Boolean,
|
231
|
+
paddingLeft: String
|
232
|
+
}
|
233
|
+
const selectButton = styled('div', selectButtonAttrs)`
|
234
|
+
position: relative;
|
235
|
+
box-sizing: border-box;
|
236
|
+
border-radius: 4px;
|
237
|
+
${(props) =>
|
238
|
+
props.isSearchBarVisible ? '' : `padding-left: ${props.paddingLeft}`};
|
239
|
+
text-align: left;
|
240
|
+
min-height: ${(props) =>
|
241
|
+
props.selectHeight
|
242
|
+
? props.selectHeight
|
243
|
+
: props.selectMinHeight
|
244
|
+
? props.selectMinHeight
|
245
|
+
: props.height
|
246
|
+
? props.height
|
247
|
+
: '36px'};
|
248
|
+
display: flex;
|
249
|
+
align-items: center;
|
250
|
+
max-height: ${(props) => props.selectHeight};
|
251
|
+
${({ showBorder, theme, hasError }) =>
|
252
|
+
showBorder &&
|
253
|
+
`
|
254
|
+
border: ${BORDER_WIDTH} solid ${
|
255
|
+
hasError ? theme.colors.red : theme.colors.grey4
|
256
|
+
}
|
257
|
+
`}
|
258
|
+
background-color:${(props) =>
|
259
|
+
props.disabled
|
260
|
+
? props.theme.colors.grey5
|
261
|
+
: props.theme.colors[props.bgColor]
|
262
|
+
? props.theme.colors[props.bgColor]
|
263
|
+
: props.bgColor};
|
264
|
+
color: ${(props) =>
|
265
|
+
props.theme.colors[props.fontColor]
|
266
|
+
? props.theme.colors[props.fontColor]
|
267
|
+
: props.fontColor};
|
268
|
+
${(props) => (props.disabled ? 'pointer-events: none' : '')};
|
269
|
+
overflow: hidden;
|
270
|
+
& > .handle {
|
271
|
+
border-right: ${(props) =>
|
272
|
+
props.hasError ? props.theme.colors.red : props.theme.colors.grey4}
|
273
|
+
1px solid;
|
274
|
+
}
|
275
|
+
`
|
276
|
+
const selectDropdownAttrs = {
|
277
|
+
hoveredBgColor: String,
|
278
|
+
bgColor: String,
|
279
|
+
fontColor: String,
|
280
|
+
optionWidth: String,
|
281
|
+
hoveredIndex: Number,
|
282
|
+
hoveredValue: Number | String,
|
283
|
+
selectedValue: Number | String
|
284
|
+
}
|
285
|
+
const selectDropdown = styled('div', selectDropdownAttrs)`
|
286
|
+
box-sizing: border-box;
|
287
|
+
z-index: ${(props) => (props.isActive ? '2' : '1')};
|
288
|
+
position: absolute;
|
289
|
+
top: 5px;
|
290
|
+
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
291
|
+
border-radius: 4px;
|
292
|
+
display: flex;
|
293
|
+
flex-direction: column;
|
294
|
+
align-items: flex-start;
|
295
|
+
padding: 0px;
|
296
|
+
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
|
297
|
+
width: ${(props) => (props.optionWidth ? props.optionWidth : '100%')};
|
298
|
+
background-color: ${(props) =>
|
299
|
+
props.theme.colors[props.bgColor]
|
300
|
+
? props.theme.colors[props.bgColor]
|
301
|
+
: props.bgColor};
|
302
|
+
color: ${(props) =>
|
303
|
+
props.theme.colors[props.fontColor]
|
304
|
+
? props.theme.colors[props.fontColor]
|
305
|
+
: props.fontColor};
|
306
|
+
max-height: 300px;
|
307
|
+
overflow-y: auto;
|
308
|
+
& > div[data-value='${(props) => props.hoveredValue}'] {
|
309
|
+
background-color: ${(props) =>
|
310
|
+
props.theme.colors[props.hoveredBgColor]
|
311
|
+
? props.theme.colors[props.hoveredBgColor]
|
312
|
+
: props.hoveredBgColor};
|
313
|
+
}
|
314
|
+
`
|
315
|
+
const DropdownWrapper = styled('div')`
|
316
|
+
position: relative;
|
317
|
+
`
|
318
|
+
const inputAttrs = { alignItems: String, hasLabel: Boolean }
|
319
|
+
const InputWrapper = styled('div', inputAttrs)`
|
320
|
+
position: relative;
|
321
|
+
display: grid;
|
322
|
+
align-items: center;
|
323
|
+
gap: 8px;
|
324
|
+
grid-template-columns: ${(props) =>
|
325
|
+
props.alignItems === 'vertical' || !props.hasLabel ? '1fr' : 'auto 1fr'};
|
326
|
+
`
|
327
|
+
export default {
|
328
|
+
name: 'RCselect',
|
329
|
+
|
330
|
+
props: {
|
331
|
+
value: {
|
332
|
+
required: false,
|
333
|
+
default: null
|
334
|
+
},
|
335
|
+
fontSize: {
|
336
|
+
required: false,
|
337
|
+
default: '13px'
|
338
|
+
},
|
339
|
+
label: {
|
340
|
+
required: false
|
341
|
+
},
|
342
|
+
labelOptional: {
|
343
|
+
required: false,
|
344
|
+
default: false
|
345
|
+
},
|
346
|
+
labelDataId: {
|
347
|
+
required: false,
|
348
|
+
default: ''
|
349
|
+
},
|
350
|
+
infoTextMessage: {
|
351
|
+
required: false
|
352
|
+
},
|
353
|
+
selectWidth: {
|
354
|
+
type: String,
|
355
|
+
required: false,
|
356
|
+
default: '100%'
|
357
|
+
},
|
358
|
+
selectHeight: {
|
359
|
+
type: String,
|
360
|
+
required: false,
|
361
|
+
default: null
|
362
|
+
},
|
363
|
+
height: {
|
364
|
+
required: false,
|
365
|
+
default: null
|
366
|
+
},
|
367
|
+
selectMinHeight: {
|
368
|
+
required: false,
|
369
|
+
default: '36px'
|
370
|
+
},
|
371
|
+
optionWidth: {
|
372
|
+
required: false,
|
373
|
+
default: null
|
374
|
+
},
|
375
|
+
hoverDropdown: {
|
376
|
+
required: false,
|
377
|
+
default: false
|
378
|
+
},
|
379
|
+
dropdownAutoClose: {
|
380
|
+
required: false,
|
381
|
+
default: false
|
382
|
+
},
|
383
|
+
alignItems: {
|
384
|
+
required: false,
|
385
|
+
default: 'horizontal'
|
386
|
+
},
|
387
|
+
buttonBgColor: {
|
388
|
+
required: false
|
389
|
+
},
|
390
|
+
buttonFontColor: {
|
391
|
+
required: false
|
392
|
+
},
|
393
|
+
dropdownBgColor: {
|
394
|
+
required: false,
|
395
|
+
default: 'grey5'
|
396
|
+
},
|
397
|
+
dropdownFontColor: {
|
398
|
+
required: false
|
399
|
+
},
|
400
|
+
caretColor: {
|
401
|
+
required: false
|
402
|
+
},
|
403
|
+
labelFontColor: {
|
404
|
+
required: false
|
405
|
+
},
|
406
|
+
colorMode: {
|
407
|
+
required: false,
|
408
|
+
default: 'light'
|
409
|
+
},
|
410
|
+
isSearchable: {
|
411
|
+
required: false,
|
412
|
+
default: true
|
413
|
+
},
|
414
|
+
hasError: {
|
415
|
+
required: false,
|
416
|
+
default: false
|
417
|
+
},
|
418
|
+
disabled: {
|
419
|
+
required: false,
|
420
|
+
default: false
|
421
|
+
},
|
422
|
+
isAutoSearch: {
|
423
|
+
required: false,
|
424
|
+
default: true
|
425
|
+
},
|
426
|
+
showBorder: {
|
427
|
+
required: false,
|
428
|
+
default: true
|
429
|
+
},
|
430
|
+
infoTextSize: {
|
431
|
+
required: false,
|
432
|
+
default: '14px'
|
433
|
+
},
|
434
|
+
dataId: {
|
435
|
+
type: String,
|
436
|
+
default: ''
|
437
|
+
},
|
438
|
+
isDraggable: {
|
439
|
+
type: Boolean,
|
440
|
+
default: false
|
441
|
+
}
|
442
|
+
},
|
443
|
+
|
444
|
+
components: {
|
445
|
+
selectButton,
|
446
|
+
SelectButtonWrapper,
|
447
|
+
selectDropdown,
|
448
|
+
Container,
|
449
|
+
InputLabel,
|
450
|
+
LabelWrapper,
|
451
|
+
optionalLabel,
|
452
|
+
InfoText,
|
453
|
+
InputWrapper,
|
454
|
+
DropdownWrapper,
|
455
|
+
icon,
|
456
|
+
Caret,
|
457
|
+
Selector,
|
458
|
+
inputText,
|
459
|
+
draggableInputHandle
|
460
|
+
},
|
461
|
+
|
462
|
+
data() {
|
463
|
+
return {
|
464
|
+
selectedValue: null,
|
465
|
+
paddingLeft: this.isDraggable ? '30px' : '15px',
|
466
|
+
isDropdownOpen: false,
|
467
|
+
isActive: false,
|
468
|
+
textSearch: '',
|
469
|
+
hoveredIndex: 0,
|
470
|
+
hoveredValue: null,
|
471
|
+
isClickOutsideActive: false
|
472
|
+
}
|
473
|
+
},
|
474
|
+
mounted() {
|
475
|
+
this.selectedValue = this.value
|
476
|
+
document.addEventListener('click', this.clickOutside)
|
477
|
+
},
|
478
|
+
beforeDestroy() {
|
479
|
+
document.removeEventListener('click', this.clickOutside)
|
480
|
+
},
|
481
|
+
methods: {
|
482
|
+
focus() {
|
483
|
+
this.isActive = true
|
484
|
+
},
|
485
|
+
blur() {
|
486
|
+
this.isActive = false
|
487
|
+
},
|
488
|
+
toggleDropdown() {
|
489
|
+
this.isDropdownOpen = !this.isDropdownOpen
|
490
|
+
},
|
491
|
+
toggleCaretDropdown() {
|
492
|
+
this.isDropdownOpen = !this.isDropdownOpen
|
493
|
+
},
|
494
|
+
openDropdown() {
|
495
|
+
this.focus()
|
496
|
+
this.isDropdownOpen = true
|
497
|
+
},
|
498
|
+
closeDropdown() {
|
499
|
+
this.blur()
|
500
|
+
this.isDropdownOpen = false
|
501
|
+
},
|
502
|
+
optionSelected(e) {
|
503
|
+
this.selectedValue = e
|
504
|
+
this.closeDropdown()
|
505
|
+
this.blur()
|
506
|
+
this.$emit('input-change', e)
|
507
|
+
},
|
508
|
+
optionHovered(e) {
|
509
|
+
this.hoveredValue = e
|
510
|
+
},
|
511
|
+
mouseEnterHandler() {
|
512
|
+
if (this.hoverDropdown) {
|
513
|
+
this.focus()
|
514
|
+
this.isDropdownOpen = true
|
515
|
+
}
|
516
|
+
},
|
517
|
+
mouseLeaveHandler() {
|
518
|
+
if (this.hoverDropdown) {
|
519
|
+
this.blur()
|
520
|
+
}
|
521
|
+
},
|
522
|
+
optionLeave() {
|
523
|
+
if (this.dropdownAutoClose) {
|
524
|
+
this.isDropdownOpen = false
|
525
|
+
}
|
526
|
+
},
|
527
|
+
searchChange(value) {
|
528
|
+
this.textSearch = value
|
529
|
+
this.$emit('search-change', value)
|
530
|
+
this.$refs.dropdown.$children
|
531
|
+
.map((component) => component.$el)
|
532
|
+
.forEach((el) => {
|
533
|
+
if (!el.textContent.toLowerCase().includes(value.toLowerCase())) {
|
534
|
+
el.style.display = 'none'
|
535
|
+
} else {
|
536
|
+
el.style.display = 'inherit'
|
537
|
+
}
|
538
|
+
})
|
539
|
+
},
|
540
|
+
clickOutside(event) {
|
541
|
+
const dropdownRef = this.$refs.dropdown
|
542
|
+
// we need to prevent closing on selecting an option, because in the case of
|
543
|
+
// a disabled option, we don't want to close the dropdown
|
544
|
+
if (!this.isClickOutsideActive) return
|
545
|
+
if (
|
546
|
+
this.$refs.select.$el == event.target ||
|
547
|
+
this.$refs.select.$el.contains(event.target) ||
|
548
|
+
event.target.parentNode === dropdownRef.$el
|
549
|
+
) {
|
550
|
+
return
|
551
|
+
} else {
|
552
|
+
this.closeDropdown()
|
553
|
+
}
|
554
|
+
},
|
555
|
+
onKeyDown(e) {
|
556
|
+
if (e.key == 'ArrowDown') {
|
557
|
+
this.onArrowPress(1)
|
558
|
+
} else if (e.key == 'ArrowUp') {
|
559
|
+
this.onArrowPress(-1)
|
560
|
+
} else if (e.key == 'Enter') {
|
561
|
+
const optionHoveredComponent =
|
562
|
+
this.$refs.dropdown.$children[
|
563
|
+
(this.hoveredIndex - 1 + this.optionLength) % this.optionLength
|
564
|
+
]
|
565
|
+
this.optionSelected(optionHoveredComponent.$el.dataset.value)
|
566
|
+
}
|
567
|
+
},
|
568
|
+
onArrowPress(dir) {
|
569
|
+
let newHoveredElem
|
570
|
+
const currentHoveredElem = this.$refs.dropdown.$el.querySelector(
|
571
|
+
`[data-value="${this.hoveredValue}"]`
|
572
|
+
)
|
573
|
+
if (currentHoveredElem) {
|
574
|
+
if (dir > 0) {
|
575
|
+
newHoveredElem = currentHoveredElem.nextElementSibling
|
576
|
+
} else {
|
577
|
+
newHoveredElem = currentHoveredElem.previousElementSibling
|
578
|
+
}
|
579
|
+
if (newHoveredElem) {
|
580
|
+
this.hoveredValue = newHoveredElem.getAttribute('data-value')
|
581
|
+
const topPos = newHoveredElem.offsetTop
|
582
|
+
this.$refs.dropdown.$el.scrollTop = topPos
|
583
|
+
}
|
584
|
+
}
|
585
|
+
},
|
586
|
+
clearSearch() {
|
587
|
+
this.textSearch = ''
|
588
|
+
}
|
589
|
+
},
|
590
|
+
computed: {
|
591
|
+
optionLength() {
|
592
|
+
if (this.isDropdownOpen) {
|
593
|
+
return this.$refs.dropdown.$el.childElementCount
|
594
|
+
}
|
595
|
+
|
596
|
+
return 0
|
597
|
+
},
|
598
|
+
isSearchBarVisible() {
|
599
|
+
return this.isSearchable && this.isDropdownOpen
|
600
|
+
}
|
601
|
+
},
|
602
|
+
watch: {
|
603
|
+
value(val) {
|
604
|
+
this.selectedValue = val
|
605
|
+
},
|
606
|
+
isDropdownOpen(val) {
|
607
|
+
this.$emit('is-dropdown-open', val)
|
608
|
+
if (val) {
|
609
|
+
setTimeout(() => {
|
610
|
+
this.isClickOutsideActive = true
|
611
|
+
}, 10)
|
612
|
+
} else {
|
613
|
+
setTimeout(() => {
|
614
|
+
this.isClickOutsideActive = false
|
615
|
+
}, 10)
|
616
|
+
}
|
617
|
+
if (val && this.isSearchable) {
|
618
|
+
this.$nextTick(() => {
|
619
|
+
if (this.$refs.searchInput) {
|
620
|
+
this.$refs.searchInput.$el.querySelector('input').focus()
|
621
|
+
}
|
622
|
+
})
|
623
|
+
}
|
624
|
+
}
|
625
|
+
}
|
626
|
+
}
|
627
|
+
</script>
|