ywana-core8 0.2.13 → 0.2.15

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.
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo, useCallback, useState, useEffect, useRef, Fragment, createContext } from "react";
1
+ import React, { useContext, useMemo, useCallback, useState, useEffect, useRef, Fragment, createContext, forwardRef, useImperativeHandle } from "react";
2
2
  function isEmpty(obj) {
3
3
  if (obj === null) {
4
4
  return true;
@@ -22632,26 +22632,38 @@ const LOGIN_CONTEXT = {
22632
22632
  const SCROLL_SENSITIVITY = 5e-4;
22633
22633
  const MAX_ZOOM = 5;
22634
22634
  const MIN_ZOOM = 0.1;
22635
- const ImageViewer = ({ image }) => {
22635
+ const ImageViewer = forwardRef(({ image }, ref2) => {
22636
22636
  const [offset2, setOffset] = useState({ x: 0, y: 0 });
22637
22637
  const [zoom, setZoom] = useState(1);
22638
- const [draggind, setDragging] = useState(false);
22638
+ const [dragging, setDragging] = useState(false);
22639
22639
  const touch = useRef({ x: 0, y: 0 });
22640
22640
  const canvasRef = useRef(null);
22641
22641
  const containerRef = useRef(null);
22642
22642
  const observer = useRef(null);
22643
22643
  const background = useMemo(() => new Image(), [image]);
22644
22644
  const clamp = (num, min2, max2) => Math.min(Math.max(num, min2), max2);
22645
+ useImperativeHandle(ref2, () => ({
22646
+ zoomIn: () => {
22647
+ setZoom((prevZoom) => clamp(prevZoom + 0.2, MIN_ZOOM, MAX_ZOOM));
22648
+ },
22649
+ zoomOut: () => {
22650
+ setZoom((prevZoom) => clamp(prevZoom - 0.2, MIN_ZOOM, MAX_ZOOM));
22651
+ },
22652
+ resetZoom: () => {
22653
+ setZoom(1);
22654
+ setOffset({ x: 0, y: 0 });
22655
+ }
22656
+ }), []);
22645
22657
  const handleWheel = (event) => {
22646
22658
  const { deltaY } = event;
22647
- if (!draggind) {
22659
+ if (!dragging) {
22648
22660
  setZoom(
22649
22661
  (zoom2) => clamp(zoom2 + deltaY * SCROLL_SENSITIVITY * -1, MIN_ZOOM, MAX_ZOOM)
22650
22662
  );
22651
22663
  }
22652
22664
  };
22653
22665
  const handleMouseMove = (event) => {
22654
- if (draggind) {
22666
+ if (dragging) {
22655
22667
  const { x, y } = touch.current;
22656
22668
  const { clientX, clientY } = event;
22657
22669
  setOffset({
@@ -22720,14 +22732,55 @@ const ImageViewer = ({ image }) => {
22720
22732
  ref: canvasRef
22721
22733
  }
22722
22734
  ));
22735
+ });
22736
+ const ViewerTest = () => {
22737
+ const [showViewer, setShowViewer] = useState(false);
22738
+ const sampleInfo = /* @__PURE__ */ React.createElement("div", { style: { padding: "1rem" } }, /* @__PURE__ */ React.createElement("h3", null, "Sample Image"), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("strong", null, "Size:"), " 1920x1080"), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("strong", null, "Format:"), " PNG"), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("strong", null, "Created:"), " 2024-01-15"));
22739
+ const sampleActions = [
22740
+ /* @__PURE__ */ React.createElement(Icon, { key: "download", icon: "download", clickable: true, title: "Download" }),
22741
+ /* @__PURE__ */ React.createElement(Icon, { key: "share", icon: "share", clickable: true, title: "Share" })
22742
+ ];
22743
+ return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("button", { onClick: () => setShowViewer(true) }, "Open Viewer Test"), showViewer && /* @__PURE__ */ React.createElement(
22744
+ Viewer,
22745
+ {
22746
+ title: "Sample Image",
22747
+ src: "https://concepto.de/wp-content/uploads/2015/03/paisaje-800x409.jpg",
22748
+ info: sampleInfo,
22749
+ actions: sampleActions,
22750
+ tools: true,
22751
+ onClose: () => setShowViewer(false)
22752
+ }
22753
+ ));
22723
22754
  };
22724
22755
  const Viewer = ({ title, src, info, actions = [], tools = false, onClose }) => {
22725
22756
  const [showDetails, setShowDetails] = useState(false);
22757
+ const [imageViewerRef, setImageViewerRef] = useState(null);
22726
22758
  function toggleDetails() {
22727
22759
  setShowDetails(!showDetails);
22728
22760
  }
22761
+ function handleZoomIn() {
22762
+ if (imageViewerRef && imageViewerRef.zoomIn) {
22763
+ imageViewerRef.zoomIn();
22764
+ }
22765
+ }
22766
+ function handleZoomOut() {
22767
+ if (imageViewerRef && imageViewerRef.zoomOut) {
22768
+ imageViewerRef.zoomOut();
22769
+ }
22770
+ }
22771
+ function handleZoomReset() {
22772
+ if (imageViewerRef && imageViewerRef.resetZoom) {
22773
+ imageViewerRef.resetZoom();
22774
+ }
22775
+ }
22729
22776
  const headerTitle = /* @__PURE__ */ React.createElement(Text, { use: "headline6" }, title);
22730
- return /* @__PURE__ */ React.createElement("div", { className: "viewer" }, /* @__PURE__ */ React.createElement(Header, { icon: "view", title: headerTitle }, onClose ? /* @__PURE__ */ React.createElement(Icon, { icon: "close", clickable: true, action: onClose }) : null, showDetails ? "" : /* @__PURE__ */ React.createElement(Icon, { icon: "info", clickable: true, action: toggleDetails }), actions), /* @__PURE__ */ React.createElement("main", null, /* @__PURE__ */ React.createElement("div", { className: "resizer" }, /* @__PURE__ */ React.createElement("picture", null, /* @__PURE__ */ React.createElement(ImageViewer, { image: src })))), /* @__PURE__ */ React.createElement("aside", { className: `${showDetails ? "open" : ""}` }, /* @__PURE__ */ React.createElement(Header, { title: "Detalles" }, /* @__PURE__ */ React.createElement(Icon, { icon: "close", clickable: true, action: toggleDetails })), /* @__PURE__ */ React.createElement("main", null, info)), tools ? /* @__PURE__ */ React.createElement("footer", null, /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_out" }), /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_out_map" }), /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_in" })) : null);
22777
+ return /* @__PURE__ */ React.createElement("div", { className: "viewer" }, /* @__PURE__ */ React.createElement(Header, { icon: "view", title: headerTitle }, actions, !showDetails && /* @__PURE__ */ React.createElement(Icon, { icon: "info", clickable: true, action: toggleDetails }), onClose && /* @__PURE__ */ React.createElement(Icon, { icon: "close", clickable: true, action: onClose })), /* @__PURE__ */ React.createElement("main", null, /* @__PURE__ */ React.createElement("div", { className: "resizer" }, /* @__PURE__ */ React.createElement("picture", null, /* @__PURE__ */ React.createElement(
22778
+ ImageViewer,
22779
+ {
22780
+ image: src,
22781
+ ref: setImageViewerRef
22782
+ }
22783
+ )))), /* @__PURE__ */ React.createElement("aside", { className: `${showDetails ? "open" : ""}` }, /* @__PURE__ */ React.createElement(Header, { title: "Detalles" }, /* @__PURE__ */ React.createElement(Icon, { icon: "close", clickable: true, action: toggleDetails })), /* @__PURE__ */ React.createElement("main", null, info)), tools && /* @__PURE__ */ React.createElement("footer", null, /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_out", action: handleZoomOut }), /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_out_map", action: handleZoomReset }), /* @__PURE__ */ React.createElement(Icon, { clickable: true, icon: "zoom_in", action: handleZoomIn })));
22731
22784
  };
22732
22785
  const Kanban = ({ children }) => {
22733
22786
  const hasSwimlanes = useMemo(() => {
@@ -32967,7 +33020,7 @@ const Workspace = ({ children }) => {
32967
33020
  toolbar: window2.toolbar,
32968
33021
  statusBar: window2.statusBar
32969
33022
  },
32970
- /* @__PURE__ */ React.createElement("div", { style: { padding: "16px" } }, window2.content)
33023
+ window2.content
32971
33024
  )));
32972
33025
  };
32973
33026
  const DesktopTaskbar = () => {
@@ -43032,6 +43085,7 @@ export {
43032
43085
  MenuItem,
43033
43086
  MenuSeparator,
43034
43087
  MonthCalendar,
43088
+ MultiProgress,
43035
43089
  MultiSelector,
43036
43090
  Page,
43037
43091
  PageContext,
@@ -43045,6 +43099,7 @@ export {
43045
43099
  ProgressExamples,
43046
43100
  Property,
43047
43101
  PropertyExamples,
43102
+ RadialProgress,
43048
43103
  RadioButton,
43049
43104
  RadioExamples,
43050
43105
  RadioGroup,
@@ -43056,6 +43111,7 @@ export {
43056
43111
  SiteContext,
43057
43112
  SiteProvider,
43058
43113
  Stack,
43114
+ StepProgress,
43059
43115
  Switch,
43060
43116
  SwitchExamples,
43061
43117
  TASK_STATES,
@@ -43100,6 +43156,7 @@ export {
43100
43156
  Uploader,
43101
43157
  View,
43102
43158
  Viewer,
43159
+ ViewerTest,
43103
43160
  WaitScreen,
43104
43161
  Window,
43105
43162
  WindowManager,