@etsoo/react 1.5.15 → 1.5.19

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.
@@ -1,6 +1,5 @@
1
1
  import { ActionResultError, BridgeUtils, CoreApp, createClient } from '@etsoo/appscript';
2
2
  import { WindowStorage } from '@etsoo/shared';
3
- import { navigate } from '@reach/router';
4
3
  import React from 'react';
5
4
  import { NotifierMU } from '../mu/NotifierMU';
6
5
  import { ProgressCount } from '../mu/ProgressCount';
@@ -8,7 +7,7 @@ import { CultureState } from '../states/CultureState';
8
7
  import { PageActionType, PageState } from '../states/PageState';
9
8
  import { UserActionType, UserState } from '../states/UserState';
10
9
  import { Labels } from './Labels';
11
- import { Utils } from './Utils';
10
+ import { ReactUtils } from './ReactUtils';
12
11
  /**
13
12
  * Global application
14
13
  */
@@ -68,7 +67,7 @@ export class ReactApp extends CoreApp {
68
67
  this.history =
69
68
  BridgeUtils.host == null
70
69
  ? undefined
71
- : Utils.getMemoryHistory(BridgeUtils.host.getStartUrl());
70
+ : ReactUtils.getMemoryHistory(BridgeUtils.host.getStartUrl());
72
71
  this.cultureState = new CultureState(settings.currentCulture);
73
72
  this.pageState = new PageState();
74
73
  globalApp = this;
@@ -199,7 +198,8 @@ export class ReactApp extends CoreApp {
199
198
  * @param url Url
200
199
  */
201
200
  redirectTo(url) {
202
- (this.history == null ? navigate : this.history.navigate)(url);
201
+ const navigate = ReactUtils.getNavigateFn();
202
+ navigate(url);
203
203
  }
204
204
  /**
205
205
  * Set page data
@@ -1,9 +1,21 @@
1
- import { History } from '@reach/router';
1
+ import { History, HistorySource } from '@reach/router';
2
2
  import React from 'react';
3
+ declare type MemoryHistorySource = HistorySource & {
4
+ history: {
5
+ get entries(): any;
6
+ get index(): number;
7
+ go(to: number): void;
8
+ };
9
+ };
3
10
  /**
4
11
  * React utils
5
12
  */
6
- export declare namespace Utils {
13
+ export declare namespace ReactUtils {
14
+ /**
15
+ * Cretae memory source to fix go back bug
16
+ * @param initialPath Initial path
17
+ */
18
+ function createMemorySource(initialPath?: string): MemoryHistorySource;
7
19
  /**
8
20
  * Format input value
9
21
  * @param value Input value
@@ -16,6 +28,11 @@ export declare namespace Utils {
16
28
  * @returns History
17
29
  */
18
30
  function getMemoryHistory(initialPath?: string | null): History;
31
+ /**
32
+ * Get navigate function, works with memory history
33
+ * @returns NavigateFn
34
+ */
35
+ function getNavigateFn(): import("@reach/router").NavigateFn;
19
36
  /**
20
37
  * Is safe click
21
38
  * @param event Mouse event
@@ -30,3 +47,4 @@ export declare namespace Utils {
30
47
  */
31
48
  function triggerChange(input: HTMLInputElement, value: string, cancelable: boolean): void;
32
49
  }
50
+ export {};
@@ -1,12 +1,77 @@
1
- import { createHistory, createMemorySource } from '@reach/router';
1
+ import { createHistory, navigate } from '@reach/router';
2
2
  /**
3
3
  * React utils
4
4
  */
5
- export var Utils;
6
- (function (Utils) {
5
+ export var ReactUtils;
6
+ (function (ReactUtils) {
7
7
  // Memory history
8
8
  // https://github.com/reach/router/issues/225
9
9
  let memoryHistory;
10
+ /**
11
+ * Cretae memory source to fix go back bug
12
+ * @param initialPath Initial path
13
+ */
14
+ function createMemorySource(initialPath = '/') {
15
+ const searchIndex = initialPath.indexOf('?');
16
+ const pathname = searchIndex > -1
17
+ ? initialPath.substring(0, searchIndex)
18
+ : initialPath;
19
+ const initialLocation = {
20
+ pathname,
21
+ search: searchIndex > -1 ? initialPath.substring(searchIndex) : ''
22
+ };
23
+ let index = 0;
24
+ const stack = [initialLocation];
25
+ const states = [null];
26
+ return {
27
+ get location() {
28
+ return stack[index];
29
+ },
30
+ addEventListener(name, fn) { },
31
+ removeEventListener(name, fn) { },
32
+ history: {
33
+ get entries() {
34
+ return stack;
35
+ },
36
+ get index() {
37
+ return index;
38
+ },
39
+ get state() {
40
+ return states[index];
41
+ },
42
+ pushState(state, _, uri) {
43
+ const [pathname, search = ''] = uri.split('?');
44
+ index++;
45
+ // View a, index = 0
46
+ // View b, index = 1
47
+ // Go(-1), a, index = 0
48
+ // View c, index = 1, directly push is wrong
49
+ if (index < stack.length) {
50
+ stack.splice(index, stack.length - index);
51
+ states.splice(index, stack.length - index);
52
+ }
53
+ stack.push({
54
+ pathname,
55
+ search: search.length ? `?${search}` : search
56
+ });
57
+ states.push(state);
58
+ },
59
+ replaceState(state, _, uri) {
60
+ const [pathname, search = ''] = uri.split('?');
61
+ stack[index] = { pathname, search };
62
+ states[index] = state;
63
+ },
64
+ go(to) {
65
+ const newIndex = index + to;
66
+ if (newIndex < 0 || newIndex > states.length - 1) {
67
+ return;
68
+ }
69
+ index = newIndex;
70
+ }
71
+ }
72
+ };
73
+ }
74
+ ReactUtils.createMemorySource = createMemorySource;
10
75
  /**
11
76
  * Format input value
12
77
  * @param value Input value
@@ -23,7 +88,7 @@ export var Utils;
23
88
  return value;
24
89
  return String(value);
25
90
  }
26
- Utils.formatInputValue = formatInputValue;
91
+ ReactUtils.formatInputValue = formatInputValue;
27
92
  /**
28
93
  * Get memory history
29
94
  * @param initialPath Initial path
@@ -35,7 +100,17 @@ export var Utils;
35
100
  }
36
101
  return memoryHistory;
37
102
  }
38
- Utils.getMemoryHistory = getMemoryHistory;
103
+ ReactUtils.getMemoryHistory = getMemoryHistory;
104
+ /**
105
+ * Get navigate function, works with memory history
106
+ * @returns NavigateFn
107
+ */
108
+ function getNavigateFn() {
109
+ if (memoryHistory == null)
110
+ return navigate;
111
+ return memoryHistory.navigate;
112
+ }
113
+ ReactUtils.getNavigateFn = getNavigateFn;
39
114
  /**
40
115
  * Is safe click
41
116
  * @param event Mouse event
@@ -61,7 +136,7 @@ export var Utils;
61
136
  }
62
137
  return true;
63
138
  }
64
- Utils.isSafeClick = isSafeClick;
139
+ ReactUtils.isSafeClick = isSafeClick;
65
140
  /**
66
141
  * Trigger input change event
67
142
  * @param input Form input
@@ -99,5 +174,5 @@ export var Utils;
99
174
  input.dispatchEvent(inputEvent);
100
175
  }
101
176
  }
102
- Utils.triggerChange = triggerChange;
103
- })(Utils || (Utils = {}));
177
+ ReactUtils.triggerChange = triggerChange;
178
+ })(ReactUtils || (ReactUtils = {}));
package/lib/index.d.ts CHANGED
@@ -6,9 +6,9 @@ export * from './app/IServiceUser';
6
6
  export * from './app/ISmartERPUser';
7
7
  export * from './app/Labels';
8
8
  export * from './app/ReactApp';
9
+ export * from './app/ReactUtils';
9
10
  export * from './app/RefreshTokenRQ';
10
11
  export * from './app/ServiceApp';
11
- export * from './app/Utils';
12
12
  export * from './components/GridColumn';
13
13
  export * from './components/GridLoader';
14
14
  export * from './components/ListItemReact';
package/lib/index.js CHANGED
@@ -7,9 +7,9 @@ export * from './app/IServiceUser';
7
7
  export * from './app/ISmartERPUser';
8
8
  export * from './app/Labels';
9
9
  export * from './app/ReactApp';
10
+ export * from './app/ReactUtils';
10
11
  export * from './app/RefreshTokenRQ';
11
12
  export * from './app/ServiceApp';
12
- export * from './app/Utils';
13
13
  // components
14
14
  export * from './components/GridColumn';
15
15
  export * from './components/GridLoader';
@@ -1,7 +1,7 @@
1
1
  import { IconButton, useTheme } from '@mui/material';
2
2
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
3
3
  import React from 'react';
4
- import { useNavigate } from '@reach/router';
4
+ import { ReactUtils } from '../app/ReactUtils';
5
5
  /**
6
6
  * BackButton
7
7
  * @param props Props
@@ -10,8 +10,6 @@ import { useNavigate } from '@reach/router';
10
10
  export function BackButton(props) {
11
11
  // Destruct
12
12
  const { color = 'primary', size = 'small', onClick, ...rest } = props;
13
- // Navigate
14
- const navigate = useNavigate();
15
13
  // Theme
16
14
  const theme = useTheme();
17
15
  // Color
@@ -19,10 +17,12 @@ export function BackButton(props) {
19
17
  ? theme.palette[color]
20
18
  : theme.palette.primary;
21
19
  // Click handler
22
- const onClickLocal = (event) => {
20
+ const onClickLocal = async (event) => {
23
21
  if (onClick)
24
22
  onClick(event);
25
- navigate(-1);
23
+ // Navigate
24
+ const navigate = ReactUtils.getNavigateFn();
25
+ await navigate(-1);
26
26
  };
27
27
  return (React.createElement(IconButton, { "aria-label": "Back", color: color, size: size, onClick: onClickLocal, sx: {
28
28
  backgroundColor: pColor.contrastText,
@@ -1,6 +1,6 @@
1
1
  import { Button } from '@mui/material';
2
- import { useNavigate } from '@reach/router';
3
2
  import React from 'react';
3
+ import { ReactUtils } from '../app/ReactUtils';
4
4
  /**
5
5
  * ButtonLink
6
6
  * @param props Props
@@ -10,7 +10,7 @@ export function ButtonLink(props) {
10
10
  // Destruct
11
11
  const { href, ...rest } = props;
12
12
  // Navigate
13
- const navigate = useNavigate();
13
+ const navigate = ReactUtils.getNavigateFn();
14
14
  const onClick = href.includes('://')
15
15
  ? () => window.open(href, '_blank')
16
16
  : () => navigate(href);
@@ -1,10 +1,10 @@
1
1
  import { Keyboard } from '@etsoo/shared';
2
2
  import { Autocomplete } from '@mui/material';
3
3
  import React from 'react';
4
- import { Utils } from '../app/Utils';
5
4
  import { Utils as SharedUtils } from '@etsoo/shared';
6
5
  import { InputField } from './InputField';
7
6
  import { SearchField } from './SearchField';
7
+ import { ReactUtils } from '../app/ReactUtils';
8
8
  /**
9
9
  * ComboBox
10
10
  * @param props Props
@@ -71,7 +71,7 @@ export function ComboBox(props) {
71
71
  const newValue = value != null ? `${Reflect.get(value, idField)}` : '';
72
72
  if (newValue !== input.value) {
73
73
  // Different value, trigger change event
74
- Utils.triggerChange(input, newValue, false);
74
+ ReactUtils.triggerChange(input, newValue, false);
75
75
  }
76
76
  }
77
77
  };
@@ -1,6 +1,6 @@
1
1
  import { IconButton } from '@mui/material';
2
- import { useNavigate } from '@reach/router';
3
2
  import React from 'react';
3
+ import { ReactUtils } from '../app/ReactUtils';
4
4
  /**
5
5
  * IconButtonLink
6
6
  * @param props Props
@@ -10,7 +10,7 @@ export function IconButtonLink(props) {
10
10
  // Destruct
11
11
  const { href, ...rest } = props;
12
12
  // Navigate
13
- const navigate = useNavigate();
13
+ const navigate = ReactUtils.getNavigateFn();
14
14
  // Layout
15
15
  return React.createElement(IconButton, { ...rest, onClick: () => navigate(href) });
16
16
  }
@@ -1,7 +1,7 @@
1
1
  import { Box, Stack } from '@mui/material';
2
2
  import React from 'react';
3
3
  import { Labels } from '../app/Labels';
4
- import { Utils } from '../app/Utils';
4
+ import { ReactUtils } from '../app/ReactUtils';
5
5
  import { GridDataGet } from '../components/GridLoader';
6
6
  import useCombinedRefs from '../uses/useCombinedRefs';
7
7
  import { useDimensions } from '../uses/useDimensions';
@@ -126,7 +126,7 @@ export function ResponsibleContainer(props) {
126
126
  return [
127
127
  React.createElement(Box, { className: "ListBox", sx: { height: heightLocal } },
128
128
  React.createElement(ScrollerListEx, { autoLoad: !hasFields, height: heightLocal, loadData: localLoadData, mRef: mRefs, onClick: (event, data) => quickAction &&
129
- Utils.isSafeClick(event) &&
129
+ ReactUtils.isSafeClick(event) &&
130
130
  quickAction(data), oRef: (element) => {
131
131
  if (element != null && elementReady)
132
132
  elementReady(element, false);
@@ -2,9 +2,9 @@ import { Button, Drawer, IconButton, Stack, useTheme } from '@mui/material';
2
2
  import React from 'react';
3
3
  import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
4
4
  import { useDimensions } from '../uses/useDimensions';
5
- import { Utils as AppUtils } from '../app/Utils';
6
5
  import { DomUtils } from '@etsoo/shared';
7
6
  import { Labels } from '../app/Labels';
7
+ import { ReactUtils } from '../app/ReactUtils';
8
8
  // Cached width attribute name
9
9
  const cachedWidthName = 'data-cached-width';
10
10
  // Reset form
@@ -20,7 +20,7 @@ const resetForm = (form) => {
20
20
  continue;
21
21
  // Ignore readOnly without data-reset=true inputs
22
22
  if (!input.readOnly || input.dataset.reset === 'true') {
23
- AppUtils.triggerChange(input, '', true);
23
+ ReactUtils.triggerChange(input, '', true);
24
24
  }
25
25
  continue;
26
26
  }
@@ -1,9 +1,9 @@
1
- import { Utils as AppUtils } from '../app/Utils';
2
1
  import { Checkbox, FormControl, InputLabel, ListItemText, MenuItem, OutlinedInput, Select } from '@mui/material';
3
2
  import React from 'react';
4
3
  import { MUGlobal } from './MUGlobal';
5
4
  import { ListItemRightIcon } from './ListItemRightIcon';
6
5
  import { Utils } from '@etsoo/shared';
6
+ import { ReactUtils } from '../app/ReactUtils';
7
7
  /**
8
8
  * Extended select component
9
9
  * @param props Props
@@ -65,7 +65,7 @@ export function SelectEx(props) {
65
65
  const input = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('input');
66
66
  if (input) {
67
67
  // Different value, trigger change event
68
- AppUtils.triggerChange(input, id, false);
68
+ ReactUtils.triggerChange(input, id, false);
69
69
  }
70
70
  }
71
71
  };
package/lib/mu/Tiplist.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
2
  import { Autocomplete } from '@mui/material';
3
3
  import React from 'react';
4
- import { Utils } from '../app/Utils';
4
+ import { ReactUtils } from '../app/ReactUtils';
5
5
  import { InputField } from './InputField';
6
6
  import { SearchField } from './SearchField';
7
7
  /**
@@ -75,7 +75,7 @@ export function Tiplist(props) {
75
75
  const input = inputRef.current;
76
76
  if (input && input.value !== '') {
77
77
  // Different value, trigger change event
78
- Utils.triggerChange(input, '', false);
78
+ ReactUtils.triggerChange(input, '', false);
79
79
  }
80
80
  if (states.options.length > 0) {
81
81
  // Reset options
@@ -106,7 +106,7 @@ export function Tiplist(props) {
106
106
  const newValue = (_a = DataTypes.getStringValue(value, idField)) !== null && _a !== void 0 ? _a : '';
107
107
  if (newValue !== input.value) {
108
108
  // Different value, trigger change event
109
- Utils.triggerChange(input, newValue, false);
109
+ ReactUtils.triggerChange(input, newValue, false);
110
110
  }
111
111
  }
112
112
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.15",
3
+ "version": "1.5.19",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,7 @@ import {
14
14
  NotificationReturn
15
15
  } from '@etsoo/notificationbase';
16
16
  import { DataTypes, WindowStorage } from '@etsoo/shared';
17
- import { History, navigate } from '@reach/router';
17
+ import { History } from '@reach/router';
18
18
  import React from 'react';
19
19
  import { NotifierMU } from '../mu/NotifierMU';
20
20
  import { ProgressCount } from '../mu/ProgressCount';
@@ -35,7 +35,7 @@ import {
35
35
  } from '../states/UserState';
36
36
  import { InputDialogProps } from './InputDialogProps';
37
37
  import { Labels } from './Labels';
38
- import { Utils } from './Utils';
38
+ import { ReactUtils } from './ReactUtils';
39
39
 
40
40
  /**
41
41
  * Global application
@@ -223,7 +223,7 @@ export class ReactApp<
223
223
  this.history =
224
224
  BridgeUtils.host == null
225
225
  ? undefined
226
- : Utils.getMemoryHistory(BridgeUtils.host.getStartUrl());
226
+ : ReactUtils.getMemoryHistory(BridgeUtils.host.getStartUrl());
227
227
 
228
228
  this.cultureState = new CultureState(settings.currentCulture);
229
229
  this.pageState = new PageState<P>();
@@ -370,7 +370,8 @@ export class ReactApp<
370
370
  * @param url Url
371
371
  */
372
372
  override redirectTo(url: string) {
373
- (this.history == null ? navigate : this.history.navigate)(url);
373
+ const navigate = ReactUtils.getNavigateFn();
374
+ navigate(url);
374
375
  }
375
376
 
376
377
  /**
@@ -1,14 +1,98 @@
1
- import { createHistory, createMemorySource, History } from '@reach/router';
1
+ import { createHistory, History, HistorySource, navigate } from '@reach/router';
2
2
  import React from 'react';
3
3
 
4
+ type MemoryHistorySource = HistorySource & {
5
+ history: {
6
+ get entries(): any;
7
+ get index(): number;
8
+ go(to: number): void;
9
+ };
10
+ };
11
+
4
12
  /**
5
13
  * React utils
6
14
  */
7
- export namespace Utils {
15
+ export namespace ReactUtils {
8
16
  // Memory history
9
17
  // https://github.com/reach/router/issues/225
10
18
  let memoryHistory: History | null;
11
19
 
20
+ /**
21
+ * Cretae memory source to fix go back bug
22
+ * @param initialPath Initial path
23
+ */
24
+ export function createMemorySource(
25
+ initialPath: string = '/'
26
+ ): MemoryHistorySource {
27
+ const searchIndex = initialPath.indexOf('?');
28
+ const pathname =
29
+ searchIndex > -1
30
+ ? initialPath.substring(0, searchIndex)
31
+ : initialPath;
32
+
33
+ const initialLocation: any = {
34
+ pathname,
35
+ search: searchIndex > -1 ? initialPath.substring(searchIndex) : ''
36
+ };
37
+
38
+ let index = 0;
39
+
40
+ const stack = [initialLocation];
41
+ const states = [null];
42
+
43
+ return {
44
+ get location() {
45
+ return stack[index];
46
+ },
47
+ addEventListener(name, fn) {},
48
+ removeEventListener(name, fn) {},
49
+ history: {
50
+ get entries() {
51
+ return stack;
52
+ },
53
+ get index() {
54
+ return index;
55
+ },
56
+ get state() {
57
+ return states[index];
58
+ },
59
+ pushState(state, _, uri) {
60
+ const [pathname, search = ''] = uri.split('?');
61
+ index++;
62
+
63
+ // View a, index = 0
64
+ // View b, index = 1
65
+ // Go(-1), a, index = 0
66
+ // View c, index = 1, directly push is wrong
67
+ if (index < stack.length) {
68
+ stack.splice(index, stack.length - index);
69
+ states.splice(index, stack.length - index);
70
+ }
71
+
72
+ stack.push({
73
+ pathname,
74
+ search: search.length ? `?${search}` : search
75
+ });
76
+ states.push(state);
77
+ },
78
+ replaceState(state, _, uri) {
79
+ const [pathname, search = ''] = uri.split('?');
80
+ stack[index] = { pathname, search };
81
+ states[index] = state;
82
+ },
83
+ go(to: number) {
84
+ const newIndex = index + to;
85
+
86
+ if (newIndex < 0 || newIndex > states.length - 1) {
87
+ return;
88
+ }
89
+
90
+ index = newIndex;
91
+ }
92
+ }
93
+ };
94
+ }
95
+
12
96
  /**
13
97
  * Format input value
14
98
  * @param value Input value
@@ -40,6 +124,15 @@ export namespace Utils {
40
124
  return memoryHistory;
41
125
  }
42
126
 
127
+ /**
128
+ * Get navigate function, works with memory history
129
+ * @returns NavigateFn
130
+ */
131
+ export function getNavigateFn() {
132
+ if (memoryHistory == null) return navigate;
133
+ return memoryHistory.navigate;
134
+ }
135
+
43
136
  /**
44
137
  * Is safe click
45
138
  * @param event Mouse event
package/src/index.ts CHANGED
@@ -7,9 +7,9 @@ export * from './app/IServiceUser';
7
7
  export * from './app/ISmartERPUser';
8
8
  export * from './app/Labels';
9
9
  export * from './app/ReactApp';
10
+ export * from './app/ReactUtils';
10
11
  export * from './app/RefreshTokenRQ';
11
12
  export * from './app/ServiceApp';
12
- export * from './app/Utils';
13
13
 
14
14
  // components
15
15
  export * from './components/GridColumn';
@@ -1,7 +1,7 @@
1
1
  import { IconButton, IconButtonProps, useTheme } from '@mui/material';
2
2
  import ArrowBackIcon from '@mui/icons-material/ArrowBack';
3
3
  import React from 'react';
4
- import { useNavigate } from '@reach/router';
4
+ import { ReactUtils } from '../app/ReactUtils';
5
5
 
6
6
  /**
7
7
  * BackButton props
@@ -17,9 +17,6 @@ export function BackButton(props: BackButtonProps) {
17
17
  // Destruct
18
18
  const { color = 'primary', size = 'small', onClick, ...rest } = props;
19
19
 
20
- // Navigate
21
- const navigate = useNavigate();
22
-
23
20
  // Theme
24
21
  const theme = useTheme();
25
22
 
@@ -30,9 +27,12 @@ export function BackButton(props: BackButtonProps) {
30
27
  : theme.palette.primary;
31
28
 
32
29
  // Click handler
33
- const onClickLocal = (event: React.MouseEvent<HTMLButtonElement>) => {
30
+ const onClickLocal = async (event: React.MouseEvent<HTMLButtonElement>) => {
34
31
  if (onClick) onClick(event);
35
- navigate(-1);
32
+
33
+ // Navigate
34
+ const navigate = ReactUtils.getNavigateFn();
35
+ await navigate(-1);
36
36
  };
37
37
 
38
38
  return (
@@ -1,6 +1,6 @@
1
1
  import { Button, ButtonProps } from '@mui/material';
2
- import { useNavigate } from '@reach/router';
3
2
  import React from 'react';
3
+ import { ReactUtils } from '../app/ReactUtils';
4
4
 
5
5
  /**
6
6
  * ButtonLink props
@@ -22,7 +22,8 @@ export function ButtonLink(props: ButtonLinkProps) {
22
22
  const { href, ...rest } = props;
23
23
 
24
24
  // Navigate
25
- const navigate = useNavigate();
25
+ const navigate = ReactUtils.getNavigateFn();
26
+
26
27
  const onClick = href.includes('://')
27
28
  ? () => window.open(href, '_blank')
28
29
  : () => navigate(href);
@@ -2,11 +2,11 @@ import { IdLabelDto } from '@etsoo/appscript';
2
2
  import { Keyboard } from '@etsoo/shared';
3
3
  import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
4
4
  import React from 'react';
5
- import { Utils } from '../app/Utils';
6
5
  import { Utils as SharedUtils } from '@etsoo/shared';
7
6
  import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
8
7
  import { InputField } from './InputField';
9
8
  import { SearchField } from './SearchField';
9
+ import { ReactUtils } from '../app/ReactUtils';
10
10
 
11
11
  /**
12
12
  * ComboBox props
@@ -152,7 +152,7 @@ export function ComboBox<T extends {} = IdLabelDto>(props: ComboBoxProps<T>) {
152
152
 
153
153
  if (newValue !== input.value) {
154
154
  // Different value, trigger change event
155
- Utils.triggerChange(input, newValue, false);
155
+ ReactUtils.triggerChange(input, newValue, false);
156
156
  }
157
157
  }
158
158
  };
@@ -1,6 +1,6 @@
1
1
  import { IconButton, IconButtonProps } from '@mui/material';
2
- import { useNavigate } from '@reach/router';
3
2
  import React from 'react';
3
+ import { ReactUtils } from '../app/ReactUtils';
4
4
 
5
5
  /**
6
6
  * IconButtonLink props
@@ -22,7 +22,7 @@ export function IconButtonLink(props: IconButtonLinkProps) {
22
22
  const { href, ...rest } = props;
23
23
 
24
24
  // Navigate
25
- const navigate = useNavigate();
25
+ const navigate = ReactUtils.getNavigateFn();
26
26
 
27
27
  // Layout
28
28
  return <IconButton {...rest} onClick={() => navigate(href)} />;
@@ -3,7 +3,7 @@ import { Box, Stack, SxProps, Theme } from '@mui/material';
3
3
  import React from 'react';
4
4
  import { ListChildComponentProps } from 'react-window';
5
5
  import { Labels } from '../app/Labels';
6
- import { Utils } from '../app/Utils';
6
+ import { ReactUtils } from '../app/ReactUtils';
7
7
  import { GridColumn } from '../components/GridColumn';
8
8
  import {
9
9
  GridDataGet,
@@ -326,7 +326,7 @@ export function ResponsibleContainer<
326
326
  mRef={mRefs}
327
327
  onClick={(event, data) =>
328
328
  quickAction &&
329
- Utils.isSafeClick(event) &&
329
+ ReactUtils.isSafeClick(event) &&
330
330
  quickAction(data)
331
331
  }
332
332
  oRef={(element) => {
@@ -2,9 +2,9 @@ import { Button, Drawer, IconButton, Stack, useTheme } from '@mui/material';
2
2
  import React from 'react';
3
3
  import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
4
4
  import { useDimensions } from '../uses/useDimensions';
5
- import { Utils as AppUtils } from '../app/Utils';
6
5
  import { DomUtils } from '@etsoo/shared';
7
6
  import { Labels } from '../app/Labels';
7
+ import { ReactUtils } from '../app/ReactUtils';
8
8
 
9
9
  /**
10
10
  * Search bar props
@@ -48,7 +48,7 @@ const resetForm = (form: HTMLFormElement) => {
48
48
 
49
49
  // Ignore readOnly without data-reset=true inputs
50
50
  if (!input.readOnly || input.dataset.reset === 'true') {
51
- AppUtils.triggerChange(input, '', true);
51
+ ReactUtils.triggerChange(input, '', true);
52
52
  }
53
53
  continue;
54
54
  }
@@ -1,4 +1,3 @@
1
- import { Utils as AppUtils } from '../app/Utils';
2
1
  import {
3
2
  Checkbox,
4
3
  FormControl,
@@ -15,6 +14,7 @@ import { MUGlobal } from './MUGlobal';
15
14
  import { IdLabelDto } from '@etsoo/appscript';
16
15
  import { ListItemRightIcon } from './ListItemRightIcon';
17
16
  import { Utils } from '@etsoo/shared';
17
+ import { ReactUtils } from '../app/ReactUtils';
18
18
 
19
19
  /**
20
20
  * Extended select component props
@@ -145,7 +145,7 @@ export function SelectEx<T extends {} = IdLabelDto>(props: SelectExProps<T>) {
145
145
  const input = divRef.current?.querySelector('input');
146
146
  if (input) {
147
147
  // Different value, trigger change event
148
- AppUtils.triggerChange(input, id as string, false);
148
+ ReactUtils.triggerChange(input, id as string, false);
149
149
  }
150
150
  }
151
151
  };
@@ -2,7 +2,7 @@ import { IdLabelDto } from '@etsoo/appscript';
2
2
  import { DataTypes } from '@etsoo/shared';
3
3
  import { Autocomplete, AutocompleteRenderInputParams } from '@mui/material';
4
4
  import React from 'react';
5
- import { Utils } from '../app/Utils';
5
+ import { ReactUtils } from '../app/ReactUtils';
6
6
  import { AutocompleteExtendedProps } from './AutocompleteExtendedProps';
7
7
  import { InputField } from './InputField';
8
8
  import { SearchField } from './SearchField';
@@ -152,7 +152,7 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
152
152
 
153
153
  if (input && input.value !== '') {
154
154
  // Different value, trigger change event
155
- Utils.triggerChange(input, '', false);
155
+ ReactUtils.triggerChange(input, '', false);
156
156
  }
157
157
 
158
158
  if (states.options.length > 0) {
@@ -186,7 +186,7 @@ export function Tiplist<T extends {} = IdLabelDto>(props: TiplistProps<T>) {
186
186
  const newValue = DataTypes.getStringValue(value, idField) ?? '';
187
187
  if (newValue !== input.value) {
188
188
  // Different value, trigger change event
189
- Utils.triggerChange(input, newValue, false);
189
+ ReactUtils.triggerChange(input, newValue, false);
190
190
  }
191
191
  }
192
192
  };