@commercetools-uikit/text-field 14.0.0 → 14.0.1

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
@@ -99,3 +99,21 @@ Known error keys are:
99
99
  ## Main Functions and use cases are:
100
100
 
101
101
  - Input field for single-line strings
102
+
103
+ ## Static methods
104
+
105
+ ### `TextField.toFieldErrors`
106
+
107
+ Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
108
+
109
+ ```ts
110
+ type FormValues = {
111
+ myField: string;
112
+ };
113
+
114
+ <TextField
115
+ // ...
116
+ name="my-field"
117
+ errors={TextField.toFieldErrors<FormValues>(formik.errors).myField}
118
+ />;
119
+ ```
@@ -144,6 +144,17 @@ var TextField = /*#__PURE__*/function (_Component) {
144
144
  })
145
145
  });
146
146
  }
147
+ }], [{
148
+ key: "toFieldErrors",
149
+ value:
150
+ /**
151
+ * Use this function to convert the Formik `errors` object type to
152
+ * our custom field errors type.
153
+ * This is primarly useful when using TypeScript.
154
+ */
155
+ function toFieldErrors(errors) {
156
+ return errors;
157
+ }
147
158
  }]);
148
159
 
149
160
  return TextField;
@@ -187,7 +198,7 @@ TextField.propTypes = process.env.NODE_ENV !== "production" ? {
187
198
  var TextField$1 = TextField;
188
199
 
189
200
  // NOTE: This string will be replaced on build time with the package version.
190
- var version = "14.0.0";
201
+ var version = "14.0.1";
191
202
 
192
203
  exports["default"] = TextField$1;
193
204
  exports.version = version;
@@ -139,6 +139,17 @@ var TextField = /*#__PURE__*/function (_Component) {
139
139
  })
140
140
  });
141
141
  }
142
+ }], [{
143
+ key: "toFieldErrors",
144
+ value:
145
+ /**
146
+ * Use this function to convert the Formik `errors` object type to
147
+ * our custom field errors type.
148
+ * This is primarly useful when using TypeScript.
149
+ */
150
+ function toFieldErrors(errors) {
151
+ return errors;
152
+ }
142
153
  }]);
143
154
 
144
155
  return TextField;
@@ -159,7 +170,7 @@ TextField.propTypes = {};
159
170
  var TextField$1 = TextField;
160
171
 
161
172
  // NOTE: This string will be replaced on build time with the package version.
162
- var version = "14.0.0";
173
+ var version = "14.0.1";
163
174
 
164
175
  exports["default"] = TextField$1;
165
176
  exports.version = version;
@@ -119,6 +119,17 @@ var TextField = /*#__PURE__*/function (_Component) {
119
119
  })
120
120
  });
121
121
  }
122
+ }], [{
123
+ key: "toFieldErrors",
124
+ value:
125
+ /**
126
+ * Use this function to convert the Formik `errors` object type to
127
+ * our custom field errors type.
128
+ * This is primarly useful when using TypeScript.
129
+ */
130
+ function toFieldErrors(errors) {
131
+ return errors;
132
+ }
122
133
  }]);
123
134
 
124
135
  return TextField;
@@ -162,6 +173,6 @@ TextField.propTypes = process.env.NODE_ENV !== "production" ? {
162
173
  var TextField$1 = TextField;
163
174
 
164
175
  // NOTE: This string will be replaced on build time with the package version.
165
- var version = "14.0.0";
176
+ var version = "14.0.1";
166
177
 
167
178
  export { TextField$1 as default, version };
@@ -1,6 +1,9 @@
1
1
  import { Component, type ChangeEventHandler, type FocusEventHandler, type ReactElement, type ReactNode } from 'react';
2
2
  declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
3
3
  declare type TFieldErrors = Record<string, boolean>;
4
+ declare type TCustomFormErrors<Values> = {
5
+ [K in keyof Values]?: TFieldErrors;
6
+ };
4
7
  declare type TTextFieldProps = {
5
8
  id?: string;
6
9
  horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
@@ -35,6 +38,7 @@ declare class TextField extends Component<TTextFieldProps, TTextFieldState> {
35
38
  static getDerivedStateFromProps: (props: TTextFieldProps, state: TTextFieldState) => {
36
39
  id: string;
37
40
  };
41
+ static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
38
42
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
39
43
  }
40
44
  export default TextField;
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": "14.0.0",
4
+ "version": "14.0.1",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,13 +21,13 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.17.2",
23
23
  "@babel/runtime-corejs3": "^7.17.2",
24
- "@commercetools-uikit/constraints": "14.0.0",
24
+ "@commercetools-uikit/constraints": "14.0.1",
25
25
  "@commercetools-uikit/design-system": "14.0.0",
26
- "@commercetools-uikit/field-errors": "14.0.0",
27
- "@commercetools-uikit/field-label": "14.0.0",
28
- "@commercetools-uikit/spacings-stack": "14.0.0",
29
- "@commercetools-uikit/text-input": "14.0.0",
30
- "@commercetools-uikit/utils": "14.0.0",
26
+ "@commercetools-uikit/field-errors": "14.0.1",
27
+ "@commercetools-uikit/field-label": "14.0.1",
28
+ "@commercetools-uikit/spacings-stack": "14.0.1",
29
+ "@commercetools-uikit/text-input": "14.0.1",
30
+ "@commercetools-uikit/utils": "14.0.1",
31
31
  "@emotion/react": "^11.4.0",
32
32
  "@emotion/styled": "^11.3.0",
33
33
  "prop-types": "15.8.1",