@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,58 +1,144 @@
1
1
  /* eslint-disable no-empty */
2
2
 
3
- import { isFinite, isObject, isString } from 'lodash'
3
+ import { isBoolean, isFinite, isNumber, isObject, isString } from 'lodash'
4
4
 
5
+ export function isDatePattern(str: string) {
6
+ const datePattern = new RegExp(
7
+ /([\(']?\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?\(dd\/mm\/yyyy\)\s?)/,
8
+ 'gi'
9
+ )
10
+ const dates = str.match(datePattern) ?? []
11
+ return dates.length > 0
12
+ }
13
+
14
+ const GeneratePureValue = (value: any) => {
15
+ if (value === '') {
16
+ return null
17
+ }
18
+
19
+ if (typeof value === 'string') {
20
+ if (value === 'true') {
21
+ return true
22
+ }
23
+ if (value === 'false') {
24
+ return false
25
+ }
26
+
27
+ try {
28
+ const num = Number(value)
29
+ if (isFinite(num)) {
30
+ return num
31
+ }
32
+ return value.replaceAll('"', '').replaceAll("'", '')
33
+ } catch (e) {}
34
+ }
35
+ return value
36
+ }
37
+
38
+ const Operators: string[] = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
39
+
40
+ /**
41
+ * Method to convert a DlSmartSearch query string to Mongo based JSON query
42
+ *
43
+ * @param { string } query DlSmartSearch query string
44
+ * @returns Mongo based JSON
45
+ */
5
46
  export const parseSmartQuery = (query: string) => {
6
47
  const queryArr = query.split(' OR ')
48
+ for (let i = 0; i < queryArr.length; i++) {
49
+ const term: string = queryArr[i]
50
+ let withOperator = false
51
+ if (Operators.includes(term.split(' ')[1])) {
52
+ withOperator = true
53
+ }
54
+
55
+ if (!withOperator) {
56
+ if (i > 0) {
57
+ queryArr[i - 1] += ` OR ${term}`
58
+ queryArr.splice(i, 1)
59
+ }
60
+ }
61
+ }
7
62
  const orTerms: { [key: string]: any }[] = []
8
63
 
9
64
  for (const query of queryArr) {
10
65
  const andTerms = query.split(' AND ')
66
+ for (let i = 0; i < andTerms.length; i++) {
67
+ const term: string = andTerms[i]
68
+ let withOperator = false
69
+ for (const op of Operators) {
70
+ if (term.includes(op)) {
71
+ withOperator = true
72
+ break
73
+ }
74
+ }
75
+
76
+ if (!withOperator) {
77
+ if (i > 0) {
78
+ andTerms[i - 1] += ` AND ${term}`
79
+ andTerms.splice(i, 1)
80
+ }
81
+ }
82
+ }
11
83
 
12
84
  const andQuery: { [key: string]: any } = {}
13
85
  let queryValue: any
14
86
 
15
87
  let key: string
16
88
  let value: string | number | object
17
-
18
- const cleanValue = (value: any) => {
19
- if (typeof value === 'string') {
20
- try {
21
- const num = Number(value)
22
- if (isFinite(num)) {
23
- return num
24
- }
25
- } catch (e) {}
26
- return value.replaceAll('"', '').replaceAll("'", '')
27
- }
28
- return value
29
- }
89
+ let pureValue:
90
+ | string
91
+ | number
92
+ | object
93
+ | boolean
94
+ | null
95
+ | (string | number | object | boolean)[]
30
96
 
31
97
  for (const term of andTerms) {
98
+ pureValue = null
99
+
32
100
  switch (true) {
33
101
  case term.includes('>='):
34
102
  [key, value] = term.split('>=').map((x) => x.trim())
35
- andQuery[key] = { $gte: cleanValue(value) }
103
+ pureValue = GeneratePureValue(value)
104
+ if (pureValue !== null) {
105
+ andQuery[key] = { $gte: pureValue }
106
+ }
36
107
  break
37
108
  case term.includes('<='):
38
109
  [key, value] = term.split('<=').map((x) => x.trim())
39
- andQuery[key] = { $lte: cleanValue(value) }
110
+ pureValue = GeneratePureValue(value)
111
+ if (pureValue !== null) {
112
+ andQuery[key] = { $lte: pureValue }
113
+ }
40
114
  break
41
115
  case term.includes('>'):
42
116
  [key, value] = term.split('>').map((x) => x.trim())
43
- andQuery[key] = { $gt: cleanValue(value) }
117
+ pureValue = GeneratePureValue(value)
118
+ if (pureValue !== null) {
119
+ andQuery[key] = { $gt: pureValue }
120
+ }
44
121
  break
45
122
  case term.includes('<'):
46
123
  [key, value] = term.split('<').map((x) => x.trim())
47
- andQuery[key] = { $lt: cleanValue(value) }
124
+ pureValue = GeneratePureValue(value)
125
+ if (pureValue !== null) {
126
+ andQuery[key] = { $lt: pureValue }
127
+ }
48
128
  break
49
129
  case term.includes('!='):
50
130
  [key, value] = term.split('!=').map((x) => x.trim())
51
- andQuery[key] = { $ne: cleanValue(value) }
131
+ pureValue = GeneratePureValue(value)
132
+ if (pureValue !== null) {
133
+ andQuery[key] = { $ne: pureValue }
134
+ }
52
135
  break
53
136
  case term.includes('='):
54
137
  [key, value] = term.split('=').map((x) => x.trim())
55
- andQuery[key] = cleanValue(value)
138
+ pureValue = GeneratePureValue(value)
139
+ if (pureValue !== null) {
140
+ andQuery[key] = pureValue
141
+ }
56
142
  break
57
143
  case term.includes('IN'):
58
144
  [key, value] = term.split('IN').map((x) => x.trim())
@@ -64,15 +150,25 @@ export const parseSmartQuery = (query: string) => {
64
150
  .split('NOT-IN')
65
151
  .map((x) => x.trim())[1]
66
152
  .split(',')
67
- .map((x) => cleanValue(x.trim()))
68
- andQuery[key] = { $nin: cleanValue(queryValue) }
153
+ .map((x) => GeneratePureValue(x.trim()))
154
+ .filter((x) => x)
155
+
156
+ pureValue = GeneratePureValue(queryValue)
157
+ if (pureValue !== null && Array.isArray(pureValue)) {
158
+ andQuery[key] = { $nin: pureValue }
159
+ }
69
160
  } else {
70
161
  queryValue = term
71
162
  .split('IN')
72
163
  .map((x) => x.trim())[1]
73
164
  .split(',')
74
- .map((x) => cleanValue(x.trim()))
75
- andQuery[key] = { $in: cleanValue(queryValue) }
165
+ .map((x) => GeneratePureValue(x.trim()))
166
+ .filter((x) => x)
167
+
168
+ pureValue = GeneratePureValue(queryValue)
169
+ if (pureValue !== null && Array.isArray(pureValue)) {
170
+ andQuery[key] = { $in: pureValue }
171
+ }
76
172
  }
77
173
  break
78
174
  }
@@ -86,108 +182,110 @@ export const parseSmartQuery = (query: string) => {
86
182
  return builtQuery
87
183
  }
88
184
 
185
+ /**
186
+ * Method to convert a Mongo based JSON query to a DlSmartSearch query string
187
+ *
188
+ * @param { { [key: string]: any } } query Mongo based JSON that represents a query
189
+ * @returns DlSmartSearch query string
190
+ */
89
191
  export const stringifySmartQuery = (query: { [key: string]: any }) => {
90
192
  let result = ''
91
193
 
92
194
  for (const key in query) {
93
- if (query.hasOwnProperty(key)) {
94
- const value = query[key]
95
-
96
- if (key === '$or') {
97
- if (Array.isArray(value)) {
98
- const subQueries = value.map(
99
- (subQuery: { [key: string]: any }) =>
100
- stringifySmartQuery(subQuery)
101
- )
102
- result += subQueries.join(' OR ')
103
- }
104
- continue
105
- }
195
+ const value = query[key]
106
196
 
107
- if (result.length) {
108
- result += ' AND '
197
+ if (key === '$or') {
198
+ if (Array.isArray(value)) {
199
+ const subQueries = value.map(
200
+ (subQuery: { [key: string]: any }) =>
201
+ stringifySmartQuery(subQuery)
202
+ )
203
+ result += subQueries.join(' OR ')
109
204
  }
205
+ continue
206
+ }
110
207
 
111
- if (isObject(value)) {
112
- for (const operator in value) {
113
- if (value.hasOwnProperty(operator)) {
114
- let operatorValue = (
115
- value as {
116
- [key: string]:
117
- | string
118
- | number
208
+ if (result.length) {
209
+ result += ' AND '
210
+ }
211
+
212
+ if (isObject(value)) {
213
+ for (const operator in value) {
214
+ if (value.hasOwnProperty(operator)) {
215
+ let operatorValue = (
216
+ value as {
217
+ [key: string]: string | number | string[] | number[]
218
+ }
219
+ )[operator]
220
+ switch (operator) {
221
+ case '$eq':
222
+ result += `${key} = ${
223
+ isString(operatorValue)
224
+ ? `'${operatorValue}'`
225
+ : operatorValue
226
+ }`
227
+ break
228
+ case '$ne':
229
+ result += `${key} != ${
230
+ isString(operatorValue)
231
+ ? `'${operatorValue}'`
232
+ : operatorValue
233
+ }`
234
+ break
235
+ case '$gt':
236
+ result += `${key} > ${operatorValue}`
237
+ break
238
+ case '$gte':
239
+ result += `${key} >= ${operatorValue}`
240
+ break
241
+ case '$lt':
242
+ result += `${key} < ${operatorValue}`
243
+ break
244
+ case '$lte':
245
+ result += `${key} <= ${operatorValue}`
246
+ break
247
+ case '$in':
248
+ if (!Array.isArray(operatorValue)) {
249
+ operatorValue = [operatorValue] as
119
250
  | string[]
120
251
  | number[]
121
252
  }
122
- )[operator]
123
- switch (operator) {
124
- case '$eq':
125
- result += `${key} = ${
126
- isString(operatorValue)
127
- ? `'${operatorValue}'`
128
- : operatorValue
129
- }`
130
- break
131
- case '$ne':
132
- result += `${key} != ${
133
- isString(operatorValue)
134
- ? `'${operatorValue}'`
135
- : operatorValue
136
- }`
137
- break
138
- case '$gt':
139
- result += `${key} > ${operatorValue}`
140
- break
141
- case '$gte':
142
- result += `${key} >= ${operatorValue}`
143
- break
144
- case '$lt':
145
- result += `${key} < ${operatorValue}`
146
- break
147
- case '$lte':
148
- result += `${key} <= ${operatorValue}`
149
- break
150
- case '$in':
151
- if (!Array.isArray(operatorValue)) {
152
- operatorValue = [operatorValue] as
153
- | string[]
154
- | number[]
155
- }
156
-
157
- const inValues: string = (
158
- operatorValue as any[]
253
+
254
+ const inValues: string = (operatorValue as any[])
255
+ .map((x: string | number) =>
256
+ isString(x) ? `'${x}'` : x
159
257
  )
160
- .map((x: string | number) =>
161
- isString(x) ? `'${x}'` : x
162
- )
163
- .join(', ')
164
- result += `${key} IN ${inValues} `
165
- break
166
- case '$nin':
167
- if (!Array.isArray(operatorValue)) {
168
- operatorValue = [operatorValue] as
169
- | string[]
170
- | number[]
171
- }
172
-
173
- const ninValues: string = (
174
- operatorValue as any[]
258
+ .join(', ')
259
+ result += `${key} IN ${inValues} `
260
+ break
261
+ case '$nin':
262
+ if (!Array.isArray(operatorValue)) {
263
+ operatorValue = [operatorValue] as
264
+ | string[]
265
+ | number[]
266
+ }
267
+
268
+ const ninValues: string = (operatorValue as any[])
269
+ .map((x: string | number) =>
270
+ isString(x) ? `'${x}'` : x
175
271
  )
176
- .map((x: string | number) =>
177
- isString(x) ? `'${x}'` : x
178
- )
179
- .join(', ')
180
-
181
- result += `${key} NOT-IN ${ninValues}`
182
- break
183
- default:
184
- throw new Error(`Invalid operator: ${operator}`)
185
- }
272
+ .join(', ')
273
+
274
+ result += `${key} NOT-IN ${ninValues}`
275
+ break
276
+ default:
277
+ throw new Error(`Invalid operator: ${operator}`)
186
278
  }
187
279
  }
188
- } else {
189
- result += `${key} = '${value}'`
190
280
  }
281
+ } else if (isNumber(value)) {
282
+ result += `${key} = ${value}`
283
+ } else if (isBoolean(value)) {
284
+ result += `${key} = ${value}`
285
+ } else if (isDatePattern(value)) {
286
+ result += `${key} = (${value})`
287
+ } else {
288
+ result += `${key} = '${value}'`
191
289
  }
192
290
  }
193
291
 
@@ -19,13 +19,13 @@ export function closePortalMenus(vm: any, evt: Event) {
19
19
  if (vm.$props.separateClosePopup === true) {
20
20
  return getParentVm(vm)
21
21
  }
22
- } else if (vm.__dlPortalInnerRef !== void 0) {
22
+ } else if (vm.__dlPortalInnerRef) {
23
23
  // treat it as point of separation if parent is DlPopupProxy
24
24
  // (so mobile matches desktop behavior)
25
25
  // and hide it too
26
26
  const parent = getParentVm(vm)
27
27
 
28
- if (parent !== void 0 && parent.$options.name === 'DlPopupProxy') {
28
+ if (parent && parent.$options.name === 'DlPopupProxy') {
29
29
  vm.hide(evt)
30
30
  return parent
31
31
  } else {
@@ -34,12 +34,12 @@ export function closePortalMenus(vm: any, evt: Event) {
34
34
  }
35
35
 
36
36
  vm = getParentVm(vm)
37
- } while (vm !== void 0 && vm !== null)
37
+ } while (vm)
38
38
  }
39
39
 
40
40
  export function closePortals(vm: any, evt: Event, depth: number) {
41
- while (depth !== 0 && vm !== void 0 && vm !== null) {
42
- if (vm.__dlPortalInnerRef !== void 0) {
41
+ while (depth !== 0 && vm) {
42
+ if (vm.__dlPortalInnerRef) {
43
43
  depth--
44
44
 
45
45
  if (vm.$options.name === 'DlMenu') {
@@ -84,7 +84,7 @@ export function parsePosition(pos: string): ParsedPosition {
84
84
  export function getAnchorProps(el: HTMLElement, offset: number[]) {
85
85
  let { top, left, right, bottom, width, height } = el.getBoundingClientRect()
86
86
 
87
- if (offset !== void 0) {
87
+ if (offset) {
88
88
  top -= offset[1]
89
89
  left -= offset[0]
90
90
  bottom += offset[1]
@@ -101,8 +101,8 @@ export function getAnchorProps(el: HTMLElement, offset: number[]) {
101
101
  bottom,
102
102
  width,
103
103
  height,
104
- middle: left + (right - left) / 2,
105
- center: top + (bottom - top) / 2
104
+ middle: left + (right - left) / 2 + offset[0] ?? 0,
105
+ center: top + (bottom - top) / 2 + offset[1] ?? 0
106
106
  }
107
107
  }
108
108
 
@@ -145,7 +145,7 @@ interface ElementStyle {
145
145
  export function setPosition(cfg: PositionConfig) {
146
146
  const isMobile = isMobileOrTablet()
147
147
 
148
- if (isMobile && window.visualViewport !== void 0) {
148
+ if (isMobile && window.visualViewport) {
149
149
  // uses the dl-position-engine CSS class
150
150
 
151
151
  const el = document.body.style
@@ -169,7 +169,7 @@ export function setPosition(cfg: PositionConfig) {
169
169
  // the new positioning
170
170
  const { scrollLeft, scrollTop } = cfg.el!
171
171
 
172
- if (cfg.absoluteOffset === void 0) {
172
+ if (!cfg.absoluteOffset) {
173
173
  anchorProps = getAnchorProps(cfg.anchorEl, cfg.offset)
174
174
  } else {
175
175
  const { top: anchorTop, left: anchorLeft } =
@@ -245,7 +245,7 @@ export function setPosition(cfg: PositionConfig) {
245
245
  left: props.left + 'px'
246
246
  }
247
247
 
248
- if (props.maxHeight !== void 0) {
248
+ if (props.maxHeight) {
249
249
  elStyle.maxHeight = props.maxHeight + 'px'
250
250
 
251
251
  if (anchorProps.height > props.maxHeight) {
@@ -253,7 +253,7 @@ export function setPosition(cfg: PositionConfig) {
253
253
  }
254
254
  }
255
255
 
256
- if (props.maxWidth !== void 0) {
256
+ if (props.maxWidth) {
257
257
  elStyle.maxWidth = props.maxWidth + 'px'
258
258
 
259
259
  if (anchorProps.width > props.maxWidth) {
@@ -18,7 +18,7 @@ export const createElement = (
18
18
  * so it's merged with the possible slot
19
19
  */
20
20
  export function mergeSlot(slot: any, source: any) {
21
- return slot !== void 0 ? source.concat(slot()) : source
21
+ return slot ? source.concat(slot()) : source
22
22
  }
23
23
 
24
24
  export const hSlot = (
@@ -14,8 +14,8 @@ export function getScrollTarget(
14
14
  ) {
15
15
  let target = getElement(targetEl)
16
16
 
17
- if (target === void 0) {
18
- if (el === void 0 || el === null) {
17
+ if (!target) {
18
+ if (!el) {
19
19
  return window
20
20
  }
21
21
 
@@ -1,11 +1,11 @@
1
1
  export function clearSelection() {
2
- if (window.getSelection !== void 0) {
2
+ if (window.getSelection) {
3
3
  const selection = window.getSelection()
4
4
  if (!selection) return
5
5
 
6
- if (selection.empty !== void 0) {
6
+ if (selection.empty) {
7
7
  selection.empty()
8
- } else if (selection.removeAllRanges !== void 0) {
8
+ } else if (selection.removeAllRanges) {
9
9
  selection.removeAllRanges()
10
10
  if ('ontouchstart' in window) {
11
11
  selection.addRange(document.createRange())
package/vite.config.ts CHANGED
@@ -13,9 +13,17 @@ export default defineConfig({
13
13
  },
14
14
  coverage: {
15
15
  reporter: ['lcovonly', 'text']
16
- }
16
+ },
17
+ exclude: [
18
+ 'node_modules/**/*.spec.js',
19
+ 'node_modules/**/*.spec.ts',
20
+ 'node_modules/**/*.test.js',
21
+ 'node_modules/**/*.test.ts',
22
+ 'misc'
23
+ ]
17
24
  },
18
25
  optimizeDeps: {
26
+ include: ['highlight.js'],
19
27
  exclude: ['vue-demi']
20
28
  },
21
29
  define: {