@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.
- 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 -6
- 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/Gradient.d.ts +8 -0
- package/out/Components/Decorator/Gradient.luau +23 -0
- package/out/Components/Decorator/Padding.d.ts +3 -1
- package/out/Components/Decorator/Padding.luau +11 -6
- package/out/Components/Decorator/index.d.ts +1 -0
- package/out/Components/Decorator/init.luau +3 -0
- package/out/Components/Input/Button.d.ts +1 -0
- package/out/Components/Input/Button.luau +49 -34
- package/out/Components/Input/Checkbox.d.ts +1 -0
- package/out/Components/Input/Checkbox.luau +28 -18
- package/out/Components/Input/HoverButton.d.ts +1 -0
- package/out/Components/Input/HoverButton.luau +44 -42
- 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 +89 -68
- package/out/Components/Input/Select.d.ts +11 -1
- package/out/Components/Input/Select.luau +315 -39
- package/out/Components/Input/Slider.luau +44 -53
- package/out/Components/Input/Switch.d.ts +9 -0
- package/out/Components/Input/Switch.luau +145 -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 +262 -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 -25
- 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 +3 -0
- package/out/Components/Layout/Container.luau +26 -17
- 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/Grid.d.ts +10 -0
- package/out/Components/Layout/Grid.luau +172 -0
- package/out/Components/Layout/Group.d.ts +1 -0
- package/out/Components/Layout/Group.luau +48 -60
- 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 +400 -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 +20 -10
- package/out/Components/Layout/Tabs.luau +113 -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 +3 -0
- package/out/Components/Layout/init.luau +9 -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 +3 -1
- package/out/Components/Surface/Box.luau +15 -4
- package/out/Components/Surface/Card.d.ts +1 -0
- package/out/Components/Surface/Card.luau +56 -154
- package/out/Components/Surface/Icon.d.ts +1 -0
- package/out/Components/Surface/Icon.luau +25 -16
- package/out/Components/Surface/ProgressBar.d.ts +14 -0
- package/out/Components/Surface/ProgressBar.luau +230 -0
- package/out/Components/Surface/index.d.ts +1 -0
- package/out/Components/Surface/init.luau +3 -0
- package/out/Components/Typography/Text.d.ts +1 -0
- package/out/Components/Typography/Text.luau +57 -53
- 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 +23 -0
- package/out/Contexts/toast.context.d.ts +1 -0
- package/out/Helpers/color.helper.luau +28 -0
- package/out/Helpers/css.helper.d.ts +4 -1
- package/out/Helpers/css.helper.luau +76 -6
- package/out/Helpers/gui.helper.luau +0 -3
- package/out/Helpers/size.helper.luau +0 -2
- package/out/Helpers/spacing.helper.luau +0 -3
- package/out/Helpers/typography.helper.luau +0 -2
- package/out/Interfaces/css.types.d.ts +7 -0
- package/out/Interfaces/css.types.luau +0 -20
- 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/Providers/registry.provider.luau +0 -2
- package/out/Theme/theme.style.d.ts +2 -1
- package/out/Theme/theme.template.d.ts +126 -1
- package/out/Theme/themes/dark.theme.luau +225 -0
- package/out/Theme/themes/default.theme.luau +210 -0
- package/out/Theme/themes/sandstone.theme.luau +173 -0
- package/out/Theme/themes/wooden.theme.luau +195 -0
- package/package.json +1 -1
|
@@ -0,0 +1,342 @@
|
|
|
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 CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
|
|
5
|
+
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
6
|
+
local SizeHelper = _Helpers.SizeHelper
|
|
7
|
+
local SpacingHelper = _Helpers.SpacingHelper
|
|
8
|
+
local TypographyHelper = _Helpers.TypographyHelper
|
|
9
|
+
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
10
|
+
local Corners = _Decorator.Corners
|
|
11
|
+
local Padding = _Decorator.Padding
|
|
12
|
+
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
13
|
+
local Container = TS.import(script, script.Parent, "Container").Container
|
|
14
|
+
local HStack = TS.import(script, script.Parent, "HStack").HStack
|
|
15
|
+
local VStack = TS.import(script, script.Parent, "VStack").VStack
|
|
16
|
+
local TableSectionContext = React.createContext(nil)
|
|
17
|
+
local TableScaleContext = React.createContext(nil)
|
|
18
|
+
local TableLayoutContext = React.createContext(nil)
|
|
19
|
+
local TableColumnContext = React.createContext(0)
|
|
20
|
+
local nextTableCellId = 0
|
|
21
|
+
local function TableHeader(props)
|
|
22
|
+
local theme = React.useContext(CleanThemeContext)
|
|
23
|
+
local layout = React.useContext(TableLayoutContext)
|
|
24
|
+
local _result = layout
|
|
25
|
+
if _result ~= nil then
|
|
26
|
+
_result = _result.autoWidth
|
|
27
|
+
end
|
|
28
|
+
local autoSectionWidth = if _result == true then layout.totalWidth else nil
|
|
29
|
+
return React.createElement(TableSectionContext.Provider, {
|
|
30
|
+
value = "header",
|
|
31
|
+
}, React.createElement(Container, {
|
|
32
|
+
name = "TableHeader",
|
|
33
|
+
Size = if autoSectionWidth ~= nil then UDim2.fromOffset(autoSectionWidth, 0) else nil,
|
|
34
|
+
width = if autoSectionWidth == nil then "100%" else nil,
|
|
35
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
36
|
+
BackgroundColor3 = theme.components.table.header.backgroundColor,
|
|
37
|
+
BackgroundTransparency = theme.components.table.header.backgroundTransparency,
|
|
38
|
+
}, React.createElement("uicorner", {
|
|
39
|
+
key = "Corners",
|
|
40
|
+
TopLeftRadius = SizeHelper:toUDim(theme.components.table.cornerRadius),
|
|
41
|
+
TopRightRadius = SizeHelper:toUDim(theme.components.table.cornerRadius),
|
|
42
|
+
BottomLeftRadius = UDim.new(0, 0),
|
|
43
|
+
BottomRightRadius = UDim.new(0, 0),
|
|
44
|
+
}), React.createElement(VStack, {
|
|
45
|
+
spacing = "None",
|
|
46
|
+
}, props.children)))
|
|
47
|
+
end
|
|
48
|
+
local function TableBody(props)
|
|
49
|
+
local layout = React.useContext(TableLayoutContext)
|
|
50
|
+
local _result = layout
|
|
51
|
+
if _result ~= nil then
|
|
52
|
+
_result = _result.autoWidth
|
|
53
|
+
end
|
|
54
|
+
local autoSectionWidth = if _result == true then layout.totalWidth else nil
|
|
55
|
+
return React.createElement(TableSectionContext.Provider, {
|
|
56
|
+
value = "body",
|
|
57
|
+
}, React.createElement(Container, {
|
|
58
|
+
name = "TableBody",
|
|
59
|
+
Size = if autoSectionWidth ~= nil then UDim2.fromOffset(autoSectionWidth, 0) else nil,
|
|
60
|
+
width = if autoSectionWidth == nil then "100%" else nil,
|
|
61
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
62
|
+
}, React.createElement(VStack, {
|
|
63
|
+
spacing = "None",
|
|
64
|
+
}, props.children)))
|
|
65
|
+
end
|
|
66
|
+
local TableHead, TableCell
|
|
67
|
+
local function TableRow(props)
|
|
68
|
+
local theme = React.useContext(CleanThemeContext)
|
|
69
|
+
local section = React.useContext(TableSectionContext)
|
|
70
|
+
local layout = React.useContext(TableLayoutContext)
|
|
71
|
+
local columnIndex = 0
|
|
72
|
+
local children = React.Children.map(props.children, function(child)
|
|
73
|
+
if not React.isValidElement(child) or (child.type ~= TableHead and child.type ~= TableCell) then
|
|
74
|
+
return child
|
|
75
|
+
end
|
|
76
|
+
local _original = columnIndex
|
|
77
|
+
columnIndex += 1
|
|
78
|
+
local currentColumnIndex = _original
|
|
79
|
+
return React.createElement(TableColumnContext.Provider, {
|
|
80
|
+
value = currentColumnIndex,
|
|
81
|
+
}, child)
|
|
82
|
+
end)
|
|
83
|
+
local _result = layout
|
|
84
|
+
if _result ~= nil then
|
|
85
|
+
_result = _result.autoWidth
|
|
86
|
+
end
|
|
87
|
+
local autoRowWidth = if _result == true then layout.totalWidth else nil
|
|
88
|
+
local _condition = section == "body"
|
|
89
|
+
if _condition then
|
|
90
|
+
local _attributes = {
|
|
91
|
+
key = "Divider",
|
|
92
|
+
BackgroundColor3 = theme.components.table.rowDividerColor,
|
|
93
|
+
BorderSizePixel = 0,
|
|
94
|
+
}
|
|
95
|
+
local _exp = UDim2.fromOffset(0, theme.components.table.rowDividerThickness)
|
|
96
|
+
local _arg0 = UDim2.fromScale(1, 0)
|
|
97
|
+
_attributes.Size = _exp + _arg0
|
|
98
|
+
_condition = (React.createElement("frame", _attributes))
|
|
99
|
+
end
|
|
100
|
+
return React.createElement(Container, {
|
|
101
|
+
name = "TableRow",
|
|
102
|
+
Size = if autoRowWidth ~= nil then UDim2.fromOffset(autoRowWidth, 0) else nil,
|
|
103
|
+
width = if autoRowWidth == nil then "100%" else nil,
|
|
104
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
105
|
+
}, _condition, React.createElement(Container, {
|
|
106
|
+
name = "TableRowContent",
|
|
107
|
+
width = "100%",
|
|
108
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
109
|
+
}, React.createElement(HStack, {
|
|
110
|
+
Padding = UDim.new(0, 0),
|
|
111
|
+
Wraps = false,
|
|
112
|
+
}, children)))
|
|
113
|
+
end
|
|
114
|
+
local function TableCellContent(props)
|
|
115
|
+
local theme = React.useContext(CleanThemeContext)
|
|
116
|
+
local tableScale = React.useContext(TableScaleContext)
|
|
117
|
+
local layout = React.useContext(TableLayoutContext)
|
|
118
|
+
local _original = nextTableCellId
|
|
119
|
+
nextTableCellId += 1
|
|
120
|
+
local id = React.useRef(_original).current
|
|
121
|
+
local measurementRef = React.useRef()
|
|
122
|
+
local typography = if props.header then TypographyHelper:getTypography(theme, tableScale, theme.components.table.header.typography) else TypographyHelper:getTypography(theme, tableScale, theme.components.table.cell.typography)
|
|
123
|
+
local _condition = props.text
|
|
124
|
+
if _condition == nil then
|
|
125
|
+
_condition = props.children
|
|
126
|
+
end
|
|
127
|
+
local content = _condition
|
|
128
|
+
local columnIndex = React.useContext(TableColumnContext)
|
|
129
|
+
local _result = layout
|
|
130
|
+
if _result ~= nil then
|
|
131
|
+
_result = _result.columnWidths[columnIndex]
|
|
132
|
+
end
|
|
133
|
+
local _condition_1 = _result
|
|
134
|
+
if _condition_1 == nil then
|
|
135
|
+
_condition_1 = 0
|
|
136
|
+
end
|
|
137
|
+
local columnWidth = _condition_1
|
|
138
|
+
local _result_1 = layout
|
|
139
|
+
if _result_1 ~= nil then
|
|
140
|
+
_result_1 = _result_1.autoWidth
|
|
141
|
+
end
|
|
142
|
+
local _condition_2 = _result_1 == false
|
|
143
|
+
if _condition_2 then
|
|
144
|
+
_condition_2 = layout.totalWidth > 0
|
|
145
|
+
end
|
|
146
|
+
local cellWidth = if _condition_2 then UDim.new(columnWidth / layout.totalWidth, 0) else UDim.new(0, columnWidth)
|
|
147
|
+
local _exp = function(instance)
|
|
148
|
+
local _result_2 = layout
|
|
149
|
+
if _result_2 ~= nil then
|
|
150
|
+
_result_2 = _result_2.reportWidth(id, columnIndex, instance.AbsoluteSize.X)
|
|
151
|
+
end
|
|
152
|
+
return _result_2
|
|
153
|
+
end
|
|
154
|
+
local _result_2 = layout
|
|
155
|
+
if _result_2 ~= nil then
|
|
156
|
+
_result_2 = _result_2.reportWidth
|
|
157
|
+
end
|
|
158
|
+
local reportMeasurement = React.useCallback(_exp, { _result_2, id, columnIndex })
|
|
159
|
+
local _exp_1 = function()
|
|
160
|
+
return function()
|
|
161
|
+
local _result_3 = layout
|
|
162
|
+
if _result_3 ~= nil then
|
|
163
|
+
_result_3 = _result_3.removeWidth(id)
|
|
164
|
+
end
|
|
165
|
+
return _result_3
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
local _result_3 = layout
|
|
169
|
+
if _result_3 ~= nil then
|
|
170
|
+
_result_3 = _result_3.removeWidth
|
|
171
|
+
end
|
|
172
|
+
React.useEffect(_exp_1, { _result_3 })
|
|
173
|
+
React.useEffect(function()
|
|
174
|
+
local mounted = true
|
|
175
|
+
local reportMountedMeasurement = function()
|
|
176
|
+
local instance = measurementRef.current
|
|
177
|
+
if mounted and instance ~= nil then
|
|
178
|
+
reportMeasurement(instance)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
reportMountedMeasurement()
|
|
182
|
+
task.defer(reportMountedMeasurement)
|
|
183
|
+
return function()
|
|
184
|
+
mounted = false
|
|
185
|
+
end
|
|
186
|
+
end, { reportMeasurement })
|
|
187
|
+
local _exp_2 = React.createElement("uilistlayout", {
|
|
188
|
+
key = "TableCellLayout",
|
|
189
|
+
FillDirection = Enum.FillDirection.Horizontal,
|
|
190
|
+
HorizontalAlignment = props.align or "Left",
|
|
191
|
+
})
|
|
192
|
+
local _attributes = {}
|
|
193
|
+
local _object = table.clone(props)
|
|
194
|
+
setmetatable(_object, nil)
|
|
195
|
+
_object.spacing = props.spacing or tableScale
|
|
196
|
+
_attributes.resolvedPadding = SpacingHelper:GetResolvedPadding(theme, _object, theme.components.table.cell.spacing, theme.components.table.cell.padding)
|
|
197
|
+
return React.createElement(Container, {
|
|
198
|
+
name = if props.header then "TableHead" else "TableCell",
|
|
199
|
+
Size = UDim2.new(cellWidth, UDim.new(0, 0)),
|
|
200
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
201
|
+
}, _exp_2, React.createElement("frame", {
|
|
202
|
+
key = "TableCellMeasurement",
|
|
203
|
+
ref = measurementRef,
|
|
204
|
+
Size = UDim2.fromOffset(0, 0),
|
|
205
|
+
AutomaticSize = Enum.AutomaticSize.XY,
|
|
206
|
+
BackgroundTransparency = 1,
|
|
207
|
+
Change = {
|
|
208
|
+
AbsoluteSize = reportMeasurement,
|
|
209
|
+
},
|
|
210
|
+
}, React.createElement(Padding, _attributes), if type(content) == "string" then React.createElement(Text, {
|
|
211
|
+
text = content,
|
|
212
|
+
typography = typography,
|
|
213
|
+
TextWrap = false,
|
|
214
|
+
}) else content))
|
|
215
|
+
end
|
|
216
|
+
function TableHead(props)
|
|
217
|
+
local _object = table.clone(props)
|
|
218
|
+
setmetatable(_object, nil)
|
|
219
|
+
_object.header = true
|
|
220
|
+
return TableCellContent(_object)
|
|
221
|
+
end
|
|
222
|
+
function TableCell(props)
|
|
223
|
+
local _object = table.clone(props)
|
|
224
|
+
setmetatable(_object, nil)
|
|
225
|
+
_object.header = false
|
|
226
|
+
return TableCellContent(_object)
|
|
227
|
+
end
|
|
228
|
+
local Table = React.forwardRef(function(props, ref)
|
|
229
|
+
local theme = React.useContext(CleanThemeContext)
|
|
230
|
+
local measurements, setMeasurements = React.useState({})
|
|
231
|
+
local autoWidth = props.Size == nil and props.width == nil
|
|
232
|
+
local reportWidth = React.useCallback(function(id, columnIndex, width)
|
|
233
|
+
setMeasurements(function(current)
|
|
234
|
+
local _current = current
|
|
235
|
+
local _id = id
|
|
236
|
+
local previous = _current[_id]
|
|
237
|
+
local _result = previous
|
|
238
|
+
if _result ~= nil then
|
|
239
|
+
_result = _result.columnIndex
|
|
240
|
+
end
|
|
241
|
+
local _condition = _result == columnIndex
|
|
242
|
+
if _condition then
|
|
243
|
+
_condition = previous.width == width
|
|
244
|
+
end
|
|
245
|
+
if _condition then
|
|
246
|
+
return current
|
|
247
|
+
end
|
|
248
|
+
local updated = {}
|
|
249
|
+
for currentId, measurement in current do
|
|
250
|
+
updated[currentId] = measurement
|
|
251
|
+
end
|
|
252
|
+
local _id_1 = id
|
|
253
|
+
local _arg1 = {
|
|
254
|
+
columnIndex = columnIndex,
|
|
255
|
+
width = width,
|
|
256
|
+
}
|
|
257
|
+
updated[_id_1] = _arg1
|
|
258
|
+
return updated
|
|
259
|
+
end)
|
|
260
|
+
end, {})
|
|
261
|
+
local removeWidth = React.useCallback(function(id)
|
|
262
|
+
setMeasurements(function(current)
|
|
263
|
+
local _current = current
|
|
264
|
+
local _id = id
|
|
265
|
+
if not (_current[_id] ~= nil) then
|
|
266
|
+
return current
|
|
267
|
+
end
|
|
268
|
+
local updated = {}
|
|
269
|
+
for currentId, measurement in current do
|
|
270
|
+
updated[currentId] = measurement
|
|
271
|
+
end
|
|
272
|
+
local _id_1 = id
|
|
273
|
+
updated[_id_1] = nil
|
|
274
|
+
return updated
|
|
275
|
+
end)
|
|
276
|
+
end, {})
|
|
277
|
+
local columnWidths = React.useMemo(function()
|
|
278
|
+
local widths = {}
|
|
279
|
+
for _, measurement in measurements do
|
|
280
|
+
local _exp = measurement.columnIndex
|
|
281
|
+
local _columnIndex = measurement.columnIndex
|
|
282
|
+
local _condition = widths[_columnIndex]
|
|
283
|
+
if _condition == nil then
|
|
284
|
+
_condition = 0
|
|
285
|
+
end
|
|
286
|
+
local _arg1 = math.max(_condition, measurement.width)
|
|
287
|
+
widths[_exp] = _arg1
|
|
288
|
+
end
|
|
289
|
+
return widths
|
|
290
|
+
end, { measurements })
|
|
291
|
+
local totalWidth = 0
|
|
292
|
+
for _, width in columnWidths do
|
|
293
|
+
totalWidth += width
|
|
294
|
+
end
|
|
295
|
+
local layout = React.useMemo(function()
|
|
296
|
+
return {
|
|
297
|
+
autoWidth = autoWidth,
|
|
298
|
+
columnWidths = columnWidths,
|
|
299
|
+
totalWidth = totalWidth,
|
|
300
|
+
reportWidth = reportWidth,
|
|
301
|
+
removeWidth = removeWidth,
|
|
302
|
+
}
|
|
303
|
+
end, { autoWidth, columnWidths, totalWidth, reportWidth, removeWidth })
|
|
304
|
+
local _attributes = {
|
|
305
|
+
ref = ref,
|
|
306
|
+
}
|
|
307
|
+
local _condition = props.name
|
|
308
|
+
if _condition == nil then
|
|
309
|
+
_condition = "Table"
|
|
310
|
+
end
|
|
311
|
+
_attributes.name = _condition
|
|
312
|
+
_attributes.Size = props.Size
|
|
313
|
+
_attributes.width = props.width
|
|
314
|
+
_attributes.height = props.height
|
|
315
|
+
_attributes.AutomaticSize = props.AutomaticSize
|
|
316
|
+
_attributes.BackgroundColor3 = theme.components.table.backgroundColor
|
|
317
|
+
_attributes.BackgroundTransparency = theme.components.table.backgroundTransparency
|
|
318
|
+
_attributes.ClipsDescendants = true
|
|
319
|
+
return React.createElement(TableScaleContext.Provider, {
|
|
320
|
+
value = props.scale,
|
|
321
|
+
}, React.createElement(TableLayoutContext.Provider, {
|
|
322
|
+
value = layout,
|
|
323
|
+
}, React.createElement(Container, _attributes, React.createElement(Corners, {
|
|
324
|
+
radius = theme.components.table.cornerRadius,
|
|
325
|
+
}), React.createElement("uistroke", {
|
|
326
|
+
key = "Stroke",
|
|
327
|
+
Color = theme.components.table.borderColor,
|
|
328
|
+
Thickness = theme.components.table.borderThickness,
|
|
329
|
+
BorderStrokePosition = Enum.BorderStrokePosition.Outer,
|
|
330
|
+
}), React.createElement(VStack, {
|
|
331
|
+
spacing = "None",
|
|
332
|
+
HorizontalFlex = if autoWidth then Enum.UIFlexAlignment.None else Enum.UIFlexAlignment.Fill,
|
|
333
|
+
}, props.children))))
|
|
334
|
+
end)
|
|
335
|
+
Table.Header = TableHeader
|
|
336
|
+
Table.Body = TableBody
|
|
337
|
+
Table.Row = TableRow
|
|
338
|
+
Table.Head = TableHead
|
|
339
|
+
Table.Cell = TableCell
|
|
340
|
+
return {
|
|
341
|
+
Table = Table,
|
|
342
|
+
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
|
-
import { PaddingProps, ScalableElementProps } from "../../Interfaces";
|
|
2
|
+
import { CssBackgroundGradient, PaddingProps, ScalableElementProps } from "../../Interfaces";
|
|
3
3
|
import { CssBackgroundImage } from "../../Theme";
|
|
4
|
-
interface TabProps {
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
declare function Tab(_props: TabProps): undefined;
|
|
8
4
|
interface TabTitleProps extends PaddingProps {
|
|
5
|
+
value: string;
|
|
9
6
|
text: string;
|
|
10
7
|
}
|
|
11
|
-
declare function TabTitle(
|
|
8
|
+
declare function TabTitle(props: TabTitleProps): React.JSX.Element;
|
|
12
9
|
interface TabContentProps {
|
|
10
|
+
value: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
declare function TabContent(props: TabContentProps): React.JSX.Element;
|
|
14
|
+
interface TabsListProps extends ScalableElementProps {
|
|
13
15
|
children?: React.ReactNode;
|
|
14
16
|
}
|
|
15
|
-
declare
|
|
16
|
-
interface
|
|
17
|
+
declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<ImageLabel>>;
|
|
18
|
+
interface TabsBodyProps extends ScalableElementProps {
|
|
17
19
|
backgroundImage?: CssBackgroundImage;
|
|
20
|
+
backgroundGradient?: CssBackgroundGradient;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
declare const TabsBody: React.ForwardRefExoticComponent<TabsBodyProps & React.RefAttributes<ImageLabel>>;
|
|
24
|
+
export interface TabsProps {
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
defaultValue?: string;
|
|
18
27
|
}
|
|
19
|
-
type TabsComponent = React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<
|
|
20
|
-
|
|
28
|
+
type TabsComponent = React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<Frame>> & {
|
|
29
|
+
List: typeof TabsList;
|
|
30
|
+
Body: typeof TabsBody;
|
|
21
31
|
Title: typeof TabTitle;
|
|
22
32
|
Content: typeof TabContent;
|
|
23
33
|
};
|
|
@@ -9,6 +9,7 @@ local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contex
|
|
|
9
9
|
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
10
10
|
local BoxShadow = _Decorator.BoxShadow
|
|
11
11
|
local Corners = _Decorator.Corners
|
|
12
|
+
local Gradient = _Decorator.Gradient
|
|
12
13
|
local Padding = _Decorator.Padding
|
|
13
14
|
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
14
15
|
local ColorHelper = _Helpers.ColorHelper
|
|
@@ -18,15 +19,10 @@ local TypographyHelper = _Helpers.TypographyHelper
|
|
|
18
19
|
local _HoverButton = TS.import(script, script.Parent.Parent, "Input", "HoverButton")
|
|
19
20
|
local HoverButton = _HoverButton.HoverButton
|
|
20
21
|
local HoverButtonContext = _HoverButton.HoverButtonContext
|
|
21
|
-
local
|
|
22
|
-
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
return nil
|
|
26
|
-
end
|
|
27
|
-
local function TabContent(props)
|
|
28
|
-
return nil
|
|
29
|
-
end
|
|
22
|
+
local TabsContext = React.createContext({
|
|
23
|
+
selected = nil,
|
|
24
|
+
setSelected = function() end,
|
|
25
|
+
})
|
|
30
26
|
local function TabButtonContent(props)
|
|
31
27
|
local theme = React.useContext(CleanThemeContext)
|
|
32
28
|
local hover = React.useContext(HoverButtonContext)
|
|
@@ -52,57 +48,95 @@ local function TabButtonContent(props)
|
|
|
52
48
|
}), React.createElement(BoxShadow, {
|
|
53
49
|
value = intent.boxShadow,
|
|
54
50
|
}), React.createElement(Text, {
|
|
51
|
+
name = "TabTitleText",
|
|
55
52
|
TextColor3 = intent.textColor,
|
|
56
53
|
text = props.text,
|
|
57
54
|
typography = TypographyHelper:getTypography(theme, nil, intent.typography),
|
|
58
55
|
}))
|
|
59
56
|
end
|
|
60
|
-
local
|
|
57
|
+
local function TabTitle(props)
|
|
61
58
|
local theme = React.useContext(CleanThemeContext)
|
|
62
|
-
local
|
|
63
|
-
local
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
local tab = child
|
|
72
|
-
React.Children.forEach(tab.props.children, function(tabChild)
|
|
73
|
-
if not React.isValidElement(tabChild) then
|
|
74
|
-
return nil
|
|
75
|
-
end
|
|
76
|
-
if tabChild.type == TabTitle then
|
|
77
|
-
title = (tabChild.props)
|
|
78
|
-
elseif tabChild.type == TabContent then
|
|
79
|
-
content = (tabChild.props).children
|
|
80
|
-
end
|
|
81
|
-
end)
|
|
82
|
-
if title ~= nil then
|
|
83
|
-
local _arg0 = {
|
|
84
|
-
title = title,
|
|
85
|
-
content = content,
|
|
86
|
-
}
|
|
87
|
-
table.insert(tabs, _arg0)
|
|
59
|
+
local _binding = React.useContext(TabsContext)
|
|
60
|
+
local selected = _binding.selected
|
|
61
|
+
local setSelected = _binding.setSelected
|
|
62
|
+
local isSelected = selected == props.value
|
|
63
|
+
React.useEffect(function()
|
|
64
|
+
setSelected(function(current)
|
|
65
|
+
local _condition = current
|
|
66
|
+
if _condition == nil then
|
|
67
|
+
_condition = props.value
|
|
88
68
|
end
|
|
69
|
+
return _condition
|
|
89
70
|
end)
|
|
90
|
-
|
|
91
|
-
end, { props.children })
|
|
92
|
-
local tabCount = #tabs
|
|
93
|
-
React.useEffect(function()
|
|
94
|
-
if selected >= tabCount then
|
|
95
|
-
setSelected(math.max(0, tabCount - 1))
|
|
96
|
-
end
|
|
97
|
-
end, { selected, tabCount })
|
|
98
|
-
local selectedTab = tabs[selected + 1]
|
|
71
|
+
end, {})
|
|
99
72
|
local buttonDefault = ColorHelper:getIntentColors(theme, "primary", "default", theme.components.tabs.button.intents)
|
|
100
73
|
local buttonHover = ColorHelper:getIntentColors(theme, "primary", "hover", theme.components.tabs.button.intents)
|
|
101
74
|
local buttonFocus = ColorHelper:getIntentColors(theme, "primary", "focus", theme.components.tabs.button.intents)
|
|
102
75
|
local buttonDefaultBackgroundImage = CssHelper:resolveBackgroundImage(buttonDefault.backgroundImage)
|
|
103
76
|
local buttonHoverBackgroundImage = CssHelper:resolveBackgroundImage(buttonHover.backgroundImage)
|
|
104
77
|
local buttonFocusBackgroundImage = CssHelper:resolveBackgroundImage(buttonFocus.backgroundImage)
|
|
78
|
+
local _attributes = table.clone(props)
|
|
79
|
+
setmetatable(_attributes, nil)
|
|
80
|
+
return React.createElement(HoverButton, {
|
|
81
|
+
isSelected = isSelected,
|
|
82
|
+
name = `TabButton-{props.value}`,
|
|
83
|
+
default = {
|
|
84
|
+
Size = UDim2.fromScale(0, 0),
|
|
85
|
+
AutomaticSize = Enum.AutomaticSize.XY,
|
|
86
|
+
BackgroundColor3 = buttonDefault.backgroundColor,
|
|
87
|
+
BackgroundTransparency = buttonDefault.backgroundTransparency,
|
|
88
|
+
BorderSizePixel = 0,
|
|
89
|
+
AutoButtonColor = false,
|
|
90
|
+
Image = buttonDefaultBackgroundImage.Image,
|
|
91
|
+
ImageColor3 = buttonDefaultBackgroundImage.ImageColor3,
|
|
92
|
+
ImageTransparency = buttonDefaultBackgroundImage.ImageTransparency,
|
|
93
|
+
ScaleType = buttonDefaultBackgroundImage.ScaleType,
|
|
94
|
+
SliceCenter = buttonDefaultBackgroundImage.SliceCenter,
|
|
95
|
+
SliceScale = buttonDefaultBackgroundImage.SliceScale,
|
|
96
|
+
TileSize = buttonDefaultBackgroundImage.TileSize,
|
|
97
|
+
Event = {
|
|
98
|
+
Activated = function()
|
|
99
|
+
setSelected(props.value)
|
|
100
|
+
end,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
hover = {
|
|
104
|
+
BackgroundColor3 = buttonHover.backgroundColor,
|
|
105
|
+
BackgroundTransparency = buttonHover.backgroundTransparency,
|
|
106
|
+
Image = buttonHoverBackgroundImage.Image,
|
|
107
|
+
ImageColor3 = buttonHoverBackgroundImage.ImageColor3,
|
|
108
|
+
ImageTransparency = buttonHoverBackgroundImage.ImageTransparency,
|
|
109
|
+
ScaleType = buttonHoverBackgroundImage.ScaleType,
|
|
110
|
+
SliceCenter = buttonHoverBackgroundImage.SliceCenter,
|
|
111
|
+
SliceScale = buttonHoverBackgroundImage.SliceScale,
|
|
112
|
+
TileSize = buttonHoverBackgroundImage.TileSize,
|
|
113
|
+
},
|
|
114
|
+
focus = {
|
|
115
|
+
BackgroundColor3 = buttonFocus.backgroundColor,
|
|
116
|
+
BackgroundTransparency = buttonFocus.backgroundTransparency,
|
|
117
|
+
Image = buttonFocusBackgroundImage.Image,
|
|
118
|
+
ImageColor3 = buttonFocusBackgroundImage.ImageColor3,
|
|
119
|
+
ImageTransparency = buttonFocusBackgroundImage.ImageTransparency,
|
|
120
|
+
ScaleType = buttonFocusBackgroundImage.ScaleType,
|
|
121
|
+
SliceCenter = buttonFocusBackgroundImage.SliceCenter,
|
|
122
|
+
SliceScale = buttonFocusBackgroundImage.SliceScale,
|
|
123
|
+
TileSize = buttonFocusBackgroundImage.TileSize,
|
|
124
|
+
},
|
|
125
|
+
}, React.createElement(TabButtonContent, _attributes))
|
|
126
|
+
end
|
|
127
|
+
local function TabContent(props)
|
|
128
|
+
local _binding = React.useContext(TabsContext)
|
|
129
|
+
local selected = _binding.selected
|
|
130
|
+
return React.createElement(Container, {
|
|
131
|
+
name = `TabContent_{props.value}`,
|
|
132
|
+
width = "100%",
|
|
133
|
+
Visible = selected == props.value,
|
|
134
|
+
}, props.children)
|
|
135
|
+
end
|
|
136
|
+
local TabsList = React.forwardRef(function(props, ref)
|
|
137
|
+
local theme = React.useContext(CleanThemeContext)
|
|
105
138
|
local _attributes = {
|
|
139
|
+
name = "TabsList",
|
|
106
140
|
ref = ref,
|
|
107
141
|
BackgroundColor3 = theme.components.tabs.list.backgroundColor,
|
|
108
142
|
width = "100%",
|
|
@@ -113,89 +147,49 @@ local Tabs = React.forwardRef(function(props, ref)
|
|
|
113
147
|
end
|
|
114
148
|
_attributes.BackgroundTransparency = _condition
|
|
115
149
|
_attributes.backgroundImage = theme.components.tabs.list.backgroundImage
|
|
116
|
-
|
|
150
|
+
return React.createElement(Container, _attributes, React.createElement(Corners, {
|
|
117
151
|
radius = theme.components.tabs.list.cornerRadius,
|
|
118
|
-
})
|
|
119
|
-
|
|
152
|
+
}), React.createElement(Gradient, {
|
|
153
|
+
value = theme.components.tabs.list.backgroundGradient,
|
|
154
|
+
}), React.createElement(Padding, {
|
|
120
155
|
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.tabs.list.spacing, theme.components.tabs.list.padding),
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
local
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
BackgroundColor3 = buttonDefault.backgroundColor,
|
|
133
|
-
BackgroundTransparency = buttonDefault.backgroundTransparency,
|
|
134
|
-
BorderSizePixel = 0,
|
|
135
|
-
AutoButtonColor = false,
|
|
136
|
-
Image = buttonDefaultBackgroundImage.Image,
|
|
137
|
-
ImageColor3 = buttonDefaultBackgroundImage.ImageColor3,
|
|
138
|
-
ImageTransparency = buttonDefaultBackgroundImage.ImageTransparency,
|
|
139
|
-
ScaleType = buttonDefaultBackgroundImage.ScaleType,
|
|
140
|
-
SliceCenter = buttonDefaultBackgroundImage.SliceCenter,
|
|
141
|
-
SliceScale = buttonDefaultBackgroundImage.SliceScale,
|
|
142
|
-
TileSize = buttonDefaultBackgroundImage.TileSize,
|
|
143
|
-
Event = {
|
|
144
|
-
Activated = function()
|
|
145
|
-
setSelected(index)
|
|
146
|
-
end,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
hover = {
|
|
150
|
-
BackgroundColor3 = buttonHover.backgroundColor,
|
|
151
|
-
BackgroundTransparency = buttonHover.backgroundTransparency,
|
|
152
|
-
Image = buttonHoverBackgroundImage.Image,
|
|
153
|
-
ImageColor3 = buttonHoverBackgroundImage.ImageColor3,
|
|
154
|
-
ImageTransparency = buttonHoverBackgroundImage.ImageTransparency,
|
|
155
|
-
ScaleType = buttonHoverBackgroundImage.ScaleType,
|
|
156
|
-
SliceCenter = buttonHoverBackgroundImage.SliceCenter,
|
|
157
|
-
SliceScale = buttonHoverBackgroundImage.SliceScale,
|
|
158
|
-
TileSize = buttonHoverBackgroundImage.TileSize,
|
|
159
|
-
},
|
|
160
|
-
focus = {
|
|
161
|
-
BackgroundColor3 = buttonFocus.backgroundColor,
|
|
162
|
-
BackgroundTransparency = buttonFocus.backgroundTransparency,
|
|
163
|
-
Image = buttonFocusBackgroundImage.Image,
|
|
164
|
-
ImageColor3 = buttonFocusBackgroundImage.ImageColor3,
|
|
165
|
-
ImageTransparency = buttonFocusBackgroundImage.ImageTransparency,
|
|
166
|
-
ScaleType = buttonFocusBackgroundImage.ScaleType,
|
|
167
|
-
SliceCenter = buttonFocusBackgroundImage.SliceCenter,
|
|
168
|
-
SliceScale = buttonFocusBackgroundImage.SliceScale,
|
|
169
|
-
TileSize = buttonFocusBackgroundImage.TileSize,
|
|
170
|
-
},
|
|
171
|
-
}, React.createElement(TabButtonContent, _attributes_1))
|
|
172
|
-
end
|
|
173
|
-
for _k, _v in tabs do
|
|
174
|
-
_newValue[_k] = _callback(_v, _k - 1, tabs)
|
|
175
|
-
end
|
|
176
|
-
-- ▲ ReadonlyArray.map ▲
|
|
177
|
-
local _exp_2 = React.createElement(Container, _attributes, _exp, _exp_1, React.createElement(HStack, nil, _newValue))
|
|
178
|
-
local _exp_3 = React.createElement("uistroke", {
|
|
156
|
+
}), React.createElement(HStack, nil, props.children))
|
|
157
|
+
end)
|
|
158
|
+
local TabsBody = React.forwardRef(function(props, ref)
|
|
159
|
+
local theme = React.useContext(CleanThemeContext)
|
|
160
|
+
return React.createElement(Container, {
|
|
161
|
+
name = "TabsBody",
|
|
162
|
+
ref = ref,
|
|
163
|
+
width = "100%",
|
|
164
|
+
backgroundImage = props.backgroundImage or theme.components.tabs.backgroundImage,
|
|
165
|
+
}, React.createElement("uistroke", {
|
|
166
|
+
key = "Stroke",
|
|
179
167
|
Thickness = theme.components.tabs.borderThickness,
|
|
180
168
|
BorderStrokePosition = Enum.BorderStrokePosition.Inner,
|
|
181
169
|
Color = theme.components.tabs.borderColor,
|
|
182
|
-
})
|
|
183
|
-
local _exp_4 = React.createElement(Padding, {
|
|
170
|
+
}), React.createElement(Padding, {
|
|
184
171
|
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.tabs.spacing, theme.components.tabs.padding),
|
|
185
|
-
})
|
|
186
|
-
local _exp_5 = React.createElement(Corners, {
|
|
172
|
+
}), React.createElement(Corners, {
|
|
187
173
|
radius = theme.components.tabs.cornerRadius,
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
174
|
+
}), React.createElement(Gradient, {
|
|
175
|
+
value = props.backgroundGradient or theme.components.tabs.backgroundGradient,
|
|
176
|
+
}), props.children)
|
|
177
|
+
end)
|
|
178
|
+
local Tabs = React.forwardRef(function(props, _ref)
|
|
179
|
+
local selected, setSelected = React.useState(props.defaultValue)
|
|
180
|
+
local contextValue = React.useMemo(function()
|
|
181
|
+
return {
|
|
182
|
+
selected = selected,
|
|
183
|
+
setSelected = setSelected,
|
|
184
|
+
}
|
|
185
|
+
end, { selected })
|
|
186
|
+
return React.createElement(TabsContext.Provider, {
|
|
187
|
+
value = contextValue,
|
|
188
|
+
}, React.createElement(VStack, nil, props.children))
|
|
196
189
|
end)
|
|
190
|
+
Tabs.List = TabsList
|
|
191
|
+
Tabs.Body = TabsBody
|
|
197
192
|
Tabs.Title = TabTitle
|
|
198
|
-
Tabs.Tab = Tab
|
|
199
193
|
Tabs.Content = TabContent
|
|
200
194
|
return {
|
|
201
195
|
Tabs = Tabs,
|
|
@@ -4,11 +4,14 @@ interface VStackProps extends SpacedElementProps {
|
|
|
4
4
|
valign?: Enum.VerticalAlignment | "Center" | "Top" | "Bottom" | React.Binding<Enum.VerticalAlignment> | undefined;
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
HorizontalFlex?: Enum.UIFlexAlignment;
|
|
7
|
+
HorizontalAlignment?: Enum.HorizontalAlignment;
|
|
7
8
|
VerticalFlex?: Enum.UIFlexAlignment;
|
|
8
9
|
VerticalAlignment?: Enum.VerticalAlignment;
|
|
9
10
|
Event?: React.InstanceEvent<UIListLayout>;
|
|
10
11
|
Change?: React.InstanceChangeEvent<UIListLayout>;
|
|
11
12
|
Padding?: UDim | Binding<UDim>;
|
|
13
|
+
Wraps?: boolean;
|
|
14
|
+
name?: string;
|
|
12
15
|
}
|
|
13
16
|
export declare function VStack(props: VStackProps): React.JSX.Element;
|
|
14
17
|
export {};
|