@granto-umbrella/umbrella-components 2.3.10 → 2.3.12
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/README.md +5 -141
- package/package.json +2 -2
- package/src/components/atoms/DatePickerInput/DatePicker.styles.ts +7 -6
- package/src/components/atoms/DatePickerInput/DatePickerInput.tsx +4 -5
- package/src/components/molecules/RadioBoxGroup/RadioBoxGroup.styles.ts +7 -40
- package/src/components/molecules/RadioBoxGroup/RadioBoxGroup.tsx +38 -27
- package/src/components/organisms/CalendarPopover/CalendarPopover.tsx +5 -2
- package/src/index.ts +1 -5
package/README.md
CHANGED
|
@@ -1,150 +1,19 @@
|
|
|
1
1
|
# Umbrella - Components - Design System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Usando no Projeto React
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
granto-umbrella-components/
|
|
7
|
-
├── cli/
|
|
8
|
-
│ ├── index.js
|
|
9
|
-
│ ├── templates/
|
|
10
|
-
│ │ ├── Button/
|
|
11
|
-
│ │ │ ├── Button.tsx
|
|
12
|
-
│ │ │ ├── styles.ts
|
|
13
|
-
│ │ │ └── index.ts
|
|
14
|
-
├── src/
|
|
15
|
-
│ ├── components/
|
|
16
|
-
│ ├── App.tsx
|
|
17
|
-
│ ├── main.tsx
|
|
18
|
-
├── package.json
|
|
19
|
-
├── vite.config.ts
|
|
20
|
-
├── tsconfig.json
|
|
21
|
-
├── README.md
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Configurar o CLI
|
|
25
|
-
|
|
26
|
-
Arquivo cli/index.js
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
#!/usr/bin/env node
|
|
30
|
-
|
|
31
|
-
const fs = require("fs");
|
|
32
|
-
const path = require("path");
|
|
33
|
-
|
|
34
|
-
const components = ["button"];
|
|
35
|
-
|
|
36
|
-
const args = process.argv.slice(2);
|
|
37
|
-
const command = args[0]; // Ex: 'add'
|
|
38
|
-
const component = args[1]; // Ex: 'button'
|
|
39
|
-
|
|
40
|
-
function copyTemplate(templatePath, targetPath) {
|
|
41
|
-
fs.mkdirSync(targetPath, { recursive: true });
|
|
42
|
-
|
|
43
|
-
fs.readdirSync(templatePath).forEach((file) => {
|
|
44
|
-
const srcFile = path.join(templatePath, file);
|
|
45
|
-
const destFile = path.join(targetPath, file);
|
|
46
|
-
|
|
47
|
-
fs.copyFileSync(srcFile, destFile);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (command === "add" && components.includes(component)) {
|
|
52
|
-
const templatePath = path.join(__dirname, "../templates", component);
|
|
53
|
-
const targetPath = path.join(process.cwd(), "src/components", component);
|
|
54
|
-
|
|
55
|
-
if (fs.existsSync(targetPath)) {
|
|
56
|
-
console.log(`⚠️ O componente "${component}" já existe.`);
|
|
57
|
-
} else {
|
|
58
|
-
copyTemplate(templatePath, targetPath);
|
|
59
|
-
console.log(`✅ Componente "${component}" adicionado com sucesso!`);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
console.log("❌ Comando inválido.");
|
|
63
|
-
console.log('Exemplo: npx meu-cli add button');
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Criando Template do Componente
|
|
68
|
-
|
|
69
|
-
Template: templates/Button/Button.tsx
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
import React from "react";
|
|
73
|
-
import styled from "styled-components";
|
|
74
|
-
|
|
75
|
-
interface ButtonProps {
|
|
76
|
-
children: React.ReactNode;
|
|
77
|
-
onClick?: () => void;
|
|
78
|
-
variant?: "primary" | "secondary";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const StyledButton = styled.button<ButtonProps>`
|
|
82
|
-
padding: 10px 20px;
|
|
83
|
-
border: none;
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
border-radius: 4px;
|
|
86
|
-
|
|
87
|
-
background-color: ${(props) =>
|
|
88
|
-
props.variant === "primary" ? "#007BFF" : "#6C757D"};
|
|
89
|
-
color: white;
|
|
90
|
-
|
|
91
|
-
&:hover {
|
|
92
|
-
opacity: 0.9;
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
95
|
-
|
|
96
|
-
const Button: React.FC<ButtonProps> = ({ children, onClick, variant = "primary" }) => {
|
|
97
|
-
return (
|
|
98
|
-
<StyledButton onClick={onClick} variant={variant}>
|
|
99
|
-
{children}
|
|
100
|
-
</StyledButton>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default Button;
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Template: templates/Button/styles.ts
|
|
108
|
-
|
|
109
|
-
```css
|
|
110
|
-
import styled from "styled-components";
|
|
111
|
-
|
|
112
|
-
export const StyledButton = styled.button`
|
|
113
|
-
padding: 10px 20px;
|
|
114
|
-
border: none;
|
|
115
|
-
cursor: pointer;
|
|
116
|
-
border-radius: 4px;
|
|
117
|
-
background-color: #007bff;
|
|
118
|
-
color: white;
|
|
119
|
-
|
|
120
|
-
&:hover {
|
|
121
|
-
opacity: 0.9;
|
|
122
|
-
}
|
|
123
|
-
`;
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
# Usando o CLI no Projeto React com Vite
|
|
127
|
-
|
|
128
|
-
## Instalar o CLI
|
|
5
|
+
## Instalar
|
|
129
6
|
|
|
130
7
|
```js
|
|
131
|
-
npm install
|
|
8
|
+
npm install @granto-umbrella/umbrella-components
|
|
132
9
|
```
|
|
133
10
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
npx granto-umbrella-components add button
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Este comando copia o template do Button para o diretório do projeto em src/components/button/.
|
|
141
|
-
|
|
142
|
-
# Uso no Projeto React com Vite
|
|
11
|
+
# Uso no Projeto React
|
|
143
12
|
|
|
144
13
|
## Importar o Componente
|
|
145
14
|
|
|
146
15
|
```js
|
|
147
|
-
import { Button } from "
|
|
16
|
+
import { Button } from "@granto-umbrella/umbrella-components";
|
|
148
17
|
|
|
149
18
|
function App() {
|
|
150
19
|
return (
|
|
@@ -155,9 +24,4 @@ function App() {
|
|
|
155
24
|
}
|
|
156
25
|
|
|
157
26
|
export default App;
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Rodar o Projeto
|
|
161
|
-
```js
|
|
162
|
-
npm run dev
|
|
163
27
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granto-umbrella/umbrella-components",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.12",
|
|
4
4
|
"description": "Umbrella Components for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@phosphor-icons/react": "^2.1.7",
|
|
34
34
|
"@radix-ui/react-dialog": "^1.1.7",
|
|
35
35
|
"@radix-ui/react-label": "^2.1.3",
|
|
36
|
-
"@radix-ui/react-popover": "^1.1.
|
|
36
|
+
"@radix-ui/react-popover": "^1.1.11",
|
|
37
37
|
"@radix-ui/react-radio-group": "^1.2.4",
|
|
38
38
|
"date-fns": "^4.1.0",
|
|
39
39
|
"lucide-react": "^0.488.0",
|
|
@@ -17,7 +17,9 @@ registerLocale("pt-BR", ptBR);
|
|
|
17
17
|
|
|
18
18
|
// global overrides for the popup calendar
|
|
19
19
|
export const DatePickerGlobalStyles = createGlobalStyle`
|
|
20
|
-
|
|
20
|
+
.react-datepicker-wrapper {
|
|
21
|
+
display: flex !important;
|
|
22
|
+
}
|
|
21
23
|
`;
|
|
22
24
|
|
|
23
25
|
// wrapper around input + icon
|
|
@@ -30,10 +32,11 @@ export const InputWrapper = styled.div`
|
|
|
30
32
|
export const IconWrapper = styled.div`
|
|
31
33
|
position: absolute;
|
|
32
34
|
top: 50%;
|
|
33
|
-
left:
|
|
35
|
+
left: 16px;
|
|
34
36
|
transform: translateY(-50%);
|
|
35
37
|
pointer-events: none;
|
|
36
|
-
color: ${semanticColors.
|
|
38
|
+
color: ${semanticColors.global.text.onSurface.enabled};
|
|
39
|
+
z-index: 1;
|
|
37
40
|
`;
|
|
38
41
|
|
|
39
42
|
// styled input itself; we add extra left‐padding for the icon
|
|
@@ -42,9 +45,7 @@ export const StyledDatePicker = styled(
|
|
|
42
45
|
)`
|
|
43
46
|
width: 100%;
|
|
44
47
|
padding: ${semanticSizes.global.padding.md} ${semanticSizes.global.padding.lg};
|
|
45
|
-
padding-left:
|
|
46
|
-
${semanticSizes.global.padding.lg} ${primitiveSizes.size.x4}
|
|
47
|
-
);
|
|
48
|
+
padding-left: 42px;
|
|
48
49
|
border: 1px solid ${semanticColors.neutral[300]};
|
|
49
50
|
border-radius: ${semanticRadius.global.radius.md};
|
|
50
51
|
font-size: ${typographyTokens.fontSizes.labelM};
|
|
@@ -14,7 +14,7 @@ import "react-datepicker/dist/react-datepicker.css";
|
|
|
14
14
|
|
|
15
15
|
interface DatePickerInputProps {
|
|
16
16
|
mode?: "single" | "range";
|
|
17
|
-
selected: Date | [Date, Date];
|
|
17
|
+
selected: Date | [Date, Date] | null;
|
|
18
18
|
onChange: (date: Date | [Date, Date]) => void;
|
|
19
19
|
minDate?: Date;
|
|
20
20
|
maxDate?: Date;
|
|
@@ -41,7 +41,6 @@ export const DatePickerInput: React.FC<DatePickerInputProps> = ({
|
|
|
41
41
|
<DatePickerGlobalStyles />
|
|
42
42
|
|
|
43
43
|
<InputWrapper>
|
|
44
|
-
{/* the calendar icon */}
|
|
45
44
|
<IconWrapper>
|
|
46
45
|
<CalendarIcon size={16} />
|
|
47
46
|
</IconWrapper>
|
|
@@ -50,9 +49,9 @@ export const DatePickerInput: React.FC<DatePickerInputProps> = ({
|
|
|
50
49
|
<StyledDatePicker
|
|
51
50
|
locale="pt-BR"
|
|
52
51
|
selectsRange
|
|
53
|
-
startDate={(selected as [Date, Date])[0] || undefined}
|
|
54
|
-
endDate={(selected as [Date, Date])[1] || undefined}
|
|
55
|
-
selected={(selected as [Date, Date])[0] || undefined}
|
|
52
|
+
startDate={(selected as [Date, Date])[0] || undefined || null}
|
|
53
|
+
endDate={(selected as [Date, Date])[1] || undefined || null}
|
|
54
|
+
selected={(selected as [Date, Date])[0] || undefined || null}
|
|
56
55
|
onChange={(d) => onChange(d as [Date, Date])}
|
|
57
56
|
minDate={minDate}
|
|
58
57
|
maxDate={maxDate}
|
|
@@ -1,44 +1,11 @@
|
|
|
1
|
-
import { semanticColors, semanticShadows } from "../../../styles/tokens";
|
|
2
|
-
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
3
1
|
import styled from "styled-components";
|
|
4
|
-
import {
|
|
2
|
+
import { semanticSizes } from "../../../styles/tokens";
|
|
5
3
|
|
|
6
|
-
export const
|
|
4
|
+
export const Container = styled.div<{
|
|
5
|
+
orientation?: "horizontal" | "vertical";
|
|
6
|
+
}>`
|
|
7
7
|
display: flex;
|
|
8
|
-
flex-direction:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const StyledRadioGroupItem = styled(RadioGroupPrimitive.Item)`
|
|
12
|
-
display: none;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
outline: none;
|
|
16
|
-
|
|
17
|
-
&:focus-visible {
|
|
18
|
-
outline: none;
|
|
19
|
-
box-shadow: 0 0 0 2px ${semanticShadows.shadow.none};
|
|
20
|
-
outline-offset: 2px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
&:disabled {
|
|
24
|
-
cursor: not-allowed;
|
|
25
|
-
opacity: 0.5;
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
export const StyledIndicator = styled(RadioGroupPrimitive.Indicator)`
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
width: 1rem;
|
|
34
|
-
height: 1rem;
|
|
35
|
-
border-radius: 9999px;
|
|
36
|
-
color: ${semanticColors.branding.surface.enabled};
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
export const StyledCircle = styled(Circle)`
|
|
40
|
-
width: 0.625rem;
|
|
41
|
-
height: 0.625rem;
|
|
42
|
-
fill: currentColor;
|
|
43
|
-
color: currentColor;
|
|
8
|
+
flex-direction: ${({ orientation = "horizontal" }) =>
|
|
9
|
+
orientation === "vertical" ? "column" : "row"};
|
|
10
|
+
gap: ${semanticSizes.global.padding.sm};
|
|
44
11
|
`;
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
StyledRadioGroup,
|
|
5
|
-
StyledRadioGroupItem,
|
|
6
|
-
StyledIndicator,
|
|
7
|
-
StyledCircle,
|
|
8
|
-
} from "./RadioBoxGroup.styles";
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Container } from "./RadioBoxGroup.styles";
|
|
3
|
+
import RadioButton from "../../../components/atoms/RadioButton/RadioButton";
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
RadioGroup.displayName = "RadioGroup";
|
|
5
|
+
export interface Option {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
export interface RadioBoxGroupProps {
|
|
12
|
+
name: string;
|
|
13
|
+
options: Option[];
|
|
14
|
+
value: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
orientation?: "horizontal" | "vertical";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const RadioBoxGroup: React.FC<RadioBoxGroupProps> = ({
|
|
20
|
+
name,
|
|
21
|
+
options,
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
orientation = "horizontal",
|
|
25
|
+
}) => {
|
|
22
26
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
<Container orientation={orientation}>
|
|
28
|
+
{options.map((opt) => (
|
|
29
|
+
<RadioButton
|
|
30
|
+
key={opt.value}
|
|
31
|
+
name={name}
|
|
32
|
+
value={opt.value}
|
|
33
|
+
label={opt.label}
|
|
34
|
+
checked={opt.value === value}
|
|
35
|
+
disabled={opt.disabled}
|
|
36
|
+
onChange={(e) => onChange(e.currentTarget.value)}
|
|
37
|
+
/>
|
|
38
|
+
))}
|
|
39
|
+
</Container>
|
|
28
40
|
);
|
|
29
|
-
}
|
|
30
|
-
RadioGroupItem.displayName = "RadioGroupItem";
|
|
41
|
+
};
|
|
31
42
|
|
|
32
|
-
export
|
|
43
|
+
export default RadioBoxGroup;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { format } from "date-fns";
|
|
3
|
-
import {
|
|
4
|
+
import { CalendarIcon } from "lucide-react";
|
|
4
5
|
|
|
5
6
|
import { cn } from "../../../lib/utils";
|
|
6
7
|
import { FormControl } from "../Form/Form";
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
PopoverTrigger,
|
|
11
12
|
} from "../../molecules/Popover/Popover";
|
|
12
13
|
import Button from "../../atoms/Button/Button";
|
|
14
|
+
import { Calendar } from "../../../components/molecules/Calendar/Calendar";
|
|
13
15
|
|
|
14
16
|
export type DatePickerFieldProps = {
|
|
15
17
|
formField: {
|
|
@@ -43,8 +45,9 @@ const DatePickerField: React.FC<DatePickerFieldProps> = ({ formField }) => {
|
|
|
43
45
|
<Calendar
|
|
44
46
|
mode="single"
|
|
45
47
|
selected={formField.value}
|
|
48
|
+
required
|
|
46
49
|
onSelect={formField.onChange}
|
|
47
|
-
disabled={(date) =>
|
|
50
|
+
disabled={(date: any) =>
|
|
48
51
|
date > new Date() || date < new Date("1900-01-01")
|
|
49
52
|
}
|
|
50
53
|
initialFocus
|
package/src/index.ts
CHANGED
|
@@ -28,10 +28,7 @@ import {
|
|
|
28
28
|
PopoverContent,
|
|
29
29
|
PopoverTrigger,
|
|
30
30
|
} from "./components/molecules/Popover/Popover";
|
|
31
|
-
import
|
|
32
|
-
RadioGroup,
|
|
33
|
-
RadioGroupItem,
|
|
34
|
-
} from "./components/molecules/RadioBoxGroup/RadioBoxGroup";
|
|
31
|
+
import RadioGroup from "./components/molecules/RadioBoxGroup/RadioBoxGroup";
|
|
35
32
|
import AlertDialog from "./components/organisms/AlertDialog/AlertDialog";
|
|
36
33
|
import {
|
|
37
34
|
DialogFooter,
|
|
@@ -88,7 +85,6 @@ export {
|
|
|
88
85
|
PopoverTrigger,
|
|
89
86
|
RadioButton,
|
|
90
87
|
RadioGroup,
|
|
91
|
-
RadioGroupItem,
|
|
92
88
|
Select,
|
|
93
89
|
StyledDialogClose,
|
|
94
90
|
StyledDialogOverlay,
|