@pautena/react-design-system 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +2 -1
- package/babel.config.js +10 -0
- package/dist/cjs/index.js +28 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/app-bar/app-bar.types.d.ts +2 -1
- package/dist/cjs/types/components/content/content.d.ts +2 -0
- package/dist/cjs/types/components/content/content.types.d.ts +4 -0
- package/dist/cjs/types/components/content/index.d.ts +2 -0
- package/dist/cjs/types/components/header/header.d.ts +2 -61
- package/dist/cjs/types/components/header/header.types.d.ts +55 -0
- package/dist/cjs/types/components/header/index.d.ts +1 -0
- package/dist/cjs/types/components/index.d.ts +1 -0
- package/dist/cjs/types/components/tab/index.d.ts +0 -1
- package/dist/cjs/types/components/tab/tab-card/tab-card.d.ts +1 -2
- package/dist/cjs/types/components/table-list/table-list.d.ts +4 -7
- package/dist/cjs/types/generators/generators.mock.d.ts +22 -1
- package/dist/cjs/types/generators/generators.model.d.ts +5 -1
- package/dist/cjs/types/generators/model-form/model-form.d.ts +5 -5
- package/dist/cjs/types/generators/model-router/model-router.d.ts +4 -35
- package/dist/cjs/types/generators/model-router/model-router.types.d.ts +8 -0
- package/dist/cjs/types/generators/model-router/screens/add-screen.d.ts +16 -2
- package/dist/cjs/types/generators/model-router/screens/details-screen.d.ts +20 -2
- package/dist/cjs/types/generators/model-router/screens/list-screen.d.ts +30 -2
- package/dist/cjs/types/generators/model-router/screens/screens.types.d.ts +11 -0
- package/dist/cjs/types/generators/model-router/screens/update-screen.d.ts +29 -2
- package/dist/cjs/types/generators/model-router/stories/templates.d.ts +23 -0
- package/dist/cjs/types/generators/object-details/object-details.d.ts +4 -4
- package/dist/cjs/types/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.d.ts +5 -8
- package/dist/cjs/types/layouts/header-layout/header-layout.d.ts +4 -5
- package/dist/cjs/types/layouts/index.d.ts +1 -6
- package/dist/cjs/types/providers/index.d.ts +1 -0
- package/dist/cjs/types/providers/notification-center/index.d.ts +1 -0
- package/dist/cjs/types/providers/tab-provider/index.d.ts +2 -0
- package/dist/cjs/types/providers/tab-provider/tab-provider.context.d.ts +4 -0
- package/dist/cjs/types/providers/tab-provider/tab-provider.provider.d.ts +6 -0
- package/dist/cjs/types/utils/theme.d.ts +7 -4
- package/dist/esm/index.js +28 -28
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/app-bar/app-bar.types.d.ts +2 -1
- package/dist/esm/types/components/content/content.d.ts +2 -0
- package/dist/esm/types/components/content/content.types.d.ts +4 -0
- package/dist/esm/types/components/content/index.d.ts +2 -0
- package/dist/esm/types/components/header/header.d.ts +2 -61
- package/dist/esm/types/components/header/header.types.d.ts +55 -0
- package/dist/esm/types/components/header/index.d.ts +1 -0
- package/dist/esm/types/components/index.d.ts +1 -0
- package/dist/esm/types/components/tab/index.d.ts +0 -1
- package/dist/esm/types/components/tab/tab-card/tab-card.d.ts +1 -2
- package/dist/esm/types/components/table-list/table-list.d.ts +4 -7
- package/dist/esm/types/generators/generators.mock.d.ts +22 -1
- package/dist/esm/types/generators/generators.model.d.ts +5 -1
- package/dist/esm/types/generators/model-form/model-form.d.ts +5 -5
- package/dist/esm/types/generators/model-router/model-router.d.ts +4 -35
- package/dist/esm/types/generators/model-router/model-router.types.d.ts +8 -0
- package/dist/esm/types/generators/model-router/screens/add-screen.d.ts +16 -2
- package/dist/esm/types/generators/model-router/screens/details-screen.d.ts +20 -2
- package/dist/esm/types/generators/model-router/screens/list-screen.d.ts +30 -2
- package/dist/esm/types/generators/model-router/screens/screens.types.d.ts +11 -0
- package/dist/esm/types/generators/model-router/screens/update-screen.d.ts +29 -2
- package/dist/esm/types/generators/model-router/stories/templates.d.ts +23 -0
- package/dist/esm/types/generators/object-details/object-details.d.ts +4 -4
- package/dist/esm/types/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.d.ts +5 -8
- package/dist/esm/types/layouts/header-layout/header-layout.d.ts +4 -5
- package/dist/esm/types/layouts/index.d.ts +1 -6
- package/dist/esm/types/providers/index.d.ts +1 -0
- package/dist/esm/types/providers/notification-center/index.d.ts +1 -0
- package/dist/esm/types/providers/tab-provider/index.d.ts +2 -0
- package/dist/esm/types/providers/tab-provider/tab-provider.context.d.ts +4 -0
- package/dist/esm/types/providers/tab-provider/tab-provider.provider.d.ts +6 -0
- package/dist/esm/types/utils/theme.d.ts +7 -4
- package/dist/index.d.ts +146 -122
- package/jest.config.js +3 -0
- package/package.json +3 -1
- package/rollup.config.js +12 -0
- package/src/components/app-bar/app-bar.types.ts +2 -1
- package/src/components/content/content.stories.tsx +23 -0
- package/src/components/content/content.test.tsx +26 -0
- package/src/components/content/content.tsx +11 -0
- package/src/components/content/content.types.ts +5 -0
- package/src/components/content/index.ts +2 -0
- package/src/components/drawer-item/drawer-item.tsx +2 -0
- package/src/components/header/header.test.tsx +18 -16
- package/src/components/header/header.tsx +5 -69
- package/src/components/header/header.types.ts +61 -0
- package/src/components/header/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/components/tab/index.ts +0 -1
- package/src/components/tab/tab-card/tab-card.dummy.tsx +14 -11
- package/src/components/tab/tab-card/tab-card.test.tsx +2 -2
- package/src/components/tab/tab-card/tab-card.tsx +11 -14
- package/src/components/tab/tab-panel/tab-panel.test.tsx +4 -4
- package/src/components/tab/tab-panel/tab-panel.tsx +2 -2
- package/src/components/table/enhanced-table/enhanced-table.tsx +2 -2
- package/src/components/table-list/table-list.test.tsx +3 -2
- package/src/components/table-list/table-list.tsx +4 -8
- package/src/components/value-displays/group-value-card/group-value-card.tsx +2 -4
- package/src/generators/generators.mock.ts +25 -2
- package/src/generators/generators.model.ts +6 -1
- package/src/generators/model-form/model-form.test.tsx +5 -3
- package/src/generators/model-form/model-form.tsx +15 -15
- package/src/generators/model-router/model-router.test.tsx +72 -39
- package/src/generators/model-router/model-router.tsx +16 -41
- package/src/generators/model-router/model-router.types.ts +14 -0
- package/src/generators/model-router/screens/add-screen.tsx +53 -36
- package/src/generators/model-router/screens/details-screen.tsx +52 -43
- package/src/generators/model-router/screens/list-screen.tsx +89 -60
- package/src/generators/model-router/screens/screens.types.ts +13 -0
- package/src/generators/model-router/screens/update-screen.tsx +76 -42
- package/src/generators/model-router/stories/details-screen.stories.tsx +38 -0
- package/src/generators/model-router/stories/list-screen.stories.tsx +45 -0
- package/src/generators/model-router/stories/model-router.stories.tsx +164 -0
- package/src/generators/model-router/stories/templates.tsx +39 -0
- package/src/generators/object-details/object-details.tsx +18 -12
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.stories.tsx +7 -8
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.test.tsx +30 -0
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.tsx +10 -7
- package/src/layouts/header-layout/header-layout.stories.tsx +158 -22
- package/src/layouts/header-layout/header-layout.test.tsx +37 -0
- package/src/layouts/header-layout/header-layout.tsx +12 -13
- package/src/layouts/index.ts +1 -6
- package/src/providers/index.ts +1 -0
- package/src/providers/notification-center/index.ts +1 -0
- package/src/providers/tab-provider/index.ts +2 -0
- package/src/providers/tab-provider/tab-provider.context.ts +8 -0
- package/src/providers/tab-provider/tab-provider.provider.tsx +13 -0
- package/src/storybook.tsx +41 -7
- package/src/tests/assertions.ts +4 -0
- package/src/tests/components.tsx +1 -1
- package/src/utils/theme.ts +7 -2
- package/tsconfig.json +8 -10
- package/tsconfig.rollup.json +2 -0
- package/dist/cjs/types/components/tab/tab.context.d.ts +0 -4
- package/dist/cjs/types/layouts/data-table-layout/data-table-layout.d.ts +0 -12
- package/dist/cjs/types/layouts/data-table-layout/index.d.ts +0 -1
- package/dist/cjs/types/layouts/details-layout/details-layout.d.ts +0 -12
- package/dist/cjs/types/layouts/details-layout/index.d.ts +0 -1
- package/dist/cjs/types/layouts/form-layout/form-layout.d.ts +0 -8
- package/dist/cjs/types/layouts/form-layout/index.d.ts +0 -1
- package/dist/cjs/types/layouts/list-layout/index.d.ts +0 -1
- package/dist/cjs/types/layouts/list-layout/list-layout.d.ts +0 -8
- package/dist/cjs/types/layouts/tab-layout/index.d.ts +0 -1
- package/dist/cjs/types/layouts/tab-layout/tab-layout.d.ts +0 -7
- package/dist/esm/types/components/tab/tab.context.d.ts +0 -4
- package/dist/esm/types/layouts/data-table-layout/data-table-layout.d.ts +0 -12
- package/dist/esm/types/layouts/data-table-layout/index.d.ts +0 -1
- package/dist/esm/types/layouts/details-layout/details-layout.d.ts +0 -12
- package/dist/esm/types/layouts/details-layout/index.d.ts +0 -1
- package/dist/esm/types/layouts/form-layout/form-layout.d.ts +0 -8
- package/dist/esm/types/layouts/form-layout/index.d.ts +0 -1
- package/dist/esm/types/layouts/list-layout/index.d.ts +0 -1
- package/dist/esm/types/layouts/list-layout/list-layout.d.ts +0 -8
- package/dist/esm/types/layouts/tab-layout/index.d.ts +0 -1
- package/dist/esm/types/layouts/tab-layout/tab-layout.d.ts +0 -7
- package/src/components/tab/tab.context.ts +0 -5
- package/src/generators/model-router/model-router.stories.tsx +0 -160
- package/src/layouts/data-table-layout/data-table-layout.stories.tsx +0 -94
- package/src/layouts/data-table-layout/data-table-layout.tsx +0 -30
- package/src/layouts/data-table-layout/index.ts +0 -1
- package/src/layouts/details-layout/details-layout.stories.tsx +0 -81
- package/src/layouts/details-layout/details-layout.tsx +0 -33
- package/src/layouts/details-layout/index.ts +0 -1
- package/src/layouts/form-layout/form-layout.stories.tsx +0 -65
- package/src/layouts/form-layout/form-layout.tsx +0 -18
- package/src/layouts/form-layout/index.ts +0 -1
- package/src/layouts/list-layout/index.ts +0 -1
- package/src/layouts/list-layout/list-layout.stories.tsx +0 -102
- package/src/layouts/list-layout/list-layout.tsx +0 -36
- package/src/layouts/tab-layout/index.ts +0 -1
- package/src/layouts/tab-layout/tab-layout.stories.tsx +0 -88
- package/src/layouts/tab-layout/tab-layout.tsx +0 -11
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { HeaderProps, PlaceholderProps } from "../../components";
|
|
2
|
-
import { DataGridProps } from "@mui/x-data-grid";
|
|
3
|
-
interface Props {
|
|
4
|
-
loading?: boolean;
|
|
5
|
-
headerProps: HeaderProps;
|
|
6
|
-
emptyPlaceholderProps: PlaceholderProps;
|
|
7
|
-
dataGridProps: DataGridProps & {
|
|
8
|
-
height: number;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export declare const DataTableLayout: ({ loading, headerProps, emptyPlaceholderProps, dataGridProps: { height, rows, ...restDataGridProps }, }: Props) => JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./data-table-layout";
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { HeaderProps, PlaceholderProps } from "../../components";
|
|
2
|
-
import { Model } from "../../generators";
|
|
3
|
-
export interface DetailsLayoutProps {
|
|
4
|
-
loading?: boolean;
|
|
5
|
-
headerProps: HeaderProps;
|
|
6
|
-
objectDetailsProps: {
|
|
7
|
-
model: Model;
|
|
8
|
-
instance?: object;
|
|
9
|
-
};
|
|
10
|
-
notFoundPlaceholderProps: PlaceholderProps;
|
|
11
|
-
}
|
|
12
|
-
export declare const DetailsLayout: ({ loading, headerProps, notFoundPlaceholderProps, objectDetailsProps: { model, instance }, }: DetailsLayoutProps) => JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./details-layout";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HeaderProps } from "../../components";
|
|
2
|
-
import { ModelFormProps } from "../../generators";
|
|
3
|
-
export interface FormLayoutProps {
|
|
4
|
-
loading?: boolean;
|
|
5
|
-
headerProps: HeaderProps;
|
|
6
|
-
modelFormProps: ModelFormProps;
|
|
7
|
-
}
|
|
8
|
-
export declare const FormLayout: ({ loading, headerProps, modelFormProps }: FormLayoutProps) => JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./form-layout";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./list-layout";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BasicData, HeaderProps, PlaceholderProps, TableListProps } from "../../components";
|
|
2
|
-
export interface ListLayoutProps<T extends BasicData> {
|
|
3
|
-
loading?: boolean;
|
|
4
|
-
headerProps: HeaderProps;
|
|
5
|
-
listProps: TableListProps<T>;
|
|
6
|
-
emptyPlaceholderProps: PlaceholderProps;
|
|
7
|
-
}
|
|
8
|
-
export declare const ListLayout: <T extends BasicData>({ loading, headerProps, emptyPlaceholderProps, listProps: { data, ...restListProps }, }: ListLayoutProps<T>) => JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./tab-layout";
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { withBrowserRouter } from "../../storybook";
|
|
4
|
-
import { ModelRouter, RequestState } from "./model-router";
|
|
5
|
-
import { mockModel, createModelInstance } from "../generators.mock";
|
|
6
|
-
import { action } from "@storybook/addon-actions";
|
|
7
|
-
import { useState } from "react";
|
|
8
|
-
import { NotificationCenterProvider } from "../../providers";
|
|
9
|
-
|
|
10
|
-
const REQUEST_TIMEOUT = 2000;
|
|
11
|
-
|
|
12
|
-
const data = [
|
|
13
|
-
createModelInstance(mockModel, 100),
|
|
14
|
-
createModelInstance(mockModel, 101),
|
|
15
|
-
createModelInstance(mockModel, 102),
|
|
16
|
-
createModelInstance(mockModel, 103),
|
|
17
|
-
createModelInstance(mockModel, 104),
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
title: "Generators/ModelRouter",
|
|
22
|
-
component: ModelRouter,
|
|
23
|
-
decorators: [withBrowserRouter()],
|
|
24
|
-
parameters: {
|
|
25
|
-
layout: "fullscreen",
|
|
26
|
-
},
|
|
27
|
-
} as ComponentMeta<typeof ModelRouter>;
|
|
28
|
-
|
|
29
|
-
const requestListAction = action("Request list data");
|
|
30
|
-
const onSubmitAddAction = action("Submit add form");
|
|
31
|
-
const onDetailsScreenMount = action("Details screen mount");
|
|
32
|
-
const onRequestUpdateInstanceAction = action("Request update instance");
|
|
33
|
-
const onSubmitUpdateAction = action("Submit update form");
|
|
34
|
-
const onRequestDeleteAction = action("click delete item option");
|
|
35
|
-
|
|
36
|
-
export const DummyModelRouter = (args: any) => {
|
|
37
|
-
const {
|
|
38
|
-
requestTimeout,
|
|
39
|
-
initialData,
|
|
40
|
-
requestListAction,
|
|
41
|
-
onSubmitAddAction,
|
|
42
|
-
onDetailsScreenMount,
|
|
43
|
-
onRequestUpdateInstanceAction,
|
|
44
|
-
onSubmitUpdateAction,
|
|
45
|
-
onRequestDeleteAction,
|
|
46
|
-
} = args;
|
|
47
|
-
|
|
48
|
-
const [data, setData] = useState<any[]>([]);
|
|
49
|
-
const [updateInstance, setUpdateInstance] = useState<any>(undefined);
|
|
50
|
-
const [listRequestState, setListRequestState] = useState<RequestState>({ idle: true });
|
|
51
|
-
const [addRequestState, setAddRequestState] = useState<RequestState>({ idle: true });
|
|
52
|
-
const [updateRequestState, setUpdateRequestState] = useState<RequestState>({ idle: true });
|
|
53
|
-
const [updateInstanceRequestState, setUpdateInstanceRequestState] = useState<RequestState>({
|
|
54
|
-
idle: true,
|
|
55
|
-
});
|
|
56
|
-
const [removeRequestState, setRemoveRequestState] = useState<RequestState>({ idle: true });
|
|
57
|
-
const [detailRequestState, setDetailRequestState] = useState<RequestState>({ idle: true });
|
|
58
|
-
const [detailInstance, setDetailInstance] = useState(undefined);
|
|
59
|
-
|
|
60
|
-
const props = {
|
|
61
|
-
...args,
|
|
62
|
-
requestList: () => {
|
|
63
|
-
requestListAction();
|
|
64
|
-
setListRequestState({ idle: false, loading: true });
|
|
65
|
-
setTimeout(() => {
|
|
66
|
-
setData(initialData);
|
|
67
|
-
setListRequestState({ idle: true, loading: false, success: true });
|
|
68
|
-
}, requestTimeout);
|
|
69
|
-
},
|
|
70
|
-
list: {
|
|
71
|
-
data,
|
|
72
|
-
listRequest: listRequestState,
|
|
73
|
-
requestDelete: removeRequestState,
|
|
74
|
-
onClickRemoveItem: (item) => {
|
|
75
|
-
setRemoveRequestState({ idle: false, loading: true });
|
|
76
|
-
onRequestDeleteAction(item);
|
|
77
|
-
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
setData((d) => [...d.filter((d) => d !== item)]);
|
|
80
|
-
setRemoveRequestState({ idle: true, loading: false, success: true });
|
|
81
|
-
}, requestTimeout);
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
add: {
|
|
85
|
-
request: addRequestState,
|
|
86
|
-
onSubmit: (obj: any) => {
|
|
87
|
-
setAddRequestState({ idle: false, loading: true });
|
|
88
|
-
onSubmitAddAction(obj);
|
|
89
|
-
|
|
90
|
-
setTimeout(() => {
|
|
91
|
-
setData((d) => [...d, obj]);
|
|
92
|
-
setAddRequestState({ idle: true, loading: false, success: true });
|
|
93
|
-
}, requestTimeout);
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
detail: {
|
|
97
|
-
request: detailRequestState,
|
|
98
|
-
instance: detailInstance,
|
|
99
|
-
onScreenMount: (id: string) => {
|
|
100
|
-
setDetailInstance(undefined);
|
|
101
|
-
setDetailRequestState({ idle: false, loading: true });
|
|
102
|
-
onDetailsScreenMount(id);
|
|
103
|
-
|
|
104
|
-
setTimeout(() => {
|
|
105
|
-
setDetailInstance(data?.find((d) => d.id === id));
|
|
106
|
-
setDetailRequestState({ idle: true, loading: false, success: true });
|
|
107
|
-
}, requestTimeout);
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
update: {
|
|
111
|
-
request: updateRequestState,
|
|
112
|
-
requestInstance: updateInstanceRequestState,
|
|
113
|
-
instance: updateInstance,
|
|
114
|
-
onRequestInstance: (id: string) => {
|
|
115
|
-
setUpdateInstanceRequestState({ idle: false, loading: true });
|
|
116
|
-
onRequestUpdateInstanceAction(id);
|
|
117
|
-
|
|
118
|
-
setTimeout(() => {
|
|
119
|
-
setUpdateInstance(data?.find((d) => d.id === id));
|
|
120
|
-
setUpdateInstanceRequestState({ idle: true, loading: false, success: true });
|
|
121
|
-
}, requestTimeout);
|
|
122
|
-
},
|
|
123
|
-
onSubmit: (obj: any) => {
|
|
124
|
-
setUpdateRequestState({ idle: false, loading: true });
|
|
125
|
-
onSubmitUpdateAction(obj);
|
|
126
|
-
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
setData((d) => [
|
|
129
|
-
...(d || []).map((item) => {
|
|
130
|
-
if (item === obj) {
|
|
131
|
-
return obj;
|
|
132
|
-
}
|
|
133
|
-
return item;
|
|
134
|
-
}),
|
|
135
|
-
]);
|
|
136
|
-
setUpdateRequestState({ idle: true, loading: false, success: true });
|
|
137
|
-
}, requestTimeout);
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<NotificationCenterProvider>
|
|
144
|
-
<ModelRouter {...props} />
|
|
145
|
-
</NotificationCenterProvider>
|
|
146
|
-
);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
DummyModelRouter.args = {
|
|
150
|
-
modelName: "Items",
|
|
151
|
-
model: mockModel,
|
|
152
|
-
requestTimeout: REQUEST_TIMEOUT,
|
|
153
|
-
initialData: data,
|
|
154
|
-
requestListAction,
|
|
155
|
-
onSubmitAddAction,
|
|
156
|
-
onDetailsScreenMount,
|
|
157
|
-
onRequestUpdateInstanceAction,
|
|
158
|
-
onSubmitUpdateAction,
|
|
159
|
-
onRequestDeleteAction,
|
|
160
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { createTemplate } from "../../storybook";
|
|
4
|
-
import { DataTableLayout } from "./data-table-layout";
|
|
5
|
-
import { useDemoData } from "@mui/x-data-grid-generator";
|
|
6
|
-
import { withRouter } from "storybook-addon-react-router-v6";
|
|
7
|
-
import { PlaceholderIconArgs } from "../../components";
|
|
8
|
-
import BackupTableIcon from "@mui/icons-material/BackupTable";
|
|
9
|
-
|
|
10
|
-
const maxColumns = 7;
|
|
11
|
-
const editable = true;
|
|
12
|
-
const breadcrumbs = [
|
|
13
|
-
{
|
|
14
|
-
id: "list",
|
|
15
|
-
text: "Items",
|
|
16
|
-
link: "/items",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: "item",
|
|
20
|
-
text: "Item 1",
|
|
21
|
-
link: "/items/1",
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const args = {
|
|
26
|
-
size: 100,
|
|
27
|
-
dataSetType: "Commodity",
|
|
28
|
-
headerProps: {
|
|
29
|
-
title: "Lorem ipsum",
|
|
30
|
-
subtitle: "Dolor sit amet",
|
|
31
|
-
breadcrumbs,
|
|
32
|
-
actions: [
|
|
33
|
-
{
|
|
34
|
-
id: "new",
|
|
35
|
-
text: "Add",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
dataGridProps: {
|
|
40
|
-
height: 500,
|
|
41
|
-
},
|
|
42
|
-
emptyPlaceholderProps: {
|
|
43
|
-
title: "No item has found",
|
|
44
|
-
subtitle: "First you have to create an item",
|
|
45
|
-
icon: ({ size, color }: PlaceholderIconArgs) => (
|
|
46
|
-
<BackupTableIcon color={color} sx={{ fontSize: size }} />
|
|
47
|
-
),
|
|
48
|
-
actions: [
|
|
49
|
-
{
|
|
50
|
-
id: "add",
|
|
51
|
-
text: "Add",
|
|
52
|
-
href: "/item/add",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default {
|
|
59
|
-
title: "Layouts/DataTableLayout",
|
|
60
|
-
component: DataTableLayout,
|
|
61
|
-
decorators: [withRouter],
|
|
62
|
-
parameters: {
|
|
63
|
-
layout: "fullscreen",
|
|
64
|
-
},
|
|
65
|
-
} as ComponentMeta<typeof DataTableLayout>;
|
|
66
|
-
|
|
67
|
-
const Template = createTemplate(({ loading, dataSetType, size, dataGridProps, ...rest }) => {
|
|
68
|
-
const { data } = useDemoData({
|
|
69
|
-
dataSet: dataSetType,
|
|
70
|
-
rowLength: size,
|
|
71
|
-
maxColumns,
|
|
72
|
-
editable,
|
|
73
|
-
});
|
|
74
|
-
return (
|
|
75
|
-
<DataTableLayout loading={loading} dataGridProps={{ ...data, ...dataGridProps }} {...rest} />
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export const Default = Template.bind({});
|
|
80
|
-
Default.args = {
|
|
81
|
-
...args,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const Loading = Template.bind({});
|
|
85
|
-
Loading.args = {
|
|
86
|
-
...args,
|
|
87
|
-
loading: true,
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
export const Empty = Template.bind({});
|
|
91
|
-
Empty.args = {
|
|
92
|
-
...args,
|
|
93
|
-
size: 0,
|
|
94
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { HeaderProps, Placeholder, PlaceholderProps } from "../../components";
|
|
3
|
-
import { DataGrid, DataGridProps } from "@mui/x-data-grid";
|
|
4
|
-
import { HeaderLayout } from "../header-layout";
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
loading?: boolean;
|
|
8
|
-
headerProps: HeaderProps;
|
|
9
|
-
emptyPlaceholderProps: PlaceholderProps;
|
|
10
|
-
dataGridProps: DataGridProps & { height: number };
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const DataTableLayout = ({
|
|
14
|
-
loading,
|
|
15
|
-
headerProps,
|
|
16
|
-
emptyPlaceholderProps,
|
|
17
|
-
dataGridProps: { height, rows, ...restDataGridProps },
|
|
18
|
-
}: Props) => {
|
|
19
|
-
const isEmpty = rows.length === 0;
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<HeaderLayout loading={loading} headerProps={headerProps}>
|
|
23
|
-
{!isEmpty ? (
|
|
24
|
-
<DataGrid rows={rows} {...restDataGridProps} sx={{ height }} />
|
|
25
|
-
) : (
|
|
26
|
-
<Placeholder {...emptyPlaceholderProps} />
|
|
27
|
-
)}
|
|
28
|
-
</HeaderLayout>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./data-table-layout";
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { createTemplate } from "../../storybook";
|
|
4
|
-
import { DetailsLayout } from "./details-layout";
|
|
5
|
-
import { withRouter } from "storybook-addon-react-router-v6";
|
|
6
|
-
import { mockModel, createModelInstance } from "../../generators/generators.mock";
|
|
7
|
-
import SentimentVeryDissatisfiedIcon from "@mui/icons-material/SentimentVeryDissatisfied";
|
|
8
|
-
import { PlaceholderIconArgs } from "../../components";
|
|
9
|
-
|
|
10
|
-
const breadcrumbs = [
|
|
11
|
-
{
|
|
12
|
-
id: "list",
|
|
13
|
-
text: "Items",
|
|
14
|
-
link: "/items",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: "item",
|
|
18
|
-
text: "Item 1",
|
|
19
|
-
link: "/items/1",
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
|
|
23
|
-
const args = {
|
|
24
|
-
size: 100,
|
|
25
|
-
dataSetType: "Commodity",
|
|
26
|
-
headerProps: {
|
|
27
|
-
title: "Lorem ipsum",
|
|
28
|
-
subtitle: "Dolor sit amet",
|
|
29
|
-
breadcrumbs,
|
|
30
|
-
actions: [
|
|
31
|
-
{
|
|
32
|
-
id: "new",
|
|
33
|
-
text: "Add",
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
notFoundPlaceholderProps: {
|
|
38
|
-
title: "Not found",
|
|
39
|
-
subtitle: "There is no item with that id",
|
|
40
|
-
icon: ({ size, color }: PlaceholderIconArgs) => (
|
|
41
|
-
<SentimentVeryDissatisfiedIcon color={color} sx={{ fontSize: size }} />
|
|
42
|
-
),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default {
|
|
47
|
-
title: "Layouts/DetailsLayout",
|
|
48
|
-
component: DetailsLayout,
|
|
49
|
-
decorators: [withRouter],
|
|
50
|
-
parameters: {
|
|
51
|
-
layout: "fullscreen",
|
|
52
|
-
},
|
|
53
|
-
} as ComponentMeta<typeof DetailsLayout>;
|
|
54
|
-
|
|
55
|
-
const Template = createTemplate(DetailsLayout);
|
|
56
|
-
|
|
57
|
-
export const Default = Template.bind({});
|
|
58
|
-
Default.args = {
|
|
59
|
-
...args,
|
|
60
|
-
objectDetailsProps: {
|
|
61
|
-
model: mockModel,
|
|
62
|
-
instance: createModelInstance(mockModel),
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export const Loading = Template.bind({});
|
|
67
|
-
Loading.args = {
|
|
68
|
-
...args,
|
|
69
|
-
loading: true,
|
|
70
|
-
objectDetailsProps: {
|
|
71
|
-
model: mockModel,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const NotFound = Template.bind({});
|
|
76
|
-
NotFound.args = {
|
|
77
|
-
...args,
|
|
78
|
-
objectDetailsProps: {
|
|
79
|
-
model: mockModel,
|
|
80
|
-
},
|
|
81
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { HeaderProps, Placeholder, PlaceholderProps } from "../../components";
|
|
3
|
-
import { Model, ObjectDetails } from "../../generators";
|
|
4
|
-
import { HeaderLayout } from "../header-layout";
|
|
5
|
-
|
|
6
|
-
export interface DetailsLayoutProps {
|
|
7
|
-
loading?: boolean;
|
|
8
|
-
headerProps: HeaderProps;
|
|
9
|
-
objectDetailsProps: {
|
|
10
|
-
model: Model;
|
|
11
|
-
instance?: object;
|
|
12
|
-
};
|
|
13
|
-
notFoundPlaceholderProps: PlaceholderProps;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const DetailsLayout = ({
|
|
17
|
-
loading,
|
|
18
|
-
headerProps,
|
|
19
|
-
notFoundPlaceholderProps,
|
|
20
|
-
objectDetailsProps: { model, instance },
|
|
21
|
-
}: DetailsLayoutProps) => {
|
|
22
|
-
const notFound = !loading && !instance;
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<HeaderLayout loading={loading} headerProps={headerProps}>
|
|
26
|
-
{!notFound && instance ? (
|
|
27
|
-
<ObjectDetails model={model} instance={instance} />
|
|
28
|
-
) : (
|
|
29
|
-
<Placeholder {...notFoundPlaceholderProps} />
|
|
30
|
-
)}
|
|
31
|
-
</HeaderLayout>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./details-layout";
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { createTemplate } from "../../storybook";
|
|
3
|
-
import { FormLayout } from "./form-layout";
|
|
4
|
-
import { mockModel, createModelInstance } from "../../generators/generators.mock";
|
|
5
|
-
import { withRouter } from "storybook-addon-react-router-v6";
|
|
6
|
-
import { action } from "@storybook/addon-actions";
|
|
7
|
-
|
|
8
|
-
const breadcrumbs = [
|
|
9
|
-
{
|
|
10
|
-
id: "list",
|
|
11
|
-
text: "Items",
|
|
12
|
-
link: "/items",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: "item",
|
|
16
|
-
text: "Item 1",
|
|
17
|
-
link: "/items/1",
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const args = {
|
|
22
|
-
size: 100,
|
|
23
|
-
dataSetType: "Commodity",
|
|
24
|
-
headerProps: {
|
|
25
|
-
title: "Lorem ipsum",
|
|
26
|
-
subtitle: "Dolor sit amet",
|
|
27
|
-
breadcrumbs,
|
|
28
|
-
actions: [
|
|
29
|
-
{
|
|
30
|
-
id: "new",
|
|
31
|
-
text: "Add",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
modelFormProps: {
|
|
36
|
-
model: mockModel,
|
|
37
|
-
onSubmit: action("submit model form"),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default {
|
|
42
|
-
title: "Layouts/FormLayout",
|
|
43
|
-
component: FormLayout,
|
|
44
|
-
decorators: [withRouter],
|
|
45
|
-
parameters: {
|
|
46
|
-
layout: "fullscreen",
|
|
47
|
-
},
|
|
48
|
-
} as ComponentMeta<typeof FormLayout>;
|
|
49
|
-
|
|
50
|
-
const Template = createTemplate(FormLayout);
|
|
51
|
-
|
|
52
|
-
export const Add = Template.bind({});
|
|
53
|
-
Add.args = {
|
|
54
|
-
...args,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const Update = Template.bind({});
|
|
58
|
-
Update.args = {
|
|
59
|
-
...args,
|
|
60
|
-
modelFormProps: {
|
|
61
|
-
...args.modelFormProps,
|
|
62
|
-
saveButtonText: "update",
|
|
63
|
-
initialValues: createModelInstance(mockModel),
|
|
64
|
-
},
|
|
65
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { HeaderProps } from "../../components";
|
|
3
|
-
import { ModelFormProps, ModelForm } from "../../generators";
|
|
4
|
-
import { HeaderLayout } from "../header-layout";
|
|
5
|
-
|
|
6
|
-
export interface FormLayoutProps {
|
|
7
|
-
loading?: boolean;
|
|
8
|
-
headerProps: HeaderProps;
|
|
9
|
-
modelFormProps: ModelFormProps;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const FormLayout = ({ loading, headerProps, modelFormProps }: FormLayoutProps) => {
|
|
13
|
-
return (
|
|
14
|
-
<HeaderLayout loading={loading} headerProps={headerProps}>
|
|
15
|
-
<ModelForm {...modelFormProps} />
|
|
16
|
-
</HeaderLayout>
|
|
17
|
-
);
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./form-layout";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./list-layout";
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { createTemplate } from "../../storybook";
|
|
4
|
-
import { ListLayout } from "./list-layout";
|
|
5
|
-
import { useDemoData } from "@mui/x-data-grid-generator";
|
|
6
|
-
import { withRouter } from "storybook-addon-react-router-v6";
|
|
7
|
-
import { PlaceholderIconArgs } from "../../components";
|
|
8
|
-
import BackupTableIcon from "@mui/icons-material/BackupTable";
|
|
9
|
-
|
|
10
|
-
const maxColumns = 3;
|
|
11
|
-
const editable = true;
|
|
12
|
-
const breadcrumbs = [
|
|
13
|
-
{
|
|
14
|
-
id: "list",
|
|
15
|
-
text: "Items",
|
|
16
|
-
link: "/items",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: "item",
|
|
20
|
-
text: "Item 1",
|
|
21
|
-
link: "/items/1",
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const args = {
|
|
26
|
-
size: 100,
|
|
27
|
-
dataSetType: "Commodity",
|
|
28
|
-
headerProps: {
|
|
29
|
-
title: "Lorem ipsum",
|
|
30
|
-
subtitle: "Dolor sit amet",
|
|
31
|
-
breadcrumbs,
|
|
32
|
-
actions: [
|
|
33
|
-
{
|
|
34
|
-
id: "new",
|
|
35
|
-
text: "Add",
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
listProps: {
|
|
40
|
-
search: true,
|
|
41
|
-
},
|
|
42
|
-
emptyPlaceholderProps: {
|
|
43
|
-
title: "No item has found",
|
|
44
|
-
subtitle: "First you have to create an item",
|
|
45
|
-
icon: ({ size, color }: PlaceholderIconArgs) => (
|
|
46
|
-
<BackupTableIcon color={color} sx={{ fontSize: size }} />
|
|
47
|
-
),
|
|
48
|
-
actions: [
|
|
49
|
-
{
|
|
50
|
-
id: "add",
|
|
51
|
-
text: "Add",
|
|
52
|
-
href: "/item/add",
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default {
|
|
59
|
-
title: "Layouts/ListLayout",
|
|
60
|
-
component: ListLayout,
|
|
61
|
-
decorators: [withRouter],
|
|
62
|
-
parameters: {
|
|
63
|
-
layout: "fullscreen",
|
|
64
|
-
},
|
|
65
|
-
} as ComponentMeta<typeof ListLayout>;
|
|
66
|
-
|
|
67
|
-
const Template = createTemplate(({ loading, dataSetType, size, listProps, ...rest }) => {
|
|
68
|
-
const { data } = useDemoData({
|
|
69
|
-
dataSet: dataSetType,
|
|
70
|
-
rowLength: size,
|
|
71
|
-
maxColumns,
|
|
72
|
-
editable,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const { rows } = data;
|
|
76
|
-
const columns = data.columns.map(({ field, headerName }) => ({
|
|
77
|
-
id: field,
|
|
78
|
-
label: headerName,
|
|
79
|
-
sort: true,
|
|
80
|
-
}));
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<ListLayout loading={loading} listProps={{ ...listProps, data: rows, columns }} {...rest} />
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export const Default = Template.bind({});
|
|
88
|
-
Default.args = {
|
|
89
|
-
...args,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const Loading = Template.bind({});
|
|
93
|
-
Loading.args = {
|
|
94
|
-
...args,
|
|
95
|
-
loading: true,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const Empty = Template.bind({});
|
|
99
|
-
Empty.args = {
|
|
100
|
-
...args,
|
|
101
|
-
size: 0,
|
|
102
|
-
};
|