@commercetools-uikit/localized-text-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 +19 -1
- package/dist/commercetools-uikit-localized-text-field.cjs.dev.js +13 -2
- package/dist/commercetools-uikit-localized-text-field.cjs.prod.js +12 -1
- package/dist/commercetools-uikit-localized-text-field.esm.js +13 -2
- package/dist/declarations/src/localized-text-field.d.ts +5 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ export default Example;
|
|
|
53
53
|
| ------------------------------- | -------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
54
|
| `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
|
|
55
55
|
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
|
|
56
|
-
| `errors` | `
|
|
56
|
+
| `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.
<br />
Unknown errors will be forwarded to `renderError` |
|
|
57
57
|
| `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
|
|
58
58
|
| `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
|
|
59
59
|
| `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
@@ -107,3 +107,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
|
|
|
107
107
|
Known error keys are:
|
|
108
108
|
|
|
109
109
|
- `missing`: tells the user that this field is required
|
|
110
|
+
|
|
111
|
+
## Static methods
|
|
112
|
+
|
|
113
|
+
### `LocalizedTextField.toFieldErrors`
|
|
114
|
+
|
|
115
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
type FormValues = {
|
|
119
|
+
myField: string;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
<LocalizedTextField
|
|
123
|
+
// ...
|
|
124
|
+
name="my-field"
|
|
125
|
+
errors={LocalizedTextField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
126
|
+
/>;
|
|
127
|
+
```
|
|
@@ -148,6 +148,17 @@ var LocalizedTextField = /*#__PURE__*/function (_Component) {
|
|
|
148
148
|
})
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
+
}], [{
|
|
152
|
+
key: "toFieldErrors",
|
|
153
|
+
value:
|
|
154
|
+
/**
|
|
155
|
+
* Use this function to convert the Formik `errors` object type to
|
|
156
|
+
* our custom field errors type.
|
|
157
|
+
* This is primarly useful when using TypeScript.
|
|
158
|
+
*/
|
|
159
|
+
function toFieldErrors(errors) {
|
|
160
|
+
return errors;
|
|
161
|
+
}
|
|
151
162
|
}]);
|
|
152
163
|
|
|
153
164
|
return LocalizedTextField;
|
|
@@ -167,7 +178,7 @@ LocalizedTextField.getDerivedStateFromProps = function (props, state) {
|
|
|
167
178
|
LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
168
179
|
id: _pt__default["default"].string,
|
|
169
180
|
horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
170
|
-
errors: _pt__default["default"].
|
|
181
|
+
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
171
182
|
renderError: _pt__default["default"].func,
|
|
172
183
|
isRequired: _pt__default["default"].bool,
|
|
173
184
|
touched: _pt__default["default"].bool,
|
|
@@ -194,7 +205,7 @@ LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
194
205
|
var LocalizedTextField$1 = LocalizedTextField;
|
|
195
206
|
|
|
196
207
|
// NOTE: This string will be replaced on build time with the package version.
|
|
197
|
-
var version = "14.0.
|
|
208
|
+
var version = "14.0.1";
|
|
198
209
|
|
|
199
210
|
exports["default"] = LocalizedTextField$1;
|
|
200
211
|
exports.version = version;
|
|
@@ -143,6 +143,17 @@ var LocalizedTextField = /*#__PURE__*/function (_Component) {
|
|
|
143
143
|
})
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
+
}], [{
|
|
147
|
+
key: "toFieldErrors",
|
|
148
|
+
value:
|
|
149
|
+
/**
|
|
150
|
+
* Use this function to convert the Formik `errors` object type to
|
|
151
|
+
* our custom field errors type.
|
|
152
|
+
* This is primarly useful when using TypeScript.
|
|
153
|
+
*/
|
|
154
|
+
function toFieldErrors(errors) {
|
|
155
|
+
return errors;
|
|
156
|
+
}
|
|
146
157
|
}]);
|
|
147
158
|
|
|
148
159
|
return LocalizedTextField;
|
|
@@ -163,7 +174,7 @@ LocalizedTextField.propTypes = {};
|
|
|
163
174
|
var LocalizedTextField$1 = LocalizedTextField;
|
|
164
175
|
|
|
165
176
|
// NOTE: This string will be replaced on build time with the package version.
|
|
166
|
-
var version = "14.0.
|
|
177
|
+
var version = "14.0.1";
|
|
167
178
|
|
|
168
179
|
exports["default"] = LocalizedTextField$1;
|
|
169
180
|
exports.version = version;
|
|
@@ -123,6 +123,17 @@ var LocalizedTextField = /*#__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 LocalizedTextField;
|
|
@@ -142,7 +153,7 @@ LocalizedTextField.getDerivedStateFromProps = function (props, state) {
|
|
|
142
153
|
LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
143
154
|
id: _pt.string,
|
|
144
155
|
horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
145
|
-
errors: _pt.
|
|
156
|
+
errors: _pt.objectOf(_pt.bool),
|
|
146
157
|
renderError: _pt.func,
|
|
147
158
|
isRequired: _pt.bool,
|
|
148
159
|
touched: _pt.bool,
|
|
@@ -169,6 +180,6 @@ LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
169
180
|
var LocalizedTextField$1 = LocalizedTextField;
|
|
170
181
|
|
|
171
182
|
// NOTE: This string will be replaced on build time with the package version.
|
|
172
|
-
var version = "14.0.
|
|
183
|
+
var version = "14.0.1";
|
|
173
184
|
|
|
174
185
|
export { LocalizedTextField$1 as default, version };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Component, type ChangeEventHandler, type FocusEventHandler, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
|
|
2
|
-
import { type TFieldErrors } from '@commercetools-uikit/field-errors';
|
|
3
2
|
declare type TEvent = MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>;
|
|
4
3
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
4
|
+
declare type TFieldErrors = Record<string, boolean>;
|
|
5
|
+
declare type TCustomFormErrors<Values> = {
|
|
6
|
+
[K in keyof Values]?: TFieldErrors;
|
|
7
|
+
};
|
|
5
8
|
declare type TLocalizedTextFieldProps = {
|
|
6
9
|
id?: string;
|
|
7
10
|
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
@@ -40,6 +43,7 @@ declare class LocalizedTextField extends Component<TLocalizedTextFieldProps, TLo
|
|
|
40
43
|
static getDerivedStateFromProps: (props: TLocalizedTextFieldProps, state: TLocalizedTextFieldSTate) => {
|
|
41
44
|
id: string;
|
|
42
45
|
};
|
|
46
|
+
static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
43
47
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
44
48
|
}
|
|
45
49
|
export default LocalizedTextField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/localized-text-field",
|
|
3
3
|
"description": "A controlled text input component for localized single-line strings with validation states.",
|
|
4
|
-
"version": "14.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.
|
|
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/localized-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.1",
|
|
28
|
+
"@commercetools-uikit/localized-text-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
|
"prop-types": "15.8.1",
|