@sepveneto/free-dom 0.12.0-beta.0 → 0.12.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.css CHANGED
@@ -1,4 +1,4 @@
1
- /* ../../../../../../../tmp/tmp-1923-wOVpZZwj554Y/core/src/style/index.css */
1
+ /* ../../../../../../../tmp/tmp-1955-TXizoLOtOqOd/core/src/style/index.css */
2
2
  :root {
3
3
  --vv-free-dom--theme: rgb(64, 137, 239);
4
4
  --vv-free-dom--line: var(--vv-free-dom--theme);
package/dist/index.d.ts CHANGED
@@ -121,11 +121,11 @@ declare const FreeScene: vue.DefineComponent<{
121
121
  };
122
122
  minWidth: {
123
123
  type: NumberConstructor;
124
- default: number;
124
+ default: undefined;
125
125
  };
126
126
  minHeight: {
127
127
  type: NumberConstructor;
128
- default: number;
128
+ default: undefined;
129
129
  };
130
130
  lockAspectRatio: BooleanConstructor;
131
131
  disabledDrag: BooleanConstructor;
@@ -176,11 +176,11 @@ declare const FreeScene: vue.DefineComponent<{
176
176
  };
177
177
  minWidth: {
178
178
  type: NumberConstructor;
179
- default: number;
179
+ default: undefined;
180
180
  };
181
181
  minHeight: {
182
182
  type: NumberConstructor;
183
- default: number;
183
+ default: undefined;
184
184
  };
185
185
  lockAspectRatio: BooleanConstructor;
186
186
  disabledDrag: BooleanConstructor;
package/dist/index.js CHANGED
@@ -18449,8 +18449,8 @@ function useDraggableData(props) {
18449
18449
  props.dragStartFn(evt, data);
18450
18450
  };
18451
18451
  const handleDrag = (evt, data) => {
18452
- x.value = data.x;
18453
- y.value = data.y;
18452
+ x.value = Number(data.x.toFixed(2));
18453
+ y.value = Number(data.y.toFixed(2));
18454
18454
  deltaX.value = data.deltaX;
18455
18455
  deltaY.value = data.deltaY;
18456
18456
  props.dragFn(evt, data);
@@ -19661,11 +19661,11 @@ var resizeDomCore = (0, import_vue_demi16.defineComponent)({
19661
19661
  return Array.isArray(_dots) ? _dots : Dots;
19662
19662
  });
19663
19663
  const lastRect = (0, import_vue_demi16.shallowRef)();
19664
- function runConstraints(width, height) {
19664
+ function runConstraints(width, height, axis) {
19665
19665
  const { lockAspectRatio } = props;
19666
19666
  if (!props.minHeight && !props.minWidth && !lockAspectRatio)
19667
19667
  return [width, height];
19668
- if (lockAspectRatio) {
19668
+ if (lockAspectRatio && axis.length === 2) {
19669
19669
  const ratio = props.width / props.height;
19670
19670
  if (ratio > 1) {
19671
19671
  height = Math.max(height, props.minHeight);
@@ -19697,7 +19697,7 @@ var resizeDomCore = (0, import_vue_demi16.defineComponent)({
19697
19697
  let width = props.width + (canDragX ? deltaX : 0);
19698
19698
  let height = props.height + (canDragY ? deltaY : 0);
19699
19699
  if (!evt.shiftKey) {
19700
- [width, height] = runConstraints(width, height);
19700
+ [width, height] = runConstraints(width, height, axis);
19701
19701
  }
19702
19702
  const sizeChanged = width !== props.width || height !== props.height;
19703
19703
  const fnName = `${handleName}Fn`;
@@ -19865,7 +19865,8 @@ var freeDom = (0, import_vue_demi17.defineComponent)({
19865
19865
  }),
19866
19866
  trigger: (pos) => {
19867
19867
  emit2("update:modelValue", pos);
19868
- }
19868
+ },
19869
+ props
19869
19870
  });
19870
19871
  const sceneContext = useSceneContext(domRef, context, props);
19871
19872
  onClickOutside(domRef, () => {
@@ -19884,11 +19885,13 @@ var freeDom = (0, import_vue_demi17.defineComponent)({
19884
19885
  (0, import_vue_demi17.onMounted)(() => {
19885
19886
  props.autoSize && syncSize();
19886
19887
  });
19887
- const style = (0, import_vue_demi17.computed)(() => ({
19888
- width: `${width.value}px`,
19889
- height: `${height.value}px`,
19890
- transform: `translate(${x.value}px, ${y.value}px)`
19891
- }));
19888
+ const style = (0, import_vue_demi17.computed)(() => {
19889
+ return {
19890
+ width: `${width.value}px`,
19891
+ height: `${height.value}px`,
19892
+ transform: `translate(${x.value}px, ${y.value}px)`
19893
+ };
19894
+ });
19892
19895
  const onDrag = (evt, coreData) => {
19893
19896
  if (!canDrag.value)
19894
19897
  return;
@@ -19958,10 +19961,10 @@ var freeDom = (0, import_vue_demi17.defineComponent)({
19958
19961
  const isValid = sceneContext.check?.({ x: _x, y: _y, width: w, height: h8 });
19959
19962
  if (!isValid)
19960
19963
  return;
19961
- width.value = w;
19962
- height.value = h8;
19963
- x.value = _x;
19964
- y.value = _y;
19964
+ width.value = Number(w.toFixed(2));
19965
+ height.value = Number(h8.toFixed(2));
19966
+ x.value = Number(_x.toFixed(2));
19967
+ y.value = Number(_y.toFixed(2));
19965
19968
  props.resizeFn(evt, { node, width: w, height: h8, handle: axis });
19966
19969
  sceneContext?.emit("move");
19967
19970
  };
@@ -20119,8 +20122,14 @@ var freeDomWrapProps = {
20119
20122
  keyboard: Boolean,
20120
20123
  disabledBatch: Boolean,
20121
20124
  handle: freeDomProps.handle,
20122
- minWidth: freeDomProps.minWidth,
20123
- minHeight: freeDomProps.minHeight,
20125
+ minWidth: {
20126
+ type: Number,
20127
+ default: void 0
20128
+ },
20129
+ minHeight: {
20130
+ type: Number,
20131
+ default: void 0
20132
+ },
20124
20133
  lockAspectRatio: freeDomProps.lockAspectRatio,
20125
20134
  disabledDrag: freeDomProps.disabledDrag,
20126
20135
  disabledResize: freeDomProps.disabledResize,
@@ -20167,7 +20176,14 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
20167
20176
  const mask = useMask(rectRef, props, nodes);
20168
20177
  function runCorrect() {
20169
20178
  nodes.value.forEach((pos) => {
20170
- const { x, y, width: width2, height: height2 } = correct(pos.node._rect);
20179
+ const minWidth = props.minWidth || pos.node.props.minWidth;
20180
+ const minHeight = props.minHeight || pos.node.props.minHeight;
20181
+ const { x, y, width: width2, height: height2 } = correct(
20182
+ // @ts-expect-error: triggered after mount
20183
+ pos.node._rect,
20184
+ minWidth,
20185
+ minHeight
20186
+ );
20171
20187
  pos.node._rect.x = x;
20172
20188
  pos.node._rect.y = y;
20173
20189
  pos.node._rect.width = width2;
@@ -20190,7 +20206,7 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
20190
20206
  const { x, y, width: w, height: h8 } = pos;
20191
20207
  return x >= 0 && x + w <= width.value && y >= 0 && y + h8 <= height.value;
20192
20208
  }
20193
- function correct(pos) {
20209
+ function correct(pos, minWidth, minHeight) {
20194
20210
  let x = Math.max(pos.x, 0);
20195
20211
  let y = Math.max(pos.y, 0);
20196
20212
  let w = pos.width;
@@ -20198,14 +20214,14 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
20198
20214
  if (pos.x + pos.width > width.value) {
20199
20215
  x = width.value - pos.width;
20200
20216
  if (x < 0) {
20201
- w = width.value;
20217
+ w = Math.max(width.value, minWidth);
20202
20218
  x = 0;
20203
20219
  }
20204
20220
  }
20205
20221
  if (pos.y + pos.height > height.value) {
20206
20222
  y = height.value - pos.height;
20207
20223
  if (y < 0) {
20208
- h8 = height.value;
20224
+ h8 = Math.max(height.value, minHeight);
20209
20225
  y = 0;
20210
20226
  }
20211
20227
  }
package/dist/index.mjs CHANGED
@@ -18446,8 +18446,8 @@ function useDraggableData(props) {
18446
18446
  props.dragStartFn(evt, data);
18447
18447
  };
18448
18448
  const handleDrag = (evt, data) => {
18449
- x.value = data.x;
18450
- y.value = data.y;
18449
+ x.value = Number(data.x.toFixed(2));
18450
+ y.value = Number(data.y.toFixed(2));
18451
18451
  deltaX.value = data.deltaX;
18452
18452
  deltaY.value = data.deltaY;
18453
18453
  props.dragFn(evt, data);
@@ -19658,11 +19658,11 @@ var resizeDomCore = defineComponent4({
19658
19658
  return Array.isArray(_dots) ? _dots : Dots;
19659
19659
  });
19660
19660
  const lastRect = shallowRef5();
19661
- function runConstraints(width, height) {
19661
+ function runConstraints(width, height, axis) {
19662
19662
  const { lockAspectRatio } = props;
19663
19663
  if (!props.minHeight && !props.minWidth && !lockAspectRatio)
19664
19664
  return [width, height];
19665
- if (lockAspectRatio) {
19665
+ if (lockAspectRatio && axis.length === 2) {
19666
19666
  const ratio = props.width / props.height;
19667
19667
  if (ratio > 1) {
19668
19668
  height = Math.max(height, props.minHeight);
@@ -19694,7 +19694,7 @@ var resizeDomCore = defineComponent4({
19694
19694
  let width = props.width + (canDragX ? deltaX : 0);
19695
19695
  let height = props.height + (canDragY ? deltaY : 0);
19696
19696
  if (!evt.shiftKey) {
19697
- [width, height] = runConstraints(width, height);
19697
+ [width, height] = runConstraints(width, height, axis);
19698
19698
  }
19699
19699
  const sizeChanged = width !== props.width || height !== props.height;
19700
19700
  const fnName = `${handleName}Fn`;
@@ -19862,7 +19862,8 @@ var freeDom = defineComponent5({
19862
19862
  }),
19863
19863
  trigger: (pos) => {
19864
19864
  emit2("update:modelValue", pos);
19865
- }
19865
+ },
19866
+ props
19866
19867
  });
19867
19868
  const sceneContext = useSceneContext(domRef, context, props);
19868
19869
  onClickOutside(domRef, () => {
@@ -19881,11 +19882,13 @@ var freeDom = defineComponent5({
19881
19882
  onMounted4(() => {
19882
19883
  props.autoSize && syncSize();
19883
19884
  });
19884
- const style = computed10(() => ({
19885
- width: `${width.value}px`,
19886
- height: `${height.value}px`,
19887
- transform: `translate(${x.value}px, ${y.value}px)`
19888
- }));
19885
+ const style = computed10(() => {
19886
+ return {
19887
+ width: `${width.value}px`,
19888
+ height: `${height.value}px`,
19889
+ transform: `translate(${x.value}px, ${y.value}px)`
19890
+ };
19891
+ });
19889
19892
  const onDrag = (evt, coreData) => {
19890
19893
  if (!canDrag.value)
19891
19894
  return;
@@ -19955,10 +19958,10 @@ var freeDom = defineComponent5({
19955
19958
  const isValid = sceneContext.check?.({ x: _x, y: _y, width: w, height: h8 });
19956
19959
  if (!isValid)
19957
19960
  return;
19958
- width.value = w;
19959
- height.value = h8;
19960
- x.value = _x;
19961
- y.value = _y;
19961
+ width.value = Number(w.toFixed(2));
19962
+ height.value = Number(h8.toFixed(2));
19963
+ x.value = Number(_x.toFixed(2));
19964
+ y.value = Number(_y.toFixed(2));
19962
19965
  props.resizeFn(evt, { node, width: w, height: h8, handle: axis });
19963
19966
  sceneContext?.emit("move");
19964
19967
  };
@@ -20116,8 +20119,14 @@ var freeDomWrapProps = {
20116
20119
  keyboard: Boolean,
20117
20120
  disabledBatch: Boolean,
20118
20121
  handle: freeDomProps.handle,
20119
- minWidth: freeDomProps.minWidth,
20120
- minHeight: freeDomProps.minHeight,
20122
+ minWidth: {
20123
+ type: Number,
20124
+ default: void 0
20125
+ },
20126
+ minHeight: {
20127
+ type: Number,
20128
+ default: void 0
20129
+ },
20121
20130
  lockAspectRatio: freeDomProps.lockAspectRatio,
20122
20131
  disabledDrag: freeDomProps.disabledDrag,
20123
20132
  disabledResize: freeDomProps.disabledResize,
@@ -20164,7 +20173,14 @@ var FreeDomWrap = defineComponent6({
20164
20173
  const mask = useMask(rectRef, props, nodes);
20165
20174
  function runCorrect() {
20166
20175
  nodes.value.forEach((pos) => {
20167
- const { x, y, width: width2, height: height2 } = correct(pos.node._rect);
20176
+ const minWidth = props.minWidth || pos.node.props.minWidth;
20177
+ const minHeight = props.minHeight || pos.node.props.minHeight;
20178
+ const { x, y, width: width2, height: height2 } = correct(
20179
+ // @ts-expect-error: triggered after mount
20180
+ pos.node._rect,
20181
+ minWidth,
20182
+ minHeight
20183
+ );
20168
20184
  pos.node._rect.x = x;
20169
20185
  pos.node._rect.y = y;
20170
20186
  pos.node._rect.width = width2;
@@ -20187,7 +20203,7 @@ var FreeDomWrap = defineComponent6({
20187
20203
  const { x, y, width: w, height: h8 } = pos;
20188
20204
  return x >= 0 && x + w <= width.value && y >= 0 && y + h8 <= height.value;
20189
20205
  }
20190
- function correct(pos) {
20206
+ function correct(pos, minWidth, minHeight) {
20191
20207
  let x = Math.max(pos.x, 0);
20192
20208
  let y = Math.max(pos.y, 0);
20193
20209
  let w = pos.width;
@@ -20195,14 +20211,14 @@ var FreeDomWrap = defineComponent6({
20195
20211
  if (pos.x + pos.width > width.value) {
20196
20212
  x = width.value - pos.width;
20197
20213
  if (x < 0) {
20198
- w = width.value;
20214
+ w = Math.max(width.value, minWidth);
20199
20215
  x = 0;
20200
20216
  }
20201
20217
  }
20202
20218
  if (pos.y + pos.height > height.value) {
20203
20219
  y = height.value - pos.height;
20204
20220
  if (y < 0) {
20205
- h8 = height.value;
20221
+ h8 = Math.max(height.value, minHeight);
20206
20222
  y = 0;
20207
20223
  }
20208
20224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sepveneto/free-dom",
3
- "version": "0.12.0-beta.0",
3
+ "version": "0.12.0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",