@dataloop-ai/components 0.13.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/.eslintrc.js +154 -0
- package/.prettierrc.json +7 -0
- package/Dockerfile +12 -0
- package/LICENSE +201 -0
- package/README.md +43 -0
- package/favicon.ico +0 -0
- package/index.html +13 -0
- package/index.ts +1 -0
- package/jest.config.js +16 -0
- package/jest.setup.js +59 -0
- package/models.ts +1 -0
- package/package.json +109 -0
- package/src/App.vue +201 -0
- package/src/assets/globals.scss +253 -0
- package/src/assets/globalsKeys.ts +28 -0
- package/src/components/DlAccordion/AccordionHeader.vue +148 -0
- package/src/components/DlAccordion/DlAccordion.vue +108 -0
- package/src/components/DlAccordion/index.ts +2 -0
- package/src/components/DlAlert.vue +227 -0
- package/src/components/DlAvatar.vue +99 -0
- package/src/components/DlBadge.vue +127 -0
- package/src/components/DlButton/DlButton.vue +370 -0
- package/src/components/DlButton/index.ts +4 -0
- package/src/components/DlButton/utils.ts +169 -0
- package/src/components/DlButtonGroup.vue +122 -0
- package/src/components/DlCheckbox.vue +298 -0
- package/src/components/DlChip/DlChip.vue +244 -0
- package/src/components/DlChip/index.ts +4 -0
- package/src/components/DlChip/utils.ts +100 -0
- package/src/components/DlColorPicker/DlAlpha.vue +142 -0
- package/src/components/DlColorPicker/DlBox.vue +75 -0
- package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
- package/src/components/DlColorPicker/DlColors.vue +139 -0
- package/src/components/DlColorPicker/DlHue.vue +135 -0
- package/src/components/DlColorPicker/DlPreview.vue +61 -0
- package/src/components/DlColorPicker/DlSaturation.vue +152 -0
- package/src/components/DlColorPicker/constants.ts +16 -0
- package/src/components/DlColorPicker/index.ts +20 -0
- package/src/components/DlColorPicker/types.ts +11 -0
- package/src/components/DlColorPicker/utils.ts +128 -0
- package/src/components/DlCounters.vue +173 -0
- package/src/components/DlDatePicker/DlCalendar.vue +332 -0
- package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
- package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
- package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
- package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
- package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
- package/src/components/DlDatePicker/index.ts +3 -0
- package/src/components/DlDatePicker/isInRange.ts +44 -0
- package/src/components/DlDatePicker/types.ts +4 -0
- package/src/components/DlDatePicker/utils.ts +39 -0
- package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
- package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
- package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
- package/src/components/DlDateTimeRange/index.ts +3 -0
- package/src/components/DlDateTimeRange/types.ts +42 -0
- package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
- package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
- package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
- package/src/components/DlDialogBox/index.ts +5 -0
- package/src/components/DlDropdownButton.vue +463 -0
- package/src/components/DlIcon.vue +147 -0
- package/src/components/DlInfoErrorMessage.vue +91 -0
- package/src/components/DlItem/DlItem.vue +35 -0
- package/src/components/DlItem/index.ts +2 -0
- package/src/components/DlItemSection.vue +88 -0
- package/src/components/DlLink/DlLink.vue +76 -0
- package/src/components/DlLink/index.ts +4 -0
- package/src/components/DlLink/utils.ts +4 -0
- package/src/components/DlList.vue +61 -0
- package/src/components/DlListItem/DlListItem.vue +205 -0
- package/src/components/DlListItem/index.ts +3 -0
- package/src/components/DlListItem/utils.ts +14 -0
- package/src/components/DlMenu/DlMenu.vue +438 -0
- package/src/components/DlMenu/index.ts +3 -0
- package/src/components/DlMenu/utils.ts +138 -0
- package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
- package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
- package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
- package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
- package/src/components/DlOptionGroup/index.ts +4 -0
- package/src/components/DlOptionGroup/utils.ts +40 -0
- package/src/components/DlPagination/DlPagination.vue +184 -0
- package/src/components/DlPagination/PageNavigation.vue +350 -0
- package/src/components/DlPagination/PaginationLegend.vue +41 -0
- package/src/components/DlPagination/QuickNavigation.vue +146 -0
- package/src/components/DlPagination/RowsSelector.vue +74 -0
- package/src/components/DlPagination/index.ts +3 -0
- package/src/components/DlPanelContainer/DlPanel.vue +213 -0
- package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
- package/src/components/DlPanelContainer/index.ts +4 -0
- package/src/components/DlPopup/DlPopup.vue +478 -0
- package/src/components/DlPopup/DraggableUpper.vue +64 -0
- package/src/components/DlPopup/PopupHeader.vue +129 -0
- package/src/components/DlPopup/index.ts +1 -0
- package/src/components/DlProgressBar.vue +159 -0
- package/src/components/DlProgressChart.vue +299 -0
- package/src/components/DlRadio.vue +218 -0
- package/src/components/DlRange/DlRange.vue +439 -0
- package/src/components/DlRange/utils.ts +209 -0
- package/src/components/DlSearch.vue +155 -0
- package/src/components/DlSelect/DlSelect.vue +992 -0
- package/src/components/DlSelect/SelectOption.vue +261 -0
- package/src/components/DlSelect/index.ts +4 -0
- package/src/components/DlSelect/utils.ts +43 -0
- package/src/components/DlSkeleton.vue +72 -0
- package/src/components/DlSlider/DlSlider.vue +243 -0
- package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
- package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
- package/src/components/DlSlider/components/index.ts +4 -0
- package/src/components/DlSlider/index.ts +3 -0
- package/src/components/DlSlider/sliderStyles.scss +109 -0
- package/src/components/DlSlider/useSlider.ts +277 -0
- package/src/components/DlSlider/utils.ts +7 -0
- package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
- package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
- package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
- package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
- package/src/components/DlSmartSearch/index.ts +4 -0
- package/src/components/DlSmartSearch/types.ts +36 -0
- package/src/components/DlSmartSearch/utils.ts +45 -0
- package/src/components/DlStepper/DlStepper.vue +196 -0
- package/src/components/DlStepper/DlStepperContainer.vue +55 -0
- package/src/components/DlStepper/DlStepperContent.vue +101 -0
- package/src/components/DlStepper/DlStepperFooter.vue +133 -0
- package/src/components/DlStepper/DlStepperHeader.vue +49 -0
- package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
- package/src/components/DlStepper/Step.ts +101 -0
- package/src/components/DlStepper/Stepper.ts +107 -0
- package/src/components/DlStepper/index.ts +7 -0
- package/src/components/DlStepper/interfaces.ts +11 -0
- package/src/components/DlSwitch.vue +280 -0
- package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
- package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
- package/src/components/DlTabPanels/index.ts +4 -0
- package/src/components/DlTabPanels/utils.ts +19 -0
- package/src/components/DlTable/DlTable.vue +1264 -0
- package/src/components/DlTable/DlTd.vue +109 -0
- package/src/components/DlTable/DlTh.vue +126 -0
- package/src/components/DlTable/DlTr.vue +44 -0
- package/src/components/DlTable/ResizableManager.ts +233 -0
- package/src/components/DlTable/dl-table-styles.scss +466 -0
- package/src/components/DlTable/hooks/tableActions.ts +64 -0
- package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
- package/src/components/DlTable/hooks/tableFilter.ts +42 -0
- package/src/components/DlTable/hooks/tablePagination.ts +197 -0
- package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
- package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
- package/src/components/DlTable/hooks/tableSort.ts +125 -0
- package/src/components/DlTable/index.ts +6 -0
- package/src/components/DlTable/types.ts +96 -0
- package/src/components/DlTabs/DlTab.vue +146 -0
- package/src/components/DlTabs/DlTabs.vue +192 -0
- package/src/components/DlTabs/TabsWrapper.vue +104 -0
- package/src/components/DlTabs/index.ts +4 -0
- package/src/components/DlTabs/types.ts +8 -0
- package/src/components/DlTextArea.vue +151 -0
- package/src/components/DlTextHolder.vue +65 -0
- package/src/components/DlTextInput.vue +753 -0
- package/src/components/DlThemeProvider.vue +41 -0
- package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
- package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
- package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
- package/src/components/DlTimePicker/index.ts +3 -0
- package/src/components/DlTimePicker/types.ts +4 -0
- package/src/components/DlTooltip.vue +456 -0
- package/src/components/DlTrend.vue +97 -0
- package/src/components/DlTypography.vue +87 -0
- package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
- package/src/components/DlVirtualScroll/index.ts +3 -0
- package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
- package/src/components/DlWidget/DlWidget.vue +50 -0
- package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
- package/src/components/DlWidget/index.ts +4 -0
- package/src/components/DlWidget/types.ts +6 -0
- package/src/components/DlWidget/utils.ts +30 -0
- package/src/components/index.ts +118 -0
- package/src/demo/DlAccordionDemo.vue +60 -0
- package/src/demo/DlAlertDemo.vue +54 -0
- package/src/demo/DlAvatarDemo.vue +43 -0
- package/src/demo/DlBadgeDemo.vue +65 -0
- package/src/demo/DlButtonDemo.vue +266 -0
- package/src/demo/DlCheckboxDemo.vue +50 -0
- package/src/demo/DlChipDemo.vue +181 -0
- package/src/demo/DlColorPickerDemo.vue +43 -0
- package/src/demo/DlCounterDemo.vue +53 -0
- package/src/demo/DlDateTimeRangeDemo.vue +217 -0
- package/src/demo/DlDialogBoxDemo.vue +175 -0
- package/src/demo/DlDropdownButtonDemo.vue +260 -0
- package/src/demo/DlIconDemo.vue +47 -0
- package/src/demo/DlLinkDemo.vue +23 -0
- package/src/demo/DlListDemo.vue +177 -0
- package/src/demo/DlMenuDemo.vue +524 -0
- package/src/demo/DlOptionGroupDemo.vue +79 -0
- package/src/demo/DlPaginationDemo.vue +44 -0
- package/src/demo/DlPanelContainerDemo.vue +221 -0
- package/src/demo/DlPopupDemo.vue +58 -0
- package/src/demo/DlProgressBarDemo.vue +22 -0
- package/src/demo/DlProgressChartDemo.vue +71 -0
- package/src/demo/DlRadioDemo.vue +35 -0
- package/src/demo/DlRangeDemo.vue +44 -0
- package/src/demo/DlSearchDemo.vue +27 -0
- package/src/demo/DlSelectDemo.vue +355 -0
- package/src/demo/DlSkeletonDemo.vue +20 -0
- package/src/demo/DlSliderDemo.vue +47 -0
- package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
- package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
- package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
- package/src/demo/DlStepperDemo/index.ts +5 -0
- package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
- package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
- package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
- package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
- package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
- package/src/demo/DlSwitchDemo.vue +49 -0
- package/src/demo/DlTableDemo.vue +475 -0
- package/src/demo/DlTabsDemo.vue +67 -0
- package/src/demo/DlTdDemo.vue +19 -0
- package/src/demo/DlTextAreaDemo.vue +37 -0
- package/src/demo/DlTextHolderDemo.vue +42 -0
- package/src/demo/DlTextInputDemo.vue +89 -0
- package/src/demo/DlThDemo.vue +32 -0
- package/src/demo/DlTooltipDemo.vue +60 -0
- package/src/demo/DlTrDemo.vue +18 -0
- package/src/demo/DlTrendDemo.vue +25 -0
- package/src/demo/DlTypographyDemo.vue +93 -0
- package/src/demo/DlWidgetDemo.vue +157 -0
- package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
- package/src/demo/SmartSearchDemo/schema.ts +44 -0
- package/src/demo/index.ts +141 -0
- package/src/directives/TouchPan.ts +525 -0
- package/src/env.d.ts +8 -0
- package/src/hooks/use-anchor.ts +223 -0
- package/src/hooks/use-model-toggle.ts +181 -0
- package/src/hooks/use-portal.ts +104 -0
- package/src/hooks/use-scroll-target.ts +53 -0
- package/src/hooks/use-size-observer.ts +24 -0
- package/src/hooks/use-suggestions.ts +355 -0
- package/src/hooks/use-tick.ts +32 -0
- package/src/hooks/use-timeout.ts +20 -0
- package/src/hooks/use-transition.ts +32 -0
- package/src/hooks/use-window-size.ts +25 -0
- package/src/hooks/useForm.ts +12 -0
- package/src/index.ts +7 -0
- package/src/main.ts +4 -0
- package/src/models.ts +4 -0
- package/src/types.ts +6 -0
- package/src/utils/calcs.ts +18 -0
- package/src/utils/click-outside.ts +108 -0
- package/src/utils/component-name-parser.ts +1 -0
- package/src/utils/css-color-names.ts +150 -0
- package/src/utils/dom.ts +55 -0
- package/src/utils/draggable-table.ts +416 -0
- package/src/utils/escape-key.ts +54 -0
- package/src/utils/events.ts +67 -0
- package/src/utils/focus-manager.ts +33 -0
- package/src/utils/focusout.ts +29 -0
- package/src/utils/format.ts +3 -0
- package/src/utils/getColor.ts +17 -0
- package/src/utils/getLighterGradient.ts +36 -0
- package/src/utils/getRootStyles.ts +52 -0
- package/src/utils/global-config.ts +6 -0
- package/src/utils/global-nodes.ts +42 -0
- package/src/utils/includes.ts +3 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/inject-object-prop.ts +21 -0
- package/src/utils/input-sizes.ts +7 -0
- package/src/utils/is-ellipsis-active.ts +3 -0
- package/src/utils/is-in-viewport.ts +13 -0
- package/src/utils/is.ts +15 -0
- package/src/utils/key-composition.ts +17 -0
- package/src/utils/keyCodes.ts +12 -0
- package/src/utils/logger/ConsoleLogger.ts +65 -0
- package/src/utils/logger/ILogger.ts +8 -0
- package/src/utils/logger/index.ts +8 -0
- package/src/utils/nav-keys-constants.ts +1 -0
- package/src/utils/portal.ts +55 -0
- package/src/utils/position-engine.ts +381 -0
- package/src/utils/render.ts +36 -0
- package/src/utils/ripple.ts +7 -0
- package/src/utils/scroll.ts +73 -0
- package/src/utils/selection.ts +15 -0
- package/src/utils/sort.ts +7 -0
- package/src/utils/splitByQuotes.ts +32 -0
- package/src/utils/string.ts +6 -0
- package/src/utils/teleport.ts +14 -0
- package/src/utils/theme.ts +2 -0
- package/src/utils/vm.ts +16 -0
- package/storybook.js +8 -0
- package/tsconfig.json +44 -0
- package/tsconfig.node.json +8 -0
- package/types.ts +1 -0
- package/vite.config.ts +13 -0
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
:style="cssVars"
|
|
5
|
+
class="root-container"
|
|
6
|
+
:class="{ 'root-container--s': isSmall, [identifierClass]: true }"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
v-show="!!title.length || !!tooltip.length"
|
|
10
|
+
:class="{
|
|
11
|
+
'dl-select__title-container': true,
|
|
12
|
+
'title-container--s': isSmall
|
|
13
|
+
}"
|
|
14
|
+
>
|
|
15
|
+
<label
|
|
16
|
+
v-show="!!title.length"
|
|
17
|
+
class="dl-select__title"
|
|
18
|
+
>
|
|
19
|
+
{{ title
|
|
20
|
+
}}<span
|
|
21
|
+
v-show="required"
|
|
22
|
+
:class="asteriskClasses"
|
|
23
|
+
> *</span>
|
|
24
|
+
{{ !required && optional ? ' (Optional)' : null }}
|
|
25
|
+
</label>
|
|
26
|
+
<span v-show="!!tooltip.length">
|
|
27
|
+
<dl-icon
|
|
28
|
+
icon="icon-dl-info"
|
|
29
|
+
class="tooltip-icon"
|
|
30
|
+
size="12px"
|
|
31
|
+
/>
|
|
32
|
+
<dl-tooltip>
|
|
33
|
+
{{ tooltip }}
|
|
34
|
+
</dl-tooltip>
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
<div
|
|
38
|
+
v-show="!!topMessage.length && !isSmall"
|
|
39
|
+
class="top-message-container"
|
|
40
|
+
>
|
|
41
|
+
<dl-info-error-message
|
|
42
|
+
v-show="!!topMessage.length"
|
|
43
|
+
position="above"
|
|
44
|
+
:value="topMessage"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
<div
|
|
48
|
+
class="select-wrapper"
|
|
49
|
+
:style="placeholderStyles"
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
ref="select"
|
|
53
|
+
:class="selectClasses"
|
|
54
|
+
>
|
|
55
|
+
<div
|
|
56
|
+
v-show="hasPrepend || search"
|
|
57
|
+
:class="[
|
|
58
|
+
...adornmentClasses,
|
|
59
|
+
'adornment-container--pos-left'
|
|
60
|
+
]"
|
|
61
|
+
>
|
|
62
|
+
<dl-icon
|
|
63
|
+
v-if="search"
|
|
64
|
+
icon="icon-dl-search"
|
|
65
|
+
:size="iconSize"
|
|
66
|
+
color="dl-color-lighter"
|
|
67
|
+
/>
|
|
68
|
+
<slot
|
|
69
|
+
v-else
|
|
70
|
+
name="prepend"
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
<input
|
|
74
|
+
v-if="search"
|
|
75
|
+
ref="searchInput"
|
|
76
|
+
class="select-search-input"
|
|
77
|
+
:style="!isExpanded ? 'display: none;' : 'width: 100%;'"
|
|
78
|
+
:disabled="disabled"
|
|
79
|
+
@input="handleSearchInput"
|
|
80
|
+
@focus="handleSearchFocus"
|
|
81
|
+
@blur="handleSearchBlur"
|
|
82
|
+
>
|
|
83
|
+
<div v-if="hasSelectedSlot">
|
|
84
|
+
<slot
|
|
85
|
+
v-if="search ? !isExpanded : true"
|
|
86
|
+
:opt="selectedOption"
|
|
87
|
+
name="selected"
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
<template v-if="!hasSelectedSlot">
|
|
91
|
+
<span
|
|
92
|
+
v-show="
|
|
93
|
+
(multiselect && !search) ||
|
|
94
|
+
(multiselect && search && !isExpanded)
|
|
95
|
+
"
|
|
96
|
+
class="root-container--placeholder"
|
|
97
|
+
>
|
|
98
|
+
<template v-if="allFiltersModel">
|
|
99
|
+
{{ computedAllItemsLabel }}
|
|
100
|
+
</template>
|
|
101
|
+
<template v-else>
|
|
102
|
+
{{ filterSelectLabel }}
|
|
103
|
+
</template>
|
|
104
|
+
</span>
|
|
105
|
+
<span
|
|
106
|
+
v-show="
|
|
107
|
+
(!multiselect && !search) ||
|
|
108
|
+
(!multiselect && search && !isExpanded)
|
|
109
|
+
"
|
|
110
|
+
class="selected-label"
|
|
111
|
+
>
|
|
112
|
+
{{ getLabel(selectedOption) }}
|
|
113
|
+
</span>
|
|
114
|
+
</template>
|
|
115
|
+
<div
|
|
116
|
+
:class="[
|
|
117
|
+
...adornmentClasses,
|
|
118
|
+
`adornment-container--pos-right${
|
|
119
|
+
disableDropdownIconPadding
|
|
120
|
+
? ' adornment-container--pos-right-without_padding'
|
|
121
|
+
: ''
|
|
122
|
+
}`
|
|
123
|
+
]"
|
|
124
|
+
>
|
|
125
|
+
<dl-icon
|
|
126
|
+
:icon="dropdownIcon"
|
|
127
|
+
class="expand-icon"
|
|
128
|
+
:inline="false"
|
|
129
|
+
:size="withoutBorders ? '12px' : '16px'"
|
|
130
|
+
:class="{ expanded: isExpanded }"
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
<dl-menu
|
|
135
|
+
ref="menu"
|
|
136
|
+
v-model="isExpanded"
|
|
137
|
+
:fit="fit"
|
|
138
|
+
square
|
|
139
|
+
no-focus
|
|
140
|
+
:offset="[0, 3]"
|
|
141
|
+
style="border-radius: 0"
|
|
142
|
+
:disabled="disabled"
|
|
143
|
+
@show="onMenuOpen"
|
|
144
|
+
@hide="closeMenu"
|
|
145
|
+
>
|
|
146
|
+
<dl-list
|
|
147
|
+
class="select-list"
|
|
148
|
+
:style="dropdownCSSVars"
|
|
149
|
+
:padding="false"
|
|
150
|
+
>
|
|
151
|
+
<dl-list-item v-if="noOptions">
|
|
152
|
+
<dl-item-section color="dl-color-medium">
|
|
153
|
+
<slot name="no-options">
|
|
154
|
+
No options
|
|
155
|
+
</slot>
|
|
156
|
+
</dl-item-section>
|
|
157
|
+
</dl-list-item>
|
|
158
|
+
<dl-list-item v-if="hasBeforeOptions && !noOptions">
|
|
159
|
+
<dl-item-section color="dl-color-medium">
|
|
160
|
+
<slot name="before-options" />
|
|
161
|
+
</dl-item-section>
|
|
162
|
+
</dl-list-item>
|
|
163
|
+
<select-option
|
|
164
|
+
v-if="showAllItems"
|
|
165
|
+
:multiselect="multiselect"
|
|
166
|
+
:with-wave="withWave"
|
|
167
|
+
clickable
|
|
168
|
+
:model-value="allFiltersModel"
|
|
169
|
+
:count="totalCount"
|
|
170
|
+
:highlight-selected="highlightSelected"
|
|
171
|
+
total-items
|
|
172
|
+
@update:model-value="selectAll"
|
|
173
|
+
>
|
|
174
|
+
<slot
|
|
175
|
+
v-if="hasAllItemsSlot"
|
|
176
|
+
name="all-items"
|
|
177
|
+
/>
|
|
178
|
+
<template v-else>
|
|
179
|
+
{{ computedAllItemsLabel }}
|
|
180
|
+
</template>
|
|
181
|
+
</select-option>
|
|
182
|
+
<select-option
|
|
183
|
+
v-for="option in options"
|
|
184
|
+
:key="getKeyForOption(option)"
|
|
185
|
+
clickable
|
|
186
|
+
:multiselect="multiselect"
|
|
187
|
+
:class="{
|
|
188
|
+
selected:
|
|
189
|
+
option === selectedOption && highlightSelected
|
|
190
|
+
}"
|
|
191
|
+
:with-wave="withWave"
|
|
192
|
+
:model-value="modelValue"
|
|
193
|
+
:value="getOptionValue(option)"
|
|
194
|
+
:highlight-selected="highlightSelected"
|
|
195
|
+
:count="getOptionCount(option)"
|
|
196
|
+
:children="getOptionChildren(option)"
|
|
197
|
+
:capitalized="capitalizedOptions"
|
|
198
|
+
@update:model-value="handleModelValueUpdate"
|
|
199
|
+
@click="selectOption(option)"
|
|
200
|
+
@selected="handleSelected"
|
|
201
|
+
@deselected="handleDeselected"
|
|
202
|
+
>
|
|
203
|
+
<slot
|
|
204
|
+
v-if="hasOptionSlot"
|
|
205
|
+
:opt="option"
|
|
206
|
+
name="option"
|
|
207
|
+
/>
|
|
208
|
+
<template v-else>
|
|
209
|
+
{{
|
|
210
|
+
capitalizedOptions
|
|
211
|
+
? typeof getOptionLabel(option) ===
|
|
212
|
+
'string' &&
|
|
213
|
+
getOptionLabel(option).toLowerCase()
|
|
214
|
+
: getOptionLabel(option)
|
|
215
|
+
}}
|
|
216
|
+
</template>
|
|
217
|
+
</select-option>
|
|
218
|
+
<dl-list-item v-if="hasAfterOptions && !noOptions">
|
|
219
|
+
<dl-item-section>
|
|
220
|
+
<slot name="after-options" />
|
|
221
|
+
</dl-item-section>
|
|
222
|
+
</dl-list-item>
|
|
223
|
+
</dl-list>
|
|
224
|
+
</dl-menu>
|
|
225
|
+
</div>
|
|
226
|
+
<div
|
|
227
|
+
v-show="!isSmall && (!!infoMessage.length || !!errorMessage.length)"
|
|
228
|
+
class="bottom-message-container"
|
|
229
|
+
>
|
|
230
|
+
<dl-info-error-message
|
|
231
|
+
v-show="!!infoMessage.length && !error"
|
|
232
|
+
position="below"
|
|
233
|
+
:value="infoMessage"
|
|
234
|
+
/>
|
|
235
|
+
<dl-info-error-message
|
|
236
|
+
v-show="error && !!errorMessage.length"
|
|
237
|
+
position="below"
|
|
238
|
+
error
|
|
239
|
+
:value="errorMessage"
|
|
240
|
+
/>
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
</template>
|
|
244
|
+
|
|
245
|
+
<script lang="ts">
|
|
246
|
+
import { InputSizes, TInputSizes } from '../../utils/input-sizes'
|
|
247
|
+
import DlIcon from '../DlIcon.vue'
|
|
248
|
+
import DlInfoErrorMessage from '../DlInfoErrorMessage.vue'
|
|
249
|
+
import DlList from '../DlList.vue'
|
|
250
|
+
import { DlListItem } from '../DlListItem'
|
|
251
|
+
import DlItemSection from '../DlItemSection.vue'
|
|
252
|
+
import { DlMenu } from '../DlMenu'
|
|
253
|
+
import DlTooltip from '../DlTooltip.vue'
|
|
254
|
+
import { defineComponent, isVue2, PropType } from 'vue-demi'
|
|
255
|
+
import {
|
|
256
|
+
getLabel,
|
|
257
|
+
getIconSize,
|
|
258
|
+
optionsValidator,
|
|
259
|
+
SelectOptionType,
|
|
260
|
+
getLabelOfSelectedOption
|
|
261
|
+
} from './utils'
|
|
262
|
+
import SelectOption from './SelectOption.vue'
|
|
263
|
+
import { isEqual } from 'lodash'
|
|
264
|
+
import { getColor } from '../../utils'
|
|
265
|
+
import { v4 } from 'uuid'
|
|
266
|
+
|
|
267
|
+
export default defineComponent({
|
|
268
|
+
components: {
|
|
269
|
+
DlIcon,
|
|
270
|
+
DlInfoErrorMessage,
|
|
271
|
+
DlList,
|
|
272
|
+
DlItemSection,
|
|
273
|
+
DlListItem,
|
|
274
|
+
DlMenu,
|
|
275
|
+
DlTooltip,
|
|
276
|
+
SelectOption
|
|
277
|
+
},
|
|
278
|
+
model: {
|
|
279
|
+
prop: 'modelValue',
|
|
280
|
+
event: 'update:model-value'
|
|
281
|
+
},
|
|
282
|
+
props: {
|
|
283
|
+
modelValue: { type: [String, Object, Array, Number], default: '' },
|
|
284
|
+
size: {
|
|
285
|
+
type: String as PropType<TInputSizes>,
|
|
286
|
+
default: InputSizes.l
|
|
287
|
+
},
|
|
288
|
+
withWave: Boolean,
|
|
289
|
+
alignRight: { type: Boolean, default: false },
|
|
290
|
+
allItemsOption: { type: Boolean, default: false },
|
|
291
|
+
allItemsOptionLabel: { type: String, default: null },
|
|
292
|
+
placeholder: { type: String, default: null },
|
|
293
|
+
removableSelection: { type: Boolean, default: false },
|
|
294
|
+
width: { type: String, default: '100%' },
|
|
295
|
+
withoutBorders: { type: Boolean, default: false },
|
|
296
|
+
title: { type: String, default: '' },
|
|
297
|
+
search: { type: Boolean, default: false },
|
|
298
|
+
required: { type: Boolean, default: false },
|
|
299
|
+
optional: { type: Boolean, default: false },
|
|
300
|
+
fit: { type: Boolean, default: true },
|
|
301
|
+
tooltip: { type: String, default: '' },
|
|
302
|
+
highlightSelected: { type: Boolean, default: false },
|
|
303
|
+
type: { type: String, default: 'text' },
|
|
304
|
+
multiselect: { type: Boolean, default: false },
|
|
305
|
+
dropdownIcon: { type: String, default: 'icon-dl-down-chevron' },
|
|
306
|
+
topMessage: { type: String, default: '' },
|
|
307
|
+
redAsterisk: { type: Boolean, default: false },
|
|
308
|
+
infoMessage: { type: String, default: '' },
|
|
309
|
+
errorMessage: { type: String, default: '' },
|
|
310
|
+
error: { type: Boolean, default: false },
|
|
311
|
+
disabled: { type: Boolean, default: false },
|
|
312
|
+
emitValue: { type: Boolean, default: false }, // We emit the value from the option and compare with it as a modelvalue
|
|
313
|
+
options: {
|
|
314
|
+
type: Array as PropType<SelectOptionType[]>,
|
|
315
|
+
default: (): SelectOptionType[] => [],
|
|
316
|
+
validator: optionsValidator
|
|
317
|
+
},
|
|
318
|
+
capitalizedOptions: { type: Boolean, default: false },
|
|
319
|
+
disableClearBtn: { type: Boolean, default: false },
|
|
320
|
+
disableDropdownIconPadding: { type: Boolean, default: false },
|
|
321
|
+
clearButtonTooltip: { type: Boolean, default: false },
|
|
322
|
+
dropdownMaxHeight: { type: String, default: '30vh' },
|
|
323
|
+
preserveSearch: { type: Boolean, default: false }
|
|
324
|
+
},
|
|
325
|
+
emits: [
|
|
326
|
+
'search-focus',
|
|
327
|
+
'search-blur',
|
|
328
|
+
'filter',
|
|
329
|
+
'change',
|
|
330
|
+
'search-input',
|
|
331
|
+
'update:model-value',
|
|
332
|
+
'before-show',
|
|
333
|
+
'before-hide',
|
|
334
|
+
'show',
|
|
335
|
+
'hide',
|
|
336
|
+
'selected',
|
|
337
|
+
'deselected'
|
|
338
|
+
],
|
|
339
|
+
data() {
|
|
340
|
+
return {
|
|
341
|
+
uuid: `dl-select-${v4()}`,
|
|
342
|
+
isExpanded: false,
|
|
343
|
+
selectedIndex: -1,
|
|
344
|
+
isEmpty: true
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
computed: {
|
|
348
|
+
identifierClass(): string {
|
|
349
|
+
return `dl-select-${this.title}-${
|
|
350
|
+
this.placeholder ?? ''
|
|
351
|
+
}`.replaceAll(' ', '-')
|
|
352
|
+
},
|
|
353
|
+
showAllItems: {
|
|
354
|
+
get(): boolean {
|
|
355
|
+
return this.multiselect && this.allItemsOption && this.isEmpty
|
|
356
|
+
},
|
|
357
|
+
set(val: boolean) {
|
|
358
|
+
this.isEmpty = val
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
modelValueLength(): number {
|
|
362
|
+
if (
|
|
363
|
+
typeof this.modelValue !== 'string' &&
|
|
364
|
+
!Array.isArray(this.modelValue)
|
|
365
|
+
) {
|
|
366
|
+
return 0
|
|
367
|
+
}
|
|
368
|
+
return this.modelValue?.length ?? 0
|
|
369
|
+
},
|
|
370
|
+
allFiltersModel(): boolean {
|
|
371
|
+
if (Array.isArray(this.modelValue)) {
|
|
372
|
+
const options = this.options.some((opt) =>
|
|
373
|
+
this.getOptionChildren(opt)
|
|
374
|
+
)
|
|
375
|
+
return (
|
|
376
|
+
this.modelValue?.length === this.options.length && !options
|
|
377
|
+
)
|
|
378
|
+
}
|
|
379
|
+
return false
|
|
380
|
+
},
|
|
381
|
+
filterSelectLabel(): string {
|
|
382
|
+
if (this.modelValueLength === 1) {
|
|
383
|
+
const valueToSearch = (this.modelValue as any)[0]
|
|
384
|
+
return getLabelOfSelectedOption(valueToSearch, this.options)
|
|
385
|
+
}
|
|
386
|
+
return this.modelValueLength > 0
|
|
387
|
+
? `${this.modelValueLength} Selected Items`
|
|
388
|
+
: this.computedPlaceholder
|
|
389
|
+
},
|
|
390
|
+
computedAllItemsLabel(): string {
|
|
391
|
+
return this.allItemsOptionLabel || 'All Items'
|
|
392
|
+
},
|
|
393
|
+
isModelValuePrimitiveType(): boolean {
|
|
394
|
+
return this.isPrimitiveValue(this.modelValue)
|
|
395
|
+
},
|
|
396
|
+
totalCount(): number {
|
|
397
|
+
let total = 0
|
|
398
|
+
if (typeof this.options[0] !== 'string') {
|
|
399
|
+
this.options.forEach((option: any) => {
|
|
400
|
+
if (typeof option === 'object' && option!.count) {
|
|
401
|
+
total += option!.count as number
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return total
|
|
407
|
+
},
|
|
408
|
+
iconSize(): string {
|
|
409
|
+
return getIconSize(this.size)
|
|
410
|
+
},
|
|
411
|
+
hasOptionSlot(): boolean {
|
|
412
|
+
if (isVue2) {
|
|
413
|
+
// @ts-ignore
|
|
414
|
+
return !!this.$scopedSlots.option
|
|
415
|
+
}
|
|
416
|
+
return !!this.$slots.option
|
|
417
|
+
},
|
|
418
|
+
hasAllItemsSlot(): boolean {
|
|
419
|
+
if (isVue2) {
|
|
420
|
+
// @ts-ignore
|
|
421
|
+
return !!this.$scopedSlots['all-items']
|
|
422
|
+
}
|
|
423
|
+
return !!this.$slots['all-items']
|
|
424
|
+
},
|
|
425
|
+
hasSelectedSlot(): boolean {
|
|
426
|
+
if (isVue2) {
|
|
427
|
+
// @ts-ignore
|
|
428
|
+
return !!this.$scopedSlots.selected
|
|
429
|
+
}
|
|
430
|
+
return !!this.$slots.selected
|
|
431
|
+
},
|
|
432
|
+
computedPlaceholder(): string {
|
|
433
|
+
return this.placeholder || 'Select option'
|
|
434
|
+
},
|
|
435
|
+
placeholderStyles(): Record<string, string> {
|
|
436
|
+
if (this.disabled) {
|
|
437
|
+
return
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
'--placeholder-color': getColor(
|
|
441
|
+
this.modelValueLength > 0 || this.selectedIndex !== -1
|
|
442
|
+
? 'dl-color-darker'
|
|
443
|
+
: 'dl-color-lighter'
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
selectedOption(): string | Record<string, string | number> | number {
|
|
448
|
+
return this.selectedIndex === -1
|
|
449
|
+
? this.computedPlaceholder
|
|
450
|
+
: this.options[this.selectedIndex]
|
|
451
|
+
},
|
|
452
|
+
hasBeforeOptions(): boolean {
|
|
453
|
+
if (isVue2) {
|
|
454
|
+
// @ts-ignore
|
|
455
|
+
return !!this.$scopedSlots['before-options']
|
|
456
|
+
}
|
|
457
|
+
return !!this.$slots['before-options']
|
|
458
|
+
},
|
|
459
|
+
hasAfterOptions(): boolean {
|
|
460
|
+
if (isVue2) {
|
|
461
|
+
// @ts-ignore
|
|
462
|
+
return !!this.$scopedSlots['after-options']
|
|
463
|
+
}
|
|
464
|
+
return !!this.$slots['after-options']
|
|
465
|
+
},
|
|
466
|
+
noOptions(): boolean {
|
|
467
|
+
if (Array.isArray(this.options)) {
|
|
468
|
+
return this.options.length === 0
|
|
469
|
+
}
|
|
470
|
+
return true
|
|
471
|
+
},
|
|
472
|
+
selectClasses(): string[] {
|
|
473
|
+
const classes = ['dl_select__select']
|
|
474
|
+
|
|
475
|
+
classes.push(`dl_select__select--${this.size}`)
|
|
476
|
+
classes.push('dl_select__select--append')
|
|
477
|
+
|
|
478
|
+
if (this.disableDropdownIconPadding) {
|
|
479
|
+
classes.push('dl_select__select--append-without_padding')
|
|
480
|
+
}
|
|
481
|
+
if (this.selectedIndex !== -1) {
|
|
482
|
+
classes.push('dl_select__select--has-selection')
|
|
483
|
+
}
|
|
484
|
+
if (this.alignRight) {
|
|
485
|
+
classes.push('dl_select__select--align-right')
|
|
486
|
+
}
|
|
487
|
+
if (this.withoutBorders) {
|
|
488
|
+
classes.push('dl_select__select--without-border')
|
|
489
|
+
}
|
|
490
|
+
if (this.hasPrepend || this.search) {
|
|
491
|
+
classes.push('dl_select__select--prepend')
|
|
492
|
+
classes.push('dl_select__select--both-adornments')
|
|
493
|
+
}
|
|
494
|
+
if (this.error) {
|
|
495
|
+
classes.push('dl_select__select--error')
|
|
496
|
+
}
|
|
497
|
+
if (this.disabled) {
|
|
498
|
+
classes.push('dl_select__select--disabled')
|
|
499
|
+
}
|
|
500
|
+
if (this.isExpanded) {
|
|
501
|
+
classes.push('dl_select__select--focused')
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
return classes
|
|
505
|
+
},
|
|
506
|
+
cssVars(): Record<string, string> {
|
|
507
|
+
return {
|
|
508
|
+
'--dl-select-width': this.width,
|
|
509
|
+
'--dl-select-expand-icon-width': this.disableDropdownIconPadding
|
|
510
|
+
? '16px'
|
|
511
|
+
: '28px'
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
dropdownCSSVars(): Record<string, string> {
|
|
515
|
+
return {
|
|
516
|
+
'--dl-select-dropdown-max-height': this.dropdownMaxHeight
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
asteriskClasses(): string[] {
|
|
520
|
+
const classes = ['required-asterisk']
|
|
521
|
+
if (this.redAsterisk) {
|
|
522
|
+
classes.push('required-asterisk--red')
|
|
523
|
+
}
|
|
524
|
+
return classes
|
|
525
|
+
},
|
|
526
|
+
adornmentClasses(): string[] {
|
|
527
|
+
const classes = ['adornment-container']
|
|
528
|
+
classes.push(`adornment-container--${this.size}`)
|
|
529
|
+
return classes
|
|
530
|
+
},
|
|
531
|
+
isSmall(): boolean {
|
|
532
|
+
return this.size === InputSizes.s
|
|
533
|
+
},
|
|
534
|
+
hasPrepend(): boolean {
|
|
535
|
+
if (isVue2) {
|
|
536
|
+
// @ts-ignore
|
|
537
|
+
return !!this.$scopedSlots.prepend && !this.isSmall
|
|
538
|
+
}
|
|
539
|
+
return !!this.$slots.prepend && !this.isSmall
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
watch: {
|
|
543
|
+
isExpanded(newVal: boolean) {
|
|
544
|
+
if (this.search) {
|
|
545
|
+
if (newVal) {
|
|
546
|
+
const inputRef = this.$refs.searchInput as HTMLInputElement
|
|
547
|
+
this.$nextTick(() => {
|
|
548
|
+
inputRef?.focus({})
|
|
549
|
+
})
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
modelValue() {
|
|
554
|
+
this.setSelectedIndex()
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
beforeMount() {
|
|
558
|
+
this.setSelectedIndex()
|
|
559
|
+
},
|
|
560
|
+
methods: {
|
|
561
|
+
isPrimitiveValue(option: any): boolean {
|
|
562
|
+
return (
|
|
563
|
+
typeof option === 'string' ||
|
|
564
|
+
typeof option === 'number' ||
|
|
565
|
+
typeof option === 'boolean'
|
|
566
|
+
)
|
|
567
|
+
},
|
|
568
|
+
setSelectedIndex() {
|
|
569
|
+
if (!this.modelValue) {
|
|
570
|
+
this.selectedIndex = -1
|
|
571
|
+
return
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
if (this.emitValue) {
|
|
575
|
+
this.selectedIndex = this.options.findIndex(
|
|
576
|
+
(
|
|
577
|
+
option:
|
|
578
|
+
| string
|
|
579
|
+
| Record<string, string | number>
|
|
580
|
+
| number
|
|
581
|
+
) =>
|
|
582
|
+
isEqual(
|
|
583
|
+
(option as any).value,
|
|
584
|
+
this.modelValue as string | number
|
|
585
|
+
)
|
|
586
|
+
)
|
|
587
|
+
return
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
if (this.isModelValuePrimitiveType) {
|
|
591
|
+
this.selectedIndex = this.options.findIndex(
|
|
592
|
+
(
|
|
593
|
+
option:
|
|
594
|
+
| string
|
|
595
|
+
| Record<string, string | number>
|
|
596
|
+
| number
|
|
597
|
+
) => option === this.modelValue
|
|
598
|
+
)
|
|
599
|
+
return
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
this.selectedIndex = this.options.findIndex(
|
|
603
|
+
(option: string | Record<string, string | number> | number) =>
|
|
604
|
+
isEqual(
|
|
605
|
+
(option as any).value,
|
|
606
|
+
(this.modelValue as any).value
|
|
607
|
+
)
|
|
608
|
+
)
|
|
609
|
+
},
|
|
610
|
+
getOptionValue(option: any) {
|
|
611
|
+
return option?.value ?? option
|
|
612
|
+
},
|
|
613
|
+
getOptionLabel(option: any) {
|
|
614
|
+
return getLabel(option) ?? this.getOptionValue(option)
|
|
615
|
+
},
|
|
616
|
+
getOptionChildren(option: any) {
|
|
617
|
+
if (typeof option === 'string') {
|
|
618
|
+
return null
|
|
619
|
+
}
|
|
620
|
+
return option?.children && option?.children?.length
|
|
621
|
+
? option?.children
|
|
622
|
+
: null
|
|
623
|
+
},
|
|
624
|
+
getOptionCount(option: any) {
|
|
625
|
+
return option?.count ?? null
|
|
626
|
+
},
|
|
627
|
+
getKeyForOption(
|
|
628
|
+
option: string | number | Record<string, string | number>
|
|
629
|
+
) {
|
|
630
|
+
if (typeof option === 'string' || typeof option === 'number') {
|
|
631
|
+
return option
|
|
632
|
+
}
|
|
633
|
+
return option.key ?? option.label
|
|
634
|
+
},
|
|
635
|
+
handleMenuTrigger(val: boolean) {
|
|
636
|
+
this.isExpanded = val
|
|
637
|
+
},
|
|
638
|
+
selectAll(val: string[] | boolean, e: Event): void {
|
|
639
|
+
e.preventDefault()
|
|
640
|
+
e.stopPropagation()
|
|
641
|
+
let toEmit: string[] = []
|
|
642
|
+
if (
|
|
643
|
+
!['string', 'number'].includes(typeof this.options[0]) &&
|
|
644
|
+
!this.isModelValuePrimitiveType &&
|
|
645
|
+
(this.modelValue as any)?.length < this.options.length
|
|
646
|
+
) {
|
|
647
|
+
toEmit = this.options.map((option: any) => option!.value)
|
|
648
|
+
}
|
|
649
|
+
this.$emit('update:model-value', toEmit)
|
|
650
|
+
this.$emit('change', toEmit)
|
|
651
|
+
},
|
|
652
|
+
clearSelection(): void {
|
|
653
|
+
this.selectedIndex = -1
|
|
654
|
+
this.closeMenu()
|
|
655
|
+
},
|
|
656
|
+
handleModelValueUpdate(val: any) {
|
|
657
|
+
this.$emit('update:model-value', val)
|
|
658
|
+
this.$emit('change', val)
|
|
659
|
+
},
|
|
660
|
+
selectOption(selected: any) {
|
|
661
|
+
if (this.multiselect) {
|
|
662
|
+
return
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
this.selectedIndex = this.options.findIndex(
|
|
666
|
+
(el: string | Record<string, string | number> | number) =>
|
|
667
|
+
isEqual(el, selected)
|
|
668
|
+
)
|
|
669
|
+
const selectedOption =
|
|
670
|
+
this.selectedIndex === -1
|
|
671
|
+
? undefined
|
|
672
|
+
: this.options[this.selectedIndex]
|
|
673
|
+
|
|
674
|
+
if (this.search) {
|
|
675
|
+
(this.$refs.searchInput as HTMLInputElement).value =
|
|
676
|
+
typeof selectedOption === 'string'
|
|
677
|
+
? selectedOption
|
|
678
|
+
: (selectedOption as Record<string, any>)?.label
|
|
679
|
+
}
|
|
680
|
+
this.closeMenu()
|
|
681
|
+
|
|
682
|
+
const valueToEmit =
|
|
683
|
+
this.emitValue && !this.isPrimitiveValue(selectedOption)
|
|
684
|
+
? (selectedOption as Record<string, any>)?.value
|
|
685
|
+
: selectedOption
|
|
686
|
+
|
|
687
|
+
this.handleModelValueUpdate(valueToEmit)
|
|
688
|
+
},
|
|
689
|
+
handleSearchInput(e: Event): void {
|
|
690
|
+
if (this.search) {
|
|
691
|
+
this.$emit(
|
|
692
|
+
'filter',
|
|
693
|
+
(e.target as HTMLInputElement).value.trim()
|
|
694
|
+
)
|
|
695
|
+
this.showAllItems =
|
|
696
|
+
(e.target as HTMLInputElement).value.trim() === ''
|
|
697
|
+
|
|
698
|
+
this.$nextTick(() => {
|
|
699
|
+
(this.$refs.menu as any)?.updatePosition()
|
|
700
|
+
})
|
|
701
|
+
}
|
|
702
|
+
this.$emit('search-input', (e.target as HTMLInputElement).value)
|
|
703
|
+
},
|
|
704
|
+
handleSearchBlur(e: Event): void {
|
|
705
|
+
if (this.search) {
|
|
706
|
+
const inputRef = this.$refs.searchInput as HTMLInputElement
|
|
707
|
+
this.$nextTick(() => {
|
|
708
|
+
inputRef?.focus({})
|
|
709
|
+
})
|
|
710
|
+
this.$emit('search-blur', e)
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
closeMenu(): void {
|
|
714
|
+
this.$emit('before-hide')
|
|
715
|
+
this.isExpanded = false
|
|
716
|
+
this.$emit('hide')
|
|
717
|
+
|
|
718
|
+
if (!this.preserveSearch) {
|
|
719
|
+
const inputRef = this.$refs.searchInput as HTMLInputElement
|
|
720
|
+
if (inputRef) inputRef.value = ''
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
getLabel,
|
|
724
|
+
onMenuOpen(): void {
|
|
725
|
+
this.$emit('before-show')
|
|
726
|
+
if (this.search) {
|
|
727
|
+
const inputRef = this.$refs.searchInput as HTMLInputElement
|
|
728
|
+
this.$nextTick(() => {
|
|
729
|
+
inputRef?.focus({})
|
|
730
|
+
})
|
|
731
|
+
}
|
|
732
|
+
this.$emit('show')
|
|
733
|
+
},
|
|
734
|
+
handleSearchFocus(e: FocusEvent): void {
|
|
735
|
+
this.$emit('search-focus', e)
|
|
736
|
+
},
|
|
737
|
+
onBlur(e: InputEvent): void {
|
|
738
|
+
this.$emit('search-blur', e)
|
|
739
|
+
},
|
|
740
|
+
handleSelected(value: any) {
|
|
741
|
+
this.$emit('selected', value)
|
|
742
|
+
},
|
|
743
|
+
handleDeselected(value: any) {
|
|
744
|
+
this.$emit('deselected', value)
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
})
|
|
748
|
+
</script>
|
|
749
|
+
|
|
750
|
+
<style scoped lang="scss">
|
|
751
|
+
.root-container {
|
|
752
|
+
width: var(--dl-select-width);
|
|
753
|
+
&--s {
|
|
754
|
+
display: flex;
|
|
755
|
+
align-items: center;
|
|
756
|
+
}
|
|
757
|
+
&--placeholder {
|
|
758
|
+
color: var(--placeholder-color);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
.dl-select__title-container {
|
|
762
|
+
margin-bottom: 6px;
|
|
763
|
+
display: flex;
|
|
764
|
+
align-items: center;
|
|
765
|
+
color: var(--dl-color-lighter);
|
|
766
|
+
|
|
767
|
+
&--s {
|
|
768
|
+
margin-right: 5px;
|
|
769
|
+
margin-bottom: 0px;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
.selected-label {
|
|
774
|
+
color: var(--placeholder-color);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
.dl-select__title {
|
|
778
|
+
color: var(--dl-color-medium);
|
|
779
|
+
font-size: 12px;
|
|
780
|
+
text-align: left;
|
|
781
|
+
margin-right: 5px;
|
|
782
|
+
white-space: nowrap;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.required-asterisk {
|
|
786
|
+
color: var(--dl-color-medium);
|
|
787
|
+
font-size: 12px;
|
|
788
|
+
user-select: none;
|
|
789
|
+
|
|
790
|
+
&--red {
|
|
791
|
+
color: var(--dl-color-negative);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
.tooltip-icon {
|
|
796
|
+
color: var(--dl-color-medium);
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.top-message-container {
|
|
800
|
+
display: flex;
|
|
801
|
+
margin-bottom: 10px;
|
|
802
|
+
text-align: start;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.select-wrapper {
|
|
806
|
+
position: relative;
|
|
807
|
+
width: 100%;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.dl_select__select {
|
|
811
|
+
border: 1px solid var(--dl-color-separator);
|
|
812
|
+
border-radius: 2px;
|
|
813
|
+
cursor: pointer;
|
|
814
|
+
color: var(--dl-color-darker);
|
|
815
|
+
height: 12px;
|
|
816
|
+
width: 100%;
|
|
817
|
+
box-sizing: content-box;
|
|
818
|
+
padding: 10px;
|
|
819
|
+
outline: none;
|
|
820
|
+
background: none;
|
|
821
|
+
font-size: 12px;
|
|
822
|
+
position: relative;
|
|
823
|
+
display: flex;
|
|
824
|
+
align-items: center;
|
|
825
|
+
transition-property: border-color;
|
|
826
|
+
transition-duration: 0.28s, 0.28s;
|
|
827
|
+
transition-timing-function: ease, ease;
|
|
828
|
+
transition-delay: 0s, 0s;
|
|
829
|
+
|
|
830
|
+
&--align-right {
|
|
831
|
+
justify-content: flex-end;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
&--prepend {
|
|
835
|
+
padding-left: 28px;
|
|
836
|
+
width: calc(100% - 10px - 28px);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
&--append {
|
|
840
|
+
padding-right: var(--dl-select-expand-icon-width);
|
|
841
|
+
width: calc(100% - 10px - var(--dl-select-expand-icon-width));
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
&--both-adornments {
|
|
845
|
+
width: calc(100% - 28px - 28px);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
&--m {
|
|
849
|
+
padding-top: 7px;
|
|
850
|
+
padding-bottom: 7px;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
&--s {
|
|
854
|
+
padding-top: 3px;
|
|
855
|
+
padding-bottom: 3px;
|
|
856
|
+
padding-left: 5px;
|
|
857
|
+
padding-right: 5px;
|
|
858
|
+
width: calc(100% - 10px);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
&--has-selection {
|
|
862
|
+
color: var(--dl-color-medium);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
&--error {
|
|
866
|
+
border-color: var(--dl-color-negative);
|
|
867
|
+
}
|
|
868
|
+
&--without-border {
|
|
869
|
+
border: none;
|
|
870
|
+
width: calc(100% - var(--dl-select-expand-icon-width));
|
|
871
|
+
padding: 0;
|
|
872
|
+
padding-right: var(--dl-select-expand-icon-width);
|
|
873
|
+
.adornment-container {
|
|
874
|
+
height: 100%;
|
|
875
|
+
}
|
|
876
|
+
height: auto;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
&::placeholder {
|
|
880
|
+
color: var(--dl-color-lighter);
|
|
881
|
+
opacity: 1;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
&:hover {
|
|
885
|
+
border-color: var(--dl-color-hover);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
&--focused {
|
|
889
|
+
border-color: var(--dl-color-secondary);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
&--disabled {
|
|
893
|
+
border-color: var(--dl-color-separator);
|
|
894
|
+
color: var(--dl-color-disabled);
|
|
895
|
+
cursor: not-allowed;
|
|
896
|
+
|
|
897
|
+
&:hover {
|
|
898
|
+
border-color: var(--dl-color-separator);
|
|
899
|
+
}
|
|
900
|
+
& input {
|
|
901
|
+
pointer-events: none;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.selected {
|
|
907
|
+
background-color: var(--dl-color-fill);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
.select-list {
|
|
911
|
+
padding: 5px 0;
|
|
912
|
+
max-height: var(--dl-select-dropdown-max-height);
|
|
913
|
+
overflow: auto;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
.expand-icon {
|
|
917
|
+
display: flex !important;
|
|
918
|
+
justify-content: center !important;
|
|
919
|
+
align-items: center;
|
|
920
|
+
color: var(--dl-color-medium);
|
|
921
|
+
transition-property: transform, -webkit-transform;
|
|
922
|
+
transition-duration: 0.28s, 0.28s;
|
|
923
|
+
transition-timing-function: ease, ease;
|
|
924
|
+
transition-delay: 0s, 0s;
|
|
925
|
+
&.expanded {
|
|
926
|
+
transform: rotate(180deg);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
.adornment-container {
|
|
931
|
+
display: flex;
|
|
932
|
+
justify-content: center;
|
|
933
|
+
align-items: center;
|
|
934
|
+
position: absolute;
|
|
935
|
+
width: 28px;
|
|
936
|
+
|
|
937
|
+
&--l {
|
|
938
|
+
height: 34px;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
&--m {
|
|
942
|
+
height: 28px;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
&--s {
|
|
946
|
+
height: 20px;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
&--pos-left {
|
|
950
|
+
top: 0;
|
|
951
|
+
left: 0;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
&--pos-right {
|
|
955
|
+
top: 0;
|
|
956
|
+
right: 0;
|
|
957
|
+
&-without_padding {
|
|
958
|
+
width: 14px;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.select-search-input {
|
|
964
|
+
appearance: none;
|
|
965
|
+
border: 0;
|
|
966
|
+
outline: none;
|
|
967
|
+
background: none;
|
|
968
|
+
color: var(--dl-color-darker);
|
|
969
|
+
font-family: 'Roboto', sans-serif;
|
|
970
|
+
font-size: 12px;
|
|
971
|
+
height: 14px;
|
|
972
|
+
|
|
973
|
+
&.hidden {
|
|
974
|
+
position: absolute;
|
|
975
|
+
width: 1px;
|
|
976
|
+
height: 1px;
|
|
977
|
+
padding: 0;
|
|
978
|
+
margin: -1px;
|
|
979
|
+
overflow: hidden;
|
|
980
|
+
clip: rect(0, 0, 0, 0);
|
|
981
|
+
white-space: nowrap;
|
|
982
|
+
border: 0;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
.bottom-message-container {
|
|
986
|
+
display: flex;
|
|
987
|
+
justify-content: space-between;
|
|
988
|
+
text-align: left;
|
|
989
|
+
padding-top: 3px;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
</style>
|