@sepveneto/free-dom 0.4.0 → 0.4.2

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.css CHANGED
@@ -1,4 +1,4 @@
1
- /* ../../../../../../../tmp/tmp-1800-oTeH5e7LtwVq/core/src/style/index.css */
1
+ /* ../../../../../../../tmp/tmp-1778-6uk8ditWyl3v/core/src/style/index.css */
2
2
  :root {
3
3
  --free-dom-theme: #4089ef;
4
4
  --free-dom-line: var(--free-dom-theme);
package/dist/index.d.ts CHANGED
@@ -3,19 +3,19 @@ import * as vue_demi from 'vue-demi';
3
3
  declare const freeDom: vue_demi.DefineComponent<{
4
4
  x: {
5
5
  type: NumberConstructor;
6
- default: number;
6
+ default: undefined;
7
7
  };
8
8
  y: {
9
9
  type: NumberConstructor;
10
- default: number;
10
+ default: undefined;
11
11
  };
12
12
  width: {
13
13
  type: NumberConstructor;
14
- default: number;
14
+ default: undefined;
15
15
  };
16
16
  height: {
17
17
  type: NumberConstructor;
18
- default: number;
18
+ default: undefined;
19
19
  };
20
20
  absolute: {
21
21
  type: BooleanConstructor;
@@ -73,19 +73,19 @@ declare const freeDom: vue_demi.DefineComponent<{
73
73
  }, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, ("update:x" | "update:y" | "update:width" | "update:height" | "select")[], "update:x" | "update:y" | "update:width" | "update:height" | "select", vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
74
74
  x: {
75
75
  type: NumberConstructor;
76
- default: number;
76
+ default: undefined;
77
77
  };
78
78
  y: {
79
79
  type: NumberConstructor;
80
- default: number;
80
+ default: undefined;
81
81
  };
82
82
  width: {
83
83
  type: NumberConstructor;
84
- default: number;
84
+ default: undefined;
85
85
  };
86
86
  height: {
87
87
  type: NumberConstructor;
88
- default: number;
88
+ default: undefined;
89
89
  };
90
90
  absolute: {
91
91
  type: BooleanConstructor;
package/dist/index.js CHANGED
@@ -146,19 +146,19 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
146
146
  props: {
147
147
  x: {
148
148
  type: Number,
149
- default: 0
149
+ default: void 0
150
150
  },
151
151
  y: {
152
152
  type: Number,
153
- default: 0
153
+ default: void 0
154
154
  },
155
155
  width: {
156
156
  type: Number,
157
- default: 0
157
+ default: void 0
158
158
  },
159
159
  height: {
160
160
  type: Number,
161
- default: 0
161
+ default: void 0
162
162
  },
163
163
  absolute: {
164
164
  type: Boolean,
@@ -235,19 +235,38 @@ var FreeDom = (0, import_vue_demi2.defineComponent)({
235
235
  }
236
236
  let init = false;
237
237
  (0, import_vue_demi2.watchEffect)(() => {
238
- _rect.width = props.width;
239
- _rect.height = props.height;
240
- _rect.x = props.x;
241
- _rect.y = props.y;
238
+ props.width && (_rect.width = props.width);
239
+ props.height && (_rect.height = props.height);
240
+ props.x && (_rect.x = props.x);
241
+ props.y && (_rect.y = props.y);
242
242
  init && triggerThrottle();
243
243
  init = true;
244
244
  });
245
+ const rectBound = (0, import_core.useElementBounding)(widgetRef);
246
+ const unwatchHeight = (0, import_vue_demi2.watch)(rectBound.height, (height) => {
247
+ if (height) {
248
+ _rect.height = height;
249
+ unwatchHeight();
250
+ }
251
+ });
252
+ const unwatchWidth = (0, import_vue_demi2.watch)(rectBound.width, (width) => {
253
+ if (width) {
254
+ _rect.width = width;
255
+ unwatchWidth();
256
+ }
257
+ });
245
258
  (0, import_vue_demi2.onMounted)(async () => {
246
259
  SceneContext?.register(uuid, context);
247
260
  await (0, import_vue_demi2.nextTick)();
248
261
  const rect = widgetRef.value.getBoundingClientRect();
249
262
  _rect.width = _rect.width || rect.width;
263
+ if (_rect.width) {
264
+ unwatchWidth();
265
+ }
250
266
  _rect.height = _rect.height || rect.height;
267
+ if (_rect.height) {
268
+ unwatchHeight();
269
+ }
251
270
  _rect.x = _rect.x || 0;
252
271
  _rect.y = _rect.y || 0;
253
272
  trigger();
package/dist/index.mjs CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  reactive,
18
18
  isVue2,
19
19
  shallowRef,
20
- watchEffect
20
+ watchEffect,
21
+ watch as watch2
21
22
  } from "vue-demi";
22
23
 
23
24
  // src/hooks/use-normalize-style.ts
@@ -125,7 +126,7 @@ function useResize(startX, startY, rect, dot, diagonal, snapGrid, callbacks) {
125
126
  }
126
127
 
127
128
  // src/components/freeDom.ts
128
- import { onClickOutside, useThrottleFn } from "@vueuse/core";
129
+ import { onClickOutside, useThrottleFn, useElementBounding } from "@vueuse/core";
129
130
  import { v4 as uuidv4 } from "uuid";
130
131
  var Dots = ["t", "r", "l", "b", "lt", "lb", "rt", "rb"];
131
132
  var FreeDom = defineComponent({
@@ -133,19 +134,19 @@ var FreeDom = defineComponent({
133
134
  props: {
134
135
  x: {
135
136
  type: Number,
136
- default: 0
137
+ default: void 0
137
138
  },
138
139
  y: {
139
140
  type: Number,
140
- default: 0
141
+ default: void 0
141
142
  },
142
143
  width: {
143
144
  type: Number,
144
- default: 0
145
+ default: void 0
145
146
  },
146
147
  height: {
147
148
  type: Number,
148
- default: 0
149
+ default: void 0
149
150
  },
150
151
  absolute: {
151
152
  type: Boolean,
@@ -222,19 +223,38 @@ var FreeDom = defineComponent({
222
223
  }
223
224
  let init = false;
224
225
  watchEffect(() => {
225
- _rect.width = props.width;
226
- _rect.height = props.height;
227
- _rect.x = props.x;
228
- _rect.y = props.y;
226
+ props.width && (_rect.width = props.width);
227
+ props.height && (_rect.height = props.height);
228
+ props.x && (_rect.x = props.x);
229
+ props.y && (_rect.y = props.y);
229
230
  init && triggerThrottle();
230
231
  init = true;
231
232
  });
233
+ const rectBound = useElementBounding(widgetRef);
234
+ const unwatchHeight = watch2(rectBound.height, (height) => {
235
+ if (height) {
236
+ _rect.height = height;
237
+ unwatchHeight();
238
+ }
239
+ });
240
+ const unwatchWidth = watch2(rectBound.width, (width) => {
241
+ if (width) {
242
+ _rect.width = width;
243
+ unwatchWidth();
244
+ }
245
+ });
232
246
  onMounted(async () => {
233
247
  SceneContext?.register(uuid, context);
234
248
  await nextTick();
235
249
  const rect = widgetRef.value.getBoundingClientRect();
236
250
  _rect.width = _rect.width || rect.width;
251
+ if (_rect.width) {
252
+ unwatchWidth();
253
+ }
237
254
  _rect.height = _rect.height || rect.height;
255
+ if (_rect.height) {
256
+ unwatchHeight();
257
+ }
238
258
  _rect.x = _rect.x || 0;
239
259
  _rect.y = _rect.y || 0;
240
260
  trigger();
@@ -461,7 +481,7 @@ var FreeDom = defineComponent({
461
481
 
462
482
  // src/components/freeDomWrap.ts
463
483
  import { defineComponent as defineComponent3, shallowRef as shallowRef3, h as h3, provide, reactive as reactive3, ref as ref4, toRefs } from "vue-demi";
464
- import { useElementBounding } from "@vueuse/core";
484
+ import { useElementBounding as useElementBounding2 } from "@vueuse/core";
465
485
 
466
486
  // src/components/markLine.ts
467
487
  import { h as h2, defineComponent as defineComponent2, shallowRef as shallowRef2, ref as ref3, reactive as reactive2, inject as inject2, onBeforeUnmount } from "vue-demi";
@@ -655,7 +675,7 @@ var FreeDomWrap = defineComponent3({
655
675
  props: freeDomWrapProps,
656
676
  setup(props) {
657
677
  const rectRef = shallowRef3(null);
658
- const rect = useElementBounding(rectRef);
678
+ const rect = useElementBounding2(rectRef);
659
679
  const nodes = ref4([]);
660
680
  function register(uuid, node) {
661
681
  nodes.value.push({ uuid, node });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sepveneto/free-dom",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",