@rbxts-ui/components 2.0.0 → 3.0.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.
- package/dist/DynamicWindow/DynamicWindow.d.ts +19 -0
- package/dist/DynamicWindow/DynamicWindow.luau +327 -0
- package/dist/DynamicWindow/DynamicWindow.utils.d.ts +13 -0
- package/dist/DynamicWindow/DynamicWindow.utils.luau +46 -0
- package/dist/DynamicWindow/ResizeCornerButton.d.ts +13 -0
- package/dist/DynamicWindow/ResizeCornerButton.luau +47 -0
- package/dist/DynamicWindow/TrafficLightButton.d.ts +8 -0
- package/dist/DynamicWindow/TrafficLightButton.luau +26 -0
- package/dist/buttons/Button.d.ts +15 -0
- package/dist/buttons/Button.luau +66 -0
- package/dist/buttons/DropdownButton.d.ts +20 -0
- package/dist/buttons/DropdownButton.luau +106 -0
- package/dist/buttons/DropdownOptionButton.d.ts +11 -0
- package/dist/buttons/DropdownOptionButton.luau +66 -0
- package/dist/buttons/IconRoundButton.d.ts +21 -0
- package/dist/buttons/IconRoundButton.luau +145 -0
- package/dist/buttons/IconTileButton.d.ts +12 -0
- package/dist/buttons/IconTileButton.luau +86 -0
- package/dist/buttons/PrimaryButton.d.ts +23 -0
- package/dist/buttons/PrimaryButton.luau +84 -0
- package/dist/buttons/ReactiveButton.d.ts +32 -0
- package/dist/buttons/ReactiveButton.luau +163 -0
- package/dist/buttons/TextButton.d.ts +30 -0
- package/dist/buttons/TextButton.luau +121 -0
- package/dist/{Checkmark.luau → display/Checkmark.luau} +1 -1
- package/dist/display/Legend.d.ts +11 -0
- package/dist/display/Legend.luau +54 -0
- package/dist/display/PillText.d.ts +6 -0
- package/dist/display/PillText.luau +65 -0
- package/dist/display/TimeAgo.d.ts +8 -0
- package/dist/display/TimeAgo.luau +48 -0
- package/dist/error-handler/ErrorHandler.d.ts +3 -0
- package/dist/error-handler/ErrorHandler.luau +18 -0
- package/dist/error-handler/ErrorPage.d.ts +6 -0
- package/dist/error-handler/ErrorPage.luau +144 -0
- package/dist/error-handler/index.d.ts +3 -0
- package/dist/error-handler/init.luau +6 -0
- package/dist/form/Checkbox.d.ts +11 -0
- package/dist/form/Checkbox.luau +108 -0
- package/dist/form/CheckboxRow.d.ts +12 -0
- package/dist/form/CheckboxRow.luau +48 -0
- package/dist/form/Dropdown.d.ts +16 -0
- package/dist/form/Dropdown.luau +155 -0
- package/dist/form/DropdownRow.d.ts +18 -0
- package/dist/form/DropdownRow.luau +28 -0
- package/dist/form/FormRow.d.ts +9 -0
- package/dist/form/FormRow.luau +36 -0
- package/dist/form/InputRound.d.ts +18 -0
- package/dist/form/InputRound.luau +218 -0
- package/dist/form/InputRow.d.ts +13 -0
- package/dist/form/InputRow.luau +32 -0
- package/dist/form/Radio.d.ts +11 -0
- package/dist/form/Radio.luau +105 -0
- package/dist/form/RadioRow.d.ts +8 -0
- package/dist/form/RadioRow.luau +46 -0
- package/dist/form/RoundEmoji.d.ts +8 -0
- package/dist/form/RoundEmoji.luau +40 -0
- package/dist/form/TextBox.d.ts +24 -0
- package/dist/form/TextBox.luau +57 -0
- package/dist/{TextField.d.ts → form/TextField.d.ts} +1 -1
- package/dist/{TextField.luau → form/TextField.luau} +4 -2
- package/dist/form/validation.d.ts +13 -0
- package/dist/form/validation.luau +80 -0
- package/dist/hooks/use-button-animation.d.ts +36 -0
- package/dist/hooks/use-button-animation.luau +80 -0
- package/dist/hooks/use-button-state.d.ts +13 -0
- package/dist/hooks/use-button-state.luau +81 -0
- package/dist/hooks/use-input-device.d.ts +7 -0
- package/dist/hooks/use-input-device.luau +38 -0
- package/dist/index.d.ts +48 -6
- package/dist/init.luau +72 -6
- package/dist/layout/Accordion.d.ts +14 -0
- package/dist/layout/Accordion.luau +101 -0
- package/dist/{Divider.luau → layout/Divider.luau} +1 -1
- package/dist/layout/Section.d.ts +10 -0
- package/dist/layout/Section.luau +51 -0
- package/dist/layout/SegmentedToggle.d.ts +17 -0
- package/dist/layout/SegmentedToggle.luau +117 -0
- package/dist/layout/SegmentedToggle.story.d.ts +10 -0
- package/dist/layout/SegmentedToggle.story.luau +72 -0
- package/dist/table/ExampleTable.d.ts +2 -0
- package/dist/table/ExampleTable.luau +46 -0
- package/dist/table/Table.d.ts +10 -0
- package/dist/table/Table.luau +26 -0
- package/dist/table/TableCell.d.ts +9 -0
- package/dist/table/TableCell.luau +26 -0
- package/dist/table/TableFooter.d.ts +9 -0
- package/dist/table/TableFooter.luau +12 -0
- package/dist/table/TableHeader.d.ts +9 -0
- package/dist/table/TableHeader.luau +12 -0
- package/dist/table/TableRow.d.ts +9 -0
- package/dist/table/TableRow.luau +24 -0
- package/dist/tooltip/Tooltip.d.ts +14 -0
- package/dist/tooltip/Tooltip.luau +65 -0
- package/dist/tooltip/useTooltip.d.ts +12 -0
- package/dist/tooltip/useTooltip.luau +40 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/ClickOutsideOverlay.d.ts +11 -0
- package/dist/utils/ClickOutsideOverlay.luau +35 -0
- package/dist/utils/Outline.d.ts +14 -0
- package/dist/utils/Outline.luau +99 -0
- package/package.json +19 -7
- /package/dist/{Checkmark.d.ts → display/Checkmark.d.ts} +0 -0
- /package/dist/{Divider.d.ts → layout/Divider.d.ts} +0 -0
- /package/dist/{Padding.d.ts → layout/Padding.d.ts} +0 -0
- /package/dist/{Padding.luau → layout/Padding.luau} +0 -0
- /package/dist/{DelayRender.d.ts → utils/DelayRender.d.ts} +0 -0
- /package/dist/{DelayRender.luau → utils/DelayRender.luau} +0 -0
- /package/dist/{ErrorBoundary.d.ts → utils/ErrorBoundary.d.ts} +0 -0
- /package/dist/{ErrorBoundary.luau → utils/ErrorBoundary.luau} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
export interface ExtendableFrameProps extends React.PropsWithChildren {
|
|
3
|
+
readonly size?: UDim2 | React.Binding<UDim2>;
|
|
4
|
+
readonly position?: UDim2 | React.Binding<UDim2>;
|
|
5
|
+
readonly backgroundColor?: Color3 | React.Binding<Color3>;
|
|
6
|
+
readonly backgroundTransparency?: number | React.Binding<number>;
|
|
7
|
+
readonly clipsDescendants?: boolean | React.Binding<boolean>;
|
|
8
|
+
readonly initialSize?: UDim2;
|
|
9
|
+
readonly initialPosition?: UDim2;
|
|
10
|
+
readonly title?: string;
|
|
11
|
+
readonly onClose?: () => void;
|
|
12
|
+
readonly onPositionChange?: (position: UDim2) => void;
|
|
13
|
+
readonly onSizeChange?: (size: UDim2) => void;
|
|
14
|
+
readonly active?: boolean;
|
|
15
|
+
readonly zIndex?: number;
|
|
16
|
+
readonly resizeEnabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function DynamicWindow({ children, size, position, backgroundColor, backgroundTransparency, clipsDescendants, initialSize, initialPosition, title, resizeEnabled, onClose, onPositionChange, onSizeChange, active, zIndex, }: ExtendableFrameProps): JSX.Element;
|
|
19
|
+
//# sourceMappingURL=DynamicWindow.d.ts.map
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local HStack = TS.import(script, TS.getModule(script, "@rbxts-ui", "layout").dist).HStack
|
|
4
|
+
local _primitives = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist)
|
|
5
|
+
local Frame = _primitives.Frame
|
|
6
|
+
local Text = _primitives.Text
|
|
7
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
8
|
+
local defaultTheme = TS.import(script, TS.getModule(script, "@rbxts-ui", "theme").dist).defaultTheme
|
|
9
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
10
|
+
local useEventListener = _pretty_react_hooks.useEventListener
|
|
11
|
+
local useLatest = _pretty_react_hooks.useLatest
|
|
12
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
13
|
+
local React = _react
|
|
14
|
+
local useBinding = _react.useBinding
|
|
15
|
+
local useRef = _react.useRef
|
|
16
|
+
local useState = _react.useState
|
|
17
|
+
local UserInputService = TS.import(script, TS.getModule(script, "@rbxts", "services")).UserInputService
|
|
18
|
+
local Button = TS.import(script, script.Parent.Parent, "buttons", "Button").Button
|
|
19
|
+
local Divider = TS.import(script, script.Parent.Parent, "layout", "Divider").Divider
|
|
20
|
+
local Padding = TS.import(script, script.Parent.Parent, "layout", "Padding").Padding
|
|
21
|
+
local _DynamicWindow_utils = TS.import(script, script.Parent, "DynamicWindow.utils")
|
|
22
|
+
local getInputViewportPos = _DynamicWindow_utils.getInputViewportPos
|
|
23
|
+
local getMouseViewportPos = _DynamicWindow_utils.getMouseViewportPos
|
|
24
|
+
local ResizeCornerButton = TS.import(script, script.Parent, "ResizeCornerButton").ResizeCornerButton
|
|
25
|
+
local TrafficLightButton = TS.import(script, script.Parent, "TrafficLightButton").TrafficLightButton
|
|
26
|
+
local ROBLOX_TOOLBAR_HEIGHT = 68
|
|
27
|
+
local function DynamicWindow(_param)
|
|
28
|
+
local children = _param.children
|
|
29
|
+
local size = _param.size
|
|
30
|
+
local position = _param.position
|
|
31
|
+
local backgroundColor = _param.backgroundColor
|
|
32
|
+
local backgroundTransparency = _param.backgroundTransparency
|
|
33
|
+
if backgroundTransparency == nil then
|
|
34
|
+
backgroundTransparency = 0
|
|
35
|
+
end
|
|
36
|
+
local clipsDescendants = _param.clipsDescendants
|
|
37
|
+
if clipsDescendants == nil then
|
|
38
|
+
clipsDescendants = true
|
|
39
|
+
end
|
|
40
|
+
local initialSize = _param.initialSize
|
|
41
|
+
local initialPosition = _param.initialPosition
|
|
42
|
+
local title = _param.title
|
|
43
|
+
if title == nil then
|
|
44
|
+
title = "Workspace"
|
|
45
|
+
end
|
|
46
|
+
local resizeEnabled = _param.resizeEnabled
|
|
47
|
+
if resizeEnabled == nil then
|
|
48
|
+
resizeEnabled = true
|
|
49
|
+
end
|
|
50
|
+
local onClose = _param.onClose
|
|
51
|
+
local onPositionChange = _param.onPositionChange
|
|
52
|
+
local onSizeChange = _param.onSizeChange
|
|
53
|
+
local active = _param.active
|
|
54
|
+
local zIndex = _param.zIndex
|
|
55
|
+
local rem = useRem()
|
|
56
|
+
local theme = defaultTheme
|
|
57
|
+
local titleBarHeight = rem(7)
|
|
58
|
+
local titleBarPadding = rem(1)
|
|
59
|
+
local trafficLightSize = rem(2.5)
|
|
60
|
+
local titleFontSize = rem(3.2)
|
|
61
|
+
local titleBarColor = theme.palette.lightblue
|
|
62
|
+
local corner = UDim.new(0, rem(1.5))
|
|
63
|
+
-- Defaults: fixed offset size/position so move/resize make sense immediately
|
|
64
|
+
local fallbackPosition = UDim2.new(0, 0, 0, ROBLOX_TOOLBAR_HEIGHT)
|
|
65
|
+
local fallbackSize = UDim2.new(0, rem(30), 1, -ROBLOX_TOOLBAR_HEIGHT)
|
|
66
|
+
local defaultPosition = initialPosition or fallbackPosition
|
|
67
|
+
local defaultSize = initialSize or fallbackSize
|
|
68
|
+
local internalPositionBinding, setInternalPosition = useBinding(defaultPosition)
|
|
69
|
+
local internalSizeBinding, setInternalSize = useBinding(defaultSize)
|
|
70
|
+
local positionBinding = position or internalPositionBinding
|
|
71
|
+
local sizeBinding = size or internalSizeBinding
|
|
72
|
+
local mode, setMode = useState("none")
|
|
73
|
+
local modeRef = useLatest(mode)
|
|
74
|
+
local minimized, setMinimized = useState(false)
|
|
75
|
+
local prevSizeRef = useRef()
|
|
76
|
+
local dragRef = useRef()
|
|
77
|
+
local frameRef = useRef(nil)
|
|
78
|
+
local applyInternalPosition = function(positionValue)
|
|
79
|
+
setInternalPosition(positionValue)
|
|
80
|
+
local _result = onPositionChange
|
|
81
|
+
if _result ~= nil then
|
|
82
|
+
_result(positionValue)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
local applyInternalSize = function(sizeValue)
|
|
86
|
+
setInternalSize(sizeValue)
|
|
87
|
+
local _result = onSizeChange
|
|
88
|
+
if _result ~= nil then
|
|
89
|
+
_result(sizeValue)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
local startInteraction = function(nextMode, mousePos, resizeCorner)
|
|
93
|
+
if nextMode == "resize" and (minimized or not resizeEnabled) then
|
|
94
|
+
return nil
|
|
95
|
+
end
|
|
96
|
+
local frame = frameRef.current
|
|
97
|
+
if not frame then
|
|
98
|
+
return nil
|
|
99
|
+
end
|
|
100
|
+
dragRef.current = {
|
|
101
|
+
startMouse = mousePos,
|
|
102
|
+
startPos = frame.Position,
|
|
103
|
+
startSize = frame.Size,
|
|
104
|
+
startAbsSize = frame.AbsoluteSize,
|
|
105
|
+
startAbsPos = frame.AbsolutePosition,
|
|
106
|
+
resizeCorner = resizeCorner,
|
|
107
|
+
}
|
|
108
|
+
setMode(nextMode)
|
|
109
|
+
end
|
|
110
|
+
local onDrag
|
|
111
|
+
local stopInteraction = function(commitPosition)
|
|
112
|
+
if commitPosition and dragRef.current then
|
|
113
|
+
onDrag(commitPosition)
|
|
114
|
+
end
|
|
115
|
+
dragRef.current = nil
|
|
116
|
+
if modeRef.current ~= "none" then
|
|
117
|
+
setMode("none")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
useEventListener(UserInputService.InputChanged, function(input)
|
|
121
|
+
if modeRef.current == "none" then
|
|
122
|
+
return nil
|
|
123
|
+
end
|
|
124
|
+
if not dragRef.current then
|
|
125
|
+
return nil
|
|
126
|
+
end
|
|
127
|
+
if input.UserInputType ~= Enum.UserInputType.MouseMovement then
|
|
128
|
+
return nil
|
|
129
|
+
end
|
|
130
|
+
onDrag(getInputViewportPos(input))
|
|
131
|
+
end)
|
|
132
|
+
useEventListener(UserInputService.InputEnded, function(input)
|
|
133
|
+
if modeRef.current ~= "none" and input.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
134
|
+
stopInteraction(getInputViewportPos(input))
|
|
135
|
+
end
|
|
136
|
+
end)
|
|
137
|
+
onDrag = function(mousePos)
|
|
138
|
+
local drag = dragRef.current
|
|
139
|
+
if not drag then
|
|
140
|
+
return nil
|
|
141
|
+
end
|
|
142
|
+
local _mousePos = mousePos
|
|
143
|
+
local _startMouse = drag.startMouse
|
|
144
|
+
local delta = _mousePos - _startMouse
|
|
145
|
+
local currentMode = modeRef.current
|
|
146
|
+
if currentMode == "move" then
|
|
147
|
+
local nextPos = UDim2.new(drag.startPos.X.Scale, drag.startPos.X.Offset + delta.X, drag.startPos.Y.Scale, drag.startPos.Y.Offset + delta.Y)
|
|
148
|
+
applyInternalPosition(nextPos)
|
|
149
|
+
elseif currentMode == "resize" then
|
|
150
|
+
if minimized then
|
|
151
|
+
return nil
|
|
152
|
+
end
|
|
153
|
+
local resizeCorner = drag.resizeCorner or "bottomRight"
|
|
154
|
+
local minW = rem(24)
|
|
155
|
+
local minH = titleBarHeight + rem(6)
|
|
156
|
+
local currentAbsSize = drag.startAbsSize
|
|
157
|
+
local isLeft = resizeCorner == "topLeft" or resizeCorner == "bottomLeft"
|
|
158
|
+
local isTop = resizeCorner == "topLeft" or resizeCorner == "topRight"
|
|
159
|
+
local desiredAbsW = currentAbsSize.X + (if isLeft then -delta.X else delta.X)
|
|
160
|
+
local desiredAbsH = currentAbsSize.Y + (if isTop then -delta.Y else delta.Y)
|
|
161
|
+
local finalAbsW = math.max(minW, desiredAbsW)
|
|
162
|
+
local finalAbsH = math.max(minH, desiredAbsH)
|
|
163
|
+
local usedDeltaX = finalAbsW - currentAbsSize.X
|
|
164
|
+
local usedDeltaY = finalAbsH - currentAbsSize.Y
|
|
165
|
+
local nextSize = UDim2.new(drag.startSize.X.Scale, drag.startSize.X.Offset + usedDeltaX, drag.startSize.Y.Scale, drag.startSize.Y.Offset + usedDeltaY)
|
|
166
|
+
applyInternalSize(nextSize)
|
|
167
|
+
if isLeft or isTop then
|
|
168
|
+
local nextPos = drag.startPos
|
|
169
|
+
if isLeft then
|
|
170
|
+
local positionDeltaX = currentAbsSize.X - finalAbsW
|
|
171
|
+
nextPos = UDim2.new(nextPos.X.Scale, nextPos.X.Offset + positionDeltaX, nextPos.Y.Scale, nextPos.Y.Offset)
|
|
172
|
+
end
|
|
173
|
+
if isTop then
|
|
174
|
+
local positionDeltaY = currentAbsSize.Y - finalAbsH
|
|
175
|
+
nextPos = UDim2.new(nextPos.X.Scale, nextPos.X.Offset, nextPos.Y.Scale, nextPos.Y.Offset + positionDeltaY)
|
|
176
|
+
end
|
|
177
|
+
applyInternalPosition(nextPos)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
local toggleMinimize = function()
|
|
182
|
+
stopInteraction()
|
|
183
|
+
if not minimized then
|
|
184
|
+
local currentSize = internalSizeBinding:getValue()
|
|
185
|
+
prevSizeRef.current = currentSize
|
|
186
|
+
local collapsed = UDim2.new(currentSize.X.Scale, currentSize.X.Offset, 0, titleBarHeight)
|
|
187
|
+
applyInternalSize(collapsed)
|
|
188
|
+
setMinimized(true)
|
|
189
|
+
else
|
|
190
|
+
local prev = prevSizeRef.current
|
|
191
|
+
if prev then
|
|
192
|
+
applyInternalSize(prev)
|
|
193
|
+
end
|
|
194
|
+
setMinimized(false)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
local handleClose = function()
|
|
198
|
+
stopInteraction()
|
|
199
|
+
local _result = onClose
|
|
200
|
+
if _result ~= nil then
|
|
201
|
+
_result()
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
local maximize = function()
|
|
205
|
+
applyInternalSize(UDim2.new(1, 0, 1, -ROBLOX_TOOLBAR_HEIGHT))
|
|
206
|
+
applyInternalPosition(UDim2.new(0, 0, 0, ROBLOX_TOOLBAR_HEIGHT))
|
|
207
|
+
end
|
|
208
|
+
local commonResizeCornerProps = {
|
|
209
|
+
size = rem(2.5),
|
|
210
|
+
startInteraction = startInteraction,
|
|
211
|
+
stopInteraction = stopInteraction,
|
|
212
|
+
visible = resizeEnabled and not minimized,
|
|
213
|
+
}
|
|
214
|
+
local defaultBackgroundColor = backgroundColor or theme.palette.white
|
|
215
|
+
local _exp = React.createElement("uistroke", {
|
|
216
|
+
Color = theme.palette.offwhite,
|
|
217
|
+
Transparency = 0.5,
|
|
218
|
+
Thickness = 1,
|
|
219
|
+
}, children)
|
|
220
|
+
local _exp_1 = React.createElement(Button, {
|
|
221
|
+
backgroundColor = titleBarColor,
|
|
222
|
+
backgroundTransparency = 1,
|
|
223
|
+
size = UDim2.new(1, 0, 0, titleBarHeight),
|
|
224
|
+
event = {
|
|
225
|
+
MouseButton1Down = function()
|
|
226
|
+
startInteraction("move", getMouseViewportPos())
|
|
227
|
+
end,
|
|
228
|
+
MouseButton1Up = function()
|
|
229
|
+
stopInteraction(getMouseViewportPos())
|
|
230
|
+
end,
|
|
231
|
+
},
|
|
232
|
+
}, React.createElement("uicorner", {
|
|
233
|
+
CornerRadius = corner,
|
|
234
|
+
}), React.createElement(Padding, {
|
|
235
|
+
padding = titleBarPadding,
|
|
236
|
+
}), React.createElement(HStack, {
|
|
237
|
+
size = UDim2.new(0.2, 0, 1, 0),
|
|
238
|
+
backgroundTransparency = 1,
|
|
239
|
+
verticalAlignment = Enum.VerticalAlignment.Center,
|
|
240
|
+
horizontalAlignment = Enum.HorizontalAlignment.Left,
|
|
241
|
+
spacing = rem(0.75),
|
|
242
|
+
}, React.createElement(TrafficLightButton, {
|
|
243
|
+
color = theme.palette.macRed,
|
|
244
|
+
size = trafficLightSize,
|
|
245
|
+
onClick = handleClose,
|
|
246
|
+
}), resizeEnabled and (React.createElement(React.Fragment, nil, React.createElement(TrafficLightButton, {
|
|
247
|
+
color = theme.palette.macYellow,
|
|
248
|
+
size = trafficLightSize,
|
|
249
|
+
onClick = toggleMinimize,
|
|
250
|
+
}), React.createElement(TrafficLightButton, {
|
|
251
|
+
color = theme.palette.macGreen,
|
|
252
|
+
size = trafficLightSize,
|
|
253
|
+
onClick = maximize,
|
|
254
|
+
})))), React.createElement(Text, {
|
|
255
|
+
text = title,
|
|
256
|
+
textSize = titleFontSize,
|
|
257
|
+
textColor = theme.palette.crust,
|
|
258
|
+
anchorPoint = Vector2.new(0.5, 0.5),
|
|
259
|
+
position = UDim2.new(0.5, 0, 0.5, 0),
|
|
260
|
+
}))
|
|
261
|
+
local _exp_2 = React.createElement(Divider, {
|
|
262
|
+
zIndex = 2,
|
|
263
|
+
position = UDim2.new(0, 0, 0, titleBarHeight),
|
|
264
|
+
color = theme.palette.offwhite,
|
|
265
|
+
thickness = 1,
|
|
266
|
+
})
|
|
267
|
+
local _exp_3 = React.createElement(Frame, {
|
|
268
|
+
size = UDim2.new(1, 0, 1, -titleBarHeight),
|
|
269
|
+
position = UDim2.new(0, 0, 0, titleBarHeight),
|
|
270
|
+
backgroundTransparency = 1,
|
|
271
|
+
visible = not minimized,
|
|
272
|
+
zIndex = 1,
|
|
273
|
+
}, children)
|
|
274
|
+
local _attributes = {
|
|
275
|
+
handleCorner = "topLeft",
|
|
276
|
+
anchorPoint = Vector2.new(0, 0),
|
|
277
|
+
position = UDim2.new(0, 0, 0, 0),
|
|
278
|
+
}
|
|
279
|
+
for _k, _v in commonResizeCornerProps do
|
|
280
|
+
_attributes[_k] = _v
|
|
281
|
+
end
|
|
282
|
+
local _exp_4 = React.createElement(ResizeCornerButton, _attributes)
|
|
283
|
+
local _attributes_1 = {
|
|
284
|
+
handleCorner = "topRight",
|
|
285
|
+
anchorPoint = Vector2.new(1, 0),
|
|
286
|
+
position = UDim2.new(1, 0, 0, 0),
|
|
287
|
+
}
|
|
288
|
+
for _k, _v in commonResizeCornerProps do
|
|
289
|
+
_attributes_1[_k] = _v
|
|
290
|
+
end
|
|
291
|
+
local _exp_5 = React.createElement(ResizeCornerButton, _attributes_1)
|
|
292
|
+
local _attributes_2 = {
|
|
293
|
+
handleCorner = "bottomLeft",
|
|
294
|
+
anchorPoint = Vector2.new(0, 1),
|
|
295
|
+
position = UDim2.new(0, 0, 1, 0),
|
|
296
|
+
}
|
|
297
|
+
for _k, _v in commonResizeCornerProps do
|
|
298
|
+
_attributes_2[_k] = _v
|
|
299
|
+
end
|
|
300
|
+
local _exp_6 = React.createElement(ResizeCornerButton, _attributes_2)
|
|
301
|
+
local _attributes_3 = {
|
|
302
|
+
handleCorner = "bottomRight",
|
|
303
|
+
anchorPoint = Vector2.new(1, 1),
|
|
304
|
+
position = UDim2.new(1, 0, 1, 0),
|
|
305
|
+
}
|
|
306
|
+
for _k, _v in commonResizeCornerProps do
|
|
307
|
+
_attributes_3[_k] = _v
|
|
308
|
+
end
|
|
309
|
+
return React.createElement(Frame, {
|
|
310
|
+
ref = frameRef,
|
|
311
|
+
size = sizeBinding,
|
|
312
|
+
position = positionBinding,
|
|
313
|
+
clipsDescendants = false,
|
|
314
|
+
active = active,
|
|
315
|
+
zIndex = zIndex,
|
|
316
|
+
}, React.createElement(Frame, {
|
|
317
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
318
|
+
backgroundTransparency = backgroundTransparency,
|
|
319
|
+
backgroundColor = defaultBackgroundColor,
|
|
320
|
+
cornerRadius = corner,
|
|
321
|
+
clipsDescendants = clipsDescendants,
|
|
322
|
+
active = active,
|
|
323
|
+
}, _exp, _exp_1, _exp_2, _exp_3, _exp_4, _exp_5, _exp_6, React.createElement(ResizeCornerButton, _attributes_3)))
|
|
324
|
+
end
|
|
325
|
+
return {
|
|
326
|
+
DynamicWindow = DynamicWindow,
|
|
327
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ResizeCorner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
|
|
2
|
+
export type Mode = "none" | "move" | "resize";
|
|
3
|
+
export declare const toViewportPoint: (pos: Vector2) => Vector2;
|
|
4
|
+
export declare const getInputViewportPos: (input: InputObject) => Vector2;
|
|
5
|
+
export declare const getMouseViewportPos: () => Vector2;
|
|
6
|
+
export interface WindowSpawnOptions {
|
|
7
|
+
readonly size: Vector2;
|
|
8
|
+
readonly preferredPosition?: Vector2;
|
|
9
|
+
readonly fallbackInstance?: GuiObject;
|
|
10
|
+
}
|
|
11
|
+
export declare const clampViewportPosition: (position: Vector2, size: Vector2) => Vector2;
|
|
12
|
+
export declare const resolveWindowSpawnPosition: ({ size, preferredPosition, fallbackInstance }: WindowSpawnOptions) => UDim2;
|
|
13
|
+
//# sourceMappingURL=DynamicWindow.utils.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
|
|
4
|
+
local GuiService = _services.GuiService
|
|
5
|
+
local UserInputService = _services.UserInputService
|
|
6
|
+
local Workspace = _services.Workspace
|
|
7
|
+
local toViewportPoint = function(pos)
|
|
8
|
+
local inset = GuiService:GetGuiInset()
|
|
9
|
+
return Vector2.new(pos.X - inset.X, pos.Y - inset.Y)
|
|
10
|
+
end
|
|
11
|
+
local getInputViewportPos = function(input)
|
|
12
|
+
return Vector2.new(input.Position.X, input.Position.Y)
|
|
13
|
+
end
|
|
14
|
+
local getMouseViewportPos = function()
|
|
15
|
+
return toViewportPoint(UserInputService:GetMouseLocation())
|
|
16
|
+
end
|
|
17
|
+
local clampViewportPosition = function(position, size)
|
|
18
|
+
local camera = Workspace.CurrentCamera
|
|
19
|
+
if not camera then
|
|
20
|
+
return position
|
|
21
|
+
end
|
|
22
|
+
local viewportSize = camera.ViewportSize
|
|
23
|
+
local maxX = math.max(0, viewportSize.X - size.X)
|
|
24
|
+
local maxY = math.max(0, viewportSize.Y - size.Y)
|
|
25
|
+
return Vector2.new(math.clamp(position.X, 0, maxX), math.clamp(position.Y, 0, maxY))
|
|
26
|
+
end
|
|
27
|
+
local resolveWindowSpawnPosition = function(_param)
|
|
28
|
+
local size = _param.size
|
|
29
|
+
local preferredPosition = _param.preferredPosition
|
|
30
|
+
local fallbackInstance = _param.fallbackInstance
|
|
31
|
+
local _fallbackPos = fallbackInstance
|
|
32
|
+
if _fallbackPos ~= nil then
|
|
33
|
+
_fallbackPos = _fallbackPos.AbsolutePosition
|
|
34
|
+
end
|
|
35
|
+
local fallbackPos = _fallbackPos
|
|
36
|
+
local basePosition = preferredPosition or fallbackPos or Vector2.zero
|
|
37
|
+
local clamped = clampViewportPosition(basePosition, size)
|
|
38
|
+
return UDim2.new(0, clamped.X, 0, clamped.Y)
|
|
39
|
+
end
|
|
40
|
+
return {
|
|
41
|
+
toViewportPoint = toViewportPoint,
|
|
42
|
+
getInputViewportPos = getInputViewportPos,
|
|
43
|
+
getMouseViewportPos = getMouseViewportPos,
|
|
44
|
+
clampViewportPosition = clampViewportPosition,
|
|
45
|
+
resolveWindowSpawnPosition = resolveWindowSpawnPosition,
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Mode, ResizeCorner } from "./DynamicWindow.utils";
|
|
2
|
+
interface ResizeCornerButtonProps {
|
|
3
|
+
readonly size: number;
|
|
4
|
+
readonly handleCorner: ResizeCorner;
|
|
5
|
+
readonly anchorPoint: Vector2;
|
|
6
|
+
readonly position: UDim2;
|
|
7
|
+
startInteraction: (mode: Mode, mousePos: Vector2, handleCorner?: ResizeCorner) => void;
|
|
8
|
+
stopInteraction: (mousePos: Vector2) => void;
|
|
9
|
+
readonly visible: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function ResizeCornerButton({ size, handleCorner, anchorPoint, position, startInteraction, stopInteraction, visible, }: ResizeCornerButtonProps): JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=ResizeCornerButton.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
4
|
+
local defaultTheme = TS.import(script, TS.getModule(script, "@rbxts-ui", "theme").dist).defaultTheme
|
|
5
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
6
|
+
local Button = TS.import(script, script.Parent.Parent, "buttons", "Button").Button
|
|
7
|
+
local getMouseViewportPos = TS.import(script, script.Parent, "DynamicWindow.utils").getMouseViewportPos
|
|
8
|
+
local function ResizeCornerButton(_param)
|
|
9
|
+
local size = _param.size
|
|
10
|
+
local handleCorner = _param.handleCorner
|
|
11
|
+
local anchorPoint = _param.anchorPoint
|
|
12
|
+
local position = _param.position
|
|
13
|
+
local startInteraction = _param.startInteraction
|
|
14
|
+
local stopInteraction = _param.stopInteraction
|
|
15
|
+
local visible = _param.visible
|
|
16
|
+
local rem = useRem()
|
|
17
|
+
local theme = defaultTheme
|
|
18
|
+
local isHovering, setIsHovering = React.useState(false)
|
|
19
|
+
local handleMouseEnter = function()
|
|
20
|
+
return setIsHovering(true)
|
|
21
|
+
end
|
|
22
|
+
local handleMouseLeave = function()
|
|
23
|
+
return setIsHovering(false)
|
|
24
|
+
end
|
|
25
|
+
return React.createElement(Button, {
|
|
26
|
+
key = handleCorner,
|
|
27
|
+
size = UDim2.new(0, size, 0, size),
|
|
28
|
+
position = position,
|
|
29
|
+
anchorPoint = anchorPoint,
|
|
30
|
+
visible = visible,
|
|
31
|
+
backgroundColor = theme.palette.surface2,
|
|
32
|
+
backgroundTransparency = if isHovering then 0.65 else 1,
|
|
33
|
+
cornerRadius = UDim.new(0, rem(1.5)),
|
|
34
|
+
selectable = false,
|
|
35
|
+
onMouseEnter = handleMouseEnter,
|
|
36
|
+
onMouseLeave = handleMouseLeave,
|
|
37
|
+
onMouseDown = function()
|
|
38
|
+
startInteraction("resize", getMouseViewportPos(), handleCorner)
|
|
39
|
+
end,
|
|
40
|
+
onMouseUp = function()
|
|
41
|
+
stopInteraction(getMouseViewportPos())
|
|
42
|
+
end,
|
|
43
|
+
})
|
|
44
|
+
end
|
|
45
|
+
return {
|
|
46
|
+
ResizeCornerButton = ResizeCornerButton,
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface TrafficLightButtonProps {
|
|
2
|
+
readonly size: number;
|
|
3
|
+
readonly color: Color3;
|
|
4
|
+
readonly onClick: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function TrafficLightButton({ color, size, onClick }: TrafficLightButtonProps): JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=TrafficLightButton.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local function TrafficLightButton(_param)
|
|
5
|
+
local color = _param.color
|
|
6
|
+
local size = _param.size
|
|
7
|
+
local onClick = _param.onClick
|
|
8
|
+
return React.createElement("imagebutton", {
|
|
9
|
+
BackgroundColor3 = color,
|
|
10
|
+
BackgroundTransparency = 0,
|
|
11
|
+
BorderSizePixel = 0,
|
|
12
|
+
AutoButtonColor = false,
|
|
13
|
+
Selectable = false,
|
|
14
|
+
Size = UDim2.new(0, size, 0, size),
|
|
15
|
+
Event = if onClick then {
|
|
16
|
+
MouseButton1Click = function()
|
|
17
|
+
onClick()
|
|
18
|
+
end,
|
|
19
|
+
} else nil,
|
|
20
|
+
}, React.createElement("uicorner", {
|
|
21
|
+
CornerRadius = UDim.new(1, 0),
|
|
22
|
+
}))
|
|
23
|
+
end
|
|
24
|
+
return {
|
|
25
|
+
TrafficLightButton = TrafficLightButton,
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { FrameProps } from "@rbxts-ui/primitives";
|
|
3
|
+
export interface ButtonProps extends FrameProps<TextButton> {
|
|
4
|
+
active?: boolean | React.Binding<boolean>;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
onMouseDown?: () => void;
|
|
7
|
+
onMouseUp?: () => void;
|
|
8
|
+
onMouseEnter?: () => void;
|
|
9
|
+
onMouseLeave?: () => void;
|
|
10
|
+
onMouseClick?: () => void;
|
|
11
|
+
automaticSize?: Enum.AutomaticSize;
|
|
12
|
+
selectable?: boolean | React.Binding<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<TextButton>>;
|
|
15
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local forwardRef = _react.forwardRef
|
|
6
|
+
local Button = forwardRef(function(props, ref)
|
|
7
|
+
local _binding = props
|
|
8
|
+
local onClick = _binding.onClick
|
|
9
|
+
local onMouseDown = _binding.onMouseDown
|
|
10
|
+
local onMouseEnter = _binding.onMouseEnter
|
|
11
|
+
local onMouseLeave = _binding.onMouseLeave
|
|
12
|
+
local onMouseUp = _binding.onMouseUp
|
|
13
|
+
local onMouseClick = _binding.onMouseClick
|
|
14
|
+
local _object = {
|
|
15
|
+
Activated = onClick and (function()
|
|
16
|
+
return onClick()
|
|
17
|
+
end),
|
|
18
|
+
MouseButton1Down = onMouseDown and (function()
|
|
19
|
+
return onMouseDown()
|
|
20
|
+
end),
|
|
21
|
+
MouseButton1Click = onMouseClick and (function()
|
|
22
|
+
return onMouseClick()
|
|
23
|
+
end),
|
|
24
|
+
MouseButton1Up = onMouseUp and (function()
|
|
25
|
+
return onMouseUp()
|
|
26
|
+
end),
|
|
27
|
+
MouseEnter = onMouseEnter and (function()
|
|
28
|
+
return onMouseEnter()
|
|
29
|
+
end),
|
|
30
|
+
MouseLeave = onMouseLeave and (function()
|
|
31
|
+
return onMouseLeave()
|
|
32
|
+
end),
|
|
33
|
+
}
|
|
34
|
+
local _spread = props.event
|
|
35
|
+
if _spread then
|
|
36
|
+
for _k, _v in _spread do
|
|
37
|
+
_object[_k] = _v
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
local event = _object
|
|
41
|
+
return React.createElement("textbutton", {
|
|
42
|
+
ref = ref,
|
|
43
|
+
Active = props.active,
|
|
44
|
+
Text = "",
|
|
45
|
+
AutoButtonColor = false,
|
|
46
|
+
Size = props.size,
|
|
47
|
+
Position = props.position,
|
|
48
|
+
AnchorPoint = props.anchorPoint,
|
|
49
|
+
BackgroundColor3 = props.backgroundColor,
|
|
50
|
+
BackgroundTransparency = props.backgroundTransparency,
|
|
51
|
+
ClipsDescendants = props.clipsDescendants,
|
|
52
|
+
Visible = props.visible,
|
|
53
|
+
ZIndex = props.zIndex,
|
|
54
|
+
LayoutOrder = props.layoutOrder,
|
|
55
|
+
BorderSizePixel = 0,
|
|
56
|
+
Selectable = props.selectable,
|
|
57
|
+
Event = event,
|
|
58
|
+
Change = props.change,
|
|
59
|
+
AutomaticSize = props.automaticSize,
|
|
60
|
+
}, props.children, props.cornerRadius and React.createElement("uicorner", {
|
|
61
|
+
CornerRadius = props.cornerRadius,
|
|
62
|
+
}))
|
|
63
|
+
end)
|
|
64
|
+
return {
|
|
65
|
+
Button = Button,
|
|
66
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
interface DropdownButtonProps extends React.PropsWithChildren {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
readonly onClick?: () => void;
|
|
5
|
+
readonly onHover?: (hovered: boolean) => void;
|
|
6
|
+
readonly size?: UDim2 | React.Binding<UDim2>;
|
|
7
|
+
readonly position?: UDim2 | React.Binding<UDim2>;
|
|
8
|
+
readonly anchorPoint?: Vector2 | React.Binding<Vector2>;
|
|
9
|
+
readonly overlayGradient?: ColorSequence | React.Binding<ColorSequence>;
|
|
10
|
+
readonly overlayTransparency?: number | React.Binding<number>;
|
|
11
|
+
readonly overlayRotation?: number | React.Binding<number>;
|
|
12
|
+
readonly layoutOrder?: number | React.Binding<number>;
|
|
13
|
+
readonly isDisabled?: boolean;
|
|
14
|
+
readonly hasShadow?: boolean;
|
|
15
|
+
readonly padding?: number;
|
|
16
|
+
readonly radius?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function DropdownButton({ text, onClick, onHover, position, anchorPoint, layoutOrder, isDisabled, size, padding, radius, }: DropdownButtonProps): JSX.Element;
|
|
19
|
+
export type { DropdownButtonProps };
|
|
20
|
+
//# sourceMappingURL=DropdownButton.d.ts.map
|