@sepveneto/free-dom 0.11.1 → 0.11.3

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-1985-FkdDer0n5Q4M/core/src/style/index.css */
1
+ /* ../../../../../../../tmp/tmp-1881-SB3y5ybBKUrY/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
@@ -101,14 +101,6 @@ type GridLayoutItem = {
101
101
  type GridLayoutConfig = GridLayoutItem[];
102
102
 
103
103
  declare const FreeScene: vue_demi.DefineComponent<{
104
- width: {
105
- type: NumberConstructor;
106
- default: undefined;
107
- };
108
- height: {
109
- type: NumberConstructor;
110
- default: undefined;
111
- };
112
104
  diff: {
113
105
  type: NumberConstructor;
114
106
  default: number;
@@ -144,10 +136,6 @@ declare const FreeScene: vue_demi.DefineComponent<{
144
136
  fixNonMonospaced: BooleanConstructor;
145
137
  }, {
146
138
  rectRef: vue_demi.ShallowRef<HTMLElement | undefined>;
147
- style: vue_demi.ComputedRef<{
148
- width: string;
149
- height: string;
150
- }>;
151
139
  selecting: vue_demi.Ref<boolean>;
152
140
  mask: {
153
141
  selecting: vue_demi.Ref<boolean>;
@@ -166,14 +154,6 @@ declare const FreeScene: vue_demi.DefineComponent<{
166
154
  push: (operate: any) => void;
167
155
  };
168
156
  }, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.PublicProps, Readonly<vue_demi.ExtractPropTypes<{
169
- width: {
170
- type: NumberConstructor;
171
- default: undefined;
172
- };
173
- height: {
174
- type: NumberConstructor;
175
- default: undefined;
176
- };
177
157
  diff: {
178
158
  type: NumberConstructor;
179
159
  default: number;
@@ -209,8 +189,6 @@ declare const FreeScene: vue_demi.DefineComponent<{
209
189
  fixNonMonospaced: BooleanConstructor;
210
190
  }>>, {
211
191
  scale: boolean | ("t" | "r" | "l" | "b" | "lt" | "lb" | "rt" | "rb")[];
212
- width: number;
213
- height: number;
214
192
  diff: number;
215
193
  showLine: boolean;
216
194
  transformScale: number;
@@ -340,7 +318,6 @@ declare const GridLayout: vue_demi.DefineComponent<{
340
318
  }>> & {
341
319
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
342
320
  }, {
343
- width: number;
344
321
  disabledDrag: boolean;
345
322
  disabledResize: boolean;
346
323
  modelValue: GridLayoutConfig;
@@ -350,6 +327,7 @@ declare const GridLayout: vue_demi.DefineComponent<{
350
327
  minW: number;
351
328
  minH: number;
352
329
  rowHeight: number;
330
+ width: number;
353
331
  margin: number[];
354
332
  containerPadding: number[];
355
333
  collision: boolean;
@@ -636,8 +614,6 @@ declare const FreeDom: vue_demi.DefineComponent<{
636
614
  y: number;
637
615
  dragFn: CoreFnCallback;
638
616
  scale: boolean | ("t" | "r" | "l" | "b" | "lt" | "lb" | "rt" | "rb")[];
639
- width: number;
640
- height: number;
641
617
  transformScale: number;
642
618
  keyboard: boolean;
643
619
  handle: string;
@@ -653,6 +629,8 @@ declare const FreeDom: vue_demi.DefineComponent<{
653
629
  w: number;
654
630
  h: number;
655
631
  }>;
632
+ width: number;
633
+ height: number;
656
634
  dragStartFn: CoreFnCallback;
657
635
  dragStopFn: CoreFnCallback;
658
636
  resizeStartFn: (evt: MouseEvent, resizeData: ResizeData) => void;
@@ -804,11 +782,11 @@ declare const ResizeDomCore: vue_demi.DefineComponent<{
804
782
  startFn: ResizeFnCallback;
805
783
  stopFn: ResizeFnCallback;
806
784
  scale: boolean | ("t" | "r" | "l" | "b" | "lt" | "lb" | "rt" | "rb")[];
807
- width: number;
808
- height: number;
809
785
  minWidth: number;
810
786
  minHeight: number;
811
787
  lockAspectRatio: boolean;
788
+ width: number;
789
+ height: number;
812
790
  resizeFn: ResizeFnCallback;
813
791
  dragOpts: Partial<FreeDomCoreProps>;
814
792
  }, {}>;
package/dist/index.js CHANGED
@@ -1209,7 +1209,8 @@ function useMask(target, nodes) {
1209
1209
  top: startY.value + (height < 0 ? height : 0) + "px",
1210
1210
  left: startX.value + (width < 0 ? width : 0) + "px",
1211
1211
  width: Math.abs(width) + "px",
1212
- height: Math.abs(height) + "px"
1212
+ height: Math.abs(height) + "px",
1213
+ zIndex: 1
1213
1214
  };
1214
1215
  });
1215
1216
  const selecting = (0, import_vue_demi13.ref)(false);
@@ -1750,8 +1751,6 @@ var freeDom = (0, import_vue_demi17.defineComponent)({
1750
1751
  const canDrag = (0, import_vue_demi17.ref)(false);
1751
1752
  (0, import_vue_demi17.onMounted)(() => {
1752
1753
  props.autoSize && syncSize();
1753
- const pos = sceneContext.correct(context._rect);
1754
- context.trigger({ x: pos.x, y: pos.y, w: pos.width, h: pos.height });
1755
1754
  });
1756
1755
  const style = (0, import_vue_demi17.computed)(() => ({
1757
1756
  width: `${width.value}px`,
@@ -1971,14 +1970,6 @@ var freeDom_default = freeDom;
1971
1970
 
1972
1971
  // src/components/freeDomWrap.ts
1973
1972
  var freeDomWrapProps = {
1974
- width: {
1975
- type: Number,
1976
- default: void 0
1977
- },
1978
- height: {
1979
- type: Number,
1980
- default: void 0
1981
- },
1982
1973
  diff: {
1983
1974
  type: Number,
1984
1975
  default: 2
@@ -2006,11 +1997,23 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2006
1997
  props: freeDomWrapProps,
2007
1998
  setup(props) {
2008
1999
  const eventBus = useEventBus();
2009
- const rectRef = (0, import_vue_demi18.shallowRef)();
2010
2000
  const nodes = (0, import_vue_demi18.ref)([]);
2011
2001
  const history = useOperateHistory(nodes);
2012
- const width = (0, import_vue_demi18.ref)(props.width);
2013
- const height = (0, import_vue_demi18.ref)(props.height);
2002
+ const width = (0, import_vue_demi18.ref)(0);
2003
+ const height = (0, import_vue_demi18.ref)(0);
2004
+ const rectRef = (0, import_vue_demi18.shallowRef)();
2005
+ const wrapRect = useElementBounding(rectRef);
2006
+ (0, import_vue_demi18.watch)([
2007
+ wrapRect.width,
2008
+ wrapRect.height,
2009
+ () => nodes.value.length
2010
+ ], ([w, h7]) => {
2011
+ width.value = w;
2012
+ height.value = h7;
2013
+ if (!w || !h7)
2014
+ return;
2015
+ runCorrect();
2016
+ });
2014
2017
  const selectedNodes = (0, import_vue_demi18.computed)(() => nodes.value.filter((node) => node.node.selected));
2015
2018
  eventBus.on("move", (nodeId) => {
2016
2019
  const mainNode = selectedNodes.value.find((node) => node.uuid === nodeId);
@@ -2026,23 +2029,7 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2026
2029
  });
2027
2030
  const selecting = (0, import_vue_demi18.ref)(false);
2028
2031
  const mask = useMask(rectRef, nodes);
2029
- (0, import_vue_demi18.watchEffect)(() => {
2030
- width.value = props.width;
2031
- });
2032
- (0, import_vue_demi18.watchEffect)(() => {
2033
- height.value = props.height;
2034
- });
2035
- (0, import_vue_demi18.onMounted)(() => {
2036
- if (!props.width || !props.height) {
2037
- if (!rectRef.value)
2038
- console.warn("[free-dom] cannot find element, width or height may be set to 0");
2039
- const h7 = rectRef.value?.clientHeight;
2040
- const w = rectRef.value?.clientWidth;
2041
- if (!props.width)
2042
- width.value = w || 0;
2043
- if (!props.height)
2044
- height.value = h7 || 0;
2045
- }
2032
+ function runCorrect() {
2046
2033
  nodes.value.forEach((pos) => {
2047
2034
  const { x, y, width: width2, height: height2 } = correct(pos.node._rect);
2048
2035
  pos.node._rect.x = x;
@@ -2051,7 +2038,7 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2051
2038
  pos.node._rect.height = height2;
2052
2039
  pos.node.trigger({ x, y, w: width2, h: height2 });
2053
2040
  });
2054
- });
2041
+ }
2055
2042
  function register(uuid, node) {
2056
2043
  nodes.value.push({
2057
2044
  uuid,
@@ -2064,9 +2051,7 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2064
2051
  }
2065
2052
  function checkValid(pos) {
2066
2053
  const { x, y, width: w, height: h7 } = pos;
2067
- return x >= 0 && // @ts-expect-error: trigger after mounted
2068
- x + w <= width.value && y >= 0 && // @ts-expect-error: trigger after mounted
2069
- y + h7 <= height.value;
2054
+ return x >= 0 && x + w <= width.value && y >= 0 && y + h7 <= height.value;
2070
2055
  }
2071
2056
  function correct(pos) {
2072
2057
  let x = Math.max(pos.x, 0);
@@ -2117,13 +2102,8 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2117
2102
  emit: eventBus.emit
2118
2103
  })
2119
2104
  );
2120
- const style = (0, import_vue_demi18.computed)(() => ({
2121
- width: `${props.width}px`,
2122
- height: `${props.height}px`
2123
- }));
2124
2105
  return {
2125
2106
  rectRef,
2126
- style,
2127
2107
  selecting,
2128
2108
  mask,
2129
2109
  history
@@ -2141,13 +2121,16 @@ var FreeDomWrap = (0, import_vue_demi18.defineComponent)({
2141
2121
  "section",
2142
2122
  {
2143
2123
  ref: "rectRef",
2144
- class: "vv-free-dom--scene",
2145
- style: this.style
2124
+ class: "vv-free-dom--scene"
2146
2125
  },
2147
- {
2126
+ import_vue_demi18.isVue2 ? {} : {
2148
2127
  onMousedown: this.mask.handleMousedown,
2149
2128
  onMousemove: this.mask.handleMousemove
2150
- }
2129
+ },
2130
+ import_vue_demi18.isVue2 ? {
2131
+ mousedown: this.mask.handleMousedown,
2132
+ mousemove: this.mask.handleMousemove
2133
+ } : {}
2151
2134
  )(slotList);
2152
2135
  }
2153
2136
  });
package/dist/index.mjs CHANGED
@@ -2,13 +2,13 @@
2
2
  import {
3
3
  computed as computed11,
4
4
  defineComponent as defineComponent6,
5
- onMounted as onMounted5,
5
+ isVue2 as isVue26,
6
6
  provide as provide2,
7
7
  reactive as reactive5,
8
8
  ref as ref13,
9
9
  shallowRef as shallowRef6,
10
10
  toRefs as toRefs2,
11
- watchEffect as watchEffect6
11
+ watch as watch4
12
12
  } from "vue-demi";
13
13
 
14
14
  // src/util/tokens.ts
@@ -1189,7 +1189,8 @@ function useMask(target, nodes) {
1189
1189
  top: startY.value + (height < 0 ? height : 0) + "px",
1190
1190
  left: startX.value + (width < 0 ? width : 0) + "px",
1191
1191
  width: Math.abs(width) + "px",
1192
- height: Math.abs(height) + "px"
1192
+ height: Math.abs(height) + "px",
1193
+ zIndex: 1
1193
1194
  };
1194
1195
  });
1195
1196
  const selecting = ref9(false);
@@ -1730,8 +1731,6 @@ var freeDom = defineComponent5({
1730
1731
  const canDrag = ref12(false);
1731
1732
  onMounted4(() => {
1732
1733
  props.autoSize && syncSize();
1733
- const pos = sceneContext.correct(context._rect);
1734
- context.trigger({ x: pos.x, y: pos.y, w: pos.width, h: pos.height });
1735
1734
  });
1736
1735
  const style = computed10(() => ({
1737
1736
  width: `${width.value}px`,
@@ -1951,14 +1950,6 @@ var freeDom_default = freeDom;
1951
1950
 
1952
1951
  // src/components/freeDomWrap.ts
1953
1952
  var freeDomWrapProps = {
1954
- width: {
1955
- type: Number,
1956
- default: void 0
1957
- },
1958
- height: {
1959
- type: Number,
1960
- default: void 0
1961
- },
1962
1953
  diff: {
1963
1954
  type: Number,
1964
1955
  default: 2
@@ -1986,11 +1977,23 @@ var FreeDomWrap = defineComponent6({
1986
1977
  props: freeDomWrapProps,
1987
1978
  setup(props) {
1988
1979
  const eventBus = useEventBus();
1989
- const rectRef = shallowRef6();
1990
1980
  const nodes = ref13([]);
1991
1981
  const history = useOperateHistory(nodes);
1992
- const width = ref13(props.width);
1993
- const height = ref13(props.height);
1982
+ const width = ref13(0);
1983
+ const height = ref13(0);
1984
+ const rectRef = shallowRef6();
1985
+ const wrapRect = useElementBounding(rectRef);
1986
+ watch4([
1987
+ wrapRect.width,
1988
+ wrapRect.height,
1989
+ () => nodes.value.length
1990
+ ], ([w, h7]) => {
1991
+ width.value = w;
1992
+ height.value = h7;
1993
+ if (!w || !h7)
1994
+ return;
1995
+ runCorrect();
1996
+ });
1994
1997
  const selectedNodes = computed11(() => nodes.value.filter((node) => node.node.selected));
1995
1998
  eventBus.on("move", (nodeId) => {
1996
1999
  const mainNode = selectedNodes.value.find((node) => node.uuid === nodeId);
@@ -2006,23 +2009,7 @@ var FreeDomWrap = defineComponent6({
2006
2009
  });
2007
2010
  const selecting = ref13(false);
2008
2011
  const mask = useMask(rectRef, nodes);
2009
- watchEffect6(() => {
2010
- width.value = props.width;
2011
- });
2012
- watchEffect6(() => {
2013
- height.value = props.height;
2014
- });
2015
- onMounted5(() => {
2016
- if (!props.width || !props.height) {
2017
- if (!rectRef.value)
2018
- console.warn("[free-dom] cannot find element, width or height may be set to 0");
2019
- const h7 = rectRef.value?.clientHeight;
2020
- const w = rectRef.value?.clientWidth;
2021
- if (!props.width)
2022
- width.value = w || 0;
2023
- if (!props.height)
2024
- height.value = h7 || 0;
2025
- }
2012
+ function runCorrect() {
2026
2013
  nodes.value.forEach((pos) => {
2027
2014
  const { x, y, width: width2, height: height2 } = correct(pos.node._rect);
2028
2015
  pos.node._rect.x = x;
@@ -2031,7 +2018,7 @@ var FreeDomWrap = defineComponent6({
2031
2018
  pos.node._rect.height = height2;
2032
2019
  pos.node.trigger({ x, y, w: width2, h: height2 });
2033
2020
  });
2034
- });
2021
+ }
2035
2022
  function register(uuid, node) {
2036
2023
  nodes.value.push({
2037
2024
  uuid,
@@ -2044,9 +2031,7 @@ var FreeDomWrap = defineComponent6({
2044
2031
  }
2045
2032
  function checkValid(pos) {
2046
2033
  const { x, y, width: w, height: h7 } = pos;
2047
- return x >= 0 && // @ts-expect-error: trigger after mounted
2048
- x + w <= width.value && y >= 0 && // @ts-expect-error: trigger after mounted
2049
- y + h7 <= height.value;
2034
+ return x >= 0 && x + w <= width.value && y >= 0 && y + h7 <= height.value;
2050
2035
  }
2051
2036
  function correct(pos) {
2052
2037
  let x = Math.max(pos.x, 0);
@@ -2097,13 +2082,8 @@ var FreeDomWrap = defineComponent6({
2097
2082
  emit: eventBus.emit
2098
2083
  })
2099
2084
  );
2100
- const style = computed11(() => ({
2101
- width: `${props.width}px`,
2102
- height: `${props.height}px`
2103
- }));
2104
2085
  return {
2105
2086
  rectRef,
2106
- style,
2107
2087
  selecting,
2108
2088
  mask,
2109
2089
  history
@@ -2121,13 +2101,16 @@ var FreeDomWrap = defineComponent6({
2121
2101
  "section",
2122
2102
  {
2123
2103
  ref: "rectRef",
2124
- class: "vv-free-dom--scene",
2125
- style: this.style
2104
+ class: "vv-free-dom--scene"
2126
2105
  },
2127
- {
2106
+ isVue26 ? {} : {
2128
2107
  onMousedown: this.mask.handleMousedown,
2129
2108
  onMousemove: this.mask.handleMousemove
2130
- }
2109
+ },
2110
+ isVue26 ? {
2111
+ mousedown: this.mask.handleMousedown,
2112
+ mousemove: this.mask.handleMousemove
2113
+ } : {}
2131
2114
  )(slotList);
2132
2115
  }
2133
2116
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sepveneto/free-dom",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",