@activecollab/components 2.0.527 → 2.0.529

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.
Files changed (63) hide show
  1. package/dist/cjs/components/Dialog/Dialog.js +32 -187
  2. package/dist/cjs/components/Dialog/Dialog.js.map +1 -1
  3. package/dist/cjs/components/Dialog/DialogFrame.js +209 -0
  4. package/dist/cjs/components/Dialog/DialogFrame.js.map +1 -0
  5. package/dist/cjs/components/GlobalPortal/GlobalPortal.js +10 -4
  6. package/dist/cjs/components/GlobalPortal/GlobalPortal.js.map +1 -1
  7. package/dist/cjs/components/Modal/Modal.js +17 -108
  8. package/dist/cjs/components/Modal/Modal.js.map +1 -1
  9. package/dist/cjs/components/Modal/ModalBase.js +125 -0
  10. package/dist/cjs/components/Modal/ModalBase.js.map +1 -0
  11. package/dist/cjs/components/ModalRoot/ModalRoot.js +5 -4
  12. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  13. package/dist/cjs/components/ModalRoot/modalRootStack.js +21 -13
  14. package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
  15. package/dist/cjs/components/ModalRoot/useModalStackHost.js +43 -5
  16. package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -1
  17. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js +41 -64
  18. package/dist/cjs/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  19. package/dist/esm/components/Dialog/Dialog.d.ts +3 -3
  20. package/dist/esm/components/Dialog/Dialog.d.ts.map +1 -1
  21. package/dist/esm/components/Dialog/Dialog.js +34 -175
  22. package/dist/esm/components/Dialog/Dialog.js.map +1 -1
  23. package/dist/esm/components/Dialog/DialogFrame.d.ts +14 -0
  24. package/dist/esm/components/Dialog/DialogFrame.d.ts.map +1 -0
  25. package/dist/esm/components/Dialog/DialogFrame.js +180 -0
  26. package/dist/esm/components/Dialog/DialogFrame.js.map +1 -0
  27. package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts +6 -4
  28. package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts.map +1 -1
  29. package/dist/esm/components/GlobalPortal/GlobalPortal.js +9 -4
  30. package/dist/esm/components/GlobalPortal/GlobalPortal.js.map +1 -1
  31. package/dist/esm/components/Modal/Modal.d.ts +8 -17
  32. package/dist/esm/components/Modal/Modal.d.ts.map +1 -1
  33. package/dist/esm/components/Modal/Modal.js +18 -99
  34. package/dist/esm/components/Modal/Modal.js.map +1 -1
  35. package/dist/esm/components/Modal/ModalBase.d.ts +19 -0
  36. package/dist/esm/components/Modal/ModalBase.d.ts.map +1 -0
  37. package/dist/esm/components/Modal/ModalBase.js +108 -0
  38. package/dist/esm/components/Modal/ModalBase.js.map +1 -0
  39. package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
  40. package/dist/esm/components/ModalRoot/ModalRoot.js +5 -4
  41. package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
  42. package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -4
  43. package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
  44. package/dist/esm/components/ModalRoot/modalRootStack.js +15 -11
  45. package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
  46. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +4 -2
  47. package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -1
  48. package/dist/esm/components/ModalRoot/useModalStackHost.js +36 -5
  49. package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -1
  50. package/dist/esm/components/ObjectFormModal/ObjectFormModal.d.ts.map +1 -1
  51. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js +42 -65
  52. package/dist/esm/components/ObjectFormModal/ObjectFormModal.js.map +1 -1
  53. package/dist/index.js +989 -902
  54. package/dist/index.js.map +1 -1
  55. package/dist/index.min.js +1 -1
  56. package/dist/index.min.js.map +1 -1
  57. package/package.json +1 -1
  58. package/dist/cjs/hooks/useDeprecation.js +0 -15
  59. package/dist/cjs/hooks/useDeprecation.js.map +0 -1
  60. package/dist/esm/hooks/useDeprecation.d.ts +0 -2
  61. package/dist/esm/hooks/useDeprecation.d.ts.map +0 -1
  62. package/dist/esm/hooks/useDeprecation.js +0 -9
  63. package/dist/esm/hooks/useDeprecation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","names":["React","forwardRef","useCallback","useEffect","useMemo","useRef","useState","classnames","DialogActions","DialogContent","DialogContentDivider","DialogContext","DialogTitle","dialogSizes","StyledDialog","StyledDialogViewport","useFluidHeightAnimation","useStableId","Modal","ModalRoot","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","NativeDialog","_ref2","forwardedRef","surface","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref3","isIn","_Dialog","_ref4","_dialogSizes$size","_ref4$open","_ref4$enableBackgroun","_ref4$disableCloseOnE","_ref4$animate","_ref4$size","size","_ref4$height","height","_ref4$native","native","_excluded2","_useState3","dialogNode","setDialogNode","$maxWidth","m","$height","overlayTimeout","enter","exit","Dialog","Object","assign","Title","Content","ContentDivider","Actions"],"sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n MouseEvent,\n PropsWithChildren,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { DialogActions } from \"./DialogActions\";\nimport { DialogContent } from \"./DialogContent\";\nimport { DialogContentDivider } from \"./DialogContentDivider\";\nimport { DialogContext } from \"./DialogContext\";\nimport { DialogTitle } from \"./DialogTitle\";\nimport {\n DialogSize,\n dialogSizes,\n StyledDialog,\n StyledDialogViewport,\n} from \"./Styles\";\nimport { useFluidHeightAnimation } from \"./useFluidHeightAnimation\";\nimport useStableId from \"../../utils/useStableId\";\nimport { Modal } from \"../Modal\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\nexport interface DialogProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n className?: string;\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n animate?: \"fade\" | \"slide\";\n onClickOutside?: (event) => void;\n /** Width step. Every step is a max-width; the dialog always fills it when there is room. */\n size?: DialogSize;\n /** \"fluid\" follows the content. A CSS length (\"95%\", \"600px\") pins the height instead. */\n height?: string;\n /** Opens as a native modal <dialog>: the page behind is inert and the dialog sits in the top layer. Temporary opt-in. */\n native?: boolean;\n}\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// Modal only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though Modal overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\ninterface NativeDialogProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef: Ref<HTMLDivElement>;\n surface: ReactElement;\n children?: ReactNode;\n}\n\nconst NativeDialog = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n ...rest\n}: NativeDialogProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef as unknown as Ref<HTMLDialogElement>}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nNativeDialog.displayName = \"NativeDialog\";\n\nexport const _Dialog = forwardRef<\n HTMLDivElement,\n PropsWithChildren<DialogProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n className,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n size = \"m\",\n height = \"fluid\",\n native = false,\n ...rest\n },\n ref\n ) => {\n const [dialogNode, setDialogNode] = useState<HTMLDivElement | null>(null);\n\n useFluidHeightAnimation(dialogNode, height === \"fluid\");\n\n const surface = (\n <StyledDialog\n ref={setDialogNode}\n $maxWidth={dialogSizes[size] ?? dialogSizes.m}\n $height={height === \"fluid\" ? undefined : height}\n className={classnames(\"c-dialog\", className)}\n >\n {children}\n </StyledDialog>\n );\n\n if (native) {\n return (\n <NativeDialog\n {...rest}\n forwardedRef={ref}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n\n return (\n <Modal\n ref={ref}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n {surface}\n </DialogSurface>\n </Modal>\n );\n }\n);\n\n_Dialog.displayName = \"Dialog\";\n\n// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757\nexport const Dialog = Object.assign({}, _Dialog, {\n Title: DialogTitle,\n Content: DialogContent,\n ContentDivider: DialogContentDivider,\n Actions: DialogActions,\n});\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAOVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAEEC,WAAW,EACXC,YAAY,EACZC,oBAAoB,QACf,UAAU;AACjB,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACpD,SACEC,YAAY,EACZC,oBAAoB,EACpBC,mBAAmB,QACd,6BAA6B;AA4BpC;AACA;AACA,MAAMC,aAA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EAAEA,qBAAsB;MAC7CE,iBAAiB,EAAEA,iBAAkB;MACrClB,OAAO,EAAEA,OAAQ;MACjBoB,cAAc,EAAEA,cAAe;MAC/BR,OAAO,EAAEA;IAAQ,EAClB,CAAC;EAEN;EAEA,oBACE9C,KAAA,CAAAuC,aAAA,CAACrB,KAAK,EAAAoE,QAAA;IACJC,GAAG,EAAEA,GAAI;IACTvC,IAAI,EAAEA,IAAK;IACXf,OAAO,EAAEA,OAAQ;IACjByD,sBAAsB,EAAE,CAACxC,qBAAsB;IAC/CE,iBAAiB,EAAEA,iBAAkB;IACrCE,cAAc,EAAEA,cAAe;IAC/B2D,cAAc,EACZ/E,OAAO,KAAK,MAAM,GACd;MAAEgF,KAAK,EAAE7F,aAAa;MAAE8F,IAAI,EAAE9F;IAAc,CAAC,GAC7C;MAAE6F,KAAK,EAAE3F,oBAAoB;MAAE4F,IAAI,EAAE3F;IAAoB;EAC9D,GACG+B,IAAI,gBAERvD,KAAA,CAAAuC,aAAA,CAACd,aAAa;IAACG,EAAE,EAAEoB,IAAK;IAACf,OAAO,EAAEA,OAAQ;IAACC,OAAO,EAAEA;EAAQ,GACzDY,OACY,CACV,CAAC;AAEZ,CACF,CAAC;AAED+C,OAAO,CAACnD,WAAW,GAAG,QAAQ;;AAE9B;AACA,OAAO,MAAM0E,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEzB,OAAO,EAAE;EAC/C0B,KAAK,EAAE3G,WAAW;EAClB4G,OAAO,EAAE/G,aAAa;EACtBgH,cAAc,EAAE/G,oBAAoB;EACpCgH,OAAO,EAAElH;AACX,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Dialog.js","names":["React","forwardRef","useState","classnames","DialogActions","DialogContent","DialogContentDivider","DialogFrame","DialogTitle","dialogSizes","StyledDialog","useFluidHeightAnimation","_Dialog","_ref","ref","_dialogSizes$size","children","_ref$open","open","onClose","className","_ref$enableBackground","enableBackgroundClick","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$animate","animate","onClickOutside","_ref$size","size","_ref$height","height","_ref$native","native","rest","_objectWithoutPropertiesLoose","_excluded","_useState","dialogNode","setDialogNode","surface","createElement","$maxWidth","m","$height","undefined","_extends","forwardedRef","displayName","Dialog","Object","assign","Title","Content","ContentDivider","Actions"],"sources":["../../../../src/components/Dialog/Dialog.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n PropsWithChildren,\n useState,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { DialogActions } from \"./DialogActions\";\nimport { DialogContent } from \"./DialogContent\";\nimport { DialogContentDivider } from \"./DialogContentDivider\";\nimport { DialogFrame } from \"./DialogFrame\";\nimport { DialogTitle } from \"./DialogTitle\";\nimport { DialogSize, dialogSizes, StyledDialog } from \"./Styles\";\nimport { useFluidHeightAnimation } from \"./useFluidHeightAnimation\";\n\nexport interface DialogProps extends HTMLAttributes<HTMLDivElement> {\n open?: boolean;\n onClose?: () => void;\n className?: string;\n enableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n animate?: \"fade\" | \"slide\";\n onClickOutside?: (event) => void;\n /** Width step. Every step is a max-width; the dialog always fills it when there is room. */\n size?: DialogSize;\n /** \"fluid\" follows the content. A CSS length (\"95%\", \"600px\") pins the height instead. */\n height?: string;\n /** Opens as a native modal <dialog>: the page behind is inert and the dialog sits in the top layer. Temporary opt-in. */\n native?: boolean;\n}\n\nexport const _Dialog = forwardRef<\n HTMLDivElement,\n PropsWithChildren<DialogProps>\n>(\n (\n {\n children,\n open = false,\n onClose,\n className,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n size = \"m\",\n height = \"fluid\",\n native = false,\n ...rest\n },\n ref\n ) => {\n const [dialogNode, setDialogNode] = useState<HTMLDivElement | null>(null);\n\n useFluidHeightAnimation(dialogNode, height === \"fluid\");\n\n const surface = (\n <StyledDialog\n ref={setDialogNode}\n $maxWidth={dialogSizes[size] ?? dialogSizes.m}\n $height={height === \"fluid\" ? undefined : height}\n className={classnames(\"c-dialog\", className)}\n >\n {children}\n </StyledDialog>\n );\n\n return (\n <DialogFrame\n {...rest}\n forwardedRef={ref}\n native={native}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n);\n\n_Dialog.displayName = \"Dialog\";\n\n// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34757\nexport const Dialog = Object.assign({}, _Dialog, {\n Title: DialogTitle,\n Content: DialogContent,\n ContentDivider: DialogContentDivider,\n Actions: DialogActions,\n});\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAGVC,QAAQ,QACH,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAAqBC,WAAW,EAAEC,YAAY,QAAQ,UAAU;AAChE,SAASC,uBAAuB,QAAQ,2BAA2B;AAkBnE,OAAO,MAAMC,OAAO,gBAAGX,UAAU,CAI/B,CAAAY,IAAA,EAeEC,GAAG,KACA;EAAA,IAAAC,iBAAA;EAAA,IAdDC,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,SAAA,GAAAJ,IAAA,CACRK,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,KAAK,GAAAA,SAAA;IACZE,OAAO,GAAAN,IAAA,CAAPM,OAAO;IACPC,SAAS,GAAAP,IAAA,CAATO,SAAS;IAAAC,qBAAA,GAAAR,IAAA,CACTS,qBAAqB;IAArBA,qBAAqB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAV,IAAA,CA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G,qBAAqB,EAAEA,qBAAsB;IAC7CE,iBAAiB,EAAEA,iBAAkB;IACrCE,OAAO,EAAEA,OAAQ;IACjBC,cAAc,EAAEA,cAAe;IAC/Ba,OAAO,EAAEA;EAAQ,EAClB,CAAC;AAEN,CACF,CAAC;AAED5B,OAAO,CAACoC,WAAW,GAAG,QAAQ;;AAE9B;AACA,OAAO,MAAMC,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEvC,OAAO,EAAE;EAC/CwC,KAAK,EAAE5C,WAAW;EAClB6C,OAAO,EAAEhD,aAAa;EACtBiD,cAAc,EAAEhD,oBAAoB;EACpCiD,OAAO,EAAEnD;AACX,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import React, { ReactElement, Ref } from "react";
2
+ import type { DialogProps } from "./Dialog";
3
+ export interface DialogFrameProps extends Omit<DialogProps, "children" | "size" | "height"> {
4
+ forwardedRef?: Ref<HTMLDivElement>;
5
+ /** The visible card. The frame places it in the viewport and runs its open and close animation. */
6
+ surface: ReactElement;
7
+ /** Only the modal path has a focus lock to turn off. */
8
+ disableFocusLock?: boolean;
9
+ }
10
+ export declare const DialogFrame: {
11
+ ({ forwardedRef, surface, native, open, onClose, enableBackgroundClick, disableCloseOnEsc, animate, onClickOutside, disableFocusLock, ...rest }: DialogFrameProps): React.JSX.Element;
12
+ displayName: string;
13
+ };
14
+ //# sourceMappingURL=DialogFrame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogFrame.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,YAAY,EAEZ,GAAG,EAMJ,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAsK5C,MAAM,WAAW,gBACf,SAAQ,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;IACzD,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,mGAAmG;IACnG,OAAO,EAAE,YAAY,CAAC;IACtB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAGD,eAAO,MAAM,WAAW;qJAYrB,gBAAgB;;CAsClB,CAAC"}
@@ -0,0 +1,180 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["forwardedRef", "surface", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside"],
4
+ _excluded2 = ["forwardedRef", "surface", "native", "open", "onClose", "enableBackgroundClick", "disableCloseOnEsc", "animate", "onClickOutside", "disableFocusLock"];
5
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ import { DialogContext } from "./DialogContext";
7
+ import { StyledDialogViewport } from "./Styles";
8
+ import useStableId from "../../utils/useStableId";
9
+ import { ModalBase } from "../Modal/ModalBase";
10
+ import { ModalRoot } from "../ModalRoot";
11
+ import { Fade, FADE_DURATION } from "../Transitions";
12
+ import { SlideFromTop, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions/SlideFromTop";
13
+ // ModalBase only treats a child as a transition when its props already carry `in`, so this element
14
+ // must declare it even though ModalBase overwrites it on clone.
15
+ const DialogSurface = _ref => {
16
+ let _ref$in = _ref.in,
17
+ inProp = _ref$in === void 0 ? false : _ref$in,
18
+ onEnter = _ref.onEnter,
19
+ onExited = _ref.onExited,
20
+ forceClose = _ref.forceClose,
21
+ onClose = _ref.onClose,
22
+ animate = _ref.animate,
23
+ children = _ref.children;
24
+ const Animation = animate === "fade" ? Fade : SlideFromTop;
25
+ const value = useMemo(() => ({
26
+ requestClose: forceClose,
27
+ onClose
28
+ }), [forceClose, onClose]);
29
+ return /*#__PURE__*/React.createElement(DialogContext.Provider, {
30
+ value: value
31
+ }, /*#__PURE__*/React.createElement(StyledDialogViewport, {
32
+ className: "c-dialog-viewport"
33
+ }, /*#__PURE__*/React.createElement(Animation, {
34
+ in: inProp,
35
+ onEnter: onEnter,
36
+ onExited: onExited
37
+ }, children)));
38
+ };
39
+ DialogSurface.displayName = "DialogSurface";
40
+ const NativeDialog = _ref2 => {
41
+ let forwardedRef = _ref2.forwardedRef,
42
+ surface = _ref2.surface,
43
+ _ref2$open = _ref2.open,
44
+ open = _ref2$open === void 0 ? false : _ref2$open,
45
+ onClose = _ref2.onClose,
46
+ _ref2$enableBackgroun = _ref2.enableBackgroundClick,
47
+ enableBackgroundClick = _ref2$enableBackgroun === void 0 ? false : _ref2$enableBackgroun,
48
+ _ref2$disableCloseOnE = _ref2.disableCloseOnEsc,
49
+ disableCloseOnEsc = _ref2$disableCloseOnE === void 0 ? false : _ref2$disableCloseOnE,
50
+ _ref2$animate = _ref2.animate,
51
+ animate = _ref2$animate === void 0 ? "slide" : _ref2$animate,
52
+ onClickOutside = _ref2.onClickOutside,
53
+ rest = _objectWithoutPropertiesLoose(_ref2, _excluded);
54
+ const _useState = useState(open),
55
+ innerOpen = _useState[0],
56
+ setInnerOpen = _useState[1];
57
+ const Animation = animate === "fade" ? Fade : SlideFromTop;
58
+ useEffect(() => {
59
+ setInnerOpen(open);
60
+ }, [open]);
61
+ const requestClose = useCallback(() => setInnerOpen(false), []);
62
+ const titleId = useStableId();
63
+ const _useState2 = useState(0),
64
+ titleCount = _useState2[0],
65
+ setTitleCount = _useState2[1];
66
+ const titleCountRef = useRef(0);
67
+ const warnedAboutName = useRef(false);
68
+ const registerTitle = useCallback(() => {
69
+ titleCountRef.current += 1;
70
+ setTitleCount(count => count + 1);
71
+ return () => {
72
+ titleCountRef.current -= 1;
73
+ setTitleCount(count => count - 1);
74
+ };
75
+ }, []);
76
+ const ariaLabel = rest["aria-label"];
77
+ const explicitLabelledBy = rest["aria-labelledby"];
78
+ const ariaLabelledBy = explicitLabelledBy != null ? explicitLabelledBy : ariaLabel || titleCount === 0 ? undefined : titleId;
79
+
80
+ // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.
81
+ useEffect(() => {
82
+ if (process.env.NODE_ENV === "production" || !innerOpen || warnedAboutName.current || ariaLabel || explicitLabelledBy) {
83
+ return undefined;
84
+ }
85
+ const timeout = setTimeout(() => {
86
+ if (titleCountRef.current === 0) {
87
+ warnedAboutName.current = true;
88
+ // eslint-disable-next-line no-console
89
+ console.warn("Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.");
90
+ }
91
+ });
92
+ return () => clearTimeout(timeout);
93
+ }, [innerOpen, ariaLabel, explicitLabelledBy]);
94
+ const handleDismissBlocked = useCallback((reason, event) => {
95
+ if (reason === "backdrop") {
96
+ onClickOutside == null || onClickOutside(event);
97
+ }
98
+ }, [onClickOutside]);
99
+ const contextValue = useMemo(() => ({
100
+ requestClose,
101
+ onClose,
102
+ titleId,
103
+ registerTitle
104
+ }), [requestClose, onClose, titleId, registerTitle]);
105
+ return /*#__PURE__*/React.createElement(ModalRoot, _extends({}, rest, {
106
+ ref: forwardedRef,
107
+ open: innerOpen,
108
+ onRequestClose: requestClose,
109
+ onDismissBlocked: handleDismissBlocked,
110
+ onClose: onClose,
111
+ disableCloseOnEsc: disableCloseOnEsc,
112
+ disableBackgroundClick: !enableBackgroundClick,
113
+ "aria-labelledby": ariaLabelledBy
114
+ }), _ref3 => {
115
+ let isIn = _ref3.in,
116
+ onExited = _ref3.onExited;
117
+ return /*#__PURE__*/React.createElement(DialogContext.Provider, {
118
+ value: contextValue
119
+ }, /*#__PURE__*/React.createElement(StyledDialogViewport, {
120
+ className: "c-dialog-viewport"
121
+ }, /*#__PURE__*/React.createElement(Animation, {
122
+ in: isIn,
123
+ onExited: onExited
124
+ }, surface)));
125
+ });
126
+ };
127
+ NativeDialog.displayName = "NativeDialog";
128
+ // What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.
129
+ export const DialogFrame = _ref4 => {
130
+ let forwardedRef = _ref4.forwardedRef,
131
+ surface = _ref4.surface,
132
+ _ref4$native = _ref4.native,
133
+ native = _ref4$native === void 0 ? false : _ref4$native,
134
+ _ref4$open = _ref4.open,
135
+ open = _ref4$open === void 0 ? false : _ref4$open,
136
+ onClose = _ref4.onClose,
137
+ _ref4$enableBackgroun = _ref4.enableBackgroundClick,
138
+ enableBackgroundClick = _ref4$enableBackgroun === void 0 ? false : _ref4$enableBackgroun,
139
+ _ref4$disableCloseOnE = _ref4.disableCloseOnEsc,
140
+ disableCloseOnEsc = _ref4$disableCloseOnE === void 0 ? false : _ref4$disableCloseOnE,
141
+ _ref4$animate = _ref4.animate,
142
+ animate = _ref4$animate === void 0 ? "slide" : _ref4$animate,
143
+ onClickOutside = _ref4.onClickOutside,
144
+ disableFocusLock = _ref4.disableFocusLock,
145
+ rest = _objectWithoutPropertiesLoose(_ref4, _excluded2);
146
+ if (native) {
147
+ return /*#__PURE__*/React.createElement(NativeDialog, _extends({}, rest, {
148
+ forwardedRef: forwardedRef,
149
+ open: open,
150
+ onClose: onClose,
151
+ enableBackgroundClick: enableBackgroundClick,
152
+ disableCloseOnEsc: disableCloseOnEsc,
153
+ animate: animate,
154
+ onClickOutside: onClickOutside,
155
+ surface: surface
156
+ }));
157
+ }
158
+ return /*#__PURE__*/React.createElement(ModalBase, _extends({
159
+ ref: forwardedRef,
160
+ open: open,
161
+ onClose: onClose,
162
+ disableBackgroundClick: !enableBackgroundClick,
163
+ disableCloseOnEsc: disableCloseOnEsc,
164
+ disableFocusLock: disableFocusLock,
165
+ onClickOutside: onClickOutside,
166
+ overlayTimeout: animate === "fade" ? {
167
+ enter: FADE_DURATION,
168
+ exit: FADE_DURATION
169
+ } : {
170
+ enter: SLIDE_FROM_TOP_ENTER,
171
+ exit: SLIDE_FROM_TOP_EXIT
172
+ }
173
+ }, rest), /*#__PURE__*/React.createElement(DialogSurface, {
174
+ in: open,
175
+ onClose: onClose,
176
+ animate: animate
177
+ }, surface));
178
+ };
179
+ DialogFrame.displayName = "DialogFrame";
180
+ //# sourceMappingURL=DialogFrame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogFrame.js","names":["React","useCallback","useEffect","useMemo","useRef","useState","DialogContext","StyledDialogViewport","useStableId","ModalBase","ModalRoot","Fade","FADE_DURATION","SlideFromTop","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","DialogSurface","_ref","_ref$in","in","inProp","onEnter","onExited","forceClose","onClose","animate","children","Animation","value","requestClose","createElement","Provider","className","displayName","NativeDialog","_ref2","forwardedRef","surface","_ref2$open","open","_ref2$enableBackgroun","enableBackgroundClick","_ref2$disableCloseOnE","disableCloseOnEsc","_ref2$animate","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","innerOpen","setInnerOpen","titleId","_useState2","titleCount","setTitleCount","titleCountRef","warnedAboutName","registerTitle","current","count","ariaLabel","explicitLabelledBy","ariaLabelledBy","undefined","process","env","NODE_ENV","timeout","setTimeout","console","warn","clearTimeout","handleDismissBlocked","reason","event","contextValue","_extends","ref","onRequestClose","onDismissBlocked","disableBackgroundClick","_ref3","isIn","DialogFrame","_ref4","_ref4$native","native","_ref4$open","_ref4$enableBackgroun","_ref4$disableCloseOnE","_ref4$animate","disableFocusLock","_excluded2","overlayTimeout","enter","exit"],"sources":["../../../../src/components/Dialog/DialogFrame.tsx"],"sourcesContent":["import React, {\n HTMLAttributes,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport type { DialogProps } from \"./Dialog\";\nimport { DialogContext } from \"./DialogContext\";\nimport { StyledDialogViewport } from \"./Styles\";\nimport useStableId from \"../../utils/useStableId\";\nimport { ModalBase } from \"../Modal/ModalBase\";\nimport { ModalRoot, ModalRootDismissReason } from \"../ModalRoot\";\nimport { Fade, FADE_DURATION } from \"../Transitions\";\nimport {\n SlideFromTop,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions/SlideFromTop\";\n\ninterface DialogSurfaceProps {\n in?: boolean;\n onEnter?: () => void;\n onExited?: () => void;\n forceClose?: () => void;\n onClose?: () => void;\n animate: \"fade\" | \"slide\";\n children: ReactElement;\n}\n\n// ModalBase only treats a child as a transition when its props already carry `in`, so this element\n// must declare it even though ModalBase overwrites it on clone.\nconst DialogSurface = ({\n in: inProp = false,\n onEnter,\n onExited,\n forceClose,\n onClose,\n animate,\n children,\n}: DialogSurfaceProps) => {\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n const value = useMemo(\n () => ({ requestClose: forceClose, onClose }),\n [forceClose, onClose]\n );\n\n return (\n <DialogContext.Provider value={value}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={inProp} onEnter={onEnter} onExited={onExited}>\n {children}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n );\n};\n\nDialogSurface.displayName = \"DialogSurface\";\n\ninterface NativeDialogProps\n extends Omit<DialogProps, \"native\" | \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n surface: ReactElement;\n children?: ReactNode;\n}\n\nconst NativeDialog = ({\n forwardedRef,\n surface,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n ...rest\n}: NativeDialogProps) => {\n const [innerOpen, setInnerOpen] = useState(open);\n const Animation = animate === \"fade\" ? Fade : SlideFromTop;\n\n useEffect(() => {\n setInnerOpen(open);\n }, [open]);\n\n const requestClose = useCallback(() => setInnerOpen(false), []);\n\n const titleId = useStableId();\n const [titleCount, setTitleCount] = useState(0);\n const titleCountRef = useRef(0);\n const warnedAboutName = useRef(false);\n\n const registerTitle = useCallback(() => {\n titleCountRef.current += 1;\n setTitleCount((count) => count + 1);\n\n return () => {\n titleCountRef.current -= 1;\n setTitleCount((count) => count - 1);\n };\n }, []);\n\n const ariaLabel = rest[\"aria-label\"];\n const explicitLabelledBy = rest[\"aria-labelledby\"];\n const ariaLabelledBy =\n explicitLabelledBy ?? (ariaLabel || titleCount === 0 ? undefined : titleId);\n\n // A dialog inside another one mounts its content a render later, so the check waits a tick for its title.\n useEffect(() => {\n if (\n process.env.NODE_ENV === \"production\" ||\n !innerOpen ||\n warnedAboutName.current ||\n ariaLabel ||\n explicitLabelledBy\n ) {\n return undefined;\n }\n\n const timeout = setTimeout(() => {\n if (titleCountRef.current === 0) {\n warnedAboutName.current = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Dialog: a native dialog needs an accessible name. Add a Dialog.Title, aria-label or aria-labelledby.\"\n );\n }\n });\n\n return () => clearTimeout(timeout);\n }, [innerOpen, ariaLabel, explicitLabelledBy]);\n\n const handleDismissBlocked = useCallback(\n (reason: ModalRootDismissReason, event?: MouseEvent<HTMLDialogElement>) => {\n if (reason === \"backdrop\") {\n onClickOutside?.(event);\n }\n },\n [onClickOutside]\n );\n\n const contextValue = useMemo(\n () => ({ requestClose, onClose, titleId, registerTitle }),\n [requestClose, onClose, titleId, registerTitle]\n );\n\n return (\n <ModalRoot\n {...(rest as HTMLAttributes<HTMLDialogElement>)}\n ref={forwardedRef as unknown as Ref<HTMLDialogElement>}\n open={innerOpen}\n onRequestClose={requestClose}\n onDismissBlocked={handleDismissBlocked}\n onClose={onClose}\n disableCloseOnEsc={disableCloseOnEsc}\n disableBackgroundClick={!enableBackgroundClick}\n aria-labelledby={ariaLabelledBy}\n >\n {({ in: isIn, onExited }) => (\n <DialogContext.Provider value={contextValue}>\n <StyledDialogViewport className=\"c-dialog-viewport\">\n <Animation in={isIn} onExited={onExited}>\n {surface}\n </Animation>\n </StyledDialogViewport>\n </DialogContext.Provider>\n )}\n </ModalRoot>\n );\n};\n\nNativeDialog.displayName = \"NativeDialog\";\n\nexport interface DialogFrameProps\n extends Omit<DialogProps, \"children\" | \"size\" | \"height\"> {\n forwardedRef?: Ref<HTMLDivElement>;\n /** The visible card. The frame places it in the viewport and runs its open and close animation. */\n surface: ReactElement;\n /** Only the modal path has a focus lock to turn off. */\n disableFocusLock?: boolean;\n}\n\n// What Dialog and ObjectFormModal share: the modal, the viewport and the animation around a surface each draws.\nexport const DialogFrame = ({\n forwardedRef,\n surface,\n native = false,\n open = false,\n onClose,\n enableBackgroundClick = false,\n disableCloseOnEsc = false,\n animate = \"slide\",\n onClickOutside,\n disableFocusLock,\n ...rest\n}: DialogFrameProps) => {\n if (native) {\n return (\n <NativeDialog\n {...rest}\n forwardedRef={forwardedRef}\n open={open}\n onClose={onClose}\n enableBackgroundClick={enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n animate={animate}\n onClickOutside={onClickOutside}\n surface={surface}\n />\n );\n }\n\n return (\n <ModalBase\n ref={forwardedRef}\n open={open}\n onClose={onClose}\n disableBackgroundClick={!enableBackgroundClick}\n disableCloseOnEsc={disableCloseOnEsc}\n disableFocusLock={disableFocusLock}\n onClickOutside={onClickOutside}\n overlayTimeout={\n animate === \"fade\"\n ? { enter: FADE_DURATION, exit: FADE_DURATION }\n : { enter: SLIDE_FROM_TOP_ENTER, exit: SLIDE_FROM_TOP_EXIT }\n }\n {...rest}\n >\n <DialogSurface in={open} onClose={onClose} animate={animate}>\n {surface}\n </DialogSurface>\n </ModalBase>\n );\n};\n\nDialogFrame.displayName = \"DialogFrame\";\n"],"mappings":";;;;AAAA,OAAOA,KAAK,IAMVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AAGd,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,oBAAoB,QAAQ,UAAU;AAC/C,OAAOC,WAAW,MAAM,yBAAyB;AACjD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAgC,cAAc;AAChE,SAASC,IAAI,EAAEC,aAAa,QAAQ,gBAAgB;AACpD,SACEC,YAAY,EACZC,oBAAoB,EACpBC,mBAAmB,QACd,6BA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K;IAACf,OAAO,EAAEA,OAAQ;IAACC,OAAO,EAAEA;EAAQ,GACzDY,OACY,CACN,CAAC;AAEhB,CAAC;AAED+C,WAAW,CAACnD,WAAW,GAAG,aAAa","ignoreList":[]}
@@ -1,13 +1,15 @@
1
- import { PropsWithChildren } from "react";
1
+ import React, { PropsWithChildren } from "react";
2
2
  /**
3
- * Renders content that must stay above every modal, such as toasts. Everything outside an open native modal is inert,
4
- * so the content follows the top open modal into its overlay root and comes back to document.body once none is open.
3
+ * Renders content that must stay above every modal, such as toasts, a chat or a feedback prompt. Everything outside
4
+ * an open native modal is inert, so the content follows the top open modal into its overlay root and comes back to
5
+ * document.body once none is open.
5
6
  * The host node moves instead of the content being portalled again, so the content never remounts on the way.
7
+ * Portals from the content, such as a menu or a tooltip, render into the host too, so they move along with it.
6
8
  * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads
7
9
  * no size there, and a transition that runs while the host moves restarts.
8
10
  */
9
11
  export declare const GlobalPortal: {
10
- ({ children }: PropsWithChildren): import("react").ReactPortal;
12
+ ({ children }: PropsWithChildren): React.ReactPortal;
11
13
  displayName: string;
12
14
  };
13
15
  //# sourceMappingURL=GlobalPortal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalPortal.d.ts","sourceRoot":"","sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAYpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;mBAAkB,iBAAiB;;CAM3D,CAAC"}
1
+ {"version":3,"file":"GlobalPortal.d.ts","sourceRoot":"","sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAa3D;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;mBAAkB,iBAAiB;;CAS3D,CAAC"}
@@ -1,5 +1,6 @@
1
- import { useState } from "react";
1
+ import React, { useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
+ import { PortalContainerProvider } from "../../helpers";
3
4
  import { useModalStackHost } from "../ModalRoot/useModalStackHost";
4
5
  const createHost = () => {
5
6
  const host = document.createElement("div");
@@ -8,9 +9,11 @@ const createHost = () => {
8
9
  };
9
10
 
10
11
  /**
11
- * Renders content that must stay above every modal, such as toasts. Everything outside an open native modal is inert,
12
- * so the content follows the top open modal into its overlay root and comes back to document.body once none is open.
12
+ * Renders content that must stay above every modal, such as toasts, a chat or a feedback prompt. Everything outside
13
+ * an open native modal is inert, so the content follows the top open modal into its overlay root and comes back to
14
+ * document.body once none is open.
13
15
  * The host node moves instead of the content being portalled again, so the content never remounts on the way.
16
+ * Portals from the content, such as a menu or a tooltip, render into the host too, so they move along with it.
14
17
  * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads
15
18
  * no size there, and a transition that runs while the host moves restarts.
16
19
  */
@@ -19,7 +22,9 @@ export const GlobalPortal = _ref => {
19
22
  const _useState = useState(createHost),
20
23
  host = _useState[0];
21
24
  useModalStackHost(host);
22
- return /*#__PURE__*/ReactDOM.createPortal(children, host);
25
+ return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement(PortalContainerProvider, {
26
+ value: host
27
+ }, children), host);
23
28
  };
24
29
  GlobalPortal.displayName = "GlobalPortal";
25
30
  //# sourceMappingURL=GlobalPortal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalPortal.js","names":["useState","ReactDOM","useModalStackHost","createHost","host","document","createElement","className","GlobalPortal","_ref","children","_useState","createPortal","displayName"],"sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"sourcesContent":["import { PropsWithChildren, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport { useModalStackHost } from \"../ModalRoot/useModalStackHost\";\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-global-portal\";\n\n return host;\n};\n\n/**\n * Renders content that must stay above every modal, such as toasts. Everything outside an open native modal is inert,\n * so the content follows the top open modal into its overlay root and comes back to document.body once none is open.\n * The host node moves instead of the content being portalled again, so the content never remounts on the way.\n * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads\n * no size there, and a transition that runs while the host moves restarts.\n */\nexport const GlobalPortal = ({ children }: PropsWithChildren) => {\n const [host] = useState(createHost);\n\n useModalStackHost(host);\n\n return ReactDOM.createPortal(children, host);\n};\n\nGlobalPortal.displayName = \"GlobalPortal\";\n"],"mappings":"AAAA,SAA4BA,QAAQ,QAAQ,OAAO;AACnD,OAAOC,QAAQ,MAAM,WAAW;AAEhC,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAG,iBAAiB;EAElC,OAAOH,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,GAAGC,IAAA,IAAqC;EAAA,IAAlCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACrC,MAAAC,SAAA,GAAeX,QAAQ,CAACG,UAAU,CAAC;IAA5BC,IAAI,GAAAO,SAAA;EAEXT,iBAAiB,CAACE,IAAI,CAAC;EAEvB,oBAAOH,QAAQ,CAACW,YAAY,CAACF,QAAQ,EAAEN,IAAI,CAAC;AAC9C,CAAC;AAEDI,YAAY,CAACK,WAAW,GAAG,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"GlobalPortal.js","names":["React","useState","ReactDOM","PortalContainerProvider","useModalStackHost","createHost","host","document","createElement","className","GlobalPortal","_ref","children","_useState","createPortal","value","displayName"],"sources":["../../../../src/components/GlobalPortal/GlobalPortal.tsx"],"sourcesContent":["import React, { PropsWithChildren, useState } from \"react\";\nimport ReactDOM from \"react-dom\";\n\nimport { PortalContainerProvider } from \"../../helpers\";\nimport { useModalStackHost } from \"../ModalRoot/useModalStackHost\";\n\nconst createHost = () => {\n const host = document.createElement(\"div\");\n host.className = \"c-global-portal\";\n\n return host;\n};\n\n/**\n * Renders content that must stay above every modal, such as toasts, a chat or a feedback prompt. Everything outside\n * an open native modal is inert, so the content follows the top open modal into its overlay root and comes back to\n * document.body once none is open.\n * The host node moves instead of the content being portalled again, so the content never remounts on the way.\n * Portals from the content, such as a menu or a tooltip, render into the host too, so they move along with it.\n * The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads\n * no size there, and a transition that runs while the host moves restarts.\n */\nexport const GlobalPortal = ({ children }: PropsWithChildren) => {\n const [host] = useState(createHost);\n\n useModalStackHost(host);\n\n return ReactDOM.createPortal(\n <PortalContainerProvider value={host}>{children}</PortalContainerProvider>,\n host\n );\n};\n\nGlobalPortal.displayName = \"GlobalPortal\";\n"],"mappings":"AAAA,OAAOA,KAAK,IAAuBC,QAAQ,QAAQ,OAAO;AAC1D,OAAOC,QAAQ,MAAM,WAAW;AAEhC,SAASC,uBAAuB,QAAQ,eAAe;AACvD,SAASC,iBAAiB,QAAQ,gCAAgC;AAElE,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC;EAC1CF,IAAI,CAACG,SAAS,GAAG,iBAAiB;EAElC,OAAOH,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,YAAY,GAAGC,IAAA,IAAqC;EAAA,IAAlCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EACrC,MAAAC,SAAA,GAAeZ,QAAQ,CAACI,UAAU,CAAC;IAA5BC,IAAI,GAAAO,SAAA;EAEXT,iBAAiB,CAACE,IAAI,CAAC;EAEvB,oBAAOJ,QAAQ,CAACY,YAAY,cAC1Bd,KAAA,CAAAQ,aAAA,CAACL,uBAAuB;IAACY,KAAK,EAAET;EAAK,GAAEM,QAAkC,CAAC,EAC1EN,IACF,CAAC;AACH,CAAC;AAEDI,YAAY,CAACM,WAAW,GAAG,cAAc","ignoreList":[]}
@@ -1,19 +1,10 @@
1
- import React, { ReactElement } from "react";
2
- export interface IModal {
3
- disableFocusLock?: boolean;
4
- disableScrollLock?: boolean;
5
- open?: boolean;
6
- disableBackgroundClick?: boolean;
7
- disableCloseOnEsc?: boolean;
8
- disableBackgroundColor?: boolean;
9
- onClose?: () => void;
10
- children: ReactElement;
11
- onClickOutside?: (event: any) => void;
12
- /** How long the overlay takes to arrive and to leave. Match it to the animation the child runs. */
13
- overlayTimeout?: {
14
- enter: number;
15
- exit: number;
16
- };
17
- }
1
+ import React from "react";
2
+ import { IModal } from "./ModalBase";
3
+ export type { IModal } from "./ModalBase";
4
+ /**
5
+ * @deprecated A modal that takes any child says nothing about what it shows. Use Dialog for a dialog, Sheet for
6
+ * a side or full panel, and Menu or Popper for an overlay that should not be modal. Modal is removed once nothing
7
+ * renders it.
8
+ */
18
9
  export declare const Modal: React.ForwardRefExoticComponent<IModal & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
19
10
  //# sourceMappingURL=Modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,YAAY,EAIb,MAAM,OAAO,CAAC;AAYf,MAAM,WAAW,MAAM;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,CAAC;IACjC,mGAAmG;IACnG,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AAQD,eAAO,MAAM,KAAK,sHAgHjB,CAAC"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAErE,OAAO,EAAE,MAAM,EAAa,MAAM,aAAa,CAAC;AAEhD,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C;;;;GAIG;AACH,eAAO,MAAM,KAAK,sHAiBhB,CAAC"}
@@ -1,106 +1,25 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "disableFocusLock", "disableScrollLock", "disableBackgroundClick", "disableBackgroundColor", "disableCloseOnEsc", "open", "overlayTimeout", "onClose", "onClickOutside"];
4
- import React, { forwardRef, useRef, cloneElement, useMemo, useCallback, useState, useEffect } from "react";
5
- import createChainedFunction from "../../utils/createChainedFunction";
6
- import useForkRef from "../../utils/useForkRef";
7
- import { Overlay } from "../Overlay";
8
- import { Fade, SLIDE_FROM_TOP_ENTER, SLIDE_FROM_TOP_EXIT } from "../Transitions";
9
- import { Window } from "../Window";
10
- const getHasTransition = children => {
11
- return children.props ? Object.prototype.hasOwnProperty.call(children.props, "in") : false;
12
- };
13
- export const Modal = /*#__PURE__*/forwardRef((_ref, ref) => {
14
- let children = _ref.children,
15
- _ref$disableFocusLock = _ref.disableFocusLock,
16
- disableFocusLock = _ref$disableFocusLock === void 0 ? false : _ref$disableFocusLock,
17
- _ref$disableScrollLoc = _ref.disableScrollLock,
18
- disableScrollLock = _ref$disableScrollLoc === void 0 ? false : _ref$disableScrollLoc,
19
- _ref$disableBackgroun = _ref.disableBackgroundClick,
20
- disableBackgroundClick = _ref$disableBackgroun === void 0 ? false : _ref$disableBackgroun,
21
- _ref$disableBackgroun2 = _ref.disableBackgroundColor,
22
- disableBackgroundColor = _ref$disableBackgroun2 === void 0 ? false : _ref$disableBackgroun2,
23
- _ref$disableCloseOnEs = _ref.disableCloseOnEsc,
24
- disableCloseOnEsc = _ref$disableCloseOnEs === void 0 ? false : _ref$disableCloseOnEs,
25
- _ref$open = _ref.open,
26
- defaultOpen = _ref$open === void 0 ? false : _ref$open,
27
- _ref$overlayTimeout = _ref.overlayTimeout,
28
- overlayTimeout = _ref$overlayTimeout === void 0 ? {
29
- enter: SLIDE_FROM_TOP_ENTER,
30
- exit: SLIDE_FROM_TOP_EXIT
31
- } : _ref$overlayTimeout,
32
- onClose = _ref.onClose,
33
- onClickOutside = _ref.onClickOutside,
34
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
35
- const _useState = useState(defaultOpen),
36
- open = _useState[0],
37
- setOpen = _useState[1];
38
- const _useState2 = useState(true),
39
- exited = _useState2[0],
40
- setExited = _useState2[1];
41
- const innerRef = useRef(null);
42
- const handleRef = useForkRef(innerRef, ref);
43
- const hasTransition = useMemo(() => {
44
- return getHasTransition(children);
45
- }, [children]);
2
+ import React, { forwardRef, useEffect } from "react";
3
+ import { ModalBase } from "./ModalBase";
4
+ let warnedAboutDeprecation = false;
5
+
6
+ /**
7
+ * @deprecated A modal that takes any child says nothing about what it shows. Use Dialog for a dialog, Sheet for
8
+ * a side or full panel, and Menu or Popper for an overlay that should not be modal. Modal is removed once nothing
9
+ * renders it.
10
+ */
11
+ export const Modal = /*#__PURE__*/forwardRef((props, ref) => {
46
12
  useEffect(() => {
47
- setOpen(defaultOpen);
48
- }, [defaultOpen]);
49
- const handleClose = useCallback(() => {
50
- setOpen(false);
51
- if (!hasTransition) {
52
- typeof onClose === "function" && onClose();
53
- }
54
- }, [hasTransition, onClose]);
55
- const handleBackgroundClick = useCallback(event => {
56
- if (!disableBackgroundClick) {
57
- event.preventDefault();
58
- return handleClose();
59
- }
60
- if (onClickOutside) {
61
- onClickOutside(event);
13
+ if (process.env.NODE_ENV === "production" || warnedAboutDeprecation) {
14
+ return;
62
15
  }
63
- }, [disableBackgroundClick, onClickOutside, handleClose]);
64
- const handleEnter = useCallback(() => {
65
- setExited(false);
16
+ warnedAboutDeprecation = true;
17
+ // eslint-disable-next-line no-console
18
+ console.warn("Modal is deprecated and will be removed. Use Dialog for a dialog, Sheet for a side or full panel, and Menu or Popper for an overlay that should not be modal.");
66
19
  }, []);
67
- const handleExited = useCallback(() => {
68
- setExited(true);
69
- typeof onClose === "function" && onClose();
70
- }, [onClose]);
71
- const childProps = useMemo(() => {
72
- let props = {};
73
-
74
- // It's a Transition like component
75
- if (hasTransition && children) {
76
- props = {
77
- onEnter: createChainedFunction(handleEnter, children.props.onEnter),
78
- onExited: createChainedFunction(handleExited, children.props.onExited),
79
- in: open,
80
- forceClose: handleClose
81
- };
82
- }
83
- return props;
84
- }, [children, handleClose, handleEnter, handleExited, hasTransition, open]);
85
- if (!open && (!hasTransition || exited)) {
86
- return null;
87
- }
88
- return /*#__PURE__*/React.createElement(Window, _extends({}, rest, {
89
- ref: handleRef,
90
- onClose: handleClose,
91
- disableFocusLock: disableFocusLock,
92
- disableScrollLock: disableScrollLock,
93
- disableCloseOnEsc: disableCloseOnEsc
94
- }), /*#__PURE__*/React.createElement(Fade, {
95
- in: open,
96
- timeout: open ? overlayTimeout.enter : overlayTimeout.exit
97
- }, /*#__PURE__*/React.createElement(Overlay, {
98
- onClick: handleBackgroundClick,
99
- disableBackgroundColor: disableBackgroundColor,
100
- style: {
101
- pointerEvents: open ? undefined : "none"
102
- }
103
- })), /*#__PURE__*/cloneElement(children, childProps));
20
+ return /*#__PURE__*/React.createElement(ModalBase, _extends({}, props, {
21
+ ref: ref
22
+ }));
104
23
  });
105
24
  Modal.displayName = "Modal";
106
25
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":["React","forwardRef","useRef","cloneElement","useMemo","useCallback","useState","useEffect","createChainedFunction","useForkRef","Overlay","Fade","SLIDE_FROM_TOP_ENTER","SLIDE_FROM_TOP_EXIT","Window","getHasTransition","children","props","Object","prototype","hasOwnProperty","call","Modal","_ref","ref","_ref$disableFocusLock","disableFocusLock","_ref$disableScrollLoc","disableScrollLock","_ref$disableBackgroun","disableBackgroundClick","_ref$disableBackgroun2","disableBackgroundColor","_ref$disableCloseOnEs","disableCloseOnEsc","_ref$open","open","defaultOpen","_ref$overlayTimeout","overlayTimeout","enter","exit","onClose","onClickOutside","rest","_objectWithoutPropertiesLoose","_excluded","_useState","setOpen","_useState2","exited","setExited","innerRef","handleRef","hasTransition","handleClose","handleBackgroundClick","event","preventDefault","handleEnter","handleExited","childProps","onEnter","onExited","in","forceClose","createElement","_extends","timeout","onClick","style","pointerEvents","undefined","displayName"],"sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n useRef,\n cloneElement,\n useMemo,\n useCallback,\n ReactElement,\n useState,\n useEffect,\n MouseEvent,\n} from \"react\";\n\nimport createChainedFunction from \"../../utils/createChainedFunction\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport {\n Fade,\n SLIDE_FROM_TOP_ENTER,\n SLIDE_FROM_TOP_EXIT,\n} from \"../Transitions\";\nimport { Window } from \"../Window\";\n\nexport interface IModal {\n disableFocusLock?: boolean;\n disableScrollLock?: boolean;\n open?: boolean;\n disableBackgroundClick?: boolean;\n disableCloseOnEsc?: boolean;\n disableBackgroundColor?: boolean;\n onClose?: () => void;\n children: ReactElement;\n onClickOutside?: (event) => void;\n /** How long the overlay takes to arrive and to leave. Match it to the animation the child runs. */\n overlayTimeout?: { enter: number; exit: number };\n}\n\nconst getHasTransition = (children): boolean => {\n return children.props\n ? Object.prototype.hasOwnProperty.call(children.props, \"in\")\n : false;\n};\n\nexport const Modal = forwardRef<\n HTMLDivElement,\n IModal & HTMLAttributes<HTMLDivElement>\n>(\n (\n {\n children,\n disableFocusLock = false,\n disableScrollLock = false,\n disableBackgroundClick = false,\n disableBackgroundColor = false,\n disableCloseOnEsc = false,\n open: defaultOpen = false,\n overlayTimeout = {\n enter: SLIDE_FROM_TOP_ENTER,\n exit: SLIDE_FROM_TOP_EXIT,\n },\n onClose,\n onClickOutside,\n ...rest\n },\n ref\n ) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(true);\n const innerRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(innerRef, ref);\n\n const hasTransition = useMemo(() => {\n return getHasTransition(children);\n }, [children]);\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n const handleClose = useCallback(() => {\n setOpen(false);\n if (!hasTransition) {\n typeof onClose === \"function\" && onClose();\n }\n }, [hasTransition, onClose]);\n\n const handleBackgroundClick = useCallback(\n (event: MouseEvent<HTMLDivElement>) => {\n if (!disableBackgroundClick) {\n event.preventDefault();\n return handleClose();\n }\n\n if (onClickOutside) {\n onClickOutside(event);\n }\n },\n [disableBackgroundClick, onClickOutside, handleClose]\n );\n\n const handleEnter = useCallback(() => {\n setExited(false);\n }, []);\n\n const handleExited = useCallback(() => {\n setExited(true);\n typeof onClose === \"function\" && onClose();\n }, [onClose]);\n\n const childProps = useMemo(() => {\n let props = {};\n\n // It's a Transition like component\n if (hasTransition && children) {\n props = {\n onEnter: createChainedFunction(handleEnter, children.props.onEnter),\n onExited: createChainedFunction(\n handleExited,\n children.props.onExited\n ),\n in: open,\n forceClose: handleClose,\n };\n }\n\n return props;\n }, [children, handleClose, handleEnter, handleExited, hasTransition, open]);\n\n if (!open && (!hasTransition || exited)) {\n return null;\n }\n\n return (\n <Window\n {...rest}\n ref={handleRef}\n onClose={handleClose}\n disableFocusLock={disableFocusLock}\n disableScrollLock={disableScrollLock}\n disableCloseOnEsc={disableCloseOnEsc}\n >\n <Fade\n in={open}\n timeout={open ? overlayTimeout.enter : overlayTimeout.exit}\n >\n <Overlay\n onClick={handleBackgroundClick}\n disableBackgroundColor={disableBackgroundColor}\n style={{ pointerEvents: open ? undefined : \"none\" }}\n />\n </Fade>\n {cloneElement(children, childProps)}\n </Window>\n );\n }\n);\n\nModal.displayName = \"Modal\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,UAAU,EAEVC,MAAM,EACNC,YAAY,EACZC,OAAO,EACPC,WAAW,EAEXC,QAAQ,EACRC,SAAS,QAEJ,OAAO;AAEd,OAAOC,qBAAqB,MAAM,mCAAmC;AACrE,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SACEC,IAAI,EACJC,oBAAoB,EACpBC,mBAAmB,QACd,gBAAgB;AACvB,SAASC,MAAM,QAAQ,WAAW;AAgBlC,MAAMC,gBAAgB,GAAIC,QAAQ,IAAc;EAC9C,OAAOA,QAAQ,CAACC,KAAK,GACjBC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACL,QAAQ,CAACC,KAAK,EAAE,IAAI,CAAC,GAC1D,KAAK;AACX,CAAC;AAED,OAAO,MAAMK,KAAK,gBAAGrB,UAAU,CAI7B,CAAAsB,IAAA,EAiBEC,GAAG,KACA;EAAA,IAhBDR,QAAQ,GAAAO,IAAA,CAARP,QAAQ;IAAAS,qBAAA,GAAAF,IAAA,CACRG,gBAAgB;IAAhBA,gBAAgB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAJ,IAAA,CACxBK,iBAAiB;IAAjBA,iBAAiB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,qBAAA,GAAAN,IAAA,CACzBO,sBAAsB;IAAtBA,sBAAsB,GAAAD,qBAAA,cAAG,KAAK,GAAAA,qBAAA;IAAAE,sBAAA,GAAAR,IAAA,CAC9BS,sBAAsB;IAAtB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C;EAE3E,IAAI,CAACA,IAAI,KAAK,CAACkB,aAAa,IAAIJ,MAAM,CAAC,EAAE;IACvC,OAAO,IAAI;EACb;EAEA,oBACElD,KAAA,CAAAkE,aAAA,CAACpD,MAAM,EAAAqD,QAAA,KACDvB,IAAI;IACRpB,GAAG,EAAE6B,SAAU;IACfX,OAAO,EAAEa,WAAY;IACrB7B,gBAAgB,EAAEA,gBAAiB;IACnCE,iBAAiB,EAAEA,iBAAkB;IACrCM,iBAAiB,EAAEA;EAAkB,iBAErClC,KAAA,CAAAkE,aAAA,CAACvD,IAAI;IACHqD,EAAE,EAAE5B,IAAK;IACTgC,OAAO,EAAEhC,IAAI,GAAGG,cAAc,CAACC,KAAK,GAAGD,cAAc,CAACE;EAAK,gBAE3DzC,KAAA,CAAAkE,aAAA,CAACxD,OAAO;IACN2D,OAAO,EAAEb,qBAAsB;IAC/BxB,sBAAsB,EAAEA,sBAAuB;IAC/CsC,KAAK,EAAE;MAAEC,aAAa,EAAEnC,IAAI,GAAGoC,SAAS,GAAG;IAAO;EAAE,CACrD,CACG,CAAC,eACNrE,YAAY,CAACa,QAAQ,EAAE6C,UAAU,CAC5B,CAAC;AAEb,CACF,CAAC;AAEDvC,KAAK,CAACmD,WAAW,GAAG,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Modal.js","names":["React","forwardRef","useEffect","ModalBase","warnedAboutDeprecation","Modal","props","ref","process","env","NODE_ENV","console","warn","createElement","_extends","displayName"],"sources":["../../../../src/components/Modal/Modal.tsx"],"sourcesContent":["import React, { forwardRef, HTMLAttributes, useEffect } from \"react\";\n\nimport { IModal, ModalBase } from \"./ModalBase\";\n\nexport type { IModal } from \"./ModalBase\";\n\nlet warnedAboutDeprecation = false;\n\n/**\n * @deprecated A modal that takes any child says nothing about what it shows. Use Dialog for a dialog, Sheet for\n * a side or full panel, and Menu or Popper for an overlay that should not be modal. Modal is removed once nothing\n * renders it.\n */\nexport const Modal = forwardRef<\n HTMLDivElement,\n IModal & HTMLAttributes<HTMLDivElement>\n>((props, ref) => {\n useEffect(() => {\n if (process.env.NODE_ENV === \"production\" || warnedAboutDeprecation) {\n return;\n }\n\n warnedAboutDeprecation = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"Modal is deprecated and will be removed. Use Dialog for a dialog, Sheet for a side or full panel, and Menu or Popper for an overlay that should not be modal.\"\n );\n }, []);\n\n return <ModalBase {...props} ref={ref} />;\n});\n\nModal.displayName = \"Modal\";\n"],"mappings":";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAkBC,SAAS,QAAQ,OAAO;AAEpE,SAAiBC,SAAS,QAAQ,aAAa;AAI/C,IAAIC,sBAAsB,GAAG,KAAK;;AAElC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,gBAAGJ,UAAU,CAG7B,CAACK,KAAK,EAAEC,GAAG,KAAK;EAChBL,SAAS,CAAC,MAAM;IACd,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAIN,sBAAsB,EAAE;MACnE;IACF;IAEAA,sBAAsB,GAAG,IAAI;IAC7B;IACAO,OAAO,CAACC,IAAI,CACV,+JACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOZ,KAAA,CAAAa,aAAA,CAACV,SAAS,EAAAW,QAAA,KAAKR,KAAK;IAAEC,GAAG,EAAEA;EAAI,EAAE,CAAC;AAC3C,CAAC,CAAC;AAEFF,KAAK,CAACU,WAAW,GAAG,OAAO","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import React, { ReactElement } from "react";
2
+ export interface IModal {
3
+ disableFocusLock?: boolean;
4
+ disableScrollLock?: boolean;
5
+ open?: boolean;
6
+ disableBackgroundClick?: boolean;
7
+ disableCloseOnEsc?: boolean;
8
+ disableBackgroundColor?: boolean;
9
+ onClose?: () => void;
10
+ children: ReactElement;
11
+ onClickOutside?: (event: any) => void;
12
+ /** How long the overlay takes to arrive and to leave. Match it to the animation the child runs. */
13
+ overlayTimeout?: {
14
+ enter: number;
15
+ exit: number;
16
+ };
17
+ }
18
+ export declare const ModalBase: React.ForwardRefExoticComponent<IModal & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
19
+ //# sourceMappingURL=ModalBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalBase.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal/ModalBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAOZ,YAAY,EAIb,MAAM,OAAO,CAAC;AAYf,MAAM,WAAW,MAAM;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,KAAA,KAAK,IAAI,CAAC;IACjC,mGAAmG;IACnG,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAClD;AASD,eAAO,MAAM,SAAS,sHAgHrB,CAAC"}