@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,150 @@
1
+ export const colorNames = {
2
+ aliceblue: '#f0f8ff',
3
+ antiquewhite: '#faebd7',
4
+ aqua: '#00ffff',
5
+ aquamarine: '#7fffd4',
6
+ azure: '#f0ffff',
7
+ beige: '#f5f5dc',
8
+ bisque: '#ffe4c4',
9
+ black: '#000000',
10
+ blanchedalmond: '#ffebcd',
11
+ blue: '#0000ff',
12
+ blueviolet: '#8a2be2',
13
+ brown: '#a52a2a',
14
+ burlywood: '#deb887',
15
+ cadetblue: '#5f9ea0',
16
+ chartreuse: '#7fff00',
17
+ chocolate: '#d2691e',
18
+ coral: '#ff7f50',
19
+ cornflowerblue: '#6495ed',
20
+ cornsilk: '#fff8dc',
21
+ crimson: '#dc143c',
22
+ cyan: '#00ffff',
23
+ darkblue: '#00008b',
24
+ darkcyan: '#008b8b',
25
+ darkgoldenrod: '#b8860b',
26
+ darkgray: '#a9a9a9',
27
+ darkgreen: '#006400',
28
+ darkgrey: '#a9a9a9',
29
+ darkkhaki: '#bdb76b',
30
+ darkmagenta: '#8b008b',
31
+ darkolivegreen: '#556b2f',
32
+ darkorange: '#ff8c00',
33
+ darkorchid: '#9932cc',
34
+ darkred: '#8b0000',
35
+ darksalmon: '#e9967a',
36
+ darkseagreen: '#8fbc8f',
37
+ darkslateblue: '#483d8b',
38
+ darkslategray: '#2f4f4f',
39
+ darkslategrey: '#2f4f4f',
40
+ darkturquoise: '#00ced1',
41
+ darkviolet: '#9400d3',
42
+ deeppink: '#ff1493',
43
+ deepskyblue: '#00bfff',
44
+ dimgray: '#696969',
45
+ dimgrey: '#696969',
46
+ dodgerblue: '#1e90ff',
47
+ firebrick: '#b22222',
48
+ floralwhite: '#fffaf0',
49
+ forestgreen: '#228b22',
50
+ fuchsia: '#ff00ff',
51
+ gainsboro: '#dcdcdc',
52
+ ghostwhite: '#f8f8ff',
53
+ goldenrod: '#daa520',
54
+ gold: '#ffd700',
55
+ gray: '#808080',
56
+ green: '#008000',
57
+ greenyellow: '#adff2f',
58
+ grey: '#808080',
59
+ honeydew: '#f0fff0',
60
+ hotpink: '#ff69b4',
61
+ indianred: '#cd5c5c',
62
+ indigo: '#4b0082',
63
+ ivory: '#fffff0',
64
+ khaki: '#f0e68c',
65
+ lavenderblush: '#fff0f5',
66
+ lavender: '#e6e6fa',
67
+ lawngreen: '#7cfc00',
68
+ lemonchiffon: '#fffacd',
69
+ lightblue: '#add8e6',
70
+ lightcoral: '#f08080',
71
+ lightcyan: '#e0ffff',
72
+ lightgoldenrodyellow: '#fafad2',
73
+ lightgray: '#d3d3d3',
74
+ lightgreen: '#90ee90',
75
+ lightgrey: '#d3d3d3',
76
+ lightpink: '#ffb6c1',
77
+ lightsalmon: '#ffa07a',
78
+ lightseagreen: '#20b2aa',
79
+ lightskyblue: '#87cefa',
80
+ lightslategray: '#778899',
81
+ lightslategrey: '#778899',
82
+ lightsteelblue: '#b0c4de',
83
+ lightyellow: '#ffffe0',
84
+ lime: '#00ff00',
85
+ limegreen: '#32cd32',
86
+ linen: '#faf0e6',
87
+ magenta: '#ff00ff',
88
+ maroon: '#800000',
89
+ mediumaquamarine: '#66cdaa',
90
+ mediumblue: '#0000cd',
91
+ mediumorchid: '#ba55d3',
92
+ mediumpurple: '#9370db',
93
+ mediumseagreen: '#3cb371',
94
+ mediumslateblue: '#7b68ee',
95
+ mediumspringgreen: '#00fa9a',
96
+ mediumturquoise: '#48d1cc',
97
+ mediumvioletred: '#c71585',
98
+ midnightblue: '#191970',
99
+ mintcream: '#f5fffa',
100
+ mistyrose: '#ffe4e1',
101
+ moccasin: '#ffe4b5',
102
+ navajowhite: '#ffdead',
103
+ navy: '#000080',
104
+ oldlace: '#fdf5e6',
105
+ olive: '#808000',
106
+ olivedrab: '#6b8e23',
107
+ orange: '#ffa500',
108
+ orangered: '#ff4500',
109
+ orchid: '#da70d6',
110
+ palegoldenrod: '#eee8aa',
111
+ palegreen: '#98fb98',
112
+ paleturquoise: '#afeeee',
113
+ palevioletred: '#db7093',
114
+ papayawhip: '#ffefd5',
115
+ peachpuff: '#ffdab9',
116
+ peru: '#cd853f',
117
+ pink: '#ffc0cb',
118
+ plum: '#dda0dd',
119
+ powderblue: '#b0e0e6',
120
+ purple: '#800080',
121
+ rebeccapurple: '#663399',
122
+ red: '#ff0000',
123
+ rosybrown: '#bc8f8f',
124
+ royalblue: '#4169e1',
125
+ saddlebrown: '#8b4513',
126
+ salmon: '#fa8072',
127
+ sandybrown: '#f4a460',
128
+ seagreen: '#2e8b57',
129
+ seashell: '#fff5ee',
130
+ sienna: '#a0522d',
131
+ silver: '#c0c0c0',
132
+ skyblue: '#87ceeb',
133
+ slateblue: '#6a5acd',
134
+ slategray: '#708090',
135
+ slategrey: '#708090',
136
+ snow: '#fffafa',
137
+ springgreen: '#00ff7f',
138
+ steelblue: '#4682b4',
139
+ tan: '#d2b48c',
140
+ teal: '#008080',
141
+ thistle: '#d8bfd8',
142
+ tomato: '#ff6347',
143
+ turquoise: '#40e0d0',
144
+ violet: '#ee82ee',
145
+ wheat: '#f5deb3',
146
+ white: '#ffffff',
147
+ whitesmoke: '#f5f5f5',
148
+ yellow: '#ffff00',
149
+ yellowgreen: '#9acd32'
150
+ }
@@ -0,0 +1,55 @@
1
+ import { isRef, Ref } from 'vue-demi'
2
+
3
+ export function css(element: HTMLElement, css: Record<string, string>) {
4
+ const style = element.style
5
+
6
+ for (const prop in css) {
7
+ style[prop as unknown as number] = css[prop]
8
+ }
9
+ }
10
+
11
+ // internal
12
+ export function getElement(
13
+ el: HTMLElement | Ref<HTMLElement> | Element | null | string
14
+ ) {
15
+ if (el === void 0 || el === null) {
16
+ return void 0
17
+ }
18
+
19
+ if (typeof el === 'string') {
20
+ try {
21
+ return document.querySelector(el) || void 0
22
+ } catch (err) {
23
+ return void 0
24
+ }
25
+ }
26
+
27
+ const target = isRef(el) === true ? (el as Ref<HTMLElement>).value : el
28
+
29
+ if (target) {
30
+ return (target as any).$el || target
31
+ }
32
+ }
33
+
34
+ // internal
35
+ export function childHasFocus(el: HTMLElement, focusedEl: Node) {
36
+ if (el === void 0 || el === null || el.contains(focusedEl) === true) {
37
+ return true
38
+ }
39
+
40
+ for (
41
+ let next = el.nextElementSibling;
42
+ next !== null;
43
+ next = next.nextElementSibling
44
+ ) {
45
+ if (next.contains(focusedEl)) {
46
+ return true
47
+ }
48
+ }
49
+
50
+ return false
51
+ }
52
+
53
+ export default {
54
+ css
55
+ }
@@ -0,0 +1,416 @@
1
+ import { debounce } from 'lodash'
2
+
3
+ function getTargetRow(target: any) {
4
+ const elemName = target.tagName.toLowerCase()
5
+ const elemClassList = Array.from(target.classList) as string[]
6
+
7
+ if (elemName == 'tr') return target
8
+ if (elemClassList.includes('icon-dl-drag')) return target.closest('tr')
9
+ }
10
+
11
+ function removeColumnBoundaries(eventTarget: any) {
12
+ const leftSeparator = eventTarget.querySelector(
13
+ '[data-type="left-separator"]'
14
+ ) as HTMLElement
15
+ const resizeSeparator = eventTarget.querySelector(
16
+ '[data-type="resize-separator"]'
17
+ ) as HTMLElement
18
+
19
+ if (leftSeparator) {
20
+ leftSeparator.style.backgroundColor = 'transparent'
21
+ }
22
+
23
+ if (resizeSeparator) {
24
+ resizeSeparator.style.backgroundColor = 'transparent'
25
+ }
26
+ eventTarget.style.cursor = 'inherit'
27
+ }
28
+
29
+ function getMouseCoords(event: any, root?: HTMLDivElement) {
30
+ if (root) {
31
+ const rootPos = root.getBoundingClientRect()
32
+
33
+ return {
34
+ x: event.clientX - rootPos.x - 16,
35
+ y: event.clientY - rootPos.y - 8
36
+ }
37
+ }
38
+
39
+ return {
40
+ x: event.clientX,
41
+ y: event.clientY
42
+ }
43
+ }
44
+
45
+ function getStyle(target: HTMLElement, styleName: any) {
46
+ const compStyle = getComputedStyle(target)
47
+ const style = compStyle[styleName]
48
+ return style ? style : null
49
+ }
50
+
51
+ function isIntersecting(
52
+ min0: number,
53
+ max0: number,
54
+ min1: number,
55
+ max1: number
56
+ ) {
57
+ return max0 >= min1 && min0 <= max1
58
+ }
59
+
60
+ function getRows(table: HTMLTableElement) {
61
+ return table.querySelectorAll('tbody tr')
62
+ }
63
+
64
+ export function applyDraggableRows(
65
+ table: HTMLTableElement,
66
+ vm?: any,
67
+ root?: HTMLDivElement
68
+ ) {
69
+ const tbody = table.querySelector('tbody')!
70
+
71
+ let currRow: any = null
72
+ let dragElem: any = null
73
+ let oldIndex = 0
74
+ let newIndex = 0
75
+ let mouseDownX = 0
76
+ let mouseDownY = 0
77
+ let mouseX = 0
78
+ let mouseY = 0
79
+ let mouseDrag = false
80
+ let rowHeight = 0
81
+ let wasMoved = false
82
+
83
+ function bindMouse() {
84
+ table.addEventListener('mousedown', handleMouseDown)
85
+ document.addEventListener('mousemove', handleMouseMove)
86
+ document.addEventListener('mouseup', handleMouseUp)
87
+ }
88
+
89
+ function handleMouseDown(event: MouseEvent) {
90
+ if (event.button != 0) return true
91
+
92
+ const target = getTargetRow(event.target)
93
+
94
+ if (target) {
95
+ table.style.userSelect = 'none'
96
+ rowHeight = target.cells[0].getBoundingClientRect().height
97
+
98
+ currRow = target
99
+ addDraggableRow(target)
100
+
101
+ const coords = getMouseCoords(event, root)
102
+
103
+ mouseDownX = coords.x
104
+ mouseDownY = coords.y
105
+
106
+ mouseDrag = true
107
+ table.classList.add('mouse-drag')
108
+ }
109
+ }
110
+
111
+ function handleMouseMove() {
112
+ if (!mouseDrag) return
113
+
114
+ const coords = getMouseCoords(event, root)
115
+
116
+ mouseX = coords.x
117
+ mouseY = coords.y
118
+
119
+ moveRow(mouseX, mouseY)
120
+ }
121
+
122
+ function handleMouseUp() {
123
+ if (!mouseDrag) return
124
+
125
+ currRow.classList.remove('dl-table__is-dragging')
126
+ table.removeChild(dragElem)
127
+
128
+ if (oldIndex !== newIndex) vm?.emit('row-reorder', oldIndex, newIndex)
129
+
130
+ dragElem = null
131
+ mouseDrag = false
132
+ table.classList.remove('mouse-drag')
133
+ wasMoved = false
134
+
135
+ table.style.userSelect = 'auto'
136
+ }
137
+
138
+ function swapRow(row: any, index: number) {
139
+ const currIndex = Array.from(tbody.children).indexOf(currRow)
140
+ const row1 = currIndex > index ? currRow : row
141
+ const row2 = currIndex > index ? row : currRow
142
+
143
+ newIndex = index + 1
144
+ wasMoved = oldIndex !== newIndex
145
+ tbody.insertBefore(row1, row2)
146
+ }
147
+
148
+ function moveRow(x: number, y: number) {
149
+ dragElem.style.top = y + 'px'
150
+ dragElem.style.left = x + 'px'
151
+
152
+ const dPos = dragElem.getBoundingClientRect()
153
+ const currStartY = dPos.y
154
+ const currEndY = currStartY + dPos.height
155
+ const rows = getRows(table)
156
+
157
+ for (let i = 0; i < rows.length; i++) {
158
+ const rowElem = rows[i] as HTMLTableRowElement
159
+ const rowSize = rowElem.cells[0].getBoundingClientRect()
160
+ const rowStartY = rowSize.y
161
+ const rowEndY = rowStartY + rowSize.height
162
+
163
+ if (
164
+ currRow !== rowElem &&
165
+ isIntersecting(currStartY, currEndY, rowStartY, rowEndY)
166
+ ) {
167
+ if (Math.abs(currStartY - rowStartY) < rowSize.height / 2)
168
+ swapRow(rowElem, i)
169
+ }
170
+ }
171
+ }
172
+
173
+ function addDraggableRow(target: any) {
174
+ target.classList.add('dl-table__is-dragging')
175
+ dragElem = target.cloneNode(true)
176
+ oldIndex = target.rowIndex
177
+ newIndex = target.rowIndex
178
+
179
+ dragElem.classList.add('dl-table__drag')
180
+ dragElem.style.height = `${rowHeight}px`
181
+ for (let i = 0; i < target.children.length; i++) {
182
+ const oldTD = target.children[i]
183
+ const newTD = dragElem.children[i]
184
+ newTD.style.width = getStyle(oldTD, 'width')
185
+ newTD.style.height = getStyle(oldTD, 'height')
186
+ newTD.style.padding = getStyle(oldTD, 'padding')
187
+ newTD.style.margin = getStyle(oldTD, 'margin')
188
+ }
189
+
190
+ table.appendChild(dragElem)
191
+
192
+ const tPos = target.getBoundingClientRect()
193
+ const dPos = dragElem.getBoundingClientRect()
194
+ dragElem.style.bottom = dPos.y - tPos.y - tPos.height + 'px'
195
+ dragElem.style.left = '-1px'
196
+
197
+ document.dispatchEvent(
198
+ new MouseEvent('mousemove', {
199
+ view: window,
200
+ cancelable: true,
201
+ bubbles: true
202
+ })
203
+ )
204
+ }
205
+
206
+ bindMouse()
207
+
208
+ function unsubscribeEvents() {
209
+ table.removeEventListener('mousedown', handleMouseDown)
210
+ document.removeEventListener('mousemove', handleMouseMove)
211
+ document.removeEventListener('mouseup', handleMouseUp)
212
+ }
213
+
214
+ return unsubscribeEvents
215
+ }
216
+
217
+ export function applyDraggableColumns(
218
+ table: HTMLTableElement,
219
+ vm?: any,
220
+ draggableElement?: HTMLDivElement,
221
+ root?: HTMLDivElement
222
+ ) {
223
+ let colIndex: number | null = null
224
+ let newColIndex = -1
225
+ let dragElem: any = null
226
+ let mouseDownX = 0
227
+ let mouseDownY = 0
228
+ let mouseX = 0
229
+ let mouseY = 0
230
+ let mouseDrag = false
231
+ let colHeight = 0
232
+
233
+ function bindMouse() {
234
+ table.addEventListener('mousedown', handleMouseDown)
235
+ document.addEventListener('mousemove', handleMouseMove)
236
+ document.addEventListener('mouseup', handleMouseUp)
237
+ }
238
+
239
+ function handleMouseDown(event: MouseEvent) {
240
+ if (event.button != 0) return true
241
+
242
+ const target: any = getTargetCol(event.target as Element)
243
+
244
+ if (target) {
245
+ colHeight = table.getBoundingClientRect().height
246
+
247
+ colIndex = target.cellIndex
248
+ newColIndex = colIndex
249
+
250
+ if (vm.props.resizable) {
251
+ removeColumnBoundaries(target)
252
+ }
253
+ addDraggableColumn(colIndex)
254
+
255
+ const coords = getMouseCoords(event)
256
+
257
+ mouseDownX = coords.x
258
+ mouseDownY = coords.y
259
+
260
+ mouseDrag = true
261
+ // table.classList.add('mouse-drag')
262
+ }
263
+ }
264
+
265
+ function handleMouseMove(event: MouseEvent) {
266
+ if (!mouseDrag) return
267
+
268
+ const coords = getMouseCoords(event, root)
269
+
270
+ mouseX = coords.x
271
+ mouseY = coords.y
272
+
273
+ moveCol(mouseX, mouseY)
274
+ }
275
+
276
+ function handleMouseUp() {
277
+ if (!mouseDrag) return
278
+
279
+ Array.from(table.rows).forEach((row) => {
280
+ row.cells[
281
+ newColIndex === -1 ? colIndex : newColIndex
282
+ ].classList.remove('dl-table__selected')
283
+ })
284
+
285
+ vm.emit('col-reorder', colIndex, newColIndex)
286
+ table.removeChild(dragElem)
287
+
288
+ dragElem = null
289
+ mouseDrag = false
290
+ table.classList.remove('mouse-drag')
291
+ newColIndex = -1
292
+ }
293
+
294
+ function addDraggableColumn(index: number) {
295
+ dragElem = draggableElement.cloneNode()
296
+ dragElem.classList.add('dl-table__drag--col')
297
+
298
+ const tableParent = table.parentElement
299
+ const {
300
+ bottom: bottomLimit,
301
+ top: topLimit,
302
+ height
303
+ } = tableParent.getBoundingClientRect()
304
+
305
+ dragElem.style.height = `${height}px`
306
+
307
+ Array.from(table.rows).forEach((row, rowIndex) => {
308
+ const rowTop = row.getBoundingClientRect().top
309
+
310
+ if (rowIndex !== 0 && (rowTop > bottomLimit || rowTop < topLimit)) {
311
+ return
312
+ }
313
+
314
+ if (row.classList.contains('dl-tr')) {
315
+ dragElem.appendChild(row.cells[index]?.cloneNode(true) || {})
316
+
317
+ row.cells[index].classList.add('dl-table__selected')
318
+ }
319
+ })
320
+
321
+ table.appendChild(dragElem)
322
+ }
323
+
324
+ function getTargetCol(target: Element) {
325
+ if (target.classList.contains('empty-col')) return null
326
+
327
+ if (target.tagName === 'th') return target
328
+
329
+ // if a nested element in <th /> was clicked
330
+ return target.closest('th')
331
+ }
332
+
333
+ function moveCol(x: number, y: number) {
334
+ dragElem.style.top = y + 'px'
335
+ dragElem.style.left = x + 'px'
336
+
337
+ const { x: draggedColStartX } = dragElem.getBoundingClientRect()
338
+ const cols = getFirstRowCells()
339
+
340
+ let currentIndex = newColIndex
341
+
342
+ for (let i = cols.length - 1; i > newColIndex; i--) {
343
+ const col = cols[i] as HTMLTableCellElement
344
+ const { x: colStartX, width: colWidth } =
345
+ col.getBoundingClientRect()
346
+
347
+ const leftToRight = draggedColStartX >= colStartX + colWidth / 2
348
+
349
+ if (leftToRight) {
350
+ currentIndex = i
351
+ break
352
+ }
353
+ }
354
+
355
+ if (currentIndex !== newColIndex) {
356
+ moveAfter(currentIndex)
357
+ return
358
+ }
359
+
360
+ const start = vm.props.draggable === 'columns' ? 0 : 1
361
+
362
+ for (let i = start; i < newColIndex; i++) {
363
+ const col = cols[i] as HTMLTableCellElement
364
+ const { x: colStartX, width: colWidth } =
365
+ col.getBoundingClientRect()
366
+ const colEndX = colStartX + colWidth
367
+
368
+ const rightToLeft = draggedColStartX <= colEndX - colWidth / 2
369
+
370
+ if (rightToLeft) {
371
+ currentIndex = i
372
+ break
373
+ }
374
+ }
375
+
376
+ if (currentIndex !== newColIndex) {
377
+ moveBefore(currentIndex)
378
+ }
379
+ }
380
+
381
+ const moveBefore = (index: number) => {
382
+ requestAnimationFrame(() => {
383
+ Array.from(table.rows).forEach((row) => {
384
+ row.insertBefore(row.cells[newColIndex], row.cells[index])
385
+ })
386
+
387
+ newColIndex = index
388
+ })
389
+ }
390
+
391
+ const moveAfter = (index: number) => {
392
+ requestAnimationFrame(() => {
393
+ Array.from(table.rows).forEach((row) => {
394
+ row.insertBefore(row.cells[index], row.cells[newColIndex])
395
+ })
396
+
397
+ newColIndex = index
398
+ })
399
+ }
400
+
401
+ function getFirstRowCells() {
402
+ return table.rows[0].cells
403
+ }
404
+
405
+ if (table) {
406
+ bindMouse()
407
+ }
408
+
409
+ function unsubscribeEvents() {
410
+ table.removeEventListener('mousedown', handleMouseDown)
411
+ document.removeEventListener('mousemove', handleMouseMove)
412
+ document.removeEventListener('mouseup', handleMouseUp)
413
+ }
414
+
415
+ return unsubscribeEvents
416
+ }
@@ -0,0 +1,54 @@
1
+ import { isMobileOrTablet } from '.'
2
+ import { isKeyCode } from '../utils/key-composition'
3
+
4
+ const handlers: Function[] = []
5
+ let escDown: boolean
6
+
7
+ function onKeydown(evt: KeyboardEvent) {
8
+ escDown = evt.keyCode === 27
9
+ }
10
+
11
+ function onBlur() {
12
+ if (escDown === true) {
13
+ escDown = false
14
+ }
15
+ }
16
+
17
+ function onKeyup(evt: KeyboardEvent) {
18
+ if (escDown === true) {
19
+ escDown = false
20
+
21
+ if (isKeyCode(evt, 27) === true) {
22
+ handlers[handlers.length - 1](evt)
23
+ }
24
+ }
25
+ }
26
+
27
+ function update(action: string) {
28
+ (window as { [key: string]: any })[action]('keydown', onKeydown)
29
+ ;(window as { [key: string]: any })[action]('blur', onBlur)
30
+ ;(window as { [key: string]: any })[action]('keyup', onKeyup)
31
+ escDown = false
32
+ }
33
+
34
+ export function addEscapeKey(fn: Function) {
35
+ const isMobile = isMobileOrTablet()
36
+ if (!isMobile) {
37
+ handlers.push(fn)
38
+
39
+ if (handlers.length === 1) {
40
+ update('addEventListener')
41
+ }
42
+ }
43
+ }
44
+
45
+ export function removeEscapeKey(fn: Function) {
46
+ const index = handlers.indexOf(fn)
47
+ if (index > -1) {
48
+ handlers.splice(index, 1)
49
+
50
+ if (handlers.length === 0) {
51
+ update('removeEventListener')
52
+ }
53
+ }
54
+ }