@dataloop-ai/components 0.17.134 → 0.18.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 +3 -1
- package/src/App.vue +5 -227
- package/src/assets/globals.scss +4 -0
- package/src/components/basic/DlAccordion/DlAccordion.vue +26 -4
- package/src/components/basic/DlButton/DlButton.vue +2 -6
- package/src/components/basic/DlChip/DlChip.vue +1 -5
- package/src/components/basic/DlEmptyState/DlEmptyState.vue +282 -0
- package/src/components/basic/DlEmptyState/index.ts +2 -0
- package/src/components/basic/DlEmptyState/types.ts +20 -0
- package/src/components/basic/DlListItem/DlListItem.vue +96 -63
- package/src/components/basic/DlListItem/utils.ts +0 -3
- package/src/components/basic/DlPanelContainer/DlPanelContainer.vue +35 -12
- package/src/components/basic/DlPopup/DlPopup.vue +29 -7
- package/src/components/basic/DlWidget/DlWidget.vue +32 -4
- package/src/components/basic/index.ts +2 -1
- package/src/components/basic/types.ts +2 -0
- package/src/components/compound/DlCard/DlCard.vue +796 -0
- package/src/components/compound/DlCard/components/DescriptionModal.vue +137 -0
- package/src/components/compound/DlCard/types.ts +38 -0
- package/src/components/compound/DlCharts/charts/DlBarChart/DlBarChart.vue +35 -3
- package/src/components/compound/DlCharts/charts/DlColumnChart/DlColumnChart.vue +51 -12
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +71 -14
- package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChart.vue +28 -4
- package/src/components/compound/DlCharts/charts/DlDoughnutChart/components/DlDoughnutChartLegend.vue +1 -1
- package/src/components/compound/DlCharts/charts/DlLineChart/DlLineChart.vue +46 -8
- package/src/components/compound/DlCharts/components/DlBrush.vue +2 -2
- package/src/components/compound/DlCharts/types/props.ts +5 -1
- package/src/components/compound/DlCharts/utils.ts +1 -1
- package/src/components/compound/DlCodeEditor/DlCodeEditor.vue +171 -0
- package/src/components/compound/DlCodeEditor/README.md +11 -0
- package/src/components/compound/DlCodeEditor/components/CodeEditor.vue +705 -0
- package/src/components/compound/DlCodeEditor/index.ts +3 -0
- package/src/components/compound/DlCodeEditor/styles/themes-base16.css +12809 -0
- package/src/components/compound/DlCodeEditor/styles/themes.css +3999 -0
- package/src/components/compound/DlCodeEditor/types.ts +21 -0
- package/src/components/compound/DlDateTime/DlDateTimeRange/{DlCardSidebar.vue → CardSidebar.vue} +10 -11
- package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeRange.vue +8 -8
- package/src/components/compound/DlDialogBox/DlDialogBox.vue +26 -2
- package/src/components/compound/DlInput/DlInput.vue +2 -2
- package/src/components/compound/DlOptionGroup/components/MenuItemWrapper.vue +2 -2
- package/src/components/compound/DlRange/DlRange.vue +2 -2
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +1 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSuggestionsDropdown.vue +1 -1
- package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +10 -6
- package/src/components/compound/DlSelect/DlSelect.vue +78 -70
- package/src/components/compound/DlSlider/components/DlSliderBase.vue +2 -2
- package/src/components/compound/DlSlider/useSlider.ts +2 -2
- package/src/components/compound/DlStepper/DlStepper.vue +33 -3
- package/src/components/compound/DlStepper/components/DlStepperContent.vue +6 -2
- package/src/components/compound/DlStepper/components/DlStepperSidebar.vue +12 -6
- package/src/components/compound/DlTable/DlTable.vue +30 -4
- package/src/components/compound/DlTable/components/DlTd.vue +8 -8
- package/src/components/compound/DlTable/components/DlTh.vue +1 -1
- package/src/components/compound/DlTable/hooks/tableColumnSelection.ts +35 -40
- package/src/components/compound/DlTable/hooks/tableFilter.ts +33 -21
- package/src/components/compound/DlTable/hooks/tablePagination.ts +10 -13
- package/src/components/compound/DlTable/hooks/tableRowExpand.ts +2 -1
- package/src/components/compound/DlTable/hooks/tableRowSelection.ts +0 -1
- package/src/components/compound/DlTable/hooks/tableSort.ts +52 -47
- package/src/components/compound/DlThumbnailGallery/DlThumbnailGallery.vue +268 -0
- package/src/components/compound/DlThumbnailGallery/index.ts +2 -0
- package/src/components/compound/DlThumbnailGallery/types.ts +11 -0
- package/src/components/compound/DlTreeTable/DlTreeTable.vue +1293 -0
- package/src/components/compound/DlTreeTable/components/DlTdTree.vue +119 -0
- package/src/components/compound/DlTreeTable/components/DlTrTree.vue +52 -0
- package/src/components/compound/DlTreeTable/index.ts +3 -0
- package/src/components/compound/DlTreeTable/types.ts +1 -0
- package/src/components/compound/DlTreeTable/utils/convertToNestedObject.ts +51 -0
- package/src/components/compound/DlTreeTable/utils/flatTreeData.ts +19 -0
- package/src/components/compound/DlTreeTable/utils/getFromChildren.ts +39 -0
- package/src/components/compound/DlTreeTable/utils/trSpacing.ts +13 -0
- package/src/components/compound/DlTreeTable/utils/treeTableRowSelection.ts +184 -0
- package/src/components/compound/index.ts +5 -0
- package/src/components/compound/types.ts +2 -0
- package/src/components/essential/DlBadge/DlBadge.vue +3 -3
- package/src/components/essential/DlCheckbox/DlCheckbox.vue +6 -3
- package/src/components/essential/DlEllipsis/DlEllipsis.vue +18 -14
- package/src/components/essential/DlIcon/DlIcon.vue +1 -1
- package/src/components/essential/DlLabel/DlLabel.vue +174 -0
- package/src/components/essential/DlLabel/index.ts +2 -0
- package/src/components/essential/DlList/DlList.vue +2 -2
- package/src/components/essential/DlMenu/DlMenu.vue +26 -20
- package/src/components/essential/DlMenu/utils.ts +7 -6
- package/src/components/essential/DlPageLayout/DlPageLayout.vue +90 -0
- package/src/components/essential/DlPageLayout/index.ts +2 -0
- package/src/components/essential/DlSeparator/DlSeparator.vue +2 -2
- package/src/components/essential/DlThemeProvider/DlThemeProvider.vue +6 -0
- package/src/components/essential/index.ts +2 -1
- package/src/components/shared/DlTooltip/DlTooltip.vue +9 -10
- package/src/demos/BarChartDemo.vue +47 -2
- package/src/demos/ColumnChartDemo.vue +51 -2
- package/src/demos/DlAccordionDemo.vue +92 -43
- package/src/demos/DlCardDemo.vue +156 -19
- package/src/demos/DlChartDoughnutDemo.vue +49 -2
- package/src/demos/DlCheckboxDemo.vue +13 -0
- package/src/demos/DlCodeEditor/DlCodeEditorDemo.vue +247 -0
- package/src/demos/DlCodeEditor/index.ts +2 -0
- package/src/demos/DlConfusionMatrixDemo.vue +51 -6
- package/src/demos/DlDemoPage.vue +235 -0
- package/src/demos/DlDialogBoxDemo.vue +56 -51
- package/src/demos/DlDropdownButtonDemo.vue +1 -1
- package/src/demos/DlEmptyStateDemo.vue +81 -0
- package/src/demos/DlLabelDemo.vue +128 -0
- package/src/demos/DlLineChartDemo.vue +50 -2
- package/src/demos/DlListDemo.vue +12 -9
- package/src/demos/DlMenuDemo.vue +13 -14
- package/src/demos/DlPageLayoutDemo.vue +146 -0
- package/src/demos/DlPanelContainerDemo.vue +113 -2
- package/src/demos/DlPopupDemo.vue +51 -0
- package/src/demos/DlSelectDemo.vue +14 -5
- package/src/demos/DlStepperDemo/DlStepperDemo.vue +5 -1
- package/src/demos/DlStepperDemo/EmptyStateStepper.vue +149 -0
- package/src/demos/DlTableDemo.vue +65 -2
- package/src/demos/DlTabsDemo.vue +1 -1
- package/src/demos/DlThumbnailGalleryDemo.vue +99 -0
- package/src/demos/DlTreeTableDemo.vue +694 -0
- package/src/demos/DlWidgetDemo.vue +48 -3
- package/src/demos/index.ts +17 -4
- package/src/hooks/use-anchor.ts +14 -16
- package/src/hooks/use-model-toggle.ts +12 -14
- package/src/hooks/use-portal.ts +2 -2
- package/src/hooks/use-scroll-target.ts +2 -4
- package/src/hooks/use-size-observer.ts +3 -2
- package/src/hooks/use-transition.ts +10 -4
- package/src/index.ts +22 -1
- package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetFooter.vue +78 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetHeader.vue +22 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetLeftDrawer.vue +96 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetMainContent.vue +51 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/DatasetRightDrawer.vue +88 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/ActionsMenu.vue +70 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/AutomationMenu.vue +106 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardView.vue +101 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardViewGallery.vue +141 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/CardViewTable.vue +193 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/EmptyState/LayoutEmptyState.vue +227 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/EmptyState/UploadData.vue +106 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/MainContentImages.vue +540 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/MainContent/MainContentNav.vue +329 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/NavbarKpi.vue +84 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/NavbarSearch.vue +132 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/SearchFilterMenu.vue +19 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/filters/AddFilter.vue +212 -0
- package/src/layouts/DlDatasetBrowser/DemoComponents/types/imageMetadata.ts +28 -0
- package/src/layouts/DlDatasetBrowser/DlDatasetBrowser.vue +42 -0
- package/src/layouts/DlStudioLayout/DlStudioLayout.vue +42 -0
- package/src/layouts/DlStudioLayout/components/Demo/LeftMenuContent.vue +23 -0
- package/src/layouts/DlStudioLayout/components/Demo/StudioFooter.vue +25 -0
- package/src/layouts/DlStudioLayout/components/Demo/StudioHeader.vue +121 -0
- package/src/layouts/DlStudioLayout/components/Demo/StudioLeftDrawer.vue +245 -0
- package/src/layouts/DlStudioLayout/components/Demo/StudioMainContent.vue +31 -0
- package/src/layouts/DlStudioLayout/components/Demo/StudioTabsMenu.vue +117 -0
- package/src/layouts/DlStudioLayout/components/Demo/TabMenu/FilterMenu.vue +62 -0
- package/src/layouts/DlStudioLayout/components/Demo/TabMenu/TabMenuAnnotations.vue +98 -0
- package/src/layouts/DlStudioLayout/components/Demo/TabMenu/TabMenuItem.vue +66 -0
- package/src/layouts/DlStudioLayout/components/LayoutNavbar.vue +24 -0
- package/src/layouts/DlStudioLayout/components/ListAutocomplete.vue +149 -0
- package/src/layouts/DlStudioLayout/components/NavigationDrawer.vue +147 -0
- package/src/layouts/DlStudioLayout/index.ts +2 -0
- package/src/layouts/DlStudioLayout/types/HorizontalItems.ts +9 -0
- package/src/layouts/DlStudioLayout/types/VerticalItems.ts +10 -0
- package/src/simple-code-editor.d.ts +1 -0
- package/src/utils/click-outside.ts +1 -1
- package/src/utils/dom.ts +5 -5
- package/src/utils/events.ts +3 -3
- package/src/utils/global-nodes.ts +2 -2
- package/src/utils/is-ellipsis-active.ts +4 -1
- package/src/utils/portal.ts +5 -5
- package/src/utils/position-engine.ts +5 -5
- package/src/utils/render.ts +1 -1
- package/src/utils/scroll.ts +2 -2
- package/src/utils/selection.ts +3 -3
- package/vite.config.ts +9 -1
- package/src/components/basic/DlCard/DlCard.vue +0 -242
- package/src/components/basic/DlCard/types.ts +0 -20
- package/src/components/essential/DlTextHolder/DlTextHolder.vue +0 -93
- package/src/components/essential/DlTextHolder/index.ts +0 -2
- package/src/demos/DlTextHolderDemo.vue +0 -50
- /package/src/components/{basic → compound}/DlCard/index.ts +0 -0
- /package/src/components/compound/DlDateTime/DlDateTimeRange/{DlDateInput.vue → DateInput.vue} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<td
|
|
3
|
+
:class="classes"
|
|
4
|
+
:style="styles"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
ref="tableTd"
|
|
8
|
+
class="dl-table-cell-inner-div"
|
|
9
|
+
>
|
|
10
|
+
<slot name="icon" />
|
|
11
|
+
<dl-tooltip v-if="hasEllipsis">
|
|
12
|
+
<slot />
|
|
13
|
+
</dl-tooltip>
|
|
14
|
+
<slot />
|
|
15
|
+
</div>
|
|
16
|
+
</td>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import { defineComponent, getCurrentInstance, computed, ref } from 'vue-demi'
|
|
21
|
+
import { getColor } from '../../../../utils'
|
|
22
|
+
import { DlTooltip } from '../../../shared'
|
|
23
|
+
import { useSizeObserver } from '../../../../hooks/use-size-observer'
|
|
24
|
+
|
|
25
|
+
export default defineComponent({
|
|
26
|
+
name: 'DlTdTree',
|
|
27
|
+
components: {
|
|
28
|
+
DlTooltip
|
|
29
|
+
},
|
|
30
|
+
props: {
|
|
31
|
+
props: { type: Object, default: () => {} },
|
|
32
|
+
autoWidth: Boolean,
|
|
33
|
+
noHover: Boolean,
|
|
34
|
+
row: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: () => {}
|
|
37
|
+
},
|
|
38
|
+
bgColor: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ''
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
setup(props) {
|
|
44
|
+
const vm = getCurrentInstance()
|
|
45
|
+
|
|
46
|
+
const tableTd = ref(null)
|
|
47
|
+
|
|
48
|
+
const { hasEllipsis } = useSizeObserver(tableTd)
|
|
49
|
+
|
|
50
|
+
const hasOptionalProps = computed(() => {
|
|
51
|
+
return props.props !== void 0
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const tdClasses = computed(() => {
|
|
55
|
+
let classNames = 'dl-td dl-td-tree'
|
|
56
|
+
|
|
57
|
+
if (props.autoWidth) {
|
|
58
|
+
classNames = classNames.concat(' dl-table--col-auto-width')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (props.noHover) {
|
|
62
|
+
classNames = classNames.concat(' dl-td--no-hover')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return classNames
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const tdStyles = computed(() => {
|
|
69
|
+
let styles = ''
|
|
70
|
+
|
|
71
|
+
console.log(props)
|
|
72
|
+
|
|
73
|
+
if (props.bgColor) {
|
|
74
|
+
styles = styles.concat(
|
|
75
|
+
`background: ${getColor(props.bgColor, '')};`
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return styles
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const column = computed(() => {
|
|
83
|
+
const name = vm.vnode.key as string
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
(props.props.colsMap !== void 0
|
|
87
|
+
? props.props.colsMap[name]
|
|
88
|
+
: null) || props.props.col
|
|
89
|
+
)
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
if (!hasOptionalProps.value) {
|
|
93
|
+
return {
|
|
94
|
+
classes: tdClasses,
|
|
95
|
+
styles: tdStyles,
|
|
96
|
+
tableTd,
|
|
97
|
+
hasEllipsis
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (column.value === void 0) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const { row } = props.props
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
classes: tdClasses.value + column.value.tdClass(row),
|
|
109
|
+
styles: tdStyles.value + column.value.tdStyle(row),
|
|
110
|
+
tableTd,
|
|
111
|
+
hasEllipsis
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
</script>
|
|
116
|
+
|
|
117
|
+
<style scoped lang="scss">
|
|
118
|
+
@import '../../DlTable/styles/dl-table-styles.scss';
|
|
119
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tr
|
|
3
|
+
:class="trClasses"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
v-on="listeners"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
</tr>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { defineComponent, isVue2 } from 'vue-demi'
|
|
13
|
+
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: 'DlTrTree',
|
|
16
|
+
props: {
|
|
17
|
+
props: { type: Object, default: () => {} },
|
|
18
|
+
noHover: Boolean
|
|
19
|
+
},
|
|
20
|
+
computed: {
|
|
21
|
+
listeners(): any {
|
|
22
|
+
if (isVue2) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return this.$listeners
|
|
25
|
+
} else {
|
|
26
|
+
return this.$attrs
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
trClasses(): string {
|
|
30
|
+
let classes = 'dl-tr'
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
this.$props.props?.header // header slot
|
|
34
|
+
) {
|
|
35
|
+
return classes
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.$props.props?._trClass) {
|
|
39
|
+
classes = classes.concat(' ' + this.$props.props._trClass)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (this.$props.props?.noHover || this.$props.noHover) {
|
|
43
|
+
classes = classes.concat(' dl-tr--no-hover')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return classes
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style scoped src="../../DlTable/styles/dl-table-styles.scss" lang="scss" />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type RecordStringAny = Record<string, any>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RecordStringAny } from '../types'
|
|
2
|
+
import { cloneDeep } from 'lodash'
|
|
3
|
+
|
|
4
|
+
export function convertToNestedObject(selectedRows: RecordStringAny[]) {
|
|
5
|
+
const clonedSelectedRows = cloneDeep(selectedRows)
|
|
6
|
+
let selectedItems: RecordStringAny[] = []
|
|
7
|
+
|
|
8
|
+
function isObjectContained(row: RecordStringAny, rows: RecordStringAny[]) {
|
|
9
|
+
for (const rowsItem of rows) {
|
|
10
|
+
if (rowsItem.children) {
|
|
11
|
+
const indexItem = rowsItem.children.findIndex(
|
|
12
|
+
(item: RecordStringAny) => item.name === row.name
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if (indexItem > -1) {
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const filteredObjects = clonedSelectedRows.filter(
|
|
24
|
+
(obj) => !isObjectContained(obj, clonedSelectedRows)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
function deleteMissingObjects(
|
|
28
|
+
rows: RecordStringAny[],
|
|
29
|
+
filteredObjects: RecordStringAny[]
|
|
30
|
+
) {
|
|
31
|
+
const cloneFilteredObjects = filteredObjects.filter((obj) => {
|
|
32
|
+
// Check if the object's name exists in rows
|
|
33
|
+
return rows.some((row) => row.name === obj.name)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
// Recursively delete missing objects from children arrays
|
|
37
|
+
cloneFilteredObjects.forEach((obj) => {
|
|
38
|
+
if (obj.children) {
|
|
39
|
+
obj.children = deleteMissingObjects(rows, obj.children)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return cloneFilteredObjects
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
selectedItems = deleteMissingObjects(selectedRows, filteredObjects)
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
selectedItems
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cloneDeep } from 'lodash'
|
|
2
|
+
import { RecordStringAny } from '../types'
|
|
3
|
+
|
|
4
|
+
export function getFromChildren(
|
|
5
|
+
parent: RecordStringAny,
|
|
6
|
+
propsRowKey: string | Function
|
|
7
|
+
) {
|
|
8
|
+
const clonedParentRows = cloneDeep(parent)
|
|
9
|
+
const childrenKeys: string[] = []
|
|
10
|
+
const childrenCollection: RecordStringAny[] = []
|
|
11
|
+
|
|
12
|
+
childrenCollection.push(clonedParentRows)
|
|
13
|
+
|
|
14
|
+
if (typeof propsRowKey === 'function') {
|
|
15
|
+
const keys = clonedParentRows.map(propsRowKey)
|
|
16
|
+
childrenCollection.concat(keys)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function traverseChildren(parentRow: RecordStringAny) {
|
|
20
|
+
if (!parentRow) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof propsRowKey === 'string') {
|
|
25
|
+
childrenKeys.push(parentRow[propsRowKey])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!(parentRow as any)?.children) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
for (const child of (parentRow as any).children) {
|
|
32
|
+
childrenCollection.push(child)
|
|
33
|
+
traverseChildren(child)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
traverseChildren(clonedParentRows)
|
|
37
|
+
|
|
38
|
+
return { childrenKeys, childrenCollection }
|
|
39
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const setTrSpacing = (item: Record<string, any>) => {
|
|
2
|
+
let paddingLeft = 10
|
|
3
|
+
|
|
4
|
+
if (item.children) {
|
|
5
|
+
paddingLeft = item.level * 16
|
|
6
|
+
} else {
|
|
7
|
+
paddingLeft = item.level * 16 + 16
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return `padding-left: ${paddingLeft}px;`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { setTrSpacing }
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { computed, ComputedRef, ref } from 'vue-demi'
|
|
2
|
+
import { DlTableProps, DlTableRow } from '../../DlTable/types'
|
|
3
|
+
import { convertToNestedObject } from './convertToNestedObject'
|
|
4
|
+
import { RecordStringAny } from '../types'
|
|
5
|
+
|
|
6
|
+
type booleanStringPartial = boolean | 'partial'
|
|
7
|
+
|
|
8
|
+
export const useTreeTableRowSelectionProps = {
|
|
9
|
+
selection: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: 'none',
|
|
12
|
+
validator: (v: string) => ['single', 'multiple', 'none'].includes(v)
|
|
13
|
+
},
|
|
14
|
+
selected: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => [] as (string | DlTableRow)[]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const useTreeTableRowSelectionEmits = ['selection', 'selectedItems']
|
|
21
|
+
|
|
22
|
+
export function useTreeTableRowSelection(
|
|
23
|
+
props: DlTableProps,
|
|
24
|
+
emit: (event: string, val: any) => void,
|
|
25
|
+
computedRows: ComputedRef<DlTableRow[]>,
|
|
26
|
+
getRowKey: ComputedRef<(val: string | DlTableRow) => any>
|
|
27
|
+
) {
|
|
28
|
+
const selectedRows = ref<(string | DlTableRow)[]>([])
|
|
29
|
+
const selectedItemsNested = ref([])
|
|
30
|
+
|
|
31
|
+
const selectedKeys = computed(() => {
|
|
32
|
+
return selectedRows.value
|
|
33
|
+
.map(getRowKey.value)
|
|
34
|
+
.reduce((acc, key: string) => {
|
|
35
|
+
acc[key] = true
|
|
36
|
+
|
|
37
|
+
return acc
|
|
38
|
+
}, {} as Record<string, boolean>)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const hasSelectionMode = computed(() => {
|
|
42
|
+
console.log('test')
|
|
43
|
+
return props.selection !== 'none'
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const singleSelection = computed(() => {
|
|
47
|
+
return props.selection === 'single'
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const multipleSelection = computed(() => {
|
|
51
|
+
return props.selection === 'multiple'
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const allRowsSelected = computed(
|
|
55
|
+
() =>
|
|
56
|
+
computedRows.value.length > 0 &&
|
|
57
|
+
computedRows.value.every(
|
|
58
|
+
(row) => selectedKeys.value[getRowKey.value(row)] === true
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
const someRowsSelected = computed(
|
|
63
|
+
() =>
|
|
64
|
+
allRowsSelected.value !== true &&
|
|
65
|
+
computedRows.value.some(
|
|
66
|
+
(row) => selectedKeys.value[getRowKey.value(row)] === true
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const rowsSelectedNumber = computed(() => selectedRows.value.length)
|
|
71
|
+
|
|
72
|
+
function getRowByKey(rowKey: string) {
|
|
73
|
+
selectedItemsNested.value.findIndex((item) => item[rowKey] === rowKey)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function clearSelection() {
|
|
77
|
+
selectedRows.value = []
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function updateSelection(
|
|
81
|
+
keys: string[],
|
|
82
|
+
rows: (string | DlTableRow)[],
|
|
83
|
+
added: boolean,
|
|
84
|
+
evt?: (event: string, val: any) => void
|
|
85
|
+
) {
|
|
86
|
+
emit('selection', { rows, added, keys, evt })
|
|
87
|
+
/*
|
|
88
|
+
const payload =
|
|
89
|
+
singleSelection.value === true
|
|
90
|
+
? added === true
|
|
91
|
+
? rows
|
|
92
|
+
: []
|
|
93
|
+
: added === true
|
|
94
|
+
? props.selected.concat(rows as string[])
|
|
95
|
+
: props.selected.filter(
|
|
96
|
+
(row) => keys.includes(getRowKey.value(row)) === false
|
|
97
|
+
)*/
|
|
98
|
+
|
|
99
|
+
let payload: any
|
|
100
|
+
if (singleSelection.value === true) {
|
|
101
|
+
if (added === true) {
|
|
102
|
+
payload = rows
|
|
103
|
+
} else {
|
|
104
|
+
payload = []
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
if (added === true) {
|
|
108
|
+
payload = selectedRows.value.concat(rows as string[])
|
|
109
|
+
} else {
|
|
110
|
+
payload = selectedRows.value.filter(
|
|
111
|
+
(row) => !keys.includes(getRowKey.value(row))
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
selectedRows.value = payload
|
|
117
|
+
|
|
118
|
+
const { selectedItems } = convertToNestedObject(payload)
|
|
119
|
+
selectedItemsNested.value = selectedItems
|
|
120
|
+
|
|
121
|
+
emit('selectedItems', selectedItems)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function isIncludedInSelectedNestedItems(
|
|
125
|
+
row: any,
|
|
126
|
+
rowKey: string
|
|
127
|
+
): boolean {
|
|
128
|
+
const index = selectedItemsNested.value.findIndex(
|
|
129
|
+
(item) => item[rowKey] === row[rowKey]
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
return index > -1
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function isRowSelected(
|
|
136
|
+
rowKey: string | Function,
|
|
137
|
+
rowKeyValue: string
|
|
138
|
+
): booleanStringPartial {
|
|
139
|
+
let getOriginalRowByRowKey: any
|
|
140
|
+
let getSelectedRowByRowKey: RecordStringAny
|
|
141
|
+
|
|
142
|
+
if (typeof rowKey === 'string') {
|
|
143
|
+
const originalRows = selectedRows.value.filter((item) =>
|
|
144
|
+
isIncludedInSelectedNestedItems(item, rowKey)
|
|
145
|
+
)
|
|
146
|
+
getOriginalRowByRowKey = originalRows.find(
|
|
147
|
+
(originalItem: any) => originalItem[rowKey] === rowKeyValue
|
|
148
|
+
)
|
|
149
|
+
getSelectedRowByRowKey = selectedItemsNested.value.find(
|
|
150
|
+
(selectedItem: any) => {
|
|
151
|
+
if (getOriginalRowByRowKey) {
|
|
152
|
+
return (
|
|
153
|
+
selectedItem[rowKey] ===
|
|
154
|
+
getOriginalRowByRowKey[rowKey]
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
if (getSelectedRowByRowKey && getOriginalRowByRowKey) {
|
|
162
|
+
if (
|
|
163
|
+
getOriginalRowByRowKey.children?.length !==
|
|
164
|
+
getSelectedRowByRowKey.children?.length
|
|
165
|
+
) {
|
|
166
|
+
return 'partial'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return selectedKeys.value[rowKeyValue] === true
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
hasSelectionMode,
|
|
175
|
+
singleSelection,
|
|
176
|
+
multipleSelection,
|
|
177
|
+
allRowsSelected,
|
|
178
|
+
someRowsSelected,
|
|
179
|
+
rowsSelectedNumber,
|
|
180
|
+
isRowSelected,
|
|
181
|
+
clearSelection,
|
|
182
|
+
updateSelection
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -17,8 +17,13 @@ export * from './DlToast'
|
|
|
17
17
|
|
|
18
18
|
// uses other compound
|
|
19
19
|
export * from './DlDialogBox'
|
|
20
|
+
export * from './DlThumbnailGallery'
|
|
20
21
|
export * from './DlToggleButton'
|
|
22
|
+
export * from './DlTreeTable'
|
|
23
|
+
export * from './DlThumbnailGallery'
|
|
21
24
|
export * from './DlJsonEditor'
|
|
25
|
+
export * from './DlCodeEditor'
|
|
26
|
+
export * from './DlCard'
|
|
22
27
|
|
|
23
28
|
/**
|
|
24
29
|
* Moved to bottom of file as dlsmartsearch specifically uses other components here and needs to be initialized last
|
|
@@ -42,7 +42,7 @@ export default defineComponent({
|
|
|
42
42
|
|
|
43
43
|
const style = computed(() => {
|
|
44
44
|
return {
|
|
45
|
-
verticalAlign: props.align
|
|
45
|
+
verticalAlign: props.align ? props.align : null,
|
|
46
46
|
aspectRatio: hasSlot.value || props.label ? '' : '1/1',
|
|
47
47
|
padding:
|
|
48
48
|
hasSlot.value || props.label
|
|
@@ -66,10 +66,10 @@ export default defineComponent({
|
|
|
66
66
|
}-line` +
|
|
67
67
|
(props.outline === true
|
|
68
68
|
? ' dl-badge--outline'
|
|
69
|
-
: props.color
|
|
69
|
+
: props.color
|
|
70
70
|
? ` bg-${props.color}`
|
|
71
71
|
: '') +
|
|
72
|
-
(text
|
|
72
|
+
(text ? ` text-${text}` : '') +
|
|
73
73
|
(props.floating === true ? ' dl-badge--floating' : '') +
|
|
74
74
|
(props.rounded === true ? ' dl-badge--rounded' : '') +
|
|
75
75
|
(props.transparent === true ? ' dl-badge--transparent' : '')
|
|
@@ -84,7 +84,7 @@ import { getColor } from '../../../utils'
|
|
|
84
84
|
import { v4 } from 'uuid'
|
|
85
85
|
import { stopAndPrevent } from '../../../utils'
|
|
86
86
|
|
|
87
|
-
const ValueTypes = [Array, Boolean, String, Number, Object, Function
|
|
87
|
+
const ValueTypes = [Array, Boolean, String, Number, Object, Function]
|
|
88
88
|
|
|
89
89
|
export default defineComponent({
|
|
90
90
|
name: 'DlCheckbox',
|
|
@@ -116,7 +116,7 @@ export default defineComponent({
|
|
|
116
116
|
},
|
|
117
117
|
computed: {
|
|
118
118
|
identifierClass(): string {
|
|
119
|
-
return `dl-checkbox-${this.label ?? ''}`.
|
|
119
|
+
return `dl-checkbox-${this.label ?? ''}`.replace(/ /g, '-')
|
|
120
120
|
},
|
|
121
121
|
computedId(): string {
|
|
122
122
|
return `${this.id || v4()}`
|
|
@@ -155,7 +155,8 @@ export default defineComponent({
|
|
|
155
155
|
},
|
|
156
156
|
cssSvgVars(): Record<string, string> {
|
|
157
157
|
return {
|
|
158
|
-
'--dl-active-color': this.getCurrentColor()
|
|
158
|
+
'--dl-active-color': this.getCurrentColor(),
|
|
159
|
+
'min-width': '12px'
|
|
159
160
|
}
|
|
160
161
|
},
|
|
161
162
|
hasLabel(): boolean {
|
|
@@ -293,6 +294,8 @@ input {
|
|
|
293
294
|
.checkbox-label {
|
|
294
295
|
font-size: var(--dl-font-size-body);
|
|
295
296
|
color: var(--dl-color-darker);
|
|
297
|
+
overflow-wrap: break-word;
|
|
298
|
+
width: 100%;
|
|
296
299
|
}
|
|
297
300
|
.check {
|
|
298
301
|
position: absolute;
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
ref="dlEllipsisRef"
|
|
5
5
|
class="dl-ellipsis__left"
|
|
6
6
|
>
|
|
7
|
-
<slot
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
<slot
|
|
8
|
+
v-if="hasDefaultSlot"
|
|
9
|
+
name="default"
|
|
10
|
+
/>
|
|
11
|
+
<span v-else>{{ leftText }}</span>
|
|
10
12
|
</span>
|
|
11
13
|
<span
|
|
12
14
|
v-if="rightText"
|
|
@@ -21,15 +23,17 @@
|
|
|
21
23
|
:anchor="tooltipPosition"
|
|
22
24
|
:offset="tooltipOffset"
|
|
23
25
|
>
|
|
24
|
-
<slot
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
<slot
|
|
27
|
+
v-if="hasDefaultSlot"
|
|
28
|
+
name="default"
|
|
29
|
+
/>
|
|
30
|
+
<span v-else>{{ fullText }}</span>
|
|
27
31
|
</dl-tooltip>
|
|
28
32
|
</div>
|
|
29
33
|
</template>
|
|
30
34
|
|
|
31
35
|
<script lang="ts">
|
|
32
|
-
import { defineComponent, ref, computed
|
|
36
|
+
import { defineComponent, ref, computed } from 'vue-demi'
|
|
33
37
|
import { DlTooltip } from '../../shared'
|
|
34
38
|
import { useSizeObserver } from '../../../hooks/use-size-observer'
|
|
35
39
|
|
|
@@ -80,31 +84,31 @@ export default defineComponent({
|
|
|
80
84
|
// TODO: fix type issue here
|
|
81
85
|
setup(props: any, { slots }: any) {
|
|
82
86
|
const dlEllipsisRef = ref(null)
|
|
83
|
-
const textRef = toRef(props, 'text')
|
|
84
87
|
const { hasEllipsis } = useSizeObserver(dlEllipsisRef)
|
|
88
|
+
|
|
85
89
|
const hasDefaultSlot = computed(() => !!slots.default)
|
|
86
90
|
const splitIndex = computed(() => {
|
|
87
|
-
if (!
|
|
91
|
+
if (!props.text.length) return null
|
|
88
92
|
return props.split
|
|
89
|
-
? Math.round(
|
|
90
|
-
:
|
|
93
|
+
? Math.round(props.text.length * props.splitPosition)
|
|
94
|
+
: props.text.length
|
|
91
95
|
})
|
|
92
96
|
const leftText = computed(() => {
|
|
93
97
|
if (splitIndex.value !== null) {
|
|
94
|
-
return
|
|
98
|
+
return props.text.slice(0, splitIndex.value)
|
|
95
99
|
}
|
|
96
100
|
return ''
|
|
97
101
|
})
|
|
98
102
|
const rightText = computed(() => {
|
|
99
103
|
if (splitIndex.value !== null) {
|
|
100
|
-
return
|
|
104
|
+
return props.text.slice(splitIndex.value)
|
|
101
105
|
}
|
|
102
106
|
return ''
|
|
103
107
|
})
|
|
104
108
|
const shouldShowTooltip = computed(
|
|
105
109
|
() => hasEllipsis.value && props.tooltip
|
|
106
110
|
)
|
|
107
|
-
const fullText = computed(() =>
|
|
111
|
+
const fullText = computed(() => props.text)
|
|
108
112
|
|
|
109
113
|
return {
|
|
110
114
|
hasDefaultSlot,
|
|
@@ -90,7 +90,7 @@ export default defineComponent({
|
|
|
90
90
|
return {
|
|
91
91
|
'--dl-icon-font-size': `${this.size}`,
|
|
92
92
|
'--dl-icon-color': this.color
|
|
93
|
-
? // needed for now until the swap of DLBTN in OA
|
|
93
|
+
? // todo: remove this. this is needed for now until the swap of DLBTN in OA
|
|
94
94
|
getColor(
|
|
95
95
|
this.color === 'secondary'
|
|
96
96
|
? 'q-color-secondary'
|