@etsoo/react 1.4.40 → 1.4.44

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.
@@ -8,6 +8,7 @@ export declare namespace Labels {
8
8
  */
9
9
  const CommonPage: {
10
10
  add: string;
11
+ delete: string;
11
12
  more: string;
12
13
  pullToRefresh: string;
13
14
  refresh: string;
package/lib/app/Labels.js CHANGED
@@ -9,6 +9,7 @@ export var Labels;
9
9
  */
10
10
  Labels.CommonPage = {
11
11
  add: 'Add',
12
+ delete: 'Delete',
12
13
  more: 'More',
13
14
  pullToRefresh: 'Pull down to refresh',
14
15
  refresh: 'Refresh',
@@ -67,7 +67,7 @@ export var DataGridRenderers;
67
67
  if (value)
68
68
  return React.createElement(CheckIcon, { fontSize: "small" });
69
69
  else
70
- return React.createElement(ClearIcon, { fontSize: "small", color: "error" });
70
+ return React.createElement(ClearIcon, { fontSize: "small", color: "warning" });
71
71
  }
72
72
  // To string
73
73
  return new String(value);
@@ -147,7 +147,7 @@ export function ResponsibleContainer(props) {
147
147
  ? undefined
148
148
  : containerBoxSx(paddings, showDataGrid) },
149
149
  React.createElement(Stack, null,
150
- React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox" }, searchBar),
150
+ React.createElement(Box, { ref: dimensions[0][0], className: "SearchBox", sx: { height: 64 } }, searchBar),
151
151
  list),
152
152
  pullToRefresh && pullContainer && (React.createElement(PullToRefreshUI, { mainElement: pullContainer, triggerElement: pullContainer, instructionsPullToRefresh: labels.pullToRefresh, instructionsReleaseToRefresh: labels.releaseToRefresh, instructionsRefreshing: labels.refreshing, onRefresh: () => { var _a; return (_a = state.ref) === null || _a === void 0 ? void 0 : _a.reset(); }, shouldPullToRefresh: () => {
153
153
  const container = document.querySelector(pullContainer);
@@ -12,6 +12,10 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
12
12
  * Panel box props
13
13
  */
14
14
  panel?: Omit<BoxProps, 'hidden'>;
15
+ /**
16
+ * To URL
17
+ */
18
+ to?: string;
15
19
  }
16
20
  /**
17
21
  * Tabs with box props
package/lib/mu/TabBox.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Utils } from '@etsoo/shared';
2
2
  import { Box, Tab, Tabs } from '@mui/material';
3
+ import { Link } from '@reach/router';
3
4
  import React from 'react';
4
5
  /**
5
6
  * Tabs with box
@@ -25,6 +26,6 @@ export function TabBox(props) {
25
26
  setValue(newValue);
26
27
  if (onChange)
27
28
  onChange(event, newValue);
28
- }, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, ...tabRest }))))),
29
+ }, ...rest }, tabs.map(({ children, panel, ...tabRest }, index) => (React.createElement(Tab, { key: index, value: index, LinkComponent: tabRest.to ? Link : undefined, ...tabRest }))))),
29
30
  tabs.map(({ children, panel }, index) => (React.createElement(Box, { key: index, hidden: value !== index, ...panel }, Utils.getResult(children, value === index))))));
30
31
  }
@@ -4,10 +4,18 @@ import { CommonPageProps } from './CommonPageProps';
4
4
  * Add / Edit page props
5
5
  */
6
6
  export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
7
+ /**
8
+ * Is editing
9
+ */
10
+ isEditing?: boolean;
7
11
  /**
8
12
  * On form submit
9
13
  */
10
14
  onSubmit?: FormEventHandler<HTMLFormElement>;
15
+ /**
16
+ * On delete callback
17
+ */
18
+ onDelete?: () => Promise<void> | void;
11
19
  }
12
20
  /**
13
21
  * Add / Edit page
@@ -4,22 +4,24 @@ import { Labels } from '../../app/Labels';
4
4
  import { MUGlobal } from '../MUGlobal';
5
5
  import { CommonPage, CommonPageScrollContainer } from './CommonPage';
6
6
  import SaveIcon from '@mui/icons-material/Save';
7
+ import DeleteIcon from '@mui/icons-material/Delete';
7
8
  /**
8
9
  * Add / Edit page
9
10
  * @param props Props
10
11
  */
11
12
  export function EditPage(props) {
12
13
  // Destruct
13
- const { children, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, ...rest } = props;
14
+ const { children, isEditing, onDelete, onSubmit, paddings = MUGlobal.pagePaddings, scrollContainer = CommonPageScrollContainer, ...rest } = props;
14
15
  // Labels
15
16
  const labels = Labels.CommonPage;
16
17
  return (React.createElement(CommonPage, { paddings: paddings, scrollContainer: scrollContainer, ...rest },
17
18
  React.createElement("form", { onSubmit: onSubmit },
18
19
  React.createElement(Grid, { container: true, justifyContent: "left", spacing: paddings, paddingTop: 1 }, children),
19
- React.createElement(Grid, { container: true, position: "sticky", sx: {
20
+ React.createElement(Grid, { container: true, position: "sticky", display: "flex", gap: paddings, sx: {
20
21
  top: 'auto',
21
22
  bottom: (theme) => MUGlobal.updateWithTheme(paddings, theme.spacing),
22
23
  paddingTop: paddings
23
24
  } },
24
- React.createElement(Button, { variant: "contained", type: "submit", fullWidth: true, startIcon: React.createElement(SaveIcon, null) }, labels.save)))));
25
+ isEditing && onDelete && (React.createElement(Button, { color: "primary", variant: "outlined", onClick: () => onDelete(), startIcon: React.createElement(DeleteIcon, { color: "warning" }) }, labels.delete)),
26
+ React.createElement(Button, { variant: "contained", type: "submit", startIcon: React.createElement(SaveIcon, null), sx: { flexGrow: 1 } }, labels.save)))));
25
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.4.40",
3
+ "version": "1.4.44",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "@emotion/react": "^11.7.1",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.2.22",
53
+ "@etsoo/appscript": "^1.2.24",
54
54
  "@etsoo/notificationbase": "^1.1.0",
55
55
  "@etsoo/shared": "^1.1.3",
56
56
  "@mui/icons-material": "^5.2.5",
@@ -91,7 +91,7 @@
91
91
  "eslint-plugin-react": "^7.28.0",
92
92
  "jest": "^27.4.7",
93
93
  "react-test-renderer": "^17.0.2",
94
- "ts-jest": "^27.1.2",
94
+ "ts-jest": "^27.1.3",
95
95
  "typescript": "^4.5.4"
96
96
  }
97
97
  }
package/src/app/Labels.ts CHANGED
@@ -9,6 +9,7 @@ export namespace Labels {
9
9
  */
10
10
  export const CommonPage = {
11
11
  add: 'Add',
12
+ delete: 'Delete',
12
13
  more: 'More',
13
14
  pullToRefresh: 'Pull down to refresh',
14
15
  refresh: 'Refresh',
@@ -103,7 +103,7 @@ export namespace DataGridRenderers {
103
103
  }
104
104
 
105
105
  if (value) return <CheckIcon fontSize="small" />;
106
- else return <ClearIcon fontSize="small" color="error" />;
106
+ else return <ClearIcon fontSize="small" color="warning" />;
107
107
  }
108
108
 
109
109
  // To string
@@ -349,7 +349,11 @@ export function ResponsibleContainer<
349
349
  }
350
350
  >
351
351
  <Stack>
352
- <Box ref={dimensions[0][0]} className="SearchBox">
352
+ <Box
353
+ ref={dimensions[0][0]}
354
+ className="SearchBox"
355
+ sx={{ height: 64 }}
356
+ >
353
357
  {searchBar}
354
358
  </Box>
355
359
  {list}
package/src/mu/TabBox.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Utils } from '@etsoo/shared';
2
2
  import { Box, BoxProps, Tab, TabProps, Tabs, TabsProps } from '@mui/material';
3
+ import { Link } from '@reach/router';
3
4
  import React from 'react';
4
5
 
5
6
  /**
@@ -15,6 +16,11 @@ export interface TabBoxPanel extends Omit<TabProps, 'value' | 'children'> {
15
16
  * Panel box props
16
17
  */
17
18
  panel?: Omit<BoxProps, 'hidden'>;
19
+
20
+ /**
21
+ * To URL
22
+ */
23
+ to?: string;
18
24
  }
19
25
 
20
26
  /**
@@ -93,7 +99,12 @@ export function TabBox(props: TabBoxPros) {
93
99
  {...rest}
94
100
  >
95
101
  {tabs.map(({ children, panel, ...tabRest }, index) => (
96
- <Tab key={index} value={index} {...tabRest} />
102
+ <Tab
103
+ key={index}
104
+ value={index}
105
+ LinkComponent={tabRest.to ? Link : undefined}
106
+ {...tabRest}
107
+ />
97
108
  ))}
98
109
  </Tabs>
99
110
  </Box>
@@ -5,15 +5,26 @@ import { MUGlobal } from '../MUGlobal';
5
5
  import { CommonPage, CommonPageScrollContainer } from './CommonPage';
6
6
  import { CommonPageProps } from './CommonPageProps';
7
7
  import SaveIcon from '@mui/icons-material/Save';
8
+ import DeleteIcon from '@mui/icons-material/Delete';
8
9
 
9
10
  /**
10
11
  * Add / Edit page props
11
12
  */
12
13
  export interface EditPageProps extends Omit<CommonPageProps, 'onSubmit'> {
14
+ /**
15
+ * Is editing
16
+ */
17
+ isEditing?: boolean;
18
+
13
19
  /**
14
20
  * On form submit
15
21
  */
16
22
  onSubmit?: FormEventHandler<HTMLFormElement>;
23
+
24
+ /**
25
+ * On delete callback
26
+ */
27
+ onDelete?: () => Promise<void> | void;
17
28
  }
18
29
 
19
30
  /**
@@ -24,6 +35,8 @@ export function EditPage(props: EditPageProps) {
24
35
  // Destruct
25
36
  const {
26
37
  children,
38
+ isEditing,
39
+ onDelete,
27
40
  onSubmit,
28
41
  paddings = MUGlobal.pagePaddings,
29
42
  scrollContainer = CommonPageScrollContainer,
@@ -51,6 +64,8 @@ export function EditPage(props: EditPageProps) {
51
64
  <Grid
52
65
  container
53
66
  position="sticky"
67
+ display="flex"
68
+ gap={paddings}
54
69
  sx={{
55
70
  top: 'auto',
56
71
  bottom: (theme) =>
@@ -58,11 +73,21 @@ export function EditPage(props: EditPageProps) {
58
73
  paddingTop: paddings
59
74
  }}
60
75
  >
76
+ {isEditing && onDelete && (
77
+ <Button
78
+ color="primary"
79
+ variant="outlined"
80
+ onClick={() => onDelete()}
81
+ startIcon={<DeleteIcon color="warning" />}
82
+ >
83
+ {labels.delete}
84
+ </Button>
85
+ )}
61
86
  <Button
62
87
  variant="contained"
63
88
  type="submit"
64
- fullWidth
65
89
  startIcon={<SaveIcon />}
90
+ sx={{ flexGrow: 1 }}
66
91
  >
67
92
  {labels.save}
68
93
  </Button>