@dataloop-ai/components 0.19.104 → 0.19.106

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.19.104",
3
+ "version": "0.19.106",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -193,7 +193,7 @@ body {
193
193
  --dl-color-hover: #7b8cff;
194
194
  --dl-color-disabled: #b3b3b3;
195
195
  --dl-color-fill: #00000005;
196
- --dl-color-fill-hover: #00000010;
196
+ --dl-color-fill-hover: #f8f8f8;
197
197
  --dl-color-separator: #e4e4e4;
198
198
  --dl-color-scrollbar: #e4e4e4;
199
199
  --dl-color-body-background: #eef1ff;
@@ -254,7 +254,7 @@ body {
254
254
  --dl-color-disabled: #ffffff40;
255
255
  --dl-color-fill: #ffffff05;
256
256
  --dl-color-fill-secondary: #f8f8f81a;
257
- --dl-color-fill-hover: #ffffff10;
257
+ --dl-color-fill-hover: #454a50;
258
258
  --dl-color-separator: #ffffff26;
259
259
  --dl-color-body-background: #24282d;
260
260
  --dl-color-panel-background: #30363d;
@@ -536,6 +536,7 @@ export default defineComponent({
536
536
  .dl-button-container {
537
537
  display: inline-block;
538
538
  width: var(--dl-button-container-width);
539
+ height: fit-content;
539
540
  }
540
541
 
541
542
  .active-class {
@@ -75,7 +75,7 @@
75
75
  <dl-menu
76
76
  ref="menuRef"
77
77
  v-model="menuModel"
78
- :class="contentClass"
78
+ :menu-class="contentClass"
79
79
  :style="contentStyle"
80
80
  :cover="cover"
81
81
  fit-container
@@ -136,7 +136,7 @@
136
136
  <dl-menu
137
137
  ref="menuRef"
138
138
  v-model="menuModel"
139
- :class="contentClass"
139
+ :menu-class="contentClass"
140
140
  :style="contentStyle"
141
141
  :cover="cover"
142
142
  fit-container
@@ -551,6 +551,7 @@ export default defineComponent({
551
551
  </style>
552
552
  <style lang="scss">
553
553
  .dl-button-dropdown {
554
+ height: fit-content;
554
555
  .dl-button-content {
555
556
  line-height: unset;
556
557
  }
@@ -141,14 +141,16 @@
141
141
  @click="onThClick($event, col.name)"
142
142
  >
143
143
  <span
144
- class="inner-th"
144
+ :class="`inner-th ${`inner-th--${col.align}`}`"
145
145
  :style="
146
146
  col.width && {
147
147
  maxWidth: 'calc(100% - 15px)'
148
148
  }
149
149
  "
150
150
  >
151
- {{ col.label }}
151
+ <dl-ellipsis>
152
+ {{ col.label }}
153
+ </dl-ellipsis>
152
154
  </span>
153
155
  </DlTh>
154
156
  </slot>
@@ -157,6 +159,7 @@
157
159
  key="visibleColumnsSlot"
158
160
  :col-index="-1"
159
161
  no-tooltip
162
+ padding="0"
160
163
  >
161
164
  <slot
162
165
  name="header-cell-visible-columns-button"
@@ -179,8 +182,8 @@
179
182
  flat
180
183
  icon="icon-dl-column"
181
184
  tooltip="Manage columns"
182
- :disabled="isDataEmpty"
183
185
  padding="0"
186
+ :disabled="isDataEmpty"
184
187
  >
185
188
  <slot
186
189
  name="header-cell-visible-columns-menu"
@@ -531,14 +534,16 @@
531
534
  @click="onThClick($event, col.name)"
532
535
  >
533
536
  <span
534
- class="inner-th"
537
+ :class="`inner-th ${`inner-th--${col.align}`}`"
535
538
  :style="
536
539
  col.width && {
537
540
  maxWidth: 'calc(100% - 15px)'
538
541
  }
539
542
  "
540
543
  >
541
- {{ col.label }}
544
+ <dl-ellipsis>
545
+ {{ col.label }}
546
+ </dl-ellipsis>
542
547
  </span>
543
548
  </DlTh>
544
549
  </slot>
@@ -957,9 +962,20 @@ import {
957
962
  import { useTableActions, useTableActionsProps } from './hooks/tableActions'
958
963
  import { applyDraggableColumns, applyResizableColumns } from '../../../utils'
959
964
  import { injectProp } from '../../../utils/inject-object-prop'
960
- import { DlTableRow, DlTableProps, DlTableColumn } from './types'
965
+ import {
966
+ DlTableRow,
967
+ DlTableProps,
968
+ DlTableColumn,
969
+ TableStickyPosition
970
+ } from './types'
961
971
  import { DlPagination } from '../DlPagination'
962
- import { DlIcon, DlCheckbox, DlProgressBar, DlList } from '../../essential'
972
+ import {
973
+ DlIcon,
974
+ DlCheckbox,
975
+ DlProgressBar,
976
+ DlList,
977
+ DlEllipsis
978
+ } from '../../essential'
963
979
  import { DlButton, DlPopup } from '../../basic'
964
980
  import DlOptionGroup from '../DlOptionGroup/DlOptionGroup.vue'
965
981
  import DlEmptyState from '../../basic/DlEmptyState/DlEmptyState.vue'
@@ -994,7 +1010,8 @@ export default defineComponent({
994
1010
  DlOptionGroup,
995
1011
  DlPopup,
996
1012
  DlList,
997
- Sortable
1013
+ Sortable,
1014
+ DlEllipsis
998
1015
  },
999
1016
  props: {
1000
1017
  /**
@@ -1214,7 +1231,7 @@ export default defineComponent({
1214
1231
  },
1215
1232
  fitAllColumns: {
1216
1233
  type: Boolean,
1217
- default: true
1234
+ default: false
1218
1235
  },
1219
1236
  expandableRows: {
1220
1237
  type: Boolean,
@@ -1224,6 +1241,12 @@ export default defineComponent({
1224
1241
  type: String,
1225
1242
  default: 'No data'
1226
1243
  },
1244
+ stickyColumns: {
1245
+ type: Object as PropType<TableStickyPosition>,
1246
+ default: null,
1247
+ validator: (value: string) =>
1248
+ ['first', 'last', 'both'].includes(value)
1249
+ },
1227
1250
  ...useTableActionsProps,
1228
1251
  ...commonVirtScrollProps,
1229
1252
  ...useTableRowExpandProps,
@@ -1396,7 +1419,12 @@ export default defineComponent({
1396
1419
  (document.querySelector('table.dl-table') as HTMLTableElement)
1397
1420
 
1398
1421
  nextTick(() => {
1399
- setAllColumnWidths(tableEl, columns.value as DlTableColumn[])
1422
+ setAllColumnWidths(
1423
+ tableEl,
1424
+ columns.value as DlTableColumn[],
1425
+ props.stickyColumns,
1426
+ props.fitAllColumns
1427
+ )
1400
1428
  })
1401
1429
  if (visibleColumns.value) return
1402
1430
  if (resizable.value) {
@@ -1424,7 +1452,9 @@ export default defineComponent({
1424
1452
  nextTick(() => {
1425
1453
  setAllColumnWidths(
1426
1454
  tableEl,
1427
- props.columns as DlTableColumn[]
1455
+ props.columns as DlTableColumn[],
1456
+ props.stickyColumns,
1457
+ props.fitAllColumns
1428
1458
  )
1429
1459
  })
1430
1460
  if (visibleColumns.value) return
@@ -1462,7 +1492,9 @@ export default defineComponent({
1462
1492
  nextTick(() => {
1463
1493
  setAllColumnWidths(
1464
1494
  tableRef.value,
1465
- newColumns as DlTableColumn[]
1495
+ newColumns as DlTableColumn[],
1496
+ props.stickyColumns,
1497
+ props.fitAllColumns
1466
1498
  )
1467
1499
  })
1468
1500
  },
@@ -8,26 +8,9 @@
8
8
  @mouseenter="iconHover = true"
9
9
  @mouseleave="iconHover = false"
10
10
  >
11
- <dl-icon
12
- v-if="isSortable && align === 'right'"
13
- :class="iconClass"
14
- :icon="computedSortIcon"
15
- :style="
16
- !isCurrentlySorted && !iconHover
17
- ? 'display: none !important;'
18
- : ''
19
- "
20
- />
21
- <dl-tooltip v-if="hasEllipsis">
22
- <slot />
23
- </dl-tooltip>
24
- <slot />
25
- <span
26
- class="th-icons"
27
- :style="{ top: isDense ? '5px' : '12px' }"
28
- >
11
+ <div class="inner-th-wrapper">
29
12
  <dl-icon
30
- v-if="isSortable && ['left', 'center'].includes(align)"
13
+ v-if="isSortable && align === 'right'"
31
14
  :class="iconClass"
32
15
  :icon="computedSortIcon"
33
16
  :style="
@@ -36,17 +19,34 @@
36
19
  : ''
37
20
  "
38
21
  />
39
- <dl-icon
40
- v-if="hasHint"
41
- icon="icon-dl-info"
42
- size="10px"
43
- style="max-width: 30%"
44
- >
45
- <dl-tooltip>
46
- {{ props.col.hint }}
47
- </dl-tooltip>
48
- </dl-icon>
49
- </span>
22
+ <dl-tooltip v-if="hasEllipsis">
23
+ <slot />
24
+ </dl-tooltip>
25
+ <slot />
26
+ <span class="th-icons">
27
+ <dl-icon
28
+ v-if="hasHint"
29
+ icon="icon-dl-info"
30
+ size="10px"
31
+ style="max-width: 30%; margin-top: 1px"
32
+ >
33
+ <dl-tooltip>
34
+ {{ props.col.hint }}
35
+ </dl-tooltip>
36
+ </dl-icon>
37
+ <dl-icon
38
+ v-if="isSortable && ['left', 'center'].includes(align)"
39
+ :class="iconClass"
40
+ :icon="computedSortIcon"
41
+ size="16px"
42
+ :style="
43
+ !isCurrentlySorted && !iconHover
44
+ ? 'opacity: 0 !important;'
45
+ : ''
46
+ "
47
+ />
48
+ </span>
49
+ </div>
50
50
  </th>
51
51
  </template>
52
52
 
@@ -8,16 +8,40 @@
8
8
  border-right: 1px solid var(--dl-color-separator);
9
9
  }
10
10
 
11
+ .sticky-col {
12
+ position: sticky;
13
+ background-color: var(--dl-color-panel-background);
14
+ z-index: 50;
15
+ }
16
+
17
+ .inner-th-wrapper {
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: space-between;
21
+ gap: 6px;
22
+ height: 34px;
23
+ position: relative;
24
+ }
11
25
  .inner-th {
12
26
  display: inline-block;
27
+ flex: 0 1 auto;
28
+ position: absolute;
29
+ left: 50%;
30
+ transform: translateX(-50%);
13
31
  overflow: hidden;
14
- margin-right: 5px;
15
32
  position: relative;
33
+ line-height: 34px;
34
+ &--left {
35
+ left: 0;
36
+ transform: none;
37
+ }
16
38
  }
17
39
  .th-icons {
18
40
  display: flex;
19
- right: 0;
20
- position: absolute;
41
+ flex: 0 1 auto;
42
+ margin-left: auto;
43
+ align-items: center;
44
+ justify-content: flex-end;
21
45
  }
22
46
 
23
47
  .expanded-row {
@@ -76,11 +100,6 @@
76
100
  padding-left: 8px;
77
101
  }
78
102
 
79
- th:last-child,
80
- td:last-child {
81
- padding-right: 8px;
82
- }
83
-
84
103
  thead tr {
85
104
  height: 34px;
86
105
  }
@@ -92,7 +111,6 @@
92
111
  .dl-table__drag-icon > div {
93
112
  opacity: 1;
94
113
  }
95
-
96
114
  td:not(.dl-td--no-hover) {
97
115
  background-color: var(--dl-color-fill-hover);
98
116
  }
@@ -425,8 +443,8 @@
425
443
 
426
444
  .dl-table {
427
445
  th {
428
- font-size: 12px;
429
- line-height: 12px;
446
+ font-size: 14px;
447
+ line-height: 14px;
430
448
  }
431
449
 
432
450
  thead tr {
@@ -1,5 +1,7 @@
1
1
  import { DlTextTransformOptions } from '../../shared/types'
2
2
 
3
+ export type TableStickyPosition = 'first' | 'last' | 'both' | ''
4
+
3
5
  export interface SortingMovement {
4
6
  lastId: string
5
7
  direction: 'up' | 'down'
@@ -41,6 +43,7 @@ export type DlTableColumn = {
41
43
  textTransform?: DlTextTransformOptions
42
44
  width?: number
43
45
  hint?: string
46
+ sticky?: boolean
44
47
  }
45
48
 
46
49
  export type DlTableFilterMethod = (
@@ -117,6 +117,63 @@
117
117
  @col-update="updateColumns"
118
118
  @row-reorder="reorderRows"
119
119
  />
120
+ <div style="margin-top: 100px">
121
+ Fit table columns
122
+ <DlTable
123
+ :selected="selected"
124
+ :separator="separator"
125
+ :columns="tableColumns"
126
+ fit-all-columns
127
+ :bordered="bordered"
128
+ :draggable="draggable"
129
+ :dense="dense"
130
+ class="sticky-header"
131
+ :filter="filter"
132
+ :selection="selection"
133
+ :loading="loading"
134
+ :rows="tableRows"
135
+ :resizable="resizable"
136
+ row-key="name"
137
+ color="dl-color-secondary"
138
+ title="Table Title"
139
+ :virtual-scroll="vScroll"
140
+ style="height: 500px"
141
+ :rows-per-page-options="rowsPerPageOptions"
142
+ @row-click="log"
143
+ @th-click="log"
144
+ @update:selected="updateSeleted"
145
+ @col-update="updateColumns"
146
+ @row-reorder="reorderRows"
147
+ />
148
+
149
+ ALot of columns and fit
150
+ <DlTable
151
+ :selected="selected"
152
+ :separator="separator"
153
+ :columns="[...tableColumns, ...tableColumns]"
154
+ fit-all-columns
155
+ :bordered="bordered"
156
+ :draggable="draggable"
157
+ :dense="dense"
158
+ class="sticky-header"
159
+ :filter="filter"
160
+ :selection="selection"
161
+ :loading="loading"
162
+ :rows="tableRows"
163
+ :resizable="resizable"
164
+ row-key="name"
165
+ color="dl-color-secondary"
166
+ title="Table Title"
167
+ :virtual-scroll="vScroll"
168
+ style="height: 500px"
169
+ :rows-per-page-options="rowsPerPageOptions"
170
+ @row-click="log"
171
+ @th-click="log"
172
+ @update:selected="updateSeleted"
173
+ @col-update="updateColumns"
174
+ @row-reorder="reorderRows"
175
+ />
176
+ </div>
120
177
 
121
178
  <div style="margin-top: 100px">
122
179
  Custom Slot row-body
@@ -198,6 +255,33 @@
198
255
  </DlTable>
199
256
  </div>
200
257
 
258
+ <div style="margin-top: 100px">
259
+ With sticky columns: both
260
+ <DlTable
261
+ :columns="[...tableColumns, ...tableColumns]"
262
+ sticky-columns="both"
263
+ :rows="tableRows"
264
+ row-key="id"
265
+ style="height: 300px"
266
+ />
267
+ With sticky columns: first
268
+ <DlTable
269
+ :columns="[...tableColumns, ...tableColumns]"
270
+ sticky-columns="first"
271
+ :rows="tableRows"
272
+ row-key="id"
273
+ style="height: 300px"
274
+ />
275
+ With sticky columns: last
276
+ <DlTable
277
+ :columns="[...tableColumns, ...tableColumns]"
278
+ sticky-columns="last"
279
+ :rows="tableRows"
280
+ row-key="id"
281
+ style="height: 300px"
282
+ />
283
+ </div>
284
+
201
285
  <div style="margin-top: 100px">
202
286
  Loading WIth custom row
203
287
  <DlTable
@@ -541,6 +625,7 @@
541
625
  :rows="tableRows"
542
626
  row-key="id"
543
627
  style="height: 500px"
628
+ sticky-columns="last"
544
629
  :rows-per-page-options="rowsPerPageOptions"
545
630
  @row-click="log"
546
631
  @th-click="log"
@@ -625,7 +710,7 @@ const columns = [
625
710
  label: 'Calories',
626
711
  field: 'calories',
627
712
  sortable: true,
628
- width: 100
713
+ width: '50px'
629
714
  },
630
715
  {
631
716
  name: 'fat',
@@ -1044,7 +1129,6 @@ export default defineComponent({
1044
1129
  }
1045
1130
 
1046
1131
  const updateColumns = (newColumns: any) => {
1047
- console.log(newColumns)
1048
1132
  tableColumns.value = newColumns
1049
1133
  }
1050
1134
 
@@ -1,5 +1,5 @@
1
1
  import { cloneDeep } from 'lodash'
2
- import { DlTableColumn } from '../types'
2
+ import { DlTableColumn, TableStickyPosition } from '../types'
3
3
  import { browseNestedNodes } from './browse-nested-nodes'
4
4
  import { swapNodes } from './swap-nodes'
5
5
 
@@ -121,9 +121,24 @@ function getIconWidth(el: HTMLElement) {
121
121
  return iconEl?.scrollWidth
122
122
  }
123
123
 
124
+ function addStickyPosition(
125
+ element: HTMLElement,
126
+ position: TableStickyPosition,
127
+ index: number,
128
+ totalElements: number
129
+ ) {
130
+ if (position === 'both')
131
+ position =
132
+ index === 0 ? 'first' : index === totalElements - 1 ? 'last' : ''
133
+ element.style.left = position === 'first' ? '0' : ''
134
+ element.style.right = position === 'last' ? '0' : ''
135
+ }
136
+
124
137
  export function setAllColumnWidths(
125
138
  table: HTMLElement,
126
- columns: DlTableColumn[]
139
+ columns: DlTableColumn[],
140
+ stickyColumns: TableStickyPosition,
141
+ fitAllColumns: boolean
127
142
  ) {
128
143
  const hasWidth = columns.some((col) => col.hasOwnProperty('width'))
129
144
  if (!hasWidth) return
@@ -135,12 +150,37 @@ export function setAllColumnWidths(
135
150
  (el.tagName === 'TH' || el.tagName === 'TD') &&
136
151
  parseInt(el.dataset.colIndex) === i,
137
152
  (targetEl) => {
138
- const width =
139
- (col.width ?? targetEl.scrollWidth) +
140
- getIconWidth(targetEl) +
141
- 15
142
- targetEl.style.width = `${width}px`
143
- // then
153
+ if (!fitAllColumns && targetEl.tagName === 'TH') {
154
+ // Calculate the width for the column
155
+ const width =
156
+ (col.width ??
157
+ targetEl.querySelector('.inner-th').scrollWidth) +
158
+ getIconWidth(targetEl) +
159
+ 35
160
+
161
+ // Set the width of the column
162
+ targetEl.style.width =
163
+ typeof col.width === 'number' || !col.width
164
+ ? `${width}px`
165
+ : col.width
166
+ } else if (targetEl.tagName === 'TH') {
167
+ // Adjust the maximum width for TH elements
168
+ const innerTh = targetEl.querySelector(
169
+ '.inner-th'
170
+ ) as HTMLElement
171
+ innerTh.style.maxWidth = '80%'
172
+ }
173
+
174
+ if (stickyColumns && (i === 0 || i === columns.length - 1)) {
175
+ // Add sticky column class and position for sticky columns
176
+ targetEl.classList.add('sticky-col')
177
+ addStickyPosition(
178
+ targetEl,
179
+ stickyColumns,
180
+ i,
181
+ columns.length
182
+ )
183
+ }
144
184
  }
145
185
  )
146
186
  })