@sproutsocial/seeds-react-modal 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +6 -0
- package/dist/esm/index.js +14 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -8
- package/dist/index.d.ts +1 -8
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/Modal.stories.tsx +2 -5
- package/src/Modal.tsx +12 -13
package/.turbo/turbo-build.log
CHANGED
|
@@ -8,14 +8,14 @@ CLI Target: es2022
|
|
|
8
8
|
CLI Cleaning output folder
|
|
9
9
|
CJS Build start
|
|
10
10
|
ESM Build start
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
ESM dist/esm/index.js 7.18 KB
|
|
12
|
+
ESM dist/esm/index.js.map 14.55 KB
|
|
13
|
+
ESM ⚡️ Build success in 145ms
|
|
14
|
+
CJS dist/index.js 9.96 KB
|
|
15
|
+
CJS dist/index.js.map 14.76 KB
|
|
16
|
+
CJS ⚡️ Build success in 145ms
|
|
17
17
|
DTS Build start
|
|
18
|
-
DTS ⚡️ Build success in
|
|
19
|
-
DTS dist/index.d.ts 2.
|
|
20
|
-
DTS dist/index.d.mts 2.
|
|
21
|
-
Done in 18.
|
|
18
|
+
DTS ⚡️ Build success in 14377ms
|
|
19
|
+
DTS dist/index.d.ts 2.51 KB
|
|
20
|
+
DTS dist/index.d.mts 2.51 KB
|
|
21
|
+
Done in 18.80s.
|
package/CHANGELOG.md
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -144,10 +144,18 @@ var ModalCloseButton = (props) => {
|
|
|
144
144
|
if (!onClose) return null;
|
|
145
145
|
return /* @__PURE__ */ jsx2(Button, { onClick: onClose, ...props, children: /* @__PURE__ */ jsx2(Icon, { name: "x-outline", ariaLabel: closeButtonLabel }) });
|
|
146
146
|
};
|
|
147
|
-
var ModalFooter = (
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
147
|
+
var ModalFooter = ({
|
|
148
|
+
bg = "container.background.base",
|
|
149
|
+
...rest
|
|
150
|
+
}) => /* @__PURE__ */ jsx2(
|
|
151
|
+
Footer,
|
|
152
|
+
{
|
|
153
|
+
bg,
|
|
154
|
+
borderTop: 500,
|
|
155
|
+
borderColor: "container.border.base",
|
|
156
|
+
...rest
|
|
157
|
+
}
|
|
158
|
+
);
|
|
151
159
|
var ModalContent = React2.forwardRef(
|
|
152
160
|
({ children, ...rest }, ref) => {
|
|
153
161
|
const { label } = useContext(ModalContext);
|
|
@@ -162,8 +170,8 @@ var Modal = (props) => {
|
|
|
162
170
|
label,
|
|
163
171
|
onClose,
|
|
164
172
|
closeButtonLabel,
|
|
165
|
-
width: width2,
|
|
166
|
-
zIndex: zIndex2,
|
|
173
|
+
width: width2 = "800px",
|
|
174
|
+
zIndex: zIndex2 = 6,
|
|
167
175
|
data = {},
|
|
168
176
|
...rest
|
|
169
177
|
} = props;
|
|
@@ -209,10 +217,6 @@ var Modal = (props) => {
|
|
|
209
217
|
}
|
|
210
218
|
);
|
|
211
219
|
};
|
|
212
|
-
Modal.defaultProps = {
|
|
213
|
-
width: "800px",
|
|
214
|
-
zIndex: 6
|
|
215
|
-
};
|
|
216
220
|
ModalHeader.displayName = "Modal.Header";
|
|
217
221
|
ModalFooter.displayName = "Modal.Footer";
|
|
218
222
|
ModalContent.displayName = "Modal.Content";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Modal.tsx","../../src/styles.tsx","../../src/ModalTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useContext } from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Container, Content, Header, Footer, Body } from \"./styles\";\nimport type {\n TypeModalProps,\n TypeModalCloseButtonProps,\n TypeModalContentProps,\n TypeModalFooterProps,\n TypeModalHeaderProps,\n} from \"./ModalTypes\";\n\ntype TypeModalContext = Partial<{\n onClose: () => void;\n closeButtonLabel: string;\n label: string;\n}>;\n\nconst ModalContext = React.createContext<TypeModalContext>({});\n\nconst ModalHeader = (props: TypeModalHeaderProps) => {\n const { title, subtitle, children, bordered, ...rest } = props;\n return (\n <Header bordered={title || subtitle || bordered} {...rest}>\n {children ? (\n children\n ) : (\n <React.Fragment>\n <Box>\n {title && (\n <Text as=\"h1\" fontSize={400} fontWeight=\"semibold\">\n {title}\n </Text>\n )}\n {subtitle && (\n <Text as=\"div\" fontSize={200}>\n {subtitle}\n </Text>\n )}\n </Box>\n <Box display=\"flex\" alignItems=\"center\" justify-content=\"flex-end\">\n <ModalCloseButton ml={400} />\n </Box>\n </React.Fragment>\n )}\n </Header>\n );\n};\n\nconst ModalCloseButton = (props: TypeModalCloseButtonProps) => {\n const { onClose, closeButtonLabel } = useContext(ModalContext);\n if (!onClose) return null;\n return (\n <Button onClick={onClose} {...props}>\n <Icon name=\"x-outline\" ariaLabel={closeButtonLabel} />\n </Button>\n );\n};\n\nconst ModalFooter = (props: TypeModalFooterProps) => (\n <Footer borderTop={500} borderColor=\"container.border.base\" {...props} />\n);\n\nModalFooter.defaultProps = {\n bg: \"container.background.base\",\n};\n\nconst ModalContent = React.forwardRef(\n ({ children, ...rest }: TypeModalContentProps, ref) => {\n const { label } = useContext(ModalContext);\n return (\n <Content data-qa-modal data-qa-label={label} ref={ref} {...rest}>\n {children}\n </Content>\n );\n }\n);\n\n/**\n * The modal you want\n */\nconst Modal = (props: TypeModalProps) => {\n const {\n appElementSelector,\n children,\n isOpen,\n label,\n onClose,\n closeButtonLabel,\n width,\n zIndex,\n data = {},\n ...rest\n } = props;\n\n const isCloseable = Boolean(onClose);\n const appElement =\n appElementSelector && document\n ? (document.querySelector(appElementSelector) as HTMLElement)\n : undefined;\n\n return (\n <Container\n appElement={appElement}\n ariaHideApp={!!appElement}\n isOpen={isOpen}\n contentLabel={label}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onRequestClose={onClose || (() => {})}\n shouldFocusAfterRender={true}\n shouldCloseOnOverlayClick={isCloseable}\n shouldCloseOnEsc={isCloseable}\n shouldReturnFocusAfterClose={true}\n closeTimeoutMS={200}\n role=\"dialog\"\n width={width}\n zIndex={zIndex}\n data={{\n \"qa-modal\": \"\",\n \"qa-modal-isopen\": isOpen,\n ...data,\n }}\n {...rest}\n >\n <React.Fragment>\n <Body />\n\n <ModalContext.Provider\n value={{\n onClose,\n closeButtonLabel,\n label,\n }}\n >\n {children}\n </ModalContext.Provider>\n </React.Fragment>\n </Container>\n );\n};\n\nModal.defaultProps = {\n width: \"800px\",\n zIndex: 6,\n};\n\nModalHeader.displayName = \"Modal.Header\";\nModalFooter.displayName = \"Modal.Footer\";\nModalContent.displayName = \"Modal.Content\";\nModalCloseButton.displayName = \"Modal.CloseButton\";\n\nModal.Header = ModalHeader;\nModal.Footer = ModalFooter;\nModal.Content = ModalContent;\nModal.CloseButton = ModalCloseButton;\n\nexport default Modal;\n","import React from \"react\";\nimport styled, { createGlobalStyle } from \"styled-components\";\nimport { width, zIndex } from \"styled-system\";\nimport ReactModal from \"react-modal\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport Box, { type TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\n\n// This is the max space allowed between the modal and the edge of the browser\nconst BODY_PADDING = \"64px\";\n\nconst ReactModalAdapter = ({\n className = \"\",\n ...props\n}: { className?: string } & Omit<\n ReactModal.Props,\n \"portalClassName\" | \"className\" | \"overlayClassName\"\n>) => {\n // We want to create *__Content and *__Overlay class names on the subcomponents.\n // Because `className` could be a space-separated list of class names, we make\n // sure that we append `__Content` and `__Overlay` to every class name.\n const contentClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Content`)\n .join(\" \");\n\n const overlayClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Overlay`)\n .join(\" \");\n\n return (\n <ReactModal\n portalClassName={className}\n className={contentClassName}\n overlayClassName={overlayClassName}\n {...props}\n />\n );\n};\n\nexport const Body = createGlobalStyle`\n .ReactModal__Body--open {\n overflow: hidden;\n }\n`;\n\nexport const Container = styled(ReactModalAdapter)<TypeContainerProps>`\n &__Overlay {\n position: fixed;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ${(props) => props.theme.colors.overlay.background.base};\n opacity: 0;\n will-change: opacity;\n transition: opacity ${(props) => props.theme.duration.medium}\n ${(props) => props.theme.easing.ease_inout};\n\n ${zIndex}\n\n &.ReactModal__Overlay--after-open {\n opacity: 1;\n }\n &.ReactModal__Overlay--before-close {\n opacity: 0;\n }\n }\n\n &__Content {\n display: flex;\n flex-direction: column;\n background: ${(props) => props.theme.colors.container.background.base};\n border-radius: ${(props) => props.theme.radii[600]};\n box-shadow: ${(props) => props.theme.shadows.medium};\n filter: blur(0);\n color: ${(props) => props.theme.colors.text.body};\n\n outline: none;\n max-width: calc(100vw - ${BODY_PADDING});\n max-height: calc(100vh - ${BODY_PADDING});\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /**\n * This prevents the modal from being very short in IE11. Better too big\n * than too small.\n */\n height: calc(100vh - ${BODY_PADDING});\n }\n\n ${width}\n\n ${COMMON}\n }\n`;\n\nexport const Content = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n min-height: 80px;\n overflow-y: auto;\n flex: 1 1 auto;\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /* 'flex-basis: auto' breaks overflow in IE11 */\n flex-basis: 100%;\n }\n`;\n\nexport const HeaderContainer = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n`;\n\nexport const Header = styled(HeaderContainer)<{ bordered?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 0 0 auto;\n border-bottom-width: ${(props) => props.theme.borderWidths[500]};\n border-bottom-color: ${(props) =>\n props.bordered ? props.theme.colors.container.border.base : \"transparent\"};\n border-bottom-style: solid;\n`;\n\nexport const Footer = styled(Box)`\n flex: 0 0 auto;\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n border-bottom-right-radius: ${(props) => props.theme.radii[500]};\n border-bottom-left-radius: ${(props) => props.theme.radii[500]};\n`;\n\nContainer.displayName = \"ModalContainer\";\nContent.displayName = \"Content\";\nHeader.displayName = \"Modal.Header\";\nFooter.displayName = \"Modal.Footer\";\n","import * as React from \"react\";\nimport ReactModal from \"react-modal\";\nimport type {\n TypeBoxProps,\n TypeContainerProps,\n} from \"@sproutsocial/seeds-react-box\";\nimport type { TypeButtonProps } from \"@sproutsocial/seeds-react-button\";\n\nexport interface TypeModalCloseButtonProps\n extends Omit<TypeButtonProps, \"children\"> {\n children?: void | null;\n}\n\nexport interface TypeModalHeaderProps extends TypeBoxProps {\n title?: string;\n subtitle?: string;\n\n /** Passing children will override the default modal header */\n children?: React.ReactNode;\n\n /** If you're rendering a custom header, you can use this prop to add a bottom border */\n bordered?: boolean;\n}\n\nexport interface TypeModalFooterProps extends TypeBoxProps {\n bg?: string;\n children: React.ReactNode;\n}\n\nexport interface TypeModalContentProps extends TypeBoxProps {\n children?: React.ReactNode;\n}\n\nexport interface TypeModalProps\n extends TypeContainerProps,\n // @ts-notes - onClose is an alias for onRequestClose so we don't need to include it here\n Omit<ReactModal.Props, keyof TypeContainerProps | \"onRequestClose\"> {\n /** section of app to aria hide for the modal */\n appElementSelector?: string;\n\n /** trigger to open or close the modal */\n isOpen: boolean;\n\n /** label for screen readers to announce the modal */\n label: string;\n\n /** body content of the modal */\n children: React.ReactNode;\n\n /** callback for close */\n onClose?: () => void;\n\n /** aria-label for modal X */\n closeButtonLabel: string;\n\n /** Controls the z-index CSS property */\n zIndex?: number;\n\n /** The max width of the modal container */\n width?: string | number;\n\n /**\n * Custom attributes to be added to the modals container\n * Each key will be prepended with \"data-\" when rendered in the DOM\n */\n data?: Record<string, string | boolean | number>;\n}\n","import Modal from \"./Modal\";\n\nexport default Modal;\nexport { Modal };\nexport * from \"./ModalTypes\";\n"],"mappings":";AAAA,YAAYA,YAAW;AACvB,SAAS,kBAAkB;AAC3B,OAAOC,UAAS;AAChB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,UAAU;;;ACLjB,OAAkB;AAClB,OAAO,UAAU,yBAAyB;AAC1C,SAAS,OAAO,cAAc;AAC9B,OAAO,gBAAgB;AACvB,SAAS,cAAc;AACvB,OAAO,SAAsC;AA0BzC;AAvBJ,IAAM,eAAe;AAErB,IAAM,oBAAoB,CAAC;AAAA,EACzB,YAAY;AAAA,EACZ,GAAG;AACL,MAGM;AAIJ,QAAM,mBAAmB,UACtB,MAAM,GAAG,EACT,IAAI,CAACC,eAAc,GAAGA,UAAS,IAAIA,UAAS,WAAW,EACvD,KAAK,GAAG;AAEX,QAAM,mBAAmB,UACtB,MAAM,GAAG,EACT,IAAI,CAACA,eAAc,GAAGA,UAAS,IAAIA,UAAS,WAAW,EACvD,KAAK,GAAG;AAEX,SACE;AAAA,IAAC;AAAA;AAAA,MACC,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,IAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAMb,IAAM,YAAY,OAAO,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAUzB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ,WAAW,IAAI;AAAA;AAAA;AAAA,0BA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AAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AACV;AAEA,YAAY,cAAc;AAC1B,YAAY,cAAc;AAC1B,aAAa,cAAc;AAC3B,iBAAiB,cAAc;AAE/B,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,cAAc;AAEpB,IAAO,gBAAQ;;;AE/Jf,OAAuB;AACvB,OAAuB;;;ACCvB,IAAO,gBAAQ;","names":["React","Box","className","jsx","Box","width","zIndex"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Modal.tsx","../../src/styles.tsx","../../src/ModalTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { useContext } from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Container, Content, Header, Footer, Body } from \"./styles\";\nimport type {\n TypeModalProps,\n TypeModalCloseButtonProps,\n TypeModalContentProps,\n TypeModalFooterProps,\n TypeModalHeaderProps,\n} from \"./ModalTypes\";\n\ntype TypeModalContext = Partial<{\n onClose: () => void;\n closeButtonLabel: string;\n label: string;\n}>;\n\nconst ModalContext = React.createContext<TypeModalContext>({});\n\nconst ModalHeader = (props: TypeModalHeaderProps) => {\n const { title, subtitle, children, bordered, ...rest } = props;\n return (\n <Header bordered={title || subtitle || bordered} {...rest}>\n {children ? (\n children\n ) : (\n <React.Fragment>\n <Box>\n {title && (\n <Text as=\"h1\" fontSize={400} fontWeight=\"semibold\">\n {title}\n </Text>\n )}\n {subtitle && (\n <Text as=\"div\" fontSize={200}>\n {subtitle}\n </Text>\n )}\n </Box>\n <Box display=\"flex\" alignItems=\"center\" justify-content=\"flex-end\">\n <ModalCloseButton ml={400} />\n </Box>\n </React.Fragment>\n )}\n </Header>\n );\n};\n\nconst ModalCloseButton = (props: TypeModalCloseButtonProps) => {\n const { onClose, closeButtonLabel } = useContext(ModalContext);\n if (!onClose) return null;\n return (\n <Button onClick={onClose} {...props}>\n <Icon name=\"x-outline\" ariaLabel={closeButtonLabel} />\n </Button>\n );\n};\n\nconst ModalFooter = ({\n bg = \"container.background.base\",\n ...rest\n}: TypeModalFooterProps) => (\n <Footer\n bg={bg}\n borderTop={500}\n borderColor=\"container.border.base\"\n {...rest}\n />\n);\n\nconst ModalContent = React.forwardRef(\n ({ children, ...rest }: TypeModalContentProps, ref) => {\n const { label } = useContext(ModalContext);\n return (\n <Content data-qa-modal data-qa-label={label} ref={ref} {...rest}>\n {children}\n </Content>\n );\n }\n);\n\n/**\n * The modal you want\n */\nconst Modal = (props: TypeModalProps) => {\n const {\n appElementSelector,\n children,\n isOpen,\n label,\n onClose,\n closeButtonLabel,\n width = \"800px\",\n zIndex = 6,\n data = {},\n ...rest\n } = props;\n\n const isCloseable = Boolean(onClose);\n const appElement =\n appElementSelector && document\n ? (document.querySelector(appElementSelector) as HTMLElement)\n : undefined;\n\n return (\n <Container\n appElement={appElement}\n ariaHideApp={!!appElement}\n isOpen={isOpen}\n contentLabel={label}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onRequestClose={onClose || (() => {})}\n shouldFocusAfterRender={true}\n shouldCloseOnOverlayClick={isCloseable}\n shouldCloseOnEsc={isCloseable}\n shouldReturnFocusAfterClose={true}\n closeTimeoutMS={200}\n role=\"dialog\"\n width={width}\n zIndex={zIndex}\n data={{\n \"qa-modal\": \"\",\n \"qa-modal-isopen\": isOpen,\n ...data,\n }}\n {...rest}\n >\n <React.Fragment>\n <Body />\n\n <ModalContext.Provider\n value={{\n onClose,\n closeButtonLabel,\n label,\n }}\n >\n {children}\n </ModalContext.Provider>\n </React.Fragment>\n </Container>\n );\n};\n\nModalHeader.displayName = \"Modal.Header\";\nModalFooter.displayName = \"Modal.Footer\";\nModalContent.displayName = \"Modal.Content\";\nModalCloseButton.displayName = \"Modal.CloseButton\";\n\nModal.Header = ModalHeader;\nModal.Footer = ModalFooter;\nModal.Content = ModalContent;\nModal.CloseButton = ModalCloseButton;\n\nexport default Modal;\n","import React from \"react\";\nimport styled, { createGlobalStyle } from \"styled-components\";\nimport { width, zIndex } from \"styled-system\";\nimport ReactModal from \"react-modal\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport Box, { type TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\n\n// This is the max space allowed between the modal and the edge of the browser\nconst BODY_PADDING = \"64px\";\n\nconst ReactModalAdapter = ({\n className = \"\",\n ...props\n}: { className?: string } & Omit<\n ReactModal.Props,\n \"portalClassName\" | \"className\" | \"overlayClassName\"\n>) => {\n // We want to create *__Content and *__Overlay class names on the subcomponents.\n // Because `className` could be a space-separated list of class names, we make\n // sure that we append `__Content` and `__Overlay` to every class name.\n const contentClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Content`)\n .join(\" \");\n\n const overlayClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Overlay`)\n .join(\" \");\n\n return (\n <ReactModal\n portalClassName={className}\n className={contentClassName}\n overlayClassName={overlayClassName}\n {...props}\n />\n );\n};\n\nexport const Body = createGlobalStyle`\n .ReactModal__Body--open {\n overflow: hidden;\n }\n`;\n\nexport const Container = styled(ReactModalAdapter)<TypeContainerProps>`\n &__Overlay {\n position: fixed;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ${(props) => props.theme.colors.overlay.background.base};\n opacity: 0;\n will-change: opacity;\n transition: opacity ${(props) => props.theme.duration.medium}\n ${(props) => props.theme.easing.ease_inout};\n\n ${zIndex}\n\n &.ReactModal__Overlay--after-open {\n opacity: 1;\n }\n &.ReactModal__Overlay--before-close {\n opacity: 0;\n }\n }\n\n &__Content {\n display: flex;\n flex-direction: column;\n background: ${(props) => props.theme.colors.container.background.base};\n border-radius: ${(props) => props.theme.radii[600]};\n box-shadow: ${(props) => props.theme.shadows.medium};\n filter: blur(0);\n color: ${(props) => props.theme.colors.text.body};\n\n outline: none;\n max-width: calc(100vw - ${BODY_PADDING});\n max-height: calc(100vh - ${BODY_PADDING});\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /**\n * This prevents the modal from being very short in IE11. Better too big\n * than too small.\n */\n height: calc(100vh - ${BODY_PADDING});\n }\n\n ${width}\n\n ${COMMON}\n }\n`;\n\nexport const Content = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n min-height: 80px;\n overflow-y: auto;\n flex: 1 1 auto;\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /* 'flex-basis: auto' breaks overflow in IE11 */\n flex-basis: 100%;\n }\n`;\n\nexport const HeaderContainer = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n`;\n\nexport const Header = styled(HeaderContainer)<{ bordered?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 0 0 auto;\n border-bottom-width: ${(props) => props.theme.borderWidths[500]};\n border-bottom-color: ${(props) =>\n props.bordered ? props.theme.colors.container.border.base : \"transparent\"};\n border-bottom-style: solid;\n`;\n\nexport const Footer = styled(Box)`\n flex: 0 0 auto;\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n border-bottom-right-radius: ${(props) => props.theme.radii[500]};\n border-bottom-left-radius: ${(props) => props.theme.radii[500]};\n`;\n\nContainer.displayName = \"ModalContainer\";\nContent.displayName = \"Content\";\nHeader.displayName = \"Modal.Header\";\nFooter.displayName = \"Modal.Footer\";\n","import * as React from \"react\";\nimport ReactModal from \"react-modal\";\nimport type {\n TypeBoxProps,\n TypeContainerProps,\n} from \"@sproutsocial/seeds-react-box\";\nimport type { TypeButtonProps } from \"@sproutsocial/seeds-react-button\";\n\nexport interface TypeModalCloseButtonProps\n extends Omit<TypeButtonProps, \"children\"> {\n children?: void | null;\n}\n\nexport interface TypeModalHeaderProps extends TypeBoxProps {\n title?: string;\n subtitle?: string;\n\n /** Passing children will override the default modal header */\n children?: React.ReactNode;\n\n /** If you're rendering a custom header, you can use this prop to add a bottom border */\n bordered?: boolean;\n}\n\nexport interface TypeModalFooterProps extends TypeBoxProps {\n bg?: string;\n children: React.ReactNode;\n}\n\nexport interface TypeModalContentProps extends TypeBoxProps {\n children?: React.ReactNode;\n}\n\nexport interface TypeModalProps\n extends TypeContainerProps,\n // @ts-notes - onClose is an alias for onRequestClose so we don't need to include it here\n Omit<ReactModal.Props, keyof TypeContainerProps | \"onRequestClose\"> {\n /** section of app to aria hide for the modal */\n appElementSelector?: string;\n\n /** trigger to open or close the modal */\n isOpen: boolean;\n\n /** label for screen readers to announce the modal */\n label: string;\n\n /** body content of the modal */\n children: React.ReactNode;\n\n /** callback for close */\n onClose?: () => void;\n\n /** aria-label for modal X */\n closeButtonLabel: string;\n\n /** Controls the z-index CSS property */\n zIndex?: number;\n\n /** The max width of the modal container */\n width?: string | number;\n\n /**\n * Custom attributes to be added to the modals container\n * Each key will be prepended with \"data-\" when rendered in the DOM\n */\n data?: Record<string, string | boolean | number>;\n}\n","import Modal from \"./Modal\";\n\nexport default Modal;\nexport { Modal };\nexport * from \"./ModalTypes\";\n"],"mappings":";AAAA,YAAYA,YAAW;AACvB,SAAS,kBAAkB;AAC3B,OAAOC,UAAS;AAChB,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,OAAO,UAAU;;;ACLjB,OAAkB;AAClB,OAAO,UAAU,yBAAyB;AAC1C,SAAS,OAAO,cAAc;AAC9B,OAAO,gBAAgB;AACvB,SAAS,cAAc;AACvB,OAAO,SAAsC;AA0BzC;AAvBJ,IAAM,eAAe;AAErB,IAAM,oBAAoB,CAAC;AAAA,EACzB,YAAY;AAAA,EACZ,GAAG;AACL,MAGM;AAIJ,QAAM,mBAAmB,UACtB,MAAM,GAAG,EACT,IAAI,CAACC,e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Ac;AAAA,MAEd,gBAAgB,YAAY,MAAM;AAAA,MAAC;AAAA,MACnC,wBAAwB;AAAA,MACxB,2BAA2B;AAAA,MAC3B,kBAAkB;AAAA,MAClB,6BAA6B;AAAA,MAC7B,gBAAgB;AAAA,MAChB,MAAK;AAAA,MACL,OAAOE;AAAA,MACP,QAAQC;AAAA,MACR,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,mBAAmB;AAAA,QACnB,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEJ,+BAAO,iBAAN,EACC;AAAA,wBAAAH,KAAC,QAAK;AAAA,QAEN,gBAAAA;AAAA,UAAC,aAAa;AAAA,UAAb;AAAA,YACC,OAAO;AAAA,cACL;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,YAAY,cAAc;AAC1B,aAAa,cAAc;AAC3B,iBAAiB,cAAc;AAE/B,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,cAAc;AAEpB,IAAO,gBAAQ;;;AE9Jf,OAAuB;AACvB,OAAuB;;;ACCvB,IAAO,gBAAQ;","names":["React","Box","className","jsx","Box","width","zIndex"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -51,19 +51,12 @@ interface TypeModalProps extends TypeContainerProps, Omit<ReactModal.Props, keyo
|
|
|
51
51
|
*/
|
|
52
52
|
declare const Modal: {
|
|
53
53
|
(props: TypeModalProps): react_jsx_runtime.JSX.Element;
|
|
54
|
-
defaultProps: {
|
|
55
|
-
width: string;
|
|
56
|
-
zIndex: number;
|
|
57
|
-
};
|
|
58
54
|
Header: {
|
|
59
55
|
(props: TypeModalHeaderProps): react_jsx_runtime.JSX.Element;
|
|
60
56
|
displayName: string;
|
|
61
57
|
};
|
|
62
58
|
Footer: {
|
|
63
|
-
(
|
|
64
|
-
defaultProps: {
|
|
65
|
-
bg: string;
|
|
66
|
-
};
|
|
59
|
+
({ bg, ...rest }: TypeModalFooterProps): react_jsx_runtime.JSX.Element;
|
|
67
60
|
displayName: string;
|
|
68
61
|
};
|
|
69
62
|
Content: React.ForwardRefExoticComponent<Omit<TypeModalContentProps, "ref"> & React.RefAttributes<unknown>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -51,19 +51,12 @@ interface TypeModalProps extends TypeContainerProps, Omit<ReactModal.Props, keyo
|
|
|
51
51
|
*/
|
|
52
52
|
declare const Modal: {
|
|
53
53
|
(props: TypeModalProps): react_jsx_runtime.JSX.Element;
|
|
54
|
-
defaultProps: {
|
|
55
|
-
width: string;
|
|
56
|
-
zIndex: number;
|
|
57
|
-
};
|
|
58
54
|
Header: {
|
|
59
55
|
(props: TypeModalHeaderProps): react_jsx_runtime.JSX.Element;
|
|
60
56
|
displayName: string;
|
|
61
57
|
};
|
|
62
58
|
Footer: {
|
|
63
|
-
(
|
|
64
|
-
defaultProps: {
|
|
65
|
-
bg: string;
|
|
66
|
-
};
|
|
59
|
+
({ bg, ...rest }: TypeModalFooterProps): react_jsx_runtime.JSX.Element;
|
|
67
60
|
displayName: string;
|
|
68
61
|
};
|
|
69
62
|
Content: React.ForwardRefExoticComponent<Omit<TypeModalContentProps, "ref"> & React.RefAttributes<unknown>>;
|
package/dist/index.js
CHANGED
|
@@ -181,10 +181,18 @@ var ModalCloseButton = (props) => {
|
|
|
181
181
|
if (!onClose) return null;
|
|
182
182
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_button.default, { onClick: onClose, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_seeds_react_icon.default, { name: "x-outline", ariaLabel: closeButtonLabel }) });
|
|
183
183
|
};
|
|
184
|
-
var ModalFooter = (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
184
|
+
var ModalFooter = ({
|
|
185
|
+
bg = "container.background.base",
|
|
186
|
+
...rest
|
|
187
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
188
|
+
Footer,
|
|
189
|
+
{
|
|
190
|
+
bg,
|
|
191
|
+
borderTop: 500,
|
|
192
|
+
borderColor: "container.border.base",
|
|
193
|
+
...rest
|
|
194
|
+
}
|
|
195
|
+
);
|
|
188
196
|
var ModalContent = React2.forwardRef(
|
|
189
197
|
({ children, ...rest }, ref) => {
|
|
190
198
|
const { label } = (0, import_react2.useContext)(ModalContext);
|
|
@@ -199,8 +207,8 @@ var Modal = (props) => {
|
|
|
199
207
|
label,
|
|
200
208
|
onClose,
|
|
201
209
|
closeButtonLabel,
|
|
202
|
-
width: width2,
|
|
203
|
-
zIndex: zIndex2,
|
|
210
|
+
width: width2 = "800px",
|
|
211
|
+
zIndex: zIndex2 = 6,
|
|
204
212
|
data = {},
|
|
205
213
|
...rest
|
|
206
214
|
} = props;
|
|
@@ -246,10 +254,6 @@ var Modal = (props) => {
|
|
|
246
254
|
}
|
|
247
255
|
);
|
|
248
256
|
};
|
|
249
|
-
Modal.defaultProps = {
|
|
250
|
-
width: "800px",
|
|
251
|
-
zIndex: 6
|
|
252
|
-
};
|
|
253
257
|
ModalHeader.displayName = "Modal.Header";
|
|
254
258
|
ModalFooter.displayName = "Modal.Footer";
|
|
255
259
|
ModalContent.displayName = "Modal.Content";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/Modal.tsx","../src/styles.tsx","../src/ModalTypes.ts"],"sourcesContent":["import Modal from \"./Modal\";\n\nexport default Modal;\nexport { Modal };\nexport * from \"./ModalTypes\";\n","import * as React from \"react\";\nimport { useContext } from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Container, Content, Header, Footer, Body } from \"./styles\";\nimport type {\n TypeModalProps,\n TypeModalCloseButtonProps,\n TypeModalContentProps,\n TypeModalFooterProps,\n TypeModalHeaderProps,\n} from \"./ModalTypes\";\n\ntype TypeModalContext = Partial<{\n onClose: () => void;\n closeButtonLabel: string;\n label: string;\n}>;\n\nconst ModalContext = React.createContext<TypeModalContext>({});\n\nconst ModalHeader = (props: TypeModalHeaderProps) => {\n const { title, subtitle, children, bordered, ...rest } = props;\n return (\n <Header bordered={title || subtitle || bordered} {...rest}>\n {children ? (\n children\n ) : (\n <React.Fragment>\n <Box>\n {title && (\n <Text as=\"h1\" fontSize={400} fontWeight=\"semibold\">\n {title}\n </Text>\n )}\n {subtitle && (\n <Text as=\"div\" fontSize={200}>\n {subtitle}\n </Text>\n )}\n </Box>\n <Box display=\"flex\" alignItems=\"center\" justify-content=\"flex-end\">\n <ModalCloseButton ml={400} />\n </Box>\n </React.Fragment>\n )}\n </Header>\n );\n};\n\nconst ModalCloseButton = (props: TypeModalCloseButtonProps) => {\n const { onClose, closeButtonLabel } = useContext(ModalContext);\n if (!onClose) return null;\n return (\n <Button onClick={onClose} {...props}>\n <Icon name=\"x-outline\" ariaLabel={closeButtonLabel} />\n </Button>\n );\n};\n\nconst ModalFooter = (props: TypeModalFooterProps) => (\n <Footer borderTop={500} borderColor=\"container.border.base\" {...props} />\n);\n\nModalFooter.defaultProps = {\n bg: \"container.background.base\",\n};\n\nconst ModalContent = React.forwardRef(\n ({ children, ...rest }: TypeModalContentProps, ref) => {\n const { label } = useContext(ModalContext);\n return (\n <Content data-qa-modal data-qa-label={label} ref={ref} {...rest}>\n {children}\n </Content>\n );\n }\n);\n\n/**\n * The modal you want\n */\nconst Modal = (props: TypeModalProps) => {\n const {\n appElementSelector,\n children,\n isOpen,\n label,\n onClose,\n closeButtonLabel,\n width,\n zIndex,\n data = {},\n ...rest\n } = props;\n\n const isCloseable = Boolean(onClose);\n const appElement =\n appElementSelector && document\n ? (document.querySelector(appElementSelector) as HTMLElement)\n : undefined;\n\n return (\n <Container\n appElement={appElement}\n ariaHideApp={!!appElement}\n isOpen={isOpen}\n contentLabel={label}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onRequestClose={onClose || (() => {})}\n shouldFocusAfterRender={true}\n shouldCloseOnOverlayClick={isCloseable}\n shouldCloseOnEsc={isCloseable}\n shouldReturnFocusAfterClose={true}\n closeTimeoutMS={200}\n role=\"dialog\"\n width={width}\n zIndex={zIndex}\n data={{\n \"qa-modal\": \"\",\n \"qa-modal-isopen\": isOpen,\n ...data,\n }}\n {...rest}\n >\n <React.Fragment>\n <Body />\n\n <ModalContext.Provider\n value={{\n onClose,\n closeButtonLabel,\n label,\n }}\n >\n {children}\n </ModalContext.Provider>\n </React.Fragment>\n </Container>\n );\n};\n\nModal.defaultProps = {\n width: \"800px\",\n zIndex: 6,\n};\n\nModalHeader.displayName = \"Modal.Header\";\nModalFooter.displayName = \"Modal.Footer\";\nModalContent.displayName = \"Modal.Content\";\nModalCloseButton.displayName = \"Modal.CloseButton\";\n\nModal.Header = ModalHeader;\nModal.Footer = ModalFooter;\nModal.Content = ModalContent;\nModal.CloseButton = ModalCloseButton;\n\nexport default Modal;\n","import React from \"react\";\nimport styled, { createGlobalStyle } from \"styled-components\";\nimport { width, zIndex } from \"styled-system\";\nimport ReactModal from \"react-modal\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport Box, { type TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\n\n// This is the max space allowed between the modal and the edge of the browser\nconst BODY_PADDING = \"64px\";\n\nconst ReactModalAdapter = ({\n className = \"\",\n ...props\n}: { className?: string } & Omit<\n ReactModal.Props,\n \"portalClassName\" | \"className\" | \"overlayClassName\"\n>) => {\n // We want to create *__Content and *__Overlay class names on the subcomponents.\n // Because `className` could be a space-separated list of class names, we make\n // sure that we append `__Content` and `__Overlay` to every class name.\n const contentClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Content`)\n .join(\" \");\n\n const overlayClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Overlay`)\n .join(\" \");\n\n return (\n <ReactModal\n portalClassName={className}\n className={contentClassName}\n overlayClassName={overlayClassName}\n {...props}\n />\n );\n};\n\nexport const Body = createGlobalStyle`\n .ReactModal__Body--open {\n overflow: hidden;\n }\n`;\n\nexport const Container = styled(ReactModalAdapter)<TypeContainerProps>`\n &__Overlay {\n position: fixed;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ${(props) => props.theme.colors.overlay.background.base};\n opacity: 0;\n will-change: opacity;\n transition: opacity ${(props) => props.theme.duration.medium}\n ${(props) => props.theme.easing.ease_inout};\n\n ${zIndex}\n\n &.ReactModal__Overlay--after-open {\n opacity: 1;\n }\n &.ReactModal__Overlay--before-close {\n opacity: 0;\n }\n }\n\n &__Content {\n display: flex;\n flex-direction: column;\n background: ${(props) => props.theme.colors.container.background.base};\n border-radius: ${(props) => props.theme.radii[600]};\n box-shadow: ${(props) => props.theme.shadows.medium};\n filter: blur(0);\n color: ${(props) => props.theme.colors.text.body};\n\n outline: none;\n max-width: calc(100vw - ${BODY_PADDING});\n max-height: calc(100vh - ${BODY_PADDING});\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /**\n * This prevents the modal from being very short in IE11. Better too big\n * than too small.\n */\n height: calc(100vh - ${BODY_PADDING});\n }\n\n ${width}\n\n ${COMMON}\n }\n`;\n\nexport const Content = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n min-height: 80px;\n overflow-y: auto;\n flex: 1 1 auto;\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /* 'flex-basis: auto' breaks overflow in IE11 */\n flex-basis: 100%;\n }\n`;\n\nexport const HeaderContainer = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n`;\n\nexport const Header = styled(HeaderContainer)<{ bordered?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 0 0 auto;\n border-bottom-width: ${(props) => props.theme.borderWidths[500]};\n border-bottom-color: ${(props) =>\n props.bordered ? props.theme.colors.container.border.base : \"transparent\"};\n border-bottom-style: solid;\n`;\n\nexport const Footer = styled(Box)`\n flex: 0 0 auto;\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n border-bottom-right-radius: ${(props) => props.theme.radii[500]};\n border-bottom-left-radius: ${(props) => props.theme.radii[500]};\n`;\n\nContainer.displayName = \"ModalContainer\";\nContent.displayName = \"Content\";\nHeader.displayName = \"Modal.Header\";\nFooter.displayName = \"Modal.Footer\";\n","import * as React from \"react\";\nimport ReactModal from \"react-modal\";\nimport type {\n TypeBoxProps,\n TypeContainerProps,\n} from \"@sproutsocial/seeds-react-box\";\nimport type { TypeButtonProps } from \"@sproutsocial/seeds-react-button\";\n\nexport interface TypeModalCloseButtonProps\n extends Omit<TypeButtonProps, \"children\"> {\n children?: void | null;\n}\n\nexport interface TypeModalHeaderProps extends TypeBoxProps {\n title?: string;\n subtitle?: string;\n\n /** Passing children will override the default modal header */\n children?: React.ReactNode;\n\n /** If you're rendering a custom header, you can use this prop to add a bottom border */\n bordered?: boolean;\n}\n\nexport interface TypeModalFooterProps extends TypeBoxProps {\n bg?: string;\n children: React.ReactNode;\n}\n\nexport interface TypeModalContentProps extends TypeBoxProps {\n children?: React.ReactNode;\n}\n\nexport interface TypeModalProps\n extends TypeContainerProps,\n // @ts-notes - onClose is an alias for onRequestClose so we don't need to include it here\n Omit<ReactModal.Props, keyof TypeContainerProps | \"onRequestClose\"> {\n /** section of app to aria hide for the modal */\n appElementSelector?: string;\n\n /** trigger to open or close the modal */\n isOpen: boolean;\n\n /** label for screen readers to announce the modal */\n label: string;\n\n /** body content of the modal */\n children: React.ReactNode;\n\n /** callback for close */\n onClose?: () => void;\n\n /** aria-label for modal X */\n closeButtonLabel: string;\n\n /** Controls the z-index CSS property */\n zIndex?: number;\n\n /** The max width of the modal container */\n width?: string | number;\n\n /**\n * Custom attributes to be added to the modals container\n * Each key will be prepended with \"data-\" when rendered in the DOM\n */\n data?: Record<string, string | boolean | number>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AACvB,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAgB;AAChB,gCAAmB;AACnB,8BAAiB;AACjB,8BAAiB;;;ACLjB,mBAAkB;AAClB,+BAA0C;AAC1C,2BAA8B;AAC9B,yBAAuB;AACvB,sCAAuB;AACvB,6BAA6C;AA0BzC;AAvBJ,IAAM,eAAe;AAErB,IAAM,oBAAoB,CAAC;AAAA,EACzB,YAAY;AAAA,EACZ,GAAG;AACL,MAGM;AAIJ,QAAM,mBAAmB,UACtB,MAAM,GAAG,EACT,IAAI,CAACC,eAAc,GAAGA,UAAS,IAAIA,UAAS,WAAW,EACvD,KAAK,GAAG;AAEX,QAAM,mBAAmB,UACtB,MAAM,GAAG,EACT,IAAI,CAACA,eAAc,GAAGA,UAAS,IAAIA,UAAS,WAAW,EACvD,KAAK,GAAG;AAEX,SACE;AAAA,IAAC,mBAAAC;AAAA,IAAA;AAAA,MACC,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;AAEO,IAAM,OAAO;AAAA;AAAA;AAAA;AAAA;AAMb,IAAM,gBAAY,yBAAAC,SAAO,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAUzB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ,WAAW,IAAI;AAAA;AAAA;AAAA,0BAGnD,CAAC,UAAU,MAAM,MAAM,SAAS,MAAM;AAAA,QACxD,CAAC,UAAU,MAAM,MAAM,OAAO,UAAU;AAAA;AAAA,MAE1C,2BAAM;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AC1B,YAAY,cAAc;AAC1B,aAAa,cAAc;AAC3B,iBAAiB,cAAc;AAE/B,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,cAAc;AAEpB,IAAO,gBAAQ;;;AE/Jf,IAAAC,SAAuB;AACvB,IAAAC,sBAAuB;;;AHCvB,IAAO,gBAAQ;","names":["React","import_react","import_seeds_react_box","className","ReactModal","styled","Box","import_jsx_runtime","Box","Text","Button","Icon","width","zIndex","React","import_react_modal"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/Modal.tsx","../src/styles.tsx","../src/ModalTypes.ts"],"sourcesContent":["import Modal from \"./Modal\";\n\nexport default Modal;\nexport { Modal };\nexport * from \"./ModalTypes\";\n","import * as React from \"react\";\nimport { useContext } from \"react\";\nimport Box from \"@sproutsocial/seeds-react-box\";\nimport Button from \"@sproutsocial/seeds-react-button\";\nimport Icon from \"@sproutsocial/seeds-react-icon\";\nimport Text from \"@sproutsocial/seeds-react-text\";\nimport { Container, Content, Header, Footer, Body } from \"./styles\";\nimport type {\n TypeModalProps,\n TypeModalCloseButtonProps,\n TypeModalContentProps,\n TypeModalFooterProps,\n TypeModalHeaderProps,\n} from \"./ModalTypes\";\n\ntype TypeModalContext = Partial<{\n onClose: () => void;\n closeButtonLabel: string;\n label: string;\n}>;\n\nconst ModalContext = React.createContext<TypeModalContext>({});\n\nconst ModalHeader = (props: TypeModalHeaderProps) => {\n const { title, subtitle, children, bordered, ...rest } = props;\n return (\n <Header bordered={title || subtitle || bordered} {...rest}>\n {children ? (\n children\n ) : (\n <React.Fragment>\n <Box>\n {title && (\n <Text as=\"h1\" fontSize={400} fontWeight=\"semibold\">\n {title}\n </Text>\n )}\n {subtitle && (\n <Text as=\"div\" fontSize={200}>\n {subtitle}\n </Text>\n )}\n </Box>\n <Box display=\"flex\" alignItems=\"center\" justify-content=\"flex-end\">\n <ModalCloseButton ml={400} />\n </Box>\n </React.Fragment>\n )}\n </Header>\n );\n};\n\nconst ModalCloseButton = (props: TypeModalCloseButtonProps) => {\n const { onClose, closeButtonLabel } = useContext(ModalContext);\n if (!onClose) return null;\n return (\n <Button onClick={onClose} {...props}>\n <Icon name=\"x-outline\" ariaLabel={closeButtonLabel} />\n </Button>\n );\n};\n\nconst ModalFooter = ({\n bg = \"container.background.base\",\n ...rest\n}: TypeModalFooterProps) => (\n <Footer\n bg={bg}\n borderTop={500}\n borderColor=\"container.border.base\"\n {...rest}\n />\n);\n\nconst ModalContent = React.forwardRef(\n ({ children, ...rest }: TypeModalContentProps, ref) => {\n const { label } = useContext(ModalContext);\n return (\n <Content data-qa-modal data-qa-label={label} ref={ref} {...rest}>\n {children}\n </Content>\n );\n }\n);\n\n/**\n * The modal you want\n */\nconst Modal = (props: TypeModalProps) => {\n const {\n appElementSelector,\n children,\n isOpen,\n label,\n onClose,\n closeButtonLabel,\n width = \"800px\",\n zIndex = 6,\n data = {},\n ...rest\n } = props;\n\n const isCloseable = Boolean(onClose);\n const appElement =\n appElementSelector && document\n ? (document.querySelector(appElementSelector) as HTMLElement)\n : undefined;\n\n return (\n <Container\n appElement={appElement}\n ariaHideApp={!!appElement}\n isOpen={isOpen}\n contentLabel={label}\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onRequestClose={onClose || (() => {})}\n shouldFocusAfterRender={true}\n shouldCloseOnOverlayClick={isCloseable}\n shouldCloseOnEsc={isCloseable}\n shouldReturnFocusAfterClose={true}\n closeTimeoutMS={200}\n role=\"dialog\"\n width={width}\n zIndex={zIndex}\n data={{\n \"qa-modal\": \"\",\n \"qa-modal-isopen\": isOpen,\n ...data,\n }}\n {...rest}\n >\n <React.Fragment>\n <Body />\n\n <ModalContext.Provider\n value={{\n onClose,\n closeButtonLabel,\n label,\n }}\n >\n {children}\n </ModalContext.Provider>\n </React.Fragment>\n </Container>\n );\n};\n\nModalHeader.displayName = \"Modal.Header\";\nModalFooter.displayName = \"Modal.Footer\";\nModalContent.displayName = \"Modal.Content\";\nModalCloseButton.displayName = \"Modal.CloseButton\";\n\nModal.Header = ModalHeader;\nModal.Footer = ModalFooter;\nModal.Content = ModalContent;\nModal.CloseButton = ModalCloseButton;\n\nexport default Modal;\n","import React from \"react\";\nimport styled, { createGlobalStyle } from \"styled-components\";\nimport { width, zIndex } from \"styled-system\";\nimport ReactModal from \"react-modal\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport Box, { type TypeContainerProps } from \"@sproutsocial/seeds-react-box\";\n\n// This is the max space allowed between the modal and the edge of the browser\nconst BODY_PADDING = \"64px\";\n\nconst ReactModalAdapter = ({\n className = \"\",\n ...props\n}: { className?: string } & Omit<\n ReactModal.Props,\n \"portalClassName\" | \"className\" | \"overlayClassName\"\n>) => {\n // We want to create *__Content and *__Overlay class names on the subcomponents.\n // Because `className` could be a space-separated list of class names, we make\n // sure that we append `__Content` and `__Overlay` to every class name.\n const contentClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Content`)\n .join(\" \");\n\n const overlayClassName = className\n .split(\" \")\n .map((className) => `${className} ${className}__Overlay`)\n .join(\" \");\n\n return (\n <ReactModal\n portalClassName={className}\n className={contentClassName}\n overlayClassName={overlayClassName}\n {...props}\n />\n );\n};\n\nexport const Body = createGlobalStyle`\n .ReactModal__Body--open {\n overflow: hidden;\n }\n`;\n\nexport const Container = styled(ReactModalAdapter)<TypeContainerProps>`\n &__Overlay {\n position: fixed;\n top: 0px;\n left: 0px;\n right: 0px;\n bottom: 0px;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: ${(props) => props.theme.colors.overlay.background.base};\n opacity: 0;\n will-change: opacity;\n transition: opacity ${(props) => props.theme.duration.medium}\n ${(props) => props.theme.easing.ease_inout};\n\n ${zIndex}\n\n &.ReactModal__Overlay--after-open {\n opacity: 1;\n }\n &.ReactModal__Overlay--before-close {\n opacity: 0;\n }\n }\n\n &__Content {\n display: flex;\n flex-direction: column;\n background: ${(props) => props.theme.colors.container.background.base};\n border-radius: ${(props) => props.theme.radii[600]};\n box-shadow: ${(props) => props.theme.shadows.medium};\n filter: blur(0);\n color: ${(props) => props.theme.colors.text.body};\n\n outline: none;\n max-width: calc(100vw - ${BODY_PADDING});\n max-height: calc(100vh - ${BODY_PADDING});\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /**\n * This prevents the modal from being very short in IE11. Better too big\n * than too small.\n */\n height: calc(100vh - ${BODY_PADDING});\n }\n\n ${width}\n\n ${COMMON}\n }\n`;\n\nexport const Content = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n min-height: 80px;\n overflow-y: auto;\n flex: 1 1 auto;\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {\n /* 'flex-basis: auto' breaks overflow in IE11 */\n flex-basis: 100%;\n }\n`;\n\nexport const HeaderContainer = styled(Box)`\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n`;\n\nexport const Header = styled(HeaderContainer)<{ bordered?: boolean }>`\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex: 0 0 auto;\n border-bottom-width: ${(props) => props.theme.borderWidths[500]};\n border-bottom-color: ${(props) =>\n props.bordered ? props.theme.colors.container.border.base : \"transparent\"};\n border-bottom-style: solid;\n`;\n\nexport const Footer = styled(Box)`\n flex: 0 0 auto;\n font-family: ${(props) => props.theme.fontFamily};\n padding: ${(props) => props.theme.space[400]}\n ${(props) => props.theme.space[450]};\n border-bottom-right-radius: ${(props) => props.theme.radii[500]};\n border-bottom-left-radius: ${(props) => props.theme.radii[500]};\n`;\n\nContainer.displayName = \"ModalContainer\";\nContent.displayName = \"Content\";\nHeader.displayName = \"Modal.Header\";\nFooter.displayName = \"Modal.Footer\";\n","import * as React from \"react\";\nimport ReactModal from \"react-modal\";\nimport type {\n TypeBoxProps,\n TypeContainerProps,\n} from \"@sproutsocial/seeds-react-box\";\nimport type { TypeButtonProps } from \"@sproutsocial/seeds-react-button\";\n\nexport interface TypeModalCloseButtonProps\n extends Omit<TypeButtonProps, \"children\"> {\n children?: void | null;\n}\n\nexport interface TypeModalHeaderProps extends TypeBoxProps {\n title?: string;\n subtitle?: string;\n\n /** Passing children will override the default modal header */\n children?: React.ReactNode;\n\n /** If you're rendering a custom header, you can use this prop to add a bottom border */\n bordered?: boolean;\n}\n\nexport interface TypeModalFooterProps extends TypeBoxProps {\n bg?: string;\n children: React.ReactNode;\n}\n\nexport interface TypeModalContentProps extends TypeBoxProps {\n children?: React.ReactNode;\n}\n\nexport interface TypeModalProps\n extends TypeContainerProps,\n // @ts-notes - onClose is an alias for onRequestClose so we don't need to include it here\n Omit<ReactModal.Props, keyof TypeContainerProps | \"onRequestClose\"> {\n /** section of app to aria hide for the modal */\n appElementSelector?: string;\n\n /** trigger to open or close the modal */\n isOpen: boolean;\n\n /** label for screen readers to announce the modal */\n label: string;\n\n /** body content of the modal */\n children: React.ReactNode;\n\n /** callback for close */\n onClose?: () => void;\n\n /** aria-label for modal X */\n closeButtonLabel: string;\n\n /** Controls the z-index CSS property */\n zIndex?: number;\n\n /** The max width of the modal container */\n width?: string | number;\n\n /**\n * Custom attributes to be added to the modals container\n * Each key will be prepended with \"data-\" when rendered in the DOM\n */\n data?: Record<string, string | boolean | number>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,SAAuB;AACvB,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAgB;AAChB,gCAAmB;AACnB,8BAAiB;AACjB,8BAAiB;;;ACLjB,mBAAkB;AAClB,+BAA0C;AAC1C,2BAA8B;AAC9B,yBAAuB;AACvB,sCAAuB;AACvB,6BAA6C;AA0BzC;AAvBJ,IAAM,eAAe;AAErB,IAAM,oBAAoB,CAAC;AAAA,EACzB,YAAY;AAAA,EACZ,GAAG;AACL,MAGM;AAIJ,QAAM,mBAAmB,UACtB,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AAc,kBAAkB,IAC1C;AAEN,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,aAAa,CAAC,CAAC;AAAA,MACf;AAAA,MACA,cAAc;AAAA,MAEd,gBAAgB,YAAY,MAAM;AAAA,MAAC;AAAA,MACnC,wBAAwB;AAAA,MACxB,2BAA2B;AAAA,MAC3B,kBAAkB;AAAA,MAClB,6BAA6B;AAAA,MAC7B,gBAAgB;AAAA,MAChB,MAAK;AAAA,MACL,OAAOD;AAAA,MACP,QAAQC;AAAA,MACR,MAAM;AAAA,QACJ,YAAY;AAAA,QACZ,mBAAmB;AAAA,QACnB,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,MAEJ,wDAAO,iBAAN,EACC;AAAA,qDAAC,QAAK;AAAA,QAEN;AAAA,UAAC,aAAa;AAAA,UAAb;AAAA,YACC,OAAO;AAAA,cACL;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;AAEA,YAAY,cAAc;AAC1B,YAAY,cAAc;AAC1B,aAAa,cAAc;AAC3B,iBAAiB,cAAc;AAE/B,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,UAAU;AAChB,MAAM,cAAc;AAEpB,IAAO,gBAAQ;;;AE9Jf,IAAAC,SAAuB;AACvB,IAAAC,sBAAuB;;;AHCvB,IAAO,gBAAQ;","names":["React","import_react","import_seeds_react_box","className","ReactModal","styled","Box","import_jsx_runtime","Box","Text","Button","Icon","width","zIndex","React","import_react_modal"]}
|
package/package.json
CHANGED
package/src/Modal.stories.tsx
CHANGED
|
@@ -7,16 +7,13 @@ import { Input } from "@sproutsocial/seeds-react-input";
|
|
|
7
7
|
import { Text } from "@sproutsocial/seeds-react-text";
|
|
8
8
|
import Modal from "./Modal";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface StatefulStoryProps<T> {
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
12
|
children: FC<{ state: T; setState: (state: T) => void }>;
|
|
13
13
|
initialState: T;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
children,
|
|
18
|
-
initialState,
|
|
19
|
-
}: StatefulStoryProps<T>) {
|
|
16
|
+
function StatefulStory<T>({ children, initialState }: StatefulStoryProps<T>) {
|
|
20
17
|
const [state, setState] = useState<T>(initialState);
|
|
21
18
|
return children({ state, setState });
|
|
22
19
|
}
|
package/src/Modal.tsx
CHANGED
|
@@ -60,14 +60,18 @@ const ModalCloseButton = (props: TypeModalCloseButtonProps) => {
|
|
|
60
60
|
);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
const ModalFooter = (
|
|
64
|
-
|
|
63
|
+
const ModalFooter = ({
|
|
64
|
+
bg = "container.background.base",
|
|
65
|
+
...rest
|
|
66
|
+
}: TypeModalFooterProps) => (
|
|
67
|
+
<Footer
|
|
68
|
+
bg={bg}
|
|
69
|
+
borderTop={500}
|
|
70
|
+
borderColor="container.border.base"
|
|
71
|
+
{...rest}
|
|
72
|
+
/>
|
|
65
73
|
);
|
|
66
74
|
|
|
67
|
-
ModalFooter.defaultProps = {
|
|
68
|
-
bg: "container.background.base",
|
|
69
|
-
};
|
|
70
|
-
|
|
71
75
|
const ModalContent = React.forwardRef(
|
|
72
76
|
({ children, ...rest }: TypeModalContentProps, ref) => {
|
|
73
77
|
const { label } = useContext(ModalContext);
|
|
@@ -90,8 +94,8 @@ const Modal = (props: TypeModalProps) => {
|
|
|
90
94
|
label,
|
|
91
95
|
onClose,
|
|
92
96
|
closeButtonLabel,
|
|
93
|
-
width,
|
|
94
|
-
zIndex,
|
|
97
|
+
width = "800px",
|
|
98
|
+
zIndex = 6,
|
|
95
99
|
data = {},
|
|
96
100
|
...rest
|
|
97
101
|
} = props;
|
|
@@ -142,11 +146,6 @@ const Modal = (props: TypeModalProps) => {
|
|
|
142
146
|
);
|
|
143
147
|
};
|
|
144
148
|
|
|
145
|
-
Modal.defaultProps = {
|
|
146
|
-
width: "800px",
|
|
147
|
-
zIndex: 6,
|
|
148
|
-
};
|
|
149
|
-
|
|
150
149
|
ModalHeader.displayName = "Modal.Header";
|
|
151
150
|
ModalFooter.displayName = "Modal.Footer";
|
|
152
151
|
ModalContent.displayName = "Modal.Content";
|