@commercetools-uikit/search-select-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 +18 -0
- package/dist/commercetools-uikit-search-select-field.cjs.dev.js +13 -2
- package/dist/commercetools-uikit-search-select-field.cjs.prod.js +13 -2
- package/dist/commercetools-uikit-search-select-field.esm.js +13 -2
- package/dist/declarations/src/search-select-field.d.ts +5 -1
- package/package.json +8 -7
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');
|
|
@@ -59,7 +60,7 @@ var sequentialErrorsId = utils.createSequentialId('search-select-field-error-')(
|
|
|
59
60
|
|
|
60
61
|
var SearchSelectField = function SearchSelectField(props) {
|
|
61
62
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
62
|
-
var id = props.id
|
|
63
|
+
var id = hooks.useFieldId(props.id, sequentialId);
|
|
63
64
|
|
|
64
65
|
if (props.hintIcon) {
|
|
65
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;
|
|
@@ -159,10 +160,20 @@ SearchSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
159
160
|
badge: _pt__default["default"].node
|
|
160
161
|
} : {};
|
|
161
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
|
+
|
|
162
173
|
var SearchSelectField$1 = SearchSelectField;
|
|
163
174
|
|
|
164
175
|
// NOTE: This string will be replaced on build time with the package version.
|
|
165
|
-
var version = "14.0.
|
|
176
|
+
var version = "14.0.1";
|
|
166
177
|
|
|
167
178
|
exports["default"] = SearchSelectField$1;
|
|
168
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');
|
|
@@ -57,7 +58,7 @@ var sequentialErrorsId = utils.createSequentialId('search-select-field-error-')(
|
|
|
57
58
|
|
|
58
59
|
var SearchSelectField = function SearchSelectField(props) {
|
|
59
60
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
60
|
-
var id = props.id
|
|
61
|
+
var id = hooks.useFieldId(props.id, sequentialId);
|
|
61
62
|
|
|
62
63
|
if (props.hintIcon) ;
|
|
63
64
|
|
|
@@ -127,10 +128,20 @@ var SearchSelectField = function SearchSelectField(props) {
|
|
|
127
128
|
|
|
128
129
|
SearchSelectField.propTypes = {};
|
|
129
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
|
+
|
|
130
141
|
var SearchSelectField$1 = SearchSelectField;
|
|
131
142
|
|
|
132
143
|
// NOTE: This string will be replaced on build time with the package version.
|
|
133
|
-
var version = "14.0.
|
|
144
|
+
var version = "14.0.1";
|
|
134
145
|
|
|
135
146
|
exports["default"] = SearchSelectField$1;
|
|
136
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';
|
|
@@ -35,7 +36,7 @@ var sequentialErrorsId = createSequentialId('search-select-field-error-')();
|
|
|
35
36
|
|
|
36
37
|
var SearchSelectField = function SearchSelectField(props) {
|
|
37
38
|
var hasError = Boolean(props.touched) && hasErrors(props.errors);
|
|
38
|
-
var id = props.id
|
|
39
|
+
var id = useFieldId(props.id, sequentialId);
|
|
39
40
|
|
|
40
41
|
if (props.hintIcon) {
|
|
41
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;
|
|
@@ -135,9 +136,19 @@ SearchSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
135
136
|
badge: _pt.node
|
|
136
137
|
} : {};
|
|
137
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
|
+
|
|
138
149
|
var SearchSelectField$1 = SearchSelectField;
|
|
139
150
|
|
|
140
151
|
// NOTE: This string will be replaced on build time with the package version.
|
|
141
|
-
var version = "14.0.
|
|
152
|
+
var version = "14.0.1";
|
|
142
153
|
|
|
143
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": "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,14 @@
|
|
|
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/
|
|
29
|
-
"@commercetools-uikit/
|
|
30
|
-
"@commercetools-uikit/
|
|
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",
|