@dataloop-ai/components 0.16.64 → 0.17.1
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.
- package/package.json +1 -1
- package/src/components/basic/DlAlert/DlAlert.vue +7 -8
- package/src/components/basic/DlButton/DlButton.vue +33 -11
- package/src/components/basic/DlButton/utils.ts +12 -2
- package/src/components/basic/DlChip/DlChip.vue +1 -8
- package/src/components/basic/DlPanelContainer/DlPanelContainer.vue +5 -5
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/utils.ts +6 -2
- package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +21 -15
- package/src/components/compound/DlDropdownButton/components/ButtonGroup.vue +11 -9
- package/src/components/compound/DlInput/DlInput.vue +7 -7
- package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +14 -14
- package/src/components/compound/DlPagination/components/PageNavigation.vue +21 -21
- package/src/components/compound/DlRange/DlRange.vue +1 -1
- package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +3 -3
- package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +132 -42
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchFilters.vue +75 -0
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +183 -173
- package/src/components/compound/DlSearches/DlSmartSearch/components/FiltersQuery.vue +101 -0
- package/src/components/compound/DlSearches/DlSmartSearch/types.ts +4 -4
- package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +9 -4
- package/src/components/compound/DlSearches/DlSmartSearch/utils/utils.ts +18 -1
- package/src/components/compound/DlSelect/DlSelect.vue +3 -4
- package/src/components/compound/DlSlider/DlSlider.vue +1 -1
- package/src/components/compound/DlStepper/DlStepper.vue +2 -2
- package/src/components/compound/DlStepper/components/DlStepperFooter.vue +3 -3
- package/src/components/compound/DlStepper/components/DlStepperHeader.vue +2 -2
- package/src/components/compound/DlTabs/components/TabsWrapper.vue +1 -1
- package/src/components/compound/DlToggleButton/DlToggleButton.vue +14 -11
- package/src/components/essential/DlIcon/DlIcon.vue +1 -1
- package/src/components/essential/DlSpinner/styles/spinnerStyles.scss +1 -1
- package/src/components/essential/DlTypography/DlTypography.vue +18 -2
- package/src/components/shared/types.ts +7 -1
- package/src/demos/DlAlertDemo.vue +17 -3
- package/src/demos/DlDropdownButtonDemo.vue +4 -4
- package/src/demos/DlSearchDemo.vue +1 -1
- package/src/demos/DlStepperDemo/SimpleStepper.vue +1 -1
- package/src/demos/DlStepperDemo/steps/DataStep.vue +1 -1
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +40 -75
- package/src/hooks/use-suggestions.ts +8 -3
- package/src/utils/parse-smart-query.ts +109 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-empty */
|
|
2
2
|
|
|
3
|
-
import { isFinite } from 'lodash'
|
|
3
|
+
import { isFinite, isObject, isString } from 'lodash'
|
|
4
4
|
|
|
5
5
|
export const parseSmartQuery = (query: string) => {
|
|
6
6
|
const queryArr = query.split(' OR ')
|
|
@@ -85,3 +85,111 @@ export const parseSmartQuery = (query: string) => {
|
|
|
85
85
|
|
|
86
86
|
return builtQuery
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
export const stringifySmartQuery = (query: { [key: string]: any }) => {
|
|
90
|
+
let result = ''
|
|
91
|
+
|
|
92
|
+
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
|
+
}
|
|
106
|
+
|
|
107
|
+
if (result.length) {
|
|
108
|
+
result += ' AND '
|
|
109
|
+
}
|
|
110
|
+
|
|
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
|
|
119
|
+
| string[]
|
|
120
|
+
| number[]
|
|
121
|
+
}
|
|
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[]
|
|
159
|
+
)
|
|
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[]
|
|
175
|
+
)
|
|
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
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
result += `${key} = '${value}'`
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return result
|
|
195
|
+
}
|