@rbxts/react-clean-ui 1.0.12 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/out/Components/Chart/Pie.d.ts +27 -0
  2. package/out/Components/Chart/Pie.luau +281 -0
  3. package/out/Components/Chart/index.d.ts +1 -0
  4. package/out/Components/Chart/init.luau +7 -0
  5. package/out/Components/Decorator/BoxShadow.d.ts +2 -1
  6. package/out/Components/Decorator/BoxShadow.luau +51 -28
  7. package/out/Components/Input/Select.d.ts +6 -14
  8. package/out/Components/Input/Select.luau +111 -151
  9. package/out/Components/Input/Slider.d.ts +3 -37
  10. package/out/Components/Input/Slider.luau +271 -300
  11. package/out/Components/Layout/Column.d.ts +2 -8
  12. package/out/Components/Layout/Column.luau +28 -48
  13. package/out/Components/Layout/Draggable.d.ts +7 -31
  14. package/out/Components/Layout/Draggable.luau +190 -214
  15. package/out/Components/Layout/Fieldset.d.ts +8 -18
  16. package/out/Components/Layout/Fieldset.luau +42 -84
  17. package/out/Components/Layout/Group.d.ts +7 -14
  18. package/out/Components/Layout/Group.luau +111 -129
  19. package/out/Components/Layout/Row.d.ts +2 -11
  20. package/out/Components/Layout/Row.luau +46 -71
  21. package/out/Components/Layout/Tabs.d.ts +10 -18
  22. package/out/Components/Layout/Tabs.luau +85 -104
  23. package/out/Components/Navigation/Menu.d.ts +6 -10
  24. package/out/Components/Navigation/Menu.luau +38 -65
  25. package/out/Components/Surface/Card.d.ts +8 -11
  26. package/out/Components/Surface/Card.luau +28 -48
  27. package/out/Components/Surface/index.d.ts +0 -1
  28. package/out/Components/Surface/init.luau +0 -3
  29. package/out/Components/index.d.ts +1 -0
  30. package/out/Components/init.luau +3 -0
  31. package/out/Helpers/css.helper.d.ts +2 -1
  32. package/out/Helpers/css.helper.luau +25 -0
  33. package/out/Helpers/size.helper.luau +1 -1
  34. package/out/Interfaces/clean.element.props.d.ts +5 -0
  35. package/out/Providers/registry.provider.d.ts +1 -0
  36. package/out/Providers/registry.provider.luau +5 -0
  37. package/out/Theme/theme.template.d.ts +15 -1
  38. package/out/Theme/themes/dark.theme.luau +3 -0
  39. package/out/Theme/themes/default.theme.luau +15 -0
  40. package/out/Theme/themes/sandstone.theme.luau +13 -0
  41. package/package.json +1 -1
  42. package/out/Components/Surface/Panel.d.ts +0 -4
  43. package/out/Components/Surface/Panel.luau +0 -33
@@ -0,0 +1,27 @@
1
+ import React from "@rbxts/react";
2
+ import { ScaleSize } from "../../Interfaces";
3
+ type PieLabel = {
4
+ text?: string;
5
+ spacing?: ScaleSize | "None";
6
+ content?: React.ReactNode;
7
+ BackgroundColor3?: Color3;
8
+ BorderColor3?: Color3;
9
+ };
10
+ type PieValue = {
11
+ value: number;
12
+ color?: Color3;
13
+ label?: string | PieLabel;
14
+ };
15
+ interface PieProps {
16
+ key?: string;
17
+ values: PieValue[];
18
+ ['label-distance']?: number;
19
+ ['label-hover']?: boolean;
20
+ ['Label-hidden']?: boolean;
21
+ ['label-spacing']?: ScaleSize | "None";
22
+ ['hover-darken']?: number;
23
+ onChangeSelected?: (index: number, value?: PieValue) => void;
24
+ onClick?: (index: number, value: PieValue) => void;
25
+ }
26
+ export declare function Pie(props: PieProps): React.JSX.Element;
27
+ export {};
@@ -0,0 +1,281 @@
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 React = _react
5
+ local useState = _react.useState
6
+ local GuiService = TS.import(script, TS.getModule(script, "@rbxts", "services")).GuiService
7
+ local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
8
+ local BoxShadow = _Decorator.BoxShadow
9
+ local Corners = _Decorator.Corners
10
+ local Padding = _Decorator.Padding
11
+ local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
12
+ local Text = TS.import(script, script.Parent.Parent, "Typography").Text
13
+ local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
14
+ local CssHelper = _Helpers.CssHelper
15
+ local SpacingHelper = _Helpers.SpacingHelper
16
+ local TypographyHelper = _Helpers.TypographyHelper
17
+ local function Segment(props)
18
+ local sizeX = if props.section == "Left" or props.section == "Right" then 0.5 else 1
19
+ local sizeY = if props.section == "Left" or props.section == "Right" then 1 else 0.5
20
+ local anchor = Vector2.new(1, 0.5)
21
+ local zeroed = 0
22
+ if props.section == "Right" then
23
+ zeroed = 180
24
+ anchor = Vector2.new(0, 0.5)
25
+ elseif props.section == "Top" then
26
+ zeroed = 90
27
+ anchor = Vector2.new(0.5, 1)
28
+ elseif props.section == "Bottom" then
29
+ zeroed = 270
30
+ anchor = Vector2.new(0.5, 0)
31
+ end
32
+ return React.createElement("frame", {
33
+ Size = UDim2.fromScale(sizeX, sizeY),
34
+ AnchorPoint = anchor,
35
+ Position = UDim2.fromScale(0.5, 0.5),
36
+ ClipsDescendants = true,
37
+ BorderSizePixel = 0,
38
+ BackgroundTransparency = 1,
39
+ BackgroundColor3 = Color3.fromHex("#FFFFFF"),
40
+ }, React.createElement("frame", {
41
+ BackgroundColor3 = props.color,
42
+ Size = UDim2.fromScale(if sizeX == 1 then 1 else 2, if sizeY == 1 then 1 else 2),
43
+ AnchorPoint = Vector2.new(0.5, 0.5),
44
+ BorderSizePixel = 0,
45
+ Position = UDim2.fromScale(anchor.X, anchor.Y),
46
+ }, React.createElement("uicorner", {
47
+ CornerRadius = UDim.new(0.5, 0),
48
+ }), React.createElement("uigradient", {
49
+ Transparency = NumberSequence.new({ NumberSequenceKeypoint.new(0, 1), NumberSequenceKeypoint.new(0.4999, 1), NumberSequenceKeypoint.new(0.5, 0), NumberSequenceKeypoint.new(1, 0) }),
50
+ Rotation = zeroed + props.fill * 180,
51
+ })))
52
+ end
53
+ local function getCirclePosition(normalized, radius)
54
+ if radius == nil then
55
+ radius = 0.3
56
+ end
57
+ local centerX = 0.5
58
+ local centerY = 0.5
59
+ -- Convert 0 → 1 into radians (0 → 2π)
60
+ local angle = normalized * math.pi * 2 + math.pi
61
+ local x = centerX + math.cos(angle) * radius
62
+ local y = centerY + math.sin(angle) * radius
63
+ return UDim2.fromScale(x, y)
64
+ end
65
+ local function Pie(props)
66
+ local theme = React.useContext(CleanThemeContext)
67
+ local state, setState = useState({
68
+ hover = -1,
69
+ })
70
+ local changeHover = function(index)
71
+ if state.hover == index then
72
+ return nil
73
+ end
74
+ setState({
75
+ hover = index,
76
+ })
77
+ local _result = props.onChangeSelected
78
+ if _result ~= nil then
79
+ _result(index, if index >= 0 then props.values[index + 1] else nil)
80
+ end
81
+ end
82
+ local segments = {}
83
+ local labels = {}
84
+ local _exp = props.values
85
+ -- ▼ ReadonlyArray.reduce ▼
86
+ local _result = 0
87
+ local _callback = function(sum, obj)
88
+ return sum + obj.value
89
+ end
90
+ for _i = 1, #_exp do
91
+ _result = _callback(_result, _exp[_i], _i - 1, _exp)
92
+ end
93
+ -- ▲ ReadonlyArray.reduce ▲
94
+ local totalValue = _result
95
+ local section = "Top"
96
+ local sectionRemaining = 1
97
+ local totalPercent = 0
98
+ local _exp_1 = props.values
99
+ -- ▼ ReadonlyArray.forEach ▼
100
+ local _callback_1 = function(v, index)
101
+ local percent = v.value / totalValue
102
+ totalPercent += (percent / 2)
103
+ local fill = percent * 2
104
+ local color = v.color or theme.components.pie.colors[index % #theme.components.pie.colors + 1]
105
+ if index == state.hover then
106
+ local _condition = props["hover-darken"]
107
+ if _condition == nil then
108
+ _condition = 0.2
109
+ end
110
+ local d = _condition
111
+ color = color:Lerp((if d < 0 then Color3.new(1, 1, 1) else Color3.new(0, 0, 0)), math.abs(d))
112
+ end
113
+ local _arg0 = React.createElement(Segment, {
114
+ section = section,
115
+ color = color,
116
+ fill = -sectionRemaining,
117
+ })
118
+ table.insert(segments, _arg0)
119
+ sectionRemaining -= fill
120
+ if sectionRemaining <= 0 then
121
+ section = "Bottom"
122
+ if sectionRemaining < 0 then
123
+ local _arg0_1 = React.createElement(Segment, {
124
+ section = section,
125
+ color = color,
126
+ fill = -sectionRemaining,
127
+ })
128
+ table.insert(segments, _arg0_1)
129
+ end
130
+ sectionRemaining = 1 + sectionRemaining
131
+ end
132
+ local _condition = not props["Label-hidden"]
133
+ if _condition then
134
+ _condition = v.label
135
+ if _condition ~= "" and _condition then
136
+ _condition = (not props["label-hover"] or state.hover == index)
137
+ end
138
+ end
139
+ if _condition ~= "" and _condition then
140
+ local label = v.label
141
+ local isTextLabel = type(label) == "string" or label.text ~= nil
142
+ local position = if #props.values == 1 then UDim2.fromScale(0.5, 0.5) else getCirclePosition(totalPercent, props["label-distance"])
143
+ if isTextLabel then
144
+ local text = if type(label) == "string" then label else (label.text)
145
+ local spacing = if type(label) == "string" then props["label-spacing"] else label.spacing
146
+ local background = if not (type(label) == "string") and label.BackgroundColor3 ~= nil then label.BackgroundColor3 else theme.components.pie.labels.backgroundColor or theme.components.box.backgroundColor
147
+ local border = if not (type(label) == "string") and label.BorderColor3 ~= nil then label.BorderColor3 else theme.components.pie.labels.borderColor or theme.components.box.borderColor
148
+ local _attributes = {
149
+ Size = UDim2.fromScale(0, 0),
150
+ AutomaticSize = Enum.AutomaticSize.XY,
151
+ AnchorPoint = Vector2.new(0.5, 0.5),
152
+ Position = position,
153
+ BackgroundColor3 = background,
154
+ }
155
+ local _condition_1 = theme.components.pie.labels.backgroundTransparency
156
+ if _condition_1 == nil then
157
+ _condition_1 = theme.components.box.backgroundTransparency
158
+ end
159
+ _attributes.BackgroundTransparency = _condition_1
160
+ local _exp_2 = React.createElement(Text, {
161
+ text = text,
162
+ typography = TypographyHelper:getTypography(theme, "md", theme.components.pie.labels.typography),
163
+ })
164
+ local _attributes_1 = {}
165
+ local _condition_2 = theme.components.pie.labels.cornerRadius
166
+ if _condition_2 == nil then
167
+ _condition_2 = theme.components.box.cornerRadius
168
+ end
169
+ _attributes_1.radius = _condition_2
170
+ local _exp_3 = React.createElement(Corners, _attributes_1)
171
+ local _attributes_2 = {}
172
+ local _condition_3 = theme.components.pie.labels.borderThickness
173
+ if _condition_3 == nil then
174
+ _condition_3 = theme.components.box.borderThickness
175
+ end
176
+ _attributes_2.Thickness = _condition_3
177
+ _attributes_2.BorderStrokePosition = Enum.BorderStrokePosition.Inner
178
+ _attributes_2.Color = border
179
+ local _arg0_1 = React.createElement("frame", _attributes, _exp_2, _exp_3, React.createElement("uistroke", _attributes_2), React.createElement(Padding, {
180
+ resolvedPadding = SpacingHelper:ResolveNumberPadding(SpacingHelper:GetPadding(theme, spacing, theme.components.pie.labels.spacing)),
181
+ }), React.createElement(BoxShadow))
182
+ table.insert(labels, _arg0_1)
183
+ elseif label.content ~= nil then
184
+ local _arg0_1 = React.createElement("frame", {
185
+ Size = UDim2.fromScale(0, 0),
186
+ AutomaticSize = Enum.AutomaticSize.XY,
187
+ AnchorPoint = Vector2.new(0.5, 0.5),
188
+ Position = position,
189
+ BackgroundTransparency = 1,
190
+ }, label.content)
191
+ table.insert(labels, _arg0_1)
192
+ end
193
+ end
194
+ totalPercent += (percent / 2)
195
+ end
196
+ for _k, _v in _exp_1 do
197
+ _callback_1(_v, _k - 1, _exp_1)
198
+ end
199
+ -- ▲ ReadonlyArray.forEach ▲
200
+ local shadowPadding
201
+ if theme.components.pie.boxShadow ~= nil then
202
+ local shadowParsed = CssHelper:parseCssShadow(theme.components.pie.boxShadow.shadow)
203
+ if shadowParsed ~= nil then
204
+ local shadowValue = shadowParsed.spread.X.Offset + shadowParsed.blurRadius.Offset
205
+ if shadowValue > 0 then
206
+ local resolvedPadding = SpacingHelper:ResolveNumberPadding(shadowValue)
207
+ resolvedPadding.left = math.max(0, resolvedPadding.left - shadowParsed.offset.X.Offset)
208
+ resolvedPadding.right += shadowParsed.offset.X.Offset
209
+ resolvedPadding.top = math.max(0, resolvedPadding.top - shadowParsed.offset.Y.Offset)
210
+ resolvedPadding.bottom += shadowParsed.offset.Y.Offset
211
+ shadowPadding = React.createElement(Padding, {
212
+ resolvedPadding = resolvedPadding,
213
+ })
214
+ end
215
+ end
216
+ end
217
+ return React.createElement("canvasgroup", {
218
+ BackgroundTransparency = 1,
219
+ Size = UDim2.fromScale(1, 1),
220
+ }, shadowPadding, React.createElement("frame", {
221
+ BackgroundTransparency = 1,
222
+ Size = UDim2.fromScale(1, 1),
223
+ Event = {
224
+ MouseLeave = function()
225
+ changeHover(-1)
226
+ end,
227
+ InputEnded = function(rbx, input)
228
+ if input.UserInputType ~= Enum.UserInputType.MouseButton1 then
229
+ return nil
230
+ end
231
+ if state.hover < 0 then
232
+ return nil
233
+ end
234
+ local _result_1 = props.onClick
235
+ if _result_1 ~= nil then
236
+ _result_1(state.hover, props.values[state.hover + 1])
237
+ end
238
+ end,
239
+ MouseMoved = function(rbx, x, y)
240
+ local offset = GuiService:GetGuiInset()
241
+ local localX = x - rbx.AbsolutePosition.X
242
+ local localY = y - rbx.AbsolutePosition.Y - offset.Y
243
+ local width = rbx.AbsoluteSize.X
244
+ local height = rbx.AbsoluteSize.Y
245
+ local centerX = width / 2
246
+ local centerY = height / 2
247
+ local dx = localX - centerX
248
+ local dy = localY - centerY
249
+ local radius = math.min(width, height) / 2
250
+ local distance = math.sqrt(dx * dx + dy * dy)
251
+ if distance > radius then
252
+ changeHover(-1)
253
+ return nil
254
+ end
255
+ local angle = math.atan2(dy, dx)
256
+ if angle < 0 then
257
+ angle += math.pi * 2
258
+ end
259
+ local normalized = angle / (math.pi * 2)
260
+ normalized = (normalized + 0.5) % 1
261
+ local running = 0
262
+ for i = 0, #props.values - 1 do
263
+ local percent = props.values[i + 1].value / totalValue
264
+ if normalized >= running and normalized <= running + percent then
265
+ changeHover(i)
266
+ return nil
267
+ end
268
+ running += percent
269
+ end
270
+ changeHover(-1)
271
+ end,
272
+ },
273
+ }, segments, labels, theme.components.pie.boxShadow ~= nil and React.createElement(BoxShadow, {
274
+ completeShadow = theme.components.pie.boxShadow,
275
+ }), React.createElement("uicorner", {
276
+ CornerRadius = UDim.new(1, 0),
277
+ })))
278
+ end
279
+ return {
280
+ Pie = Pie,
281
+ }
@@ -0,0 +1 @@
1
+ export * from './Pie';
@@ -0,0 +1,7 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ for _k, _v in TS.import(script, script, "Pie") or {} do
5
+ exports[_k] = _v
6
+ end
7
+ return exports
@@ -1,7 +1,8 @@
1
1
  import React from "@rbxts/react";
2
- import { CssShadow, ShadowElementProps } from "../../Interfaces/";
2
+ import { CssBoxShadow, CssShadow, ShadowElementProps } from "../../Interfaces/";
3
3
  interface BoxShadowProps extends ShadowElementProps {
4
4
  value?: CssShadow;
5
+ completeShadow?: CssBoxShadow;
5
6
  color?: Color3;
6
7
  transparency?: number;
7
8
  zindex?: number;
@@ -4,36 +4,59 @@ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
4
  local CssHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").CssHelper
5
5
  local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
6
6
  local function BoxShadow(props)
7
- local theme = React.useContext(CleanThemeContext)
8
- local shadowTheme = theme.components.boxShadow
9
- local _condition = props["box-shadow"]
10
- if _condition == nil then
11
- _condition = props.value
12
- end
13
- local shadowValue = _condition
14
- if shadowValue == nil then
15
- return nil
16
- end
17
- local shadow = CssHelper:parseCssShadow(shadowValue)
18
- if shadow == nil then
19
- return nil
7
+ local shadowProps
8
+ if props.completeShadow then
9
+ shadowProps = CssHelper:ResolveShadow(props.completeShadow)
10
+ else
11
+ local theme = React.useContext(CleanThemeContext)
12
+ local shadowTheme = theme.components.boxShadow
13
+ local _condition = props["box-shadow"]
14
+ if _condition == nil then
15
+ _condition = props.value
16
+ end
17
+ local shadowValue = _condition
18
+ if shadowValue == nil then
19
+ return nil
20
+ end
21
+ local shadow = CssHelper:parseCssShadow(shadowValue)
22
+ if shadow == nil then
23
+ return nil
24
+ end
25
+ local _object = {}
26
+ local _left = "Offset"
27
+ local _result = shadow
28
+ if _result ~= nil then
29
+ _result = _result.offset
30
+ end
31
+ _object[_left] = _result
32
+ local _left_1 = "BlurRadius"
33
+ local _result_1 = shadow
34
+ if _result_1 ~= nil then
35
+ _result_1 = _result_1.blurRadius
36
+ end
37
+ _object[_left_1] = _result_1
38
+ local _left_2 = "Spread"
39
+ local _result_2 = shadow
40
+ if _result_2 ~= nil then
41
+ _result_2 = _result_2.spread
42
+ end
43
+ _object[_left_2] = _result_2
44
+ _object.Color = props.color or shadowTheme.color
45
+ local _left_3 = "Transparency"
46
+ local _condition_1 = props.transparency
47
+ if _condition_1 == nil then
48
+ _condition_1 = shadowTheme.transparency
49
+ end
50
+ _object[_left_3] = _condition_1
51
+ shadowProps = _object
20
52
  end
21
- local _attributes = {
22
- Offset = shadow.offset,
23
- BlurRadius = shadow.blurRadius,
24
- Spread = shadow.spread,
25
- Color = props.color or shadowTheme.color,
26
- }
27
- local _condition_1 = props.transparency
28
- if _condition_1 == nil then
29
- _condition_1 = shadowTheme.transparency
30
- end
31
- _attributes.Transparency = _condition_1
32
- local _condition_2 = props.zindex
33
- if _condition_2 == nil then
34
- _condition_2 = -1
53
+ local _attributes = table.clone(shadowProps)
54
+ setmetatable(_attributes, nil)
55
+ local _condition = props.zindex
56
+ if _condition == nil then
57
+ _condition = -1
35
58
  end
36
- _attributes.ZIndex = _condition_2
59
+ _attributes.ZIndex = _condition
37
60
  return React.createElement("uishadow", _attributes)
38
61
  end
39
62
  return {
@@ -1,4 +1,4 @@
1
- import React, { Component } from "@rbxts/react";
1
+ import React from "@rbxts/react";
2
2
  import { CssSize, ScalableElementProps, SpacedElementProps } from "../../Interfaces";
3
3
  interface SelectProps extends ScalableElementProps, SpacedElementProps, React.InstanceProps<TextBox> {
4
4
  selected?: number;
@@ -6,12 +6,6 @@ interface SelectProps extends ScalableElementProps, SpacedElementProps, React.In
6
6
  onChange?: (selected: number, value?: string) => void;
7
7
  Event?: React.InstanceEvent<TextBox>;
8
8
  }
9
- interface SelectState {
10
- selected: number;
11
- open: boolean;
12
- dropdownSize: UDim2;
13
- dropdownPosition: UDim2;
14
- }
15
9
  interface SelectOptionProps {
16
10
  text?: string;
17
11
  children?: React.ReactNode;
@@ -21,10 +15,8 @@ interface SelectOptionProps {
21
15
  BackgroundColor3?: Color3;
22
16
  }
23
17
  declare function SelectOption(props: SelectOptionProps): React.JSX.Element;
24
- export declare class Select extends Component<SelectProps, SelectState> {
25
- static Option: typeof SelectOption;
26
- state: SelectState;
27
- private buttonRef;
28
- render(): React.JSX.Element;
29
- }
30
- export {};
18
+ type SelectComponent = React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<Frame>> & {
19
+ Option: typeof SelectOption;
20
+ };
21
+ declare const Select: SelectComponent;
22
+ export { Select };