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 CHANGED
@@ -2923,10 +2923,162 @@ 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
+ className: "image-viewer",
3067
+ ref: containerRef
3068
+ }, /*#__PURE__*/React__default["default"].createElement("canvas", {
3069
+ onMouseDown: handleMouseDown,
3070
+ onMouseUp: handleMouseUp,
3071
+ onWheel: handleWheel,
3072
+ onMouseMove: handleMouseMove,
3073
+ ref: canvasRef
3074
+ }));
3075
+ };
3076
+
2926
3077
  /**
2927
3078
  * Viewer
2928
3079
  */
2929
3080
 
3081
+
2930
3082
  var Viewer = function Viewer(_ref) {
2931
3083
  var title = _ref.title,
2932
3084
  src = _ref.src,
@@ -2963,8 +3115,8 @@ var Viewer = function Viewer(_ref) {
2963
3115
  action: toggleDetails
2964
3116
  }), actions), /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement("div", {
2965
3117
  className: "resizer"
2966
- }, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement("img", {
2967
- src: src
3118
+ }, /*#__PURE__*/React__default["default"].createElement("picture", null, /*#__PURE__*/React__default["default"].createElement(ImageViewer, {
3119
+ image: src
2968
3120
  })))), /*#__PURE__*/React__default["default"].createElement("aside", {
2969
3121
  className: "" + (showDetails ? 'open' : '')
2970
3122
  }, /*#__PURE__*/React__default["default"].createElement(Header, {
@@ -4500,156 +4652,6 @@ var EmptyMessage = function EmptyMessage(_ref) {
4500
4652
  }, text));
4501
4653
  };
4502
4654
 
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
4655
  /**
4654
4656
  * Content Form
4655
4657
  */
@@ -10839,33 +10841,12 @@ function _catch(body, recover) {
10839
10841
 
10840
10842
  var CollectionContext = React__default["default"].createContext();
10841
10843
  var CollectionContextProvider = function CollectionContextProvider(props) {
10842
- var fetch = function fetch(id) {
10843
- try {
10844
- return Promise.resolve(_catch(function () {
10845
- return Promise.resolve(API.find(id));
10846
- }, function (error) {
10847
- console.log(error);
10848
- }));
10849
- } catch (e) {
10850
- return Promise.reject(e);
10851
- }
10852
- };
10853
10844
  /*
10854
10845
  async function reloadSelection() {
10855
10846
  const result = await this.fetch(this.selected.id)
10856
10847
  this.selected = result
10857
10848
  }
10858
- async function create(form) {
10859
- try {
10860
- if (versioning) form.version = 1
10861
- await API.create(form);
10862
- await this.load();
10863
- } catch (error) {
10864
- console.log(error)
10865
- }
10866
- return
10867
- }
10868
- async function update(form) {
10849
+ async function update(form) {
10869
10850
  try {
10870
10851
  if (versioning) form.version = form.version ? form.version + 1 : 1
10871
10852
  await API.update(form)
@@ -10906,6 +10887,18 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
10906
10887
  */
10907
10888
 
10908
10889
 
10890
+ var fetch = function fetch(id) {
10891
+ try {
10892
+ return Promise.resolve(_catch(function () {
10893
+ return Promise.resolve(API.find(id));
10894
+ }, function (error) {
10895
+ console.log(error);
10896
+ }));
10897
+ } catch (e) {
10898
+ return Promise.reject(e);
10899
+ }
10900
+ };
10901
+
10909
10902
  var removeCustomFilter = function removeCustomFilter(id) {
10910
10903
  try {
10911
10904
  var next = _extends({}, customFilters);
@@ -11017,7 +11010,6 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
11017
11010
  setSelected = _useState6[1];
11018
11011
 
11019
11012
  React.useEffect(function () {
11020
- console.log("CONTEXT LOAD for Filters", filters, customFilters);
11021
11013
  var mounted = true;
11022
11014
 
11023
11015
  var callLoad = function callLoad() {
@@ -11028,7 +11020,6 @@ var CollectionContextProvider = function CollectionContextProvider(props) {
11028
11020
 
11029
11021
  callLoad();
11030
11022
  return function () {
11031
- console.log("CONTEXT UNMOUNT", filters, customFilters);
11032
11023
  mounted = false;
11033
11024
  };
11034
11025
  }, [filters, customFilters]);
@@ -11410,7 +11401,8 @@ var CollectionPage = function CollectionPage(props) {
11410
11401
  }, /*#__PURE__*/React__default["default"].createElement(CollectionContextProvider, {
11411
11402
  host: host,
11412
11403
  url: url,
11413
- filtersValue: filtersValue
11404
+ filtersValue: filtersValue,
11405
+ versioning: false
11414
11406
  }, /*#__PURE__*/React__default["default"].createElement(Header, {
11415
11407
  title: title
11416
11408
  }, actions), canFilter ? /*#__PURE__*/React__default["default"].createElement(CollectionFilters, {
@@ -11456,6 +11448,7 @@ exports.DataTable = DataTable;
11456
11448
  exports.DateRange = DateRange;
11457
11449
  exports.Dialog = Dialog;
11458
11450
  exports.DropDown = DropDown;
11451
+ exports.DynamicForm = DynamicForm;
11459
11452
  exports.EditContentDialog = EditContentDialog;
11460
11453
  exports.EmptyMessage = EmptyMessage;
11461
11454
  exports.FORMATS = FORMATS$1;