@basic-ui/material 0.1.12 → 0.1.15

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.
Files changed (114) hide show
  1. package/build/cjs/index.js +38 -27
  2. package/build/cjs/index.js.map +1 -1
  3. package/build/esm/Alert/Alert.d.ts +1 -1
  4. package/build/esm/AppBar/AppBar.d.ts +1 -1
  5. package/build/esm/AppBar/AppBarButton.d.ts +1 -1
  6. package/build/esm/Badge/Badge.d.ts +1 -1
  7. package/build/esm/BottomSheet/BottomSheet.d.ts +1 -1
  8. package/build/esm/BottomSheet/BottomSheetSurface.d.ts +1 -1
  9. package/build/esm/Button/BaseButton.d.ts +1 -1
  10. package/build/esm/Button/Button.d.ts +1 -1
  11. package/build/esm/Button/FilledButton.d.ts +1 -1
  12. package/build/esm/Button/OutlinedButton.d.ts +1 -1
  13. package/build/esm/Button/TransparentButton.d.ts +1 -1
  14. package/build/esm/CheckBox/CheckBox.d.ts +1 -1
  15. package/build/esm/CheckBox/CheckBoxIcon.d.ts +1 -1
  16. package/build/esm/Chip/ButtonChip.d.ts +1 -1
  17. package/build/esm/Chip/ButtonChip.js +4 -0
  18. package/build/esm/Chip/ButtonChip.js.map +1 -1
  19. package/build/esm/Chip/ChipBase.d.ts +1 -1
  20. package/build/esm/Chip/ChoiceChip.d.ts +1 -1
  21. package/build/esm/ColorMode/ColorModeProvider.js +10 -3
  22. package/build/esm/ColorMode/ColorModeProvider.js.map +1 -1
  23. package/build/esm/Combobox/Combobox.d.ts +7 -7
  24. package/build/esm/Dialog/Dialog.d.ts +1 -1
  25. package/build/esm/Dialog/DialogBackdrop.d.ts +1 -1
  26. package/build/esm/Dialog/DialogContainer.d.ts +1 -1
  27. package/build/esm/Dialog/DialogSurface.d.ts +1 -1
  28. package/build/esm/Dialog/Scrim.d.ts +1 -1
  29. package/build/esm/Dialog/useDialogAnimation.js +1 -1
  30. package/build/esm/Dialog/useDialogAnimation.js.map +1 -1
  31. package/build/esm/Divider/Divider.d.ts +1 -1
  32. package/build/esm/LineRipple/LineRipple.d.ts +1 -1
  33. package/build/esm/Link/Link.d.ts +1 -1
  34. package/build/esm/List/List.d.ts +1 -1
  35. package/build/esm/ListItem/ListItem.d.ts +1 -1
  36. package/build/esm/Menu/Menu.d.ts +4 -4
  37. package/build/esm/Paper/Paper.d.ts +1 -1
  38. package/build/esm/ProgressSpinner/ProgressSpinner.d.ts +1 -1
  39. package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
  40. package/build/esm/Select/Select.js +2 -2
  41. package/build/esm/Select/Select.js.map +1 -1
  42. package/build/esm/Select/SelectIcon.d.ts +1 -1
  43. package/build/esm/SelectItem/SelectItem.d.ts +1 -1
  44. package/build/esm/SelectionControl/SelectionControlLabel.d.ts +1 -1
  45. package/build/esm/SelectionControl/SelectionControlText.d.ts +1 -1
  46. package/build/esm/Skeleton/DelayAppearance.d.ts +1 -1
  47. package/build/esm/Skeleton/Skeleton.d.ts +1 -1
  48. package/build/esm/Snackbar/Snackbar.d.ts +1 -1
  49. package/build/esm/Switch/Switch.d.ts +1 -1
  50. package/build/esm/Tab/Tab.d.ts +1 -1
  51. package/build/esm/Tab/TabList.d.ts +1 -1
  52. package/build/esm/Tab/TabPanel.d.ts +1 -1
  53. package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
  54. package/build/esm/Table/Table.d.ts +1 -1
  55. package/build/esm/Table/TableBody.d.ts +1 -1
  56. package/build/esm/Table/TableCell.d.ts +1 -1
  57. package/build/esm/Table/TableHead.d.ts +1 -1
  58. package/build/esm/Table/TableRow.d.ts +1 -1
  59. package/build/esm/Text/LoremIpsum.d.ts +4 -4
  60. package/build/esm/Text/LoremIpsum.js.map +1 -1
  61. package/build/esm/Text/Text.d.ts +1 -1
  62. package/build/esm/TextField/FilledContainer.d.ts +1 -1
  63. package/build/esm/TextField/HelperText.d.ts +1 -1
  64. package/build/esm/TextField/Input.d.ts +1 -1
  65. package/build/esm/TextField/OutlinedContainer.d.ts +1 -1
  66. package/build/esm/TextField/TextField.d.ts +1 -1
  67. package/build/esm/TextField/TextField.js +2 -2
  68. package/build/esm/TextField/TextField.js.map +1 -1
  69. package/build/esm/ThemeExplorer/TextFieldColorPicker.js +1 -1
  70. package/build/esm/ThemeExplorer/TextFieldColorPicker.js.map +1 -1
  71. package/build/esm/ThemeExplorer/makeColorScheme.js +2 -2
  72. package/build/esm/ThemeExplorer/makeColorScheme.js.map +1 -1
  73. package/build/esm/Tooltip/Tooltip.d.ts +1 -1
  74. package/build/esm/hooks/useAnimation.js +22 -21
  75. package/build/esm/hooks/useAnimation.js.map +1 -1
  76. package/build/esm/theme/useTheme.d.ts +1 -425
  77. package/build/tsconfig.tsbuildinfo +1 -4757
  78. package/package.json +13 -13
  79. package/src/Alert/Alert.story.tsx +5 -6
  80. package/src/AppBar/AppBar.story.tsx +11 -20
  81. package/src/BottomSheet/BottomSheet.story.tsx +5 -6
  82. package/src/Button/Button.story.tsx +14 -14
  83. package/src/Button/SpinnerButton.story.tsx +6 -6
  84. package/src/CheckBox/CheckBox.story.tsx +7 -6
  85. package/src/Chip/ButtonChip.tsx +3 -1
  86. package/src/Chip/Chip.story.tsx +56 -6
  87. package/src/ColorMode/ColorModeProvider.tsx +9 -3
  88. package/src/Combobox/Combobox.story.tsx +12 -13
  89. package/src/Dialog/Dialog.story.tsx +7 -8
  90. package/src/Dialog/useDialogAnimation.tsx +1 -1
  91. package/src/Divider/Divider.story.tsx +6 -5
  92. package/src/FloatingLabel/FloatingLabel.story.tsx +10 -9
  93. package/src/LineRipple/LineRipple.story.tsx +5 -4
  94. package/src/Link/Link.story.tsx +3 -4
  95. package/src/ListItem/ListItem.story.tsx +6 -5
  96. package/src/Menu/Menu.story.tsx +8 -7
  97. package/src/NotchedOutline/NotchedOutline.story.tsx +5 -4
  98. package/src/Paper/Paper.story.tsx +5 -4
  99. package/src/ProgressSpinner/ProgressSpinner.story.tsx +5 -4
  100. package/src/RadioButton/RadioButton.story.tsx +12 -10
  101. package/src/Ripple/Ripple.story.tsx +5 -4
  102. package/src/Select/Select.story.tsx +8 -7
  103. package/src/Select/Select.tsx +1 -1
  104. package/src/Skeleton/Skeleton.story.tsx +7 -6
  105. package/src/Snackbar/Snackbar.story.tsx +7 -6
  106. package/src/Switch/Switch.story.tsx +5 -4
  107. package/src/Tab/Tab.story.tsx +7 -5
  108. package/src/Table/Table.story.tsx +5 -4
  109. package/src/Text/LoremIpsum.tsx +3 -1
  110. package/src/Text/Text.story.tsx +5 -4
  111. package/src/TextField/TextField.story.tsx +7 -6
  112. package/src/TextField/TextField.tsx +2 -2
  113. package/src/Tooltip/Tooltip.story.tsx +5 -4
  114. package/src/hooks/useAnimation.ts +42 -32
@@ -1,11 +1,14 @@
1
1
  import {} from './';
2
- import { storiesOf } from '@storybook/react';
3
2
  import { NotchedOutline } from './NotchedOutline';
4
3
  import { Box } from '../Box';
5
4
  import { FloatingLabel } from '../FloatingLabel';
6
5
  import { rem } from 'polished';
7
6
  // import './styles.css';
8
7
 
8
+ export default {
9
+ title: 'helper components/NotchedOutline',
10
+ };
11
+
9
12
  const Example = () => {
10
13
  const labelWidth = 68.27;
11
14
 
@@ -92,6 +95,4 @@ const Example = () => {
92
95
  );
93
96
  };
94
97
 
95
- const stories = storiesOf('Helper Components/NotchedOutline', module);
96
-
97
- stories.add('controlled', () => <Example />);
98
+ export const Controlled = () => <Example />;
@@ -1,9 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import { Paper } from './';
3
- import { storiesOf } from '@storybook/react';
4
3
  import { Text } from '../Text';
5
4
  import { Box } from '../Box';
6
5
 
6
+ export default {
7
+ title: 'components/Paper',
8
+ };
9
+
7
10
  const Example = ({}) => {
8
11
  const [elevation, setElevation] = useState(0);
9
12
 
@@ -30,6 +33,4 @@ const Example = ({}) => {
30
33
  );
31
34
  };
32
35
 
33
- const stories = storiesOf('Components/Paper', module);
34
-
35
- stories.add('paper', () => <Example />);
36
+ export const Default = () => <Example />;
@@ -1,8 +1,11 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { ProgressSpinner } from './';
3
- import { storiesOf } from '@storybook/react';
4
3
  import { Box } from '../Box';
5
4
 
5
+ export default {
6
+ title: 'components/ProgressSpinner',
7
+ };
8
+
6
9
  const Example = () => {
7
10
  const steps = [0, 25, 50, 75, 100];
8
11
  const [currentProgress, setCurrentProgress] = useState(0);
@@ -28,6 +31,4 @@ const Example = () => {
28
31
  );
29
32
  };
30
33
 
31
- const stories = storiesOf('Components/ProgressSpinner', module);
32
-
33
- stories.add('controlled', () => <Example />);
34
+ export const Default = () => <Example />;
@@ -1,9 +1,12 @@
1
1
  import { useState } from 'react';
2
2
  import type * as React from 'react';
3
3
  import { RadioButton, RadioGroup, Box } from '../';
4
- import { storiesOf } from '@storybook/react';
5
4
  // import './styles.css';
6
5
 
6
+ export default {
7
+ title: 'components/RadioButton',
8
+ };
9
+
7
10
  const Example = (props) => {
8
11
  return (
9
12
  <>
@@ -29,7 +32,7 @@ const Example = (props) => {
29
32
  );
30
33
  };
31
34
 
32
- const Standalone = (props) => {
35
+ const StandaloneExample = (props) => {
33
36
  const [selectedValue, setSelectedValue] = useState('a');
34
37
  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35
38
  setSelectedValue(e.target.value);
@@ -90,17 +93,16 @@ const Standalone = (props) => {
90
93
  );
91
94
  };
92
95
 
93
- const stories = storiesOf('Components/RadioButton', module);
94
-
95
- stories.add('controlled', () => (
96
+ export const Controlled = () => (
96
97
  <>
97
98
  <Example name="demo-1" />
98
99
  <Example name="demo-2" />
99
100
  </>
100
- ));
101
- stories.add('standalone', () => (
101
+ );
102
+
103
+ export const Standalone = () => (
102
104
  <>
103
- <Standalone name="demo-1" />
104
- <Standalone name="demo-2" />
105
+ <StandaloneExample name="demo-1" />
106
+ <StandaloneExample name="demo-2" />
105
107
  </>
106
- ));
108
+ );
@@ -3,10 +3,13 @@ import { Ripple, useRipple } from './';
3
3
  import { Box } from '../Box';
4
4
  import { Text } from '../Text';
5
5
  import { Button } from '../Button';
6
- import { storiesOf } from '@storybook/react';
7
6
  import { useTheme } from '../theme';
8
7
  import { get } from '@styled-system/css';
9
8
 
9
+ export default {
10
+ title: 'helper components/Ripple',
11
+ };
12
+
10
13
  const Example = () => {
11
14
  const theme = useTheme();
12
15
  const ref = useRef<HTMLDivElement>();
@@ -66,6 +69,4 @@ const Example = () => {
66
69
  );
67
70
  };
68
71
 
69
- const stories = storiesOf('Helper Components/Ripple', module);
70
-
71
- stories.add('controlled', () => <Example />);
72
+ export const Controlled = () => <Example />;
@@ -1,11 +1,14 @@
1
1
  import { useState } from 'react';
2
2
  import { Select } from './';
3
3
  import { SelectItem } from '../SelectItem';
4
- import { storiesOf } from '@storybook/react';
5
4
  import { Box } from '../Box';
6
5
  import { CheckBox } from '../CheckBox';
7
6
  // import './styles.css';
8
7
 
8
+ export default {
9
+ title: 'components/Select',
10
+ };
11
+
9
12
  const Example = ({ variant, native = false }) => {
10
13
  const [error, setError] = useState<boolean | string>(false);
11
14
  const [color, setColor] = useState<'primary' | 'secondary'>('primary');
@@ -191,9 +194,7 @@ const Example = ({ variant, native = false }) => {
191
194
  );
192
195
  };
193
196
 
194
- const stories = storiesOf('Components/Select', module);
195
-
196
- stories.add('filled', () => <Example variant="filled" />);
197
- stories.add('outlined', () => <Example variant="outlined" />);
198
- stories.add('filled, native', () => <Example variant="filled" native />);
199
- stories.add('outlined, native', () => <Example variant="outlined" native />);
197
+ export const Filled = () => <Example variant="filled" />;
198
+ export const Outlined = () => <Example variant="outlined" />;
199
+ export const FilledNative = () => <Example variant="filled" native />;
200
+ export const OutlinedNative = () => <Example variant="outlined" native />;
@@ -5,12 +5,12 @@ import {
5
5
  ForwardRefExoticComponent,
6
6
  RefAttributes,
7
7
  useEffect,
8
+ useId,
8
9
  } from 'react';
9
10
 
10
11
  import type * as React from 'react';
11
12
  import {
12
13
  wrapEvent,
13
- useId,
14
14
  assignMultipleRefs,
15
15
  useControlledState,
16
16
  } from '@basic-ui/core';
@@ -1,9 +1,12 @@
1
1
  import { Skeleton } from './';
2
- import { storiesOf } from '@storybook/react';
3
2
  import { Box } from '../Box';
4
3
  import { Text } from '../Text';
5
4
  import { DelayAppearance } from './DelayAppearance';
6
5
 
6
+ export default {
7
+ title: 'components/Skeleton',
8
+ };
9
+
7
10
  const Skeletons = ({
8
11
  animation = 'pulse',
9
12
  }: {
@@ -46,11 +49,9 @@ const Example = () => {
46
49
  );
47
50
  };
48
51
 
49
- const stories = storiesOf('Components/Skeleton', module);
50
-
51
- stories.add('controlled', () => <Example />);
52
- stories.add('controlled, delayed appearance', () => (
52
+ export const Default = () => <Example />;
53
+ export const DelayedAppearance = () => (
53
54
  <DelayAppearance>
54
55
  <Example />
55
56
  </DelayAppearance>
56
- ));
57
+ );
@@ -1,6 +1,5 @@
1
1
  import { useState } from 'react';
2
2
  import { Snackbar } from './';
3
- import { storiesOf } from '@storybook/react';
4
3
  import { Box } from '../Box';
5
4
  import { Button } from '../Button';
6
5
  import { Select } from '../Select';
@@ -9,6 +8,10 @@ import { Link } from '../Link';
9
8
  import { StackProvider, useStack } from './Stack';
10
9
  // import './styles.css';
11
10
 
11
+ export default {
12
+ title: 'components/Snackbar',
13
+ };
14
+
12
15
  const Example = () => {
13
16
  return (
14
17
  <>
@@ -90,8 +93,6 @@ const SnackbarStackExample = () => {
90
93
  );
91
94
  };
92
95
 
93
- const stories = storiesOf('Components/Snackbar', module);
94
-
95
- stories.add('simple', () => <Example />);
96
- stories.add('controlled', () => <ControlledExample />);
97
- stories.add('snackbar stack', () => <SnackbarStackExample />);
96
+ export const Default = () => <Example />;
97
+ export const Controlled = () => <ControlledExample />;
98
+ export const SnackbarStack = () => <SnackbarStackExample />;
@@ -1,6 +1,9 @@
1
1
  import { Switch } from './';
2
2
  import { Box } from '../';
3
- import { storiesOf } from '@storybook/react';
3
+
4
+ export default {
5
+ title: 'components/Switch',
6
+ };
4
7
 
5
8
  const Example = () => {
6
9
  return (
@@ -21,6 +24,4 @@ const Example = () => {
21
24
  );
22
25
  };
23
26
 
24
- const stories = storiesOf('Components/Switch', module);
25
-
26
- stories.add('controlled', () => <Example />);
27
+ export const Default = () => <Example />;
@@ -1,8 +1,12 @@
1
1
  import { Tabs, TabList, Tab, TabPanels, TabPanel } from './';
2
2
  import { AppBar } from '../AppBar';
3
- import { storiesOf } from '@storybook/react';
3
+
4
4
  // import './styles.css';
5
5
 
6
+ export default {
7
+ title: 'components/Tab',
8
+ };
9
+
6
10
  const Example = () => {
7
11
  return (
8
12
  <Tabs defaultIndex={0}>
@@ -45,7 +49,5 @@ const ExampleAppBar = () => {
45
49
  );
46
50
  };
47
51
 
48
- const stories = storiesOf('Components/Tab', module);
49
-
50
- stories.add('controlled', () => <Example />);
51
- stories.add('with app bar', () => <ExampleAppBar />);
52
+ export const Controlled = () => <Example />;
53
+ export const WithAppBar = () => <ExampleAppBar />;
@@ -1,6 +1,9 @@
1
1
  import { Table, TableRow, TableBody, TableHead, TableCell } from './';
2
2
  import { Link } from '../Link';
3
- import { storiesOf } from '@storybook/react';
3
+
4
+ export default {
5
+ title: 'components/Table',
6
+ };
4
7
 
5
8
  const data = {
6
9
  items: [
@@ -221,6 +224,4 @@ const GitHubTable = () => {
221
224
  );
222
225
  };
223
226
 
224
- const stories = storiesOf('Components/Table', module);
225
-
226
- stories.add('github table', () => <GitHubTable />);
227
+ export const Example = () => <GitHubTable />;
@@ -1,8 +1,10 @@
1
+ import { FC } from 'react';
1
2
  import { Text } from '.';
2
3
 
3
4
  const phrase =
4
5
  'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tincidunt sem ut tincidunt eleifend. Cras eget sem nisi. Mauris at orci pretium, auctor ex non, vestibulum mauris. Etiam at nisi eu enim volutpat semper. Phasellus interdum tincidunt eleifend. Suspendisse potenti. Nulla dapibus felis in purus tristique pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
5
- export const LoremIpsum = ({ count = 50 }) => {
6
+
7
+ export const LoremIpsum: FC<{ count: number }> = ({ count = 50 }) => {
6
8
  const phrases = [];
7
9
  for (let i = 0; i < count; i++) {
8
10
  phrases.push(
@@ -1,8 +1,11 @@
1
1
  import { Text } from './';
2
- import { storiesOf } from '@storybook/react';
3
2
  import { Box } from '../Box';
4
3
  // import './styles.css';
5
4
 
5
+ export default {
6
+ title: 'components/Text',
7
+ };
8
+
6
9
  const Example = () => {
7
10
  const variantMapping = {
8
11
  h1: 'Heading 1',
@@ -34,6 +37,4 @@ const Example = () => {
34
37
  );
35
38
  };
36
39
 
37
- const stories = storiesOf('Components/Text', module);
38
-
39
- stories.add('all variants', () => <Example />);
40
+ export const AllVariants = () => <Example />;
@@ -1,11 +1,14 @@
1
1
  import { useState } from 'react';
2
- import { TextField } from './';
3
- import { storiesOf } from '@storybook/react';
4
2
  import { Box } from '../Box';
5
3
  import { CheckBox } from '../CheckBox';
6
4
  import { Select, SelectItem } from '../';
7
5
  import { Button } from '../Button';
8
6
  import { alpha } from '../color';
7
+ import { TextField } from './';
8
+
9
+ export default {
10
+ title: 'components/TextField',
11
+ };
9
12
 
10
13
  const Example = ({ variant }) => {
11
14
  const [error, setError] = useState<boolean | string>(false);
@@ -220,7 +223,5 @@ const Example = ({ variant }) => {
220
223
  );
221
224
  };
222
225
 
223
- const stories = storiesOf('Components/TextField', module);
224
-
225
- stories.add('filled', () => <Example variant="filled" />);
226
- stories.add('outlined', () => <Example variant="outlined" />);
226
+ export const Filled = () => <Example variant="filled" />;
227
+ export const Outlined = () => <Example variant="outlined" />;
@@ -1,6 +1,6 @@
1
- import { forwardRef, useState } from 'react';
1
+ import { forwardRef, useState, useId } from 'react';
2
2
  import type * as React from 'react';
3
- import { wrapEvent, useId, useControlledState } from '@basic-ui/core';
3
+ import { wrapEvent, useControlledState } from '@basic-ui/core';
4
4
  import { Input, InputProps } from './Input';
5
5
  import { useTheme } from '../theme';
6
6
  import { FilledContainer } from './FilledContainer';
@@ -1,9 +1,12 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import { Tooltip } from './';
3
3
  import { Button } from '../Button';
4
- import { storiesOf } from '@storybook/react';
5
4
  // import './styles.css';
6
5
 
6
+ export default {
7
+ title: 'components/Tooltip',
8
+ };
9
+
7
10
  const Example = () => {
8
11
  const buttonRef = useRef();
9
12
  const [counter, setCounter] = useState(0);
@@ -28,6 +31,4 @@ const Example = () => {
28
31
  );
29
32
  };
30
33
 
31
- const stories = storiesOf('Components/Tooltip', module);
32
-
33
- stories.add('controlled', () => <Example />);
34
+ export const Default = () => <Example />;
@@ -43,51 +43,61 @@ export function useAnimation<
43
43
  });
44
44
 
45
45
  const handleClose = useCallback(() => {
46
- setAnimation((animation) => ({
47
- ...animation,
48
- state: 'close',
49
- style: animationStyle.close || animationStyle.closed,
50
- timing: closeTimeoutInMilliseconds,
51
- }));
52
-
53
- return setTimeout(() => {
54
- setAnimation({
55
- state: 'closed',
56
- style: animationStyle.closed,
57
- open: false,
58
- timing: closeTimeoutInMilliseconds,
59
- });
60
- }, closeTimeoutInMilliseconds);
46
+ setAnimation((animation) =>
47
+ animation.state === 'closed'
48
+ ? animation
49
+ : {
50
+ ...animation,
51
+ state: 'close',
52
+ style: animationStyle.close || animationStyle.closed,
53
+ timing: closeTimeoutInMilliseconds,
54
+ }
55
+ );
61
56
  }, [animationStyle, closeTimeoutInMilliseconds]);
62
57
 
63
58
  const handleOpen = useCallback(() => {
64
- setAnimation((animation) => ({
65
- ...animation,
66
- open: true,
67
- state: 'opening',
68
- style: animationStyle.opening || animationStyle.closed,
69
- }));
70
- return requestAnimationFrame(() => {
59
+ setAnimation((animation) =>
60
+ animation.state === 'open'
61
+ ? animation
62
+ : {
63
+ ...animation,
64
+ open: true,
65
+ state: 'opening',
66
+ style: animationStyle.opening || animationStyle.closed,
67
+ }
68
+ );
69
+ }, [animationStyle]);
70
+
71
+ useEffect(() => {
72
+ if (state === 'opening') {
71
73
  setAnimation((animation) => ({
72
74
  ...animation,
73
75
  state: 'open',
74
76
  style: animationStyle.open,
75
77
  timing: openTimeoutInMilliseconds,
76
78
  }));
77
- });
78
- }, [animationStyle, openTimeoutInMilliseconds]);
79
+ }
80
+ }, [animationStyle.open, openTimeoutInMilliseconds, state]);
81
+
82
+ useEffect(() => {
83
+ if (state === 'close') {
84
+ const timeout = setTimeout(() => {
85
+ setAnimation({
86
+ state: 'closed',
87
+ style: animationStyle.closed,
88
+ open: false,
89
+ timing: closeTimeoutInMilliseconds,
90
+ });
91
+ }, closeTimeoutInMilliseconds);
92
+ return () => clearTimeout(timeout);
93
+ }
94
+ }, [animationStyle.closed, closeTimeoutInMilliseconds, state]);
79
95
 
80
96
  useEffect(() => {
81
97
  if (openProp) {
82
- const frameHandler = handleOpen();
83
- return () => {
84
- cancelAnimationFrame(frameHandler);
85
- };
98
+ handleOpen();
86
99
  } else {
87
- const timeoutHandler = handleClose();
88
- return () => {
89
- clearTimeout(timeoutHandler);
90
- };
100
+ handleClose();
91
101
  }
92
102
  }, [handleClose, handleOpen, openProp]);
93
103