@dataloop-ai/components 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +154 -0
- package/.prettierrc.json +7 -0
- package/Dockerfile +12 -0
- package/LICENSE +201 -0
- package/README.md +43 -0
- package/favicon.ico +0 -0
- package/index.html +13 -0
- package/index.ts +1 -0
- package/jest.config.js +16 -0
- package/jest.setup.js +59 -0
- package/models.ts +1 -0
- package/package.json +109 -0
- package/src/App.vue +201 -0
- package/src/assets/globals.scss +253 -0
- package/src/assets/globalsKeys.ts +28 -0
- package/src/components/DlAccordion/AccordionHeader.vue +148 -0
- package/src/components/DlAccordion/DlAccordion.vue +108 -0
- package/src/components/DlAccordion/index.ts +2 -0
- package/src/components/DlAlert.vue +227 -0
- package/src/components/DlAvatar.vue +99 -0
- package/src/components/DlBadge.vue +127 -0
- package/src/components/DlButton/DlButton.vue +370 -0
- package/src/components/DlButton/index.ts +4 -0
- package/src/components/DlButton/utils.ts +169 -0
- package/src/components/DlButtonGroup.vue +122 -0
- package/src/components/DlCheckbox.vue +298 -0
- package/src/components/DlChip/DlChip.vue +244 -0
- package/src/components/DlChip/index.ts +4 -0
- package/src/components/DlChip/utils.ts +100 -0
- package/src/components/DlColorPicker/DlAlpha.vue +142 -0
- package/src/components/DlColorPicker/DlBox.vue +75 -0
- package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
- package/src/components/DlColorPicker/DlColors.vue +139 -0
- package/src/components/DlColorPicker/DlHue.vue +135 -0
- package/src/components/DlColorPicker/DlPreview.vue +61 -0
- package/src/components/DlColorPicker/DlSaturation.vue +152 -0
- package/src/components/DlColorPicker/constants.ts +16 -0
- package/src/components/DlColorPicker/index.ts +20 -0
- package/src/components/DlColorPicker/types.ts +11 -0
- package/src/components/DlColorPicker/utils.ts +128 -0
- package/src/components/DlCounters.vue +173 -0
- package/src/components/DlDatePicker/DlCalendar.vue +332 -0
- package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
- package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
- package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
- package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
- package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
- package/src/components/DlDatePicker/index.ts +3 -0
- package/src/components/DlDatePicker/isInRange.ts +44 -0
- package/src/components/DlDatePicker/types.ts +4 -0
- package/src/components/DlDatePicker/utils.ts +39 -0
- package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
- package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
- package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
- package/src/components/DlDateTimeRange/index.ts +3 -0
- package/src/components/DlDateTimeRange/types.ts +42 -0
- package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
- package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
- package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
- package/src/components/DlDialogBox/index.ts +5 -0
- package/src/components/DlDropdownButton.vue +463 -0
- package/src/components/DlIcon.vue +147 -0
- package/src/components/DlInfoErrorMessage.vue +91 -0
- package/src/components/DlItem/DlItem.vue +35 -0
- package/src/components/DlItem/index.ts +2 -0
- package/src/components/DlItemSection.vue +88 -0
- package/src/components/DlLink/DlLink.vue +76 -0
- package/src/components/DlLink/index.ts +4 -0
- package/src/components/DlLink/utils.ts +4 -0
- package/src/components/DlList.vue +61 -0
- package/src/components/DlListItem/DlListItem.vue +205 -0
- package/src/components/DlListItem/index.ts +3 -0
- package/src/components/DlListItem/utils.ts +14 -0
- package/src/components/DlMenu/DlMenu.vue +438 -0
- package/src/components/DlMenu/index.ts +3 -0
- package/src/components/DlMenu/utils.ts +138 -0
- package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
- package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
- package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
- package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
- package/src/components/DlOptionGroup/index.ts +4 -0
- package/src/components/DlOptionGroup/utils.ts +40 -0
- package/src/components/DlPagination/DlPagination.vue +184 -0
- package/src/components/DlPagination/PageNavigation.vue +350 -0
- package/src/components/DlPagination/PaginationLegend.vue +41 -0
- package/src/components/DlPagination/QuickNavigation.vue +146 -0
- package/src/components/DlPagination/RowsSelector.vue +74 -0
- package/src/components/DlPagination/index.ts +3 -0
- package/src/components/DlPanelContainer/DlPanel.vue +213 -0
- package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
- package/src/components/DlPanelContainer/index.ts +4 -0
- package/src/components/DlPopup/DlPopup.vue +478 -0
- package/src/components/DlPopup/DraggableUpper.vue +64 -0
- package/src/components/DlPopup/PopupHeader.vue +129 -0
- package/src/components/DlPopup/index.ts +1 -0
- package/src/components/DlProgressBar.vue +159 -0
- package/src/components/DlProgressChart.vue +299 -0
- package/src/components/DlRadio.vue +218 -0
- package/src/components/DlRange/DlRange.vue +439 -0
- package/src/components/DlRange/utils.ts +209 -0
- package/src/components/DlSearch.vue +155 -0
- package/src/components/DlSelect/DlSelect.vue +992 -0
- package/src/components/DlSelect/SelectOption.vue +261 -0
- package/src/components/DlSelect/index.ts +4 -0
- package/src/components/DlSelect/utils.ts +43 -0
- package/src/components/DlSkeleton.vue +72 -0
- package/src/components/DlSlider/DlSlider.vue +243 -0
- package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
- package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
- package/src/components/DlSlider/components/index.ts +4 -0
- package/src/components/DlSlider/index.ts +3 -0
- package/src/components/DlSlider/sliderStyles.scss +109 -0
- package/src/components/DlSlider/useSlider.ts +277 -0
- package/src/components/DlSlider/utils.ts +7 -0
- package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
- package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
- package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
- package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
- package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
- package/src/components/DlSmartSearch/index.ts +4 -0
- package/src/components/DlSmartSearch/types.ts +36 -0
- package/src/components/DlSmartSearch/utils.ts +45 -0
- package/src/components/DlStepper/DlStepper.vue +196 -0
- package/src/components/DlStepper/DlStepperContainer.vue +55 -0
- package/src/components/DlStepper/DlStepperContent.vue +101 -0
- package/src/components/DlStepper/DlStepperFooter.vue +133 -0
- package/src/components/DlStepper/DlStepperHeader.vue +49 -0
- package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
- package/src/components/DlStepper/Step.ts +101 -0
- package/src/components/DlStepper/Stepper.ts +107 -0
- package/src/components/DlStepper/index.ts +7 -0
- package/src/components/DlStepper/interfaces.ts +11 -0
- package/src/components/DlSwitch.vue +280 -0
- package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
- package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
- package/src/components/DlTabPanels/index.ts +4 -0
- package/src/components/DlTabPanels/utils.ts +19 -0
- package/src/components/DlTable/DlTable.vue +1264 -0
- package/src/components/DlTable/DlTd.vue +109 -0
- package/src/components/DlTable/DlTh.vue +126 -0
- package/src/components/DlTable/DlTr.vue +44 -0
- package/src/components/DlTable/ResizableManager.ts +233 -0
- package/src/components/DlTable/dl-table-styles.scss +466 -0
- package/src/components/DlTable/hooks/tableActions.ts +64 -0
- package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
- package/src/components/DlTable/hooks/tableFilter.ts +42 -0
- package/src/components/DlTable/hooks/tablePagination.ts +197 -0
- package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
- package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
- package/src/components/DlTable/hooks/tableSort.ts +125 -0
- package/src/components/DlTable/index.ts +6 -0
- package/src/components/DlTable/types.ts +96 -0
- package/src/components/DlTabs/DlTab.vue +146 -0
- package/src/components/DlTabs/DlTabs.vue +192 -0
- package/src/components/DlTabs/TabsWrapper.vue +104 -0
- package/src/components/DlTabs/index.ts +4 -0
- package/src/components/DlTabs/types.ts +8 -0
- package/src/components/DlTextArea.vue +151 -0
- package/src/components/DlTextHolder.vue +65 -0
- package/src/components/DlTextInput.vue +753 -0
- package/src/components/DlThemeProvider.vue +41 -0
- package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
- package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
- package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
- package/src/components/DlTimePicker/index.ts +3 -0
- package/src/components/DlTimePicker/types.ts +4 -0
- package/src/components/DlTooltip.vue +456 -0
- package/src/components/DlTrend.vue +97 -0
- package/src/components/DlTypography.vue +87 -0
- package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
- package/src/components/DlVirtualScroll/index.ts +3 -0
- package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
- package/src/components/DlWidget/DlWidget.vue +50 -0
- package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
- package/src/components/DlWidget/index.ts +4 -0
- package/src/components/DlWidget/types.ts +6 -0
- package/src/components/DlWidget/utils.ts +30 -0
- package/src/components/index.ts +118 -0
- package/src/demo/DlAccordionDemo.vue +60 -0
- package/src/demo/DlAlertDemo.vue +54 -0
- package/src/demo/DlAvatarDemo.vue +43 -0
- package/src/demo/DlBadgeDemo.vue +65 -0
- package/src/demo/DlButtonDemo.vue +266 -0
- package/src/demo/DlCheckboxDemo.vue +50 -0
- package/src/demo/DlChipDemo.vue +181 -0
- package/src/demo/DlColorPickerDemo.vue +43 -0
- package/src/demo/DlCounterDemo.vue +53 -0
- package/src/demo/DlDateTimeRangeDemo.vue +217 -0
- package/src/demo/DlDialogBoxDemo.vue +175 -0
- package/src/demo/DlDropdownButtonDemo.vue +260 -0
- package/src/demo/DlIconDemo.vue +47 -0
- package/src/demo/DlLinkDemo.vue +23 -0
- package/src/demo/DlListDemo.vue +177 -0
- package/src/demo/DlMenuDemo.vue +524 -0
- package/src/demo/DlOptionGroupDemo.vue +79 -0
- package/src/demo/DlPaginationDemo.vue +44 -0
- package/src/demo/DlPanelContainerDemo.vue +221 -0
- package/src/demo/DlPopupDemo.vue +58 -0
- package/src/demo/DlProgressBarDemo.vue +22 -0
- package/src/demo/DlProgressChartDemo.vue +71 -0
- package/src/demo/DlRadioDemo.vue +35 -0
- package/src/demo/DlRangeDemo.vue +44 -0
- package/src/demo/DlSearchDemo.vue +27 -0
- package/src/demo/DlSelectDemo.vue +355 -0
- package/src/demo/DlSkeletonDemo.vue +20 -0
- package/src/demo/DlSliderDemo.vue +47 -0
- package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
- package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
- package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
- package/src/demo/DlStepperDemo/index.ts +5 -0
- package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
- package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
- package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
- package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
- package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
- package/src/demo/DlSwitchDemo.vue +49 -0
- package/src/demo/DlTableDemo.vue +475 -0
- package/src/demo/DlTabsDemo.vue +67 -0
- package/src/demo/DlTdDemo.vue +19 -0
- package/src/demo/DlTextAreaDemo.vue +37 -0
- package/src/demo/DlTextHolderDemo.vue +42 -0
- package/src/demo/DlTextInputDemo.vue +89 -0
- package/src/demo/DlThDemo.vue +32 -0
- package/src/demo/DlTooltipDemo.vue +60 -0
- package/src/demo/DlTrDemo.vue +18 -0
- package/src/demo/DlTrendDemo.vue +25 -0
- package/src/demo/DlTypographyDemo.vue +93 -0
- package/src/demo/DlWidgetDemo.vue +157 -0
- package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
- package/src/demo/SmartSearchDemo/schema.ts +44 -0
- package/src/demo/index.ts +141 -0
- package/src/directives/TouchPan.ts +525 -0
- package/src/env.d.ts +8 -0
- package/src/hooks/use-anchor.ts +223 -0
- package/src/hooks/use-model-toggle.ts +181 -0
- package/src/hooks/use-portal.ts +104 -0
- package/src/hooks/use-scroll-target.ts +53 -0
- package/src/hooks/use-size-observer.ts +24 -0
- package/src/hooks/use-suggestions.ts +355 -0
- package/src/hooks/use-tick.ts +32 -0
- package/src/hooks/use-timeout.ts +20 -0
- package/src/hooks/use-transition.ts +32 -0
- package/src/hooks/use-window-size.ts +25 -0
- package/src/hooks/useForm.ts +12 -0
- package/src/index.ts +7 -0
- package/src/main.ts +4 -0
- package/src/models.ts +4 -0
- package/src/types.ts +6 -0
- package/src/utils/calcs.ts +18 -0
- package/src/utils/click-outside.ts +108 -0
- package/src/utils/component-name-parser.ts +1 -0
- package/src/utils/css-color-names.ts +150 -0
- package/src/utils/dom.ts +55 -0
- package/src/utils/draggable-table.ts +416 -0
- package/src/utils/escape-key.ts +54 -0
- package/src/utils/events.ts +67 -0
- package/src/utils/focus-manager.ts +33 -0
- package/src/utils/focusout.ts +29 -0
- package/src/utils/format.ts +3 -0
- package/src/utils/getColor.ts +17 -0
- package/src/utils/getLighterGradient.ts +36 -0
- package/src/utils/getRootStyles.ts +52 -0
- package/src/utils/global-config.ts +6 -0
- package/src/utils/global-nodes.ts +42 -0
- package/src/utils/includes.ts +3 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/inject-object-prop.ts +21 -0
- package/src/utils/input-sizes.ts +7 -0
- package/src/utils/is-ellipsis-active.ts +3 -0
- package/src/utils/is-in-viewport.ts +13 -0
- package/src/utils/is.ts +15 -0
- package/src/utils/key-composition.ts +17 -0
- package/src/utils/keyCodes.ts +12 -0
- package/src/utils/logger/ConsoleLogger.ts +65 -0
- package/src/utils/logger/ILogger.ts +8 -0
- package/src/utils/logger/index.ts +8 -0
- package/src/utils/nav-keys-constants.ts +1 -0
- package/src/utils/portal.ts +55 -0
- package/src/utils/position-engine.ts +381 -0
- package/src/utils/render.ts +36 -0
- package/src/utils/ripple.ts +7 -0
- package/src/utils/scroll.ts +73 -0
- package/src/utils/selection.ts +15 -0
- package/src/utils/sort.ts +7 -0
- package/src/utils/splitByQuotes.ts +32 -0
- package/src/utils/string.ts +6 -0
- package/src/utils/teleport.ts +14 -0
- package/src/utils/theme.ts +2 -0
- package/src/utils/vm.ts +16 -0
- package/storybook.js +8 -0
- package/tsconfig.json +44 -0
- package/tsconfig.node.json +8 -0
- package/types.ts +1 -0
- package/vite.config.ts +13 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dl-teleport
|
|
3
|
+
v-if="portalIsActive"
|
|
4
|
+
:to="portalEl"
|
|
5
|
+
>
|
|
6
|
+
<transition
|
|
7
|
+
name="fade"
|
|
8
|
+
appear
|
|
9
|
+
>
|
|
10
|
+
<div
|
|
11
|
+
v-if="showing"
|
|
12
|
+
:id="uuid"
|
|
13
|
+
ref="innerRef"
|
|
14
|
+
tabIndex="-1"
|
|
15
|
+
:class="classes"
|
|
16
|
+
:style="styles"
|
|
17
|
+
>
|
|
18
|
+
<draggable-upper @move="movePopup" />
|
|
19
|
+
<popup-header
|
|
20
|
+
:title="title"
|
|
21
|
+
:additional-info="additionalInfo"
|
|
22
|
+
:subtitle="subtitle"
|
|
23
|
+
:with-close-button="withCloseButton"
|
|
24
|
+
@hide-button-clik="handleHideClick"
|
|
25
|
+
>
|
|
26
|
+
<template
|
|
27
|
+
v-if="hasHeaderSlot"
|
|
28
|
+
#header
|
|
29
|
+
>
|
|
30
|
+
<slot name="header" />
|
|
31
|
+
</template>
|
|
32
|
+
<template
|
|
33
|
+
v-if="hasHideButtonSlot"
|
|
34
|
+
#hide-button
|
|
35
|
+
>
|
|
36
|
+
<slot name="hide-button" />
|
|
37
|
+
</template>
|
|
38
|
+
</popup-header>
|
|
39
|
+
<div class="popup-content">
|
|
40
|
+
<slot />
|
|
41
|
+
</div>
|
|
42
|
+
<div
|
|
43
|
+
v-if="hasFooterSlot"
|
|
44
|
+
class="popup-footer"
|
|
45
|
+
>
|
|
46
|
+
<slot name="footer" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</transition>
|
|
50
|
+
</dl-teleport>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script lang="ts">
|
|
54
|
+
import {
|
|
55
|
+
h as _h,
|
|
56
|
+
defineComponent,
|
|
57
|
+
onBeforeUnmount,
|
|
58
|
+
getCurrentInstance,
|
|
59
|
+
ref,
|
|
60
|
+
watch,
|
|
61
|
+
computed,
|
|
62
|
+
PropType,
|
|
63
|
+
Ref,
|
|
64
|
+
isVue2
|
|
65
|
+
} from 'vue-demi'
|
|
66
|
+
|
|
67
|
+
import useWindowSize from '../../hooks/use-window-size'
|
|
68
|
+
import useAnchor, { useAnchorProps } from '../../hooks/use-anchor'
|
|
69
|
+
import useScrollTarget from '../../hooks/use-scroll-target'
|
|
70
|
+
import useModelToggle, {
|
|
71
|
+
useModelToggleProps,
|
|
72
|
+
AnchorEvent
|
|
73
|
+
} from '../../hooks/use-model-toggle'
|
|
74
|
+
import usePortal from '../../hooks/use-portal'
|
|
75
|
+
import useTransition, { useTransitionProps } from '../../hooks/use-transition'
|
|
76
|
+
import useTick from '../../hooks/use-tick'
|
|
77
|
+
import useTimeout from '../../hooks/use-timeout'
|
|
78
|
+
|
|
79
|
+
import { getScrollTarget } from '../../utils/scroll'
|
|
80
|
+
import DlTeleport from '../../utils/teleport'
|
|
81
|
+
import { removeEscapeKey } from '../../utils/escape-key'
|
|
82
|
+
import { addFocusout, removeFocusout } from '../../utils/focusout'
|
|
83
|
+
import { childHasFocus } from '../../utils/dom'
|
|
84
|
+
import {
|
|
85
|
+
removeClickOutside,
|
|
86
|
+
ClickOutsideEvent
|
|
87
|
+
} from '../../utils/click-outside'
|
|
88
|
+
import { addFocusFn } from '../../utils/focus-manager'
|
|
89
|
+
|
|
90
|
+
import {
|
|
91
|
+
validatePosition,
|
|
92
|
+
validateOffset,
|
|
93
|
+
setPosition,
|
|
94
|
+
parsePosition,
|
|
95
|
+
setForcedPosition
|
|
96
|
+
} from '../../utils/position-engine'
|
|
97
|
+
import {
|
|
98
|
+
getAnchorOrigin,
|
|
99
|
+
handleWatcherEvents,
|
|
100
|
+
setOffsetOnShow,
|
|
101
|
+
updateUnwatchPosition,
|
|
102
|
+
refocusTargetFn,
|
|
103
|
+
conditionalHandler,
|
|
104
|
+
handleClickOutside
|
|
105
|
+
} from '../DlMenu/utils'
|
|
106
|
+
import DraggableUpper from './DraggableUpper.vue'
|
|
107
|
+
import PopupHeader from './PopupHeader.vue'
|
|
108
|
+
import { v4 } from 'uuid'
|
|
109
|
+
|
|
110
|
+
export default defineComponent({
|
|
111
|
+
name: 'DlPopup',
|
|
112
|
+
components: {
|
|
113
|
+
DlTeleport,
|
|
114
|
+
PopupHeader,
|
|
115
|
+
DraggableUpper
|
|
116
|
+
},
|
|
117
|
+
model: {
|
|
118
|
+
prop: 'modelValue',
|
|
119
|
+
event: 'update:model-value'
|
|
120
|
+
},
|
|
121
|
+
props: {
|
|
122
|
+
...useAnchorProps,
|
|
123
|
+
...useModelToggleProps,
|
|
124
|
+
...useTransitionProps,
|
|
125
|
+
disabled: Boolean,
|
|
126
|
+
persistent: Boolean,
|
|
127
|
+
autoClose: Boolean,
|
|
128
|
+
noRefocus: Boolean,
|
|
129
|
+
noFocus: Boolean,
|
|
130
|
+
anchor: {
|
|
131
|
+
type: String,
|
|
132
|
+
default: 'center middle',
|
|
133
|
+
validator: validatePosition
|
|
134
|
+
},
|
|
135
|
+
additionalInfo: { type: String, default: '' },
|
|
136
|
+
title: { type: String, default: '' },
|
|
137
|
+
subtitle: { type: String, default: '' },
|
|
138
|
+
withCloseButton: { type: Boolean, default: false },
|
|
139
|
+
preventHide: { type: Boolean, default: false },
|
|
140
|
+
disableCloseByEsc: { type: Boolean, default: false },
|
|
141
|
+
hideOnClickOutside: { type: Boolean, default: false },
|
|
142
|
+
self: {
|
|
143
|
+
type: String,
|
|
144
|
+
default: 'top middle',
|
|
145
|
+
validator: validatePosition
|
|
146
|
+
},
|
|
147
|
+
offset: {
|
|
148
|
+
type: Array,
|
|
149
|
+
default: () => [0, 0],
|
|
150
|
+
validator: validateOffset
|
|
151
|
+
},
|
|
152
|
+
scrollTarget: {
|
|
153
|
+
type: String as PropType<Element | string>,
|
|
154
|
+
default: void 0
|
|
155
|
+
},
|
|
156
|
+
touchPosition: Boolean,
|
|
157
|
+
maxHeight: { type: String, default: 'auto' },
|
|
158
|
+
maxWidth: { type: String, default: 'auto' },
|
|
159
|
+
height: { type: String, default: 'auto' },
|
|
160
|
+
width: { type: String, default: 'auto' }
|
|
161
|
+
},
|
|
162
|
+
emits: [
|
|
163
|
+
'hide-button-click',
|
|
164
|
+
'show',
|
|
165
|
+
'before-show',
|
|
166
|
+
'hide',
|
|
167
|
+
'escape-key',
|
|
168
|
+
'before-hide',
|
|
169
|
+
'update:model-value'
|
|
170
|
+
],
|
|
171
|
+
setup(props, { attrs, slots }) {
|
|
172
|
+
const vm = getCurrentInstance()
|
|
173
|
+
|
|
174
|
+
let refocusTarget: HTMLElement | Element | null = null
|
|
175
|
+
let absoluteOffset: Record<any, any> | undefined
|
|
176
|
+
let unwatchPosition: Function | undefined
|
|
177
|
+
|
|
178
|
+
const proxy = vm!.proxy!
|
|
179
|
+
|
|
180
|
+
const innerRef: Ref<HTMLElement | null> = ref(null)
|
|
181
|
+
const showing = ref(false)
|
|
182
|
+
|
|
183
|
+
const { registerTick, removeTick } = useTick()
|
|
184
|
+
const { registerTimeout, removeTimeout } = useTimeout()
|
|
185
|
+
const { transitionStyle } = useTransition(props, showing)
|
|
186
|
+
const { localScrollTarget, changeScrollEvent } = useScrollTarget(
|
|
187
|
+
props,
|
|
188
|
+
configureScrollTarget
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
const { anchorEl, canShow } = useAnchor({})
|
|
192
|
+
|
|
193
|
+
const screen = useWindowSize()
|
|
194
|
+
|
|
195
|
+
const hasFooterSlot = computed(() => slots.footer !== undefined)
|
|
196
|
+
|
|
197
|
+
const hasHeaderSlot = computed(() => slots.header !== undefined)
|
|
198
|
+
|
|
199
|
+
const hasHideButtonSlot = computed(
|
|
200
|
+
() => slots['hide-button'] !== undefined
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
const { hide } = useModelToggle({
|
|
204
|
+
showing,
|
|
205
|
+
canShow,
|
|
206
|
+
handleShow,
|
|
207
|
+
handleHide,
|
|
208
|
+
processOnMount: true
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
const {
|
|
212
|
+
showPortal,
|
|
213
|
+
hidePortal,
|
|
214
|
+
portalEl,
|
|
215
|
+
portalIsActive,
|
|
216
|
+
portalIsAccessible
|
|
217
|
+
} = usePortal(vm, innerRef)
|
|
218
|
+
|
|
219
|
+
const clickOutsideProps = {
|
|
220
|
+
anchorEl,
|
|
221
|
+
innerRef,
|
|
222
|
+
onClickOutside: (e: AnchorEvent) =>
|
|
223
|
+
handleClickOutside(e, {
|
|
224
|
+
persistent: !props.hideOnClickOutside,
|
|
225
|
+
showing: showing.value,
|
|
226
|
+
fn: hide
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const anchorOrigin = computed(() =>
|
|
231
|
+
getAnchorOrigin(props.anchor, false)
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
const selfOrigin = computed(() =>
|
|
235
|
+
parsePosition(props.self || 'top start')
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
const handlesFocus = computed(
|
|
239
|
+
() => showing.value === true && props.persistent !== true
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
const stylesFromProps = computed(() => {
|
|
243
|
+
return {
|
|
244
|
+
'--popup-max-width': props.maxWidth,
|
|
245
|
+
'--popup-max-height': props.maxHeight,
|
|
246
|
+
'--popup-width': props.width,
|
|
247
|
+
'--popup-height': props.height
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
watch(handlesFocus, (val) =>
|
|
252
|
+
handleWatcherEvents(val, onEscapeKey, clickOutsideProps)
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
function focus() {
|
|
256
|
+
addFocusFn(() => {
|
|
257
|
+
let node = innerRef.value as unknown as HTMLElement
|
|
258
|
+
|
|
259
|
+
if (node && node.contains(document.activeElement) !== true) {
|
|
260
|
+
node =
|
|
261
|
+
node.querySelector('[autofocus], [data-autofocus]') ||
|
|
262
|
+
node
|
|
263
|
+
node.focus({ preventScroll: true })
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function handleShow(evt: MouseEvent | TouchEvent) {
|
|
269
|
+
removeTick()
|
|
270
|
+
removeTimeout()
|
|
271
|
+
|
|
272
|
+
refocusTarget =
|
|
273
|
+
props.noRefocus === false ? document.activeElement : null
|
|
274
|
+
|
|
275
|
+
addFocusout(onFocusout)
|
|
276
|
+
|
|
277
|
+
showPortal()
|
|
278
|
+
|
|
279
|
+
absoluteOffset = void 0
|
|
280
|
+
|
|
281
|
+
const offsetOnShow = setOffsetOnShow(evt as TouchEvent, {
|
|
282
|
+
contextMenu: props.contextMenu,
|
|
283
|
+
touchPosition: props.touchPosition,
|
|
284
|
+
anchorEl,
|
|
285
|
+
absoluteOffset
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
absoluteOffset = offsetOnShow as Record<any, any> | undefined
|
|
289
|
+
|
|
290
|
+
if (unwatchPosition === void 0) {
|
|
291
|
+
unwatchPosition = watch(() => screen, updatePosition, {
|
|
292
|
+
deep: true
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (!props.noFocus) (document.activeElement as HTMLElement).blur()
|
|
297
|
+
|
|
298
|
+
registerTick(() => {
|
|
299
|
+
updatePosition()
|
|
300
|
+
if (!props.noFocus) focus()
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
registerTimeout(() => {
|
|
304
|
+
updatePosition()
|
|
305
|
+
showPortal(true) // done showing portal
|
|
306
|
+
proxy.$emit('show', evt)
|
|
307
|
+
}, props.transitionDuration)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function handleHide(evt: ClickOutsideEvent) {
|
|
311
|
+
removeTick()
|
|
312
|
+
removeTimeout()
|
|
313
|
+
hidePortal()
|
|
314
|
+
|
|
315
|
+
anchorCleanup(true)
|
|
316
|
+
refocusTarget = refocusTargetFn(evt, refocusTarget as HTMLElement)
|
|
317
|
+
|
|
318
|
+
registerTimeout(() => {
|
|
319
|
+
hidePortal(true) // done hiding, now destroy
|
|
320
|
+
proxy.$emit('hide', evt)
|
|
321
|
+
}, props.transitionDuration)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function anchorCleanup(hiding: boolean) {
|
|
325
|
+
absoluteOffset = void 0
|
|
326
|
+
|
|
327
|
+
unwatchPosition = updateUnwatchPosition(unwatchPosition)
|
|
328
|
+
|
|
329
|
+
conditionalHandler(hiding || showing.value, () => {
|
|
330
|
+
removeFocusout(onFocusout)
|
|
331
|
+
removeClickOutside(clickOutsideProps)
|
|
332
|
+
removeEscapeKey(onEscapeKey)
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
conditionalHandler(!hiding, () => {
|
|
336
|
+
refocusTarget = null
|
|
337
|
+
})
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function configureScrollTarget() {
|
|
341
|
+
if (anchorEl.value !== null || props.scrollTarget !== void 0) {
|
|
342
|
+
(localScrollTarget as Ref<any>).value = getScrollTarget(
|
|
343
|
+
anchorEl.value as HTMLElement,
|
|
344
|
+
props.scrollTarget
|
|
345
|
+
)
|
|
346
|
+
changeScrollEvent(
|
|
347
|
+
(localScrollTarget as Ref<any>).value,
|
|
348
|
+
updatePosition
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function onFocusout(evt: MouseEvent) {
|
|
354
|
+
// the focus is not in a vue child component
|
|
355
|
+
conditionalHandler(
|
|
356
|
+
handlesFocus.value === true &&
|
|
357
|
+
props.noFocus !== true &&
|
|
358
|
+
childHasFocus(
|
|
359
|
+
innerRef.value as HTMLElement,
|
|
360
|
+
evt.target as Node
|
|
361
|
+
) !== true,
|
|
362
|
+
focus
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function onEscapeKey(evt: AnchorEvent) {
|
|
367
|
+
proxy.$emit('escape-key')
|
|
368
|
+
if (!props.disableCloseByEsc) {
|
|
369
|
+
hide(evt)
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function updatePosition() {
|
|
374
|
+
const el = innerRef.value
|
|
375
|
+
|
|
376
|
+
if (el === null || anchorEl.value === null) {
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
setPosition({
|
|
381
|
+
el,
|
|
382
|
+
offset: props.offset as number[],
|
|
383
|
+
anchorEl: anchorEl.value as HTMLElement,
|
|
384
|
+
anchorOrigin: anchorOrigin.value,
|
|
385
|
+
selfOrigin: selfOrigin.value,
|
|
386
|
+
absoluteOffset,
|
|
387
|
+
fit: false,
|
|
388
|
+
cover: false,
|
|
389
|
+
maxHeight: props.maxHeight,
|
|
390
|
+
maxWidth: props.maxWidth
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function movePopup(x: number, y: number) {
|
|
395
|
+
const el = innerRef.value
|
|
396
|
+
|
|
397
|
+
if (el === null || anchorEl.value === null) {
|
|
398
|
+
return
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
setForcedPosition(
|
|
402
|
+
{
|
|
403
|
+
el,
|
|
404
|
+
offset: props.offset as number[],
|
|
405
|
+
anchorEl: anchorEl.value as HTMLElement,
|
|
406
|
+
anchorOrigin: anchorOrigin.value,
|
|
407
|
+
selfOrigin: selfOrigin.value
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
top: y,
|
|
411
|
+
left: x
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function handleHideClick(e: Event) {
|
|
417
|
+
if (!props.preventHide) {
|
|
418
|
+
hide(e as AnchorEvent)
|
|
419
|
+
}
|
|
420
|
+
proxy.$emit('hide-button-click', e)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
onBeforeUnmount(anchorCleanup as any)
|
|
424
|
+
|
|
425
|
+
// expose public methods
|
|
426
|
+
Object.assign(proxy, { focus, updatePosition })
|
|
427
|
+
|
|
428
|
+
return {
|
|
429
|
+
uuid: `dl-popup-${v4()}`,
|
|
430
|
+
portalIsAccessible,
|
|
431
|
+
anchorEl,
|
|
432
|
+
showing,
|
|
433
|
+
handleHideClick,
|
|
434
|
+
hasHideButtonSlot,
|
|
435
|
+
hasFooterSlot,
|
|
436
|
+
movePopup,
|
|
437
|
+
hasHeaderSlot,
|
|
438
|
+
innerRef,
|
|
439
|
+
portalEl: isVue2 ? 'body' : portalEl,
|
|
440
|
+
portalIsActive,
|
|
441
|
+
classes: 'dl-popup dl-position-engine scroll',
|
|
442
|
+
styles: [
|
|
443
|
+
attrs.style,
|
|
444
|
+
transitionStyle.value,
|
|
445
|
+
stylesFromProps.value
|
|
446
|
+
] as any
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
})
|
|
450
|
+
</script>
|
|
451
|
+
|
|
452
|
+
<style>
|
|
453
|
+
.dl-popup {
|
|
454
|
+
z-index: calc(var(--dl-z-index-menu) - 1);
|
|
455
|
+
position: fixed !important;
|
|
456
|
+
padding: 0 0 16px;
|
|
457
|
+
border: 1px solid var(--dl-color-separator);
|
|
458
|
+
display: flex;
|
|
459
|
+
background-color: var(--dl-color-panel-background);
|
|
460
|
+
flex-direction: column;
|
|
461
|
+
max-width: var(--popup-max-width);
|
|
462
|
+
max-height: var(--popup-max-height);
|
|
463
|
+
width: var(--popup-width);
|
|
464
|
+
height: var(--popup-height);
|
|
465
|
+
/* TODO: Change to variable */
|
|
466
|
+
box-shadow: 0px 3px 6px rgba(16, 30, 115, 0.15);
|
|
467
|
+
border-radius: 2px;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.popup-content {
|
|
471
|
+
max-width: 100%;
|
|
472
|
+
padding: 0 16px;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
.popup-footer {
|
|
476
|
+
padding: 20px 16px 0px;
|
|
477
|
+
}
|
|
478
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="draggableUpper"
|
|
4
|
+
class="root"
|
|
5
|
+
/>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { defineComponent, getCurrentInstance, onMounted } from 'vue-demi'
|
|
10
|
+
|
|
11
|
+
export default defineComponent({
|
|
12
|
+
emits: ['move'],
|
|
13
|
+
setup() {
|
|
14
|
+
const vm = getCurrentInstance()
|
|
15
|
+
|
|
16
|
+
onMounted(() => {
|
|
17
|
+
const root = vm!.refs.draggableUpper as HTMLElement
|
|
18
|
+
let newX = 0
|
|
19
|
+
let newY = 0
|
|
20
|
+
let offsetX = 0
|
|
21
|
+
let offsetY = 0
|
|
22
|
+
|
|
23
|
+
if (root) {
|
|
24
|
+
root.onmousedown = dragMouseDown
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function dragMouseDown(e: any) {
|
|
28
|
+
e = e || window.event
|
|
29
|
+
e.preventDefault()
|
|
30
|
+
|
|
31
|
+
offsetX = e.layerX
|
|
32
|
+
offsetY = e.layerY
|
|
33
|
+
|
|
34
|
+
newX = e.clientX
|
|
35
|
+
newY = e.clientY
|
|
36
|
+
document.onmouseup = closeDragElement
|
|
37
|
+
|
|
38
|
+
document.onmousemove = elementDrag
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function elementDrag(e: any) {
|
|
42
|
+
e = e || window.event
|
|
43
|
+
e.preventDefault()
|
|
44
|
+
newX = e.clientX - offsetX
|
|
45
|
+
newY = e.clientY - offsetY
|
|
46
|
+
vm!.emit('move', newX, newY)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function closeDragElement() {
|
|
50
|
+
document.onmouseup = null
|
|
51
|
+
document.onmousemove = null
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<style scoped>
|
|
59
|
+
.root {
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 10px;
|
|
62
|
+
cursor: move;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="popup-header"
|
|
4
|
+
:style="cssVars"
|
|
5
|
+
>
|
|
6
|
+
<slot
|
|
7
|
+
v-if="hasHeaderSlot"
|
|
8
|
+
name="header"
|
|
9
|
+
/>
|
|
10
|
+
<div
|
|
11
|
+
v-else
|
|
12
|
+
class="header-content"
|
|
13
|
+
>
|
|
14
|
+
<span class="title">
|
|
15
|
+
{{ title }}
|
|
16
|
+
<span class="info-icon">
|
|
17
|
+
<dl-icon
|
|
18
|
+
v-if="hasAdditionalInfo"
|
|
19
|
+
size="12px"
|
|
20
|
+
icon="icon-dl-info"
|
|
21
|
+
class="info-icon"
|
|
22
|
+
/>
|
|
23
|
+
<dl-tooltip>
|
|
24
|
+
{{ additionalInfo }}
|
|
25
|
+
</dl-tooltip>
|
|
26
|
+
</span>
|
|
27
|
+
</span>
|
|
28
|
+
<span
|
|
29
|
+
v-if="withCloseButton"
|
|
30
|
+
class="hide-button"
|
|
31
|
+
@click="handleHide"
|
|
32
|
+
>
|
|
33
|
+
<slot
|
|
34
|
+
v-if="hasHideButtonSlot"
|
|
35
|
+
name="hide-button"
|
|
36
|
+
/>
|
|
37
|
+
<dl-icon
|
|
38
|
+
v-else
|
|
39
|
+
color="dl-color-darker"
|
|
40
|
+
icon="icon-dl-close"
|
|
41
|
+
size="8px"
|
|
42
|
+
/>
|
|
43
|
+
</span>
|
|
44
|
+
<span class="subtitle">{{ subtitle }}</span>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
|
|
49
|
+
<script lang="ts">
|
|
50
|
+
import { defineComponent } from 'vue-demi'
|
|
51
|
+
import DlTooltip from '../DlTooltip.vue'
|
|
52
|
+
import DlIcon from '../DlIcon.vue'
|
|
53
|
+
|
|
54
|
+
export default defineComponent({
|
|
55
|
+
components: {
|
|
56
|
+
DlIcon,
|
|
57
|
+
DlTooltip
|
|
58
|
+
},
|
|
59
|
+
props: {
|
|
60
|
+
title: { type: String, default: '' },
|
|
61
|
+
subtitle: { type: String, default: '' },
|
|
62
|
+
additionalInfo: { type: String, default: '' },
|
|
63
|
+
withCloseButton: { type: Boolean, default: false }
|
|
64
|
+
},
|
|
65
|
+
emits: ['hide-button-clik'],
|
|
66
|
+
computed: {
|
|
67
|
+
hasHeaderSlot(): boolean {
|
|
68
|
+
return this.$slots.header !== undefined
|
|
69
|
+
},
|
|
70
|
+
hasHideButtonSlot(): boolean {
|
|
71
|
+
return this.$slots['hide-button'] !== undefined
|
|
72
|
+
},
|
|
73
|
+
hasAdditionalInfo(): boolean {
|
|
74
|
+
return this.additionalInfo !== ''
|
|
75
|
+
},
|
|
76
|
+
cssVars(): Record<string, string> {
|
|
77
|
+
return {
|
|
78
|
+
'--popup-header-template-columns': this.withCloseButton
|
|
79
|
+
? '1fr auto'
|
|
80
|
+
: '100%'
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
methods: {
|
|
85
|
+
handleHide(e: Event) {
|
|
86
|
+
this.$emit('hide-button-clik', e)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<style scoped lang="scss">
|
|
93
|
+
.popup-header {
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
padding: 0 10px 20px 16px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.header-content {
|
|
99
|
+
display: grid;
|
|
100
|
+
grid-template-columns: var(--popup-header-template-columns);
|
|
101
|
+
column-gap: 10px;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.title {
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: 5px;
|
|
108
|
+
color: var(--dl-color-darker);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.hide-button {
|
|
112
|
+
display: flex;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
align-items: center;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
transition: color 200ms;
|
|
117
|
+
&:hover {
|
|
118
|
+
color: var(--dl-color-secondary);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.subtitle {
|
|
123
|
+
color: var(--dl-color-medium);
|
|
124
|
+
padding-top: 3px;
|
|
125
|
+
font-size: var(--dl-font-size-small);
|
|
126
|
+
grid-column: 1 / 3;
|
|
127
|
+
grid-row: 2;
|
|
128
|
+
}
|
|
129
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './DlPopup.vue'
|