@basic-ui/material 0.1.13 → 0.1.16

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 (130) hide show
  1. package/build/cjs/index.js +64 -45
  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.js +4 -0
  17. package/build/esm/Chip/ButtonChip.js.map +1 -1
  18. package/build/esm/Chip/ChoiceChip.d.ts +1 -1
  19. package/build/esm/Combobox/Combobox.d.ts +7 -7
  20. package/build/esm/Combobox/Combobox.js +1 -0
  21. package/build/esm/Combobox/Combobox.js.map +1 -1
  22. package/build/esm/Dialog/Dialog.d.ts +1 -1
  23. package/build/esm/Dialog/DialogBackdrop.d.ts +1 -1
  24. package/build/esm/Dialog/DialogSurface.d.ts +1 -1
  25. package/build/esm/Divider/Divider.d.ts +1 -1
  26. package/build/esm/FloatingLabel/FloatingLabel.d.ts +0 -1
  27. package/build/esm/FloatingLabel/FloatingLabel.js +1 -3
  28. package/build/esm/FloatingLabel/FloatingLabel.js.map +1 -1
  29. package/build/esm/LineRipple/LineRipple.d.ts +1 -1
  30. package/build/esm/Link/Link.d.ts +1 -1
  31. package/build/esm/List/List.d.ts +1 -1
  32. package/build/esm/ListItem/ListItem.d.ts +1 -1
  33. package/build/esm/Menu/Menu.d.ts +4 -4
  34. package/build/esm/Menu/Menu.js +1 -0
  35. package/build/esm/Menu/Menu.js.map +1 -1
  36. package/build/esm/NotchedOutline/styledComponents.js +2 -2
  37. package/build/esm/NotchedOutline/styledComponents.js.map +1 -1
  38. package/build/esm/Paper/Paper.d.ts +1 -1
  39. package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
  40. package/build/esm/Select/Select.d.ts +3 -3
  41. package/build/esm/Select/Select.js +5 -14
  42. package/build/esm/Select/Select.js.map +1 -1
  43. package/build/esm/Select/SelectIcon.d.ts +1 -1
  44. package/build/esm/Select/SelectIcon.js +3 -1
  45. package/build/esm/Select/SelectIcon.js.map +1 -1
  46. package/build/esm/Select/styledComponents.js +9 -5
  47. package/build/esm/Select/styledComponents.js.map +1 -1
  48. package/build/esm/SelectItem/SelectItem.d.ts +1 -1
  49. package/build/esm/SelectionControl/SelectionControlLabel.d.ts +1 -1
  50. package/build/esm/SelectionControl/SelectionControlText.d.ts +1 -1
  51. package/build/esm/Skeleton/DelayAppearance.d.ts +1 -1
  52. package/build/esm/Skeleton/Skeleton.d.ts +1 -1
  53. package/build/esm/Snackbar/Snackbar.d.ts +1 -1
  54. package/build/esm/Switch/Switch.d.ts +1 -1
  55. package/build/esm/Tab/Tab.d.ts +1 -1
  56. package/build/esm/Tab/TabList.d.ts +1 -1
  57. package/build/esm/Tab/TabPanel.d.ts +1 -1
  58. package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
  59. package/build/esm/Table/Table.d.ts +1 -1
  60. package/build/esm/Table/TableRow.d.ts +1 -1
  61. package/build/esm/Text/LoremIpsum.d.ts +4 -4
  62. package/build/esm/Text/LoremIpsum.js.map +1 -1
  63. package/build/esm/Text/Text.d.ts +1 -1
  64. package/build/esm/TextField/FilledContainer.d.ts +1 -1
  65. package/build/esm/TextField/FilledContainer.js +11 -5
  66. package/build/esm/TextField/FilledContainer.js.map +1 -1
  67. package/build/esm/TextField/HelperText.d.ts +1 -1
  68. package/build/esm/TextField/IconContainer.d.ts +2 -2
  69. package/build/esm/TextField/IconContainer.js +4 -2
  70. package/build/esm/TextField/IconContainer.js.map +1 -1
  71. package/build/esm/TextField/Input.d.ts +1 -1
  72. package/build/esm/TextField/Input.js +17 -9
  73. package/build/esm/TextField/Input.js.map +1 -1
  74. package/build/esm/TextField/OutlinedContainer.d.ts +1 -1
  75. package/build/esm/TextField/OutlinedContainer.js +7 -4
  76. package/build/esm/TextField/OutlinedContainer.js.map +1 -1
  77. package/build/esm/TextField/TextField.d.ts +1 -1
  78. package/build/esm/TextField/TextField.js +2 -2
  79. package/build/esm/TextField/TextField.js.map +1 -1
  80. package/build/esm/TextField/consts.d.ts +5 -0
  81. package/build/esm/TextField/consts.js +6 -0
  82. package/build/esm/TextField/consts.js.map +1 -0
  83. package/build/esm/Tooltip/Tooltip.d.ts +1 -1
  84. package/build/tsconfig.tsbuildinfo +1 -4757
  85. package/package.json +13 -13
  86. package/src/Alert/Alert.story.tsx +5 -6
  87. package/src/AppBar/AppBar.story.tsx +11 -20
  88. package/src/BottomSheet/BottomSheet.story.tsx +5 -6
  89. package/src/Button/Button.story.tsx +14 -14
  90. package/src/Button/SpinnerButton.story.tsx +6 -6
  91. package/src/CheckBox/CheckBox.story.tsx +7 -6
  92. package/src/Chip/ButtonChip.tsx +3 -1
  93. package/src/Chip/Chip.story.tsx +56 -6
  94. package/src/Combobox/Combobox.story.tsx +12 -13
  95. package/src/Combobox/Combobox.tsx +1 -0
  96. package/src/Dialog/Dialog.story.tsx +7 -8
  97. package/src/Divider/Divider.story.tsx +6 -5
  98. package/src/FloatingLabel/FloatingLabel.story.tsx +10 -9
  99. package/src/FloatingLabel/FloatingLabel.tsx +0 -3
  100. package/src/LineRipple/LineRipple.story.tsx +5 -4
  101. package/src/Link/Link.story.tsx +3 -4
  102. package/src/ListItem/ListItem.story.tsx +6 -5
  103. package/src/Menu/Menu.story.tsx +8 -7
  104. package/src/Menu/Menu.tsx +1 -0
  105. package/src/NotchedOutline/NotchedOutline.story.tsx +5 -4
  106. package/src/NotchedOutline/styledComponents.ts +1 -1
  107. package/src/Paper/Paper.story.tsx +5 -4
  108. package/src/ProgressSpinner/ProgressSpinner.story.tsx +5 -4
  109. package/src/RadioButton/RadioButton.story.tsx +12 -10
  110. package/src/Ripple/Ripple.story.tsx +5 -4
  111. package/src/Select/PaymentMethodSelect.story.tsx +321 -0
  112. package/src/Select/Select.story.tsx +34 -8
  113. package/src/Select/Select.tsx +12 -34
  114. package/src/Select/SelectIcon.tsx +2 -1
  115. package/src/Select/styledComponents.tsx +8 -4
  116. package/src/Skeleton/Skeleton.story.tsx +7 -6
  117. package/src/Snackbar/Snackbar.story.tsx +7 -6
  118. package/src/Switch/Switch.story.tsx +5 -4
  119. package/src/Tab/Tab.story.tsx +7 -5
  120. package/src/Table/Table.story.tsx +5 -4
  121. package/src/Text/LoremIpsum.tsx +3 -1
  122. package/src/Text/Text.story.tsx +5 -4
  123. package/src/TextField/FilledContainer.tsx +22 -5
  124. package/src/TextField/IconContainer.tsx +5 -4
  125. package/src/TextField/Input.tsx +29 -9
  126. package/src/TextField/OutlinedContainer.tsx +18 -4
  127. package/src/TextField/TextField.story.tsx +21 -7
  128. package/src/TextField/TextField.tsx +2 -2
  129. package/src/TextField/consts.ts +7 -0
  130. package/src/Tooltip/Tooltip.story.tsx +5 -4
@@ -26,17 +26,21 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
26
26
  const SelectButtonInner = forwardRef<
27
27
  HTMLButtonElement,
28
28
  SelectProps & { innerAs?: React.ElementType<any> }
29
- >(({ innerAs = 'button', ...props }, forwardedRef) => {
29
+ >(({ innerAs = 'div', ...props }, forwardedRef) => {
30
30
  const InputButton: React.FC<
31
31
  SelectProps & React.RefAttributes<HTMLButtonElement>
32
32
  > = Input as any;
33
33
 
34
- return <InputButton as={innerAs} ref={forwardedRef} {...props} />;
34
+ return (
35
+ <InputButton as={innerAs} ref={forwardedRef} tabIndex={0} {...props} />
36
+ );
35
37
  });
36
38
 
37
39
  export const SelectButton = forwardRef<
38
40
  HTMLButtonElement,
39
41
  SelectProps & MenuButtonProps
40
- >(({ as, ...props }, ref) => (
41
- <BaseMenuButton as={SelectButtonInner} innerAs={as} ref={ref} {...props} />
42
+ >(({ as, children, ...props }, ref) => (
43
+ <BaseMenuButton as={SelectButtonInner} innerAs={as} ref={ref} {...props}>
44
+ {children}
45
+ </BaseMenuButton>
42
46
  ));
@@ -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 />;
@@ -7,6 +7,11 @@ import { LineRipple } from '../LineRipple';
7
7
  import { rem } from 'polished';
8
8
  import { alpha } from '../color';
9
9
  import { Box, BoxProps } from '../Box';
10
+ import {
11
+ ICON_WIDTH,
12
+ PADDING_LEFT_WITHOUT_ICON,
13
+ PADDING_LEFT_WITH_ICON,
14
+ } from './consts';
10
15
 
11
16
  const makeSelector = (
12
17
  state:
@@ -99,7 +104,8 @@ export const FilledContainer = forwardRef<HTMLDivElement, FilledContainerProps>(
99
104
  ...otherProps
100
105
  } = props;
101
106
 
102
- const labelHeight = 18;
107
+ const finalLabelHeight = 16;
108
+ const labelHeight = finalLabelHeight / 0.75;
103
109
  const inputHeight = 56;
104
110
 
105
111
  const color = error ? 'error' : colorProp;
@@ -112,6 +118,7 @@ export const FilledContainer = forwardRef<HTMLDivElement, FilledContainerProps>(
112
118
  active={active || error}
113
119
  __css={{
114
120
  position: 'relative',
121
+ lineHeight: 0,
115
122
  width: '100%',
116
123
  backgroundColor: 'surface',
117
124
  overflow: 'hidden',
@@ -126,11 +133,21 @@ export const FilledContainer = forwardRef<HTMLDivElement, FilledContainerProps>(
126
133
  >
127
134
  {label && (
128
135
  <FloatingLabel
129
- height={labelHeight}
130
- top={(inputHeight - labelHeight) * 0.5}
131
- offsetX={leadingIcon ? 48 : 16}
136
+ height={inputHeight}
137
+ offsetX={
138
+ leadingIcon
139
+ ? PADDING_LEFT_WITH_ICON +
140
+ ICON_WIDTH +
141
+ PADDING_LEFT_WITHOUT_ICON
142
+ : PADDING_LEFT_WITHOUT_ICON
143
+ }
132
144
  translateX={0}
133
- translateY={-labelHeight * 0.75}
145
+ translateY={
146
+ // To debug, delete these lines one by one to see it doing its work
147
+ -(inputHeight * 0.5) + // Put it at the top, crossing middle label
148
+ labelHeight * 0.75 * 0.5 + // Put it at position 0
149
+ 8 // Add a 8px padding to the top
150
+ }
134
151
  active={labelIsFloating}
135
152
  htmlFor={inputId}
136
153
  color={active || error ? color : undefined}
@@ -1,10 +1,11 @@
1
1
  import { rem } from 'polished';
2
- import { VFC } from 'react';
2
+ import { FC } from 'react';
3
3
  import type * as React from 'react';
4
4
  import { Box } from '../Box';
5
5
  import { alpha } from '../color';
6
+ import { ICON_WIDTH, PADDING_LEFT_WITH_ICON } from './consts';
6
7
 
7
- export const IconContainer: VFC<{
8
+ export const IconContainer: FC<{
8
9
  children?: React.ReactNode;
9
10
  position: 'start' | 'end';
10
11
  }> = ({ position, children }) => (
@@ -12,8 +13,8 @@ export const IconContainer: VFC<{
12
13
  position="absolute"
13
14
  __css={{
14
15
  top: 0,
15
- [position === 'start' ? 'left' : 'right']: 3,
16
- minWidth: rem(24),
16
+ [position === 'start' ? 'left' : 'right']: rem(PADDING_LEFT_WITH_ICON),
17
+ minWidth: rem(ICON_WIDTH),
17
18
  display: 'inline-flex',
18
19
  alignItems: 'center',
19
20
  justifyContent: 'center',
@@ -2,6 +2,13 @@ import { rem } from 'polished';
2
2
  import { InputHTMLAttributes, forwardRef } from 'react';
3
3
  import { Box, BoxProps } from '../Box';
4
4
  import { alpha } from '../color';
5
+ import {
6
+ ICON_WIDTH,
7
+ PADDING_LEFT_WITHOUT_ICON,
8
+ PADDING_LEFT_WITH_ICON,
9
+ PADDING_RIGHT_WITHOUT_ICON,
10
+ PADDING_RIGHT_WITH_ICON,
11
+ } from './consts';
5
12
 
6
13
  export interface InputProps
7
14
  extends BoxProps<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>> {
@@ -36,7 +43,6 @@ export const Input = forwardRef<HTMLDivElement, InputProps>(function Input(
36
43
  {...otherProps}
37
44
  __css={{
38
45
  WebkitTapHighlightColor: 'transparent',
39
- boxSizing: 'border-box',
40
46
  appearance: 'none',
41
47
  outline: 'none',
42
48
  width: '100%',
@@ -50,6 +56,14 @@ export const Input = forwardRef<HTMLDivElement, InputProps>(function Input(
50
56
  color: alpha('on.surface', 0.87),
51
57
  letterSpacing: rem(0.5),
52
58
  textAlign: 'left',
59
+ display: 'flex',
60
+ alignItems: 'center',
61
+ ...(!multiline && {
62
+ lineHeight: 1,
63
+ overflow: 'hidden',
64
+ whiteSpace: 'nowrap',
65
+ textOverflow: 'ellipsis',
66
+ }),
53
67
  '::placeholder': {
54
68
  opacity: 0,
55
69
  color: alpha('on.surface', 0.54),
@@ -64,7 +78,7 @@ export const Input = forwardRef<HTMLDivElement, InputProps>(function Input(
64
78
  ':disabled': {
65
79
  cursor: 'default',
66
80
  },
67
- 'select&,button&': {
81
+ 'select&,[role="button"]&': {
68
82
  cursor: 'pointer',
69
83
  },
70
84
  'select&': {
@@ -73,20 +87,26 @@ export const Input = forwardRef<HTMLDivElement, InputProps>(function Input(
73
87
  color: 'on.surface',
74
88
  },
75
89
  },
76
- paddingLeft: leadingIcon ? rem(18 + 30) : rem(16),
77
- paddingRight: trailingIcon ? rem(18 + 30) : rem(16),
90
+ paddingLeft: leadingIcon
91
+ ? rem(PADDING_LEFT_WITH_ICON + ICON_WIDTH + PADDING_LEFT_WITHOUT_ICON)
92
+ : rem(PADDING_LEFT_WITHOUT_ICON),
93
+ paddingRight: trailingIcon
94
+ ? rem(
95
+ PADDING_RIGHT_WITH_ICON + ICON_WIDTH + PADDING_RIGHT_WITHOUT_ICON
96
+ )
97
+ : rem(PADDING_RIGHT_WITHOUT_ICON),
78
98
  ...(variant === 'outlined' && {
79
- paddingTop: hasLabel ? rem(12) : rem(12),
80
- paddingBottom: hasLabel ? rem(14) : rem(12),
99
+ paddingTop: rem(16),
100
+ paddingBottom: rem(16),
81
101
  }),
82
102
  ...(variant === 'filled' && {
83
- paddingTop: hasLabel ? rem(20) : rem(12),
84
- paddingBottom: hasLabel ? rem(6) : rem(12),
103
+ paddingTop: hasLabel ? rem(24) : rem(16),
104
+ paddingBottom: hasLabel ? rem(8) : rem(16),
85
105
  }),
86
106
  ...(multiline && {
87
107
  resize: 'vertical',
88
108
  paddingTop: 0,
89
- marginTop: variant === 'outlined' || !hasLabel ? rem(12) : rem(20),
109
+ marginTop: variant === 'outlined' || !hasLabel ? rem(18) : rem(26),
90
110
  }),
91
111
  ...__css,
92
112
  }}
@@ -10,6 +10,11 @@ import { NotchedOutline } from '../NotchedOutline';
10
10
  import { Box, BoxProps } from '../Box';
11
11
  import { FloatingLabel } from '../FloatingLabel';
12
12
  import { Theme } from '../theme';
13
+ import {
14
+ ICON_WIDTH,
15
+ PADDING_LEFT_WITHOUT_ICON,
16
+ PADDING_LEFT_WITH_ICON,
17
+ } from './consts';
13
18
 
14
19
  const useEnhancedEffect =
15
20
  typeof window !== 'undefined' ? useLayoutEffect : useEffect;
@@ -61,9 +66,10 @@ export const OutlinedContainer = forwardRef<
61
66
  }, [label]);
62
67
 
63
68
  const color = error ? 'error' : colorProp;
69
+ const inputHeight = 56;
64
70
 
65
71
  return (
66
- <Box position="relative" {...otherProps}>
72
+ <Box position="relative" lineHeight={0} {...otherProps}>
67
73
  <NotchedOutline
68
74
  ref={forwardedRef}
69
75
  borderRadius={4}
@@ -76,9 +82,17 @@ export const OutlinedContainer = forwardRef<
76
82
  label={
77
83
  label && (
78
84
  <FloatingLabel
79
- height={56}
80
- offsetX={leadingIcon ? 48 : 16}
81
- translateX={leadingIcon ? -32 : 0}
85
+ height={inputHeight}
86
+ offsetX={
87
+ leadingIcon
88
+ ? PADDING_LEFT_WITH_ICON +
89
+ ICON_WIDTH +
90
+ PADDING_LEFT_WITHOUT_ICON
91
+ : PADDING_LEFT_WITHOUT_ICON
92
+ }
93
+ translateX={
94
+ leadingIcon ? -(PADDING_LEFT_WITH_ICON + ICON_WIDTH) : 0
95
+ }
82
96
  active={forceActive || labelIsFloating}
83
97
  ref={labelRef}
84
98
  htmlFor={inputId}
@@ -1,11 +1,27 @@
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
+ };
12
+
13
+ const SearchIcon = (props) => (
14
+ <svg
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ height={24}
17
+ width={24}
18
+ viewBox="0 0 48 48"
19
+ fill="currentColor"
20
+ {...props}
21
+ >
22
+ <path d="M39.8 41.95 26.65 28.8q-1.5 1.3-3.5 2.025-2 .725-4.25.725-5.4 0-9.15-3.75T6 18.75q0-5.3 3.75-9.05 3.75-3.75 9.1-3.75 5.3 0 9.025 3.75 3.725 3.75 3.725 9.05 0 2.15-.7 4.15-.7 2-2.1 3.75L42 39.75Zm-20.95-13.4q4.05 0 6.9-2.875Q28.6 22.8 28.6 18.75t-2.85-6.925Q22.9 8.95 18.85 8.95q-4.1 0-6.975 2.875T9 18.75q0 4.05 2.875 6.925t6.975 2.875Z" />
23
+ </svg>
24
+ );
9
25
 
10
26
  const Example = ({ variant }) => {
11
27
  const [error, setError] = useState<boolean | string>(false);
@@ -156,7 +172,7 @@ const Example = ({ variant }) => {
156
172
  label="With icon"
157
173
  error={error}
158
174
  color={color}
159
- leadingIcon={'O'}
175
+ leadingIcon={<SearchIcon />}
160
176
  />
161
177
  </Box>
162
178
  <Box m={2} width={230} display="inline-block">
@@ -220,7 +236,5 @@ const Example = ({ variant }) => {
220
236
  );
221
237
  };
222
238
 
223
- const stories = storiesOf('Components/TextField', module);
224
-
225
- stories.add('filled', () => <Example variant="filled" />);
226
- stories.add('outlined', () => <Example variant="outlined" />);
239
+ export const Filled = () => <Example variant="filled" />;
240
+ 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';
@@ -0,0 +1,7 @@
1
+ export const PADDING_LEFT_WITH_ICON = 14;
2
+ export const PADDING_LEFT_WITHOUT_ICON = 16;
3
+
4
+ export const ICON_WIDTH = 24;
5
+
6
+ export const PADDING_RIGHT_WITH_ICON = 12;
7
+ export const PADDING_RIGHT_WITHOUT_ICON = 16;
@@ -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 />;