carbon-addons-iot-react 5.10.4 → 5.10.5
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/es/components/BarChartCard/BarChartCard.js +16 -4
- package/es/components/BarChartCard/barChartUtils.js +8 -7
- package/es/components/Card/Card.js +8 -5
- package/es/components/Card/CardToolbar.js +3 -1
- package/es/components/DateTimePicker/DateTimePicker.js +29 -10
- package/es/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +2 -3
- package/es/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +30 -10
- package/es/components/DateTimePicker/dateTimePickerUtils.js +34 -29
- package/es/components/ImageCard/ImageCard.js +15 -2
- package/es/components/ListCard/ListCard.js +7 -2
- package/es/components/TableCard/TableCard.js +15 -4
- package/es/components/TableCard/tableCardUtils.js +2 -2
- package/es/components/TimeSeriesCard/TimeSeriesCard.js +15 -4
- package/es/components/TimeSeriesCard/timeSeriesUtils.js +2 -2
- package/es/components/ValueCard/ValueCard.js +6 -1
- package/es/constants/CardPropTypes.js +2 -0
- package/es/utils/cardUtilityFunctions.js +1 -1
- package/es/utils/dayjs.js +21 -1
- package/lib/components/BarChartCard/BarChartCard.js +16 -4
- package/lib/components/BarChartCard/barChartUtils.js +8 -7
- package/lib/components/Card/Card.js +7 -4
- package/lib/components/Card/CardToolbar.js +3 -1
- package/lib/components/DateTimePicker/DateTimePicker.js +28 -9
- package/lib/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +2 -3
- package/lib/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +29 -9
- package/lib/components/DateTimePicker/dateTimePickerUtils.js +34 -29
- package/lib/components/ImageCard/ImageCard.js +15 -2
- package/lib/components/ListCard/ListCard.js +7 -2
- package/lib/components/TableCard/TableCard.js +15 -4
- package/lib/components/TableCard/tableCardUtils.js +2 -2
- package/lib/components/TimeSeriesCard/TimeSeriesCard.js +15 -4
- package/lib/components/TimeSeriesCard/timeSeriesUtils.js +2 -2
- package/lib/components/ValueCard/ValueCard.js +6 -1
- package/lib/constants/CardPropTypes.js +2 -0
- package/lib/utils/cardUtilityFunctions.js +1 -1
- package/lib/utils/dayjs.js +22 -0
- package/package.json +1 -1
- package/umd/carbon-addons-iot-react.js +234 -111
|
@@ -34,7 +34,7 @@ import dayjs, { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
|
|
|
34
34
|
import { formatGraphTick } from '../TimeSeriesCard/timeSeriesUtils.js';
|
|
35
35
|
import { generateSampleValues, generateSampleValuesForEditor, formatChartData, mapValuesToAxes, formatColors, generateTableColumns, formatTableData, getMaxTicksPerSize, handleTooltip } from './barChartUtils.js';
|
|
36
36
|
|
|
37
|
-
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"];
|
|
37
|
+
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"];
|
|
38
38
|
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; }
|
|
39
39
|
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; }
|
|
40
40
|
var iotPrefix = settings.iotPrefix;
|
|
@@ -59,6 +59,7 @@ var defaultProps = {
|
|
|
59
59
|
series: []
|
|
60
60
|
},
|
|
61
61
|
locale: 'en',
|
|
62
|
+
timeZone: undefined,
|
|
62
63
|
showTimeInGMT: false,
|
|
63
64
|
tooltipDateFormatPattern: DAYJS_INPUT_FORMATS.SECONDS,
|
|
64
65
|
values: null,
|
|
@@ -72,6 +73,7 @@ var BarChartCard = function BarChartCard(_ref) {
|
|
|
72
73
|
initialValues = _ref.values,
|
|
73
74
|
availableDimensions = _ref.availableDimensions,
|
|
74
75
|
locale = _ref.locale,
|
|
76
|
+
timeZone = _ref.timeZone,
|
|
75
77
|
i18n = _ref.i18n,
|
|
76
78
|
isExpanded = _ref.isExpanded,
|
|
77
79
|
isLazyLoading = _ref.isLazyLoading,
|
|
@@ -89,6 +91,8 @@ var BarChartCard = function BarChartCard(_ref) {
|
|
|
89
91
|
testId = _ref.testId,
|
|
90
92
|
defaultDateFormatPattern = _ref.defaultDateFormatPattern,
|
|
91
93
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
94
|
+
var effectiveTimezone = timeZone || dayjs.tz.guess();
|
|
95
|
+
dayjs.tz.setDefault(effectiveTimezone);
|
|
92
96
|
// need to deep merge the nested content default props as default props only uses a shallow merge natively
|
|
93
97
|
var contentWithDefaults = useMemo(function () {
|
|
94
98
|
return _defaultsDeep({}, content, defaultProps.content);
|
|
@@ -249,7 +253,7 @@ var BarChartCard = function BarChartCard(_ref) {
|
|
|
249
253
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
250
254
|
args[_key] = arguments[_key];
|
|
251
255
|
}
|
|
252
|
-
return handleTooltip.apply(void 0, args.concat([timeDataSourceId, showTimeInGMT, tooltipDateFormatPattern, locale]));
|
|
256
|
+
return handleTooltip.apply(void 0, args.concat([timeDataSourceId, showTimeInGMT, tooltipDateFormatPattern, locale, effectiveTimezone]));
|
|
253
257
|
},
|
|
254
258
|
groupLabel: mergedI18n.tooltipGroupLabel,
|
|
255
259
|
totalLabel: mergedI18n.tooltipTotalLabel
|
|
@@ -268,7 +272,7 @@ var BarChartCard = function BarChartCard(_ref) {
|
|
|
268
272
|
enabled: false
|
|
269
273
|
}
|
|
270
274
|
});
|
|
271
|
-
}, [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]);
|
|
275
|
+
}, [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.enabled, zoomBar.initialZoomDomain, zoomBar.view, size, isExpanded, locale, showTimeInGMT, tooltipDateFormatPattern, effectiveTimezone]);
|
|
272
276
|
return /*#__PURE__*/React__default.createElement(Card, _extends({
|
|
273
277
|
title: title,
|
|
274
278
|
className: classnames(className, "".concat(iotPrefix, "--bar-chart-card")),
|
|
@@ -282,7 +286,8 @@ var BarChartCard = function BarChartCard(_ref) {
|
|
|
282
286
|
isResizable: isResizable,
|
|
283
287
|
resizeHandles: resizeHandles,
|
|
284
288
|
timeRange: timeRange,
|
|
285
|
-
locale: locale
|
|
289
|
+
locale: locale,
|
|
290
|
+
timeZone: effectiveTimezone
|
|
286
291
|
// TODO: remove deprecated testID in v3.
|
|
287
292
|
,
|
|
288
293
|
testId: testID || testId
|
|
@@ -378,6 +383,13 @@ BarChartCard.__docgenInfo = {
|
|
|
378
383
|
},
|
|
379
384
|
"required": false
|
|
380
385
|
},
|
|
386
|
+
"timeZone": {
|
|
387
|
+
"defaultValue": {
|
|
388
|
+
"value": "undefined",
|
|
389
|
+
"computed": true
|
|
390
|
+
},
|
|
391
|
+
"required": false
|
|
392
|
+
},
|
|
381
393
|
"showTimeInGMT": {
|
|
382
394
|
"defaultValue": {
|
|
383
395
|
"value": "false",
|
|
@@ -258,8 +258,7 @@ var formatChartData = function formatChartData(seriesArg, values, categoryDataSo
|
|
|
258
258
|
// bar this data belongs to
|
|
259
259
|
value: value[dataset.dataSourceId]
|
|
260
260
|
}, timeDataSourceId && type !== BAR_CHART_TYPES.GROUPED ? {
|
|
261
|
-
date:
|
|
262
|
-
// timestamp
|
|
261
|
+
date: dayjs.tz(value[timeDataSourceId]).toDate(),
|
|
263
262
|
key: value[timeDataSourceId]
|
|
264
263
|
} : {
|
|
265
264
|
key: value[categoryDataSourceId]
|
|
@@ -304,14 +303,13 @@ var formatChartData = function formatChartData(seriesArg, values, categoryDataSo
|
|
|
304
303
|
dataset.forEach(function (value) {
|
|
305
304
|
// if value is null, don't add it to the formatted chartData
|
|
306
305
|
if (!isNil(value[series[0].dataSourceId])) {
|
|
307
|
-
var dataDate = new Date(value[timeDataSourceId]);
|
|
308
306
|
data.push({
|
|
309
307
|
// Use the label if one exists
|
|
310
308
|
group: series[0].label ? series[0].label : series[0].dataSourceId,
|
|
311
309
|
// bar this data belongs to
|
|
312
310
|
value: value[series[0].dataSourceId],
|
|
313
311
|
// there should only be one series here because its a simple bar
|
|
314
|
-
date:
|
|
312
|
+
date: dayjs.tz(value[timeDataSourceId]).toDate()
|
|
315
313
|
});
|
|
316
314
|
}
|
|
317
315
|
});
|
|
@@ -432,10 +430,12 @@ var formatColors = function formatColors(series, datasetNames, isDashboardPrevie
|
|
|
432
430
|
* @param {string} timeDatasourceId time-based attribute
|
|
433
431
|
* @param {bool} showTimeInGMT
|
|
434
432
|
* @param {string} tooltipDataFormatPattern
|
|
433
|
+
* @param {string} timezone
|
|
435
434
|
*/
|
|
436
435
|
var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip, _datum, timeDataSourceId, showTimeInGMT) {
|
|
437
436
|
var tooltipDateFormatPattern = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : DAYJS_INPUT_FORMATS.SECONDS;
|
|
438
437
|
var locale = arguments.length > 6 ? arguments[6] : undefined;
|
|
438
|
+
var timezone = arguments.length > 7 ? arguments[7] : undefined;
|
|
439
439
|
dayjs.locale(locale);
|
|
440
440
|
var data = dataOrHoveredElement.__data__ // eslint-disable-line no-underscore-dangle
|
|
441
441
|
? dataOrHoveredElement.__data__ // eslint-disable-line no-underscore-dangle
|
|
@@ -449,8 +449,7 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
|
|
|
449
449
|
if (timeDataSourceId) {
|
|
450
450
|
// generate the formatted label
|
|
451
451
|
var timestamp = typedData === null || typedData === void 0 ? void 0 : typedData.date;
|
|
452
|
-
var dateLabel = timestamp ? "<li class='datapoint-tooltip'>\n <p class='label'>\n ".concat((showTimeInGMT
|
|
453
|
-
? dayjs.utc(timestamp) : dayjs(timestamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
|
|
452
|
+
var dateLabel = timestamp ? "<li class='datapoint-tooltip'>\n <p class='label'>\n ".concat((showTimeInGMT ? dayjs.utc(timestamp) : dayjs(timestamp).tz(timezone)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
|
|
454
453
|
var _convertStringsToDOME3 = convertStringsToDOMElement([dateLabel]),
|
|
455
454
|
_convertStringsToDOME4 = _slicedToArray(_convertStringsToDOME3, 1),
|
|
456
455
|
parsedDateLabel = _convertStringsToDOME4[0];
|
|
@@ -516,6 +515,8 @@ var generateTableColumns = function generateTableColumns(timeDataSourceId, categ
|
|
|
516
515
|
* @param {string} type of chart i.e. simple, grouped, stacked
|
|
517
516
|
* @param {Array<Object>} values values before they are formatted for charting
|
|
518
517
|
* @param {Array<Object>} chartData values after they are formatted for charting
|
|
518
|
+
* @param {string} defaultDateFormatPattern date format pattern
|
|
519
|
+
* @param {string} timezone timezone to use for formatting dates
|
|
519
520
|
*/
|
|
520
521
|
var formatTableData = function formatTableData(timeDataSourceId, categoryDataSourceId, type, values, chartData) {
|
|
521
522
|
var defaultDateFormatPattern = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : DAYJS_INPUT_FORMATS.SECONDS;
|
|
@@ -540,7 +541,7 @@ var formatTableData = function formatTableData(timeDataSourceId, categoryDataSou
|
|
|
540
541
|
});
|
|
541
542
|
tableData.push({
|
|
542
543
|
id: "dataindex-".concat(index),
|
|
543
|
-
values: _objectSpread(_objectSpread({}, barTimeValue), {}, _defineProperty({}, timeDataSourceId, dayjs(timestamp).format(defaultDateFormatPattern))),
|
|
544
|
+
values: _objectSpread(_objectSpread({}, barTimeValue), {}, _defineProperty({}, timeDataSourceId, dayjs.tz(timestamp).format(defaultDateFormatPattern))),
|
|
544
545
|
isSelectable: false
|
|
545
546
|
});
|
|
546
547
|
});
|
|
@@ -30,13 +30,13 @@ import { getTranslatedLabel, getUpdatedCardSize, useCardResizing } from '../../u
|
|
|
30
30
|
import { parseValue } from '../DateTimePicker/dateTimePickerUtils.js';
|
|
31
31
|
import useSizeObserver from '../../hooks/useSizeObserver.js';
|
|
32
32
|
import EmptyState from '../EmptyState/EmptyState.js';
|
|
33
|
-
import { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
|
|
33
|
+
import dayjs, { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
|
|
34
34
|
import CardTypeContent from './CardTypeContent.js';
|
|
35
35
|
import CardToolbar from './CardToolbar.js';
|
|
36
36
|
import { CardTitle } from './CardTitle.js';
|
|
37
37
|
|
|
38
38
|
var _excluded = ["isSelected", "children", "dimensions", "id", "style", "className", "onScroll", "onMouseDown", "onMouseUp", "onTouchEnd", "onTouchStart", "onFocus", "onBlur", "tabIndex", "testID", "testId"],
|
|
39
|
-
_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", "extraHeaderContent", "shouldUseTranslatedLabels"];
|
|
39
|
+
_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", "extraHeaderContent", "timeZone", "shouldUseTranslatedLabels"];
|
|
40
40
|
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; }
|
|
41
41
|
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; }
|
|
42
42
|
var prefix = settings.prefix,
|
|
@@ -300,9 +300,11 @@ var Card = function Card(props) {
|
|
|
300
300
|
data = props.data,
|
|
301
301
|
content = props.content,
|
|
302
302
|
extraHeaderContent = props.extraHeaderContent,
|
|
303
|
+
timeZone = props.timeZone,
|
|
303
304
|
shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
|
|
304
305
|
others = _objectWithoutProperties(props, _excluded2);
|
|
305
|
-
|
|
306
|
+
var effectiveTimezone = timeZone || dayjs.tz.guess();
|
|
307
|
+
dayjs.tz.setDefault(effectiveTimezone);
|
|
306
308
|
// Get translated title if shouldUseTranslatedLabels is true
|
|
307
309
|
var title = getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
|
|
308
310
|
var tooltip = getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n);
|
|
@@ -340,12 +342,12 @@ var Card = function Card(props) {
|
|
|
340
342
|
return subtitleProp;
|
|
341
343
|
}
|
|
342
344
|
if (mergedAvailableActions.range === 'full' || mergedAvailableActions.range === 'iconOnly') {
|
|
343
|
-
var _parseValue = parseValue(timeRange, dateTimeMask, strings.toLabel),
|
|
345
|
+
var _parseValue = parseValue(timeRange, dateTimeMask, strings.toLabel, true, effectiveTimezone),
|
|
344
346
|
readableValue = _parseValue.readableValue;
|
|
345
347
|
return readableValue;
|
|
346
348
|
}
|
|
347
349
|
return undefined;
|
|
348
|
-
}, [dateTimeMask, mergedAvailableActions.range, strings.toLabel, subtitleProp, timeRange]);
|
|
350
|
+
}, [dateTimeMask, mergedAvailableActions.range, strings.toLabel, subtitleProp, timeRange, effectiveTimezone]);
|
|
349
351
|
var _useState = useState(getTheSubtitle),
|
|
350
352
|
_useState2 = _slicedToArray(_useState, 2),
|
|
351
353
|
subtitle = _useState2[0],
|
|
@@ -403,6 +405,7 @@ var Card = function Card(props) {
|
|
|
403
405
|
isExpanded: isExpanded,
|
|
404
406
|
timeRange: timeRange,
|
|
405
407
|
locale: others.locale,
|
|
408
|
+
timeZone: effectiveTimezone,
|
|
406
409
|
timeRangeOptions: timeRangeOptions,
|
|
407
410
|
onCardAction: cachedOnCardAction
|
|
408
411
|
// TODO: remove deprecated testID prop in v3
|
|
@@ -133,7 +133,8 @@ var CardToolbar = function CardToolbar(_ref) {
|
|
|
133
133
|
dateTimeMask = _ref.dateTimeMask,
|
|
134
134
|
extraActions = _ref.extraActions,
|
|
135
135
|
renderDateDropdownInPortal = _ref.renderDateDropdownInPortal,
|
|
136
|
-
id = _ref.id
|
|
136
|
+
id = _ref.id,
|
|
137
|
+
timeZone = _ref.timeZone;
|
|
137
138
|
var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
|
|
138
139
|
var langDir = useLangDirection();
|
|
139
140
|
var overflowMenuPosition = React__default.useMemo(function () {
|
|
@@ -237,6 +238,7 @@ var CardToolbar = function CardToolbar(_ref) {
|
|
|
237
238
|
i18n: mergedI18n,
|
|
238
239
|
dateTimeMask: dateTimeMask,
|
|
239
240
|
locale: locale,
|
|
241
|
+
timeZone: timeZone,
|
|
240
242
|
hasIconOnly: true,
|
|
241
243
|
presets: Object.entries(timeRangeOptions).reduce(function (acc, _ref2) {
|
|
242
244
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -18,13 +18,13 @@ import classnames from 'classnames';
|
|
|
18
18
|
import { v4 } from 'uuid';
|
|
19
19
|
import TimePickerSpinner from '../TimePickerSpinner/TimePickerSpinner.js';
|
|
20
20
|
import { settings } from '../../constants/Settings.js';
|
|
21
|
-
import dayjs, { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
|
|
21
|
+
import dayjs, { DAYJS_INPUT_FORMATS, detectDateTimeFormat } from '../../utils/dayjs.js';
|
|
22
22
|
import { useOnClickOutside, handleSpecificKeyDown } from '../../utils/componentUtilityFunctions.js';
|
|
23
23
|
import { Tooltip } from '../Tooltip/index.js';
|
|
24
24
|
import { useDateTimePickerRangeKind, useDateTimePickerKeyboardInteraction, useAbsoluteDateTimeValue, useRelativeDateTimeValue, useCloseDropdown, getIntervalValue, parseValue, invalidEndDate, invalidStartDate, useDateTimePickerClickOutside } from './dateTimePickerUtils.js';
|
|
25
25
|
import { WarningFilled, Calendar } from '@carbon/icons-react';
|
|
26
26
|
|
|
27
|
-
var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "style"];
|
|
27
|
+
var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "timeZone", "style"];
|
|
28
28
|
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; }
|
|
29
29
|
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; }
|
|
30
30
|
var iotPrefix = settings.iotPrefix,
|
|
@@ -171,6 +171,8 @@ var propTypes = {
|
|
|
171
171
|
light: PropTypes.bool,
|
|
172
172
|
/** The language locale used to format the days of the week, months, and numbers. */
|
|
173
173
|
locale: PropTypes.string,
|
|
174
|
+
/** IANA timezone string to interpret datetime values in (e.g., 'America/New_York') */
|
|
175
|
+
timeZone: PropTypes.string,
|
|
174
176
|
/** Unique id of the component */
|
|
175
177
|
id: PropTypes.string,
|
|
176
178
|
style: PropTypes.objectOf(PropTypes.string)
|
|
@@ -246,6 +248,7 @@ var defaultProps = {
|
|
|
246
248
|
},
|
|
247
249
|
light: false,
|
|
248
250
|
locale: 'en',
|
|
251
|
+
timeZone: undefined,
|
|
249
252
|
id: undefined,
|
|
250
253
|
style: {}
|
|
251
254
|
};
|
|
@@ -268,10 +271,13 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
268
271
|
i18n = _ref.i18n,
|
|
269
272
|
light = _ref.light,
|
|
270
273
|
locale = _ref.locale,
|
|
274
|
+
timeZone = _ref.timeZone,
|
|
271
275
|
style = _ref.style,
|
|
272
276
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
273
277
|
var id = useRef(others.id || v4()).current;
|
|
274
278
|
var mergedI18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
|
|
279
|
+
var effectiveTimezone = timeZone || dayjs.tz.guess();
|
|
280
|
+
dayjs.tz.setDefault(effectiveTimezone);
|
|
275
281
|
dayjs.locale(locale);
|
|
276
282
|
|
|
277
283
|
// State
|
|
@@ -398,7 +404,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
398
404
|
value.kind = PICKER_KINDS.PRESET;
|
|
399
405
|
}
|
|
400
406
|
setCurrentValue(value);
|
|
401
|
-
var parsedValue = parseValue(value, dateTimeMask, mergedI18n.toLabel);
|
|
407
|
+
var parsedValue = parseValue(value, dateTimeMask, mergedI18n.toLabel, hasTimeInput, effectiveTimezone);
|
|
402
408
|
setHumanValue(parsedValue.readableValue);
|
|
403
409
|
return _objectSpread(_objectSpread({}, value), parsedValue);
|
|
404
410
|
};
|
|
@@ -453,15 +459,17 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
453
459
|
setIsCustomRange(true);
|
|
454
460
|
setCustomRangeKind(PICKER_KINDS.ABSOLUTE);
|
|
455
461
|
if (!absolute.hasOwnProperty('start')) {
|
|
456
|
-
|
|
462
|
+
var startDateTime = "".concat(absolute.startDate, " ").concat(absolute.startTime);
|
|
463
|
+
absolute.start = dayjs.tz(startDateTime, detectDateTimeFormat(startDateTime), effectiveTimezone).valueOf();
|
|
457
464
|
}
|
|
458
465
|
if (!absolute.hasOwnProperty('end')) {
|
|
459
|
-
|
|
466
|
+
var endDateTime = "".concat(absolute.endDate, " ").concat(absolute.endTime);
|
|
467
|
+
absolute.end = dayjs.tz(endDateTime, detectDateTimeFormat(endDateTime), effectiveTimezone).valueOf();
|
|
460
468
|
}
|
|
461
|
-
absolute.startDate = dayjs(absolute.start).format('MM/DD/YYYY');
|
|
462
|
-
absolute.startTime = dayjs(absolute.start).format('HH:mm');
|
|
463
|
-
absolute.endDate = dayjs(absolute.end).format('MM/DD/YYYY');
|
|
464
|
-
absolute.endTime = dayjs(absolute.end).format('HH:mm');
|
|
469
|
+
absolute.startDate = dayjs.tz(absolute.start).format('MM/DD/YYYY');
|
|
470
|
+
absolute.startTime = dayjs.tz(absolute.start).format('HH:mm');
|
|
471
|
+
absolute.endDate = dayjs.tz(absolute.end).format('MM/DD/YYYY');
|
|
472
|
+
absolute.endTime = dayjs.tz(absolute.end).format('HH:mm');
|
|
465
473
|
setAbsoluteValue(absolute);
|
|
466
474
|
}
|
|
467
475
|
} else {
|
|
@@ -550,7 +558,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
550
558
|
humanValue: humanValue
|
|
551
559
|
});
|
|
552
560
|
var disableRelativeApply = isCustomRange && customRangeKind === PICKER_KINDS.RELATIVE && (relativeLastNumberInvalid || relativeToTimeInvalid);
|
|
553
|
-
var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || absoluteValue.startDate
|
|
561
|
+
var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || !absoluteValue.startDate || !absoluteValue.endDate || (hasTimeInput ? !absoluteValue.startTime || !absoluteValue.endTime : false));
|
|
554
562
|
var disableApply = disableRelativeApply || disableAbsoluteApply;
|
|
555
563
|
useEffect(function () {
|
|
556
564
|
return setInvalidState(invalid || disableApply);
|
|
@@ -1264,6 +1272,17 @@ DateTimePicker.__docgenInfo = {
|
|
|
1264
1272
|
},
|
|
1265
1273
|
"required": false
|
|
1266
1274
|
},
|
|
1275
|
+
"timeZone": {
|
|
1276
|
+
"defaultValue": {
|
|
1277
|
+
"value": "undefined",
|
|
1278
|
+
"computed": true
|
|
1279
|
+
},
|
|
1280
|
+
"description": "IANA timezone string to interpret datetime values in (e.g., 'America/New_York')",
|
|
1281
|
+
"type": {
|
|
1282
|
+
"name": "string"
|
|
1283
|
+
},
|
|
1284
|
+
"required": false
|
|
1285
|
+
},
|
|
1267
1286
|
"id": {
|
|
1268
1287
|
"defaultValue": {
|
|
1269
1288
|
"value": "undefined",
|
|
@@ -800,7 +800,6 @@ var DateTimePicker = function DateTimePicker(_ref2) {
|
|
|
800
800
|
return setInvalidState(invalid);
|
|
801
801
|
}, [invalid]);
|
|
802
802
|
var onApplyClick = function onApplyClick() {
|
|
803
|
-
var _value$absolute$start, _value$absolute$end;
|
|
804
803
|
var value = renderValue();
|
|
805
804
|
var returnValue = {
|
|
806
805
|
timeRangeKind: value.kind,
|
|
@@ -815,8 +814,8 @@ var DateTimePicker = function DateTimePicker(_ref2) {
|
|
|
815
814
|
returnValue.timeRangeValue = _objectSpread(_objectSpread({}, value.absolute), {}, {
|
|
816
815
|
humanValue: humanValue,
|
|
817
816
|
tooltipValue: tooltipValue,
|
|
818
|
-
ISOStart:
|
|
819
|
-
ISOEnd:
|
|
817
|
+
ISOStart: value.absolute.start ? new Date(value.absolute.start).toISOString() : undefined,
|
|
818
|
+
ISOEnd: value.absolute.end ? new Date(value.absolute.end).toISOString() : undefined
|
|
820
819
|
});
|
|
821
820
|
break;
|
|
822
821
|
case PICKER_KINDS.SINGLE:
|
|
@@ -20,7 +20,7 @@ import warning from 'warning';
|
|
|
20
20
|
import { useLangDirection } from '../../utils/useLangDirection.js';
|
|
21
21
|
import TimePickerSpinner from '../TimePickerSpinner/TimePickerSpinner.js';
|
|
22
22
|
import { settings } from '../../constants/Settings.js';
|
|
23
|
-
import dayjs, { DAYJS_INPUT_FORMATS } from '../../utils/dayjs.js';
|
|
23
|
+
import dayjs, { DAYJS_INPUT_FORMATS, detectDateTimeFormat } from '../../utils/dayjs.js';
|
|
24
24
|
import { PICKER_KINDS, INTERVAL_VALUES, PRESET_VALUES, RELATIVE_VALUES } from '../../constants/DateConstants.js';
|
|
25
25
|
import Button from '../Button/Button.js';
|
|
26
26
|
import FlyoutMenu, { FlyoutMenuButtonSize, FlyoutMenuDirection } from '../FlyoutMenu/FlyoutMenu.js';
|
|
@@ -28,7 +28,7 @@ import { useOnClickOutside, handleSpecificKeyDown } from '../../utils/componentU
|
|
|
28
28
|
import { useDateTimePickerRangeKind, useAbsoluteDateTimeValue, useRelativeDateTimeValue, useDateTimePickerKeyboardInteraction, getIntervalValue, useCloseDropdown, useCustomHeight, parseValue, invalidEndDate, invalidStartDate, useDateTimePickerClickOutside } from './dateTimePickerUtils.js';
|
|
29
29
|
import { WarningFilled, Calendar } from '@carbon/icons-react';
|
|
30
30
|
|
|
31
|
-
var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "hasIconOnly", "menuOffset", "renderInPortal", "useAutoPositioning", "style", "buttonProps"];
|
|
31
|
+
var _excluded = ["testId", "defaultValue", "dateTimeMask", "presets", "intervals", "relatives", "expanded", "disabled", "invalid", "showRelativeOption", "showCustomRangeLink", "hasTimeInput", "renderPresetTooltipText", "onCancel", "onApply", "i18n", "light", "locale", "timeZone", "hasIconOnly", "menuOffset", "renderInPortal", "useAutoPositioning", "style", "buttonProps"];
|
|
32
32
|
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; }
|
|
33
33
|
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; }
|
|
34
34
|
var iotPrefix = settings.iotPrefix,
|
|
@@ -138,6 +138,8 @@ var propTypes = {
|
|
|
138
138
|
light: PropTypes.bool,
|
|
139
139
|
/** The language locale used to format the days of the week, months, and numbers. */
|
|
140
140
|
locale: PropTypes.string,
|
|
141
|
+
/** IANA timezone string to set as default timezone for dayjs */
|
|
142
|
+
timeZone: PropTypes.string,
|
|
141
143
|
/** Unique id of the component */
|
|
142
144
|
id: PropTypes.string,
|
|
143
145
|
/** Optionally renders only an icon rather than displaying the current selected time */
|
|
@@ -228,6 +230,7 @@ var defaultProps = {
|
|
|
228
230
|
},
|
|
229
231
|
light: false,
|
|
230
232
|
locale: 'en',
|
|
233
|
+
timeZone: undefined,
|
|
231
234
|
id: undefined,
|
|
232
235
|
hasIconOnly: false,
|
|
233
236
|
menuOffset: undefined,
|
|
@@ -256,6 +259,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
256
259
|
i18n = _ref.i18n,
|
|
257
260
|
light = _ref.light,
|
|
258
261
|
locale = _ref.locale,
|
|
262
|
+
timeZone = _ref.timeZone,
|
|
259
263
|
hasIconOnly = _ref.hasIconOnly,
|
|
260
264
|
menuOffset = _ref.menuOffset,
|
|
261
265
|
renderInPortal = _ref.renderInPortal,
|
|
@@ -263,6 +267,9 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
263
267
|
style = _ref.style,
|
|
264
268
|
buttonProps = _ref.buttonProps,
|
|
265
269
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
270
|
+
var effectiveTimezone = timeZone || dayjs.tz.guess();
|
|
271
|
+
dayjs.tz.setDefault(effectiveTimezone);
|
|
272
|
+
dayjs.locale(locale);
|
|
266
273
|
var id = useRef(others.id || v4()).current;
|
|
267
274
|
React__default.useEffect(function () {
|
|
268
275
|
{
|
|
@@ -402,7 +409,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
402
409
|
value.kind = PICKER_KINDS.PRESET;
|
|
403
410
|
}
|
|
404
411
|
setCurrentValue(value);
|
|
405
|
-
var parsedValue = parseValue(value, dateTimeMask, mergedI18n.toLabel);
|
|
412
|
+
var parsedValue = parseValue(value, dateTimeMask, mergedI18n.toLabel, hasTimeInput, effectiveTimezone);
|
|
406
413
|
setHumanValue(parsedValue.readableValue);
|
|
407
414
|
return _objectSpread(_objectSpread({}, value), parsedValue);
|
|
408
415
|
};
|
|
@@ -457,15 +464,17 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
457
464
|
setIsCustomRange(true);
|
|
458
465
|
setCustomRangeKind(PICKER_KINDS.ABSOLUTE);
|
|
459
466
|
if (!absolute.hasOwnProperty('start')) {
|
|
460
|
-
|
|
467
|
+
var startDateTime = "".concat(absolute.startDate, " ").concat(absolute.startTime);
|
|
468
|
+
absolute.start = dayjs.tz(startDateTime, detectDateTimeFormat(startDateTime), effectiveTimezone).valueOf();
|
|
461
469
|
}
|
|
462
470
|
if (!absolute.hasOwnProperty('end')) {
|
|
463
|
-
|
|
471
|
+
var endDateTime = "".concat(absolute.endDate, " ").concat(absolute.endTime);
|
|
472
|
+
absolute.end = dayjs.tz(endDateTime, detectDateTimeFormat(endDateTime), effectiveTimezone).valueOf();
|
|
464
473
|
}
|
|
465
|
-
absolute.startDate = dayjs(absolute.start).format('MM/DD/YYYY');
|
|
466
|
-
absolute.startTime = dayjs(absolute.start).format('HH:mm');
|
|
467
|
-
absolute.endDate = dayjs(absolute.end).format('MM/DD/YYYY');
|
|
468
|
-
absolute.endTime = dayjs(absolute.end).format('HH:mm');
|
|
474
|
+
absolute.startDate = dayjs.tz(absolute.start).format('MM/DD/YYYY');
|
|
475
|
+
absolute.startTime = dayjs.tz(absolute.start).format('HH:mm');
|
|
476
|
+
absolute.endDate = dayjs.tz(absolute.end).format('MM/DD/YYYY');
|
|
477
|
+
absolute.endTime = dayjs.tz(absolute.end).format('HH:mm');
|
|
469
478
|
setAbsoluteValue(absolute);
|
|
470
479
|
}
|
|
471
480
|
} else {
|
|
@@ -512,7 +521,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
512
521
|
humanValue: humanValue
|
|
513
522
|
});
|
|
514
523
|
var disableRelativeApply = isCustomRange && customRangeKind === PICKER_KINDS.RELATIVE && (relativeLastNumberInvalid || relativeToTimeInvalid);
|
|
515
|
-
var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || absoluteValue.startDate
|
|
524
|
+
var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid || !absoluteValue.startDate || !absoluteValue.endDate || (hasTimeInput ? !absoluteValue.startTime || !absoluteValue.endTime : false));
|
|
516
525
|
var disableApply = disableRelativeApply || disableAbsoluteApply;
|
|
517
526
|
useEffect(function () {
|
|
518
527
|
return setInvalidState(invalid || disableApply);
|
|
@@ -1206,6 +1215,17 @@ DateTimePicker.__docgenInfo = {
|
|
|
1206
1215
|
},
|
|
1207
1216
|
"required": false
|
|
1208
1217
|
},
|
|
1218
|
+
"timeZone": {
|
|
1219
|
+
"defaultValue": {
|
|
1220
|
+
"value": "undefined",
|
|
1221
|
+
"computed": true
|
|
1222
|
+
},
|
|
1223
|
+
"description": "IANA timezone string to set as default timezone for dayjs",
|
|
1224
|
+
"type": {
|
|
1225
|
+
"name": "string"
|
|
1226
|
+
},
|
|
1227
|
+
"required": false
|
|
1228
|
+
},
|
|
1209
1229
|
"id": {
|
|
1210
1230
|
"defaultValue": {
|
|
1211
1231
|
"value": "undefined",
|
|
@@ -82,7 +82,7 @@ var format12hourTo24hour = function format12hourTo24hour(time12hour) {
|
|
|
82
82
|
* @param {Object} value - the absolute time selection
|
|
83
83
|
* @returns {Object} a human readable value and a furtherly augmented value object
|
|
84
84
|
*/
|
|
85
|
-
var parseValue = function parseValue(timeRange, dateTimeMask, toLabel, hasTimeInput) {
|
|
85
|
+
var parseValue = function parseValue(timeRange, dateTimeMask, toLabel, hasTimeInput, timeZone) {
|
|
86
86
|
var _timeRange$kind, _timeRange$relative, _timeRange$absolute, _timeRange$single, _timeRange$preset;
|
|
87
87
|
var readableValue = '';
|
|
88
88
|
if (!timeRange) {
|
|
@@ -102,9 +102,9 @@ var parseValue = function parseValue(timeRange, dateTimeMask, toLabel, hasTimeIn
|
|
|
102
102
|
switch (kind) {
|
|
103
103
|
case PICKER_KINDS.RELATIVE:
|
|
104
104
|
{
|
|
105
|
-
var endDate = dayjs();
|
|
105
|
+
var endDate = dayjs.tz();
|
|
106
106
|
if (value.relativeToWhen !== '') {
|
|
107
|
-
endDate = value.relativeToWhen === RELATIVE_VALUES.YESTERDAY ? dayjs().
|
|
107
|
+
endDate = value.relativeToWhen === RELATIVE_VALUES.YESTERDAY ? dayjs.tz().subtract(1, INTERVAL_VALUES.DAYS) : dayjs.tz();
|
|
108
108
|
// wait to parse it until fully typed
|
|
109
109
|
if (value.relativeToTime.length === 5) {
|
|
110
110
|
endDate = endDate.hour(Number(value.relativeToTime.split(':')[0]));
|
|
@@ -116,37 +116,42 @@ var parseValue = function parseValue(timeRange, dateTimeMask, toLabel, hasTimeIn
|
|
|
116
116
|
}
|
|
117
117
|
returnValue.relative.start = new Date(startDate.valueOf());
|
|
118
118
|
returnValue.relative.end = new Date(endDate.valueOf());
|
|
119
|
-
readableValue = "".concat(
|
|
119
|
+
readableValue = "".concat(startDate.format(dateTimeMask), " ").concat(toLabel, " ").concat(endDate.format(dateTimeMask));
|
|
120
120
|
}
|
|
121
121
|
break;
|
|
122
122
|
}
|
|
123
123
|
case PICKER_KINDS.ABSOLUTE:
|
|
124
124
|
{
|
|
125
|
-
var _value$start
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
_endDate =
|
|
125
|
+
var _value$start;
|
|
126
|
+
if ((_value$start = value.start) !== null && _value$start !== void 0 ? _value$start : value.startDate) {
|
|
127
|
+
var _value$end;
|
|
128
|
+
var _startDate = value.start instanceof Date ? dayjs(value.start).tz(timeZone, true) // Date from picker - preserve local time
|
|
129
|
+
: value.start ? dayjs.tz(value.start) // Timestamp - convert from UTC
|
|
130
|
+
: dayjs.tz(value.startDate, 'MM/DD/YYYY', timeZone); // String - parse with format
|
|
131
|
+
|
|
132
|
+
if (value.startTime && value.startTime.includes(':')) {
|
|
133
|
+
var formatedStartTime = is24hours(dateTimeMask) ? value.startTime : format12hourTo24hour(value.startTime);
|
|
134
|
+
_startDate = _startDate.hours(formatedStartTime.split(':')[0]);
|
|
135
|
+
_startDate = _startDate.minutes(formatedStartTime.split(':')[1]);
|
|
136
|
+
}
|
|
137
|
+
if (!returnValue.absolute) {
|
|
138
|
+
returnValue.absolute = {};
|
|
139
|
+
}
|
|
140
|
+
returnValue.absolute.start = _startDate.valueOf();
|
|
141
|
+
var startTimeValue = value.startTime ? "".concat(_startDate.format(dateTimeMask)) : "".concat(_startDate.format(dateTimeMask)).split(' ')[0];
|
|
142
|
+
if ((_value$end = value.end) !== null && _value$end !== void 0 ? _value$end : value.endDate) {
|
|
143
|
+
var _endDate = value.end instanceof Date ? dayjs(value.end).tz(timeZone, true) : value.end ? dayjs(value.end).tz(timeZone) : dayjs.tz(value.endDate, 'MM/DD/YYYY', timeZone);
|
|
144
|
+
if (value.endTime && value.endTime.includes(':')) {
|
|
145
|
+
var formatedEndTime = is24hours(dateTimeMask) ? value.endTime : format12hourTo24hour(value.endTime);
|
|
146
|
+
_endDate = _endDate.hours(formatedEndTime.split(':')[0]);
|
|
147
|
+
_endDate = _endDate.minutes(formatedEndTime.split(':')[1]);
|
|
148
|
+
}
|
|
149
|
+
var endTimeValue = value.endTime ? "".concat(_endDate.format(dateTimeMask)) : "".concat(_endDate.format(dateTimeMask)).split(' ')[0];
|
|
150
|
+
returnValue.absolute.end = _endDate.valueOf();
|
|
151
|
+
readableValue = "".concat(startTimeValue, " ").concat(toLabel, " ").concat(endTimeValue);
|
|
152
|
+
} else {
|
|
153
|
+
readableValue = "".concat(startTimeValue, " ").concat(toLabel, " ").concat(startTimeValue);
|
|
144
154
|
}
|
|
145
|
-
var endTimeValue = value.endTime ? "".concat(dayjs(_endDate).format(dateTimeMask)) : "".concat(dayjs(_endDate).format(dateTimeMask)).split(' ')[0];
|
|
146
|
-
returnValue.absolute.end = new Date(_endDate.valueOf());
|
|
147
|
-
readableValue = "".concat(startTimeValue, " ").concat(toLabel, " ").concat(endTimeValue);
|
|
148
|
-
} else {
|
|
149
|
-
readableValue = "".concat(startTimeValue, " ").concat(toLabel, " ").concat(startTimeValue);
|
|
150
155
|
}
|
|
151
156
|
break;
|
|
152
157
|
}
|
|
@@ -577,7 +582,7 @@ var getIntervalValue = function getIntervalValue(_ref7) {
|
|
|
577
582
|
humanValue = _ref7.humanValue;
|
|
578
583
|
if (currentValue) {
|
|
579
584
|
if (currentValue.kind === PICKER_KINDS.PRESET) {
|
|
580
|
-
return "".concat(dayjs().subtract(currentValue.preset.offset, 'minutes').format(dateTimeMask), " ").concat(mergedI18n.toNowLabel);
|
|
585
|
+
return "".concat(dayjs.tz().subtract(currentValue.preset.offset, 'minutes').format(dateTimeMask), " ").concat(mergedI18n.toNowLabel);
|
|
581
586
|
}
|
|
582
587
|
return humanValue;
|
|
583
588
|
}
|
|
@@ -26,11 +26,12 @@ import Card from '../Card/Card.js';
|
|
|
26
26
|
import { getUpdatedCardSize, getResizeHandles } from '../../utils/cardUtilityFunctions.js';
|
|
27
27
|
import { validHotspotIcons, validThresholdIcons } from '../DashboardEditor/editorUtils.js';
|
|
28
28
|
import { settings } from '../../constants/Settings.js';
|
|
29
|
+
import dayjs from '../../utils/dayjs.js';
|
|
29
30
|
import ImageHotspots from './ImageHotspots.js';
|
|
30
31
|
import ImageUploader from './ImageUploader.js';
|
|
31
32
|
import { Image, Warning } from '@carbon/icons-react';
|
|
32
33
|
|
|
33
|
-
var _excluded = ["title", "content", "children", "values", "size", "onCardAction", "availableActions", "isEditable", "isExpanded", "isResizable", "error", "isLoading", "maxFileSizeInBytes", "i18n", "i18n", "renderIconByName", "locale", "onUpload", "validateUploadedImage", "onBrowseClick", "testID", "testId"];
|
|
34
|
+
var _excluded = ["title", "content", "children", "values", "size", "onCardAction", "availableActions", "isEditable", "isExpanded", "isResizable", "error", "isLoading", "maxFileSizeInBytes", "i18n", "i18n", "renderIconByName", "locale", "onUpload", "validateUploadedImage", "onBrowseClick", "testID", "testId", "timeZone"];
|
|
34
35
|
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; }
|
|
35
36
|
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; }
|
|
36
37
|
var iotPrefix = settings.iotPrefix;
|
|
@@ -52,6 +53,7 @@ var defaultProps = {
|
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
locale: 'en',
|
|
56
|
+
timeZone: undefined,
|
|
55
57
|
content: {},
|
|
56
58
|
maxFileSizeInBytes: 1048576,
|
|
57
59
|
accept: null,
|
|
@@ -111,7 +113,10 @@ var ImageCard = function ImageCard(_ref) {
|
|
|
111
113
|
onBrowseClick = _ref.onBrowseClick,
|
|
112
114
|
testID = _ref.testID,
|
|
113
115
|
testId = _ref.testId,
|
|
116
|
+
timeZone = _ref.timeZone,
|
|
114
117
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
118
|
+
var effectiveTimezone = timeZone || dayjs.tz.guess();
|
|
119
|
+
dayjs.tz.setDefault(effectiveTimezone);
|
|
115
120
|
var _useState = useState(content),
|
|
116
121
|
_useState2 = _slicedToArray(_useState, 2),
|
|
117
122
|
imgContent = _useState2[0],
|
|
@@ -170,7 +175,8 @@ var ImageCard = function ImageCard(_ref) {
|
|
|
170
175
|
// TODO: remove deprecated testID prop in v3.
|
|
171
176
|
,
|
|
172
177
|
testId: testID || testId,
|
|
173
|
-
locale: locale
|
|
178
|
+
locale: locale,
|
|
179
|
+
timeZone: effectiveTimezone
|
|
174
180
|
}, others, {
|
|
175
181
|
error: error,
|
|
176
182
|
i18n: mergedI18n
|
|
@@ -246,6 +252,13 @@ ImageCard.__docgenInfo = {
|
|
|
246
252
|
},
|
|
247
253
|
"required": false
|
|
248
254
|
},
|
|
255
|
+
"timeZone": {
|
|
256
|
+
"defaultValue": {
|
|
257
|
+
"value": "undefined",
|
|
258
|
+
"computed": true
|
|
259
|
+
},
|
|
260
|
+
"required": false
|
|
261
|
+
},
|
|
249
262
|
"content": {
|
|
250
263
|
"defaultValue": {
|
|
251
264
|
"value": "{}",
|