@trackunit/react-components 1.24.1 → 1.24.2

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/index.cjs.js CHANGED
@@ -2799,10 +2799,10 @@ const cvaPopoverTitleText = cssClassVarianceUtilities.cvaMerge(["flex-1", "text-
2799
2799
  * @param {PopoverContentProps} props - The props for the PopoverContent component
2800
2800
  * @returns {ReactElement} The popover content element
2801
2801
  */
2802
- const PopoverContent = function PopoverContent({ className, "data-testid": dataTestId, children, portalId, ref: propRef, ...props }) {
2802
+ const PopoverContent = function PopoverContent({ className, "data-testid": dataTestId, children, portalId, initialFocus, ref: propRef, ...props }) {
2803
2803
  const { context: floatingContext, customProps, ...context } = usePopoverContext();
2804
2804
  const ref = react$1.useMergeRefs([context.refs.setFloating, propRef]);
2805
- return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen === true ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsxRuntime.jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
2805
+ return (jsxRuntime.jsx(Portal, { id: portalId, children: context.isOpen === true ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, initialFocus: initialFocus, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsxRuntime.jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
2806
2806
  position: context.strategy,
2807
2807
  top: context.y,
2808
2808
  left: context.x,
package/index.esm.js CHANGED
@@ -2797,10 +2797,10 @@ const cvaPopoverTitleText = cvaMerge(["flex-1", "text-neutral-500"]);
2797
2797
  * @param {PopoverContentProps} props - The props for the PopoverContent component
2798
2798
  * @returns {ReactElement} The popover content element
2799
2799
  */
2800
- const PopoverContent = function PopoverContent({ className, "data-testid": dataTestId, children, portalId, ref: propRef, ...props }) {
2800
+ const PopoverContent = function PopoverContent({ className, "data-testid": dataTestId, children, portalId, initialFocus, ref: propRef, ...props }) {
2801
2801
  const { context: floatingContext, customProps, ...context } = usePopoverContext();
2802
2802
  const ref = useMergeRefs$1([context.refs.setFloating, propRef]);
2803
- return (jsx(Portal, { id: portalId, children: context.isOpen === true ? (jsx(FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
2803
+ return (jsx(Portal, { id: portalId, children: context.isOpen === true ? (jsx(FloatingFocusManager, { closeOnFocusOut: false, context: floatingContext, guards: true, initialFocus: initialFocus, modal: context.isModal, order: ["reference", "content"], returnFocus: true, children: jsx("div", { "aria-describedby": context.descriptionId, "aria-labelledby": context.labelId, className: cvaPopoverContainer({ className: className ?? customProps.className }), "data-testid": dataTestId ?? customProps["data-testid"] ?? "popover-content", ref: ref, style: {
2804
2804
  position: context.strategy,
2805
2805
  top: context.y,
2806
2806
  left: context.x,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "1.24.1",
3
+ "version": "1.24.2",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "migrations": "./migrations.json",
@@ -1,4 +1,4 @@
1
- import { HTMLProps, ReactElement, ReactNode, Ref } from "react";
1
+ import { HTMLProps, MutableRefObject, ReactElement, ReactNode, Ref } from "react";
2
2
  import { CommonProps } from "../../common/CommonProps";
3
3
  export type PopoverContentChildren = ((close: () => void) => ReactNode) | ReactNode;
4
4
  export interface PopoverContentProps extends Omit<HTMLProps<HTMLDivElement>, "children">, CommonProps {
@@ -31,6 +31,18 @@ export interface PopoverContentProps extends Omit<HTMLProps<HTMLDivElement>, "ch
31
31
  * Custom dom id to use for portalling the popover content
32
32
  */
33
33
  portalId?: string;
34
+ /**
35
+ * Controls which element receives focus when the popover opens.
36
+ *
37
+ * - **number** (default `0`): index into the FloatingFocusManager focus order. With the
38
+ * default `order` of `["reference", "content"]`, `0` keeps focus on the trigger reference
39
+ * and `1` moves focus to the first tabbable element inside the popover content.
40
+ * - **ref**: focuses the specific element pointed to by the ref when the popover opens.
41
+ *
42
+ * Use this when you want the popover to capture keyboard focus on open (for example,
43
+ * dialog-like menus or pickers) instead of leaving focus on the trigger.
44
+ */
45
+ initialFocus?: number | MutableRefObject<HTMLElement | null>;
34
46
  /**
35
47
  * A ref for the component
36
48
  */
@@ -71,4 +83,4 @@ export interface PopoverContentProps extends Omit<HTMLProps<HTMLDivElement>, "ch
71
83
  * @param {PopoverContentProps} props - The props for the PopoverContent component
72
84
  * @returns {ReactElement} The popover content element
73
85
  */
74
- export declare const PopoverContent: ({ className, "data-testid": dataTestId, children, portalId, ref: propRef, ...props }: PopoverContentProps) => ReactElement;
86
+ export declare const PopoverContent: ({ className, "data-testid": dataTestId, children, portalId, initialFocus, ref: propRef, ...props }: PopoverContentProps) => ReactElement;