td-stylekit 26.13.0 → 26.14.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [26.14.0](https://github.com/treasure-data/td-stylekit/compare/v26.13.0...v26.14.0) (2022-06-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **CON-10188:** Expose onErrorChange the same way we do in TimeControl ([#1293](https://github.com/treasure-data/td-stylekit/issues/1293)) ([1c00fc1](https://github.com/treasure-data/td-stylekit/commit/1c00fc1))
7
+
1
8
  # [26.13.0](https://github.com/treasure-data/td-stylekit/compare/v26.12.3...v26.13.0) (2022-06-13)
2
9
 
3
10
 
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type * as Immutable from 'immutable';
2
3
  import type { DatePickerProps } from '../DatePicker';
3
4
  import type { FormControlProps } from '../FormControl';
4
5
  import { PLACEMENT } from '../TooltipPopover';
@@ -56,6 +57,8 @@ export declare type DateControlProps = Omit<FormControlProps<'text'>, 'blockLabe
56
57
  value: Date | null;
57
58
  /** Locale */
58
59
  locale?: string;
60
+ /** Event raised when an error occurs or changes. */
61
+ onErrorChange?: (value?: string | string[] | Immutable.List<string> | null) => void;
59
62
  };
60
63
  /**
61
64
  * Displays a text Input component with a popover DatePicker for selecting a date.
@@ -195,7 +195,19 @@ var UnstyledDateControl = function UnstyledDateControl(_ref) {
195
195
  var previousEditor = usePreviousValue(editor);
196
196
  var inputRef = (0, _react.useRef)(null);
197
197
  var datePickerRef = (0, _react.useRef)(null);
198
+
199
+ var _useDebouncedState = (0, _utils.useDebouncedState)(null),
200
+ _useDebouncedState2 = _slicedToArray(_useDebouncedState, 2),
201
+ errors = _useDebouncedState2[0],
202
+ setErrors = _useDebouncedState2[1];
203
+
198
204
  var dateIsValid = value && (0, _dateFns.isValid)(value);
205
+ (0, _react.useEffect)(function () {
206
+ if (props.onErrorChange) {
207
+ props.onErrorChange(errors);
208
+ } // eslint-disable-next-line react-hooks/exhaustive-deps
209
+
210
+ }, [errors]);
199
211
  (0, _react.useEffect)(function () {
200
212
  if (previousValue !== value || previousEditor !== editor) {
201
213
  // Keep our inner <input> synced with changes to Date
@@ -328,11 +340,6 @@ var UnstyledDateControl = function UnstyledDateControl(_ref) {
328
340
  });
329
341
  };
330
342
 
331
- var _useDebouncedState = (0, _utils.useDebouncedState)(null),
332
- _useDebouncedState2 = _slicedToArray(_useDebouncedState, 2),
333
- errors = _useDebouncedState2[0],
334
- setErrors = _useDebouncedState2[1];
335
-
336
343
  (0, _react.useEffect)(function () {
337
344
  var errorList = error ? (0, _utils.getErrorList)(error) : [];
338
345
  var date = stringToDate(inputValue, [resolvedDisplayFormat].concat(DATE_FORMATS), locale);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "td-stylekit",
3
- "version": "26.13.0",
3
+ "version": "26.14.0",
4
4
  "main": "dist/es/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",