@rbxts/centurion-ui 1.0.0-dev-284510d
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/out/app/app.d.ts +6 -0
- package/out/app/app.lua +83 -0
- package/out/app/index.d.ts +1 -0
- package/out/app/init.lua +7 -0
- package/out/app/terminal-app.d.ts +1 -0
- package/out/app/terminal-app.lua +61 -0
- package/out/components/history/history-line.d.ts +10 -0
- package/out/components/history/history-line.lua +63 -0
- package/out/components/history/history-list.d.ts +15 -0
- package/out/components/history/history-list.lua +62 -0
- package/out/components/history/index.d.ts +1 -0
- package/out/components/history/init.lua +7 -0
- package/out/components/index.d.ts +1 -0
- package/out/components/init.lua +7 -0
- package/out/components/suggestions/badge.d.ts +16 -0
- package/out/components/suggestions/badge.lua +52 -0
- package/out/components/suggestions/index.d.ts +1 -0
- package/out/components/suggestions/init.lua +7 -0
- package/out/components/suggestions/main-suggestion.d.ts +12 -0
- package/out/components/suggestions/main-suggestion.lua +180 -0
- package/out/components/suggestions/suggestion-list.d.ts +8 -0
- package/out/components/suggestions/suggestion-list.lua +70 -0
- package/out/components/suggestions/suggestions.d.ts +1 -0
- package/out/components/suggestions/suggestions.lua +117 -0
- package/out/components/suggestions/types.d.ts +6 -0
- package/out/components/suggestions/types.lua +2 -0
- package/out/components/suggestions/util.d.ts +4 -0
- package/out/components/suggestions/util.lua +72 -0
- package/out/components/terminal-text-field.d.ts +11 -0
- package/out/components/terminal-text-field.lua +289 -0
- package/out/components/terminal-window.d.ts +1 -0
- package/out/components/terminal-window.lua +265 -0
- package/out/components/terminal.d.ts +1 -0
- package/out/components/terminal.lua +26 -0
- package/out/components/ui/frame.d.ts +20 -0
- package/out/components/ui/frame.lua +29 -0
- package/out/components/ui/group.d.ts +17 -0
- package/out/components/ui/group.lua +24 -0
- package/out/components/ui/layer.d.ts +7 -0
- package/out/components/ui/layer.lua +23 -0
- package/out/components/ui/outline.d.ts +14 -0
- package/out/components/ui/outline.lua +106 -0
- package/out/components/ui/padding.d.ts +10 -0
- package/out/components/ui/padding.lua +19 -0
- package/out/components/ui/scrolling-frame.d.ts +15 -0
- package/out/components/ui/scrolling-frame.lua +42 -0
- package/out/components/ui/shortcut-group.d.ts +6 -0
- package/out/components/ui/shortcut-group.lua +100 -0
- package/out/components/ui/text-field.d.ts +13 -0
- package/out/components/ui/text-field.lua +53 -0
- package/out/components/ui/text.d.ts +20 -0
- package/out/components/ui/text.lua +55 -0
- package/out/constants/options.d.ts +2 -0
- package/out/constants/options.lua +19 -0
- package/out/constants/springs.d.ts +19 -0
- package/out/constants/springs.lua +20 -0
- package/out/constants/text.d.ts +3 -0
- package/out/constants/text.lua +9 -0
- package/out/constants/util.d.ts +1 -0
- package/out/constants/util.lua +7 -0
- package/out/hooks/use-motion.d.ts +4 -0
- package/out/hooks/use-motion.lua +24 -0
- package/out/hooks/use-px.d.ts +24 -0
- package/out/hooks/use-px.lua +56 -0
- package/out/hooks/use-store.d.ts +3 -0
- package/out/hooks/use-store.lua +7 -0
- package/out/index.d.ts +2 -0
- package/out/init.lua +10 -0
- package/out/palette.d.ts +56 -0
- package/out/palette.lua +51 -0
- package/out/providers/api-provider.d.ts +8 -0
- package/out/providers/api-provider.lua +17 -0
- package/out/providers/options-provider.d.ts +13 -0
- package/out/providers/options-provider.lua +39 -0
- package/out/providers/root-provider.d.ts +11 -0
- package/out/providers/root-provider.lua +24 -0
- package/out/store/app/app-selectors.d.ts +2 -0
- package/out/store/app/app-selectors.lua +7 -0
- package/out/store/app/app-slice.d.ts +8 -0
- package/out/store/app/app-slice.lua +17 -0
- package/out/store/app/index.d.ts +2 -0
- package/out/store/app/init.lua +10 -0
- package/out/store/command/command-selectors.d.ts +2 -0
- package/out/store/command/command-selectors.lua +7 -0
- package/out/store/command/command-slice.d.ts +15 -0
- package/out/store/command/command-slice.lua +21 -0
- package/out/store/command/index.d.ts +2 -0
- package/out/store/command/init.lua +10 -0
- package/out/store/history/history-slice.d.ts +11 -0
- package/out/store/history/history-slice.lua +52 -0
- package/out/store/history/index.d.ts +1 -0
- package/out/store/history/init.lua +7 -0
- package/out/store/index.d.ts +46 -0
- package/out/store/init.lua +18 -0
- package/out/store/suggestion/index.d.ts +2 -0
- package/out/store/suggestion/init.lua +10 -0
- package/out/store/suggestion/suggestion-selectors.d.ts +2 -0
- package/out/store/suggestion/suggestion-selectors.lua +7 -0
- package/out/store/suggestion/suggestion-slice.d.ts +9 -0
- package/out/store/suggestion/suggestion-slice.lua +15 -0
- package/out/store/text/index.d.ts +2 -0
- package/out/store/text/init.lua +10 -0
- package/out/store/text/text-selectors.d.ts +3 -0
- package/out/store/text/text-selectors.lua +11 -0
- package/out/store/text/text-slice.d.ts +20 -0
- package/out/store/text/text-slice.lua +29 -0
- package/out/types.d.ts +40 -0
- package/out/types.lua +2 -0
- package/out/util/argument.d.ts +2 -0
- package/out/util/argument.lua +26 -0
- package/out/util/suggestion.d.ts +4 -0
- package/out/util/suggestion.lua +208 -0
- package/package.json +54 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _centurion = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out)
|
|
4
|
+
local ImmutableRegistryPath = _centurion.ImmutableRegistryPath
|
|
5
|
+
local RegistryPath = _centurion.RegistryPath
|
|
6
|
+
local ArrayUtil = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.data).ArrayUtil
|
|
7
|
+
local _string = TS.import(script, TS.getModule(script, "@rbxts", "centurion").out.shared.util.string)
|
|
8
|
+
local endsWithSpace = _string.endsWithSpace
|
|
9
|
+
local formatPartsAsPath = _string.formatPartsAsPath
|
|
10
|
+
local splitString = _string.splitString
|
|
11
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
12
|
+
local useEventListener = _pretty_react_hooks.useEventListener
|
|
13
|
+
local useLatestCallback = _pretty_react_hooks.useLatestCallback
|
|
14
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
15
|
+
local React = _react
|
|
16
|
+
local useContext = _react.useContext
|
|
17
|
+
local useEffect = _react.useEffect
|
|
18
|
+
local useMemo = _react.useMemo
|
|
19
|
+
local useState = _react.useState
|
|
20
|
+
local TextService = TS.import(script, TS.getModule(script, "@rbxts", "services")).TextService
|
|
21
|
+
local HISTORY_TEXT_SIZE = TS.import(script, script.Parent.Parent, "constants", "text").HISTORY_TEXT_SIZE
|
|
22
|
+
local useMotion = TS.import(script, script.Parent.Parent, "hooks", "use-motion").useMotion
|
|
23
|
+
local usePx = TS.import(script, script.Parent.Parent, "hooks", "use-px").usePx
|
|
24
|
+
local useStore = TS.import(script, script.Parent.Parent, "hooks", "use-store").useStore
|
|
25
|
+
local ApiContext = TS.import(script, script.Parent.Parent, "providers", "api-provider").ApiContext
|
|
26
|
+
local OptionsContext = TS.import(script, script.Parent.Parent, "providers", "options-provider").OptionsContext
|
|
27
|
+
local _suggestion = TS.import(script, script.Parent.Parent, "util", "suggestion")
|
|
28
|
+
local getArgumentSuggestion = _suggestion.getArgumentSuggestion
|
|
29
|
+
local getCommandSuggestion = _suggestion.getCommandSuggestion
|
|
30
|
+
local HistoryList = TS.import(script, script.Parent, "history").HistoryList
|
|
31
|
+
local TerminalTextField = TS.import(script, script.Parent, "terminal-text-field").TerminalTextField
|
|
32
|
+
local Frame = TS.import(script, script.Parent, "ui", "frame").Frame
|
|
33
|
+
local Padding = TS.import(script, script.Parent, "ui", "padding").Padding
|
|
34
|
+
local MAX_HEIGHT = HISTORY_TEXT_SIZE * 10
|
|
35
|
+
local TEXT_FIELD_HEIGHT = 40
|
|
36
|
+
local function TerminalWindow()
|
|
37
|
+
local px = usePx()
|
|
38
|
+
local store = useStore()
|
|
39
|
+
local api = useContext(ApiContext)
|
|
40
|
+
local options = useContext(OptionsContext)
|
|
41
|
+
local history, setHistory = useState(api.dispatcher:getHistory())
|
|
42
|
+
local historyData, setHistoryData = useState({
|
|
43
|
+
lines = {},
|
|
44
|
+
height = 0,
|
|
45
|
+
})
|
|
46
|
+
local historyHeight, historyHeightMotion = useMotion(0)
|
|
47
|
+
local textBoundsParams = useMemo(function()
|
|
48
|
+
local params = Instance.new("GetTextBoundsParams")
|
|
49
|
+
params.Width = math.huge
|
|
50
|
+
params.Font = options.font.regular
|
|
51
|
+
return params
|
|
52
|
+
end, {})
|
|
53
|
+
local windowHeightBinding = useMemo(function()
|
|
54
|
+
return historyHeight:map(function(y)
|
|
55
|
+
return UDim2.new(1, 0, 0, math.ceil(px(TEXT_FIELD_HEIGHT + 16) + y))
|
|
56
|
+
end)
|
|
57
|
+
end, { px })
|
|
58
|
+
local checkMissingArgs = useLatestCallback(function(path, command)
|
|
59
|
+
if command.arguments == nil or #command.arguments == 0 then
|
|
60
|
+
return nil
|
|
61
|
+
end
|
|
62
|
+
local storeState = store:getState()
|
|
63
|
+
local lastPartIndex = #storeState.text.parts - path:size() - 1
|
|
64
|
+
local missingArgs = {}
|
|
65
|
+
local index = 0
|
|
66
|
+
for _, arg in command.arguments do
|
|
67
|
+
if arg.optional then
|
|
68
|
+
break
|
|
69
|
+
end
|
|
70
|
+
if index > lastPartIndex then
|
|
71
|
+
local _arg0 = `<b>{arg.name}</b>`
|
|
72
|
+
table.insert(missingArgs, _arg0)
|
|
73
|
+
end
|
|
74
|
+
index += 1
|
|
75
|
+
end
|
|
76
|
+
if #missingArgs == 0 then
|
|
77
|
+
return nil
|
|
78
|
+
end
|
|
79
|
+
local text = "Missing required argument"
|
|
80
|
+
if #missingArgs ~= 1 then
|
|
81
|
+
text ..= "s"
|
|
82
|
+
end
|
|
83
|
+
return `{text}: {table.concat(missingArgs, ", ")}`
|
|
84
|
+
end)
|
|
85
|
+
useEventListener(api.dispatcher.historyUpdated, function(entries)
|
|
86
|
+
local _array = {}
|
|
87
|
+
local _length = #_array
|
|
88
|
+
table.move(entries, 1, #entries, _length + 1, _array)
|
|
89
|
+
setHistory(_array)
|
|
90
|
+
end)
|
|
91
|
+
-- Handle history updates
|
|
92
|
+
useEffect(function()
|
|
93
|
+
local historySize = #history
|
|
94
|
+
local totalHeight = if historySize > 0 then px(8) + (historySize - 1) * px(8) else 0
|
|
95
|
+
textBoundsParams.Size = HISTORY_TEXT_SIZE
|
|
96
|
+
local historyLines = {}
|
|
97
|
+
for _, entry in history do
|
|
98
|
+
textBoundsParams.Text = entry.text
|
|
99
|
+
local textSize = TextService:GetTextBoundsAsync(textBoundsParams)
|
|
100
|
+
local lineHeight = px(textSize.Y + 4)
|
|
101
|
+
totalHeight += lineHeight
|
|
102
|
+
local _arg0 = {
|
|
103
|
+
entry = entry,
|
|
104
|
+
height = lineHeight,
|
|
105
|
+
}
|
|
106
|
+
table.insert(historyLines, _arg0)
|
|
107
|
+
end
|
|
108
|
+
local isClamped = totalHeight > px(MAX_HEIGHT)
|
|
109
|
+
local clampedHeight = if isClamped then px(MAX_HEIGHT) else totalHeight
|
|
110
|
+
historyHeightMotion:spring(clampedHeight, {
|
|
111
|
+
mass = 0.1,
|
|
112
|
+
tension = 300,
|
|
113
|
+
friction = 15,
|
|
114
|
+
})
|
|
115
|
+
setHistoryData({
|
|
116
|
+
lines = historyLines,
|
|
117
|
+
height = totalHeight,
|
|
118
|
+
})
|
|
119
|
+
end, { history, px })
|
|
120
|
+
return React.createElement(Frame, {
|
|
121
|
+
size = windowHeightBinding,
|
|
122
|
+
backgroundColor = options.palette.background,
|
|
123
|
+
backgroundTransparency = options.backgroundTransparency,
|
|
124
|
+
cornerRadius = UDim.new(0, px(8)),
|
|
125
|
+
event = {
|
|
126
|
+
MouseEnter = function()
|
|
127
|
+
return options.setMouseOnGUI(true)
|
|
128
|
+
end,
|
|
129
|
+
MouseLeave = function()
|
|
130
|
+
return options.setMouseOnGUI(false)
|
|
131
|
+
end,
|
|
132
|
+
},
|
|
133
|
+
}, React.createElement(Padding, {
|
|
134
|
+
all = UDim.new(0, px(8)),
|
|
135
|
+
}), React.createElement(HistoryList, {
|
|
136
|
+
size = UDim2.new(1, 0, 1, -px(TEXT_FIELD_HEIGHT + 8)),
|
|
137
|
+
data = historyData,
|
|
138
|
+
maxHeight = px(MAX_HEIGHT),
|
|
139
|
+
}), React.createElement(TerminalTextField, {
|
|
140
|
+
anchorPoint = Vector2.new(0, 1),
|
|
141
|
+
size = UDim2.new(1, 0, 0, px(TEXT_FIELD_HEIGHT)),
|
|
142
|
+
position = UDim2.fromScale(0, 1),
|
|
143
|
+
backgroundTransparency = options.backgroundTransparency,
|
|
144
|
+
onTextChange = function(text)
|
|
145
|
+
local parts = splitString(text, " ")
|
|
146
|
+
store.setText(text, parts)
|
|
147
|
+
if #parts == 0 then
|
|
148
|
+
store.setSuggestion(nil)
|
|
149
|
+
store.setCommand(nil)
|
|
150
|
+
store.setArgIndex(nil)
|
|
151
|
+
return nil
|
|
152
|
+
end
|
|
153
|
+
store:flush()
|
|
154
|
+
-- If the text ends in a space, we want to count that as having traversed
|
|
155
|
+
-- to the next "part" of the text. This means we should include the previous
|
|
156
|
+
-- text part as part of the parent path.
|
|
157
|
+
local atNextPart = endsWithSpace(text)
|
|
158
|
+
local commandPath = store:getState().command.path
|
|
159
|
+
local atCommand = false
|
|
160
|
+
if commandPath ~= nil and formatPartsAsPath(ArrayUtil.slice(parts, 0, commandPath:size())) == commandPath:toString() then
|
|
161
|
+
-- The current path still leads to the command, so it's valid
|
|
162
|
+
atCommand = true
|
|
163
|
+
elseif api.registry:getCommandByString(formatPartsAsPath(parts)) ~= nil then
|
|
164
|
+
atCommand = true
|
|
165
|
+
commandPath = ImmutableRegistryPath.new(parts)
|
|
166
|
+
else
|
|
167
|
+
local currentPath = RegistryPath:empty()
|
|
168
|
+
for _, part in parts do
|
|
169
|
+
currentPath:append(part)
|
|
170
|
+
if api.registry:getCommand(currentPath) ~= nil then
|
|
171
|
+
atCommand = true
|
|
172
|
+
break
|
|
173
|
+
end
|
|
174
|
+
if #api.registry:getChildPaths(currentPath) == 0 then
|
|
175
|
+
atCommand = false
|
|
176
|
+
break
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
commandPath = ImmutableRegistryPath:fromPath(currentPath)
|
|
180
|
+
end
|
|
181
|
+
if not atCommand and store:getState().command.path ~= nil then
|
|
182
|
+
store.setCommand(nil)
|
|
183
|
+
store:flush()
|
|
184
|
+
elseif atCommand and commandPath ~= store:getState().command.path then
|
|
185
|
+
store.setCommand(commandPath)
|
|
186
|
+
store:flush()
|
|
187
|
+
end
|
|
188
|
+
local _result
|
|
189
|
+
if commandPath ~= nil then
|
|
190
|
+
local _result_1 = api.registry:getCommand(commandPath)
|
|
191
|
+
if _result_1 ~= nil then
|
|
192
|
+
_result_1 = _result_1.options
|
|
193
|
+
end
|
|
194
|
+
_result = _result_1
|
|
195
|
+
else
|
|
196
|
+
_result = nil
|
|
197
|
+
end
|
|
198
|
+
local command = _result
|
|
199
|
+
if commandPath ~= nil and command ~= nil then
|
|
200
|
+
store.setTextValid(checkMissingArgs(commandPath, command) == nil)
|
|
201
|
+
else
|
|
202
|
+
store.setTextValid(false)
|
|
203
|
+
end
|
|
204
|
+
-- Update suggestions
|
|
205
|
+
local showArgs = atCommand and (atNextPart or (commandPath ~= nil and #parts > commandPath:size()))
|
|
206
|
+
local _result_1
|
|
207
|
+
if showArgs and command ~= nil then
|
|
208
|
+
local _result_2 = command.arguments
|
|
209
|
+
if _result_2 ~= nil then
|
|
210
|
+
_result_2 = #_result_2
|
|
211
|
+
end
|
|
212
|
+
local _condition = _result_2
|
|
213
|
+
if _condition == nil then
|
|
214
|
+
_condition = 0
|
|
215
|
+
end
|
|
216
|
+
_result_1 = _condition
|
|
217
|
+
else
|
|
218
|
+
_result_1 = 0
|
|
219
|
+
end
|
|
220
|
+
local argCount = _result_1
|
|
221
|
+
local currentTextPart = if not atNextPart then parts[#parts] else nil
|
|
222
|
+
local suggestion
|
|
223
|
+
if argCount == 0 then
|
|
224
|
+
local parentPath = if atNextPart then commandPath elseif commandPath:size() ~= 1 then commandPath:parent() else nil
|
|
225
|
+
suggestion = getCommandSuggestion(api.registry, parentPath, currentTextPart)
|
|
226
|
+
elseif commandPath ~= nil then
|
|
227
|
+
-- Handle argument suggestions
|
|
228
|
+
local argIndex = #parts - commandPath:size() - (if atNextPart then 0 else 1)
|
|
229
|
+
if argIndex >= argCount then
|
|
230
|
+
return nil
|
|
231
|
+
end
|
|
232
|
+
store.setArgIndex(argIndex)
|
|
233
|
+
suggestion = getArgumentSuggestion(api.registry, commandPath, argIndex, currentTextPart)
|
|
234
|
+
end
|
|
235
|
+
store.setSuggestion(suggestion)
|
|
236
|
+
end,
|
|
237
|
+
onSubmit = function(text)
|
|
238
|
+
local storeState = store:getState()
|
|
239
|
+
local commandPath = storeState.command.path
|
|
240
|
+
local command = if commandPath ~= nil then api.registry:getCommand(commandPath) else nil
|
|
241
|
+
if commandPath == nil or command == nil then
|
|
242
|
+
api.dispatcher:addHistoryEntry({
|
|
243
|
+
success = false,
|
|
244
|
+
text = "Command not found.",
|
|
245
|
+
sentAt = os.time(),
|
|
246
|
+
})
|
|
247
|
+
return nil
|
|
248
|
+
end
|
|
249
|
+
local argCheckMessage = checkMissingArgs(commandPath, command.options)
|
|
250
|
+
if argCheckMessage ~= nil then
|
|
251
|
+
api.dispatcher:addHistoryEntry({
|
|
252
|
+
success = false,
|
|
253
|
+
text = argCheckMessage,
|
|
254
|
+
sentAt = os.time(),
|
|
255
|
+
})
|
|
256
|
+
return nil
|
|
257
|
+
end
|
|
258
|
+
local args = ArrayUtil.slice(storeState.text.parts, commandPath:size())
|
|
259
|
+
api.dispatcher:run(commandPath, args)
|
|
260
|
+
end,
|
|
261
|
+
}))
|
|
262
|
+
end
|
|
263
|
+
return {
|
|
264
|
+
TerminalWindow = TerminalWindow,
|
|
265
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function Terminal(): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local useContext = _react.useContext
|
|
6
|
+
local GuiService = TS.import(script, TS.getModule(script, "@rbxts", "services")).GuiService
|
|
7
|
+
local usePx = TS.import(script, script.Parent.Parent, "hooks", "use-px").usePx
|
|
8
|
+
local OptionsContext = TS.import(script, script.Parent.Parent, "providers", "options-provider").OptionsContext
|
|
9
|
+
local Suggestions = TS.import(script, script.Parent, "suggestions").Suggestions
|
|
10
|
+
local TerminalWindow = TS.import(script, script.Parent, "terminal-window").TerminalWindow
|
|
11
|
+
local Group = TS.import(script, script.Parent, "ui", "group").Group
|
|
12
|
+
local function Terminal()
|
|
13
|
+
local px = usePx()
|
|
14
|
+
local options = useContext(OptionsContext)
|
|
15
|
+
return React.createElement(Group, {
|
|
16
|
+
anchorPoint = options.anchorPoint or Vector2.new(0, 0),
|
|
17
|
+
size = options.size or UDim2.new(0, px(1024), 1, 0),
|
|
18
|
+
position = options.position or UDim2.fromOffset(px(16), px(8) + (GuiService:GetGuiInset()).Y),
|
|
19
|
+
}, React.createElement(TerminalWindow), React.createElement(Suggestions), React.createElement("uilistlayout", {
|
|
20
|
+
Padding = UDim.new(0, px(8)),
|
|
21
|
+
SortOrder = "LayoutOrder",
|
|
22
|
+
}))
|
|
23
|
+
end
|
|
24
|
+
return {
|
|
25
|
+
default = Terminal,
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BindingOrValue } from "@rbxts/pretty-react-hooks";
|
|
2
|
+
import React, { InferEnumNames } from "@rbxts/react";
|
|
3
|
+
export interface FrameProps<T extends Instance = Frame> extends React.PropsWithChildren {
|
|
4
|
+
ref?: React.Ref<T>;
|
|
5
|
+
event?: React.InstanceEvent<T>;
|
|
6
|
+
change?: React.InstanceChangeEvent<T>;
|
|
7
|
+
size?: BindingOrValue<UDim2>;
|
|
8
|
+
position?: BindingOrValue<UDim2>;
|
|
9
|
+
anchorPoint?: BindingOrValue<Vector2>;
|
|
10
|
+
rotation?: BindingOrValue<number>;
|
|
11
|
+
backgroundColor?: BindingOrValue<Color3>;
|
|
12
|
+
backgroundTransparency?: BindingOrValue<number>;
|
|
13
|
+
clipsDescendants?: BindingOrValue<boolean>;
|
|
14
|
+
visible?: BindingOrValue<boolean>;
|
|
15
|
+
zIndex?: BindingOrValue<number>;
|
|
16
|
+
layoutOrder?: BindingOrValue<number>;
|
|
17
|
+
cornerRadius?: BindingOrValue<UDim>;
|
|
18
|
+
automaticSize?: InferEnumNames<Enum.AutomaticSize>;
|
|
19
|
+
}
|
|
20
|
+
export declare const Frame: React.ForwardRefExoticComponent<Omit<FrameProps<Frame>, "ref"> & React.RefAttributes<Frame>>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
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 Frame = forwardRef(function(props, ref)
|
|
7
|
+
return React.createElement("frame", {
|
|
8
|
+
ref = ref,
|
|
9
|
+
AutomaticSize = props.automaticSize,
|
|
10
|
+
Size = props.size,
|
|
11
|
+
Position = props.position,
|
|
12
|
+
AnchorPoint = props.anchorPoint,
|
|
13
|
+
Rotation = props.rotation,
|
|
14
|
+
BackgroundColor3 = props.backgroundColor,
|
|
15
|
+
BackgroundTransparency = props.backgroundTransparency,
|
|
16
|
+
ClipsDescendants = props.clipsDescendants,
|
|
17
|
+
Visible = props.visible,
|
|
18
|
+
ZIndex = props.zIndex,
|
|
19
|
+
LayoutOrder = props.layoutOrder,
|
|
20
|
+
BorderSizePixel = 0,
|
|
21
|
+
Event = props.event or {},
|
|
22
|
+
Change = props.change or {},
|
|
23
|
+
}, props.cornerRadius and React.createElement("uicorner", {
|
|
24
|
+
CornerRadius = props.cornerRadius,
|
|
25
|
+
}), props.children)
|
|
26
|
+
end)
|
|
27
|
+
return {
|
|
28
|
+
Frame = Frame,
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BindingOrValue } from "@rbxts/pretty-react-hooks";
|
|
2
|
+
import React from "@rbxts/react";
|
|
3
|
+
interface GroupProps extends React.PropsWithChildren {
|
|
4
|
+
ref?: React.Ref<Frame>;
|
|
5
|
+
event?: React.InstanceEvent<Frame>;
|
|
6
|
+
change?: React.InstanceChangeEvent<Frame>;
|
|
7
|
+
size?: BindingOrValue<UDim2>;
|
|
8
|
+
position?: BindingOrValue<UDim2>;
|
|
9
|
+
anchorPoint?: BindingOrValue<Vector2>;
|
|
10
|
+
rotation?: BindingOrValue<number>;
|
|
11
|
+
clipsDescendants?: BindingOrValue<boolean>;
|
|
12
|
+
layoutOrder?: BindingOrValue<number>;
|
|
13
|
+
visible?: BindingOrValue<boolean>;
|
|
14
|
+
zIndex?: BindingOrValue<number>;
|
|
15
|
+
}
|
|
16
|
+
export declare const Group: React.ForwardRefExoticComponent<Omit<GroupProps, "ref"> & React.RefAttributes<Frame>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
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 Group = forwardRef(function(props, ref)
|
|
7
|
+
return React.createElement("frame", {
|
|
8
|
+
ref = ref,
|
|
9
|
+
Size = props.size or UDim2.fromScale(1, 1),
|
|
10
|
+
Position = props.position,
|
|
11
|
+
AnchorPoint = props.anchorPoint,
|
|
12
|
+
Rotation = props.rotation,
|
|
13
|
+
ClipsDescendants = props.clipsDescendants,
|
|
14
|
+
LayoutOrder = props.layoutOrder,
|
|
15
|
+
Visible = props.visible,
|
|
16
|
+
ZIndex = props.zIndex,
|
|
17
|
+
BackgroundTransparency = 1,
|
|
18
|
+
Event = props.event or {},
|
|
19
|
+
Change = props.change or {},
|
|
20
|
+
}, props.children)
|
|
21
|
+
end)
|
|
22
|
+
return {
|
|
23
|
+
Group = Group,
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local IS_EDIT = TS.import(script, script.Parent.Parent.Parent, "constants", "util").IS_EDIT
|
|
5
|
+
local Group = TS.import(script, script.Parent, "group").Group
|
|
6
|
+
local function Layer(_param)
|
|
7
|
+
local visible = _param.visible
|
|
8
|
+
local displayOrder = _param.displayOrder
|
|
9
|
+
local children = _param.children
|
|
10
|
+
return if IS_EDIT then (React.createElement(Group, {
|
|
11
|
+
visible = visible,
|
|
12
|
+
zIndex = displayOrder,
|
|
13
|
+
}, children)) else (React.createElement("screengui", {
|
|
14
|
+
Enabled = visible,
|
|
15
|
+
ResetOnSpawn = false,
|
|
16
|
+
DisplayOrder = displayOrder,
|
|
17
|
+
IgnoreGuiInset = true,
|
|
18
|
+
ZIndexBehavior = "Sibling",
|
|
19
|
+
}, children))
|
|
20
|
+
end
|
|
21
|
+
return {
|
|
22
|
+
Layer = Layer,
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BindingOrValue } from "@rbxts/pretty-react-hooks";
|
|
2
|
+
import React from "@rbxts/react";
|
|
3
|
+
interface OutlineProps extends React.PropsWithChildren {
|
|
4
|
+
readonly outlineTransparency?: BindingOrValue<number>;
|
|
5
|
+
readonly innerColor?: BindingOrValue<Color3>;
|
|
6
|
+
readonly outerColor?: BindingOrValue<Color3>;
|
|
7
|
+
readonly innerTransparency?: BindingOrValue<number>;
|
|
8
|
+
readonly outerTransparency?: BindingOrValue<number>;
|
|
9
|
+
readonly innerThickness?: BindingOrValue<number>;
|
|
10
|
+
readonly outerThickness?: BindingOrValue<number>;
|
|
11
|
+
readonly cornerRadius?: BindingOrValue<UDim>;
|
|
12
|
+
}
|
|
13
|
+
export declare function Outline({ outlineTransparency, innerColor, outerColor, innerTransparency, outerTransparency, innerThickness, outerThickness, cornerRadius, children, }: OutlineProps): JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
4
|
+
local blend = _pretty_react_hooks.blend
|
|
5
|
+
local composeBindings = _pretty_react_hooks.composeBindings
|
|
6
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
7
|
+
local React = _react
|
|
8
|
+
local useMemo = _react.useMemo
|
|
9
|
+
local usePx = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").usePx
|
|
10
|
+
local Group = TS.import(script, script.Parent, "group").Group
|
|
11
|
+
local function ceilEven(n)
|
|
12
|
+
return math.ceil(n / 2) * 2
|
|
13
|
+
end
|
|
14
|
+
local DEFAULT_INNER_COLOR = Color3.new(1, 1, 1)
|
|
15
|
+
local DEFAULT_OUTER_COLOR = Color3.new(0, 0, 0)
|
|
16
|
+
local function Outline(_param)
|
|
17
|
+
local outlineTransparency = _param.outlineTransparency
|
|
18
|
+
if outlineTransparency == nil then
|
|
19
|
+
outlineTransparency = 0
|
|
20
|
+
end
|
|
21
|
+
local innerColor = _param.innerColor
|
|
22
|
+
if innerColor == nil then
|
|
23
|
+
innerColor = DEFAULT_INNER_COLOR
|
|
24
|
+
end
|
|
25
|
+
local outerColor = _param.outerColor
|
|
26
|
+
if outerColor == nil then
|
|
27
|
+
outerColor = DEFAULT_OUTER_COLOR
|
|
28
|
+
end
|
|
29
|
+
local innerTransparency = _param.innerTransparency
|
|
30
|
+
if innerTransparency == nil then
|
|
31
|
+
innerTransparency = 0.9
|
|
32
|
+
end
|
|
33
|
+
local outerTransparency = _param.outerTransparency
|
|
34
|
+
if outerTransparency == nil then
|
|
35
|
+
outerTransparency = 0.85
|
|
36
|
+
end
|
|
37
|
+
local innerThickness = _param.innerThickness
|
|
38
|
+
local outerThickness = _param.outerThickness
|
|
39
|
+
local cornerRadius = _param.cornerRadius
|
|
40
|
+
local children = _param.children
|
|
41
|
+
local px = usePx()
|
|
42
|
+
local _object = {}
|
|
43
|
+
local _left = "innerThickness"
|
|
44
|
+
local _condition = innerThickness
|
|
45
|
+
if _condition == nil then
|
|
46
|
+
_condition = px(3)
|
|
47
|
+
end
|
|
48
|
+
_object[_left] = _condition
|
|
49
|
+
local _left_1 = "outerThickness"
|
|
50
|
+
local _condition_1 = outerThickness
|
|
51
|
+
if _condition_1 == nil then
|
|
52
|
+
_condition_1 = px(1.5)
|
|
53
|
+
end
|
|
54
|
+
_object[_left_1] = _condition_1
|
|
55
|
+
_object.cornerRadius = cornerRadius or UDim.new(0, px(8))
|
|
56
|
+
local properties = _object
|
|
57
|
+
local innerStyle = useMemo(function()
|
|
58
|
+
local size = composeBindings(properties.innerThickness, function(thickness)
|
|
59
|
+
return UDim2.new(1, ceilEven(-2 * thickness), 1, ceilEven(-2 * thickness))
|
|
60
|
+
end)
|
|
61
|
+
local position = composeBindings(properties.innerThickness, function(thickness)
|
|
62
|
+
return UDim2.new(0, thickness, 0, thickness)
|
|
63
|
+
end)
|
|
64
|
+
local radius = composeBindings(properties.cornerRadius, properties.innerThickness, function(radius, thickness)
|
|
65
|
+
local _radius = radius
|
|
66
|
+
local _uDim = UDim.new(0, thickness)
|
|
67
|
+
return _radius - _uDim
|
|
68
|
+
end)
|
|
69
|
+
local transparency = composeBindings(outlineTransparency, innerTransparency, function(a, b)
|
|
70
|
+
return math.clamp(blend(a, b), 0, 1)
|
|
71
|
+
end)
|
|
72
|
+
return {
|
|
73
|
+
size = size,
|
|
74
|
+
position = position,
|
|
75
|
+
radius = radius,
|
|
76
|
+
transparency = transparency,
|
|
77
|
+
}
|
|
78
|
+
end, { properties.innerThickness, innerTransparency, properties.cornerRadius, outlineTransparency, px })
|
|
79
|
+
local outerStyle = useMemo(function()
|
|
80
|
+
local transparency = composeBindings(outlineTransparency, outerTransparency, function(a, b)
|
|
81
|
+
return math.clamp(blend(a, b), 0, 1)
|
|
82
|
+
end)
|
|
83
|
+
return {
|
|
84
|
+
transparency = transparency,
|
|
85
|
+
}
|
|
86
|
+
end, { outlineTransparency, outerTransparency })
|
|
87
|
+
return React.createElement(React.Fragment, nil, React.createElement(Group, {
|
|
88
|
+
size = innerStyle.size,
|
|
89
|
+
position = innerStyle.position,
|
|
90
|
+
}, React.createElement("uicorner", {
|
|
91
|
+
CornerRadius = innerStyle.radius,
|
|
92
|
+
}), React.createElement("uistroke", {
|
|
93
|
+
Color = innerColor,
|
|
94
|
+
Transparency = innerStyle.transparency,
|
|
95
|
+
Thickness = innerThickness,
|
|
96
|
+
}, children)), React.createElement(Group, nil, React.createElement("uicorner", {
|
|
97
|
+
CornerRadius = cornerRadius,
|
|
98
|
+
}), React.createElement("uistroke", {
|
|
99
|
+
Color = outerColor,
|
|
100
|
+
Transparency = outerStyle.transparency,
|
|
101
|
+
Thickness = outerThickness,
|
|
102
|
+
}, children)))
|
|
103
|
+
end
|
|
104
|
+
return {
|
|
105
|
+
Outline = Outline,
|
|
106
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BindingOrValue } from "@rbxts/pretty-react-hooks";
|
|
2
|
+
interface Props {
|
|
3
|
+
all?: BindingOrValue<UDim>;
|
|
4
|
+
left?: BindingOrValue<UDim>;
|
|
5
|
+
right?: BindingOrValue<UDim>;
|
|
6
|
+
top?: BindingOrValue<UDim>;
|
|
7
|
+
bottom?: BindingOrValue<UDim>;
|
|
8
|
+
}
|
|
9
|
+
export declare function Padding({ all, left, right, top, bottom }: Props): JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local function Padding(_param)
|
|
5
|
+
local all = _param.all
|
|
6
|
+
local left = _param.left
|
|
7
|
+
local right = _param.right
|
|
8
|
+
local top = _param.top
|
|
9
|
+
local bottom = _param.bottom
|
|
10
|
+
return React.createElement("uipadding", {
|
|
11
|
+
PaddingLeft = left or all,
|
|
12
|
+
PaddingRight = right or all,
|
|
13
|
+
PaddingTop = top or all,
|
|
14
|
+
PaddingBottom = bottom or all,
|
|
15
|
+
})
|
|
16
|
+
end
|
|
17
|
+
return {
|
|
18
|
+
Padding = Padding,
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BindingOrValue } from "@rbxts/pretty-react-hooks";
|
|
2
|
+
import React from "@rbxts/react";
|
|
3
|
+
import { FrameProps } from "./frame";
|
|
4
|
+
export interface ScrollingFrameProps extends FrameProps<ScrollingFrame> {
|
|
5
|
+
automaticSize?: React.InferEnumNames<Enum.AutomaticSize>;
|
|
6
|
+
automaticCanvasSize?: React.InferEnumNames<Enum.AutomaticSize>;
|
|
7
|
+
scrollingDirection?: React.InferEnumNames<Enum.ScrollingDirection>;
|
|
8
|
+
scrollBarThickness?: BindingOrValue<number>;
|
|
9
|
+
scrollBarColor?: BindingOrValue<Color3>;
|
|
10
|
+
scrollBarTransparency?: BindingOrValue<number>;
|
|
11
|
+
scrollingEnabled?: BindingOrValue<boolean>;
|
|
12
|
+
canvasSize?: BindingOrValue<UDim2>;
|
|
13
|
+
canvasPosition?: BindingOrValue<Vector2>;
|
|
14
|
+
}
|
|
15
|
+
export declare const ScrollingFrame: React.ForwardRefExoticComponent<Omit<ScrollingFrameProps, "ref"> & React.RefAttributes<ScrollingFrame>>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
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 ScrollingFrame = forwardRef(function(props, ref)
|
|
7
|
+
local _attributes = {
|
|
8
|
+
ref = ref,
|
|
9
|
+
AutomaticSize = props.automaticSize,
|
|
10
|
+
AutomaticCanvasSize = props.automaticCanvasSize,
|
|
11
|
+
ScrollingDirection = props.scrollingDirection,
|
|
12
|
+
ScrollBarThickness = props.scrollBarThickness,
|
|
13
|
+
ScrollBarImageColor3 = props.scrollBarColor,
|
|
14
|
+
ScrollBarImageTransparency = props.scrollBarTransparency,
|
|
15
|
+
ScrollingEnabled = props.scrollingEnabled,
|
|
16
|
+
CanvasSize = props.canvasSize,
|
|
17
|
+
CanvasPosition = props.canvasPosition,
|
|
18
|
+
Size = props.size,
|
|
19
|
+
Position = props.position,
|
|
20
|
+
AnchorPoint = props.anchorPoint,
|
|
21
|
+
Rotation = props.rotation,
|
|
22
|
+
BackgroundColor3 = props.backgroundColor,
|
|
23
|
+
}
|
|
24
|
+
local _condition = props.backgroundTransparency
|
|
25
|
+
if _condition == nil then
|
|
26
|
+
_condition = 1
|
|
27
|
+
end
|
|
28
|
+
_attributes.BackgroundTransparency = _condition
|
|
29
|
+
_attributes.ClipsDescendants = props.clipsDescendants
|
|
30
|
+
_attributes.Visible = props.visible
|
|
31
|
+
_attributes.ZIndex = props.zIndex
|
|
32
|
+
_attributes.LayoutOrder = props.layoutOrder
|
|
33
|
+
_attributes.BorderSizePixel = 0
|
|
34
|
+
_attributes.Event = props.event or {}
|
|
35
|
+
_attributes.Change = props.change or {}
|
|
36
|
+
return React.createElement("scrollingframe", _attributes, props.cornerRadius and React.createElement("uicorner", {
|
|
37
|
+
CornerRadius = props.cornerRadius,
|
|
38
|
+
}), props.children)
|
|
39
|
+
end)
|
|
40
|
+
return {
|
|
41
|
+
ScrollingFrame = ScrollingFrame,
|
|
42
|
+
}
|