@commercetools-uikit/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 +18 -0
- package/dist/commercetools-uikit-creatable-select-field.cjs.dev.js +16 -1
- package/dist/commercetools-uikit-creatable-select-field.cjs.prod.js +16 -1
- package/dist/commercetools-uikit-creatable-select-field.esm.js +16 -1
- package/dist/declarations/src/creatable-select-field.d.ts +4 -0
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -147,3 +147,21 @@ When the `key` is known, and when the value is truthy, and when `renderError` re
|
|
|
147
147
|
Known error keys are:
|
|
148
148
|
|
|
149
149
|
- `missing`: tells the user that this field is required
|
|
150
|
+
|
|
151
|
+
## Static methods
|
|
152
|
+
|
|
153
|
+
### `CreatableSelectField.toFieldErrors`
|
|
154
|
+
|
|
155
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
type FormValues = {
|
|
159
|
+
myField: string;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
<CreatableSelectField
|
|
163
|
+
// ...
|
|
164
|
+
name="my-field"
|
|
165
|
+
errors={CreatableSelectField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
166
|
+
/>;
|
|
167
|
+
```
|
|
@@ -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('creatable-select-field-');
|
|
64
|
+
var sequentialErrorsId = utils.createSequentialId('creatable-select-field-error-')();
|
|
64
65
|
|
|
65
66
|
var hasErrors = function hasErrors(errors) {
|
|
66
67
|
var _context;
|
|
@@ -125,6 +126,8 @@ var CreatableSelectField = /*#__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,
|
|
@@ -162,6 +165,7 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
162
165
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
163
166
|
iconLeft: this.props.iconLeft
|
|
164
167
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
168
|
+
id: sequentialErrorsId,
|
|
165
169
|
errors: this.props.errors,
|
|
166
170
|
isVisible: hasError,
|
|
167
171
|
renderError: this.props.renderError
|
|
@@ -169,6 +173,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
169
173
|
})
|
|
170
174
|
});
|
|
171
175
|
}
|
|
176
|
+
}], [{
|
|
177
|
+
key: "toFieldErrors",
|
|
178
|
+
value:
|
|
179
|
+
/**
|
|
180
|
+
* Use this function to convert the Formik `errors` object type to
|
|
181
|
+
* our custom field errors type.
|
|
182
|
+
* This is primarly useful when using TypeScript.
|
|
183
|
+
*/
|
|
184
|
+
function toFieldErrors(errors) {
|
|
185
|
+
return errors;
|
|
186
|
+
}
|
|
172
187
|
}]);
|
|
173
188
|
|
|
174
189
|
return CreatableSelectField;
|
|
@@ -214,7 +229,7 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
214
229
|
} : {};
|
|
215
230
|
|
|
216
231
|
// NOTE: This string will be replaced on build time with the package version.
|
|
217
|
-
var version = "
|
|
232
|
+
var version = "14.0.1";
|
|
218
233
|
|
|
219
234
|
exports["default"] = CreatableSelectField;
|
|
220
235
|
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('creatable-select-field-');
|
|
62
|
+
var sequentialErrorsId = utils.createSequentialId('creatable-select-field-error-')();
|
|
62
63
|
|
|
63
64
|
var hasErrors = function hasErrors(errors) {
|
|
64
65
|
var _context;
|
|
@@ -118,6 +119,8 @@ var CreatableSelectField = /*#__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,
|
|
@@ -155,6 +158,7 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
155
158
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
156
159
|
iconLeft: this.props.iconLeft
|
|
157
160
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
161
|
+
id: sequentialErrorsId,
|
|
158
162
|
errors: this.props.errors,
|
|
159
163
|
isVisible: hasError,
|
|
160
164
|
renderError: this.props.renderError
|
|
@@ -162,6 +166,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
162
166
|
})
|
|
163
167
|
});
|
|
164
168
|
}
|
|
169
|
+
}], [{
|
|
170
|
+
key: "toFieldErrors",
|
|
171
|
+
value:
|
|
172
|
+
/**
|
|
173
|
+
* Use this function to convert the Formik `errors` object type to
|
|
174
|
+
* our custom field errors type.
|
|
175
|
+
* This is primarly useful when using TypeScript.
|
|
176
|
+
*/
|
|
177
|
+
function toFieldErrors(errors) {
|
|
178
|
+
return errors;
|
|
179
|
+
}
|
|
165
180
|
}]);
|
|
166
181
|
|
|
167
182
|
return CreatableSelectField;
|
|
@@ -180,7 +195,7 @@ CreatableSelectField.getDerivedStateFromProps = function (props, state) {
|
|
|
180
195
|
CreatableSelectField.propTypes = {};
|
|
181
196
|
|
|
182
197
|
// NOTE: This string will be replaced on build time with the package version.
|
|
183
|
-
var version = "
|
|
198
|
+
var version = "14.0.1";
|
|
184
199
|
|
|
185
200
|
exports["default"] = CreatableSelectField;
|
|
186
201
|
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('creatable-select-field-');
|
|
38
|
+
var sequentialErrorsId = createSequentialId('creatable-select-field-error-')();
|
|
38
39
|
|
|
39
40
|
var hasErrors = function hasErrors(errors) {
|
|
40
41
|
var _context;
|
|
@@ -99,6 +100,8 @@ var CreatableSelectField = /*#__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,
|
|
@@ -136,6 +139,7 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
136
139
|
showOptionGroupDivider: this.props.showOptionGroupDivider,
|
|
137
140
|
iconLeft: this.props.iconLeft
|
|
138
141
|
}, filterDataAttributes(this.props))), jsx(FieldErrors, {
|
|
142
|
+
id: sequentialErrorsId,
|
|
139
143
|
errors: this.props.errors,
|
|
140
144
|
isVisible: hasError,
|
|
141
145
|
renderError: this.props.renderError
|
|
@@ -143,6 +147,17 @@ var CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
143
147
|
})
|
|
144
148
|
});
|
|
145
149
|
}
|
|
150
|
+
}], [{
|
|
151
|
+
key: "toFieldErrors",
|
|
152
|
+
value:
|
|
153
|
+
/**
|
|
154
|
+
* Use this function to convert the Formik `errors` object type to
|
|
155
|
+
* our custom field errors type.
|
|
156
|
+
* This is primarly useful when using TypeScript.
|
|
157
|
+
*/
|
|
158
|
+
function toFieldErrors(errors) {
|
|
159
|
+
return errors;
|
|
160
|
+
}
|
|
146
161
|
}]);
|
|
147
162
|
|
|
148
163
|
return CreatableSelectField;
|
|
@@ -188,6 +203,6 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
188
203
|
} : {};
|
|
189
204
|
|
|
190
205
|
// NOTE: This string will be replaced on build time with the package version.
|
|
191
|
-
var version = "
|
|
206
|
+
var version = "14.0.1";
|
|
192
207
|
|
|
193
208
|
export { CreatableSelectField as default, version };
|
|
@@ -4,6 +4,9 @@ import type { CreatableProps } from 'react-select/creatable';
|
|
|
4
4
|
declare type ReactSelectCreatableProps = CreatableProps<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 TValue = {
|
|
8
11
|
value: string;
|
|
9
12
|
};
|
|
@@ -80,6 +83,7 @@ export default class CreatableSelectField extends Component<TCreatableSelectFiel
|
|
|
80
83
|
static getDerivedStateFromProps: (props: TCreatableSelectFieldProps, state: TCreatableSelectFieldState) => {
|
|
81
84
|
id: string;
|
|
82
85
|
};
|
|
86
|
+
static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
83
87
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
84
88
|
}
|
|
85
89
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/creatable-select-field",
|
|
3
3
|
"description": "A controlled input component with validation states and a label getting a selection from the user, and where options can also 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/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-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/constraints": "
|
|
25
|
-
"@commercetools-uikit/creatable-select-input": "
|
|
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/constraints": "14.0.1",
|
|
25
|
+
"@commercetools-uikit/creatable-select-input": "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"
|