carbon-addons-iot-react 4.4.1 → 4.5.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.
Files changed (39) hide show
  1. package/README.MD +6 -2
  2. package/es/components/BarChartCard/BarChartCard.js +16 -4
  3. package/es/components/BarChartCard/barChartUtils.js +8 -7
  4. package/es/components/Card/Card.js +8 -5
  5. package/es/components/Card/CardToolbar.js +3 -1
  6. package/es/components/DateTimePicker/DateTimePicker.js +29 -10
  7. package/es/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +2 -3
  8. package/es/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +30 -10
  9. package/es/components/DateTimePicker/dateTimePickerUtils.js +34 -29
  10. package/es/components/ImageCard/ImageCard.js +15 -2
  11. package/es/components/ListCard/ListCard.js +7 -2
  12. package/es/components/TableCard/TableCard.js +15 -4
  13. package/es/components/TableCard/tableCardUtils.js +2 -2
  14. package/es/components/TimeSeriesCard/TimeSeriesCard.js +15 -4
  15. package/es/components/TimeSeriesCard/timeSeriesUtils.js +2 -2
  16. package/es/components/ValueCard/ValueCard.js +6 -1
  17. package/es/constants/CardPropTypes.js +2 -0
  18. package/es/utils/cardUtilityFunctions.js +1 -1
  19. package/es/utils/dayjs.js +21 -1
  20. package/lib/components/BarChartCard/BarChartCard.js +16 -4
  21. package/lib/components/BarChartCard/barChartUtils.js +8 -7
  22. package/lib/components/Card/Card.js +7 -4
  23. package/lib/components/Card/CardToolbar.js +3 -1
  24. package/lib/components/DateTimePicker/DateTimePicker.js +28 -9
  25. package/lib/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +2 -3
  26. package/lib/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +29 -9
  27. package/lib/components/DateTimePicker/dateTimePickerUtils.js +34 -29
  28. package/lib/components/ImageCard/ImageCard.js +15 -2
  29. package/lib/components/ListCard/ListCard.js +7 -2
  30. package/lib/components/TableCard/TableCard.js +15 -4
  31. package/lib/components/TableCard/tableCardUtils.js +2 -2
  32. package/lib/components/TimeSeriesCard/TimeSeriesCard.js +15 -4
  33. package/lib/components/TimeSeriesCard/timeSeriesUtils.js +2 -2
  34. package/lib/components/ValueCard/ValueCard.js +6 -1
  35. package/lib/constants/CardPropTypes.js +2 -0
  36. package/lib/utils/cardUtilityFunctions.js +1 -1
  37. package/lib/utils/dayjs.js +22 -0
  38. package/package.json +1 -1
  39. package/umd/carbon-addons-iot-react.js +234 -111
@@ -24,8 +24,9 @@ import { CardPropTypes } from '../../constants/CardPropTypes.js';
24
24
  import Card from '../Card/Card.js';
25
25
  import { getResizeHandles } from '../../utils/cardUtilityFunctions.js';
26
26
  import deprecate from '../../internal/deprecate.js';
27
+ import dayjs from '../../utils/dayjs.js';
27
28
 
28
- var _excluded = ["id", "title", "size", "data", "isLoading", "isResizable", "loadData", "hasMoreData", "layout", "className", "children", "testID", "testId"];
29
+ var _excluded = ["id", "title", "size", "data", "isLoading", "isResizable", "loadData", "hasMoreData", "layout", "className", "children", "testID", "testId", "timeZone"];
29
30
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
30
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
31
32
  var ListCard = function ListCard(_ref) {
@@ -42,7 +43,10 @@ var ListCard = function ListCard(_ref) {
42
43
  children = _ref.children,
43
44
  testID = _ref.testID,
44
45
  testId = _ref.testId,
46
+ timeZone = _ref.timeZone,
45
47
  others = _objectWithoutProperties(_ref, _excluded);
48
+ var effectiveTimezone = timeZone || dayjs.tz.guess();
49
+ dayjs.tz.setDefault(effectiveTimezone);
46
50
  var handleScroll = function handleScroll(e) {
47
51
  var element = e.target;
48
52
  // height of the elements content - height element’s content is scrolled vertically === height of the scrollable part of the element
@@ -60,7 +64,8 @@ var ListCard = function ListCard(_ref) {
60
64
  resizeHandles: resizeHandles
61
65
  // TODO: remove deprecated 'testID' in v3.
62
66
  ,
63
- testId: testID || testId
67
+ testId: testID || testId,
68
+ timeZone: effectiveTimezone
64
69
  }, others), /*#__PURE__*/React__default.createElement("div", {
65
70
  className: classnames('list-card', className),
66
71
  style: {
@@ -43,13 +43,14 @@ import { createColumnsWithFormattedLinks, determineFilterFunction, determinePrec
43
43
  import ThresholdIcon from './ThresholdIcon.js';
44
44
  import { OverflowMenuVertical } from '@carbon/icons-react';
45
45
 
46
- var _excluded = ["id", "title", "isExpanded", "content", "children", "size", "onCardAction", "values", "filters", "isEditable", "isResizable", "i18n", "tooltip", "locale", "timeRange", "timeRangeOptions", "availableActions", "isLoading", "testID", "testId", "className", "renderDateDropdownInPortal", "withToolbarTooltips", "defaultDateFormatPattern", "extraActions"];
46
+ var _excluded = ["id", "title", "isExpanded", "content", "children", "size", "onCardAction", "values", "filters", "isEditable", "isResizable", "i18n", "tooltip", "locale", "timeZone", "timeRange", "timeRangeOptions", "availableActions", "isLoading", "testID", "testId", "className", "renderDateDropdownInPortal", "withToolbarTooltips", "defaultDateFormatPattern", "extraActions"];
47
47
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
48
48
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
49
  var iotPrefix = settings.iotPrefix;
50
50
  var defaultProps = {
51
51
  size: CARD_SIZES.LARGE,
52
52
  locale: 'en',
53
+ timeZone: undefined,
53
54
  values: [],
54
55
  filters: [],
55
56
  i18n: {
@@ -103,6 +104,7 @@ var TableCard = function TableCard(_ref) {
103
104
  i18n = _ref.i18n,
104
105
  tooltip = _ref.tooltip,
105
106
  locale = _ref.locale,
107
+ timeZone = _ref.timeZone,
106
108
  timeRange = _ref.timeRange,
107
109
  timeRangeOptions = _ref.timeRangeOptions,
108
110
  availableActions = _ref.availableActions,
@@ -116,8 +118,8 @@ var TableCard = function TableCard(_ref) {
116
118
  extraActions = _ref.extraActions,
117
119
  others = _objectWithoutProperties(_ref, _excluded);
118
120
  var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
119
-
120
- // Set the locale
121
+ var effectiveTimezone = timeZone || dayjs.tz.guess();
122
+ dayjs.tz.setDefault(effectiveTimezone);
121
123
  dayjs.locale(locale);
122
124
  /** Searches for variables and updates the card if it is passed the cardVariables prop */
123
125
  // Need to skip the linkTemplate variable for now because we will handle it at render time per row
@@ -300,7 +302,7 @@ var TableCard = function TableCard(_ref) {
300
302
  var values = _objectSpread({}, row.values);
301
303
  Object.keys(values).forEach(function (column) {
302
304
  if (!isEditable && filteredTimestampColumns.includes(column)) {
303
- values[column] = values[column] ? dayjs(values[column]).format(defaultDateFormatPattern) : '';
305
+ values[column] = values[column] ? dayjs.tz(values[column]).format(defaultDateFormatPattern) : '';
304
306
  }
305
307
  });
306
308
  return _objectSpread(_objectSpread({}, row), {}, {
@@ -478,6 +480,7 @@ var TableCard = function TableCard(_ref) {
478
480
  timeRangeOptions: timeRangeOptions,
479
481
  renderDateDropdownInPortal: renderDateDropdownInPortal,
480
482
  locale: locale,
483
+ timeZone: effectiveTimezone,
481
484
  id: id,
482
485
  extraActions: extraActions
483
486
  });
@@ -495,6 +498,7 @@ var TableCard = function TableCard(_ref) {
495
498
  isExpanded: isExpanded,
496
499
  i18n: mergedI18n,
497
500
  locale: locale,
501
+ timeZone: effectiveTimezone,
498
502
  resizeHandles: resizeHandles,
499
503
  hideHeader: true,
500
504
  className: classnames("".concat(iotPrefix, "--table-card"), className, _defineProperty({}, "".concat(iotPrefix, "--table-card--with-tooltips"), withToolbarTooltips))
@@ -602,6 +606,13 @@ TableCard.__docgenInfo = {
602
606
  },
603
607
  "required": false
604
608
  },
609
+ "timeZone": {
610
+ "defaultValue": {
611
+ "value": "undefined",
612
+ "computed": true
613
+ },
614
+ "required": false
615
+ },
605
616
  "values": {
606
617
  "defaultValue": {
607
618
  "value": "[]",
@@ -63,7 +63,7 @@ var createColumnsWithFormattedLinks = function createColumnsWithFormattedLinks(c
63
63
  });
64
64
  var variableValue =
65
65
  // format the TIMESTAMP type columns
66
- (matchingColumn === null || matchingColumn === void 0 ? void 0 : matchingColumn.type) === 'TIMESTAMP' ? dayjs(row[variable]).format(defaultDateFormatPattern) : row[variable];
66
+ (matchingColumn === null || matchingColumn === void 0 ? void 0 : matchingColumn.type) === 'TIMESTAMP' ? dayjs.tz(row[variable]).format(defaultDateFormatPattern) : row[variable];
67
67
  // encode value so the URL can be valid
68
68
  var encodedValue = typeof variableValue === 'string' && variableValue !== null && variableValue !== void 0 && variableValue.includes('https') ? variableValue : encodeURIComponent(variableValue);
69
69
  variableLink = variableLink.replace("{".concat(variable, "}"), encodedValue);
@@ -131,7 +131,7 @@ var determineFilterFunction = function determineFilterFunction(column, defaultFi
131
131
  var defaultDateFormatPattern = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DAYJS_INPUT_FORMATS.SECONDS;
132
132
  return _objectSpread(_objectSpread({}, column.type === 'TIMESTAMP' ? {
133
133
  filterFunction: function filterFunction(cellValue, filterValue) {
134
- var dateString = dayjs(cellValue).format(defaultDateFormatPattern);
134
+ var dateString = dayjs.tz(cellValue).format(defaultDateFormatPattern);
135
135
  return dateString.includes(filterValue);
136
136
  }
137
137
  } : {}), {}, {
@@ -43,7 +43,7 @@ import dayjs, { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
43
43
  import { usePrevious } from '../../hooks/usePrevious.js';
44
44
  import { generateSampleValues, formatGraphTick, formatColors, formatChartData, applyStrokeColor, applyFillColor, applyIsFilled } from './timeSeriesUtils.js';
45
45
 
46
- var _excluded = ["title", "content", "children", "size", "interval", "isEditable", "isResizable", "values", "locale", "i18n", "isExpanded", "timeRange", "isLazyLoading", "isLoading", "domainRange", "tooltipDateFormatPattern", "tooltipShowTotals", "showTimeInGMT", "testID", "testId", "defaultDateFormatPattern"];
46
+ var _excluded = ["title", "content", "children", "size", "interval", "isEditable", "isResizable", "values", "locale", "timeZone", "i18n", "isExpanded", "timeRange", "isLazyLoading", "isLoading", "domainRange", "tooltipDateFormatPattern", "tooltipShowTotals", "showTimeInGMT", "testID", "testId", "defaultDateFormatPattern"];
47
47
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
48
48
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49
49
  var iotPrefix = settings.iotPrefix;
@@ -160,6 +160,7 @@ var defaultProps = {
160
160
  },
161
161
  chartType: TIME_SERIES_TYPES.LINE,
162
162
  locale: 'en',
163
+ timeZone: undefined,
163
164
  content: {
164
165
  series: [],
165
166
  timeDataSourceId: 'timestamp',
@@ -190,6 +191,7 @@ var TimeSeriesCard = function TimeSeriesCard(_ref) {
190
191
  isResizable = _ref.isResizable,
191
192
  initialValues = _ref.values,
192
193
  locale = _ref.locale,
194
+ timeZone = _ref.timeZone,
193
195
  i18n = _ref.i18n,
194
196
  isExpanded = _ref.isExpanded,
195
197
  timeRange = _ref.timeRange,
@@ -203,6 +205,9 @@ var TimeSeriesCard = function TimeSeriesCard(_ref) {
203
205
  testId = _ref.testId,
204
206
  defaultDateFormatPattern = _ref.defaultDateFormatPattern,
205
207
  others = _objectWithoutProperties(_ref, _excluded);
208
+ var effectiveTimezone = timeZone || dayjs.tz.guess();
209
+ dayjs.tz.setDefault(effectiveTimezone);
210
+ dayjs.locale(locale);
206
211
  // need to deep merge the nested content default props as default props only uses a shallow merge natively
207
212
  var contentWithDefaults = useMemo(function () {
208
213
  return _defaultsDeep({}, content, defaultProps.content);
@@ -232,8 +237,6 @@ var TimeSeriesCard = function TimeSeriesCard(_ref) {
232
237
  valuesProp = _handleCardVariables.values;
233
238
  var chartRef = useRef(null);
234
239
  var previousTick = useRef();
235
- dayjs.locale(locale);
236
-
237
240
  // Workaround since downstream consumers might keep regenerating the series object and useMemo does a direct in-memory comparison for the object
238
241
  var objectAgnosticSeries = JSON.stringify(series);
239
242
  var objectAgnosticThresholds = JSON.stringify(thresholds);
@@ -313,7 +316,7 @@ var TimeSeriesCard = function TimeSeriesCard(_ref) {
313
316
  });
314
317
  return {
315
318
  id: "dataindex-".concat(index),
316
- values: _objectSpread(_objectSpread({}, _omit(value, timeDataSourceId)), {}, _defineProperty({}, timeDataSourceId, dayjs(value[timeDataSourceId]).format(defaultDateFormatPattern))),
319
+ values: _objectSpread(_objectSpread({}, _omit(value, timeDataSourceId)), {}, _defineProperty({}, timeDataSourceId, dayjs.tz(value[timeDataSourceId]).format(defaultDateFormatPattern))),
317
320
  isSelectable: false
318
321
  };
319
322
  });
@@ -467,6 +470,7 @@ var TimeSeriesCard = function TimeSeriesCard(_ref) {
467
470
  timeRange: timeRange
468
471
  }, others, {
469
472
  locale: locale,
473
+ timeZone: effectiveTimezone,
470
474
  isExpanded: isExpanded,
471
475
  isEditable: isEditable,
472
476
  isEmpty: isChartDataEmpty,
@@ -617,6 +621,13 @@ TimeSeriesCard.__docgenInfo = {
617
621
  },
618
622
  "required": false
619
623
  },
624
+ "timeZone": {
625
+ "defaultValue": {
626
+ "value": "undefined",
627
+ "computed": true
628
+ },
629
+ "required": false
630
+ },
620
631
  "content": {
621
632
  "defaultValue": {
622
633
  "value": "{\n series: [],\n timeDataSourceId: 'timestamp',\n includeZeroOnXaxis: false,\n includeZeroOnYaxis: false,\n showLegend: true,\n legendPosition: 'bottom',\n truncation: {\n type: 'end_line',\n threshold: 20,\n numCharacter: 20,\n },\n}",
@@ -139,7 +139,7 @@ var formatGraphTick = function formatGraphTick(timestamp, index, ticks, interval
139
139
  var previousTickTimestamp = arguments.length > 5 ? arguments[5] : undefined;
140
140
  var shouldDisplayGMT = arguments.length > 6 ? arguments[6] : undefined;
141
141
  dayjs.locale(locale);
142
- var currentTimestamp = shouldDisplayGMT ? dayjs.utc(timestamp) : dayjs(timestamp);
142
+ var currentTimestamp = shouldDisplayGMT ? dayjs.utc(timestamp) : dayjs.tz(timestamp);
143
143
  var sameDay = dayjs(previousTickTimestamp).isSame(currentTimestamp, 'day');
144
144
  var sameMonth = dayjs(previousTickTimestamp).isSame(currentTimestamp, 'month');
145
145
  var sameYear = dayjs(previousTickTimestamp).isSame(currentTimestamp, 'year');
@@ -233,7 +233,7 @@ var formatChartData = function formatChartData() {
233
233
  // Check to see if the data Item actually exists in this timestamp before adding to data (to support sparse data in the values)
234
234
  if (!isNil(dataItem[dataSourceId])) {
235
235
  data.push({
236
- date: dataItem[timeDataSourceId] instanceof Date ? dataItem[timeDataSourceId] : new Date(dataItem[timeDataSourceId]),
236
+ date: dayjs.tz(dataItem[timeDataSourceId]).toDate(),
237
237
  value: dataItem[dataSourceId],
238
238
  group: label,
239
239
  dataSourceId: dataSourceId
@@ -17,10 +17,11 @@ import { CardPropTypes, ValueContentPropTypes } from '../../constants/CardPropTy
17
17
  import { CARD_LAYOUTS, CARD_SIZES } from '../../constants/LayoutConstants.js';
18
18
  import Card from '../Card/Card.js';
19
19
  import { getUpdatedCardSize, getResizeHandles, handleCardVariables } from '../../utils/cardUtilityFunctions.js';
20
+ import dayjs from '../../utils/dayjs.js';
20
21
  import { determineLayout, BASE_CLASS_NAME, DEFAULT_FONT_SIZE } from './valueCardUtils.js';
21
22
  import ValueContent from './ValueContent.js';
22
23
 
23
- var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
24
+ var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "timeZone", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
24
25
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
25
26
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
27
 
@@ -41,6 +42,7 @@ var ValueCard = function ValueCard(_ref) {
41
42
  dataState = _ref.dataState,
42
43
  id = _ref.id,
43
44
  locale = _ref.locale,
45
+ timeZone = _ref.timeZone,
44
46
  customFormatter = _ref.customFormatter,
45
47
  children = _ref.children,
46
48
  fontSize = _ref.fontSize,
@@ -51,6 +53,8 @@ var ValueCard = function ValueCard(_ref) {
51
53
  className = _ref.className,
52
54
  shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
53
55
  others = _objectWithoutProperties(_ref, _excluded);
56
+ var effectiveTimezone = timeZone || dayjs.tz.guess();
57
+ dayjs.tz.setDefault(effectiveTimezone);
54
58
  var availableActions = _objectSpread({
55
59
  expand: false
56
60
  }, others.availableActions);
@@ -76,6 +80,7 @@ var ValueCard = function ValueCard(_ref) {
76
80
  i18n: i18n,
77
81
  shouldUseTranslatedLabels: shouldUseTranslatedLabels,
78
82
  locale: locale,
83
+ timeZone: effectiveTimezone,
79
84
  id: id,
80
85
  className: classnames(className, _defineProperty(_defineProperty({}, "".concat(BASE_CLASS_NAME, "__horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), "".concat(BASE_CLASS_NAME, "__vertical"), layout === CARD_LAYOUTS.VERTICAL))
81
86
  // TODO: remove deprecated 'testID' in v3.
@@ -746,6 +746,8 @@ var CardPropTypes = {
746
746
  testId: PropTypes.string,
747
747
  /** the locale of the card, needed for number and date formatting */
748
748
  locale: PropTypes.string,
749
+ /** IANA timezone string to set as default timezone for dayjs */
750
+ timeZone: PropTypes.string,
749
751
  /** a way to pass down dashboard grid resize handles, only used by other card types */
750
752
  resizeHandles: PropTypes.array,
751
753
  /** Optional callback function that is passed an onChange function and the original cardConfig object.
@@ -539,7 +539,7 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
539
539
  : dataOrHoveredElement;
540
540
  var timeStamp = Array.isArray(data) ? (_data$ = data[0]) === null || _data$ === void 0 || (_data$ = _data$.date) === null || _data$ === void 0 ? void 0 : _data$.getTime() : data === null || data === void 0 || (_data$date = data.date) === null || _data$date === void 0 ? void 0 : _data$date.getTime();
541
541
  var dateLabel = timeStamp ? "<li class='datapoint-tooltip'>\n <p class='label'>".concat((showTimeInGMT // show timestamp in gmt or local time
542
- ? dayjs.utc(timeStamp) : dayjs(timeStamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
542
+ ? dayjs.utc(timeStamp) : dayjs.tz(timeStamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
543
543
  var matchingAlertRanges = findMatchingAlertRange(alertRanges, data);
544
544
  var matchingAlertLabels = Array.isArray(matchingAlertRanges) ? matchingAlertRanges.map(function (matchingAlertRange) {
545
545
  return "<li class='datapoint-tooltip'><a style=\"background-color:".concat(matchingAlertRange.color, "\" class=\"tooltip-color\"></a><p class='label'>").concat(alertDetected, " ").concat(matchingAlertRange.details, "</p></li>");
package/es/utils/dayjs.js CHANGED
@@ -1,5 +1,7 @@
1
+ import 'core-js/modules/es.array.find.js';
1
2
  import 'core-js/modules/es.object.keys.js';
2
3
  import 'core-js/modules/es.object.to-string.js';
4
+ import 'core-js/modules/es.string.trim.js';
3
5
  import 'core-js/modules/web.dom-collections.for-each.js';
4
6
  import dayjs$2 from 'dayjs';
5
7
 
@@ -8,12 +10,14 @@ var utc = require('dayjs/plugin/utc');
8
10
  var pluralGetSet = require('dayjs/plugin/pluralGetSet');
9
11
  var timezone = require('dayjs/plugin/timezone');
10
12
  var localeData = require('dayjs/plugin/localeData');
13
+ var customParseFormat = require('dayjs/plugin/customParseFormat');
11
14
  var dayjs = dayjs$2;
12
15
  dayjs.extend(localizedFormat); // gives the 'L' formatting ability for .format
13
16
  dayjs.extend(utc); // gives .utc() and .local()
14
17
  dayjs.extend(pluralGetSet); // gives .hour .minute get/set ability
15
18
  dayjs.extend(timezone); // timezone support
16
19
  dayjs.extend(localeData); // gives local specific data
20
+ dayjs.extend(customParseFormat);
17
21
 
18
22
  /* eslint-disable global-require */
19
23
  var locales = {
@@ -443,6 +447,22 @@ var DAYJS_INPUT_FORMATS = {
443
447
  SECONDS: 'L HH:mm:ss',
444
448
  RANGE: 'L HH:mm'
445
449
  };
450
+ var formats = [
451
+ // ISO Variations (Most common for APIs)
452
+ 'YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ', 'YYYY-MM-DDTHH:mm:ss', 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD HH:mm',
453
+ // US / Common UI Variations
454
+ 'MM/DD/YYYY HH:mm:ss', 'MM/DD/YYYY HH:mm', 'MM-DD-YYYY HH:mm:ss', 'MM-DD-YYYY HH:mm',
455
+ // 12-Hour Variations (If users can type AM/PM)
456
+ 'MM/DD/YYYY hh:mm A', 'YYYY-MM-DD hh:mm A',
457
+ // Date Only Fallbacks
458
+ 'YYYY-MM-DD', 'MM/DD/YYYY', 'MM-DD-YYYY', 'L' // Localized format (uses the loaded Day.js locale)
459
+ ];
460
+ var detectDateTimeFormat = function detectDateTimeFormat(dateTimeString) {
461
+ if (!(dateTimeString !== null && dateTimeString !== void 0 && dateTimeString.trim())) return null;
462
+ return formats.find(function (format) {
463
+ return dayjs(dateTimeString, format, true).isValid();
464
+ });
465
+ };
446
466
  var dayjs$1 = dayjs;
447
467
 
448
- export { DAYJS_INPUT_FORMATS, dayjs$1 as default };
468
+ export { DAYJS_INPUT_FORMATS, dayjs$1 as default, detectDateTimeFormat, formats };
@@ -45,7 +45,7 @@ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWith
45
45
  var React__default = /*#__PURE__*/_interopDefault(React);
46
46
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
47
47
 
48
- var _excluded = ["title", "content", "children", "size", "values", "availableDimensions", "locale", "i18n", "isExpanded", "isLazyLoading", "isEditable", "isDashboardPreview", "isLoading", "isResizable", "interval", "className", "domainRange", "timeRange", "showTimeInGMT", "tooltipDateFormatPattern", "testID", "testId", "defaultDateFormatPattern"];
48
+ var _excluded = ["title", "content", "children", "size", "values", "availableDimensions", "locale", "timeZone", "i18n", "isExpanded", "isLazyLoading", "isEditable", "isDashboardPreview", "isLoading", "isResizable", "interval", "className", "domainRange", "timeRange", "showTimeInGMT", "tooltipDateFormatPattern", "testID", "testId", "defaultDateFormatPattern"];
49
49
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
50
50
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
51
51
  var iotPrefix = Settings.settings.iotPrefix;
@@ -70,6 +70,7 @@ var defaultProps = {
70
70
  series: []
71
71
  },
72
72
  locale: 'en',
73
+ timeZone: undefined,
73
74
  showTimeInGMT: false,
74
75
  tooltipDateFormatPattern: dayjs.DAYJS_INPUT_FORMATS.SECONDS,
75
76
  values: null,
@@ -83,6 +84,7 @@ var BarChartCard = function BarChartCard(_ref) {
83
84
  initialValues = _ref.values,
84
85
  availableDimensions = _ref.availableDimensions,
85
86
  locale = _ref.locale,
87
+ timeZone = _ref.timeZone,
86
88
  i18n = _ref.i18n,
87
89
  isExpanded = _ref.isExpanded,
88
90
  isLazyLoading = _ref.isLazyLoading,
@@ -100,6 +102,8 @@ var BarChartCard = function BarChartCard(_ref) {
100
102
  testId = _ref.testId,
101
103
  defaultDateFormatPattern = _ref.defaultDateFormatPattern,
102
104
  others = _objectWithoutProperties__default.default(_ref, _excluded);
105
+ var effectiveTimezone = timeZone || dayjs.default.tz.guess();
106
+ dayjs.default.tz.setDefault(effectiveTimezone);
103
107
  // need to deep merge the nested content default props as default props only uses a shallow merge natively
104
108
  var contentWithDefaults = React.useMemo(function () {
105
109
  return defaultsDeep({}, content, defaultProps.content);
@@ -260,7 +264,7 @@ var BarChartCard = function BarChartCard(_ref) {
260
264
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
261
265
  args[_key] = arguments[_key];
262
266
  }
263
- return barChartUtils.handleTooltip.apply(void 0, args.concat([timeDataSourceId, showTimeInGMT, tooltipDateFormatPattern, locale]));
267
+ return barChartUtils.handleTooltip.apply(void 0, args.concat([timeDataSourceId, showTimeInGMT, tooltipDateFormatPattern, locale, effectiveTimezone]));
264
268
  },
265
269
  groupLabel: mergedI18n.tooltipGroupLabel,
266
270
  totalLabel: mergedI18n.tooltipTotalLabel
@@ -279,7 +283,7 @@ var BarChartCard = function BarChartCard(_ref) {
279
283
  enabled: false
280
284
  }
281
285
  });
282
- }, [xLabel, layout, unit, scaleType, type, timeDataSourceId, axes.bottomAxesMapsTo, axes.leftAxesMapsTo, domainRange, decimalPrecision, maxTicksPerSize, formatTick, yLabel, legendPosition, chartData.length, isEditable, truncation, colors, mergedI18n.tooltipGroupLabel, mergedI18n.tooltipTotalLabel, zoomBar, size, isExpanded, locale, showTimeInGMT, tooltipDateFormatPattern]);
286
+ }, [xLabel, layout, unit, scaleType, type, timeDataSourceId, axes.bottomAxesMapsTo, axes.leftAxesMapsTo, domainRange, decimalPrecision, maxTicksPerSize, formatTick, yLabel, legendPosition, chartData.length, isEditable, truncation, colors, mergedI18n.tooltipGroupLabel, mergedI18n.tooltipTotalLabel, zoomBar, size, isExpanded, locale, showTimeInGMT, tooltipDateFormatPattern, effectiveTimezone]);
283
287
  return /*#__PURE__*/React__default.default.createElement(Card.default, _extends__default.default({
284
288
  title: title,
285
289
  className: classnames__default.default(className, "".concat(iotPrefix, "--bar-chart-card")),
@@ -293,7 +297,8 @@ var BarChartCard = function BarChartCard(_ref) {
293
297
  isResizable: isResizable,
294
298
  resizeHandles: resizeHandles,
295
299
  timeRange: timeRange,
296
- locale: locale
300
+ locale: locale,
301
+ timeZone: effectiveTimezone
297
302
  // TODO: remove deprecated testID in v3.
298
303
  ,
299
304
  testId: testID || testId
@@ -389,6 +394,13 @@ BarChartCard.__docgenInfo = {
389
394
  },
390
395
  "required": false
391
396
  },
397
+ "timeZone": {
398
+ "defaultValue": {
399
+ "value": "undefined",
400
+ "computed": true
401
+ },
402
+ "required": false
403
+ },
392
404
  "showTimeInGMT": {
393
405
  "defaultValue": {
394
406
  "value": "false",
@@ -266,8 +266,7 @@ var formatChartData = function formatChartData(seriesArg, values, categoryDataSo
266
266
  // bar this data belongs to
267
267
  value: value[dataset.dataSourceId]
268
268
  }, timeDataSourceId && type !== LayoutConstants.BAR_CHART_TYPES.GROUPED ? {
269
- date: new Date(value[timeDataSourceId]),
270
- // timestamp
269
+ date: dayjs.default.tz(value[timeDataSourceId]).toDate(),
271
270
  key: value[timeDataSourceId]
272
271
  } : {
273
272
  key: value[categoryDataSourceId]
@@ -312,14 +311,13 @@ var formatChartData = function formatChartData(seriesArg, values, categoryDataSo
312
311
  dataset.forEach(function (value) {
313
312
  // if value is null, don't add it to the formatted chartData
314
313
  if (!isNil(value[series[0].dataSourceId])) {
315
- var dataDate = new Date(value[timeDataSourceId]);
316
314
  data.push({
317
315
  // Use the label if one exists
318
316
  group: series[0].label ? series[0].label : series[0].dataSourceId,
319
317
  // bar this data belongs to
320
318
  value: value[series[0].dataSourceId],
321
319
  // there should only be one series here because its a simple bar
322
- date: dataDate // timestamp
320
+ date: dayjs.default.tz(value[timeDataSourceId]).toDate()
323
321
  });
324
322
  }
325
323
  });
@@ -440,10 +438,12 @@ var formatColors = function formatColors(series, datasetNames, isDashboardPrevie
440
438
  * @param {string} timeDatasourceId time-based attribute
441
439
  * @param {bool} showTimeInGMT
442
440
  * @param {string} tooltipDataFormatPattern
441
+ * @param {string} timezone
443
442
  */
444
443
  var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip, _datum, timeDataSourceId, showTimeInGMT) {
445
444
  var tooltipDateFormatPattern = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : dayjs.DAYJS_INPUT_FORMATS.SECONDS;
446
445
  var locale = arguments.length > 6 ? arguments[6] : undefined;
446
+ var timezone = arguments.length > 7 ? arguments[7] : undefined;
447
447
  dayjs.default.locale(locale);
448
448
  var data = dataOrHoveredElement.__data__ // eslint-disable-line no-underscore-dangle
449
449
  ? dataOrHoveredElement.__data__ // eslint-disable-line no-underscore-dangle
@@ -457,8 +457,7 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
457
457
  if (timeDataSourceId) {
458
458
  // generate the formatted label
459
459
  var timestamp = typedData === null || typedData === void 0 ? void 0 : typedData.date;
460
- var dateLabel = timestamp ? "<li class='datapoint-tooltip'>\n <p class='label'>\n ".concat((showTimeInGMT // show timestamp in gmt or local time
461
- ? dayjs.default.utc(timestamp) : dayjs.default(timestamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
460
+ var dateLabel = timestamp ? "<li class='datapoint-tooltip'>\n <p class='label'>\n ".concat((showTimeInGMT ? dayjs.default.utc(timestamp) : dayjs.default(timestamp).tz(timezone)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
462
461
  var _convertStringsToDOME3 = componentUtilityFunctions.convertStringsToDOMElement([dateLabel]),
463
462
  _convertStringsToDOME4 = _slicedToArray__default.default(_convertStringsToDOME3, 1),
464
463
  parsedDateLabel = _convertStringsToDOME4[0];
@@ -524,6 +523,8 @@ var generateTableColumns = function generateTableColumns(timeDataSourceId, categ
524
523
  * @param {string} type of chart i.e. simple, grouped, stacked
525
524
  * @param {Array<Object>} values values before they are formatted for charting
526
525
  * @param {Array<Object>} chartData values after they are formatted for charting
526
+ * @param {string} defaultDateFormatPattern date format pattern
527
+ * @param {string} timezone timezone to use for formatting dates
527
528
  */
528
529
  var formatTableData = function formatTableData(timeDataSourceId, categoryDataSourceId, type, values, chartData) {
529
530
  var defaultDateFormatPattern = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : dayjs.DAYJS_INPUT_FORMATS.SECONDS;
@@ -548,7 +549,7 @@ var formatTableData = function formatTableData(timeDataSourceId, categoryDataSou
548
549
  });
549
550
  tableData.push({
550
551
  id: "dataindex-".concat(index),
551
- values: _objectSpread(_objectSpread({}, barTimeValue), {}, _defineProperty__default.default({}, timeDataSourceId, dayjs.default(timestamp).format(defaultDateFormatPattern))),
552
+ values: _objectSpread(_objectSpread({}, barTimeValue), {}, _defineProperty__default.default({}, timeDataSourceId, dayjs.default.tz(timestamp).format(defaultDateFormatPattern))),
552
553
  isSelectable: false
553
554
  });
554
555
  });
@@ -51,7 +51,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
51
51
  var warning__default = /*#__PURE__*/_interopDefault(warning);
52
52
 
53
53
  var _excluded = ["isSelected", "children", "dimensions", "id", "style", "className", "onScroll", "onMouseDown", "onMouseUp", "onTouchEnd", "onTouchStart", "onFocus", "onBlur", "tabIndex", "testID", "testId"],
54
- _excluded2 = ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content", "shouldUseTranslatedLabels"];
54
+ _excluded2 = ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content", "timeZone", "shouldUseTranslatedLabels"];
55
55
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
56
56
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
57
57
  var prefix = Settings.settings.prefix,
@@ -314,9 +314,11 @@ var Card = function Card(props) {
314
314
  type = props.type,
315
315
  data = props.data,
316
316
  content = props.content,
317
+ timeZone = props.timeZone,
317
318
  shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
318
319
  others = _objectWithoutProperties__default.default(props, _excluded2);
319
-
320
+ var effectiveTimezone = timeZone || dayjs.default.tz.guess();
321
+ dayjs.default.tz.setDefault(effectiveTimezone);
320
322
  // Get translated title if shouldUseTranslatedLabels is true
321
323
  var title = cardUtilityFunctions.getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
322
324
  var tooltip = cardUtilityFunctions.getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n);
@@ -354,12 +356,12 @@ var Card = function Card(props) {
354
356
  return subtitleProp;
355
357
  }
356
358
  if (mergedAvailableActions.range === 'full' || mergedAvailableActions.range === 'iconOnly') {
357
- var _parseValue = dateTimePickerUtils.parseValue(timeRange, dateTimeMask, strings.toLabel),
359
+ var _parseValue = dateTimePickerUtils.parseValue(timeRange, dateTimeMask, strings.toLabel, true, effectiveTimezone),
358
360
  readableValue = _parseValue.readableValue;
359
361
  return readableValue;
360
362
  }
361
363
  return undefined;
362
- }, [dateTimeMask, mergedAvailableActions.range, strings.toLabel, subtitleProp, timeRange]);
364
+ }, [dateTimeMask, mergedAvailableActions.range, strings.toLabel, subtitleProp, timeRange, effectiveTimezone]);
363
365
  var _useState = React.useState(getTheSubtitle),
364
366
  _useState2 = _slicedToArray__default.default(_useState, 2),
365
367
  subtitle = _useState2[0],
@@ -417,6 +419,7 @@ var Card = function Card(props) {
417
419
  isExpanded: isExpanded,
418
420
  timeRange: timeRange,
419
421
  locale: others.locale,
422
+ timeZone: effectiveTimezone,
420
423
  timeRangeOptions: timeRangeOptions,
421
424
  onCardAction: cachedOnCardAction
422
425
  // TODO: remove deprecated testID prop in v3
@@ -146,7 +146,8 @@ var CardToolbar = function CardToolbar(_ref) {
146
146
  dateTimeMask = _ref.dateTimeMask,
147
147
  extraActions = _ref.extraActions,
148
148
  renderDateDropdownInPortal = _ref.renderDateDropdownInPortal,
149
- id = _ref.id;
149
+ id = _ref.id,
150
+ timeZone = _ref.timeZone;
150
151
  var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
151
152
  var langDir = useLangDirection.useLangDirection();
152
153
  var overflowMenuPosition = React__default.default.useMemo(function () {
@@ -250,6 +251,7 @@ var CardToolbar = function CardToolbar(_ref) {
250
251
  i18n: mergedI18n,
251
252
  dateTimeMask: dateTimeMask,
252
253
  locale: locale,
254
+ timeZone: timeZone,
253
255
  hasIconOnly: true,
254
256
  presets: Object.entries(timeRangeOptions).reduce(function (acc, _ref2) {
255
257
  var _ref3 = _slicedToArray__default.default(_ref2, 2),
@@ -38,7 +38,7 @@ var React__default = /*#__PURE__*/_interopDefault(React);
38
38
  var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
39
39
  var classnames__default = /*#__PURE__*/_interopDefault(classnames);
40
40
 
41
- var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "style"];
41
+ var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "timeZone", "style"];
42
42
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
43
43
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
44
44
  var iotPrefix = Settings.settings.iotPrefix,
@@ -185,6 +185,8 @@ var propTypes = {
185
185
  light: PropTypes__default.default.bool,
186
186
  /** The language locale used to format the days of the week, months, and numbers. */
187
187
  locale: PropTypes__default.default.string,
188
+ /** IANA timezone string to interpret datetime values in (e.g., 'America/New_York') */
189
+ timeZone: PropTypes__default.default.string,
188
190
  /** Unique id of the component */
189
191
  id: PropTypes__default.default.string,
190
192
  style: PropTypes__default.default.objectOf(PropTypes__default.default.string)
@@ -260,6 +262,7 @@ var defaultProps = {
260
262
  },
261
263
  light: false,
262
264
  locale: 'en',
265
+ timeZone: undefined,
263
266
  id: undefined,
264
267
  style: {}
265
268
  };
@@ -282,10 +285,13 @@ var DateTimePicker = function DateTimePicker(_ref) {
282
285
  i18n = _ref.i18n,
283
286
  light = _ref.light,
284
287
  locale = _ref.locale,
288
+ timeZone = _ref.timeZone,
285
289
  style = _ref.style,
286
290
  others = _objectWithoutProperties__default.default(_ref, _excluded);
287
291
  var id = React.useRef(others.id || uuid.v4()).current;
288
292
  var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
293
+ var effectiveTimezone = timeZone || dayjs.default.tz.guess();
294
+ dayjs.default.tz.setDefault(effectiveTimezone);
289
295
  dayjs.default.locale(locale);
290
296
 
291
297
  // State
@@ -412,7 +418,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
412
418
  value.kind = PICKER_KINDS.PRESET;
413
419
  }
414
420
  setCurrentValue(value);
415
- var parsedValue = dateTimePickerUtils.parseValue(value, dateTimeMask, mergedI18n.toLabel);
421
+ var parsedValue = dateTimePickerUtils.parseValue(value, dateTimeMask, mergedI18n.toLabel, hasTimeInput, effectiveTimezone);
416
422
  setHumanValue(parsedValue.readableValue);
417
423
  return _objectSpread(_objectSpread({}, value), parsedValue);
418
424
  };
@@ -467,15 +473,17 @@ var DateTimePicker = function DateTimePicker(_ref) {
467
473
  setIsCustomRange(true);
468
474
  setCustomRangeKind(PICKER_KINDS.ABSOLUTE);
469
475
  if (!absolute.hasOwnProperty('start')) {
470
- absolute.start = dayjs.default("".concat(absolute.startDate, " ").concat(absolute.startTime)).valueOf();
476
+ var startDateTime = "".concat(absolute.startDate, " ").concat(absolute.startTime);
477
+ absolute.start = dayjs.default.tz(startDateTime, dayjs.detectDateTimeFormat(startDateTime), effectiveTimezone).valueOf();
471
478
  }
472
479
  if (!absolute.hasOwnProperty('end')) {
473
- absolute.end = dayjs.default("".concat(absolute.endDate, " ").concat(absolute.endTime)).valueOf();
480
+ var endDateTime = "".concat(absolute.endDate, " ").concat(absolute.endTime);
481
+ absolute.end = dayjs.default.tz(endDateTime, dayjs.detectDateTimeFormat(endDateTime), effectiveTimezone).valueOf();
474
482
  }
475
- absolute.startDate = dayjs.default(absolute.start).format('MM/DD/YYYY');
476
- absolute.startTime = dayjs.default(absolute.start).format('HH:mm');
477
- absolute.endDate = dayjs.default(absolute.end).format('MM/DD/YYYY');
478
- absolute.endTime = dayjs.default(absolute.end).format('HH:mm');
483
+ absolute.startDate = dayjs.default.tz(absolute.start).format('MM/DD/YYYY');
484
+ absolute.startTime = dayjs.default.tz(absolute.start).format('HH:mm');
485
+ absolute.endDate = dayjs.default.tz(absolute.end).format('MM/DD/YYYY');
486
+ absolute.endTime = dayjs.default.tz(absolute.end).format('HH:mm');
479
487
  setAbsoluteValue(absolute);
480
488
  }
481
489
  } else {
@@ -564,7 +572,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
564
572
  humanValue: humanValue
565
573
  });
566
574
  var disableRelativeApply = isCustomRange && customRangeKind === PICKER_KINDS.RELATIVE && (relativeLastNumberInvalid || relativeToTimeInvalid);
567
- var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || absoluteValue.startDate === '' && absoluteValue.endDate === '' || (hasTimeInput ? !absoluteValue.startTime || !absoluteValue.endTime : false));
575
+ var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || !absoluteValue.startDate || !absoluteValue.endDate || (hasTimeInput ? !absoluteValue.startTime || !absoluteValue.endTime : false));
568
576
  var disableApply = disableRelativeApply || disableAbsoluteApply;
569
577
  React.useEffect(function () {
570
578
  return setInvalidState(invalid || disableApply);
@@ -1278,6 +1286,17 @@ DateTimePicker.__docgenInfo = {
1278
1286
  },
1279
1287
  "required": false
1280
1288
  },
1289
+ "timeZone": {
1290
+ "defaultValue": {
1291
+ "value": "undefined",
1292
+ "computed": true
1293
+ },
1294
+ "description": "IANA timezone string to interpret datetime values in (e.g., 'America/New_York')",
1295
+ "type": {
1296
+ "name": "string"
1297
+ },
1298
+ "required": false
1299
+ },
1281
1300
  "id": {
1282
1301
  "defaultValue": {
1283
1302
  "value": "undefined",