@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,109 @@
1
+ <template>
2
+ <td
3
+ :class="classes"
4
+ :style="styles"
5
+ >
6
+ <div
7
+ ref="tableTd"
8
+ class="dl-table-cell-inner-div"
9
+ >
10
+ <dl-tooltip v-if="hasEllipsis">
11
+ <slot />
12
+ </dl-tooltip>
13
+ <slot />
14
+ </div>
15
+ </td>
16
+ </template>
17
+
18
+ <script lang="ts">
19
+ import { defineComponent, getCurrentInstance, computed, ref } from 'vue-demi'
20
+ import { getColor } from '../../utils'
21
+ import { DlTooltip } from '../'
22
+ import { useSizeObserver } from '../../hooks/use-size-observer'
23
+
24
+ export default defineComponent({
25
+ name: 'DlTd',
26
+ components: {
27
+ DlTooltip
28
+ },
29
+ props: {
30
+ props: { type: Object, default: () => {} },
31
+ autoWidth: Boolean,
32
+ noHover: Boolean,
33
+ bgColor: {
34
+ type: String,
35
+ default: ''
36
+ }
37
+ },
38
+ setup(props) {
39
+ const vm = getCurrentInstance()
40
+
41
+ const tableTd = ref(null)
42
+
43
+ const { hasEllipsis } = useSizeObserver(tableTd)
44
+
45
+ const hasOptionalProps = computed(() => {
46
+ return props.props !== void 0
47
+ })
48
+
49
+ const tdClasses = computed(() => {
50
+ let classNames = 'dl-td'
51
+
52
+ if (props.autoWidth) {
53
+ classNames = classNames.concat(' dl-table--col-auto-width')
54
+ }
55
+
56
+ if (props.noHover) {
57
+ classNames = classNames.concat(' dl-td--no-hover')
58
+ }
59
+
60
+ return classNames
61
+ })
62
+
63
+ const tdStyles = computed(() => {
64
+ let styles = ''
65
+
66
+ if (props.bgColor) {
67
+ styles = styles.concat(
68
+ `background: ${getColor(props.bgColor, '')}`
69
+ )
70
+ }
71
+ return styles
72
+ })
73
+
74
+ const column = computed(() => {
75
+ const name = vm.vnode.key as string
76
+
77
+ return (
78
+ (props.props.colsMap !== void 0
79
+ ? props.props.colsMap[name]
80
+ : null) || props.props.col
81
+ )
82
+ })
83
+
84
+ if (!hasOptionalProps.value) {
85
+ return {
86
+ classes: tdClasses,
87
+ styles: tdStyles,
88
+ tableTd,
89
+ hasEllipsis
90
+ }
91
+ }
92
+
93
+ if (column.value === void 0) {
94
+ return
95
+ }
96
+
97
+ const { row } = props.props
98
+
99
+ return {
100
+ classes: tdClasses.value + column.value.tdClass(row),
101
+ styles: tdStyles.value + column.value.tdStyle(row),
102
+ tableTd,
103
+ hasEllipsis
104
+ }
105
+ }
106
+ })
107
+ </script>
108
+
109
+ <style scoped src="./dl-table-styles.scss" lang="scss" />
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <th
3
+ :style="headerStyle"
4
+ :class="thClasses"
5
+ @click="onClick"
6
+ >
7
+ <div
8
+ ref="tableTh"
9
+ class="dl-table-cell-inner-div"
10
+ >
11
+ <dl-icon
12
+ v-if="isSortable && align === 'right'"
13
+ :class="iconClass"
14
+ icon="icon-dl-arrow-up"
15
+ />
16
+ <dl-tooltip v-if="hasEllipsis">
17
+ <slot />
18
+ </dl-tooltip>
19
+ <slot />
20
+ <dl-icon
21
+ v-if="isSortable && ['left', 'center'].includes(align)"
22
+ :class="iconClass"
23
+ icon="icon-dl-arrow-up"
24
+ />
25
+ </div>
26
+ </th>
27
+ </template>
28
+
29
+ <script lang="ts">
30
+ import { defineComponent, getCurrentInstance, computed, ref } from 'vue-demi'
31
+ import { useSizeObserver } from '../../hooks/use-size-observer'
32
+ import DlIcon from '../DlIcon.vue'
33
+ import DlTooltip from '../DlTooltip.vue'
34
+
35
+ export default defineComponent({
36
+ name: 'DlTh',
37
+ components: {
38
+ DlIcon,
39
+ DlTooltip
40
+ },
41
+ props: {
42
+ props: { type: Object, default: () => {} },
43
+ autoWidth: Boolean
44
+ },
45
+ emits: ['click'],
46
+
47
+ setup(props, { emit }) {
48
+ const vm = getCurrentInstance()
49
+ const tableTh = ref(null)
50
+
51
+ const { hasEllipsis } = useSizeObserver(tableTh)
52
+
53
+ const onClickFn = (event: Event) => {
54
+ emit('click', event)
55
+ }
56
+
57
+ const hasOptionalProps = computed(() => {
58
+ return !!Object.keys(props.props ?? {})
59
+ })
60
+
61
+ const column = computed(() => {
62
+ let col: any
63
+ const name = vm.vnode.key as string
64
+ if (name) {
65
+ col = props.props?.colsMap[name]
66
+ } else {
67
+ col = props?.props?.col
68
+ }
69
+
70
+ return col
71
+ })
72
+
73
+ if (!column.value) {
74
+ return {
75
+ headerStyle: '',
76
+ thClasses: '',
77
+ isSortable: false,
78
+ hasEllipsis: false,
79
+ onClick: onClickFn
80
+ }
81
+ }
82
+
83
+ const thClasses = computed(() => {
84
+ let className = ''
85
+
86
+ if (props.autoWidth) {
87
+ className = 'dl-table--col-auto-width'
88
+ }
89
+
90
+ if (column.value.thClass) {
91
+ className = className.concat(' ' + column.value.thClass)
92
+ }
93
+
94
+ return className
95
+ })
96
+
97
+ const handleClick = (evt: Event) => {
98
+ if (column.value.sortable) {
99
+ const sort = props.props?.sort as Function
100
+ sort(column.value)
101
+ }
102
+ onClickFn(evt)
103
+ }
104
+
105
+ const onClick = !hasOptionalProps.value ? onClickFn : handleClick
106
+
107
+ const state = {
108
+ isSortable: !hasOptionalProps.value
109
+ ? false
110
+ : column?.value?.sortable ?? false,
111
+ thClasses,
112
+ align: column?.value?.align ?? 'left',
113
+ iconClass: column?.value?.iconClass ?? null,
114
+ hasOptionalProps,
115
+ headerStyle: column.value.headerStyle ?? '',
116
+ tableTh,
117
+ hasEllipsis,
118
+ onClick
119
+ }
120
+
121
+ return state
122
+ }
123
+ })
124
+ </script>
125
+
126
+ <style scoped src="./dl-table-styles.scss" lang="scss" />
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <tr
3
+ :class="trClasses"
4
+ v-bind="$attrs"
5
+ v-on="$listeners"
6
+ >
7
+ <slot />
8
+ </tr>
9
+ </template>
10
+
11
+ <script lang="ts">
12
+ import { defineComponent } from 'vue-demi'
13
+
14
+ export default defineComponent({
15
+ name: 'DlTr',
16
+ props: {
17
+ props: { type: Object, default: () => {} },
18
+ noHover: Boolean
19
+ },
20
+ computed: {
21
+ trClasses(): string {
22
+ let classes = 'dl-tr'
23
+
24
+ if (
25
+ this.$props.props?.header // header slot
26
+ ) {
27
+ return classes
28
+ }
29
+
30
+ if (this.$props.props?._trClass) {
31
+ classes = classes.concat(' ' + this.$props.props._trClass)
32
+ }
33
+
34
+ if (this.$props.props?.noHover || this.$props.noHover) {
35
+ classes = classes.concat(' dl-tr--no-hover')
36
+ }
37
+
38
+ return classes
39
+ }
40
+ }
41
+ })
42
+ </script>
43
+
44
+ <style scoped src="./dl-table-styles.scss" lang="scss" />
@@ -0,0 +1,233 @@
1
+ interface Options {
2
+ minColWidth?: number
3
+ width?: number
4
+ cursor?: string
5
+ color: string
6
+ resizingColor?: string
7
+ }
8
+
9
+ const DEFAULT_SEPARTOR_WIDTH = 1
10
+ const DEFAULT_MIN_COL_WIDTH = 16
11
+ const DEFAULT_RESIZING_COLOR = 'var(--dl-color-medium)'
12
+ const DEFAULT_COLOR = 'var(--dl-color-lighter)'
13
+ const DEFAULT_CURSOR = 'ew-resize'
14
+
15
+ const INNER_DIV_CLASS = 'dl-table-cell-inner-div'
16
+
17
+ export class ResizableManager {
18
+ private _table: HTMLTableElement
19
+ private _currentColumn: HTMLTableCellElement | null = null
20
+ private _thInnerDiv: HTMLDivElement = null
21
+ private _columnIndex: number = 0
22
+ private _tdInnerDivs: HTMLElement[] = []
23
+ private _resizing: boolean = false
24
+ private _options: Options = {
25
+ minColWidth: DEFAULT_MIN_COL_WIDTH,
26
+ width: DEFAULT_SEPARTOR_WIDTH,
27
+ cursor: DEFAULT_CURSOR,
28
+ color: DEFAULT_COLOR,
29
+ resizingColor: DEFAULT_RESIZING_COLOR
30
+ }
31
+
32
+ private _colEvents: any[] = []
33
+ private _separators: HTMLDivElement[] = []
34
+
35
+ private _onMouseMoveFn = this._onMouseMove.bind(this)
36
+ private _onMouseUpFn = this._onMouseUp.bind(this)
37
+
38
+ private _onMouseMove(e: MouseEvent) {
39
+ requestAnimationFrame(() => {
40
+ if (!this._currentColumn || !this._thInnerDiv) return
41
+
42
+ const padding = this._paddingDiff(this._currentColumn)
43
+ const { x } = this._currentColumn.getBoundingClientRect()
44
+ const newWidth = e.clientX - x - padding
45
+
46
+ if (newWidth <= this._options.minColWidth) return
47
+
48
+ this._thInnerDiv.style.width = newWidth + 'px'
49
+
50
+ this._tdInnerDivs.forEach((div) => {
51
+ div.style.width = newWidth + 'px'
52
+ })
53
+ })
54
+ }
55
+
56
+ private _paddingDiff(col: HTMLElement) {
57
+ const padLeft = this._getStyleVal(col, 'padding-left')
58
+ const padRight = this._getStyleVal(col, 'padding-right')
59
+ return parseInt(padLeft) + parseInt(padRight)
60
+ }
61
+
62
+ private _getStyleVal(elm: HTMLElement, css: string) {
63
+ return window.getComputedStyle(elm, null).getPropertyValue(css)
64
+ }
65
+
66
+ private _onMouseUp(e: MouseEvent) {
67
+ e.stopPropagation()
68
+
69
+ this._resizing = false
70
+
71
+ this._removeColumnBoundaries(this._currentColumn)
72
+
73
+ document.removeEventListener('mousemove', this._onMouseMoveFn)
74
+ document.removeEventListener('mouseup', this._onMouseUpFn)
75
+ }
76
+
77
+ private _removeColumnBoundaries(eventTarget: any) {
78
+ const leftSeparator = eventTarget.querySelector(
79
+ '[data-type="left-separator"]'
80
+ ) as HTMLElement
81
+ const resizeSeparator = eventTarget.querySelector(
82
+ '[data-type="resize-separator"]'
83
+ ) as HTMLElement
84
+
85
+ leftSeparator.style.backgroundColor = 'transparent'
86
+ resizeSeparator.style.backgroundColor = 'transparent'
87
+ eventTarget.style.cursor = 'inherit'
88
+ }
89
+
90
+ private _onMouseDown = (e: MouseEvent) => {
91
+ this._resizing = true
92
+
93
+ e.stopPropagation()
94
+ const eventTarget = e.target as HTMLDivElement
95
+ eventTarget.style.backgroundColor = this._options.resizingColor
96
+
97
+ this._currentColumn = eventTarget!
98
+ .parentElement! as HTMLTableCellElement
99
+ this._thInnerDiv = this._currentColumn.querySelector(
100
+ `.${INNER_DIV_CLASS}`
101
+ )
102
+
103
+ this._columnIndex = Number(eventTarget.getAttribute('data-index')!)
104
+ this._tdInnerDivs = this._table!.querySelectorAll(
105
+ `tbody > tr > td:nth-of-type(${
106
+ this._columnIndex + 1
107
+ }) > .${INNER_DIV_CLASS}`
108
+ )! as unknown as HTMLDivElement[]
109
+
110
+ document.addEventListener('mousemove', this._onMouseMoveFn)
111
+ document.addEventListener('mouseup', this._onMouseUpFn)
112
+ }
113
+
114
+ private _onMouseEnter(e: any) {
115
+ if (this._resizing === true) return
116
+
117
+ const leftSeparator = e.target.querySelector(
118
+ '[data-type="left-separator"]'
119
+ ) as HTMLElement
120
+ const resizeSeparator = e.target.querySelector(
121
+ '[data-type="resize-separator"]'
122
+ ) as HTMLElement
123
+
124
+ leftSeparator.style.backgroundColor = this._options.color
125
+ resizeSeparator.style.backgroundColor = this._options.color
126
+ e.target.style.cursor = 'pointer'
127
+ }
128
+
129
+ private _onMouseLeave = (e: any) => {
130
+ if (this._resizing === true) return
131
+
132
+ this._removeColumnBoundaries(e.target)
133
+ }
134
+
135
+ private _createResizeSeparator(height: number, index: number) {
136
+ const div = document.createElement('div')
137
+ div.style.top = '0px'
138
+ div.style.right = '0px'
139
+ div.style.width = this._options.width + 'px'
140
+ div.style.position = 'absolute'
141
+ div.style.cursor = this._options.cursor
142
+ div.style.userSelect = 'none'
143
+ div.style.height = height + 'px'
144
+ div.setAttribute('data-index', index.toString())
145
+ div.setAttribute('data-type', 'resize-separator')
146
+
147
+ return div
148
+ }
149
+
150
+ private _createLeftSeparator(height: number) {
151
+ const div = document.createElement('div')
152
+ div.style.top = '0px'
153
+ div.style.left = '0px'
154
+ div.style.width = this._options.width + 'px'
155
+ div.style.position = 'absolute'
156
+ div.style.userSelect = 'none'
157
+ div.style.height = height + 'px'
158
+ div.setAttribute('data-type', 'left-separator')
159
+
160
+ return div
161
+ }
162
+
163
+ public addResizeCapability(
164
+ table: HTMLTableElement,
165
+ options: Partial<Options> = {}
166
+ ) {
167
+ this._options = {
168
+ ...this._options,
169
+ ...options
170
+ }
171
+ this._table = table
172
+ const tableHeight = table.offsetHeight
173
+ const cols = table.querySelectorAll('thead > tr:first-of-type > th')
174
+
175
+ for (let i = 0; i < cols.length - 1; i++) {
176
+ const column = cols[i]
177
+
178
+ if ((column as HTMLElement).dataset.resizable === 'false') {
179
+ continue
180
+ }
181
+
182
+ (column as HTMLElement).style.position = 'relative'
183
+
184
+ const resizeSeparator = this._createResizeSeparator(tableHeight, i)
185
+ column.appendChild(resizeSeparator)
186
+ resizeSeparator.addEventListener(
187
+ 'mousedown',
188
+ this._onMouseDown.bind(this)
189
+ )
190
+
191
+ const leftSeparator = this._createLeftSeparator(tableHeight)
192
+ column.appendChild(leftSeparator)
193
+
194
+ this._separators.push(resizeSeparator, leftSeparator)
195
+
196
+ const onMouseEnterFn = this._onMouseEnter.bind(this)
197
+ column.addEventListener('mouseenter', onMouseEnterFn)
198
+ this._colEvents.push({
199
+ column,
200
+ type: 'mouseenter',
201
+ evt: onMouseEnterFn
202
+ })
203
+
204
+ const onMouseLeaveFn = this._onMouseLeave.bind(this)
205
+ column.addEventListener('mouseleave', onMouseLeaveFn)
206
+ this._colEvents.push({
207
+ column,
208
+ type: 'mouseleave',
209
+ evt: onMouseLeaveFn
210
+ })
211
+ }
212
+ }
213
+
214
+ public updateResizersHeight(height: number) {
215
+ this._separators.forEach((el) => {
216
+ el.style.height = height + 'px'
217
+ })
218
+ }
219
+
220
+ public removeResizeCapability() {
221
+ this._separators.forEach((separator) => {
222
+ separator.remove()
223
+ })
224
+
225
+ this._colEvents.forEach(({ column, type, evt }) => {
226
+ (column as HTMLElement).style.position = 'inherit'
227
+ column.removeEventListener(type, evt)
228
+ })
229
+
230
+ this._currentColumn = null
231
+ this._separators = []
232
+ }
233
+ }