@abdellatifui/react 3.1.82 → 3.1.83

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/dist/nextgen.d.ts CHANGED
@@ -504,10 +504,16 @@ export declare interface MenuButtonProps extends ButtonProps {
504
504
  }>;
505
505
  }
506
506
 
507
- export declare const Model: default_2.ForwardRefExoticComponent<ModelProps_2 & default_2.RefAttributes<HTMLDivElement>>;
507
+ export declare const Model: default_2.ForwardRefExoticComponent<ModelProps_2 & default_2.RefAttributes<ModelHandle>>;
508
508
 
509
509
  export declare const ModelContext: Context< {}>;
510
510
 
511
+ declare interface ModelHandle {
512
+ open: () => void;
513
+ close: () => void;
514
+ readonly isOpen: boolean;
515
+ }
516
+
511
517
  export declare interface ModelProps extends ContainerProps {
512
518
  isOpen: boolean;
513
519
  onClose: () => void;
package/dist/nextgen.js CHANGED
@@ -16333,29 +16333,33 @@ const Model = forwardRef((props, ref) => {
16333
16333
  hideOnContextMenu,
16334
16334
  blur = false
16335
16335
  } = props;
16336
- function handleClose() {
16336
+ const handleClose = useCallback(() => {
16337
16337
  setOpen(false);
16338
- }
16339
- function hanldeOpen() {
16338
+ }, []);
16339
+ const hanldeOpen = useCallback(() => {
16340
16340
  setOpen(true);
16341
- }
16341
+ }, []);
16342
+ useImperativeHandle(ref, () => ({
16343
+ open: hanldeOpen,
16344
+ close: handleClose,
16345
+ get isOpen() {
16346
+ return open;
16347
+ }
16348
+ }), [handleClose, hanldeOpen, open]);
16342
16349
  useEffect(() => {
16343
- if (ref.current) {
16344
- ref.current.open = hanldeOpen;
16345
- ref.current.close = handleClose;
16346
- ref.open = hanldeOpen;
16347
- ref.close = handleClose;
16348
- ref.current.isOpen = open;
16349
- if (open == true && !inline) {
16350
- setTimeout(() => {
16351
- const element = $(`#${id}`);
16352
- const element2 = document.getElementById(id);
16353
- const boundires = element2.getBoundingClientRect();
16354
- element.css("top", -boundires.y + "px");
16355
- }, 10);
16356
- }
16350
+ if (!open || inline) {
16351
+ return;
16357
16352
  }
16358
- }, [open, ref, id]);
16353
+ const element = document.getElementById(id);
16354
+ if (!element) {
16355
+ return;
16356
+ }
16357
+ const frame = window.requestAnimationFrame(() => {
16358
+ const boundaries = element.getBoundingClientRect();
16359
+ element.style.top = `${-boundaries.y}px`;
16360
+ });
16361
+ return () => window.cancelAnimationFrame(frame);
16362
+ }, [id, inline, open]);
16359
16363
  function handleWrapperClose(e) {
16360
16364
  if (e.target.classList.contains("custom-click-away") && bodyClick) {
16361
16365
  setOpen(false);
@@ -26545,3 +26549,4 @@ export {
26545
26549
  useStore,
26546
26550
  useVariable
26547
26551
  };
26552
+ //# sourceMappingURL=nextgen.js.map