@channel.io/bezier-react 1.7.2 → 1.8.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.
- package/dist/cjs/components/ListItem/ListItem.styled.js +1 -1
- package/dist/cjs/components/Modals/Modal/Modal.types.js.map +1 -1
- package/dist/cjs/components/Modals/Modal/ModalAnimation.styled.js +1 -1
- package/dist/cjs/components/Modals/Modal/ModalContent.js +14 -7
- package/dist/cjs/components/Modals/Modal/ModalContent.js.map +1 -1
- package/dist/cjs/components/Modals/Modal/ModalContext.js +14 -0
- package/dist/cjs/components/Modals/Modal/ModalContext.js.map +1 -0
- package/dist/cjs/components/Modals/Modal/ModalHeader.js +2 -2
- package/dist/cjs/components/Modals/Modal/ModalHeader.js.map +1 -1
- package/dist/cjs/components/Overlay/Overlay.js +13 -11
- package/dist/cjs/components/Overlay/Overlay.js.map +1 -1
- package/dist/cjs/components/Overlay/Overlay.types.js.map +1 -1
- package/dist/cjs/components/Text/Text.styled.js +1 -1
- package/dist/cjs/components/Toast/ToastProvider.js +3 -1
- package/dist/cjs/components/Toast/ToastProvider.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +5 -1
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.types.js.map +1 -1
- package/dist/cjs/hooks/useIsMounted.js +16 -0
- package/dist/cjs/hooks/useIsMounted.js.map +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/ListItem/ListItem.styled.mjs +1 -1
- package/dist/esm/components/Modals/Modal/Modal.types.mjs.map +1 -1
- package/dist/esm/components/Modals/Modal/ModalAnimation.styled.mjs +1 -1
- package/dist/esm/components/Modals/Modal/ModalContent.mjs +16 -9
- package/dist/esm/components/Modals/Modal/ModalContent.mjs.map +1 -1
- package/dist/esm/components/Modals/Modal/ModalContext.mjs +9 -0
- package/dist/esm/components/Modals/Modal/ModalContext.mjs.map +1 -0
- package/dist/esm/components/Modals/Modal/ModalHeader.mjs +2 -2
- package/dist/esm/components/Modals/Modal/ModalHeader.mjs.map +1 -1
- package/dist/esm/components/Overlay/Overlay.mjs +13 -11
- package/dist/esm/components/Overlay/Overlay.mjs.map +1 -1
- package/dist/esm/components/Overlay/Overlay.types.mjs.map +1 -1
- package/dist/esm/components/Text/Text.styled.mjs +1 -1
- package/dist/esm/components/Toast/ToastProvider.mjs +3 -1
- package/dist/esm/components/Toast/ToastProvider.mjs.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.mjs +6 -2
- package/dist/esm/components/Tooltip/Tooltip.mjs.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.types.mjs.map +1 -1
- package/dist/esm/hooks/useIsMounted.mjs +12 -0
- package/dist/esm/hooks/useIsMounted.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/components/Modals/Modal/Modal.types.d.ts +1 -1
- package/dist/types/components/Modals/Modal/Modal.types.d.ts.map +1 -1
- package/dist/types/components/Modals/Modal/ModalContent.d.ts.map +1 -1
- package/dist/types/components/Modals/Modal/ModalContext.d.ts +5 -0
- package/dist/types/components/Modals/Modal/ModalContext.d.ts.map +1 -0
- package/dist/types/components/Modals/Modal/index.d.ts +1 -0
- package/dist/types/components/Modals/Modal/index.d.ts.map +1 -1
- package/dist/types/components/Overlay/Overlay.d.ts.map +1 -1
- package/dist/types/components/Overlay/Overlay.types.d.ts +5 -0
- package/dist/types/components/Overlay/Overlay.types.d.ts.map +1 -1
- package/dist/types/components/Toast/ToastProvider.d.ts.map +1 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/types/components/Tooltip/Tooltip.types.d.ts +1 -0
- package/dist/types/components/Tooltip/Tooltip.types.d.ts.map +1 -1
- package/dist/types/hooks/useIsMounted.d.ts +2 -0
- package/dist/types/hooks/useIsMounted.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/Button/__snapshots__/Button.test.tsx.snap +15 -15
- package/src/components/Forms/FormControl/__snapshots__/FormControl.test.tsx.snap +57 -57
- package/src/components/Modals/Modal/Modal.types.ts +1 -1
- package/src/components/Modals/Modal/ModalContent.tsx +26 -9
- package/src/components/Modals/Modal/ModalContext.ts +15 -0
- package/src/components/Modals/Modal/ModalHeader.tsx +2 -2
- package/src/components/Modals/Modal/index.ts +2 -0
- package/src/components/Overlay/Overlay.tsx +20 -12
- package/src/components/Overlay/Overlay.types.ts +5 -0
- package/src/components/Toast/ToastProvider.tsx +4 -1
- package/src/components/Tooltip/Tooltip.tsx +9 -3
- package/src/components/Tooltip/Tooltip.types.ts +1 -0
- package/src/hooks/useIsMounted.ts +14 -0
- package/dist/cjs/components/Modals/Modal/ModalContentContext.js +0 -11
- package/dist/cjs/components/Modals/Modal/ModalContentContext.js.map +0 -1
- package/dist/esm/components/Modals/Modal/ModalContentContext.mjs +0 -8
- package/dist/esm/components/Modals/Modal/ModalContentContext.mjs.map +0 -1
- package/dist/types/components/Modals/Modal/ModalContentContext.d.ts +0 -4
- package/dist/types/components/Modals/Modal/ModalContentContext.d.ts.map +0 -1
- package/src/components/Modals/Modal/ModalContentContext.ts +0 -10
|
@@ -4,10 +4,10 @@ var DisabledOpacity = require('../../constants/DisabledOpacity.js');
|
|
|
4
4
|
var ListItem_types = require('./ListItem.types.js');
|
|
5
5
|
var utils = require('./utils.js');
|
|
6
6
|
var Icon = require('../Icon/Icon.js');
|
|
7
|
-
var index = require('../../foundation/Transition/index.js');
|
|
8
7
|
var FoundationStyledComponent = require('../../foundation/FoundationStyledComponent.js');
|
|
9
8
|
var Mixins = require('../../foundation/Mixins.js');
|
|
10
9
|
var Typography = require('../../foundation/Typography.js');
|
|
10
|
+
var index = require('../../foundation/Transition/index.js');
|
|
11
11
|
|
|
12
12
|
const getColorFromColorVariantWithDefaultValue = (variant, defaultValue) => {
|
|
13
13
|
switch (variant) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.types.js","sources":["../../../../../src/components/Modals/Modal/Modal.types.ts"],"sourcesContent":["import {\n type BezierComponentProps,\n type ChildrenProps,\n type SideContentProps,\n} from '~/src/types/ComponentProps'\n\nexport enum ModalTitleSize {\n L = 'L',\n M = 'M',\n}\n\ninterface ModalOptions {\n /**\n * The controlled open state of the modal.\n * Must be used in conjunction with `onShow` and `onHide`.\n */\n show?: boolean\n\n /**\n * The open state of the modal when it is initially rendered.\n * Use when you **do not need to control** its open state.\n */\n defaultShow?: boolean\n\n /**\n * Callback function to be called when the modal is opened.\n * @default noop\n */\n onShow?: () => void\n\n /**\n * Callback function to be called when the modal is closed.\n * @default noop\n */\n onHide?: () => void\n}\n\ninterface ModalContentOptions {\n /**\n * Specify a container element to portal the content into.\n * @default document.body\n */\n container?: HTMLElement | null\n\n /**\n * Show close icon button that closes the modal when clicked.\n * @default false\n */\n showCloseIcon?: boolean\n\n /**\n * Width of the modal.\n * @default 'max-content'\n */\n width?: React.CSSProperties['width']\n\n /**\n * Height of the modal.\n * @default 'fit-content'\n */\n height?: React.CSSProperties['height']\n\n /**\n * z-index of the modal content.\n * Rather than using this option, Please check modal is positioned in the proper stacking context.\n * @default ZIndex.Modal\n */\n zIndex?: React.CSSProperties['zIndex']\n}\n\ninterface ModalHeaderOptions {\n /**\n * An accessible title to be announced when the modal is opened.\n */\n title: React.ReactNode\n\n /**\n * An accessible subtitle to be announced when the modal is opened.\n */\n subtitle?: React.ReactNode\n\n /**\n * An accessible description to be announced when the modal is opened.\n */\n description?: React.ReactNode\n\n /**\n * Size of the title\n * @default ModalTitleSize.L\n */\n titleSize?: ModalTitleSize\n\n /**\n * Hides content from the screen in an accessible way.\n * @default false\n */\n hidden?: boolean\n}\n\ntype ModalFooterSideContent = React.ReactNode\n\ninterface ModalFooterOptions extends\n SideContentProps<ModalFooterSideContent, ModalFooterSideContent> {}\n\nexport interface ModalProps extends\n ChildrenProps,\n ModalOptions {}\n\nexport interface ModalContentProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement>,\n ModalContentOptions {}\n\nexport interface ModalHeaderProps extends\n BezierComponentProps,\n Omit<React.HTMLAttributes<HTMLElement>, keyof ModalHeaderOptions>,\n ModalHeaderOptions {}\n\nexport interface ModalBodyProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement> {}\n\nexport interface ModalFooterProps extends\n BezierComponentProps,\n React.HTMLAttributes<HTMLElement>,\n ModalFooterOptions {}\n\nexport interface ModalTriggerProps extends\n ChildrenProps<React.ReactElement> {}\n\nexport interface ModalCloseProps extends\n ChildrenProps<React.ReactElement> {}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"Modal.types.js","sources":["../../../../../src/components/Modals/Modal/Modal.types.ts"],"sourcesContent":["import {\n type BezierComponentProps,\n type ChildrenProps,\n type SideContentProps,\n} from '~/src/types/ComponentProps'\n\nexport enum ModalTitleSize {\n L = 'L',\n M = 'M',\n}\n\ninterface ModalOptions {\n /**\n * The controlled open state of the modal.\n * Must be used in conjunction with `onShow` and `onHide`.\n */\n show?: boolean\n\n /**\n * The open state of the modal when it is initially rendered.\n * Use when you **do not need to control** its open state.\n */\n defaultShow?: boolean\n\n /**\n * Callback function to be called when the modal is opened.\n * @default noop\n */\n onShow?: () => void\n\n /**\n * Callback function to be called when the modal is closed.\n * @default noop\n */\n onHide?: () => void\n}\n\ninterface ModalContentOptions {\n /**\n * Specify a container element to portal the content into.\n * @default document.body\n */\n container?: HTMLElement | null\n\n /**\n * Show close icon button that closes the modal when clicked.\n * @default false\n */\n showCloseIcon?: boolean\n\n /**\n * Width of the modal.\n * @default 'max-content'\n */\n width?: React.CSSProperties['width']\n\n /**\n * Height of the modal.\n * @default 'fit-content'\n */\n height?: React.CSSProperties['height']\n\n /**\n * z-index of the modal content.\n * Rather than using this option, Please check modal is positioned in the proper stacking context.\n * @default ZIndex.Modal\n */\n zIndex?: React.CSSProperties['zIndex']\n}\n\ninterface ModalHeaderOptions {\n /**\n * An accessible title to be announced when the modal is opened.\n */\n title: React.ReactNode\n\n /**\n * An accessible subtitle to be announced when the modal is opened.\n */\n subtitle?: React.ReactNode\n\n /**\n * An accessible description to be announced when the modal is opened.\n */\n description?: React.ReactNode\n\n /**\n * Size of the title\n * @default ModalTitleSize.L\n */\n titleSize?: ModalTitleSize\n\n /**\n * Hides content from the screen in an accessible way.\n * @default false\n */\n hidden?: boolean\n}\n\ntype ModalFooterSideContent = React.ReactNode\n\ninterface ModalFooterOptions extends\n SideContentProps<ModalFooterSideContent, ModalFooterSideContent> {}\n\nexport interface ModalProps extends\n ChildrenProps,\n ModalOptions {}\n\nexport interface ModalContentProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement>,\n ModalContentOptions {}\n\nexport interface ModalHeaderProps extends\n BezierComponentProps,\n Omit<React.HTMLAttributes<HTMLElement>, keyof ModalHeaderOptions>,\n ModalHeaderOptions {}\n\nexport interface ModalBodyProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement> {}\n\nexport interface ModalFooterProps extends\n BezierComponentProps,\n React.HTMLAttributes<HTMLElement>,\n ModalFooterOptions {}\n\nexport interface ModalTriggerProps extends\n ChildrenProps<React.ReactElement> {}\n\nexport interface ModalCloseProps extends\n ChildrenProps<React.ReactElement> {}\n\nexport interface ModalContentPropsContextValue extends\n Required<Pick<ModalContentOptions, 'showCloseIcon'>> {}\n"],"names":["ModalTitleSize"],"mappings":";;AAMYA,IAAAA,cAAc,0BAAdA,cAAc,EAAA;EAAdA,cAAc,CAAA,GAAA,CAAA,GAAA,GAAA,CAAA;EAAdA,cAAc,CAAA,GAAA,CAAA,GAAA,GAAA,CAAA;AAAA,EAAA,OAAdA,cAAc,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var index = require('../../../foundation/Transition/index.js');
|
|
5
6
|
var FoundationStyledComponent = require('../../../foundation/FoundationStyledComponent.js');
|
|
6
7
|
var styled = require('styled-components');
|
|
7
|
-
var index = require('../../../foundation/Transition/index.js');
|
|
8
8
|
|
|
9
9
|
const overlayStyles = {
|
|
10
10
|
open: FoundationStyledComponent.css`
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var index = require('../../../node_modules/@radix-ui/react-dialog/dist/index.js');
|
|
5
5
|
var ZIndex = require('../../../constants/ZIndex.js');
|
|
6
|
+
var useMergeRefs = require('../../../hooks/useMergeRefs.js');
|
|
6
7
|
var domUtils = require('../../../utils/domUtils.js');
|
|
7
8
|
var typeUtils = require('../../../utils/typeUtils.js');
|
|
8
|
-
var
|
|
9
|
+
var ModalContext = require('./ModalContext.js');
|
|
9
10
|
var ModalHelpers = require('./ModalHelpers.js');
|
|
10
11
|
var Modal_styled = require('./Modal.styled.js');
|
|
11
12
|
|
|
@@ -17,13 +18,17 @@ var Modal_styled = require('./Modal.styled.js');
|
|
|
17
18
|
const ModalContent = /*#__PURE__*/React.forwardRef(function ModalContent({
|
|
18
19
|
children,
|
|
19
20
|
style,
|
|
20
|
-
container = domUtils.
|
|
21
|
+
container = domUtils.getRootElement(),
|
|
21
22
|
showCloseIcon = false,
|
|
22
23
|
width = 'max-content',
|
|
23
24
|
height = 'fit-content',
|
|
24
25
|
zIndex = ZIndex.ZIndex.Modal,
|
|
25
26
|
...rest
|
|
26
27
|
}, forwardedRef) {
|
|
28
|
+
const [contentContainer, setContentContainer] = React.useState();
|
|
29
|
+
const contentRef = useMergeRefs.default(forwardedRef, React.useCallback(node => {
|
|
30
|
+
setContentContainer(node ?? undefined);
|
|
31
|
+
}, []));
|
|
27
32
|
const overlayStyle = React.useMemo(() => ({
|
|
28
33
|
'--bezier-modal-z-index': zIndex
|
|
29
34
|
}), [zIndex]);
|
|
@@ -32,7 +37,7 @@ const ModalContent = /*#__PURE__*/React.forwardRef(function ModalContent({
|
|
|
32
37
|
'--bezier-modal-width': typeUtils.isNumber(width) ? `${width}px` : width,
|
|
33
38
|
'--bezier-modal-height': typeUtils.isNumber(height) ? `${height}px` : height
|
|
34
39
|
}), [style, width, height]);
|
|
35
|
-
const
|
|
40
|
+
const propsContextValue = React.useMemo(() => ({
|
|
36
41
|
showCloseIcon
|
|
37
42
|
}), [showCloseIcon]);
|
|
38
43
|
return /*#__PURE__*/React.createElement(index.Portal, {
|
|
@@ -43,11 +48,13 @@ const ModalContent = /*#__PURE__*/React.forwardRef(function ModalContent({
|
|
|
43
48
|
asChild: true
|
|
44
49
|
}, /*#__PURE__*/React.createElement(Modal_styled.Content, Object.assign({
|
|
45
50
|
"aria-modal": true,
|
|
46
|
-
ref:
|
|
51
|
+
ref: contentRef,
|
|
47
52
|
style: contentStyle
|
|
48
|
-
}, rest), /*#__PURE__*/React.createElement(Modal_styled.Section, null, /*#__PURE__*/React.createElement(
|
|
49
|
-
value:
|
|
50
|
-
},
|
|
53
|
+
}, rest), /*#__PURE__*/React.createElement(Modal_styled.Section, null, /*#__PURE__*/React.createElement(ModalContext.ModalContainerContextProvider, {
|
|
54
|
+
value: contentContainer
|
|
55
|
+
}, /*#__PURE__*/React.createElement(ModalContext.ModalContentPropsContextProvider, {
|
|
56
|
+
value: propsContextValue
|
|
57
|
+
}, children)), showCloseIcon && /*#__PURE__*/React.createElement(ModalHelpers.ModalClose, null, /*#__PURE__*/React.createElement(Modal_styled.CloseIconButton, null)))))));
|
|
51
58
|
});
|
|
52
59
|
|
|
53
60
|
exports.ModalContent = ModalContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalContent.js","sources":["../../../../../src/components/Modals/Modal/ModalContent.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useMemo,\n} from 'react'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\n\nimport { ZIndex } from '~/src/constants/ZIndex'\nimport {
|
|
1
|
+
{"version":3,"file":"ModalContent.js","sources":["../../../../../src/components/Modals/Modal/ModalContent.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useMemo,\n useState,\n} from 'react'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\n\nimport { ZIndex } from '~/src/constants/ZIndex'\nimport useMergeRefs from '~/src/hooks/useMergeRefs'\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { isNumber } from '~/src/utils/typeUtils'\n\nimport {\n type ModalContentProps,\n type ModalContentPropsContextValue,\n} from './Modal.types'\nimport {\n ModalContainerContextProvider,\n ModalContentPropsContextProvider,\n} from './ModalContext'\nimport { ModalClose } from './ModalHelpers'\n\nimport * as Styled from './Modal.styled'\n\n/**\n * `ModalContent` is a container of the modal content.\n * It creates a portal to render the modal content outside of the DOM tree\n * and renders overlay behind the modal content too.\n */\nexport const ModalContent = forwardRef(function ModalContent({\n children,\n style,\n container = getRootElement(),\n showCloseIcon = false,\n width = 'max-content',\n height = 'fit-content',\n zIndex = ZIndex.Modal,\n ...rest\n}: ModalContentProps, forwardedRef: React.Ref<HTMLDivElement>) {\n const [contentContainer, setContentContainer] = useState<HTMLElement>()\n\n const contentRef = useMergeRefs(\n forwardedRef,\n useCallback((node: HTMLElement | null) => {\n setContentContainer(node ?? undefined)\n }, []),\n )\n\n const overlayStyle = useMemo((): React.CSSProperties & {\n '--bezier-modal-z-index': ModalContentProps['zIndex']\n } => ({\n '--bezier-modal-z-index': zIndex,\n }), [zIndex])\n\n const contentStyle = useMemo((): React.CSSProperties & {\n '--bezier-modal-width': ModalContentProps['width']\n '--bezier-modal-height': ModalContentProps['height']\n } => ({\n ...style,\n '--bezier-modal-width': isNumber(width) ? `${width}px` : width,\n '--bezier-modal-height': isNumber(height) ? `${height}px` : height,\n }), [\n style,\n width,\n height,\n ])\n\n const propsContextValue = useMemo((): ModalContentPropsContextValue => ({\n showCloseIcon,\n }), [showCloseIcon])\n\n return (\n <DialogPrimitive.Portal container={container}>\n <Styled.DialogPrimitiveOverlay style={overlayStyle}>\n <DialogPrimitive.Content asChild>\n <Styled.Content\n aria-modal\n ref={contentRef}\n style={contentStyle}\n {...rest}\n >\n <Styled.Section>\n <ModalContainerContextProvider value={contentContainer}>\n <ModalContentPropsContextProvider value={propsContextValue}>\n { children }\n </ModalContentPropsContextProvider>\n </ModalContainerContextProvider>\n\n { /* NOTE: To prevent focusing first on the close button when opening the modal, place the close button behind. */ }\n { showCloseIcon && (\n <ModalClose>\n <Styled.CloseIconButton />\n </ModalClose>\n ) }\n </Styled.Section>\n </Styled.Content>\n </DialogPrimitive.Content>\n </Styled.DialogPrimitiveOverlay>\n </DialogPrimitive.Portal>\n )\n})\n"],"names":["ModalContent","forwardRef","children","style","container","getRootElement","showCloseIcon","width","height","zIndex","ZIndex","Modal","rest","forwardedRef","contentContainer","setContentContainer","useState","contentRef","useMergeRefs","useCallback","node","undefined","overlayStyle","useMemo","contentStyle","isNumber","propsContextValue","React","createElement","DialogPrimitive","Styled","asChild","Object","assign","ref","ModalContainerContextProvider","value","ModalContentPropsContextProvider","ModalClose"],"mappings":";;;;;;;;;;;;AA0BA;AACA;AACA;AACA;AACA;MACaA,YAAY,gBAAGC,gBAAU,CAAC,SAASD,YAAYA,CAAC;EAC3DE,QAAQ;EACRC,KAAK;EACLC,SAAS,GAAGC,uBAAc,EAAE;AAC5BC,EAAAA,aAAa,GAAG,KAAK;AACrBC,EAAAA,KAAK,GAAG,aAAa;AACrBC,EAAAA,MAAM,GAAG,aAAa;EACtBC,MAAM,GAAGC,aAAM,CAACC,KAAK;EACrB,GAAGC,IAAAA;AACc,CAAC,EAAEC,YAAuC,EAAE;EAC7D,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGC,cAAQ,EAAe,CAAA;EAEvE,MAAMC,UAAU,GAAGC,oBAAY,CAC7BL,YAAY,EACZM,iBAAW,CAAEC,IAAwB,IAAK;AACxCL,IAAAA,mBAAmB,CAACK,IAAI,IAAIC,SAAS,CAAC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AC,aAAA,CAACO,0CAA6B,EAAA;AAACC,IAAAA,KAAK,EAAEtB,gBAAAA;AAAiB,GAAA,eACrDa,KAAA,CAAAC,aAAA,CAACS,6CAAgC,EAAA;AAACD,IAAAA,KAAK,EAAEV,iBAAAA;GACrCxB,EAAAA,QAC8B,CACL,CAAC,EAG9BI,aAAa,iBACbqB,KAAA,CAAAC,aAAA,CAACU,uBAAU,EACTX,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACE,4BAAsB,EAAA,IAAE,CACf,CAEA,CACF,CACO,CACI,CACT,CAAC,CAAA;AAE7B,CAAC;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactUtils = require('../../../utils/reactUtils.js');
|
|
4
|
+
|
|
5
|
+
const [ModalContentPropsContextProvider, useModalContentPropsContext] = reactUtils.createContext({
|
|
6
|
+
showCloseIcon: false
|
|
7
|
+
});
|
|
8
|
+
const [ModalContainerContextProvider, useModalContainerContext] = reactUtils.createContext(undefined);
|
|
9
|
+
|
|
10
|
+
exports.ModalContainerContextProvider = ModalContainerContextProvider;
|
|
11
|
+
exports.ModalContentPropsContextProvider = ModalContentPropsContextProvider;
|
|
12
|
+
exports.useModalContainerContext = useModalContainerContext;
|
|
13
|
+
exports.useModalContentPropsContext = useModalContentPropsContext;
|
|
14
|
+
//# sourceMappingURL=ModalContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sources":["../../../../../src/components/Modals/Modal/ModalContext.ts"],"sourcesContent":["import { createContext } from '~/src/utils/reactUtils'\n\nimport { type ModalContentPropsContextValue } from './Modal.types'\n\nexport const [\n ModalContentPropsContextProvider,\n useModalContentPropsContext,\n] = createContext<ModalContentPropsContextValue>({\n showCloseIcon: false,\n})\n\nexport const [\n ModalContainerContextProvider,\n useModalContainerContext,\n] = createContext<HTMLElement | undefined>(undefined)\n"],"names":["ModalContentPropsContextProvider","useModalContentPropsContext","createContext","showCloseIcon","ModalContainerContextProvider","useModalContainerContext","undefined"],"mappings":";;;;AAIO,MAAM,CACXA,gCAAgC,EAChCC,2BAA2B,CAC5B,GAAGC,wBAAa,CAAgC;AAC/CC,EAAAA,aAAa,EAAE,KAAA;AACjB,CAAC,EAAC;AAEK,MAAM,CACXC,6BAA6B,EAC7BC,wBAAwB,CACzB,GAAGH,wBAAa,CAA0BI,SAAS;;;;;;;"}
|
|
@@ -4,7 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var index = require('../../../node_modules/@radix-ui/react-dialog/dist/index.js');
|
|
5
5
|
var Text = require('../../Text/Text.js');
|
|
6
6
|
var Modal_types = require('./Modal.types.js');
|
|
7
|
-
var
|
|
7
|
+
var ModalContext = require('./ModalContext.js');
|
|
8
8
|
var Modal_styled = require('./Modal.styled.js');
|
|
9
9
|
var VisuallyHidden = require('../../VisuallyHidden/VisuallyHidden.js');
|
|
10
10
|
var Typography = require('../../../foundation/Typography.js');
|
|
@@ -59,7 +59,7 @@ const ModalHeader = /*#__PURE__*/React.forwardRef(function ModalHeader({
|
|
|
59
59
|
}, forwardedRef) {
|
|
60
60
|
const {
|
|
61
61
|
showCloseIcon
|
|
62
|
-
} =
|
|
62
|
+
} = ModalContext.useModalContentPropsContext();
|
|
63
63
|
const hasTitleArea = title || showCloseIcon;
|
|
64
64
|
const Hidden = hidden ? VisuallyHidden.VisuallyHidden : React.Fragment;
|
|
65
65
|
return /*#__PURE__*/React.createElement(Hidden, null, /*#__PURE__*/React.createElement(Modal_styled.Header, Object.assign({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalHeader.js","sources":["../../../../../src/components/Modals/Modal/ModalHeader.tsx"],"sourcesContent":["import React, { forwardRef } from 'react'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\n\nimport { Typography } from '~/src/foundation'\n\nimport { Text } from '~/src/components/Text'\nimport { VisuallyHidden } from '~/src/components/VisuallyHidden'\n\nimport {\n type ModalHeaderProps,\n ModalTitleSize,\n} from './Modal.types'\nimport {
|
|
1
|
+
{"version":3,"file":"ModalHeader.js","sources":["../../../../../src/components/Modals/Modal/ModalHeader.tsx"],"sourcesContent":["import React, { forwardRef } from 'react'\n\nimport * as DialogPrimitive from '@radix-ui/react-dialog'\n\nimport { Typography } from '~/src/foundation'\n\nimport { Text } from '~/src/components/Text'\nimport { VisuallyHidden } from '~/src/components/VisuallyHidden'\n\nimport {\n type ModalHeaderProps,\n ModalTitleSize,\n} from './Modal.types'\nimport { useModalContentPropsContext } from './ModalContext'\n\nimport * as Styled from './Modal.styled'\n\nfunction getTitleTypo(size: ModalTitleSize) {\n switch (size) {\n case ModalTitleSize.L:\n return Typography.Size24\n case ModalTitleSize.M:\n return Typography.Size16\n default:\n return Typography.Size16\n }\n}\n\nfunction ModalHeaderTitle({\n children,\n size,\n subtitle,\n}: React.PropsWithChildren<Pick<ModalHeaderProps, 'subtitle'> & { size: NonNullable<ModalHeaderProps['titleSize']> }>) {\n const hasSubtitle = !!subtitle\n const titleTypo = getTitleTypo(size)\n\n return (\n <DialogPrimitive.Title asChild>\n { hasSubtitle\n ? (\n <Styled.HeadingGroup\n role=\"group\"\n aria-roledescription=\"Heading group\"\n >\n <Styled.Title typo={titleTypo}>\n { children }\n </Styled.Title>\n\n <Text\n aria-roledescription=\"subtitle\"\n as=\"p\"\n bold\n color=\"txt-black-dark\"\n typo={Typography.Size13}\n >\n { subtitle }\n </Text>\n </Styled.HeadingGroup>\n )\n : (\n <Styled.Title typo={titleTypo}>\n { children }\n </Styled.Title>\n ) }\n </DialogPrimitive.Title>\n )\n}\n\n/**\n * `ModalHeader` is a header of the modal content.\n * It renders the accessible title and description of the modal.\n * If you want to hide the title and description, use `hidden` prop.\n */\nexport const ModalHeader = forwardRef(function ModalHeader({\n title,\n subtitle,\n description,\n titleSize = ModalTitleSize.L,\n hidden = false,\n ...rest\n}: ModalHeaderProps, forwardedRef: React.Ref<HTMLElement>) {\n const { showCloseIcon } = useModalContentPropsContext()\n const hasTitleArea = title || showCloseIcon\n const Hidden = hidden ? VisuallyHidden : React.Fragment\n\n return (\n <Hidden>\n <Styled.Header\n ref={forwardedRef}\n hidden={hidden}\n {...rest}\n >\n { hasTitleArea && (\n <Styled.TitleContainer>\n { title && (\n <ModalHeaderTitle\n size={titleSize}\n subtitle={subtitle}\n >\n { title }\n </ModalHeaderTitle>\n ) }\n\n { showCloseIcon && (\n <Styled.CloseIconButtonSpacer />\n ) }\n </Styled.TitleContainer>\n ) }\n\n { description && (\n <DialogPrimitive.Description asChild>\n <Text\n as=\"p\"\n color=\"txt-black-darkest\"\n typo={Typography.Size15}\n >\n { description }\n </Text>\n </DialogPrimitive.Description>\n ) }\n </Styled.Header>\n </Hidden>\n )\n})\n"],"names":["getTitleTypo","size","ModalTitleSize","L","Typography","Size24","M","Size16","ModalHeaderTitle","children","subtitle","hasSubtitle","titleTypo","React","createElement","DialogPrimitive","asChild","Styled","role","typo","Text","as","bold","color","Size13","ModalHeader","forwardRef","title","description","titleSize","hidden","rest","forwardedRef","showCloseIcon","useModalContentPropsContext","hasTitleArea","Hidden","VisuallyHidden","Fragment","Object","assign","ref","Size15"],"mappings":";;;;;;;;;;;AAiBA,SAASA,YAAYA,CAACC,IAAoB,EAAE;AAC1C,EAAA,QAAQA,IAAI;IACV,KAAKC,0BAAc,CAACC,CAAC;MACnB,OAAOC,qBAAU,CAACC,MAAM,CAAA;IAC1B,KAAKH,0BAAc,CAACI,CAAC;MACnB,OAAOF,qBAAU,CAACG,MAAM,CAAA;AAC1B,IAAA;MACE,OAAOH,qBAAU,CAACG,MAAM,CAAA;AAC5B,GAAA;AACF,CAAA;AAEA,SAASC,gBAAgBA,CAAC;EACxBC,QAAQ;EACRR,IAAI;AACJS,EAAAA,QAAAA;AACkH,CAAC,EAAE;AACrH,EAAA,MAAMC,WAAW,GAAG,CAAC,CAACD,QAAQ,CAAA;AAC9B,EAAA,MAAME,SAAS,GAAGZ,YAAY,CAACC,IAAI,CAA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KAAA,CAAAC,aAAA,CAACG,mBAAa,EAAAsB,MAAA,CAAAC,MAAA,CAAA;AACZC,IAAAA,GAAG,EAAET,YAAa;AAClBF,IAAAA,MAAM,EAAEA,MAAAA;AAAO,GAAA,EACXC,IAAI,CAENI,EAAAA,YAAY,iBACZtB,KAAA,CAAAC,aAAA,CAACG,2BAAqB,QAClBU,KAAK,iBACLd,KAAA,CAAAC,aAAA,CAACN,gBAAgB,EAAA;AACfP,IAAAA,IAAI,EAAE4B,SAAU;AAChBnB,IAAAA,QAAQ,EAAEA,QAAAA;GAERiB,EAAAA,KACc,CACnB,EAECM,aAAa,iBACbpB,KAAA,CAAAC,aAAA,CAACG,kCAA4B,MAAE,CAEZ,CACxB,EAECW,WAAW,iBACXf,KAAA,CAAAC,aAAA,CAACC,iBAA2B,EAAA;IAACC,OAAO,EAAA,IAAA;AAAA,GAAA,eAClCH,KAAA,CAAAC,aAAA,CAACM,YAAI,EAAA;AACHC,IAAAA,EAAE,EAAC,GAAG;AACNE,IAAAA,KAAK,EAAC,mBAAmB;IACzBJ,IAAI,EAAEf,qBAAU,CAACsC,MAAAA;AAAO,GAAA,EAEtBd,WACE,CACqB,CAElB,CACT,CAAC,CAAA;AAEb,CAAC;;;;"}
|
|
@@ -10,6 +10,7 @@ var domUtils = require('../../utils/domUtils.js');
|
|
|
10
10
|
var functionUtils = require('../../utils/functionUtils.js');
|
|
11
11
|
var Overlay_types = require('./Overlay.types.js');
|
|
12
12
|
var Overlay_styled = require('./Overlay.styled.js');
|
|
13
|
+
var ModalContext = require('../Modals/Modal/ModalContext.js');
|
|
13
14
|
|
|
14
15
|
const CONTAINER_TEST_ID = 'bezier-react-container';
|
|
15
16
|
const WRAPPER_TEST_ID = 'bezier-react-wrapper';
|
|
@@ -25,7 +26,7 @@ function Overlay({
|
|
|
25
26
|
style,
|
|
26
27
|
containerClassName = '',
|
|
27
28
|
containerStyle,
|
|
28
|
-
container,
|
|
29
|
+
container: givenContainer,
|
|
29
30
|
target,
|
|
30
31
|
position = Overlay_types.OverlayPosition.LeftCenter,
|
|
31
32
|
marginX = 0,
|
|
@@ -38,9 +39,7 @@ function Overlay({
|
|
|
38
39
|
onTransitionEnd = functionUtils.noop,
|
|
39
40
|
...rest
|
|
40
41
|
}, forwardedRef) {
|
|
41
|
-
// NOTE: DOM render 가 필요한지 여부를 결정하는 state
|
|
42
42
|
const [shouldRender, setShouldRender] = React.useState(false);
|
|
43
|
-
// NOTE: 화면에 실제 표현해야 하는지 여부를 결정하는 state
|
|
44
43
|
const [shouldShow, setShouldShow] = React.useState(false);
|
|
45
44
|
const containerRect = React.useRef(null);
|
|
46
45
|
const targetRect = React.useRef(null);
|
|
@@ -48,26 +47,29 @@ function Overlay({
|
|
|
48
47
|
const containerRef = React.useRef(null);
|
|
49
48
|
const overlayRef = React.useRef(null);
|
|
50
49
|
const mergedRef = useMergeRefs.default(overlayRef, forwardedRef);
|
|
50
|
+
const defaultContainer = domUtils.getRootElement();
|
|
51
|
+
const modalContainer = ModalContext.useModalContainerContext();
|
|
52
|
+
const hasContainer = Boolean(givenContainer || modalContainer);
|
|
53
|
+
const container = givenContainer ?? modalContainer ?? defaultContainer;
|
|
51
54
|
const handleOverlayForceUpdate = React.useCallback(() => {
|
|
52
55
|
forceUpdate();
|
|
53
56
|
}, []);
|
|
54
57
|
const handleContainerRect = React.useCallback(() => {
|
|
55
|
-
const containerElement = container || domUtils.getRootElement();
|
|
56
58
|
const {
|
|
57
59
|
width: containerWidth,
|
|
58
60
|
height: containerHeight,
|
|
59
61
|
top: containerTop,
|
|
60
62
|
left: containerLeft
|
|
61
|
-
} =
|
|
63
|
+
} = container.getBoundingClientRect();
|
|
62
64
|
containerRect.current = {
|
|
63
65
|
containerWidth,
|
|
64
66
|
containerHeight,
|
|
65
67
|
containerTop,
|
|
66
68
|
containerLeft,
|
|
67
|
-
scrollTop:
|
|
68
|
-
scrollLeft:
|
|
69
|
+
scrollTop: hasContainer ? container.scrollTop : 0,
|
|
70
|
+
scrollLeft: hasContainer ? container.scrollLeft : 0
|
|
69
71
|
};
|
|
70
|
-
}, [container]);
|
|
72
|
+
}, [container, hasContainer]);
|
|
71
73
|
React.useLayoutEffect(function initContainerRect() {
|
|
72
74
|
if (show) {
|
|
73
75
|
handleContainerRect();
|
|
@@ -146,7 +148,7 @@ function Overlay({
|
|
|
146
148
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
147
149
|
, [as, children, className, containerRect, handleTransitionEnd, keepInContainer, marginX, marginY, mergedRef, position, shouldShow, style, targetRect, testId, withTransition, dummy]);
|
|
148
150
|
const overlay = React.useMemo(() => {
|
|
149
|
-
if (
|
|
151
|
+
if (hasContainer) {
|
|
150
152
|
return Content;
|
|
151
153
|
}
|
|
152
154
|
return /*#__PURE__*/React.createElement(Overlay_styled.DefaultContainer, {
|
|
@@ -158,7 +160,7 @@ function Overlay({
|
|
|
158
160
|
}, /*#__PURE__*/React.createElement(Overlay_styled.DefaultWrapper, {
|
|
159
161
|
"data-testid": wrapperTestId
|
|
160
162
|
}, Content));
|
|
161
|
-
}, [
|
|
163
|
+
}, [hasContainer, containerClassName, show, containerStyle, containerTestId, wrapperTestId, Content]);
|
|
162
164
|
React.useEffect(() => {
|
|
163
165
|
handleOverlayForceUpdate();
|
|
164
166
|
}, [children, handleOverlayForceUpdate]);
|
|
@@ -196,7 +198,7 @@ function Overlay({
|
|
|
196
198
|
if (!shouldRender) {
|
|
197
199
|
return null;
|
|
198
200
|
}
|
|
199
|
-
return /*#__PURE__*/ReactDOM.createPortal(overlay, container
|
|
201
|
+
return /*#__PURE__*/ReactDOM.createPortal(overlay, container);
|
|
200
202
|
}
|
|
201
203
|
var Overlay$1 = /*#__PURE__*/React.forwardRef(Overlay);
|
|
202
204
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Overlay.js","sources":["../../../../src/components/Overlay/Overlay.tsx"],"sourcesContent":["import React, {\n type Ref,\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n\nimport ReactDOM from 'react-dom'\n\nimport useEventHandler from '~/src/hooks/useEventHandler'\nimport useMergeRefs from '~/src/hooks/useMergeRefs'\nimport {\n document,\n getRootElement,\n window,\n} from '~/src/utils/domUtils'\nimport { noop } from '~/src/utils/functionUtils'\n\nimport type OverlayProps from './Overlay.types'\nimport {\n type ContainerRectAttr,\n type TargetRectAttr,\n} from './Overlay.types'\nimport { OverlayPosition } from './Overlay.types'\n\nimport * as Styled from './Overlay.styled'\n\nexport const CONTAINER_TEST_ID = 'bezier-react-container'\nexport const WRAPPER_TEST_ID = 'bezier-react-wrapper'\nexport const OVERLAY_TEST_ID = 'bezier-react-overlay'\nexport const ESCAPE_KEY = 'Escape'\n\nfunction Overlay(\n {\n as,\n containerTestId = CONTAINER_TEST_ID,\n wrapperTestId = WRAPPER_TEST_ID,\n testId = OVERLAY_TEST_ID,\n show = false,\n className = '',\n style,\n containerClassName = '',\n containerStyle,\n container,\n target,\n position = OverlayPosition.LeftCenter,\n marginX = 0,\n marginY = 0,\n keepInContainer = false,\n withTransition = false,\n enableClickOutside = false,\n children,\n onHide = noop,\n onTransitionEnd = noop,\n ...rest\n }: OverlayProps,\n forwardedRef: Ref<HTMLDivElement>,\n) {\n // NOTE: DOM render 가 필요한지 여부를 결정하는 state\n const [shouldRender, setShouldRender] = useState(false)\n // NOTE: 화면에 실제 표현해야 하는지 여부를 결정하는 state\n const [shouldShow, setShouldShow] = useState(false)\n const containerRect = useRef<ContainerRectAttr | null>(null)\n const targetRect = useRef<TargetRectAttr | null>(null)\n\n const [dummy, forceUpdate] = useReducer(x => !x, true)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const overlayRef = useRef<HTMLDivElement>(null)\n const mergedRef = useMergeRefs<HTMLDivElement>(overlayRef, forwardedRef)\n\n const handleOverlayForceUpdate = useCallback(() => {\n forceUpdate()\n }, [])\n\n const handleContainerRect = useCallback(() => {\n const containerElement = container || getRootElement()\n\n const {\n width: containerWidth,\n height: containerHeight,\n top: containerTop,\n left: containerLeft,\n } = containerElement.getBoundingClientRect()\n\n containerRect.current = {\n containerWidth,\n containerHeight,\n containerTop,\n containerLeft,\n scrollTop: container ? container.scrollTop : 0,\n scrollLeft: container ? container.scrollLeft : 0,\n }\n }, [container])\n\n useLayoutEffect(function initContainerRect() {\n if (show) {\n handleContainerRect()\n }\n }, [\n show,\n handleContainerRect,\n ])\n\n const handleTargetRect = useCallback(() => {\n if (!target) {\n return\n }\n const {\n width: targetWidth,\n height: targetHeight,\n top: targetTop,\n left: targetLeft,\n } = target.getBoundingClientRect()\n const { clientTop, clientLeft } = target\n\n targetRect.current = {\n targetWidth,\n targetHeight,\n targetTop,\n targetLeft,\n clientTop,\n clientLeft,\n }\n }, [target])\n\n useLayoutEffect(function initTargetRect() {\n if (show) {\n handleTargetRect()\n }\n }, [\n show,\n handleTargetRect,\n ])\n\n const handleTransitionEnd = useCallback<React.TransitionEventHandler<HTMLDivElement>>((event) => {\n onTransitionEnd(event)\n if (!show) {\n setShouldRender(false)\n }\n }, [\n show,\n onTransitionEnd,\n ])\n\n const handleBlockMouseWheel = useCallback((event: HTMLElementEventMap['wheel']) => {\n event.stopPropagation()\n }, [])\n\n const handleHideOverlay = useCallback((event: any) => {\n if (!event.target?.closest(Styled.Overlay)) {\n onHide()\n\n if (!enableClickOutside) {\n event.stopPropagation()\n }\n }\n }, [\n enableClickOutside,\n onHide,\n ])\n\n const handleKeydown = useCallback((event: HTMLElementEventMap['keyup']) => {\n if (event.key === ESCAPE_KEY) {\n onHide()\n }\n }, [onHide])\n\n useEventHandler(document, 'click', handleHideOverlay, show, true)\n useEventHandler(document, 'keydown', handleKeydown, show)\n useEventHandler(containerRef.current, 'wheel', handleBlockMouseWheel, show)\n\n const Content = useMemo(() => (\n <Styled.Overlay\n as={as}\n ref={mergedRef}\n className={className}\n show={shouldShow}\n withTransition={withTransition}\n style={style}\n data-testid={testId}\n containerRect={containerRect.current}\n targetRect={targetRect.current}\n overlay={overlayRef.current}\n position={position}\n marginX={marginX}\n marginY={marginY}\n keepInContainer={keepInContainer}\n onTransitionEnd={handleTransitionEnd}\n {...rest}\n >\n { children }\n </Styled.Overlay>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ), [\n as,\n children,\n className,\n containerRect,\n handleTransitionEnd,\n keepInContainer,\n marginX,\n marginY,\n mergedRef,\n position,\n shouldShow,\n style,\n targetRect,\n testId,\n withTransition,\n dummy,\n ])\n\n const overlay = useMemo(() => {\n if (container) {\n return Content\n }\n\n return (\n <Styled.DefaultContainer\n ref={containerRef}\n className={containerClassName}\n show={show}\n style={containerStyle}\n data-testid={containerTestId}\n >\n <Styled.DefaultWrapper data-testid={wrapperTestId}>\n { Content }\n </Styled.DefaultWrapper>\n </Styled.DefaultContainer>\n )\n }, [\n container,\n containerClassName,\n show,\n containerStyle,\n containerTestId,\n wrapperTestId,\n Content,\n ])\n\n useEffect(() => {\n handleOverlayForceUpdate()\n }, [\n children,\n handleOverlayForceUpdate,\n ])\n\n /**\n * Case 1: show === true\n * show -> shouldRender -> shouldShow\n * shouldRender 를 true 로 설정하고, 직후에 shouldShow 를 true 로 설정하여 transition 유발\n *\n * Case 2: show === false\n * show -> shouldShow -> (...) -> shouldRender\n * shouldShow 를 false 로 설정하고, shouldRender 는 transition 필요 여부에 따라 다르게 결정함\n * Case 2-1: withTransition === true\n * shouldShow -> onTransitionEnd -> shouldRender\n * onTransitionEnd handler 를 이용해 transition 이 끝난 다음 shouldRender 를 false 로 설정\n * Case 2-2: withTransition === false\n * shouldShow && shouldRender\n * transition 을 기다릴 필요가 없으므로 바로 shouldRender 를 false 로 설정\n */\n useEffect(() => {\n if (show) {\n if (shouldRender) {\n window.requestAnimationFrame(() => setShouldShow(true))\n } else {\n window.requestAnimationFrame(() => setShouldRender(true))\n }\n }\n\n if (!show) {\n window.requestAnimationFrame(() => setShouldShow(false))\n\n if (!withTransition) {\n window.requestAnimationFrame(() => setShouldRender(false))\n }\n }\n }, [\n show,\n withTransition,\n shouldRender,\n shouldShow,\n ])\n\n if (!shouldRender) { return null }\n\n return ReactDOM.createPortal(\n overlay,\n container || getRootElement(),\n )\n}\n\nexport default forwardRef(Overlay)\n"],"names":["CONTAINER_TEST_ID","WRAPPER_TEST_ID","OVERLAY_TEST_ID","ESCAPE_KEY","Overlay","as","containerTestId","wrapperTestId","testId","show","className","style","containerClassName","containerStyle","container","target","position","OverlayPosition","LeftCenter","marginX","marginY","keepInContainer","withTransition","enableClickOutside","children","onHide","noop","onTransitionEnd","rest","forwardedRef","shouldRender","setShouldRender","useState","shouldShow","setShouldShow","containerRect","useRef","targetRect","dummy","forceUpdate","useReducer","x","containerRef","overlayRef","mergedRef","useMergeRefs","handleOverlayForceUpdate","useCallback","handleContainerRect","containerElement","getRootElement","width","containerWidth","height","containerHeight","top","containerTop","left","containerLeft","getBoundingClientRect","current","scrollTop","scrollLeft","useLayoutEffect","initContainerRect","handleTargetRect","targetWidth","targetHeight","targetTop","targetLeft","clientTop","clientLeft","initTargetRect","handleTransitionEnd","event","handleBlockMouseWheel","stopPropagation","handleHideOverlay","closest","Styled","handleKeydown","key","useEventHandler","document","Content","useMemo","React","createElement","Object","assign","ref","overlay","useEffect","window","requestAnimationFrame","ReactDOM","createPortal","forwardRef"],"mappings":";;;;;;;;;;;;;AAgCO,MAAMA,iBAAiB,GAAG,yBAAwB;AAClD,MAAMC,eAAe,GAAG,uBAAsB;AAC9C,MAAMC,eAAe,GAAG,uBAAsB;AAC9C,MAAMC,UAAU,GAAG,SAAQ;AAElC,SAASC,OAAOA,CACd;EACEC,EAAE;AACFC,EAAAA,eAAe,GAAGN,iBAAiB;AACnCO,EAAAA,aAAa,GAAGN,eAAe;AAC/BO,EAAAA,MAAM,GAAGN,eAAe;AACxBO,EAAAA,IAAI,GAAG,KAAK;AACZC,EAAAA,SAAS,GAAG,EAAE;EACdC,KAAK;AACLC,EAAAA,kBAAkB,GAAG,EAAE;EACvBC,cAAc;EACdC,S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AC5D,OAAA;AACF,KAAA;GACD,EAAE,CACDtB,IAAI,EACJa,cAAc,EACdQ,YAAY,EACZG,UAAU,CACX,CAAC,CAAA;EAEF,IAAI,CAACH,YAAY,EAAE;AAAE,IAAA,OAAO,IAAI,CAAA;AAAC,GAAA;EAEjC,oBAAOiE,QAAQ,CAACC,YAAY,CAC1BL,OAAO,EACP7E,SAAS,IAAIoC,uBAAc,EAC7B,CAAC,CAAA;AACH,CAAA;AAEA,gBAAe+C,aAAAA,gBAAU,CAAC7F,OAAO,CAAC;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Overlay.js","sources":["../../../../src/components/Overlay/Overlay.tsx"],"sourcesContent":["import React, {\n type Ref,\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from 'react'\n\nimport ReactDOM from 'react-dom'\n\nimport useEventHandler from '~/src/hooks/useEventHandler'\nimport useMergeRefs from '~/src/hooks/useMergeRefs'\nimport {\n document,\n getRootElement,\n window,\n} from '~/src/utils/domUtils'\nimport { noop } from '~/src/utils/functionUtils'\n\nimport { useModalContainerContext } from '~/src/components/Modals'\n\nimport type OverlayProps from './Overlay.types'\nimport {\n type ContainerRectAttr,\n type TargetRectAttr,\n} from './Overlay.types'\nimport { OverlayPosition } from './Overlay.types'\n\nimport * as Styled from './Overlay.styled'\n\nexport const CONTAINER_TEST_ID = 'bezier-react-container'\nexport const WRAPPER_TEST_ID = 'bezier-react-wrapper'\nexport const OVERLAY_TEST_ID = 'bezier-react-overlay'\nexport const ESCAPE_KEY = 'Escape'\n\nfunction Overlay(\n {\n as,\n containerTestId = CONTAINER_TEST_ID,\n wrapperTestId = WRAPPER_TEST_ID,\n testId = OVERLAY_TEST_ID,\n show = false,\n className = '',\n style,\n containerClassName = '',\n containerStyle,\n container: givenContainer,\n target,\n position = OverlayPosition.LeftCenter,\n marginX = 0,\n marginY = 0,\n keepInContainer = false,\n withTransition = false,\n enableClickOutside = false,\n children,\n onHide = noop,\n onTransitionEnd = noop,\n ...rest\n }: OverlayProps,\n forwardedRef: Ref<HTMLDivElement>,\n) {\n const [shouldRender, setShouldRender] = useState(false)\n const [shouldShow, setShouldShow] = useState(false)\n\n const containerRect = useRef<ContainerRectAttr | null>(null)\n const targetRect = useRef<TargetRectAttr | null>(null)\n\n const [dummy, forceUpdate] = useReducer(x => !x, true)\n\n const containerRef = useRef<HTMLDivElement>(null)\n const overlayRef = useRef<HTMLDivElement>(null)\n const mergedRef = useMergeRefs<HTMLDivElement>(overlayRef, forwardedRef)\n\n const defaultContainer = getRootElement()\n const modalContainer = useModalContainerContext()\n\n const hasContainer = Boolean(givenContainer || modalContainer)\n const container = givenContainer ?? modalContainer ?? defaultContainer\n\n const handleOverlayForceUpdate = useCallback(() => {\n forceUpdate()\n }, [])\n\n const handleContainerRect = useCallback(() => {\n const {\n width: containerWidth,\n height: containerHeight,\n top: containerTop,\n left: containerLeft,\n } = container.getBoundingClientRect()\n\n containerRect.current = {\n containerWidth,\n containerHeight,\n containerTop,\n containerLeft,\n scrollTop: hasContainer ? container.scrollTop : 0,\n scrollLeft: hasContainer ? container.scrollLeft : 0,\n }\n }, [\n container,\n hasContainer,\n ])\n\n useLayoutEffect(function initContainerRect() {\n if (show) {\n handleContainerRect()\n }\n }, [\n show,\n handleContainerRect,\n ])\n\n const handleTargetRect = useCallback(() => {\n if (!target) {\n return\n }\n const {\n width: targetWidth,\n height: targetHeight,\n top: targetTop,\n left: targetLeft,\n } = target.getBoundingClientRect()\n const { clientTop, clientLeft } = target\n\n targetRect.current = {\n targetWidth,\n targetHeight,\n targetTop,\n targetLeft,\n clientTop,\n clientLeft,\n }\n }, [target])\n\n useLayoutEffect(function initTargetRect() {\n if (show) {\n handleTargetRect()\n }\n }, [\n show,\n handleTargetRect,\n ])\n\n const handleTransitionEnd = useCallback<React.TransitionEventHandler<HTMLDivElement>>((event) => {\n onTransitionEnd(event)\n if (!show) {\n setShouldRender(false)\n }\n }, [\n show,\n onTransitionEnd,\n ])\n\n const handleBlockMouseWheel = useCallback((event: HTMLElementEventMap['wheel']) => {\n event.stopPropagation()\n }, [])\n\n const handleHideOverlay = useCallback((event: any) => {\n if (!event.target?.closest(Styled.Overlay)) {\n onHide()\n\n if (!enableClickOutside) {\n event.stopPropagation()\n }\n }\n }, [\n enableClickOutside,\n onHide,\n ])\n\n const handleKeydown = useCallback((event: HTMLElementEventMap['keyup']) => {\n if (event.key === ESCAPE_KEY) {\n onHide()\n }\n }, [onHide])\n\n useEventHandler(document, 'click', handleHideOverlay, show, true)\n useEventHandler(document, 'keydown', handleKeydown, show)\n useEventHandler(containerRef.current, 'wheel', handleBlockMouseWheel, show)\n\n const Content = useMemo(() => (\n <Styled.Overlay\n as={as}\n ref={mergedRef}\n className={className}\n show={shouldShow}\n withTransition={withTransition}\n style={style}\n data-testid={testId}\n containerRect={containerRect.current}\n targetRect={targetRect.current}\n overlay={overlayRef.current}\n position={position}\n marginX={marginX}\n marginY={marginY}\n keepInContainer={keepInContainer}\n onTransitionEnd={handleTransitionEnd}\n {...rest}\n >\n { children }\n </Styled.Overlay>\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ), [\n as,\n children,\n className,\n containerRect,\n handleTransitionEnd,\n keepInContainer,\n marginX,\n marginY,\n mergedRef,\n position,\n shouldShow,\n style,\n targetRect,\n testId,\n withTransition,\n dummy,\n ])\n\n const overlay = useMemo(() => {\n if (hasContainer) {\n return Content\n }\n\n return (\n <Styled.DefaultContainer\n ref={containerRef}\n className={containerClassName}\n show={show}\n style={containerStyle}\n data-testid={containerTestId}\n >\n <Styled.DefaultWrapper data-testid={wrapperTestId}>\n { Content }\n </Styled.DefaultWrapper>\n </Styled.DefaultContainer>\n )\n }, [\n hasContainer,\n containerClassName,\n show,\n containerStyle,\n containerTestId,\n wrapperTestId,\n Content,\n ])\n\n useEffect(() => {\n handleOverlayForceUpdate()\n }, [\n children,\n handleOverlayForceUpdate,\n ])\n\n /**\n * Case 1: show === true\n * show -> shouldRender -> shouldShow\n * shouldRender 를 true 로 설정하고, 직후에 shouldShow 를 true 로 설정하여 transition 유발\n *\n * Case 2: show === false\n * show -> shouldShow -> (...) -> shouldRender\n * shouldShow 를 false 로 설정하고, shouldRender 는 transition 필요 여부에 따라 다르게 결정함\n * Case 2-1: withTransition === true\n * shouldShow -> onTransitionEnd -> shouldRender\n * onTransitionEnd handler 를 이용해 transition 이 끝난 다음 shouldRender 를 false 로 설정\n * Case 2-2: withTransition === false\n * shouldShow && shouldRender\n * transition 을 기다릴 필요가 없으므로 바로 shouldRender 를 false 로 설정\n */\n useEffect(() => {\n if (show) {\n if (shouldRender) {\n window.requestAnimationFrame(() => setShouldShow(true))\n } else {\n window.requestAnimationFrame(() => setShouldRender(true))\n }\n }\n\n if (!show) {\n window.requestAnimationFrame(() => setShouldShow(false))\n\n if (!withTransition) {\n window.requestAnimationFrame(() => setShouldRender(false))\n }\n }\n }, [\n show,\n withTransition,\n shouldRender,\n shouldShow,\n ])\n\n if (!shouldRender) { return null }\n\n return ReactDOM.createPortal(\n overlay,\n container,\n )\n}\n\nexport default forwardRef(Overlay)\n"],"names":["CONTAINER_TEST_ID","WRAPPER_TEST_ID","OVERLAY_TEST_ID","ESCAPE_KEY","Overlay","as","containerTestId","wrapperTestId","testId","show","className","style","containerClassName","containerStyle","container","givenContainer","target","position","OverlayPosition","LeftCenter","marginX","marginY","keepInContainer","withTransition","enableClickOutside","children","onHide","noop","onTransitionEnd","rest","forwardedRef","shouldRender","setShouldRender","useState","shouldShow","setShouldShow","containerRect","useRef","targetRect","dummy","forceUpdate","useReducer","x","containerRef","overlayRef","mergedRef","useMergeRefs","defaultContainer","getRootElement","modalContainer","useModalContainerContext","hasContainer","Boolean","handleOverlayForceUpdate","useCallback","handleContainerRect","width","containerWidth","height","containerHeight","top","containerTop","left","containerLeft","getBoundingClientRect","current","scrollTop","scrollLeft","useLayoutEffect","initContainerRect","handleTargetRect","targetWidth","targetHeight","targetTop","targetLeft","clientTop","clientLeft","initTargetRect","handleTransitionEnd","event","handleBlockMouseWheel","stopPropagation","handleHideOverlay","closest","Styled","handleKeydown","key","useEventHandler","document","Content","useMemo","React","createElement","Object","assign","ref","overlay","useEffect","window","requestAnimationFrame","ReactDOM","createPortal","forwardRef"],"mappings":";;;;;;;;;;;;;;AAkCO,MAAMA,iBAAiB,GAAG,yBAAwB;AAClD,MAAMC,eAAe,GAAG,uBAAsB;AAC9C,MAAMC,eAAe,GAAG,uBAAsB;AAC9C,MAAMC,UAAU,GAAG,SAAQ;AAElC,SAASC,OAAOA,CACd;EACEC,EAAE;AACFC,EAAAA,eAAe,GAAGN,iBAAiB;AACnCO,EAAAA,aAAa,GAAGN,eAAe;AAC/BO,EAAAA,MAAM,GAAGN,eAAe;AACxBO,EAAAA,IAAI,GAAG,KAAK;AACZC,EAAAA,SAAS,GAAG,EAAE;EACdC,KAAK;AACLC,EAAAA,kBAAkB,GAAG,EAAE;EACvBC,cAAc;AACdC,EAAAA,SAAS,EAAEC,cAAc;EACzBC,MAAM;EACNC,QAAQ,GAAGC,6BAAe,CAACC,UAAU;AACrCC,EAAAA,OAAO,GAAG,CAAC;AACXC,EAAAA,OAAO,GAAG,CAAC;AACXC,EAAAA,eAAe,GAAG,KAAK;AACvBC,EAAAA,cAAc,GAAG,KAAK;AACtBC,EAAAA,kBAAkB,GAAG,KAAK;EAC1BC,QAAQ;AACRC,EAAAA,MAAM,GAAGC,kBAAI;AACbC,EAAAA,eAAe,GAAGD,kBAAI;EACtB,GAAGE,IAAAA;AACS,CAAC,EACfC,YAAiC,EACjC;EACA,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAA;EACvD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGF,cAAQ,CAAC,KAAK,CAAC,CAAA;AAEnD,EAAA,MAAMG,aAAa,GAAGC,YAAM,CAA2B,IAAI,CAAC,CAAA;AAC5D,EAAA,MAAMC,UAAU,GAAGD,YA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ay.types.ts"],"sourcesContent":["import type React from 'react'\n\nimport {\n type AdditionalStylableProps,\n type AdditionalTestIdProps,\n type BezierComponentProps,\n type ChildrenProps,\n} from '~/src/types/ComponentProps'\n\nexport interface ContainerRectAttr {\n containerWidth: number\n containerHeight: number\n containerTop: number\n containerLeft: number\n scrollTop: number\n scrollLeft: number\n}\n\nexport interface TargetRectAttr {\n targetWidth: number\n targetHeight: number\n targetTop: number\n targetLeft: number\n clientTop: number\n clientLeft: number\n}\n\nexport enum OverlayPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n InnerLeftTop = 'innerLeftTop',\n InnerLeftBottom = 'innerLeftBottom',\n InnerRightTop = 'innerRightTop',\n InnerRightBottom = 'innerRightBottom',\n}\n\ninterface OverlayOptions {\n show?: boolean\n container?: HTMLElement | null\n target?: HTMLElement | null\n position?: OverlayPosition\n marginX?: number\n marginY?: number\n keepInContainer?: boolean\n withTransition?: boolean\n enableClickOutside?: boolean\n onHide?: () => void\n}\n\nexport default interface OverlayProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement>,\n AdditionalStylableProps<'container'>,\n AdditionalTestIdProps<['container', 'wrapper']>,\n OverlayOptions {}\n"],"names":["OverlayPosition"],"mappings":";;AA2BYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;EAAfA,eAAe,CAAA,eAAA,CAAA,GAAA,eAAA,CAAA;EAAfA,eAAe,CAAA,kBAAA,CAAA,GAAA,kBAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Overlay.types.js","sources":["../../../../src/components/Overlay/Overlay.types.ts"],"sourcesContent":["import type React from 'react'\n\nimport {\n type AdditionalStylableProps,\n type AdditionalTestIdProps,\n type BezierComponentProps,\n type ChildrenProps,\n} from '~/src/types/ComponentProps'\n\nexport interface ContainerRectAttr {\n containerWidth: number\n containerHeight: number\n containerTop: number\n containerLeft: number\n scrollTop: number\n scrollLeft: number\n}\n\nexport interface TargetRectAttr {\n targetWidth: number\n targetHeight: number\n targetTop: number\n targetLeft: number\n clientTop: number\n clientLeft: number\n}\n\nexport enum OverlayPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n InnerLeftTop = 'innerLeftTop',\n InnerLeftBottom = 'innerLeftBottom',\n InnerRightTop = 'innerRightTop',\n InnerRightBottom = 'innerRightBottom',\n}\n\ninterface OverlayOptions {\n show?: boolean\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n target?: HTMLElement | null\n position?: OverlayPosition\n marginX?: number\n marginY?: number\n keepInContainer?: boolean\n withTransition?: boolean\n enableClickOutside?: boolean\n onHide?: () => void\n}\n\nexport default interface OverlayProps extends\n BezierComponentProps,\n ChildrenProps,\n React.HTMLAttributes<HTMLDivElement>,\n AdditionalStylableProps<'container'>,\n AdditionalTestIdProps<['container', 'wrapper']>,\n OverlayOptions {}\n"],"names":["OverlayPosition"],"mappings":";;AA2BYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,iBAAA,CAAA,GAAA,iBAAA,CAAA;EAAfA,eAAe,CAAA,eAAA,CAAA,GAAA,eAAA,CAAA;EAAfA,eAAe,CAAA,kBAAA,CAAA,GAAA,kBAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var FoundationStyledComponent = require('../../foundation/FoundationStyledComponent.js');
|
|
6
5
|
var Mixins = require('../../foundation/Mixins.js');
|
|
6
|
+
var FoundationStyledComponent = require('../../foundation/FoundationStyledComponent.js');
|
|
7
7
|
|
|
8
8
|
function getMargin({
|
|
9
9
|
margintop,
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var ReactDOM = require('react-dom');
|
|
7
|
+
var useIsMounted = require('../../hooks/useIsMounted.js');
|
|
7
8
|
var domUtils = require('../../utils/domUtils.js');
|
|
8
9
|
var Toast_types = require('./Toast.types.js');
|
|
9
10
|
var ToastContainer = require('./ToastContainer.js');
|
|
@@ -18,6 +19,7 @@ function ToastProvider({
|
|
|
18
19
|
autoDismissTimeout = 3000,
|
|
19
20
|
children = []
|
|
20
21
|
}) {
|
|
22
|
+
const isMounted = useIsMounted.default();
|
|
21
23
|
const toastContextValue = useToastContextValues.default();
|
|
22
24
|
const {
|
|
23
25
|
leftToasts,
|
|
@@ -59,7 +61,7 @@ function ToastProvider({
|
|
|
59
61
|
}))), [autoDismissTimeout, dismiss]);
|
|
60
62
|
return /*#__PURE__*/React.createElement(ToastContext.ToastContextProvider, {
|
|
61
63
|
value: toastContextValue
|
|
62
|
-
}, children, /*#__PURE__*/ReactDOM.createPortal([createContainer(Toast_types.ToastPlacement.BottomLeft, leftToasts), createContainer(Toast_types.ToastPlacement.BottomRight, rightToasts)], domUtils.getRootElement()));
|
|
64
|
+
}, children, isMounted && /*#__PURE__*/ReactDOM.createPortal([createContainer(Toast_types.ToastPlacement.BottomLeft, leftToasts), createContainer(Toast_types.ToastPlacement.BottomRight, rightToasts)], domUtils.getRootElement()));
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
exports.default = ToastProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.js","sources":["../../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["import React, { useCallback } from 'react'\n\nimport { createPortal } from 'react-dom'\n\nimport {\n TransitionDuration,\n css,\n} from '~/src/foundation'\n\nimport { getRootElement } from '~/src/utils/domUtils'\n\nimport {\n ToastPlacement,\n type ToastProviderProps,\n type ToastType,\n} from './Toast.types'\nimport ToastContainer from './ToastContainer'\nimport { ToastContextProvider } from './ToastContext'\nimport ToastController from './ToastController'\nimport ToastElement from './ToastElement'\nimport useToastProviderValues from './useToastContextValues'\n\nfunction ToastProvider({\n autoDismissTimeout = 3000,\n children = [],\n}: ToastProviderProps) {\n const toastContextValue = useToastProviderValues()\n const {\n leftToasts,\n rightToasts,\n dismiss,\n } = toastContextValue\n\n const createContainer = useCallback((placement: ToastPlacement, toasts: ToastType[]) => (\n <ToastContainer\n key={placement}\n placement={placement}\n >\n { toasts.map(({\n autoDismiss,\n content,\n preset,\n appearance,\n icon,\n actionContent,\n onClick,\n id,\n onDismiss,\n zIndex,\n version,\n }) => (\n <ToastController\n key={id}\n placement={placement}\n autoDismiss={autoDismiss ?? true}\n transitionDuration={TransitionDuration.M}\n actionContent={actionContent}\n onClick={onClick}\n autoDismissTimeout={autoDismissTimeout}\n preset={preset}\n appearance={appearance}\n content={content}\n icon={icon}\n component={ToastElement}\n onDismiss={() => dismiss(id, onDismiss)}\n transform={css``}\n zIndex={zIndex}\n version={version}\n />\n )) }\n </ToastContainer>\n ), [\n autoDismissTimeout,\n dismiss,\n ])\n\n return (\n <ToastContextProvider value={toastContextValue}>\n { children }\n { createPortal(\n [\n createContainer(ToastPlacement.BottomLeft, leftToasts),\n createContainer(ToastPlacement.BottomRight, rightToasts),\n ],\n getRootElement(),\n ) }\n </ToastContextProvider>\n )\n}\n\nexport default ToastProvider\n"],"names":["ToastProvider","autoDismissTimeout","children","toastContextValue","useToastProviderValues","leftToasts","rightToasts","dismiss","createContainer","useCallback","placement","toasts","React","createElement","ToastContainer","key","map","autoDismiss","content","preset","appearance","icon","actionContent","onClick","id","onDismiss","zIndex","version","ToastController","transitionDuration","TransitionDuration","M","component","ToastElement","transform","css","ToastContextProvider","value","createPortal","ToastPlacement","BottomLeft","BottomRight","getRootElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ToastProvider.js","sources":["../../../../src/components/Toast/ToastProvider.tsx"],"sourcesContent":["import React, { useCallback } from 'react'\n\nimport { createPortal } from 'react-dom'\n\nimport {\n TransitionDuration,\n css,\n} from '~/src/foundation'\n\nimport useIsMounted from '~/src/hooks/useIsMounted'\nimport { getRootElement } from '~/src/utils/domUtils'\n\nimport {\n ToastPlacement,\n type ToastProviderProps,\n type ToastType,\n} from './Toast.types'\nimport ToastContainer from './ToastContainer'\nimport { ToastContextProvider } from './ToastContext'\nimport ToastController from './ToastController'\nimport ToastElement from './ToastElement'\nimport useToastProviderValues from './useToastContextValues'\n\nfunction ToastProvider({\n autoDismissTimeout = 3000,\n children = [],\n}: ToastProviderProps) {\n const isMounted = useIsMounted()\n\n const toastContextValue = useToastProviderValues()\n const {\n leftToasts,\n rightToasts,\n dismiss,\n } = toastContextValue\n\n const createContainer = useCallback((placement: ToastPlacement, toasts: ToastType[]) => (\n <ToastContainer\n key={placement}\n placement={placement}\n >\n { toasts.map(({\n autoDismiss,\n content,\n preset,\n appearance,\n icon,\n actionContent,\n onClick,\n id,\n onDismiss,\n zIndex,\n version,\n }) => (\n <ToastController\n key={id}\n placement={placement}\n autoDismiss={autoDismiss ?? true}\n transitionDuration={TransitionDuration.M}\n actionContent={actionContent}\n onClick={onClick}\n autoDismissTimeout={autoDismissTimeout}\n preset={preset}\n appearance={appearance}\n content={content}\n icon={icon}\n component={ToastElement}\n onDismiss={() => dismiss(id, onDismiss)}\n transform={css``}\n zIndex={zIndex}\n version={version}\n />\n )) }\n </ToastContainer>\n ), [\n autoDismissTimeout,\n dismiss,\n ])\n\n return (\n <ToastContextProvider value={toastContextValue}>\n { children }\n { isMounted && createPortal(\n [\n createContainer(ToastPlacement.BottomLeft, leftToasts),\n createContainer(ToastPlacement.BottomRight, rightToasts),\n ],\n getRootElement(),\n ) }\n </ToastContextProvider>\n )\n}\n\nexport default ToastProvider\n"],"names":["ToastProvider","autoDismissTimeout","children","isMounted","useIsMounted","toastContextValue","useToastProviderValues","leftToasts","rightToasts","dismiss","createContainer","useCallback","placement","toasts","React","createElement","ToastContainer","key","map","autoDismiss","content","preset","appearance","icon","actionContent","onClick","id","onDismiss","zIndex","version","ToastController","transitionDuration","TransitionDuration","M","component","ToastElement","transform","css","ToastContextProvider","value","createPortal","ToastPlacement","BottomLeft","BottomRight","getRootElement"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,SAASA,aAAaA,CAAC;AACrBC,EAAAA,kBAAkB,GAAG,IAAI;AACzBC,EAAAA,QAAQ,GAAG,EAAA;AACO,CAAC,EAAE;AACrB,EAAA,MAAMC,SAAS,GAAGC,oBAAY,EAAE,CAAA;AAEhC,EAAA,MAAMC,iBAAiB,GAAGC,6BAAsB,EAAE,CAAA;EAClD,MAAM;IACJC,UAAU;IACVC,WAAW;AACXC,IAAAA,OAAAA;AACF,GAAC,GAAGJ,iBAAiB,CAAA;AAErB,EAAA,MAAMK,eAAe,GAAGC,iBAAW,CAAC,CAACC,SAAyB,EAAEC,MAAmB,kBACjFC,KAAA,CAAAC,aAAA,CAACC,sBAAc,EAAA;AACbC,IAAAA,GAAG,EAAEL,SAAU;AACfA,IAAAA,SAAS,EAAEA,SAAAA;AAAU,GAAA,EAEnBC,MAAM,CAACK,GAAG,CAAC,CAAC;IACZC,WAAW;IACXC,OAAO;IAC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js');
|
|
|
7
7
|
var typeUtils = require('../../utils/typeUtils.js');
|
|
8
8
|
var Tooltip_types = require('./Tooltip.types.js');
|
|
9
9
|
var Tooltip_styled = require('./Tooltip.styled.js');
|
|
10
|
+
var ModalContext = require('../Modals/Modal/ModalContext.js');
|
|
10
11
|
|
|
11
12
|
function getSideAndAlign(placement) {
|
|
12
13
|
switch (placement) {
|
|
@@ -143,7 +144,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
|
|
|
143
144
|
icon,
|
|
144
145
|
placement = Tooltip_types.TooltipPosition.BottomCenter,
|
|
145
146
|
offset = 4,
|
|
146
|
-
container
|
|
147
|
+
container: givenContainer,
|
|
147
148
|
keepInContainer = true,
|
|
148
149
|
allowHover,
|
|
149
150
|
delayShow,
|
|
@@ -156,6 +157,9 @@ const Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip({
|
|
|
156
157
|
delayHide: globalDelayHide
|
|
157
158
|
} = useTooltipGlobalContext('Tooltip');
|
|
158
159
|
const delayHide = delayHideProp ?? globalDelayHide;
|
|
160
|
+
const defaultContainer = domUtils.getRootElement();
|
|
161
|
+
const modalContainer = ModalContext.useModalContainerContext();
|
|
162
|
+
const container = givenContainer ?? modalContainer ?? defaultContainer;
|
|
159
163
|
React.useEffect(function cleanUpTimeout() {
|
|
160
164
|
return function cleanUp() {
|
|
161
165
|
if (timeoutRef.current) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { document } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport { isBoolean } from '~/src/utils/typeUtils'\n\nimport {\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n disabled,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container = document.body,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n\n const delayHide = delayHideProp ?? globalDelayHide\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (disabled) { return }\n\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n disabled,\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","Tooltip","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","disabled","content","description","icon","offset","container","document","body","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source"],"mappings":";;;;;;;;;;AAuBA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,6BAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,QAAAA,KAAK,E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EAAAA,EAAAA,IAAI,EACJtD,eAAe,CAACC,SAAS,CAAC,EAAA;IAC9BwE,OAAO,EAAA,IAAA;AACPG,IAAAA,GAAG,EAAErB,YAAa;AAClBsB,IAAAA,UAAU,EAAE7B,MAAO;AACnB8B,IAAAA,eAAe,EAAE1B,eAAgB;AACjC2B,IAAAA,gBAAgB,EAAE,CAAE;IACpBC,gBAAgB,EAAA,IAAA;AAAA,GAAA,CAAA,eAEhBnD,KAAA,CAAAC,aAAA,CAACmD,6BAAqB,EAAA;AAACC,IAAAA,WAAW,EAAE5C,EAAAA;AAAG,GAAA,eACrCT,KAAA,CAAAC,aAAA,CAACmD,4BAAoB,EACnBpD,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACmD,sBAAc,EACXpC,IAAAA,EAAAA,OACY,CAAC,EAEfC,WAAW,iBACXjB,KAAA,CAAAC,aAAA,CAACmD,0BAAkB,QACfnC,WACgB,CAEF,CAAC,EAErBC,IAAI,iBACJlB,KAAA,CAAAC,aAAA,CAACmD,mBAAW,EAAA;AAACE,IAAAA,MAAM,EAAEpC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC;;;;;"}
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["import React, {\n forwardRef,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip'\n\nimport { getRootElement } from '~/src/utils/domUtils'\nimport { createContext } from '~/src/utils/reactUtils'\nimport { isBoolean } from '~/src/utils/typeUtils'\n\nimport { useModalContainerContext } from '~/src/components/Modals'\n\nimport {\n TooltipPosition,\n type TooltipProps,\n type TooltipProviderProps,\n} from './Tooltip.types'\n\nimport * as Styled from './Tooltip.styled'\n\nfunction getSideAndAlign(\n placement: TooltipPosition,\n): Pick<TooltipPrimitive.TooltipContentProps, 'side' | 'align'> {\n switch (placement) {\n case TooltipPosition.TopCenter:\n return {\n side: 'top',\n align: 'center',\n }\n case TooltipPosition.TopLeft:\n return {\n side: 'top',\n align: 'start',\n }\n case TooltipPosition.TopRight:\n return {\n side: 'top',\n align: 'end',\n }\n case TooltipPosition.RightCenter:\n return {\n side: 'right',\n align: 'center',\n }\n case TooltipPosition.RightTop:\n return {\n side: 'right',\n align: 'start',\n }\n case TooltipPosition.RightBottom:\n return {\n side: 'right',\n align: 'end',\n }\n case TooltipPosition.BottomCenter:\n return {\n side: 'bottom',\n align: 'center',\n }\n case TooltipPosition.BottomLeft:\n return {\n side: 'bottom',\n align: 'start',\n }\n case TooltipPosition.BottomRight:\n return {\n side: 'bottom',\n align: 'end',\n }\n case TooltipPosition.LeftCenter:\n return {\n side: 'left',\n align: 'center',\n }\n case TooltipPosition.LeftTop:\n return {\n side: 'left',\n align: 'start',\n }\n case TooltipPosition.LeftBottom:\n return {\n side: 'left',\n align: 'end',\n }\n default:\n // NOTE: should not reach here\n return {\n side: undefined,\n align: undefined,\n }\n }\n}\n\nconst [\n /**\n * NOTE: Custom context use because the radix-ui doesn't support `delayHide`.\n */\n TooltipGlobalContextProvider,\n useTooltipGlobalContext,\n] = createContext<Required<Pick<TooltipProviderProps, 'delayHide'>> | null>(null, 'TooltipProvider')\n\n/**\n * `TooltipProvider` is used to globally provide props to child tooltips.\n *\n * @example\n *\n * ```tsx\n * <TooltipProvider allowHover delayShow={1000}>\n * <Tooltip />\n * </TooltipProvider>\n * ```\n */\nexport function TooltipProvider({\n children,\n allowHover = false,\n delayShow = 300,\n delayHide = 0,\n skipDelayShow = 500,\n}: TooltipProviderProps) {\n const contextValue = useMemo(() => ({\n delayHide,\n }), [delayHide])\n\n return (\n <TooltipPrimitive.Provider\n delayDuration={delayShow}\n skipDelayDuration={skipDelayShow}\n disableHoverableContent={!allowHover}\n >\n <TooltipGlobalContextProvider value={contextValue}>\n { children }\n </TooltipGlobalContextProvider>\n </TooltipPrimitive.Provider>\n )\n}\n\n/**\n * `Tooltip` is a component that shows additional information when the mouse hovers or the keyboard is focused.\n *\n * @example\n *\n * ```tsx\n * // Anatomy of the Tooltip\n * <TooltipProvider>\n * <Tooltip />\n * </TooltipProvider>\n *\n * // Example of a Tooltip with a button\n * <Tooltip content=\"Ta-da!\">\n * <button>Hover me</button>\n * </Tooltip>\n * ```\n */\nexport const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(function Tooltip({\n as,\n children,\n defaultShow,\n onShow: onShowProp,\n onHide: onHideProp,\n disabled,\n content,\n description,\n icon,\n placement = TooltipPosition.BottomCenter,\n offset = 4,\n container: givenContainer,\n keepInContainer = true,\n allowHover,\n delayShow,\n delayHide: delayHideProp,\n ...rest\n}, forwardedRef) {\n const [show, setShow] = useState<boolean>(defaultShow ?? false)\n const timeoutRef = useRef<NodeJS.Timeout>()\n\n const { delayHide: globalDelayHide } = useTooltipGlobalContext('Tooltip')\n const delayHide = delayHideProp ?? globalDelayHide\n\n const defaultContainer = getRootElement()\n const modalContainer = useModalContainerContext()\n const container = givenContainer ?? modalContainer ?? defaultContainer\n\n useEffect(function cleanUpTimeout() {\n return function cleanUp() {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n const onShow = useCallback(() => {\n setShow(true)\n onShowProp?.()\n }, [onShowProp])\n\n const onHide = useCallback(() => {\n setShow(false)\n onHideProp?.()\n }, [onHideProp])\n\n const onOpenChange = useCallback((open: boolean) => {\n if (disabled) { return }\n\n if (open) {\n onShow()\n return\n }\n\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current)\n timeoutRef.current = undefined\n }\n\n if (delayHide > 0) {\n timeoutRef.current = setTimeout(() => {\n onHide()\n }, delayHide)\n return\n }\n\n onHide()\n }, [\n disabled,\n delayHide,\n onShow,\n onHide,\n ])\n\n return (\n <TooltipPrimitive.Root\n open={show}\n defaultOpen={defaultShow}\n delayDuration={delayShow}\n disableHoverableContent={isBoolean(allowHover) ? !allowHover : undefined}\n onOpenChange={onOpenChange}\n >\n <TooltipPrimitive.Trigger asChild>\n { children }\n </TooltipPrimitive.Trigger>\n\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n {...rest}\n {...getSideAndAlign(placement)}\n asChild\n ref={forwardedRef}\n sideOffset={offset}\n avoidCollisions={keepInContainer}\n collisionPadding={8}\n hideWhenDetached\n >\n <Styled.TooltipContent forwardedAs={as}>\n <Styled.TextContainer>\n <Styled.Content>\n { content }\n </Styled.Content>\n\n { description && (\n <Styled.Description>\n { description }\n </Styled.Description>\n ) }\n </Styled.TextContainer>\n\n { icon && (\n <Styled.Icon source={icon} />\n ) }\n </Styled.TooltipContent>\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n </TooltipPrimitive.Root>\n )\n})\n"],"names":["getSideAndAlign","placement","TooltipPosition","TopCenter","side","align","TopLeft","TopRight","RightCenter","RightTop","RightBottom","BottomCenter","BottomLeft","BottomRight","LeftCenter","LeftTop","LeftBottom","undefined","TooltipGlobalContextProvider","useTooltipGlobalContext","createContext","TooltipProvider","children","allowHover","delayShow","delayHide","skipDelayShow","contextValue","useMemo","React","createElement","TooltipPrimitive","delayDuration","skipDelayDuration","disableHoverableContent","value","Tooltip","forwardRef","as","defaultShow","onShow","onShowProp","onHide","onHideProp","disabled","content","description","icon","offset","container","givenContainer","keepInContainer","delayHideProp","rest","forwardedRef","show","setShow","useState","timeoutRef","useRef","globalDelayHide","defaultContainer","getRootElement","modalContainer","useModalContainerContext","useEffect","cleanUpTimeout","cleanUp","current","clearTimeout","useCallback","onOpenChange","open","setTimeout","defaultOpen","isBoolean","asChild","Object","assign","ref","sideOffset","avoidCollisions","collisionPadding","hideWhenDetached","Styled","forwardedAs","source"],"mappings":";;;;;;;;;;;AAyBA,SAASA,eAAeA,CACtBC,SAA0B,EACoC;AAC9D,EAAA,QAAQA,SAAS;IACf,KAAKC,6BAAe,CAACC,SAAS;MAC5B,OAAO;AACLC,QAAAA,IAAI,EAAE,KAAK;AACXC,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AAAA,QACsB,CAAC,eAE3BO,KAAA,CAAAC,aAAA,CAACC,YAAuB,EAAA;AAACkB,IAAAA,SAAS,EAAEA,SAAAA;AAAU,GAAA,eAC5CpB,KAAA,CAAAC,aAAA,CAACC,aAAwB,EAAA8C,MAAA,CAAAC,MAAA,CACnBzB,EAAAA,EAAAA,IAAI,EACJrD,eAAe,CAACC,SAAS,CAAC,EAAA;IAC9B2E,OAAO,EAAA,IAAA;AACPG,IAAAA,GAAG,EAAEzB,YAAa;AAClB0B,IAAAA,UAAU,EAAEhC,MAAO;AACnBiC,IAAAA,eAAe,EAAE9B,eAAgB;AACjC+B,IAAAA,gBAAgB,EAAE,CAAE;IACpBC,gBAAgB,EAAA,IAAA;AAAA,GAAA,CAAA,eAEhBtD,KAAA,CAAAC,aAAA,CAACsD,6BAAqB,EAAA;AAACC,IAAAA,WAAW,EAAE/C,EAAAA;AAAG,GAAA,eACrCT,KAAA,CAAAC,aAAA,CAACsD,4BAAoB,EACnBvD,IAAAA,eAAAA,KAAA,CAAAC,aAAA,CAACsD,sBAAc,EACXvC,IAAAA,EAAAA,OACY,CAAC,EAEfC,WAAW,iBACXjB,KAAA,CAAAC,aAAA,CAACsD,0BAAkB,QACftC,WACgB,CAEF,CAAC,EAErBC,IAAI,iBACJlB,KAAA,CAAAC,aAAA,CAACsD,mBAAW,EAAA;AAACE,IAAAA,MAAM,EAAEvC,IAAAA;AAAK,GAAE,CAET,CACC,CACH,CACJ,CAAC,CAAA;AAE5B,CAAC;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.types.js","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n DisableProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n"],"names":["TooltipPosition"],"mappings":";;AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Tooltip.types.js","sources":["../../../../src/components/Tooltip/Tooltip.types.ts"],"sourcesContent":["import { type BezierIcon } from '@channel.io/bezier-icons'\n\nimport {\n type BezierComponentProps,\n type ChildrenProps,\n type ContentProps,\n type DisableProps,\n} from '~/src/types/ComponentProps'\n\n/**\n * An enumeration that determines the position of `Tooltip`.\n */\nexport enum TooltipPosition {\n TopCenter = 'topCenter',\n TopLeft = 'topLeft',\n TopRight = 'topRight',\n RightCenter = 'rightCenter',\n RightTop = 'rightTop',\n RightBottom = 'rightBottom',\n BottomCenter = 'bottomCenter',\n BottomLeft = 'bottomLeft',\n BottomRight = 'bottomRight',\n LeftCenter = 'leftCenter',\n LeftTop = 'leftTop',\n LeftBottom = 'leftBottom',\n}\n\ninterface TooltipProviderOptions {\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * @default 0\n */\n delayHide?: number\n /**\n * How much time a user has to enter another trigger without incurring a delay again.\n * @default 500\n */\n skipDelayShow?: number\n}\n\ninterface TooltipOptions {\n /**\n * The open state of the tooltip when it is initially rendered.\n */\n defaultShow?: boolean\n /**\n * An element that sits below the tooltip content.\n */\n description?: React.ReactNode\n /**\n * A decorative icon that sits right of the tooltip content.\n */\n icon?: BezierIcon\n /**\n * Options to determine the location from the trigger.\n * @default TooltipPosition.BottomCenter\n */\n placement?: TooltipPosition\n /**\n * The distance in pixels from the trigger.\n * @default 4\n */\n offset?: number\n /**\n * Specify a container element to portal the content into.\n * @note When placed inside a `Modal`, default value is the container element of `Modal`.\n * @default document.body\n */\n container?: HTMLElement | null\n /**\n * When `true`, overrides the `position` of the tooltip\n * to prevent collisions with boundary edges.\n * @default true\n */\n keepInContainer?: boolean\n /**\n * Keeps the content of the tooltip open on hover. Disabling this feature affects accessibility.\n * Inherits from the nearest `TooltipProvider`.\n * @default false\n */\n allowHover?: boolean\n /**\n * The delay from when the mouse enters a tooltip trigger until the tooltip opens.\n * Inherits from the nearest `TooltipProvider`.\n * @default 300\n */\n delayShow?: number\n /**\n * The delay from when the mouse leaves a tooltip content until the tooltip hides.\n * Inherits from the nearest `TooltipProvider`.\n * @default 0\n */\n delayHide?: number\n /**\n * Callback function to be called when the tooltip is opened.\n */\n onShow?: () => void\n /**\n * Callback function to be called when the tooltip is closed.\n */\n onHide?: () => void\n /**\n * Event handler called when the escape key is down.\n * It can be prevented by calling `event.preventDefault`.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Event handler called when a pointer event occurs outside the bounds of the component.\n * It can be prevented by calling `event.preventDefault`.\n */\n onPointerDownOutside?: (event: CustomEvent<{ originalEvent: PointerEvent }>) => void\n}\n\nexport interface TooltipProviderProps extends\n ChildrenProps,\n TooltipProviderOptions {}\n\nexport interface TooltipProps extends\n BezierComponentProps,\n ChildrenProps<React.ReactElement>,\n ContentProps,\n DisableProps,\n Omit<React.HTMLAttributes<HTMLDivElement>, keyof ContentProps | keyof ChildrenProps>,\n TooltipOptions {}\n"],"names":["TooltipPosition"],"mappings":";;AASA;AACA;AACA;AACYA,IAAAA,eAAe,0BAAfA,eAAe,EAAA;EAAfA,eAAe,CAAA,WAAA,CAAA,GAAA,WAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,UAAA,CAAA,GAAA,UAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,cAAA,CAAA,GAAA,cAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,aAAA,CAAA,GAAA,aAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;EAAfA,eAAe,CAAA,SAAA,CAAA,GAAA,SAAA,CAAA;EAAfA,eAAe,CAAA,YAAA,CAAA,GAAA,YAAA,CAAA;AAAA,EAAA,OAAfA,eAAe,CAAA;AAAA,CAAA,CAAA,EAAA;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function useIsMounted() {
|
|
8
|
+
const [isMounted, setIsMounted] = React.useState(false);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
setIsMounted(true);
|
|
11
|
+
}, []);
|
|
12
|
+
return isMounted;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.default = useIsMounted;
|
|
16
|
+
//# sourceMappingURL=useIsMounted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsMounted.js","sources":["../../../src/hooks/useIsMounted.ts"],"sourcesContent":["import {\n useEffect,\n useState,\n} from 'react'\n\nexport default function useIsMounted() {\n const [isMounted, setIsMounted] = useState(false)\n\n useEffect(() => {\n setIsMounted(true)\n }, [])\n\n return isMounted\n}\n"],"names":["useIsMounted","isMounted","setIsMounted","useState","useEffect"],"mappings":";;;;;;AAKe,SAASA,YAAYA,GAAG;EACrC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAA;AAEjDC,EAAAA,eAAS,CAAC,MAAM;IACdF,YAAY,CAAC,IAAI,CAAC,CAAA;GACnB,EAAE,EAAE,CAAC,CAAA;AAEN,EAAA,OAAOD,SAAS,CAAA;AAClB;;;;"}
|