@rbxts/react-clean-ui 1.0.19 → 1.0.36
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 +47 -0
- package/out/Components/Chart/BarChart.luau +880 -0
- package/out/Components/Chart/Pie.luau +12 -12
- package/out/Components/Chart/index.d.ts +1 -0
- package/out/Components/Chart/init.luau +3 -0
- package/out/Components/Interaction/Toast.d.ts +1 -1
- package/out/Components/Interaction/Toast.luau +4 -4
- package/out/Components/Interaction/Tooltip.d.ts +1 -1
- package/out/Components/Interaction/Tooltip.luau +8 -1
- package/out/Components/Layout/Accordion.d.ts +34 -0
- package/out/Components/Layout/Accordion.luau +430 -0
- package/out/Components/Layout/Container.luau +21 -5
- package/out/Components/Layout/HStack.d.ts +2 -1
- package/out/Components/Layout/HStack.luau +1 -2
- package/out/Components/Layout/VStack.d.ts +4 -1
- package/out/Components/Layout/VStack.luau +2 -2
- package/out/Components/Layout/index.d.ts +1 -0
- package/out/Components/Layout/init.luau +3 -0
- package/out/Components/Surface/Box.d.ts +2 -2
- package/out/Components/Surface/Card.luau +16 -4
- package/out/Components/Surface/Icon.d.ts +1 -1
- package/out/Components/Surface/Icon.luau +1 -0
- package/out/Components/Typography/Text.luau +26 -13
- package/out/Helpers/create-ui-story.d.ts +6 -4
- package/out/Helpers/create-ui-story.luau +15 -4
- package/out/Interfaces/clean.element.props.d.ts +2 -2
- package/out/Theme/theme.template.d.ts +67 -10
- package/out/Theme/themes/dark.theme.luau +45 -1
- package/out/Theme/themes/default.theme.luau +111 -11
- package/out/Theme/themes/sandstone.theme.luau +56 -10
- package/package.json +4 -2
|
@@ -101,7 +101,7 @@ local function Pie(props)
|
|
|
101
101
|
local percent = v.value / totalValue
|
|
102
102
|
totalPercent += (percent / 2)
|
|
103
103
|
local fill = percent * 2
|
|
104
|
-
local color = v.color or theme.components.
|
|
104
|
+
local color = v.color or theme.components.charts.colors[index % #theme.components.charts.colors + 1]
|
|
105
105
|
if index == state.hover then
|
|
106
106
|
local _condition = props["hover-darken"]
|
|
107
107
|
if _condition == nil then
|
|
@@ -143,8 +143,8 @@ local function Pie(props)
|
|
|
143
143
|
if isTextLabel then
|
|
144
144
|
local text = if type(label) == "string" then label else (label.text)
|
|
145
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
|
|
146
|
+
local background = if not (type(label) == "string") and label.BackgroundColor3 ~= nil then label.BackgroundColor3 else theme.components.charts.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.charts.pie.labels.borderColor or theme.components.box.borderColor
|
|
148
148
|
local _attributes = {
|
|
149
149
|
Size = UDim2.fromScale(0, 0),
|
|
150
150
|
AutomaticSize = Enum.AutomaticSize.XY,
|
|
@@ -152,24 +152,24 @@ local function Pie(props)
|
|
|
152
152
|
Position = position,
|
|
153
153
|
BackgroundColor3 = background,
|
|
154
154
|
}
|
|
155
|
-
local _condition_1 = theme.components.pie.labels.backgroundTransparency
|
|
155
|
+
local _condition_1 = theme.components.charts.pie.labels.backgroundTransparency
|
|
156
156
|
if _condition_1 == nil then
|
|
157
157
|
_condition_1 = theme.components.box.backgroundTransparency
|
|
158
158
|
end
|
|
159
159
|
_attributes.BackgroundTransparency = _condition_1
|
|
160
160
|
local _exp_2 = React.createElement(Text, {
|
|
161
161
|
text = text,
|
|
162
|
-
typography = TypographyHelper:getTypography(theme, "md", theme.components.pie.labels.typography),
|
|
162
|
+
typography = TypographyHelper:getTypography(theme, "md", theme.components.charts.pie.labels.typography),
|
|
163
163
|
})
|
|
164
164
|
local _attributes_1 = {}
|
|
165
|
-
local _condition_2 = theme.components.pie.labels.cornerRadius
|
|
165
|
+
local _condition_2 = theme.components.charts.pie.labels.cornerRadius
|
|
166
166
|
if _condition_2 == nil then
|
|
167
167
|
_condition_2 = theme.components.box.cornerRadius
|
|
168
168
|
end
|
|
169
169
|
_attributes_1.radius = _condition_2
|
|
170
170
|
local _exp_3 = React.createElement(Corners, _attributes_1)
|
|
171
171
|
local _attributes_2 = {}
|
|
172
|
-
local _condition_3 = theme.components.pie.labels.borderThickness
|
|
172
|
+
local _condition_3 = theme.components.charts.pie.labels.borderThickness
|
|
173
173
|
if _condition_3 == nil then
|
|
174
174
|
_condition_3 = theme.components.box.borderThickness
|
|
175
175
|
end
|
|
@@ -177,7 +177,7 @@ local function Pie(props)
|
|
|
177
177
|
_attributes_2.BorderStrokePosition = Enum.BorderStrokePosition.Inner
|
|
178
178
|
_attributes_2.Color = border
|
|
179
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)),
|
|
180
|
+
resolvedPadding = SpacingHelper:ResolveNumberPadding(SpacingHelper:GetPadding(theme, spacing, theme.components.charts.pie.labels.spacing)),
|
|
181
181
|
}), React.createElement(BoxShadow))
|
|
182
182
|
table.insert(labels, _arg0_1)
|
|
183
183
|
elseif label.content ~= nil then
|
|
@@ -198,8 +198,8 @@ local function Pie(props)
|
|
|
198
198
|
end
|
|
199
199
|
-- ▲ ReadonlyArray.forEach ▲
|
|
200
200
|
local shadowPadding
|
|
201
|
-
if theme.components.pie.boxShadow ~= nil then
|
|
202
|
-
local shadowParsed = CssHelper:parseCssShadow(theme.components.pie.boxShadow.shadow)
|
|
201
|
+
if theme.components.charts.pie.boxShadow ~= nil then
|
|
202
|
+
local shadowParsed = CssHelper:parseCssShadow(theme.components.charts.pie.boxShadow.shadow)
|
|
203
203
|
if shadowParsed ~= nil then
|
|
204
204
|
local shadowValue = shadowParsed.spread.X.Offset + shadowParsed.blurRadius.Offset
|
|
205
205
|
if shadowValue > 0 then
|
|
@@ -270,8 +270,8 @@ local function Pie(props)
|
|
|
270
270
|
changeHover(-1)
|
|
271
271
|
end,
|
|
272
272
|
},
|
|
273
|
-
}, segments, labels, theme.components.pie.boxShadow ~= nil and React.createElement(BoxShadow, {
|
|
274
|
-
completeShadow = theme.components.pie.boxShadow,
|
|
273
|
+
}, segments, labels, theme.components.charts.pie.boxShadow ~= nil and React.createElement(BoxShadow, {
|
|
274
|
+
completeShadow = theme.components.charts.pie.boxShadow,
|
|
275
275
|
}), React.createElement("uicorner", {
|
|
276
276
|
CornerRadius = UDim.new(1, 0),
|
|
277
277
|
})))
|
|
@@ -10,11 +10,11 @@ local Container = _Layout.Container
|
|
|
10
10
|
local FlexItem = _Layout.FlexItem
|
|
11
11
|
local HStack = _Layout.HStack
|
|
12
12
|
local VStack = _Layout.VStack
|
|
13
|
-
local Button = TS.import(script, script.Parent.Parent, "Input").Button
|
|
13
|
+
local Button = TS.import(script, script.Parent.Parent, "Input", "Button").Button
|
|
14
14
|
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
15
|
-
local
|
|
16
|
-
local CleanThemeContext =
|
|
17
|
-
local useToast =
|
|
15
|
+
local _Contexts = TS.import(script, script.Parent.Parent.Parent, "Contexts")
|
|
16
|
+
local CleanThemeContext = _Contexts.CleanThemeContext
|
|
17
|
+
local useToast = _Contexts.useToast
|
|
18
18
|
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
19
19
|
local ColorHelper = _Helpers.ColorHelper
|
|
20
20
|
local SizeHelper = _Helpers.SizeHelper
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "@rbxts/react";
|
|
2
2
|
import { IntentElementProps } from "../../Interfaces";
|
|
3
3
|
import { BoxProps } from "../Surface";
|
|
4
|
-
type TooltipPlacement = "Top" | "Bottom" | "Left" | "Right";
|
|
4
|
+
type TooltipPlacement = "Top" | "Bottom" | "Left" | "Right" | "Center";
|
|
5
5
|
interface TooltipProps extends BoxProps, IntentElementProps {
|
|
6
6
|
content: React.ReactNode | string;
|
|
7
7
|
children: React.ReactElement<React.InstanceProps<GuiObject>>;
|
|
@@ -38,7 +38,7 @@ local function TooltipPopup(props)
|
|
|
38
38
|
resolvedPadding.left += shadow.blurRadius.Offset + shadow.spread.X.Offset - shadow.offset.X.Offset
|
|
39
39
|
resolvedPadding.right += shadow.blurRadius.Offset + shadow.spread.X.Offset + shadow.offset.X.Offset
|
|
40
40
|
end
|
|
41
|
-
local pointerSize = theme.components.tooltip.pointerSize
|
|
41
|
+
local pointerSize = if props.placement == "Center" then 0 else theme.components.tooltip.pointerSize
|
|
42
42
|
local anchor = Vector2.zero
|
|
43
43
|
local _position = props.target.position
|
|
44
44
|
local _absolutePosition = props.overlay.AbsolutePosition
|
|
@@ -93,6 +93,13 @@ local function TooltipPopup(props)
|
|
|
93
93
|
resolvedPadding.left = math.max(math.floor(pointerHeight), resolvedPadding.left)
|
|
94
94
|
break
|
|
95
95
|
end
|
|
96
|
+
if _exp == "Center" then
|
|
97
|
+
anchor = Vector2.new(0.5, 0.5)
|
|
98
|
+
local _position_1 = position
|
|
99
|
+
local _vector2 = Vector2.new(props.target.size.X / 2, props.target.size.Y / 2)
|
|
100
|
+
position = _position_1 + _vector2
|
|
101
|
+
break
|
|
102
|
+
end
|
|
96
103
|
until true
|
|
97
104
|
local intent = ColorHelper:getIntentColors(theme, props.intent, "default", theme.components.tooltip.intents)
|
|
98
105
|
local padding = SpacingHelper:ResolveNumberPadding(SpacingHelper:GetPadding(theme, props.spacing, theme.components.tooltip.spacing))
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { IconName, ScalableElementProps } from "../../Interfaces";
|
|
3
|
+
interface AccordionItemProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
value: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function AccordionItem(_props: AccordionItemProps): undefined;
|
|
9
|
+
interface AccordionHeaderProps {
|
|
10
|
+
children?: React.ReactNode | string;
|
|
11
|
+
icon?: IconName;
|
|
12
|
+
text?: string;
|
|
13
|
+
}
|
|
14
|
+
declare function AccordionHeader(_props: AccordionHeaderProps): undefined;
|
|
15
|
+
interface AccordionContentProps {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
text?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function AccordionContent(_props: AccordionContentProps): undefined;
|
|
20
|
+
export interface AccordionProps extends ScalableElementProps {
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
collapsible?: boolean;
|
|
23
|
+
animationDuration?: number;
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
value?: string;
|
|
26
|
+
onValueChange?: (value: string | undefined) => void;
|
|
27
|
+
}
|
|
28
|
+
type AccordionComponent = React.ForwardRefExoticComponent<AccordionProps & React.RefAttributes<Frame>> & {
|
|
29
|
+
Item: typeof AccordionItem;
|
|
30
|
+
Header: typeof AccordionHeader;
|
|
31
|
+
Content: typeof AccordionContent;
|
|
32
|
+
};
|
|
33
|
+
declare const Accordion: AccordionComponent;
|
|
34
|
+
export { Accordion };
|
|
@@ -0,0 +1,430 @@
|
|
|
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 useTween = TS.import(script, TS.getModule(script, "@rbxts", "react-ripple").src).useTween
|
|
5
|
+
local CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
|
|
6
|
+
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
7
|
+
local ColorHelper = _Helpers.ColorHelper
|
|
8
|
+
local SizeHelper = _Helpers.SizeHelper
|
|
9
|
+
local SpacingHelper = _Helpers.SpacingHelper
|
|
10
|
+
local TypographyHelper = _Helpers.TypographyHelper
|
|
11
|
+
local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
|
|
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 VStack = TS.import(script, script.Parent, "VStack").VStack
|
|
22
|
+
local function AccordionItem(_props)
|
|
23
|
+
return nil
|
|
24
|
+
end
|
|
25
|
+
local function AccordionHeader(_props)
|
|
26
|
+
return nil
|
|
27
|
+
end
|
|
28
|
+
local function AccordionContent(_props)
|
|
29
|
+
return nil
|
|
30
|
+
end
|
|
31
|
+
local function AccordionHeaderVisual(props)
|
|
32
|
+
local theme = React.useContext(CleanThemeContext)
|
|
33
|
+
local hover = React.useContext(HoverButtonContext)
|
|
34
|
+
local _result
|
|
35
|
+
if props.disabled then
|
|
36
|
+
_result = "disabled"
|
|
37
|
+
else
|
|
38
|
+
local _result_1 = hover
|
|
39
|
+
if _result_1 ~= nil then
|
|
40
|
+
_result_1 = _result_1.isSelected
|
|
41
|
+
end
|
|
42
|
+
local _result_2
|
|
43
|
+
if _result_1 then
|
|
44
|
+
_result_2 = "focus"
|
|
45
|
+
else
|
|
46
|
+
local _result_3 = hover
|
|
47
|
+
if _result_3 ~= nil then
|
|
48
|
+
_result_3 = _result_3.hover
|
|
49
|
+
end
|
|
50
|
+
_result_2 = if _result_3 then "hover" else "default"
|
|
51
|
+
end
|
|
52
|
+
_result = _result_2
|
|
53
|
+
end
|
|
54
|
+
local state = _result
|
|
55
|
+
local colors = ColorHelper:getIntentColors(theme, "primary", state, theme.components.accordion.header.intents)
|
|
56
|
+
local rotation, rotationTween = useTween(if props.open then 0 else -90, {
|
|
57
|
+
duration = props.duration,
|
|
58
|
+
})
|
|
59
|
+
React.useEffect(function()
|
|
60
|
+
local goal = if props.open then 0 else -90
|
|
61
|
+
rotationTween:setGoal(goal, {
|
|
62
|
+
duration = props.duration,
|
|
63
|
+
})
|
|
64
|
+
if props.duration == 0 then
|
|
65
|
+
rotationTween:setPosition(goal)
|
|
66
|
+
end
|
|
67
|
+
rotationTween:start()
|
|
68
|
+
end, { props.duration, props.open, rotationTween })
|
|
69
|
+
local _condition = props.header.text == nil and props.header.children ~= nil
|
|
70
|
+
if _condition then
|
|
71
|
+
local _children = props.header.children
|
|
72
|
+
_condition = not (type(_children) == "string")
|
|
73
|
+
end
|
|
74
|
+
if _condition then
|
|
75
|
+
return props.header.children
|
|
76
|
+
end
|
|
77
|
+
local _exp = React.createElement(Padding, {
|
|
78
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.accordion.header.spacing),
|
|
79
|
+
})
|
|
80
|
+
local _exp_1 = props.header.icon ~= nil and React.createElement(Icon, {
|
|
81
|
+
icon = props.header.icon,
|
|
82
|
+
color = colors.textColor,
|
|
83
|
+
})
|
|
84
|
+
local _result_1
|
|
85
|
+
if props.header.text ~= nil then
|
|
86
|
+
_result_1 = React.createElement(Text, {
|
|
87
|
+
text = props.header.text,
|
|
88
|
+
TextColor3 = colors.textColor,
|
|
89
|
+
typography = TypographyHelper:getTypography(theme, nil, colors.typography or theme.components.accordion.header.typography),
|
|
90
|
+
})
|
|
91
|
+
else
|
|
92
|
+
local _children = props.header.children
|
|
93
|
+
_result_1 = if type(_children) == "string" then React.createElement(Text, {
|
|
94
|
+
text = props.header.children,
|
|
95
|
+
TextColor3 = colors.textColor,
|
|
96
|
+
typography = TypographyHelper:getTypography(theme, nil, colors.typography or theme.components.accordion.header.typography),
|
|
97
|
+
}) else props.header.children
|
|
98
|
+
end
|
|
99
|
+
return React.createElement(React.Fragment, nil, _exp, React.createElement(HStack, {
|
|
100
|
+
valign = "Center",
|
|
101
|
+
Wraps = false,
|
|
102
|
+
HorizontalFlex = Enum.UIFlexAlignment.Fill,
|
|
103
|
+
}, _exp_1, React.createElement(Container, {
|
|
104
|
+
Size = UDim2.new(1, theme.components.accordion.header.indicatorSize, 0, 0),
|
|
105
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
106
|
+
}, _result_1), React.createElement(Icon, {
|
|
107
|
+
icon = "chevron-down",
|
|
108
|
+
color = if props.disabled then colors.textColor else theme.components.accordion.header.indicatorColor,
|
|
109
|
+
Size = UDim2.fromOffset(theme.components.accordion.header.indicatorSize, theme.components.accordion.header.indicatorSize),
|
|
110
|
+
Rotation = rotation,
|
|
111
|
+
})))
|
|
112
|
+
end
|
|
113
|
+
local function RenderedAccordionItem(props)
|
|
114
|
+
local theme = React.useContext(CleanThemeContext)
|
|
115
|
+
local mounted, setMounted = React.useState(props.open)
|
|
116
|
+
local height, heightTween = useTween(0, {
|
|
117
|
+
duration = props.duration,
|
|
118
|
+
})
|
|
119
|
+
React.useEffect(function()
|
|
120
|
+
if props.open then
|
|
121
|
+
setMounted(true)
|
|
122
|
+
else
|
|
123
|
+
heightTween:setGoal(0, {
|
|
124
|
+
duration = props.duration,
|
|
125
|
+
})
|
|
126
|
+
if props.duration == 0 then
|
|
127
|
+
heightTween:setPosition(0)
|
|
128
|
+
end
|
|
129
|
+
heightTween:start()
|
|
130
|
+
if props.duration == 0 then
|
|
131
|
+
setMounted(false)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end, { props.duration, props.open, heightTween })
|
|
135
|
+
React.useEffect(function()
|
|
136
|
+
if props.duration == 0 then
|
|
137
|
+
heightTween:setPosition(heightTween:getGoal())
|
|
138
|
+
end
|
|
139
|
+
end, { props.duration, heightTween })
|
|
140
|
+
React.useEffect(function()
|
|
141
|
+
return heightTween:onComplete(function(value)
|
|
142
|
+
if value == 0 and not props.open then
|
|
143
|
+
setMounted(false)
|
|
144
|
+
end
|
|
145
|
+
end)
|
|
146
|
+
end, { heightTween, props.open })
|
|
147
|
+
local defaultColors = ColorHelper:getIntentColors(theme, "primary", if props.disabled then "disabled" else "default", theme.components.accordion.header.intents)
|
|
148
|
+
local hoverColors = ColorHelper:getIntentColors(theme, "primary", "hover", theme.components.accordion.header.intents)
|
|
149
|
+
local focusColors = ColorHelper:getIntentColors(theme, "primary", "focus", theme.components.accordion.header.intents)
|
|
150
|
+
local _condition = not props.first
|
|
151
|
+
if _condition then
|
|
152
|
+
local _attributes = {
|
|
153
|
+
BackgroundColor3 = theme.components.accordion.borderColor,
|
|
154
|
+
BackgroundTransparency = 0,
|
|
155
|
+
BorderSizePixel = 0,
|
|
156
|
+
}
|
|
157
|
+
local _exp = UDim2.fromOffset(0, theme.components.accordion.borderThickness)
|
|
158
|
+
local _arg0 = UDim2.fromScale(1, 0)
|
|
159
|
+
_attributes.Size = _exp + _arg0
|
|
160
|
+
_condition = (React.createElement("frame", _attributes))
|
|
161
|
+
end
|
|
162
|
+
local _attributes = {
|
|
163
|
+
isSelected = props.open,
|
|
164
|
+
}
|
|
165
|
+
local _object = {
|
|
166
|
+
Active = not props.disabled and props.content ~= nil,
|
|
167
|
+
Selectable = not props.disabled and props.content ~= nil,
|
|
168
|
+
AutoButtonColor = false,
|
|
169
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
170
|
+
Size = UDim2.fromScale(1, 0),
|
|
171
|
+
ImageTransparency = 1,
|
|
172
|
+
BackgroundColor3 = defaultColors.backgroundColor,
|
|
173
|
+
}
|
|
174
|
+
local _left = "BackgroundTransparency"
|
|
175
|
+
local _condition_1 = defaultColors.backgroundTransparency
|
|
176
|
+
if _condition_1 == nil then
|
|
177
|
+
_condition_1 = 0
|
|
178
|
+
end
|
|
179
|
+
_object[_left] = _condition_1
|
|
180
|
+
_object.BorderSizePixel = 0
|
|
181
|
+
_object.Event = {
|
|
182
|
+
Activated = props.onActivate,
|
|
183
|
+
}
|
|
184
|
+
_attributes.default = _object
|
|
185
|
+
local _object_1 = {
|
|
186
|
+
BackgroundColor3 = hoverColors.backgroundColor,
|
|
187
|
+
}
|
|
188
|
+
local _left_1 = "BackgroundTransparency"
|
|
189
|
+
local _condition_2 = hoverColors.backgroundTransparency
|
|
190
|
+
if _condition_2 == nil then
|
|
191
|
+
_condition_2 = 0
|
|
192
|
+
end
|
|
193
|
+
_object_1[_left_1] = _condition_2
|
|
194
|
+
_attributes.hover = _object_1
|
|
195
|
+
local _object_2 = {
|
|
196
|
+
BackgroundColor3 = focusColors.backgroundColor,
|
|
197
|
+
}
|
|
198
|
+
local _left_2 = "BackgroundTransparency"
|
|
199
|
+
local _condition_3 = focusColors.backgroundTransparency
|
|
200
|
+
if _condition_3 == nil then
|
|
201
|
+
_condition_3 = 0
|
|
202
|
+
end
|
|
203
|
+
_object_2[_left_2] = _condition_3
|
|
204
|
+
_attributes.focus = _object_2
|
|
205
|
+
return React.createElement(Container, {
|
|
206
|
+
width = "100%",
|
|
207
|
+
}, React.createElement(VStack, {
|
|
208
|
+
spacing = "None",
|
|
209
|
+
}, _condition, React.createElement(HoverButton, _attributes, props.first and (React.createElement("uicorner", {
|
|
210
|
+
TopLeftRadius = SizeHelper:toUDim(theme.components.accordion.cornerRadius),
|
|
211
|
+
TopRightRadius = SizeHelper:toUDim(theme.components.accordion.cornerRadius),
|
|
212
|
+
BottomLeftRadius = UDim.new(0, 0),
|
|
213
|
+
BottomRightRadius = UDim.new(0, 0),
|
|
214
|
+
})), React.createElement(AccordionHeaderVisual, {
|
|
215
|
+
header = props.header,
|
|
216
|
+
disabled = props.disabled,
|
|
217
|
+
duration = props.duration,
|
|
218
|
+
open = props.open,
|
|
219
|
+
})), mounted and (React.createElement("frame", {
|
|
220
|
+
BackgroundTransparency = 1,
|
|
221
|
+
ClipsDescendants = true,
|
|
222
|
+
Size = height:map(function(value)
|
|
223
|
+
local _exp = UDim2.fromScale(1, 0)
|
|
224
|
+
local _arg0 = UDim2.fromOffset(0, value)
|
|
225
|
+
return _exp + _arg0
|
|
226
|
+
end),
|
|
227
|
+
}, React.createElement("frame", {
|
|
228
|
+
BackgroundColor3 = theme.components.accordion.content.backgroundColor,
|
|
229
|
+
BackgroundTransparency = theme.components.accordion.content.backgroundTransparency,
|
|
230
|
+
Size = UDim2.fromScale(1, 0),
|
|
231
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
232
|
+
Change = {
|
|
233
|
+
AbsoluteSize = function(instance)
|
|
234
|
+
if props.open then
|
|
235
|
+
heightTween:setGoal(instance.AbsoluteSize.Y, {
|
|
236
|
+
duration = props.duration,
|
|
237
|
+
})
|
|
238
|
+
if props.duration == 0 then
|
|
239
|
+
heightTween:setPosition(instance.AbsoluteSize.Y)
|
|
240
|
+
end
|
|
241
|
+
heightTween:start()
|
|
242
|
+
end
|
|
243
|
+
end,
|
|
244
|
+
},
|
|
245
|
+
}, React.createElement(Padding, {
|
|
246
|
+
resolvedPadding = SpacingHelper:GetResolvedPadding(theme, {}, theme.components.accordion.content.spacing),
|
|
247
|
+
}), if props.contentText ~= nil then React.createElement(Text, {
|
|
248
|
+
text = props.contentText,
|
|
249
|
+
}) else props.content)))))
|
|
250
|
+
end
|
|
251
|
+
local Accordion = React.forwardRef(function(props, ref)
|
|
252
|
+
local theme = React.useContext(CleanThemeContext)
|
|
253
|
+
local items = React.useMemo(function()
|
|
254
|
+
local parsed = {}
|
|
255
|
+
local seen = {}
|
|
256
|
+
React.Children.forEach(props.children, function(child)
|
|
257
|
+
if not React.isValidElement(child) or child.type ~= AccordionItem then
|
|
258
|
+
return nil
|
|
259
|
+
end
|
|
260
|
+
local item = child
|
|
261
|
+
local _value = item.props.value
|
|
262
|
+
if seen[_value] ~= nil then
|
|
263
|
+
return nil
|
|
264
|
+
end
|
|
265
|
+
local header
|
|
266
|
+
local contentText
|
|
267
|
+
local content
|
|
268
|
+
React.Children.forEach(item.props.children, function(itemChild)
|
|
269
|
+
if not React.isValidElement(itemChild) then
|
|
270
|
+
return nil
|
|
271
|
+
end
|
|
272
|
+
if itemChild.type == AccordionHeader and header == nil then
|
|
273
|
+
header = itemChild.props
|
|
274
|
+
end
|
|
275
|
+
if itemChild.type == AccordionContent and content == nil then
|
|
276
|
+
local contentProps = itemChild.props
|
|
277
|
+
contentText = contentProps.text
|
|
278
|
+
content = contentProps.children
|
|
279
|
+
end
|
|
280
|
+
end)
|
|
281
|
+
if header ~= nil then
|
|
282
|
+
local _value_1 = item.props.value
|
|
283
|
+
seen[_value_1] = true
|
|
284
|
+
local _object = {
|
|
285
|
+
value = item.props.value,
|
|
286
|
+
}
|
|
287
|
+
local _left = "disabled"
|
|
288
|
+
local _condition = item.props.disabled
|
|
289
|
+
if _condition == nil then
|
|
290
|
+
_condition = false
|
|
291
|
+
end
|
|
292
|
+
_object[_left] = _condition
|
|
293
|
+
_object.header = header
|
|
294
|
+
_object.contentText = contentText
|
|
295
|
+
_object.content = content
|
|
296
|
+
table.insert(parsed, _object)
|
|
297
|
+
end
|
|
298
|
+
end)
|
|
299
|
+
return parsed
|
|
300
|
+
end, { props.children })
|
|
301
|
+
local initial = if props.defaultValue ~= nil then { props.defaultValue } else {}
|
|
302
|
+
local uncontrolled, setUncontrolled = React.useState(initial)
|
|
303
|
+
local supplied = if props.value ~= nil then { props.value } else uncontrolled
|
|
304
|
+
local _set = {}
|
|
305
|
+
-- ▼ ReadonlyArray.map ▼
|
|
306
|
+
local _newValue = table.create(#items)
|
|
307
|
+
local _callback = function(item)
|
|
308
|
+
return item.value
|
|
309
|
+
end
|
|
310
|
+
for _k, _v in items do
|
|
311
|
+
_newValue[_k] = _callback(_v, _k - 1, items)
|
|
312
|
+
end
|
|
313
|
+
-- ▲ ReadonlyArray.map ▲
|
|
314
|
+
for _, _v in _newValue do
|
|
315
|
+
_set[_v] = true
|
|
316
|
+
end
|
|
317
|
+
local available = _set
|
|
318
|
+
-- ▼ ReadonlyArray.filter ▼
|
|
319
|
+
local _newValue_1 = {}
|
|
320
|
+
local _callback_1 = function(value)
|
|
321
|
+
local _value = value
|
|
322
|
+
return available[_value] ~= nil
|
|
323
|
+
end
|
|
324
|
+
local _length = 0
|
|
325
|
+
for _k, _v in supplied do
|
|
326
|
+
if _callback_1(_v, _k - 1, supplied) == true then
|
|
327
|
+
_length += 1
|
|
328
|
+
_newValue_1[_length] = _v
|
|
329
|
+
end
|
|
330
|
+
end
|
|
331
|
+
-- ▲ ReadonlyArray.filter ▲
|
|
332
|
+
local openValues = _newValue_1
|
|
333
|
+
React.useEffect(function()
|
|
334
|
+
local _condition = props.value == nil
|
|
335
|
+
if _condition then
|
|
336
|
+
local _condition_1 = #uncontrolled ~= #openValues
|
|
337
|
+
if not _condition_1 then
|
|
338
|
+
-- ▼ ReadonlyArray.some ▼
|
|
339
|
+
local _result = false
|
|
340
|
+
local _callback_2 = function(value)
|
|
341
|
+
local _value = value
|
|
342
|
+
return not (available[_value] ~= nil)
|
|
343
|
+
end
|
|
344
|
+
for _k, _v in uncontrolled do
|
|
345
|
+
if _callback_2(_v, _k - 1, uncontrolled) then
|
|
346
|
+
_result = true
|
|
347
|
+
break
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
-- ▲ ReadonlyArray.some ▲
|
|
351
|
+
_condition_1 = _result
|
|
352
|
+
end
|
|
353
|
+
_condition = _condition_1
|
|
354
|
+
end
|
|
355
|
+
if _condition then
|
|
356
|
+
setUncontrolled(openValues)
|
|
357
|
+
end
|
|
358
|
+
end, { items, props.value })
|
|
359
|
+
local activate = function(item)
|
|
360
|
+
if item.disabled or (item.content == nil and item.contentText == nil) then
|
|
361
|
+
return nil
|
|
362
|
+
end
|
|
363
|
+
local _value = item.value
|
|
364
|
+
local isOpen = table.find(openValues, _value) ~= nil
|
|
365
|
+
local nextValues
|
|
366
|
+
if isOpen then
|
|
367
|
+
if not props.collapsible then
|
|
368
|
+
return nil
|
|
369
|
+
end
|
|
370
|
+
nextValues = {}
|
|
371
|
+
else
|
|
372
|
+
nextValues = { item.value }
|
|
373
|
+
end
|
|
374
|
+
if props.value == nil then
|
|
375
|
+
setUncontrolled(nextValues)
|
|
376
|
+
end
|
|
377
|
+
local _result = props.onValueChange
|
|
378
|
+
if _result ~= nil then
|
|
379
|
+
_result(nextValues[1])
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
local _exp = React.createElement(Corners, {
|
|
383
|
+
radius = theme.components.accordion.cornerRadius,
|
|
384
|
+
})
|
|
385
|
+
local _exp_1 = React.createElement("uistroke", {
|
|
386
|
+
Color = theme.components.accordion.borderColor,
|
|
387
|
+
Thickness = theme.components.accordion.borderThickness,
|
|
388
|
+
BorderStrokePosition = Enum.BorderStrokePosition.Outer,
|
|
389
|
+
})
|
|
390
|
+
-- ▼ ReadonlyArray.map ▼
|
|
391
|
+
local _newValue_2 = table.create(#items)
|
|
392
|
+
local _callback_2 = function(item, index)
|
|
393
|
+
local _attributes = {
|
|
394
|
+
key = item.value,
|
|
395
|
+
}
|
|
396
|
+
for _k, _v in item do
|
|
397
|
+
_attributes[_k] = _v
|
|
398
|
+
end
|
|
399
|
+
_attributes.first = index == 0
|
|
400
|
+
local _value = item.value
|
|
401
|
+
_attributes.open = table.find(openValues, _value) ~= nil
|
|
402
|
+
local _condition = props.animationDuration
|
|
403
|
+
if _condition == nil then
|
|
404
|
+
_condition = theme.components.accordion.animation.duration
|
|
405
|
+
end
|
|
406
|
+
_attributes.duration = _condition
|
|
407
|
+
_attributes.onActivate = function()
|
|
408
|
+
return activate(item)
|
|
409
|
+
end
|
|
410
|
+
return React.createElement(RenderedAccordionItem, _attributes)
|
|
411
|
+
end
|
|
412
|
+
for _k, _v in items do
|
|
413
|
+
_newValue_2[_k] = _callback_2(_v, _k - 1, items)
|
|
414
|
+
end
|
|
415
|
+
-- ▲ ReadonlyArray.map ▲
|
|
416
|
+
return React.createElement(Container, {
|
|
417
|
+
ref = ref,
|
|
418
|
+
width = "100%",
|
|
419
|
+
height = "100%",
|
|
420
|
+
ClipsDescendants = true,
|
|
421
|
+
}, _exp, _exp_1, React.createElement(VStack, {
|
|
422
|
+
Padding = UDim.new(0, SpacingHelper:GetPadding(theme, props.scale, theme.components.accordion.spacing)),
|
|
423
|
+
}, _newValue_2))
|
|
424
|
+
end)
|
|
425
|
+
Accordion.Item = AccordionItem
|
|
426
|
+
Accordion.Header = AccordionHeader
|
|
427
|
+
Accordion.Content = AccordionContent
|
|
428
|
+
return {
|
|
429
|
+
Accordion = Accordion,
|
|
430
|
+
}
|
|
@@ -7,13 +7,16 @@ local Group = _Group.Group
|
|
|
7
7
|
local GroupContext = _Group.GroupContext
|
|
8
8
|
local Container = React.forwardRef(function(props, ref)
|
|
9
9
|
local group = React.useContext(GroupContext)
|
|
10
|
+
local autoSize = SizeHelper:GetAutoSize(props)
|
|
11
|
+
local isAutoSizeActive = autoSize ~= Enum.AutomaticSize.None and autoSize ~= "None"
|
|
12
|
+
local centerViaLayout = props.center == true and props.Position == nil and props.AnchorPoint == nil and isAutoSizeActive
|
|
10
13
|
local _attributes = {
|
|
11
14
|
ref = ref,
|
|
12
15
|
Archivable = props.Archivable,
|
|
13
16
|
Tag = props.Tag,
|
|
14
17
|
Active = props.Active,
|
|
15
|
-
AnchorPoint = SizeHelper:GetAnchor(props),
|
|
16
|
-
AutomaticSize =
|
|
18
|
+
AnchorPoint = if centerViaLayout then Vector2.zero else SizeHelper:GetAnchor(props),
|
|
19
|
+
AutomaticSize = autoSize,
|
|
17
20
|
BackgroundColor3 = props.BackgroundColor3,
|
|
18
21
|
}
|
|
19
22
|
local _condition = props.BackgroundTransparency
|
|
@@ -31,7 +34,7 @@ local Container = React.forwardRef(function(props, ref)
|
|
|
31
34
|
_attributes.NextSelectionLeft = props.NextSelectionLeft
|
|
32
35
|
_attributes.NextSelectionRight = props.NextSelectionRight
|
|
33
36
|
_attributes.NextSelectionUp = props.NextSelectionUp
|
|
34
|
-
_attributes.Position = SizeHelper:GetPosition(props)
|
|
37
|
+
_attributes.Position = if centerViaLayout then UDim2.fromOffset(0, 0) else SizeHelper:GetPosition(props)
|
|
35
38
|
_attributes.Rotation = props.Rotation
|
|
36
39
|
_attributes.Selectable = props.Selectable
|
|
37
40
|
_attributes.SelectionGroup = props.SelectionGroup
|
|
@@ -64,9 +67,22 @@ local Container = React.forwardRef(function(props, ref)
|
|
|
64
67
|
_attributes.Style = props.Style
|
|
65
68
|
_attributes.Change = props.Change
|
|
66
69
|
_attributes.Event = props.Event
|
|
67
|
-
|
|
70
|
+
local content = (React.createElement("frame", _attributes, React.createElement(Group.Element, {
|
|
68
71
|
enabled = props.group,
|
|
69
|
-
}, props.children))
|
|
72
|
+
}, props.children)))
|
|
73
|
+
if not centerViaLayout then
|
|
74
|
+
return content
|
|
75
|
+
end
|
|
76
|
+
return React.createElement("frame", {
|
|
77
|
+
Size = UDim2.fromScale(1, 1),
|
|
78
|
+
BackgroundTransparency = 1,
|
|
79
|
+
ZIndex = props.ZIndex,
|
|
80
|
+
LayoutOrder = props.LayoutOrder,
|
|
81
|
+
}, React.createElement("uilistlayout", {
|
|
82
|
+
FillDirection = Enum.FillDirection.Horizontal,
|
|
83
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
84
|
+
VerticalAlignment = Enum.VerticalAlignment.Center,
|
|
85
|
+
}), content)
|
|
70
86
|
end)
|
|
71
87
|
return {
|
|
72
88
|
Container = Container,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "@rbxts/react";
|
|
1
|
+
import React, { Binding } from "@rbxts/react";
|
|
2
2
|
import { SpacedElementProps } from "../../Interfaces";
|
|
3
3
|
interface HStackProps extends SpacedElementProps {
|
|
4
4
|
children?: React.ReactNode;
|
|
@@ -7,6 +7,7 @@ interface HStackProps extends SpacedElementProps {
|
|
|
7
7
|
HorizontalFlex?: Enum.UIFlexAlignment;
|
|
8
8
|
Event?: React.InstanceEvent<UIListLayout>;
|
|
9
9
|
Change?: React.InstanceChangeEvent<UIListLayout>;
|
|
10
|
+
Padding?: UDim | Binding<UDim>;
|
|
10
11
|
}
|
|
11
12
|
export declare function HStack(props: HStackProps): React.JSX.Element;
|
|
12
13
|
export {};
|