@destyler/popper 0.0.1-beta.8 → 0.0.1
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/LICENSE +21 -0
- package/dist/component.cjs +16 -0
- package/dist/component.d.cts +5 -0
- package/dist/component.d.mts +5 -0
- package/dist/component.d.ts +5 -0
- package/dist/component.mjs +7 -0
- package/dist/index.cjs +51 -44
- package/dist/index.d.cts +334 -356
- package/dist/index.d.mts +334 -356
- package/dist/index.d.ts +334 -356
- package/dist/index.mjs +55 -36
- package/dist/resolver.cjs +23 -0
- package/dist/resolver.d.cts +6 -0
- package/dist/resolver.d.mts +6 -0
- package/dist/resolver.d.ts +6 -0
- package/dist/resolver.mjs +20 -0
- package/package.json +15 -5
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defineComponent, ref, watch, h, computed, watchEffect, mergeProps } from 'vue';
|
|
2
2
|
import { createContext, computedEager } from '@destyler/shared';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { DestylerPrimitive } from '@destyler/primitive';
|
|
4
|
+
import { useForwardExpose, useSize } from '@destyler/composition';
|
|
5
5
|
import { offset, shift, limitShift, flip, size, arrow, hide, useFloating, autoUpdate } from '@floating-ui/vue';
|
|
6
|
-
import {
|
|
6
|
+
import { DestylerArrow } from '@destyler/arrow';
|
|
7
7
|
|
|
8
8
|
const [injectPopperRootContext, providePopperRootContext] = createContext("DestylerPopperRoot");
|
|
9
9
|
const DestylerPopperRoot = defineComponent({
|
|
@@ -21,7 +21,16 @@ const DestylerPopperRoot = defineComponent({
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const destylerPopperAnchorProps = {
|
|
24
|
-
|
|
24
|
+
as: {
|
|
25
|
+
type: [String, Object],
|
|
26
|
+
required: false,
|
|
27
|
+
default: "div"
|
|
28
|
+
},
|
|
29
|
+
asChild: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
required: false,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
25
34
|
element: {
|
|
26
35
|
type: Object
|
|
27
36
|
}
|
|
@@ -30,21 +39,23 @@ const DestylerPopperAnchor = defineComponent({
|
|
|
30
39
|
name: "DestylerPopperAnchor",
|
|
31
40
|
props: destylerPopperAnchorProps,
|
|
32
41
|
setup(props) {
|
|
33
|
-
const {
|
|
42
|
+
const { forwardRef, currentElement } = useForwardExpose();
|
|
34
43
|
const rootContext = injectPopperRootContext();
|
|
35
44
|
watch(currentElement, () => {
|
|
36
45
|
rootContext.onAnchorChange(props.element ?? currentElement.value);
|
|
37
46
|
});
|
|
38
47
|
return {
|
|
39
|
-
|
|
48
|
+
forwardRef
|
|
40
49
|
};
|
|
41
50
|
},
|
|
42
51
|
render() {
|
|
43
52
|
return h(DestylerPrimitive, {
|
|
44
53
|
as: this.$props.as,
|
|
45
54
|
asChild: this.$props.asChild,
|
|
46
|
-
ref:
|
|
47
|
-
},
|
|
55
|
+
ref: (el) => this.forwardRef(el)
|
|
56
|
+
}, {
|
|
57
|
+
default: () => this.$slots.default?.()
|
|
58
|
+
});
|
|
48
59
|
}
|
|
49
60
|
});
|
|
50
61
|
|
|
@@ -91,7 +102,16 @@ function getSideAndAlignFromPlacement(placement) {
|
|
|
91
102
|
|
|
92
103
|
const [injectPopperContentContext, providePopperContentContext] = createContext("DestylerPopperContent");
|
|
93
104
|
const destylerPopperContentProps = {
|
|
94
|
-
|
|
105
|
+
as: {
|
|
106
|
+
type: [String, Object],
|
|
107
|
+
required: false,
|
|
108
|
+
default: "div"
|
|
109
|
+
},
|
|
110
|
+
asChild: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
required: false,
|
|
113
|
+
default: false
|
|
114
|
+
},
|
|
95
115
|
side: {
|
|
96
116
|
type: String,
|
|
97
117
|
required: false,
|
|
@@ -163,8 +183,7 @@ const DestylerPopperContent = defineComponent({
|
|
|
163
183
|
props: destylerPopperContentProps,
|
|
164
184
|
setup(props, { attrs }) {
|
|
165
185
|
const rootContext = injectPopperRootContext();
|
|
166
|
-
const forwardRef =
|
|
167
|
-
const { customElement, currentElement: contentElement } = useCustomElement();
|
|
186
|
+
const { forwardRef, currentElement: contentElement } = useForwardExpose();
|
|
168
187
|
const floatingRef = ref();
|
|
169
188
|
const arrow$1 = ref();
|
|
170
189
|
const { width: arrowWidth, height: arrowHeight } = useSize(arrow$1);
|
|
@@ -278,14 +297,13 @@ const DestylerPopperContent = defineComponent({
|
|
|
278
297
|
contentZIndex,
|
|
279
298
|
middlewareData,
|
|
280
299
|
forwardRef,
|
|
281
|
-
customElement,
|
|
282
300
|
placedSide,
|
|
283
301
|
placedAlign,
|
|
284
302
|
attrStyle: attrs.style
|
|
285
303
|
};
|
|
286
304
|
},
|
|
287
305
|
render() {
|
|
288
|
-
return h("div",
|
|
306
|
+
return h("div", {
|
|
289
307
|
"data-destyler-popper-content-wrapper": "",
|
|
290
308
|
"ref": "floatingRef",
|
|
291
309
|
"style": {
|
|
@@ -298,11 +316,8 @@ const DestylerPopperContent = defineComponent({
|
|
|
298
316
|
this.middlewareData.transformOrigin?.y
|
|
299
317
|
].join(" ")
|
|
300
318
|
}
|
|
301
|
-
}
|
|
302
|
-
"ref": (
|
|
303
|
-
this.forwardRef(vnode);
|
|
304
|
-
this.customElement = vnode;
|
|
305
|
-
},
|
|
319
|
+
}, h(DestylerPrimitive, mergeProps(this.$attrs, {
|
|
320
|
+
"ref": (el) => this.forwardRef(el),
|
|
306
321
|
"as": this.$props.as,
|
|
307
322
|
"asChild": this.$props.asChild,
|
|
308
323
|
"data-side": this.placedSide,
|
|
@@ -311,7 +326,9 @@ const DestylerPopperContent = defineComponent({
|
|
|
311
326
|
animation: !this.isPositioned ? "none" : void 0,
|
|
312
327
|
opacity: this.middlewareData.hide?.referenceHidden ? 0 : void 0
|
|
313
328
|
}
|
|
314
|
-
}),
|
|
329
|
+
}), {
|
|
330
|
+
default: () => this.$slots.default?.()
|
|
331
|
+
}));
|
|
315
332
|
}
|
|
316
333
|
});
|
|
317
334
|
|
|
@@ -322,8 +339,21 @@ const OPPOSITE_SIDE = {
|
|
|
322
339
|
left: "right"
|
|
323
340
|
};
|
|
324
341
|
const destylerPopperArrowProps = {
|
|
325
|
-
|
|
326
|
-
|
|
342
|
+
asChild: {
|
|
343
|
+
type: Boolean,
|
|
344
|
+
required: false,
|
|
345
|
+
default: false
|
|
346
|
+
},
|
|
347
|
+
width: {
|
|
348
|
+
type: Number,
|
|
349
|
+
required: false,
|
|
350
|
+
default: 5
|
|
351
|
+
},
|
|
352
|
+
height: {
|
|
353
|
+
type: Number,
|
|
354
|
+
required: false,
|
|
355
|
+
default: 10
|
|
356
|
+
},
|
|
327
357
|
as: {
|
|
328
358
|
type: [String, Object],
|
|
329
359
|
required: false,
|
|
@@ -375,21 +405,10 @@ const DestylerPopperArrow = defineComponent({
|
|
|
375
405
|
style: {
|
|
376
406
|
display: "block"
|
|
377
407
|
}
|
|
378
|
-
}),
|
|
408
|
+
}), {
|
|
409
|
+
default: () => this.$slots.default?.()
|
|
410
|
+
}));
|
|
379
411
|
}
|
|
380
412
|
});
|
|
381
413
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const packageName = name;
|
|
385
|
-
function DestylerPopperResolver() {
|
|
386
|
-
return {
|
|
387
|
-
type: "component",
|
|
388
|
-
resolve: (name2) => {
|
|
389
|
-
if (name2 === "DestylerTemplate")
|
|
390
|
-
return { name: name2, from: packageName };
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export { DestylerPopperAnchor, DestylerPopperArrow, DestylerPopperContent, DestylerPopperResolver, DestylerPopperRoot, OPPOSITE_SIDE, destylerPopperAnchorProps, destylerPopperArrowProps, destylerPopperContentProps, getSideAndAlignFromPlacement, injectPopperContentContext, injectPopperRootContext, isNotNull, providePopperContentContext, providePopperRootContext, transformOrigin };
|
|
414
|
+
export { DestylerPopperAnchor, DestylerPopperArrow, DestylerPopperContent, DestylerPopperRoot };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const name = "@destyler/popper";
|
|
4
|
+
|
|
5
|
+
const packageName = name;
|
|
6
|
+
const popperComponentName = [
|
|
7
|
+
"DestylerPopperRoot",
|
|
8
|
+
"DestylerPopperAnchor",
|
|
9
|
+
"DestylerPopperContent",
|
|
10
|
+
"DestylerPopperArrow"
|
|
11
|
+
];
|
|
12
|
+
function DestylerPopperResolver() {
|
|
13
|
+
return {
|
|
14
|
+
type: "component",
|
|
15
|
+
resolve: (name2) => {
|
|
16
|
+
if (popperComponentName.includes(name2))
|
|
17
|
+
return { name: name2, from: packageName };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.DestylerPopperResolver = DestylerPopperResolver;
|
|
23
|
+
exports.popperComponentName = popperComponentName;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const name = "@destyler/popper";
|
|
2
|
+
|
|
3
|
+
const packageName = name;
|
|
4
|
+
const popperComponentName = [
|
|
5
|
+
"DestylerPopperRoot",
|
|
6
|
+
"DestylerPopperAnchor",
|
|
7
|
+
"DestylerPopperContent",
|
|
8
|
+
"DestylerPopperArrow"
|
|
9
|
+
];
|
|
10
|
+
function DestylerPopperResolver() {
|
|
11
|
+
return {
|
|
12
|
+
type: "component",
|
|
13
|
+
resolve: (name2) => {
|
|
14
|
+
if (popperComponentName.includes(name2))
|
|
15
|
+
return { name: name2, from: packageName };
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { DestylerPopperResolver, popperComponentName };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@destyler/popper",
|
|
3
|
-
"version": "0.0.1
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "unstyled popper component for vue",
|
|
5
5
|
"author": "Elone Hoo <elonehoo@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
"import": "./dist/index.mjs",
|
|
11
11
|
"require": "./dist/index.cjs"
|
|
12
12
|
},
|
|
13
|
+
"./resolver": {
|
|
14
|
+
"types": "./dist/resolver.d.ts",
|
|
15
|
+
"import": "./dist/resolver.mjs",
|
|
16
|
+
"require": "./dist/resolver.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./component": {
|
|
19
|
+
"types": "./dist/component.d.ts",
|
|
20
|
+
"import": "./dist/component.mjs",
|
|
21
|
+
"require": "./dist/component.cjs"
|
|
22
|
+
},
|
|
13
23
|
"./*": "./*"
|
|
14
24
|
},
|
|
15
25
|
"main": "dist/index.cjs",
|
|
@@ -24,10 +34,10 @@
|
|
|
24
34
|
},
|
|
25
35
|
"dependencies": {
|
|
26
36
|
"@floating-ui/vue": "^1.0.4",
|
|
27
|
-
"@destyler/arrow": "0.0.1
|
|
28
|
-
"@destyler/
|
|
29
|
-
"@destyler/
|
|
30
|
-
"@destyler/
|
|
37
|
+
"@destyler/arrow": "0.0.1",
|
|
38
|
+
"@destyler/composition": "0.0.1",
|
|
39
|
+
"@destyler/primitive": "0.0.1",
|
|
40
|
+
"@destyler/shared": "0.0.1"
|
|
31
41
|
},
|
|
32
42
|
"scripts": {
|
|
33
43
|
"clear": "rimraf ./dist",
|