@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,456 @@
|
|
|
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
|
+
class="capitalize"
|
|
17
|
+
:style="styles"
|
|
18
|
+
>
|
|
19
|
+
<slot />
|
|
20
|
+
</div>
|
|
21
|
+
</transition>
|
|
22
|
+
</dl-teleport>
|
|
23
|
+
</template>
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import {
|
|
26
|
+
defineComponent,
|
|
27
|
+
getCurrentInstance,
|
|
28
|
+
ref,
|
|
29
|
+
computed,
|
|
30
|
+
watch,
|
|
31
|
+
onBeforeUnmount,
|
|
32
|
+
isVue2,
|
|
33
|
+
Ref,
|
|
34
|
+
PropType,
|
|
35
|
+
onMounted
|
|
36
|
+
} from 'vue-demi'
|
|
37
|
+
import useAnchor, { useAnchorProps } from '../hooks/use-anchor'
|
|
38
|
+
import useModelToggle, { AnchorEvent } from '../hooks/use-model-toggle'
|
|
39
|
+
import usePortal from '../hooks/use-portal'
|
|
40
|
+
import useScrollTarget from '../hooks/use-scroll-target'
|
|
41
|
+
import useTick from '../hooks/use-tick'
|
|
42
|
+
import useTimeout from '../hooks/use-timeout'
|
|
43
|
+
import useTransition, { useTransitionProps } from '../hooks/use-transition'
|
|
44
|
+
import {
|
|
45
|
+
addEvt,
|
|
46
|
+
cleanEvt,
|
|
47
|
+
clearSelection,
|
|
48
|
+
getColor,
|
|
49
|
+
isMobileOrTablet
|
|
50
|
+
} from '../utils'
|
|
51
|
+
import {
|
|
52
|
+
parsePosition,
|
|
53
|
+
setPosition,
|
|
54
|
+
validateOffset,
|
|
55
|
+
validatePosition
|
|
56
|
+
} from '../utils/position-engine'
|
|
57
|
+
import { getScrollTarget } from '../utils/scroll'
|
|
58
|
+
import useWindowSize from '../hooks/use-window-size'
|
|
59
|
+
import {
|
|
60
|
+
removeClickOutside,
|
|
61
|
+
ClickOutsideEvent,
|
|
62
|
+
addClickOutside
|
|
63
|
+
} from '../utils/click-outside'
|
|
64
|
+
import DlTeleport from '../utils/teleport'
|
|
65
|
+
import { v4 } from 'uuid'
|
|
66
|
+
|
|
67
|
+
export default defineComponent({
|
|
68
|
+
name: 'DlTooltip',
|
|
69
|
+
components: {
|
|
70
|
+
DlTeleport
|
|
71
|
+
},
|
|
72
|
+
inheritAttrs: false,
|
|
73
|
+
props: {
|
|
74
|
+
...useAnchorProps,
|
|
75
|
+
...useTransitionProps,
|
|
76
|
+
color: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: false,
|
|
79
|
+
default: 'dl-color-tooltip-text'
|
|
80
|
+
},
|
|
81
|
+
backgroundColor: {
|
|
82
|
+
type: String,
|
|
83
|
+
required: false,
|
|
84
|
+
default: 'dl-color-tooltip-background'
|
|
85
|
+
},
|
|
86
|
+
maxHeight: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: null
|
|
89
|
+
},
|
|
90
|
+
maxWidth: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: '240px'
|
|
93
|
+
},
|
|
94
|
+
anchor: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: 'bottom middle',
|
|
97
|
+
validator: validatePosition
|
|
98
|
+
},
|
|
99
|
+
self: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: 'top middle',
|
|
102
|
+
validator: validatePosition
|
|
103
|
+
},
|
|
104
|
+
capitalized: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
offset: {
|
|
109
|
+
type: Array,
|
|
110
|
+
default: () => [9, 9],
|
|
111
|
+
validator: validateOffset
|
|
112
|
+
},
|
|
113
|
+
scrollTarget: {
|
|
114
|
+
type: String as PropType<Element | string>,
|
|
115
|
+
default: void 0
|
|
116
|
+
},
|
|
117
|
+
delay: {
|
|
118
|
+
type: Number,
|
|
119
|
+
default: 500
|
|
120
|
+
},
|
|
121
|
+
hideDelay: {
|
|
122
|
+
type: Number,
|
|
123
|
+
default: 0
|
|
124
|
+
},
|
|
125
|
+
textAlignment: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: 'left',
|
|
128
|
+
validator: (v: string) =>
|
|
129
|
+
['left', 'right', 'justify', 'center'].includes(v)
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
setup(props, { emit, attrs }) {
|
|
133
|
+
let unwatchPosition: Function | undefined
|
|
134
|
+
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
let observer: MutationObserver | undefined
|
|
137
|
+
|
|
138
|
+
const vm = getCurrentInstance()
|
|
139
|
+
|
|
140
|
+
const innerRef = ref(null)
|
|
141
|
+
const showing = ref(false)
|
|
142
|
+
|
|
143
|
+
const anchorOrigin = computed(() => parsePosition(props.anchor))
|
|
144
|
+
const selfOrigin = computed(() => parsePosition(props.self))
|
|
145
|
+
|
|
146
|
+
const { registerTick, removeTick } = useTick()
|
|
147
|
+
const { registerTimeout, removeTimeout } = useTimeout()
|
|
148
|
+
const { transitionStyle } = useTransition(props, showing)
|
|
149
|
+
const { width, height } = useWindowSize()
|
|
150
|
+
const {
|
|
151
|
+
localScrollTarget,
|
|
152
|
+
changeScrollEvent,
|
|
153
|
+
unconfigureScrollTarget
|
|
154
|
+
} = useScrollTarget(props, configureScrollTarget)
|
|
155
|
+
|
|
156
|
+
const { anchorEl, canShow, anchorEvents } = useAnchor({
|
|
157
|
+
configureAnchorEl
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const { show, hide } = useModelToggle({
|
|
161
|
+
showing,
|
|
162
|
+
canShow,
|
|
163
|
+
handleShow,
|
|
164
|
+
handleHide,
|
|
165
|
+
processOnMount: true
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
Object.assign(anchorEvents, { delayShow, delayHide })
|
|
169
|
+
|
|
170
|
+
const { showPortal, hidePortal, portalIsActive, portalEl } = usePortal(
|
|
171
|
+
vm,
|
|
172
|
+
innerRef
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const isMobile = computed(() => isMobileOrTablet())
|
|
176
|
+
// if we're on mobile, let's improve the experience
|
|
177
|
+
// by closing it when user taps outside of it
|
|
178
|
+
if (isMobile.value === true) {
|
|
179
|
+
const clickOutsideProps = {
|
|
180
|
+
anchorEl,
|
|
181
|
+
innerRef,
|
|
182
|
+
onClickOutside(e: AnchorEvent) {
|
|
183
|
+
hide(e)
|
|
184
|
+
return true
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const hasClickOutside = computed(() => showing.value === true)
|
|
189
|
+
|
|
190
|
+
watch(hasClickOutside, (val) => {
|
|
191
|
+
const fn = val === true ? addClickOutside : removeClickOutside
|
|
192
|
+
fn(clickOutsideProps)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
onBeforeUnmount(() => {
|
|
196
|
+
removeClickOutside(clickOutsideProps)
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function handleShow(evt: MouseEvent | TouchEvent) {
|
|
201
|
+
removeTick()
|
|
202
|
+
removeTimeout()
|
|
203
|
+
|
|
204
|
+
showPortal()
|
|
205
|
+
|
|
206
|
+
registerTick(() => {
|
|
207
|
+
updatePosition()
|
|
208
|
+
configureScrollTarget()
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
if (unwatchPosition === void 0) {
|
|
212
|
+
unwatchPosition = watch(
|
|
213
|
+
() =>
|
|
214
|
+
width +
|
|
215
|
+
'|' +
|
|
216
|
+
height +
|
|
217
|
+
'|' +
|
|
218
|
+
props.self +
|
|
219
|
+
'|' +
|
|
220
|
+
props.anchor,
|
|
221
|
+
updatePosition
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
registerTimeout(() => {
|
|
226
|
+
showPortal(true) // done showing portal
|
|
227
|
+
emit('show', evt)
|
|
228
|
+
}, props.transitionDuration)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function handleHide(evt: ClickOutsideEvent) {
|
|
232
|
+
removeTick()
|
|
233
|
+
removeTimeout()
|
|
234
|
+
hidePortal()
|
|
235
|
+
|
|
236
|
+
anchorCleanup()
|
|
237
|
+
|
|
238
|
+
registerTimeout(() => {
|
|
239
|
+
hidePortal(true) // done hiding, now destroy
|
|
240
|
+
emit('hide', evt)
|
|
241
|
+
}, props.transitionDuration)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function anchorCleanup() {
|
|
245
|
+
if (observer !== void 0) {
|
|
246
|
+
observer.disconnect()
|
|
247
|
+
observer = void 0
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (unwatchPosition !== void 0) {
|
|
251
|
+
unwatchPosition()
|
|
252
|
+
unwatchPosition = void 0
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
unconfigureScrollTarget()
|
|
256
|
+
cleanEvt(anchorEvents, 'tooltipTemp')
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function updatePosition() {
|
|
260
|
+
const el = innerRef.value
|
|
261
|
+
|
|
262
|
+
if (anchorEl.value === null || !el) {
|
|
263
|
+
return
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
setPosition({
|
|
267
|
+
el,
|
|
268
|
+
offset: props.offset as number[],
|
|
269
|
+
anchorEl: anchorEl.value as HTMLElement,
|
|
270
|
+
anchorOrigin: anchorOrigin.value,
|
|
271
|
+
selfOrigin: selfOrigin.value,
|
|
272
|
+
maxWidth: props.maxWidth,
|
|
273
|
+
maxHeight: props.maxHeight
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function delayShow(evt: AnchorEvent) {
|
|
278
|
+
if (isMobile.value === true) {
|
|
279
|
+
clearSelection()
|
|
280
|
+
document.body.classList.add('non-selectable')
|
|
281
|
+
|
|
282
|
+
const target = anchorEl.value
|
|
283
|
+
const evts = [
|
|
284
|
+
'touchmove',
|
|
285
|
+
'touchcancel',
|
|
286
|
+
'touchend',
|
|
287
|
+
'click'
|
|
288
|
+
].map((e) => [target, e, 'delayHide', 'passiveCapture'])
|
|
289
|
+
|
|
290
|
+
addEvt(anchorEvents, 'tooltipTemp', evts)
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
registerTimeout(() => {
|
|
294
|
+
show(evt)
|
|
295
|
+
}, props.delay)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function delayHide(evt: AnchorEvent) {
|
|
299
|
+
removeTimeout()
|
|
300
|
+
|
|
301
|
+
if (isMobile.value === true) {
|
|
302
|
+
cleanEvt(anchorEvents, 'tooltipTemp')
|
|
303
|
+
clearSelection()
|
|
304
|
+
// delay needed otherwise selection still occurs
|
|
305
|
+
setTimeout(() => {
|
|
306
|
+
document.body.classList.remove('non-selectable')
|
|
307
|
+
}, 10)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
registerTimeout(() => {
|
|
311
|
+
hide(evt)
|
|
312
|
+
}, props.hideDelay)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function configureAnchorEl() {
|
|
316
|
+
if (props.noParentEvent === true || anchorEl.value === null) {
|
|
317
|
+
return
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const evts =
|
|
321
|
+
isMobile.value === true
|
|
322
|
+
? [[anchorEl.value, 'touchstart', 'delayShow', 'passive']]
|
|
323
|
+
: [
|
|
324
|
+
[
|
|
325
|
+
anchorEl.value,
|
|
326
|
+
'mouseenter',
|
|
327
|
+
'delayShow',
|
|
328
|
+
'passive'
|
|
329
|
+
],
|
|
330
|
+
[anchorEl.value, 'mouseleave', 'delayHide', 'passive']
|
|
331
|
+
]
|
|
332
|
+
|
|
333
|
+
addEvt(anchorEvents, 'anchor', evts)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function configureScrollTarget() {
|
|
337
|
+
if (anchorEl.value !== null || props.scrollTarget !== void 0) {
|
|
338
|
+
(localScrollTarget as Ref<any>).value = getScrollTarget(
|
|
339
|
+
anchorEl.value as HTMLElement,
|
|
340
|
+
props.scrollTarget as Element
|
|
341
|
+
)
|
|
342
|
+
const fn = props.noParentEvent === true ? updatePosition : hide
|
|
343
|
+
|
|
344
|
+
changeScrollEvent((localScrollTarget as Ref<any>).value, fn)
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function handleRouteChange(e: any) {
|
|
349
|
+
if (showing.value === true) {
|
|
350
|
+
hide(e as AnchorEvent)
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
onMounted(() => {
|
|
355
|
+
window.addEventListener('hashchange', handleRouteChange)
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
onBeforeUnmount(() => {
|
|
359
|
+
anchorCleanup()
|
|
360
|
+
window.removeEventListener('hashchange', handleRouteChange)
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
// expose public methods
|
|
364
|
+
Object.assign(vm!.proxy, { updatePosition })
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
uuid: `dl-tooltip-${v4()}`,
|
|
368
|
+
portalIsActive,
|
|
369
|
+
classes: ['dl-tooltip dl-position-engine', attrs.class],
|
|
370
|
+
showing,
|
|
371
|
+
innerRef,
|
|
372
|
+
portalEl: isVue2 ? 'body' : portalEl,
|
|
373
|
+
styles: [
|
|
374
|
+
attrs.style,
|
|
375
|
+
transitionStyle.value,
|
|
376
|
+
{
|
|
377
|
+
'--dl-tooltip-color': getColor(
|
|
378
|
+
props.color,
|
|
379
|
+
'dl-color-tooltip-text'
|
|
380
|
+
),
|
|
381
|
+
'--dl-tooltip-background': getColor(
|
|
382
|
+
props.backgroundColor,
|
|
383
|
+
'dl-color-tooltip-background'
|
|
384
|
+
),
|
|
385
|
+
'--dl-tooltip-text-align': props.textAlignment,
|
|
386
|
+
'--dl-tooltip-text-transform': props.capitalized
|
|
387
|
+
? 'capitalize'
|
|
388
|
+
: 'none'
|
|
389
|
+
}
|
|
390
|
+
] as any
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
template: 'dl-tooltip'
|
|
394
|
+
})
|
|
395
|
+
</script>
|
|
396
|
+
|
|
397
|
+
<style lang="scss">
|
|
398
|
+
.dl-tooltip {
|
|
399
|
+
z-index: var(--dl-z-index-tooltip);
|
|
400
|
+
position: fixed !important;
|
|
401
|
+
overflow-y: auto;
|
|
402
|
+
overflow-x: hidden;
|
|
403
|
+
min-height: 16px;
|
|
404
|
+
padding: 2px 5px;
|
|
405
|
+
font-size: var(--dl-font-size-small);
|
|
406
|
+
line-height: 16px;
|
|
407
|
+
color: var(--dl-tooltip-color);
|
|
408
|
+
background: var(--dl-tooltip-background);
|
|
409
|
+
border-radius: 2px;
|
|
410
|
+
text-transform: none;
|
|
411
|
+
font-family: 'Roboto', sans-serif;
|
|
412
|
+
font-weight: 400;
|
|
413
|
+
text-align: var(--dl-tooltip-text-align);
|
|
414
|
+
white-space: break-spaces;
|
|
415
|
+
word-break: break-word;
|
|
416
|
+
pointer-events: none;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.dl-tooltip {
|
|
420
|
+
z-index: 9000;
|
|
421
|
+
position: fixed !important;
|
|
422
|
+
overflow-y: auto;
|
|
423
|
+
overflow-x: hidden;
|
|
424
|
+
padding: 2px 5px;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.capitalize::first-letter {
|
|
428
|
+
text-transform: var(--dl-tooltip-text-transform);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.dl-position-engine {
|
|
432
|
+
margin-top: var(--dl-pe-top, 0) !important;
|
|
433
|
+
margin-left: var(--dl-pe-left, 0) !important;
|
|
434
|
+
will-change: auto;
|
|
435
|
+
visibility: collapse; // needed for animation - is removed on first positioning;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.fade-enter,
|
|
439
|
+
.fade-enter-active {
|
|
440
|
+
animation: fade-in var(--dl-transition-duration);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.fade-leave-active,
|
|
444
|
+
.fade-leave-to {
|
|
445
|
+
animation: fade-in var(--dl-transition-duration) reverse;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
@keyframes fade-in {
|
|
449
|
+
0% {
|
|
450
|
+
opacity: 0;
|
|
451
|
+
}
|
|
452
|
+
100% {
|
|
453
|
+
opacity: 1;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
</style>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:id="uuid"
|
|
4
|
+
class="trend-wrapper"
|
|
5
|
+
>
|
|
6
|
+
<span
|
|
7
|
+
v-if="withArrow"
|
|
8
|
+
class="direction-arrow"
|
|
9
|
+
:class="{
|
|
10
|
+
down: isDown
|
|
11
|
+
}"
|
|
12
|
+
:style="{ '--trend-triangle-color': computedColor }"
|
|
13
|
+
/>
|
|
14
|
+
<span class="value">
|
|
15
|
+
{{ computedValue }}
|
|
16
|
+
</span>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
import { v4 } from 'uuid'
|
|
22
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
23
|
+
import { getColor } from '../utils'
|
|
24
|
+
|
|
25
|
+
const colorValidator = (val: string | null) =>
|
|
26
|
+
val === 'negative' || val === 'positive' || val === null
|
|
27
|
+
|
|
28
|
+
export default defineComponent({
|
|
29
|
+
name: 'DlTrend',
|
|
30
|
+
props: {
|
|
31
|
+
value: {
|
|
32
|
+
type: [Number, String],
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
direction: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: 'up',
|
|
38
|
+
validator: (val) => val === 'up' || val === 'down'
|
|
39
|
+
},
|
|
40
|
+
color: {
|
|
41
|
+
type: String as PropType<'negative' | 'positive' | null>,
|
|
42
|
+
default: null,
|
|
43
|
+
validator: colorValidator
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
uuid: `dl-trend-${v4()}`
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
computedValue(): string {
|
|
53
|
+
if (typeof this.value === 'number') {
|
|
54
|
+
return `${this.value}%`
|
|
55
|
+
}
|
|
56
|
+
return this.value
|
|
57
|
+
},
|
|
58
|
+
isUp(): boolean {
|
|
59
|
+
return this.direction === 'up'
|
|
60
|
+
},
|
|
61
|
+
isDown(): boolean {
|
|
62
|
+
return this.direction === 'down'
|
|
63
|
+
},
|
|
64
|
+
computedColor(): string {
|
|
65
|
+
if (this.color !== null || !colorValidator(this.color)) {
|
|
66
|
+
return getColor(`dl-color-${this.color}`)
|
|
67
|
+
}
|
|
68
|
+
return getColor(`dl-color-${this.isUp ? 'positive' : 'negative'}`)
|
|
69
|
+
},
|
|
70
|
+
withArrow(): boolean {
|
|
71
|
+
return !(this.value === 0 || this.value === '0')
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
</script>
|
|
76
|
+
<style scoped lang="scss">
|
|
77
|
+
.trend-wrapper {
|
|
78
|
+
display: flex;
|
|
79
|
+
gap: 3px;
|
|
80
|
+
align-items: center;
|
|
81
|
+
}
|
|
82
|
+
.value {
|
|
83
|
+
font-size: var(--dl-font-size-body);
|
|
84
|
+
line-height: 1;
|
|
85
|
+
padding: 2px 0;
|
|
86
|
+
color: var(--dl-color-darker);
|
|
87
|
+
}
|
|
88
|
+
.direction-arrow {
|
|
89
|
+
width: 8px;
|
|
90
|
+
height: 8px;
|
|
91
|
+
clip-path: polygon(50% 5%, 4% 80%, 96% 80%);
|
|
92
|
+
background-color: var(--trend-triangle-color);
|
|
93
|
+
&.down {
|
|
94
|
+
transform: rotate(180deg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="variant"
|
|
4
|
+
:id="uuid"
|
|
5
|
+
:class="classes"
|
|
6
|
+
:style="styles"
|
|
7
|
+
>
|
|
8
|
+
<slot />
|
|
9
|
+
</component>
|
|
10
|
+
</template>
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { v4 } from 'uuid'
|
|
13
|
+
import { defineComponent, PropType } from 'vue-demi'
|
|
14
|
+
import { getColor } from '../utils'
|
|
15
|
+
|
|
16
|
+
type Variant = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p'
|
|
17
|
+
|
|
18
|
+
const sizes = ['h1', 'h2', 'h3', 'h4', 'body']
|
|
19
|
+
|
|
20
|
+
export default defineComponent({
|
|
21
|
+
name: 'DlTypography',
|
|
22
|
+
props: {
|
|
23
|
+
variant: {
|
|
24
|
+
type: String as PropType<Variant>,
|
|
25
|
+
required: false,
|
|
26
|
+
default: 'p'
|
|
27
|
+
},
|
|
28
|
+
size: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: 'body'
|
|
31
|
+
},
|
|
32
|
+
uppercase: Boolean,
|
|
33
|
+
bold: Boolean,
|
|
34
|
+
color: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: 'dl-color-darker'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
uuid: `dl-typography-${v4()}`
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
computed: {
|
|
45
|
+
styles(): Record<string, string | number> {
|
|
46
|
+
const styles: Record<string, string | number> = {
|
|
47
|
+
color: getColor(this.color as string, 'dl-color-darker'),
|
|
48
|
+
textTransform: this.uppercase ? 'uppercase' : 'none',
|
|
49
|
+
fontWeight: this.bold ? 'bold' : 400
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!sizes.includes(this.size)) {
|
|
53
|
+
styles.fontSize = this.size as string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return styles
|
|
57
|
+
},
|
|
58
|
+
classes(): string[] {
|
|
59
|
+
return [`dl-typography dl-typography--${this.size}`]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
<style scoped lang="scss">
|
|
65
|
+
.dl-typography {
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding: 0;
|
|
68
|
+
&--h1 {
|
|
69
|
+
font-size: var(--dl-font-size-h1);
|
|
70
|
+
}
|
|
71
|
+
&--h2 {
|
|
72
|
+
font-size: var(--dl-font-size-h2);
|
|
73
|
+
}
|
|
74
|
+
&--h3 {
|
|
75
|
+
font-size: var(--dl-font-size-h3);
|
|
76
|
+
}
|
|
77
|
+
&--h4 {
|
|
78
|
+
font-size: var(--dl-font-size-h4);
|
|
79
|
+
}
|
|
80
|
+
&--body {
|
|
81
|
+
font-size: var(--dl-font-size-body);
|
|
82
|
+
}
|
|
83
|
+
&--small {
|
|
84
|
+
font-size: var(--dl-font-size-small);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
</style>
|