@rbxts-ui/components 2.0.0 → 2.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.
Files changed (56) hide show
  1. package/dist/Accordion.d.ts +16 -0
  2. package/dist/Accordion.luau +105 -0
  3. package/dist/Button.d.ts +15 -0
  4. package/dist/Button.luau +66 -0
  5. package/dist/Checkbox.d.ts +13 -0
  6. package/dist/Checkbox.luau +113 -0
  7. package/dist/CheckboxRow.d.ts +14 -0
  8. package/dist/CheckboxRow.luau +52 -0
  9. package/dist/ClickOutsideOverlay.d.ts +11 -0
  10. package/dist/ClickOutsideOverlay.luau +35 -0
  11. package/dist/Dropdown.d.ts +18 -0
  12. package/dist/Dropdown.luau +160 -0
  13. package/dist/DropdownButton.d.ts +22 -0
  14. package/dist/DropdownButton.luau +111 -0
  15. package/dist/DropdownOptionButton.d.ts +13 -0
  16. package/dist/DropdownOptionButton.luau +70 -0
  17. package/dist/FormRow.d.ts +11 -0
  18. package/dist/FormRow.luau +39 -0
  19. package/dist/IconRoundButton.d.ts +23 -0
  20. package/dist/IconRoundButton.luau +149 -0
  21. package/dist/IconTileButton.d.ts +14 -0
  22. package/dist/IconTileButton.luau +89 -0
  23. package/dist/Legend.d.ts +11 -0
  24. package/dist/Legend.luau +54 -0
  25. package/dist/Outline.d.ts +16 -0
  26. package/dist/Outline.luau +102 -0
  27. package/dist/PillText.d.ts +8 -0
  28. package/dist/PillText.luau +69 -0
  29. package/dist/PrimaryButton.d.ts +25 -0
  30. package/dist/PrimaryButton.luau +89 -0
  31. package/dist/Radio.d.ts +13 -0
  32. package/dist/Radio.luau +110 -0
  33. package/dist/RadioRow.d.ts +10 -0
  34. package/dist/RadioRow.luau +50 -0
  35. package/dist/ReactiveButton.d.ts +34 -0
  36. package/dist/ReactiveButton.luau +168 -0
  37. package/dist/Section.d.ts +12 -0
  38. package/dist/Section.luau +54 -0
  39. package/dist/SegmentedToggle.d.ts +19 -0
  40. package/dist/SegmentedToggle.luau +120 -0
  41. package/dist/TextButton.d.ts +32 -0
  42. package/dist/TextButton.luau +125 -0
  43. package/dist/TimeAgo.d.ts +8 -0
  44. package/dist/TimeAgo.luau +48 -0
  45. package/dist/index.d.ts +26 -0
  46. package/dist/init.luau +37 -0
  47. package/dist/theme.d.ts +41 -0
  48. package/dist/theme.luau +58 -0
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/use-button-animation.d.ts +38 -0
  51. package/dist/use-button-animation.luau +83 -0
  52. package/dist/use-button-state.d.ts +13 -0
  53. package/dist/use-button-state.luau +81 -0
  54. package/dist/use-input-device.d.ts +7 -0
  55. package/dist/use-input-device.luau +38 -0
  56. package/package.json +13 -3
@@ -0,0 +1,102 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
4
+ local blend = _pretty_react_hooks.blend
5
+ local composeBindings = _pretty_react_hooks.composeBindings
6
+ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
+ local React = _react
8
+ local useMemo = _react.useMemo
9
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
10
+ local Group = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Group
11
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
12
+ local function ceilEven(n)
13
+ return math.ceil(n / 2) * 2
14
+ end
15
+ local function Outline(_param)
16
+ local outlineTransparency = _param.outlineTransparency
17
+ if outlineTransparency == nil then
18
+ outlineTransparency = 0
19
+ end
20
+ local innerColor = _param.innerColor
21
+ local outerColor = _param.outerColor
22
+ local innerTransparency = _param.innerTransparency
23
+ if innerTransparency == nil then
24
+ innerTransparency = 0.9
25
+ end
26
+ local outerTransparency = _param.outerTransparency
27
+ if outerTransparency == nil then
28
+ outerTransparency = 0.85
29
+ end
30
+ local innerThickness = _param.innerThickness
31
+ local outerThickness = _param.outerThickness
32
+ local cornerRadius = _param.cornerRadius
33
+ local children = _param.children
34
+ local theme = _param.theme
35
+ if theme == nil then
36
+ theme = defaultTheme
37
+ end
38
+ local rem = useRem()
39
+ local defaultInnerColor = innerColor or theme.palette.white
40
+ local defaultOuterColor = outerColor or theme.palette.black
41
+ if innerThickness == nil then
42
+ innerThickness = rem(3, "pixel")
43
+ end
44
+ if outerThickness == nil then
45
+ outerThickness = rem(1.5, "pixel")
46
+ end
47
+ if cornerRadius == nil then
48
+ cornerRadius = UDim.new(0, rem(0.5))
49
+ end
50
+ local innerStyle = useMemo(function()
51
+ local size = composeBindings(innerThickness, function(thickness)
52
+ return UDim2.new(1, ceilEven(-2 * thickness), 1, ceilEven(-2 * thickness))
53
+ end)
54
+ local position = composeBindings(innerThickness, function(thickness)
55
+ return UDim2.new(0, thickness, 0, thickness)
56
+ end)
57
+ local radius = composeBindings(cornerRadius, innerThickness, function(radius, thickness)
58
+ local _radius = radius
59
+ local _uDim = UDim.new(0, thickness)
60
+ return _radius - _uDim
61
+ end)
62
+ local transparency = composeBindings(outlineTransparency, innerTransparency, function(a, b)
63
+ return math.clamp(blend(a, b), 0, 1)
64
+ end)
65
+ return {
66
+ size = size,
67
+ position = position,
68
+ radius = radius,
69
+ transparency = transparency,
70
+ }
71
+ end, { innerThickness, innerTransparency, cornerRadius, outlineTransparency, rem })
72
+ local outerStyle = useMemo(function()
73
+ local transparency = composeBindings(outlineTransparency, outerTransparency, function(a, b)
74
+ return math.clamp(blend(a, b), 0, 1)
75
+ end)
76
+ return {
77
+ transparency = transparency,
78
+ }
79
+ end, { outlineTransparency, outerTransparency })
80
+ return React.createElement(React.Fragment, nil, React.createElement(Group, {
81
+ size = innerStyle.size,
82
+ position = innerStyle.position,
83
+ name = "InnerOutline",
84
+ }, React.createElement("uicorner", {
85
+ CornerRadius = innerStyle.radius,
86
+ }), React.createElement("uistroke", {
87
+ Color = defaultInnerColor,
88
+ Transparency = innerStyle.transparency,
89
+ Thickness = innerThickness,
90
+ }, children)), React.createElement(Group, {
91
+ name = "OuterOutline",
92
+ }, React.createElement("uicorner", {
93
+ CornerRadius = cornerRadius,
94
+ }), React.createElement("uistroke", {
95
+ Color = defaultOuterColor,
96
+ Transparency = outerStyle.transparency,
97
+ Thickness = outerThickness,
98
+ }, children)))
99
+ end
100
+ return {
101
+ Outline = Outline,
102
+ }
@@ -0,0 +1,8 @@
1
+ import { type TextProps } from "@rbxts-ui/primitives";
2
+ import { type Theme } from "./theme";
3
+ interface PillTextProps extends TextProps {
4
+ theme?: Theme;
5
+ }
6
+ export declare function PillText(props: PillTextProps): JSX.Element;
7
+ export type { PillTextProps };
8
+ //# sourceMappingURL=PillText.d.ts.map
@@ -0,0 +1,69 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local Object = TS.import(script, TS.getModule(script, "@rbxts", "object-utils"))
4
+ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
5
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
6
+ local omit = TS.import(script, TS.getModule(script, "@rbxts-ui", "utils").dist).omit
7
+ local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
8
+ local Outline = TS.import(script, script.Parent, "Outline").Outline
9
+ local Padding = TS.import(script, script.Parent, "Padding").Padding
10
+ local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
11
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
12
+ local WIDTH = 3
13
+ local HEIGHT = 2
14
+ local function PillText(props)
15
+ local _binding = props
16
+ local text = _binding.text
17
+ local textColor = _binding.textColor
18
+ local position = _binding.position
19
+ local name = _binding.name
20
+ local zIndex = _binding.zIndex
21
+ local anchorPoint = _binding.anchorPoint
22
+ local theme = _binding.theme
23
+ if theme == nil then
24
+ theme = defaultTheme
25
+ end
26
+ local textProps = Object.assign({}, omit(props, { "position", "name", "text", "textColor", "zIndex", "anchorPoint", "theme" }))
27
+ local rem = useRem()
28
+ local cornerRadius = UDim.new(0, rem(3))
29
+ local _exp = React.createElement(Frame, {
30
+ backgroundColor = theme.palette.black,
31
+ backgroundTransparency = 0.3,
32
+ cornerRadius = cornerRadius,
33
+ size = UDim2.new(1, 0, 1, 0),
34
+ zIndex = 1,
35
+ })
36
+ local _exp_1 = React.createElement(Outline, {
37
+ cornerRadius = cornerRadius,
38
+ innerTransparency = 1,
39
+ innerColor = theme.palette.black,
40
+ outerTransparency = 0,
41
+ outerColor = theme.palette.black,
42
+ theme = theme,
43
+ })
44
+ local _attributes = {
45
+ text = `{text}`,
46
+ textSize = rem(1),
47
+ textColor = textColor or theme.palette.text,
48
+ richText = true,
49
+ automaticSize = Enum.AutomaticSize.XY,
50
+ rem = rem,
51
+ }
52
+ for _k, _v in textProps do
53
+ _attributes[_k] = _v
54
+ end
55
+ return React.createElement(Frame, {
56
+ size = UDim2.new(0, WIDTH, 0, HEIGHT),
57
+ position = position,
58
+ name = name,
59
+ zIndex = zIndex,
60
+ automaticSize = Enum.AutomaticSize.XY,
61
+ anchorPoint = anchorPoint,
62
+ }, _exp, _exp_1, React.createElement(Text, _attributes, React.createElement(Padding, {
63
+ paddingY = rem(0.7),
64
+ paddingX = rem(1.5),
65
+ })))
66
+ end
67
+ return {
68
+ PillText = PillText,
69
+ }
@@ -0,0 +1,25 @@
1
+ import React from "@rbxts/react";
2
+ import { type Theme } from "./theme";
3
+ interface PrimaryButtonProps extends React.PropsWithChildren {
4
+ name?: string;
5
+ readonly onClick?: () => void;
6
+ readonly onHover?: (hovered: boolean) => void;
7
+ readonly size?: UDim2 | React.Binding<UDim2>;
8
+ readonly position?: UDim2 | React.Binding<UDim2>;
9
+ readonly anchorPoint?: Vector2 | React.Binding<Vector2>;
10
+ readonly backgroundColor?: Color3 | React.Binding<Color3>;
11
+ readonly backgroundTransparency?: number | React.Binding<number>;
12
+ readonly overlayGradient?: ColorSequence | React.Binding<ColorSequence>;
13
+ readonly overlayTransparency?: number | React.Binding<number>;
14
+ readonly overlayRotation?: number | React.Binding<number>;
15
+ readonly layoutOrder?: number | React.Binding<number>;
16
+ readonly hasShadow?: boolean;
17
+ readonly hasOutline?: boolean;
18
+ readonly hasGlow?: boolean;
19
+ readonly hasBackground?: boolean;
20
+ readonly automaticSize?: Enum.AutomaticSize;
21
+ readonly theme?: Theme;
22
+ }
23
+ export declare function PrimaryButton({ name, onClick, onHover, size, position, anchorPoint, backgroundColor, backgroundTransparency, hasBackground, overlayGradient, overlayTransparency, overlayRotation, layoutOrder, hasShadow, hasOutline, hasGlow, automaticSize, children, theme, }: PrimaryButtonProps): JSX.Element;
24
+ export type { PrimaryButtonProps };
25
+ //# sourceMappingURL=PrimaryButton.d.ts.map
@@ -0,0 +1,89 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
4
+ local lerpBinding = _pretty_react_hooks.lerpBinding
5
+ local useMotion = _pretty_react_hooks.useMotion
6
+ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
8
+ local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
9
+ local Outline = TS.import(script, script.Parent, "Outline").Outline
10
+ local ReactiveButton = TS.import(script, script.Parent, "ReactiveButton").ReactiveButton
11
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
12
+ local function PrimaryButton(_param)
13
+ local name = _param.name
14
+ local onClick = _param.onClick
15
+ local onHover = _param.onHover
16
+ local size = _param.size
17
+ local position = _param.position
18
+ local anchorPoint = _param.anchorPoint
19
+ local backgroundColor = _param.backgroundColor
20
+ local backgroundTransparency = _param.backgroundTransparency
21
+ if backgroundTransparency == nil then
22
+ backgroundTransparency = 0
23
+ end
24
+ local hasBackground = _param.hasBackground
25
+ if hasBackground == nil then
26
+ hasBackground = true
27
+ end
28
+ local overlayGradient = _param.overlayGradient
29
+ local overlayTransparency = _param.overlayTransparency
30
+ if overlayTransparency == nil then
31
+ overlayTransparency = 0
32
+ end
33
+ local overlayRotation = _param.overlayRotation
34
+ local layoutOrder = _param.layoutOrder
35
+ local hasShadow = _param.hasShadow
36
+ if hasShadow == nil then
37
+ hasShadow = true
38
+ end
39
+ local hasOutline = _param.hasOutline
40
+ if hasOutline == nil then
41
+ hasOutline = true
42
+ end
43
+ local hasGlow = _param.hasGlow
44
+ if hasGlow == nil then
45
+ hasGlow = true
46
+ end
47
+ local automaticSize = _param.automaticSize
48
+ local children = _param.children
49
+ local theme = _param.theme
50
+ if theme == nil then
51
+ theme = defaultTheme
52
+ end
53
+ local rem = useRem()
54
+ local hover, hoverMotion = useMotion(0)
55
+ return React.createElement(ReactiveButton, {
56
+ automaticSize = automaticSize,
57
+ name = name,
58
+ onClick = onClick,
59
+ onHover = function(hovered)
60
+ hoverMotion:spring(if hovered then 1 else 0)
61
+ local _result = onHover
62
+ if _result ~= nil then
63
+ _result(hovered)
64
+ end
65
+ end,
66
+ backgroundTransparency = 1,
67
+ anchorPoint = anchorPoint,
68
+ size = size,
69
+ position = position,
70
+ layoutOrder = layoutOrder,
71
+ theme = theme,
72
+ }, if hasBackground then (React.createElement(Frame, {
73
+ backgroundColor = backgroundColor,
74
+ cornerRadius = UDim.new(0, rem(1)),
75
+ size = UDim2.new(1, 0, 1, 0),
76
+ backgroundTransparency = backgroundTransparency,
77
+ }, React.createElement("uigradient", {
78
+ Offset = lerpBinding(hover, Vector2.new(), Vector2.new(0, 1)),
79
+ Rotation = 90,
80
+ Transparency = NumberSequence.new(0, 0.1),
81
+ }))) else nil, if hasOutline then React.createElement(Outline, {
82
+ cornerRadius = UDim.new(0, rem(1)),
83
+ innerTransparency = 0,
84
+ theme = theme,
85
+ }) else nil, children)
86
+ end
87
+ return {
88
+ PrimaryButton = PrimaryButton,
89
+ }
@@ -0,0 +1,13 @@
1
+ import { type Theme } from "./theme";
2
+ interface RadioProps {
3
+ checked: boolean;
4
+ onChecked: (checked: boolean) => void;
5
+ text?: string;
6
+ variant?: "default" | "large" | "small";
7
+ position?: UDim2;
8
+ disabled?: boolean;
9
+ theme?: Theme;
10
+ }
11
+ export declare function Radio({ checked, onChecked, text, variant, position, disabled, theme }: RadioProps): JSX.Element;
12
+ export type { RadioProps };
13
+ //# sourceMappingURL=Radio.d.ts.map
@@ -0,0 +1,110 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
4
+ local lerpBinding = _pretty_react_hooks.lerpBinding
5
+ local useMotion = _pretty_react_hooks.useMotion
6
+ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
+ local React = _react
8
+ local useMemo = _react.useMemo
9
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
10
+ local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
11
+ local Outline = TS.import(script, script.Parent, "Outline").Outline
12
+ local ReactiveButton = TS.import(script, script.Parent, "ReactiveButton").ReactiveButton
13
+ local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
14
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
15
+ local function Radio(_param)
16
+ local checked = _param.checked
17
+ local onChecked = _param.onChecked
18
+ local text = _param.text
19
+ local variant = _param.variant
20
+ if variant == nil then
21
+ variant = "default"
22
+ end
23
+ local position = _param.position
24
+ local disabled = _param.disabled
25
+ if disabled == nil then
26
+ disabled = false
27
+ end
28
+ local theme = _param.theme
29
+ if theme == nil then
30
+ theme = defaultTheme
31
+ end
32
+ local rem = useRem()
33
+ local hover, hoverMotion = useMotion(0)
34
+ local checkboxSize = if variant == "large" then 4 elseif variant == "small" then 1.7 else 3
35
+ local buttonSize = UDim2.new(0, rem(checkboxSize), 0, rem(checkboxSize))
36
+ local textWidth, textWidthMotion = useMotion({
37
+ label = 0,
38
+ value = 0,
39
+ })
40
+ local size = useMemo(function()
41
+ return textWidth:map(function(_param_1)
42
+ local label = _param_1.label
43
+ local value = _param_1.value
44
+ local content = math.max(label, value)
45
+ local width = checkboxSize
46
+ return UDim2.new(0, rem(width) + content, 0, rem(checkboxSize))
47
+ end)
48
+ end, { rem })
49
+ local cornerRadius = UDim.new(1, 0)
50
+ local mainColor = if disabled then theme.palette.overlay0 else theme.palette.black
51
+ local textColor = if disabled then theme.palette.overlay0 else theme.palette.black
52
+ return React.createElement(ReactiveButton, {
53
+ backgroundTransparency = 1,
54
+ size = size,
55
+ position = position,
56
+ onClick = function()
57
+ return not disabled and onChecked(not checked)
58
+ end,
59
+ onHover = function(hovered)
60
+ return hoverMotion:spring(if hovered then 1 else 0)
61
+ end,
62
+ theme = theme,
63
+ }, React.createElement("uilistlayout", {
64
+ FillDirection = "Horizontal",
65
+ VerticalAlignment = "Center",
66
+ Padding = UDim.new(0, 8),
67
+ }), React.createElement(Frame, {
68
+ backgroundTransparency = 1,
69
+ size = buttonSize,
70
+ }, React.createElement(Frame, {
71
+ backgroundColor = theme.palette.white,
72
+ cornerRadius = cornerRadius,
73
+ size = UDim2.new(1, 0, 1, 0),
74
+ }, React.createElement("uigradient", {
75
+ Offset = lerpBinding(hover, Vector2.new(), Vector2.new(0, 1)),
76
+ Rotation = 90,
77
+ Transparency = NumberSequence.new(0, 0.1),
78
+ })), React.createElement(Outline, {
79
+ outerColor = mainColor,
80
+ innerColor = mainColor,
81
+ cornerRadius = cornerRadius,
82
+ innerTransparency = 0,
83
+ outerTransparency = 1,
84
+ innerThickness = 2,
85
+ theme = theme,
86
+ }), if checked then (React.createElement(Frame, {
87
+ backgroundColor = theme.palette.blue,
88
+ backgroundTransparency = 0,
89
+ size = UDim2.new(0.7, 0, 0.7, 0),
90
+ position = UDim2.new(0.5, 0, 0.5, 0),
91
+ anchorPoint = Vector2.new(0.5, 0.5),
92
+ }, React.createElement("uicorner", {
93
+ CornerRadius = cornerRadius,
94
+ }))) else nil), if text ~= "" and text then (React.createElement(Text, {
95
+ text = text,
96
+ size = UDim2.new(0, rem(2), 0, rem(2)),
97
+ textColor = textColor,
98
+ textXAlignment = "Left",
99
+ change = {
100
+ TextBounds = function(rbx)
101
+ textWidthMotion:spring({
102
+ value = rbx.TextBounds.X,
103
+ })
104
+ end,
105
+ },
106
+ })) else nil)
107
+ end
108
+ return {
109
+ Radio = Radio,
110
+ }
@@ -0,0 +1,10 @@
1
+ import { type Theme } from "./theme";
2
+ export interface RadioRowProps {
3
+ label: string;
4
+ checked: boolean;
5
+ onChecked: () => void;
6
+ disabled?: boolean;
7
+ theme?: Theme;
8
+ }
9
+ export declare function RadioRow({ label, checked, onChecked, disabled, theme, }: RadioRowProps): JSX.Element;
10
+ //# sourceMappingURL=RadioRow.d.ts.map
@@ -0,0 +1,50 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local HStack = TS.import(script, TS.getModule(script, "@rbxts-ui", "layout").dist).HStack
4
+ local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
5
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
6
+ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
7
+ local Button = TS.import(script, script.Parent, "Button").Button
8
+ local Radio = TS.import(script, script.Parent, "Radio").Radio
9
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
10
+ local function RadioRow(_param)
11
+ local label = _param.label
12
+ local checked = _param.checked
13
+ local onChecked = _param.onChecked
14
+ local disabled = _param.disabled
15
+ local theme = _param.theme
16
+ if theme == nil then
17
+ theme = defaultTheme
18
+ end
19
+ local rem = useRem()
20
+ local textSize = rem(3)
21
+ return React.createElement(HStack, {
22
+ size = UDim2.new(1, 0, 0, 0),
23
+ automaticSize = Enum.AutomaticSize.Y,
24
+ spacing = rem(2),
25
+ }, React.createElement(Radio, {
26
+ checked = checked,
27
+ variant = "large",
28
+ onChecked = onChecked,
29
+ disabled = disabled,
30
+ theme = theme,
31
+ }), React.createElement(Button, {
32
+ backgroundTransparency = 1,
33
+ size = UDim2.new(1, 0, 0, rem(4)),
34
+ onClick = onChecked,
35
+ }, React.createElement(Text, {
36
+ text = label,
37
+ textSize = textSize,
38
+ textScaled = true,
39
+ textColor = if disabled then theme.palette.disabled else theme.palette.crust,
40
+ size = UDim2.new(0.8, 0, 0, rem(4)),
41
+ textXAlignment = "Left",
42
+ }, React.createElement("uiflexitem", {
43
+ FlexMode = Enum.UIFlexMode.Fill,
44
+ }))), React.createElement("uiflexitem", {
45
+ FlexMode = Enum.UIFlexMode.Fill,
46
+ }))
47
+ end
48
+ return {
49
+ RadioRow = RadioRow,
50
+ }
@@ -0,0 +1,34 @@
1
+ import React from "@rbxts/react";
2
+ import { type Theme } from "./theme";
3
+ interface ReactiveButtonProps extends React.PropsWithChildren {
4
+ name?: string;
5
+ onClick?: () => void;
6
+ onMouseDown?: () => void;
7
+ onMouseUp?: () => void;
8
+ onMouseEnter?: () => void;
9
+ onMouseLeave?: () => void;
10
+ onHover?: (hovered: boolean) => void;
11
+ onPress?: (pressed: boolean) => void;
12
+ enabled?: boolean;
13
+ size?: UDim2 | React.Binding<UDim2>;
14
+ position?: UDim2 | React.Binding<UDim2>;
15
+ anchorPoint?: Vector2 | React.Binding<Vector2>;
16
+ backgroundColor?: Color3 | React.Binding<Color3>;
17
+ backgroundTransparency?: number | React.Binding<number>;
18
+ cornerRadius?: UDim | React.Binding<UDim>;
19
+ layoutOrder?: number | React.Binding<number>;
20
+ animatePosition?: boolean;
21
+ animatePositionStrength?: number;
22
+ animatePositionDirection?: Vector2;
23
+ animateSize?: boolean;
24
+ animateSizeStrength?: number;
25
+ zIndex?: number | React.Binding<number>;
26
+ event?: React.InstanceEvent<TextButton>;
27
+ change?: React.InstanceChangeEvent<TextButton>;
28
+ fill?: boolean;
29
+ automaticSize?: Enum.AutomaticSize;
30
+ theme?: Theme;
31
+ }
32
+ export declare function ReactiveButton({ name, onClick, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onHover, onPress, enabled, size, position, anchorPoint, backgroundColor, backgroundTransparency, cornerRadius, layoutOrder, zIndex, animatePosition, animatePositionStrength, animatePositionDirection, animateSize, animateSizeStrength, event, change, children, fill, automaticSize, theme, }: ReactiveButtonProps): JSX.Element;
33
+ export type { ReactiveButtonProps };
34
+ //# sourceMappingURL=ReactiveButton.d.ts.map
@@ -0,0 +1,168 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
4
+ local blend = _pretty_react_hooks.blend
5
+ local composeBindings = _pretty_react_hooks.composeBindings
6
+ local lerpBinding = _pretty_react_hooks.lerpBinding
7
+ local useMotion = _pretty_react_hooks.useMotion
8
+ local useUpdateEffect = _pretty_react_hooks.useUpdateEffect
9
+ local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
10
+ local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
11
+ local Button = TS.import(script, script.Parent, "Button").Button
12
+ local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
13
+ local useButtonAnimation = TS.import(script, script.Parent, "use-button-animation").useButtonAnimation
14
+ local useButtonState = TS.import(script, script.Parent, "use-button-state").useButtonState
15
+ local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
16
+ local function ReactiveButton(_param)
17
+ local name = _param.name
18
+ local onClick = _param.onClick
19
+ local onMouseDown = _param.onMouseDown
20
+ local onMouseUp = _param.onMouseUp
21
+ local onMouseEnter = _param.onMouseEnter
22
+ local onMouseLeave = _param.onMouseLeave
23
+ local onHover = _param.onHover
24
+ local onPress = _param.onPress
25
+ local enabled = _param.enabled
26
+ if enabled == nil then
27
+ enabled = true
28
+ end
29
+ local size = _param.size
30
+ local position = _param.position
31
+ local anchorPoint = _param.anchorPoint
32
+ local backgroundColor = _param.backgroundColor
33
+ if backgroundColor == nil then
34
+ backgroundColor = Color3.fromRGB(255, 255, 255)
35
+ end
36
+ local backgroundTransparency = _param.backgroundTransparency
37
+ if backgroundTransparency == nil then
38
+ backgroundTransparency = 0
39
+ end
40
+ local cornerRadius = _param.cornerRadius
41
+ local layoutOrder = _param.layoutOrder
42
+ local zIndex = _param.zIndex
43
+ local animatePosition = _param.animatePosition
44
+ if animatePosition == nil then
45
+ animatePosition = true
46
+ end
47
+ local animatePositionStrength = _param.animatePositionStrength
48
+ if animatePositionStrength == nil then
49
+ animatePositionStrength = 1
50
+ end
51
+ local animatePositionDirection = _param.animatePositionDirection
52
+ if animatePositionDirection == nil then
53
+ animatePositionDirection = Vector2.new(0, 1)
54
+ end
55
+ local animateSize = _param.animateSize
56
+ if animateSize == nil then
57
+ animateSize = true
58
+ end
59
+ local animateSizeStrength = _param.animateSizeStrength
60
+ if animateSizeStrength == nil then
61
+ animateSizeStrength = 1
62
+ end
63
+ local event = _param.event
64
+ local change = _param.change
65
+ local children = _param.children
66
+ local fill = _param.fill
67
+ if fill == nil then
68
+ fill = false
69
+ end
70
+ local automaticSize = _param.automaticSize
71
+ local theme = _param.theme
72
+ if theme == nil then
73
+ theme = defaultTheme
74
+ end
75
+ local rem = useRem()
76
+ local sizeAnimation, sizeMotion = useMotion(0)
77
+ local press, hover, buttonEvents = useButtonState(enabled)
78
+ local animation = useButtonAnimation(press, hover, theme)
79
+ useUpdateEffect(function()
80
+ if press then
81
+ sizeMotion:spring(-0.1, {
82
+ tension = 300,
83
+ })
84
+ else
85
+ sizeMotion:spring(0, {
86
+ impulse = 0.01,
87
+ tension = 300,
88
+ })
89
+ end
90
+ end, { press })
91
+ useUpdateEffect(function()
92
+ local _result = onHover
93
+ if _result ~= nil then
94
+ _result(hover)
95
+ end
96
+ end, { hover })
97
+ useUpdateEffect(function()
98
+ local _result = onPress
99
+ if _result ~= nil then
100
+ _result(press)
101
+ end
102
+ end, { press })
103
+ return React.createElement(Button, {
104
+ name = name,
105
+ onClick = if enabled then onClick else nil,
106
+ active = enabled,
107
+ onMouseDown = function()
108
+ if not enabled then
109
+ return nil
110
+ end
111
+ buttonEvents.onMouseDown()
112
+ local _result = onMouseDown
113
+ if _result ~= nil then
114
+ _result()
115
+ end
116
+ end,
117
+ onMouseUp = function()
118
+ if not enabled then
119
+ return nil
120
+ end
121
+ buttonEvents.onMouseUp()
122
+ local _result = onMouseUp
123
+ if _result ~= nil then
124
+ _result()
125
+ end
126
+ end,
127
+ onMouseEnter = function()
128
+ buttonEvents.onMouseEnter()
129
+ local _result = onMouseEnter
130
+ if _result ~= nil then
131
+ _result()
132
+ end
133
+ end,
134
+ onMouseLeave = function()
135
+ buttonEvents.onMouseLeave()
136
+ local _result = onMouseLeave
137
+ if _result ~= nil then
138
+ _result()
139
+ end
140
+ end,
141
+ backgroundTransparency = 1,
142
+ size = size,
143
+ position = position,
144
+ anchorPoint = anchorPoint,
145
+ layoutOrder = layoutOrder,
146
+ zIndex = zIndex,
147
+ event = event,
148
+ change = change,
149
+ automaticSize = automaticSize,
150
+ }, if fill then React.createElement("uiflexitem", {
151
+ FlexMode = Enum.UIFlexMode.Fill,
152
+ }) else nil, React.createElement(Frame, {
153
+ automaticSize = automaticSize,
154
+ backgroundColor = composeBindings(animation.hoverOnly, animation.press, backgroundColor, function(hover, press, color)
155
+ return color:Lerp(Color3.new(1, 1, 1), hover * 0.15):Lerp(Color3.new(), press * 0.1)
156
+ end),
157
+ backgroundTransparency = composeBindings(animation.press, backgroundTransparency, function(press, transparency)
158
+ return blend(-press * 0.2, transparency)
159
+ end),
160
+ cornerRadius = cornerRadius,
161
+ anchorPoint = Vector2.new(0.5, 0.5),
162
+ size = lerpBinding(if animateSize then sizeAnimation else 0, UDim2.new(1, 0, 1, 0), UDim2.new(1, rem(2 * animateSizeStrength), 1, rem(2 * animateSizeStrength))),
163
+ position = UDim2.new(0.5, 0, 0.5, 0),
164
+ }, children))
165
+ end
166
+ return {
167
+ ReactiveButton = ReactiveButton,
168
+ }