@rbxts/centurion-ui 1.0.0-dev-dacc7af → 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.
Files changed (113) hide show
  1. package/out/app/centurion-app.d.ts +3 -0
  2. package/out/app/centurion-app.lua +92 -0
  3. package/out/app/index.d.ts +6 -1
  4. package/out/app/init.lua +57 -4
  5. package/out/components/history/history-line.d.ts +5 -5
  6. package/out/components/history/history-line.lua +51 -27
  7. package/out/components/history/history-list.d.ts +8 -12
  8. package/out/components/history/history-list.lua +41 -41
  9. package/out/components/index.d.ts +1 -0
  10. package/out/components/init.lua +3 -0
  11. package/out/components/suggestions/badge.d.ts +11 -11
  12. package/out/components/suggestions/badge.lua +14 -20
  13. package/out/components/suggestions/main-suggestion.d.ts +6 -8
  14. package/out/components/suggestions/main-suggestion.lua +153 -143
  15. package/out/components/suggestions/suggestion-list.d.ts +5 -5
  16. package/out/components/suggestions/suggestion-list.lua +70 -49
  17. package/out/components/suggestions/suggestions.d.ts +2 -1
  18. package/out/components/suggestions/suggestions.lua +41 -50
  19. package/out/components/suggestions/util.d.ts +2 -2
  20. package/out/components/suggestions/util.lua +1 -0
  21. package/out/components/terminal/index.d.ts +1 -0
  22. package/out/{store/history → components/terminal}/init.lua +1 -1
  23. package/out/components/terminal/terminal-text-field.d.ts +11 -0
  24. package/out/components/terminal/terminal-text-field.lua +319 -0
  25. package/out/components/terminal/terminal.d.ts +2 -0
  26. package/out/components/terminal/terminal.lua +240 -0
  27. package/out/components/ui/frame.d.ts +17 -18
  28. package/out/components/ui/frame.lua +8 -10
  29. package/out/components/ui/group.d.ts +13 -15
  30. package/out/components/ui/group.lua +6 -9
  31. package/out/components/ui/layer.d.ts +5 -5
  32. package/out/components/ui/layer.lua +3 -3
  33. package/out/components/ui/outline.d.ts +13 -12
  34. package/out/components/ui/outline.lua +64 -54
  35. package/out/components/ui/padding.d.ts +7 -7
  36. package/out/components/ui/padding.lua +2 -2
  37. package/out/components/ui/scrolling-frame.d.ts +11 -12
  38. package/out/components/ui/scrolling-frame.lua +4 -9
  39. package/out/components/ui/text-field.d.ts +10 -9
  40. package/out/components/ui/text-field.lua +15 -13
  41. package/out/components/ui/text.d.ts +16 -16
  42. package/out/components/ui/text.lua +39 -38
  43. package/out/hooks/use-api.d.ts +3 -0
  44. package/out/hooks/use-api.lua +18 -0
  45. package/out/hooks/use-atom.d.ts +2 -0
  46. package/out/hooks/use-atom.lua +17 -0
  47. package/out/hooks/use-debounce-source.d.ts +11 -0
  48. package/out/hooks/use-debounce-source.lua +27 -0
  49. package/out/hooks/use-event.d.ts +14 -0
  50. package/out/hooks/use-event.lua +58 -0
  51. package/out/hooks/use-history.d.ts +2 -0
  52. package/out/hooks/use-history.lua +56 -0
  53. package/out/hooks/use-motion.d.ts +4 -4
  54. package/out/hooks/use-motion.lua +10 -15
  55. package/out/hooks/use-px.d.ts +13 -1
  56. package/out/hooks/use-px.lua +52 -39
  57. package/out/store.d.ts +14 -0
  58. package/out/store.lua +44 -0
  59. package/out/types.d.ts +7 -4
  60. package/out/util/argument.d.ts +2 -1
  61. package/out/util/argument.lua +25 -0
  62. package/out/util/suggestion.d.ts +2 -2
  63. package/out/util/suggestion.lua +9 -14
  64. package/package.json +12 -13
  65. package/out/app/app.d.ts +0 -6
  66. package/out/app/app.lua +0 -83
  67. package/out/app/terminal-app.d.ts +0 -1
  68. package/out/app/terminal-app.lua +0 -61
  69. package/out/components/terminal-text-field.d.ts +0 -11
  70. package/out/components/terminal-text-field.lua +0 -289
  71. package/out/components/terminal-window.d.ts +0 -1
  72. package/out/components/terminal-window.lua +0 -265
  73. package/out/components/terminal.d.ts +0 -1
  74. package/out/components/terminal.lua +0 -26
  75. package/out/components/ui/shortcut-group.d.ts +0 -6
  76. package/out/components/ui/shortcut-group.lua +0 -100
  77. package/out/hooks/use-store.d.ts +0 -3
  78. package/out/hooks/use-store.lua +0 -7
  79. package/out/providers/api-provider.d.ts +0 -8
  80. package/out/providers/api-provider.lua +0 -17
  81. package/out/providers/options-provider.d.ts +0 -13
  82. package/out/providers/options-provider.lua +0 -39
  83. package/out/providers/root-provider.d.ts +0 -11
  84. package/out/providers/root-provider.lua +0 -24
  85. package/out/store/app/app-selectors.d.ts +0 -2
  86. package/out/store/app/app-selectors.lua +0 -7
  87. package/out/store/app/app-slice.d.ts +0 -8
  88. package/out/store/app/app-slice.lua +0 -17
  89. package/out/store/app/index.d.ts +0 -2
  90. package/out/store/app/init.lua +0 -10
  91. package/out/store/command/command-selectors.d.ts +0 -2
  92. package/out/store/command/command-selectors.lua +0 -7
  93. package/out/store/command/command-slice.d.ts +0 -15
  94. package/out/store/command/command-slice.lua +0 -21
  95. package/out/store/command/index.d.ts +0 -2
  96. package/out/store/command/init.lua +0 -10
  97. package/out/store/history/history-slice.d.ts +0 -11
  98. package/out/store/history/history-slice.lua +0 -52
  99. package/out/store/history/index.d.ts +0 -1
  100. package/out/store/index.d.ts +0 -46
  101. package/out/store/init.lua +0 -18
  102. package/out/store/suggestion/index.d.ts +0 -2
  103. package/out/store/suggestion/init.lua +0 -10
  104. package/out/store/suggestion/suggestion-selectors.d.ts +0 -2
  105. package/out/store/suggestion/suggestion-selectors.lua +0 -7
  106. package/out/store/suggestion/suggestion-slice.d.ts +0 -9
  107. package/out/store/suggestion/suggestion-slice.lua +0 -15
  108. package/out/store/text/index.d.ts +0 -2
  109. package/out/store/text/init.lua +0 -10
  110. package/out/store/text/text-selectors.d.ts +0 -3
  111. package/out/store/text/text-selectors.lua +0 -11
  112. package/out/store/text/text-slice.d.ts +0 -20
  113. 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 lerpBinding = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).lerpBinding
4
- local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
5
- local React = _react
6
- local useContext = _react.useContext
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 usePx = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").usePx
14
- local OptionsContext = TS.import(script, script.Parent.Parent.Parent, "providers", "options-provider").OptionsContext
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 argument = _param.argument
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
- useEffect(function()
37
- local _result = suggestion
30
+ effect(function()
31
+ local _result = read(suggestion)
38
32
  if _result ~= nil then
39
- _result = _result.main.description
33
+ _result = _result.description
40
34
  end
41
35
  titleHeightMotion:spring(if _result ~= nil then 1 else 0, springs.responsive)
42
- end, { suggestion })
43
- local _exp = React.createElement(Padding, {
44
- all = UDim.new(0, px(8)),
45
- })
46
- local _exp_1 = React.createElement(Badge, {
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 = badgeWidth:map(function(width)
49
- return UDim2.fromOffset(math.round(width), px(24))
50
- end),
65
+ size = function()
66
+ return UDim2.fromOffset(badgeWidth(), px(24))
67
+ end,
51
68
  position = UDim2.fromScale(1, 0),
52
- color = options.palette.highlight,
53
- text = if argument and suggestion ~= nil then (suggestion.main).dataType else "",
54
- textColor = options.palette.surface,
55
- textSize = px(SUGGESTION_TEXT_SIZE),
56
- visible = argument,
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
- local _result
65
- if showKeybindsGui({
66
- options = options,
67
- suggestion = suggestion,
68
- }) then
69
- local _attributes = {}
70
- local _result_1 = suggestion
71
- if _result_1 ~= nil then
72
- _result_1 = _result_1.main.type
73
- end
74
- local _result_2
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
- _result_2 = _result_3.shortcuts
81
- else
82
- _result_2 = {}
83
- end
84
- _attributes.shortcuts = _result_2
85
- _result = (React.createElement(ShortcutGroup, _attributes))
86
- else
87
- _result = (React.createElement(React.Fragment))
88
- end
89
- local _attributes = {
90
- size = sizes:map(function(val)
91
- return val.title
92
- end),
93
- position = lerpBinding(titleHeight, UDim2.fromOffset(0, 0), UDim2.fromOffset(0, px(-4))),
94
- }
95
- local _result_1
96
- if argument then
97
- local _result_2 = suggestion
98
- if _result_2 ~= nil then
99
- _result_2 = _result_2.main.title
100
- end
101
- _result_1 = _result_2
102
- else
103
- local _exp_2 = options.palette.highlight
104
- local _result_2 = suggestion
105
- if _result_2 ~= nil then
106
- _result_2 = _result_2.main.title
107
- end
108
- _result_1 = highlightMatching(_exp_2, _result_2, currentText)
109
- end
110
- _attributes.text = _result_1
111
- _attributes.textSize = px(SUGGESTION_TITLE_TEXT_SIZE)
112
- _attributes.textColor = options.palette.text
113
- _attributes.textXAlignment = "Left"
114
- _attributes.textYAlignment = "Top"
115
- _attributes.richText = true
116
- _attributes.font = options.font.bold
117
- local _exp_2 = React.createElement(Text, _attributes)
118
- local _attributes_1 = {
119
- size = sizes:map(function(val)
120
- return val.description
121
- end),
122
- position = UDim2.fromOffset(0, px(SUGGESTION_TITLE_TEXT_SIZE)),
123
- }
124
- local _result_2 = suggestion
125
- if _result_2 ~= nil then
126
- _result_2 = _result_2.main.description
127
- end
128
- local _condition = _result_2
129
- if _condition == nil then
130
- _condition = ""
131
- end
132
- _attributes_1.text = _condition
133
- _attributes_1.textSize = px(SUGGESTION_TEXT_SIZE)
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 = sizes:map(function(val)
143
- return UDim2.new(1, 0, 0, val.errorTextHeight)
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
- local _result_3
148
- if argument and suggestion ~= nil then
149
- local _condition_1 = (suggestion.main).error
150
- if _condition_1 == nil then
151
- _condition_1 = ""
152
- end
153
- _result_3 = _condition_1
154
- else
155
- _result_3 = ""
156
- end
157
- _attributes_2.text = _result_3
158
- _attributes_2.textColor = options.palette.error
159
- _attributes_2.textSize = px(SUGGESTION_TEXT_SIZE)
160
- _attributes_2.textWrapped = true
161
- _attributes_2.textXAlignment = "Left"
162
- return React.createElement(Frame, {
163
- size = size,
164
- backgroundColor = options.palette.background,
165
- backgroundTransparency = options.backgroundTransparency,
166
- cornerRadius = UDim.new(0, px(8)),
167
- clipsDescendants = false,
168
- event = {
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 { BindingOrValue } from "@rbxts/pretty-react-hooks";
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: BindingOrValue<UDim2>;
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): JSX.Element;
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 _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
- local React = _react
5
- local useContext = _react.useContext
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 usePx = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").usePx
8
- local OptionsContext = TS.import(script, script.Parent.Parent.Parent, "providers", "options-provider").OptionsContext
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 px = usePx()
19
- local options = useContext(OptionsContext)
20
- local _exp = React.createElement("uilistlayout", {
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 = UDim.new(0, px(8)),
23
- })
24
- local _result = suggestion
25
- if _result ~= nil then
26
- _result = _result.others
27
- if _result ~= nil then
28
- -- ▼ ReadonlyArray.map ▼
29
- local _newValue = table.create(#_result)
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
- for _k, _v in _result do
50
- _newValue[_k] = _callback(_v, _k - 1, _result)
42
+ local _condition = _result
43
+ if _condition == nil then
44
+ _condition = {}
51
45
  end
52
- -- ▲ ReadonlyArray.map ▲
53
- _result = _newValue
54
- end
55
- end
56
- return React.createElement(Group, {
57
- size = size,
58
- event = {
59
- MouseEnter = function()
60
- return options.setMouseOnGUI(true)
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
- MouseLeave = function()
63
- return options.setMouseOnGUI(false)
81
+ textSize = function()
82
+ return px(SUGGESTION_TEXT_SIZE)
64
83
  end,
65
- },
66
- }, _exp, _result)
84
+ textXAlignment = "Left",
85
+ richText = true,
86
+ }))
87
+ end))
67
88
  end
68
89
  return {
69
90
  SuggestionList = SuggestionList,
@@ -1 +1,2 @@
1
- export declare function Suggestions(): JSX.Element;
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 usePx = TS.import(script, script.Parent.Parent.Parent, "hooks", "use-px").usePx
17
- local OptionsContext = TS.import(script, script.Parent.Parent.Parent, "providers", "options-provider").OptionsContext
18
- local selectSuggestion = TS.import(script, script.Parent.Parent.Parent, "store", "suggestion").selectSuggestion
19
- local selectText = TS.import(script, script.Parent.Parent.Parent, "store", "text").selectText
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 = useContext(OptionsContext)
29
- local px = usePx()
30
- local terminalText = useSelector(selectText)
31
- local currentTextPart = useMemo(function()
32
- if terminalText.index == -1 or terminalText.index >= #terminalText.parts then
33
- return nil
34
- end
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 currentSuggestion = useSelector(selectSuggestion)
42
- local sizes, setSizes = useBinding({
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
- useEffect(function()
52
- if currentSuggestion == nil then
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 mainSuggestion = currentSuggestion.main
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, mainSuggestion, px(SUGGESTION_TITLE_TEXT_SIZE), px(SUGGESTION_TEXT_SIZE), px(MAX_SUGGESTION_WIDTH), px(MAX_BADGE_WIDTH))
63
- setSizes(textBounds)
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, { currentSuggestion, px })
92
- local _attributes = {
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
- }, React.createElement(MainSuggestion, _attributes), React.createElement(SuggestionList, {
107
- suggestion = currentSuggestion,
108
- currentText = currentTextPart,
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
- }), React.createElement("uilistlayout", {
99
+ }), Vide.jsx("uilistlayout", {
111
100
  SortOrder = "LayoutOrder",
112
- Padding = UDim.new(0, px(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 { ArgumentSuggestion, CommandSuggestion, InterfaceOptions } from "../../types";
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: ArgumentSuggestion | CommandSuggestion, titleTextSize: number, textSize: number, maxWidth: number, maxBadgeWidth: number): SuggestionTextBounds;
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";