@rbxts/uiblox 0.1.47 → 0.1.49

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.
@@ -0,0 +1,5 @@
1
+ import { Theme } from "../interfaces/theme/index";
2
+ export declare const themeProducer: import("@rbxts/reflex").Producer<Theme, {
3
+ setTheme: (_state: Theme, theme: Theme) => Theme;
4
+ }>;
5
+ export type ThemeProducer = typeof themeProducer;
@@ -0,0 +1,12 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ local TS = _G[script]
3
+ local createProducer = TS.import(script, TS.getModule(script, "@rbxts", "reflex").src).createProducer
4
+ local DEFAULT_THEME = TS.import(script, script.Parent.Parent, "constants").DEFAULT_THEME
5
+ local themeProducer = createProducer(DEFAULT_THEME, {
6
+ setTheme = function(_state, theme)
7
+ return theme
8
+ end,
9
+ })
10
+ return {
11
+ themeProducer = themeProducer,
12
+ }
@@ -1,11 +1,7 @@
1
- import React, { PropsWithChildren } from "@rbxts/react";
2
1
  import { Theme } from "../interfaces/index";
3
- export declare const ThemeContext: React.Context<{
4
- theme: Theme;
5
- setTheme?: React.Dispatch<React.SetStateAction<Theme>>;
6
- }>;
2
+ import { CustomizedProps } from "../types/index";
7
3
  export interface ThemeProviderProps {
8
- initialTheme?: Theme;
4
+ theme?: Theme;
9
5
  }
10
- export declare function ThemeProvider(props: PropsWithChildren<ThemeProviderProps>): JSX.Element;
6
+ declare function ThemeProvider(props: CustomizedProps<Instance, ThemeProviderProps>): JSX.Element;
11
7
  export default ThemeProvider;
@@ -2,33 +2,27 @@
2
2
  local TS = _G[script]
3
3
  local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
4
  local React = _react
5
+ local StrictMode = _react.StrictMode
5
6
  local useEffect = _react.useEffect
6
- local useMemo = _react.useMemo
7
- local useState = _react.useState
7
+ local ReflexProvider = TS.import(script, TS.getModule(script, "@rbxts", "react-reflex")).ReflexProvider
8
8
  local DEFAULT_THEME = TS.import(script, script.Parent.Parent, "constants").DEFAULT_THEME
9
- local ThemeContext = React.createContext({
10
- theme = DEFAULT_THEME,
11
- })
9
+ local themeProducer = TS.import(script, script.Parent, "ThemeProducer").themeProducer
12
10
  local function ThemeProvider(props)
13
11
  local _binding = props
14
- local initialTheme = _binding.initialTheme
15
- local theme, setTheme = useState(initialTheme or DEFAULT_THEME)
12
+ local theme = _binding.theme
13
+ if theme == nil then
14
+ theme = DEFAULT_THEME
15
+ end
16
+ local children = _binding.children
17
+ -- When theme prop changes
16
18
  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
- }
19
+ themeProducer.setTheme(theme)
24
20
  end, { theme })
25
- return React.createElement(ThemeContext.Provider, {
26
- value = memoizedValue,
27
- }, props.children)
21
+ return React.createElement(StrictMode, nil, React.createElement(ReflexProvider, {
22
+ producer = themeProducer,
23
+ }, children))
28
24
  end
29
25
  local default = ThemeProvider
30
26
  return {
31
- ThemeProvider = ThemeProvider,
32
- ThemeContext = ThemeContext,
33
27
  default = default,
34
28
  }
@@ -1,4 +1,6 @@
1
- export default function useTheme(): {
2
- theme: import("../index").Theme;
3
- setTheme?: import("@rbxts/react").Dispatch<import("@rbxts/react").SetStateAction<import("..").Theme>>;
1
+ import { Theme } from "../interfaces/index";
2
+ declare const useTheme: () => {
3
+ theme: Theme;
4
+ setTheme: (theme: Theme) => void;
4
5
  };
6
+ export default useTheme;
@@ -1,10 +1,26 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
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
- return useContext(ThemeContext)
3
+ local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
+ local useCallback = _react.useCallback
5
+ local useMemo = _react.useMemo
6
+ local useState = _react.useState
7
+ local themeProducer = TS.import(script, script.Parent.Parent, "context", "ThemeProducer").themeProducer
8
+ local useTheme = function()
9
+ local theme, setTheme = useState(themeProducer:getState())
10
+ themeProducer:subscribe(function(state, _previousState)
11
+ setTheme(state)
12
+ end)
13
+ local setProducerTheme = useCallback(function(t)
14
+ themeProducer.setTheme(t)
15
+ end, { setTheme })
16
+ return useMemo(function()
17
+ return {
18
+ theme = theme,
19
+ setTheme = setProducerTheme,
20
+ }
21
+ end, { theme, setTheme })
7
22
  end
23
+ local default = useTheme
8
24
  return {
9
- default = useTheme,
25
+ default = default,
10
26
  }
@@ -3,7 +3,6 @@ export * from "./constants/index";
3
3
  export { DEFAULT_THEME } from "./constants/index";
4
4
  export * from "./context/index";
5
5
  export { ThemeProvider } from "./context/index";
6
- export { ThemeContext } from "./context/index";
7
6
  export { useTheme } from "./hooks/index";
8
7
  export * from "./interfaces/index";
9
8
  export * from "./styles/index";
@@ -9,7 +9,6 @@ for _k, _v in TS.import(script, script, "context") or {} do
9
9
  exports[_k] = _v
10
10
  end
11
11
  exports.ThemeProvider = TS.import(script, script, "context").ThemeProvider
12
- exports.ThemeContext = TS.import(script, script, "context").ThemeContext
13
12
  exports.useTheme = TS.import(script, script, "hooks").useTheme
14
13
  for _k, _v in TS.import(script, script, "interfaces") or {} do
15
14
  exports[_k] = _v
@@ -1,13 +1,13 @@
1
1
  import { CustomizedProps } from "../../../../theme/index";
2
2
  export interface GridProps {
3
- cellPadding?: UDim;
3
+ cellPadding?: UDim2;
4
4
  cellSize?: UDim2;
5
5
  fillDirection?: Enum.FillDirection;
6
6
  fillDirectionMaxCells?: number;
7
7
  sortOrder?: Enum.SortOrder;
8
8
  startCorner: Enum.StartCorner;
9
9
  horizontalAlignment?: Enum.HorizontalAlignment;
10
- veritcalAlignment?: Enum.VerticalAlignment;
10
+ verticalAlignment?: Enum.VerticalAlignment;
11
11
  }
12
12
  declare function Grid(props: CustomizedProps<Frame, GridProps>): JSX.Element;
13
13
  export default Grid;
@@ -20,7 +20,7 @@ local useGridStyles = makeStyles(function(_, props)
20
20
  SortOrder = props.sortOrder,
21
21
  StartCorner = props.startCorner,
22
22
  HorizontalAlignment = props.horizontalAlignment,
23
- VerticalAlignment = props.veritcalAlignment,
23
+ VerticalAlignment = props.verticalAlignment,
24
24
  },
25
25
  })
26
26
  end)
@@ -28,7 +28,7 @@ local function Grid(props)
28
28
  local _binding = props
29
29
  local cellPadding = _binding.cellPadding
30
30
  if cellPadding == nil then
31
- cellPadding = UDim.new(0, 0)
31
+ cellPadding = UDim2.fromScale(0, 0)
32
32
  end
33
33
  local cellSize = _binding.cellSize
34
34
  if cellSize == nil then
@@ -54,9 +54,9 @@ local function Grid(props)
54
54
  if horizontalAlignment == nil then
55
55
  horizontalAlignment = Enum.HorizontalAlignment.Left
56
56
  end
57
- local veritcalAlignment = _binding.veritcalAlignment
58
- if veritcalAlignment == nil then
59
- veritcalAlignment = Enum.VerticalAlignment.Top
57
+ local verticalAlignment = _binding.verticalAlignment
58
+ if verticalAlignment == nil then
59
+ verticalAlignment = Enum.VerticalAlignment.Top
60
60
  end
61
61
  local className = _binding.className
62
62
  local children = _binding.children
@@ -70,7 +70,7 @@ local function Grid(props)
70
70
  sortOrder = sortOrder,
71
71
  startCorner = startCorner,
72
72
  horizontalAlignment = horizontalAlignment,
73
- veritcalAlignment = veritcalAlignment,
73
+ verticalAlignment = verticalAlignment,
74
74
  })
75
75
  local baseGrid = _binding_1.baseGrid
76
76
  local baseLayout = _binding_1.baseLayout
@@ -6,7 +6,7 @@ export interface ListProps {
6
6
  wrap?: "wrap" | "no-wrap";
7
7
  horizontalAlignment?: Enum.HorizontalAlignment;
8
8
  horizontalFlex?: Enum.UIFlexAlignment;
9
- veritcalAlignment?: Enum.VerticalAlignment;
9
+ verticalAlignment?: Enum.VerticalAlignment;
10
10
  verticalFlex?: Enum.UIFlexAlignment;
11
11
  }
12
12
  declare function List(props: CustomizedProps<Frame, ListProps>): JSX.Element;
@@ -19,7 +19,7 @@ local useListStyles = makeStyles(function(_, props)
19
19
  Wraps = props.wrap == "wrap",
20
20
  HorizontalAlignment = props.horizontalAlignment,
21
21
  HorizontalFlex = props.horizontalFlex,
22
- VerticalAlignment = props.veritcalAlignment,
22
+ VerticalAlignment = props.verticalAlignment,
23
23
  VerticalFlex = props.verticalFlex,
24
24
  },
25
25
  })
@@ -50,9 +50,9 @@ local function List(props)
50
50
  if horizontalFlex == nil then
51
51
  horizontalFlex = Enum.UIFlexAlignment.None
52
52
  end
53
- local veritcalAlignment = _binding.veritcalAlignment
54
- if veritcalAlignment == nil then
55
- veritcalAlignment = Enum.VerticalAlignment.Top
53
+ local verticalAlignment = _binding.verticalAlignment
54
+ if verticalAlignment == nil then
55
+ verticalAlignment = Enum.VerticalAlignment.Top
56
56
  end
57
57
  local verticalFlex = _binding.verticalFlex
58
58
  if verticalFlex == nil then
@@ -69,7 +69,7 @@ local function List(props)
69
69
  wrap = wrap,
70
70
  horizontalAlignment = horizontalAlignment,
71
71
  horizontalFlex = horizontalFlex,
72
- veritcalAlignment = veritcalAlignment,
72
+ verticalAlignment = verticalAlignment,
73
73
  verticalFlex = verticalFlex,
74
74
  })
75
75
  local baseList = _binding_1.baseList
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {