@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.
- package/out/theme/styles/index.d.ts +1 -0
- package/out/theme/styles/types/ConditionalStylesMap.d.ts +2 -0
- package/out/theme/styles/types/ConditionalStylesMap.luau +2 -0
- package/out/theme/styles/types/index.d.ts +1 -0
- package/out/theme/styles/utilities/classNames.d.ts +2 -6
- package/out/theme/styles/utilities/classNames.luau +29 -15
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { WriteableStyle } from "../types/
|
|
2
|
-
|
|
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
|
-
|
|
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
|
|
49
|
-
|
|
50
|
-
return
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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>
|