@dataloop-ai/components 0.20.154 → 0.20.155
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
|
@@ -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>
|