carbon-addons-iot-react 4.4.0 → 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.
- package/README.MD +6 -2
- 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/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +1 -1
- package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +1 -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/Attribute.js +2 -1
- 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/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +1 -1
- package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +1 -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/Attribute.js +2 -1
- 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 +238 -114
|
@@ -19,6 +19,7 @@ var CardPropTypes = require('../../constants/CardPropTypes.js');
|
|
|
19
19
|
var LayoutConstants = require('../../constants/LayoutConstants.js');
|
|
20
20
|
var Card = require('../Card/Card.js');
|
|
21
21
|
var cardUtilityFunctions = require('../../utils/cardUtilityFunctions.js');
|
|
22
|
+
var dayjs = require('../../utils/dayjs.js');
|
|
22
23
|
var valueCardUtils = require('./valueCardUtils.js');
|
|
23
24
|
var ValueContent = require('./ValueContent.js');
|
|
24
25
|
|
|
@@ -30,7 +31,7 @@ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWith
|
|
|
30
31
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
31
32
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
32
33
|
|
|
33
|
-
var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
|
|
34
|
+
var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "timeZone", "customFormatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
|
|
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__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; }
|
|
36
37
|
|
|
@@ -51,6 +52,7 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
51
52
|
dataState = _ref.dataState,
|
|
52
53
|
id = _ref.id,
|
|
53
54
|
locale = _ref.locale,
|
|
55
|
+
timeZone = _ref.timeZone,
|
|
54
56
|
customFormatter = _ref.customFormatter,
|
|
55
57
|
children = _ref.children,
|
|
56
58
|
fontSize = _ref.fontSize,
|
|
@@ -61,6 +63,8 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
61
63
|
className = _ref.className,
|
|
62
64
|
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
63
65
|
others = _objectWithoutProperties__default.default(_ref, _excluded);
|
|
66
|
+
var effectiveTimezone = timeZone || dayjs.default.tz.guess();
|
|
67
|
+
dayjs.default.tz.setDefault(effectiveTimezone);
|
|
64
68
|
var availableActions = _objectSpread({
|
|
65
69
|
expand: false
|
|
66
70
|
}, others.availableActions);
|
|
@@ -86,6 +90,7 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
86
90
|
i18n: i18n,
|
|
87
91
|
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
88
92
|
locale: locale,
|
|
93
|
+
timeZone: effectiveTimezone,
|
|
89
94
|
id: id,
|
|
90
95
|
className: classnames__default.default(className, _defineProperty__default.default(_defineProperty__default.default({}, "".concat(valueCardUtils.BASE_CLASS_NAME, "__horizontal"), layout === LayoutConstants.CARD_LAYOUTS.HORIZONTAL), "".concat(valueCardUtils.BASE_CLASS_NAME, "__vertical"), layout === LayoutConstants.CARD_LAYOUTS.VERTICAL))
|
|
91
96
|
// TODO: remove deprecated 'testID' in v3.
|
|
@@ -753,6 +753,8 @@ var CardPropTypes = {
|
|
|
753
753
|
testId: PropTypes__default.default.string,
|
|
754
754
|
/** the locale of the card, needed for number and date formatting */
|
|
755
755
|
locale: PropTypes__default.default.string,
|
|
756
|
+
/** IANA timezone string to set as default timezone for dayjs */
|
|
757
|
+
timeZone: PropTypes__default.default.string,
|
|
756
758
|
/** a way to pass down dashboard grid resize handles, only used by other card types */
|
|
757
759
|
resizeHandles: PropTypes__default.default.array,
|
|
758
760
|
/** Optional callback function that is passed an onChange function and the original cardConfig object.
|
|
@@ -550,7 +550,7 @@ var handleTooltip = function handleTooltip(dataOrHoveredElement, defaultTooltip,
|
|
|
550
550
|
: dataOrHoveredElement;
|
|
551
551
|
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();
|
|
552
552
|
var dateLabel = timeStamp ? "<li class='datapoint-tooltip'>\n <p class='label'>".concat((showTimeInGMT // show timestamp in gmt or local time
|
|
553
|
-
? dayjs.default.utc(timeStamp) : dayjs.default(timeStamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
|
|
553
|
+
? dayjs.default.utc(timeStamp) : dayjs.default.tz(timeStamp)).format(tooltipDateFormatPattern), "</p>\n </li>") : '';
|
|
554
554
|
var matchingAlertRanges = findMatchingAlertRange(alertRanges, data);
|
|
555
555
|
var matchingAlertLabels = Array.isArray(matchingAlertRanges) ? matchingAlertRanges.map(function (matchingAlertRange) {
|
|
556
556
|
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/lib/utils/dayjs.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/es.array.find.js');
|
|
5
6
|
require('core-js/modules/es.object.keys.js');
|
|
6
7
|
require('core-js/modules/es.object.to-string.js');
|
|
8
|
+
require('core-js/modules/es.string.trim.js');
|
|
7
9
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
8
10
|
var dayjs$2 = require('dayjs');
|
|
9
11
|
|
|
@@ -16,12 +18,14 @@ var utc = require('dayjs/plugin/utc');
|
|
|
16
18
|
var pluralGetSet = require('dayjs/plugin/pluralGetSet');
|
|
17
19
|
var timezone = require('dayjs/plugin/timezone');
|
|
18
20
|
var localeData = require('dayjs/plugin/localeData');
|
|
21
|
+
var customParseFormat = require('dayjs/plugin/customParseFormat');
|
|
19
22
|
var dayjs = dayjs__default.default;
|
|
20
23
|
dayjs.extend(localizedFormat); // gives the 'L' formatting ability for .format
|
|
21
24
|
dayjs.extend(utc); // gives .utc() and .local()
|
|
22
25
|
dayjs.extend(pluralGetSet); // gives .hour .minute get/set ability
|
|
23
26
|
dayjs.extend(timezone); // timezone support
|
|
24
27
|
dayjs.extend(localeData); // gives local specific data
|
|
28
|
+
dayjs.extend(customParseFormat);
|
|
25
29
|
|
|
26
30
|
/* eslint-disable global-require */
|
|
27
31
|
var locales = {
|
|
@@ -451,7 +455,25 @@ var DAYJS_INPUT_FORMATS = {
|
|
|
451
455
|
SECONDS: 'L HH:mm:ss',
|
|
452
456
|
RANGE: 'L HH:mm'
|
|
453
457
|
};
|
|
458
|
+
var formats = [
|
|
459
|
+
// ISO Variations (Most common for APIs)
|
|
460
|
+
'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',
|
|
461
|
+
// US / Common UI Variations
|
|
462
|
+
'MM/DD/YYYY HH:mm:ss', 'MM/DD/YYYY HH:mm', 'MM-DD-YYYY HH:mm:ss', 'MM-DD-YYYY HH:mm',
|
|
463
|
+
// 12-Hour Variations (If users can type AM/PM)
|
|
464
|
+
'MM/DD/YYYY hh:mm A', 'YYYY-MM-DD hh:mm A',
|
|
465
|
+
// Date Only Fallbacks
|
|
466
|
+
'YYYY-MM-DD', 'MM/DD/YYYY', 'MM-DD-YYYY', 'L' // Localized format (uses the loaded Day.js locale)
|
|
467
|
+
];
|
|
468
|
+
var detectDateTimeFormat = function detectDateTimeFormat(dateTimeString) {
|
|
469
|
+
if (!(dateTimeString !== null && dateTimeString !== void 0 && dateTimeString.trim())) return null;
|
|
470
|
+
return formats.find(function (format) {
|
|
471
|
+
return dayjs(dateTimeString, format, true).isValid();
|
|
472
|
+
});
|
|
473
|
+
};
|
|
454
474
|
var dayjs$1 = dayjs;
|
|
455
475
|
|
|
456
476
|
exports.DAYJS_INPUT_FORMATS = DAYJS_INPUT_FORMATS;
|
|
457
477
|
exports.default = dayjs$1;
|
|
478
|
+
exports.detectDateTimeFormat = detectDateTimeFormat;
|
|
479
|
+
exports.formats = formats;
|