w-design-system 0.0.46 → 0.0.47

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,20 @@
1
+ import React, { HTMLAttributes, ReactNode } from 'react';
2
+ export interface InputProps extends HTMLAttributes<HTMLDivElement> {
3
+ placeholder?: string;
4
+ rightIcon?: ReactNode;
5
+ leftIcon?: ReactNode;
6
+ label?: string;
7
+ readonly?: boolean;
8
+ disabled?: boolean;
9
+ value?: string;
10
+ tags: string[];
11
+ setTags: (tags: string[]) => void;
12
+ }
13
+ export interface Position {
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ }
19
+ export declare const InputTag: React.FC<InputProps>;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InputTag/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAE,SAAS,EAAmD,MAAM,OAAO,CAAA;AAKzG,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,cAAc,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;CAClC;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAuHzC,CAAA"}
@@ -0,0 +1,95 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
13
+ import { InputWrapper, StyledInput, StyledInputBorder, StyledInputContent, StyledLabel } from './styles';
14
+ import { Paragraph } from '../Paragraph';
15
+ import { theme } from '../Themes';
16
+ export const InputTag = (_a) => {
17
+ var { label, readonly, disabled, leftIcon, rightIcon, tags, setTags, placeholder } = _a, props = __rest(_a, ["label", "readonly", "disabled", "leftIcon", "rightIcon", "tags", "setTags", "placeholder"]);
18
+ const id = useId();
19
+ const contentRef = useRef(null);
20
+ const labelRef = useRef(null);
21
+ const inputRef = useRef(null);
22
+ const [inputValue, setInputValue] = useState('');
23
+ const [labelPosition, setLabelPosition] = useState({
24
+ x: 0,
25
+ y: 0,
26
+ width: 0,
27
+ height: 0,
28
+ });
29
+ const [contentPosition, setContentPosition] = useState({
30
+ x: 0,
31
+ y: 0,
32
+ width: 0,
33
+ height: 0,
34
+ });
35
+ const updatePositions = useCallback(() => {
36
+ const margin = 30;
37
+ if (contentRef.current) {
38
+ setContentPosition({
39
+ x: contentRef.current.offsetLeft - margin,
40
+ y: contentRef.current.offsetTop - margin,
41
+ width: contentRef.current.offsetWidth + margin * 2,
42
+ height: contentRef.current.offsetHeight + margin * 2,
43
+ });
44
+ }
45
+ if (labelRef.current) {
46
+ setLabelPosition({
47
+ x: labelRef.current.offsetLeft,
48
+ y: labelRef.current.offsetTop,
49
+ width: labelRef.current.offsetWidth,
50
+ height: labelRef.current.offsetHeight,
51
+ });
52
+ }
53
+ }, []);
54
+ useEffect(() => {
55
+ updatePositions();
56
+ }, [label, updatePositions]);
57
+ const addTag = (e) => {
58
+ var _a;
59
+ if (e)
60
+ e.stopPropagation();
61
+ if (inputValue.trim() && !tags.includes(inputValue.trim())) {
62
+ setTags([...tags, inputValue.trim()]);
63
+ setInputValue('');
64
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
65
+ }
66
+ };
67
+ const removeTag = (tagToRemove) => {
68
+ setTags(tags.filter(tag => tag !== tagToRemove));
69
+ };
70
+ const handleContainerClick = (e) => {
71
+ var _a;
72
+ (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
73
+ e.stopPropagation();
74
+ };
75
+ return (React.createElement(React.Fragment, null,
76
+ React.createElement(InputWrapper, Object.assign({}, props),
77
+ React.createElement(StyledInputContent, { disabled: disabled, ref: contentRef, onClick: e => handleContainerClick(e) },
78
+ React.createElement(StyledInputBorder, { content: contentPosition, label: labelPosition }),
79
+ React.createElement(StyledLabel, { htmlFor: id, ref: labelRef }, label),
80
+ leftIcon,
81
+ React.createElement(StyledInput, { id: id, disabled: disabled, ref: inputRef, value: inputValue, onChange: e => setInputValue(e.target.value), placeholder: placeholder, onKeyDown: e => {
82
+ if (e.key === 'Enter') {
83
+ e.preventDefault();
84
+ addTag();
85
+ }
86
+ }, readOnly: readonly }),
87
+ rightIcon),
88
+ React.createElement("button", { className: 'button-action', onClick: e => addTag(e) },
89
+ React.createElement(Paragraph, { color: theme.colors.cyan30 }, "add")),
90
+ React.createElement("div", { className: 'container-input-tag' }, tags.map((tag, index) => (React.createElement("button", { className: 'wrapper-tag', key: index },
91
+ React.createElement(Paragraph, { color: theme.colors.cyan30 }, tag),
92
+ React.createElement("button", { onClick: () => removeTag(tag) },
93
+ React.createElement(Paragraph, { color: theme.colors.shade40 }, "x")))))))));
94
+ };
95
+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C;oBACH,CAAC,EACD,QAAQ,EAAE,QAAQ,GAClB;gBAED,SAAS,CACS;YACrB,gCAAQ,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;gBACzD,oBAAC,SAAS,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,UAAiB,CAC/C;YACT,6BAAK,SAAS,EAAE,qBAAqB,IAClC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CACxB,gCAAQ,SAAS,EAAE,aAAa,EAAE,GAAG,EAAE,KAAK;gBAC1C,oBAAC,SAAS,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,IAAG,GAAG,CAAa;gBACxD,gCAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC;oBACnC,oBAAC,SAAS,IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,QAAe,CAC9C,CACF,CACV,CAAC,CACE,CACO,CACd,CACJ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { InputTag } from './index';
3
+ declare const meta: Meta<typeof InputTag>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof InputTag>;
6
+ export declare const Playground: Story;
7
+ //# sourceMappingURL=stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stories.d.ts","sourceRoot":"","sources":["../../../src/components/InputTag/stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,QAAQ,CAS/B,CAAA;AAED,eAAe,IAAI,CAAA;AACnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,QAAQ,CAAC,CAAA;AAQtC,eAAO,MAAM,UAAU,EAAE,KAMxB,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { InputTag } from './index';
2
+ import React, { useState } from 'react';
3
+ const meta = {
4
+ title: 'Components/InputTag',
5
+ component: InputTag,
6
+ argTypes: {
7
+ placeholder: { control: 'text' },
8
+ label: { control: 'text' },
9
+ readonly: { control: 'boolean' },
10
+ disabled: { control: 'boolean' },
11
+ },
12
+ };
13
+ export default meta;
14
+ const Template = (args) => {
15
+ const [tags, setTags] = useState(['Tag1', 'Tag2']);
16
+ return React.createElement(InputTag, Object.assign({}, args, { tags: tags, setTags: setTags }));
17
+ };
18
+ export const Playground = {
19
+ render: args => React.createElement(Template, Object.assign({}, args)),
20
+ args: {
21
+ label: 'Label',
22
+ placeholder: 'Digite uma tag',
23
+ },
24
+ };
25
+ //# sourceMappingURL=stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stories.js","sourceRoot":"","sources":["../../../src/components/InputTag/stories.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,IAAI,GAA0B;IAClC,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE;QACR,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QAC1B,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;QAChC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;KACjC;CACF,CAAA;AAED,eAAe,IAAI,CAAA;AAGnB,MAAM,QAAQ,GAAG,CAAC,IAAS,EAAE,EAAE;IAC7B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAE5D,OAAO,oBAAC,QAAQ,oBAAK,IAAI,IAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,CAAA;AAC7D,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,oBAAC,QAAQ,oBAAK,IAAI,EAAI;IACtC,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,gBAAgB;KAC9B;CACF,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { Position } from '.';
2
+ export declare const InputWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
3
+ export declare const StyledInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, never>> & string;
4
+ export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
5
+ export interface StyledInputContentProps {
6
+ disabled?: boolean;
7
+ }
8
+ export declare const StyledInputContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputContentProps>> & string;
9
+ export interface StyledInputBorderProps {
10
+ label: Position;
11
+ content: Position;
12
+ }
13
+ /**
14
+ * O clip-path faz com que o elemento fique transparente na região do label
15
+ * @see https://stackoverflow.com/questions/3742479/how-to-cut-a-hole-in-an-svg-rectangle
16
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
17
+ */
18
+ export declare const StyledInputBorder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledInputBorderProps>> & string;
19
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/InputTag/styles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAA;AAEjC,eAAO,MAAM,YAAY,6NA4CxB,CAAA;AAED,eAAO,MAAM,WAAW,sOA4BvB,CAAA;AAED,eAAO,MAAM,WAAW,sOAavB,CAAA;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,kBAAkB,4PAiB9B,CAAA;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,QAAQ,CAAA;IACf,OAAO,EAAE,QAAQ,CAAA;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,2PAc7B,CAAA"}
@@ -0,0 +1,127 @@
1
+ import styled from 'styled-components';
2
+ import { theme } from '../Themes';
3
+ export const InputWrapper = styled.div `
4
+ position: relative;
5
+ border-radius: 4px;
6
+ .button-action {
7
+ position: absolute;
8
+ right: 0;
9
+ top: 1px;
10
+ display: flex;
11
+ align-items: center;
12
+ padding: 18px;
13
+ height: 52px;
14
+ border-radius: 4px;
15
+ background: ${theme.colors.shade10};
16
+ border: none;
17
+ cursor: pointer;
18
+ }
19
+ .container-input-tag {
20
+ display: flex;
21
+ gap: 16px;
22
+ margin-top: 8px;
23
+
24
+ button {
25
+ background: none;
26
+ border: none;
27
+ cursor: pointer;
28
+ display: flex;
29
+ justify-content: center;
30
+ gap: 8px;
31
+
32
+ p {
33
+ margin-top: 2px;
34
+ }
35
+ }
36
+
37
+ .wrapper-tag {
38
+ background: ${theme.colors.cyan10};
39
+ display: flex;
40
+
41
+ gap: 8px;
42
+ flex-wrap: wrap;
43
+ border-radius: 4px;
44
+ padding: 4px 8px;
45
+ }
46
+ }
47
+ `;
48
+ export const StyledInput = styled.input `
49
+ width: 100%;
50
+
51
+ background-color: transparent;
52
+ border: none;
53
+ outline: none;
54
+
55
+ color: ${theme.colors.shade50};
56
+
57
+ font-family: ${theme.fonts.join(', ')};
58
+ font-size: ${theme.paragraph.medium};
59
+
60
+ &:active,
61
+ &:focus {
62
+ outline: none;
63
+ border: none;
64
+ }
65
+
66
+ &::placeholder {
67
+ color: ${theme.colors.shade30};
68
+ font-size: ${theme.paragraph.medium};
69
+ opacity: 1;
70
+ }
71
+
72
+ &:disabled {
73
+ background-color: transparent;
74
+ cursor: not-allowed;
75
+ }
76
+ `;
77
+ export const StyledLabel = styled.label `
78
+ position: absolute;
79
+ color: ${theme.colors.shade50};
80
+
81
+ box-sizing: content-box;
82
+ left: 15px;
83
+ top: -8px;
84
+ padding: 0 1px;
85
+
86
+ font-family: 'Nunito Sans', sans-serif;
87
+ font-size: ${theme.paragraph.small};
88
+ font-weight: 600;
89
+ text-wrap: nowrap;
90
+ `;
91
+ export const StyledInputContent = styled.div `
92
+ position: relative;
93
+
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: space-between;
97
+
98
+ box-sizing: content-box;
99
+ padding: 18px 16px 14px 16px;
100
+ height: 22px;
101
+ gap: 8px;
102
+ border-radius: 4px;
103
+
104
+ background-color: ${({ disabled }) => disabled ? theme.colors.shade10 : theme.colors.white};
105
+
106
+ cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
107
+ `;
108
+ /**
109
+ * O clip-path faz com que o elemento fique transparente na região do label
110
+ * @see https://stackoverflow.com/questions/3742479/how-to-cut-a-hole-in-an-svg-rectangle
111
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
112
+ */
113
+ export const StyledInputBorder = styled.div `
114
+ position: absolute;
115
+
116
+ box-sizing: content-box;
117
+ inset: 0px;
118
+ border-radius: 4px;
119
+ border: 1px solid ${theme.colors.shade20};
120
+ clip-rule: evenodd;
121
+ clip-path: path(
122
+ '${({ label, content }) => label.height !== 0 && label.width !== 0
123
+ ? `M ${content.x} ${content.y} l ${content.width} 0 l 0 ${content.height} l -${content.width} 0z M ${label.x} ${label.y} l 0 ${label.height} l ${label.width} 0 l 0 -${label.height}z`
124
+ : ''}'
125
+ );
126
+ `;
127
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/InputTag/styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAGjC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;kBAYpB,KAAK,CAAC,MAAM,CAAC,OAAO;;;;;;;;;;;;;;;;;;;;;;;oBAuBlB,KAAK,CAAC,MAAM,CAAC,MAAM;;;;;;;;;CAStC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;;;;;;WAO5B,KAAK,CAAC,MAAM,CAAC,OAAO;;iBAEd,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;eACxB,KAAK,CAAC,SAAS,CAAC,MAAM;;;;;;;;;aASxB,KAAK,CAAC,MAAM,CAAC,OAAO;iBAChB,KAAK,CAAC,SAAS,CAAC,MAAM;;;;;;;;CAQtC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;;WAE5B,KAAK,CAAC,MAAM,CAAC,OAAO;;;;;;;;eAQhB,KAAK,CAAC,SAAS,CAAC,KAAK;;;CAGnC,CAAA;AAMD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAyB;;;;;;;;;;;;;sBAa/C,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAC5D,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;;YAE5C,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;CAC5F,CAAA;AAOD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAwB;;;;;;sBAM7C,KAAK,CAAC,MAAM,CAAC,OAAO;;;OAGnC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CACxB,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,KAAK,CAAC;IACrC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,UAAU,OAAO,CAAC,MAAM,OAAO,OAAO,CAAC,KAAK,SAAS,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,KAAK,WAAW,KAAK,CAAC,MAAM,GAAG;IACtL,CAAC,CAAC,EAAE;;CAEX,CAAA"}
@@ -12,4 +12,5 @@ export { Paginate } from './Paginate/index';
12
12
  export { Table } from './Table/index';
13
13
  export { Input } from './Input/index';
14
14
  export { EmptyState } from './EmptyState/index';
15
+ export { InputTag } from './InputTag/index';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC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AAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
@@ -12,4 +12,5 @@ export { Paginate } from './Paginate/index';
12
12
  export { Table } from './Table/index';
13
13
  export { Input } from './Input/index';
14
14
  export { EmptyState } from './EmptyState/index';
15
+ export { InputTag } from './InputTag/index';
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export { Tabs } from './components/Tabs/index';
17
17
  export { theme } from './components/Themes/index';
18
18
  export { Title } from './components/Title/index';
19
19
  export { EmptyState } from './components/EmptyState/index';
20
+ export { InputTag } from './components/InputTag/index';
20
21
  export * from './components/Types/index';
21
22
  export { alertSVG, appsSVG, bellSVG, bindSVG, bookmarkSVG, calendarSVG, checkSVG, chevronDownSVG, chevronLeftSVG, chevronRightSVG, closeSVG, commentSVG, dashboardSVG, docCheckSVG, docDownloadSVG, docSVG, docUploadSVG, dumpSVG, editSVG, editalSVG, eyesSVG, fileSVG, financeSVG, gearSVG, grid2PlusSVG, imageSVG, moneySVG, monitoringSVG, orderSVG, portalSVG, settingSVG, spinSVG, spreadsheetSVG, wavePulseSVG, } from './assets/icon/index';
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],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;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,cAAc,0BAA0B,CAAA;AAExC,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,MAAM,EACN,YAAY,EACZ,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ export { Tabs } from './components/Tabs/index';
17
17
  export { theme } from './components/Themes/index';
18
18
  export { Title } from './components/Title/index';
19
19
  export { EmptyState } from './components/EmptyState/index';
20
+ export { InputTag } from './components/InputTag/index';
20
21
  export * from './components/Types/index';
21
22
  export { alertSVG, appsSVG, bellSVG, bindSVG, bookmarkSVG, calendarSVG, checkSVG, chevronDownSVG, chevronLeftSVG, chevronRightSVG, closeSVG, commentSVG, dashboardSVG, docCheckSVG, docDownloadSVG, docSVG, docUploadSVG, dumpSVG, editSVG, editalSVG, eyesSVG, fileSVG, financeSVG, gearSVG, grid2PlusSVG, imageSVG, moneySVG, monitoringSVG, orderSVG, portalSVG, settingSVG, spinSVG, spreadsheetSVG, wavePulseSVG, } from './assets/icon/index';
22
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO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P,OAAO,EACP,WAAW,EACX,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EACd,eAAe,EACf,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,cAAc,EACd,MAAM,EACN,YAAY,EACZ,OAAO,EACP,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,UAAU,EACV,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,SAAS,EACT,UAAU,EACV,OAAO,EACP,cAAc,EACd,YAAY,GACb,MAAM,qBAAqB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-design-system",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -0,0 +1,144 @@
1
+ import React, { HTMLAttributes, ReactNode, useCallback, useEffect, useId, useRef, useState } from 'react'
2
+ import { InputWrapper, StyledInput, StyledInputBorder, StyledInputContent, StyledLabel } from './styles'
3
+ import { Paragraph } from '../Paragraph'
4
+ import { theme } from '../Themes'
5
+
6
+ export interface InputProps extends HTMLAttributes<HTMLDivElement> {
7
+ placeholder?: string
8
+ rightIcon?: ReactNode
9
+ leftIcon?: ReactNode
10
+ label?: string
11
+ readonly?: boolean
12
+ disabled?: boolean
13
+ value?: string
14
+ tags: string[]
15
+ setTags: (tags: string[]) => void
16
+ }
17
+
18
+ export interface Position {
19
+ x: number
20
+ y: number
21
+ width: number
22
+ height: number
23
+ }
24
+
25
+ export const InputTag: React.FC<InputProps> = ({
26
+ label,
27
+ readonly,
28
+ disabled,
29
+ leftIcon,
30
+ rightIcon,
31
+ tags,
32
+ setTags,
33
+ placeholder,
34
+ ...props
35
+ }) => {
36
+ const id = useId()
37
+ const contentRef = useRef<HTMLDivElement>(null)
38
+ const labelRef = useRef<HTMLLabelElement>(null)
39
+ const inputRef = useRef<HTMLInputElement>(null)
40
+ const [inputValue, setInputValue] = useState('')
41
+
42
+ const [labelPosition, setLabelPosition] = useState<Position>({
43
+ x: 0,
44
+ y: 0,
45
+ width: 0,
46
+ height: 0,
47
+ })
48
+ const [contentPosition, setContentPosition] = useState<Position>({
49
+ x: 0,
50
+ y: 0,
51
+ width: 0,
52
+ height: 0,
53
+ })
54
+
55
+ const updatePositions = useCallback(() => {
56
+ const margin = 30
57
+ if (contentRef.current) {
58
+ setContentPosition({
59
+ x: contentRef.current.offsetLeft - margin,
60
+ y: contentRef.current.offsetTop - margin,
61
+ width: contentRef.current.offsetWidth + margin * 2,
62
+ height: contentRef.current.offsetHeight + margin * 2,
63
+ })
64
+ }
65
+ if (labelRef.current) {
66
+ setLabelPosition({
67
+ x: labelRef.current.offsetLeft,
68
+ y: labelRef.current.offsetTop,
69
+ width: labelRef.current.offsetWidth,
70
+ height: labelRef.current.offsetHeight,
71
+ })
72
+ }
73
+ }, [])
74
+
75
+ useEffect(() => {
76
+ updatePositions()
77
+ }, [label, updatePositions])
78
+
79
+ const addTag = (e?: React.MouseEvent<HTMLButtonElement>) => {
80
+ if (e) e.stopPropagation()
81
+ if (inputValue.trim() && !tags.includes(inputValue.trim())) {
82
+ setTags([...tags, inputValue.trim()])
83
+ setInputValue('')
84
+ inputRef.current?.focus()
85
+ }
86
+ }
87
+
88
+ const removeTag = (tagToRemove: string) => {
89
+ setTags(tags.filter(tag => tag !== tagToRemove))
90
+ }
91
+
92
+ const handleContainerClick = (e: React.MouseEvent<HTMLDivElement>) => {
93
+ inputRef.current?.focus()
94
+ e.stopPropagation()
95
+ }
96
+
97
+ return (
98
+ <>
99
+ {/* ✅ Mantendo a borda dinâmica com ref */}
100
+ <InputWrapper {...props}>
101
+ <StyledInputContent disabled={disabled} ref={contentRef} onClick={e => handleContainerClick(e)}>
102
+ {/* ✅ Mantendo a borda dinâmica */}
103
+ <StyledInputBorder content={contentPosition} label={labelPosition} />
104
+ <StyledLabel htmlFor={id} ref={labelRef}>
105
+ {label}
106
+ </StyledLabel>
107
+ {leftIcon}
108
+
109
+ {/* ✅ Input controlado e foco garantido */}
110
+ <StyledInput
111
+ id={id}
112
+ disabled={disabled}
113
+ ref={inputRef}
114
+ value={inputValue}
115
+ onChange={e => setInputValue(e.target.value)}
116
+ placeholder={placeholder}
117
+ onKeyDown={e => {
118
+ if (e.key === 'Enter') {
119
+ e.preventDefault()
120
+ addTag()
121
+ }
122
+ }}
123
+ readOnly={readonly}
124
+ />
125
+
126
+ {rightIcon}
127
+ </StyledInputContent>
128
+ <button className={'button-action'} onClick={e => addTag(e)}>
129
+ <Paragraph color={theme.colors.cyan30}>add</Paragraph>
130
+ </button>
131
+ <div className={'container-input-tag'}>
132
+ {tags.map((tag, index) => (
133
+ <button className={'wrapper-tag'} key={index}>
134
+ <Paragraph color={theme.colors.cyan30}>{tag}</Paragraph>
135
+ <button onClick={() => removeTag(tag)}>
136
+ <Paragraph color={theme.colors.shade40}>x</Paragraph>
137
+ </button>
138
+ </button>
139
+ ))}
140
+ </div>
141
+ </InputWrapper>
142
+ </>
143
+ )
144
+ }
@@ -0,0 +1,31 @@
1
+ import { Meta, StoryObj } from '@storybook/react'
2
+ import { InputTag } from './index'
3
+ import React, { useState } from 'react'
4
+
5
+ const meta: Meta<typeof InputTag> = {
6
+ title: 'Components/InputTag',
7
+ component: InputTag,
8
+ argTypes: {
9
+ placeholder: { control: 'text' },
10
+ label: { control: 'text' },
11
+ readonly: { control: 'boolean' },
12
+ disabled: { control: 'boolean' },
13
+ },
14
+ }
15
+
16
+ export default meta
17
+ type Story = StoryObj<typeof InputTag>
18
+
19
+ const Template = (args: any) => {
20
+ const [tags, setTags] = useState<string[]>(['Tag1', 'Tag2'])
21
+
22
+ return <InputTag {...args} tags={tags} setTags={setTags} />
23
+ }
24
+
25
+ export const Playground: Story = {
26
+ render: args => <Template {...args} />,
27
+ args: {
28
+ label: 'Label',
29
+ placeholder: 'Digite uma tag',
30
+ },
31
+ }
@@ -0,0 +1,143 @@
1
+ import styled from 'styled-components'
2
+ import { theme } from '../Themes'
3
+ import type { Position } from '.'
4
+
5
+ export const InputWrapper = styled.div`
6
+ position: relative;
7
+ border-radius: 4px;
8
+ .button-action {
9
+ position: absolute;
10
+ right: 0;
11
+ top: 1px;
12
+ display: flex;
13
+ align-items: center;
14
+ padding: 18px;
15
+ height: 52px;
16
+ border-radius: 4px;
17
+ background: ${theme.colors.shade10};
18
+ border: none;
19
+ cursor: pointer;
20
+ }
21
+ .container-input-tag {
22
+ display: flex;
23
+ gap: 16px;
24
+ margin-top: 8px;
25
+
26
+ button {
27
+ background: none;
28
+ border: none;
29
+ cursor: pointer;
30
+ display: flex;
31
+ justify-content: center;
32
+ gap: 8px;
33
+
34
+ p {
35
+ margin-top: 2px;
36
+ }
37
+ }
38
+
39
+ .wrapper-tag {
40
+ background: ${theme.colors.cyan10};
41
+ display: flex;
42
+
43
+ gap: 8px;
44
+ flex-wrap: wrap;
45
+ border-radius: 4px;
46
+ padding: 4px 8px;
47
+ }
48
+ }
49
+ `
50
+
51
+ export const StyledInput = styled.input`
52
+ width: 100%;
53
+
54
+ background-color: transparent;
55
+ border: none;
56
+ outline: none;
57
+
58
+ color: ${theme.colors.shade50};
59
+
60
+ font-family: ${theme.fonts.join(', ')};
61
+ font-size: ${theme.paragraph.medium};
62
+
63
+ &:active,
64
+ &:focus {
65
+ outline: none;
66
+ border: none;
67
+ }
68
+
69
+ &::placeholder {
70
+ color: ${theme.colors.shade30};
71
+ font-size: ${theme.paragraph.medium};
72
+ opacity: 1;
73
+ }
74
+
75
+ &:disabled {
76
+ background-color: transparent;
77
+ cursor: not-allowed;
78
+ }
79
+ `
80
+
81
+ export const StyledLabel = styled.label`
82
+ position: absolute;
83
+ color: ${theme.colors.shade50};
84
+
85
+ box-sizing: content-box;
86
+ left: 15px;
87
+ top: -8px;
88
+ padding: 0 1px;
89
+
90
+ font-family: 'Nunito Sans', sans-serif;
91
+ font-size: ${theme.paragraph.small};
92
+ font-weight: 600;
93
+ text-wrap: nowrap;
94
+ `
95
+
96
+ export interface StyledInputContentProps {
97
+ disabled?: boolean
98
+ }
99
+
100
+ export const StyledInputContent = styled.div<StyledInputContentProps>`
101
+ position: relative;
102
+
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: space-between;
106
+
107
+ box-sizing: content-box;
108
+ padding: 18px 16px 14px 16px;
109
+ height: 22px;
110
+ gap: 8px;
111
+ border-radius: 4px;
112
+
113
+ background-color: ${({ disabled }: StyledInputContentProps) =>
114
+ disabled ? theme.colors.shade10 : theme.colors.white};
115
+
116
+ cursor: ${({ disabled }: StyledInputContentProps) => (disabled ? 'not-allowed' : 'pointer')};
117
+ `
118
+
119
+ export interface StyledInputBorderProps {
120
+ label: Position
121
+ content: Position
122
+ }
123
+
124
+ /**
125
+ * O clip-path faz com que o elemento fique transparente na região do label
126
+ * @see https://stackoverflow.com/questions/3742479/how-to-cut-a-hole-in-an-svg-rectangle
127
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d
128
+ */
129
+ export const StyledInputBorder = styled.div<StyledInputBorderProps>`
130
+ position: absolute;
131
+
132
+ box-sizing: content-box;
133
+ inset: 0px;
134
+ border-radius: 4px;
135
+ border: 1px solid ${theme.colors.shade20};
136
+ clip-rule: evenodd;
137
+ clip-path: path(
138
+ '${({ label, content }) =>
139
+ label.height !== 0 && label.width !== 0
140
+ ? `M ${content.x} ${content.y} l ${content.width} 0 l 0 ${content.height} l -${content.width} 0z M ${label.x} ${label.y} l 0 ${label.height} l ${label.width} 0 l 0 -${label.height}z`
141
+ : ''}'
142
+ );
143
+ `
@@ -12,3 +12,4 @@ export { Paginate } from './Paginate/index'
12
12
  export { Table } from './Table/index'
13
13
  export { Input } from './Input/index'
14
14
  export { EmptyState } from './EmptyState/index'
15
+ export { InputTag } from './InputTag/index'
package/src/index.tsx CHANGED
@@ -17,6 +17,7 @@ export { Tabs } from './components/Tabs/index'
17
17
  export { theme } from './components/Themes/index'
18
18
  export { Title } from './components/Title/index'
19
19
  export { EmptyState } from './components/EmptyState/index'
20
+ export { InputTag } from './components/InputTag/index'
20
21
  export * from './components/Types/index'
21
22
 
22
23
  export {