@rbxts/centurion-ui 1.0.0-dev-284510d → 1.0.0-dev-a7b777e
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/README.md +29 -0
- package/out/app/centurion-app.d.ts +3 -0
- package/out/app/centurion-app.lua +92 -0
- package/out/app/index.d.ts +6 -1
- package/out/app/init.lua +57 -4
- package/out/components/history/history-line.d.ts +5 -5
- package/out/components/history/history-line.lua +51 -27
- package/out/components/history/history-list.d.ts +8 -12
- package/out/components/history/history-list.lua +41 -41
- package/out/components/index.d.ts +1 -0
- package/out/components/init.lua +3 -0
- package/out/components/suggestions/badge.d.ts +11 -11
- package/out/components/suggestions/badge.lua +14 -20
- package/out/components/suggestions/main-suggestion.d.ts +6 -8
- package/out/components/suggestions/main-suggestion.lua +153 -143
- package/out/components/suggestions/suggestion-list.d.ts +5 -5
- package/out/components/suggestions/suggestion-list.lua +70 -49
- package/out/components/suggestions/suggestions.d.ts +2 -1
- package/out/components/suggestions/suggestions.lua +41 -50
- package/out/components/suggestions/util.d.ts +2 -2
- package/out/components/suggestions/util.lua +1 -0
- package/out/components/terminal/index.d.ts +1 -0
- package/out/{store/history → components/terminal}/init.lua +1 -1
- package/out/components/terminal/terminal-text-field.d.ts +11 -0
- package/out/components/terminal/terminal-text-field.lua +319 -0
- package/out/components/terminal/terminal.d.ts +2 -0
- package/out/components/terminal/terminal.lua +240 -0
- package/out/components/ui/frame.d.ts +17 -18
- package/out/components/ui/frame.lua +8 -10
- package/out/components/ui/group.d.ts +13 -15
- package/out/components/ui/group.lua +6 -9
- package/out/components/ui/layer.d.ts +5 -5
- package/out/components/ui/layer.lua +3 -3
- package/out/components/ui/outline.d.ts +13 -12
- package/out/components/ui/outline.lua +64 -54
- package/out/components/ui/padding.d.ts +7 -7
- package/out/components/ui/padding.lua +2 -2
- package/out/components/ui/scrolling-frame.d.ts +11 -12
- package/out/components/ui/scrolling-frame.lua +4 -9
- package/out/components/ui/text-field.d.ts +10 -9
- package/out/components/ui/text-field.lua +15 -13
- package/out/components/ui/text.d.ts +16 -16
- package/out/components/ui/text.lua +39 -38
- package/out/constants/springs.lua +1 -1
- package/out/hooks/use-api.d.ts +3 -0
- package/out/hooks/use-api.lua +18 -0
- package/out/hooks/use-atom.d.ts +2 -0
- package/out/hooks/use-atom.lua +17 -0
- package/out/hooks/use-debounce-source.d.ts +11 -0
- package/out/hooks/use-debounce-source.lua +27 -0
- package/out/hooks/use-event.d.ts +14 -0
- package/out/hooks/use-event.lua +58 -0
- package/out/hooks/use-history.d.ts +2 -0
- package/out/hooks/use-history.lua +56 -0
- package/out/hooks/use-motion.d.ts +4 -4
- package/out/hooks/use-motion.lua +11 -16
- package/out/hooks/use-px.d.ts +13 -1
- package/out/hooks/use-px.lua +52 -39
- package/out/store.d.ts +14 -0
- package/out/store.lua +44 -0
- package/out/types.d.ts +7 -4
- package/out/util/argument.d.ts +2 -1
- package/out/util/argument.lua +25 -0
- package/out/util/suggestion.d.ts +2 -2
- package/out/util/suggestion.lua +9 -14
- package/package.json +14 -14
- package/out/app/app.d.ts +0 -6
- package/out/app/app.lua +0 -83
- package/out/app/terminal-app.d.ts +0 -1
- package/out/app/terminal-app.lua +0 -61
- package/out/components/terminal-text-field.d.ts +0 -11
- package/out/components/terminal-text-field.lua +0 -289
- package/out/components/terminal-window.d.ts +0 -1
- package/out/components/terminal-window.lua +0 -265
- package/out/components/terminal.d.ts +0 -1
- package/out/components/terminal.lua +0 -26
- package/out/components/ui/shortcut-group.d.ts +0 -6
- package/out/components/ui/shortcut-group.lua +0 -100
- package/out/hooks/use-store.d.ts +0 -3
- package/out/hooks/use-store.lua +0 -7
- package/out/providers/api-provider.d.ts +0 -8
- package/out/providers/api-provider.lua +0 -17
- package/out/providers/options-provider.d.ts +0 -13
- package/out/providers/options-provider.lua +0 -39
- package/out/providers/root-provider.d.ts +0 -11
- package/out/providers/root-provider.lua +0 -24
- package/out/store/app/app-selectors.d.ts +0 -2
- package/out/store/app/app-selectors.lua +0 -7
- package/out/store/app/app-slice.d.ts +0 -8
- package/out/store/app/app-slice.lua +0 -17
- package/out/store/app/index.d.ts +0 -2
- package/out/store/app/init.lua +0 -10
- package/out/store/command/command-selectors.d.ts +0 -2
- package/out/store/command/command-selectors.lua +0 -7
- package/out/store/command/command-slice.d.ts +0 -15
- package/out/store/command/command-slice.lua +0 -21
- package/out/store/command/index.d.ts +0 -2
- package/out/store/command/init.lua +0 -10
- package/out/store/history/history-slice.d.ts +0 -11
- package/out/store/history/history-slice.lua +0 -52
- package/out/store/history/index.d.ts +0 -1
- package/out/store/index.d.ts +0 -46
- package/out/store/init.lua +0 -18
- package/out/store/suggestion/index.d.ts +0 -2
- package/out/store/suggestion/init.lua +0 -10
- package/out/store/suggestion/suggestion-selectors.d.ts +0 -2
- package/out/store/suggestion/suggestion-selectors.lua +0 -7
- package/out/store/suggestion/suggestion-slice.d.ts +0 -9
- package/out/store/suggestion/suggestion-slice.lua +0 -15
- package/out/store/text/index.d.ts +0 -2
- package/out/store/text/init.lua +0 -10
- package/out/store/text/text-selectors.d.ts +0 -3
- package/out/store/text/text-selectors.lua +0 -11
- package/out/store/text/text-slice.d.ts +0 -20
- package/out/store/text/text-slice.lua +0 -29
|
@@ -1,179 +1,189 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local useEffect = _react.useEffect
|
|
3
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
4
|
+
local Vide = _vide
|
|
5
|
+
local effect = _vide.effect
|
|
6
|
+
local read = _vide.read
|
|
8
7
|
local springs = TS.import(script, script.Parent.Parent.Parent, "constants", "springs").springs
|
|
9
8
|
local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
|
|
10
9
|
local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
|
|
11
10
|
local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
|
|
11
|
+
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
12
12
|
local useMotion = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-motion").useMotion
|
|
13
|
-
local
|
|
14
|
-
local
|
|
13
|
+
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
14
|
+
local _store = TS.import(script, script.Parent.Parent.Parent, "store")
|
|
15
|
+
local interfaceOptions = _store.interfaceOptions
|
|
16
|
+
local mouseOverInterface = _store.mouseOverInterface
|
|
15
17
|
local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
|
|
16
18
|
local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
|
|
17
|
-
local ShortcutGroup = TS.import(script, script.Parent.Parent, "ui", "shortcut-group").ShortcutGroup
|
|
18
19
|
local Text = TS.import(script, script.Parent.Parent, "ui", "text").Text
|
|
19
20
|
local Badge = TS.import(script, script.Parent, "badge").Badge
|
|
20
21
|
local highlightMatching = TS.import(script, script.Parent, "util").highlightMatching
|
|
21
|
-
local function showKeybindsGui(props)
|
|
22
|
-
if props.suggestion and props.suggestion.main.type == "command" and (props.suggestion.main).shortcuts ~= nil and props.options.showShortcutSuggestions then
|
|
23
|
-
return true
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
22
|
local function MainSuggestion(_param)
|
|
27
23
|
local suggestion = _param.suggestion
|
|
28
24
|
local currentText = _param.currentText
|
|
29
25
|
local size = _param.size
|
|
30
26
|
local sizes = _param.sizes
|
|
31
|
-
local
|
|
32
|
-
local px = usePx()
|
|
33
|
-
local options = useContext(OptionsContext)
|
|
27
|
+
local options = useAtom(interfaceOptions)
|
|
34
28
|
local titleHeight, titleHeightMotion = useMotion(0)
|
|
35
29
|
local badgeWidth, badgeWidthMotion = useMotion(0)
|
|
36
|
-
|
|
37
|
-
local _result = suggestion
|
|
30
|
+
effect(function()
|
|
31
|
+
local _result = read(suggestion)
|
|
38
32
|
if _result ~= nil then
|
|
39
|
-
_result = _result.
|
|
33
|
+
_result = _result.description
|
|
40
34
|
end
|
|
41
35
|
titleHeightMotion:spring(if _result ~= nil then 1 else 0, springs.responsive)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
end)
|
|
37
|
+
return Vide.jsx(Frame, {
|
|
38
|
+
size = size,
|
|
39
|
+
backgroundColor = function()
|
|
40
|
+
return options().palette.background
|
|
41
|
+
end,
|
|
42
|
+
backgroundTransparency = function()
|
|
43
|
+
local _condition = options().backgroundTransparency
|
|
44
|
+
if _condition == nil then
|
|
45
|
+
_condition = 0
|
|
46
|
+
end
|
|
47
|
+
return _condition
|
|
48
|
+
end,
|
|
49
|
+
cornerRadius = function()
|
|
50
|
+
return UDim.new(0, px(8))
|
|
51
|
+
end,
|
|
52
|
+
clipsDescendants = false,
|
|
53
|
+
mouseEnter = function()
|
|
54
|
+
return mouseOverInterface(true)
|
|
55
|
+
end,
|
|
56
|
+
mouseLeave = function()
|
|
57
|
+
return mouseOverInterface(false)
|
|
58
|
+
end,
|
|
59
|
+
}, Vide.jsx(Padding, {
|
|
60
|
+
all = function()
|
|
61
|
+
return UDim.new(0, px(8))
|
|
62
|
+
end,
|
|
63
|
+
}), Vide.jsx(Badge, {
|
|
47
64
|
anchorPoint = Vector2.new(1, 0),
|
|
48
|
-
size =
|
|
49
|
-
return UDim2.fromOffset(
|
|
50
|
-
end
|
|
65
|
+
size = function()
|
|
66
|
+
return UDim2.fromOffset(badgeWidth(), px(24))
|
|
67
|
+
end,
|
|
51
68
|
position = UDim2.fromScale(1, 0),
|
|
52
|
-
color =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
color = function()
|
|
70
|
+
return options().palette.highlight
|
|
71
|
+
end,
|
|
72
|
+
text = function()
|
|
73
|
+
local currentSuggestion = read(suggestion)
|
|
74
|
+
return if currentSuggestion ~= nil and currentSuggestion.type == "argument" then currentSuggestion.dataType else ""
|
|
75
|
+
end,
|
|
76
|
+
textColor = function()
|
|
77
|
+
return options().palette.surface
|
|
78
|
+
end,
|
|
79
|
+
textSize = function()
|
|
80
|
+
return px(SUGGESTION_TEXT_SIZE)
|
|
81
|
+
end,
|
|
82
|
+
visible = function()
|
|
83
|
+
local currentSuggestion = read(suggestion)
|
|
84
|
+
return currentSuggestion ~= nil and currentSuggestion.type == "argument"
|
|
85
|
+
end,
|
|
57
86
|
onTextBoundsChange = function(textBounds)
|
|
58
87
|
return badgeWidthMotion:spring(textBounds.X + px(8), {
|
|
59
88
|
mass = 0.5,
|
|
60
89
|
tension = 400,
|
|
61
90
|
})
|
|
62
91
|
end,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if _result_1 == "command" then
|
|
76
|
-
local _result_3 = suggestion
|
|
77
|
-
if _result_3 ~= nil then
|
|
78
|
-
_result_3 = _result_3.main
|
|
92
|
+
}), Vide.jsx(Text, {
|
|
93
|
+
size = function()
|
|
94
|
+
return read(sizes).title
|
|
95
|
+
end,
|
|
96
|
+
position = function()
|
|
97
|
+
return UDim2.fromOffset(0, 0):Lerp(UDim2.fromOffset(0, px(-4)), titleHeight())
|
|
98
|
+
end,
|
|
99
|
+
text = function()
|
|
100
|
+
local currentSuggestion = read(suggestion)
|
|
101
|
+
local _result = currentSuggestion
|
|
102
|
+
if _result ~= nil then
|
|
103
|
+
_result = _result.type
|
|
79
104
|
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
_attributes_1.textColor = options.palette.subtext
|
|
135
|
-
_attributes_1.textXAlignment = "Left"
|
|
136
|
-
_attributes_1.textYAlignment = "Top"
|
|
137
|
-
_attributes_1.textWrapped = true
|
|
138
|
-
_attributes_1.richText = true
|
|
139
|
-
local _exp_3 = React.createElement(Text, _attributes_1)
|
|
140
|
-
local _attributes_2 = {
|
|
105
|
+
local _result_1
|
|
106
|
+
if _result == "argument" then
|
|
107
|
+
_result_1 = currentSuggestion.title
|
|
108
|
+
else
|
|
109
|
+
local _exp = options().palette.highlight
|
|
110
|
+
local _result_2 = currentSuggestion
|
|
111
|
+
if _result_2 ~= nil then
|
|
112
|
+
_result_2 = _result_2.title
|
|
113
|
+
end
|
|
114
|
+
_result_1 = highlightMatching(_exp, _result_2, read(currentText))
|
|
115
|
+
end
|
|
116
|
+
return _result_1
|
|
117
|
+
end,
|
|
118
|
+
textSize = function()
|
|
119
|
+
return px(SUGGESTION_TITLE_TEXT_SIZE)
|
|
120
|
+
end,
|
|
121
|
+
textColor = function()
|
|
122
|
+
return options().palette.text
|
|
123
|
+
end,
|
|
124
|
+
textXAlignment = "Left",
|
|
125
|
+
textYAlignment = "Top",
|
|
126
|
+
richText = true,
|
|
127
|
+
font = function()
|
|
128
|
+
return options().font.bold
|
|
129
|
+
end,
|
|
130
|
+
}), Vide.jsx(Text, {
|
|
131
|
+
size = function()
|
|
132
|
+
return read(sizes).description
|
|
133
|
+
end,
|
|
134
|
+
position = function()
|
|
135
|
+
return UDim2.fromOffset(0, px(SUGGESTION_TITLE_TEXT_SIZE))
|
|
136
|
+
end,
|
|
137
|
+
text = function()
|
|
138
|
+
local _result = read(suggestion)
|
|
139
|
+
if _result ~= nil then
|
|
140
|
+
_result = _result.description
|
|
141
|
+
end
|
|
142
|
+
local _condition = _result
|
|
143
|
+
if _condition == nil then
|
|
144
|
+
_condition = ""
|
|
145
|
+
end
|
|
146
|
+
return _condition
|
|
147
|
+
end,
|
|
148
|
+
textSize = function()
|
|
149
|
+
return px(SUGGESTION_TEXT_SIZE)
|
|
150
|
+
end,
|
|
151
|
+
textColor = function()
|
|
152
|
+
return options().palette.subtext
|
|
153
|
+
end,
|
|
154
|
+
textXAlignment = "Left",
|
|
155
|
+
textYAlignment = "Top",
|
|
156
|
+
textWrapped = true,
|
|
157
|
+
richText = true,
|
|
158
|
+
}), Vide.jsx(Text, {
|
|
141
159
|
anchorPoint = Vector2.new(0, 1),
|
|
142
|
-
size =
|
|
143
|
-
return UDim2.new(1, 0, 0,
|
|
144
|
-
end
|
|
160
|
+
size = function()
|
|
161
|
+
return UDim2.new(1, 0, 0, read(sizes).errorTextHeight)
|
|
162
|
+
end,
|
|
145
163
|
position = UDim2.fromScale(0, 1),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
MouseEnter = function()
|
|
170
|
-
return options.setMouseOnGUI(true)
|
|
171
|
-
end,
|
|
172
|
-
MouseLeave = function()
|
|
173
|
-
return options.setMouseOnGUI(false)
|
|
174
|
-
end,
|
|
175
|
-
},
|
|
176
|
-
}, _exp, _exp_1, _result, _exp_2, _exp_3, React.createElement(Text, _attributes_2))
|
|
164
|
+
text = function()
|
|
165
|
+
local currentSuggestion = read(suggestion)
|
|
166
|
+
local _result
|
|
167
|
+
if currentSuggestion ~= nil and currentSuggestion.type == "argument" then
|
|
168
|
+
local _condition = currentSuggestion.error
|
|
169
|
+
if _condition == nil then
|
|
170
|
+
_condition = ""
|
|
171
|
+
end
|
|
172
|
+
_result = _condition
|
|
173
|
+
else
|
|
174
|
+
_result = ""
|
|
175
|
+
end
|
|
176
|
+
return _result
|
|
177
|
+
end,
|
|
178
|
+
textColor = function()
|
|
179
|
+
return options().palette.error
|
|
180
|
+
end,
|
|
181
|
+
textSize = function()
|
|
182
|
+
return px(SUGGESTION_TEXT_SIZE)
|
|
183
|
+
end,
|
|
184
|
+
textWrapped = true,
|
|
185
|
+
textXAlignment = "Left",
|
|
186
|
+
}))
|
|
177
187
|
end
|
|
178
188
|
return {
|
|
179
189
|
MainSuggestion = MainSuggestion,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import Vide, { Derivable } from "@rbxts/vide";
|
|
2
2
|
import { Suggestion } from "../../types";
|
|
3
3
|
export interface SuggestionListProps {
|
|
4
|
-
suggestion?: Suggestion
|
|
5
|
-
currentText?: string
|
|
6
|
-
size:
|
|
4
|
+
suggestion?: Derivable<Suggestion | undefined>;
|
|
5
|
+
currentText?: Derivable<string | undefined>;
|
|
6
|
+
size: Derivable<UDim2>;
|
|
7
7
|
}
|
|
8
|
-
export declare function SuggestionList({ suggestion, currentText, size, }: SuggestionListProps):
|
|
8
|
+
export declare function SuggestionList({ suggestion, currentText, size, }: SuggestionListProps): Vide.Node;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
local
|
|
3
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
4
|
+
local Vide = _vide
|
|
5
|
+
local For = _vide.For
|
|
6
|
+
local read = _vide.read
|
|
6
7
|
local SUGGESTION_TEXT_SIZE = TS.import(script, script.Parent.Parent.Parent, "constants", "text").SUGGESTION_TEXT_SIZE
|
|
7
|
-
local
|
|
8
|
-
local
|
|
8
|
+
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
9
|
+
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
10
|
+
local _store = TS.import(script, script.Parent.Parent.Parent, "store")
|
|
11
|
+
local interfaceOptions = _store.interfaceOptions
|
|
12
|
+
local mouseOverInterface = _store.mouseOverInterface
|
|
9
13
|
local Frame = TS.import(script, script.Parent.Parent, "ui", "frame").Frame
|
|
10
14
|
local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
|
|
11
15
|
local Padding = TS.import(script, script.Parent.Parent, "ui", "padding").Padding
|
|
@@ -15,55 +19,72 @@ local function SuggestionList(_param)
|
|
|
15
19
|
local suggestion = _param.suggestion
|
|
16
20
|
local currentText = _param.currentText
|
|
17
21
|
local size = _param.size
|
|
18
|
-
local
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
local options = useAtom(interfaceOptions)
|
|
23
|
+
return Vide.jsx(Group, {
|
|
24
|
+
size = size,
|
|
25
|
+
mouseEnter = function()
|
|
26
|
+
return mouseOverInterface(true)
|
|
27
|
+
end,
|
|
28
|
+
mouseLeave = function()
|
|
29
|
+
return mouseOverInterface(false)
|
|
30
|
+
end,
|
|
31
|
+
}, Vide.jsx("uilistlayout", {
|
|
21
32
|
SortOrder = "LayoutOrder",
|
|
22
|
-
Padding =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
local _callback = function(name, i)
|
|
31
|
-
return React.createElement(Frame, {
|
|
32
|
-
key = `{i}-{name}`,
|
|
33
|
-
size = UDim2.new(1, 0, 0, px(SUGGESTION_TEXT_SIZE + 6)),
|
|
34
|
-
backgroundColor = options.palette.background,
|
|
35
|
-
backgroundTransparency = options.backgroundTransparency,
|
|
36
|
-
cornerRadius = UDim.new(0, px(8)),
|
|
37
|
-
clipsDescendants = true,
|
|
38
|
-
}, React.createElement(Padding, {
|
|
39
|
-
all = UDim.new(0, px(4)),
|
|
40
|
-
}), React.createElement(Text, {
|
|
41
|
-
size = UDim2.new(1, 0, 1, 0),
|
|
42
|
-
text = highlightMatching(options.palette.highlight, name, currentText),
|
|
43
|
-
textColor = options.palette.text,
|
|
44
|
-
textSize = px(SUGGESTION_TEXT_SIZE),
|
|
45
|
-
textXAlignment = "Left",
|
|
46
|
-
richText = true,
|
|
47
|
-
}))
|
|
33
|
+
Padding = function()
|
|
34
|
+
return UDim.new(0, px(8))
|
|
35
|
+
end,
|
|
36
|
+
}), Vide.jsx(For, {
|
|
37
|
+
each = function()
|
|
38
|
+
local _result = read(suggestion)
|
|
39
|
+
if _result ~= nil then
|
|
40
|
+
_result = _result.others
|
|
48
41
|
end
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
local _condition = _result
|
|
43
|
+
if _condition == nil then
|
|
44
|
+
_condition = {}
|
|
51
45
|
end
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return options
|
|
46
|
+
return _condition
|
|
47
|
+
end,
|
|
48
|
+
}, function(name, i)
|
|
49
|
+
return Vide.jsx(Frame, {
|
|
50
|
+
size = function()
|
|
51
|
+
return UDim2.new(1, 0, 0, px(SUGGESTION_TEXT_SIZE + 6))
|
|
52
|
+
end,
|
|
53
|
+
backgroundColor = function()
|
|
54
|
+
return options().palette.background
|
|
55
|
+
end,
|
|
56
|
+
backgroundTransparency = function()
|
|
57
|
+
local _condition = options().backgroundTransparency
|
|
58
|
+
if _condition == nil then
|
|
59
|
+
_condition = 0
|
|
60
|
+
end
|
|
61
|
+
return _condition
|
|
62
|
+
end,
|
|
63
|
+
cornerRadius = function()
|
|
64
|
+
return UDim.new(0, px(8))
|
|
65
|
+
end,
|
|
66
|
+
clipsDescendants = true,
|
|
67
|
+
}, Vide.jsx(Padding, {
|
|
68
|
+
all = function()
|
|
69
|
+
return UDim.new(0, px(4))
|
|
70
|
+
end,
|
|
71
|
+
}), Vide.jsx(Text, {
|
|
72
|
+
size = function()
|
|
73
|
+
return UDim2.new(1, 0, 1, 0)
|
|
74
|
+
end,
|
|
75
|
+
text = function()
|
|
76
|
+
return highlightMatching(options().palette.highlight, name, read(currentText))
|
|
77
|
+
end,
|
|
78
|
+
textColor = function()
|
|
79
|
+
return options().palette.text
|
|
61
80
|
end,
|
|
62
|
-
|
|
63
|
-
return
|
|
81
|
+
textSize = function()
|
|
82
|
+
return px(SUGGESTION_TEXT_SIZE)
|
|
64
83
|
end,
|
|
65
|
-
|
|
66
|
-
|
|
84
|
+
textXAlignment = "Left",
|
|
85
|
+
richText = true,
|
|
86
|
+
}))
|
|
87
|
+
end))
|
|
67
88
|
end
|
|
68
89
|
return {
|
|
69
90
|
SuggestionList = SuggestionList,
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import Vide from "@rbxts/vide";
|
|
2
|
+
export declare function Suggestions(): Vide.Node;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v2.3.0-dev-26ec859
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
-
local React = _react
|
|
5
|
-
local useBinding = _react.useBinding
|
|
6
|
-
local useContext = _react.useContext
|
|
7
|
-
local useEffect = _react.useEffect
|
|
8
|
-
local useMemo = _react.useMemo
|
|
9
|
-
local useSelector = TS.import(script, TS.getModule(script, "@rbxts", "react-reflex")).useSelector
|
|
10
3
|
local TextService = TS.import(script, TS.getModule(script, "@rbxts", "services")).TextService
|
|
4
|
+
local _vide = TS.import(script, TS.getModule(script, "@rbxts", "vide").src)
|
|
5
|
+
local Vide = _vide
|
|
6
|
+
local cleanup = _vide.cleanup
|
|
7
|
+
local effect = _vide.effect
|
|
8
|
+
local source = _vide.source
|
|
11
9
|
local springs = TS.import(script, script.Parent.Parent.Parent, "constants", "springs").springs
|
|
12
10
|
local _text = TS.import(script, script.Parent.Parent.Parent, "constants", "text")
|
|
13
11
|
local SUGGESTION_TEXT_SIZE = _text.SUGGESTION_TEXT_SIZE
|
|
14
12
|
local SUGGESTION_TITLE_TEXT_SIZE = _text.SUGGESTION_TITLE_TEXT_SIZE
|
|
13
|
+
local useAtom = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-atom").useAtom
|
|
15
14
|
local useMotion = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-motion").useMotion
|
|
16
|
-
local
|
|
17
|
-
local
|
|
18
|
-
local
|
|
19
|
-
local
|
|
15
|
+
local px = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").px
|
|
16
|
+
local _store = TS.import(script, script.Parent.Parent.Parent, "store")
|
|
17
|
+
local currentSuggestion = _store.currentSuggestion
|
|
18
|
+
local currentTextPart = _store.currentTextPart
|
|
19
|
+
local interfaceOptions = _store.interfaceOptions
|
|
20
20
|
local Group = TS.import(script, script.Parent.Parent, "ui", "group").Group
|
|
21
21
|
local MainSuggestion = TS.import(script, script.Parent, "main-suggestion").MainSuggestion
|
|
22
22
|
local SuggestionList = TS.import(script, script.Parent, "suggestion-list").SuggestionList
|
|
@@ -25,21 +25,16 @@ local MAX_SUGGESTION_WIDTH = 180
|
|
|
25
25
|
local MAX_BADGE_WIDTH = 80
|
|
26
26
|
local PADDING = 8
|
|
27
27
|
local function Suggestions()
|
|
28
|
-
local options =
|
|
29
|
-
local
|
|
30
|
-
local
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return terminalText.parts[terminalText.index + 1]
|
|
36
|
-
end, { terminalText })
|
|
37
|
-
local textBoundsParams = useMemo(function()
|
|
38
|
-
return Instance.new("GetTextBoundsParams")
|
|
39
|
-
end, {})
|
|
28
|
+
local options = useAtom(interfaceOptions)
|
|
29
|
+
local textPart = useAtom(currentTextPart)
|
|
30
|
+
local textBoundsParams = Instance.new("GetTextBoundsParams")
|
|
31
|
+
textBoundsParams.RichText = true
|
|
32
|
+
cleanup(function()
|
|
33
|
+
textBoundsParams:Destroy()
|
|
34
|
+
end)
|
|
40
35
|
-- Suggestions
|
|
41
|
-
local
|
|
42
|
-
local sizes
|
|
36
|
+
local suggestion = useAtom(currentSuggestion)
|
|
37
|
+
local sizes = source({
|
|
43
38
|
title = UDim2.fromOffset(0, px(SUGGESTION_TITLE_TEXT_SIZE)),
|
|
44
39
|
description = UDim2.fromOffset(0, px(SUGGESTION_TEXT_SIZE)),
|
|
45
40
|
errorTextHeight = 0,
|
|
@@ -48,19 +43,19 @@ local function Suggestions()
|
|
|
48
43
|
local suggestionSize, suggestionSizeMotion = useMotion(UDim2.new())
|
|
49
44
|
local otherSuggestionSize, otherSuggestionSizeMotion = useMotion(UDim2.new())
|
|
50
45
|
-- Resize window based on suggestions
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
effect(function()
|
|
47
|
+
local current = suggestion()
|
|
48
|
+
if current == nil then
|
|
53
49
|
suggestionSizeMotion:spring(UDim2.new())
|
|
54
50
|
otherSuggestionSizeMotion:spring(UDim2.new())
|
|
55
51
|
return nil
|
|
56
52
|
end
|
|
57
|
-
local
|
|
58
|
-
local otherSuggestions = currentSuggestion.others
|
|
53
|
+
local otherSuggestions = current.others
|
|
59
54
|
if #otherSuggestions == 0 then
|
|
60
55
|
otherSuggestionSizeMotion:spring(UDim2.new())
|
|
61
56
|
end
|
|
62
|
-
local textBounds = getSuggestionTextBounds(options,
|
|
63
|
-
|
|
57
|
+
local textBounds = getSuggestionTextBounds(options(), current, px(SUGGESTION_TITLE_TEXT_SIZE), px(SUGGESTION_TEXT_SIZE), px(MAX_SUGGESTION_WIDTH), px(MAX_BADGE_WIDTH))
|
|
58
|
+
sizes(textBounds)
|
|
64
59
|
local windowWidth = math.max(textBounds.title.X.Offset, textBounds.description.X.Offset) + px(PADDING * 2)
|
|
65
60
|
local windowHeight = textBounds.title.Y.Offset + textBounds.description.Y.Offset + textBounds.errorTextHeight + px(PADDING * 2)
|
|
66
61
|
if textBounds.typeBadgeWidth > 0 then
|
|
@@ -73,7 +68,7 @@ local function Suggestions()
|
|
|
73
68
|
local otherHeight = 0
|
|
74
69
|
if not (#otherSuggestions == 0) then
|
|
75
70
|
local maxSuggestionWidth = 0
|
|
76
|
-
textBoundsParams.Font = options.font.regular
|
|
71
|
+
textBoundsParams.Font = options().font.regular
|
|
77
72
|
textBoundsParams.Size = px(SUGGESTION_TEXT_SIZE)
|
|
78
73
|
textBoundsParams.Width = math.huge
|
|
79
74
|
for _, name in otherSuggestions do
|
|
@@ -88,28 +83,24 @@ local function Suggestions()
|
|
|
88
83
|
otherSuggestionSizeMotion:spring(UDim2.fromOffset(windowWidth, otherHeight), springs.gentle)
|
|
89
84
|
end
|
|
90
85
|
suggestionSizeMotion:spring(UDim2.fromOffset(windowWidth, windowHeight), springs.responsive)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
suggestion = currentSuggestion,
|
|
94
|
-
}
|
|
95
|
-
local _result = currentSuggestion
|
|
96
|
-
if _result ~= nil then
|
|
97
|
-
_result = _result.main.type
|
|
98
|
-
end
|
|
99
|
-
_attributes.argument = _result == "argument"
|
|
100
|
-
_attributes.currentText = currentTextPart
|
|
101
|
-
_attributes.size = suggestionSize
|
|
102
|
-
_attributes.sizes = sizes
|
|
103
|
-
return React.createElement(Group, {
|
|
86
|
+
end)
|
|
87
|
+
return Vide.jsx(Group, {
|
|
104
88
|
size = UDim2.fromScale(1, 1),
|
|
105
89
|
visible = currentSuggestion ~= nil,
|
|
106
|
-
},
|
|
107
|
-
suggestion =
|
|
108
|
-
currentText =
|
|
90
|
+
}, Vide.jsx(MainSuggestion, {
|
|
91
|
+
suggestion = suggestion,
|
|
92
|
+
currentText = textPart,
|
|
93
|
+
size = suggestionSize,
|
|
94
|
+
sizes = sizes,
|
|
95
|
+
}), Vide.jsx(SuggestionList, {
|
|
96
|
+
suggestion = suggestion,
|
|
97
|
+
currentText = textPart,
|
|
109
98
|
size = otherSuggestionSize,
|
|
110
|
-
}),
|
|
99
|
+
}), Vide.jsx("uilistlayout", {
|
|
111
100
|
SortOrder = "LayoutOrder",
|
|
112
|
-
Padding =
|
|
101
|
+
Padding = function()
|
|
102
|
+
return UDim.new(0, px(PADDING))
|
|
103
|
+
end,
|
|
113
104
|
}))
|
|
114
105
|
end
|
|
115
106
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InterfaceOptions, Suggestion } from "../../types";
|
|
2
2
|
import { SuggestionTextBounds } from "./types";
|
|
3
3
|
export declare function highlightMatching(color: Color3, text?: string, terminalText?: string): string;
|
|
4
|
-
export declare function getSuggestionTextBounds(options: InterfaceOptions, suggestion:
|
|
4
|
+
export declare function getSuggestionTextBounds(options: InterfaceOptions, suggestion: Suggestion, titleTextSize: number, textSize: number, maxWidth: number, maxBadgeWidth: number): SuggestionTextBounds;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local TextService = TS.import(script, TS.getModule(script, "@rbxts", "services")).TextService
|
|
4
4
|
local TEXT_BOUNDS_PARAMS = Instance.new("GetTextBoundsParams")
|
|
5
|
+
TEXT_BOUNDS_PARAMS.RichText = true
|
|
5
6
|
local DEFAULT_BOUNDS = Vector2.new()
|
|
6
7
|
local prevColor
|
|
7
8
|
local prevColorHex
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./terminal";
|