tgui-core 4.2.3 → 4.3.1
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 +1 @@
|
|
|
1
|
-
import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{classes as o}from"../common/react.js";import{FloatingPortal as i,autoUpdate as r,flip as a,offset as l,shift as s,size as c,useClick as d,useDismiss as m,useFloating as p,useHover as
|
|
1
|
+
import{Fragment as e,jsx as t,jsxs as n}from"react/jsx-runtime";import{classes as o}from"../common/react.js";import{FloatingPortal as i,autoUpdate as r,flip as a,offset as l,shift as s,size as c,useClick as d,useDismiss as m,useFloating as p,useHover as g,useInteractions as f,useTransitionStatus as h}from"@floating-ui/react";import{cloneElement as u,isValidElement as C,useEffect as v,useState as w}from"react";function F(F){let b,{allowedOutsideClasses:x,animationDuration:y,children:O,closeAfterInteract:R,content:j,contentAutoWidth:k,contentClasses:z,contentOffset:E=6,contentStyles:M,disabled:P,hoverDelay:S,hoverOpen:N,handleOpen:$,onMounted:q,placement:A,preventPortal:B,stopChildPropagation:D,onOpenChange:G}=F,[H,I]=w(!1),{refs:J,floatingStyles:K,context:L}=p({middleware:[l(E),a({padding:6}),s(),k&&c({apply({rects:e,elements:t}){t.floating.style.width=`${e.reference.width}px`}})],onOpenChange(e){I(e),G?.(e)},open:H,placement:A||"bottom",transform:!1,whileElementsMounted:(e,t,n)=>(void 0!==q&&q(),r(e,t,n,{ancestorResize:!1,ancestorScroll:!1,elementResize:!1}))}),{isMounted:Q,status:T}=h(L,{duration:y||200}),U=m(L,{ancestorScroll:!0,outsidePress:e=>!x||e.target instanceof Element&&!e.target.closest(x)}),V=d(L,{enabled:!P}),W=g(L,{enabled:!P,restMs:S||200}),X=void 0!==$,{getReferenceProps:Y,getFloatingProps:Z}=f(X?[]:[U,N?W:V]),_=Y({ref:J.setReference,...D&&{onClick:e=>e.stopPropagation()}}),ee=Z({onClick:()=>{R&&L.onOpenChange(!1)},ref:J.setFloating});v(()=>{X&&L.onOpenChange($)},[$]),b=C(O)?u(O,_):t("div",{..._,children:O});let et=t("div",{className:o(["Floating",!y&&"Floating--animated",z]),"data-position":L.placement,"data-transition":T,style:{...K,...M},...ee,children:j});return n(e,{children:[b,Q&&!!j&&(B?et:t(i,{id:"tgui-root",children:et}))]})}export{F as Floating};
|
|
@@ -12,6 +12,25 @@ type Props = {
|
|
|
12
12
|
initialTop: number;
|
|
13
13
|
/** Padding applied to the right of the zoom controls */
|
|
14
14
|
zoomPadding: number;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum level of zoom possible
|
|
17
|
+
* @default 0.5
|
|
18
|
+
*/
|
|
19
|
+
minimumZoom: number;
|
|
20
|
+
/**
|
|
21
|
+
* Maximum level of zoom possible
|
|
22
|
+
* @default 1.5
|
|
23
|
+
*/
|
|
24
|
+
maximumZoom: number;
|
|
25
|
+
/**
|
|
26
|
+
* Increments by which zoom level changes every scroll/button click
|
|
27
|
+
* @default 0.1
|
|
28
|
+
*/
|
|
29
|
+
zoomIncrement: number;
|
|
30
|
+
/** X position to snap to. When this value is changed, the element will snap to said position */
|
|
31
|
+
zoomToX: number;
|
|
32
|
+
/** Y position to snap to. When this value is changed, the element will snap to said position */
|
|
33
|
+
zoomToY: number;
|
|
15
34
|
/** A callback function that is called when the background image is moved. */
|
|
16
35
|
onBackgroundMoved: (newX: number, newY: number) => void;
|
|
17
36
|
/** A callback function that is called when the zoom value changes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{computeBoxProps as n}from"../common/ui.js";import{useEffect as i,useRef as o,useState as r}from"react";import{Button as s}from"./Button.js";import{ProgressBar as l}from"./ProgressBar.js";import{Stack as a}from"./Stack.js";function c(s){let{backgroundImage:l,children:a,imageWidth:c,zoomPadding:d=0,initialLeft:m=0,initialTop:f=0,minimumZoom:p=.5,maximumZoom:h=1.5,zoomIncrement:v=.1,zoomToX:g=m,zoomToY:w=f,onBackgroundMoved:x,onZoomChange:b,...$}=s,[k,M]=r(m),[Y,j]=r(f),[y,I]=r(m),[z,E]=r(f),[X,C]=r(!1),[D,P]=r(1),Z=o(null);function B(e){M(e.clientX-y),j(e.clientY-z),C(!0)}function L(e){if(!X)return;let t=e.clientX-k,n=e.clientY-Y;x?.(t,n),I(t),E(n)}function S(){C(!1)}function V(e,t,n){if("increase"===e&&D>=h||"decrease"===e&&D<=p)return;let i=Math.round((D+("increase"===e?v:-v))*10)/10;P(i),I((y-t)/D*i+t),E((z-n)*i+n),b?.(i)}return i(()=>(window.addEventListener("mouseup",S),()=>{window.removeEventListener("mouseup",S)}),[]),i(()=>{void 0!==g&&void 0!==w&&(I(g),E(w))},[g,w]),t("div",{...n({...$,style:{...$.style,height:"100%",overflow:"hidden",position:"relative",width:"100%"}}),ref:Z,children:[e("div",{onMouseDown:B,onMouseMove:L,onWheel:function(e){0!==e.deltaY&&(e.preventDefault(),V(e.deltaY<0?"increase":"decrease",e.nativeEvent.offsetX,e.nativeEvent.offsetY))},style:{backgroundImage:`url("${l}")`,backgroundPosition:`${y}px ${z}px`,backgroundRepeat:"repeat",backgroundSize:`${D*c}px`,transition:`${X?"0s":"0.075s"} linear`,height:"100%",inset:0,position:"absolute",width:"100%"}}),e("div",{onMouseDown:B,onMouseMove:L,style:{height:"100%",inset:0,position:"absolute",transform:`translate(${y}px, ${z}px) scale(${D})`,transition:`${X?"0s":"0.075s"} linear`,transformOrigin:"top left",width:"100%"},children:a}),e(u,{padding:d,minimumZoom:p,maximumZoom:h,zoomX:(Z.current?.offsetWidth||0)/2,zoomY:(Z.current?.offsetHeight||0)/2,onZoomClick:V,zoom:D})]})}function u(n){let{zoom:i,padding:o,onZoomClick:r,minimumZoom:c,maximumZoom:u,zoomX:d,zoomY:m}=n;return e("div",{style:{left:5,position:"absolute",right:5+o,top:5},children:t(a,{children:[e(a.Item,{children:e(s,{disabled:i<=c,icon:"minus",onClick:()=>r("decrease",d,m)})}),e(a.Item,{grow:!0,children:t(l,{maxValue:u,minValue:c,value:i,children:[i,"x"]})}),e(a.Item,{children:e(s,{disabled:i>=u,icon:"plus",onClick:()=>r("increase",d,m)})})]})})}export{c as InfinitePlane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{Floating as o}from"./Floating.js";function e(e){let{content:n,children:r,position:i}=e;return t(o,{content:n,
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";import{Floating as o}from"./Floating.js";function e(e){let{content:n,children:r,position:i}=e;return t(o,{content:n,contentClasses:"Tooltip",hoverOpen:!0,placement:i,children:r})}export{e as Tooltip};
|
package/package.json
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
},
|
|
7
7
|
"description": "TGUI core component library",
|
|
8
8
|
"devDependencies": {
|
|
9
|
-
"@biomejs/biome": "^2.0.0
|
|
9
|
+
"@biomejs/biome": "^2.0.0",
|
|
10
10
|
"@rsbuild/core": "^1.3.22",
|
|
11
11
|
"@rsbuild/plugin-react": "^1.3.2",
|
|
12
12
|
"@rsbuild/plugin-sass": "^1.3.2",
|
|
13
|
-
"@rslib/core": "^0.
|
|
14
|
-
"@storybook/addon-docs": "^9.0.
|
|
15
|
-
"@types/bun": "^1.2.
|
|
16
|
-
"@types/react": "^19.1.
|
|
13
|
+
"@rslib/core": "^0.10.0",
|
|
14
|
+
"@storybook/addon-docs": "^9.0.11",
|
|
15
|
+
"@types/bun": "^1.2.16",
|
|
16
|
+
"@types/react": "^19.1.8",
|
|
17
17
|
"@types/react-dom": "^19.1.6",
|
|
18
18
|
"prettier": "^3.5.3",
|
|
19
19
|
"sass": "^1.89.2",
|
|
20
|
-
"storybook": "^9.0.
|
|
20
|
+
"storybook": "^9.0.11",
|
|
21
21
|
"storybook-addon-sass-postcss": "^0.3.2",
|
|
22
22
|
"storybook-react-rsbuild": "^2.0.1",
|
|
23
23
|
"typescript": "^5.8.3"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"license": "MIT",
|
|
53
53
|
"name": "tgui-core",
|
|
54
|
-
"packageManager": "bun@1.2.
|
|
54
|
+
"packageManager": "bun@1.2.16",
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^19.1.0",
|
|
57
57
|
"react-dom": "^19.1.0"
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"test": "bun test"
|
|
70
70
|
},
|
|
71
71
|
"type": "module",
|
|
72
|
-
"version": "4.
|
|
72
|
+
"version": "4.3.1"
|
|
73
73
|
}
|