@akad/design-system 3.0.0 → 4.0.1
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/css/core.css +1 -1
- package/package.json +1 -1
- package/react/react-lib.js +2641 -2242
- package/react/react-lib.umd.cjs +5 -5
- package/react/src/components/atoms/Card/Card.config.d.ts +27 -4
- package/react/src/components/atoms/Card/Card.d.ts +6 -4
- package/react/src/components/atoms/Card/Card.stories.d.ts +22 -4
- package/react/src/components/atoms/Radio/Radio.d.ts +5 -0
- package/react/src/components/index.d.ts +1 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCard.config.d.ts +70 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCard.d.ts +21 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCard.stories.d.ts +135 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCard.test.d.ts +1 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCardForm.stories.d.ts +36 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCardGroup.config.d.ts +88 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCardGroup.d.ts +34 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCardGroup.stories.d.ts +94 -0
- package/react/src/components/molecules/CheckboxCard/CheckboxCardGroup.test.d.ts +1 -0
- package/react/src/components/molecules/CheckboxCard/index.d.ts +8 -0
- package/scss/core/components/atoms/button.scss +1 -1
- package/scss/core/components/atoms/card.scss +56 -9
- package/scss/core/components/atoms/chip.scss +1 -1
- package/scss/core/components/atoms/input.scss +1 -1
- package/scss/core/components/atoms/loading.scss +4 -4
- package/scss/core/components/atoms/progress.scss +2 -2
- package/scss/core/components/atoms/radio-card.scss +1 -1
- package/scss/core/components/atoms/radio.scss +2 -2
- package/scss/core/components/atoms/segment-control.scss +2 -2
- package/scss/core/components/atoms/select.scss +13 -4
- package/scss/core/components/atoms/textarea.scss +1 -1
- package/scss/core/components/atoms/tooltip.scss +1 -1
- package/scss/core/components/index.scss +1 -0
- package/scss/core/components/molecules/accordion.scss +5 -3
- package/scss/core/components/molecules/active-tags.scss +3 -2
- package/scss/core/components/molecules/carousel.scss +1 -1
- package/scss/core/components/molecules/checkbox-card.scss +473 -0
- package/scss/core/components/molecules/editable-select.scss +2 -2
- package/scss/core/components/molecules/indicator.scss +1 -1
- package/scss/core/components/molecules/modal.scss +2 -2
- package/scss/core/components/molecules/notification.scss +2 -2
- package/scss/core/components/molecules/stepper.scss +1 -1
- package/scss/core/components/molecules/table.scss +11 -6
- package/scss/core/tokens/borders.scss +24 -5
- package/scss/themes/aon/index.scss +4 -1
- package/scss/themes/linker/index.scss +4 -1
|
@@ -48,6 +48,22 @@ export declare enum CardSize {
|
|
|
48
48
|
XXS = "xxs",
|
|
49
49
|
XS = "xs"
|
|
50
50
|
}
|
|
51
|
+
export declare enum CardBorder {
|
|
52
|
+
None = "none",
|
|
53
|
+
Full = "full",
|
|
54
|
+
Side = "side"
|
|
55
|
+
}
|
|
56
|
+
export declare enum CardRadius {
|
|
57
|
+
None = "none",
|
|
58
|
+
XS = "xs",
|
|
59
|
+
SM = "sm",
|
|
60
|
+
MD = "md",
|
|
61
|
+
LG = "lg",
|
|
62
|
+
XL = "xl",
|
|
63
|
+
XXL = "xxl",
|
|
64
|
+
XXXL = "xxxl",
|
|
65
|
+
Pill = "pill"
|
|
66
|
+
}
|
|
51
67
|
export interface CardBackgroundColorProps {
|
|
52
68
|
type: StringConstructor;
|
|
53
69
|
default: CardColor;
|
|
@@ -58,9 +74,10 @@ export interface CardBorderColorProps {
|
|
|
58
74
|
default: CardColor;
|
|
59
75
|
options: CardColor[];
|
|
60
76
|
}
|
|
61
|
-
export interface
|
|
62
|
-
type:
|
|
63
|
-
default:
|
|
77
|
+
export interface CardBorderProps {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
default: CardBorder;
|
|
80
|
+
options: CardBorder[];
|
|
64
81
|
}
|
|
65
82
|
export interface CardIdProps {
|
|
66
83
|
type: StringConstructor;
|
|
@@ -75,16 +92,22 @@ export interface CardSizeProps {
|
|
|
75
92
|
default: CardSize;
|
|
76
93
|
options: CardSize[];
|
|
77
94
|
}
|
|
95
|
+
export interface CardRadiusProps {
|
|
96
|
+
type: StringConstructor;
|
|
97
|
+
default: CardRadius;
|
|
98
|
+
options: CardRadius[];
|
|
99
|
+
}
|
|
78
100
|
export interface CardConfig {
|
|
79
101
|
name: string;
|
|
80
102
|
class: string;
|
|
81
103
|
props: {
|
|
82
104
|
backgroundColor: CardBackgroundColorProps;
|
|
105
|
+
border: CardBorderProps;
|
|
83
106
|
borderColor: CardBorderColorProps;
|
|
84
|
-
sideBorder: CardSideBorderProps;
|
|
85
107
|
id: CardIdProps;
|
|
86
108
|
testId: CardTestIdProps;
|
|
87
109
|
size: CardSizeProps;
|
|
110
|
+
radius: CardRadiusProps;
|
|
88
111
|
};
|
|
89
112
|
}
|
|
90
113
|
declare const cardConfig: CardConfig;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { default as PropTypes } from 'prop-types';
|
|
2
|
-
import { CardColor } from './Card.config';
|
|
2
|
+
import { CardBorder, CardColor } from './Card.config';
|
|
3
3
|
|
|
4
4
|
export interface DsCardProps {
|
|
5
5
|
id?: string;
|
|
@@ -7,18 +7,20 @@ export interface DsCardProps {
|
|
|
7
7
|
children?: string | JSX.Element | JSX.Element[];
|
|
8
8
|
className?: string;
|
|
9
9
|
backgroundColor?: string;
|
|
10
|
+
border?: string;
|
|
10
11
|
borderColor?: string;
|
|
11
|
-
sideBorder?: boolean;
|
|
12
12
|
size?: string;
|
|
13
|
+
radius?: string;
|
|
13
14
|
}
|
|
14
15
|
declare const DsCard: {
|
|
15
|
-
({ id, testId, children, className, backgroundColor,
|
|
16
|
+
({ id, testId, children, className, backgroundColor, border, borderColor, size, radius, }: DsCardProps): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
propTypes: {
|
|
17
18
|
id: PropTypes.Requireable<string>;
|
|
18
19
|
testId: PropTypes.Requireable<string>;
|
|
19
20
|
backgroundColor: PropTypes.Requireable<CardColor>;
|
|
21
|
+
border: PropTypes.Requireable<CardBorder>;
|
|
20
22
|
borderColor: PropTypes.Requireable<CardColor>;
|
|
21
|
-
|
|
23
|
+
radius: PropTypes.Requireable<import('./Card.config').CardRadius>;
|
|
22
24
|
};
|
|
23
25
|
displayName: string;
|
|
24
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta } from '@storybook/react';
|
|
2
|
-
import { CardSize } from './Card.config';
|
|
2
|
+
import { CardBorder, CardRadius, CardSize } from './Card.config';
|
|
3
3
|
import { DsCardProps } from '.';
|
|
4
4
|
|
|
5
5
|
declare const ComponentProps: Meta;
|
|
@@ -13,17 +13,23 @@ export declare const WithBorder: {
|
|
|
13
13
|
borderColor: string;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
+
export declare const WithoutBorder: {
|
|
17
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCardProps>;
|
|
18
|
+
args: {
|
|
19
|
+
border: CardBorder;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
16
22
|
export declare const WithSideBorder: {
|
|
17
23
|
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCardProps>;
|
|
18
24
|
args: {
|
|
19
|
-
|
|
25
|
+
border: CardBorder;
|
|
20
26
|
};
|
|
21
27
|
};
|
|
22
|
-
export declare const
|
|
28
|
+
export declare const WithSideBorderAndColor: {
|
|
23
29
|
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCardProps>;
|
|
24
30
|
args: {
|
|
31
|
+
border: CardBorder;
|
|
25
32
|
borderColor: string;
|
|
26
|
-
sideBorder: boolean;
|
|
27
33
|
};
|
|
28
34
|
};
|
|
29
35
|
export declare const WithBackground: {
|
|
@@ -44,3 +50,15 @@ export declare const WithoutPadding: {
|
|
|
44
50
|
size: CardSize;
|
|
45
51
|
};
|
|
46
52
|
};
|
|
53
|
+
export declare const WithRadius: {
|
|
54
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCardProps>;
|
|
55
|
+
args: {
|
|
56
|
+
radius: CardRadius;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const WithoutRadius: {
|
|
60
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCardProps>;
|
|
61
|
+
args: {
|
|
62
|
+
radius: CardRadius;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
@@ -8,6 +8,11 @@ export interface DsRadioProps extends Omit<React.InputHTMLAttributes<HTMLInputEl
|
|
|
8
8
|
description?: React.ReactNode;
|
|
9
9
|
className?: string;
|
|
10
10
|
testId?: string;
|
|
11
|
+
status?: string;
|
|
12
|
+
feedback?: React.ReactNode;
|
|
13
|
+
onChangeHandler?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
14
|
+
onBlurHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
15
|
+
onFocusHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
11
16
|
}
|
|
12
17
|
declare const DsRadio: React.ForwardRefExoticComponent<DsRadioProps & React.RefAttributes<HTMLInputElement>>;
|
|
13
18
|
export default DsRadio;
|
|
@@ -25,6 +25,7 @@ export * from './bosons/Wrapper';
|
|
|
25
25
|
export * from './molecules/Accordion';
|
|
26
26
|
export * from './molecules/ActiveTags';
|
|
27
27
|
export * from './molecules/Carousel';
|
|
28
|
+
export * from './molecules/CheckboxCard';
|
|
28
29
|
export * from './molecules/EditableSelect';
|
|
29
30
|
export * from './molecules/Indicator';
|
|
30
31
|
export * from './molecules/InlineEditable';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segue a convenção de `status` + `feedback` já usada por DsInput, DsSelect e
|
|
3
|
+
* DsTextArea, incluindo o `Default = ''` — string vazia é falsy, então o
|
|
4
|
+
* modificador de classe simplesmente não é aplicado.
|
|
5
|
+
*
|
|
6
|
+
* `Warning` não existe nos outros três, mas o design do card especifica. Por
|
|
7
|
+
* outro lado, `Success` existe neles e não no card, então não foi inventado
|
|
8
|
+
* aqui.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum CheckboxCardStatus {
|
|
11
|
+
Default = "",
|
|
12
|
+
Error = "error",
|
|
13
|
+
Warning = "warning"
|
|
14
|
+
}
|
|
15
|
+
/** Glifos Material usados pelo box, conforme o design (nós 153:324 e 153:327). */
|
|
16
|
+
export declare const CheckboxCardGlyph: {
|
|
17
|
+
readonly Checked: "check_box";
|
|
18
|
+
readonly Unchecked: "check_box_outline_blank";
|
|
19
|
+
};
|
|
20
|
+
/** Glifos Material do feedback de validação (nós 153:5223 e 153:5232). */
|
|
21
|
+
export declare const CheckboxCardFeedbackGlyph: Record<string, string>;
|
|
22
|
+
export interface CheckboxCardValueProps {
|
|
23
|
+
type: StringConstructor;
|
|
24
|
+
required: false;
|
|
25
|
+
}
|
|
26
|
+
export interface CheckboxCardStatusProps {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: CheckboxCardStatus;
|
|
29
|
+
options: CheckboxCardStatus[];
|
|
30
|
+
}
|
|
31
|
+
export interface CheckboxCardFeedbackProps {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckboxCardHasFeedbackProps {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface CheckboxCardFullWidthProps {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface CheckboxCardDisabledProps {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
}
|
|
47
|
+
export interface CheckboxCardClassNameProps {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
}
|
|
51
|
+
export interface CheckboxCardTestIdProps {
|
|
52
|
+
type: StringConstructor;
|
|
53
|
+
default: string;
|
|
54
|
+
}
|
|
55
|
+
export interface CheckboxCardConfig {
|
|
56
|
+
name: string;
|
|
57
|
+
class: string;
|
|
58
|
+
props: {
|
|
59
|
+
value: CheckboxCardValueProps;
|
|
60
|
+
status: CheckboxCardStatusProps;
|
|
61
|
+
feedback: CheckboxCardFeedbackProps;
|
|
62
|
+
hasFeedback: CheckboxCardHasFeedbackProps;
|
|
63
|
+
fullWidth: CheckboxCardFullWidthProps;
|
|
64
|
+
disabled: CheckboxCardDisabledProps;
|
|
65
|
+
className: CheckboxCardClassNameProps;
|
|
66
|
+
testId: CheckboxCardTestIdProps;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
declare const checkboxCardConfig: CheckboxCardConfig;
|
|
70
|
+
export default checkboxCardConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CheckboxCardStatus } from './CheckboxCard.config';
|
|
3
|
+
|
|
4
|
+
export interface DsCheckboxCardProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'children' | 'className' | 'size' | 'value'> {
|
|
5
|
+
value?: string;
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
icon?: React.ReactNode;
|
|
9
|
+
status?: CheckboxCardStatus;
|
|
10
|
+
feedback?: React.ReactNode;
|
|
11
|
+
/** Reserva o espaço do feedback para o layout não pular quando ele aparece. */
|
|
12
|
+
hasFeedback?: boolean;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
testId?: string;
|
|
16
|
+
onChangeHandler?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
+
onBlurHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
18
|
+
onFocusHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
19
|
+
}
|
|
20
|
+
declare const DsCheckboxCard: React.ForwardRefExoticComponent<DsCheckboxCardProps & React.RefAttributes<HTMLInputElement>>;
|
|
21
|
+
export default DsCheckboxCard;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { DsCheckboxCardProps } from './CheckboxCard';
|
|
3
|
+
import { CheckboxCardStatus } from './CheckboxCard.config';
|
|
4
|
+
|
|
5
|
+
declare const meta: Meta<DsCheckboxCardProps>;
|
|
6
|
+
export default meta;
|
|
7
|
+
export declare const Default: {
|
|
8
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
9
|
+
args: {
|
|
10
|
+
label: string;
|
|
11
|
+
name: string;
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const WithDescription: {
|
|
16
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
17
|
+
args: {
|
|
18
|
+
label: string;
|
|
19
|
+
description: string;
|
|
20
|
+
name: string;
|
|
21
|
+
value: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare const WithIcon: {
|
|
25
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
26
|
+
args: {
|
|
27
|
+
label: string;
|
|
28
|
+
description: string;
|
|
29
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
name: string;
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Marcado e habilitado: a borda fica `primary`, então a seleção aparece no
|
|
36
|
+
* card inteiro e não só no box de 20px.
|
|
37
|
+
*
|
|
38
|
+
* Compare com `DisabledChecked`, que segue cinza, e com a linha `Invalid` de
|
|
39
|
+
* `AllStates`, onde a borda de validação tem prioridade sobre a de marcado.
|
|
40
|
+
*/
|
|
41
|
+
export declare const Checked: {
|
|
42
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
43
|
+
args: {
|
|
44
|
+
label: string;
|
|
45
|
+
description: string;
|
|
46
|
+
defaultChecked: boolean;
|
|
47
|
+
name: string;
|
|
48
|
+
value: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export declare const Disabled: {
|
|
52
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
53
|
+
args: {
|
|
54
|
+
label: string;
|
|
55
|
+
description: string;
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
name: string;
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const DisabledChecked: {
|
|
62
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
63
|
+
args: {
|
|
64
|
+
label: string;
|
|
65
|
+
description: string;
|
|
66
|
+
defaultChecked: boolean;
|
|
67
|
+
disabled: boolean;
|
|
68
|
+
name: string;
|
|
69
|
+
value: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare const Controlled: {
|
|
73
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
74
|
+
};
|
|
75
|
+
export declare const FullWidth: {
|
|
76
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
};
|
|
78
|
+
export declare const Error: {
|
|
79
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
80
|
+
args: {
|
|
81
|
+
label: string;
|
|
82
|
+
description: string;
|
|
83
|
+
feedback: string;
|
|
84
|
+
status: CheckboxCardStatus;
|
|
85
|
+
name: string;
|
|
86
|
+
value: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export declare const Warning: {
|
|
90
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
91
|
+
args: {
|
|
92
|
+
label: string;
|
|
93
|
+
description: string;
|
|
94
|
+
feedback: string;
|
|
95
|
+
status: CheckboxCardStatus;
|
|
96
|
+
name: string;
|
|
97
|
+
value: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* `hasFeedback` reserva a altura do feedback, então o card não muda de altura
|
|
102
|
+
* quando o erro aparece.
|
|
103
|
+
*
|
|
104
|
+
* O segundo e o terceiro card têm a **mesma altura** — um sem mensagem, outro
|
|
105
|
+
* com. O primeiro, sem reserva, é mais baixo: a diferença entre ele e o
|
|
106
|
+
* terceiro é exatamente o salto de layout que a reserva evita.
|
|
107
|
+
*
|
|
108
|
+
* Diferente do `DsInput`, aqui a prop **só reserva, nunca esconde**: com
|
|
109
|
+
* `hasFeedback={false}` e um `status` de erro, a mensagem aparece normalmente.
|
|
110
|
+
* No `DsInput`, `hasFeedback={false}` faz o feedback nunca ser exibido.
|
|
111
|
+
*/
|
|
112
|
+
export declare const ReservedFeedback: {
|
|
113
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Espelha a matriz de variantes do Figma: uma linha por estado, coluna da
|
|
117
|
+
* esquerda não marcado e da direita marcado. Falta o `Hover`, que é
|
|
118
|
+
* pseudo-classe CSS e não dá para renderizar estaticamente.
|
|
119
|
+
*/
|
|
120
|
+
export declare const AllStates: {
|
|
121
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
122
|
+
};
|
|
123
|
+
export declare const Playground: {
|
|
124
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardProps>;
|
|
125
|
+
args: {
|
|
126
|
+
label: string;
|
|
127
|
+
description: string;
|
|
128
|
+
name: string;
|
|
129
|
+
value: string;
|
|
130
|
+
disabled: boolean;
|
|
131
|
+
fullWidth: boolean;
|
|
132
|
+
status: CheckboxCardStatus;
|
|
133
|
+
feedback: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
declare const meta: Meta;
|
|
4
|
+
export default meta;
|
|
5
|
+
/**
|
|
6
|
+
* Formulário de cotação com os dois componentes: o grupo para escolher
|
|
7
|
+
* coberturas (seleção múltipla, obrigatória) e um card avulso para um opt-in
|
|
8
|
+
* único.
|
|
9
|
+
*
|
|
10
|
+
* Pontos que valem atenção no código:
|
|
11
|
+
*
|
|
12
|
+
* - O grupo é **controlado**, porque a validação precisa ler a seleção antes
|
|
13
|
+
* do submit. Se não houvesse validação, `defaultValue` bastaria e o
|
|
14
|
+
* componente não guardaria estado nenhum.
|
|
15
|
+
* - O card avulso é **não-controlado**: ninguém precisa do valor dele antes
|
|
16
|
+
* do submit, então ele sai do payload nativo do formulário.
|
|
17
|
+
* - "Selecione pelo menos uma" é regra **do grupo**, não de um card, então
|
|
18
|
+
* usa `status` e `feedback` no grupo. Quem faz o wiring de acessibilidade é
|
|
19
|
+
* o componente: `aria-describedby` no `<fieldset>` e `role="alert"` no
|
|
20
|
+
* feedback, para o leitor de tela anunciar sem precisar mover o foco.
|
|
21
|
+
* - `hasFeedback` reserva a altura da mensagem, então os cards não são
|
|
22
|
+
* empurrados quando o erro aparece.
|
|
23
|
+
* - O envio usa `FormData`, sem estado intermediário para os valores: os
|
|
24
|
+
* `name` e `value` dos inputs nativos já montam o payload.
|
|
25
|
+
*/
|
|
26
|
+
export declare const Formulario: {
|
|
27
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Mesma tela, mas com a validação vindo do backend por cobertura. Aqui o
|
|
31
|
+
* feedback é **do card**, via `status` e `feedback` no item — diferente do
|
|
32
|
+
* exemplo acima, em que o erro era do grupo.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ValidacaoPorCobertura: {
|
|
35
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CheckboxCardStatus } from './CheckboxCard.config';
|
|
3
|
+
|
|
4
|
+
export declare enum CheckboxCardGroupOrientation {
|
|
5
|
+
Row = "row",
|
|
6
|
+
Column = "column"
|
|
7
|
+
}
|
|
8
|
+
export interface DsCheckboxCardItem {
|
|
9
|
+
value: string;
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
description?: ReactNode;
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Validação do card. Para uma regra do grupo, use `status` no grupo. */
|
|
15
|
+
status?: CheckboxCardStatus;
|
|
16
|
+
feedback?: ReactNode;
|
|
17
|
+
testId?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CheckboxCardGroupItemsProps {
|
|
20
|
+
type: ArrayConstructor;
|
|
21
|
+
required: true;
|
|
22
|
+
}
|
|
23
|
+
export interface CheckboxCardGroupValueProps {
|
|
24
|
+
type: ArrayConstructor;
|
|
25
|
+
required: false;
|
|
26
|
+
}
|
|
27
|
+
export interface CheckboxCardGroupDefaultValueProps {
|
|
28
|
+
type: ArrayConstructor;
|
|
29
|
+
required: false;
|
|
30
|
+
}
|
|
31
|
+
export interface CheckboxCardGroupOrientationProps {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: CheckboxCardGroupOrientation;
|
|
34
|
+
options: CheckboxCardGroupOrientation[];
|
|
35
|
+
}
|
|
36
|
+
export interface CheckboxCardGroupStatusProps {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: CheckboxCardStatus;
|
|
39
|
+
options: CheckboxCardStatus[];
|
|
40
|
+
}
|
|
41
|
+
export interface CheckboxCardGroupFeedbackProps {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CheckboxCardGroupHasFeedbackProps {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface CheckboxCardGroupFullWidthProps {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface CheckboxCardGroupDisabledProps {
|
|
54
|
+
type: BooleanConstructor;
|
|
55
|
+
default: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface CheckboxCardGroupClassNameProps {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: string;
|
|
60
|
+
}
|
|
61
|
+
export interface CheckboxCardGroupTestIdProps {
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
default: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CheckboxCardGroupOnChangeProps {
|
|
66
|
+
type: FunctionConstructor;
|
|
67
|
+
default: (values: string[]) => void;
|
|
68
|
+
}
|
|
69
|
+
export interface CheckboxCardGroupConfig {
|
|
70
|
+
name: string;
|
|
71
|
+
class: string;
|
|
72
|
+
props: {
|
|
73
|
+
items: CheckboxCardGroupItemsProps;
|
|
74
|
+
value: CheckboxCardGroupValueProps;
|
|
75
|
+
defaultValue: CheckboxCardGroupDefaultValueProps;
|
|
76
|
+
orientation: CheckboxCardGroupOrientationProps;
|
|
77
|
+
status: CheckboxCardGroupStatusProps;
|
|
78
|
+
feedback: CheckboxCardGroupFeedbackProps;
|
|
79
|
+
hasFeedback: CheckboxCardGroupHasFeedbackProps;
|
|
80
|
+
fullWidth: CheckboxCardGroupFullWidthProps;
|
|
81
|
+
disabled: CheckboxCardGroupDisabledProps;
|
|
82
|
+
className: CheckboxCardGroupClassNameProps;
|
|
83
|
+
testId: CheckboxCardGroupTestIdProps;
|
|
84
|
+
onChange: CheckboxCardGroupOnChangeProps;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
declare const checkboxCardGroupConfig: CheckboxCardGroupConfig;
|
|
88
|
+
export default checkboxCardGroupConfig;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CheckboxCardStatus } from './CheckboxCard.config';
|
|
3
|
+
import { CheckboxCardGroupOrientation, DsCheckboxCardItem } from './CheckboxCardGroup.config';
|
|
4
|
+
|
|
5
|
+
export interface DsCheckboxCardGroupProps extends Omit<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'children' | 'className' | 'onChange'> {
|
|
6
|
+
items: DsCheckboxCardItem[];
|
|
7
|
+
value?: string[];
|
|
8
|
+
defaultValue?: string[];
|
|
9
|
+
onChange?: (values: string[], event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Validação da regra do grupo, como "selecione pelo menos uma". Para
|
|
14
|
+
* validação de um card específico, use `status` no item.
|
|
15
|
+
*/
|
|
16
|
+
status?: CheckboxCardStatus;
|
|
17
|
+
feedback?: React.ReactNode;
|
|
18
|
+
/** Reserva o espaço do feedback para os cards não serem empurrados. */
|
|
19
|
+
hasFeedback?: boolean;
|
|
20
|
+
orientation?: CheckboxCardGroupOrientation;
|
|
21
|
+
/**
|
|
22
|
+
* Faz o `<fieldset>` ocupar toda a largura do container pai. Não afeta os
|
|
23
|
+
* cards: dentro de um grupo eles já têm largura uniforme por CSS, então a
|
|
24
|
+
* prop `fullWidth` do card não é propagada.
|
|
25
|
+
*/
|
|
26
|
+
fullWidth?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
testId?: string;
|
|
29
|
+
onChangeHandler?: (values: string[], event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
30
|
+
onBlurHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
31
|
+
onFocusHandler?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
32
|
+
}
|
|
33
|
+
declare const DsCheckboxCardGroup: React.ForwardRefExoticComponent<DsCheckboxCardGroupProps & React.RefAttributes<HTMLFieldSetElement>>;
|
|
34
|
+
export default DsCheckboxCardGroup;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
import { CheckboxCardStatus } from './CheckboxCard.config';
|
|
3
|
+
import { DsCheckboxCardGroupProps } from './CheckboxCardGroup';
|
|
4
|
+
import { CheckboxCardGroupOrientation, DsCheckboxCardItem } from './CheckboxCardGroup.config';
|
|
5
|
+
|
|
6
|
+
declare const meta: Meta<DsCheckboxCardGroupProps>;
|
|
7
|
+
export default meta;
|
|
8
|
+
export declare const Default: {
|
|
9
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
10
|
+
args: {
|
|
11
|
+
items: DsCheckboxCardItem[];
|
|
12
|
+
label: string;
|
|
13
|
+
defaultValue: string[];
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare const Horizontal: {
|
|
18
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
19
|
+
args: {
|
|
20
|
+
items: DsCheckboxCardItem[];
|
|
21
|
+
label: string;
|
|
22
|
+
orientation: CheckboxCardGroupOrientation;
|
|
23
|
+
defaultValue: string[];
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const WithDescription: {
|
|
28
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
29
|
+
args: {
|
|
30
|
+
items: DsCheckboxCardItem[];
|
|
31
|
+
label: string;
|
|
32
|
+
description: string;
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Onde o `fullWidth` do grupo faz diferença — e onde não faz.
|
|
38
|
+
*
|
|
39
|
+
* O tracejado marca os limites do pai, sempre com 420px. Os dois primeiros
|
|
40
|
+
* casos são **idênticos**: num pai em bloco o `<fieldset>` já preenche a
|
|
41
|
+
* largura por padrão, então a prop não muda nada. A diferença aparece só nos
|
|
42
|
+
* dois últimos, em pai flex, onde sem a prop o grupo encolhe para o conteúdo.
|
|
43
|
+
*/
|
|
44
|
+
export declare const FullWidthWhereItMatters: {
|
|
45
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
};
|
|
47
|
+
export declare const DisabledGroup: {
|
|
48
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
49
|
+
args: {
|
|
50
|
+
items: DsCheckboxCardItem[];
|
|
51
|
+
label: string;
|
|
52
|
+
defaultValue: string[];
|
|
53
|
+
disabled: boolean;
|
|
54
|
+
name: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export declare const MixedDisabled: {
|
|
58
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
59
|
+
args: {
|
|
60
|
+
label: string;
|
|
61
|
+
name: string;
|
|
62
|
+
items: DsCheckboxCardItem[];
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Validação da regra do grupo: `status` e `feedback` no próprio grupo, com o
|
|
67
|
+
* `aria-describedby` e o `role="alert"` ligados pelo componente.
|
|
68
|
+
*/
|
|
69
|
+
export declare const GroupValidation: {
|
|
70
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
71
|
+
args: {
|
|
72
|
+
items: DsCheckboxCardItem[];
|
|
73
|
+
label: string;
|
|
74
|
+
name: string;
|
|
75
|
+
status: CheckboxCardStatus;
|
|
76
|
+
feedback: string;
|
|
77
|
+
hasFeedback: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/** Validação por item: cada card carrega o seu `status` e o seu `feedback`. */
|
|
81
|
+
export declare const ItemValidation: {
|
|
82
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, DsCheckboxCardGroupProps>;
|
|
83
|
+
args: {
|
|
84
|
+
label: string;
|
|
85
|
+
name: string;
|
|
86
|
+
items: DsCheckboxCardItem[];
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export declare const Controlled: {
|
|
90
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
91
|
+
};
|
|
92
|
+
export declare const InsideForm: {
|
|
93
|
+
render: () => import("react/jsx-runtime").JSX.Element;
|
|
94
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './CheckboxCard';
|
|
2
|
+
export * from './CheckboxCardGroup';
|
|
3
|
+
export * from './CheckboxCard.config';
|
|
4
|
+
export * from './CheckboxCardGroup.config';
|
|
5
|
+
export { default as DsCheckboxCard } from './CheckboxCard';
|
|
6
|
+
export { default as DsCheckboxCardGroup } from './CheckboxCardGroup';
|
|
7
|
+
export { default as checkboxCardConfig } from './CheckboxCard.config';
|
|
8
|
+
export { default as checkboxCardGroupConfig } from './CheckboxCardGroup.config';
|
|
@@ -3,7 +3,7 @@ $button__font--family: var(--font__family--highlight) !default;
|
|
|
3
3
|
$button__font--weight: $font__weight--regular !default;
|
|
4
4
|
$button__padding: 0 $spacing__inset--sm !default;
|
|
5
5
|
$button__padding--with-icon: 0 $spacing__inset--xs !default;
|
|
6
|
-
$button__border-radius: $border__radius--
|
|
6
|
+
$button__border-radius: $border__radius--sm !default;
|
|
7
7
|
$button__border-width: $border__width--hairline !default;
|
|
8
8
|
$button__text--transform: initial !default;
|
|
9
9
|
$button__text-letter--spacing: initial !default;
|