@sproutsocial/seeds-react-textarea 1.0.0

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/.eslintignore ADDED
@@ -0,0 +1,6 @@
1
+ # Node modules
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ coverage/
package/.eslintrc.js ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ["eslint-config-seeds/racine"],
4
+ };
@@ -0,0 +1,21 @@
1
+ yarn run v1.22.22
2
+ $ tsup --dts
3
+ CLI Building entry: src/index.ts
4
+ CLI Using tsconfig: tsconfig.json
5
+ CLI tsup v8.0.2
6
+ CLI Using tsup config: /home/runner/work/seeds/seeds/seeds-react/seeds-react-textarea/tsup.config.ts
7
+ CLI Target: es2022
8
+ CLI Cleaning output folder
9
+ CJS Build start
10
+ ESM Build start
11
+ CJS dist/index.js 7.13 KB
12
+ CJS dist/index.js.map 12.10 KB
13
+ CJS ⚡️ Build success in 189ms
14
+ ESM dist/esm/index.js 5.09 KB
15
+ ESM dist/esm/index.js.map 12.05 KB
16
+ ESM ⚡️ Build success in 189ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 37155ms
19
+ DTS dist/index.d.ts 3.36 KB
20
+ DTS dist/index.d.mts 3.36 KB
21
+ Done in 45.30s.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @sproutsocial/seeds-react-textarea
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - bd8d03d: Migrate Textarea from Racine to seeds-react-textarea
@@ -0,0 +1,210 @@
1
+ // src/Textarea.tsx
2
+ import * as React from "react";
3
+
4
+ // src/styles.ts
5
+ import styled, { css } from "styled-components";
6
+ import { COMMON } from "@sproutsocial/seeds-react-system-props";
7
+ import { focusRing } from "@sproutsocial/seeds-react-mixins";
8
+ var Container = styled.div`
9
+ box-sizing: border-box;
10
+ position: relative;
11
+
12
+ textarea {
13
+ box-sizing: border-box;
14
+ display: block;
15
+ width: 100%;
16
+ padding: ${(props) => props.theme.space[300]};
17
+ border: 1px solid ${(props) => props.theme.colors.form.border.base};
18
+ border-radius: ${(props) => props.theme.radii[500]};
19
+ background-color: ${(props) => props.theme.colors.form.background.base};
20
+ color: ${(props) => props.theme.colors.text.body};
21
+ outline: none;
22
+ resize: none;
23
+ transition: border-color ${(props) => props.theme.duration.fast}
24
+ ${(props) => props.theme.easing.ease_in},
25
+ box-shadow ${(props) => props.theme.duration.fast}
26
+ ${(props) => props.theme.easing.ease_in};
27
+ font-family: ${(props) => props.theme.fontFamily};
28
+ ${(props) => props.theme.typography[200]}
29
+ font-weight: ${(props) => props.theme.fontWeights.normal};
30
+ appearance: none;
31
+
32
+ &:focus {
33
+ ${focusRing}
34
+ }
35
+
36
+ &::placeholder {
37
+ color: ${(props) => props.theme.colors.form.placeholder.base};
38
+ font-style: italic;
39
+ }
40
+
41
+ ${(props) => props.resizable && css`
42
+ resize: vertical;
43
+ `}
44
+
45
+ ${(props) => props.hasBeforeElement && css`
46
+ padding-left: 40px;
47
+ `}
48
+
49
+ ${(props) => props.hasAfterElement && css`
50
+ padding-right: 40px;
51
+ `}
52
+ }
53
+
54
+ ${(props) => props.disabled && css`
55
+ opacity: 0.4;
56
+
57
+ textarea {
58
+ cursor: not-allowed;
59
+ }
60
+ `}
61
+
62
+ ${(props) => props.invalid && css`
63
+ textarea {
64
+ border-color: ${(props2) => props2.theme.colors.form.border.error};
65
+ }
66
+ `}
67
+
68
+ ${COMMON}
69
+ `;
70
+ var Accessory = styled.div`
71
+ position: absolute;
72
+ color: ${(props) => props.theme.colors.icon.base};
73
+
74
+ ${(props) => props.before && css`
75
+ top: ${props.theme.space[300]};
76
+ left: ${props.theme.space[350]};
77
+ `};
78
+
79
+ ${(props) => props.after && css`
80
+ right: ${props.theme.space[350]};
81
+ bottom: ${props.theme.space[300]};
82
+ `};
83
+ `;
84
+ Container.displayName = "TextareaContainer";
85
+ Accessory.displayName = "TextareaAccessory";
86
+ var styles_default = Container;
87
+
88
+ // src/Textarea.tsx
89
+ import { jsx, jsxs } from "react/jsx-runtime";
90
+ var Textarea = class extends React.Component {
91
+ static defaultProps = {
92
+ rows: 4
93
+ };
94
+ handleBlur = (e) => {
95
+ if (this.props.onBlur) {
96
+ this.props.onBlur(e);
97
+ }
98
+ };
99
+ handleChange = (e) => {
100
+ if (this.props.onChange) {
101
+ this.props.onChange(e);
102
+ }
103
+ };
104
+ handleFocus = (e) => {
105
+ if (this.props.onFocus) {
106
+ this.props.onFocus(e);
107
+ }
108
+ };
109
+ handleKeyDown = (e) => {
110
+ if (this.props.onKeyDown) {
111
+ this.props.onKeyDown(e);
112
+ }
113
+ };
114
+ handleKeyUp = (e) => {
115
+ if (this.props.onKeyUp) {
116
+ this.props.onKeyUp(e);
117
+ }
118
+ };
119
+ render() {
120
+ const {
121
+ autoFocus,
122
+ disabled,
123
+ readOnly,
124
+ isInvalid,
125
+ id,
126
+ name,
127
+ placeholder,
128
+ value,
129
+ enableSpellcheck,
130
+ enableResize,
131
+ required,
132
+ rows,
133
+ elemBefore,
134
+ elemAfter,
135
+ maxLength,
136
+ ariaLabel,
137
+ ariaDescribedby,
138
+ innerRef,
139
+ onBlur,
140
+ onChange,
141
+ onFocus,
142
+ onKeyDown,
143
+ onKeyUp,
144
+ color,
145
+ qa = {},
146
+ inputProps = {},
147
+ ...rest
148
+ } = this.props;
149
+ return /* @__PURE__ */ jsxs(
150
+ styles_default,
151
+ {
152
+ hasBeforeElement: !!elemBefore,
153
+ hasAfterElement: !!elemAfter,
154
+ disabled,
155
+ invalid: isInvalid,
156
+ resizable: enableResize,
157
+ color,
158
+ "data-qa-textarea": id,
159
+ "data-qa-textarea-isdisabled": disabled === true,
160
+ "data-qa-textarea-isrequired": required === true,
161
+ "data-qa-textarea-isinvalid": isInvalid === true,
162
+ ...qa,
163
+ ...rest,
164
+ children: [
165
+ elemBefore && /* @__PURE__ */ jsx(Accessory, { before: true, children: elemBefore }),
166
+ /* @__PURE__ */ jsx(
167
+ "textarea",
168
+ {
169
+ id,
170
+ "aria-label": ariaLabel,
171
+ "aria-describedby": ariaDescribedby,
172
+ "aria-invalid": isInvalid,
173
+ value,
174
+ name,
175
+ placeholder,
176
+ rows,
177
+ disabled,
178
+ readOnly: Boolean(readOnly),
179
+ autoFocus,
180
+ spellCheck: enableSpellcheck,
181
+ required,
182
+ maxLength,
183
+ onChange: this.handleChange,
184
+ onKeyUp: this.handleKeyUp,
185
+ onKeyDown: this.handleKeyDown,
186
+ onBlur: this.handleBlur,
187
+ onFocus: this.handleFocus,
188
+ ref: innerRef,
189
+ "data-qa-textarea-input": "",
190
+ "data-qa-input": name,
191
+ ...inputProps
192
+ }
193
+ ),
194
+ elemAfter && /* @__PURE__ */ jsx(Accessory, { after: true, children: elemAfter })
195
+ ]
196
+ }
197
+ );
198
+ }
199
+ };
200
+
201
+ // src/TextareaTypes.ts
202
+ import "react";
203
+
204
+ // src/index.ts
205
+ var src_default = Textarea;
206
+ export {
207
+ Textarea,
208
+ src_default as default
209
+ };
210
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Textarea.tsx","../../src/styles.ts","../../src/TextareaTypes.ts","../../src/index.ts"],"sourcesContent":["import * as React from \"react\";\nimport Container, { Accessory } from \"./styles\";\nimport type { TypeTextareaProps } from \"./TextareaTypes\";\n\n/**\n * @deprecated Use TypeTextareaProps from root instead\n */\nexport type TypeProps = TypeTextareaProps;\n\nexport default class Textarea extends React.Component<TypeTextareaProps> {\n static defaultProps = {\n rows: 4,\n };\n\n handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n if (this.props.onBlur) {\n this.props.onBlur(e);\n }\n };\n\n handleChange = (e: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (this.props.onChange) {\n this.props.onChange(e);\n }\n };\n\n handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n if (this.props.onFocus) {\n this.props.onFocus(e);\n }\n };\n\n handleKeyDown = (e: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (this.props.onKeyDown) {\n this.props.onKeyDown(e);\n }\n };\n\n handleKeyUp = (e: React.SyntheticEvent<HTMLTextAreaElement>) => {\n if (this.props.onKeyUp) {\n this.props.onKeyUp(e);\n }\n };\n\n override render() {\n const {\n autoFocus,\n disabled,\n readOnly,\n isInvalid,\n id,\n name,\n placeholder,\n value,\n enableSpellcheck,\n enableResize,\n required,\n rows,\n elemBefore,\n elemAfter,\n maxLength,\n ariaLabel,\n ariaDescribedby,\n innerRef,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n onKeyUp,\n color,\n qa = {},\n inputProps = {},\n ...rest\n } = this.props;\n\n return (\n <Container\n hasBeforeElement={!!elemBefore}\n hasAfterElement={!!elemAfter}\n disabled={disabled}\n invalid={isInvalid}\n resizable={enableResize}\n // TODO: fix this type since `color` should be valid here. TS can't resolve the correct type.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n color={color}\n data-qa-textarea={id}\n data-qa-textarea-isdisabled={disabled === true}\n data-qa-textarea-isrequired={required === true}\n data-qa-textarea-isinvalid={isInvalid === true}\n {...qa}\n {...rest}\n >\n {elemBefore && <Accessory before>{elemBefore}</Accessory>}\n\n <textarea\n id={id}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={isInvalid}\n value={value}\n name={name}\n placeholder={placeholder}\n rows={rows}\n disabled={disabled}\n readOnly={Boolean(readOnly)}\n autoFocus={autoFocus}\n spellCheck={enableSpellcheck}\n required={required}\n maxLength={maxLength}\n onChange={this.handleChange}\n onKeyUp={this.handleKeyUp}\n onKeyDown={this.handleKeyDown}\n onBlur={this.handleBlur}\n onFocus={this.handleFocus}\n ref={innerRef}\n data-qa-textarea-input=\"\"\n data-qa-input={name}\n {...inputProps}\n />\n\n {elemAfter && <Accessory after>{elemAfter}</Accessory>}\n </Container>\n );\n }\n}\n","import styled, { css } from \"styled-components\";\nimport { COMMON } from \"@sproutsocial/seeds-react-system-props\";\nimport { focusRing } from \"@sproutsocial/seeds-react-mixins\";\nimport type {\n TypeTextareaAccessoryProps,\n TypeTextareaContainerProps,\n} from \"./TextareaTypes\";\n\nconst Container = styled.div<TypeTextareaContainerProps>`\n box-sizing: border-box;\n position: relative;\n\n textarea {\n box-sizing: border-box;\n display: block;\n width: 100%;\n padding: ${(props) => props.theme.space[300]};\n border: 1px solid ${(props) => props.theme.colors.form.border.base};\n border-radius: ${(props) => props.theme.radii[500]};\n background-color: ${(props) => props.theme.colors.form.background.base};\n color: ${(props) => props.theme.colors.text.body};\n outline: none;\n resize: none;\n transition: border-color ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in},\n box-shadow ${(props) => props.theme.duration.fast}\n ${(props) => props.theme.easing.ease_in};\n font-family: ${(props) => props.theme.fontFamily};\n ${(props) => props.theme.typography[200]}\n font-weight: ${(props) => props.theme.fontWeights.normal};\n appearance: none;\n\n &:focus {\n ${focusRing}\n }\n\n &::placeholder {\n color: ${(props) => props.theme.colors.form.placeholder.base};\n font-style: italic;\n }\n\n ${(props) =>\n props.resizable &&\n css`\n resize: vertical;\n `}\n\n ${(props) =>\n props.hasBeforeElement &&\n css`\n padding-left: 40px;\n `}\n\n ${(props) =>\n props.hasAfterElement &&\n css`\n padding-right: 40px;\n `}\n }\n\n ${(props) =>\n props.disabled &&\n css`\n opacity: 0.4;\n\n textarea {\n cursor: not-allowed;\n }\n `}\n\n ${(props) =>\n props.invalid &&\n css`\n textarea {\n border-color: ${(props) => props.theme.colors.form.border.error};\n }\n `}\n\n ${COMMON}\n`;\n\nexport const Accessory = styled.div<TypeTextareaAccessoryProps>`\n position: absolute;\n color: ${(props) => props.theme.colors.icon.base};\n\n ${(props) =>\n props.before &&\n css`\n top: ${props.theme.space[300]};\n left: ${props.theme.space[350]};\n `};\n\n ${(props) =>\n props.after &&\n css`\n right: ${props.theme.space[350]};\n bottom: ${props.theme.space[300]};\n `};\n`;\n\nContainer.displayName = \"TextareaContainer\";\nAccessory.displayName = \"TextareaAccessory\";\n\nexport default Container;\n","import * as React from \"react\";\nimport type {\n TypeSystemCommonProps,\n TypeStyledComponentsCommonProps,\n} from \"@sproutsocial/seeds-react-system-props\";\n\ntype CollisionTypes =\n | \"color\"\n | \"onChange\"\n | \"onFocus\"\n | \"onBlur\"\n | \"onKeyDown\"\n | \"onKeyUp\";\n\nexport interface TypeTextareaProps\n extends TypeStyledComponentsCommonProps,\n TypeSystemCommonProps,\n Omit<React.ComponentPropsWithoutRef<\"textarea\">, CollisionTypes> {\n /** ID of the form element, should match the \"for\" value of the associated label */\n id: string;\n name: string;\n\n /** Label used to describe the input if not used with an accompanying visual label */\n ariaLabel?: string;\n\n /** Attribute used to associate other elements that describe the Textarea, like an error */\n ariaDescribedby?: string;\n\n /** Current value of the textarea */\n value?: string;\n\n /** Will autofocus the element when mounted to the DOM */\n autoFocus?: boolean;\n\n /** HTML disabled attribute */\n disabled?: boolean;\n\n /** HTML readonly attribute */\n readOnly?: boolean;\n\n /** Whether or not the current contents of the input are invalid */\n isInvalid?: boolean;\n\n /** Placeholder text for when value is undefined or empty */\n placeholder?: string;\n\n /** HTML required attribute */\n required?: boolean;\n\n /** 16x16 element, such as an icon */\n elemBefore?: React.ReactNode;\n\n /** 16x16 element, such as an icon */\n elemAfter?: React.ReactNode;\n\n /** Max length of the input */\n maxLength?: number;\n\n /** HTML spellcheck attribute */\n enableSpellcheck?: boolean;\n\n /** Makes the text area vertically resizable */\n enableResize?: boolean;\n\n /** The number of visible lines of text without scrolling */\n rows?: number;\n qa?: object;\n\n /** Props to spread onto the underlying textarea element */\n inputProps?: React.ComponentPropsWithoutRef<\"textarea\">;\n\n /** Used to get a reference to the underlying element */\n innerRef?:\n | {\n current: null | HTMLTextAreaElement;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | ((arg0: React.ElementRef<any> | HTMLElement) => void);\n onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onChange?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;\n onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;\n onKeyDown?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;\n onKeyUp?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;\n}\n\nexport interface TypeTextareaContainerProps {\n resizable?: TypeTextareaProps[\"enableResize\"];\n hasBeforeElement?: boolean;\n hasAfterElement?: boolean;\n disabled?: TypeTextareaProps[\"disabled\"];\n invalid?: TypeTextareaProps[\"isInvalid\"];\n}\n\nexport interface TypeTextareaAccessoryProps {\n before?: boolean;\n after?: boolean;\n}\n","import Textarea from \"./Textarea\";\n\nexport default Textarea;\nexport { Textarea };\nexport * from \"./TextareaTypes\";\n"],"mappings":";AAAA,YAAY,WAAW;;;ACAvB,OAAO,UAAU,WAAW;AAC5B,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAM1B,IAAM,YAAY,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAQV,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,wBACxB,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,OAAO,IAAI;AAAA,qBACjD,CAAC,UAAU,MAAM,MAAM,MAAM,GAAG,CAAC;AAAA,wBAC9B,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,WAAW,IAAI;AAAA,aAC7D,CAAC,UAAU,MAAM,MAAM,OAAO,KAAK,IAAI;AAAA;AAAA;AAAA,+BAGrB,CAAC,UAAU,MAAM,MAAM,SAAS,IAAI;AAAA,UACzD,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO;AAAA,mBAC5B,CAAC,UAAU,MAAM,MAAM,SAAS,IAAI;AAAA,UAC7C,CAAC,UAAU,MAAM,MAAM,OAAO,OAAO;AAAA,mBAC5B,CAAC,UAAU,MAAM,MAAM,UAAU;AAAA,MAC9C,CAAC,UAAU,MAAM,MAAM,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,YAAC;AAAA;AAAA,cACC;AAAA,cACA,cAAY;AAAA,cACZ,oBAAkB;AAAA,cAClB,gBAAc;AAAA,cACd;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,UAAU,QAAQ,QAAQ;AAAA,cAC1B;AAAA,cACA,YAAY;AAAA,cACZ;AAAA,cACA;AAAA,cACA,UAAU,KAAK;AAAA,cACf,SAAS,KAAK;AAAA,cACd,WAAW,KAAK;AAAA,cAChB,QAAQ,KAAK;AAAA,cACb,SAAS,KAAK;AAAA,cACd,KAAK;AAAA,cACL,0BAAuB;AAAA,cACvB,iBAAe;AAAA,cACd,GAAG;AAAA;AAAA,UACN;AAAA,UAEC,aAAa,oBAAC,aAAU,OAAK,MAAE,qBAAU;AAAA;AAAA;AAAA,IAC5C;AAAA,EAEJ;AACF;;;AE7HA,OAAuB;;;ACEvB,IAAO,cAAQ;","names":["props"]}
@@ -0,0 +1,77 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
4
+
5
+ type CollisionTypes = "color" | "onChange" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp";
6
+ interface TypeTextareaProps extends TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"textarea">, CollisionTypes> {
7
+ /** ID of the form element, should match the "for" value of the associated label */
8
+ id: string;
9
+ name: string;
10
+ /** Label used to describe the input if not used with an accompanying visual label */
11
+ ariaLabel?: string;
12
+ /** Attribute used to associate other elements that describe the Textarea, like an error */
13
+ ariaDescribedby?: string;
14
+ /** Current value of the textarea */
15
+ value?: string;
16
+ /** Will autofocus the element when mounted to the DOM */
17
+ autoFocus?: boolean;
18
+ /** HTML disabled attribute */
19
+ disabled?: boolean;
20
+ /** HTML readonly attribute */
21
+ readOnly?: boolean;
22
+ /** Whether or not the current contents of the input are invalid */
23
+ isInvalid?: boolean;
24
+ /** Placeholder text for when value is undefined or empty */
25
+ placeholder?: string;
26
+ /** HTML required attribute */
27
+ required?: boolean;
28
+ /** 16x16 element, such as an icon */
29
+ elemBefore?: React.ReactNode;
30
+ /** 16x16 element, such as an icon */
31
+ elemAfter?: React.ReactNode;
32
+ /** Max length of the input */
33
+ maxLength?: number;
34
+ /** HTML spellcheck attribute */
35
+ enableSpellcheck?: boolean;
36
+ /** Makes the text area vertically resizable */
37
+ enableResize?: boolean;
38
+ /** The number of visible lines of text without scrolling */
39
+ rows?: number;
40
+ qa?: object;
41
+ /** Props to spread onto the underlying textarea element */
42
+ inputProps?: React.ComponentPropsWithoutRef<"textarea">;
43
+ /** Used to get a reference to the underlying element */
44
+ innerRef?: {
45
+ current: null | HTMLTextAreaElement;
46
+ } | ((arg0: React.ElementRef<any> | HTMLElement) => void);
47
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
48
+ onChange?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
49
+ onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
50
+ onKeyDown?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
51
+ onKeyUp?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
52
+ }
53
+ interface TypeTextareaContainerProps {
54
+ resizable?: TypeTextareaProps["enableResize"];
55
+ hasBeforeElement?: boolean;
56
+ hasAfterElement?: boolean;
57
+ disabled?: TypeTextareaProps["disabled"];
58
+ invalid?: TypeTextareaProps["isInvalid"];
59
+ }
60
+ interface TypeTextareaAccessoryProps {
61
+ before?: boolean;
62
+ after?: boolean;
63
+ }
64
+
65
+ declare class Textarea extends React.Component<TypeTextareaProps> {
66
+ static defaultProps: {
67
+ rows: number;
68
+ };
69
+ handleBlur: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
70
+ handleChange: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
71
+ handleFocus: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
72
+ handleKeyDown: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
73
+ handleKeyUp: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
74
+ render(): react_jsx_runtime.JSX.Element;
75
+ }
76
+
77
+ export { Textarea, type TypeTextareaAccessoryProps, type TypeTextareaContainerProps, type TypeTextareaProps, Textarea as default };
@@ -0,0 +1,77 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
4
+
5
+ type CollisionTypes = "color" | "onChange" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp";
6
+ interface TypeTextareaProps extends TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"textarea">, CollisionTypes> {
7
+ /** ID of the form element, should match the "for" value of the associated label */
8
+ id: string;
9
+ name: string;
10
+ /** Label used to describe the input if not used with an accompanying visual label */
11
+ ariaLabel?: string;
12
+ /** Attribute used to associate other elements that describe the Textarea, like an error */
13
+ ariaDescribedby?: string;
14
+ /** Current value of the textarea */
15
+ value?: string;
16
+ /** Will autofocus the element when mounted to the DOM */
17
+ autoFocus?: boolean;
18
+ /** HTML disabled attribute */
19
+ disabled?: boolean;
20
+ /** HTML readonly attribute */
21
+ readOnly?: boolean;
22
+ /** Whether or not the current contents of the input are invalid */
23
+ isInvalid?: boolean;
24
+ /** Placeholder text for when value is undefined or empty */
25
+ placeholder?: string;
26
+ /** HTML required attribute */
27
+ required?: boolean;
28
+ /** 16x16 element, such as an icon */
29
+ elemBefore?: React.ReactNode;
30
+ /** 16x16 element, such as an icon */
31
+ elemAfter?: React.ReactNode;
32
+ /** Max length of the input */
33
+ maxLength?: number;
34
+ /** HTML spellcheck attribute */
35
+ enableSpellcheck?: boolean;
36
+ /** Makes the text area vertically resizable */
37
+ enableResize?: boolean;
38
+ /** The number of visible lines of text without scrolling */
39
+ rows?: number;
40
+ qa?: object;
41
+ /** Props to spread onto the underlying textarea element */
42
+ inputProps?: React.ComponentPropsWithoutRef<"textarea">;
43
+ /** Used to get a reference to the underlying element */
44
+ innerRef?: {
45
+ current: null | HTMLTextAreaElement;
46
+ } | ((arg0: React.ElementRef<any> | HTMLElement) => void);
47
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
48
+ onChange?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
49
+ onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
50
+ onKeyDown?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
51
+ onKeyUp?: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
52
+ }
53
+ interface TypeTextareaContainerProps {
54
+ resizable?: TypeTextareaProps["enableResize"];
55
+ hasBeforeElement?: boolean;
56
+ hasAfterElement?: boolean;
57
+ disabled?: TypeTextareaProps["disabled"];
58
+ invalid?: TypeTextareaProps["isInvalid"];
59
+ }
60
+ interface TypeTextareaAccessoryProps {
61
+ before?: boolean;
62
+ after?: boolean;
63
+ }
64
+
65
+ declare class Textarea extends React.Component<TypeTextareaProps> {
66
+ static defaultProps: {
67
+ rows: number;
68
+ };
69
+ handleBlur: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
70
+ handleChange: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
71
+ handleFocus: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
72
+ handleKeyDown: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
73
+ handleKeyUp: (e: React.SyntheticEvent<HTMLTextAreaElement>) => void;
74
+ render(): react_jsx_runtime.JSX.Element;
75
+ }
76
+
77
+ export { Textarea, type TypeTextareaAccessoryProps, type TypeTextareaContainerProps, type TypeTextareaProps, Textarea as default };
package/dist/index.js ADDED
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ Textarea: () => Textarea,
34
+ default: () => src_default
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+
38
+ // src/Textarea.tsx
39
+ var React = __toESM(require("react"));
40
+
41
+ // src/styles.ts
42
+ var import_styled_components = __toESM(require("styled-components"));
43
+ var import_seeds_react_system_props = require("@sproutsocial/seeds-react-system-props");
44
+ var import_seeds_react_mixins = require("@sproutsocial/seeds-react-mixins");
45
+ var Container = import_styled_components.default.div`
46
+ box-sizing: border-box;
47
+ position: relative;
48
+
49
+ textarea {
50
+ box-sizing: border-box;
51
+ display: block;
52
+ width: 100%;
53
+ padding: ${(props) => props.theme.space[300]};
54
+ border: 1px solid ${(props) => props.theme.colors.form.border.base};
55
+ border-radius: ${(props) => props.theme.radii[500]};
56
+ background-color: ${(props) => props.theme.colors.form.background.base};
57
+ color: ${(props) => props.theme.colors.text.body};
58
+ outline: none;
59
+ resize: none;
60
+ transition: border-color ${(props) => props.theme.duration.fast}
61
+ ${(props) => props.theme.easing.ease_in},
62
+ box-shadow ${(props) => props.theme.duration.fast}
63
+ ${(props) => props.theme.easing.ease_in};
64
+ font-family: ${(props) => props.theme.fontFamily};
65
+ ${(props) => props.theme.typography[200]}
66
+ font-weight: ${(props) => props.theme.fontWeights.normal};
67
+ appearance: none;
68
+
69
+ &:focus {
70
+ ${import_seeds_react_mixins.focusRing}
71
+ }
72
+
73
+ &::placeholder {
74
+ color: ${(props) => props.theme.colors.form.placeholder.base};
75
+ font-style: italic;
76
+ }
77
+
78
+ ${(props) => props.resizable && import_styled_components.css`
79
+ resize: vertical;
80
+ `}
81
+
82
+ ${(props) => props.hasBeforeElement && import_styled_components.css`
83
+ padding-left: 40px;
84
+ `}
85
+
86
+ ${(props) => props.hasAfterElement && import_styled_components.css`
87
+ padding-right: 40px;
88
+ `}
89
+ }
90
+
91
+ ${(props) => props.disabled && import_styled_components.css`
92
+ opacity: 0.4;
93
+
94
+ textarea {
95
+ cursor: not-allowed;
96
+ }
97
+ `}
98
+
99
+ ${(props) => props.invalid && import_styled_components.css`
100
+ textarea {
101
+ border-color: ${(props2) => props2.theme.colors.form.border.error};
102
+ }
103
+ `}
104
+
105
+ ${import_seeds_react_system_props.COMMON}
106
+ `;
107
+ var Accessory = import_styled_components.default.div`
108
+ position: absolute;
109
+ color: ${(props) => props.theme.colors.icon.base};
110
+
111
+ ${(props) => props.before && import_styled_components.css`
112
+ top: ${props.theme.space[300]};
113
+ left: ${props.theme.space[350]};
114
+ `};
115
+
116
+ ${(props) => props.after && import_styled_components.css`
117
+ right: ${props.theme.space[350]};
118
+ bottom: ${props.theme.space[300]};
119
+ `};
120
+ `;
121
+ Container.displayName = "TextareaContainer";
122
+ Accessory.displayName = "TextareaAccessory";
123
+ var styles_default = Container;
124
+
125
+ // src/Textarea.tsx
126
+ var import_jsx_runtime = require("react/jsx-runtime");
127
+ var Textarea = class extends React.Component {
128
+ static defaultProps = {
129
+ rows: 4
130
+ };
131
+ handleBlur = (e) => {
132
+ if (this.props.onBlur) {
133
+ this.props.onBlur(e);
134
+ }
135
+ };
136
+ handleChange = (e) => {
137
+ if (this.props.onChange) {
138
+ this.props.onChange(e);
139
+ }
140
+ };
141
+ handleFocus = (e) => {
142
+ if (this.props.onFocus) {
143
+ this.props.onFocus(e);
144
+ }
145
+ };
146
+ handleKeyDown = (e) => {
147
+ if (this.props.onKeyDown) {
148
+ this.props.onKeyDown(e);
149
+ }
150
+ };
151
+ handleKeyUp = (e) => {
152
+ if (this.props.onKeyUp) {
153
+ this.props.onKeyUp(e);
154
+ }
155
+ };
156
+ render() {
157
+ const {
158
+ autoFocus,
159
+ disabled,
160
+ readOnly,
161
+ isInvalid,
162
+ id,
163
+ name,
164
+ placeholder,
165
+ value,
166
+ enableSpellcheck,
167
+ enableResize,
168
+ required,
169
+ rows,
170
+ elemBefore,
171
+ elemAfter,
172
+ maxLength,
173
+ ariaLabel,
174
+ ariaDescribedby,
175
+ innerRef,
176
+ onBlur,
177
+ onChange,
178
+ onFocus,
179
+ onKeyDown,
180
+ onKeyUp,
181
+ color,
182
+ qa = {},
183
+ inputProps = {},
184
+ ...rest
185
+ } = this.props;
186
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
187
+ styles_default,
188
+ {
189
+ hasBeforeElement: !!elemBefore,
190
+ hasAfterElement: !!elemAfter,
191
+ disabled,
192
+ invalid: isInvalid,
193
+ resizable: enableResize,
194
+ color,
195
+ "data-qa-textarea": id,
196
+ "data-qa-textarea-isdisabled": disabled === true,
197
+ "data-qa-textarea-isrequired": required === true,
198
+ "data-qa-textarea-isinvalid": isInvalid === true,
199
+ ...qa,
200
+ ...rest,
201
+ children: [
202
+ elemBefore && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Accessory, { before: true, children: elemBefore }),
203
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
204
+ "textarea",
205
+ {
206
+ id,
207
+ "aria-label": ariaLabel,
208
+ "aria-describedby": ariaDescribedby,
209
+ "aria-invalid": isInvalid,
210
+ value,
211
+ name,
212
+ placeholder,
213
+ rows,
214
+ disabled,
215
+ readOnly: Boolean(readOnly),
216
+ autoFocus,
217
+ spellCheck: enableSpellcheck,
218
+ required,
219
+ maxLength,
220
+ onChange: this.handleChange,
221
+ onKeyUp: this.handleKeyUp,
222
+ onKeyDown: this.handleKeyDown,
223
+ onBlur: this.handleBlur,
224
+ onFocus: this.handleFocus,
225
+ ref: innerRef,
226
+ "data-qa-textarea-input": "",
227
+ "data-qa-input": name,
228
+ ...inputProps
229
+ }
230
+ ),
231
+ elemAfter && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Accessory, { after: true, children: elemAfter })
232
+ ]
233
+ }
234
+ );
235
+ }
236
+ };
237
+
238
+ // src/TextareaTypes.ts
239
+ var React2 = require("react");
240
+
241
+ // src/index.ts
242
+ var src_default = Textarea;
243
+ // Annotate the CommonJS export names for ESM import in node:
244
+ 0 && (module.exports = {
245
+ Textarea
246
+ });
247
+ //# sourceMappingURL=index.js.map