@nrbx/topbar-components 1.3.0 → 1.3.1
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/components/overflow.luau +39 -41
- package/package.json +1 -1
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local
|
|
5
|
-
local
|
|
6
|
-
local
|
|
7
|
-
local
|
|
8
|
-
local useStylesheet = TS.import(script, script.Parent.Parent, "context").useStylesheet
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local _context = TS.import(script, script.Parent.Parent, "context")
|
|
5
|
+
local LocationContext = _context.LocationContext
|
|
6
|
+
local useLocation = _context.useLocation
|
|
7
|
+
local Dropdown = TS.import(script, script.Parent, "dropdown").Dropdown
|
|
9
8
|
local Icon = TS.import(script, script.Parent, "icon").Icon
|
|
10
9
|
--[[
|
|
11
|
-
*
|
|
12
|
-
* Collects child icons and renders a "more" button (⋯) when they overflow
|
|
13
|
-
* the available space. Overflowing icons appear in a dropdown.
|
|
14
|
-
*
|
|
15
|
-
* Simplified from TopbarPlus v3 overflow handler.
|
|
10
|
+
*
|
|
11
|
+
* Collects child icons and renders a "more" button (⋯) when they overflow
|
|
12
|
+
* the available space. Overflowing icons appear in a dropdown.
|
|
13
|
+
*
|
|
14
|
+
* Simplified from TopbarPlus v3 overflow handler.
|
|
16
15
|
|
|
17
16
|
]]
|
|
17
|
+
local OverflowDropdown
|
|
18
18
|
local function Overflow(_param)
|
|
19
19
|
local children = _param.children
|
|
20
|
-
local
|
|
21
|
-
|
|
22
|
-
local childArray = useMemo(function()
|
|
23
|
-
local arr = React.Children.toArray(children)
|
|
24
|
-
return arr
|
|
25
|
-
end, { children })
|
|
26
|
-
local overflowCount = #childArray
|
|
27
|
-
local handleToggle = useCallback(function(state)
|
|
28
|
-
setExpanded(state == "selected")
|
|
29
|
-
end, {})
|
|
30
|
-
if overflowCount == 0 then
|
|
20
|
+
local childArray = React.Children.toArray(children)
|
|
21
|
+
if #childArray == 0 then
|
|
31
22
|
return React.createElement(React.Fragment)
|
|
32
23
|
end
|
|
33
24
|
return React.createElement(Icon, {
|
|
34
25
|
imageId = "rbxassetid://6069276526",
|
|
35
26
|
toggle = true,
|
|
36
27
|
defaultState = "deselected",
|
|
37
|
-
stateChanged = handleToggle,
|
|
38
28
|
contentPaddingX = 4,
|
|
39
29
|
contentPaddingY = 4,
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
30
|
+
}, React.createElement(OverflowDropdown, nil, childArray))
|
|
31
|
+
end
|
|
32
|
+
--[[
|
|
33
|
+
*
|
|
34
|
+
* Mounts a {@link Dropdown} inside the overflow button without letting it
|
|
35
|
+
* resize the button's layout footprint. The overflow menu is a floating
|
|
36
|
+
* overlay, so it must not push the surrounding topbar icons around when it
|
|
37
|
+
* opens or closes.
|
|
38
|
+
|
|
39
|
+
]]
|
|
40
|
+
function OverflowDropdown(_param)
|
|
41
|
+
local children = _param.children
|
|
42
|
+
local location = useLocation()
|
|
43
|
+
local _arg0 = location.type == "icon"
|
|
44
|
+
assert(_arg0, "Overflow dropdown must be rendered under an icon")
|
|
45
|
+
return React.createElement(LocationContext.Provider, {
|
|
46
|
+
value = {
|
|
47
|
+
type = "icon",
|
|
48
|
+
isVisible = location.isVisible,
|
|
49
|
+
isUnderDropdown = location.isUnderDropdown,
|
|
50
|
+
width = location.width,
|
|
51
|
+
setAnimationState = location.setAnimationState,
|
|
52
|
+
setContentSize = location.setContentSize,
|
|
53
|
+
setDropdownSize = function() end,
|
|
54
|
+
},
|
|
55
|
+
}, React.createElement(Dropdown, nil, children))
|
|
58
56
|
end
|
|
59
57
|
return {
|
|
60
58
|
Overflow = Overflow,
|