vue-unwrap 1.0.1 → 1.1.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/dist/index.d.ts +24 -1
- package/dist/index.js +10 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ declare function unwrapVNodes(vnodes: VNodeArrayChildren): VNode[];
|
|
|
8
8
|
declare function useUnwrap<N = NodeRef, P = Record<string, any>>(propTypes?: Record<string, any>): {
|
|
9
9
|
$el: _$vue.ShallowRef<Element | null, Element | null>;
|
|
10
10
|
children: _$vue.ShallowReactive<N[]>;
|
|
11
|
+
dom: _$vue.ComputedRef<{
|
|
12
|
+
el: Element | null;
|
|
13
|
+
children: _$vue.ShallowReactive<N[]>;
|
|
14
|
+
}>;
|
|
11
15
|
Unwrap: {
|
|
12
16
|
(props: P, context: SetupContext): VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
|
13
17
|
[key: string]: any;
|
|
@@ -22,10 +26,29 @@ declare function useUnwrap<N = NodeRef, P = Record<string, any>>(propTypes?: Rec
|
|
|
22
26
|
};
|
|
23
27
|
//#endregion
|
|
24
28
|
//#region src/Unwrap.vue.d.ts
|
|
25
|
-
declare const
|
|
29
|
+
declare const dom: _$vue.ComputedRef<{
|
|
30
|
+
el: Element | null;
|
|
31
|
+
children: _$vue.ShallowReactive<NodeRef[]>;
|
|
32
|
+
}>;
|
|
33
|
+
type __VLS_Slots = {
|
|
34
|
+
default(props: {
|
|
35
|
+
dom: typeof dom;
|
|
36
|
+
}): any;
|
|
37
|
+
};
|
|
38
|
+
declare const __VLS_base: _$vue.DefineComponent<{}, {
|
|
26
39
|
$el: _$vue.ShallowRef<Element | null, Element | null>;
|
|
27
40
|
children: _$vue.ShallowReactive<NodeRef[]>;
|
|
41
|
+
dom: _$vue.ComputedRef<{
|
|
42
|
+
el: Element | null;
|
|
43
|
+
children: _$vue.ShallowReactive<NodeRef[]>;
|
|
44
|
+
}>;
|
|
28
45
|
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
47
|
declare const _default: typeof __VLS_export;
|
|
48
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
49
|
+
new (): {
|
|
50
|
+
$slots: S;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
30
53
|
//#endregion
|
|
31
54
|
export { NodeRef, _default as Unwrap, getNodeElement, unwrapVNodes, useUnwrap };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Comment, Fragment, cloneVNode, createBlock, defineComponent, h, isVNode, openBlock, shallowReactive, shallowRef, unref, useSlots } from "vue";
|
|
1
|
+
import { Comment, Fragment, cloneVNode, computed, createBlock, defineComponent, h, isVNode, openBlock, shallowReactive, shallowRef, unref, useSlots } from "vue";
|
|
2
2
|
//#region src/useUnwrap.ts
|
|
3
3
|
function getNodeElement(node) {
|
|
4
4
|
const el = node?.$el || node;
|
|
@@ -21,6 +21,10 @@ function unwrapVNodes(vnodes) {
|
|
|
21
21
|
function useUnwrap(propTypes) {
|
|
22
22
|
const $el = shallowRef(null);
|
|
23
23
|
const children = shallowReactive([]);
|
|
24
|
+
const dom = computed(() => ({
|
|
25
|
+
el: $el.value,
|
|
26
|
+
children
|
|
27
|
+
}));
|
|
24
28
|
const slots = useSlots();
|
|
25
29
|
const trackChildRef = (index) => (node) => children[index] = node;
|
|
26
30
|
const trackWrapperRef = (node) => $el.value = getNodeElement(node);
|
|
@@ -36,6 +40,7 @@ function useUnwrap(propTypes) {
|
|
|
36
40
|
return {
|
|
37
41
|
$el,
|
|
38
42
|
children,
|
|
43
|
+
dom,
|
|
39
44
|
Unwrap
|
|
40
45
|
};
|
|
41
46
|
}
|
|
@@ -44,13 +49,14 @@ function useUnwrap(propTypes) {
|
|
|
44
49
|
var Unwrap_default = /* @__PURE__ */ defineComponent({
|
|
45
50
|
__name: "Unwrap",
|
|
46
51
|
setup(__props, { expose: __expose }) {
|
|
47
|
-
const { $el, children, Unwrap } = useUnwrap();
|
|
52
|
+
const { $el, children, dom, Unwrap } = useUnwrap();
|
|
48
53
|
__expose({
|
|
49
54
|
$el,
|
|
50
|
-
children
|
|
55
|
+
children,
|
|
56
|
+
dom
|
|
51
57
|
});
|
|
52
58
|
return (_ctx, _cache) => {
|
|
53
|
-
return openBlock(), createBlock(unref(Unwrap));
|
|
59
|
+
return openBlock(), createBlock(unref(Unwrap), { dom: unref(dom) }, null, 8, ["dom"]);
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
62
|
});
|
package/package.json
CHANGED