@doist/reactist 10.0.0-beta.10 → 10.0.0-beta.12
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/reactist.cjs.development.js +141 -71
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +34 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/es/components/deprecated-button/deprecated-button.js +2 -1
- package/es/components/deprecated-button/deprecated-button.js.map +1 -1
- package/es/components/deprecated-modal/deprecated-modal.js +1 -1
- package/es/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/es/components/dropdown/dropdown.js +3 -1
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/error-message/error-message.js +1 -1
- package/es/components/error-message/error-message.js.map +1 -1
- package/es/components/icon/icon.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +2 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/menu/menu.js +22 -11
- package/es/components/menu/menu.js.map +1 -1
- package/es/components/notification/notification.js +3 -1
- package/es/components/notification/notification.js.map +1 -1
- package/es/components/popover/popover.js.map +1 -1
- package/es/components/popover/positioning-utils.js.map +1 -1
- package/es/components/select/select.js +3 -1
- package/es/components/select/select.js.map +1 -1
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js.map +1 -1
- package/es/components/tooltip/tooltip.js +3 -1
- package/es/components/tooltip/tooltip.js.map +1 -1
- package/es/new-components/base-button/base-button.js +3 -1
- package/es/new-components/base-button/base-button.js.map +1 -1
- package/es/new-components/box/box.js +2 -1
- package/es/new-components/box/box.js.map +1 -1
- package/es/new-components/button/button.js +2 -1
- package/es/new-components/button/button.js.map +1 -1
- package/es/new-components/button-link/button-link.js +2 -1
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +2 -1
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-icon.js +2 -1
- package/es/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/new-components/columns/columns.js +4 -2
- package/es/new-components/columns/columns.js.map +1 -1
- package/es/new-components/divider/divider.js +3 -1
- package/es/new-components/divider/divider.js.map +1 -1
- package/es/new-components/heading/heading.js +2 -1
- package/es/new-components/heading/heading.js.map +1 -1
- package/es/new-components/hidden/hidden.js +2 -1
- package/es/new-components/hidden/hidden.js.map +1 -1
- package/es/new-components/icons/alert-icon.js +2 -1
- package/es/new-components/icons/alert-icon.js.map +1 -1
- package/es/new-components/inline/inline.js +2 -1
- package/es/new-components/inline/inline.js.map +1 -1
- package/es/new-components/loading/loading.js +2 -1
- package/es/new-components/loading/loading.js.map +1 -1
- package/es/new-components/modal/modal.js +10 -5
- package/es/new-components/modal/modal.js.map +1 -1
- package/es/new-components/modal/modal.module.css.js +1 -1
- package/es/new-components/password-field/password-field.js +2 -1
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/select-field/select-field.js +2 -1
- package/es/new-components/select-field/select-field.js.map +1 -1
- package/es/new-components/stack/stack.js +2 -1
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +2 -1
- package/es/new-components/switch-field/switch-field.js.map +1 -1
- package/es/new-components/tabs/tabs.js +10 -5
- package/es/new-components/tabs/tabs.js.map +1 -1
- package/es/new-components/text/text.js +2 -1
- package/es/new-components/text/text.js.map +1 -1
- package/es/new-components/text-area/text-area.js +3 -1
- package/es/new-components/text-area/text-area.js.map +1 -1
- package/es/new-components/text-field/text-field.js +2 -1
- package/es/new-components/text-field/text-field.js.map +1 -1
- package/es/new-components/text-link/text-link.js +2 -1
- package/es/new-components/text-link/text-link.js.map +1 -1
- package/lib/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/lib/components/dropdown/dropdown.js +1 -1
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/error-message/error-message.js +1 -1
- package/lib/components/error-message/error-message.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/components/notification/notification.js +1 -1
- package/lib/components/notification/notification.js.map +1 -1
- package/lib/components/select/select.js +1 -1
- package/lib/components/select/select.js.map +1 -1
- package/lib/components/tooltip/tooltip.js +1 -1
- package/lib/components/tooltip/tooltip.js.map +1 -1
- package/lib/new-components/base-button/base-button.js +1 -1
- package/lib/new-components/base-button/base-button.js.map +1 -1
- package/lib/new-components/box/box.js +1 -1
- package/lib/new-components/box/box.js.map +1 -1
- package/lib/new-components/button/button.js +1 -1
- package/lib/new-components/button/button.js.map +1 -1
- package/lib/new-components/button-link/button-link.js +1 -1
- package/lib/new-components/button-link/button-link.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/new-components/columns/columns.js +1 -1
- package/lib/new-components/columns/columns.js.map +1 -1
- package/lib/new-components/divider/divider.js +1 -1
- package/lib/new-components/divider/divider.js.map +1 -1
- package/lib/new-components/heading/heading.js +1 -1
- package/lib/new-components/heading/heading.js.map +1 -1
- package/lib/new-components/hidden/hidden.js +1 -1
- package/lib/new-components/hidden/hidden.js.map +1 -1
- package/lib/new-components/icons/alert-icon.js +1 -1
- package/lib/new-components/icons/alert-icon.js.map +1 -1
- package/lib/new-components/inline/inline.js +1 -1
- package/lib/new-components/inline/inline.js.map +1 -1
- package/lib/new-components/loading/loading.js +1 -1
- package/lib/new-components/loading/loading.js.map +1 -1
- package/lib/new-components/modal/modal.d.ts +1 -1
- package/lib/new-components/modal/modal.js +1 -1
- package/lib/new-components/modal/modal.js.map +1 -1
- package/lib/new-components/modal/modal.module.css.js +1 -1
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/select-field/select-field.js +1 -1
- package/lib/new-components/select-field/select-field.js.map +1 -1
- package/lib/new-components/stack/stack.js +1 -1
- package/lib/new-components/stack/stack.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.js +1 -1
- package/lib/new-components/switch-field/switch-field.js.map +1 -1
- package/lib/new-components/tabs/tabs.js +1 -1
- package/lib/new-components/tabs/tabs.js.map +1 -1
- package/lib/new-components/text/text.js +1 -1
- package/lib/new-components/text/text.js.map +1 -1
- package/lib/new-components/text-area/text-area.js +1 -1
- package/lib/new-components/text-area/text-area.js.map +1 -1
- package/lib/new-components/text-field/text-field.js +1 -1
- package/lib/new-components/text-field/text-field.js.map +1 -1
- package/lib/new-components/text-link/text-link.js +1 -1
- package/lib/new-components/text-link/text-link.js.map +1 -1
- package/package.json +9 -9
- package/styles/base-button.css +1 -1
- package/styles/color-picker.css +1 -1
- package/styles/deprecated-button.css +1 -1
- package/styles/deprecated-loading.css +1 -1
- package/styles/deprecated-modal.css +1 -1
- package/styles/dropdown.css +1 -1
- package/styles/loading.css +1 -1
- package/styles/modal.css +2 -2
- package/styles/modal.module.css.css +1 -1
- package/styles/reactist.css +5 -5
- package/styles/spinner.module.css.css +1 -1
- package/styles/tip.css +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../src/new-components/modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { DialogOverlay, DialogContent } from '@reach/dialog'\nimport FocusLock from 'react-focus-lock'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Column, Columns } from '../columns'\nimport { Inline } from '../inline'\nimport { Divider } from '../divider'\nimport { Box } from '../box'\nimport { Button, ButtonProps } from '../button'\n\nimport styles from './modal.module.css'\n\ntype ModalWidth = 'small' | 'medium' | 'large'\ntype ModalHeightMode = 'expand' | 'fitContent'\n\n//\n// ModalContext\n//\n\ntype ModalContextValue = {\n onDismiss?(this: void): void\n height: ModalHeightMode\n}\n\nconst ModalContext = React.createContext<ModalContextValue>({\n onDismiss: undefined,\n height: 'fitContent',\n})\n\n//\n// Modal container\n//\n\ntype DivProps = Omit<\n React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLDivElement>, HTMLDivElement>,\n 'className' | 'children'\n>\n\nexport type ModalProps = DivProps & {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\n /**\n * A descriptive setting for how wide the modal should aim to be, depending on how much space\n * it has on screen.\n * @default 'medium'\n */\n width?: ModalWidth\n /**\n * A descriptive setting for how tall the modal should aim to be.\n *\n * - 'expand': the modal aims to fill most of the available screen height, leaving only a small\n * padding above and below.\n * - 'fitContent': the modal shrinks to the smallest size that allow it to fit its content.\n *\n * In either case, if content does not fit, the content of the main body is set to scroll\n * (provided you use `ModalBody`) so that the modal never has to strech vertically beyond the\n * viewport boundaries.\n *\n * If you do not use `ModalBody`, the modal still prevents overflow, and you are in charge of\n * the inner layout to ensure scroll, or whatever other strategy you may want.\n */\n height?: ModalHeightMode\n /**\n * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\nfunction isNotInternalFrame(element: HTMLElement) {\n return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe')\n}\n\n/**\n * Renders a modal that sits on top of the rest of the content in the entire page.\n *\n * Follows the WAI-ARIA Dialog (Modal) Pattern.\n *\n * @see ModalHeader\n * @see ModalFooter\n * @see ModalBody\n */\nexport function Modal({\n isOpen,\n onDismiss,\n height = 'fitContent',\n width = 'medium',\n exceptionallySetClassName,\n autoFocus = true,\n children,\n ...props\n}: ModalProps) {\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n return (\n <DialogOverlay\n isOpen={isOpen}\n onDismiss={onDismiss}\n dangerouslyBypassFocusLock // We're setting up our own focus lock below\n className={classNames(styles.overlay, styles[height], styles[width])}\n data-testid=\"modal-overlay\"\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame}>\n <DialogContent\n {...props}\n as={Box}\n borderRadius=\"full\"\n background=\"default\"\n display=\"flex\"\n flexDirection=\"column\"\n overflow=\"hidden\"\n height={height === 'expand' ? 'full' : undefined}\n flexGrow={height === 'expand' ? 1 : 0}\n className={[exceptionallySetClassName, styles.container]}\n >\n <ModalContext.Provider value={contextValue}>{children}</ModalContext.Provider>\n </DialogContent>\n </FocusLock>\n </DialogOverlay>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport type ModalCloseButtonProps = Omit<\n ButtonProps,\n 'type' | 'children' | 'variant' | 'icon' | 'startIcon' | 'endIcon' | 'disabled' | 'loading'\n> & {\n /**\n * The descriptive label of the button.\n */\n 'aria-label': string\n}\n\n/**\n * The close button rendered by ModalHeader. Provided independently so that consumers can customize\n * the button's label.\n *\n * @see ModalHeader\n */\nexport function ModalCloseButton(props: ModalCloseButtonProps) {\n const { onDismiss } = React.useContext(ModalContext)\n return <Button {...props} variant=\"quaternary\" onClick={onDismiss} icon={<CloseIcon />} />\n}\n\n//\n// ModalHeader\n//\n\nexport type ModalHeaderProps = DivProps & {\n /**\n * The content of the header.\n */\n children: React.ReactNode\n /**\n * Allows to provide a custom button element, or to omit the close button if set to false.\n * @see ModalCloseButton\n */\n button?: React.ReactNode | boolean\n /**\n * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal header area with an optional close button.\n *\n * @see Modal\n * @see ModalFooter\n * @see ModalBody\n */\nexport function ModalHeader({\n children,\n button = true,\n withDivider = false,\n exceptionallySetClassName,\n ...props\n}: ModalHeaderProps) {\n return (\n <>\n <Box\n {...props}\n as=\"header\"\n paddingLeft=\"large\"\n paddingRight=\"small\"\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n <Column width=\"content\" exceptionallySetClassName={styles.buttonContainer}>\n {typeof button !== 'boolean' ? (\n button\n ) : button === true ? (\n <ModalCloseButton aria-label=\"Close modal\" />\n ) : null}\n </Column>\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport type ModalBodyProps = DivProps & {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders the body of a modal.\n *\n * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other\n * things, that the contet of the modal body expands or contracts depending on the modal height\n * setting or the size of the content. The body content also automatically scrolls when it's too\n * large to fit the available space.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalFooter\n */\nexport function ModalBody({ exceptionallySetClassName, children, ...props }: ModalBodyProps) {\n const { height } = React.useContext(ModalContext)\n return (\n <Box\n {...props}\n className={exceptionallySetClassName}\n flexGrow={height === 'expand' ? 1 : 0}\n height={height === 'expand' ? 'full' : undefined}\n overflow=\"auto\"\n >\n <Box padding=\"large\" paddingBottom=\"xxlarge\">\n {children}\n </Box>\n </Box>\n )\n}\n\n//\n// ModalFooter\n//\n\nexport type ModalFooterProps = DivProps & {\n /**\n * The contant of the modal footer.\n */\n children: React.ReactNode\n /**\n * Whether to render a divider line below the footer.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal footer area.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalBody\n */\nexport function ModalFooter({\n exceptionallySetClassName,\n withDivider = false,\n ...props\n}: ModalFooterProps) {\n return (\n <>\n {withDivider ? <Divider /> : null}\n <Box as=\"footer\" {...props} className={exceptionallySetClassName} padding=\"large\" />\n </>\n )\n}\n\n//\n// ModalActions\n//\n\n/**\n * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).\n * @see ModalFooter\n */\nexport function ModalActions({ children, ...props }: ModalFooterProps) {\n return (\n <ModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {React.Children.map(children, (child) => (\n <div>{child}</div>\n ))}\n </Inline>\n </ModalFooter>\n )\n}\n"],"names":["ModalContext","React","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","Modal","isOpen","width","exceptionallySetClassName","autoFocus","children","props","contextValue","DialogOverlay","dangerouslyBypassFocusLock","className","classNames","styles","overlay","FocusLock","whiteList","DialogContent","as","Box","borderRadius","background","display","flexDirection","overflow","flexGrow","container","Provider","value","ModalCloseButton","Button","variant","onClick","icon","CloseIcon","ModalHeader","button","withDivider","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","buttonContainer","Divider","ModalBody","padding","paddingBottom","ModalFooter","ModalActions","Inline","align","map","child"],"mappings":";;;;;;;;;;;;;AA0BA,IAAMA,YAAY,gBAAGC,aAAA,CAAuC;AACxDC,EAAAA,SAAS,EAAEC,SAD6C;AAExDC,EAAAA,MAAM,EAAE;AAFgD,CAAvC,CAArB;;AA0DA,SAASC,kBAAT,CAA4BC,OAA5B;AACI,SAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,I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AAA;;AACR,sBACIH,aAAA,CAAC4B,GAAD,oBACQZ;AACJI,IAAAA,SAAS,EAAEP;AACXqB,IAAAA,QAAQ,EAAE/B,MAAM,KAAK,QAAX,GAAsB,CAAtB,GAA0B;AACpCA,IAAAA,MAAM,EAAEA,MAAM,KAAK,QAAX,GAAsB,MAAtB,GAA+BD;AACvC+B,IAAAA,QAAQ,EAAC;IALb,eAOIjC,aAAA,CAAC4B,GAAD;AAAK6B,IAAAA,OAAO,EAAC;AAAQC,IAAAA,aAAa,EAAC;GAAnC,EACK3C,QADL,CAPJ,CADJ;AAaH;AAsBD;;;;;;;;SAOgB4C;MACZ9C,kCAAAA;gCACAiC;MAAAA,6CAAc;MACX9B;;AAEH,sBACIhB,aAAA,SAAA,MAAA,EACK8C,WAAW,gBAAG9C,aAAA,CAACuD,OAAD,MAAA,CAAH,GAAiB,IADjC,eAEIvD,aAAA,CAAC4B,GAAD;AAAKD,IAAAA,EAAE,EAAC;KAAaX;AAAOI,IAAAA,SAAS,EAAEP;AAA2B4C,IAAAA,OAAO,EAAC;IAA1E,CAFJ,CADJ;AAMH;AAGD;AACA;;AAEA;;;;;SAIgBG;MAAe7C,iBAAAA;MAAaC;;AACxC,sBACIhB,aAAA,CAAC2D,WAAD,oBAAiB3C,MAAjB,eACIhB,aAAA,CAAC6D,MAAD;AAAQC,IAAAA,KAAK,EAAC;AAAQX,IAAAA,KAAK,EAAC;GAA5B,EACKnD,QAAA,CAAe+D,GAAf,CAAmBhD,QAAnB,EAA6B,UAACiD,KAAD;AAAA,wBAC1BhE,aAAA,MAAA,MAAA,EAAMgE,KAAN,CAD0B;AAAA,GAA7B,CADL,CADJ,CADJ;AASH;;;;"}
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../src/new-components/modal/modal.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport { DialogOverlay, DialogContent } from '@reach/dialog'\nimport FocusLock from 'react-focus-lock'\n\nimport { CloseIcon } from '../icons/close-icon'\nimport { Column, Columns } from '../columns'\nimport { Inline } from '../inline'\nimport { Divider } from '../divider'\nimport { Box } from '../box'\nimport { Button, ButtonProps } from '../button'\n\nimport styles from './modal.module.css'\n\ntype ModalWidth = 'small' | 'medium' | 'large' | 'xlarge' | 'full'\ntype ModalHeightMode = 'expand' | 'fitContent'\n\n//\n// ModalContext\n//\n\ntype ModalContextValue = {\n onDismiss?(this: void): void\n height: ModalHeightMode\n}\n\nconst ModalContext = React.createContext<ModalContextValue>({\n onDismiss: undefined,\n height: 'fitContent',\n})\n\n//\n// Modal container\n//\n\ntype DivProps = Omit<\n React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLDivElement>, HTMLDivElement>,\n 'className' | 'children'\n>\n\nexport type ModalProps = DivProps & {\n /**\n * The content of the modal.\n */\n children: React.ReactNode\n /**\n * Whether the modal is open and visible or not.\n */\n isOpen: boolean\n /**\n * Called when the user triggers closing the modal.\n */\n onDismiss?(): void\n /**\n * A descriptive setting for how wide the modal should aim to be, depending on how much space\n * it has on screen.\n * @default 'medium'\n */\n width?: ModalWidth\n /**\n * A descriptive setting for how tall the modal should aim to be.\n *\n * - 'expand': the modal aims to fill most of the available screen height, leaving only a small\n * padding above and below.\n * - 'fitContent': the modal shrinks to the smallest size that allow it to fit its content.\n *\n * In either case, if content does not fit, the content of the main body is set to scroll\n * (provided you use `ModalBody`) so that the modal never has to strech vertically beyond the\n * viewport boundaries.\n *\n * If you do not use `ModalBody`, the modal still prevents overflow, and you are in charge of\n * the inner layout to ensure scroll, or whatever other strategy you may want.\n */\n height?: ModalHeightMode\n /**\n * Whether to set or not the focus initially to the first focusable element inside the modal.\n */\n autoFocus?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\nfunction isNotInternalFrame(element: HTMLElement) {\n return !(element.ownerDocument === document && element.tagName.toLowerCase() === 'iframe')\n}\n\n/**\n * Renders a modal that sits on top of the rest of the content in the entire page.\n *\n * Follows the WAI-ARIA Dialog (Modal) Pattern.\n *\n * @see ModalHeader\n * @see ModalFooter\n * @see ModalBody\n */\nexport function Modal({\n isOpen,\n onDismiss,\n height = 'fitContent',\n width = 'medium',\n exceptionallySetClassName,\n autoFocus = true,\n children,\n ...props\n}: ModalProps) {\n const contextValue: ModalContextValue = React.useMemo(() => ({ onDismiss, height }), [\n onDismiss,\n height,\n ])\n\n return (\n <DialogOverlay\n isOpen={isOpen}\n onDismiss={onDismiss}\n dangerouslyBypassFocusLock // We're setting up our own focus lock below\n className={classNames(styles.overlay, styles[height], styles[width])}\n data-testid=\"modal-overlay\"\n >\n <FocusLock autoFocus={autoFocus} whiteList={isNotInternalFrame}>\n <DialogContent\n {...props}\n as={Box}\n borderRadius=\"full\"\n background=\"default\"\n display=\"flex\"\n flexDirection=\"column\"\n overflow=\"hidden\"\n height={height === 'expand' ? 'full' : undefined}\n flexGrow={height === 'expand' ? 1 : 0}\n className={[exceptionallySetClassName, styles.container]}\n >\n <ModalContext.Provider value={contextValue}>{children}</ModalContext.Provider>\n </DialogContent>\n </FocusLock>\n </DialogOverlay>\n )\n}\n\n//\n// ModalCloseButton\n//\n\nexport type ModalCloseButtonProps = Omit<\n ButtonProps,\n 'type' | 'children' | 'variant' | 'icon' | 'startIcon' | 'endIcon' | 'disabled' | 'loading'\n> & {\n /**\n * The descriptive label of the button.\n */\n 'aria-label': string\n}\n\n/**\n * The close button rendered by ModalHeader. Provided independently so that consumers can customize\n * the button's label.\n *\n * @see ModalHeader\n */\nexport function ModalCloseButton(props: ModalCloseButtonProps) {\n const { onDismiss } = React.useContext(ModalContext)\n return <Button {...props} variant=\"quaternary\" onClick={onDismiss} icon={<CloseIcon />} />\n}\n\n//\n// ModalHeader\n//\n\nexport type ModalHeaderProps = DivProps & {\n /**\n * The content of the header.\n */\n children: React.ReactNode\n /**\n * Allows to provide a custom button element, or to omit the close button if set to false.\n * @see ModalCloseButton\n */\n button?: React.ReactNode | boolean\n /**\n * Whether to render a divider line below the header.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal header area with an optional close button.\n *\n * @see Modal\n * @see ModalFooter\n * @see ModalBody\n */\nexport function ModalHeader({\n children,\n button = true,\n withDivider = false,\n exceptionallySetClassName,\n ...props\n}: ModalHeaderProps) {\n return (\n <>\n <Box\n {...props}\n as=\"header\"\n paddingLeft=\"large\"\n paddingRight=\"small\"\n paddingY=\"small\"\n className={exceptionallySetClassName}\n >\n <Columns space=\"large\" alignY=\"center\">\n <Column width=\"auto\">{children}</Column>\n <Column width=\"content\" exceptionallySetClassName={styles.buttonContainer}>\n {typeof button !== 'boolean' ? (\n button\n ) : button === true ? (\n <ModalCloseButton aria-label=\"Close modal\" />\n ) : null}\n </Column>\n </Columns>\n </Box>\n {withDivider ? <Divider /> : null}\n </>\n )\n}\n\n//\n// ModalBody\n//\n\nexport type ModalBodyProps = DivProps & {\n /**\n * The content of the modal body.\n */\n children: React.ReactNode\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders the body of a modal.\n *\n * Convenient to use alongside ModalHeader and/or ModalFooter as needed. It ensures, among other\n * things, that the contet of the modal body expands or contracts depending on the modal height\n * setting or the size of the content. The body content also automatically scrolls when it's too\n * large to fit the available space.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalFooter\n */\nexport function ModalBody({ exceptionallySetClassName, children, ...props }: ModalBodyProps) {\n const { height } = React.useContext(ModalContext)\n return (\n <Box\n {...props}\n className={exceptionallySetClassName}\n flexGrow={height === 'expand' ? 1 : 0}\n height={height === 'expand' ? 'full' : undefined}\n overflow=\"auto\"\n >\n <Box padding=\"large\" paddingBottom=\"xxlarge\">\n {children}\n </Box>\n </Box>\n )\n}\n\n//\n// ModalFooter\n//\n\nexport type ModalFooterProps = DivProps & {\n /**\n * The contant of the modal footer.\n */\n children: React.ReactNode\n /**\n * Whether to render a divider line below the footer.\n * @default false\n */\n withDivider?: boolean\n /**\n * A escape hatch in case you need to provide a custom class name to the container element.\n */\n exceptionallySetClassName?: string\n}\n\n/**\n * Renders a standard modal footer area.\n *\n * @see Modal\n * @see ModalHeader\n * @see ModalBody\n */\nexport function ModalFooter({\n exceptionallySetClassName,\n withDivider = false,\n ...props\n}: ModalFooterProps) {\n return (\n <>\n {withDivider ? <Divider /> : null}\n <Box as=\"footer\" {...props} className={exceptionallySetClassName} padding=\"large\" />\n </>\n )\n}\n\n//\n// ModalActions\n//\n\n/**\n * A specific version of the ModalFooter, tailored to showing an inline list of actions (buttons).\n * @see ModalFooter\n */\nexport function ModalActions({ children, ...props }: ModalFooterProps) {\n return (\n <ModalFooter {...props}>\n <Inline align=\"right\" space=\"large\">\n {React.Children.map(children, (child) => (\n <div>{child}</div>\n ))}\n </Inline>\n </ModalFooter>\n )\n}\n"],"names":["ModalContext","React","onDismiss","undefined","height","isNotInternalFrame","element","ownerDocument","document","tagName","toLowerCase","Modal","isOpen","width","exceptionallySetClassName","autoFocus","children","props","contextValue","DialogOverlay","dangerouslyBypassFocusLock","className","classNames","styles","overlay","FocusLock","whiteList","DialogContent","as","Box","borderRadius","background","display","flexDirection","overflow","flexGrow","container","Provider","value","ModalCloseButton","Button","variant","onClick","icon","CloseIcon","ModalHeader","button","withDivider","paddingLeft","paddingRight","paddingY","Columns","space","alignY","Column","buttonContainer","Divider","ModalBody","padding","paddingBottom","ModalFooter","ModalActions","Inline","align","map","child"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,IAAMA,YAAY,gBAAGC,aAAA,CAAuC;AACxDC,EAAAA,SAAS,EAAEC,SAD6C;AAExDC,EAAAA,MAAM,EAAE;AAFgD,CAAvC,CAArB;;AA0DA,SAASC,kBAAT,CAA4BC,OAA5B;AACI,SAAO,EAAEA,OAAO,CAACC,aAAR,KAA0BC,QAA1B,IAAsCF,OAAO,CAACG,OAAR,CAAgBC,WAAhB,OAAkC,QAA1E,CAA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AAQA,MAAR;;AACA,sBACIH,aAAA,CAAC4B,GAAD,oBACQZ;AACJI,IAAAA,SAAS,EAAEP;AACXqB,IAAAA,QAAQ,EAAE/B,MAAM,KAAK,QAAX,GAAsB,CAAtB,GAA0B;AACpCA,IAAAA,MAAM,EAAEA,MAAM,KAAK,QAAX,GAAsB,MAAtB,GAA+BD;AACvC+B,IAAAA,QAAQ,EAAC;IALb,eAOIjC,aAAA,CAAC4B,GAAD;AAAK6B,IAAAA,OAAO,EAAC;AAAQC,IAAAA,aAAa,EAAC;GAAnC,EACK3C,QADL,CAPJ,CADJ;AAaH;AAsBD;;;;;;;;SAOgB4C;MACZ9C,kCAAAA;gCACAiC;MAAAA,6CAAc;MACX9B;;AAEH,sBACIhB,aAAA,SAAA,MAAA,EACK8C,WAAW,gBAAG9C,aAAA,CAACuD,OAAD,MAAA,CAAH,GAAiB,IADjC,eAEIvD,aAAA,CAAC4B,GAAD;AAAKD,IAAAA,EAAE,EAAC;KAAaX;AAAOI,IAAAA,SAAS,EAAEP;AAA2B4C,IAAAA,OAAO,EAAC;IAA1E,CAFJ,CADJ;AAMH;AAGD;AACA;;AAEA;;;;;SAIgBG;MAAe7C,iBAAAA;MAAaC;;AACxC,sBACIhB,aAAA,CAAC2D,WAAD,oBAAiB3C,MAAjB,eACIhB,aAAA,CAAC6D,MAAD;AAAQC,IAAAA,KAAK,EAAC;AAAQX,IAAAA,KAAK,EAAC;GAA5B,EACKnD,QAAA,CAAe+D,GAAf,CAAmBhD,QAAnB,EAA6B,UAACiD,KAAD;AAAA,wBAC1BhE,aAAA,MAAA,MAAA,EAAMgE,KAAN,CAD0B;AAAA,GAA7B,CADL,CADJ,CADJ;AASH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var modules_8f59d13b = {"reach-portal":"
|
|
1
|
+
var modules_8f59d13b = {"reach-portal":"dddb40c3","fadein":"_955f2d73","fitContent":"_95c7550e","container":"_88079712","full":"_4779d078","large":"_5fd86231","medium":"bdfb5931","small":"_4e848a11","xlarge":"d673fba2","overlay":"ea9ae0cc","expand":"a8bf8a4f","buttonContainer":"_44d6850e"};
|
|
2
2
|
|
|
3
3
|
export default modules_8f59d13b;
|
|
4
4
|
//# sourceMappingURL=modal.module.css.js.map
|
|
@@ -10,6 +10,7 @@ import { PasswordHiddenIcon } from '../icons/password-hidden-icon.js';
|
|
|
10
10
|
import styles from './password-field.module.css.js';
|
|
11
11
|
import styles$1 from '../text-field/text-field.module.css.js';
|
|
12
12
|
|
|
13
|
+
var _excluded = ["label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth", "togglePasswordLabel", "hidden", "aria-describedby"];
|
|
13
14
|
var PasswordField = /*#__PURE__*/forwardRef(function PasswordField(_ref, ref) {
|
|
14
15
|
var label = _ref.label,
|
|
15
16
|
secondaryLabel = _ref.secondaryLabel,
|
|
@@ -20,7 +21,7 @@ var PasswordField = /*#__PURE__*/forwardRef(function PasswordField(_ref, ref) {
|
|
|
20
21
|
togglePasswordLabel = _ref$togglePasswordLa === void 0 ? 'Toggle password visibility' : _ref$togglePasswordLa,
|
|
21
22
|
hidden = _ref.hidden,
|
|
22
23
|
ariaDescribedBy = _ref['aria-describedby'],
|
|
23
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
24
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
25
|
|
|
25
26
|
var id = useId(props.id);
|
|
26
27
|
var internalRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-field.js","sources":["../../../src/new-components/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useForkRef } from 'reakit-utils'\nimport { Tooltip } from '../../components/tooltip'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport { useId } from '../common-helpers'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport styles from './password-field.module.css'\nimport textFieldStyles from '../text-field/text-field.module.css'\n\nimport type { TextFieldProps } from '../text-field'\n\ntype PasswordFieldProps = Omit<TextFieldProps, 'type'> & {\n togglePasswordLabel?: string\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n {\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n togglePasswordLabel = 'Toggle password visibility',\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n const id = useId(props.id)\n const internalRef = React.useRef<HTMLInputElement>(null)\n const inputRef = useForkRef(internalRef, ref)\n\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n\n function togglePasswordVisibility() {\n setPasswordVisible((v) => !v)\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[styles.inputWrapper, textFieldStyles.inputWrapper]}\n >\n <input\n {...props}\n {...extraProps}\n ref={inputRef}\n type={isPasswordVisible ? 'text' : 'password'}\n />\n <Tooltip content={togglePasswordLabel}>\n <button\n type=\"button\"\n onClick={togglePasswordVisibility}\n aria-label={togglePasswordLabel}\n tabIndex={-1}\n >\n {isPasswordVisible ? (\n <PasswordVisibleIcon aria-hidden />\n ) : (\n <PasswordHiddenIcon aria-hidden />\n )}\n </button>\n </Tooltip>\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","ref","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","togglePasswordLabel","hidden","ariaDescribedBy","props","id","useId","internalRef","inputRef","useForkRef","isPasswordVisible","setPasswordVisible","togglePasswordVisibility","v","current","focus","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","textFieldStyles","type","Tooltip","content","onClick","tabIndex","PasswordVisibleIcon","PasswordHiddenIcon"],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-field.js","sources":["../../../src/new-components/password-field/password-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useForkRef } from 'reakit-utils'\nimport { Tooltip } from '../../components/tooltip'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport { useId } from '../common-helpers'\n\nimport { PasswordVisibleIcon } from '../icons/password-visible-icon'\nimport { PasswordHiddenIcon } from '../icons/password-hidden-icon'\n\nimport styles from './password-field.module.css'\nimport textFieldStyles from '../text-field/text-field.module.css'\n\nimport type { TextFieldProps } from '../text-field'\n\ntype PasswordFieldProps = Omit<TextFieldProps, 'type'> & {\n togglePasswordLabel?: string\n}\n\nconst PasswordField = React.forwardRef<HTMLInputElement, PasswordFieldProps>(function PasswordField(\n {\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n togglePasswordLabel = 'Toggle password visibility',\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n const id = useId(props.id)\n const internalRef = React.useRef<HTMLInputElement>(null)\n const inputRef = useForkRef(internalRef, ref)\n\n const [isPasswordVisible, setPasswordVisible] = React.useState(false)\n\n function togglePasswordVisibility() {\n setPasswordVisible((v) => !v)\n internalRef.current?.focus()\n }\n\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n className={[styles.inputWrapper, textFieldStyles.inputWrapper]}\n >\n <input\n {...props}\n {...extraProps}\n ref={inputRef}\n type={isPasswordVisible ? 'text' : 'password'}\n />\n <Tooltip content={togglePasswordLabel}>\n <button\n type=\"button\"\n onClick={togglePasswordVisibility}\n aria-label={togglePasswordLabel}\n tabIndex={-1}\n >\n {isPasswordVisible ? (\n <PasswordVisibleIcon aria-hidden />\n ) : (\n <PasswordHiddenIcon aria-hidden />\n )}\n </button>\n </Tooltip>\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { PasswordField }\nexport type { PasswordFieldProps }\n"],"names":["PasswordField","React","ref","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","togglePasswordLabel","hidden","ariaDescribedBy","props","id","useId","internalRef","inputRef","useForkRef","isPasswordVisible","setPasswordVisible","togglePasswordVisibility","v","current","focus","BaseField","extraProps","Box","display","alignItems","className","styles","inputWrapper","textFieldStyles","type","Tooltip","content","onClick","tabIndex","PasswordVisibleIcon","PasswordHiddenIcon"],"mappings":";;;;;;;;;;;;;IAmBMA,aAAa,gBAAGC,UAAA,CAAuD,SAASD,aAAT,OAYzEE,GAZyE;MAErEC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;MACAC,gBAAAA;mCACAC;MAAAA,yDAAsB;MACtBC,cAAAA;MACoBC,uBAApB;MACGC;;AAIP,MAAMC,EAAE,GAAGC,KAAK,CAACF,KAAK,CAACC,EAAP,CAAhB;AACA,MAAME,WAAW,GAAGb,MAAA,CAA+B,IAA/B,CAApB;AACA,MAAMc,QAAQ,GAAGC,UAAU,CAACF,WAAD,EAAcZ,GAAd,CAA3B;;AAEA,wBAAgDD,QAAA,CAAe,KAAf,CAAhD;AAAA,MAAOgB,iBAAP;AAAA,MAA0BC,kBAA1B;;AAEA,WAASC,wBAAT;;;AACID,IAAAA,kBAAkB,CAAC,UAACE,CAAD;AAAA,aAAO,CAACA,CAAR;AAAA,KAAD,CAAlB;AACA,4BAAAN,WAAW,CAACO,OAAZ,8EAAqBC,KAArB;AACH;;AAED,sBACIrB,aAAA,CAACsB,SAAD;AACIX,IAAAA,EAAE,EAAEA;AACJT,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNC,IAAAA,QAAQ,EAAEA;AACVE,IAAAA,MAAM,EAAEA;wBACUC;GARtB,EAUK,UAACc,UAAD;AAAA,wBACGvB,aAAA,CAACwB,GAAD;AACIC,MAAAA,OAAO,EAAC;AACRC,MAAAA,UAAU,EAAC;AACXC,MAAAA,SAAS,EAAE,CAACC,MAAM,CAACC,YAAR,EAAsBC,QAAe,CAACD,YAAtC;KAHf,eAKI7B,aAAA,QAAA,oBACQU,OACAa;AACJtB,MAAAA,GAAG,EAAEa;AACLiB,MAAAA,IAAI,EAAEf,iBAAiB,GAAG,MAAH,GAAY;MAJvC,CALJ,eAWIhB,aAAA,CAACgC,OAAD;AAASC,MAAAA,OAAO,EAAE1B;KAAlB,eACIP,aAAA,SAAA;AACI+B,MAAAA,IAAI,EAAC;AACLG,MAAAA,OAAO,EAAEhB;oBACGX;AACZ4B,MAAAA,QAAQ,EAAE,CAAC;KAJf,EAMKnB,iBAAiB,gBACdhB,aAAA,CAACoC,mBAAD;;KAAA,CADc,gBAGdpC,aAAA,CAACqC,kBAAD;;KAAA,CATR,CADJ,CAXJ,CADH;AAAA,GAVL,CADJ;AAyCH,CAlEqB;;;;"}
|
|
@@ -4,6 +4,7 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './select-field.module.css.js';
|
|
6
6
|
|
|
7
|
+
var _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth", "children", "hidden", "aria-describedby"];
|
|
7
8
|
var SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
8
9
|
var id = _ref.id,
|
|
9
10
|
label = _ref.label,
|
|
@@ -14,7 +15,7 @@ var SelectField = /*#__PURE__*/forwardRef(function SelectField(_ref, ref) {
|
|
|
14
15
|
children = _ref.children,
|
|
15
16
|
hidden = _ref.hidden,
|
|
16
17
|
ariaDescribedBy = _ref['aria-describedby'],
|
|
17
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
18
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
19
|
|
|
19
20
|
return /*#__PURE__*/createElement(BaseField, {
|
|
20
21
|
id: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-field.js","sources":["../../../src/new-components/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ntype SelectFieldProps = FieldComponentProps<HTMLSelectElement>\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.selectWrapper}>\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","children","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","selectWrapper","SelectChevron","width","height","fill","xmlns","d"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select-field.js","sources":["../../../src/new-components/select-field/select-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './select-field.module.css'\n\ntype SelectFieldProps = FieldComponentProps<HTMLSelectElement>\n\nconst SelectField = React.forwardRef<HTMLSelectElement, SelectFieldProps>(function SelectField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n children,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.selectWrapper}>\n <select {...props} {...extraProps} ref={ref}>\n {children}\n </select>\n <SelectChevron aria-hidden />\n </Box>\n )}\n </BaseField>\n )\n})\n\nfunction SelectChevron(props: JSX.IntrinsicElements['svg']) {\n return (\n <svg width=\"16\" height=\"16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" {...props}>\n <path\n d=\"M11.646 5.646a.5.5 0 0 1 .708.708l-4 4a.5.5 0 0 1-.708 0l-4-4a.5.5 0 1 1 .708-.708L8 9.293l3.646-3.647z\"\n fill=\"currentColor\"\n />\n </svg>\n )\n}\n\nexport { SelectField }\nexport type { SelectFieldProps }\n"],"names":["SelectField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","children","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","selectWrapper","SelectChevron","width","height","fill","xmlns","d"],"mappings":";;;;;;;IAOMA,WAAW,gBAAGC,UAAA,CAAsD,SAASD,WAAT,OAatEE,GAbsE;MAElEC,UAAAA;MACAC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;MACAC,gBAAAA;MACAC,gBAAAA;MACAC,cAAAA;MACoBC,uBAApB;MACGC;;AAIP,sBACIX,aAAA,CAACY,SAAD;AACIV,IAAAA,EAAE,EAAEA;AACJC,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNC,IAAAA,QAAQ,EAAEA;AACVE,IAAAA,MAAM,EAAEA;wBACUC;GARtB,EAUK,UAACG,UAAD;AAAA,wBACGb,aAAA,CAACc,GAAD;AAAKC,MAAAA,SAAS,EAAEC,MAAM,CAACC;KAAvB,eACIjB,aAAA,SAAA,oBAAYW,OAAWE;AAAYZ,MAAAA,GAAG,EAAEA;MAAxC,EACKO,QADL,CADJ,eAIIR,aAAA,CAACkB,aAAD;;KAAA,CAJJ,CADH;AAAA,GAVL,CADJ;AAqBH,CApCmB;;AAsCpB,SAASA,aAAT,CAAuBP,KAAvB;AACI,sBACIX,aAAA,MAAA;AAAKmB,IAAAA,KAAK,EAAC;AAAKC,IAAAA,MAAM,EAAC;AAAKC,IAAAA,IAAI,EAAC;AAAOC,IAAAA,KAAK,EAAC;KAAiCX,MAA/E,eACIX,aAAA,OAAA;AACIuB,IAAAA,CAAC,EAAC;AACFF,IAAAA,IAAI,EAAC;GAFT,CADJ,CADJ;AAQH;;;;"}
|
|
@@ -7,6 +7,7 @@ import { Divider } from '../divider/divider.js';
|
|
|
7
7
|
import flattenChildren from 'react-keyed-flatten-children';
|
|
8
8
|
import styles from './stack.module.css.js';
|
|
9
9
|
|
|
10
|
+
var _excluded = ["as", "space", "align", "dividers", "children", "exceptionallySetClassName"];
|
|
10
11
|
var Stack = /*#__PURE__*/polymorphicComponent(function Stack(_ref, ref) {
|
|
11
12
|
var as = _ref.as,
|
|
12
13
|
space = _ref.space,
|
|
@@ -16,7 +17,7 @@ var Stack = /*#__PURE__*/polymorphicComponent(function Stack(_ref, ref) {
|
|
|
16
17
|
dividers = _ref$dividers === void 0 ? 'none' : _ref$dividers,
|
|
17
18
|
children = _ref.children,
|
|
18
19
|
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
19
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
20
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
21
|
|
|
21
22
|
var alignProps = align === 'start' ? undefined : {
|
|
22
23
|
width: 'full',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","sources":["../../../src/new-components/stack/stack.tsx"],"sourcesContent":["import * as React from 'react'\nimport flattenChildren from 'react-keyed-flatten-children'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { getClassNames, mapResponsiveProp } from '../responsive-props'\nimport { Box } from '../box'\nimport { Divider } from '../divider'\n\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { DividerWeight, Space } from '../common-types'\nimport type { BoxProps, ReusableBoxProps } from '../box'\n\nimport styles from './stack.module.css'\n\ntype Align = 'start' | 'center' | 'end'\n\ninterface StackProps extends ReusableBoxProps {\n /** Space between items */\n space?: ResponsiveProp<Space>\n /** Align items horizontally */\n align?: ResponsiveProp<Align>\n /** The weight of the dividers to add. Defaults to 'none', which means no dividers are added */\n dividers?: DividerWeight\n}\n\nconst Stack = polymorphicComponent<'div', StackProps>(function Stack(\n {\n as,\n space,\n align = 'start',\n dividers = 'none',\n children,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const alignProps: BoxProps | undefined =\n align === 'start'\n ? undefined\n : {\n width: 'full',\n flexDirection: 'column',\n display: 'flex',\n alignItems: mapResponsiveProp(align, (align) =>\n align === 'start' ? 'flexStart' : align === 'end' ? 'flexEnd' : 'center',\n ),\n }\n\n return (\n <Box\n {...props}\n {...alignProps}\n as={as}\n className={[exceptionallySetClassName, getClassNames(styles, 'space', space)]}\n ref={ref}\n >\n {dividers !== 'none'\n ? React.Children.map(flattenChildren(children), (child, index) =>\n index > 0 ? (\n <>\n <Divider weight={dividers} />\n {child}\n </>\n ) : (\n child\n ),\n )\n : children}\n </Box>\n )\n})\n\nexport type { StackProps }\nexport { Stack }\n"],"names":["Stack","polymorphicComponent","ref","as","space","align","dividers","children","exceptionallySetClassName","props","alignProps","undefined","width","flexDirection","display","alignItems","mapResponsiveProp","React","Box","className","getClassNames","styles","map","flattenChildren","child","index","Divider","weight"],"mappings":"
|
|
1
|
+
{"version":3,"file":"stack.js","sources":["../../../src/new-components/stack/stack.tsx"],"sourcesContent":["import * as React from 'react'\nimport flattenChildren from 'react-keyed-flatten-children'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport { getClassNames, mapResponsiveProp } from '../responsive-props'\nimport { Box } from '../box'\nimport { Divider } from '../divider'\n\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { DividerWeight, Space } from '../common-types'\nimport type { BoxProps, ReusableBoxProps } from '../box'\n\nimport styles from './stack.module.css'\n\ntype Align = 'start' | 'center' | 'end'\n\ninterface StackProps extends ReusableBoxProps {\n /** Space between items */\n space?: ResponsiveProp<Space>\n /** Align items horizontally */\n align?: ResponsiveProp<Align>\n /** The weight of the dividers to add. Defaults to 'none', which means no dividers are added */\n dividers?: DividerWeight\n}\n\nconst Stack = polymorphicComponent<'div', StackProps>(function Stack(\n {\n as,\n space,\n align = 'start',\n dividers = 'none',\n children,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const alignProps: BoxProps | undefined =\n align === 'start'\n ? undefined\n : {\n width: 'full',\n flexDirection: 'column',\n display: 'flex',\n alignItems: mapResponsiveProp(align, (align) =>\n align === 'start' ? 'flexStart' : align === 'end' ? 'flexEnd' : 'center',\n ),\n }\n\n return (\n <Box\n {...props}\n {...alignProps}\n as={as}\n className={[exceptionallySetClassName, getClassNames(styles, 'space', space)]}\n ref={ref}\n >\n {dividers !== 'none'\n ? React.Children.map(flattenChildren(children), (child, index) =>\n index > 0 ? (\n <>\n <Divider weight={dividers} />\n {child}\n </>\n ) : (\n child\n ),\n )\n : children}\n </Box>\n )\n})\n\nexport type { StackProps }\nexport { Stack }\n"],"names":["Stack","polymorphicComponent","ref","as","space","align","dividers","children","exceptionallySetClassName","props","alignProps","undefined","width","flexDirection","display","alignItems","mapResponsiveProp","React","Box","className","getClassNames","styles","map","flattenChildren","child","index","Divider","weight"],"mappings":";;;;;;;;;;IAwBMA,KAAK,gBAAGC,oBAAoB,CAAoB,SAASD,KAAT,OAUlDE,GAVkD;MAE9CC,UAAAA;MACAC,aAAAA;wBACAC;MAAAA,gCAAQ;2BACRC;MAAAA,sCAAW;MACXC,gBAAAA;MACAC,iCAAAA;MACGC;;AAIP,MAAMC,UAAU,GACZL,KAAK,KAAK,OAAV,GACMM,SADN,GAEM;AACIC,IAAAA,KAAK,EAAE,MADX;AAEIC,IAAAA,aAAa,EAAE,QAFnB;AAGIC,IAAAA,OAAO,EAAE,MAHb;AAIIC,IAAAA,UAAU,EAAEC,iBAAiB,CAACX,KAAD,EAAQ,UAACA,KAAD;AAAA,aACjCA,KAAK,KAAK,OAAV,GAAoB,WAApB,GAAkCA,KAAK,KAAK,KAAV,GAAkB,SAAlB,GAA8B,QAD/B;AAAA,KAAR;AAJjC,GAHV;AAYA,sBACIY,aAAA,CAACC,GAAD,oBACQT,OACAC;AACJP,IAAAA,EAAE,EAAEA;AACJgB,IAAAA,SAAS,EAAE,CAACX,yBAAD,EAA4BY,aAAa,CAACC,MAAD,EAAS,OAAT,EAAkBjB,KAAlB,CAAzC;AACXF,IAAAA,GAAG,EAAEA;IALT,EAOKI,QAAQ,KAAK,MAAb,GACKW,QAAA,CAAeK,GAAf,CAAmBC,eAAe,CAAChB,QAAD,CAAlC,EAA8C,UAACiB,KAAD,EAAQC,KAAR;AAAA,WAC1CA,KAAK,GAAG,CAAR,gBACIR,aAAA,SAAA,MAAA,eACIA,aAAA,CAACS,OAAD;AAASC,MAAAA,MAAM,EAAErB;KAAjB,CADJ,EAEKkB,KAFL,CADJ,GAMIA,KAPsC;AAAA,GAA9C,CADL,GAWKjB,QAlBV,CADJ;AAsBH,CA9CiC;;;;"}
|
|
@@ -8,6 +8,7 @@ import { useId } from '../common-helpers.js';
|
|
|
8
8
|
import { FieldHint } from '../base-field/base-field.js';
|
|
9
9
|
import styles from './switch-field.module.css.js';
|
|
10
10
|
|
|
11
|
+
var _excluded = ["label", "hint", "disabled", "hidden", "defaultChecked", "id", "aria-describedby", "onChange"];
|
|
11
12
|
var SwitchField = /*#__PURE__*/forwardRef(function SwitchField(_ref, ref) {
|
|
12
13
|
var _ref2, _props$checked, _props$checked2;
|
|
13
14
|
|
|
@@ -20,7 +21,7 @@ var SwitchField = /*#__PURE__*/forwardRef(function SwitchField(_ref, ref) {
|
|
|
20
21
|
originalId = _ref.id,
|
|
21
22
|
originalAriaDescribedBy = _ref['aria-describedby'],
|
|
22
23
|
_onChange = _ref.onChange,
|
|
23
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
24
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
24
25
|
|
|
25
26
|
var id = useId(originalId);
|
|
26
27
|
var hintId = useId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-field.js","sources":["../../../src/new-components/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../common-helpers'\nimport styles from './switch-field.module.css'\n\ntype SwitchFieldProps = Omit<\n FieldComponentProps<HTMLInputElement>,\n 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth'\n>\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["SwitchField","React","ref","label","hint","disabled","hidden","defaultChecked","originalId","id","originalAriaDescribedBy","onChange","props","useId","hintId","ariaDescribedBy","undefined","checked","checkedState","setChecked","isChecked","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","handle","Text","exceptionallySetClassName","FieldHint"],"mappings":"
|
|
1
|
+
{"version":3,"file":"switch-field.js","sources":["../../../src/new-components/switch-field/switch-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { Stack } from '../stack'\nimport { Text } from '../text'\nimport { HiddenVisually } from '../hidden-visually'\nimport { FieldComponentProps, FieldHint } from '../base-field'\nimport { useId } from '../common-helpers'\nimport styles from './switch-field.module.css'\n\ntype SwitchFieldProps = Omit<\n FieldComponentProps<HTMLInputElement>,\n 'type' | 'secondaryLabel' | 'auxiliaryLabel' | 'maxWidth'\n>\n\nconst SwitchField = React.forwardRef<HTMLInputElement, SwitchFieldProps>(function SwitchField(\n {\n label,\n hint,\n disabled = false,\n hidden,\n defaultChecked,\n id: originalId,\n 'aria-describedby': originalAriaDescribedBy,\n onChange,\n ...props\n },\n ref,\n) {\n const id = useId(originalId)\n const hintId = useId()\n const ariaDescribedBy = originalAriaDescribedBy ?? (hint ? hintId : undefined)\n const [checkedState, setChecked] = React.useState(props.checked ?? defaultChecked ?? false)\n const isChecked = props.checked ?? checkedState\n return (\n <Stack space=\"small\" hidden={hidden}>\n <Box\n className={[\n styles.container,\n disabled ? styles.disabled : null,\n isChecked ? styles.checked : null,\n ]}\n as=\"label\"\n display=\"flex\"\n alignItems=\"center\"\n >\n <Box\n position=\"relative\"\n display=\"inlineBlock\"\n overflow=\"visible\"\n marginRight=\"small\"\n flexShrink={0}\n className={styles.toggle}\n >\n <HiddenVisually>\n <input\n {...props}\n id={id}\n type=\"checkbox\"\n disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n checked={isChecked}\n onChange={(event) => {\n onChange?.(event)\n if (!event.defaultPrevented) {\n setChecked(event.currentTarget.checked)\n }\n }}\n />\n </HiddenVisually>\n <span className={styles.handle} />\n </Box>\n <Text exceptionallySetClassName={styles.label}>{label}</Text>\n </Box>\n {hint ? <FieldHint id={hintId}>{hint}</FieldHint> : null}\n </Stack>\n )\n})\n\nexport { SwitchField }\nexport type { SwitchFieldProps }\n"],"names":["SwitchField","React","ref","label","hint","disabled","hidden","defaultChecked","originalId","id","originalAriaDescribedBy","onChange","props","useId","hintId","ariaDescribedBy","undefined","checked","checkedState","setChecked","isChecked","Stack","space","Box","className","styles","container","as","display","alignItems","position","overflow","marginRight","flexShrink","toggle","HiddenVisually","type","event","defaultPrevented","currentTarget","handle","Text","exceptionallySetClassName","FieldHint"],"mappings":";;;;;;;;;;;IAcMA,WAAW,gBAAGC,UAAA,CAAqD,SAASD,WAAT,OAYrEE,GAZqE;;;MAEjEC,aAAAA;MACAC,YAAAA;2BACAC;MAAAA,sCAAW;MACXC,cAAAA;MACAC,sBAAAA;MACIC,kBAAJ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B,MAAAA,SAAQ,SAAR,IAAAA,SAAQ,WAAR,YAAAA,SAAQ,CAAG0B,KAAH,CAAR;;AACA,UAAI,CAACA,KAAK,CAACC,gBAAX,EAA6B;AACzBnB,QAAAA,UAAU,CAACkB,KAAK,CAACE,aAAN,CAAoBtB,OAArB,CAAV;AACH;AACJ;IAbL,CADJ,CARJ,eAyBIhB,aAAA,OAAA;AAAMuB,IAAAA,SAAS,EAAEC,MAAM,CAACe;GAAxB,CAzBJ,CAVJ,eAqCIvC,aAAA,CAACwC,IAAD;AAAMC,IAAAA,yBAAyB,EAAEjB,MAAM,CAACtB;GAAxC,EAAgDA,KAAhD,CArCJ,CADJ,EAwCKC,IAAI,gBAAGH,aAAA,CAAC0C,SAAD;AAAWlC,IAAAA,EAAE,EAAEK;GAAf,EAAwBV,IAAxB,CAAH,GAA+C,IAxCxD,CADJ;AA4CH,CA/DmB;;;;"}
|
|
@@ -7,6 +7,11 @@ import { useTabState, Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1
|
|
|
7
7
|
import { usePrevious } from '../../hooks/use-previous/use-previous.js';
|
|
8
8
|
import styles from './tabs.module.css.js';
|
|
9
9
|
|
|
10
|
+
var _excluded = ["color", "variant"],
|
|
11
|
+
_excluded2 = ["children", "space"],
|
|
12
|
+
_excluded3 = ["color", "variant"],
|
|
13
|
+
_excluded4 = ["children", "id", "as", "render"],
|
|
14
|
+
_excluded5 = ["color", "variant"];
|
|
10
15
|
var TabsContext = /*#__PURE__*/createContext(null);
|
|
11
16
|
/**
|
|
12
17
|
* Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.
|
|
@@ -58,7 +63,7 @@ function Tab(_ref2) {
|
|
|
58
63
|
|
|
59
64
|
var color = tabContextValue.color,
|
|
60
65
|
variant = tabContextValue.variant,
|
|
61
|
-
tabState = _objectWithoutPropertiesLoose(tabContextValue,
|
|
66
|
+
tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded);
|
|
62
67
|
|
|
63
68
|
return /*#__PURE__*/createElement(Tab$1, Object.assign({
|
|
64
69
|
className: classNames(styles.tab, styles["tab-" + (variant !== null && variant !== void 0 ? variant : '')], styles["tab-" + (color !== null && color !== void 0 ? color : '')]),
|
|
@@ -73,7 +78,7 @@ function TabList(_ref3) {
|
|
|
73
78
|
var children = _ref3.children,
|
|
74
79
|
_ref3$space = _ref3.space,
|
|
75
80
|
space = _ref3$space === void 0 ? 'medium' : _ref3$space,
|
|
76
|
-
props = _objectWithoutPropertiesLoose(_ref3,
|
|
81
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded2);
|
|
77
82
|
|
|
78
83
|
var tabContextValue = useContext(TabsContext);
|
|
79
84
|
|
|
@@ -81,7 +86,7 @@ function TabList(_ref3) {
|
|
|
81
86
|
return null;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
var tabState = _objectWithoutPropertiesLoose(tabContextValue,
|
|
89
|
+
var tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded3);
|
|
85
90
|
|
|
86
91
|
return /*#__PURE__*/createElement(TabList$1, Object.assign({}, props, tabState), /*#__PURE__*/createElement(Inline, {
|
|
87
92
|
space: space
|
|
@@ -97,7 +102,7 @@ var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
|
|
|
97
102
|
as = _ref4.as,
|
|
98
103
|
_ref4$render = _ref4.render,
|
|
99
104
|
render = _ref4$render === void 0 ? 'always' : _ref4$render,
|
|
100
|
-
props = _objectWithoutPropertiesLoose(_ref4,
|
|
105
|
+
props = _objectWithoutPropertiesLoose(_ref4, _excluded4);
|
|
101
106
|
|
|
102
107
|
var tabContextValue = useContext(TabsContext);
|
|
103
108
|
|
|
@@ -116,7 +121,7 @@ var TabPanel = /*#__PURE__*/polymorphicComponent(function TabPanel(_ref4, ref) {
|
|
|
116
121
|
return null;
|
|
117
122
|
}
|
|
118
123
|
|
|
119
|
-
var tabState = _objectWithoutPropertiesLoose(tabContextValue,
|
|
124
|
+
var tabState = _objectWithoutPropertiesLoose(tabContextValue, _excluded5);
|
|
120
125
|
|
|
121
126
|
return /*#__PURE__*/createElement(TabPanel$1, Object.assign({
|
|
122
127
|
tabId: id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStateReturn,\n} from 'reakit/Tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\nconst TabsContext = React.createContext<\n (TabStateReturn & Omit<TabsProps, 'children' | 'selectedId'>) | null\n>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab\n */\n selectedId?: string | null\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nexport function Tabs({\n children,\n selectedId,\n color = 'primary',\n variant = 'normal',\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId })\n const previousSelectedId = usePrevious(selectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectTab() {\n if (\n previousSelectedId !== selectedId &&\n selectedId !== actualSelectedId &&\n selectedId !== undefined\n ) {\n select(selectedId)\n }\n },\n [selectedId, actualSelectedId, select, previousSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n ...tabState,\n color,\n variant,\n }\n },\n // There is no guarantee that useTabState returns a stable object when there are no changes, so\n // following reakit/Tab's example we only return a new objet when any of its values have changed\n // eslint-disable-next-line\n [color, variant, ...Object.values(tabState)],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nexport function Tab({ children, id }: TabProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTab\n className={classNames(\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n {...tabState}\n >\n {children}\n </BaseTab>\n )\n}\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nexport function TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabList {...props} {...tabState}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nexport const TabPanel = polymorphicComponent<'div', TabPanelProps, 'omitClassName'>(\n function TabPanel(\n { children, id, as, render = 'always', ...props },\n ref,\n ): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...tabState} {...props} as={as} ref={ref}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n },\n)\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nexport function TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue.selectedId }) : null\n}\n"],"names":["TabsContext","React","Tabs","children","selectedId","color","variant","tabState","useTabState","previousSelectedId","usePrevious","actualSelectedId","select","selectTab","undefined","memoizedTabState","memoizeTabState","Object","values","Provider","value","Tab","id","tabContextValue","BaseTab","className","classNames","styles","tab","TabList","space","props","BaseTabList","Inline","TabPanel","polymorphicComponent","ref","as","render","tabRendered","setTabRendered","tabIsActive","trackTabRenderedState","BaseTabPanel","tabId","TabAwareSlot"],"mappings":";;;;;;;;;AAiBA,IAAMA,WAAW,gBAAGC,aAAA,CAElB,IAFkB,CAApB;AAqBA;;;;SAGgBC;MACZC,gBAAAA;MACAC,kBAAAA;wBACAC;MAAAA,gCAAQ;0BACRC;MAAAA,oCAAU;AAEV,MAAMC,QAAQ,GAAGC,WAAW,CAAC;AAAEJ,IAAAA,UAAU,EAAVA;AAAF,GAAD,CAA5B;AACA,MAAMK,kBAAkB,GAAGC,WAAW,CAACN,UAAD,CAAtC;MACoBO,mBAA6BJ,SAAzCH;MAA8BQ,SAAWL,SAAXK;AAEtCX,EAAAA,SAAA,CACI,SAASY,SAAT;AACI,QACIJ,kBAAkB,KAAKL,UAAvB,IACAA,UAAU,KAAKO,gBADf,IAEAP,UAAU,KAAKU,SAHnB,EAIE;AACEF,MAAAA,MAAM,CAACR,UAAD,CAAN;AACH;AACJ,GATL,EAUI,CAACA,UAAD,EAAaO,gBAAb,EAA+BC,MAA/B,EAAuCH,kBAAvC,CAVJ;AAaA,MAAMM,gBAAgB,GAAGd,OAAA,CACrB,SAASe,eAAT;AACI,6CACOT,QADP;AAEIF,MAAAA,KAAK,EAALA,KAFJ;AAGIC,MAAAA,OAAO,EAAPA;AAHJ;AAKH,GAPoB;AASrB;AACA;AAVqB,GAWpBD,KAXoB,EAWbC,OAXa,SAWDW,MAAM,CAACC,MAAP,CAAcX,QAAd,CAXC,EAAzB;AAcA,sBAAON,aAAA,CAACD,WAAW,CAACmB,QAAb;AAAsBC,IAAAA,KAAK,EAAEL;GAA7B,EAAgDZ,QAAhD,CAAP;AACH;AAUD;;;;SAGgBkB;MAAMlB,iBAAAA;MAAUmB,WAAAA;AAC5B,MAAMC,eAAe,GAAGtB,UAAA,CAAiBD,WAAjB,CAAxB;;AAEA,MAAI,CAACuB,eAAL,EAAsB;AAClB,WAAO,IAAP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AACH;AACJ,GALL,EAMI,CAACD,WAAD,EAAcE,WAAd,CANJ;;AASA,MAAI,CAAClB,eAAL,EAAsB;AAClB,WAAO,IAAP;AACH;;MAE0BhB,yCAAagB;;AAExC,sBACItB,aAAA,CAAC0C,UAAD;AAAcC,IAAAA,KAAK,EAAEtB;KAAQf,UAAcwB;AAAOM,IAAAA,EAAE,EAAEA;AAAID,IAAAA,GAAG,EAAEA;IAA/D,EACKE,MAAM,KAAK,QAAX,GAAsBnC,QAAtB,GAAiC,IADtC,EAEKmC,MAAM,KAAK,QAAX,IAAuBG,WAAvB,GAAqCtC,QAArC,GAAgD,IAFrD,EAGKmC,MAAM,KAAK,MAAX,KAAsBG,WAAW,IAAIF,WAArC,IAAoDpC,QAApD,GAA+D,IAHpE,CADJ;AAOH,CA/BuC;AA0C5C;;;;;SAIgB0C;MAAe1C,iBAAAA;AAC3B,MAAMoB,eAAe,GAAGtB,UAAA,CAAiBD,WAAjB,CAAxB;AAEA,SAAOuB,eAAe,GAAGpB,QAAQ,CAAC;AAAEC,IAAAA,UAAU,EAAEmB,eAAe,CAACnB;AAA9B,GAAD,CAAX,GAA0D,IAAhF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"tabs.js","sources":["../../../src/new-components/tabs/tabs.tsx"],"sourcesContent":["import * as React from 'react'\nimport classNames from 'classnames'\nimport {\n useTabState,\n Tab as BaseTab,\n TabList as BaseTabList,\n TabPanel as BaseTabPanel,\n TabStateReturn,\n} from 'reakit/Tab'\nimport { Inline } from '../inline'\nimport { usePrevious } from '../../hooks/use-previous'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport type { ResponsiveProp } from '../responsive-props'\nimport type { Space } from '../common-types'\n\nimport styles from './tabs.module.css'\n\nconst TabsContext = React.createContext<\n (TabStateReturn & Omit<TabsProps, 'children' | 'selectedId'>) | null\n>(null)\n\ntype TabsProps = {\n /** The `<Tabs>` component must be composed from a `<TabList>` and corresponding `<TabPanel>` components */\n children: React.ReactNode\n /**\n * Determines the primary colour of the tabs\n */\n color?: 'primary' | 'secondary' | 'tertiary'\n /**\n * Determines the style of the tabs\n */\n variant?: 'normal' | 'plain'\n /**\n * The id of the selected tab\n */\n selectedId?: string | null\n}\n\n/**\n * Used to group components that compose a set of tabs. There can only be one active tab within the same `<Tabs>` group.\n */\nexport function Tabs({\n children,\n selectedId,\n color = 'primary',\n variant = 'normal',\n}: TabsProps): React.ReactElement {\n const tabState = useTabState({ selectedId })\n const previousSelectedId = usePrevious(selectedId)\n const { selectedId: actualSelectedId, select } = tabState\n\n React.useEffect(\n function selectTab() {\n if (\n previousSelectedId !== selectedId &&\n selectedId !== actualSelectedId &&\n selectedId !== undefined\n ) {\n select(selectedId)\n }\n },\n [selectedId, actualSelectedId, select, previousSelectedId],\n )\n\n const memoizedTabState = React.useMemo(\n function memoizeTabState() {\n return {\n ...tabState,\n color,\n variant,\n }\n },\n // There is no guarantee that useTabState returns a stable object when there are no changes, so\n // following reakit/Tab's example we only return a new objet when any of its values have changed\n // eslint-disable-next-line\n [color, variant, ...Object.values(tabState)],\n )\n\n return <TabsContext.Provider value={memoizedTabState}>{children}</TabsContext.Provider>\n}\n\ntype TabProps = {\n /** The content to render inside of the tab button */\n children: React.ReactNode\n\n /** The tab's identifier. This must match its corresponding `<TabPanel>`'s id */\n id: string\n}\n\n/**\n * Represents the individual tab elements within the group. Each `<Tab>` must have a corresponding `<TabPanel>` component.\n */\nexport function Tab({ children, id }: TabProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTab\n className={classNames(\n styles.tab,\n styles[`tab-${variant ?? ''}`],\n styles[`tab-${color ?? ''}`],\n )}\n id={id}\n {...tabState}\n >\n {children}\n </BaseTab>\n )\n}\n\ntype TabListProps = (\n | {\n /** Labels the tab list for assistive technologies. This must be provided if `aria-labelledby` is omitted. */\n 'aria-label': string\n }\n | {\n /**\n * One or more element IDs used to label the tab list for assistive technologies. Required if\n * `aria-label` is omitted.\n */\n 'aria-labelledby': string\n }\n | {\n /**\n * For cases where multiple instances of the tab list exists, the duplicates may be marked as aria-hidden\n */\n 'aria-hidden': boolean\n }\n) & {\n /**\n * A list of `<Tab>` elements\n */\n children: React.ReactNode\n\n /**\n * Controls the spacing between tabs\n */\n space?: ResponsiveProp<Space>\n}\n\n/**\n * A component used to group `<Tab>` elements together.\n */\nexport function TabList({\n children,\n space = 'medium',\n ...props\n}: TabListProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabList {...props} {...tabState}>\n <Inline space={space}>{children}</Inline>\n </BaseTabList>\n )\n}\n\ntype TabPanelProps = {\n /** The content to be rendered inside the tab */\n children: React.ReactNode\n\n /** The tabPanel's identifier. This must match its corresponding `<Tab>`'s id */\n id: string\n\n /**\n * By default, the tab panel's content is always rendered even when they are not active. This behaviour can be changed to\n * 'active', which renders only when the tab is active, and 'lazy', meaning while inactive tab panels will not be rendered\n * initially, they will remain mounted once they are active until the entire Tabs tree is unmounted.\n */\n render?: 'always' | 'active' | 'lazy'\n}\n\n/**\n * Used to define the content to be rendered when a tab is active. Each `<TabPanel>` must have a corresponding `<Tab>` component.\n */\nexport const TabPanel = polymorphicComponent<'div', TabPanelProps, 'omitClassName'>(\n function TabPanel(\n { children, id, as, render = 'always', ...props },\n ref,\n ): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n const [tabRendered, setTabRendered] = React.useState(false)\n const tabIsActive = tabContextValue?.selectedId === id\n\n React.useEffect(\n function trackTabRenderedState() {\n if (!tabRendered && tabIsActive) {\n setTabRendered(true)\n }\n },\n [tabRendered, tabIsActive],\n )\n\n if (!tabContextValue) {\n return null\n }\n\n const { color, variant, ...tabState } = tabContextValue\n\n return (\n <BaseTabPanel tabId={id} {...tabState} {...props} as={as} ref={ref}>\n {render === 'always' ? children : null}\n {render === 'active' && tabIsActive ? children : null}\n {render === 'lazy' && (tabIsActive || tabRendered) ? children : null}\n </BaseTabPanel>\n )\n },\n)\n\ntype TabAwareSlotProps = {\n /**\n * Render prop used to provide the content to be rendered inside the slot. The render prop will be\n * called with the current `selectedId`\n */\n children: (provided: { selectedId?: string | null }) => React.ReactElement | null\n}\n\n/**\n * Allows content to be rendered based on the current tab being selected while outside of the TabPanel\n * component. Can be placed freely within the main `<Tabs>` component.\n */\nexport function TabAwareSlot({ children }: TabAwareSlotProps): React.ReactElement | null {\n const tabContextValue = React.useContext(TabsContext)\n\n return tabContextValue ? children({ selectedId: tabContextValue.selectedId }) : null\n}\n"],"names":["TabsContext","React","Tabs","children","selectedId","color","variant","tabState","useTabState","previousSelectedId","usePrevious","actualSelectedId","select","selectTab","undefined","memoizedTabState","memoizeTabState","Object","values","Provider","value","Tab","id","tabContextValue","BaseTab","className","classNames","styles","tab","TabList","space","props","BaseTabList","Inline","TabPanel","polymorphicComponent","ref","as","render","tabRendered","setTabRendered","tabIsActive","trackTabRenderedState","BaseTabPanel","tabId","TabAwareSlot"],"mappings":";;;;;;;;;;;;;;AAiBA,IAAMA,WAAW,gBAAGC,aAAA,CAElB,IAFkB,CAApB;AAqBA;;;;SAGgBC;MACZC,gBAAAA;MACAC,kBAAAA;wBACAC;MAAAA,gCAAQ;0BACRC;MAAAA,oCAAU;AAEV,MAAMC,QAAQ,GAAGC,WAAW,CAAC;AAAEJ,IAAAA,UAAU,EAAVA;AAAF,GAAD,CAA5B;AACA,MAAMK,kBAAkB,GAAGC,WAAW,CAACN,UAAD,CAAtC;AACA,MAAoBO,gBAApB,GAAiDJ,QAAjD,CAAQH,UAAR;AAAA,MAAsCQ,MAAtC,GAAiDL,QAAjD,CAAsCK,MAAtC;AAEAX,EAAAA,SAAA,CACI,SAASY,SAAT;AACI,QACIJ,kBAAkB,KAAKL,UAAvB,IACAA,UAAU,KAAKO,gBADf,IAEAP,UAAU,KAAKU,SAHnB,EA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AAIF,WAArC,IAAoDpC,QAApD,GAA+D,IAHpE,CADJ;AAOH,CA/BuC;AA0C5C;;;;;SAIgB0C;MAAe1C,iBAAAA;AAC3B,MAAMoB,eAAe,GAAGtB,UAAA,CAAiBD,WAAjB,CAAxB;AAEA,SAAOuB,eAAe,GAAGpB,QAAQ,CAAC;AAAEC,IAAAA,UAAU,EAAEmB,eAAe,CAACnB;AAA9B,GAAD,CAAX,GAA0D,IAAhF;AACH;;;;"}
|
|
@@ -5,6 +5,7 @@ import { getClassNames } from '../responsive-props.js';
|
|
|
5
5
|
import { Box } from '../box/box.js';
|
|
6
6
|
import styles from './text.module.css.js';
|
|
7
7
|
|
|
8
|
+
var _excluded = ["as", "size", "weight", "tone", "align", "children", "lineClamp", "exceptionallySetClassName"];
|
|
8
9
|
var Text = /*#__PURE__*/polymorphicComponent(function Text(_ref, ref) {
|
|
9
10
|
var as = _ref.as,
|
|
10
11
|
_ref$size = _ref.size,
|
|
@@ -17,7 +18,7 @@ var Text = /*#__PURE__*/polymorphicComponent(function Text(_ref, ref) {
|
|
|
17
18
|
children = _ref.children,
|
|
18
19
|
lineClamp = _ref.lineClamp,
|
|
19
20
|
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
20
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
21
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
22
|
|
|
22
23
|
var lineClampMultipleLines = typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp !== null && lineClamp !== void 0 ? lineClamp : 1) > 1;
|
|
23
24
|
return /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sources":["../../../src/new-components/text/text.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../responsive-props'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\nimport type { Tone } from '../common-types'\nimport type { BoxProps } from '../box'\n\nimport styles from './text.module.css'\n\ntype TextProps = {\n children: React.ReactNode\n /**\n * The size of the text.\n *\n * The supported values, from smaller size to larger size, are:\n * 'caption', 'copy', 'body', and 'subtitle'\n *\n * @default 'body'\n */\n size?: 'caption' | 'copy' | 'body' | 'subtitle'\n /**\n * The weight of the text font.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'semibold' | 'bold'\n /**\n * The tone (semantic color) of the text.\n *\n * @default 'normal'\n */\n tone?: Tone\n /**\n * Used to truncate the text to a given number of lines.\n *\n * It will add an ellipsis (`…`) to the text at the end of the last line, only if the text was\n * truncated. If the text fits without it being truncated, no ellipsis is added.\n *\n * By default, the text is not truncated at all, no matter how many lines it takes to render it.\n *\n * @default undefined\n */\n lineClamp?: 1 | 2 | 3 | 4 | 5 | '1' | '2' | '3' | '4' | '5'\n /**\n * How to align the text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Text = polymorphicComponent<'div', TextProps>(function Text(\n {\n as,\n size = 'body',\n weight = 'regular',\n tone = 'normal',\n align,\n children,\n lineClamp,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp ?? 1) > 1\n\n return (\n <Box\n {...props}\n as={as}\n className={[\n exceptionallySetClassName,\n styles.text,\n size !== 'body' ? getClassNames(styles, 'size', size) : null,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\n lineClampMultipleLines ? styles.lineClampMultipleLines : null,\n lineClamp ? getClassNames(styles, 'lineClamp', lineClamp.toString()) : null,\n ]}\n textAlign={align}\n // Prevents emojis from being cut-off\n // See https://github.com/Doist/reactist/pull/528\n paddingRight={lineClamp ? 'xsmall' : undefined}\n ref={ref}\n >\n {children}\n </Box>\n )\n})\n\nexport type { TextProps }\nexport { Text }\n"],"names":["Text","polymorphicComponent","ref","as","size","weight","tone","align","children","lineClamp","exceptionallySetClassName","props","lineClampMultipleLines","Number","React","Box","className","styles","text","getClassNames","toString","textAlign","paddingRight","undefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"text.js","sources":["../../../src/new-components/text/text.tsx"],"sourcesContent":["import * as React from 'react'\nimport { getClassNames } from '../responsive-props'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\n\nimport type { Tone } from '../common-types'\nimport type { BoxProps } from '../box'\n\nimport styles from './text.module.css'\n\ntype TextProps = {\n children: React.ReactNode\n /**\n * The size of the text.\n *\n * The supported values, from smaller size to larger size, are:\n * 'caption', 'copy', 'body', and 'subtitle'\n *\n * @default 'body'\n */\n size?: 'caption' | 'copy' | 'body' | 'subtitle'\n /**\n * The weight of the text font.\n *\n * @default 'regular'\n */\n weight?: 'regular' | 'semibold' | 'bold'\n /**\n * The tone (semantic color) of the text.\n *\n * @default 'normal'\n */\n tone?: Tone\n /**\n * Used to truncate the text to a given number of lines.\n *\n * It will add an ellipsis (`…`) to the text at the end of the last line, only if the text was\n * truncated. If the text fits without it being truncated, no ellipsis is added.\n *\n * By default, the text is not truncated at all, no matter how many lines it takes to render it.\n *\n * @default undefined\n */\n lineClamp?: 1 | 2 | 3 | 4 | 5 | '1' | '2' | '3' | '4' | '5'\n /**\n * How to align the text horizontally.\n *\n * @default 'start'\n */\n align?: BoxProps['textAlign']\n}\n\nconst Text = polymorphicComponent<'div', TextProps>(function Text(\n {\n as,\n size = 'body',\n weight = 'regular',\n tone = 'normal',\n align,\n children,\n lineClamp,\n exceptionallySetClassName,\n ...props\n },\n ref,\n) {\n const lineClampMultipleLines =\n typeof lineClamp === 'string' ? Number(lineClamp) > 1 : (lineClamp ?? 1) > 1\n\n return (\n <Box\n {...props}\n as={as}\n className={[\n exceptionallySetClassName,\n styles.text,\n size !== 'body' ? getClassNames(styles, 'size', size) : null,\n weight !== 'regular' ? getClassNames(styles, 'weight', weight) : null,\n tone !== 'normal' ? getClassNames(styles, 'tone', tone) : null,\n lineClampMultipleLines ? styles.lineClampMultipleLines : null,\n lineClamp ? getClassNames(styles, 'lineClamp', lineClamp.toString()) : null,\n ]}\n textAlign={align}\n // Prevents emojis from being cut-off\n // See https://github.com/Doist/reactist/pull/528\n paddingRight={lineClamp ? 'xsmall' : undefined}\n ref={ref}\n >\n {children}\n </Box>\n )\n})\n\nexport type { TextProps }\nexport { Text }\n"],"names":["Text","polymorphicComponent","ref","as","size","weight","tone","align","children","lineClamp","exceptionallySetClassName","props","lineClampMultipleLines","Number","React","Box","className","styles","text","getClassNames","toString","textAlign","paddingRight","undefined"],"mappings":";;;;;;;;IAoDMA,IAAI,gBAAGC,oBAAoB,CAAmB,SAASD,IAAT,OAYhDE,GAZgD;MAE5CC,UAAAA;uBACAC;MAAAA,8BAAO;yBACPC;MAAAA,kCAAS;uBACTC;MAAAA,8BAAO;MACPC,aAAAA;MACAC,gBAAAA;MACAC,iBAAAA;MACAC,iCAAAA;MACGC;;AAIP,MAAMC,sBAAsB,GACxB,OAAOH,SAAP,KAAqB,QAArB,GAAgCI,MAAM,CAACJ,SAAD,CAAN,GAAoB,CAApD,GAAwD,CAACA,SAAD,aAACA,SAAD,cAACA,SAAD,GAAc,CAAd,IAAmB,CAD/E;AAGA,sBACIK,aAAA,CAACC,GAAD,oBACQJ;AACJR,IAAAA,EAAE,EAAEA;AACJa,IAAAA,SAAS,EAAE,CACPN,yBADO,EAEPO,MAAM,CAACC,IAFA,EAGPd,IAAI,KAAK,MAAT,GAAkBe,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBb,IAAjB,CAA/B,GAAwD,IAHjD,EAIPC,MAAM,KAAK,SAAX,GAAuBc,aAAa,CAACF,MAAD,EAAS,QAAT,EAAmBZ,MAAnB,CAApC,GAAiE,IAJ1D,EAKPC,IAAI,KAAK,QAAT,GAAoBa,aAAa,CAACF,MAAD,EAAS,MAAT,EAAiBX,IAAjB,CAAjC,GAA0D,IALnD,EAMPM,sBAAsB,GAAGK,MAAM,CAACL,sBAAV,GAAmC,IANlD,EAOPH,SAAS,GAAGU,aAAa,CAACF,MAAD,EAAS,WAAT,EAAsBR,SAAS,CAACW,QAAV,EAAtB,CAAhB,GAA8D,IAPhE;AASXC,IAAAA,SAAS,EAAEd;AACX;AACA;AACAe,IAAAA,YAAY,EAAEb,SAAS,GAAG,QAAH,GAAcc;AACrCrB,IAAAA,GAAG,EAAEA;IAhBT,EAkBKM,QAlBL,CADJ;AAsBH,CAvCgC;;;;"}
|
|
@@ -4,6 +4,8 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './text-area.module.css.js';
|
|
6
6
|
|
|
7
|
+
var _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "maxWidth"];
|
|
8
|
+
|
|
7
9
|
function TextArea(_ref) {
|
|
8
10
|
var id = _ref.id,
|
|
9
11
|
label = _ref.label,
|
|
@@ -11,7 +13,7 @@ function TextArea(_ref) {
|
|
|
11
13
|
auxiliaryLabel = _ref.auxiliaryLabel,
|
|
12
14
|
hint = _ref.hint,
|
|
13
15
|
maxWidth = _ref.maxWidth,
|
|
14
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
16
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
15
17
|
|
|
16
18
|
return /*#__PURE__*/createElement(BaseField, {
|
|
17
19
|
id: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement>\n\nfunction TextArea({\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n ...props\n}: TextAreaProps) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n className={styles.container}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box width=\"full\">\n <textarea {...props} {...extraProps} />\n </Box>\n )}\n </BaseField>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","props","React","BaseField","className","styles","container","extraProps","Box","width"],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-area.js","sources":["../../../src/new-components/text-area/text-area.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField, FieldComponentProps } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-area.module.css'\n\ntype TextAreaProps = FieldComponentProps<HTMLTextAreaElement>\n\nfunction TextArea({\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n maxWidth,\n ...props\n}: TextAreaProps) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n className={styles.container}\n maxWidth={maxWidth}\n >\n {(extraProps) => (\n <Box width=\"full\">\n <textarea {...props} {...extraProps} />\n </Box>\n )}\n </BaseField>\n )\n}\n\nexport { TextArea }\nexport type { TextAreaProps }\n"],"names":["TextArea","id","label","secondaryLabel","auxiliaryLabel","hint","maxWidth","props","React","BaseField","className","styles","container","extraProps","Box","width"],"mappings":";;;;;;;;AAOA,SAASA,QAAT;MACIC,UAAAA;MACAC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;MACAC,gBAAAA;MACGC;;AAEH,sBACIC,aAAA,CAACC,SAAD;AACIR,IAAAA,EAAE,EAAEA;AACJC,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNK,IAAAA,SAAS,EAAEC,MAAM,CAACC;AAClBN,IAAAA,QAAQ,EAAEA;GAPd,EASK,UAACO,UAAD;AAAA,wBACGL,aAAA,CAACM,GAAD;AAAKC,MAAAA,KAAK,EAAC;KAAX,eACIP,aAAA,WAAA,oBAAcD,OAAWM,WAAzB,CADJ,CADH;AAAA,GATL,CADJ;AAiBH;;;;"}
|
|
@@ -4,6 +4,7 @@ import { Box } from '../box/box.js';
|
|
|
4
4
|
import { BaseField } from '../base-field/base-field.js';
|
|
5
5
|
import styles from './text-field.module.css.js';
|
|
6
6
|
|
|
7
|
+
var _excluded = ["id", "label", "secondaryLabel", "auxiliaryLabel", "hint", "type", "maxWidth", "hidden", "aria-describedby"];
|
|
7
8
|
var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
8
9
|
var id = _ref.id,
|
|
9
10
|
label = _ref.label,
|
|
@@ -15,7 +16,7 @@ var TextField = /*#__PURE__*/forwardRef(function TextField(_ref, ref) {
|
|
|
15
16
|
maxWidth = _ref.maxWidth,
|
|
16
17
|
hidden = _ref.hidden,
|
|
17
18
|
ariaDescribedBy = _ref['aria-describedby'],
|
|
18
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
19
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
19
20
|
|
|
20
21
|
return /*#__PURE__*/createElement(BaseField, {
|
|
21
22
|
id: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> & {\n type?: TextFieldType\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.inputWrapper}>\n <input {...props} {...extraProps} type={type} ref={ref} />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","type","maxWidth","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","inputWrapper"],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-field.js","sources":["../../../src/new-components/text-field/text-field.tsx"],"sourcesContent":["import * as React from 'react'\nimport { BaseField } from '../base-field'\nimport { Box } from '../box'\nimport styles from './text-field.module.css'\nimport type { FieldComponentProps } from '../base-field'\n\ntype TextFieldType = 'email' | 'search' | 'tel' | 'text' | 'url'\n\ntype TextFieldProps = Omit<FieldComponentProps<HTMLInputElement>, 'type'> & {\n type?: TextFieldType\n}\n\nconst TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(function TextField(\n {\n id,\n label,\n secondaryLabel,\n auxiliaryLabel,\n hint,\n type = 'text',\n maxWidth,\n hidden,\n 'aria-describedby': ariaDescribedBy,\n ...props\n },\n ref,\n) {\n return (\n <BaseField\n id={id}\n label={label}\n secondaryLabel={secondaryLabel}\n auxiliaryLabel={auxiliaryLabel}\n hint={hint}\n maxWidth={maxWidth}\n hidden={hidden}\n aria-describedby={ariaDescribedBy}\n >\n {(extraProps) => (\n <Box className={styles.inputWrapper}>\n <input {...props} {...extraProps} type={type} ref={ref} />\n </Box>\n )}\n </BaseField>\n )\n})\n\nexport { TextField }\nexport type { TextFieldProps, TextFieldType }\n"],"names":["TextField","React","ref","id","label","secondaryLabel","auxiliaryLabel","hint","type","maxWidth","hidden","ariaDescribedBy","props","BaseField","extraProps","Box","className","styles","inputWrapper"],"mappings":";;;;;;;IAYMA,SAAS,gBAAGC,UAAA,CAAmD,SAASD,SAAT,OAajEE,GAbiE;MAE7DC,UAAAA;MACAC,aAAAA;MACAC,sBAAAA;MACAC,sBAAAA;MACAC,YAAAA;uBACAC;MAAAA,8BAAO;MACPC,gBAAAA;MACAC,cAAAA;MACoBC,uBAApB;MACGC;;AAIP,sBACIX,aAAA,CAACY,SAAD;AACIV,IAAAA,EAAE,EAAEA;AACJC,IAAAA,KAAK,EAAEA;AACPC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,cAAc,EAAEA;AAChBC,IAAAA,IAAI,EAAEA;AACNE,IAAAA,QAAQ,EAAEA;AACVC,IAAAA,MAAM,EAAEA;wBACUC;GARtB,EAUK,UAACG,UAAD;AAAA,wBACGb,aAAA,CAACc,GAAD;AAAKC,MAAAA,SAAS,EAAEC,MAAM,CAACC;KAAvB,eACIjB,aAAA,QAAA,oBAAWW,OAAWE;AAAYN,MAAAA,IAAI,EAAEA;AAAMN,MAAAA,GAAG,EAAEA;MAAnD,CADJ,CADH;AAAA,GAVL,CADJ;AAkBH,CAjCiB;;;;"}
|
|
@@ -4,13 +4,14 @@ import { polymorphicComponent } from '../../utils/polymorphism.js';
|
|
|
4
4
|
import { Box } from '../box/box.js';
|
|
5
5
|
import styles from './text-link.module.css.js';
|
|
6
6
|
|
|
7
|
+
var _excluded = ["as", "openInNewTab", "exceptionallySetClassName"];
|
|
7
8
|
var TextLink = /*#__PURE__*/polymorphicComponent(function TextLink(_ref, ref) {
|
|
8
9
|
var _ref$as = _ref.as,
|
|
9
10
|
as = _ref$as === void 0 ? 'a' : _ref$as,
|
|
10
11
|
_ref$openInNewTab = _ref.openInNewTab,
|
|
11
12
|
openInNewTab = _ref$openInNewTab === void 0 ? false : _ref$openInNewTab,
|
|
12
13
|
exceptionallySetClassName = _ref.exceptionallySetClassName,
|
|
13
|
-
props = _objectWithoutPropertiesLoose(_ref,
|
|
14
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
14
15
|
|
|
15
16
|
return /*#__PURE__*/createElement(Box, Object.assign({}, props, {
|
|
16
17
|
as: as,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-link.js","sources":["../../../src/new-components/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","Box","display","className","styles","container","target","undefined","rel"],"mappings":"
|
|
1
|
+
{"version":3,"file":"text-link.js","sources":["../../../src/new-components/text-link/text-link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { Box } from '../box'\nimport { polymorphicComponent } from '../../utils/polymorphism'\nimport styles from './text-link.module.css'\nimport type { OpenInNewTab } from '../common-types'\n\ntype TextLinkProps = OpenInNewTab\n\nconst TextLink = polymorphicComponent<'a', TextLinkProps>(function TextLink(\n { as = 'a', openInNewTab = false, exceptionallySetClassName, ...props },\n ref,\n) {\n return (\n <Box\n {...props}\n as={as}\n display=\"inline\"\n className={[exceptionallySetClassName, styles.container]}\n ref={ref}\n target={openInNewTab ? '_blank' : undefined}\n rel={openInNewTab ? 'noopener noreferrer' : undefined}\n />\n )\n})\n\nexport { TextLink }\nexport type { TextLinkProps }\n"],"names":["TextLink","polymorphicComponent","ref","as","openInNewTab","exceptionallySetClassName","props","React","Box","display","className","styles","container","target","undefined","rel"],"mappings":";;;;;;;IAQMA,QAAQ,gBAAGC,oBAAoB,CAAqB,SAASD,QAAT,OAEtDE,GAFsD;qBACpDC;MAAAA,0BAAK;+BAAKC;MAAAA,8CAAe;MAAOC,iCAAAA;MAA8BC;;AAGhE,sBACIC,aAAA,CAACC,GAAD,oBACQF;AACJH,IAAAA,EAAE,EAAEA;AACJM,IAAAA,OAAO,EAAC;AACRC,IAAAA,SAAS,EAAE,CAACL,yBAAD,EAA4BM,MAAM,CAACC,SAAnC;AACXV,IAAAA,GAAG,EAAEA;AACLW,IAAAA,MAAM,EAAET,YAAY,GAAG,QAAH,GAAcU;AAClCC,IAAAA,GAAG,EAAEX,YAAY,GAAG,qBAAH,GAA2BU;IAPhD,CADJ;AAWH,CAfoC;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e,t
|
|
1
|
+
"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.assertThisInitialized=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},exports.defineProperty=t,exports.inheritsLoose=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,r(e,t)},exports.objectSpread2=function(r){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?e(Object(n),!0).forEach((function(e){t(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r},exports.objectWithoutPropertiesLoose=function(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t.indexOf(r=i[o])>=0||(n[r]=e[r]);return n},exports.setPrototypeOf=r;
|
|
2
2
|
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),i=t(require("react")),o=t(require("classnames")),a=require("../tooltip/tooltip.js"),l=i.forwardRef((function(t,
|
|
1
|
+
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),i=t(require("react")),o=t(require("classnames")),a=require("../tooltip/tooltip.js"),l=["type","variant","size","loading","disabled","tooltip","onClick","children"],r=i.forwardRef((function(t,r){var n=t.type,s=void 0===n?"button":n,u=t.variant,d=t.size,c=void 0===d?"default":d,p=t.loading,b=void 0!==p&&p,f=t.disabled,v=void 0!==f&&f,_=t.tooltip,g=t.onClick,j=t.children,m=e.objectWithoutPropertiesLoose(t,l),y=o("reactist_button",u?"reactist_button--"+u:null,"default"!==c?"reactist_button--"+c:null,{"reactist_button--loading":b},m.className),q=i.createElement("button",Object.assign({},m,{ref:r,type:s,className:y,"aria-disabled":v||b,onClick:v||b?void 0:g}),j);return _?i.createElement(a.Tooltip,{content:_},q):q}));r.displayName="Button",r.defaultProps={size:"default",loading:!1,disabled:!1},exports.Button=r;
|
|
2
2
|
//# sourceMappingURL=deprecated-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deprecated-button.js","sources":["../../../src/components/deprecated-button/deprecated-button.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { Tooltip } from '../tooltip'\n\nimport './deprecated-button.less'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\n/** @deprecated */\nexport type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'link'\n\n/** @deprecated */\nexport type ButtonSize = 'default' | 'small' | 'large'\n\n/** @deprecated */\nexport type ButtonProps = Omit<NativeButtonProps, 'title' | 'ref'> & {\n /**\n * Loading style. When true it disables the button, but it also adds a visual indication of\n * some in-progress operation going on.\n */\n loading?: boolean\n /**\n * Controls visually how the button shows up from a predefined set of kinds of buttons.\n */\n variant?: ButtonVariant\n /**\n * The size of the button. If not provided it shows up in a normal size.\n */\n size?: ButtonSize\n /**\n * Tooltip that is displayed on hover.\n *\n * This replaces `title` which is not supported for these buttons to avoid confusion.\n */\n tooltip?: React.ReactNode\n}\n\n/**\n * @deprecated\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n type = 'button',\n variant,\n size = 'default',\n loading = false,\n disabled = false,\n tooltip,\n onClick,\n children,\n ...props\n },\n ref,\n) {\n const className = classNames(\n 'reactist_button',\n variant ? `reactist_button--${variant}` : null,\n size !== 'default' ? `reactist_button--${size}` : null,\n { 'reactist_button--loading': loading },\n props.className,\n )\n\n const button = (\n <button\n {...props}\n ref={ref}\n type={type}\n className={className}\n aria-disabled={disabled || loading}\n onClick={disabled || loading ? undefined : onClick}\n >\n {children}\n </button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{button}</Tooltip> : button\n})\n\nButton.displayName = 'Button'\n\nButton.defaultProps = {\n size: 'default',\n loading: false,\n disabled: false,\n}\n\nexport { Button }\n"],"names":["Button","React","forwardRef","ref","type","variant","size","loading","disabled","tooltip","onClick","children","props","className","classNames","button","undefined","Tooltip","content","displayName","defaultProps"],"mappings":"
|
|
1
|
+
{"version":3,"file":"deprecated-button.js","sources":["../../../src/components/deprecated-button/deprecated-button.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { Tooltip } from '../tooltip'\n\nimport './deprecated-button.less'\n\ntype NativeButtonProps = React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>\n\n/** @deprecated */\nexport type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'link'\n\n/** @deprecated */\nexport type ButtonSize = 'default' | 'small' | 'large'\n\n/** @deprecated */\nexport type ButtonProps = Omit<NativeButtonProps, 'title' | 'ref'> & {\n /**\n * Loading style. When true it disables the button, but it also adds a visual indication of\n * some in-progress operation going on.\n */\n loading?: boolean\n /**\n * Controls visually how the button shows up from a predefined set of kinds of buttons.\n */\n variant?: ButtonVariant\n /**\n * The size of the button. If not provided it shows up in a normal size.\n */\n size?: ButtonSize\n /**\n * Tooltip that is displayed on hover.\n *\n * This replaces `title` which is not supported for these buttons to avoid confusion.\n */\n tooltip?: React.ReactNode\n}\n\n/**\n * @deprecated\n */\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n {\n type = 'button',\n variant,\n size = 'default',\n loading = false,\n disabled = false,\n tooltip,\n onClick,\n children,\n ...props\n },\n ref,\n) {\n const className = classNames(\n 'reactist_button',\n variant ? `reactist_button--${variant}` : null,\n size !== 'default' ? `reactist_button--${size}` : null,\n { 'reactist_button--loading': loading },\n props.className,\n )\n\n const button = (\n <button\n {...props}\n ref={ref}\n type={type}\n className={className}\n aria-disabled={disabled || loading}\n onClick={disabled || loading ? undefined : onClick}\n >\n {children}\n </button>\n )\n\n return tooltip ? <Tooltip content={tooltip}>{button}</Tooltip> : button\n})\n\nButton.displayName = 'Button'\n\nButton.defaultProps = {\n size: 'default',\n loading: false,\n disabled: false,\n}\n\nexport { Button }\n"],"names":["Button","React","forwardRef","ref","type","variant","size","loading","disabled","tooltip","onClick","children","props","className","classNames","button","undefined","Tooltip","content","displayName","defaultProps"],"mappings":"2WA4CMA,EAASC,EAAMC,YAA2C,WAY5DC,WAVIC,KAAAA,aAAO,WACPC,IAAAA,YACAC,KAAAA,aAAO,gBACPC,QAAAA,oBACAC,SAAAA,gBACAC,IAAAA,QACAC,IAAAA,QACAC,IAAAA,SACGC,sCAIDC,EAAYC,EACd,kBACAT,sBAA8BA,EAAY,KACjC,YAATC,sBAAyCA,EAAS,KAClD,4BAA8BC,GAC9BK,EAAMC,WAGJE,EACFd,0CACQW,GACJT,IAAKA,EACLC,KAAMA,EACNS,UAAWA,kBACIL,GAAYD,EAC3BG,QAASF,GAAYD,OAAUS,EAAYN,IAE1CC,UAIFF,EAAUR,gBAACgB,WAAQC,QAAST,GAAUM,GAAoBA,KAGrEf,EAAOmB,YAAc,SAErBnB,EAAOoB,aAAe,CAClBd,KAAM,UACNC,SAAS,EACTC,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),n=e(require("react")),o=e(require("classnames")),r=e(require("react-dom")),l=require("../icons/CloseIcon.svg.js"),a=function(e){function l(){var t;return(t=e.apply(this,arguments)||this)._closeModal=function(){var e=document.getElementById("modal_box");r.unmountComponentAtNode(e)},t._handleKeyDown=function(e){27===e.keyCode&&(t._closeModal(),e.preventDefault&&e.preventDefault())},t._handleOverlayClick=function(e){e.target instanceof Element&&("reactist-overlay"===e.target.id||"reactist-overlay-inner"===e.target.id)&&t._closeModal()},t}t.inheritsLoose(l,e);var a=l.prototype;return a.componentDidMount=function(){window.addEventListener("keydown",this._handleKeyDown)},a.componentWillUnmount=function(){window.removeEventListener("keydown",this._handleKeyDown)},a.render=function(){var e=this.props,t=e.style,r=e.children,l=e.closeOnOverlayClick,a=o("reactist_modal_box",{large:e.large,medium:e.medium},this.props.className);return n.createElement("div",{className:"reactist_overlay",id:"reactist-overlay",onClick:l?this._handleOverlayClick:void 0},n.createElement("div",{className:"reactist_overlay_inner",id:"reactist-overlay-inner"},n.createElement("div",{style:t,className:a},r)))},l}(n.Component);a.displayName="Modal.Box",a.defaultProps={large:!1,closeOnOverlayClick:!1};var s=function(e){function o(){return e.apply(this,arguments)||this}t.inheritsLoose(o,e);var a=o.prototype;return a._closeModal=function(e){e.preventDefault(),"function"==typeof this.props.beforeClose&&this.props.beforeClose();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},a.render=function(){return n.createElement("div",{className:"reactist_modal_box__header"},n.createElement("p",null,this.props.title&&n.createElement("span",{className:"title"},this.props.title),this.props.subtitle&&n.createElement("span",{className:"subtitle"},this.props.subtitle),this.props.children),n.createElement("a",{className:"close",onClick:this._closeModal.bind(this),href:"#"},n.createElement(l.default,null)))},o}(n.Component);s.displayName="Modal.Header";var i=function(e){function a(){return e.apply(this,arguments)||this}t.inheritsLoose(a,e);var s=a.prototype;return s._closeModal=function(e){e.preventDefault();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},s.render=function(){var e=this.props,t=e.icon,r=e.children,a=e.style,s=e.showCloseIcon,i=o("reactist_modal_box__body",{plain:e.plain},this.props.className);return n.createElement("div",{className:i,style:a},s&&n.createElement("a",{className:"close",onClick:this._closeModal.bind(this),href:"#"},n.createElement(l.default,null)),t?n.createElement("div",{className:"dialog"},n.createElement("div",{className:"reactist_icon"},t),n.createElement("div",{className:"content"},r)):r)},a}(n.Component);i.displayName="Modal.Body",i.defaultProps={showCloseIcon:!1};var c=function(e){function o(){return e.apply(this,arguments)||this}t.inheritsLoose(o,e);var l=o.prototype;return l._onClick=function(e){e&&e();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},l.render=function(){var e=this,t=n.Children.map(this.props.children,(function(t){var o;return
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),n=e(require("react")),o=e(require("classnames")),r=e(require("react-dom")),l=require("../icons/CloseIcon.svg.js"),a=function(e){function l(){var t;return(t=e.apply(this,arguments)||this)._closeModal=function(){var e=document.getElementById("modal_box");r.unmountComponentAtNode(e)},t._handleKeyDown=function(e){27===e.keyCode&&(t._closeModal(),e.preventDefault&&e.preventDefault())},t._handleOverlayClick=function(e){e.target instanceof Element&&("reactist-overlay"===e.target.id||"reactist-overlay-inner"===e.target.id)&&t._closeModal()},t}t.inheritsLoose(l,e);var a=l.prototype;return a.componentDidMount=function(){window.addEventListener("keydown",this._handleKeyDown)},a.componentWillUnmount=function(){window.removeEventListener("keydown",this._handleKeyDown)},a.render=function(){var e=this.props,t=e.style,r=e.children,l=e.closeOnOverlayClick,a=o("reactist_modal_box",{large:e.large,medium:e.medium},this.props.className);return n.createElement("div",{className:"reactist_overlay",id:"reactist-overlay",onClick:l?this._handleOverlayClick:void 0},n.createElement("div",{className:"reactist_overlay_inner",id:"reactist-overlay-inner"},n.createElement("div",{style:t,className:a},r)))},l}(n.Component);a.displayName="Modal.Box",a.defaultProps={large:!1,closeOnOverlayClick:!1};var s=function(e){function o(){return e.apply(this,arguments)||this}t.inheritsLoose(o,e);var a=o.prototype;return a._closeModal=function(e){e.preventDefault(),"function"==typeof this.props.beforeClose&&this.props.beforeClose();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},a.render=function(){return n.createElement("div",{className:"reactist_modal_box__header"},n.createElement("p",null,this.props.title&&n.createElement("span",{className:"title"},this.props.title),this.props.subtitle&&n.createElement("span",{className:"subtitle"},this.props.subtitle),this.props.children),n.createElement("a",{className:"close",onClick:this._closeModal.bind(this),href:"#"},n.createElement(l.default,null)))},o}(n.Component);s.displayName="Modal.Header";var i=function(e){function a(){return e.apply(this,arguments)||this}t.inheritsLoose(a,e);var s=a.prototype;return s._closeModal=function(e){e.preventDefault();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},s.render=function(){var e=this.props,t=e.icon,r=e.children,a=e.style,s=e.showCloseIcon,i=o("reactist_modal_box__body",{plain:e.plain},this.props.className);return n.createElement("div",{className:i,style:a},s&&n.createElement("a",{className:"close",onClick:this._closeModal.bind(this),href:"#"},n.createElement(l.default,null)),t?n.createElement("div",{className:"dialog"},n.createElement("div",{className:"reactist_icon"},t),n.createElement("div",{className:"content"},r)):r)},a}(n.Component);i.displayName="Modal.Body",i.defaultProps={showCloseIcon:!1};var c=function(e){function o(){return e.apply(this,arguments)||this}t.inheritsLoose(o,e);var l=o.prototype;return l._onClick=function(e){e&&e();var t=document.getElementById("modal_box");r.unmountComponentAtNode(t)},l.render=function(){var e=this,t=n.Children.map(this.props.children,(function(t){var o;return null!=t&&null!==(o=t.props)&&void 0!==o&&o.close?n.cloneElement(t,{onClick:function(){return e._onClick(t.props.onClick)}}):t?n.cloneElement(t):n.createElement(n.Fragment,null)}));return n.createElement("div",{className:"reactist_modal_box__actions"},t)},o}(n.Component);c.displayName="Modal.Actions",exports.Actions=c,exports.Body=i,exports.Box=a,exports.Header=s;
|
|
2
2
|
//# sourceMappingURL=deprecated-modal.js.map
|