@arbisoft/react-design-tool 1.0.70 → 1.0.71
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/README.md +56 -27
- package/dist/cjs/index.js +392 -82
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +392 -82
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -348,7 +348,14 @@ var propTypes$z = {
|
|
|
348
348
|
defaultText: PropTypes.string,
|
|
349
349
|
onSave: PropTypes.func,
|
|
350
350
|
saveButtonText: PropTypes.string,
|
|
351
|
-
locale: PropTypes.oneOf(['en', 'ru', 'pl', 'de', 'es', 'fr', 'it'])
|
|
351
|
+
locale: PropTypes.oneOf(['en', 'ru', 'pl', 'de', 'es', 'fr', 'it']),
|
|
352
|
+
canvasSize: PropTypes.shape({
|
|
353
|
+
mode: PropTypes.oneOf(['preset', 'custom']),
|
|
354
|
+
preset: PropTypes.string,
|
|
355
|
+
widthMm: PropTypes.number,
|
|
356
|
+
heightMm: PropTypes.number
|
|
357
|
+
}),
|
|
358
|
+
onCanvasSizeChange: PropTypes.func
|
|
352
359
|
};
|
|
353
360
|
|
|
354
361
|
/**
|
|
@@ -613,6 +620,125 @@ var pageSizesDimensions = _defineProperty(_defineProperty(_defineProperty(_defin
|
|
|
613
620
|
width: 460,
|
|
614
621
|
height: 648
|
|
615
622
|
});
|
|
623
|
+
var STANDARD_PAPER_SIZES_MM = {
|
|
624
|
+
A3: {
|
|
625
|
+
width: 297,
|
|
626
|
+
height: 420
|
|
627
|
+
},
|
|
628
|
+
A4: {
|
|
629
|
+
width: 210,
|
|
630
|
+
height: 297
|
|
631
|
+
},
|
|
632
|
+
A5: {
|
|
633
|
+
width: 148,
|
|
634
|
+
height: 210
|
|
635
|
+
},
|
|
636
|
+
Letter: {
|
|
637
|
+
width: 215.9,
|
|
638
|
+
height: 279.4
|
|
639
|
+
},
|
|
640
|
+
Legal: {
|
|
641
|
+
width: 215.9,
|
|
642
|
+
height: 355.6
|
|
643
|
+
},
|
|
644
|
+
Ledger: {
|
|
645
|
+
width: 431.8,
|
|
646
|
+
height: 279.4
|
|
647
|
+
},
|
|
648
|
+
B5: {
|
|
649
|
+
width: 176,
|
|
650
|
+
height: 250
|
|
651
|
+
},
|
|
652
|
+
C5: {
|
|
653
|
+
width: 162,
|
|
654
|
+
height: 229
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
var CANVAS_SIZE_MODES = {
|
|
658
|
+
preset: 'preset',
|
|
659
|
+
custom: 'custom'
|
|
660
|
+
};
|
|
661
|
+
var CUSTOM_CANVAS_PRESET_KEY = 'Custom';
|
|
662
|
+
var MM_TO_PX_RATIO = pageSizesDimensions[pageSizes.A4].width / STANDARD_PAPER_SIZES_MM.A4.width;
|
|
663
|
+
var MIN_CUSTOM_MM = 10;
|
|
664
|
+
var MAX_CUSTOM_MM = 2000;
|
|
665
|
+
var isValidPresetSize = function isValidPresetSize(size) {
|
|
666
|
+
return Boolean(size && pageSizesDimensions[size]);
|
|
667
|
+
};
|
|
668
|
+
var clampMm = function clampMm(value) {
|
|
669
|
+
var parsed = Number(value);
|
|
670
|
+
if (!Number.isFinite(parsed)) return null;
|
|
671
|
+
var clamped = Math.max(MIN_CUSTOM_MM, Math.min(MAX_CUSTOM_MM, parsed));
|
|
672
|
+
return Number(clamped.toFixed(2));
|
|
673
|
+
};
|
|
674
|
+
var mmToPx = function mmToPx(mm) {
|
|
675
|
+
var safeMm = clampMm(mm);
|
|
676
|
+
if (!safeMm) return null;
|
|
677
|
+
return Math.round(safeMm * MM_TO_PX_RATIO);
|
|
678
|
+
};
|
|
679
|
+
var getPresetMmDimensions = function getPresetMmDimensions(preset) {
|
|
680
|
+
return STANDARD_PAPER_SIZES_MM[preset] || null;
|
|
681
|
+
};
|
|
682
|
+
var getCanvasSizeLabel = function getCanvasSizeLabel(canvasSize) {
|
|
683
|
+
if (!canvasSize) return pageSizes.A4;
|
|
684
|
+
if (canvasSize.mode === CANVAS_SIZE_MODES.custom) {
|
|
685
|
+
return "".concat(canvasSize.widthMm, " x ").concat(canvasSize.heightMm, " mm");
|
|
686
|
+
}
|
|
687
|
+
return canvasSize.preset || pageSizes.A4;
|
|
688
|
+
};
|
|
689
|
+
var normalizeCanvasSize = function normalizeCanvasSize() {
|
|
690
|
+
var _pageSizesDimensions$, _pageSizesDimensions$2, _getPresetMmDimension, _getPresetMmDimension2;
|
|
691
|
+
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
692
|
+
var fallbackPreset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : pageSizes.A4;
|
|
693
|
+
var fallback = {
|
|
694
|
+
mode: CANVAS_SIZE_MODES.preset,
|
|
695
|
+
preset: fallbackPreset,
|
|
696
|
+
widthPx: ((_pageSizesDimensions$ = pageSizesDimensions[fallbackPreset]) === null || _pageSizesDimensions$ === void 0 ? void 0 : _pageSizesDimensions$.width) || pageSizesDimensions[pageSizes.A4].width,
|
|
697
|
+
heightPx: ((_pageSizesDimensions$2 = pageSizesDimensions[fallbackPreset]) === null || _pageSizesDimensions$2 === void 0 ? void 0 : _pageSizesDimensions$2.height) || pageSizesDimensions[pageSizes.A4].height,
|
|
698
|
+
widthMm: ((_getPresetMmDimension = getPresetMmDimensions(fallbackPreset)) === null || _getPresetMmDimension === void 0 ? void 0 : _getPresetMmDimension.width) || STANDARD_PAPER_SIZES_MM.A4.width,
|
|
699
|
+
heightMm: ((_getPresetMmDimension2 = getPresetMmDimensions(fallbackPreset)) === null || _getPresetMmDimension2 === void 0 ? void 0 : _getPresetMmDimension2.height) || STANDARD_PAPER_SIZES_MM.A4.height
|
|
700
|
+
};
|
|
701
|
+
if (!input) return fallback;
|
|
702
|
+
if (typeof input === 'string' && isValidPresetSize(input)) {
|
|
703
|
+
var mmDims = getPresetMmDimensions(input) || getPresetMmDimensions(fallbackPreset);
|
|
704
|
+
return {
|
|
705
|
+
mode: CANVAS_SIZE_MODES.preset,
|
|
706
|
+
preset: input,
|
|
707
|
+
widthPx: pageSizesDimensions[input].width,
|
|
708
|
+
heightPx: pageSizesDimensions[input].height,
|
|
709
|
+
widthMm: mmDims === null || mmDims === void 0 ? void 0 : mmDims.width,
|
|
710
|
+
heightMm: mmDims === null || mmDims === void 0 ? void 0 : mmDims.height
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
var mode = input.mode || (isValidPresetSize(input.size) ? CANVAS_SIZE_MODES.preset : null);
|
|
714
|
+
var preset = input.preset || input.size;
|
|
715
|
+
if (mode === CANVAS_SIZE_MODES.preset && isValidPresetSize(preset)) {
|
|
716
|
+
var _mmDims = getPresetMmDimensions(preset) || getPresetMmDimensions(fallbackPreset);
|
|
717
|
+
return {
|
|
718
|
+
mode: CANVAS_SIZE_MODES.preset,
|
|
719
|
+
preset: preset,
|
|
720
|
+
widthPx: pageSizesDimensions[preset].width,
|
|
721
|
+
heightPx: pageSizesDimensions[preset].height,
|
|
722
|
+
widthMm: _mmDims === null || _mmDims === void 0 ? void 0 : _mmDims.width,
|
|
723
|
+
heightMm: _mmDims === null || _mmDims === void 0 ? void 0 : _mmDims.height
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
var widthMm = clampMm(input.widthMm);
|
|
727
|
+
var heightMm = clampMm(input.heightMm);
|
|
728
|
+
var widthPx = mmToPx(widthMm);
|
|
729
|
+
var heightPx = mmToPx(heightMm);
|
|
730
|
+
if (mode === CANVAS_SIZE_MODES.custom && widthPx && heightPx) {
|
|
731
|
+
return {
|
|
732
|
+
mode: CANVAS_SIZE_MODES.custom,
|
|
733
|
+
preset: CUSTOM_CANVAS_PRESET_KEY,
|
|
734
|
+
widthMm: widthMm,
|
|
735
|
+
heightMm: heightMm,
|
|
736
|
+
widthPx: widthPx,
|
|
737
|
+
heightPx: heightPx
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
return fallback;
|
|
741
|
+
};
|
|
616
742
|
|
|
617
743
|
var sideBarpillsList = {
|
|
618
744
|
template: 'Template',
|
|
@@ -656,24 +782,6 @@ var textList = [{
|
|
|
656
782
|
fontStyle: 'normal',
|
|
657
783
|
textAlign: 'left',
|
|
658
784
|
width: 220
|
|
659
|
-
}, {
|
|
660
|
-
text: 'LOCATION_BREADCRUMB',
|
|
661
|
-
fontFamily: 'Open Sans',
|
|
662
|
-
fontSize: 12,
|
|
663
|
-
color: '#6D737B',
|
|
664
|
-
fontWeight: theme.fontWeights[400],
|
|
665
|
-
textDecoration: 'normal',
|
|
666
|
-
fontStyle: 'normal',
|
|
667
|
-
textAlign: 'left'
|
|
668
|
-
}, {
|
|
669
|
-
text: 'DOMAIN',
|
|
670
|
-
fontFamily: 'Plus Jakarta Sans',
|
|
671
|
-
fontSize: 10,
|
|
672
|
-
color: '#333333',
|
|
673
|
-
fontWeight: theme.fontWeights[400],
|
|
674
|
-
textDecoration: 'normal',
|
|
675
|
-
fontStyle: 'normal',
|
|
676
|
-
textAlign: 'left'
|
|
677
785
|
}];
|
|
678
786
|
var elementTypes = {
|
|
679
787
|
pageSize: 'pageSize',
|
|
@@ -810,7 +918,7 @@ var LOCATION_BREADCRUMB$8 = "property > building > room";
|
|
|
810
918
|
var DOMAIN$8 = "www.domain.com";
|
|
811
919
|
var SHOW_PROPERTY_LOCATION$8 = "Show Property Label";
|
|
812
920
|
var LOCATION_HELPER$8 = "Enable this to show the property’s location label on the canvas, or disable it to hide it.";
|
|
813
|
-
var SHOW_QR_ID$8 = "Show QR
|
|
921
|
+
var SHOW_QR_ID$8 = "Show QR ID";
|
|
814
922
|
var QR_ID_HELPER$8 = "Enable this to display the unique QR Code ID on the canvas, or disable it to remove it.";
|
|
815
923
|
var MONOCHROME_COLOR$8 = "Tint Color";
|
|
816
924
|
var MONOCHROME_STRENGTH$8 = "Tint Strength";
|
|
@@ -2264,6 +2372,7 @@ var propTypes$w = {
|
|
|
2264
2372
|
onChangeTextProperty: PropTypes.func,
|
|
2265
2373
|
onSetPageSize: PropTypes.func,
|
|
2266
2374
|
selectedPageSize: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
2375
|
+
selectedPageSizeLabel: PropTypes.string,
|
|
2267
2376
|
loadingImages: PropTypes.bool,
|
|
2268
2377
|
loadingFonts: PropTypes.bool,
|
|
2269
2378
|
uploadImageCallBack: PropTypes.func,
|
|
@@ -2275,7 +2384,7 @@ var propTypes$w = {
|
|
|
2275
2384
|
outsideBoundaryPreviewPadding: PropTypes.number
|
|
2276
2385
|
};
|
|
2277
2386
|
|
|
2278
|
-
var _templateObject$r, _templateObject2$l, _templateObject3$b, _templateObject4$
|
|
2387
|
+
var _templateObject$r, _templateObject2$l, _templateObject3$b, _templateObject4$8, _templateObject5$5;
|
|
2279
2388
|
var Container$4 = styled.div(_templateObject$r || (_templateObject$r = _taggedTemplateLiteral(["\n flex: 1;\n display: flex;\n background-color: ", ";\n background-image: ", ";\n position: relative;\n flex-direction: column;\n overflow: hidden;\n"])), theme.color.white_F7F7F7, function (_ref) {
|
|
2280
2389
|
var selectedTab = _ref.selectedTab;
|
|
2281
2390
|
return selectedTab ? 'none' : "url(".concat(EditorBg, ")");
|
|
@@ -2294,8 +2403,8 @@ var InnerContainerWrapper = styled.div(_templateObject3$b || (_templateObject3$b
|
|
|
2294
2403
|
var editorWidth = _ref5.editorWidth;
|
|
2295
2404
|
return editorWidth || 400;
|
|
2296
2405
|
});
|
|
2297
|
-
var Title = styled.p(_templateObject4$
|
|
2298
|
-
var EditorBox = styled.div(_templateObject5$
|
|
2406
|
+
var Title = styled.p(_templateObject4$8 || (_templateObject4$8 = _taggedTemplateLiteral(["\n border: 1px solid ", ";\n align-self: flex-start;\n font-size: 14px;\n font-family: ", ";\n font-weight: ", ";\n color: ", ";\n padding: 0 6px;\n border-bottom-width: 0;\n"])), theme.color.gray_E8E8E8, theme.fonts.primary, theme.fontWeights[300], theme.color.gray_7A7979);
|
|
2407
|
+
var EditorBox = styled.div(_templateObject5$5 || (_templateObject5$5 = _taggedTemplateLiteral(["\n height: ", "px;\n width: ", "px;\n min-height: ", "px;\n min-width: ", "px;\n background: ", ";\n box-shadow: 1.317px 1.317px 1.317px 0px rgba(0, 0, 0, 0.08);\n // transition: all 0.1s ease-in-out;\n overflow: hidden;\n"])), function (_ref6) {
|
|
2299
2408
|
var editorHeight = _ref6.editorHeight;
|
|
2300
2409
|
return editorHeight || 470;
|
|
2301
2410
|
}, function (_ref7) {
|
|
@@ -2347,6 +2456,7 @@ var propTypes$v = {
|
|
|
2347
2456
|
onChangeTextProperty: PropTypes.func,
|
|
2348
2457
|
onSetPageSize: PropTypes.func,
|
|
2349
2458
|
selectedPageSize: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
2459
|
+
selectedPageSizeLabel: PropTypes.string,
|
|
2350
2460
|
translation: PropTypes.object,
|
|
2351
2461
|
uploadImageCallBack: PropTypes.func,
|
|
2352
2462
|
setLoadingUploadImage: PropTypes.func,
|
|
@@ -2373,6 +2483,7 @@ var propTypes$u = {
|
|
|
2373
2483
|
onChangeBackgroundImageOpacity: PropTypes.func,
|
|
2374
2484
|
onSetPageSize: PropTypes.func,
|
|
2375
2485
|
selectedPageSize: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
2486
|
+
selectedPageSizeLabel: PropTypes.string,
|
|
2376
2487
|
languageLocale: PropTypes.string,
|
|
2377
2488
|
uploadImageCallBack: PropTypes.func,
|
|
2378
2489
|
setLoadingUploadImage: PropTypes.func,
|
|
@@ -2446,7 +2557,7 @@ var StyledContainer$6 = styled.div(_templateObject$p || (_templateObject$p = _ta
|
|
|
2446
2557
|
return disabled ? 'none' : 'all';
|
|
2447
2558
|
});
|
|
2448
2559
|
|
|
2449
|
-
var _templateObject$o, _templateObject2$j, _templateObject3$a, _templateObject4$
|
|
2560
|
+
var _templateObject$o, _templateObject2$j, _templateObject3$a, _templateObject4$7, _templateObject5$4, _templateObject6$2, _templateObject7$2;
|
|
2450
2561
|
var Wrapper = styled.span(_templateObject$o || (_templateObject$o = _taggedTemplateLiteral(["\n position: relative;\n display: inline-flex;\n cursor: ", ";\n"])), function (_ref) {
|
|
2451
2562
|
var disabled = _ref.disabled;
|
|
2452
2563
|
return disabled ? 'not-allowed' : 'pointer';
|
|
@@ -2454,16 +2565,16 @@ var Wrapper = styled.span(_templateObject$o || (_templateObject$o = _taggedTempl
|
|
|
2454
2565
|
var Floating = styled.div(_templateObject2$j || (_templateObject2$j = _taggedTemplateLiteral(["\n background-color: rgba(0, 0, 0, 0.75);\n color: #fff;\n border-radius: 6px;\n /* wrapping */\n white-space: normal;\n word-break: break-word;\n overflow-wrap: anywhere;\n /* defaults (can be overridden via inline style in component) */\n font-family: ", ";\n font-weight: ", ";\n pointer-events: none;\n box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);\n"])), theme.fonts.primary, theme.fontWeights[400]);
|
|
2455
2566
|
styled.div(_templateObject3$a || (_templateObject3$a = _taggedTemplateLiteral(["\n visibility: hidden;\n background-color: rgba(0, 0, 0, 0.7);\n color: white;\n text-align: center;\n padding: 4px 10px;\n border-radius: 4px;\n position: absolute;\n z-index: 9999;\n white-space: nowrap;\n opacity: 0;\n transition: all 0.1s;\n font-size: 13px;\n font-family: ", ";\n font-weight: ", ";\n\n ", "\n ", "\n ", "\n ", "\n\n ", ":hover & {\n visibility: visible;\n opacity: 1;\n }\n"])), theme.fonts.primary, theme.fontWeights[400], function (_ref2) {
|
|
2456
2567
|
var position = _ref2.position;
|
|
2457
|
-
return position === 'top' && css(_templateObject4$
|
|
2568
|
+
return position === 'top' && css(_templateObject4$7 || (_templateObject4$7 = _taggedTemplateLiteral(["\n bottom: 110%;\n left: 50%;\n transform: translateX(-50%);\n "])));
|
|
2458
2569
|
}, function (_ref3) {
|
|
2459
2570
|
var position = _ref3.position;
|
|
2460
|
-
return position === 'right' && css(_templateObject5$
|
|
2571
|
+
return position === 'right' && css(_templateObject5$4 || (_templateObject5$4 = _taggedTemplateLiteral(["\n top: 50%;\n left: 105%;\n transform: translateY(-50%);\n "])));
|
|
2461
2572
|
}, function (_ref4) {
|
|
2462
2573
|
var position = _ref4.position;
|
|
2463
|
-
return position === 'bottom' && css(_templateObject6$
|
|
2574
|
+
return position === 'bottom' && css(_templateObject6$2 || (_templateObject6$2 = _taggedTemplateLiteral(["\n top: 110%;\n left: 50%;\n transform: translateX(-50%);\n "])));
|
|
2464
2575
|
}, function (_ref5) {
|
|
2465
2576
|
var position = _ref5.position;
|
|
2466
|
-
return position === 'left' && css(_templateObject7$
|
|
2577
|
+
return position === 'left' && css(_templateObject7$2 || (_templateObject7$2 = _taggedTemplateLiteral(["\n top: 50%;\n right: 105%;\n transform: translateY(-50%);\n "])));
|
|
2467
2578
|
}, Wrapper);
|
|
2468
2579
|
|
|
2469
2580
|
var Tooltip = function Tooltip(_ref) {
|
|
@@ -2623,13 +2734,13 @@ var propTypes$s = {
|
|
|
2623
2734
|
tooltip: PropTypes.string
|
|
2624
2735
|
};
|
|
2625
2736
|
|
|
2626
|
-
var _templateObject$n, _templateObject2$i, _templateObject3$9, _templateObject4$
|
|
2737
|
+
var _templateObject$n, _templateObject2$i, _templateObject3$9, _templateObject4$6;
|
|
2627
2738
|
var DropDownItem = styled.div(_templateObject$n || (_templateObject$n = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
2628
2739
|
var IconWrapper$3 = styled.img(_templateObject2$i || (_templateObject2$i = _taggedTemplateLiteral(["\n object-fit: contain;\n"])));
|
|
2629
2740
|
var DropDownList = styled.div(_templateObject3$9 || (_templateObject3$9 = _taggedTemplateLiteral(["\n position: absolute;\n left: 0;\n top: 50;\n background-color: white;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n border-radius: 4px;\n margin-top: 5px;\n z-index: 10;\n width: 100%;\n max-height: 200px;\n overflow-y: auto;\n z-index: 9999;\n"])));
|
|
2630
2741
|
|
|
2631
2742
|
// Individual option in the dropdown
|
|
2632
|
-
var DropDownOption = styled.div(_templateObject4$
|
|
2743
|
+
var DropDownOption = styled.div(_templateObject4$6 || (_templateObject4$6 = _taggedTemplateLiteral(["\n padding: 8px 16px;\n cursor: pointer;\n font-size: 14px;\n color: #333333;\n &:hover {\n background-color: #f0f0f0;\n }\n &:active {\n background-color: #e0e0e0;\n }\n"])));
|
|
2633
2744
|
|
|
2634
2745
|
var DropDown = function DropDown(_ref) {
|
|
2635
2746
|
var left = _ref.left,
|
|
@@ -2697,10 +2808,18 @@ var DropDown = function DropDown(_ref) {
|
|
|
2697
2808
|
};
|
|
2698
2809
|
DropDown.propTypes = propTypes$s;
|
|
2699
2810
|
|
|
2700
|
-
var _templateObject$m, _templateObject2$h, _templateObject3$8;
|
|
2701
|
-
var Label$1 = styled.p(_templateObject$m || (_templateObject$m = _taggedTemplateLiteral(["\n
|
|
2702
|
-
var RowContainer$4 = styled.div(_templateObject2$h || (_templateObject2$h = _taggedTemplateLiteral(["\n
|
|
2703
|
-
var RemoveButton = styled.div(_templateObject3$8 || (_templateObject3$8 = _taggedTemplateLiteral(["\n
|
|
2811
|
+
var _templateObject$m, _templateObject2$h, _templateObject3$8, _templateObject4$5, _templateObject5$3, _templateObject6$1, _templateObject7$1, _templateObject8, _templateObject9, _templateObject0, _templateObject1;
|
|
2812
|
+
var Label$1 = styled.p(_templateObject$m || (_templateObject$m = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 14px;\n font-weight: ", ";\n font-family: ", ";\n"])), theme.color.gray_700, theme.fontWeights[400], theme.fonts.primary);
|
|
2813
|
+
var RowContainer$4 = styled.div(_templateObject2$h || (_templateObject2$h = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: flex-end;\n flex-wrap: wrap;\n gap: 2px;\n"])));
|
|
2814
|
+
var RemoveButton = styled.div(_templateObject3$8 || (_templateObject3$8 = _taggedTemplateLiteral(["\n height: 20px;\n width: 20px;\n border-radius: 20px;\n position: absolute;\n right: -7px;\n top: -7px;\n background: #ff4d4d;\n display: flex;\n align-items: center;\n justify-content: center;\n"])));
|
|
2815
|
+
var CustomSizeRow = styled.div(_templateObject4$5 || (_templateObject4$5 = _taggedTemplateLiteral(["\n display: flex;\n align-items: flex-end;\n gap: 10px;\n margin-left: 8px;\n margin-right: 12px;\n"])));
|
|
2816
|
+
var CustomSizeField = styled.div(_templateObject5$3 || (_templateObject5$3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n gap: 3px;\n"])));
|
|
2817
|
+
var CustomSizeFieldLabel = styled.span(_templateObject6$1 || (_templateObject6$1 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 9px;\n line-height: 11px;\n font-weight: ", ";\n font-family: ", ";\n"])), theme.color.gray_545454, theme.fontWeights[500], theme.fonts.primary);
|
|
2818
|
+
var CustomSizeInputWrap = styled.div(_templateObject7$1 || (_templateObject7$1 = _taggedTemplateLiteral(["\n position: relative;\n width: 108px;\n height: 40px;\n border: 1px solid ", ";\n border-radius: 8px;\n background-color: ", ";\n box-sizing: border-box;\n transition: border-color 0.15s ease;\n\n &:focus-within {\n border-color: ", ";\n }\n"])), theme.color.gray_200, theme.color.white, theme.color.primary);
|
|
2819
|
+
var CustomSizeInput = styled.input(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n border: none;\n border-radius: 8px;\n padding: 6px 32px 6px 10px;\n box-sizing: border-box;\n background: transparent;\n color: ", ";\n font-size: 14px;\n line-height: 20px;\n font-family: ", ";\n color-scheme: light;\n appearance: textfield;\n\n &:focus {\n outline: none;\n }\n\n &::-webkit-outer-spin-button,\n &::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n }\n"])), theme.color.gray_700, theme.fonts.primary);
|
|
2820
|
+
var CustomSizeUnit = styled.span(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n right: 10px;\n transform: translateY(-50%);\n color: ", ";\n font-size: 12px;\n line-height: 16px;\n font-family: ", ";\n pointer-events: none;\n"])), theme.color.gray_545454, theme.fonts.primary);
|
|
2821
|
+
var CustomSizeSeparator = styled.span(_templateObject0 || (_templateObject0 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 20px;\n line-height: 20px;\n font-weight: ", ";\n padding-bottom: 8px;\n font-family: ", ";\n"])), theme.color.gray_700, theme.fontWeights[400], theme.fonts.primary);
|
|
2822
|
+
var CustomSizeError = styled.span(_templateObject1 || (_templateObject1 = _taggedTemplateLiteral(["\n color: #d32f2f;\n font-size: 11px;\n margin-left: 4px;\n"])));
|
|
2704
2823
|
|
|
2705
2824
|
var propTypes$r = {
|
|
2706
2825
|
backgroundColor: PropTypes.string,
|
|
@@ -3349,6 +3468,7 @@ var TemplateToolBar = function TemplateToolBar(_ref) {
|
|
|
3349
3468
|
onChangeBackgroundImageOpacity = _ref.onChangeBackgroundImageOpacity,
|
|
3350
3469
|
onSetPageSize = _ref.onSetPageSize,
|
|
3351
3470
|
selectedPageSize = _ref.selectedPageSize,
|
|
3471
|
+
selectedPageSizeLabel = _ref.selectedPageSizeLabel,
|
|
3352
3472
|
languageLocale = _ref.languageLocale,
|
|
3353
3473
|
uploadImageCallBack = _ref.uploadImageCallBack,
|
|
3354
3474
|
setLoadingUploadImage = _ref.setLoadingUploadImage,
|
|
@@ -3361,6 +3481,62 @@ var TemplateToolBar = function TemplateToolBar(_ref) {
|
|
|
3361
3481
|
showBackgroundImagePicker = _ref$showBackgroundIm === void 0 ? true : _ref$showBackgroundIm,
|
|
3362
3482
|
_ref$showOpacityPicke = _ref.showOpacityPicker,
|
|
3363
3483
|
showOpacityPicker = _ref$showOpacityPicke === void 0 ? true : _ref$showOpacityPicke;
|
|
3484
|
+
var DEFAULT_CUSTOM_MM = 100;
|
|
3485
|
+
var _useState = useState(DEFAULT_CUSTOM_MM),
|
|
3486
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3487
|
+
customWidthMm = _useState2[0],
|
|
3488
|
+
setCustomWidthMm = _useState2[1];
|
|
3489
|
+
var _useState3 = useState(DEFAULT_CUSTOM_MM),
|
|
3490
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3491
|
+
customHeightMm = _useState4[0],
|
|
3492
|
+
setCustomHeightMm = _useState4[1];
|
|
3493
|
+
var _useState5 = useState(false),
|
|
3494
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3495
|
+
showCustomSizeInputs = _useState6[0],
|
|
3496
|
+
setShowCustomSizeInputs = _useState6[1];
|
|
3497
|
+
var _useState7 = useState(''),
|
|
3498
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3499
|
+
customSizeError = _useState8[0],
|
|
3500
|
+
setCustomSizeError = _useState8[1];
|
|
3501
|
+
var selectedLabel = selectedPageSizeLabel || (selectedPageSize === null || selectedPageSize === void 0 ? void 0 : selectedPageSize.preset) || selectedPageSize;
|
|
3502
|
+
var sizeOptions = useMemo(function () {
|
|
3503
|
+
return [].concat(_toConsumableArray(Object.keys(pageSizes)), [CUSTOM_CANVAS_PRESET_KEY]);
|
|
3504
|
+
}, []);
|
|
3505
|
+
useEffect(function () {
|
|
3506
|
+
var isCustom = (selectedPageSize === null || selectedPageSize === void 0 ? void 0 : selectedPageSize.mode) === CANVAS_SIZE_MODES.custom;
|
|
3507
|
+
setShowCustomSizeInputs(Boolean(isCustom));
|
|
3508
|
+
if (isCustom) {
|
|
3509
|
+
setCustomWidthMm((selectedPageSize === null || selectedPageSize === void 0 ? void 0 : selectedPageSize.widthMm) || DEFAULT_CUSTOM_MM);
|
|
3510
|
+
setCustomHeightMm((selectedPageSize === null || selectedPageSize === void 0 ? void 0 : selectedPageSize.heightMm) || DEFAULT_CUSTOM_MM);
|
|
3511
|
+
}
|
|
3512
|
+
}, [selectedPageSize]);
|
|
3513
|
+
var applyCustomSize = function applyCustomSize() {
|
|
3514
|
+
var widthValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : customWidthMm;
|
|
3515
|
+
var heightValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : customHeightMm;
|
|
3516
|
+
var showError = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
3517
|
+
var widthMm = Number(widthValue);
|
|
3518
|
+
var heightMm = Number(heightValue);
|
|
3519
|
+
var isValidRange = widthMm >= 10 && widthMm <= 2000 && heightMm >= 10 && heightMm <= 2000;
|
|
3520
|
+
if (!Number.isFinite(widthMm) || !Number.isFinite(heightMm) || !isValidRange) {
|
|
3521
|
+
if (showError) setCustomSizeError('10-2000 mm');
|
|
3522
|
+
return;
|
|
3523
|
+
}
|
|
3524
|
+
setCustomSizeError('');
|
|
3525
|
+
onSetPageSize === null || onSetPageSize === void 0 || onSetPageSize({
|
|
3526
|
+
mode: CANVAS_SIZE_MODES.custom,
|
|
3527
|
+
widthMm: widthMm,
|
|
3528
|
+
heightMm: heightMm
|
|
3529
|
+
});
|
|
3530
|
+
};
|
|
3531
|
+
var handleCustomInputKeyDown = function handleCustomInputKeyDown(e) {
|
|
3532
|
+
if (e.key !== 'Enter') return;
|
|
3533
|
+
e.preventDefault();
|
|
3534
|
+
applyCustomSize(customWidthMm, customHeightMm, true);
|
|
3535
|
+
};
|
|
3536
|
+
var handleCustomRowBlur = function handleCustomRowBlur(e) {
|
|
3537
|
+
if (e.currentTarget.contains(e.relatedTarget)) return;
|
|
3538
|
+
applyCustomSize(customWidthMm, customHeightMm, true);
|
|
3539
|
+
};
|
|
3364
3540
|
var selectBackgroundColor = function selectBackgroundColor(e) {
|
|
3365
3541
|
onSetBackgroundColor(e);
|
|
3366
3542
|
};
|
|
@@ -3410,13 +3586,43 @@ var TemplateToolBar = function TemplateToolBar(_ref) {
|
|
|
3410
3586
|
}();
|
|
3411
3587
|
return /*#__PURE__*/React.createElement(RowContainer$4, null, /*#__PURE__*/React.createElement(DropDown, {
|
|
3412
3588
|
gap: 20,
|
|
3413
|
-
left: /*#__PURE__*/React.createElement(Label$1, null,
|
|
3414
|
-
list:
|
|
3589
|
+
left: /*#__PURE__*/React.createElement(Label$1, null, selectedLabel),
|
|
3590
|
+
list: sizeOptions,
|
|
3415
3591
|
onSelect: function onSelect(e) {
|
|
3592
|
+
if (e === CUSTOM_CANVAS_PRESET_KEY) {
|
|
3593
|
+
setShowCustomSizeInputs(true);
|
|
3594
|
+
return;
|
|
3595
|
+
}
|
|
3596
|
+
setCustomSizeError('');
|
|
3597
|
+
setShowCustomSizeInputs(false);
|
|
3416
3598
|
onSetPageSize && onSetPageSize(e);
|
|
3417
3599
|
},
|
|
3418
3600
|
tooltip: TEXT_DICTIONARY === null || TEXT_DICTIONARY === void 0 || (_TEXT_DICTIONARY$lang = TEXT_DICTIONARY[languageLocale]) === null || _TEXT_DICTIONARY$lang === void 0 ? void 0 : _TEXT_DICTIONARY$lang.PAGE_SIZE
|
|
3419
|
-
}), /*#__PURE__*/React.createElement(
|
|
3601
|
+
}), showCustomSizeInputs ? /*#__PURE__*/React.createElement(CustomSizeRow, {
|
|
3602
|
+
onBlur: handleCustomRowBlur
|
|
3603
|
+
}, /*#__PURE__*/React.createElement(CustomSizeField, null, /*#__PURE__*/React.createElement(CustomSizeFieldLabel, null, "Width"), /*#__PURE__*/React.createElement(CustomSizeInputWrap, null, /*#__PURE__*/React.createElement(CustomSizeInput, {
|
|
3604
|
+
value: customWidthMm,
|
|
3605
|
+
onChange: function onChange(e) {
|
|
3606
|
+
var nextWidth = e.target.value;
|
|
3607
|
+
setCustomWidthMm(nextWidth);
|
|
3608
|
+
applyCustomSize(nextWidth, customHeightMm, false);
|
|
3609
|
+
},
|
|
3610
|
+
onKeyDown: handleCustomInputKeyDown,
|
|
3611
|
+
type: "number",
|
|
3612
|
+
min: 10,
|
|
3613
|
+
max: 2000
|
|
3614
|
+
}), /*#__PURE__*/React.createElement(CustomSizeUnit, null, "mm"))), /*#__PURE__*/React.createElement(CustomSizeSeparator, null, "x"), /*#__PURE__*/React.createElement(CustomSizeField, null, /*#__PURE__*/React.createElement(CustomSizeFieldLabel, null, "Height"), /*#__PURE__*/React.createElement(CustomSizeInputWrap, null, /*#__PURE__*/React.createElement(CustomSizeInput, {
|
|
3615
|
+
value: customHeightMm,
|
|
3616
|
+
onChange: function onChange(e) {
|
|
3617
|
+
var nextHeight = e.target.value;
|
|
3618
|
+
setCustomHeightMm(nextHeight);
|
|
3619
|
+
applyCustomSize(customWidthMm, nextHeight, false);
|
|
3620
|
+
},
|
|
3621
|
+
onKeyDown: handleCustomInputKeyDown,
|
|
3622
|
+
type: "number",
|
|
3623
|
+
min: 10,
|
|
3624
|
+
max: 2000
|
|
3625
|
+
}), /*#__PURE__*/React.createElement(CustomSizeUnit, null, "mm"))), customSizeError ? /*#__PURE__*/React.createElement(CustomSizeError, null, customSizeError) : null) : null, /*#__PURE__*/React.createElement(ToolBarButtonWrapper, {
|
|
3420
3626
|
gap: 11,
|
|
3421
3627
|
tooltip: TEXT_DICTIONARY === null || TEXT_DICTIONARY === void 0 || (_TEXT_DICTIONARY$lang2 = TEXT_DICTIONARY[languageLocale]) === null || _TEXT_DICTIONARY$lang2 === void 0 ? void 0 : _TEXT_DICTIONARY$lang2.BACKGROUND_COLOR,
|
|
3422
3628
|
tooltipPosition: 'bottom'
|
|
@@ -3993,6 +4199,7 @@ var TopToolBar = function TopToolBar(_ref) {
|
|
|
3993
4199
|
onChangeTextProperty = _ref.onChangeTextProperty,
|
|
3994
4200
|
onSetPageSize = _ref.onSetPageSize,
|
|
3995
4201
|
selectedPageSize = _ref.selectedPageSize,
|
|
4202
|
+
selectedPageSizeLabel = _ref.selectedPageSizeLabel,
|
|
3996
4203
|
languageLocale = _ref.languageLocale,
|
|
3997
4204
|
uploadImageCallBack = _ref.uploadImageCallBack,
|
|
3998
4205
|
setLoadingUploadImage = _ref.setLoadingUploadImage,
|
|
@@ -4018,6 +4225,7 @@ var TopToolBar = function TopToolBar(_ref) {
|
|
|
4018
4225
|
backgroundImageOpacity: backgroundImageOpacity,
|
|
4019
4226
|
onSetPageSize: onSetPageSize,
|
|
4020
4227
|
selectedPageSize: selectedPageSize,
|
|
4228
|
+
selectedPageSizeLabel: selectedPageSizeLabel,
|
|
4021
4229
|
languageLocale: languageLocale,
|
|
4022
4230
|
uploadImageCallBack: uploadImageCallBack,
|
|
4023
4231
|
setLoadingUploadImage: setLoadingUploadImage,
|
|
@@ -5364,6 +5572,7 @@ var Editor = function Editor(_ref) {
|
|
|
5364
5572
|
onChangeTextProperty = _ref.onChangeTextProperty,
|
|
5365
5573
|
onSetPageSize = _ref.onSetPageSize,
|
|
5366
5574
|
selectedPageSize = _ref.selectedPageSize,
|
|
5575
|
+
selectedPageSizeLabel = _ref.selectedPageSizeLabel,
|
|
5367
5576
|
loadingImages = _ref.loadingImages,
|
|
5368
5577
|
loadingFonts = _ref.loadingFonts,
|
|
5369
5578
|
uploadImageCallBack = _ref.uploadImageCallBack,
|
|
@@ -5382,7 +5591,7 @@ var Editor = function Editor(_ref) {
|
|
|
5382
5591
|
_ref$showOutsideBound = _ref.showOutsideBoundaryPreview,
|
|
5383
5592
|
showOutsideBoundaryPreview = _ref$showOutsideBound === void 0 ? false : _ref$showOutsideBound,
|
|
5384
5593
|
_ref$outsideBoundaryP = _ref.outsideBoundaryPreviewPadding,
|
|
5385
|
-
outsideBoundaryPreviewPadding = _ref$outsideBoundaryP === void 0 ?
|
|
5594
|
+
outsideBoundaryPreviewPadding = _ref$outsideBoundaryP === void 0 ? 80 : _ref$outsideBoundaryP;
|
|
5386
5595
|
var transformerRef = useRef(null);
|
|
5387
5596
|
var previewPadding = useMemo(function () {
|
|
5388
5597
|
return showOutsideBoundaryPreview ? Math.max(0, Number(outsideBoundaryPreviewPadding) || 0) : 0;
|
|
@@ -5719,6 +5928,7 @@ var Editor = function Editor(_ref) {
|
|
|
5719
5928
|
onChangeTextProperty: onChangeTextProperty,
|
|
5720
5929
|
onSetPageSize: onSetPageSize,
|
|
5721
5930
|
selectedPageSize: selectedPageSize,
|
|
5931
|
+
selectedPageSizeLabel: selectedPageSizeLabel,
|
|
5722
5932
|
languageLocale: languageLocale,
|
|
5723
5933
|
uploadImageCallBack: uploadImageCallBack,
|
|
5724
5934
|
setLoadingUploadImage: setLoadingUploadImage,
|
|
@@ -6710,13 +6920,15 @@ var isPropValid = /* #__PURE__ */memoize(function (prop) {
|
|
|
6710
6920
|
* @property {Array} [allowedFormats] - Allowed formats for image uploading functions
|
|
6711
6921
|
* @property {boolean} showQrIdToggle (boolean, default false) → controls visibility of the QR ID toggle
|
|
6712
6922
|
* @property {string | number} qrId (string | number | null, default null) → the value to render when toggled on
|
|
6923
|
+
* @property {{ mode: 'preset' | 'custom', preset?: string, widthMm?: number, heightMm?: number }} [canvasSize]
|
|
6924
|
+
* @property {Function} [onCanvasSizeChange]
|
|
6713
6925
|
*/
|
|
6714
6926
|
|
|
6715
6927
|
/**
|
|
6716
6928
|
* @type {React.ForwardRefExoticComponent<StudioProps & React.RefAttributes<HTMLDivElement>>}
|
|
6717
6929
|
*/
|
|
6718
6930
|
var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
6719
|
-
var _elements$elements$fi, _elements$
|
|
6931
|
+
var _elements$elements$fi, _elements$find, _elements$find2, _elements$find3;
|
|
6720
6932
|
var _ref$title = _ref.title,
|
|
6721
6933
|
title = _ref$title === void 0 ? '' : _ref$title,
|
|
6722
6934
|
_ref$defaultQrLogo = _ref.defaultQrLogo,
|
|
@@ -6737,7 +6949,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
6737
6949
|
_ref$showOutsideBound = _ref.showOutsideBoundaryPreview,
|
|
6738
6950
|
showOutsideBoundaryPreview = _ref$showOutsideBound === void 0 ? false : _ref$showOutsideBound,
|
|
6739
6951
|
_ref$outsideBoundaryP = _ref.outsideBoundaryPreviewPadding,
|
|
6740
|
-
outsideBoundaryPreviewPadding = _ref$outsideBoundaryP === void 0 ?
|
|
6952
|
+
outsideBoundaryPreviewPadding = _ref$outsideBoundaryP === void 0 ? 80 : _ref$outsideBoundaryP,
|
|
6741
6953
|
onDeleteCustomTemplate = _ref.onDeleteCustomTemplate,
|
|
6742
6954
|
_ref$qrLink = _ref.qrLink,
|
|
6743
6955
|
qrLink = _ref$qrLink === void 0 ? 'www.google.com' : _ref$qrLink,
|
|
@@ -6760,7 +6972,9 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
6760
6972
|
_ref$showQrIdToggle = _ref.showQrIdToggle,
|
|
6761
6973
|
showQrIdToggle = _ref$showQrIdToggle === void 0 ? false : _ref$showQrIdToggle,
|
|
6762
6974
|
_ref$qrId = _ref.qrId,
|
|
6763
|
-
qrId = _ref$qrId === void 0 ? null : _ref$qrId
|
|
6975
|
+
qrId = _ref$qrId === void 0 ? null : _ref$qrId,
|
|
6976
|
+
canvasSize = _ref.canvasSize,
|
|
6977
|
+
onCanvasSizeChange = _ref.onCanvasSizeChange;
|
|
6764
6978
|
var stageRef = useRef(null);
|
|
6765
6979
|
var elementCacheRef = useRef({});
|
|
6766
6980
|
var qrIdActiveRef = useRef(false);
|
|
@@ -6886,14 +7100,31 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
6886
7100
|
currentQrId = _useState58[0],
|
|
6887
7101
|
setCurrentQrId = _useState58[1];
|
|
6888
7102
|
var overallLoading = loadingFonts || loadingImages || loadingUploadImage || loading;
|
|
6889
|
-
var
|
|
6890
|
-
var _base$find;
|
|
7103
|
+
var getPageSizeElement = useCallback(function () {
|
|
6891
7104
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
|
|
6892
|
-
|
|
7105
|
+
return base === null || base === void 0 ? void 0 : base.find(function (e) {
|
|
6893
7106
|
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
|
|
6894
|
-
})
|
|
6895
|
-
return pageSizesDimensions[sizeKey] || pageSizesDimensions[pageSizes.A4];
|
|
7107
|
+
});
|
|
6896
7108
|
}, [elements]);
|
|
7109
|
+
var getNormalizedCanvasSize = useCallback(function () {
|
|
7110
|
+
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
|
|
7111
|
+
var canvasSizeInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : canvasSize;
|
|
7112
|
+
if (canvasSizeInput) {
|
|
7113
|
+
return normalizeCanvasSize(canvasSizeInput, pageSizes.A4);
|
|
7114
|
+
}
|
|
7115
|
+
var pageSizeElem = base === null || base === void 0 ? void 0 : base.find(function (e) {
|
|
7116
|
+
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
|
|
7117
|
+
});
|
|
7118
|
+
return normalizeCanvasSize(pageSizeElem, pageSizes.A4);
|
|
7119
|
+
}, [elements, canvasSize]);
|
|
7120
|
+
var getPageDims = useCallback(function () {
|
|
7121
|
+
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : elements;
|
|
7122
|
+
var normalized = getNormalizedCanvasSize(base);
|
|
7123
|
+
return {
|
|
7124
|
+
width: normalized.widthPx,
|
|
7125
|
+
height: normalized.heightPx
|
|
7126
|
+
};
|
|
7127
|
+
}, [elements, getNormalizedCanvasSize]);
|
|
6897
7128
|
var findById = useCallback(function (id) {
|
|
6898
7129
|
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : elements;
|
|
6899
7130
|
return base.find(function (e) {
|
|
@@ -7109,9 +7340,47 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7109
7340
|
});
|
|
7110
7341
|
}, []);
|
|
7111
7342
|
useEffect(function () {
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7343
|
+
var incomingPageSizeElem = elementsList === null || elementsList === void 0 ? void 0 : elementsList.find(function (e) {
|
|
7344
|
+
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
|
|
7345
|
+
});
|
|
7346
|
+
var nextCanvasSize = canvasSize ? normalizeCanvasSize(canvasSize, pageSizes.A4) : normalizeCanvasSize(incomingPageSizeElem, pageSizes.A4);
|
|
7347
|
+
var nextElements = elementsList.map(function (elem) {
|
|
7348
|
+
if (elem.type !== elementTypes.pageSize) return elem;
|
|
7349
|
+
var nextPageSize = _objectSpread2({}, elem);
|
|
7350
|
+
if (nextCanvasSize.mode === CANVAS_SIZE_MODES.custom) {
|
|
7351
|
+
delete nextPageSize.size;
|
|
7352
|
+
nextPageSize.mode = CANVAS_SIZE_MODES.custom;
|
|
7353
|
+
nextPageSize.widthMm = nextCanvasSize.widthMm;
|
|
7354
|
+
nextPageSize.heightMm = nextCanvasSize.heightMm;
|
|
7355
|
+
} else {
|
|
7356
|
+
delete nextPageSize.mode;
|
|
7357
|
+
delete nextPageSize.widthMm;
|
|
7358
|
+
delete nextPageSize.heightMm;
|
|
7359
|
+
nextPageSize.size = nextCanvasSize.preset;
|
|
7360
|
+
}
|
|
7361
|
+
return nextPageSize;
|
|
7362
|
+
});
|
|
7363
|
+
if (!nextElements.some(function (elem) {
|
|
7364
|
+
return elem.type === elementTypes.pageSize;
|
|
7365
|
+
})) {
|
|
7366
|
+
var injectedPageSize = {
|
|
7367
|
+
type: elementTypes.pageSize,
|
|
7368
|
+
id: "element".concat(Date.now()),
|
|
7369
|
+
size: nextCanvasSize.preset || pageSizes.A4,
|
|
7370
|
+
cuttingGuideStroke: 0,
|
|
7371
|
+
cuttingGuideStrokeColor: theme.color.black
|
|
7372
|
+
};
|
|
7373
|
+
if (nextCanvasSize.mode === CANVAS_SIZE_MODES.custom) {
|
|
7374
|
+
delete injectedPageSize.size;
|
|
7375
|
+
injectedPageSize.mode = CANVAS_SIZE_MODES.custom;
|
|
7376
|
+
injectedPageSize.widthMm = nextCanvasSize.widthMm;
|
|
7377
|
+
injectedPageSize.heightMm = nextCanvasSize.heightMm;
|
|
7378
|
+
}
|
|
7379
|
+
nextElements.unshift(injectedPageSize);
|
|
7380
|
+
}
|
|
7381
|
+
LoadImages(nextElements);
|
|
7382
|
+
setElements(nextElements);
|
|
7383
|
+
var foundLoc = nextElements === null || nextElements === void 0 ? void 0 : nextElements.find(function (e) {
|
|
7115
7384
|
return e.id === LOCATION_ELEMENT_ID && e.type === elementTypes.text;
|
|
7116
7385
|
});
|
|
7117
7386
|
if (foundLoc) {
|
|
@@ -7120,7 +7389,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7120
7389
|
rest = _extends({}, (_objectDestructuringEmpty(_ref4), _ref4));
|
|
7121
7390
|
elementCacheRef.current[LOCATION_ELEMENT_ID] = _objectSpread2({}, rest);
|
|
7122
7391
|
}
|
|
7123
|
-
}, _toConsumableArray(elementsList));
|
|
7392
|
+
}, [canvasSize].concat(_toConsumableArray(elementsList)));
|
|
7124
7393
|
var LoadImages = function LoadImages(elems) {
|
|
7125
7394
|
setLoadingImages(true);
|
|
7126
7395
|
preloadRelevantImages(elems).then(function (_ref5) {
|
|
@@ -7136,17 +7405,15 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7136
7405
|
});
|
|
7137
7406
|
};
|
|
7138
7407
|
var editorHeight = useMemo(function () {
|
|
7139
|
-
var
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
}, [zoomPercentage, elements]);
|
|
7408
|
+
var _getPageDims2 = getPageDims(elements),
|
|
7409
|
+
height = _getPageDims2.height;
|
|
7410
|
+
return calculatePercentageValue(height, zoomPercentage);
|
|
7411
|
+
}, [zoomPercentage, elements, getPageDims]);
|
|
7144
7412
|
var editorWidth = useMemo(function () {
|
|
7145
|
-
var
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
}, [zoomPercentage, elements]);
|
|
7413
|
+
var _getPageDims3 = getPageDims(elements),
|
|
7414
|
+
width = _getPageDims3.width;
|
|
7415
|
+
return calculatePercentageValue(width, zoomPercentage);
|
|
7416
|
+
}, [zoomPercentage, elements, getPageDims]);
|
|
7150
7417
|
var normalizedOutsidePreviewPadding = useMemo(function () {
|
|
7151
7418
|
return Math.max(0, Number(outsideBoundaryPreviewPadding) || 0);
|
|
7152
7419
|
}, [outsideBoundaryPreviewPadding]);
|
|
@@ -7160,11 +7427,11 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7160
7427
|
};
|
|
7161
7428
|
}, [showOutsideBoundaryPreview, normalizedOutsidePreviewPadding, editorWidth, editorHeight]);
|
|
7162
7429
|
var selectedPageSize = useMemo(function () {
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
}, [
|
|
7430
|
+
return getNormalizedCanvasSize(elements);
|
|
7431
|
+
}, [elements, getNormalizedCanvasSize]);
|
|
7432
|
+
var selectedPageSizeLabel = useMemo(function () {
|
|
7433
|
+
return getCanvasSizeLabel(selectedPageSize);
|
|
7434
|
+
}, [selectedPageSize]);
|
|
7168
7435
|
var hasLocationText = useMemo(function () {
|
|
7169
7436
|
return elements.some(function (e) {
|
|
7170
7437
|
return e.type === elementTypes.text && e.id === LOCATION_ELEMENT_ID;
|
|
@@ -7293,20 +7560,30 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7293
7560
|
saveHistory([].concat(_toConsumableArray(elemClone), [newElement]));
|
|
7294
7561
|
};
|
|
7295
7562
|
var onSetPageSize = function onSetPageSize(newSize) {
|
|
7296
|
-
var _elements$find4;
|
|
7297
7563
|
if (!newSize) return;
|
|
7298
|
-
var
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
var
|
|
7302
|
-
var
|
|
7303
|
-
var
|
|
7304
|
-
var scaleY = newDims.height / oldDims.height;
|
|
7564
|
+
var oldDims = getNormalizedCanvasSize(elements);
|
|
7565
|
+
var newDims = normalizeCanvasSize(newSize, pageSizes.A4);
|
|
7566
|
+
var scaleX = newDims.widthPx / oldDims.widthPx;
|
|
7567
|
+
var scaleY = newDims.heightPx / oldDims.heightPx;
|
|
7568
|
+
var pageSizeElem = getPageSizeElement(elements);
|
|
7569
|
+
var pageSizeId = (pageSizeElem === null || pageSizeElem === void 0 ? void 0 : pageSizeElem.id) || "element".concat(Date.now());
|
|
7305
7570
|
var scaledElements = elements.map(function (elem) {
|
|
7306
7571
|
if (elem.type === elementTypes.pageSize) {
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
});
|
|
7572
|
+
var nextPageElem = _objectSpread2(_objectSpread2({}, elem), {}, {
|
|
7573
|
+
id: pageSizeId
|
|
7574
|
+
});
|
|
7575
|
+
if (newDims.mode === CANVAS_SIZE_MODES.custom) {
|
|
7576
|
+
delete nextPageElem.size;
|
|
7577
|
+
nextPageElem.mode = CANVAS_SIZE_MODES.custom;
|
|
7578
|
+
nextPageElem.widthMm = newDims.widthMm;
|
|
7579
|
+
nextPageElem.heightMm = newDims.heightMm;
|
|
7580
|
+
} else {
|
|
7581
|
+
delete nextPageElem.mode;
|
|
7582
|
+
delete nextPageElem.widthMm;
|
|
7583
|
+
delete nextPageElem.heightMm;
|
|
7584
|
+
nextPageElem.size = newDims.preset;
|
|
7585
|
+
}
|
|
7586
|
+
return nextPageElem;
|
|
7310
7587
|
}
|
|
7311
7588
|
var scaled = _objectSpread2({}, elem);
|
|
7312
7589
|
|
|
@@ -7326,7 +7603,39 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7326
7603
|
}
|
|
7327
7604
|
return scaled;
|
|
7328
7605
|
});
|
|
7606
|
+
if (!scaledElements.some(function (elem) {
|
|
7607
|
+
return elem.type === elementTypes.pageSize;
|
|
7608
|
+
})) {
|
|
7609
|
+
var newPageElement = {
|
|
7610
|
+
type: elementTypes.pageSize,
|
|
7611
|
+
id: pageSizeId,
|
|
7612
|
+
size: newDims.preset || pageSizes.A4,
|
|
7613
|
+
cuttingGuideStroke: 0,
|
|
7614
|
+
cuttingGuideStrokeColor: theme.color.black
|
|
7615
|
+
};
|
|
7616
|
+
if (newDims.mode === CANVAS_SIZE_MODES.custom) {
|
|
7617
|
+
delete newPageElement.size;
|
|
7618
|
+
newPageElement.mode = CANVAS_SIZE_MODES.custom;
|
|
7619
|
+
newPageElement.widthMm = newDims.widthMm;
|
|
7620
|
+
newPageElement.heightMm = newDims.heightMm;
|
|
7621
|
+
}
|
|
7622
|
+
scaledElements.unshift(newPageElement);
|
|
7623
|
+
}
|
|
7329
7624
|
saveHistory(removeImageProperty(scaledElements));
|
|
7625
|
+
if (typeof onCanvasSizeChange === 'function') {
|
|
7626
|
+
if (newDims.mode === CANVAS_SIZE_MODES.custom) {
|
|
7627
|
+
onCanvasSizeChange({
|
|
7628
|
+
mode: CANVAS_SIZE_MODES.custom,
|
|
7629
|
+
widthMm: newDims.widthMm,
|
|
7630
|
+
heightMm: newDims.heightMm
|
|
7631
|
+
});
|
|
7632
|
+
} else {
|
|
7633
|
+
onCanvasSizeChange({
|
|
7634
|
+
mode: CANVAS_SIZE_MODES.preset,
|
|
7635
|
+
preset: newDims.preset
|
|
7636
|
+
});
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7330
7639
|
};
|
|
7331
7640
|
var _onChangeCuttingGuideProp = function onChangeCuttingGuideProp(type, value) {
|
|
7332
7641
|
var elemClone = JSON.parse(JSON.stringify(elements));
|
|
@@ -7965,12 +8274,12 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
7965
8274
|
onToggleQrIdText: toggleQrIdText
|
|
7966
8275
|
}), loadingFonts ? null : /*#__PURE__*/React.createElement(Editor, {
|
|
7967
8276
|
setLoading: setLoading,
|
|
7968
|
-
cuttingGuideStroke: (elements === null || elements === void 0 || (_elements$
|
|
8277
|
+
cuttingGuideStroke: (elements === null || elements === void 0 || (_elements$find = elements.find(function (e) {
|
|
7969
8278
|
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
|
|
7970
|
-
})) === null || _elements$
|
|
7971
|
-
cuttingGuideStrokeColor: (elements === null || elements === void 0 || (_elements$
|
|
8279
|
+
})) === null || _elements$find === void 0 ? void 0 : _elements$find.cuttingGuideStroke) || 0,
|
|
8280
|
+
cuttingGuideStrokeColor: (elements === null || elements === void 0 || (_elements$find2 = elements.find(function (e) {
|
|
7972
8281
|
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.pageSize);
|
|
7973
|
-
})) === null || _elements$
|
|
8282
|
+
})) === null || _elements$find2 === void 0 ? void 0 : _elements$find2.cuttingGuideStrokeColor) || (theme === null || theme === void 0 ? void 0 : theme.color.black),
|
|
7974
8283
|
onChangeCuttingGuideProp: function onChangeCuttingGuideProp(type, value) {
|
|
7975
8284
|
_onChangeCuttingGuideProp(type, value);
|
|
7976
8285
|
},
|
|
@@ -8017,9 +8326,9 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
8017
8326
|
stageRef: stageRef,
|
|
8018
8327
|
saveHistory: saveHistory,
|
|
8019
8328
|
onChangeBackgroundImageOpacity: onChangeBackgroundImageOpacity,
|
|
8020
|
-
backgroundImageOpacity: (elements === null || elements === void 0 || (_elements$
|
|
8329
|
+
backgroundImageOpacity: (elements === null || elements === void 0 || (_elements$find3 = elements.find(function (e) {
|
|
8021
8330
|
return (e === null || e === void 0 ? void 0 : e.type) === (elementTypes === null || elementTypes === void 0 ? void 0 : elementTypes.backgroundImage);
|
|
8022
|
-
})) === null || _elements$
|
|
8331
|
+
})) === null || _elements$find3 === void 0 ? void 0 : _elements$find3.opacity) || backgroundImageOpacity,
|
|
8023
8332
|
onDeleteSelectedElement: onDeleteSelectedElement,
|
|
8024
8333
|
onCopySelectedElement: onCopySelectedElement,
|
|
8025
8334
|
onToggleLockElement: onToggleLockElement,
|
|
@@ -8029,6 +8338,7 @@ var Studio = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
8029
8338
|
onChangeTextProperty: onChangeTextProperty,
|
|
8030
8339
|
onSetPageSize: onSetPageSize,
|
|
8031
8340
|
selectedPageSize: selectedPageSize,
|
|
8341
|
+
selectedPageSizeLabel: selectedPageSizeLabel,
|
|
8032
8342
|
loadingImages: loadingImages,
|
|
8033
8343
|
loadingFonts: loadingFonts,
|
|
8034
8344
|
uploadImageCallBack: uploadImageCallBack,
|