ywana-core8 0.0.789 → 0.0.791
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.cjs +154 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +3 -3
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +154 -153
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +154 -153
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/widgets/upload/UploadDialog.js +1 -1
- package/src/widgets/viewer/Viewer.js +8 -1
package/dist/index.cjs
CHANGED
@@ -2923,10 +2923,161 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
2923
2923
|
})));
|
2924
2924
|
};
|
2925
2925
|
|
2926
|
+
var SCROLL_SENSITIVITY = 0.0005;
|
2927
|
+
var MAX_ZOOM = 5;
|
2928
|
+
var MIN_ZOOM = 0.1;
|
2929
|
+
var ImageViewer = function ImageViewer(_ref) {
|
2930
|
+
var image = _ref.image;
|
2931
|
+
|
2932
|
+
var _useState = React.useState({
|
2933
|
+
x: 0,
|
2934
|
+
y: 0
|
2935
|
+
}),
|
2936
|
+
offset = _useState[0],
|
2937
|
+
setOffset = _useState[1];
|
2938
|
+
|
2939
|
+
var _useState2 = React.useState(1),
|
2940
|
+
zoom = _useState2[0],
|
2941
|
+
setZoom = _useState2[1];
|
2942
|
+
|
2943
|
+
var _useState3 = React.useState(false),
|
2944
|
+
draggind = _useState3[0],
|
2945
|
+
setDragging = _useState3[1];
|
2946
|
+
|
2947
|
+
var touch = React.useRef({
|
2948
|
+
x: 0,
|
2949
|
+
y: 0
|
2950
|
+
});
|
2951
|
+
var canvasRef = React.useRef(null);
|
2952
|
+
var containerRef = React.useRef(null);
|
2953
|
+
var observer = React.useRef(null);
|
2954
|
+
var background = React.useMemo(function () {
|
2955
|
+
return new Image();
|
2956
|
+
}, [image]);
|
2957
|
+
|
2958
|
+
var clamp = function clamp(num, min, max) {
|
2959
|
+
return Math.min(Math.max(num, min), max);
|
2960
|
+
};
|
2961
|
+
|
2962
|
+
var handleWheel = function handleWheel(event) {
|
2963
|
+
var deltaY = event.deltaY;
|
2964
|
+
|
2965
|
+
if (!draggind) {
|
2966
|
+
setZoom(function (zoom) {
|
2967
|
+
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
2968
|
+
});
|
2969
|
+
}
|
2970
|
+
};
|
2971
|
+
|
2972
|
+
var handleMouseMove = function handleMouseMove(event) {
|
2973
|
+
if (draggind) {
|
2974
|
+
var _touch$current = touch.current,
|
2975
|
+
x = _touch$current.x,
|
2976
|
+
y = _touch$current.y;
|
2977
|
+
var clientX = event.clientX,
|
2978
|
+
clientY = event.clientY;
|
2979
|
+
setOffset({
|
2980
|
+
x: offset.x + (x - clientX),
|
2981
|
+
y: offset.y + (y - clientY)
|
2982
|
+
});
|
2983
|
+
touch.current = {
|
2984
|
+
x: clientX,
|
2985
|
+
y: clientY
|
2986
|
+
};
|
2987
|
+
}
|
2988
|
+
};
|
2989
|
+
|
2990
|
+
var handleMouseDown = function handleMouseDown(event) {
|
2991
|
+
var clientX = event.clientX,
|
2992
|
+
clientY = event.clientY;
|
2993
|
+
touch.current = {
|
2994
|
+
x: clientX,
|
2995
|
+
y: clientY
|
2996
|
+
};
|
2997
|
+
setDragging(true);
|
2998
|
+
};
|
2999
|
+
|
3000
|
+
var handleMouseUp = function handleMouseUp() {
|
3001
|
+
return setDragging(false);
|
3002
|
+
};
|
3003
|
+
|
3004
|
+
var draw = function draw() {
|
3005
|
+
if (canvasRef.current) {
|
3006
|
+
var _canvasRef$current = canvasRef.current,
|
3007
|
+
width = _canvasRef$current.width,
|
3008
|
+
height = _canvasRef$current.height;
|
3009
|
+
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
3010
|
+
|
3011
|
+
canvasRef.current.width = width;
|
3012
|
+
canvasRef.current.height = height; // Clear canvas and scale it
|
3013
|
+
|
3014
|
+
context.translate(-offset.x, -offset.y);
|
3015
|
+
context.scale(zoom, zoom);
|
3016
|
+
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
3017
|
+
|
3018
|
+
var x = (context.canvas.width / zoom - background.width) / 2;
|
3019
|
+
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
3020
|
+
|
3021
|
+
context.drawImage(background, x, y);
|
3022
|
+
}
|
3023
|
+
};
|
3024
|
+
|
3025
|
+
React.useEffect(function () {
|
3026
|
+
observer.current = new ResizeObserver(function (entries) {
|
3027
|
+
entries.forEach(function (_ref2) {
|
3028
|
+
var target = _ref2.target;
|
3029
|
+
var width = background.width,
|
3030
|
+
height = background.height; // If width of the container is smaller than image, scale image down
|
3031
|
+
|
3032
|
+
if (target.clientWidth < width) {
|
3033
|
+
// Calculate scale
|
3034
|
+
var scale = target.clientWidth / width; // Redraw image
|
3035
|
+
|
3036
|
+
canvasRef.current.width = width * scale;
|
3037
|
+
canvasRef.current.height = height * scale;
|
3038
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
3039
|
+
}
|
3040
|
+
});
|
3041
|
+
});
|
3042
|
+
observer.current.observe(containerRef.current);
|
3043
|
+
return function () {
|
3044
|
+
return observer.current.unobserve(containerRef.current);
|
3045
|
+
};
|
3046
|
+
}, []);
|
3047
|
+
React.useEffect(function () {
|
3048
|
+
background.src = image;
|
3049
|
+
|
3050
|
+
if (canvasRef.current) {
|
3051
|
+
background.onload = function () {
|
3052
|
+
// Get the image dimensions
|
3053
|
+
var width = background.width,
|
3054
|
+
height = background.height;
|
3055
|
+
canvasRef.current.width = width;
|
3056
|
+
canvasRef.current.height = height; // Set image as background
|
3057
|
+
|
3058
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
3059
|
+
};
|
3060
|
+
}
|
3061
|
+
}, [background]);
|
3062
|
+
React.useEffect(function () {
|
3063
|
+
draw();
|
3064
|
+
}, [zoom, offset]);
|
3065
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
3066
|
+
ref: containerRef
|
3067
|
+
}, /*#__PURE__*/React__default["default"].createElement("canvas", {
|
3068
|
+
onMouseDown: handleMouseDown,
|
3069
|
+
onMouseUp: handleMouseUp,
|
3070
|
+
onWheel: handleWheel,
|
3071
|
+
onMouseMove: handleMouseMove,
|
3072
|
+
ref: canvasRef
|
3073
|
+
}));
|
3074
|
+
};
|
3075
|
+
|
2926
3076
|
/**
|
2927
3077
|
* Viewer
|
2928
3078
|
*/
|
2929
3079
|
|
3080
|
+
|
2930
3081
|
var Viewer = function Viewer(_ref) {
|
2931
3082
|
var title = _ref.title,
|
2932
3083
|
src = _ref.src,
|
@@ -2963,8 +3114,8 @@ var Viewer = function Viewer(_ref) {
|
|
2963
3114
|
action: toggleDetails
|
2964
3115
|
}), actions), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
2965
3116
|
className: "resizer"
|
2966
|
-
}, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement(
|
2967
|
-
|
3117
|
+
}, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement(ImageViewer, {
|
3118
|
+
image: src
|
2968
3119
|
})))), /*#__PURE__*/React__default["default"].createElement("aside", {
|
2969
3120
|
className: "" + (showDetails ? 'open' : '')
|
2970
3121
|
}, /*#__PURE__*/React__default["default"].createElement(Header, {
|
@@ -4382,7 +4533,7 @@ var UploadDialog = function UploadDialog(_ref) {
|
|
4382
4533
|
action: function action() {
|
4383
4534
|
return onAction("CLOSE");
|
4384
4535
|
},
|
4385
|
-
disabled: canClose()
|
4536
|
+
disabled: !canClose()
|
4386
4537
|
}));
|
4387
4538
|
var title = /*#__PURE__*/React__default["default"].createElement(Text, {
|
4388
4539
|
use: "headline6"
|
@@ -4500,156 +4651,6 @@ var EmptyMessage = function EmptyMessage(_ref) {
|
|
4500
4651
|
}, text));
|
4501
4652
|
};
|
4502
4653
|
|
4503
|
-
var SCROLL_SENSITIVITY = 0.0005;
|
4504
|
-
var MAX_ZOOM = 5;
|
4505
|
-
var MIN_ZOOM = 0.1;
|
4506
|
-
var ImageViewer = function ImageViewer(_ref) {
|
4507
|
-
var image = _ref.image;
|
4508
|
-
|
4509
|
-
var _useState = React.useState({
|
4510
|
-
x: 0,
|
4511
|
-
y: 0
|
4512
|
-
}),
|
4513
|
-
offset = _useState[0],
|
4514
|
-
setOffset = _useState[1];
|
4515
|
-
|
4516
|
-
var _useState2 = React.useState(1),
|
4517
|
-
zoom = _useState2[0],
|
4518
|
-
setZoom = _useState2[1];
|
4519
|
-
|
4520
|
-
var _useState3 = React.useState(false),
|
4521
|
-
draggind = _useState3[0],
|
4522
|
-
setDragging = _useState3[1];
|
4523
|
-
|
4524
|
-
var touch = React.useRef({
|
4525
|
-
x: 0,
|
4526
|
-
y: 0
|
4527
|
-
});
|
4528
|
-
var canvasRef = React.useRef(null);
|
4529
|
-
var containerRef = React.useRef(null);
|
4530
|
-
var observer = React.useRef(null);
|
4531
|
-
var background = React.useMemo(function () {
|
4532
|
-
return new Image();
|
4533
|
-
}, [image]);
|
4534
|
-
|
4535
|
-
var clamp = function clamp(num, min, max) {
|
4536
|
-
return Math.min(Math.max(num, min), max);
|
4537
|
-
};
|
4538
|
-
|
4539
|
-
var handleWheel = function handleWheel(event) {
|
4540
|
-
var deltaY = event.deltaY;
|
4541
|
-
|
4542
|
-
if (!draggind) {
|
4543
|
-
setZoom(function (zoom) {
|
4544
|
-
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
4545
|
-
});
|
4546
|
-
}
|
4547
|
-
};
|
4548
|
-
|
4549
|
-
var handleMouseMove = function handleMouseMove(event) {
|
4550
|
-
if (draggind) {
|
4551
|
-
var _touch$current = touch.current,
|
4552
|
-
x = _touch$current.x,
|
4553
|
-
y = _touch$current.y;
|
4554
|
-
var clientX = event.clientX,
|
4555
|
-
clientY = event.clientY;
|
4556
|
-
setOffset({
|
4557
|
-
x: offset.x + (x - clientX),
|
4558
|
-
y: offset.y + (y - clientY)
|
4559
|
-
});
|
4560
|
-
touch.current = {
|
4561
|
-
x: clientX,
|
4562
|
-
y: clientY
|
4563
|
-
};
|
4564
|
-
}
|
4565
|
-
};
|
4566
|
-
|
4567
|
-
var handleMouseDown = function handleMouseDown(event) {
|
4568
|
-
var clientX = event.clientX,
|
4569
|
-
clientY = event.clientY;
|
4570
|
-
touch.current = {
|
4571
|
-
x: clientX,
|
4572
|
-
y: clientY
|
4573
|
-
};
|
4574
|
-
setDragging(true);
|
4575
|
-
};
|
4576
|
-
|
4577
|
-
var handleMouseUp = function handleMouseUp() {
|
4578
|
-
return setDragging(false);
|
4579
|
-
};
|
4580
|
-
|
4581
|
-
var draw = function draw() {
|
4582
|
-
if (canvasRef.current) {
|
4583
|
-
var _canvasRef$current = canvasRef.current,
|
4584
|
-
width = _canvasRef$current.width,
|
4585
|
-
height = _canvasRef$current.height;
|
4586
|
-
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
4587
|
-
|
4588
|
-
canvasRef.current.width = width;
|
4589
|
-
canvasRef.current.height = height; // Clear canvas and scale it
|
4590
|
-
|
4591
|
-
context.translate(-offset.x, -offset.y);
|
4592
|
-
context.scale(zoom, zoom);
|
4593
|
-
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
4594
|
-
|
4595
|
-
var x = (context.canvas.width / zoom - background.width) / 2;
|
4596
|
-
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
4597
|
-
|
4598
|
-
context.drawImage(background, x, y);
|
4599
|
-
}
|
4600
|
-
};
|
4601
|
-
|
4602
|
-
React.useEffect(function () {
|
4603
|
-
observer.current = new ResizeObserver(function (entries) {
|
4604
|
-
entries.forEach(function (_ref2) {
|
4605
|
-
var target = _ref2.target;
|
4606
|
-
var width = background.width,
|
4607
|
-
height = background.height; // If width of the container is smaller than image, scale image down
|
4608
|
-
|
4609
|
-
if (target.clientWidth < width) {
|
4610
|
-
// Calculate scale
|
4611
|
-
var scale = target.clientWidth / width; // Redraw image
|
4612
|
-
|
4613
|
-
canvasRef.current.width = width * scale;
|
4614
|
-
canvasRef.current.height = height * scale;
|
4615
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
4616
|
-
}
|
4617
|
-
});
|
4618
|
-
});
|
4619
|
-
observer.current.observe(containerRef.current);
|
4620
|
-
return function () {
|
4621
|
-
return observer.current.unobserve(containerRef.current);
|
4622
|
-
};
|
4623
|
-
}, []);
|
4624
|
-
React.useEffect(function () {
|
4625
|
-
background.src = image;
|
4626
|
-
|
4627
|
-
if (canvasRef.current) {
|
4628
|
-
background.onload = function () {
|
4629
|
-
// Get the image dimensions
|
4630
|
-
var width = background.width,
|
4631
|
-
height = background.height;
|
4632
|
-
canvasRef.current.width = width;
|
4633
|
-
canvasRef.current.height = height; // Set image as background
|
4634
|
-
|
4635
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
4636
|
-
};
|
4637
|
-
}
|
4638
|
-
}, [background]);
|
4639
|
-
React.useEffect(function () {
|
4640
|
-
draw();
|
4641
|
-
}, [zoom, offset]);
|
4642
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
4643
|
-
ref: containerRef
|
4644
|
-
}, /*#__PURE__*/React__default["default"].createElement("canvas", {
|
4645
|
-
onMouseDown: handleMouseDown,
|
4646
|
-
onMouseUp: handleMouseUp,
|
4647
|
-
onWheel: handleWheel,
|
4648
|
-
onMouseMove: handleMouseMove,
|
4649
|
-
ref: canvasRef
|
4650
|
-
}));
|
4651
|
-
};
|
4652
|
-
|
4653
4654
|
/**
|
4654
4655
|
* Content Form
|
4655
4656
|
*/
|