ywana-core8 0.0.790 → 0.0.792
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 +170 -177
- 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 +170 -178
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +170 -177
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/domain2/CollectionContext.js +7 -14
- package/src/domain2/CollectionPage.js +1 -1
- package/src/domain2/index.js +2 -1
- package/src/widgets/image/ImageViewer.js +1 -2
- package/src/widgets/viewer/Viewer.js +8 -1
package/dist/index.umd.js
CHANGED
@@ -2917,10 +2917,162 @@
|
|
2917
2917
|
})));
|
2918
2918
|
};
|
2919
2919
|
|
2920
|
+
var SCROLL_SENSITIVITY = 0.0005;
|
2921
|
+
var MAX_ZOOM = 5;
|
2922
|
+
var MIN_ZOOM = 0.1;
|
2923
|
+
var ImageViewer = function ImageViewer(_ref) {
|
2924
|
+
var image = _ref.image;
|
2925
|
+
|
2926
|
+
var _useState = React.useState({
|
2927
|
+
x: 0,
|
2928
|
+
y: 0
|
2929
|
+
}),
|
2930
|
+
offset = _useState[0],
|
2931
|
+
setOffset = _useState[1];
|
2932
|
+
|
2933
|
+
var _useState2 = React.useState(1),
|
2934
|
+
zoom = _useState2[0],
|
2935
|
+
setZoom = _useState2[1];
|
2936
|
+
|
2937
|
+
var _useState3 = React.useState(false),
|
2938
|
+
draggind = _useState3[0],
|
2939
|
+
setDragging = _useState3[1];
|
2940
|
+
|
2941
|
+
var touch = React.useRef({
|
2942
|
+
x: 0,
|
2943
|
+
y: 0
|
2944
|
+
});
|
2945
|
+
var canvasRef = React.useRef(null);
|
2946
|
+
var containerRef = React.useRef(null);
|
2947
|
+
var observer = React.useRef(null);
|
2948
|
+
var background = React.useMemo(function () {
|
2949
|
+
return new Image();
|
2950
|
+
}, [image]);
|
2951
|
+
|
2952
|
+
var clamp = function clamp(num, min, max) {
|
2953
|
+
return Math.min(Math.max(num, min), max);
|
2954
|
+
};
|
2955
|
+
|
2956
|
+
var handleWheel = function handleWheel(event) {
|
2957
|
+
var deltaY = event.deltaY;
|
2958
|
+
|
2959
|
+
if (!draggind) {
|
2960
|
+
setZoom(function (zoom) {
|
2961
|
+
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
2962
|
+
});
|
2963
|
+
}
|
2964
|
+
};
|
2965
|
+
|
2966
|
+
var handleMouseMove = function handleMouseMove(event) {
|
2967
|
+
if (draggind) {
|
2968
|
+
var _touch$current = touch.current,
|
2969
|
+
x = _touch$current.x,
|
2970
|
+
y = _touch$current.y;
|
2971
|
+
var clientX = event.clientX,
|
2972
|
+
clientY = event.clientY;
|
2973
|
+
setOffset({
|
2974
|
+
x: offset.x + (x - clientX),
|
2975
|
+
y: offset.y + (y - clientY)
|
2976
|
+
});
|
2977
|
+
touch.current = {
|
2978
|
+
x: clientX,
|
2979
|
+
y: clientY
|
2980
|
+
};
|
2981
|
+
}
|
2982
|
+
};
|
2983
|
+
|
2984
|
+
var handleMouseDown = function handleMouseDown(event) {
|
2985
|
+
var clientX = event.clientX,
|
2986
|
+
clientY = event.clientY;
|
2987
|
+
touch.current = {
|
2988
|
+
x: clientX,
|
2989
|
+
y: clientY
|
2990
|
+
};
|
2991
|
+
setDragging(true);
|
2992
|
+
};
|
2993
|
+
|
2994
|
+
var handleMouseUp = function handleMouseUp() {
|
2995
|
+
return setDragging(false);
|
2996
|
+
};
|
2997
|
+
|
2998
|
+
var draw = function draw() {
|
2999
|
+
if (canvasRef.current) {
|
3000
|
+
var _canvasRef$current = canvasRef.current,
|
3001
|
+
width = _canvasRef$current.width,
|
3002
|
+
height = _canvasRef$current.height;
|
3003
|
+
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
3004
|
+
|
3005
|
+
canvasRef.current.width = width;
|
3006
|
+
canvasRef.current.height = height; // Clear canvas and scale it
|
3007
|
+
|
3008
|
+
context.translate(-offset.x, -offset.y);
|
3009
|
+
context.scale(zoom, zoom);
|
3010
|
+
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
3011
|
+
|
3012
|
+
var x = (context.canvas.width / zoom - background.width) / 2;
|
3013
|
+
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
3014
|
+
|
3015
|
+
context.drawImage(background, x, y);
|
3016
|
+
}
|
3017
|
+
};
|
3018
|
+
|
3019
|
+
React.useEffect(function () {
|
3020
|
+
observer.current = new ResizeObserver(function (entries) {
|
3021
|
+
entries.forEach(function (_ref2) {
|
3022
|
+
var target = _ref2.target;
|
3023
|
+
var width = background.width,
|
3024
|
+
height = background.height; // If width of the container is smaller than image, scale image down
|
3025
|
+
|
3026
|
+
if (target.clientWidth < width) {
|
3027
|
+
// Calculate scale
|
3028
|
+
var scale = target.clientWidth / width; // Redraw image
|
3029
|
+
|
3030
|
+
canvasRef.current.width = width * scale;
|
3031
|
+
canvasRef.current.height = height * scale;
|
3032
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
3033
|
+
}
|
3034
|
+
});
|
3035
|
+
});
|
3036
|
+
observer.current.observe(containerRef.current);
|
3037
|
+
return function () {
|
3038
|
+
return observer.current.unobserve(containerRef.current);
|
3039
|
+
};
|
3040
|
+
}, []);
|
3041
|
+
React.useEffect(function () {
|
3042
|
+
background.src = image;
|
3043
|
+
|
3044
|
+
if (canvasRef.current) {
|
3045
|
+
background.onload = function () {
|
3046
|
+
// Get the image dimensions
|
3047
|
+
var width = background.width,
|
3048
|
+
height = background.height;
|
3049
|
+
canvasRef.current.width = width;
|
3050
|
+
canvasRef.current.height = height; // Set image as background
|
3051
|
+
|
3052
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
3053
|
+
};
|
3054
|
+
}
|
3055
|
+
}, [background]);
|
3056
|
+
React.useEffect(function () {
|
3057
|
+
draw();
|
3058
|
+
}, [zoom, offset]);
|
3059
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
3060
|
+
className: "image-viewer",
|
3061
|
+
ref: containerRef
|
3062
|
+
}, /*#__PURE__*/React__default["default"].createElement("canvas", {
|
3063
|
+
onMouseDown: handleMouseDown,
|
3064
|
+
onMouseUp: handleMouseUp,
|
3065
|
+
onWheel: handleWheel,
|
3066
|
+
onMouseMove: handleMouseMove,
|
3067
|
+
ref: canvasRef
|
3068
|
+
}));
|
3069
|
+
};
|
3070
|
+
|
2920
3071
|
/**
|
2921
3072
|
* Viewer
|
2922
3073
|
*/
|
2923
3074
|
|
3075
|
+
|
2924
3076
|
var Viewer = function Viewer(_ref) {
|
2925
3077
|
var title = _ref.title,
|
2926
3078
|
src = _ref.src,
|
@@ -2957,8 +3109,8 @@
|
|
2957
3109
|
action: toggleDetails
|
2958
3110
|
}), actions), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement("div", {
|
2959
3111
|
className: "resizer"
|
2960
|
-
}, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement(
|
2961
|
-
|
3112
|
+
}, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement(ImageViewer, {
|
3113
|
+
image: src
|
2962
3114
|
})))), /*#__PURE__*/React__default["default"].createElement("aside", {
|
2963
3115
|
className: "" + (showDetails ? 'open' : '')
|
2964
3116
|
}, /*#__PURE__*/React__default["default"].createElement(Header, {
|
@@ -4494,156 +4646,6 @@
|
|
4494
4646
|
}, text));
|
4495
4647
|
};
|
4496
4648
|
|
4497
|
-
var SCROLL_SENSITIVITY = 0.0005;
|
4498
|
-
var MAX_ZOOM = 5;
|
4499
|
-
var MIN_ZOOM = 0.1;
|
4500
|
-
var ImageViewer = function ImageViewer(_ref) {
|
4501
|
-
var image = _ref.image;
|
4502
|
-
|
4503
|
-
var _useState = React.useState({
|
4504
|
-
x: 0,
|
4505
|
-
y: 0
|
4506
|
-
}),
|
4507
|
-
offset = _useState[0],
|
4508
|
-
setOffset = _useState[1];
|
4509
|
-
|
4510
|
-
var _useState2 = React.useState(1),
|
4511
|
-
zoom = _useState2[0],
|
4512
|
-
setZoom = _useState2[1];
|
4513
|
-
|
4514
|
-
var _useState3 = React.useState(false),
|
4515
|
-
draggind = _useState3[0],
|
4516
|
-
setDragging = _useState3[1];
|
4517
|
-
|
4518
|
-
var touch = React.useRef({
|
4519
|
-
x: 0,
|
4520
|
-
y: 0
|
4521
|
-
});
|
4522
|
-
var canvasRef = React.useRef(null);
|
4523
|
-
var containerRef = React.useRef(null);
|
4524
|
-
var observer = React.useRef(null);
|
4525
|
-
var background = React.useMemo(function () {
|
4526
|
-
return new Image();
|
4527
|
-
}, [image]);
|
4528
|
-
|
4529
|
-
var clamp = function clamp(num, min, max) {
|
4530
|
-
return Math.min(Math.max(num, min), max);
|
4531
|
-
};
|
4532
|
-
|
4533
|
-
var handleWheel = function handleWheel(event) {
|
4534
|
-
var deltaY = event.deltaY;
|
4535
|
-
|
4536
|
-
if (!draggind) {
|
4537
|
-
setZoom(function (zoom) {
|
4538
|
-
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
4539
|
-
});
|
4540
|
-
}
|
4541
|
-
};
|
4542
|
-
|
4543
|
-
var handleMouseMove = function handleMouseMove(event) {
|
4544
|
-
if (draggind) {
|
4545
|
-
var _touch$current = touch.current,
|
4546
|
-
x = _touch$current.x,
|
4547
|
-
y = _touch$current.y;
|
4548
|
-
var clientX = event.clientX,
|
4549
|
-
clientY = event.clientY;
|
4550
|
-
setOffset({
|
4551
|
-
x: offset.x + (x - clientX),
|
4552
|
-
y: offset.y + (y - clientY)
|
4553
|
-
});
|
4554
|
-
touch.current = {
|
4555
|
-
x: clientX,
|
4556
|
-
y: clientY
|
4557
|
-
};
|
4558
|
-
}
|
4559
|
-
};
|
4560
|
-
|
4561
|
-
var handleMouseDown = function handleMouseDown(event) {
|
4562
|
-
var clientX = event.clientX,
|
4563
|
-
clientY = event.clientY;
|
4564
|
-
touch.current = {
|
4565
|
-
x: clientX,
|
4566
|
-
y: clientY
|
4567
|
-
};
|
4568
|
-
setDragging(true);
|
4569
|
-
};
|
4570
|
-
|
4571
|
-
var handleMouseUp = function handleMouseUp() {
|
4572
|
-
return setDragging(false);
|
4573
|
-
};
|
4574
|
-
|
4575
|
-
var draw = function draw() {
|
4576
|
-
if (canvasRef.current) {
|
4577
|
-
var _canvasRef$current = canvasRef.current,
|
4578
|
-
width = _canvasRef$current.width,
|
4579
|
-
height = _canvasRef$current.height;
|
4580
|
-
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
4581
|
-
|
4582
|
-
canvasRef.current.width = width;
|
4583
|
-
canvasRef.current.height = height; // Clear canvas and scale it
|
4584
|
-
|
4585
|
-
context.translate(-offset.x, -offset.y);
|
4586
|
-
context.scale(zoom, zoom);
|
4587
|
-
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
4588
|
-
|
4589
|
-
var x = (context.canvas.width / zoom - background.width) / 2;
|
4590
|
-
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
4591
|
-
|
4592
|
-
context.drawImage(background, x, y);
|
4593
|
-
}
|
4594
|
-
};
|
4595
|
-
|
4596
|
-
React.useEffect(function () {
|
4597
|
-
observer.current = new ResizeObserver(function (entries) {
|
4598
|
-
entries.forEach(function (_ref2) {
|
4599
|
-
var target = _ref2.target;
|
4600
|
-
var width = background.width,
|
4601
|
-
height = background.height; // If width of the container is smaller than image, scale image down
|
4602
|
-
|
4603
|
-
if (target.clientWidth < width) {
|
4604
|
-
// Calculate scale
|
4605
|
-
var scale = target.clientWidth / width; // Redraw image
|
4606
|
-
|
4607
|
-
canvasRef.current.width = width * scale;
|
4608
|
-
canvasRef.current.height = height * scale;
|
4609
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
4610
|
-
}
|
4611
|
-
});
|
4612
|
-
});
|
4613
|
-
observer.current.observe(containerRef.current);
|
4614
|
-
return function () {
|
4615
|
-
return observer.current.unobserve(containerRef.current);
|
4616
|
-
};
|
4617
|
-
}, []);
|
4618
|
-
React.useEffect(function () {
|
4619
|
-
background.src = image;
|
4620
|
-
|
4621
|
-
if (canvasRef.current) {
|
4622
|
-
background.onload = function () {
|
4623
|
-
// Get the image dimensions
|
4624
|
-
var width = background.width,
|
4625
|
-
height = background.height;
|
4626
|
-
canvasRef.current.width = width;
|
4627
|
-
canvasRef.current.height = height; // Set image as background
|
4628
|
-
|
4629
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
4630
|
-
};
|
4631
|
-
}
|
4632
|
-
}, [background]);
|
4633
|
-
React.useEffect(function () {
|
4634
|
-
draw();
|
4635
|
-
}, [zoom, offset]);
|
4636
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
4637
|
-
ref: containerRef
|
4638
|
-
}, /*#__PURE__*/React__default["default"].createElement("canvas", {
|
4639
|
-
onMouseDown: handleMouseDown,
|
4640
|
-
onMouseUp: handleMouseUp,
|
4641
|
-
onWheel: handleWheel,
|
4642
|
-
onMouseMove: handleMouseMove,
|
4643
|
-
ref: canvasRef
|
4644
|
-
}));
|
4645
|
-
};
|
4646
|
-
|
4647
4649
|
/**
|
4648
4650
|
* Content Form
|
4649
4651
|
*/
|
@@ -10833,33 +10835,12 @@
|
|
10833
10835
|
|
10834
10836
|
var CollectionContext = React__default["default"].createContext();
|
10835
10837
|
var CollectionContextProvider = function CollectionContextProvider(props) {
|
10836
|
-
var fetch = function fetch(id) {
|
10837
|
-
try {
|
10838
|
-
return Promise.resolve(_catch(function () {
|
10839
|
-
return Promise.resolve(API.find(id));
|
10840
|
-
}, function (error) {
|
10841
|
-
console.log(error);
|
10842
|
-
}));
|
10843
|
-
} catch (e) {
|
10844
|
-
return Promise.reject(e);
|
10845
|
-
}
|
10846
|
-
};
|
10847
10838
|
/*
|
10848
10839
|
async function reloadSelection() {
|
10849
10840
|
const result = await this.fetch(this.selected.id)
|
10850
10841
|
this.selected = result
|
10851
10842
|
}
|
10852
|
-
|
10853
|
-
try {
|
10854
|
-
if (versioning) form.version = 1
|
10855
|
-
await API.create(form);
|
10856
|
-
await this.load();
|
10857
|
-
} catch (error) {
|
10858
|
-
console.log(error)
|
10859
|
-
}
|
10860
|
-
return
|
10861
|
-
}
|
10862
|
-
async function update(form) {
|
10843
|
+
async function update(form) {
|
10863
10844
|
try {
|
10864
10845
|
if (versioning) form.version = form.version ? form.version + 1 : 1
|
10865
10846
|
await API.update(form)
|
@@ -10900,6 +10881,18 @@
|
|
10900
10881
|
*/
|
10901
10882
|
|
10902
10883
|
|
10884
|
+
var fetch = function fetch(id) {
|
10885
|
+
try {
|
10886
|
+
return Promise.resolve(_catch(function () {
|
10887
|
+
return Promise.resolve(API.find(id));
|
10888
|
+
}, function (error) {
|
10889
|
+
console.log(error);
|
10890
|
+
}));
|
10891
|
+
} catch (e) {
|
10892
|
+
return Promise.reject(e);
|
10893
|
+
}
|
10894
|
+
};
|
10895
|
+
|
10903
10896
|
var removeCustomFilter = function removeCustomFilter(id) {
|
10904
10897
|
try {
|
10905
10898
|
var next = _extends({}, customFilters);
|
@@ -11011,7 +11004,6 @@
|
|
11011
11004
|
setSelected = _useState6[1];
|
11012
11005
|
|
11013
11006
|
React.useEffect(function () {
|
11014
|
-
console.log("CONTEXT LOAD for Filters", filters, customFilters);
|
11015
11007
|
var mounted = true;
|
11016
11008
|
|
11017
11009
|
var callLoad = function callLoad() {
|
@@ -11022,7 +11014,6 @@
|
|
11022
11014
|
|
11023
11015
|
callLoad();
|
11024
11016
|
return function () {
|
11025
|
-
console.log("CONTEXT UNMOUNT", filters, customFilters);
|
11026
11017
|
mounted = false;
|
11027
11018
|
};
|
11028
11019
|
}, [filters, customFilters]);
|
@@ -11404,7 +11395,8 @@
|
|
11404
11395
|
}, /*#__PURE__*/React__default["default"].createElement(CollectionContextProvider, {
|
11405
11396
|
host: host,
|
11406
11397
|
url: url,
|
11407
|
-
filtersValue: filtersValue
|
11398
|
+
filtersValue: filtersValue,
|
11399
|
+
versioning: false
|
11408
11400
|
}, /*#__PURE__*/React__default["default"].createElement(Header, {
|
11409
11401
|
title: title
|
11410
11402
|
}, actions), canFilter ? /*#__PURE__*/React__default["default"].createElement(CollectionFilters, {
|
@@ -11450,6 +11442,7 @@
|
|
11450
11442
|
exports.DateRange = DateRange;
|
11451
11443
|
exports.Dialog = Dialog;
|
11452
11444
|
exports.DropDown = DropDown;
|
11445
|
+
exports.DynamicForm = DynamicForm;
|
11453
11446
|
exports.EditContentDialog = EditContentDialog;
|
11454
11447
|
exports.EmptyMessage = EmptyMessage;
|
11455
11448
|
exports.FORMATS = FORMATS$1;
|