@rbxts/react-clean-ui 1.0.5 → 1.0.7
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/Interaction/Toast.d.ts +11 -0
- package/out/Components/Interaction/Toast.luau +212 -0
- package/out/Contexts/index.d.ts +1 -0
- package/out/Contexts/init.luau +3 -0
- package/out/Contexts/toast.context.d.ts +26 -0
- package/out/Contexts/toast.context.luau +14 -0
- package/out/Helpers/color.helper.d.ts +5 -1
- package/out/Helpers/color.helper.luau +22 -40
- package/out/Helpers/create-ui-story.d.ts +1 -1
- package/out/Helpers/create-ui-story.luau +6 -7
- package/out/Helpers/index.d.ts +0 -1
- package/out/Helpers/init.luau +0 -3
- package/out/Providers/app.provider.d.ts +9 -0
- package/out/Providers/app.provider.luau +22 -0
- package/out/Providers/index.d.ts +1 -0
- package/out/Providers/init.luau +3 -0
- package/out/Providers/toast.provider.d.ts +6 -0
- package/out/Providers/toast.provider.luau +94 -0
- package/out/Theme/CleanTheme.d.ts +18 -1
- package/out/Theme/themes/dark.theme.luau +6 -0
- package/out/Theme/themes/default.theme.luau +55 -0
- package/out/Theme/themes/sandstone.theme.luau +6 -0
- package/out/index.d.ts +2 -0
- package/out/init.luau +6 -0
- package/package.json +9 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { SizeElementProps } from "../../Interfaces";
|
|
3
|
+
import { ToastOptions } from "../../Contexts/";
|
|
4
|
+
interface ToastProps extends ToastOptions {
|
|
5
|
+
onDismiss: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function Toast({ title, description, icon, intent, duration, dismissible, children, onDismiss, }: ToastProps): React.JSX.Element;
|
|
8
|
+
interface ToastContainerProps extends SizeElementProps {
|
|
9
|
+
}
|
|
10
|
+
export declare function ToastContainer(props: ToastContainerProps): React.JSX.Element | undefined;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
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 _Surface = TS.import(script, script.Parent.Parent, "Surface")
|
|
6
|
+
local Box = _Surface.Box
|
|
7
|
+
local Icon = _Surface.Icon
|
|
8
|
+
local _Layout = TS.import(script, script.Parent.Parent, "Layout")
|
|
9
|
+
local Container = _Layout.Container
|
|
10
|
+
local FlexItem = _Layout.FlexItem
|
|
11
|
+
local HStack = _Layout.HStack
|
|
12
|
+
local VStack = _Layout.VStack
|
|
13
|
+
local Button = TS.import(script, script.Parent.Parent, "Input").Button
|
|
14
|
+
local Text = TS.import(script, script.Parent.Parent, "Typography").Text
|
|
15
|
+
local _ = TS.import(script, script.Parent.Parent.Parent, "Contexts")
|
|
16
|
+
local CleanThemeContext = _.CleanThemeContext
|
|
17
|
+
local useToast = _.useToast
|
|
18
|
+
local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
|
|
19
|
+
local ColorHelper = _Helpers.ColorHelper
|
|
20
|
+
local SizeHelper = _Helpers.SizeHelper
|
|
21
|
+
local TypographyHelper = _Helpers.TypographyHelper
|
|
22
|
+
local Corners = TS.import(script, script.Parent.Parent, "Decorator").Corners
|
|
23
|
+
local function Toast(_param)
|
|
24
|
+
local title = _param.title
|
|
25
|
+
if title == nil then
|
|
26
|
+
title = nil
|
|
27
|
+
end
|
|
28
|
+
local description = _param.description
|
|
29
|
+
if description == nil then
|
|
30
|
+
description = nil
|
|
31
|
+
end
|
|
32
|
+
local icon = _param.icon
|
|
33
|
+
if icon == nil then
|
|
34
|
+
icon = nil
|
|
35
|
+
end
|
|
36
|
+
local intent = _param.intent
|
|
37
|
+
if intent == nil then
|
|
38
|
+
intent = "primary"
|
|
39
|
+
end
|
|
40
|
+
local duration = _param.duration
|
|
41
|
+
if duration == nil then
|
|
42
|
+
duration = 3
|
|
43
|
+
end
|
|
44
|
+
local dismissible = _param.dismissible
|
|
45
|
+
if dismissible == nil then
|
|
46
|
+
dismissible = true
|
|
47
|
+
end
|
|
48
|
+
local children = _param.children
|
|
49
|
+
if children == nil then
|
|
50
|
+
children = nil
|
|
51
|
+
end
|
|
52
|
+
local onDismiss = _param.onDismiss
|
|
53
|
+
local theme = React.useContext(CleanThemeContext)
|
|
54
|
+
local dismissRef = React.useRef(onDismiss)
|
|
55
|
+
local dismissingRef = React.useRef(false)
|
|
56
|
+
local fadeThreadRef = React.useRef()
|
|
57
|
+
local statusBarTheme = theme.components.toast.statusBar
|
|
58
|
+
local progress, progressTween = useTween(1, {
|
|
59
|
+
duration = duration,
|
|
60
|
+
easing = "linear",
|
|
61
|
+
})
|
|
62
|
+
React.useEffect(function()
|
|
63
|
+
if statusBarTheme == nil or duration == math.huge or duration <= 0 then
|
|
64
|
+
return nil
|
|
65
|
+
end
|
|
66
|
+
progressTween:setGoal(0)
|
|
67
|
+
end, { duration, statusBarTheme })
|
|
68
|
+
local TOAST_FADE_DURATION = theme.components.toast.fadeDuration
|
|
69
|
+
local groupTransparency, transparencyTween = useTween(0, {
|
|
70
|
+
duration = TOAST_FADE_DURATION,
|
|
71
|
+
easing = "quadOut",
|
|
72
|
+
})
|
|
73
|
+
React.useEffect(function() end)
|
|
74
|
+
React.useEffect(function()
|
|
75
|
+
dismissRef.current = onDismiss
|
|
76
|
+
end, { onDismiss })
|
|
77
|
+
local beginDismiss = React.useCallback(function()
|
|
78
|
+
if dismissingRef.current then
|
|
79
|
+
return nil
|
|
80
|
+
end
|
|
81
|
+
dismissingRef.current = true
|
|
82
|
+
if TOAST_FADE_DURATION <= 0 then
|
|
83
|
+
dismissRef.current()
|
|
84
|
+
return nil
|
|
85
|
+
end
|
|
86
|
+
transparencyTween:setGoal(1)
|
|
87
|
+
fadeThreadRef.current = task.delay(TOAST_FADE_DURATION, function()
|
|
88
|
+
fadeThreadRef.current = nil
|
|
89
|
+
dismissRef.current()
|
|
90
|
+
end)
|
|
91
|
+
end, { transparencyTween })
|
|
92
|
+
React.useEffect(function()
|
|
93
|
+
if duration == math.huge or duration <= 0 then
|
|
94
|
+
return nil
|
|
95
|
+
end
|
|
96
|
+
local dismissThread = task.delay(duration, beginDismiss)
|
|
97
|
+
return function()
|
|
98
|
+
task.cancel(dismissThread)
|
|
99
|
+
end
|
|
100
|
+
end, { duration, beginDismiss })
|
|
101
|
+
React.useEffect(function()
|
|
102
|
+
if TOAST_FADE_DURATION <= 0 then
|
|
103
|
+
return nil
|
|
104
|
+
end
|
|
105
|
+
return function()
|
|
106
|
+
local fadeThread = fadeThreadRef.current
|
|
107
|
+
if fadeThread ~= nil then
|
|
108
|
+
task.cancel(fadeThread)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end, {})
|
|
112
|
+
local boxStyles = ColorHelper:getIntentColors(theme, intent, "default", theme.components.toast.intents)
|
|
113
|
+
local _condition = children ~= nil and children
|
|
114
|
+
if not _condition then
|
|
115
|
+
local _exp = icon ~= nil and React.createElement(Icon, {
|
|
116
|
+
icon = icon,
|
|
117
|
+
scale = "sm",
|
|
118
|
+
color = boxStyles.textColor,
|
|
119
|
+
})
|
|
120
|
+
local _attributes = {
|
|
121
|
+
TextColor3 = boxStyles.textColor,
|
|
122
|
+
}
|
|
123
|
+
local _condition_1 = title
|
|
124
|
+
if _condition_1 == nil then
|
|
125
|
+
_condition_1 = ""
|
|
126
|
+
end
|
|
127
|
+
_attributes.text = _condition_1
|
|
128
|
+
_attributes.typography = TypographyHelper:getTypography(theme, nil, theme.components.toast.header.typography)
|
|
129
|
+
_condition = React.createElement(VStack, {
|
|
130
|
+
spacing = "None",
|
|
131
|
+
}, React.createElement(Container, nil, React.createElement(HStack, {
|
|
132
|
+
valign = "Center",
|
|
133
|
+
}, _exp, React.createElement(Text, _attributes), dismissible and (React.createElement(FlexItem, {
|
|
134
|
+
align = "Right",
|
|
135
|
+
}, React.createElement(Button, {
|
|
136
|
+
intent = intent,
|
|
137
|
+
spacing = "xs",
|
|
138
|
+
Event = {
|
|
139
|
+
Activated = beginDismiss,
|
|
140
|
+
},
|
|
141
|
+
}, React.createElement(Button.Icon, {
|
|
142
|
+
intent = intent,
|
|
143
|
+
icon = "times",
|
|
144
|
+
scale = "sm",
|
|
145
|
+
})))))), description ~= nil and (React.createElement(Container, nil, React.createElement(Text, {
|
|
146
|
+
text = description,
|
|
147
|
+
TextColor3 = boxStyles.textColor,
|
|
148
|
+
}))))
|
|
149
|
+
end
|
|
150
|
+
return React.createElement("canvasgroup", {
|
|
151
|
+
Size = UDim2.fromScale(0, 0),
|
|
152
|
+
AutomaticSize = Enum.AutomaticSize.XY,
|
|
153
|
+
BackgroundTransparency = 1,
|
|
154
|
+
GroupTransparency = groupTransparency,
|
|
155
|
+
}, React.createElement(Box, {
|
|
156
|
+
["border-color"] = boxStyles.borderColor,
|
|
157
|
+
BackgroundColor3 = boxStyles.backgroundColor,
|
|
158
|
+
BackgroundTransparency = boxStyles.backgroundTransparency,
|
|
159
|
+
}, _condition), statusBarTheme ~= nil and React.createElement(React.Fragment, nil, React.createElement("frame", {
|
|
160
|
+
Size = progress:map(function(value)
|
|
161
|
+
return UDim2.new(UDim.new(value, 0), SizeHelper:toUDim(statusBarTheme.height))
|
|
162
|
+
end),
|
|
163
|
+
BackgroundColor3 = ColorHelper:getIntentColors(theme, intent, "default", statusBarTheme.intents).backgroundColor,
|
|
164
|
+
BackgroundTransparency = ColorHelper:getIntentColors(theme, intent, "default", statusBarTheme.intents).backgroundTransparency,
|
|
165
|
+
ZIndex = 2,
|
|
166
|
+
BorderSizePixel = 0,
|
|
167
|
+
Position = UDim2.fromScale(0, if statusBarTheme.position == "Top" then 0 else 1),
|
|
168
|
+
AnchorPoint = Vector2.new(0, if statusBarTheme.position == "Top" then 0 else 1),
|
|
169
|
+
}), React.createElement(Corners, {
|
|
170
|
+
radius = theme.components.box.cornerRadius,
|
|
171
|
+
})))
|
|
172
|
+
end
|
|
173
|
+
local function ToastContainer(props)
|
|
174
|
+
local _binding = useToast()
|
|
175
|
+
local toasts = _binding.toasts
|
|
176
|
+
local dismiss = _binding.dismiss
|
|
177
|
+
local theme = React.useContext(CleanThemeContext)
|
|
178
|
+
if #toasts == 0 then
|
|
179
|
+
return nil
|
|
180
|
+
end
|
|
181
|
+
local position = if theme.components.toast.position then SizeHelper:GetPosition(theme.components.toast.position) else UDim2.fromOffset(5, 5)
|
|
182
|
+
local anchor = if theme.components.toast.position then SizeHelper:GetAnchor(theme.components.toast.position) else Vector2.new(0, 0)
|
|
183
|
+
-- ▼ ReadonlyArray.map ▼
|
|
184
|
+
local _newValue = table.create(#toasts)
|
|
185
|
+
local _callback = function(toast)
|
|
186
|
+
local _attributes = {
|
|
187
|
+
key = toast.id,
|
|
188
|
+
}
|
|
189
|
+
for _k, _v in toast do
|
|
190
|
+
_attributes[_k] = _v
|
|
191
|
+
end
|
|
192
|
+
_attributes.onDismiss = function()
|
|
193
|
+
return dismiss(toast.id)
|
|
194
|
+
end
|
|
195
|
+
return React.createElement(Toast, _attributes)
|
|
196
|
+
end
|
|
197
|
+
for _k, _v in toasts do
|
|
198
|
+
_newValue[_k] = _callback(_v, _k - 1, toasts)
|
|
199
|
+
end
|
|
200
|
+
-- ▲ ReadonlyArray.map ▲
|
|
201
|
+
return React.createElement(Container, {
|
|
202
|
+
Size = SizeHelper:GetSize(props, UDim2.new(SizeHelper:toUDim(theme.components.toast.width), UDim.new(0, 0))),
|
|
203
|
+
Position = position,
|
|
204
|
+
AnchorPoint = anchor,
|
|
205
|
+
}, React.createElement(VStack, {
|
|
206
|
+
spacing = "xs",
|
|
207
|
+
}, _newValue))
|
|
208
|
+
end
|
|
209
|
+
return {
|
|
210
|
+
Toast = Toast,
|
|
211
|
+
ToastContainer = ToastContainer,
|
|
212
|
+
}
|
package/out/Contexts/index.d.ts
CHANGED
package/out/Contexts/init.luau
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { IconName, Intent } from "../Interfaces";
|
|
3
|
+
export interface ToastOptions {
|
|
4
|
+
id?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
icon?: IconName;
|
|
8
|
+
intent?: Intent;
|
|
9
|
+
duration?: number;
|
|
10
|
+
dismissible?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export interface ToastRecord extends ToastOptions {
|
|
14
|
+
id: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ToastController {
|
|
17
|
+
show: (options: ToastOptions) => string;
|
|
18
|
+
update: (id: string, options: Partial<ToastOptions>) => void;
|
|
19
|
+
dismiss: (id: string) => void;
|
|
20
|
+
dismissAll: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface ToastContextValue extends ToastController {
|
|
23
|
+
toasts: ToastRecord[];
|
|
24
|
+
}
|
|
25
|
+
export declare const ToastContext: React.Context<ToastContextValue | undefined>;
|
|
26
|
+
export declare function useToast(): ToastContextValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
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 ToastContext = React.createContext(nil)
|
|
5
|
+
local function useToast()
|
|
6
|
+
local context = React.useContext(ToastContext)
|
|
7
|
+
local _arg0 = context ~= nil
|
|
8
|
+
assert(_arg0, "ToastProvider is missing.")
|
|
9
|
+
return context
|
|
10
|
+
end
|
|
11
|
+
return {
|
|
12
|
+
useToast = useToast,
|
|
13
|
+
ToastContext = ToastContext,
|
|
14
|
+
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { CleanTheme, InlineIntentColors, IntentScheme } from "../Theme";
|
|
2
2
|
import { ButtonFlag, Intent } from "../Interfaces";
|
|
3
|
+
type ComponentIntentColors = Partial<Record<Intent, InlineIntentColors>> | Partial<Record<Intent, Partial<IntentScheme>>>;
|
|
3
4
|
export declare class ColorHelper {
|
|
4
|
-
static getIntentColors(theme: CleanTheme, intent: Intent | undefined, state?: ButtonFlag, componentColors?:
|
|
5
|
+
static getIntentColors(theme: CleanTheme, intent: Intent | undefined, state?: ButtonFlag, componentColors?: ComponentIntentColors): IntentScheme;
|
|
6
|
+
private static resolveComponentColors;
|
|
7
|
+
private static isInlineIntentColors;
|
|
5
8
|
}
|
|
9
|
+
export {};
|
|
@@ -49,52 +49,34 @@ do
|
|
|
49
49
|
for _k, _v in _condition_1 do
|
|
50
50
|
_object[_k] = _v
|
|
51
51
|
end
|
|
52
|
-
|
|
53
|
-
if _result ~= nil then
|
|
54
|
-
_result = _result.default
|
|
55
|
-
end
|
|
56
|
-
local _condition_2 = _result
|
|
57
|
-
if _condition_2 == nil then
|
|
58
|
-
_condition_2 = {}
|
|
59
|
-
end
|
|
60
|
-
for _k, _v in _condition_2 do
|
|
61
|
-
_object[_k] = _v
|
|
62
|
-
end
|
|
63
|
-
local _result_1 = componentPrimary
|
|
64
|
-
if _result_1 ~= nil then
|
|
65
|
-
_result_1 = _result_1[state]
|
|
66
|
-
end
|
|
67
|
-
local _condition_3 = _result_1
|
|
68
|
-
if _condition_3 == nil then
|
|
69
|
-
_condition_3 = {}
|
|
70
|
-
end
|
|
71
|
-
for _k, _v in _condition_3 do
|
|
72
|
-
_object[_k] = _v
|
|
73
|
-
end
|
|
74
|
-
local _result_2 = componentMatching
|
|
75
|
-
if _result_2 ~= nil then
|
|
76
|
-
_result_2 = _result_2.default
|
|
77
|
-
end
|
|
78
|
-
local _condition_4 = _result_2
|
|
79
|
-
if _condition_4 == nil then
|
|
80
|
-
_condition_4 = {}
|
|
81
|
-
end
|
|
82
|
-
for _k, _v in _condition_4 do
|
|
52
|
+
for _k, _v in self:resolveComponentColors(componentPrimary, state) do
|
|
83
53
|
_object[_k] = _v
|
|
84
54
|
end
|
|
85
|
-
|
|
86
|
-
if _result_3 ~= nil then
|
|
87
|
-
_result_3 = _result_3[state]
|
|
88
|
-
end
|
|
89
|
-
local _condition_5 = _result_3
|
|
90
|
-
if _condition_5 == nil then
|
|
91
|
-
_condition_5 = {}
|
|
92
|
-
end
|
|
93
|
-
for _k, _v in _condition_5 do
|
|
55
|
+
for _k, _v in self:resolveComponentColors(componentMatching, state) do
|
|
94
56
|
_object[_k] = _v
|
|
95
57
|
end
|
|
96
58
|
return _object
|
|
97
59
|
end
|
|
60
|
+
function ColorHelper:resolveComponentColors(colors, state)
|
|
61
|
+
if colors == nil then
|
|
62
|
+
return {}
|
|
63
|
+
end
|
|
64
|
+
if self:isInlineIntentColors(colors) then
|
|
65
|
+
local _object = table.clone((colors.default or {}))
|
|
66
|
+
setmetatable(_object, nil)
|
|
67
|
+
for _k, _v in (colors[state] or {}) do
|
|
68
|
+
_object[_k] = _v
|
|
69
|
+
end
|
|
70
|
+
return _object
|
|
71
|
+
end
|
|
72
|
+
-- A direct Partial<IntentScheme> has no state variants,
|
|
73
|
+
-- so the requested state is ignored.
|
|
74
|
+
return colors
|
|
75
|
+
end
|
|
76
|
+
function ColorHelper:isInlineIntentColors(colors)
|
|
77
|
+
local statefulColors = colors
|
|
78
|
+
return statefulColors.default ~= nil or statefulColors.hover ~= nil or statefulColors.focus ~= nil
|
|
79
|
+
end
|
|
98
80
|
end
|
|
99
81
|
return {
|
|
100
82
|
ColorHelper = ColorHelper,
|
|
@@ -5,7 +5,7 @@ declare const controls: {
|
|
|
5
5
|
Theme: import("@rbxts/ui-labs/src/ControlTypings/Advanced").AdvancedTypes.Choose<"Default" | "Dark" | "Sandstone">;
|
|
6
6
|
};
|
|
7
7
|
type StoryProps = InferProps<typeof controls>;
|
|
8
|
-
export declare function createStory(
|
|
8
|
+
export declare function createStory(StoryComponent: (props: StoryProps) => React.ReactNode): {
|
|
9
9
|
react: typeof React;
|
|
10
10
|
reactRoblox: typeof ReactRoblox;
|
|
11
11
|
controls: {
|
|
@@ -7,14 +7,11 @@ local DarkTheme = _Theme.DarkTheme
|
|
|
7
7
|
local DefaultTheme = _Theme.DefaultTheme
|
|
8
8
|
local SandstoneTheme = _Theme.SandstoneTheme
|
|
9
9
|
local Choose = TS.import(script, TS.getModule(script, "@rbxts", "ui-labs").src).Choose
|
|
10
|
-
local
|
|
11
|
-
local OverlayProvider = _.OverlayProvider
|
|
12
|
-
local ThemeProvider = _.ThemeProvider
|
|
13
|
-
local RegistryProvider = TS.import(script, script.Parent.Parent, "Providers", "registry.provider").RegistryProvider
|
|
10
|
+
local CleanUiProvider = TS.import(script, script.Parent.Parent, "Providers", "app.provider").CleanUiProvider
|
|
14
11
|
local controls = {
|
|
15
12
|
Theme = Choose({ "Default", "Dark", "Sandstone" }),
|
|
16
13
|
}
|
|
17
|
-
local function createStory(
|
|
14
|
+
local function createStory(StoryComponent)
|
|
18
15
|
return {
|
|
19
16
|
react = React,
|
|
20
17
|
reactRoblox = ReactRoblox,
|
|
@@ -27,9 +24,11 @@ local function createStory(render)
|
|
|
27
24
|
if props.controls.Theme == "Sandstone" then
|
|
28
25
|
theme = SandstoneTheme
|
|
29
26
|
end
|
|
30
|
-
|
|
27
|
+
local _attributes = table.clone(props)
|
|
28
|
+
setmetatable(_attributes, nil)
|
|
29
|
+
return React.createElement(CleanUiProvider, {
|
|
31
30
|
theme = theme,
|
|
32
|
-
}, React.createElement(
|
|
31
|
+
}, React.createElement(StoryComponent, _attributes))
|
|
33
32
|
end,
|
|
34
33
|
}
|
|
35
34
|
end
|
package/out/Helpers/index.d.ts
CHANGED
package/out/Helpers/init.luau
CHANGED
|
@@ -7,9 +7,6 @@ end
|
|
|
7
7
|
for _k, _v in TS.import(script, script, "color.helper") or {} do
|
|
8
8
|
exports[_k] = _v
|
|
9
9
|
end
|
|
10
|
-
for _k, _v in TS.import(script, script, "create-ui-story") or {} do
|
|
11
|
-
exports[_k] = _v
|
|
12
|
-
end
|
|
13
10
|
for _k, _v in TS.import(script, script, "css.helper") or {} do
|
|
14
11
|
exports[_k] = _v
|
|
15
12
|
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { CleanTheme } from "../Theme";
|
|
3
|
+
interface CleanUiProviderProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
theme: CleanTheme;
|
|
6
|
+
toasts?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function CleanUiProvider({ children, theme, toasts }: CleanUiProviderProps): React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 ToastContainer = TS.import(script, script.Parent.Parent, "Components", "Interaction", "Toast").ToastContainer
|
|
5
|
+
local RegistryProvider = TS.import(script, script.Parent, "registry.provider").RegistryProvider
|
|
6
|
+
local ThemeProvider = TS.import(script, script.Parent, "theme.provider").ThemeProvider
|
|
7
|
+
local OverlayProvider = TS.import(script, script.Parent, "overlay.provider").OverlayProvider
|
|
8
|
+
local ToastProvider = TS.import(script, script.Parent, "toast.provider").ToastProvider
|
|
9
|
+
local function CleanUiProvider(_param)
|
|
10
|
+
local children = _param.children
|
|
11
|
+
local theme = _param.theme
|
|
12
|
+
local toasts = _param.toasts
|
|
13
|
+
if toasts == nil then
|
|
14
|
+
toasts = true
|
|
15
|
+
end
|
|
16
|
+
return React.createElement(RegistryProvider, nil, React.createElement(ThemeProvider, {
|
|
17
|
+
theme = theme,
|
|
18
|
+
}, React.createElement(OverlayProvider, nil, React.createElement(ToastProvider, nil, children, toasts and React.createElement(ToastContainer)))))
|
|
19
|
+
end
|
|
20
|
+
return {
|
|
21
|
+
CleanUiProvider = CleanUiProvider,
|
|
22
|
+
}
|
package/out/Providers/index.d.ts
CHANGED
package/out/Providers/init.luau
CHANGED
|
@@ -0,0 +1,94 @@
|
|
|
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 ToastContext = TS.import(script, script.Parent.Parent, "Contexts", "toast.context").ToastContext
|
|
5
|
+
local nextToastId = 0
|
|
6
|
+
local function generateId()
|
|
7
|
+
nextToastId += 1
|
|
8
|
+
return `toast-{nextToastId}`
|
|
9
|
+
end
|
|
10
|
+
local function ToastProvider(props)
|
|
11
|
+
local toasts, setToasts = React.useState({})
|
|
12
|
+
local show = React.useCallback(function(options)
|
|
13
|
+
local _condition = options.id
|
|
14
|
+
if _condition == nil then
|
|
15
|
+
_condition = generateId()
|
|
16
|
+
end
|
|
17
|
+
local id = _condition
|
|
18
|
+
setToasts(function(current)
|
|
19
|
+
local _array = {}
|
|
20
|
+
local _length = #_array
|
|
21
|
+
local _currentLength = #current
|
|
22
|
+
table.move(current, 1, _currentLength, _length + 1, _array)
|
|
23
|
+
_length += _currentLength
|
|
24
|
+
local _object = table.clone(options)
|
|
25
|
+
setmetatable(_object, nil)
|
|
26
|
+
_object.id = id
|
|
27
|
+
_array[_length + 1] = _object
|
|
28
|
+
return _array
|
|
29
|
+
end)
|
|
30
|
+
return id
|
|
31
|
+
end, {})
|
|
32
|
+
local update = React.useCallback(function(id, options)
|
|
33
|
+
setToasts(function(current)
|
|
34
|
+
-- ▼ ReadonlyArray.map ▼
|
|
35
|
+
local _newValue = table.create(#current)
|
|
36
|
+
local _callback = function(toast)
|
|
37
|
+
local _result
|
|
38
|
+
if toast.id == id then
|
|
39
|
+
local _object = table.clone(toast)
|
|
40
|
+
setmetatable(_object, nil)
|
|
41
|
+
for _k, _v in options do
|
|
42
|
+
_object[_k] = _v
|
|
43
|
+
end
|
|
44
|
+
_object.id = id
|
|
45
|
+
_result = _object
|
|
46
|
+
else
|
|
47
|
+
_result = toast
|
|
48
|
+
end
|
|
49
|
+
return _result
|
|
50
|
+
end
|
|
51
|
+
for _k, _v in current do
|
|
52
|
+
_newValue[_k] = _callback(_v, _k - 1, current)
|
|
53
|
+
end
|
|
54
|
+
-- ▲ ReadonlyArray.map ▲
|
|
55
|
+
return _newValue
|
|
56
|
+
end)
|
|
57
|
+
end, {})
|
|
58
|
+
local dismiss = React.useCallback(function(id)
|
|
59
|
+
setToasts(function(current)
|
|
60
|
+
-- ▼ ReadonlyArray.filter ▼
|
|
61
|
+
local _newValue = {}
|
|
62
|
+
local _callback = function(toast)
|
|
63
|
+
return toast.id ~= id
|
|
64
|
+
end
|
|
65
|
+
local _length = 0
|
|
66
|
+
for _k, _v in current do
|
|
67
|
+
if _callback(_v, _k - 1, current) == true then
|
|
68
|
+
_length += 1
|
|
69
|
+
_newValue[_length] = _v
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
-- ▲ ReadonlyArray.filter ▲
|
|
73
|
+
return _newValue
|
|
74
|
+
end)
|
|
75
|
+
end, {})
|
|
76
|
+
local dismissAll = React.useCallback(function()
|
|
77
|
+
setToasts({})
|
|
78
|
+
end, {})
|
|
79
|
+
local value = React.useMemo(function()
|
|
80
|
+
return {
|
|
81
|
+
toasts = toasts,
|
|
82
|
+
show = show,
|
|
83
|
+
update = update,
|
|
84
|
+
dismiss = dismiss,
|
|
85
|
+
dismissAll = dismissAll,
|
|
86
|
+
}
|
|
87
|
+
end, { toasts, show, update, dismiss, dismissAll })
|
|
88
|
+
return React.createElement(ToastContext.Provider, {
|
|
89
|
+
value = value,
|
|
90
|
+
}, props.children)
|
|
91
|
+
end
|
|
92
|
+
return {
|
|
93
|
+
ToastProvider = ToastProvider,
|
|
94
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CssShadow, CssSize, Breakpoint, BreakpointValue, ScaleSizeValue, ScaleSize, Intent, IconSet, TextVariant, ButtonFlag } from "../Interfaces/";
|
|
1
|
+
import { CssShadow, CssSize, Breakpoint, BreakpointValue, ScaleSizeValue, ScaleSize, Intent, IconSet, TextVariant, ButtonFlag, PositionElementProps } from "../Interfaces/";
|
|
2
2
|
export interface TypographyStyle {
|
|
3
3
|
font: Enum.Font;
|
|
4
4
|
size: Enum.FontSize;
|
|
@@ -163,6 +163,23 @@ export interface CleanTheme {
|
|
|
163
163
|
aspectRation?: number;
|
|
164
164
|
};
|
|
165
165
|
};
|
|
166
|
+
toast: {
|
|
167
|
+
width: CssSize;
|
|
168
|
+
fadeDuration: number;
|
|
169
|
+
position?: PositionElementProps;
|
|
170
|
+
intents?: Partial<Record<Intent, Partial<IntentScheme>>>;
|
|
171
|
+
header: {
|
|
172
|
+
typography?: Partial<TypographyStyle>;
|
|
173
|
+
};
|
|
174
|
+
body: {
|
|
175
|
+
typography?: Partial<TypographyStyle>;
|
|
176
|
+
};
|
|
177
|
+
statusBar?: {
|
|
178
|
+
position: "Top" | "Bottom";
|
|
179
|
+
height: CssSize;
|
|
180
|
+
intents?: Partial<Record<Intent, Partial<IntentScheme>>>;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
166
183
|
};
|
|
167
184
|
icons: Partial<IconSet>;
|
|
168
185
|
iconSize: ScaleSizeValue<number>;
|
|
@@ -386,6 +386,61 @@ local DefaultTheme = {
|
|
|
386
386
|
aspectRation = 1,
|
|
387
387
|
},
|
|
388
388
|
},
|
|
389
|
+
toast = {
|
|
390
|
+
fadeDuration = 0.5,
|
|
391
|
+
width = 300,
|
|
392
|
+
position = {
|
|
393
|
+
right = 5,
|
|
394
|
+
top = 5,
|
|
395
|
+
},
|
|
396
|
+
header = {
|
|
397
|
+
typography = {
|
|
398
|
+
weight = Enum.FontWeight.Bold,
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
body = {},
|
|
402
|
+
intents = {
|
|
403
|
+
primary = {
|
|
404
|
+
backgroundTransparency = 0,
|
|
405
|
+
},
|
|
406
|
+
success = {
|
|
407
|
+
backgroundColor = Color3.fromHex("#dcf5e8"),
|
|
408
|
+
},
|
|
409
|
+
info = {
|
|
410
|
+
backgroundColor = Color3.fromHex("#b3d7f2"),
|
|
411
|
+
},
|
|
412
|
+
warning = {
|
|
413
|
+
backgroundColor = Color3.fromHex("#f7e1b5"),
|
|
414
|
+
textColor = Color3.fromHex("#75520f"),
|
|
415
|
+
},
|
|
416
|
+
danger = {
|
|
417
|
+
backgroundColor = Color3.fromHex("#edafaf"),
|
|
418
|
+
textColor = Color3.fromHex("#731717"),
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
statusBar = {
|
|
422
|
+
height = 4,
|
|
423
|
+
position = "Bottom",
|
|
424
|
+
intents = {
|
|
425
|
+
primary = {
|
|
426
|
+
backgroundColor = Color3.fromHex("#000000"),
|
|
427
|
+
backgroundTransparency = 0.5,
|
|
428
|
+
},
|
|
429
|
+
success = {
|
|
430
|
+
backgroundColor = Color3.fromHex("#237D4D"),
|
|
431
|
+
},
|
|
432
|
+
info = {
|
|
433
|
+
backgroundColor = Color3.fromHex("#3187C8"),
|
|
434
|
+
},
|
|
435
|
+
warning = {
|
|
436
|
+
backgroundColor = Color3.fromHex("#C58B1D"),
|
|
437
|
+
},
|
|
438
|
+
danger = {
|
|
439
|
+
backgroundColor = Color3.fromHex("#D64545"),
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
},
|
|
389
444
|
},
|
|
390
445
|
icons = {
|
|
391
446
|
["shopping-cart"] = 112388431913339,
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./Components";
|
|
2
2
|
export * from "./Helpers";
|
|
3
|
+
export * from "./Helpers/create-ui-story";
|
|
3
4
|
export * from "./Theme";
|
|
4
5
|
export * from "./Interfaces";
|
|
5
6
|
export * from "./Providers";
|
|
7
|
+
export * from "./Providers/app.provider";
|
|
6
8
|
export * from "./Contexts";
|
package/out/init.luau
CHANGED
|
@@ -7,6 +7,9 @@ end
|
|
|
7
7
|
for _k, _v in TS.import(script, script, "Helpers") or {} do
|
|
8
8
|
exports[_k] = _v
|
|
9
9
|
end
|
|
10
|
+
for _k, _v in TS.import(script, script, "Helpers", "create-ui-story") or {} do
|
|
11
|
+
exports[_k] = _v
|
|
12
|
+
end
|
|
10
13
|
for _k, _v in TS.import(script, script, "Theme") or {} do
|
|
11
14
|
exports[_k] = _v
|
|
12
15
|
end
|
|
@@ -16,6 +19,9 @@ end
|
|
|
16
19
|
for _k, _v in TS.import(script, script, "Providers") or {} do
|
|
17
20
|
exports[_k] = _v
|
|
18
21
|
end
|
|
22
|
+
for _k, _v in TS.import(script, script, "Providers", "app.provider") or {} do
|
|
23
|
+
exports[_k] = _v
|
|
24
|
+
end
|
|
19
25
|
for _k, _v in TS.import(script, script, "Contexts") or {} do
|
|
20
26
|
exports[_k] = _v
|
|
21
27
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/react-clean-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"scripts": {
|
|
@@ -39,5 +39,13 @@
|
|
|
39
39
|
"@rbxts/react-roblox": "^17.3.7-ts.2",
|
|
40
40
|
"@rbxts/services": "^1.6.0",
|
|
41
41
|
"@rbxts/ui-labs": "^2.4.2"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/Shadercloud/rbxts-react-clean-ui.git"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://shadercloud.github.io/rbxts-react-clean-ui/",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/Shadercloud/rbxts-react-clean-ui/issues"
|
|
42
50
|
}
|
|
43
51
|
}
|