@commercetools-uikit/async-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 +18 -0
- package/dist/commercetools-uikit-async-select-field.cjs.dev.js +17 -2
- package/dist/commercetools-uikit-async-select-field.cjs.prod.js +16 -1
- package/dist/commercetools-uikit-async-select-field.esm.js +17 -2
- package/dist/declarations/src/async-select-field.d.ts +4 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -145,3 +145,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
|
|
|
145
145
|
Known error keys are:
|
|
146
146
|
|
|
147
147
|
- `missing`: tells the user that this field is required
|
|
148
|
+
|
|
149
|
+
## Static methods
|
|
150
|
+
|
|
151
|
+
### `AsyncSelectField.toFieldErrors`
|
|
152
|
+
|
|
153
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
type FormValues = {
|
|
157
|
+
myField: string;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
<AsyncSelectField
|
|
161
|
+
// ...
|
|
162
|
+
name="my-field"
|
|
163
|
+
errors={AsyncSelectField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
164
|
+
/>;
|
|
165
|
+
```
|
|
@@ -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-select-field-');
|
|
64
|
+
var sequentialErrorsId = utils.createSequentialId('async-select-field-error-')();
|
|
64
65
|
|
|
65
66
|
var hasErrors = function hasErrors(errors) {
|
|
66
67
|
var _context;
|
|
@@ -99,7 +100,7 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
99
100
|
var hasError = AsyncSelectInput__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), 'AsyncSelectField: `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 AsyncSelectField = /*#__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,
|
|
@@ -160,6 +163,7 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
160
163
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
161
164
|
iconLeft: this.props.iconLeft
|
|
162
165
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
166
|
+
id: sequentialErrorsId,
|
|
163
167
|
errors: this.props.errors,
|
|
164
168
|
isVisible: hasError,
|
|
165
169
|
renderError: this.props.renderError
|
|
@@ -167,6 +171,17 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
167
171
|
})
|
|
168
172
|
});
|
|
169
173
|
}
|
|
174
|
+
}], [{
|
|
175
|
+
key: "toFieldErrors",
|
|
176
|
+
value:
|
|
177
|
+
/**
|
|
178
|
+
* Use this function to convert the Formik `errors` object type to
|
|
179
|
+
* our custom field errors type.
|
|
180
|
+
* This is primarly useful when using TypeScript.
|
|
181
|
+
*/
|
|
182
|
+
function toFieldErrors(errors) {
|
|
183
|
+
return errors;
|
|
184
|
+
}
|
|
170
185
|
}]);
|
|
171
186
|
|
|
172
187
|
return AsyncSelectField;
|
|
@@ -208,7 +223,7 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
208
223
|
} : {};
|
|
209
224
|
|
|
210
225
|
// NOTE: This string will be replaced on build time with the package version.
|
|
211
|
-
var version = "
|
|
226
|
+
var version = "14.0.1";
|
|
212
227
|
|
|
213
228
|
exports["default"] = AsyncSelectField;
|
|
214
229
|
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-select-field-');
|
|
62
|
+
var sequentialErrorsId = utils.createSequentialId('async-select-field-error-')();
|
|
62
63
|
|
|
63
64
|
var hasErrors = function hasErrors(errors) {
|
|
64
65
|
var _context;
|
|
@@ -118,6 +119,8 @@ var AsyncSelectField = /*#__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,
|
|
@@ -153,6 +156,7 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
153
156
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
154
157
|
iconLeft: this.props.iconLeft
|
|
155
158
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
159
|
+
id: sequentialErrorsId,
|
|
156
160
|
errors: this.props.errors,
|
|
157
161
|
isVisible: hasError,
|
|
158
162
|
renderError: this.props.renderError
|
|
@@ -160,6 +164,17 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
160
164
|
})
|
|
161
165
|
});
|
|
162
166
|
}
|
|
167
|
+
}], [{
|
|
168
|
+
key: "toFieldErrors",
|
|
169
|
+
value:
|
|
170
|
+
/**
|
|
171
|
+
* Use this function to convert the Formik `errors` object type to
|
|
172
|
+
* our custom field errors type.
|
|
173
|
+
* This is primarly useful when using TypeScript.
|
|
174
|
+
*/
|
|
175
|
+
function toFieldErrors(errors) {
|
|
176
|
+
return errors;
|
|
177
|
+
}
|
|
163
178
|
}]);
|
|
164
179
|
|
|
165
180
|
return AsyncSelectField;
|
|
@@ -178,7 +193,7 @@ AsyncSelectField.getDerivedStateFromProps = function (props, state) {
|
|
|
178
193
|
AsyncSelectField.propTypes = {};
|
|
179
194
|
|
|
180
195
|
// NOTE: This string will be replaced on build time with the package version.
|
|
181
|
-
var version = "
|
|
196
|
+
var version = "14.0.1";
|
|
182
197
|
|
|
183
198
|
exports["default"] = AsyncSelectField;
|
|
184
199
|
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-select-field-');
|
|
38
|
+
var sequentialErrorsId = createSequentialId('async-select-field-error-')();
|
|
38
39
|
|
|
39
40
|
var hasErrors = function hasErrors(errors) {
|
|
40
41
|
var _context;
|
|
@@ -73,7 +74,7 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
73
74
|
var hasError = AsyncSelectInput.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), 'AsyncSelectField: `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 AsyncSelectField = /*#__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,
|
|
@@ -134,6 +137,7 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
134
137
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
135
138
|
iconLeft: this.props.iconLeft
|
|
136
139
|
}, filterDataAttributes(this.props))), jsx(FieldErrors, {
|
|
140
|
+
id: sequentialErrorsId,
|
|
137
141
|
errors: this.props.errors,
|
|
138
142
|
isVisible: hasError,
|
|
139
143
|
renderError: this.props.renderError
|
|
@@ -141,6 +145,17 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
|
|
|
141
145
|
})
|
|
142
146
|
});
|
|
143
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
|
+
}
|
|
144
159
|
}]);
|
|
145
160
|
|
|
146
161
|
return AsyncSelectField;
|
|
@@ -182,6 +197,6 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
182
197
|
} : {};
|
|
183
198
|
|
|
184
199
|
// NOTE: This string will be replaced on build time with the package version.
|
|
185
|
-
var version = "
|
|
200
|
+
var version = "14.0.1";
|
|
186
201
|
|
|
187
202
|
export { AsyncSelectField as default, version };
|
|
@@ -4,6 +4,9 @@ import type { GroupBase, OptionsOrGroups, ActionMeta } from 'react-select';
|
|
|
4
4
|
declare type ReactSelectAsyncProps = AsyncProps<unknown, boolean, GroupBase<unknown>>;
|
|
5
5
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
6
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;
|
|
@@ -69,6 +72,7 @@ export default class AsyncSelectField extends Component<TAsyncSelectFieldProps,
|
|
|
69
72
|
static getDerivedStateFromProps: (props: TAsyncSelectFieldProps, state: TAsyncSelectFieldState) => {
|
|
70
73
|
id: string;
|
|
71
74
|
};
|
|
75
|
+
static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
72
76
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
73
77
|
}
|
|
74
78
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/async-select-field",
|
|
3
3
|
"description": "A controlled input component with validation states and a label getting a selection from an asynchronously loaded list from 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-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-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-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-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"
|