Skip to content

Commit

Permalink
Merge branch 'master' into valueGetter-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Sep 16, 2024
2 parents a920a3a + 2777772 commit 738deb2
Show file tree
Hide file tree
Showing 24 changed files with 171 additions and 55 deletions.
2 changes: 1 addition & 1 deletion changelogOld/CHANGELOG.v6.md
Original file line number Diff line number Diff line change
Expand Up @@ -5374,7 +5374,7 @@ You can find more information about the new api, including how to set those tran
- [pickers] Clean slots on `PickersArrowSwitcher` component (#5890) @flaviendelangle
- [pickers] Fix invalid date error when decreasing `DateField` day (#6071) @alexfauquette
- [pickers] Fix mobile section selection (#6207) @oliviertassinari
- [pickers] Fix usage with Typescript 4.8 (#6229) @flaviendelangle
- [pickers] Fix usage with TypeScript 4.8 (#6229) @flaviendelangle
- [pickers] Improve error message when no adapter context is found (#6211) @flaviendelangle
- [pickers] Remove `valueStr` from the field state (#6142) @flaviendelangle
- [pickers] Remove remaining deprecated locale props (#6233) @flaviendelangle
Expand Down
2 changes: 1 addition & 1 deletion docs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
3 changes: 3 additions & 0 deletions docs/public/_headers
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: strict-origin-when-cross-origin
# TODO: progressively reduce the CSP scopes
# Start with a wildcard, using https://github.com/mui/mui-toolpad/blob/f4c4eb046b352e4fc00729c3bed605e671b040c4/packages/toolpad-studio/src/server/index.ts#L241
Content-Security-Policy: default-src * data: mediastream: blob: filesystem: about: ws: wss: 'unsafe-eval' 'wasm-unsafe-eval' 'unsafe-inline'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; script-src-elem * data: blob: 'unsafe-inline'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; media-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline'; frame-ancestors *;
2 changes: 1 addition & 1 deletion packages/eslint-plugin-material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git"
"url": "git+https://github.com/mui/mui-x.git"
},
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/x-charts-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-charts-pro"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts-vendor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-charts-vendor"
},
"license": "MIT AND ISC",
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-charts"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-codemod"
},
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-data-grid-generator"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-premium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-data-grid-premium"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-data-grid-pro"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-data-grid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-data-grid"
},
"dependencies": {
Expand Down
19 changes: 13 additions & 6 deletions packages/x-data-grid/src/components/cell/GridCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
unstable_capitalize as capitalize,
} from '@mui/utils';
import { fastMemo } from '@mui/x-internals/fastMemo';
import { useRtl } from '@mui/system/RtlProvider';
import { doesSupportPreventScroll } from '../../utils/doesSupportPreventScroll';
import { getDataGridUtilityClass, gridClasses } from '../../constants/gridClasses';
import {
Expand Down Expand Up @@ -175,6 +176,7 @@ const GridCell = React.forwardRef<HTMLDivElement, GridCellProps>(function GridCe

const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
const isRtl = useRtl();

const field = column.field;

Expand Down Expand Up @@ -334,16 +336,21 @@ const GridCell = React.forwardRef<HTMLDivElement, GridCellProps>(function GridCe
...styleProp,
};

if (pinnedPosition === PinnedPosition.LEFT) {
cellStyle.left = pinnedOffset;
}
const isLeftPinned = pinnedPosition === PinnedPosition.LEFT;
const isRightPinned = pinnedPosition === PinnedPosition.RIGHT;

if (isLeftPinned || isRightPinned) {
let side: 'left' | 'right' = isLeftPinned ? 'left' : 'right';

if (isRtl) {
side = isLeftPinned ? 'right' : 'left';
}

if (pinnedPosition === PinnedPosition.RIGHT) {
cellStyle.right = pinnedOffset;
cellStyle[side] = pinnedOffset;
}

return cellStyle;
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition]);
}, [width, isNotVisible, styleProp, pinnedOffset, pinnedPosition, isRtl]);

React.useEffect(() => {
if (!hasFocus || cellMode === GridCellModes.Edit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,7 @@ export const useGridColumnHeaders = (props: UseGridColumnHeadersProps) => {
const renderContext = useGridSelector(apiRef, gridRenderContextColumnsSelector);
const pinnedColumns = useGridSelector(apiRef, gridVisiblePinnedColumnDefinitionsSelector);
const columnsLookup = useGridSelector(apiRef, gridColumnLookupSelector);
const offsetLeft = computeOffsetLeft(
columnPositions,
renderContext,
isRtl,
pinnedColumns.left.length,
);
const offsetLeft = computeOffsetLeft(columnPositions, renderContext, pinnedColumns.left.length);
const gridHasFiller = dimensions.columnsTotalWidth < dimensions.viewportOuterSize.width;

React.useEffect(() => {
Expand Down Expand Up @@ -230,20 +225,30 @@ export const useGridColumnHeaders = (props: UseGridColumnHeadersProps) => {
computedWidth: number;
}) => {
let style: React.CSSProperties | undefined;
if (pinnedPosition === 'left' || pinnedPosition === 'right') {

const isLeftPinned = pinnedPosition === GridPinnedColumnPosition.LEFT;
const isRightPinned = pinnedPosition === GridPinnedColumnPosition.RIGHT;

if (isLeftPinned || isRightPinned) {
const pinnedOffset = getPinnedCellOffset(
pinnedPosition,
computedWidth,
columnIndex,
columnPositions,
dimensions,
);
let side = isLeftPinned ? 'left' : 'right';

if (isRtl) {
side = isLeftPinned ? 'right' : 'left';
}

if (pinnedPosition === 'left') {
style = { left: pinnedOffset };
style = { [side]: pinnedOffset };
}

if (pinnedPosition === 'right') {
style = { right: pinnedOffset };
style = { [side]: pinnedOffset };
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,14 @@ export const useGridColumnResize = (

refs.cellElements = findGridCellElementsFromCol(refs.columnHeaderElement, apiRef.current);

refs.fillerLeft = findGridElement(apiRef.current, 'filler--pinnedLeft');
refs.fillerRight = findGridElement(apiRef.current, 'filler--pinnedRight');
refs.fillerLeft = findGridElement(
apiRef.current,
isRtl ? 'filler--pinnedRight' : 'filler--pinnedLeft',
);
refs.fillerRight = findGridElement(
apiRef.current,
isRtl ? 'filler--pinnedLeft' : 'filler--pinnedRight',
);

const pinnedPosition = apiRef.current.unstable_applyPipeProcessors(
'isColumnPinned',
Expand All @@ -468,20 +474,20 @@ export const useGridColumnResize = (
refs.leftPinnedCellsAfter =
pinnedPosition !== GridPinnedColumnPosition.LEFT
? []
: findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement);
: findLeftPinnedCellsAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
refs.rightPinnedCellsBefore =
pinnedPosition !== GridPinnedColumnPosition.RIGHT
? []
: findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement);
: findRightPinnedCellsBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);

refs.leftPinnedHeadersAfter =
pinnedPosition !== GridPinnedColumnPosition.LEFT
? []
: findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement);
: findLeftPinnedHeadersAfterCol(apiRef.current, refs.columnHeaderElement, isRtl);
refs.rightPinnedHeadersBefore =
pinnedPosition !== GridPinnedColumnPosition.RIGHT
? []
: findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement);
: findRightPinnedHeadersBeforeCol(apiRef.current, refs.columnHeaderElement, isRtl);

resizeDirection.current = getResizeDirection(separator, isRtl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ export const useGridVirtualScroller = () => {
const offsetLeft = computeOffsetLeft(
columnPositions,
currentRenderContext,
isRtl,
pinnedColumns.left.length,
);
const showBottomBorder = isLastVisibleInSection && params.position === 'top';
Expand Down Expand Up @@ -939,14 +938,11 @@ export function areRenderContextsEqual(context1: GridRenderContext, context2: Gr
export function computeOffsetLeft(
columnPositions: number[],
renderContext: GridColumnsRenderContext,
isRtl: boolean,
pinnedLeftLength: number,
) {
const factor = isRtl ? -1 : 1;
const left =
factor * (columnPositions[renderContext.firstColumnIndex] ?? 0) -
(columnPositions[renderContext.firstColumnIndex] ?? 0) -
(columnPositions[pinnedLeftLength] ?? 0);

return Math.abs(left);
}

Expand Down
40 changes: 28 additions & 12 deletions packages/x-data-grid/src/utils/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,31 @@ const findPinnedCells = ({
return cells;
};

export function findLeftPinnedCellsAfterCol(api: GridPrivateApiCommunity, col: HTMLElement) {
export function findLeftPinnedCellsAfterCol(
api: GridPrivateApiCommunity,
col: HTMLElement,
isRtl: boolean,
) {
const colIndex = parseCellColIndex(col);
return findPinnedCells({
api,
colIndex,
position: 'left',
filterFn: (index) => index > colIndex!,
position: isRtl ? 'right' : 'left',
filterFn: (index) => (isRtl ? index < colIndex! : index > colIndex!),
});
}

export function findRightPinnedCellsBeforeCol(api: GridPrivateApiCommunity, col: HTMLElement) {
export function findRightPinnedCellsBeforeCol(
api: GridPrivateApiCommunity,
col: HTMLElement,
isRtl: boolean,
) {
const colIndex = parseCellColIndex(col);
return findPinnedCells({
api,
colIndex,
position: 'right',
filterFn: (index) => index < colIndex!,
position: isRtl ? 'left' : 'right',
filterFn: (index) => (isRtl ? index > colIndex! : index < colIndex!),
});
}

Expand Down Expand Up @@ -218,23 +226,31 @@ const findPinnedHeaders = ({
return elements;
};

export function findLeftPinnedHeadersAfterCol(api: GridPrivateApiCommunity, col: HTMLElement) {
export function findLeftPinnedHeadersAfterCol(
api: GridPrivateApiCommunity,
col: HTMLElement,
isRtl: boolean,
) {
const colIndex = parseCellColIndex(col);
return findPinnedHeaders({
api,
position: 'left',
position: isRtl ? 'right' : 'left',
colIndex,
filterFn: (index) => index > colIndex!,
filterFn: (index) => (isRtl ? index < colIndex! : index > colIndex!),
});
}

export function findRightPinnedHeadersBeforeCol(api: GridPrivateApiCommunity, col: HTMLElement) {
export function findRightPinnedHeadersBeforeCol(
api: GridPrivateApiCommunity,
col: HTMLElement,
isRtl: boolean,
) {
const colIndex = parseCellColIndex(col);
return findPinnedHeaders({
api,
position: 'right',
position: isRtl ? 'left' : 'right',
colIndex,
filterFn: (index) => index < colIndex!,
filterFn: (index) => (isRtl ? index > colIndex! : index < colIndex!),
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/x-date-pickers-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-date-pickers-pro"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-date-pickers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-date-pickers"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-internals"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-license/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-license"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-tree-view-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-tree-view-pro"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/x-tree-view/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/mui/mui-x.git",
"url": "git+https://github.com/mui/mui-x.git",
"directory": "packages/x-tree-view"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 738deb2

Please sign in to comment.