@pautena/react-design-system 0.7.2 → 0.7.4
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/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/alerts/expandable-alert/expandable-alert.d.ts +4 -1
- package/dist/cjs/types/components/data-display/board/board.d.ts +1 -2
- package/dist/cjs/types/components/feedback/query-container/query-container.d.ts +7 -3
- package/dist/cjs/types/components/inputs/index.d.ts +1 -0
- package/dist/cjs/types/components/value-displays/group-value-card/group-value-card.mock.d.ts +3 -1
- package/dist/cjs/types/components/value-displays/value-base/value-edit.d.ts +7 -2
- package/dist/cjs/types/components/value-displays/value-content/value-content.d.ts +10 -1
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/alerts/expandable-alert/expandable-alert.d.ts +4 -1
- package/dist/esm/types/components/data-display/board/board.d.ts +1 -2
- package/dist/esm/types/components/feedback/query-container/query-container.d.ts +7 -3
- package/dist/esm/types/components/inputs/index.d.ts +1 -0
- package/dist/esm/types/components/value-displays/group-value-card/group-value-card.mock.d.ts +3 -1
- package/dist/esm/types/components/value-displays/value-base/value-edit.d.ts +7 -2
- package/dist/esm/types/components/value-displays/value-content/value-content.d.ts +10 -1
- package/dist/index.d.ts +26 -9
- package/package.json +2 -1
- package/src/components/alerts/expandable-alert/expandable-alert.stories.tsx +23 -1
- package/src/components/alerts/expandable-alert/expandable-alert.tsx +11 -4
- package/src/components/data-display/board/board.test.tsx +60 -43
- package/src/components/data-display/board/board.tsx +24 -17
- package/src/components/feedback/query-container/query-container.stories.tsx +19 -6
- package/src/components/feedback/query-container/query-container.test.tsx +65 -17
- package/src/components/feedback/query-container/query-container.tsx +20 -5
- package/src/components/inputs/autocomplete/autocomplete.stories.tsx +8 -0
- package/src/components/inputs/index.ts +1 -0
- package/src/components/inputs/text-field/text-field.stories.tsx +8 -0
- package/src/components/inputs/text-field/text-field.tsx +2 -2
- package/src/components/value-displays/group-value-card/group-value-card.mock.tsx +28 -8
- package/src/components/value-displays/group-value-card/group-value-card.stories.tsx +19 -2
- package/src/components/value-displays/group-value-card/group-value-card.test.tsx +16 -18
- package/src/components/value-displays/value-base/value-edit.test.tsx +88 -0
- package/src/components/value-displays/value-base/value-edit.tsx +28 -6
- package/src/components/value-displays/value-boolean/value-boolean.stories.tsx +9 -0
- package/src/components/value-displays/value-boolean/value-boolean.test.tsx +29 -15
- package/src/components/value-displays/value-boolean/value-boolean.tsx +18 -11
- package/src/components/value-displays/value-content/value-content.test.tsx +20 -6
- package/src/components/value-displays/value-content/value-content.tsx +24 -10
- package/src/components/value-displays/value-datetime/value-datetime.stories.tsx +11 -0
- package/src/components/value-displays/value-datetime/value-datetime.test.tsx +9 -9
- package/src/components/value-displays/value-datetime/value-datetime.tsx +14 -10
- package/src/components/value-displays/value-rating/value-rating.stories.tsx +10 -0
- package/src/components/value-displays/value-rating/value-rating.test.tsx +11 -11
- package/src/components/value-displays/value-rating/value-rating.tsx +10 -8
- package/src/components/value-displays/value-text/value-text.stories.tsx +9 -0
- package/src/components/value-displays/value-text/value-text.test.tsx +20 -9
- package/src/components/value-displays/value-text/value-text.tsx +23 -10
- package/src/generators/model-form/model-form.test.tsx +1 -1
- package/src/generators/model-router/model-router.test.tsx +3 -3
- package/src/layouts/header-layout/header-layout.stories.tsx +2 -2
- package/src/layouts/header-layout/header-layout.tsx +1 -7
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React from "react";
|
|
1
|
+
import { Typography, TextField } from "@mui/material";
|
|
2
|
+
import React, { useEffect, useRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
BaseValueProps,
|
|
5
5
|
DefaultPlaceholder,
|
|
6
6
|
EditableValueProps,
|
|
7
7
|
useEditableValueDisplay,
|
|
8
|
+
ValueEditButton,
|
|
8
9
|
ValueEditButtons,
|
|
9
10
|
} from "../value-base";
|
|
10
11
|
import { getValueContentLabelId, ValueContent } from "../value-content";
|
|
11
|
-
import EditIcon from "@mui/icons-material/Edit";
|
|
12
12
|
|
|
13
13
|
export type ValueTextProps = BaseValueProps<string | number> & EditableValueProps<string>;
|
|
14
14
|
|
|
@@ -23,30 +23,43 @@ export const ValueText = ({
|
|
|
23
23
|
dense,
|
|
24
24
|
onEdit = () => null,
|
|
25
25
|
}: ValueTextProps) => {
|
|
26
|
+
const editInputRef = useRef<HTMLInputElement>(null);
|
|
26
27
|
const { isEditing, editValue, startEdit, cancelEdit, setEditValue, submitEdit } =
|
|
27
28
|
useEditableValueDisplay(valueProp?.toString(), onEdit);
|
|
28
29
|
const id = getValueContentLabelId(label);
|
|
29
30
|
const value = valueProp?.toString() || placeholder;
|
|
30
31
|
|
|
32
|
+
const editKeyPressListener = (e: KeyboardEvent) => {
|
|
33
|
+
if (e.key === "Enter") {
|
|
34
|
+
onEdit((e.target as any).value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
editInputRef.current?.addEventListener("keypress", editKeyPressListener);
|
|
40
|
+
return () => editInputRef.current?.removeEventListener("keypress", editKeyPressListener);
|
|
41
|
+
}, [editInputRef.current]);
|
|
42
|
+
|
|
31
43
|
return (
|
|
32
|
-
<ValueContent label={label} tooltip={value} dense={dense}>
|
|
44
|
+
<ValueContent hideLabel={isEditing} label={label} tooltip={value} dense={dense}>
|
|
33
45
|
{isEditing ? (
|
|
34
46
|
<TextField
|
|
47
|
+
inputRef={editInputRef}
|
|
35
48
|
value={editValue}
|
|
49
|
+
label={label}
|
|
36
50
|
size="small"
|
|
37
51
|
onChange={(e) => setEditValue(e.target.value)}
|
|
38
52
|
InputProps={{
|
|
39
|
-
endAdornment:
|
|
53
|
+
endAdornment: (
|
|
54
|
+
<ValueEditButtons onClickCancel={cancelEdit} onClickSubmit={submitEdit} />
|
|
55
|
+
),
|
|
40
56
|
}}
|
|
57
|
+
sx={{ marginY: !dense ? 1 : 0 }}
|
|
41
58
|
/>
|
|
42
59
|
) : (
|
|
43
60
|
<Typography variant={dense ? "body1" : "h5"} noWrap aria-labelledby={id}>
|
|
44
61
|
{value}
|
|
45
|
-
{editable &&
|
|
46
|
-
<IconButton size="small" onClick={startEdit} sx={{ ml: 1 }}>
|
|
47
|
-
<EditIcon />
|
|
48
|
-
</IconButton>
|
|
49
|
-
)}
|
|
62
|
+
{editable && <ValueEditButton dense={dense} onClick={startEdit} />}
|
|
50
63
|
</Typography>
|
|
51
64
|
)}
|
|
52
65
|
</ValueContent>
|
|
@@ -711,7 +711,7 @@ describe("ModelRouter", () => {
|
|
|
711
711
|
const newInstance = await actions.fullfillModelForm({ model, submit: false });
|
|
712
712
|
|
|
713
713
|
expectModelFieldInputValue(model.fields, newInstance);
|
|
714
|
-
});
|
|
714
|
+
}, 20000);
|
|
715
715
|
|
|
716
716
|
it("would make a request when the form is submitted", async () => {
|
|
717
717
|
const { onSubmitNewItem, model } = await renderComponent({ screen: "add" });
|
|
@@ -721,7 +721,7 @@ describe("ModelRouter", () => {
|
|
|
721
721
|
expectToHaveBeenCalledOnceWithMockInstance(onSubmitNewItem, {
|
|
722
722
|
...newInstance,
|
|
723
723
|
});
|
|
724
|
-
});
|
|
724
|
+
}, 20000);
|
|
725
725
|
|
|
726
726
|
it("would show a loading indicator when the request is in progress", async () => {
|
|
727
727
|
const { model } = await renderComponent({ screen: "add" });
|
|
@@ -729,7 +729,7 @@ describe("ModelRouter", () => {
|
|
|
729
729
|
await actions.fullfillModelForm({ model, submit: true });
|
|
730
730
|
|
|
731
731
|
expectProgressIndicator();
|
|
732
|
-
});
|
|
732
|
+
}, 20000);
|
|
733
733
|
|
|
734
734
|
it("would show a success message if the request finish with a success", async () => {
|
|
735
735
|
renderAddScreen();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement } from "react";
|
|
2
2
|
import { Meta, StoryObj } from "@storybook/react";
|
|
3
3
|
import { HeaderLayout, HeaderLayoutProps } from "./header-layout";
|
|
4
|
-
import { withMemoryRouter } from "~/storybook";
|
|
4
|
+
import { withLocalizationProvider, withMemoryRouter } from "~/storybook";
|
|
5
5
|
import { withFullHeight } from "../../storybook";
|
|
6
6
|
import { Content, Header, HeaderProps, HeaderTab, SkeletonGrid, TabPanel } from "../../components";
|
|
7
7
|
import { Box, Typography } from "@mui/material";
|
|
@@ -64,7 +64,7 @@ const DummyHeaderLayout = ({ headerProps, contentChildren, ...rest }: HeaderLayo
|
|
|
64
64
|
export default {
|
|
65
65
|
title: "Layouts/HeaderLayout",
|
|
66
66
|
component: DummyHeaderLayout,
|
|
67
|
-
decorators: [withMemoryRouter(), withFullHeight],
|
|
67
|
+
decorators: [withMemoryRouter(), withFullHeight, withLocalizationProvider],
|
|
68
68
|
parameters: {
|
|
69
69
|
layout: "fullscreen",
|
|
70
70
|
},
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Box, LinearProgress } from "@mui/material";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
ContentElement,
|
|
5
|
-
HeaderElement,
|
|
6
|
-
Placeholder,
|
|
7
|
-
PlaceholderIcon,
|
|
8
|
-
PlaceholderIconArgs,
|
|
9
|
-
} from "../../components";
|
|
3
|
+
import { ContentElement, HeaderElement, Placeholder, PlaceholderIcon } from "../../components";
|
|
10
4
|
import { LoadingArea } from "../../components/feedback/loading-area";
|
|
11
5
|
import { TabProvider } from "../../providers";
|
|
12
6
|
import ReportProblemIcon from "@mui/icons-material/ReportProblem";
|