@commercetools-uikit/radio-field 13.0.4 → 14.0.2
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
|
@@ -114,3 +114,21 @@ Known error keys are:
|
|
|
114
114
|
## Main Functions and use cases are:
|
|
115
115
|
|
|
116
116
|
- Single option selection field in login forms
|
|
117
|
+
|
|
118
|
+
## Static methods
|
|
119
|
+
|
|
120
|
+
### `RadioField.toFieldErrors`
|
|
121
|
+
|
|
122
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
type FormValues = {
|
|
126
|
+
myField: string;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
<RadioField
|
|
130
|
+
// ...
|
|
131
|
+
name="my-field"
|
|
132
|
+
errors={RadioField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
133
|
+
/>;
|
|
134
|
+
```
|
|
@@ -97,7 +97,7 @@ var RadioField = /*#__PURE__*/function (_Component) {
|
|
|
97
97
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
98
98
|
|
|
99
99
|
if (!this.props.isReadOnly) {
|
|
100
|
-
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when
|
|
100
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when field is not read only.') : void 0;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
if (this.props.hintIcon) {
|
|
@@ -140,6 +140,17 @@ var RadioField = /*#__PURE__*/function (_Component) {
|
|
|
140
140
|
})
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
+
}], [{
|
|
144
|
+
key: "toFieldErrors",
|
|
145
|
+
value:
|
|
146
|
+
/**
|
|
147
|
+
* Use this function to convert the Formik `errors` object type to
|
|
148
|
+
* our custom field errors type.
|
|
149
|
+
* This is primarly useful when using TypeScript.
|
|
150
|
+
*/
|
|
151
|
+
function toFieldErrors(errors) {
|
|
152
|
+
return errors;
|
|
153
|
+
}
|
|
143
154
|
}]);
|
|
144
155
|
|
|
145
156
|
return RadioField;
|
|
@@ -183,7 +194,7 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
183
194
|
var RadioField$1 = RadioField;
|
|
184
195
|
|
|
185
196
|
// NOTE: This string will be replaced on build time with the package version.
|
|
186
|
-
var version = "
|
|
197
|
+
var version = "14.0.2";
|
|
187
198
|
|
|
188
199
|
exports["default"] = RadioField$1;
|
|
189
200
|
exports.version = version;
|
|
@@ -135,6 +135,17 @@ var RadioField = /*#__PURE__*/function (_Component) {
|
|
|
135
135
|
})
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
+
}], [{
|
|
139
|
+
key: "toFieldErrors",
|
|
140
|
+
value:
|
|
141
|
+
/**
|
|
142
|
+
* Use this function to convert the Formik `errors` object type to
|
|
143
|
+
* our custom field errors type.
|
|
144
|
+
* This is primarly useful when using TypeScript.
|
|
145
|
+
*/
|
|
146
|
+
function toFieldErrors(errors) {
|
|
147
|
+
return errors;
|
|
148
|
+
}
|
|
138
149
|
}]);
|
|
139
150
|
|
|
140
151
|
return RadioField;
|
|
@@ -155,7 +166,7 @@ RadioField.propTypes = {};
|
|
|
155
166
|
var RadioField$1 = RadioField;
|
|
156
167
|
|
|
157
168
|
// NOTE: This string will be replaced on build time with the package version.
|
|
158
|
-
var version = "
|
|
169
|
+
var version = "14.0.2";
|
|
159
170
|
|
|
160
171
|
exports["default"] = RadioField$1;
|
|
161
172
|
exports.version = version;
|
|
@@ -72,7 +72,7 @@ var RadioField = /*#__PURE__*/function (_Component) {
|
|
|
72
72
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
73
73
|
|
|
74
74
|
if (!this.props.isReadOnly) {
|
|
75
|
-
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when
|
|
75
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when field is not read only.') : void 0;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
if (this.props.hintIcon) {
|
|
@@ -115,6 +115,17 @@ var RadioField = /*#__PURE__*/function (_Component) {
|
|
|
115
115
|
})
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
+
}], [{
|
|
119
|
+
key: "toFieldErrors",
|
|
120
|
+
value:
|
|
121
|
+
/**
|
|
122
|
+
* Use this function to convert the Formik `errors` object type to
|
|
123
|
+
* our custom field errors type.
|
|
124
|
+
* This is primarly useful when using TypeScript.
|
|
125
|
+
*/
|
|
126
|
+
function toFieldErrors(errors) {
|
|
127
|
+
return errors;
|
|
128
|
+
}
|
|
118
129
|
}]);
|
|
119
130
|
|
|
120
131
|
return RadioField;
|
|
@@ -158,6 +169,6 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
158
169
|
var RadioField$1 = RadioField;
|
|
159
170
|
|
|
160
171
|
// NOTE: This string will be replaced on build time with the package version.
|
|
161
|
-
var version = "
|
|
172
|
+
var version = "14.0.2";
|
|
162
173
|
|
|
163
174
|
export { RadioField$1 as default, version };
|
|
@@ -2,6 +2,9 @@ import { Component, type ChangeEventHandler, type FocusEventHandler, type ReactE
|
|
|
2
2
|
import { type TStackProps } from '@commercetools-uikit/spacings-stack';
|
|
3
3
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
4
4
|
declare type TFieldErrors = Record<string, boolean>;
|
|
5
|
+
declare type TCustomFormErrors<Values> = {
|
|
6
|
+
[K in keyof Values]?: TFieldErrors;
|
|
7
|
+
};
|
|
5
8
|
declare type TRadioFieldProps = {
|
|
6
9
|
id?: string;
|
|
7
10
|
horizontalConstraint?: 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
@@ -11,9 +14,9 @@ declare type TRadioFieldProps = {
|
|
|
11
14
|
touched?: boolean;
|
|
12
15
|
name?: string;
|
|
13
16
|
value: string;
|
|
14
|
-
onChange?: ChangeEventHandler
|
|
15
|
-
onBlur?: FocusEventHandler
|
|
16
|
-
onFocus?: FocusEventHandler
|
|
17
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
18
|
+
onBlur?: FocusEventHandler<HTMLLabelElement>;
|
|
19
|
+
onFocus?: FocusEventHandler<HTMLLabelElement>;
|
|
17
20
|
isDisabled?: boolean;
|
|
18
21
|
isReadOnly?: boolean;
|
|
19
22
|
direction?: 'stack' | 'inline';
|
|
@@ -38,6 +41,7 @@ declare class RadioField extends Component<TRadioFieldProps, TRadioFieldStates>
|
|
|
38
41
|
static getDerivedStateFromProps: (props: TRadioFieldProps, state: TRadioFieldStates) => {
|
|
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 RadioField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/radio-field",
|
|
3
3
|
"description": "A controlled radio input component with validation states and a label.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.2",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/components/fields/radio-field"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://uikit.commercetools.com",
|
|
12
|
-
"keywords": ["javascript", "design
|
|
12
|
+
"keywords": ["javascript", "typescript", "design-system", "react", "uikit"],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-radio-field.esm.js",
|
|
20
20
|
"files": ["dist"],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/runtime": "7.17.2",
|
|
23
|
-
"@babel/runtime-corejs3": "7.17.2",
|
|
24
|
-
"@commercetools-uikit/constraints": "
|
|
25
|
-
"@commercetools-uikit/design-system": "
|
|
26
|
-
"@commercetools-uikit/field-errors": "
|
|
27
|
-
"@commercetools-uikit/field-label": "
|
|
28
|
-
"@commercetools-uikit/radio-input": "
|
|
29
|
-
"@commercetools-uikit/spacings-stack": "
|
|
30
|
-
"@commercetools-uikit/utils": "
|
|
22
|
+
"@babel/runtime": "^7.17.2",
|
|
23
|
+
"@babel/runtime-corejs3": "^7.17.2",
|
|
24
|
+
"@commercetools-uikit/constraints": "14.0.1",
|
|
25
|
+
"@commercetools-uikit/design-system": "14.0.0",
|
|
26
|
+
"@commercetools-uikit/field-errors": "14.0.1",
|
|
27
|
+
"@commercetools-uikit/field-label": "14.0.2",
|
|
28
|
+
"@commercetools-uikit/radio-input": "14.0.2",
|
|
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",
|