@dataloop-ai/components 0.18.145 → 0.19.0

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 (86) hide show
  1. package/package.json +4 -1
  2. package/src/assets/constants.scss +25 -26
  3. package/src/assets/globals.scss +58 -56
  4. package/src/assets/grid.css +1 -1
  5. package/src/assets/grid.scss +4 -4
  6. package/src/components/basic/DlAccordion/DlAccordion.vue +10 -3
  7. package/src/components/basic/DlEmptyState/types.ts +1 -1
  8. package/src/components/basic/DlGrid/DlGrid.vue +2 -1
  9. package/src/components/basic/DlPopup/DlPopup.vue +159 -396
  10. package/src/components/basic/DlWidget/DlWidget.vue +2 -1
  11. package/src/components/basic/utils.ts +0 -9
  12. package/src/components/blocks/DlLabelPicker/DlLabelPicker.vue +127 -0
  13. package/src/components/blocks/DlLabelPicker/index.ts +3 -0
  14. package/src/components/blocks/DlLabelPicker/types.ts +6 -0
  15. package/src/components/blocks/index.ts +1 -0
  16. package/src/components/blocks/types.ts +1 -0
  17. package/src/components/compound/DlCodeEditor/README.md +5 -4
  18. package/src/components/compound/DlCodeEditor/styles/themes-base16.css +16934 -11289
  19. package/src/components/compound/DlCodeEditor/styles/themes.css +5122 -3448
  20. package/src/components/compound/DlInput/DlInput.vue +609 -178
  21. package/src/components/compound/DlInput/components/InputFileElement.vue +97 -0
  22. package/src/components/compound/DlInput/types.ts +12 -0
  23. package/src/components/compound/DlInput/utils.ts +117 -0
  24. package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +10 -1
  25. package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +3 -3
  26. package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +1 -1
  27. package/src/components/compound/DlSlider/sliderStyles.scss +92 -92
  28. package/src/components/compound/DlTable/DlTable.vue +701 -358
  29. package/src/components/compound/DlTable/components/DlTd.vue +11 -9
  30. package/src/components/compound/DlTable/components/DlTh.vue +22 -21
  31. package/src/components/compound/DlTable/components/SortableJS.vue +33 -0
  32. package/src/components/compound/DlTable/hooks/tableActions.ts +3 -3
  33. package/src/components/compound/DlTable/hooks/tableColumnSelection.ts +3 -4
  34. package/src/components/compound/DlTable/hooks/use-sortable.ts +152 -0
  35. package/src/components/compound/DlTable/styles/dl-table-styles.scss +372 -377
  36. package/src/components/compound/DlTable/types.ts +6 -0
  37. package/src/components/compound/DlTable/utils/getCellValue.ts +27 -0
  38. package/src/components/compound/DlTable/utils/insertAtIndex.ts +22 -0
  39. package/src/components/compound/DlTable/utils/tableClasses.ts +22 -0
  40. package/src/components/compound/DlToast/api/useToast.ts +10 -4
  41. package/src/components/compound/DlToast/components/ToastComponent.vue +26 -21
  42. package/src/components/compound/DlToast/utils/render.ts +15 -8
  43. package/src/components/compound/DlTreeTable/DlTreeTable.vue +708 -323
  44. package/src/components/compound/DlTreeTable/components/DlTdTree.vue +10 -9
  45. package/src/components/compound/DlTreeTable/components/DlTrTree.vue +13 -0
  46. package/src/components/compound/DlTreeTable/emits.ts +2 -2
  47. package/src/components/compound/DlTreeTable/utils/index.ts +6 -0
  48. package/src/components/compound/DlTreeTable/utils/moveNestedRow.ts +95 -0
  49. package/src/components/compound/DlTreeTable/utils/trSpacing.ts +12 -1
  50. package/src/components/compound/DlTreeTable/utils/treeTableRowSelection.ts +10 -7
  51. package/src/components/compound/DlTreeTable/views/DlTrTreeView.vue +52 -58
  52. package/src/components/essential/DlMenu/DlMenu.vue +25 -0
  53. package/src/components/index.ts +1 -0
  54. package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +2 -1
  55. package/src/components/shared/DlVirtualScroll/styles/dl-virtual-scroll-styles.scss +62 -41
  56. package/src/components/types.ts +1 -0
  57. package/src/demos/DlAccordionDemo.vue +32 -0
  58. package/src/demos/DlButtonDemo.vue +7 -0
  59. package/src/demos/DlDemoPage.vue +1 -0
  60. package/src/demos/DlInputDemo.vue +122 -64
  61. package/src/demos/DlLabelPickerDemo.vue +46 -0
  62. package/src/demos/DlPopupDemo.vue +94 -4
  63. package/src/demos/DlSearchDemo.vue +0 -1
  64. package/src/demos/DlTableDemo.vue +261 -162
  65. package/src/demos/DlToastDemo.vue +28 -1
  66. package/src/demos/DlTreeTableDemo.vue +266 -262
  67. package/src/demos/DlVirtualScrollDemo.vue +1 -4
  68. package/src/demos/index.ts +3 -1
  69. package/src/hooks/use-model-toggle.ts +26 -62
  70. package/src/utils/browse-nested-nodes.ts +26 -0
  71. package/src/utils/draggable-table.ts +100 -488
  72. package/src/utils/get-element-above.ts +8 -0
  73. package/src/utils/getSlotByVersion.ts +11 -0
  74. package/src/utils/index.ts +4 -0
  75. package/src/utils/keyCodes.ts +1 -1
  76. package/src/utils/remove-child-nodes.ts +5 -0
  77. package/src/utils/render-fn.ts +46 -0
  78. package/src/utils/resizable-table.ts +110 -0
  79. package/src/utils/selection.ts +196 -0
  80. package/src/utils/swap-nodes.ts +11 -0
  81. package/src/utils/table-columns.ts +209 -0
  82. package/src/components/compound/DlTable/utils/ResizableManager.ts +0 -236
  83. package/src/components/compound/DlTable/utils/index.ts +0 -1
  84. package/src/components/compound/DlTable/utils/props.ts +0 -120
  85. package/src/components/compound/DlTreeTable/props.ts +0 -134
  86. package/src/components/compound/DlTreeTable/utils/flatTreeData.ts +0 -19
@@ -1,236 +0,0 @@
1
- interface Options {
2
- minColWidth?: number
3
- width?: number
4
- cursor?: string
5
- color: string
6
- resizingColor?: string
7
- }
8
-
9
- const DEFAULT_SEPARTOR_WIDTH = 1
10
- const DEFAULT_MIN_COL_WIDTH = 16
11
- const DEFAULT_RESIZING_COLOR = 'var(--dl-color-medium)'
12
- const DEFAULT_COLOR = 'var(--dl-color-lighter)'
13
- const DEFAULT_CURSOR = 'ew-resize'
14
-
15
- const INNER_DIV_CLASS = 'dl-table-cell-inner-div'
16
-
17
- export class ResizableManager {
18
- private _table: HTMLTableElement
19
- private _currentColumn: HTMLTableCellElement | null = null
20
- private _thInnerDiv: HTMLDivElement = null
21
- private _columnIndex: number = 0
22
- private _tdInnerDivs: HTMLElement[] = []
23
- private _resizing: boolean = false
24
- private _options: Options = {
25
- minColWidth: DEFAULT_MIN_COL_WIDTH,
26
- width: DEFAULT_SEPARTOR_WIDTH,
27
- cursor: DEFAULT_CURSOR,
28
- color: DEFAULT_COLOR,
29
- resizingColor: DEFAULT_RESIZING_COLOR
30
- }
31
-
32
- private _colEvents: any[] = []
33
- private _separators: HTMLDivElement[] = []
34
-
35
- private _onMouseMoveFn = this._onMouseMove.bind(this)
36
- private _onMouseUpFn = this._onMouseUp.bind(this)
37
-
38
- private _onMouseMove(e: MouseEvent) {
39
- requestAnimationFrame(() => {
40
- if (!this._currentColumn || !this._thInnerDiv) return
41
-
42
- const padding = this._paddingDiff(this._currentColumn)
43
- const { x } = this._currentColumn.getBoundingClientRect()
44
- const newWidth = e.clientX - x - padding
45
-
46
- if (newWidth <= this._options.minColWidth) return
47
-
48
- this._thInnerDiv.style.width = newWidth + 'px'
49
-
50
- this._tdInnerDivs.forEach((div) => {
51
- div.style.width = newWidth + 'px'
52
- })
53
- })
54
- }
55
-
56
- private _paddingDiff(col: HTMLElement) {
57
- const padLeft = this._getStyleVal(col, 'padding-left')
58
- const padRight = this._getStyleVal(col, 'padding-right')
59
- return parseInt(padLeft) + parseInt(padRight)
60
- }
61
-
62
- private _getStyleVal(elm: HTMLElement, css: string) {
63
- return window.getComputedStyle(elm, null).getPropertyValue(css)
64
- }
65
-
66
- private _onMouseUp(e: MouseEvent) {
67
- e.stopPropagation()
68
-
69
- this._resizing = false
70
-
71
- this._removeColumnBoundaries(this._currentColumn)
72
-
73
- document.removeEventListener('mousemove', this._onMouseMoveFn)
74
- document.removeEventListener('mouseup', this._onMouseUpFn)
75
- }
76
-
77
- private _removeColumnBoundaries(eventTarget: any) {
78
- const leftSeparator = eventTarget.querySelector(
79
- '[data-type="left-separator"]'
80
- ) as HTMLElement
81
- const resizeSeparator = eventTarget.querySelector(
82
- '[data-type="resize-separator"]'
83
- ) as HTMLElement
84
-
85
- leftSeparator.style.backgroundColor = 'transparent'
86
- resizeSeparator.style.backgroundColor = 'transparent'
87
- resizeSeparator.style.border = '0px'
88
- eventTarget.style.cursor = 'inherit'
89
- }
90
-
91
- private _onMouseDown = (e: MouseEvent) => {
92
- this._resizing = true
93
-
94
- e.stopPropagation()
95
- const eventTarget = e.target as HTMLDivElement
96
- eventTarget.style.backgroundColor = this._options.resizingColor
97
-
98
- this._currentColumn = eventTarget!
99
- .parentElement! as HTMLTableCellElement
100
- this._thInnerDiv = this._currentColumn.querySelector(
101
- `.${INNER_DIV_CLASS}`
102
- )
103
-
104
- this._columnIndex = Number(eventTarget.getAttribute('data-index')!)
105
- this._tdInnerDivs = this._table!.querySelectorAll(
106
- `tbody > tr > td:nth-of-type(${
107
- this._columnIndex + 1
108
- }) > .${INNER_DIV_CLASS}`
109
- )! as unknown as HTMLDivElement[]
110
-
111
- document.addEventListener('mousemove', this._onMouseMoveFn)
112
- document.addEventListener('mouseup', this._onMouseUpFn)
113
- }
114
-
115
- private _onMouseEnter(e: any) {
116
- if (this._resizing === true) return
117
-
118
- const leftSeparator = e.target.querySelector(
119
- '[data-type="left-separator"]'
120
- ) as HTMLElement
121
- const resizeSeparator = e.target.querySelector(
122
- '[data-type="resize-separator"]'
123
- ) as HTMLElement
124
-
125
- leftSeparator.style.backgroundColor = this._options.color
126
- resizeSeparator.style.backgroundColor = this._options.color
127
- resizeSeparator.style.width = '1px'
128
- resizeSeparator.style.border = '3px solid var(--dl-color-bg)'
129
- e.target.style.cursor = 'pointer'
130
- }
131
-
132
- private _onMouseLeave = (e: any) => {
133
- if (this._resizing === true) return
134
-
135
- this._removeColumnBoundaries(e.target)
136
- }
137
-
138
- private _createResizeSeparator(height: number, index: number) {
139
- const div = document.createElement('div')
140
- div.style.top = '0px'
141
- div.style.right = '0px'
142
- div.style.width = this._options.width + 'px'
143
- div.style.position = 'absolute'
144
- div.style.cursor = this._options.cursor
145
- div.style.userSelect = 'none'
146
- div.style.height = height + 'px'
147
- div.setAttribute('data-index', index.toString())
148
- div.setAttribute('data-type', 'resize-separator')
149
-
150
- return div
151
- }
152
-
153
- private _createLeftSeparator(height: number) {
154
- const div = document.createElement('div')
155
- div.style.top = '0px'
156
- div.style.left = '0px'
157
- div.style.width = this._options.width + 'px'
158
- div.style.position = 'absolute'
159
- div.style.userSelect = 'none'
160
- div.style.height = height + 'px'
161
- div.setAttribute('data-type', 'left-separator')
162
-
163
- return div
164
- }
165
-
166
- public addResizeCapability(
167
- table: HTMLTableElement,
168
- options: Partial<Options> = {}
169
- ) {
170
- this._options = {
171
- ...this._options,
172
- ...options
173
- }
174
- this._table = table
175
- const tableHeight = table.offsetHeight
176
- const cols = table.querySelectorAll('thead > tr:first-of-type > th')
177
-
178
- for (let i = 0; i < cols.length - 1; i++) {
179
- const column = cols[i]
180
-
181
- if ((column as HTMLElement).dataset.resizable === 'false') {
182
- continue
183
- }
184
-
185
- (column as HTMLElement).style.position = 'relative'
186
-
187
- const resizeSeparator = this._createResizeSeparator(tableHeight, i)
188
- column.appendChild(resizeSeparator)
189
- resizeSeparator.addEventListener(
190
- 'mousedown',
191
- this._onMouseDown.bind(this)
192
- )
193
-
194
- const leftSeparator = this._createLeftSeparator(tableHeight)
195
- column.appendChild(leftSeparator)
196
-
197
- this._separators.push(resizeSeparator, leftSeparator)
198
-
199
- const onMouseEnterFn = this._onMouseEnter.bind(this)
200
- column.addEventListener('mouseenter', onMouseEnterFn)
201
- this._colEvents.push({
202
- column,
203
- type: 'mouseenter',
204
- evt: onMouseEnterFn
205
- })
206
-
207
- const onMouseLeaveFn = this._onMouseLeave.bind(this)
208
- column.addEventListener('mouseleave', onMouseLeaveFn)
209
- this._colEvents.push({
210
- column,
211
- type: 'mouseleave',
212
- evt: onMouseLeaveFn
213
- })
214
- }
215
- }
216
-
217
- public updateResizersHeight(height: number) {
218
- this._separators.forEach((el) => {
219
- el.style.height = height + 'px'
220
- })
221
- }
222
-
223
- public removeResizeCapability() {
224
- this._separators.forEach((separator) => {
225
- separator.remove()
226
- })
227
-
228
- this._colEvents.forEach(({ column, type, evt }) => {
229
- (column as HTMLElement).style.position = 'inherit'
230
- column.removeEventListener(type, evt)
231
- })
232
-
233
- this._currentColumn = null
234
- this._separators = []
235
- }
236
- }
@@ -1 +0,0 @@
1
- export * from './ResizableManager'
@@ -1,120 +0,0 @@
1
- import { PropType } from 'vue-demi'
2
- import { DlEmptyStateProps } from '../../../basic/DlEmptyState/types'
3
- import { useTableActionsProps } from '../hooks/tableActions'
4
- import { commonVirtScrollProps } from '../../../shared/DlVirtualScroll/useVirtualScroll'
5
- import { useTableRowExpandProps } from '../hooks/tableRowExpand'
6
- import { useTablePaginationProps } from '../hooks/tablePagination'
7
- import { useTableFilterProps } from '../hooks/tableFilter'
8
- import { useTableSortProps } from '../hooks/tableSort'
9
- import { useTableColumnSelectionProps } from '../hooks/tableColumnSelection'
10
- import { useTableRowSelectionProps } from '../hooks/tableRowSelection'
11
- import { DlTableColumn, DlTableRow } from '../types'
12
-
13
- export const props = {
14
- columns: {
15
- type: Array as PropType<DlTableColumn[]>,
16
- default: () => [] as DlTableColumn[]
17
- },
18
- rows: {
19
- type: Array as PropType<DlTableRow[]>,
20
- default: () => [] as DlTableRow[]
21
- },
22
- rowKey: {
23
- type: [String, Function],
24
- default: 'id'
25
- },
26
- bordered: Boolean,
27
- separator: {
28
- type: String,
29
- default: 'horizontal',
30
- validator: (v: string) =>
31
- ['horizontal', 'vertical', 'cell', 'none'].includes(v)
32
- },
33
- draggable: {
34
- type: String,
35
- default: 'none',
36
- validator: (v: string) =>
37
- ['rows', 'columns', 'none', 'both'].includes(v)
38
- },
39
- title: { type: String, default: '' },
40
- color: {
41
- type: String,
42
- default: 'dl-color-darker'
43
- },
44
- loading: Boolean,
45
- dense: Boolean,
46
- resizable: Boolean,
47
- hideNoData: Boolean,
48
- hideHeader: Boolean,
49
- hideBottom: Boolean,
50
- virtualScroll: Boolean,
51
- hidePagination: Boolean,
52
- hideSelectedBanner: Boolean,
53
- selectedRowsLabel: {
54
- type: Function,
55
- default: (val: number) => `${val} records selected`
56
- },
57
- loadingLabel: {
58
- type: String,
59
- default: 'Loading...'
60
- },
61
- noResultsLabel: {
62
- type: String,
63
- default: 'There are no results to display'
64
- },
65
- noDataLabel: {
66
- type: String,
67
- default: 'No data available'
68
- },
69
- virtualScrollTarget: {
70
- type: Object as PropType<HTMLElement>,
71
- default: null as unknown as PropType<HTMLElement>
72
- },
73
- titleClass: {
74
- type: [String, Array, Object],
75
- default: null as unknown as PropType<any[]>
76
- },
77
- tableStyle: {
78
- type: [String, Array, Object],
79
- default: null as unknown as PropType<any[]>
80
- },
81
- tableClass: {
82
- type: [String, Array, Object],
83
- default: null as unknown as PropType<any[]>
84
- },
85
- tableHeaderStyle: {
86
- type: [String, Array, Object],
87
- default: null as unknown as PropType<any[]>
88
- },
89
- tableHeaderClass: {
90
- type: [String, Array, Object],
91
- default: null as unknown as PropType<any[]>
92
- },
93
- noHover: Boolean,
94
- isEmpty: Boolean,
95
- emptyStateProps: {
96
- type: Object as PropType<DlEmptyStateProps>,
97
- default: () =>
98
- ({
99
- title: '',
100
- subtitle: 'No data to show yet',
101
- icon: 'icon-dl-dataset-filled'
102
- } as unknown as PropType<DlEmptyStateProps>)
103
- },
104
- scrollDebounce: {
105
- type: Number,
106
- default: 100
107
- },
108
- flatTreeData: {
109
- type: Boolean,
110
- default: false
111
- },
112
- ...useTableActionsProps,
113
- ...commonVirtScrollProps,
114
- ...useTableRowExpandProps,
115
- ...useTablePaginationProps,
116
- ...useTableFilterProps,
117
- ...useTableSortProps,
118
- ...useTableColumnSelectionProps,
119
- ...useTableRowSelectionProps
120
- }
@@ -1,134 +0,0 @@
1
- import { PropType } from 'vue-demi'
2
- import { DlEmptyStateProps } from '../../basic/DlEmptyState/types'
3
- import { useTableActionsProps } from '../DlTable/hooks/tableActions'
4
- import { commonVirtScrollProps } from '../../shared/DlVirtualScroll/useVirtualScroll'
5
- import { useTableRowExpandProps } from '../DlTable/hooks/tableRowExpand'
6
- import { useTablePaginationProps } from '../DlTable/hooks/tablePagination'
7
- import { useTableFilterProps } from '../DlTable/hooks/tableFilter'
8
- import { useTableSortProps } from '../DlTable/hooks/tableSort'
9
- import { useTableColumnSelectionProps } from '../DlTable/hooks/tableColumnSelection'
10
- import { useTableRowSelectionProps } from '../DlTable/hooks/tableRowSelection'
11
-
12
- export const props = {
13
- columns: { type: Array, default: () => [] as Record<string, any>[] },
14
- rows: {
15
- type: Array,
16
- default: () => [] as Record<string, any>[]
17
- },
18
- rowKey: {
19
- type: [String, Function],
20
- default: 'id'
21
- },
22
- bordered: Boolean,
23
- separator: {
24
- type: String,
25
- default: 'horizontal',
26
- validator: (v: string) =>
27
- ['horizontal', 'vertical', 'cell', 'none'].includes(v)
28
- },
29
- draggable: {
30
- type: String,
31
- default: 'none',
32
- validator: (v: string) =>
33
- ['rows', 'columns', 'none', 'both'].includes(v)
34
- },
35
- title: { type: String, default: '' },
36
- color: {
37
- type: String,
38
- default: 'dl-color-darker'
39
- },
40
- loading: {
41
- type: Boolean,
42
- default: false
43
- },
44
- dense: {
45
- type: Boolean,
46
- default: false
47
- },
48
- resizable: {
49
- type: Boolean,
50
- default: false
51
- },
52
- hideNoData: {
53
- type: Boolean,
54
- default: false
55
- },
56
- hideHeader: {
57
- type: Boolean,
58
- default: false
59
- },
60
- hideBottom: {
61
- type: Boolean,
62
- default: false
63
- },
64
- virtualScroll: {
65
- type: Boolean,
66
- default: false
67
- },
68
- hidePagination: {
69
- type: Boolean,
70
- default: false
71
- },
72
- hideSelectedBanner: {
73
- type: Boolean,
74
- default: false
75
- },
76
- selectedRowsLabel: {
77
- type: Function,
78
- default: (val: number) => `${val} records selected`
79
- },
80
- loadingLabel: {
81
- type: String,
82
- default: 'Loading...'
83
- },
84
- noResultsLabel: {
85
- type: String,
86
- default: 'There are no results to display'
87
- },
88
- noDataLabel: {
89
- type: String,
90
- default: 'No data available'
91
- },
92
- virtualScrollTarget: {
93
- type: Object as PropType<HTMLElement>,
94
- default: null as unknown as PropType<HTMLElement>
95
- },
96
- titleClass: {
97
- type: [String, Array, Object],
98
- default: null as unknown as PropType<any[]>
99
- },
100
- tableStyle: {
101
- type: [String, Array, Object],
102
- default: null as unknown as PropType<any[]>
103
- },
104
- tableClass: {
105
- type: [String, Array, Object],
106
- default: null as unknown as PropType<any[]>
107
- },
108
- tableHeaderStyle: {
109
- type: [String, Array, Object],
110
- default: null as unknown as PropType<any[]>
111
- },
112
- tableHeaderClass: {
113
- type: [String, Array, Object],
114
- default: null as unknown as PropType<any[]>
115
- },
116
- noHover: Boolean,
117
- isEmpty: Boolean,
118
- emptyStateProps: {
119
- type: Object as PropType<DlEmptyStateProps>,
120
- default: null as unknown as PropType<DlEmptyStateProps>
121
- },
122
- scrollDebounce: {
123
- type: Number,
124
- default: 100
125
- },
126
- ...useTableActionsProps,
127
- ...commonVirtScrollProps,
128
- ...useTableRowExpandProps,
129
- ...useTablePaginationProps,
130
- ...useTableFilterProps,
131
- ...useTableSortProps,
132
- ...useTableColumnSelectionProps,
133
- ...useTableRowSelectionProps
134
- }
@@ -1,19 +0,0 @@
1
- import { flatMapDeep } from 'lodash'
2
-
3
- type TreeDataItem = Record<string, any>
4
-
5
- const flatten = (item: TreeDataItem): TreeDataItem[] => {
6
- if (!item.level) {
7
- item.level = 1
8
- }
9
- const leveledItems = (item.children || []).map((i: any) => {
10
- return {
11
- ...i,
12
- level: (item.level || 1) + 1
13
- }
14
- })
15
-
16
- return [item, flatMapDeep(leveledItems, flatten)]
17
- }
18
-
19
- export const flatTreeData = (data: TreeDataItem[]) => flatMapDeep(data, flatten)