@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,380 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="slider-bar"
|
|
4
|
+
:aria-valuenow="model"
|
|
5
|
+
v-bind="attributes"
|
|
6
|
+
data-test="slider"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
v-touch-pan:horizontal.stop.mouse.mouseAllDir="onTouchPan"
|
|
10
|
+
v-bind="trackContainerAttrs"
|
|
11
|
+
class="track-container"
|
|
12
|
+
:class="{ readonly, disabled: disabled }"
|
|
13
|
+
data-test="track-container"
|
|
14
|
+
v-on="trackContainerEvents"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="track"
|
|
18
|
+
:style="trackStyle"
|
|
19
|
+
data-test="track"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
class="selection"
|
|
23
|
+
:style="selectionBarStyle"
|
|
24
|
+
/>
|
|
25
|
+
<div
|
|
26
|
+
class="thumb"
|
|
27
|
+
:style="thumbStyle"
|
|
28
|
+
data-test="thumb"
|
|
29
|
+
>
|
|
30
|
+
<input
|
|
31
|
+
v-if="name !== null && disabled !== true"
|
|
32
|
+
type="hidden"
|
|
33
|
+
:name="name"
|
|
34
|
+
:value="model"
|
|
35
|
+
>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script lang="ts">
|
|
43
|
+
import { defineComponent } from 'vue-demi'
|
|
44
|
+
import {
|
|
45
|
+
KEY_CODE,
|
|
46
|
+
getColor,
|
|
47
|
+
includes,
|
|
48
|
+
stopAndPrevent,
|
|
49
|
+
position,
|
|
50
|
+
keyCodes,
|
|
51
|
+
between
|
|
52
|
+
} from '../../../utils'
|
|
53
|
+
import touchPanDirective from '../../../directives/TouchPan'
|
|
54
|
+
|
|
55
|
+
export default defineComponent({
|
|
56
|
+
name: 'DlSliderBase',
|
|
57
|
+
directives: {
|
|
58
|
+
touchPan: touchPanDirective as any // force any type cause of the vue version
|
|
59
|
+
},
|
|
60
|
+
model: {
|
|
61
|
+
prop: 'modelValue',
|
|
62
|
+
event: 'update:model-value'
|
|
63
|
+
},
|
|
64
|
+
props: {
|
|
65
|
+
width: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: '100%'
|
|
68
|
+
},
|
|
69
|
+
color: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'dl-color-secondary'
|
|
72
|
+
},
|
|
73
|
+
snap: {
|
|
74
|
+
type: Boolean,
|
|
75
|
+
default: false
|
|
76
|
+
},
|
|
77
|
+
step: {
|
|
78
|
+
type: Number,
|
|
79
|
+
default: 1,
|
|
80
|
+
validator: (v: number) => v >= 0
|
|
81
|
+
},
|
|
82
|
+
min: {
|
|
83
|
+
type: Number,
|
|
84
|
+
default: 0
|
|
85
|
+
},
|
|
86
|
+
max: {
|
|
87
|
+
type: Number,
|
|
88
|
+
default: 100
|
|
89
|
+
},
|
|
90
|
+
readonly: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false
|
|
93
|
+
},
|
|
94
|
+
disabled: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: false
|
|
97
|
+
},
|
|
98
|
+
modelValue: {
|
|
99
|
+
type: Number,
|
|
100
|
+
required: true
|
|
101
|
+
},
|
|
102
|
+
thumbSize: {
|
|
103
|
+
type: String,
|
|
104
|
+
default: '10px'
|
|
105
|
+
},
|
|
106
|
+
trackSize: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: '3px'
|
|
109
|
+
},
|
|
110
|
+
tabindex: {
|
|
111
|
+
type: [String, Number],
|
|
112
|
+
default: '0'
|
|
113
|
+
},
|
|
114
|
+
name: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: null
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
emits: ['update:model-value', 'change', 'pan'],
|
|
120
|
+
data(): {
|
|
121
|
+
model: number
|
|
122
|
+
curRatio: number
|
|
123
|
+
active: boolean
|
|
124
|
+
dragging?: DOMRect
|
|
125
|
+
} {
|
|
126
|
+
return {
|
|
127
|
+
model: this.modelValue,
|
|
128
|
+
curRatio: 0,
|
|
129
|
+
active: false
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
computed: {
|
|
133
|
+
isMobile(): boolean {
|
|
134
|
+
return 'ontouchstart' in window
|
|
135
|
+
},
|
|
136
|
+
modelRatio(): number {
|
|
137
|
+
return this.convertModelToRatio(this.model)
|
|
138
|
+
},
|
|
139
|
+
ratio(): number {
|
|
140
|
+
return this.active === true ? this.curRatio : this.modelRatio
|
|
141
|
+
},
|
|
142
|
+
selectionBarStyle(): Record<string, any> {
|
|
143
|
+
return {
|
|
144
|
+
left: `${100 * this.minRation}%`,
|
|
145
|
+
width: `${100 * (this.ratio - this.minRation)}%`,
|
|
146
|
+
color:
|
|
147
|
+
this.disabled !== true
|
|
148
|
+
? getColor(this.color, 'dl-color-secondary')
|
|
149
|
+
: 'var(--dl-color-separator)'
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
thumbStyle(): Record<string, any> {
|
|
153
|
+
return {
|
|
154
|
+
width: this.thumbSize,
|
|
155
|
+
height: this.thumbSize,
|
|
156
|
+
left: `${100 * this.ratio}%`,
|
|
157
|
+
backgroundColor:
|
|
158
|
+
this.disabled !== true
|
|
159
|
+
? getColor(this.color, 'dl-color-secondary')
|
|
160
|
+
: 'var(--dl-color-separator)'
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
trackContainerEvents(): Record<string, any> {
|
|
164
|
+
if (this.editable !== true) {
|
|
165
|
+
return {}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return this.isMobile === true
|
|
169
|
+
? { click: this.onMobileClick }
|
|
170
|
+
: {
|
|
171
|
+
mousedown: this.onActivate,
|
|
172
|
+
keydown: this.onKeydown,
|
|
173
|
+
keyup: this.onKeyup
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
trackContainerAttrs(): Record<string, any> {
|
|
177
|
+
return {
|
|
178
|
+
tabindex: this.isMobile !== true ? this.computedTabindex : null
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
editable(): boolean {
|
|
182
|
+
return (
|
|
183
|
+
this.disabled !== true &&
|
|
184
|
+
this.readonly !== true &&
|
|
185
|
+
this.min < this.max
|
|
186
|
+
)
|
|
187
|
+
},
|
|
188
|
+
computedDecimals(): number {
|
|
189
|
+
return (String(this.step).trim().split('.')[1] || '').length
|
|
190
|
+
},
|
|
191
|
+
computedStep(): number {
|
|
192
|
+
return this.step === 0 ? 1 : this.step
|
|
193
|
+
},
|
|
194
|
+
computedTabindex(): string | number {
|
|
195
|
+
return this.editable === true ? this.tabindex || 0 : -1
|
|
196
|
+
},
|
|
197
|
+
trackLen(): number {
|
|
198
|
+
return this.max - this.min
|
|
199
|
+
},
|
|
200
|
+
minRation(): number {
|
|
201
|
+
return this.convertModelToRatio(this.min)
|
|
202
|
+
},
|
|
203
|
+
maxRatio(): number {
|
|
204
|
+
return this.convertModelToRatio(this.max)
|
|
205
|
+
},
|
|
206
|
+
attributes(): Record<string, any> {
|
|
207
|
+
const acc: Record<string, any> = {
|
|
208
|
+
role: 'slider',
|
|
209
|
+
'aria-valuemin': this.min,
|
|
210
|
+
'aria-valuemax': this.max,
|
|
211
|
+
'aria-orientation': 'horizontal',
|
|
212
|
+
'data-step': this.step
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (this.disabled === true) {
|
|
216
|
+
acc['aria-disabled'] = 'true'
|
|
217
|
+
} else if (this.readonly === true) {
|
|
218
|
+
acc['aria-readonly'] = 'true'
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return acc
|
|
222
|
+
},
|
|
223
|
+
trackStyle(): Record<string, any> {
|
|
224
|
+
return {
|
|
225
|
+
height: this.trackSize
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
onTouchPan(): Function | null {
|
|
229
|
+
return this.editable ? this.onPan : null
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
watch: {
|
|
233
|
+
modelValue() {
|
|
234
|
+
this.model = this.modelValue
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
beforeUnmount() {
|
|
238
|
+
document.removeEventListener(
|
|
239
|
+
'mouseup',
|
|
240
|
+
this.onDeactivate as EventListener, // eslint-disable-line no-undef
|
|
241
|
+
true
|
|
242
|
+
)
|
|
243
|
+
},
|
|
244
|
+
methods: {
|
|
245
|
+
updateValue(change?: boolean) {
|
|
246
|
+
if (this.model !== this.modelValue) {
|
|
247
|
+
this.$emit('update:model-value', this.model)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (change === true) {
|
|
251
|
+
this.$emit('change', this.model)
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
getDragging(evt?: MouseEvent) {
|
|
255
|
+
return this.$el.getBoundingClientRect()
|
|
256
|
+
},
|
|
257
|
+
updatePosition(event: MouseEvent, dragging?: DOMRect) {
|
|
258
|
+
const ratio = this.getDraggingRatio(
|
|
259
|
+
event,
|
|
260
|
+
dragging || this.dragging!
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
this.model = this.convertRatioToModel(ratio)
|
|
264
|
+
this.curRatio =
|
|
265
|
+
this.snap !== true || this.computedStep === 0
|
|
266
|
+
? ratio
|
|
267
|
+
: this.convertModelToRatio(this.model)
|
|
268
|
+
},
|
|
269
|
+
onKeydown(evt: KeyboardEvent) {
|
|
270
|
+
if (!includes(keyCodes, Number(evt.code))) return
|
|
271
|
+
|
|
272
|
+
stopAndPrevent(evt)
|
|
273
|
+
|
|
274
|
+
const step =
|
|
275
|
+
(includes([KEY_CODE.PGDOWN, KEY_CODE.PGUP], Number(evt.code))
|
|
276
|
+
? 10
|
|
277
|
+
: 1) * this.computedStep
|
|
278
|
+
const offset =
|
|
279
|
+
(includes(
|
|
280
|
+
[KEY_CODE.PGDOWN, KEY_CODE.LEFT, KEY_CODE.DOWN],
|
|
281
|
+
Number(evt.code)
|
|
282
|
+
)
|
|
283
|
+
? -1
|
|
284
|
+
: 1) * step
|
|
285
|
+
|
|
286
|
+
this.model = between(
|
|
287
|
+
parseFloat(
|
|
288
|
+
(this.model + offset).toFixed(this.computedDecimals)
|
|
289
|
+
),
|
|
290
|
+
this.min,
|
|
291
|
+
this.max
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
this.updateValue()
|
|
295
|
+
},
|
|
296
|
+
convertRatioToModel(ratio: number) {
|
|
297
|
+
let model = this.min + ratio * (this.max - this.min)
|
|
298
|
+
|
|
299
|
+
if (this.step > 0) {
|
|
300
|
+
const modulo = (model - this.min) % this.step
|
|
301
|
+
model +=
|
|
302
|
+
(Math.abs(modulo) >= this.step / 2
|
|
303
|
+
? (modulo < 0 ? -1 : 1) * this.step
|
|
304
|
+
: 0) - modulo
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (this.computedDecimals > 0) {
|
|
308
|
+
model = parseFloat(model.toFixed(this.computedDecimals))
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return between(model, this.min, this.max)
|
|
312
|
+
},
|
|
313
|
+
convertModelToRatio(model: number) {
|
|
314
|
+
return this.trackLen === 0 ? 0 : (model - this.min) / this.trackLen
|
|
315
|
+
},
|
|
316
|
+
getDraggingRatio(evt: MouseEvent, dragging: DOMRect) {
|
|
317
|
+
const pos = position(evt)
|
|
318
|
+
const val = between(
|
|
319
|
+
(pos.left - dragging.left) / dragging.width,
|
|
320
|
+
0,
|
|
321
|
+
1
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
return between(val, this.minRation, this.maxRatio)
|
|
325
|
+
},
|
|
326
|
+
onActivate(evt: MouseEvent) {
|
|
327
|
+
this.updatePosition(evt, this.getDragging(evt))
|
|
328
|
+
this.updateValue()
|
|
329
|
+
|
|
330
|
+
this.active = true
|
|
331
|
+
|
|
332
|
+
document.addEventListener('mouseup', this.onDeactivate, true)
|
|
333
|
+
},
|
|
334
|
+
onDeactivate() {
|
|
335
|
+
this.active = false
|
|
336
|
+
|
|
337
|
+
this.updateValue(true)
|
|
338
|
+
|
|
339
|
+
document.removeEventListener('mouseup', this.onDeactivate, true)
|
|
340
|
+
},
|
|
341
|
+
onMobileClick(evt: any) {
|
|
342
|
+
this.updatePosition(evt, this.getDragging(evt))
|
|
343
|
+
this.updateValue(true)
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
onKeyup(evt: KeyboardEvent) {
|
|
347
|
+
if (includes(keyCodes, Number(evt.code))) {
|
|
348
|
+
this.updateValue(true)
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
onPan(event: any): void {
|
|
352
|
+
if (event.isFinal === true) {
|
|
353
|
+
if (this.dragging !== void 0) {
|
|
354
|
+
this.updatePosition(event.evt)
|
|
355
|
+
if (event.touch === true) {
|
|
356
|
+
this.updateValue(true)
|
|
357
|
+
}
|
|
358
|
+
this.dragging = void 0
|
|
359
|
+
this.$emit('pan', 'end')
|
|
360
|
+
}
|
|
361
|
+
this.active = false
|
|
362
|
+
} else if (event.isFirst === true) {
|
|
363
|
+
this.dragging = this.getDragging(event.evt)
|
|
364
|
+
this.updatePosition(event.evt)
|
|
365
|
+
this.updateValue()
|
|
366
|
+
this.active = true
|
|
367
|
+
this.$emit('pan', 'start')
|
|
368
|
+
} else {
|
|
369
|
+
this.updatePosition(event.evt)
|
|
370
|
+
this.updateValue()
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
template: 'dl-slider-base'
|
|
375
|
+
})
|
|
376
|
+
</script>
|
|
377
|
+
|
|
378
|
+
<style scoped lang="scss">
|
|
379
|
+
@import '../sliderStyles.scss';
|
|
380
|
+
</style>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input
|
|
3
|
+
ref="sliderInput"
|
|
4
|
+
:value="sliderValue"
|
|
5
|
+
type="number"
|
|
6
|
+
:min="min"
|
|
7
|
+
:max="max"
|
|
8
|
+
:readonly="readonly"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
@input="sliderValue = $event"
|
|
11
|
+
@change="handleChange"
|
|
12
|
+
>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { defineComponent } from 'vue-demi'
|
|
17
|
+
import { getInputValue } from '../utils'
|
|
18
|
+
|
|
19
|
+
export default defineComponent({
|
|
20
|
+
name: 'DlSliderInput',
|
|
21
|
+
model: {
|
|
22
|
+
prop: 'modelValue',
|
|
23
|
+
event: 'update:model-value'
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: null
|
|
29
|
+
},
|
|
30
|
+
min: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 0
|
|
33
|
+
},
|
|
34
|
+
max: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 100
|
|
37
|
+
},
|
|
38
|
+
readonly: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
disabled: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
emits: ['update:model-value', 'change'],
|
|
48
|
+
computed: {
|
|
49
|
+
sliderValue: {
|
|
50
|
+
get(): number | undefined {
|
|
51
|
+
return this.modelValue
|
|
52
|
+
},
|
|
53
|
+
set(evt: any): void {
|
|
54
|
+
const val = evt.target.value
|
|
55
|
+
|
|
56
|
+
if (val === '') return
|
|
57
|
+
|
|
58
|
+
const { value } = getInputValue(val, this.min, this.max)
|
|
59
|
+
|
|
60
|
+
;(this.$refs.sliderInput as HTMLInputElement).value = value
|
|
61
|
+
|
|
62
|
+
this.$emit('update:model-value', Number(value))
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
handleChange(evt: any) {
|
|
68
|
+
const val = evt.target.value
|
|
69
|
+
if (val === '') return
|
|
70
|
+
|
|
71
|
+
const { value } = getInputValue(val, this.min, this.max)
|
|
72
|
+
|
|
73
|
+
;(this.$refs.sliderInput as HTMLInputElement).value = value
|
|
74
|
+
|
|
75
|
+
this.$emit('change', Number(value))
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
template: 'dl-slider-input'
|
|
79
|
+
})
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style scoped>
|
|
83
|
+
input[type='number'] {
|
|
84
|
+
width: 31px;
|
|
85
|
+
height: 12px;
|
|
86
|
+
padding-top: 3px;
|
|
87
|
+
padding-left: 5px;
|
|
88
|
+
padding-bottom: 3px;
|
|
89
|
+
color: var(--text-color);
|
|
90
|
+
background-color: transparent;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Chrome, Safari, Edge, Opera */
|
|
94
|
+
input::-webkit-outer-spin-button,
|
|
95
|
+
input::-webkit-inner-spin-button {
|
|
96
|
+
-webkit-appearance: none;
|
|
97
|
+
margin: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Firefox */
|
|
101
|
+
input[type='number'] {
|
|
102
|
+
-moz-appearance: textfield;
|
|
103
|
+
border: none;
|
|
104
|
+
border: 1px solid var(--dl-color-separator);
|
|
105
|
+
border-radius: 2px;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
input[type='number']:hover {
|
|
109
|
+
border: none;
|
|
110
|
+
border: 1px solid var(--dl-color-hover);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
input[type='number']:focus-visible {
|
|
114
|
+
border-color: var(--color);
|
|
115
|
+
outline: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
input:disabled {
|
|
119
|
+
border-color: var(--dl-color-separator) !important;
|
|
120
|
+
color: var(--dl-color-disabled);
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
.slider-bar {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
cursor: grab;
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
flex-wrap: nowrap;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
opacity: 1;
|
|
9
|
+
|
|
10
|
+
& .track-container {
|
|
11
|
+
cursor: grab;
|
|
12
|
+
outline: 0;
|
|
13
|
+
width: 100%;
|
|
14
|
+
padding: 4px 0;
|
|
15
|
+
|
|
16
|
+
& .track {
|
|
17
|
+
height: 2px;
|
|
18
|
+
width: inherit;
|
|
19
|
+
position: relative;
|
|
20
|
+
outline: none;
|
|
21
|
+
background-color: var(--dl-color-separator);
|
|
22
|
+
|
|
23
|
+
& .selection {
|
|
24
|
+
background: currentColor;
|
|
25
|
+
border-radius: inherit;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
position: absolute;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
& .thumb {
|
|
32
|
+
z-index: 1;
|
|
33
|
+
outline: 0;
|
|
34
|
+
transition: transform 0.18s ease-out, fill 0.18s ease-out,
|
|
35
|
+
stroke 0.18s ease-out;
|
|
36
|
+
top: 50%;
|
|
37
|
+
transform: scale(1) translate(-50%, -50%);
|
|
38
|
+
position: absolute;
|
|
39
|
+
user-select: none;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.slider-content {
|
|
47
|
+
font-size: var(--dl-font-size-body);
|
|
48
|
+
line-height: 13px;
|
|
49
|
+
color: var(--text-color);
|
|
50
|
+
|
|
51
|
+
.disabled {
|
|
52
|
+
color: var(--dl-color-separator);
|
|
53
|
+
cursor: not-allowed;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.readonly {
|
|
57
|
+
cursor: auto;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.slider {
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
width: var(--width);
|
|
65
|
+
|
|
66
|
+
& .slider-bar-container {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
width: 100%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
& .text {
|
|
73
|
+
padding: 0;
|
|
74
|
+
margin-right: 5px;
|
|
75
|
+
text-align: left;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
& .capitalize::first-letter {
|
|
79
|
+
text-transform: capitalize;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.editable {
|
|
84
|
+
align-items: center;
|
|
85
|
+
flex-direction: row;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.non-editable {
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
|
|
91
|
+
& .header {
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
align-items: center;
|
|
95
|
+
margin-bottom: 10px;
|
|
96
|
+
|
|
97
|
+
& .right-container {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: space-between;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// override the button padding
|
|
106
|
+
.dl-button {
|
|
107
|
+
padding: 0;
|
|
108
|
+
font-size: var(--dl-font-size-body);
|
|
109
|
+
}
|