@commercetools-uikit/date-field 14.0.0 → 14.0.3
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
CHANGED
|
@@ -55,7 +55,7 @@ export default Example;
|
|
|
55
55
|
| `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
56
56
|
| `name` | `string` | | | Used as HTML name of the input component. |
|
|
57
57
|
| `value` | `string` | ✅ | | Value of the input |
|
|
58
|
-
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) |
|
|
58
|
+
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with an event containing the new value.
This is always called with either an empty string or a valid date in the format of `YYYY-MM-DD`.
<br/>
Parent should pass it back as `value`. |
|
|
59
59
|
| `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when input is blurred |
|
|
60
60
|
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
|
|
61
61
|
| `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
|
|
@@ -81,13 +81,13 @@ export default Example;
|
|
|
81
81
|
### Signature `onChange`
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
|
-
(event:
|
|
84
|
+
(event: TCustomEvent) => void
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
### Signature `onBlur`
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
|
-
(event:
|
|
90
|
+
(event: TCustomEvent) => void
|
|
91
91
|
```
|
|
92
92
|
|
|
93
93
|
### Signature `onInfoButtonClick`
|
|
@@ -115,3 +115,21 @@ Known error keys are:
|
|
|
115
115
|
## Main Functions and use cases are:
|
|
116
116
|
|
|
117
117
|
- Input field for a single date
|
|
118
|
+
|
|
119
|
+
## Static methods
|
|
120
|
+
|
|
121
|
+
### `DateField.toFieldErrors`
|
|
122
|
+
|
|
123
|
+
Use this function to convert the Formik `errors` object type to our custom field errors type. This is primarily useful when using TypeScript.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
type FormValues = {
|
|
127
|
+
myField: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
<DateField
|
|
131
|
+
// ...
|
|
132
|
+
name="my-field"
|
|
133
|
+
errors={DateField.toFieldErrors<FormValues>(formik.errors).myField}
|
|
134
|
+
/>;
|
|
135
|
+
```
|
|
@@ -145,6 +145,17 @@ var DateField = /*#__PURE__*/function (_Component) {
|
|
|
145
145
|
})
|
|
146
146
|
});
|
|
147
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
|
+
}
|
|
148
159
|
}]);
|
|
149
160
|
|
|
150
161
|
return DateField;
|
|
@@ -170,7 +181,7 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
170
181
|
touched: _pt__default["default"].bool,
|
|
171
182
|
name: _pt__default["default"].string,
|
|
172
183
|
value: _pt__default["default"].string.isRequired,
|
|
173
|
-
onChange: _pt__default["default"].func
|
|
184
|
+
onChange: _pt__default["default"].func,
|
|
174
185
|
onBlur: _pt__default["default"].func,
|
|
175
186
|
onFocus: _pt__default["default"].func,
|
|
176
187
|
isDisabled: _pt__default["default"].bool,
|
|
@@ -188,7 +199,7 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
188
199
|
var DateField$1 = DateField;
|
|
189
200
|
|
|
190
201
|
// NOTE: This string will be replaced on build time with the package version.
|
|
191
|
-
var version = "14.0.
|
|
202
|
+
var version = "14.0.3";
|
|
192
203
|
|
|
193
204
|
exports["default"] = DateField$1;
|
|
194
205
|
exports.version = version;
|
|
@@ -140,6 +140,17 @@ var DateField = /*#__PURE__*/function (_Component) {
|
|
|
140
140
|
})
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
+
}], [{
|
|
144
|
+
key: "toFieldErrors",
|
|
145
|
+
value:
|
|
146
|
+
/**
|
|
147
|
+
* Use this function to convert the Formik `errors` object type to
|
|
148
|
+
* our custom field errors type.
|
|
149
|
+
* This is primarly useful when using TypeScript.
|
|
150
|
+
*/
|
|
151
|
+
function toFieldErrors(errors) {
|
|
152
|
+
return errors;
|
|
153
|
+
}
|
|
143
154
|
}]);
|
|
144
155
|
|
|
145
156
|
return DateField;
|
|
@@ -160,7 +171,7 @@ DateField.propTypes = {};
|
|
|
160
171
|
var DateField$1 = DateField;
|
|
161
172
|
|
|
162
173
|
// NOTE: This string will be replaced on build time with the package version.
|
|
163
|
-
var version = "14.0.
|
|
174
|
+
var version = "14.0.3";
|
|
164
175
|
|
|
165
176
|
exports["default"] = DateField$1;
|
|
166
177
|
exports.version = version;
|
|
@@ -120,6 +120,17 @@ var DateField = /*#__PURE__*/function (_Component) {
|
|
|
120
120
|
})
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
+
}], [{
|
|
124
|
+
key: "toFieldErrors",
|
|
125
|
+
value:
|
|
126
|
+
/**
|
|
127
|
+
* Use this function to convert the Formik `errors` object type to
|
|
128
|
+
* our custom field errors type.
|
|
129
|
+
* This is primarly useful when using TypeScript.
|
|
130
|
+
*/
|
|
131
|
+
function toFieldErrors(errors) {
|
|
132
|
+
return errors;
|
|
133
|
+
}
|
|
123
134
|
}]);
|
|
124
135
|
|
|
125
136
|
return DateField;
|
|
@@ -145,7 +156,7 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
145
156
|
touched: _pt.bool,
|
|
146
157
|
name: _pt.string,
|
|
147
158
|
value: _pt.string.isRequired,
|
|
148
|
-
onChange: _pt.func
|
|
159
|
+
onChange: _pt.func,
|
|
149
160
|
onBlur: _pt.func,
|
|
150
161
|
onFocus: _pt.func,
|
|
151
162
|
isDisabled: _pt.bool,
|
|
@@ -163,6 +174,6 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
163
174
|
var DateField$1 = DateField;
|
|
164
175
|
|
|
165
176
|
// NOTE: This string will be replaced on build time with the package version.
|
|
166
|
-
var version = "14.0.
|
|
177
|
+
var version = "14.0.3";
|
|
167
178
|
|
|
168
179
|
export { DateField$1 as default, version };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Component, type FocusEventHandler, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
3
3
|
declare type TFieldErrors = Record<string, boolean>;
|
|
4
|
-
declare type
|
|
4
|
+
declare type TCustomFormErrors<Values> = {
|
|
5
|
+
[K in keyof Values]?: TFieldErrors;
|
|
6
|
+
};
|
|
7
|
+
declare type TCustomEvent = {
|
|
5
8
|
target: {
|
|
6
9
|
id?: string;
|
|
7
10
|
name?: string;
|
|
@@ -17,8 +20,8 @@ declare type TDateFieldProps = {
|
|
|
17
20
|
touched?: boolean;
|
|
18
21
|
name?: string;
|
|
19
22
|
value: string;
|
|
20
|
-
onChange
|
|
21
|
-
onBlur?: (event:
|
|
23
|
+
onChange?: (event: TCustomEvent) => void;
|
|
24
|
+
onBlur?: (event: TCustomEvent) => void;
|
|
22
25
|
onFocus?: FocusEventHandler;
|
|
23
26
|
isDisabled?: boolean;
|
|
24
27
|
isReadOnly?: boolean;
|
|
@@ -44,6 +47,7 @@ declare class DateField extends Component<TDateFieldProps, TDateFieldState> {
|
|
|
44
47
|
static getDerivedStateFromProps: (props: TDateFieldProps, state: TDateFieldState) => {
|
|
45
48
|
id: string;
|
|
46
49
|
};
|
|
50
|
+
static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
|
|
47
51
|
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
48
52
|
}
|
|
49
53
|
export default DateField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/date-field",
|
|
3
3
|
"description": "A controlled date input component for single date, with validation states and a label.",
|
|
4
|
-
"version": "14.0.
|
|
4
|
+
"version": "14.0.3",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.17.2",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.17.2",
|
|
24
|
-
"@commercetools-uikit/constraints": "14.0.
|
|
25
|
-
"@commercetools-uikit/date-input": "14.0.
|
|
24
|
+
"@commercetools-uikit/constraints": "14.0.1",
|
|
25
|
+
"@commercetools-uikit/date-input": "14.0.3",
|
|
26
26
|
"@commercetools-uikit/design-system": "14.0.0",
|
|
27
|
-
"@commercetools-uikit/field-errors": "14.0.
|
|
28
|
-
"@commercetools-uikit/field-label": "14.0.
|
|
29
|
-
"@commercetools-uikit/spacings": "14.0.
|
|
30
|
-
"@commercetools-uikit/utils": "14.0.
|
|
27
|
+
"@commercetools-uikit/field-errors": "14.0.1",
|
|
28
|
+
"@commercetools-uikit/field-label": "14.0.2",
|
|
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",
|