ywana-core8 0.0.751 → 0.0.753

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
@@ -203,6 +203,29 @@ function _extends() {
203
203
  return _extends.apply(this, arguments);
204
204
  }
205
205
 
206
+ /**
207
+ * Tooltip
208
+ */
209
+
210
+ var Tooltip = function Tooltip(props) {
211
+ var _props$text = props.text,
212
+ text = _props$text === void 0 ? "" : _props$text,
213
+ _props$top = props.top,
214
+ top = _props$top === void 0 ? "1rem" : _props$top,
215
+ _props$left = props.left,
216
+ left = _props$left === void 0 ? "1rem" : _props$left;
217
+ var style = {
218
+ top: top,
219
+ left: left
220
+ };
221
+ return /*#__PURE__*/React__default["default"].createElement("div", {
222
+ className: "tooltip"
223
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
224
+ className: "tooltip-text",
225
+ style: style
226
+ }, text), props.children);
227
+ };
228
+
206
229
  /**
207
230
  * Icon
208
231
  */
@@ -211,6 +234,7 @@ var Icon = function Icon(_ref) {
211
234
  var icon = _ref.icon,
212
235
  _ref$size = _ref.size,
213
236
  size = _ref$size === void 0 ? "normal" : _ref$size,
237
+ tooltip = _ref.tooltip,
214
238
  _ref$clickable = _ref.clickable,
215
239
  clickable = _ref$clickable === void 0 ? false : _ref$clickable,
216
240
  _ref$disabled = _ref.disabled,
@@ -230,7 +254,10 @@ var Icon = function Icon(_ref) {
230
254
  }
231
255
 
232
256
  var style = disabled ? "disabled" : clickable ? "clickable" : "";
233
- return /*#__PURE__*/React__default["default"].createElement("i", {
257
+ return tooltip ? /*#__PURE__*/React__default["default"].createElement(Tooltip, tooltip, /*#__PURE__*/React__default["default"].createElement("i", {
258
+ className: "icon " + size + " " + style + " " + className + " material-icons",
259
+ onClick: click
260
+ }, icon)) : /*#__PURE__*/React__default["default"].createElement("i", {
234
261
  className: "icon " + size + " " + style + " " + className + " material-icons",
235
262
  onClick: click
236
263
  }, icon);
@@ -752,6 +779,7 @@ var ListItem = function ListItem(_ref) {
752
779
  onSelect = _ref.onSelect;
753
780
  var id = item.id,
754
781
  icon = item.icon,
782
+ iconTooltip = item.iconTooltip,
755
783
  line1 = item.line1,
756
784
  line2 = item.line2,
757
785
  meta = item.meta;
@@ -767,7 +795,8 @@ var ListItem = function ListItem(_ref) {
767
795
  onClick: select
768
796
  }, icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
769
797
  icon: icon,
770
- size: "small"
798
+ size: "small",
799
+ tooltip: iconTooltip
771
800
  }) : null, /*#__PURE__*/React__default["default"].createElement("main", null, /*#__PURE__*/React__default["default"].createElement("div", {
772
801
  className: "primary-line"
773
802
  }, /*#__PURE__*/React__default["default"].createElement(Text, null, line1)), line2 ? /*#__PURE__*/React__default["default"].createElement("div", {
@@ -2420,29 +2449,6 @@ var Switch = function Switch(props) {
2420
2449
  }));
2421
2450
  };
2422
2451
 
2423
- /**
2424
- * Tooltip
2425
- */
2426
-
2427
- var Tooltip = function Tooltip(props) {
2428
- var _props$text = props.text,
2429
- text = _props$text === void 0 ? "" : _props$text,
2430
- _props$top = props.top,
2431
- top = _props$top === void 0 ? "1rem" : _props$top,
2432
- _props$left = props.left,
2433
- left = _props$left === void 0 ? "1rem" : _props$left;
2434
- var style = {
2435
- top: top,
2436
- left: left
2437
- };
2438
- return /*#__PURE__*/React__default["default"].createElement("div", {
2439
- className: "tooltip"
2440
- }, /*#__PURE__*/React__default["default"].createElement("span", {
2441
- className: "tooltip-text",
2442
- style: style
2443
- }, text), props.children);
2444
- };
2445
-
2446
2452
  /**
2447
2453
  * Thumbnail
2448
2454
  */
@@ -4315,6 +4321,156 @@ var EmptyMessage = function EmptyMessage(_ref) {
4315
4321
  }, text));
4316
4322
  };
4317
4323
 
4324
+ var SCROLL_SENSITIVITY = 0.0005;
4325
+ var MAX_ZOOM = 5;
4326
+ var MIN_ZOOM = 0.1;
4327
+ var ImageViewer = function ImageViewer(_ref) {
4328
+ var image = _ref.image;
4329
+
4330
+ var _useState = React.useState({
4331
+ x: 0,
4332
+ y: 0
4333
+ }),
4334
+ offset = _useState[0],
4335
+ setOffset = _useState[1];
4336
+
4337
+ var _useState2 = React.useState(1),
4338
+ zoom = _useState2[0],
4339
+ setZoom = _useState2[1];
4340
+
4341
+ var _useState3 = React.useState(false),
4342
+ draggind = _useState3[0],
4343
+ setDragging = _useState3[1];
4344
+
4345
+ var touch = React.useRef({
4346
+ x: 0,
4347
+ y: 0
4348
+ });
4349
+ var canvasRef = React.useRef(null);
4350
+ var containerRef = React.useRef(null);
4351
+ var observer = React.useRef(null);
4352
+ var background = React.useMemo(function () {
4353
+ return new Image();
4354
+ }, [image]);
4355
+
4356
+ var clamp = function clamp(num, min, max) {
4357
+ return Math.min(Math.max(num, min), max);
4358
+ };
4359
+
4360
+ var handleWheel = function handleWheel(event) {
4361
+ var deltaY = event.deltaY;
4362
+
4363
+ if (!draggind) {
4364
+ setZoom(function (zoom) {
4365
+ return clamp(zoom + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM);
4366
+ });
4367
+ }
4368
+ };
4369
+
4370
+ var handleMouseMove = function handleMouseMove(event) {
4371
+ if (draggind) {
4372
+ var _touch$current = touch.current,
4373
+ x = _touch$current.x,
4374
+ y = _touch$current.y;
4375
+ var clientX = event.clientX,
4376
+ clientY = event.clientY;
4377
+ setOffset({
4378
+ x: offset.x + (x - clientX),
4379
+ y: offset.y + (y - clientY)
4380
+ });
4381
+ touch.current = {
4382
+ x: clientX,
4383
+ y: clientY
4384
+ };
4385
+ }
4386
+ };
4387
+
4388
+ var handleMouseDown = function handleMouseDown(event) {
4389
+ var clientX = event.clientX,
4390
+ clientY = event.clientY;
4391
+ touch.current = {
4392
+ x: clientX,
4393
+ y: clientY
4394
+ };
4395
+ setDragging(true);
4396
+ };
4397
+
4398
+ var handleMouseUp = function handleMouseUp() {
4399
+ return setDragging(false);
4400
+ };
4401
+
4402
+ var draw = function draw() {
4403
+ if (canvasRef.current) {
4404
+ var _canvasRef$current = canvasRef.current,
4405
+ width = _canvasRef$current.width,
4406
+ height = _canvasRef$current.height;
4407
+ var context = canvasRef.current.getContext("2d"); // Set canvas dimensions
4408
+
4409
+ canvasRef.current.width = width;
4410
+ canvasRef.current.height = height; // Clear canvas and scale it
4411
+
4412
+ context.translate(-offset.x, -offset.y);
4413
+ context.scale(zoom, zoom);
4414
+ context.clearRect(0, 0, width, height); // Make sure we're zooming to the center
4415
+
4416
+ var x = (context.canvas.width / zoom - background.width) / 2;
4417
+ var y = (context.canvas.height / zoom - background.height) / 2; // Draw image
4418
+
4419
+ context.drawImage(background, x, y);
4420
+ }
4421
+ };
4422
+
4423
+ React.useEffect(function () {
4424
+ observer.current = new ResizeObserver(function (entries) {
4425
+ entries.forEach(function (_ref2) {
4426
+ var target = _ref2.target;
4427
+ var width = background.width,
4428
+ height = background.height; // If width of the container is smaller than image, scale image down
4429
+
4430
+ if (target.clientWidth < width) {
4431
+ // Calculate scale
4432
+ var scale = target.clientWidth / width; // Redraw image
4433
+
4434
+ canvasRef.current.width = width * scale;
4435
+ canvasRef.current.height = height * scale;
4436
+ canvasRef.current.getContext("2d").drawImage(background, 0, 0, width * scale, height * scale);
4437
+ }
4438
+ });
4439
+ });
4440
+ observer.current.observe(containerRef.current);
4441
+ return function () {
4442
+ return observer.current.unobserve(containerRef.current);
4443
+ };
4444
+ }, []);
4445
+ React.useEffect(function () {
4446
+ background.src = image;
4447
+
4448
+ if (canvasRef.current) {
4449
+ background.onload = function () {
4450
+ // Get the image dimensions
4451
+ var width = background.width,
4452
+ height = background.height;
4453
+ canvasRef.current.width = width;
4454
+ canvasRef.current.height = height; // Set image as background
4455
+
4456
+ canvasRef.current.getContext("2d").drawImage(background, 0, 0);
4457
+ };
4458
+ }
4459
+ }, [background]);
4460
+ React.useEffect(function () {
4461
+ draw();
4462
+ }, [zoom, offset]);
4463
+ return /*#__PURE__*/React__default["default"].createElement("div", {
4464
+ ref: containerRef
4465
+ }, /*#__PURE__*/React__default["default"].createElement("canvas", {
4466
+ onMouseDown: handleMouseDown,
4467
+ onMouseUp: handleMouseUp,
4468
+ onWheel: handleWheel,
4469
+ onMouseMove: handleMouseMove,
4470
+ ref: canvasRef
4471
+ }));
4472
+ };
4473
+
4318
4474
  /**
4319
4475
  * Content Form
4320
4476
  */
@@ -6353,6 +6509,9 @@ var CollectionEditor$1 = function CollectionEditor(props) {
6353
6509
  var _temp5 = function _temp5() {
6354
6510
  if (onChange) onChange(form);
6355
6511
  setPageContext(Object.assign({}, pageContext));
6512
+ site.notify({
6513
+ title: "Datos Guardados"
6514
+ });
6356
6515
  };
6357
6516
 
6358
6517
  var _temp6 = function () {
@@ -11014,6 +11173,7 @@ exports.Form = Form;
11014
11173
  exports.HTTPClient = HTTPClient;
11015
11174
  exports.Header = Header;
11016
11175
  exports.Icon = Icon;
11176
+ exports.ImageViewer = ImageViewer;
11017
11177
  exports.Kanban = Kanban;
11018
11178
  exports.KanbanCard = KanbanCard;
11019
11179
  exports.KanbanColumn = KanbanColumn;