@rbxts/react-clean-ui 1.1.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/Components/Chart/BarChart.d.ts +1 -0
- package/out/Components/Chart/BarChart.luau +149 -112
- package/out/Components/Chart/Pie.d.ts +1 -0
- package/out/Components/Chart/Pie.luau +21 -5
- package/out/Components/Decorator/BoxShadow.d.ts +1 -0
- package/out/Components/Decorator/BoxShadow.luau +12 -5
- package/out/Components/Decorator/Corners.d.ts +1 -0
- package/out/Components/Decorator/Corners.luau +8 -3
- package/out/Components/Decorator/Padding.d.ts +3 -1
- package/out/Components/Decorator/Padding.luau +11 -6
- package/out/Components/Input/Button.d.ts +1 -0
- package/out/Components/Input/Button.luau +44 -33
- package/out/Components/Input/Checkbox.d.ts +1 -0
- package/out/Components/Input/Checkbox.luau +22 -16
- package/out/Components/Input/HoverButton.d.ts +1 -0
- package/out/Components/Input/HoverButton.luau +44 -40
- package/out/Components/Input/Increment.d.ts +1 -0
- package/out/Components/Input/Increment.luau +10 -3
- package/out/Components/Input/Input.d.ts +3 -1
- package/out/Components/Input/Input.luau +85 -66
- package/out/Components/Input/Select.d.ts +9 -0
- package/out/Components/Input/Select.luau +311 -34
- package/out/Components/Input/Slider.luau +44 -29
- package/out/Components/Input/Switch.d.ts +9 -0
- package/out/Components/Input/Switch.luau +147 -0
- package/out/Components/Input/index.d.ts +1 -0
- package/out/Components/Input/init.luau +3 -0
- package/out/Components/Interaction/Modal.d.ts +14 -0
- package/out/Components/Interaction/Modal.luau +276 -0
- package/out/Components/Interaction/Toast.d.ts +2 -1
- package/out/Components/Interaction/Toast.luau +53 -28
- package/out/Components/Interaction/Tooltip.luau +36 -24
- package/out/Components/Interaction/index.d.ts +1 -0
- package/out/Components/Interaction/init.luau +3 -0
- package/out/Components/Layout/Accordion.d.ts +1 -0
- package/out/Components/Layout/Accordion.luau +51 -55
- package/out/Components/Layout/Column.d.ts +1 -0
- package/out/Components/Layout/Column.luau +11 -6
- package/out/Components/Layout/Container.d.ts +1 -0
- package/out/Components/Layout/Container.luau +22 -16
- package/out/Components/Layout/Draggable.luau +25 -3
- package/out/Components/Layout/Fieldset.d.ts +1 -0
- package/out/Components/Layout/Fieldset.luau +14 -42
- package/out/Components/Layout/FlexItem.luau +7 -0
- package/out/Components/Layout/Group.d.ts +1 -0
- package/out/Components/Layout/Group.luau +16 -33
- package/out/Components/Layout/HStack.d.ts +4 -0
- package/out/Components/Layout/HStack.luau +17 -10
- package/out/Components/Layout/Pagination.d.ts +32 -0
- package/out/Components/Layout/Pagination.luau +405 -0
- package/out/Components/Layout/Row.d.ts +1 -0
- package/out/Components/Layout/Row.luau +20 -48
- package/out/Components/Layout/Scroller.d.ts +1 -0
- package/out/Components/Layout/Scroller.luau +26 -34
- package/out/Components/Layout/Table.d.ts +31 -0
- package/out/Components/Layout/Table.luau +342 -0
- package/out/Components/Layout/Tabs.d.ts +18 -9
- package/out/Components/Layout/Tabs.luau +134 -119
- package/out/Components/Layout/VStack.d.ts +3 -0
- package/out/Components/Layout/VStack.luau +17 -10
- package/out/Components/Layout/index.d.ts +2 -0
- package/out/Components/Layout/init.luau +6 -0
- package/out/Components/Navigation/Menu.d.ts +1 -0
- package/out/Components/Navigation/Menu.luau +12 -3
- package/out/Components/Surface/Box.d.ts +1 -0
- package/out/Components/Surface/Box.luau +12 -4
- package/out/Components/Surface/Card.d.ts +1 -0
- package/out/Components/Surface/Card.luau +54 -51
- package/out/Components/Surface/Icon.d.ts +1 -0
- package/out/Components/Surface/Icon.luau +25 -16
- package/out/Components/Typography/Text.d.ts +1 -0
- package/out/Components/Typography/Text.luau +57 -47
- package/out/Contexts/index.d.ts +1 -0
- package/out/Contexts/init.luau +3 -0
- package/out/Contexts/modal.context.d.ts +15 -0
- package/out/Contexts/modal.context.luau +26 -0
- package/out/Contexts/toast.context.d.ts +1 -0
- package/out/Providers/app.provider.luau +2 -1
- package/out/Providers/index.d.ts +1 -0
- package/out/Providers/init.luau +3 -0
- package/out/Providers/modal.provider.d.ts +6 -0
- package/out/Providers/modal.provider.luau +86 -0
- package/out/Providers/overlay.provider.luau +1 -0
- package/out/Theme/theme.template.d.ts +85 -0
- package/out/Theme/themes/dark.theme.luau +103 -0
- package/out/Theme/themes/default.theme.luau +130 -0
- package/out/Theme/themes/sandstone.theme.luau +103 -0
- package/out/Theme/themes/wooden.theme.luau +122 -0
- package/package.json +1 -1
|
@@ -6,6 +6,9 @@ export interface SelectProps extends ScalableElementProps, SpacedElementProps, R
|
|
|
6
6
|
'max-height'?: CssSize;
|
|
7
7
|
backgroundImage?: CssBackgroundImage;
|
|
8
8
|
onChange?: (selected: number, value?: string) => void;
|
|
9
|
+
name?: string;
|
|
10
|
+
searchable?: boolean;
|
|
11
|
+
searchPlaceholder?: string;
|
|
9
12
|
}
|
|
10
13
|
interface SelectOptionProps {
|
|
11
14
|
text?: string;
|
|
@@ -16,8 +19,14 @@ interface SelectOptionProps {
|
|
|
16
19
|
BackgroundColor3?: Color3;
|
|
17
20
|
}
|
|
18
21
|
declare function SelectOption(props: SelectOptionProps): React.JSX.Element;
|
|
22
|
+
interface SelectOptGroupProps {
|
|
23
|
+
label: string;
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
declare function SelectOptGroup(_props: SelectOptGroupProps): undefined;
|
|
19
27
|
type SelectComponent = React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<ImageLabel>> & {
|
|
20
28
|
Option: typeof SelectOption;
|
|
29
|
+
OptGroup: typeof SelectOptGroup;
|
|
21
30
|
};
|
|
22
31
|
declare const Select: SelectComponent;
|
|
23
32
|
export { Select };
|
|
@@ -8,6 +8,7 @@ local OverlayContext = _Contexts.OverlayContext
|
|
|
8
8
|
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
9
9
|
local ColorHelper = _Helpers.ColorHelper
|
|
10
10
|
local SizeHelper = _Helpers.SizeHelper
|
|
11
|
+
local SpacingHelper = _Helpers.SpacingHelper
|
|
11
12
|
local TypographyHelper = _Helpers.TypographyHelper
|
|
12
13
|
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
13
14
|
local Corners = _Decorator.Corners
|
|
@@ -21,6 +22,7 @@ local Scroller = _Layout.Scroller
|
|
|
21
22
|
local VStack = _Layout.VStack
|
|
22
23
|
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
23
24
|
local Icon = TS.import(script, script.Parent.Parent, "Surface").Icon
|
|
25
|
+
local Input = TS.import(script, script.Parent, "Input").Input
|
|
24
26
|
local SelectContext = React.createContext(nil)
|
|
25
27
|
local function SelectOption(props)
|
|
26
28
|
local theme = React.useContext(CleanThemeContext)
|
|
@@ -29,8 +31,10 @@ local function SelectOption(props)
|
|
|
29
31
|
local _arg0 = context ~= nil
|
|
30
32
|
assert(_arg0, "Select.Option must be used inside a Select")
|
|
31
33
|
local _arg0_1 = props.index ~= nil
|
|
32
|
-
assert(_arg0_1, "Select.Option must be a direct child of Select")
|
|
33
|
-
local _attributes = {
|
|
34
|
+
assert(_arg0_1, "Select.Option must be a direct child of Select or Select.OptGroup")
|
|
35
|
+
local _attributes = {
|
|
36
|
+
key = "Option",
|
|
37
|
+
}
|
|
34
38
|
local _object = {}
|
|
35
39
|
local _spread = props.Event
|
|
36
40
|
if _spread then
|
|
@@ -71,10 +75,163 @@ local function SelectOption(props)
|
|
|
71
75
|
local _attributes_1 = table.clone(props)
|
|
72
76
|
setmetatable(_attributes_1, nil)
|
|
73
77
|
return React.createElement("imagebutton", _attributes, React.createElement(Padding, _attributes_1), props.text ~= nil and props.children == nil and React.createElement(Text, {
|
|
78
|
+
name = "OptionText",
|
|
74
79
|
text = props.text,
|
|
75
80
|
TextColor3 = ColorHelper:getIntentColors(theme, "primary", if context.selected == props.index then "focus" elseif hover then "hover" else "default", theme.components.select.intents).textColor,
|
|
76
81
|
}), props.children)
|
|
77
82
|
end
|
|
83
|
+
local function SelectOptGroup(_props)
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
local function parseSelectChildren(children)
|
|
87
|
+
local sections = {}
|
|
88
|
+
local flatOptions = {}
|
|
89
|
+
local index = 0
|
|
90
|
+
local nodeCount = 0
|
|
91
|
+
local groupCount = 0
|
|
92
|
+
-- Fragment-wrapped children (`<>...</>`) are unwrapped/recursed into so
|
|
93
|
+
-- consumers can conditionally compose Option/OptGroup lists (a common
|
|
94
|
+
-- React pattern) without breaking option indexing.
|
|
95
|
+
local collectGroupOptions
|
|
96
|
+
collectGroupOptions = function(node, options)
|
|
97
|
+
React.Children.forEach(node, function(groupChild)
|
|
98
|
+
if React.isValidElement(groupChild) and groupChild.type == React.Fragment then
|
|
99
|
+
collectGroupOptions((groupChild.props).children, options)
|
|
100
|
+
return nil
|
|
101
|
+
end
|
|
102
|
+
if not React.isValidElement(groupChild) or groupChild.type ~= SelectOption then
|
|
103
|
+
return nil
|
|
104
|
+
end
|
|
105
|
+
local _object = {}
|
|
106
|
+
local _left = "index"
|
|
107
|
+
local _original = index
|
|
108
|
+
index += 1
|
|
109
|
+
_object[_left] = _original
|
|
110
|
+
_object.element = groupChild
|
|
111
|
+
_object.text = groupChild.props.text
|
|
112
|
+
local option = _object
|
|
113
|
+
table.insert(options, option)
|
|
114
|
+
table.insert(flatOptions, option)
|
|
115
|
+
end)
|
|
116
|
+
end
|
|
117
|
+
local visit
|
|
118
|
+
visit = function(child)
|
|
119
|
+
if React.isValidElement(child) and child.type == React.Fragment then
|
|
120
|
+
React.Children.forEach((child.props).children, visit)
|
|
121
|
+
return nil
|
|
122
|
+
end
|
|
123
|
+
if React.isValidElement(child) and child.type == SelectOption then
|
|
124
|
+
local _object = {}
|
|
125
|
+
local _left = "index"
|
|
126
|
+
local _original = index
|
|
127
|
+
index += 1
|
|
128
|
+
_object[_left] = _original
|
|
129
|
+
_object.element = child
|
|
130
|
+
_object.text = child.props.text
|
|
131
|
+
local option = _object
|
|
132
|
+
local _arg0 = {
|
|
133
|
+
kind = "option",
|
|
134
|
+
option = option,
|
|
135
|
+
}
|
|
136
|
+
table.insert(sections, _arg0)
|
|
137
|
+
table.insert(flatOptions, option)
|
|
138
|
+
return nil
|
|
139
|
+
end
|
|
140
|
+
if React.isValidElement(child) and child.type == SelectOptGroup then
|
|
141
|
+
local options = {}
|
|
142
|
+
collectGroupOptions(child.props.children, options)
|
|
143
|
+
local _object = {
|
|
144
|
+
kind = "group",
|
|
145
|
+
}
|
|
146
|
+
local _left = "group"
|
|
147
|
+
local _object_1 = {}
|
|
148
|
+
local _left_1 = "key"
|
|
149
|
+
local _original = groupCount
|
|
150
|
+
groupCount += 1
|
|
151
|
+
_object_1[_left_1] = `group-{_original}`
|
|
152
|
+
_object_1.label = child.props.label
|
|
153
|
+
_object_1.options = options
|
|
154
|
+
_object[_left] = _object_1
|
|
155
|
+
table.insert(sections, _object)
|
|
156
|
+
return nil
|
|
157
|
+
end
|
|
158
|
+
local _object = {
|
|
159
|
+
kind = "node",
|
|
160
|
+
}
|
|
161
|
+
local _left = "key"
|
|
162
|
+
local _original = nodeCount
|
|
163
|
+
nodeCount += 1
|
|
164
|
+
_object[_left] = `node-{_original}`
|
|
165
|
+
_object.node = child
|
|
166
|
+
table.insert(sections, _object)
|
|
167
|
+
end
|
|
168
|
+
React.Children.forEach(children, visit)
|
|
169
|
+
return {
|
|
170
|
+
sections = sections,
|
|
171
|
+
flatOptions = flatOptions,
|
|
172
|
+
}
|
|
173
|
+
end
|
|
174
|
+
local function optionMatchesQuery(option, normalizedQuery)
|
|
175
|
+
if normalizedQuery == "" then
|
|
176
|
+
return true
|
|
177
|
+
end
|
|
178
|
+
if option.text == nil then
|
|
179
|
+
return true
|
|
180
|
+
end
|
|
181
|
+
-- Plain-text/literal find (the trailing `true`) avoids treating Lua
|
|
182
|
+
-- pattern characters in the query (e.g. `%`, `-`) as patterns.
|
|
183
|
+
local _exp = string.lower(option.text)
|
|
184
|
+
local _normalizedQuery = normalizedQuery
|
|
185
|
+
return (string.find(_exp, _normalizedQuery, 1, true)) ~= nil
|
|
186
|
+
end
|
|
187
|
+
local function SelectSearchInput(props)
|
|
188
|
+
local theme = React.useContext(CleanThemeContext)
|
|
189
|
+
local _exp = React.createElement(Padding, {
|
|
190
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.select.search.spacing, theme.components.select.search.padding),
|
|
191
|
+
})
|
|
192
|
+
local _attributes = {
|
|
193
|
+
icon = "search",
|
|
194
|
+
controlled = true,
|
|
195
|
+
value = props.value,
|
|
196
|
+
onChange = props.onChange,
|
|
197
|
+
}
|
|
198
|
+
local _condition = props.placeholder
|
|
199
|
+
if _condition == nil then
|
|
200
|
+
_condition = "Search"
|
|
201
|
+
end
|
|
202
|
+
_attributes.placeholder = _condition
|
|
203
|
+
_attributes.scale = props.scale
|
|
204
|
+
return React.createElement("frame", {
|
|
205
|
+
key = "SearchInput",
|
|
206
|
+
Size = UDim2.fromScale(1, 0),
|
|
207
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
208
|
+
BackgroundTransparency = 1,
|
|
209
|
+
}, _exp, React.createElement(Input, _attributes))
|
|
210
|
+
end
|
|
211
|
+
local function SelectGroupHeader(props)
|
|
212
|
+
local theme = React.useContext(CleanThemeContext)
|
|
213
|
+
local typography = TypographyHelper:getTypography(theme, props.scale, theme.components.select.optGroup.typography)
|
|
214
|
+
local _attributes = {
|
|
215
|
+
key = "OptGroupHeader",
|
|
216
|
+
Size = UDim2.fromScale(1, 0),
|
|
217
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
218
|
+
BackgroundColor3 = theme.components.select.optGroup.backgroundColor,
|
|
219
|
+
}
|
|
220
|
+
local _condition = theme.components.select.optGroup.backgroundTransparency
|
|
221
|
+
if _condition == nil then
|
|
222
|
+
_condition = 1
|
|
223
|
+
end
|
|
224
|
+
_attributes.BackgroundTransparency = _condition
|
|
225
|
+
_attributes.BorderSizePixel = 0
|
|
226
|
+
return React.createElement("frame", _attributes, React.createElement(Padding, {
|
|
227
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.select.optGroup.spacing, theme.components.select.optGroup.padding),
|
|
228
|
+
}), React.createElement(Text, {
|
|
229
|
+
name = "OptGroupLabel",
|
|
230
|
+
text = props.label,
|
|
231
|
+
TextColor3 = theme.components.select.optGroup.textColor,
|
|
232
|
+
typography = typography,
|
|
233
|
+
}))
|
|
234
|
+
end
|
|
78
235
|
local Select = React.forwardRef(function(props, ref)
|
|
79
236
|
local theme = React.useContext(CleanThemeContext)
|
|
80
237
|
local overlay = React.useContext(OverlayContext)
|
|
@@ -88,6 +245,7 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
88
245
|
local dropdownSize, setDropdownSize = React.useState(UDim2.fromOffset(0, 0))
|
|
89
246
|
local dropdownPosition, setDropdownPosition = React.useState(UDim2.fromOffset(0, 0))
|
|
90
247
|
local contentHeight, setContentHeight = React.useState(0)
|
|
248
|
+
local query, setQuery = React.useState("")
|
|
91
249
|
local buttonRef = React.useRef()
|
|
92
250
|
local context = React.useMemo(function()
|
|
93
251
|
return {
|
|
@@ -119,8 +277,113 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
119
277
|
}
|
|
120
278
|
end, { props.onChange, selected, open, dropdownSize, dropdownPosition })
|
|
121
279
|
local typography = TypographyHelper:getTypography(theme, props.scale, theme.components.select.typography)
|
|
122
|
-
local
|
|
123
|
-
|
|
280
|
+
local _binding = React.useMemo(function()
|
|
281
|
+
return parseSelectChildren(props.children)
|
|
282
|
+
end, { props.children })
|
|
283
|
+
local sections = _binding.sections
|
|
284
|
+
local flatOptions = _binding.flatOptions
|
|
285
|
+
local _result = flatOptions[selected + 1]
|
|
286
|
+
if _result ~= nil then
|
|
287
|
+
_result = _result.element
|
|
288
|
+
end
|
|
289
|
+
local _condition_1 = _result
|
|
290
|
+
if _condition_1 == nil then
|
|
291
|
+
local _result_1 = flatOptions[1]
|
|
292
|
+
if _result_1 ~= nil then
|
|
293
|
+
_result_1 = _result_1.element
|
|
294
|
+
end
|
|
295
|
+
_condition_1 = _result_1
|
|
296
|
+
end
|
|
297
|
+
local selectedOption = _condition_1
|
|
298
|
+
React.useEffect(function()
|
|
299
|
+
if not open then
|
|
300
|
+
setQuery("")
|
|
301
|
+
end
|
|
302
|
+
end, { open })
|
|
303
|
+
local normalizedQuery = if props.searchable then string.lower(query) else ""
|
|
304
|
+
local renderOption = function(option)
|
|
305
|
+
return React.cloneElement(option.element, {
|
|
306
|
+
index = option.index,
|
|
307
|
+
key = `option-{option.index}`,
|
|
308
|
+
})
|
|
309
|
+
end
|
|
310
|
+
local renderSections = function()
|
|
311
|
+
-- ▼ ReadonlyArray.map ▼
|
|
312
|
+
local _newValue = table.create(#sections)
|
|
313
|
+
local _callback = function(section)
|
|
314
|
+
if section.kind == "node" then
|
|
315
|
+
return section.node
|
|
316
|
+
end
|
|
317
|
+
if section.kind == "option" then
|
|
318
|
+
if props.searchable and not optionMatchesQuery(section.option, normalizedQuery) then
|
|
319
|
+
return nil
|
|
320
|
+
end
|
|
321
|
+
return renderOption(section.option)
|
|
322
|
+
end
|
|
323
|
+
if #section.group.options == 0 then
|
|
324
|
+
return nil
|
|
325
|
+
end
|
|
326
|
+
local _result_1
|
|
327
|
+
if props.searchable then
|
|
328
|
+
local _exp = section.group.options
|
|
329
|
+
-- ▼ ReadonlyArray.filter ▼
|
|
330
|
+
local _newValue_1 = {}
|
|
331
|
+
local _callback_1 = function(option)
|
|
332
|
+
return optionMatchesQuery(option, normalizedQuery)
|
|
333
|
+
end
|
|
334
|
+
local _length = 0
|
|
335
|
+
for _k, _v in _exp do
|
|
336
|
+
if _callback_1(_v, _k - 1, _exp) == true then
|
|
337
|
+
_length += 1
|
|
338
|
+
_newValue_1[_length] = _v
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
-- ▲ ReadonlyArray.filter ▲
|
|
342
|
+
_result_1 = _newValue_1
|
|
343
|
+
else
|
|
344
|
+
_result_1 = section.group.options
|
|
345
|
+
end
|
|
346
|
+
local visibleOptions = _result_1
|
|
347
|
+
if props.searchable and query ~= "" and #visibleOptions == 0 then
|
|
348
|
+
return nil
|
|
349
|
+
end
|
|
350
|
+
local _exp = React.createElement(SelectGroupHeader, {
|
|
351
|
+
label = section.group.label,
|
|
352
|
+
scale = props.scale,
|
|
353
|
+
})
|
|
354
|
+
-- ▼ ReadonlyArray.map ▼
|
|
355
|
+
local _newValue_1 = table.create(#visibleOptions)
|
|
356
|
+
for _k, _v in visibleOptions do
|
|
357
|
+
_newValue_1[_k] = renderOption(_v, _k - 1, visibleOptions)
|
|
358
|
+
end
|
|
359
|
+
-- ▲ ReadonlyArray.map ▲
|
|
360
|
+
return React.createElement(React.Fragment, {
|
|
361
|
+
key = section.group.key,
|
|
362
|
+
}, _exp, _newValue_1)
|
|
363
|
+
end
|
|
364
|
+
for _k, _v in sections do
|
|
365
|
+
_newValue[_k] = _callback(_v, _k - 1, sections)
|
|
366
|
+
end
|
|
367
|
+
-- ▲ ReadonlyArray.map ▲
|
|
368
|
+
return _newValue
|
|
369
|
+
end
|
|
370
|
+
local _condition_2 = not props.searchable or query == ""
|
|
371
|
+
if not _condition_2 then
|
|
372
|
+
-- ▼ ReadonlyArray.some ▼
|
|
373
|
+
local _result_1 = false
|
|
374
|
+
local _callback = function(option)
|
|
375
|
+
return optionMatchesQuery(option, normalizedQuery)
|
|
376
|
+
end
|
|
377
|
+
for _k, _v in flatOptions do
|
|
378
|
+
if _callback(_v, _k - 1, flatOptions) then
|
|
379
|
+
_result_1 = true
|
|
380
|
+
break
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
-- ▲ ReadonlyArray.some ▲
|
|
384
|
+
_condition_2 = _result_1
|
|
385
|
+
end
|
|
386
|
+
local hasVisibleOptions = _condition_2
|
|
124
387
|
local dropdownHeight = math.min(contentHeight, if props["max-height"] ~= nil then SizeHelper:toUDim(props["max-height"]).Offset else theme.components.select.maxDropDownHeight)
|
|
125
388
|
local activateSelect = React.useCallback(function()
|
|
126
389
|
local button = buttonRef.current
|
|
@@ -153,17 +416,21 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
153
416
|
return connection:Disconnect()
|
|
154
417
|
end
|
|
155
418
|
end
|
|
156
|
-
local
|
|
157
|
-
if
|
|
158
|
-
|
|
419
|
+
local _result_1 = fieldset
|
|
420
|
+
if _result_1 ~= nil then
|
|
421
|
+
_result_1 = _result_1.labelActivated
|
|
159
422
|
end
|
|
160
|
-
React.useEffect(_exp, {
|
|
423
|
+
React.useEffect(_exp, { _result_1, activateSelect })
|
|
161
424
|
if open and overlay.overlay == nil then
|
|
162
425
|
warn("You have used a Select component without using the Overlay Provider")
|
|
163
426
|
end
|
|
164
|
-
local _attributes = {
|
|
165
|
-
|
|
166
|
-
|
|
427
|
+
local _attributes = {}
|
|
428
|
+
local _condition_3 = props.name
|
|
429
|
+
if _condition_3 == nil then
|
|
430
|
+
_condition_3 = "Select"
|
|
431
|
+
end
|
|
432
|
+
_attributes.name = _condition_3
|
|
433
|
+
_attributes.ref = ref
|
|
167
434
|
for _k, _v in props do
|
|
168
435
|
_attributes[_k] = _v
|
|
169
436
|
end
|
|
@@ -171,6 +438,7 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
171
438
|
_attributes.AutomaticSize = Enum.AutomaticSize.Y
|
|
172
439
|
_attributes.backgroundImage = props.backgroundImage or theme.components.select.backgroundImage
|
|
173
440
|
local _exp_1 = React.createElement("uistroke", {
|
|
441
|
+
key = "Stroke",
|
|
174
442
|
Thickness = theme.components.select.borderThickness,
|
|
175
443
|
BorderStrokePosition = Enum.BorderStrokePosition.Inner,
|
|
176
444
|
Color = theme.components.select.borderColor,
|
|
@@ -181,24 +449,28 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
181
449
|
local _attributes_1 = table.clone(props)
|
|
182
450
|
setmetatable(_attributes_1, nil)
|
|
183
451
|
local _exp_3 = React.createElement(Padding, _attributes_1)
|
|
184
|
-
local _attributes_2 = {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
452
|
+
local _attributes_2 = {
|
|
453
|
+
name = "SelectedText",
|
|
454
|
+
}
|
|
455
|
+
local _result_2 = selectedOption
|
|
456
|
+
if _result_2 ~= nil then
|
|
457
|
+
_result_2 = _result_2.props.text
|
|
188
458
|
end
|
|
189
|
-
local
|
|
190
|
-
if
|
|
191
|
-
|
|
459
|
+
local _condition_4 = _result_2
|
|
460
|
+
if _condition_4 == nil then
|
|
461
|
+
_condition_4 = "No Options"
|
|
192
462
|
end
|
|
193
|
-
_attributes_2.text =
|
|
463
|
+
_attributes_2.text = _condition_4
|
|
194
464
|
_attributes_2.typography = typography
|
|
195
465
|
local _exp_4 = React.createElement(HStack, nil, React.createElement(FlexItem, nil, React.createElement(Text, _attributes_2)), React.createElement(Icon, {
|
|
466
|
+
name = "SelectCaret",
|
|
196
467
|
icon = "caret-down",
|
|
197
468
|
color = theme.colors.intents.primary.default.textColor,
|
|
198
469
|
}))
|
|
199
|
-
local
|
|
200
|
-
if
|
|
470
|
+
local _condition_5 = open and overlay.overlay ~= nil
|
|
471
|
+
if _condition_5 then
|
|
201
472
|
local _attributes_3 = {
|
|
473
|
+
key = "SelectDropdown",
|
|
202
474
|
BackgroundTransparency = 0,
|
|
203
475
|
BackgroundColor3 = theme.components.select.dropDownBackgroundColor,
|
|
204
476
|
AnchorPoint = Vector2.zero,
|
|
@@ -208,13 +480,21 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
208
480
|
_attributes_3.Size = UDim2.fromOffset(dropdownSize.X.Offset, 0)
|
|
209
481
|
_attributes_3.AutomaticSize = Enum.AutomaticSize.Y
|
|
210
482
|
_attributes_3.ClipsDescendants = true
|
|
211
|
-
|
|
483
|
+
_condition_5 = ReactRoblox.createPortal(React.createElement("frame", _attributes_3, React.createElement("uistroke", {
|
|
484
|
+
key = "Stroke",
|
|
212
485
|
Thickness = theme.components.select.borderThickness,
|
|
213
486
|
BorderStrokePosition = Enum.BorderStrokePosition.Outer,
|
|
214
487
|
Color = theme.components.select.borderColor,
|
|
215
488
|
}), React.createElement(Corners, {
|
|
216
489
|
radius = theme.components.select.cornerRadius,
|
|
217
|
-
}), React.createElement(
|
|
490
|
+
}), React.createElement(VStack, {
|
|
491
|
+
spacing = "None",
|
|
492
|
+
}, props.searchable and (React.createElement(SelectSearchInput, {
|
|
493
|
+
value = query,
|
|
494
|
+
onChange = setQuery,
|
|
495
|
+
placeholder = props.searchPlaceholder,
|
|
496
|
+
scale = props.scale,
|
|
497
|
+
})), React.createElement(Scroller, {
|
|
218
498
|
Size = UDim2.new(1, 0, 0, dropdownHeight),
|
|
219
499
|
spacing = "None",
|
|
220
500
|
}, React.createElement(VStack, {
|
|
@@ -224,20 +504,16 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
224
504
|
setContentHeight(layout.AbsoluteContentSize.Y)
|
|
225
505
|
end,
|
|
226
506
|
},
|
|
227
|
-
}, React.
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
local optionIndex = childIndex - 1
|
|
233
|
-
return React.cloneElement(child, {
|
|
234
|
-
index = optionIndex,
|
|
235
|
-
})
|
|
236
|
-
end)))), overlay.overlay)
|
|
507
|
+
}, if hasVisibleOptions then renderSections() else React.createElement(Text, {
|
|
508
|
+
name = "NoResultsText",
|
|
509
|
+
text = "No Results",
|
|
510
|
+
typography = typography,
|
|
511
|
+
}))))), overlay.overlay)
|
|
237
512
|
end
|
|
238
513
|
return React.createElement(Container, _attributes, React.createElement(SelectContext.Provider, {
|
|
239
514
|
value = context,
|
|
240
515
|
}, React.createElement("imagebutton", {
|
|
516
|
+
key = "SelectButton",
|
|
241
517
|
ref = buttonRef,
|
|
242
518
|
Size = UDim2.fromScale(1, 0),
|
|
243
519
|
AutomaticSize = Enum.AutomaticSize.Y,
|
|
@@ -245,9 +521,10 @@ local Select = React.forwardRef(function(props, ref)
|
|
|
245
521
|
Event = {
|
|
246
522
|
Activated = activateSelect,
|
|
247
523
|
},
|
|
248
|
-
}, _exp_1, _exp_2, _exp_3, _exp_4,
|
|
524
|
+
}, _exp_1, _exp_2, _exp_3, _exp_4, _condition_5)))
|
|
249
525
|
end)
|
|
250
526
|
Select.Option = SelectOption
|
|
527
|
+
Select.OptGroup = SelectOptGroup
|
|
251
528
|
return {
|
|
252
529
|
Select = Select,
|
|
253
530
|
}
|
|
@@ -248,19 +248,23 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
248
248
|
}
|
|
249
249
|
table.insert(handles, _arg0)
|
|
250
250
|
end
|
|
251
|
-
local _attributes = {
|
|
252
|
-
|
|
253
|
-
Archivable = props.Archivable,
|
|
254
|
-
Tag = props.Tag,
|
|
255
|
-
Active = props.Active,
|
|
256
|
-
AnchorPoint = SizeHelper:GetAnchor(props),
|
|
257
|
-
BackgroundColor3 = props.BackgroundColor3,
|
|
258
|
-
}
|
|
259
|
-
local _condition_1 = props.BackgroundTransparency
|
|
251
|
+
local _attributes = {}
|
|
252
|
+
local _condition_1 = props.name
|
|
260
253
|
if _condition_1 == nil then
|
|
261
|
-
_condition_1 =
|
|
254
|
+
_condition_1 = "Slider"
|
|
255
|
+
end
|
|
256
|
+
_attributes.key = _condition_1
|
|
257
|
+
_attributes.ref = ref
|
|
258
|
+
_attributes.Archivable = props.Archivable
|
|
259
|
+
_attributes.Tag = props.Tag
|
|
260
|
+
_attributes.Active = props.Active
|
|
261
|
+
_attributes.AnchorPoint = SizeHelper:GetAnchor(props)
|
|
262
|
+
_attributes.BackgroundColor3 = props.BackgroundColor3
|
|
263
|
+
local _condition_2 = props.BackgroundTransparency
|
|
264
|
+
if _condition_2 == nil then
|
|
265
|
+
_condition_2 = 1
|
|
262
266
|
end
|
|
263
|
-
_attributes.BackgroundTransparency =
|
|
267
|
+
_attributes.BackgroundTransparency = _condition_2
|
|
264
268
|
_attributes.BorderColor3 = props.BorderColor3
|
|
265
269
|
_attributes.BorderMode = props.BorderMode
|
|
266
270
|
_attributes.BorderSizePixel = props.BorderSizePixel
|
|
@@ -287,18 +291,22 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
287
291
|
_attributes.Change = props.Change
|
|
288
292
|
_attributes.Event = props.Event
|
|
289
293
|
local _exp = React.createElement("frame", {
|
|
294
|
+
key = "Bar",
|
|
290
295
|
Size = UDim2.new(UDim.new(1, 0), SizeHelper:toUDim(theme.bar.height)),
|
|
291
296
|
Position = UDim2.fromScale(0.5, 0.5),
|
|
292
297
|
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
293
298
|
BackgroundTransparency = theme.bar.backgroundTransparency,
|
|
294
299
|
BackgroundColor3 = theme.bar.backgroundColor,
|
|
295
300
|
}, React.createElement("uistroke", {
|
|
301
|
+
key = "Stroke",
|
|
296
302
|
Thickness = theme.bar.borderThickness,
|
|
297
303
|
Color = theme.bar.borderColor,
|
|
298
304
|
}), React.createElement("uicorner", {
|
|
305
|
+
key = "Corners",
|
|
299
306
|
CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
|
|
300
307
|
}))
|
|
301
308
|
local _attributes_1 = {
|
|
309
|
+
key = "HandleContainer",
|
|
302
310
|
ref = containerRef,
|
|
303
311
|
}
|
|
304
312
|
local _exp_1 = UDim2.fromScale(1, 1)
|
|
@@ -307,9 +315,10 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
307
315
|
_attributes_1.BackgroundTransparency = 1
|
|
308
316
|
_attributes_1.Position = UDim2.fromScale(0.5, 0.5)
|
|
309
317
|
_attributes_1.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
310
|
-
local
|
|
311
|
-
if
|
|
318
|
+
local _condition_3 = props.highlight ~= nil
|
|
319
|
+
if _condition_3 then
|
|
312
320
|
local _attributes_2 = {
|
|
321
|
+
key = "Highlight",
|
|
313
322
|
BackgroundColor3 = theme.bar.highlight.backgroundColor,
|
|
314
323
|
BackgroundTransparency = theme.bar.highlight.backgroundTransparency,
|
|
315
324
|
}
|
|
@@ -339,27 +348,29 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
339
348
|
else
|
|
340
349
|
local _result_2
|
|
341
350
|
if props.highlight == "end" then
|
|
342
|
-
local
|
|
343
|
-
if
|
|
344
|
-
|
|
351
|
+
local _condition_4 = secondPosition
|
|
352
|
+
if _condition_4 == nil then
|
|
353
|
+
_condition_4 = firstPosition
|
|
345
354
|
end
|
|
346
|
-
local _uDim2_1 = UDim2.new(UDim.new(1 -
|
|
355
|
+
local _uDim2_1 = UDim2.new(UDim.new(1 - _condition_4, 0), SizeHelper:toUDim(theme.bar.height))
|
|
347
356
|
local _uDim2_2 = UDim2.new(padding, UDim.new(0, 0))
|
|
348
357
|
_result_2 = _uDim2_1 + _uDim2_2
|
|
349
358
|
else
|
|
350
|
-
local
|
|
351
|
-
if
|
|
352
|
-
|
|
359
|
+
local _condition_4 = secondPosition
|
|
360
|
+
if _condition_4 == nil then
|
|
361
|
+
_condition_4 = 0
|
|
353
362
|
end
|
|
354
|
-
_result_2 = UDim2.new(UDim.new(
|
|
363
|
+
_result_2 = UDim2.new(UDim.new(_condition_4 - firstPosition, 0), SizeHelper:toUDim(theme.bar.height))
|
|
355
364
|
end
|
|
356
365
|
_result_1 = _result_2
|
|
357
366
|
end
|
|
358
367
|
_attributes_2.Size = _result_1
|
|
359
|
-
|
|
368
|
+
_condition_3 = (React.createElement("frame", _attributes_2, React.createElement("uistroke", {
|
|
369
|
+
key = "Stroke",
|
|
360
370
|
Thickness = theme.bar.borderThickness,
|
|
361
371
|
Color = theme.bar.highlight.borderColor,
|
|
362
372
|
}), React.createElement("uicorner", {
|
|
373
|
+
key = "Corners",
|
|
363
374
|
CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
|
|
364
375
|
})))
|
|
365
376
|
end
|
|
@@ -369,25 +380,29 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
369
380
|
local index = _param.index
|
|
370
381
|
local position = _param.position
|
|
371
382
|
local _exp_2 = React.createElement("uistroke", {
|
|
383
|
+
key = "Stroke",
|
|
372
384
|
Thickness = theme.handle.borderThickness,
|
|
373
385
|
Color = theme.handle.borderColor,
|
|
374
386
|
})
|
|
375
387
|
local _exp_3 = React.createElement("uicorner", {
|
|
388
|
+
key = "Corners",
|
|
376
389
|
CornerRadius = SizeHelper:toUDim(theme.handle.cornerRadius),
|
|
377
390
|
})
|
|
378
391
|
local _exp_4 = (hoveredHandle == index or (dragging and activeHandleRef.current == index)) and (React.createElement(BoxShadow, {
|
|
379
392
|
["box-shadow"] = theme.handle.boxShadow,
|
|
380
393
|
}))
|
|
381
|
-
local _attributes_2 = {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
394
|
+
local _attributes_2 = {
|
|
395
|
+
key = "AspectRatio",
|
|
396
|
+
}
|
|
397
|
+
local _condition_4 = theme.handle.aspectRatio
|
|
398
|
+
if _condition_4 == nil then
|
|
399
|
+
_condition_4 = 1
|
|
385
400
|
end
|
|
386
|
-
_attributes_2.AspectRatio =
|
|
401
|
+
_attributes_2.AspectRatio = _condition_4
|
|
387
402
|
_attributes_2.DominantAxis = Enum.DominantAxis.Height
|
|
388
403
|
_attributes_2.AspectType = Enum.AspectType.ScaleWithParentSize
|
|
389
404
|
return React.createElement("frame", {
|
|
390
|
-
key = index
|
|
405
|
+
key = `Handle-{index}`,
|
|
391
406
|
Position = UDim2.fromScale(position, 0.5),
|
|
392
407
|
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
393
408
|
Size = UDim2.fromScale(0, 1),
|
|
@@ -413,7 +428,7 @@ local Slider = React.forwardRef(function(props, ref)
|
|
|
413
428
|
_newValue[_k] = _callback(_v, _k - 1, handles)
|
|
414
429
|
end
|
|
415
430
|
-- ▲ ReadonlyArray.map ▲
|
|
416
|
-
return React.createElement("frame", _attributes, _exp, React.createElement("frame", _attributes_1,
|
|
431
|
+
return React.createElement("frame", _attributes, _exp, React.createElement("frame", _attributes_1, _condition_3, _newValue))
|
|
417
432
|
end)
|
|
418
433
|
return {
|
|
419
434
|
Slider = Slider,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { BackgroundElementProps, IntentElementProps, ZIndexElementProps } from "../../Interfaces";
|
|
3
|
+
export interface SwitchProps extends IntentElementProps, BackgroundElementProps, ZIndexElementProps {
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
onChange?: (value: boolean) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
name?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function Switch(props: SwitchProps): React.JSX.Element;
|