@gridsuite/commons-ui 0.34.1 → 0.35.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.
@@ -1,22 +1,33 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports["default"] = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = void 0;
4
+ exports.generateMuiVirtualizedTableClass = exports["default"] = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
6
  var _reactIntl = require("react-intl");
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
8
  var _clsx3 = _interopRequireDefault(require("clsx"));
9
9
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
10
10
  var _material = require("@mui/material");
11
- var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
11
+ var _system = require("@mui/system");
12
12
  var _GetApp = _interopRequireDefault(require("@mui/icons-material/GetApp"));
13
13
  var _reactVirtualized = require("react-virtualized");
14
14
  var _reactCsvDownloader = _interopRequireDefault(require("react-csv-downloader"));
15
15
  var _overflowableText = _interopRequireDefault(require("../OverflowableText/overflowable-text"));
16
+ var _styles = require("../../utils/styles");
16
17
  var _KeyedColumnsRowIndexer = require("./KeyedColumnsRowIndexer");
17
18
  var _ColumnHeader = _interopRequireDefault(require("./ColumnHeader"));
18
19
  var _excluded = ["sort"],
19
20
  _excluded2 = ["dataKey"];
21
+ var _defaultStyles;
22
+ /**
23
+ * Copyright (c) 2022, RTE (http://www.rte-france.com)
24
+ * This Source Code Form is subject to the terms of the Mozilla Public
25
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
26
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
27
+ */
28
+ /**
29
+ * This class has been taken from 'Virtualized Table' example at https://material-ui.com/components/tables/
30
+ */
20
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
33
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -30,14 +41,7 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Objec
30
41
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
42
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
32
43
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
33
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } /**
34
- * Copyright (c) 2022, RTE (http://www.rte-france.com)
35
- * This Source Code Form is subject to the terms of the Mozilla Public
36
- * License, v. 2.0. If a copy of the MPL was not distributed with this
37
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
38
- */ /**
39
- * This class has been taken from 'Virtualized Table' example at https://material-ui.com/components/tables/
40
- */
44
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
41
45
  function getTextWidth(text) {
42
46
  // re-use canvas object for better performance
43
47
  var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement('canvas'));
@@ -52,42 +56,57 @@ exports.DEFAULT_CELL_PADDING = DEFAULT_CELL_PADDING;
52
56
  var DEFAULT_HEADER_HEIGHT = 48;
53
57
  exports.DEFAULT_HEADER_HEIGHT = DEFAULT_HEADER_HEIGHT;
54
58
  var DEFAULT_ROW_HEIGHT = 48;
59
+
60
+ // As a bunch of individual variables to try to make it easier
61
+ // to track that they are all used. Not sure, maybe group them in an object ?
55
62
  exports.DEFAULT_ROW_HEIGHT = DEFAULT_ROW_HEIGHT;
56
- var defaultStyles = {
57
- flexContainer: {
58
- display: 'flex',
59
- alignItems: 'center',
60
- boxSizing: 'border-box'
61
- },
62
- table: {
63
- // temporary right-to-left patch, waiting for
64
- // https://github.com/bvaughn/react-virtualized/issues/454
65
- '& .ReactVirtualized__Table__headerRow': {
66
- flip: false
67
- }
68
- },
69
- tableRow: {
70
- cursor: 'pointer'
71
- },
72
- tableRowHover: {},
73
- tableCell: {
74
- flex: 1,
75
- padding: DEFAULT_CELL_PADDING + 'px'
76
- },
77
- tableCellColor: {},
78
- noClick: {
79
- cursor: 'initial'
80
- },
81
- header: {
82
- fontWeight: 'bold'
83
- },
84
- rowBackgroundDark: {},
85
- rowBackgroundLight: {},
86
- cellTooltip: {
87
- maxWidth: '1260px',
88
- fontSize: '0.9rem'
63
+ var cssFlexContainer = 'flexContainer';
64
+ var cssTable = 'table';
65
+ var cssTableRow = 'tableRow';
66
+ var cssTableRowHover = 'tableRowHover';
67
+ var cssTableCell = 'tableCell';
68
+ var cssTableCellColor = 'tableCellColor';
69
+ var cssNoClick = 'noClick';
70
+ var cssHeader = 'header';
71
+ var cssRowBackgroundDark = 'rowBackgroundDark';
72
+ var cssRowBackgroundLight = 'rowBackgroundLight';
73
+
74
+ // converted to nested rules
75
+ var defaultStyles = (_defaultStyles = {}, _defaultStyles[cssFlexContainer] = {
76
+ display: 'flex',
77
+ alignItems: 'center',
78
+ boxSizing: 'border-box'
79
+ }, _defaultStyles[cssTable] = {
80
+ // temporary right-to-left patch, waiting for
81
+ // https://github.com/bvaughn/react-virtualized/issues/454
82
+ '& .ReactVirtualized__Table__headerRow': {
83
+ flip: false
89
84
  }
85
+ }, _defaultStyles[cssTableRow] = {
86
+ cursor: 'pointer'
87
+ }, _defaultStyles[cssTableRowHover] = {}, _defaultStyles[cssTableCell] = {
88
+ flex: 1,
89
+ padding: DEFAULT_CELL_PADDING + 'px'
90
+ }, _defaultStyles[cssTableCellColor] = {}, _defaultStyles[cssNoClick] = {
91
+ cursor: 'initial'
92
+ }, _defaultStyles[cssHeader] = {
93
+ fontWeight: 'bold'
94
+ }, _defaultStyles[cssRowBackgroundDark] = {}, _defaultStyles[cssRowBackgroundLight] = {}, _defaultStyles);
95
+
96
+ // TODO find a better system, maybe MUI will fix/improve this ?
97
+ // Different from all others because of the poor nested sx support for portals
98
+ // requiring classname sharing/forwarding between the content and the tooltip
99
+ var defaultTooltipSx = {
100
+ maxWidth: '1260px',
101
+ fontSize: '0.9rem'
90
102
  };
103
+
104
+ //TODO do we need to export this to clients (index.js) ?
105
+ var generateMuiVirtualizedTableClass = function generateMuiVirtualizedTableClass(className) {
106
+ return "MuiVirtualizedTable-" + className;
107
+ };
108
+ exports.generateMuiVirtualizedTableClass = generateMuiVirtualizedTableClass;
109
+ var composeClasses = (0, _styles.makeComposeClasses)(generateMuiVirtualizedTableClass);
91
110
  var AmongChooser = function AmongChooser(props) {
92
111
  var options = props.options,
93
112
  value = props.value,
@@ -411,7 +430,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
411
430
  var _this$props = _this.props,
412
431
  classes = _this$props.classes,
413
432
  onRowClick = _this$props.onRowClick;
414
- return (0, _clsx3["default"])(classes.tableRow, classes.flexContainer, index % 2 === 0 && classes.rowBackgroundDark, index % 2 !== 0 && classes.rowBackgroundLight, ((_rowGetter = rowGetter(index)) === null || _rowGetter === void 0 ? void 0 : _rowGetter.notClickable) === true && classes.noClick, (_clsx = {}, _clsx[classes.tableRowHover] = index !== -1 && onRowClick != null, _clsx));
433
+ return (0, _clsx3["default"])(composeClasses(classes, cssTableRow), composeClasses(classes, cssFlexContainer), index % 2 === 0 && composeClasses(classes, cssRowBackgroundDark), index % 2 !== 0 && composeClasses(classes, cssRowBackgroundLight), ((_rowGetter = rowGetter(index)) === null || _rowGetter === void 0 ? void 0 : _rowGetter.notClickable) === true && composeClasses(classes, cssNoClick), (_clsx = {}, _clsx[composeClasses(classes, cssTableRowHover)] = index !== -1 && onRowClick != null, _clsx));
415
434
  });
416
435
  _defineProperty(_assertThisInitialized(_this), "onClickableRowClick", function (event) {
417
436
  var _event$rowData;
@@ -429,11 +448,12 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
429
448
  classes = _this$props2.classes,
430
449
  rowHeight = _this$props2.rowHeight,
431
450
  onCellClick = _this$props2.onCellClick,
432
- rows = _this$props2.rows;
451
+ rows = _this$props2.rows,
452
+ tooltipSx = _this$props2.tooltipSx;
433
453
  var displayedValue = _this.getDisplayValue(columns[columnIndex], cellData);
434
454
  return /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
435
455
  component: "div",
436
- className: (0, _clsx3["default"])(classes.tableCell, classes.flexContainer, (_clsx2 = {}, _clsx2[classes.noClick] = displayedValue === undefined || ((_rows$rowIndex = rows[rowIndex]) === null || _rows$rowIndex === void 0 ? void 0 : _rows$rowIndex.notClickable) === true || onCellClick == null || columns[columnIndex].clickable === undefined || !columns[columnIndex].clickable, _clsx2[classes.tableCellColor] = displayedValue === undefined || onCellClick !== null && !((_rows$rowIndex2 = rows[rowIndex]) === null || _rows$rowIndex2 === void 0 ? void 0 : _rows$rowIndex2.notClickable) === true && columns[columnIndex].clickable !== undefined && columns[columnIndex].clickable, _clsx2)),
456
+ className: (0, _clsx3["default"])(composeClasses(classes, cssTableCell), composeClasses(classes, cssFlexContainer), (_clsx2 = {}, _clsx2[composeClasses(classes, cssNoClick)] = displayedValue === undefined || ((_rows$rowIndex = rows[rowIndex]) === null || _rows$rowIndex === void 0 ? void 0 : _rows$rowIndex.notClickable) === true || onCellClick == null || columns[columnIndex].clickable === undefined || !columns[columnIndex].clickable, _clsx2[composeClasses(classes, cssTableCellColor)] = displayedValue === undefined || onCellClick !== null && !((_rows$rowIndex2 = rows[rowIndex]) === null || _rows$rowIndex2 === void 0 ? void 0 : _rows$rowIndex2.notClickable) === true && columns[columnIndex].clickable !== undefined && columns[columnIndex].clickable, _clsx2)),
437
457
  variant: "body",
438
458
  style: {
439
459
  height: rowHeight,
@@ -448,7 +468,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
448
468
  }
449
469
  }, /*#__PURE__*/_react["default"].createElement(_overflowableText["default"], {
450
470
  text: displayedValue,
451
- tooltipStyle: classes.cellTooltip
471
+ tooltipStyle: classes.cellTooltip,
472
+ tooltipSx: _extends({}, defaultTooltipSx, tooltipSx)
452
473
  }));
453
474
  });
454
475
  _defineProperty(_assertThisInitialized(_this), "makeSizedTable", function (height, width, sizes, reorderedIndex, _rowGetter2) {
@@ -464,7 +485,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
464
485
  direction: 'inherit'
465
486
  },
466
487
  headerHeight: _this.state.headerHeight,
467
- className: otherProps.classes.table,
488
+ className: composeClasses(otherProps.classes, cssTable),
468
489
  onRowClick: _this.props.onRowClick && /* The {...otherProps} just above would hold the slot onRowClick */
469
490
  _this.onClickableRowClick,
470
491
  rowCount: (_reorderedIndex$lengt = reorderedIndex === null || reorderedIndex === void 0 ? void 0 : reorderedIndex.length) !== null && _reorderedIndex$lengt !== void 0 ? _reorderedIndex$lengt : otherProps.rows.length,
@@ -485,7 +506,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
485
506
  return /*#__PURE__*/_react["default"].createElement(_reactVirtualized.Column, _extends({
486
507
  key: dataKey,
487
508
  headerRenderer: _this.makeHeaderRenderer(dataKey, index),
488
- className: otherProps.classes.flexContainer,
509
+ className: composeClasses(otherProps.classes, cssFlexContainer),
489
510
  cellRenderer: _this.cellRenderer,
490
511
  dataKey: dataKey,
491
512
  flexGrow: 1,
@@ -656,7 +677,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
656
677
  return function (headerProps) {
657
678
  return /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
658
679
  component: "div",
659
- className: (0, _clsx3["default"])(classes.tableCell, classes.flexContainer, classes.noClick, classes.header),
680
+ className: (0, _clsx3["default"])(composeClasses(classes, cssTableCell), composeClasses(classes, cssFlexContainer), composeClasses(classes, cssNoClick), composeClasses(classes, cssHeader)),
660
681
  variant: "head",
661
682
  style: {
662
683
  height: _this3.state.headerHeight
@@ -685,7 +706,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
685
706
  display: 'flex',
686
707
  flexDirection: 'column',
687
708
  height: '100%'
688
- }
709
+ },
710
+ className: this.props.className
689
711
  }, this.props.enableExportCSV && /*#__PURE__*/_react["default"].createElement("div", {
690
712
  style: {
691
713
  display: 'flex',
@@ -734,11 +756,12 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
734
756
  _defineProperty(MuiVirtualizedTable, "defaultProps", {
735
757
  headerHeight: DEFAULT_HEADER_HEIGHT,
736
758
  rowHeight: DEFAULT_ROW_HEIGHT,
737
- enableExportCSV: false
759
+ enableExportCSV: false,
760
+ classes: {}
738
761
  });
739
762
  MuiVirtualizedTable.propTypes = process.env.NODE_ENV !== "production" ? {
740
763
  name: _propTypes["default"].string,
741
- classes: _propTypes["default"].object.isRequired,
764
+ classes: _propTypes["default"].object,
742
765
  rows: _propTypes["default"].array,
743
766
  columns: _propTypes["default"].arrayOf(_propTypes["default"].shape({
744
767
  dataKey: _propTypes["default"].string.isRequired,
@@ -759,7 +782,9 @@ MuiVirtualizedTable.propTypes = process.env.NODE_ENV !== "production" ? {
759
782
  onRowClick: _propTypes["default"].func,
760
783
  onCellClick: _propTypes["default"].func,
761
784
  rowHeight: _propTypes["default"].number,
762
- filter: _propTypes["default"].func
785
+ filter: _propTypes["default"].func,
786
+ tooltipSx: _propTypes["default"].object
763
787
  } : {};
764
- var _default = (0, _withStyles["default"])(defaultStyles)(MuiVirtualizedTable);
788
+ var nestedGlobalSelectorsStyles = (0, _styles.toNestedGlobalSelectors)(defaultStyles, generateMuiVirtualizedTableClass);
789
+ var _default = (0, _system.styled)(MuiVirtualizedTable)(nestedGlobalSelectorsStyles);
765
790
  exports["default"] = _default;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports["default"] = exports.KeyedColumnsRowIndexer = exports.CHANGE_WAYS = void 0;
5
- var _MuiVirtualizedTable = _interopRequireDefault(require("./MuiVirtualizedTable"));
4
+ exports.generateMuiVirtualizedTableClass = exports["default"] = exports.KeyedColumnsRowIndexer = exports.CHANGE_WAYS = void 0;
5
+ var _MuiVirtualizedTable = _interopRequireWildcard(require("./MuiVirtualizedTable"));
6
6
  exports["default"] = _MuiVirtualizedTable["default"];
7
+ exports.generateMuiVirtualizedTableClass = _MuiVirtualizedTable.generateMuiVirtualizedTableClass;
7
8
  var _KeyedColumnsRowIndexer = require("./KeyedColumnsRowIndexer");
8
9
  exports.KeyedColumnsRowIndexer = _KeyedColumnsRowIndexer.KeyedColumnsRowIndexer;
9
10
  exports.CHANGE_WAYS = _KeyedColumnsRowIndexer.CHANGE_WAYS;
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -5,9 +5,8 @@ exports["default"] = exports.OverflowableText = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
6
  var _material = require("@mui/material");
7
7
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
- var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
9
- var _clsx = _interopRequireDefault(require("clsx"));
10
- var _excluded = ["text", "tooltipStyle", "className", "children"];
8
+ var _system = require("@mui/system");
9
+ var _excluded = ["text", "tooltipStyle", "tooltipSx", "className", "children"];
11
10
  /**
12
11
  * Copyright (c) 2020, RTE (http://www.rte-france.com)
13
12
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -19,30 +18,28 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
20
19
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
22
- var overflowStyle = function overflowStyle(theme) {
23
- return {
24
- overflow: {
25
- display: 'inline-block',
26
- whiteSpace: 'pre',
27
- textOverflow: 'ellipsis',
28
- overflow: 'hidden'
29
- },
30
- tooltip: {
31
- whiteSpace: 'pre',
32
- width: 'fit-content',
33
- maxWidth: 'fit-content'
34
- }
35
- };
21
+ var overflowStyle = {
22
+ overflow: {
23
+ display: 'inline-block',
24
+ whiteSpace: 'pre',
25
+ textOverflow: 'ellipsis',
26
+ overflow: 'hidden'
27
+ },
28
+ tooltip: {
29
+ whiteSpace: 'pre',
30
+ width: 'fit-content',
31
+ maxWidth: 'fit-content'
32
+ }
36
33
  };
37
- var useStyles = (0, _makeStyles["default"])(overflowStyle);
38
- var OverflowableText = function OverflowableText(_ref) {
34
+ var OverflowableText = (0, _system.styled)(function (_ref) {
35
+ var _element$current, _element$current2;
39
36
  var text = _ref.text,
40
37
  tooltipStyle = _ref.tooltipStyle,
38
+ tooltipSx = _ref.tooltipSx,
41
39
  className = _ref.className,
42
40
  children = _ref.children,
43
41
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
44
42
  var element = (0, _react.useRef)();
45
- var classes = useStyles();
46
43
  var _useState = (0, _react.useState)(false),
47
44
  overflowed = _useState[0],
48
45
  setOverflowed = _useState[1];
@@ -52,26 +49,41 @@ var OverflowableText = function OverflowableText(_ref) {
52
49
  }
53
50
  setOverflowed(element.current.scrollWidth > element.current.clientWidth);
54
51
  }, [setOverflowed, element]);
55
- (0, _react.useEffect)(function () {
52
+ (0, _react.useLayoutEffect)(function () {
56
53
  checkOverflow();
57
- }, [checkOverflow, text]);
58
- return /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
59
- title: text || '',
60
- disableHoverListener: !overflowed,
54
+ }, [checkOverflow, text, (_element$current = element.current) === null || _element$current === void 0 ? void 0 : _element$current.scrollWidth, (_element$current2 = element.current) === null || _element$current2 === void 0 ? void 0 : _element$current2.clientWidth]);
55
+ var defaultTooltipSx = !tooltipStyle ? overflowStyle.tooltip : false;
56
+ // the previous tooltipStyle classname API was replacing default, not
57
+ // merging with the defaults, so keep the same behavior with the new tooltipSx API
58
+ var finalTooltipSx = tooltipSx || defaultTooltipSx;
59
+ var tooltipStyleProps = _extends({}, tooltipStyle && {
61
60
  classes: {
62
- tooltip: tooltipStyle ? tooltipStyle : classes.tooltip
61
+ tooltip: tooltipStyle
62
+ }
63
+ }, finalTooltipSx && {
64
+ slotProps: {
65
+ tooltip: {
66
+ sx: finalTooltipSx
67
+ }
63
68
  }
64
- }, /*#__PURE__*/_react["default"].createElement("div", _extends({}, props, {
69
+ });
70
+ return /*#__PURE__*/_react["default"].createElement(_material.Tooltip, _extends({
71
+ title: text || '',
72
+ disableHoverListener: !overflowed
73
+ }, tooltipStyleProps /* legacy classes or newer slotProps API */), /*#__PURE__*/_react["default"].createElement(_material.Box, _extends({}, props, {
65
74
  ref: element,
66
75
  children: children || text,
67
- className: (0, _clsx["default"])(className, classes.overflow)
76
+ className: className,
77
+ sx: overflowStyle.overflow
68
78
  })));
69
- };
79
+ })({});
70
80
  exports.OverflowableText = OverflowableText;
71
81
  OverflowableText.propTypes = process.env.NODE_ENV !== "production" ? {
72
82
  children: _propTypes["default"].array,
73
83
  text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number, _propTypes["default"].node]),
74
84
  tooltipStyle: _propTypes["default"].string,
85
+ tooltipSx: _propTypes["default"].object,
86
+ sx: _propTypes["default"].object,
75
87
  className: _propTypes["default"].string
76
88
  } : {};
77
89
  var _default = OverflowableText;
@@ -4,8 +4,8 @@ exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
6
  var _reactIntl = require("react-intl");
7
- var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
8
7
  var _TableCell = _interopRequireDefault(require("@mui/material/TableCell"));
8
+ var _system = require("@mui/system");
9
9
  var _MuiVirtualizedTable = _interopRequireDefault(require("../MuiVirtualizedTable"));
10
10
  var _styles = require("@mui/material/styles");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -19,27 +19,27 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
19
19
  */
20
20
 
21
21
  var SEVERITY_COLUMN_FIXED_WIDTH = 100;
22
- var styles = function styles(theme) {
23
- return {
24
- flexContainer: {
25
- display: 'flex',
26
- alignItems: 'center',
27
- boxSizing: 'border-box'
28
- },
29
- table: {
22
+ var styles = {
23
+ flexContainer: {
24
+ display: 'flex',
25
+ alignItems: 'center',
26
+ boxSizing: 'border-box'
27
+ },
28
+ table: function table(theme) {
29
+ return {
30
30
  // temporary right-to-left patch, waiting for
31
31
  // https://github.com/bvaughn/react-virtualized/issues/454
32
32
  '& .ReactVirtualized__Table__headerRow': {
33
33
  flip: false,
34
34
  paddingRight: theme.direction === 'rtl' ? '0 !important' : undefined
35
35
  }
36
- },
37
- header: {
38
- variant: 'header'
39
- }
40
- };
36
+ };
37
+ },
38
+ header: {
39
+ variant: 'header'
40
+ }
41
41
  };
42
- var VirtualizedTable = (0, _withStyles["default"])(styles)(_MuiVirtualizedTable["default"]);
42
+ var VirtualizedTable = (0, _system.styled)(_MuiVirtualizedTable["default"])(styles);
43
43
  var LogTable = function LogTable(_ref) {
44
44
  var logs = _ref.logs,
45
45
  onRowClick = _ref.onRowClick;
@@ -3,14 +3,14 @@
3
3
  exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
7
+ var _system = require("@mui/system");
6
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
7
- var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
8
9
  var _TreeItem = _interopRequireDefault(require("@mui/lab/TreeItem"));
9
10
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
10
11
  var _Label = _interopRequireDefault(require("@mui/icons-material/Label"));
11
12
  var _reportTreeViewContext = _interopRequireDefault(require("./report-tree-view-context"));
12
- var _system = require("@mui/system");
13
- var _excluded = ["labelText", "labelIconColor"];
13
+ var _excluded = ["labelText", "labelIconColor", "className"];
14
14
  /**
15
15
  * Copyright (c) 2021, RTE (http://www.rte-france.com)
16
16
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -22,96 +22,108 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
22
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
23
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
24
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
25
- var useReportItemStyles = (0, _makeStyles["default"])(function (theme) {
26
- return {
27
- root: {
25
+ var styles = {
26
+ root: function root(theme) {
27
+ return {
28
28
  color: theme.palette.text.secondary,
29
- '&:hover > $content': {
29
+ '&:hover > .MuiTreeItem-content': {
30
30
  backgroundColor: theme.palette.action.hover
31
31
  }
32
- },
33
- content: {
32
+ };
33
+ },
34
+ content: function content(theme) {
35
+ return {
34
36
  color: theme.palette.text.secondary,
35
37
  borderRadius: theme.spacing(2),
36
38
  width: 'fit-content',
37
39
  paddingRight: theme.spacing(1),
38
40
  fontWeight: theme.typography.fontWeightMedium,
39
- '&$expanded': {
41
+ '&.Mui-expanded': {
40
42
  fontWeight: theme.typography.fontWeightRegular
41
43
  },
42
- /* &&.Mui-focused to increase specifity because mui5 has a rule for &.Mui-selected.Mui-focused */
43
- /* &&$selected to increase specifity because we have a rule for &:hover > $content on root */
44
- '&&.Mui-focused, &&$selected': {
44
+ /* &.MuiTreeItem-content.Mui-focused to increase specifity because mui5 has a rule for &.Mui-selected.Mui-focused */
45
+ '&.MuiTreeItem-content.Mui-focused, &.Mui-selected': {
45
46
  backgroundColor: "var(--tree-view-bg-color, " + theme.palette.action.selected + ")",
46
47
  color: 'var(--tree-view-color)'
47
48
  },
48
49
  // same as mui v4 behavior on label text only right after clicking in contrast to after moving away with arrow keys.
49
- '&$selected $label:hover, &$selected.Mui-focused $label': {
50
+ '&.Mui-selected .MuiTreeItem-label:hover, &.Mui-selected.Mui-focused .MuiTreeItem-label': {
50
51
  borderRadius: theme.spacing(2),
51
52
  backgroundColor: (0, _system.alpha)(theme.palette.primary.main, theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity)
52
53
  },
53
- '&.Mui-focused $label, &:hover $label, &$selected $label': {
54
+ '&.Mui-focused .MuiTreeItem-label, &:hover .MuiTreeItem-label, &Mui-selected .MuiTreeItem-label': {
54
55
  backgroundColor: 'transparent'
55
56
  }
56
- },
57
- group: {
58
- marginLeft: 10,
59
- '& $content': {
57
+ };
58
+ },
59
+ group: function group(theme) {
60
+ return {
61
+ marginLeft: '10px',
62
+ '& .MuiTreeItem-content': {
60
63
  paddingLeft: theme.spacing(2)
61
64
  }
62
- },
63
- expanded: {},
64
- selected: {},
65
- label: {
66
- fontWeight: 'inherit',
67
- color: 'inherit'
68
- },
69
- labelRoot: {
65
+ };
66
+ },
67
+ expanded: {},
68
+ selected: {},
69
+ label: {
70
+ fontWeight: 'inherit',
71
+ color: 'inherit'
72
+ },
73
+ labelRoot: function labelRoot(theme) {
74
+ return {
70
75
  display: 'flex',
71
76
  alignItems: 'center',
72
77
  padding: theme.spacing(0.5, 0)
73
- },
74
- labelRootHighlighted: {
78
+ };
79
+ },
80
+ labelRootHighlighted: function labelRootHighlighted(theme) {
81
+ return {
75
82
  display: 'flex',
76
83
  alignItems: 'center',
77
84
  padding: theme.spacing(0.5, 0),
78
85
  backgroundColor: theme.palette.action.selected
79
- },
80
- labelIcon: {
86
+ };
87
+ },
88
+ labelIcon: function labelIcon(theme) {
89
+ return {
81
90
  marginRight: theme.spacing(1)
82
- },
83
- labelText: {
91
+ };
92
+ },
93
+ labelText: function labelText(theme) {
94
+ return {
84
95
  fontWeight: 'inherit',
85
96
  marginRight: theme.spacing(2)
86
- }
87
- };
88
- });
97
+ };
98
+ }
99
+ };
89
100
  var ReportItem = function ReportItem(props) {
90
101
  // using a context because TreeItem uses useMemo on this. See report-viewer.js for the provider
91
102
  var _useContext = (0, _react.useContext)(_reportTreeViewContext["default"]),
92
103
  isHighlighted = _useContext.isHighlighted;
93
104
  var highlighted = isHighlighted ? isHighlighted(props.nodeId) : false;
94
- var classes = useReportItemStyles();
95
105
  var labelText = props.labelText,
96
106
  labelIconColor = props.labelIconColor,
107
+ className = props.className,
97
108
  other = _objectWithoutPropertiesLoose(props, _excluded);
98
109
  return /*#__PURE__*/_react["default"].createElement(_TreeItem["default"], _extends({
99
- classes: {
100
- root: classes.root,
101
- content: classes.content,
102
- expanded: classes.expanded,
103
- selected: classes.selected,
104
- group: classes.group,
105
- label: classes.label
110
+ className: className,
111
+ sx: {
112
+ '&': styles.root,
113
+ '& .MuiTreeItem-content': styles.content,
114
+ '& .Mui-expanded': styles.expanded,
115
+ '& .Mui-selected': styles.selected,
116
+ '& .MuiTreeItem-group': styles.group,
117
+ '& .MuiTreeItem-label': styles.label
106
118
  },
107
- label: /*#__PURE__*/_react["default"].createElement("div", {
108
- className: highlighted ? classes.labelRootHighlighted : classes.labelRoot
119
+ label: /*#__PURE__*/_react["default"].createElement(_Box["default"], {
120
+ sx: highlighted ? styles.labelRootHighlighted : styles.labelRoot
109
121
  }, /*#__PURE__*/_react["default"].createElement(_Label["default"], {
110
122
  htmlColor: labelIconColor,
111
- className: classes.labelIcon
123
+ sx: styles.labelIcon
112
124
  }), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
113
125
  variant: "body2",
114
- className: classes.labelText
126
+ sx: styles.labelText
115
127
  }, labelText))
116
128
  }, other));
117
129
  };
@@ -121,6 +133,6 @@ ReportItem.propTypes = process.env.NODE_ENV !== "production" ? {
121
133
  labelInfo: _propTypes["default"].string,
122
134
  labelText: _propTypes["default"].string.isRequired
123
135
  } : {};
124
- var _default = ReportItem;
136
+ var _default = (0, _system.styled)(ReportItem)({});
125
137
  exports["default"] = _default;
126
138
  module.exports = exports.default;