@commercetools-uikit/money-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
@@ -157,3 +157,21 @@ Known error keys are:
157
157
  ## Main Functions and use cases are:
158
158
 
159
159
  - Getting monetary value input with a currency from users (with cent precision or high precision)
160
+
161
+ ## Static methods
162
+
163
+ ### `MoneyField.toFieldErrors`
164
+
165
+ Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
166
+
167
+ ```ts
168
+ type FormValues = {
169
+ myField: string;
170
+ };
171
+
172
+ <MoneyField
173
+ // ...
174
+ name="my-field"
175
+ errors={MoneyField.toFieldErrors<FormValues>(formik.errors).myField}
176
+ />;
177
+ ```
@@ -149,6 +149,17 @@ var MoneyField = /*#__PURE__*/function (_Component) {
149
149
  })
150
150
  });
151
151
  }
152
+ }], [{
153
+ key: "toFieldErrors",
154
+ value:
155
+ /**
156
+ * Use this function to convert the Formik `errors` object type to
157
+ * our custom field errors type.
158
+ * This is primarly useful when using TypeScript.
159
+ */
160
+ function toFieldErrors(errors) {
161
+ return errors;
162
+ }
152
163
  }]);
153
164
 
154
165
  return MoneyField;
@@ -201,7 +212,7 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
201
212
  var MoneyField$1 = MoneyField;
202
213
 
203
214
  // NOTE: This string will be replaced on build time with the package version.
204
- var version = "14.0.0";
215
+ var version = "14.0.1";
205
216
 
206
217
  exports["default"] = MoneyField$1;
207
218
  exports.version = version;
@@ -144,6 +144,17 @@ var MoneyField = /*#__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 MoneyField;
@@ -164,7 +175,7 @@ MoneyField.propTypes = {};
164
175
  var MoneyField$1 = MoneyField;
165
176
 
166
177
  // NOTE: This string will be replaced on build time with the package version.
167
- var version = "14.0.0";
178
+ var version = "14.0.1";
168
179
 
169
180
  exports["default"] = MoneyField$1;
170
181
  exports.version = version;
@@ -123,6 +123,17 @@ var MoneyField = /*#__PURE__*/function (_Component) {
123
123
  })
124
124
  });
125
125
  }
126
+ }], [{
127
+ key: "toFieldErrors",
128
+ value:
129
+ /**
130
+ * Use this function to convert the Formik `errors` object type to
131
+ * our custom field errors type.
132
+ * This is primarly useful when using TypeScript.
133
+ */
134
+ function toFieldErrors(errors) {
135
+ return errors;
136
+ }
126
137
  }]);
127
138
 
128
139
  return MoneyField;
@@ -175,6 +186,6 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
175
186
  var MoneyField$1 = MoneyField;
176
187
 
177
188
  // NOTE: This string will be replaced on build time with the package version.
178
- var version = "14.0.0";
189
+ var version = "14.0.1";
179
190
 
180
191
  export { MoneyField$1 as default, version };
@@ -1,8 +1,11 @@
1
1
  import { Component, type ReactElement, type ReactNode } from 'react';
2
2
  import { type Props as ReactSelectProps } from 'react-select';
3
3
  import { type TCurrencyCode } from '@commercetools-uikit/money-input';
4
- declare type TFieldErrors = Record<string, boolean>;
5
4
  declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
5
+ declare type TFieldErrors = Record<string, boolean>;
6
+ declare type TCustomFormErrors<Values> = {
7
+ [K in keyof Values]?: TFieldErrors;
8
+ };
6
9
  declare type TTouched = {
7
10
  amount?: boolean;
8
11
  currencyCode?: boolean;
@@ -60,6 +63,7 @@ declare class MoneyField extends Component<TMoneyFieldProps, TMoneyFieldState> {
60
63
  static getDerivedStateFromProps: (props: TMoneyFieldProps, state: TMoneyFieldState) => {
61
64
  id: string;
62
65
  };
66
+ static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
63
67
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
64
68
  }
65
69
  export default MoneyField;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/money-field",
3
3
  "description": "A controlled input component for money values with validation states and a label.",
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/money-input": "14.0.0",
29
- "@commercetools-uikit/spacings": "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/money-input": "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
  "lodash": "4.17.21",