@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,282 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="dl-month-calendar"
|
|
4
|
+
:class="{ 'dl-month-calendar-disabled': disabled }"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
class="dl-month-calendar--title"
|
|
8
|
+
:class="{ 'dl-month-calendar--title-disabled': disabled }"
|
|
9
|
+
>
|
|
10
|
+
<dl-icon
|
|
11
|
+
v-if="withLeftChevron"
|
|
12
|
+
icon="icon-dl-left-chevron"
|
|
13
|
+
class="dl-month-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-month-calendar--right-chevron"
|
|
23
|
+
size="16px"
|
|
24
|
+
:style="chevronStyle"
|
|
25
|
+
@click="$emit('next')"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="dl-month-calendar--content">
|
|
29
|
+
<div
|
|
30
|
+
v-for="month in months"
|
|
31
|
+
:key="month.name"
|
|
32
|
+
class="dl-month-calendar--month"
|
|
33
|
+
:class="{ 'dl-month-calendar--month-disabled': disabled }"
|
|
34
|
+
:style="getMonthStyle(month.value)"
|
|
35
|
+
@click="handleClick(month.value)"
|
|
36
|
+
@mouseenter="handleMouseenter(month.value)"
|
|
37
|
+
@mousedown="handleMousedown(month.value)"
|
|
38
|
+
>
|
|
39
|
+
{{ month.name }}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
46
|
+
import DlIcon from '../DlIcon.vue'
|
|
47
|
+
import { CalendarDate } from './classes/CalendarDate'
|
|
48
|
+
import { DateInterval } from './types'
|
|
49
|
+
import { Month, getMonths } from './utils'
|
|
50
|
+
import { isInRange } from './isInRange'
|
|
51
|
+
|
|
52
|
+
export default defineComponent({
|
|
53
|
+
components: {
|
|
54
|
+
DlIcon
|
|
55
|
+
},
|
|
56
|
+
model: {
|
|
57
|
+
prop: 'modelValue',
|
|
58
|
+
event: 'update:modelValue'
|
|
59
|
+
},
|
|
60
|
+
props: {
|
|
61
|
+
title: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: ''
|
|
64
|
+
},
|
|
65
|
+
availableRange: {
|
|
66
|
+
type: Object as PropType<Partial<DateInterval>>,
|
|
67
|
+
default: null
|
|
68
|
+
},
|
|
69
|
+
modelValue: {
|
|
70
|
+
type: Object as PropType<DateInterval>,
|
|
71
|
+
default: () => {
|
|
72
|
+
const date = new Date()
|
|
73
|
+
return {
|
|
74
|
+
from: date,
|
|
75
|
+
to: date
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
withLeftChevron: Boolean,
|
|
80
|
+
withRightChevron: Boolean,
|
|
81
|
+
disabled: Boolean
|
|
82
|
+
},
|
|
83
|
+
emits: [
|
|
84
|
+
'update:modelValue',
|
|
85
|
+
'change',
|
|
86
|
+
'mousedown',
|
|
87
|
+
'mouseenter',
|
|
88
|
+
'next',
|
|
89
|
+
'prev'
|
|
90
|
+
],
|
|
91
|
+
computed: {
|
|
92
|
+
months(): Month[] {
|
|
93
|
+
return getMonths()
|
|
94
|
+
},
|
|
95
|
+
chevronStyle(): Record<string, any> {
|
|
96
|
+
return this.disabled
|
|
97
|
+
? {
|
|
98
|
+
color: 'var(--dl-color-disabled)',
|
|
99
|
+
cursor: 'not-allowed'
|
|
100
|
+
}
|
|
101
|
+
: {
|
|
102
|
+
color: 'var(--dl-color-darker)',
|
|
103
|
+
cursor: 'pointer'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
methods: {
|
|
108
|
+
handleClick(value: number) {
|
|
109
|
+
const d = new CalendarDate(this.modelValue.from)
|
|
110
|
+
d.year(parseInt(this.title)).month(value).startOf('month')
|
|
111
|
+
|
|
112
|
+
if (!isInRange(this.availableRange, d)) return
|
|
113
|
+
|
|
114
|
+
const newDate = {
|
|
115
|
+
from: d.toDate(),
|
|
116
|
+
to: d.toDate()
|
|
117
|
+
}
|
|
118
|
+
this.$emit('update:modelValue', newDate)
|
|
119
|
+
this.$emit('change', newDate)
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
handleMouseenter(value: number) {
|
|
123
|
+
const d = new CalendarDate(this.modelValue.from)
|
|
124
|
+
d.year(parseInt(this.title)).month(value).startOf('month')
|
|
125
|
+
|
|
126
|
+
if (!isInRange(this.availableRange, d)) return
|
|
127
|
+
|
|
128
|
+
if (d.isBefore(new CalendarDate(this.modelValue.from), 'day'))
|
|
129
|
+
return
|
|
130
|
+
|
|
131
|
+
this.$emit('mouseenter', d.toDate())
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
handleMousedown(value: number) {
|
|
135
|
+
const d = new CalendarDate(this.modelValue.from)
|
|
136
|
+
d.year(parseInt(this.title)).month(value).startOf('month')
|
|
137
|
+
|
|
138
|
+
if (!isInRange(this.availableRange, d)) return
|
|
139
|
+
|
|
140
|
+
this.$emit('mousedown', d.toDate())
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
getMonthStyle(value: number) {
|
|
144
|
+
let style: Record<string, any> = {}
|
|
145
|
+
|
|
146
|
+
const selectedStyle = {
|
|
147
|
+
color: 'var(--dl-color-text-buttons)',
|
|
148
|
+
background: 'var(--dl-color-secondary)'
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const currentD = new CalendarDate(this.modelValue.from)
|
|
152
|
+
const d = new CalendarDate(currentD)
|
|
153
|
+
d.month(value).year(parseInt(this.title))
|
|
154
|
+
|
|
155
|
+
if (!isInRange(this.availableRange, d)) {
|
|
156
|
+
style = {
|
|
157
|
+
'border-color': 'var(--dl-color-disabled)',
|
|
158
|
+
color: 'var(--dl-color-disabled)'
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
const initialD = new CalendarDate()
|
|
162
|
+
|
|
163
|
+
const from = new CalendarDate(this.modelValue.from)
|
|
164
|
+
const to = new CalendarDate(this.modelValue.to)
|
|
165
|
+
|
|
166
|
+
const bgColor = 'var(--dl-color-secondary)'
|
|
167
|
+
const intervalOpacity = 0.3
|
|
168
|
+
|
|
169
|
+
const isInInterval =
|
|
170
|
+
d.isAfter(from, 'month') && d.isBefore(to, 'month')
|
|
171
|
+
|
|
172
|
+
const isIntervalBoundary =
|
|
173
|
+
d.isSame(from, 'month') || d.isSame(to, 'month')
|
|
174
|
+
|
|
175
|
+
if (isInInterval && this.disabled) {
|
|
176
|
+
style = {
|
|
177
|
+
...selectedStyle,
|
|
178
|
+
background: bgColor,
|
|
179
|
+
opacity: intervalOpacity
|
|
180
|
+
}
|
|
181
|
+
} else if (isInInterval) {
|
|
182
|
+
style = {
|
|
183
|
+
background: bgColor,
|
|
184
|
+
color: 'var(--dl-color-text-buttons)',
|
|
185
|
+
opacity: intervalOpacity
|
|
186
|
+
}
|
|
187
|
+
} else if (isIntervalBoundary && this.disabled) {
|
|
188
|
+
style = {
|
|
189
|
+
...style,
|
|
190
|
+
...selectedStyle,
|
|
191
|
+
opacity: 0.6
|
|
192
|
+
}
|
|
193
|
+
} else if (isIntervalBoundary) {
|
|
194
|
+
style = {
|
|
195
|
+
...style,
|
|
196
|
+
...selectedStyle
|
|
197
|
+
}
|
|
198
|
+
} else if (
|
|
199
|
+
d.isSame(initialD, 'month') &&
|
|
200
|
+
!isIntervalBoundary &&
|
|
201
|
+
this.disabled
|
|
202
|
+
) {
|
|
203
|
+
style.color = 'var(--dl-color-secondary)'
|
|
204
|
+
} else if (d.isSame(initialD, 'month') && !isIntervalBoundary) {
|
|
205
|
+
style.color = 'var(--dl-color-secondary)'
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return style
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
</script>
|
|
214
|
+
<style lang="scss" scoped>
|
|
215
|
+
.dl-month-calendar {
|
|
216
|
+
font-size: 12px;
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-direction: column;
|
|
219
|
+
width: 100%;
|
|
220
|
+
|
|
221
|
+
&--title {
|
|
222
|
+
display: flex;
|
|
223
|
+
justify-content: center;
|
|
224
|
+
align-items: center;
|
|
225
|
+
flex-wrap: nowrap;
|
|
226
|
+
font-size: 14px;
|
|
227
|
+
padding: 0 15px 20px 15px;
|
|
228
|
+
position: relative;
|
|
229
|
+
color: var(--dl-color-darker);
|
|
230
|
+
|
|
231
|
+
&-disabled {
|
|
232
|
+
color: var(--dl-color-disabled);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
&--left-chevron,
|
|
237
|
+
&--right-chevron {
|
|
238
|
+
width: 16px;
|
|
239
|
+
height: 16px;
|
|
240
|
+
position: absolute;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
&--left-chevron {
|
|
244
|
+
left: 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
&--right-chevron {
|
|
248
|
+
right: 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
&--content {
|
|
252
|
+
width: 250px;
|
|
253
|
+
display: flex;
|
|
254
|
+
flex-wrap: wrap;
|
|
255
|
+
justify-content: space-around;
|
|
256
|
+
align-items: center;
|
|
257
|
+
margin-left: -15px;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&--month {
|
|
261
|
+
color: var(--dl-color-darker);
|
|
262
|
+
border: 1px solid var(--dl-color-separator);
|
|
263
|
+
border-radius: 2px;
|
|
264
|
+
margin-left: 15px;
|
|
265
|
+
margin-bottom: 15px;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
font-size: 14px;
|
|
268
|
+
text-transform: capitalize;
|
|
269
|
+
padding: 7px 21px;
|
|
270
|
+
|
|
271
|
+
&-disabled {
|
|
272
|
+
cursor: not-allowed;
|
|
273
|
+
color: var(--dl-color-disabled);
|
|
274
|
+
border: 1px solid var(--dl-color-disabled);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.dl-month-calendar-disabled {
|
|
280
|
+
cursor: not-allowed !important;
|
|
281
|
+
}
|
|
282
|
+
</style>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { CalendarDate } from './CalendarDate'
|
|
2
|
+
|
|
3
|
+
export class Calendar {
|
|
4
|
+
private _dateTitle: string
|
|
5
|
+
private _monthTitle: string
|
|
6
|
+
private _currentDate: CalendarDate
|
|
7
|
+
private _activeDate: CalendarDate
|
|
8
|
+
private _dates: CalendarDate[] = []
|
|
9
|
+
|
|
10
|
+
constructor(date?: CalendarDate) {
|
|
11
|
+
this._currentDate = date || new CalendarDate()
|
|
12
|
+
this._activeDate = new CalendarDate(this._currentDate)
|
|
13
|
+
|
|
14
|
+
this._dateTitle = ''
|
|
15
|
+
this._monthTitle = ''
|
|
16
|
+
this._updateState()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
private _updateState() {
|
|
20
|
+
this._dateTitle = this._activeDate.format('MMMM YYYY')
|
|
21
|
+
this._monthTitle = this._activeDate.format('YYYY')
|
|
22
|
+
|
|
23
|
+
const startOfMonth = this._activeDate.clone().startOf('month')
|
|
24
|
+
const endOfMonth = this._activeDate.clone().endOf('month')
|
|
25
|
+
|
|
26
|
+
let startDate = new CalendarDate(startOfMonth.day(0))
|
|
27
|
+
|
|
28
|
+
const endDate = new CalendarDate(endOfMonth.day(6))
|
|
29
|
+
|
|
30
|
+
this._dates = []
|
|
31
|
+
|
|
32
|
+
while (startDate.isSameOrBefore(endDate)) {
|
|
33
|
+
if (
|
|
34
|
+
startDate.isSame(this._currentDate, 'day') &&
|
|
35
|
+
startDate.isSame(this._currentDate, 'month')
|
|
36
|
+
) {
|
|
37
|
+
startDate.isCurrent = true
|
|
38
|
+
} else {
|
|
39
|
+
startDate.isCurrent = false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!startDate.isSame(this._activeDate, 'month')) {
|
|
43
|
+
startDate.isDisabled = true
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this._dates.push(startDate)
|
|
47
|
+
startDate = new CalendarDate(startDate.clone().add(1, 'd'))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public get dates(): CalendarDate[] {
|
|
52
|
+
return this._dates
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get dateTitle(): string {
|
|
56
|
+
return this._dateTitle
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public set dateTitle(value: string) {
|
|
60
|
+
this._dateTitle = value
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public get monthTitle(): string {
|
|
64
|
+
return this._monthTitle
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public set monthTitle(value: string) {
|
|
68
|
+
this._monthTitle = value
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public get currentDate(): CalendarDate {
|
|
72
|
+
return this._currentDate
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public set currentDate(value: CalendarDate) {
|
|
76
|
+
this._currentDate = value
|
|
77
|
+
this._dates.forEach((date) => {
|
|
78
|
+
date.isCurrent = date.isSame(value)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get activeDate(): CalendarDate {
|
|
83
|
+
return this._activeDate
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public set activeDate(value: CalendarDate) {
|
|
87
|
+
this._activeDate = value
|
|
88
|
+
this._updateState()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public moveToNextMonth() {
|
|
92
|
+
this._activeDate.add(1, 'M').startOf('month')
|
|
93
|
+
this._updateState()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public moveToPreviousMonth() {
|
|
97
|
+
this._activeDate.subtract(1, 'M').startOf('month')
|
|
98
|
+
this._updateState()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public moveToNextYear() {
|
|
102
|
+
this._activeDate.add(1, 'y').startOf('year')
|
|
103
|
+
this._updateState()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public moveToPreviousYear() {
|
|
107
|
+
this._activeDate.subtract(1, 'y').startOf('year')
|
|
108
|
+
this._updateState()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CustomDate } from './CustomDate'
|
|
2
|
+
|
|
3
|
+
export class CalendarDate extends CustomDate {
|
|
4
|
+
public isCurrent: boolean
|
|
5
|
+
public isDisabled: boolean
|
|
6
|
+
|
|
7
|
+
constructor(date?: CalendarDate | CustomDate | Date | string) {
|
|
8
|
+
super(date)
|
|
9
|
+
this.isCurrent = false
|
|
10
|
+
this.isDisabled = false
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import moment, { DurationInputArg1, Moment } from 'moment'
|
|
2
|
+
|
|
3
|
+
export class CustomDate {
|
|
4
|
+
private _momentDate: Moment = moment()
|
|
5
|
+
|
|
6
|
+
constructor(date?: CustomDate | Moment | Date | string) {
|
|
7
|
+
if (date instanceof CustomDate) {
|
|
8
|
+
this._momentDate = date._momentDate.clone()
|
|
9
|
+
} else if (moment.isMoment(date)) {
|
|
10
|
+
this._momentDate = date.clone()
|
|
11
|
+
} else if (typeof date === 'string' || date instanceof Date) {
|
|
12
|
+
this._momentDate = moment(date)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public day(d: number | string): CustomDate
|
|
17
|
+
public day(): number
|
|
18
|
+
public day(d?: any): any {
|
|
19
|
+
if (typeof d === 'string' || typeof d === 'number') {
|
|
20
|
+
this._momentDate.day(d)
|
|
21
|
+
|
|
22
|
+
return this
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return this._momentDate.day()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public date(d: number): CustomDate
|
|
29
|
+
public date(): number
|
|
30
|
+
public date(d?: any): any {
|
|
31
|
+
if (typeof d === 'number') {
|
|
32
|
+
this._momentDate.date(d)
|
|
33
|
+
|
|
34
|
+
return this
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this._momentDate.date()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public month(M: string | number): CustomDate
|
|
41
|
+
public month(): number
|
|
42
|
+
public month(M?: any): any {
|
|
43
|
+
if (typeof M === 'string' || typeof M === 'number') {
|
|
44
|
+
this._momentDate.month(M)
|
|
45
|
+
|
|
46
|
+
return this
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return this._momentDate.month()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public year(y: number): CustomDate
|
|
53
|
+
public year(): number
|
|
54
|
+
public year(y?: any): any {
|
|
55
|
+
if (typeof y === 'number') {
|
|
56
|
+
this._momentDate.year(y)
|
|
57
|
+
|
|
58
|
+
return this
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return this._momentDate.year()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public hours(h?: number): CustomDate
|
|
65
|
+
public hours(): number
|
|
66
|
+
public hours(h?: any): any {
|
|
67
|
+
if (typeof h === 'number') {
|
|
68
|
+
this._momentDate.hours(h)
|
|
69
|
+
|
|
70
|
+
return this
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this._momentDate.hours()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public minutes(m?: number): CustomDate
|
|
77
|
+
public minutes(): number
|
|
78
|
+
public minutes(m?: any): any {
|
|
79
|
+
if (typeof m === 'number') {
|
|
80
|
+
this._momentDate.minutes(m)
|
|
81
|
+
|
|
82
|
+
return this
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this._momentDate.minutes()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public format(format?: string) {
|
|
89
|
+
return this._momentDate.format(format)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public toString() {
|
|
93
|
+
return this._momentDate.toISOString()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public startOf(unitOfTime: string) {
|
|
97
|
+
this._momentDate.startOf(unitOfTime as moment.unitOfTime.StartOf)
|
|
98
|
+
|
|
99
|
+
return this
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public endOf(unitOfTime: string) {
|
|
103
|
+
this._momentDate.endOf(unitOfTime as moment.unitOfTime.StartOf)
|
|
104
|
+
|
|
105
|
+
return this
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public add(amount: number, unitOfTime: string) {
|
|
109
|
+
this._momentDate.add(
|
|
110
|
+
amount as DurationInputArg1,
|
|
111
|
+
unitOfTime as moment.unitOfTime.DurationConstructor
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
return this
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public subtract(amount: number, unitOfTime: string) {
|
|
118
|
+
this._momentDate.subtract(
|
|
119
|
+
amount as DurationInputArg1,
|
|
120
|
+
unitOfTime as moment.unitOfTime.DurationConstructor
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
return this
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public clone() {
|
|
127
|
+
return new CustomDate(this)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public isSame(date: CustomDate, granularity?: string) {
|
|
131
|
+
return this._momentDate.isSame(
|
|
132
|
+
date._momentDate,
|
|
133
|
+
granularity as moment.unitOfTime.StartOf
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public isAfter(date: CustomDate, granularity?: string) {
|
|
138
|
+
return this._momentDate.isAfter(
|
|
139
|
+
date._momentDate,
|
|
140
|
+
granularity as moment.unitOfTime.StartOf
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public isBefore(date: CustomDate, granularity?: string) {
|
|
145
|
+
return this._momentDate.isBefore(
|
|
146
|
+
date._momentDate,
|
|
147
|
+
granularity as moment.unitOfTime.StartOf
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public isSameOrBefore(date: CustomDate, granularity?: string) {
|
|
152
|
+
return this._momentDate.isSameOrBefore(
|
|
153
|
+
date._momentDate,
|
|
154
|
+
granularity as moment.unitOfTime.StartOf
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public isSameOrAfter(date: CustomDate, granularity?: string) {
|
|
159
|
+
return this._momentDate.isSameOrAfter(
|
|
160
|
+
date._momentDate,
|
|
161
|
+
granularity as moment.unitOfTime.StartOf
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public toDate() {
|
|
166
|
+
return this._momentDate.toDate()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public static toString(date?: string) {
|
|
170
|
+
return moment(date).toISOString()
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
public static format(date?: Date | string, format?: string): string {
|
|
174
|
+
return moment(date).format(format)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public static startOf(unitOfTime: string, date?: string): CustomDate {
|
|
178
|
+
return new CustomDate(
|
|
179
|
+
moment(date).startOf(unitOfTime as moment.unitOfTime.StartOf)
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
public static endOf(unitOfTime: string, date?: string): CustomDate {
|
|
184
|
+
return new CustomDate(
|
|
185
|
+
moment(date).endOf(unitOfTime as moment.unitOfTime.StartOf)
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public static add(
|
|
190
|
+
amount: number,
|
|
191
|
+
unitOfTime: string,
|
|
192
|
+
date?: string
|
|
193
|
+
): CustomDate {
|
|
194
|
+
return new CustomDate(
|
|
195
|
+
moment(date).add(
|
|
196
|
+
amount as DurationInputArg1,
|
|
197
|
+
unitOfTime as moment.unitOfTime.DurationConstructor
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public static subtract(
|
|
203
|
+
amount: number,
|
|
204
|
+
unitOfTime: string,
|
|
205
|
+
date?: string
|
|
206
|
+
): CustomDate {
|
|
207
|
+
return new CustomDate(
|
|
208
|
+
moment(date).subtract(
|
|
209
|
+
amount as DurationInputArg1,
|
|
210
|
+
unitOfTime as moment.unitOfTime.DurationConstructor
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public static toDate(date: CustomDate) {
|
|
216
|
+
return date._momentDate.toDate()
|
|
217
|
+
}
|
|
218
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CustomDate } from './classes/CustomDate'
|
|
2
|
+
import { DateInterval } from './types'
|
|
3
|
+
|
|
4
|
+
export function isInRange(
|
|
5
|
+
range: Partial<DateInterval> | null,
|
|
6
|
+
value: CustomDate | DateInterval | null
|
|
7
|
+
): boolean {
|
|
8
|
+
const unit = 'day'
|
|
9
|
+
if (!value || !range || Object.values(range).every((key) => !key))
|
|
10
|
+
return true
|
|
11
|
+
|
|
12
|
+
const valueFrom =
|
|
13
|
+
'from' in value
|
|
14
|
+
? new CustomDate(value.from).startOf(unit)
|
|
15
|
+
: value.startOf(unit)
|
|
16
|
+
const valueTo =
|
|
17
|
+
'to' in value
|
|
18
|
+
? new CustomDate(value.to).startOf(unit)
|
|
19
|
+
: value.startOf(unit)
|
|
20
|
+
|
|
21
|
+
const rangeFrom = range.from && new CustomDate(range.from)
|
|
22
|
+
const rangeTo = range.to && new CustomDate(range.to)
|
|
23
|
+
|
|
24
|
+
if (rangeFrom && rangeTo) {
|
|
25
|
+
return (
|
|
26
|
+
valueFrom.isSameOrAfter(rangeFrom, unit) &&
|
|
27
|
+
valueTo.isSameOrBefore(rangeTo, unit)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!rangeFrom) {
|
|
32
|
+
return (
|
|
33
|
+
valueFrom.isSameOrBefore(rangeTo, unit) &&
|
|
34
|
+
valueTo.isSameOrBefore(rangeTo, unit)
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!rangeTo) {
|
|
39
|
+
return (
|
|
40
|
+
valueFrom.isSameOrAfter(rangeFrom, unit) &&
|
|
41
|
+
valueTo.isSameOrAfter(rangeFrom, unit)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|