@commercetools-uikit/number-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
@@ -108,3 +108,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
108
108
  Known error keys are:
109
109
 
110
110
  - `missing`: tells the user that this field is required
111
+
112
+ ## Static methods
113
+
114
+ ### `NumberField.toFieldErrors`
115
+
116
+ Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
117
+
118
+ ```ts
119
+ type FormValues = {
120
+ myField: string;
121
+ };
122
+
123
+ <NumberField
124
+ // ...
125
+ name="my-field"
126
+ errors={NumberField.toFieldErrors<FormValues>(formik.errors).myField}
127
+ />;
128
+ ```
@@ -147,6 +147,17 @@ var NumberField = /*#__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 NumberField;
@@ -193,7 +204,7 @@ NumberField.propTypes = process.env.NODE_ENV !== "production" ? {
193
204
  var NumberField$1 = NumberField;
194
205
 
195
206
  // NOTE: This string will be replaced on build time with the package version.
196
- var version = "14.0.0";
207
+ var version = "14.0.1";
197
208
 
198
209
  exports["default"] = NumberField$1;
199
210
  exports.version = version;
@@ -142,6 +142,17 @@ var NumberField = /*#__PURE__*/function (_Component) {
142
142
  })
143
143
  });
144
144
  }
145
+ }], [{
146
+ key: "toFieldErrors",
147
+ value:
148
+ /**
149
+ * Use this function to convert the Formik `errors` object type to
150
+ * our custom field errors type.
151
+ * This is primarly useful when using TypeScript.
152
+ */
153
+ function toFieldErrors(errors) {
154
+ return errors;
155
+ }
145
156
  }]);
146
157
 
147
158
  return NumberField;
@@ -162,7 +173,7 @@ NumberField.propTypes = {};
162
173
  var NumberField$1 = NumberField;
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
  exports["default"] = NumberField$1;
168
179
  exports.version = version;
@@ -122,6 +122,17 @@ var NumberField = /*#__PURE__*/function (_Component) {
122
122
  })
123
123
  });
124
124
  }
125
+ }], [{
126
+ key: "toFieldErrors",
127
+ value:
128
+ /**
129
+ * Use this function to convert the Formik `errors` object type to
130
+ * our custom field errors type.
131
+ * This is primarly useful when using TypeScript.
132
+ */
133
+ function toFieldErrors(errors) {
134
+ return errors;
135
+ }
125
136
  }]);
126
137
 
127
138
  return NumberField;
@@ -168,6 +179,6 @@ NumberField.propTypes = process.env.NODE_ENV !== "production" ? {
168
179
  var NumberField$1 = NumberField;
169
180
 
170
181
  // NOTE: This string will be replaced on build time with the package version.
171
- var version = "14.0.0";
182
+ var version = "14.0.1";
172
183
 
173
184
  export { NumberField$1 as default, version };
@@ -1,6 +1,9 @@
1
1
  import { Component, type ChangeEventHandler, type FocusEventHandler, type ReactElement, type ReactNode, type MouseEvent, type KeyboardEvent } from 'react';
2
- declare type TFieldErrors = Record<string, boolean>;
3
2
  declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
3
+ declare type TFieldErrors = Record<string, boolean>;
4
+ declare type TCustomFormErrors<Values> = {
5
+ [K in keyof Values]?: TFieldErrors;
6
+ };
4
7
  declare type TNumberFieldProps = {
5
8
  id?: string;
6
9
  horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
@@ -38,6 +41,7 @@ declare class NumberField extends Component<TNumberFieldProps, TNumberFieldState
38
41
  static getDerivedStateFromProps: (props: TNumberFieldProps, state: TNumberFieldState) => {
39
42
  id: string;
40
43
  };
44
+ static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
41
45
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
42
46
  }
43
47
  export default NumberField;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/number-field",
3
3
  "description": "A controlled input component for numbers 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/number-input": "14.0.0",
29
- "@commercetools-uikit/spacings-stack": "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/number-input": "14.0.1",
29
+ "@commercetools-uikit/spacings-stack": "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",