@granto-umbrella/umbrella-components 2.0.0 → 2.0.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granto-umbrella/umbrella-components",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Umbrella Components for React",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,10 +1,8 @@
1
- import { Radius } from "../../../types/radius.types";
2
-
3
1
  export interface ButtonProps
4
2
  extends React.ButtonHTMLAttributes<HTMLButtonElement> {
5
3
  size?: "sm" | "md" | "lg";
6
4
  variant?: "primary" | "outline" | "danger" | "ghost" | "alert";
7
- radius?: Radius;
5
+ radius?: string;
8
6
  isLoading?: boolean;
9
7
  leftIcon?: string;
10
8
  rightIcon?: string;
@@ -16,38 +16,35 @@ export const CheckboxWrapper = styled.label`
16
16
  user-select: none;
17
17
  `;
18
18
 
19
- export const StyledCheckbox = styled.input.attrs({ type: "checkbox" })`
20
- width: ${semanticSizes.global.padding.xl};
21
- height: ${semanticSizes.global.padding.xl};
19
+ export const StyledCheckbox = styled.input`
20
+ width: ${semanticSizes.global.padding.lg};
21
+ height: ${semanticSizes.global.padding.lg};
22
22
  border: 2px solid ${semanticColors.neutral[400]};
23
23
  border-radius: ${semanticRadius.global.radius.sm};
24
24
  appearance: none;
25
- display: flex;
26
- align-items: center;
27
- justify-content: center;
28
- transition: all 0.2s ease-in-out;
29
25
  cursor: pointer;
30
26
  position: relative;
27
+ transition: all 0.2s ease-in-out;
31
28
 
32
29
  &:checked {
33
30
  background: ${semanticColors.branding.surface.enabled};
34
31
  border-color: ${semanticColors.branding.surface.enabled};
35
32
  }
36
-
37
- &:disabled {
38
- background: ${semanticColors.neutral[200]};
39
- border-color: ${semanticColors.neutral[300]};
40
- cursor: not-allowed;
41
- }
42
33
  `;
43
34
 
44
- export const CheckboxIconWrapper = styled.span`
45
- position: absolute;
35
+ export const CheckboxIconWrapper = styled.div<{ checked?: boolean }>`
46
36
  display: flex;
47
37
  align-items: center;
48
38
  justify-content: center;
39
+ position: absolute;
40
+ width: ${semanticSizes.global.padding.lg};
41
+ height: ${semanticSizes.global.padding.lg};
42
+ left: 0;
43
+ top: 50%;
44
+ transform: translateY(-50%);
49
45
  pointer-events: none;
50
- color: ${semanticColors.base.background};
46
+ color: ${({ checked }) =>
47
+ checked ? semanticColors.base.background : "transparent"};
51
48
  `;
52
49
 
53
50
  export const CheckboxLabel = styled.span`
@@ -55,18 +52,21 @@ export const CheckboxLabel = styled.span`
55
52
  color: ${semanticColors.base.text};
56
53
  `;
57
54
 
58
- export const CheckboxGroup = styled.div`
55
+ export const CheckboxGroupWrapper = styled.div`
59
56
  display: flex;
60
57
  flex-direction: column;
61
58
  gap: ${semanticSizes.global.gap.sm};
62
59
  `;
63
60
 
64
- export const CheckboxGroupHorizontal = styled(CheckboxGroup)`
61
+ export const CheckboxGroupHorizontal = styled(CheckboxGroupWrapper)`
65
62
  flex-direction: row;
66
63
  flex-wrap: wrap;
67
64
  `;
68
65
 
69
66
  export const SelectAllWrapper = styled.div`
67
+ display: flex;
68
+ flex-direction: column;
69
+ gap: ${semanticSizes.global.gap.sm};
70
70
  font-weight: bold;
71
71
  font-size: ${typographyTokens.fontSizes.labelS};
72
72
  `;
@@ -1,97 +1,35 @@
1
- import React, { useCallback } from "react";
1
+ import React from "react";
2
2
  import { Check } from "@phosphor-icons/react";
3
3
  import {
4
4
  CheckboxWrapper,
5
5
  StyledCheckbox,
6
6
  CheckboxLabel,
7
- CheckboxGroupHorizontal,
8
- SelectAllWrapper,
9
7
  CheckboxIconWrapper,
10
8
  } from "./Checkbox.styles";
11
- import { CheckboxGroupProps, CheckboxProps } from "./Checkbox.types";
9
+ import { CheckboxProps } from "./Checkbox.types";
12
10
 
13
11
  export const Checkbox: React.FC<CheckboxProps> = ({
14
12
  label,
15
13
  checked,
14
+ onChange,
15
+ disabled = false,
16
16
  ...props
17
17
  }) => {
18
18
  return (
19
- <CheckboxWrapper>
20
- <StyledCheckbox checked={checked} {...props} />
19
+ <CheckboxWrapper disabled={disabled}>
20
+ <StyledCheckbox
21
+ type="checkbox"
22
+ checked={checked}
23
+ onChange={onChange}
24
+ disabled={disabled}
25
+ {...props}
26
+ />
21
27
  {checked && (
22
28
  <CheckboxIconWrapper>
23
- <Check size={14} weight="bold" />
29
+ <Check size={8} weight="bold" />
24
30
  </CheckboxIconWrapper>
25
31
  )}
26
32
  {label && <CheckboxLabel>{label}</CheckboxLabel>}
27
33
  </CheckboxWrapper>
28
34
  );
29
35
  };
30
-
31
- export const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
32
- options = [],
33
- selected = [],
34
- setSelected,
35
- direction = "vertical",
36
- }) => {
37
- console.log("1", options);
38
- const handleChange = useCallback(
39
- (value: string) => {
40
- setSelected((prev) =>
41
- prev.includes(value)
42
- ? prev.filter((v) => v !== value)
43
- : [...prev, value]
44
- );
45
- },
46
- [setSelected]
47
- );
48
-
49
- return (
50
- <CheckboxWrapper
51
- as={direction === "horizontal" ? CheckboxGroupHorizontal : CheckboxGroup}
52
- >
53
- {options.length > 0 ? (
54
- options.map((option) => (
55
- <Checkbox
56
- key={option.value}
57
- label={option.label}
58
- checked={selected.includes(option.value)}
59
- onChange={() => handleChange(option.value)}
60
- />
61
- ))
62
- ) : (
63
- <span>Nenhuma opção disponível</span>
64
- )}
65
- </CheckboxWrapper>
66
- );
67
- };
68
-
69
- export const CheckboxSelectAll: React.FC<CheckboxGroupProps> = ({
70
- options = [],
71
- selected = [],
72
- setSelected,
73
- }) => {
74
- console.log("2", options);
75
- const allSelected = options.length > 0 && selected.length === options.length;
76
- const isIndeterminate = selected.length > 0 && !allSelected;
77
-
78
- const handleSelectAll = useCallback(() => {
79
- setSelected(allSelected ? [] : options.map((option) => option.value));
80
- }, [allSelected, options, setSelected]);
81
-
82
- return (
83
- <SelectAllWrapper>
84
- <Checkbox
85
- label="Selecionar todos"
86
- checked={allSelected}
87
- indeterminate={isIndeterminate}
88
- onChange={handleSelectAll}
89
- />
90
- <CheckboxGroup
91
- options={options}
92
- selected={selected}
93
- setSelected={setSelected}
94
- />
95
- </SelectAllWrapper>
96
- );
97
- };
@@ -1,12 +1,14 @@
1
1
  export interface CheckboxProps
2
2
  extends React.InputHTMLAttributes<HTMLInputElement> {
3
3
  label?: string;
4
- indeterminate?: boolean;
4
+ checked?: boolean;
5
+ onChange?: () => void;
6
+ disabled?: boolean;
5
7
  }
6
8
 
7
9
  export interface CheckboxGroupProps {
8
10
  options: { label: string; value: string }[];
9
11
  selected: string[];
10
- setSelected: (selected: string[] | ((prev: string[]) => string[])) => void;
12
+ setSelected: (values: string[]) => void;
11
13
  direction?: "vertical" | "horizontal";
12
14
  }
@@ -0,0 +1,31 @@
1
+ import React from "react";
2
+ import { Checkbox } from "./Checkbox";
3
+ import { CheckboxGroupProps } from "./Checkbox.types";
4
+ import { CheckboxGroupWrapper } from "./Checkbox.styles";
5
+
6
+ export const CheckboxGroup: React.FC<CheckboxGroupProps> = ({
7
+ options,
8
+ selected,
9
+ setSelected,
10
+ direction = "vertical",
11
+ }) => {
12
+ const handleChange = (value: string) => {
13
+ const newSelected = selected.includes(value)
14
+ ? selected.filter((v: string) => v !== value)
15
+ : [...selected, value];
16
+ setSelected(newSelected);
17
+ };
18
+
19
+ return (
20
+ <CheckboxGroupWrapper direction={direction}>
21
+ {options.map((option) => (
22
+ <Checkbox
23
+ key={option.value}
24
+ label={option.label}
25
+ checked={selected.includes(option.value)}
26
+ onChange={() => handleChange(option.value)}
27
+ />
28
+ ))}
29
+ </CheckboxGroupWrapper>
30
+ );
31
+ };
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { Checkbox } from "./Checkbox";
3
+ import { CheckboxGroup } from "./CheckboxGroup";
4
+ import { CheckboxGroupProps } from "./Checkbox.types";
5
+ import { SelectAllWrapper } from "./Checkbox.styles";
6
+
7
+ export const CheckboxSelectAll: React.FC<CheckboxGroupProps> = ({
8
+ options,
9
+ selected,
10
+ setSelected,
11
+ }) => {
12
+ const allSelected = selected.length === options.length;
13
+
14
+ const handleSelectAll = () => {
15
+ setSelected(allSelected ? [] : options.map((option) => option.value));
16
+ };
17
+
18
+ return (
19
+ <SelectAllWrapper>
20
+ <Checkbox
21
+ label="Selecionar todos"
22
+ checked={allSelected}
23
+ onChange={handleSelectAll}
24
+ />
25
+ <CheckboxGroup
26
+ options={options}
27
+ selected={selected}
28
+ setSelected={setSelected}
29
+ />
30
+ </SelectAllWrapper>
31
+ );
32
+ };
package/src/index.ts CHANGED
@@ -4,9 +4,32 @@ import Button from "./components/atoms/Button";
4
4
  import Icon from "./components/atoms/Icon";
5
5
  import Input from "./components/atoms/Input";
6
6
  import Select from "./components/atoms/Select";
7
+ import AlertDialog from "./components/organisms/AlertDialog/AlertDialog";
8
+ import Badge from "./components/atoms/Badge/Badge";
9
+ import Breadcrumb from "./components/atoms/Breadcrumb/Breadcrumb";
10
+ import RadioButton from "./components/atoms/RadioButton/RadioButton";
11
+ import { Checkbox } from "./components/atoms/Checkbox/Checkbox";
12
+ import Switch from "./components/atoms/Switch/Switch";
13
+ import Text from "./components/atoms/Text";
14
+ import Textarea from "./components/atoms/Textarea/Textarea";
15
+ import ButtonGroup from "./components/molecules/ButtonGroup";
7
16
 
8
17
  // Export all components
9
- export { Button, Icon, Input, Select };
18
+ export {
19
+ Button,
20
+ Icon,
21
+ Input,
22
+ Select,
23
+ AlertDialog,
24
+ Badge,
25
+ Breadcrumb,
26
+ RadioButton,
27
+ Checkbox,
28
+ Switch,
29
+ Text,
30
+ Textarea,
31
+ ButtonGroup,
32
+ };
10
33
 
11
34
  // Export all tokens from a new file
12
35
  export { primitiveColors, semanticColors } from "./styles/tokens/colors";