@commercetools-uikit/text-field 19.8.0 → 19.10.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/README.md CHANGED
@@ -62,6 +62,7 @@ export default Example;
62
62
  | `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
63
63
  | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
64
64
  | `placeholder` | `string` | | | Placeholder text for the input |
65
+ | `maxLength` | `number` | | | Maximum number of characters allowed in the input field |
65
66
  | `title` | `union`<br/>Possible values:<br/>`string , ReactNode` | ✅ | | Title of the label |
66
67
  | `hint` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth. Can also receive a hintIcon. |
67
68
  | `description` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Provides a description for the title. |
@@ -123,6 +123,7 @@ let TextField = /*#__PURE__*/function (_Component) {
123
123
  hasWarning: hasWarning,
124
124
  hasError: hasError,
125
125
  placeholder: this.props.placeholder,
126
+ maxLength: this.props.maxLength,
126
127
  horizontalConstraint: "scale"
127
128
  }, utils.filterDataAttributes(this.props)), {}, {
128
129
  /* ARIA */
@@ -193,7 +194,7 @@ TextField.propTypes = process.env.NODE_ENV !== "production" ? {
193
194
  var TextField$1 = TextField;
194
195
 
195
196
  // NOTE: This string will be replaced on build time with the package version.
196
- var version = "19.8.0";
197
+ var version = "19.10.0";
197
198
 
198
199
  exports["default"] = TextField$1;
199
200
  exports.version = version;
@@ -118,6 +118,7 @@ let TextField = /*#__PURE__*/function (_Component) {
118
118
  hasWarning: hasWarning,
119
119
  hasError: hasError,
120
120
  placeholder: this.props.placeholder,
121
+ maxLength: this.props.maxLength,
121
122
  horizontalConstraint: "scale"
122
123
  }, utils.filterDataAttributes(this.props)), {}, {
123
124
  /* ARIA */
@@ -162,7 +163,7 @@ TextField.propTypes = {};
162
163
  var TextField$1 = TextField;
163
164
 
164
165
  // NOTE: This string will be replaced on build time with the package version.
165
- var version = "19.8.0";
166
+ var version = "19.10.0";
166
167
 
167
168
  exports["default"] = TextField$1;
168
169
  exports.version = version;
@@ -98,6 +98,7 @@ let TextField = /*#__PURE__*/function (_Component) {
98
98
  hasWarning: hasWarning,
99
99
  hasError: hasError,
100
100
  placeholder: this.props.placeholder,
101
+ maxLength: this.props.maxLength,
101
102
  horizontalConstraint: "scale"
102
103
  }, filterDataAttributes(this.props)), {}, {
103
104
  /* ARIA */
@@ -168,6 +169,6 @@ TextField.propTypes = process.env.NODE_ENV !== "production" ? {
168
169
  var TextField$1 = TextField;
169
170
 
170
171
  // NOTE: This string will be replaced on build time with the package version.
171
- var version = "19.8.0";
172
+ var version = "19.10.0";
172
173
 
173
174
  export { TextField$1 as default, version };
@@ -6,31 +6,116 @@ type TCustomFormErrors<Values> = {
6
6
  [K in keyof Values]?: TFieldErrors;
7
7
  };
8
8
  export type TTextFieldProps = {
9
+ /**
10
+ * Used as HTML id property. An id is auto-generated when it is not specified.
11
+ */
9
12
  id?: string;
13
+ /**
14
+ * Horizontal size limit of the input fields.
15
+ */
10
16
  horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
17
+ /**
18
+ * A map of errors. Error messages for known errors are rendered automatically.
19
+ * <br/>
20
+ * Unknown errors will be forwarded to renderError.
21
+ */
11
22
  errors?: TFieldErrors;
23
+ /**
24
+ * A map of warnings. Warning messages for known warnings are rendered automatically.
25
+ * <br/>
26
+ * Unknown warnings will be forwarded to renderWarning.
27
+ */
12
28
  warnings?: TFieldWarnings;
29
+ /**
30
+ * This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
31
+ */
13
32
  renderError?: TErrorRenderer;
33
+ /**
34
+ * Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
35
+ * <br />
36
+ * It can also return null to show no warning.
37
+ */
14
38
  renderWarning?: (key: string, warning?: boolean) => ReactNode;
39
+ /**
40
+ * Indicates if the value is required. Shows an the "required asterisk" if so.
41
+ */
15
42
  isRequired?: boolean;
43
+ /**
44
+ * Indicates whether the field was touched. Errors will only be shown when the field was touched.
45
+ */
16
46
  touched?: boolean;
47
+ /**
48
+ * Used as HTML autocomplete property
49
+ */
17
50
  autoComplete?: string;
51
+ /**
52
+ * Used as HTML name of the input component. property
53
+ */
18
54
  name?: string;
55
+ /**
56
+ * Value of the input component.
57
+ */
19
58
  value: string;
59
+ /**
60
+ * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
61
+ */
20
62
  onChange?: ChangeEventHandler<HTMLInputElement>;
63
+ /**
64
+ * Called when input is blurred
65
+ */
21
66
  onBlur?: FocusEventHandler<HTMLInputElement>;
67
+ /**
68
+ * Called when input is focused
69
+ */
22
70
  onFocus?: FocusEventHandler<HTMLInputElement>;
71
+ /**
72
+ * Focus the input on initial render
73
+ */
23
74
  isAutofocussed?: boolean;
75
+ /**
76
+ * Use this property to reduce the paddings of the component for a ui compact variant
77
+ */
24
78
  isCondensed?: boolean;
79
+ /**
80
+ * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
81
+ */
25
82
  isDisabled?: boolean;
83
+ /**
84
+ * Indicates that the field is displaying read-only content
85
+ */
26
86
  isReadOnly?: boolean;
87
+ /**
88
+ * Placeholder text for the input
89
+ */
27
90
  placeholder?: string;
91
+ /**
92
+ * Title of the label
93
+ */
28
94
  title: string | ReactNode;
95
+ /**
96
+ * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth. Can also receive a hintIcon.
97
+ */
29
98
  hint?: string | ReactNode;
99
+ /**
100
+ * Provides a description for the title.
101
+ */
30
102
  description?: string | ReactNode;
103
+ /**
104
+ * Function called when info button is pressed. Info button will only be visible when this prop is passed.
105
+ */
31
106
  onInfoButtonClick?: () => void;
107
+ /**
108
+ * Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well.
109
+ */
32
110
  hintIcon?: ReactElement;
111
+ /**
112
+ * Badge to be displayed beside the label. Might be used to display additional information about the content of the field (E.g verified email)
113
+ */
33
114
  badge?: ReactNode;
115
+ /**
116
+ * Maximum number of characters allowed in the input. if this prop is used, It is recommended to inform the user about this limit in the InputField description, or otherwise
117
+ */
118
+ maxLength?: number;
34
119
  };
35
120
  type TTextFieldState = Pick<TTextFieldProps, 'id'>;
36
121
  declare class TextField extends Component<TTextFieldProps, TTextFieldState> {
@@ -42,6 +127,11 @@ declare class TextField extends Component<TTextFieldProps, TTextFieldState> {
42
127
  static getDerivedStateFromProps: (props: TTextFieldProps, state: TTextFieldState) => {
43
128
  id: string;
44
129
  };
130
+ /**
131
+ * Use this function to convert the Formik `errors` object type to
132
+ * our custom field errors type.
133
+ * This is primarly useful when using TypeScript.
134
+ */
45
135
  static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
46
136
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
47
137
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/text-field",
3
3
  "description": "A controlled text input component for single-line strings with validation states.",
4
- "version": "19.8.0",
4
+ "version": "19.10.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/constraints": "19.8.0",
25
- "@commercetools-uikit/design-system": "19.8.0",
26
- "@commercetools-uikit/field-errors": "19.8.0",
27
- "@commercetools-uikit/field-label": "19.8.0",
28
- "@commercetools-uikit/field-warnings": "19.8.0",
29
- "@commercetools-uikit/spacings-stack": "19.8.0",
30
- "@commercetools-uikit/text-input": "19.8.0",
31
- "@commercetools-uikit/utils": "19.8.0",
24
+ "@commercetools-uikit/constraints": "19.10.0",
25
+ "@commercetools-uikit/design-system": "19.10.0",
26
+ "@commercetools-uikit/field-errors": "19.10.0",
27
+ "@commercetools-uikit/field-label": "19.10.0",
28
+ "@commercetools-uikit/field-warnings": "19.10.0",
29
+ "@commercetools-uikit/spacings-stack": "19.10.0",
30
+ "@commercetools-uikit/text-input": "19.10.0",
31
+ "@commercetools-uikit/utils": "19.10.0",
32
32
  "@emotion/react": "^11.10.5",
33
33
  "@emotion/styled": "^11.10.5",
34
34
  "prop-types": "15.8.1",