@superdispatch/ui 0.21.6 → 0.21.13

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 (233) hide show
  1. package/.babelrc.js +5 -0
  2. package/.turbo/turbo-version.log +28 -0
  3. package/package.json +65 -39
  4. package/pkg/README.md +30 -0
  5. package/{dist-node → pkg/dist-node}/index.js +2 -1
  6. package/pkg/dist-node/index.js.map +1 -0
  7. package/{dist-src → pkg/dist-src}/number-field/NumberField.js +2 -1
  8. package/{dist-types → pkg/dist-types}/index.d.ts +364 -364
  9. package/{dist-web → pkg/dist-web}/index.js +2 -1
  10. package/pkg/dist-web/index.js.map +1 -0
  11. package/pkg/package.json +39 -0
  12. package/playroom.ts +31 -0
  13. package/src/__tests__/index.spec.ts +134 -0
  14. package/src/adaptive-toolbar/AdaptiveToolbar.stories.tsx +50 -0
  15. package/src/adaptive-toolbar/AdaptiveToolbar.tsx +199 -0
  16. package/src/adaptive-toolbar/__tests__/AdaptiveToolbar.spec.tsx +11 -0
  17. package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.stories.tsx +49 -0
  18. package/src/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.tsx +171 -0
  19. package/src/app-bar/AppBar.stories.tsx +62 -0
  20. package/src/app-bar/AppBarOverrides.ts +9 -0
  21. package/src/app-bar/__tests__/AppBar.spec.tsx +86 -0
  22. package/src/autocomplete/Autocomplete.stories.tsx +76 -0
  23. package/src/autocomplete/AutocompleteOverrides.tsx +58 -0
  24. package/src/autocomplete/__tests__/Autocomplete.spec.tsx +323 -0
  25. package/src/avatar/Avatar.stories.tsx +17 -0
  26. package/src/avatar/AvatarOverrides.ts +24 -0
  27. package/src/avatar/__tests__/Avatar.spec.tsx +71 -0
  28. package/src/avatar-button/AvatarButton.stories.tsx +153 -0
  29. package/src/avatar-button/AvatarButton.tsx +223 -0
  30. package/src/avatar-button/__tests__/AvatarButton.spec.tsx +126 -0
  31. package/src/button/Button.tsx +51 -0
  32. package/src/button/ButtonOverrides.ts +375 -0
  33. package/src/button/__tests__/Button.spec.tsx +599 -0
  34. package/src/card/Card.stories.tsx +39 -0
  35. package/src/card/CardOverrides.ts +9 -0
  36. package/src/card/__tests__/Card.spec.tsx +68 -0
  37. package/src/card-button/CardButton.stories.tsx +36 -0
  38. package/src/card-button/CardButton.tsx +202 -0
  39. package/src/card-button/__tests__/CardButton.spec.tsx +95 -0
  40. package/src/checkbox/CheckboxField.stories.tsx +61 -0
  41. package/src/checkbox/CheckboxField.tsx +56 -0
  42. package/src/checkbox/CheckboxGroudField.tsx +53 -0
  43. package/src/checkbox/CheckboxOverrides.tsx +55 -0
  44. package/src/checkbox/__tests__/Checkbox.spec.tsx +105 -0
  45. package/src/chip/Chip.stories.tsx +26 -0
  46. package/src/chip/ChipOverrides.tsx +111 -0
  47. package/src/chip/__tests__/Chip.spec.tsx +308 -0
  48. package/src/columns/Column.tsx +124 -0
  49. package/src/columns/Columns.stories.tsx +426 -0
  50. package/src/columns/Columns.tsx +76 -0
  51. package/src/description-list/DescriptionList.spec.tsx +137 -0
  52. package/src/description-list/DescriptionList.stories.tsx +148 -0
  53. package/src/description-list/DescriptionList.tsx +170 -0
  54. package/src/dialog/Dialog.playroom.tsx +24 -0
  55. package/src/dialog/Dialog.stories.tsx +60 -0
  56. package/src/dialog/DialogOverrides.ts +39 -0
  57. package/src/dialog/__tests__/Dialog.spec.tsx +219 -0
  58. package/src/drawer/Drawer.playroom.tsx +22 -0
  59. package/src/drawer/Drawer.stories.tsx +194 -0
  60. package/src/drawer/DrawerActions.tsx +69 -0
  61. package/src/drawer/DrawerContent.tsx +30 -0
  62. package/src/drawer/DrawerList.tsx +60 -0
  63. package/src/drawer/DrawerOverrides.ts +19 -0
  64. package/src/drawer/DrawerTitle.tsx +143 -0
  65. package/src/drawer/__tests__/Drawer.spec.tsx +227 -0
  66. package/src/dropdown-button/DropdownButton.stories.tsx +15 -0
  67. package/src/dropdown-button/DropdownButton.tsx +131 -0
  68. package/src/grid/GridStack.tsx +45 -0
  69. package/src/grid/InlineGrid.tsx +56 -0
  70. package/src/icon-button/IconButton.stories.tsx +53 -0
  71. package/src/icon-button/IconButtonOverrides.ts +32 -0
  72. package/src/icon-button/__tests__/IconButton.spec.tsx +124 -0
  73. package/src/index.ts +47 -0
  74. package/src/info-card/InfoCard.stories.tsx +29 -0
  75. package/src/info-card/InfoCard.tsx +95 -0
  76. package/src/info-card/__tests__/InfoCard.spec.tsx +22 -0
  77. package/src/info-tooltip/InfoTooltip.stories.tsx +77 -0
  78. package/src/info-tooltip/InfoTooltip.tsx +72 -0
  79. package/src/info-tooltip/__tests__/InfoTooltip.spec.tsx +166 -0
  80. package/src/inline/Inline.stories.tsx +135 -0
  81. package/src/inline/Inline.tsx +144 -0
  82. package/src/link/Link.stories.tsx +41 -0
  83. package/src/link/LinkOverrides.ts +43 -0
  84. package/src/link/__tests__/Link.spec.tsx +98 -0
  85. package/src/list/ListOverrides.ts +11 -0
  86. package/src/list/__tests__/List.spec.tsx +182 -0
  87. package/src/menu/Menu.stories.tsx +35 -0
  88. package/src/menu/MenuOverrides.ts +17 -0
  89. package/src/menu/__tests__/Menu.spec.tsx +99 -0
  90. package/src/number-field/NumberField.stories.tsx +123 -0
  91. package/src/number-field/NumberField.tsx +98 -0
  92. package/src/overflow-text/OverflowText.stories.tsx +32 -0
  93. package/src/overflow-text/OverflowText.tsx +114 -0
  94. package/src/overflow-text/__tests__/OverflowText.spec.tsx +24 -0
  95. package/src/pagination/Pagination.stories.tsx +36 -0
  96. package/src/pagination/PaginationOverrides.ts +47 -0
  97. package/src/pagination/__tests__/Pagination.spec.tsx +228 -0
  98. package/src/paper/PaperOverrides.ts +10 -0
  99. package/src/paper/__tests__/Paper.spec.tsx +155 -0
  100. package/src/props/AlignProps.ts +22 -0
  101. package/src/props/CollapseProp.ts +13 -0
  102. package/src/props/ResponsiveProp.ts +65 -0
  103. package/src/props/SpaceProp.ts +40 -0
  104. package/src/radio/RadioField.stories.tsx +42 -0
  105. package/src/radio/RadioField.tsx +55 -0
  106. package/src/radio/RadioGroupField.tsx +64 -0
  107. package/src/radio/RadioOverrides.tsx +51 -0
  108. package/src/radio/__tests__/Radio.spec.tsx +90 -0
  109. package/src/responsive/CollapseBreakpoint.ts +21 -0
  110. package/src/responsive/MinBreakpoint.ts +21 -0
  111. package/src/responsive/ResponsiveContext.tsx +57 -0
  112. package/src/snackbar/Snackbar.stories.tsx +196 -0
  113. package/src/snackbar/Snackbar.tsx +83 -0
  114. package/src/snackbar/SnackbarContent.tsx +147 -0
  115. package/src/snackbar/SnackbarOverrides.ts +23 -0
  116. package/src/snackbar/SnackbarStack.tsx +160 -0
  117. package/src/snackbar/__tests__/Snackbar.spec.tsx +196 -0
  118. package/src/stack/Stack.stories.tsx +113 -0
  119. package/src/stack/Stack.tsx +86 -0
  120. package/src/svg-icon/SvgIcon.stories.tsx +29 -0
  121. package/src/svg-icon/SvgIconOverrides.ts +32 -0
  122. package/src/svg-icon/__tests__/SvgIcon.spec.tsx +67 -0
  123. package/src/switch/Switch.stories.tsx +60 -0
  124. package/src/switch/SwitchOverrides.ts +88 -0
  125. package/src/switch/__tests__/Switch.spec.tsx +204 -0
  126. package/src/tabs/Tabs.stories.tsx +40 -0
  127. package/src/tabs/TabsOverrides.ts +45 -0
  128. package/src/tabs/__tests__/Tabs.spec.tsx +226 -0
  129. package/src/tag/Tag.stories.tsx +53 -0
  130. package/src/tag/Tag.tsx +130 -0
  131. package/src/tag/__tests__/Tag.spec.tsx +82 -0
  132. package/src/text-field/TextField.stories.tsx +50 -0
  133. package/src/text-field/TextFieldOverrides.tsx +149 -0
  134. package/src/text-field/__tests__/TextField.spec.tsx +662 -0
  135. package/src/theme/Color.ts +117 -0
  136. package/src/theme/SuperDispatchTheme.ts +3 -0
  137. package/src/theme/ThemeProvider.tsx +179 -0
  138. package/src/theme/__tests__/CssBaseline.spec.tsx +49 -0
  139. package/src/theme/__tests__/ThemeProvider.spec.ts +40 -0
  140. package/src/theme/__tests__/__snapshots__/ThemeProvider.spec.ts.snap +204 -0
  141. package/src/tiles/Tiles.stories.tsx +69 -0
  142. package/src/tiles/Tiles.tsx +163 -0
  143. package/src/tiles/__tests__/Tiles.spec.tsx +221 -0
  144. package/src/toolbar/ToolbarOverrides.ts +14 -0
  145. package/src/toolbar/__tests__/Toolbar.spec.tsx +50 -0
  146. package/src/tooltip/Tooltip.stories.tsx +32 -0
  147. package/src/tooltip/TooltipOverrides.ts +34 -0
  148. package/src/tooltip/__tests__/Tooltip.spec.tsx +182 -0
  149. package/src/typography/Typography.stories.tsx +132 -0
  150. package/src/typography/TypographyOverrides.ts +125 -0
  151. package/src/typography/__tests__/Typography.spec.tsx +253 -0
  152. package/src/utils/ExitTransitionPlaceholder.tsx +22 -0
  153. package/src/utils/ResizeObserver.tsx +28 -0
  154. package/src/utils/VisibilityObserver.tsx +75 -0
  155. package/src/utils/__tests__/ExitTransitionPlaceholder.spec.tsx +34 -0
  156. package/src/utils/isEmptyReactNode.ts +11 -0
  157. package/src/utils/mergeRefs.ts +21 -0
  158. package/src/utils/renderChildren.ts +10 -0
  159. package/src/utils/useUID.ts +9 -0
  160. package/tsconfig.json +19 -0
  161. package/LICENSE +0 -21
  162. package/dist-node/index.js.map +0 -1
  163. package/dist-web/index.js.map +0 -1
  164. /package/{dist-src → pkg/dist-src}/adaptive-toolbar/AdaptiveToolbar.js +0 -0
  165. /package/{dist-src → pkg/dist-src}/adaptive-vertical-toolbar/AdaptiveVerticalToolbar.js +0 -0
  166. /package/{dist-src → pkg/dist-src}/app-bar/AppBarOverrides.js +0 -0
  167. /package/{dist-src → pkg/dist-src}/autocomplete/AutocompleteOverrides.js +0 -0
  168. /package/{dist-src → pkg/dist-src}/avatar/AvatarOverrides.js +0 -0
  169. /package/{dist-src → pkg/dist-src}/avatar-button/AvatarButton.js +0 -0
  170. /package/{dist-src → pkg/dist-src}/button/Button.js +0 -0
  171. /package/{dist-src → pkg/dist-src}/button/ButtonOverrides.js +0 -0
  172. /package/{dist-src → pkg/dist-src}/card/CardOverrides.js +0 -0
  173. /package/{dist-src → pkg/dist-src}/card-button/CardButton.js +0 -0
  174. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxField.js +0 -0
  175. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxGroudField.js +0 -0
  176. /package/{dist-src → pkg/dist-src}/checkbox/CheckboxOverrides.js +0 -0
  177. /package/{dist-src → pkg/dist-src}/chip/ChipOverrides.js +0 -0
  178. /package/{dist-src → pkg/dist-src}/columns/Column.js +0 -0
  179. /package/{dist-src → pkg/dist-src}/columns/Columns.js +0 -0
  180. /package/{dist-src → pkg/dist-src}/description-list/DescriptionList.js +0 -0
  181. /package/{dist-src → pkg/dist-src}/dialog/DialogOverrides.js +0 -0
  182. /package/{dist-src → pkg/dist-src}/drawer/DrawerActions.js +0 -0
  183. /package/{dist-src → pkg/dist-src}/drawer/DrawerContent.js +0 -0
  184. /package/{dist-src → pkg/dist-src}/drawer/DrawerList.js +0 -0
  185. /package/{dist-src → pkg/dist-src}/drawer/DrawerOverrides.js +0 -0
  186. /package/{dist-src → pkg/dist-src}/drawer/DrawerTitle.js +0 -0
  187. /package/{dist-src → pkg/dist-src}/dropdown-button/DropdownButton.js +0 -0
  188. /package/{dist-src → pkg/dist-src}/grid/GridStack.js +0 -0
  189. /package/{dist-src → pkg/dist-src}/grid/InlineGrid.js +0 -0
  190. /package/{dist-src → pkg/dist-src}/icon-button/IconButtonOverrides.js +0 -0
  191. /package/{dist-src → pkg/dist-src}/index.js +0 -0
  192. /package/{dist-src → pkg/dist-src}/info-card/InfoCard.js +0 -0
  193. /package/{dist-src → pkg/dist-src}/inline/Inline.js +0 -0
  194. /package/{dist-src → pkg/dist-src}/link/LinkOverrides.js +0 -0
  195. /package/{dist-src → pkg/dist-src}/list/ListOverrides.js +0 -0
  196. /package/{dist-src → pkg/dist-src}/menu/MenuOverrides.js +0 -0
  197. /package/{dist-src → pkg/dist-src}/overflow-text/OverflowText.js +0 -0
  198. /package/{dist-src → pkg/dist-src}/pagination/PaginationOverrides.js +0 -0
  199. /package/{dist-src → pkg/dist-src}/paper/PaperOverrides.js +0 -0
  200. /package/{dist-src → pkg/dist-src}/props/AlignProps.js +0 -0
  201. /package/{dist-src → pkg/dist-src}/props/CollapseProp.js +0 -0
  202. /package/{dist-src → pkg/dist-src}/props/ResponsiveProp.js +0 -0
  203. /package/{dist-src → pkg/dist-src}/props/SpaceProp.js +0 -0
  204. /package/{dist-src → pkg/dist-src}/radio/RadioField.js +0 -0
  205. /package/{dist-src → pkg/dist-src}/radio/RadioGroupField.js +0 -0
  206. /package/{dist-src → pkg/dist-src}/radio/RadioOverrides.js +0 -0
  207. /package/{dist-src → pkg/dist-src}/responsive/CollapseBreakpoint.js +0 -0
  208. /package/{dist-src → pkg/dist-src}/responsive/MinBreakpoint.js +0 -0
  209. /package/{dist-src → pkg/dist-src}/responsive/ResponsiveContext.js +0 -0
  210. /package/{dist-src → pkg/dist-src}/snackbar/Snackbar.js +0 -0
  211. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarContent.js +0 -0
  212. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarOverrides.js +0 -0
  213. /package/{dist-src → pkg/dist-src}/snackbar/SnackbarStack.js +0 -0
  214. /package/{dist-src → pkg/dist-src}/stack/Stack.js +0 -0
  215. /package/{dist-src → pkg/dist-src}/svg-icon/SvgIconOverrides.js +0 -0
  216. /package/{dist-src → pkg/dist-src}/switch/SwitchOverrides.js +0 -0
  217. /package/{dist-src → pkg/dist-src}/tabs/TabsOverrides.js +0 -0
  218. /package/{dist-src → pkg/dist-src}/tag/Tag.js +0 -0
  219. /package/{dist-src → pkg/dist-src}/text-field/TextFieldOverrides.js +0 -0
  220. /package/{dist-src → pkg/dist-src}/theme/Color.js +0 -0
  221. /package/{dist-src → pkg/dist-src}/theme/SuperDispatchTheme.js +0 -0
  222. /package/{dist-src → pkg/dist-src}/theme/ThemeProvider.js +0 -0
  223. /package/{dist-src → pkg/dist-src}/tiles/Tiles.js +0 -0
  224. /package/{dist-src → pkg/dist-src}/toolbar/ToolbarOverrides.js +0 -0
  225. /package/{dist-src → pkg/dist-src}/tooltip/TooltipOverrides.js +0 -0
  226. /package/{dist-src → pkg/dist-src}/typography/TypographyOverrides.js +0 -0
  227. /package/{dist-src → pkg/dist-src}/utils/ExitTransitionPlaceholder.js +0 -0
  228. /package/{dist-src → pkg/dist-src}/utils/ResizeObserver.js +0 -0
  229. /package/{dist-src → pkg/dist-src}/utils/VisibilityObserver.js +0 -0
  230. /package/{dist-src → pkg/dist-src}/utils/isEmptyReactNode.js +0 -0
  231. /package/{dist-src → pkg/dist-src}/utils/mergeRefs.js +0 -0
  232. /package/{dist-src → pkg/dist-src}/utils/renderChildren.js +0 -0
  233. /package/{dist-src → pkg/dist-src}/utils/useUID.js +0 -0
@@ -0,0 +1,123 @@
1
+ import { UseState } from '@superdispatch/ui-docs';
2
+ import { NumberField } from '..';
3
+
4
+ export default { title: 'Inputs/NumberField', component: NumberField };
5
+
6
+ export const basic = () => (
7
+ <UseState initialState={0}>
8
+ {(value, setValue) => (
9
+ <NumberField
10
+ value={value}
11
+ label="Label"
12
+ helperText="helperText"
13
+ onChange={(event) => {
14
+ setValue(event.target.value);
15
+ }}
16
+ />
17
+ )}
18
+ </UseState>
19
+ );
20
+
21
+ export const decimalSeparator = () => (
22
+ <UseState initialState={0}>
23
+ {(value, setValue) => (
24
+ <NumberField
25
+ value={value}
26
+ label="Separator :"
27
+ helperText="helperText"
28
+ inputProps={{
29
+ decimalSeparator: ':',
30
+ }}
31
+ onChange={(event) => {
32
+ setValue(event.target.value);
33
+ }}
34
+ />
35
+ )}
36
+ </UseState>
37
+ );
38
+
39
+ export const decimalScale = () => (
40
+ <UseState initialState={0}>
41
+ {(value, setValue) => (
42
+ <NumberField
43
+ value={value}
44
+ label="Decimal scale 2"
45
+ helperText="helperText"
46
+ inputProps={{
47
+ decimalScale: 2,
48
+ }}
49
+ onChange={(event) => {
50
+ setValue(event.target.value);
51
+ }}
52
+ />
53
+ )}
54
+ </UseState>
55
+ );
56
+
57
+ export const prefix = () => (
58
+ <UseState initialState={0}>
59
+ {(value, setValue) => (
60
+ <NumberField
61
+ value={value}
62
+ label="Prefix $"
63
+ helperText="helperText"
64
+ inputProps={{
65
+ prefix: '$',
66
+ }}
67
+ onChange={(event) => {
68
+ setValue(event.target.value);
69
+ }}
70
+ />
71
+ )}
72
+ </UseState>
73
+ );
74
+
75
+ export const withoutSeparator = () => (
76
+ <UseState initialState={0}>
77
+ {(value, setValue) => (
78
+ <NumberField
79
+ value={value}
80
+ label="Label"
81
+ helperText="helperText"
82
+ inputProps={{
83
+ thousandSeparator: false,
84
+ }}
85
+ onChange={(event) => {
86
+ setValue(event.target.value);
87
+ }}
88
+ />
89
+ )}
90
+ </UseState>
91
+ );
92
+
93
+ export const error = () => (
94
+ <UseState initialState={0}>
95
+ {(value, setValue) => (
96
+ <NumberField
97
+ value={value}
98
+ label="Label"
99
+ helperText="Error Text"
100
+ error={true}
101
+ onChange={(event) => {
102
+ setValue(event.target.value);
103
+ }}
104
+ />
105
+ )}
106
+ </UseState>
107
+ );
108
+
109
+ export const format = () => (
110
+ <UseState initialState={0}>
111
+ {(value, setValue) => (
112
+ <NumberField
113
+ value={value}
114
+ inputProps={{
115
+ format: '### ### ### ###',
116
+ }}
117
+ onChange={(event) => {
118
+ setValue(event.target.value);
119
+ }}
120
+ />
121
+ )}
122
+ </UseState>
123
+ );
@@ -0,0 +1,98 @@
1
+ import {
2
+ InputProps as StandardInputProps,
3
+ StandardTextFieldProps,
4
+ TextField,
5
+ } from '@material-ui/core';
6
+ import {
7
+ ChangeEvent,
8
+ forwardRef,
9
+ ForwardRefExoticComponent,
10
+ InputHTMLAttributes,
11
+ } from 'react';
12
+ import NumberFormat, { NumberFormatProps } from 'react-number-format';
13
+ import { useUID } from '../utils/useUID';
14
+
15
+ type SafeNumberFormatProps = Pick<
16
+ NumberFormatProps,
17
+ | 'value'
18
+ | 'onChange'
19
+ | 'getInputRef'
20
+ | 'decimalScale'
21
+ | 'onValueChange'
22
+ | 'isNumericString'
23
+ | 'decimalSeparator'
24
+ | 'thousandSeparator'
25
+ | 'fixedDecimalScale'
26
+ | 'thousandsGroupStyle'
27
+ >;
28
+
29
+ interface NumberFormatCustomProps
30
+ extends Omit<SafeNumberFormatProps, 'getInputRef' | 'onValueChange'>,
31
+ Omit<
32
+ StandardTextFieldProps,
33
+ 'ref' | keyof InputHTMLAttributes<HTMLInputElement>
34
+ > {
35
+ disableValueParsing?: boolean;
36
+ format?: NumberFormatProps['format'];
37
+ }
38
+
39
+ export interface NumberFieldProps
40
+ extends Omit<StandardTextFieldProps, 'InputProps' | 'inputProps'>,
41
+ Omit<SafeNumberFormatProps, keyof StandardTextFieldProps> {
42
+ InputProps?: Partial<Omit<StandardInputProps, 'inputComponent'>>;
43
+ inputProps?: NumberFormatCustomProps & StandardTextFieldProps['inputProps'];
44
+ }
45
+
46
+ function NumberInputComponent({
47
+ value,
48
+ inputRef,
49
+ onChange,
50
+ isNumericString = true,
51
+ thousandSeparator = true,
52
+ disableValueParsing,
53
+ ...props
54
+ }: NumberFormatCustomProps): JSX.Element {
55
+ return (
56
+ <NumberFormat
57
+ {...props}
58
+ value={value ?? ''}
59
+ inputMode="decimal"
60
+ getInputRef={inputRef}
61
+ isNumericString={isNumericString}
62
+ thousandSeparator={thousandSeparator}
63
+ allowedDecimalSeparators={['.', ',']}
64
+ onValueChange={(values) => {
65
+ const floatValue = !Number.isNaN(Number(values.floatValue))
66
+ ? values.floatValue
67
+ : null;
68
+
69
+ const event = {
70
+ target: {
71
+ value: disableValueParsing ? values.value : floatValue,
72
+ },
73
+ } as ChangeEvent<HTMLInputElement>;
74
+
75
+ onChange?.(event);
76
+ }}
77
+ />
78
+ );
79
+ }
80
+
81
+ export const NumberField: ForwardRefExoticComponent<NumberFieldProps> =
82
+ forwardRef(({ id, InputProps, ...props }, ref) => {
83
+ const uid = useUID(id);
84
+
85
+ return (
86
+ <TextField
87
+ {...props}
88
+ ref={ref}
89
+ id={uid}
90
+ InputProps={{
91
+ ...InputProps,
92
+ inputComponent: NumberInputComponent,
93
+ }}
94
+ />
95
+ );
96
+ });
97
+
98
+ NumberField.displayName = 'NumberField';
@@ -0,0 +1,32 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { Box } from '@superdispatch/ui-lab';
3
+ import { OverflowText } from './OverflowText';
4
+
5
+ export default {
6
+ title: 'Data Display/OverflowText',
7
+ component: OverflowText,
8
+ decorators: [
9
+ (Story) => (
10
+ <Box maxWidth="200px">
11
+ <Story />
12
+ </Box>
13
+ ),
14
+ ],
15
+ } as Meta;
16
+
17
+ export const basic = () => (
18
+ <OverflowText>
19
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
20
+ </OverflowText>
21
+ );
22
+
23
+ export const customTooltip = () => (
24
+ <OverflowText
25
+ TooltipProps={{
26
+ title:
27
+ 'Sed felis libero, interdum sit amet congue et, pretium vel massa.',
28
+ }}
29
+ >
30
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
31
+ </OverflowText>
32
+ );
@@ -0,0 +1,114 @@
1
+ import {
2
+ Tooltip,
3
+ TooltipProps,
4
+ Typography,
5
+ TypographyProps,
6
+ } from '@material-ui/core';
7
+ import { CSSProperties, makeStyles } from '@material-ui/styles';
8
+ import clsx from 'clsx';
9
+ import {
10
+ ElementType,
11
+ forwardRef,
12
+ ForwardRefExoticComponent,
13
+ useState,
14
+ } from 'react';
15
+ import { Color } from '../theme/Color';
16
+ import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
17
+ import { VisibilityObserver } from '../utils/VisibilityObserver';
18
+
19
+ const useStyles = makeStyles(
20
+ (
21
+ theme: SuperDispatchTheme,
22
+ ): Record<'root' | 'truncated' | 'sentinel', CSSProperties> => ({
23
+ root: {
24
+ marginBottom: -1,
25
+ borderBottom: '1px dashed transparent',
26
+ transition: theme.transitions.create('border'),
27
+
28
+ '&$truncated': {
29
+ cursor: 'pointer',
30
+ borderBottomColor: Color.Silver500,
31
+ },
32
+ },
33
+ truncated: {},
34
+ sentinel: {
35
+ width: 1,
36
+ height: '100%',
37
+ display: 'inline-block',
38
+ },
39
+ }),
40
+ { name: 'SD-OverflowText' },
41
+ );
42
+
43
+ export interface OverflowTextProps extends Omit<TypographyProps, 'noWrap'> {
44
+ component?: ElementType;
45
+ disableUnderline?: boolean;
46
+ TooltipProps?: Omit<Partial<TooltipProps>, 'open' | 'children'>;
47
+ }
48
+
49
+ export const OverflowText: ForwardRefExoticComponent<OverflowTextProps> =
50
+ forwardRef(
51
+ (
52
+ {
53
+ onClick,
54
+ children,
55
+ className,
56
+ disableUnderline,
57
+ TooltipProps: {
58
+ title = children,
59
+ enterDelay = 1000,
60
+ ...tooltipProps
61
+ } = {} as const,
62
+ ...props
63
+ },
64
+ rootRef,
65
+ ) => {
66
+ const [isOpen, setIsOpen] = useState(false);
67
+ const styles = useStyles();
68
+ return (
69
+ <VisibilityObserver
70
+ render={({ ref, visibility }) => {
71
+ const isTooltipEnabled = !!children && visibility === 'invisible';
72
+
73
+ return (
74
+ <Tooltip
75
+ {...tooltipProps}
76
+ enterDelay={1000}
77
+ title={title || ''}
78
+ disableFocusListener={true}
79
+ open={isOpen && isTooltipEnabled}
80
+ onOpen={() => {
81
+ setIsOpen(true);
82
+ }}
83
+ onClose={() => {
84
+ setIsOpen(false);
85
+ }}
86
+ >
87
+ <Typography
88
+ {...props}
89
+ ref={rootRef}
90
+ noWrap={true}
91
+ onClick={(event) => {
92
+ setIsOpen(true);
93
+ onClick?.(event);
94
+ }}
95
+ className={clsx(
96
+ styles.root,
97
+ {
98
+ [styles.truncated]:
99
+ !disableUnderline && visibility === 'invisible',
100
+ },
101
+ className,
102
+ )}
103
+ >
104
+ {children}
105
+
106
+ {!!children && <span ref={ref} className={styles.sentinel} />}
107
+ </Typography>
108
+ </Tooltip>
109
+ );
110
+ }}
111
+ />
112
+ );
113
+ },
114
+ );
@@ -0,0 +1,24 @@
1
+ import { renderCSS } from '@superdispatch/ui-testutils';
2
+ import { OverflowText } from '../OverflowText';
3
+
4
+ it('checks component css', () => {
5
+ expect(renderCSS(<OverflowText />, ['SD-OverflowText']))
6
+ .toMatchInlineSnapshot(`
7
+ .SD-OverflowText-root {
8
+ transition: border 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
9
+ border-bottom: 1px dashed transparent;
10
+ margin-bottom: -1px;
11
+ }
12
+
13
+ .SD-OverflowText-root.SD-OverflowText-truncated {
14
+ cursor: pointer;
15
+ border-bottom-color: Color.Silver500;
16
+ }
17
+
18
+ .SD-OverflowText-sentinel {
19
+ width: 1px;
20
+ height: 100%;
21
+ display: inline-block;
22
+ }
23
+ `);
24
+ });
@@ -0,0 +1,36 @@
1
+ import { Pagination } from '@material-ui/lab';
2
+ import { Meta } from '@storybook/react';
3
+ import { Stack } from '@superdispatch/ui';
4
+ import { PropsLink } from '@superdispatch/ui-docs';
5
+ import { Box } from '@superdispatch/ui-lab';
6
+
7
+ export default {
8
+ title: 'Inputs/Pagination',
9
+ component: Pagination,
10
+ decorators: [
11
+ (Story) => (
12
+ <Box backgroundColor="White">
13
+ <Story />
14
+ </Box>
15
+ ),
16
+ ],
17
+ parameters: {
18
+ componentSubtitle: (
19
+ <PropsLink url="https://material-ui.com/api/pagination/#props" />
20
+ ),
21
+ },
22
+ } as Meta;
23
+
24
+ export const basic = () => (
25
+ <Stack space="medium">
26
+ <Pagination count={154} page={5} siblingCount={3} />
27
+
28
+ <Pagination count={154} page={13} siblingCount={3} />
29
+
30
+ <Pagination count={154} page={147} siblingCount={3} />
31
+ </Stack>
32
+ );
33
+
34
+ export const disabled = () => (
35
+ <Pagination count={154} page={1} siblingCount={3} disabled={true} />
36
+ );
@@ -0,0 +1,47 @@
1
+ import { StyleRules } from '@material-ui/core';
2
+ import { PaginationItemClassKey, PaginationItemProps } from '@material-ui/lab';
3
+ import { CSSProperties } from '@material-ui/styles';
4
+ import { Color } from '../theme/Color';
5
+ import { SuperDispatchTheme } from '../theme/SuperDispatchTheme';
6
+
7
+ type Overrides<T extends string> = Partial<StyleRules<T>> & {
8
+ MuiCssBaseline?: CSSProperties | string;
9
+ };
10
+
11
+ export function overridePagination(theme: SuperDispatchTheme): void {
12
+ const props: Partial<PaginationItemProps> = {};
13
+ const overrides: Overrides<PaginationItemClassKey> = {
14
+ root: {
15
+ color: Color.Dark400,
16
+ },
17
+ page: {
18
+ '&:hover': {
19
+ backgroundColor: Color.Silver200,
20
+ },
21
+ '&$focusVisible': {
22
+ borderRadius: 4,
23
+ backgroundColor: Color.White,
24
+ border: `1px solid ${Color.Blue100}`,
25
+ },
26
+ '&$selected': {
27
+ backgroundColor: Color.Silver400,
28
+ '&:hover, &$focusVisible': {
29
+ backgroundColor: Color.Silver400,
30
+ },
31
+ '&$disabled': {
32
+ color: Color.Dark100,
33
+ backgroundColor: Color.Silver400,
34
+ },
35
+ },
36
+
37
+ '&$disabled': {
38
+ opacity: undefined,
39
+ color: Color.Dark100,
40
+ },
41
+ },
42
+ };
43
+
44
+ // Remove `Object.assign` after official release of `PaginationItem`.
45
+ Object.assign(theme.props, { MuiPaginationItem: props });
46
+ Object.assign(theme.overrides, { MuiPaginationItem: overrides });
47
+ }
@@ -0,0 +1,228 @@
1
+ import { Pagination } from '@material-ui/lab';
2
+ import { renderCSS, renderTheme } from '@superdispatch/ui-testutils';
3
+
4
+ it('checks default props', () => {
5
+ const { props } = renderTheme();
6
+
7
+ // Remove `any` after official release.
8
+ expect((props as any).MuiPagination).toMatchInlineSnapshot(`undefined`);
9
+ expect((props as any).MuiPaginationItem).toMatchInlineSnapshot(`Object {}`);
10
+ });
11
+
12
+ it('checks component css', () => {
13
+ expect(renderCSS(<Pagination />, ['MuiPagination', 'MuiPaginationItem']))
14
+ .toMatchInlineSnapshot(`
15
+ .MuiPagination-ul {
16
+ margin: 0;
17
+ display: flex;
18
+ padding: 0;
19
+ flex-wrap: wrap;
20
+ list-style: none;
21
+ align-items: center;
22
+ }
23
+
24
+ .MuiPaginationItem-root {
25
+ color: Color.Dark400;
26
+ height: 32px;
27
+ margin: 0 3px;
28
+ padding: 0 6px;
29
+ font-size: 14px;
30
+ min-width: 32px;
31
+ box-sizing: border-box;
32
+ text-align: center;
33
+ font-family: 'Inter', sans-serif;
34
+ font-weight: 400;
35
+ line-height: 20px;
36
+ border-radius: 16px;
37
+ }
38
+
39
+ @media (min-width: 0px) and (max-width: 599.95px) {
40
+ .MuiPaginationItem-root {
41
+ font-size: 16px;
42
+ line-height: 24px;
43
+ }
44
+ }
45
+
46
+ .MuiPaginationItem-page {
47
+ transition: color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
48
+ background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
49
+ }
50
+
51
+ .MuiPaginationItem-page:hover {
52
+ background-color: Color.Silver200;
53
+ }
54
+
55
+ .MuiPaginationItem-page.Mui-focusVisible {
56
+ border: 1px solid Color.Blue100;
57
+ border-radius: 4px;
58
+ background-color: Color.White;
59
+ }
60
+
61
+ .MuiPaginationItem-page.Mui-selected {
62
+ background-color: Color.Silver400;
63
+ }
64
+
65
+ .MuiPaginationItem-page.Mui-disabled {
66
+ color: Color.Dark100;
67
+ }
68
+
69
+ .MuiPaginationItem-page.Mui-selected:hover,
70
+ .MuiPaginationItem-page.Mui-selected.Mui-focusVisible {
71
+ background-color: Color.Silver400;
72
+ }
73
+
74
+ .MuiPaginationItem-page.Mui-selected.Mui-disabled {
75
+ color: Color.Dark100;
76
+ opacity: 1;
77
+ background-color: Color.Silver400;
78
+ }
79
+
80
+ @media (hover: none) {
81
+ .MuiPaginationItem-page.Mui-selected:hover,
82
+ .MuiPaginationItem-page.Mui-selected.Mui-focusVisible {
83
+ background-color: Color.Silver300;
84
+ }
85
+ }
86
+
87
+ @media (hover: none) {
88
+ .MuiPaginationItem-page:hover {
89
+ background-color: transparent;
90
+ }
91
+ }
92
+
93
+ .MuiPaginationItem-sizeSmall {
94
+ height: 26px;
95
+ margin: 0 1px;
96
+ padding: 0 4px;
97
+ min-width: 26px;
98
+ border-radius: 13px;
99
+ }
100
+
101
+ .MuiPaginationItem-sizeSmall .MuiPaginationItem-icon {
102
+ font-size: 1.125rem;
103
+ }
104
+
105
+ .MuiPaginationItem-sizeLarge {
106
+ height: 40px;
107
+ padding: 0 10px;
108
+ font-size: 0.9375rem;
109
+ min-width: 40px;
110
+ border-radius: 20px;
111
+ }
112
+
113
+ .MuiPaginationItem-sizeLarge .MuiPaginationItem-icon {
114
+ font-size: 1.375rem;
115
+ }
116
+
117
+ .MuiPaginationItem-textPrimary.Mui-selected {
118
+ color: Color.White;
119
+ background-color: Color.Blue300;
120
+ }
121
+
122
+ .MuiPaginationItem-textPrimary.Mui-selected:hover,
123
+ .MuiPaginationItem-textPrimary.Mui-selected.Mui-focusVisible {
124
+ background-color: rgb(0, 81, 178);
125
+ }
126
+
127
+ .MuiPaginationItem-textPrimary.Mui-selected.Mui-disabled {
128
+ color: Color.Silver400;
129
+ }
130
+
131
+ @media (hover: none) {
132
+ .MuiPaginationItem-textPrimary.Mui-selected:hover,
133
+ .MuiPaginationItem-textPrimary.Mui-selected.Mui-focusVisible {
134
+ background-color: Color.Blue300;
135
+ }
136
+ }
137
+
138
+ .MuiPaginationItem-textSecondary.Mui-selected {
139
+ color: Color.White;
140
+ background-color: #f50057;
141
+ }
142
+
143
+ .MuiPaginationItem-textSecondary.Mui-selected:hover,
144
+ .MuiPaginationItem-textSecondary.Mui-selected.Mui-focusVisible {
145
+ background-color: #c51162;
146
+ }
147
+
148
+ .MuiPaginationItem-textSecondary.Mui-selected.Mui-disabled {
149
+ color: Color.Silver400;
150
+ }
151
+
152
+ @media (hover: none) {
153
+ .MuiPaginationItem-textSecondary.Mui-selected:hover,
154
+ .MuiPaginationItem-textSecondary.Mui-selected.Mui-focusVisible {
155
+ background-color: #f50057;
156
+ }
157
+ }
158
+
159
+ .MuiPaginationItem-outlined {
160
+ border: 1px solid rgba(0, 0, 0, 0.23);
161
+ }
162
+
163
+ .MuiPaginationItem-outlined.Mui-selected.Mui-disabled {
164
+ border: 1px solid rgba(0, 0, 0, 0.12);
165
+ }
166
+
167
+ .MuiPaginationItem-outlinedPrimary.Mui-selected {
168
+ color: Color.Blue300;
169
+ border: 1px solid rgba(0, 117, 255, 0.5);
170
+ background-color: rgba(0, 117, 255, 0.12);
171
+ }
172
+
173
+ .MuiPaginationItem-outlinedPrimary.Mui-selected:hover,
174
+ .MuiPaginationItem-outlinedPrimary.Mui-selected.Mui-focusVisible {
175
+ background-color: rgba(0, 117, 255, 0.16);
176
+ }
177
+
178
+ .MuiPaginationItem-outlinedPrimary.Mui-selected.Mui-disabled {
179
+ color: Color.Silver400;
180
+ }
181
+
182
+ @media (hover: none) {
183
+ .MuiPaginationItem-outlinedPrimary.Mui-selected:hover,
184
+ .MuiPaginationItem-outlinedPrimary.Mui-selected.Mui-focusVisible {
185
+ background-color: transparent;
186
+ }
187
+ }
188
+
189
+ .MuiPaginationItem-outlinedSecondary.Mui-selected {
190
+ color: #f50057;
191
+ border: 1px solid rgba(245, 0, 87, 0.5);
192
+ background-color: rgba(245, 0, 87, 0.12);
193
+ }
194
+
195
+ .MuiPaginationItem-outlinedSecondary.Mui-selected:hover,
196
+ .MuiPaginationItem-outlinedSecondary.Mui-selected.Mui-focusVisible {
197
+ background-color: rgba(245, 0, 87, 0.16);
198
+ }
199
+
200
+ .MuiPaginationItem-outlinedSecondary.Mui-selected.Mui-disabled {
201
+ color: Color.Silver400;
202
+ }
203
+
204
+ @media (hover: none) {
205
+ .MuiPaginationItem-outlinedSecondary.Mui-selected:hover,
206
+ .MuiPaginationItem-outlinedSecondary.Mui-selected.Mui-focusVisible {
207
+ background-color: transparent;
208
+ }
209
+ }
210
+
211
+ .MuiPaginationItem-rounded {
212
+ border-radius: 4px;
213
+ }
214
+
215
+ .MuiPaginationItem-ellipsis {
216
+ height: auto;
217
+ }
218
+
219
+ .MuiPaginationItem-ellipsis.Mui-disabled {
220
+ opacity: 0.38;
221
+ }
222
+
223
+ .MuiPaginationItem-icon {
224
+ margin: 0 -8px;
225
+ font-size: 1.25rem;
226
+ }
227
+ `);
228
+ });