@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
|
@@ -3,11 +3,15 @@ import { SpacedElementProps } from "../../Interfaces";
|
|
|
3
3
|
interface HStackProps extends SpacedElementProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
valign?: Enum.VerticalAlignment | "Center" | "Top" | "Bottom" | React.Binding<Enum.VerticalAlignment> | undefined;
|
|
6
|
+
VerticalAlignment?: Enum.VerticalAlignment;
|
|
6
7
|
Wraps?: boolean;
|
|
8
|
+
HorizontalAlignment?: Enum.HorizontalAlignment;
|
|
7
9
|
HorizontalFlex?: Enum.UIFlexAlignment;
|
|
10
|
+
VerticalFlex?: Enum.UIFlexAlignment;
|
|
8
11
|
Event?: React.InstanceEvent<UIListLayout>;
|
|
9
12
|
Change?: React.InstanceChangeEvent<UIListLayout>;
|
|
10
13
|
Padding?: UDim | Binding<UDim>;
|
|
14
|
+
name?: string;
|
|
11
15
|
}
|
|
12
16
|
export declare function HStack(props: HStackProps): React.JSX.Element;
|
|
13
17
|
export {};
|
|
@@ -5,16 +5,23 @@ local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contex
|
|
|
5
5
|
local SpacingHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").SpacingHelper
|
|
6
6
|
local function HStack(props)
|
|
7
7
|
local theme = React.useContext(CleanThemeContext)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
local _attributes = {}
|
|
9
|
+
local _condition = props.name
|
|
10
|
+
if _condition == nil then
|
|
11
|
+
_condition = "HStack"
|
|
12
|
+
end
|
|
13
|
+
_attributes.key = _condition
|
|
14
|
+
_attributes.FillDirection = Enum.FillDirection.Horizontal
|
|
15
|
+
_attributes.HorizontalFlex = props.HorizontalFlex
|
|
16
|
+
_attributes.HorizontalAlignment = props.HorizontalAlignment
|
|
17
|
+
_attributes.VerticalAlignment = props.valign or props.VerticalAlignment
|
|
18
|
+
_attributes.VerticalFlex = props.VerticalFlex
|
|
19
|
+
_attributes.Padding = props.Padding or UDim.new(0, math.ceil(SpacingHelper:GetPadding(theme, props.spacing) / 2))
|
|
20
|
+
_attributes.Wraps = if props.Wraps == nil then true else props.Wraps
|
|
21
|
+
_attributes.SortOrder = Enum.SortOrder.LayoutOrder
|
|
22
|
+
_attributes.Change = props.Change
|
|
23
|
+
_attributes.Event = props.Event
|
|
24
|
+
return React.createElement(React.Fragment, nil, React.createElement("uilistlayout", _attributes), props.children)
|
|
18
25
|
end
|
|
19
26
|
return {
|
|
20
27
|
HStack = HStack,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { PaddingProps } from "../../Interfaces";
|
|
3
|
+
export interface PaginationItemProps extends PaddingProps {
|
|
4
|
+
value: number;
|
|
5
|
+
layoutOrder?: number;
|
|
6
|
+
}
|
|
7
|
+
declare function PaginationItem(props: PaginationItemProps): React.JSX.Element;
|
|
8
|
+
declare function PaginationPrev(): React.JSX.Element;
|
|
9
|
+
declare function PaginationNext(): React.JSX.Element;
|
|
10
|
+
declare function PaginationEllipsis(props: {
|
|
11
|
+
layoutOrder?: number;
|
|
12
|
+
}): React.JSX.Element;
|
|
13
|
+
export interface PaginationListProps {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
declare function PaginationList(props: PaginationListProps): React.JSX.Element;
|
|
17
|
+
export interface PaginationProps {
|
|
18
|
+
page: number;
|
|
19
|
+
totalPages: number;
|
|
20
|
+
siblingCount?: number;
|
|
21
|
+
onPageChange: (page: number) => void;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
type PaginationComponent = React.ForwardRefExoticComponent<PaginationProps & React.RefAttributes<Frame>> & {
|
|
25
|
+
Prev: typeof PaginationPrev;
|
|
26
|
+
Next: typeof PaginationNext;
|
|
27
|
+
Item: typeof PaginationItem;
|
|
28
|
+
Ellipsis: typeof PaginationEllipsis;
|
|
29
|
+
List: typeof PaginationList;
|
|
30
|
+
};
|
|
31
|
+
declare const Pagination: PaginationComponent;
|
|
32
|
+
export { Pagination };
|
|
@@ -0,0 +1,405 @@
|
|
|
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 ColorHelper = _Helpers.ColorHelper
|
|
7
|
+
local CssHelper = _Helpers.CssHelper
|
|
8
|
+
local SpacingHelper = _Helpers.SpacingHelper
|
|
9
|
+
local TypographyHelper = _Helpers.TypographyHelper
|
|
10
|
+
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
11
|
+
local BoxShadow = _Decorator.BoxShadow
|
|
12
|
+
local Corners = _Decorator.Corners
|
|
13
|
+
local Padding = _Decorator.Padding
|
|
14
|
+
local _HoverButton = TS.import(script, script.Parent.Parent, "Input", "HoverButton")
|
|
15
|
+
local HoverButton = _HoverButton.HoverButton
|
|
16
|
+
local HoverButtonContext = _HoverButton.HoverButtonContext
|
|
17
|
+
local Icon = TS.import(script, script.Parent.Parent, "Surface", "Icon").Icon
|
|
18
|
+
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
19
|
+
local Container = TS.import(script, script.Parent, "Container").Container
|
|
20
|
+
local HStack = TS.import(script, script.Parent, "HStack").HStack
|
|
21
|
+
local function computePaginationItems(page, totalPages, siblingCount)
|
|
22
|
+
local pageCount = math.max(0, math.floor(totalPages))
|
|
23
|
+
if pageCount == 0 then
|
|
24
|
+
return {}
|
|
25
|
+
end
|
|
26
|
+
local currentPage = math.clamp(math.floor(page), 1, pageCount)
|
|
27
|
+
local siblings = math.max(0, math.floor(siblingCount))
|
|
28
|
+
local visiblePageCount = siblings * 2 + 5
|
|
29
|
+
if pageCount <= visiblePageCount then
|
|
30
|
+
local allPages = {}
|
|
31
|
+
do
|
|
32
|
+
local value = 1
|
|
33
|
+
local _shouldIncrement = false
|
|
34
|
+
while true do
|
|
35
|
+
if _shouldIncrement then
|
|
36
|
+
value += 1
|
|
37
|
+
else
|
|
38
|
+
_shouldIncrement = true
|
|
39
|
+
end
|
|
40
|
+
if not (value <= pageCount) then
|
|
41
|
+
break
|
|
42
|
+
end
|
|
43
|
+
local _value = value
|
|
44
|
+
table.insert(allPages, _value)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
return allPages
|
|
48
|
+
end
|
|
49
|
+
local leftSiblingIndex = math.max(currentPage - siblings, 1)
|
|
50
|
+
local rightSiblingIndex = math.min(currentPage + siblings, pageCount)
|
|
51
|
+
local showLeftEllipsis = leftSiblingIndex > 2
|
|
52
|
+
local showRightEllipsis = rightSiblingIndex < pageCount - 1
|
|
53
|
+
if not showLeftEllipsis and showRightEllipsis then
|
|
54
|
+
-- Near the start: no left ellipsis needed, so extend the leading run of
|
|
55
|
+
-- numbers to keep the total item count constant.
|
|
56
|
+
local leftItemCount = siblings * 2 + 3
|
|
57
|
+
local items = {}
|
|
58
|
+
do
|
|
59
|
+
local value = 1
|
|
60
|
+
local _shouldIncrement = false
|
|
61
|
+
while true do
|
|
62
|
+
if _shouldIncrement then
|
|
63
|
+
value += 1
|
|
64
|
+
else
|
|
65
|
+
_shouldIncrement = true
|
|
66
|
+
end
|
|
67
|
+
if not (value <= leftItemCount) then
|
|
68
|
+
break
|
|
69
|
+
end
|
|
70
|
+
local _value = value
|
|
71
|
+
table.insert(items, _value)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
table.insert(items, "ellipsis")
|
|
75
|
+
table.insert(items, pageCount)
|
|
76
|
+
return items
|
|
77
|
+
end
|
|
78
|
+
if showLeftEllipsis and not showRightEllipsis then
|
|
79
|
+
-- Near the end: no right ellipsis needed, so extend the trailing run of
|
|
80
|
+
-- numbers to keep the total item count constant.
|
|
81
|
+
local rightItemCount = siblings * 2 + 3
|
|
82
|
+
local items = { 1, "ellipsis" }
|
|
83
|
+
do
|
|
84
|
+
local value = pageCount - rightItemCount + 1
|
|
85
|
+
local _shouldIncrement = false
|
|
86
|
+
while true do
|
|
87
|
+
if _shouldIncrement then
|
|
88
|
+
value += 1
|
|
89
|
+
else
|
|
90
|
+
_shouldIncrement = true
|
|
91
|
+
end
|
|
92
|
+
if not (value <= pageCount) then
|
|
93
|
+
break
|
|
94
|
+
end
|
|
95
|
+
local _value = value
|
|
96
|
+
table.insert(items, _value)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
return items
|
|
100
|
+
end
|
|
101
|
+
-- Both ellipses shown (the normal middle case) — unchanged from before.
|
|
102
|
+
local items = { 1, "ellipsis" }
|
|
103
|
+
do
|
|
104
|
+
local value = leftSiblingIndex
|
|
105
|
+
local _shouldIncrement = false
|
|
106
|
+
while true do
|
|
107
|
+
if _shouldIncrement then
|
|
108
|
+
value += 1
|
|
109
|
+
else
|
|
110
|
+
_shouldIncrement = true
|
|
111
|
+
end
|
|
112
|
+
if not (value <= rightSiblingIndex) then
|
|
113
|
+
break
|
|
114
|
+
end
|
|
115
|
+
local _value = value
|
|
116
|
+
table.insert(items, _value)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
table.insert(items, "ellipsis")
|
|
120
|
+
table.insert(items, pageCount)
|
|
121
|
+
return items
|
|
122
|
+
end
|
|
123
|
+
local PaginationContext = React.createContext(nil)
|
|
124
|
+
local function usePagination()
|
|
125
|
+
local context = React.useContext(PaginationContext)
|
|
126
|
+
if context == nil then
|
|
127
|
+
error("Pagination subparts must be rendered inside Pagination")
|
|
128
|
+
end
|
|
129
|
+
return context
|
|
130
|
+
end
|
|
131
|
+
local function PaginationItemVisual(props)
|
|
132
|
+
local theme = React.useContext(CleanThemeContext)
|
|
133
|
+
local hover = React.useContext(HoverButtonContext)
|
|
134
|
+
local _result
|
|
135
|
+
if props.disabled then
|
|
136
|
+
_result = "disabled"
|
|
137
|
+
else
|
|
138
|
+
local _result_1 = hover
|
|
139
|
+
if _result_1 ~= nil then
|
|
140
|
+
_result_1 = _result_1.isSelected
|
|
141
|
+
end
|
|
142
|
+
local _result_2
|
|
143
|
+
if _result_1 then
|
|
144
|
+
_result_2 = "focus"
|
|
145
|
+
else
|
|
146
|
+
local _result_3 = hover
|
|
147
|
+
if _result_3 ~= nil then
|
|
148
|
+
_result_3 = _result_3.hover
|
|
149
|
+
end
|
|
150
|
+
_result_2 = if _result_3 then "hover" else "default"
|
|
151
|
+
end
|
|
152
|
+
_result = _result_2
|
|
153
|
+
end
|
|
154
|
+
local colors = ColorHelper:getIntentColors(theme, "primary", _result, theme.components.pagination.item.intents)
|
|
155
|
+
local _exp = React.createElement(Corners, {
|
|
156
|
+
radius = theme.components.pagination.item.cornerRadius,
|
|
157
|
+
})
|
|
158
|
+
local _exp_1 = React.createElement(Padding, {
|
|
159
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, props, theme.components.pagination.item.spacing, theme.components.pagination.item.padding),
|
|
160
|
+
})
|
|
161
|
+
local _attributes = {}
|
|
162
|
+
local _condition = colors.boxShadow
|
|
163
|
+
if _condition == nil then
|
|
164
|
+
_condition = theme.components.pagination.item.boxShadow
|
|
165
|
+
end
|
|
166
|
+
_attributes.value = _condition
|
|
167
|
+
return React.createElement(React.Fragment, nil, _exp, _exp_1, React.createElement(BoxShadow, _attributes), if props.text ~= nil then (React.createElement(Text, {
|
|
168
|
+
name = "PaginationItemText",
|
|
169
|
+
text = props.text,
|
|
170
|
+
TextColor3 = colors.textColor,
|
|
171
|
+
typography = TypographyHelper:getTypography(theme, nil, colors.typography or theme.components.pagination.item.typography),
|
|
172
|
+
})) else (React.createElement(Container, {
|
|
173
|
+
name = "PaginationIconContainer",
|
|
174
|
+
}, React.createElement(Icon, {
|
|
175
|
+
name = "PaginationIcon",
|
|
176
|
+
icon = props.icon,
|
|
177
|
+
color = colors.textColor,
|
|
178
|
+
}))))
|
|
179
|
+
end
|
|
180
|
+
local function getButtonState(theme)
|
|
181
|
+
local itemTheme = theme.components.pagination.item
|
|
182
|
+
local defaultColors = ColorHelper:getIntentColors(theme, "primary", "default", itemTheme.intents)
|
|
183
|
+
local hoverColors = ColorHelper:getIntentColors(theme, "primary", "hover", itemTheme.intents)
|
|
184
|
+
local focusColors = ColorHelper:getIntentColors(theme, "primary", "focus", itemTheme.intents)
|
|
185
|
+
local disabledColors = ColorHelper:getIntentColors(theme, "primary", "disabled", itemTheme.intents)
|
|
186
|
+
return {
|
|
187
|
+
defaultColors = defaultColors,
|
|
188
|
+
hoverColors = hoverColors,
|
|
189
|
+
focusColors = focusColors,
|
|
190
|
+
disabledColors = disabledColors,
|
|
191
|
+
defaultImage = CssHelper:resolveBackgroundImage(defaultColors.backgroundImage),
|
|
192
|
+
hoverImage = CssHelper:resolveBackgroundImage(hoverColors.backgroundImage),
|
|
193
|
+
focusImage = CssHelper:resolveBackgroundImage(focusColors.backgroundImage),
|
|
194
|
+
}
|
|
195
|
+
end
|
|
196
|
+
local function PaginationButton(props)
|
|
197
|
+
local theme = React.useContext(CleanThemeContext)
|
|
198
|
+
local state = getButtonState(theme)
|
|
199
|
+
return React.createElement(HoverButton, {
|
|
200
|
+
name = props.name,
|
|
201
|
+
isSelected = props.selected,
|
|
202
|
+
default = {
|
|
203
|
+
Active = not props.disabled,
|
|
204
|
+
Selectable = not props.disabled,
|
|
205
|
+
LayoutOrder = props.layoutOrder,
|
|
206
|
+
Size = UDim2.fromScale(0, 0),
|
|
207
|
+
AutomaticSize = Enum.AutomaticSize.XY,
|
|
208
|
+
BackgroundColor3 = if props.disabled then state.disabledColors.backgroundColor else state.defaultColors.backgroundColor,
|
|
209
|
+
BackgroundTransparency = if props.disabled then state.disabledColors.backgroundTransparency else state.defaultColors.backgroundTransparency,
|
|
210
|
+
BorderSizePixel = theme.components.pagination.item.borderThickness,
|
|
211
|
+
BorderColor3 = if props.disabled then state.disabledColors.borderColor else state.defaultColors.borderColor,
|
|
212
|
+
AutoButtonColor = false,
|
|
213
|
+
Image = state.defaultImage.Image,
|
|
214
|
+
ImageColor3 = state.defaultImage.ImageColor3,
|
|
215
|
+
ImageTransparency = if props.disabled then 0.7 else state.defaultImage.ImageTransparency,
|
|
216
|
+
ScaleType = state.defaultImage.ScaleType,
|
|
217
|
+
SliceCenter = state.defaultImage.SliceCenter,
|
|
218
|
+
SliceScale = state.defaultImage.SliceScale,
|
|
219
|
+
TileSize = state.defaultImage.TileSize,
|
|
220
|
+
Event = {
|
|
221
|
+
Activated = function()
|
|
222
|
+
if not props.disabled then
|
|
223
|
+
props.onActivate()
|
|
224
|
+
end
|
|
225
|
+
end,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
hover = if props.disabled then nil else {
|
|
229
|
+
BackgroundColor3 = state.hoverColors.backgroundColor,
|
|
230
|
+
BackgroundTransparency = state.hoverColors.backgroundTransparency,
|
|
231
|
+
BorderColor3 = state.hoverColors.borderColor,
|
|
232
|
+
Image = state.hoverImage.Image,
|
|
233
|
+
ImageColor3 = state.hoverImage.ImageColor3,
|
|
234
|
+
ImageTransparency = state.hoverImage.ImageTransparency,
|
|
235
|
+
ScaleType = state.hoverImage.ScaleType,
|
|
236
|
+
SliceCenter = state.hoverImage.SliceCenter,
|
|
237
|
+
SliceScale = state.hoverImage.SliceScale,
|
|
238
|
+
TileSize = state.hoverImage.TileSize,
|
|
239
|
+
},
|
|
240
|
+
focus = {
|
|
241
|
+
BackgroundColor3 = state.focusColors.backgroundColor,
|
|
242
|
+
BackgroundTransparency = state.focusColors.backgroundTransparency,
|
|
243
|
+
BorderColor3 = state.focusColors.borderColor,
|
|
244
|
+
Image = state.focusImage.Image,
|
|
245
|
+
ImageColor3 = state.focusImage.ImageColor3,
|
|
246
|
+
ImageTransparency = state.focusImage.ImageTransparency,
|
|
247
|
+
ScaleType = state.focusImage.ScaleType,
|
|
248
|
+
SliceCenter = state.focusImage.SliceCenter,
|
|
249
|
+
SliceScale = state.focusImage.SliceScale,
|
|
250
|
+
TileSize = state.focusImage.TileSize,
|
|
251
|
+
},
|
|
252
|
+
}, props.children)
|
|
253
|
+
end
|
|
254
|
+
local function PaginationItem(props)
|
|
255
|
+
local _binding = usePagination()
|
|
256
|
+
local page = _binding.page
|
|
257
|
+
local setPage = _binding.setPage
|
|
258
|
+
local _attributes = table.clone(props)
|
|
259
|
+
setmetatable(_attributes, nil)
|
|
260
|
+
_attributes.text = `{props.value}`
|
|
261
|
+
return React.createElement(PaginationButton, {
|
|
262
|
+
name = `PaginationItem-{props.value}`,
|
|
263
|
+
selected = page == props.value,
|
|
264
|
+
layoutOrder = props.layoutOrder,
|
|
265
|
+
onActivate = function()
|
|
266
|
+
return setPage(props.value)
|
|
267
|
+
end,
|
|
268
|
+
}, React.createElement(PaginationItemVisual, _attributes))
|
|
269
|
+
end
|
|
270
|
+
local function PaginationPrev()
|
|
271
|
+
local _binding = usePagination()
|
|
272
|
+
local page = _binding.page
|
|
273
|
+
local setPage = _binding.setPage
|
|
274
|
+
local canGoPrev = _binding.canGoPrev
|
|
275
|
+
return React.createElement(PaginationButton, {
|
|
276
|
+
name = "PaginationPrev",
|
|
277
|
+
disabled = not canGoPrev,
|
|
278
|
+
onActivate = function()
|
|
279
|
+
return setPage(page - 1)
|
|
280
|
+
end,
|
|
281
|
+
}, React.createElement(PaginationItemVisual, {
|
|
282
|
+
icon = "chevron-left",
|
|
283
|
+
disabled = not canGoPrev,
|
|
284
|
+
}))
|
|
285
|
+
end
|
|
286
|
+
local function PaginationNext()
|
|
287
|
+
local _binding = usePagination()
|
|
288
|
+
local page = _binding.page
|
|
289
|
+
local setPage = _binding.setPage
|
|
290
|
+
local canGoNext = _binding.canGoNext
|
|
291
|
+
return React.createElement(PaginationButton, {
|
|
292
|
+
name = "PaginationNext",
|
|
293
|
+
disabled = not canGoNext,
|
|
294
|
+
onActivate = function()
|
|
295
|
+
return setPage(page + 1)
|
|
296
|
+
end,
|
|
297
|
+
}, React.createElement(PaginationItemVisual, {
|
|
298
|
+
icon = "chevron-right",
|
|
299
|
+
disabled = not canGoNext,
|
|
300
|
+
}))
|
|
301
|
+
end
|
|
302
|
+
local function PaginationEllipsis(props)
|
|
303
|
+
local theme = React.useContext(CleanThemeContext)
|
|
304
|
+
return React.createElement(Text, {
|
|
305
|
+
name = "PaginationEllipsis",
|
|
306
|
+
text = "…",
|
|
307
|
+
LayoutOrder = props.layoutOrder,
|
|
308
|
+
typography = TypographyHelper:getTypography(theme, nil, theme.components.pagination.item.typography),
|
|
309
|
+
})
|
|
310
|
+
end
|
|
311
|
+
local function PaginationList(props)
|
|
312
|
+
local _binding = usePagination()
|
|
313
|
+
local items = _binding.items
|
|
314
|
+
local _condition = props.children
|
|
315
|
+
if _condition == nil then
|
|
316
|
+
-- ▼ ReadonlyArray.map ▼
|
|
317
|
+
local _newValue = table.create(#items)
|
|
318
|
+
local _callback = function(item, index)
|
|
319
|
+
return if item == "ellipsis" then (React.createElement(PaginationEllipsis, {
|
|
320
|
+
key = `ellipsis-{index}`,
|
|
321
|
+
layoutOrder = index,
|
|
322
|
+
})) else (React.createElement(PaginationItem, {
|
|
323
|
+
key = item,
|
|
324
|
+
value = item,
|
|
325
|
+
layoutOrder = index,
|
|
326
|
+
}))
|
|
327
|
+
end
|
|
328
|
+
for _k, _v in items do
|
|
329
|
+
_newValue[_k] = _callback(_v, _k - 1, items)
|
|
330
|
+
end
|
|
331
|
+
-- ▲ ReadonlyArray.map ▲
|
|
332
|
+
_condition = _newValue
|
|
333
|
+
end
|
|
334
|
+
return React.createElement(Container, {
|
|
335
|
+
name = "PaginationList",
|
|
336
|
+
}, React.createElement(HStack, {
|
|
337
|
+
Wraps = false,
|
|
338
|
+
valign = "Center",
|
|
339
|
+
}, _condition))
|
|
340
|
+
end
|
|
341
|
+
local function PaginationDefaultLayout()
|
|
342
|
+
local theme = React.useContext(CleanThemeContext)
|
|
343
|
+
local paginationTheme = theme.components.pagination
|
|
344
|
+
return React.createElement(HStack, {
|
|
345
|
+
Wraps = false,
|
|
346
|
+
valign = "Center",
|
|
347
|
+
spacing = "None",
|
|
348
|
+
Padding = UDim.new(0, SpacingHelper:GetPadding(theme, nil, paginationTheme.spacing)),
|
|
349
|
+
}, React.createElement(PaginationPrev), React.createElement(PaginationList), React.createElement(PaginationNext))
|
|
350
|
+
end
|
|
351
|
+
local Pagination = React.forwardRef(function(props, _ref)
|
|
352
|
+
local theme = React.useContext(CleanThemeContext)
|
|
353
|
+
local pageCount = math.max(0, math.floor(props.totalPages))
|
|
354
|
+
local currentPage = if pageCount == 0 then 0 else math.clamp(math.floor(props.page), 1, pageCount)
|
|
355
|
+
local _condition = props.siblingCount
|
|
356
|
+
if _condition == nil then
|
|
357
|
+
_condition = 1
|
|
358
|
+
end
|
|
359
|
+
local siblingCount = math.max(0, math.floor(_condition))
|
|
360
|
+
local items = React.useMemo(function()
|
|
361
|
+
return computePaginationItems(currentPage, pageCount, siblingCount)
|
|
362
|
+
end, { currentPage, pageCount, siblingCount })
|
|
363
|
+
local setPage = function(page)
|
|
364
|
+
if pageCount == 0 then
|
|
365
|
+
return nil
|
|
366
|
+
end
|
|
367
|
+
props.onPageChange(math.clamp(math.floor(page), 1, pageCount))
|
|
368
|
+
end
|
|
369
|
+
local contextValue = React.useMemo(function()
|
|
370
|
+
return {
|
|
371
|
+
page = currentPage,
|
|
372
|
+
totalPages = pageCount,
|
|
373
|
+
items = items,
|
|
374
|
+
setPage = setPage,
|
|
375
|
+
canGoPrev = currentPage > 1,
|
|
376
|
+
canGoNext = currentPage < pageCount,
|
|
377
|
+
}
|
|
378
|
+
end, { currentPage, pageCount, items, props.onPageChange })
|
|
379
|
+
local paginationTheme = theme.components.pagination
|
|
380
|
+
return React.createElement(PaginationContext.Provider, {
|
|
381
|
+
value = contextValue,
|
|
382
|
+
}, React.createElement(Container, {
|
|
383
|
+
name = "Pagination",
|
|
384
|
+
BackgroundColor3 = paginationTheme.backgroundColor,
|
|
385
|
+
BackgroundTransparency = paginationTheme.backgroundTransparency,
|
|
386
|
+
BorderSizePixel = 0,
|
|
387
|
+
}, React.createElement("uistroke", {
|
|
388
|
+
key = "PaginationBorder",
|
|
389
|
+
Thickness = paginationTheme.borderThickness,
|
|
390
|
+
BorderStrokePosition = Enum.BorderStrokePosition.Inner,
|
|
391
|
+
Color = paginationTheme.borderColor,
|
|
392
|
+
}), React.createElement(Corners, {
|
|
393
|
+
radius = paginationTheme.cornerRadius,
|
|
394
|
+
}), React.createElement(Padding, {
|
|
395
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, paginationTheme.spacing, paginationTheme.padding),
|
|
396
|
+
}), if props.children ~= nil then props.children else React.createElement(PaginationDefaultLayout)))
|
|
397
|
+
end)
|
|
398
|
+
Pagination.Prev = PaginationPrev
|
|
399
|
+
Pagination.Next = PaginationNext
|
|
400
|
+
Pagination.Item = PaginationItem
|
|
401
|
+
Pagination.Ellipsis = PaginationEllipsis
|
|
402
|
+
Pagination.List = PaginationList
|
|
403
|
+
return {
|
|
404
|
+
Pagination = Pagination,
|
|
405
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import { BreakPointElementProps, SpacedElementProps } from "../../Interfaces/";
|
|
3
3
|
interface RowProps extends SpacedElementProps, BreakPointElementProps {
|
|
4
|
+
name?: string;
|
|
4
5
|
}
|
|
5
6
|
export declare const Row: React.ForwardRefExoticComponent<RowProps & React.RefAttributes<Frame>>;
|
|
6
7
|
export {};
|
|
@@ -13,55 +13,32 @@ local Row = React.forwardRef(function(props, ref)
|
|
|
13
13
|
local width, setWidth = React.useState(0)
|
|
14
14
|
local breakpoints = props.breakpoints or theme.breakpoints
|
|
15
15
|
local padding = UDim.new(0, SpacingHelper:GetPadding(theme, props.spacing))
|
|
16
|
-
local
|
|
17
|
-
local
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if type(_ref) == "function" then
|
|
21
|
-
ref(instance)
|
|
22
|
-
else
|
|
23
|
-
local _condition = ref ~= nil
|
|
24
|
-
if _condition then
|
|
25
|
-
local _ref_1 = ref
|
|
26
|
-
_condition = type(_ref_1) == "table"
|
|
27
|
-
end
|
|
28
|
-
if _condition then
|
|
29
|
-
ref.current = instance
|
|
30
|
-
end
|
|
31
|
-
end
|
|
16
|
+
local _attributes = {}
|
|
17
|
+
local _condition = props.name
|
|
18
|
+
if _condition == nil then
|
|
19
|
+
_condition = "Row"
|
|
32
20
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
pcall(function()
|
|
44
|
-
conn = frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
|
|
45
|
-
local nextWidth = frame.AbsoluteSize.X
|
|
46
|
-
setWidth(function(currentWidth)
|
|
47
|
-
return if currentWidth == nextWidth then currentWidth else nextWidth
|
|
48
|
-
end)
|
|
21
|
+
_attributes.key = _condition
|
|
22
|
+
_attributes.ref = ref
|
|
23
|
+
_attributes.Size = UDim2.fromScale(1, 1)
|
|
24
|
+
_attributes.AutomaticSize = Enum.AutomaticSize.Y
|
|
25
|
+
_attributes.BackgroundTransparency = 1
|
|
26
|
+
_attributes.Change = {
|
|
27
|
+
AbsoluteSize = function(instance)
|
|
28
|
+
local nextWidth = instance.AbsoluteSize.X
|
|
29
|
+
setWidth(function(currentWidth)
|
|
30
|
+
return if currentWidth == nextWidth then currentWidth else nextWidth
|
|
49
31
|
end)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
local _result = conn
|
|
53
|
-
if _result ~= nil then
|
|
54
|
-
_result:Disconnect()
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end, {})
|
|
32
|
+
end,
|
|
33
|
+
}
|
|
58
34
|
local _exp = React.createElement("uilistlayout", {
|
|
35
|
+
key = "RowLayout",
|
|
59
36
|
FillDirection = Enum.FillDirection.Horizontal,
|
|
60
37
|
SortOrder = Enum.SortOrder.LayoutOrder,
|
|
61
38
|
Padding = padding,
|
|
62
39
|
Wraps = true,
|
|
63
40
|
})
|
|
64
|
-
local
|
|
41
|
+
local _attributes_1 = {}
|
|
65
42
|
local _object = {
|
|
66
43
|
width = width,
|
|
67
44
|
}
|
|
@@ -83,13 +60,8 @@ local Row = React.forwardRef(function(props, ref)
|
|
|
83
60
|
_object[_left] = #_newValue
|
|
84
61
|
_object.padding = padding
|
|
85
62
|
_object.breakpoint = BreakpointHelper:getBreakpoint(width, breakpoints)
|
|
86
|
-
|
|
87
|
-
return React.createElement("frame",
|
|
88
|
-
ref = setRowRef,
|
|
89
|
-
Size = UDim2.fromScale(1, 1),
|
|
90
|
-
AutomaticSize = Enum.AutomaticSize.Y,
|
|
91
|
-
BackgroundTransparency = 1,
|
|
92
|
-
}, _exp, React.createElement(RowContext.Provider, _attributes, props.children))
|
|
63
|
+
_attributes_1.value = _object
|
|
64
|
+
return React.createElement("frame", _attributes, _exp, React.createElement(RowContext.Provider, _attributes_1, props.children))
|
|
93
65
|
end)
|
|
94
66
|
return {
|
|
95
67
|
Row = Row,
|
|
@@ -3,6 +3,7 @@ import { PositionElementProps, SizeElementProps, SpacedElementProps } from "../.
|
|
|
3
3
|
interface ScrollerProps extends SizeElementProps, SpacedElementProps, PositionElementProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
5
|
AutomaticSizeParent?: boolean;
|
|
6
|
+
name?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function Scroller(props: ScrollerProps): React.JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -19,46 +19,38 @@ local function Scroller(props)
|
|
|
19
19
|
setIsScrolling(frame.AbsoluteCanvasSize.Y > frame.AbsoluteWindowSize.Y)
|
|
20
20
|
end
|
|
21
21
|
updateScrolling()
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-- guard the subscription instead of throwing and losing overflow tracking.
|
|
25
|
-
local canvasConn
|
|
26
|
-
local windowConn
|
|
27
|
-
pcall(function()
|
|
28
|
-
canvasConn = frame:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(updateScrolling)
|
|
29
|
-
end)
|
|
30
|
-
pcall(function()
|
|
31
|
-
windowConn = frame:GetPropertyChangedSignal("AbsoluteWindowSize"):Connect(updateScrolling)
|
|
32
|
-
end)
|
|
22
|
+
local canvasConn = frame:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(updateScrolling)
|
|
23
|
+
local windowConn = frame:GetPropertyChangedSignal("AbsoluteWindowSize"):Connect(updateScrolling)
|
|
33
24
|
return function()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_result:Disconnect()
|
|
37
|
-
end
|
|
38
|
-
local _result_1 = windowConn
|
|
39
|
-
if _result_1 ~= nil then
|
|
40
|
-
_result_1:Disconnect()
|
|
41
|
-
end
|
|
25
|
+
canvasConn:Disconnect()
|
|
26
|
+
windowConn:Disconnect()
|
|
42
27
|
end
|
|
43
28
|
end, {})
|
|
44
29
|
local spacing = SpacingHelper:GetPadding(theme, props.spacing)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
30
|
+
local _attributes = {}
|
|
31
|
+
local _condition = props.name
|
|
32
|
+
if _condition == nil then
|
|
33
|
+
_condition = "Scroller"
|
|
34
|
+
end
|
|
35
|
+
_attributes.key = _condition
|
|
36
|
+
_attributes.ref = ref
|
|
37
|
+
_attributes.AnchorPoint = SizeHelper:GetAnchor(props)
|
|
38
|
+
_attributes.AutomaticSize = SizeHelper:GetAutoSize(props, Enum.AutomaticSize.None)
|
|
39
|
+
_attributes.Position = SizeHelper:GetPosition(props)
|
|
40
|
+
_attributes.Size = SizeHelper:GetSize(props, UDim2.fromScale(1, 1))
|
|
41
|
+
_attributes.BorderSizePixel = 0
|
|
42
|
+
_attributes.ScrollingDirection = Enum.ScrollingDirection.Y
|
|
43
|
+
_attributes.ScrollBarImageColor3 = theme.components.scroller.barColor
|
|
44
|
+
_attributes.CanvasSize = UDim2.fromScale(1, 0)
|
|
45
|
+
_attributes.BackgroundTransparency = 1
|
|
46
|
+
_attributes.ScrollBarThickness = thickness
|
|
47
|
+
_attributes.VerticalScrollBarInset = Enum.ScrollBarInset.ScrollBar
|
|
48
|
+
_attributes.AutomaticCanvasSize = Enum.AutomaticSize.Y
|
|
49
|
+
return React.createElement("scrollingframe", _attributes, props.AutomaticSizeParent and React.createElement("uilistlayout", {
|
|
50
|
+
key = "AutomaticSizeLayout",
|
|
60
51
|
FillDirection = Enum.FillDirection.Horizontal,
|
|
61
52
|
}), React.createElement("frame", {
|
|
53
|
+
key = "ScrollerContent",
|
|
62
54
|
Size = UDim2.new(1, if isScrolling then -thickness - spacing else 0, 0, 0),
|
|
63
55
|
AutomaticSize = Enum.AutomaticSize.Y,
|
|
64
56
|
BackgroundTransparency = 1,
|