tgui-core 3.3.1 → 4.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.
- package/README.md +5 -2
- package/dist/common/collections.d.ts +0 -7
- package/dist/common/collections.js +1 -1
- package/dist/common/constants.d.ts +2 -2
- package/dist/common/constants.js +1 -1
- package/dist/common/events.d.ts +1 -2
- package/dist/common/format.d.ts +0 -1
- package/dist/common/format.js +1 -1
- package/dist/common/fp.d.ts +2 -3
- package/dist/common/hotkeys.d.ts +6 -1
- package/dist/common/hotkeys.js +1 -1
- package/dist/common/http.d.ts +1 -3
- package/dist/common/react.d.ts +2 -9
- package/dist/common/react.js +1 -1
- package/dist/common/type-utils.js +1 -1
- package/dist/common/ui.d.ts +4 -4
- package/dist/components/Autofocus.d.ts +1 -1
- package/dist/components/Blink.d.ts +1 -1
- package/dist/components/Box.d.ts +10 -6
- package/dist/components/ByondUi.d.ts +6 -0
- package/dist/components/ByondUi.js +1 -1
- package/dist/components/Popper.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,12 @@ A collection of utilities and components for the [tgui](https://github.com/tgsta
|
|
|
4
4
|
|
|
5
5
|
This package was built to help the various downstream SS13 servers stay up to date with TGUI without having to keep a local version of each file.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Links
|
|
8
|
+
- [GitHub](https://github.com/tgstation/tgui-core)
|
|
9
|
+
- [npm](https://www.npmjs.com/package/tgui-core)
|
|
10
|
+
- [Storybook](https://tgstation.github.io/tgui-core/?path=/docs/components-animatednumber--docs)
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## Usage
|
|
10
13
|
|
|
11
14
|
(assuming you have a tgui folder, navigate to the specific package)
|
|
12
15
|
|
|
@@ -7,11 +7,4 @@ type Zip<T extends unknown[][]> = {
|
|
|
7
7
|
* the second elements of the given arrays, and so on.
|
|
8
8
|
*/
|
|
9
9
|
export declare function zip<T extends unknown[][]>(...arr: T): Zip<T>;
|
|
10
|
-
/**
|
|
11
|
-
* Helper function for string compares with native sorts
|
|
12
|
-
* @param a first string to compare
|
|
13
|
-
* @param b second string to compare
|
|
14
|
-
* @returns -1 for a < b, 1 for a > b and 0 otherwise
|
|
15
|
-
*/
|
|
16
|
-
export declare function stringCompare(a: string, b: string): 1 | -1 | 0;
|
|
17
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(...p){return Array(Math.max(...p.map(a=>a.length))).fill(void 0).map((a,r)=>p.map(a=>a[r]))}export{a as zip};
|
|
@@ -97,8 +97,8 @@ export declare const RADIO_CHANNELS: readonly [{
|
|
|
97
97
|
}];
|
|
98
98
|
export declare function getGasLabel(gasId: string, fallbackValue?: string): string;
|
|
99
99
|
export declare function getGasColor(gasId: string): string;
|
|
100
|
-
export declare
|
|
101
|
-
export declare
|
|
100
|
+
export declare function getGasFromId(gasId: string): Gas | undefined;
|
|
101
|
+
export declare function getGasFromPath(gasPath: string): Gas | undefined;
|
|
102
102
|
export declare const COMPONENT_COLORS: {
|
|
103
103
|
readonly spectrum: readonly ["red", "orange", "yellow", "olive", "green", "teal", "blue", "violet", "purple", "pink", "brown", "grey", "gold"];
|
|
104
104
|
readonly states: readonly ["", "good", "average", "bad", "black", "white"];
|
package/dist/common/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=2,a=1,o=0,r=-1,l={damageType:{brute:"#e74c3c",burn:"#e67e22",oxy:"#3498db",toxin:"#2ecc71"},department:{captain:"#c06616",cargo:"#f39c12",centcom:"#00c100",engineering:"#f1c40f",medbay:"#3498db",other:"#c38312",science:"#9b59b6",security:"#e74c3c",service:"#7cc46a"},reagent:{acidicbuffer:"#fbc314",basicbuffer:"#3853a4"}},t=["average","bad","black","blue","brown","good","green","grey","label","olive","orange","pink","purple","red","teal","transparent","violet","white","yellow"],i=[{color:"#8f4a4b",freq:1213,name:"Syndicate"},{color:"#ff4444",freq:1215,name:"Red Team"},{color:"#3434fd",freq:1217,name:"Blue Team"},{color:"#34fd34",freq:1219,name:"Green Team"},{color:"#fdfd34",freq:1221,name:"Yellow Team"},{color:"#2681a5",freq:1337,name:"CentCom"},{color:"#b88646",freq:1347,name:"Supply"},{color:"#6ca729",freq:1349,name:"Service"},{color:"#c68cfa",freq:1351,name:"Science"},{color:"#fcdf03",freq:1353,name:"Command"},{color:"#57b8f0",freq:1355,name:"Medical"},{color:"#f37746",freq:1357,name:"Engineering"},{color:"#dd3535",freq:1359,name:"Security"},{color:"#d65d95",freq:1447,name:"AI Private"},{color:"#1ecc43",freq:1459,name:"Common"}],n=[{color:"blue",id:"o2",label:"O₂",name:"Oxygen",path:"/datum/gas/oxygen"},{color:"yellow",id:"n2",label:"N₂",name:"Nitrogen",path:"/datum/gas/nitrogen"},{color:"grey",id:"co2",label:"CO₂",name:"Carbon Dioxide",path:"/datum/gas/carbon_dioxide"},{color:"pink",id:"plasma",label:"Plasma",name:"Plasma",path:"/datum/gas/plasma"},{color:"lightsteelblue",id:"water_vapor",label:"H₂O",name:"Water Vapor",path:"/datum/gas/water_vapor"},{color:"teal",id:"hypernoblium",label:"Hyper-nob",name:"Hyper-noblium",path:"/datum/gas/hypernoblium"},{color:"bisque",id:"n2o",label:"N₂O",name:"Nitrous Oxide",path:"/datum/gas/nitrous_oxide"},{color:"brown",id:"no2",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"},{color:"limegreen",id:"tritium",label:"Tritium",name:"Tritium",path:"/datum/gas/tritium"},{color:"mediumpurple",id:"bz",label:"BZ",name:"BZ",path:"/datum/gas/bz"},{color:"mediumslateblue",id:"pluoxium",label:"Pluoxium",name:"Pluoxium",path:"/datum/gas/pluoxium"},{color:"olive",id:"miasma",label:"Miasma",name:"Miasma",path:"/datum/gas/miasma"},{color:"paleturquoise",id:"freon",label:"Freon",name:"Freon",path:"/datum/gas/freon"},{color:"white",id:"hydrogen",label:"H₂",name:"Hydrogen",path:"/datum/gas/hydrogen"},{color:"salmon",id:"healium",label:"Healium",name:"Healium",path:"/datum/gas/healium"},{color:"greenyellow",id:"proto_nitrate",label:"Proto-Nitrate",name:"Proto Nitrate",path:"/datum/gas/proto_nitrate"},{color:"darkgreen",id:"zauker",label:"Zauker",name:"Zauker",path:"/datum/gas/zauker"},{color:"purple",id:"halon",label:"Halon",name:"Halon",path:"/datum/gas/halon"},{color:"aliceblue",id:"helium",label:"He",name:"Helium",path:"/datum/gas/helium"},{color:"maroon",id:"antinoblium",label:"Anti-Noblium",name:"Antinoblium",path:"/datum/gas/antinoblium"},{color:"brown",id:"nitrium",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"}];function m(e,a){if(!e)return a||"None";let o=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===o)return n[e].label;return a||"None"}function u(e){if(!e)return"black";let a=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===a)return n[e].color;return"black"}
|
|
1
|
+
let e=2,a=1,o=0,r=-1,l={damageType:{brute:"#e74c3c",burn:"#e67e22",oxy:"#3498db",toxin:"#2ecc71"},department:{captain:"#c06616",cargo:"#f39c12",centcom:"#00c100",engineering:"#f1c40f",medbay:"#3498db",other:"#c38312",science:"#9b59b6",security:"#e74c3c",service:"#7cc46a"},reagent:{acidicbuffer:"#fbc314",basicbuffer:"#3853a4"}},t=["average","bad","black","blue","brown","good","green","grey","label","olive","orange","pink","purple","red","teal","transparent","violet","white","yellow"],i=[{color:"#8f4a4b",freq:1213,name:"Syndicate"},{color:"#ff4444",freq:1215,name:"Red Team"},{color:"#3434fd",freq:1217,name:"Blue Team"},{color:"#34fd34",freq:1219,name:"Green Team"},{color:"#fdfd34",freq:1221,name:"Yellow Team"},{color:"#2681a5",freq:1337,name:"CentCom"},{color:"#b88646",freq:1347,name:"Supply"},{color:"#6ca729",freq:1349,name:"Service"},{color:"#c68cfa",freq:1351,name:"Science"},{color:"#fcdf03",freq:1353,name:"Command"},{color:"#57b8f0",freq:1355,name:"Medical"},{color:"#f37746",freq:1357,name:"Engineering"},{color:"#dd3535",freq:1359,name:"Security"},{color:"#d65d95",freq:1447,name:"AI Private"},{color:"#1ecc43",freq:1459,name:"Common"}],n=[{color:"blue",id:"o2",label:"O₂",name:"Oxygen",path:"/datum/gas/oxygen"},{color:"yellow",id:"n2",label:"N₂",name:"Nitrogen",path:"/datum/gas/nitrogen"},{color:"grey",id:"co2",label:"CO₂",name:"Carbon Dioxide",path:"/datum/gas/carbon_dioxide"},{color:"pink",id:"plasma",label:"Plasma",name:"Plasma",path:"/datum/gas/plasma"},{color:"lightsteelblue",id:"water_vapor",label:"H₂O",name:"Water Vapor",path:"/datum/gas/water_vapor"},{color:"teal",id:"hypernoblium",label:"Hyper-nob",name:"Hyper-noblium",path:"/datum/gas/hypernoblium"},{color:"bisque",id:"n2o",label:"N₂O",name:"Nitrous Oxide",path:"/datum/gas/nitrous_oxide"},{color:"brown",id:"no2",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"},{color:"limegreen",id:"tritium",label:"Tritium",name:"Tritium",path:"/datum/gas/tritium"},{color:"mediumpurple",id:"bz",label:"BZ",name:"BZ",path:"/datum/gas/bz"},{color:"mediumslateblue",id:"pluoxium",label:"Pluoxium",name:"Pluoxium",path:"/datum/gas/pluoxium"},{color:"olive",id:"miasma",label:"Miasma",name:"Miasma",path:"/datum/gas/miasma"},{color:"paleturquoise",id:"freon",label:"Freon",name:"Freon",path:"/datum/gas/freon"},{color:"white",id:"hydrogen",label:"H₂",name:"Hydrogen",path:"/datum/gas/hydrogen"},{color:"salmon",id:"healium",label:"Healium",name:"Healium",path:"/datum/gas/healium"},{color:"greenyellow",id:"proto_nitrate",label:"Proto-Nitrate",name:"Proto Nitrate",path:"/datum/gas/proto_nitrate"},{color:"darkgreen",id:"zauker",label:"Zauker",name:"Zauker",path:"/datum/gas/zauker"},{color:"purple",id:"halon",label:"Halon",name:"Halon",path:"/datum/gas/halon"},{color:"aliceblue",id:"helium",label:"He",name:"Helium",path:"/datum/gas/helium"},{color:"maroon",id:"antinoblium",label:"Anti-Noblium",name:"Antinoblium",path:"/datum/gas/antinoblium"},{color:"brown",id:"nitrium",label:"Nitrium",name:"Nitrium",path:"/datum/gas/nitrium"}];function m(e,a){if(!e)return a||"None";let o=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===o)return n[e].label;return a||"None"}function u(e){if(!e)return"black";let a=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===a)return n[e].color;return"black"}function c(e){if(!e)return;let a=e.toLowerCase();for(let e=0;e<n.length;e++)if(n[e].id===a)return n[e]}function d(e){if(e){for(let a=0;a<n.length;a++)if(n[a].path===e)return n[a]}}let b={spectrum:["red","orange","yellow","olive","green","teal","blue","violet","purple","pink","brown","grey","gold"],states:["","good","average","bad","black","white"]};export{l as COLORS,b as COMPONENT_COLORS,t as CSS_COLORS,i as RADIO_CHANNELS,r as UI_CLOSE,o as UI_DISABLED,e as UI_INTERACTIVE,a as UI_UPDATE,u as getGasColor,c as getGasFromId,d as getGasFromPath,m as getGasLabel};
|
package/dist/common/events.d.ts
CHANGED
package/dist/common/format.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export declare function formatSiUnit(value: number, minBase1000?: number, unit?:
|
|
|
2
2
|
export declare function formatPower(value: number, minBase1000?: number): string;
|
|
3
3
|
export declare function formatEnergy(value: number, minBase1000?: number): string;
|
|
4
4
|
export declare function formatMoney(value: number, precision?: number): string;
|
|
5
|
-
export declare function formatDb(value: number): string;
|
|
6
5
|
export declare function formatSiBaseTenUnit(value: number, minBase1000?: number, unit?: string): string;
|
|
7
6
|
/**
|
|
8
7
|
* Formats decisecond count into HH:MM:SS display by default
|
package/dist/common/format.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let t=["f","p","n","μ","m"," ","k","M","G","T","P","E","Z","Y","R","Q","F","N","H"],r=t.indexOf(" ");function e(n
|
|
1
|
+
let t=["f","p","n","μ","m"," ","k","M","G","T","P","E","Z","Y","R","Q","F","N","H"],r=t.indexOf(" ");function e(i,n=-r,o=""){if(!Number.isFinite(i))return i.toString();let a=Math.floor(Math.max(3*n,Math.floor(Math.log10(Math.abs(i))))/3),f=t[Math.min(a+r,t.length-1)],l=(i/1e3**a).toFixed(2);return l.endsWith(".00")?l=l.slice(0,-3):l.endsWith(".0")&&(l=l.slice(0,-2)),`${l} ${f.trim()}${o}`.trim()}function i(t,r=0){return e(t,r,"W")}function n(t,r=0){return e(t,r,"J")}function o(t,r=0){if(!Number.isFinite(t))return String(t);let e=Number(t.toFixed(r)),i=Math.abs(e).toString().split(".");i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g," ");let n=i.join(".");return e<0?`-${n}`:n}let a=["","\xb7 10\xb3","\xb7 10⁶","\xb7 10⁹","\xb7 10\xb9\xb2","\xb7 10\xb9⁵","\xb7 10\xb9⁸","\xb7 10\xb2\xb9","\xb7 10\xb2⁴","\xb7 10\xb2⁷","\xb7 10\xb3⁰","\xb7 10\xb3\xb3","\xb7 10\xb3⁶","\xb7 10\xb3⁹"];function f(t,r=0,e=""){if(!Number.isFinite(t))return"NaN";let i=Math.max(3*r,Math.floor(Math.log10(t))),n=Math.floor(i/3),o=a[n],l=Math.max(0,2-i%3),u=(t/1e3**n).toFixed(l);return`${u} ${o} ${e}`.trim()}function l(t,r="default"){let e=Math.floor(t/10),i=Math.floor(e/3600),n=Math.floor(e%3600/60),o=e%60;if("short"===r){let t=i>0?`${i}h`:"",r=n>0?`${n}m`:"",e=o>0?`${o}s`:"";return`${t}${r}${e}`}let a=String(i).padStart(2,"0"),f=String(n).padStart(2,"0"),u=String(o).padStart(2,"0");return`${a}:${f}:${u}`}export{n as formatEnergy,o as formatMoney,i as formatPower,f as formatSiBaseTenUnit,e as formatSiUnit,l as formatTime};
|
package/dist/common/fp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { Fn } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a function that returns the result of invoking the given
|
|
4
4
|
* functions, where each successive invocation is supplied the return
|
|
@@ -15,5 +15,4 @@ type Func = (...args: any[]) => any;
|
|
|
15
15
|
* const composedFunction2 = flow([add2, multiplyBy3], subtract5); // ((4 + 2) * 3) - 5 = 13
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export declare const flow: (...funcs: Array<
|
|
19
|
-
export {};
|
|
18
|
+
export declare const flow: (...funcs: Array<Fn | Fn[]>) => (input: any, ...rest: any[]) => any;
|
package/dist/common/hotkeys.d.ts
CHANGED
|
@@ -9,7 +9,12 @@ export declare function acquireHotKey(keyCode: number): void;
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function releaseHotKey(keyCode: number): void;
|
|
11
11
|
export declare function releaseHeldKeys(): void;
|
|
12
|
-
export
|
|
12
|
+
export type KeyPassthroughConfig = {
|
|
13
|
+
keyUpVerb: string;
|
|
14
|
+
keyDownVerb: string;
|
|
15
|
+
verbParamsFn: (verb: string, keyCode: string) => string;
|
|
16
|
+
};
|
|
17
|
+
export declare function setupHotKeys(config?: KeyPassthroughConfig): void;
|
|
13
18
|
export declare function startKeyPassthrough(): void;
|
|
14
19
|
export declare function stopKeyPassthrough(): void;
|
|
15
20
|
/**
|
package/dist/common/hotkeys.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"./events.js";import*as t from"./keycodes.js";let
|
|
1
|
+
import*as e from"./events.js";import*as t from"./keycodes.js";let n={},o=[t.KEY_ESCAPE,t.KEY_ENTER,t.KEY_SPACE,t.KEY_TAB,t.KEY_CTRL,t.KEY_SHIFT,t.KEY_UP,t.KEY_DOWN,t.KEY_LEFT,t.KEY_RIGHT,t.KEY_F5],r={},l=[];function s(e){o.push(e)}function i(e){let t=o.indexOf(e);t>=0&&o.splice(t,1)}function a(){for(let e in r)r[e]&&(r[e]=!1,Byond.command(f.verbParamsFn(f.keyUpVerb,e)))}let f={keyDownVerb:"KeyDown",keyUpVerb:"KeyUp",verbParamsFn:(e,t)=>`${e} "${t}"`};function u(t){t&&(f=t),Byond.winget("default.*").then(e=>{let t={};for(let n in e){let o=n.split("."),r=o[1],l=o[2];r&&l&&(t[r]||(t[r]={}),t[r][l]=e[n])}let o=/\\"/g;function r(e){return e.substring(1,e.length-1).replace(o,'"')}for(let e in t){let o=t[e];n[r(o.name)]=r(o.command)}}),e.globalEvents.on("window-blur",()=>{a()}),d()}function d(){e.globalEvents.on("key",y)}function c(){e.globalEvents.off("key",y)}function y(e){for(let t of l)t(e);!function(e){var t;let l=String(e);if("Ctrl+F5"===l||"Ctrl+R"===l)return location.reload();if("Ctrl+F"===l||e.event.defaultPrevented||e.isModifierKey()||o.includes(e.code))return;let s=16===(t=e.code)?"Shift":17===t?"Ctrl":18===t?"Alt":33===t?"Northeast":34===t?"Southeast":35===t?"Southwest":36===t?"Northwest":37===t?"West":38===t?"North":39===t?"East":40===t?"South":45===t?"Insert":46===t?"Delete":t>=48&&t<=57||t>=65&&t<=90?String.fromCharCode(t):t>=96&&t<=105?`Numpad${t-96}`:t>=112&&t<=123?`F${t-111}`:188===t?",":189===t?"-":190===t?".":void 0;if(!s)return;let i=n[s];if(i)return Byond.command(i);if(e.isDown()&&!r[s]){r[s]=!0;let e=f.verbParamsFn(f.keyDownVerb,s);return Byond.command(e)}if(e.isUp()&&r[s]){r[s]=!1;let e=f.verbParamsFn(f.keyUpVerb,s);Byond.command(e)}}(e)}function E(e){l.push(e);let t=!1;return()=>{t||(t=!0,l.splice(l.indexOf(e),1))}}export{s as acquireHotKey,E as listenForKeyEvents,a as releaseHeldKeys,i as releaseHotKey,u as setupHotKeys,d as startKeyPassthrough,c as stopKeyPassthrough};
|
package/dist/common/http.d.ts
CHANGED
package/dist/common/react.d.ts
CHANGED
|
@@ -2,22 +2,15 @@
|
|
|
2
2
|
* Helper for conditionally adding/removing classes in React
|
|
3
3
|
*/
|
|
4
4
|
export declare function classes(classNames: (string | BooleanLike)[]): string;
|
|
5
|
-
/**
|
|
6
|
-
* Normalizes children prop, so that it is always an array of VDom
|
|
7
|
-
* elements.
|
|
8
|
-
*/
|
|
9
|
-
export declare function normalizeChildren<T>(children: T | T[]): T[];
|
|
10
5
|
/**
|
|
11
6
|
* Shallowly checks if two objects are different.
|
|
12
7
|
* Credit: https://github.com/developit/preact-compat
|
|
13
8
|
*/
|
|
14
9
|
export declare function shallowDiffers(a: Record<string, any>, b: Record<string, any>): boolean;
|
|
15
10
|
/**
|
|
16
|
-
* A common case in tgui
|
|
11
|
+
* A common case in tgui when you pass a value conditionally. These are
|
|
17
12
|
* the types that can fall through the condition.
|
|
18
13
|
*/
|
|
19
14
|
export type BooleanLike = number | boolean | null | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* A helper to determine whether the object is renderable by React.
|
|
22
|
-
*/
|
|
15
|
+
/** A helper to determine whether the object is renderable by React. */
|
|
23
16
|
export declare function canRender(value: unknown): boolean;
|
package/dist/common/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function n(n){let e="";for(let r=0;r<n.length;r++){let t=n[r];"string"==typeof t&&(e+=`${t} `)}return e}function e(n,e){let r;for(r in n)if(!(r in e))return!0;for(r in e)if(n[r]!==e[r])return!0;return!1}function r(n){return null!=n&&"boolean"!=typeof n}export{r as canRender,n as classes,e as shallowDiffers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){let t={};for(let
|
|
1
|
+
function e(e){let t={};for(let r in e)if(Array.isArray(e[r])){let n=e[r];if(e[r].length>0){t[r]=n[0];continue}t[r]="emptyarray"}else if("object"==typeof e[r]&&null!==e[r])t[r]="Record<string, sometype>";else if("number"==typeof e[r]){let n=Number(e[r]);if(1===n||0===n){t[r]=`${n}, BooleanLike?`;continue}t[r]=e[r]}return t}export{e as getShallowTypes};
|
package/dist/common/ui.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const unit: UnitMapper;
|
|
|
9
9
|
* Same as `unit`, but half the size for integers numbers.
|
|
10
10
|
*/
|
|
11
11
|
export declare const halfUnit: UnitMapper;
|
|
12
|
-
export type StringStyleMap = {
|
|
12
|
+
export type StringStyleMap = Partial<{
|
|
13
13
|
/** Align text inside the box. */
|
|
14
14
|
align: string | BooleanLike;
|
|
15
15
|
/** A direct mapping to `position` CSS property. */
|
|
@@ -94,9 +94,9 @@ export type StringStyleMap = {
|
|
|
94
94
|
lineHeight: string | BooleanLike;
|
|
95
95
|
/** Align text inside the box. */
|
|
96
96
|
textAlign: string | BooleanLike;
|
|
97
|
-
}
|
|
97
|
+
}>;
|
|
98
98
|
export declare const stringStyleMap: Record<keyof StringStyleMap, any>;
|
|
99
|
-
export type BooleanStyleMap = {
|
|
99
|
+
export type BooleanStyleMap = Partial<{
|
|
100
100
|
/** Make text bold. */
|
|
101
101
|
bold: boolean;
|
|
102
102
|
/** Fill positioned parent. */
|
|
@@ -109,7 +109,7 @@ export type BooleanStyleMap = {
|
|
|
109
109
|
nowrap: boolean;
|
|
110
110
|
/** Preserves line-breaks and spacing in text. */
|
|
111
111
|
preserveWhitespace: boolean;
|
|
112
|
-
}
|
|
112
|
+
}>;
|
|
113
113
|
export declare const booleanStyleMap: Record<keyof BooleanStyleMap, any>;
|
|
114
114
|
export declare function computeBoxProps(props: any): Record<string, any>;
|
|
115
115
|
export declare function computeBoxClassName<TElement = HTMLDivElement>(props: BoxProps<TElement>): string;
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type KeyboardEventHandler, type MouseEventHandler, type ReactNode, type UIEventHandler } from 'react';
|
|
2
2
|
import type { BooleanLike } from '../common/react';
|
|
3
3
|
import { type BooleanStyleMap, type StringStyleMap } from '../common/ui';
|
|
4
|
-
type EventHandlers<TElement = HTMLDivElement> = {
|
|
4
|
+
type EventHandlers<TElement = HTMLDivElement> = Partial<{
|
|
5
5
|
onClick: MouseEventHandler<TElement>;
|
|
6
6
|
onContextMenu: MouseEventHandler<TElement>;
|
|
7
7
|
onDoubleClick: MouseEventHandler<TElement>;
|
|
@@ -13,9 +13,12 @@ type EventHandlers<TElement = HTMLDivElement> = {
|
|
|
13
13
|
onMouseOver: MouseEventHandler<TElement>;
|
|
14
14
|
onMouseUp: MouseEventHandler<TElement>;
|
|
15
15
|
onScroll: UIEventHandler<TElement>;
|
|
16
|
-
}
|
|
17
|
-
type InternalProps = {
|
|
18
|
-
/**
|
|
16
|
+
}>;
|
|
17
|
+
type InternalProps = Partial<{
|
|
18
|
+
/**
|
|
19
|
+
* The component used for the root node.
|
|
20
|
+
* @default <div>
|
|
21
|
+
*/
|
|
19
22
|
as: string;
|
|
20
23
|
/** The content of the component. */
|
|
21
24
|
children: ReactNode;
|
|
@@ -48,8 +51,9 @@ type InternalProps = {
|
|
|
48
51
|
* 3. This should be a static string with minimal interpolation. If you need more logic, prefer the props approach.
|
|
49
52
|
*/
|
|
50
53
|
tw: string;
|
|
51
|
-
}
|
|
52
|
-
export
|
|
54
|
+
}>;
|
|
55
|
+
export interface BoxProps<TElement = HTMLDivElement> extends InternalProps, BooleanStyleMap, StringStyleMap, EventHandlers<TElement> {
|
|
56
|
+
}
|
|
53
57
|
type DangerDoNotUse = {
|
|
54
58
|
dangerouslySetInnerHTML?: {
|
|
55
59
|
__html: any;
|
|
@@ -16,6 +16,12 @@ type Props = Partial<{
|
|
|
16
16
|
* You can find a full reference of these parameters
|
|
17
17
|
* in [BYOND controls and parameters guide](https://secure.byond.com/docs/ref/skinparams.html). */
|
|
18
18
|
params: SampleByondParams & Record<string, any>;
|
|
19
|
+
/**
|
|
20
|
+
* If this ByondUi element should tell DreamMaker that it has been created or not.
|
|
21
|
+
*
|
|
22
|
+
* Defaults to on.
|
|
23
|
+
*/
|
|
24
|
+
phonehome: boolean;
|
|
19
25
|
}> & BoxProps;
|
|
20
26
|
/**
|
|
21
27
|
* ## ByondUi
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import*as
|
|
1
|
+
import*as e from"react/jsx-runtime";import*as n from"react";import*as t from"../common/timer.js";import*as o from"../common/ui.js";let r=[];function i(i){let{params:s,phonehome:d,...u}=i,l=(0,n.useRef)(null),m=(0,n.useRef)(function(e,n=!0){let t=r.length;r.push(null);let o=e||`byondui_${t}`;return{render:e=>{n&&Byond.sendMessage("renderByondUi",{renderByondUi:o}),r[t]=o,Byond.winset(o,e)},unmount:()=>{n&&Byond.sendMessage("unmountByondUi",{renderByondUi:o}),r[t]=null,Byond.winset(o,{parent:""})}}}(s?.id,d));function f(){let e=l.current;if(!e)return;let n=function(e){let n=window.devicePixelRatio??1,t=e.getBoundingClientRect();return{pos:[t.left*n,t.top*n],size:[(t.right-t.left)*n,(t.bottom-t.top)*n]}}(e);m.current.render({parent:Byond.windowId,...s,pos:`${n.pos[0]},${n.pos[1]}`,size:`${n.size[0]}x${n.size[1]}`})}let p=(0,t.debounce)(()=>{f()},100);return(0,n.useEffect)(()=>(window.addEventListener("resize",p),f(),()=>{window.removeEventListener("resize",p),m.current.unmount()}),[]),(0,e.jsx)("div",{ref:l,...(0,o.computeBoxProps)(u),children:(0,e.jsx)("div",{style:{minHeight:"22px"}})})}window.addEventListener("beforeunload",()=>{for(let e=0;e<r.length;e++){let n=r[e];"string"==typeof n&&(r[e]=null,Byond.winset(n,{parent:""}))}});export{i as ByondUi};
|
package/package.json
CHANGED