tgui-core 3.0.0 → 3.0.2
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.
|
@@ -9,6 +9,15 @@ export type BaseInputProps = Partial<{
|
|
|
9
9
|
className: string;
|
|
10
10
|
/** Disables the input. Outlined in gray */
|
|
11
11
|
disabled: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to debounce the onChange event.
|
|
14
|
+
*
|
|
15
|
+
* Do this if it's performing expensive ops on each input, like filtering or
|
|
16
|
+
* sending the value immediate to Byond (via act).
|
|
17
|
+
*
|
|
18
|
+
* It will only fire once every 250ms.
|
|
19
|
+
*/
|
|
20
|
+
expensive: boolean;
|
|
12
21
|
/** Fills the parent container */
|
|
13
22
|
fluid: boolean;
|
|
14
23
|
/** Mark this if you want to use a monospace font */
|
|
@@ -30,7 +39,8 @@ export type TextInputProps = Partial<{
|
|
|
30
39
|
/**
|
|
31
40
|
* Generally, input can handle its own state value.
|
|
32
41
|
*
|
|
33
|
-
* Use this if you want to hold the value in the parent for external
|
|
42
|
+
* Use this if you want to hold the value in the parent for external
|
|
43
|
+
* manipulation.
|
|
34
44
|
*
|
|
35
45
|
* ```tsx
|
|
36
46
|
* const [value, setValue] = useState('');
|
|
@@ -51,16 +61,8 @@ export type TextInputProps = Partial<{
|
|
|
51
61
|
value: string;
|
|
52
62
|
}> & BaseInputProps;
|
|
53
63
|
type Props = Partial<{
|
|
54
|
-
/**
|
|
55
|
-
* Whether to debounce the input.
|
|
56
|
-
* Do this if it's performing expensive ops on each input.
|
|
57
|
-
* It will only fire once every 250ms.
|
|
58
|
-
*/
|
|
59
|
-
expensive: boolean;
|
|
60
64
|
/** Ref of the input element */
|
|
61
65
|
ref: RefObject<HTMLInputElement | null>;
|
|
62
|
-
/** Auto-updates the input value on props change, ie, data from Byond */
|
|
63
|
-
updateOnPropsChange: boolean;
|
|
64
66
|
}> & BaseInputProps & TextInputProps;
|
|
65
67
|
/**
|
|
66
68
|
* ## Input
|
package/dist/components/Input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"react";import*as r from"../common/keys.js";import*as u from"../common/react.js";import*as o from"../common/timer.js";import*as n from"../common/ui.js";let a=(0,o.debounce)(e=>e(),250);function
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"react";import*as r from"../common/keys.js";import*as u from"../common/react.js";import*as o from"../common/timer.js";import*as n from"../common/ui.js";let a=(0,o.debounce)(e=>e(),250);function s(o){let{autoFocus:s,autoSelect:c,className:m,disabled:l,expensive:p,fluid:f,maxLength:i,monospace:v,onChange:d,onEnter:g,onEscape:T,placeholder:j,ref:x,selfClear:E,...b}=o,y=(0,t.useRef)(null),I=x??y,[h,k]=(0,t.useState)(o.value),C=(0,t.useMemo)(()=>(0,n.computeBoxProps)(b),[b]),D=(0,t.useMemo)(()=>(0,u.classes)(["Input",l&&"Input--disabled",f&&"Input--fluid",v&&"Input--monospace",m]),[m,f,v]);return(0,t.useEffect)(()=>{let e;return(s||c)&&(e=setTimeout(()=>{I.current?.focus(),c&&I.current?.select()},1)),()=>clearTimeout(e)},[]),(0,t.useEffect)(()=>{document.activeElement!==I.current&&o.value!==h&&k(o.value??"")},[o.value]),(0,e.jsx)("input",{...C,autoComplete:"off",className:D,disabled:l,maxLength:i,onChange:function(e){let t=e.currentTarget.value;k(t),p?a(()=>d?.(t)):d?.(t)},onKeyDown:function(e){if(e.key===r.KEY.Enter){e.preventDefault(),g?.(e.currentTarget.value),E&&k(""),e.currentTarget.blur();return}(0,r.isEscape)(e.key)&&(e.preventDefault(),T?.(e.currentTarget.value),e.currentTarget.blur())},placeholder:j,ref:I,type:"text",value:h,spellCheck:!1})}export{s as Input};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"../common/math.js";import*as r from"../common/react.js";import*as u from"../common/
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"../common/math.js";import*as r from"../common/react.js";import*as u from"../common/timer.js";import*as n from"../common/ui.js";import*as o from"react";import*as m from"../common/keys.js";let s=(0,u.debounce)(e=>e(),250);function a(u){let{allowFloats:a,autoFocus:c,autoSelect:i,className:l,disabled:f,expensive:p,fluid:d,maxValue:v=1e4,minValue:b=0,monospace:j,onChange:E,onEnter:y,onEscape:I,...k}=u,x=(0,o.useRef)(null),[N,h]=(0,o.useState)(u.value??b),D=(0,o.useMemo)(()=>(0,n.computeBoxProps)(k),[k]),M=(0,o.useMemo)(()=>(0,r.classes)(["Input","RestrictedInput",f&&"Input--disabled",d&&"Input--fluid",j&&"Input--monospace",l]),[l,d,j]);function C(e){if(e===N)return;let r=e;Number.isNaN(e)?r=b:a||(r=Math.round(e)),h(r=(0,t.clamp)(r,b,v)),E&&(p?s(()=>E(r)):E(r))}return(0,o.useEffect)(()=>{let e;return(c||i)&&(e=setTimeout(()=>{x.current?.focus(),i&&x.current?.select()},1)),()=>clearTimeout(e)},[]),(0,o.useEffect)(()=>{document.activeElement!==x.current&&u.value!==N&&h(u.value??b)},[u.value]),(0,e.jsx)("input",{...D,autoComplete:"off",className:M,disabled:f,max:v,min:b,onChange:function(e){C(Number(e.target.value))},onKeyDown:function(e){if(e.key===m.KEY.Enter){e.preventDefault(),y?.(N),x.current?.blur();return}if((0,m.isEscape)(e.key)){e.preventDefault(),I?.(N),x.current?.blur();return}if(e.key===m.KEY.Minus){e.preventDefault(),C(-1*N);return}},ref:x,spellCheck:!1,type:"number",value:N})}export{a as RestrictedInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as t from"
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as t from"../common/timer.js";import*as r from"react";import*as u from"../common/keys.js";import*as n from"../common/react.js";import*as a from"../common/ui.js";let s=(0,t.debounce)(e=>e(),250);function o(t){let{autoFocus:o,autoSelect:c,disabled:l,dontUseTabForIndent:m,expensive:i,fluid:f,maxLength:p,monospace:g,onChange:T,onEnter:v,onEscape:b,placeholder:y,ref:E,selfClear:d,userMarkup:x,...k}=t,$=(0,r.useRef)(null),h=E??$,[j,K]=(0,r.useState)(t.value??""),D=(0,r.useMemo)(()=>(0,a.computeBoxProps)(k),[k]),I=(0,r.useMemo)(()=>(0,n.classes)(["Input","TextArea",f&&"Input--fluid",g&&"Input--monospace",l&&"Input--disabled"]),[l,f,g]);return(0,r.useEffect)(()=>{(o||c)&&setTimeout(()=>{h.current?.focus(),c&&h.current?.select()},1)},[]),(0,r.useEffect)(()=>{document.activeElement!==h.current&&t.value!==j&&K(t.value??"")},[t.value]),(0,e.jsx)("textarea",{...D,autoComplete:"off",className:I,maxLength:p,onChange:function(e){let t=e.currentTarget.value;K(t),T&&(i?s(()=>T(t)):T(t))},onKeyDown:function(e){if(e.key===u.KEY.Enter&&!e.shiftKey){e.preventDefault(),v?.(e.currentTarget.value),d&&K(""),e.currentTarget.blur();return}if((0,u.isEscape)(e.key)){b?.(e.currentTarget.value),e.currentTarget.blur();return}if(!m&&e.key===u.KEY.Tab){e.preventDefault();let{value:t,selectionStart:r,selectionEnd:u}=e.currentTarget;K(`${t.substring(0,r)} ${t.substring(u)}`),e.currentTarget.selectionEnd=r+1,T?.(e.currentTarget.value);return}if(x&&(e.ctrlKey||e.metaKey)&&x[e.key]){e.preventDefault();let{selectionStart:t,selectionEnd:r,value:u}=e.currentTarget,n=x[e.key];K(`${u.substring(0,t)}${n}${u.substring(t,r)}${n}${u.substring(r)}`),e.currentTarget.selectionEnd=r+2*n.length,T?.(e.currentTarget.value);return}},placeholder:y,ref:h,spellCheck:!1,value:j})}export{o as TextArea};
|
package/package.json
CHANGED
|
@@ -137,9 +137,9 @@
|
|
|
137
137
|
--progress-bar-transition: var(--transition-time-slowest);
|
|
138
138
|
|
|
139
139
|
/* Restricted Input */
|
|
140
|
-
--restricted-input-border-color: var(--color-
|
|
140
|
+
--restricted-input-border-color: var(--color-good);
|
|
141
141
|
--restricted-input-border-color-focus: hsl(
|
|
142
|
-
from var(--color-
|
|
142
|
+
from var(--color-good) h s calc(l + 10)
|
|
143
143
|
);
|
|
144
144
|
|
|
145
145
|
/* Round Gauge */
|