@rbxts/uiblox 0.1.16 → 0.1.17
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/ui/index.d.ts +3 -0
- package/out/ui/init.luau +1 -0
- package/out/ui/packages/index.d.ts +1 -0
- package/out/ui/packages/init.luau +3 -0
- package/out/ui/packages/preloader/components/Preloader.d.ts +13 -0
- package/out/ui/packages/preloader/components/Preloader.luau +110 -0
- package/out/ui/packages/preloader/components/Preloader.styles.d.ts +3 -0
- package/out/ui/packages/preloader/components/Preloader.styles.luau +52 -0
- package/out/ui/packages/preloader/index.d.ts +3 -0
- package/out/ui/packages/preloader/init.luau +8 -0
- package/package.json +1 -1
package/out/ui/index.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export { InputProps } from "./packages/index";
|
|
|
11
11
|
export { InputColor } from "./packages/index";
|
|
12
12
|
export { InputMargin } from "./packages/index";
|
|
13
13
|
export { InputVariant } from "./packages/index";
|
|
14
|
+
export { Preloader } from "./packages/index";
|
|
15
|
+
export { PreloaderProps } from "./packages/index";
|
|
16
|
+
export { PreloaderAssets as Assets } from "./packages/index";
|
|
14
17
|
export { ProgressBar } from "./packages/index";
|
|
15
18
|
export { ProgressBarProps } from "./packages/index";
|
|
16
19
|
export { Shadow } from "./packages/index";
|
package/out/ui/init.luau
CHANGED
|
@@ -11,6 +11,7 @@ exports.Divider = TS.import(script, script, "packages").Divider
|
|
|
11
11
|
exports.Icon = TS.import(script, script, "packages").Icon
|
|
12
12
|
exports.IconButton = TS.import(script, script, "packages").IconButton
|
|
13
13
|
exports.Input = TS.import(script, script, "packages").Input
|
|
14
|
+
exports.Preloader = TS.import(script, script, "packages").Preloader
|
|
14
15
|
exports.ProgressBar = TS.import(script, script, "packages").ProgressBar
|
|
15
16
|
exports.Shadow = TS.import(script, script, "packages").Shadow
|
|
16
17
|
exports.Sidebar = TS.import(script, script, "packages").Sidebar
|
|
@@ -2,6 +2,7 @@ export * from "./divider/index";
|
|
|
2
2
|
export * from "./icon/index";
|
|
3
3
|
export * from "./iconButton/index";
|
|
4
4
|
export * from "./input/index";
|
|
5
|
+
export * from "./preloader/index";
|
|
5
6
|
export * from "./progressBar/index";
|
|
6
7
|
export * from "./shadow/index";
|
|
7
8
|
export * from "./sidebar/index";
|
|
@@ -13,6 +13,9 @@ end
|
|
|
13
13
|
for _k, _v in TS.import(script, script, "input") or {} do
|
|
14
14
|
exports[_k] = _v
|
|
15
15
|
end
|
|
16
|
+
for _k, _v in TS.import(script, script, "preloader") or {} do
|
|
17
|
+
exports[_k] = _v
|
|
18
|
+
end
|
|
16
19
|
for _k, _v in TS.import(script, script, "progressBar") or {} do
|
|
17
20
|
exports[_k] = _v
|
|
18
21
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CustomizedProps } from "../../../../theme/index";
|
|
2
|
+
export interface PreloaderAssets {
|
|
3
|
+
[key: string]: string | PreloaderAssets;
|
|
4
|
+
}
|
|
5
|
+
export interface PreloaderProps {
|
|
6
|
+
assetMap: Map<string, PreloaderAssets>;
|
|
7
|
+
logo?: string;
|
|
8
|
+
showPercentage?: boolean;
|
|
9
|
+
loaderPrecision?: number;
|
|
10
|
+
showAssetName?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function Preloader(props: CustomizedProps<Frame, PreloaderProps>): JSX.Element;
|
|
13
|
+
export default Preloader;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local React = _react
|
|
5
|
+
local useState = _react.useState
|
|
6
|
+
local useMemo = _react.useMemo
|
|
7
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
8
|
+
local useAsyncEffect = _pretty_react_hooks.useAsyncEffect
|
|
9
|
+
local useDeferState = _pretty_react_hooks.useDeferState
|
|
10
|
+
local ContentProvider = TS.import(script, TS.getModule(script, "@rbxts", "services")).ContentProvider
|
|
11
|
+
local ProgressBar = TS.import(script, script.Parent.Parent.Parent, "progressBar").ProgressBar
|
|
12
|
+
local usePreloaderStyles = TS.import(script, script.Parent, "Preloader.styles").default
|
|
13
|
+
local function Preloader(props)
|
|
14
|
+
local _binding = props
|
|
15
|
+
local assetMap = _binding.assetMap
|
|
16
|
+
local showPercentage = _binding.showPercentage
|
|
17
|
+
if showPercentage == nil then
|
|
18
|
+
showPercentage = false
|
|
19
|
+
end
|
|
20
|
+
local loaderPrecision = _binding.loaderPrecision
|
|
21
|
+
if loaderPrecision == nil then
|
|
22
|
+
loaderPrecision = 0
|
|
23
|
+
end
|
|
24
|
+
local showAssetName = _binding.showAssetName
|
|
25
|
+
if showAssetName == nil then
|
|
26
|
+
showAssetName = false
|
|
27
|
+
end
|
|
28
|
+
local children = _binding.children
|
|
29
|
+
local percentage, setPercentage = useState(0)
|
|
30
|
+
local loaded, setLoaded = useState(false)
|
|
31
|
+
local _binding_1 = usePreloaderStyles(props)
|
|
32
|
+
local container = _binding_1.container
|
|
33
|
+
local logo = _binding_1.logo
|
|
34
|
+
local label = _binding_1.label
|
|
35
|
+
local progressBar = _binding_1.progressBar
|
|
36
|
+
local _binding_2 = useMemo(function()
|
|
37
|
+
local contentIds = {}
|
|
38
|
+
local contentNamesById = {}
|
|
39
|
+
local scan
|
|
40
|
+
scan = function(assets, prefix)
|
|
41
|
+
if prefix == nil then
|
|
42
|
+
prefix = ""
|
|
43
|
+
end
|
|
44
|
+
for name, asset in pairs(assets) do
|
|
45
|
+
if type(asset) == "string" then
|
|
46
|
+
table.insert(contentIds, asset)
|
|
47
|
+
local _arg1 = `{prefix}{if showAssetName then `/{name}` else ""}`
|
|
48
|
+
contentNamesById[asset] = _arg1
|
|
49
|
+
else
|
|
50
|
+
scan(asset, `{prefix}{if showAssetName then `/{name}` else ""}`)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
-- ▼ ReadonlyMap.forEach ▼
|
|
55
|
+
local _callback = function(assets, category)
|
|
56
|
+
scan(assets, `{category}`)
|
|
57
|
+
end
|
|
58
|
+
for _k, _v in assetMap do
|
|
59
|
+
_callback(_v, _k, assetMap)
|
|
60
|
+
end
|
|
61
|
+
-- ▲ ReadonlyMap.forEach ▲
|
|
62
|
+
return { contentIds, contentNamesById }
|
|
63
|
+
end, {})
|
|
64
|
+
local contentIds = _binding_2[1]
|
|
65
|
+
local contentNamesById = _binding_2[2]
|
|
66
|
+
local currentAsset, setCurrentAsset = useDeferState()
|
|
67
|
+
useAsyncEffect(TS.async(function()
|
|
68
|
+
local unit = (1 / #contentIds) * 100
|
|
69
|
+
ContentProvider:PreloadAsync(contentIds, function(assetId)
|
|
70
|
+
local _assetId = assetId
|
|
71
|
+
setCurrentAsset(contentNamesById[_assetId])
|
|
72
|
+
setPercentage(function(prev)
|
|
73
|
+
local newPercentage = math.round(math.clamp(prev + unit, 0, 100))
|
|
74
|
+
if newPercentage == 100 then
|
|
75
|
+
setLoaded(true)
|
|
76
|
+
end
|
|
77
|
+
return newPercentage
|
|
78
|
+
end)
|
|
79
|
+
end)
|
|
80
|
+
setCurrentAsset(nil)
|
|
81
|
+
end), {})
|
|
82
|
+
local _result
|
|
83
|
+
if loaded then
|
|
84
|
+
_result = ({
|
|
85
|
+
children = children,
|
|
86
|
+
})
|
|
87
|
+
else
|
|
88
|
+
local _attributes = {
|
|
89
|
+
key = "Preloader",
|
|
90
|
+
}
|
|
91
|
+
for _k, _v in container do
|
|
92
|
+
_attributes[_k] = _v
|
|
93
|
+
end
|
|
94
|
+
local _attributes_1 = table.clone(logo)
|
|
95
|
+
setmetatable(_attributes_1, nil)
|
|
96
|
+
local _exp = React.createElement("imagelabel", _attributes_1)
|
|
97
|
+
local _attributes_2 = table.clone(label)
|
|
98
|
+
setmetatable(_attributes_2, nil)
|
|
99
|
+
_attributes_2.Text = `Loading {if currentAsset ~= nil then currentAsset else "resources"}... {if showPercentage then string.format(`%.{loaderPrecision}f\%`, percentage) else ""}`
|
|
100
|
+
_result = (React.createElement("frame", _attributes, _exp, React.createElement("textlabel", _attributes_2), React.createElement(ProgressBar, {
|
|
101
|
+
className = progressBar,
|
|
102
|
+
progress = percentage,
|
|
103
|
+
})))
|
|
104
|
+
end
|
|
105
|
+
return React.createElement(React.Fragment, nil, _result)
|
|
106
|
+
end
|
|
107
|
+
local default = Preloader
|
|
108
|
+
return {
|
|
109
|
+
default = default,
|
|
110
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _theme = TS.import(script, script.Parent.Parent.Parent.Parent.Parent, "theme")
|
|
4
|
+
local createStyles = _theme.createStyles
|
|
5
|
+
local makeStyles = _theme.makeStyles
|
|
6
|
+
local usePreloaderStyles = makeStyles(function(theme, props)
|
|
7
|
+
local getLogo = function(props)
|
|
8
|
+
local _binding = props
|
|
9
|
+
local logo = _binding.logo
|
|
10
|
+
return logo
|
|
11
|
+
end
|
|
12
|
+
return createStyles({
|
|
13
|
+
container = {
|
|
14
|
+
Size = UDim2.new(1, 0, 1, 0),
|
|
15
|
+
BackgroundColor3 = theme.palette.background.default,
|
|
16
|
+
BorderSizePixel = 0,
|
|
17
|
+
ZIndex = 100000,
|
|
18
|
+
},
|
|
19
|
+
logo = {
|
|
20
|
+
Size = UDim2.new(0.33, 0, 0.33, 0),
|
|
21
|
+
Position = UDim2.new(0.5, 0, 0.4, 0),
|
|
22
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
23
|
+
BackgroundTransparency = 1,
|
|
24
|
+
BorderSizePixel = 0,
|
|
25
|
+
Image = getLogo(props),
|
|
26
|
+
ScaleType = Enum.ScaleType.Fit,
|
|
27
|
+
ZIndex = 110000,
|
|
28
|
+
},
|
|
29
|
+
label = {
|
|
30
|
+
Size = UDim2.new(0.33, 0, 0, theme.spacing.calc(2)),
|
|
31
|
+
Position = UDim2.new(0.5, 0, 0.73, theme.spacing.calc(2) + theme.padding.calc(4)),
|
|
32
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
33
|
+
BackgroundTransparency = 1,
|
|
34
|
+
BorderSizePixel = 0,
|
|
35
|
+
TextSize = theme.typography.fontSizes.h3,
|
|
36
|
+
TextColor3 = theme.palette.text.primary,
|
|
37
|
+
Font = theme.typography.fontFamilies.bold,
|
|
38
|
+
TextScaled = false,
|
|
39
|
+
ZIndex = 110000,
|
|
40
|
+
},
|
|
41
|
+
progressBar = {
|
|
42
|
+
Size = UDim2.new(0.33, 0, 0, theme.spacing.calc(2)),
|
|
43
|
+
Position = UDim2.new(0.5, 0, 0.74, theme.padding.calc(2)),
|
|
44
|
+
AnchorPoint = Vector2.new(0.5, 0.5),
|
|
45
|
+
ZIndex = 110000,
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
end)
|
|
49
|
+
local default = usePreloaderStyles
|
|
50
|
+
return {
|
|
51
|
+
default = default,
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local exports = {}
|
|
4
|
+
exports.Preloader = TS.import(script, script, "components", "Preloader").default
|
|
5
|
+
for _k, _v in TS.import(script, script, "components", "Preloader") or {} do
|
|
6
|
+
exports[_k] = _v
|
|
7
|
+
end
|
|
8
|
+
return exports
|