@rbxts/uiblox 0.1.38 → 0.1.40
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/callbacks/index.d.ts +1 -0
- package/out/theme/callbacks/init.luau +5 -0
- package/out/theme/callbacks/useThemeCallbacks.d.ts +7 -0
- package/out/theme/callbacks/useThemeCallbacks.luau +23 -0
- package/out/theme/constants/ThemeConstants.d.ts +2 -0
- package/out/theme/constants/ThemeConstants.luau +5 -0
- package/out/theme/context/index.d.ts +3 -0
- package/out/theme/context/init.luau +9 -0
- package/out/theme/context/provider.d.ts +12 -0
- package/out/theme/context/provider.luau +39 -0
- package/out/theme/context/reducer.d.ts +3 -0
- package/out/theme/context/reducer.luau +26 -0
- package/out/theme/enums/ThemeActionTypes.d.ts +4 -0
- package/out/theme/enums/ThemeActionTypes.luau +8 -0
- package/out/theme/enums/index.d.ts +1 -0
- package/out/theme/enums/init.luau +7 -0
- package/out/theme/hooks/index.d.ts +1 -0
- package/out/theme/hooks/init.luau +5 -0
- package/out/theme/hooks/useTheme.d.ts +5 -0
- package/out/theme/hooks/useTheme.luau +15 -0
- package/out/theme/index.d.ts +9 -3
- package/out/theme/init.luau +9 -3
- package/out/theme/styles/utilities/makeStyles.luau +5 -2
- package/out/theme/types/context.d.ts +13 -0
- package/out/theme/types/context.luau +2 -0
- package/out/theme/types/index.d.ts +3 -0
- package/package.json +1 -3
- package/out/theme/components/ThemeProducer.d.ts +0 -7
- package/out/theme/components/ThemeProducer.luau +0 -12
- package/out/theme/components/ThemeProvider.d.ts +0 -7
- package/out/theme/components/ThemeProvider.luau +0 -22
- package/out/theme/components/ThemeWrapper.d.ts +0 -7
- package/out/theme/components/ThemeWrapper.luau +0 -32
- package/out/theme/components/index.d.ts +0 -5
- package/out/theme/components/init.luau +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useThemeCallbacks } from "./useThemeCallbacks";
|
|
@@ -0,0 +1,23 @@
|
|
|
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,5 +1,7 @@
|
|
|
1
1
|
import { Colors } from "../interfaces/palette/colors/index";
|
|
2
2
|
import { Borders } from "../interfaces/spacing/index";
|
|
3
|
+
import { ThemeState } from "../types/index";
|
|
3
4
|
export declare const DARK_THEME_COLORS: Colors;
|
|
4
5
|
export declare const LIGHT_THEME_COLORS: Colors;
|
|
5
6
|
export declare const DEFAULT_BORDERS: Borders;
|
|
7
|
+
export declare const INITIAL_THEME_STATE: ThemeState;
|
|
@@ -8,6 +8,7 @@ local Green = _colors.Green
|
|
|
8
8
|
local Purple = _colors.Purple
|
|
9
9
|
local Red = _colors.Red
|
|
10
10
|
local Yellow = _colors.Yellow
|
|
11
|
+
local DefaultTheme = TS.import(script, script.Parent.Parent).DefaultTheme
|
|
11
12
|
-- dark theme
|
|
12
13
|
local DARK_THEME_COLORS = {
|
|
13
14
|
backgroundDefault = Common.Black,
|
|
@@ -97,8 +98,12 @@ local DEFAULT_BORDERS = {
|
|
|
97
98
|
default = 1,
|
|
98
99
|
divider = 2,
|
|
99
100
|
}
|
|
101
|
+
local INITIAL_THEME_STATE = {
|
|
102
|
+
theme = DefaultTheme,
|
|
103
|
+
}
|
|
100
104
|
return {
|
|
101
105
|
DARK_THEME_COLORS = DARK_THEME_COLORS,
|
|
102
106
|
LIGHT_THEME_COLORS = LIGHT_THEME_COLORS,
|
|
103
107
|
DEFAULT_BORDERS = DEFAULT_BORDERS,
|
|
108
|
+
INITIAL_THEME_STATE = INITIAL_THEME_STATE,
|
|
104
109
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local exports = {}
|
|
4
|
+
exports.ThemeContext = TS.import(script, script, "provider").default
|
|
5
|
+
for _k, _v in TS.import(script, script, "provider") or {} do
|
|
6
|
+
exports[_k] = _v
|
|
7
|
+
end
|
|
8
|
+
exports.themeReducer = TS.import(script, script, "reducer").default
|
|
9
|
+
return exports
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from "@rbxts/react";
|
|
2
|
+
import { ThemeDispatch, ThemeState } from "../types/index";
|
|
3
|
+
import { Theme } from "../index";
|
|
4
|
+
export declare const ThemeContext: React.Context<{
|
|
5
|
+
state: ThemeState;
|
|
6
|
+
dispatch: ThemeDispatch | undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export interface ThemeProviderProps {
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
}
|
|
11
|
+
export declare function ThemeProvider(props: PropsWithChildren<ThemeProviderProps>): JSX.Element;
|
|
12
|
+
export default ThemeContext;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 _theme = TS.import(script, script.Parent.Parent)
|
|
9
|
+
local INITIAL_THEME_STATE = _theme.INITIAL_THEME_STATE
|
|
10
|
+
local ThemeActionTypes = _theme.ThemeActionTypes
|
|
11
|
+
local ThemeContext = React.createContext({
|
|
12
|
+
state = INITIAL_THEME_STATE,
|
|
13
|
+
dispatch = nil,
|
|
14
|
+
})
|
|
15
|
+
local function ThemeProvider(props)
|
|
16
|
+
local _binding = props
|
|
17
|
+
local theme = _binding.theme
|
|
18
|
+
local _object = table.clone(INITIAL_THEME_STATE)
|
|
19
|
+
setmetatable(_object, nil)
|
|
20
|
+
_object.theme = theme or INITIAL_THEME_STATE.theme
|
|
21
|
+
local state, dispatch = useReducer(themeReducer, _object)
|
|
22
|
+
useEffect(function()
|
|
23
|
+
dispatch({
|
|
24
|
+
type = ThemeActionTypes.Hydrate,
|
|
25
|
+
})
|
|
26
|
+
end, { dispatch })
|
|
27
|
+
return React.createElement(ThemeContext.Provider, {
|
|
28
|
+
value = {
|
|
29
|
+
state = state,
|
|
30
|
+
dispatch = dispatch,
|
|
31
|
+
},
|
|
32
|
+
}, props.children)
|
|
33
|
+
end
|
|
34
|
+
local default = ThemeContext
|
|
35
|
+
return {
|
|
36
|
+
ThemeProvider = ThemeProvider,
|
|
37
|
+
ThemeContext = ThemeContext,
|
|
38
|
+
default = default,
|
|
39
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ThemeActionTypes";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useTheme } from "./useTheme";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local useContext = TS.import(script, TS.getModule(script, "@rbxts", "react")).useContext
|
|
4
|
+
local ThemeContext = TS.import(script, script.Parent.Parent, "context").ThemeContext
|
|
5
|
+
local function useTheme()
|
|
6
|
+
local context = useContext(ThemeContext)
|
|
7
|
+
if not context then
|
|
8
|
+
error(error("Missing ThemeProvider"))
|
|
9
|
+
end
|
|
10
|
+
return context
|
|
11
|
+
end
|
|
12
|
+
local default = useTheme
|
|
13
|
+
return {
|
|
14
|
+
default = default,
|
|
15
|
+
}
|
package/out/theme/index.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
export { default as Theme } from "./interfaces/theme/Theme";
|
|
2
|
-
export {
|
|
3
|
-
export { ThemeState } from "./components/index";
|
|
4
|
-
export * from "./components/index";
|
|
2
|
+
export { useThemeCallbacks } from "./callbacks/index";
|
|
5
3
|
export * from "./constants/index";
|
|
4
|
+
export * from "./context/index";
|
|
5
|
+
export { ThemeProvider } from "./context/index";
|
|
6
|
+
export { themeReducer } from "./context/index";
|
|
7
|
+
export * from "./enums/index";
|
|
8
|
+
export { useTheme } from "./hooks/index";
|
|
6
9
|
export * from "./interfaces/index";
|
|
7
10
|
export * from "./styles/index";
|
|
8
11
|
export * from "./themes/index";
|
|
9
12
|
export { default as DefaultTheme } from "./themes/index";
|
|
10
13
|
export { default as DarkTheme } from "./themes/DarkTheme";
|
|
11
14
|
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";
|
|
12
18
|
export { CommonProps } from "./types/index";
|
|
13
19
|
export { BaseDefaultProps } from "./types/index";
|
|
14
20
|
export { BaseCustomizedProps } from "./types/index";
|
package/out/theme/init.luau
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local exports = {}
|
|
4
|
-
exports.
|
|
5
|
-
for _k, _v in TS.import(script, script, "
|
|
4
|
+
exports.useThemeCallbacks = TS.import(script, script, "callbacks").useThemeCallbacks
|
|
5
|
+
for _k, _v in TS.import(script, script, "constants") or {} do
|
|
6
6
|
exports[_k] = _v
|
|
7
7
|
end
|
|
8
|
-
for _k, _v in TS.import(script, script, "
|
|
8
|
+
for _k, _v in TS.import(script, script, "context") or {} do
|
|
9
|
+
exports[_k] = _v
|
|
10
|
+
end
|
|
11
|
+
exports.ThemeProvider = TS.import(script, script, "context").ThemeProvider
|
|
12
|
+
exports.themeReducer = TS.import(script, script, "context").themeReducer
|
|
13
|
+
for _k, _v in TS.import(script, script, "enums") or {} do
|
|
9
14
|
exports[_k] = _v
|
|
10
15
|
end
|
|
16
|
+
exports.useTheme = TS.import(script, script, "hooks").useTheme
|
|
11
17
|
for _k, _v in TS.import(script, script, "interfaces") or {} do
|
|
12
18
|
exports[_k] = _v
|
|
13
19
|
end
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local DefaultTheme = TS.import(script, script.Parent.Parent.Parent, "themes").default
|
|
4
|
-
local
|
|
4
|
+
local useTheme = TS.import(script, script.Parent.Parent.Parent, "hooks").useTheme
|
|
5
5
|
local makeStyles = function(f)
|
|
6
6
|
return function(props)
|
|
7
7
|
local _exitType, _returns = TS.try(function()
|
|
8
|
-
local
|
|
8
|
+
local _binding = useTheme()
|
|
9
|
+
local state = _binding.state
|
|
10
|
+
local _binding_1 = state
|
|
11
|
+
local theme = _binding_1.theme
|
|
9
12
|
local _fn = f
|
|
10
13
|
local _exp = theme or DefaultTheme
|
|
11
14
|
local _condition = props
|
|
@@ -0,0 +1,13 @@
|
|
|
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>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/uiblox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "UI Library and theming for roblox-ts projects",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"scripts": {
|
|
@@ -50,8 +50,6 @@
|
|
|
50
50
|
"@rbxts/react": "^17.2.1",
|
|
51
51
|
"@rbxts/react-reflex": "^0.3.4",
|
|
52
52
|
"@rbxts/react-roblox": "^17.2.1",
|
|
53
|
-
"@rbxts/reflex": "^4.3.1",
|
|
54
|
-
"@rbxts/roselect": "^0.1.2",
|
|
55
53
|
"@rbxts/services": "^1.5.5"
|
|
56
54
|
},
|
|
57
55
|
"directories": {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Theme } from "../interfaces/theme/index";
|
|
2
|
-
import { InferState } from "@rbxts/reflex";
|
|
3
|
-
export declare const themeProducer: import("@rbxts/reflex").Producer<Theme, {
|
|
4
|
-
setTheme: (_state: Theme, theme: Theme) => Theme;
|
|
5
|
-
}>;
|
|
6
|
-
export type ThemeProducer = typeof themeProducer;
|
|
7
|
-
export type ThemeState = InferState<ThemeProducer>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
-- Compiled with roblox-ts v3.0.0
|
|
2
|
-
local TS = _G[script]
|
|
3
|
-
local DefaultTheme = TS.import(script, script.Parent.Parent, "themes").default
|
|
4
|
-
local createProducer = TS.import(script, TS.getModule(script, "@rbxts", "reflex").src).createProducer
|
|
5
|
-
local themeProducer = createProducer(DefaultTheme, {
|
|
6
|
-
setTheme = function(_state, theme)
|
|
7
|
-
return theme
|
|
8
|
-
end,
|
|
9
|
-
})
|
|
10
|
-
return {
|
|
11
|
-
themeProducer = themeProducer,
|
|
12
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Theme } from "../interfaces/theme/index";
|
|
2
|
-
import { CustomizedProps } from "../types/index";
|
|
3
|
-
export interface ThemeProviderProps {
|
|
4
|
-
theme?: Theme;
|
|
5
|
-
}
|
|
6
|
-
declare function ThemeProvider(props: CustomizedProps<Instance, ThemeProviderProps>): JSX.Element;
|
|
7
|
-
export default ThemeProvider;
|
|
@@ -1,22 +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 StrictMode = _react.StrictMode
|
|
6
|
-
local ThemeWrapper = TS.import(script, script.Parent, "ThemeWrapper").default
|
|
7
|
-
local ReflexProvider = TS.import(script, TS.getModule(script, "@rbxts", "react-reflex")).ReflexProvider
|
|
8
|
-
local themeProducer = TS.import(script, script.Parent, "ThemeProducer").themeProducer
|
|
9
|
-
local function ThemeProvider(props)
|
|
10
|
-
local _binding = props
|
|
11
|
-
local theme = _binding.theme
|
|
12
|
-
local children = _binding.children
|
|
13
|
-
return React.createElement(StrictMode, nil, React.createElement(ReflexProvider, {
|
|
14
|
-
producer = themeProducer,
|
|
15
|
-
}, React.createElement(ThemeWrapper, {
|
|
16
|
-
theme = theme,
|
|
17
|
-
}, children)))
|
|
18
|
-
end
|
|
19
|
-
local default = ThemeProvider
|
|
20
|
-
return {
|
|
21
|
-
default = default,
|
|
22
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Theme } from "../interfaces/theme/index";
|
|
2
|
-
import { CustomizedProps } from "../types/index";
|
|
3
|
-
export interface ThemeWrapperProps {
|
|
4
|
-
theme?: Theme;
|
|
5
|
-
}
|
|
6
|
-
declare function ThemeWrapper(props: CustomizedProps<Instance, ThemeWrapperProps>): JSX.Element;
|
|
7
|
-
export default ThemeWrapper;
|
|
@@ -1,32 +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 useRef = _react.useRef
|
|
7
|
-
local DefaultTheme = TS.import(script, script.Parent.Parent, "themes").default
|
|
8
|
-
local useProducer = TS.import(script, TS.getModule(script, "@rbxts", "react-reflex")).useProducer
|
|
9
|
-
local themeProducer = TS.import(script, script.Parent, "ThemeProducer").themeProducer
|
|
10
|
-
local function ThemeWrapper(props)
|
|
11
|
-
local _binding = props
|
|
12
|
-
local theme = _binding.theme
|
|
13
|
-
local children = _binding.children
|
|
14
|
-
local _binding_1 = useProducer()
|
|
15
|
-
local setTheme = _binding_1.setTheme
|
|
16
|
-
local ref = useRef()
|
|
17
|
-
-- When theme prop changes
|
|
18
|
-
useEffect(function()
|
|
19
|
-
setTheme(theme or DefaultTheme)
|
|
20
|
-
end, { theme })
|
|
21
|
-
return React.createElement("frame", {
|
|
22
|
-
key = `ThemeWrapper-{themeProducer:getState().type}`,
|
|
23
|
-
BackgroundTransparency = 1,
|
|
24
|
-
Size = UDim2.new(1, 0, 1, 0),
|
|
25
|
-
ZIndex = 500000,
|
|
26
|
-
ref = ref,
|
|
27
|
-
}, children)
|
|
28
|
-
end
|
|
29
|
-
local default = ThemeWrapper
|
|
30
|
-
return {
|
|
31
|
-
default = default,
|
|
32
|
-
}
|