@etsoo/react 1.3.47 → 1.3.51

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/lib/index.d.ts CHANGED
@@ -55,6 +55,7 @@ export * from './mu/OptionGroup';
55
55
  export * from './mu/PList';
56
56
  export * from './mu/ProgressCount';
57
57
  export * from './mu/PullToRefreshUI';
58
+ export * from './mu/RLink';
58
59
  export * from './mu/ScrollerListEx';
59
60
  export * from './mu/ScrollTopFab';
60
61
  export * from './mu/SearchBar';
package/lib/index.js CHANGED
@@ -58,6 +58,7 @@ export * from './mu/OptionGroup';
58
58
  export * from './mu/PList';
59
59
  export * from './mu/ProgressCount';
60
60
  export * from './mu/PullToRefreshUI';
61
+ export * from './mu/RLink';
61
62
  export * from './mu/ScrollerListEx';
62
63
  export * from './mu/ScrollTopFab';
63
64
  export * from './mu/SearchBar';
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { LinkProps } from '@mui/material';
3
+ import { LinkProps as RouterLinkProps } from '@reach/router';
4
+ /**
5
+ * Router Link props
6
+ */
7
+ export declare type RLinkProps = LinkProps & RouterLinkProps<{}>;
8
+ /**
9
+ * Router Link
10
+ * @param props Props
11
+ * @returns Component
12
+ */
13
+ export declare function RLink(props: RLinkProps): JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { Link } from '@mui/material';
2
+ import { Link as RouterLink } from '@reach/router';
3
+ import React from 'react';
4
+ /**
5
+ * Router Link
6
+ * @param props Props
7
+ * @returns Component
8
+ */
9
+ export function RLink(props) {
10
+ return React.createElement(Link, { component: RouterLink, ...props });
11
+ }
@@ -27,13 +27,17 @@ export function CommonPage(props) {
27
27
  Object.assign(sx, {
28
28
  padding: paddings
29
29
  });
30
+ const [state] = React.useState({});
30
31
  // Fab padding
31
32
  const fabPadding = MUGlobal.increase(MUGlobal.pagePaddings, fabPaddingAdjust);
32
33
  // Labels
33
34
  const labels = Labels.CommonPage;
34
35
  // Update
35
36
  const update = onUpdateAll
36
- ? onUpdateAll
37
+ ? async (authorized) => {
38
+ await onUpdateAll(authorized);
39
+ state.loaded = true;
40
+ }
37
41
  : onUpdate
38
42
  ? (authorized) => {
39
43
  if (authorized == null || authorized)
@@ -45,6 +49,17 @@ export function CommonPage(props) {
45
49
  onRefresh();
46
50
  }
47
51
  : undefined;
52
+ React.useEffect(() => {
53
+ return () => {
54
+ state.loaded = false;
55
+ };
56
+ }, []);
57
+ React.useEffect(() => {
58
+ // onUpdateAll support to load after page mounted
59
+ if (onUpdateAll != null && state.loaded) {
60
+ onUpdateAll();
61
+ }
62
+ });
48
63
  // Return the UI
49
64
  return (React.createElement(React.Fragment, null,
50
65
  update && React.createElement(ReactAppStateDetector, { update: update }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.47",
3
+ "version": "1.3.51",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -46,15 +46,15 @@
46
46
  },
47
47
  "homepage": "https://github.com/ETSOO/AppReact#readme",
48
48
  "dependencies": {
49
- "@emotion/css": "^11.5.0",
50
- "@emotion/react": "^11.7.0",
49
+ "@emotion/css": "^11.7.1",
50
+ "@emotion/react": "^11.7.1",
51
51
  "@emotion/style": "^0.8.0",
52
52
  "@emotion/styled": "^11.6.0",
53
- "@etsoo/appscript": "^1.1.70",
53
+ "@etsoo/appscript": "^1.1.77",
54
54
  "@etsoo/notificationbase": "^1.0.94",
55
55
  "@etsoo/shared": "^1.0.76",
56
- "@mui/icons-material": "^5.2.1",
57
- "@mui/material": "^5.2.3",
56
+ "@mui/icons-material": "^5.2.4",
57
+ "@mui/material": "^5.2.4",
58
58
  "@reach/router": "^1.3.4",
59
59
  "@types/pica": "^5.1.3",
60
60
  "@types/pulltorefreshjs": "^0.1.5",
@@ -64,7 +64,7 @@
64
64
  "@types/react-dom": "^17.0.11",
65
65
  "@types/react-input-mask": "^3.0.1",
66
66
  "@types/react-window": "^1.8.5",
67
- "pica": "^9.0.0",
67
+ "pica": "^9.0.1",
68
68
  "pulltorefreshjs": "^0.1.22",
69
69
  "react": "^17.0.2",
70
70
  "react-avatar-editor": "^12.0.0",
@@ -75,21 +75,21 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@babel/cli": "^7.16.0",
78
- "@babel/core": "^7.16.0",
79
- "@babel/plugin-transform-runtime": "^7.16.4",
80
- "@babel/preset-env": "^7.16.4",
81
- "@babel/runtime-corejs3": "^7.16.3",
78
+ "@babel/core": "^7.16.5",
79
+ "@babel/plugin-transform-runtime": "^7.16.5",
80
+ "@babel/preset-env": "^7.16.5",
81
+ "@babel/runtime-corejs3": "^7.16.5",
82
82
  "@types/jest": "^27.0.3",
83
83
  "@types/react-test-renderer": "^17.0.1",
84
- "@typescript-eslint/eslint-plugin": "^5.6.0",
85
- "@typescript-eslint/parser": "^5.6.0",
84
+ "@typescript-eslint/eslint-plugin": "^5.7.0",
85
+ "@typescript-eslint/parser": "^5.7.0",
86
86
  "eslint": "^8.4.1",
87
87
  "eslint-config-airbnb-base": "^15.0.0",
88
88
  "eslint-plugin-import": "^2.25.3",
89
89
  "eslint-plugin-react": "^7.27.1",
90
- "jest": "^27.4.4",
90
+ "jest": "^27.4.5",
91
91
  "react-test-renderer": "^17.0.2",
92
92
  "ts-jest": "^27.1.1",
93
- "typescript": "^4.5.3"
93
+ "typescript": "^4.5.4"
94
94
  }
95
95
  }
package/src/index.ts CHANGED
@@ -62,6 +62,7 @@ export * from './mu/OptionGroup';
62
62
  export * from './mu/PList';
63
63
  export * from './mu/ProgressCount';
64
64
  export * from './mu/PullToRefreshUI';
65
+ export * from './mu/RLink';
65
66
  export * from './mu/ScrollerListEx';
66
67
  export * from './mu/ScrollTopFab';
67
68
  export * from './mu/SearchBar';
@@ -0,0 +1,20 @@
1
+ import { Link, LinkProps } from '@mui/material';
2
+ import {
3
+ Link as RouterLink,
4
+ LinkProps as RouterLinkProps
5
+ } from '@reach/router';
6
+ import React from 'react';
7
+
8
+ /**
9
+ * Router Link props
10
+ */
11
+ export type RLinkProps = LinkProps & RouterLinkProps<{}>;
12
+
13
+ /**
14
+ * Router Link
15
+ * @param props Props
16
+ * @returns Component
17
+ */
18
+ export function RLink(props: RLinkProps) {
19
+ return <Link component={RouterLink} {...props} />;
20
+ }
@@ -50,6 +50,8 @@ export function CommonPage(props: CommonPageProps) {
50
50
  padding: paddings
51
51
  });
52
52
 
53
+ const [state] = React.useState<{ loaded?: boolean }>({});
54
+
53
55
  // Fab padding
54
56
  const fabPadding = MUGlobal.increase(
55
57
  MUGlobal.pagePaddings,
@@ -61,7 +63,10 @@ export function CommonPage(props: CommonPageProps) {
61
63
 
62
64
  // Update
63
65
  const update = onUpdateAll
64
- ? onUpdateAll
66
+ ? async (authorized?: boolean) => {
67
+ await onUpdateAll(authorized);
68
+ state.loaded = true;
69
+ }
65
70
  : onUpdate
66
71
  ? (authorized?: boolean) => {
67
72
  if (authorized == null || authorized) onUpdate();
@@ -72,6 +77,19 @@ export function CommonPage(props: CommonPageProps) {
72
77
  }
73
78
  : undefined;
74
79
 
80
+ React.useEffect(() => {
81
+ return () => {
82
+ state.loaded = false;
83
+ };
84
+ }, []);
85
+
86
+ React.useEffect(() => {
87
+ // onUpdateAll support to load after page mounted
88
+ if (onUpdateAll != null && state.loaded) {
89
+ onUpdateAll();
90
+ }
91
+ });
92
+
75
93
  // Return the UI
76
94
  return (
77
95
  <React.Fragment>