@tecsinapse/react-web-kit 1.18.5 → 1.19.0

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 (93) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/components/atoms/Button/Button.d.ts +2 -0
  3. package/dist/components/atoms/Button/Button.js +18 -2
  4. package/dist/components/atoms/Button/Button.js.map +1 -1
  5. package/dist/components/atoms/Button/hooks/useMouseHover.d.ts +3 -3
  6. package/dist/components/atoms/Button/hooks/useMouseHover.js +13 -3
  7. package/dist/components/atoms/Button/hooks/useMouseHover.js.map +1 -1
  8. package/dist/components/atoms/Button/hooks/useMousePressed.d.ts +5 -0
  9. package/dist/components/atoms/Button/hooks/useMousePressed.js +32 -0
  10. package/dist/components/atoms/Button/hooks/useMousePressed.js.map +1 -0
  11. package/dist/components/atoms/Button/styled.js +9 -4
  12. package/dist/components/atoms/Button/styled.js.map +1 -1
  13. package/dist/components/molecules/Grid/Grid.d.ts +3 -13
  14. package/dist/components/molecules/Grid/Grid.js +4 -2
  15. package/dist/components/molecules/Grid/Grid.js.map +1 -1
  16. package/dist/components/molecules/Grid/Item/Item.d.ts +6 -27
  17. package/dist/components/molecules/Grid/Item/Item.js +41 -19
  18. package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
  19. package/dist/components/molecules/Grid/Item/functions.d.ts +2 -0
  20. package/dist/components/molecules/Grid/Item/functions.js +16 -0
  21. package/dist/components/molecules/Grid/Item/functions.js.map +1 -0
  22. package/dist/components/molecules/Grid/Item/index.d.ts +1 -1
  23. package/dist/components/molecules/Grid/Item/index.js.map +1 -1
  24. package/dist/components/molecules/Grid/index.d.ts +2 -2
  25. package/dist/components/molecules/Grid/index.js.map +1 -1
  26. package/dist/components/molecules/IconTextButton/IconTextButton.d.ts +6 -0
  27. package/dist/components/molecules/IconTextButton/IconTextButton.js +64 -0
  28. package/dist/components/molecules/IconTextButton/IconTextButton.js.map +1 -0
  29. package/dist/components/molecules/IconTextButton/TextComponent.d.ts +12 -0
  30. package/dist/components/molecules/IconTextButton/TextComponent.js +32 -0
  31. package/dist/components/molecules/IconTextButton/TextComponent.js.map +1 -0
  32. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.d.ts +6 -0
  33. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.js +31 -0
  34. package/dist/components/molecules/IconTextButton/hooks/useIconTextButton.js.map +1 -0
  35. package/dist/components/molecules/IconTextButton/index.d.ts +1 -0
  36. package/dist/components/molecules/IconTextButton/index.js +24 -0
  37. package/dist/components/molecules/IconTextButton/index.js.map +1 -0
  38. package/dist/components/molecules/IconTextButton/styled.d.ts +1 -0
  39. package/dist/components/molecules/IconTextButton/styled.js +33 -0
  40. package/dist/components/molecules/IconTextButton/styled.js.map +1 -0
  41. package/dist/components/molecules/LabeledSwitch/LabelComponent.d.ts +12 -0
  42. package/dist/components/molecules/LabeledSwitch/LabelComponent.js +38 -0
  43. package/dist/components/molecules/LabeledSwitch/LabelComponent.js.map +1 -0
  44. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.d.ts +7 -0
  45. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +55 -0
  46. package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +1 -0
  47. package/dist/components/molecules/LabeledSwitch/index.d.ts +1 -0
  48. package/dist/components/molecules/LabeledSwitch/index.js +24 -0
  49. package/dist/components/molecules/LabeledSwitch/index.js.map +1 -0
  50. package/dist/components/molecules/LabeledSwitch/styled.d.ts +8 -0
  51. package/dist/components/molecules/LabeledSwitch/styled.js +39 -0
  52. package/dist/components/molecules/LabeledSwitch/styled.js.map +1 -0
  53. package/dist/components/organisms/DataGrid/Footer/Footer.js +3 -2
  54. package/dist/components/organisms/DataGrid/Footer/Footer.js.map +1 -1
  55. package/dist/hooks/index.d.ts +2 -0
  56. package/dist/hooks/index.js +16 -0
  57. package/dist/hooks/index.js.map +1 -1
  58. package/dist/hooks/useBreakpoints.d.ts +6 -0
  59. package/dist/hooks/useBreakpoints.js +27 -0
  60. package/dist/hooks/useBreakpoints.js.map +1 -0
  61. package/dist/hooks/useWindowSize.d.ts +6 -0
  62. package/dist/hooks/useWindowSize.js +35 -0
  63. package/dist/hooks/useWindowSize.js.map +1 -0
  64. package/dist/index.d.ts +14 -13
  65. package/dist/index.js +147 -131
  66. package/dist/index.js.map +1 -1
  67. package/package.json +6 -6
  68. package/src/components/atoms/Button/Button.tsx +20 -1
  69. package/src/components/atoms/Button/hooks/useMouseHover.ts +17 -9
  70. package/src/components/atoms/Button/hooks/useMousePressed.ts +29 -0
  71. package/src/components/atoms/Button/styled.ts +23 -6
  72. package/src/components/molecules/Grid/Grid.stories.tsx +198 -0
  73. package/src/components/molecules/Grid/Grid.tsx +7 -25
  74. package/src/components/molecules/Grid/Item/Item.tsx +57 -57
  75. package/src/components/molecules/Grid/Item/functions.ts +13 -0
  76. package/src/components/molecules/Grid/Item/index.ts +1 -1
  77. package/src/components/molecules/Grid/index.ts +2 -2
  78. package/src/components/molecules/IconTextButton/IconTextButton.stories.tsx +51 -0
  79. package/src/components/molecules/IconTextButton/IconTextButton.tsx +65 -0
  80. package/src/components/molecules/IconTextButton/TextComponent.tsx +39 -0
  81. package/src/components/molecules/IconTextButton/hooks/useIconTextButton.ts +31 -0
  82. package/src/components/molecules/IconTextButton/index.ts +4 -0
  83. package/src/components/molecules/IconTextButton/styled.ts +18 -0
  84. package/src/components/molecules/LabeledSwitch/LabelComponent.tsx +46 -0
  85. package/src/components/molecules/LabeledSwitch/LabeledSwitch.stories.tsx +41 -0
  86. package/src/components/molecules/LabeledSwitch/LabeledSwitch.tsx +58 -0
  87. package/src/components/molecules/LabeledSwitch/index.ts +4 -0
  88. package/src/components/molecules/LabeledSwitch/styled.ts +26 -0
  89. package/src/components/organisms/DataGrid/Footer/Footer.tsx +4 -4
  90. package/src/hooks/index.ts +2 -0
  91. package/src/hooks/useBreakpoints.ts +18 -0
  92. package/src/hooks/useWindowSize.ts +25 -0
  93. package/src/index.ts +33 -24
@@ -0,0 +1,39 @@
1
+ import {
2
+ ButtonSizeType,
3
+ FontColor,
4
+ IconPositionOptions,
5
+ Text,
6
+ TextProps,
7
+ } from '@tecsinapse/react-core';
8
+ import React, { FC } from 'react';
9
+
10
+ interface TextComponentProps {
11
+ textProps?: TextProps;
12
+ size?: ButtonSizeType;
13
+ defaultFontColor: keyof FontColor;
14
+ label?: string;
15
+ iconPosition?: IconPositionOptions;
16
+ hasIcon?: boolean;
17
+ }
18
+
19
+ const TextComponent: FC<TextComponentProps> = ({
20
+ textProps,
21
+ size = 'default',
22
+ defaultFontColor,
23
+ label,
24
+ }) => {
25
+ return label ? (
26
+ <Text
27
+ typography={textProps?.typography ?? size === 'small' ? 'sub' : 'base'}
28
+ fontWeight={textProps?.fontWeight ?? 'bold'}
29
+ fontColor={textProps?.fontColor ?? defaultFontColor}
30
+ {...textProps}
31
+ >
32
+ {label}
33
+ </Text>
34
+ ) : (
35
+ <></>
36
+ );
37
+ };
38
+
39
+ export default React.memo(TextComponent);
@@ -0,0 +1,31 @@
1
+ import { fontColorVC, VariantType } from '@tecsinapse/react-core';
2
+ import { useCallback, useState } from 'react';
3
+
4
+ const useIconTextButton = (variant: VariantType) => {
5
+ const [hover, setHover] = useState<boolean>(false);
6
+ const [pressed, setPressed] = useState<boolean>(false);
7
+
8
+ const defaultFontColor = !pressed && hover ? 'light' : fontColorVC[variant];
9
+
10
+ const handleHover = useCallback(
11
+ (value: boolean) => {
12
+ setHover(value);
13
+ },
14
+ [setHover]
15
+ );
16
+
17
+ const handlePressed = useCallback(
18
+ (value: boolean) => {
19
+ setPressed(value);
20
+ },
21
+ [setPressed]
22
+ );
23
+
24
+ return {
25
+ handleHover,
26
+ handlePressed,
27
+ defaultFontColor,
28
+ };
29
+ };
30
+
31
+ export default useIconTextButton;
@@ -0,0 +1,4 @@
1
+ export {
2
+ default as IconTextButton,
3
+ WebIconTextButtonProps,
4
+ } from './IconTextButton';
@@ -0,0 +1,18 @@
1
+ import styled from '@emotion/native';
2
+ import { StyleProps } from '@tecsinapse/react-core';
3
+ import { Button } from '../../atoms/Button';
4
+
5
+ const boxedStyle = ({ theme }: Partial<StyleProps>) =>
6
+ `
7
+ padding: ${theme?.spacing.centi};
8
+ aspect-ratio: 1;
9
+ `;
10
+
11
+ export const StyledIconTextButton = styled(Button)<
12
+ Partial<StyleProps> & {
13
+ boxed: boolean;
14
+ }
15
+ >`
16
+ gap: ${({ theme }) => theme?.spacing.mili};
17
+ ${({ boxed, theme }) => boxed && boxedStyle({ theme })};
18
+ `;
@@ -0,0 +1,46 @@
1
+ import {
2
+ FontColor,
3
+ FontWeight,
4
+ LabelPositionOptions,
5
+ TextProps,
6
+ } from '@tecsinapse/react-core';
7
+ import React, { FC } from 'react';
8
+ import { Pressable, PressableProps } from 'react-native';
9
+ import { StyledLabel } from './styled';
10
+
11
+ export interface LabelComponentProps extends PressableProps {
12
+ label: string;
13
+ labelPosition: LabelPositionOptions;
14
+ labelProps?: TextProps;
15
+ active: boolean;
16
+ switchDisabled?: boolean;
17
+ }
18
+
19
+ const LabelComponent: FC<LabelComponentProps> = ({
20
+ label,
21
+ labelPosition,
22
+ labelProps,
23
+ active,
24
+ switchDisabled = false,
25
+ ...rest
26
+ }) => {
27
+ const defaultFontColor: keyof FontColor =
28
+ active && !switchDisabled ? 'dark' : 'medium';
29
+ const defaultFontWeight: keyof FontWeight =
30
+ active && !switchDisabled ? 'bold' : 'regular';
31
+
32
+ return (
33
+ <Pressable {...rest}>
34
+ <StyledLabel
35
+ labelPosition={labelPosition}
36
+ fontColor={labelProps?.fontColor ?? defaultFontColor}
37
+ fontWeight={labelProps?.fontWeight ?? defaultFontWeight}
38
+ {...labelProps}
39
+ >
40
+ {label}
41
+ </StyledLabel>
42
+ </Pressable>
43
+ );
44
+ };
45
+
46
+ export default React.memo(LabelComponent);
@@ -0,0 +1,41 @@
1
+ import { action } from '@storybook/addon-actions';
2
+ import { Story } from '@storybook/react';
3
+ import React from 'react';
4
+ import {
5
+ default as LabeledSwitch,
6
+ LabeledSwitchWebProps,
7
+ } from './LabeledSwitch';
8
+
9
+ export default {
10
+ title: 'Web/LabeledSwitch',
11
+ component: LabeledSwitch,
12
+ };
13
+
14
+ const Template: Story<LabeledSwitchWebProps> = args => {
15
+ const [active, setActive] = React.useState(args.active);
16
+ const onChange = arg => {
17
+ setActive(!active);
18
+ args.onChange(arg);
19
+ };
20
+
21
+ return (
22
+ <LabeledSwitch
23
+ active={active}
24
+ onChange={onChange}
25
+ disabled={args.disabled}
26
+ label={'Labeled switch!'}
27
+ labelPosition={args.labelPosition}
28
+ pressableLabel={args.pressableLabel}
29
+ />
30
+ );
31
+ };
32
+
33
+ export const Base = Template.bind({});
34
+
35
+ Base.args = {
36
+ active: true,
37
+ onChange: value => action('Clicked')(value),
38
+ disabled: false,
39
+ labelPosition: 'right',
40
+ pressableLabel: true,
41
+ };
@@ -0,0 +1,58 @@
1
+ import { LabeledSwitchProps, Switch, TextProps } from '@tecsinapse/react-core';
2
+ import React, { FC } from 'react';
3
+ import LabelComponent from './LabelComponent';
4
+ import { StyledDiv } from './styled';
5
+
6
+ export type LabeledSwitchWebProps = LabeledSwitchProps & {
7
+ labelProps?: TextProps;
8
+ };
9
+
10
+ const LabeledSwitch: FC<LabeledSwitchWebProps> = ({
11
+ label,
12
+ labelPosition = 'right',
13
+ labelProps,
14
+ pressableLabel = false,
15
+ disabled,
16
+ active,
17
+ onChange,
18
+ ...rest
19
+ }) => {
20
+ return (
21
+ <StyledDiv>
22
+ {labelPosition === 'left' ? (
23
+ <LabelComponent
24
+ active={active}
25
+ label={label}
26
+ labelPosition={'left'}
27
+ labelProps={labelProps}
28
+ disabled={!pressableLabel || disabled}
29
+ switchDisabled={disabled}
30
+ onPress={() => onChange(!active)}
31
+ />
32
+ ) : (
33
+ <></>
34
+ )}
35
+ <Switch
36
+ active={active}
37
+ disabled={disabled}
38
+ onChange={onChange}
39
+ {...rest}
40
+ />
41
+ {labelPosition === 'right' ? (
42
+ <LabelComponent
43
+ active={active}
44
+ label={label}
45
+ labelPosition={'right'}
46
+ labelProps={labelProps}
47
+ disabled={!pressableLabel || disabled}
48
+ switchDisabled={disabled}
49
+ onPress={() => onChange(!active)}
50
+ />
51
+ ) : (
52
+ <></>
53
+ )}
54
+ </StyledDiv>
55
+ );
56
+ };
57
+
58
+ export default LabeledSwitch;
@@ -0,0 +1,4 @@
1
+ export {
2
+ default as LabeledSwitch,
3
+ LabeledSwitchWebProps,
4
+ } from './LabeledSwitch';
@@ -0,0 +1,26 @@
1
+ import { css, default as nativeStyled } from '@emotion/native';
2
+ import { default as webStyled } from '@emotion/styled';
3
+ import { LabelPositionOptions, StyleProps, Text } from '@tecsinapse/react-core';
4
+
5
+ export const StyledDiv = webStyled('div')`
6
+ display: flex;
7
+ flex-direction: row;
8
+ align-items: center;
9
+ `;
10
+
11
+ export const StyledLabel = nativeStyled(Text)<
12
+ Partial<StyleProps> & {
13
+ labelPosition: LabelPositionOptions;
14
+ }
15
+ >`
16
+ ${({ theme, labelPosition }) => {
17
+ if (labelPosition === 'right')
18
+ return css`
19
+ margin-left: ${theme?.spacing.centi};
20
+ `;
21
+ else if (labelPosition === 'left')
22
+ return css`
23
+ margin-right: ${theme?.spacing.centi};
24
+ `;
25
+ }}
26
+ `;
@@ -69,9 +69,9 @@ const Footer: React.FC<DataGridFooterProps> = ({
69
69
  },
70
70
  [onPageChange, onRowsPerPageChange]
71
71
  );
72
-
73
- const quantityRowsRendered =
74
- rowsPerPage > rowsCount ? rowsCount : rowsPerPage;
72
+ const currentInitItem = page * rowsPerPage + 1;
73
+ const currentFinalItem =
74
+ (page + 1) * rowsPerPage > rowsCount ? rowsCount : (page + 1) * rowsPerPage;
75
75
 
76
76
  return (
77
77
  <TFoot>
@@ -108,7 +108,7 @@ const Footer: React.FC<DataGridFooterProps> = ({
108
108
  <TextPagination
109
109
  fontWeight={'bold'}
110
110
  fontColor={'medium'}
111
- >{`Exibindo ${quantityRowsRendered} de ${rowsCount} registros`}</TextPagination>
111
+ >{`Exibindo ${currentInitItem} a ${currentFinalItem} de ${rowsCount} registros`}</TextPagination>
112
112
  <FooterContainerEnd>
113
113
  <NavigationButton
114
114
  onPress={() => onPageChange?.(page - 1)}
@@ -1 +1,3 @@
1
+ export { useBreakpoints } from './useBreakpoints';
1
2
  export { useClickAwayListener } from './useClickAwayListener';
3
+ export { useWindowSize } from './useWindowSize';
@@ -0,0 +1,18 @@
1
+ import { useTheme } from '@tecsinapse/react-core';
2
+ import { useWindowSize } from './useWindowSize';
3
+
4
+ export type UseBreakpointsReturn = {
5
+ sm: boolean;
6
+ md: boolean;
7
+ lg: boolean;
8
+ };
9
+
10
+ export const useBreakpoints = (): UseBreakpointsReturn => {
11
+ const { width } = useWindowSize();
12
+ const { breakpoints } = useTheme();
13
+ return {
14
+ sm: Number(width) >= 0 && Number(width) <= breakpoints.sm,
15
+ md: Number(width) > breakpoints.sm && Number(width) <= breakpoints.md,
16
+ lg: Number(width) > breakpoints.md,
17
+ };
18
+ };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ type WindowSize = {
4
+ width: number | undefined;
5
+ height: number | undefined;
6
+ };
7
+
8
+ export const useWindowSize = (): WindowSize => {
9
+ const [windowSize, setWindowSize] = React.useState<WindowSize>({
10
+ width: undefined,
11
+ height: undefined,
12
+ });
13
+ React.useEffect(() => {
14
+ const handleResize = () => {
15
+ setWindowSize({
16
+ width: window.innerWidth,
17
+ height: window.innerHeight,
18
+ });
19
+ };
20
+ window.addEventListener('resize', handleResize);
21
+ handleResize();
22
+ return () => window.removeEventListener('resize', handleResize);
23
+ }, []);
24
+ return windowSize;
25
+ };
package/src/index.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export * from '@tecsinapse/react-core';
2
+ export { Accordion, AccordionProps } from './components/atoms/Accordion';
2
3
  export {
3
- default as Badge,
4
4
  BadgeWebProps,
5
+ default as Badge,
5
6
  } from './components/atoms/Badge/Badge';
6
7
  export {
7
8
  Button,
@@ -9,44 +10,52 @@ export {
9
10
  WebButtonProps,
10
11
  } from './components/atoms/Button';
11
12
  export { Input, InputWebProps } from './components/atoms/Input';
13
+ export { InputMask, InputMaskWebProps } from './components/atoms/InputMask';
14
+ export { Modal, ModalProps } from './components/atoms/Modal';
15
+ export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';
12
16
  export { Tag, TagProps } from './components/atoms/Tag';
17
+ export { ITooltip, Tooltip } from './components/atoms/Tooltip';
18
+ export {
19
+ Breadcrumbs,
20
+ BreadcrumbsProps,
21
+ BreadcrumbType,
22
+ } from './components/molecules/Breadcrumbs';
23
+ export {
24
+ DatePicker,
25
+ WebDatePickerProps,
26
+ } from './components/molecules/DatePicker';
27
+ export {
28
+ DateTimePicker,
29
+ WebDateTimePickerProps,
30
+ } from './components/molecules/DateTimePicker';
31
+ export { Drawer, DrawerProps } from './components/molecules/Drawer';
32
+ export {
33
+ Grid,
34
+ GridItem,
35
+ IGridWeb,
36
+ IGridItemWeb,
37
+ } from './components/molecules/Grid';
13
38
  export {
14
39
  InputPassword,
15
40
  InputPasswordWebProps,
16
41
  } from './components/molecules/InputPassword';
17
- export { InputMask, InputMaskWebProps } from './components/atoms/InputMask';
42
+ export {
43
+ LabeledSwitch,
44
+ LabeledSwitchWebProps,
45
+ } from './components/molecules/LabeledSwitch';
18
46
  export {
19
47
  Menubar,
20
- MenubarProps,
21
- MenubarOptionsType,
22
48
  MenubarItemsOptions,
23
49
  MenubarMostUsedType,
50
+ MenubarOptionsType,
51
+ MenubarProps,
24
52
  } from './components/molecules/Menubar';
25
- export { Drawer, DrawerProps } from './components/molecules/Drawer';
26
53
  export { Select, SelectProps } from './components/molecules/Select';
27
54
  export { Snackbar, SnackbarWebProps } from './components/molecules/Snackbar';
28
- export {
29
- Breadcrumbs,
30
- BreadcrumbsProps,
31
- BreadcrumbType,
32
- } from './components/molecules/Breadcrumbs';
33
- export { Skeleton, SkeletonProps } from './components/atoms/Skeleton';
34
- export { Accordion, AccordionProps } from './components/atoms/Accordion';
55
+ export { TextArea, TextAreaProps } from './components/molecules/TextArea';
35
56
  export {
36
57
  DataGrid,
37
58
  DataGridProps,
38
59
  HeadersType,
39
60
  } from './components/organisms/DataGrid';
40
- export { Modal, ModalProps } from './components/atoms/Modal';
41
- export { TextArea, TextAreaProps } from './components/molecules/TextArea';
42
- export { Tooltip, ITooltip } from './components/atoms/Tooltip';
43
61
  export * from './hooks';
44
- export {
45
- DatePicker,
46
- WebDatePickerProps,
47
- } from './components/molecules/DatePicker';
48
- export {
49
- DateTimePicker,
50
- WebDateTimePickerProps,
51
- } from './components/molecules/DateTimePicker';
52
- export { Grid, GridItem, IGrid, IGridItem } from './components/molecules/Grid';