@arbisoft/react-design-tool 1.0.56 → 1.0.60

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/esm/index.js CHANGED
@@ -144,6 +144,9 @@ function _nonIterableRest() {
144
144
  function _nonIterableSpread() {
145
145
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
146
146
  }
147
+ function _objectDestructuringEmpty(t) {
148
+ if (null == t) throw new TypeError("Cannot destructure " + t);
149
+ }
147
150
  function ownKeys(e, r) {
148
151
  var t = Object.keys(e);
149
152
  if (Object.getOwnPropertySymbols) {
@@ -2073,7 +2076,6 @@ var TEXT_DICTIONARY = {
2073
2076
  };
2074
2077
  var LOCATION_ELEMENT_ID = 'element-location-text';
2075
2078
  var QRID_ELEMENT_ID = 'element-qrid-text';
2076
- var QRID_ELEMENT_PILL = 'element-qrid-text-pill';
2077
2079
 
2078
2080
  var SideBar = function SideBar(_ref) {
2079
2081
  var _TEXT_DICTIONARY$lang, _TEXT_DICTIONARY$lang2, _TEXT_DICTIONARY$lang3, _TEXT_DICTIONARY$lang4, _TEXT_DICTIONARY$lang5, _TEXT_DICTIONARY$lang6;
@@ -2760,7 +2762,7 @@ var StyledText = styled.p(_templateObject2$g || (_templateObject2$g = _taggedTem
2760
2762
  return "".concat(paddingLeft, "px");
2761
2763
  });
2762
2764
 
2763
- var _excluded$1 = ["image"];
2765
+ var _excluded = ["image"];
2764
2766
  var calculatePercentageValue = function calculatePercentageValue(value, percentage) {
2765
2767
  return value * percentage / 100;
2766
2768
  };
@@ -2923,7 +2925,7 @@ var removeImageProperty = function removeImageProperty() {
2923
2925
  if ('image' in elem) {
2924
2926
  // eslint-disable-next-line no-unused-vars
2925
2927
  elem.image;
2926
- var rest = _objectWithoutProperties(elem, _excluded$1);
2928
+ var rest = _objectWithoutProperties(elem, _excluded);
2927
2929
  return rest;
2928
2930
  }
2929
2931
  return elem;
@@ -6433,7 +6435,6 @@ var isPropValid = /* #__PURE__ */memoize(function (prop) {
6433
6435
  /* Z+1 */
6434
6436
  );
6435
6437
 
6436
- var _excluded = ["ref"];
6437
6438
  /**
6438
6439
  * @typedef {Object} StudioProps
6439
6440
  * @property {string} [title]
@@ -6453,7 +6454,8 @@ var _excluded = ["ref"];
6453
6454
  * @property {'en'|'ru'|'pl'|'de'|'es'|'fr'|'it'} [locale]
6454
6455
  * @property {Function} [onCreateNewTemplate] - called when user creates a new template, passes new canvas elements
6455
6456
  * @property {Function} [onTemplateSelect] - called when a template is selected, passes template id
6456
- * @property {Function} [uploadQRLogoImage] - Optional callback to upload the QR logo image. Should return a string or an object with `{ url }`
6457
+ * @property {Function} [uploadQRLogoImage]
6458
+ * - Optional callback to upload the QR logo image. Should return a string or an object with `{ url }`
6457
6459
  * @property {number} [zoomLevel] - Optional zoom level (e.g. 100 for 100%)
6458
6460
  * @property {boolean} [showBackgroundImagePicker] - Used to set background image on entire canvas
6459
6461
  * @property {boolean} [showOpacityPicker] - Related to showBackgroundImagePicker and it's opacity
@@ -6466,7 +6468,7 @@ var _excluded = ["ref"];
6466
6468
  * @type {React.ForwardRefExoticComponent<StudioProps & React.RefAttributes<HTMLDivElement>>}
6467
6469
  */
6468
6470
  var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6469
- var _elements$elements$fi, _elements$find6, _elements$find7, _elements$find8;
6471
+ var _elements$elements$fi, _elements$find5, _elements$find6, _elements$find7;
6470
6472
  var _ref$title = _ref.title,
6471
6473
  title = _ref$title === void 0 ? '' : _ref$title,
6472
6474
  _ref$defaultQrLogo = _ref.defaultQrLogo,
@@ -6504,11 +6506,10 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6504
6506
  _ref$showQrIdToggle = _ref.showQrIdToggle,
6505
6507
  showQrIdToggle = _ref$showQrIdToggle === void 0 ? false : _ref$showQrIdToggle,
6506
6508
  _ref$qrId = _ref.qrId,
6507
- qrId = _ref$qrId === void 0 ? null : _ref$qrId,
6508
- _ref$qrIdText = _ref.qrIdText,
6509
- qrIdText = _ref$qrIdText === void 0 ? null : _ref$qrIdText;
6509
+ qrId = _ref$qrId === void 0 ? null : _ref$qrId;
6510
6510
  var stageRef = useRef(null);
6511
6511
  var elementCacheRef = useRef({});
6512
+ var qrIdActiveRef = useRef(false);
6512
6513
  var _useState = useState(null),
6513
6514
  _useState2 = _slicedToArray(_useState, 2),
6514
6515
  copiedElement = _useState2[0],
@@ -6618,7 +6619,59 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6618
6619
  _useState52 = _slicedToArray(_useState51, 2),
6619
6620
  defaultTextProps = _useState52[0],
6620
6621
  setDefaultTextProps = _useState52[1];
6622
+ var _useState53 = useState(qrId),
6623
+ _useState54 = _slicedToArray(_useState53, 2),
6624
+ currentQrId = _useState54[0],
6625
+ setCurrentQrId = _useState54[1];
6621
6626
  var overallLoading = loadingFonts || loadingImages || loadingUploadImage || loading;
6627
+ var getPageDims = useCallback(function () {
6628
+ var _base$find;
6629
+ var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
6630
+ var sizeKey = (base === null || base === void 0 || (_base$find = base.find(function (e) {
6631
+ return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
6632
+ })) === null || _base$find === void 0 ? void 0 : _base$find.size) || pageSizes.A4;
6633
+ return pageSizesDimensions[sizeKey] || pageSizesDimensions[pageSizes.A4];
6634
+ }, [elements]);
6635
+ var findById = useCallback(function (id) {
6636
+ var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : elements;
6637
+ return base.find(function (e) {
6638
+ return e.id === id;
6639
+ });
6640
+ }, [elements]);
6641
+
6642
+ /**
6643
+ * Compute the QR-ID frame:
6644
+ * - If LOCATION_ELEMENT_ID exists: center-align above it
6645
+ * - Otherwise: center of page
6646
+ */
6647
+ var computeQrIdFrame = useCallback(function () {
6648
+ var _ref2, _loc$fontSize, _loc$x, _loc$width, _loc$y, _ref3, _loc$color, _loc$fontFamily;
6649
+ var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
6650
+ var _getPageDims = getPageDims(base),
6651
+ Cw = _getPageDims.width,
6652
+ Ch = _getPageDims.height;
6653
+ var loc = findById(LOCATION_ELEMENT_ID, base);
6654
+ var fs = Math.max(14, Math.min(28, (_ref2 = (_loc$fontSize = loc === null || loc === void 0 ? void 0 : loc.fontSize) !== null && _loc$fontSize !== void 0 ? _loc$fontSize : defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontSize) !== null && _ref2 !== void 0 ? _ref2 : 16));
6655
+ var GAP = 8; // vertical gap above location text line
6656
+ var width = Number.isFinite(loc === null || loc === void 0 ? void 0 : loc.width) ? loc.width : 240;
6657
+
6658
+ // center horizontally over location text (or page)
6659
+ var x = loc ? Math.max(0, ((_loc$x = loc.x) !== null && _loc$x !== void 0 ? _loc$x : 0) + (((_loc$width = loc.width) !== null && _loc$width !== void 0 ? _loc$width : width) - width) / 2) : Math.max(0, (Cw - width) / 2);
6660
+
6661
+ // place just above location text line (or vertical center)
6662
+ var y = loc ? Math.max(0, ((_loc$y = loc.y) !== null && _loc$y !== void 0 ? _loc$y : 0) - fs - GAP) : Math.max(0, (Ch - fs) / 2);
6663
+ var color = (_ref3 = (_loc$color = loc === null || loc === void 0 ? void 0 : loc.color) !== null && _loc$color !== void 0 ? _loc$color : defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.color) !== null && _ref3 !== void 0 ? _ref3 : '#111';
6664
+ var fontFamily = (_loc$fontFamily = loc === null || loc === void 0 ? void 0 : loc.fontFamily) !== null && _loc$fontFamily !== void 0 ? _loc$fontFamily : defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontFamily;
6665
+ return {
6666
+ x: x,
6667
+ y: y,
6668
+ width: width,
6669
+ textAlign: 'center',
6670
+ fontSize: fs,
6671
+ color: color,
6672
+ fontFamily: fontFamily
6673
+ };
6674
+ }, [getPageDims, findById, defaultTextProps]);
6622
6675
  var undo = useCallback(function () {
6623
6676
  if (history.length > 0) {
6624
6677
  setSelectedElement(null);
@@ -6674,9 +6727,41 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6674
6727
  setLoading: setLoading,
6675
6728
  undoCount: history.length,
6676
6729
  hasChanges: history.length > 0,
6677
- redoCount: redoStack.length
6730
+ redoCount: redoStack.length,
6731
+ updateQrId: function updateQrId(newId) {
6732
+ setCurrentQrId(newId);
6733
+ var idx = elements.findIndex(function (e) {
6734
+ return e.id === QRID_ELEMENT_ID;
6735
+ });
6736
+ if (idx > -1) {
6737
+ var frame = computeQrIdFrame(elements);
6738
+ var newElements = _toConsumableArray(elements);
6739
+ newElements[idx] = _objectSpread2(_objectSpread2({}, newElements[idx]), {}, {
6740
+ text: String(newId)
6741
+ }, frame);
6742
+ saveHistory(newElements);
6743
+ if ((selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.id) === QRID_ELEMENT_ID) setSelectedElement(newElements[idx]);
6744
+ }
6745
+ },
6746
+ reflowQrId: function reflowQrId() {
6747
+ var idx = elements.findIndex(function (e) {
6748
+ return e.id === QRID_ELEMENT_ID;
6749
+ });
6750
+ if (idx === -1) return;
6751
+ var frame = computeQrIdFrame(elements);
6752
+ var copy = _toConsumableArray(elements);
6753
+ copy[idx] = _objectSpread2(_objectSpread2({}, copy[idx]), frame);
6754
+ saveHistory(copy);
6755
+ }
6678
6756
  };
6679
6757
  });
6758
+ useEffect(function () {
6759
+ if (selectedElement && !elements.some(function (e) {
6760
+ return e.id === selectedElement.id;
6761
+ })) {
6762
+ setSelectedElement(null);
6763
+ }
6764
+ }, [elements, selectedElement]);
6680
6765
  useEffect(function () {
6681
6766
  if (typeof zoomLevel === 'number') {
6682
6767
  setZoomPercentage(zoomLevel);
@@ -6765,16 +6850,15 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6765
6850
  });
6766
6851
  if (foundLoc) {
6767
6852
  // store a clean copy (no runtime refs)
6768
- var _ref2 = foundLoc || {};
6769
- _ref2.ref;
6770
- var rest = _objectWithoutProperties(_ref2, _excluded);
6853
+ var _ref4 = foundLoc || {},
6854
+ rest = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
6771
6855
  elementCacheRef.current[LOCATION_ELEMENT_ID] = _objectSpread2({}, rest);
6772
6856
  }
6773
6857
  }, _toConsumableArray(elementsList));
6774
6858
  var LoadImages = function LoadImages(elems) {
6775
6859
  setLoadingImages(true);
6776
- preloadRelevantImages(elems).then(function (_ref4) {
6777
- var errors = _ref4.errors;
6860
+ preloadRelevantImages(elems).then(function (_ref5) {
6861
+ var errors = _ref5.errors;
6778
6862
  // console.log('✅ Loaded images:', successes);
6779
6863
  if ((errors === null || errors === void 0 ? void 0 : errors.length) > 0) {
6780
6864
  console.log('❌ Failed images:', errors);
@@ -6813,6 +6897,9 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6813
6897
  return e.type === elementTypes.text && e.id === QRID_ELEMENT_ID;
6814
6898
  });
6815
6899
  }, [elements]);
6900
+ useEffect(function () {
6901
+ qrIdActiveRef.current = hasQrIdText; // keep this in sync
6902
+ }, [hasQrIdText]);
6816
6903
  var removeElementById = function removeElementById(id) {
6817
6904
  var idx = elements.findIndex(function (e) {
6818
6905
  return e.id === id;
@@ -6821,16 +6908,11 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6821
6908
  var snapshot = _objectSpread2({}, elements[idx]);
6822
6909
  delete snapshot.ref;
6823
6910
  // cache latest props before removing
6824
- elementCacheRef.current[id] = snapshot;
6911
+ if (id !== QRID_ELEMENT_ID) {
6912
+ elementCacheRef.current[id] = snapshot; // never cache QR-ID
6913
+ }
6825
6914
  var next = elements.slice();
6826
6915
  next.splice(idx, 1);
6827
- if (id === QRID_ELEMENT_ID) {
6828
- // remove its pill if present
6829
- var pillId = "".concat(QRID_ELEMENT_ID, "-pill");
6830
- for (var i = next.length - 1; i >= 0; i--) {
6831
- if (next[i].id === pillId) next.splice(i, 1);
6832
- }
6833
- }
6834
6916
  if ((selectedElement === null || selectedElement === void 0 ? void 0 : selectedElement.id) === id) setSelectedElement(null);
6835
6917
  saveHistory(next);
6836
6918
  }
@@ -6848,88 +6930,23 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6848
6930
  setSelectedElement(toAdd);
6849
6931
  };
6850
6932
  var addQrIdText = function addQrIdText() {
6851
- var _elements$find4, _qrIdText$width, _qrIdText$textAlign, _ref5, _qrIdText$color, _ref6, _qrIdText$fontWeight;
6852
- if (!qrId || hasQrIdText) return;
6853
-
6854
- // 1) If we’ve seen it before, restore EXACTLY as it was
6855
- var cached = elementCacheRef.current[QRID_ELEMENT_ID];
6856
- if (cached) {
6857
- var toAdd = _objectSpread2(_objectSpread2({}, cached), {}, {
6858
- id: QRID_ELEMENT_ID,
6859
- text: String(qrId)
6860
- });
6861
- saveHistory([].concat(_toConsumableArray(elements), [toAdd]));
6862
- setSelectedElement(toAdd);
6863
- return;
6864
- }
6865
-
6866
- // 2) Otherwise, build from external qrIdText + sensible defaults
6867
- var sizeKey = (elements === null || elements === void 0 || (_elements$find4 = elements.find(function (e) {
6868
- return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
6869
- })) === null || _elements$find4 === void 0 ? void 0 : _elements$find4.size) || pageSizes.A4;
6870
- var _pageSizesDimensions$ = pageSizesDimensions[sizeKey],
6871
- Cw = _pageSizesDimensions$.width,
6872
- Ch = _pageSizesDimensions$.height;
6873
- var fs = (defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontSize) || 16;
6874
- var lineH = fs * 1.25;
6875
-
6876
- // --- external layout (REQUIRED x,y for custom placement) ---
6877
- var hasExternal = qrIdText && typeof qrIdText.x === 'number' && typeof qrIdText.y === 'number';
6878
- var x = hasExternal ? qrIdText.x : Math.max(0, (Cw - 240) / 2);
6879
- var y = hasExternal ? qrIdText.y : Math.max(0, (Ch - lineH) / 2);
6880
- var width = (_qrIdText$width = qrIdText === null || qrIdText === void 0 ? void 0 : qrIdText.width) !== null && _qrIdText$width !== void 0 ? _qrIdText$width : 240;
6881
- var textAlign = (_qrIdText$textAlign = qrIdText === null || qrIdText === void 0 ? void 0 : qrIdText.textAlign) !== null && _qrIdText$textAlign !== void 0 ? _qrIdText$textAlign : 'center';
6882
- var color = (_ref5 = (_qrIdText$color = qrIdText === null || qrIdText === void 0 ? void 0 : qrIdText.color) !== null && _qrIdText$color !== void 0 ? _qrIdText$color : defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.color) !== null && _ref5 !== void 0 ? _ref5 : '#111';
6883
-
6884
- // optional readability helpers (opt-in)
6885
- var wantPill = !!(qrIdText !== null && qrIdText !== void 0 && qrIdText.pill);
6886
- var pillColor = (qrIdText === null || qrIdText === void 0 ? void 0 : qrIdText.pillColor) || (color === '#fff' || color.toLowerCase() === 'white' ? 'rgba(0,0,0,0.35)' : 'rgba(255,255,255,0.85)');
6887
- var wantOutline = !!(qrIdText !== null && qrIdText !== void 0 && qrIdText.outline);
6888
- var pillId = "".concat(QRID_ELEMENT_ID, "-pill");
6889
- var vPad = 8,
6890
- hPad = 10;
6891
- var newElements = _toConsumableArray(elements);
6892
- if (wantPill) {
6893
- newElements.push({
6894
- id: pillId,
6895
- type: elementTypes.square,
6896
- draggable: true,
6897
- x: x - hPad,
6898
- y: y - vPad,
6899
- width: width + hPad * 2,
6900
- height: lineH + vPad * 2,
6901
- cornerRadius: 8,
6902
- fill: pillColor,
6903
- opacity: 1,
6904
- stroke: 'rgba(0,0,0,0.12)',
6905
- strokeWidth: 1
6906
- });
6907
- }
6933
+ var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
6934
+ if (!currentQrId || base.some(function (e) {
6935
+ return e.id === QRID_ELEMENT_ID;
6936
+ })) return;
6937
+ var frame = computeQrIdFrame(base);
6908
6938
  var textProps = _objectSpread2({
6909
6939
  id: QRID_ELEMENT_ID,
6910
6940
  type: elementTypes.text,
6911
6941
  draggable: true,
6912
- x: x,
6913
- y: y,
6914
- width: width,
6915
- textAlign: textAlign,
6916
- text: String(qrId),
6917
- opacity: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.opacity,
6918
- fontSize: fs,
6919
- fontFamily: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontFamily,
6920
- color: color,
6921
- textDecoration: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.textDecoration,
6922
- fontStyle: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontStyle,
6923
- fontWeight: (_ref6 = (_qrIdText$fontWeight = qrIdText === null || qrIdText === void 0 ? void 0 : qrIdText.fontWeight) !== null && _qrIdText$fontWeight !== void 0 ? _qrIdText$fontWeight : defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.fontWeight) !== null && _ref6 !== void 0 ? _ref6 : '400'
6924
- }, wantOutline && {
6925
- stroke: color.toLowerCase() === '#ffffff' || color.toLowerCase() === 'white' ? 'rgba(0,0,0,0.5)' : 'rgba(255,255,255,0.8)',
6926
- strokeWidth: 1,
6927
- shadowColor: 'rgba(0,0,0,0.4)',
6928
- shadowBlur: 3,
6929
- shadowOpacity: 0.8
6930
- });
6931
- newElements.push(textProps);
6932
- saveHistory(newElements);
6942
+ text: String(currentQrId),
6943
+ fontWeight: '700',
6944
+ // always bold
6945
+ textAlign: 'center',
6946
+ opacity: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.opacity
6947
+ }, frame);
6948
+ var next = [].concat(_toConsumableArray(base), [textProps]);
6949
+ saveHistory(next);
6933
6950
  setSelectedElement(textProps);
6934
6951
  };
6935
6952
  var toggleLocationText = function toggleLocationText() {
@@ -6998,11 +7015,11 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
6998
7015
  saveHistory([].concat(_toConsumableArray(elemClone), [newElement]));
6999
7016
  };
7000
7017
  var onSetPageSize = function onSetPageSize(newSize) {
7001
- var _elements$find5;
7018
+ var _elements$find4;
7002
7019
  if (!newSize) return;
7003
- var oldSize = (elements === null || elements === void 0 || (_elements$find5 = elements.find(function (e) {
7020
+ var oldSize = (elements === null || elements === void 0 || (_elements$find4 = elements.find(function (e) {
7004
7021
  return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
7005
- })) === null || _elements$find5 === void 0 ? void 0 : _elements$find5.size) || pageSizes.A4;
7022
+ })) === null || _elements$find4 === void 0 ? void 0 : _elements$find4.size) || pageSizes.A4;
7006
7023
  var oldDims = pageSizesDimensions[oldSize];
7007
7024
  var newDims = pageSizesDimensions[newSize];
7008
7025
  var scaleX = newDims.width / oldDims.width;
@@ -7259,6 +7276,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7259
7276
  saveHistory(_toConsumableArray(copyElements));
7260
7277
  };
7261
7278
  var createNewTemplate = function createNewTemplate() {
7279
+ var _elementsRef$current;
7262
7280
  var elems = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [].concat(_toConsumableArray(defaultElements), [{
7263
7281
  type: elementTypes.qr,
7264
7282
  id: "element".concat(Date.now() + 1),
@@ -7275,19 +7293,25 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7275
7293
  opacity: 1,
7276
7294
  logoVisible: false
7277
7295
  }]);
7278
- var prevElements = elementsRef.current;
7279
- var prevQrIdText = prevElements.find(function (element) {
7280
- return element.id === QRID_ELEMENT_ID;
7296
+ var prevHadQrId = (_elementsRef$current = elementsRef.current) === null || _elementsRef$current === void 0 ? void 0 : _elementsRef$current.some(function (e) {
7297
+ return e.id === QRID_ELEMENT_ID;
7281
7298
  });
7282
- var newQrIdText = elems.find(function (element) {
7283
- return element.id === QRID_ELEMENT_ID;
7284
- });
7285
- if (!(newQrIdText !== null && newQrIdText !== void 0 && newQrIdText.id) && prevQrIdText !== null && prevQrIdText !== void 0 && prevQrIdText.id) {
7286
- var qrIdPill = prevElements.find(function (element) {
7287
- return element.id === QRID_ELEMENT_PILL;
7288
- });
7289
- if (qrIdPill.id) elems.push(qrIdPill);
7290
- elems.push(prevQrIdText);
7299
+ var next = _toConsumableArray(elems);
7300
+
7301
+ // If toggle was ON before and current template doesn’t include QR-ID, re-add it above Location (or center)
7302
+ if (prevHadQrId && !next.some(function (e) {
7303
+ return e.id === QRID_ELEMENT_ID;
7304
+ }) && showQrIdToggle && currentQrId) {
7305
+ var frame = computeQrIdFrame(next);
7306
+ next.push(_objectSpread2({
7307
+ id: QRID_ELEMENT_ID,
7308
+ type: elementTypes.text,
7309
+ draggable: true,
7310
+ text: String(currentQrId),
7311
+ fontWeight: '700',
7312
+ textAlign: 'center',
7313
+ opacity: defaultTextProps === null || defaultTextProps === void 0 ? void 0 : defaultTextProps.opacity
7314
+ }, frame));
7291
7315
  }
7292
7316
  setElements(_toConsumableArray(elems));
7293
7317
  setHistory([]);
@@ -7472,7 +7496,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7472
7496
  }
7473
7497
  };
7474
7498
  var addQrLogo = /*#__PURE__*/function () {
7475
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
7499
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
7476
7500
  var file, result, imageUrl, reader, _t;
7477
7501
  return _regenerator().w(function (_context2) {
7478
7502
  while (1) switch (_context2.n) {
@@ -7528,7 +7552,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7528
7552
  }, _callee2, null, [[3, 5, 6, 7]]);
7529
7553
  }));
7530
7554
  return function addQrLogo() {
7531
- return _ref7.apply(this, arguments);
7555
+ return _ref6.apply(this, arguments);
7532
7556
  };
7533
7557
  }();
7534
7558
  var addLogo = function addLogo(url) {
@@ -7557,7 +7581,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7557
7581
  }
7558
7582
  };
7559
7583
  var onSaveProgress = /*#__PURE__*/function () {
7560
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
7584
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
7561
7585
  var processedElements, dataURL;
7562
7586
  return _regenerator().w(function (_context3) {
7563
7587
  while (1) switch (_context3.n) {
@@ -7591,7 +7615,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7591
7615
  }, _callee3);
7592
7616
  }));
7593
7617
  return function onSaveProgress() {
7594
- return _ref8.apply(this, arguments);
7618
+ return _ref7.apply(this, arguments);
7595
7619
  };
7596
7620
  }();
7597
7621
  return /*#__PURE__*/React.createElement(StyleSheetManager, {
@@ -7640,12 +7664,12 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7640
7664
  onToggleQrIdText: toggleQrIdText
7641
7665
  }), loadingFonts ? null : /*#__PURE__*/React.createElement(Editor, {
7642
7666
  setLoading: setLoading,
7643
- cuttingGuideStroke: (elements === null || elements === void 0 || (_elements$find6 = elements.find(function (e) {
7667
+ cuttingGuideStroke: (elements === null || elements === void 0 || (_elements$find5 = elements.find(function (e) {
7644
7668
  return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
7645
- })) === null || _elements$find6 === void 0 ? void 0 : _elements$find6.cuttingGuideStroke) || 0,
7646
- cuttingGuideStrokeColor: (elements === null || elements === void 0 || (_elements$find7 = elements.find(function (e) {
7669
+ })) === null || _elements$find5 === void 0 ? void 0 : _elements$find5.cuttingGuideStroke) || 0,
7670
+ cuttingGuideStrokeColor: (elements === null || elements === void 0 || (_elements$find6 = elements.find(function (e) {
7647
7671
  return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
7648
- })) === null || _elements$find7 === void 0 ? void 0 : _elements$find7.cuttingGuideStrokeColor) || (theme === null || theme === void 0 ? void 0 : theme.color.black),
7672
+ })) === null || _elements$find6 === void 0 ? void 0 : _elements$find6.cuttingGuideStrokeColor) || (theme === null || theme === void 0 ? void 0 : theme.color.black),
7649
7673
  onChangeCuttingGuideProp: function onChangeCuttingGuideProp(type, value) {
7650
7674
  _onChangeCuttingGuideProp(type, value);
7651
7675
  },
@@ -7687,9 +7711,9 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
7687
7711
  stageRef: stageRef,
7688
7712
  saveHistory: saveHistory,
7689
7713
  onChangeBackgroundImageOpacity: onChangeBackgroundImageOpacity,
7690
- backgroundImageOpacity: (elements === null || elements === void 0 || (_elements$find8 = elements.find(function (e) {
7714
+ backgroundImageOpacity: (elements === null || elements === void 0 || (_elements$find7 = elements.find(function (e) {
7691
7715
  return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.backgroundImage);
7692
- })) === null || _elements$find8 === void 0 ? void 0 : _elements$find8.opacity) || backgroundImageOpacity,
7716
+ })) === null || _elements$find7 === void 0 ? void 0 : _elements$find7.opacity) || backgroundImageOpacity,
7693
7717
  onDeleteSelectedElement: onDeleteSelectedElement,
7694
7718
  onCopySelectedElement: onCopySelectedElement,
7695
7719
  onToggleLockElement: onToggleLockElement,