@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,288 @@
|
|
|
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 ReactRoblox = TS.import(script, TS.getModule(script, "@rbxts", "react-roblox"))
|
|
8
|
+
local _Contexts = TS.import(script, script.Parent.Parent.Parent, "Contexts")
|
|
9
|
+
local CleanThemeContext = _Contexts.CleanThemeContext
|
|
10
|
+
local OverlayContext = _Contexts.OverlayContext
|
|
11
|
+
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
12
|
+
local ColorHelper = _Helpers.ColorHelper
|
|
13
|
+
local SizeHelper = _Helpers.SizeHelper
|
|
14
|
+
local TypographyHelper = _Helpers.TypographyHelper
|
|
15
|
+
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
16
|
+
local Corners = _Decorator.Corners
|
|
17
|
+
local Padding = _Decorator.Padding
|
|
18
|
+
local _Layout = TS.import(script, script.Parent.Parent, "Layout")
|
|
19
|
+
local FieldsetContext = _Layout.FieldsetContext
|
|
20
|
+
local FlexItem = _Layout.FlexItem
|
|
21
|
+
local HStack = _Layout.HStack
|
|
22
|
+
local Scroller = _Layout.Scroller
|
|
23
|
+
local VStack = _Layout.VStack
|
|
24
|
+
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
25
|
+
local Icon = TS.import(script, script.Parent.Parent, "Surface").Icon
|
|
26
|
+
local SelectContext = React.createContext(nil)
|
|
27
|
+
local function SelectOption(props)
|
|
28
|
+
local theme = React.useContext(CleanThemeContext)
|
|
29
|
+
local hover, setHover = React.useState(false)
|
|
30
|
+
local context = React.useContext(SelectContext)
|
|
31
|
+
local _arg0 = context ~= nil
|
|
32
|
+
assert(_arg0, "Select.Option must be used inside a Select")
|
|
33
|
+
local _arg0_1 = props.index ~= nil
|
|
34
|
+
assert(_arg0_1, "Select.Option must be a direct child of Select")
|
|
35
|
+
local _attributes = {}
|
|
36
|
+
local _object = {}
|
|
37
|
+
local _spread = props.Event
|
|
38
|
+
if _spread then
|
|
39
|
+
for _k, _v in _spread do
|
|
40
|
+
_object[_k] = _v
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
_object.MouseEnter = function(button, x, y)
|
|
44
|
+
setHover(true)
|
|
45
|
+
local _result = props.Event
|
|
46
|
+
if _result ~= nil then
|
|
47
|
+
_result = _result.MouseEnter
|
|
48
|
+
if _result ~= nil then
|
|
49
|
+
_result(button, x, y)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
_object.MouseLeave = function(button, x, y)
|
|
54
|
+
setHover(false)
|
|
55
|
+
local _result = props.Event
|
|
56
|
+
if _result ~= nil then
|
|
57
|
+
_result = _result.MouseLeave
|
|
58
|
+
if _result ~= nil then
|
|
59
|
+
_result(button, x, y)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
_object.Activated = function()
|
|
64
|
+
context.setSelected(props.index, props.value)
|
|
65
|
+
context.closeDropdown()
|
|
66
|
+
end
|
|
67
|
+
_attributes.Event = _object
|
|
68
|
+
_attributes.Size = UDim2.new(1, 0, 0, 0)
|
|
69
|
+
_attributes.AutomaticSize = Enum.AutomaticSize.Y
|
|
70
|
+
_attributes.BackgroundTransparency = 0
|
|
71
|
+
_attributes.BackgroundColor3 = ColorHelper:getIntentColors(theme, "primary", if context.selected == props.index then "focus" elseif hover then "hover" else "default", theme.components.select.intents).backgroundColor
|
|
72
|
+
_attributes.AutoButtonColor = false
|
|
73
|
+
local _attributes_1 = table.clone(props)
|
|
74
|
+
setmetatable(_attributes_1, nil)
|
|
75
|
+
return React.createElement("imagebutton", _attributes, React.createElement(Padding, _attributes_1), props.text ~= nil and props.children == nil and React.createElement(Text, {
|
|
76
|
+
text = props.text,
|
|
77
|
+
TextColor3 = ColorHelper:getIntentColors(theme, "primary", if context.selected == props.index then "focus" elseif hover then "hover" else "default", theme.components.select.intents).textColor,
|
|
78
|
+
}), props.children)
|
|
79
|
+
end
|
|
80
|
+
local function ActivateSelect(context, overlay)
|
|
81
|
+
local button = context.buttonRef.current
|
|
82
|
+
if button and overlay.overlay then
|
|
83
|
+
if context.open then
|
|
84
|
+
context.closeDropdown()
|
|
85
|
+
return nil
|
|
86
|
+
end
|
|
87
|
+
local buttonPosition = button.AbsolutePosition
|
|
88
|
+
local overlayPosition = overlay.overlay.AbsolutePosition
|
|
89
|
+
local localPosition = buttonPosition - overlayPosition
|
|
90
|
+
context.openDropdown(UDim2.fromOffset(button.AbsoluteSize.X, button.AbsoluteSize.Y), UDim2.fromOffset(localPosition.X, localPosition.Y))
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
local function SelectRenderer(props)
|
|
94
|
+
local context = React.useContext(SelectContext)
|
|
95
|
+
local theme = React.useContext(CleanThemeContext)
|
|
96
|
+
local overlay = React.useContext(OverlayContext)
|
|
97
|
+
local fieldset = React.useContext(FieldsetContext)
|
|
98
|
+
local contentHeight, setContentHeight = React.useState(0)
|
|
99
|
+
local _labelActivated = fieldset
|
|
100
|
+
if _labelActivated ~= nil then
|
|
101
|
+
_labelActivated = _labelActivated.labelActivated
|
|
102
|
+
end
|
|
103
|
+
local labelActivated = _labelActivated
|
|
104
|
+
local overlayInstance = overlay.overlay
|
|
105
|
+
local _buttonRef = context
|
|
106
|
+
if _buttonRef ~= nil then
|
|
107
|
+
_buttonRef = _buttonRef.buttonRef
|
|
108
|
+
end
|
|
109
|
+
local buttonRef = _buttonRef
|
|
110
|
+
local _openDropdown = context
|
|
111
|
+
if _openDropdown ~= nil then
|
|
112
|
+
_openDropdown = _openDropdown.openDropdown
|
|
113
|
+
end
|
|
114
|
+
local openDropdown = _openDropdown
|
|
115
|
+
local _arg0 = context ~= nil
|
|
116
|
+
assert(_arg0, "SelectRenderer must be used inside a Select")
|
|
117
|
+
if context.open and overlay.overlay == nil then
|
|
118
|
+
warn("You have used a Select component without using the Overlay Provider")
|
|
119
|
+
end
|
|
120
|
+
local typography = TypographyHelper:getTypography(theme, context.props.scale, theme.components.select.typography)
|
|
121
|
+
local children = React.Children.toArray(context.props.children)
|
|
122
|
+
local selectedOption = (children[context.selected + 1] or children[1])
|
|
123
|
+
local dropdownHeight = math.min(contentHeight, if props["max-height"] ~= nil then SizeHelper:toUDim(props["max-height"]).Offset else theme.components.select.maxDropDownHeight)
|
|
124
|
+
React.useEffect(function()
|
|
125
|
+
if not labelActivated then
|
|
126
|
+
return nil
|
|
127
|
+
end
|
|
128
|
+
local connection = labelActivated.Event:Connect(function()
|
|
129
|
+
ActivateSelect(context, overlay)
|
|
130
|
+
end)
|
|
131
|
+
return function()
|
|
132
|
+
return connection:Disconnect()
|
|
133
|
+
end
|
|
134
|
+
end, { labelActivated, overlayInstance, buttonRef, openDropdown })
|
|
135
|
+
local _exp = React.createElement("uistroke", {
|
|
136
|
+
Thickness = theme.components.select.borderThickness,
|
|
137
|
+
BorderStrokePosition = Enum.BorderStrokePosition.Inner,
|
|
138
|
+
Color = theme.components.select.borderColor,
|
|
139
|
+
})
|
|
140
|
+
local _exp_1 = React.createElement(Corners, {
|
|
141
|
+
radius = theme.components.select.cornerRadius,
|
|
142
|
+
})
|
|
143
|
+
local _attributes = table.clone(context.props)
|
|
144
|
+
setmetatable(_attributes, nil)
|
|
145
|
+
local _exp_2 = React.createElement(Padding, _attributes)
|
|
146
|
+
local _attributes_1 = {}
|
|
147
|
+
local _result = selectedOption
|
|
148
|
+
if _result ~= nil then
|
|
149
|
+
_result = _result.props.text
|
|
150
|
+
end
|
|
151
|
+
local _condition = _result
|
|
152
|
+
if _condition == nil then
|
|
153
|
+
_condition = "No Options"
|
|
154
|
+
end
|
|
155
|
+
_attributes_1.text = _condition
|
|
156
|
+
_attributes_1.typography = typography
|
|
157
|
+
local _exp_3 = React.createElement(HStack, nil, React.createElement(FlexItem, nil, React.createElement(Text, _attributes_1)), React.createElement(Icon, {
|
|
158
|
+
icon = "caret-down",
|
|
159
|
+
color = theme.colors.intents.primary.default.textColor,
|
|
160
|
+
}))
|
|
161
|
+
local _condition_1 = context.open and overlay.overlay ~= nil
|
|
162
|
+
if _condition_1 then
|
|
163
|
+
local _attributes_2 = {
|
|
164
|
+
BackgroundTransparency = 0,
|
|
165
|
+
BackgroundColor3 = theme.components.select.dropDownBackgroundColor,
|
|
166
|
+
AnchorPoint = Vector2.zero,
|
|
167
|
+
}
|
|
168
|
+
local _dropdownPosition = context.dropdownPosition
|
|
169
|
+
local _uDim2 = UDim2.new(0, 0, 0, context.dropdownSize.Y.Offset)
|
|
170
|
+
_attributes_2.Position = _dropdownPosition + _uDim2
|
|
171
|
+
_attributes_2.Size = UDim2.fromOffset(context.dropdownSize.X.Offset, 0)
|
|
172
|
+
_attributes_2.AutomaticSize = Enum.AutomaticSize.Y
|
|
173
|
+
_attributes_2.ClipsDescendants = true
|
|
174
|
+
_condition_1 = ReactRoblox.createPortal(React.createElement("frame", _attributes_2, React.createElement("uistroke", {
|
|
175
|
+
Thickness = theme.components.select.borderThickness,
|
|
176
|
+
BorderStrokePosition = Enum.BorderStrokePosition.Outer,
|
|
177
|
+
Color = theme.components.select.borderColor,
|
|
178
|
+
}), React.createElement(Corners, {
|
|
179
|
+
radius = theme.components.select.cornerRadius,
|
|
180
|
+
}), React.createElement(Scroller, {
|
|
181
|
+
Size = UDim2.new(1, 0, 0, dropdownHeight),
|
|
182
|
+
spacing = "None",
|
|
183
|
+
}, React.createElement(VStack, {
|
|
184
|
+
spacing = "None",
|
|
185
|
+
Change = {
|
|
186
|
+
AbsoluteContentSize = function(layout)
|
|
187
|
+
setContentHeight(layout.AbsoluteContentSize.Y)
|
|
188
|
+
end,
|
|
189
|
+
},
|
|
190
|
+
}, React.Children.map(context.props.children, function(child, index)
|
|
191
|
+
if not React.isValidElement(child) then
|
|
192
|
+
return child
|
|
193
|
+
end
|
|
194
|
+
return React.cloneElement(child, {
|
|
195
|
+
index = index - 1,
|
|
196
|
+
})
|
|
197
|
+
end)))), overlay.overlay)
|
|
198
|
+
end
|
|
199
|
+
return React.createElement("imagebutton", {
|
|
200
|
+
ref = context.buttonRef,
|
|
201
|
+
Size = UDim2.fromScale(1, 0),
|
|
202
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
203
|
+
BackgroundTransparency = 1,
|
|
204
|
+
Event = {
|
|
205
|
+
Activated = function()
|
|
206
|
+
ActivateSelect(context, overlay)
|
|
207
|
+
end,
|
|
208
|
+
},
|
|
209
|
+
}, _exp, _exp_1, _exp_2, _exp_3, _condition_1)
|
|
210
|
+
end
|
|
211
|
+
local Select
|
|
212
|
+
do
|
|
213
|
+
local super = Component
|
|
214
|
+
Select = setmetatable({}, {
|
|
215
|
+
__tostring = function()
|
|
216
|
+
return "Select"
|
|
217
|
+
end,
|
|
218
|
+
__index = super,
|
|
219
|
+
})
|
|
220
|
+
Select.__index = Select
|
|
221
|
+
function Select.new(...)
|
|
222
|
+
local self = setmetatable({}, Select)
|
|
223
|
+
return self:constructor(...) or self
|
|
224
|
+
end
|
|
225
|
+
function Select:constructor(...)
|
|
226
|
+
super.constructor(self, ...)
|
|
227
|
+
local _object = {}
|
|
228
|
+
local _left = "selected"
|
|
229
|
+
local _condition = self.props.selected
|
|
230
|
+
if _condition == nil then
|
|
231
|
+
_condition = 0
|
|
232
|
+
end
|
|
233
|
+
_object[_left] = _condition
|
|
234
|
+
_object.open = false
|
|
235
|
+
_object.dropdownSize = UDim2.fromOffset(0, 0)
|
|
236
|
+
_object.dropdownPosition = UDim2.fromOffset(0, 0)
|
|
237
|
+
self.state = _object
|
|
238
|
+
self.buttonRef = React.createRef()
|
|
239
|
+
end
|
|
240
|
+
function Select:render()
|
|
241
|
+
local context = {
|
|
242
|
+
props = self.props,
|
|
243
|
+
selected = self.state.selected,
|
|
244
|
+
open = self.state.open,
|
|
245
|
+
dropdownSize = self.state.dropdownSize,
|
|
246
|
+
dropdownPosition = self.state.dropdownPosition,
|
|
247
|
+
buttonRef = self.buttonRef,
|
|
248
|
+
setSelected = function(selected, value)
|
|
249
|
+
local _result = self.props.onChange
|
|
250
|
+
if _result ~= nil then
|
|
251
|
+
_result(selected, value)
|
|
252
|
+
end
|
|
253
|
+
self:setState({
|
|
254
|
+
selected = selected,
|
|
255
|
+
})
|
|
256
|
+
end,
|
|
257
|
+
openDropdown = function(size, position)
|
|
258
|
+
self:setState({
|
|
259
|
+
dropdownSize = size,
|
|
260
|
+
dropdownPosition = position,
|
|
261
|
+
open = true,
|
|
262
|
+
})
|
|
263
|
+
end,
|
|
264
|
+
closeDropdown = function()
|
|
265
|
+
self:setState({
|
|
266
|
+
open = false,
|
|
267
|
+
})
|
|
268
|
+
end,
|
|
269
|
+
toggleOpen = function()
|
|
270
|
+
self:setState(function(state)
|
|
271
|
+
return {
|
|
272
|
+
open = not state.open,
|
|
273
|
+
}
|
|
274
|
+
end)
|
|
275
|
+
end,
|
|
276
|
+
}
|
|
277
|
+
local _attributes = table.clone(self.props)
|
|
278
|
+
setmetatable(_attributes, nil)
|
|
279
|
+
return React.createElement(SelectContext.Provider, {
|
|
280
|
+
value = context,
|
|
281
|
+
}, React.createElement(SelectRenderer, _attributes))
|
|
282
|
+
end
|
|
283
|
+
Select.Option = SelectOption
|
|
284
|
+
Select = ReactComponent(Select) or Select
|
|
285
|
+
end
|
|
286
|
+
return {
|
|
287
|
+
Select = Select,
|
|
288
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { Component } from "@rbxts/react";
|
|
2
|
+
import { ContainerProps } from "../Layout";
|
|
3
|
+
import { CleanThemeContext } from "../../Contexts";
|
|
4
|
+
type SliderValue = number | Vector2;
|
|
5
|
+
type SliderHandleIndex = 0 | 1;
|
|
6
|
+
type HighlightOption = "start" | "end" | "middle";
|
|
7
|
+
interface SliderProps extends ContainerProps {
|
|
8
|
+
"max-value": number;
|
|
9
|
+
"min-value"?: number;
|
|
10
|
+
value?: SliderValue;
|
|
11
|
+
step?: number;
|
|
12
|
+
onDragged?: (value: SliderValue) => void;
|
|
13
|
+
onChanged?: (value: SliderValue) => void;
|
|
14
|
+
controlled?: boolean;
|
|
15
|
+
range?: boolean;
|
|
16
|
+
highlight?: HighlightOption;
|
|
17
|
+
}
|
|
18
|
+
interface SliderState {
|
|
19
|
+
value: SliderValue;
|
|
20
|
+
dragging: boolean;
|
|
21
|
+
hoveredHandle?: SliderHandleIndex;
|
|
22
|
+
}
|
|
23
|
+
export declare class Slider extends Component<SliderProps, SliderState> {
|
|
24
|
+
private inputChangedListener?;
|
|
25
|
+
private inputEndedListener?;
|
|
26
|
+
private isDragging;
|
|
27
|
+
private activeHandle?;
|
|
28
|
+
containerRef: React.RefObject<Frame>;
|
|
29
|
+
static contextType: React.Context<import("../..").CleanTheme>;
|
|
30
|
+
context: React.ContextType<typeof CleanThemeContext>;
|
|
31
|
+
state: SliderState;
|
|
32
|
+
private getInitialValue;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the value currently used to render the slider.
|
|
35
|
+
*/
|
|
36
|
+
private getCurrentValue;
|
|
37
|
+
/**
|
|
38
|
+
* Converts an input position into a single slider value.
|
|
39
|
+
*/
|
|
40
|
+
private getNumberFromInput;
|
|
41
|
+
/**
|
|
42
|
+
* Converts a single input value into either a number or Vector2,
|
|
43
|
+
* depending on whether range mode is enabled.
|
|
44
|
+
*/
|
|
45
|
+
private getValueFromInput;
|
|
46
|
+
private beginDragging;
|
|
47
|
+
componentDidMount(): void;
|
|
48
|
+
componentWillUnmount(): void;
|
|
49
|
+
render(): React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
export {};
|