@dataloop-ai/components 0.18.0 → 0.18.2

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 (277) hide show
  1. package/package.json +6 -3
  2. package/src/App.vue +5 -227
  3. package/src/assets/constants.scss +2 -1
  4. package/src/assets/globals.scss +21 -0
  5. package/src/components/basic/DlAccordion/DlAccordion.vue +26 -4
  6. package/src/components/basic/DlAccordion/components/AccordionHeader.vue +2 -1
  7. package/src/components/basic/DlAvatar/DlAvatar.vue +1 -1
  8. package/src/components/basic/DlButton/DlButton.vue +115 -25
  9. package/src/components/basic/DlButton/utils.ts +45 -2
  10. package/src/components/basic/DlChip/DlChip.vue +3 -7
  11. package/src/components/basic/DlChip/utils.ts +4 -4
  12. package/src/components/basic/DlContainer/DlContainer.vue +70 -0
  13. package/src/components/basic/DlContainer/index.ts +3 -0
  14. package/src/components/basic/DlEmptyState/DlEmptyState.vue +282 -0
  15. package/src/components/basic/DlEmptyState/index.ts +2 -0
  16. package/src/components/basic/DlEmptyState/types.ts +20 -0
  17. package/src/components/basic/DlGrid/DlGrid.vue +163 -0
  18. package/src/components/basic/DlGrid/index.ts +4 -0
  19. package/src/components/basic/DlGrid/types.ts +5 -0
  20. package/src/components/basic/DlKpi/components/KpiInfo.vue +2 -1
  21. package/src/components/basic/DlListItem/DlListItem.vue +96 -66
  22. package/src/components/basic/DlListItem/utils.ts +0 -3
  23. package/src/components/basic/DlPanelContainer/DlPanelContainer.vue +37 -13
  24. package/src/components/basic/DlPopup/DlPopup.vue +58 -11
  25. package/src/components/basic/DlPopup/components/PopupHeader.vue +11 -6
  26. package/src/components/basic/DlProgressChart/DlProgressChart.vue +2 -1
  27. package/src/components/basic/DlWidget/DlWidget.vue +273 -141
  28. package/src/components/basic/DlWidget/index.ts +1 -3
  29. package/src/components/basic/DlWidget/utils.ts +90 -8
  30. package/src/components/basic/index.ts +4 -2
  31. package/src/components/basic/types.ts +2 -0
  32. package/src/components/compound/DlCard/DlCard.vue +796 -0
  33. package/src/components/compound/DlCard/components/DescriptionModal.vue +137 -0
  34. package/src/components/compound/DlCard/types.ts +38 -0
  35. package/src/components/compound/DlCharts/charts/DlBarChart/DlBarChart.vue +39 -4
  36. package/src/components/compound/DlCharts/charts/DlColumnChart/DlColumnChart.vue +128 -36
  37. package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +167 -87
  38. package/src/components/compound/DlCharts/charts/DlConfusionMatrix/utils.ts +2 -1
  39. package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChart.vue +44 -3
  40. package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChartWidget.vue +1 -2
  41. package/src/components/compound/DlCharts/charts/DlDoughnutChart/components/DlDoughnutChartLegend.vue +9 -18
  42. package/src/components/compound/DlCharts/charts/DlLineChart/DlLineChart.vue +48 -9
  43. package/src/components/compound/DlCharts/charts/DlScatterChart/DlScatterChart.vue +667 -0
  44. package/src/components/compound/DlCharts/charts/DlScatterChart/index.ts +2 -0
  45. package/src/components/compound/DlCharts/charts/index.ts +1 -0
  46. package/src/components/compound/DlCharts/components/DlBrush.vue +3 -2
  47. package/src/components/compound/DlCharts/components/DlChartLabels.vue +2 -1
  48. package/src/components/compound/DlCharts/components/DlChartScrollBar.vue +1 -0
  49. package/src/components/compound/DlCharts/types/props.ts +5 -1
  50. package/src/components/compound/DlCharts/utils.ts +1 -1
  51. package/src/components/compound/DlCodeEditor/DlCodeEditor.vue +173 -0
  52. package/src/components/compound/DlCodeEditor/README.md +11 -0
  53. package/src/components/compound/DlCodeEditor/components/CodeEditor.vue +705 -0
  54. package/src/components/compound/DlCodeEditor/index.ts +3 -0
  55. package/src/components/compound/DlCodeEditor/styles/themes-base16.css +12809 -0
  56. package/src/components/compound/DlCodeEditor/styles/themes.css +3999 -0
  57. package/src/components/compound/DlCodeEditor/types.ts +21 -0
  58. package/src/components/compound/DlDateTime/DlDatePicker/DlDatePicker.vue +9 -1
  59. package/src/components/compound/DlDateTime/DlDatePicker/components/DlCalendar.vue +4 -2
  60. package/src/components/compound/DlDateTime/DlDatePicker/components/DlMonthCalendar.vue +2 -1
  61. package/src/components/compound/DlDateTime/DlDateTimeRange/{DlCardSidebar.vue → CardSidebar.vue} +10 -11
  62. package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeRange.vue +18 -9
  63. package/src/components/compound/DlDateTime/DlTimePicker/DlTimePicker.vue +2 -2
  64. package/src/components/compound/DlDialogBox/DlDialogBox.vue +74 -15
  65. package/src/components/compound/DlDialogBox/components/DlDialogBoxFooter.vue +1 -1
  66. package/src/components/compound/DlDialogBox/components/DlDialogBoxHeader.vue +9 -7
  67. package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +13 -4
  68. package/src/components/compound/DlInput/DlInput.vue +80 -17
  69. package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +42 -219
  70. package/src/components/compound/DlOptionGroup/DlOptionGroup.vue +16 -17
  71. package/src/components/compound/DlOptionGroup/components/MenuItemWrapper.vue +2 -2
  72. package/src/components/compound/DlPagination/DlPagination.vue +1 -1
  73. package/src/components/compound/DlPagination/components/PaginationLegend.vue +0 -2
  74. package/src/components/compound/DlPagination/components/RowsSelector.vue +0 -2
  75. package/src/components/compound/DlRange/DlRange.vue +3 -2
  76. package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +12 -5
  77. package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +413 -97
  78. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchFilters.vue +4 -1
  79. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +100 -39
  80. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSuggestionsDropdown.vue +12 -7
  81. package/src/components/compound/DlSearches/DlSmartSearch/components/FiltersQuery.vue +5 -6
  82. package/src/components/compound/DlSearches/DlSmartSearch/types.ts +14 -0
  83. package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +10 -6
  84. package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +172 -48
  85. package/src/components/compound/DlSelect/DlSelect.vue +264 -130
  86. package/src/components/compound/DlSelect/utils.ts +4 -1
  87. package/src/components/compound/DlSlider/DlSlider.vue +10 -2
  88. package/src/components/compound/DlSlider/components/DlSliderBase.vue +3 -3
  89. package/src/components/compound/DlSlider/components/DlSliderInput.vue +17 -26
  90. package/src/components/compound/DlSlider/sliderStyles.scss +5 -1
  91. package/src/components/compound/DlSlider/useSlider.ts +2 -2
  92. package/src/components/compound/DlSlider/utils.ts +2 -2
  93. package/src/components/compound/DlStepper/DlStepper.vue +46 -4
  94. package/src/components/compound/DlStepper/components/DlStepperContent.vue +6 -2
  95. package/src/components/compound/DlStepper/components/DlStepperFooter.vue +12 -0
  96. package/src/components/compound/DlStepper/components/DlStepperSidebar.vue +24 -11
  97. package/src/components/compound/DlStepper/models/Step.ts +37 -8
  98. package/src/components/compound/DlStepper/models/Stepper.ts +108 -15
  99. package/src/components/compound/DlStepper/models/interfaces.ts +2 -1
  100. package/src/components/compound/DlTable/DlTable.vue +49 -14
  101. package/src/components/compound/DlTable/components/DlTd.vue +9 -9
  102. package/src/components/compound/DlTable/components/DlTh.vue +3 -2
  103. package/src/components/compound/DlTable/hooks/tableColumnSelection.ts +35 -40
  104. package/src/components/compound/DlTable/hooks/tableFilter.ts +33 -21
  105. package/src/components/compound/DlTable/hooks/tablePagination.ts +18 -18
  106. package/src/components/compound/DlTable/hooks/tableRowExpand.ts +2 -1
  107. package/src/components/compound/DlTable/hooks/tableRowSelection.ts +0 -1
  108. package/src/components/compound/DlTable/hooks/tableSort.ts +52 -47
  109. package/src/components/compound/DlTable/styles/dl-table-styles.scss +8 -0
  110. package/src/components/compound/DlTabs/DlTabs.vue +83 -31
  111. package/src/components/compound/DlTabs/components/DlTab.vue +14 -4
  112. package/src/components/compound/DlTabs/components/TabsWrapper.vue +32 -27
  113. package/src/components/compound/DlThumbnailGallery/DlThumbnailGallery.vue +268 -0
  114. package/src/components/compound/DlThumbnailGallery/index.ts +2 -0
  115. package/src/components/compound/DlThumbnailGallery/types.ts +11 -0
  116. package/src/components/compound/DlToast/api/useToast.ts +42 -1
  117. package/src/components/compound/DlToast/components/ToastComponent.vue +24 -32
  118. package/src/components/compound/DlToast/types.ts +52 -0
  119. package/src/components/compound/DlTreeTable/DlTreeTable.vue +1293 -0
  120. package/src/components/compound/DlTreeTable/components/DlTdTree.vue +119 -0
  121. package/src/components/compound/DlTreeTable/components/DlTrTree.vue +52 -0
  122. package/src/components/compound/DlTreeTable/index.ts +3 -0
  123. package/src/components/compound/DlTreeTable/types.ts +1 -0
  124. package/src/components/compound/DlTreeTable/utils/convertToNestedObject.ts +51 -0
  125. package/src/components/compound/DlTreeTable/utils/flatTreeData.ts +19 -0
  126. package/src/components/compound/DlTreeTable/utils/getFromChildren.ts +39 -0
  127. package/src/components/compound/DlTreeTable/utils/trSpacing.ts +13 -0
  128. package/src/components/compound/DlTreeTable/utils/treeTableRowSelection.ts +184 -0
  129. package/src/components/compound/index.ts +14 -1
  130. package/src/components/compound/types.ts +2 -0
  131. package/src/components/essential/DlBadge/DlBadge.vue +3 -3
  132. package/src/components/essential/DlCheckbox/DlCheckbox.vue +10 -7
  133. package/src/components/essential/DlEllipsis/DlEllipsis.vue +141 -0
  134. package/src/components/essential/DlIcon/DlIcon.vue +5 -5
  135. package/src/components/essential/DlLabel/DlLabel.vue +190 -0
  136. package/src/components/essential/DlLabel/index.ts +2 -0
  137. package/src/components/essential/DlList/DlList.vue +3 -3
  138. package/src/components/essential/DlMenu/DlMenu.vue +41 -22
  139. package/src/components/essential/DlMenu/utils.ts +8 -7
  140. package/src/components/essential/DlPageLayout/DlPageLayout.vue +90 -0
  141. package/src/components/essential/DlPageLayout/index.ts +2 -0
  142. package/src/components/essential/DlProgressBar/DlProgressBar.vue +1 -1
  143. package/src/components/essential/DlRadio/DlRadio.vue +10 -5
  144. package/src/components/essential/DlSeparator/DlSeparator.vue +2 -2
  145. package/src/components/essential/DlSpinner/index.ts +1 -13
  146. package/src/components/essential/DlSpinner/styles/spinnerStyles.scss +7 -0
  147. package/src/components/essential/DlSwitch/DlSwitch.vue +6 -3
  148. package/src/components/essential/DlTextArea/DlTextArea.vue +212 -7
  149. package/src/components/essential/DlThemeProvider/DlThemeProvider.vue +6 -0
  150. package/src/components/essential/DlTypography/DlTypography.vue +7 -1
  151. package/src/components/essential/index.ts +3 -2
  152. package/src/components/shared/DlInfoErrorMessage/DlInfoErrorMessage.vue +1 -1
  153. package/src/components/{essential → shared}/DlTooltip/DlTooltip.vue +26 -19
  154. package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +106 -43
  155. package/src/components/shared/DlVirtualScroll/useVirtualScroll.ts +28 -4
  156. package/src/components/shared/index.ts +1 -0
  157. package/src/components/types.ts +2 -0
  158. package/src/demos/BarChartDemo.vue +59 -2
  159. package/src/demos/ColumnChartDemo.vue +67 -2
  160. package/src/demos/DlAccordionDemo.vue +92 -43
  161. package/src/demos/DlAlertDemo.vue +14 -0
  162. package/src/demos/DlButtonDemo.vue +41 -4
  163. package/src/demos/DlCardDemo.vue +156 -19
  164. package/src/demos/DlChartDoughnutDemo.vue +49 -2
  165. package/src/demos/DlCheckboxDemo.vue +28 -3
  166. package/src/demos/DlCodeEditor/DlCodeEditorDemo.vue +247 -0
  167. package/src/demos/DlCodeEditor/index.ts +2 -0
  168. package/src/demos/DlConfusionMatrixDemo.vue +93 -37
  169. package/src/demos/DlDemoPage.vue +235 -0
  170. package/src/demos/DlDialogBoxDemo.vue +56 -51
  171. package/src/demos/DlDropdownButtonDemo.vue +35 -27
  172. package/src/demos/DlEmptyStateDemo.vue +81 -0
  173. package/src/demos/DlGridDemo.vue +40 -0
  174. package/src/demos/DlInputDemo.vue +21 -1
  175. package/src/demos/DlJsonEditorDemo.vue +59 -0
  176. package/src/demos/DlLabelDemo.vue +208 -0
  177. package/src/demos/DlLineChartDemo.vue +50 -2
  178. package/src/demos/DlListDemo.vue +12 -9
  179. package/src/demos/DlMenuDemo.vue +147 -20
  180. package/src/demos/DlPageLayoutDemo.vue +146 -0
  181. package/src/demos/DlPanelContainerDemo.vue +113 -2
  182. package/src/demos/DlPopupDemo.vue +82 -1
  183. package/src/demos/DlRadioDemo.vue +16 -1
  184. package/src/demos/DlScatterChartDemo.vue +161 -0
  185. package/src/demos/DlSearchDemo.vue +9 -0
  186. package/src/demos/DlSelectDemo.vue +124 -27
  187. package/src/demos/DlSpinnerDemo.vue +0 -2
  188. package/src/demos/DlStepperDemo/DlStepperDemo.vue +5 -1
  189. package/src/demos/DlStepperDemo/EmptyStateStepper.vue +149 -0
  190. package/src/demos/DlStepperDemo/SimpleStepper.vue +4 -0
  191. package/src/demos/DlStepperDemo/steps/GeneralStep.vue +1 -0
  192. package/src/demos/DlSwitchDemo.vue +12 -0
  193. package/src/demos/DlTableDemo.vue +84 -5
  194. package/src/demos/DlTabsDemo.vue +92 -3
  195. package/src/demos/DlTextAreaDemo.vue +14 -17
  196. package/src/demos/DlThumbnailGalleryDemo.vue +99 -0
  197. package/src/demos/DlToastDemo.vue +3 -9
  198. package/src/demos/DlTooltipDemo.vue +66 -2
  199. package/src/demos/DlTreeTableDemo.vue +694 -0
  200. package/src/demos/DlVirtualScrollDemo.vue +3 -12
  201. package/src/demos/DlWidgetDemo.vue +252 -61
  202. package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +151 -32
  203. package/src/demos/index.ts +23 -4
  204. package/src/hooks/use-anchor.ts +15 -17
  205. package/src/hooks/use-arrow-navigation.ts +64 -21
  206. package/src/hooks/use-model-toggle.ts +14 -16
  207. package/src/hooks/use-portal.ts +9 -3
  208. package/src/hooks/use-scroll-target.ts +2 -4
  209. package/src/hooks/use-size-observer.ts +3 -2
  210. package/src/hooks/use-suggestions.ts +239 -49
  211. package/src/hooks/use-transition.ts +10 -4
  212. package/src/index.ts +22 -1
  213. package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetFooter.vue +78 -0
  214. package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetHeader.vue +22 -0
  215. package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetLeftDrawer.vue +96 -0
  216. package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetMainContent.vue +51 -0
  217. package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetRightDrawer.vue +88 -0
  218. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/ActionsMenu.vue +70 -0
  219. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/AutomationMenu.vue +106 -0
  220. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardView.vue +101 -0
  221. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardViewGallery.vue +141 -0
  222. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardViewTable.vue +193 -0
  223. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/EmptyState/LayoutEmptyState.vue +227 -0
  224. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/EmptyState/UploadData.vue +106 -0
  225. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/MainContentImages.vue +540 -0
  226. package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/MainContentNav.vue +329 -0
  227. package/src/layouts/DlDatasetBrowser/DemoComponents/NavbarKpi.vue +84 -0
  228. package/src/layouts/DlDatasetBrowser/DemoComponents/NavbarSearch.vue +132 -0
  229. package/src/layouts/DlDatasetBrowser/DemoComponents/SearchFilterMenu.vue +19 -0
  230. package/src/layouts/DlDatasetBrowser/DemoComponents/filters/AddFilter.vue +212 -0
  231. package/src/layouts/DlDatasetBrowser/DemoComponents/types/imageMetadata.ts +28 -0
  232. package/src/layouts/DlDatasetBrowser/DlDatasetBrowser.vue +42 -0
  233. package/src/layouts/DlStudioLayout/DlStudioLayout.vue +42 -0
  234. package/src/layouts/DlStudioLayout/components/Demo/LeftMenuContent.vue +23 -0
  235. package/src/layouts/DlStudioLayout/components/Demo/StudioFooter.vue +25 -0
  236. package/src/layouts/DlStudioLayout/components/Demo/StudioHeader.vue +121 -0
  237. package/src/layouts/DlStudioLayout/components/Demo/StudioLeftDrawer.vue +245 -0
  238. package/src/layouts/DlStudioLayout/components/Demo/StudioMainContent.vue +31 -0
  239. package/src/layouts/DlStudioLayout/components/Demo/StudioTabsMenu.vue +117 -0
  240. package/src/layouts/DlStudioLayout/components/Demo/TabMenu/FilterMenu.vue +62 -0
  241. package/src/layouts/DlStudioLayout/components/Demo/TabMenu/TabMenuAnnotations.vue +98 -0
  242. package/src/layouts/DlStudioLayout/components/Demo/TabMenu/TabMenuItem.vue +66 -0
  243. package/src/layouts/DlStudioLayout/components/LayoutNavbar.vue +24 -0
  244. package/src/layouts/DlStudioLayout/components/ListAutocomplete.vue +149 -0
  245. package/src/layouts/DlStudioLayout/components/NavigationDrawer.vue +147 -0
  246. package/src/layouts/DlStudioLayout/index.ts +2 -0
  247. package/src/layouts/DlStudioLayout/types/HorizontalItems.ts +9 -0
  248. package/src/layouts/DlStudioLayout/types/VerticalItems.ts +10 -0
  249. package/src/simple-code-editor.d.ts +1 -0
  250. package/src/utils/click-outside.ts +1 -1
  251. package/src/utils/dom.ts +5 -5
  252. package/src/utils/events.ts +3 -3
  253. package/src/utils/global-nodes.ts +2 -2
  254. package/src/utils/input-sizes.ts +5 -2
  255. package/src/utils/is-ellipsis-active.ts +4 -1
  256. package/src/utils/parse-smart-query.ts +209 -111
  257. package/src/utils/portal.ts +5 -5
  258. package/src/utils/position-engine.ts +7 -7
  259. package/src/utils/render.ts +1 -1
  260. package/src/utils/scroll.ts +2 -2
  261. package/src/utils/selection.ts +3 -3
  262. package/vite.config.ts +9 -1
  263. package/src/components/basic/DlCard/DlCard.vue +0 -241
  264. package/src/components/basic/DlCard/types.ts +0 -20
  265. package/src/components/basic/DlEllipsis/DlEllipsis.vue +0 -114
  266. package/src/components/basic/DlWidget/DlGrid.vue +0 -33
  267. package/src/components/basic/DlWidget/DlGridRow.vue +0 -32
  268. package/src/components/compound/DlSearches/DlSmartSearch/utils/utils.ts +0 -124
  269. package/src/components/compound/DlToast/utils/config.ts +0 -17
  270. package/src/components/essential/DlTextHolder/DlTextHolder.vue +0 -65
  271. package/src/components/essential/DlTextHolder/index.ts +0 -2
  272. package/src/demos/DlTextHolderDemo.vue +0 -42
  273. package/src/utils/swapNodes.ts +0 -30
  274. /package/src/components/{basic → compound}/DlCard/index.ts +0 -0
  275. /package/src/components/compound/DlDateTime/DlDateTimeRange/{DlDateInput.vue → DateInput.vue} +0 -0
  276. /package/src/components/{basic → essential}/DlEllipsis/index.ts +0 -0
  277. /package/src/components/{essential → shared}/DlTooltip/index.ts +0 -0
@@ -15,15 +15,24 @@ interface AnchorEvent extends KeyboardEvent {
15
15
  dlAnchorHandled?: boolean
16
16
  }
17
17
 
18
+ interface AnchorElements {
19
+ hide: Function
20
+ toggle?: Function
21
+ toggleKey: Function
22
+ contextClick: Function
23
+ prevent: Function
24
+ }
25
+
18
26
  export const useAnchorProps = {
19
27
  target: {
28
+ type: [String, Boolean],
20
29
  default: true
21
30
  },
22
31
  noParentEvent: Boolean,
23
32
  contextMenu: Boolean
24
33
  }
25
34
 
26
- export default function ({
35
+ export default function useAnchor({
27
36
  configureAnchorEl
28
37
  }: {
29
38
  configureAnchorEl?: Function
@@ -38,22 +47,12 @@ export default function ({
38
47
  // abort with no parent configured or on multi-touch
39
48
  return anchorEl?.value === null
40
49
  ? 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
50
+ : !evt || !evt.touches || evt.touches.length <= 1
52
51
  }
53
52
 
54
53
  const anchorEvents: Partial<AnchorElements> = {}
55
54
 
56
- if (configureAnchorEl === void 0 && proxy) {
55
+ if (!configureAnchorEl && proxy) {
57
56
  // default configureAnchorEl is designed for
58
57
  // DlMenu & DlPopupProxy (which is why it's handled here)
59
58
 
@@ -70,7 +69,7 @@ export default function ({
70
69
  },
71
70
 
72
71
  toggleKey(evt: AnchorEvent) {
73
- if (isKeyCode(evt, 13) && anchorEvents.toggle !== void 0) {
72
+ if (isKeyCode(evt, 13) && anchorEvents.toggle) {
74
73
  anchorEvents.toggle(evt)
75
74
  }
76
75
  },
@@ -144,16 +143,15 @@ export default function ({
144
143
  setAnchorEl(proxy.$el.parentNode as HTMLElement)
145
144
  } else {
146
145
  let el = props.target
147
-
148
146
  if (typeof props.target === 'string') {
149
147
  try {
150
148
  el = document.querySelector(props.target)
151
149
  } catch (err) {
152
- el = void 0
150
+ el = null
153
151
  }
154
152
  }
155
153
 
156
- if (el !== void 0 && el !== null) {
154
+ if (el) {
157
155
  anchorEl.value = (el as any).$el || el // cannot use VUE type to work on both vue versions, so let it be any
158
156
  if (configureAnchorEl) {
159
157
  configureAnchorEl()
@@ -1,41 +1,84 @@
1
- import { ref, onMounted, onBeforeUnmount } from 'vue-demi'
1
+ import { ref, isRef, onMounted, onBeforeUnmount, computed } from 'vue-demi'
2
+
3
+ type ItemType = Record<string, any> | string
2
4
 
3
5
  export function useArrowNavigation(items: any, isOpen: any) {
4
- const selectedItem = ref(null)
5
- const highlightedIndex = ref(-1)
6
+ const selectItem = ref<ItemType | null>(null)
7
+ const highlightIndex = ref<number>(-1)
8
+
9
+ const itemsData = computed(() => (isRef(items) ? items.value : items))
10
+ const isMenuOpen = computed(() => (isRef(isOpen) ? isOpen.value : isOpen))
6
11
 
7
- const handleArrowUp = () => {
8
- if (highlightedIndex.value > 0) {
9
- highlightedIndex.value--
12
+ const selectedItem = computed({
13
+ get: () => selectItem.value,
14
+ set: (value: ItemType) => {
15
+ selectItem.value = value
10
16
  }
11
- }
12
- const handleArrowDown = () => {
13
- if (highlightedIndex.value < items.value.length - 1) {
14
- highlightedIndex.value++
17
+ })
18
+ const highlightedIndex = computed({
19
+ get: () => highlightIndex.value,
20
+ set: (value: number) => {
21
+ highlightIndex.value = value
15
22
  }
23
+ })
24
+
25
+ const itemsLength = computed<number>(() => itemsData.value.length)
26
+
27
+ const decrementHighlightedIndex = (): void => {
28
+ highlightedIndex.value -= 1
16
29
  }
17
- const handleEnter = () => {
18
- if (
30
+ const incrementHighlightedIndex = (): void => {
31
+ highlightedIndex.value += 1
32
+ }
33
+ const resetHighlightedIndex = (): void => {
34
+ highlightedIndex.value = -1
35
+ }
36
+
37
+ const isEligibleToHandleEnter = computed<boolean>(() => {
38
+ return (
19
39
  highlightedIndex.value >= 0 &&
20
- highlightedIndex.value < items.value.length
21
- ) {
22
- selectedItem.value = items.value[highlightedIndex.value]
23
- resetNavigation()
40
+ highlightedIndex.value < itemsLength.value
41
+ )
42
+ })
43
+ const isEligibleToIncrementHighlightedIndex = computed<boolean>(() => {
44
+ return highlightedIndex.value < itemsLength.value - 1
45
+ })
46
+ const isEligibleToDecrementHighlightedIndex = computed<boolean>(() => {
47
+ return highlightedIndex.value > 0
48
+ })
49
+ const isNotEligibleToHandleArrows = computed<boolean>(() => {
50
+ return !itemsLength.value || !isMenuOpen.value
51
+ })
52
+
53
+ const handleArrowUp = (event: KeyboardEvent) => {
54
+ event.preventDefault()
55
+ if (isEligibleToDecrementHighlightedIndex.value) {
56
+ decrementHighlightedIndex()
24
57
  }
25
58
  }
26
- const resetNavigation = () => {
27
- highlightedIndex.value = -1
59
+ const handleArrowDown = (event: KeyboardEvent) => {
60
+ event.preventDefault()
61
+ if (isEligibleToIncrementHighlightedIndex.value) {
62
+ incrementHighlightedIndex()
63
+ }
28
64
  }
65
+ const handleEnter = () => {
66
+ if (isEligibleToHandleEnter.value) {
67
+ selectedItem.value = itemsData.value[highlightedIndex.value]
68
+ resetHighlightedIndex()
69
+ }
70
+ }
71
+
29
72
  const navigateList = (event: KeyboardEvent) => {
30
- if (!items.value?.length || !isOpen.value) {
73
+ if (isNotEligibleToHandleArrows.value) {
31
74
  return
32
75
  }
33
76
  switch (event.key) {
34
77
  case 'ArrowUp':
35
- handleArrowUp()
78
+ handleArrowUp(event)
36
79
  break
37
80
  case 'ArrowDown':
38
- handleArrowDown()
81
+ handleArrowDown(event)
39
82
  break
40
83
  case 'Enter':
41
84
  handleEnter()
@@ -41,7 +41,7 @@ export interface AnchorEvent extends KeyboardEvent {
41
41
 
42
42
  // handleShow/handleHide -> removeTick(), self (& emit show)
43
43
 
44
- export default function ({
44
+ export default function useModelToggle({
45
45
  showing,
46
46
  canShow, // optional
47
47
  handleShow, // optional
@@ -70,29 +70,28 @@ export default function ({
70
70
  function show(evt: AnchorEvent) {
71
71
  if (
72
72
  props.disabled === true ||
73
- (evt !== void 0 && evt.dlAnchorHandled === true) ||
74
- (canShow !== void 0 && canShow(evt) !== true)
73
+ (evt && evt.dlAnchorHandled === true) ||
74
+ (canShow && canShow(evt) !== true)
75
75
  ) {
76
76
  return
77
77
  }
78
78
 
79
79
  const listener =
80
- props[`onUpdate:${modelValueNaming}`] !== void 0 ||
81
- (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`] !==
82
- void 0
80
+ props[`onUpdate:${modelValueNaming}`] ||
81
+ (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
83
82
 
84
- if (listener === true) {
83
+ if (listener) {
85
84
  emit(`update:${modelValueNaming}`, true)
86
85
  payload = evt
87
86
 
88
87
  nextTick(() => {
89
88
  if (payload === evt) {
90
- payload = void 0
89
+ payload = null
91
90
  }
92
91
  })
93
92
  }
94
93
 
95
- if (!props.modelValue || listener === false) {
94
+ if (!props.modelValue || !listener) {
96
95
  processShow(evt)
97
96
  }
98
97
  }
@@ -106,7 +105,7 @@ export default function ({
106
105
 
107
106
  emit('before-show', evt)
108
107
 
109
- if (handleShow !== void 0) {
108
+ if (handleShow) {
110
109
  handleShow(evt)
111
110
  } else {
112
111
  emit('show', evt)
@@ -119,16 +118,15 @@ export default function ({
119
118
  }
120
119
 
121
120
  const listener =
122
- props[`onUpdate:${modelValueNaming}`] !== void 0 ||
123
- (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`] !==
124
- void 0
121
+ props[`onUpdate:${modelValueNaming}`] ||
122
+ (vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
125
123
 
126
124
  if (listener === true) {
127
125
  emit(`update:${modelValueNaming}`, false)
128
126
  payload = evt
129
127
  nextTick(() => {
130
128
  if (payload === evt) {
131
- payload = void 0
129
+ payload = null
132
130
  }
133
131
  })
134
132
  }
@@ -147,7 +145,7 @@ export default function ({
147
145
 
148
146
  emit('before-hide', evt)
149
147
 
150
- if (handleHide !== void 0) {
148
+ if (handleHide) {
151
149
  handleHide(evt)
152
150
  } else {
153
151
  emit('hide', evt)
@@ -156,7 +154,7 @@ export default function ({
156
154
 
157
155
  function processModelChange(val: boolean) {
158
156
  if (props.disabled === true && val === true) {
159
- if (props[`onUpdate:${modelValueNaming}`] !== void 0) {
157
+ if (props[`onUpdate:${modelValueNaming}`]) {
160
158
  emit(`update:${modelValueNaming}`, false)
161
159
  }
162
160
  } else if ((val === true) !== showing.value) {
@@ -7,7 +7,7 @@ import { portalList } from '../utils/portal'
7
7
  function isOnGlobalDialog(vm: any) {
8
8
  vm = vm.parent
9
9
 
10
- while (vm !== void 0 && vm !== null) {
10
+ while (vm) {
11
11
  if (vm.type.name === 'DlGlobalDialog') {
12
12
  return true
13
13
  }
@@ -24,15 +24,21 @@ function isOnGlobalDialog(vm: any) {
24
24
  // Warning!
25
25
  // You MUST specify "inheritAttrs: false" in your component
26
26
 
27
- export default function (
27
+ export default function usePortal(
28
28
  vm: ComponentInternalInstance | null,
29
29
  innerRef: Ref<HTMLElement | null>,
30
- checkGlobalDialog = false
30
+ checkGlobalDialog = false,
31
+ config: {
32
+ parentId?: string
33
+ parentClass?: string
34
+ parentStyle?: string
35
+ } = {}
31
36
  ) {
32
37
  // showing, including while in show/hide transition
33
38
  const portalIsActive = ref(false)
34
39
 
35
40
  const { proxy } = vm!
41
+ const { parentId, parentClass, parentStyle } = config
36
42
 
37
43
  // showing & not in any show/hide transition
38
44
  const portalIsAccessible = ref(false)
@@ -8,10 +8,8 @@ export default function (props: any, configureScrollTarget: Function) {
8
8
  let scrollFn: Function | undefined
9
9
 
10
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
11
+ const fnProp: string = `${fn ? 'add' : 'remove'}EventListener`
12
+ const fnHandler = fn ? fn : scrollFn
15
13
 
16
14
  if (scrollTarget !== window) {
17
15
  scrollTarget[fnProp]('scroll', fnHandler, listenOpts.passive)
@@ -1,14 +1,15 @@
1
1
  import { onBeforeUnmount, onMounted, ref, Ref } from 'vue-demi'
2
2
  import { isEllipsisActive } from '../utils/is-ellipsis-active'
3
+ import { get } from 'lodash'
3
4
 
4
- export function useSizeObserver(elRef: Ref) {
5
+ export function useSizeObserver(elRef: Ref, entryLevel = 'target') {
5
6
  const widthRef = ref(0)
6
7
  const heightRef = ref(0)
7
8
  const hasEllipsis = ref(false)
8
9
  const borderBoxSize = ref(null)
9
10
  const resizeObserver = new ResizeObserver((entries) => {
10
11
  for (const entry of entries) {
11
- hasEllipsis.value = isEllipsisActive(entry.target)
12
+ hasEllipsis.value = isEllipsisActive(get(entry, entryLevel))
12
13
  widthRef.value = entry.contentRect.width
13
14
  heightRef.value = entry.contentRect.height
14
15
  borderBoxSize.value = entry.borderBoxSize