@lattice-ui/popover 0.3.2 → 0.4.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.
|
@@ -15,18 +15,22 @@ local function PopoverClose(props)
|
|
|
15
15
|
error("[PopoverClose] `asChild` requires a child element.")
|
|
16
16
|
end
|
|
17
17
|
return React.createElement(Slot, {
|
|
18
|
+
Active = true,
|
|
18
19
|
Event = {
|
|
19
20
|
Activated = handleActivated,
|
|
20
21
|
},
|
|
22
|
+
Selectable = false,
|
|
21
23
|
}, child)
|
|
22
24
|
end
|
|
23
25
|
return React.createElement("textbutton", {
|
|
26
|
+
Active = true,
|
|
24
27
|
AutoButtonColor = false,
|
|
25
28
|
BackgroundTransparency = 1,
|
|
26
29
|
BorderSizePixel = 0,
|
|
27
30
|
Event = {
|
|
28
31
|
Activated = handleActivated,
|
|
29
32
|
},
|
|
33
|
+
Selectable = false,
|
|
30
34
|
Size = UDim2.fromOffset(110, 34),
|
|
31
35
|
Text = "Close",
|
|
32
36
|
TextColor3 = Color3.fromRGB(240, 244, 250),
|
|
@@ -3,6 +3,7 @@ local TS = _G[script]
|
|
|
3
3
|
local _core = TS.import(script, TS.getModule(script, "@lattice-ui", "core").out)
|
|
4
4
|
local React = _core.React
|
|
5
5
|
local Slot = _core.Slot
|
|
6
|
+
local FocusScope = TS.import(script, TS.getModule(script, "@lattice-ui", "focus").out).FocusScope
|
|
6
7
|
local _layer = TS.import(script, TS.getModule(script, "@lattice-ui", "layer").out)
|
|
7
8
|
local DismissableLayer = _layer.DismissableLayer
|
|
8
9
|
local Presence = _layer.Presence
|
|
@@ -28,33 +29,18 @@ local function PopoverContentImpl(props)
|
|
|
28
29
|
local setContentRef = React.useCallback(function(instance)
|
|
29
30
|
popoverContext.contentRef.current = toGuiObject(instance)
|
|
30
31
|
end, { popoverContext.contentRef })
|
|
31
|
-
if props.asChild then
|
|
32
|
+
local contentNode = if props.asChild then ((function()
|
|
32
33
|
local child = props.children
|
|
33
34
|
if not React.isValidElement(child) then
|
|
34
35
|
error("[PopoverContent] `asChild` requires a child element.")
|
|
35
36
|
end
|
|
36
|
-
return React.createElement(
|
|
37
|
-
enabled = props.enabled,
|
|
38
|
-
modal = popoverContext.modal,
|
|
39
|
-
onDismiss = props.onDismiss,
|
|
40
|
-
onEscapeKeyDown = props.onEscapeKeyDown,
|
|
41
|
-
onInteractOutside = props.onInteractOutside,
|
|
42
|
-
onPointerDownOutside = props.onPointerDownOutside,
|
|
43
|
-
}, React.createElement(Slot, {
|
|
37
|
+
return React.createElement(Slot, {
|
|
44
38
|
AnchorPoint = popper.anchorPoint,
|
|
45
39
|
Position = popper.position,
|
|
46
40
|
Visible = props.visible,
|
|
47
41
|
ref = setContentRef,
|
|
48
|
-
}, child)
|
|
49
|
-
end
|
|
50
|
-
return React.createElement(DismissableLayer, {
|
|
51
|
-
enabled = props.enabled,
|
|
52
|
-
modal = popoverContext.modal,
|
|
53
|
-
onDismiss = props.onDismiss,
|
|
54
|
-
onEscapeKeyDown = props.onEscapeKeyDown,
|
|
55
|
-
onInteractOutside = props.onInteractOutside,
|
|
56
|
-
onPointerDownOutside = props.onPointerDownOutside,
|
|
57
|
-
}, React.createElement("frame", {
|
|
42
|
+
}, child)
|
|
43
|
+
end)()) else (React.createElement("frame", {
|
|
58
44
|
AnchorPoint = popper.anchorPoint,
|
|
59
45
|
BackgroundTransparency = 1,
|
|
60
46
|
BorderSizePixel = 0,
|
|
@@ -63,6 +49,17 @@ local function PopoverContentImpl(props)
|
|
|
63
49
|
Visible = props.visible,
|
|
64
50
|
ref = setContentRef,
|
|
65
51
|
}, props.children))
|
|
52
|
+
return React.createElement(DismissableLayer, {
|
|
53
|
+
enabled = props.enabled,
|
|
54
|
+
modal = popoverContext.modal,
|
|
55
|
+
onDismiss = props.onDismiss,
|
|
56
|
+
onInteractOutside = props.onInteractOutside,
|
|
57
|
+
onPointerDownOutside = props.onPointerDownOutside,
|
|
58
|
+
}, React.createElement(FocusScope, {
|
|
59
|
+
active = props.enabled,
|
|
60
|
+
restoreFocus = true,
|
|
61
|
+
trapped = popoverContext.modal,
|
|
62
|
+
}, contentNode))
|
|
66
63
|
end
|
|
67
64
|
local function PopoverContent(props)
|
|
68
65
|
local popoverContext = usePopoverContext()
|
|
@@ -80,7 +77,6 @@ local function PopoverContent(props)
|
|
|
80
77
|
enabled = open,
|
|
81
78
|
offset = props.offset,
|
|
82
79
|
onDismiss = handleDismiss,
|
|
83
|
-
onEscapeKeyDown = props.onEscapeKeyDown,
|
|
84
80
|
onInteractOutside = props.onInteractOutside,
|
|
85
81
|
onPointerDownOutside = props.onPointerDownOutside,
|
|
86
82
|
padding = props.padding,
|
|
@@ -97,7 +93,6 @@ local function PopoverContent(props)
|
|
|
97
93
|
enabled = state.isPresent,
|
|
98
94
|
offset = props.offset,
|
|
99
95
|
onDismiss = handleDismiss,
|
|
100
|
-
onEscapeKeyDown = props.onEscapeKeyDown,
|
|
101
96
|
onInteractOutside = props.onInteractOutside,
|
|
102
97
|
onPointerDownOutside = props.onPointerDownOutside,
|
|
103
98
|
padding = props.padding,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
3
|
local _core = TS.import(script, TS.getModule(script, "@lattice-ui", "core").out)
|
|
4
|
+
local focusGuiObject = _core.focusGuiObject
|
|
4
5
|
local React = _core.React
|
|
5
6
|
local Slot = _core.Slot
|
|
7
|
+
local useFocusNode = _core.useFocusNode
|
|
6
8
|
local usePopoverContext = TS.import(script, script.Parent, "context").usePopoverContext
|
|
7
9
|
local function toGuiObject(instance)
|
|
8
10
|
if not instance or not instance:IsA("GuiObject") then
|
|
@@ -12,24 +14,35 @@ local function toGuiObject(instance)
|
|
|
12
14
|
end
|
|
13
15
|
local function PopoverTrigger(props)
|
|
14
16
|
local popoverContext = usePopoverContext()
|
|
17
|
+
local triggerRef = popoverContext.triggerRef
|
|
15
18
|
local setTriggerRef = React.useCallback(function(instance)
|
|
16
|
-
|
|
17
|
-
end, {
|
|
19
|
+
triggerRef.current = toGuiObject(instance)
|
|
20
|
+
end, { triggerRef })
|
|
21
|
+
useFocusNode({
|
|
22
|
+
ref = triggerRef,
|
|
23
|
+
disabled = props.disabled == true,
|
|
24
|
+
syncToRoblox = false,
|
|
25
|
+
})
|
|
18
26
|
local handleActivated = React.useCallback(function()
|
|
19
27
|
if props.disabled then
|
|
20
28
|
return nil
|
|
21
29
|
end
|
|
30
|
+
if not popoverContext.open then
|
|
31
|
+
focusGuiObject(triggerRef.current)
|
|
32
|
+
end
|
|
22
33
|
popoverContext.setOpen(not popoverContext.open)
|
|
23
|
-
end, { popoverContext.open, popoverContext.setOpen, props.disabled })
|
|
34
|
+
end, { popoverContext.open, popoverContext.setOpen, props.disabled, triggerRef })
|
|
24
35
|
if props.asChild then
|
|
25
36
|
local child = props.children
|
|
26
37
|
if not child then
|
|
27
38
|
error("[PopoverTrigger] `asChild` requires a child element.")
|
|
28
39
|
end
|
|
29
40
|
return React.createElement(Slot, {
|
|
41
|
+
Active = props.disabled ~= true,
|
|
30
42
|
Event = {
|
|
31
43
|
Activated = handleActivated,
|
|
32
44
|
},
|
|
45
|
+
Selectable = false,
|
|
33
46
|
ref = setTriggerRef,
|
|
34
47
|
}, child)
|
|
35
48
|
end
|
|
@@ -41,7 +54,7 @@ local function PopoverTrigger(props)
|
|
|
41
54
|
Event = {
|
|
42
55
|
Activated = handleActivated,
|
|
43
56
|
},
|
|
44
|
-
Selectable =
|
|
57
|
+
Selectable = false,
|
|
45
58
|
Size = UDim2.fromOffset(150, 38),
|
|
46
59
|
Text = "Toggle Popover",
|
|
47
60
|
TextColor3 = Color3.fromRGB(240, 244, 250),
|
package/out/Popover/types.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ export type PopoverContentProps = {
|
|
|
33
33
|
placement?: PopperPlacement;
|
|
34
34
|
offset?: Vector2;
|
|
35
35
|
padding?: number;
|
|
36
|
-
onEscapeKeyDown?: (event: LayerInteractEvent) => void;
|
|
37
36
|
onPointerDownOutside?: (event: LayerInteractEvent) => void;
|
|
38
37
|
onInteractOutside?: (event: LayerInteractEvent) => void;
|
|
39
38
|
children?: React.ReactNode;
|
package/out/index.d.ts
CHANGED
|
@@ -12,5 +12,5 @@ export declare const Popover: {
|
|
|
12
12
|
readonly Anchor: typeof PopoverAnchor;
|
|
13
13
|
readonly Close: typeof PopoverClose;
|
|
14
14
|
};
|
|
15
|
-
export { PopoverAnchor, PopoverClose, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger };
|
|
16
15
|
export type { PopoverAnchorProps, PopoverCloseProps, PopoverContentProps, PopoverPortalProps, PopoverProps, PopoverTriggerProps, } from "./Popover/types";
|
|
16
|
+
export { PopoverAnchor, PopoverClose, PopoverContent, PopoverPortal, PopoverRoot, PopoverTrigger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lattice-ui/popover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "out/init.luau",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"README.md"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@lattice-ui/core": "0.
|
|
13
|
-
"@lattice-ui/
|
|
14
|
-
"@lattice-ui/layer": "0.
|
|
12
|
+
"@lattice-ui/core": "0.4.1",
|
|
13
|
+
"@lattice-ui/focus": "0.4.1",
|
|
14
|
+
"@lattice-ui/layer": "0.4.1",
|
|
15
|
+
"@lattice-ui/popper": "0.4.1"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@rbxts/react": "17.3.7-ts.1",
|