@dataloop-ai/components 0.16.44 → 0.16.46

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 (146) hide show
  1. package/.eslintrc.js +2 -2
  2. package/package.json +10 -9
  3. package/src/App.vue +116 -57
  4. package/src/assets/globals.scss +2 -0
  5. package/src/components/basic/DlAlert/DlAlert.vue +1 -1
  6. package/src/components/basic/DlButton/DlButton.vue +22 -10
  7. package/src/components/basic/DlCard/DlCard.vue +217 -0
  8. package/src/components/basic/DlCard/index.ts +3 -0
  9. package/src/components/basic/DlCard/types.ts +20 -0
  10. package/src/components/basic/DlChip/DlChip.vue +1 -0
  11. package/src/components/basic/DlEllipsis/DlEllipsis.vue +90 -0
  12. package/src/components/basic/DlEllipsis/index.ts +2 -0
  13. package/src/components/basic/DlListItem/DlListItem.vue +11 -5
  14. package/src/components/basic/index.ts +2 -0
  15. package/src/components/compound/DlCharts/charts/DlBarChart/DlBarChart.vue +8 -1
  16. package/src/components/compound/DlCharts/charts/DlColumnChart/DlColumnChart.vue +22 -6
  17. package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +526 -0
  18. package/src/components/compound/DlCharts/charts/DlConfusionMatrix/index.ts +2 -0
  19. package/src/components/compound/DlCharts/charts/DlConfusionMatrix/utils.ts +96 -0
  20. package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChart.vue +2 -2
  21. package/src/components/compound/DlCharts/charts/DlLineChart/DlLineChart.vue +22 -6
  22. package/src/components/compound/DlCharts/charts/index.ts +1 -0
  23. package/src/components/compound/DlCharts/components/DlBrush.vue +8 -1
  24. package/src/components/compound/DlCharts/components/DlChartScrollBar.vue +34 -21
  25. package/src/components/compound/DlCharts/types/DlConfusionMatrix.types.ts +19 -0
  26. package/src/components/compound/DlCharts/types/index.ts +2 -1
  27. package/src/components/compound/DlCharts/types/props.ts +14 -0
  28. package/src/components/compound/DlDialogBox/DlDialogBox.vue +1 -1
  29. package/src/components/compound/DlDialogBox/components/DlDialogBoxFooter.vue +1 -0
  30. package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +58 -12
  31. package/src/components/compound/DlInput/DlInput.vue +45 -23
  32. package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +13 -29
  33. package/src/components/compound/DlPagination/DlPagination.vue +14 -4
  34. package/src/components/compound/DlPagination/components/PageNavigation.vue +24 -25
  35. package/src/components/compound/DlPagination/components/PaginationLegend.vue +2 -1
  36. package/src/components/compound/DlPagination/components/QuickNavigation.vue +1 -0
  37. package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +86 -49
  38. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +20 -13
  39. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSuggestionsDropdown.vue +43 -4
  40. package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +1 -55
  41. package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +42 -10
  42. package/src/components/compound/DlSearches/DlSmartSearch/utils/utils.ts +107 -0
  43. package/src/components/compound/DlSelect/DlSelect.vue +41 -8
  44. package/src/components/compound/DlTable/DlTable.vue +13 -10
  45. package/src/components/compound/DlTable/styles/dl-table-styles.scss +16 -4
  46. package/src/components/compound/DlToggleButton/DlToggleButton.vue +109 -0
  47. package/src/components/compound/DlToggleButton/config.ts +27 -0
  48. package/src/components/compound/DlToggleButton/index.ts +3 -0
  49. package/src/components/compound/DlToggleButton/types.ts +4 -0
  50. package/src/components/compound/index.ts +1 -0
  51. package/src/components/compound/types.ts +1 -0
  52. package/src/components/essential/DlColorPicker/DlColorPicker.vue +4 -1
  53. package/src/components/essential/DlColorPicker/components/DlColors.vue +2 -6
  54. package/src/components/essential/DlIcon/DlIcon.vue +5 -1
  55. package/src/components/essential/DlMenu/DlMenu.vue +30 -2
  56. package/src/components/essential/DlSeparator/DlSeparator.vue +62 -0
  57. package/src/components/essential/DlSeparator/index.ts +2 -0
  58. package/src/components/essential/DlSpinner/DlSpinner.vue +53 -217
  59. package/src/components/essential/DlSpinner/components/DlSpinnerCircle.vue +44 -0
  60. package/src/components/essential/DlSpinner/components/DlSpinnerClock.vue +79 -0
  61. package/src/components/essential/DlSpinner/components/DlSpinnerDots.vue +113 -0
  62. package/src/components/essential/DlSpinner/components/DlSpinnerGrid.vue +166 -0
  63. package/src/components/essential/DlSpinner/components/DlSpinnerLogo.vue +152 -0
  64. package/src/components/essential/DlSpinner/index.ts +14 -1
  65. package/src/components/essential/DlSpinner/styles/spinnerStyles.scss +111 -0
  66. package/src/components/essential/DlSpinner/types.ts +7 -0
  67. package/src/components/essential/index.ts +1 -0
  68. package/src/components/essential/types.ts +1 -0
  69. package/src/components/shared/DlItemSection/DlItemSection.vue +21 -15
  70. package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +36 -21
  71. package/src/components/shared/DlVirtualScroll/useVirtualScroll.ts +8 -10
  72. package/src/{demo → demos}/DlButtonDemo.vue +36 -1
  73. package/src/demos/DlCardDemo.vue +47 -0
  74. package/src/{demo → demos}/DlColorPickerDemo.vue +16 -1
  75. package/src/demos/DlConfusionMatrixDemo.vue +53 -0
  76. package/src/{demo → demos}/DlDialogBoxDemo.vue +4 -1
  77. package/src/demos/DlDropdownButtonDemo.vue +386 -0
  78. package/src/demos/DlEllipsisDemo.vue +30 -0
  79. package/src/{demo → demos}/DlLineChartDemo.vue +8 -8
  80. package/src/{demo → demos}/DlMenuDemo.vue +61 -2
  81. package/src/{demo → demos}/DlSearchDemo.vue +3 -2
  82. package/src/demos/DlSeparatorDemo.vue +44 -0
  83. package/src/demos/DlSpinnerDemo.vue +59 -0
  84. package/src/{demo → demos}/DlTableDemo.vue +117 -29
  85. package/src/demos/DlToggleButtonDemo.vue +57 -0
  86. package/src/{demo → demos}/DlTooltipDemo.vue +43 -2
  87. package/src/{demo → demos}/DlWidgetDemo.vue +34 -19
  88. package/src/{demo → demos}/SmartSearchDemo/DlSmartSearchDemo.vue +2 -50
  89. package/src/{demo → demos}/index.ts +14 -56
  90. package/src/hooks/use-arrow-navigation.ts +58 -0
  91. package/src/hooks/use-suggestions.ts +97 -74
  92. package/src/utils/colors.ts +1 -1
  93. package/src/utils/draggable-table.ts +2 -2
  94. package/src/utils/index.ts +1 -0
  95. package/src/utils/parse-smart-query.ts +87 -0
  96. package/src/components/compound/DlCharts/types.ts +0 -1
  97. package/src/demo/DlDropdownButtonDemo.vue +0 -260
  98. package/src/demo/DlSpinnerDemo.vue +0 -20
  99. /package/src/{demo → demos}/BarChartDemo.vue +0 -0
  100. /package/src/{demo → demos}/ColumnChartDemo.vue +0 -0
  101. /package/src/{demo → demos}/DlAccordionDemo.vue +0 -0
  102. /package/src/{demo → demos}/DlAlertDemo.vue +0 -0
  103. /package/src/{demo → demos}/DlAvatarDemo.vue +0 -0
  104. /package/src/{demo → demos}/DlBadgeDemo.vue +0 -0
  105. /package/src/{demo → demos}/DlChartDoughnutDemo.vue +0 -0
  106. /package/src/{demo → demos}/DlCheckboxDemo.vue +0 -0
  107. /package/src/{demo → demos}/DlChipDemo.vue +0 -0
  108. /package/src/{demo → demos}/DlCounterDemo.vue +0 -0
  109. /package/src/{demo → demos}/DlDateTimeRangeDemo.vue +0 -0
  110. /package/src/{demo → demos}/DlIconDemo.vue +0 -0
  111. /package/src/{demo → demos}/DlInputDemo.vue +0 -0
  112. /package/src/{demo → demos}/DlKpiDemo.vue +0 -0
  113. /package/src/{demo → demos}/DlLinkDemo.vue +0 -0
  114. /package/src/{demo → demos}/DlListDemo.vue +0 -0
  115. /package/src/{demo → demos}/DlOptionGroupDemo.vue +0 -0
  116. /package/src/{demo → demos}/DlPaginationDemo.vue +0 -0
  117. /package/src/{demo → demos}/DlPanelContainerDemo.vue +0 -0
  118. /package/src/{demo → demos}/DlPopupDemo.vue +0 -0
  119. /package/src/{demo → demos}/DlProgressBarDemo.vue +0 -0
  120. /package/src/{demo → demos}/DlProgressChartDemo.vue +0 -0
  121. /package/src/{demo → demos}/DlRadioDemo.vue +0 -0
  122. /package/src/{demo → demos}/DlRangeDemo.vue +0 -0
  123. /package/src/{demo → demos}/DlSelectDemo.vue +0 -0
  124. /package/src/{demo → demos}/DlSkeletonDemo.vue +0 -0
  125. /package/src/{demo → demos}/DlSliderDemo.vue +0 -0
  126. /package/src/{demo → demos}/DlStepperDemo/CenteredStepperInDialogBox.vue +0 -0
  127. /package/src/{demo → demos}/DlStepperDemo/DlStepperDemo.vue +0 -0
  128. /package/src/{demo → demos}/DlStepperDemo/SimpleStepper.vue +0 -0
  129. /package/src/{demo → demos}/DlStepperDemo/StepperInDialogBox.vue +0 -0
  130. /package/src/{demo → demos}/DlStepperDemo/index.ts +0 -0
  131. /package/src/{demo → demos}/DlStepperDemo/steps/AssignmentsStep.vue +0 -0
  132. /package/src/{demo → demos}/DlStepperDemo/steps/DataStep.vue +0 -0
  133. /package/src/{demo → demos}/DlStepperDemo/steps/GeneralStep.vue +0 -0
  134. /package/src/{demo → demos}/DlStepperDemo/steps/InstructionStep.vue +0 -0
  135. /package/src/{demo → demos}/DlStepperDemo/steps/QualityStep.vue +0 -0
  136. /package/src/{demo → demos}/DlSwitchDemo.vue +0 -0
  137. /package/src/{demo → demos}/DlTabsDemo.vue +0 -0
  138. /package/src/{demo → demos}/DlTdDemo.vue +0 -0
  139. /package/src/{demo → demos}/DlTextAreaDemo.vue +0 -0
  140. /package/src/{demo → demos}/DlTextHolderDemo.vue +0 -0
  141. /package/src/{demo → demos}/DlThDemo.vue +0 -0
  142. /package/src/{demo → demos}/DlToastDemo.vue +0 -0
  143. /package/src/{demo → demos}/DlTrDemo.vue +0 -0
  144. /package/src/{demo → demos}/DlTrendDemo.vue +0 -0
  145. /package/src/{demo → demos}/DlTypographyDemo.vue +0 -0
  146. /package/src/{demo → demos}/SmartSearchDemo/schema.ts +0 -0
@@ -10,34 +10,8 @@
10
10
  <div
11
11
  style="width: 100px"
12
12
  class="props"
13
- >
14
- <select
15
- id="status_select"
16
- class="prop"
17
- placeholder="Status type"
18
- @input="updateStatusType"
19
- >
20
- <option value="info">
21
- Info
22
- </option>
23
- <option value="warning">
24
- Warning
25
- </option>
26
- <option value="error">
27
- Error
28
- </option>
29
- <option value="success">
30
- Success
31
- </option>
32
- </select>
33
- <input
34
- class="prop"
35
- placeholder="Status Messaee"
36
- @input="updateStatusMessage"
37
- >
38
- </div>
13
+ />
39
14
  <dl-smart-search
40
- :status="status"
41
15
  :aliases="aliases"
42
16
  :schema="schema"
43
17
  :color-schema="{
@@ -74,10 +48,6 @@ export default defineComponent({
74
48
  return {
75
49
  switchState: false,
76
50
  isLoading: false,
77
- status: {
78
- type: 'info',
79
- message: ''
80
- },
81
51
  filters: [
82
52
  {
83
53
  label: 'Saved DQL Queries',
@@ -93,7 +63,7 @@ export default defineComponent({
93
63
  },
94
64
  {
95
65
  name: 'Query 3',
96
- query: ''
66
+ query: '{"query3": "query3"}'
97
67
  },
98
68
  {
99
69
  name: 'Query 4',
@@ -143,8 +113,6 @@ export default defineComponent({
143
113
  ]
144
114
  }
145
115
  },
146
-
147
- mounted() {},
148
116
  methods: {
149
117
  handleSearchQuery({ query }: { query: string }) {
150
118
  this.isLoading = true
@@ -154,22 +122,6 @@ export default defineComponent({
154
122
  this.isLoading = false
155
123
  }, 2000)
156
124
  },
157
-
158
- updateStatusType(e: Event) {
159
- const newType = (e.target as HTMLInputElement).value
160
- this.status = {
161
- type: newType,
162
- message: this.status.message
163
- }
164
- },
165
- updateStatusMessage(e: Event) {
166
- const newMessage = (e.target as HTMLInputElement).value
167
- this.status = {
168
- type: this.status.type,
169
- message: newMessage
170
- }
171
- },
172
-
173
125
  handleSaveQuery(query: Query) {
174
126
  const saveQueryIndex = this.filters[0].queries.findIndex(
175
127
  (q: Query) => q.name === query.name || q.query === query.query
@@ -47,9 +47,14 @@ import DlToastDemo from './DlToastDemo.vue'
47
47
  import DlChartDoughnutDemo from './DlChartDoughnutDemo.vue'
48
48
  import DlLineChartDemo from './DlLineChartDemo.vue'
49
49
  import DlSpinner from './DlSpinnerDemo.vue'
50
+ import DlConfusionMatrix from './DlConfusionMatrixDemo.vue'
51
+ import DlToggleButtonDemo from './DlToggleButtonDemo.vue'
50
52
  import DlKpiDemo from './DlKpiDemo.vue'
53
+ import DlEllipsisDemo from './DlEllipsisDemo.vue'
54
+ import DlSeparatorDemo from './DlSeparatorDemo.vue'
55
+ import DlCardDemo from './DlCardDemo.vue'
51
56
 
52
- export {
57
+ export default {
53
58
  AvatarDemo,
54
59
  DlAlertDemo,
55
60
  DlProgressChartDemo,
@@ -92,64 +97,17 @@ export {
92
97
  DlWidgetDemo,
93
98
  DlRadioDemo,
94
99
  DlTextHolderDemo,
95
- DlToastDemo as DlToastMessageDemo,
100
+ DlToastDemo,
96
101
  DlColumnChartDemo,
97
102
  DlSwitchDemo,
98
103
  DlChartDoughnutDemo,
99
104
  DlBarChartDemo,
100
105
  DlLineChartDemo,
101
- DlSpinner
102
- }
103
-
104
- export const demoState = {
105
- accordion: AccordionDemo,
106
- alert: DlAlertDemo,
107
- avatar: AvatarDemo,
108
- badge: DlBadgeDemo,
109
- button: DlButtonDemo,
110
- column_chart: DlColumnChartDemo,
111
- bar_chart: DlBarChartDemo,
112
- line_chart: DlLineChartDemo,
113
- checkbox: DlCheckboxDemo,
114
- chip: DlChipDemo,
115
- color_picker: DlColorPickerDemo,
116
- counter: DlCounterDemo,
117
- dialog_box: DlDialogBoxDemo,
118
- doughnut_chart: DlChartDoughnutDemo,
119
- dropdown_button: DropdownButtonDemo,
120
- icon: DlIconDemo,
121
- link: DlLinkDemo,
122
- list: DlListDemo,
123
- menu: DlMenuDemo,
124
- option_group: DlOptionGroupDemo,
125
- pagination: DlPaginationDemo,
126
- panel_container: DlPanelContainerDemo,
127
- popup: PopupDemo,
128
- progress_bar: DlProgressBarDemo,
129
- progress_chart: DlProgressChartDemo,
130
- kpi: DlKpiDemo,
131
- range: DlRangeDemo,
132
- search: DlSearchDemo,
133
- select: DlSelectDemo,
134
- skeleton: DlSkeletonDemo,
135
- slider: DlSliderDemo,
136
- stepper: DlStepperDemo,
137
- table: DlTableDemo,
138
- table_td: DlTdDemo,
139
- table_th: DlThDemo,
140
- table_tr: DlTrDemo,
141
- tabs: TabsDemo,
142
- input: DlInputDemo,
143
- textarea: DlTextareaDemo,
144
- text_holder: DlTextHolderDemo,
145
- time_picker: DlDateTimeRangeDemo,
146
- tooltip: DlTooltipDemo,
147
- trend: DlTrendDemo,
148
- typography: DlTypographyDemo,
149
- widget: DlWidgetDemo,
150
- radio: DlRadioDemo,
151
- switch: DlSwitchDemo,
152
- smart_search: DlSmartSearchDemo,
153
- toast: DlToastDemo,
154
- spinner: DlSpinner
106
+ DlSpinner,
107
+ DlConfusionMatrix,
108
+ DlToggleButtonDemo,
109
+ DlEllipsisDemo,
110
+ DlSeparatorDemo,
111
+ DlKpiDemo,
112
+ DlCardDemo
155
113
  }
@@ -0,0 +1,58 @@
1
+ import { ref, onMounted, onBeforeUnmount } from 'vue-demi'
2
+
3
+ export function useArrowNavigation(items: any, isOpen: any) {
4
+ const selectedItem = ref(null)
5
+ const highlightedIndex = ref(-1)
6
+
7
+ const handleArrowUp = () => {
8
+ if (highlightedIndex.value > 0) {
9
+ highlightedIndex.value--
10
+ }
11
+ }
12
+ const handleArrowDown = () => {
13
+ if (highlightedIndex.value < items.value.length - 1) {
14
+ highlightedIndex.value++
15
+ }
16
+ }
17
+ const handleEnter = () => {
18
+ if (
19
+ highlightedIndex.value >= 0 &&
20
+ highlightedIndex.value < items.value.length
21
+ ) {
22
+ selectedItem.value = items.value[highlightedIndex.value]
23
+ resetNavigation()
24
+ }
25
+ }
26
+ const resetNavigation = () => {
27
+ highlightedIndex.value = -1
28
+ }
29
+ const navigateList = (event: KeyboardEvent) => {
30
+ if (!items.value?.length || !isOpen.value) {
31
+ return
32
+ }
33
+ switch (event.key) {
34
+ case 'ArrowUp':
35
+ handleArrowUp()
36
+ break
37
+ case 'ArrowDown':
38
+ handleArrowDown()
39
+ break
40
+ case 'Enter':
41
+ handleEnter()
42
+ break
43
+ }
44
+ }
45
+
46
+ onMounted(() => {
47
+ window.addEventListener('keydown', navigateList)
48
+ })
49
+ onBeforeUnmount(() => {
50
+ window.removeEventListener('keydown', navigateList)
51
+ })
52
+
53
+ return {
54
+ handleEnter,
55
+ highlightedIndex,
56
+ selectedItem
57
+ }
58
+ }
@@ -60,12 +60,22 @@ type Expression = {
60
60
  }
61
61
 
62
62
  const space = ' '
63
+ const dateStartSuggestionString = '(From dd/mm/yyyy)'
64
+ const dateEndSuggestionString = '(To dd/mm/yyyy)'
63
65
  const dateIntervalSuggestionString = '(From (dd/mm/yyyy) To (dd/mm/yyyy))'
64
66
 
65
67
  let localSuggestions: Suggestion[] = []
66
68
 
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
+ )
67
77
  export const dateIntervalPattern = new RegExp(
68
- /\((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
+ /(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)/,
69
79
  'gi'
70
80
  )
71
81
 
@@ -75,99 +85,99 @@ export const useSuggestions = (schema: Schema, aliases: Alias[]) => {
75
85
  const error: Ref<string | null> = ref(null)
76
86
 
77
87
  const findSuggestions = (input: string) => {
88
+ input = input.replace(/\s+/g, ' ').trimStart()
78
89
  localSuggestions = initialSuggestions
79
90
 
80
91
  const words = splitByQuotes(input, space)
81
92
  const expressions = mapWordsToExpressions(words)
82
93
 
83
- expressions.forEach(
84
- ({ field, operator, value, keyword }: Expression) => {
85
- let matchedField: Suggestion | null = null
86
- let matchedOperator: Suggestion | null = null
87
- let matchedKeyword: Suggestion | null = null
94
+ for (const { field, operator, value, keyword } of expressions) {
95
+ let matchedField: Suggestion | null = null
96
+ let matchedOperator: Suggestion | null = null
97
+ let matchedKeyword: Suggestion | null = null
88
98
 
89
- if (!field) return
99
+ if (!field) continue
90
100
 
91
- localSuggestions = getMatches(localSuggestions, field)
92
- matchedField = getMatch(localSuggestions, field)
101
+ localSuggestions = getMatches(localSuggestions, field)
102
+ matchedField = getMatch(localSuggestions, field)
93
103
 
94
- if (!matchedField && isNextCharSpace(input, field)) {
95
- localSuggestions = []
96
- return
97
- }
104
+ if (!matchedField && isNextCharSpace(input, field)) {
105
+ localSuggestions = []
106
+ continue
107
+ }
98
108
 
99
- if (!matchedField || !isNextCharSpace(input, matchedField)) {
100
- return
101
- }
109
+ if (!matchedField || !isNextCharSpace(input, matchedField)) {
110
+ continue
111
+ }
102
112
 
103
- const alias = getAliasObjByAlias(aliases, matchedField)
104
- if (!alias) return
105
- const dataType = getDataTypeByAliasKey(schema, alias.key)
106
- if (!dataType) {
107
- localSuggestions = []
108
- return
109
- }
113
+ const alias = getAliasObjByAlias(aliases, matchedField)
114
+ if (!alias) continue
115
+ const dataType = getDataTypeByAliasKey(schema, alias.key)
116
+ if (!dataType) {
117
+ localSuggestions = []
118
+ continue
119
+ }
110
120
 
111
- const ops: string[] = Array.isArray(dataType)
112
- ? getGenericOperators()
113
- : getOperatorByDataType(dataType)
121
+ const ops: string[] = Array.isArray(dataType)
122
+ ? getGenericOperators()
123
+ : getOperatorByDataType(dataType)
114
124
 
115
- localSuggestions = getOperators(ops)
125
+ localSuggestions = getOperators(ops)
116
126
 
117
- if (!operator) return
127
+ if (!operator) continue
118
128
 
119
- localSuggestions = getMatches(localSuggestions, operator)
120
- matchedOperator = getMatch(localSuggestions, operator)
129
+ localSuggestions = getMatches(localSuggestions, operator)
130
+ matchedOperator = getMatch(localSuggestions, operator)
121
131
 
122
- if (!matchedOperator && isNextCharSpace(input, operator)) {
123
- localSuggestions = []
124
- return
125
- }
132
+ if (!matchedOperator && isNextCharSpace(input, operator)) {
133
+ localSuggestions = []
134
+ continue
135
+ }
126
136
 
127
- if (
128
- !matchedOperator ||
129
- !isNextCharSpace(input, matchedOperator)
130
- ) {
131
- return
132
- }
137
+ if (!matchedOperator || !isNextCharSpace(input, matchedOperator)) {
138
+ continue
139
+ }
133
140
 
134
- if (Array.isArray(dataType)) {
135
- localSuggestions = dataType
141
+ if (Array.isArray(dataType)) {
142
+ localSuggestions = dataType
136
143
 
137
- if (!value) return
144
+ if (!value) continue
138
145
 
139
- localSuggestions = getMatches(localSuggestions, value)
140
- } else if (
141
- dataType === 'datetime' ||
142
- dataType === 'date' ||
143
- dataType === 'time'
144
- ) {
145
- localSuggestions = [dateIntervalSuggestionString]
146
+ localSuggestions = getMatches(localSuggestions, value)
147
+ } else if (
148
+ dataType === 'datetime' ||
149
+ dataType === 'date' ||
150
+ dataType === 'time'
151
+ ) {
152
+ localSuggestions = [
153
+ dateIntervalSuggestionString,
154
+ dateStartSuggestionString,
155
+ dateEndSuggestionString
156
+ ]
146
157
 
147
- if (!value) return
158
+ if (!value) continue
148
159
 
149
- localSuggestions = getMatches(localSuggestions, value)
150
- } else {
151
- localSuggestions = []
152
- }
160
+ localSuggestions = getMatches(localSuggestions, value)
161
+ } else {
162
+ localSuggestions = []
163
+ }
153
164
 
154
- if (!value || !isNextCharSpace(input, value)) {
155
- return
156
- }
165
+ if (!value || !isNextCharSpace(input, value)) {
166
+ continue
167
+ }
157
168
 
158
- localSuggestions = [Logical.AND, Logical.OR]
169
+ localSuggestions = [Logical.AND, Logical.OR]
159
170
 
160
- if (!keyword) return
171
+ if (!keyword) continue
161
172
 
162
- localSuggestions = getMatches(localSuggestions, keyword)
163
- matchedKeyword = getMatch(localSuggestions, keyword)
173
+ localSuggestions = getMatches(localSuggestions, keyword)
174
+ matchedKeyword = getMatch(localSuggestions, keyword)
164
175
 
165
- if (!matchedKeyword || !isNextCharSpace(input, matchedKeyword))
166
- return
176
+ if (!matchedKeyword || !isNextCharSpace(input, matchedKeyword))
177
+ continue
167
178
 
168
- localSuggestions = initialSuggestions
169
- }
170
- )
179
+ localSuggestions = initialSuggestions
180
+ }
171
181
 
172
182
  error.value = input.length
173
183
  ? getError(schema, aliases, expressions)
@@ -203,12 +213,11 @@ const getError = (
203
213
  return expressions
204
214
  .filter(({ field, value }) => field !== null && value !== null)
205
215
  .reduce<string | null>((acc, { field, value, operator }, _, arr) => {
216
+ const aliasObj = getAliasObjByAlias(aliases, field)
217
+ if (!aliasObj) return 'warning'
206
218
  const valid = isValidByDataType(
207
- value,
208
- getDataTypeByAliasKey(
209
- schema,
210
- getAliasObjByAlias(aliases, field)!.key
211
- ),
219
+ validateBracketValues(value),
220
+ getDataTypeByAliasKey(schema, aliasObj!.key),
212
221
  operator
213
222
  )
214
223
 
@@ -244,8 +253,18 @@ const isValidByDataType = (
244
253
  }
245
254
  }
246
255
 
256
+ const validateBracketValues = (value: string) => {
257
+ value = removeBrackets(value)
258
+ value = value.split(',')[0]
259
+ return value
260
+ }
261
+
247
262
  const isValidDateIntervalPattern = (str: string) => {
248
- return !!str.match(dateIntervalPattern)
263
+ return (
264
+ !!str.match(dateIntervalPattern) ||
265
+ !!str.match(startDatePattern) ||
266
+ !!str.match(endDatePattern)
267
+ )
249
268
  }
250
269
 
251
270
  const isValidNumber = (str: string) => {
@@ -309,7 +328,7 @@ const getGenericOperators = () => {
309
328
  )
310
329
  }
311
330
 
312
- const mapWordsToExpressions = (words: string[]): Expression[] => {
331
+ export const mapWordsToExpressions = (words: string[]): Expression[] => {
313
332
  const _words = words.slice()
314
333
  const expressions = [mapWordsToExpression(_words.splice(0, 4))]
315
334
 
@@ -353,3 +372,7 @@ const isNextCharSpace = (input: string, str: string) => {
353
372
 
354
373
  const matchStringEnd = (input: string, str: string) =>
355
374
  input.lastIndexOf(str + '" ') > -1 || input.lastIndexOf(str + "' ") > -1
375
+
376
+ export const removeBrackets = (str: string) => {
377
+ return str.replaceAll('(', '').replaceAll(')', '')
378
+ }
@@ -4,7 +4,7 @@ export const hexToRgbA = (hex: string, opacity = 1) => {
4
4
  const g = parseInt(hex.slice(3, 5), 16)
5
5
  const b = parseInt(hex.slice(5, 7), 16)
6
6
 
7
- if (opacity) {
7
+ if (opacity || opacity === 0) {
8
8
  return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + opacity + ')'
9
9
  } else {
10
10
  return 'rgb(' + r + ', ' + g + ', ' + b + ')'
@@ -58,7 +58,7 @@ function isIntersecting(
58
58
  }
59
59
 
60
60
  function getRows(table: HTMLTableElement) {
61
- return table.querySelectorAll('tbody tr')
61
+ return table.querySelectorAll('tbody#draggable tr')
62
62
  }
63
63
 
64
64
  export function applyDraggableRows(
@@ -66,7 +66,7 @@ export function applyDraggableRows(
66
66
  vm?: any,
67
67
  root?: HTMLDivElement
68
68
  ) {
69
- const tbody = table.querySelector('tbody')!
69
+ const tbody = table.querySelector('tbody#draggable')!
70
70
 
71
71
  let currRow: any = null
72
72
  let dragElem: any = null
@@ -12,6 +12,7 @@ export * from './render'
12
12
  export * from './component-name-parser'
13
13
  export * from './colors'
14
14
  export * from './teleport'
15
+ export * from './parse-smart-query'
15
16
 
16
17
  export const isMobileOrTablet = () => {
17
18
  let check = false
@@ -0,0 +1,87 @@
1
+ /* eslint-disable no-empty */
2
+
3
+ import { isFinite } from 'lodash'
4
+
5
+ export const parseSmartQuery = (query: string) => {
6
+ const queryArr = query.split(' OR ')
7
+ const orTerms: { [key: string]: any }[] = []
8
+
9
+ for (const query of queryArr) {
10
+ const andTerms = query.split(' AND ')
11
+
12
+ const andQuery: { [key: string]: any } = {}
13
+ let queryValue: any
14
+
15
+ let key: string
16
+ 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
+ }
30
+
31
+ for (const term of andTerms) {
32
+ switch (true) {
33
+ case term.includes('>='):
34
+ [key, value] = term.split('>=').map((x) => x.trim())
35
+ andQuery[key] = { $gte: cleanValue(value) }
36
+ break
37
+ case term.includes('<='):
38
+ [key, value] = term.split('<=').map((x) => x.trim())
39
+ andQuery[key] = { $lte: cleanValue(value) }
40
+ break
41
+ case term.includes('>'):
42
+ [key, value] = term.split('>').map((x) => x.trim())
43
+ andQuery[key] = { $gt: cleanValue(value) }
44
+ break
45
+ case term.includes('<'):
46
+ [key, value] = term.split('<').map((x) => x.trim())
47
+ andQuery[key] = { $lt: cleanValue(value) }
48
+ break
49
+ case term.includes('!='):
50
+ [key, value] = term.split('!=').map((x) => x.trim())
51
+ andQuery[key] = { $ne: cleanValue(value) }
52
+ break
53
+ case term.includes('='):
54
+ [key, value] = term.split('=').map((x) => x.trim())
55
+ andQuery[key] = cleanValue(value)
56
+ break
57
+ case term.includes('IN'):
58
+ [key, value] = term.split('IN').map((x) => x.trim())
59
+ if (key.includes('NOT-')) {
60
+ [key, value] = term
61
+ .split('NOT-IN')
62
+ .map((x) => x.trim())
63
+ queryValue = term
64
+ .split('NOT-IN')
65
+ .map((x) => x.trim())[1]
66
+ .split(',')
67
+ .map((x) => cleanValue(x.trim()))
68
+ andQuery[key] = { $nin: cleanValue(queryValue) }
69
+ } else {
70
+ queryValue = term
71
+ .split('IN')
72
+ .map((x) => x.trim())[1]
73
+ .split(',')
74
+ .map((x) => cleanValue(x.trim()))
75
+ andQuery[key] = { $in: cleanValue(queryValue) }
76
+ }
77
+ break
78
+ }
79
+ }
80
+
81
+ orTerms.push(andQuery)
82
+ }
83
+
84
+ const builtQuery = orTerms.length > 1 ? { $or: orTerms } : orTerms[0]
85
+
86
+ return builtQuery
87
+ }
@@ -1 +0,0 @@
1
- export * from './types'