@rbxts-ui/components 2.0.0 → 3.0.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/dist/DynamicWindow/DynamicWindow.d.ts +19 -0
- package/dist/DynamicWindow/DynamicWindow.luau +327 -0
- package/dist/DynamicWindow/DynamicWindow.utils.d.ts +13 -0
- package/dist/DynamicWindow/DynamicWindow.utils.luau +46 -0
- package/dist/DynamicWindow/ResizeCornerButton.d.ts +13 -0
- package/dist/DynamicWindow/ResizeCornerButton.luau +47 -0
- package/dist/DynamicWindow/TrafficLightButton.d.ts +8 -0
- package/dist/DynamicWindow/TrafficLightButton.luau +26 -0
- package/dist/buttons/Button.d.ts +15 -0
- package/dist/buttons/Button.luau +66 -0
- package/dist/buttons/DropdownButton.d.ts +20 -0
- package/dist/buttons/DropdownButton.luau +106 -0
- package/dist/buttons/DropdownOptionButton.d.ts +11 -0
- package/dist/buttons/DropdownOptionButton.luau +66 -0
- package/dist/buttons/IconRoundButton.d.ts +21 -0
- package/dist/buttons/IconRoundButton.luau +145 -0
- package/dist/buttons/IconTileButton.d.ts +12 -0
- package/dist/buttons/IconTileButton.luau +86 -0
- package/dist/buttons/PrimaryButton.d.ts +23 -0
- package/dist/buttons/PrimaryButton.luau +84 -0
- package/dist/buttons/ReactiveButton.d.ts +32 -0
- package/dist/buttons/ReactiveButton.luau +163 -0
- package/dist/buttons/TextButton.d.ts +30 -0
- package/dist/buttons/TextButton.luau +121 -0
- package/dist/{Checkmark.luau → display/Checkmark.luau} +1 -1
- package/dist/display/Legend.d.ts +11 -0
- package/dist/display/Legend.luau +54 -0
- package/dist/display/PillText.d.ts +6 -0
- package/dist/display/PillText.luau +65 -0
- package/dist/display/TimeAgo.d.ts +8 -0
- package/dist/display/TimeAgo.luau +48 -0
- package/dist/error-handler/ErrorHandler.d.ts +3 -0
- package/dist/error-handler/ErrorHandler.luau +18 -0
- package/dist/error-handler/ErrorPage.d.ts +6 -0
- package/dist/error-handler/ErrorPage.luau +144 -0
- package/dist/error-handler/index.d.ts +3 -0
- package/dist/error-handler/init.luau +6 -0
- package/dist/form/Checkbox.d.ts +11 -0
- package/dist/form/Checkbox.luau +108 -0
- package/dist/form/CheckboxRow.d.ts +12 -0
- package/dist/form/CheckboxRow.luau +48 -0
- package/dist/form/Dropdown.d.ts +16 -0
- package/dist/form/Dropdown.luau +155 -0
- package/dist/form/DropdownRow.d.ts +18 -0
- package/dist/form/DropdownRow.luau +28 -0
- package/dist/form/FormRow.d.ts +9 -0
- package/dist/form/FormRow.luau +36 -0
- package/dist/form/InputRound.d.ts +18 -0
- package/dist/form/InputRound.luau +218 -0
- package/dist/form/InputRow.d.ts +13 -0
- package/dist/form/InputRow.luau +32 -0
- package/dist/form/Radio.d.ts +11 -0
- package/dist/form/Radio.luau +105 -0
- package/dist/form/RadioRow.d.ts +8 -0
- package/dist/form/RadioRow.luau +46 -0
- package/dist/form/RoundEmoji.d.ts +8 -0
- package/dist/form/RoundEmoji.luau +40 -0
- package/dist/form/TextBox.d.ts +24 -0
- package/dist/form/TextBox.luau +57 -0
- package/dist/{TextField.d.ts → form/TextField.d.ts} +1 -1
- package/dist/{TextField.luau → form/TextField.luau} +4 -2
- package/dist/form/validation.d.ts +13 -0
- package/dist/form/validation.luau +80 -0
- package/dist/hooks/use-button-animation.d.ts +36 -0
- package/dist/hooks/use-button-animation.luau +80 -0
- package/dist/hooks/use-button-state.d.ts +13 -0
- package/dist/hooks/use-button-state.luau +81 -0
- package/dist/hooks/use-input-device.d.ts +7 -0
- package/dist/hooks/use-input-device.luau +38 -0
- package/dist/index.d.ts +48 -6
- package/dist/init.luau +72 -6
- package/dist/layout/Accordion.d.ts +14 -0
- package/dist/layout/Accordion.luau +101 -0
- package/dist/{Divider.luau → layout/Divider.luau} +1 -1
- package/dist/layout/Section.d.ts +10 -0
- package/dist/layout/Section.luau +51 -0
- package/dist/layout/SegmentedToggle.d.ts +17 -0
- package/dist/layout/SegmentedToggle.luau +117 -0
- package/dist/layout/SegmentedToggle.story.d.ts +10 -0
- package/dist/layout/SegmentedToggle.story.luau +72 -0
- package/dist/table/ExampleTable.d.ts +2 -0
- package/dist/table/ExampleTable.luau +46 -0
- package/dist/table/Table.d.ts +10 -0
- package/dist/table/Table.luau +26 -0
- package/dist/table/TableCell.d.ts +9 -0
- package/dist/table/TableCell.luau +26 -0
- package/dist/table/TableFooter.d.ts +9 -0
- package/dist/table/TableFooter.luau +12 -0
- package/dist/table/TableHeader.d.ts +9 -0
- package/dist/table/TableHeader.luau +12 -0
- package/dist/table/TableRow.d.ts +9 -0
- package/dist/table/TableRow.luau +24 -0
- package/dist/tooltip/Tooltip.d.ts +14 -0
- package/dist/tooltip/Tooltip.luau +65 -0
- package/dist/tooltip/useTooltip.d.ts +12 -0
- package/dist/tooltip/useTooltip.luau +40 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/ClickOutsideOverlay.d.ts +11 -0
- package/dist/utils/ClickOutsideOverlay.luau +35 -0
- package/dist/utils/Outline.d.ts +14 -0
- package/dist/utils/Outline.luau +99 -0
- package/package.json +19 -7
- /package/dist/{Checkmark.d.ts → display/Checkmark.d.ts} +0 -0
- /package/dist/{Divider.d.ts → layout/Divider.d.ts} +0 -0
- /package/dist/{Padding.d.ts → layout/Padding.d.ts} +0 -0
- /package/dist/{Padding.luau → layout/Padding.luau} +0 -0
- /package/dist/{DelayRender.d.ts → utils/DelayRender.d.ts} +0 -0
- /package/dist/{DelayRender.luau → utils/DelayRender.luau} +0 -0
- /package/dist/{ErrorBoundary.d.ts → utils/ErrorBoundary.d.ts} +0 -0
- /package/dist/{ErrorBoundary.luau → utils/ErrorBoundary.luau} +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
|
|
4
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
5
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
6
|
+
local blend = _pretty_react_hooks.blend
|
|
7
|
+
local composeBindings = _pretty_react_hooks.composeBindings
|
|
8
|
+
local lerpBinding = _pretty_react_hooks.lerpBinding
|
|
9
|
+
local useMotion = _pretty_react_hooks.useMotion
|
|
10
|
+
local useUpdateEffect = _pretty_react_hooks.useUpdateEffect
|
|
11
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
12
|
+
local Button = TS.import(script, script.Parent, "Button").Button
|
|
13
|
+
local useButtonAnimation = TS.import(script, script.Parent.Parent, "hooks", "use-button-animation").useButtonAnimation
|
|
14
|
+
local useButtonState = TS.import(script, script.Parent.Parent, "hooks", "use-button-state").useButtonState
|
|
15
|
+
local function ReactiveButton(_param)
|
|
16
|
+
local name = _param.name
|
|
17
|
+
local onClick = _param.onClick
|
|
18
|
+
local onMouseDown = _param.onMouseDown
|
|
19
|
+
local onMouseUp = _param.onMouseUp
|
|
20
|
+
local onMouseEnter = _param.onMouseEnter
|
|
21
|
+
local onMouseLeave = _param.onMouseLeave
|
|
22
|
+
local onHover = _param.onHover
|
|
23
|
+
local onPress = _param.onPress
|
|
24
|
+
local enabled = _param.enabled
|
|
25
|
+
if enabled == nil then
|
|
26
|
+
enabled = true
|
|
27
|
+
end
|
|
28
|
+
local size = _param.size
|
|
29
|
+
local position = _param.position
|
|
30
|
+
local anchorPoint = _param.anchorPoint
|
|
31
|
+
local backgroundColor = _param.backgroundColor
|
|
32
|
+
if backgroundColor == nil then
|
|
33
|
+
backgroundColor = Color3.fromRGB(255, 255, 255)
|
|
34
|
+
end
|
|
35
|
+
local backgroundTransparency = _param.backgroundTransparency
|
|
36
|
+
if backgroundTransparency == nil then
|
|
37
|
+
backgroundTransparency = 0
|
|
38
|
+
end
|
|
39
|
+
local cornerRadius = _param.cornerRadius
|
|
40
|
+
local layoutOrder = _param.layoutOrder
|
|
41
|
+
local zIndex = _param.zIndex
|
|
42
|
+
local animatePosition = _param.animatePosition
|
|
43
|
+
if animatePosition == nil then
|
|
44
|
+
animatePosition = true
|
|
45
|
+
end
|
|
46
|
+
local animatePositionStrength = _param.animatePositionStrength
|
|
47
|
+
if animatePositionStrength == nil then
|
|
48
|
+
animatePositionStrength = 1
|
|
49
|
+
end
|
|
50
|
+
local animatePositionDirection = _param.animatePositionDirection
|
|
51
|
+
if animatePositionDirection == nil then
|
|
52
|
+
animatePositionDirection = Vector2.new(0, 1)
|
|
53
|
+
end
|
|
54
|
+
local animateSize = _param.animateSize
|
|
55
|
+
if animateSize == nil then
|
|
56
|
+
animateSize = true
|
|
57
|
+
end
|
|
58
|
+
local animateSizeStrength = _param.animateSizeStrength
|
|
59
|
+
if animateSizeStrength == nil then
|
|
60
|
+
animateSizeStrength = 1
|
|
61
|
+
end
|
|
62
|
+
local event = _param.event
|
|
63
|
+
local change = _param.change
|
|
64
|
+
local children = _param.children
|
|
65
|
+
local fill = _param.fill
|
|
66
|
+
if fill == nil then
|
|
67
|
+
fill = false
|
|
68
|
+
end
|
|
69
|
+
local automaticSize = _param.automaticSize
|
|
70
|
+
local rem = useRem()
|
|
71
|
+
local sizeAnimation, sizeMotion = useMotion(0)
|
|
72
|
+
local press, hover, buttonEvents = useButtonState(enabled)
|
|
73
|
+
local animation = useButtonAnimation(press, hover)
|
|
74
|
+
useUpdateEffect(function()
|
|
75
|
+
if press then
|
|
76
|
+
sizeMotion:spring(-0.1, {
|
|
77
|
+
tension = 300,
|
|
78
|
+
})
|
|
79
|
+
else
|
|
80
|
+
sizeMotion:spring(0, {
|
|
81
|
+
impulse = 0.01,
|
|
82
|
+
tension = 300,
|
|
83
|
+
})
|
|
84
|
+
end
|
|
85
|
+
end, { press })
|
|
86
|
+
useUpdateEffect(function()
|
|
87
|
+
local _result = onHover
|
|
88
|
+
if _result ~= nil then
|
|
89
|
+
_result(hover)
|
|
90
|
+
end
|
|
91
|
+
end, { hover })
|
|
92
|
+
useUpdateEffect(function()
|
|
93
|
+
local _result = onPress
|
|
94
|
+
if _result ~= nil then
|
|
95
|
+
_result(press)
|
|
96
|
+
end
|
|
97
|
+
end, { press })
|
|
98
|
+
return React.createElement(Button, {
|
|
99
|
+
name = name,
|
|
100
|
+
onClick = if enabled then onClick else nil,
|
|
101
|
+
active = enabled,
|
|
102
|
+
onMouseDown = function()
|
|
103
|
+
if not enabled then
|
|
104
|
+
return nil
|
|
105
|
+
end
|
|
106
|
+
buttonEvents.onMouseDown()
|
|
107
|
+
local _result = onMouseDown
|
|
108
|
+
if _result ~= nil then
|
|
109
|
+
_result()
|
|
110
|
+
end
|
|
111
|
+
end,
|
|
112
|
+
onMouseUp = function()
|
|
113
|
+
if not enabled then
|
|
114
|
+
return nil
|
|
115
|
+
end
|
|
116
|
+
buttonEvents.onMouseUp()
|
|
117
|
+
local _result = onMouseUp
|
|
118
|
+
if _result ~= nil then
|
|
119
|
+
_result()
|
|
120
|
+
end
|
|
121
|
+
end,
|
|
122
|
+
onMouseEnter = function()
|
|
123
|
+
buttonEvents.onMouseEnter()
|
|
124
|
+
local _result = onMouseEnter
|
|
125
|
+
if _result ~= nil then
|
|
126
|
+
_result()
|
|
127
|
+
end
|
|
128
|
+
end,
|
|
129
|
+
onMouseLeave = function()
|
|
130
|
+
buttonEvents.onMouseLeave()
|
|
131
|
+
local _result = onMouseLeave
|
|
132
|
+
if _result ~= nil then
|
|
133
|
+
_result()
|
|
134
|
+
end
|
|
135
|
+
end,
|
|
136
|
+
backgroundTransparency = 1,
|
|
137
|
+
size = size,
|
|
138
|
+
position = position,
|
|
139
|
+
anchorPoint = anchorPoint,
|
|
140
|
+
layoutOrder = layoutOrder,
|
|
141
|
+
zIndex = zIndex,
|
|
142
|
+
event = event,
|
|
143
|
+
change = change,
|
|
144
|
+
automaticSize = automaticSize,
|
|
145
|
+
}, if fill then React.createElement("uiflexitem", {
|
|
146
|
+
FlexMode = Enum.UIFlexMode.Fill,
|
|
147
|
+
}) else nil, React.createElement(Frame, {
|
|
148
|
+
automaticSize = automaticSize,
|
|
149
|
+
backgroundColor = composeBindings(animation.hoverOnly, animation.press, backgroundColor, function(hover, press, color)
|
|
150
|
+
return color:Lerp(Color3.new(1, 1, 1), hover * 0.15):Lerp(Color3.new(), press * 0.1)
|
|
151
|
+
end),
|
|
152
|
+
backgroundTransparency = composeBindings(animation.press, backgroundTransparency, function(press, transparency)
|
|
153
|
+
return blend(-press * 0.2, transparency)
|
|
154
|
+
end),
|
|
155
|
+
cornerRadius = cornerRadius,
|
|
156
|
+
anchorPoint = Vector2.new(0.5, 0.5),
|
|
157
|
+
size = lerpBinding(if animateSize then sizeAnimation else 0, UDim2.new(1, 0, 1, 0), UDim2.new(1, rem(2 * animateSizeStrength), 1, rem(2 * animateSizeStrength))),
|
|
158
|
+
position = UDim2.new(0.5, 0, 0.5, 0),
|
|
159
|
+
}, children))
|
|
160
|
+
end
|
|
161
|
+
return {
|
|
162
|
+
ReactiveButton = ReactiveButton,
|
|
163
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
export declare enum TextButtonVariant {
|
|
3
|
+
Green = 0,
|
|
4
|
+
Red = 1,
|
|
5
|
+
Blue = 2,
|
|
6
|
+
Black = 3,
|
|
7
|
+
DarkGray = 4
|
|
8
|
+
}
|
|
9
|
+
interface TextButtonProps extends React.PropsWithChildren {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly onClick?: () => void;
|
|
12
|
+
readonly onHover?: (hovered: boolean) => void;
|
|
13
|
+
readonly size?: UDim2 | React.Binding<UDim2>;
|
|
14
|
+
readonly position?: UDim2 | React.Binding<UDim2>;
|
|
15
|
+
readonly anchorPoint?: Vector2 | React.Binding<Vector2>;
|
|
16
|
+
readonly overlayGradient?: ColorSequence | React.Binding<ColorSequence>;
|
|
17
|
+
readonly overlayTransparency?: number | React.Binding<number>;
|
|
18
|
+
readonly overlayRotation?: number | React.Binding<number>;
|
|
19
|
+
readonly layoutOrder?: number | React.Binding<number>;
|
|
20
|
+
readonly variant: TextButtonVariant;
|
|
21
|
+
readonly isDisabled?: boolean;
|
|
22
|
+
readonly hasShadow?: boolean;
|
|
23
|
+
readonly padding?: number;
|
|
24
|
+
readonly radius?: number;
|
|
25
|
+
readonly textSize?: number;
|
|
26
|
+
readonly textScaled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function TextButton({ text, onClick, onHover, position, anchorPoint, layoutOrder, variant, isDisabled, hasShadow, size, padding, radius, children, textSize, textScaled, }: TextButtonProps): JSX.Element;
|
|
29
|
+
export type { TextButtonProps };
|
|
30
|
+
//# sourceMappingURL=TextButton.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _primitives = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist)
|
|
4
|
+
local Frame = _primitives.Frame
|
|
5
|
+
local Text = _primitives.Text
|
|
6
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
7
|
+
local defaultTheme = TS.import(script, TS.getModule(script, "@rbxts-ui", "theme").dist).defaultTheme
|
|
8
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
9
|
+
local lerpBinding = _pretty_react_hooks.lerpBinding
|
|
10
|
+
local useMotion = _pretty_react_hooks.useMotion
|
|
11
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
12
|
+
local Outline = TS.import(script, script.Parent.Parent, "utils", "Outline").Outline
|
|
13
|
+
local ReactiveButton = TS.import(script, script.Parent, "ReactiveButton").ReactiveButton
|
|
14
|
+
local TextButtonVariant
|
|
15
|
+
do
|
|
16
|
+
local _inverse = {}
|
|
17
|
+
TextButtonVariant = setmetatable({}, {
|
|
18
|
+
__index = _inverse,
|
|
19
|
+
})
|
|
20
|
+
TextButtonVariant.Green = 0
|
|
21
|
+
_inverse[0] = "Green"
|
|
22
|
+
TextButtonVariant.Red = 1
|
|
23
|
+
_inverse[1] = "Red"
|
|
24
|
+
TextButtonVariant.Blue = 2
|
|
25
|
+
_inverse[2] = "Blue"
|
|
26
|
+
TextButtonVariant.Black = 3
|
|
27
|
+
_inverse[3] = "Black"
|
|
28
|
+
TextButtonVariant.DarkGray = 4
|
|
29
|
+
_inverse[4] = "DarkGray"
|
|
30
|
+
end
|
|
31
|
+
local function TextButton(_param)
|
|
32
|
+
local text = _param.text
|
|
33
|
+
local onClick = _param.onClick
|
|
34
|
+
local onHover = _param.onHover
|
|
35
|
+
local position = _param.position
|
|
36
|
+
local anchorPoint = _param.anchorPoint
|
|
37
|
+
local layoutOrder = _param.layoutOrder
|
|
38
|
+
local variant = _param.variant
|
|
39
|
+
local isDisabled = _param.isDisabled
|
|
40
|
+
local hasShadow = _param.hasShadow
|
|
41
|
+
local size = _param.size
|
|
42
|
+
local padding = _param.padding
|
|
43
|
+
local radius = _param.radius
|
|
44
|
+
local children = _param.children
|
|
45
|
+
local textSize = _param.textSize
|
|
46
|
+
local textScaled = _param.textScaled
|
|
47
|
+
local theme = defaultTheme
|
|
48
|
+
local rem = useRem()
|
|
49
|
+
local hover, hoverMotion = useMotion(0)
|
|
50
|
+
local colorVariant = {
|
|
51
|
+
[TextButtonVariant.Green] = theme.palette.green,
|
|
52
|
+
[TextButtonVariant.Red] = theme.palette.red,
|
|
53
|
+
[TextButtonVariant.Blue] = theme.palette.blue,
|
|
54
|
+
[TextButtonVariant.Black] = theme.palette.black,
|
|
55
|
+
[TextButtonVariant.DarkGray] = theme.palette.darkgray,
|
|
56
|
+
}
|
|
57
|
+
local color = colorVariant[variant]
|
|
58
|
+
local textColor = if variant == TextButtonVariant.Black then theme.palette.white else theme.palette.crust
|
|
59
|
+
local _condition = radius
|
|
60
|
+
if _condition == nil then
|
|
61
|
+
_condition = 1
|
|
62
|
+
end
|
|
63
|
+
local cornerRadius = UDim.new(_condition, 0)
|
|
64
|
+
local _exp = React.createElement(Frame, {
|
|
65
|
+
backgroundColor = theme.palette.offwhite,
|
|
66
|
+
backgroundTransparency = if isDisabled then 0.7 else 0,
|
|
67
|
+
cornerRadius = cornerRadius,
|
|
68
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
69
|
+
}, React.createElement("uigradient", {
|
|
70
|
+
Offset = lerpBinding(hover, Vector2.new(), Vector2.new(0, 1)),
|
|
71
|
+
Rotation = 90,
|
|
72
|
+
Transparency = NumberSequence.new(0, 0.1),
|
|
73
|
+
}))
|
|
74
|
+
local _exp_1 = React.createElement(Outline, {
|
|
75
|
+
cornerRadius = cornerRadius,
|
|
76
|
+
innerTransparency = if isDisabled then 1 else 0,
|
|
77
|
+
innerColor = color,
|
|
78
|
+
innerThickness = 1,
|
|
79
|
+
})
|
|
80
|
+
local _attributes = {
|
|
81
|
+
key = "mainText",
|
|
82
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
83
|
+
text = text,
|
|
84
|
+
}
|
|
85
|
+
local _condition_1 = textScaled
|
|
86
|
+
if _condition_1 == nil then
|
|
87
|
+
_condition_1 = true
|
|
88
|
+
end
|
|
89
|
+
_attributes.textScaled = _condition_1
|
|
90
|
+
_attributes.textColor = textColor
|
|
91
|
+
_attributes.textXAlignment = "Center"
|
|
92
|
+
_attributes.textYAlignment = "Center"
|
|
93
|
+
_attributes.layoutOrder = 2
|
|
94
|
+
local _condition_2 = padding
|
|
95
|
+
if _condition_2 == nil then
|
|
96
|
+
_condition_2 = 1
|
|
97
|
+
end
|
|
98
|
+
_attributes.padding = _condition_2
|
|
99
|
+
_attributes.textSize = textSize
|
|
100
|
+
_attributes.rem = rem
|
|
101
|
+
return React.createElement(ReactiveButton, {
|
|
102
|
+
onClick = onClick,
|
|
103
|
+
onHover = function(hovered)
|
|
104
|
+
hoverMotion:spring(if hovered then 1 else 0)
|
|
105
|
+
local _result = onHover
|
|
106
|
+
if _result ~= nil then
|
|
107
|
+
_result(hovered)
|
|
108
|
+
end
|
|
109
|
+
end,
|
|
110
|
+
backgroundTransparency = 1,
|
|
111
|
+
anchorPoint = anchorPoint,
|
|
112
|
+
size = size or UDim2.new(0, rem(10), 0, rem(4)),
|
|
113
|
+
position = position,
|
|
114
|
+
layoutOrder = layoutOrder,
|
|
115
|
+
fill = true,
|
|
116
|
+
}, _exp, _exp_1, React.createElement(Text, _attributes), children)
|
|
117
|
+
end
|
|
118
|
+
return {
|
|
119
|
+
TextButton = TextButton,
|
|
120
|
+
TextButtonVariant = TextButtonVariant,
|
|
121
|
+
}
|
|
@@ -3,7 +3,7 @@ local TS = _G[script]
|
|
|
3
3
|
local lerpBinding = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).lerpBinding
|
|
4
4
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
5
5
|
local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
|
|
6
|
-
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem")
|
|
6
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
7
7
|
local function Checkmark(_param)
|
|
8
8
|
local checked = _param.checked
|
|
9
9
|
local color = _param.color
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface LegendProps {
|
|
2
|
+
items: Array<{
|
|
3
|
+
color: Color3;
|
|
4
|
+
label: string;
|
|
5
|
+
}>;
|
|
6
|
+
position?: UDim2;
|
|
7
|
+
size?: UDim2;
|
|
8
|
+
}
|
|
9
|
+
export declare function Legend({ items, position, size }: LegendProps): JSX.Element;
|
|
10
|
+
export type { LegendProps };
|
|
11
|
+
//# sourceMappingURL=Legend.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
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 useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "@rbxts-ui/rem")).useRem
|
|
5
|
+
local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
|
|
6
|
+
local _layout = TS.import(script, TS.getModule(script, "@rbxts-ui", "layout").dist)
|
|
7
|
+
local HStack = _layout.HStack
|
|
8
|
+
local VStack = _layout.VStack
|
|
9
|
+
local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
|
|
10
|
+
local function Legend(_param)
|
|
11
|
+
local items = _param.items
|
|
12
|
+
local position = _param.position
|
|
13
|
+
local size = _param.size
|
|
14
|
+
local rem = useRem()
|
|
15
|
+
local defaultPosition = UDim2.new(0, rem(2), 0, rem(2))
|
|
16
|
+
local defaultSize = UDim2.new(0, rem(20), 0, 1)
|
|
17
|
+
-- ▼ ReadonlyArray.map ▼
|
|
18
|
+
local _newValue = table.create(#items)
|
|
19
|
+
local _callback = function(item, index)
|
|
20
|
+
return React.createElement(HStack, {
|
|
21
|
+
key = `legend-{index}`,
|
|
22
|
+
spacing = rem(1),
|
|
23
|
+
verticalAlignment = Enum.VerticalAlignment.Center,
|
|
24
|
+
size = UDim2.new(1, 0, 0, rem(4)),
|
|
25
|
+
}, React.createElement(Frame, {
|
|
26
|
+
size = UDim2.new(0, rem(2), 0, rem(2)),
|
|
27
|
+
backgroundColor = item.color,
|
|
28
|
+
backgroundTransparency = 0,
|
|
29
|
+
cornerRadius = UDim.new(0, rem(0.5)),
|
|
30
|
+
}), React.createElement(Text, {
|
|
31
|
+
text = item.label,
|
|
32
|
+
textSize = rem(2),
|
|
33
|
+
textColor = Color3.fromRGB(255, 255, 255),
|
|
34
|
+
automaticSize = Enum.AutomaticSize.X,
|
|
35
|
+
}))
|
|
36
|
+
end
|
|
37
|
+
for _k, _v in items do
|
|
38
|
+
_newValue[_k] = _callback(_v, _k - 1, items)
|
|
39
|
+
end
|
|
40
|
+
-- ▲ ReadonlyArray.map ▲
|
|
41
|
+
return React.createElement(VStack, {
|
|
42
|
+
position = position or defaultPosition,
|
|
43
|
+
size = size or defaultSize,
|
|
44
|
+
spacing = rem(0.5),
|
|
45
|
+
cornerRadius = UDim.new(0, rem(2)),
|
|
46
|
+
backgroundColor = Color3.fromRGB(0, 0, 0),
|
|
47
|
+
backgroundTransparency = 0.3,
|
|
48
|
+
padding = rem(1),
|
|
49
|
+
automaticSize = Enum.AutomaticSize.Y,
|
|
50
|
+
}, _newValue)
|
|
51
|
+
end
|
|
52
|
+
return {
|
|
53
|
+
Legend = Legend,
|
|
54
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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", "@rbxts-ui/rem")).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.Parent, "utils", "Outline").Outline
|
|
9
|
+
local Padding = TS.import(script, script.Parent.Parent, "layout", "Padding").Padding
|
|
10
|
+
local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
|
|
11
|
+
local defaultTheme = TS.import(script, TS.getModule(script, "@rbxts-ui", "theme").dist).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 = defaultTheme
|
|
23
|
+
local textProps = Object.assign({}, omit(props, { "position", "name", "text", "textColor", "zIndex", "anchorPoint" }))
|
|
24
|
+
local rem = useRem()
|
|
25
|
+
local cornerRadius = UDim.new(0, rem(3))
|
|
26
|
+
local _exp = React.createElement(Frame, {
|
|
27
|
+
backgroundColor = theme.palette.black,
|
|
28
|
+
backgroundTransparency = 0.3,
|
|
29
|
+
cornerRadius = cornerRadius,
|
|
30
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
31
|
+
zIndex = 1,
|
|
32
|
+
})
|
|
33
|
+
local _exp_1 = React.createElement(Outline, {
|
|
34
|
+
cornerRadius = cornerRadius,
|
|
35
|
+
innerTransparency = 1,
|
|
36
|
+
innerColor = theme.palette.black,
|
|
37
|
+
outerTransparency = 0,
|
|
38
|
+
outerColor = theme.palette.black,
|
|
39
|
+
})
|
|
40
|
+
local _attributes = {
|
|
41
|
+
text = `{text}`,
|
|
42
|
+
textSize = rem(1),
|
|
43
|
+
textColor = textColor or theme.palette.text,
|
|
44
|
+
richText = true,
|
|
45
|
+
automaticSize = Enum.AutomaticSize.XY,
|
|
46
|
+
rem = rem,
|
|
47
|
+
}
|
|
48
|
+
for _k, _v in textProps do
|
|
49
|
+
_attributes[_k] = _v
|
|
50
|
+
end
|
|
51
|
+
return React.createElement(Frame, {
|
|
52
|
+
size = UDim2.new(0, WIDTH, 0, HEIGHT),
|
|
53
|
+
position = position,
|
|
54
|
+
name = name,
|
|
55
|
+
zIndex = zIndex,
|
|
56
|
+
automaticSize = Enum.AutomaticSize.XY,
|
|
57
|
+
anchorPoint = anchorPoint,
|
|
58
|
+
}, _exp, _exp_1, React.createElement(Text, _attributes, React.createElement(Padding, {
|
|
59
|
+
paddingY = rem(0.7),
|
|
60
|
+
paddingX = rem(1.5),
|
|
61
|
+
})))
|
|
62
|
+
end
|
|
63
|
+
return {
|
|
64
|
+
PillText = PillText,
|
|
65
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TextProps } from "@rbxts-ui/primitives";
|
|
2
|
+
interface TimeAgoProps extends Omit<TextProps, "text"> {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
refreshInterval?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function TimeAgo(props: TimeAgoProps): JSX.Element;
|
|
7
|
+
export type { TimeAgoProps };
|
|
8
|
+
//# sourceMappingURL=TimeAgo.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
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 useInterval = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).useInterval
|
|
5
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
6
|
+
local React = _react
|
|
7
|
+
local useState = _react.useState
|
|
8
|
+
local omit = TS.import(script, TS.getModule(script, "@rbxts-ui", "utils").dist).omit
|
|
9
|
+
local PillText = TS.import(script, script.Parent, "PillText").PillText
|
|
10
|
+
local function getTimeAgo(timestamp)
|
|
11
|
+
local now = os.time()
|
|
12
|
+
local seconds = now - timestamp / 1000
|
|
13
|
+
if seconds < 60 then
|
|
14
|
+
return `{math.floor(seconds)}s ago`
|
|
15
|
+
end
|
|
16
|
+
local minutes = math.floor(seconds / 60)
|
|
17
|
+
if minutes < 60 then
|
|
18
|
+
return `{minutes}m ago`
|
|
19
|
+
end
|
|
20
|
+
local hours = math.floor(minutes / 60)
|
|
21
|
+
if hours < 24 then
|
|
22
|
+
return `{hours}h ago`
|
|
23
|
+
end
|
|
24
|
+
local days = math.floor(hours / 24)
|
|
25
|
+
return `{days}d ago`
|
|
26
|
+
end
|
|
27
|
+
local function TimeAgo(props)
|
|
28
|
+
local timeAgo, setTimeAgo = useState(function()
|
|
29
|
+
return getTimeAgo(props.timestamp)
|
|
30
|
+
end)
|
|
31
|
+
local _exp = function()
|
|
32
|
+
setTimeAgo(getTimeAgo(props.timestamp))
|
|
33
|
+
end
|
|
34
|
+
local _condition = props.refreshInterval
|
|
35
|
+
if _condition == nil then
|
|
36
|
+
_condition = 1
|
|
37
|
+
end
|
|
38
|
+
useInterval(_exp, _condition)
|
|
39
|
+
local textProps = Object.assign({}, omit(props, { "timestamp", "refreshInterval" }))
|
|
40
|
+
local _attributes = table.clone(Object.assign({
|
|
41
|
+
text = timeAgo,
|
|
42
|
+
}, textProps))
|
|
43
|
+
setmetatable(_attributes, nil)
|
|
44
|
+
return React.createElement(PillText, _attributes)
|
|
45
|
+
end
|
|
46
|
+
return {
|
|
47
|
+
TimeAgo = TimeAgo,
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 ErrorBoundary = TS.import(script, script.Parent.Parent, "utils", "ErrorBoundary").ErrorBoundary
|
|
5
|
+
local ErrorPage = TS.import(script, script.Parent, "ErrorPage").ErrorPage
|
|
6
|
+
local function ErrorHandler(_param)
|
|
7
|
+
local children = _param.children
|
|
8
|
+
return React.createElement(ErrorBoundary, {
|
|
9
|
+
fallback = function(message)
|
|
10
|
+
return React.createElement(ErrorPage, {
|
|
11
|
+
message = message,
|
|
12
|
+
})
|
|
13
|
+
end,
|
|
14
|
+
}, children)
|
|
15
|
+
end
|
|
16
|
+
return {
|
|
17
|
+
ErrorHandler = ErrorHandler,
|
|
18
|
+
}
|