@pautena/react-design-system 0.1.1 → 0.1.2
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/package.json +1 -1
- package/.eslintrc.js +0 -26
- package/.github/workflows/ci.yml +0 -23
- package/.github/workflows/deploy-storybook.yaml +0 -23
- package/.github/workflows/publish.yml +0 -31
- package/.husky/pre-commit +0 -5
- package/.prettierignore +0 -5
- package/.storybook/main.js +0 -10
- package/.storybook/preview.js +0 -36
- package/babel.config.js +0 -13
- package/jest.config.js +0 -17
- package/jest.setup.ts +0 -5
- package/rollup.config.js +0 -52
- package/src/components/app-bar/app-bar.stories.tsx +0 -54
- package/src/components/app-bar/app-bar.test.tsx +0 -142
- package/src/components/app-bar/app-bar.tsx +0 -150
- package/src/components/app-bar/app-bar.types.ts +0 -17
- package/src/components/app-bar/index.ts +0 -3
- package/src/components/app-bar/mini-app-bar/index.ts +0 -1
- package/src/components/app-bar/mini-app-bar/mini-app-bar.tsx +0 -31
- package/src/components/bullet/bullet.stories.tsx +0 -43
- package/src/components/bullet/bullet.test.tsx +0 -24
- package/src/components/bullet/bullet.tsx +0 -30
- package/src/components/bullet/index.ts +0 -1
- package/src/components/center-container/center-container.stories.tsx +0 -50
- package/src/components/center-container/center-container.test.tsx +0 -16
- package/src/components/center-container/center-container.tsx +0 -32
- package/src/components/center-container/index.ts +0 -1
- package/src/components/content/content.stories.tsx +0 -23
- package/src/components/content/content.test.tsx +0 -26
- package/src/components/content/content.tsx +0 -11
- package/src/components/content/content.types.ts +0 -5
- package/src/components/content/index.ts +0 -2
- package/src/components/drawer/__snapshots__/drawer.test.tsx.snap +0 -20
- package/src/components/drawer/drawer.context.ts +0 -20
- package/src/components/drawer/drawer.mixins.ts +0 -24
- package/src/components/drawer/drawer.mock.tsx +0 -100
- package/src/components/drawer/drawer.provider.tsx +0 -23
- package/src/components/drawer/drawer.test.tsx +0 -97
- package/src/components/drawer/drawer.tsx +0 -30
- package/src/components/drawer/drawer.types.ts +0 -53
- package/src/components/drawer/index.ts +0 -5
- package/src/components/drawer/mini-drawer/index.ts +0 -1
- package/src/components/drawer/mini-drawer/mini-drawer.stories.tsx +0 -34
- package/src/components/drawer/mini-drawer/mini-drawer.tsx +0 -67
- package/src/components/drawer-content/drawer-content.stories.tsx +0 -29
- package/src/components/drawer-content/drawer-content.test.tsx +0 -34
- package/src/components/drawer-content/drawer-content.tsx +0 -18
- package/src/components/drawer-content/index.ts +0 -1
- package/src/components/drawer-item/drawer-item.stories.tsx +0 -62
- package/src/components/drawer-item/drawer-item.test.tsx +0 -119
- package/src/components/drawer-item/drawer-item.tsx +0 -71
- package/src/components/drawer-item/index.ts +0 -1
- package/src/components/drawer-section/drawer-section.mock.tsx +0 -39
- package/src/components/drawer-section/drawer-section.stories.tsx +0 -28
- package/src/components/drawer-section/drawer-section.test.tsx +0 -44
- package/src/components/drawer-section/drawer-section.tsx +0 -40
- package/src/components/drawer-section/index.ts +0 -1
- package/src/components/header/header.dummy.ts +0 -55
- package/src/components/header/header.stories.tsx +0 -116
- package/src/components/header/header.test.tsx +0 -169
- package/src/components/header/header.tsx +0 -121
- package/src/components/header/header.types.ts +0 -61
- package/src/components/header/index.ts +0 -2
- package/src/components/index.ts +0 -18
- package/src/components/label/index.ts +0 -1
- package/src/components/label/label.stories.tsx +0 -49
- package/src/components/label/label.test.tsx +0 -30
- package/src/components/label/label.tsx +0 -60
- package/src/components/link/index.ts +0 -1
- package/src/components/link/link.tsx +0 -17
- package/src/components/loading-area/index.ts +0 -1
- package/src/components/loading-area/loading-area.stories.tsx +0 -17
- package/src/components/loading-area/loading-area.test.tsx +0 -11
- package/src/components/loading-area/loading-area.tsx +0 -13
- package/src/components/placeholder/index.ts +0 -1
- package/src/components/placeholder/placeholder.mock.ts +0 -15
- package/src/components/placeholder/placeholder.stories.tsx +0 -44
- package/src/components/placeholder/placeholder.test.tsx +0 -76
- package/src/components/placeholder/placeholder.tsx +0 -75
- package/src/components/query-container/index.ts +0 -1
- package/src/components/query-container/query-container.stories.tsx +0 -68
- package/src/components/query-container/query-container.test.tsx +0 -95
- package/src/components/query-container/query-container.tsx +0 -71
- package/src/components/sign-in/index.ts +0 -1
- package/src/components/sign-in/sign-in.stories.tsx +0 -36
- package/src/components/sign-in/sign-in.test.tsx +0 -95
- package/src/components/sign-in/sign-in.tsx +0 -97
- package/src/components/tab/index.ts +0 -2
- package/src/components/tab/tab-card/index.ts +0 -1
- package/src/components/tab/tab-card/tab-card.dummy.tsx +0 -30
- package/src/components/tab/tab-card/tab-card.stories.tsx +0 -22
- package/src/components/tab/tab-card/tab-card.test.tsx +0 -53
- package/src/components/tab/tab-card/tab-card.tsx +0 -27
- package/src/components/tab/tab-panel/index.ts +0 -1
- package/src/components/tab/tab-panel/tab-panel.test.tsx +0 -26
- package/src/components/tab/tab-panel/tab-panel.tsx +0 -27
- package/src/components/table/enhanced-remote-table/enhanced-remote-table.mock.tsx +0 -27
- package/src/components/table/enhanced-remote-table/enhanced-remote-table.stories.tsx +0 -24
- package/src/components/table/enhanced-remote-table/enhanced-remote-table.test.tsx +0 -77
- package/src/components/table/enhanced-remote-table/enhanced-remote-table.tsx +0 -74
- package/src/components/table/enhanced-remote-table/index.ts +0 -1
- package/src/components/table/enhanced-table/enhanced-table-head.tsx +0 -58
- package/src/components/table/enhanced-table/enhanced-table.mock.tsx +0 -93
- package/src/components/table/enhanced-table/enhanced-table.stories.tsx +0 -21
- package/src/components/table/enhanced-table/enhanced-table.test.tsx +0 -107
- package/src/components/table/enhanced-table/enhanced-table.tsx +0 -136
- package/src/components/table/enhanced-table/index.ts +0 -2
- package/src/components/table/index.ts +0 -2
- package/src/components/table-list/index.ts +0 -1
- package/src/components/table-list/table-list.stories.tsx +0 -75
- package/src/components/table-list/table-list.test.tsx +0 -284
- package/src/components/table-list/table-list.tsx +0 -127
- package/src/components/value-displays/group-value-card/group-value-card.mock.tsx +0 -35
- package/src/components/value-displays/group-value-card/group-value-card.stories.tsx +0 -26
- package/src/components/value-displays/group-value-card/group-value-card.test.tsx +0 -58
- package/src/components/value-displays/group-value-card/group-value-card.tsx +0 -63
- package/src/components/value-displays/group-value-card/index.ts +0 -1
- package/src/components/value-displays/index.ts +0 -4
- package/src/components/value-displays/value-boolean/index.ts +0 -1
- package/src/components/value-displays/value-boolean/value-boolean.stories.tsx +0 -25
- package/src/components/value-displays/value-boolean/value-boolean.test.tsx +0 -27
- package/src/components/value-displays/value-boolean/value-boolean.tsx +0 -33
- package/src/components/value-displays/value-card/index.ts +0 -1
- package/src/components/value-displays/value-card/value-card.stories.tsx +0 -22
- package/src/components/value-displays/value-card/value-card.test.tsx +0 -18
- package/src/components/value-displays/value-card/value-card.tsx +0 -12
- package/src/components/value-displays/value-text/index.ts +0 -1
- package/src/components/value-displays/value-text/value-test.test.tsx +0 -21
- package/src/components/value-displays/value-text/value-text.stories.tsx +0 -26
- package/src/components/value-displays/value-text/value-text.tsx +0 -32
- package/src/generators/generators.mock.ts +0 -238
- package/src/generators/generators.model.ts +0 -46
- package/src/generators/index.ts +0 -4
- package/src/generators/model-form/index.ts +0 -1
- package/src/generators/model-form/model-form.stories.tsx +0 -30
- package/src/generators/model-form/model-form.test.tsx +0 -100
- package/src/generators/model-form/model-form.tsx +0 -97
- package/src/generators/model-router/index.ts +0 -1
- package/src/generators/model-router/model-router.test.tsx +0 -666
- package/src/generators/model-router/model-router.tsx +0 -29
- package/src/generators/model-router/model-router.types.ts +0 -14
- package/src/generators/model-router/screens/add-screen.tsx +0 -69
- package/src/generators/model-router/screens/details-screen.tsx +0 -62
- package/src/generators/model-router/screens/index.ts +0 -4
- package/src/generators/model-router/screens/list-screen.tsx +0 -110
- package/src/generators/model-router/screens/screens.types.ts +0 -13
- package/src/generators/model-router/screens/update-screen.tsx +0 -96
- package/src/generators/model-router/stories/details-screen.stories.tsx +0 -38
- package/src/generators/model-router/stories/list-screen.stories.tsx +0 -45
- package/src/generators/model-router/stories/model-router.stories.tsx +0 -164
- package/src/generators/model-router/stories/templates.tsx +0 -39
- package/src/generators/object-details/index.ts +0 -1
- package/src/generators/object-details/object-details.stories.tsx +0 -20
- package/src/generators/object-details/object-details.test.tsx +0 -21
- package/src/generators/object-details/object-details.tsx +0 -76
- package/src/index.ts +0 -4
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.stories.tsx +0 -28
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.test.tsx +0 -30
- package/src/layouts/app-bar-with-drawer-layout/app-bar-with-drawer-layout.tsx +0 -37
- package/src/layouts/app-bar-with-drawer-layout/index.ts +0 -1
- package/src/layouts/header-layout/header-layout.stories.tsx +0 -204
- package/src/layouts/header-layout/header-layout.test.tsx +0 -37
- package/src/layouts/header-layout/header-layout.tsx +0 -23
- package/src/layouts/header-layout/index.ts +0 -1
- package/src/layouts/index.ts +0 -2
- package/src/providers/index.ts +0 -2
- package/src/providers/notification-center/index.ts +0 -2
- package/src/providers/notification-center/notification-center.context.ts +0 -37
- package/src/providers/notification-center/notification-center.provider.tsx +0 -51
- package/src/providers/notification-center/notification-center.stories.tsx +0 -52
- package/src/providers/notification-center/notification-center.test.tsx +0 -112
- package/src/providers/tab-provider/index.ts +0 -2
- package/src/providers/tab-provider/tab-provider.context.ts +0 -8
- package/src/providers/tab-provider/tab-provider.provider.tsx +0 -13
- package/src/storybook.tsx +0 -90
- package/src/tests/assertions.ts +0 -76
- package/src/tests/components.tsx +0 -60
- package/src/tests/content-placeholder.stories.tsx +0 -16
- package/src/tests/index.ts +0 -3
- package/src/tests/skeleton-card.stories.tsx +0 -18
- package/src/tests/testing-library.tsx +0 -65
- package/src/utils/arrays.test.ts +0 -9
- package/src/utils/arrays.ts +0 -7
- package/src/utils/index.ts +0 -2
- package/src/utils/theme.ts +0 -11
- package/tsconfig.json +0 -25
- package/tsconfig.rollup.json +0 -28
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { TableRow, TableCell, IconButton, MenuItem, Menu } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { EnhancedTable, HeadCell, Order } from "../table/enhanced-table";
|
|
4
|
-
import MoreVertIcon from "@mui/icons-material/MoreVert";
|
|
5
|
-
import { BasicModelInstance } from "~/generators";
|
|
6
|
-
|
|
7
|
-
const OptionsId = "__options";
|
|
8
|
-
|
|
9
|
-
export interface TableRowOption<T extends BasicModelInstance> {
|
|
10
|
-
id: string;
|
|
11
|
-
label: string;
|
|
12
|
-
onClick: (item: T) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface TableListProps<T extends BasicModelInstance> {
|
|
16
|
-
columns: HeadCell[];
|
|
17
|
-
data: T[];
|
|
18
|
-
search?: boolean;
|
|
19
|
-
defaultSort: string;
|
|
20
|
-
defaultOrder?: Order;
|
|
21
|
-
loading?: boolean;
|
|
22
|
-
options?: TableRowOption<T>[];
|
|
23
|
-
onClick?: (d: T) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const TableList = <T extends BasicModelInstance>({
|
|
27
|
-
columns: columnsProp,
|
|
28
|
-
options,
|
|
29
|
-
data,
|
|
30
|
-
onClick = () => null,
|
|
31
|
-
search,
|
|
32
|
-
defaultSort,
|
|
33
|
-
defaultOrder,
|
|
34
|
-
loading,
|
|
35
|
-
}: TableListProps<T>) => {
|
|
36
|
-
const columns = columnsProp;
|
|
37
|
-
const [anchorMenuEl, setAnchorMenuEl] = React.useState<null | { item: T; anchor: HTMLElement }>(
|
|
38
|
-
null,
|
|
39
|
-
);
|
|
40
|
-
if (options && !columns.some((c) => c.id === OptionsId)) {
|
|
41
|
-
columns.push({
|
|
42
|
-
id: OptionsId,
|
|
43
|
-
label: "",
|
|
44
|
-
disablePadding: false,
|
|
45
|
-
numeric: false,
|
|
46
|
-
sort: false,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<EnhancedTable<T>
|
|
53
|
-
columns={columns}
|
|
54
|
-
data={data}
|
|
55
|
-
search={search}
|
|
56
|
-
defaultSort={defaultSort}
|
|
57
|
-
defaultOrder={defaultOrder}
|
|
58
|
-
loading={loading}
|
|
59
|
-
>
|
|
60
|
-
{(filteredData) =>
|
|
61
|
-
filteredData.map((row, i) => {
|
|
62
|
-
return (
|
|
63
|
-
<TableRow
|
|
64
|
-
key={row.id}
|
|
65
|
-
onClick={() => onClick(row)}
|
|
66
|
-
role="row"
|
|
67
|
-
aria-rowindex={i}
|
|
68
|
-
sx={{ cursor: "pointer" }}
|
|
69
|
-
>
|
|
70
|
-
{columns.map(({ id }, j) => (
|
|
71
|
-
<TableCell role="cell" scope="row" key={id} aria-rowindex={i} aria-colindex={j}>
|
|
72
|
-
{row[id]}
|
|
73
|
-
</TableCell>
|
|
74
|
-
))}
|
|
75
|
-
{options && (
|
|
76
|
-
<TableCell>
|
|
77
|
-
<IconButton
|
|
78
|
-
data-testid={`options-${row.id}`}
|
|
79
|
-
onClick={(event) => {
|
|
80
|
-
event.stopPropagation();
|
|
81
|
-
setAnchorMenuEl({
|
|
82
|
-
item: row,
|
|
83
|
-
anchor: event.currentTarget,
|
|
84
|
-
});
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
<MoreVertIcon />
|
|
88
|
-
</IconButton>
|
|
89
|
-
</TableCell>
|
|
90
|
-
)}
|
|
91
|
-
</TableRow>
|
|
92
|
-
);
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
</EnhancedTable>
|
|
96
|
-
{options && (
|
|
97
|
-
<Menu
|
|
98
|
-
anchorEl={anchorMenuEl?.anchor}
|
|
99
|
-
open={!!anchorMenuEl}
|
|
100
|
-
onClose={() => setAnchorMenuEl(null)}
|
|
101
|
-
anchorOrigin={{
|
|
102
|
-
vertical: "top",
|
|
103
|
-
horizontal: "left",
|
|
104
|
-
}}
|
|
105
|
-
transformOrigin={{
|
|
106
|
-
vertical: "top",
|
|
107
|
-
horizontal: "left",
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
{options.map(({ id, label, onClick }) => (
|
|
111
|
-
<MenuItem
|
|
112
|
-
key={id}
|
|
113
|
-
onClick={() => {
|
|
114
|
-
if (anchorMenuEl) {
|
|
115
|
-
onClick(anchorMenuEl?.item);
|
|
116
|
-
}
|
|
117
|
-
setAnchorMenuEl(null);
|
|
118
|
-
}}
|
|
119
|
-
>
|
|
120
|
-
{label}
|
|
121
|
-
</MenuItem>
|
|
122
|
-
))}
|
|
123
|
-
</Menu>
|
|
124
|
-
)}
|
|
125
|
-
</>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ValueBoolean } from "../value-boolean/value-boolean";
|
|
3
|
-
import { ValueText } from "../value-text";
|
|
4
|
-
import { GroupValueCard, GroupValueItem } from "./group-value-card";
|
|
5
|
-
|
|
6
|
-
export const GroupValueCardDummy = (props) => {
|
|
7
|
-
return (
|
|
8
|
-
<GroupValueCard {...props}>
|
|
9
|
-
<GroupValueItem xs={12} sm={6} md={4}>
|
|
10
|
-
<ValueText label="Hello world" value="Lorem ipsum sit amet" />
|
|
11
|
-
</GroupValueItem>
|
|
12
|
-
<GroupValueItem xs={12} sm={6} md={2}>
|
|
13
|
-
<ValueBoolean label="Enabled" value />
|
|
14
|
-
</GroupValueItem>
|
|
15
|
-
<GroupValueItem xs={12} sm={6} md={3}>
|
|
16
|
-
<ValueText label="Quantity" value="1200" />
|
|
17
|
-
</GroupValueItem>
|
|
18
|
-
<GroupValueItem xs={12} sm={6} md={3}>
|
|
19
|
-
<ValueText label="Currency" value="EUR" />
|
|
20
|
-
</GroupValueItem>
|
|
21
|
-
<GroupValueItem xs={12} sm={6} md={6}>
|
|
22
|
-
<ValueText
|
|
23
|
-
label="I am Batman"
|
|
24
|
-
value=" Does it come in black? It's ends here. Hero can be anyone"
|
|
25
|
-
/>
|
|
26
|
-
</GroupValueItem>
|
|
27
|
-
<GroupValueItem xs={12} sm={6} md={3}>
|
|
28
|
-
<ValueText label="Status" value="Open" />
|
|
29
|
-
</GroupValueItem>
|
|
30
|
-
<GroupValueItem xs={12} sm={6} md={3}>
|
|
31
|
-
<ValueText label="Level" value="2144" />
|
|
32
|
-
</GroupValueItem>
|
|
33
|
-
</GroupValueCard>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { GroupValueCard } from "./group-value-card";
|
|
3
|
-
import { createTemplate, withPadding } from "../../../storybook";
|
|
4
|
-
import { GroupValueCardDummy } from "./group-value-card.mock";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: "Value displays/GroupValueCard",
|
|
8
|
-
component: GroupValueCard,
|
|
9
|
-
decorators: [withPadding(2)],
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: "fullscreen",
|
|
12
|
-
},
|
|
13
|
-
} as ComponentMeta<typeof GroupValueCard>;
|
|
14
|
-
|
|
15
|
-
const Template = createTemplate(GroupValueCardDummy);
|
|
16
|
-
|
|
17
|
-
export const Default = Template.bind({});
|
|
18
|
-
Default.args = {
|
|
19
|
-
title: "Hello world",
|
|
20
|
-
subtitle: "Lorem ipsum sit amet",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const WihtoutSubtitle = Template.bind({});
|
|
24
|
-
WihtoutSubtitle.args = {
|
|
25
|
-
title: "Hello world",
|
|
26
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "../../../tests";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { GroupValueCardDummy } from "./group-value-card.mock";
|
|
4
|
-
|
|
5
|
-
describe("GroupValueCard", () => {
|
|
6
|
-
const renderComponent = ({
|
|
7
|
-
title = "Hello world",
|
|
8
|
-
subtitle = undefined,
|
|
9
|
-
}: { title?: string; subtitle?: string } = {}) => {
|
|
10
|
-
return render(<GroupValueCardDummy title={title} subtitle={subtitle} />);
|
|
11
|
-
};
|
|
12
|
-
it("would render a title", () => {
|
|
13
|
-
renderComponent({ title: "Hello world" });
|
|
14
|
-
|
|
15
|
-
expect(screen.getByRole("heading", { level: 1 })).toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe("subtitle", () => {
|
|
19
|
-
it("would not render a subtitle if it's not provided", () => {
|
|
20
|
-
renderComponent({ subtitle: undefined });
|
|
21
|
-
|
|
22
|
-
expect(screen.queryByRole("heading", { level: 2 })).not.toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("would render a subtitle if it's provided", () => {
|
|
26
|
-
renderComponent({ subtitle: "Hi. I am batman" });
|
|
27
|
-
|
|
28
|
-
expect(
|
|
29
|
-
screen.getByRole("heading", { level: 2, name: /hi. i am batman/i }),
|
|
30
|
-
).toBeInTheDocument();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("would render all values", () => {
|
|
35
|
-
renderComponent();
|
|
36
|
-
|
|
37
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
38
|
-
expect(screen.getByText(/lorem ipsum sit amet/i)).toBeInTheDocument();
|
|
39
|
-
|
|
40
|
-
expect(screen.getByRole("label", { name: /enabled/i })).toBeInTheDocument();
|
|
41
|
-
expect(screen.getByTestId("CheckIcon")).toBeInTheDocument();
|
|
42
|
-
|
|
43
|
-
expect(screen.getByRole("label", { name: /quantity/i })).toBeInTheDocument();
|
|
44
|
-
expect(screen.getByText(/1200/i)).toBeInTheDocument();
|
|
45
|
-
|
|
46
|
-
expect(screen.getByRole("label", { name: /currency/i })).toBeInTheDocument();
|
|
47
|
-
expect(screen.getByText(/eur/i)).toBeInTheDocument();
|
|
48
|
-
|
|
49
|
-
expect(screen.getByRole("label", { name: /i am batman/i })).toBeInTheDocument();
|
|
50
|
-
expect(screen.getByText(/does it come in black/i)).toBeInTheDocument();
|
|
51
|
-
|
|
52
|
-
expect(screen.getByRole("label", { name: /status/i })).toBeInTheDocument();
|
|
53
|
-
expect(screen.getByText(/open/i)).toBeInTheDocument();
|
|
54
|
-
|
|
55
|
-
expect(screen.getByRole("label", { name: /level/i })).toBeInTheDocument();
|
|
56
|
-
expect(screen.getByText(/2144/i)).toBeInTheDocument();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Grid, Paper, GridProps, Box, Typography } from "@mui/material";
|
|
2
|
-
import React, { FunctionComponent, PropsWithChildren, ReactElement } from "react";
|
|
3
|
-
import { useGetDefaultThemeColor } from "../../../utils/theme";
|
|
4
|
-
|
|
5
|
-
export type GroupValueItemProps = PropsWithChildren<Omit<GridProps, "item" | "container">>;
|
|
6
|
-
export type GroupValueItemComponent = FunctionComponent<GroupValueItemProps>;
|
|
7
|
-
export type GroupValueItemElement = ReactElement<GroupValueItemProps, GroupValueItemComponent>;
|
|
8
|
-
|
|
9
|
-
export const groupValueItemClasses = {
|
|
10
|
-
root: "RdsGroupValueItem-root",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const GroupValueItem: GroupValueItemComponent = ({
|
|
14
|
-
children,
|
|
15
|
-
...rest
|
|
16
|
-
}: GroupValueItemProps) => {
|
|
17
|
-
const defaultColor = useGetDefaultThemeColor({ lightWeight: 200, darkWeight: 800 });
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Grid item className={groupValueItemClasses.root} {...rest}>
|
|
21
|
-
<Box
|
|
22
|
-
px={1}
|
|
23
|
-
sx={{
|
|
24
|
-
borderLeft: `solid ${defaultColor} 1px`,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
{children}
|
|
28
|
-
</Box>
|
|
29
|
-
</Grid>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export interface GroupValueCardProps {
|
|
34
|
-
title: string;
|
|
35
|
-
subtitle?: string;
|
|
36
|
-
children: GroupValueItemElement | GroupValueItemElement[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const GroupValueCard = ({ title, subtitle, children }: GroupValueCardProps) => {
|
|
40
|
-
const defaultColor = useGetDefaultThemeColor({ lightWeight: 200, darkWeight: 800 });
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<Paper
|
|
44
|
-
sx={{
|
|
45
|
-
paddingBottom: 1,
|
|
46
|
-
}}
|
|
47
|
-
>
|
|
48
|
-
<Box bgcolor={defaultColor} px={2} py={1}>
|
|
49
|
-
<Typography variant="h6" role="heading" aria-level={1}>
|
|
50
|
-
{title}
|
|
51
|
-
</Typography>
|
|
52
|
-
{subtitle && (
|
|
53
|
-
<Typography variant="body2" role="heading" aria-level={2}>
|
|
54
|
-
{subtitle}
|
|
55
|
-
</Typography>
|
|
56
|
-
)}
|
|
57
|
-
</Box>
|
|
58
|
-
<Grid container margin={2} rowSpacing={2}>
|
|
59
|
-
{children}
|
|
60
|
-
</Grid>
|
|
61
|
-
</Paper>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./group-value-card";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-boolean";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { ValueBoolean } from "./value-boolean";
|
|
3
|
-
import { createTemplate } from "../../../storybook";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Value displays/ValueBoolean",
|
|
7
|
-
component: ValueBoolean,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "centered",
|
|
10
|
-
},
|
|
11
|
-
} as ComponentMeta<typeof ValueBoolean>;
|
|
12
|
-
|
|
13
|
-
const Template = createTemplate(ValueBoolean);
|
|
14
|
-
|
|
15
|
-
export const True = Template.bind({});
|
|
16
|
-
True.args = {
|
|
17
|
-
label: "Lorem ipsum",
|
|
18
|
-
value: true,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const False = Template.bind({});
|
|
22
|
-
False.args = {
|
|
23
|
-
label: "Lorem ipsum",
|
|
24
|
-
value: false,
|
|
25
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ValueBoolean } from "./value-boolean";
|
|
3
|
-
import { render, screen } from "../../../tests";
|
|
4
|
-
|
|
5
|
-
describe("ValueBoolean", () => {
|
|
6
|
-
const renderComponent = ({ value }: { value: boolean }) => {
|
|
7
|
-
return render(<ValueBoolean label="Hello world" value={value} />);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
it("would render the label", () => {
|
|
11
|
-
renderComponent({ value: true });
|
|
12
|
-
|
|
13
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("would render a check if value is true", () => {
|
|
17
|
-
renderComponent({ value: true });
|
|
18
|
-
|
|
19
|
-
expect(screen.getByTestId("CheckIcon")).toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("would render a cross if value is false", () => {
|
|
23
|
-
renderComponent({ value: false });
|
|
24
|
-
|
|
25
|
-
expect(screen.getByTestId("CloseIcon")).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Box, Typography, useTheme } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import CheckIcon from "@mui/icons-material/Check";
|
|
4
|
-
import CloseIcon from "@mui/icons-material/Close";
|
|
5
|
-
|
|
6
|
-
export interface ValueBooleanProps {
|
|
7
|
-
/**
|
|
8
|
-
* Name of the displayed value
|
|
9
|
-
*/
|
|
10
|
-
label: string;
|
|
11
|
-
/**
|
|
12
|
-
* Value displayed
|
|
13
|
-
*/
|
|
14
|
-
value: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Displays a boolean value with a label
|
|
19
|
-
*/
|
|
20
|
-
export const ValueBoolean = ({ label, value }: ValueBooleanProps) => {
|
|
21
|
-
const { typography } = useTheme();
|
|
22
|
-
|
|
23
|
-
const iconSx = { fontSize: typography.h5.fontSize };
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<Box>
|
|
27
|
-
<Typography variant="subtitle2" role="label">
|
|
28
|
-
{label}
|
|
29
|
-
</Typography>
|
|
30
|
-
{value ? <CheckIcon color="success" sx={iconSx} /> : <CloseIcon color="error" sx={iconSx} />}
|
|
31
|
-
</Box>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-card";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { ComponentMeta } from "@storybook/react";
|
|
3
|
-
import { ValueCard } from "./value-card";
|
|
4
|
-
import { createTemplate } from "../../../storybook";
|
|
5
|
-
import { ValueText } from "../value-text";
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: "Value displays/ValueCard",
|
|
9
|
-
component: ValueCard,
|
|
10
|
-
parameters: {
|
|
11
|
-
layout: "centered",
|
|
12
|
-
},
|
|
13
|
-
} as ComponentMeta<typeof ValueCard>;
|
|
14
|
-
|
|
15
|
-
const Template = createTemplate(({ children }: PropsWithChildren) => {
|
|
16
|
-
return <ValueCard>{children}</ValueCard>;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const ValueCardText = Template.bind({});
|
|
20
|
-
ValueCardText.args = {
|
|
21
|
-
children: <ValueText label="Hello world" value="Lorem ipsum sit amet" />,
|
|
22
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ValueCard } from "./value-card";
|
|
3
|
-
import { render, screen } from "../../../tests";
|
|
4
|
-
import { ReactElement } from "react";
|
|
5
|
-
import { ValueText } from "../value-text";
|
|
6
|
-
|
|
7
|
-
describe("ValueCard", () => {
|
|
8
|
-
const renderComponent = ({ children }: { children: ReactElement }) => {
|
|
9
|
-
return render(<ValueCard>{children}</ValueCard>);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
it("would render with a ValueText inside", () => {
|
|
13
|
-
renderComponent({ children: <ValueText label="Hello world" value="Lorem ipsum sit amet" /> });
|
|
14
|
-
|
|
15
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
16
|
-
expect(screen.getByText(/lorem ipsum sit amet/i)).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Paper } from "@mui/material";
|
|
3
|
-
import { PropsWithChildren } from "react";
|
|
4
|
-
|
|
5
|
-
export type ValueCardProps = PropsWithChildren;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Container to show a labeled value
|
|
9
|
-
*/
|
|
10
|
-
export const ValueCard = ({ children }: ValueCardProps) => {
|
|
11
|
-
return <Paper sx={{ p: 2 }}>{children}</Paper>;
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./value-text";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { render, screen } from "../../../tests";
|
|
3
|
-
import { ValueText } from "./value-text";
|
|
4
|
-
|
|
5
|
-
describe("ValueText", () => {
|
|
6
|
-
const renderComponent = () => {
|
|
7
|
-
return render(<ValueText label="Hello world" value="Lorem ipsum sit amet" />);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
it("would render the label", () => {
|
|
11
|
-
renderComponent();
|
|
12
|
-
|
|
13
|
-
expect(screen.getByRole("label", { name: /hello world/i })).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it("would render the value", () => {
|
|
17
|
-
renderComponent();
|
|
18
|
-
|
|
19
|
-
expect(screen.getByText(/lorem ipsum sit amet/i)).toBeInTheDocument();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ComponentMeta } from "@storybook/react";
|
|
2
|
-
import { ValueText } from "./value-text";
|
|
3
|
-
import { createTemplate, withContainer } from "../../../storybook";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Value displays/ValueText",
|
|
7
|
-
component: ValueText,
|
|
8
|
-
decorators: [withContainer({ width: 200 })],
|
|
9
|
-
parameters: {
|
|
10
|
-
layout: "centered",
|
|
11
|
-
},
|
|
12
|
-
} as ComponentMeta<typeof ValueText>;
|
|
13
|
-
|
|
14
|
-
const Template = createTemplate(ValueText);
|
|
15
|
-
|
|
16
|
-
export const Default = Template.bind({});
|
|
17
|
-
Default.args = {
|
|
18
|
-
label: "Lorem",
|
|
19
|
-
value: "ipsum sit",
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const TruncatedText = Template.bind({});
|
|
23
|
-
TruncatedText.args = {
|
|
24
|
-
label: "Lorem",
|
|
25
|
-
value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit",
|
|
26
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Box, Tooltip, Typography } from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
export interface ValueTextProps {
|
|
5
|
-
/**
|
|
6
|
-
* Name of the displayed value
|
|
7
|
-
*/
|
|
8
|
-
label: string;
|
|
9
|
-
/**
|
|
10
|
-
* Value displayed
|
|
11
|
-
*/
|
|
12
|
-
value: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Displays a string value with a label
|
|
17
|
-
*/
|
|
18
|
-
export const ValueText = ({ label, value }: ValueTextProps) => {
|
|
19
|
-
const id = `label-${label.replace(/ /g, "-")}`;
|
|
20
|
-
return (
|
|
21
|
-
<Box>
|
|
22
|
-
<Typography variant="subtitle2" role="label" id={id}>
|
|
23
|
-
{label}
|
|
24
|
-
</Typography>
|
|
25
|
-
<Tooltip title={value} placement="top" enterDelay={2000}>
|
|
26
|
-
<Typography variant="h5" noWrap aria-labelledby={id}>
|
|
27
|
-
{value}
|
|
28
|
-
</Typography>
|
|
29
|
-
</Tooltip>
|
|
30
|
-
</Box>
|
|
31
|
-
);
|
|
32
|
-
};
|