carbon-addons-iot-react 2.147.0-next.2 → 2.147.0-next.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +404 -0
- package/css/carbon-addons-iot-react.css +5374 -5566
- package/css/carbon-addons-iot-react.css.map +1 -1
- package/es/components/Card/Card.js +44 -7
- package/es/components/Card/CardRangePicker.js +15 -4
- package/es/components/Card/CardToolbar.js +2 -3
- package/es/components/ComboBox/ComboBox.js +2 -1
- package/es/components/DateTimePicker/DateTimePicker.js +68 -92
- package/es/components/DateTimePicker/DateTimePickerV2.js +58 -94
- package/es/components/DateTimePicker/dateTimePickerUtils.js +124 -0
- package/es/components/Header/HeaderAction/HeaderAction.js +2 -2
- package/es/components/Header/HeaderActionGroup.js +4 -2
- package/es/components/ImageCard/ImageCard.js +2 -2
- package/es/components/ImageCard/ImageHotspots.js +2 -1
- package/es/components/List/HierarchyList/HierarchyList.js +72 -15
- package/es/components/List/List.js +56 -120
- package/es/components/List/ListContent/ListContent.js +509 -0
- package/es/components/List/ListItem/ListItem.js +14 -2
- package/es/components/List/VirtualListContent/VirtualListContent.js +685 -0
- package/es/components/PieChartCard/PieChartCard.js +4 -2
- package/es/components/Table/Table.js +49 -45
- package/es/components/Table/TableFoot/TableFoot.js +22 -10
- package/es/components/Table/TableHead/ColumnGrouping/ColumnGrouping.js +164 -0
- package/es/components/Table/TableHead/TableHead.js +61 -31
- package/es/components/Table/TableHead/TableHeader.js +47 -7
- package/es/components/Table/TablePropTypes.js +19 -2
- package/es/components/Table/TableToolbar/TableToolbar.js +2 -1
- package/es/components/TimePickerSpinner/TimePickerSpinner.js +86 -20
- package/es/constants/CardPropTypes.js +22 -4
- package/es/constants/KeyCodeConstants.js +17 -14
- package/es/index.js +2 -0
- package/es/utils/cardUtilityFunctions.js +2 -2
- package/lib/components/Card/Card.js +44 -6
- package/lib/components/Card/CardRangePicker.js +14 -3
- package/lib/components/Card/CardToolbar.js +1 -2
- package/lib/components/ComboBox/ComboBox.js +2 -1
- package/lib/components/DateTimePicker/DateTimePicker.js +68 -92
- package/lib/components/DateTimePicker/DateTimePickerV2.js +58 -95
- package/lib/components/DateTimePicker/dateTimePickerUtils.js +133 -0
- package/lib/components/Header/HeaderAction/HeaderAction.js +1 -1
- package/lib/components/Header/HeaderActionGroup.js +4 -2
- package/lib/components/ImageCard/ImageCard.js +2 -2
- package/lib/components/ImageCard/ImageHotspots.js +2 -1
- package/lib/components/List/HierarchyList/HierarchyList.js +72 -15
- package/lib/components/List/List.js +55 -120
- package/lib/components/List/ListContent/ListContent.js +519 -0
- package/lib/components/List/ListItem/ListItem.js +14 -2
- package/lib/components/List/VirtualListContent/VirtualListContent.js +695 -0
- package/lib/components/PieChartCard/PieChartCard.js +4 -2
- package/lib/components/Table/Table.js +49 -44
- package/lib/components/Table/TableFoot/TableFoot.js +21 -9
- package/lib/components/Table/TableHead/ColumnGrouping/ColumnGrouping.js +175 -0
- package/lib/components/Table/TableHead/TableHead.js +60 -30
- package/lib/components/Table/TableHead/TableHeader.js +47 -7
- package/lib/components/Table/TablePropTypes.js +20 -1
- package/lib/components/Table/TableToolbar/TableToolbar.js +2 -1
- package/lib/components/TimePickerSpinner/TimePickerSpinner.js +86 -19
- package/lib/constants/CardPropTypes.js +22 -4
- package/lib/constants/KeyCodeConstants.js +17 -14
- package/lib/css/carbon-addons-iot-react.css +5374 -5566
- package/lib/css/carbon-addons-iot-react.css.map +1 -1
- package/lib/index.js +4 -0
- package/lib/scss/components/DateTimePicker/_date-time-picker.scss +1 -1
- package/lib/scss/components/DateTimePicker/_date-time-pickerv2.scss +1 -1
- package/lib/scss/components/List/ListItem/_list-item.scss +1 -0
- package/lib/scss/components/Table/TableHead/ColumnGrouping/_column-grouping.scss +250 -0
- package/lib/scss/components/Table/TableHead/_table-head.scss +1 -0
- package/lib/scss/components/Table/_table.scss +4 -0
- package/lib/scss/components/TimePickerSpinner/_time-picker-spinner.scss +10 -0
- package/lib/scss/components/ValueCard/_attribute.scss +5 -0
- package/lib/scss/components/ValueCard/_value-renderer.scss +6 -1
- package/lib/utils/cardUtilityFunctions.js +2 -2
- package/package.json +11 -10
- package/scss/components/DateTimePicker/_date-time-picker.scss +1 -1
- package/scss/components/DateTimePicker/_date-time-pickerv2.scss +1 -1
- package/scss/components/List/ListItem/_list-item.scss +1 -0
- package/scss/components/Table/TableHead/ColumnGrouping/_column-grouping.scss +250 -0
- package/scss/components/Table/TableHead/_table-head.scss +1 -0
- package/scss/components/Table/_table.scss +4 -0
- package/scss/components/TimePickerSpinner/_time-picker-spinner.scss +10 -0
- package/scss/components/ValueCard/_attribute.scss +5 -0
- package/scss/components/ValueCard/_value-renderer.scss +6 -1
- package/umd/carbon-addons-iot-react.js +13477 -6841
|
@@ -4,6 +4,7 @@ import 'core-js/modules/es.array.filter.js';
|
|
|
4
4
|
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
5
5
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
6
6
|
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
7
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
8
|
import _extends from '@babel/runtime/helpers/extends';
|
|
8
9
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
9
10
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
@@ -14,7 +15,7 @@ import 'core-js/modules/es.array.find.js';
|
|
|
14
15
|
import 'core-js/modules/es.object.values.js';
|
|
15
16
|
import 'core-js/modules/es.array.concat.js';
|
|
16
17
|
import 'core-js/modules/es.array.slice.js';
|
|
17
|
-
import React__default, { useEffect, useMemo, useCallback, useRef } from 'react';
|
|
18
|
+
import React__default, { useEffect, useMemo, useState, useCallback, useRef } from 'react';
|
|
18
19
|
import VisibilitySensor from 'react-visibility-sensor';
|
|
19
20
|
import { Tooltip, SkeletonText } from 'carbon-components-react';
|
|
20
21
|
import withSize from 'react-sizeme';
|
|
@@ -27,6 +28,7 @@ import { CardPropTypes } from '../../constants/CardPropTypes.js';
|
|
|
27
28
|
import { getCardMinSize, filterValidAttributes } from '../../utils/componentUtilityFunctions.js';
|
|
28
29
|
import { getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
|
|
29
30
|
import useHasTextOverflow from '../../hooks/useHasTextOverflow.js';
|
|
31
|
+
import { parseValue } from '../DateTimePicker/dateTimePickerUtils.js';
|
|
30
32
|
import CardToolbar from './CardToolbar.js';
|
|
31
33
|
|
|
32
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -247,7 +249,8 @@ var defaultProps = {
|
|
|
247
249
|
deleteCardLabel: 'Delete card',
|
|
248
250
|
closeLabel: 'Close',
|
|
249
251
|
expandLabel: 'Expand to fullscreen',
|
|
250
|
-
overflowMenuDescription: 'Open and close list of options'
|
|
252
|
+
overflowMenuDescription: 'Open and close list of options',
|
|
253
|
+
toLabel: 'to'
|
|
251
254
|
},
|
|
252
255
|
onMouseDown: undefined,
|
|
253
256
|
onMouseUp: undefined,
|
|
@@ -267,7 +270,7 @@ var Card = function Card(props) {
|
|
|
267
270
|
var size = props.size,
|
|
268
271
|
children = props.children,
|
|
269
272
|
title = props.title,
|
|
270
|
-
|
|
273
|
+
subtitleProp = props.subtitle,
|
|
271
274
|
hasTitleWrap = props.hasTitleWrap;
|
|
272
275
|
props.layout;
|
|
273
276
|
var isLoading = props.isLoading,
|
|
@@ -317,16 +320,50 @@ var Card = function Card(props) {
|
|
|
317
320
|
}));
|
|
318
321
|
|
|
319
322
|
var strings = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
|
|
320
|
-
/** adds the id to the card action */
|
|
321
323
|
|
|
324
|
+
var getTheSubtitle = useMemo(function () {
|
|
325
|
+
if (subtitleProp) {
|
|
326
|
+
return subtitleProp;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (mergedAvailableActions.range === 'full' || mergedAvailableActions.range === 'iconOnly') {
|
|
330
|
+
var _parseValue = parseValue(timeRange, dateTimeMask, strings.toLabel),
|
|
331
|
+
readableValue = _parseValue.readableValue;
|
|
332
|
+
|
|
333
|
+
return readableValue;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
return undefined;
|
|
337
|
+
}, [dateTimeMask, mergedAvailableActions.range, strings.toLabel, subtitleProp, timeRange]);
|
|
338
|
+
|
|
339
|
+
var _useState = useState(getTheSubtitle),
|
|
340
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
341
|
+
subtitle = _useState2[0],
|
|
342
|
+
setSubtitle = _useState2[1];
|
|
343
|
+
|
|
344
|
+
useEffect(function () {
|
|
345
|
+
setSubtitle(getTheSubtitle);
|
|
346
|
+
}, [getTheSubtitle, subtitleProp]);
|
|
347
|
+
/** adds the id to the card action */
|
|
322
348
|
|
|
323
349
|
var cachedOnCardAction = useCallback(function () {
|
|
324
350
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
325
351
|
args[_key] = arguments[_key];
|
|
326
352
|
}
|
|
327
353
|
|
|
328
|
-
|
|
329
|
-
|
|
354
|
+
var action = args[0],
|
|
355
|
+
value = args[1];
|
|
356
|
+
|
|
357
|
+
if (action === 'CHANGE_TIME_RANGE' && !subtitleProp) {
|
|
358
|
+
if (value.timeRangeKind === 'PRESET') {
|
|
359
|
+
setSubtitle(value.timeRangeValue.tooltipValue);
|
|
360
|
+
} else if (!value.range) {
|
|
361
|
+
setSubtitle(value.timeRangeValue.humanValue);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
onCardAction.apply(void 0, [id].concat(args));
|
|
366
|
+
}, [subtitleProp, onCardAction, id]);
|
|
330
367
|
|
|
331
368
|
var getChildSize = function getChildSize(cardSize, cardTitle) {
|
|
332
369
|
var childSize = _objectSpread(_objectSpread({}, cardSize), {}, {
|
|
@@ -604,7 +641,7 @@ Card.__docgenInfo = {
|
|
|
604
641
|
},
|
|
605
642
|
"i18n": {
|
|
606
643
|
"defaultValue": {
|
|
607
|
-
"value": "{\n noDataLabel: 'No data is available for this time range.',\n noDataShortLabel: 'No data',\n errorLoadingDataLabel: 'Error loading data for this card: ',\n errorLoadingDataShortLabel: 'Data error.',\n timeRangeLabel: 'Time range',\n rollingPeriodLabel: 'Rolling period',\n defaultLabel: 'Default',\n last24HoursLabel: 'Last 24 hrs',\n last7DaysLabel: 'Last 7 days',\n lastMonthLabel: 'Last month',\n lastQuarterLabel: 'Last quarter',\n lastYearLabel: 'Last year',\n periodToDateLabel: 'Period to date',\n thisWeekLabel: 'This week',\n thisMonthLabel: 'This month',\n thisQuarterLabel: 'This quarter',\n thisYearLabel: 'This year',\n selectTimeRangeLabel: 'Select time range',\n hourlyLabel: 'Hourly',\n dailyLabel: 'Daily',\n weeklyLabel: 'Weekly',\n monthlyLabel: 'Monthly',\n editCardLabel: 'Edit card',\n cloneCardLabel: 'Clone card',\n deleteCardLabel: 'Delete card',\n closeLabel: 'Close',\n expandLabel: 'Expand to fullscreen',\n overflowMenuDescription: 'Open and close list of options',\n}",
|
|
644
|
+
"value": "{\n noDataLabel: 'No data is available for this time range.',\n noDataShortLabel: 'No data',\n errorLoadingDataLabel: 'Error loading data for this card: ',\n errorLoadingDataShortLabel: 'Data error.',\n timeRangeLabel: 'Time range',\n rollingPeriodLabel: 'Rolling period',\n defaultLabel: 'Default',\n last24HoursLabel: 'Last 24 hrs',\n last7DaysLabel: 'Last 7 days',\n lastMonthLabel: 'Last month',\n lastQuarterLabel: 'Last quarter',\n lastYearLabel: 'Last year',\n periodToDateLabel: 'Period to date',\n thisWeekLabel: 'This week',\n thisMonthLabel: 'This month',\n thisQuarterLabel: 'This quarter',\n thisYearLabel: 'This year',\n selectTimeRangeLabel: 'Select time range',\n hourlyLabel: 'Hourly',\n dailyLabel: 'Daily',\n weeklyLabel: 'Weekly',\n monthlyLabel: 'Monthly',\n editCardLabel: 'Edit card',\n cloneCardLabel: 'Clone card',\n deleteCardLabel: 'Delete card',\n closeLabel: 'Close',\n expandLabel: 'Expand to fullscreen',\n overflowMenuDescription: 'Open and close list of options',\n toLabel: 'to',\n}",
|
|
608
645
|
"computed": false
|
|
609
646
|
},
|
|
610
647
|
"required": false
|
|
@@ -5,7 +5,7 @@ import 'core-js/modules/es.array.filter.js';
|
|
|
5
5
|
import 'core-js/modules/es.object.keys.js';
|
|
6
6
|
import 'core-js/modules/es.array.includes.js';
|
|
7
7
|
import 'core-js/modules/es.string.includes.js';
|
|
8
|
-
import React__default, { useState, useCallback } from 'react';
|
|
8
|
+
import React__default, { useState, useCallback, useEffect } from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import { EventSchedule16 } from '@carbon/icons-react';
|
|
11
11
|
import { ToolbarItem, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
|
@@ -58,12 +58,23 @@ var CardRangePicker = function CardRangePicker(_ref) {
|
|
|
58
58
|
});
|
|
59
59
|
setTimeRange(value);
|
|
60
60
|
}, [setTimeRange, onCardAction]);
|
|
61
|
+
useEffect(function () {
|
|
62
|
+
setTimeRange(timeRangeProp);
|
|
63
|
+
}, [timeRangeProp]);
|
|
64
|
+
|
|
65
|
+
var getTimeRangeText = function getTimeRangeText(key) {
|
|
66
|
+
var _timeRangeOptions$key;
|
|
67
|
+
|
|
68
|
+
var defaultText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
69
|
+
return typeof timeRangeOptions[key] === 'string' ? timeRangeOptions[key] : ((_timeRangeOptions$key = timeRangeOptions[key]) === null || _timeRangeOptions$key === void 0 ? void 0 : _timeRangeOptions$key.label) || defaultText;
|
|
70
|
+
};
|
|
71
|
+
|
|
61
72
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
62
73
|
className: "".concat(iotPrefix, "--card--toolbar-date-range-wrapper")
|
|
63
74
|
}, /*#__PURE__*/React__default.createElement(ToolbarItem, null, /*#__PURE__*/React__default.createElement("div", {
|
|
64
75
|
id: "timeRange",
|
|
65
76
|
className: classnames("".concat(iotPrefix, "--card--toolbar-timerange-label"), _defineProperty({}, "".concat(iotPrefix, "--card--toolbar-timerange-label--hidden"), cardWidth < 400))
|
|
66
|
-
},
|
|
77
|
+
}, getTimeRangeText(timeRange, i18n.defaultLabel)), /*#__PURE__*/React__default.createElement(OverflowMenu, {
|
|
67
78
|
className: classnames("".concat(iotPrefix, "--card--toolbar-date-range-action")),
|
|
68
79
|
flipped: true,
|
|
69
80
|
title: i18n.selectTimeRangeLabel,
|
|
@@ -87,7 +98,7 @@ var CardRangePicker = function CardRangePicker(_ref) {
|
|
|
87
98
|
onClick: function onClick() {
|
|
88
99
|
return handleTimeRange(i);
|
|
89
100
|
},
|
|
90
|
-
itemText:
|
|
101
|
+
itemText: getTimeRangeText(i),
|
|
91
102
|
className: classnames(_defineProperty({}, "".concat(iotPrefix, "--card--overflow-menuitem-active"), timeRange === i))
|
|
92
103
|
});
|
|
93
104
|
}), Object.keys(timeRangeOptions).filter(function (i) {
|
|
@@ -99,7 +110,7 @@ var CardRangePicker = function CardRangePicker(_ref) {
|
|
|
99
110
|
onClick: function onClick() {
|
|
100
111
|
return handleTimeRange(i);
|
|
101
112
|
},
|
|
102
|
-
itemText:
|
|
113
|
+
itemText: getTimeRangeText(i),
|
|
103
114
|
className: classnames(_defineProperty({}, "".concat(iotPrefix, "--card--overflow-menuitem-active"), timeRange === i))
|
|
104
115
|
});
|
|
105
116
|
}))));
|
|
@@ -17,7 +17,7 @@ import { OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
|
|
17
17
|
import classnames from 'classnames';
|
|
18
18
|
import keyBy from 'lodash/keyBy';
|
|
19
19
|
import { settings } from '../../constants/Settings.js';
|
|
20
|
-
import { TimeRangeOptionsPropTypes
|
|
20
|
+
import { TimeRangeOptionsPropTypes } from '../../constants/CardPropTypes.js';
|
|
21
21
|
import { CARD_ACTIONS } from '../../constants/LayoutConstants.js';
|
|
22
22
|
import DateTimePicker, { DateTimePickerDefaultValuePropTypes } from '../DateTimePicker/DateTimePickerV2.js';
|
|
23
23
|
import Button from '../Button/Button.js';
|
|
@@ -196,8 +196,7 @@ var CardToolbar = function CardToolbar(_ref) {
|
|
|
196
196
|
i18n: mergedI18n,
|
|
197
197
|
dateTimeMask: dateTimeMask,
|
|
198
198
|
locale: locale,
|
|
199
|
-
hasIconOnly:
|
|
200
|
-
width > 0 && width < 320 || availableActions.range === DATE_PICKER_OPTIONS.ICON_ONLY,
|
|
199
|
+
hasIconOnly: true,
|
|
201
200
|
presets: Object.entries(timeRangeOptions).reduce(function (acc, _ref2) {
|
|
202
201
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
203
202
|
timeRangeOptionKey = _ref3[0],
|
|
@@ -27,6 +27,7 @@ import { ComboBox as ComboBox$1, Tag } from 'carbon-components-react';
|
|
|
27
27
|
import pick from 'lodash/pick';
|
|
28
28
|
import { settings } from '../../constants/Settings.js';
|
|
29
29
|
import { filterValidAttributes } from '../../utils/componentUtilityFunctions.js';
|
|
30
|
+
import { keyboardKeys } from '../../constants/KeyCodeConstants.js';
|
|
30
31
|
|
|
31
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
32
33
|
|
|
@@ -205,7 +206,7 @@ var ComboBox = function ComboBox(_ref) {
|
|
|
205
206
|
// Current value of input
|
|
206
207
|
var currentValue = comboRef.current.value.trim();
|
|
207
208
|
|
|
208
|
-
if (evt.key ===
|
|
209
|
+
if (evt.key === keyboardKeys.ENTER && currentValue) {
|
|
209
210
|
var newItem = {
|
|
210
211
|
id: "".concat(iotPrefix, "-input-").concat(currentValue.split(' ').join('-'), "-").concat(currentValue.length),
|
|
211
212
|
text: currentValue
|
|
@@ -8,15 +8,13 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
8
8
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
9
9
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
10
10
|
import 'core-js/modules/es.array.concat.js';
|
|
11
|
-
import 'core-js/modules/es.number.constructor.js';
|
|
12
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
13
|
-
import 'core-js/modules/es.string.split.js';
|
|
14
11
|
import 'core-js/modules/es.array.filter.js';
|
|
15
12
|
import 'core-js/modules/es.array.from.js';
|
|
16
13
|
import 'core-js/modules/es.string.iterator.js';
|
|
17
14
|
import 'core-js/modules/es.array.find-index.js';
|
|
18
15
|
import 'core-js/modules/es.array.includes.js';
|
|
19
16
|
import 'core-js/modules/es.string.includes.js';
|
|
17
|
+
import 'core-js/modules/es.number.constructor.js';
|
|
20
18
|
import 'core-js/modules/es.array.map.js';
|
|
21
19
|
import React__default, { useEffect, useState, useRef, useCallback } from 'react';
|
|
22
20
|
import PropTypes from 'prop-types';
|
|
@@ -29,6 +27,7 @@ import { settings } from '../../constants/Settings.js';
|
|
|
29
27
|
import dayjs from '../../utils/dayjs.js';
|
|
30
28
|
import { handleSpecificKeyDown } from '../../utils/componentUtilityFunctions.js';
|
|
31
29
|
import { Tooltip } from '../Tooltip/index.js';
|
|
30
|
+
import { parseValue } from './dateTimePickerUtils.js';
|
|
32
31
|
|
|
33
32
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
34
33
|
|
|
@@ -96,6 +95,12 @@ var propTypes = {
|
|
|
96
95
|
timeRangeValue: PropTypes.exact({
|
|
97
96
|
startDate: PropTypes.string.isRequired,
|
|
98
97
|
startTime: PropTypes.string.isRequired,
|
|
98
|
+
|
|
99
|
+
/** Can be a full parseable DateTime string or a Date object */
|
|
100
|
+
start: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
101
|
+
|
|
102
|
+
/** Can be a full parseable DateTime string or a Date object */
|
|
103
|
+
end: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]),
|
|
99
104
|
endDate: PropTypes.string.isRequired,
|
|
100
105
|
endTime: PropTypes.string.isRequired
|
|
101
106
|
}).isRequired
|
|
@@ -340,13 +345,28 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
340
345
|
var _useState23 = useState(false),
|
|
341
346
|
_useState24 = _slicedToArray(_useState23, 2),
|
|
342
347
|
relativeLastNumberInvalid = _useState24[0],
|
|
343
|
-
setRelativeLastNumberInvalid = _useState24[1];
|
|
348
|
+
setRelativeLastNumberInvalid = _useState24[1];
|
|
344
349
|
|
|
345
|
-
|
|
346
|
-
var _useState25 = useState(null),
|
|
350
|
+
var _useState25 = useState(false),
|
|
347
351
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
348
|
-
|
|
349
|
-
|
|
352
|
+
relativeToTimeInvalid = _useState26[0],
|
|
353
|
+
setRelativeToTimeInvalid = _useState26[1];
|
|
354
|
+
|
|
355
|
+
var _useState27 = useState(false),
|
|
356
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
357
|
+
absoluteStartTimeInvalid = _useState28[0],
|
|
358
|
+
setAbsoluteStartTimeInvalid = _useState28[1];
|
|
359
|
+
|
|
360
|
+
var _useState29 = useState(false),
|
|
361
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
362
|
+
absoluteEndTimeInvalid = _useState30[0],
|
|
363
|
+
setAbsoluteEndTimeInvalid = _useState30[1]; // Refs
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
var _useState31 = useState(null),
|
|
367
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
368
|
+
datePickerElem = _useState32[0],
|
|
369
|
+
setDatePickerElem = _useState32[1];
|
|
350
370
|
|
|
351
371
|
var relativeSelect = useRef(null);
|
|
352
372
|
var presetListRef = useRef(null);
|
|
@@ -411,84 +431,6 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
411
431
|
clearTimeout(timeout);
|
|
412
432
|
};
|
|
413
433
|
}, [datePickerElem, id]);
|
|
414
|
-
/**
|
|
415
|
-
* Parses a value object into a human readable value
|
|
416
|
-
* @param {Object} value - the currently selected value
|
|
417
|
-
* @param {string} value.kind - preset/relative/absolute
|
|
418
|
-
* @param {Object} value.preset - the preset selection
|
|
419
|
-
* @param {Object} value.relative - the relative time selection
|
|
420
|
-
* @param {Object} value.absolute - the absolute time selection
|
|
421
|
-
* @returns {Object} a human readable value and a furtherly augmented value object
|
|
422
|
-
*/
|
|
423
|
-
|
|
424
|
-
var parseValue = function parseValue(value) {
|
|
425
|
-
setCurrentValue(value);
|
|
426
|
-
var readableValue = '';
|
|
427
|
-
|
|
428
|
-
var returnValue = _objectSpread({}, value);
|
|
429
|
-
|
|
430
|
-
switch (value.kind) {
|
|
431
|
-
case PICKER_KINDS.RELATIVE:
|
|
432
|
-
{
|
|
433
|
-
var endDate = dayjs();
|
|
434
|
-
|
|
435
|
-
if (value.relative.relativeToWhen !== '') {
|
|
436
|
-
endDate = value.relative.relativeToWhen === RELATIVE_VALUES.YESTERDAY ? dayjs().add(-1, INTERVAL_VALUES.DAYS) : dayjs(); // wait to parse it until fully typed
|
|
437
|
-
|
|
438
|
-
if (value.relative.relativeToTime.length === 5) {
|
|
439
|
-
endDate = endDate.hour(Number(value.relative.relativeToTime.split(':')[0]));
|
|
440
|
-
endDate = endDate.minute(Number(value.relative.relativeToTime.split(':')[1]));
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
var startDate = endDate.clone().subtract(value.relative.lastNumber, value.relative.lastInterval ? value.relative.lastInterval : INTERVAL_VALUES.MINUTES);
|
|
444
|
-
returnValue.relative.start = new Date(startDate.valueOf());
|
|
445
|
-
returnValue.relative.end = new Date(endDate.valueOf());
|
|
446
|
-
readableValue = "".concat(dayjs(startDate).format(dateTimeMask), " ").concat(strings.toLabel, " ").concat(dayjs(endDate).format(dateTimeMask));
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
case PICKER_KINDS.ABSOLUTE:
|
|
453
|
-
{
|
|
454
|
-
var _startDate = dayjs(value.absolute.start); // wait to parse it until fully typed
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (value.absolute.startTime && value.absolute.startTime.length === 5) {
|
|
458
|
-
_startDate = _startDate.hours(value.absolute.startTime.split(':')[0]);
|
|
459
|
-
_startDate = _startDate.minutes(value.absolute.startTime.split(':')[1]);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
returnValue.absolute.start = new Date(_startDate.valueOf());
|
|
463
|
-
|
|
464
|
-
if (value.absolute.end) {
|
|
465
|
-
var _endDate = dayjs(value.absolute.end); // wait to parse it until fully typed
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (value.absolute.endTime && value.absolute.endTime.length === 5) {
|
|
469
|
-
_endDate = _endDate.hours(value.absolute.endTime.split(':')[0]);
|
|
470
|
-
_endDate = _endDate.minutes(value.absolute.endTime.split(':')[1]);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
returnValue.absolute.end = new Date(_endDate.valueOf());
|
|
474
|
-
readableValue = "".concat(dayjs(_startDate).format(dateTimeMask), " ").concat(strings.toLabel, " ").concat(dayjs(_endDate).format(dateTimeMask));
|
|
475
|
-
} else {
|
|
476
|
-
readableValue = "".concat(dayjs(_startDate).format(dateTimeMask), " ").concat(strings.toLabel, " ").concat(dayjs(_startDate).format(dateTimeMask));
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
break;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
default:
|
|
483
|
-
readableValue = value.preset.label;
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
setHumanValue(readableValue);
|
|
488
|
-
return _objectSpread({
|
|
489
|
-
readableValue: readableValue
|
|
490
|
-
}, returnValue);
|
|
491
|
-
};
|
|
492
434
|
/**
|
|
493
435
|
* Transforms a default or selected value into a full blown returnable object
|
|
494
436
|
* @param {Object} [preset] clicked preset
|
|
@@ -497,7 +439,6 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
497
439
|
* @returns {Object} the augmented value itself and the human readable value
|
|
498
440
|
*/
|
|
499
441
|
|
|
500
|
-
|
|
501
442
|
var renderValue = function renderValue() {
|
|
502
443
|
var clickedPreset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
503
444
|
|
|
@@ -527,7 +468,10 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
527
468
|
value.kind = PICKER_KINDS.PRESET;
|
|
528
469
|
}
|
|
529
470
|
|
|
530
|
-
|
|
471
|
+
setCurrentValue(value);
|
|
472
|
+
var parsedValue = parseValue(value, dateTimeMask, strings.toLabel);
|
|
473
|
+
setHumanValue(parsedValue.readableValue);
|
|
474
|
+
return _objectSpread(_objectSpread({}, value), parsedValue);
|
|
531
475
|
};
|
|
532
476
|
|
|
533
477
|
useEffect(function () {
|
|
@@ -874,7 +818,8 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
874
818
|
changeRelativePropertyValue('relativeToWhen', event.currentTarget.value);
|
|
875
819
|
};
|
|
876
820
|
|
|
877
|
-
var onRelativeToTimeChange = function onRelativeToTimeChange(pickerValue) {
|
|
821
|
+
var onRelativeToTimeChange = function onRelativeToTimeChange(pickerValue, evt, meta) {
|
|
822
|
+
setRelativeToTimeInvalid(meta.invalid);
|
|
878
823
|
changeRelativePropertyValue('relativeToTime', pickerValue);
|
|
879
824
|
}; // Util func to update the absolute value
|
|
880
825
|
|
|
@@ -887,15 +832,20 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
887
832
|
}; // on change functions that trigger a absolute value update
|
|
888
833
|
|
|
889
834
|
|
|
890
|
-
var onAbsoluteStartTimeChange = function onAbsoluteStartTimeChange(pickerValue) {
|
|
835
|
+
var onAbsoluteStartTimeChange = function onAbsoluteStartTimeChange(pickerValue, evt, meta) {
|
|
836
|
+
setAbsoluteStartTimeInvalid(meta.invalid);
|
|
891
837
|
changeAbsolutePropertyValue('startTime', pickerValue);
|
|
892
838
|
};
|
|
893
839
|
|
|
894
|
-
var onAbsoluteEndTimeChange = function onAbsoluteEndTimeChange(pickerValue) {
|
|
840
|
+
var onAbsoluteEndTimeChange = function onAbsoluteEndTimeChange(pickerValue, evt, meta) {
|
|
841
|
+
setAbsoluteEndTimeInvalid(meta.invalid);
|
|
895
842
|
changeAbsolutePropertyValue('endTime', pickerValue);
|
|
896
843
|
};
|
|
897
844
|
|
|
898
845
|
var tooltipValue = renderPresetTooltipText ? renderPresetTooltipText(currentValue) : getIntervalValue();
|
|
846
|
+
var disableRelativeApply = isCustomRange && customRangeKind === PICKER_KINDS.RELATIVE && (relativeLastNumberInvalid || relativeToTimeInvalid);
|
|
847
|
+
var disableAbsoluteApply = isCustomRange && customRangeKind === PICKER_KINDS.ABSOLUTE && (absoluteStartTimeInvalid || absoluteEndTimeInvalid);
|
|
848
|
+
var disableApply = disableRelativeApply || disableAbsoluteApply;
|
|
899
849
|
/**
|
|
900
850
|
* Shows and hides the tooltip with the humanValue (Relative) or full-range (Absolute) when
|
|
901
851
|
* the user focuses or hovers on the input
|
|
@@ -1056,7 +1006,9 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
1056
1006
|
})[0] || relative.label
|
|
1057
1007
|
});
|
|
1058
1008
|
})), hasTimeInput ? /*#__PURE__*/React__default.createElement(TimePickerSpinner, {
|
|
1009
|
+
key: "".concat(id, "-relative-to-time"),
|
|
1059
1010
|
id: "".concat(id, "-relative-to-time"),
|
|
1011
|
+
invalid: relativeToTimeInvalid,
|
|
1060
1012
|
value: relativeValue ? relativeValue.relativeToTime : '',
|
|
1061
1013
|
i18n: i18n,
|
|
1062
1014
|
light: true,
|
|
@@ -1090,6 +1042,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
1090
1042
|
className: "".concat(iotPrefix, "--date-time-picker__fields-wrapper")
|
|
1091
1043
|
}, /*#__PURE__*/React__default.createElement(TimePickerSpinner, {
|
|
1092
1044
|
id: "".concat(id, "-start-time"),
|
|
1045
|
+
invalid: absoluteStartTimeInvalid,
|
|
1093
1046
|
labelText: strings.startTimeLabel,
|
|
1094
1047
|
value: absoluteValue ? absoluteValue.startTime : '00:00',
|
|
1095
1048
|
i18n: i18n,
|
|
@@ -1099,6 +1052,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
1099
1052
|
autoComplete: "off"
|
|
1100
1053
|
}), /*#__PURE__*/React__default.createElement(TimePickerSpinner, {
|
|
1101
1054
|
id: "".concat(id, "-end-time"),
|
|
1055
|
+
invalid: absoluteEndTimeInvalid,
|
|
1102
1056
|
labelText: strings.endTimeLabel,
|
|
1103
1057
|
value: absoluteValue ? absoluteValue.endTime : '00:00',
|
|
1104
1058
|
i18n: i18n,
|
|
@@ -1137,7 +1091,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
|
|
|
1137
1091
|
,
|
|
1138
1092
|
onKeyUp: handleSpecificKeyDown(['Enter', ' '], onApplyClick),
|
|
1139
1093
|
size: "field",
|
|
1140
|
-
disabled:
|
|
1094
|
+
disabled: disableApply
|
|
1141
1095
|
}), strings.applyBtnLabel)))))
|
|
1142
1096
|
);
|
|
1143
1097
|
};
|
|
@@ -1264,6 +1218,28 @@ DateTimePicker.__docgenInfo = {
|
|
|
1264
1218
|
"name": "string",
|
|
1265
1219
|
"required": true
|
|
1266
1220
|
},
|
|
1221
|
+
"start": {
|
|
1222
|
+
"name": "union",
|
|
1223
|
+
"value": [{
|
|
1224
|
+
"name": "string"
|
|
1225
|
+
}, {
|
|
1226
|
+
"name": "instanceOf",
|
|
1227
|
+
"value": "Date"
|
|
1228
|
+
}],
|
|
1229
|
+
"description": "Can be a full parseable DateTime string or a Date object",
|
|
1230
|
+
"required": false
|
|
1231
|
+
},
|
|
1232
|
+
"end": {
|
|
1233
|
+
"name": "union",
|
|
1234
|
+
"value": [{
|
|
1235
|
+
"name": "string"
|
|
1236
|
+
}, {
|
|
1237
|
+
"name": "instanceOf",
|
|
1238
|
+
"value": "Date"
|
|
1239
|
+
}],
|
|
1240
|
+
"description": "Can be a full parseable DateTime string or a Date object",
|
|
1241
|
+
"required": false
|
|
1242
|
+
},
|
|
1267
1243
|
"endDate": {
|
|
1268
1244
|
"name": "string",
|
|
1269
1245
|
"required": true
|