Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRUD component #4486

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aa8a72c
Allow full-size content in PageContainer
apedroferreira Nov 26, 2024
b5d7544
CRUS list component (WIP)
apedroferreira Nov 27, 2024
7d63c71
First version of List without documentation
apedroferreira Nov 27, 2024
35f63a3
Show component (initial version)
apedroferreira Dec 2, 2024
0bb5aa1
Better Show component
apedroferreira Dec 11, 2024
dccbb8e
Create component - saving progress
apedroferreira Jan 16, 2025
6b47e14
Let's pop a save
apedroferreira Jan 22, 2025
e807873
Merge remote-tracking branch 'upstream/master' into crud-list
apedroferreira Jan 22, 2025
59d923d
Fix merge
apedroferreira Jan 22, 2025
87bd739
Fix merge more
apedroferreira Jan 22, 2025
f7a894a
More fixes and updates
apedroferreira Jan 22, 2025
355be7a
Render correct form field types
apedroferreira Jan 22, 2025
c650f1a
Form integration logic, in progress
apedroferreira Jan 29, 2025
5eaa530
Finish basic form logic
apedroferreira Jan 30, 2025
0575330
Refactor forms not to use any library, add validation feature
apedroferreira Jan 30, 2025
cb4fc26
Improve form state and field validation
apedroferreira Jan 30, 2025
fcbb266
Make form pages reusable, use it for Create page
apedroferreira Jan 30, 2025
07f4923
Add Edit component and page
apedroferreira Jan 31, 2025
78433dc
CRUD context provider - in progress
apedroferreira Jan 31, 2025
734d716
Typing changes
apedroferreira Feb 3, 2025
3784767
All-in-one CRUD ohyeah
apedroferreira Feb 3, 2025
6146dd1
Improvements
apedroferreira Feb 3, 2025
47732fe
More fixes
apedroferreira Feb 3, 2025
6ab92c2
Delete flow and error fixes
apedroferreira Feb 3, 2025
21db37d
Clean up example
apedroferreira Feb 3, 2025
ed873ad
Date field fixes
apedroferreira Feb 4, 2025
9d149eb
Improve field display formatting in Show pages
apedroferreira Feb 4, 2025
4c87878
Reorder imports
apedroferreira Feb 4, 2025
09ed0ed
Merge remote-tracking branch 'upstream/master' into crud-list
apedroferreira Feb 4, 2025
46454cd
API docs
apedroferreira Feb 5, 2025
84178e1
Add deep linking in List + some features
apedroferreira Feb 5, 2025
0a8ae4b
Fixes to URL table state
apedroferreira Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/data/toolpad/core/all-components/all-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<p class="description">This page contains an index to the components included in Toolpad Core.</p>

- [Account](/toolpad/core/react-account/)
- [App Provider](/toolpad/core/react-app-provider/)
- [CRUD](/toolpad/core/react-crud/)
- [Dashboard Layout](/toolpad/core/react-dashboard-layout/)
- [Page Container](/toolpad/core/react-page-container/)
- [Sign-in Page](/toolpad/core/react-sign-in-page/)
- [Account](/toolpad/core/react-account/)
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
productId: toolpad-core
title: CRUD Page
title: CRUD
components: CRUD, CRUDProvider, List, Show, Create, Edit
---

# CRUD Page 🚧
# CRUD

<p class="description">The CRUD component provides a UI for editable data sources. With deep-linkable, form-based pages.</p>

Expand Down
3 changes: 1 addition & 2 deletions docs/data/toolpad/core/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ const pages: MuiPage[] = [
subheader: 'Data',
children: [
{
pathname: '/toolpad/core/react-crud-page',
pathname: '/toolpad/core/react-crud',
title: 'CRUD',
planned: true,
},
{
pathname: '/toolpad/core/react-stat-card',
Expand Down
6 changes: 6 additions & 0 deletions docs/data/toolpad/core/pagesApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ module.exports = [
{ pathname: '/toolpad/core/api/account-popover-header' },
{ pathname: '/toolpad/core/api/account-preview' },
{ pathname: '/toolpad/core/api/app-provider' },
{ pathname: '/toolpad/core/api/create' },
{ pathname: '/toolpad/core/api/crud' },
{ pathname: '/toolpad/core/api/crud-provider' },
{ pathname: '/toolpad/core/api/dashboard-layout' },
{ pathname: '/toolpad/core/api/dialogs-provider' },
{ pathname: '/toolpad/core/api/edit' },
{ pathname: '/toolpad/core/api/list' },
{ pathname: '/toolpad/core/api/notifications-provider' },
{ pathname: '/toolpad/core/api/page-container' },
{ pathname: '/toolpad/core/api/page-header' },
{ pathname: '/toolpad/core/api/page-header-toolbar' },
{ pathname: '/toolpad/core/api/show' },
{ pathname: '/toolpad/core/api/sign-in-button' },
{ pathname: '/toolpad/core/api/sign-in-page' },
{ pathname: '/toolpad/core/api/sign-out-button' },
Expand Down
12 changes: 6 additions & 6 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"@emotion/server": "11.11.0",
"@emotion/styled": "11.14.0",
"@mui/base": "5.0.0-beta.68",
"@mui/docs": "6.3.1",
"@mui/icons-material": "6.3.1",
"@mui/docs": "6.4.1",
"@mui/icons-material": "6.4.1",
"@mui/internal-markdown": "1.0.24",
"@mui/joy": "5.0.0-beta.51",
"@mui/lab": "6.0.0-beta.22",
"@mui/material": "6.3.1",
"@mui/material": "6.4.1",
"@mui/material-nextjs": "6.3.1",
"@mui/styles": "6.3.1",
"@mui/system": "6.3.1",
"@mui/utils": "6.3.1",
"@mui/styles": "6.4.1",
"@mui/system": "6.4.1",
"@mui/utils": "6.4.1",
"@mui/x-date-pickers": "7.25.0",
"@mui/x-date-pickers-pro": "7.25.0",
"@mui/x-license": "7.25.0",
Expand Down
23 changes: 23 additions & 0 deletions docs/pages/toolpad/core/api/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './create.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs-toolpad/translations/api-docs/create',
false,
/\.\/create.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
15 changes: 15 additions & 0 deletions docs/pages/toolpad/core/api/create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"props": {
"dataSource": { "type": { "name": "object" } },
"initialValues": { "type": { "name": "object" }, "default": "{}" },
"onSubmitSuccess": { "type": { "name": "func" } }
},
"name": "Create",
"imports": ["import { Create } from '@toolpad/core/CRUD';"],
"classes": [],
"muiName": "Create",
"filename": "/packages/toolpad-core/src/CRUD/Create.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
23 changes: 23 additions & 0 deletions docs/pages/toolpad/core/api/crud-provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './crud-provider.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs-toolpad/translations/api-docs/crud-provider',
false,
/\.\/crud-provider.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
11 changes: 11 additions & 0 deletions docs/pages/toolpad/core/api/crud-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"props": { "dataSource": { "type": { "name": "object" }, "required": true } },
"name": "CRUDProvider",
"imports": ["import { CRUDProvider } from '@toolpad/core/CRUD';"],
"classes": [],
"muiName": "CRUDProvider",
"filename": "/packages/toolpad-core/src/CRUD/CRUDProvider.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
19 changes: 19 additions & 0 deletions docs/pages/toolpad/core/api/crud.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './crud.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context('docs-toolpad/translations/api-docs/crud', false, /\.\/crud.*.json$/);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
19 changes: 19 additions & 0 deletions docs/pages/toolpad/core/api/crud.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"props": {
"dataSource": { "type": { "name": "object" }, "required": true },
"rootPath": { "type": { "name": "string" }, "required": true },
"defaultValues": { "type": { "name": "object" }, "default": "{}" },
"initialPageSize": { "type": { "name": "number" }, "default": "100" }
},
"name": "CRUD",
"imports": [
"import { CRUD } from '@toolpad/core/CRUD';",
"import { CRUD } from '@toolpad/core';"
],
"classes": [],
"muiName": "CRUD",
"filename": "/packages/toolpad-core/src/CRUD/CRUD.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
19 changes: 19 additions & 0 deletions docs/pages/toolpad/core/api/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './edit.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context('docs-toolpad/translations/api-docs/edit', false, /\.\/edit.*.json$/);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
14 changes: 14 additions & 0 deletions docs/pages/toolpad/core/api/edit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"props": {
"dataSource": { "type": { "name": "object" } },
"onSubmitSuccess": { "type": { "name": "func" } }
},
"name": "Edit",
"imports": ["import { Edit } from '@toolpad/core/CRUD';"],
"classes": [],
"muiName": "Edit",
"filename": "/packages/toolpad-core/src/CRUD/Edit.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
19 changes: 19 additions & 0 deletions docs/pages/toolpad/core/api/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './list.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context('docs-toolpad/translations/api-docs/list', false, /\.\/list.*.json$/);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
34 changes: 34 additions & 0 deletions docs/pages/toolpad/core/api/list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"props": {
"dataSource": { "type": { "name": "object" } },
"initialPageSize": { "type": { "name": "number" }, "default": "100" },
"onCreateClick": { "type": { "name": "func" } },
"onEditClick": { "type": { "name": "func" } },
"onRowClick": { "type": { "name": "func" } },
"slotProps": {
"type": { "name": "shape", "description": "{ dataGrid?: object }" },
"default": "{}"
},
"slots": {
"type": { "name": "shape", "description": "{ dataGrid?: elementType }" },
"default": "{}",
"additionalInfo": { "slotsApi": true }
}
},
"name": "List",
"imports": ["import { List } from '@toolpad/core/CRUD';"],
"slots": [
{
"name": "dataGrid",
"description": "The DataGrid component used to list the items.",
"default": "DataGrid",
"class": null
}
],
"classes": [],
"muiName": "List",
"filename": "/packages/toolpad-core/src/CRUD/List.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
19 changes: 19 additions & 0 deletions docs/pages/toolpad/core/api/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './show.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context('docs-toolpad/translations/api-docs/show', false, /\.\/show.*.json$/);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
15 changes: 15 additions & 0 deletions docs/pages/toolpad/core/api/show.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"props": {
"dataSource": { "type": { "name": "object" } },
"onDelete": { "type": { "name": "func" } },
"onEditClick": { "type": { "name": "func" } }
},
"name": "Show",
"imports": ["import { Show } from '@toolpad/core/CRUD';"],
"classes": [],
"muiName": "Show",
"filename": "/packages/toolpad-core/src/CRUD/Show.tsx",
"inheritance": null,
"demos": "<ul><li><a href=\"/toolpad/core/react-crud/\">CRUD</a></li></ul>",
"cssComponent": false
}
42 changes: 42 additions & 0 deletions docs/pages/toolpad/core/api/sign-in-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,48 @@
"isGlobal": false,
"isDeprecated": true
},
{
"key": "loading",
"className": "",
"description": "Styles applied to the root element if `loading={true}`.",
"isGlobal": false
},
{
"key": "loadingIconPlaceholder",
"className": "",
"description": "Styles applied to the loadingIconPlaceholder element.",
"isGlobal": false
},
{
"key": "loadingIndicator",
"className": "",
"description": "Styles applied to the loadingIndicator element.",
"isGlobal": false
},
{
"key": "loadingPositionCenter",
"className": "",
"description": "Styles applied to the root element if `loadingPosition=\"center\"`.",
"isGlobal": false
},
{
"key": "loadingPositionEnd",
"className": "",
"description": "Styles applied to the root element if `loadingPosition=\"end\"`.",
"isGlobal": false
},
{
"key": "loadingPositionStart",
"className": "",
"description": "Styles applied to the root element if `loadingPosition=\"start\"`.",
"isGlobal": false
},
{
"key": "loadingWrapper",
"className": "",
"description": "Styles applied to the loadingWrapper element.",
"isGlobal": false
},
{
"key": "outlined",
"className": "",
Expand Down
Loading