@rbxts/react-clean-ui 1.0.5
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 +3 -0
- package/out/Components/Decorator/BoxShadow.d.ts +10 -0
- package/out/Components/Decorator/BoxShadow.luau +41 -0
- package/out/Components/Decorator/Corners.d.ts +7 -0
- package/out/Components/Decorator/Corners.luau +15 -0
- package/out/Components/Decorator/Padding.d.ts +3 -0
- package/out/Components/Decorator/Padding.luau +18 -0
- package/out/Components/Decorator/index.d.ts +3 -0
- package/out/Components/Decorator/init.luau +13 -0
- package/out/Components/Input/Button.d.ts +24 -0
- package/out/Components/Input/Button.luau +159 -0
- package/out/Components/Input/Checkbox.d.ts +12 -0
- package/out/Components/Input/Checkbox.luau +79 -0
- package/out/Components/Input/HoverButton.d.ts +16 -0
- package/out/Components/Input/HoverButton.luau +127 -0
- package/out/Components/Input/Input.d.ts +12 -0
- package/out/Components/Input/Input.luau +92 -0
- package/out/Components/Input/Select.d.ts +30 -0
- package/out/Components/Input/Select.luau +288 -0
- package/out/Components/Input/Slider.d.ts +51 -0
- package/out/Components/Input/Slider.luau +415 -0
- package/out/Components/Input/index.d.ts +6 -0
- package/out/Components/Input/init.luau +22 -0
- package/out/Components/Layout/Column.d.ts +13 -0
- package/out/Components/Layout/Column.luau +60 -0
- package/out/Components/Layout/Container.d.ts +6 -0
- package/out/Components/Layout/Container.luau +73 -0
- package/out/Components/Layout/Draggable.d.ts +46 -0
- package/out/Components/Layout/Draggable.luau +315 -0
- package/out/Components/Layout/Droppable.d.ts +10 -0
- package/out/Components/Layout/Droppable.luau +34 -0
- package/out/Components/Layout/Fieldset.d.ts +34 -0
- package/out/Components/Layout/Fieldset.luau +130 -0
- package/out/Components/Layout/FlexItem.d.ts +11 -0
- package/out/Components/Layout/FlexItem.luau +20 -0
- package/out/Components/Layout/Group.d.ts +34 -0
- package/out/Components/Layout/Group.luau +168 -0
- package/out/Components/Layout/HStack.d.ts +12 -0
- package/out/Components/Layout/HStack.luau +21 -0
- package/out/Components/Layout/Row.d.ts +15 -0
- package/out/Components/Layout/Row.luau +87 -0
- package/out/Components/Layout/Scroller.d.ts +7 -0
- package/out/Components/Layout/Scroller.luau +54 -0
- package/out/Components/Layout/Tabs.d.ts +31 -0
- package/out/Components/Layout/Tabs.luau +189 -0
- package/out/Components/Layout/VStack.d.ts +11 -0
- package/out/Components/Layout/VStack.luau +21 -0
- package/out/Components/Layout/index.d.ts +12 -0
- package/out/Components/Layout/init.luau +40 -0
- package/out/Components/Navigation/Menu.d.ts +19 -0
- package/out/Components/Navigation/Menu.luau +91 -0
- package/out/Components/Navigation/index.d.ts +1 -0
- package/out/Components/Navigation/init.luau +7 -0
- package/out/Components/Surface/Box.d.ts +7 -0
- package/out/Components/Surface/Box.luau +50 -0
- package/out/Components/Surface/Card.d.ts +25 -0
- package/out/Components/Surface/Card.luau +138 -0
- package/out/Components/Surface/Icon.d.ts +10 -0
- package/out/Components/Surface/Icon.luau +64 -0
- package/out/Components/Surface/Panel.d.ts +4 -0
- package/out/Components/Surface/Panel.luau +33 -0
- package/out/Components/Surface/index.d.ts +4 -0
- package/out/Components/Surface/init.luau +16 -0
- package/out/Components/Typography/Text.d.ts +18 -0
- package/out/Components/Typography/Text.luau +48 -0
- package/out/Components/Typography/index.d.ts +1 -0
- package/out/Components/Typography/init.luau +7 -0
- package/out/Components/index.d.ts +8 -0
- package/out/Components/init.luau +28 -0
- package/out/Contexts/draggable.context.d.ts +8 -0
- package/out/Contexts/draggable.context.luau +7 -0
- package/out/Contexts/droppable.context.d.ts +6 -0
- package/out/Contexts/droppable.context.luau +7 -0
- package/out/Contexts/index.d.ts +6 -0
- package/out/Contexts/init.luau +22 -0
- package/out/Contexts/navigation.context.d.ts +5 -0
- package/out/Contexts/navigation.context.luau +9 -0
- package/out/Contexts/overlay.context.d.ts +13 -0
- package/out/Contexts/overlay.context.luau +17 -0
- package/out/Contexts/row.context.d.ts +9 -0
- package/out/Contexts/row.context.luau +12 -0
- package/out/Contexts/theme.context.d.ts +3 -0
- package/out/Contexts/theme.context.luau +8 -0
- package/out/Helpers/breakpoint.helper.d.ts +7 -0
- package/out/Helpers/breakpoint.helper.luau +124 -0
- package/out/Helpers/color.helper.d.ts +5 -0
- package/out/Helpers/color.helper.luau +101 -0
- package/out/Helpers/create-ui-story.d.ts +16 -0
- package/out/Helpers/create-ui-story.luau +38 -0
- package/out/Helpers/css.helper.d.ts +12 -0
- package/out/Helpers/css.helper.luau +114 -0
- package/out/Helpers/gui.helper.d.ts +10 -0
- package/out/Helpers/gui.helper.luau +134 -0
- package/out/Helpers/index.d.ts +8 -0
- package/out/Helpers/init.luau +28 -0
- package/out/Helpers/size.helper.d.ts +14 -0
- package/out/Helpers/size.helper.luau +162 -0
- package/out/Helpers/spacing.helper.d.ts +7 -0
- package/out/Helpers/spacing.helper.luau +57 -0
- package/out/Helpers/typography.helper.d.ts +7 -0
- package/out/Helpers/typography.helper.luau +91 -0
- package/out/Interfaces/clean.element.props.d.ts +109 -0
- package/out/Interfaces/clean.element.props.luau +5 -0
- package/out/Interfaces/icon.d.ts +2 -0
- package/out/Interfaces/icon.luau +2 -0
- package/out/Interfaces/index.d.ts +3 -0
- package/out/Interfaces/init.luau +13 -0
- package/out/Interfaces/userinput.d.ts +22 -0
- package/out/Interfaces/userinput.luau +8 -0
- package/out/Providers/index.d.ts +3 -0
- package/out/Providers/init.luau +13 -0
- package/out/Providers/overlay.provider.d.ts +3 -0
- package/out/Providers/overlay.provider.luau +25 -0
- package/out/Providers/registry.provider.d.ts +33 -0
- package/out/Providers/registry.provider.luau +119 -0
- package/out/Providers/theme.provider.d.ts +8 -0
- package/out/Providers/theme.provider.luau +12 -0
- package/out/Theme/CleanTheme.d.ts +169 -0
- package/out/Theme/CleanTheme.luau +2 -0
- package/out/Theme/DefaultIcons.d.ts +2 -0
- package/out/Theme/DefaultIcons.luau +791 -0
- package/out/Theme/index.d.ts +3 -0
- package/out/Theme/init.luau +13 -0
- package/out/Theme/themes/dark.theme.d.ts +2 -0
- package/out/Theme/themes/dark.theme.luau +345 -0
- package/out/Theme/themes/default.theme.d.ts +2 -0
- package/out/Theme/themes/default.theme.luau +403 -0
- package/out/Theme/themes/index.d.ts +3 -0
- package/out/Theme/themes/init.luau +13 -0
- package/out/Theme/themes/sandstone.theme.d.ts +2 -0
- package/out/Theme/themes/sandstone.theme.luau +345 -0
- package/out/index.d.ts +6 -0
- package/out/init.luau +22 -0
- package/package.json +43 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local Component = _react.Component
|
|
6
|
+
local ReactComponent = _react.ReactComponent
|
|
7
|
+
local CustomInputService = TS.import(script, script.Parent.Parent.Parent, "Interfaces").CustomInputService
|
|
8
|
+
local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
|
|
9
|
+
local SizeHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").SizeHelper
|
|
10
|
+
local BoxShadow = TS.import(script, script.Parent.Parent, "Decorator").BoxShadow
|
|
11
|
+
local Slider
|
|
12
|
+
do
|
|
13
|
+
local super = Component
|
|
14
|
+
Slider = setmetatable({}, {
|
|
15
|
+
__tostring = function()
|
|
16
|
+
return "Slider"
|
|
17
|
+
end,
|
|
18
|
+
__index = super,
|
|
19
|
+
})
|
|
20
|
+
Slider.__index = Slider
|
|
21
|
+
function Slider.new(...)
|
|
22
|
+
local self = setmetatable({}, Slider)
|
|
23
|
+
return self:constructor(...) or self
|
|
24
|
+
end
|
|
25
|
+
function Slider:constructor(...)
|
|
26
|
+
super.constructor(self, ...)
|
|
27
|
+
self.isDragging = false
|
|
28
|
+
self.containerRef = React.createRef()
|
|
29
|
+
self.state = {
|
|
30
|
+
value = self:getInitialValue(),
|
|
31
|
+
dragging = false,
|
|
32
|
+
hoveredHandle = nil,
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
function Slider:getInitialValue()
|
|
36
|
+
local _condition = self.props["min-value"]
|
|
37
|
+
if _condition == nil then
|
|
38
|
+
_condition = 0
|
|
39
|
+
end
|
|
40
|
+
local minValue = _condition
|
|
41
|
+
local maxValue = self.props["max-value"]
|
|
42
|
+
if self.props.range then
|
|
43
|
+
local _value = self.props.value
|
|
44
|
+
return if typeof(_value) == "Vector2" then self.props.value else Vector2.new(minValue, maxValue)
|
|
45
|
+
end
|
|
46
|
+
local _value = self.props.value
|
|
47
|
+
return if type(_value) == "number" then self.props.value else minValue
|
|
48
|
+
end
|
|
49
|
+
function Slider:getCurrentValue()
|
|
50
|
+
if self.props.controlled then
|
|
51
|
+
local value = self.props.value
|
|
52
|
+
if self.props.range then
|
|
53
|
+
local _result
|
|
54
|
+
if typeof(value) == "Vector2" then
|
|
55
|
+
_result = value
|
|
56
|
+
else
|
|
57
|
+
local _condition = self.props["min-value"]
|
|
58
|
+
if _condition == nil then
|
|
59
|
+
_condition = 0
|
|
60
|
+
end
|
|
61
|
+
_result = Vector2.new(_condition, self.props["max-value"])
|
|
62
|
+
end
|
|
63
|
+
return _result
|
|
64
|
+
end
|
|
65
|
+
local _result
|
|
66
|
+
if type(value) == "number" then
|
|
67
|
+
_result = value
|
|
68
|
+
else
|
|
69
|
+
local _condition = self.props["min-value"]
|
|
70
|
+
if _condition == nil then
|
|
71
|
+
_condition = 0
|
|
72
|
+
end
|
|
73
|
+
_result = _condition
|
|
74
|
+
end
|
|
75
|
+
return _result
|
|
76
|
+
end
|
|
77
|
+
return self.state.value
|
|
78
|
+
end
|
|
79
|
+
function Slider:getNumberFromInput(input)
|
|
80
|
+
local container = self.containerRef.current
|
|
81
|
+
if not container then
|
|
82
|
+
return nil
|
|
83
|
+
end
|
|
84
|
+
local containerWidth = container.AbsoluteSize.X
|
|
85
|
+
if containerWidth <= 0 then
|
|
86
|
+
return nil
|
|
87
|
+
end
|
|
88
|
+
local inputX = input.Position.X
|
|
89
|
+
local containerStart = container.AbsolutePosition.X
|
|
90
|
+
local percentage = math.clamp((inputX - containerStart) / containerWidth, 0, 1)
|
|
91
|
+
local _condition = self.props["min-value"]
|
|
92
|
+
if _condition == nil then
|
|
93
|
+
_condition = 0
|
|
94
|
+
end
|
|
95
|
+
local minValue = _condition
|
|
96
|
+
local maxValue = self.props["max-value"]
|
|
97
|
+
local value = minValue + percentage * (maxValue - minValue)
|
|
98
|
+
local step = self.props.step
|
|
99
|
+
if step ~= nil and step > 0 then
|
|
100
|
+
--[[
|
|
101
|
+
|
|
102
|
+
* Offset snapping from minValue so ranges such as
|
|
103
|
+
* min=5, step=2 produce 5, 7, 9, etc.
|
|
104
|
+
|
|
105
|
+
]]
|
|
106
|
+
value = minValue + math.round((value - minValue) / step) * step
|
|
107
|
+
-- Remove floating-point artifacts.
|
|
108
|
+
local parts = string.split(tostring(step), ".")
|
|
109
|
+
local decimals = if #parts > 1 then #parts[2] else 0
|
|
110
|
+
local scale = 10 ^ decimals
|
|
111
|
+
value = math.round(value * scale) / scale
|
|
112
|
+
end
|
|
113
|
+
return math.clamp(value, minValue, maxValue)
|
|
114
|
+
end
|
|
115
|
+
function Slider:getValueFromInput(input)
|
|
116
|
+
local inputValue = self:getNumberFromInput(input)
|
|
117
|
+
if inputValue == nil then
|
|
118
|
+
return nil
|
|
119
|
+
end
|
|
120
|
+
if not self.props.range then
|
|
121
|
+
return inputValue
|
|
122
|
+
end
|
|
123
|
+
local currentValue = self:getCurrentValue()
|
|
124
|
+
local _result
|
|
125
|
+
if typeof(currentValue) == "Vector2" then
|
|
126
|
+
_result = currentValue
|
|
127
|
+
else
|
|
128
|
+
local _condition = self.props["min-value"]
|
|
129
|
+
if _condition == nil then
|
|
130
|
+
_condition = 0
|
|
131
|
+
end
|
|
132
|
+
_result = Vector2.new(_condition, self.props["max-value"])
|
|
133
|
+
end
|
|
134
|
+
local rangeValue = _result
|
|
135
|
+
if self.activeHandle == 0 then
|
|
136
|
+
return Vector2.new(math.min(inputValue, rangeValue.Y), rangeValue.Y)
|
|
137
|
+
end
|
|
138
|
+
if self.activeHandle == 1 then
|
|
139
|
+
return Vector2.new(rangeValue.X, math.max(inputValue, rangeValue.X))
|
|
140
|
+
end
|
|
141
|
+
return rangeValue
|
|
142
|
+
end
|
|
143
|
+
function Slider:beginDragging(handle, input)
|
|
144
|
+
if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then
|
|
145
|
+
return nil
|
|
146
|
+
end
|
|
147
|
+
self.activeHandle = handle
|
|
148
|
+
self.isDragging = true
|
|
149
|
+
local value = self:getValueFromInput(input)
|
|
150
|
+
local _self = self
|
|
151
|
+
local _object = {
|
|
152
|
+
dragging = true,
|
|
153
|
+
}
|
|
154
|
+
local _left = "value"
|
|
155
|
+
local _condition = value
|
|
156
|
+
if _condition == nil then
|
|
157
|
+
_condition = self.state.value
|
|
158
|
+
end
|
|
159
|
+
_object[_left] = _condition
|
|
160
|
+
_self:setState(_object)
|
|
161
|
+
if value ~= nil then
|
|
162
|
+
local _result = self.props.onDragged
|
|
163
|
+
if _result ~= nil then
|
|
164
|
+
_result(value)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
function Slider:componentDidMount()
|
|
169
|
+
self.inputChangedListener = CustomInputService.InputChanged:Connect(function(input)
|
|
170
|
+
if input.UserInputType ~= Enum.UserInputType.MouseMovement and input.UserInputType ~= Enum.UserInputType.Touch then
|
|
171
|
+
return nil
|
|
172
|
+
end
|
|
173
|
+
if not self.isDragging then
|
|
174
|
+
return nil
|
|
175
|
+
end
|
|
176
|
+
local value = self:getValueFromInput(input)
|
|
177
|
+
if value == nil then
|
|
178
|
+
return nil
|
|
179
|
+
end
|
|
180
|
+
self:setState({
|
|
181
|
+
value = value,
|
|
182
|
+
})
|
|
183
|
+
local _result = self.props.onDragged
|
|
184
|
+
if _result ~= nil then
|
|
185
|
+
_result(value)
|
|
186
|
+
end
|
|
187
|
+
end)
|
|
188
|
+
self.inputEndedListener = CustomInputService.InputEnded:Connect(function(input)
|
|
189
|
+
if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then
|
|
190
|
+
return nil
|
|
191
|
+
end
|
|
192
|
+
if not self.isDragging then
|
|
193
|
+
return nil
|
|
194
|
+
end
|
|
195
|
+
--[[
|
|
196
|
+
|
|
197
|
+
* Stop processing movement immediately, before
|
|
198
|
+
* React gets around to updating the state.
|
|
199
|
+
|
|
200
|
+
]]
|
|
201
|
+
self.isDragging = false
|
|
202
|
+
local value = self:getValueFromInput(input)
|
|
203
|
+
self.activeHandle = nil
|
|
204
|
+
local _self = self
|
|
205
|
+
local _object = {}
|
|
206
|
+
local _left = "value"
|
|
207
|
+
local _condition = value
|
|
208
|
+
if _condition == nil then
|
|
209
|
+
_condition = self.state.value
|
|
210
|
+
end
|
|
211
|
+
_object[_left] = _condition
|
|
212
|
+
_object.dragging = false
|
|
213
|
+
_object.hoveredHandle = React.None
|
|
214
|
+
_self:setState(_object)
|
|
215
|
+
if value ~= nil then
|
|
216
|
+
local _result = self.props.onChanged
|
|
217
|
+
if _result ~= nil then
|
|
218
|
+
_result(value)
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end)
|
|
222
|
+
end
|
|
223
|
+
function Slider:componentWillUnmount()
|
|
224
|
+
self.isDragging = false
|
|
225
|
+
self.activeHandle = nil
|
|
226
|
+
local _result = self.inputChangedListener
|
|
227
|
+
if _result ~= nil then
|
|
228
|
+
_result:Disconnect()
|
|
229
|
+
end
|
|
230
|
+
local _result_1 = self.inputEndedListener
|
|
231
|
+
if _result_1 ~= nil then
|
|
232
|
+
_result_1:Disconnect()
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
function Slider:render()
|
|
236
|
+
local theme = self.context.components.slider
|
|
237
|
+
local height = SizeHelper:toUDim(theme.height)
|
|
238
|
+
local _condition = self.props["min-value"]
|
|
239
|
+
if _condition == nil then
|
|
240
|
+
_condition = 0
|
|
241
|
+
end
|
|
242
|
+
local minValue = _condition
|
|
243
|
+
local maxValue = self.props["max-value"]
|
|
244
|
+
local valueRange = maxValue - minValue
|
|
245
|
+
local currentValue = self:getCurrentValue()
|
|
246
|
+
local firstValue
|
|
247
|
+
local secondValue
|
|
248
|
+
if self.props.range and typeof(currentValue) == "Vector2" then
|
|
249
|
+
firstValue = currentValue.X
|
|
250
|
+
secondValue = currentValue.Y
|
|
251
|
+
else
|
|
252
|
+
firstValue = if type(currentValue) == "number" then currentValue else currentValue.X
|
|
253
|
+
end
|
|
254
|
+
local getPosition = function(value)
|
|
255
|
+
if valueRange <= 0 then
|
|
256
|
+
return 0
|
|
257
|
+
end
|
|
258
|
+
return math.clamp((value - minValue) / valueRange, 0, 1)
|
|
259
|
+
end
|
|
260
|
+
local firstPosition = getPosition(firstValue)
|
|
261
|
+
local secondPosition = if secondValue ~= nil then getPosition(secondValue) else nil
|
|
262
|
+
local padding = SizeHelper:toUDim(theme.bar.padding)
|
|
263
|
+
local handles = { {
|
|
264
|
+
index = 0,
|
|
265
|
+
position = firstPosition,
|
|
266
|
+
} }
|
|
267
|
+
if self.props.range and secondPosition ~= nil then
|
|
268
|
+
local _arg0 = {
|
|
269
|
+
index = 1,
|
|
270
|
+
position = secondPosition,
|
|
271
|
+
}
|
|
272
|
+
table.insert(handles, _arg0)
|
|
273
|
+
end
|
|
274
|
+
local _exp = React.createElement("frame", {
|
|
275
|
+
Size = UDim2.new(UDim.new(1, 0), SizeHelper:toUDim(theme.bar.height)),
|
|
276
|
+
Position = UDim2.fromScale(0.5, 0.5),
|
|
277
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
278
|
+
BackgroundTransparency = theme.bar.backgroundTransparency,
|
|
279
|
+
BackgroundColor3 = theme.bar.backgroundColor,
|
|
280
|
+
}, React.createElement("uistroke", {
|
|
281
|
+
Thickness = theme.bar.borderThickness,
|
|
282
|
+
Color = theme.bar.borderColor,
|
|
283
|
+
}), React.createElement("uicorner", {
|
|
284
|
+
CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
|
|
285
|
+
}))
|
|
286
|
+
local _attributes = {
|
|
287
|
+
ref = self.containerRef,
|
|
288
|
+
}
|
|
289
|
+
local _exp_1 = UDim2.fromScale(1, 1)
|
|
290
|
+
local _uDim2 = UDim2.new(padding + padding, UDim.new(0, 0))
|
|
291
|
+
_attributes.Size = _exp_1 - _uDim2
|
|
292
|
+
_attributes.BackgroundTransparency = 1
|
|
293
|
+
_attributes.Position = UDim2.fromScale(0.5, 0.5)
|
|
294
|
+
_attributes.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
295
|
+
local _condition_1 = self.props.highlight ~= nil
|
|
296
|
+
if _condition_1 then
|
|
297
|
+
local _attributes_1 = {
|
|
298
|
+
BackgroundColor3 = theme.bar.highlight.backgroundColor,
|
|
299
|
+
BackgroundTransparency = theme.bar.highlight.backgroundTransparency,
|
|
300
|
+
}
|
|
301
|
+
local _result
|
|
302
|
+
if self.props.highlight == "start" then
|
|
303
|
+
local _exp_2 = UDim2.fromScale(0, 0.5)
|
|
304
|
+
local _uDim2_1 = UDim2.new(padding, UDim.new(0, 0))
|
|
305
|
+
_result = _exp_2 - _uDim2_1
|
|
306
|
+
else
|
|
307
|
+
local _result_1
|
|
308
|
+
if self.props.highlight == "end" then
|
|
309
|
+
local _exp_2 = UDim2.fromScale(1, 0.5)
|
|
310
|
+
local _uDim2_1 = UDim2.new(padding, UDim.new(0, 0))
|
|
311
|
+
_result_1 = _exp_2 + _uDim2_1
|
|
312
|
+
else
|
|
313
|
+
_result_1 = UDim2.fromScale(firstPosition, 0.5)
|
|
314
|
+
end
|
|
315
|
+
_result = _result_1
|
|
316
|
+
end
|
|
317
|
+
_attributes_1.Position = _result
|
|
318
|
+
_attributes_1.AnchorPoint = if self.props.highlight == "end" then Vector2.new(1, 0.5) else Vector2.new(0, 0.5)
|
|
319
|
+
local _result_1
|
|
320
|
+
if self.props.highlight == "start" then
|
|
321
|
+
local _uDim2_1 = UDim2.new(UDim.new(firstPosition, 0), SizeHelper:toUDim(theme.bar.height))
|
|
322
|
+
local _uDim2_2 = UDim2.new(padding, UDim.new(0, 0))
|
|
323
|
+
_result_1 = _uDim2_1 + _uDim2_2
|
|
324
|
+
else
|
|
325
|
+
local _result_2
|
|
326
|
+
if self.props.highlight == "end" then
|
|
327
|
+
local _condition_2 = secondPosition
|
|
328
|
+
if _condition_2 == nil then
|
|
329
|
+
_condition_2 = firstPosition
|
|
330
|
+
end
|
|
331
|
+
local _uDim2_1 = UDim2.new(UDim.new(1 - _condition_2, 0), SizeHelper:toUDim(theme.bar.height))
|
|
332
|
+
local _uDim2_2 = UDim2.new(padding, UDim.new(0, 0))
|
|
333
|
+
_result_2 = _uDim2_1 + _uDim2_2
|
|
334
|
+
else
|
|
335
|
+
local _condition_2 = secondPosition
|
|
336
|
+
if _condition_2 == nil then
|
|
337
|
+
_condition_2 = 0
|
|
338
|
+
end
|
|
339
|
+
_result_2 = UDim2.new(UDim.new(_condition_2 - firstPosition, 0), SizeHelper:toUDim(theme.bar.height))
|
|
340
|
+
end
|
|
341
|
+
_result_1 = _result_2
|
|
342
|
+
end
|
|
343
|
+
_attributes_1.Size = _result_1
|
|
344
|
+
_condition_1 = React.createElement("frame", _attributes_1, React.createElement("uistroke", {
|
|
345
|
+
Thickness = theme.bar.borderThickness,
|
|
346
|
+
Color = theme.bar.highlight.borderColor,
|
|
347
|
+
}), React.createElement("uicorner", {
|
|
348
|
+
CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
|
|
349
|
+
}))
|
|
350
|
+
end
|
|
351
|
+
-- ▼ ReadonlyArray.map ▼
|
|
352
|
+
local _newValue = table.create(#handles)
|
|
353
|
+
local _callback = function(_param)
|
|
354
|
+
local index = _param.index
|
|
355
|
+
local position = _param.position
|
|
356
|
+
local _exp_2 = React.createElement("uistroke", {
|
|
357
|
+
Thickness = theme.handle.borderThickness,
|
|
358
|
+
Color = theme.handle.borderColor,
|
|
359
|
+
})
|
|
360
|
+
local _exp_3 = React.createElement("uicorner", {
|
|
361
|
+
CornerRadius = SizeHelper:toUDim(theme.handle.cornerRadius),
|
|
362
|
+
})
|
|
363
|
+
local _exp_4 = (self.state.hoveredHandle == index or (self.state.dragging and self.activeHandle == index)) and (React.createElement(BoxShadow, {
|
|
364
|
+
["box-shadow"] = theme.handle.boxShadow,
|
|
365
|
+
}))
|
|
366
|
+
local _attributes_1 = {}
|
|
367
|
+
local _condition_2 = theme.handle.aspectRation
|
|
368
|
+
if _condition_2 == nil then
|
|
369
|
+
_condition_2 = 1
|
|
370
|
+
end
|
|
371
|
+
_attributes_1.AspectRatio = _condition_2
|
|
372
|
+
_attributes_1.DominantAxis = Enum.DominantAxis.Height
|
|
373
|
+
_attributes_1.AspectType = Enum.AspectType.ScaleWithParentSize
|
|
374
|
+
return React.createElement("frame", {
|
|
375
|
+
key = index,
|
|
376
|
+
Position = UDim2.fromScale(position, 0.5),
|
|
377
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
378
|
+
Size = UDim2.fromScale(0, 1),
|
|
379
|
+
BackgroundTransparency = theme.handle.backgroundTransparency,
|
|
380
|
+
BackgroundColor3 = theme.handle.backgroundColor,
|
|
381
|
+
BorderSizePixel = 0,
|
|
382
|
+
Event = {
|
|
383
|
+
InputBegan = function(_instance, input)
|
|
384
|
+
self:beginDragging(index, input)
|
|
385
|
+
end,
|
|
386
|
+
MouseEnter = function()
|
|
387
|
+
self:setState({
|
|
388
|
+
hoveredHandle = index,
|
|
389
|
+
})
|
|
390
|
+
end,
|
|
391
|
+
MouseLeave = function()
|
|
392
|
+
self:setState(function(state)
|
|
393
|
+
return {
|
|
394
|
+
hoveredHandle = if state.hoveredHandle == index then React.None else (if state.hoveredHandle == nil then React.None else state.hoveredHandle),
|
|
395
|
+
}
|
|
396
|
+
end)
|
|
397
|
+
end,
|
|
398
|
+
},
|
|
399
|
+
}, _exp_2, _exp_3, _exp_4, React.createElement("uiaspectratioconstraint", _attributes_1))
|
|
400
|
+
end
|
|
401
|
+
for _k, _v in handles do
|
|
402
|
+
_newValue[_k] = _callback(_v, _k - 1, handles)
|
|
403
|
+
end
|
|
404
|
+
-- ▲ ReadonlyArray.map ▲
|
|
405
|
+
return React.createElement("frame", {
|
|
406
|
+
Size = UDim2.new(UDim.new(1, 0), height),
|
|
407
|
+
BackgroundTransparency = 1,
|
|
408
|
+
}, _exp, React.createElement("frame", _attributes, _condition_1, _newValue))
|
|
409
|
+
end
|
|
410
|
+
Slider.contextType = CleanThemeContext
|
|
411
|
+
Slider = ReactComponent(Slider) or Slider
|
|
412
|
+
end
|
|
413
|
+
return {
|
|
414
|
+
Slider = Slider,
|
|
415
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local exports = {}
|
|
4
|
+
for _k, _v in TS.import(script, script, "Button") or {} do
|
|
5
|
+
exports[_k] = _v
|
|
6
|
+
end
|
|
7
|
+
for _k, _v in TS.import(script, script, "Checkbox") or {} do
|
|
8
|
+
exports[_k] = _v
|
|
9
|
+
end
|
|
10
|
+
for _k, _v in TS.import(script, script, "HoverButton") or {} do
|
|
11
|
+
exports[_k] = _v
|
|
12
|
+
end
|
|
13
|
+
for _k, _v in TS.import(script, script, "Input") or {} do
|
|
14
|
+
exports[_k] = _v
|
|
15
|
+
end
|
|
16
|
+
for _k, _v in TS.import(script, script, "Select") or {} do
|
|
17
|
+
exports[_k] = _v
|
|
18
|
+
end
|
|
19
|
+
for _k, _v in TS.import(script, script, "Slider") or {} do
|
|
20
|
+
exports[_k] = _v
|
|
21
|
+
end
|
|
22
|
+
return exports
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { Component } from "@rbxts/react";
|
|
2
|
+
import { RowContext } from "../../Contexts/";
|
|
3
|
+
import { ResponsiveGridSpan } from "../../Interfaces/";
|
|
4
|
+
interface ColumnProps {
|
|
5
|
+
span?: ResponsiveGridSpan | number | `${number}`;
|
|
6
|
+
}
|
|
7
|
+
export declare class Column extends Component<ColumnProps> {
|
|
8
|
+
static contextType: React.Context<import("../../Contexts/row.context").RowContextValue>;
|
|
9
|
+
context: React.ContextType<typeof RowContext>;
|
|
10
|
+
private getSpan;
|
|
11
|
+
render(): React.JSX.Element;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local Component = _react.Component
|
|
6
|
+
local ReactComponent = _react.ReactComponent
|
|
7
|
+
local RowContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").RowContext
|
|
8
|
+
local BreakpointHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").BreakpointHelper
|
|
9
|
+
local Column
|
|
10
|
+
do
|
|
11
|
+
local super = Component
|
|
12
|
+
Column = setmetatable({}, {
|
|
13
|
+
__tostring = function()
|
|
14
|
+
return "Column"
|
|
15
|
+
end,
|
|
16
|
+
__index = super,
|
|
17
|
+
})
|
|
18
|
+
Column.__index = Column
|
|
19
|
+
function Column.new(...)
|
|
20
|
+
local self = setmetatable({}, Column)
|
|
21
|
+
return self:constructor(...) or self
|
|
22
|
+
end
|
|
23
|
+
function Column:constructor(...)
|
|
24
|
+
super.constructor(self, ...)
|
|
25
|
+
end
|
|
26
|
+
function Column:getSpan()
|
|
27
|
+
local span = self.props.span
|
|
28
|
+
if span == nil then
|
|
29
|
+
return math.floor(12 / math.max(self.context.children, 1))
|
|
30
|
+
end
|
|
31
|
+
if type(span) == "number" then
|
|
32
|
+
return span
|
|
33
|
+
end
|
|
34
|
+
if type(span) == "string" then
|
|
35
|
+
local _condition = tonumber(span)
|
|
36
|
+
if _condition == nil then
|
|
37
|
+
_condition = 12
|
|
38
|
+
end
|
|
39
|
+
return _condition
|
|
40
|
+
end
|
|
41
|
+
return BreakpointHelper:getValue(self.context.breakpoint, span) or 12
|
|
42
|
+
end
|
|
43
|
+
function Column:render()
|
|
44
|
+
local span = self:getSpan()
|
|
45
|
+
local fraction = math.floor((span / 12) * 1000) / 1000
|
|
46
|
+
local padding = self.context.padding
|
|
47
|
+
local widthScale = fraction + ((fraction - 1) * padding.Scale)
|
|
48
|
+
local widthOffset = (fraction - 1) * padding.Offset
|
|
49
|
+
return React.createElement("frame", {
|
|
50
|
+
Size = UDim2.new(widthScale, widthOffset, 0, 0),
|
|
51
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
52
|
+
BackgroundTransparency = 1,
|
|
53
|
+
}, self.props.children)
|
|
54
|
+
end
|
|
55
|
+
Column.contextType = RowContext
|
|
56
|
+
Column = ReactComponent(Column) or Column
|
|
57
|
+
end
|
|
58
|
+
return {
|
|
59
|
+
Column = Column,
|
|
60
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { PositionElementProps, SizeElementProps, ZIndexElementProps } from "../../Interfaces/";
|
|
3
|
+
export interface ContainerProps extends SizeElementProps, PositionElementProps, ZIndexElementProps, React.InstanceProps<Frame> {
|
|
4
|
+
group?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Container: React.ForwardRefExoticComponent<Omit<ContainerProps, "ref"> & React.RefAttributes<Frame>>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local SizeHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").SizeHelper
|
|
5
|
+
local _Group = TS.import(script, script.Parent, "Group")
|
|
6
|
+
local Group = _Group.Group
|
|
7
|
+
local GroupContext = _Group.GroupContext
|
|
8
|
+
local Container = React.forwardRef(function(props, ref)
|
|
9
|
+
local group = React.useContext(GroupContext)
|
|
10
|
+
local _attributes = {
|
|
11
|
+
ref = ref,
|
|
12
|
+
Archivable = props.Archivable,
|
|
13
|
+
Tag = props.Tag,
|
|
14
|
+
Active = props.Active,
|
|
15
|
+
AnchorPoint = SizeHelper:GetAnchor(props),
|
|
16
|
+
AutomaticSize = SizeHelper:GetAutoSize(props),
|
|
17
|
+
BackgroundColor3 = props.BackgroundColor3,
|
|
18
|
+
}
|
|
19
|
+
local _condition = props.BackgroundTransparency
|
|
20
|
+
if _condition == nil then
|
|
21
|
+
_condition = 1
|
|
22
|
+
end
|
|
23
|
+
_attributes.BackgroundTransparency = _condition
|
|
24
|
+
_attributes.BorderColor3 = props.BorderColor3
|
|
25
|
+
_attributes.BorderMode = props.BorderMode
|
|
26
|
+
_attributes.BorderSizePixel = props.BorderSizePixel
|
|
27
|
+
_attributes.ClipsDescendants = props.ClipsDescendants
|
|
28
|
+
_attributes.Interactable = props.Interactable
|
|
29
|
+
_attributes.LayoutOrder = props.LayoutOrder
|
|
30
|
+
_attributes.NextSelectionDown = props.NextSelectionDown
|
|
31
|
+
_attributes.NextSelectionLeft = props.NextSelectionLeft
|
|
32
|
+
_attributes.NextSelectionRight = props.NextSelectionRight
|
|
33
|
+
_attributes.NextSelectionUp = props.NextSelectionUp
|
|
34
|
+
_attributes.Position = SizeHelper:GetPosition(props)
|
|
35
|
+
_attributes.Rotation = props.Rotation
|
|
36
|
+
_attributes.Selectable = props.Selectable
|
|
37
|
+
_attributes.SelectionGroup = props.SelectionGroup
|
|
38
|
+
_attributes.SelectionImageObject = props.SelectionImageObject
|
|
39
|
+
_attributes.SelectionOrder = props.SelectionOrder
|
|
40
|
+
local _exp = props
|
|
41
|
+
local _result
|
|
42
|
+
if props.group then
|
|
43
|
+
local _result_1 = group
|
|
44
|
+
if _result_1 ~= nil then
|
|
45
|
+
_result_1 = _result_1.size
|
|
46
|
+
if _result_1 ~= nil then
|
|
47
|
+
_result_1 = _result_1.X
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
local _condition_1 = _result_1
|
|
51
|
+
if _condition_1 == nil then
|
|
52
|
+
_condition_1 = 0
|
|
53
|
+
end
|
|
54
|
+
_result = _condition_1
|
|
55
|
+
else
|
|
56
|
+
_result = 0
|
|
57
|
+
end
|
|
58
|
+
_attributes.Size = SizeHelper:GetSize(_exp, UDim2.fromOffset(_result, 0))
|
|
59
|
+
_attributes.SizeConstraint = props.SizeConstraint
|
|
60
|
+
_attributes.Visible = props.Visible
|
|
61
|
+
_attributes.ZIndex = props.ZIndex
|
|
62
|
+
_attributes.AutoLocalize = props.AutoLocalize
|
|
63
|
+
_attributes.RootLocalizationTable = props.RootLocalizationTable
|
|
64
|
+
_attributes.Style = props.Style
|
|
65
|
+
_attributes.Change = props.Change
|
|
66
|
+
_attributes.Event = props.Event
|
|
67
|
+
return React.createElement("frame", _attributes, React.createElement(Group.Element, {
|
|
68
|
+
enabled = props.group,
|
|
69
|
+
}, props.children))
|
|
70
|
+
end)
|
|
71
|
+
return {
|
|
72
|
+
Container = Container,
|
|
73
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { Component, ReactNode } from "@rbxts/react";
|
|
2
|
+
import { DroppableRegistration, RegistryContext } from "../../Providers";
|
|
3
|
+
type GuiObjectProps = React.InstanceProps<GuiObject>;
|
|
4
|
+
type GuiElement = React.ReactElement<GuiObjectProps>;
|
|
5
|
+
interface DragHandleProps {
|
|
6
|
+
children: GuiElement;
|
|
7
|
+
}
|
|
8
|
+
declare function DragHandle({ children }: DragHandleProps): React.ReactElement<GuiObjectProps, string | React.JSXElementConstructor<any>>;
|
|
9
|
+
interface DraggableProps {
|
|
10
|
+
onDropped?: (droppable?: DroppableRegistration) => void;
|
|
11
|
+
onDragged?: (droppable?: DroppableRegistration) => void;
|
|
12
|
+
onStartDrag?: () => void;
|
|
13
|
+
placeholder?: boolean;
|
|
14
|
+
retainPosition?: boolean;
|
|
15
|
+
children: GuiElement;
|
|
16
|
+
id?: string;
|
|
17
|
+
}
|
|
18
|
+
interface DraggableState {
|
|
19
|
+
dragging: boolean;
|
|
20
|
+
overlayPosition: Vector2;
|
|
21
|
+
overlaySize: Vector2;
|
|
22
|
+
placeholderPosition: UDim2;
|
|
23
|
+
placeholderAnchorPoint: Vector2;
|
|
24
|
+
placeholderLayoutOrder: number;
|
|
25
|
+
placeholderZIndex: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class Draggable extends Component<DraggableProps, DraggableState> {
|
|
28
|
+
static Handle: typeof DragHandle;
|
|
29
|
+
readonly state: DraggableState;
|
|
30
|
+
static contextType: React.Context<import("../../Providers").RegistryContextValue | undefined>;
|
|
31
|
+
context: React.ContextType<typeof RegistryContext>;
|
|
32
|
+
rootRef: React.RefObject<GuiObject>;
|
|
33
|
+
private readonly placeholderRef;
|
|
34
|
+
private dragInformation;
|
|
35
|
+
private usePlaceholder;
|
|
36
|
+
private registration;
|
|
37
|
+
componentDidMount(): void;
|
|
38
|
+
componentWillUnmount(): void;
|
|
39
|
+
private beginDrag;
|
|
40
|
+
private updateDrag;
|
|
41
|
+
private endDrag;
|
|
42
|
+
private findDroppable;
|
|
43
|
+
private readonly contextValue;
|
|
44
|
+
render(): ReactNode;
|
|
45
|
+
}
|
|
46
|
+
export {};
|