@dataloop-ai/components 0.20.154 → 0.20.156
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
CHANGED
|
@@ -64,6 +64,8 @@
|
|
|
64
64
|
:icon="dropdownIcon"
|
|
65
65
|
:size="iconSize"
|
|
66
66
|
:color="getIconColor"
|
|
67
|
+
:tooltip="iconTooltip"
|
|
68
|
+
@click="onIconClicked"
|
|
67
69
|
/>
|
|
68
70
|
</dl-button>
|
|
69
71
|
<dl-menu
|
|
@@ -132,6 +134,8 @@
|
|
|
132
134
|
:icon="dropdownIcon"
|
|
133
135
|
:size="iconSize"
|
|
134
136
|
:color="getIconColor"
|
|
137
|
+
:tooltip="iconTooltip"
|
|
138
|
+
@click="onIconClicked"
|
|
135
139
|
/>
|
|
136
140
|
</div>
|
|
137
141
|
|
|
@@ -235,6 +239,11 @@ export default defineComponent({
|
|
|
235
239
|
fluid: Boolean,
|
|
236
240
|
icon: { type: String, required: false, default: '' },
|
|
237
241
|
iconSize: { type: String, required: false, default: '20px' },
|
|
242
|
+
iconTooltip: {
|
|
243
|
+
type: String,
|
|
244
|
+
required: false,
|
|
245
|
+
default: null
|
|
246
|
+
},
|
|
238
247
|
flat: Boolean,
|
|
239
248
|
transform: {
|
|
240
249
|
type: String as PropType<DlTextTransformOptions>,
|
|
@@ -276,6 +285,7 @@ export default defineComponent({
|
|
|
276
285
|
'update:model-value',
|
|
277
286
|
'update:model-value',
|
|
278
287
|
'click',
|
|
288
|
+
'icon-clicked',
|
|
279
289
|
'before-show',
|
|
280
290
|
'show',
|
|
281
291
|
'before-hide',
|
|
@@ -384,6 +394,10 @@ export default defineComponent({
|
|
|
384
394
|
emit('click', e)
|
|
385
395
|
}
|
|
386
396
|
|
|
397
|
+
function onIconClicked(e: Event) {
|
|
398
|
+
emit('icon-clicked', e)
|
|
399
|
+
}
|
|
400
|
+
|
|
387
401
|
function onClickHide(e: Event) {
|
|
388
402
|
stop(e)
|
|
389
403
|
hide(e)
|
|
@@ -486,6 +500,7 @@ export default defineComponent({
|
|
|
486
500
|
onShow,
|
|
487
501
|
onHide,
|
|
488
502
|
onClick,
|
|
503
|
+
onIconClicked,
|
|
489
504
|
onClickHide,
|
|
490
505
|
toggle,
|
|
491
506
|
show,
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
{{ externalIcon ? icon : null }}
|
|
19
19
|
</i>
|
|
20
20
|
<slot />
|
|
21
|
+
<dl-tooltip v-if="tooltip">
|
|
22
|
+
{{ tooltip }}
|
|
23
|
+
</dl-tooltip>
|
|
21
24
|
</div>
|
|
22
25
|
<div
|
|
23
26
|
v-else
|
|
@@ -48,9 +51,13 @@ import {
|
|
|
48
51
|
} from 'vue-demi'
|
|
49
52
|
import { getColor, loggerFactory, stringStyleToRecord } from '../../../utils'
|
|
50
53
|
import { COLORED_ICONS } from '@dataloop-ai/icons/types'
|
|
54
|
+
import { DlTooltip } from '../../shared'
|
|
51
55
|
|
|
52
56
|
export default defineComponent({
|
|
53
57
|
name: 'DlIcon',
|
|
58
|
+
components: {
|
|
59
|
+
DlTooltip
|
|
60
|
+
},
|
|
54
61
|
props: {
|
|
55
62
|
color: {
|
|
56
63
|
type: String,
|
|
@@ -79,11 +86,15 @@ export default defineComponent({
|
|
|
79
86
|
svgSource: {
|
|
80
87
|
type: String,
|
|
81
88
|
default: null
|
|
89
|
+
},
|
|
90
|
+
tooltip: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: null
|
|
82
93
|
}
|
|
83
94
|
},
|
|
84
95
|
emits: ['click', 'mousemove', 'mouseup', 'mousedown'],
|
|
85
96
|
setup(props) {
|
|
86
|
-
const { styles, color, size, icon, svg, inline, svgSource } =
|
|
97
|
+
const { styles, color, size, icon, svg, inline, svgSource, tooltip } =
|
|
87
98
|
toRefs(props)
|
|
88
99
|
|
|
89
100
|
const svgIcon = ref(null)
|
|
@@ -75,13 +75,20 @@ import {
|
|
|
75
75
|
refocusTargetFn,
|
|
76
76
|
conditionalHandler
|
|
77
77
|
} from './utils'
|
|
78
|
-
import {
|
|
78
|
+
import {
|
|
79
|
+
addEvt,
|
|
80
|
+
isMobileOrTablet
|
|
81
|
+
} from '../../../utils'
|
|
79
82
|
import { v4 } from 'uuid'
|
|
80
83
|
import {
|
|
81
84
|
arrowNavigationEvents,
|
|
82
85
|
useArrowNavigation
|
|
83
86
|
} from '../../../hooks/use-arrow-navigation'
|
|
84
87
|
|
|
88
|
+
const hoverGroupHiders: {
|
|
89
|
+
[group: string]: ((evt: AnchorEvent) => void)[]
|
|
90
|
+
} = {}
|
|
91
|
+
|
|
85
92
|
export default defineComponent({
|
|
86
93
|
name: 'DlMenu',
|
|
87
94
|
components: {
|
|
@@ -108,6 +115,11 @@ export default defineComponent({
|
|
|
108
115
|
|
|
109
116
|
square: Boolean,
|
|
110
117
|
|
|
118
|
+
hoverGroup: {
|
|
119
|
+
type: String,
|
|
120
|
+
default: ''
|
|
121
|
+
},
|
|
122
|
+
|
|
111
123
|
anchor: {
|
|
112
124
|
type: String,
|
|
113
125
|
default: 'bottom left',
|
|
@@ -206,10 +218,20 @@ export default defineComponent({
|
|
|
206
218
|
unconfigureScrollTarget
|
|
207
219
|
} = useScrollTarget(props, configureScrollTarget)
|
|
208
220
|
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
const isMobile = computed(() => isMobileOrTablet())
|
|
222
|
+
|
|
223
|
+
const { anchorEl, canShow, anchorEvents } = useAnchor(
|
|
224
|
+
props.hoverGroup && !isMobile.value
|
|
225
|
+
? {
|
|
226
|
+
configureAnchorEl
|
|
227
|
+
}
|
|
228
|
+
: {
|
|
229
|
+
toggleKey: toggleKey.value,
|
|
230
|
+
ignoreEvents: ignoreEvents.value
|
|
231
|
+
}
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
Object.assign(anchorEvents, { delayShow })
|
|
213
235
|
|
|
214
236
|
const screen = useWindowSize()
|
|
215
237
|
|
|
@@ -222,7 +244,7 @@ export default defineComponent({
|
|
|
222
244
|
|
|
223
245
|
const isInitialized = ref(false)
|
|
224
246
|
|
|
225
|
-
const { hide } = useModelToggle({
|
|
247
|
+
const { show, hide } = useModelToggle({
|
|
226
248
|
showing,
|
|
227
249
|
canShow,
|
|
228
250
|
handleShow,
|
|
@@ -282,8 +304,6 @@ export default defineComponent({
|
|
|
282
304
|
})
|
|
283
305
|
}
|
|
284
306
|
|
|
285
|
-
const isMobile = computed(() => isMobileOrTablet())
|
|
286
|
-
|
|
287
307
|
function handleShow(evt: MouseEvent | TouchEvent) {
|
|
288
308
|
isMenuOpen.value = true
|
|
289
309
|
removeTick()
|
|
@@ -463,7 +483,54 @@ export default defineComponent({
|
|
|
463
483
|
})
|
|
464
484
|
}
|
|
465
485
|
|
|
466
|
-
|
|
486
|
+
const {
|
|
487
|
+
registerTimeout: registerHoverTimeout,
|
|
488
|
+
removeTimeout: removeHoverTimeout
|
|
489
|
+
} = useTimeout()
|
|
490
|
+
|
|
491
|
+
function delayShow(evt: AnchorEvent) {
|
|
492
|
+
for (const hider of hoverGroupHiders[props.hoverGroup]) {
|
|
493
|
+
if (hider !== delayHide) {
|
|
494
|
+
hider(evt)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
removeHoverTimeout()
|
|
498
|
+
registerHoverTimeout(() => {
|
|
499
|
+
show(evt)
|
|
500
|
+
}, 250)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function delayHide(evt: AnchorEvent) {
|
|
504
|
+
removeHoverTimeout()
|
|
505
|
+
registerHoverTimeout(() => {
|
|
506
|
+
hide(evt)
|
|
507
|
+
}, 250)
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function configureAnchorEl() {
|
|
511
|
+
if (anchorEl.value === null) {
|
|
512
|
+
return
|
|
513
|
+
}
|
|
514
|
+
addEvt(anchorEvents, 'anchor', [
|
|
515
|
+
[anchorEl.value, 'mouseenter', 'delayShow', 'passive']
|
|
516
|
+
])
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if (props.hoverGroup) {
|
|
520
|
+
hoverGroupHiders[props.hoverGroup] = hoverGroupHiders[props.hoverGroup] ?? []
|
|
521
|
+
hoverGroupHiders[props.hoverGroup].push(delayHide)
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
onBeforeUnmount(() => {
|
|
525
|
+
anchorCleanup(false)
|
|
526
|
+
if (props.hoverGroup) {
|
|
527
|
+
const hiders = hoverGroupHiders[props.hoverGroup]
|
|
528
|
+
hiders.splice(hiders.indexOf(delayHide), 1)
|
|
529
|
+
if (hiders.length === 0) {
|
|
530
|
+
delete hoverGroupHiders[props.hoverGroup]
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
})
|
|
467
534
|
|
|
468
535
|
// expose public methods
|
|
469
536
|
Object.assign(proxy, { focus, updatePosition })
|
package/src/demos/DlMenuDemo.vue
CHANGED
|
@@ -88,6 +88,65 @@
|
|
|
88
88
|
</dl-menu>
|
|
89
89
|
</dl-button>
|
|
90
90
|
|
|
91
|
+
<dl-button label="Auto-opening Submenus">
|
|
92
|
+
<dl-menu
|
|
93
|
+
auto-close
|
|
94
|
+
anchor="top end"
|
|
95
|
+
self="top start"
|
|
96
|
+
>
|
|
97
|
+
<dl-list bordered>
|
|
98
|
+
<dl-list-item
|
|
99
|
+
v-for="i in 3"
|
|
100
|
+
:key="i"
|
|
101
|
+
clickable
|
|
102
|
+
end-icon="icon-dl-right-chevron"
|
|
103
|
+
>
|
|
104
|
+
<dl-item-section no-wrap>
|
|
105
|
+
Submenu {{ i }}
|
|
106
|
+
</dl-item-section>
|
|
107
|
+
<dl-menu
|
|
108
|
+
auto-close
|
|
109
|
+
anchor="top end"
|
|
110
|
+
self="top start"
|
|
111
|
+
hover-group="main-submenus"
|
|
112
|
+
>
|
|
113
|
+
<dl-list bordered>
|
|
114
|
+
<dl-list-item
|
|
115
|
+
v-for="j in 3"
|
|
116
|
+
:key="j"
|
|
117
|
+
clickable
|
|
118
|
+
end-icon="icon-dl-right-chevron"
|
|
119
|
+
>
|
|
120
|
+
<dl-item-section no-wrap>
|
|
121
|
+
Submenu {{ i }}. {{ j }}
|
|
122
|
+
</dl-item-section>
|
|
123
|
+
<dl-menu
|
|
124
|
+
auto-close
|
|
125
|
+
anchor="top end"
|
|
126
|
+
self="top start"
|
|
127
|
+
:hover-group="`submenus-${i}`"
|
|
128
|
+
>
|
|
129
|
+
<dl-list bordered>
|
|
130
|
+
<dl-list-item
|
|
131
|
+
v-for="k in 3"
|
|
132
|
+
:key="k"
|
|
133
|
+
clickable
|
|
134
|
+
dense
|
|
135
|
+
>
|
|
136
|
+
<dl-item-section no-wrap>
|
|
137
|
+
Submenu item {{ k }}
|
|
138
|
+
</dl-item-section>
|
|
139
|
+
</dl-list-item>
|
|
140
|
+
</dl-list>
|
|
141
|
+
</dl-menu>
|
|
142
|
+
</dl-list-item>
|
|
143
|
+
</dl-list>
|
|
144
|
+
</dl-menu>
|
|
145
|
+
</dl-list-item>
|
|
146
|
+
</dl-list>
|
|
147
|
+
</dl-menu>
|
|
148
|
+
</dl-button>
|
|
149
|
+
|
|
91
150
|
<dl-button label="Basic Menu With SubText">
|
|
92
151
|
This is a menu button
|
|
93
152
|
<dl-menu>
|