@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.
Files changed (294) hide show
  1. package/.eslintrc.js +154 -0
  2. package/.prettierrc.json +7 -0
  3. package/Dockerfile +12 -0
  4. package/LICENSE +201 -0
  5. package/README.md +43 -0
  6. package/favicon.ico +0 -0
  7. package/index.html +13 -0
  8. package/index.ts +1 -0
  9. package/jest.config.js +16 -0
  10. package/jest.setup.js +59 -0
  11. package/models.ts +1 -0
  12. package/package.json +109 -0
  13. package/src/App.vue +201 -0
  14. package/src/assets/globals.scss +253 -0
  15. package/src/assets/globalsKeys.ts +28 -0
  16. package/src/components/DlAccordion/AccordionHeader.vue +148 -0
  17. package/src/components/DlAccordion/DlAccordion.vue +108 -0
  18. package/src/components/DlAccordion/index.ts +2 -0
  19. package/src/components/DlAlert.vue +227 -0
  20. package/src/components/DlAvatar.vue +99 -0
  21. package/src/components/DlBadge.vue +127 -0
  22. package/src/components/DlButton/DlButton.vue +370 -0
  23. package/src/components/DlButton/index.ts +4 -0
  24. package/src/components/DlButton/utils.ts +169 -0
  25. package/src/components/DlButtonGroup.vue +122 -0
  26. package/src/components/DlCheckbox.vue +298 -0
  27. package/src/components/DlChip/DlChip.vue +244 -0
  28. package/src/components/DlChip/index.ts +4 -0
  29. package/src/components/DlChip/utils.ts +100 -0
  30. package/src/components/DlColorPicker/DlAlpha.vue +142 -0
  31. package/src/components/DlColorPicker/DlBox.vue +75 -0
  32. package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
  33. package/src/components/DlColorPicker/DlColors.vue +139 -0
  34. package/src/components/DlColorPicker/DlHue.vue +135 -0
  35. package/src/components/DlColorPicker/DlPreview.vue +61 -0
  36. package/src/components/DlColorPicker/DlSaturation.vue +152 -0
  37. package/src/components/DlColorPicker/constants.ts +16 -0
  38. package/src/components/DlColorPicker/index.ts +20 -0
  39. package/src/components/DlColorPicker/types.ts +11 -0
  40. package/src/components/DlColorPicker/utils.ts +128 -0
  41. package/src/components/DlCounters.vue +173 -0
  42. package/src/components/DlDatePicker/DlCalendar.vue +332 -0
  43. package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
  44. package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
  45. package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
  46. package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
  47. package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
  48. package/src/components/DlDatePicker/index.ts +3 -0
  49. package/src/components/DlDatePicker/isInRange.ts +44 -0
  50. package/src/components/DlDatePicker/types.ts +4 -0
  51. package/src/components/DlDatePicker/utils.ts +39 -0
  52. package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
  53. package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
  54. package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
  55. package/src/components/DlDateTimeRange/index.ts +3 -0
  56. package/src/components/DlDateTimeRange/types.ts +42 -0
  57. package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
  58. package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
  59. package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
  60. package/src/components/DlDialogBox/index.ts +5 -0
  61. package/src/components/DlDropdownButton.vue +463 -0
  62. package/src/components/DlIcon.vue +147 -0
  63. package/src/components/DlInfoErrorMessage.vue +91 -0
  64. package/src/components/DlItem/DlItem.vue +35 -0
  65. package/src/components/DlItem/index.ts +2 -0
  66. package/src/components/DlItemSection.vue +88 -0
  67. package/src/components/DlLink/DlLink.vue +76 -0
  68. package/src/components/DlLink/index.ts +4 -0
  69. package/src/components/DlLink/utils.ts +4 -0
  70. package/src/components/DlList.vue +61 -0
  71. package/src/components/DlListItem/DlListItem.vue +205 -0
  72. package/src/components/DlListItem/index.ts +3 -0
  73. package/src/components/DlListItem/utils.ts +14 -0
  74. package/src/components/DlMenu/DlMenu.vue +438 -0
  75. package/src/components/DlMenu/index.ts +3 -0
  76. package/src/components/DlMenu/utils.ts +138 -0
  77. package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
  78. package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
  79. package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
  80. package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
  81. package/src/components/DlOptionGroup/index.ts +4 -0
  82. package/src/components/DlOptionGroup/utils.ts +40 -0
  83. package/src/components/DlPagination/DlPagination.vue +184 -0
  84. package/src/components/DlPagination/PageNavigation.vue +350 -0
  85. package/src/components/DlPagination/PaginationLegend.vue +41 -0
  86. package/src/components/DlPagination/QuickNavigation.vue +146 -0
  87. package/src/components/DlPagination/RowsSelector.vue +74 -0
  88. package/src/components/DlPagination/index.ts +3 -0
  89. package/src/components/DlPanelContainer/DlPanel.vue +213 -0
  90. package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
  91. package/src/components/DlPanelContainer/index.ts +4 -0
  92. package/src/components/DlPopup/DlPopup.vue +478 -0
  93. package/src/components/DlPopup/DraggableUpper.vue +64 -0
  94. package/src/components/DlPopup/PopupHeader.vue +129 -0
  95. package/src/components/DlPopup/index.ts +1 -0
  96. package/src/components/DlProgressBar.vue +159 -0
  97. package/src/components/DlProgressChart.vue +299 -0
  98. package/src/components/DlRadio.vue +218 -0
  99. package/src/components/DlRange/DlRange.vue +439 -0
  100. package/src/components/DlRange/utils.ts +209 -0
  101. package/src/components/DlSearch.vue +155 -0
  102. package/src/components/DlSelect/DlSelect.vue +992 -0
  103. package/src/components/DlSelect/SelectOption.vue +261 -0
  104. package/src/components/DlSelect/index.ts +4 -0
  105. package/src/components/DlSelect/utils.ts +43 -0
  106. package/src/components/DlSkeleton.vue +72 -0
  107. package/src/components/DlSlider/DlSlider.vue +243 -0
  108. package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
  109. package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
  110. package/src/components/DlSlider/components/index.ts +4 -0
  111. package/src/components/DlSlider/index.ts +3 -0
  112. package/src/components/DlSlider/sliderStyles.scss +109 -0
  113. package/src/components/DlSlider/useSlider.ts +277 -0
  114. package/src/components/DlSlider/utils.ts +7 -0
  115. package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
  116. package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
  117. package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
  118. package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
  119. package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
  120. package/src/components/DlSmartSearch/index.ts +4 -0
  121. package/src/components/DlSmartSearch/types.ts +36 -0
  122. package/src/components/DlSmartSearch/utils.ts +45 -0
  123. package/src/components/DlStepper/DlStepper.vue +196 -0
  124. package/src/components/DlStepper/DlStepperContainer.vue +55 -0
  125. package/src/components/DlStepper/DlStepperContent.vue +101 -0
  126. package/src/components/DlStepper/DlStepperFooter.vue +133 -0
  127. package/src/components/DlStepper/DlStepperHeader.vue +49 -0
  128. package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
  129. package/src/components/DlStepper/Step.ts +101 -0
  130. package/src/components/DlStepper/Stepper.ts +107 -0
  131. package/src/components/DlStepper/index.ts +7 -0
  132. package/src/components/DlStepper/interfaces.ts +11 -0
  133. package/src/components/DlSwitch.vue +280 -0
  134. package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
  135. package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
  136. package/src/components/DlTabPanels/index.ts +4 -0
  137. package/src/components/DlTabPanels/utils.ts +19 -0
  138. package/src/components/DlTable/DlTable.vue +1264 -0
  139. package/src/components/DlTable/DlTd.vue +109 -0
  140. package/src/components/DlTable/DlTh.vue +126 -0
  141. package/src/components/DlTable/DlTr.vue +44 -0
  142. package/src/components/DlTable/ResizableManager.ts +233 -0
  143. package/src/components/DlTable/dl-table-styles.scss +466 -0
  144. package/src/components/DlTable/hooks/tableActions.ts +64 -0
  145. package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
  146. package/src/components/DlTable/hooks/tableFilter.ts +42 -0
  147. package/src/components/DlTable/hooks/tablePagination.ts +197 -0
  148. package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
  149. package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
  150. package/src/components/DlTable/hooks/tableSort.ts +125 -0
  151. package/src/components/DlTable/index.ts +6 -0
  152. package/src/components/DlTable/types.ts +96 -0
  153. package/src/components/DlTabs/DlTab.vue +146 -0
  154. package/src/components/DlTabs/DlTabs.vue +192 -0
  155. package/src/components/DlTabs/TabsWrapper.vue +104 -0
  156. package/src/components/DlTabs/index.ts +4 -0
  157. package/src/components/DlTabs/types.ts +8 -0
  158. package/src/components/DlTextArea.vue +151 -0
  159. package/src/components/DlTextHolder.vue +65 -0
  160. package/src/components/DlTextInput.vue +753 -0
  161. package/src/components/DlThemeProvider.vue +41 -0
  162. package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
  163. package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
  164. package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
  165. package/src/components/DlTimePicker/index.ts +3 -0
  166. package/src/components/DlTimePicker/types.ts +4 -0
  167. package/src/components/DlTooltip.vue +456 -0
  168. package/src/components/DlTrend.vue +97 -0
  169. package/src/components/DlTypography.vue +87 -0
  170. package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
  171. package/src/components/DlVirtualScroll/index.ts +3 -0
  172. package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
  173. package/src/components/DlWidget/DlWidget.vue +50 -0
  174. package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
  175. package/src/components/DlWidget/index.ts +4 -0
  176. package/src/components/DlWidget/types.ts +6 -0
  177. package/src/components/DlWidget/utils.ts +30 -0
  178. package/src/components/index.ts +118 -0
  179. package/src/demo/DlAccordionDemo.vue +60 -0
  180. package/src/demo/DlAlertDemo.vue +54 -0
  181. package/src/demo/DlAvatarDemo.vue +43 -0
  182. package/src/demo/DlBadgeDemo.vue +65 -0
  183. package/src/demo/DlButtonDemo.vue +266 -0
  184. package/src/demo/DlCheckboxDemo.vue +50 -0
  185. package/src/demo/DlChipDemo.vue +181 -0
  186. package/src/demo/DlColorPickerDemo.vue +43 -0
  187. package/src/demo/DlCounterDemo.vue +53 -0
  188. package/src/demo/DlDateTimeRangeDemo.vue +217 -0
  189. package/src/demo/DlDialogBoxDemo.vue +175 -0
  190. package/src/demo/DlDropdownButtonDemo.vue +260 -0
  191. package/src/demo/DlIconDemo.vue +47 -0
  192. package/src/demo/DlLinkDemo.vue +23 -0
  193. package/src/demo/DlListDemo.vue +177 -0
  194. package/src/demo/DlMenuDemo.vue +524 -0
  195. package/src/demo/DlOptionGroupDemo.vue +79 -0
  196. package/src/demo/DlPaginationDemo.vue +44 -0
  197. package/src/demo/DlPanelContainerDemo.vue +221 -0
  198. package/src/demo/DlPopupDemo.vue +58 -0
  199. package/src/demo/DlProgressBarDemo.vue +22 -0
  200. package/src/demo/DlProgressChartDemo.vue +71 -0
  201. package/src/demo/DlRadioDemo.vue +35 -0
  202. package/src/demo/DlRangeDemo.vue +44 -0
  203. package/src/demo/DlSearchDemo.vue +27 -0
  204. package/src/demo/DlSelectDemo.vue +355 -0
  205. package/src/demo/DlSkeletonDemo.vue +20 -0
  206. package/src/demo/DlSliderDemo.vue +47 -0
  207. package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
  208. package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
  209. package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
  210. package/src/demo/DlStepperDemo/index.ts +5 -0
  211. package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
  212. package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
  213. package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
  214. package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
  215. package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
  216. package/src/demo/DlSwitchDemo.vue +49 -0
  217. package/src/demo/DlTableDemo.vue +475 -0
  218. package/src/demo/DlTabsDemo.vue +67 -0
  219. package/src/demo/DlTdDemo.vue +19 -0
  220. package/src/demo/DlTextAreaDemo.vue +37 -0
  221. package/src/demo/DlTextHolderDemo.vue +42 -0
  222. package/src/demo/DlTextInputDemo.vue +89 -0
  223. package/src/demo/DlThDemo.vue +32 -0
  224. package/src/demo/DlTooltipDemo.vue +60 -0
  225. package/src/demo/DlTrDemo.vue +18 -0
  226. package/src/demo/DlTrendDemo.vue +25 -0
  227. package/src/demo/DlTypographyDemo.vue +93 -0
  228. package/src/demo/DlWidgetDemo.vue +157 -0
  229. package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
  230. package/src/demo/SmartSearchDemo/schema.ts +44 -0
  231. package/src/demo/index.ts +141 -0
  232. package/src/directives/TouchPan.ts +525 -0
  233. package/src/env.d.ts +8 -0
  234. package/src/hooks/use-anchor.ts +223 -0
  235. package/src/hooks/use-model-toggle.ts +181 -0
  236. package/src/hooks/use-portal.ts +104 -0
  237. package/src/hooks/use-scroll-target.ts +53 -0
  238. package/src/hooks/use-size-observer.ts +24 -0
  239. package/src/hooks/use-suggestions.ts +355 -0
  240. package/src/hooks/use-tick.ts +32 -0
  241. package/src/hooks/use-timeout.ts +20 -0
  242. package/src/hooks/use-transition.ts +32 -0
  243. package/src/hooks/use-window-size.ts +25 -0
  244. package/src/hooks/useForm.ts +12 -0
  245. package/src/index.ts +7 -0
  246. package/src/main.ts +4 -0
  247. package/src/models.ts +4 -0
  248. package/src/types.ts +6 -0
  249. package/src/utils/calcs.ts +18 -0
  250. package/src/utils/click-outside.ts +108 -0
  251. package/src/utils/component-name-parser.ts +1 -0
  252. package/src/utils/css-color-names.ts +150 -0
  253. package/src/utils/dom.ts +55 -0
  254. package/src/utils/draggable-table.ts +416 -0
  255. package/src/utils/escape-key.ts +54 -0
  256. package/src/utils/events.ts +67 -0
  257. package/src/utils/focus-manager.ts +33 -0
  258. package/src/utils/focusout.ts +29 -0
  259. package/src/utils/format.ts +3 -0
  260. package/src/utils/getColor.ts +17 -0
  261. package/src/utils/getLighterGradient.ts +36 -0
  262. package/src/utils/getRootStyles.ts +52 -0
  263. package/src/utils/global-config.ts +6 -0
  264. package/src/utils/global-nodes.ts +42 -0
  265. package/src/utils/includes.ts +3 -0
  266. package/src/utils/index.ts +29 -0
  267. package/src/utils/inject-object-prop.ts +21 -0
  268. package/src/utils/input-sizes.ts +7 -0
  269. package/src/utils/is-ellipsis-active.ts +3 -0
  270. package/src/utils/is-in-viewport.ts +13 -0
  271. package/src/utils/is.ts +15 -0
  272. package/src/utils/key-composition.ts +17 -0
  273. package/src/utils/keyCodes.ts +12 -0
  274. package/src/utils/logger/ConsoleLogger.ts +65 -0
  275. package/src/utils/logger/ILogger.ts +8 -0
  276. package/src/utils/logger/index.ts +8 -0
  277. package/src/utils/nav-keys-constants.ts +1 -0
  278. package/src/utils/portal.ts +55 -0
  279. package/src/utils/position-engine.ts +381 -0
  280. package/src/utils/render.ts +36 -0
  281. package/src/utils/ripple.ts +7 -0
  282. package/src/utils/scroll.ts +73 -0
  283. package/src/utils/selection.ts +15 -0
  284. package/src/utils/sort.ts +7 -0
  285. package/src/utils/splitByQuotes.ts +32 -0
  286. package/src/utils/string.ts +6 -0
  287. package/src/utils/teleport.ts +14 -0
  288. package/src/utils/theme.ts +2 -0
  289. package/src/utils/vm.ts +16 -0
  290. package/storybook.js +8 -0
  291. package/tsconfig.json +44 -0
  292. package/tsconfig.node.json +8 -0
  293. package/types.ts +1 -0
  294. package/vite.config.ts +13 -0
@@ -0,0 +1,468 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ class="dl-date-time-range"
5
+ >
6
+ <dl-date-input
7
+ :text="dateInputText"
8
+ :input-style="dateInputStyle"
9
+ :disabled="disabled"
10
+ >
11
+ <dl-menu
12
+ ref="dateTimeRangeMenu"
13
+ anchor="bottom middle"
14
+ self="top middle"
15
+ :offset="[0, 5]"
16
+ :disabled="disabled"
17
+ >
18
+ <div class="dl-date-time-range--card">
19
+ <div
20
+ v-if="mode === 'multi'"
21
+ class="dl-date-time-range--card_sidebar"
22
+ >
23
+ <dl-card-sidebar
24
+ v-if="typeState === 'day'"
25
+ :options="sidebarDayOptions"
26
+ :current-option="currentSidebarOption"
27
+ @click="handleDayTypeOptionClick"
28
+ />
29
+ <dl-card-sidebar
30
+ v-else
31
+ :options="sidebarMonthOptions"
32
+ :current-option="currentSidebarOption"
33
+ @click="handleMonthTypeOptionClick"
34
+ />
35
+ </div>
36
+ <div
37
+ class="dl-date-time-range--card_content"
38
+ :style="cardContentStyles"
39
+ >
40
+ <dl-date-picker
41
+ :model-value="dateInterval"
42
+ :type="typeState"
43
+ :available-range="availableRange"
44
+ :disabled="isInputDisabled"
45
+ :normalize-calendars="normalizeCalendars"
46
+ @update:modelValue="updateDateIntervalWithAutoClose"
47
+ />
48
+ <dl-time-picker
49
+ v-if="showTime && typeState === 'day'"
50
+ :disabled="isInputDisabled"
51
+ :model-value="dateInterval"
52
+ @update:modelValue="updateDateInterval"
53
+ />
54
+ </div>
55
+ </div>
56
+ </dl-menu>
57
+ </dl-date-input>
58
+ </div>
59
+ </template>
60
+ <script lang="ts">
61
+ import { DlTimePicker } from '../DlTimePicker'
62
+ import { DateInterval } from '../DlDatePicker/types'
63
+ import DlCardSidebar from './DlCardSidebar.vue'
64
+ import {
65
+ DayTypeOption,
66
+ DAY_SIDEBAR_OPTION,
67
+ MonthTypeOption,
68
+ MONTH_SIDEBAR_OPTION
69
+ } from './types'
70
+ import { CustomDate } from '../DlDatePicker/classes/CustomDate'
71
+ import { DlDatePicker } from '../DlDatePicker'
72
+ import { CalendarDate } from '../DlDatePicker/classes/CalendarDate'
73
+ import DlDateInput from './DlDateInput.vue'
74
+ import { DlMenu } from '../DlMenu'
75
+ import { defineComponent, PropType } from 'vue-demi'
76
+ import { isInRange } from '../DlDatePicker/isInRange'
77
+ import { v4 } from 'uuid'
78
+
79
+ export default defineComponent({
80
+ components: {
81
+ DlCardSidebar,
82
+ DlDatePicker,
83
+ DlTimePicker,
84
+ DlDateInput,
85
+ DlMenu
86
+ },
87
+ model: {
88
+ prop: 'modelValue',
89
+ event: 'update:modelValue'
90
+ },
91
+ props: {
92
+ modelValue: {
93
+ type: Object as PropType<DateInterval>,
94
+ default: () => {
95
+ const date = new Date()
96
+ return {
97
+ from: date,
98
+ to: date
99
+ }
100
+ }
101
+ },
102
+ showTime: Boolean,
103
+ type: {
104
+ type: String as PropType<'day' | 'month'>,
105
+ default: 'day'
106
+ },
107
+ mode: {
108
+ type: String as PropType<'single' | 'multi'>,
109
+ default: 'single'
110
+ },
111
+ datePickerCardWidth: {
112
+ type: String,
113
+ default: '590px'
114
+ },
115
+ availableRange: {
116
+ type: Object as PropType<Partial<DateInterval> | null>,
117
+ default: null
118
+ },
119
+ withSelectedOption: Boolean,
120
+ disabled: Boolean,
121
+ autoClose: Boolean
122
+ },
123
+ emits: ['update:modelValue', 'set-type', 'change'],
124
+ data(): {
125
+ uuid: string
126
+ dateInterval: DateInterval
127
+ typeState: 'day' | 'month'
128
+ isOpen: boolean
129
+ isInputDisabled: boolean
130
+ dayTypeOptions: DayTypeOption[]
131
+ monthTypeOptions: MonthTypeOption[]
132
+ currentSidebarOption: DAY_SIDEBAR_OPTION | MONTH_SIDEBAR_OPTION
133
+ } {
134
+ const today = CustomDate.startOf('day').toDate()
135
+ const yesterday = CustomDate.subtract(1, 'day').startOf('day').toDate()
136
+ const thisMonth = CustomDate.startOf('month').toDate()
137
+ const lastMonth = CustomDate.subtract(1, 'months')
138
+ .startOf('month')
139
+ .toDate()
140
+
141
+ return {
142
+ uuid: `dl-date-time-range-${v4()}`,
143
+ dateInterval: {
144
+ from: this.modelValue.from,
145
+ to: this.modelValue.to
146
+ },
147
+ typeState: this.type,
148
+ isOpen: false,
149
+ isInputDisabled: false,
150
+ dayTypeOptions: [
151
+ {
152
+ title: 'today',
153
+ key: DAY_SIDEBAR_OPTION.today,
154
+ value: { from: today, to: today }
155
+ },
156
+ {
157
+ title: 'yesterday',
158
+ key: DAY_SIDEBAR_OPTION.yesterday,
159
+ value: { from: yesterday, to: yesterday }
160
+ },
161
+ {
162
+ title: 'last 7 days',
163
+ key: DAY_SIDEBAR_OPTION.last_7_days,
164
+ value: {
165
+ from: CustomDate.subtract(7, 'day').toDate(),
166
+ to: today
167
+ }
168
+ },
169
+ {
170
+ title: 'last 14 days',
171
+ key: DAY_SIDEBAR_OPTION.last_14_days,
172
+ value: {
173
+ from: CustomDate.subtract(14, 'day').toDate(),
174
+ to: today
175
+ }
176
+ },
177
+ {
178
+ title: 'last 30 days',
179
+ key: DAY_SIDEBAR_OPTION.last_month,
180
+ value: {
181
+ from: CustomDate.subtract(1, 'months')
182
+ .startOf('day')
183
+ .toDate(),
184
+ to: today
185
+ }
186
+ },
187
+ { title: 'custom by day', key: DAY_SIDEBAR_OPTION.custom },
188
+ {
189
+ title: 'custom by month',
190
+ key: DAY_SIDEBAR_OPTION.custom_by_month,
191
+ value: {
192
+ from: new CalendarDate(this.modelValue.from)
193
+ .startOf('month')
194
+ .toDate(),
195
+ to: new CalendarDate(this.modelValue.from)
196
+ .startOf('month')
197
+ .toDate()
198
+ }
199
+ }
200
+ ],
201
+ monthTypeOptions: [
202
+ {
203
+ title: 'this month',
204
+ key: MONTH_SIDEBAR_OPTION.this_month,
205
+ value: { from: thisMonth, to: thisMonth }
206
+ },
207
+ {
208
+ title: 'last month',
209
+ key: MONTH_SIDEBAR_OPTION.last_month,
210
+ value: { from: lastMonth, to: lastMonth }
211
+ },
212
+ {
213
+ title: 'last 3 months',
214
+ key: MONTH_SIDEBAR_OPTION.last_3_months,
215
+ value: {
216
+ from: CustomDate.subtract(3, 'months')
217
+ .startOf('month')
218
+ .toDate(),
219
+ to: today
220
+ }
221
+ },
222
+ {
223
+ title: 'last 6 months',
224
+ key: MONTH_SIDEBAR_OPTION.last_6_months,
225
+ value: {
226
+ from: CustomDate.subtract(6, 'months')
227
+ .startOf('month')
228
+ .toDate(),
229
+ to: today
230
+ }
231
+ },
232
+ {
233
+ title: 'last 12 months',
234
+ key: MONTH_SIDEBAR_OPTION.last_12_months,
235
+ value: {
236
+ from: CustomDate.subtract(1, 'year')
237
+ .startOf('month')
238
+ .toDate(),
239
+ to: today
240
+ }
241
+ },
242
+ { title: 'custom by month', key: MONTH_SIDEBAR_OPTION.custom },
243
+ {
244
+ title: 'custom by day',
245
+ key: MONTH_SIDEBAR_OPTION.custom_by_day,
246
+ value: {
247
+ from: new CalendarDate(this.modelValue.from)
248
+ .startOf('day')
249
+ .toDate(),
250
+ to: new CalendarDate(this.modelValue.from)
251
+ .startOf('day')
252
+ .toDate()
253
+ }
254
+ }
255
+ ],
256
+ currentSidebarOption: DAY_SIDEBAR_OPTION.custom
257
+ }
258
+ },
259
+ computed: {
260
+ sidebarDayOptions(): DayTypeOption[] {
261
+ return this.dayTypeOptions.map((o) => ({
262
+ ...o,
263
+ disabled: !isInRange(this.availableRange, o.value)
264
+ }))
265
+ },
266
+ sidebarMonthOptions(): MonthTypeOption[] {
267
+ return this.monthTypeOptions.map((o) => ({
268
+ ...o,
269
+ disabled: !isInRange(this.availableRange, o.value)
270
+ }))
271
+ },
272
+ dateInputStyle(): Record<string, any> {
273
+ return { width: `${this.dateInputText.length / 2}em` }
274
+ },
275
+ dateInputText(): string {
276
+ let text = ''
277
+
278
+ if (this.typeState === 'month') {
279
+ if (this.dateInterval.from !== this.dateInterval.to) {
280
+ text = `${CustomDate.format(
281
+ this.dateInterval.from,
282
+ 'MMM, YYYY'
283
+ )} - ${CustomDate.format(
284
+ this.dateInterval.to,
285
+ 'MMM, YYYY'
286
+ )}`
287
+ } else {
288
+ text = CustomDate.format(
289
+ this.dateInterval.from,
290
+ 'MMM, YYYY'
291
+ )
292
+ }
293
+ } else {
294
+ if (this.dateInterval.from !== this.dateInterval.to) {
295
+ if (this.showTime) {
296
+ text = `${CustomDate.format(
297
+ this.dateInterval.from,
298
+ 'MMM D, YYYY, HH:mm'
299
+ )} - ${CustomDate.format(
300
+ this.dateInterval.to,
301
+ 'MMM D, YYYY, HH:mm'
302
+ )}`
303
+ } else {
304
+ text = `${CustomDate.format(
305
+ this.dateInterval.from,
306
+ 'MMM D, YYYY'
307
+ )} - ${CustomDate.format(
308
+ this.dateInterval.to,
309
+ 'MMM D, YYYY'
310
+ )}`
311
+ }
312
+ } else {
313
+ if (this.showTime) {
314
+ text = CustomDate.format(
315
+ this.dateInterval.from,
316
+ 'MMM D, YYYY, HH:mm'
317
+ )
318
+ } else {
319
+ text = CustomDate.format(
320
+ this.dateInterval.from,
321
+ 'MMM D, YYYY'
322
+ )
323
+ }
324
+ }
325
+ }
326
+
327
+ if (this.mode === 'multi' && this.withSelectedOption) {
328
+ let title = ''
329
+ if (this.typeState === 'month') {
330
+ const option = this.monthTypeOptions.find(
331
+ (option) => option.key === this.currentSidebarOption
332
+ )
333
+ title = option ? option.title : MONTH_SIDEBAR_OPTION.custom
334
+ } else {
335
+ const option = this.dayTypeOptions.find(
336
+ (option) => option.key === this.currentSidebarOption
337
+ )
338
+ title = option ? option.title : DAY_SIDEBAR_OPTION.custom
339
+ }
340
+ text = `${title.slice(0, 1).toUpperCase()}${title.slice(
341
+ 1
342
+ )}: ${text}`
343
+ }
344
+
345
+ return text
346
+ },
347
+ normalizeCalendars(): boolean {
348
+ return ![
349
+ DAY_SIDEBAR_OPTION.custom,
350
+ DAY_SIDEBAR_OPTION.custom_by_month,
351
+ MONTH_SIDEBAR_OPTION.custom_by_day
352
+ ].includes(this.currentSidebarOption as any)
353
+ },
354
+ cardContentStyles(): Record<string, any> {
355
+ return {
356
+ '--card-content-width': this.datePickerCardWidth
357
+ }
358
+ }
359
+ },
360
+ watch: {
361
+ type(value: 'day' | 'month') {
362
+ this.typeState = value
363
+
364
+ const date = new CustomDate(this.modelValue.from)
365
+ .startOf(value)
366
+ .toDate()
367
+
368
+ this.updateDateInterval({
369
+ from: date,
370
+ to: date
371
+ })
372
+ },
373
+ mode(value: 'single' | 'multi') {
374
+ if (value === 'single') {
375
+ this.currentSidebarOption = DAY_SIDEBAR_OPTION.custom
376
+ this.isInputDisabled = false
377
+ }
378
+ },
379
+ availableRange: {
380
+ handler() {
381
+ this.currentSidebarOption =
382
+ this.typeState === 'day'
383
+ ? DAY_SIDEBAR_OPTION.custom
384
+ : MONTH_SIDEBAR_OPTION.custom
385
+ this.updateDateInterval({
386
+ from: this.modelValue.from,
387
+ to: this.modelValue.to
388
+ })
389
+ },
390
+ deep: true
391
+ }
392
+ },
393
+ methods: {
394
+ handleTypeChange(value: 'day' | 'month') {
395
+ this.isInputDisabled = false
396
+ this.currentSidebarOption =
397
+ value === 'day'
398
+ ? DAY_SIDEBAR_OPTION.custom
399
+ : MONTH_SIDEBAR_OPTION.custom
400
+
401
+ this.typeState = value
402
+ this.$emit('set-type', value)
403
+ },
404
+ updateDateInterval(value: DateInterval) {
405
+ this.dateInterval = value
406
+ this.$emit('update:modelValue', value)
407
+ this.$emit('change', value)
408
+ },
409
+ updateDateIntervalWithAutoClose(value: DateInterval) {
410
+ this.updateDateInterval(value)
411
+
412
+ if (this.autoClose) {
413
+ const dateTimeRangeMenu = this.$refs[
414
+ 'dateTimeRangeMenu'
415
+ ] as unknown as {
416
+ hide: () => void
417
+ }
418
+ dateTimeRangeMenu.hide()
419
+ }
420
+ },
421
+ handleDayTypeOptionClick(option: DayTypeOption) {
422
+ this.currentSidebarOption = option.key as DAY_SIDEBAR_OPTION
423
+ this.isInputDisabled = option.key !== DAY_SIDEBAR_OPTION.custom
424
+
425
+ if (option.disabled || option.key === DAY_SIDEBAR_OPTION.custom) {
426
+ return
427
+ }
428
+
429
+ if (option.key === DAY_SIDEBAR_OPTION.custom_by_month) {
430
+ this.handleTypeChange('month')
431
+ }
432
+
433
+ this.updateDateInterval(option.value)
434
+ },
435
+ handleMonthTypeOptionClick(option: MonthTypeOption) {
436
+ this.currentSidebarOption = option.key as MONTH_SIDEBAR_OPTION
437
+ this.isInputDisabled = option.key !== MONTH_SIDEBAR_OPTION.custom
438
+
439
+ if (option.disabled || option.key === MONTH_SIDEBAR_OPTION.custom) {
440
+ return
441
+ }
442
+
443
+ if (option.key === MONTH_SIDEBAR_OPTION.custom_by_day) {
444
+ this.handleTypeChange('day')
445
+ }
446
+
447
+ this.updateDateInterval(option.value)
448
+ }
449
+ }
450
+ })
451
+ </script>
452
+ <style lang="scss" scoped>
453
+ .dl-date-time-range {
454
+ display: flex;
455
+ justify-content: center;
456
+
457
+ &--card {
458
+ background-color: var(--dl-color-bg);
459
+ z-index: 1;
460
+ display: flex;
461
+ border-radius: 2px;
462
+ }
463
+
464
+ &--card_content {
465
+ width: var(--card-content-width);
466
+ }
467
+ }
468
+ </style>
@@ -0,0 +1,3 @@
1
+ import DlDateTimeRange from './DlDateTimeRange.vue'
2
+
3
+ export { DlDateTimeRange }
@@ -0,0 +1,42 @@
1
+ import { DateInterval } from '../DlDatePicker/types'
2
+
3
+ export const DAY_SIDEBAR_OPTION = {
4
+ today: 'today',
5
+ yesterday: 'yesterday',
6
+ last_7_days: 'last_7_days',
7
+ last_14_days: 'last_14_days',
8
+ last_month: 'last_month',
9
+ whole_period: 'whole_period',
10
+ custom: 'custom',
11
+ custom_by_month: 'custom_by_month'
12
+ } as const
13
+
14
+ export type DAY_SIDEBAR_OPTION =
15
+ typeof DAY_SIDEBAR_OPTION[keyof typeof DAY_SIDEBAR_OPTION]
16
+
17
+ export const MONTH_SIDEBAR_OPTION = {
18
+ this_month: 'this_month',
19
+ last_month: 'last_month',
20
+ last_3_months: 'last_3_months',
21
+ last_6_months: 'last_6_months',
22
+ last_12_months: 'last_12_months',
23
+ custom: 'custom',
24
+ custom_by_day: 'custom_by_day'
25
+ } as const
26
+
27
+ export type MONTH_SIDEBAR_OPTION =
28
+ typeof MONTH_SIDEBAR_OPTION[keyof typeof MONTH_SIDEBAR_OPTION]
29
+
30
+ export type DayTypeOption = {
31
+ title: string
32
+ key: DAY_SIDEBAR_OPTION
33
+ value?: DateInterval
34
+ disabled?: boolean
35
+ }
36
+
37
+ export type MonthTypeOption = {
38
+ title: string
39
+ key: MONTH_SIDEBAR_OPTION
40
+ value?: DateInterval
41
+ disabled?: boolean
42
+ }
@@ -0,0 +1,196 @@
1
+ <template>
2
+ <transition name="fade">
3
+ <div
4
+ v-if="show"
5
+ :id="uuid"
6
+ :style="cssVars"
7
+ class="root-wrapper"
8
+ >
9
+ <div
10
+ class="backdrop"
11
+ @click.stop.prevent="volatile ? closeModal() : ''"
12
+ />
13
+ <div
14
+ class="dialog-wrapper"
15
+ :style="{ maxWidth: `${width}px` }"
16
+ :class="{ 'dialog-wrapper--fullscreen': fullscreen }"
17
+ >
18
+ <div
19
+ v-if="hasHeader"
20
+ class="header"
21
+ >
22
+ <slot name="header" />
23
+ </div>
24
+ <div
25
+ class="content"
26
+ :class="{ 'content--fullscreen': fullscreen }"
27
+ >
28
+ <slot name="body" />
29
+ </div>
30
+ <div
31
+ v-if="hasFooter"
32
+ class="footer"
33
+ >
34
+ <slot name="footer" />
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </transition>
39
+ </template>
40
+
41
+ <script lang="ts">
42
+ import { v4 } from 'uuid'
43
+ import { defineComponent } from 'vue-demi'
44
+
45
+ export default defineComponent({
46
+ name: 'DlDialogBox',
47
+ model: {
48
+ prop: 'modelValue',
49
+ event: 'update:modelValue'
50
+ },
51
+ props: {
52
+ width: { type: Number, default: 400 },
53
+ fullscreen: Boolean,
54
+ modelValue: Boolean,
55
+ volatile: { type: Boolean, default: false }
56
+ },
57
+ emits: ['update:modelValue', 'hide', 'show'],
58
+ data() {
59
+ return {
60
+ uuid: `dl-dialog-box-${v4()}`,
61
+ show: this.modelValue
62
+ }
63
+ },
64
+ computed: {
65
+ cssVars(): Record<string, string> {
66
+ return {
67
+ '--dl-backdrop-color': this.hasParent
68
+ ? 'transparent'
69
+ : 'rgba(0, 0, 0, 0.4)'
70
+ }
71
+ },
72
+ hasParent(): boolean {
73
+ const parentClassList = (this?.$el?.parentNode as HTMLElement)
74
+ ?.classList
75
+ return parentClassList?.contains('content')
76
+ },
77
+ hasHeader(): boolean {
78
+ return !!this.$slots.header
79
+ },
80
+ hasFooter(): boolean {
81
+ return !!this.$slots.footer
82
+ }
83
+ },
84
+ watch: {
85
+ modelValue(newVal: boolean) {
86
+ if (newVal) {
87
+ this.openModal()
88
+ } else {
89
+ this.closeModal()
90
+ }
91
+ }
92
+ },
93
+ methods: {
94
+ closeModal() {
95
+ if ((this.$el as HTMLElement)?.blur) {
96
+ (this.$el as HTMLElement).blur()
97
+ }
98
+ this.show = false
99
+ this.$emit('hide')
100
+ this.$emit('update:modelValue', false)
101
+ if (!this.hasParent) {
102
+ document.documentElement.style.overflow = 'auto'
103
+ }
104
+ },
105
+ openModal() {
106
+ this.show = true
107
+ this.$emit('show')
108
+ this.$emit('update:modelValue', true)
109
+ if (!this.hasParent) {
110
+ document.documentElement.style.overflow = 'hidden'
111
+ }
112
+ }
113
+ }
114
+ })
115
+ </script>
116
+
117
+ <style lang="scss" scoped>
118
+ .root-wrapper {
119
+ position: fixed;
120
+ top: 0;
121
+ right: 0;
122
+ bottom: 0;
123
+ left: 0;
124
+ z-index: var(--dl-z-index-menu);
125
+ overflow-x: hidden;
126
+ overflow-y: hidden;
127
+ text-align: start;
128
+ display: flex;
129
+ justify-content: center;
130
+ align-items: center;
131
+ }
132
+
133
+ .backdrop {
134
+ position: fixed;
135
+ top: 0;
136
+ right: 0;
137
+ bottom: 0;
138
+ left: 0;
139
+ background-color: var(--dl-backdrop-color);
140
+ z-index: var(--dl-z-index-menu);
141
+ }
142
+
143
+ .dialog-wrapper {
144
+ position: relative;
145
+ width: 100%;
146
+ background-color: var(--dl-color-panel-background);
147
+ border: 1px solid var(--dl-color-separator);
148
+ color: var(--dl-color-darker);
149
+ border-radius: 2px;
150
+ display: flex;
151
+ flex-direction: column;
152
+ z-index: var(--dl-z-index-menu);
153
+ max-height: 100vh;
154
+
155
+ &--fullscreen {
156
+ margin: 0;
157
+ width: 100vw;
158
+ height: 100vh;
159
+ max-width: 100vw !important;
160
+ border-radius: 0px;
161
+ }
162
+ }
163
+
164
+ .header {
165
+ display: flex;
166
+ padding: 16px;
167
+ border-bottom: 1px solid var(--dl-color-separator);
168
+ }
169
+
170
+ .content {
171
+ padding: 10px 16px 30px 16px;
172
+ overflow: auto;
173
+
174
+ &--fullscreen {
175
+ flex-grow: 1;
176
+ }
177
+ }
178
+
179
+ .footer {
180
+ display: flex;
181
+ padding: 20px 16px;
182
+ border-top: 1px solid var(--dl-color-separator);
183
+ }
184
+
185
+ .fade {
186
+ &-enter-active,
187
+ &-leave-active {
188
+ transition: opacity 0.2s;
189
+ }
190
+
191
+ &-enter,
192
+ &-leave-to {
193
+ opacity: 0;
194
+ }
195
+ }
196
+ </style>