@dataloop-ai/components 0.18.77 → 0.18.79

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.18.77",
3
+ "version": "0.18.79",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -11,6 +11,7 @@
11
11
  ref="smartSearchInput"
12
12
  v-model="queryObject"
13
13
  style="margin-bottom: 0px"
14
+ :width="width"
14
15
  :status="status"
15
16
  :aliases="aliases"
16
17
  :schema="schema"
@@ -33,7 +34,7 @@
33
34
  height: '28px'
34
35
  }"
35
36
  :disabled="disabled"
36
- @click="emitSearchQuery"
37
+ @click="$emit('search-query', queryObject)"
37
38
  />
38
39
  </div>
39
40
  <div
@@ -138,6 +139,7 @@ export default defineComponent({
138
139
  //#endregion
139
140
 
140
141
  //#region data
142
+ // todo: more cleanup
141
143
  const inputModel = ref('')
142
144
  const jsonEditorModel = ref(false)
143
145
  const showJSONEditor = ref(false)
@@ -901,13 +901,12 @@ export default defineComponent({
901
901
 
902
902
  &__search-label {
903
903
  font-size: 10px;
904
- height: 10px;
904
+ height: 15px;
905
905
  color: gray;
906
906
  position: absolute;
907
907
  word-break: break-all;
908
- bottom: -10px;
908
+ bottom: -15px;
909
909
  max-width: 100%;
910
- margin-top: 3px;
911
910
  }
912
911
 
913
912
  &__date-picker-wrapper {
@@ -332,6 +332,34 @@
332
332
  {{ col.label }}
333
333
  </DlTh>
334
334
  </slot>
335
+ <DlTh
336
+ v-if="hasEditableColumns"
337
+ key="visibleColsBtn"
338
+ >
339
+ <dl-button
340
+ text-color="dl-color-medium"
341
+ flat
342
+ icon="icon-dl-column"
343
+ >
344
+ <dl-menu>
345
+ <dl-list separator>
346
+ <dl-option-group
347
+ :model-value="
348
+ computedVisibleCols
349
+ "
350
+ :options="groupOptions"
351
+ :left-label="true"
352
+ max-width="250px"
353
+ type="switch"
354
+ class="table-options"
355
+ @update:model-value="
356
+ handleVisibleColumnsUpdate
357
+ "
358
+ />
359
+ </dl-list>
360
+ </dl-menu>
361
+ </dl-button>
362
+ </DlTh>
335
363
  </DlTr>
336
364
 
337
365
  <tr
@@ -583,8 +611,16 @@ import {
583
611
  import { injectProp } from '../../../utils/inject-object-prop'
584
612
  import { DlTableRow, DlTableProps, DlTableColumn } from './types'
585
613
  import { DlPagination } from '../DlPagination'
586
- import { DlIcon, DlCheckbox, DlProgressBar } from '../../essential'
614
+ import {
615
+ DlIcon,
616
+ DlCheckbox,
617
+ DlProgressBar,
618
+ DlMenu,
619
+ DlList
620
+ } from '../../essential'
587
621
  import { ResizableManager } from './utils'
622
+ import { DlButton } from '../../basic'
623
+ import { DlOptionGroup } from '../../compound'
588
624
  import DlEmptyState from '../../basic/DlEmptyState/DlEmptyState.vue'
589
625
  import { v4 } from 'uuid'
590
626
  import { flatTreeData } from '../DlTreeTable/utils/flatTreeData'
@@ -606,7 +642,11 @@ export default defineComponent({
606
642
  DlProgressBar,
607
643
  DlIcon,
608
644
  DlCheckbox,
609
- DlEmptyState
645
+ DlEmptyState,
646
+ DlButton,
647
+ DlOptionGroup,
648
+ DlMenu,
649
+ DlList
610
650
  },
611
651
  props,
612
652
  emits,
@@ -625,6 +665,21 @@ export default defineComponent({
625
665
  const virtScrollRef = ref(null)
626
666
  const hasVirtScroll = computed(() => props.virtualScroll === true)
627
667
 
668
+ const groupOptions = computed(() =>
669
+ (props.columns as DlTableColumn[]).map((item) => ({
670
+ label: item.label,
671
+ value: item.name
672
+ }))
673
+ )
674
+
675
+ const visibleColumnsState = ref(
676
+ (props.columns as DlTableColumn[]).map((col) => col.name)
677
+ )
678
+
679
+ const computedVisibleCols = computed(() =>
680
+ computedCols.value.map((col) => col.name)
681
+ )
682
+
628
683
  const { hasAnyAction } = useTableActions(props) // todo: does not work
629
684
 
630
685
  const getRowKey = computed(() =>
@@ -790,6 +845,13 @@ export default defineComponent({
790
845
  }
791
846
  )
792
847
 
848
+ watch(
849
+ () => (props as any).visibleColummns,
850
+ (value) => {
851
+ visibleColumnsState.value = value
852
+ }
853
+ )
854
+
793
855
  watch(
794
856
  () => props.draggable,
795
857
  () => {
@@ -950,7 +1012,8 @@ export default defineComponent({
950
1012
  props as unknown as DlTableProps,
951
1013
  computedPagination,
952
1014
  hasSelectionMode,
953
- hasDraggableRows
1015
+ hasDraggableRows,
1016
+ visibleColumnsState
954
1017
  )
955
1018
 
956
1019
  const { columnToSort, computedSortMethod, sort } = useTableSort(
@@ -1243,6 +1306,12 @@ export default defineComponent({
1243
1306
  () => Object.keys(props.emptyStateProps).length > 0
1244
1307
  )
1245
1308
 
1309
+ const handleVisibleColumnsUpdate = (columns: string[]) => {
1310
+ if (columns.length < 1) return
1311
+ visibleColumnsState.value = columns
1312
+ emit('update-visible-columns', columns)
1313
+ }
1314
+
1246
1315
  return {
1247
1316
  uuid: `dl-table-${v4()}`,
1248
1317
  rootRef,
@@ -1296,7 +1365,11 @@ export default defineComponent({
1296
1365
  hasSlotHeaderSelection,
1297
1366
  stopAndPrevent,
1298
1367
  updatePagination,
1299
- hasEmptyStateProps
1368
+ hasEmptyStateProps,
1369
+ groupOptions,
1370
+ visibleColumnsState,
1371
+ handleVisibleColumnsUpdate,
1372
+ computedVisibleCols
1300
1373
  }
1301
1374
  }
1302
1375
  })
@@ -1,4 +1,4 @@
1
- import { computed, ComputedRef } from 'vue-demi'
1
+ import { computed, ComputedRef, Ref } from 'vue-demi'
2
2
 
3
3
  import { isNumber } from '../../../../utils/is'
4
4
  import { DlTableProps, DlTableColumn, DlTableRow } from '../types'
@@ -12,7 +12,8 @@ export function useTableColumnSelection(
12
12
  props: DlTableProps,
13
13
  computedPagination: ComputedRef<TablePagination>,
14
14
  hasSelectionMode: ComputedRef<boolean>,
15
- hasDraggableRows: ComputedRef<boolean>
15
+ hasDraggableRows: ComputedRef<boolean>,
16
+ visibleColumnsState: Ref
16
17
  ) {
17
18
  const colList = computed(() => {
18
19
  if (props.columns) {
@@ -40,11 +41,11 @@ export function useTableColumnSelection(
40
41
  const computedCols = computed(() => {
41
42
  const { sortBy, descending } = computedPagination.value
42
43
 
43
- const cols = props.visibleColumns
44
+ const cols = visibleColumnsState?.value
44
45
  ? colList.value.filter(
45
46
  (col) =>
46
47
  col.required === true ||
47
- props.visibleColumns.includes(col.name) === true
48
+ visibleColumnsState.value.includes(col.name) === true
48
49
  )
49
50
  : colList.value
50
51
 
@@ -46,6 +46,7 @@ export const props = {
46
46
  virtualScroll: Boolean,
47
47
  hidePagination: Boolean,
48
48
  hideSelectedBanner: Boolean,
49
+ hasEditableColumns: Boolean,
49
50
  selectedRowsLabel: {
50
51
  type: Function,
51
52
  default: (val: number) => `${val} records selected`
@@ -10,6 +10,7 @@ export const emits = [
10
10
  'th-click',
11
11
  'row-dblclick',
12
12
  'row-contextmenu',
13
+ 'update-visible-columns',
13
14
  ...useTableRowExpandEmits,
14
15
  ...useTreeTableRowSelectionEmits
15
16
  ]
@@ -408,6 +408,15 @@
408
408
  </template>
409
409
  </DlTable>
410
410
  </div>
411
+ <div>
412
+ <p>With editable columns</p>
413
+ <DlTable
414
+ :rows="tableRows"
415
+ :columns="tableColumns"
416
+ title="Editable Columns"
417
+ has-editable-columns
418
+ />
419
+ </div>
411
420
  </div>
412
421
  </div>
413
422
  </template>
@@ -26,7 +26,7 @@
26
26
  <dl-smart-search
27
27
  v-model="queryObject"
28
28
  :aliases="aliases"
29
- :schema="schema"
29
+ :schema="schema2"
30
30
  :color-schema="colorSchema"
31
31
  :filters="filters"
32
32
  :disabled="switchState"
@@ -48,7 +48,7 @@
48
48
  <dl-smart-search-input
49
49
  v-model="queryObject2"
50
50
  :aliases="aliases"
51
- :schema="schema"
51
+ :schema="schema2"
52
52
  :color-schema="colorSchema"
53
53
  :strict="strictState"
54
54
  :disabled="switchState"
@@ -383,6 +383,7 @@ const isValidByDataType = (
383
383
  */
384
384
 
385
385
  if (Array.isArray(dataType)) {
386
+ str = str.replace(/\'/g, '')
386
387
  let isOneOf = !!getValueMatch(dataType, str)
387
388
  for (const type of dataType) {
388
389
  isOneOf = isOneOf || isValidByDataType(str, type, operator)
@@ -209,6 +209,18 @@ export const stringifySmartQuery = (query: { [key: string]: any }): string => {
209
209
  continue
210
210
  }
211
211
 
212
+ if (key === '$and') {
213
+ if (Array.isArray(value)) {
214
+ const andObject: { [key: string]: any } = {}
215
+ for (const subQuery of value) {
216
+ for (const subKey in subQuery) {
217
+ andObject[subKey] = subQuery[subKey]
218
+ }
219
+ }
220
+ return stringifySmartQuery(andObject)
221
+ }
222
+ }
223
+
212
224
  if (result.length) {
213
225
  result += ' AND '
214
226
  }