@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
package/src/env.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6
+ const component: DefineComponent<{}, {}, any>
7
+ export default component
8
+ }
@@ -0,0 +1,223 @@
1
+ import {
2
+ ref,
3
+ watch,
4
+ onMounted,
5
+ onBeforeUnmount,
6
+ nextTick,
7
+ getCurrentInstance,
8
+ Ref
9
+ } from 'vue-demi'
10
+
11
+ import { addEvt, cleanEvt, prevent } from '../utils/events'
12
+ import { isKeyCode } from '../utils/key-composition'
13
+
14
+ interface AnchorEvent extends KeyboardEvent {
15
+ dlAnchorHandled?: boolean
16
+ }
17
+
18
+ export const useAnchorProps = {
19
+ target: {
20
+ default: true
21
+ },
22
+ noParentEvent: Boolean,
23
+ contextMenu: Boolean
24
+ }
25
+
26
+ export default function ({
27
+ configureAnchorEl
28
+ }: {
29
+ configureAnchorEl?: Function
30
+ }) {
31
+ const { props, proxy, emit } = getCurrentInstance()!
32
+
33
+ const anchorEl: Ref<HTMLElement | Element | null> = ref(null)
34
+
35
+ let touchTimer: number
36
+
37
+ function canShow(evt: TouchEvent) {
38
+ // abort with no parent configured or on multi-touch
39
+ return anchorEl?.value === null
40
+ ? false
41
+ : evt === void 0 ||
42
+ evt.touches === void 0 ||
43
+ evt.touches.length <= 1
44
+ }
45
+
46
+ interface AnchorElements {
47
+ hide: Function
48
+ toggle?: Function
49
+ toggleKey: Function
50
+ contextClick: Function
51
+ prevent: Function
52
+ }
53
+
54
+ const anchorEvents: Partial<AnchorElements> = {}
55
+
56
+ if (configureAnchorEl === void 0 && proxy) {
57
+ // default configureAnchorEl is designed for
58
+ // DlMenu & DlPopupProxy (which is why it's handled here)
59
+
60
+ Object.assign(anchorEvents, {
61
+ hide(evt: Event) {
62
+ // @ts-ignore
63
+ proxy.hide(evt)
64
+ },
65
+
66
+ toggle(evt: AnchorEvent) {
67
+ // @ts-ignore
68
+ proxy.toggle(evt)
69
+ evt.dlAnchorHandled = true
70
+ },
71
+
72
+ toggleKey(evt: AnchorEvent) {
73
+ if (isKeyCode(evt, 13) && anchorEvents.toggle !== void 0) {
74
+ anchorEvents.toggle(evt)
75
+ }
76
+ },
77
+
78
+ contextClick(evt: AnchorEvent) {
79
+ // @ts-ignore
80
+ proxy.hide(evt)
81
+ prevent(evt)
82
+ nextTick(() => {
83
+ // @ts-ignore
84
+ proxy.show(evt)
85
+ evt.dlAnchorHandled = true
86
+ })
87
+ },
88
+
89
+ prevent
90
+ })
91
+
92
+ configureAnchorEl = function (context = props.contextMenu) {
93
+ if (props.noParentEvent === true || anchorEl.value === null) {
94
+ return
95
+ }
96
+
97
+ let evts
98
+
99
+ if (context === true) {
100
+ evts = [
101
+ [anchorEl.value, 'mousedown', 'hide', 'passive'],
102
+ [
103
+ anchorEl.value,
104
+ 'contextmenu',
105
+ 'contextClick',
106
+ 'notPassive'
107
+ ]
108
+ ]
109
+ } else {
110
+ evts = [
111
+ [anchorEl.value, 'click', 'toggle', 'passive'],
112
+ [anchorEl.value, 'keyup', 'toggleKey', 'passive']
113
+ ]
114
+ }
115
+
116
+ addEvt(anchorEvents, 'anchor', evts as string[][])
117
+ }
118
+ }
119
+
120
+ function unconfigureAnchorEl() {
121
+ cleanEvt(anchorEvents, 'anchor')
122
+ }
123
+
124
+ function setAnchorEl(el: HTMLElement | null) {
125
+ if (!el) return
126
+ anchorEl.value = el
127
+ while (
128
+ (anchorEl.value as HTMLElement).classList.contains(
129
+ 'dl-anchor--skip'
130
+ )
131
+ ) {
132
+ anchorEl.value = (anchorEl.value as HTMLElement)
133
+ .parentNode as HTMLElement
134
+ }
135
+ if (configureAnchorEl) {
136
+ configureAnchorEl()
137
+ }
138
+ }
139
+
140
+ function pickAnchorEl() {
141
+ if (props.target === false || props.target === '') {
142
+ anchorEl.value = null
143
+ } else if (props.target === true && proxy) {
144
+ setAnchorEl(proxy.$el.parentNode as HTMLElement)
145
+ } else {
146
+ let el = props.target
147
+
148
+ if (typeof props.target === 'string') {
149
+ try {
150
+ el = document.querySelector(props.target)
151
+ } catch (err) {
152
+ el = void 0
153
+ }
154
+ }
155
+
156
+ if (el !== void 0 && el !== null) {
157
+ anchorEl.value = (el as any).$el || el // cannot use VUE type to work on both vue versions, so let it be any
158
+ if (configureAnchorEl) {
159
+ configureAnchorEl()
160
+ }
161
+ } else {
162
+ anchorEl.value = null
163
+ }
164
+ }
165
+ }
166
+
167
+ watch(
168
+ () => props.contextMenu,
169
+ (val) => {
170
+ if (anchorEl.value !== null) {
171
+ unconfigureAnchorEl()
172
+ if (configureAnchorEl) {
173
+ configureAnchorEl(val)
174
+ }
175
+ }
176
+ }
177
+ )
178
+
179
+ watch(
180
+ () => props.target,
181
+ () => {
182
+ if (anchorEl.value !== null) {
183
+ unconfigureAnchorEl()
184
+ }
185
+
186
+ pickAnchorEl()
187
+ }
188
+ )
189
+
190
+ watch(
191
+ () => props.noParentEvent,
192
+ (val) => {
193
+ if (anchorEl.value !== null) {
194
+ if (val === true) {
195
+ unconfigureAnchorEl()
196
+ } else {
197
+ if (configureAnchorEl) {
198
+ configureAnchorEl()
199
+ }
200
+ }
201
+ }
202
+ }
203
+ )
204
+
205
+ onMounted(() => {
206
+ pickAnchorEl()
207
+
208
+ if (props.modelValue === true && anchorEl.value === null) {
209
+ emit('update:modelValue', false)
210
+ }
211
+ })
212
+
213
+ onBeforeUnmount(() => {
214
+ clearTimeout(touchTimer)
215
+ unconfigureAnchorEl()
216
+ })
217
+
218
+ return {
219
+ anchorEl,
220
+ canShow,
221
+ anchorEvents
222
+ }
223
+ }
@@ -0,0 +1,181 @@
1
+ import {
2
+ watch,
3
+ nextTick,
4
+ onMounted,
5
+ getCurrentInstance,
6
+ Ref,
7
+ PropType,
8
+ isVue2
9
+ } from 'vue-demi'
10
+
11
+ const modelValueNaming = isVue2 ? 'model-value' : 'modelValue'
12
+
13
+ const staticUseModelToggleProps: any = {
14
+ modelValue: {
15
+ type: Boolean as PropType<boolean>,
16
+ default: false
17
+ }
18
+ }
19
+
20
+ staticUseModelToggleProps[`onUpdate:${modelValueNaming}`] = [Function, Array]
21
+
22
+ export const useModelToggleProps = staticUseModelToggleProps as {
23
+ modelValue: {
24
+ type: PropType<boolean>
25
+ default: boolean
26
+ }
27
+ 'onUpdate:model-value': (FunctionConstructor | ArrayConstructor)[]
28
+ }
29
+
30
+ export const useModelToggleEmits = [
31
+ 'before-show',
32
+ 'show',
33
+ 'before-hide',
34
+ 'hide',
35
+ 'update:mode-value'
36
+ ]
37
+
38
+ export interface AnchorEvent extends KeyboardEvent {
39
+ dlAnchorHandled?: boolean
40
+ }
41
+
42
+ // handleShow/handleHide -> removeTick(), self (& emit show)
43
+
44
+ export default function ({
45
+ showing,
46
+ canShow, // optional
47
+ handleShow, // optional
48
+ handleHide, // optional
49
+ processOnMount // optional
50
+ }: {
51
+ showing: Ref<boolean>
52
+ canShow: Function
53
+ handleShow: Function
54
+ handleHide: Function
55
+ processOnMount: boolean
56
+ }) {
57
+ const vm = getCurrentInstance()!
58
+ const { props, emit, proxy } = vm
59
+
60
+ let payload: AnchorEvent | undefined
61
+
62
+ function toggle(evt: AnchorEvent) {
63
+ if (showing.value === true) {
64
+ hide(evt)
65
+ } else {
66
+ show(evt)
67
+ }
68
+ }
69
+
70
+ function show(evt: AnchorEvent) {
71
+ if (
72
+ props.disabled === true ||
73
+ (evt !== void 0 && evt.dlAnchorHandled === true) ||
74
+ (canShow !== void 0 && canShow(evt) !== true)
75
+ ) {
76
+ return
77
+ }
78
+
79
+ const listener =
80
+ props[`onUpdate:${modelValueNaming}`] !== void 0 ||
81
+ (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`] !==
82
+ void 0
83
+
84
+ if (listener === true) {
85
+ emit(`update:${modelValueNaming}`, true)
86
+ payload = evt
87
+
88
+ nextTick(() => {
89
+ if (payload === evt) {
90
+ payload = void 0
91
+ }
92
+ })
93
+ }
94
+
95
+ if (!props.modelValue || listener === false) {
96
+ processShow(evt)
97
+ }
98
+ }
99
+
100
+ function processShow(evt: AnchorEvent) {
101
+ if (showing.value === true) {
102
+ return
103
+ }
104
+
105
+ showing.value = true
106
+
107
+ emit('before-show', evt)
108
+
109
+ if (handleShow !== void 0) {
110
+ handleShow(evt)
111
+ } else {
112
+ emit('show', evt)
113
+ }
114
+ }
115
+
116
+ function hide(evt: AnchorEvent) {
117
+ if (props.disabled === true) {
118
+ return
119
+ }
120
+
121
+ const listener =
122
+ props[`onUpdate:${modelValueNaming}`] !== void 0 ||
123
+ (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`] !==
124
+ void 0
125
+
126
+ if (listener === true) {
127
+ emit(`update:${modelValueNaming}`, false)
128
+ payload = evt
129
+ nextTick(() => {
130
+ if (payload === evt) {
131
+ payload = void 0
132
+ }
133
+ })
134
+ }
135
+
136
+ if (!props.modelValue || listener === false) {
137
+ processHide(evt)
138
+ }
139
+ }
140
+
141
+ function processHide(evt: AnchorEvent) {
142
+ if (!showing.value) {
143
+ return
144
+ }
145
+
146
+ showing.value = false
147
+
148
+ emit('before-hide', evt)
149
+
150
+ if (handleHide !== void 0) {
151
+ handleHide(evt)
152
+ } else {
153
+ emit('hide', evt)
154
+ }
155
+ }
156
+
157
+ function processModelChange(val: boolean) {
158
+ if (props.disabled === true && val === true) {
159
+ if (props[`onUpdate:${modelValueNaming}`] !== void 0) {
160
+ emit(`update:${modelValueNaming}`, false)
161
+ }
162
+ } else if ((val === true) !== showing.value) {
163
+ const fn = val === true ? processShow : processHide
164
+ fn(payload as AnchorEvent)
165
+ }
166
+ }
167
+
168
+ watch(() => props.modelValue as boolean, processModelChange, { deep: true })
169
+
170
+ if (processOnMount) {
171
+ onMounted(() => {
172
+ return processModelChange(props.modelValue as boolean)
173
+ })
174
+ }
175
+
176
+ // expose public methods
177
+ const publicMethods = { show, hide, toggle }
178
+ Object.assign(proxy!, publicMethods)
179
+
180
+ return publicMethods
181
+ }
@@ -0,0 +1,104 @@
1
+ import { ref, onUnmounted, Ref, ComponentInternalInstance } from 'vue-demi'
2
+
3
+ import { addFocusWaitFlag, removeFocusWaitFlag } from '../utils/focus-manager'
4
+ import { createGlobalNode, removeGlobalNode } from '../utils/global-nodes'
5
+ import { portalList } from '../utils/portal'
6
+
7
+ function isOnGlobalDialog(vm: any) {
8
+ vm = vm.parent
9
+
10
+ while (vm !== void 0 && vm !== null) {
11
+ if (vm.type.name === 'DlGlobalDialog') {
12
+ return true
13
+ }
14
+ if (vm.type.name === 'DlDialog' || vm.type.name === 'DlMenu') {
15
+ return false
16
+ }
17
+
18
+ vm = vm.parent
19
+ }
20
+
21
+ return false
22
+ }
23
+
24
+ // Warning!
25
+ // You MUST specify "inheritAttrs: false" in your component
26
+
27
+ export default function (
28
+ vm: ComponentInternalInstance | null,
29
+ innerRef: Ref<HTMLElement | null>,
30
+ checkGlobalDialog = false
31
+ ) {
32
+ // showing, including while in show/hide transition
33
+ const portalIsActive = ref(false)
34
+
35
+ const { proxy } = vm!
36
+
37
+ // showing & not in any show/hide transition
38
+ const portalIsAccessible = ref(false)
39
+
40
+ // let portalEl = null
41
+ const portalEl: any = ref(null)
42
+ const focusObj = {}
43
+ const onGlobalDialog = checkGlobalDialog === true && isOnGlobalDialog(vm)
44
+
45
+ function showPortal(isReady = false) {
46
+ if (isReady === true) {
47
+ removeFocusWaitFlag(focusObj)
48
+ portalIsAccessible.value = true
49
+ return
50
+ }
51
+
52
+ portalIsAccessible.value = false
53
+
54
+ if (portalIsActive.value === false) {
55
+ if (onGlobalDialog === false && portalEl.value === null) {
56
+ portalEl.value = createGlobalNode()
57
+ }
58
+
59
+ portalIsActive.value = true
60
+
61
+ // register portal
62
+ portalList.push(proxy!)
63
+
64
+ addFocusWaitFlag(focusObj)
65
+ }
66
+ }
67
+
68
+ function hidePortal(isReady = false) {
69
+ portalIsAccessible.value = false
70
+
71
+ if (isReady !== true) {
72
+ return
73
+ }
74
+
75
+ removeFocusWaitFlag(focusObj)
76
+ portalIsActive.value = false
77
+
78
+ // unregister portal
79
+ const index = portalList.indexOf(proxy!)
80
+ if (index > -1) {
81
+ portalList.splice(index, 1)
82
+ }
83
+
84
+ if (portalEl.value !== null) {
85
+ removeGlobalNode(portalEl.value)
86
+ portalEl.value = null
87
+ }
88
+ }
89
+
90
+ onUnmounted(() => {
91
+ hidePortal(true)
92
+ })
93
+
94
+ // expose publicly needed stuff for portal utils
95
+ Object.assign(proxy!, { __dlPortalInnerRef: innerRef })
96
+
97
+ return {
98
+ showPortal,
99
+ hidePortal,
100
+ portalEl,
101
+ portalIsActive,
102
+ portalIsAccessible
103
+ }
104
+ }
@@ -0,0 +1,53 @@
1
+ import { ref, watch, onBeforeUnmount } from 'vue-demi'
2
+
3
+ import { listenOpts } from '../utils/events'
4
+
5
+ export default function (props: any, configureScrollTarget: Function) {
6
+ const localScrollTarget = ref(null)
7
+
8
+ let scrollFn: Function | undefined
9
+
10
+ function changeScrollEvent(scrollTarget: any, fn: Function = () => {}) {
11
+ const fnProp: string = `${
12
+ fn !== void 0 ? 'add' : 'remove'
13
+ }EventListener`
14
+ const fnHandler = fn !== void 0 ? fn : scrollFn
15
+
16
+ if (scrollTarget !== window) {
17
+ scrollTarget[fnProp]('scroll', fnHandler, listenOpts.passive)
18
+ }
19
+
20
+ (window as { [key: string]: any })[fnProp](
21
+ 'scroll',
22
+ fnHandler,
23
+ listenOpts.passive
24
+ )
25
+
26
+ scrollFn = fn
27
+ }
28
+
29
+ function unconfigureScrollTarget() {
30
+ if (localScrollTarget.value !== null) {
31
+ changeScrollEvent(localScrollTarget.value as any)
32
+ localScrollTarget.value = null
33
+ }
34
+ }
35
+
36
+ const noParentEventWatcher = watch(
37
+ () => props.noParentEvent,
38
+ () => {
39
+ if (localScrollTarget.value !== null) {
40
+ unconfigureScrollTarget()
41
+ configureScrollTarget()
42
+ }
43
+ }
44
+ )
45
+
46
+ onBeforeUnmount(noParentEventWatcher)
47
+
48
+ return {
49
+ localScrollTarget,
50
+ unconfigureScrollTarget,
51
+ changeScrollEvent
52
+ }
53
+ }
@@ -0,0 +1,24 @@
1
+ import { onBeforeUnmount, onMounted, ref, Ref } from 'vue-demi'
2
+ import { isEllipsisActive } from '../utils/is-ellipsis-active'
3
+
4
+ export function useSizeObserver(elRef: Ref) {
5
+ const widthRef = ref(0)
6
+ const heightRef = ref(0)
7
+ const hasEllipsis = ref(false)
8
+ const resizeObserver = new ResizeObserver((entries) => {
9
+ for (const entry of entries) {
10
+ hasEllipsis.value = isEllipsisActive(entry.target)
11
+ widthRef.value = entry.contentRect.width
12
+ heightRef.value = entry.contentRect.height
13
+ }
14
+ })
15
+
16
+ onMounted(() => elRef.value && resizeObserver.observe(elRef.value))
17
+ onBeforeUnmount(() => elRef.value && resizeObserver.unobserve(elRef.value))
18
+
19
+ return {
20
+ widthRef,
21
+ heightRef,
22
+ hasEllipsis
23
+ }
24
+ }