tgui-core 5.4.1 → 5.5.0
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.
|
@@ -11,39 +11,48 @@
|
|
|
11
11
|
* and update accordingly.
|
|
12
12
|
*
|
|
13
13
|
* @usage
|
|
14
|
+
*
|
|
15
|
+
* First, create an EventBus with the listeners you want to handle.
|
|
14
16
|
* ```ts
|
|
15
17
|
* const bus = new EventBus(listeners);
|
|
18
|
+
*```
|
|
16
19
|
*
|
|
17
|
-
*
|
|
20
|
+
* Next, define the listeners object. These are the event types and their
|
|
21
|
+
* corresponding callbacks.
|
|
22
|
+
* ```ts
|
|
18
23
|
* const listeners = {
|
|
19
|
-
* 'messageTypeA':
|
|
24
|
+
* 'messageTypeA': [handlerA, handlerB, handlerC],
|
|
20
25
|
* } as const;
|
|
26
|
+
*```
|
|
21
27
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
28
|
+
* Write a handler for the specific message type. They're handled serially.
|
|
29
|
+
* Anything you return will be passed to the next listener as the payload.
|
|
30
|
+
* ```ts
|
|
31
|
+
* function handlerA(payload: { text: string }) {
|
|
24
32
|
* logger.log(payload.text);
|
|
33
|
+
* // The payload is discarded!
|
|
25
34
|
* }
|
|
26
35
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* // Later, dispatch a message:
|
|
33
|
-
* const message: ByondMessage = {
|
|
34
|
-
* type: 'messageTypeA',
|
|
35
|
-
* payload: { text: 'Hello, world!' },
|
|
36
|
-
* };
|
|
36
|
+
* function handlerB(payload: { count: number }) {
|
|
37
|
+
* // The next handler will receive this object as its payload.
|
|
38
|
+
* return { count: payload.count + 1, otherData: 'foo' };
|
|
39
|
+
* }
|
|
37
40
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
41
|
+
* function handlerC(payload: { count: number; otherData: string }) {
|
|
42
|
+
* logger.log(`Count is ${payload.count} and otherData is ${payload.otherData}`);
|
|
43
|
+
* }
|
|
44
|
+
*```
|
|
40
45
|
*/
|
|
41
|
-
export declare class EventBus<TListeners extends Readonly<Record<string, (payload: unknown) => void
|
|
46
|
+
export declare class EventBus<TListeners extends Readonly<Record<string, Array<(payload: unknown) => void>>>> {
|
|
42
47
|
private listeners;
|
|
43
48
|
constructor(initialListeners: TListeners);
|
|
44
49
|
/** Dispatch a message to the appropriate listener. */
|
|
45
50
|
dispatch<TType extends keyof TListeners>(message: {
|
|
46
51
|
type: TType;
|
|
47
|
-
|
|
52
|
+
/**
|
|
53
|
+
* This should match the first listener's payload type. It can be passed
|
|
54
|
+
* along and mutated by each listener in the chain by returning a new value.
|
|
55
|
+
*/
|
|
56
|
+
payload?: Parameters<TListeners[TType][0]>[0];
|
|
48
57
|
}): void;
|
|
49
58
|
}
|
package/dist/common/eventbus.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class e{listeners={};constructor(e){this.listeners=e}dispatch(e){let t=this.listeners[e.type]?.length||0;if(0===t)return void console.warn(`EventBus: No listeners for message type "${String(e.type)}"`);let s=e.payload;for(let r=0;r<t;r++)s=this.listeners[e.type]?.[r](s)}}export{e as EventBus};
|
|
@@ -22,7 +22,7 @@ export { Image } from './Image';
|
|
|
22
22
|
export { ImageButton } from './ImageButton';
|
|
23
23
|
export { InfinitePlane } from './InfinitePlane';
|
|
24
24
|
export { Input } from './Input';
|
|
25
|
-
export { Interactive } from './Interactive';
|
|
25
|
+
export { type Interaction, Interactive } from './Interactive';
|
|
26
26
|
export { KeyListener } from './KeyListener';
|
|
27
27
|
export { Knob } from './Knob';
|
|
28
28
|
export { LabeledControls } from './LabeledControls';
|
package/package.json
CHANGED
package/styles/main.scss
CHANGED
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
@include meta.load-css("./components/BlockQuote.scss");
|
|
13
13
|
@include meta.load-css("./components/Button.scss");
|
|
14
14
|
@include meta.load-css("./components/ColorBox.scss");
|
|
15
|
-
@include meta.load-css("./components/ColorPicker.scss");
|
|
16
15
|
@include meta.load-css("./components/Dialog.scss");
|
|
17
16
|
@include meta.load-css("./components/Dimmer.scss");
|
|
18
17
|
@include meta.load-css("./components/Divider.scss");
|
|
@@ -1,153 +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
|
-
|
|
15
|
-
@use '../colors.scss';
|
|
16
|
-
@use '../base.scss';
|
|
17
|
-
|
|
18
|
-
.react-colorful {
|
|
19
|
-
position: relative;
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
width: 200px;
|
|
23
|
-
height: 200px;
|
|
24
|
-
user-select: none;
|
|
25
|
-
cursor: default;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.react-colorful__saturation_value {
|
|
29
|
-
position: relative;
|
|
30
|
-
flex-grow: 1;
|
|
31
|
-
border-color: transparent; /* Fixes https://github.com/omgovich/react-colorful/issues/139 */
|
|
32
|
-
border-bottom: 12px solid #000;
|
|
33
|
-
border-radius: 8px 8px 0 0;
|
|
34
|
-
background-image: linear-gradient(
|
|
35
|
-
to top,
|
|
36
|
-
rgba(0, 0, 0, 255),
|
|
37
|
-
rgba(0, 0, 0, 0)
|
|
38
|
-
),
|
|
39
|
-
linear-gradient(to right, rgba(255, 255, 255, 255), rgba(255, 255, 255, 0));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.react-colorful__pointer-fill,
|
|
43
|
-
.react-colorful__alpha-gradient {
|
|
44
|
-
content: '';
|
|
45
|
-
position: absolute;
|
|
46
|
-
left: 0;
|
|
47
|
-
top: 0;
|
|
48
|
-
right: 0;
|
|
49
|
-
bottom: 0;
|
|
50
|
-
pointer-events: none;
|
|
51
|
-
border-radius: inherit;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/* Improve elements rendering on light backgrounds */
|
|
55
|
-
.react-colorful__alpha-gradient,
|
|
56
|
-
.react-colorful__saturation_value {
|
|
57
|
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.react-colorful__hue,
|
|
61
|
-
.react-colorful__r,
|
|
62
|
-
.react-colorful__g,
|
|
63
|
-
.react-colorful__b,
|
|
64
|
-
.react-colorful__alpha,
|
|
65
|
-
.react-colorful__saturation,
|
|
66
|
-
.react-colorful__value {
|
|
67
|
-
position: relative;
|
|
68
|
-
height: 24px;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.react-colorful__hue {
|
|
72
|
-
background: linear-gradient(
|
|
73
|
-
to right,
|
|
74
|
-
#f00 0%,
|
|
75
|
-
#ff0 17%,
|
|
76
|
-
#0f0 33%,
|
|
77
|
-
#0ff 50%,
|
|
78
|
-
#00f 67%,
|
|
79
|
-
#f0f 83%,
|
|
80
|
-
#f00 100%
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.react-colorful__r {
|
|
85
|
-
background: linear-gradient(to right, #000, #f00);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.react-colorful__g {
|
|
89
|
-
background: linear-gradient(to right, #000, #0f0);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.react-colorful__b {
|
|
93
|
-
background: linear-gradient(to right, #000, #00f);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/* Round bottom corners of the last element: `Hue` for `ColorPicker` or `Alpha` for `AlphaColorPicker` */
|
|
97
|
-
.react-colorful__last-control {
|
|
98
|
-
border-radius: 0 0 8px 8px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.react-colorful__interactive {
|
|
102
|
-
position: absolute;
|
|
103
|
-
left: 0;
|
|
104
|
-
top: 0;
|
|
105
|
-
right: 0;
|
|
106
|
-
bottom: 0;
|
|
107
|
-
border-radius: inherit;
|
|
108
|
-
outline: none;
|
|
109
|
-
/* Don't trigger the default scrolling behavior when the event is originating from this element */
|
|
110
|
-
touch-action: none;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.react-colorful__pointer {
|
|
114
|
-
position: absolute;
|
|
115
|
-
z-index: 1;
|
|
116
|
-
box-sizing: border-box;
|
|
117
|
-
width: 28px;
|
|
118
|
-
height: 28px;
|
|
119
|
-
transform: translate(-50%, -50%);
|
|
120
|
-
background-color: #cfcfcf;
|
|
121
|
-
border: 2px solid #cfcfcf;
|
|
122
|
-
border-radius: 50%;
|
|
123
|
-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.react-colorful__interactive:focus .react-colorful__pointer {
|
|
127
|
-
transform: translate(-50%, -50%) scale(1.1);
|
|
128
|
-
background-color: #fff;
|
|
129
|
-
border-color: #fff;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/* Chessboard-like pattern for alpha related elements */
|
|
133
|
-
.react-colorful__alpha,
|
|
134
|
-
.react-colorful__alpha-pointer {
|
|
135
|
-
background-color: #fff;
|
|
136
|
-
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><rect x="8" width="8" height="8"/><rect y="8" width="8" height="8"/></svg>');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.react-colorful__saturation-pointer,
|
|
140
|
-
.react-colorful__value-pointer,
|
|
141
|
-
.react-colorful__hue-pointer,
|
|
142
|
-
.react-colorful__r-pointer,
|
|
143
|
-
.react-colorful__g-pointer,
|
|
144
|
-
.react-colorful__b-pointer {
|
|
145
|
-
z-index: 1;
|
|
146
|
-
width: 20px;
|
|
147
|
-
height: 20px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/* Display the saturation value pointer over the hue one */
|
|
151
|
-
.react-colorful__saturation_value-pointer {
|
|
152
|
-
z-index: 3;
|
|
153
|
-
}
|