@commercetools-uikit/multiline-text-field 14.0.0 → 14.0.3
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 +18 -0
- package/dist/commercetools-uikit-multiline-text-field.cjs.dev.js +13 -2
- package/dist/commercetools-uikit-multiline-text-field.cjs.prod.js +12 -1
- package/dist/commercetools-uikit-multiline-text-field.esm.js +13 -2
- package/dist/declarations/src/multiline-text-field.d.ts +7 -3
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -104,3 +104,21 @@ Known error keys are:
|
|
|
104
104
|
## Main Functions and use cases are:
|
|
105
105
|
|
|
106
106
|
- Input field for multi-line strings
|
|
107
|
+
|
|
108
|
+
## Static methods
|
|
109
|
+
|
|
110
|
+
### `MultilineTextField.toFieldErrors`
|
|
111
|
+
|
|
112
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
type FormValues = {
|
|
116
|
+
myField: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
<MultilineTextField
|
|
120
|
+
// ...
|
|
121
|
+
name="my-field"
|
|
122
|
+
errors={MultilineTextField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
123
|
+
/>;
|
|
124
|
+
```
|
|
@@ -98,7 +98,7 @@ var MultilineTextField = /*#__PURE__*/function (_Component) {
|
|
|
98
98
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
99
99
|
|
|
100
100
|
if (!this.props.isReadOnly) {
|
|
101
|
-
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'MultilineField: "onChange" is required when is not read only.') : void 0;
|
|
101
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'MultilineField: "onChange" is required when field is not read only.') : void 0;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (this.props.hint) {
|
|
@@ -145,6 +145,17 @@ var MultilineTextField = /*#__PURE__*/function (_Component) {
|
|
|
145
145
|
})
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
+
}], [{
|
|
149
|
+
key: "toFieldErrors",
|
|
150
|
+
value:
|
|
151
|
+
/**
|
|
152
|
+
* Use this function to convert the Formik `errors` object type to
|
|
153
|
+
* our custom field errors type.
|
|
154
|
+
* This is primarly useful when using TypeScript.
|
|
155
|
+
*/
|
|
156
|
+
function toFieldErrors(errors) {
|
|
157
|
+
return errors;
|
|
158
|
+
}
|
|
148
159
|
}]);
|
|
149
160
|
|
|
150
161
|
return MultilineTextField;
|
|
@@ -189,7 +200,7 @@ MultilineTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
189
200
|
var MultilineTextField$1 = MultilineTextField;
|
|
190
201
|
|
|
191
202
|
// NOTE: This string will be replaced on build time with the package version.
|
|
192
|
-
var version = "14.0.
|
|
203
|
+
var version = "14.0.3";
|
|
193
204
|
|
|
194
205
|
exports["default"] = MultilineTextField$1;
|
|
195
206
|
exports.version = version;
|
|
@@ -140,6 +140,17 @@ var MultilineTextField = /*#__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 MultilineTextField;
|
|
@@ -160,7 +171,7 @@ MultilineTextField.propTypes = {};
|
|
|
160
171
|
var MultilineTextField$1 = MultilineTextField;
|
|
161
172
|
|
|
162
173
|
// NOTE: This string will be replaced on build time with the package version.
|
|
163
|
-
var version = "14.0.
|
|
174
|
+
var version = "14.0.3";
|
|
164
175
|
|
|
165
176
|
exports["default"] = MultilineTextField$1;
|
|
166
177
|
exports.version = version;
|
|
@@ -73,7 +73,7 @@ var MultilineTextField = /*#__PURE__*/function (_Component) {
|
|
|
73
73
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
74
74
|
|
|
75
75
|
if (!this.props.isReadOnly) {
|
|
76
|
-
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'MultilineField: "onChange" is required when is not read only.') : void 0;
|
|
76
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'MultilineField: "onChange" is required when field is not read only.') : void 0;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (this.props.hint) {
|
|
@@ -120,6 +120,17 @@ var MultilineTextField = /*#__PURE__*/function (_Component) {
|
|
|
120
120
|
})
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
+
}], [{
|
|
124
|
+
key: "toFieldErrors",
|
|
125
|
+
value:
|
|
126
|
+
/**
|
|
127
|
+
* Use this function to convert the Formik `errors` object type to
|
|
128
|
+
* our custom field errors type.
|
|
129
|
+
* This is primarly useful when using TypeScript.
|
|
130
|
+
*/
|
|
131
|
+
function toFieldErrors(errors) {
|
|
132
|
+
return errors;
|
|
133
|
+
}
|
|
123
134
|
}]);
|
|
124
135
|
|
|
125
136
|
return MultilineTextField;
|
|
@@ -164,6 +175,6 @@ MultilineTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
164
175
|
var MultilineTextField$1 = MultilineTextField;
|
|
165
176
|
|
|
166
177
|
// NOTE: This string will be replaced on build time with the package version.
|
|
167
|
-
var version = "14.0.
|
|
178
|
+
var version = "14.0.3";
|
|
168
179
|
|
|
169
180
|
export { MultilineTextField$1 as default, version };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type ChangeEventHandler, type FocusEventHandler, type ReactElement, type ReactNode, Component } from 'react';
|
|
2
2
|
export declare type TFieldErrors = Record<string, boolean>;
|
|
3
|
+
declare type TCustomFormErrors<Values> = {
|
|
4
|
+
[K in keyof Values]?: TFieldErrors;
|
|
5
|
+
};
|
|
3
6
|
export declare type TMultiTextFieldProps = {
|
|
4
7
|
id?: string;
|
|
5
8
|
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
@@ -9,9 +12,9 @@ export declare type TMultiTextFieldProps = {
|
|
|
9
12
|
autoComplete?: string;
|
|
10
13
|
name?: string;
|
|
11
14
|
value: string;
|
|
12
|
-
onChange?: ChangeEventHandler
|
|
13
|
-
onBlur?: FocusEventHandler
|
|
14
|
-
onFocus?: FocusEventHandler
|
|
15
|
+
onChange?: ChangeEventHandler<HTMLTextAreaElement>;
|
|
16
|
+
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
|
|
17
|
+
onFocus?: FocusEventHandler<HTMLTextAreaElement>;
|
|
15
18
|
isAutofocussed?: boolean;
|
|
16
19
|
defaultExpandMultilineText?: boolean;
|
|
17
20
|
isDisabled?: boolean;
|
|
@@ -38,6 +41,7 @@ declare class MultilineTextField extends Component<TMultiTextFieldProps, TState>
|
|
|
38
41
|
static getDerivedStateFromProps: (props: TMultiTextFieldProps, state: TState) => {
|
|
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 MultilineTextField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/multiline-text-field",
|
|
3
3
|
"description": "A controlled text input component for multi-line strings with validation states and a label.",
|
|
4
|
-
"version": "14.0.
|
|
4
|
+
"version": "14.0.3",
|
|
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.
|
|
24
|
+
"@commercetools-uikit/constraints": "14.0.1",
|
|
25
25
|
"@commercetools-uikit/design-system": "14.0.0",
|
|
26
|
-
"@commercetools-uikit/field-errors": "14.0.
|
|
27
|
-
"@commercetools-uikit/field-label": "14.0.
|
|
28
|
-
"@commercetools-uikit/multiline-text-input": "14.0.
|
|
29
|
-
"@commercetools-uikit/spacings": "14.0.
|
|
30
|
-
"@commercetools-uikit/utils": "14.0.
|
|
26
|
+
"@commercetools-uikit/field-errors": "14.0.1",
|
|
27
|
+
"@commercetools-uikit/field-label": "14.0.2",
|
|
28
|
+
"@commercetools-uikit/multiline-text-input": "14.0.3",
|
|
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",
|