@bitrise/bitkit 9.38.1 → 9.38.2-alpha-chakra.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.38.1",
4
+ "version": "9.38.2-alpha-chakra.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -1,6 +1,7 @@
1
1
  import { Story, ComponentMeta } from '@storybook/react';
2
+ import { useDisclosure } from '@chakra-ui/react';
2
3
  import Button from '../Button/Button';
3
- import Dialog, { DialogProps, useDialog } from './Dialog';
4
+ import Dialog, { DialogProps } from './Dialog';
4
5
  import DialogBody from './DialogBody';
5
6
  import DialogFooter from './DialogFooter';
6
7
 
@@ -24,13 +25,13 @@ interface StoryType extends DialogProps {
24
25
  }
25
26
 
26
27
  export const WithProps: Story<StoryType> = ({ lotsOfContent, ...props }: StoryType) => {
27
- const state = useDialog();
28
+ const { isOpen, onClose, onOpen } = useDisclosure();
28
29
 
29
30
  return (
30
31
  <>
31
- <Button onClick={state.onOpen}>Open Dialog</Button>
32
+ <Button onClick={onOpen}>Open Dialog</Button>
32
33
 
33
- <Dialog {...props} state={state}>
34
+ <Dialog {...props} isOpen={isOpen} onClose={onClose}>
34
35
  <DialogBody>
35
36
  {[...Array(lotsOfContent ? 10 : 1)].map((_key, index) => (
36
37
  // eslint-disable-next-line react/no-array-index-key
@@ -5,42 +5,38 @@ import {
5
5
  ModalCloseButton,
6
6
  ModalHeader,
7
7
  useBreakpointValue,
8
- useDisclosure,
9
8
  HTMLChakraProps,
10
9
  } from '@chakra-ui/react';
11
10
  import Icon from '../Icon/Icon';
12
11
  import Text from '../Text/Text';
13
12
 
14
- type DialogState = {
15
- isOpen: boolean;
16
- onClose(): void;
17
- onOpen?(): void;
18
- };
19
-
20
- export const useDialog = (): DialogState => {
21
- const { isOpen, onOpen, onClose } = useDisclosure();
22
- return {
23
- isOpen,
24
- onClose,
25
- onOpen,
26
- };
27
- };
28
13
  export interface DialogProps extends Omit<HTMLChakraProps<'section'>, 'scrollBehavior'> {
29
14
  dataTestid?: string;
15
+ isOpen: boolean;
16
+ onClose(): void;
30
17
  size?: 'small' | 'medium' | 'large' | 'full';
31
18
  scrollBehavior?: 'inside' | 'outside';
32
- state: DialogState;
33
19
  title: string;
34
20
  trapFocus?: boolean;
35
21
  }
36
22
 
37
- const Dialog = ({ children, dataTestid, scrollBehavior, state, size, title, trapFocus, ...rest }: DialogProps) => {
23
+ const Dialog = ({
24
+ children,
25
+ dataTestid,
26
+ isOpen,
27
+ onClose,
28
+ scrollBehavior,
29
+ size,
30
+ title,
31
+ trapFocus,
32
+ ...rest
33
+ }: DialogProps) => {
38
34
  const dialogSize = useBreakpointValue({ mobile: 'mobile', desktop: size });
39
35
  return (
40
36
  <Modal
41
37
  closeOnOverlayClick={false}
42
- isOpen={state.isOpen}
43
- onClose={state.onClose}
38
+ isOpen={isOpen}
39
+ onClose={onClose}
44
40
  scrollBehavior={scrollBehavior}
45
41
  size={dialogSize}
46
42
  trapFocus={trapFocus}
@@ -1 +1,2 @@
1
1
  export { default as useHistory } from './useHistory';
2
+ export { useDisclosure } from '@chakra-ui/react';
package/src/index.ts CHANGED
@@ -91,7 +91,6 @@ export { default as EmptyState } from './Components/EmptyState/EmptyState';
91
91
 
92
92
  export type { DialogProps } from './Components/Dialog/Dialog';
93
93
  export { default as Dialog } from './Components/Dialog/Dialog';
94
- export { useDialog } from './Components/Dialog/Dialog';
95
94
 
96
95
  export type { DialogBodyProps } from './Components/Dialog/DialogBody';
97
96
  export { default as DialogBody } from './Components/Dialog/DialogBody';