@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,262 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
- import _extends from "@babel/runtime/helpers/esm/extends";
5
- import _regeneratorRuntime from "@babel/runtime/regenerator";
6
- import * as React from 'react';
7
- import { getGridDefaultColumnTypes, GridLogicOperator } from '@mui/x-data-grid-pro';
8
- import { isDeepEqual } from '@mui/x-data-grid/internals';
9
- import { useDemoData, getColumnsFromOptions, getInitialState } from './useDemoData';
10
- import { randomInt } from '../services/random-generator';
11
- var apiRef = {};
12
- var simplifiedValueGetter = function simplifiedValueGetter(field, colDef) {
13
- return function (row) {
14
- var _colDef$valueGetter;
15
- return ((_colDef$valueGetter = colDef.valueGetter) == null ? void 0 : _colDef$valueGetter.call(colDef, row[row.id], row, colDef, apiRef)) || row[field];
16
- };
17
- };
18
- var getRowComparator = function getRowComparator(sortModel, columnsWithDefaultColDef) {
19
- if (!sortModel) {
20
- var _comparator = function _comparator() {
21
- return 0;
22
- };
23
- return _comparator;
24
- }
25
- var sortOperators = sortModel.map(function (sortItem) {
26
- var columnField = sortItem.field;
27
- var colDef = columnsWithDefaultColDef.find(function (_ref) {
28
- var field = _ref.field;
29
- return field === columnField;
30
- });
31
- return _extends({}, sortItem, {
32
- valueGetter: simplifiedValueGetter(columnField, colDef),
33
- sortComparator: colDef.sortComparator
34
- });
35
- });
36
- var comparator = function comparator(row1, row2) {
37
- return sortOperators.reduce(function (acc, _ref2) {
38
- var valueGetter = _ref2.valueGetter,
39
- sort = _ref2.sort,
40
- sortComparator = _ref2.sortComparator;
41
- if (acc !== 0) {
42
- return acc;
43
- }
44
- var v1 = valueGetter(row1);
45
- var v2 = valueGetter(row2);
46
- return sort === 'desc' ? -1 * sortComparator(v1, v2) : sortComparator(v1, v2);
47
- }, 0);
48
- };
49
- return comparator;
50
- };
51
- var getFilteredRows = function getFilteredRows(rows, filterModel, columnsWithDefaultColDef) {
52
- if (filterModel === undefined || filterModel.items.length === 0) {
53
- return rows;
54
- }
55
- var valueGetters = filterModel.items.map(function (_ref3) {
56
- var field = _ref3.field;
57
- return simplifiedValueGetter(field, columnsWithDefaultColDef.find(function (column) {
58
- return column.field === field;
59
- }));
60
- });
61
- var filterFunctions = filterModel.items.map(function (filterItem) {
62
- var field = filterItem.field,
63
- operator = filterItem.operator;
64
- var colDef = columnsWithDefaultColDef.find(function (column) {
65
- return column.field === field;
66
- });
67
- var filterOperator = colDef.filterOperators.find(function (_ref4) {
68
- var value = _ref4.value;
69
- return operator === value;
70
- });
71
- var parsedValue = filterItem.value;
72
- if (colDef.valueParser) {
73
- var _filterItem$value;
74
- var parser = colDef.valueParser;
75
- parsedValue = Array.isArray(filterItem.value) ? (_filterItem$value = filterItem.value) == null ? void 0 : _filterItem$value.map(function (x) {
76
- return parser(x);
77
- }) : parser(filterItem.value);
78
- }
79
- return filterOperator == null ? void 0 : filterOperator.getApplyFilterFn({
80
- filterItem: filterItem,
81
- value: parsedValue
82
- }, colDef);
83
- });
84
- if (filterModel.logicOperator === GridLogicOperator.Or) {
85
- return rows.filter(function (row) {
86
- return filterModel.items.some(function (_, index) {
87
- var value = valueGetters[index](row);
88
- return filterFunctions[index] === null ? true : filterFunctions[index]({
89
- value: value
90
- });
91
- });
92
- });
93
- }
94
- return rows.filter(function (row) {
95
- return filterModel.items.every(function (_, index) {
96
- var value = valueGetters[index](row);
97
- return filterFunctions[index] === null ? true : filterFunctions[index]({
98
- value: value
99
- });
100
- });
101
- });
102
- };
103
-
104
- /**
105
- * Simulates server data loading
106
- */
107
- export var loadServerRows = function loadServerRows(rows, queryOptions, serverOptions, columnsWithDefaultColDef) {
108
- var _serverOptions$minDel = serverOptions.minDelay,
109
- minDelay = _serverOptions$minDel === void 0 ? 100 : _serverOptions$minDel,
110
- _serverOptions$maxDel = serverOptions.maxDelay,
111
- maxDelay = _serverOptions$maxDel === void 0 ? 300 : _serverOptions$maxDel,
112
- useCursorPagination = serverOptions.useCursorPagination;
113
- if (maxDelay < minDelay) {
114
- throw new Error('serverOptions.minDelay is larger than serverOptions.maxDelay ');
115
- }
116
- var delay = randomInt(minDelay, maxDelay);
117
- var cursor = queryOptions.cursor,
118
- _queryOptions$page = queryOptions.page,
119
- page = _queryOptions$page === void 0 ? 0 : _queryOptions$page,
120
- pageSize = queryOptions.pageSize;
121
- var nextCursor;
122
- var firstRowIndex;
123
- var lastRowIndex;
124
- var filteredRows = getFilteredRows(rows, queryOptions.filterModel, columnsWithDefaultColDef);
125
- var rowComparator = getRowComparator(queryOptions.sortModel, columnsWithDefaultColDef);
126
- filteredRows = _toConsumableArray(filteredRows).sort(rowComparator);
127
- var totalRowCount = filteredRows.length;
128
- if (!pageSize) {
129
- firstRowIndex = 0;
130
- lastRowIndex = filteredRows.length;
131
- } else if (useCursorPagination) {
132
- firstRowIndex = cursor ? filteredRows.findIndex(function (_ref5) {
133
- var id = _ref5.id;
134
- return id === cursor;
135
- }) : 0;
136
- firstRowIndex = Math.max(firstRowIndex, 0); // if cursor not found return 0
137
- lastRowIndex = firstRowIndex + pageSize;
138
- nextCursor = lastRowIndex >= filteredRows.length ? undefined : filteredRows[lastRowIndex].id;
139
- } else {
140
- firstRowIndex = page * pageSize;
141
- lastRowIndex = (page + 1) * pageSize;
142
- }
143
- var response = {
144
- returnedRows: filteredRows.slice(firstRowIndex, lastRowIndex),
145
- nextCursor: nextCursor,
146
- totalRowCount: totalRowCount
147
- };
148
- return new Promise(function (resolve) {
149
- setTimeout(function () {
150
- resolve(response);
151
- }, delay); // simulate network latency
152
- });
153
- };
154
- var DEFAULT_DATASET_OPTIONS = {
155
- dataSet: 'Commodity',
156
- rowLength: 100,
157
- maxColumns: 6
158
- };
159
- var disableDelay = typeof DISABLE_CHANCE_RANDOM !== 'undefined' && DISABLE_CHANCE_RANDOM;
160
- var DEFAULT_SERVER_OPTIONS = {
161
- minDelay: disableDelay ? 0 : 100,
162
- maxDelay: disableDelay ? 0 : 300,
163
- useCursorPagination: true
164
- };
165
- export var createFakeServer = function createFakeServer(dataSetOptions, serverOptions) {
166
- var dataSetOptionsWithDefault = _extends({}, DEFAULT_DATASET_OPTIONS, dataSetOptions);
167
- var serverOptionsWithDefault = _extends({}, DEFAULT_SERVER_OPTIONS, serverOptions);
168
- var columns = getColumnsFromOptions(dataSetOptionsWithDefault);
169
- var initialState = getInitialState(dataSetOptionsWithDefault, columns);
170
- var defaultColDef = getGridDefaultColumnTypes();
171
- var columnsWithDefaultColDef = columns.map(function (column) {
172
- return _extends({}, defaultColDef[column.type || 'string'], column);
173
- });
174
- var useQuery = function useQuery(queryOptions) {
175
- var _useDemoData = useDemoData(dataSetOptionsWithDefault),
176
- rows = _useDemoData.data.rows,
177
- dataGenerationIsLoading = _useDemoData.loading;
178
- var queryOptionsRef = React.useRef(queryOptions);
179
- var _React$useState = React.useState({
180
- pageInfo: {},
181
- rows: []
182
- }),
183
- _React$useState2 = _slicedToArray(_React$useState, 2),
184
- response = _React$useState2[0],
185
- setResponse = _React$useState2[1];
186
- var _React$useState3 = React.useState(dataGenerationIsLoading),
187
- _React$useState4 = _slicedToArray(_React$useState3, 2),
188
- isLoading = _React$useState4[0],
189
- setIsLoading = _React$useState4[1];
190
- React.useEffect(function () {
191
- if (dataGenerationIsLoading) {
192
- // dataset is not ready
193
- return function () {};
194
- }
195
- queryOptionsRef.current = queryOptions;
196
- var active = true;
197
- setIsLoading(true);
198
- setResponse(function (prev) {
199
- return Object.keys(prev.pageInfo).length === 0 ? prev : _extends({}, prev, {
200
- pageInfo: {}
201
- });
202
- });
203
- (function () {
204
- var _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
205
- var _yield$loadServerRows, returnedRows, nextCursor, totalRowCount, newRep;
206
- return _regeneratorRuntime.wrap(function _callee$(_context) {
207
- while (1) switch (_context.prev = _context.next) {
208
- case 0:
209
- _context.next = 2;
210
- return loadServerRows(rows, queryOptions, serverOptionsWithDefault, columnsWithDefaultColDef);
211
- case 2:
212
- _yield$loadServerRows = _context.sent;
213
- returnedRows = _yield$loadServerRows.returnedRows;
214
- nextCursor = _yield$loadServerRows.nextCursor;
215
- totalRowCount = _yield$loadServerRows.totalRowCount;
216
- if (active) {
217
- _context.next = 8;
218
- break;
219
- }
220
- return _context.abrupt("return");
221
- case 8:
222
- newRep = {
223
- rows: returnedRows,
224
- pageInfo: {
225
- totalRowCount: totalRowCount,
226
- nextCursor: nextCursor,
227
- pageSize: returnedRows.length
228
- }
229
- };
230
- setResponse(function (prev) {
231
- return isDeepEqual(prev, newRep) ? prev : newRep;
232
- });
233
- setIsLoading(false);
234
- case 11:
235
- case "end":
236
- return _context.stop();
237
- }
238
- }, _callee);
239
- }));
240
- function fetchData() {
241
- return _fetchData.apply(this, arguments);
242
- }
243
- return fetchData;
244
- })()();
245
- return function () {
246
- active = false;
247
- };
248
- }, [dataGenerationIsLoading, queryOptions, rows]);
249
-
250
- // We use queryOptions pointer to be sure that isLoading===true as soon as the options change
251
- var effectShouldStart = queryOptionsRef.current !== queryOptions;
252
- return _extends({
253
- isLoading: isLoading || effectShouldStart
254
- }, response);
255
- };
256
- return {
257
- columns: columns,
258
- columnsWithDefaultColDef: columnsWithDefaultColDef,
259
- initialState: initialState,
260
- useQuery: useQuery
261
- };
262
- };
package/legacy/index.js DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * @mui/x-data-grid-generator v7.0.0-beta.3
3
- *
4
- * @license MUI X Commercial
5
- * This source code is licensed under the commercial license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- export * from './renderer';
9
- export * from './services';
10
- export * from './columns';
11
- export * from './hooks';
@@ -1,16 +0,0 @@
1
- export * from './renderAvatar';
2
- export * from './renderCountry';
3
- export * from './renderEmail';
4
- export * from './renderIncoterm';
5
- export * from './renderLink';
6
- export * from './renderPnl';
7
- export * from './renderProgress';
8
- export * from './renderRating';
9
- export * from './renderStatus';
10
- export * from './renderTotalPrice';
11
- export * from './renderEditCurrency';
12
- export * from './renderEditProgress';
13
- export * from './renderEditStatus';
14
- export * from './renderEditIncoterm';
15
- export * from './renderEditRating';
16
- export * from './renderEditCountry';
@@ -1,14 +0,0 @@
1
- import * as React from 'react';
2
- import Avatar from '@mui/material/Avatar';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- export function renderAvatar(params) {
5
- if (params.value == null) {
6
- return '';
7
- }
8
- return /*#__PURE__*/_jsx(Avatar, {
9
- style: {
10
- backgroundColor: params.value.color
11
- },
12
- children: params.value.name.toUpperCase().substring(0, 1)
13
- });
14
- }
@@ -1,47 +0,0 @@
1
- import * as React from 'react';
2
- import Box from '@mui/material/Box';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { jsxs as _jsxs } from "react/jsx-runtime";
5
- var Country = /*#__PURE__*/React.memo(function Country(props) {
6
- var value = props.value;
7
- return /*#__PURE__*/_jsxs(Box, {
8
- sx: {
9
- width: '100%',
10
- display: 'flex',
11
- alignItems: 'center',
12
- '& > img': {
13
- mr: 0.5,
14
- flexShrink: 0,
15
- width: '20px'
16
- }
17
- },
18
- children: [/*#__PURE__*/_jsx("img", {
19
- loading: "lazy",
20
- width: "20",
21
- src: "https://flagcdn.com/w20/".concat(value.code.toLowerCase(), ".png"),
22
- srcSet: "https://flagcdn.com/w40/".concat(value.code.toLowerCase(), ".png 2x"),
23
- alt: ""
24
- }), /*#__PURE__*/_jsx(Box, {
25
- component: "span",
26
- sx: {
27
- overflow: 'hidden',
28
- textOverflow: 'ellipsis'
29
- },
30
- children: value.label
31
- })]
32
- });
33
- });
34
- export function renderCountry(params) {
35
- if (params.value == null) {
36
- return '';
37
- }
38
-
39
- // If the aggregated value does not have the same unit as the other cell
40
- // Then we fall back to the default rendering based on `valueGetter` instead of rendering the total price UI.
41
- if (params.aggregation && !params.aggregation.hasCellUnit) {
42
- return null;
43
- }
44
- return /*#__PURE__*/_jsx(Country, {
45
- value: params.value
46
- });
47
- }
@@ -1,102 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import * as React from 'react';
6
- import { useGridApiContext } from '@mui/x-data-grid-premium';
7
- import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
8
- import InputBase from '@mui/material/InputBase';
9
- import Box from '@mui/material/Box';
10
- import { styled } from '@mui/material/styles';
11
- import { COUNTRY_ISO_OPTIONS } from '../services/static-data';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
- var StyledAutocomplete = styled(Autocomplete)(function (_ref) {
15
- var theme = _ref.theme;
16
- return _defineProperty({
17
- height: '100%'
18
- }, "& .".concat(autocompleteClasses.inputRoot), _extends({}, theme.typography.body2, {
19
- padding: '1px 0',
20
- height: '100%',
21
- '& input': {
22
- padding: '0 16px',
23
- height: '100%'
24
- }
25
- }));
26
- });
27
- function EditCountry(props) {
28
- var id = props.id,
29
- value = props.value,
30
- field = props.field;
31
- var apiRef = useGridApiContext();
32
- var handleChange = React.useCallback( /*#__PURE__*/function () {
33
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, newValue) {
34
- return _regeneratorRuntime.wrap(function _callee$(_context) {
35
- while (1) switch (_context.prev = _context.next) {
36
- case 0:
37
- _context.next = 2;
38
- return apiRef.current.setEditCellValue({
39
- id: id,
40
- field: field,
41
- value: newValue
42
- }, event);
43
- case 2:
44
- apiRef.current.stopCellEditMode({
45
- id: id,
46
- field: field
47
- });
48
- case 3:
49
- case "end":
50
- return _context.stop();
51
- }
52
- }, _callee);
53
- }));
54
- return function (_x, _x2) {
55
- return _ref3.apply(this, arguments);
56
- };
57
- }(), [apiRef, field, id]);
58
- return /*#__PURE__*/_jsx(StyledAutocomplete, {
59
- value: value,
60
- onChange: handleChange,
61
- options: COUNTRY_ISO_OPTIONS,
62
- getOptionLabel: function getOptionLabel(option) {
63
- return option.label;
64
- },
65
- autoHighlight: true,
66
- fullWidth: true,
67
- open: true,
68
- disableClearable: true,
69
- renderOption: function renderOption(optionProps, option) {
70
- return /*#__PURE__*/_jsxs(Box, _extends({
71
- component: "li",
72
- sx: {
73
- '& > img': {
74
- mr: 1.5,
75
- flexShrink: 0
76
- }
77
- }
78
- }, optionProps, {
79
- children: [/*#__PURE__*/_jsx("img", {
80
- loading: "lazy",
81
- width: "20",
82
- src: "https://flagcdn.com/w20/".concat(option.code.toLowerCase(), ".png"),
83
- srcSet: "https://flagcdn.com/w40/".concat(option.code.toLowerCase(), ".png 2x"),
84
- alt: ""
85
- }), option.label]
86
- }));
87
- },
88
- renderInput: function renderInput(params) {
89
- return /*#__PURE__*/_jsx(InputBase, _extends({
90
- autoFocus: true,
91
- fullWidth: true,
92
- id: params.id,
93
- inputProps: _extends({}, params.inputProps, {
94
- autoComplete: 'new-password' // disable autocomplete and autofill
95
- })
96
- }, params.InputProps));
97
- }
98
- });
99
- }
100
- export function renderEditCountry(params) {
101
- return /*#__PURE__*/_jsx(EditCountry, _extends({}, params));
102
- }
@@ -1,99 +0,0 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import _extends from "@babel/runtime/helpers/esm/extends";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
- import * as React from 'react';
6
- import { useGridApiContext } from '@mui/x-data-grid-premium';
7
- import Autocomplete, { autocompleteClasses } from '@mui/material/Autocomplete';
8
- import InputBase from '@mui/material/InputBase';
9
- import Box from '@mui/material/Box';
10
- import { styled } from '@mui/material/styles';
11
- import { CURRENCY_OPTIONS } from '../services/static-data';
12
- import { jsx as _jsx } from "react/jsx-runtime";
13
- import { jsxs as _jsxs } from "react/jsx-runtime";
14
- var StyledAutocomplete = styled(Autocomplete)(function (_ref) {
15
- var theme = _ref.theme;
16
- return _defineProperty({
17
- height: '100%'
18
- }, "& .".concat(autocompleteClasses.inputRoot), _extends({}, theme.typography.body2, {
19
- padding: '1px 0',
20
- height: '100%',
21
- '& input': {
22
- padding: '0 16px',
23
- height: '100%'
24
- }
25
- }));
26
- });
27
- function EditCurrency(props) {
28
- var id = props.id,
29
- value = props.value,
30
- field = props.field;
31
- var apiRef = useGridApiContext();
32
- var handleChange = React.useCallback( /*#__PURE__*/function () {
33
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, newValue) {
34
- return _regeneratorRuntime.wrap(function _callee$(_context) {
35
- while (1) switch (_context.prev = _context.next) {
36
- case 0:
37
- _context.next = 2;
38
- return apiRef.current.setEditCellValue({
39
- id: id,
40
- field: field,
41
- value: newValue.toUpperCase()
42
- }, event);
43
- case 2:
44
- apiRef.current.stopCellEditMode({
45
- id: id,
46
- field: field
47
- });
48
- case 3:
49
- case "end":
50
- return _context.stop();
51
- }
52
- }, _callee);
53
- }));
54
- return function (_x, _x2) {
55
- return _ref3.apply(this, arguments);
56
- };
57
- }(), [apiRef, field, id]);
58
- return /*#__PURE__*/_jsx(StyledAutocomplete, {
59
- value: value,
60
- onChange: handleChange,
61
- options: CURRENCY_OPTIONS,
62
- autoHighlight: true,
63
- fullWidth: true,
64
- open: true,
65
- disableClearable: true,
66
- renderOption: function renderOption(optionProps, option) {
67
- return /*#__PURE__*/_jsxs(Box, _extends({
68
- component: "li",
69
- sx: {
70
- '& > img': {
71
- mr: 1.5,
72
- flexShrink: 0
73
- }
74
- }
75
- }, optionProps, {
76
- children: [/*#__PURE__*/_jsx("img", {
77
- loading: "lazy",
78
- width: "20",
79
- src: "https://flagcdn.com/w20/".concat(option.slice(0, -1).toLowerCase(), ".png"),
80
- srcSet: "https://flagcdn.com/w40/".concat(option.slice(0, -1).toLowerCase(), ".png 2x"),
81
- alt: ""
82
- }), option]
83
- }));
84
- },
85
- renderInput: function renderInput(params) {
86
- return /*#__PURE__*/_jsx(InputBase, _extends({
87
- autoFocus: true,
88
- fullWidth: true,
89
- id: params.id,
90
- inputProps: _extends({}, params.inputProps, {
91
- autoComplete: 'new-password' // disable autocomplete and autofill
92
- })
93
- }, params.InputProps));
94
- }
95
- });
96
- }
97
- export function renderEditCurrency(params) {
98
- return /*#__PURE__*/_jsx(EditCurrency, _extends({}, params));
99
- }
@@ -1,91 +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 } 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 { INCOTERM_OPTIONS } from '../services/static-data';
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- import { jsxs as _jsxs } from "react/jsx-runtime";
13
- function EditIncoterm(props) {
14
- var id = props.id,
15
- value = props.value,
16
- field = props.field;
17
- var apiRef = useGridApiContext();
18
- var handleChange = /*#__PURE__*/function () {
19
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event) {
20
- return _regeneratorRuntime.wrap(function _callee$(_context) {
21
- while (1) switch (_context.prev = _context.next) {
22
- case 0:
23
- _context.next = 2;
24
- return apiRef.current.setEditCellValue({
25
- id: id,
26
- field: field,
27
- value: event.target.value
28
- }, event);
29
- case 2:
30
- apiRef.current.stopCellEditMode({
31
- id: id,
32
- field: field
33
- });
34
- case 3:
35
- case "end":
36
- return _context.stop();
37
- }
38
- }, _callee);
39
- }));
40
- return function handleChange(_x) {
41
- return _ref.apply(this, arguments);
42
- };
43
- }();
44
- var handleClose = function handleClose(event, reason) {
45
- if (reason === 'backdropClick') {
46
- apiRef.current.stopCellEditMode({
47
- id: id,
48
- field: field
49
- });
50
- }
51
- };
52
- return /*#__PURE__*/_jsx(Select, {
53
- value: value,
54
- onChange: handleChange,
55
- MenuProps: {
56
- onClose: handleClose
57
- },
58
- sx: {
59
- height: '100%',
60
- '& .MuiSelect-select': {
61
- display: 'flex',
62
- alignItems: 'center',
63
- pl: 1
64
- }
65
- },
66
- autoFocus: true,
67
- fullWidth: true,
68
- open: true,
69
- children: INCOTERM_OPTIONS.map(function (option) {
70
- var tooltip = option.slice(option.indexOf('(') + 1, option.indexOf(')'));
71
- var code = option.slice(0, option.indexOf('(')).trim();
72
- return /*#__PURE__*/_jsxs(MenuItem, {
73
- value: option,
74
- children: [/*#__PURE__*/_jsx(ListItemIcon, {
75
- sx: {
76
- minWidth: 36
77
- },
78
- children: code
79
- }), /*#__PURE__*/_jsx(ListItemText, {
80
- primary: tooltip,
81
- sx: {
82
- overflow: 'hidden'
83
- }
84
- })]
85
- }, option);
86
- })
87
- });
88
- }
89
- export function renderEditIncoterm(params) {
90
- return /*#__PURE__*/_jsx(EditIncoterm, _extends({}, params));
91
- }