@sproutsocial/seeds-react-input 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.
@@ -0,0 +1,102 @@
1
+ import * as React from 'react';
2
+ import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
3
+
4
+ interface TypeBaseInputProps {
5
+ /** ID of the form element, should match the "for" value of the associated label */
6
+ id: string;
7
+ name: string;
8
+ /** Label used to describe the input if not used with an accompanying visual label */
9
+ ariaLabel?: string;
10
+ /** Attribute used to associate other elements that describe the Input, like an error */
11
+ ariaDescribedby?: string;
12
+ /** Label for Input.ClearButton. Required when using Input.ClearButton. */
13
+ clearButtonLabel?: string;
14
+ /** Placeholder text for when value is undefined or empty */
15
+ placeholder?: string;
16
+ /** Current value of the input */
17
+ value?: string;
18
+ /** HTML type attribute */
19
+ type?: "date" | "email" | "number" | "password" | "text" | "url" | "search";
20
+ /** Set option to display earlier typed values */
21
+ autoComplete?: boolean;
22
+ /** Will autofocus the element when mounted to the DOM */
23
+ autoFocus?: boolean;
24
+ /** HTML disabled attribute */
25
+ disabled?: boolean;
26
+ /** HTML readonly attribute */
27
+ readOnly?: boolean;
28
+ /** Whether or not the current contents of the input are invalid */
29
+ isInvalid?: boolean;
30
+ /** Whether or not the current contents of the input has any warnings */
31
+ hasWarning?: boolean;
32
+ /** HTML required attribute */
33
+ required?: boolean;
34
+ /** 16x16 element, such as an icon */
35
+ elemBefore?: React.ReactNode;
36
+ /** 16x16 element, such as an icon */
37
+ elemAfter?: React.ReactNode;
38
+ /** Max length of the input */
39
+ maxLength?: number;
40
+ /** Props to spread onto the underlying input element */
41
+ inputProps?: React.ComponentPropsWithoutRef<"input">;
42
+ /** Used to get a reference to the underlying element */
43
+ innerRef?: {
44
+ current: null | HTMLInputElement;
45
+ } | ((arg0: React.ElementRef<any> | HTMLElement) => void);
46
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
47
+ onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
48
+ onClear?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
49
+ onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
50
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;
51
+ onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;
52
+ onPaste?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
53
+ size?: "large" | "small" | "default";
54
+ qa?: object;
55
+ /**
56
+ Controls the styles of the input. Primary is our standard input styles and secondary is a borderless input.
57
+ Note that this prop should only be used to alter styles and not functionality.
58
+ */
59
+ appearance?: "primary" | "secondary";
60
+ }
61
+ interface TypeInputProps extends TypeBaseInputProps, TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"div">, keyof TypeBaseInputProps | "color"> {
62
+ }
63
+ interface TypeInputContainerProps {
64
+ size: TypeInputProps["size"];
65
+ appearance: TypeInputProps["appearance"];
66
+ hasBeforeElement: boolean;
67
+ hasAfterElement: boolean;
68
+ invalid?: boolean;
69
+ warning?: boolean;
70
+ disabled?: boolean;
71
+ }
72
+
73
+ interface TypeState {
74
+ hasValue: boolean;
75
+ }
76
+ declare class Input extends React.Component<TypeInputProps, TypeState> {
77
+ constructor(props: TypeInputProps);
78
+ componentDidUpdate({ value: prevValue }: TypeInputProps): void;
79
+ static defaultProps: {
80
+ autoFocus: boolean;
81
+ disabled: boolean;
82
+ type: string;
83
+ size: string;
84
+ appearance: string;
85
+ };
86
+ static ClearButton: {
87
+ (): JSX.Element | null;
88
+ displayName: string;
89
+ };
90
+ inputRef: React.RefObject<HTMLInputElement>;
91
+ handleBlur: (e: React.FocusEvent<HTMLInputElement>) => void | undefined;
92
+ handleClear: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
93
+ handleChange: (e: React.SyntheticEvent<HTMLInputElement>) => void;
94
+ handleFocus: (e: React.FocusEvent<HTMLInputElement>) => void | undefined;
95
+ handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void | undefined;
96
+ handleKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void | undefined;
97
+ handlePaste: (e: React.SyntheticEvent<HTMLInputElement>) => void | undefined;
98
+ updateState: (inputValue: string) => void;
99
+ render(): JSX.Element;
100
+ }
101
+
102
+ export { Input, type TypeInputContainerProps, type TypeInputProps, Input as default };
@@ -0,0 +1,102 @@
1
+ import * as React from 'react';
2
+ import { TypeStyledComponentsCommonProps, TypeSystemCommonProps } from '@sproutsocial/seeds-react-system-props';
3
+
4
+ interface TypeBaseInputProps {
5
+ /** ID of the form element, should match the "for" value of the associated label */
6
+ id: string;
7
+ name: string;
8
+ /** Label used to describe the input if not used with an accompanying visual label */
9
+ ariaLabel?: string;
10
+ /** Attribute used to associate other elements that describe the Input, like an error */
11
+ ariaDescribedby?: string;
12
+ /** Label for Input.ClearButton. Required when using Input.ClearButton. */
13
+ clearButtonLabel?: string;
14
+ /** Placeholder text for when value is undefined or empty */
15
+ placeholder?: string;
16
+ /** Current value of the input */
17
+ value?: string;
18
+ /** HTML type attribute */
19
+ type?: "date" | "email" | "number" | "password" | "text" | "url" | "search";
20
+ /** Set option to display earlier typed values */
21
+ autoComplete?: boolean;
22
+ /** Will autofocus the element when mounted to the DOM */
23
+ autoFocus?: boolean;
24
+ /** HTML disabled attribute */
25
+ disabled?: boolean;
26
+ /** HTML readonly attribute */
27
+ readOnly?: boolean;
28
+ /** Whether or not the current contents of the input are invalid */
29
+ isInvalid?: boolean;
30
+ /** Whether or not the current contents of the input has any warnings */
31
+ hasWarning?: boolean;
32
+ /** HTML required attribute */
33
+ required?: boolean;
34
+ /** 16x16 element, such as an icon */
35
+ elemBefore?: React.ReactNode;
36
+ /** 16x16 element, such as an icon */
37
+ elemAfter?: React.ReactNode;
38
+ /** Max length of the input */
39
+ maxLength?: number;
40
+ /** Props to spread onto the underlying input element */
41
+ inputProps?: React.ComponentPropsWithoutRef<"input">;
42
+ /** Used to get a reference to the underlying element */
43
+ innerRef?: {
44
+ current: null | HTMLInputElement;
45
+ } | ((arg0: React.ElementRef<any> | HTMLElement) => void);
46
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
47
+ onChange?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
48
+ onClear?: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
49
+ onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
50
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;
51
+ onKeyUp?: (e: React.KeyboardEvent<HTMLInputElement>, value: string) => void;
52
+ onPaste?: (e: React.SyntheticEvent<HTMLInputElement>, value: string) => void;
53
+ size?: "large" | "small" | "default";
54
+ qa?: object;
55
+ /**
56
+ Controls the styles of the input. Primary is our standard input styles and secondary is a borderless input.
57
+ Note that this prop should only be used to alter styles and not functionality.
58
+ */
59
+ appearance?: "primary" | "secondary";
60
+ }
61
+ interface TypeInputProps extends TypeBaseInputProps, TypeStyledComponentsCommonProps, TypeSystemCommonProps, Omit<React.ComponentPropsWithoutRef<"div">, keyof TypeBaseInputProps | "color"> {
62
+ }
63
+ interface TypeInputContainerProps {
64
+ size: TypeInputProps["size"];
65
+ appearance: TypeInputProps["appearance"];
66
+ hasBeforeElement: boolean;
67
+ hasAfterElement: boolean;
68
+ invalid?: boolean;
69
+ warning?: boolean;
70
+ disabled?: boolean;
71
+ }
72
+
73
+ interface TypeState {
74
+ hasValue: boolean;
75
+ }
76
+ declare class Input extends React.Component<TypeInputProps, TypeState> {
77
+ constructor(props: TypeInputProps);
78
+ componentDidUpdate({ value: prevValue }: TypeInputProps): void;
79
+ static defaultProps: {
80
+ autoFocus: boolean;
81
+ disabled: boolean;
82
+ type: string;
83
+ size: string;
84
+ appearance: string;
85
+ };
86
+ static ClearButton: {
87
+ (): JSX.Element | null;
88
+ displayName: string;
89
+ };
90
+ inputRef: React.RefObject<HTMLInputElement>;
91
+ handleBlur: (e: React.FocusEvent<HTMLInputElement>) => void | undefined;
92
+ handleClear: (e: React.SyntheticEvent<HTMLButtonElement>) => void;
93
+ handleChange: (e: React.SyntheticEvent<HTMLInputElement>) => void;
94
+ handleFocus: (e: React.FocusEvent<HTMLInputElement>) => void | undefined;
95
+ handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void | undefined;
96
+ handleKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void | undefined;
97
+ handlePaste: (e: React.SyntheticEvent<HTMLInputElement>) => void | undefined;
98
+ updateState: (inputValue: string) => void;
99
+ render(): JSX.Element;
100
+ }
101
+
102
+ export { Input, type TypeInputContainerProps, type TypeInputProps, Input as default };