@lattice-ui/dialog 0.3.2 → 0.4.0

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 DialogClose(props)
15
15
  error("[DialogClose] `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),
@@ -11,7 +11,6 @@ local function DialogContentImpl(props)
11
11
  enabled = props.enabled,
12
12
  modal = props.modal,
13
13
  onDismiss = props.onDismiss,
14
- onEscapeKeyDown = props.onEscapeKeyDown,
15
14
  onInteractOutside = props.onInteractOutside,
16
15
  onPointerDownOutside = props.onPointerDownOutside,
17
16
  }, React.createElement(FocusScope, {
@@ -45,7 +44,6 @@ local function DialogContent(props)
45
44
  enabled = open,
46
45
  modal = dialogContext.modal,
47
46
  onDismiss = handleDismiss,
48
- onEscapeKeyDown = props.onEscapeKeyDown,
49
47
  onInteractOutside = props.onInteractOutside,
50
48
  onPointerDownOutside = props.onPointerDownOutside,
51
49
  restoreFocus = restoreFocus,
@@ -60,7 +58,6 @@ local function DialogContent(props)
60
58
  enabled = state.isPresent,
61
59
  modal = dialogContext.modal,
62
60
  onDismiss = handleDismiss,
63
- onEscapeKeyDown = props.onEscapeKeyDown,
64
61
  onInteractOutside = props.onInteractOutside,
65
62
  onPointerDownOutside = props.onPointerDownOutside,
66
63
  restoreFocus = restoreFocus,
@@ -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 useDialogContext = TS.import(script, script.Parent, "context").useDialogContext
7
9
  local function toGuiObject(instance)
8
10
  if not instance or not instance:IsA("GuiObject") then
@@ -12,24 +14,33 @@ local function toGuiObject(instance)
12
14
  end
13
15
  local function DialogTrigger(props)
14
16
  local dialogContext = useDialogContext()
17
+ local triggerRef = dialogContext.triggerRef
15
18
  local setTriggerRef = React.useCallback(function(instance)
16
- dialogContext.triggerRef.current = toGuiObject(instance)
17
- end, { dialogContext.triggerRef })
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
+ focusGuiObject(triggerRef.current)
22
31
  dialogContext.setOpen(true)
23
- end, { dialogContext.setOpen, props.disabled })
32
+ end, { dialogContext.setOpen, props.disabled, triggerRef })
24
33
  if props.asChild then
25
34
  local child = props.children
26
35
  if not child then
27
36
  error("[DialogTrigger] `asChild` requires a child element.")
28
37
  end
29
38
  return React.createElement(Slot, {
39
+ Active = props.disabled ~= true,
30
40
  Event = {
31
41
  Activated = handleActivated,
32
42
  },
43
+ Selectable = false,
33
44
  ref = setTriggerRef,
34
45
  }, child)
35
46
  end
@@ -41,6 +52,7 @@ local function DialogTrigger(props)
41
52
  Event = {
42
53
  Activated = handleActivated,
43
54
  },
55
+ Selectable = false,
44
56
  Size = UDim2.fromOffset(140, 38),
45
57
  Text = "Open Dialog",
46
58
  TextColor3 = Color3.fromRGB(240, 244, 250),
@@ -33,7 +33,6 @@ export type DialogContentProps = {
33
33
  forceMount?: boolean;
34
34
  trapFocus?: boolean;
35
35
  restoreFocus?: boolean;
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 Dialog: {
12
12
  readonly Overlay: typeof DialogOverlay;
13
13
  readonly Close: typeof DialogClose;
14
14
  };
15
- export { DialogClose, DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTrigger };
16
15
  export type { DialogCloseProps, DialogContentProps, DialogOverlayProps, DialogPortalProps, DialogProps, DialogTriggerProps, } from "./Dialog/types";
16
+ export { DialogClose, DialogContent, DialogOverlay, DialogPortal, DialogRoot, DialogTrigger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lattice-ui/dialog",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "main": "out/init.luau",
6
6
  "types": "out/index.d.ts",
@@ -9,9 +9,9 @@
9
9
  "README.md"
10
10
  ],
11
11
  "dependencies": {
12
- "@lattice-ui/core": "0.3.2",
13
- "@lattice-ui/layer": "0.3.2",
14
- "@lattice-ui/focus": "0.3.2"
12
+ "@lattice-ui/core": "0.4.0",
13
+ "@lattice-ui/focus": "0.4.0",
14
+ "@lattice-ui/layer": "0.4.0"
15
15
  },
16
16
  "devDependencies": {
17
17
  "@rbxts/react": "17.3.7-ts.1",