@granto-umbrella/umbrella-components 2.3.13 → 2.3.15

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.13",
3
+ "version": "2.3.15",
4
4
  "description": "Umbrella Components for React",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -1,3 +1,4 @@
1
+ // DatePicker.styles.ts
1
2
  import { createGlobalStyle, styled } from "styled-components";
2
3
  import ReactDatePicker, {
3
4
  DatePickerProps,
@@ -9,47 +10,62 @@ import {
9
10
  semanticRadius,
10
11
  typographyTokens,
11
12
  semanticSizes,
12
- primitiveSizes,
13
13
  } from "../../../styles/tokens";
14
14
 
15
15
  // register Portuguese‐Brazil locale
16
16
  registerLocale("pt-BR", ptBR);
17
17
 
18
- // global overrides for the popup calendar
18
+ // 1) Global overrides for the popup calendar:
19
19
  export const DatePickerGlobalStyles = createGlobalStyle`
20
- .react-datepicker-wrapper {
21
- display: flex !important;
20
+ .react-datepicker {
21
+ background: ${semanticColors.base.background};
22
+ border: 1px solid ${semanticColors.neutral[300]};
23
+ border-radius: ${semanticRadius.global.radius.md};
24
+ font-family: inherit;
25
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
22
26
  }
23
- `;
24
27
 
25
- // wrapper around input + icon
26
- export const InputWrapper = styled.div`
27
- position: relative;
28
- width: 100%;
29
- `;
28
+ .react-datepicker__header {
29
+ background: ${semanticColors.neutral[100]};
30
+ border-bottom: none;
31
+ border-top-left-radius: ${semanticRadius.global.radius.md};
32
+ border-top-right-radius: ${semanticRadius.global.radius.md};
33
+ padding: ${semanticSizes.global.padding.sm};
34
+ }
30
35
 
31
- // ícone absolutizado à esquerda
32
- export const IconWrapper = styled.div`
33
- position: absolute;
34
- top: 50%;
35
- left: 16px;
36
- transform: translateY(-50%);
37
- pointer-events: none;
38
- color: ${semanticColors.global.text.onSurface.enabled};
39
- z-index: 1;
36
+ .react-datepicker__current-month {
37
+ font-size: ${typographyTokens.fontSizes.bodyM};
38
+ color: ${semanticColors.base.text};
39
+ }
40
+
41
+ .react-datepicker__day-name,
42
+ .react-datepicker__day {
43
+ width: 2rem;
44
+ line-height: 2rem;
45
+ margin: 0.1rem;
46
+ }
47
+
48
+ .react-datepicker__day--selected {
49
+ background-color: ${semanticColors.branding.surface.enabled};
50
+ color: ${semanticColors.base.background};
51
+ border-radius: 50%;
52
+ }
53
+
54
+ .react-datepicker__triangle {
55
+ display: none;
56
+ }
40
57
  `;
41
58
 
42
- // styled input itself; we add extra left‐padding for the icon
59
+ // 2) Styled input only:
43
60
  export const StyledDatePicker = styled(
44
61
  ReactDatePicker as unknown as React.ComponentType<DatePickerProps>
45
62
  )`
46
63
  width: 100%;
47
- padding: ${semanticSizes.global.padding.md} ${semanticSizes.global.padding.lg};
48
- padding-left: 42px;
64
+ padding: ${semanticSizes.global.padding.sm} ${semanticSizes.global.padding.md};
49
65
  border: 1px solid ${semanticColors.neutral[300]};
50
66
  border-radius: ${semanticRadius.global.radius.md};
51
- font-size: ${typographyTokens.fontSizes.labelM};
52
- color: ${semanticColors.global.text.onSurface.enabled};
67
+ font-size: ${typographyTokens.fontSizes.bodyM};
68
+ color: ${semanticColors.base.text};
53
69
 
54
70
  &:focus {
55
71
  outline: none;
@@ -57,23 +73,3 @@ export const StyledDatePicker = styled(
57
73
  box-shadow: 0 0 0 2px ${semanticColors.branding.surface.enabled}33;
58
74
  }
59
75
  `;
60
-
61
- export const Label = styled.label`
62
- font-size: ${typographyTokens.fontSizes.labelS};
63
- color: ${semanticColors.global.text.subtitle.enabled};
64
- font-weight: ${typographyTokens.fontWeights.medium};
65
- `;
66
-
67
- export const SupportText = styled.span<{ $error?: boolean }>`
68
- font-size: ${typographyTokens.fontSizes.captionM};
69
- color: ${({ $error }) =>
70
- $error
71
- ? semanticColors.danger.text.enabled
72
- : semanticColors.global.text.subtitle.enabled};
73
- `;
74
-
75
- export const Container = styled.div`
76
- display: flex;
77
- flex-direction: column;
78
- gap: ${primitiveSizes.size.x1};
79
- `;
@@ -1,27 +1,17 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import React from "react";
2
- import { Calendar as CalendarIcon } from "lucide-react";
3
- import {
4
- Container,
5
- DatePickerGlobalStyles,
6
- Label,
7
- StyledDatePicker,
8
- SupportText,
9
- InputWrapper,
10
- IconWrapper,
11
- } from "./DatePicker.styles";
3
+ import { DatePickerGlobalStyles, StyledDatePicker } from "./DatePicker.styles";
12
4
 
13
5
  import "react-datepicker/dist/react-datepicker.css";
14
6
 
15
- interface DatePickerInputProps {
7
+ export interface DatePickerInputProps {
16
8
  mode?: "single" | "range";
17
- selected: Date | [Date, Date] | null;
9
+ selected: Date | [Date, Date];
18
10
  onChange: (date: Date | [Date, Date]) => void;
19
11
  minDate?: Date;
20
12
  maxDate?: Date;
21
13
  placeholder?: string;
22
- label?: string;
23
- supportText?: string;
24
- error?: boolean;
14
+ [key: string]: any;
25
15
  }
26
16
 
27
17
  export const DatePickerInput: React.FC<DatePickerInputProps> = ({
@@ -31,48 +21,37 @@ export const DatePickerInput: React.FC<DatePickerInputProps> = ({
31
21
  minDate,
32
22
  maxDate,
33
23
  placeholder,
34
- label,
35
- supportText,
36
- error,
37
24
  ...rest
38
25
  }) => (
39
- <Container>
40
- {label && <Label>{label}</Label>}
26
+ <>
27
+ {/* inject our calendar overrides */}
41
28
  <DatePickerGlobalStyles />
42
29
 
43
- <InputWrapper>
44
- <IconWrapper>
45
- <CalendarIcon size={16} />
46
- </IconWrapper>
47
-
48
- {mode === "range" ? (
49
- <StyledDatePicker
50
- locale="pt-BR"
51
- selectsRange
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}
55
- onChange={(d) => onChange(d as [Date, Date])}
56
- minDate={minDate}
57
- maxDate={maxDate}
58
- placeholderText={placeholder}
59
- dateFormat="dd/MM/yyyy"
60
- {...rest}
61
- />
62
- ) : (
63
- <StyledDatePicker
64
- locale="pt-BR"
65
- selected={selected as Date}
66
- onChange={(d) => onChange(d as Date)}
67
- minDate={minDate}
68
- maxDate={maxDate}
69
- placeholderText={placeholder}
70
- dateFormat="dd/MM/yyyy"
71
- {...rest}
72
- />
73
- )}
74
- </InputWrapper>
75
-
76
- {supportText && <SupportText $error={error}>{supportText}</SupportText>}
77
- </Container>
30
+ {mode === "range" ? (
31
+ <StyledDatePicker
32
+ locale="pt-BR"
33
+ selectsRange
34
+ startDate={(selected as [Date, Date])[0] || undefined}
35
+ endDate={(selected as [Date, Date])[1] || undefined}
36
+ selected={(selected as [Date, Date])[0] || undefined}
37
+ onChange={(d) => onChange(d as [Date, Date])}
38
+ minDate={minDate}
39
+ maxDate={maxDate}
40
+ placeholderText={placeholder}
41
+ dateFormat="dd/MM/yyyy"
42
+ {...rest}
43
+ />
44
+ ) : (
45
+ <StyledDatePicker
46
+ locale="pt-BR"
47
+ selected={selected as Date}
48
+ onChange={(d) => onChange(d as Date)}
49
+ minDate={minDate}
50
+ maxDate={maxDate}
51
+ placeholderText={placeholder}
52
+ dateFormat="dd/MM/yyyy"
53
+ {...rest}
54
+ />
55
+ )}
56
+ </>
78
57
  );
@@ -4,7 +4,7 @@ import RadioButton from "../../../components/atoms/RadioButton/RadioButton";
4
4
 
5
5
  export interface Option {
6
6
  label: string;
7
- value: string;
7
+ value: string | number;
8
8
  disabled?: boolean;
9
9
  }
10
10
 
@@ -29,7 +29,7 @@ const RadioBoxGroup: React.FC<RadioBoxGroupProps> = ({
29
29
  <RadioButton
30
30
  key={opt.value}
31
31
  name={name}
32
- value={opt.value}
32
+ value={`${opt.value}`}
33
33
  label={opt.label}
34
34
  checked={opt.value === value}
35
35
  disabled={opt.disabled}
@@ -16,6 +16,7 @@ const AlertDialog: React.FC<AlertDialogProps> = ({
16
16
  text,
17
17
  isOpen,
18
18
  buttons: { confirm, cancel, onClose, onConfirm },
19
+ testId,
19
20
  }) => {
20
21
  if (!isOpen) return null;
21
22
 
@@ -43,12 +44,20 @@ const AlertDialog: React.FC<AlertDialogProps> = ({
43
44
  </Text>
44
45
  <ButtonContainer>
45
46
  {cancel && (
46
- <Button variant="alert" onClick={onClose}>
47
+ <Button
48
+ testId={`${testId}_cancelar`}
49
+ variant="alert"
50
+ onClick={onClose}
51
+ >
47
52
  {cancel}
48
53
  </Button>
49
54
  )}
50
55
  {confirm && (
51
- <Button variant="danger" onClick={onConfirm}>
56
+ <Button
57
+ testId={`${testId}_confirmar`}
58
+ variant="danger"
59
+ onClick={onConfirm}
60
+ >
52
61
  {confirm}
53
62
  </Button>
54
63
  )}
@@ -10,4 +10,5 @@ export interface AlertDialogProps {
10
10
  title: string;
11
11
  description: string;
12
12
  };
13
+ testId?: string;
13
14
  }
@@ -1,60 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import * as React from "react";
3
- import { format } from "date-fns";
4
- import { CalendarIcon } from "lucide-react";
5
-
6
- import { cn } from "../../../lib/utils";
7
- import { FormControl } from "../Form/Form";
8
- import {
9
- Popover,
10
- PopoverContent,
11
- PopoverTrigger,
12
- } from "../../molecules/Popover/Popover";
13
- import Button from "../../atoms/Button/Button";
14
- import { Calendar } from "../../../components/molecules/Calendar/Calendar";
15
-
16
- export type DatePickerFieldProps = {
17
- formField: {
18
- value: Date | null;
19
- onChange: (date: Date | null) => void;
20
- };
21
- };
22
-
23
- const DatePickerField: React.FC<DatePickerFieldProps> = ({ formField }) => {
24
- return (
25
- <Popover>
26
- <PopoverTrigger asChild>
27
- <FormControl>
28
- <Button
29
- variant="outline"
30
- className={cn(
31
- "w-[240px] pl-3 text-left font-normal",
32
- !formField.value && "text-muted-foreground"
33
- )}
34
- >
35
- {formField.value ? (
36
- format(formField.value, "PPP")
37
- ) : (
38
- <span>CALENDÁRIO</span>
39
- )}
40
- <CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
41
- </Button>
42
- </FormControl>
43
- </PopoverTrigger>
44
- <PopoverContent className="w-auto p-0" align="start">
45
- <Calendar
46
- mode="single"
47
- selected={formField.value}
48
- required
49
- onSelect={formField.onChange}
50
- disabled={(date: any) =>
51
- date > new Date() || date < new Date("1900-01-01")
52
- }
53
- initialFocus
54
- />
55
- </PopoverContent>
56
- </Popover>
57
- );
58
- };
59
-
60
- export default DatePickerField;