carbon-addons-iot-react 2.152.0-next.13 → 2.152.0-next.14

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 (33) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/css/carbon-addons-iot-react.css +8 -3
  3. package/css/carbon-addons-iot-react.css.map +1 -1
  4. package/es/components/Card/CardTitle.js +8 -2
  5. package/es/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +3 -3
  6. package/es/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +3 -3
  7. package/es/components/Table/Table.js +7 -17
  8. package/es/components/Table/TableBody/TableBody.js +5 -16
  9. package/es/components/Table/TableBody/TableBodyRow/TableBodyRow.js +9 -20
  10. package/es/components/Table/TableBody/TableBodyRowRenderer.js +5 -16
  11. package/es/components/Table/TableCellRenderer/TableCellRenderer.js +6 -17
  12. package/es/components/Table/TableHead/TableHead.js +4 -15
  13. package/es/constants/SharedPropTypes.js +2 -1
  14. package/es/hooks/usePopoverPositioning.js +53 -11
  15. package/lib/components/Card/CardTitle.js +8 -2
  16. package/lib/components/DateTimePicker/DateTimePickerV2WithTimeSpinner.js +3 -3
  17. package/lib/components/DateTimePicker/DateTimePickerV2WithoutTimeSpinner.js +3 -3
  18. package/lib/components/Table/Table.js +7 -17
  19. package/lib/components/Table/TableBody/TableBody.js +5 -16
  20. package/lib/components/Table/TableBody/TableBodyRow/TableBodyRow.js +9 -20
  21. package/lib/components/Table/TableBody/TableBodyRowRenderer.js +5 -16
  22. package/lib/components/Table/TableCellRenderer/TableCellRenderer.js +6 -17
  23. package/lib/components/Table/TableHead/TableHead.js +4 -15
  24. package/lib/constants/SharedPropTypes.js +2 -0
  25. package/lib/css/carbon-addons-iot-react.css +8 -3
  26. package/lib/css/carbon-addons-iot-react.css.map +1 -1
  27. package/lib/hooks/usePopoverPositioning.js +53 -11
  28. package/lib/scss/components/DateTimePicker/_date-time-pickerv2.scss +4 -4
  29. package/lib/scss/components/Table/_table.scss +5 -0
  30. package/package.json +4 -3
  31. package/scss/components/DateTimePicker/_date-time-pickerv2.scss +4 -4
  32. package/scss/components/Table/_table.scss +5 -0
  33. package/umd/carbon-addons-iot-react.js +98 -120
@@ -71,6 +71,7 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
71
71
 
72
72
  var _usePopoverPositionin = usePopoverPositioning({
73
73
  direction: 'bottom',
74
+ defaultAlignment: 'center',
74
75
  menuOffset: getTooltipMenuOffset,
75
76
  useAutoPositioning: true,
76
77
  isOverflowMenu: true // Needed to preserve default direction (bottom)
@@ -78,7 +79,9 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
78
79
  }),
79
80
  _usePopoverPositionin2 = _slicedToArray(_usePopoverPositionin, 2),
80
81
  calculateMenuOffset = _usePopoverPositionin2[0],
81
- adjustedDirection = _usePopoverPositionin2[1].adjustedDirection;
82
+ _usePopoverPositionin3 = _usePopoverPositionin2[1],
83
+ adjustedDirection = _usePopoverPositionin3.adjustedDirection,
84
+ adjustedAlignment = _usePopoverPositionin3.adjustedAlignment;
82
85
 
83
86
  var _useState = useState({
84
87
  title: false,
@@ -154,7 +157,7 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
154
157
  var _classnames;
155
158
 
156
159
  return hasTitleTooltipFromTruncation || hasExternalTitleTextTooltip ? /*#__PURE__*/React__default.createElement(Tooltip, {
157
- align: "center",
160
+ align: adjustedAlignment,
158
161
  menuOffset: calculateMenuOffset,
159
162
  direction: adjustedDirection,
160
163
  "data-testid": "".concat(testId, "-title-tooltip"),
@@ -179,6 +182,9 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
179
182
 
180
183
  var renderSubTitle = function renderSubTitle() {
181
184
  return !subtitle ? null : hasSubTitleTooltip ? /*#__PURE__*/React__default.createElement(Tooltip, {
185
+ align: adjustedAlignment,
186
+ menuOffset: calculateMenuOffset,
187
+ direction: adjustedDirection,
182
188
  "data-testid": "".concat(testId, "-subtitle"),
183
189
  ref: subTitleRef,
184
190
  showIcon: false,
@@ -272,7 +272,7 @@ var defaultProps = {
272
272
  };
273
273
 
274
274
  var DateTimePicker = function DateTimePicker(_ref) {
275
- var _classnames2, _classnames4, _style$zIndex;
275
+ var _classnames, _classnames2, _classnames4, _style$zIndex;
276
276
 
277
277
  var testId = _ref.testId,
278
278
  defaultValue = _ref.defaultValue,
@@ -847,7 +847,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
847
847
  }, /*#__PURE__*/React__default.createElement("div", {
848
848
  "data-testid": testId,
849
849
  id: "".concat(id, "-").concat(iotPrefix, "--date-time-pickerv2__wrapper"),
850
- className: classnames("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), _defineProperty({}, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled)),
850
+ className: classnames("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), (_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled), _defineProperty(_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--invalid"), invalidState), _classnames)),
851
851
  style: {
852
852
  '--wrapper-width': hasIconOnly ? '3rem' : '20rem'
853
853
  },
@@ -869,7 +869,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
869
869
  onMouseLeave: toggleTooltip,
870
870
  tabIndex: 0
871
871
  }, /*#__PURE__*/React__default.createElement("div", {
872
- className: classnames((_classnames2 = {}, _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _classnames2))
872
+ className: classnames((_classnames2 = {}, _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _classnames2))
873
873
  }, !hasIconOnly ? /*#__PURE__*/React__default.createElement("div", {
874
874
  "data-testid": "".concat(testId, "__field"),
875
875
  className: "".concat(iotPrefix, "--date-time-picker__field")
@@ -253,7 +253,7 @@ var defaultProps = {
253
253
  };
254
254
 
255
255
  var DateTimePicker = function DateTimePicker(_ref) {
256
- var _classnames2, _classnames4;
256
+ var _classnames, _classnames2, _classnames4;
257
257
 
258
258
  var testId = _ref.testId,
259
259
  defaultValue = _ref.defaultValue,
@@ -706,7 +706,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
706
706
  }, /*#__PURE__*/React__default.createElement("div", {
707
707
  "data-testid": testId,
708
708
  id: "".concat(id, "-").concat(iotPrefix, "--date-time-pickerv2__wrapper"),
709
- className: classnames("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), _defineProperty({}, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled)),
709
+ className: classnames("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), (_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled), _defineProperty(_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--invalid"), invalidState), _classnames)),
710
710
  style: {
711
711
  '--wrapper-width': hasIconOnly ? '3rem' : '20rem'
712
712
  },
@@ -728,7 +728,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
728
728
  onMouseLeave: toggleTooltip,
729
729
  tabIndex: 0
730
730
  }, /*#__PURE__*/React__default.createElement("div", {
731
- className: classnames((_classnames2 = {}, _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _classnames2))
731
+ className: classnames((_classnames2 = {}, _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _defineProperty(_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _classnames2))
732
732
  }, !hasIconOnly ? /*#__PURE__*/React__default.createElement("div", {
733
733
  "data-testid": "".concat(testId, "__field"),
734
734
  className: "".concat(iotPrefix, "--date-time-picker__field")
@@ -37,6 +37,7 @@ import { useLangDirection } from 'use-lang-direction';
37
37
  import warning from 'warning';
38
38
  import { defaultFunction } from '../../utils/componentUtilityFunctions.js';
39
39
  import { settings } from '../../constants/Settings.js';
40
+ import { WrapCellTextPropTypes } from '../../constants/SharedPropTypes.js';
40
41
  import FilterTags from '../FilterTags/FilterTags.js';
41
42
  import { RuleGroupPropType } from '../RuleBuilder/RuleBuilderPropTypes.js';
42
43
  import deprecate$1 from '../../internal/experimental.js';
@@ -158,8 +159,9 @@ var propTypes = {
158
159
  * always - Wrap if needed for all table column configurations
159
160
  * never - Tables with dynamic columns widths grow larger and tables with fixed or resizable columns truncate.
160
161
  * alwaysTruncate - Always truncate if needed for all table column configurations
162
+ * expand - Expand to fit text width (by horizontal scrollbar) for table with fixed columns
161
163
  */
162
- wrapCellText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']),
164
+ wrapCellText: WrapCellTextPropTypes,
163
165
 
164
166
  /** use white-space: pre; css when true */
165
167
  preserveCellWhiteSpace: PropTypes.bool
@@ -708,7 +710,7 @@ var Table = function Table(props) {
708
710
  forceUpdateCellTextWidth = _useState4[1];
709
711
 
710
712
  var useCellTextTruncate = useMemo(function () {
711
- return options ? options.wrapCellText === 'alwaysTruncate' || options.wrapCellText !== 'always' && (options.hasResize && !options.useAutoTableLayoutForResize || columns.some(function (col) {
713
+ return options ? options.wrapCellText === 'alwaysTruncate' || options.wrapCellText !== 'always' && options.wrapCellText !== 'expand' && (options.hasResize && !options.useAutoTableLayoutForResize || columns.some(function (col) {
712
714
  return col.hasOwnProperty('width');
713
715
  })) : undefined;
714
716
  }, [options, columns]);
@@ -1318,21 +1320,9 @@ Table.__docgenInfo = {
1318
1320
  "required": false
1319
1321
  },
1320
1322
  "wrapCellText": {
1321
- "name": "enum",
1322
- "value": [{
1323
- "value": "'always'",
1324
- "computed": false
1325
- }, {
1326
- "value": "'never'",
1327
- "computed": false
1328
- }, {
1329
- "value": "'auto'",
1330
- "computed": false
1331
- }, {
1332
- "value": "'alwaysTruncate'",
1333
- "computed": false
1334
- }],
1335
- "description": "auto - Wrap for tables with dynamic columns widths and truncate for tables with fixed or resizable columns\nalways - Wrap if needed for all table column configurations\nnever - Tables with dynamic columns widths grow larger and tables with fixed or resizable columns truncate.\nalwaysTruncate - Always truncate if needed for all table column configurations",
1323
+ "name": "custom",
1324
+ "raw": "WrapCellTextPropTypes",
1325
+ "description": "auto - Wrap for tables with dynamic columns widths and truncate for tables with fixed or resizable columns\nalways - Wrap if needed for all table column configurations\nnever - Tables with dynamic columns widths grow larger and tables with fixed or resizable columns truncate.\nalwaysTruncate - Always truncate if needed for all table column configurations\nexpand - Expand to fit text width (by horizontal scrollbar) for table with fixed columns",
1336
1326
  "required": false
1337
1327
  },
1338
1328
  "preserveCellWhiteSpace": {
@@ -22,6 +22,7 @@ import PropTypes from 'prop-types';
22
22
  import { TableBody as TableBody$1 } from 'carbon-components-react';
23
23
  import { TableRowsPropTypes, ExpandedRowsPropTypes, TableColumnsPropTypes, RowActionsStatePropTypes } from '../TablePropTypes.js';
24
24
  import deprecate from '../../../internal/deprecate.js';
25
+ import { WrapCellTextPropTypes } from '../../../constants/SharedPropTypes.js';
25
26
  import { tableTraverser, findRow } from '../tableUtilities.js';
26
27
  import TableBodyRowRenderer from './TableBodyRowRenderer.js';
27
28
 
@@ -74,7 +75,7 @@ var propTypes = {
74
75
  hasSingleNestedHierarchy: PropTypes.bool
75
76
  })]),
76
77
  hasRowActions: PropTypes.bool,
77
- wrapCellText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']).isRequired,
78
+ wrapCellText: WrapCellTextPropTypes.isRequired,
78
79
  truncateCellText: PropTypes.bool.isRequired,
79
80
 
80
81
  /** the current state of the row actions */
@@ -776,22 +777,10 @@ TableBody.__docgenInfo = {
776
777
  },
777
778
  "wrapCellText": {
778
779
  "type": {
779
- "name": "enum",
780
- "value": [{
781
- "value": "'always'",
782
- "computed": false
783
- }, {
784
- "value": "'never'",
785
- "computed": false
786
- }, {
787
- "value": "'auto'",
788
- "computed": false
789
- }, {
790
- "value": "'alwaysTruncate'",
791
- "computed": false
792
- }]
780
+ "name": "custom",
781
+ "raw": "WrapCellTextPropTypes.isRequired"
793
782
  },
794
- "required": true,
783
+ "required": false,
795
784
  "description": ""
796
785
  },
797
786
  "truncateCellText": {
@@ -12,6 +12,7 @@ import PropTypes from 'prop-types';
12
12
  import { TableCell, TableRow, Checkbox, RadioButton } from 'carbon-components-react';
13
13
  import classnames from 'classnames';
14
14
  import { settings } from '../../../../constants/Settings.js';
15
+ import { WrapCellTextPropTypes } from '../../../../constants/SharedPropTypes.js';
15
16
  import RowActionsCell from '../RowActionsCell/RowActionsCell.js';
16
17
  import TableCellRenderer from '../../TableCellRenderer/TableCellRenderer.js';
17
18
  import { TableColumnsPropTypes, RowActionPropTypes, RowActionErrorPropTypes } from '../../TablePropTypes.js';
@@ -63,7 +64,7 @@ var propTypes = {
63
64
  })]),
64
65
  hasRowActions: PropTypes.bool,
65
66
  shouldExpandOnRowClick: PropTypes.bool,
66
- wrapCellText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']).isRequired,
67
+ wrapCellText: WrapCellTextPropTypes.isRequired,
67
68
  truncateCellText: PropTypes.bool.isRequired,
68
69
 
69
70
  /** use white-space: pre; css when true */
@@ -185,7 +186,7 @@ var defaultProps = {
185
186
  };
186
187
 
187
188
  var TableBodyRow = function TableBodyRow(_ref) {
188
- var _classnames4, _classnames5, _classnames6;
189
+ var _classnames5, _classnames6, _classnames7;
189
190
 
190
191
  var id = _ref.id,
191
192
  tableId = _ref.tableId,
@@ -311,7 +312,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
311
312
  className: classnames("data-table-".concat(align), (_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell--truncate"), truncateCellText), _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell--sortable"), sortable), _classnames)),
312
313
  width: initialColumnWidth
313
314
  }, /*#__PURE__*/React__default.createElement("span", {
314
- className: "".concat(iotPrefix, "--table__cell__offset"),
315
+ className: classnames("".concat(iotPrefix, "--table__cell__offset"), _defineProperty({}, "".concat(iotPrefix, "--table__cell__offset__expand"), wrapCellText === 'expand')),
315
316
  style: {
316
317
  '--row-nesting-offset': "".concat(offset, "px")
317
318
  }
@@ -399,7 +400,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
399
400
  }, rowDetails))) : /*#__PURE__*/React__default.createElement(TableExpandRow, {
400
401
  key: id,
401
402
  expandHeaderId: "".concat(tableId, "-expand"),
402
- className: classnames("".concat(iotPrefix, "--expandable-tablerow"), (_classnames4 = {}, _defineProperty(_classnames4, "".concat(iotPrefix, "--expandable-tablerow--parent"), hasRowNesting && (hasRowNesting === null || hasRowNesting === void 0 ? void 0 : hasRowNesting.hasSingleNestedHierarchy) && nestingChildCount > 0), _defineProperty(_classnames4, "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), _defineProperty(_classnames4, "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), _defineProperty(_classnames4, "".concat(iotPrefix, "--expandable-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), _defineProperty(_classnames4, "".concat(iotPrefix, "--expandable-tablerow--last-child"), isLastChild), _classnames4)),
403
+ className: classnames("".concat(iotPrefix, "--expandable-tablerow"), (_classnames5 = {}, _defineProperty(_classnames5, "".concat(iotPrefix, "--expandable-tablerow--parent"), hasRowNesting && (hasRowNesting === null || hasRowNesting === void 0 ? void 0 : hasRowNesting.hasSingleNestedHierarchy) && nestingChildCount > 0), _defineProperty(_classnames5, "".concat(iotPrefix, "--expandable-tablerow--childless"), hasRowNesting && nestingChildCount === 0), _defineProperty(_classnames5, "".concat(iotPrefix, "--expandable-tablerow--indented"), parseInt(nestingOffset, 10) > 0), _defineProperty(_classnames5, "".concat(iotPrefix, "--expandable-tablerow--singly-selected"), hasRowSelection === 'single' && isSelected && !useRadioButtonSingleSelect), _defineProperty(_classnames5, "".concat(iotPrefix, "--expandable-tablerow--last-child"), isLastChild), _classnames5)),
403
404
  "data-row-nesting": hasRowNesting,
404
405
  "data-child-count": nestingChildCount,
405
406
  "data-nesting-offset": nestingOffset,
@@ -430,7 +431,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
430
431
  rowId: id,
431
432
  langDir: langDir
432
433
  }, tableCells) : hasRowSelection === 'single' && isSelected ? /*#__PURE__*/React__default.createElement(TableRow, {
433
- className: classnames("".concat(iotPrefix, "--table__row"), (_classnames5 = {}, _defineProperty(_classnames5, "".concat(iotPrefix, "--table__row--singly-selected"), isSelected && !useRadioButtonSingleSelect), _defineProperty(_classnames5, "".concat(iotPrefix, "--table__row--background"), isSelected), _classnames5)),
434
+ className: classnames("".concat(iotPrefix, "--table__row"), (_classnames6 = {}, _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--singly-selected"), isSelected && !useRadioButtonSingleSelect), _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--background"), isSelected), _classnames6)),
434
435
  key: id,
435
436
  onClick: function onClick() {
436
437
  if (isSelectable !== false) {
@@ -442,7 +443,7 @@ var TableBodyRow = function TableBodyRow(_ref) {
442
443
  }
443
444
  }
444
445
  }, tableCells) : /*#__PURE__*/React__default.createElement(TableRow, {
445
- className: classnames("".concat(iotPrefix, "--table__row"), (_classnames6 = {}, _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--unselectable"), isSelectable === false), _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--selectable"), isSelectable !== false), _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--editing"), isEditMode), _defineProperty(_classnames6, "".concat(iotPrefix, "--table__row--selected"), isSelected), _classnames6)),
446
+ className: classnames("".concat(iotPrefix, "--table__row"), (_classnames7 = {}, _defineProperty(_classnames7, "".concat(iotPrefix, "--table__row--unselectable"), isSelectable === false), _defineProperty(_classnames7, "".concat(iotPrefix, "--table__row--selectable"), isSelectable !== false), _defineProperty(_classnames7, "".concat(iotPrefix, "--table__row--editing"), isEditMode), _defineProperty(_classnames7, "".concat(iotPrefix, "--table__row--selected"), isSelected), _classnames7)),
446
447
  key: id,
447
448
  onClick: function onClick() {
448
449
  if (isSelectable !== false) {
@@ -636,20 +637,8 @@ TableBodyRow.__docgenInfo = {
636
637
  "required": false
637
638
  },
638
639
  "wrapCellText": {
639
- "name": "enum",
640
- "value": [{
641
- "value": "'always'",
642
- "computed": false
643
- }, {
644
- "value": "'never'",
645
- "computed": false
646
- }, {
647
- "value": "'auto'",
648
- "computed": false
649
- }, {
650
- "value": "'alwaysTruncate'",
651
- "computed": false
652
- }],
640
+ "name": "custom",
641
+ "raw": "WrapCellTextPropTypes.isRequired",
653
642
  "required": true
654
643
  },
655
644
  "truncateCellText": {
@@ -19,6 +19,7 @@ import 'core-js/modules/es.array.map.js';
19
19
  import React__default, { useRef } from 'react';
20
20
  import PropTypes from 'prop-types';
21
21
  import useVisibilityObserver from '../../../hooks/useVisibilityObserver.js';
22
+ import { WrapCellTextPropTypes } from '../../../constants/SharedPropTypes.js';
22
23
  import { ExpandedRowsPropTypes, TableColumnsPropTypes, RowActionsStatePropTypes, TableRowPropTypes, TableRowsPropTypes } from '../TablePropTypes.js';
23
24
  import TableBodyRow from './TableBodyRow/TableBodyRow.js';
24
25
  import TableBodyLoadMoreRow from './TableBodyLoadMoreRow/TableBodyLoadMoreRow.js';
@@ -74,7 +75,7 @@ var propTypes = {
74
75
  hasSingleNestedHierarchy: PropTypes.bool
75
76
  })]),
76
77
  hasRowActions: PropTypes.bool,
77
- wrapCellText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']).isRequired,
78
+ wrapCellText: WrapCellTextPropTypes.isRequired,
78
79
  truncateCellText: PropTypes.bool.isRequired,
79
80
 
80
81
  /** the current state of the row actions */
@@ -797,22 +798,10 @@ TableBodyRowRenderer.__docgenInfo = {
797
798
  },
798
799
  "wrapCellText": {
799
800
  "type": {
800
- "name": "enum",
801
- "value": [{
802
- "value": "'always'",
803
- "computed": false
804
- }, {
805
- "value": "'never'",
806
- "computed": false
807
- }, {
808
- "value": "'auto'",
809
- "computed": false
810
- }, {
811
- "value": "'alwaysTruncate'",
812
- "computed": false
813
- }]
801
+ "name": "custom",
802
+ "raw": "WrapCellTextPropTypes.isRequired"
814
803
  },
815
- "required": true,
804
+ "required": false,
816
805
  "description": ""
817
806
  },
818
807
  "truncateCellText": {
@@ -9,11 +9,12 @@ import classnames from 'classnames';
9
9
  import { TooltipDefinition, Tooltip } from 'carbon-components-react';
10
10
  import warning from 'warning';
11
11
  import { settings } from '../../../constants/Settings.js';
12
+ import { WrapCellTextPropTypes } from '../../../constants/SharedPropTypes.js';
12
13
 
13
14
  var iotPrefix = settings.iotPrefix;
14
15
  var propTypes = {
15
16
  children: PropTypes.oneOfType([PropTypes.node, PropTypes.bool, PropTypes.object, PropTypes.array]),
16
- wrapText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']).isRequired,
17
+ wrapText: WrapCellTextPropTypes.isRequired,
17
18
  truncateCellText: PropTypes.bool.isRequired,
18
19
  allowTooltip: PropTypes.bool,
19
20
 
@@ -74,7 +75,7 @@ var TableCellRenderer = function TableCellRenderer(_ref) {
74
75
  filterFunction = _ref.filterFunction,
75
76
  preserveCellWhiteSpace = _ref.preserveCellWhiteSpace;
76
77
  var mySpanRef = /*#__PURE__*/React__default.createRef();
77
- var myClasses = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--truncate"), wrapText !== 'always' && truncateCellText), _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--no-wrap"), wrapText === 'never'), _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--preserve"), preserveCellWhiteSpace), _classnames));
78
+ var myClasses = classnames((_classnames = {}, _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--truncate"), wrapText !== 'always' && truncateCellText), _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--no-wrap"), wrapText === 'never' || wrapText === 'expand'), _defineProperty(_classnames, "".concat(iotPrefix, "--table__cell-text--preserve"), preserveCellWhiteSpace), _classnames));
78
79
 
79
80
  var _useState = useState(false),
80
81
  _useState2 = _slicedToArray(_useState, 2),
@@ -254,22 +255,10 @@ TableCellRenderer.__docgenInfo = {
254
255
  },
255
256
  "wrapText": {
256
257
  "type": {
257
- "name": "enum",
258
- "value": [{
259
- "value": "'always'",
260
- "computed": false
261
- }, {
262
- "value": "'never'",
263
- "computed": false
264
- }, {
265
- "value": "'auto'",
266
- "computed": false
267
- }, {
268
- "value": "'alwaysTruncate'",
269
- "computed": false
270
- }]
258
+ "name": "custom",
259
+ "raw": "WrapCellTextPropTypes.isRequired"
271
260
  },
272
- "required": true,
261
+ "required": false,
273
262
  "description": ""
274
263
  },
275
264
  "truncateCellText": {
@@ -29,6 +29,7 @@ import { TableColumnsPropTypes, TableColumnGroupPropType, ActiveTableToolbarProp
29
29
  import TableCellRenderer from '../TableCellRenderer/TableCellRenderer.js';
30
30
  import { tableTranslateWithId } from '../../../utils/componentUtilityFunctions.js';
31
31
  import { settings } from '../../../constants/Settings.js';
32
+ import { WrapCellTextPropTypes } from '../../../constants/SharedPropTypes.js';
32
33
  import { OverflowMenu } from '../../OverflowMenu/index.js';
33
34
  import { usePrevious } from '../../../hooks/usePrevious.js';
34
35
  import deprecate from '../../../internal/deprecate.js';
@@ -58,7 +59,7 @@ var propTypes = {
58
59
  /** If the hierarchy only has 1 nested level of children */
59
60
  hasSingleNestedHierarchy: PropTypes.bool
60
61
  })]),
61
- wrapCellText: PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate']).isRequired,
62
+ wrapCellText: WrapCellTextPropTypes.isRequired,
62
63
  truncateCellText: PropTypes.bool.isRequired,
63
64
  hasMultiSort: PropTypes.bool,
64
65
  useAutoTableLayoutForResize: PropTypes.bool,
@@ -699,20 +700,8 @@ TableHead.__docgenInfo = {
699
700
  "required": false
700
701
  },
701
702
  "wrapCellText": {
702
- "name": "enum",
703
- "value": [{
704
- "value": "'always'",
705
- "computed": false
706
- }, {
707
- "value": "'never'",
708
- "computed": false
709
- }, {
710
- "value": "'auto'",
711
- "computed": false
712
- }, {
713
- "value": "'alwaysTruncate'",
714
- "computed": false
715
- }],
703
+ "name": "custom",
704
+ "raw": "WrapCellTextPropTypes.isRequired",
716
705
  "required": true
717
706
  },
718
707
  "truncateCellText": {
@@ -151,5 +151,6 @@ var CarbonIconPropType = PropTypes.oneOfType([PropTypes.func, PropTypes.object])
151
151
  var HtmlElementRefProp = PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
152
152
  current: PropTypes.oneOfType([PropTypes.object])
153
153
  })]);
154
+ var WrapCellTextPropTypes = PropTypes.oneOf(['always', 'never', 'auto', 'alwaysTruncate', 'expand']);
154
155
 
155
- export { ButtonIconPropType, CarbonIconPropType, ColorPropType, HotspotContentPropTypes, HotspotIconPropType, HotspotPropTypes, HtmlElementRefProp, OverridePropTypes, SvgPropType };
156
+ export { ButtonIconPropType, CarbonIconPropType, ColorPropType, HotspotContentPropTypes, HotspotIconPropType, HotspotPropTypes, HtmlElementRefProp, OverridePropTypes, SvgPropType, WrapCellTextPropTypes };
@@ -46,6 +46,36 @@ var isOffscreen = function isOffscreen(menuBody, menuDirection, menuButton
46
46
  var L = offLeft ? 'left' : '';
47
47
  return [T, R, B, L].filter(Boolean).join('-');
48
48
  };
49
+ /**
50
+ * This is used as the callback for menuOffset ONLY on Tooltips. It's needed due to
51
+ * truncation that might happen on Tooltip trigger, therefore we need to consider
52
+ * right position of the trigger as well. This function is used as an enhancement for
53
+ * the isOffscreen method.
54
+ *
55
+ * @param {HTMLElement} menuBody The underlying carbon FloatingMenu element
56
+ * @param {string} menuDirection The direction prop
57
+ * @param {HTMLElement} menuButton The button triggering the menu
58
+ * @returns {string} 'start', 'center' or 'end'
59
+ */
60
+
61
+
62
+ var getTooltipAlignment = function getTooltipAlignment(menuBody, menuDirection, menuButton) {
63
+ var buttonRect = menuButton.getBoundingClientRect();
64
+ var tooltipRect = menuBody.getBoundingClientRect();
65
+ var windowWidth = window.innerWidth || document.documentElement.clientWidth;
66
+ var triggerCenter = (buttonRect.left + buttonRect.right) / 2;
67
+ var tooltipCenter = tooltipRect.width / 2;
68
+
69
+ if (triggerCenter - tooltipCenter < 0) {
70
+ return 'start';
71
+ }
72
+
73
+ if (triggerCenter + tooltipCenter > windowWidth) {
74
+ return 'end';
75
+ }
76
+
77
+ return 'center';
78
+ };
49
79
  /**
50
80
  * Given a subset of props from the Tooltip, OverflowMenu, or FlyoutMenu. This hook returns a decorator
51
81
  * function around the original menuOffset function. It determines if the element overflows using that
@@ -63,22 +93,29 @@ var usePopoverPositioning = function usePopoverPositioning(_ref) {
63
93
  _ref$isOverflowMenu = _ref.isOverflowMenu,
64
94
  isOverflowMenu = _ref$isOverflowMenu === void 0 ? false : _ref$isOverflowMenu,
65
95
  _ref$useAutoPositioni = _ref.useAutoPositioning,
66
- useAutoPositioning = _ref$useAutoPositioni === void 0 ? true : _ref$useAutoPositioni;
96
+ useAutoPositioning = _ref$useAutoPositioni === void 0 ? true : _ref$useAutoPositioni,
97
+ _ref$defaultAlignment = _ref.defaultAlignment,
98
+ defaultAlignment = _ref$defaultAlignment === void 0 ? 'center' : _ref$defaultAlignment;
67
99
 
68
100
  var _React$useState = React.useState(),
69
101
  _React$useState2 = _slicedToArray(_React$useState, 2),
70
102
  adjustedDirection = _React$useState2[0],
71
103
  setAdjustedDirection = _React$useState2[1];
72
104
 
73
- var _React$useState3 = React.useState(),
105
+ var _React$useState3 = React.useState(defaultAlignment),
74
106
  _React$useState4 = _slicedToArray(_React$useState3, 2),
75
- adjustedFlipped = _React$useState4[0],
76
- setAdjustedFlipped = _React$useState4[1];
107
+ adjustedAlignment = _React$useState4[0],
108
+ setAdjustedAlignment = _React$useState4[1];
77
109
 
78
- var _React$useState5 = React.useState({}),
110
+ var _React$useState5 = React.useState(),
79
111
  _React$useState6 = _slicedToArray(_React$useState5, 2),
80
- flyoutAlignment = _React$useState6[0].flyoutAlignment,
81
- setDirections = _React$useState6[1];
112
+ adjustedFlipped = _React$useState6[0],
113
+ setAdjustedFlipped = _React$useState6[1];
114
+
115
+ var _React$useState7 = React.useState({}),
116
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
117
+ flyoutAlignment = _React$useState8[0].flyoutAlignment,
118
+ setDirections = _React$useState8[1];
82
119
 
83
120
  var previousDirection = React.useRef();
84
121
  var langDir = useLangDirection();
@@ -176,10 +213,12 @@ var usePopoverPositioning = function usePopoverPositioning(_ref) {
176
213
  * be adjusted to `right-start`.
177
214
  */
178
215
 
179
- var fixOverflow = React.useCallback(function (overflow, menuOffsetArgs) {
216
+ var fixOverflow = React.useCallback(function (overflow, menuOffsetArgs, alignment) {
180
217
  var _menuOffsetArgs = _slicedToArray(menuOffsetArgs, 1),
181
218
  tooltipElement = _menuOffsetArgs[0];
182
219
 
220
+ setAdjustedAlignment(alignment);
221
+
183
222
  switch (overflow) {
184
223
  case 'top':
185
224
  if (flyoutAlignment) {
@@ -306,7 +345,9 @@ var usePopoverPositioning = function usePopoverPositioning(_ref) {
306
345
  } // determine if the element is off-screen.
307
346
 
308
347
 
309
- var overflow = isOffscreen.apply(void 0, args.concat([defaultOffset])); // if it's offscreen in a direction we can fix, do so
348
+ var overflow = isOffscreen.apply(void 0, args.concat([defaultOffset])); // determine if the element has new alignment
349
+
350
+ var alignment = getTooltipAlignment.apply(void 0, args); // if it's offscreen in a direction we can fix, do so
310
351
  // otherwise leave it be. ie. 'top-left' is fixable, but
311
352
  // a large element with 'top-right-left' wouldn't be.
312
353
 
@@ -319,7 +360,7 @@ var usePopoverPositioning = function usePopoverPositioning(_ref) {
319
360
  case 'right':
320
361
  case 'bottom':
321
362
  case 'left':
322
- return fixOverflow(overflow, [].concat(args));
363
+ return fixOverflow(overflow, [].concat(args), alignment);
323
364
 
324
365
  default:
325
366
  return defaultOffset;
@@ -333,7 +374,8 @@ var usePopoverPositioning = function usePopoverPositioning(_ref) {
333
374
 
334
375
  return [calculateMenuOffset, {
335
376
  adjustedDirection: adjustedDirection,
336
- adjustedFlipped: adjustedFlipped
377
+ adjustedFlipped: adjustedFlipped,
378
+ adjustedAlignment: adjustedAlignment
337
379
  }];
338
380
  };
339
381
 
@@ -83,6 +83,7 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
83
83
 
84
84
  var _usePopoverPositionin = usePopoverPositioning.usePopoverPositioning({
85
85
  direction: 'bottom',
86
+ defaultAlignment: 'center',
86
87
  menuOffset: index.getTooltipMenuOffset,
87
88
  useAutoPositioning: true,
88
89
  isOverflowMenu: true // Needed to preserve default direction (bottom)
@@ -90,7 +91,9 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
90
91
  }),
91
92
  _usePopoverPositionin2 = _slicedToArray__default['default'](_usePopoverPositionin, 2),
92
93
  calculateMenuOffset = _usePopoverPositionin2[0],
93
- adjustedDirection = _usePopoverPositionin2[1].adjustedDirection;
94
+ _usePopoverPositionin3 = _usePopoverPositionin2[1],
95
+ adjustedDirection = _usePopoverPositionin3.adjustedDirection,
96
+ adjustedAlignment = _usePopoverPositionin3.adjustedAlignment;
94
97
 
95
98
  var _useState = React.useState({
96
99
  title: false,
@@ -166,7 +169,7 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
166
169
  var _classnames;
167
170
 
168
171
  return hasTitleTooltipFromTruncation || hasExternalTitleTextTooltip ? /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.Tooltip, {
169
- align: "center",
172
+ align: adjustedAlignment,
170
173
  menuOffset: calculateMenuOffset,
171
174
  direction: adjustedDirection,
172
175
  "data-testid": "".concat(testId, "-title-tooltip"),
@@ -191,6 +194,9 @@ var CardTitle = function CardTitle(_ref // eslint-disable-line react/prop-types
191
194
 
192
195
  var renderSubTitle = function renderSubTitle() {
193
196
  return !subtitle ? null : hasSubTitleTooltip ? /*#__PURE__*/React__default['default'].createElement(carbonComponentsReact.Tooltip, {
197
+ align: adjustedAlignment,
198
+ menuOffset: calculateMenuOffset,
199
+ direction: adjustedDirection,
194
200
  "data-testid": "".concat(testId, "-subtitle"),
195
201
  ref: subTitleRef,
196
202
  showIcon: false,
@@ -287,7 +287,7 @@ var defaultProps = {
287
287
  };
288
288
 
289
289
  var DateTimePicker = function DateTimePicker(_ref) {
290
- var _classnames2, _classnames4, _style$zIndex;
290
+ var _classnames, _classnames2, _classnames4, _style$zIndex;
291
291
 
292
292
  var testId = _ref.testId,
293
293
  defaultValue = _ref.defaultValue,
@@ -862,7 +862,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
862
862
  }, /*#__PURE__*/React__default['default'].createElement("div", {
863
863
  "data-testid": testId,
864
864
  id: "".concat(id, "-").concat(iotPrefix, "--date-time-pickerv2__wrapper"),
865
- className: classnames__default['default']("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), _defineProperty__default['default']({}, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled)),
865
+ className: classnames__default['default']("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), (_classnames = {}, _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled), _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--invalid"), invalidState), _classnames)),
866
866
  style: {
867
867
  '--wrapper-width': hasIconOnly ? '3rem' : '20rem'
868
868
  },
@@ -884,7 +884,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
884
884
  onMouseLeave: toggleTooltip,
885
885
  tabIndex: 0
886
886
  }, /*#__PURE__*/React__default['default'].createElement("div", {
887
- className: classnames__default['default']((_classnames2 = {}, _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _classnames2))
887
+ className: classnames__default['default']((_classnames2 = {}, _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _classnames2))
888
888
  }, !hasIconOnly ? /*#__PURE__*/React__default['default'].createElement("div", {
889
889
  "data-testid": "".concat(testId, "__field"),
890
890
  className: "".concat(iotPrefix, "--date-time-picker__field")
@@ -268,7 +268,7 @@ var defaultProps = {
268
268
  };
269
269
 
270
270
  var DateTimePicker = function DateTimePicker(_ref) {
271
- var _classnames2, _classnames4;
271
+ var _classnames, _classnames2, _classnames4;
272
272
 
273
273
  var testId = _ref.testId,
274
274
  defaultValue = _ref.defaultValue,
@@ -721,7 +721,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
721
721
  }, /*#__PURE__*/React__default['default'].createElement("div", {
722
722
  "data-testid": testId,
723
723
  id: "".concat(id, "-").concat(iotPrefix, "--date-time-pickerv2__wrapper"),
724
- className: classnames__default['default']("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), _defineProperty__default['default']({}, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled)),
724
+ className: classnames__default['default']("".concat(iotPrefix, "--date-time-pickerv2__wrapper"), (_classnames = {}, _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--disabled"), disabled), _defineProperty__default['default'](_classnames, "".concat(iotPrefix, "--date-time-pickerv2__wrapper--invalid"), invalidState), _classnames)),
725
725
  style: {
726
726
  '--wrapper-width': hasIconOnly ? '3rem' : '20rem'
727
727
  },
@@ -743,7 +743,7 @@ var DateTimePicker = function DateTimePicker(_ref) {
743
743
  onMouseLeave: toggleTooltip,
744
744
  tabIndex: 0
745
745
  }, /*#__PURE__*/React__default['default'].createElement("div", {
746
- className: classnames__default['default']((_classnames2 = {}, _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _classnames2))
746
+ className: classnames__default['default']((_classnames2 = {}, _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--full"), !hasIconOnly), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--light"), light), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--disabled"), disabled), _defineProperty__default['default'](_classnames2, "".concat(iotPrefix, "--date-time-picker__box--invalid"), invalidState), _classnames2))
747
747
  }, !hasIconOnly ? /*#__PURE__*/React__default['default'].createElement("div", {
748
748
  "data-testid": "".concat(testId, "__field"),
749
749
  className: "".concat(iotPrefix, "--date-time-picker__field")