@granto-umbrella/umbrella-components 2.3.2 → 2.3.4

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.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Umbrella Components for React",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -35,8 +35,10 @@
35
35
  "@radix-ui/react-label": "^2.1.3",
36
36
  "@radix-ui/react-popover": "^1.1.7",
37
37
  "@radix-ui/react-radio-group": "^1.2.4",
38
+ "date-fns": "^4.1.0",
38
39
  "lucide-react": "^0.488.0",
39
40
  "react": "^18.3.1",
41
+ "react-datepicker": "^8.3.0",
40
42
  "react-day-picker": "^9.6.7",
41
43
  "react-dom": "^18.3.1",
42
44
  "react-hook-form": "^7.54.2",
@@ -0,0 +1,96 @@
1
+ // DatePicker.styles.ts
2
+ import { createGlobalStyle, styled } from "styled-components";
3
+ import ReactDatePicker, {
4
+ DatePickerProps,
5
+ registerLocale,
6
+ } from "react-datepicker";
7
+ import { ptBR } from "date-fns/locale";
8
+ import {
9
+ semanticColors,
10
+ semanticRadius,
11
+ typographyTokens,
12
+ semanticSizes,
13
+ primitiveSizes,
14
+ } from "../../../styles/tokens";
15
+
16
+ // register Portuguese‐Brazil locale
17
+ registerLocale("pt-BR", ptBR);
18
+
19
+ // 1) Global overrides for the popup calendar:
20
+ export const DatePickerGlobalStyles = createGlobalStyle`
21
+ .react-datepicker {
22
+ background: ${semanticColors.base.background};
23
+ border: 1px solid ${semanticColors.neutral[300]};
24
+ border-radius: ${semanticRadius.global.radius.md};
25
+ font-family: inherit;
26
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
27
+ }
28
+
29
+ .react-datepicker__header {
30
+ background: ${semanticColors.neutral[100]};
31
+ border-bottom: none;
32
+ border-top-left-radius: ${semanticRadius.global.radius.md};
33
+ border-top-right-radius: ${semanticRadius.global.radius.md};
34
+ padding: ${semanticSizes.global.padding.sm};
35
+ }
36
+
37
+ .react-datepicker__current-month {
38
+ font-size: ${typographyTokens.fontSizes.bodyM};
39
+ color: ${semanticColors.base.text};
40
+ }
41
+
42
+ .react-datepicker__day-name,
43
+ .react-datepicker__day {
44
+ width: 2rem;
45
+ line-height: 2rem;
46
+ margin: 0.1rem;
47
+ }
48
+
49
+ .react-datepicker__day--selected {
50
+ background-color: ${semanticColors.branding.surface.enabled};
51
+ color: ${semanticColors.base.background};
52
+ border-radius: 50%;
53
+ }
54
+
55
+ .react-datepicker__triangle {
56
+ display: none;
57
+ }
58
+ `;
59
+
60
+ // 2) Styled input only:
61
+ export const StyledDatePicker = styled(
62
+ ReactDatePicker as unknown as React.ComponentType<DatePickerProps>
63
+ )`
64
+ width: 100%;
65
+ padding: ${semanticSizes.global.padding.sm} ${semanticSizes.global.padding.md};
66
+ border: 1px solid ${semanticColors.neutral[300]};
67
+ border-radius: ${semanticRadius.global.radius.md};
68
+ font-size: ${typographyTokens.fontSizes.bodyM};
69
+ color: ${semanticColors.global.text.onSurface.enabled};
70
+
71
+ &:focus {
72
+ outline: none;
73
+ border-color: ${semanticColors.branding.surface.enabled};
74
+ box-shadow: 0 0 0 2px ${semanticColors.branding.surface.enabled}33;
75
+ }
76
+ `;
77
+
78
+ export const Label = styled.label`
79
+ font-size: ${typographyTokens.fontSizes.labelS};
80
+ color: ${semanticColors.global.text.subtitle.enabled};
81
+ font-weight: ${typographyTokens.fontWeights.medium};
82
+ `;
83
+
84
+ export const SupportText = styled.span<{ $error?: boolean }>`
85
+ font-size: ${typographyTokens.fontSizes.captionM};
86
+ color: ${({ $error }) =>
87
+ $error
88
+ ? semanticColors.danger.text.enabled
89
+ : semanticColors.global.text.subtitle.enabled};
90
+ `;
91
+
92
+ export const Container = styled.div`
93
+ display: flex;
94
+ flex-direction: column;
95
+ gap: ${primitiveSizes.size.x1};
96
+ `;
@@ -0,0 +1,70 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React from "react";
3
+ import {
4
+ Container,
5
+ DatePickerGlobalStyles,
6
+ Label,
7
+ StyledDatePicker,
8
+ SupportText,
9
+ } from "./DatePicker.styles";
10
+
11
+ import "react-datepicker/dist/react-datepicker.css";
12
+
13
+ interface DatePickerInputProps {
14
+ mode?: "single" | "range";
15
+ selected: Date | [Date, Date];
16
+ onChange: (date: Date | [Date, Date]) => void;
17
+ minDate?: Date;
18
+ maxDate?: Date;
19
+ placeholder?: string;
20
+ [key: string]: any;
21
+ label?: string;
22
+ supportText?: string;
23
+ error?: boolean;
24
+ }
25
+
26
+ export const DatePickerInput: React.FC<DatePickerInputProps> = ({
27
+ mode = "single",
28
+ selected,
29
+ onChange,
30
+ minDate,
31
+ maxDate,
32
+ placeholder,
33
+ label,
34
+ supportText,
35
+ error,
36
+ ...rest
37
+ }) => (
38
+ <Container>
39
+ {label && <Label>{label}</Label>}
40
+ <DatePickerGlobalStyles />
41
+
42
+ {mode === "range" ? (
43
+ <StyledDatePicker
44
+ locale="pt-BR"
45
+ selectsRange
46
+ startDate={(selected as [Date, Date])[0] || undefined}
47
+ endDate={(selected as [Date, Date])[1] || undefined}
48
+ selected={(selected as [Date, Date])[0] || undefined}
49
+ onChange={(d) => onChange(d as [Date, Date])}
50
+ minDate={minDate}
51
+ maxDate={maxDate}
52
+ placeholderText={placeholder}
53
+ dateFormat="dd/MM/yyyy"
54
+ {...rest}
55
+ />
56
+ ) : (
57
+ <StyledDatePicker
58
+ locale="pt-BR"
59
+ selected={selected as Date}
60
+ onChange={(d) => onChange(d as Date)}
61
+ minDate={minDate}
62
+ maxDate={maxDate}
63
+ placeholderText={placeholder}
64
+ dateFormat="dd/MM/yyyy"
65
+ {...rest}
66
+ />
67
+ )}
68
+ {supportText && <SupportText $error={error}>{supportText}</SupportText>}
69
+ </Container>
70
+ );
package/src/index.ts CHANGED
@@ -53,6 +53,8 @@ import {
53
53
 
54
54
  import { TabToggle } from "./components/molecules/TabToggle/TabToggle";
55
55
 
56
+ import { DatePickerInput } from "./components/atoms/DatePickerInput/DatePickerInput";
57
+
56
58
  // Export all components
57
59
  export {
58
60
  AlertDialog,
@@ -62,6 +64,7 @@ export {
62
64
  ButtonGroup,
63
65
  Calendar,
64
66
  Checkbox,
67
+ DatePickerInput,
65
68
  Dialog,
66
69
  DialogContent,
67
70
  DialogDescription,
@@ -90,10 +93,10 @@ export {
90
93
  StyledDialogClose,
91
94
  StyledDialogOverlay,
92
95
  Switch,
96
+ TabToggle,
93
97
  Text,
94
98
  Textarea,
95
99
  useFormField,
96
- TabToggle,
97
100
  };
98
101
 
99
102
  // Export all tokens from a new file