@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.
@@ -1,60 +1,58 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
- local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
4
- local React = _react
5
- local useCallback = _react.useCallback
6
- local useMemo = _react.useMemo
7
- local useState = _react.useState
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 stylesheet = useStylesheet()
21
- local expanded, setExpanded = useState(false)
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
- }, expanded and (React.createElement("frame", {
41
- Size = UDim2.new(0, 0, 0, 0),
42
- Position = stylesheet.customDropdown.position or stylesheet.dropdownTheme.position,
43
- BackgroundColor3 = stylesheet.dropdownTheme.backgroundColor,
44
- BackgroundTransparency = stylesheet.dropdownTheme.backgroundTransparency,
45
- BorderSizePixel = stylesheet.dropdownTheme.borderSize,
46
- BorderColor3 = stylesheet.dropdownTheme.borderColor,
47
- ZIndex = 50,
48
- }, React.createElement("uicorner", {
49
- CornerRadius = stylesheet.dropdownTheme.cornerRadius,
50
- }), React.createElement("uistroke", {
51
- Color = stylesheet.dropdownTheme.borderColor,
52
- Transparency = stylesheet.dropdownTheme.borderTransparency,
53
- Thickness = stylesheet.dropdownTheme.borderSize,
54
- }), React.createElement("uilistlayout", {
55
- SortOrder = Enum.SortOrder.LayoutOrder,
56
- Padding = UDim.new(0, 2),
57
- }), childArray)))
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrbx/topbar-components",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "main": "out/init.luau",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",