@rbxts/uiblox 0.1.38 → 0.1.39

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.
@@ -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,3 @@
1
+ export { default as ThemeContext } from "./provider";
2
+ export * from "./provider";
3
+ export { default as themeReducer } from "./reducer";
@@ -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,3 @@
1
+ import { ThemeAction, ThemeState } from "../types/index";
2
+ declare function themeReducer(state: ThemeState | undefined, action: ThemeAction): ThemeState;
3
+ export default themeReducer;
@@ -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,4 @@
1
+ export declare enum ThemeActionTypes {
2
+ Hydrate = "Hydrate",
3
+ SetTheme = "SetTheme"
4
+ }
@@ -0,0 +1,8 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local ThemeActionTypes = {
3
+ Hydrate = "Hydrate",
4
+ SetTheme = "SetTheme",
5
+ }
6
+ return {
7
+ ThemeActionTypes = ThemeActionTypes,
8
+ }
@@ -0,0 +1 @@
1
+ export * from "./ThemeActionTypes";
@@ -0,0 +1,7 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ for _k, _v in TS.import(script, script, "ThemeActionTypes") or {} do
5
+ exports[_k] = _v
6
+ end
7
+ return exports
@@ -0,0 +1 @@
1
+ export { default as useTheme } from "./useTheme";
@@ -0,0 +1,5 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ exports.useTheme = TS.import(script, script, "useTheme").default
5
+ return exports
@@ -0,0 +1,5 @@
1
+ declare function useTheme(): {
2
+ state: import("../index").ThemeState;
3
+ dispatch: import("../index").ThemeDispatch | undefined;
4
+ };
5
+ export default 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
+ }
@@ -1,14 +1,19 @@
1
1
  export { default as Theme } from "./interfaces/theme/Theme";
2
- export { ThemeProvider } from "./components/index";
3
- export { ThemeState } from "./components/index";
4
- export * from "./components/index";
2
+ export * from "./context/index";
3
+ export { ThemeProvider } from "./context/index";
4
+ export { themeReducer } from "./context/index";
5
5
  export * from "./constants/index";
6
+ export * from "./enums/index";
7
+ export { useTheme } from "./hooks/index";
6
8
  export * from "./interfaces/index";
7
9
  export * from "./styles/index";
8
10
  export * from "./themes/index";
9
11
  export { default as DefaultTheme } from "./themes/index";
10
12
  export { default as DarkTheme } from "./themes/DarkTheme";
11
13
  export { default as LightTheme } from "./themes/LightTheme";
14
+ export { ThemeState } from "./types/index";
15
+ export { ThemeAction } from "./types/index";
16
+ export { ThemeDispatch } from "./types/index";
12
17
  export { CommonProps } from "./types/index";
13
18
  export { BaseDefaultProps } from "./types/index";
14
19
  export { BaseCustomizedProps } from "./types/index";
@@ -1,13 +1,18 @@
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, "components").ThemeProvider
5
- for _k, _v in TS.import(script, script, "components") or {} do
4
+ for _k, _v in TS.import(script, script, "context") or {} do
6
5
  exports[_k] = _v
7
6
  end
7
+ exports.ThemeProvider = TS.import(script, script, "context").ThemeProvider
8
+ exports.themeReducer = TS.import(script, script, "context").themeReducer
8
9
  for _k, _v in TS.import(script, script, "constants") or {} do
9
10
  exports[_k] = _v
10
11
  end
12
+ for _k, _v in TS.import(script, script, "enums") or {} do
13
+ exports[_k] = _v
14
+ end
15
+ exports.useTheme = TS.import(script, script, "hooks").useTheme
11
16
  for _k, _v in TS.import(script, script, "interfaces") or {} do
12
17
  exports[_k] = _v
13
18
  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 themeProducer = TS.import(script, script.Parent.Parent.Parent, "components", "ThemeProducer").themeProducer
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 theme = themeProducer:getState()
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>;
@@ -0,0 +1,2 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ return nil
@@ -1,3 +1,6 @@
1
+ export { ThemeState } from "./context";
2
+ export { ThemeAction } from "./context";
3
+ export { ThemeDispatch } from "./context";
1
4
  export { CommonProps } from "./types";
2
5
  export { BaseDefaultProps } from "./types";
3
6
  export { BaseCustomizedProps } from "./types";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.38",
3
+ "version": "0.1.39",
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
- }
@@ -1,5 +0,0 @@
1
- export { default as ThemeProvider } from "./ThemeProvider";
2
- export { ThemeProviderProps } from "./ThemeProvider";
3
- export * from "./ThemeProvider";
4
- export { ThemeState } from "./ThemeProducer";
5
- export { ThemeProducer } from "./ThemeProducer";
@@ -1,8 +0,0 @@
1
- -- Compiled with roblox-ts v3.0.0
2
- local TS = _G[script]
3
- local exports = {}
4
- exports.ThemeProvider = TS.import(script, script, "ThemeProvider").default
5
- for _k, _v in TS.import(script, script, "ThemeProvider") or {} do
6
- exports[_k] = _v
7
- end
8
- return exports