@mui/x-data-grid-generator 7.0.0-beta.3 → 7.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +357 -22
  2. package/columns/employees.columns.js +2 -0
  3. package/hooks/useQuery.d.ts +6 -0
  4. package/index.js +1 -1
  5. package/modern/columns/employees.columns.js +2 -0
  6. package/modern/index.js +1 -1
  7. package/modern/renderer/renderProgress.js +11 -4
  8. package/node/columns/employees.columns.js +2 -0
  9. package/node/index.js +1 -1
  10. package/node/renderer/renderProgress.js +11 -4
  11. package/package.json +2 -2
  12. package/renderer/renderProgress.js +11 -4
  13. package/legacy/columns/commodities.columns.js +0 -253
  14. package/legacy/columns/employees.columns.js +0 -141
  15. package/legacy/columns/index.js +0 -2
  16. package/legacy/hooks/index.js +0 -4
  17. package/legacy/hooks/useBasicDemoData.js +0 -7
  18. package/legacy/hooks/useDemoData.js +0 -235
  19. package/legacy/hooks/useMovieData.js +0 -497
  20. package/legacy/hooks/useQuery.js +0 -262
  21. package/legacy/index.js +0 -11
  22. package/legacy/renderer/index.js +0 -16
  23. package/legacy/renderer/renderAvatar.js +0 -14
  24. package/legacy/renderer/renderCountry.js +0 -47
  25. package/legacy/renderer/renderEditCountry.js +0 -102
  26. package/legacy/renderer/renderEditCurrency.js +0 -99
  27. package/legacy/renderer/renderEditIncoterm.js +0 -91
  28. package/legacy/renderer/renderEditProgress.js +0 -110
  29. package/legacy/renderer/renderEditRating.js +0 -68
  30. package/legacy/renderer/renderEditStatus.js +0 -116
  31. package/legacy/renderer/renderEmail.js +0 -12
  32. package/legacy/renderer/renderIncoterm.js +0 -39
  33. package/legacy/renderer/renderLink.js +0 -31
  34. package/legacy/renderer/renderPnl.js +0 -35
  35. package/legacy/renderer/renderProgress.js +0 -63
  36. package/legacy/renderer/renderRating.js +0 -37
  37. package/legacy/renderer/renderStatus.js +0 -73
  38. package/legacy/renderer/renderTotalPrice.js +0 -48
  39. package/legacy/services/asyncWorker.js +0 -26
  40. package/legacy/services/basic-data-service.js +0 -37
  41. package/legacy/services/gridColDefGenerator.js +0 -1
  42. package/legacy/services/index.js +0 -4
  43. package/legacy/services/random-generator.js +0 -213
  44. package/legacy/services/real-data-service.js +0 -51
  45. package/legacy/services/static-data.js +0 -1260
  46. package/legacy/services/tree-data-generator.js +0 -78
@@ -1,110 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
- import * as React from 'react';
5
- import clsx from 'clsx';
6
- import { useGridApiContext } from '@mui/x-data-grid-premium';
7
- import Slider, { sliderClasses } from '@mui/material/Slider';
8
- import Tooltip from '@mui/material/Tooltip';
9
- import { unstable_debounce as debounce } from '@mui/utils';
10
- import { alpha, styled } from '@mui/material/styles';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- var StyledSlider = styled(Slider)(function (_ref) {
13
- var theme = _ref.theme;
14
- return _defineProperty(_defineProperty(_defineProperty({
15
- display: 'flex',
16
- height: '100%',
17
- width: '100%',
18
- alignItems: 'center',
19
- justifyContent: 'center',
20
- padding: 0,
21
- borderRadius: 0
22
- }, "& .".concat(sliderClasses.rail), {
23
- height: '100%',
24
- backgroundColor: 'transparent'
25
- }), "& .".concat(sliderClasses.track), {
26
- height: '100%',
27
- transition: theme.transitions.create('background-color', {
28
- duration: theme.transitions.duration.shorter
29
- }),
30
- '&.low': {
31
- backgroundColor: '#f44336'
32
- },
33
- '&.medium': {
34
- backgroundColor: '#efbb5aa3'
35
- },
36
- '&.high': {
37
- backgroundColor: '#088208a3'
38
- }
39
- }), "& .".concat(sliderClasses.thumb), {
40
- height: '100%',
41
- width: 5,
42
- borderRadius: 0,
43
- marginTop: 0,
44
- backgroundColor: alpha('#000000', 0.2)
45
- });
46
- });
47
- function ValueLabelComponent(props) {
48
- var children = props.children,
49
- open = props.open,
50
- value = props.value;
51
- return /*#__PURE__*/_jsx(Tooltip, {
52
- open: open,
53
- enterTouchDelay: 0,
54
- placement: "top",
55
- title: value,
56
- children: children
57
- });
58
- }
59
- function EditProgress(props) {
60
- var id = props.id,
61
- value = props.value,
62
- field = props.field;
63
- var _React$useState = React.useState(Number(value)),
64
- _React$useState2 = _slicedToArray(_React$useState, 2),
65
- valueState = _React$useState2[0],
66
- setValueState = _React$useState2[1];
67
- var apiRef = useGridApiContext();
68
- var updateCellEditProps = React.useCallback(function (newValue) {
69
- apiRef.current.setEditCellValue({
70
- id: id,
71
- field: field,
72
- value: newValue
73
- });
74
- }, [apiRef, field, id]);
75
- var debouncedUpdateCellEditProps = React.useMemo(function () {
76
- return debounce(updateCellEditProps, 60);
77
- }, [updateCellEditProps]);
78
- var handleChange = function handleChange(event, newValue) {
79
- setValueState(newValue);
80
- debouncedUpdateCellEditProps(newValue);
81
- };
82
- React.useEffect(function () {
83
- setValueState(Number(value));
84
- }, [value]);
85
- var handleRef = function handleRef(element) {
86
- if (element) {
87
- element.querySelector('[type="range"]').focus();
88
- }
89
- };
90
- return /*#__PURE__*/_jsx(StyledSlider, {
91
- ref: handleRef,
92
- classes: {
93
- track: clsx(valueState < 0.3 && "low", valueState >= 0.3 && valueState <= 0.7 && "medium", valueState > 0.7 && "high")
94
- },
95
- value: valueState,
96
- max: 1,
97
- step: 0.00001,
98
- onChange: handleChange,
99
- components: {
100
- ValueLabel: ValueLabelComponent
101
- },
102
- valueLabelDisplay: "auto",
103
- valueLabelFormat: function valueLabelFormat(newValue) {
104
- return "".concat((newValue * 100).toLocaleString(), " %");
105
- }
106
- });
107
- }
108
- export function renderEditProgress(params) {
109
- return /*#__PURE__*/_jsx(EditProgress, _extends({}, params));
110
- }
@@ -1,68 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import * as React from 'react';
5
- import Box from '@mui/material/Box';
6
- import Rating from '@mui/material/Rating';
7
- import { useGridApiContext } from '@mui/x-data-grid-premium';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
- function EditRating(props) {
11
- var id = props.id,
12
- value = props.value,
13
- field = props.field;
14
- var apiRef = useGridApiContext();
15
- var handleChange = /*#__PURE__*/function () {
16
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
17
- return _regeneratorRuntime.wrap(function _callee$(_context) {
18
- while (1) switch (_context.prev = _context.next) {
19
- case 0:
20
- _context.next = 2;
21
- return apiRef.current.setEditCellValue({
22
- id: id,
23
- field: field,
24
- value: Number(event.target.value)
25
- }, event);
26
- case 2:
27
- apiRef.current.stopCellEditMode({
28
- id: id,
29
- field: field
30
- });
31
- case 3:
32
- case "end":
33
- return _context.stop();
34
- }
35
- }, _callee);
36
- }));
37
- return function handleChange(_x) {
38
- return _ref.apply(this, arguments);
39
- };
40
- }();
41
- var handleRef = function handleRef(element) {
42
- if (element) {
43
- element.querySelector("input[value=\"".concat(value, "\"]")).focus();
44
- }
45
- };
46
- return /*#__PURE__*/_jsxs(Box, {
47
- sx: {
48
- display: 'flex',
49
- alignItems: 'center',
50
- lineHeight: '24px',
51
- color: 'text.secondary',
52
- mr: 1
53
- },
54
- children: [/*#__PURE__*/_jsx(Rating, {
55
- ref: handleRef,
56
- name: "rating",
57
- value: Number(value),
58
- precision: 1,
59
- onChange: handleChange,
60
- sx: {
61
- mr: 1
62
- }
63
- }), Number(value)]
64
- });
65
- }
66
- export function renderEditRating(params) {
67
- return /*#__PURE__*/_jsx(EditRating, _extends({}, params));
68
- }
@@ -1,116 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import * as React from 'react';
5
- import { useGridApiContext, useGridRootProps, GridEditModes } from '@mui/x-data-grid-premium';
6
- import Select from '@mui/material/Select';
7
- import MenuItem from '@mui/material/MenuItem';
8
- import ListItemIcon from '@mui/material/ListItemIcon';
9
- import ListItemText from '@mui/material/ListItemText';
10
- import ReportProblemIcon from '@mui/icons-material/ReportProblem';
11
- import InfoIcon from '@mui/icons-material/Info';
12
- import AutorenewIcon from '@mui/icons-material/Autorenew';
13
- import DoneIcon from '@mui/icons-material/Done';
14
- import { STATUS_OPTIONS } from '../services/static-data';
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- import { jsxs as _jsxs } from "react/jsx-runtime";
17
- function EditStatus(props) {
18
- var id = props.id,
19
- value = props.value,
20
- field = props.field;
21
- var rootProps = useGridRootProps();
22
- var apiRef = useGridApiContext();
23
- var handleChange = /*#__PURE__*/function () {
24
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
25
- var isValid;
26
- return _regeneratorRuntime.wrap(function _callee$(_context) {
27
- while (1) switch (_context.prev = _context.next) {
28
- case 0:
29
- _context.next = 2;
30
- return apiRef.current.setEditCellValue({
31
- id: id,
32
- field: field,
33
- value: event.target.value
34
- });
35
- case 2:
36
- isValid = _context.sent;
37
- if (isValid && rootProps.editMode === GridEditModes.Cell) {
38
- apiRef.current.stopCellEditMode({
39
- id: id,
40
- field: field,
41
- cellToFocusAfter: 'below'
42
- });
43
- }
44
- case 4:
45
- case "end":
46
- return _context.stop();
47
- }
48
- }, _callee);
49
- }));
50
- return function handleChange(_x) {
51
- return _ref.apply(this, arguments);
52
- };
53
- }();
54
- var handleClose = function handleClose(event, reason) {
55
- if (reason === 'backdropClick') {
56
- apiRef.current.stopCellEditMode({
57
- id: id,
58
- field: field,
59
- ignoreModifications: true
60
- });
61
- }
62
- };
63
- return /*#__PURE__*/_jsx(Select, {
64
- value: value,
65
- onChange: handleChange,
66
- MenuProps: {
67
- onClose: handleClose
68
- },
69
- sx: {
70
- height: '100%',
71
- '& .MuiSelect-select': {
72
- display: 'flex',
73
- alignItems: 'center',
74
- pl: 1
75
- }
76
- },
77
- autoFocus: true,
78
- fullWidth: true,
79
- open: true,
80
- children: STATUS_OPTIONS.map(function (option) {
81
- var IconComponent = null;
82
- if (option === 'Rejected') {
83
- IconComponent = ReportProblemIcon;
84
- } else if (option === 'Open') {
85
- IconComponent = InfoIcon;
86
- } else if (option === 'PartiallyFilled') {
87
- IconComponent = AutorenewIcon;
88
- } else if (option === 'Filled') {
89
- IconComponent = DoneIcon;
90
- }
91
- var label = option;
92
- if (option === 'PartiallyFilled') {
93
- label = 'Partially Filled';
94
- }
95
- return /*#__PURE__*/_jsxs(MenuItem, {
96
- value: option,
97
- children: [/*#__PURE__*/_jsx(ListItemIcon, {
98
- sx: {
99
- minWidth: 36
100
- },
101
- children: /*#__PURE__*/_jsx(IconComponent, {
102
- fontSize: "small"
103
- })
104
- }), /*#__PURE__*/_jsx(ListItemText, {
105
- primary: label,
106
- sx: {
107
- overflow: 'hidden'
108
- }
109
- })]
110
- }, option);
111
- })
112
- });
113
- }
114
- export function renderEditStatus(params) {
115
- return /*#__PURE__*/_jsx(EditStatus, _extends({}, params));
116
- }
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
- import { DemoLink } from './renderLink';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- export function renderEmail(params) {
5
- var _params$value;
6
- var email = (_params$value = params.value) != null ? _params$value : '';
7
- return /*#__PURE__*/_jsx(DemoLink, {
8
- href: "mailto:".concat(email),
9
- tabIndex: params.tabIndex,
10
- children: email
11
- });
12
- }
@@ -1,39 +0,0 @@
1
- import * as React from 'react';
2
- import Tooltip from '@mui/material/Tooltip';
3
- import Box from '@mui/material/Box';
4
- import InfoIcon from '@mui/icons-material/Info';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- var Incoterm = /*#__PURE__*/React.memo(function Incoterm(props) {
8
- var value = props.value;
9
- if (!value) {
10
- return null;
11
- }
12
- var valueStr = value.toString();
13
- var tooltip = valueStr.slice(valueStr.indexOf('(') + 1, valueStr.indexOf(')'));
14
- var code = valueStr.slice(0, valueStr.indexOf('(')).trim();
15
- return /*#__PURE__*/_jsxs(Box, {
16
- sx: {
17
- display: 'flex',
18
- alignItems: 'center',
19
- justifyContent: 'space-between'
20
- },
21
- children: [/*#__PURE__*/_jsx("span", {
22
- children: code
23
- }), /*#__PURE__*/_jsx(Tooltip, {
24
- title: tooltip,
25
- children: /*#__PURE__*/_jsx(InfoIcon, {
26
- sx: {
27
- color: '#2196f3',
28
- alignSelf: 'center',
29
- ml: '8px'
30
- }
31
- })
32
- })]
33
- });
34
- });
35
- export function renderIncoterm(params) {
36
- return /*#__PURE__*/_jsx(Incoterm, {
37
- value: params.value
38
- });
39
- }
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { styled } from '@mui/material/styles';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- var Link = styled('a')({
5
- textOverflow: 'ellipsis',
6
- whiteSpace: 'nowrap',
7
- overflow: 'hidden',
8
- color: 'inherit'
9
- });
10
- export var DemoLink = /*#__PURE__*/React.memo(function DemoLink(props) {
11
- var handleClick = function handleClick(event) {
12
- event.preventDefault();
13
- event.stopPropagation();
14
- };
15
- return /*#__PURE__*/_jsx(Link, {
16
- tabIndex: props.tabIndex,
17
- onClick: handleClick,
18
- href: props.href,
19
- children: props.children
20
- });
21
- });
22
- export function renderLink(params) {
23
- if (params.value == null) {
24
- return '';
25
- }
26
- return /*#__PURE__*/_jsx(DemoLink, {
27
- href: params.value,
28
- tabIndex: params.tabIndex,
29
- children: params.value
30
- });
31
- }
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- import clsx from 'clsx';
3
- import { styled } from '@mui/material/styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- var Value = styled('div')(function (_ref) {
6
- var theme = _ref.theme;
7
- return {
8
- width: '100%',
9
- fontVariantNumeric: 'tabular-nums',
10
- '&.positive': {
11
- color: theme.palette.mode === 'light' ? theme.palette.success.dark : theme.palette.success.light
12
- },
13
- '&.negative': {
14
- color: theme.palette.mode === 'light' ? theme.palette.error.dark : theme.palette.error.light
15
- }
16
- };
17
- });
18
- function pnlFormatter(value) {
19
- return value < 0 ? "(".concat(Math.abs(value).toLocaleString(), ")") : value.toLocaleString();
20
- }
21
- var Pnl = /*#__PURE__*/React.memo(function Pnl(props) {
22
- var value = props.value;
23
- return /*#__PURE__*/_jsx(Value, {
24
- className: clsx(value > 0 && "positive", value < 0 && "negative"),
25
- children: pnlFormatter(value)
26
- });
27
- });
28
- export function renderPnl(params) {
29
- if (params.value == null) {
30
- return '';
31
- }
32
- return /*#__PURE__*/_jsx(Pnl, {
33
- value: params.value
34
- });
35
- }
@@ -1,63 +0,0 @@
1
- import * as React from 'react';
2
- import clsx from 'clsx';
3
- import { styled } from '@mui/material/styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- var Root = styled('div')(function (_ref) {
7
- var theme = _ref.theme;
8
- return {
9
- border: "1px solid ".concat((theme.vars || theme).palette.divider),
10
- position: 'relative',
11
- overflow: 'hidden',
12
- width: '100%',
13
- height: 26,
14
- borderRadius: 2
15
- };
16
- });
17
- var Value = styled('div')({
18
- position: 'absolute',
19
- lineHeight: '24px',
20
- width: '100%',
21
- display: 'flex',
22
- justifyContent: 'center'
23
- });
24
- var Bar = styled('div')({
25
- height: '100%',
26
- '&.low': {
27
- backgroundColor: '#f44336'
28
- },
29
- '&.medium': {
30
- backgroundColor: '#efbb5aa3'
31
- },
32
- '&.high': {
33
- backgroundColor: '#088208a3'
34
- }
35
- });
36
- var ProgressBar = /*#__PURE__*/React.memo(function ProgressBar(props) {
37
- var value = props.value;
38
- var valueInPercent = value * 100;
39
- return /*#__PURE__*/_jsxs(Root, {
40
- children: [/*#__PURE__*/_jsx(Value, {
41
- children: "".concat(valueInPercent.toLocaleString(), " %")
42
- }), /*#__PURE__*/_jsx(Bar, {
43
- className: clsx(valueInPercent < 30 && "low", valueInPercent >= 30 && valueInPercent <= 70 && "medium", valueInPercent > 70 && "high"),
44
- style: {
45
- maxWidth: "".concat(valueInPercent, "%")
46
- }
47
- })]
48
- });
49
- });
50
- export function renderProgress(params) {
51
- if (params.value == null) {
52
- return '';
53
- }
54
-
55
- // If the aggregated value does not have the same unit as the other cell
56
- // Then we fall back to the default rendering based on `valueGetter` instead of rendering a progress bar.
57
- if (params.aggregation && !params.aggregation.hasCellUnit) {
58
- return null;
59
- }
60
- return /*#__PURE__*/_jsx(ProgressBar, {
61
- value: params.value
62
- });
63
- }
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import Box from '@mui/material/Box';
3
- import Rating from '@mui/material/Rating';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- var RatingValue = /*#__PURE__*/React.memo(function RatingValue(props) {
7
- var value = props.value;
8
- return /*#__PURE__*/_jsxs(Box, {
9
- sx: {
10
- display: 'flex',
11
- alignItems: 'center',
12
- lineHeight: '24px',
13
- color: 'text.secondary'
14
- },
15
- children: [/*#__PURE__*/_jsx(Rating, {
16
- value: value,
17
- sx: {
18
- mr: 1
19
- },
20
- readOnly: true
21
- }), " ", Math.round(Number(value) * 10) / 10]
22
- });
23
- });
24
- export function renderRating(params) {
25
- if (params.value == null) {
26
- return '';
27
- }
28
-
29
- // If the aggregated value does not have the same unit as the other cell
30
- // Then we fall back to the default rendering based on `valueGetter` instead of rendering the total price UI.
31
- if (params.aggregation && !params.aggregation.hasCellUnit) {
32
- return null;
33
- }
34
- return /*#__PURE__*/_jsx(RatingValue, {
35
- value: params.value
36
- });
37
- }
@@ -1,73 +0,0 @@
1
- import * as React from 'react';
2
- import ReportProblemIcon from '@mui/icons-material/ReportProblem';
3
- import InfoIcon from '@mui/icons-material/Info';
4
- import AutorenewIcon from '@mui/icons-material/Autorenew';
5
- import DoneIcon from '@mui/icons-material/Done';
6
- import Chip from '@mui/material/Chip';
7
- import { styled } from '@mui/material/styles';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- var StyledChip = styled(Chip)(function (_ref) {
10
- var theme = _ref.theme;
11
- return {
12
- justifyContent: 'left',
13
- '& .icon': {
14
- color: 'inherit'
15
- },
16
- '&.Open': {
17
- color: (theme.vars || theme).palette.info.dark,
18
- border: "1px solid ".concat((theme.vars || theme).palette.info.main)
19
- },
20
- '&.Filled': {
21
- color: (theme.vars || theme).palette.success.dark,
22
- border: "1px solid ".concat((theme.vars || theme).palette.success.main)
23
- },
24
- '&.PartiallyFilled': {
25
- color: (theme.vars || theme).palette.warning.dark,
26
- border: "1px solid ".concat((theme.vars || theme).palette.warning.main)
27
- },
28
- '&.Rejected': {
29
- color: (theme.vars || theme).palette.error.dark,
30
- border: "1px solid ".concat((theme.vars || theme).palette.error.main)
31
- }
32
- };
33
- });
34
- var Status = /*#__PURE__*/React.memo(function (props) {
35
- var status = props.status;
36
- var icon = null;
37
- if (status === 'Rejected') {
38
- icon = /*#__PURE__*/_jsx(ReportProblemIcon, {
39
- className: "icon"
40
- });
41
- } else if (status === 'Open') {
42
- icon = /*#__PURE__*/_jsx(InfoIcon, {
43
- className: "icon"
44
- });
45
- } else if (status === 'PartiallyFilled') {
46
- icon = /*#__PURE__*/_jsx(AutorenewIcon, {
47
- className: "icon"
48
- });
49
- } else if (status === 'Filled') {
50
- icon = /*#__PURE__*/_jsx(DoneIcon, {
51
- className: "icon"
52
- });
53
- }
54
- var label = status;
55
- if (status === 'PartiallyFilled') {
56
- label = 'Partially Filled';
57
- }
58
- return /*#__PURE__*/_jsx(StyledChip, {
59
- className: status,
60
- icon: icon,
61
- size: "small",
62
- label: label,
63
- variant: "outlined"
64
- });
65
- });
66
- export function renderStatus(params) {
67
- if (params.value == null) {
68
- return '';
69
- }
70
- return /*#__PURE__*/_jsx(Status, {
71
- status: params.value
72
- });
73
- }
@@ -1,48 +0,0 @@
1
- import * as React from 'react';
2
- import clsx from 'clsx';
3
- import { alpha, styled } from '@mui/material/styles';
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- var Value = styled('div')(function (_ref) {
6
- var theme = _ref.theme;
7
- return {
8
- width: '100%',
9
- height: '100%',
10
- lineHeight: '100%',
11
- paddingRight: 8,
12
- fontVariantNumeric: 'tabular-nums',
13
- display: 'flex',
14
- alignItems: 'center',
15
- justifyContent: 'flex-end',
16
- '&.good': {
17
- backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.success.mainChannel, " / 0.3)") : alpha(theme.palette.success.main, 0.3)
18
- },
19
- '&.bad': {
20
- backgroundColor: theme.vars ? "rgba(".concat(theme.vars.palette.error.mainChannel, " / 0.3)") : alpha(theme.palette.error.main, 0.3)
21
- }
22
- };
23
- });
24
- var currencyFormatter = new Intl.NumberFormat('en-US', {
25
- style: 'currency',
26
- currency: 'USD'
27
- });
28
- var TotalPrice = /*#__PURE__*/React.memo(function TotalPrice(props) {
29
- var value = props.value;
30
- return /*#__PURE__*/_jsx(Value, {
31
- className: clsx(value > 1000000 && "good", value < 1000000 && "bad"),
32
- children: currencyFormatter.format(value)
33
- });
34
- });
35
- export function renderTotalPrice(params) {
36
- if (params.value == null) {
37
- return '';
38
- }
39
-
40
- // If the aggregated value does not have the same unit as the other cell
41
- // Then we fall back to the default rendering based on `valueGetter` instead of rendering the total price UI.
42
- if (params.aggregation && !params.aggregation.hasCellUnit) {
43
- return null;
44
- }
45
- return /*#__PURE__*/_jsx(TotalPrice, {
46
- value: params.value
47
- });
48
- }
@@ -1,26 +0,0 @@
1
- export default function asyncWorker(_ref) {
2
- var work = _ref.work,
3
- tasks = _ref.tasks,
4
- done = _ref.done;
5
- var myNonEssentialWork = function myNonEssentialWork(deadline) {
6
- // If there is a surplus time in the frame, or timeout
7
- while ((deadline.timeRemaining() > 0 || deadline.didTimeout) && tasks.current > 0) {
8
- work();
9
- }
10
- if (tasks.current > 0) {
11
- requestIdleCallback(myNonEssentialWork);
12
- } else {
13
- done();
14
- }
15
- };
16
-
17
- // Don't use requestIdleCallback if the time is mock, better to run synchronously in such case.
18
- if (typeof requestIdleCallback === 'function' && !requestIdleCallback.clock) {
19
- requestIdleCallback(myNonEssentialWork);
20
- } else {
21
- while (tasks.current > 0) {
22
- work();
23
- }
24
- done();
25
- }
26
- }