@commercetools-uikit/radio-field 19.9.0 → 19.10.0

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.
@@ -188,7 +188,7 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
188
188
  var RadioField$1 = RadioField;
189
189
 
190
190
  // NOTE: This string will be replaced on build time with the package version.
191
- var version = "19.9.0";
191
+ var version = "19.10.0";
192
192
 
193
193
  exports["default"] = RadioField$1;
194
194
  exports.version = version;
@@ -158,7 +158,7 @@ RadioField.propTypes = {};
158
158
  var RadioField$1 = RadioField;
159
159
 
160
160
  // NOTE: This string will be replaced on build time with the package version.
161
- var version = "19.9.0";
161
+ var version = "19.10.0";
162
162
 
163
163
  exports["default"] = RadioField$1;
164
164
  exports.version = version;
@@ -163,6 +163,6 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
163
163
  var RadioField$1 = RadioField;
164
164
 
165
165
  // NOTE: This string will be replaced on build time with the package version.
166
- var version = "19.9.0";
166
+ var version = "19.10.0";
167
167
 
168
168
  export { RadioField$1 as default, version };
@@ -7,29 +7,115 @@ type TCustomFormErrors<Values> = {
7
7
  [K in keyof Values]?: TFieldErrors;
8
8
  };
9
9
  export type TRadioFieldProps = {
10
+ /**
11
+ * Used as HTML id property. An id is auto-generated when it is not specified.
12
+ */
10
13
  id?: string;
14
+ /**
15
+ * Horizontal size limit of the input fields.
16
+ */
11
17
  horizontalConstraint?: 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
18
+ /**
19
+ * A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`.
20
+ */
12
21
  errors?: TFieldErrors;
22
+ /**
23
+ * A map of warnings. Warning messages for known warnings are rendered automatically.
24
+ * <br/>
25
+ * Unknown warnings will be forwarded to renderWarning.
26
+ */
13
27
  warnings?: TFieldWarnings;
28
+ /**
29
+ * Called with custom errors.
30
+ * <br/>
31
+ * This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
32
+ */
14
33
  renderError?: TErrorRenderer;
34
+ /**
35
+ * Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
36
+ * <br />
37
+ * It can also return null to show no warning.
38
+ */
15
39
  renderWarning?: (key: string, warning?: boolean) => ReactNode;
40
+ /**
41
+ * Indicates if the value is required. Shows an the "required asterisk" if so.
42
+ */
16
43
  isRequired?: boolean;
44
+ /**
45
+ * Indicates whether the field was touched. Errors will only be shown when the field was touched.
46
+ */
17
47
  touched?: boolean;
48
+ /**
49
+ * Used as HTML name of the input component.
50
+ */
18
51
  name?: string;
52
+ /**
53
+ * Value of the input component.
54
+ */
19
55
  value: string | boolean;
56
+ /**
57
+ * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
58
+ */
20
59
  onChange?: ChangeEventHandler<HTMLInputElement>;
60
+ /**
61
+ * Called when input is blurred
62
+ */
21
63
  onBlur?: FocusEventHandler<HTMLLabelElement>;
64
+ /**
65
+ * Called when input is focused
66
+ */
22
67
  onFocus?: FocusEventHandler<HTMLLabelElement>;
68
+ /**
69
+ * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
70
+ */
23
71
  isDisabled?: boolean;
72
+ /**
73
+ * Indicates that the field is displaying read-only content
74
+ */
24
75
  isReadOnly?: boolean;
76
+ /**
77
+ * Rendering direction of the radio `RadioInput.Option`s
78
+ */
25
79
  direction?: 'stack' | 'inline';
80
+ /**
81
+ * Passes props of the `Spacings.Stack` or `Spacings.Inline`, depending on the chosen direction
82
+ */
26
83
  directionProps?: Partial<TStackProps>;
84
+ /**
85
+ * At least one `RadioInput.Option` component or another node (mixed children are allowed)
86
+ */
27
87
  children: ReactNode;
88
+ /**
89
+ * Title of the label
90
+ */
28
91
  title: string | ReactNode;
92
+ /**
93
+ * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.
94
+ * <br />
95
+ * Can also receive a `hintIcon`.
96
+ */
29
97
  hint?: string | ReactNode;
98
+ /**
99
+ * Provides a description for the title.
100
+ */
30
101
  description?: string | ReactNode;
102
+ /**
103
+ * Function called when info button is pressed.
104
+ * <br />
105
+ * Info button will only be visible when this prop is passed.
106
+ */
31
107
  onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
108
+ /**
109
+ * Icon to be displayed beside the hint text.
110
+ * <br />
111
+ * Will only get rendered when `hint` is passed as well.
112
+ */
32
113
  hintIcon?: ReactElement;
114
+ /**
115
+ * Badge to be displayed beside the label.
116
+ * <br />
117
+ * Might be used to display additional information about the content of the field (E.g verified email)
118
+ */
33
119
  badge?: ReactNode;
34
120
  };
35
121
  type TRadioFieldStates = Pick<TRadioFieldProps, 'id'>;
@@ -44,6 +130,11 @@ declare class RadioField extends Component<TRadioFieldProps, TRadioFieldStates>
44
130
  static getDerivedStateFromProps: (props: TRadioFieldProps, state: TRadioFieldStates) => {
45
131
  id: string;
46
132
  };
133
+ /**
134
+ * Use this function to convert the Formik `errors` object type to
135
+ * our custom field errors type.
136
+ * This is primarly useful when using TypeScript.
137
+ */
47
138
  static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
48
139
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
49
140
  }
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": "19.9.0",
4
+ "version": "19.10.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/constraints": "19.9.0",
25
- "@commercetools-uikit/design-system": "19.9.0",
26
- "@commercetools-uikit/field-errors": "19.9.0",
27
- "@commercetools-uikit/field-label": "19.9.0",
28
- "@commercetools-uikit/field-warnings": "19.9.0",
29
- "@commercetools-uikit/radio-input": "19.9.0",
30
- "@commercetools-uikit/spacings-stack": "19.9.0",
31
- "@commercetools-uikit/utils": "19.9.0",
24
+ "@commercetools-uikit/constraints": "19.10.0",
25
+ "@commercetools-uikit/design-system": "19.10.0",
26
+ "@commercetools-uikit/field-errors": "19.10.0",
27
+ "@commercetools-uikit/field-label": "19.10.0",
28
+ "@commercetools-uikit/field-warnings": "19.10.0",
29
+ "@commercetools-uikit/radio-input": "19.10.0",
30
+ "@commercetools-uikit/spacings-stack": "19.10.0",
31
+ "@commercetools-uikit/utils": "19.10.0",
32
32
  "@emotion/react": "^11.10.5",
33
33
  "@emotion/styled": "^11.10.5",
34
34
  "prop-types": "15.8.1",