@commercetools-uikit/async-creatable-select-field 13.0.2 → 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 +20 -0
- package/dist/commercetools-uikit-async-creatable-select-field.cjs.dev.js +17 -2
- package/dist/commercetools-uikit-async-creatable-select-field.cjs.prod.js +16 -1
- package/dist/commercetools-uikit-async-creatable-select-field.esm.js +17 -2
- package/dist/declarations/src/async-creatable-select-field.d.ts +5 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -152,3 +152,23 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
|
|
|
152
152
|
Known error keys are:
|
|
153
153
|
|
|
154
154
|
- `missing`: tells the user that this field is required
|
|
155
|
+
|
|
156
|
+
## Static methods
|
|
157
|
+
|
|
158
|
+
### `AsyncCreatableSelectField.toFieldErrors`
|
|
159
|
+
|
|
160
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
type FormValues = {
|
|
164
|
+
myField: string;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
<AsyncCreatableSelectField
|
|
168
|
+
// ...
|
|
169
|
+
name="my-field"
|
|
170
|
+
errors={
|
|
171
|
+
AsyncCreatableSelectField.toFieldErrors<FormValues>(formik.errors).myField
|
|
172
|
+
}
|
|
173
|
+
/>;
|
|
174
|
+
```
|
|
@@ -61,6 +61,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
61
61
|
|
|
62
62
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
63
63
|
var sequentialId = utils.createSequentialId('async-creatable-select-field-');
|
|
64
|
+
var sequentialErrorsId = utils.createSequentialId('async-creatable-select-field-error-')();
|
|
64
65
|
|
|
65
66
|
var hasErrors = function hasErrors(errors) {
|
|
66
67
|
var _context;
|
|
@@ -99,7 +100,7 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
99
100
|
var hasError = AsyncCreatableSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
|
|
100
101
|
|
|
101
102
|
if (this.props.hintIcon) {
|
|
102
|
-
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), '
|
|
103
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'AsyncCreatableSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
if (this.props.isMulti) {
|
|
@@ -125,6 +126,8 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
125
126
|
hasError: hasError,
|
|
126
127
|
"aria-label": this.props['aria-label'],
|
|
127
128
|
"aria-labelledby": this.props['aria-labelledby'],
|
|
129
|
+
"aria-invalid": hasError,
|
|
130
|
+
"aria-errormessage": sequentialErrorsId,
|
|
128
131
|
isAutofocussed: this.props.isAutofocussed,
|
|
129
132
|
backspaceRemovesValue: this.props.backspaceRemovesValue,
|
|
130
133
|
components: this.props.components,
|
|
@@ -166,6 +169,7 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
166
169
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
167
170
|
iconLeft: this.props.iconLeft
|
|
168
171
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
172
|
+
id: sequentialErrorsId,
|
|
169
173
|
errors: this.props.errors,
|
|
170
174
|
isVisible: hasError,
|
|
171
175
|
renderError: this.props.renderError
|
|
@@ -173,6 +177,17 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
173
177
|
})
|
|
174
178
|
});
|
|
175
179
|
}
|
|
180
|
+
}], [{
|
|
181
|
+
key: "toFieldErrors",
|
|
182
|
+
value:
|
|
183
|
+
/**
|
|
184
|
+
* Use this function to convert the Formik `errors` object type to
|
|
185
|
+
* our custom field errors type.
|
|
186
|
+
* This is primarly useful when using TypeScript.
|
|
187
|
+
*/
|
|
188
|
+
function toFieldErrors(errors) {
|
|
189
|
+
return errors;
|
|
190
|
+
}
|
|
176
191
|
}]);
|
|
177
192
|
|
|
178
193
|
return AsyncCreatableSelectField;
|
|
@@ -211,7 +226,7 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
211
226
|
} : {};
|
|
212
227
|
|
|
213
228
|
// NOTE: This string will be replaced on build time with the package version.
|
|
214
|
-
var version = "
|
|
229
|
+
var version = "14.0.1";
|
|
215
230
|
|
|
216
231
|
exports["default"] = AsyncCreatableSelectField;
|
|
217
232
|
exports.version = version;
|
|
@@ -59,6 +59,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
59
59
|
|
|
60
60
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct__default["default"]) return false; if (_Reflect$construct__default["default"].sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
61
|
var sequentialId = utils.createSequentialId('async-creatable-select-field-');
|
|
62
|
+
var sequentialErrorsId = utils.createSequentialId('async-creatable-select-field-error-')();
|
|
62
63
|
|
|
63
64
|
var hasErrors = function hasErrors(errors) {
|
|
64
65
|
var _context;
|
|
@@ -118,6 +119,8 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
118
119
|
hasError: hasError,
|
|
119
120
|
"aria-label": this.props['aria-label'],
|
|
120
121
|
"aria-labelledby": this.props['aria-labelledby'],
|
|
122
|
+
"aria-invalid": hasError,
|
|
123
|
+
"aria-errormessage": sequentialErrorsId,
|
|
121
124
|
isAutofocussed: this.props.isAutofocussed,
|
|
122
125
|
backspaceRemovesValue: this.props.backspaceRemovesValue,
|
|
123
126
|
components: this.props.components,
|
|
@@ -159,6 +162,7 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
159
162
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
160
163
|
iconLeft: this.props.iconLeft
|
|
161
164
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
165
|
+
id: sequentialErrorsId,
|
|
162
166
|
errors: this.props.errors,
|
|
163
167
|
isVisible: hasError,
|
|
164
168
|
renderError: this.props.renderError
|
|
@@ -166,6 +170,17 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
166
170
|
})
|
|
167
171
|
});
|
|
168
172
|
}
|
|
173
|
+
}], [{
|
|
174
|
+
key: "toFieldErrors",
|
|
175
|
+
value:
|
|
176
|
+
/**
|
|
177
|
+
* Use this function to convert the Formik `errors` object type to
|
|
178
|
+
* our custom field errors type.
|
|
179
|
+
* This is primarly useful when using TypeScript.
|
|
180
|
+
*/
|
|
181
|
+
function toFieldErrors(errors) {
|
|
182
|
+
return errors;
|
|
183
|
+
}
|
|
169
184
|
}]);
|
|
170
185
|
|
|
171
186
|
return AsyncCreatableSelectField;
|
|
@@ -184,7 +199,7 @@ AsyncCreatableSelectField.getDerivedStateFromProps = function (props, state) {
|
|
|
184
199
|
AsyncCreatableSelectField.propTypes = {};
|
|
185
200
|
|
|
186
201
|
// NOTE: This string will be replaced on build time with the package version.
|
|
187
|
-
var version = "
|
|
202
|
+
var version = "14.0.1";
|
|
188
203
|
|
|
189
204
|
exports["default"] = AsyncCreatableSelectField;
|
|
190
205
|
exports.version = version;
|
|
@@ -35,6 +35,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
35
35
|
|
|
36
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
37
|
var sequentialId = createSequentialId('async-creatable-select-field-');
|
|
38
|
+
var sequentialErrorsId = createSequentialId('async-creatable-select-field-error-')();
|
|
38
39
|
|
|
39
40
|
var hasErrors = function hasErrors(errors) {
|
|
40
41
|
var _context;
|
|
@@ -73,7 +74,7 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
73
74
|
var hasError = AsyncCreatableSelectInput.isTouched(this.props.touched) && hasErrors(this.props.errors);
|
|
74
75
|
|
|
75
76
|
if (this.props.hintIcon) {
|
|
76
|
-
process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), '
|
|
77
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'AsyncCreatableSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
if (this.props.isMulti) {
|
|
@@ -99,6 +100,8 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
99
100
|
hasError: hasError,
|
|
100
101
|
"aria-label": this.props['aria-label'],
|
|
101
102
|
"aria-labelledby": this.props['aria-labelledby'],
|
|
103
|
+
"aria-invalid": hasError,
|
|
104
|
+
"aria-errormessage": sequentialErrorsId,
|
|
102
105
|
isAutofocussed: this.props.isAutofocussed,
|
|
103
106
|
backspaceRemovesValue: this.props.backspaceRemovesValue,
|
|
104
107
|
components: this.props.components,
|
|
@@ -140,6 +143,7 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
140
143
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
141
144
|
iconLeft: this.props.iconLeft
|
|
142
145
|
}, filterDataAttributes(this.props))), jsx(FieldErrors, {
|
|
146
|
+
id: sequentialErrorsId,
|
|
143
147
|
errors: this.props.errors,
|
|
144
148
|
isVisible: hasError,
|
|
145
149
|
renderError: this.props.renderError
|
|
@@ -147,6 +151,17 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
147
151
|
})
|
|
148
152
|
});
|
|
149
153
|
}
|
|
154
|
+
}], [{
|
|
155
|
+
key: "toFieldErrors",
|
|
156
|
+
value:
|
|
157
|
+
/**
|
|
158
|
+
* Use this function to convert the Formik `errors` object type to
|
|
159
|
+
* our custom field errors type.
|
|
160
|
+
* This is primarly useful when using TypeScript.
|
|
161
|
+
*/
|
|
162
|
+
function toFieldErrors(errors) {
|
|
163
|
+
return errors;
|
|
164
|
+
}
|
|
150
165
|
}]);
|
|
151
166
|
|
|
152
167
|
return AsyncCreatableSelectField;
|
|
@@ -185,6 +200,6 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
185
200
|
} : {};
|
|
186
201
|
|
|
187
202
|
// NOTE: This string will be replaced on build time with the package version.
|
|
188
|
-
var version = "
|
|
203
|
+
var version = "14.0.1";
|
|
189
204
|
|
|
190
205
|
export { AsyncCreatableSelectField as default, version };
|
|
@@ -2,8 +2,11 @@ import { Component, type ReactElement, type ReactNode } from 'react';
|
|
|
2
2
|
import type { GroupBase, ActionMeta } from 'react-select';
|
|
3
3
|
import type { AsyncCreatableProps } from 'react-select/async-creatable';
|
|
4
4
|
declare type ReactSelectAsyncCreatableProps = AsyncCreatableProps<unknown, boolean, GroupBase<unknown>>;
|
|
5
|
-
declare type TFieldErrors = Record<string, boolean>;
|
|
6
5
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
6
|
+
declare type TFieldErrors = Record<string, boolean>;
|
|
7
|
+
declare type TCustomFormErrors<Values> = {
|
|
8
|
+
[K in keyof Values]?: TFieldErrors;
|
|
9
|
+
};
|
|
7
10
|
declare type TEvent = {
|
|
8
11
|
target: {
|
|
9
12
|
name?: string;
|
|
@@ -74,6 +77,7 @@ export default class AsyncCreatableSelectField extends Component<TAsyncCreatable
|
|
|
74
77
|
static getDerivedStateFromProps: (props: TAsyncCreatableSelectFieldProps, state: TAsyncCreatableSelectFieldState) => {
|
|
75
78
|
id: string;
|
|
76
79
|
};
|
|
80
|
+
static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
77
81
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
78
82
|
}
|
|
79
83
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/async-creatable-select-field",
|
|
3
3
|
"description": "An input component with validation states and a label getting a selection from an asynchronously loaded list from the user, and where options can be created by the user.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "14.0.1",
|
|
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/async-creatable-select-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,19 +19,19 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-async-creatable-select-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/async-creatable-select-input": "
|
|
25
|
-
"@commercetools-uikit/constraints": "
|
|
26
|
-
"@commercetools-uikit/design-system": "
|
|
27
|
-
"@commercetools-uikit/field-errors": "
|
|
28
|
-
"@commercetools-uikit/field-label": "
|
|
29
|
-
"@commercetools-uikit/spacings": "
|
|
30
|
-
"@commercetools-uikit/utils": "
|
|
22
|
+
"@babel/runtime": "^7.17.2",
|
|
23
|
+
"@babel/runtime-corejs3": "^7.17.2",
|
|
24
|
+
"@commercetools-uikit/async-creatable-select-input": "14.0.1",
|
|
25
|
+
"@commercetools-uikit/constraints": "14.0.1",
|
|
26
|
+
"@commercetools-uikit/design-system": "14.0.0",
|
|
27
|
+
"@commercetools-uikit/field-errors": "14.0.1",
|
|
28
|
+
"@commercetools-uikit/field-label": "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",
|
|
34
|
-
"react-
|
|
34
|
+
"react-intl": "^5.24.6"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"react": "17.0.2"
|