@destyler/hover-card 0.0.2 → 0.0.4
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/README.md +7 -0
- package/dist/component.cjs +155 -209
- package/dist/component.d.cts +247 -98
- package/dist/component.d.mts +247 -98
- package/dist/component.d.ts +247 -98
- package/dist/component.mjs +145 -208
- package/dist/index.cjs +12 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -2
- package/dist/resolver.cjs +10 -6
- package/dist/resolver.d.cts +3 -3
- package/dist/resolver.d.mts +3 -3
- package/dist/resolver.d.ts +3 -3
- package/dist/resolver.mjs +9 -5
- package/dist/shared/hover-card.c926f135.d.cts +843 -0
- package/dist/shared/hover-card.c926f135.d.mts +843 -0
- package/dist/shared/hover-card.c926f135.d.ts +843 -0
- package/package.json +19 -20
- package/dist/shared/hover-card.2208f99f.d.cts +0 -546
- package/dist/shared/hover-card.2208f99f.d.mts +0 -546
- package/dist/shared/hover-card.2208f99f.d.ts +0 -546
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @destyler/hover-card
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@destyler/hover-card)
|
|
4
|
+
|
|
5
|
+
> for sighted users to preview content available behind a link.
|
|
6
|
+
|
|
7
|
+
[GitHub](https://github.com/destyler/destyler) | [Documentation](https://destyler-dev.zeabur.app/)
|
package/dist/component.cjs
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
+
const primitive = require('@destyler/primitive');
|
|
4
5
|
const composition = require('@destyler/composition');
|
|
5
6
|
const popper = require('@destyler/popper');
|
|
6
7
|
const presence = require('@destyler/presence');
|
|
7
8
|
const dismissableLayer = require('@destyler/dismissable-layer');
|
|
9
|
+
const component = require('@destyler/dismissable-layer/component');
|
|
8
10
|
const shared = require('@destyler/shared');
|
|
9
11
|
const teleport = require('@destyler/teleport');
|
|
10
|
-
const primitive = require('@destyler/primitive');
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const hoverCardArrowProps = {
|
|
14
|
+
...primitive.primitiveProps,
|
|
15
|
+
/**
|
|
16
|
+
* @default svg
|
|
17
|
+
*/
|
|
18
|
+
as: {
|
|
19
|
+
...primitive.primitiveProps.as,
|
|
20
|
+
default: "svg"
|
|
17
21
|
},
|
|
22
|
+
/**
|
|
23
|
+
* The width of the arrow in pixels.
|
|
24
|
+
*
|
|
25
|
+
* @default 10
|
|
26
|
+
*/
|
|
18
27
|
width: {
|
|
19
28
|
type: Number,
|
|
20
29
|
required: false,
|
|
21
30
|
default: 10
|
|
22
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* The height of the arrow in pixels.
|
|
34
|
+
*
|
|
35
|
+
* @default 5
|
|
36
|
+
*/
|
|
23
37
|
height: {
|
|
24
38
|
type: Number,
|
|
25
39
|
required: false,
|
|
26
40
|
default: 5
|
|
27
|
-
},
|
|
28
|
-
as: {
|
|
29
|
-
type: [String, Object],
|
|
30
|
-
required: false,
|
|
31
|
-
default: "svg"
|
|
32
41
|
}
|
|
33
42
|
};
|
|
34
|
-
const
|
|
43
|
+
const HoverCardArrow = vue.defineComponent({
|
|
35
44
|
name: "DestylerHoverCardArrow",
|
|
36
|
-
props:
|
|
45
|
+
props: hoverCardArrowProps,
|
|
37
46
|
setup() {
|
|
38
47
|
composition.useForwardExpose();
|
|
39
48
|
},
|
|
40
49
|
render() {
|
|
41
|
-
return vue.h(popper.
|
|
42
|
-
default: () => this.$slots.default?.()
|
|
43
|
-
});
|
|
50
|
+
return vue.h(popper.PopperArrow, this.$props, () => this.$slots.default?.());
|
|
44
51
|
}
|
|
45
52
|
});
|
|
46
53
|
|
|
@@ -59,32 +66,63 @@ function getTabbableNodes(container) {
|
|
|
59
66
|
return nodes;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
const
|
|
69
|
+
const hoverCardRootProps = {
|
|
70
|
+
/**
|
|
71
|
+
* The controlled open state of the hover card.
|
|
72
|
+
* Can be binded as `v-model:open`.
|
|
73
|
+
*
|
|
74
|
+
* @default undefined
|
|
75
|
+
*/
|
|
63
76
|
open: {
|
|
64
77
|
type: Boolean,
|
|
65
|
-
required:
|
|
78
|
+
required: false,
|
|
79
|
+
default: void 0
|
|
66
80
|
},
|
|
81
|
+
/**
|
|
82
|
+
* The open state of the hover card when it is initially rendered.
|
|
83
|
+
* Use when you do not need to control its open state.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
67
87
|
defaultOpen: {
|
|
68
88
|
type: Boolean,
|
|
69
89
|
required: false,
|
|
70
90
|
default: false
|
|
71
91
|
},
|
|
92
|
+
/**
|
|
93
|
+
* The duration from when the mouse enters the
|
|
94
|
+
* trigger until the hover card opens.
|
|
95
|
+
*
|
|
96
|
+
* @default 700
|
|
97
|
+
*/
|
|
72
98
|
openDelay: {
|
|
73
99
|
type: Number,
|
|
74
100
|
required: false,
|
|
75
101
|
default: 700
|
|
76
102
|
},
|
|
103
|
+
/**
|
|
104
|
+
* The duration from when the mouse leaves the trigger
|
|
105
|
+
* or content until the hover card closes.
|
|
106
|
+
*
|
|
107
|
+
* @default 300
|
|
108
|
+
*/
|
|
77
109
|
closeDelay: {
|
|
78
110
|
type: Number,
|
|
79
111
|
required: false,
|
|
80
112
|
default: 300
|
|
81
113
|
}
|
|
82
114
|
};
|
|
115
|
+
const hoverCardRootEmits = {
|
|
116
|
+
/**
|
|
117
|
+
* Event handler called when the open state of the hover card changes.
|
|
118
|
+
*/
|
|
119
|
+
"update:open": (_value) => true
|
|
120
|
+
};
|
|
83
121
|
const [injectHoverCardRootContext, provideHoverCardRootContext] = shared.createContext("DestylerHoverCardRoot");
|
|
84
|
-
const
|
|
122
|
+
const HoverCardRoot = vue.defineComponent({
|
|
85
123
|
name: "DestylerHoverCardRoot",
|
|
86
|
-
props:
|
|
87
|
-
emits:
|
|
124
|
+
props: hoverCardRootProps,
|
|
125
|
+
emits: hoverCardRootEmits,
|
|
88
126
|
setup(props, { emit }) {
|
|
89
127
|
const { openDelay, closeDelay } = vue.toRefs(props);
|
|
90
128
|
composition.useForwardExpose();
|
|
@@ -121,92 +159,20 @@ const DestylerHoverCardRoot = vue.defineComponent({
|
|
|
121
159
|
});
|
|
122
160
|
},
|
|
123
161
|
render() {
|
|
124
|
-
return vue.h(popper.
|
|
125
|
-
default: () => this.$slots.default?.()
|
|
126
|
-
});
|
|
162
|
+
return vue.h(popper.PopperRoot, {}, () => this.$slots.default?.());
|
|
127
163
|
}
|
|
128
164
|
});
|
|
129
165
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
},
|
|
136
|
-
asChild: {
|
|
137
|
-
type: Boolean,
|
|
138
|
-
required: false,
|
|
139
|
-
default: false
|
|
140
|
-
},
|
|
141
|
-
side: {
|
|
142
|
-
type: String,
|
|
143
|
-
required: false,
|
|
144
|
-
default: "bottom"
|
|
145
|
-
},
|
|
146
|
-
sideOffset: {
|
|
147
|
-
type: Number,
|
|
148
|
-
required: false,
|
|
149
|
-
default: 0
|
|
150
|
-
},
|
|
151
|
-
align: {
|
|
152
|
-
type: String,
|
|
153
|
-
required: false,
|
|
154
|
-
default: "center"
|
|
155
|
-
},
|
|
156
|
-
alignOffset: {
|
|
157
|
-
type: Number,
|
|
158
|
-
required: false,
|
|
159
|
-
default: 0
|
|
160
|
-
},
|
|
161
|
-
avoidCollisions: {
|
|
162
|
-
type: Boolean,
|
|
163
|
-
required: false,
|
|
164
|
-
default: true
|
|
165
|
-
},
|
|
166
|
-
collisionBoundary: {
|
|
167
|
-
type: [Object, Array, null],
|
|
168
|
-
required: false,
|
|
169
|
-
default: () => []
|
|
170
|
-
},
|
|
171
|
-
collisionPadding: {
|
|
172
|
-
type: [Number, Object],
|
|
173
|
-
required: false,
|
|
174
|
-
default: 0
|
|
175
|
-
},
|
|
176
|
-
arrowPadding: {
|
|
177
|
-
type: Number,
|
|
178
|
-
required: false,
|
|
179
|
-
default: 0
|
|
180
|
-
},
|
|
181
|
-
sticky: {
|
|
182
|
-
type: String,
|
|
183
|
-
required: false,
|
|
184
|
-
default: "partial"
|
|
185
|
-
},
|
|
186
|
-
hideWhenDetached: {
|
|
187
|
-
type: Boolean,
|
|
188
|
-
required: false,
|
|
189
|
-
default: false
|
|
190
|
-
},
|
|
191
|
-
updatePositionStrategy: {
|
|
192
|
-
type: String,
|
|
193
|
-
required: false,
|
|
194
|
-
default: "optimized"
|
|
195
|
-
},
|
|
196
|
-
onPlaced: {
|
|
197
|
-
type: Function,
|
|
198
|
-
required: false
|
|
199
|
-
},
|
|
200
|
-
prioritizePosition: {
|
|
201
|
-
type: Boolean,
|
|
202
|
-
required: false,
|
|
203
|
-
default: false
|
|
204
|
-
}
|
|
166
|
+
const hoverCardContentImplProps = {
|
|
167
|
+
...popper.popperContentProps
|
|
168
|
+
};
|
|
169
|
+
const hoverCardContentImplEmits = {
|
|
170
|
+
...component.dismissableLayerEmits
|
|
205
171
|
};
|
|
206
|
-
const
|
|
172
|
+
const HoverCardContentImpl = vue.defineComponent({
|
|
207
173
|
name: "DestylerHoverCardContentImpl",
|
|
208
|
-
props:
|
|
209
|
-
emits:
|
|
174
|
+
props: hoverCardContentImplProps,
|
|
175
|
+
emits: hoverCardContentImplEmits,
|
|
210
176
|
setup(props) {
|
|
211
177
|
const forwarded = composition.useForwardProps(props);
|
|
212
178
|
const { forwardRef, currentElement: contentElement } = composition.useForwardExpose();
|
|
@@ -238,7 +204,7 @@ const DestylerHoverCardContentImpl = vue.defineComponent({
|
|
|
238
204
|
if (contentElement.value) {
|
|
239
205
|
document.addEventListener("pointerup", handlePointerUp);
|
|
240
206
|
const tabbables = getTabbableNodes(contentElement.value);
|
|
241
|
-
tabbables.forEach((tabbable) => tabbable.setAttribute("tabindex", "
|
|
207
|
+
tabbables.forEach((tabbable) => tabbable.setAttribute("tabindex", "-1"));
|
|
242
208
|
}
|
|
243
209
|
});
|
|
244
210
|
vue.onUnmounted(() => {
|
|
@@ -254,7 +220,7 @@ const DestylerHoverCardContentImpl = vue.defineComponent({
|
|
|
254
220
|
};
|
|
255
221
|
},
|
|
256
222
|
render() {
|
|
257
|
-
return vue.h(dismissableLayer.
|
|
223
|
+
return vue.h(dismissableLayer.DismissableLayer, {
|
|
258
224
|
asChild: true,
|
|
259
225
|
disableOutsidePointerEvents: false,
|
|
260
226
|
onEscapeKeyDown: (event) => {
|
|
@@ -269,45 +235,46 @@ const DestylerHoverCardContentImpl = vue.defineComponent({
|
|
|
269
235
|
onDismiss: () => {
|
|
270
236
|
this.rootContext.onDismiss();
|
|
271
237
|
}
|
|
272
|
-
}, {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
this.rootContext.hasSelectionRef.value = false;
|
|
290
|
-
this.rootContext.isPointerDownOnContentRef.value = true;
|
|
291
|
-
}
|
|
292
|
-
}), {
|
|
293
|
-
default: () => this.$slots.default?.()
|
|
294
|
-
});
|
|
238
|
+
}, () => vue.h(popper.PopperContent, vue.mergeProps(this.forwarded, this.$attrs, {
|
|
239
|
+
"ref": (el) => this.forwardRef(el),
|
|
240
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
241
|
+
"style": {
|
|
242
|
+
"userSelect": this.containSelection ? "text" : void 0,
|
|
243
|
+
"WebkitUserSelect": this.containSelection ? "text" : void 0,
|
|
244
|
+
"--destyler-hover-card-content-transform-origin": "var(--destyler-popper-transform-origin)",
|
|
245
|
+
"--destyler-hover-card-content-available-width": "var(--destyler-popper-available-width)",
|
|
246
|
+
"--destyler-hover-card-content-available-height": "var(--destyler-popper-available-height)",
|
|
247
|
+
"--destyler-hover-card-trigger-width": "var(--destyler-popper-anchor-width)",
|
|
248
|
+
"--destyler-hover-card-trigger-height": "var(--destyler-popper-anchor-height)"
|
|
249
|
+
},
|
|
250
|
+
"onPointerdown": (event) => {
|
|
251
|
+
if (event.currentTarget.contains(event.target))
|
|
252
|
+
this.containSelection = true;
|
|
253
|
+
this.rootContext.hasSelectionRef.value = false;
|
|
254
|
+
this.rootContext.isPointerDownOnContentRef.value = true;
|
|
295
255
|
}
|
|
296
|
-
});
|
|
256
|
+
}), () => this.$slots.default?.()));
|
|
297
257
|
}
|
|
298
258
|
});
|
|
299
259
|
|
|
300
|
-
const
|
|
301
|
-
...
|
|
260
|
+
const hoverCardContentProps = {
|
|
261
|
+
...hoverCardContentImplProps,
|
|
262
|
+
/**
|
|
263
|
+
* Used to force mounting when more control is needed.
|
|
264
|
+
* Useful when controlling animation with Vue animation libraries.
|
|
265
|
+
*/
|
|
302
266
|
forceMount: {
|
|
303
267
|
type: Boolean,
|
|
304
268
|
required: false
|
|
305
269
|
}
|
|
306
270
|
};
|
|
307
|
-
const
|
|
271
|
+
const hoverCardContentEmits = {
|
|
272
|
+
...hoverCardContentImplEmits
|
|
273
|
+
};
|
|
274
|
+
const HoverCardContent = vue.defineComponent({
|
|
308
275
|
name: "DestylerHoverCardContent",
|
|
309
|
-
props:
|
|
310
|
-
emits:
|
|
276
|
+
props: hoverCardContentProps,
|
|
277
|
+
emits: hoverCardContentEmits,
|
|
311
278
|
setup(props, { emit }) {
|
|
312
279
|
const forwarded = composition.useForwardPropsEmits(props, emit);
|
|
313
280
|
const { forwardRef } = composition.useForwardExpose();
|
|
@@ -319,68 +286,44 @@ const DestylerHoverCardContent = vue.defineComponent({
|
|
|
319
286
|
};
|
|
320
287
|
},
|
|
321
288
|
render() {
|
|
322
|
-
return vue.h(presence.
|
|
289
|
+
return vue.h(presence.Presence, {
|
|
323
290
|
present: this.forceMount || this.rootContext.open.value
|
|
324
|
-
}, {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
onPointerleave: (event) => {
|
|
332
|
-
excludeTouch(this.rootContext.onClose)(event);
|
|
333
|
-
}
|
|
334
|
-
}), {
|
|
335
|
-
default: () => this.$slots.default?.()
|
|
336
|
-
});
|
|
291
|
+
}, () => vue.h(HoverCardContentImpl, vue.mergeProps(this.forwarded, {
|
|
292
|
+
ref: (el) => this.forwardRef(el),
|
|
293
|
+
onPointerenter: (event) => {
|
|
294
|
+
excludeTouch(this.rootContext.onOpen)(event);
|
|
295
|
+
},
|
|
296
|
+
onPointerleave: (event) => {
|
|
297
|
+
excludeTouch(this.rootContext.onClose)(event);
|
|
337
298
|
}
|
|
338
|
-
});
|
|
299
|
+
}), () => this.$slots.default?.()));
|
|
339
300
|
}
|
|
340
301
|
});
|
|
341
302
|
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
type: [String, Object],
|
|
345
|
-
required: false,
|
|
346
|
-
default: "body"
|
|
347
|
-
},
|
|
348
|
-
disabled: {
|
|
349
|
-
type: Boolean,
|
|
350
|
-
required: false,
|
|
351
|
-
default: false
|
|
352
|
-
},
|
|
353
|
-
forceMount: {
|
|
354
|
-
type: Boolean,
|
|
355
|
-
required: false,
|
|
356
|
-
default: false
|
|
357
|
-
}
|
|
303
|
+
const hoverCardPortalProps = {
|
|
304
|
+
...teleport.teleportPrimitiveProps
|
|
358
305
|
};
|
|
359
|
-
const
|
|
306
|
+
const HoverCardPortal = vue.defineComponent({
|
|
360
307
|
name: "DestylerHoverCardPortal",
|
|
361
|
-
props:
|
|
308
|
+
props: hoverCardPortalProps,
|
|
362
309
|
render() {
|
|
363
|
-
return vue.h(teleport.
|
|
364
|
-
default: () => this.$slots.default?.()
|
|
365
|
-
});
|
|
310
|
+
return vue.h(teleport.TeleportPrimitive, this.$props, () => this.$slots.default?.());
|
|
366
311
|
}
|
|
367
312
|
});
|
|
368
313
|
|
|
369
|
-
const
|
|
314
|
+
const hoverCardTriggerProps = {
|
|
315
|
+
...primitive.primitiveProps,
|
|
316
|
+
/**
|
|
317
|
+
* @default a
|
|
318
|
+
*/
|
|
370
319
|
as: {
|
|
371
|
-
|
|
372
|
-
required: false,
|
|
320
|
+
...primitive.primitiveProps.as,
|
|
373
321
|
default: "a"
|
|
374
|
-
},
|
|
375
|
-
asChild: {
|
|
376
|
-
type: Boolean,
|
|
377
|
-
required: false,
|
|
378
|
-
default: false
|
|
379
322
|
}
|
|
380
323
|
};
|
|
381
|
-
const
|
|
324
|
+
const HoverCardTrigger = vue.defineComponent({
|
|
382
325
|
name: "DestylerHoverCardTrigger",
|
|
383
|
-
props:
|
|
326
|
+
props: hoverCardTriggerProps,
|
|
384
327
|
setup() {
|
|
385
328
|
const { forwardRef } = composition.useForwardExpose();
|
|
386
329
|
const rootContext = injectHoverCardRootContext();
|
|
@@ -390,38 +333,41 @@ const DestylerHoverCardTrigger = vue.defineComponent({
|
|
|
390
333
|
};
|
|
391
334
|
},
|
|
392
335
|
render() {
|
|
393
|
-
return vue.h(popper.
|
|
336
|
+
return vue.h(popper.PopperAnchor, {
|
|
394
337
|
asChild: true
|
|
395
|
-
}, {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
"onBlur": () => {
|
|
412
|
-
this.rootContext.onClose();
|
|
413
|
-
}
|
|
414
|
-
}, {
|
|
415
|
-
default: () => this.$slots.default?.()
|
|
416
|
-
});
|
|
338
|
+
}, () => vue.h(primitive.Primitive, {
|
|
339
|
+
"ref": (el) => this.forwardRef(el),
|
|
340
|
+
"as": this.$props.as,
|
|
341
|
+
"asChild": this.$props.asChild,
|
|
342
|
+
"data-state": this.rootContext.open.value ? "open" : "closed",
|
|
343
|
+
"onPointerenter": (event) => {
|
|
344
|
+
excludeTouch(this.rootContext.onOpen)(event);
|
|
345
|
+
},
|
|
346
|
+
"onPointerleave": (event) => {
|
|
347
|
+
excludeTouch(this.rootContext.onClose)(event);
|
|
348
|
+
},
|
|
349
|
+
"onFocus": () => {
|
|
350
|
+
this.rootContext.onOpen();
|
|
351
|
+
},
|
|
352
|
+
"onBlur": () => {
|
|
353
|
+
this.rootContext.onClose();
|
|
417
354
|
}
|
|
418
|
-
});
|
|
355
|
+
}, () => this.$slots.default?.()));
|
|
419
356
|
}
|
|
420
357
|
});
|
|
421
358
|
|
|
422
|
-
exports.
|
|
423
|
-
exports.
|
|
424
|
-
exports.
|
|
425
|
-
exports.
|
|
426
|
-
exports.
|
|
427
|
-
exports.
|
|
359
|
+
exports.HoverCardArrow = HoverCardArrow;
|
|
360
|
+
exports.HoverCardContent = HoverCardContent;
|
|
361
|
+
exports.HoverCardContentImpl = HoverCardContentImpl;
|
|
362
|
+
exports.HoverCardPortal = HoverCardPortal;
|
|
363
|
+
exports.HoverCardRoot = HoverCardRoot;
|
|
364
|
+
exports.HoverCardTrigger = HoverCardTrigger;
|
|
365
|
+
exports.hoverCardArrowProps = hoverCardArrowProps;
|
|
366
|
+
exports.hoverCardContentEmits = hoverCardContentEmits;
|
|
367
|
+
exports.hoverCardContentImplEmits = hoverCardContentImplEmits;
|
|
368
|
+
exports.hoverCardContentImplProps = hoverCardContentImplProps;
|
|
369
|
+
exports.hoverCardContentProps = hoverCardContentProps;
|
|
370
|
+
exports.hoverCardPortalProps = hoverCardPortalProps;
|
|
371
|
+
exports.hoverCardRootEmits = hoverCardRootEmits;
|
|
372
|
+
exports.hoverCardRootProps = hoverCardRootProps;
|
|
373
|
+
exports.hoverCardTriggerProps = hoverCardTriggerProps;
|