@rbxts/uiblox 0.1.45 → 0.1.47
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/theme/constants/StateConstants.d.ts +0 -2
- package/out/theme/constants/StateConstants.luau +0 -4
- package/out/theme/context/{provider.d.ts → ThemeProvider.d.ts} +3 -4
- package/out/theme/context/ThemeProvider.luau +34 -0
- package/out/theme/context/index.d.ts +2 -3
- package/out/theme/context/init.luau +2 -3
- package/out/theme/hooks/useTheme.d.ts +3 -4
- package/out/theme/hooks/useTheme.luau +4 -10
- package/out/theme/index.d.ts +1 -6
- package/out/theme/init.luau +1 -5
- package/out/theme/styles/utilities/makeStyles.luau +1 -3
- package/out/theme/types/index.d.ts +0 -3
- package/package.json +1 -1
- package/out/theme/callbacks/index.d.ts +0 -1
- package/out/theme/callbacks/init.luau +0 -5
- package/out/theme/callbacks/useThemeCallbacks.d.ts +0 -7
- package/out/theme/callbacks/useThemeCallbacks.luau +0 -23
- package/out/theme/context/provider.luau +0 -38
- package/out/theme/context/reducer.d.ts +0 -3
- package/out/theme/context/reducer.luau +0 -26
- package/out/theme/enums/ThemeActionTypes.d.ts +0 -4
- package/out/theme/enums/ThemeActionTypes.luau +0 -8
- package/out/theme/enums/index.d.ts +0 -1
- package/out/theme/enums/init.luau +0 -7
- package/out/theme/types/context.d.ts +0 -13
- package/out/theme/types/context.luau +0 -2
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local DarkTheme = TS.import(script, script.Parent.Parent, "themes").DarkTheme
|
|
4
4
|
local DEFAULT_THEME = DarkTheme
|
|
5
|
-
local INITIAL_THEME_STATE = {
|
|
6
|
-
theme = DEFAULT_THEME,
|
|
7
|
-
}
|
|
8
5
|
return {
|
|
9
6
|
DEFAULT_THEME = DEFAULT_THEME,
|
|
10
|
-
INITIAL_THEME_STATE = INITIAL_THEME_STATE,
|
|
11
7
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "@rbxts/react";
|
|
2
|
-
import { ThemeDispatch, ThemeState } from "../types/index";
|
|
3
2
|
import { Theme } from "../interfaces/index";
|
|
4
3
|
export declare const ThemeContext: React.Context<{
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
theme: Theme;
|
|
5
|
+
setTheme?: React.Dispatch<React.SetStateAction<Theme>>;
|
|
7
6
|
}>;
|
|
8
7
|
export interface ThemeProviderProps {
|
|
9
|
-
|
|
8
|
+
initialTheme?: Theme;
|
|
10
9
|
}
|
|
11
10
|
export declare function ThemeProvider(props: PropsWithChildren<ThemeProviderProps>): JSX.Element;
|
|
12
11
|
export default ThemeProvider;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 useEffect = _react.useEffect
|
|
6
|
+
local useMemo = _react.useMemo
|
|
7
|
+
local useState = _react.useState
|
|
8
|
+
local DEFAULT_THEME = TS.import(script, script.Parent.Parent, "constants").DEFAULT_THEME
|
|
9
|
+
local ThemeContext = React.createContext({
|
|
10
|
+
theme = DEFAULT_THEME,
|
|
11
|
+
})
|
|
12
|
+
local function ThemeProvider(props)
|
|
13
|
+
local _binding = props
|
|
14
|
+
local initialTheme = _binding.initialTheme
|
|
15
|
+
local theme, setTheme = useState(initialTheme or DEFAULT_THEME)
|
|
16
|
+
useEffect(function()
|
|
17
|
+
setTheme(initialTheme or DEFAULT_THEME)
|
|
18
|
+
end, { initialTheme })
|
|
19
|
+
local memoizedValue = useMemo(function()
|
|
20
|
+
return {
|
|
21
|
+
theme = theme,
|
|
22
|
+
setTheme = setTheme,
|
|
23
|
+
}
|
|
24
|
+
end, { theme })
|
|
25
|
+
return React.createElement(ThemeContext.Provider, {
|
|
26
|
+
value = memoizedValue,
|
|
27
|
+
}, props.children)
|
|
28
|
+
end
|
|
29
|
+
local default = ThemeProvider
|
|
30
|
+
return {
|
|
31
|
+
ThemeProvider = ThemeProvider,
|
|
32
|
+
ThemeContext = ThemeContext,
|
|
33
|
+
default = default,
|
|
34
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { default as ThemeProvider } from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export { default as themeReducer } from "./reducer";
|
|
1
|
+
export { default as ThemeProvider } from "./ThemeProvider";
|
|
2
|
+
export * from "./ThemeProvider";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
-
exports.ThemeProvider = TS.import(script, script, "
|
|
5
|
-
for _k, _v in TS.import(script, script, "
|
|
4
|
+
exports.ThemeProvider = TS.import(script, script, "ThemeProvider").default
|
|
5
|
+
for _k, _v in TS.import(script, script, "ThemeProvider") or {} do
|
|
6
6
|
exports[_k] = _v
|
|
7
7
|
end
|
|
8
|
-
exports.themeReducer = TS.import(script, script, "reducer").default
|
|
9
8
|
return exports
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default function useTheme(): {
|
|
2
|
+
theme: import("../index").Theme;
|
|
3
|
+
setTheme?: import("@rbxts/react").Dispatch<import("@rbxts/react").SetStateAction<import("..").Theme>>;
|
|
4
4
|
};
|
|
5
|
-
export default useTheme;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local useContext = _react.useContext
|
|
5
|
-
local useMemo = _react.useMemo
|
|
3
|
+
local useContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).useContext
|
|
6
4
|
local ThemeContext = TS.import(script, script.Parent.Parent, "context").ThemeContext
|
|
7
|
-
local useTheme
|
|
8
|
-
|
|
9
|
-
return useMemo(function()
|
|
10
|
-
return context
|
|
11
|
-
end, { context })
|
|
5
|
+
local function useTheme()
|
|
6
|
+
return useContext(ThemeContext)
|
|
12
7
|
end
|
|
13
|
-
local default = useTheme
|
|
14
8
|
return {
|
|
15
|
-
default =
|
|
9
|
+
default = useTheme,
|
|
16
10
|
}
|
package/out/theme/index.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
export { default as Theme } from "./interfaces/theme/Theme";
|
|
2
|
-
export { useThemeCallbacks } from "./callbacks/index";
|
|
3
2
|
export * from "./constants/index";
|
|
4
3
|
export { DEFAULT_THEME } from "./constants/index";
|
|
5
4
|
export * from "./context/index";
|
|
6
5
|
export { ThemeProvider } from "./context/index";
|
|
7
|
-
export {
|
|
8
|
-
export * from "./enums/index";
|
|
6
|
+
export { ThemeContext } from "./context/index";
|
|
9
7
|
export { useTheme } from "./hooks/index";
|
|
10
8
|
export * from "./interfaces/index";
|
|
11
9
|
export * from "./styles/index";
|
|
12
10
|
export * from "./themes/index";
|
|
13
11
|
export { default as DarkTheme } from "./themes/DarkTheme";
|
|
14
12
|
export { default as LightTheme } from "./themes/LightTheme";
|
|
15
|
-
export { ThemeState } from "./types/index";
|
|
16
|
-
export { ThemeAction } from "./types/index";
|
|
17
|
-
export { ThemeDispatch } from "./types/index";
|
|
18
13
|
export { CommonProps } from "./types/index";
|
|
19
14
|
export { BaseDefaultProps } from "./types/index";
|
|
20
15
|
export { BaseCustomizedProps } from "./types/index";
|
package/out/theme/init.luau
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
-
exports.useThemeCallbacks = TS.import(script, script, "callbacks").useThemeCallbacks
|
|
5
4
|
for _k, _v in TS.import(script, script, "constants") or {} do
|
|
6
5
|
exports[_k] = _v
|
|
7
6
|
end
|
|
@@ -10,10 +9,7 @@ for _k, _v in TS.import(script, script, "context") or {} do
|
|
|
10
9
|
exports[_k] = _v
|
|
11
10
|
end
|
|
12
11
|
exports.ThemeProvider = TS.import(script, script, "context").ThemeProvider
|
|
13
|
-
exports.
|
|
14
|
-
for _k, _v in TS.import(script, script, "enums") or {} do
|
|
15
|
-
exports[_k] = _v
|
|
16
|
-
end
|
|
12
|
+
exports.ThemeContext = TS.import(script, script, "context").ThemeContext
|
|
17
13
|
exports.useTheme = TS.import(script, script, "hooks").useTheme
|
|
18
14
|
for _k, _v in TS.import(script, script, "interfaces") or {} do
|
|
19
15
|
exports[_k] = _v
|
|
@@ -6,9 +6,7 @@ local makeStyles = function(f)
|
|
|
6
6
|
return function(props)
|
|
7
7
|
local _exitType, _returns = TS.try(function()
|
|
8
8
|
local _binding = useTheme()
|
|
9
|
-
local
|
|
10
|
-
local _binding_1 = state
|
|
11
|
-
local theme = _binding_1.theme
|
|
9
|
+
local theme = _binding.theme
|
|
12
10
|
local _fn = f
|
|
13
11
|
local _exp = theme or DefaultTheme
|
|
14
12
|
local _condition = props
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as useThemeCallbacks } from "./useThemeCallbacks";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local useMemo = TS.import(script, TS.getModule(script, "@rbxts", "react")).useMemo
|
|
4
|
-
local ThemeActionTypes = TS.import(script, script.Parent.Parent, "enums").ThemeActionTypes
|
|
5
|
-
local useTheme = TS.import(script, script.Parent.Parent, "hooks").useTheme
|
|
6
|
-
local function useThemeCallbacks()
|
|
7
|
-
local _binding = useTheme()
|
|
8
|
-
local dispatch = _binding.dispatch
|
|
9
|
-
return useMemo(function()
|
|
10
|
-
return if dispatch then {
|
|
11
|
-
onSetTheme = function(theme)
|
|
12
|
-
return dispatch({
|
|
13
|
-
type = ThemeActionTypes.SetTheme,
|
|
14
|
-
theme = theme,
|
|
15
|
-
})
|
|
16
|
-
end,
|
|
17
|
-
} else {}
|
|
18
|
-
end, { dispatch })
|
|
19
|
-
end
|
|
20
|
-
local default = useThemeCallbacks
|
|
21
|
-
return {
|
|
22
|
-
default = default,
|
|
23
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
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 useEffect = _react.useEffect
|
|
6
|
-
local useReducer = _react.useReducer
|
|
7
|
-
local themeReducer = TS.import(script, script.Parent, "reducer").default
|
|
8
|
-
local INITIAL_THEME_STATE = TS.import(script, script.Parent.Parent, "constants").INITIAL_THEME_STATE
|
|
9
|
-
local ThemeActionTypes = TS.import(script, script.Parent.Parent, "enums").ThemeActionTypes
|
|
10
|
-
local ThemeContext = React.createContext({
|
|
11
|
-
state = INITIAL_THEME_STATE,
|
|
12
|
-
dispatch = nil,
|
|
13
|
-
})
|
|
14
|
-
local function ThemeProvider(props)
|
|
15
|
-
local _binding = props
|
|
16
|
-
local theme = _binding.theme
|
|
17
|
-
local _object = table.clone(INITIAL_THEME_STATE)
|
|
18
|
-
setmetatable(_object, nil)
|
|
19
|
-
_object.theme = theme or INITIAL_THEME_STATE.theme
|
|
20
|
-
local state, dispatch = useReducer(themeReducer, _object)
|
|
21
|
-
useEffect(function()
|
|
22
|
-
dispatch({
|
|
23
|
-
type = ThemeActionTypes.Hydrate,
|
|
24
|
-
})
|
|
25
|
-
end, { dispatch })
|
|
26
|
-
return React.createElement(ThemeContext.Provider, {
|
|
27
|
-
value = {
|
|
28
|
-
state = state,
|
|
29
|
-
dispatch = dispatch,
|
|
30
|
-
},
|
|
31
|
-
}, props.children)
|
|
32
|
-
end
|
|
33
|
-
local default = ThemeProvider
|
|
34
|
-
return {
|
|
35
|
-
ThemeProvider = ThemeProvider,
|
|
36
|
-
ThemeContext = ThemeContext,
|
|
37
|
-
default = default,
|
|
38
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local INITIAL_THEME_STATE = TS.import(script, script.Parent.Parent, "constants").INITIAL_THEME_STATE
|
|
4
|
-
local ThemeActionTypes = TS.import(script, script.Parent.Parent, "enums").ThemeActionTypes
|
|
5
|
-
local function themeReducer(state, action)
|
|
6
|
-
if action.type == ThemeActionTypes.Hydrate then
|
|
7
|
-
local _object = table.clone(INITIAL_THEME_STATE)
|
|
8
|
-
setmetatable(_object, nil)
|
|
9
|
-
_object.theme = action.theme or INITIAL_THEME_STATE.theme
|
|
10
|
-
return _object
|
|
11
|
-
end
|
|
12
|
-
if not state then
|
|
13
|
-
error(error("State is undefined"))
|
|
14
|
-
end
|
|
15
|
-
if action.type == ThemeActionTypes.SetTheme then
|
|
16
|
-
local _object = table.clone(state)
|
|
17
|
-
setmetatable(_object, nil)
|
|
18
|
-
_object.theme = action.theme
|
|
19
|
-
return _object
|
|
20
|
-
end
|
|
21
|
-
error(error(`Unhandled action type: {action}`))
|
|
22
|
-
end
|
|
23
|
-
local default = themeReducer
|
|
24
|
-
return {
|
|
25
|
-
default = default,
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./ThemeActionTypes";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ThemeActionTypes } from "../enums/index";
|
|
2
|
-
import { Theme } from "../interfaces/index";
|
|
3
|
-
export interface ThemeState {
|
|
4
|
-
theme: Theme;
|
|
5
|
-
}
|
|
6
|
-
export type ThemeAction = {
|
|
7
|
-
type: ThemeActionTypes.Hydrate;
|
|
8
|
-
theme?: Theme;
|
|
9
|
-
} | {
|
|
10
|
-
type: ThemeActionTypes.SetTheme;
|
|
11
|
-
theme: Theme;
|
|
12
|
-
};
|
|
13
|
-
export type ThemeDispatch = React.Dispatch<ThemeAction>;
|