labellife-design-tool 2.1.6 → 2.1.8

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
  });
@@ -1731,6 +1692,7 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1731
1692
  var dateFormat = custom.dateFormat || 'MM-DD-YYYY';
1732
1693
  var isRequired = custom.required === true;
1733
1694
  var logoUrl = config.logoUrl || null;
1695
+ var headerText = config.headerText || null;
1734
1696
  var accentColor = config.accentColor || '#0d83cd';
1735
1697
  var progressPct = Math.round((currentIndex + 1) / totalCount * 100);
1736
1698
  react.useEffect(function () {
@@ -1950,22 +1912,29 @@ var SingleFieldDialog = function SingleFieldDialog(_ref) {
1950
1912
  py: 1.75,
1951
1913
  flexShrink: 0
1952
1914
  }, config.titleStyle),
1953
- children: logoUrl ? /*#__PURE__*/jsxRuntime.jsx("img", {
1954
- src: logoUrl,
1955
- alt: "Logo",
1956
- style: {
1957
- maxHeight: 36,
1958
- maxWidth: 200,
1959
- objectFit: 'contain'
1960
- }
1961
- }) : /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1915
+ children: /*#__PURE__*/jsxRuntime.jsxs(material.Box, {
1962
1916
  sx: {
1963
- fontWeight: 700,
1964
- fontSize: 17,
1965
- color: '#1a1a1a',
1966
- letterSpacing: '-0.2px'
1917
+ display: 'flex',
1918
+ alignItems: 'center',
1919
+ gap: 1.5
1967
1920
  },
1968
- children: "LabelLife"
1921
+ children: [logoUrl && /*#__PURE__*/jsxRuntime.jsx("img", {
1922
+ src: logoUrl,
1923
+ alt: "Logo",
1924
+ style: {
1925
+ maxHeight: 36,
1926
+ maxWidth: 200,
1927
+ objectFit: 'contain'
1928
+ }
1929
+ }), (headerText || !logoUrl) && /*#__PURE__*/jsxRuntime.jsx(material.Typography, {
1930
+ sx: {
1931
+ fontWeight: 700,
1932
+ fontSize: 17,
1933
+ color: '#1a1a1a',
1934
+ letterSpacing: '-0.2px'
1935
+ },
1936
+ children: headerText || 'LabelLife'
1937
+ })]
1969
1938
  })
1970
1939
  }), /*#__PURE__*/jsxRuntime.jsx(material.Box, {
1971
1940
  sx: {
@@ -2065,10 +2034,13 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2065
2034
  _onComplete = _ref2.onComplete,
2066
2035
  _ref2$enabled = _ref2.enabled,
2067
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.
2068
2039
  var _useState5 = react.useState(0),
2069
2040
  _useState6 = _slicedToArray(_useState5, 2),
2070
- currentIndex = _useState6[0],
2071
- setCurrentIndex = _useState6[1];
2041
+ displayIndex = _useState6[0],
2042
+ setDisplayIndex = _useState6[1];
2043
+ var initialTotalRef = react.useRef(0);
2072
2044
  var config = getInputFieldsConfig();
2073
2045
  var pendingFields = store._pendingInputFields || [];
2074
2046
 
@@ -2081,11 +2053,22 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2081
2053
  var fields = pendingFields.filter(function (f) {
2082
2054
  return f.custom && f.custom.inputField;
2083
2055
  });
2056
+
2057
+ // Capture total and reset display counter when a fresh batch appears
2084
2058
  react.useEffect(function () {
2085
- setCurrentIndex(0);
2086
- }, [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;
2087
2068
  if (!enabled || fields.length === 0) return null;
2088
- var currentField = fields[currentIndex];
2069
+
2070
+ // Always show the first remaining field — the array shrinks as fields are resolved
2071
+ var currentField = fields[0];
2089
2072
  if (!currentField) return null;
2090
2073
 
2091
2074
  // ── Shared submit / skip helpers ────────────────────────────────────
@@ -2104,21 +2087,21 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2104
2087
  }
2105
2088
  }
2106
2089
  store._resolveInputField(elementId);
2107
- if (currentIndex + 1 >= fields.length) {
2090
+ if (fields.length <= 1) {
2108
2091
  store.history.addUndoState();
2109
2092
  if (_onComplete) _onComplete();
2110
2093
  } else {
2111
- setCurrentIndex(function (prev) {
2094
+ setDisplayIndex(function (prev) {
2112
2095
  return prev + 1;
2113
2096
  });
2114
2097
  }
2115
2098
  };
2116
2099
  var handleSkip = function handleSkip(elementId) {
2117
2100
  store._resolveInputField(elementId);
2118
- if (currentIndex + 1 >= fields.length) {
2101
+ if (fields.length <= 1) {
2119
2102
  if (_onComplete) _onComplete();
2120
2103
  } else {
2121
- setCurrentIndex(function (prev) {
2104
+ setDisplayIndex(function (prev) {
2122
2105
  return prev + 1;
2123
2106
  });
2124
2107
  }
@@ -2140,8 +2123,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2140
2123
  return /*#__PURE__*/jsxRuntime.jsx(ResolvedDialog, {
2141
2124
  field: currentField,
2142
2125
  fields: fields,
2143
- currentIndex: currentIndex,
2144
- totalCount: fields.length,
2126
+ currentIndex: displayIndex,
2127
+ totalCount: totalCount,
2145
2128
  onSubmit: handleSubmit,
2146
2129
  onSkip: handleSkip,
2147
2130
  onComplete: function onComplete() {
@@ -2154,8 +2137,8 @@ var InputFieldsDialog = mobxReactLite.observer(function (_ref2) {
2154
2137
  field: currentField,
2155
2138
  onSubmit: handleSubmit,
2156
2139
  onSkip: handleSkip,
2157
- currentIndex: currentIndex,
2158
- totalCount: fields.length
2140
+ currentIndex: displayIndex,
2141
+ totalCount: totalCount
2159
2142
  });
2160
2143
  });
2161
2144
  InputFieldsDialog.displayName = 'InputFieldsDialog';