Skip to content

Commit

Permalink
release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Aug 12, 2023
1 parent b6b6eda commit ee05ed0
Show file tree
Hide file tree
Showing 76 changed files with 5,457 additions and 3,698 deletions.
11 changes: 10 additions & 1 deletion apps/mantine-react-table-docs/example-groups/BasicExamples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import MinimalExample from '../examples/minimal';
import AdvancedExample from '../examples/advanced';
import AggregationAndGroupingExample from '../examples/aggregation-and-grouping';
import CustomHeadlessExample from '../examples/custom-headless';
import Link from 'next/link';
import { IconExternalLink } from '@tabler/icons-react';

const BasicExamples = ({ isPage = false }) => {
const { pathname, push } = useRouter();
Expand All @@ -17,7 +19,9 @@ const BasicExamples = ({ isPage = false }) => {
<Tabs
value={isPage ? pathname.split('/').pop() : activeTab}
onTabChange={(newPath) =>
isPage ? push(newPath as string) : setActiveTab(newPath as string)
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
}
keepMounted={false}
>
Expand All @@ -29,6 +33,11 @@ const BasicExamples = ({ isPage = false }) => {
Aggregation and Grouping
</Tabs.Tab>
<Tabs.Tab value="custom-headless">Custom Headless</Tabs.Tab>
<Link href="/docs/examples">
<Tabs.Tab value="more">
More Examples <IconExternalLink size="1.1rem" />
</Tabs.Tab>
</Link>
</Tabs.List>
<Tabs.Panel value="basic">
<BasicExample showTopRow={isPage} />
Expand Down
19 changes: 16 additions & 3 deletions apps/mantine-react-table-docs/example-groups/EditingCRUD.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { useState } from 'react';
import { useRouter } from 'next/router';
import { Box, Tabs } from '@mantine/core';
import ModalExample from '../examples/editing-crud-modal';
import InlineRowExample from '../examples/editing-crud-row';
import InlineCellExample from '../examples/editing-crud-cell';
import InlineTableExample from '../examples/editing-crud-table';
import Link from 'next/link';
import { IconExternalLink } from '@tabler/icons-react';

const EditingCRUD = () => {
const EditingCRUD = ({ isPage = false }) => {
const { pathname, push } = useRouter();
const [activeTab, setActiveTab] = useState('editing-crud');

return (
<>
<Box sx={{ width: '100%', marginTop: '1rem' }}>
<Tabs
value={pathname.split('/').pop()}
onTabChange={(newPath) => push(newPath as string)}
value={isPage ? pathname.split('/').pop() : activeTab}
onTabChange={(newPath) =>
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
}
keepMounted={false}
>
<Tabs.List>
Expand All @@ -25,6 +33,11 @@ const EditingCRUD = () => {
<Tabs.Tab value="editing-crud-inline-table">
Inline Table (All Rows Editable)
</Tabs.Tab>
<Link href="/docs/examples">
<Tabs.Tab value="more">
More Examples <IconExternalLink size="1.1rem" />
</Tabs.Tab>
</Link>
</Tabs.List>
<Tabs.Panel value="editing-crud">
<ModalExample />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { Tabs, Box } from '@mantine/core';
import AR_Table from '../examples/localization-i18n-ar';
import BG_Table from '../examples/localization-i18n-bg';
import CS_Table from '../examples/localization-i18n-cs';
import DA_Table from '../examples/localization-i18n-da';
Expand Down Expand Up @@ -32,6 +33,7 @@ import ZH_HANS_Table from '../examples/localization-i18n-zh-hans';
import ZH_HANT_Table from '../examples/localization-i18n-zh-hant';

const supportedLocales = [
'ar',
'bg',
'cs',
'da',
Expand Down Expand Up @@ -80,7 +82,8 @@ const LocaleExamples = () => {
</Tabs.List>
</Tabs>
</Box>
<div style={{ minHeight: '1500px' }} lang={currentLocale ?? 'en'}>
<Box sx={{ minHeight: '1500px' }} lang={currentLocale ?? 'en'}>
{currentLocale === 'ar' && <AR_Table />}
{currentLocale === 'bg' && <BG_Table />}
{currentLocale === 'cs' && <CS_Table />}
{currentLocale === 'da' && <DA_Table />}
Expand Down Expand Up @@ -111,7 +114,7 @@ const LocaleExamples = () => {
{currentLocale === 'zh-Hans' && <ZH_HANS_Table />}
{currentLocale === 'zh-Hant' && <ZH_HANT_Table />}
{currentLocale === 'no' && <NO_TABLE />}
</div>
</Box>
</>
);
};
Expand Down
19 changes: 16 additions & 3 deletions apps/mantine-react-table-docs/example-groups/RemoteFetching.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,34 @@ import { useRouter } from 'next/router';
import { Box, Tabs } from '@mantine/core';
import ReactQueryExample from '../examples/react-query';
import RemoteExample from '../examples/remote';
import { useState } from 'react';
import Link from 'next/link';
import { IconExternalLink } from '@tabler/icons-react';

const RemoteFetching = () => {
const RemoteFetching = ({ isPage = false }) => {
const { pathname, push } = useRouter();
const [activeTab, setActiveTab] = useState('react-query');

return (
<>
<Box sx={{ width: '100%', marginTop: '1rem' }}>
<Tabs
value={pathname.split('/').pop()}
onTabChange={(newPath) => push(newPath as string)}
value={isPage ? pathname.split('/').pop() : activeTab}
onTabChange={(newPath) =>
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
}
keepMounted={false}
>
<Tabs.List>
<Tabs.Tab value="react-query">React Query</Tabs.Tab>
<Tabs.Tab value="remote">useEffect</Tabs.Tab>
<Link href="/docs/examples">
<Tabs.Tab value="more">
More Examples <IconExternalLink size="1.1rem" />
</Tabs.Tab>
</Link>
</Tabs.List>
<Tabs.Panel value="react-query">
<ReactQueryExample />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ const Example = () => {
};

//UPDATE action
const handleSaveUser = async ({ values, exitEditingMode }) => {
const handleSaveUser = async ({ values, table }) => {
const newValidationErrors = validateUser(values);
if (Object.values(newValidationErrors).some((error) => error)) {
setValidationErrors(newValidationErrors);
return;
}
setValidationErrors({});
await updateUser(values);
exitEditingMode();
table.setEditingRow(null); //exit editing mode
};

//DELETE action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const Example = () => {
//UPDATE action
const handleSaveUser: MRT_TableOptions<User>['onEditingRowSave'] = async ({
values,
exitEditingMode,
table,
}) => {
const newValidationErrors = validateUser(values);
if (Object.values(newValidationErrors).some((error) => error)) {
Expand All @@ -144,7 +144,7 @@ const Example = () => {
}
setValidationErrors({});
await updateUser(values);
exitEditingMode();
table.setEditingRow(null); //exit editing mode
};

//DELETE action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ const Example = () => {
};

//UPDATE action
const handleSaveUser = async ({ values, exitEditingMode }) => {
const handleSaveUser = async ({ values, table }) => {
const newValidationErrors = validateUser(values);
if (Object.values(newValidationErrors).some((error) => error)) {
setValidationErrors(newValidationErrors);
return;
}
setValidationErrors({});
await updateUser(values);
exitEditingMode();
table.setEditingRow(null); //exit editing mode
};

//DELETE action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const Example = () => {
//UPDATE action
const handleSaveUser: MRT_TableOptions<User>['onEditingRowSave'] = async ({
values,
exitEditingMode,
table,
}) => {
const newValidationErrors = validateUser(values);
if (Object.values(newValidationErrors).some((error) => error)) {
Expand All @@ -135,7 +135,7 @@ const Example = () => {
}
setValidationErrors({});
await updateUser(values);
exitEditingMode();
table.setEditingRow(null); //exit editing mode
};

//DELETE action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const Example = () => {

const [tableData, setTableData] = useState(() => data);

const handleSaveRow = async ({ exitEditingMode, row, values }) => {
const handleSaveRow = async ({ table, row, values }) => {
//if using flat data and simple accessorKeys/ids, you can just do a simple assignment here.
tableData[row.index] = values;
//send/receive api updates here
setTableData([...tableData]);
exitEditingMode(); //required to exit editing mode
table.setEditingRow(null); //exit editing mode
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ const Example = () => {
const [tableData, setTableData] = useState<Person[]>(() => data);

const handleSaveRow: MRT_TableOptions<Person>['onEditingRowSave'] = async ({
exitEditingMode,
table,
row,
values,
}) => {
//if using flat data and simple accessorKeys/ids, you can just do a simple assignment here.
tableData[row.index] = values;
//send/receive api updates here
setTableData([...tableData]);
exitEditingMode(); //required to exit editing mode
table.setEditingRow(null); //exit editing mode
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ const Example = () => {

const [tableData, setTableData] = useState(() => data);

const handleSaveRow = async ({ exitEditingMode, row, values }) => {
const handleSaveRow = async ({ table, row, values }) => {
//if using flat data and simple accessorKeys/ids, you can just do a simple assignment here.
tableData[row.index] = values;
//send/receive api updates here
setTableData([...tableData]);
exitEditingMode(); //required to exit editing mode
table.setEditingRow(null); //exit editing mode
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ const Example = () => {
const [tableData, setTableData] = useState<Person[]>(() => data);

const handleSaveRow: MRT_TableOptions<Person>['onEditingRowSave'] = async ({
exitEditingMode,
table,
row,
values,
}) => {
//if using flat data and simple accessorKeys/ids, you can just do a simple assignment here.
tableData[row.index] = values;
//send/receive api updates here
setTableData([...tableData]);
exitEditingMode(); //required to exit editing mode
table.setEditingRow(null); //exit editing mode
};

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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-ar"
/>
);
};

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>Mantine React Table Example</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit ee05ed0

Please sign in to comment.