@commercetools-uikit/creatable-select-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
@@ -147,3 +147,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
147
147
  Known error keys are:
148
148
 
149
149
  - `missing`: tells the user that this field is required
150
+
151
+ ## Static methods
152
+
153
+ ### `CreatableSelectField.toFieldErrors`
154
+
155
+ Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
156
+
157
+ ```ts
158
+ type FormValues = {
159
+ myField: string;
160
+ };
161
+
162
+ <CreatableSelectField
163
+ // ...
164
+ name="my-field"
165
+ errors={CreatableSelectField.toFieldErrors<FormValues>(formik.errors).myField}
166
+ />;
167
+ ```
@@ -173,6 +173,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
173
173
  })
174
174
  });
175
175
  }
176
+ }], [{
177
+ key: "toFieldErrors",
178
+ value:
179
+ /**
180
+ * Use this function to convert the Formik `errors` object type to
181
+ * our custom field errors type.
182
+ * This is primarly useful when using TypeScript.
183
+ */
184
+ function toFieldErrors(errors) {
185
+ return errors;
186
+ }
176
187
  }]);
177
188
 
178
189
  return CreatableSelectField;
@@ -218,7 +229,7 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
218
229
  } : {};
219
230
 
220
231
  // NOTE: This string will be replaced on build time with the package version.
221
- var version = "14.0.0";
232
+ var version = "14.0.1";
222
233
 
223
234
  exports["default"] = CreatableSelectField;
224
235
  exports.version = version;
@@ -166,6 +166,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
166
166
  })
167
167
  });
168
168
  }
169
+ }], [{
170
+ key: "toFieldErrors",
171
+ value:
172
+ /**
173
+ * Use this function to convert the Formik `errors` object type to
174
+ * our custom field errors type.
175
+ * This is primarly useful when using TypeScript.
176
+ */
177
+ function toFieldErrors(errors) {
178
+ return errors;
179
+ }
169
180
  }]);
170
181
 
171
182
  return CreatableSelectField;
@@ -184,7 +195,7 @@ CreatableSelectField.getDerivedStateFromProps = function (props, state) {
184
195
  CreatableSelectField.propTypes = {};
185
196
 
186
197
  // NOTE: This string will be replaced on build time with the package version.
187
- var version = "14.0.0";
198
+ var version = "14.0.1";
188
199
 
189
200
  exports["default"] = CreatableSelectField;
190
201
  exports.version = version;
@@ -147,6 +147,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
147
147
  })
148
148
  });
149
149
  }
150
+ }], [{
151
+ key: "toFieldErrors",
152
+ value:
153
+ /**
154
+ * Use this function to convert the Formik `errors` object type to
155
+ * our custom field errors type.
156
+ * This is primarly useful when using TypeScript.
157
+ */
158
+ function toFieldErrors(errors) {
159
+ return errors;
160
+ }
150
161
  }]);
151
162
 
152
163
  return CreatableSelectField;
@@ -192,6 +203,6 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
192
203
  } : {};
193
204
 
194
205
  // NOTE: This string will be replaced on build time with the package version.
195
- var version = "14.0.0";
206
+ var version = "14.0.1";
196
207
 
197
208
  export { CreatableSelectField as default, version };
@@ -4,6 +4,9 @@ import type { CreatableProps } from 'react-select/creatable';
4
4
  declare type ReactSelectCreatableProps = CreatableProps<unknown, boolean, GroupBase<unknown>>;
5
5
  declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
6
6
  declare type TFieldErrors = Record<string, boolean>;
7
+ declare type TCustomFormErrors<Values> = {
8
+ [K in keyof Values]?: TFieldErrors;
9
+ };
7
10
  declare type TValue = {
8
11
  value: string;
9
12
  };
@@ -80,6 +83,7 @@ export default class CreatableSelectField extends Component<TCreatableSelectFiel
80
83
  static getDerivedStateFromProps: (props: TCreatableSelectFieldProps, state: TCreatableSelectFieldState) => {
81
84
  id: string;
82
85
  };
86
+ static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
83
87
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
84
88
  }
85
89
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/creatable-select-field",
3
3
  "description": "A controlled input component with validation states and a label getting a selection from the user, and where options can also be created by the user.",
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",
25
- "@commercetools-uikit/creatable-select-input": "14.0.0",
24
+ "@commercetools-uikit/constraints": "14.0.1",
25
+ "@commercetools-uikit/creatable-select-input": "14.0.1",
26
26
  "@commercetools-uikit/design-system": "14.0.0",
27
- "@commercetools-uikit/field-errors": "14.0.0",
28
- "@commercetools-uikit/field-label": "14.0.0",
29
- "@commercetools-uikit/spacings": "14.0.0",
30
- "@commercetools-uikit/utils": "14.0.0",
27
+ "@commercetools-uikit/field-errors": "14.0.1",
28
+ "@commercetools-uikit/field-label": "14.0.1",
29
+ "@commercetools-uikit/spacings": "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",