labellife-design-tool 2.1.7 → 2.1.9

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.
@@ -855,7 +855,6 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
855
855
  _useState2 = _slicedToArray(_useState, 2),
856
856
  textHeight = _useState2[0],
857
857
  setTextHeight = _useState2[1];
858
- var skipAutoHeightRef = react.useRef(false);
859
858
 
860
859
  // Force Konva to recalculate text layout when fonts finish loading.
861
860
  react.useEffect(function () {
@@ -886,15 +885,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
886
885
  }, []);
887
886
 
888
887
  // Sync Konva auto-sized height back to element model after text reflows
889
- // Skip when the user just finished a manual resize (skipAutoHeightRef)
890
888
  react.useEffect(function () {
891
889
  var node = textRef.current;
892
890
  if (!node) return;
893
891
  var frame = requestAnimationFrame(function () {
894
- if (skipAutoHeightRef.current) {
895
- skipAutoHeightRef.current = false;
896
- return;
897
- }
898
892
  var h = node.height();
899
893
  if (h > 0) {
900
894
  setTextHeight(h);
@@ -932,45 +926,18 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
932
926
  if (onDragEnd) onDragEnd(e);
933
927
  };
934
928
 
935
- // Live text reflow during resize: convert scale to width on every frame
936
- var handleTransform = function handleTransform(e) {
937
- var node = e.target;
938
- var scaleX = node.scaleX();
939
- node.scaleY();
940
- // Use element.width as the base since Group.width() can return 0
941
- var baseWidth = node.width() || element.width || 100;
942
- var newWidth = Math.max(20, baseWidth * Math.abs(scaleX));
943
- node.scaleX(1);
944
- node.scaleY(1);
945
- node.width(newWidth);
946
- element.set({
947
- x: node.x(),
948
- y: node.y(),
949
- width: newWidth
950
- });
951
- };
929
+ // During live drag: let Konva scale the node visually no imperative changes,
930
+ // no element.set(). Any MobX update here causes React to sync stale x/y back
931
+ // to the node every frame, fighting the Transformer (especially top/left anchors).
932
+ var handleTransform = function handleTransform() {};
952
933
  var handleTransformEnd = function handleTransformEnd(e) {
953
934
  var node = e.target;
935
+ // Read accumulated scale against the MODEL values (not node.width/height,
936
+ // which accumulate across multiple transform sessions and can drift).
954
937
  var scaleX = node.scaleX();
955
938
  var scaleY = node.scaleY();
956
- var baseWidth = node.width() || element.width || 100;
957
- var baseHeight = node.height() || element.height || 50;
958
- var newWidth = Math.max(20, baseWidth * Math.abs(scaleX));
959
- var newHeight = Math.max(10, baseHeight * Math.abs(scaleY));
939
+ var newWidth = Math.max(20, element.width * Math.abs(scaleX));
960
940
  var newFontSize = Math.max(8, Math.round(element.fontSize * Math.abs(scaleY)));
961
- console.log('[TEXT RESIZE]', {
962
- scaleX: scaleX,
963
- scaleY: scaleY,
964
- baseWidth: baseWidth,
965
- baseHeight: baseHeight,
966
- newWidth: newWidth,
967
- newHeight: newHeight,
968
- oldFontSize: element.fontSize,
969
- newFontSize: newFontSize
970
- });
971
-
972
- // Update KonvaText child BEFORE resetting Group scale so that
973
- // the Transformer sees the correct bounding box immediately.
974
941
  var tNode = textRef.current;
975
942
  if (tNode) {
976
943
  tNode.width(newWidth);
@@ -979,16 +946,10 @@ var TextElementComponent = mobxReactLite.observer(function (_ref) {
979
946
  node.scaleX(1);
980
947
  node.scaleY(1);
981
948
  node.width(newWidth);
982
- node.height(newHeight);
983
-
984
- // Prevent the auto-height useEffect from overriding the user's resize
985
- skipAutoHeightRef.current = true;
986
- setTextHeight(newHeight);
987
949
  element.set({
988
950
  x: node.x(),
989
951
  y: node.y(),
990
952
  width: newWidth,
991
- height: newHeight,
992
953
  fontSize: newFontSize,
993
954
  rotation: node.rotation()
994
955
  });
@@ -2073,10 +2034,13 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2073
2034
  _onComplete = _ref2.onComplete,
2074
2035
  _ref2$enabled = _ref2.enabled,
2075
2036
  enabled = _ref2$enabled === void 0 ? true : _ref2$enabled;
2037
+ // displayIndex counts how many fields have been answered (for step indicator only).
2038
+ // Navigation always uses fields[0] — the first remaining pending field.
2076
2039
  var _useState5 = react.useState(0),
2077
2040
  _useState6 = _slicedToArray(_useState5, 2),
2078
- currentIndex = _useState6[0],
2079
- setCurrentIndex = _useState6[1];
2041
+ displayIndex = _useState6[0],
2042
+ setDisplayIndex = _useState6[1];
2043
+ var initialTotalRef = react.useRef(0);
2080
2044
  var config = getInputFieldsConfig();
2081
2045
  var pendingFields = store._pendingInputFields || [];
2082
2046
 
@@ -2089,11 +2053,22 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2089
2053
  var fields = pendingFields.filter(function (f) {
2090
2054
  return f.custom && f.custom.inputField;
2091
2055
  });
2056
+
2057
+ // Capture total and reset display counter when a fresh batch appears
2092
2058
  react.useEffect(function () {
2093
- setCurrentIndex(0);
2094
- }, [pendingFields.length]);
2059
+ if (fields.length > 0 && initialTotalRef.current === 0) {
2060
+ initialTotalRef.current = fields.length;
2061
+ setDisplayIndex(0);
2062
+ }
2063
+ if (fields.length === 0) {
2064
+ initialTotalRef.current = 0;
2065
+ }
2066
+ }, [fields.length]);
2067
+ var totalCount = initialTotalRef.current || fields.length;
2095
2068
  if (!enabled || fields.length === 0) return null;
2096
- var currentField = fields[currentIndex];
2069
+
2070
+ // Always show the first remaining field — the array shrinks as fields are resolved
2071
+ var currentField = fields[0];
2097
2072
  if (!currentField) return null;
2098
2073
 
2099
2074
  // ── Shared submit / skip helpers ────────────────────────────────────
@@ -2112,21 +2087,21 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2112
2087
  }
2113
2088
  }
2114
2089
  store._resolveInputField(elementId);
2115
- if (currentIndex + 1 >= fields.length) {
2090
+ if (fields.length <= 1) {
2116
2091
  store.history.addUndoState();
2117
2092
  if (_onComplete) _onComplete();
2118
2093
  } else {
2119
- setCurrentIndex(function (prev) {
2094
+ setDisplayIndex(function (prev) {
2120
2095
  return prev + 1;
2121
2096
  });
2122
2097
  }
2123
2098
  };
2124
2099
  var handleSkip = function handleSkip(elementId) {
2125
2100
  store._resolveInputField(elementId);
2126
- if (currentIndex + 1 >= fields.length) {
2101
+ if (fields.length <= 1) {
2127
2102
  if (_onComplete) _onComplete();
2128
2103
  } else {
2129
- setCurrentIndex(function (prev) {
2104
+ setDisplayIndex(function (prev) {
2130
2105
  return prev + 1;
2131
2106
  });
2132
2107
  }
@@ -2148,8 +2123,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2148
2123
  return /*#__PURE__*/jsxRuntime.jsx(ResolvedDialog, {
2149
2124
  field: currentField,
2150
2125
  fields: fields,
2151
- currentIndex: currentIndex,
2152
- totalCount: fields.length,
2126
+ currentIndex: displayIndex,
2127
+ totalCount: totalCount,
2153
2128
  onSubmit: handleSubmit,
2154
2129
  onSkip: handleSkip,
2155
2130
  onComplete: function onComplete() {
@@ -2162,8 +2137,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2162
2137
  field: currentField,
2163
2138
  onSubmit: handleSubmit,
2164
2139
  onSkip: handleSkip,
2165
- currentIndex: currentIndex,
2166
- totalCount: fields.length
2140
+ currentIndex: displayIndex,
2141
+ totalCount: totalCount
2167
2142
  });
2168
2143
  });
2169
2144
  InputFieldsDialog.displayName = 'InputFieldsDialog';