@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
package/src/hooks/use-anchor.ts
CHANGED
|
@@ -15,15 +15,24 @@ interface AnchorEvent extends KeyboardEvent {
|
|
|
15
15
|
dlAnchorHandled?: boolean
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
interface AnchorElements {
|
|
19
|
+
hide: Function
|
|
20
|
+
toggle?: Function
|
|
21
|
+
toggleKey: Function
|
|
22
|
+
contextClick: Function
|
|
23
|
+
prevent: Function
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export const useAnchorProps = {
|
|
19
27
|
target: {
|
|
28
|
+
type: [String, Boolean],
|
|
20
29
|
default: true
|
|
21
30
|
},
|
|
22
31
|
noParentEvent: Boolean,
|
|
23
32
|
contextMenu: Boolean
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
export default function ({
|
|
35
|
+
export default function useAnchor({
|
|
27
36
|
configureAnchorEl
|
|
28
37
|
}: {
|
|
29
38
|
configureAnchorEl?: Function
|
|
@@ -38,22 +47,12 @@ export default function ({
|
|
|
38
47
|
// abort with no parent configured or on multi-touch
|
|
39
48
|
return anchorEl?.value === null
|
|
40
49
|
? false
|
|
41
|
-
: evt
|
|
42
|
-
evt.touches === void 0 ||
|
|
43
|
-
evt.touches.length <= 1
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface AnchorElements {
|
|
47
|
-
hide: Function
|
|
48
|
-
toggle?: Function
|
|
49
|
-
toggleKey: Function
|
|
50
|
-
contextClick: Function
|
|
51
|
-
prevent: Function
|
|
50
|
+
: !evt || !evt.touches || evt.touches.length <= 1
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
const anchorEvents: Partial<AnchorElements> = {}
|
|
55
54
|
|
|
56
|
-
if (configureAnchorEl
|
|
55
|
+
if (!configureAnchorEl && proxy) {
|
|
57
56
|
// default configureAnchorEl is designed for
|
|
58
57
|
// DlMenu & DlPopupProxy (which is why it's handled here)
|
|
59
58
|
|
|
@@ -70,7 +69,7 @@ export default function ({
|
|
|
70
69
|
},
|
|
71
70
|
|
|
72
71
|
toggleKey(evt: AnchorEvent) {
|
|
73
|
-
if (isKeyCode(evt, 13) && anchorEvents.toggle
|
|
72
|
+
if (isKeyCode(evt, 13) && anchorEvents.toggle) {
|
|
74
73
|
anchorEvents.toggle(evt)
|
|
75
74
|
}
|
|
76
75
|
},
|
|
@@ -144,16 +143,15 @@ export default function ({
|
|
|
144
143
|
setAnchorEl(proxy.$el.parentNode as HTMLElement)
|
|
145
144
|
} else {
|
|
146
145
|
let el = props.target
|
|
147
|
-
|
|
148
146
|
if (typeof props.target === 'string') {
|
|
149
147
|
try {
|
|
150
148
|
el = document.querySelector(props.target)
|
|
151
149
|
} catch (err) {
|
|
152
|
-
el =
|
|
150
|
+
el = null
|
|
153
151
|
}
|
|
154
152
|
}
|
|
155
153
|
|
|
156
|
-
if (el
|
|
154
|
+
if (el) {
|
|
157
155
|
anchorEl.value = (el as any).$el || el // cannot use VUE type to work on both vue versions, so let it be any
|
|
158
156
|
if (configureAnchorEl) {
|
|
159
157
|
configureAnchorEl()
|
|
@@ -1,41 +1,84 @@
|
|
|
1
|
-
import { ref, onMounted, onBeforeUnmount } from 'vue-demi'
|
|
1
|
+
import { ref, isRef, onMounted, onBeforeUnmount, computed } from 'vue-demi'
|
|
2
|
+
|
|
3
|
+
type ItemType = Record<string, any> | string
|
|
2
4
|
|
|
3
5
|
export function useArrowNavigation(items: any, isOpen: any) {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
+
const selectItem = ref<ItemType | null>(null)
|
|
7
|
+
const highlightIndex = ref<number>(-1)
|
|
8
|
+
|
|
9
|
+
const itemsData = computed(() => (isRef(items) ? items.value : items))
|
|
10
|
+
const isMenuOpen = computed(() => (isRef(isOpen) ? isOpen.value : isOpen))
|
|
6
11
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
const selectedItem = computed({
|
|
13
|
+
get: () => selectItem.value,
|
|
14
|
+
set: (value: ItemType) => {
|
|
15
|
+
selectItem.value = value
|
|
10
16
|
}
|
|
11
|
-
}
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
})
|
|
18
|
+
const highlightedIndex = computed({
|
|
19
|
+
get: () => highlightIndex.value,
|
|
20
|
+
set: (value: number) => {
|
|
21
|
+
highlightIndex.value = value
|
|
15
22
|
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const itemsLength = computed<number>(() => itemsData.value.length)
|
|
26
|
+
|
|
27
|
+
const decrementHighlightedIndex = (): void => {
|
|
28
|
+
highlightedIndex.value -= 1
|
|
16
29
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
30
|
+
const incrementHighlightedIndex = (): void => {
|
|
31
|
+
highlightedIndex.value += 1
|
|
32
|
+
}
|
|
33
|
+
const resetHighlightedIndex = (): void => {
|
|
34
|
+
highlightedIndex.value = -1
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const isEligibleToHandleEnter = computed<boolean>(() => {
|
|
38
|
+
return (
|
|
19
39
|
highlightedIndex.value >= 0 &&
|
|
20
|
-
highlightedIndex.value <
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
highlightedIndex.value < itemsLength.value
|
|
41
|
+
)
|
|
42
|
+
})
|
|
43
|
+
const isEligibleToIncrementHighlightedIndex = computed<boolean>(() => {
|
|
44
|
+
return highlightedIndex.value < itemsLength.value - 1
|
|
45
|
+
})
|
|
46
|
+
const isEligibleToDecrementHighlightedIndex = computed<boolean>(() => {
|
|
47
|
+
return highlightedIndex.value > 0
|
|
48
|
+
})
|
|
49
|
+
const isNotEligibleToHandleArrows = computed<boolean>(() => {
|
|
50
|
+
return !itemsLength.value || !isMenuOpen.value
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const handleArrowUp = (event: KeyboardEvent) => {
|
|
54
|
+
event.preventDefault()
|
|
55
|
+
if (isEligibleToDecrementHighlightedIndex.value) {
|
|
56
|
+
decrementHighlightedIndex()
|
|
24
57
|
}
|
|
25
58
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
59
|
+
const handleArrowDown = (event: KeyboardEvent) => {
|
|
60
|
+
event.preventDefault()
|
|
61
|
+
if (isEligibleToIncrementHighlightedIndex.value) {
|
|
62
|
+
incrementHighlightedIndex()
|
|
63
|
+
}
|
|
28
64
|
}
|
|
65
|
+
const handleEnter = () => {
|
|
66
|
+
if (isEligibleToHandleEnter.value) {
|
|
67
|
+
selectedItem.value = itemsData.value[highlightedIndex.value]
|
|
68
|
+
resetHighlightedIndex()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
29
72
|
const navigateList = (event: KeyboardEvent) => {
|
|
30
|
-
if (
|
|
73
|
+
if (isNotEligibleToHandleArrows.value) {
|
|
31
74
|
return
|
|
32
75
|
}
|
|
33
76
|
switch (event.key) {
|
|
34
77
|
case 'ArrowUp':
|
|
35
|
-
handleArrowUp()
|
|
78
|
+
handleArrowUp(event)
|
|
36
79
|
break
|
|
37
80
|
case 'ArrowDown':
|
|
38
|
-
handleArrowDown()
|
|
81
|
+
handleArrowDown(event)
|
|
39
82
|
break
|
|
40
83
|
case 'Enter':
|
|
41
84
|
handleEnter()
|
|
@@ -41,7 +41,7 @@ export interface AnchorEvent extends KeyboardEvent {
|
|
|
41
41
|
|
|
42
42
|
// handleShow/handleHide -> removeTick(), self (& emit show)
|
|
43
43
|
|
|
44
|
-
export default function ({
|
|
44
|
+
export default function useModelToggle({
|
|
45
45
|
showing,
|
|
46
46
|
canShow, // optional
|
|
47
47
|
handleShow, // optional
|
|
@@ -70,29 +70,28 @@ export default function ({
|
|
|
70
70
|
function show(evt: AnchorEvent) {
|
|
71
71
|
if (
|
|
72
72
|
props.disabled === true ||
|
|
73
|
-
(evt
|
|
74
|
-
(canShow
|
|
73
|
+
(evt && evt.dlAnchorHandled === true) ||
|
|
74
|
+
(canShow && canShow(evt) !== true)
|
|
75
75
|
) {
|
|
76
76
|
return
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const listener =
|
|
80
|
-
props[`onUpdate:${modelValueNaming}`]
|
|
81
|
-
(vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
|
|
82
|
-
void 0
|
|
80
|
+
props[`onUpdate:${modelValueNaming}`] ||
|
|
81
|
+
(vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
|
|
83
82
|
|
|
84
|
-
if (listener
|
|
83
|
+
if (listener) {
|
|
85
84
|
emit(`update:${modelValueNaming}`, true)
|
|
86
85
|
payload = evt
|
|
87
86
|
|
|
88
87
|
nextTick(() => {
|
|
89
88
|
if (payload === evt) {
|
|
90
|
-
payload =
|
|
89
|
+
payload = null
|
|
91
90
|
}
|
|
92
91
|
})
|
|
93
92
|
}
|
|
94
93
|
|
|
95
|
-
if (!props.modelValue || listener
|
|
94
|
+
if (!props.modelValue || !listener) {
|
|
96
95
|
processShow(evt)
|
|
97
96
|
}
|
|
98
97
|
}
|
|
@@ -106,7 +105,7 @@ export default function ({
|
|
|
106
105
|
|
|
107
106
|
emit('before-show', evt)
|
|
108
107
|
|
|
109
|
-
if (handleShow
|
|
108
|
+
if (handleShow) {
|
|
110
109
|
handleShow(evt)
|
|
111
110
|
} else {
|
|
112
111
|
emit('show', evt)
|
|
@@ -119,16 +118,15 @@ export default function ({
|
|
|
119
118
|
}
|
|
120
119
|
|
|
121
120
|
const listener =
|
|
122
|
-
props[`onUpdate:${modelValueNaming}`]
|
|
123
|
-
(vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
|
|
124
|
-
void 0
|
|
121
|
+
props[`onUpdate:${modelValueNaming}`] ||
|
|
122
|
+
(vm!.proxy! as any)?.$listeners?.[`update:${modelValueNaming}`]
|
|
125
123
|
|
|
126
124
|
if (listener === true) {
|
|
127
125
|
emit(`update:${modelValueNaming}`, false)
|
|
128
126
|
payload = evt
|
|
129
127
|
nextTick(() => {
|
|
130
128
|
if (payload === evt) {
|
|
131
|
-
payload =
|
|
129
|
+
payload = null
|
|
132
130
|
}
|
|
133
131
|
})
|
|
134
132
|
}
|
|
@@ -147,7 +145,7 @@ export default function ({
|
|
|
147
145
|
|
|
148
146
|
emit('before-hide', evt)
|
|
149
147
|
|
|
150
|
-
if (handleHide
|
|
148
|
+
if (handleHide) {
|
|
151
149
|
handleHide(evt)
|
|
152
150
|
} else {
|
|
153
151
|
emit('hide', evt)
|
|
@@ -156,7 +154,7 @@ export default function ({
|
|
|
156
154
|
|
|
157
155
|
function processModelChange(val: boolean) {
|
|
158
156
|
if (props.disabled === true && val === true) {
|
|
159
|
-
if (props[`onUpdate:${modelValueNaming}`]
|
|
157
|
+
if (props[`onUpdate:${modelValueNaming}`]) {
|
|
160
158
|
emit(`update:${modelValueNaming}`, false)
|
|
161
159
|
}
|
|
162
160
|
} else if ((val === true) !== showing.value) {
|
package/src/hooks/use-portal.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { portalList } from '../utils/portal'
|
|
|
7
7
|
function isOnGlobalDialog(vm: any) {
|
|
8
8
|
vm = vm.parent
|
|
9
9
|
|
|
10
|
-
while (vm
|
|
10
|
+
while (vm) {
|
|
11
11
|
if (vm.type.name === 'DlGlobalDialog') {
|
|
12
12
|
return true
|
|
13
13
|
}
|
|
@@ -24,15 +24,21 @@ function isOnGlobalDialog(vm: any) {
|
|
|
24
24
|
// Warning!
|
|
25
25
|
// You MUST specify "inheritAttrs: false" in your component
|
|
26
26
|
|
|
27
|
-
export default function (
|
|
27
|
+
export default function usePortal(
|
|
28
28
|
vm: ComponentInternalInstance | null,
|
|
29
29
|
innerRef: Ref<HTMLElement | null>,
|
|
30
|
-
checkGlobalDialog = false
|
|
30
|
+
checkGlobalDialog = false,
|
|
31
|
+
config: {
|
|
32
|
+
parentId?: string
|
|
33
|
+
parentClass?: string
|
|
34
|
+
parentStyle?: string
|
|
35
|
+
} = {}
|
|
31
36
|
) {
|
|
32
37
|
// showing, including while in show/hide transition
|
|
33
38
|
const portalIsActive = ref(false)
|
|
34
39
|
|
|
35
40
|
const { proxy } = vm!
|
|
41
|
+
const { parentId, parentClass, parentStyle } = config
|
|
36
42
|
|
|
37
43
|
// showing & not in any show/hide transition
|
|
38
44
|
const portalIsAccessible = ref(false)
|
|
@@ -8,10 +8,8 @@ export default function (props: any, configureScrollTarget: Function) {
|
|
|
8
8
|
let scrollFn: Function | undefined
|
|
9
9
|
|
|
10
10
|
function changeScrollEvent(scrollTarget: any, fn: Function = () => {}) {
|
|
11
|
-
const fnProp: string = `${
|
|
12
|
-
|
|
13
|
-
}EventListener`
|
|
14
|
-
const fnHandler = fn !== void 0 ? fn : scrollFn
|
|
11
|
+
const fnProp: string = `${fn ? 'add' : 'remove'}EventListener`
|
|
12
|
+
const fnHandler = fn ? fn : scrollFn
|
|
15
13
|
|
|
16
14
|
if (scrollTarget !== window) {
|
|
17
15
|
scrollTarget[fnProp]('scroll', fnHandler, listenOpts.passive)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { onBeforeUnmount, onMounted, ref, Ref } from 'vue-demi'
|
|
2
2
|
import { isEllipsisActive } from '../utils/is-ellipsis-active'
|
|
3
|
+
import { get } from 'lodash'
|
|
3
4
|
|
|
4
|
-
export function useSizeObserver(elRef: Ref) {
|
|
5
|
+
export function useSizeObserver(elRef: Ref, entryLevel = 'target') {
|
|
5
6
|
const widthRef = ref(0)
|
|
6
7
|
const heightRef = ref(0)
|
|
7
8
|
const hasEllipsis = ref(false)
|
|
8
9
|
const borderBoxSize = ref(null)
|
|
9
10
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
10
11
|
for (const entry of entries) {
|
|
11
|
-
hasEllipsis.value = isEllipsisActive(entry
|
|
12
|
+
hasEllipsis.value = isEllipsisActive(get(entry, entryLevel))
|
|
12
13
|
widthRef.value = entry.contentRect.width
|
|
13
14
|
heightRef.value = entry.contentRect.height
|
|
14
15
|
borderBoxSize.value = entry.borderBoxSize
|