@rbxts/react-clean-ui 1.0.36 → 1.1.0
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/Decorator/Corners.luau +5 -1
- package/out/Components/Decorator/Padding.luau +1 -1
- package/out/Components/Input/Button.d.ts +9 -0
- package/out/Components/Input/Button.luau +155 -46
- package/out/Components/Input/Checkbox.luau +22 -6
- package/out/Components/Input/Increment.d.ts +11 -0
- package/out/Components/Input/Increment.luau +107 -0
- package/out/Components/Input/Increment.step.d.ts +1 -0
- package/out/Components/Input/Increment.step.luau +25 -0
- package/out/Components/Input/Input.d.ts +4 -3
- package/out/Components/Input/Input.luau +115 -18
- package/out/Components/Input/Input.validation.d.ts +4 -0
- package/out/Components/Input/Input.validation.luau +42 -0
- package/out/Components/Input/Select.d.ts +4 -3
- package/out/Components/Input/Select.luau +23 -18
- package/out/Components/Input/Slider.d.ts +1 -1
- package/out/Components/Input/Slider.luau +68 -34
- package/out/Components/Input/index.d.ts +1 -0
- package/out/Components/Input/init.luau +3 -0
- package/out/Components/Layout/Accordion.d.ts +4 -4
- package/out/Components/Layout/Accordion.luau +75 -23
- package/out/Components/Layout/Container.d.ts +4 -2
- package/out/Components/Layout/Container.luau +12 -3
- package/out/Components/Layout/Draggable.luau +1 -1
- package/out/Components/Layout/Fieldset.d.ts +1 -1
- package/out/Components/Layout/Fieldset.luau +40 -6
- package/out/Components/Layout/FlexItem.d.ts +2 -1
- package/out/Components/Layout/FlexItem.luau +1 -0
- package/out/Components/Layout/Group.luau +30 -8
- package/out/Components/Layout/HStack.luau +1 -0
- package/out/Components/Layout/Row.luau +43 -9
- package/out/Components/Layout/Scroller.d.ts +1 -0
- package/out/Components/Layout/Scroller.luau +20 -5
- package/out/Components/Layout/Tabs.d.ts +5 -3
- package/out/Components/Layout/Tabs.luau +48 -16
- package/out/Components/Navigation/Menu.d.ts +1 -1
- package/out/Components/Navigation/Menu.luau +2 -0
- package/out/Components/Surface/Box.d.ts +4 -2
- package/out/Components/Surface/Box.luau +25 -22
- package/out/Components/Surface/Card.d.ts +12 -6
- package/out/Components/Surface/Card.luau +456 -26
- package/out/Components/Surface/Icon.luau +42 -4
- package/out/Components/Typography/Text.d.ts +1 -0
- package/out/Components/Typography/Text.luau +119 -10
- package/out/Contexts/row.context.d.ts +1 -1
- package/out/Contexts/theme.context.d.ts +2 -2
- package/out/Helpers/color.helper.d.ts +5 -3
- package/out/Helpers/color.helper.luau +62 -34
- package/out/Helpers/create-ui-story.d.ts +2 -2
- package/out/Helpers/create-ui-story.luau +33 -1
- package/out/Helpers/css.helper.d.ts +28 -2
- package/out/Helpers/css.helper.luau +208 -0
- package/out/Helpers/index.d.ts +1 -0
- package/out/Helpers/init.luau +3 -0
- package/out/Helpers/size.helper.d.ts +3 -1
- package/out/Helpers/size.helper.luau +10 -9
- package/out/Helpers/spacing.helper.d.ts +5 -4
- package/out/Helpers/spacing.helper.luau +102 -18
- package/out/Helpers/typography.helper.d.ts +2 -2
- package/out/Interfaces/css.types.d.ts +30 -0
- package/out/Interfaces/css.types.luau +21 -0
- package/out/Interfaces/element.props.d.ts +61 -0
- package/out/Interfaces/element.props.luau +1 -0
- package/out/Interfaces/index.d.ts +5 -3
- package/out/Interfaces/init.luau +1 -7
- package/out/Interfaces/responsive.types.d.ts +26 -0
- package/out/Interfaces/semantics.d.ts +3 -0
- package/out/Interfaces/semantics.luau +2 -0
- package/out/Providers/app.provider.d.ts +2 -2
- package/out/Providers/theme.provider.d.ts +2 -2
- package/out/Theme/index.d.ts +1 -0
- package/out/Theme/theme.factory.d.ts +3 -3
- package/out/Theme/theme.style.d.ts +48 -0
- package/out/Theme/theme.style.luau +1 -0
- package/out/Theme/theme.template.d.ts +34 -26
- package/out/Theme/themes/dark.theme.d.ts +1 -1
- package/out/Theme/themes/dark.theme.luau +28 -0
- package/out/Theme/themes/default.theme.d.ts +2 -2
- package/out/Theme/themes/default.theme.luau +11 -1
- package/out/Theme/themes/index.d.ts +1 -0
- package/out/Theme/themes/init.luau +3 -0
- package/out/Theme/themes/sandstone.theme.d.ts +1 -1
- package/out/Theme/themes/sandstone.theme.luau +25 -0
- package/out/Theme/themes/wooden.theme.d.ts +1 -0
- package/out/Theme/themes/wooden.theme.luau +554 -0
- package/out/index.d.ts +8 -8
- package/package.json +19 -7
- package/out/Interfaces/clean.element.props.d.ts +0 -114
- /package/out/{Interfaces/userinput.d.ts → Helpers/input.helper.d.ts} +0 -0
- /package/out/{Interfaces/userinput.luau → Helpers/input.helper.luau} +0 -0
- /package/out/Interfaces/{clean.element.props.luau → responsive.types.luau} +0 -0
|
@@ -6,8 +6,12 @@ local function Corners(props)
|
|
|
6
6
|
if props.radius == nil then
|
|
7
7
|
return nil
|
|
8
8
|
end
|
|
9
|
+
local radius = SizeHelper:toUDim(props.radius)
|
|
10
|
+
if radius.Scale == 0 and radius.Offset == 0 then
|
|
11
|
+
return nil
|
|
12
|
+
end
|
|
9
13
|
return React.createElement("uicorner", {
|
|
10
|
-
CornerRadius =
|
|
14
|
+
CornerRadius = radius,
|
|
11
15
|
})
|
|
12
16
|
end
|
|
13
17
|
return {
|
|
@@ -5,7 +5,7 @@ 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 Padding(props)
|
|
7
7
|
local theme = React.useContext(CleanThemeContext)
|
|
8
|
-
local padding =
|
|
8
|
+
local padding = SpacingHelper:GetResolvedPadding(theme, props)
|
|
9
9
|
return React.createElement("uipadding", {
|
|
10
10
|
PaddingTop = UDim.new(0, padding.top),
|
|
11
11
|
PaddingBottom = UDim.new(0, padding.bottom),
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import { BackgroundElementProps, IconElementProps, IntentElementProps, ScalableElementProps, ShadowElementProps, SpacedElementProps, ZIndexElementProps } from "../../Interfaces/";
|
|
3
3
|
import { IconProps } from "../Surface";
|
|
4
|
+
import { ThemeTemplate } from "../../Theme/theme.template";
|
|
5
|
+
export type ButtonStyleOverride = Partial<ThemeTemplate["components"]["button"]>;
|
|
4
6
|
export interface ButtonProps extends SpacedElementProps, ShadowElementProps, ZIndexElementProps, BackgroundElementProps, IntentElementProps, ScalableElementProps, IconElementProps {
|
|
5
7
|
text?: string;
|
|
6
8
|
fontWeight?: Enum.FontWeight;
|
|
7
9
|
Event?: React.InstanceEvent<ImageButton>;
|
|
8
10
|
children?: React.ReactNode;
|
|
9
11
|
group?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
LayoutOrder?: number;
|
|
14
|
+
styleOverride?: ButtonStyleOverride;
|
|
10
15
|
}
|
|
11
16
|
export interface ButtonTextProps extends ScalableElementProps, IntentElementProps {
|
|
12
17
|
children?: string;
|
|
13
18
|
text: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
styleOverride?: ButtonStyleOverride;
|
|
14
21
|
}
|
|
15
22
|
declare function ButtonText(props: ButtonTextProps): React.JSX.Element;
|
|
16
23
|
export interface ButtonIconProps extends IconProps, IntentElementProps {
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
styleOverride?: ButtonStyleOverride;
|
|
17
26
|
}
|
|
18
27
|
declare function ButtonIcon(props: ButtonIconProps): React.JSX.Element;
|
|
19
28
|
type ButtonComponent = React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<ImageButton>> & {
|
|
@@ -9,6 +9,7 @@ local Padding = _Decorator.Padding
|
|
|
9
9
|
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
10
10
|
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
11
11
|
local ColorHelper = _Helpers.ColorHelper
|
|
12
|
+
local CssHelper = _Helpers.CssHelper
|
|
12
13
|
local SpacingHelper = _Helpers.SpacingHelper
|
|
13
14
|
local TypographyHelper = _Helpers.TypographyHelper
|
|
14
15
|
local Icon = TS.import(script, script.Parent.Parent, "Surface").Icon
|
|
@@ -18,29 +19,77 @@ local Group = _.Group
|
|
|
18
19
|
local GroupContext = _.GroupContext
|
|
19
20
|
local function ButtonText(props)
|
|
20
21
|
local theme = React.useContext(CleanThemeContext)
|
|
21
|
-
|
|
22
|
+
local _attributes = {
|
|
22
23
|
text = props.text,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
}
|
|
25
|
+
local _exp = props.scale
|
|
26
|
+
local _object = {}
|
|
27
|
+
local _spread = theme.components.button.typography
|
|
28
|
+
if _spread then
|
|
29
|
+
for _k, _v in _spread do
|
|
30
|
+
_object[_k] = _v
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
local _result = props.styleOverride
|
|
34
|
+
if _result ~= nil then
|
|
35
|
+
_result = _result.typography
|
|
36
|
+
end
|
|
37
|
+
if _result then
|
|
38
|
+
for _k, _v in _result do
|
|
39
|
+
_object[_k] = _v
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
_attributes.typography = TypographyHelper:getTypography(theme, _exp, _object)
|
|
43
|
+
local _exp_1 = props.intent
|
|
44
|
+
local _exp_2 = if props.disabled then "disabled" else "default"
|
|
45
|
+
local _exp_3 = theme.components.button.intents
|
|
46
|
+
local _result_1 = props.styleOverride
|
|
47
|
+
if _result_1 ~= nil then
|
|
48
|
+
_result_1 = _result_1.intents
|
|
49
|
+
end
|
|
50
|
+
_attributes.TextColor3 = ColorHelper:getIntentColors(theme, _exp_1, _exp_2, _exp_3, _result_1).textColor
|
|
51
|
+
return React.createElement(Text, _attributes)
|
|
26
52
|
end
|
|
27
53
|
local function ButtonIcon(props)
|
|
28
54
|
local theme = React.useContext(CleanThemeContext)
|
|
29
|
-
|
|
55
|
+
local _attributes = {
|
|
30
56
|
scale = props.scale,
|
|
31
57
|
icon = props.icon,
|
|
32
58
|
spinning = props.spinning,
|
|
33
59
|
speed = props.speed,
|
|
34
|
-
|
|
35
|
-
|
|
60
|
+
}
|
|
61
|
+
local _exp = props.intent
|
|
62
|
+
local _exp_1 = if props.disabled then "disabled" else "default"
|
|
63
|
+
local _exp_2 = theme.components.button.intents
|
|
64
|
+
local _result = props.styleOverride
|
|
65
|
+
if _result ~= nil then
|
|
66
|
+
_result = _result.intents
|
|
67
|
+
end
|
|
68
|
+
_attributes.color = ColorHelper:getIntentColors(theme, _exp, _exp_1, _exp_2, _result).textColor
|
|
69
|
+
return React.createElement(Icon, _attributes)
|
|
36
70
|
end
|
|
37
71
|
local Button = React.forwardRef(function(props, ref)
|
|
38
72
|
local theme = React.useContext(CleanThemeContext)
|
|
39
73
|
local hover, setHover = React.useState(false)
|
|
74
|
+
React.useEffect(function()
|
|
75
|
+
if props.disabled then
|
|
76
|
+
setHover(false)
|
|
77
|
+
end
|
|
78
|
+
end, { props.disabled })
|
|
40
79
|
local group = React.useContext(GroupContext)
|
|
41
80
|
local padding = SpacingHelper:GetResolvedPadding(theme, props)
|
|
81
|
+
local state = if props.disabled then "disabled" elseif hover then "hover" else "default"
|
|
82
|
+
local _exp = props.intent
|
|
83
|
+
local _exp_1 = theme.components.button.intents
|
|
84
|
+
local _result = props.styleOverride
|
|
85
|
+
if _result ~= nil then
|
|
86
|
+
_result = _result.intents
|
|
87
|
+
end
|
|
88
|
+
local intentColors = ColorHelper:getIntentColors(theme, _exp, state, _exp_1, _result)
|
|
89
|
+
local backgroundImage = CssHelper:resolveBackgroundImage(intentColors.backgroundImage)
|
|
42
90
|
local _attributes = {
|
|
43
91
|
ref = ref,
|
|
92
|
+
Active = not props.disabled,
|
|
44
93
|
}
|
|
45
94
|
local _object = {}
|
|
46
95
|
local _spread = props.Event
|
|
@@ -50,81 +99,141 @@ local Button = React.forwardRef(function(props, ref)
|
|
|
50
99
|
end
|
|
51
100
|
end
|
|
52
101
|
_object.MouseEnter = function(button, x, y)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
102
|
+
if not props.disabled then
|
|
103
|
+
setHover(true)
|
|
104
|
+
end
|
|
105
|
+
local _result_1 = props.Event
|
|
106
|
+
if _result_1 ~= nil then
|
|
107
|
+
_result_1 = _result_1.MouseEnter
|
|
108
|
+
if _result_1 ~= nil then
|
|
109
|
+
_result_1(button, x, y)
|
|
59
110
|
end
|
|
60
111
|
end
|
|
61
112
|
end
|
|
62
113
|
_object.MouseLeave = function(button, x, y)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
114
|
+
if not props.disabled then
|
|
115
|
+
setHover(false)
|
|
116
|
+
end
|
|
117
|
+
local _result_1 = props.Event
|
|
118
|
+
if _result_1 ~= nil then
|
|
119
|
+
_result_1 = _result_1.MouseLeave
|
|
120
|
+
if _result_1 ~= nil then
|
|
121
|
+
_result_1(button, x, y)
|
|
69
122
|
end
|
|
70
123
|
end
|
|
71
124
|
end
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
_object.Activated = function(button, inputObject, clickCount)
|
|
126
|
+
if props.disabled then
|
|
127
|
+
return nil
|
|
128
|
+
end
|
|
129
|
+
local _result_1 = props.Event
|
|
76
130
|
if _result_1 ~= nil then
|
|
77
|
-
_result_1 = _result_1.
|
|
131
|
+
_result_1 = _result_1.Activated
|
|
78
132
|
if _result_1 ~= nil then
|
|
79
|
-
_result_1
|
|
133
|
+
_result_1(button, inputObject, clickCount)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
_attributes.Event = _object
|
|
138
|
+
local _result_1
|
|
139
|
+
if props.group then
|
|
140
|
+
local _result_2 = group
|
|
141
|
+
if _result_2 ~= nil then
|
|
142
|
+
_result_2 = _result_2.size
|
|
143
|
+
if _result_2 ~= nil then
|
|
144
|
+
_result_2 = _result_2.X
|
|
80
145
|
end
|
|
81
146
|
end
|
|
82
|
-
local _condition =
|
|
147
|
+
local _condition = _result_2
|
|
83
148
|
if _condition == nil then
|
|
84
149
|
_condition = 0
|
|
85
150
|
end
|
|
86
|
-
|
|
151
|
+
_result_1 = _condition
|
|
87
152
|
else
|
|
88
|
-
|
|
153
|
+
_result_1 = 0
|
|
89
154
|
end
|
|
90
|
-
_attributes.Size = UDim2.fromOffset(
|
|
155
|
+
_attributes.Size = UDim2.fromOffset(_result_1, 0)
|
|
91
156
|
_attributes.AutomaticSize = Enum.AutomaticSize.XY
|
|
92
157
|
local _condition = props.BackgroundTransparency
|
|
93
158
|
if _condition == nil then
|
|
94
|
-
|
|
159
|
+
local _result_2 = props.styleOverride
|
|
160
|
+
if _result_2 ~= nil then
|
|
161
|
+
_result_2 = _result_2.backgroundTransparency
|
|
162
|
+
end
|
|
163
|
+
_condition = _result_2
|
|
164
|
+
if _condition == nil then
|
|
165
|
+
_condition = theme.components.button.backgroundTransparency
|
|
166
|
+
end
|
|
95
167
|
end
|
|
96
168
|
_attributes.BackgroundTransparency = _condition
|
|
97
|
-
_attributes.BackgroundColor3 =
|
|
169
|
+
_attributes.BackgroundColor3 = intentColors.backgroundColor
|
|
98
170
|
_attributes.AutoButtonColor = false
|
|
171
|
+
_attributes.LayoutOrder = props.LayoutOrder
|
|
99
172
|
_attributes.ZIndex = props.ZIndex
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
local
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
local
|
|
113
|
-
|
|
114
|
-
|
|
173
|
+
_attributes.Image = backgroundImage.Image
|
|
174
|
+
_attributes.ImageColor3 = backgroundImage.ImageColor3
|
|
175
|
+
_attributes.ImageTransparency = backgroundImage.ImageTransparency
|
|
176
|
+
_attributes.ScaleType = backgroundImage.ScaleType
|
|
177
|
+
_attributes.SliceCenter = backgroundImage.SliceCenter
|
|
178
|
+
_attributes.SliceScale = backgroundImage.SliceScale
|
|
179
|
+
_attributes.TileSize = backgroundImage.TileSize
|
|
180
|
+
local _attributes_1 = {}
|
|
181
|
+
local _result_2 = props.styleOverride
|
|
182
|
+
if _result_2 ~= nil then
|
|
183
|
+
_result_2 = _result_2.cornerRadius
|
|
184
|
+
end
|
|
185
|
+
local _condition_1 = _result_2
|
|
186
|
+
if _condition_1 == nil then
|
|
187
|
+
_condition_1 = theme.components.button.cornerRadius
|
|
188
|
+
end
|
|
189
|
+
_attributes_1.radius = _condition_1
|
|
190
|
+
local _exp_2 = React.createElement(Corners, _attributes_1)
|
|
191
|
+
local _attributes_2 = {}
|
|
192
|
+
local _result_3 = props.styleOverride
|
|
193
|
+
if _result_3 ~= nil then
|
|
194
|
+
_result_3 = _result_3.borderThickness
|
|
195
|
+
end
|
|
196
|
+
local _condition_2 = _result_3
|
|
197
|
+
if _condition_2 == nil then
|
|
198
|
+
_condition_2 = theme.components.button.borderThickness
|
|
199
|
+
end
|
|
200
|
+
_attributes_2.Thickness = _condition_2
|
|
201
|
+
_attributes_2.BorderStrokePosition = Enum.BorderStrokePosition.Inner
|
|
202
|
+
_attributes_2.Color = intentColors.borderColor
|
|
203
|
+
local _exp_3 = React.createElement("uistroke", _attributes_2)
|
|
204
|
+
local _attributes_3 = table.clone(props)
|
|
205
|
+
setmetatable(_attributes_3, nil)
|
|
206
|
+
local _result_4 = props.styleOverride
|
|
207
|
+
if _result_4 ~= nil then
|
|
208
|
+
_result_4 = _result_4.boxShadow
|
|
209
|
+
end
|
|
210
|
+
local _condition_3 = _result_4
|
|
211
|
+
if _condition_3 == nil then
|
|
212
|
+
_condition_3 = theme.components.button.boxShadow
|
|
213
|
+
end
|
|
214
|
+
_attributes_3.value = _condition_3
|
|
215
|
+
local _exp_4 = React.createElement(BoxShadow, _attributes_3)
|
|
216
|
+
local _attributes_4 = table.clone(props)
|
|
217
|
+
setmetatable(_attributes_4, nil)
|
|
218
|
+
return React.createElement("imagebutton", _attributes, _exp_2, _exp_3, _exp_4, React.createElement(Padding, _attributes_4), React.createElement(Group.Element, {
|
|
115
219
|
enabled = props.group,
|
|
116
220
|
padding = padding,
|
|
117
221
|
}, (props.icon ~= nil or props.text ~= nil) and React.createElement(HStack, {
|
|
118
222
|
valign = "Center",
|
|
119
223
|
spacing = props.spacing,
|
|
224
|
+
Wraps = false,
|
|
120
225
|
}, props.icon ~= nil and React.createElement(ButtonIcon, {
|
|
121
226
|
scale = props.scale,
|
|
122
227
|
intent = props.intent,
|
|
228
|
+
disabled = props.disabled,
|
|
123
229
|
icon = props.icon,
|
|
230
|
+
styleOverride = props.styleOverride,
|
|
124
231
|
}), props.text ~= nil and React.createElement(ButtonText, {
|
|
125
232
|
text = props.text,
|
|
126
233
|
intent = props.intent,
|
|
234
|
+
disabled = props.disabled,
|
|
127
235
|
scale = props.scale,
|
|
236
|
+
styleOverride = props.styleOverride,
|
|
128
237
|
})), props.children))
|
|
129
238
|
end)
|
|
130
239
|
Button.Text = ButtonText
|
|
@@ -9,6 +9,7 @@ local Corners = _Decorator.Corners
|
|
|
9
9
|
local Padding = _Decorator.Padding
|
|
10
10
|
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
11
11
|
local ColorHelper = _Helpers.ColorHelper
|
|
12
|
+
local CssHelper = _Helpers.CssHelper
|
|
12
13
|
local SpacingHelper = _Helpers.SpacingHelper
|
|
13
14
|
local function Checkbox(props)
|
|
14
15
|
local theme = React.useContext(CleanThemeContext)
|
|
@@ -44,6 +45,7 @@ local function Checkbox(props)
|
|
|
44
45
|
_result(checked)
|
|
45
46
|
end
|
|
46
47
|
end, { checked })
|
|
48
|
+
local backgroundImage = CssHelper:resolveBackgroundImage(theme.components.checkbox.backgroundImage)
|
|
47
49
|
local _attributes = {
|
|
48
50
|
Size = UDim2.fromOffset(0, 0),
|
|
49
51
|
AutomaticSize = Enum.AutomaticSize.XY,
|
|
@@ -60,14 +62,28 @@ local function Checkbox(props)
|
|
|
60
62
|
_attributes.BackgroundTransparency = _condition_1
|
|
61
63
|
_attributes.BackgroundColor3 = ColorHelper:getIntentColors(theme, props.intent, "default", theme.components.button.intents).backgroundColor
|
|
62
64
|
_attributes.AutoButtonColor = false
|
|
63
|
-
|
|
65
|
+
_attributes.Image = backgroundImage.Image
|
|
66
|
+
_attributes.ImageColor3 = backgroundImage.ImageColor3
|
|
67
|
+
_attributes.ImageTransparency = backgroundImage.ImageTransparency
|
|
68
|
+
_attributes.ScaleType = backgroundImage.ScaleType
|
|
69
|
+
_attributes.SliceCenter = backgroundImage.SliceCenter
|
|
70
|
+
_attributes.SliceScale = backgroundImage.SliceScale
|
|
71
|
+
_attributes.TileSize = backgroundImage.TileSize
|
|
72
|
+
local _exp = React.createElement(Corners, {
|
|
64
73
|
radius = theme.components.checkbox.cornerRadius,
|
|
65
|
-
})
|
|
66
|
-
|
|
74
|
+
})
|
|
75
|
+
local _attributes_1 = {
|
|
76
|
+
Thickness = theme.components.checkbox.borderThickness,
|
|
67
77
|
BorderStrokePosition = Enum.BorderStrokePosition.Inner,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
}
|
|
79
|
+
local _condition_2 = theme.components.checkbox.borderTransparency
|
|
80
|
+
if _condition_2 == nil then
|
|
81
|
+
_condition_2 = 0
|
|
82
|
+
end
|
|
83
|
+
_attributes_1.Transparency = _condition_2
|
|
84
|
+
_attributes_1.Color = ColorHelper:getIntentColors(theme, if checked then props["intent-checked"] or "success" else props["intent-unchecked"] or "primary", "default", theme.components.checkbox.intents).borderColor
|
|
85
|
+
return React.createElement("imagebutton", _attributes, _exp, React.createElement("uistroke", _attributes_1), React.createElement(Padding, {
|
|
86
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, props, theme.components.checkbox.spacing, theme.components.checkbox.padding),
|
|
71
87
|
}), React.createElement(Icon, {
|
|
72
88
|
scale = props.scale,
|
|
73
89
|
icon = if checked then props["icon-checked"] or "check" else props["icon-unchecked"],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { IntentElementProps, ScalableElementProps, SpacedElementProps } from "../../Interfaces";
|
|
3
|
+
export interface IncrementProps extends ScalableElementProps, SpacedElementProps, IntentElementProps, React.InstanceProps<ImageLabel> {
|
|
4
|
+
value: number;
|
|
5
|
+
onChange?: (value: number) => void;
|
|
6
|
+
step?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
controlled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const Increment: React.ForwardRefExoticComponent<Omit<IncrementProps, "ref"> & React.RefAttributes<ImageLabel>>;
|
|
@@ -0,0 +1,107 @@
|
|
|
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 _Layout = TS.import(script, script.Parent.Parent, "Layout")
|
|
6
|
+
local Container = _Layout.Container
|
|
7
|
+
local FlexItem = _Layout.FlexItem
|
|
8
|
+
local HStack = _Layout.HStack
|
|
9
|
+
local Button = TS.import(script, script.Parent, "Button").Button
|
|
10
|
+
local resolveSteppedValue = TS.import(script, script.Parent, "Increment.step").resolveSteppedValue
|
|
11
|
+
local Input = TS.import(script, script.Parent, "Input").Input
|
|
12
|
+
local Increment = React.forwardRef(function(props, ref)
|
|
13
|
+
local theme = React.useContext(CleanThemeContext)
|
|
14
|
+
local _buttonStyleOverride = theme.components.increment
|
|
15
|
+
if _buttonStyleOverride ~= nil then
|
|
16
|
+
_buttonStyleOverride = _buttonStyleOverride.button
|
|
17
|
+
end
|
|
18
|
+
local buttonStyleOverride = _buttonStyleOverride
|
|
19
|
+
local value, setValue = React.useState(props.value)
|
|
20
|
+
local current = if props.controlled then props.value else value
|
|
21
|
+
local _condition = props.step
|
|
22
|
+
if _condition == nil then
|
|
23
|
+
_condition = 1
|
|
24
|
+
end
|
|
25
|
+
local step = _condition
|
|
26
|
+
local decrementDisabled = resolveSteppedValue(current, "decrement", step, props.min, props.max) == nil
|
|
27
|
+
local incrementDisabled = resolveSteppedValue(current, "increment", step, props.min, props.max) == nil
|
|
28
|
+
local applyValue = function(nextValue)
|
|
29
|
+
if not props.controlled then
|
|
30
|
+
setValue(nextValue)
|
|
31
|
+
end
|
|
32
|
+
local _result = props.onChange
|
|
33
|
+
if _result ~= nil then
|
|
34
|
+
_result(nextValue)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
local _attributes = {
|
|
38
|
+
ref = ref,
|
|
39
|
+
}
|
|
40
|
+
for _k, _v in props do
|
|
41
|
+
_attributes[_k] = _v
|
|
42
|
+
end
|
|
43
|
+
_attributes.Size = UDim2.fromScale(1, 0)
|
|
44
|
+
_attributes.AutomaticSize = Enum.AutomaticSize.Y
|
|
45
|
+
return React.createElement(Container, _attributes, React.createElement(HStack, {
|
|
46
|
+
Wraps = false,
|
|
47
|
+
valign = "Center",
|
|
48
|
+
spacing = props.spacing,
|
|
49
|
+
}, React.createElement(Button, {
|
|
50
|
+
icon = "minus",
|
|
51
|
+
intent = props.intent,
|
|
52
|
+
scale = props.scale,
|
|
53
|
+
spacing = props.spacing,
|
|
54
|
+
disabled = decrementDisabled,
|
|
55
|
+
styleOverride = buttonStyleOverride,
|
|
56
|
+
LayoutOrder = 0,
|
|
57
|
+
Event = {
|
|
58
|
+
Activated = function()
|
|
59
|
+
local nextValue = resolveSteppedValue(current, "decrement", step, props.min, props.max)
|
|
60
|
+
if nextValue == nil then
|
|
61
|
+
return nil
|
|
62
|
+
end
|
|
63
|
+
applyValue(nextValue)
|
|
64
|
+
end,
|
|
65
|
+
},
|
|
66
|
+
}), React.createElement(FlexItem, {
|
|
67
|
+
HorizontalFlex = "Fill",
|
|
68
|
+
LayoutOrder = 1,
|
|
69
|
+
}, React.createElement(Input, {
|
|
70
|
+
Size = UDim2.fromScale(0, 0),
|
|
71
|
+
scale = props.scale,
|
|
72
|
+
spacing = props.spacing,
|
|
73
|
+
controlled = true,
|
|
74
|
+
validation = "Number",
|
|
75
|
+
min = props.min,
|
|
76
|
+
max = props.max,
|
|
77
|
+
value = tostring(current),
|
|
78
|
+
TextXAlignment = Enum.TextXAlignment.Center,
|
|
79
|
+
onChange = function(text)
|
|
80
|
+
local parsed = tonumber(text)
|
|
81
|
+
if parsed == nil then
|
|
82
|
+
return nil
|
|
83
|
+
end
|
|
84
|
+
applyValue(parsed)
|
|
85
|
+
end,
|
|
86
|
+
})), React.createElement(Button, {
|
|
87
|
+
icon = "plus",
|
|
88
|
+
intent = props.intent,
|
|
89
|
+
scale = props.scale,
|
|
90
|
+
spacing = props.spacing,
|
|
91
|
+
disabled = incrementDisabled,
|
|
92
|
+
styleOverride = buttonStyleOverride,
|
|
93
|
+
LayoutOrder = 2,
|
|
94
|
+
Event = {
|
|
95
|
+
Activated = function()
|
|
96
|
+
local nextValue = resolveSteppedValue(current, "increment", step, props.min, props.max)
|
|
97
|
+
if nextValue == nil then
|
|
98
|
+
return nil
|
|
99
|
+
end
|
|
100
|
+
applyValue(nextValue)
|
|
101
|
+
end,
|
|
102
|
+
},
|
|
103
|
+
})))
|
|
104
|
+
end)
|
|
105
|
+
return {
|
|
106
|
+
Increment = Increment,
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveSteppedValue(current: number, direction: "increment" | "decrement", step: number, min?: number, max?: number): number | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local ROUNDING_PRECISION = 1e9
|
|
3
|
+
local function roundToPrecision(value)
|
|
4
|
+
return if value >= 0 then math.floor(value * ROUNDING_PRECISION + 0.5) / ROUNDING_PRECISION else math.ceil(value * ROUNDING_PRECISION - 0.5) / ROUNDING_PRECISION
|
|
5
|
+
end
|
|
6
|
+
local function resolveSteppedValue(current, direction, step, min, max)
|
|
7
|
+
if direction == "decrement" and min ~= nil and current <= min then
|
|
8
|
+
return nil
|
|
9
|
+
end
|
|
10
|
+
if direction == "increment" and max ~= nil and current >= max then
|
|
11
|
+
return nil
|
|
12
|
+
end
|
|
13
|
+
local candidate = if direction == "increment" then current + step else current - step
|
|
14
|
+
candidate = roundToPrecision(candidate)
|
|
15
|
+
if min ~= nil and candidate < min then
|
|
16
|
+
candidate = min
|
|
17
|
+
end
|
|
18
|
+
if max ~= nil and candidate > max then
|
|
19
|
+
candidate = max
|
|
20
|
+
end
|
|
21
|
+
return candidate
|
|
22
|
+
end
|
|
23
|
+
return {
|
|
24
|
+
resolveSteppedValue = resolveSteppedValue,
|
|
25
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import { ScalableElementProps, SpacedElementProps } from "../../Interfaces";
|
|
3
|
-
interface InputProps extends ScalableElementProps, SpacedElementProps, React.InstanceProps<TextBox> {
|
|
3
|
+
export interface InputProps extends ScalableElementProps, SpacedElementProps, React.InstanceProps<TextBox> {
|
|
4
4
|
value: string;
|
|
5
5
|
placeholder?: string;
|
|
6
|
-
validation?: "Number" | "String" | "None" | "Int";
|
|
6
|
+
validation?: "Number" | "String" | "None" | "Int" | "Telephone" | "Alphanumeric" | "Email";
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
7
9
|
onChange?: (value: string) => void;
|
|
8
10
|
Event?: React.InstanceEvent<TextBox>;
|
|
9
11
|
controlled?: boolean;
|
|
10
12
|
}
|
|
11
13
|
export declare function Input(props: InputProps): React.JSX.Element;
|
|
12
|
-
export {};
|