tgui-core 5.5.2 → 5.5.9
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/package.json +2 -1
- package/dist/common/collections.d.ts +0 -10
- package/dist/common/collections.js +0 -1
- package/dist/common/color.d.ts +0 -76
- package/dist/common/color.js +0 -1
- package/dist/common/constants.d.ts +0 -106
- package/dist/common/constants.js +0 -1
- package/dist/common/eventbus.d.ts +0 -68
- package/dist/common/eventbus.js +0 -1
- package/dist/common/events.d.ts +0 -32
- package/dist/common/events.js +0 -1
- package/dist/common/exhaustive.d.ts +0 -17
- package/dist/common/exhaustive.js +0 -1
- package/dist/common/format.d.ts +0 -10
- package/dist/common/format.js +0 -1
- package/dist/common/fp.d.ts +0 -18
- package/dist/common/fp.js +0 -1
- package/dist/common/fuzzysearch.d.ts +0 -26
- package/dist/common/fuzzysearch.js +0 -1
- package/dist/common/hotkeys.d.ts +0 -31
- package/dist/common/hotkeys.js +0 -1
- package/dist/common/http.d.ts +0 -2
- package/dist/common/http.js +0 -1
- package/dist/common/keycodes.d.ts +0 -95
- package/dist/common/keycodes.js +0 -1
- package/dist/common/keys.d.ts +0 -118
- package/dist/common/keys.js +0 -1
- package/dist/common/math.d.ts +0 -47
- package/dist/common/math.js +0 -1
- package/dist/common/random.d.ts +0 -16
- package/dist/common/random.js +0 -1
- package/dist/common/react.d.ts +0 -16
- package/dist/common/react.js +0 -1
- package/dist/common/string.d.ts +0 -87
- package/dist/common/string.js +0 -1
- package/dist/common/timer.d.ts +0 -18
- package/dist/common/timer.js +0 -1
- package/dist/common/type-utils.d.ts +0 -10
- package/dist/common/type-utils.js +0 -1
- package/dist/common/ui.d.ts +0 -123
- package/dist/common/ui.js +0 -1
- package/dist/common/uuid.d.ts +0 -10
- package/dist/common/uuid.js +0 -1
- package/dist/common/vector.d.ts +0 -18
- package/dist/common/vector.js +0 -1
- package/dist/components/AnimatedNumber.d.ts +0 -24
- package/dist/components/AnimatedNumber.js +0 -1
- package/dist/components/Autofocus.d.ts +0 -12
- package/dist/components/Autofocus.js +0 -1
- package/dist/components/Blink.d.ts +0 -19
- package/dist/components/Blink.js +0 -1
- package/dist/components/BlockQuote.d.ts +0 -11
- package/dist/components/BlockQuote.js +0 -1
- package/dist/components/Box.d.ts +0 -104
- package/dist/components/Box.js +0 -1
- package/dist/components/Button.d.ts +0 -123
- package/dist/components/Button.js +0 -1
- package/dist/components/ByondUi.d.ts +0 -61
- package/dist/components/ByondUi.js +0 -1
- package/dist/components/Chart.d.ts +0 -24
- package/dist/components/Chart.js +0 -1
- package/dist/components/Collapsible.d.ts +0 -28
- package/dist/components/Collapsible.js +0 -1
- package/dist/components/ColorBox.d.ts +0 -19
- package/dist/components/ColorBox.js +0 -1
- package/dist/components/Dialog.d.ts +0 -39
- package/dist/components/Dialog.js +0 -1
- package/dist/components/Dimmer.d.ts +0 -11
- package/dist/components/Dimmer.js +0 -1
- package/dist/components/Divider.d.ts +0 -17
- package/dist/components/Divider.js +0 -1
- package/dist/components/DmIcon.d.ts +0 -35
- package/dist/components/DmIcon.js +0 -1
- package/dist/components/DraggableControl.d.ts +0 -57
- package/dist/components/DraggableControl.js +0 -1
- package/dist/components/Dropdown.d.ts +0 -60
- package/dist/components/Dropdown.js +0 -1
- package/dist/components/FitText.d.ts +0 -21
- package/dist/components/FitText.js +0 -1
- package/dist/components/Flex.d.ts +0 -130
- package/dist/components/Flex.js +0 -1
- package/dist/components/Floating.d.ts +0 -87
- package/dist/components/Floating.js +0 -1
- package/dist/components/Icon.d.ts +0 -53
- package/dist/components/Icon.js +0 -1
- package/dist/components/Image.d.ts +0 -30
- package/dist/components/Image.js +0 -1
- package/dist/components/ImageButton.d.ts +0 -90
- package/dist/components/ImageButton.js +0 -1
- package/dist/components/InfinitePlane.d.ts +0 -64
- package/dist/components/InfinitePlane.js +0 -1
- package/dist/components/Input.d.ts +0 -98
- package/dist/components/Input.js +0 -1
- package/dist/components/Interactive.d.ts +0 -39
- package/dist/components/Interactive.js +0 -1
- package/dist/components/KeyListener.d.ts +0 -16
- package/dist/components/KeyListener.js +0 -1
- package/dist/components/Knob.d.ts +0 -65
- package/dist/components/Knob.js +0 -1
- package/dist/components/LabeledControls.d.ts +0 -31
- package/dist/components/LabeledControls.js +0 -1
- package/dist/components/LabeledList.d.ts +0 -95
- package/dist/components/LabeledList.js +0 -1
- package/dist/components/MenuBar.d.ts +0 -42
- package/dist/components/MenuBar.js +0 -1
- package/dist/components/Modal.d.ts +0 -21
- package/dist/components/Modal.js +0 -1
- package/dist/components/NoticeBox.d.ts +0 -27
- package/dist/components/NoticeBox.js +0 -1
- package/dist/components/NumberInput.d.ts +0 -60
- package/dist/components/NumberInput.js +0 -1
- package/dist/components/Pointer.d.ts +0 -20
- package/dist/components/Pointer.js +0 -1
- package/dist/components/Popper.d.ts +0 -33
- package/dist/components/Popper.js +0 -1
- package/dist/components/ProgressBar.d.ts +0 -57
- package/dist/components/ProgressBar.js +0 -1
- package/dist/components/RestrictedInput.d.ts +0 -72
- package/dist/components/RestrictedInput.js +0 -1
- package/dist/components/RoundGauge.d.ts +0 -57
- package/dist/components/RoundGauge.js +0 -1
- package/dist/components/Section.d.ts +0 -65
- package/dist/components/Section.js +0 -1
- package/dist/components/Slider.d.ts +0 -61
- package/dist/components/Slider.js +0 -1
- package/dist/components/Stack.d.ts +0 -83
- package/dist/components/Stack.js +0 -1
- package/dist/components/StyleableSection.d.ts +0 -10
- package/dist/components/StyleableSection.js +0 -1
- package/dist/components/Table.d.ts +0 -59
- package/dist/components/Table.js +0 -1
- package/dist/components/Tabs.d.ts +0 -110
- package/dist/components/Tabs.js +0 -1
- package/dist/components/TextArea.d.ts +0 -25
- package/dist/components/TextArea.js +0 -1
- package/dist/components/TimeDisplay.d.ts +0 -18
- package/dist/components/TimeDisplay.js +0 -1
- package/dist/components/Tooltip.d.ts +0 -29
- package/dist/components/Tooltip.js +0 -1
- package/dist/components/TrackOutsideClicks.d.ts +0 -34
- package/dist/components/TrackOutsideClicks.js +0 -1
- package/dist/components/VirtualList.d.ts +0 -11
- package/dist/components/VirtualList.js +0 -1
- package/dist/components/index.d.ts +0 -49
- package/dist/components/index.js +0 -1
package/dist/components/Box.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import type { BooleanLike } from '../common/react.ts';
|
|
2
|
-
import { type BooleanStyleMap, type EventHandlers, type StringStyleMap } from '../common/ui.ts';
|
|
3
|
-
import { type CSSProperties, type HTMLAttributes, type ReactNode } from 'react';
|
|
4
|
-
export type BoxInternalProps = Partial<{
|
|
5
|
-
/**
|
|
6
|
-
* The component used for the root node.
|
|
7
|
-
* @default <div>
|
|
8
|
-
*/
|
|
9
|
-
as: string;
|
|
10
|
-
/** The content of the component. */
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
/** Class name to pass into the component. */
|
|
13
|
-
className: string | BooleanLike;
|
|
14
|
-
/** The unique id of the component. */
|
|
15
|
-
id: string;
|
|
16
|
-
/** The inline style of the component. */
|
|
17
|
-
style: CSSProperties;
|
|
18
|
-
/**
|
|
19
|
-
* A shorthand classname syntax based loosely on tailwind.
|
|
20
|
-
*
|
|
21
|
-
* This takes all Box style props with a dash separator for params, e.g.'mb-4' or the prop name alone e.g. 'bold'.
|
|
22
|
-
*
|
|
23
|
-
* It's compatible with regular Box props, even on the same component, but it will take precedence.
|
|
24
|
-
*
|
|
25
|
-
* Example:
|
|
26
|
-
* ```tsx
|
|
27
|
-
* <Box tw="mb-2 bold fontSize-16px">
|
|
28
|
-
* // Is equivalent to
|
|
29
|
-
* <Box mb={2} bold fontSize="16px">
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* Caveats:
|
|
33
|
-
* 1. You can't use this for custom props from other components.
|
|
34
|
-
*
|
|
35
|
-
* 2. There is no type info or safety for this method. Like the old days, it simply won't work if you use it incorrectly.
|
|
36
|
-
*
|
|
37
|
-
* 3. This should be a static string with minimal interpolation. If you need more logic, prefer the props approach.
|
|
38
|
-
*/
|
|
39
|
-
tw: string;
|
|
40
|
-
}>;
|
|
41
|
-
type LiftedHTMLAttributes<TElement> = {
|
|
42
|
-
/** Whether this element is draggable.
|
|
43
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/draggable
|
|
44
|
-
*/
|
|
45
|
-
draggable?: HTMLAttributes<TElement>['draggable'];
|
|
46
|
-
};
|
|
47
|
-
export interface BoxProps<TElement = HTMLDivElement> extends BoxInternalProps, BooleanStyleMap, StringStyleMap, LiftedHTMLAttributes<TElement>, EventHandlers<TElement> {
|
|
48
|
-
}
|
|
49
|
-
type DangerDoNotUse = {
|
|
50
|
-
dangerouslySetInnerHTML?: {
|
|
51
|
-
__html: any;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* ## Box
|
|
56
|
-
*
|
|
57
|
-
* The Box component serves as a wrapper component for most of the CSS utility
|
|
58
|
-
* needs. It creates a new DOM element, a `<div>` by default that can be changed
|
|
59
|
-
* with the `as` property. Let's say you want to use a `<span>` instead:
|
|
60
|
-
*
|
|
61
|
-
* Example:
|
|
62
|
-
*
|
|
63
|
-
* ```tsx
|
|
64
|
-
* <Box as="span" m={1}>
|
|
65
|
-
* <Button />
|
|
66
|
-
* </Box>
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* This works great when the changes can be isolated to a new DOM element.
|
|
70
|
-
* For instance, you can change the margin this way.
|
|
71
|
-
*
|
|
72
|
-
* However, sometimes you have to target the underlying DOM element.
|
|
73
|
-
* For instance, you want to change the text color of the button. The Button
|
|
74
|
-
* component defines its own color. CSS inheritance doesn't help.
|
|
75
|
-
*
|
|
76
|
-
* To workaround this problem, the Box children accept a render props function.
|
|
77
|
-
* This way, `Button` can pull out the `className` generated by the `Box`.
|
|
78
|
-
*
|
|
79
|
-
* Example:
|
|
80
|
-
*
|
|
81
|
-
* ```tsx
|
|
82
|
-
* <Box color="primary">{(props) => <Button {...props} />}</Box>
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* ## Box Units
|
|
86
|
-
*
|
|
87
|
-
* `Box` units, like width, height and margins can be defined in two ways:
|
|
88
|
-
*
|
|
89
|
-
* - By plain numbers
|
|
90
|
-
* - 1 unit equals `1rem` for width, height and positioning properties.
|
|
91
|
-
* - 1 unit equals `0.5rem` for margins and paddings.
|
|
92
|
-
* - By strings with proper CSS units
|
|
93
|
-
* - For example: `100px`, `2em`, `1rem`, `100%`, etc.
|
|
94
|
-
*
|
|
95
|
-
* If you need more precision, you can always use fractional numbers.
|
|
96
|
-
*
|
|
97
|
-
* Default font size (`1rem`) is equal to `12px`.
|
|
98
|
-
*
|
|
99
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
100
|
-
*/
|
|
101
|
-
export declare function Box<TElement = HTMLDivElement>(props: BoxProps<TElement> & DangerDoNotUse): import("react").ReactElement<{
|
|
102
|
-
className: string;
|
|
103
|
-
}, string | import("react").JSXElementConstructor<any>>;
|
|
104
|
-
export {};
|
package/dist/components/Box.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{computeBoxClassName as o,computeBoxProps as r,computeTwClass as m}from"../common/ui.js";import{createElement as t}from"react";function e(e){let{as:i="div",className:c,children:n,tw:a,...f}=e,p=c?`${c} ${o(f)}`:o(f);return t(i,{...r({...f,...m(a)}),className:p},n)}export{e as Box};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { type BooleanLike } from '../common/react.ts';
|
|
2
|
-
import type { Placement } from '@floating-ui/react';
|
|
3
|
-
import { type ReactNode, type RefObject } from 'react';
|
|
4
|
-
import { type BoxProps } from './Box';
|
|
5
|
-
/**
|
|
6
|
-
* Getting ellipses to work requires that you use:
|
|
7
|
-
* 1. A string rather than a node
|
|
8
|
-
* 2. A fixed width here or in a parent
|
|
9
|
-
* 3. Children prop rather than content
|
|
10
|
-
*/
|
|
11
|
-
type EllipsisUnion = {
|
|
12
|
-
children: string;
|
|
13
|
-
/** @deprecated use children instead */
|
|
14
|
-
content?: never;
|
|
15
|
-
/** Cuts off text with an ellipsis */
|
|
16
|
-
ellipsis: true;
|
|
17
|
-
} | Partial<{
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
/** @deprecated use children instead */
|
|
20
|
-
content: ReactNode;
|
|
21
|
-
ellipsis: undefined;
|
|
22
|
-
}>;
|
|
23
|
-
type Props = Partial<{
|
|
24
|
-
/** Captures keyboard events */
|
|
25
|
-
captureKeys: boolean;
|
|
26
|
-
/** Makes the button circular */
|
|
27
|
-
circular: boolean;
|
|
28
|
-
/** Reduces the padding of the button */
|
|
29
|
-
compact: boolean;
|
|
30
|
-
/** Disables button and makes it semi-transparent */
|
|
31
|
-
disabled: BooleanLike;
|
|
32
|
-
/** Fill all available horizontal space */
|
|
33
|
-
fluid: boolean;
|
|
34
|
-
/** Adds an icon to the button */
|
|
35
|
-
icon: string | false;
|
|
36
|
-
/** Icon color */
|
|
37
|
-
iconColor: string;
|
|
38
|
-
/** Icon position */
|
|
39
|
-
iconPosition: string;
|
|
40
|
-
/** Icon rotation */
|
|
41
|
-
iconRotation: number;
|
|
42
|
-
/** Icon size */
|
|
43
|
-
iconSize: number;
|
|
44
|
-
/** Makes the icon spin */
|
|
45
|
-
iconSpin: BooleanLike;
|
|
46
|
-
/** Called when the button is blurred */
|
|
47
|
-
onBlur: (e: any) => void;
|
|
48
|
-
/** Called when element is clicked */
|
|
49
|
-
onClick: (e: any) => void;
|
|
50
|
-
/** Activates the button (gives it a green color) */
|
|
51
|
-
selected: BooleanLike;
|
|
52
|
-
/** A fancy, boxy tooltip, which appears when hovering over the button */
|
|
53
|
-
tooltip: ReactNode;
|
|
54
|
-
/** Position of the tooltip. Does not guarantee the position is respected. */
|
|
55
|
-
tooltipPosition: Placement;
|
|
56
|
-
/** Align content vertically using flex. Use lineHeight if the height is static. */
|
|
57
|
-
verticalAlignContent: string;
|
|
58
|
-
}> & EllipsisUnion & BoxProps;
|
|
59
|
-
export declare function Button(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
60
|
-
type CheckProps = Partial<{
|
|
61
|
-
checked: BooleanLike;
|
|
62
|
-
}> & Props;
|
|
63
|
-
declare function ButtonCheckbox(props: CheckProps): import("react/jsx-runtime").JSX.Element;
|
|
64
|
-
type ConfirmProps = Partial<{
|
|
65
|
-
confirmColor: string;
|
|
66
|
-
confirmContent: ReactNode;
|
|
67
|
-
confirmIcon: string;
|
|
68
|
-
}> & Props;
|
|
69
|
-
declare function ButtonConfirm(props: ConfirmProps): import("react/jsx-runtime").JSX.Element;
|
|
70
|
-
type InputProps = Partial<{
|
|
71
|
-
/** Text to display on the button exclusively. If left blank, displays the value */
|
|
72
|
-
buttonText: string;
|
|
73
|
-
/** Use the value prop. This is done to be uniform with other inputs. */
|
|
74
|
-
children: never;
|
|
75
|
-
/** Max length of the input */
|
|
76
|
-
maxLength: number;
|
|
77
|
-
/** Action on outside click or enter key */
|
|
78
|
-
onCommit: (value: string) => void;
|
|
79
|
-
/** Reference to the inner input */
|
|
80
|
-
ref: RefObject<HTMLInputElement | null>;
|
|
81
|
-
/** The value of the input */
|
|
82
|
-
value: string;
|
|
83
|
-
}> & Props;
|
|
84
|
-
declare function ButtonInput(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
85
|
-
type FileProps = {
|
|
86
|
-
accept: string;
|
|
87
|
-
multiple?: boolean;
|
|
88
|
-
onSelectFiles: (files: string | string[]) => void;
|
|
89
|
-
} & Props;
|
|
90
|
-
declare function ButtonFile(props: FileProps): import("react/jsx-runtime").JSX.Element;
|
|
91
|
-
/**
|
|
92
|
-
* ## Button
|
|
93
|
-
*
|
|
94
|
-
* Buttons allow users to take actions, and make choices, with a single click.
|
|
95
|
-
*
|
|
96
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-button--docs)
|
|
97
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
98
|
-
*/
|
|
99
|
-
export declare namespace Button {
|
|
100
|
-
/**
|
|
101
|
-
* ## Button.Checkbox
|
|
102
|
-
* A ghetto checkbox, made entirely using existing Button API.
|
|
103
|
-
*/
|
|
104
|
-
const Checkbox: typeof ButtonCheckbox;
|
|
105
|
-
/**
|
|
106
|
-
* ## Button.Confirm
|
|
107
|
-
* A button with an extra confirmation step, using native button component.
|
|
108
|
-
*/
|
|
109
|
-
const Confirm: typeof ButtonConfirm;
|
|
110
|
-
/**
|
|
111
|
-
* ## Button.Input
|
|
112
|
-
* A button that turns into an input box after the first click.
|
|
113
|
-
*
|
|
114
|
-
* Turns back into a button after the user hits enter, defocuses, or hits escape. Enter and defocus commit, while escape cancels.
|
|
115
|
-
*/
|
|
116
|
-
const Input: typeof ButtonInput;
|
|
117
|
-
/**
|
|
118
|
-
* ## Button.File
|
|
119
|
-
* Accepts file input, based on the native element.
|
|
120
|
-
*/
|
|
121
|
-
const File: typeof ButtonFile;
|
|
122
|
-
}
|
|
123
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t;import{Fragment as n,jsx as e,jsxs as o}from"react/jsx-runtime";import{KEY as r,isEscape as i}from"../common/keys.js";import{classes as u}from"../common/react.js";import{computeBoxClassName as l,computeBoxProps as c}from"../common/ui.js";import{createRef as a,useEffect as s,useRef as f,useState as m}from"react";import{Box as p}from"./Box.js";import{Icon as d}from"./Icon.js";import{Tooltip as B}from"./Tooltip.js";function h(t){let{captureKeys:n=!0,children:a,circular:s,className:f,color:m,compact:p,content:h,disabled:y,ellipsis:k,fluid:g,icon:v,iconColor:x,iconPosition:C,iconRotation:b,iconSize:j,iconSpin:N,onClick:_,selected:w,tooltip:D,tooltipPosition:I,verticalAlignContent:T,...A}=t,$=h||a,q=e(d,{className:"Button--icon",color:x,name:v||"",rotation:b,size:j,spin:N}),E=e("div",{className:u(["Button",g&&"Button--fluid",y&&"Button--disabled",w&&"Button--selected",s&&"Button--circular",p&&"Button--compact",!$&&"Button--empty",v&&"Button--hasIcon",C&&`Button--icon-${C}`,T&&"Button--flex",T&&g&&"Button--flex--fluid",T&&`Button--verticalAlignContent--${T}`,`Button--color--${m||"default"}`,f,l(A)]),onClick:t=>{!y&&_&&_(t)},onKeyDown:t=>{if(n){if(t.key===r.Space||t.key===r.Enter){t.preventDefault(),!y&&_&&_(t);return}i(t.key)&&t.preventDefault()}},tabIndex:y?void 0:0,...c(A),children:o("div",{className:u(["Button__content",k&&"Button__content--ellipsis"]),children:[v&&"right"!==C&&q,k?e("span",{className:"Button--ellipsis",children:$}):$,v&&"right"===C&&q]})});return D&&(E=e(B,{content:D,position:I,children:E})),E}(t=h||(h={})).Checkbox=function(t){let{checked:n,...o}=t;return e(h,{color:"transparent",icon:n?"check-square-o":"square-o",selected:n,...o})},t.Confirm=function(t){let{children:n,color:o,confirmColor:r="bad",confirmContent:i="Confirm?",confirmIcon:u,ellipsis:l=!0,icon:c,onBlur:a,onClick:s,...f}=t,[p,d]=m(!1);return e(h,{color:p?r:o,icon:p?u:c,onBlur:function(t){d(!1),a?.(t)},onClick:function(t){p?(s?.(t),d(!1)):d(!0)},...f,children:p?i:n})},t.Input=function(t){let{buttonText:n,children:l,color:c="default",disabled:B,fluid:h,icon:y,iconRotation:k,iconSpin:g,maxLength:v,onCommit:x,ref:C,value:b="",...j}=t,[N,_]=m(b),[w,D]=m(!1),I=f(!1),T=a(),A=C??T;return s(()=>{w&&(A.current?.focus(),A.current?.select())},[w]),s(()=>{w||b===N||_(b)},[w,b]),o(p,{className:u(["Button",h&&"Button--fluid",B&&"Button--disabled",`Button--color--${c}`]),onClick:()=>{B||D(!0)},...j,children:[y&&e(d,{name:y,rotation:k,spin:g}),n??N,e("input",{className:"NumberInput__input",disabled:!!B,maxLength:v,onBlur:function(){I.current||b===N||(x?.(N),I.current=!1),D(!1)},onChange:function(t){_(t.currentTarget.value)},onKeyDown:function(t){if(t.key===r.Enter){t.preventDefault(),t.currentTarget.blur();return}if(i(t.key)){t.preventDefault(),I.current=!0,t.currentTarget.blur();return}},ref:A,spellCheck:"false",style:{display:w?"":"none",textAlign:"left"},type:"text",value:N})]})},t.File=function(t){let{accept:r,multiple:i,onSelectFiles:u,...l}=t,c=f(null);async function a(t){let n=Array.from(t).map(t=>{let n=new FileReader;return new Promise(e=>{n.onload=()=>e(n.result),n.readAsText(t)})});return await Promise.all(n)}async function s(t){let n=t.target.files;if(n?.length){let t=await a(n);u(i?t:t[0])}}return o(n,{children:[e(h,{onClick:()=>c.current?.click(),...l}),e("input",{accept:r,hidden:!0,multiple:i,onChange:s,ref:c,type:"file"})]})};export{h as Button};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { BoxProps } from './Box';
|
|
2
|
-
type SampleByondParams = Partial<{
|
|
3
|
-
/** Can be auto-generated. */
|
|
4
|
-
id: string;
|
|
5
|
-
/** Defaults to the current window */
|
|
6
|
-
parent: string;
|
|
7
|
-
/** The type of control. Read-only. */
|
|
8
|
-
type: string;
|
|
9
|
-
/** Text shown in label/button/input. For input controls this setting is only available at runtime. */
|
|
10
|
-
text: string;
|
|
11
|
-
}>;
|
|
12
|
-
type Props = Partial<{
|
|
13
|
-
/** An object with parameters, which are directly passed to
|
|
14
|
-
* the `winset` proc call.
|
|
15
|
-
*
|
|
16
|
-
* You can find a full reference of these parameters
|
|
17
|
-
* in [BYOND controls and parameters guide](https://secure.byond.com/docs/ref/skinparams.html). */
|
|
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;
|
|
25
|
-
}> & BoxProps;
|
|
26
|
-
/**
|
|
27
|
-
* ## ByondUi
|
|
28
|
-
*
|
|
29
|
-
* Displays a BYOND UI element on top of the browser, and leverages browser's
|
|
30
|
-
* layout engine to position it just like any other HTML element. It is
|
|
31
|
-
* especially useful if you want to display a secondary game map in your
|
|
32
|
-
* interface.
|
|
33
|
-
*
|
|
34
|
-
* Example:
|
|
35
|
-
*
|
|
36
|
-
* ```tsx
|
|
37
|
-
* <ByondUi
|
|
38
|
-
* params={{
|
|
39
|
-
* id: 'test_button', // optional, can be auto-generated
|
|
40
|
-
* parent: 'some_container', // optional, defaults to the current window
|
|
41
|
-
* type: 'button',
|
|
42
|
-
* text: 'Hello, world!',
|
|
43
|
-
* }} />
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* Example:
|
|
47
|
-
*
|
|
48
|
-
* ```tsx
|
|
49
|
-
* <ByondUi
|
|
50
|
-
* params={{
|
|
51
|
-
* id: 'test_map',
|
|
52
|
-
* type: 'map',
|
|
53
|
-
* }} />
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* It supports a full set of `Box` properties for layout purposes.
|
|
57
|
-
*
|
|
58
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
59
|
-
*/
|
|
60
|
-
export declare function ByondUi(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
61
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{debounce as n}from"../common/timer.js";import{computeBoxProps as t}from"../common/ui.js";import{useEffect as o,useRef as r}from"react";let i=[];function d(d){let{params:s,phonehome:l,...u}=d,m=r(null),p=r(function(e,n=!0){let t=i.length;i.push(null);let o=e||`byondui_${t}`;return{render:e=>{n&&Byond.sendMessage("renderByondUi",{renderByondUi:o}),i[t]=o,Byond.winset(o,e)},unmount:()=>{n&&Byond.sendMessage("unmountByondUi",{renderByondUi:o}),i[t]=null,Byond.winset(o,{parent:""})}}}(s?.id,l));function f(){let e,n,t=m.current;if(!t)return;let o=(e=window.devicePixelRatio??1,{pos:[(n=t.getBoundingClientRect()).left*e,n.top*e],size:[(n.right-n.left)*e,(n.bottom-n.top)*e]});p.current.render({parent:Byond.windowId,...s,pos:`${o.pos[0]},${o.pos[1]}`,size:`${o.size[0]}x${o.size[1]}`})}let y=n(()=>{f()},100);return o(()=>(window.addEventListener("resize",y),f(),()=>{window.removeEventListener("resize",y),p.current.unmount()}),[]),e("div",{ref:m,...t(u),children:e("div",{style:{minHeight:"22px"}})})}window.addEventListener("beforeunload",()=>{for(let e=0;e<i.length;e++){let n=i[e];"string"==typeof n&&(i[e]=null,Byond.winset(n,{parent:""}))}});export{d as ByondUi};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type BoxProps } from './Box';
|
|
2
|
-
type Props = {
|
|
3
|
-
data: number[][];
|
|
4
|
-
} & Partial<{
|
|
5
|
-
fillColor: string;
|
|
6
|
-
rangeX: [number, number];
|
|
7
|
-
rangeY: [number, number];
|
|
8
|
-
strokeColor: string;
|
|
9
|
-
strokeWidth: number;
|
|
10
|
-
}> & BoxProps;
|
|
11
|
-
/**
|
|
12
|
-
* ## Chart
|
|
13
|
-
*
|
|
14
|
-
* A simple chart component that displays a polyline based on the provided data.
|
|
15
|
-
*
|
|
16
|
-
* It normalizes the data to fit within the viewBox dimensions and allows for custom fill and stroke colors.
|
|
17
|
-
*
|
|
18
|
-
* - [View inherited Box Props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
19
|
-
*/
|
|
20
|
-
export declare function Chart(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
export declare namespace Chart {
|
|
22
|
-
var Line: typeof Chart;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
package/dist/components/Chart.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{zip as n}from"../common/collections.js";import{useEffect as r,useRef as i,useState as o}from"react";import{Box as l}from"./Box.js";let s={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0};function f(f){let{data:h=[],rangeX:m,rangeY:p,fillColor:a="none",strokeColor:c="#ffffff",strokeWidth:u=2,...d}=f,v=i(null),[g,w]=o([600,200]),x=function(e,t,r,i){if(0===e.length)return[];let o=n(...e),l=o.map(e=>Math.min(...e)),s=o.map(e=>Math.max(...e));return void 0!==r&&(l[0]=r[0],s[0]=r[1]),void 0!==i&&(l[1]=i[0],s[1]=i[1]),e.map(e=>n(e,l,s,t).map(([e,t,n,r])=>(e-t)/(n-t)*r))}(h,g,m,p);if(x.length>0){let e=x[0],t=x[x.length-1];x.push([g[0]+u,t[1]]),x.push([g[0]+u,-u]),x.push([-u,-u]),x.push([-u,e[1]])}let $=function(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];t+=`${r[0]},${r[1]} `}return t}(x);function j(){let e=v.current;if(!e)return;let t=e.getBoundingClientRect();w([t.width,t.height])}return r(()=>(window.addEventListener("resize",j),j(),()=>{window.removeEventListener("resize",j)}),[]),e(l,{position:"relative",...d,children:e("div",{ref:v,style:s,children:t("svg",{preserveAspectRatio:"none",style:s,viewBox:`0 0 ${g[0]} ${g[1]}`,children:[e("title",{children:"chart"}),e("polyline",{fill:a,points:$,stroke:c,strokeWidth:u,transform:`scale(1, -1) translate(0, -${g[1]})`})]})})})}f.Line=f;export{f as Chart};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
-
import { type BoxProps } from './Box';
|
|
3
|
-
type Props = Partial<{
|
|
4
|
-
/** Buttons or other content to render inline with the button */
|
|
5
|
-
buttons: ReactNode;
|
|
6
|
-
/** Top margin of the child nodes, defaulted to 1 */
|
|
7
|
-
child_mt: number;
|
|
8
|
-
/** Icon to display with the collapsible */
|
|
9
|
-
icon: string;
|
|
10
|
-
/** Whether the collapsible is open */
|
|
11
|
-
open: boolean;
|
|
12
|
-
/** Text to display on the button for collapsing */
|
|
13
|
-
title: ReactNode;
|
|
14
|
-
/** Custom styles for the child nodes */
|
|
15
|
-
childStyles: CSSProperties;
|
|
16
|
-
}> & BoxProps;
|
|
17
|
-
/**
|
|
18
|
-
* ## Collapsible
|
|
19
|
-
*
|
|
20
|
-
* Displays contents when open, acts as a fluid button when closed.
|
|
21
|
-
*
|
|
22
|
-
* Click to toggle, closed by default.
|
|
23
|
-
*
|
|
24
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-collapsible--docs)
|
|
25
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
26
|
-
*/
|
|
27
|
-
export declare function Collapsible(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as l,jsxs as e}from"react/jsx-runtime";import{useState as r}from"react";import{Box as o}from"./Box.js";import{Button as c}from"./Button.js";function i(i){let{children:n,child_mt:t=1,childStyles:a,color:m,title:s,buttons:d,icon:h,...p}=i,[b,f]=r(i.open);return e(o,{mb:1,children:[e("div",{className:"Table",children:[l("div",{className:"Table__cell",children:l(c,{color:m,fluid:!0,icon:h||(b?"chevron-down":"chevron-right"),onClick:()=>f(!b),...p,children:s})}),d&&l("div",{className:"Table__cell Table__cell--collapsing",children:d})]}),b&&l(o,{mt:t,style:a,children:n})]})}export{i as Collapsible};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
type Props = {
|
|
4
|
-
content?: ReactNode;
|
|
5
|
-
} & BoxProps;
|
|
6
|
-
/**
|
|
7
|
-
* ## ColorBox
|
|
8
|
-
*
|
|
9
|
-
* Displays a 1-character wide colored square. Can be used as a status indicator,
|
|
10
|
-
* or for visually representing a color.
|
|
11
|
-
*
|
|
12
|
-
* If you want to set a background color on an element, use a plain
|
|
13
|
-
* [Box](https://github.com/tgstation/tgui-core/tree/main/lib/components/Box.tsx) instead.
|
|
14
|
-
*
|
|
15
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-colorbox--docs)
|
|
16
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
17
|
-
*/
|
|
18
|
-
export declare function ColorBox(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
19
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as o}from"react/jsx-runtime";import{classes as r}from"../common/react.js";import{computeBoxClassName as l,computeBoxProps as m}from"../common/ui.js";function t(t){let{content:c,children:e,className:n,...i}=t;return i.color=c?null:"default",i.backgroundColor=t.color||"default",o("div",{className:r(["ColorBox",n,l(i)]),...m(i),children:c||""})}export{t as ColorBox};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
type DialogProps = {
|
|
3
|
-
/** The content of the dialog. */
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
/** The function to call when close is clicked */
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
/** The title of the dialog. */
|
|
8
|
-
title: ReactNode;
|
|
9
|
-
} & Partial<{
|
|
10
|
-
/** The height of the dialog. */
|
|
11
|
-
height: string;
|
|
12
|
-
/** The width of the dialog. */
|
|
13
|
-
width: string;
|
|
14
|
-
}>;
|
|
15
|
-
/**
|
|
16
|
-
* ## Dialog
|
|
17
|
-
*
|
|
18
|
-
* A themed dialog for user interaction.
|
|
19
|
-
*
|
|
20
|
-
* Example:
|
|
21
|
-
*
|
|
22
|
-
* ```tsx
|
|
23
|
-
* <Dialog title="Dialog Title" onClose={() => {}}>
|
|
24
|
-
* <div>Dialog Content</div>
|
|
25
|
-
* </Dialog>
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dialog--docs)
|
|
29
|
-
*/
|
|
30
|
-
export declare function Dialog(props: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export declare namespace Dialog {
|
|
32
|
-
var Button: typeof DialogButton;
|
|
33
|
-
}
|
|
34
|
-
type DialogButtonProps = {
|
|
35
|
-
children: ReactNode;
|
|
36
|
-
onClick: () => void;
|
|
37
|
-
};
|
|
38
|
-
declare function DialogButton(props: DialogButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
39
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as t,jsxs as i}from"react/jsx-runtime";import{Box as o}from"./Box.js";import{Button as e}from"./Button.js";function l(l){let{title:n,onClose:r,children:a,width:c,height:s}=l;return t("div",{className:"Dialog",children:i(o,{className:"Dialog__content",height:s,width:c||"370px",children:[i("div",{className:"Dialog__header",children:[t("div",{className:"Dialog__title",children:n}),t(o,{mr:2,children:t(e,{color:"transparent",icon:"window-close-o",lineHeight:"22px",mr:"-3px",onClick:r,textAlign:"center",tooltip:"Close",tooltipPosition:"bottom-start",width:"26px"})})]}),a]})})}l.Button=function(i){let{onClick:o,children:l}=i;return t(e,{className:"Dialog__button",onClick:o,verticalAlignContent:"middle",children:l})};export{l as Dialog};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type BoxProps } from './Box';
|
|
2
|
-
/**
|
|
3
|
-
* ## Dimmer
|
|
4
|
-
*
|
|
5
|
-
* Dims surrounding area to emphasize content placed inside.
|
|
6
|
-
*
|
|
7
|
-
* Content is automatically centered inside the dimmer.
|
|
8
|
-
*
|
|
9
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dimmer--docs)
|
|
10
|
-
*/
|
|
11
|
-
export declare function Dimmer(props: BoxProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{classes as m}from"../common/react.js";import{Box as e}from"./Box.js";function i(i){let{className:o,children:t,...n}=i;return r(e,{className:m(["Dimmer",o]),...n,children:r("div",{className:"Dimmer__inner",children:t})})}export{i as Dimmer};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
type Props = Partial<{
|
|
2
|
-
/** Divider can divide content without creating a dividing line. */
|
|
3
|
-
hidden: boolean;
|
|
4
|
-
/** Divide content vertically. */
|
|
5
|
-
vertical: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* ## Divider
|
|
10
|
-
*
|
|
11
|
-
* Draws a horizontal or vertical line, dividing a section into groups.
|
|
12
|
-
* Works like the good old `<hr>` element, but it's fancier.
|
|
13
|
-
*
|
|
14
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-divider--docs)
|
|
15
|
-
*/
|
|
16
|
-
export declare function Divider(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import{classes as r}from"../common/react.js";function e(e){let{hidden:t,vertical:o}=e;return i("div",{className:r(["Divider",t&&"Divider--hidden",o?"Divider--vertical":"Divider--horizontal"])})}export{e as Divider};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
export declare enum Direction {
|
|
4
|
-
NORTH = 1,
|
|
5
|
-
SOUTH = 2,
|
|
6
|
-
EAST = 4,
|
|
7
|
-
WEST = 8,
|
|
8
|
-
NORTHEAST = 5,
|
|
9
|
-
NORTHWEST = 9,
|
|
10
|
-
SOUTHEAST = 6,
|
|
11
|
-
SOUTHWEST = 10
|
|
12
|
-
}
|
|
13
|
-
type Props = {
|
|
14
|
-
/** Required: The path of the icon */
|
|
15
|
-
icon: string;
|
|
16
|
-
/** Required: The state of the icon */
|
|
17
|
-
icon_state: string;
|
|
18
|
-
} & Partial<{
|
|
19
|
-
/** Facing direction. See direction enum. Default is South */
|
|
20
|
-
direction: Direction;
|
|
21
|
-
/** Fallback icon. */
|
|
22
|
-
fallback: ReactNode;
|
|
23
|
-
/** Frame number. Default is 1 */
|
|
24
|
-
frame: number;
|
|
25
|
-
/** Movement state. Default is false */
|
|
26
|
-
movement: any;
|
|
27
|
-
}> & BoxProps;
|
|
28
|
-
/**
|
|
29
|
-
* ## DmIcon
|
|
30
|
-
*
|
|
31
|
-
* Displays an icon from the BYOND icon reference map. Requires Byond 515+.
|
|
32
|
-
* A much faster alternative to base64 icons.
|
|
33
|
-
*/
|
|
34
|
-
export declare function DmIcon(props: Props): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
35
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as T}from"react/jsx-runtime";import{Image as r}from"./Image.js";var S,o=((S={})[S.NORTH=1]="NORTH",S[S.SOUTH=2]="SOUTH",S[S.EAST=4]="EAST",S[S.WEST=8]="WEST",S[S.NORTHEAST=5]="NORTHEAST",S[S.NORTHWEST=9]="NORTHWEST",S[S.SOUTHEAST=6]="SOUTHEAST",S[S.SOUTHWEST=10]="SOUTHWEST",S);function e(S){let{direction:o=2,fallback:e,frame:t=1,icon_state:E,icon:H,movement:O=!1,...i}=S,m=Byond.iconRefMap?.[H];return m?T(r,{fixErrors:!0,src:`${m}?state=${E}&dir=${o}&movement=${!!O}&frame=${t}`,...i}):e}export{o as Direction,e as DmIcon};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { type MouseEventHandler, type ReactNode } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
type Control = {
|
|
4
|
-
/** Tooltip-like node to display. */
|
|
5
|
-
displayElement: ReactNode;
|
|
6
|
-
/** The value to display. */
|
|
7
|
-
displayValue: number;
|
|
8
|
-
/** Whether the element is being dragged */
|
|
9
|
-
dragging: boolean;
|
|
10
|
-
/** Whether the input is currently being edited */
|
|
11
|
-
editing: boolean;
|
|
12
|
-
/** Attach this to the element you want to be draggable */
|
|
13
|
-
handleDragStart: MouseEventHandler<HTMLDivElement>;
|
|
14
|
-
/** The input element. */
|
|
15
|
-
inputElement: ReactNode;
|
|
16
|
-
};
|
|
17
|
-
type Props = {
|
|
18
|
-
children: (control: Control) => ReactNode;
|
|
19
|
-
/** The external state value. */
|
|
20
|
-
value: number;
|
|
21
|
-
} & Partial<{
|
|
22
|
-
/** Animates the value if it was changed externally. */
|
|
23
|
-
animated: boolean;
|
|
24
|
-
/** The matrix to use for the drag. */
|
|
25
|
-
dragMatrix: [number, number];
|
|
26
|
-
/** onChange also fires when you drag the input. */
|
|
27
|
-
tickWhileDragging: boolean;
|
|
28
|
-
/** Format the value using this function before displaying it. */
|
|
29
|
-
format: (value: number) => string;
|
|
30
|
-
/** The maximum value. */
|
|
31
|
-
maxValue: number;
|
|
32
|
-
/** The minimum value. */
|
|
33
|
-
minValue: number;
|
|
34
|
-
/**
|
|
35
|
-
* An event which fires when you release the input or successfully enter a
|
|
36
|
-
* number. This is the default value event for controls.
|
|
37
|
-
*/
|
|
38
|
-
onChange: (event: Event, value: number) => void;
|
|
39
|
-
/** The step size. */
|
|
40
|
-
step: number;
|
|
41
|
-
/** The step size in pixels. */
|
|
42
|
-
stepPixelSize: number | ((defaultStepPixelSize: number) => number);
|
|
43
|
-
/** Whether to unclamp the value. */
|
|
44
|
-
unclamped: boolean;
|
|
45
|
-
/** The unit of the value. */
|
|
46
|
-
unit: string;
|
|
47
|
-
/** The rate at which the value is updated. */
|
|
48
|
-
updateRate: number;
|
|
49
|
-
}> & Omit<BoxProps, 'children'>;
|
|
50
|
-
/**
|
|
51
|
-
* ## DraggableControl
|
|
52
|
-
*
|
|
53
|
-
* A wrapper component for draggable elements.
|
|
54
|
-
* Generally, you won't need to use this component directly.
|
|
55
|
-
*/
|
|
56
|
-
export declare function DraggableControl(props: Props): ReactNode;
|
|
57
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fragment as e,jsx as r,jsxs as t}from"react/jsx-runtime";import{KEY as n,isEscape as u}from"../common/keys.js";import{clamp as o}from"../common/math.js";import{useEffect as l,useRef as c,useState as i}from"react";import{AnimatedNumber as a}from"./AnimatedNumber.js";function s(e,r){return e.screenX*r[0]+e.screenY*r[1]}function m(m){let{animated:f,children:v,dragMatrix:p=[1,0],tickWhileDragging:d,format:h,maxValue:y=1/0,minValue:g=-1/0,onChange:E,step:b=1,stepPixelSize:N,unclamped:w,unit:T,updateRate:j=400,fontSize:x,height:L,lineHeight:S}=m,[k,z]=i(m.value),[D,I]=i(!1),F=c(!1),M=c(m.value),O=c(0),$=c(0),_=c(null),A=c(null),B=c(null),C=c(null);function H(e){let r=$.current;if(null===r)throw Error("Origin is unset.");let t=s(e,p),n=_.current;if(null===n)throw Error("Final step pixel size has not been computed.");let u=O.current;if(null===u)throw Error("Original value is unset.");let l=o(Math.floor(u/b)*b+Math.trunc((t-r)/n)*b,g,y);M.current=l,z(l)}function K(e){document.body.style["pointer-events"]="auto",B.current&&clearInterval(B.current),$.current=null,_.current=null,O.current=null,document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",K),F.current&&(E?.(e,M.current),F.current=!1)}l(()=>{m.value!==M.current&&(M.current=m.value,z(m.value))},[m.value]);let P=m.value;F.current&&(P=M.current);let U=t(e,{children:[f&&!F.current?r(a,{format:h,value:P}):h?h(P):P,T?` ${T}`:""]}),W=r("input",{className:"NumberInput__input",onBlur:function(e){let r=Number.parseFloat(e.currentTarget.value);(w||(r=o(r,g,y)),Number.isNaN(r))?I(!1):(M.current=r,z(r),E?.(e.nativeEvent,r),D&&I(!1))},onKeyDown:function(e){(e.key===n.Enter||u(e.key))&&I(!1)},ref:A,style:{display:D?void 0:"none",fontSize:x,height:L,lineHeight:S}});return v({displayElement:U,displayValue:P,dragging:F.current,editing:D,handleDragStart:function(e){if(!D){if("number"!=typeof N){let r=e.currentTarget.offsetWidth/((y-g)/b);if(void 0===N)_.current=r;else if("function"==typeof N)_.current=N(r);else throw Error(`Unsupported value for stepPixelSize of type ${typeof N}`)}else _.current=N;document.body.style["pointer-events"]="none",$.current=s(e.nativeEvent,p),O.current=m.value,F.current=!0,document.addEventListener("mouseup",K),C.current=setTimeout(()=>{var r=e.nativeEvent;if(F.current)document.addEventListener("mousemove",H),B.current=setInterval(()=>{F.current&&d&&E?.(r,M.current)},j);else if(I(!0),A.current){let e=A.current;e.value=M.current.toString(),setTimeout(()=>{e.focus(),e.select()},10)}C.current&&clearTimeout(C.current)},100)}},inputElement:W})}export{m as DraggableControl};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
type DropdownEntry = {
|
|
4
|
-
displayText: ReactNode;
|
|
5
|
-
value: string | number;
|
|
6
|
-
};
|
|
7
|
-
type DropdownOption = string | DropdownEntry;
|
|
8
|
-
type Props = {
|
|
9
|
-
/** Called when a value is picked from the list, `value` is the value that was picked */
|
|
10
|
-
onSelected: (value: any) => void;
|
|
11
|
-
/** An array of strings which will be displayed in the
|
|
12
|
-
dropdown when open. See Dropdown.tsx for more advanced usage with DropdownEntry */
|
|
13
|
-
options: DropdownOption[];
|
|
14
|
-
/** Currently selected entry to display. Can be left stateless to permanently display this value. */
|
|
15
|
-
selected: DropdownOption | null | undefined;
|
|
16
|
-
} & Partial<{
|
|
17
|
-
/** Whether to scroll automatically on open. Defaults to true */
|
|
18
|
-
autoScroll: boolean;
|
|
19
|
-
/** Whether to display previous / next buttons */
|
|
20
|
-
buttons: boolean;
|
|
21
|
-
/** Color of dropdown button */
|
|
22
|
-
color: string;
|
|
23
|
-
/** Disables the dropdown */
|
|
24
|
-
disabled: boolean;
|
|
25
|
-
/** Overwrites selection text with this. Good for objects etc. */
|
|
26
|
-
displayText: ReactNode;
|
|
27
|
-
/** Icon to display in dropdown button */
|
|
28
|
-
icon: string;
|
|
29
|
-
/** Whether the icon should be displayed alone */
|
|
30
|
-
iconOnly: boolean;
|
|
31
|
-
/** Angle of the icon */
|
|
32
|
-
iconRotation: number;
|
|
33
|
-
/** Whether or not the icon should spin */
|
|
34
|
-
iconSpin: boolean;
|
|
35
|
-
/** Width of the dropdown menu in box units. Default: 15 */
|
|
36
|
-
menuWidth: string | number;
|
|
37
|
-
/** Whether or not the arrow on the right hand side of the dropdown button is visible */
|
|
38
|
-
noChevron: boolean;
|
|
39
|
-
/** Dropdown renders over instead of below */
|
|
40
|
-
over: boolean;
|
|
41
|
-
/** Fill all available horizontal space */
|
|
42
|
-
fluid: boolean;
|
|
43
|
-
/** Text to show when nothing has been selected. */
|
|
44
|
-
placeholder: string;
|
|
45
|
-
/** @deprecated If you want to allow dropdown breaks layout, set width 100% */
|
|
46
|
-
clipSelectedText: boolean;
|
|
47
|
-
/** Called when dropdown button is clicked */
|
|
48
|
-
onClick: (event: any) => void;
|
|
49
|
-
}> & BoxProps;
|
|
50
|
-
/**
|
|
51
|
-
* ## Dropdown
|
|
52
|
-
*
|
|
53
|
-
* A simple dropdown box component. Lets the user select from a list of options
|
|
54
|
-
* and displays selected entry.
|
|
55
|
-
*
|
|
56
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-dropdown--docs)
|
|
57
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
58
|
-
*/
|
|
59
|
-
export declare function Dropdown(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
60
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fragment as o,jsx as n,jsxs as e}from"react/jsx-runtime";import{KEY as t}from"../common/keys.js";import{classes as r}from"../common/react.js";import{unit as l}from"../common/ui.js";import{useRef as i,useState as c}from"react";import{Button as d}from"./Button.js";import{Floating as s}from"./Floating.js";import{Icon as a}from"./Icon.js";function m(o){return"string"==typeof o?o:o.value}function p(p){let{autoScroll:u=!0,buttons:_,className:w,color:f="default",disabled:h,displayText:D,icon:y,iconRotation:v,iconSpin:N,iconOnly:g,menuWidth:b,noChevron:x,onClick:j,onSelected:k,options:C=[],over:B,placeholder:I="Select...",selected:T,fluid:A,width:E=15}=p,[K,O]=c(!1),S=i(null),$=C.findIndex(o=>m(o)===T)||0;function F(o){let n=o;n=o<$?o<2?0:o-2:o>C.length-3?C.length-1:o-2;let e=S.current,t=e?.children[n];e&&t&&(e.scrollTop=t.offsetTop)}function M(o){let n;if(C.length<1||h)return;let e=C.length-1;n=$<0?"next"===o?e:0:"next"===o?$===e?0:$+1:0===$?e:$-1,K&&u&&F(n),k?.(m(C[n]))}let W=B?"top":"bottom";return g&&(W=`${W}-start`),e("div",{className:r(["Dropdown",A&&"Dropdown--fluid"]),children:[n(s,{allowedOutsideClasses:".Dropdown__button",closeAfterInteract:!0,content:n("div",{className:"Dropdown__menu",ref:S,children:0===C.length?n("div",{className:"Dropdown__menu--entry",children:"No options"}):C.map(o=>{let e=m(o);return n("div",{className:r(["Dropdown__menu--entry",T===e&&"selected"]),onClick:()=>{k?.(e)},onKeyDown:o=>{o.key===t.Enter&&k?.(e)},children:"string"==typeof o?o:o.displayText},e)})}),contentAutoWidth:!b,contentClasses:"Dropdown__menu--wrapper",contentStyles:{width:b?l(b):void 0},disabled:h,onMounted:()=>{K&&u&&-1!==$&&F($)},onOpenChange:O,placement:W,children:e("div",{className:r(["Dropdown__control",`Button--color--${f}`,h&&"Button--disabled",g&&"Dropdown__control--icon-only",w]),onClick:o=>{(!h||K)&&j?.(o)},onKeyDown:o=>{o.key!==t.Enter||h||j?.(o)},style:{width:l(E)},children:[y&&n(a,{className:"Dropdown__icon",name:y,rotation:v,spin:N}),!g&&e(o,{children:[n("span",{className:"Dropdown__selected-text",children:D||T&&m(T)||I}),!x&&n(a,{className:r(["Dropdown__icon","Dropdown__icon--arrow",B&&"over",K&&"open"]),name:"chevron-down"})]})]})}),_&&e(o,{children:[n(d,{className:"Dropdown__button",disabled:h,icon:"chevron-left",onClick:()=>{M("previous")}}),n(d,{className:"Dropdown__button",disabled:h,icon:"chevron-right",onClick:()=>{M("next")}})]})]})}export{p as Dropdown};
|