@commercetools-uikit/date-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 CHANGED
@@ -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
+ ```
@@ -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('date-field-');
62
+ var sequentialErrorsId = utils.createSequentialId('date-field-error-')();
62
63
 
63
64
  var hasErrors = function hasErrors(errors) {
64
65
  var _context;
@@ -117,7 +118,7 @@ var DateField = /*#__PURE__*/function (_Component) {
117
118
  badge: this.props.badge,
118
119
  hasRequiredIndicator: this.props.isRequired,
119
120
  htmlFor: this.state.id
120
- }), jsxRuntime.jsx(DateInput__default["default"], _objectSpread({
121
+ }), jsxRuntime.jsx(DateInput__default["default"], _objectSpread(_objectSpread({
121
122
  id: this.state.id,
122
123
  name: this.props.name,
123
124
  value: this.props.value,
@@ -131,7 +132,12 @@ var DateField = /*#__PURE__*/function (_Component) {
131
132
  hasError: hasError,
132
133
  placeholder: this.props.placeholder,
133
134
  horizontalConstraint: "scale"
134
- }, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
135
+ }, utils.filterDataAttributes(this.props)), {}, {
136
+ /* ARIA */
137
+ "aria-invalid": hasError,
138
+ "aria-errormessage": sequentialErrorsId
139
+ })), jsxRuntime.jsx(FieldErrors__default["default"], {
140
+ id: sequentialErrorsId,
135
141
  errors: this.props.errors,
136
142
  isVisible: hasError,
137
143
  renderError: this.props.renderError
@@ -139,6 +145,17 @@ var DateField = /*#__PURE__*/function (_Component) {
139
145
  })
140
146
  });
141
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
+ }
142
159
  }]);
143
160
 
144
161
  return DateField;
@@ -182,7 +199,7 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
182
199
  var DateField$1 = DateField;
183
200
 
184
201
  // NOTE: This string will be replaced on build time with the package version.
185
- var version = "13.0.2";
202
+ var version = "14.0.1";
186
203
 
187
204
  exports["default"] = DateField$1;
188
205
  exports.version = version;
@@ -58,6 +58,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
58
58
 
59
59
  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; } }
60
60
  var sequentialId = utils.createSequentialId('date-field-');
61
+ var sequentialErrorsId = utils.createSequentialId('date-field-error-')();
61
62
 
62
63
  var hasErrors = function hasErrors(errors) {
63
64
  var _context;
@@ -112,7 +113,7 @@ var DateField = /*#__PURE__*/function (_Component) {
112
113
  badge: this.props.badge,
113
114
  hasRequiredIndicator: this.props.isRequired,
114
115
  htmlFor: this.state.id
115
- }), jsxRuntime.jsx(DateInput__default["default"], _objectSpread({
116
+ }), jsxRuntime.jsx(DateInput__default["default"], _objectSpread(_objectSpread({
116
117
  id: this.state.id,
117
118
  name: this.props.name,
118
119
  value: this.props.value,
@@ -126,7 +127,12 @@ var DateField = /*#__PURE__*/function (_Component) {
126
127
  hasError: hasError,
127
128
  placeholder: this.props.placeholder,
128
129
  horizontalConstraint: "scale"
129
- }, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
130
+ }, utils.filterDataAttributes(this.props)), {}, {
131
+ /* ARIA */
132
+ "aria-invalid": hasError,
133
+ "aria-errormessage": sequentialErrorsId
134
+ })), jsxRuntime.jsx(FieldErrors__default["default"], {
135
+ id: sequentialErrorsId,
130
136
  errors: this.props.errors,
131
137
  isVisible: hasError,
132
138
  renderError: this.props.renderError
@@ -134,6 +140,17 @@ var DateField = /*#__PURE__*/function (_Component) {
134
140
  })
135
141
  });
136
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
+ }
137
154
  }]);
138
155
 
139
156
  return DateField;
@@ -154,7 +171,7 @@ DateField.propTypes = {};
154
171
  var DateField$1 = DateField;
155
172
 
156
173
  // NOTE: This string will be replaced on build time with the package version.
157
- var version = "13.0.2";
174
+ var version = "14.0.1";
158
175
 
159
176
  exports["default"] = DateField$1;
160
177
  exports.version = version;
@@ -34,6 +34,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
34
34
 
35
35
  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; } }
36
36
  var sequentialId = createSequentialId('date-field-');
37
+ var sequentialErrorsId = createSequentialId('date-field-error-')();
37
38
 
38
39
  var hasErrors = function hasErrors(errors) {
39
40
  var _context;
@@ -92,7 +93,7 @@ var DateField = /*#__PURE__*/function (_Component) {
92
93
  badge: this.props.badge,
93
94
  hasRequiredIndicator: this.props.isRequired,
94
95
  htmlFor: this.state.id
95
- }), jsx(DateInput, _objectSpread({
96
+ }), jsx(DateInput, _objectSpread(_objectSpread({
96
97
  id: this.state.id,
97
98
  name: this.props.name,
98
99
  value: this.props.value,
@@ -106,7 +107,12 @@ var DateField = /*#__PURE__*/function (_Component) {
106
107
  hasError: hasError,
107
108
  placeholder: this.props.placeholder,
108
109
  horizontalConstraint: "scale"
109
- }, filterDataAttributes(this.props))), jsx(FieldErrors, {
110
+ }, filterDataAttributes(this.props)), {}, {
111
+ /* ARIA */
112
+ "aria-invalid": hasError,
113
+ "aria-errormessage": sequentialErrorsId
114
+ })), jsx(FieldErrors, {
115
+ id: sequentialErrorsId,
110
116
  errors: this.props.errors,
111
117
  isVisible: hasError,
112
118
  renderError: this.props.renderError
@@ -114,6 +120,17 @@ var DateField = /*#__PURE__*/function (_Component) {
114
120
  })
115
121
  });
116
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
+ }
117
134
  }]);
118
135
 
119
136
  return DateField;
@@ -157,6 +174,6 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
157
174
  var DateField$1 = DateField;
158
175
 
159
176
  // NOTE: This string will be replaced on build time with the package version.
160
- var version = "13.0.2";
177
+ var version = "14.0.1";
161
178
 
162
179
  export { DateField$1 as default, version };
@@ -1,6 +1,9 @@
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 TCustomFormErrors<Values> = {
5
+ [K in keyof Values]?: TFieldErrors;
6
+ };
4
7
  declare type TEvent = {
5
8
  target: {
6
9
  id?: string;
@@ -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": "13.0.2",
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/date-field"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": ["javascript", "design system", "react", "uikit"],
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-date-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": "13.0.2",
25
- "@commercetools-uikit/date-input": "13.0.2",
26
- "@commercetools-uikit/design-system": "13.0.0",
27
- "@commercetools-uikit/field-errors": "13.0.2",
28
- "@commercetools-uikit/field-label": "13.0.2",
29
- "@commercetools-uikit/spacings": "13.0.2",
30
- "@commercetools-uikit/utils": "13.0.2",
22
+ "@babel/runtime": "^7.17.2",
23
+ "@babel/runtime-corejs3": "^7.17.2",
24
+ "@commercetools-uikit/constraints": "14.0.1",
25
+ "@commercetools-uikit/date-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-required-if": "1.0.3"
34
+ "react-intl": "^5.24.6"
35
35
  },
36
36
  "devDependencies": {
37
37
  "react": "17.0.2"