@mui/x-data-grid-premium 8.0.0-alpha.0 → 8.0.0-alpha.2
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 +651 -6
- package/DataGridPremium/DataGridPremium.js +10 -10
- package/README.md +2 -2
- package/components/index.d.ts +1 -0
- package/components/index.js +12 -0
- package/components/promptControl/GridToolbarPromptControl.d.ts +26 -0
- package/components/promptControl/GridToolbarPromptControl.js +209 -0
- package/components/promptControl/RecordButton.d.ts +16 -0
- package/components/promptControl/RecordButton.js +119 -0
- package/components/promptControl/index.d.ts +1 -0
- package/components/promptControl/index.js +12 -0
- package/esm/DataGridPremium/DataGridPremium.js +10 -10
- package/esm/components/index.js +1 -0
- package/esm/components/promptControl/GridToolbarPromptControl.js +202 -0
- package/esm/components/promptControl/RecordButton.js +111 -0
- package/esm/components/promptControl/index.js +1 -0
- package/esm/hooks/features/index.js +2 -1
- package/esm/hooks/features/promptControl/api.js +22 -0
- package/esm/hooks/features/promptControl/index.js +1 -0
- package/esm/hooks/features/promptControl/types.js +1 -0
- package/esm/material/icons.js +7 -1
- package/esm/material/index.js +4 -2
- package/esm/utils/releaseInfo.js +1 -1
- package/hooks/features/aggregation/wrapColumnWithAggregation.d.ts +1 -0
- package/hooks/features/index.d.ts +1 -0
- package/hooks/features/index.js +11 -0
- package/hooks/features/promptControl/api.d.ts +2 -0
- package/hooks/features/promptControl/api.js +28 -0
- package/hooks/features/promptControl/index.d.ts +2 -0
- package/hooks/features/promptControl/index.js +12 -0
- package/hooks/features/promptControl/types.d.ts +25 -0
- package/hooks/features/promptControl/types.js +5 -0
- package/index.js +1 -1
- package/material/icons.d.ts +6 -0
- package/material/icons.js +8 -2
- package/material/index.d.ts +2 -0
- package/material/index.js +3 -1
- package/models/gridPremiumIconSlotsComponent.d.ts +10 -0
- package/modern/DataGridPremium/DataGridPremium.js +10 -10
- package/modern/components/index.js +1 -0
- package/modern/components/promptControl/GridToolbarPromptControl.js +202 -0
- package/modern/components/promptControl/RecordButton.js +111 -0
- package/modern/components/promptControl/index.js +1 -0
- package/modern/hooks/features/index.js +2 -1
- package/modern/hooks/features/promptControl/api.js +22 -0
- package/modern/hooks/features/promptControl/index.js +1 -0
- package/modern/hooks/features/promptControl/types.js +1 -0
- package/modern/index.js +1 -1
- package/modern/material/icons.js +7 -1
- package/modern/material/index.js +4 -2
- package/modern/utils/releaseInfo.js +1 -1
- package/package.json +7 -7
- package/utils/releaseInfo.js +1 -1
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
5
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
|
+
import { getDataGridUtilityClass, GRID_CHECKBOX_SELECTION_FIELD, gridColumnDefinitionsSelector, gridColumnLookupSelector, GridLogicOperator, gridRowsLookupSelector } from '@mui/x-data-grid';
|
|
7
|
+
import { getValueOptions, getVisibleRows } from '@mui/x-data-grid/internals';
|
|
8
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
9
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
10
|
+
import { RecordButton, BrowserSpeechRecognition } from "./RecordButton.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const supportsSpeechRecognition = !!BrowserSpeechRecognition;
|
|
13
|
+
const useUtilityClasses = (ownerState, recording) => {
|
|
14
|
+
const {
|
|
15
|
+
classes
|
|
16
|
+
} = ownerState;
|
|
17
|
+
const slots = {
|
|
18
|
+
root: ['toolbarPromptControl', recording && 'toolbarPromptControl--recording'],
|
|
19
|
+
recordingIndicator: ['toolbarPromptControlRecordingIndicator'],
|
|
20
|
+
recordButton: ['toolbarPromptControlRecordButton'],
|
|
21
|
+
sendButton: ['toolbarPromptControlSendButton']
|
|
22
|
+
};
|
|
23
|
+
return composeClasses(slots, getDataGridUtilityClass, classes);
|
|
24
|
+
};
|
|
25
|
+
const GridToolbarPromptControlRoot = styled('div', {
|
|
26
|
+
name: 'MuiDataGrid',
|
|
27
|
+
slot: 'ToolbarPromptControl',
|
|
28
|
+
overridesResolver: (_, styles) => styles.toolbarPromptControl
|
|
29
|
+
})({
|
|
30
|
+
flex: 1,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'row'
|
|
33
|
+
});
|
|
34
|
+
function sampleData(apiRef) {
|
|
35
|
+
const columns = gridColumnDefinitionsSelector(apiRef);
|
|
36
|
+
const rows = Object.values(gridRowsLookupSelector(apiRef));
|
|
37
|
+
const columnExamples = {};
|
|
38
|
+
columns.forEach(column => {
|
|
39
|
+
columnExamples[column.field] = Array.from({
|
|
40
|
+
length: Math.min(5, rows.length)
|
|
41
|
+
}).map(() => {
|
|
42
|
+
const row = rows[Math.floor(Math.random() * rows.length)];
|
|
43
|
+
if (column.valueGetter) {
|
|
44
|
+
return column.valueGetter(row[column.field], row, column, apiRef);
|
|
45
|
+
}
|
|
46
|
+
return row[column.field];
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return columnExamples;
|
|
50
|
+
}
|
|
51
|
+
function generateContext(apiRef, examples) {
|
|
52
|
+
const columns = gridColumnDefinitionsSelector(apiRef);
|
|
53
|
+
const columnsContext = columns.map(column => ({
|
|
54
|
+
field: column.field,
|
|
55
|
+
description: column.description ?? null,
|
|
56
|
+
examples: examples?.[column.field] ?? column.unstable_examples ?? [],
|
|
57
|
+
type: column.type ?? 'string',
|
|
58
|
+
allowedOperators: column.filterOperators?.map(operator => operator.value) ?? []
|
|
59
|
+
}));
|
|
60
|
+
return `The columns are described by the following JSON:\n${JSON.stringify(columnsContext)}`;
|
|
61
|
+
}
|
|
62
|
+
function GridToolbarPromptControl(props) {
|
|
63
|
+
const apiRef = useGridApiContext();
|
|
64
|
+
const rootProps = useGridRootProps();
|
|
65
|
+
const {
|
|
66
|
+
onPrompt,
|
|
67
|
+
lang,
|
|
68
|
+
allowDataSampling = false
|
|
69
|
+
} = props;
|
|
70
|
+
const [isLoading, setLoading] = React.useState(false);
|
|
71
|
+
const [error, setError] = React.useState(null);
|
|
72
|
+
const [isRecording, setRecording] = React.useState(false);
|
|
73
|
+
const [query, setQuery] = React.useState('');
|
|
74
|
+
const classes = useUtilityClasses(rootProps, isRecording);
|
|
75
|
+
const examplesFromData = React.useMemo(() => allowDataSampling ? sampleData(apiRef) : undefined, [apiRef, allowDataSampling]);
|
|
76
|
+
const processPrompt = React.useCallback(() => {
|
|
77
|
+
const context = generateContext(apiRef, examplesFromData);
|
|
78
|
+
const columnsByField = gridColumnLookupSelector(apiRef);
|
|
79
|
+
setLoading(true);
|
|
80
|
+
setError(null);
|
|
81
|
+
apiRef.current.setLoading(true);
|
|
82
|
+
onPrompt(context, query).then(result => {
|
|
83
|
+
const interestColumns = [];
|
|
84
|
+
apiRef.current.setFilterModel({
|
|
85
|
+
items: result.filters.map((filter, index) => {
|
|
86
|
+
const item = {
|
|
87
|
+
id: index,
|
|
88
|
+
field: filter.column,
|
|
89
|
+
operator: filter.operator,
|
|
90
|
+
value: filter.value
|
|
91
|
+
};
|
|
92
|
+
const column = columnsByField[filter.column];
|
|
93
|
+
if (column.type === 'singleSelect') {
|
|
94
|
+
const options = getValueOptions(column) ?? [];
|
|
95
|
+
const found = options.find(option => typeof option === 'object' && option.label === filter.value);
|
|
96
|
+
if (found) {
|
|
97
|
+
item.value = found.value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return item;
|
|
101
|
+
}),
|
|
102
|
+
logicOperator: result.filterOperator ?? GridLogicOperator.And,
|
|
103
|
+
quickFilterValues: []
|
|
104
|
+
});
|
|
105
|
+
apiRef.current.setRowGroupingModel(result.grouping.map(g => g.column));
|
|
106
|
+
apiRef.current.setAggregationModel(result.aggregation);
|
|
107
|
+
apiRef.current.setSortModel(result.sorting.map(s => ({
|
|
108
|
+
field: s.column,
|
|
109
|
+
sort: s.direction
|
|
110
|
+
})));
|
|
111
|
+
const rows = getVisibleRows(apiRef, rootProps);
|
|
112
|
+
const selectedRowIds = result.select === -1 ? [] : rows.rows.slice(0, result.select).map(r => {
|
|
113
|
+
return apiRef.current.getRowId(r);
|
|
114
|
+
});
|
|
115
|
+
apiRef.current.setRowSelectionModel(selectedRowIds);
|
|
116
|
+
const columns = apiRef.current.getAllColumns();
|
|
117
|
+
const targetIndex = Number(columns.find(c => c.field === GRID_CHECKBOX_SELECTION_FIELD) !== undefined) + Number(result.grouping.length);
|
|
118
|
+
interestColumns.push(...Object.keys(result.aggregation));
|
|
119
|
+
interestColumns.push(...result.filters.map(f => f.column));
|
|
120
|
+
interestColumns.reverse().forEach(c => apiRef.current.setColumnIndex(c, targetIndex));
|
|
121
|
+
}).catch(_ => {
|
|
122
|
+
setError(apiRef.current.getLocaleText('toolbarPromptControlErrorMessage'));
|
|
123
|
+
}).finally(() => {
|
|
124
|
+
setLoading(false);
|
|
125
|
+
apiRef.current.setState(state => _extends({}, state, {
|
|
126
|
+
rows: _extends({}, state.rows, {
|
|
127
|
+
loading: false
|
|
128
|
+
})
|
|
129
|
+
}));
|
|
130
|
+
});
|
|
131
|
+
}, [apiRef, rootProps, onPrompt, examplesFromData, query]);
|
|
132
|
+
const handleChange = useEventCallback(event => {
|
|
133
|
+
setQuery(event.target.value);
|
|
134
|
+
});
|
|
135
|
+
const handleKeyDown = useEventCallback(event => {
|
|
136
|
+
if (event.code === 'Enter') {
|
|
137
|
+
processPrompt();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const handleDone = useEventCallback(value => {
|
|
141
|
+
setQuery(value);
|
|
142
|
+
if (value) {
|
|
143
|
+
processPrompt();
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
const placeholder = supportsSpeechRecognition ? apiRef.current.getLocaleText('toolbarPromptControlWithRecordingPlaceholder') : apiRef.current.getLocaleText('toolbarPromptControlPlaceholder');
|
|
147
|
+
return /*#__PURE__*/_jsx(GridToolbarPromptControlRoot, {
|
|
148
|
+
ownerState: rootProps,
|
|
149
|
+
className: classes.root,
|
|
150
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTextField, {
|
|
151
|
+
variant: "outlined",
|
|
152
|
+
placeholder: isRecording ? apiRef.current.getLocaleText('toolbarPromptControlRecordingPlaceholder') : placeholder,
|
|
153
|
+
"aria-label": apiRef.current.getLocaleText('toolbarPromptControlLabel'),
|
|
154
|
+
disabled: isLoading,
|
|
155
|
+
value: query,
|
|
156
|
+
style: {
|
|
157
|
+
flex: 1
|
|
158
|
+
},
|
|
159
|
+
onChange: handleChange,
|
|
160
|
+
size: "small",
|
|
161
|
+
onKeyDown: handleKeyDown,
|
|
162
|
+
error: !!error,
|
|
163
|
+
helperText: error,
|
|
164
|
+
InputProps: {
|
|
165
|
+
startAdornment: supportsSpeechRecognition && /*#__PURE__*/_jsx(rootProps.slots.baseInputAdornment, {
|
|
166
|
+
position: "start",
|
|
167
|
+
children: /*#__PURE__*/_jsx(RecordButton, {
|
|
168
|
+
className: classes.recordButton,
|
|
169
|
+
lang: lang,
|
|
170
|
+
recording: isRecording,
|
|
171
|
+
setRecording: setRecording,
|
|
172
|
+
disabled: isLoading,
|
|
173
|
+
onUpdate: setQuery,
|
|
174
|
+
onDone: handleDone,
|
|
175
|
+
onError: setError
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
endAdornment: /*#__PURE__*/_jsx(rootProps.slots.baseInputAdornment, {
|
|
179
|
+
position: "end",
|
|
180
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
181
|
+
title: apiRef.current.getLocaleText('toolbarPromptControlSendActionLabel'),
|
|
182
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
183
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, {
|
|
184
|
+
className: classes.sendButton,
|
|
185
|
+
disabled: isLoading || isRecording || query === '',
|
|
186
|
+
color: "primary",
|
|
187
|
+
onClick: processPrompt,
|
|
188
|
+
size: "small",
|
|
189
|
+
"aria-label": apiRef.current.getLocaleText('toolbarPromptControlSendActionAriaLabel'),
|
|
190
|
+
edge: "end",
|
|
191
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.toolbarPromptSendIcon, {
|
|
192
|
+
fontSize: "small"
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
export { GridToolbarPromptControl };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Timeout } from '@mui/utils/useTimeout';
|
|
3
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
4
|
+
import { useGridApiContext } from "../../hooks/utils/useGridApiContext.js";
|
|
5
|
+
import { useGridRootProps } from "../../hooks/utils/useGridRootProps.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export const BrowserSpeechRecognition = globalThis.SpeechRecognition || globalThis.webkitSpeechRecognition;
|
|
8
|
+
function RecordButton(props) {
|
|
9
|
+
const apiRef = useGridApiContext();
|
|
10
|
+
const rootProps = useGridRootProps();
|
|
11
|
+
const {
|
|
12
|
+
lang,
|
|
13
|
+
recording,
|
|
14
|
+
setRecording,
|
|
15
|
+
disabled,
|
|
16
|
+
className,
|
|
17
|
+
onDone,
|
|
18
|
+
onUpdate,
|
|
19
|
+
onError
|
|
20
|
+
} = props;
|
|
21
|
+
const buttonRef = React.useRef(null);
|
|
22
|
+
const recognition = useLazyRef(() => {
|
|
23
|
+
if (!BrowserSpeechRecognition) {
|
|
24
|
+
return {
|
|
25
|
+
start: () => {},
|
|
26
|
+
abort: () => {}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const timeout = new Timeout();
|
|
30
|
+
const instance = new BrowserSpeechRecognition();
|
|
31
|
+
instance.continuous = true;
|
|
32
|
+
instance.interimResults = true;
|
|
33
|
+
instance.lang = lang;
|
|
34
|
+
let finalResult = '';
|
|
35
|
+
let interimResult = '';
|
|
36
|
+
function start(options) {
|
|
37
|
+
if (recording) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
setRecording(true);
|
|
41
|
+
instance.onresult = event => {
|
|
42
|
+
finalResult = '';
|
|
43
|
+
interimResult = '';
|
|
44
|
+
if (typeof event.results === 'undefined') {
|
|
45
|
+
instance.stop();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (let i = event.resultIndex; i < event.results.length; i += 1) {
|
|
49
|
+
if (event.results[i].isFinal) {
|
|
50
|
+
finalResult += event.results[i][0].transcript;
|
|
51
|
+
} else {
|
|
52
|
+
interimResult += event.results[i][0].transcript;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (finalResult === '') {
|
|
56
|
+
options.onUpdate(interimResult);
|
|
57
|
+
}
|
|
58
|
+
timeout.start(1000, () => instance.stop());
|
|
59
|
+
};
|
|
60
|
+
instance.onsoundend = () => {
|
|
61
|
+
instance.stop();
|
|
62
|
+
};
|
|
63
|
+
instance.onend = () => {
|
|
64
|
+
options.onDone(finalResult);
|
|
65
|
+
setRecording(false);
|
|
66
|
+
};
|
|
67
|
+
instance.onerror = error => {
|
|
68
|
+
options.onError(error.message);
|
|
69
|
+
instance.stop();
|
|
70
|
+
setRecording(false);
|
|
71
|
+
};
|
|
72
|
+
instance.start();
|
|
73
|
+
}
|
|
74
|
+
function abort() {
|
|
75
|
+
instance.abort();
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
start,
|
|
79
|
+
abort
|
|
80
|
+
};
|
|
81
|
+
}).current;
|
|
82
|
+
const handleClick = () => {
|
|
83
|
+
if (!recording) {
|
|
84
|
+
recognition.start({
|
|
85
|
+
onDone,
|
|
86
|
+
onUpdate,
|
|
87
|
+
onError
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
recognition.abort();
|
|
92
|
+
};
|
|
93
|
+
return /*#__PURE__*/_jsx(rootProps.slots.baseTooltip, {
|
|
94
|
+
title: recording ? apiRef.current.getLocaleText('toolbarPromptControlRecordButtonActiveLabel') : apiRef.current.getLocaleText('toolbarPromptControlRecordButtonDefaultLabel'),
|
|
95
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
96
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.baseIconButton, {
|
|
97
|
+
color: recording ? 'primary' : 'default',
|
|
98
|
+
className: className,
|
|
99
|
+
disabled: disabled,
|
|
100
|
+
onClick: handleClick,
|
|
101
|
+
ref: buttonRef,
|
|
102
|
+
size: "small",
|
|
103
|
+
edge: "start",
|
|
104
|
+
children: /*#__PURE__*/_jsx(rootProps.slots.toolbarPromptRecordIcon, {
|
|
105
|
+
fontSize: "small"
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export { RecordButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { GridToolbarPromptControl as Unstable_GridToolbarPromptControl } from "./GridToolbarPromptControl.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function gridDefaultPromptResolver(url, context, query) {
|
|
2
|
+
return fetch(url, {
|
|
3
|
+
mode: 'cors',
|
|
4
|
+
method: 'POST',
|
|
5
|
+
headers: {
|
|
6
|
+
'content-type': 'application/json'
|
|
7
|
+
},
|
|
8
|
+
credentials: 'include',
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
context,
|
|
11
|
+
query
|
|
12
|
+
})
|
|
13
|
+
}).then(result => result.json()).then(result => {
|
|
14
|
+
if (result.ok === false) {
|
|
15
|
+
return Promise.reject(new Error(result.message));
|
|
16
|
+
}
|
|
17
|
+
if (result.data.error) {
|
|
18
|
+
return Promise.reject(new Error(result.data.error));
|
|
19
|
+
}
|
|
20
|
+
return result.data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { gridDefaultPromptResolver as unstable_gridDefaultPromptResolver } from "./api.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/material/icons.js
CHANGED
|
@@ -11,4 +11,10 @@ export const GridGroupWorkIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
|
|
|
11
11
|
}), 'GroupWork');
|
|
12
12
|
export const GridFunctionsIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
|
|
13
13
|
d: "M18 4H6v2l6.5 6L6 18v2h12v-3h-7l5-5-5-5h7z"
|
|
14
|
-
}), 'Functions');
|
|
14
|
+
}), 'Functions');
|
|
15
|
+
export const GridSendPromptIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
|
|
16
|
+
d: "M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"
|
|
17
|
+
}), 'SendPrompt');
|
|
18
|
+
export const GridRecordPromptIcon = createSvgIcon(/*#__PURE__*/_jsx("path", {
|
|
19
|
+
d: "M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3m5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72z"
|
|
20
|
+
}), 'RecordPrompt');
|
package/esm/material/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { GridWorkspacesIcon, GridGroupWorkIcon, GridFunctionsIcon } from "./icons.js";
|
|
2
|
+
import { GridWorkspacesIcon, GridGroupWorkIcon, GridFunctionsIcon, GridSendPromptIcon, GridRecordPromptIcon } from "./icons.js";
|
|
3
3
|
const iconsSlots = {
|
|
4
4
|
columnMenuUngroupIcon: GridWorkspacesIcon,
|
|
5
5
|
columnMenuGroupIcon: GridGroupWorkIcon,
|
|
6
|
-
columnMenuAggregationIcon: GridFunctionsIcon
|
|
6
|
+
columnMenuAggregationIcon: GridFunctionsIcon,
|
|
7
|
+
toolbarPromptSendIcon: GridSendPromptIcon,
|
|
8
|
+
toolbarPromptRecordIcon: GridRecordPromptIcon
|
|
7
9
|
};
|
|
8
10
|
const materialSlots = _extends({}, iconsSlots);
|
|
9
11
|
export default materialSlots;
|
package/esm/utils/releaseInfo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTczMjgzNDgwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -65,6 +65,7 @@ export declare const unwrapColumnFromAggregation: ({ column, }: {
|
|
|
65
65
|
disableReorder?: boolean;
|
|
66
66
|
disableExport?: boolean;
|
|
67
67
|
colSpan?: number | import("@mui/x-data-grid").GridColSpanFn<import("@mui/x-data-grid").GridValidRowModel, any, any> | undefined;
|
|
68
|
+
unstable_examples?: any[] | undefined;
|
|
68
69
|
renderHeaderFilter?: (params: import("@mui/x-data-grid-pro").GridRenderHeaderFilterProps) => React.ReactNode;
|
|
69
70
|
aggregable?: boolean;
|
|
70
71
|
availableAggregationFunctions?: string[];
|
package/hooks/features/index.js
CHANGED
|
@@ -46,4 +46,15 @@ Object.keys(_cellSelection).forEach(function (key) {
|
|
|
46
46
|
return _cellSelection[key];
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
+
});
|
|
50
|
+
var _promptControl = require("./promptControl");
|
|
51
|
+
Object.keys(_promptControl).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _promptControl[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _promptControl[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
49
60
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.gridDefaultPromptResolver = gridDefaultPromptResolver;
|
|
7
|
+
function gridDefaultPromptResolver(url, context, query) {
|
|
8
|
+
return fetch(url, {
|
|
9
|
+
mode: 'cors',
|
|
10
|
+
method: 'POST',
|
|
11
|
+
headers: {
|
|
12
|
+
'content-type': 'application/json'
|
|
13
|
+
},
|
|
14
|
+
credentials: 'include',
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
context,
|
|
17
|
+
query
|
|
18
|
+
})
|
|
19
|
+
}).then(result => result.json()).then(result => {
|
|
20
|
+
if (result.ok === false) {
|
|
21
|
+
return Promise.reject(new Error(result.message));
|
|
22
|
+
}
|
|
23
|
+
if (result.data.error) {
|
|
24
|
+
return Promise.reject(new Error(result.data.error));
|
|
25
|
+
}
|
|
26
|
+
return result.data;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "unstable_gridDefaultPromptResolver", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _api.gridDefaultPromptResolver;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _api = require("./api");
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Sort = {
|
|
2
|
+
column: string;
|
|
3
|
+
direction: 'asc' | 'desc';
|
|
4
|
+
};
|
|
5
|
+
export type Grouping = {
|
|
6
|
+
column: string;
|
|
7
|
+
};
|
|
8
|
+
export type Filter = {
|
|
9
|
+
operator: string;
|
|
10
|
+
value: string | number | boolean | string[] | number[];
|
|
11
|
+
column: string;
|
|
12
|
+
};
|
|
13
|
+
export type AggregationFunction = 'avg' | 'sum' | 'min' | 'max' | 'size';
|
|
14
|
+
export type Aggregation = {
|
|
15
|
+
[column: string]: AggregationFunction;
|
|
16
|
+
};
|
|
17
|
+
export type PromptResponse = {
|
|
18
|
+
select: number;
|
|
19
|
+
filters: Filter[];
|
|
20
|
+
filterOperator?: 'and' | 'or';
|
|
21
|
+
aggregation: Aggregation;
|
|
22
|
+
sorting: Sort[];
|
|
23
|
+
grouping: Grouping[];
|
|
24
|
+
error: string | null;
|
|
25
|
+
};
|
package/index.js
CHANGED
package/material/icons.d.ts
CHANGED
|
@@ -7,3 +7,9 @@ export declare const GridGroupWorkIcon: import("@mui/material/OverridableCompone
|
|
|
7
7
|
export declare const GridFunctionsIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
8
8
|
muiName: string;
|
|
9
9
|
};
|
|
10
|
+
export declare const GridSendPromptIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
11
|
+
muiName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const GridRecordPromptIcon: import("@mui/material/OverridableComponent").OverridableComponent<import("@mui/material").SvgIconTypeMap<{}, "svg">> & {
|
|
14
|
+
muiName: string;
|
|
15
|
+
};
|
package/material/icons.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.GridWorkspacesIcon = exports.GridGroupWorkIcon = exports.GridFunctionsIcon = void 0;
|
|
7
|
+
exports.GridWorkspacesIcon = exports.GridSendPromptIcon = exports.GridRecordPromptIcon = exports.GridGroupWorkIcon = exports.GridFunctionsIcon = void 0;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _utils = require("@mui/material/utils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -18,4 +18,10 @@ const GridGroupWorkIcon = exports.GridGroupWorkIcon = (0, _utils.createSvgIcon)(
|
|
|
18
18
|
}), 'GroupWork');
|
|
19
19
|
const GridFunctionsIcon = exports.GridFunctionsIcon = (0, _utils.createSvgIcon)(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
20
20
|
d: "M18 4H6v2l6.5 6L6 18v2h12v-3h-7l5-5-5-5h7z"
|
|
21
|
-
}), 'Functions');
|
|
21
|
+
}), 'Functions');
|
|
22
|
+
const GridSendPromptIcon = exports.GridSendPromptIcon = (0, _utils.createSvgIcon)(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
23
|
+
d: "M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"
|
|
24
|
+
}), 'SendPrompt');
|
|
25
|
+
const GridRecordPromptIcon = exports.GridRecordPromptIcon = (0, _utils.createSvgIcon)(/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
26
|
+
d: "M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3m5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72z"
|
|
27
|
+
}), 'RecordPrompt');
|
package/material/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ declare const materialSlots: {
|
|
|
2
2
|
columnMenuUngroupIcon: React.JSXElementConstructor<any>;
|
|
3
3
|
columnMenuGroupIcon: React.JSXElementConstructor<any>;
|
|
4
4
|
columnMenuAggregationIcon: React.JSXElementConstructor<any>;
|
|
5
|
+
toolbarPromptSendIcon: React.JSXElementConstructor<any>;
|
|
6
|
+
toolbarPromptRecordIcon: React.JSXElementConstructor<any>;
|
|
5
7
|
};
|
|
6
8
|
export default materialSlots;
|
package/material/index.js
CHANGED
|
@@ -10,7 +10,9 @@ var _icons = require("./icons");
|
|
|
10
10
|
const iconsSlots = {
|
|
11
11
|
columnMenuUngroupIcon: _icons.GridWorkspacesIcon,
|
|
12
12
|
columnMenuGroupIcon: _icons.GridGroupWorkIcon,
|
|
13
|
-
columnMenuAggregationIcon: _icons.GridFunctionsIcon
|
|
13
|
+
columnMenuAggregationIcon: _icons.GridFunctionsIcon,
|
|
14
|
+
toolbarPromptSendIcon: _icons.GridSendPromptIcon,
|
|
15
|
+
toolbarPromptRecordIcon: _icons.GridRecordPromptIcon
|
|
14
16
|
};
|
|
15
17
|
const materialSlots = (0, _extends2.default)({}, iconsSlots);
|
|
16
18
|
var _default = exports.default = materialSlots;
|
|
@@ -15,4 +15,14 @@ export interface GridPremiumIconSlotsComponent {
|
|
|
15
15
|
* @default GridFunctionsIcon
|
|
16
16
|
*/
|
|
17
17
|
columnMenuAggregationIcon: React.JSXElementConstructor<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Icon used for the button that sends a prompt
|
|
20
|
+
* @default GridFunctionsIcon
|
|
21
|
+
*/
|
|
22
|
+
toolbarPromptSendIcon: React.JSXElementConstructor<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Icon used for the button that starts/stops recording the prompt
|
|
25
|
+
* @default GridFunctionsIcon
|
|
26
|
+
*/
|
|
27
|
+
toolbarPromptRecordIcon: React.JSXElementConstructor<any>;
|
|
18
28
|
}
|
|
@@ -452,14 +452,6 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
452
452
|
clipboardExport: PropTypes.bool,
|
|
453
453
|
csvExport: PropTypes.bool
|
|
454
454
|
}), PropTypes.bool]),
|
|
455
|
-
/**
|
|
456
|
-
* If `select`, a group header checkbox in indeterminate state (like "Select All" checkbox)
|
|
457
|
-
* will select all the rows under it.
|
|
458
|
-
* If `deselect`, it will deselect all the rows under it.
|
|
459
|
-
* Works only if `checkboxSelection` is enabled.
|
|
460
|
-
* @default "deselect"
|
|
461
|
-
*/
|
|
462
|
-
indeterminateCheckboxAction: PropTypes.oneOf(['deselect', 'select']),
|
|
463
455
|
/**
|
|
464
456
|
* The initial state of the DataGridPremium.
|
|
465
457
|
* The data in it is set in the state on initialization but isn't controlled.
|
|
@@ -964,7 +956,7 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
964
956
|
* - Deselecting a descendant of a selected parent deselects the parent automatically.
|
|
965
957
|
*
|
|
966
958
|
* Works with tree data and row grouping on the client-side only.
|
|
967
|
-
* @default { parents:
|
|
959
|
+
* @default { parents: true, descendants: true }
|
|
968
960
|
*/
|
|
969
961
|
rowSelectionPropagation: PropTypes.shape({
|
|
970
962
|
descendants: PropTypes.bool,
|
|
@@ -1081,7 +1073,15 @@ process.env.NODE_ENV !== "production" ? DataGridPremiumRaw.propTypes = {
|
|
|
1081
1073
|
* If `true`, the Data Grid will auto span the cells over the rows having the same value.
|
|
1082
1074
|
* @default false
|
|
1083
1075
|
*/
|
|
1084
|
-
unstable_rowSpanning: PropTypes.bool
|
|
1076
|
+
unstable_rowSpanning: PropTypes.bool,
|
|
1077
|
+
/**
|
|
1078
|
+
* If `true`, the Data Grid enables column virtualization when `getRowHeight` is set to `() => 'auto'`.
|
|
1079
|
+
* By default, column virtualization is disabled when dynamic row height is enabled to measure the row height correctly.
|
|
1080
|
+
* For datasets with a large number of columns, this can cause performance issues.
|
|
1081
|
+
* The downside of enabling this prop is that the row height will be estimated based the cells that are currently rendered, which can cause row height change when scrolling horizontally.
|
|
1082
|
+
* @default false
|
|
1083
|
+
*/
|
|
1084
|
+
virtualizeColumnsWithAutoRowHeight: PropTypes.bool
|
|
1085
1085
|
} : void 0;
|
|
1086
1086
|
/**
|
|
1087
1087
|
* Demos:
|