Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh committed Nov 20, 2024
1 parent e19091c commit 892e9b3
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 33 deletions.
12 changes: 6 additions & 6 deletions docs/data/data-grid/prompt/PromptWithDataSampling.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import {
DataGridPremium,
Unstable_GridToolbarPromptControl as GridToolbarPromptControl,
GridToolbar,
GridToolbarContainer,
} from '@mui/x-data-grid-premium';
import { mockPromptResolver, useDemoData } from '@mui/x-data-grid-generator';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';

function ToolbarWithPromptInput() {
return (
<GridToolbarContainer sx={{ p: 1 }}>
<Stack flex={1} gap={1}>
<GridToolbar />
<Stack flex={1} gap={0.5} sx={{ px: 0.5 }}>
<GridToolbar />
<Box sx={{ px: 0.5 }}>
<GridToolbarPromptControl onPrompt={mockPromptResolver} allowDataSampling />
</Stack>
</GridToolbarContainer>
</Box>
</Stack>
);
}

Expand Down
11 changes: 6 additions & 5 deletions docs/data/data-grid/prompt/PromptWithDataSampling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import {
} from '@mui/x-data-grid-premium';
import { mockPromptResolver, useDemoData } from '@mui/x-data-grid-generator';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';

function ToolbarWithPromptInput() {
return (
<GridToolbarContainer sx={{ p: 1 }}>
<Stack flex={1} gap={1}>
<GridToolbar />
<Stack flex={1} gap={0.5} sx={{ px: 0.5 }}>
<GridToolbar />
<Box sx={{ px: 0.5 }}>
<GridToolbarPromptControl onPrompt={mockPromptResolver} allowDataSampling />
</Stack>
</GridToolbarContainer>
</Box>
</Stack>
);
}

Expand Down
24 changes: 14 additions & 10 deletions docs/data/data-grid/prompt/PromptWithExamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
DataGridPremium,
Unstable_GridToolbarPromptControl as GridToolbarPromptControl,
GridToolbar,
GridToolbarContainer,
} from '@mui/x-data-grid-premium';
import {
mockPromptResolver,
Expand All @@ -19,15 +18,16 @@ import {
useDemoData,
} from '@mui/x-data-grid-generator';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';

function ToolbarWithPromptInput() {
return (
<GridToolbarContainer sx={{ p: 1 }}>
<Stack flex={1} gap={1}>
<GridToolbar />
<Stack flex={1} gap={0.5} sx={{ px: 0.5 }}>
<GridToolbar />
<Box sx={{ px: 0.5 }}>
<GridToolbarPromptControl onPrompt={mockPromptResolver} />
</Stack>
</GridToolbarContainer>
</Box>
</Stack>
);
}

Expand Down Expand Up @@ -75,10 +75,14 @@ export default function PromptWithExamples() {
rowLength: 10000,
});

const columns = data.columns.map((column) => ({
...column,
unstable_examples: createExamples(column.field),
}));
const columns = React.useMemo(
() =>
data.columns.map((column) => ({
...column,
unstable_examples: createExamples(column.field),
})),
[],
);

return (
<div style={{ height: 500, width: '100%' }}>
Expand Down
23 changes: 14 additions & 9 deletions docs/data/data-grid/prompt/PromptWithExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ import {
useDemoData,
} from '@mui/x-data-grid-generator';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box';

function ToolbarWithPromptInput() {
return (
<GridToolbarContainer sx={{ p: 1 }}>
<Stack flex={1} gap={1}>
<GridToolbar />
<Stack flex={1} gap={0.5} sx={{ px: 0.5 }}>
<GridToolbar />
<Box sx={{ px: 0.5 }}>
<GridToolbarPromptControl onPrompt={mockPromptResolver} />
</Stack>
</GridToolbarContainer>
</Box>
</Stack>
);
}

Expand Down Expand Up @@ -75,10 +76,14 @@ export default function PromptWithExamples() {
rowLength: 10000,
});

const columns = data.columns.map((column) => ({
...column,
unstable_examples: createExamples(column.field),
}));
const columns = React.useMemo(
() =>
data.columns.map((column) => ({
...column,
unstable_examples: createExamples(column.field),
})),
[],
);

return (
<div style={{ height: 500, width: '100%' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ function GridToolbarPromptControl(props: GridToolbarPromptControlProps) {
aria-label={apiRef.current.getLocaleText(
'toolbarPromptControlSendActionAriaLabel',
)}
edge="end"
>
<rootProps.slots.toolbarPromptSendIcon fontSize="small" />
</rootProps.slots.baseIconButton>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import useEventCallback from '@mui/utils/useEventCallback';
import { Timeout } from '@mui/utils/useTimeout';
import useLazyRef from '@mui/utils/useLazyRef';
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
Expand Down Expand Up @@ -90,14 +89,14 @@ function RecordButton(props: RecordButtonProps) {
return { start, abort };
}).current;

const handleClick = useEventCallback(() => {
const handleClick = () => {
if (!recording) {
recognition.start({ onDone, onUpdate });
return;
}

recognition.abort();
});
};

return (
BrowserSpeechRecognition && (
Expand All @@ -116,6 +115,7 @@ function RecordButton(props: RecordButtonProps) {
onClick={handleClick}
ref={buttonRef}
size="small"
edge="start"
>
<rootProps.slots.toolbarPromptRecordIcon fontSize="small" />
</rootProps.slots.baseIconButton>
Expand Down

0 comments on commit 892e9b3

Please sign in to comment.