@indico-data/design-system 3.13.1 → 3.14.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.
@@ -1,2 +1,2 @@
1
1
  import { FloatUIProps } from './types';
2
- export declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal, portalOptions, floatingOptions, className, hover, }: FloatUIProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal, portalOptions, floatingOptions, className, hover, onOpenChange, }: FloatUIProps): import("react/jsx-runtime").JSX.Element;
@@ -20,4 +20,6 @@ export type FloatUIProps = {
20
20
  setIsOpen?: React.Dispatch<React.SetStateAction<boolean>>;
21
21
  /** If true, opens on hover instead of click. Defaults to false. */
22
22
  hover?: boolean;
23
+ /** Callback function to be called when the FloatUI is opened or closed. */
24
+ onOpenChange?: (isOpen: boolean) => void;
23
25
  };
package/lib/index.d.ts CHANGED
@@ -760,9 +760,11 @@ type FloatUIProps = {
760
760
  setIsOpen?: React.Dispatch<React.SetStateAction<boolean>>;
761
761
  /** If true, opens on hover instead of click. Defaults to false. */
762
762
  hover?: boolean;
763
+ /** Callback function to be called when the FloatUI is opened or closed. */
764
+ onOpenChange?: (isOpen: boolean) => void;
763
765
  };
764
766
 
765
- declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal, portalOptions, floatingOptions, className, hover, }: FloatUIProps): react_jsx_runtime.JSX.Element;
767
+ declare function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal, portalOptions, floatingOptions, className, hover, onOpenChange, }: FloatUIProps): react_jsx_runtime.JSX.Element;
766
768
 
767
769
  type MenuProps = {
768
770
  children: React$1.ReactNode;
package/lib/index.esm.js CHANGED
@@ -13826,7 +13826,7 @@ const defaultOptions$1 = {
13826
13826
  placement: 'bottom-start',
13827
13827
  middleware: [offset$2(5), flip$2(), shift$2()],
13828
13828
  };
13829
- function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal = false, portalOptions = {}, floatingOptions = defaultOptions$1, className, hover = false, }) {
13829
+ function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal = false, portalOptions = {}, floatingOptions = defaultOptions$1, className, hover = false, onOpenChange, }) {
13830
13830
  const [internalIsOpen, setInternalIsOpen] = useState(false);
13831
13831
  // Determine whether the component is controlled or uncontrolled
13832
13832
  const isControlled = controlledIsOpen !== undefined && controlledSetIsOpen !== undefined;
@@ -13842,13 +13842,18 @@ function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: con
13842
13842
  if (!isValidElement(trigger) || !isValidElement(content)) {
13843
13843
  throw new Error('Both children of FloatUI must be valid React elements.');
13844
13844
  }
13845
- const { refs, floatingStyles, context } = useFloating(Object.assign(Object.assign({}, floatingOptions), { open: isOpen, onOpenChange: setIsOpen, elements: {
13845
+ const { refs, floatingStyles, context } = useFloating(Object.assign(Object.assign({}, floatingOptions), { open: isOpen, onOpenChange: (isOpen) => {
13846
+ setIsOpen(isOpen);
13847
+ onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(isOpen);
13848
+ }, elements: {
13846
13849
  reference: referenceElementRef.current,
13847
13850
  } }));
13848
13851
  // Can't call hooks conditionally so this enabled option is needed.
13849
13852
  const click = useClick(context, { enabled: !hover });
13850
13853
  const hoverHook = useHover(context, { enabled: hover });
13851
- const dismiss = useDismiss(context);
13854
+ const dismiss = useDismiss(context, {
13855
+ bubbles: true,
13856
+ });
13852
13857
  const { getReferenceProps, getFloatingProps } = useInteractions([click, hoverHook, dismiss]);
13853
13858
  const tooltipContent = (jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { style: floatingStyles, role: "dialog", "aria-label": ariaLabel, className: `floatui-container ${className}`, children: jsx("div", { ref: floatUIContentRef, className: "floatui-content", children: content }) })));
13854
13859
  return (jsxs(Fragment, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: trigger })), isOpen &&