Skip to content

Commit

Permalink
release v1.11.4 - right column pinning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed May 19, 2023
1 parent 7c4a802 commit 5e8add9
Show file tree
Hide file tree
Showing 25 changed files with 355 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ES_Table from '../examples/localization-i18n-es';
import FA_Table from '../examples/localization-i18n-fa';
import FI_Table from '../examples/localization-i18n-fi';
import FR_Table from '../examples/localization-i18n-fr';
import HU_Table from '../examples/localization-i18n-hu';
import ID_Table from '../examples/localization-i18n-id';
import IT_Table from '../examples/localization-i18n-it';
import JA_Table from '../examples/localization-i18n-ja';
Expand Down Expand Up @@ -36,6 +37,7 @@ const supportedLocales = [
'fa',
'fi',
'fr',
'hu',
'id',
'it',
'ja',
Expand Down Expand Up @@ -88,6 +90,7 @@ const LocaleExamples = () => {
{currentLocale === 'fa' && <FA_Table />}
{currentLocale === 'fi' && <FI_Table />}
{currentLocale === 'fr' && <FR_Table />}
{currentLocale === 'hu' && <HU_Table />}
{currentLocale === 'id' && <ID_Table />}
{currentLocale === 'it' && <IT_Table />}
{currentLocale === 'ja' && <JA_Table />}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { SourceCodeSnippet } from '../../components/mdx/SourceCodeSnippet';
import Example from './sandbox/src/TS';
const JS = require('!!raw-loader!./sandbox/src/JS.js').default;
const TS = require('!!raw-loader!./sandbox/src/TS.tsx').default;

const ExampleTable = () => {
return (
<SourceCodeSnippet
Component={Example}
javaScriptCode={JS}
typeScriptCode={TS}
tableId="localization-i18n-hu"
/>
);
};

export default ExampleTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Example

To run this example:

- `npm install` or `yarn`
- `npm run start` or `yarn start`
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Material React Table Example</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "material-react-table-example-localization-i18n-hu",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --port 3001",
"build": "vite build",
"serve": "vite preview",
"start": "vite"
},
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.12.1",
"material-react-table": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react": "^4.0.0",
"typescript": "^5.0.4",
"vite": "^4.3.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';

//Import Material React Table and its Types
import MaterialReactTable from 'material-react-table';

//Import Material React Table Translations
import { MRT_Localization_HU } from 'material-react-table/locales/hu';

//mock data
import { data } from './makeData';

const columns = [
//column definitions...
{
accessorKey: 'firstName',
header: 'Keresztnév',
},
{
accessorKey: 'lastName',
header: 'Vezetéknév',
enableClickToCopy: true,
},
{
accessorKey: 'age',
header: 'Kor',
},
//end
];

const Example = () => {
return (
<MaterialReactTable
columns={columns}
data={data}
enableColumnFilterModes
enableColumnOrdering
enableEditing
enablePinning
enableRowActions
enableRowSelection
enableSelectAll={false}
initialState={{ showColumnFilters: true, showGlobalFilter: true }}
localization={MRT_Localization_HU}
/>
);
};

//App.tsx or similar
import { createTheme, ThemeProvider, useTheme } from '@mui/material';
import { huHU } from '@mui/material/locale';

const ExampleWithThemeProvider = () => {
const theme = useTheme(); //replace with your theme/createTheme
return (
//Setting Material UI locale as best practice to result in better accessibility
<ThemeProvider theme={createTheme(theme, huHU)}>
<Example />
</ThemeProvider>
);
};

export default ExampleWithThemeProvider;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import React from 'react';

//Import Material React Table and its Types
import MaterialReactTable, { type MRT_ColumnDef } from 'material-react-table';

//Import Material React Table Translations
import { MRT_Localization_HU } from 'material-react-table/locales/hu';

//mock data
import { data, type Person } from './makeData';

const columns: MRT_ColumnDef<Person>[] = [
//column definitions...
{
accessorKey: 'firstName',
header: 'Keresztnév',
},
{
accessorKey: 'lastName',
header: 'Vezetéknév',
enableClickToCopy: true,
},
{
accessorKey: 'age',
header: 'Kor',
},
//end
];

const Example = () => {
return (
<MaterialReactTable
columns={columns}
data={data}
enableColumnFilterModes
enableColumnOrdering
enableEditing
enablePinning
enableRowActions
enableRowSelection
enableSelectAll={false}
initialState={{ showColumnFilters: true, showGlobalFilter: true }}
localization={MRT_Localization_HU}
/>
);
};

//App.tsx or similar
import { createTheme, ThemeProvider, useTheme } from '@mui/material';
import { huHU } from '@mui/material/locale';

const ExampleWithThemeProvider = () => {
const theme = useTheme(); //replace with your theme/createTheme
return (
//Setting Material UI locale as best practice to result in better accessibility
<ThemeProvider theme={createTheme(theme, huHU)}>
<Example />
</ThemeProvider>
);
};

export default ExampleWithThemeProvider;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import Example from './TS';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<Example />
</React.StrictMode>,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export type Person = {
firstName: string;
lastName: string;
age: number;
};

export const data: Person[] = [
{
firstName: 'Kevin',
lastName: 'Vandy',
age: 26,
},
{
firstName: 'Theodore',
lastName: 'Browne',
age: 28,
},
{
firstName: 'Tanner',
lastName: 'Linsley',
age: 33,
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node"
},
"include": ["vite.config.ts"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
});
9 changes: 9 additions & 0 deletions apps/material-react-table-docs/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ import Head from 'next/head';

### Version 1 (Latest)

#### v1.11.4 (2023-05-19)

- Fixed right column pinning spacing issues
- Implemented `enableSortingRemoval` in column actions menu
- Internal virtualization specific logic for Firefox vs Chrome
- Exported new `MRT_FilterFnsState` type
- Exported `MRT_TableHeadCellFilterContainer` component
- Added hu translations that can be imported from `'material-react-table/locales/hu'`

#### v1.11.3 (2023-05-07)

- Removed internal `measureElement` virtualizer option to prevent firefox from crashing with virtualization enabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Material React Table has full support for localization (i18n). Some locales are

The following locales are included and can be imported from `'material-react-table/locales/'`:

`cs`, `da`, `de`, `en`, `es`, `fa`, `fi`, `fr`, `id`, `it`, `nl`, `ja`, `pl`, `pt`, `pt-BR`, `ro`, `ru`, `sk`, `sr-Cryl-RS`, `sr-Latn-RS`, `sv`, `tr`, `uk`, `vi`, `zh-Hans`, `zh-Hant`
`cs`, `da`, `de`, `en`, `es`, `fa`, `fi`, `fr`, `hu`, `id`, `it`, `nl`, `ja`, `pl`, `pt`, `pt-BR`, `ro`, `ru`, `sk`, `sr-Cryl-RS`, `sr-Latn-RS`, `sv`, `tr`, `uk`, `vi`, `zh-Hans`, `zh-Hant`

> If your language is not yet supported, please consider making a PR to add it to the library! See [here on GitHub](https://github.com/KevinVandy/material-react-table/tree/main/packages/material-react-table/src/_locales).
Expand Down
13 changes: 13 additions & 0 deletions apps/material-react-table-docs/pages/docs/guides/sorting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Material React Table supports almost any sorting scenario you may have. Client-s
'enableGlobalFilterRankedResults',
'enableMultiSort',
'enableSorting',
'enableSortingRemoval',
'getSortedRowModel',
'isMultiSortEvent',
'manualSorting',
Expand Down Expand Up @@ -118,6 +119,18 @@ Multi-sorting is also enabled by default, which means you can sort by multiple c

You can limit the number of columns that can be sorted at once by setting the `maxMultiSortColCount` prop, or you can disable multi-sorting entirely by setting the `enableMultiSort` prop to `false`.

#### Sorting Removal

By default, users can remove a sort on a column by clicking through the sort direction options or selecting "Clear Sort" from the column actions menu. You can disable this feature by setting the `enableSortingRemoval` prop to `false`.

```jsx
<MaterialReactTable
columns={columns}
data={data}
enableSortingRemoval={false} //users will not be able to remove a sort on a column
/>
```

#### Sort Direction

By default, columns with `string` datatypes will sort alphabetically in ascending order, but columns with `number` datatypes will sort numerically in descending order. You can change the default sort direction per column by specifying the `sortDescFirst` column option to either `true` or `false`. You can also change the default sort direction globally by setting the `sortDescFirst` prop to either `true` or `false`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ export const DisableMultiSorting = () => (
<MaterialReactTable columns={columns} data={data} enableMultiSort={false} />
);

export const DisableSortingRemoval = () => (
<MaterialReactTable
columns={columns}
data={data}
enableSortingRemoval={false}
/>
);

export const SortRanking = () => (
<MaterialReactTable
columns={[
Expand Down
2 changes: 1 addition & 1 deletion packages/material-react-table/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.11.3",
"version": "1.11.4",
"license": "MIT",
"name": "material-react-table",
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
Expand Down
1 change: 1 addition & 0 deletions packages/material-react-table/rollup-locales.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const supportedLocales = [
'fa',
'fi',
'fr',
'hu',
'id',
'it',
'ja',
Expand Down

1 comment on commit 5e8add9

@vercel
Copy link

@vercel vercel bot commented on 5e8add9 May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.