@ttoss/ui 5.0.7 → 5.0.9

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 (36) hide show
  1. package/LICENSE +21 -674
  2. package/package.json +8 -8
  3. package/src/components/ActionButton.tsx +0 -41
  4. package/src/components/Badge.tsx +0 -54
  5. package/src/components/Box.tsx +0 -1
  6. package/src/components/Button.tsx +0 -43
  7. package/src/components/Card.tsx +0 -1
  8. package/src/components/Checkbox.tsx +0 -36
  9. package/src/components/CloseButton.tsx +0 -49
  10. package/src/components/Container.tsx +0 -12
  11. package/src/components/Divider.tsx +0 -1
  12. package/src/components/Flex.tsx +0 -1
  13. package/src/components/Grid.tsx +0 -1
  14. package/src/components/Heading.tsx +0 -1
  15. package/src/components/HelpText.tsx +0 -31
  16. package/src/components/IconButton.tsx +0 -12
  17. package/src/components/Image.tsx +0 -1
  18. package/src/components/InfiniteLinearProgress.tsx +0 -38
  19. package/src/components/Input.tsx +0 -83
  20. package/src/components/InputNumber.tsx +0 -150
  21. package/src/components/InputPassword/InputPassword.tsx +0 -32
  22. package/src/components/InputPassword/useHidePassInput.ts +0 -26
  23. package/src/components/Label.tsx +0 -46
  24. package/src/components/LinearProgress.tsx +0 -4
  25. package/src/components/Link.tsx +0 -20
  26. package/src/components/Paragraph.tsx +0 -1
  27. package/src/components/Radio.tsx +0 -1
  28. package/src/components/Select.tsx +0 -284
  29. package/src/components/Slider.tsx +0 -1
  30. package/src/components/Spinner.tsx +0 -1
  31. package/src/components/Stack.tsx +0 -24
  32. package/src/components/Text.tsx +0 -1
  33. package/src/components/Textarea.tsx +0 -55
  34. package/src/index.ts +0 -58
  35. package/src/theme/ThemeProvider.tsx +0 -36
  36. package/src/theme/useTheme.ts +0 -3
@@ -1,46 +0,0 @@
1
- import { Icon } from '@ttoss/react-icons';
2
- import { type LabelProps as LabelPropsUi, Label as LabelUi } from 'theme-ui';
3
- import { Text } from '..';
4
-
5
- const TOOLTIP_LABEL = 'tooltip';
6
-
7
- export type LabelProps = LabelPropsUi & {
8
- tooltip?: boolean;
9
- onTooltipClick?: () => void;
10
- };
11
-
12
- export const Label = ({
13
- children,
14
- onTooltipClick,
15
- tooltip,
16
- sx,
17
- ...props
18
- }: LabelProps) => {
19
- return (
20
- <LabelUi
21
- sx={{
22
- fontFamily: 'caption',
23
- alignItems: 'center',
24
- fontSize: 'sm',
25
- lineHeight: 'base',
26
- ...sx,
27
- }}
28
- {...props}
29
- >
30
- {children}
31
-
32
- {tooltip && (
33
- <Text
34
- sx={{
35
- color: 'currentcolor',
36
- cursor: onTooltipClick ? 'pointer' : undefined,
37
- }}
38
- onClick={onTooltipClick}
39
- aria-label={TOOLTIP_LABEL}
40
- >
41
- <Icon inline icon="info" />
42
- </Text>
43
- )}
44
- </LabelUi>
45
- );
46
- };
@@ -1,4 +0,0 @@
1
- export {
2
- Progress as LinearProgress,
3
- type ProgressProps as LinearProgressProps,
4
- } from 'theme-ui';
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- import { type LinkProps as LinkPropsUi, Link as LinkUi } from 'theme-ui';
3
-
4
- export type LinkProps = LinkPropsUi & {
5
- quiet?: boolean;
6
- };
7
-
8
- export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
9
- ({ quiet, className, ...props }, ref) => {
10
- return (
11
- <LinkUi
12
- className={`${quiet ? 'quiet' : ''} ${className ?? ''}`}
13
- {...props}
14
- ref={ref}
15
- />
16
- );
17
- }
18
- );
19
-
20
- Link.displayName = 'Link';
@@ -1 +0,0 @@
1
- export { Paragraph, type ParagraphProps } from 'theme-ui';
@@ -1 +0,0 @@
1
- export { Radio, type RadioProps } from 'theme-ui';
@@ -1,284 +0,0 @@
1
- /**
2
- * We're using React Select component to build ttoss Select.
3
- * More info about React Select: https://react-select.com/home
4
- * ttoss Figma: https://www.figma.com/file/VrB76VkH4hKCDUe9iYhpYu/_Component-%2F-Forms-%2F-Select?type=design&mode=design&t=ZBIeOpqcvQn3yq2t-0
5
- */
6
- import * as React from 'react';
7
- import { Box, Flex, Text } from '..';
8
- import { Icon, IconType } from '@ttoss/react-icons';
9
- import { type SxProp } from 'theme-ui';
10
- import ReactSelect, {
11
- type ContainerProps,
12
- type ControlProps,
13
- type DropdownIndicatorProps,
14
- type IndicatorsContainerProps,
15
- type PlaceholderProps,
16
- type Props as ReactSelectProps,
17
- type ValueContainerProps,
18
- components,
19
- } from 'react-select';
20
-
21
- type SelectOptionValue = string | number | boolean;
22
-
23
- export type SelectOption = {
24
- label: string;
25
- value: SelectOptionValue;
26
- };
27
-
28
- export type SelectOptions = SelectOption[];
29
-
30
- /**
31
- * TODO: remove this when we accept multi select.
32
- */
33
- type IsMulti = false;
34
-
35
- export type SelectProps = Omit<
36
- ReactSelectProps<SelectOption, IsMulti>,
37
- 'styles' | 'value' | 'onChange' | 'components'
38
- > &
39
- SxProp & {
40
- value?: SelectOptionValue;
41
- onChange?: (value: SelectOptionValue | undefined) => void;
42
- disabled?: boolean;
43
- leadingIcon?: IconType;
44
- trailingIcon?: IconType;
45
- };
46
-
47
- const Control = (props: ControlProps<SelectOption, IsMulti>) => {
48
- const isDisabled = props.selectProps.isDisabled;
49
-
50
- const hasError = props.selectProps['aria-invalid'] === 'true';
51
-
52
- const border = (() => {
53
- if (isDisabled) {
54
- return 'muted';
55
- }
56
-
57
- if (hasError) {
58
- return 'danger';
59
- }
60
-
61
- return 'interaction';
62
- })();
63
-
64
- const backgroundColor = (() => {
65
- if (isDisabled) {
66
- return 'muted';
67
- }
68
-
69
- return 'surface';
70
- })();
71
-
72
- return (
73
- <Box
74
- sx={{
75
- '.react-select__control': {
76
- border,
77
- backgroundColor,
78
- paddingX: 'xl',
79
- paddingY: 'lg',
80
- borderRadius: 'action',
81
- },
82
- }}
83
- >
84
- <components.Control {...props} />
85
- </Box>
86
- );
87
- };
88
-
89
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
90
- const DropdownIndicator = (
91
- props: DropdownIndicatorProps<SelectOption, IsMulti>
92
- ) => {
93
- const isDisabled = props.selectProps.isDisabled;
94
-
95
- const color = (() => {
96
- if (isDisabled) {
97
- return 'onMuted';
98
- }
99
-
100
- return 'text';
101
- })();
102
-
103
- return (
104
- <Text
105
- sx={{
106
- fontSize: 'base',
107
- color,
108
- alignSelf: 'center',
109
- display: 'flex',
110
- alignItems: 'center',
111
- }}
112
- >
113
- <Icon icon="picker-down" />
114
- </Text>
115
- );
116
- };
117
-
118
- const IndicatorsContainer = ({
119
- children,
120
- }: IndicatorsContainerProps<SelectOption, IsMulti>) => {
121
- return (
122
- <Box
123
- sx={{
124
- marginLeft: 'lg',
125
- border: 'none',
126
- }}
127
- >
128
- {children}
129
- </Box>
130
- );
131
- };
132
-
133
- const Placeholder = ({ children }: PlaceholderProps<SelectOption, IsMulti>) => {
134
- return (
135
- <Text
136
- sx={{
137
- color: 'onMuted',
138
- alignSelf: 'center',
139
- }}
140
- >
141
- {children}
142
- </Text>
143
- );
144
- };
145
-
146
- const SelectContainer = ({
147
- children,
148
- ...props
149
- }: ContainerProps<SelectOption, IsMulti>) => {
150
- const { sx, css } = props.selectProps as unknown as SelectProps;
151
-
152
- return (
153
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
- <Box sx={sx as any} css={css}>
155
- <components.SelectContainer {...props}>
156
- {children}
157
- </components.SelectContainer>
158
- </Box>
159
- );
160
- };
161
-
162
- const ValueContainer = ({
163
- children,
164
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
165
- ...props
166
- }: ValueContainerProps<SelectOption, IsMulti>) => {
167
- const { leadingIcon, trailingIcon, isSearchable } =
168
- props.selectProps as unknown as SelectProps;
169
-
170
- const hasError = props.selectProps['aria-invalid'] === 'true';
171
-
172
- const trailingIconColor = (() => {
173
- if (hasError) {
174
- return 'danger';
175
- }
176
-
177
- return 'text';
178
- })();
179
-
180
- const finalLeadingIcon = (() => {
181
- if (!isSearchable) {
182
- return leadingIcon;
183
- }
184
-
185
- return leadingIcon || 'search';
186
- })();
187
-
188
- return (
189
- <Flex
190
- sx={{
191
- gap: 'lg',
192
- flex: 1,
193
- }}
194
- >
195
- {finalLeadingIcon && (
196
- <Text
197
- sx={{
198
- alignSelf: 'center',
199
- pointerEvents: 'none',
200
- lineHeight: 0,
201
- fontSize: 'base',
202
- }}
203
- >
204
- <Icon icon={finalLeadingIcon} />
205
- </Text>
206
- )}
207
- <Flex
208
- sx={{
209
- flex: 1,
210
- alignItems: 'center',
211
- }}
212
- >
213
- {children}
214
- </Flex>
215
- {(trailingIcon || hasError) && (
216
- <Text
217
- className={hasError ? 'error-icon' : ''}
218
- sx={{
219
- alignSelf: 'center',
220
- pointerEvents: 'none',
221
- lineHeight: 0,
222
- fontSize: 'base',
223
- color: trailingIconColor,
224
- }}
225
- >
226
- <Icon icon={hasError ? 'warning-alt' : (trailingIcon as IconType)} />
227
- </Text>
228
- )}
229
- </Flex>
230
- );
231
- };
232
-
233
- /**
234
- * https://react-select.com/home
235
- */
236
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
237
- export const Select = React.forwardRef<any, SelectProps>(
238
- ({ ...props }, ref) => {
239
- const value = props.options?.find((option) => {
240
- if ('value' in option) {
241
- return option.value === props.value;
242
- }
243
-
244
- return false;
245
- }) as SelectOption | undefined;
246
-
247
- return (
248
- <ReactSelect<SelectOption, IsMulti>
249
- ref={ref}
250
- /**
251
- * https://react-select.com/components
252
- */
253
- components={{
254
- Control,
255
- DropdownIndicator,
256
- IndicatorsContainer,
257
- Placeholder,
258
- SelectContainer,
259
- ValueContainer,
260
- }}
261
- isDisabled={props.disabled}
262
- {...props}
263
- value={value}
264
- onChange={(value) => {
265
- props.onChange?.(value?.value);
266
- }}
267
- styles={{
268
- input: (baseStyles) => {
269
- return {
270
- ...baseStyles,
271
- position: 'absolute',
272
- };
273
- },
274
- }}
275
- /**
276
- * https://react-select.com/styles#the-classnameprefix-prop
277
- */
278
- classNamePrefix="react-select"
279
- />
280
- );
281
- }
282
- );
283
-
284
- Select.displayName = 'Select';
@@ -1 +0,0 @@
1
- export { Slider, type SliderProps } from 'theme-ui';
@@ -1 +0,0 @@
1
- export { Spinner, type SpinnerProps } from 'theme-ui';
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
- import { Flex, FlexProps } from './Flex';
3
-
4
- export type StackProps = FlexProps;
5
-
6
- /**
7
- * A component that renders its children in a column.
8
- */
9
- export const Stack = React.forwardRef<HTMLElement, StackProps>(
10
- (props: FlexProps, ref) => {
11
- return (
12
- <Flex
13
- ref={ref}
14
- {...props}
15
- sx={{
16
- flexDirection: 'column',
17
- ...props.sx,
18
- }}
19
- />
20
- );
21
- }
22
- );
23
-
24
- Stack.displayName = 'Stack';
@@ -1 +0,0 @@
1
- export { Text, type TextProps } from 'theme-ui';
@@ -1,55 +0,0 @@
1
- import * as React from 'react';
2
- import { Flex, Text } from '..';
3
- import { Icon, type IconType } from '@ttoss/react-icons';
4
- import {
5
- type TextareaProps as TextareaPropsUI,
6
- Textarea as TextareaUI,
7
- } from 'theme-ui';
8
-
9
- export interface TextareaProps extends TextareaPropsUI {
10
- trailingIcon?: IconType;
11
- }
12
-
13
- export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
14
- ({ trailingIcon, className, sx, ...textareaProps }, ref) => {
15
- return (
16
- <Flex
17
- className={className}
18
- sx={{
19
- ...sx,
20
- position: 'relative',
21
- padding: 0,
22
- border: 'none',
23
- }}
24
- >
25
- <TextareaUI
26
- ref={ref}
27
- sx={{
28
- fontFamily: 'body',
29
- paddingY: 'lg',
30
- paddingX: 'xl',
31
- ...sx,
32
- paddingRight: trailingIcon ? '3xl' : undefined,
33
- margin: 0,
34
- }}
35
- className={className}
36
- {...textareaProps}
37
- />
38
-
39
- {trailingIcon && (
40
- <Text
41
- sx={{
42
- position: 'absolute',
43
- right: '1.25rem',
44
- top: '0.75rem',
45
- }}
46
- >
47
- <Icon inline icon={trailingIcon} />
48
- </Text>
49
- )}
50
- </Flex>
51
- );
52
- }
53
- );
54
-
55
- Textarea.displayName = 'Textarea';
package/src/index.ts DELETED
@@ -1,58 +0,0 @@
1
- export {
2
- BaseStyles,
3
- type Theme,
4
- Global,
5
- type SxProp,
6
- type ThemeUIStyleObject,
7
- } from 'theme-ui';
8
- export { useResponsiveValue, useBreakpointIndex } from '@theme-ui/match-media';
9
- export { keyframes, type Keyframes } from '@emotion/react';
10
-
11
- export { ThemeProvider, type ThemeProviderProps } from './theme/ThemeProvider';
12
-
13
- export { useTheme } from './theme/useTheme';
14
-
15
- export { Badge, type BadgeProps } from './components/Badge';
16
- export { Box, type BoxProps } from './components/Box';
17
- export { Button, type ButtonProps } from './components/Button';
18
- export { Card, type CardProps } from './components/Card';
19
- export { Divider, type DividerProps } from './components/Divider';
20
- export { Flex, type FlexProps } from './components/Flex';
21
- export { Grid, type GridProps } from './components/Grid';
22
- export { Heading, type HeadingProps } from './components/Heading';
23
- export { Image, type ImageProps } from './components/Image';
24
- export { Input, type InputProps } from './components/Input';
25
- export { Label, type LabelProps } from './components/Label';
26
- export { Link, type LinkProps } from './components/Link';
27
- export {
28
- LinearProgress,
29
- type LinearProgressProps,
30
- } from './components/LinearProgress';
31
- export { Text, type TextProps } from './components/Text';
32
- export {
33
- Select,
34
- type SelectProps,
35
- type SelectOptions,
36
- type SelectOption,
37
- } from './components/Select';
38
- export { Spinner, type SpinnerProps } from './components/Spinner';
39
- export { Radio, type RadioProps } from './components/Radio';
40
- export { IconButton, type IconButtonProps } from './components/IconButton';
41
- export { Slider, type SliderProps } from './components/Slider';
42
- export { Checkbox, type CheckboxProps } from './components/Checkbox';
43
- export { InfiniteLinearProgress } from './components/InfiniteLinearProgress';
44
- export { Textarea, type TextareaProps } from './components/Textarea';
45
- export { Container, type ContainerProps } from './components/Container';
46
- export { HelpText, type HelpTextProps } from './components/HelpText';
47
- export { CloseButton, type CloseButtonProps } from './components/CloseButton';
48
- export { InputNumber, type InputNumberProps } from './components/InputNumber';
49
- export { Stack, type StackProps } from './components/Stack';
50
- export { Paragraph, type ParagraphProps } from './components/Paragraph';
51
- export {
52
- InputPassword,
53
- type InputPasswordProps,
54
- } from './components/InputPassword/InputPassword';
55
- export {
56
- ActionButton,
57
- type ActionButtonProps,
58
- } from './components/ActionButton';
@@ -1,36 +0,0 @@
1
- import * as React from 'react';
2
- import { BruttalFonts, BruttalTheme } from '@ttoss/theme/Bruttal';
3
- import { Global, css } from '@emotion/react';
4
- import { Theme, ThemeUIProvider } from 'theme-ui';
5
-
6
- export type ThemeProviderProps = {
7
- children?: React.ReactNode;
8
- theme?: Theme;
9
- /**
10
- * Fonts URLs.
11
- */
12
- fonts?: string[];
13
- };
14
-
15
- export const ThemeProvider = ({
16
- children,
17
- theme = BruttalTheme,
18
- fonts = BruttalFonts,
19
- }: ThemeProviderProps) => {
20
- return (
21
- <>
22
- <ThemeUIProvider theme={theme}>
23
- <Global
24
- styles={css`
25
- ${fonts
26
- .map((url) => {
27
- return `@import url('${url}');`;
28
- })
29
- .join('\n')}
30
- `}
31
- />
32
- {children}
33
- </ThemeUIProvider>
34
- </>
35
- );
36
- };
@@ -1,3 +0,0 @@
1
- import { useThemeUI } from 'theme-ui';
2
-
3
- export const useTheme = useThemeUI;