@mui/x-data-grid-generator 5.17.3 → 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,215 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 6.0.0-alpha.0
7
+
8
+ _Sep 22, 2022_
9
+
10
+ We'd like to offer a big thanks to the 12 contributors who made this release possible. Here are some highlights ✨:
11
+
12
+ - 🌍 Add a `localeText` prop to all pickers to customize the translations (#6212) @flaviendelangle
13
+ - 🌍 Add Finnish (fi-FI) locale to the pickers (#6219) @PetroSilenius
14
+ - 🌍 Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
15
+ - 📚 Documentation improvements
16
+ - 🐞 Bugfixes
17
+
18
+ ### `@mui/x-data-grid@v6.0.0-alpha.0` / `@mui/x-data-grid-pro@v6.0.0-alpha.0` / `@mui/x-data-grid-premium@v6.0.0-alpha.0`
19
+
20
+ #### Breaking changes
21
+
22
+ - The deprecated `hide` column property has been removed in favor of the `columnVisibilityModel` prop and initial state.
23
+
24
+ ```diff
25
+ <DataGrid
26
+ columns={[
27
+ field: 'id,
28
+ - hide: true,
29
+ ]}
30
+ + initialState={{
31
+ + columns: {
32
+ + columnVisibilityModel: { id: false },
33
+ + }
34
+ + }}
35
+ />
36
+ ```
37
+
38
+ You can find more information about this new API on our [documentation](https://next.mui.com/x/react-data-grid/column-visibility/).
39
+
40
+ - The `GridEvents` enum is now a TypeScript type.
41
+
42
+ ```diff
43
+ - apiRef.current.subscribeEvent(GridEvents.rowClick', handleRowClick)
44
+ + apiRef.current.subscribeEvent('rowClick', handleRowClick)
45
+ ```
46
+
47
+ #### Changes
48
+
49
+ - [DataGrid] Do not publish `cellFocusOut` event if the row was removed (#6251) @cherniavskii
50
+ - [DataGrid] Fix scroll anchoring with master details (#6054) @oliviertassinari
51
+ - [DataGrid] Improve Polish (pl-PL) locale on the data grid (#6245) @grzegorz-bach
52
+ - [DataGrid] Remove the `GridEvents` enum (#6003) @flaviendelangle
53
+ - [DataGrid] Remove the deprecated `hide` column property (#5999) @flaviendelangle
54
+
55
+ ### `@mui/x-date-pickers@v6.0.0-alpha.0` / `@mui/x-date-pickers-pro@v6.0.0-alpha.0`
56
+
57
+ #### Breaking changes
58
+
59
+ - All the deprecated props that allowed you to set the text displayed in the pickers have been removed.
60
+
61
+ You can now use the `localText` prop available on all picker components:
62
+
63
+ | Removed prop | Property in the new `localText` prop |
64
+ |------------------------------|-----------------------------------------------------------------------------------|
65
+ | `endText` | `end` |
66
+ | `getClockLabelText` | `clockLabelText` |
67
+ | `getHoursClockNumberText` | `hoursClockNumberText` |
68
+ | `getMinutesClockNumberText` | `minutesClockNumberText` |
69
+ | `getSecondsClockNumberText` | `secondsClockNumberText` |
70
+ | `getViewSwitchingButtonText` | `calendarViewSwitchingButtonAriaLabel` |
71
+ | `leftArrowButtonText` | `openPreviousView` (or `previousMonth` when the button changes the visible month) |
72
+ | `rightArrowButtonText` | `openNextView` (or `nextMonth` when the button changes the visible month) |
73
+ | `startText` | `start` |
74
+
75
+ For instance if you want to replace the `startText` / `endText`
76
+
77
+ ```diff
78
+ <DateRangePicker
79
+ - startText="From"
80
+ - endText="To"
81
+ + localeText={{
82
+ + start: 'From',
83
+ + end: 'To',
84
+ + }}
85
+ />
86
+ ```
87
+
88
+ You can find more information about the new api, including how to set those translations on all your components at once in the [documentation](https://next.mui.com/x/react-date-pickers/localization/)
89
+
90
+ - The component slots `LeftArrowButton` and `RightArrowButton` have been renamed `PreviousIconButton` and `NextIconButton` to better describe there usage:
91
+
92
+ ```diff
93
+ <DatePicker
94
+ components={{
95
+ - LeftArrowButton: CustomButton,
96
+ + PreviousIconButton: CustomButton,
97
+
98
+ - RightArrowButton: CustomButton,
99
+ + NextIconButton: CustomButton,
100
+ }}
101
+
102
+ componentsProps={{
103
+ - leftArrowButton: {},
104
+ + previousIconButton: {},
105
+
106
+ - rightArrowButton: {},
107
+ + nextIconButton: {},
108
+ }}
109
+ />
110
+ ```
111
+
112
+ - The `date` prop has been renamed `value` on `MonthPicker` / `YearPicker`, `ClockPicker` and `CalendarPicker`.
113
+
114
+ ```diff
115
+ - <MonthPicker date={dayjs()} onChange={handleMonthChange} />
116
+ + <MonthPicker value={dayjs()} onChange={handleMonthChange} />
117
+
118
+ - <YearPicker date={dayjs()} onChange={handleYearChange} />
119
+ + <YearPicker value={dayjs()} onChange={handleYearChange} />
120
+
121
+ - <ClockPicker date={dayjs()} onChange={handleTimeChange} />
122
+ + <ClockPicker value={dayjs()} onChange={handleTimeChange} />
123
+
124
+ - <CalendarPicker date={dayjs()} onChange={handleDateChange} />
125
+ + <CalendarPicker value={dayjs()} onChange={handleDateChange} />
126
+ ```
127
+
128
+ #### Changes
129
+
130
+ - [CalendarPicker] Don't move to closest enabled date when `props.date` contains a disabled date (#6146) @flaviendelangle
131
+ - [DateRangePicker] Switch to new month when changing the value from the outside (#6166) @flaviendelangle
132
+ - [pickers] Add a `localeText` prop to all pickers to customize the translations (#6212) @flaviendelangle
133
+ - [pickers] Add Finnish (fi-FI) locale to the pickers (#6219) (#6230) @PetroSilenius
134
+ - [pickers] Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
135
+ - [pickers] Allow nested `LocalizationProvider` (#6011) @flaviendelangle
136
+ - [pickers] Clean slots on `PickersArrowSwitcher` component (#5890) @flaviendelangle
137
+ - [pickers] Fix invalid date error when decreasing `DateField` day (#6071) @alexfauquette
138
+ - [pickers] Fix mobile section selection (#6207) @oliviertassinari
139
+ - [pickers] Fix usage with Typescript 4.8 (#6229) @flaviendelangle
140
+ - [pickers] Improve error message when no adapter context is found (#6211) @flaviendelangle
141
+ - [pickers] Remove `valueStr` from the field state (#6142) @flaviendelangle
142
+ - [pickers] Remove remaining deprecated locale props (#6233) @flaviendelangle
143
+ - [pickers] Rename the `date` prop `value` on `MonthPicker` / `YearPicker`, `ClockPicker` and `CalendarPicker` (#6128) @flaviendelangle
144
+ - [pickers] Rename the `onClose` prop of `PickersPopper` `onDismiss` to simplify typing (#6155) @flaviendelangle
145
+ - [pickers] Support the `sx` prop on all public component with a root HTML elements (#5944) @flaviendelangle
146
+ - [pickers] Unify `PickersMonth` and `PickersYear` behaviors (#6034) @flaviendelangle
147
+ - [pickers] Use `shouldDisableMonth` and `shouldDisableYear` for date validation (#6066) @flaviendelangle
148
+ - [YearPicker] Scroll to the current year even with `autoFocus=false` (#6224) @alexfauquette
149
+
150
+ ### Docs
151
+
152
+ - [docs] Add automatic vale check (#5429) @alexfauquette
153
+ - [docs] Add Pro logo in "column ordering" link (#6127) @alexfauquette
154
+ - [docs] Fix 301 link (#6239) @oliviertassinari
155
+ - [docs] Fix broken link (#6163) @alexfauquette
156
+ - [docs] Fix broken links (#6101) @alexfauquette
157
+ - [docs] Fix demonstration date to avoid hydration errors (#6032) @alexfauquette
158
+ - [docs] Fix hidden popper in restore state example (#6191) @heyfirst
159
+ - [docs] Fix invalid links causing 404 & 301 errors (#6105) @oliviertassinari
160
+ - [docs] Fix npm repository url in the pickers `package.json` (#6172) @oliviertassinari
161
+ - [docs] Fix typo in linked issue (#6162) @flaviendelangle
162
+ - [docs] Import `generateUtilityClass` from `@mui/utils` (#6216) @michaldudak
163
+ - [docs] Improve Upgrade plan docs (#6018) @oliviertassinari
164
+ - [docs] Link the OpenSSF Best Practices card (#6171) @oliviertassinari
165
+
166
+ ### Core
167
+
168
+ - [core] Add `v5.17.3` changelog to next branch (#6250) @flaviendelangle
169
+ - [core] Add link to the security page on the `README` (#6073) @oliviertassinari
170
+ - [core] Fix scroll restoration in the docs (#5938) @oliviertassinari
171
+ - [core] Remove the Storybook (#6099) @flaviendelangle
172
+ - [core] Tag release as `next` in NPM (#6256) @m4theushw
173
+ - [core] Update monorepo (#6180) @flaviendelangle
174
+ - [core] Use the `next` branch for Prettier (#6097) @flaviendelangle
175
+ - [core] Use the official repository for `@mui/monorepo` instead of a fork (#6189) @oliviertassinari
176
+ - [test] Fix logic to skip column pinning tests (#6133) @m4theushw
177
+ - [test] Hide the date on the print regression test (#6120) @flaviendelangle
178
+ - [test] Skip tests for column pinning and dynamic row height (#5997) @m4theushw
179
+ - [website] Improve security header @oliviertassinari
180
+
181
+ ## v5.17.4
182
+
183
+ _Sep 22, 2022_
184
+
185
+ We'd like to offer a big thanks to the 5 contributors who made this release possible. Here are some highlights ✨:
186
+
187
+ - 🌍 Add Finnish (fi-FI) locale to the pickers (#6230) @PetroSilenius
188
+ - 🌍 Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
189
+ - 🐞 Bugfixes
190
+
191
+ ### `@mui/x-data-grid@v5.17.4` / `@mui/x-data-grid-pro@v5.17.4` / `@mui/x-data-grid-premium@v5.17.4`
192
+
193
+ #### Changes
194
+
195
+ - [DataGrid] Do not publish `cellFocusOut` event if the row was removed (#6251) @cherniavskii
196
+ - [DataGrid] Improve Polish (pl-PL) locale on the data grid (#6245) @grzegorz-bach
197
+
198
+ ### `@mui/x-date-pickers@v5.0.3` / `@mui/x-date-pickers-pro@v5.0.3`
199
+
200
+ #### Changes
201
+
202
+ - [pickers] Add Finnish (fi-FI) locale to pickers (#6219) (#6230) @PetroSilenius
203
+ - [pickers] Add Persian (fa-IR) locale to the pickers (#6181) @fakhamatia
204
+ - [pickers] Fix usage with Typescript 4.8 (#6229) @flaviendelangle
205
+ - [YearPicker] Scroll to the current year even with `autoFocus=false` (#6224) @alexfauquette
206
+
207
+ ### Docs
208
+
209
+ - [docs] Fix 301 link (#6239) @oliviertassinari
210
+
211
+ ### Core
212
+
213
+ - [core] Use the official repository for `@mui/monorepo` instead of a fork (#6189) @oliviertassinari
214
+
6
215
  ## 5.17.3
7
216
 
8
217
  _Sep 16, 2022_
@@ -1406,7 +1615,7 @@ We'd like to offer a big thanks to the 15 contributors who made this release pos
1406
1615
  - [DataGrid] Stop checkbox ripple on blur (#3835) @m4theushw
1407
1616
  - [DataGrid] Stop calling `onRowClick` when clicking in cells with interactive elements (#3929) @m4theushw
1408
1617
  - [DataGrid] Use only `headerName` when available to search column (#3959) @pkratz
1409
- - [DataGrid] Use the bundling scripts as the packages published by the [https://github.com/mui/material-ui](material-ui) repository (#3965) @flaviendelangle
1618
+ - [DataGrid] Use the bundling scripts as the packages published by the [material-ui](https://github.com/mui/material-ui) repository (#3965) @flaviendelangle
1410
1619
  - [DataGridPro] Add `unstable_setRowHeight` method to `apiRef` (#3751) @cherniavskii
1411
1620
  - [DataGridPro] Always export the `pageSize` and `page` when it has been initialized or is being controlled (#3908) @flaviendelangle
1412
1621
  - [DataGridPro] Disable export for detail panel column (#4057) @gustavhagland
@@ -4051,7 +4260,7 @@ Big thanks to the 7 contributors who made this release possible. Here are some h
4051
4260
 
4052
4261
  - 💄 Release the cell editing feature (#1287) @dtassone
4053
4262
 
4054
- This is the first release of the Cell editing feature. You can find the documentation [following this link](https://mui.com/x/react-data-grid/editing/#cell-editing). We have spent the last three months working on it.
4263
+ This is the first release of the Cell editing feature. You can find the documentation [following this link](https://mui.com/x/react-data-grid/editing/). We have spent the last three months working on it.
4055
4264
 
4056
4265
  ![cell edit](https://user-images.githubusercontent.com/3165635/115632215-87994700-a307-11eb-91d9-9f5537df0911.gif)
4057
4266
 
@@ -4661,7 +4870,7 @@ _Dec 9, 2020_
4661
4870
 
4662
4871
  Big thanks to the 6 contributors who made this release possible. Here are some highlights ✨:
4663
4872
 
4664
- - 🔍 Add a new data grid [density selector](https://mui.com/x/react-data-grid/rendering/#density) feature (#606) @DanailH.
4873
+ - 🔍 Add a new data grid [density selector](https://mui.com/x/react-data-grid/accessibility/#density) feature (#606) @DanailH.
4665
4874
  - 💄 A first iteration on the data grid's toolbar.
4666
4875
  - 🧪 Continue the iteration on the data grid filtering feature, soon to be released @dtassone.
4667
4876
 
package/hooks/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './useDemoData';
2
+ export * from './useBasicDemoData';
2
3
  export * from './useMovieData';
3
4
  export * from './useQuery';
package/hooks/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './useDemoData';
2
+ export * from './useBasicDemoData';
2
3
  export * from './useMovieData';
3
4
  export * from './useQuery';
@@ -0,0 +1,2 @@
1
+ import { GridBasicData } from '../services';
2
+ export declare const useBasicDemoData: (nbRows: number, nbCols: number) => GridBasicData;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { getBasicGridData } from '../services';
3
+ export const useBasicDemoData = (nbRows, nbCols) => {
4
+ const [data, setData] = React.useState({
5
+ rows: [],
6
+ columns: []
7
+ });
8
+ React.useEffect(() => {
9
+ const newData = getBasicGridData(nbRows, nbCols);
10
+ setData(newData);
11
+ }, [nbRows, nbCols]);
12
+ return data;
13
+ };
@@ -88,7 +88,6 @@ export const getColumnsFromOptions = options => {
88
88
  export const getInitialState = (options, columns) => {
89
89
  var _options$treeData;
90
90
 
91
- // TODO v6: Stop using `GridColDef.hide`
92
91
  const columnVisibilityModel = {};
93
92
  columns.forEach(col => {
94
93
  if (col.hide) {
@@ -35,6 +35,7 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
35
35
  columnsWithDefaultColDef: {
36
36
  generateData?: ((row: any, context: import("..").GridDataGeneratorContext) => any) | undefined;
37
37
  dataGeneratorUniquenessEnabled?: boolean | undefined;
38
+ hide?: boolean | undefined;
38
39
  field: string;
39
40
  headerName?: string | undefined;
40
41
  description?: string | undefined;
@@ -42,7 +43,6 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
42
43
  flex?: number | undefined;
43
44
  minWidth?: number | undefined;
44
45
  maxWidth?: number | undefined;
45
- hide?: boolean | undefined;
46
46
  hideable?: boolean | undefined;
47
47
  sortable?: boolean | undefined;
48
48
  sortingOrder?: import("@mui/x-data-grid-pro").GridSortDirection[] | undefined;
@@ -85,7 +85,7 @@ export declare const createFakeServer: (dataSetOptions?: Partial<UseDemoDataOpti
85
85
  };
86
86
  useQuery: (queryOptions: QueryOptions) => {
87
87
  pageInfo: PageInfo;
88
- data: GridRowModel[];
88
+ rows: GridRowModel[];
89
89
  isLoading: boolean;
90
90
  };
91
91
  };
package/hooks/useQuery.js CHANGED
@@ -192,7 +192,7 @@ export const createFakeServer = (dataSetOptions, serverOptions) => {
192
192
  const queryOptionsRef = React.useRef(queryOptions);
193
193
  const [response, setResponse] = React.useState({
194
194
  pageInfo: {},
195
- data: []
195
+ rows: []
196
196
  });
197
197
  const [isLoading, setIsLoading] = React.useState(dataGenerationIsLoading);
198
198
  React.useEffect(() => {
@@ -220,7 +220,7 @@ export const createFakeServer = (dataSetOptions, serverOptions) => {
220
220
  }
221
221
 
222
222
  const newRep = {
223
- data: returnedRows,
223
+ rows: returnedRows,
224
224
  pageInfo: {
225
225
  totalRowCount,
226
226
  nextCursor,
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.3
1
+ /** @license MUI v6.0.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,3 +1,4 @@
1
1
  export * from './useDemoData';
2
+ export * from './useBasicDemoData';
2
3
  export * from './useMovieData';
3
4
  export * from './useQuery';
@@ -0,0 +1,18 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import * as React from 'react';
3
+ import { getBasicGridData } from '../services';
4
+ export var useBasicDemoData = function useBasicDemoData(nbRows, nbCols) {
5
+ var _React$useState = React.useState({
6
+ rows: [],
7
+ columns: []
8
+ }),
9
+ _React$useState2 = _slicedToArray(_React$useState, 2),
10
+ data = _React$useState2[0],
11
+ setData = _React$useState2[1];
12
+
13
+ React.useEffect(function () {
14
+ var newData = getBasicGridData(nbRows, nbCols);
15
+ setData(newData);
16
+ }, [nbRows, nbCols]);
17
+ return data;
18
+ };
@@ -129,7 +129,6 @@ export var getColumnsFromOptions = function getColumnsFromOptions(options) {
129
129
  export var getInitialState = function getInitialState(options, columns) {
130
130
  var _options$treeData;
131
131
 
132
- // TODO v6: Stop using `GridColDef.hide`
133
132
  var columnVisibilityModel = {};
134
133
  columns.forEach(function (col) {
135
134
  if (col.hide) {
@@ -212,7 +212,7 @@ export var createFakeServer = function createFakeServer(dataSetOptions, serverOp
212
212
 
213
213
  var _React$useState = React.useState({
214
214
  pageInfo: {},
215
- data: []
215
+ rows: []
216
216
  }),
217
217
  _React$useState2 = _slicedToArray(_React$useState, 2),
218
218
  response = _React$useState2[0],
@@ -263,7 +263,7 @@ export var createFakeServer = function createFakeServer(dataSetOptions, serverOp
263
263
 
264
264
  case 8:
265
265
  newRep = {
266
- data: returnedRows,
266
+ rows: returnedRows,
267
267
  pageInfo: {
268
268
  totalRowCount: totalRowCount,
269
269
  nextCursor: nextCursor,
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.3
1
+ /** @license MUI v6.0.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -0,0 +1,44 @@
1
+ export var currencyPairs = ['USDGBP', 'USDEUR', 'GBPEUR', 'JPYUSD', 'MXNUSD', 'BTCUSD', 'USDCAD', 'EURJPY', 'EURUSD', 'EURCHF', 'USDCHF', 'EURGBP', 'GBPUSD', 'AUDCAD', 'NZDUSD', 'GBPCHF', 'AUDUSD', 'GBPJPY', 'USDJPY', 'CHFJPY', 'EURCAD', 'AUDJPY', 'EURAUD', 'AUDNZD', 'CADEUR', 'CHFMXN', 'ETHUSD', 'BCHUSD', 'ETHBTC', 'XRPUSD', 'XRPBTC', 'USDLTC', 'USDXRP', 'USDDSH', 'USDBCH', 'JPYEUR', 'JPYUSD', 'JPYGBP', 'JPYCAD', 'JPYCHF', 'JPYAUD', 'JPYNZD', 'JPYSGD', 'JPYNOK', 'JPYRUB', 'JPYSEK', 'JPYTRY', 'JPYZAR', 'JPYHKD', 'JPYCNH', 'JPYDKK', 'JPYMXN', 'JPYPLN', 'JPYXAG', 'JPYXAU', 'JPYBTC', 'JPYETH', 'JPYLTC', 'JPYXRP', 'JPYDSH', 'JPYBCH', 'GBPEUR', 'GBPRUB', 'GBPTRY'];
2
+ export var getBasicGridData = function getBasicGridData(rowLength, colLength) {
3
+ var data = [];
4
+ var pricesColLength = colLength - 2;
5
+
6
+ for (var i = 0; i < rowLength; i += 1) {
7
+ var idx = i >= currencyPairs.length ? i % currencyPairs.length : i;
8
+ var model = {
9
+ id: i,
10
+ currencyPair: currencyPairs[idx]
11
+ };
12
+
13
+ for (var j = 1; j <= pricesColLength; j += 1) {
14
+ model["price".concat(j, "M")] = Number("".concat(i.toString()).concat(j)); // randomPrice(0.7, 2);
15
+ }
16
+
17
+ data.push(model);
18
+ }
19
+
20
+ var columns = [{
21
+ field: 'id',
22
+ headerName: 'id',
23
+ type: 'number'
24
+ }, {
25
+ field: 'currencyPair',
26
+ headerName: 'Currency Pair'
27
+ }];
28
+
29
+ for (var _j = 1; _j <= pricesColLength; _j += 1) {
30
+ // const y = Math.floor(j / 12);
31
+ columns.push({
32
+ field: "price".concat(_j, "M"),
33
+ headerName: "".concat(_j, "M"),
34
+ type: 'number'
35
+ }); // (y > 0 ? `${y}Y` : '') + `${j - y * 12}M`
36
+ }
37
+
38
+ columns.length = colLength; // we cut the array in case < 2;
39
+
40
+ return {
41
+ columns: columns,
42
+ rows: data
43
+ };
44
+ };
@@ -1,3 +1,4 @@
1
1
  export * from './gridColDefGenerator';
2
2
  export * from './random-generator';
3
- export * from './real-data-service';
3
+ export * from './real-data-service';
4
+ export * from './basic-data-service';
@@ -1,3 +1,4 @@
1
1
  export * from './useDemoData';
2
+ export * from './useBasicDemoData';
2
3
  export * from './useMovieData';
3
4
  export * from './useQuery';
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { getBasicGridData } from '../services';
3
+ export const useBasicDemoData = (nbRows, nbCols) => {
4
+ const [data, setData] = React.useState({
5
+ rows: [],
6
+ columns: []
7
+ });
8
+ React.useEffect(() => {
9
+ const newData = getBasicGridData(nbRows, nbCols);
10
+ setData(newData);
11
+ }, [nbRows, nbCols]);
12
+ return data;
13
+ };
@@ -82,7 +82,6 @@ export const getColumnsFromOptions = options => {
82
82
  return columns;
83
83
  };
84
84
  export const getInitialState = (options, columns) => {
85
- // TODO v6: Stop using `GridColDef.hide`
86
85
  const columnVisibilityModel = {};
87
86
  columns.forEach(col => {
88
87
  if (col.hide) {
@@ -188,7 +188,7 @@ export const createFakeServer = (dataSetOptions, serverOptions) => {
188
188
  const queryOptionsRef = React.useRef(queryOptions);
189
189
  const [response, setResponse] = React.useState({
190
190
  pageInfo: {},
191
- data: []
191
+ rows: []
192
192
  });
193
193
  const [isLoading, setIsLoading] = React.useState(dataGenerationIsLoading);
194
194
  React.useEffect(() => {
@@ -216,7 +216,7 @@ export const createFakeServer = (dataSetOptions, serverOptions) => {
216
216
  }
217
217
 
218
218
  const newRep = {
219
- data: returnedRows,
219
+ rows: returnedRows,
220
220
  pageInfo: {
221
221
  totalRowCount,
222
222
  nextCursor,
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.3
1
+ /** @license MUI v6.0.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -0,0 +1,44 @@
1
+ export const currencyPairs = ['USDGBP', 'USDEUR', 'GBPEUR', 'JPYUSD', 'MXNUSD', 'BTCUSD', 'USDCAD', 'EURJPY', 'EURUSD', 'EURCHF', 'USDCHF', 'EURGBP', 'GBPUSD', 'AUDCAD', 'NZDUSD', 'GBPCHF', 'AUDUSD', 'GBPJPY', 'USDJPY', 'CHFJPY', 'EURCAD', 'AUDJPY', 'EURAUD', 'AUDNZD', 'CADEUR', 'CHFMXN', 'ETHUSD', 'BCHUSD', 'ETHBTC', 'XRPUSD', 'XRPBTC', 'USDLTC', 'USDXRP', 'USDDSH', 'USDBCH', 'JPYEUR', 'JPYUSD', 'JPYGBP', 'JPYCAD', 'JPYCHF', 'JPYAUD', 'JPYNZD', 'JPYSGD', 'JPYNOK', 'JPYRUB', 'JPYSEK', 'JPYTRY', 'JPYZAR', 'JPYHKD', 'JPYCNH', 'JPYDKK', 'JPYMXN', 'JPYPLN', 'JPYXAG', 'JPYXAU', 'JPYBTC', 'JPYETH', 'JPYLTC', 'JPYXRP', 'JPYDSH', 'JPYBCH', 'GBPEUR', 'GBPRUB', 'GBPTRY'];
2
+ export const getBasicGridData = (rowLength, colLength) => {
3
+ const data = [];
4
+ const pricesColLength = colLength - 2;
5
+
6
+ for (let i = 0; i < rowLength; i += 1) {
7
+ const idx = i >= currencyPairs.length ? i % currencyPairs.length : i;
8
+ const model = {
9
+ id: i,
10
+ currencyPair: currencyPairs[idx]
11
+ };
12
+
13
+ for (let j = 1; j <= pricesColLength; j += 1) {
14
+ model[`price${j}M`] = Number(`${i.toString()}${j}`); // randomPrice(0.7, 2);
15
+ }
16
+
17
+ data.push(model);
18
+ }
19
+
20
+ const columns = [{
21
+ field: 'id',
22
+ headerName: 'id',
23
+ type: 'number'
24
+ }, {
25
+ field: 'currencyPair',
26
+ headerName: 'Currency Pair'
27
+ }];
28
+
29
+ for (let j = 1; j <= pricesColLength; j += 1) {
30
+ // const y = Math.floor(j / 12);
31
+ columns.push({
32
+ field: `price${j}M`,
33
+ headerName: `${j}M`,
34
+ type: 'number'
35
+ }); // (y > 0 ? `${y}Y` : '') + `${j - y * 12}M`
36
+ }
37
+
38
+ columns.length = colLength; // we cut the array in case < 2;
39
+
40
+ return {
41
+ columns,
42
+ rows: data
43
+ };
44
+ };
@@ -1,3 +1,4 @@
1
1
  export * from './gridColDefGenerator';
2
2
  export * from './random-generator';
3
- export * from './real-data-service';
3
+ export * from './real-data-service';
4
+ export * from './basic-data-service';
@@ -17,6 +17,19 @@ Object.keys(_useDemoData).forEach(function (key) {
17
17
  });
18
18
  });
19
19
 
20
+ var _useBasicDemoData = require("./useBasicDemoData");
21
+
22
+ Object.keys(_useBasicDemoData).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _useBasicDemoData[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _useBasicDemoData[key];
29
+ }
30
+ });
31
+ });
32
+
20
33
  var _useMovieData = require("./useMovieData");
21
34
 
22
35
  Object.keys(_useMovieData).forEach(function (key) {
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBasicDemoData = void 0;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ var _services = require("../services");
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ 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; }
15
+
16
+ const useBasicDemoData = (nbRows, nbCols) => {
17
+ const [data, setData] = React.useState({
18
+ rows: [],
19
+ columns: []
20
+ });
21
+ React.useEffect(() => {
22
+ const newData = (0, _services.getBasicGridData)(nbRows, nbCols);
23
+ setData(newData);
24
+ }, [nbRows, nbCols]);
25
+ return data;
26
+ };
27
+
28
+ exports.useBasicDemoData = useBasicDemoData;
@@ -112,7 +112,6 @@ exports.getColumnsFromOptions = getColumnsFromOptions;
112
112
  const getInitialState = (options, columns) => {
113
113
  var _options$treeData;
114
114
 
115
- // TODO v6: Stop using `GridColDef.hide`
116
115
  const columnVisibilityModel = {};
117
116
  columns.forEach(col => {
118
117
  if (col.hide) {
@@ -210,7 +210,7 @@ const createFakeServer = (dataSetOptions, serverOptions) => {
210
210
  const queryOptionsRef = React.useRef(queryOptions);
211
211
  const [response, setResponse] = React.useState({
212
212
  pageInfo: {},
213
- data: []
213
+ rows: []
214
214
  });
215
215
  const [isLoading, setIsLoading] = React.useState(dataGenerationIsLoading);
216
216
  React.useEffect(() => {
@@ -238,7 +238,7 @@ const createFakeServer = (dataSetOptions, serverOptions) => {
238
238
  }
239
239
 
240
240
  const newRep = {
241
- data: returnedRows,
241
+ rows: returnedRows,
242
242
  pageInfo: {
243
243
  totalRowCount,
244
244
  nextCursor,
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.17.3
1
+ /** @license MUI v6.0.0-alpha.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBasicGridData = exports.currencyPairs = void 0;
7
+ const currencyPairs = ['USDGBP', 'USDEUR', 'GBPEUR', 'JPYUSD', 'MXNUSD', 'BTCUSD', 'USDCAD', 'EURJPY', 'EURUSD', 'EURCHF', 'USDCHF', 'EURGBP', 'GBPUSD', 'AUDCAD', 'NZDUSD', 'GBPCHF', 'AUDUSD', 'GBPJPY', 'USDJPY', 'CHFJPY', 'EURCAD', 'AUDJPY', 'EURAUD', 'AUDNZD', 'CADEUR', 'CHFMXN', 'ETHUSD', 'BCHUSD', 'ETHBTC', 'XRPUSD', 'XRPBTC', 'USDLTC', 'USDXRP', 'USDDSH', 'USDBCH', 'JPYEUR', 'JPYUSD', 'JPYGBP', 'JPYCAD', 'JPYCHF', 'JPYAUD', 'JPYNZD', 'JPYSGD', 'JPYNOK', 'JPYRUB', 'JPYSEK', 'JPYTRY', 'JPYZAR', 'JPYHKD', 'JPYCNH', 'JPYDKK', 'JPYMXN', 'JPYPLN', 'JPYXAG', 'JPYXAU', 'JPYBTC', 'JPYETH', 'JPYLTC', 'JPYXRP', 'JPYDSH', 'JPYBCH', 'GBPEUR', 'GBPRUB', 'GBPTRY'];
8
+ exports.currencyPairs = currencyPairs;
9
+
10
+ const getBasicGridData = (rowLength, colLength) => {
11
+ const data = [];
12
+ const pricesColLength = colLength - 2;
13
+
14
+ for (let i = 0; i < rowLength; i += 1) {
15
+ const idx = i >= currencyPairs.length ? i % currencyPairs.length : i;
16
+ const model = {
17
+ id: i,
18
+ currencyPair: currencyPairs[idx]
19
+ };
20
+
21
+ for (let j = 1; j <= pricesColLength; j += 1) {
22
+ model[`price${j}M`] = Number(`${i.toString()}${j}`); // randomPrice(0.7, 2);
23
+ }
24
+
25
+ data.push(model);
26
+ }
27
+
28
+ const columns = [{
29
+ field: 'id',
30
+ headerName: 'id',
31
+ type: 'number'
32
+ }, {
33
+ field: 'currencyPair',
34
+ headerName: 'Currency Pair'
35
+ }];
36
+
37
+ for (let j = 1; j <= pricesColLength; j += 1) {
38
+ // const y = Math.floor(j / 12);
39
+ columns.push({
40
+ field: `price${j}M`,
41
+ headerName: `${j}M`,
42
+ type: 'number'
43
+ }); // (y > 0 ? `${y}Y` : '') + `${j - y * 12}M`
44
+ }
45
+
46
+ columns.length = colLength; // we cut the array in case < 2;
47
+
48
+ return {
49
+ columns,
50
+ rows: data
51
+ };
52
+ };
53
+
54
+ exports.getBasicGridData = getBasicGridData;
@@ -41,4 +41,17 @@ Object.keys(_realDataService).forEach(function (key) {
41
41
  return _realDataService[key];
42
42
  }
43
43
  });
44
+ });
45
+
46
+ var _basicDataService = require("./basic-data-service");
47
+
48
+ Object.keys(_basicDataService).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _basicDataService[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _basicDataService[key];
55
+ }
56
+ });
44
57
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-data-grid-generator",
3
- "version": "5.17.3",
3
+ "version": "6.0.0-alpha.0",
4
4
  "description": "Generate fake data for demo purposes only.",
5
5
  "author": "MUI Team",
6
6
  "main": "./node/index.js",
@@ -19,9 +19,9 @@
19
19
  "directory": "packages/grid/x-data-grid-generator"
20
20
  },
21
21
  "dependencies": {
22
- "@babel/runtime": "^7.18.9",
23
- "@mui/base": "^5.0.0-alpha.97",
24
- "@mui/x-data-grid-premium": "5.17.3",
22
+ "@babel/runtime": "^7.19.0",
23
+ "@mui/base": "^5.0.0-alpha.98",
24
+ "@mui/x-data-grid-premium": "6.0.0-alpha.0",
25
25
  "chance": "^1.1.8",
26
26
  "clsx": "^1.2.1",
27
27
  "lru-cache": "^7.14.0"
@@ -0,0 +1,13 @@
1
+ import { GridColDef, GridRowId } from '@mui/x-data-grid';
2
+ export declare const currencyPairs: string[];
3
+ interface GridBasicRowModel {
4
+ id: GridRowId;
5
+ currencyPair: string;
6
+ [price: string]: number | string;
7
+ }
8
+ export interface GridBasicData {
9
+ columns: GridColDef[];
10
+ rows: GridBasicRowModel[];
11
+ }
12
+ export declare const getBasicGridData: (rowLength: number, colLength: number) => GridBasicData;
13
+ export {};
@@ -0,0 +1,44 @@
1
+ export const currencyPairs = ['USDGBP', 'USDEUR', 'GBPEUR', 'JPYUSD', 'MXNUSD', 'BTCUSD', 'USDCAD', 'EURJPY', 'EURUSD', 'EURCHF', 'USDCHF', 'EURGBP', 'GBPUSD', 'AUDCAD', 'NZDUSD', 'GBPCHF', 'AUDUSD', 'GBPJPY', 'USDJPY', 'CHFJPY', 'EURCAD', 'AUDJPY', 'EURAUD', 'AUDNZD', 'CADEUR', 'CHFMXN', 'ETHUSD', 'BCHUSD', 'ETHBTC', 'XRPUSD', 'XRPBTC', 'USDLTC', 'USDXRP', 'USDDSH', 'USDBCH', 'JPYEUR', 'JPYUSD', 'JPYGBP', 'JPYCAD', 'JPYCHF', 'JPYAUD', 'JPYNZD', 'JPYSGD', 'JPYNOK', 'JPYRUB', 'JPYSEK', 'JPYTRY', 'JPYZAR', 'JPYHKD', 'JPYCNH', 'JPYDKK', 'JPYMXN', 'JPYPLN', 'JPYXAG', 'JPYXAU', 'JPYBTC', 'JPYETH', 'JPYLTC', 'JPYXRP', 'JPYDSH', 'JPYBCH', 'GBPEUR', 'GBPRUB', 'GBPTRY'];
2
+ export const getBasicGridData = (rowLength, colLength) => {
3
+ const data = [];
4
+ const pricesColLength = colLength - 2;
5
+
6
+ for (let i = 0; i < rowLength; i += 1) {
7
+ const idx = i >= currencyPairs.length ? i % currencyPairs.length : i;
8
+ const model = {
9
+ id: i,
10
+ currencyPair: currencyPairs[idx]
11
+ };
12
+
13
+ for (let j = 1; j <= pricesColLength; j += 1) {
14
+ model[`price${j}M`] = Number(`${i.toString()}${j}`); // randomPrice(0.7, 2);
15
+ }
16
+
17
+ data.push(model);
18
+ }
19
+
20
+ const columns = [{
21
+ field: 'id',
22
+ headerName: 'id',
23
+ type: 'number'
24
+ }, {
25
+ field: 'currencyPair',
26
+ headerName: 'Currency Pair'
27
+ }];
28
+
29
+ for (let j = 1; j <= pricesColLength; j += 1) {
30
+ // const y = Math.floor(j / 12);
31
+ columns.push({
32
+ field: `price${j}M`,
33
+ headerName: `${j}M`,
34
+ type: 'number'
35
+ }); // (y > 0 ? `${y}Y` : '') + `${j - y * 12}M`
36
+ }
37
+
38
+ columns.length = colLength; // we cut the array in case < 2;
39
+
40
+ return {
41
+ columns,
42
+ rows: data
43
+ };
44
+ };
@@ -16,4 +16,8 @@ export interface GridColDefGenerator extends GridColDef {
16
16
  * @default false
17
17
  */
18
18
  dataGeneratorUniquenessEnabled?: boolean;
19
+ /**
20
+ * If `true`, the column will be marked as hidden in the `columnVisibilityModel`.
21
+ */
22
+ hide?: boolean;
19
23
  }
@@ -1,3 +1,4 @@
1
1
  export * from './gridColDefGenerator';
2
2
  export * from './random-generator';
3
3
  export * from './real-data-service';
4
+ export * from './basic-data-service';
package/services/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './gridColDefGenerator';
2
2
  export * from './random-generator';
3
- export * from './real-data-service';
3
+ export * from './real-data-service';
4
+ export * from './basic-data-service';