@dataloop-ai/components 0.18.0 → 0.18.2
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 +6 -3
- package/src/App.vue +5 -227
- package/src/assets/constants.scss +2 -1
- package/src/assets/globals.scss +21 -0
- package/src/components/basic/DlAccordion/DlAccordion.vue +26 -4
- package/src/components/basic/DlAccordion/components/AccordionHeader.vue +2 -1
- package/src/components/basic/DlAvatar/DlAvatar.vue +1 -1
- package/src/components/basic/DlButton/DlButton.vue +115 -25
- package/src/components/basic/DlButton/utils.ts +45 -2
- package/src/components/basic/DlChip/DlChip.vue +3 -7
- package/src/components/basic/DlChip/utils.ts +4 -4
- package/src/components/basic/DlContainer/DlContainer.vue +70 -0
- package/src/components/basic/DlContainer/index.ts +3 -0
- 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/DlGrid/DlGrid.vue +163 -0
- package/src/components/basic/DlGrid/index.ts +4 -0
- package/src/components/basic/DlGrid/types.ts +5 -0
- package/src/components/basic/DlKpi/components/KpiInfo.vue +2 -1
- package/src/components/basic/DlListItem/DlListItem.vue +96 -66
- package/src/components/basic/DlListItem/utils.ts +0 -3
- package/src/components/basic/DlPanelContainer/DlPanelContainer.vue +37 -13
- package/src/components/basic/DlPopup/DlPopup.vue +58 -11
- package/src/components/basic/DlPopup/components/PopupHeader.vue +11 -6
- package/src/components/basic/DlProgressChart/DlProgressChart.vue +2 -1
- package/src/components/basic/DlWidget/DlWidget.vue +273 -141
- package/src/components/basic/DlWidget/index.ts +1 -3
- package/src/components/basic/DlWidget/utils.ts +90 -8
- package/src/components/basic/index.ts +4 -2
- 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 +39 -4
- package/src/components/compound/DlCharts/charts/DlColumnChart/DlColumnChart.vue +128 -36
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +167 -87
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/utils.ts +2 -1
- package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChart.vue +44 -3
- package/src/components/compound/DlCharts/charts/DlDoughnutChart/DlDoughnutChartWidget.vue +1 -2
- package/src/components/compound/DlCharts/charts/DlDoughnutChart/components/DlDoughnutChartLegend.vue +9 -18
- package/src/components/compound/DlCharts/charts/DlLineChart/DlLineChart.vue +48 -9
- package/src/components/compound/DlCharts/charts/DlScatterChart/DlScatterChart.vue +667 -0
- package/src/components/compound/DlCharts/charts/DlScatterChart/index.ts +2 -0
- package/src/components/compound/DlCharts/charts/index.ts +1 -0
- package/src/components/compound/DlCharts/components/DlBrush.vue +3 -2
- package/src/components/compound/DlCharts/components/DlChartLabels.vue +2 -1
- package/src/components/compound/DlCharts/components/DlChartScrollBar.vue +1 -0
- 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 +173 -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/DlDatePicker/DlDatePicker.vue +9 -1
- package/src/components/compound/DlDateTime/DlDatePicker/components/DlCalendar.vue +4 -2
- package/src/components/compound/DlDateTime/DlDatePicker/components/DlMonthCalendar.vue +2 -1
- package/src/components/compound/DlDateTime/DlDateTimeRange/{DlCardSidebar.vue → CardSidebar.vue} +10 -11
- package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeRange.vue +18 -9
- package/src/components/compound/DlDateTime/DlTimePicker/DlTimePicker.vue +2 -2
- package/src/components/compound/DlDialogBox/DlDialogBox.vue +74 -15
- package/src/components/compound/DlDialogBox/components/DlDialogBoxFooter.vue +1 -1
- package/src/components/compound/DlDialogBox/components/DlDialogBoxHeader.vue +9 -7
- package/src/components/compound/DlDropdownButton/DlDropdownButton.vue +13 -4
- package/src/components/compound/DlInput/DlInput.vue +80 -17
- package/src/components/compound/DlJsonEditor/DlJsonEditor.vue +42 -219
- package/src/components/compound/DlOptionGroup/DlOptionGroup.vue +16 -17
- package/src/components/compound/DlOptionGroup/components/MenuItemWrapper.vue +2 -2
- package/src/components/compound/DlPagination/DlPagination.vue +1 -1
- package/src/components/compound/DlPagination/components/PaginationLegend.vue +0 -2
- package/src/components/compound/DlPagination/components/RowsSelector.vue +0 -2
- package/src/components/compound/DlRange/DlRange.vue +3 -2
- package/src/components/compound/DlSearches/DlSearch/DlSearch.vue +12 -5
- package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +413 -97
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchFilters.vue +4 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +100 -39
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSuggestionsDropdown.vue +12 -7
- package/src/components/compound/DlSearches/DlSmartSearch/components/FiltersQuery.vue +5 -6
- package/src/components/compound/DlSearches/DlSmartSearch/types.ts +14 -0
- package/src/components/compound/DlSearches/DlSmartSearch/utils/highlightSyntax.ts +10 -6
- package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +172 -48
- package/src/components/compound/DlSelect/DlSelect.vue +264 -130
- package/src/components/compound/DlSelect/utils.ts +4 -1
- package/src/components/compound/DlSlider/DlSlider.vue +10 -2
- package/src/components/compound/DlSlider/components/DlSliderBase.vue +3 -3
- package/src/components/compound/DlSlider/components/DlSliderInput.vue +17 -26
- package/src/components/compound/DlSlider/sliderStyles.scss +5 -1
- package/src/components/compound/DlSlider/useSlider.ts +2 -2
- package/src/components/compound/DlSlider/utils.ts +2 -2
- package/src/components/compound/DlStepper/DlStepper.vue +46 -4
- package/src/components/compound/DlStepper/components/DlStepperContent.vue +6 -2
- package/src/components/compound/DlStepper/components/DlStepperFooter.vue +12 -0
- package/src/components/compound/DlStepper/components/DlStepperSidebar.vue +24 -11
- package/src/components/compound/DlStepper/models/Step.ts +37 -8
- package/src/components/compound/DlStepper/models/Stepper.ts +108 -15
- package/src/components/compound/DlStepper/models/interfaces.ts +2 -1
- package/src/components/compound/DlTable/DlTable.vue +49 -14
- package/src/components/compound/DlTable/components/DlTd.vue +9 -9
- package/src/components/compound/DlTable/components/DlTh.vue +3 -2
- 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 +18 -18
- 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/DlTable/styles/dl-table-styles.scss +8 -0
- package/src/components/compound/DlTabs/DlTabs.vue +83 -31
- package/src/components/compound/DlTabs/components/DlTab.vue +14 -4
- package/src/components/compound/DlTabs/components/TabsWrapper.vue +32 -27
- 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/DlToast/api/useToast.ts +42 -1
- package/src/components/compound/DlToast/components/ToastComponent.vue +24 -32
- package/src/components/compound/DlToast/types.ts +52 -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 +14 -1
- package/src/components/compound/types.ts +2 -0
- package/src/components/essential/DlBadge/DlBadge.vue +3 -3
- package/src/components/essential/DlCheckbox/DlCheckbox.vue +10 -7
- package/src/components/essential/DlEllipsis/DlEllipsis.vue +141 -0
- package/src/components/essential/DlIcon/DlIcon.vue +5 -5
- package/src/components/essential/DlLabel/DlLabel.vue +190 -0
- package/src/components/essential/DlLabel/index.ts +2 -0
- package/src/components/essential/DlList/DlList.vue +3 -3
- package/src/components/essential/DlMenu/DlMenu.vue +41 -22
- package/src/components/essential/DlMenu/utils.ts +8 -7
- package/src/components/essential/DlPageLayout/DlPageLayout.vue +90 -0
- package/src/components/essential/DlPageLayout/index.ts +2 -0
- package/src/components/essential/DlProgressBar/DlProgressBar.vue +1 -1
- package/src/components/essential/DlRadio/DlRadio.vue +10 -5
- package/src/components/essential/DlSeparator/DlSeparator.vue +2 -2
- package/src/components/essential/DlSpinner/index.ts +1 -13
- package/src/components/essential/DlSpinner/styles/spinnerStyles.scss +7 -0
- package/src/components/essential/DlSwitch/DlSwitch.vue +6 -3
- package/src/components/essential/DlTextArea/DlTextArea.vue +212 -7
- package/src/components/essential/DlThemeProvider/DlThemeProvider.vue +6 -0
- package/src/components/essential/DlTypography/DlTypography.vue +7 -1
- package/src/components/essential/index.ts +3 -2
- package/src/components/shared/DlInfoErrorMessage/DlInfoErrorMessage.vue +1 -1
- package/src/components/{essential → shared}/DlTooltip/DlTooltip.vue +26 -19
- package/src/components/shared/DlVirtualScroll/DlVirtualScroll.vue +106 -43
- package/src/components/shared/DlVirtualScroll/useVirtualScroll.ts +28 -4
- package/src/components/shared/index.ts +1 -0
- package/src/components/types.ts +2 -0
- package/src/demos/BarChartDemo.vue +59 -2
- package/src/demos/ColumnChartDemo.vue +67 -2
- package/src/demos/DlAccordionDemo.vue +92 -43
- package/src/demos/DlAlertDemo.vue +14 -0
- package/src/demos/DlButtonDemo.vue +41 -4
- package/src/demos/DlCardDemo.vue +156 -19
- package/src/demos/DlChartDoughnutDemo.vue +49 -2
- package/src/demos/DlCheckboxDemo.vue +28 -3
- package/src/demos/DlCodeEditor/DlCodeEditorDemo.vue +247 -0
- package/src/demos/DlCodeEditor/index.ts +2 -0
- package/src/demos/DlConfusionMatrixDemo.vue +93 -37
- package/src/demos/DlDemoPage.vue +235 -0
- package/src/demos/DlDialogBoxDemo.vue +56 -51
- package/src/demos/DlDropdownButtonDemo.vue +35 -27
- package/src/demos/DlEmptyStateDemo.vue +81 -0
- package/src/demos/DlGridDemo.vue +40 -0
- package/src/demos/DlInputDemo.vue +21 -1
- package/src/demos/DlJsonEditorDemo.vue +59 -0
- package/src/demos/DlLabelDemo.vue +208 -0
- package/src/demos/DlLineChartDemo.vue +50 -2
- package/src/demos/DlListDemo.vue +12 -9
- package/src/demos/DlMenuDemo.vue +147 -20
- package/src/demos/DlPageLayoutDemo.vue +146 -0
- package/src/demos/DlPanelContainerDemo.vue +113 -2
- package/src/demos/DlPopupDemo.vue +82 -1
- package/src/demos/DlRadioDemo.vue +16 -1
- package/src/demos/DlScatterChartDemo.vue +161 -0
- package/src/demos/DlSearchDemo.vue +9 -0
- package/src/demos/DlSelectDemo.vue +124 -27
- package/src/demos/DlSpinnerDemo.vue +0 -2
- package/src/demos/DlStepperDemo/DlStepperDemo.vue +5 -1
- package/src/demos/DlStepperDemo/EmptyStateStepper.vue +149 -0
- package/src/demos/DlStepperDemo/SimpleStepper.vue +4 -0
- package/src/demos/DlStepperDemo/steps/GeneralStep.vue +1 -0
- package/src/demos/DlSwitchDemo.vue +12 -0
- package/src/demos/DlTableDemo.vue +84 -5
- package/src/demos/DlTabsDemo.vue +92 -3
- package/src/demos/DlTextAreaDemo.vue +14 -17
- package/src/demos/DlThumbnailGalleryDemo.vue +99 -0
- package/src/demos/DlToastDemo.vue +3 -9
- package/src/demos/DlTooltipDemo.vue +66 -2
- package/src/demos/DlTreeTableDemo.vue +694 -0
- package/src/demos/DlVirtualScrollDemo.vue +3 -12
- package/src/demos/DlWidgetDemo.vue +252 -61
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +151 -32
- package/src/demos/index.ts +23 -4
- package/src/hooks/use-anchor.ts +15 -17
- package/src/hooks/use-arrow-navigation.ts +64 -21
- package/src/hooks/use-model-toggle.ts +14 -16
- package/src/hooks/use-portal.ts +9 -3
- package/src/hooks/use-scroll-target.ts +2 -4
- package/src/hooks/use-size-observer.ts +3 -2
- package/src/hooks/use-suggestions.ts +239 -49
- 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/input-sizes.ts +5 -2
- package/src/utils/is-ellipsis-active.ts +4 -1
- package/src/utils/parse-smart-query.ts +209 -111
- package/src/utils/portal.ts +5 -5
- package/src/utils/position-engine.ts +7 -7
- 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 -241
- package/src/components/basic/DlCard/types.ts +0 -20
- package/src/components/basic/DlEllipsis/DlEllipsis.vue +0 -114
- package/src/components/basic/DlWidget/DlGrid.vue +0 -33
- package/src/components/basic/DlWidget/DlGridRow.vue +0 -32
- package/src/components/compound/DlSearches/DlSmartSearch/utils/utils.ts +0 -124
- package/src/components/compound/DlToast/utils/config.ts +0 -17
- package/src/components/essential/DlTextHolder/DlTextHolder.vue +0 -65
- package/src/components/essential/DlTextHolder/index.ts +0 -2
- package/src/demos/DlTextHolderDemo.vue +0 -42
- package/src/utils/swapNodes.ts +0 -30
- /package/src/components/{basic → compound}/DlCard/index.ts +0 -0
- /package/src/components/compound/DlDateTime/DlDateTimeRange/{DlDateInput.vue → DateInput.vue} +0 -0
- /package/src/components/{basic → essential}/DlEllipsis/index.ts +0 -0
- /package/src/components/{essential → shared}/DlTooltip/index.ts +0 -0
|
@@ -0,0 +1,1293 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
ref="rootRef"
|
|
5
|
+
:class="containerClass"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
ref="dragRef"
|
|
9
|
+
class="dl-table__drag"
|
|
10
|
+
/>
|
|
11
|
+
<!-- Top Slots -->
|
|
12
|
+
<div
|
|
13
|
+
v-if="hasTopSlots"
|
|
14
|
+
class="dl-table__top row items-center"
|
|
15
|
+
>
|
|
16
|
+
<slot
|
|
17
|
+
v-bind="marginalsScope"
|
|
18
|
+
name="top"
|
|
19
|
+
>
|
|
20
|
+
<slot
|
|
21
|
+
v-if="hasTopSelectionMode"
|
|
22
|
+
v-bind="marginalsScope"
|
|
23
|
+
name="top-selection"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
v-else
|
|
28
|
+
class="dl-table__control"
|
|
29
|
+
>
|
|
30
|
+
<slot
|
|
31
|
+
name="top-left"
|
|
32
|
+
v-bind="marginalsScope"
|
|
33
|
+
>
|
|
34
|
+
<div
|
|
35
|
+
v-if="title"
|
|
36
|
+
class="dl-table__control"
|
|
37
|
+
>
|
|
38
|
+
<div :class="titleClasses">
|
|
39
|
+
{{ title }}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</slot>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div class="dl-table__separator col" />
|
|
46
|
+
<div class="dl-table__control">
|
|
47
|
+
<slot
|
|
48
|
+
name="top-right"
|
|
49
|
+
v-bind="marginalsScope"
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
</slot>
|
|
53
|
+
</div>
|
|
54
|
+
<!-- -->
|
|
55
|
+
|
|
56
|
+
<!-- Virtual scroll -->
|
|
57
|
+
<DlVirtualScroll
|
|
58
|
+
v-if="hasVirtScroll"
|
|
59
|
+
ref="virtScrollRef"
|
|
60
|
+
type="__dltable"
|
|
61
|
+
:class="tableClass"
|
|
62
|
+
:style="tableStyle"
|
|
63
|
+
:table-colspan="computedColspan"
|
|
64
|
+
:scroll-target="virtualScrollTarget"
|
|
65
|
+
:items="computedRows"
|
|
66
|
+
v-bind="virtProps"
|
|
67
|
+
@virtual-scroll="onVScroll"
|
|
68
|
+
>
|
|
69
|
+
<template #before>
|
|
70
|
+
<thead>
|
|
71
|
+
<slot
|
|
72
|
+
v-if="!hideHeader"
|
|
73
|
+
name="header"
|
|
74
|
+
v-bind="getHeaderScope({ header: true })"
|
|
75
|
+
>
|
|
76
|
+
<DlTrTree>
|
|
77
|
+
<th
|
|
78
|
+
v-if="hasDraggableRows"
|
|
79
|
+
class="dl-table--col-auto-with empty-col"
|
|
80
|
+
:data-resizable="false"
|
|
81
|
+
/>
|
|
82
|
+
<th
|
|
83
|
+
v-if="singleSelection"
|
|
84
|
+
class="dl-table--col-auto-with"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<th
|
|
88
|
+
v-else-if="multipleSelection"
|
|
89
|
+
class="dl-table--col-auto-with dl-table--col-checkbox-wrapper"
|
|
90
|
+
:data-resizable="false"
|
|
91
|
+
>
|
|
92
|
+
<slot
|
|
93
|
+
name="header-selection"
|
|
94
|
+
v-bind="getHeaderScope({})"
|
|
95
|
+
>
|
|
96
|
+
<DlCheckbox
|
|
97
|
+
style="padding-left: 10px"
|
|
98
|
+
:color="color"
|
|
99
|
+
:model-value="headerSelectedValue"
|
|
100
|
+
:indeterminate-value="
|
|
101
|
+
selectionCheckboxIndeterminateVal
|
|
102
|
+
"
|
|
103
|
+
@update:model-value="
|
|
104
|
+
onMultipleSelectionSet
|
|
105
|
+
"
|
|
106
|
+
/>
|
|
107
|
+
</slot>
|
|
108
|
+
</th>
|
|
109
|
+
|
|
110
|
+
<slot
|
|
111
|
+
v-for="col in computedCols"
|
|
112
|
+
v-bind="getHeaderScope({ col })"
|
|
113
|
+
:name="
|
|
114
|
+
hasSlotByName(`header-cell-${col.name}`)
|
|
115
|
+
? `header-cell-${col.name}`
|
|
116
|
+
: 'header-cell'
|
|
117
|
+
"
|
|
118
|
+
>
|
|
119
|
+
<DlTh
|
|
120
|
+
:key="col.name"
|
|
121
|
+
:props="getHeaderScope({ col })"
|
|
122
|
+
>
|
|
123
|
+
{{ col.label }}
|
|
124
|
+
</DlTh>
|
|
125
|
+
</slot>
|
|
126
|
+
</DlTrTree>
|
|
127
|
+
|
|
128
|
+
<tr
|
|
129
|
+
v-if="loading && !hasLoadingSlot"
|
|
130
|
+
class="dl-table__progress"
|
|
131
|
+
>
|
|
132
|
+
<th
|
|
133
|
+
:colspan="computedColspan"
|
|
134
|
+
class="relative-position"
|
|
135
|
+
>
|
|
136
|
+
<dl-progress-bar
|
|
137
|
+
indeterminate
|
|
138
|
+
:color="color"
|
|
139
|
+
/>
|
|
140
|
+
</th>
|
|
141
|
+
</tr>
|
|
142
|
+
</slot>
|
|
143
|
+
</thead>
|
|
144
|
+
</template>
|
|
145
|
+
<template #default="props">
|
|
146
|
+
<DlTr
|
|
147
|
+
v-show="
|
|
148
|
+
props.item.isExpandedParent || props.item.level === 1
|
|
149
|
+
"
|
|
150
|
+
:key="getRowKey(props.item)"
|
|
151
|
+
:class="
|
|
152
|
+
isRowSelected(rowKey, getRowKey(props.item))
|
|
153
|
+
? 'selected'
|
|
154
|
+
: hasAnyAction
|
|
155
|
+
? ' cursor-pointer'
|
|
156
|
+
: ''
|
|
157
|
+
"
|
|
158
|
+
:no-hover="noHover"
|
|
159
|
+
@click="onTrClick($event, props.item, props.pageIndex)"
|
|
160
|
+
@dblclick="
|
|
161
|
+
onTrDblClick($event, props.item, props.pageIndex)
|
|
162
|
+
"
|
|
163
|
+
@contextmenu="
|
|
164
|
+
onTrContextMenu($event, props.item, props.pageIndex)
|
|
165
|
+
"
|
|
166
|
+
>
|
|
167
|
+
<td
|
|
168
|
+
v-if="hasDraggableRows"
|
|
169
|
+
class="dl-table__drag-icon"
|
|
170
|
+
>
|
|
171
|
+
<dl-icon
|
|
172
|
+
class="draggable-icon"
|
|
173
|
+
icon="icon-dl-drag"
|
|
174
|
+
size="12px"
|
|
175
|
+
/>
|
|
176
|
+
</td>
|
|
177
|
+
<td
|
|
178
|
+
v-if="hasSelectionMode"
|
|
179
|
+
class="dl-table--col-auto-with"
|
|
180
|
+
>
|
|
181
|
+
<slot
|
|
182
|
+
name="body-selection"
|
|
183
|
+
v-bind="
|
|
184
|
+
getBodySelectionScope({
|
|
185
|
+
key: getRowKey(props.item),
|
|
186
|
+
row: props.item,
|
|
187
|
+
pageIndex: props.pageIndex
|
|
188
|
+
})
|
|
189
|
+
"
|
|
190
|
+
>
|
|
191
|
+
<DlCheckbox
|
|
192
|
+
style="padding-left: 10px"
|
|
193
|
+
:color="color"
|
|
194
|
+
:model-value="
|
|
195
|
+
isRowSelected(rowKey, getRowKey(props.item))
|
|
196
|
+
"
|
|
197
|
+
:indeterminate-value="true"
|
|
198
|
+
:false-value="false"
|
|
199
|
+
:true-value="true"
|
|
200
|
+
@update:model-value="
|
|
201
|
+
(adding, evt) =>
|
|
202
|
+
updateSelectionIerarchy(
|
|
203
|
+
adding,
|
|
204
|
+
evt,
|
|
205
|
+
props.item
|
|
206
|
+
)
|
|
207
|
+
"
|
|
208
|
+
/>
|
|
209
|
+
</slot>
|
|
210
|
+
</td>
|
|
211
|
+
<slot
|
|
212
|
+
v-for="(col, colIndex) in computedCols"
|
|
213
|
+
v-bind="
|
|
214
|
+
getBodyCellScope({
|
|
215
|
+
key: getRowKey(props.item),
|
|
216
|
+
row: props.item,
|
|
217
|
+
pageIndex: props.pageIndex,
|
|
218
|
+
col
|
|
219
|
+
})
|
|
220
|
+
"
|
|
221
|
+
:name="
|
|
222
|
+
hasSlotByName(`body-cell-${col.name}`)
|
|
223
|
+
? `body-cell-${col.name}`
|
|
224
|
+
: 'body-cell'
|
|
225
|
+
"
|
|
226
|
+
>
|
|
227
|
+
<DlTdTree
|
|
228
|
+
:class="col.tdClass(props.item)"
|
|
229
|
+
:style="
|
|
230
|
+
col.tdStyle(props.item) +
|
|
231
|
+
getTdStyles(props.item, colIndex)
|
|
232
|
+
"
|
|
233
|
+
:no-hover="noHover"
|
|
234
|
+
>
|
|
235
|
+
<template #icon="{}">
|
|
236
|
+
<DlIcon
|
|
237
|
+
v-if="
|
|
238
|
+
(props.item.children || []).length >
|
|
239
|
+
0 && colIndex === 0
|
|
240
|
+
"
|
|
241
|
+
:icon="`icon-dl-${
|
|
242
|
+
props.item.expanded ? 'down' : 'right'
|
|
243
|
+
}-chevron`"
|
|
244
|
+
@click="
|
|
245
|
+
updateExpandedRow(
|
|
246
|
+
!props.item.expanded,
|
|
247
|
+
getRowKey(props.item)
|
|
248
|
+
)
|
|
249
|
+
"
|
|
250
|
+
/>
|
|
251
|
+
</template>
|
|
252
|
+
{{ getCellValue(col, props.item) }}
|
|
253
|
+
</DlTdTree>
|
|
254
|
+
</slot>
|
|
255
|
+
</DlTr>
|
|
256
|
+
</template>
|
|
257
|
+
</DlVirtualScroll>
|
|
258
|
+
<!-- -->
|
|
259
|
+
|
|
260
|
+
<div
|
|
261
|
+
v-else
|
|
262
|
+
class="dl-table__middle scroll"
|
|
263
|
+
>
|
|
264
|
+
<table
|
|
265
|
+
class="dl-table"
|
|
266
|
+
:class="additionalClasses"
|
|
267
|
+
>
|
|
268
|
+
<thead>
|
|
269
|
+
<slot
|
|
270
|
+
v-if="!hideHeader"
|
|
271
|
+
name="header"
|
|
272
|
+
v-bind="getHeaderScope({ header: true })"
|
|
273
|
+
>
|
|
274
|
+
<DlTr>
|
|
275
|
+
<th
|
|
276
|
+
v-if="hasDraggableRows"
|
|
277
|
+
class="dl-table--col-auto-with empty-col"
|
|
278
|
+
:data-resizable="false"
|
|
279
|
+
/>
|
|
280
|
+
|
|
281
|
+
<th
|
|
282
|
+
v-if="singleSelection"
|
|
283
|
+
class="dl-table--col-auto-with"
|
|
284
|
+
/>
|
|
285
|
+
|
|
286
|
+
<th
|
|
287
|
+
v-else-if="multipleSelection"
|
|
288
|
+
class="dl-table--col-auto-with dl-table--col-checkbox-wrapper"
|
|
289
|
+
:data-resizable="false"
|
|
290
|
+
>
|
|
291
|
+
<slot
|
|
292
|
+
name="header-selection"
|
|
293
|
+
v-bind="getHeaderScope({})"
|
|
294
|
+
>
|
|
295
|
+
<DlCheckbox
|
|
296
|
+
style="padding-left: 10px"
|
|
297
|
+
:color="color"
|
|
298
|
+
:model-value="headerSelectedValue"
|
|
299
|
+
:indeterminate-value="true"
|
|
300
|
+
@update:model-value="
|
|
301
|
+
onMultipleSelectionSet
|
|
302
|
+
"
|
|
303
|
+
/>
|
|
304
|
+
</slot>
|
|
305
|
+
</th>
|
|
306
|
+
|
|
307
|
+
<slot
|
|
308
|
+
v-for="col in computedCols"
|
|
309
|
+
v-bind="getHeaderScope({ col, onThClick })"
|
|
310
|
+
:name="
|
|
311
|
+
hasSlotByName(`header-cell-${col.name}`)
|
|
312
|
+
? `header-cell-${col.name}`
|
|
313
|
+
: 'header-cell'
|
|
314
|
+
"
|
|
315
|
+
>
|
|
316
|
+
<DlTh
|
|
317
|
+
:key="col.name"
|
|
318
|
+
:props="getHeaderScope({ col })"
|
|
319
|
+
@click="onThClick($event, col.name)"
|
|
320
|
+
>
|
|
321
|
+
{{ col.label }}
|
|
322
|
+
</DlTh>
|
|
323
|
+
</slot>
|
|
324
|
+
</DlTr>
|
|
325
|
+
|
|
326
|
+
<tr
|
|
327
|
+
v-if="loading && !hasLoadingSlot"
|
|
328
|
+
class="dl-table__progress"
|
|
329
|
+
>
|
|
330
|
+
<th
|
|
331
|
+
:colspan="computedColspan"
|
|
332
|
+
class="relative-position"
|
|
333
|
+
>
|
|
334
|
+
<dl-progress-bar
|
|
335
|
+
indeterminate
|
|
336
|
+
:color="color"
|
|
337
|
+
/>
|
|
338
|
+
</th>
|
|
339
|
+
</tr>
|
|
340
|
+
</slot>
|
|
341
|
+
</thead>
|
|
342
|
+
<tbody id="draggable">
|
|
343
|
+
<slot
|
|
344
|
+
name="top-row"
|
|
345
|
+
:cols="computedCols"
|
|
346
|
+
/>
|
|
347
|
+
<slot
|
|
348
|
+
v-for="(row, pageIndex) in computedRows"
|
|
349
|
+
v-bind="
|
|
350
|
+
getBodyScope({
|
|
351
|
+
key: getRowKey(row),
|
|
352
|
+
row,
|
|
353
|
+
pageIndex,
|
|
354
|
+
trClass: isRowSelected(rowKey, getRowKey(row))
|
|
355
|
+
? 'selected'
|
|
356
|
+
: ''
|
|
357
|
+
})
|
|
358
|
+
"
|
|
359
|
+
name="body"
|
|
360
|
+
>
|
|
361
|
+
<DlTrTree
|
|
362
|
+
v-show="row.isExpandedParent || row.level === 1"
|
|
363
|
+
:key="getRowKey(row)"
|
|
364
|
+
:class="
|
|
365
|
+
isRowSelected(rowKey, getRowKey(row))
|
|
366
|
+
? 'selected'
|
|
367
|
+
: hasAnyAction
|
|
368
|
+
? ' cursor-pointer'
|
|
369
|
+
: ''
|
|
370
|
+
"
|
|
371
|
+
:no-hover="noHover"
|
|
372
|
+
@click="onTrClick($event, row, pageIndex)"
|
|
373
|
+
@dblclick="onTrDblClick($event, row, pageIndex)"
|
|
374
|
+
@contextmenu="
|
|
375
|
+
onTrContextMenu($event, row, pageIndex)
|
|
376
|
+
"
|
|
377
|
+
>
|
|
378
|
+
<td v-if="hasDraggableRows">
|
|
379
|
+
<dl-icon
|
|
380
|
+
class="draggable-icon"
|
|
381
|
+
icon="icon-dl-drag"
|
|
382
|
+
size="12px"
|
|
383
|
+
/>
|
|
384
|
+
</td>
|
|
385
|
+
<td
|
|
386
|
+
v-if="hasSelectionMode"
|
|
387
|
+
class="dl-table--col-auto-with"
|
|
388
|
+
>
|
|
389
|
+
<slot
|
|
390
|
+
name="body-selection"
|
|
391
|
+
v-bind="
|
|
392
|
+
getBodySelectionScope({
|
|
393
|
+
key: getRowKey(row),
|
|
394
|
+
row,
|
|
395
|
+
pageIndex
|
|
396
|
+
})
|
|
397
|
+
"
|
|
398
|
+
>
|
|
399
|
+
<!--
|
|
400
|
+
Here we have to change
|
|
401
|
+
-->
|
|
402
|
+
<DlCheckbox
|
|
403
|
+
style="padding-left: 10px"
|
|
404
|
+
:color="color"
|
|
405
|
+
:model-value="
|
|
406
|
+
isRowSelected(
|
|
407
|
+
rowKey,
|
|
408
|
+
getRowKey(row)
|
|
409
|
+
)
|
|
410
|
+
"
|
|
411
|
+
toggle-indeterminate
|
|
412
|
+
:indeterminate-value="true"
|
|
413
|
+
:false-value="false"
|
|
414
|
+
:true-value="true"
|
|
415
|
+
@update:model-value="
|
|
416
|
+
(adding, evt) =>
|
|
417
|
+
updateSelectionIerarchy(
|
|
418
|
+
adding,
|
|
419
|
+
evt,
|
|
420
|
+
row
|
|
421
|
+
)
|
|
422
|
+
"
|
|
423
|
+
/>
|
|
424
|
+
</slot>
|
|
425
|
+
</td>
|
|
426
|
+
<slot
|
|
427
|
+
v-for="(col, colIndex) in computedCols"
|
|
428
|
+
v-bind="
|
|
429
|
+
getBodyCellScope({
|
|
430
|
+
key: getRowKey(row),
|
|
431
|
+
row,
|
|
432
|
+
pageIndex,
|
|
433
|
+
col
|
|
434
|
+
})
|
|
435
|
+
"
|
|
436
|
+
:name="
|
|
437
|
+
hasSlotByName(`body-cell-${col.name}`)
|
|
438
|
+
? `body-cell-${col.name}`
|
|
439
|
+
: 'body-cell'
|
|
440
|
+
"
|
|
441
|
+
>
|
|
442
|
+
<DlTdTree
|
|
443
|
+
:class="col.tdClass(row)"
|
|
444
|
+
:style="
|
|
445
|
+
col.tdStyle(row) +
|
|
446
|
+
getTdStyles(row, colIndex)
|
|
447
|
+
"
|
|
448
|
+
>
|
|
449
|
+
<template #icon="{}">
|
|
450
|
+
<DlIcon
|
|
451
|
+
v-if="
|
|
452
|
+
(row.children || []).length >
|
|
453
|
+
0 && colIndex === 0
|
|
454
|
+
"
|
|
455
|
+
:icon="`icon-dl-${
|
|
456
|
+
row.expanded ? 'down' : 'right'
|
|
457
|
+
}-chevron`"
|
|
458
|
+
@click="
|
|
459
|
+
updateExpandedRow(
|
|
460
|
+
!row.expanded,
|
|
461
|
+
getRowKey(row)
|
|
462
|
+
)
|
|
463
|
+
"
|
|
464
|
+
/>
|
|
465
|
+
</template>
|
|
466
|
+
{{ getCellValue(col, row) }}
|
|
467
|
+
</DlTdTree>
|
|
468
|
+
</slot>
|
|
469
|
+
</DlTrTree>
|
|
470
|
+
</slot>
|
|
471
|
+
<slot
|
|
472
|
+
name="bottom-row"
|
|
473
|
+
:cols="computedCols"
|
|
474
|
+
/>
|
|
475
|
+
</tbody>
|
|
476
|
+
</table>
|
|
477
|
+
</div>
|
|
478
|
+
|
|
479
|
+
<div
|
|
480
|
+
v-if="!hideBottom"
|
|
481
|
+
:class="bottomClasses"
|
|
482
|
+
>
|
|
483
|
+
<div class="dl-table__control">
|
|
484
|
+
<slot
|
|
485
|
+
v-if="nothingToDisplay && !hideNoData"
|
|
486
|
+
name="no-data"
|
|
487
|
+
>
|
|
488
|
+
{{ bottomMessage }}
|
|
489
|
+
</slot>
|
|
490
|
+
</div>
|
|
491
|
+
<div class="dl-table__control">
|
|
492
|
+
<slot
|
|
493
|
+
name="bottom"
|
|
494
|
+
v-bind="marginalsScope"
|
|
495
|
+
>
|
|
496
|
+
<div
|
|
497
|
+
v-if="hasBotomSelectionBanner"
|
|
498
|
+
class="dl-table__control"
|
|
499
|
+
>
|
|
500
|
+
<div>
|
|
501
|
+
{{ selectedRowsLabel(rowsSelectedNumber) }}
|
|
502
|
+
</div>
|
|
503
|
+
</div>
|
|
504
|
+
|
|
505
|
+
<slot
|
|
506
|
+
v-bind="marginalsScope"
|
|
507
|
+
name="pagination"
|
|
508
|
+
>
|
|
509
|
+
<dl-pagination
|
|
510
|
+
v-if="displayPagination"
|
|
511
|
+
v-bind="marginalsScope.pagination"
|
|
512
|
+
@update:rowsPerPage="
|
|
513
|
+
(v) => setPagination({ rowsPerPage: v })
|
|
514
|
+
"
|
|
515
|
+
@update:modelValue="
|
|
516
|
+
(v) => setPagination({ page: v })
|
|
517
|
+
"
|
|
518
|
+
/>
|
|
519
|
+
</slot>
|
|
520
|
+
</slot>
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
|
|
524
|
+
<slot
|
|
525
|
+
v-if="loading"
|
|
526
|
+
name="loading"
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
</template>
|
|
530
|
+
|
|
531
|
+
<script lang="ts">
|
|
532
|
+
import {
|
|
533
|
+
defineComponent,
|
|
534
|
+
computed,
|
|
535
|
+
ref,
|
|
536
|
+
PropType,
|
|
537
|
+
watch,
|
|
538
|
+
getCurrentInstance,
|
|
539
|
+
ComputedRef
|
|
540
|
+
} from 'vue-demi'
|
|
541
|
+
import {
|
|
542
|
+
useTablePagination,
|
|
543
|
+
useTablePaginationState,
|
|
544
|
+
useTablePaginationProps
|
|
545
|
+
} from '../DlTable/hooks/tablePagination'
|
|
546
|
+
import DlTr from '../DlTable/components/DlTr.vue'
|
|
547
|
+
import DlTh from '../DlTable/components/DlTh.vue'
|
|
548
|
+
import DlTrTree from './components/DlTrTree.vue'
|
|
549
|
+
import DlTdTree from './components/DlTdTree.vue'
|
|
550
|
+
import {
|
|
551
|
+
commonVirtPropsList,
|
|
552
|
+
commonVirtScrollProps,
|
|
553
|
+
ScrollDetails
|
|
554
|
+
} from '../../shared/DlVirtualScroll/useVirtualScroll'
|
|
555
|
+
import DlVirtualScroll from '../../shared/DlVirtualScroll/DlVirtualScroll.vue'
|
|
556
|
+
import {
|
|
557
|
+
useTableFilter,
|
|
558
|
+
useTableFilterProps
|
|
559
|
+
} from '../DlTable/hooks/tableFilter'
|
|
560
|
+
import { useTableSort, useTableSortProps } from '../DlTable/hooks/tableSort'
|
|
561
|
+
import {
|
|
562
|
+
useTreeTableRowSelection,
|
|
563
|
+
useTreeTableRowSelectionProps,
|
|
564
|
+
useTreeTableRowSelectionEmits
|
|
565
|
+
} from './utils/treeTableRowSelection'
|
|
566
|
+
import {
|
|
567
|
+
useTableColumnSelection,
|
|
568
|
+
useTableColumnSelectionProps
|
|
569
|
+
} from '../DlTable/hooks/tableColumnSelection'
|
|
570
|
+
import {
|
|
571
|
+
useTableRowExpand,
|
|
572
|
+
useTableRowExpandProps,
|
|
573
|
+
useTableRowExpandEmits
|
|
574
|
+
} from '../DlTable/hooks/tableRowExpand'
|
|
575
|
+
import {
|
|
576
|
+
useTableActionsProps,
|
|
577
|
+
useTableActions
|
|
578
|
+
} from '../DlTable/hooks/tableActions'
|
|
579
|
+
import { injectProp } from '../../../utils/inject-object-prop'
|
|
580
|
+
import { DlTableRow, DlTableProps, DlTableColumn } from '../DlTable/types'
|
|
581
|
+
import { DlPagination } from '../DlPagination'
|
|
582
|
+
import { DlIcon, DlCheckbox, DlProgressBar } from '../../essential'
|
|
583
|
+
import { flatTreeData } from './utils/flatTreeData'
|
|
584
|
+
import { setTrSpacing } from './utils/trSpacing'
|
|
585
|
+
import { v4 } from 'uuid'
|
|
586
|
+
import { RecordStringAny } from './types'
|
|
587
|
+
import { getFromChildren } from './utils/getFromChildren'
|
|
588
|
+
|
|
589
|
+
export default defineComponent({
|
|
590
|
+
name: 'DlTreeTable',
|
|
591
|
+
components: {
|
|
592
|
+
DlTr,
|
|
593
|
+
DlTh,
|
|
594
|
+
DlPagination,
|
|
595
|
+
DlProgressBar,
|
|
596
|
+
DlIcon,
|
|
597
|
+
DlCheckbox,
|
|
598
|
+
DlTrTree,
|
|
599
|
+
DlTdTree,
|
|
600
|
+
DlVirtualScroll
|
|
601
|
+
},
|
|
602
|
+
props: {
|
|
603
|
+
columns: { type: Array, default: () => [] as RecordStringAny[] },
|
|
604
|
+
rows: {
|
|
605
|
+
type: Array,
|
|
606
|
+
default: () => [] as RecordStringAny[]
|
|
607
|
+
},
|
|
608
|
+
rowKey: {
|
|
609
|
+
type: [String, Function],
|
|
610
|
+
default: 'id'
|
|
611
|
+
},
|
|
612
|
+
bordered: Boolean,
|
|
613
|
+
separator: {
|
|
614
|
+
type: String,
|
|
615
|
+
default: 'horizontal',
|
|
616
|
+
validator: (v: string) =>
|
|
617
|
+
['horizontal', 'vertical', 'cell', 'none'].includes(v)
|
|
618
|
+
},
|
|
619
|
+
draggable: {
|
|
620
|
+
type: String,
|
|
621
|
+
default: 'none',
|
|
622
|
+
validator: (v: string) =>
|
|
623
|
+
['rows', 'columns', 'none', 'both'].includes(v)
|
|
624
|
+
},
|
|
625
|
+
title: { type: String, default: null },
|
|
626
|
+
color: {
|
|
627
|
+
type: String,
|
|
628
|
+
default: 'dl-color-darker'
|
|
629
|
+
},
|
|
630
|
+
loading: Boolean,
|
|
631
|
+
dense: Boolean,
|
|
632
|
+
resizable: Boolean,
|
|
633
|
+
hideNoData: Boolean,
|
|
634
|
+
hideHeader: Boolean,
|
|
635
|
+
hideBottom: Boolean,
|
|
636
|
+
virtualScroll: Boolean,
|
|
637
|
+
hidePagination: Boolean,
|
|
638
|
+
hideSelectedBanner: Boolean,
|
|
639
|
+
selectedRowsLabel: {
|
|
640
|
+
type: Function,
|
|
641
|
+
default: (val: number) => `${val} records selected`
|
|
642
|
+
},
|
|
643
|
+
loadingLabel: {
|
|
644
|
+
type: String,
|
|
645
|
+
default: 'Loading...'
|
|
646
|
+
},
|
|
647
|
+
noResultsLabel: {
|
|
648
|
+
type: String,
|
|
649
|
+
default: 'There are no results to display'
|
|
650
|
+
},
|
|
651
|
+
noDataLabel: {
|
|
652
|
+
type: String,
|
|
653
|
+
default: 'No data available'
|
|
654
|
+
},
|
|
655
|
+
virtualScrollTarget: {
|
|
656
|
+
type: Object as PropType<HTMLElement>,
|
|
657
|
+
default: void 0
|
|
658
|
+
},
|
|
659
|
+
titleClass: {
|
|
660
|
+
type: [String, Array, Object],
|
|
661
|
+
default: null
|
|
662
|
+
},
|
|
663
|
+
tableStyle: {
|
|
664
|
+
type: [String, Array, Object],
|
|
665
|
+
default: null
|
|
666
|
+
},
|
|
667
|
+
tableClass: {
|
|
668
|
+
type: [String, Array, Object],
|
|
669
|
+
default: null
|
|
670
|
+
},
|
|
671
|
+
tableHeaderStyle: {
|
|
672
|
+
type: [String, Array, Object],
|
|
673
|
+
default: null
|
|
674
|
+
},
|
|
675
|
+
tableHeaderClass: {
|
|
676
|
+
type: [String, Array, Object],
|
|
677
|
+
default: null
|
|
678
|
+
},
|
|
679
|
+
noHover: Boolean,
|
|
680
|
+
...useTableActionsProps,
|
|
681
|
+
...commonVirtScrollProps,
|
|
682
|
+
...useTableRowExpandProps,
|
|
683
|
+
...useTablePaginationProps,
|
|
684
|
+
...useTableFilterProps,
|
|
685
|
+
...useTableSortProps,
|
|
686
|
+
...useTableColumnSelectionProps,
|
|
687
|
+
...useTreeTableRowSelectionProps
|
|
688
|
+
},
|
|
689
|
+
emits: [
|
|
690
|
+
'request',
|
|
691
|
+
'virtual-scroll',
|
|
692
|
+
'row-reorder',
|
|
693
|
+
'col-reorder',
|
|
694
|
+
'row-click',
|
|
695
|
+
'th-click',
|
|
696
|
+
'row-dblclick',
|
|
697
|
+
'row-contextmenu',
|
|
698
|
+
...useTableRowExpandEmits,
|
|
699
|
+
...useTreeTableRowSelectionEmits
|
|
700
|
+
],
|
|
701
|
+
setup(props, { emit, slots }) {
|
|
702
|
+
const vm = getCurrentInstance()
|
|
703
|
+
|
|
704
|
+
const rootRef = ref(null)
|
|
705
|
+
const virtScrollRef = ref(null)
|
|
706
|
+
const hasVirtScroll = computed(() => props.virtualScroll === true)
|
|
707
|
+
|
|
708
|
+
const { hasAnyAction } = useTableActions(props) // todo: does not work
|
|
709
|
+
|
|
710
|
+
const getRowKey = computed(() =>
|
|
711
|
+
typeof props.rowKey === 'function'
|
|
712
|
+
? props.rowKey
|
|
713
|
+
: (row: RecordStringAny) => row[props.rowKey as string]
|
|
714
|
+
)
|
|
715
|
+
|
|
716
|
+
// table slots
|
|
717
|
+
const hasSlotByName = (name: string) => !!slots[name]
|
|
718
|
+
|
|
719
|
+
const hasPaginationSlot = computed(() => hasSlotByName('pagination'))
|
|
720
|
+
|
|
721
|
+
const hasTopSlots = computed(
|
|
722
|
+
() =>
|
|
723
|
+
!!slots['top'] ||
|
|
724
|
+
!!slots['top-left'] ||
|
|
725
|
+
!!slots['top-right'] ||
|
|
726
|
+
!!slots['top-selection']
|
|
727
|
+
)
|
|
728
|
+
//
|
|
729
|
+
|
|
730
|
+
// table class names
|
|
731
|
+
const __containerClass = computed(() => {
|
|
732
|
+
let classNames = `dl-table__container dl-table--${props.separator}-separator column no-wrap dl-table--no-wrap`
|
|
733
|
+
|
|
734
|
+
if (props.bordered) {
|
|
735
|
+
classNames = classNames + ' dl-table--bordered'
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
if (props.dense) {
|
|
739
|
+
classNames = classNames + ' dl-table--dense'
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return classNames
|
|
743
|
+
})
|
|
744
|
+
|
|
745
|
+
const containerClass = computed(() => {
|
|
746
|
+
let classNames = __containerClass.value
|
|
747
|
+
|
|
748
|
+
if (props.loading) {
|
|
749
|
+
classNames = classNames + ' dl-table--loading'
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return classNames
|
|
753
|
+
})
|
|
754
|
+
|
|
755
|
+
const nothingToDisplay = computed(() => computedRows.value.length === 0)
|
|
756
|
+
|
|
757
|
+
const titleClasses = computed(
|
|
758
|
+
() => 'dl-table__title ' + (props.titleClass || '')
|
|
759
|
+
)
|
|
760
|
+
|
|
761
|
+
const bottomClasses = computed(() => {
|
|
762
|
+
let classNames = 'dl-table__bottom row items-center'
|
|
763
|
+
|
|
764
|
+
if (nothingToDisplay.value && !props.hideNoData) {
|
|
765
|
+
// TODO add styles for this class
|
|
766
|
+
classNames = classNames + ' dl-table__bottom--nodata'
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
return classNames
|
|
770
|
+
})
|
|
771
|
+
//
|
|
772
|
+
|
|
773
|
+
const bottomMessage = computed(() => {
|
|
774
|
+
if (props.loading) {
|
|
775
|
+
return props.loadingLabel
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (props.filter) {
|
|
779
|
+
return props.noResultsLabel
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
return props.noDataLabel
|
|
783
|
+
})
|
|
784
|
+
|
|
785
|
+
const getTdStyles = (
|
|
786
|
+
row: (typeof computedRows.value)[number],
|
|
787
|
+
colIndex: number
|
|
788
|
+
) => {
|
|
789
|
+
let styles = ''
|
|
790
|
+
if (colIndex === 0) {
|
|
791
|
+
styles = 'max-width: 100px; box-sizing: border-box;'
|
|
792
|
+
styles =
|
|
793
|
+
styles +
|
|
794
|
+
setTrSpacing({
|
|
795
|
+
...row,
|
|
796
|
+
colIndex
|
|
797
|
+
})
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
return styles
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
const hasDraggableRows = computed(() =>
|
|
804
|
+
['rows', 'both'].includes(props.draggable)
|
|
805
|
+
)
|
|
806
|
+
const hasDraggableColumns = computed(() =>
|
|
807
|
+
['columns', 'both'].includes(props.draggable)
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
const { innerPagination, computedPagination, setPagination } =
|
|
811
|
+
useTablePaginationState(vm, getCellValue)
|
|
812
|
+
|
|
813
|
+
const { computedFilterMethod } = useTableFilter(props, setPagination)
|
|
814
|
+
|
|
815
|
+
const { isRowExpanded, setExpanded, updateExpanded } =
|
|
816
|
+
useTableRowExpand(props, emit)
|
|
817
|
+
|
|
818
|
+
const tableRows = ref(props.rows)
|
|
819
|
+
|
|
820
|
+
const filteredSortedRows = computed(() => {
|
|
821
|
+
let rows = tableRows.value as DlTableRow[]
|
|
822
|
+
|
|
823
|
+
if (tableRows.value.length === 0) {
|
|
824
|
+
return rows
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const { sortBy, descending } = computedPagination.value
|
|
828
|
+
|
|
829
|
+
if (props.filter) {
|
|
830
|
+
rows = computedFilterMethod.value(
|
|
831
|
+
rows,
|
|
832
|
+
props.filter,
|
|
833
|
+
computedCols.value,
|
|
834
|
+
getCellValue
|
|
835
|
+
)
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
if (columnToSort.value !== null) {
|
|
839
|
+
rows = computedSortMethod.value(
|
|
840
|
+
tableRows.value === rows ? rows.slice() : rows,
|
|
841
|
+
sortBy,
|
|
842
|
+
descending
|
|
843
|
+
)
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
return rows
|
|
847
|
+
})
|
|
848
|
+
|
|
849
|
+
const updateExpandedRow = (
|
|
850
|
+
isExpanded: boolean,
|
|
851
|
+
name: string,
|
|
852
|
+
rowsArr = tableRows.value
|
|
853
|
+
) => {
|
|
854
|
+
(rowsArr as DlTableRow[]).some((o) => {
|
|
855
|
+
if (o.name === name) {
|
|
856
|
+
o.expanded = isExpanded
|
|
857
|
+
updateNestedRows(o, isExpanded)
|
|
858
|
+
} else {
|
|
859
|
+
if ((o.children || []).length > 0) {
|
|
860
|
+
updateExpandedRow(isExpanded, name, o.children)
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
})
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
const updateNestedRows = (
|
|
867
|
+
row: (typeof computedRows.value)[number],
|
|
868
|
+
isExpanded: boolean
|
|
869
|
+
) => {
|
|
870
|
+
if ((row.children || []).length > 0) {
|
|
871
|
+
row.children.forEach(
|
|
872
|
+
(r: (typeof computedRows.value)[number]) => {
|
|
873
|
+
r.isExpandedParent = isExpanded
|
|
874
|
+
|
|
875
|
+
if (!isExpanded) {
|
|
876
|
+
r.expanded = isExpanded
|
|
877
|
+
updateNestedRows(r, isExpanded)
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
)
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const filteredSortedRowsNumber = computed(
|
|
885
|
+
() => filteredSortedRows.value.length
|
|
886
|
+
)
|
|
887
|
+
|
|
888
|
+
const computedRows = computed(() => {
|
|
889
|
+
let rows = filteredSortedRows.value
|
|
890
|
+
|
|
891
|
+
const { rowsPerPage } = computedPagination.value
|
|
892
|
+
|
|
893
|
+
if (rowsPerPage !== 0) {
|
|
894
|
+
if (firstRowIndex.value === 0 && tableRows.value !== rows) {
|
|
895
|
+
if (rows.length > lastRowIndex.value) {
|
|
896
|
+
rows = rows.slice(0, lastRowIndex.value)
|
|
897
|
+
}
|
|
898
|
+
} else {
|
|
899
|
+
rows = rows.slice(firstRowIndex.value, lastRowIndex.value)
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
rows = flatTreeData(rows)
|
|
904
|
+
|
|
905
|
+
return rows
|
|
906
|
+
})
|
|
907
|
+
|
|
908
|
+
const additionalClasses = computed(() => {
|
|
909
|
+
const classes = []
|
|
910
|
+
|
|
911
|
+
if (hasDraggableRows.value === true) {
|
|
912
|
+
classes.push('dl-table--draggable-rows')
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
if (hasDraggableColumns.value === true) {
|
|
916
|
+
classes.push('dl-table--draggable-columns')
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
return classes
|
|
920
|
+
})
|
|
921
|
+
|
|
922
|
+
const displayPagination = computed(
|
|
923
|
+
() => !(props.hidePagination || nothingToDisplay.value)
|
|
924
|
+
)
|
|
925
|
+
|
|
926
|
+
const {
|
|
927
|
+
hasSelectionMode,
|
|
928
|
+
singleSelection,
|
|
929
|
+
multipleSelection,
|
|
930
|
+
allRowsSelected,
|
|
931
|
+
someRowsSelected,
|
|
932
|
+
rowsSelectedNumber,
|
|
933
|
+
|
|
934
|
+
isRowSelected,
|
|
935
|
+
clearSelection,
|
|
936
|
+
updateSelection
|
|
937
|
+
} = useTreeTableRowSelection(
|
|
938
|
+
props as unknown as DlTableProps,
|
|
939
|
+
emit,
|
|
940
|
+
computedRows,
|
|
941
|
+
getRowKey as ComputedRef<(val: string | DlTableRow) => any>
|
|
942
|
+
)
|
|
943
|
+
|
|
944
|
+
const { colList, computedCols, computedColsMap, computedColspan } =
|
|
945
|
+
useTableColumnSelection(
|
|
946
|
+
props as unknown as DlTableProps,
|
|
947
|
+
computedPagination,
|
|
948
|
+
hasSelectionMode,
|
|
949
|
+
hasDraggableRows
|
|
950
|
+
)
|
|
951
|
+
|
|
952
|
+
const { columnToSort, computedSortMethod, sort } = useTableSort(
|
|
953
|
+
props as unknown as DlTableProps,
|
|
954
|
+
computedPagination,
|
|
955
|
+
colList,
|
|
956
|
+
setPagination
|
|
957
|
+
)
|
|
958
|
+
|
|
959
|
+
const headerSelectedValue = computed(() =>
|
|
960
|
+
someRowsSelected.value === true ? null : allRowsSelected.value
|
|
961
|
+
)
|
|
962
|
+
|
|
963
|
+
const selectionCheckboxIndeterminateVal = computed<boolean>(
|
|
964
|
+
() =>
|
|
965
|
+
multipleSelection.value === true &&
|
|
966
|
+
computedRows.value.length > 0 &&
|
|
967
|
+
computedRows.value.length < tableRows.value.length
|
|
968
|
+
)
|
|
969
|
+
|
|
970
|
+
function onMultipleSelectionSet(val: boolean) {
|
|
971
|
+
if (someRowsSelected.value === true) {
|
|
972
|
+
val = false
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
updateSelection(
|
|
976
|
+
computedRows.value.map(getRowKey.value as any),
|
|
977
|
+
computedRows.value,
|
|
978
|
+
val
|
|
979
|
+
)
|
|
980
|
+
}
|
|
981
|
+
function updateSelectionIerarchy(
|
|
982
|
+
adding: boolean,
|
|
983
|
+
event: any,
|
|
984
|
+
row: any
|
|
985
|
+
) {
|
|
986
|
+
const { childrenKeys, childrenCollection } = getFromChildren(
|
|
987
|
+
row,
|
|
988
|
+
props.rowKey
|
|
989
|
+
)
|
|
990
|
+
|
|
991
|
+
updateSelection(childrenKeys, childrenCollection, adding, event)
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
const hasTopSelectionMode = computed(() => {
|
|
995
|
+
return (
|
|
996
|
+
hasSelectionMode.value === true && rowsSelectedNumber.value > 0
|
|
997
|
+
)
|
|
998
|
+
})
|
|
999
|
+
|
|
1000
|
+
const hasBotomSelectionBanner = computed(() => {
|
|
1001
|
+
return (
|
|
1002
|
+
props.hideSelectedBanner !== true &&
|
|
1003
|
+
hasSelectionMode.value === true &&
|
|
1004
|
+
rowsSelectedNumber.value > 0
|
|
1005
|
+
)
|
|
1006
|
+
})
|
|
1007
|
+
|
|
1008
|
+
const {
|
|
1009
|
+
firstRowIndex,
|
|
1010
|
+
lastRowIndex,
|
|
1011
|
+
isFirstPage,
|
|
1012
|
+
isLastPage,
|
|
1013
|
+
pagesNumber,
|
|
1014
|
+
computedRowsNumber,
|
|
1015
|
+
firstPage,
|
|
1016
|
+
prevPage,
|
|
1017
|
+
nextPage,
|
|
1018
|
+
lastPage
|
|
1019
|
+
} = useTablePagination(
|
|
1020
|
+
vm,
|
|
1021
|
+
computedPagination,
|
|
1022
|
+
setPagination,
|
|
1023
|
+
filteredSortedRowsNumber
|
|
1024
|
+
)
|
|
1025
|
+
|
|
1026
|
+
function getHeaderScope(data: RecordStringAny) {
|
|
1027
|
+
Object.assign(data, {
|
|
1028
|
+
cols: computedCols.value,
|
|
1029
|
+
sort,
|
|
1030
|
+
colsMap: computedColsMap.value,
|
|
1031
|
+
color: props.color,
|
|
1032
|
+
dense: props.dense
|
|
1033
|
+
})
|
|
1034
|
+
|
|
1035
|
+
if (multipleSelection.value === true) {
|
|
1036
|
+
injectProp(
|
|
1037
|
+
data,
|
|
1038
|
+
'selected',
|
|
1039
|
+
() => headerSelectedValue.value,
|
|
1040
|
+
onMultipleSelectionSet
|
|
1041
|
+
)
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return data
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
// Virtual scroll functionality
|
|
1048
|
+
|
|
1049
|
+
const virtProps = computed(() => {
|
|
1050
|
+
const acc: RecordStringAny = {}
|
|
1051
|
+
|
|
1052
|
+
commonVirtPropsList.forEach((p) => {
|
|
1053
|
+
acc[p] = (props as RecordStringAny)[p]
|
|
1054
|
+
})
|
|
1055
|
+
|
|
1056
|
+
if (!acc.virtualScrollItemSize) {
|
|
1057
|
+
acc.virtualScrollItemSize = props.dense === true ? 30 : 40
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
return acc
|
|
1061
|
+
})
|
|
1062
|
+
|
|
1063
|
+
const marginalsScope = computed(() => ({
|
|
1064
|
+
pagination: paginationState.value,
|
|
1065
|
+
pagesNumber: pagesNumber.value,
|
|
1066
|
+
isFirstPage: isFirstPage.value,
|
|
1067
|
+
isLastPage: isLastPage.value,
|
|
1068
|
+
firstPage,
|
|
1069
|
+
prevPage,
|
|
1070
|
+
nextPage,
|
|
1071
|
+
lastPage
|
|
1072
|
+
}))
|
|
1073
|
+
|
|
1074
|
+
function getCellValue(col: RecordStringAny, row: RecordStringAny) {
|
|
1075
|
+
const val =
|
|
1076
|
+
typeof col.field === 'function'
|
|
1077
|
+
? col.field(row)
|
|
1078
|
+
: row[col.field]
|
|
1079
|
+
return col.format !== void 0 ? col.format(val, row) : val
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
function resetVirtualScroll() {
|
|
1083
|
+
if (hasVirtScroll.value === true) {
|
|
1084
|
+
virtScrollRef.value.reset()
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
function scrollTo(toIndex: string | number, edge?: string) {
|
|
1089
|
+
if (virtScrollRef.value !== null) {
|
|
1090
|
+
virtScrollRef.value.scrollTo(toIndex, edge)
|
|
1091
|
+
return
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
toIndex = parseInt(toIndex as string, 10)
|
|
1095
|
+
const rowEl = rootRef.value.querySelector(
|
|
1096
|
+
`tbody tr:nth-of-type(${toIndex + 1})`
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1099
|
+
if (rowEl !== null) {
|
|
1100
|
+
const scrollTarget = rootRef.value.querySelector(
|
|
1101
|
+
'.dl-table__middle.scroll'
|
|
1102
|
+
)
|
|
1103
|
+
const offsetTop =
|
|
1104
|
+
rowEl.offsetTop -
|
|
1105
|
+
(props.virtualScrollStickySizeStart as number)
|
|
1106
|
+
const direction =
|
|
1107
|
+
offsetTop < scrollTarget.scrollTop ? 'decrease' : 'increase'
|
|
1108
|
+
|
|
1109
|
+
scrollTarget.scrollTop = offsetTop
|
|
1110
|
+
|
|
1111
|
+
emit('virtual-scroll', {
|
|
1112
|
+
index: toIndex,
|
|
1113
|
+
from: 0,
|
|
1114
|
+
to: innerPagination.value.rowsPerPage - 1,
|
|
1115
|
+
direction
|
|
1116
|
+
})
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
function onVScroll(info: ScrollDetails) {
|
|
1121
|
+
emit('virtual-scroll', info)
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
//
|
|
1125
|
+
|
|
1126
|
+
const onThClick = (evt: MouseEvent, name: string) => {
|
|
1127
|
+
emit('th-click', evt, computedRows.value, name)
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
const onTrClick = (
|
|
1131
|
+
evt: MouseEvent,
|
|
1132
|
+
row: DlTableRow,
|
|
1133
|
+
pageIndex: number
|
|
1134
|
+
) => {
|
|
1135
|
+
emit('row-click', evt, row, pageIndex)
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
const onTrDblClick = (
|
|
1139
|
+
evt: MouseEvent,
|
|
1140
|
+
row: DlTableRow,
|
|
1141
|
+
pageIndex: number
|
|
1142
|
+
) => {
|
|
1143
|
+
emit('row-dblclick', evt, row, pageIndex)
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
const onTrContextMenu = (
|
|
1147
|
+
evt: MouseEvent,
|
|
1148
|
+
row: DlTableRow,
|
|
1149
|
+
pageIndex: number
|
|
1150
|
+
) => {
|
|
1151
|
+
emit('row-contextmenu', evt, row, pageIndex)
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
function injectBodyCommonScope(data: RecordStringAny) {
|
|
1155
|
+
Object.assign(data, {
|
|
1156
|
+
cols: computedCols.value,
|
|
1157
|
+
colsMap: computedColsMap.value,
|
|
1158
|
+
sort,
|
|
1159
|
+
rowIndex: firstRowIndex.value + data.pageIndex,
|
|
1160
|
+
color: props.color,
|
|
1161
|
+
dense: props.dense,
|
|
1162
|
+
noHover: props.noHover
|
|
1163
|
+
})
|
|
1164
|
+
|
|
1165
|
+
if (hasSelectionMode.value === true) {
|
|
1166
|
+
injectProp(
|
|
1167
|
+
data,
|
|
1168
|
+
'selected',
|
|
1169
|
+
() => isRowSelected(props.rowKey, data.key),
|
|
1170
|
+
(adding: boolean, evt: any) => {
|
|
1171
|
+
updateSelection([data.key], [data.row], adding, evt)
|
|
1172
|
+
}
|
|
1173
|
+
)
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
injectProp(
|
|
1177
|
+
data,
|
|
1178
|
+
'expand',
|
|
1179
|
+
() => isRowExpanded(data.key),
|
|
1180
|
+
(adding) => {
|
|
1181
|
+
updateExpanded(data.key, adding)
|
|
1182
|
+
}
|
|
1183
|
+
)
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
function getBodyScope(data: RecordStringAny) {
|
|
1187
|
+
injectBodyCommonScope(data)
|
|
1188
|
+
|
|
1189
|
+
data.cols = data.cols.map((col: DlTableColumn) =>
|
|
1190
|
+
Object.defineProperty({ ...col }, 'value', {
|
|
1191
|
+
get: () => getCellValue(col, data.row),
|
|
1192
|
+
enumerable: true
|
|
1193
|
+
})
|
|
1194
|
+
)
|
|
1195
|
+
|
|
1196
|
+
return data
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function getBodyCellScope(data: RecordStringAny) {
|
|
1200
|
+
injectBodyCommonScope(data)
|
|
1201
|
+
injectProp(data, 'value', () => getCellValue(data.col, data.row))
|
|
1202
|
+
|
|
1203
|
+
return data
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
function getBodySelectionScope(data: RecordStringAny) {
|
|
1207
|
+
injectBodyCommonScope(data)
|
|
1208
|
+
return data
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
const hasLoadingSlot = computed(() => slots['loading'] !== void 0)
|
|
1212
|
+
|
|
1213
|
+
const paginationState = computed(() => {
|
|
1214
|
+
return {
|
|
1215
|
+
...computedPagination.value,
|
|
1216
|
+
'update:rowsPerPage': (rowsPerPage: number) =>
|
|
1217
|
+
setPagination({ rowsPerPage }),
|
|
1218
|
+
'update:modelValue': (page: number) => setPagination({ page }),
|
|
1219
|
+
modelValue: computedPagination.value.page,
|
|
1220
|
+
totalItems: computedRowsNumber.value
|
|
1221
|
+
}
|
|
1222
|
+
})
|
|
1223
|
+
|
|
1224
|
+
// expose public methods and needed computed props
|
|
1225
|
+
Object.assign(vm.proxy, {
|
|
1226
|
+
resetVirtualScroll,
|
|
1227
|
+
scrollTo,
|
|
1228
|
+
setExpanded,
|
|
1229
|
+
sort,
|
|
1230
|
+
firstPage,
|
|
1231
|
+
prevPage,
|
|
1232
|
+
nextPage,
|
|
1233
|
+
lastPage
|
|
1234
|
+
})
|
|
1235
|
+
|
|
1236
|
+
return {
|
|
1237
|
+
uuid: `dl-table-${v4()}`,
|
|
1238
|
+
rootRef,
|
|
1239
|
+
containerClass,
|
|
1240
|
+
computedRows,
|
|
1241
|
+
computedCols,
|
|
1242
|
+
computedColspan,
|
|
1243
|
+
getRowKey,
|
|
1244
|
+
additionalClasses,
|
|
1245
|
+
getHeaderScope,
|
|
1246
|
+
virtScrollRef,
|
|
1247
|
+
hasVirtScroll,
|
|
1248
|
+
virtProps,
|
|
1249
|
+
onVScroll,
|
|
1250
|
+
hasSlotByName,
|
|
1251
|
+
hasDraggableRows,
|
|
1252
|
+
hasDraggableColumns,
|
|
1253
|
+
marginalsScope,
|
|
1254
|
+
titleClasses,
|
|
1255
|
+
bottomClasses,
|
|
1256
|
+
hasTopSlots,
|
|
1257
|
+
nothingToDisplay,
|
|
1258
|
+
bottomMessage,
|
|
1259
|
+
paginationState,
|
|
1260
|
+
hasTopSelectionMode,
|
|
1261
|
+
hasBotomSelectionBanner,
|
|
1262
|
+
rowsSelectedNumber,
|
|
1263
|
+
singleSelection,
|
|
1264
|
+
multipleSelection,
|
|
1265
|
+
headerSelectedValue,
|
|
1266
|
+
selectionCheckboxIndeterminateVal,
|
|
1267
|
+
onMultipleSelectionSet,
|
|
1268
|
+
getBodyScope,
|
|
1269
|
+
isRowSelected,
|
|
1270
|
+
getCellValue,
|
|
1271
|
+
getBodyCellScope,
|
|
1272
|
+
hasSelectionMode,
|
|
1273
|
+
getBodySelectionScope,
|
|
1274
|
+
hasAnyAction,
|
|
1275
|
+
updateSelection,
|
|
1276
|
+
setPagination,
|
|
1277
|
+
hasLoadingSlot,
|
|
1278
|
+
displayPagination,
|
|
1279
|
+
onTrClick,
|
|
1280
|
+
onTrDblClick,
|
|
1281
|
+
onThClick,
|
|
1282
|
+
onTrContextMenu,
|
|
1283
|
+
hasPaginationSlot,
|
|
1284
|
+
setTrSpacing,
|
|
1285
|
+
updateExpandedRow,
|
|
1286
|
+
getTdStyles,
|
|
1287
|
+
updateSelectionIerarchy
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
})
|
|
1291
|
+
</script>
|
|
1292
|
+
|
|
1293
|
+
<style scoped src="../DlTable/styles/dl-table-styles.scss" lang="scss" />
|