@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
@@ -1,5 +1,7 @@
1
1
  import { Ref, ref } from 'vue-demi'
2
2
  import { splitByQuotes } from '../utils/splitByQuotes'
3
+ import { flatten } from 'flat'
4
+ import { isObject } from 'lodash'
3
5
 
4
6
  export type Schema = {
5
7
  [key: string]:
@@ -50,6 +52,15 @@ const operatorToDataTypeMap: OperatorToDataTypeMap = {
50
52
  $nin: []
51
53
  }
52
54
 
55
+ const knownDataTypes = [
56
+ 'number',
57
+ 'boolean',
58
+ 'string',
59
+ 'date',
60
+ 'datetime',
61
+ 'time'
62
+ ]
63
+
53
64
  type Suggestion = string
54
65
 
55
66
  type Expression = {
@@ -60,36 +71,86 @@ type Expression = {
60
71
  }
61
72
 
62
73
  const space = ' '
63
- const dateStartSuggestionString = '(From dd/mm/yyyy)'
64
- const dateEndSuggestionString = '(To dd/mm/yyyy)'
65
- const dateIntervalSuggestionString = '(From (dd/mm/yyyy) To (dd/mm/yyyy))'
74
+ const dateSuggestionPattern = '(dd/mm/yyyy)'
66
75
 
67
76
  let localSuggestions: Suggestion[] = []
68
77
 
69
- export const startDatePattern = new RegExp(
70
- /(from\s?\d{2}\/\d{2}\/\d{4}\s?|from\s?dd\/mm\/yyyy\s?)/,
71
- 'gi'
72
- )
73
- export const endDatePattern = new RegExp(
74
- /(to\s?\d{2}\/\d{2}\/\d{4}\s?|to\s?dd\/mm\/yyyy\s?)/,
75
- 'gi'
76
- )
77
- export const dateIntervalPattern = new RegExp(
78
- /(from\s?\d{2}\/\d{2}\/\d{4}\s?to\s?\d{2}\/\d{2}\/\d{4})|(from\s?dd\/mm\/yyyy\s?to\s?dd\/mm\/yyyy)/,
78
+ export const datePattern = new RegExp(
79
+ /([\(']?\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?\(dd\/mm\/yyyy\)\s?)/,
79
80
  'gi'
80
81
  )
82
+ export const datePatternNoBrackets =
83
+ /(\d{2}\/\d{2}\/\d{4}\s?|\s?dd\/mm\/yyyy\s?)/
84
+
85
+ const mergeWords = (words: string[]) => {
86
+ const result: string[] = []
87
+ let merging = false
88
+ let mergeIndex = -1
89
+
90
+ for (let i = 0; i < words.length; ++i) {
91
+ const currentItem = words[i]
92
+
93
+ if (currentItem === 'IN' || currentItem === 'NOT-IN') {
94
+ merging = true
95
+ mergeIndex = i + 1
96
+ result.push(currentItem)
97
+ continue
98
+ } else if (
99
+ Object.values(Logical).includes(currentItem as any) ||
100
+ Object.values(operators).includes(currentItem as any)
101
+ ) {
102
+ merging = false
103
+ }
104
+
105
+ if (merging) {
106
+ if (!result[mergeIndex]) {
107
+ result[mergeIndex] = ''
108
+ }
109
+ result[mergeIndex] += ' ' + currentItem
110
+ continue
111
+ }
112
+
113
+ result.push(currentItem)
114
+ }
115
+
116
+ return result
117
+ }
118
+
119
+ export const useSuggestions = (
120
+ schema: Schema,
121
+ aliases: Alias[],
122
+ options: { strict?: Ref<boolean> } = {}
123
+ ) => {
124
+ const { strict } = options
125
+ const initialSuggestions = Object.keys(schema)
126
+ const aliasedKeys = aliases.map((alias) => alias.key)
127
+ const aliasedSuggestions = initialSuggestions.map((suggestion) =>
128
+ aliasedKeys.includes(suggestion)
129
+ ? aliases.find((alias) => alias.key === suggestion)?.alias
130
+ : suggestion
131
+ )
132
+
133
+ for (const alias of aliases) {
134
+ if (aliasedSuggestions.includes(alias.alias)) {
135
+ continue
136
+ }
137
+ aliasedSuggestions.push(alias.alias)
138
+ }
139
+
140
+ const sortString = (a: string, b: string) =>
141
+ a.localeCompare(b, undefined, { sensitivity: 'base' })
142
+ const sortedSuggestions = aliasedSuggestions.sort(sortString)
81
143
 
82
- export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
83
- const initialSuggestions = aliases.map((alias) => alias.alias)
84
- const suggestions: Ref<Suggestion[]> = ref(initialSuggestions)
144
+ const suggestions: Ref<Suggestion[]> = ref(sortedSuggestions)
85
145
  const error: Ref<string | null> = ref(null)
86
146
 
87
147
  const findSuggestions = (input: string) => {
88
148
  input = input.replace(/\s+/g, ' ').trimStart()
89
- localSuggestions = initialSuggestions
149
+ localSuggestions = sortedSuggestions
90
150
 
91
151
  const words = splitByQuotes(input, space)
92
- const expressions = mapWordsToExpressions(words)
152
+ const mergedWords = mergeWords(words)
153
+ const expressions = mapWordsToExpressions(mergedWords)
93
154
 
94
155
  for (const { field, operator, value, keyword } of expressions) {
95
156
  let matchedField: Suggestion | null = null
@@ -98,33 +159,67 @@ export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
98
159
 
99
160
  if (!field) continue
100
161
 
101
- localSuggestions = getMatches(localSuggestions, field)
102
- matchedField = getMatch(localSuggestions, field)
162
+ const fieldSeparated: any = field.split('.')
163
+
164
+ if (fieldSeparated.length > 1) {
165
+ localSuggestions = []
166
+ matchedField = field
167
+ } else {
168
+ localSuggestions = getMatches(localSuggestions, field)
169
+ matchedField = getMatch(localSuggestions, field)
170
+ }
103
171
 
104
172
  if (!matchedField && isNextCharSpace(input, field)) {
105
173
  localSuggestions = []
106
174
  continue
107
175
  }
108
176
 
109
- if (!matchedField || !isNextCharSpace(input, matchedField)) {
177
+ if (
178
+ !matchedField ||
179
+ (!isNextCharSpace(input, matchedField) &&
180
+ fieldSeparated.length === 1)
181
+ ) {
110
182
  continue
111
183
  }
112
184
 
113
- const alias = getAliasObjByAlias(aliases, matchedField)
114
- if (!alias) continue
115
- const dataType = getDataTypeByAliasKey(schema, alias.key)
185
+ const dataType = getDataType(schema, aliases, matchedField)
116
186
  if (!dataType) {
117
187
  localSuggestions = []
118
188
  continue
119
189
  }
120
190
 
191
+ if (operator && (!value || value === '')) {
192
+ const valueSuggestion = getValueSuggestions(dataType, operator)
193
+ if (valueSuggestion) {
194
+ localSuggestions = valueSuggestion
195
+ continue
196
+ }
197
+ }
198
+
121
199
  const ops: string[] = Array.isArray(dataType)
122
200
  ? getGenericOperators()
123
201
  : getOperatorByDataType(dataType)
124
202
 
125
203
  localSuggestions = getOperators(ops)
126
204
 
127
- if (!operator) continue
205
+ if (!operator) {
206
+ const dotSeparated = matchedField.split('.').filter((el) => el)
207
+ let fieldOf = schema
208
+ for (const key of dotSeparated) {
209
+ fieldOf = fieldOf[key] as Schema
210
+ }
211
+
212
+ if (isObject(fieldOf) && !Array.isArray(fieldOf)) {
213
+ const toConcat: string[] = []
214
+ for (const key of Object.keys(fieldOf)) {
215
+ if (key === '*') continue
216
+ toConcat.push(`.${key}`)
217
+ }
218
+ localSuggestions = localSuggestions.concat(toConcat)
219
+ }
220
+
221
+ continue
222
+ }
128
223
 
129
224
  localSuggestions = getMatches(localSuggestions, operator)
130
225
  matchedOperator = getMatch(localSuggestions, operator)
@@ -139,7 +234,9 @@ export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
139
234
  }
140
235
 
141
236
  if (Array.isArray(dataType)) {
142
- localSuggestions = dataType
237
+ localSuggestions = dataType.filter(
238
+ (type) => !knownDataTypes.includes(type)
239
+ )
143
240
 
144
241
  if (!value) continue
145
242
 
@@ -149,11 +246,7 @@ export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
149
246
  dataType === 'date' ||
150
247
  dataType === 'time'
151
248
  ) {
152
- localSuggestions = [
153
- dateIntervalSuggestionString,
154
- dateStartSuggestionString,
155
- dateEndSuggestionString
156
- ]
249
+ localSuggestions = [dateSuggestionPattern]
157
250
 
158
251
  if (!value) continue
159
252
 
@@ -176,11 +269,11 @@ export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
176
269
  if (!matchedKeyword || !isNextCharSpace(input, matchedKeyword))
177
270
  continue
178
271
 
179
- localSuggestions = initialSuggestions
272
+ localSuggestions = sortedSuggestions
180
273
  }
181
274
 
182
275
  error.value = input.length
183
- ? getError(schema, aliases, expressions)
276
+ ? getError(schema, aliases, expressions, { strict })
184
277
  : null
185
278
 
186
279
  suggestions.value = localSuggestions
@@ -194,11 +287,38 @@ const errors = {
194
287
  INVALID_VALUE: (field: string) => `Invalid value for "${field}" field`
195
288
  }
196
289
 
290
+ const isInputAllowed = (input: string, allowedKeys: string[]): boolean => {
291
+ for (const key of allowedKeys) {
292
+ const keyParts = key.split('.')
293
+ const inputParts = input.split('.')
294
+
295
+ if (keyParts.length > inputParts.length) {
296
+ continue
297
+ }
298
+
299
+ let isMatch = true
300
+ for (let i = 0; i < keyParts.length; i++) {
301
+ if (keyParts[i] !== '*' && keyParts[i] !== inputParts[i]) {
302
+ isMatch = false
303
+ break
304
+ }
305
+ }
306
+
307
+ if (isMatch) {
308
+ return true
309
+ }
310
+ }
311
+
312
+ return false
313
+ }
314
+
197
315
  const getError = (
198
316
  schema: Schema,
199
317
  aliases: Alias[],
200
- expressions: Expression[]
318
+ expressions: Expression[],
319
+ options: { strict?: Ref<boolean> } = {}
201
320
  ): string | null => {
321
+ const { strict } = options
202
322
  const hasErrorInStructure = expressions
203
323
  .flatMap((exp) => Object.values(exp))
204
324
  .some((el, index, arr) => {
@@ -214,11 +334,29 @@ const getError = (
214
334
  .filter(({ field, value }) => field !== null && value !== null)
215
335
  .reduce<string | null>((acc, { field, value, operator }, _, arr) => {
216
336
  if (acc === 'warning') return acc
217
- const aliasObj = getAliasObjByAlias(aliases, field)
218
- if (!aliasObj) return 'warning'
337
+ const key: string = getAliasObjByAlias(aliases, field)?.key ?? field
338
+
339
+ /**
340
+ * Handle nested keys to validate if the key exists in the schema or not.
341
+ */
342
+ const keys: string[] = []
343
+ for (const key of Object.keys(schema)) {
344
+ if (isObject(schema[key]) && !Array.isArray(schema[key])) {
345
+ const flattened = flatten({ [key]: schema[key] })
346
+ keys.push(...Object.keys(flattened))
347
+ } else {
348
+ keys.push(key)
349
+ }
350
+ }
351
+
352
+ const isValid = isInputAllowed(key, keys)
353
+ if (!keys.includes(key) && !isValid) {
354
+ return strict.value ? errors.INVALID_EXPRESSION : 'warning'
355
+ }
356
+
219
357
  const valid = isValidByDataType(
220
358
  validateBracketValues(value),
221
- getDataTypeByAliasKey(schema, aliasObj!.key),
359
+ getDataType(schema, aliases, key),
222
360
  operator
223
361
  )
224
362
 
@@ -236,8 +374,16 @@ const isValidByDataType = (
236
374
  dataType: string | string[],
237
375
  operator: string // TODO: use operator
238
376
  ): boolean => {
377
+ if (dataType === 'any') {
378
+ return true
379
+ }
380
+
239
381
  if (Array.isArray(dataType)) {
240
- return !!getValueMatch(dataType, str)
382
+ let isOneOf = !!getValueMatch(dataType, str)
383
+ for (const type of dataType) {
384
+ isOneOf = isOneOf || isValidByDataType(str, type, operator)
385
+ }
386
+ return isOneOf
241
387
  }
242
388
 
243
389
  switch (dataType) {
@@ -261,11 +407,7 @@ const validateBracketValues = (value: string) => {
261
407
  }
262
408
 
263
409
  const isValidDateIntervalPattern = (str: string) => {
264
- return (
265
- !!str.match(dateIntervalPattern) ||
266
- !!str.match(startDatePattern) ||
267
- !!str.match(endDatePattern)
268
- )
410
+ return !!str.match(datePatternNoBrackets)
269
411
  }
270
412
 
271
413
  const isValidNumber = (str: string) => {
@@ -283,10 +425,18 @@ const isValidString = (str: string) => {
283
425
  }
284
426
 
285
427
  const getOperatorByDataType = (dataType: string) => {
286
- return Object.keys(operatorToDataTypeMap).filter((key) => {
428
+ if (dataType === 'boolean') return ['$eq', '$neq']
429
+
430
+ if (dataType === 'object') {
431
+ return []
432
+ }
433
+
434
+ const operators = Object.keys(operatorToDataTypeMap).filter((key) => {
287
435
  const value = operatorToDataTypeMap[key]
288
436
  return value.length === 0 || value.includes(dataType)
289
437
  })
438
+
439
+ return operators
290
440
  }
291
441
 
292
442
  const getOperators = (op: string[]) => op.map((o) => operators[o])
@@ -300,22 +450,32 @@ const mapWordsToExpression = (words: string[]): Expression => {
300
450
  }
301
451
  }
302
452
 
303
- const getDataTypeByAliasKey = (
453
+ const getDataType = (
304
454
  schema: Schema,
455
+ aliases: Alias[],
305
456
  key: string
306
457
  ): string | string[] | null => {
307
- const nestedKey = key.split('.')
458
+ const aliasedKey = getAliasObjByAlias(aliases, key)?.key ?? key
308
459
 
309
- if (nestedKey.length === 1) {
310
- return (schema[nestedKey[0]] as string | string[]) ?? null
311
- }
460
+ const nestedKey = aliasedKey.split('.').filter((el) => el)
312
461
 
313
462
  let value = schema[nestedKey[0]] as Schema
463
+ if (!value) return null
464
+
314
465
  for (let i = 1; i < nestedKey.length; i++) {
466
+ if (!value) return null
467
+
315
468
  const nextKey = nestedKey[i]
469
+ if (!value[nextKey] && value['*']) {
470
+ return 'any'
471
+ }
316
472
  value = (value[nextKey] as Schema) ?? null
317
473
  }
318
474
 
475
+ if (isObject(value) && !Array.isArray(value)) {
476
+ return 'object'
477
+ }
478
+
319
479
  return value as unknown as string | string[] | null
320
480
  }
321
481
 
@@ -381,3 +541,33 @@ export const removeBrackets = (str: string) => {
381
541
  const removeQuotes = (str: string) => {
382
542
  return str.replaceAll('"', '').replaceAll("'", '')
383
543
  }
544
+
545
+ const getValueSuggestions = (dataType: string | string[], operator: string) => {
546
+ const types: string[] = Array.isArray(dataType) ? dataType : [dataType]
547
+ const suggestion: string[] = []
548
+
549
+ if (Array.isArray(dataType)) {
550
+ suggestion.push(
551
+ ...dataType.filter((type) => !knownDataTypes.includes(type))
552
+ )
553
+ }
554
+
555
+ for (const type of types) {
556
+ switch (type) {
557
+ case 'boolean':
558
+ if (operator === '=' || operator === '!=') {
559
+ suggestion.push('true', 'false')
560
+ }
561
+ break
562
+ case 'date':
563
+ case 'time':
564
+ case 'datetime':
565
+ suggestion.push(dateSuggestionPattern)
566
+ default:
567
+ // do nothing
568
+ break
569
+ }
570
+ }
571
+
572
+ return suggestion
573
+ }
@@ -1,6 +1,13 @@
1
- import { ref, computed, watch, nextTick, Ref } from 'vue-demi'
1
+ import { computed, watch, nextTick, Ref } from 'vue-demi'
2
2
 
3
3
  export const useTransitionProps = {
4
+ /**
5
+ * The duration of the transition in milliseconds.
6
+ * @default 300
7
+ * @type {number}
8
+ *
9
+ * Disabled for Vue2
10
+ */
4
11
  transitionDuration: {
5
12
  type: Number,
6
13
  default: 300
@@ -13,11 +20,10 @@ export default function (
13
20
  },
14
21
  showing: Ref<boolean>
15
22
  ) {
16
- const transitionState = ref(showing.value)
17
-
18
23
  watch(showing, (val) => {
19
24
  nextTick(() => {
20
- transitionState.value = val
25
+ if (showing.value === val) return
26
+ showing.value = val
21
27
  })
22
28
  })
23
29
 
package/src/index.ts CHANGED
@@ -1,7 +1,28 @@
1
- import { install } from 'vue-demi'
1
+ import { computed, install, reactive } from 'vue-demi'
2
2
 
3
3
  install()
4
4
 
5
+ // @ts-ignore
6
+ window.DlComponents = window.DlComponents || {
7
+ state: reactive({}),
8
+ setTheme: (theme: 'light' | 'dark') => {
9
+ // @ts-ignore
10
+ window.DlComponents.state.theme = theme
11
+ },
12
+ get theme(): 'light' | 'dark' {
13
+ // @ts-ignore
14
+ return window.DlComponents.state.theme
15
+ },
16
+ isDark: computed(() => {
17
+ // @ts-ignore
18
+ return window.DlComponents.state.theme === 'dark'
19
+ }),
20
+ isLight: computed(() => {
21
+ // @ts-ignore
22
+ return window.DlComponents.state.theme === 'light'
23
+ })
24
+ }
25
+
5
26
  export * from './components'
6
27
  import DlComponentsDemo from './App.vue'
7
28
  export { DlComponentsDemo }
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <div class="footer-content">
3
+ <div style="width: 300px">
4
+ <DlSlider
5
+ text="Thumb size"
6
+ editable
7
+ />
8
+ </div>
9
+ <div style="width: 100%; display: flex; padding-left: 20px">
10
+ <dl-pagination
11
+ v-model="page"
12
+ :rows-per-page="rowsPerPage"
13
+ :boundary-numbers="boundaryNumbers"
14
+ :boundary-links="boundaryLinks"
15
+ :direction-links="directionLinks"
16
+ :max-pages="maxPages"
17
+ :disabled="disabled"
18
+ :with-legend="withLegend"
19
+ :total-items="total"
20
+ :items-name="itemsName"
21
+ :with-quick-navigation="withQuickNavigation"
22
+ :with-rows-per-page="withRowsPerPage"
23
+ />
24
+ </div>
25
+ </div>
26
+ </template>
27
+
28
+ <script lang="ts">
29
+ import { defineComponent, ref } from 'vue-demi'
30
+ import { DlSlider, DlPagination } from '../../../components'
31
+
32
+ export default defineComponent({
33
+ name: 'DatasetFooter',
34
+ components: {
35
+ DlSlider,
36
+ DlPagination
37
+ },
38
+ setup() {
39
+ const page = ref(18)
40
+ const rowsPerPage = ref(10)
41
+ const boundaryNumbers = ref(true)
42
+ const boundaryLinks = ref(true)
43
+ const directionLinks = ref(true)
44
+ const maxPages = ref(6)
45
+ const disabled = ref(false)
46
+ const withLegend = ref(true)
47
+ const total = ref(200)
48
+ const itemsName = ref('Rows')
49
+ const withQuickNavigation = ref(true)
50
+ const withRowsPerPage = ref(true)
51
+
52
+ return {
53
+ page,
54
+ rowsPerPage,
55
+ boundaryNumbers,
56
+ boundaryLinks,
57
+ directionLinks,
58
+ maxPages,
59
+ disabled,
60
+ withLegend,
61
+ total,
62
+ itemsName,
63
+ withQuickNavigation,
64
+ withRowsPerPage
65
+ }
66
+ }
67
+ })
68
+ </script>
69
+
70
+ <style scoped lang="scss">
71
+ .footer-content {
72
+ display: flex;
73
+ align-items: center;
74
+ height: 40px;
75
+ padding: 0 15px 0 15px;
76
+ gap: 20px;
77
+ }
78
+ </style>
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <div>
3
+ <navbar-kpi />
4
+ <navbar-search />
5
+ </div>
6
+ </template>
7
+
8
+ <script lang="ts">
9
+ import { defineComponent } from 'vue-demi'
10
+ import NavbarKpi from './NavbarKpi.vue'
11
+ import NavbarSearch from './NavbarSearch.vue'
12
+
13
+ export default defineComponent({
14
+ name: 'DatasetHeader',
15
+ components: {
16
+ NavbarKpi,
17
+ NavbarSearch
18
+ }
19
+ })
20
+ </script>
21
+
22
+ <style scoped lang="scss"></style>
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div
3
+ class="left-drawer-content"
4
+ :style="cssVars"
5
+ >
6
+ <div style="padding: 10px">
7
+ <div class="left-drawer-content__toggle-icon">
8
+ <dl-button
9
+ flat
10
+ color="secondary"
11
+ :icon="expandIcon"
12
+ @click="onToggle"
13
+ />
14
+ </div>
15
+ <div style="padding: 40px 0 10px">
16
+ <dl-typography
17
+ size="12px"
18
+ color="dl-color-dark"
19
+ >
20
+ Search in:
21
+ </dl-typography>
22
+ </div>
23
+ <dl-radio
24
+ v-model="checkModel"
25
+ label="All Dataset items"
26
+ :value="1"
27
+ />
28
+ <dl-radio
29
+ v-model="checkModel"
30
+ label="Folders"
31
+ :value="2"
32
+ />
33
+ <dl-radio
34
+ v-model="checkModel"
35
+ label="Tasks"
36
+ :value="3"
37
+ />
38
+ </div>
39
+ </div>
40
+ </template>
41
+
42
+ <script lang="ts">
43
+ import { computed, defineComponent, ref } from 'vue-demi'
44
+ import { DlRadio, DlTypography, DlButton } from '../../../components'
45
+
46
+ export default defineComponent({
47
+ name: 'DatasetLeftDrawer',
48
+ components: {
49
+ DlRadio,
50
+ DlTypography,
51
+ DlButton
52
+ },
53
+ setup() {
54
+ const LARGE_WIDTH = '300px'
55
+ const SMALL_WIDTH = '50px'
56
+ const leftDrawerContentWidth = ref(LARGE_WIDTH)
57
+ const isExpanded = ref(true)
58
+ const checkModel = ref('')
59
+
60
+ const onToggle = () => {
61
+ isExpanded.value = !isExpanded.value
62
+ leftDrawerContentWidth.value = isExpanded.value
63
+ ? LARGE_WIDTH
64
+ : SMALL_WIDTH
65
+ }
66
+ const expandIcon = computed(() =>
67
+ isExpanded.value ? 'icon-dl-expand' : 'icon-dl-collapse'
68
+ )
69
+ const cssVars = computed(() => {
70
+ return {
71
+ '--left-drawer-content-width': leftDrawerContentWidth.value
72
+ }
73
+ })
74
+
75
+ return {
76
+ checkModel,
77
+ onToggle,
78
+ expandIcon,
79
+ cssVars
80
+ }
81
+ }
82
+ })
83
+ </script>
84
+
85
+ <style scoped lang="scss">
86
+ .left-drawer-content {
87
+ width: var(--left-drawer-content-width);
88
+ position: relative;
89
+ transition: all 300ms;
90
+
91
+ &__toggle-icon {
92
+ position: absolute;
93
+ right: 0;
94
+ }
95
+ }
96
+ </style>