td-stylekit 28.30.2 → 28.31.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,17 @@
1
+ # [28.31.0](https://github.com/treasure-data/td-stylekit/compare/v28.30.3...v28.31.0) (2023-12-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * **CON-8464:** Corner radius set on the wrong corners ([#1519](https://github.com/treasure-data/td-stylekit/issues/1519)) ([4a54608](https://github.com/treasure-data/td-stylekit/commit/4a54608))
7
+
8
+ ## [28.30.3](https://github.com/treasure-data/td-stylekit/compare/v28.30.2...v28.30.3) (2023-12-18)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **CON-11008:** Properly fix migration to date-fns in `TimeControl` ([#1518](https://github.com/treasure-data/td-stylekit/issues/1518)) ([53bf9fe](https://github.com/treasure-data/td-stylekit/commit/53bf9fe))
14
+
1
15
  ## [28.30.2](https://github.com/treasure-data/td-stylekit/compare/v28.30.1...v28.30.2) (2023-12-15)
2
16
 
3
17
 
@@ -294,7 +294,7 @@ function getCustomStyles(props, options) {
294
294
  // want menu to be 12px in from each side for v5
295
295
  width: "calc(".concat(originalWidth, " - 24px)"),
296
296
  maxWidth: guessMenuWidth || menuWidth ? '50vw' : 'unset',
297
- borderRadius: "0 0 ".concat(theme.radius[2], " ").concat(theme.radius[2]),
297
+ borderRadius: "".concat(theme.radius[2]),
298
298
  border: "1px solid ".concat(theme.palette.neutral[4]),
299
299
  overflow: 'hidden',
300
300
  padding: theme.space[2],
@@ -7,6 +7,8 @@ exports.useDisplayValue = useDisplayValue;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
+ var _DatePicker = require("../DatePicker");
11
+
10
12
  var _dateFns = require("date-fns");
11
13
 
12
14
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -23,10 +25,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
25
 
24
26
  if (typeof window !== "undefined" && !window.gs) window.gs = function () {};
25
27
  if (typeof window !== "undefined" && !window.gsC) window.gsC = function () {};
26
- var TIME_FORMAT_24 = 'hh:mm:ss';
27
- var TIME_FORMAT_12 = 'hh:mm:ss A';
28
+ var isStringCorrectFormat = _DatePicker.DatePickerUtils.isStringCorrectFormat;
29
+ var TIME_FORMAT_24 = 'HH:mm:ss';
30
+ var TIME_FORMAT_12 = 'hh:mm:ss a';
28
31
  var TIME_FORMAT_MS = ':mm:ss';
29
- var TIME_FORMAT_HM = 'hh:mm'; // This hook contains all the logic needed to handle user input
32
+ var TIME_FORMAT_HM = 'HH:mm'; // This hook contains all the logic needed to handle user input
30
33
  // and the editing mode for the TimeControl component.
31
34
  // TODO: as soon as we find a nice way to test hooks we can test all
32
35
  // this logic without any UI interaction directly in our unit tests.
@@ -66,10 +69,14 @@ function useDisplayValue(time, editor, onChange) {
66
69
  }, [period, editor]);
67
70
 
68
71
  var reconcileShadowValue = function reconcileShadowValue() {
69
- var date = (0, _dateFns.parse)(time !== null && time !== void 0 ? time : '00:00', TIME_FORMAT_24, Date.now());
72
+ var referenceDate = new Date();
73
+ var date = (0, _dateFns.parse)(time !== null && time !== void 0 ? time : '00:00:00', TIME_FORMAT_24, referenceDate);
70
74
 
71
75
  if (time && (0, _dateFns.isValid)(date)) {
72
76
  setShadowValue((0, _dateFns.format)(date, displayFormat));
77
+ } else {
78
+ var defaultDate = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getMinutes(), 0, 0, 0);
79
+ setShadowValue((0, _dateFns.format)(defaultDate, displayFormat));
73
80
  }
74
81
  }; // If we do not have an initial value then we use the current time (when editing
75
82
  // hh:mm:ss) or always 00:00 when editing mm:ss. We override default behaviour of TimePicker.
@@ -112,9 +119,9 @@ function useDisplayValue(time, editor, onChange) {
112
119
  return;
113
120
  }
114
121
 
115
- var date = new Date(value);
122
+ var date = (0, _dateFns.parse)(value, displayFormat, new Date());
116
123
 
117
- if ((0, _dateFns.isValid)(date)) {
124
+ if ((0, _dateFns.isValid)(date) && isStringCorrectFormat(value, displayFormat)) {
118
125
  setErrors(undefined);
119
126
  onChange((0, _dateFns.format)(date, TIME_FORMAT_24)); // Editing the value from AM to PM (or vice-versa) causes the default
120
127
  // period in the TimePicker to change (we do not want to always have 24h if user
@@ -141,7 +148,7 @@ function useDisplayValue(time, editor, onChange) {
141
148
  setErrors(undefined);
142
149
  onChange(value);
143
150
  }
144
- }; // Display value is (rougly...) the shadow value when editing
151
+ }; // Display value is (roughly...) the shadow value when editing
145
152
  // or the input value formatted according to the `period`.
146
153
  // I18N: note that for a truly internationalized control the 12 format
147
154
  // is not always `TIME_FORMAT_12` because different countries (Japan, for example)
@@ -153,7 +160,7 @@ function useDisplayValue(time, editor, onChange) {
153
160
  return shadowValue;
154
161
  }
155
162
 
156
- var date = new Date(time);
163
+ var date = (0, _dateFns.parse)(time, displayFormat, Date.now());
157
164
  return (0, _dateFns.isValid)(date) ? (0, _dateFns.format)(date, displayFormat) : ''; // eslint-disable-next-line react-hooks/exhaustive-deps
158
165
  }, [time, shadowValue, errors, isEditing, displayFormat]);
159
166
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "td-stylekit",
3
- "version": "28.30.2",
3
+ "version": "28.31.0",
4
4
  "main": "dist/es/index.js",
5
5
  "module": "dist/es/index.js",
6
6
  "types": "dist/es/index.d.ts",