@newtonschool/grauity 0.0.13 → 0.1.10
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/README.md +138 -9
- package/dist/fonts/grauity-icons.eot +0 -0
- package/dist/fonts/grauity-icons.ttf +0 -0
- package/dist/fonts/grauity-icons.woff +0 -0
- package/dist/fonts/grauity-icons.woff2 +0 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/useClickAway.d.ts +15 -0
- package/dist/hooks/useClickAway.d.ts.map +1 -0
- package/dist/hooks/useDisableBodyScroll.d.ts +7 -0
- package/dist/hooks/useDisableBodyScroll.d.ts.map +1 -0
- package/dist/hooks/useKeyboardEvent.d.ts +17 -0
- package/dist/hooks/useKeyboardEvent.d.ts.map +1 -0
- package/dist/index.d.ts +830 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.css +10 -1
- package/dist/main.css.map +1 -1
- package/dist/module.css +10 -1
- package/dist/module.css.map +1 -1
- package/dist/module.mjs +1 -1
- package/dist/module.mjs.map +1 -1
- package/dist/stories/atoms/Colors/FoundationColors.stories.d.ts +7 -0
- package/dist/stories/atoms/Colors/FoundationColors.stories.d.ts.map +1 -0
- package/dist/stories/atoms/Colors/index.stories.d.ts +18 -0
- package/dist/stories/atoms/Colors/index.stories.d.ts.map +1 -0
- package/dist/stories/atoms/CornerRadius/index.stories.d.ts +7 -0
- package/dist/stories/atoms/CornerRadius/index.stories.d.ts.map +1 -0
- package/dist/stories/atoms/Spacing/index.stories.d.ts +7 -0
- package/dist/stories/atoms/Spacing/index.stories.d.ts.map +1 -0
- package/dist/stories/decorators/withEnableBodyScroll.d.ts +8 -0
- package/dist/stories/decorators/withEnableBodyScroll.d.ts.map +1 -0
- package/dist/stories/decorators/withInlineContainer.d.ts +15 -0
- package/dist/stories/decorators/withInlineContainer.d.ts.map +1 -0
- package/dist/stories/elements/Alert/Gallery.stories.d.ts +30 -0
- package/dist/stories/elements/Alert/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Alert/index.stories.d.ts +30 -0
- package/dist/stories/elements/Alert/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/AlertBanner/Gallery.stories.d.ts +33 -0
- package/dist/stories/elements/AlertBanner/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/AlertBanner/index.stories.d.ts +30 -0
- package/dist/stories/elements/AlertBanner/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Button/Gallery.stories.d.ts +10 -0
- package/dist/stories/elements/Button/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Button/index.stories.d.ts +9 -0
- package/dist/stories/elements/Button/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Icon/index.stories.d.ts +14 -0
- package/dist/stories/elements/Icon/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/IconButton/Gallery.stories.d.ts +10 -0
- package/dist/stories/elements/IconButton/Gallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/IconButton/index.stories.d.ts +9 -0
- package/dist/stories/elements/IconButton/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.source.d.ts +3 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.source.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts +43 -0
- package/dist/stories/elements/Modal/ConfirmationDialog.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts +42 -0
- package/dist/stories/elements/Modal/ConfirmationDialogWithTrigger.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts +46 -0
- package/dist/stories/elements/Modal/MultiStepModal.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/index.stories.d.ts +32 -0
- package/dist/stories/elements/Modal/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Modal/multiStepArgs.d.ts +4 -0
- package/dist/stories/elements/Modal/multiStepArgs.d.ts.map +1 -0
- package/dist/stories/elements/Modal/singleStepArgs.d.ts +4 -0
- package/dist/stories/elements/Modal/singleStepArgs.d.ts.map +1 -0
- package/dist/stories/elements/Table/Manual.source.d.ts +3 -0
- package/dist/stories/elements/Table/Manual.source.d.ts.map +1 -0
- package/dist/stories/elements/Table/Manual.stories.d.ts +54 -0
- package/dist/stories/elements/Table/Manual.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/ManualColumnNesting.source.d.ts +3 -0
- package/dist/stories/elements/Table/ManualColumnNesting.source.d.ts.map +1 -0
- package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts +53 -0
- package/dist/stories/elements/Table/ManualColumnNesting.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/index.stories.d.ts +46 -0
- package/dist/stories/elements/Table/index.stories.d.ts.map +1 -0
- package/dist/stories/elements/Table/simpleArgs.d.ts +4 -0
- package/dist/stories/elements/Table/simpleArgs.d.ts.map +1 -0
- package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts +29 -0
- package/dist/stories/elements/Typography/TypographyGallery.stories.d.ts.map +1 -0
- package/dist/stories/elements/Typography/index.stories.d.ts +28 -0
- package/dist/stories/elements/Typography/index.stories.d.ts.map +1 -0
- package/dist/stories/helper-components/ColorRenderer/index.d.ts +15 -0
- package/dist/stories/helper-components/ColorRenderer/index.d.ts.map +1 -0
- package/dist/stories/helper-components/DocPageWithPlayground.d.ts +12 -0
- package/dist/stories/helper-components/DocPageWithPlayground.d.ts.map +1 -0
- package/dist/stories/helper-components/TokenBlock/index.d.ts +21 -0
- package/dist/stories/helper-components/TokenBlock/index.d.ts.map +1 -0
- package/dist/stories/helper-components/TokenBlock/index.styles.d.ts +4 -0
- package/dist/stories/helper-components/TokenBlock/index.styles.d.ts.map +1 -0
- package/dist/stories/utils/index.d.ts +82 -0
- package/dist/stories/utils/index.d.ts.map +1 -0
- package/dist/ui/core/colors/colorTypes.d.ts +1 -0
- package/dist/ui/core/colors/colorTypes.d.ts.map +1 -0
- package/dist/ui/core/colors/index.d.ts +1 -0
- package/dist/ui/core/colors/index.d.ts.map +1 -0
- package/dist/ui/core/icons/iconTags.d.ts.map +1 -0
- package/dist/ui/core/icons/iconTypes.d.ts.map +1 -0
- package/dist/{core → ui/core}/icons/index.d.ts +1 -1
- package/dist/ui/core/icons/index.d.ts.map +1 -0
- package/dist/ui/core/index.d.ts +7 -0
- package/dist/ui/core/index.d.ts.map +1 -0
- package/dist/ui/core/miscellaneous-choices/index.d.ts.map +1 -0
- package/dist/ui/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +1 -0
- package/dist/ui/core/sizes/index.d.ts.map +1 -0
- package/dist/ui/core/sizes/sizeTypes.d.ts +3 -0
- package/dist/ui/core/sizes/sizeTypes.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.d.ts +8 -0
- package/dist/ui/elements/Alert/Alert.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.styles.d.ts +7 -0
- package/dist/ui/elements/Alert/Alert.styles.d.ts.map +1 -0
- package/dist/ui/elements/Alert/Alert.test.d.ts +2 -0
- package/dist/ui/elements/Alert/Alert.test.d.ts.map +1 -0
- package/dist/ui/elements/Alert/constants.d.ts +140 -0
- package/dist/ui/elements/Alert/constants.d.ts.map +1 -0
- package/dist/ui/elements/Alert/index.d.ts +7 -0
- package/dist/ui/elements/Alert/index.d.ts.map +1 -0
- package/dist/ui/elements/Alert/types.d.ts +125 -0
- package/dist/ui/elements/Alert/types.d.ts.map +1 -0
- package/dist/ui/elements/Alert/utils.d.ts +1 -0
- package/dist/ui/elements/Alert/utils.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.d.ts +9 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.styles.d.ts +4 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.styles.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.test.d.ts +2 -0
- package/dist/ui/elements/AlertBanner/AlertBanner.test.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/constants.d.ts +140 -0
- package/dist/ui/elements/AlertBanner/constants.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/index.d.ts +7 -0
- package/dist/ui/elements/AlertBanner/index.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/types.d.ts +111 -0
- package/dist/ui/elements/AlertBanner/types.d.ts.map +1 -0
- package/dist/ui/elements/AlertBanner/utils.d.ts +105 -0
- package/dist/ui/elements/AlertBanner/utils.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.d.ts +11 -0
- package/dist/ui/elements/Button/Button.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.styles.d.ts +4 -0
- package/dist/ui/elements/Button/Button.styles.d.ts.map +1 -0
- package/dist/ui/elements/Button/Button.test.d.ts +2 -0
- package/dist/ui/elements/Button/Button.test.d.ts.map +1 -0
- package/dist/ui/elements/Button/ButtonGroup.d.ts +11 -0
- package/dist/ui/elements/Button/ButtonGroup.d.ts.map +1 -0
- package/dist/ui/elements/Button/ButtonGroup.styles.d.ts +2 -0
- package/dist/ui/elements/Button/ButtonGroup.styles.d.ts.map +1 -0
- package/dist/ui/elements/Button/IconButton.d.ts +8 -0
- package/dist/ui/elements/Button/IconButton.d.ts.map +1 -0
- package/dist/ui/elements/Button/IconButton.test.d.ts +2 -0
- package/dist/ui/elements/Button/IconButton.test.d.ts.map +1 -0
- package/dist/ui/elements/Button/constants.d.ts +54 -0
- package/dist/ui/elements/Button/constants.d.ts.map +1 -0
- package/dist/ui/elements/Button/index.d.ts +9 -0
- package/dist/ui/elements/Button/index.d.ts.map +1 -0
- package/dist/ui/elements/Button/types.d.ts +226 -0
- package/dist/ui/elements/Button/types.d.ts.map +1 -0
- package/dist/ui/elements/Button/utils.d.ts +1 -0
- package/dist/ui/elements/Button/utils.d.ts.map +1 -0
- package/dist/ui/elements/Icon/Icon.d.ts +48 -0
- package/dist/ui/elements/Icon/Icon.d.ts.map +1 -0
- package/dist/ui/elements/Icon/Icon.styles.d.ts +5 -0
- package/dist/ui/elements/Icon/Icon.styles.d.ts.map +1 -0
- package/dist/ui/elements/Icon/index.d.ts +3 -0
- package/dist/ui/elements/Icon/index.d.ts.map +1 -0
- package/dist/ui/elements/Icon/types.d.ts +74 -0
- package/dist/ui/elements/Icon/types.d.ts.map +1 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts +43 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.test.d.ts +2 -0
- package/dist/ui/elements/Modal/ConfirmationDialog/index.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.d.ts +21 -0
- package/dist/ui/elements/Modal/Modal.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.styles.d.ts +18 -0
- package/dist/ui/elements/Modal/Modal.styles.d.ts.map +1 -0
- package/dist/ui/elements/Modal/Modal.test.d.ts +2 -0
- package/dist/ui/elements/Modal/Modal.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.d.ts +46 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.test.d.ts +2 -0
- package/dist/ui/elements/Modal/MultiStepModal/index.test.d.ts.map +1 -0
- package/dist/ui/elements/Modal/constants.d.ts +1 -0
- package/dist/ui/elements/Modal/constants.d.ts.map +1 -0
- package/dist/ui/elements/Modal/index.d.ts +5 -0
- package/dist/ui/elements/Modal/index.d.ts.map +1 -0
- package/dist/ui/elements/Modal/types.d.ts +312 -0
- package/dist/ui/elements/Modal/types.d.ts.map +1 -0
- package/dist/ui/elements/Modal/utils.d.ts +1 -0
- package/dist/ui/elements/Modal/utils.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.d.ts +47 -0
- package/dist/ui/elements/Table/Table.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.styles.d.ts +8 -0
- package/dist/ui/elements/Table/Table.styles.d.ts.map +1 -0
- package/dist/ui/elements/Table/Table.test.d.ts +2 -0
- package/dist/ui/elements/Table/Table.test.d.ts.map +1 -0
- package/dist/ui/elements/Table/constants.d.ts +1 -0
- package/dist/ui/elements/Table/constants.d.ts.map +1 -0
- package/dist/ui/elements/Table/index.d.ts +3 -0
- package/dist/ui/elements/Table/index.d.ts.map +1 -0
- package/dist/ui/elements/Table/types.d.ts +223 -0
- package/dist/ui/elements/Table/types.d.ts.map +1 -0
- package/dist/ui/elements/Table/utils.d.ts +1 -0
- package/dist/ui/elements/Table/utils.d.ts.map +1 -0
- package/dist/ui/elements/Typography/Typography.d.ts +36 -0
- package/dist/ui/elements/Typography/Typography.d.ts.map +1 -0
- package/dist/ui/elements/Typography/Typography.styles.d.ts +6 -0
- package/dist/ui/elements/Typography/Typography.styles.d.ts.map +1 -0
- package/dist/ui/elements/Typography/constants.d.ts +22 -0
- package/dist/ui/elements/Typography/constants.d.ts.map +1 -0
- package/dist/ui/elements/Typography/index.d.ts +5 -0
- package/dist/ui/elements/Typography/index.d.ts.map +1 -0
- package/dist/ui/elements/Typography/types.d.ts +50 -0
- package/dist/ui/elements/Typography/types.d.ts.map +1 -0
- package/dist/ui/elements/Typography/utils.d.ts +2 -0
- package/dist/ui/elements/Typography/utils.d.ts.map +1 -0
- package/dist/ui/helpers/classNameBuilders.d.ts.map +1 -0
- package/dist/ui/helpers/index.d.ts +3 -0
- package/dist/ui/helpers/index.d.ts.map +1 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/{init → ui/init}/GrauityInit.d.ts +15 -3
- package/dist/ui/init/GrauityInit.d.ts.map +1 -0
- package/dist/ui/init/index.d.ts.map +1 -0
- package/dist/ui/themes/GlobalStyle.d.ts +5 -0
- package/dist/ui/themes/GlobalStyle.d.ts.map +1 -0
- package/dist/ui/themes/ThemeContext.d.ts +24 -0
- package/dist/ui/themes/ThemeContext.d.ts.map +1 -0
- package/dist/ui/themes/constants.d.ts +6 -0
- package/dist/ui/themes/constants.d.ts.map +1 -0
- package/dist/ui/themes/darkThemeConstants.d.ts +70 -0
- package/dist/ui/themes/darkThemeConstants.d.ts.map +1 -0
- package/dist/ui/themes/lightThemeConstants.d.ts +70 -0
- package/dist/ui/themes/lightThemeConstants.d.ts.map +1 -0
- package/dist/ui/themes/tokens.d.ts +1 -0
- package/dist/ui/themes/tokens.d.ts.map +1 -0
- package/dist/ui/themes/types.d.ts +73 -0
- package/dist/ui/themes/types.d.ts.map +1 -0
- package/package.json +53 -28
- package/ui/core/colors/colorTypes.ts +2 -20
- package/ui/core/colors/index.ts +23 -23
- package/ui/core/icons/index.ts +1 -3
- package/ui/core/index.ts +7 -10
- package/ui/core/sizes/sizeTypes.ts +1 -0
- package/ui/css/fonts.scss +0 -8
- package/ui/css/index.scss +0 -8
- package/ui/css/reset.scss +2 -5
- package/ui/elements/Alert/Alert.styles.ts +66 -0
- package/ui/elements/Alert/Alert.test.tsx +81 -0
- package/ui/elements/Alert/Alert.tsx +153 -0
- package/ui/elements/Alert/constants.ts +169 -0
- package/ui/elements/Alert/index.ts +6 -0
- package/ui/elements/Alert/types.ts +150 -0
- package/ui/elements/AlertBanner/AlertBanner.styles.ts +35 -0
- package/ui/elements/AlertBanner/AlertBanner.test.tsx +70 -0
- package/ui/elements/AlertBanner/AlertBanner.tsx +137 -0
- package/ui/elements/AlertBanner/constants.ts +179 -0
- package/ui/elements/AlertBanner/index.ts +6 -0
- package/ui/elements/AlertBanner/types.ts +133 -0
- package/ui/elements/AlertBanner/utils.ts +52 -0
- package/ui/elements/Button/Button.styles.ts +88 -0
- package/ui/elements/Button/Button.test.tsx +78 -0
- package/ui/elements/Button/Button.tsx +134 -0
- package/ui/elements/Button/ButtonGroup.styles.ts +7 -0
- package/ui/elements/Button/ButtonGroup.tsx +21 -0
- package/ui/elements/Button/IconButton.test.tsx +39 -0
- package/ui/elements/Button/IconButton.tsx +118 -0
- package/ui/elements/Button/constants.ts +304 -0
- package/ui/elements/Button/index.ts +8 -0
- package/ui/elements/Button/types.ts +282 -0
- package/ui/elements/Button/utils.ts +0 -0
- package/ui/elements/Icon/Icon.styles.ts +98 -0
- package/ui/elements/Icon/Icon.tsx +17 -107
- package/ui/elements/Icon/index.ts +1 -2
- package/ui/elements/Icon/types.ts +96 -0
- package/ui/elements/Modal/ConfirmationDialog/index.test.tsx +116 -0
- package/ui/elements/Modal/ConfirmationDialog/index.tsx +151 -0
- package/ui/elements/Modal/Modal.styles.ts +230 -0
- package/ui/elements/Modal/Modal.test.tsx +117 -0
- package/ui/elements/Modal/Modal.tsx +179 -0
- package/ui/elements/Modal/MultiStepModal/index.test.tsx +116 -0
- package/ui/elements/Modal/MultiStepModal/index.tsx +184 -0
- package/ui/elements/Modal/constants.ts +0 -0
- package/ui/elements/Modal/index.ts +4 -0
- package/ui/elements/Modal/types.ts +379 -0
- package/ui/elements/Modal/utils.tsx +0 -0
- package/ui/elements/Table/Table.styles.ts +178 -0
- package/ui/elements/Table/Table.test.tsx +72 -0
- package/ui/elements/Table/Table.tsx +118 -0
- package/ui/elements/Table/constants.ts +0 -0
- package/ui/elements/Table/index.ts +2 -0
- package/ui/elements/Table/types.ts +270 -0
- package/ui/elements/Table/utils.ts +0 -0
- package/ui/elements/Typography/Typography.styles.ts +29 -0
- package/ui/elements/Typography/Typography.tsx +70 -0
- package/ui/elements/Typography/constants.ts +292 -0
- package/ui/elements/Typography/index.ts +9 -0
- package/ui/elements/Typography/types.ts +116 -0
- package/ui/elements/Typography/utils.ts +11 -0
- package/ui/fonts/grauity-icons.eot +0 -0
- package/ui/fonts/grauity-icons.ttf +0 -0
- package/ui/fonts/grauity-icons.woff +0 -0
- package/ui/fonts/grauity-icons.woff2 +0 -0
- package/ui/helpers/index.ts +1 -7
- package/ui/index.ts +42 -3
- package/ui/init/GrauityInit.tsx +30 -7
- package/ui/init/index.ts +0 -1
- package/ui/themes/GlobalStyle.ts +273 -0
- package/ui/themes/ThemeContext.tsx +140 -0
- package/ui/themes/constants.ts +8 -0
- package/ui/themes/darkThemeConstants.ts +73 -0
- package/ui/themes/lightThemeConstants.ts +73 -0
- package/ui/themes/tokens.ts +0 -0
- package/ui/themes/types.ts +77 -0
- package/dist/core/colors/colorTypes.d.ts +0 -3
- package/dist/core/colors/colorTypes.d.ts.map +0 -1
- package/dist/core/colors/index.d.ts +0 -14
- package/dist/core/colors/index.d.ts.map +0 -1
- package/dist/core/icons/iconTags.d.ts.map +0 -1
- package/dist/core/icons/iconTypes.d.ts.map +0 -1
- package/dist/core/icons/index.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -9
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/miscellaneous-choices/index.d.ts.map +0 -1
- package/dist/core/miscellaneous-choices/miscellaneousTypes.d.ts.map +0 -1
- package/dist/core/sizes/index.d.ts.map +0 -1
- package/dist/core/sizes/sizeTypes.d.ts +0 -3
- package/dist/core/sizes/sizeTypes.d.ts.map +0 -1
- package/dist/elements/Icon/Icon.d.ts +0 -115
- package/dist/elements/Icon/Icon.d.ts.map +0 -1
- package/dist/elements/Icon/index.d.ts +0 -3
- package/dist/elements/Icon/index.d.ts.map +0 -1
- package/dist/elements/index.d.ts +0 -3
- package/dist/elements/index.d.ts.map +0 -1
- package/dist/helpers/classNameBuilders.d.ts.map +0 -1
- package/dist/helpers/getElementTypeFromProps.d.ts +0 -14
- package/dist/helpers/getElementTypeFromProps.d.ts.map +0 -1
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/init/GrauityInit.d.ts.map +0 -1
- package/dist/init/index.d.ts.map +0 -1
- package/ui/css/colors.scss +0 -131
- package/ui/css/icons.scss +0 -92
- package/ui/elements/index.ts +0 -2
- package/ui/helpers/getElementTypeFromProps.ts +0 -32
- /package/dist/{core → ui/core}/icons/iconTags.d.ts +0 -0
- /package/dist/{core → ui/core}/icons/iconTypes.d.ts +0 -0
- /package/dist/{core → ui/core}/miscellaneous-choices/index.d.ts +0 -0
- /package/dist/{core → ui/core}/miscellaneous-choices/miscellaneousTypes.d.ts +0 -0
- /package/dist/{core → ui/core}/sizes/index.d.ts +0 -0
- /package/dist/{helpers → ui/helpers}/classNameBuilders.d.ts +0 -0
- /package/dist/{init → ui/init}/index.d.ts +0 -0
- /package/ui/{css/sizes.scss → elements/Alert/utils.ts} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import ConfirmationDialog, { ConfirmationDialogProps } from '.';
|
|
7
|
+
|
|
8
|
+
describe('ConfirmationDialog', () => {
|
|
9
|
+
const defaultProps: ConfirmationDialogProps = {
|
|
10
|
+
onConfirm: jest.fn(),
|
|
11
|
+
onCancel: jest.fn(),
|
|
12
|
+
title: 'Modal title',
|
|
13
|
+
description: 'Modal description',
|
|
14
|
+
confirmText: 'Modal confirmText',
|
|
15
|
+
cancelText: 'Modal cancelText',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
it('renders the confirmation dialog title, description and buttons', () => {
|
|
19
|
+
render(<ConfirmationDialog {...defaultProps} />);
|
|
20
|
+
expect(screen.getByText('Modal title')).toBeInTheDocument();
|
|
21
|
+
expect(screen.getByText('Modal description')).toBeInTheDocument();
|
|
22
|
+
expect(screen.getByText('Modal confirmText')).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText('Modal cancelText')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('calls onConfirm when confirm button is clicked', () => {
|
|
27
|
+
render(<ConfirmationDialog {...defaultProps} />);
|
|
28
|
+
fireEvent.click(screen.getByText('Modal confirmText'));
|
|
29
|
+
expect(defaultProps.onConfirm).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('calls onCancel when cancel button is clicked', () => {
|
|
33
|
+
render(<ConfirmationDialog {...defaultProps} />);
|
|
34
|
+
fireEvent.click(screen.getByText('Modal cancelText'));
|
|
35
|
+
expect(defaultProps.onCancel).toHaveBeenCalledTimes(1);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('renders the close button when showCloseButton is not falsy', () => {
|
|
39
|
+
render(<ConfirmationDialog {...defaultProps} showCloseButton />);
|
|
40
|
+
expect(screen.getByTestId('testid-iconbutton')).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not render the close button when showCloseButton is false', () => {
|
|
44
|
+
render(
|
|
45
|
+
<ConfirmationDialog {...defaultProps} showCloseButton={false} />
|
|
46
|
+
);
|
|
47
|
+
expect(
|
|
48
|
+
screen.queryByTestId('testid-iconbutton')
|
|
49
|
+
).not.toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('calls onCancel when close button is present and clicked', () => {
|
|
53
|
+
const onCancelFn = jest.fn();
|
|
54
|
+
render(
|
|
55
|
+
<ConfirmationDialog
|
|
56
|
+
{...defaultProps}
|
|
57
|
+
showCloseButton
|
|
58
|
+
onCancel={onCancelFn}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
fireEvent.click(screen.getByTestId('testid-iconbutton'));
|
|
62
|
+
expect(onCancelFn).toHaveBeenCalledTimes(1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('calls onCancel when hideOnClickAway is true and Escape button is pressed', () => {
|
|
66
|
+
const onCancelFn = jest.fn();
|
|
67
|
+
render(
|
|
68
|
+
<ConfirmationDialog
|
|
69
|
+
{...defaultProps}
|
|
70
|
+
hideOnClickAway
|
|
71
|
+
onCancel={onCancelFn}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
75
|
+
expect(onCancelFn).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('does not call onCancel when hideOnClickAway is false and Escape button is pressed', () => {
|
|
79
|
+
const onCancelFn = jest.fn();
|
|
80
|
+
render(
|
|
81
|
+
<ConfirmationDialog
|
|
82
|
+
{...defaultProps}
|
|
83
|
+
hideOnClickAway={false}
|
|
84
|
+
onCancel={onCancelFn}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
88
|
+
expect(onCancelFn).toHaveBeenCalledTimes(0);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('calls onCancel when hideOnClickAway is true and clicked outside the modal', () => {
|
|
92
|
+
const onCancelFn = jest.fn();
|
|
93
|
+
render(
|
|
94
|
+
<ConfirmationDialog
|
|
95
|
+
{...defaultProps}
|
|
96
|
+
hideOnClickAway
|
|
97
|
+
onCancel={onCancelFn}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
fireEvent.mouseDown(document);
|
|
101
|
+
expect(onCancelFn).toHaveBeenCalledTimes(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('does not call onCancel when hideOnClickAway is false and clicked outside the modal', () => {
|
|
105
|
+
const onCancelFn = jest.fn();
|
|
106
|
+
render(
|
|
107
|
+
<ConfirmationDialog
|
|
108
|
+
{...defaultProps}
|
|
109
|
+
hideOnClickAway={false}
|
|
110
|
+
onCancel={onCancelFn}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
fireEvent.mouseDown(document);
|
|
114
|
+
expect(onCancelFn).toHaveBeenCalledTimes(0);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { useId } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useKeyboardEvent } from '../../../../hooks';
|
|
5
|
+
import useClickAway from '../../../../hooks/useClickAway';
|
|
6
|
+
import useDisableBodyScroll from '../../../../hooks/useDisableBodyScroll';
|
|
7
|
+
import Button, { BUTTON_VARIANTS_ENUM, IconButton } from '../../Button';
|
|
8
|
+
import Modal from '../Modal';
|
|
9
|
+
import { ConfirmationDialogProps } from '../types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A confirmation dialog is a dialog box that asks the user to confirm an action.
|
|
13
|
+
*/
|
|
14
|
+
const ConfirmationDialog = ({
|
|
15
|
+
cancelText,
|
|
16
|
+
confirmText,
|
|
17
|
+
onCancel,
|
|
18
|
+
onConfirm,
|
|
19
|
+
banner,
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
body,
|
|
23
|
+
cancelButtonVariant,
|
|
24
|
+
confirmButtonVariant,
|
|
25
|
+
showCloseButton,
|
|
26
|
+
hideOnClickAway,
|
|
27
|
+
blurBackground,
|
|
28
|
+
mobileBottomFullWidth,
|
|
29
|
+
}: ConfirmationDialogProps) => {
|
|
30
|
+
const modalRef = React.useRef(null);
|
|
31
|
+
|
|
32
|
+
useDisableBodyScroll();
|
|
33
|
+
|
|
34
|
+
useKeyboardEvent(() => {
|
|
35
|
+
if (hideOnClickAway) {
|
|
36
|
+
onCancel();
|
|
37
|
+
}
|
|
38
|
+
}, ['Escape']);
|
|
39
|
+
|
|
40
|
+
useClickAway(modalRef, () => {
|
|
41
|
+
if (hideOnClickAway) {
|
|
42
|
+
onCancel();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const id = useId();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Modal.Wrapper blurBackground={blurBackground}>
|
|
50
|
+
<Modal.Modal
|
|
51
|
+
onClick={(e: Event) => e.stopPropagation()}
|
|
52
|
+
width="auto"
|
|
53
|
+
height="auto"
|
|
54
|
+
ref={modalRef}
|
|
55
|
+
aria-labelledby={`modal-title-${id}`}
|
|
56
|
+
aria-describedby={`modal-description-${id}`}
|
|
57
|
+
aria-modal="true"
|
|
58
|
+
role="dialog"
|
|
59
|
+
mobileBottomFullWidth={mobileBottomFullWidth}
|
|
60
|
+
>
|
|
61
|
+
<Modal.Main>
|
|
62
|
+
{showCloseButton && (
|
|
63
|
+
<Modal.Action justifyContent="end">
|
|
64
|
+
<IconButton
|
|
65
|
+
onClick={onCancel}
|
|
66
|
+
variant="secondary-outlined"
|
|
67
|
+
icon="close"
|
|
68
|
+
ariaLabel="Close"
|
|
69
|
+
/>
|
|
70
|
+
</Modal.Action>
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{banner && <Modal.Banner>{banner}</Modal.Banner>}
|
|
74
|
+
|
|
75
|
+
{title && (
|
|
76
|
+
<Modal.Title id={`modal-title-${id}`}>
|
|
77
|
+
{title}
|
|
78
|
+
</Modal.Title>
|
|
79
|
+
)}
|
|
80
|
+
|
|
81
|
+
{description && (
|
|
82
|
+
<Modal.Description id={`modal-description-${id}`}>
|
|
83
|
+
{description}
|
|
84
|
+
</Modal.Description>
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
{body && <Modal.Body>{body}</Modal.Body>}
|
|
88
|
+
</Modal.Main>
|
|
89
|
+
|
|
90
|
+
<Modal.Action>
|
|
91
|
+
<Button
|
|
92
|
+
variant={
|
|
93
|
+
cancelButtonVariant || BUTTON_VARIANTS_ENUM.DANGER
|
|
94
|
+
}
|
|
95
|
+
fullWidth
|
|
96
|
+
onClick={onCancel}
|
|
97
|
+
>
|
|
98
|
+
{cancelText}
|
|
99
|
+
</Button>
|
|
100
|
+
<Button
|
|
101
|
+
variant={
|
|
102
|
+
confirmButtonVariant || BUTTON_VARIANTS_ENUM.SUCCESS
|
|
103
|
+
}
|
|
104
|
+
fullWidth
|
|
105
|
+
onClick={onConfirm}
|
|
106
|
+
>
|
|
107
|
+
{confirmText}
|
|
108
|
+
</Button>
|
|
109
|
+
</Modal.Action>
|
|
110
|
+
</Modal.Modal>
|
|
111
|
+
</Modal.Wrapper>
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
ConfirmationDialog.propTypes = {
|
|
116
|
+
cancelText: PropTypes.string,
|
|
117
|
+
confirmText: PropTypes.string,
|
|
118
|
+
onCancel: PropTypes.func,
|
|
119
|
+
onConfirm: PropTypes.func,
|
|
120
|
+
banner: PropTypes.string || PropTypes.node,
|
|
121
|
+
title: PropTypes.string || PropTypes.node,
|
|
122
|
+
description: PropTypes.string,
|
|
123
|
+
body: PropTypes.string || PropTypes.node,
|
|
124
|
+
cancelButtonVariant: PropTypes.string,
|
|
125
|
+
confirmButtonVariant: PropTypes.string,
|
|
126
|
+
showCloseButton: PropTypes.bool,
|
|
127
|
+
hideOnClickAway: PropTypes.bool,
|
|
128
|
+
blurBackground: PropTypes.bool,
|
|
129
|
+
mobileBottomFullWidth: PropTypes.bool,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
ConfirmationDialog.defaultProps = {
|
|
133
|
+
cancelText: 'Cancel',
|
|
134
|
+
confirmText: 'Confirm',
|
|
135
|
+
banner: null,
|
|
136
|
+
title: 'Are you sure?',
|
|
137
|
+
description: 'Please confirm your action.',
|
|
138
|
+
body: null,
|
|
139
|
+
onCancel: () => {},
|
|
140
|
+
onConfirm: () => {},
|
|
141
|
+
cancelButtonVariant: 'danger',
|
|
142
|
+
confirmButtonVariant: 'success',
|
|
143
|
+
showCloseButton: false,
|
|
144
|
+
hideOnClickAway: false,
|
|
145
|
+
blurBackground: false,
|
|
146
|
+
mobileBottomFullWidth: false,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { ConfirmationDialogProps };
|
|
150
|
+
|
|
151
|
+
export default ConfirmationDialog;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ModalBodyMainProps,
|
|
6
|
+
ModalBodyProps,
|
|
7
|
+
ModalContainerProps,
|
|
8
|
+
ModalDescriptionProps,
|
|
9
|
+
ModalPaginationItemProps,
|
|
10
|
+
ModalTitleProps,
|
|
11
|
+
ModalWrapperProps,
|
|
12
|
+
} from './types';
|
|
13
|
+
|
|
14
|
+
export const StyledModalWrapper = styled.div<ModalWrapperProps>`
|
|
15
|
+
position: fixed;
|
|
16
|
+
top: 0;
|
|
17
|
+
left: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
bottom: 0;
|
|
20
|
+
background-color: var(--alpha-overlay, rgba(22, 25, 29, 0.8));
|
|
21
|
+
z-index: 1000;
|
|
22
|
+
padding: var(--spacing-16px, 16px);
|
|
23
|
+
display: flex;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
align-items: center;
|
|
26
|
+
font-family: var(--font-family, 'Mona Sans');
|
|
27
|
+
|
|
28
|
+
${({ blurBackground }) =>
|
|
29
|
+
blurBackground &&
|
|
30
|
+
css`
|
|
31
|
+
backdrop-filter: var(--backdrop-blur-8px);
|
|
32
|
+
`}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const StyledModal = styled.div<ModalContainerProps>`
|
|
36
|
+
border: var(--spacing-1px, 1px) solid var(--border, #e1e5ea);
|
|
37
|
+
background: var(--bg-primary, #fff);
|
|
38
|
+
z-index: 1000;
|
|
39
|
+
box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.25);
|
|
40
|
+
border-radius: var(--corner-radius-12px, 12px);
|
|
41
|
+
width: 500px;
|
|
42
|
+
min-width: 400px;
|
|
43
|
+
height: 525px;
|
|
44
|
+
padding: var(--spacing-20px, 20px);
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
gap: var(--spacing-16px, 16px);
|
|
50
|
+
|
|
51
|
+
@media only screen and (max-width: 600px) {
|
|
52
|
+
padding: var(--spacing-18px, 18px);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
${({ width }) =>
|
|
56
|
+
width
|
|
57
|
+
? css`
|
|
58
|
+
width: ${width};
|
|
59
|
+
`
|
|
60
|
+
: ''}
|
|
61
|
+
${({ height }) =>
|
|
62
|
+
height
|
|
63
|
+
? css`
|
|
64
|
+
height: ${height};
|
|
65
|
+
`
|
|
66
|
+
: ''}
|
|
67
|
+
${({ minHeight }) =>
|
|
68
|
+
minHeight
|
|
69
|
+
? css`
|
|
70
|
+
min-height: ${minHeight};
|
|
71
|
+
`
|
|
72
|
+
: ''}
|
|
73
|
+
${({ mobileBottomFullWidth }) =>
|
|
74
|
+
mobileBottomFullWidth
|
|
75
|
+
? css`
|
|
76
|
+
@media only screen and (max-width: 600px) {
|
|
77
|
+
position: fixed;
|
|
78
|
+
bottom: 0;
|
|
79
|
+
border-bottom-left-radius: 0;
|
|
80
|
+
border-bottom-right-radius: 0;
|
|
81
|
+
max-width: unset;
|
|
82
|
+
width: 100%;
|
|
83
|
+
padding: var(--spacing-16px, 16px);
|
|
84
|
+
}
|
|
85
|
+
`
|
|
86
|
+
: ''}
|
|
87
|
+
|
|
88
|
+
${({ modalPadding }) =>
|
|
89
|
+
css`
|
|
90
|
+
padding: ${modalPadding};
|
|
91
|
+
`}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
export const StyledModalMain = styled.div<ModalBodyMainProps>`
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
align-items: center;
|
|
98
|
+
width: 100%;
|
|
99
|
+
flex: 1;
|
|
100
|
+
gap: var(--spacing-12px, 12px);
|
|
101
|
+
|
|
102
|
+
@media only screen and (max-width: 600px) {
|
|
103
|
+
padding: 0;
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
|
|
107
|
+
export const StyledModalDivider = styled.div`
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: var(--spacing-1px, 1px);
|
|
110
|
+
background: var(--border, #e1e5ea);
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
export const StyledModalTitle = styled.h2<ModalTitleProps>`
|
|
114
|
+
color: var(--text-primary, #16191d);
|
|
115
|
+
font-weight: var(--font-weight-semibold, 600);
|
|
116
|
+
font-size: var(--font-size-24px, 24px);
|
|
117
|
+
line-height: var(--spacing-32px, 32px);
|
|
118
|
+
margin: var(--spacing-0px, 0px) auto;
|
|
119
|
+
text-align: center;
|
|
120
|
+
|
|
121
|
+
img {
|
|
122
|
+
width: 100%;
|
|
123
|
+
border-radius: var(--corner-radius-8px, 8px);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@media only screen and (max-width: 600px) {
|
|
127
|
+
font-size: var(--font-size-16px, 16px);
|
|
128
|
+
line-height: var(--spacing-24px, 24px);
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
export const StyledModalDescription = styled.div<ModalDescriptionProps>`
|
|
133
|
+
font-weight: var(--font-weight-450, 450);
|
|
134
|
+
font-size: var(--font-size-16px, 16px);
|
|
135
|
+
line-height: var(--spacing-28px, 28px);
|
|
136
|
+
text-align: center;
|
|
137
|
+
letter-spacing: 0.2px;
|
|
138
|
+
color: var(--text-secondary, #5b6271);
|
|
139
|
+
white-space: pre-line;
|
|
140
|
+
|
|
141
|
+
@media only screen and (max-width: 600px) {
|
|
142
|
+
font-size: var(--font-size-14px, 14px);
|
|
143
|
+
line-height: var(--spacing-24px, 24px);
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
export const StyledModalBody = styled.div<ModalBodyProps>`
|
|
148
|
+
font-weight: var(--font-weight-450, 450);
|
|
149
|
+
font-size: var(--font-size-16px, 16px);
|
|
150
|
+
line-height: var(--spacing-28px, 28px);
|
|
151
|
+
text-align: center;
|
|
152
|
+
letter-spacing: 0.2px;
|
|
153
|
+
color: var(--text-secondary, #5b6271);
|
|
154
|
+
margin: ${({ modalBodyMargin }) => modalBodyMargin && modalBodyMargin};
|
|
155
|
+
white-space: pre-line;
|
|
156
|
+
width: 100%;
|
|
157
|
+
flex: 1;
|
|
158
|
+
|
|
159
|
+
img {
|
|
160
|
+
width: 100%;
|
|
161
|
+
border-radius: var(--corner-radius-8px, 8px);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@media only screen and (max-width: 600px) {
|
|
165
|
+
font-size: var(--font-size-14px, 14px);
|
|
166
|
+
line-height: var(--spacing-24px, 24px);
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
|
|
170
|
+
export const StyledModalPaginatedActions = styled.div`
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
width: 100%;
|
|
174
|
+
justify-content: center;
|
|
175
|
+
gap: var(--spacing-12px, 12px);
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
export const StyledModalPagination = styled.div`
|
|
179
|
+
display: flex;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
align-items: center;
|
|
182
|
+
gap: var(--spacing-4px, 4px);
|
|
183
|
+
margin-top: auto;
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
export const StyledModalPaginationItem = styled.div<ModalPaginationItemProps>`
|
|
187
|
+
width: 6px;
|
|
188
|
+
height: 6px;
|
|
189
|
+
border-radius: var(--corner-radius-50percent, 50%);
|
|
190
|
+
background: var(--border, #e1e5ea);
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
transition: all 0.1s ease-in-out;
|
|
193
|
+
|
|
194
|
+
${({ active }) =>
|
|
195
|
+
active
|
|
196
|
+
? 'background: var(--text-secondary, #5b6271);'
|
|
197
|
+
: '&:hover {background: var(--text-disabled, #8C95A6);}'}
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
export const StyledModalAction = styled.div<{
|
|
201
|
+
justifyContent?: string;
|
|
202
|
+
children: ReactNode;
|
|
203
|
+
}>`
|
|
204
|
+
display: flex;
|
|
205
|
+
align-items: center;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
width: 100%;
|
|
208
|
+
gap: var(--spacing-8px, 8px);
|
|
209
|
+
|
|
210
|
+
${({ justifyContent }) =>
|
|
211
|
+
justifyContent &&
|
|
212
|
+
css`
|
|
213
|
+
justify-content: ${justifyContent};
|
|
214
|
+
`}
|
|
215
|
+
|
|
216
|
+
img {
|
|
217
|
+
width: 100%;
|
|
218
|
+
border-radius: var(--corner-radius-8px, 8px);
|
|
219
|
+
}
|
|
220
|
+
`;
|
|
221
|
+
|
|
222
|
+
export const StyledModalBanner = styled.div`
|
|
223
|
+
width: 100%;
|
|
224
|
+
position: relative;
|
|
225
|
+
|
|
226
|
+
img {
|
|
227
|
+
width: 100%;
|
|
228
|
+
border-radius: var(--corner-radius-8px, 8px);
|
|
229
|
+
}
|
|
230
|
+
`;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import Button from '../Button';
|
|
7
|
+
import Modal from './Modal';
|
|
8
|
+
import { ModalProps } from './types';
|
|
9
|
+
|
|
10
|
+
describe('Modal', () => {
|
|
11
|
+
const defaultProps: ModalProps = {
|
|
12
|
+
banner: 'Modal banner',
|
|
13
|
+
title: 'Modal title',
|
|
14
|
+
description: 'Modal description',
|
|
15
|
+
body: 'Modal body',
|
|
16
|
+
action: (
|
|
17
|
+
<>
|
|
18
|
+
<Button variant="primary" onClick={() => {}} fullWidth>
|
|
19
|
+
Primary Button
|
|
20
|
+
</Button>
|
|
21
|
+
<Button variant="secondary" onClick={() => {}} fullWidth>
|
|
22
|
+
Secondary Button
|
|
23
|
+
</Button>
|
|
24
|
+
</>
|
|
25
|
+
),
|
|
26
|
+
hideOnClickAway: true,
|
|
27
|
+
blurBackground: false,
|
|
28
|
+
onHide: () => {},
|
|
29
|
+
mobileBottomFullWidth: false,
|
|
30
|
+
modalPadding: '20px',
|
|
31
|
+
modalBodyMargin: '',
|
|
32
|
+
width: '500px',
|
|
33
|
+
height: 'auto',
|
|
34
|
+
minHeight: 'auto',
|
|
35
|
+
showCloseButton: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
it('renders the modal banner, title, description and body', () => {
|
|
39
|
+
render(<Modal {...defaultProps} />);
|
|
40
|
+
expect(screen.getByText('Modal banner')).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText('Modal title')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText('Modal description')).toBeInTheDocument();
|
|
43
|
+
expect(screen.getByText('Modal body')).toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('renders the modal action buttons', () => {
|
|
47
|
+
render(<Modal {...defaultProps} />);
|
|
48
|
+
expect(screen.getByText('Primary Button')).toBeInTheDocument();
|
|
49
|
+
expect(screen.getByText('Secondary Button')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('renders the close button', () => {
|
|
53
|
+
render(<Modal {...defaultProps} />);
|
|
54
|
+
expect(screen.getByTestId('testid-iconbutton')).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('does not render the close button when showCloseButton is false', () => {
|
|
58
|
+
render(<Modal {...defaultProps} showCloseButton={false} />);
|
|
59
|
+
expect(
|
|
60
|
+
screen.queryByTestId('testid-iconbutton')
|
|
61
|
+
).not.toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('calls onHide when close button is clicked', () => {
|
|
65
|
+
const onHideFn = jest.fn();
|
|
66
|
+
render(<Modal {...defaultProps} onHide={onHideFn} />);
|
|
67
|
+
fireEvent.click(screen.getByTestId('testid-iconbutton'));
|
|
68
|
+
expect(onHideFn).toHaveBeenCalledTimes(1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('calls onHide when Escape button is pressed', () => {
|
|
72
|
+
const onHideFn = jest.fn();
|
|
73
|
+
render(<Modal {...defaultProps} onHide={onHideFn} />);
|
|
74
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
75
|
+
expect(onHideFn).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('calls onHide when clicked outside the modal', () => {
|
|
79
|
+
const onHideFn = jest.fn();
|
|
80
|
+
render(<Modal {...defaultProps} onHide={onHideFn} />);
|
|
81
|
+
fireEvent.mouseDown(document);
|
|
82
|
+
expect(onHideFn).toHaveBeenCalledTimes(1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('does not call onHide when clicked inside the modal', () => {
|
|
86
|
+
const onHideFn = jest.fn();
|
|
87
|
+
render(<Modal {...defaultProps} onHide={onHideFn} />);
|
|
88
|
+
fireEvent.click(screen.getByTestId('testid-modal'));
|
|
89
|
+
expect(onHideFn).toHaveBeenCalledTimes(0);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('does not call onHide on outside click when hideOnClickAway is false', () => {
|
|
93
|
+
const onHideFn = jest.fn();
|
|
94
|
+
render(
|
|
95
|
+
<Modal
|
|
96
|
+
{...defaultProps}
|
|
97
|
+
onHide={onHideFn}
|
|
98
|
+
hideOnClickAway={false}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
fireEvent.click(screen.getByTestId('testid-modalwrapper'));
|
|
102
|
+
expect(onHideFn).toHaveBeenCalledTimes(0);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('does not call onHide on Escape key press when hideOnClickAway is false', () => {
|
|
106
|
+
const onHideFn = jest.fn();
|
|
107
|
+
render(
|
|
108
|
+
<Modal
|
|
109
|
+
{...defaultProps}
|
|
110
|
+
onHide={onHideFn}
|
|
111
|
+
hideOnClickAway={false}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' });
|
|
115
|
+
expect(onHideFn).toHaveBeenCalledTimes(0);
|
|
116
|
+
});
|
|
117
|
+
});
|