@1doc/1ds-react 0.0.2 → 2.7.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/CHANGELOG.md +659 -0
- package/README.md +137 -6
- package/package.json +43 -28
- package/src/index.ts +161 -16
- package/src/teste/AttachmentCard.test.tsx +161 -0
- package/src/teste/Chart.test.tsx +233 -0
- package/src/teste/Combobox.test.tsx +251 -0
- package/src/teste/DataTable.test.tsx +70 -0
- package/src/teste/DatePicker.test.tsx +86 -0
- package/src/teste/Drawer.test.tsx +265 -0
- package/src/teste/Dropdown.test.tsx +217 -0
- package/src/teste/Input.test.tsx +64 -0
- package/src/teste/Kanban.test.tsx +333 -0
- package/src/teste/MultiSelect.test.tsx +73 -0
- package/src/teste/Podium.test.tsx +107 -0
- package/src/teste/Popover.test.tsx +221 -0
- package/src/teste/SegmentedControl.test.tsx +183 -0
- package/src/teste/Timeline.test.tsx +100 -0
- package/src/teste/Tree.test.tsx +74 -0
- package/src/teste/setup.ts +7 -0
- package/src/utils/bandeiras.ts +22 -0
- package/src/utils/chart.ts +682 -0
- package/src/utils/density.ts +27 -0
- package/src/utils/overlay-stack.ts +26 -0
- package/src/utils/theme.ts +63 -47
- package/src/utils/toast.ts +89 -0
- package/vitest.config.ts +28 -0
- package/dist/components/Alert/Alert.css +0 -188
- package/dist/components/Alert/Alert.d.ts +0 -65
- package/dist/components/Alert/Alert.js +0 -56
- package/dist/components/Avatar/Avatar.css +0 -88
- package/dist/components/Avatar/Avatar.d.ts +0 -34
- package/dist/components/Avatar/Avatar.js +0 -16
- package/dist/components/Avatar/AvatarGroup.d.ts +0 -12
- package/dist/components/Avatar/AvatarGroup.js +0 -8
- package/dist/components/Badge/Badge.css +0 -155
- package/dist/components/Badge/Badge.d.ts +0 -46
- package/dist/components/Badge/Badge.js +0 -17
- package/dist/components/Button/Button.css +0 -199
- package/dist/components/Button/Button.d.ts +0 -23
- package/dist/components/Button/Button.js +0 -62
- package/dist/components/Checkbox/Checkbox.css +0 -122
- package/dist/components/Checkbox/Checkbox.d.ts +0 -21
- package/dist/components/Checkbox/Checkbox.js +0 -49
- package/dist/components/Divider/Divider.css +0 -81
- package/dist/components/Divider/Divider.d.ts +0 -18
- package/dist/components/Divider/Divider.js +0 -26
- package/dist/components/Grid/Grid.css +0 -154
- package/dist/components/Grid/Grid.d.ts +0 -21
- package/dist/components/Grid/Grid.js +0 -53
- package/dist/components/Icon/Icon.css +0 -55
- package/dist/components/Icon/Icon.d.ts +0 -13
- package/dist/components/Icon/Icon.js +0 -41
- package/dist/components/Input/Input.css +0 -190
- package/dist/components/Input/Input.d.ts +0 -32
- package/dist/components/Input/Input.js +0 -58
- package/dist/components/Link/Link.css +0 -76
- package/dist/components/Link/Link.d.ts +0 -15
- package/dist/components/Link/Link.js +0 -19
- package/dist/components/Logo/Logo.css +0 -32
- package/dist/components/Logo/Logo.d.ts +0 -10
- package/dist/components/Logo/Logo.js +0 -16
- package/dist/components/Modal/Modal.css +0 -155
- package/dist/components/Modal/Modal.d.ts +0 -36
- package/dist/components/Modal/Modal.js +0 -55
- package/dist/components/Radio/Radio.css +0 -114
- package/dist/components/Radio/Radio.d.ts +0 -19
- package/dist/components/Radio/Radio.js +0 -39
- package/dist/components/Select/Select.css +0 -291
- package/dist/components/Select/Select.d.ts +0 -38
- package/dist/components/Select/Select.js +0 -246
- package/dist/components/Spinner/Spinner.css +0 -60
- package/dist/components/Spinner/Spinner.d.ts +0 -16
- package/dist/components/Spinner/Spinner.js +0 -16
- package/dist/components/Switch/Switch.css +0 -127
- package/dist/components/Switch/Switch.d.ts +0 -18
- package/dist/components/Switch/Switch.js +0 -57
- package/dist/components/Tabs/Tab.d.ts +0 -19
- package/dist/components/Tabs/Tab.js +0 -76
- package/dist/components/Tabs/TabContent.d.ts +0 -15
- package/dist/components/Tabs/TabContent.js +0 -11
- package/dist/components/Tabs/Tabs.css +0 -124
- package/dist/components/Tabs/Tabs.d.ts +0 -20
- package/dist/components/Tabs/Tabs.js +0 -14
- package/dist/components/Tabs/TabsContent.d.ts +0 -16
- package/dist/components/Tabs/TabsContent.js +0 -12
- package/dist/components/Tabs/tabs.context.d.ts +0 -2
- package/dist/components/Tabs/tabs.context.js +0 -2
- package/dist/components/Tag/Tag.css +0 -140
- package/dist/components/Tag/Tag.d.ts +0 -63
- package/dist/components/Tag/Tag.js +0 -48
- package/dist/components/Text/Text.css +0 -1213
- package/dist/components/Text/Text.d.ts +0 -70
- package/dist/components/Text/Text.js +0 -89
- package/dist/components/Textarea/Textarea.css +0 -133
- package/dist/components/Textarea/Textarea.d.ts +0 -28
- package/dist/components/Textarea/Textarea.js +0 -72
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -27
- package/dist/utils/theme.d.ts +0 -30
- package/dist/utils/theme.js +0 -106
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import './Text.css';
|
|
2
|
-
/**
|
|
3
|
-
* Variantes tipográficas disponíveis
|
|
4
|
-
*/
|
|
5
|
-
export type TextVariant = "display" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "subtitle1" | "subtitle2" | "body1" | "body2" | "caption" | "overline" | "label";
|
|
6
|
-
/**
|
|
7
|
-
* Mapeamento de variante para elemento HTML
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Variantes tipográficas disponíveis
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* Mapeamento de variante para elemento HTML
|
|
14
|
-
*/
|
|
15
|
-
export interface ResponsiveVariant {
|
|
16
|
-
xs?: TextVariant;
|
|
17
|
-
sm?: TextVariant;
|
|
18
|
-
md?: TextVariant;
|
|
19
|
-
lg?: TextVariant;
|
|
20
|
-
xl?: TextVariant;
|
|
21
|
-
xxl?: TextVariant;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Variantes tipográficas disponíveis
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Mapeamento de variante para elemento HTML
|
|
28
|
-
*/
|
|
29
|
-
export interface TextProps {
|
|
30
|
-
/** Variante tipográfica padrão */
|
|
31
|
-
variant?: TextVariant;
|
|
32
|
-
/** Sobrescreve o visual independente do elemento semântico */
|
|
33
|
-
visual?: TextVariant | ResponsiveVariant;
|
|
34
|
-
/** Variante responsive para xs (também define o elemento semântico) */
|
|
35
|
-
xs?: TextVariant;
|
|
36
|
-
/** Variante responsive para sm (também define o elemento semântico) */
|
|
37
|
-
sm?: TextVariant;
|
|
38
|
-
/** Variante responsive para md (também define o elemento semântico) */
|
|
39
|
-
md?: TextVariant;
|
|
40
|
-
/** Variante responsive para lg (também define o elemento semântico) */
|
|
41
|
-
lg?: TextVariant;
|
|
42
|
-
/** Variante responsive para xl (também define o elemento semântico) */
|
|
43
|
-
xl?: TextVariant;
|
|
44
|
-
/** Variante responsive para xxl (também define o elemento semântico) */
|
|
45
|
-
xxl?: TextVariant;
|
|
46
|
-
/** Elemento HTML a ser renderizado (sobrescreve o padrão da variante) */
|
|
47
|
-
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "label";
|
|
48
|
-
/** Alinhamento do texto */
|
|
49
|
-
align?: "left" | "center" | "right" | "justify";
|
|
50
|
-
/** Cor do texto usando tokens semânticos */
|
|
51
|
-
color?: "primary" | "secondary" | "disabled" | "error" | "inherit";
|
|
52
|
-
/** Peso da fonte */
|
|
53
|
-
weight?: "thin" | "light" | "regular" | "medium" | "semibold" | "bold" | "extrabold" | "black";
|
|
54
|
-
/** Truncar texto com ellipsis */
|
|
55
|
-
noWrap?: boolean;
|
|
56
|
-
/** Número máximo de linhas antes de truncar */
|
|
57
|
-
maxLines?: number;
|
|
58
|
-
/** Transforma o texto */
|
|
59
|
-
transform?: "none" | "capitalize" | "uppercase" | "lowercase";
|
|
60
|
-
/** Adiciona margem inferior baseada no espaçamento do design system */
|
|
61
|
-
gutterBottom?: boolean;
|
|
62
|
-
/** Classes CSS adicionais */
|
|
63
|
-
className?: string;
|
|
64
|
-
/** Conteúdo do texto */
|
|
65
|
-
children?: any;
|
|
66
|
-
/** Atributos HTML adicionais */
|
|
67
|
-
[key: string]: any;
|
|
68
|
-
}
|
|
69
|
-
declare function Text(props: TextProps): import("react/jsx-runtime").JSX.Element;
|
|
70
|
-
export default Text;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import './Text.css';
|
|
3
|
-
/**
|
|
4
|
-
* Mapeamento de variante para elemento HTML
|
|
5
|
-
*/
|
|
6
|
-
const variantToElement = {
|
|
7
|
-
display: "h1",
|
|
8
|
-
h1: "h1",
|
|
9
|
-
h2: "h2",
|
|
10
|
-
h3: "h3",
|
|
11
|
-
h4: "h4",
|
|
12
|
-
h5: "h5",
|
|
13
|
-
h6: "h6",
|
|
14
|
-
subtitle1: "h6",
|
|
15
|
-
subtitle2: "h6",
|
|
16
|
-
body1: "p",
|
|
17
|
-
body2: "p",
|
|
18
|
-
caption: "span",
|
|
19
|
-
overline: "span",
|
|
20
|
-
label: "label",
|
|
21
|
-
};
|
|
22
|
-
function Text(props) {
|
|
23
|
-
function elementTag() {
|
|
24
|
-
if (props.as)
|
|
25
|
-
return props.as;
|
|
26
|
-
const baseVar = props.variant || props.xs || "body1";
|
|
27
|
-
return variantToElement[baseVar] || "p";
|
|
28
|
-
}
|
|
29
|
-
function classes() {
|
|
30
|
-
const respClasses = [];
|
|
31
|
-
// Base variant
|
|
32
|
-
const baseVar = props.variant || props.xs || "body1";
|
|
33
|
-
respClasses.push(`umds-text--${baseVar}`);
|
|
34
|
-
// Responsive variants (semantic)
|
|
35
|
-
if (props.sm)
|
|
36
|
-
respClasses.push(`umds-text--sm-${props.sm}`);
|
|
37
|
-
if (props.md)
|
|
38
|
-
respClasses.push(`umds-text--md-${props.md}`);
|
|
39
|
-
if (props.lg)
|
|
40
|
-
respClasses.push(`umds-text--lg-${props.lg}`);
|
|
41
|
-
if (props.xl)
|
|
42
|
-
respClasses.push(`umds-text--xl-${props.xl}`);
|
|
43
|
-
if (props.xxl)
|
|
44
|
-
respClasses.push(`umds-text--xxl-${props.xxl}`);
|
|
45
|
-
// Visual overrides
|
|
46
|
-
if (props.visual) {
|
|
47
|
-
if (typeof props.visual === "string") {
|
|
48
|
-
respClasses.push(`umds-text--visual-${props.visual}`);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
if (props.visual.xs)
|
|
52
|
-
respClasses.push(`umds-text--visual-${props.visual.xs}`);
|
|
53
|
-
if (props.visual.sm)
|
|
54
|
-
respClasses.push(`umds-text--visual-sm-${props.visual.sm}`);
|
|
55
|
-
if (props.visual.md)
|
|
56
|
-
respClasses.push(`umds-text--visual-md-${props.visual.md}`);
|
|
57
|
-
if (props.visual.lg)
|
|
58
|
-
respClasses.push(`umds-text--visual-lg-${props.visual.lg}`);
|
|
59
|
-
if (props.visual.xl)
|
|
60
|
-
respClasses.push(`umds-text--visual-xl-${props.visual.xl}`);
|
|
61
|
-
if (props.visual.xxl)
|
|
62
|
-
respClasses.push(`umds-text--visual-xxl-${props.visual.xxl}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return [
|
|
66
|
-
"umds-text",
|
|
67
|
-
...respClasses,
|
|
68
|
-
props.align ? `umds-text--align-${props.align}` : "",
|
|
69
|
-
props.color ? `umds-text--color-${props.color}` : "",
|
|
70
|
-
props.weight ? `umds-text--weight-${props.weight}` : "",
|
|
71
|
-
props.noWrap ? "umds-text--nowrap" : "",
|
|
72
|
-
props.maxLines ? "umds-text--clamp" : "",
|
|
73
|
-
props.transform ? `umds-text--transform-${props.transform}` : "",
|
|
74
|
-
props.gutterBottom ? "umds-text--gutter-bottom" : "",
|
|
75
|
-
props.className,
|
|
76
|
-
]
|
|
77
|
-
.filter(Boolean)
|
|
78
|
-
.join(" ");
|
|
79
|
-
}
|
|
80
|
-
function style() {
|
|
81
|
-
const styles = {};
|
|
82
|
-
if (props.maxLines) {
|
|
83
|
-
styles["--umds-text-max-lines"] = String(props.maxLines);
|
|
84
|
-
}
|
|
85
|
-
return styles;
|
|
86
|
-
}
|
|
87
|
-
return (_jsxs(_Fragment, { children: [elementTag() === "h1" ? (_jsx("h1", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "h2" ? (_jsx("h2", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "h3" ? (_jsx("h3", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "h4" ? (_jsx("h4", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "h5" ? (_jsx("h5", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "h6" ? (_jsx("h6", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "p" ? (_jsx("p", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "span" ? (_jsx("span", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "label" ? (_jsx("label", { style: style(), ...props, className: classes(), children: props.children })) : null, elementTag() === "div" ? (_jsx("div", { style: style(), ...props, className: classes(), children: props.children })) : null] }));
|
|
88
|
-
}
|
|
89
|
-
export default Text;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/* Base Wrapper */
|
|
2
|
-
.umds-textarea {
|
|
3
|
-
display: flex;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
gap: var(--umds-primitive-spacing-nano);
|
|
6
|
-
font-family: var(--umds-semantic-font-family-base);
|
|
7
|
-
width: 390px;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.umds-textarea--full-width {
|
|
11
|
-
width: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/* Label */
|
|
15
|
-
.umds-textarea__label {
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
gap: 2px;
|
|
19
|
-
/* Font styles handled by Text component */
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.umds-textarea__required {
|
|
23
|
-
color: var(--umds-semantic-color-feedback-negative-pure);
|
|
24
|
-
font-weight: bold;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/* Textarea Container (Box) */
|
|
28
|
-
.umds-textarea__container {
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: flex-start;
|
|
31
|
-
position: relative;
|
|
32
|
-
background-color: var(--umds-semantic-color-background-white);
|
|
33
|
-
border: 1px solid var(--umds-semantic-color-neutral-dark-up);
|
|
34
|
-
border-radius: var(--umds-primitive-border-radius-sm);
|
|
35
|
-
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Control (Textarea element) */
|
|
39
|
-
.umds-textarea__control {
|
|
40
|
-
flex: 1;
|
|
41
|
-
border: none;
|
|
42
|
-
background: transparent;
|
|
43
|
-
outline: none;
|
|
44
|
-
color: var(--umds-semantic-color-neutral-pure);
|
|
45
|
-
font-size: var(--umds-primitive-font-size-xs);
|
|
46
|
-
font-family: inherit;
|
|
47
|
-
width: 100%;
|
|
48
|
-
padding: var(--umds-primitive-spacing-xxxs);
|
|
49
|
-
margin: 0;
|
|
50
|
-
resize: vertical;
|
|
51
|
-
line-height: 1.5;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.umds-textarea__control::placeholder {
|
|
55
|
-
color: var(--umds-semantic-color-neutral-dark-medium);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/* AutoSize Mode */
|
|
59
|
-
.umds-textarea--autosize .umds-textarea__control {
|
|
60
|
-
resize: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* States */
|
|
64
|
-
.umds-textarea__container:hover {
|
|
65
|
-
border-color: var(--umds-semantic-color-neutral-dark-down);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.umds-textarea__container:focus-within {
|
|
69
|
-
outline: 2px solid var(--umds-semantic-color-neutral-dark-down);
|
|
70
|
-
outline-offset: 2px;
|
|
71
|
-
border-color: var(--umds-semantic-color-neutral-dark-up);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/* Error State */
|
|
75
|
-
.umds-textarea--error .umds-textarea__container {
|
|
76
|
-
border-color: var(--umds-semantic-color-feedback-negative-pure);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.umds-textarea--error .umds-textarea__container:focus-within {
|
|
80
|
-
outline: 2px solid var(--umds-semantic-color-feedback-negative-pure);
|
|
81
|
-
border-color: var(--umds-semantic-color-feedback-negative-pure);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/* Disabled State */
|
|
85
|
-
.umds-textarea--disabled .umds-textarea__label,
|
|
86
|
-
.umds-textarea--disabled .umds-textarea__message,
|
|
87
|
-
.umds-textarea--disabled .umds-textarea__counter {
|
|
88
|
-
color: var(--umds-semantic-color-neutral-light-down);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.umds-textarea--disabled .umds-textarea__container {
|
|
92
|
-
background-color: var(--umds-semantic-color-neutral-light-medium);
|
|
93
|
-
border-color: var(--umds-semantic-color-neutral-light-down);
|
|
94
|
-
pointer-events: none;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.umds-textarea--disabled .umds-textarea__control {
|
|
98
|
-
color: var(--umds-semantic-color-neutral-light-down);
|
|
99
|
-
-webkit-text-fill-color: var(--umds-semantic-color-neutral-light-down);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.umds-textarea--disabled,
|
|
103
|
-
.umds-textarea--disabled textarea {
|
|
104
|
-
cursor: not-allowed;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/* Read Only State */
|
|
108
|
-
.umds-textarea--readonly .umds-textarea__container {
|
|
109
|
-
background-color: var(--umds-semantic-color-neutral-light-medium);
|
|
110
|
-
border-color: var(--umds-semantic-color-neutral-light-down);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/* Footer (Helper/Error + Counter) */
|
|
114
|
-
.umds-textarea__footer {
|
|
115
|
-
display: flex;
|
|
116
|
-
justify-content: space-between;
|
|
117
|
-
align-items: flex-start;
|
|
118
|
-
width: 100%;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.umds-textarea__messages {
|
|
122
|
-
flex: 1;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
/* Counter */
|
|
128
|
-
.umds-textarea__counter {
|
|
129
|
-
font-size: var(--umds-primitive-font-size-xxs);
|
|
130
|
-
line-height: var(--umds-primitive-font-line-height-lg);
|
|
131
|
-
color: var(--umds-semantic-color-neutral-dark-medium);
|
|
132
|
-
white-space: nowrap;
|
|
133
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import './Textarea.css';
|
|
2
|
-
export interface TextareaProps {
|
|
3
|
-
label?: any;
|
|
4
|
-
name?: string;
|
|
5
|
-
value?: string;
|
|
6
|
-
defaultValue?: string;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
helperText?: any;
|
|
9
|
-
errorMessage?: any;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
readOnly?: boolean;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
rows?: number;
|
|
14
|
-
minRows?: number;
|
|
15
|
-
maxRows?: number;
|
|
16
|
-
maxLength?: number;
|
|
17
|
-
showCounter?: boolean;
|
|
18
|
-
autoSize?: boolean;
|
|
19
|
-
fullWidth?: boolean;
|
|
20
|
-
className?: string;
|
|
21
|
-
onChange?: (event: any) => void;
|
|
22
|
-
onInput?: (event: any) => void;
|
|
23
|
-
onFocus?: (event: any) => void;
|
|
24
|
-
onBlur?: (event: any) => void;
|
|
25
|
-
[key: string]: any;
|
|
26
|
-
}
|
|
27
|
-
declare function Textarea(props: TextareaProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export default Textarea;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import './Textarea.css';
|
|
3
|
-
"use client";
|
|
4
|
-
import { useState, useRef, useEffect } from "react";
|
|
5
|
-
import Text from "../Text/Text";
|
|
6
|
-
function Textarea(props) {
|
|
7
|
-
const textareaRef = useRef(null);
|
|
8
|
-
const [internalValue, setInternalValue] = useState(() => props.defaultValue || "");
|
|
9
|
-
function charCount() {
|
|
10
|
-
const val = props.value !== undefined ? props.value : internalValue;
|
|
11
|
-
return val ? val.length : 0;
|
|
12
|
-
}
|
|
13
|
-
function wrapperClasses() {
|
|
14
|
-
const hasError = props.errorMessage && props.errorMessage.length > 0;
|
|
15
|
-
return [
|
|
16
|
-
"umds-textarea",
|
|
17
|
-
props.fullWidth ? "umds-textarea--full-width" : "",
|
|
18
|
-
hasError ? "umds-textarea--error" : "",
|
|
19
|
-
props.disabled ? "umds-textarea--disabled" : "",
|
|
20
|
-
props.readOnly ? "umds-textarea--readonly" : "",
|
|
21
|
-
props.autoSize ? "umds-textarea--autosize" : "",
|
|
22
|
-
props.className,
|
|
23
|
-
]
|
|
24
|
-
.filter(Boolean)
|
|
25
|
-
.join(" ");
|
|
26
|
-
}
|
|
27
|
-
function containerClasses() {
|
|
28
|
-
const hasError = props.errorMessage && props.errorMessage.length > 0;
|
|
29
|
-
return [
|
|
30
|
-
"umds-textarea__container",
|
|
31
|
-
hasError ? "umds-textarea__container--error" : "",
|
|
32
|
-
props.disabled ? "umds-textarea__container--disabled" : "",
|
|
33
|
-
props.readOnly ? "umds-textarea__container--readonly" : "",
|
|
34
|
-
]
|
|
35
|
-
.filter(Boolean)
|
|
36
|
-
.join(" ");
|
|
37
|
-
}
|
|
38
|
-
function adjustHeight() {
|
|
39
|
-
if (props.autoSize && textareaRef.current) {
|
|
40
|
-
const textarea = textareaRef.current;
|
|
41
|
-
textarea.style.height = "auto";
|
|
42
|
-
const scrollHeight = textarea.scrollHeight;
|
|
43
|
-
// Calculate min/max heights based on rows
|
|
44
|
-
const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 24;
|
|
45
|
-
const paddingTop = parseInt(getComputedStyle(textarea).paddingTop) || 12;
|
|
46
|
-
const paddingBottom = parseInt(getComputedStyle(textarea).paddingBottom) || 12;
|
|
47
|
-
const minRows = props.minRows || 2;
|
|
48
|
-
const maxRows = props.maxRows || 10;
|
|
49
|
-
const minHeight = lineHeight * minRows + paddingTop + paddingBottom;
|
|
50
|
-
const maxHeight = lineHeight * maxRows + paddingTop + paddingBottom;
|
|
51
|
-
const newHeight = Math.min(Math.max(scrollHeight, minHeight), maxHeight);
|
|
52
|
-
textarea.style.height = newHeight + "px";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function handleInput(event) {
|
|
56
|
-
setInternalValue(event.target.value);
|
|
57
|
-
adjustHeight();
|
|
58
|
-
if (props.onInput) {
|
|
59
|
-
props.onInput(event);
|
|
60
|
-
}
|
|
61
|
-
if (props.onChange) {
|
|
62
|
-
props.onChange(event);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
if (props.autoSize) {
|
|
67
|
-
adjustHeight();
|
|
68
|
-
}
|
|
69
|
-
}, []);
|
|
70
|
-
return (_jsxs("div", { className: wrapperClasses(), children: [props.label ? (_jsxs(Text, { as: "label", variant: "label", weight: "semibold", className: "umds-textarea__label", children: [_jsx(_Fragment, { children: props.label || "{props.label}" }), props.required ? (_jsx("span", { className: "umds-textarea__required", children: "*" })) : null] })) : null, _jsx("div", { className: containerClasses(), children: _jsx("textarea", { className: "umds-textarea__control", ref: textareaRef, name: props.name, disabled: props.disabled, readOnly: props.readOnly, placeholder: props.placeholder, value: props.value !== undefined ? props.value : internalValue, defaultValue: props.defaultValue, rows: props.autoSize ? props.minRows || 2 : props.rows || 4, maxLength: props.maxLength, onInput: (event) => handleInput(event), onFocus: (event) => props.onFocus?.(event), onBlur: (event) => props.onBlur?.(event), "aria-invalid": !!(props.errorMessage && props.errorMessage.length > 0), required: props.required }) }), _jsxs("div", { className: "umds-textarea__footer", children: [_jsxs("div", { className: "umds-textarea__messages", children: [props.errorMessage ? (_jsx(Text, { as: "span", variant: "caption", color: "error", children: props.errorMessage })) : null, props.helperText && !props.errorMessage ? (_jsx(Text, { as: "span", variant: "caption", color: "secondary", children: _jsx(_Fragment, { children: props.helperText || "{props.helperText}" }) })) : null] }), props.showCounter ? (_jsxs("span", { className: "umds-textarea__counter", children: [charCount(), "/", props.maxLength || 150] })) : null] })] }));
|
|
71
|
-
}
|
|
72
|
-
export default Textarea;
|
package/dist/index.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export * from "./utils/theme";
|
|
2
|
-
export { default as Button } from "./components/Button/Button";
|
|
3
|
-
export { default as Icon } from "./components/Icon/Icon";
|
|
4
|
-
export { default as Spinner } from "./components/Spinner/Spinner";
|
|
5
|
-
export { default as Divider } from "./components/Divider/Divider";
|
|
6
|
-
export { default as Badge } from "./components/Badge/Badge";
|
|
7
|
-
export { default as Avatar } from "./components/Avatar/Avatar";
|
|
8
|
-
export { default as AvatarGroup } from "./components/Avatar/AvatarGroup";
|
|
9
|
-
export { default as Logo } from "./components/Logo/Logo";
|
|
10
|
-
export { default as Link } from "./components/Link/Link";
|
|
11
|
-
export { default as Switch } from "./components/Switch/Switch";
|
|
12
|
-
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
13
|
-
export { default as Radio } from "./components/Radio/Radio";
|
|
14
|
-
export { default as Input } from "./components/Input/Input";
|
|
15
|
-
export { default as Grid } from "./components/Grid/Grid";
|
|
16
|
-
export { default as Textarea } from "./components/Textarea/Textarea";
|
|
17
|
-
export { default as Select } from "./components/Select/Select";
|
|
18
|
-
export { default as Text } from "./components/Text/Text";
|
|
19
|
-
export { default as Tabs } from "./components/Tabs/Tabs";
|
|
20
|
-
export { default as Tab } from "./components/Tabs/Tab";
|
|
21
|
-
export { default as TabsContent } from "./components/Tabs/TabsContent";
|
|
22
|
-
export { default as TabContent } from "./components/Tabs/TabContent";
|
|
23
|
-
export { default as Tag } from "./components/Tag/Tag";
|
|
24
|
-
export { default as Modal } from "./components/Modal/Modal";
|
|
25
|
-
export { default as Alert } from "./components/Alert/Alert";
|
package/dist/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Theme utilities
|
|
2
|
-
export * from "./utils/theme";
|
|
3
|
-
// Components
|
|
4
|
-
export { default as Button } from "./components/Button/Button";
|
|
5
|
-
export { default as Icon } from "./components/Icon/Icon";
|
|
6
|
-
export { default as Spinner } from "./components/Spinner/Spinner";
|
|
7
|
-
export { default as Divider } from "./components/Divider/Divider";
|
|
8
|
-
export { default as Badge } from "./components/Badge/Badge";
|
|
9
|
-
export { default as Avatar } from "./components/Avatar/Avatar";
|
|
10
|
-
export { default as AvatarGroup } from "./components/Avatar/AvatarGroup";
|
|
11
|
-
export { default as Logo } from "./components/Logo/Logo";
|
|
12
|
-
export { default as Link } from "./components/Link/Link";
|
|
13
|
-
export { default as Switch } from "./components/Switch/Switch";
|
|
14
|
-
export { default as Checkbox } from "./components/Checkbox/Checkbox";
|
|
15
|
-
export { default as Radio } from "./components/Radio/Radio";
|
|
16
|
-
export { default as Input } from "./components/Input/Input";
|
|
17
|
-
export { default as Grid } from "./components/Grid/Grid";
|
|
18
|
-
export { default as Textarea } from "./components/Textarea/Textarea";
|
|
19
|
-
export { default as Select } from "./components/Select/Select";
|
|
20
|
-
export { default as Text } from "./components/Text/Text";
|
|
21
|
-
export { default as Tabs } from "./components/Tabs/Tabs";
|
|
22
|
-
export { default as Tab } from "./components/Tabs/Tab";
|
|
23
|
-
export { default as TabsContent } from "./components/Tabs/TabsContent";
|
|
24
|
-
export { default as TabContent } from "./components/Tabs/TabContent";
|
|
25
|
-
export { default as Tag } from "./components/Tag/Tag";
|
|
26
|
-
export { default as Modal } from "./components/Modal/Modal";
|
|
27
|
-
export { default as Alert } from "./components/Alert/Alert";
|
package/dist/utils/theme.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tipos de temas disponíveis no Design System
|
|
3
|
-
*/
|
|
4
|
-
export type Theme = "1doc" | "1ds-red" | "1ds-green" | "1ds-orange" | "1ds-yellow";
|
|
5
|
-
/**
|
|
6
|
-
* Define o tema ativo no documento
|
|
7
|
-
* @param theme - Nome do tema a ser aplicado
|
|
8
|
-
*/
|
|
9
|
-
export declare const setTheme: (theme: Theme) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Obtém o tema atual, considerando localStorage e preferências do sistema
|
|
12
|
-
* @returns O tema atualmente selecionado
|
|
13
|
-
*/
|
|
14
|
-
export declare const getTheme: () => Theme;
|
|
15
|
-
/**
|
|
16
|
-
* Inicializa o tema ao carregar a página
|
|
17
|
-
* Deve ser chamado o mais cedo possível para evitar flash de conteúdo
|
|
18
|
-
*/
|
|
19
|
-
export declare const initTheme: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* Retorna todos os temas disponíveis
|
|
22
|
-
* @returns Array com todos os temas disponíveis
|
|
23
|
-
*/
|
|
24
|
-
export declare const getAvailableThemes: () => Theme[];
|
|
25
|
-
/**
|
|
26
|
-
* Hook para detectar mudanças de tema (útil para frameworks reativos)
|
|
27
|
-
* @param callback - Função a ser executada quando o tema mudar
|
|
28
|
-
* @returns Função para remover o listener
|
|
29
|
-
*/
|
|
30
|
-
export declare const onThemeChange: (callback: (theme: Theme) => void) => (() => void);
|
package/dist/utils/theme.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chave do localStorage para armazenar o tema selecionado
|
|
3
|
-
*/
|
|
4
|
-
const THEME_STORAGE_KEY = "umds-theme";
|
|
5
|
-
/**
|
|
6
|
-
* Tema padrão do sistema
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_THEME = "1doc";
|
|
9
|
-
/**
|
|
10
|
-
* Define o tema ativo no documento
|
|
11
|
-
* @param theme - Nome do tema a ser aplicado
|
|
12
|
-
*/
|
|
13
|
-
export const setTheme = (theme) => {
|
|
14
|
-
if (typeof document !== "undefined") {
|
|
15
|
-
document.documentElement.setAttribute("data-theme", theme);
|
|
16
|
-
try {
|
|
17
|
-
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
// Silenciosamente falha se localStorage não estiver disponível
|
|
21
|
-
console.warn("Failed to save theme to localStorage:", e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Obtém o tema atual, considerando localStorage e preferências do sistema
|
|
27
|
-
* @returns O tema atualmente selecionado
|
|
28
|
-
*/
|
|
29
|
-
export const getTheme = () => {
|
|
30
|
-
if (typeof window === "undefined") {
|
|
31
|
-
return DEFAULT_THEME;
|
|
32
|
-
}
|
|
33
|
-
// 1. Tenta buscar do localStorage
|
|
34
|
-
try {
|
|
35
|
-
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
|
36
|
-
if (stored && isValidTheme(stored)) {
|
|
37
|
-
return stored;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
console.warn("Failed to read theme from localStorage:", e);
|
|
42
|
-
}
|
|
43
|
-
// 2. Tenta buscar do atributo data-theme do HTML
|
|
44
|
-
const currentTheme = document.documentElement.getAttribute("data-theme");
|
|
45
|
-
if (currentTheme && isValidTheme(currentTheme)) {
|
|
46
|
-
return currentTheme;
|
|
47
|
-
}
|
|
48
|
-
// 3. Retorna o tema padrão
|
|
49
|
-
return DEFAULT_THEME;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Inicializa o tema ao carregar a página
|
|
53
|
-
* Deve ser chamado o mais cedo possível para evitar flash de conteúdo
|
|
54
|
-
*/
|
|
55
|
-
export const initTheme = () => {
|
|
56
|
-
const theme = getTheme();
|
|
57
|
-
setTheme(theme);
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Valida se uma string é um tema válido
|
|
61
|
-
* @param theme - String a ser validada
|
|
62
|
-
* @returns true se o tema é válido
|
|
63
|
-
*/
|
|
64
|
-
function isValidTheme(theme) {
|
|
65
|
-
const validThemes = [
|
|
66
|
-
"1doc",
|
|
67
|
-
"1ds-red",
|
|
68
|
-
"1ds-green",
|
|
69
|
-
"1ds-orange",
|
|
70
|
-
"1ds-yellow",
|
|
71
|
-
];
|
|
72
|
-
return validThemes.includes(theme);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Retorna todos os temas disponíveis
|
|
76
|
-
* @returns Array com todos os temas disponíveis
|
|
77
|
-
*/
|
|
78
|
-
export const getAvailableThemes = () => {
|
|
79
|
-
return ["1doc", "1ds-red", "1ds-green", "1ds-orange", "1ds-yellow"];
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Hook para detectar mudanças de tema (útil para frameworks reativos)
|
|
83
|
-
* @param callback - Função a ser executada quando o tema mudar
|
|
84
|
-
* @returns Função para remover o listener
|
|
85
|
-
*/
|
|
86
|
-
export const onThemeChange = (callback) => {
|
|
87
|
-
if (typeof window === "undefined") {
|
|
88
|
-
return () => { };
|
|
89
|
-
}
|
|
90
|
-
const observer = new MutationObserver((mutations) => {
|
|
91
|
-
mutations.forEach((mutation) => {
|
|
92
|
-
if (mutation.type === "attributes" &&
|
|
93
|
-
mutation.attributeName === "data-theme") {
|
|
94
|
-
const newTheme = document.documentElement.getAttribute("data-theme");
|
|
95
|
-
if (newTheme && isValidTheme(newTheme)) {
|
|
96
|
-
callback(newTheme);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
observer.observe(document.documentElement, {
|
|
102
|
-
attributes: true,
|
|
103
|
-
attributeFilter: ["data-theme"],
|
|
104
|
-
});
|
|
105
|
-
return () => observer.disconnect();
|
|
106
|
-
};
|