@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,332 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="dl-calendar"
|
|
4
|
+
:class="{ 'dl-calendar-disabled': disabled }"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
class="dl-calendar--title"
|
|
8
|
+
:class="{ 'dl-calendar--title-disabled': disabled }"
|
|
9
|
+
>
|
|
10
|
+
<dl-icon
|
|
11
|
+
v-if="withLeftChevron"
|
|
12
|
+
icon="icon-dl-left-chevron"
|
|
13
|
+
class="dl-calendar--left-chevron"
|
|
14
|
+
size="16px"
|
|
15
|
+
:style="chevronStyle"
|
|
16
|
+
@click="$emit('prev')"
|
|
17
|
+
/>
|
|
18
|
+
{{ title }}
|
|
19
|
+
<dl-icon
|
|
20
|
+
v-if="withRightChevron"
|
|
21
|
+
icon="icon-dl-right-chevron"
|
|
22
|
+
class="dl-calendar--right-chevron"
|
|
23
|
+
size="16px"
|
|
24
|
+
:style="chevronStyle"
|
|
25
|
+
@click="$emit('next')"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="dl-calendar--header">
|
|
29
|
+
<div
|
|
30
|
+
v-for="day in weekNames"
|
|
31
|
+
:key="day"
|
|
32
|
+
class="dl-calendar--header_item"
|
|
33
|
+
:class="{ 'dl-calendar--header_item-disabled': disabled }"
|
|
34
|
+
>
|
|
35
|
+
{{ day }}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="dl-calendar--content">
|
|
39
|
+
<div
|
|
40
|
+
v-for="date in dates"
|
|
41
|
+
:key="date.toString()"
|
|
42
|
+
class="dl-calendar--day"
|
|
43
|
+
:class="{ 'dl-calendar--day-disabled': disabled }"
|
|
44
|
+
:style="getDayStyle(date)"
|
|
45
|
+
@click="handleClick(date)"
|
|
46
|
+
@mousedown="handleMouseDown(date)"
|
|
47
|
+
@mouseenter="handleMouseEnter(date)"
|
|
48
|
+
>
|
|
49
|
+
<div
|
|
50
|
+
class="dl-calendar--inner_day"
|
|
51
|
+
:style="getInnerDayStyle(date)"
|
|
52
|
+
>
|
|
53
|
+
{{ date.date() }}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
<script lang="ts">
|
|
60
|
+
import DlIcon from '../DlIcon.vue'
|
|
61
|
+
import { CalendarDate } from './classes/CalendarDate'
|
|
62
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
63
|
+
import { getWeekDayNames } from './utils'
|
|
64
|
+
import { DateInterval } from './types'
|
|
65
|
+
import { CustomDate } from './classes/CustomDate'
|
|
66
|
+
import { isInRange } from './isInRange'
|
|
67
|
+
|
|
68
|
+
const DAYS_IN_WEEK = 7
|
|
69
|
+
|
|
70
|
+
export default defineComponent({
|
|
71
|
+
components: {
|
|
72
|
+
DlIcon
|
|
73
|
+
},
|
|
74
|
+
model: {
|
|
75
|
+
prop: 'modelValue',
|
|
76
|
+
event: 'update:modelValue'
|
|
77
|
+
},
|
|
78
|
+
props: {
|
|
79
|
+
title: {
|
|
80
|
+
type: String,
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
dates: {
|
|
84
|
+
type: Array as PropType<Partial<CalendarDate>[]>,
|
|
85
|
+
required: true
|
|
86
|
+
},
|
|
87
|
+
availableRange: {
|
|
88
|
+
type: Object as PropType<Partial<DateInterval>>,
|
|
89
|
+
default: null
|
|
90
|
+
},
|
|
91
|
+
modelValue: {
|
|
92
|
+
type: Object as PropType<DateInterval>,
|
|
93
|
+
default: () => {
|
|
94
|
+
const date = new Date()
|
|
95
|
+
return {
|
|
96
|
+
from: date,
|
|
97
|
+
to: date
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
withLeftChevron: Boolean,
|
|
102
|
+
withRightChevron: Boolean,
|
|
103
|
+
disabled: Boolean
|
|
104
|
+
},
|
|
105
|
+
emits: [
|
|
106
|
+
'update:modelValue',
|
|
107
|
+
'change',
|
|
108
|
+
'mousedown',
|
|
109
|
+
'mouseenter',
|
|
110
|
+
'next',
|
|
111
|
+
'prev'
|
|
112
|
+
],
|
|
113
|
+
computed: {
|
|
114
|
+
weekNames(): string[] {
|
|
115
|
+
return getWeekDayNames()
|
|
116
|
+
},
|
|
117
|
+
chevronStyle(): Record<string, any> {
|
|
118
|
+
return this.disabled
|
|
119
|
+
? {
|
|
120
|
+
color: 'var(--dl-color-disabled)',
|
|
121
|
+
cursor: 'not-allowed'
|
|
122
|
+
}
|
|
123
|
+
: {
|
|
124
|
+
color: 'var(--dl-color-darker)',
|
|
125
|
+
cursor: 'pointer'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
methods: {
|
|
130
|
+
handleClick(value: CustomDate) {
|
|
131
|
+
if (!isInRange(this.availableRange, value)) return
|
|
132
|
+
const newDate = {
|
|
133
|
+
from: value.toDate(),
|
|
134
|
+
to: value.toDate()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
this.$emit('update:modelValue', newDate)
|
|
138
|
+
this.$emit('change', newDate)
|
|
139
|
+
},
|
|
140
|
+
getDayStyle(value: Partial<CalendarDate>) {
|
|
141
|
+
const style: Record<string, any> = {}
|
|
142
|
+
|
|
143
|
+
const from = new CalendarDate(this.modelValue.from)
|
|
144
|
+
const to = new CalendarDate(this.modelValue.to)
|
|
145
|
+
|
|
146
|
+
if (!from.isSameOrAfter(to, 'date')) {
|
|
147
|
+
const bgColor = 'rgba(52, 82, 255, 0.1)'
|
|
148
|
+
|
|
149
|
+
if (value.isAfter(from, 'date') && value.isBefore(to, 'date')) {
|
|
150
|
+
style.background = bgColor
|
|
151
|
+
} else if (value.isSame(from, 'date')) {
|
|
152
|
+
style.background = `linear-gradient(to right, transparent 50%, ${bgColor} 50%)`
|
|
153
|
+
} else if (value.isSame(to, 'date')) {
|
|
154
|
+
style.background = `linear-gradient(to right, ${bgColor} 50%, transparent 50%)`
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const radius = '11px'
|
|
158
|
+
|
|
159
|
+
if (value.day() === 0) {
|
|
160
|
+
style.borderTopLeftRadius = radius
|
|
161
|
+
style.borderBottomLeftRadius = radius
|
|
162
|
+
} else if (value.day() === DAYS_IN_WEEK - 1) {
|
|
163
|
+
style.borderTopRightRadius = radius
|
|
164
|
+
style.borderBottomRightRadius = radius
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return style
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
getInnerDayStyle(value: Partial<CalendarDate>) {
|
|
172
|
+
let style: Record<string, any> = {}
|
|
173
|
+
|
|
174
|
+
const isToday = value.isSame(new CalendarDate(), 'date')
|
|
175
|
+
|
|
176
|
+
if (
|
|
177
|
+
!isInRange(
|
|
178
|
+
this.availableRange,
|
|
179
|
+
new CustomDate(value.toString())
|
|
180
|
+
)
|
|
181
|
+
) {
|
|
182
|
+
if (isToday) {
|
|
183
|
+
style.color = 'var(--dl-color-secondary)'
|
|
184
|
+
} else {
|
|
185
|
+
style.color = 'var(--dl-color-lighter)'
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
const selectedStyle = {
|
|
189
|
+
backgroundColor: 'var(--dl-color-secondary)',
|
|
190
|
+
color: 'var(--dl-color-text-buttons)',
|
|
191
|
+
borderRadius: '11px'
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const disabledOpacity = 0.6
|
|
195
|
+
|
|
196
|
+
const from = new CalendarDate(this.modelValue.from)
|
|
197
|
+
const to = new CalendarDate(this.modelValue.to)
|
|
198
|
+
|
|
199
|
+
const isIntervalBoundary =
|
|
200
|
+
value.isSame(from, 'date') || value.isSame(to, 'date')
|
|
201
|
+
|
|
202
|
+
if (isIntervalBoundary && this.disabled) {
|
|
203
|
+
style = {
|
|
204
|
+
...style,
|
|
205
|
+
...selectedStyle,
|
|
206
|
+
opacity: disabledOpacity,
|
|
207
|
+
color: 'var(--dl-color-disabled)'
|
|
208
|
+
}
|
|
209
|
+
} else if (isIntervalBoundary) {
|
|
210
|
+
style = {
|
|
211
|
+
...style,
|
|
212
|
+
...selectedStyle
|
|
213
|
+
}
|
|
214
|
+
} else if (isToday && !isIntervalBoundary && this.disabled) {
|
|
215
|
+
style.color = 'var(--dl-color-secondary)'
|
|
216
|
+
style.opacity = disabledOpacity
|
|
217
|
+
} else if (isToday && !isIntervalBoundary) {
|
|
218
|
+
style.color = 'var(--dl-color-secondary)'
|
|
219
|
+
} else if (this.disabled) {
|
|
220
|
+
style.color = 'var(--dl-color-disabled)'
|
|
221
|
+
} else if (value.isDisabled) {
|
|
222
|
+
style.color = 'var(--dl-color-lighter)'
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return style
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
handleMouseDown(value: CustomDate) {
|
|
230
|
+
if (!isInRange(this.availableRange, value)) return
|
|
231
|
+
this.$emit('mousedown', value.toDate())
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
handleMouseEnter(value: CustomDate) {
|
|
235
|
+
if (!isInRange(this.availableRange, value)) return
|
|
236
|
+
|
|
237
|
+
if (value.isBefore(new CustomDate(this.modelValue.from))) return
|
|
238
|
+
|
|
239
|
+
this.$emit('mouseenter', value.toDate())
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
</script>
|
|
244
|
+
<style lang="scss" scoped>
|
|
245
|
+
.dl-calendar {
|
|
246
|
+
font-size: 12px;
|
|
247
|
+
display: flex;
|
|
248
|
+
flex-direction: column;
|
|
249
|
+
width: 100%;
|
|
250
|
+
|
|
251
|
+
&--title {
|
|
252
|
+
display: flex;
|
|
253
|
+
justify-content: center;
|
|
254
|
+
align-items: center;
|
|
255
|
+
flex-wrap: nowrap;
|
|
256
|
+
font-size: 14px;
|
|
257
|
+
padding: 0 15px 20px 15px;
|
|
258
|
+
position: relative;
|
|
259
|
+
color: var(--dl-color-darker);
|
|
260
|
+
|
|
261
|
+
&-disabled {
|
|
262
|
+
color: var(--dl-color-disabled);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
&--left-chevron,
|
|
267
|
+
&--right-chevron {
|
|
268
|
+
width: 16px;
|
|
269
|
+
height: 16px;
|
|
270
|
+
position: absolute;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&--left-chevron {
|
|
274
|
+
left: 0;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&--right-chevron {
|
|
278
|
+
right: 0;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&--header {
|
|
282
|
+
font-weight: bold;
|
|
283
|
+
display: flex;
|
|
284
|
+
padding-bottom: 10px;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
&--content {
|
|
288
|
+
display: grid;
|
|
289
|
+
grid-template-columns: repeat(7, 1fr);
|
|
290
|
+
row-gap: 10px;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&--header_item {
|
|
294
|
+
min-height: 18px;
|
|
295
|
+
color: var(--dl-color-medium);
|
|
296
|
+
justify-content: center;
|
|
297
|
+
align-items: center;
|
|
298
|
+
|
|
299
|
+
&-disabled {
|
|
300
|
+
color: var(--dl-color-disabled);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
&--day {
|
|
305
|
+
min-height: 20px;
|
|
306
|
+
color: var(--dl-color-darker);
|
|
307
|
+
|
|
308
|
+
&-disabled {
|
|
309
|
+
color: var(--dl-color-disabled);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&--inner_day {
|
|
314
|
+
width: 20px;
|
|
315
|
+
height: 20px;
|
|
316
|
+
display: flex;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
align-items: center;
|
|
319
|
+
margin: 0 auto;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
&--header_item,
|
|
323
|
+
&--day {
|
|
324
|
+
display: flex;
|
|
325
|
+
flex: 1 1 auto;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.dl-calendar-disabled {
|
|
330
|
+
cursor: not-allowed !important;
|
|
331
|
+
}
|
|
332
|
+
</style>
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
class="dl-date-picker"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
v-if="type === 'day'"
|
|
8
|
+
class="dl-date-picker--day_picker"
|
|
9
|
+
>
|
|
10
|
+
<div class="dl-date-picker--calendar_from">
|
|
11
|
+
<dl-calendar
|
|
12
|
+
v-if="calendarFrom"
|
|
13
|
+
:model-value="dateInterval"
|
|
14
|
+
:title="calendarFrom.dateTitle"
|
|
15
|
+
:dates="calendarFrom.dates"
|
|
16
|
+
:available-range="availableRange"
|
|
17
|
+
:disabled="disabled"
|
|
18
|
+
:with-left-chevron="true"
|
|
19
|
+
@prev="handleDatePrev"
|
|
20
|
+
@update:modelValue="updateDateInterval"
|
|
21
|
+
@mousedown="handleMousedown"
|
|
22
|
+
@mouseenter="handleMouseenter"
|
|
23
|
+
/>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="dl-date-picker--calendar_to">
|
|
26
|
+
<dl-calendar
|
|
27
|
+
v-if="calendarTo"
|
|
28
|
+
:model-value="dateInterval"
|
|
29
|
+
:title="calendarTo.dateTitle"
|
|
30
|
+
:dates="calendarTo.dates"
|
|
31
|
+
:available-range="availableRange"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
:with-right-chevron="true"
|
|
34
|
+
@next="handleDateNext"
|
|
35
|
+
@update:modelValue="updateDateInterval"
|
|
36
|
+
@mousedown="handleMousedown"
|
|
37
|
+
@mouseenter="handleMouseenter"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
<div
|
|
42
|
+
v-else
|
|
43
|
+
class="dl-date-picker--month_picker"
|
|
44
|
+
>
|
|
45
|
+
<div class="dl-date-picker--calendar_from">
|
|
46
|
+
<dl-month-calendar
|
|
47
|
+
:model-value="dateInterval"
|
|
48
|
+
:title="calendarFrom.monthTitle"
|
|
49
|
+
:available-range="availableRange"
|
|
50
|
+
:disabled="disabled"
|
|
51
|
+
:with-left-chevron="true"
|
|
52
|
+
@update:modelValue="updateDateInterval"
|
|
53
|
+
@prev="handleMonthPrev"
|
|
54
|
+
@mousedown="handleMousedown"
|
|
55
|
+
@mouseenter="handleMouseenter"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="dl-date-picker--calendar_to">
|
|
59
|
+
<dl-month-calendar
|
|
60
|
+
:model-value="dateInterval"
|
|
61
|
+
:title="calendarTo.monthTitle"
|
|
62
|
+
:available-range="availableRange"
|
|
63
|
+
:disabled="disabled"
|
|
64
|
+
:with-right-chevron="true"
|
|
65
|
+
@update:modelValue="updateDateInterval"
|
|
66
|
+
@next="handleMonthNext"
|
|
67
|
+
@mousedown="handleMousedown"
|
|
68
|
+
@mouseenter="handleMouseenter"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</template>
|
|
74
|
+
<script lang="ts">
|
|
75
|
+
import DlCalendar from './DlCalendar.vue'
|
|
76
|
+
import DlMonthCalendar from './DlMonthCalendar.vue'
|
|
77
|
+
import { Calendar } from './classes/Calendar'
|
|
78
|
+
import { CalendarDate } from './classes/CalendarDate'
|
|
79
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
80
|
+
import { DateInterval } from './types'
|
|
81
|
+
import { v4 } from 'uuid'
|
|
82
|
+
|
|
83
|
+
const HOVER_TIMEOUT = 700
|
|
84
|
+
|
|
85
|
+
export default defineComponent({
|
|
86
|
+
components: {
|
|
87
|
+
DlCalendar,
|
|
88
|
+
DlMonthCalendar
|
|
89
|
+
},
|
|
90
|
+
model: {
|
|
91
|
+
prop: 'modelValue',
|
|
92
|
+
event: 'update:modelValue'
|
|
93
|
+
},
|
|
94
|
+
props: {
|
|
95
|
+
modelValue: {
|
|
96
|
+
type: Object as PropType<DateInterval>,
|
|
97
|
+
default: () => {
|
|
98
|
+
const date = new Date()
|
|
99
|
+
return {
|
|
100
|
+
from: date,
|
|
101
|
+
to: date
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
type: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: 'day'
|
|
108
|
+
},
|
|
109
|
+
availableRange: {
|
|
110
|
+
type: Object as PropType<Partial<DateInterval> | null>,
|
|
111
|
+
default: null
|
|
112
|
+
},
|
|
113
|
+
normalizeCalendars: Boolean,
|
|
114
|
+
disabled: Boolean
|
|
115
|
+
},
|
|
116
|
+
emits: ['update:modelValue', 'change'],
|
|
117
|
+
data(): {
|
|
118
|
+
uuid: string
|
|
119
|
+
timeout: number | null
|
|
120
|
+
calendarFrom: Calendar | null
|
|
121
|
+
calendarTo: Calendar | null
|
|
122
|
+
isSelectionMode: boolean
|
|
123
|
+
dateInterval: DateInterval
|
|
124
|
+
} {
|
|
125
|
+
return {
|
|
126
|
+
uuid: `dl-date-picker-${v4()}`,
|
|
127
|
+
timeout: null,
|
|
128
|
+
calendarFrom: null,
|
|
129
|
+
calendarTo: null,
|
|
130
|
+
isSelectionMode: false,
|
|
131
|
+
dateInterval: this.modelValue
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
watch: {
|
|
135
|
+
type(value: string) {
|
|
136
|
+
const cDateFrom = new CalendarDate(this.modelValue.from)
|
|
137
|
+
const cDateTo = new CalendarDate(this.modelValue.to)
|
|
138
|
+
|
|
139
|
+
this.calendarFrom!.currentDate = cDateFrom
|
|
140
|
+
this.calendarTo!.currentDate = cDateTo
|
|
141
|
+
|
|
142
|
+
const unit = value === 'day' ? 'month' : 'year'
|
|
143
|
+
|
|
144
|
+
this.calendarTo!.activeDate = cDateTo
|
|
145
|
+
this.calendarFrom!.activeDate = new CalendarDate(cDateTo).subtract(
|
|
146
|
+
1,
|
|
147
|
+
unit
|
|
148
|
+
)
|
|
149
|
+
},
|
|
150
|
+
modelValue: {
|
|
151
|
+
handler(value: DateInterval) {
|
|
152
|
+
this.dateInterval = value
|
|
153
|
+
const cDateFrom = new CalendarDate(value.from)
|
|
154
|
+
const cDateTo = new CalendarDate(value.to)
|
|
155
|
+
|
|
156
|
+
this.calendarFrom!.currentDate = cDateFrom
|
|
157
|
+
this.calendarTo!.currentDate = cDateTo
|
|
158
|
+
|
|
159
|
+
if (this.normalizeCalendars) {
|
|
160
|
+
const unit = this.type === 'day' ? 'month' : 'year'
|
|
161
|
+
|
|
162
|
+
this.calendarTo!.activeDate = cDateTo
|
|
163
|
+
this.calendarFrom!.activeDate = new CalendarDate(
|
|
164
|
+
cDateTo
|
|
165
|
+
).subtract(1, unit)
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
deep: true
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
beforeMount() {
|
|
172
|
+
const cDateFrom = new CalendarDate(this.modelValue.from)
|
|
173
|
+
const cDateTo = new CalendarDate(this.modelValue.to)
|
|
174
|
+
|
|
175
|
+
const unit = this.type === 'day' ? 'month' : 'year'
|
|
176
|
+
|
|
177
|
+
this.calendarFrom = new Calendar(cDateFrom)
|
|
178
|
+
this.calendarFrom.activeDate = new CalendarDate(cDateTo).subtract(
|
|
179
|
+
1,
|
|
180
|
+
unit
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
this.calendarTo = new Calendar(cDateTo)
|
|
184
|
+
this.calendarTo.activeDate = cDateTo
|
|
185
|
+
},
|
|
186
|
+
beforeUnmount() {
|
|
187
|
+
if (this.timeout) {
|
|
188
|
+
clearTimeout(this.timeout)
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
methods: {
|
|
192
|
+
updateModelValue(value: DateInterval) {
|
|
193
|
+
if (this.disabled) return
|
|
194
|
+
this.$emit('update:modelValue', value)
|
|
195
|
+
this.$emit('change', value)
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
updateDateInterval(value: DateInterval) {
|
|
199
|
+
if (this.disabled) return
|
|
200
|
+
this.dateInterval = value
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
handleDateNext() {
|
|
204
|
+
if (this.disabled) return
|
|
205
|
+
|
|
206
|
+
this.calendarFrom?.moveToNextMonth()
|
|
207
|
+
this.calendarTo?.moveToNextMonth()
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
handleDatePrev() {
|
|
211
|
+
if (this.disabled) return
|
|
212
|
+
|
|
213
|
+
this.calendarFrom?.moveToPreviousMonth()
|
|
214
|
+
this.calendarTo?.moveToPreviousMonth()
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
handleMonthNext() {
|
|
218
|
+
if (this.disabled) return
|
|
219
|
+
|
|
220
|
+
this.calendarFrom?.moveToNextYear()
|
|
221
|
+
this.calendarTo?.moveToNextYear()
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
handleMonthPrev() {
|
|
225
|
+
if (this.disabled) return
|
|
226
|
+
|
|
227
|
+
this.calendarFrom?.moveToPreviousYear()
|
|
228
|
+
this.calendarTo?.moveToPreviousYear()
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
handleMouseup() {
|
|
232
|
+
if (this.timeout) {
|
|
233
|
+
clearTimeout(this.timeout)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this.isSelectionMode) {
|
|
237
|
+
window.removeEventListener('mouseup', this.handleMouseup)
|
|
238
|
+
this.isSelectionMode = false
|
|
239
|
+
this.updateModelValue(this.dateInterval)
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
handleMousedown(date: Date) {
|
|
244
|
+
if (this.disabled) return
|
|
245
|
+
|
|
246
|
+
window.addEventListener('mouseup', this.handleMouseup)
|
|
247
|
+
|
|
248
|
+
this.dateInterval = { from: date, to: date }
|
|
249
|
+
|
|
250
|
+
this.isSelectionMode = true
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
handleMouseenter(date: Date) {
|
|
254
|
+
if (!this.isSelectionMode) return
|
|
255
|
+
|
|
256
|
+
if (this.type === 'day') {
|
|
257
|
+
if (
|
|
258
|
+
this.calendarTo?.dates[
|
|
259
|
+
this.calendarTo?.dates.length - 1
|
|
260
|
+
].isSame(new CalendarDate(date))
|
|
261
|
+
) {
|
|
262
|
+
if (this.timeout) {
|
|
263
|
+
clearTimeout(this.timeout)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// @ts-ignore
|
|
267
|
+
this.timeout = setTimeout(
|
|
268
|
+
this.handleDateNext,
|
|
269
|
+
HOVER_TIMEOUT
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
if (
|
|
274
|
+
this.calendarTo?.activeDate.isSame(
|
|
275
|
+
new CalendarDate(date),
|
|
276
|
+
'year'
|
|
277
|
+
) &&
|
|
278
|
+
new CalendarDate(date).month() === 11
|
|
279
|
+
) {
|
|
280
|
+
if (this.timeout) {
|
|
281
|
+
clearTimeout(this.timeout)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// @ts-ignore
|
|
285
|
+
this.timeout = setTimeout(
|
|
286
|
+
this.handleMonthNext,
|
|
287
|
+
HOVER_TIMEOUT
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
this.dateInterval = { from: this.dateInterval.from, to: date }
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
</script>
|
|
297
|
+
<style lang="scss" scoped>
|
|
298
|
+
.dl-date-picker {
|
|
299
|
+
user-select: none;
|
|
300
|
+
padding: 0 30px;
|
|
301
|
+
|
|
302
|
+
&--day_picker,
|
|
303
|
+
&--month_picker {
|
|
304
|
+
display: flex;
|
|
305
|
+
justify-content: space-between;
|
|
306
|
+
flex-wrap: wrap;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&--calendar_from,
|
|
310
|
+
&--calendar_to {
|
|
311
|
+
width: 230px;
|
|
312
|
+
padding: 30px 0;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
</style>
|