@rbxts/uiblox 0.1.24 → 0.1.27
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.
|
@@ -4,4 +4,7 @@ local exports = {}
|
|
|
4
4
|
exports.createStyles = TS.import(script, script, "utilities").createStyles
|
|
5
5
|
exports.makeStyles = TS.import(script, script, "utilities").makeStyles
|
|
6
6
|
exports.classNames = TS.import(script, script, "utilities").classNames
|
|
7
|
+
for _k, _v in TS.import(script, script, "utilities") or {} do
|
|
8
|
+
exports[_k] = _v
|
|
9
|
+
end
|
|
7
10
|
return exports
|
|
@@ -3,5 +3,5 @@ export type GenericStyle = {
|
|
|
3
3
|
[property: string]: boolean;
|
|
4
4
|
};
|
|
5
5
|
export type ConditionalStyles<T extends Instance> = Map<WriteableStyle<T>, boolean>;
|
|
6
|
-
declare
|
|
6
|
+
declare function classNames<T extends Instance>(...args: [...Array<WriteableStyle<T>>, ConditionalStyles<T>] | [...Array<WriteableStyle<T>>]): WriteableStyle<T>;
|
|
7
7
|
export default classNames;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
-- eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
-
local
|
|
3
|
+
local classNamesInternal = function(conditionalStyles, ...)
|
|
4
4
|
local styles = { ... }
|
|
5
|
-
-- eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
5
|
local style = {}
|
|
7
6
|
local _result = conditionalStyles
|
|
8
7
|
if _result ~= nil then
|
|
@@ -41,6 +40,34 @@ local classNames = function(conditionalStyles, ...)
|
|
|
41
40
|
setmetatable(_object, nil)
|
|
42
41
|
return _object
|
|
43
42
|
end
|
|
43
|
+
-- Use variadic tuple types to allow for multiple WriteableStyle<T> arguments with an optional ConditionalStyles<T> argument at the end
|
|
44
|
+
local function classNames(...)
|
|
45
|
+
local args = { ... }
|
|
46
|
+
-- Check if last argument is ConditionalStyles
|
|
47
|
+
local hasConditionalStyles = function(args)
|
|
48
|
+
local lastArg = args[#args]
|
|
49
|
+
if lastArg == nil then
|
|
50
|
+
return false
|
|
51
|
+
end
|
|
52
|
+
return type(lastArg) == "table"
|
|
53
|
+
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
|
|
62
|
+
local styles = args
|
|
63
|
+
-- ConditionalStyles<T> is the last argument
|
|
64
|
+
return classNamesInternal(conditionalStyles, unpack(styles))
|
|
65
|
+
end
|
|
66
|
+
-- Handle case without ConditionalStyles
|
|
67
|
+
-- All args are WriteableStyle<T>
|
|
68
|
+
local styles = args
|
|
69
|
+
return classNamesInternal(nil, unpack(styles))
|
|
70
|
+
end
|
|
44
71
|
local default = classNames
|
|
45
72
|
return {
|
|
46
73
|
default = default,
|