vue-unwrap 1.0.1 → 1.1.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/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,28 @@ 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 __VLS_export: _$vue.DefineComponent<{}, {
29
+ type __VLS_Slots = {
30
+ default(props: {
31
+ dom: {
32
+ el: Element | null;
33
+ children: NodeRef[];
34
+ };
35
+ }): any;
36
+ };
37
+ declare const __VLS_base: _$vue.DefineComponent<{}, {
26
38
  $el: _$vue.ShallowRef<Element | null, Element | null>;
27
39
  children: _$vue.ShallowReactive<NodeRef[]>;
40
+ dom: _$vue.ComputedRef<{
41
+ el: Element | null;
42
+ children: _$vue.ShallowReactive<NodeRef[]>;
43
+ }>;
28
44
  }, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
45
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
29
46
  declare const _default: typeof __VLS_export;
47
+ type __VLS_WithSlots<T, S> = T & {
48
+ new (): {
49
+ $slots: S;
50
+ };
51
+ };
30
52
  //#endregion
31
53
  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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vue-unwrap",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.1.1",
5
5
  "description": "Conditional wrapper component for Vue 3 with child ref aggregation.",
6
6
  "author": "Andrea 'Fiad' Fiadone <hello@fiad.one>",
7
7
  "license": "MIT",