@ftdata/ui 0.0.2 → 0.0.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.
@@ -0,0 +1,42 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import { Input } from ".";
3
+ /**
4
+ * Os inputs são usados em formulários, onde os usuários podem inserir informações e enviá-las.
5
+ * Este componente também funciona com os atributos nativos de um HTML input element.
6
+ */
7
+ declare const meta: Meta<typeof Input>;
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+ /**
11
+ * Variação padrão do Input quando apenas as propriedades obrigatórias são fornecidas.
12
+ */
13
+ export declare const Default: Story;
14
+ /**
15
+ * Utilizado quando o input deve ser desabilitado para impedir a edição pelo usuário.
16
+ */
17
+ export declare const Disabled: Story;
18
+ /**
19
+ * Indica um erro de validação para o usuário.
20
+ */
21
+ export declare const Error: Story;
22
+ /**
23
+ * Mensagem para auxiliar o usuário em determinadas situações.
24
+ */
25
+ export declare const HelpText: Story;
26
+ /**
27
+ * Indica sucesso de validação para o usuário.
28
+ */
29
+ export declare const Success: Story;
30
+ /**
31
+ * Variação do input com icone.
32
+ * ###### Observação: O ícone apresentado neste exemplo é utilizado apenas para fins ilustrativos e não representa necessariamente a funcionalidade ou o design final do componente.
33
+ */
34
+ export declare const WithIcon: Story;
35
+ /**
36
+ * Rótulo exibido acima do input.
37
+ */
38
+ export declare const TextField: Story;
39
+ /**
40
+ * Variação do input obrigatório.
41
+ */
42
+ export declare const Required: Story;
@@ -0,0 +1,135 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Input } from "./index.js";
3
+ import SearchIcon from "../../assets/SearchIcon.js";
4
+ const meta = {
5
+ title: "DESIGN COMPONENTS/Input",
6
+ component: Input,
7
+ tags: [
8
+ "autodocs"
9
+ ],
10
+ parameters: {
11
+ layout: "centered"
12
+ },
13
+ argTypes: {
14
+ disabled: {
15
+ description: "Define se o input est\xe1 desabilitado.",
16
+ table: {
17
+ defaultValue: {
18
+ summary: "false"
19
+ }
20
+ }
21
+ },
22
+ error: {
23
+ description: "Define se o input possui erros de valida\xe7\xe3o.",
24
+ table: {
25
+ defaultValue: {
26
+ summary: "false"
27
+ }
28
+ }
29
+ },
30
+ helpText: {
31
+ description: "Define o texto de ajuda abaixo do input. A cor muda se for uma mensagem de erro ou de sucesso"
32
+ },
33
+ success: {
34
+ description: "Define se os dados de entrada foram validados com sucesso.",
35
+ table: {
36
+ defaultValue: {
37
+ summary: "false"
38
+ }
39
+ }
40
+ },
41
+ width: {
42
+ table: {
43
+ disable: true
44
+ }
45
+ },
46
+ icon: {
47
+ control: {
48
+ type: "inline-radio"
49
+ },
50
+ description: "Define o \xedcone que ser\xe1 renderizado dentro do input.",
51
+ mapping: {
52
+ "sem icone": null,
53
+ "com icone": SearchIcon
54
+ },
55
+ options: [
56
+ "sem icone",
57
+ "com icone"
58
+ ]
59
+ },
60
+ textField: {
61
+ description: "Define o texto acima do input."
62
+ },
63
+ margin: {
64
+ table: {
65
+ disable: true
66
+ }
67
+ },
68
+ required: {
69
+ description: "Define se o input \xe9 obrigat\xf3rio.",
70
+ table: {
71
+ defaultValue: {
72
+ summary: "false"
73
+ }
74
+ }
75
+ },
76
+ placeholder: {
77
+ table: {
78
+ disable: true
79
+ }
80
+ }
81
+ }
82
+ };
83
+ const Input_stories = meta;
84
+ const Default = {
85
+ args: {
86
+ placeholder: "Default"
87
+ }
88
+ };
89
+ const Disabled = {
90
+ args: {
91
+ placeholder: "Disabled",
92
+ disabled: true
93
+ }
94
+ };
95
+ const Error = {
96
+ args: {
97
+ placeholder: "Error",
98
+ error: true,
99
+ helpText: "Mensagem de Erro"
100
+ }
101
+ };
102
+ const HelpText = {
103
+ args: {
104
+ placeholder: "helpText",
105
+ helpText: "Help Text"
106
+ }
107
+ };
108
+ const Success = {
109
+ args: {
110
+ placeholder: "Success",
111
+ success: true,
112
+ helpText: "Mensagem de Sucesso"
113
+ }
114
+ };
115
+ const WithIcon = {
116
+ args: {
117
+ placeholder: "Icon",
118
+ icon: /*#__PURE__*/ jsx(SearchIcon, {})
119
+ }
120
+ };
121
+ const TextField = {
122
+ args: {
123
+ placeholder: "TextField",
124
+ textField: "Text Field"
125
+ }
126
+ };
127
+ const Required = {
128
+ args: {
129
+ placeholder: "Required",
130
+ required: true,
131
+ textField: "Required",
132
+ margin: ""
133
+ }
134
+ };
135
+ export { Default, Disabled, Error, HelpText, Required, Success, TextField, WithIcon, Input_stories as default };
@@ -0,0 +1,14 @@
1
+ import React, { InputHTMLAttributes, JSX } from "react";
2
+ import { IconsNames } from "@ftdata/f-icons";
3
+ export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
4
+ disabled?: boolean;
5
+ error?: boolean;
6
+ helpText?: string;
7
+ success?: boolean;
8
+ width?: string | number;
9
+ icon: IconsNames | JSX.Element;
10
+ textField?: string;
11
+ margin?: string;
12
+ required?: boolean;
13
+ }
14
+ export declare const Input: React.FC<InputProps>;
@@ -0,0 +1,53 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import "react";
3
+ import { Container, ContainerTextField, DivIcon, HelpText, InputContainer, InputControl, TextField } from "./styles.js";
4
+ import DoneCircleIcon from "../../assets/DoneCircleIcon.js";
5
+ import CancelSquareIcon from "../../assets/CancelSquareIcon.js";
6
+ import { Icon } from "@ftdata/f-icons";
7
+ const Input = ({ disabled, error, helpText, name, success, width, icon, textField, margin, required, ...rest })=>/*#__PURE__*/ jsxs(Container, {
8
+ margin: margin,
9
+ children: [
10
+ textField && /*#__PURE__*/ jsxs(ContainerTextField, {
11
+ children: [
12
+ /*#__PURE__*/ jsx(TextField, {
13
+ children: textField
14
+ }),
15
+ required && /*#__PURE__*/ jsx("div", {
16
+ className: "required",
17
+ children: "*"
18
+ })
19
+ ]
20
+ }),
21
+ /*#__PURE__*/ jsxs(InputContainer, {
22
+ width: width,
23
+ error: error,
24
+ success: success,
25
+ disabled: disabled,
26
+ children: [
27
+ icon && /*#__PURE__*/ jsxs(DivIcon, {
28
+ children: [
29
+ "string" == typeof icon && /*#__PURE__*/ jsx(Icon, {
30
+ name: icon
31
+ }),
32
+ "object" == typeof icon && icon
33
+ ]
34
+ }),
35
+ /*#__PURE__*/ jsx(InputControl, {
36
+ ...rest,
37
+ disabled: disabled,
38
+ id: name
39
+ })
40
+ ]
41
+ }),
42
+ helpText && /*#__PURE__*/ jsxs(HelpText, {
43
+ disabled: disabled,
44
+ error: error,
45
+ success: success,
46
+ children: [
47
+ !disabled && error && /*#__PURE__*/ jsx(CancelSquareIcon, {}) || success && /*#__PURE__*/ jsx(DoneCircleIcon, {}),
48
+ helpText
49
+ ]
50
+ })
51
+ ]
52
+ });
53
+ export { Input };
@@ -0,0 +1,17 @@
1
+ import { Component } from "react";
2
+ import type { InputProps } from "./index";
3
+ export declare const ContainerTextField: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const TextField: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
5
+ export declare const Container: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Partial<InputProps>>> & string;
6
+ export declare const InputContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Partial<InputProps>>> & string;
7
+ export declare const DivIcon: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
+ export declare class ReactInputMask extends Component<InputProps> {
9
+ }
10
+ export declare const InputControl: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
11
+ interface HelpTextProps extends React.AllHTMLAttributes<HTMLSpanElement> {
12
+ disabled?: boolean;
13
+ error?: boolean;
14
+ success?: boolean;
15
+ }
16
+ export declare const HelpText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, HelpTextProps>> & string;
17
+ export {};
@@ -0,0 +1,96 @@
1
+ import styled_components from "styled-components";
2
+ import { BORDER_RADIUS_SM, COLOR_ACCENT_MEDIUM, COLOR_DANGER_MEDIUM, COLOR_NEUTRAL_DARK, COLOR_NEUTRAL_DAY, COLOR_NEUTRAL_DUSK, COLOR_NEUTRAL_LIGHT, COLOR_NEUTRAL_LIGHTER, COLOR_NEUTRAL_MEDIUM, COLOR_SUCCESS_DARK, COLOR_SUCCESS_MEDIUM, FONT_FAMILY_01, FONT_SIZE_MD, FONT_SIZE_SM, FONT_SIZE_XS, FONT_WEIGHT_BOLD, FONT_WEIGHT_MEDIUM, LINE_HEIGHT_MEDIUM, SPACING_INLINE_01, SPACING_INLINE_02, SPACING_INSET_SM, SPACING_SQUISH_NANO, SPACING_STACK_02 } from "@ftdata/f-tokens";
3
+ import { Component } from "react";
4
+ const ContainerTextField = styled_components.div`
5
+ display: flex;
6
+ margin-bottom: ${SPACING_STACK_02};
7
+ gap: 4px;
8
+
9
+ .required {
10
+ color: ${COLOR_DANGER_MEDIUM};
11
+ }
12
+ `;
13
+ const TextField = styled_components.span`
14
+ font-weight: ${FONT_WEIGHT_BOLD};
15
+ font-size: ${FONT_SIZE_SM};
16
+ color: ${COLOR_NEUTRAL_DUSK};
17
+ font-family: "Inter";
18
+ `;
19
+ const Container = styled_components.div`
20
+ display: flex;
21
+ flex-direction: column;
22
+ box-sizing: border-box;
23
+ margin: ${({ margin })=>margin};
24
+
25
+ .required {
26
+ color: ${COLOR_DANGER_MEDIUM};
27
+ }
28
+ `;
29
+ const InputContainer = styled_components.div`
30
+ display: flex;
31
+ align-items: center;
32
+ width: ${({ width })=>width ? width : "230px"};
33
+ background-color: ${({ disabled })=>disabled ? COLOR_NEUTRAL_LIGHTER : COLOR_NEUTRAL_DAY};
34
+ border-radius: ${BORDER_RADIUS_SM};
35
+ border-width: 1px;
36
+ border-style: solid;
37
+ border-color: ${({ disabled, error, success })=>disabled && COLOR_NEUTRAL_LIGHT || error && COLOR_DANGER_MEDIUM || success && COLOR_SUCCESS_MEDIUM || COLOR_NEUTRAL_MEDIUM};
38
+ padding: ${SPACING_SQUISH_NANO};
39
+ height: 40px;
40
+
41
+ &:focus-within {
42
+ border: 1.5px solid ${COLOR_ACCENT_MEDIUM};
43
+ transition: all 0.2s linear ease-in;
44
+ }
45
+
46
+ &,
47
+ input {
48
+ cursor: ${({ disabled })=>disabled ? "not-allowed" : "initial"};
49
+ }
50
+
51
+ svg {
52
+ color: ${({ disabled })=>disabled ? COLOR_NEUTRAL_LIGHT : COLOR_NEUTRAL_DARK};
53
+ }
54
+ `;
55
+ const DivIcon = styled_components.div`
56
+ width: ${SPACING_INSET_SM};
57
+ height: ${SPACING_INSET_SM};
58
+ margin-right: ${SPACING_INLINE_02};
59
+ `;
60
+ class ReactInputMask extends Component {
61
+ }
62
+ const InputControl = styled_components.input`
63
+ border: none;
64
+ box-sizing: border-box;
65
+ color: ${COLOR_NEUTRAL_DUSK};
66
+ font-family: ${FONT_FAMILY_01};
67
+ font-weight: ${FONT_WEIGHT_MEDIUM};
68
+ font-size: ${FONT_SIZE_MD};
69
+ line-height: ${LINE_HEIGHT_MEDIUM};
70
+ width: 100%;
71
+ background: transparent;
72
+ outline: none;
73
+
74
+ ::placeholder {
75
+ color: ${({ disabled })=>disabled ? COLOR_NEUTRAL_LIGHT : COLOR_NEUTRAL_MEDIUM};
76
+ }
77
+ `;
78
+ const HelpText = styled_components("span")`
79
+ align-items: center;
80
+ box-sizing: border-box;
81
+ color: ${({ disabled, error, success })=>disabled && COLOR_NEUTRAL_MEDIUM || error && COLOR_DANGER_MEDIUM || success && COLOR_SUCCESS_DARK || COLOR_NEUTRAL_DARK};
82
+ display: flex;
83
+ font-family: ${FONT_FAMILY_01};
84
+ font-weight: ${FONT_WEIGHT_MEDIUM};
85
+ line-height: ${LINE_HEIGHT_MEDIUM};
86
+ font-size: ${FONT_SIZE_XS};
87
+ margin-top: 8px;
88
+
89
+ svg {
90
+ margin-right: ${SPACING_INLINE_01};
91
+ path {
92
+ stroke: ${({ error, success })=>error && COLOR_DANGER_MEDIUM || success && COLOR_SUCCESS_MEDIUM || COLOR_NEUTRAL_DARK};
93
+ }
94
+ }
95
+ `;
96
+ export { Container, ContainerTextField, DivIcon, HelpText, InputContainer, InputControl, ReactInputMask, TextField };
@@ -0,0 +1,3 @@
1
+ export type ColorFeedbackType = "success" | "warning" | "danger" | "info" | "neutral";
2
+ export type StateFeedbackType = "loading" | "disabled" | "pending" | "success" | "error";
3
+ export type FeedbackType = ColorFeedbackType | StateFeedbackType;
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftdata/ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -28,7 +28,7 @@
28
28
  "react-input-mask-next": "3.0.0-alpha.12",
29
29
  "react-select": "^5.10.2",
30
30
  "react-window": "^1.8.11",
31
- "@ftdata/f-icons": "0.0.1",
31
+ "@ftdata/f-icons": "0.0.2",
32
32
  "@ftdata/f-tokens": "0.0.1"
33
33
  },
34
34
  "publishConfig": {