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
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Component, type HTMLAttributes, type PropsWithChildren } from 'react';
|
|
2
|
-
type Props = {
|
|
3
|
-
acceptableDifference?: number;
|
|
4
|
-
maxFontSize: number;
|
|
5
|
-
maxWidth: number;
|
|
6
|
-
native?: HTMLAttributes<HTMLDivElement>;
|
|
7
|
-
} & PropsWithChildren;
|
|
8
|
-
type State = {
|
|
9
|
-
fontSize: number;
|
|
10
|
-
};
|
|
11
|
-
export declare class FitText extends Component<Props, State> {
|
|
12
|
-
ref: import("react").RefObject<HTMLDivElement | null>;
|
|
13
|
-
state: State;
|
|
14
|
-
constructor(props: Props);
|
|
15
|
-
componentDidUpdate(prevProps: any): void;
|
|
16
|
-
componentWillUnmount(): void;
|
|
17
|
-
resize(): void;
|
|
18
|
-
componentDidMount(): void;
|
|
19
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{Component as t,createRef as i}from"react";class s extends t{ref=i();state={fontSize:0};constructor(e){super(e),this.resize=this.resize.bind(this),window.addEventListener("resize",this.resize)}componentDidUpdate(e){e.children!==this.props.children&&this.resize()}componentWillUnmount(){window.removeEventListener("resize",this.resize)}resize(){let e=this.ref.current;if(!e)return;let t=this.props.maxWidth,i=0,s=this.props.maxFontSize;for(let r=0;r<10;r++){let r=Math.round((i+s)/2);e.style.fontSize=`${r}px`;let n=e.offsetWidth-t;if(n>0)s=r;else if(n<(this.props.acceptableDifference??5))i=r;else break}this.setState({fontSize:Math.round((i+s)/2)})}componentDidMount(){this.resize()}render(){return e("span",{ref:this.ref,style:{fontSize:`${this.state.fontSize}px`,..."object"==typeof this.props.native?.style?this.props.native.style:{}},children:this.props.children})}}export{s as FitText};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { BoxProps } from './Box';
|
|
2
|
-
export type FlexProps = Partial<{
|
|
3
|
-
/**
|
|
4
|
-
* Default alignment of all children.
|
|
5
|
-
*
|
|
6
|
-
* - `stretch` (default) - stretch to fill the container.
|
|
7
|
-
* - `start` - items are placed at the start of the cross axis.
|
|
8
|
-
* - `end` - items are placed at the end of the cross axis.
|
|
9
|
-
* - `center` - items are centered on the cross axis.
|
|
10
|
-
* - `baseline` - items are aligned such as their baselines align.
|
|
11
|
-
*/
|
|
12
|
-
align: string | boolean;
|
|
13
|
-
/**
|
|
14
|
-
* This establishes the main-axis, thus defining the direction flex items are placed in the flex container.
|
|
15
|
-
*
|
|
16
|
-
* - `row` (default) - left to right.
|
|
17
|
-
* - `row-reverse` - right to left.
|
|
18
|
-
* - `column` - top to bottom.
|
|
19
|
-
* - `column-reverse` - bottom to top.
|
|
20
|
-
*/
|
|
21
|
-
direction: string;
|
|
22
|
-
/** Makes flexbox container inline, with similar behavior to an `inline` property on a `Box`. */
|
|
23
|
-
inlineFlex: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* This defines the alignment along the main axis. It helps distribute extra free space leftover when either all the flex items on a line are
|
|
26
|
-
* inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow
|
|
27
|
-
* the line.
|
|
28
|
-
*
|
|
29
|
-
* - `flex-start` (default) - items are packed toward the start of the
|
|
30
|
-
* flex-direction.
|
|
31
|
-
* - `flex-end` - items are packed toward the end of the flex-direction.
|
|
32
|
-
* - `space-between` - items are evenly distributed in the line; first item is
|
|
33
|
-
* on the start line, last item on the end line
|
|
34
|
-
* - `space-around` - items are evenly distributed in the line with equal space
|
|
35
|
-
* around them. Note that visually the spaces aren't equal, since all the items
|
|
36
|
-
* have equal space on both sides. The first item will have one unit of space
|
|
37
|
-
* against the container edge, but two units of space between the next item
|
|
38
|
-
* because that next item has its own spacing that applies.
|
|
39
|
-
* - `space-evenly` - items are distributed so that the spacing between any two
|
|
40
|
-
* items (and the space to the edges) is equal.
|
|
41
|
-
*/
|
|
42
|
-
justify: string;
|
|
43
|
-
/** By default, flex items will all try to fit onto one line. You can change that and allow the items to wrap as needed with this property. */
|
|
44
|
-
scrollable: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* This defines the alignment along the cross axis. It helps distribute extra free space leftover when either all the flex items on a line are
|
|
47
|
-
* inflexible, or are flexible but have reached their maximum size. It also exerts some control over the alignment of items when they overflow
|
|
48
|
-
* the line.
|
|
49
|
-
*
|
|
50
|
-
* - `nowrap` (default) - all flex items will be on one line
|
|
51
|
-
* - `wrap` - flex items will wrap onto multiple lines, from top to bottom.
|
|
52
|
-
* - `wrap-reverse` - flex items will wrap onto multiple lines from bottom to top.
|
|
53
|
-
*/
|
|
54
|
-
wrap: string | boolean;
|
|
55
|
-
}> & BoxProps;
|
|
56
|
-
export declare function computeFlexClassName(props: FlexProps): string;
|
|
57
|
-
export declare function computeFlexProps(props: FlexProps): Record<string, any>;
|
|
58
|
-
/**
|
|
59
|
-
* ## Flex
|
|
60
|
-
*
|
|
61
|
-
* Quickly manage the layout, alignment, and sizing of grid columns, navigation,
|
|
62
|
-
* components, and more with a full suite of responsive flexbox utilities.
|
|
63
|
-
*
|
|
64
|
-
* If you are new to or unfamiliar with flexbox, we encourage you to read this
|
|
65
|
-
* [CSS-Tricks flexbox guide](https://css-tricks.com/snippets/css/a-guide-to-flexbox/).
|
|
66
|
-
*
|
|
67
|
-
* Consists of two elements: `<Flex>` and `<Flex.Item>`. Both of them provide
|
|
68
|
-
* the most straight-forward mapping to flex CSS properties as possible.
|
|
69
|
-
*
|
|
70
|
-
* One of the most basic usage of flex, is to align certain elements
|
|
71
|
-
* to the left, and certain elements to the right:
|
|
72
|
-
*
|
|
73
|
-
* Example:
|
|
74
|
-
*
|
|
75
|
-
* ```tsx
|
|
76
|
-
* <Flex>
|
|
77
|
-
* <Flex.Item grow>Button description</Flex.Item>
|
|
78
|
-
* <Flex.Item>
|
|
79
|
-
* <Button>Perform an action</Button>
|
|
80
|
-
* </Flex.Item>
|
|
81
|
-
* </Flex>
|
|
82
|
-
* ```
|
|
83
|
-
*
|
|
84
|
-
* Flex item with `grow` property will grow to take all available empty space,
|
|
85
|
-
* while flex items without grow will take the minimum amount of space. This
|
|
86
|
-
* effectively places the last flex item to the very end of the flex container.
|
|
87
|
-
*
|
|
88
|
-
* @deprecated - Use
|
|
89
|
-
* [Stack](https://github.com/tgstation/tgui-core/tree/main/lib/components/Stack.tsx)
|
|
90
|
-
* where possible.
|
|
91
|
-
*
|
|
92
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-flex--docs)
|
|
93
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
94
|
-
*/
|
|
95
|
-
export declare function Flex(props: any): import("react/jsx-runtime").JSX.Element;
|
|
96
|
-
export declare namespace Flex {
|
|
97
|
-
var Item: typeof FlexItem;
|
|
98
|
-
}
|
|
99
|
-
export declare function computeFlexItemClassName(props: FlexItemProps): string;
|
|
100
|
-
export type FlexItemProps = Partial<{
|
|
101
|
-
/** This allows the default alignment (or the one specified by align-items) to be overridden for individual flex items. */
|
|
102
|
-
align: string | boolean;
|
|
103
|
-
/**
|
|
104
|
-
* This defines the default size of an element
|
|
105
|
-
* before any flex-related calculations are done. Has to be a length
|
|
106
|
-
* (e.g. `20%`, `5rem`), an `auto` or `content` keyword.
|
|
107
|
-
*
|
|
108
|
-
* - **Important:** IE11 flex is buggy, and auto width/height calculations
|
|
109
|
-
* can sometimes end up in a circular dependency. This usually happens, when
|
|
110
|
-
* working with tables inside flex (they have wacky internal widths and such).
|
|
111
|
-
* Setting basis to `0` breaks the loop and fixes all of the problems.
|
|
112
|
-
*/
|
|
113
|
-
basis: string | number;
|
|
114
|
-
/**
|
|
115
|
-
* This defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion.
|
|
116
|
-
* It dictates what amount of the available space inside the flex container the item should take up.
|
|
117
|
-
* This number is unit-less and is relative to other siblings.
|
|
118
|
-
*/
|
|
119
|
-
grow: number | boolean;
|
|
120
|
-
/**
|
|
121
|
-
* By default, flex items are laid out in the source order. However, the order property controls the order in which they appear in the
|
|
122
|
-
* flex container
|
|
123
|
-
*/
|
|
124
|
-
order: number;
|
|
125
|
-
/** This defines the ability for a flex item to shrink if necessary. Inverse of `grow`. */
|
|
126
|
-
shrink: number | boolean;
|
|
127
|
-
}> & BoxProps;
|
|
128
|
-
export declare function computeFlexItemProps(props: FlexItemProps): Record<string, any>;
|
|
129
|
-
declare function FlexItem(props: any): import("react/jsx-runtime").JSX.Element;
|
|
130
|
-
export {};
|
package/dist/components/Flex.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{classes as t}from"../common/react.js";import{computeBoxClassName as r,computeBoxProps as n,unit as o}from"../common/ui.js";function i(e){return t(["Flex",e.inlineFlex&&"Flex--inline",r(e)])}function l(e){let{direction:t,wrap:r,align:o,justify:i,...l}=e;return n({style:{...l.style,alignItems:o,flexDirection:t,flexWrap:!0===r?"wrap":r,justifyContent:i},...l})}function m(r){let{className:n,...o}=r;return e("div",{className:t([n,i(o)]),...l(o)})}function u(e){return t(["Flex__item",r(e)])}function s(e){let{style:t,grow:r,order:i,shrink:l,basis:m,align:u,...s}=e,c=m??e.width??(void 0!==r?0:void 0);return n({style:{...t,alignSelf:u,flexBasis:o(c),flexGrow:void 0!==r&&Number(r),flexShrink:void 0!==l&&Number(l),order:i},...s})}m.Item=function(r){let{className:n,...o}=r;return e("div",{className:t([n,u(r)]),...s(o)})};export{m as Flex,i as computeFlexClassName,u as computeFlexItemClassName,s as computeFlexItemProps,l as computeFlexProps};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { type BooleanLike } from '../common/react.ts';
|
|
2
|
-
import { type Placement } from '@floating-ui/react';
|
|
3
|
-
import { type CSSProperties, type ReactNode } from 'react';
|
|
4
|
-
type Props = {
|
|
5
|
-
/** Interacting with this element will open the floating element. */
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
/** The content to display like floating. */
|
|
8
|
-
content: ReactNode;
|
|
9
|
-
} & Partial<{
|
|
10
|
-
/**
|
|
11
|
-
* Where the content will be displayed, relative to children.
|
|
12
|
-
* - See [Placement](https://floating-ui.com/docs/useFloating#placement)
|
|
13
|
-
* @default 'bottom'
|
|
14
|
-
*/
|
|
15
|
-
placement: Placement;
|
|
16
|
-
/** Classes with will be applied to the content. */
|
|
17
|
-
contentClasses: string;
|
|
18
|
-
/** Inline styles with will be applied to the content. */
|
|
19
|
-
contentStyles: CSSProperties;
|
|
20
|
-
/** Use calculated by Floating UI children width as content width. */
|
|
21
|
-
contentAutoWidth: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Indentation of content element from children.
|
|
24
|
-
* @default 6
|
|
25
|
-
*/
|
|
26
|
-
contentOffset: number;
|
|
27
|
-
/** Disables all interactions. */
|
|
28
|
-
disabled: BooleanLike;
|
|
29
|
-
/**
|
|
30
|
-
* How long the animation takes in ms.
|
|
31
|
-
* - If specified, default animation will be disabled.
|
|
32
|
-
* - Fully disables animations if 0
|
|
33
|
-
* @default 200
|
|
34
|
-
*/
|
|
35
|
-
animationDuration: number;
|
|
36
|
-
/** Direct content open state control. */
|
|
37
|
-
handleOpen: boolean;
|
|
38
|
-
/** Content will open when you hover over children. */
|
|
39
|
-
hoverOpen: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Delay in ms before opening and closing the content.
|
|
42
|
-
* - Works only if used `hoverOpen` prop.
|
|
43
|
-
* @default 200
|
|
44
|
-
*/
|
|
45
|
-
hoverDelay: number;
|
|
46
|
-
/**
|
|
47
|
-
* Content will not close if the mouse moves out of the children while
|
|
48
|
-
* trying to move into the content.
|
|
49
|
-
* - Works only if used `hoverOpen` prop.
|
|
50
|
-
*/
|
|
51
|
-
hoverSafePolygon: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Whitelisted classes.
|
|
54
|
-
* Used to allow to add some secured classes,
|
|
55
|
-
* click on which will not close the content.
|
|
56
|
-
* - Classes must be sent like this: `".class1, .class2"`
|
|
57
|
-
*/
|
|
58
|
-
allowedOutsideClasses: string;
|
|
59
|
-
/** Do not wrap content in FloatingPortal, thus preventing it from moving into the body */
|
|
60
|
-
preventPortal: true;
|
|
61
|
-
/** Stops event propagation on children. */
|
|
62
|
-
stopChildPropagation: boolean;
|
|
63
|
-
/** Close the content after interaction with it. */
|
|
64
|
-
closeAfterInteract: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Called when the open state changes.
|
|
67
|
-
* Returns the new open state.
|
|
68
|
-
* Can be used this way:
|
|
69
|
-
* ```tsx
|
|
70
|
-
* onOpenChange={open ? makeThingsOnOpen : makeThingsOnClose}
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
onOpenChange: (open: boolean) => void;
|
|
74
|
-
/**
|
|
75
|
-
* Called when mounted
|
|
76
|
-
*/
|
|
77
|
-
onMounted: () => void;
|
|
78
|
-
}>;
|
|
79
|
-
/**
|
|
80
|
-
* ## Floating
|
|
81
|
-
*
|
|
82
|
-
* Floating lets you position elements so that they don't go out of the bounds of the window.
|
|
83
|
-
*
|
|
84
|
-
* - [Documentation](https://floating-ui.com/docs/react) for more information.
|
|
85
|
-
*/
|
|
86
|
-
export declare function Floating(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
87
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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 r,autoUpdate as i,flip as a,offset as l,safePolygon as s,shift as c,size as d,useClick as m,useDismiss as p,useFloating as g,useHover as f,useInteractions as h,useTransitionStatus as u}from"@floating-ui/react";import{cloneElement as C,isValidElement as v,useEffect as w,useState as F}from"react";function b(b){let x,{allowedOutsideClasses:y,animationDuration:O,children:R,closeAfterInteract:j,content:k,contentAutoWidth:z,contentClasses:E,contentOffset:M=6,contentStyles:P,disabled:S,hoverDelay:q,hoverOpen:I,hoverSafePolygon:N,handleOpen:$,onMounted:A,placement:B,preventPortal:D,stopChildPropagation:G,onOpenChange:H}=b,[J,K]=F(!1),{refs:L,floatingStyles:Q,context:T}=g({middleware:[l(M),a({padding:6}),c(),z&&d({apply({rects:e,elements:t}){t.floating.style.width=`${e.reference.width}px`}})],onOpenChange(e){K(e),H?.(e)},open:J,placement:B||"bottom",transform:!1,whileElementsMounted:(e,t,n)=>(void 0!==A&&A(),i(e,t,n,{ancestorResize:!1,ancestorScroll:!1,elementResize:!1}))}),{isMounted:U,status:V}=u(T,{duration:O||200}),W=p(T,{ancestorScroll:!0,outsidePress:e=>!y||e.target instanceof Element&&!e.target.closest(y)}),X=m(T,{enabled:!S}),Y=f(T,{enabled:!S,restMs:q||200,handleClose:N?s({requireIntent:!1}):null}),Z=void 0!==$,{getReferenceProps:_,getFloatingProps:ee}=h(Z?[]:[W,I?Y:X]),et=_({ref:L.setReference,...G&&{onClick:e=>e.stopPropagation()}}),en=ee({onClick:()=>{j&&T.onOpenChange(!1)},ref:L.setFloating});w(()=>{Z&&T.onOpenChange($)},[$]),x=v(R)?C(R,et):t("div",{...et,children:R});let eo=t("div",{className:o(["Floating",!O&&"Floating--animated",E]),"data-position":T.placement,"data-transition":V,style:{...Q,...P},...en,children:k});return n(e,{children:[x,U&&!!k&&(D?eo:t(r,{id:"tgui-root",children:eo}))]})}export{b as Floating};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type BooleanLike } from '../common/react.ts';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
type Props = {
|
|
4
|
-
/** Icon name. @see https://fontawesome.com/v6/search?o=r&m=free */
|
|
5
|
-
name: string;
|
|
6
|
-
} & Partial<{
|
|
7
|
-
/** Icon rotation, in degrees. */
|
|
8
|
-
rotation: number;
|
|
9
|
-
/** Icon size. `1` is normal size, `2` is two times bigger. Fractional numbers are supported. */
|
|
10
|
-
size: number;
|
|
11
|
-
/** Whether an icon should be spinning. Good for load indicators. */
|
|
12
|
-
spin: BooleanLike;
|
|
13
|
-
}> & Omit<BoxProps, 'children'>;
|
|
14
|
-
export declare function Icon(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
type IconStackProps = {
|
|
16
|
-
/** Works same as `Icon` size prop, but for all icons inside. */
|
|
17
|
-
size?: number;
|
|
18
|
-
};
|
|
19
|
-
declare function IconStack(props: BoxProps & IconStackProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
/**
|
|
21
|
-
* ## Icon
|
|
22
|
-
*
|
|
23
|
-
* Renders one of the FontAwesome icons of your choice.
|
|
24
|
-
*
|
|
25
|
-
* Example:
|
|
26
|
-
*
|
|
27
|
-
* ```tsx
|
|
28
|
-
* <Icon name="plus" />
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* Icons: https://fontawesome.com/v6/search?o=r&m=free
|
|
32
|
-
*
|
|
33
|
-
* - [View documentation on tgui core](http://localhost:6006/?path=/docs/components-icon--docs)
|
|
34
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
35
|
-
*/
|
|
36
|
-
export declare namespace Icon {
|
|
37
|
-
/**
|
|
38
|
-
* ## Icon.Stack
|
|
39
|
-
* Renders children icons on top of each other in order to make your own icon.
|
|
40
|
-
*
|
|
41
|
-
* Example:
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
* ```tsx
|
|
45
|
-
* <Icon.Stack>
|
|
46
|
-
* <Icon name="pen" />
|
|
47
|
-
* <Icon name="slash" />
|
|
48
|
-
* </Icon.Stack>
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
const Stack: typeof IconStack;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
package/dist/components/Icon.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as t}from"react/jsx-runtime";import{classes as e}from"../common/react.js";import{computeBoxClassName as o,computeBoxProps as r}from"../common/ui.js";let s=/-o$/;function a(a){let{name:n="",size:c,spin:i,className:f,rotation:l,...m}=a,p=m.style||{};c&&(p.fontSize=`${100*c}%`),l&&(p.transform=`rotate(${l}deg)`),m.style=p;let u=r(m),I="";if(n.startsWith("tg-"))I=n;else{let t=s.test(n),e=n.replace(s,""),o=!e.startsWith("fa-");I=t?"far ":"fas ",o&&(I+="fa-"),I+=e,i&&(I+=" fa-spin")}return t("i",{className:e(["Icon",I,f,o(m)]),...u})}(a||(a={})).Stack=function(s){let{className:a,children:n,size:c,...i}=s,f=i.style||{};return c&&(f.fontSize=`${100*c}%`),i.style=f,t("span",{className:e(["IconStack",a,o(i)]),...r(i),children:n})};export{a as Icon};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { BoxProps } from './Box';
|
|
2
|
-
type Props = Partial<{
|
|
3
|
-
/** True is default, this fixes DM icon rendering issues */
|
|
4
|
-
fixBlur: boolean;
|
|
5
|
-
/**
|
|
6
|
-
* False by default. Good if you're fetching images on UIs that do not auto
|
|
7
|
-
* update. This will attempt to fix the 'x' icon 5 times.
|
|
8
|
-
*/
|
|
9
|
-
fixErrors: boolean;
|
|
10
|
-
/** Fill is default. */
|
|
11
|
-
objectFit: 'contain' | 'cover';
|
|
12
|
-
/**
|
|
13
|
-
* The image source.
|
|
14
|
-
*
|
|
15
|
-
* Use transparent base64 pixel if there is no src so we don't get a broken
|
|
16
|
-
* image icon when using assets.
|
|
17
|
-
*/
|
|
18
|
-
src: string;
|
|
19
|
-
}> & BoxProps;
|
|
20
|
-
/**
|
|
21
|
-
* ## Image
|
|
22
|
-
*
|
|
23
|
-
* A wrapper for the `<img>` element.
|
|
24
|
-
*
|
|
25
|
-
* It can attempt to fix broken images by fetching them again with `fixErrors`.
|
|
26
|
-
*
|
|
27
|
-
* It will also try to fix blurry images by rendering them pixelated.
|
|
28
|
-
*/
|
|
29
|
-
export declare function Image(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
export {};
|
package/dist/components/Image.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{computeBoxProps as e}from"../common/ui.js";import{useEffect as t,useRef as A}from"react";function n(n){let{fixBlur:u=!0,fixErrors:c,objectFit:i="fill",src:m="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",...o}=n,a=A(0),l=A(null),g=e(o);return g.style={...g.style,imageRendering:u?"pixelated":"auto",objectFit:i},t(()=>()=>{l.current&&clearTimeout(l.current)},[]),r("img",{alt:"dm icon",onError:function(r){if(!c||a.current>=5){l.current&&clearTimeout(l.current);return}let e=r.currentTarget;l.current=setTimeout(()=>{e.src=`${m}?attempt=${a.current}`,a.current++},1e3)},src:m,...g})}export{n as Image};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @copyright 2024 Aylong (https://github.com/AyIong)
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
import { type BooleanLike } from '../common/react.ts';
|
|
7
|
-
import type { Placement } from '@floating-ui/react';
|
|
8
|
-
import type { ReactNode } from 'react';
|
|
9
|
-
import type { BoxProps } from './Box';
|
|
10
|
-
import { type Direction } from './DmIcon';
|
|
11
|
-
type Props = Partial<{
|
|
12
|
-
/** Asset cache. Example: `asset={['assetname32x32', thing.key]}` */
|
|
13
|
-
asset: string[];
|
|
14
|
-
/**
|
|
15
|
-
* Asset size. Used for asset scaling. Example: `assetSize={32}`
|
|
16
|
-
* With that, you can use `imageSize` to set asset image size in px.
|
|
17
|
-
* By default, it's 32px. So if you have 32x32 you don't need to touch it.
|
|
18
|
-
*/
|
|
19
|
-
assetSize: number;
|
|
20
|
-
/** Classic way to put images. Example: `base64={thing.image}` */
|
|
21
|
-
base64: string;
|
|
22
|
-
/**
|
|
23
|
-
* Special container for buttons.
|
|
24
|
-
* You can put any other component here.
|
|
25
|
-
* Has some special stylings!
|
|
26
|
-
* Example: `buttons={<Button>Send</Button>}`
|
|
27
|
-
*/
|
|
28
|
-
buttons: ReactNode;
|
|
29
|
-
/**
|
|
30
|
-
* Same as buttons, but. Have disabled pointer-events on content inside if non-fluid.
|
|
31
|
-
* Fluid version have humburger layout.
|
|
32
|
-
* Can be used with buttons prop.
|
|
33
|
-
*/
|
|
34
|
-
buttonsAlt: ReactNode;
|
|
35
|
-
/** Content under image. Or on the right if fluid. */
|
|
36
|
-
children: ReactNode;
|
|
37
|
-
/** Applies a CSS class to the element. */
|
|
38
|
-
className: string;
|
|
39
|
-
/**
|
|
40
|
-
* Color of the button. See
|
|
41
|
-
* [Button](https://github.com/tgstation/tgui-core/tree/main/lib/components/Button.tsx)
|
|
42
|
-
* but without `transparent`.
|
|
43
|
-
*/
|
|
44
|
-
color: string;
|
|
45
|
-
/** Makes button disabled and dark red if true. Also disables onClick. */
|
|
46
|
-
disabled: BooleanLike;
|
|
47
|
-
/** Optional. Replaces default "stub" when loading DmIcon. */
|
|
48
|
-
dmFallback: ReactNode;
|
|
49
|
-
/** Parameter `icon` of component `DmIcon`. */
|
|
50
|
-
dmIcon: string | null;
|
|
51
|
-
/** Parameter `icon_state` of component `DmIcon`. */
|
|
52
|
-
dmIconState: string | null;
|
|
53
|
-
/** Parameter `direction` of component `DmIcon`. */
|
|
54
|
-
dmDirection: Direction;
|
|
55
|
-
/**
|
|
56
|
-
* Changes the layout of the button, making it fill the entire horizontally available space.
|
|
57
|
-
* Allows the use of `title`
|
|
58
|
-
*/
|
|
59
|
-
fluid: boolean;
|
|
60
|
-
/** Replaces default "question" icon when image missing. */
|
|
61
|
-
fallbackIcon: string;
|
|
62
|
-
/** Parameter responsible for the size of the image, component and standard "stubs". */
|
|
63
|
-
imageSize: number;
|
|
64
|
-
/** Prop `src` of Image component. Example: `imageSrc={resolveAsset(thing.image)}` */
|
|
65
|
-
imageSrc: string;
|
|
66
|
-
/** Called when button is clicked with LMB. */
|
|
67
|
-
onClick: (e: any) => void;
|
|
68
|
-
/** Called when button is clicked with RMB. */
|
|
69
|
-
onRightClick: (e: any) => void;
|
|
70
|
-
/** Makes button selected and green if true. */
|
|
71
|
-
selected: BooleanLike;
|
|
72
|
-
/** Requires `fluid` for work. Bold text with divider betwen content. */
|
|
73
|
-
title: string;
|
|
74
|
-
/** A fancy, boxy tooltip, which appears when hovering over the button */
|
|
75
|
-
tooltip: ReactNode;
|
|
76
|
-
/** Position of the tooltip. Does not guarantee the position is respected. */
|
|
77
|
-
tooltipPosition: Placement;
|
|
78
|
-
}> & BoxProps;
|
|
79
|
-
/**
|
|
80
|
-
* ## ImageButton
|
|
81
|
-
*
|
|
82
|
-
* Stylized button, with the ability to easily and simply insert any picture into it.
|
|
83
|
-
* - Without image, will be default question icon.
|
|
84
|
-
* - If an image is specified but for some reason cannot be displayed, there will be a spinner fallback until it is loaded.
|
|
85
|
-
*
|
|
86
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-imagebutton--docs)
|
|
87
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
88
|
-
*/
|
|
89
|
-
export declare function ImageButton(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
90
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{classes as n}from"../common/react.js";import{computeBoxProps as o}from"../common/ui.js";import{DmIcon as a}from"./DmIcon.js";import{Icon as i}from"./Icon.js";import{Image as m}from"./Image.js";import{Tooltip as s}from"./Tooltip.js";function c(i){let{asset:c,assetSize:r=32,base64:u,buttons:p,buttonsAlt:d,children:g,className:_,color:h,disabled:I,dmFallback:B,dmIcon:f,dmIconState:x,fluid:$,fallbackIcon:y,imageSize:N=64,imageSrc:b,onClick:v,onRightClick:w,selected:j,title:k,tooltip:z,tooltipPosition:D,...C}=i,q=e("div",{className:"ImageButton__container",onClick:t=>{!I&&v&&v(t)},onContextMenu:t=>{t.preventDefault(),!I&&w&&w(t)},onKeyDown:t=>{"Enter"===t.key&&!I&&v&&v(t)},style:{width:$?"auto":`calc(${N}px + 0.5em + 2px)`},tabIndex:I?void 0:0,children:[t("div",{className:"ImageButton__image",children:u||b?t(m,{height:`${N}px`,src:u?`data:image/png;base64,${u}`:b,width:`${N}px`}):f&&x?t(a,{fallback:B||t(l,{icon:"spinner",size:N,spin:!0}),height:`${N}px`,icon:f,icon_state:x,width:`${N}px`}):c?t(m,{className:n(c||[]),height:`${N}px`,style:{transform:`scale(${N/r})`,transformOrigin:"top left"},width:`${N}px`}):t(l,{icon:y||"question",size:N})}),$&&(k||g)?e("div",{className:"ImageButton__content",children:[k&&t("span",{className:n(["ImageButton__content--title",!!g&&"ImageButton__content--divider"]),children:k}),g&&t("span",{className:"ImageButton__content--text",children:g})]}):g&&t("span",{className:"ImageButton__content",children:g})]});return z&&(q=t(s,{content:z,position:D,children:q})),e("div",{className:n(["ImageButton",$&&"ImageButton--fluid",j&&"ImageButton--selected",I&&"ImageButton--disabled",!g&&"ImageButton--empty",!(v||w)&&"ImageButton--noAction",h&&"string"==typeof h?`ImageButton__color--${h}`:"ImageButton__color--default",_]),...o(C),children:[q,p&&t("div",{className:n(["ImageButton__buttons",!g&&"ImageButton__buttons--empty"]),style:{width:"auto"},children:p}),d&&t("div",{className:n(["ImageButton__buttons","ImageButton__buttons--alt",!g&&"ImageButton__buttons--empty"]),style:{maxWidth:$?"auto":`calc(${N}px + 0.5em)`,width:`calc(${N}px + ${.5*!$}em)`},children:d})]})}function l(e){let{icon:n,spin:o,size:a=64}=e;return t(i,{className:"ImageButton__image--fallback",height:`${a}px`,name:n,spin:o,style:{fontSize:`${a}px`},width:`${a}px`})}export{c as ImageButton};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type PropsWithChildren } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
type Props = {
|
|
4
|
-
/** The width of the image to display. */
|
|
5
|
-
imageWidth: number;
|
|
6
|
-
} & Partial<{
|
|
7
|
-
/** The background image to display. */
|
|
8
|
-
backgroundImage: string;
|
|
9
|
-
/** The initial left position of the image. */
|
|
10
|
-
initialLeft: number;
|
|
11
|
-
/** The initial top position of the image. */
|
|
12
|
-
initialTop: number;
|
|
13
|
-
/** Padding applied to the right of the zoom controls */
|
|
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;
|
|
34
|
-
/** A callback function that is called when the background image is moved. */
|
|
35
|
-
onBackgroundMoved: (newX: number, newY: number) => void;
|
|
36
|
-
/** A callback function that is called when the zoom value changes. */
|
|
37
|
-
onZoomChange: (newZoomValue: number) => void;
|
|
38
|
-
}> & BoxProps & PropsWithChildren;
|
|
39
|
-
/**
|
|
40
|
-
* ## InfinitePlane
|
|
41
|
-
*
|
|
42
|
-
* Creates a scrolling infinite plane using a background image.
|
|
43
|
-
*
|
|
44
|
-
* Example:
|
|
45
|
-
*
|
|
46
|
-
* ```tsx
|
|
47
|
-
* <InfinitePlane imageWidth={100} backgroundImage="https://example.com/image.png">
|
|
48
|
-
* <Box position="absolute" top={0} left={0}>
|
|
49
|
-
* Hello, world!
|
|
50
|
-
* </Box>
|
|
51
|
-
* <Box position="absolute" top={0} left={100}>
|
|
52
|
-
* Hello, world!
|
|
53
|
-
* </Box>
|
|
54
|
-
* <Box position="absolute" top={0} left={200}>
|
|
55
|
-
* Hello, world!
|
|
56
|
-
* </Box>
|
|
57
|
-
* </InfinitePlane>
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-infiniteplane--docs)
|
|
61
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
62
|
-
*/
|
|
63
|
-
export declare function InfinitePlane(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
64
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
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,98 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from 'react';
|
|
2
|
-
import type { BoxProps } from './Box';
|
|
3
|
-
export type BaseInputProps<TElement = HTMLInputElement> = Partial<{
|
|
4
|
-
/** Automatically focuses the input on mount */
|
|
5
|
-
autoFocus: boolean;
|
|
6
|
-
/** Automatically selects the input value on focus */
|
|
7
|
-
autoSelect: boolean;
|
|
8
|
-
/** Custom css classes */
|
|
9
|
-
className: string;
|
|
10
|
-
/** Disables the input. Outlined in gray */
|
|
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;
|
|
21
|
-
/** Fills the parent container */
|
|
22
|
-
fluid: boolean;
|
|
23
|
-
/** Mark this if you want to use a monospace font */
|
|
24
|
-
monospace: boolean;
|
|
25
|
-
/** Allows to toggle on spellcheck on inputs */
|
|
26
|
-
spellcheck: boolean;
|
|
27
|
-
}> & BoxProps<TElement>;
|
|
28
|
-
export type TextInputProps<TElement = HTMLInputElement> = Partial<{
|
|
29
|
-
/** The maximum length of the input value */
|
|
30
|
-
maxLength: number;
|
|
31
|
-
/** Fires each time focus leaves the input, including if Esc or Enter are pressed */
|
|
32
|
-
onBlur: (value: string) => void;
|
|
33
|
-
/** Fires each time the input has been changed */
|
|
34
|
-
onChange: (value: string) => void;
|
|
35
|
-
/** Fires once the enter key is pressed */
|
|
36
|
-
onEnter: (value: string) => void;
|
|
37
|
-
/** Fires once the escape key is pressed */
|
|
38
|
-
onEscape: (value: string) => void;
|
|
39
|
-
/** The placeholder text when everything is cleared */
|
|
40
|
-
placeholder: string;
|
|
41
|
-
/** Clears the input value on enter */
|
|
42
|
-
selfClear: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Generally, input can handle its own state value. You might not NEED this.
|
|
45
|
-
*
|
|
46
|
-
* Use this if you want to hold the value in the parent for external
|
|
47
|
-
* manipulation. For instance:
|
|
48
|
-
*
|
|
49
|
-
* Clearing the input
|
|
50
|
-
*
|
|
51
|
-
* ```tsx
|
|
52
|
-
* const [value, setValue] = useState('');
|
|
53
|
-
*
|
|
54
|
-
* return (
|
|
55
|
-
* <>
|
|
56
|
-
* <Button onClick={() => act('inputVal', {inputVal: value})}>
|
|
57
|
-
* Submit
|
|
58
|
-
* </Button>
|
|
59
|
-
* <Input
|
|
60
|
-
* value={value}
|
|
61
|
-
* onChange={setValue} />
|
|
62
|
-
* <Button onClick={() => setValue('')}>
|
|
63
|
-
* Clear
|
|
64
|
-
* </Button>
|
|
65
|
-
* </>
|
|
66
|
-
* )
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* Updating the value from the backend
|
|
70
|
-
*
|
|
71
|
-
* ```tsx
|
|
72
|
-
* const { data } = useBackend<Data>();
|
|
73
|
-
* const { valveSetting } = data;
|
|
74
|
-
*
|
|
75
|
-
* return (
|
|
76
|
-
* <Input
|
|
77
|
-
* value={valveSetting}
|
|
78
|
-
* onEnter={(value) => act('submit', { valveSetting: value })}
|
|
79
|
-
* />
|
|
80
|
-
* )
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
value: string;
|
|
84
|
-
}> & BaseInputProps<TElement>;
|
|
85
|
-
type Props = Partial<{
|
|
86
|
-
/** Ref of the input element */
|
|
87
|
-
ref: RefObject<HTMLInputElement | null>;
|
|
88
|
-
}> & BaseInputProps & TextInputProps;
|
|
89
|
-
/**
|
|
90
|
-
* ## Input
|
|
91
|
-
*
|
|
92
|
-
* A basic text input which allow users to enter text into a UI.
|
|
93
|
-
*
|
|
94
|
-
* - [View documentation on tgui core](https://tgstation.github.io/tgui-core/?path=/docs/components-input--docs)
|
|
95
|
-
* - [View inherited Box props](https://tgstation.github.io/tgui-core/?path=/docs/components-box--docs)
|
|
96
|
-
*/
|
|
97
|
-
export declare function Input(props: Props): import("react/jsx-runtime").JSX.Element;
|
|
98
|
-
export {};
|
package/dist/components/Input.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{KEY as t,isEscape as r}from"../common/keys.js";import{classes as n}from"../common/react.js";import{debounce as u}from"../common/timer.js";import{computeBoxClassName as o,computeBoxProps as m}from"../common/ui.js";import{useEffect as c,useRef as l,useState as a}from"react";let i=u(e=>e(),250);function p(u){let{autoFocus:p,autoSelect:f,className:s,disabled:d,expensive:g,fluid:v,maxLength:T,monospace:j,onBlur:y,onChange:I,onEnter:b,onEscape:h,onKeyDown:k,placeholder:x,ref:C,selfClear:D,spellcheck:E=!1,value:w,...B}=u,K=l(null),L=C??K,[N,q]=a(w??"");c(()=>{let e;return(p||f)&&(e=setTimeout(()=>{L.current?.focus(),f&&L.current?.select()},1)),()=>clearTimeout(e)},[]),c(()=>{L.current&&document.activeElement!==L.current&&w!==N&&q(w??"")},[w]);let z=m(B),A=n(["Input",d&&"Input--disabled",v&&"Input--fluid",j&&"Input--monospace",o(B),s]);return e("input",{...z,autoComplete:"off",className:A,disabled:d,maxLength:T,onBlur:()=>y?.(N),onChange:function(e){let t=e.currentTarget.value;q(t),g?i(()=>I?.(t)):I?.(t)},onKeyDown:function(e){if(k?.(e),e.key===t.Enter){e.preventDefault(),b?.(e.currentTarget.value),D&&q(""),e.currentTarget.blur();return}r(e.key)&&(e.preventDefault(),h?.(e.currentTarget.value),e.currentTarget.blur())},placeholder:x,ref:L,spellCheck:E,type:"text",value:N})}export{p as Input};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT License
|
|
3
|
-
* https://github.com/omgovich/react-colorful/
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2020 Vlad Shilov <omgovich@ya.ru>
|
|
6
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
7
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
8
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
9
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
10
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
11
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
12
|
-
* SOFTWARE.
|
|
13
|
-
*/
|
|
14
|
-
import type { CSSProperties, ReactNode, RefObject } from 'react';
|
|
15
|
-
export type Interaction = {
|
|
16
|
-
left: number;
|
|
17
|
-
top: number;
|
|
18
|
-
};
|
|
19
|
-
export type InteractiveProps = {
|
|
20
|
-
/** Callback when interaction moves */
|
|
21
|
-
onMove: (interaction: Interaction) => void;
|
|
22
|
-
/** Callback when key is pressed */
|
|
23
|
-
onKey: (offset: Interaction) => void;
|
|
24
|
-
/** Child elements */
|
|
25
|
-
children: ReactNode;
|
|
26
|
-
/** Ref to the container element */
|
|
27
|
-
containerRef: RefObject<HTMLDivElement | null>;
|
|
28
|
-
/** Optional styles */
|
|
29
|
-
style?: CSSProperties;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* ## Interactive
|
|
33
|
-
*
|
|
34
|
-
* A low-level component that handles pointer and keyboard interactions.
|
|
35
|
-
*
|
|
36
|
-
* See an example of usage in the story:
|
|
37
|
-
* - [View Colorpicker story](https://tgstation.github.io/tgui-core/?path=/story/interfaces-colorpickermodal--default)
|
|
38
|
-
*/
|
|
39
|
-
export declare function Interactive(props: InteractiveProps): import("react/jsx-runtime").JSX.Element;
|