@rbxts/uiblox 0.1.27 → 0.1.28

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,6 @@
1
1
  export { ClassNameMap } from "./types/index";
2
2
  export { WriteableStyle } from "./types/index";
3
+ export { ConditionalStylesMap } from "./types/index";
3
4
  export { createStyles } from "./utilities/index";
4
5
  export { makeStyles } from "./utilities/index";
5
6
  export { classNames } from "./utilities/index";
@@ -0,0 +1,2 @@
1
+ import { WriteableStyle } from "./WriteableStyle";
2
+ export type ConditionalStylesMap<T extends Instance> = Map<WriteableStyle<T>, boolean>;
@@ -0,0 +1,2 @@
1
+ -- Compiled with roblox-ts v3.0.0
2
+ return nil
@@ -1,2 +1,3 @@
1
1
  export { ClassNameMap } from "./styles";
2
2
  export { WriteableStyle } from "./WriteableStyle";
3
+ export { ConditionalStylesMap } from "./ConditionalStylesMap";
@@ -1,7 +1,3 @@
1
- import { WriteableStyle } from "../types/WriteableStyle";
2
- export type GenericStyle = {
3
- [property: string]: boolean;
4
- };
5
- export type ConditionalStyles<T extends Instance> = Map<WriteableStyle<T>, boolean>;
6
- declare function classNames<T extends Instance>(...args: [...Array<WriteableStyle<T>>, ConditionalStyles<T>] | [...Array<WriteableStyle<T>>]): WriteableStyle<T>;
1
+ import { WriteableStyle, ConditionalStylesMap } from "../types/index";
2
+ declare function classNames<T extends Instance>(...args: [...Array<WriteableStyle<T>>, ConditionalStylesMap<T>] | [...Array<WriteableStyle<T>>]): WriteableStyle<T>;
7
3
  export default classNames;
@@ -1,5 +1,5 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
- -- eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ local TS = _G[script]
3
3
  local classNamesInternal = function(conditionalStyles, ...)
4
4
  local styles = { ... }
5
5
  local style = {}
@@ -45,23 +45,37 @@ local function classNames(...)
45
45
  local args = { ... }
46
46
  -- Check if last argument is ConditionalStyles
47
47
  local hasConditionalStyles = function(args)
48
- local lastArg = args[#args]
49
- if lastArg == nil then
50
- return false
48
+ local _exitType, _returns = TS.try(function()
49
+ local lastArg = args[#args]
50
+ return TS.TRY_RETURN, { lastArg ~= nil and type(lastArg) == "table" }
51
+ end, function()
52
+ -- If we catch an error, it means that the last argument is not a ConditionalStyles<T>
53
+ return TS.TRY_RETURN, { false }
54
+ end)
55
+ if _exitType then
56
+ return unpack(_returns)
51
57
  end
52
- return type(lastArg) == "table"
53
58
  end
54
- if hasConditionalStyles(args) then
55
- -- Handle case with ConditionalStyles
56
- -- ▼ Array.pop ▼
57
- local _length = #args
58
- local _result = args[_length]
59
- args[_length] = nil
60
- -- ▲ Array.pop ▲
61
- local conditionalStyles = _result
59
+ local _exitType, _returns = TS.try(function()
60
+ if hasConditionalStyles(args) then
61
+ -- Handle case with ConditionalStyles
62
+ -- ▼ Array.pop ▼
63
+ local _length = #args
64
+ local _result = args[_length]
65
+ args[_length] = nil
66
+ -- ▲ Array.pop ▲
67
+ local conditionalStyles = _result
68
+ local styles = args
69
+ -- ConditionalStyles<T> is the last argument
70
+ return TS.TRY_RETURN, { classNamesInternal(conditionalStyles, unpack(styles)) }
71
+ end
72
+ end, function()
73
+ -- If we catch an error, like attempt to iterate over a string value, it means that the last argument is not a ConditionalStyles<T>
62
74
  local styles = args
63
- -- ConditionalStyles<T> is the last argument
64
- return classNamesInternal(conditionalStyles, unpack(styles))
75
+ return TS.TRY_RETURN, { classNamesInternal(nil, unpack(styles)) }
76
+ end)
77
+ if _exitType then
78
+ return unpack(_returns)
65
79
  end
66
80
  -- Handle case without ConditionalStyles
67
81
  -- All args are WriteableStyle<T>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {