@commercetools-uikit/search-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-search-select-field.cjs.dev.js +18 -3
- package/dist/commercetools-uikit-search-select-field.cjs.prod.js +18 -3
- package/dist/commercetools-uikit-search-select-field.esm.js +18 -3
- package/dist/declarations/src/search-select-field.d.ts +5 -1
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -178,3 +178,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
|
|
|
178
178
|
Known error keys are:
|
|
179
179
|
|
|
180
180
|
- `missing`: tells the user that this field is required
|
|
181
|
+
|
|
182
|
+
## Static methods
|
|
183
|
+
|
|
184
|
+
### `SearchSelectField.toFieldErrors`
|
|
185
|
+
|
|
186
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
type FormValues = {
|
|
190
|
+
myField: string;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
<SearchSelectField
|
|
194
|
+
// ...
|
|
195
|
+
name="my-field"
|
|
196
|
+
errors={SearchSelectField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
197
|
+
/>;
|
|
198
|
+
```
|
|
@@ -18,6 +18,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
18
18
|
var react = require('react');
|
|
19
19
|
var utils = require('@commercetools-uikit/utils');
|
|
20
20
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
21
|
+
var hooks = require('@commercetools-uikit/hooks');
|
|
21
22
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
22
23
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
23
24
|
var SearchSelectInput = require('@commercetools-uikit/search-select-input');
|
|
@@ -54,11 +55,12 @@ var hasErrors = function hasErrors(errors) {
|
|
|
54
55
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
var sequentialId = utils.createSequentialId('
|
|
58
|
+
var sequentialId = utils.createSequentialId('search-select-field-');
|
|
59
|
+
var sequentialErrorsId = utils.createSequentialId('search-select-field-error-')();
|
|
58
60
|
|
|
59
61
|
var SearchSelectField = function SearchSelectField(props) {
|
|
60
62
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
61
|
-
var id = props.id
|
|
63
|
+
var id = hooks.useFieldId(props.id, sequentialId);
|
|
62
64
|
|
|
63
65
|
if (props.hintIcon) {
|
|
64
66
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.hint === 'string' || /*#__PURE__*/react.isValidElement(props.hint), 'SearchSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
@@ -87,6 +89,8 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
87
89
|
hasError: hasError,
|
|
88
90
|
"aria-label": props['aria-label'],
|
|
89
91
|
"aria-labelledby": props['aria-labelledby?'],
|
|
92
|
+
"aria-invalid": hasError,
|
|
93
|
+
"aria-errormessage": sequentialErrorsId,
|
|
90
94
|
isAutofocussed: props.isAutofocussed,
|
|
91
95
|
backspaceRemovesValue: props.backspaceRemovesValue,
|
|
92
96
|
components: props.components,
|
|
@@ -120,6 +124,7 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
120
124
|
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
121
125
|
optionType: props.optionType
|
|
122
126
|
})), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
127
|
+
id: sequentialErrorsId,
|
|
123
128
|
errors: props.errors,
|
|
124
129
|
isVisible: hasError,
|
|
125
130
|
renderError: props.renderError
|
|
@@ -155,10 +160,20 @@ SearchSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
155
160
|
badge: _pt__default["default"].node
|
|
156
161
|
} : {};
|
|
157
162
|
SearchSelectField.displayName = 'SearchSelectField';
|
|
163
|
+
/**
|
|
164
|
+
* Use this function to convert the Formik `errors` object type to
|
|
165
|
+
* our custom field errors type.
|
|
166
|
+
* This is primarly useful when using TypeScript.
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
SearchSelectField.toFieldErrors = function toFieldErrors(errors) {
|
|
170
|
+
return errors;
|
|
171
|
+
};
|
|
172
|
+
|
|
158
173
|
var SearchSelectField$1 = SearchSelectField;
|
|
159
174
|
|
|
160
175
|
// NOTE: This string will be replaced on build time with the package version.
|
|
161
|
-
var version = "
|
|
176
|
+
var version = "14.0.1";
|
|
162
177
|
|
|
163
178
|
exports["default"] = SearchSelectField$1;
|
|
164
179
|
exports.version = version;
|
|
@@ -18,6 +18,7 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
18
18
|
require('react');
|
|
19
19
|
var utils = require('@commercetools-uikit/utils');
|
|
20
20
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
21
|
+
var hooks = require('@commercetools-uikit/hooks');
|
|
21
22
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
22
23
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
23
24
|
var SearchSelectInput = require('@commercetools-uikit/search-select-input');
|
|
@@ -52,11 +53,12 @@ var hasErrors = function hasErrors(errors) {
|
|
|
52
53
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
var sequentialId = utils.createSequentialId('
|
|
56
|
+
var sequentialId = utils.createSequentialId('search-select-field-');
|
|
57
|
+
var sequentialErrorsId = utils.createSequentialId('search-select-field-error-')();
|
|
56
58
|
|
|
57
59
|
var SearchSelectField = function SearchSelectField(props) {
|
|
58
60
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
59
|
-
var id = props.id
|
|
61
|
+
var id = hooks.useFieldId(props.id, sequentialId);
|
|
60
62
|
|
|
61
63
|
if (props.hintIcon) ;
|
|
62
64
|
|
|
@@ -80,6 +82,8 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
80
82
|
hasError: hasError,
|
|
81
83
|
"aria-label": props['aria-label'],
|
|
82
84
|
"aria-labelledby": props['aria-labelledby?'],
|
|
85
|
+
"aria-invalid": hasError,
|
|
86
|
+
"aria-errormessage": sequentialErrorsId,
|
|
83
87
|
isAutofocussed: props.isAutofocussed,
|
|
84
88
|
backspaceRemovesValue: props.backspaceRemovesValue,
|
|
85
89
|
components: props.components,
|
|
@@ -113,6 +117,7 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
113
117
|
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
114
118
|
optionType: props.optionType
|
|
115
119
|
})), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
120
|
+
id: sequentialErrorsId,
|
|
116
121
|
errors: props.errors,
|
|
117
122
|
isVisible: hasError,
|
|
118
123
|
renderError: props.renderError
|
|
@@ -123,10 +128,20 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
123
128
|
|
|
124
129
|
SearchSelectField.propTypes = {};
|
|
125
130
|
SearchSelectField.displayName = 'SearchSelectField';
|
|
131
|
+
/**
|
|
132
|
+
* Use this function to convert the Formik `errors` object type to
|
|
133
|
+
* our custom field errors type.
|
|
134
|
+
* This is primarly useful when using TypeScript.
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
SearchSelectField.toFieldErrors = function toFieldErrors(errors) {
|
|
138
|
+
return errors;
|
|
139
|
+
};
|
|
140
|
+
|
|
126
141
|
var SearchSelectField$1 = SearchSelectField;
|
|
127
142
|
|
|
128
143
|
// NOTE: This string will be replaced on build time with the package version.
|
|
129
|
-
var version = "
|
|
144
|
+
var version = "14.0.1";
|
|
130
145
|
|
|
131
146
|
exports["default"] = SearchSelectField$1;
|
|
132
147
|
exports.version = version;
|
|
@@ -14,6 +14,7 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
|
|
|
14
14
|
import { isValidElement } from 'react';
|
|
15
15
|
import { createSequentialId, warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
16
16
|
import Constraints from '@commercetools-uikit/constraints';
|
|
17
|
+
import { useFieldId } from '@commercetools-uikit/hooks';
|
|
17
18
|
import Spacings from '@commercetools-uikit/spacings';
|
|
18
19
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
19
20
|
import SearchSelectInput from '@commercetools-uikit/search-select-input';
|
|
@@ -30,11 +31,12 @@ var hasErrors = function hasErrors(errors) {
|
|
|
30
31
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
var sequentialId = createSequentialId('
|
|
34
|
+
var sequentialId = createSequentialId('search-select-field-');
|
|
35
|
+
var sequentialErrorsId = createSequentialId('search-select-field-error-')();
|
|
34
36
|
|
|
35
37
|
var SearchSelectField = function SearchSelectField(props) {
|
|
36
38
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
37
|
-
var id = props.id
|
|
39
|
+
var id = useFieldId(props.id, sequentialId);
|
|
38
40
|
|
|
39
41
|
if (props.hintIcon) {
|
|
40
42
|
process.env.NODE_ENV !== "production" ? warning(typeof props.hint === 'string' || /*#__PURE__*/isValidElement(props.hint), 'SearchSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
@@ -63,6 +65,8 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
63
65
|
hasError: hasError,
|
|
64
66
|
"aria-label": props['aria-label'],
|
|
65
67
|
"aria-labelledby": props['aria-labelledby?'],
|
|
68
|
+
"aria-invalid": hasError,
|
|
69
|
+
"aria-errormessage": sequentialErrorsId,
|
|
66
70
|
isAutofocussed: props.isAutofocussed,
|
|
67
71
|
backspaceRemovesValue: props.backspaceRemovesValue,
|
|
68
72
|
components: props.components,
|
|
@@ -96,6 +100,7 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
96
100
|
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
97
101
|
optionType: props.optionType
|
|
98
102
|
})), jsx(FieldErrors, {
|
|
103
|
+
id: sequentialErrorsId,
|
|
99
104
|
errors: props.errors,
|
|
100
105
|
isVisible: hasError,
|
|
101
106
|
renderError: props.renderError
|
|
@@ -131,9 +136,19 @@ SearchSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
131
136
|
badge: _pt.node
|
|
132
137
|
} : {};
|
|
133
138
|
SearchSelectField.displayName = 'SearchSelectField';
|
|
139
|
+
/**
|
|
140
|
+
* Use this function to convert the Formik `errors` object type to
|
|
141
|
+
* our custom field errors type.
|
|
142
|
+
* This is primarly useful when using TypeScript.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
SearchSelectField.toFieldErrors = function toFieldErrors(errors) {
|
|
146
|
+
return errors;
|
|
147
|
+
};
|
|
148
|
+
|
|
134
149
|
var SearchSelectField$1 = SearchSelectField;
|
|
135
150
|
|
|
136
151
|
// NOTE: This string will be replaced on build time with the package version.
|
|
137
|
-
var version = "
|
|
152
|
+
var version = "14.0.1";
|
|
138
153
|
|
|
139
154
|
export { SearchSelectField$1 as default, version };
|
|
@@ -9,8 +9,11 @@ declare type TEvent = {
|
|
|
9
9
|
};
|
|
10
10
|
persist: () => void;
|
|
11
11
|
};
|
|
12
|
-
declare type TFieldErrors = Record<string, boolean>;
|
|
13
12
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
13
|
+
declare type TFieldErrors = Record<string, boolean>;
|
|
14
|
+
declare type TCustomFormErrors<Values> = {
|
|
15
|
+
[K in keyof Values]?: TFieldErrors;
|
|
16
|
+
};
|
|
14
17
|
declare type TSearchSelectFieldProps = {
|
|
15
18
|
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
16
19
|
'aria-label'?: ReactSelectAsyncProps['aria-label'];
|
|
@@ -61,5 +64,6 @@ declare type TSearchSelectFieldProps = {
|
|
|
61
64
|
declare const SearchSelectField: {
|
|
62
65
|
(props: TSearchSelectFieldProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
63
66
|
displayName: string;
|
|
67
|
+
toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
64
68
|
};
|
|
65
69
|
export default SearchSelectField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/search-select-field",
|
|
3
3
|
"description": "A search select field built on top of search select input, allowing users to asynchronously search for options",
|
|
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/search-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,20 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-search-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/constraints": "
|
|
25
|
-
"@commercetools-uikit/design-system": "
|
|
26
|
-
"@commercetools-uikit/field-errors": "
|
|
27
|
-
"@commercetools-uikit/field-label": "
|
|
28
|
-
"@commercetools-uikit/
|
|
29
|
-
"@commercetools-uikit/
|
|
30
|
-
"@commercetools-uikit/
|
|
22
|
+
"@babel/runtime": "^7.17.2",
|
|
23
|
+
"@babel/runtime-corejs3": "^7.17.2",
|
|
24
|
+
"@commercetools-uikit/constraints": "14.0.1",
|
|
25
|
+
"@commercetools-uikit/design-system": "14.0.0",
|
|
26
|
+
"@commercetools-uikit/field-errors": "14.0.1",
|
|
27
|
+
"@commercetools-uikit/field-label": "14.0.1",
|
|
28
|
+
"@commercetools-uikit/hooks": "14.0.1",
|
|
29
|
+
"@commercetools-uikit/search-select-input": "14.0.1",
|
|
30
|
+
"@commercetools-uikit/spacings": "14.0.1",
|
|
31
|
+
"@commercetools-uikit/utils": "14.0.1",
|
|
31
32
|
"@emotion/react": "^11.4.0",
|
|
32
33
|
"@emotion/styled": "^11.3.0",
|
|
33
34
|
"prop-types": "15.8.1",
|
|
34
|
-
"react-
|
|
35
|
+
"react-intl": "^5.24.6"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"react": "17.0.2"
|