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.modern.js
CHANGED
@@ -2915,10 +2915,162 @@ var ResetPasswordBox = function ResetPasswordBox(_ref) {
|
|
2915
2915
|
})));
|
2916
2916
|
};
|
2917
2917
|
|
2918
|
+
var SCROLL_SENSITIVITY = 0.0005;
|
2919
|
+
var MAX_ZOOM = 5;
|
2920
|
+
var MIN_ZOOM = 0.1;
|
2921
|
+
var ImageViewer = function ImageViewer(_ref) {
|
2922
|
+
var image = _ref.image;
|
2923
|
+
|
2924
|
+
var _useState = useState({
|
2925
|
+
x: 0,
|
2926
|
+
y: 0
|
2927
|
+
}),
|
2928
|
+
offset = _useState[0],
|
2929
|
+
setOffset = _useState[1];
|
2930
|
+
|
2931
|
+
var _useState2 = useState(1),
|
2932
|
+
zoom = _useState2[0],
|
2933
|
+
setZoom = _useState2[1];
|
2934
|
+
|
2935
|
+
var _useState3 = useState(false),
|
2936
|
+
draggind = _useState3[0],
|
2937
|
+
setDragging = _useState3[1];
|
2938
|
+
|
2939
|
+
var touch = useRef({
|
2940
|
+
x: 0,
|
2941
|
+
y: 0
|
2942
|
+
});
|
2943
|
+
var canvasRef = useRef(null);
|
2944
|
+
var containerRef = useRef(null);
|
2945
|
+
var observer = useRef(null);
|
2946
|
+
var background = useMemo(function () {
|
2947
|
+
return new Image();
|
2948
|
+
}, [image]);
|
2949
|
+
|
2950
|
+
var clamp = function clamp(num, min, max) {
|
2951
|
+
return Math.min(Math.max(num, min), max);
|
2952
|
+
};
|
2953
|
+
|
2954
|
+
var handleWheel = function handleWheel(event) {
|
2955
|
+
var deltaY = event.deltaY;
|
2956
|
+
|
2957
|
+
if (!draggind) {
|
2958
|
+
setZoom(function (zoom) {
|
2959
|
+
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
2960
|
+
});
|
2961
|
+
}
|
2962
|
+
};
|
2963
|
+
|
2964
|
+
var handleMouseMove = function handleMouseMove(event) {
|
2965
|
+
if (draggind) {
|
2966
|
+
var _touch$current = touch.current,
|
2967
|
+
x = _touch$current.x,
|
2968
|
+
y = _touch$current.y;
|
2969
|
+
var clientX = event.clientX,
|
2970
|
+
clientY = event.clientY;
|
2971
|
+
setOffset({
|
2972
|
+
x: offset.x + (x - clientX),
|
2973
|
+
y: offset.y + (y - clientY)
|
2974
|
+
});
|
2975
|
+
touch.current = {
|
2976
|
+
x: clientX,
|
2977
|
+
y: clientY
|
2978
|
+
};
|
2979
|
+
}
|
2980
|
+
};
|
2981
|
+
|
2982
|
+
var handleMouseDown = function handleMouseDown(event) {
|
2983
|
+
var clientX = event.clientX,
|
2984
|
+
clientY = event.clientY;
|
2985
|
+
touch.current = {
|
2986
|
+
x: clientX,
|
2987
|
+
y: clientY
|
2988
|
+
};
|
2989
|
+
setDragging(true);
|
2990
|
+
};
|
2991
|
+
|
2992
|
+
var handleMouseUp = function handleMouseUp() {
|
2993
|
+
return setDragging(false);
|
2994
|
+
};
|
2995
|
+
|
2996
|
+
var draw = function draw() {
|
2997
|
+
if (canvasRef.current) {
|
2998
|
+
var _canvasRef$current = canvasRef.current,
|
2999
|
+
width = _canvasRef$current.width,
|
3000
|
+
height = _canvasRef$current.height;
|
3001
|
+
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
3002
|
+
|
3003
|
+
canvasRef.current.width = width;
|
3004
|
+
canvasRef.current.height = height; // Clear canvas and scale it
|
3005
|
+
|
3006
|
+
context.translate(-offset.x, -offset.y);
|
3007
|
+
context.scale(zoom, zoom);
|
3008
|
+
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
3009
|
+
|
3010
|
+
var x = (context.canvas.width / zoom - background.width) / 2;
|
3011
|
+
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
3012
|
+
|
3013
|
+
context.drawImage(background, x, y);
|
3014
|
+
}
|
3015
|
+
};
|
3016
|
+
|
3017
|
+
useEffect(function () {
|
3018
|
+
observer.current = new ResizeObserver(function (entries) {
|
3019
|
+
entries.forEach(function (_ref2) {
|
3020
|
+
var target = _ref2.target;
|
3021
|
+
var width = background.width,
|
3022
|
+
height = background.height; // If width of the container is smaller than image, scale image down
|
3023
|
+
|
3024
|
+
if (target.clientWidth < width) {
|
3025
|
+
// Calculate scale
|
3026
|
+
var scale = target.clientWidth / width; // Redraw image
|
3027
|
+
|
3028
|
+
canvasRef.current.width = width * scale;
|
3029
|
+
canvasRef.current.height = height * scale;
|
3030
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
3031
|
+
}
|
3032
|
+
});
|
3033
|
+
});
|
3034
|
+
observer.current.observe(containerRef.current);
|
3035
|
+
return function () {
|
3036
|
+
return observer.current.unobserve(containerRef.current);
|
3037
|
+
};
|
3038
|
+
}, []);
|
3039
|
+
useEffect(function () {
|
3040
|
+
background.src = image;
|
3041
|
+
|
3042
|
+
if (canvasRef.current) {
|
3043
|
+
background.onload = function () {
|
3044
|
+
// Get the image dimensions
|
3045
|
+
var width = background.width,
|
3046
|
+
height = background.height;
|
3047
|
+
canvasRef.current.width = width;
|
3048
|
+
canvasRef.current.height = height; // Set image as background
|
3049
|
+
|
3050
|
+
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
3051
|
+
};
|
3052
|
+
}
|
3053
|
+
}, [background]);
|
3054
|
+
useEffect(function () {
|
3055
|
+
draw();
|
3056
|
+
}, [zoom, offset]);
|
3057
|
+
return /*#__PURE__*/React.createElement("div", {
|
3058
|
+
className: "image-viewer",
|
3059
|
+
ref: containerRef
|
3060
|
+
}, /*#__PURE__*/React.createElement("canvas", {
|
3061
|
+
onMouseDown: handleMouseDown,
|
3062
|
+
onMouseUp: handleMouseUp,
|
3063
|
+
onWheel: handleWheel,
|
3064
|
+
onMouseMove: handleMouseMove,
|
3065
|
+
ref: canvasRef
|
3066
|
+
}));
|
3067
|
+
};
|
3068
|
+
|
2918
3069
|
/**
|
2919
3070
|
* Viewer
|
2920
3071
|
*/
|
2921
3072
|
|
3073
|
+
|
2922
3074
|
var Viewer = function Viewer(_ref) {
|
2923
3075
|
var title = _ref.title,
|
2924
3076
|
src = _ref.src,
|
@@ -2955,8 +3107,8 @@ var Viewer = function Viewer(_ref) {
|
|
2955
3107
|
action: toggleDetails
|
2956
3108
|
}), actions), /*#__PURE__*/React.createElement("main", null, /*#__PURE__*/React.createElement("div", {
|
2957
3109
|
className: "resizer"
|
2958
|
-
}, /*#__PURE__*/React.createElement("picture", null, /*#__PURE__*/React.createElement(
|
2959
|
-
|
3110
|
+
}, /*#__PURE__*/React.createElement("picture", null, /*#__PURE__*/React.createElement(ImageViewer, {
|
3111
|
+
image: src
|
2960
3112
|
})))), /*#__PURE__*/React.createElement("aside", {
|
2961
3113
|
className: "" + (showDetails ? 'open' : '')
|
2962
3114
|
}, /*#__PURE__*/React.createElement(Header, {
|
@@ -4492,156 +4644,6 @@ var EmptyMessage = function EmptyMessage(_ref) {
|
|
4492
4644
|
}, text));
|
4493
4645
|
};
|
4494
4646
|
|
4495
|
-
var SCROLL_SENSITIVITY = 0.0005;
|
4496
|
-
var MAX_ZOOM = 5;
|
4497
|
-
var MIN_ZOOM = 0.1;
|
4498
|
-
var ImageViewer = function ImageViewer(_ref) {
|
4499
|
-
var image = _ref.image;
|
4500
|
-
|
4501
|
-
var _useState = useState({
|
4502
|
-
x: 0,
|
4503
|
-
y: 0
|
4504
|
-
}),
|
4505
|
-
offset = _useState[0],
|
4506
|
-
setOffset = _useState[1];
|
4507
|
-
|
4508
|
-
var _useState2 = useState(1),
|
4509
|
-
zoom = _useState2[0],
|
4510
|
-
setZoom = _useState2[1];
|
4511
|
-
|
4512
|
-
var _useState3 = useState(false),
|
4513
|
-
draggind = _useState3[0],
|
4514
|
-
setDragging = _useState3[1];
|
4515
|
-
|
4516
|
-
var touch = useRef({
|
4517
|
-
x: 0,
|
4518
|
-
y: 0
|
4519
|
-
});
|
4520
|
-
var canvasRef = useRef(null);
|
4521
|
-
var containerRef = useRef(null);
|
4522
|
-
var observer = useRef(null);
|
4523
|
-
var background = useMemo(function () {
|
4524
|
-
return new Image();
|
4525
|
-
}, [image]);
|
4526
|
-
|
4527
|
-
var clamp = function clamp(num, min, max) {
|
4528
|
-
return Math.min(Math.max(num, min), max);
|
4529
|
-
};
|
4530
|
-
|
4531
|
-
var handleWheel = function handleWheel(event) {
|
4532
|
-
var deltaY = event.deltaY;
|
4533
|
-
|
4534
|
-
if (!draggind) {
|
4535
|
-
setZoom(function (zoom) {
|
4536
|
-
return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
|
4537
|
-
});
|
4538
|
-
}
|
4539
|
-
};
|
4540
|
-
|
4541
|
-
var handleMouseMove = function handleMouseMove(event) {
|
4542
|
-
if (draggind) {
|
4543
|
-
var _touch$current = touch.current,
|
4544
|
-
x = _touch$current.x,
|
4545
|
-
y = _touch$current.y;
|
4546
|
-
var clientX = event.clientX,
|
4547
|
-
clientY = event.clientY;
|
4548
|
-
setOffset({
|
4549
|
-
x: offset.x + (x - clientX),
|
4550
|
-
y: offset.y + (y - clientY)
|
4551
|
-
});
|
4552
|
-
touch.current = {
|
4553
|
-
x: clientX,
|
4554
|
-
y: clientY
|
4555
|
-
};
|
4556
|
-
}
|
4557
|
-
};
|
4558
|
-
|
4559
|
-
var handleMouseDown = function handleMouseDown(event) {
|
4560
|
-
var clientX = event.clientX,
|
4561
|
-
clientY = event.clientY;
|
4562
|
-
touch.current = {
|
4563
|
-
x: clientX,
|
4564
|
-
y: clientY
|
4565
|
-
};
|
4566
|
-
setDragging(true);
|
4567
|
-
};
|
4568
|
-
|
4569
|
-
var handleMouseUp = function handleMouseUp() {
|
4570
|
-
return setDragging(false);
|
4571
|
-
};
|
4572
|
-
|
4573
|
-
var draw = function draw() {
|
4574
|
-
if (canvasRef.current) {
|
4575
|
-
var _canvasRef$current = canvasRef.current,
|
4576
|
-
width = _canvasRef$current.width,
|
4577
|
-
height = _canvasRef$current.height;
|
4578
|
-
var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
|
4579
|
-
|
4580
|
-
canvasRef.current.width = width;
|
4581
|
-
canvasRef.current.height = height; // Clear canvas and scale it
|
4582
|
-
|
4583
|
-
context.translate(-offset.x, -offset.y);
|
4584
|
-
context.scale(zoom, zoom);
|
4585
|
-
context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
|
4586
|
-
|
4587
|
-
var x = (context.canvas.width / zoom - background.width) / 2;
|
4588
|
-
var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
|
4589
|
-
|
4590
|
-
context.drawImage(background, x, y);
|
4591
|
-
}
|
4592
|
-
};
|
4593
|
-
|
4594
|
-
useEffect(function () {
|
4595
|
-
observer.current = new ResizeObserver(function (entries) {
|
4596
|
-
entries.forEach(function (_ref2) {
|
4597
|
-
var target = _ref2.target;
|
4598
|
-
var width = background.width,
|
4599
|
-
height = background.height; // If width of the container is smaller than image, scale image down
|
4600
|
-
|
4601
|
-
if (target.clientWidth < width) {
|
4602
|
-
// Calculate scale
|
4603
|
-
var scale = target.clientWidth / width; // Redraw image
|
4604
|
-
|
4605
|
-
canvasRef.current.width = width * scale;
|
4606
|
-
canvasRef.current.height = height * scale;
|
4607
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
|
4608
|
-
}
|
4609
|
-
});
|
4610
|
-
});
|
4611
|
-
observer.current.observe(containerRef.current);
|
4612
|
-
return function () {
|
4613
|
-
return observer.current.unobserve(containerRef.current);
|
4614
|
-
};
|
4615
|
-
}, []);
|
4616
|
-
useEffect(function () {
|
4617
|
-
background.src = image;
|
4618
|
-
|
4619
|
-
if (canvasRef.current) {
|
4620
|
-
background.onload = function () {
|
4621
|
-
// Get the image dimensions
|
4622
|
-
var width = background.width,
|
4623
|
-
height = background.height;
|
4624
|
-
canvasRef.current.width = width;
|
4625
|
-
canvasRef.current.height = height; // Set image as background
|
4626
|
-
|
4627
|
-
canvasRef.current.getContext("2d").drawImage(background, 0, 0);
|
4628
|
-
};
|
4629
|
-
}
|
4630
|
-
}, [background]);
|
4631
|
-
useEffect(function () {
|
4632
|
-
draw();
|
4633
|
-
}, [zoom, offset]);
|
4634
|
-
return /*#__PURE__*/React.createElement("div", {
|
4635
|
-
ref: containerRef
|
4636
|
-
}, /*#__PURE__*/React.createElement("canvas", {
|
4637
|
-
onMouseDown: handleMouseDown,
|
4638
|
-
onMouseUp: handleMouseUp,
|
4639
|
-
onWheel: handleWheel,
|
4640
|
-
onMouseMove: handleMouseMove,
|
4641
|
-
ref: canvasRef
|
4642
|
-
}));
|
4643
|
-
};
|
4644
|
-
|
4645
4647
|
/**
|
4646
4648
|
* Content Form
|
4647
4649
|
*/
|
@@ -10831,33 +10833,12 @@ function _catch(body, recover) {
|
|
10831
10833
|
|
10832
10834
|
var CollectionContext = React.createContext();
|
10833
10835
|
var CollectionContextProvider = function CollectionContextProvider(props) {
|
10834
|
-
var fetch = function fetch(id) {
|
10835
|
-
try {
|
10836
|
-
return Promise.resolve(_catch(function () {
|
10837
|
-
return Promise.resolve(API.find(id));
|
10838
|
-
}, function (error) {
|
10839
|
-
console.log(error);
|
10840
|
-
}));
|
10841
|
-
} catch (e) {
|
10842
|
-
return Promise.reject(e);
|
10843
|
-
}
|
10844
|
-
};
|
10845
10836
|
/*
|
10846
10837
|
async function reloadSelection() {
|
10847
10838
|
const result = await this.fetch(this.selected.id)
|
10848
10839
|
this.selected = result
|
10849
10840
|
}
|
10850
|
-
|
10851
|
-
try {
|
10852
|
-
if (versioning) form.version = 1
|
10853
|
-
await API.create(form);
|
10854
|
-
await this.load();
|
10855
|
-
} catch (error) {
|
10856
|
-
console.log(error)
|
10857
|
-
}
|
10858
|
-
return
|
10859
|
-
}
|
10860
|
-
async function update(form) {
|
10841
|
+
async function update(form) {
|
10861
10842
|
try {
|
10862
10843
|
if (versioning) form.version = form.version ? form.version + 1 : 1
|
10863
10844
|
await API.update(form)
|
@@ -10898,6 +10879,18 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
|
|
10898
10879
|
*/
|
10899
10880
|
|
10900
10881
|
|
10882
|
+
var fetch = function fetch(id) {
|
10883
|
+
try {
|
10884
|
+
return Promise.resolve(_catch(function () {
|
10885
|
+
return Promise.resolve(API.find(id));
|
10886
|
+
}, function (error) {
|
10887
|
+
console.log(error);
|
10888
|
+
}));
|
10889
|
+
} catch (e) {
|
10890
|
+
return Promise.reject(e);
|
10891
|
+
}
|
10892
|
+
};
|
10893
|
+
|
10901
10894
|
var removeCustomFilter = function removeCustomFilter(id) {
|
10902
10895
|
try {
|
10903
10896
|
var next = _extends({}, customFilters);
|
@@ -11009,7 +11002,6 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
|
|
11009
11002
|
setSelected = _useState6[1];
|
11010
11003
|
|
11011
11004
|
useEffect(function () {
|
11012
|
-
console.log("CONTEXT LOAD for Filters", filters, customFilters);
|
11013
11005
|
var mounted = true;
|
11014
11006
|
|
11015
11007
|
var callLoad = function callLoad() {
|
@@ -11020,7 +11012,6 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
|
|
11020
11012
|
|
11021
11013
|
callLoad();
|
11022
11014
|
return function () {
|
11023
|
-
console.log("CONTEXT UNMOUNT", filters, customFilters);
|
11024
11015
|
mounted = false;
|
11025
11016
|
};
|
11026
11017
|
}, [filters, customFilters]);
|
@@ -11402,7 +11393,8 @@ var CollectionPage = function CollectionPage(props) {
|
|
11402
11393
|
}, /*#__PURE__*/React.createElement(CollectionContextProvider, {
|
11403
11394
|
host: host,
|
11404
11395
|
url: url,
|
11405
|
-
filtersValue: filtersValue
|
11396
|
+
filtersValue: filtersValue,
|
11397
|
+
versioning: false
|
11406
11398
|
}, /*#__PURE__*/React.createElement(Header, {
|
11407
11399
|
title: title
|
11408
11400
|
}, actions), canFilter ? /*#__PURE__*/React.createElement(CollectionFilters, {
|
@@ -11423,5 +11415,5 @@ var isFunction = function isFunction(value) {
|
|
11423
11415
|
return value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);
|
11424
11416
|
};
|
11425
11417
|
|
11426
|
-
export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
|
11418
|
+
export { Accordion, Avatar, Button, Calendar, CheckBox, Chip, Chips, CircularProgress, CollectionContext$1 as CollectionContext, CollectionContext as CollectionContext2, CollectionEditor$2 as CollectionEditor, CollectionFilters$1 as CollectionFilters, CollectionPage$1 as CollectionPage, CollectionPage as CollectionPage2, CollectionTree, ColorField, Content, ContentEditor, ContentForm, ContentViewer, CreateContentDialog, DataTable, DateRange, Dialog, DropDown, DynamicForm, EditContentDialog, EmptyMessage, FORMATS$1 as FORMATS, FieldEditor, FileExplorer, FilesGrid, Form, HTTPClient, Header, Icon, ImageViewer, Kanban, KanbanCard, KanbanColumn, LinearProgress, List, ListEditor, LoginBox, Menu, MenuIcon, MenuItem, MenuSeparator, MultiSelector, Page, PageContext, PageProvider, PasswordEditor, PasswordField, Planner, Property, RadioButton, ResetPasswordBox, Section, Session, Site, SiteContext, SiteProvider, Stack, Switch, TEXTFORMATS, TYPES, Tab, TabbedContentEditor, TabbedTablePage, TabbedView, TableEditor$2 as TableEditor, TablePage, TablePage2, Tabs, TaskContext, TaskContextProvider, TaskMonitor, TaskProgress, Text, TextArea, TextField, Thumbnail, ToggleButton, TokenField, Tooltip, Tree, TreeItem, TreeNode, TreededContentEditor, UploadArea, UploadDialog, UploadFile, UploadIcon, Uploader, View, Viewer, WaitScreen, Wizard, WizardContext, isEmpty, isFunction };
|
11427
11419
|
//# sourceMappingURL=index.modern.js.map
|