@rbxts/react-clean-ui 1.1.0 → 1.2.4

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 (110) hide show
  1. package/out/Components/Chart/BarChart.d.ts +1 -0
  2. package/out/Components/Chart/BarChart.luau +149 -112
  3. package/out/Components/Chart/Pie.d.ts +1 -0
  4. package/out/Components/Chart/Pie.luau +21 -6
  5. package/out/Components/Decorator/BoxShadow.d.ts +1 -0
  6. package/out/Components/Decorator/BoxShadow.luau +12 -5
  7. package/out/Components/Decorator/Corners.d.ts +1 -0
  8. package/out/Components/Decorator/Corners.luau +8 -3
  9. package/out/Components/Decorator/Gradient.d.ts +8 -0
  10. package/out/Components/Decorator/Gradient.luau +23 -0
  11. package/out/Components/Decorator/Padding.d.ts +3 -1
  12. package/out/Components/Decorator/Padding.luau +11 -6
  13. package/out/Components/Decorator/index.d.ts +1 -0
  14. package/out/Components/Decorator/init.luau +3 -0
  15. package/out/Components/Input/Button.d.ts +1 -0
  16. package/out/Components/Input/Button.luau +49 -34
  17. package/out/Components/Input/Checkbox.d.ts +1 -0
  18. package/out/Components/Input/Checkbox.luau +28 -18
  19. package/out/Components/Input/HoverButton.d.ts +1 -0
  20. package/out/Components/Input/HoverButton.luau +44 -42
  21. package/out/Components/Input/Increment.d.ts +1 -0
  22. package/out/Components/Input/Increment.luau +10 -3
  23. package/out/Components/Input/Input.d.ts +3 -1
  24. package/out/Components/Input/Input.luau +89 -68
  25. package/out/Components/Input/Select.d.ts +11 -1
  26. package/out/Components/Input/Select.luau +315 -39
  27. package/out/Components/Input/Slider.luau +44 -53
  28. package/out/Components/Input/Switch.d.ts +9 -0
  29. package/out/Components/Input/Switch.luau +145 -0
  30. package/out/Components/Input/index.d.ts +1 -0
  31. package/out/Components/Input/init.luau +3 -0
  32. package/out/Components/Interaction/Modal.d.ts +14 -0
  33. package/out/Components/Interaction/Modal.luau +262 -0
  34. package/out/Components/Interaction/Toast.d.ts +2 -1
  35. package/out/Components/Interaction/Toast.luau +53 -28
  36. package/out/Components/Interaction/Tooltip.luau +36 -25
  37. package/out/Components/Interaction/index.d.ts +1 -0
  38. package/out/Components/Interaction/init.luau +3 -0
  39. package/out/Components/Layout/Accordion.d.ts +1 -0
  40. package/out/Components/Layout/Accordion.luau +51 -55
  41. package/out/Components/Layout/Column.d.ts +1 -0
  42. package/out/Components/Layout/Column.luau +11 -6
  43. package/out/Components/Layout/Container.d.ts +3 -0
  44. package/out/Components/Layout/Container.luau +26 -17
  45. package/out/Components/Layout/Draggable.luau +25 -3
  46. package/out/Components/Layout/Fieldset.d.ts +1 -0
  47. package/out/Components/Layout/Fieldset.luau +14 -42
  48. package/out/Components/Layout/FlexItem.luau +7 -0
  49. package/out/Components/Layout/Grid.d.ts +10 -0
  50. package/out/Components/Layout/Grid.luau +172 -0
  51. package/out/Components/Layout/Group.d.ts +1 -0
  52. package/out/Components/Layout/Group.luau +48 -60
  53. package/out/Components/Layout/HStack.d.ts +4 -0
  54. package/out/Components/Layout/HStack.luau +17 -10
  55. package/out/Components/Layout/Pagination.d.ts +32 -0
  56. package/out/Components/Layout/Pagination.luau +400 -0
  57. package/out/Components/Layout/Row.d.ts +1 -0
  58. package/out/Components/Layout/Row.luau +20 -48
  59. package/out/Components/Layout/Scroller.d.ts +1 -0
  60. package/out/Components/Layout/Scroller.luau +26 -34
  61. package/out/Components/Layout/Table.d.ts +31 -0
  62. package/out/Components/Layout/Table.luau +342 -0
  63. package/out/Components/Layout/Tabs.d.ts +20 -10
  64. package/out/Components/Layout/Tabs.luau +113 -119
  65. package/out/Components/Layout/VStack.d.ts +3 -0
  66. package/out/Components/Layout/VStack.luau +17 -10
  67. package/out/Components/Layout/index.d.ts +3 -0
  68. package/out/Components/Layout/init.luau +9 -0
  69. package/out/Components/Navigation/Menu.d.ts +1 -0
  70. package/out/Components/Navigation/Menu.luau +12 -3
  71. package/out/Components/Surface/Box.d.ts +3 -1
  72. package/out/Components/Surface/Box.luau +15 -4
  73. package/out/Components/Surface/Card.d.ts +1 -0
  74. package/out/Components/Surface/Card.luau +56 -154
  75. package/out/Components/Surface/Icon.d.ts +1 -0
  76. package/out/Components/Surface/Icon.luau +25 -16
  77. package/out/Components/Surface/ProgressBar.d.ts +14 -0
  78. package/out/Components/Surface/ProgressBar.luau +230 -0
  79. package/out/Components/Surface/index.d.ts +1 -0
  80. package/out/Components/Surface/init.luau +3 -0
  81. package/out/Components/Typography/Text.d.ts +1 -0
  82. package/out/Components/Typography/Text.luau +57 -53
  83. package/out/Contexts/index.d.ts +1 -0
  84. package/out/Contexts/init.luau +3 -0
  85. package/out/Contexts/modal.context.d.ts +15 -0
  86. package/out/Contexts/modal.context.luau +23 -0
  87. package/out/Contexts/toast.context.d.ts +1 -0
  88. package/out/Helpers/color.helper.luau +28 -0
  89. package/out/Helpers/css.helper.d.ts +4 -1
  90. package/out/Helpers/css.helper.luau +76 -6
  91. package/out/Helpers/gui.helper.luau +0 -3
  92. package/out/Helpers/size.helper.luau +0 -2
  93. package/out/Helpers/spacing.helper.luau +0 -3
  94. package/out/Helpers/typography.helper.luau +0 -2
  95. package/out/Interfaces/css.types.d.ts +7 -0
  96. package/out/Interfaces/css.types.luau +0 -20
  97. package/out/Providers/app.provider.luau +2 -1
  98. package/out/Providers/index.d.ts +1 -0
  99. package/out/Providers/init.luau +3 -0
  100. package/out/Providers/modal.provider.d.ts +6 -0
  101. package/out/Providers/modal.provider.luau +86 -0
  102. package/out/Providers/overlay.provider.luau +1 -0
  103. package/out/Providers/registry.provider.luau +0 -2
  104. package/out/Theme/theme.style.d.ts +2 -1
  105. package/out/Theme/theme.template.d.ts +126 -1
  106. package/out/Theme/themes/dark.theme.luau +225 -0
  107. package/out/Theme/themes/default.theme.luau +210 -0
  108. package/out/Theme/themes/sandstone.theme.luau +173 -0
  109. package/out/Theme/themes/wooden.theme.luau +195 -0
  110. package/package.json +1 -1
@@ -8,9 +8,11 @@ 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
15
+ local Gradient = _Decorator.Gradient
14
16
  local Padding = _Decorator.Padding
15
17
  local _Layout = TS.import(script, script.Parent.Parent, "Layout")
16
18
  local Container = _Layout.Container
@@ -21,6 +23,7 @@ local Scroller = _Layout.Scroller
21
23
  local VStack = _Layout.VStack
22
24
  local Text = TS.import(script, script.Parent.Parent, "Typography").Text
23
25
  local Icon = TS.import(script, script.Parent.Parent, "Surface").Icon
26
+ local Input = TS.import(script, script.Parent, "Input").Input
24
27
  local SelectContext = React.createContext(nil)
25
28
  local function SelectOption(props)
26
29
  local theme = React.useContext(CleanThemeContext)
@@ -29,8 +32,10 @@ local function SelectOption(props)
29
32
  local _arg0 = context ~= nil
30
33
  assert(_arg0, "Select.Option must be used inside a Select")
31
34
  local _arg0_1 = props.index ~= nil
32
- assert(_arg0_1, "Select.Option must be a direct child of Select")
33
- local _attributes = {}
35
+ assert(_arg0_1, "Select.Option must be a direct child of Select or Select.OptGroup")
36
+ local _attributes = {
37
+ key = "Option",
38
+ }
34
39
  local _object = {}
35
40
  local _spread = props.Event
36
41
  if _spread then
@@ -71,10 +76,158 @@ local function SelectOption(props)
71
76
  local _attributes_1 = table.clone(props)
72
77
  setmetatable(_attributes_1, nil)
73
78
  return React.createElement("imagebutton", _attributes, React.createElement(Padding, _attributes_1), props.text ~= nil and props.children == nil and React.createElement(Text, {
79
+ name = "OptionText",
74
80
  text = props.text,
75
81
  TextColor3 = ColorHelper:getIntentColors(theme, "primary", if context.selected == props.index then "focus" elseif hover then "hover" else "default", theme.components.select.intents).textColor,
76
82
  }), props.children)
77
83
  end
84
+ local function SelectOptGroup(_props)
85
+ return nil
86
+ end
87
+ local function parseSelectChildren(children)
88
+ local sections = {}
89
+ local flatOptions = {}
90
+ local index = 0
91
+ local nodeCount = 0
92
+ local groupCount = 0
93
+ local collectGroupOptions
94
+ collectGroupOptions = function(node, options)
95
+ React.Children.forEach(node, function(groupChild)
96
+ if React.isValidElement(groupChild) and groupChild.type == React.Fragment then
97
+ collectGroupOptions((groupChild.props).children, options)
98
+ return nil
99
+ end
100
+ if not React.isValidElement(groupChild) or groupChild.type ~= SelectOption then
101
+ return nil
102
+ end
103
+ local _object = {}
104
+ local _left = "index"
105
+ local _original = index
106
+ index += 1
107
+ _object[_left] = _original
108
+ _object.element = groupChild
109
+ _object.text = groupChild.props.text
110
+ local option = _object
111
+ table.insert(options, option)
112
+ table.insert(flatOptions, option)
113
+ end)
114
+ end
115
+ local visit
116
+ visit = function(child)
117
+ if React.isValidElement(child) and child.type == React.Fragment then
118
+ React.Children.forEach((child.props).children, visit)
119
+ return nil
120
+ end
121
+ if React.isValidElement(child) and child.type == SelectOption then
122
+ local _object = {}
123
+ local _left = "index"
124
+ local _original = index
125
+ index += 1
126
+ _object[_left] = _original
127
+ _object.element = child
128
+ _object.text = child.props.text
129
+ local option = _object
130
+ local _arg0 = {
131
+ kind = "option",
132
+ option = option,
133
+ }
134
+ table.insert(sections, _arg0)
135
+ table.insert(flatOptions, option)
136
+ return nil
137
+ end
138
+ if React.isValidElement(child) and child.type == SelectOptGroup then
139
+ local options = {}
140
+ collectGroupOptions(child.props.children, options)
141
+ local _object = {
142
+ kind = "group",
143
+ }
144
+ local _left = "group"
145
+ local _object_1 = {}
146
+ local _left_1 = "key"
147
+ local _original = groupCount
148
+ groupCount += 1
149
+ _object_1[_left_1] = `group-{_original}`
150
+ _object_1.label = child.props.label
151
+ _object_1.options = options
152
+ _object[_left] = _object_1
153
+ table.insert(sections, _object)
154
+ return nil
155
+ end
156
+ local _object = {
157
+ kind = "node",
158
+ }
159
+ local _left = "key"
160
+ local _original = nodeCount
161
+ nodeCount += 1
162
+ _object[_left] = `node-{_original}`
163
+ _object.node = child
164
+ table.insert(sections, _object)
165
+ end
166
+ React.Children.forEach(children, visit)
167
+ return {
168
+ sections = sections,
169
+ flatOptions = flatOptions,
170
+ }
171
+ end
172
+ local function optionMatchesQuery(option, normalizedQuery)
173
+ if normalizedQuery == "" then
174
+ return true
175
+ end
176
+ if option.text == nil then
177
+ return true
178
+ end
179
+ local _exp = string.lower(option.text)
180
+ local _normalizedQuery = normalizedQuery
181
+ return (string.find(_exp, _normalizedQuery, 1, true)) ~= nil
182
+ end
183
+ local function SelectSearchInput(props)
184
+ local theme = React.useContext(CleanThemeContext)
185
+ local _exp = React.createElement(Padding, {
186
+ resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.select.search.spacing, theme.components.select.search.padding),
187
+ })
188
+ local _attributes = {
189
+ icon = "search",
190
+ controlled = true,
191
+ value = props.value,
192
+ onChange = props.onChange,
193
+ }
194
+ local _condition = props.placeholder
195
+ if _condition == nil then
196
+ _condition = "Search"
197
+ end
198
+ _attributes.placeholder = _condition
199
+ _attributes.scale = props.scale
200
+ return React.createElement("frame", {
201
+ key = "SearchInput",
202
+ Size = UDim2.fromScale(1, 0),
203
+ AutomaticSize = Enum.AutomaticSize.Y,
204
+ BackgroundTransparency = 1,
205
+ }, _exp, React.createElement(Input, _attributes))
206
+ end
207
+ local function SelectGroupHeader(props)
208
+ local theme = React.useContext(CleanThemeContext)
209
+ local typography = TypographyHelper:getTypography(theme, props.scale, theme.components.select.optGroup.typography)
210
+ local _attributes = {
211
+ key = "OptGroupHeader",
212
+ Size = UDim2.fromScale(1, 0),
213
+ AutomaticSize = Enum.AutomaticSize.Y,
214
+ BackgroundColor3 = theme.components.select.optGroup.backgroundColor,
215
+ }
216
+ local _condition = theme.components.select.optGroup.backgroundTransparency
217
+ if _condition == nil then
218
+ _condition = 1
219
+ end
220
+ _attributes.BackgroundTransparency = _condition
221
+ _attributes.BorderSizePixel = 0
222
+ return React.createElement("frame", _attributes, React.createElement(Padding, {
223
+ resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.select.optGroup.spacing, theme.components.select.optGroup.padding),
224
+ }), React.createElement(Text, {
225
+ name = "OptGroupLabel",
226
+ text = props.label,
227
+ TextColor3 = theme.components.select.optGroup.textColor,
228
+ typography = typography,
229
+ }))
230
+ end
78
231
  local Select = React.forwardRef(function(props, ref)
79
232
  local theme = React.useContext(CleanThemeContext)
80
233
  local overlay = React.useContext(OverlayContext)
@@ -88,6 +241,7 @@ local Select = React.forwardRef(function(props, ref)
88
241
  local dropdownSize, setDropdownSize = React.useState(UDim2.fromOffset(0, 0))
89
242
  local dropdownPosition, setDropdownPosition = React.useState(UDim2.fromOffset(0, 0))
90
243
  local contentHeight, setContentHeight = React.useState(0)
244
+ local query, setQuery = React.useState("")
91
245
  local buttonRef = React.useRef()
92
246
  local context = React.useMemo(function()
93
247
  return {
@@ -119,8 +273,113 @@ local Select = React.forwardRef(function(props, ref)
119
273
  }
120
274
  end, { props.onChange, selected, open, dropdownSize, dropdownPosition })
121
275
  local typography = TypographyHelper:getTypography(theme, props.scale, theme.components.select.typography)
122
- local children = React.Children.toArray(props.children)
123
- local selectedOption = (children[selected + 1] or children[1])
276
+ local _binding = React.useMemo(function()
277
+ return parseSelectChildren(props.children)
278
+ end, { props.children })
279
+ local sections = _binding.sections
280
+ local flatOptions = _binding.flatOptions
281
+ local _result = flatOptions[selected + 1]
282
+ if _result ~= nil then
283
+ _result = _result.element
284
+ end
285
+ local _condition_1 = _result
286
+ if _condition_1 == nil then
287
+ local _result_1 = flatOptions[1]
288
+ if _result_1 ~= nil then
289
+ _result_1 = _result_1.element
290
+ end
291
+ _condition_1 = _result_1
292
+ end
293
+ local selectedOption = _condition_1
294
+ React.useEffect(function()
295
+ if not open then
296
+ setQuery("")
297
+ end
298
+ end, { open })
299
+ local normalizedQuery = if props.searchable then string.lower(query) else ""
300
+ local renderOption = function(option)
301
+ return React.cloneElement(option.element, {
302
+ index = option.index,
303
+ key = `option-{option.index}`,
304
+ })
305
+ end
306
+ local renderSections = function()
307
+ -- ▼ ReadonlyArray.map ▼
308
+ local _newValue = table.create(#sections)
309
+ local _callback = function(section)
310
+ if section.kind == "node" then
311
+ return section.node
312
+ end
313
+ if section.kind == "option" then
314
+ if props.searchable and not optionMatchesQuery(section.option, normalizedQuery) then
315
+ return nil
316
+ end
317
+ return renderOption(section.option)
318
+ end
319
+ if #section.group.options == 0 then
320
+ return nil
321
+ end
322
+ local _result_1
323
+ if props.searchable then
324
+ local _exp = section.group.options
325
+ -- ▼ ReadonlyArray.filter ▼
326
+ local _newValue_1 = {}
327
+ local _callback_1 = function(option)
328
+ return optionMatchesQuery(option, normalizedQuery)
329
+ end
330
+ local _length = 0
331
+ for _k, _v in _exp do
332
+ if _callback_1(_v, _k - 1, _exp) == true then
333
+ _length += 1
334
+ _newValue_1[_length] = _v
335
+ end
336
+ end
337
+ -- ▲ ReadonlyArray.filter ▲
338
+ _result_1 = _newValue_1
339
+ else
340
+ _result_1 = section.group.options
341
+ end
342
+ local visibleOptions = _result_1
343
+ if props.searchable and query ~= "" and #visibleOptions == 0 then
344
+ return nil
345
+ end
346
+ local _exp = React.createElement(SelectGroupHeader, {
347
+ label = section.group.label,
348
+ scale = props.scale,
349
+ })
350
+ -- ▼ ReadonlyArray.map ▼
351
+ local _newValue_1 = table.create(#visibleOptions)
352
+ for _k, _v in visibleOptions do
353
+ _newValue_1[_k] = renderOption(_v, _k - 1, visibleOptions)
354
+ end
355
+ -- ▲ ReadonlyArray.map ▲
356
+ return React.createElement(React.Fragment, {
357
+ key = section.group.key,
358
+ }, _exp, _newValue_1)
359
+ end
360
+ for _k, _v in sections do
361
+ _newValue[_k] = _callback(_v, _k - 1, sections)
362
+ end
363
+ -- ▲ ReadonlyArray.map ▲
364
+ return _newValue
365
+ end
366
+ local _condition_2 = not props.searchable or query == ""
367
+ if not _condition_2 then
368
+ -- ▼ ReadonlyArray.some ▼
369
+ local _result_1 = false
370
+ local _callback = function(option)
371
+ return optionMatchesQuery(option, normalizedQuery)
372
+ end
373
+ for _k, _v in flatOptions do
374
+ if _callback(_v, _k - 1, flatOptions) then
375
+ _result_1 = true
376
+ break
377
+ end
378
+ end
379
+ -- ▲ ReadonlyArray.some ▲
380
+ _condition_2 = _result_1
381
+ end
382
+ local hasVisibleOptions = _condition_2
124
383
  local dropdownHeight = math.min(contentHeight, if props["max-height"] ~= nil then SizeHelper:toUDim(props["max-height"]).Offset else theme.components.select.maxDropDownHeight)
125
384
  local activateSelect = React.useCallback(function()
126
385
  local button = buttonRef.current
@@ -153,52 +412,64 @@ local Select = React.forwardRef(function(props, ref)
153
412
  return connection:Disconnect()
154
413
  end
155
414
  end
156
- local _result = fieldset
157
- if _result ~= nil then
158
- _result = _result.labelActivated
415
+ local _result_1 = fieldset
416
+ if _result_1 ~= nil then
417
+ _result_1 = _result_1.labelActivated
159
418
  end
160
- React.useEffect(_exp, { _result, activateSelect })
419
+ React.useEffect(_exp, { _result_1, activateSelect })
161
420
  if open and overlay.overlay == nil then
162
421
  warn("You have used a Select component without using the Overlay Provider")
163
422
  end
164
- local _attributes = {
165
- ref = ref,
166
- }
423
+ local _attributes = {}
424
+ local _condition_3 = props.name
425
+ if _condition_3 == nil then
426
+ _condition_3 = "Select"
427
+ end
428
+ _attributes.name = _condition_3
429
+ _attributes.ref = ref
167
430
  for _k, _v in props do
168
431
  _attributes[_k] = _v
169
432
  end
170
433
  _attributes.Size = UDim2.fromScale(1, 0)
171
434
  _attributes.AutomaticSize = Enum.AutomaticSize.Y
172
435
  _attributes.backgroundImage = props.backgroundImage or theme.components.select.backgroundImage
173
- local _exp_1 = React.createElement("uistroke", {
436
+ local _exp_1 = React.createElement(Gradient, {
437
+ value = props.backgroundGradient or theme.components.select.backgroundGradient,
438
+ })
439
+ local _exp_2 = React.createElement("uistroke", {
440
+ key = "Stroke",
174
441
  Thickness = theme.components.select.borderThickness,
175
442
  BorderStrokePosition = Enum.BorderStrokePosition.Inner,
176
443
  Color = theme.components.select.borderColor,
177
444
  })
178
- local _exp_2 = React.createElement(Corners, {
445
+ local _exp_3 = React.createElement(Corners, {
179
446
  radius = theme.components.select.cornerRadius,
180
447
  })
181
448
  local _attributes_1 = table.clone(props)
182
449
  setmetatable(_attributes_1, nil)
183
- local _exp_3 = React.createElement(Padding, _attributes_1)
184
- local _attributes_2 = {}
185
- local _result_1 = selectedOption
186
- if _result_1 ~= nil then
187
- _result_1 = _result_1.props.text
450
+ local _exp_4 = React.createElement(Padding, _attributes_1)
451
+ local _attributes_2 = {
452
+ name = "SelectedText",
453
+ }
454
+ local _result_2 = selectedOption
455
+ if _result_2 ~= nil then
456
+ _result_2 = _result_2.props.text
188
457
  end
189
- local _condition_1 = _result_1
190
- if _condition_1 == nil then
191
- _condition_1 = "No Options"
458
+ local _condition_4 = _result_2
459
+ if _condition_4 == nil then
460
+ _condition_4 = "No Options"
192
461
  end
193
- _attributes_2.text = _condition_1
462
+ _attributes_2.text = _condition_4
194
463
  _attributes_2.typography = typography
195
- local _exp_4 = React.createElement(HStack, nil, React.createElement(FlexItem, nil, React.createElement(Text, _attributes_2)), React.createElement(Icon, {
464
+ local _exp_5 = React.createElement(HStack, nil, React.createElement(FlexItem, nil, React.createElement(Text, _attributes_2)), React.createElement(Icon, {
465
+ name = "SelectCaret",
196
466
  icon = "caret-down",
197
467
  color = theme.colors.intents.primary.default.textColor,
198
468
  }))
199
- local _condition_2 = open and overlay.overlay ~= nil
200
- if _condition_2 then
469
+ local _condition_5 = open and overlay.overlay ~= nil
470
+ if _condition_5 then
201
471
  local _attributes_3 = {
472
+ key = "SelectDropdown",
202
473
  BackgroundTransparency = 0,
203
474
  BackgroundColor3 = theme.components.select.dropDownBackgroundColor,
204
475
  AnchorPoint = Vector2.zero,
@@ -208,13 +479,21 @@ local Select = React.forwardRef(function(props, ref)
208
479
  _attributes_3.Size = UDim2.fromOffset(dropdownSize.X.Offset, 0)
209
480
  _attributes_3.AutomaticSize = Enum.AutomaticSize.Y
210
481
  _attributes_3.ClipsDescendants = true
211
- _condition_2 = ReactRoblox.createPortal(React.createElement("frame", _attributes_3, React.createElement("uistroke", {
482
+ _condition_5 = ReactRoblox.createPortal(React.createElement("frame", _attributes_3, React.createElement("uistroke", {
483
+ key = "Stroke",
212
484
  Thickness = theme.components.select.borderThickness,
213
485
  BorderStrokePosition = Enum.BorderStrokePosition.Outer,
214
486
  Color = theme.components.select.borderColor,
215
487
  }), React.createElement(Corners, {
216
488
  radius = theme.components.select.cornerRadius,
217
- }), React.createElement(Scroller, {
489
+ }), React.createElement(VStack, {
490
+ spacing = "None",
491
+ }, props.searchable and (React.createElement(SelectSearchInput, {
492
+ value = query,
493
+ onChange = setQuery,
494
+ placeholder = props.searchPlaceholder,
495
+ scale = props.scale,
496
+ })), React.createElement(Scroller, {
218
497
  Size = UDim2.new(1, 0, 0, dropdownHeight),
219
498
  spacing = "None",
220
499
  }, React.createElement(VStack, {
@@ -224,20 +503,16 @@ local Select = React.forwardRef(function(props, ref)
224
503
  setContentHeight(layout.AbsoluteContentSize.Y)
225
504
  end,
226
505
  },
227
- }, React.Children.map(props.children, function(child, childIndex)
228
- if not React.isValidElement(child) then
229
- return child
230
- end
231
- -- React.Children.map uses a 1-based index in roblox-ts.
232
- local optionIndex = childIndex - 1
233
- return React.cloneElement(child, {
234
- index = optionIndex,
235
- })
236
- end)))), overlay.overlay)
506
+ }, if hasVisibleOptions then renderSections() else React.createElement(Text, {
507
+ name = "NoResultsText",
508
+ text = "No Results",
509
+ typography = typography,
510
+ }))))), overlay.overlay)
237
511
  end
238
- return React.createElement(Container, _attributes, React.createElement(SelectContext.Provider, {
512
+ return React.createElement(Container, _attributes, _exp_1, React.createElement(SelectContext.Provider, {
239
513
  value = context,
240
514
  }, React.createElement("imagebutton", {
515
+ key = "SelectButton",
241
516
  ref = buttonRef,
242
517
  Size = UDim2.fromScale(1, 0),
243
518
  AutomaticSize = Enum.AutomaticSize.Y,
@@ -245,9 +520,10 @@ local Select = React.forwardRef(function(props, ref)
245
520
  Event = {
246
521
  Activated = activateSelect,
247
522
  },
248
- }, _exp_1, _exp_2, _exp_3, _exp_4, _condition_2)))
523
+ }, _exp_2, _exp_3, _exp_4, _exp_5, _condition_5)))
249
524
  end)
250
525
  Select.Option = SelectOption
526
+ Select.OptGroup = SelectOptGroup
251
527
  return {
252
528
  Select = Select,
253
529
  }
@@ -68,11 +68,6 @@ local Slider = React.forwardRef(function(props, ref)
68
68
  end
69
69
  setValue(nextValue)
70
70
  end, {})
71
- --[[
72
- *
73
- * Converts an input position into a single slider value.
74
-
75
- ]]
76
71
  local getNumberFromInput = React.useCallback(function(input)
77
72
  local container = containerRef.current
78
73
  if not container then
@@ -95,14 +90,7 @@ local Slider = React.forwardRef(function(props, ref)
95
90
  local nextValue = minValue + percentage * (maxValue - minValue)
96
91
  local step = currentProps.step
97
92
  if step ~= nil and step > 0 then
98
- --[[
99
-
100
- * Offset snapping from minValue so ranges such as
101
- * min=5, step=2 produce 5, 7, 9, etc.
102
-
103
- ]]
104
93
  nextValue = minValue + math.round((nextValue - minValue) / step) * step
105
- -- Remove floating-point artifacts.
106
94
  local parts = string.split(tostring(step), ".")
107
95
  local decimals = if #parts > 1 then #parts[2] else 0
108
96
  local scale = 10 ^ decimals
@@ -110,12 +98,6 @@ local Slider = React.forwardRef(function(props, ref)
110
98
  end
111
99
  return math.clamp(nextValue, minValue, maxValue)
112
100
  end, {})
113
- --[[
114
- *
115
- * Converts a single input value into either a number or Vector2,
116
- * depending on whether range mode is enabled.
117
-
118
- ]]
119
101
  local getValueFromInput = React.useCallback(function(input)
120
102
  local inputValue = getNumberFromInput(input)
121
103
  if inputValue == nil then
@@ -186,12 +168,6 @@ local Slider = React.forwardRef(function(props, ref)
186
168
  if not isDraggingRef.current then
187
169
  return nil
188
170
  end
189
- --[[
190
-
191
- * Stop processing movement immediately, before
192
- * React gets around to updating the state.
193
-
194
- ]]
195
171
  isDraggingRef.current = false
196
172
  local nextValue = getValueFromInput(input)
197
173
  activeHandleRef.current = nil
@@ -248,19 +224,23 @@ local Slider = React.forwardRef(function(props, ref)
248
224
  }
249
225
  table.insert(handles, _arg0)
250
226
  end
251
- local _attributes = {
252
- ref = ref,
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
227
+ local _attributes = {}
228
+ local _condition_1 = props.name
260
229
  if _condition_1 == nil then
261
- _condition_1 = 1
230
+ _condition_1 = "Slider"
231
+ end
232
+ _attributes.key = _condition_1
233
+ _attributes.ref = ref
234
+ _attributes.Archivable = props.Archivable
235
+ _attributes.Tag = props.Tag
236
+ _attributes.Active = props.Active
237
+ _attributes.AnchorPoint = SizeHelper:GetAnchor(props)
238
+ _attributes.BackgroundColor3 = props.BackgroundColor3
239
+ local _condition_2 = props.BackgroundTransparency
240
+ if _condition_2 == nil then
241
+ _condition_2 = 1
262
242
  end
263
- _attributes.BackgroundTransparency = _condition_1
243
+ _attributes.BackgroundTransparency = _condition_2
264
244
  _attributes.BorderColor3 = props.BorderColor3
265
245
  _attributes.BorderMode = props.BorderMode
266
246
  _attributes.BorderSizePixel = props.BorderSizePixel
@@ -287,18 +267,22 @@ local Slider = React.forwardRef(function(props, ref)
287
267
  _attributes.Change = props.Change
288
268
  _attributes.Event = props.Event
289
269
  local _exp = React.createElement("frame", {
270
+ key = "Bar",
290
271
  Size = UDim2.new(UDim.new(1, 0), SizeHelper:toUDim(theme.bar.height)),
291
272
  Position = UDim2.fromScale(0.5, 0.5),
292
273
  AnchorPoint = Vector2.new(0.5, 0.5),
293
274
  BackgroundTransparency = theme.bar.backgroundTransparency,
294
275
  BackgroundColor3 = theme.bar.backgroundColor,
295
276
  }, React.createElement("uistroke", {
277
+ key = "Stroke",
296
278
  Thickness = theme.bar.borderThickness,
297
279
  Color = theme.bar.borderColor,
298
280
  }), React.createElement("uicorner", {
281
+ key = "Corners",
299
282
  CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
300
283
  }))
301
284
  local _attributes_1 = {
285
+ key = "HandleContainer",
302
286
  ref = containerRef,
303
287
  }
304
288
  local _exp_1 = UDim2.fromScale(1, 1)
@@ -307,9 +291,10 @@ local Slider = React.forwardRef(function(props, ref)
307
291
  _attributes_1.BackgroundTransparency = 1
308
292
  _attributes_1.Position = UDim2.fromScale(0.5, 0.5)
309
293
  _attributes_1.AnchorPoint = Vector2.new(0.5, 0.5)
310
- local _condition_2 = props.highlight ~= nil
311
- if _condition_2 then
294
+ local _condition_3 = props.highlight ~= nil
295
+ if _condition_3 then
312
296
  local _attributes_2 = {
297
+ key = "Highlight",
313
298
  BackgroundColor3 = theme.bar.highlight.backgroundColor,
314
299
  BackgroundTransparency = theme.bar.highlight.backgroundTransparency,
315
300
  }
@@ -339,27 +324,29 @@ local Slider = React.forwardRef(function(props, ref)
339
324
  else
340
325
  local _result_2
341
326
  if props.highlight == "end" then
342
- local _condition_3 = secondPosition
343
- if _condition_3 == nil then
344
- _condition_3 = firstPosition
327
+ local _condition_4 = secondPosition
328
+ if _condition_4 == nil then
329
+ _condition_4 = firstPosition
345
330
  end
346
- local _uDim2_1 = UDim2.new(UDim.new(1 - _condition_3, 0), SizeHelper:toUDim(theme.bar.height))
331
+ local _uDim2_1 = UDim2.new(UDim.new(1 - _condition_4, 0), SizeHelper:toUDim(theme.bar.height))
347
332
  local _uDim2_2 = UDim2.new(padding, UDim.new(0, 0))
348
333
  _result_2 = _uDim2_1 + _uDim2_2
349
334
  else
350
- local _condition_3 = secondPosition
351
- if _condition_3 == nil then
352
- _condition_3 = 0
335
+ local _condition_4 = secondPosition
336
+ if _condition_4 == nil then
337
+ _condition_4 = 0
353
338
  end
354
- _result_2 = UDim2.new(UDim.new(_condition_3 - firstPosition, 0), SizeHelper:toUDim(theme.bar.height))
339
+ _result_2 = UDim2.new(UDim.new(_condition_4 - firstPosition, 0), SizeHelper:toUDim(theme.bar.height))
355
340
  end
356
341
  _result_1 = _result_2
357
342
  end
358
343
  _attributes_2.Size = _result_1
359
- _condition_2 = (React.createElement("frame", _attributes_2, React.createElement("uistroke", {
344
+ _condition_3 = (React.createElement("frame", _attributes_2, React.createElement("uistroke", {
345
+ key = "Stroke",
360
346
  Thickness = theme.bar.borderThickness,
361
347
  Color = theme.bar.highlight.borderColor,
362
348
  }), React.createElement("uicorner", {
349
+ key = "Corners",
363
350
  CornerRadius = SizeHelper:toUDim(theme.bar.cornerRadius),
364
351
  })))
365
352
  end
@@ -369,25 +356,29 @@ local Slider = React.forwardRef(function(props, ref)
369
356
  local index = _param.index
370
357
  local position = _param.position
371
358
  local _exp_2 = React.createElement("uistroke", {
359
+ key = "Stroke",
372
360
  Thickness = theme.handle.borderThickness,
373
361
  Color = theme.handle.borderColor,
374
362
  })
375
363
  local _exp_3 = React.createElement("uicorner", {
364
+ key = "Corners",
376
365
  CornerRadius = SizeHelper:toUDim(theme.handle.cornerRadius),
377
366
  })
378
367
  local _exp_4 = (hoveredHandle == index or (dragging and activeHandleRef.current == index)) and (React.createElement(BoxShadow, {
379
368
  ["box-shadow"] = theme.handle.boxShadow,
380
369
  }))
381
- local _attributes_2 = {}
382
- local _condition_3 = theme.handle.aspectRatio
383
- if _condition_3 == nil then
384
- _condition_3 = 1
370
+ local _attributes_2 = {
371
+ key = "AspectRatio",
372
+ }
373
+ local _condition_4 = theme.handle.aspectRatio
374
+ if _condition_4 == nil then
375
+ _condition_4 = 1
385
376
  end
386
- _attributes_2.AspectRatio = _condition_3
377
+ _attributes_2.AspectRatio = _condition_4
387
378
  _attributes_2.DominantAxis = Enum.DominantAxis.Height
388
379
  _attributes_2.AspectType = Enum.AspectType.ScaleWithParentSize
389
380
  return React.createElement("frame", {
390
- key = index,
381
+ key = `Handle-{index}`,
391
382
  Position = UDim2.fromScale(position, 0.5),
392
383
  AnchorPoint = Vector2.new(0.5, 0.5),
393
384
  Size = UDim2.fromScale(0, 1),
@@ -413,7 +404,7 @@ local Slider = React.forwardRef(function(props, ref)
413
404
  _newValue[_k] = _callback(_v, _k - 1, handles)
414
405
  end
415
406
  -- ▲ ReadonlyArray.map ▲
416
- return React.createElement("frame", _attributes, _exp, React.createElement("frame", _attributes_1, _condition_2, _newValue))
407
+ return React.createElement("frame", _attributes, _exp, React.createElement("frame", _attributes_1, _condition_3, _newValue))
417
408
  end)
418
409
  return {
419
410
  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;