@etsoo/materialui 1.0.17 → 1.0.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.
package/lib/MUGlobal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NumberUtils } from '@etsoo/shared';
2
- import { RLink } from './RLink';
2
+ import { Link } from 'react-router-dom';
3
3
  /**
4
4
  * MUGlobal for global configurations
5
5
  */
@@ -24,9 +24,9 @@ export class MUGlobal {
24
24
  selected = path.startsWith(href.slice(0, -3));
25
25
  }
26
26
  return {
27
- component: RLink,
27
+ component: Link,
28
28
  selected,
29
- href,
29
+ to: href,
30
30
  sx: {
31
31
  ...(selected && {
32
32
  '.MuiListItemIcon-root': {
@@ -3,7 +3,7 @@ import { NotificationRenderProps, NotificationReturn } from '@etsoo/notification
3
3
  import { DataTypes } from '@etsoo/shared';
4
4
  import React from 'react';
5
5
  import { CultureAction, CultureState, INotificationReact, InputDialogProps, IPageData, IStateProps, NotificationReactCallProps, PageAction, PageState, UserAction, UserState } from '@etsoo/react';
6
- import { History } from '@remix-run/router';
6
+ import { NavigateFunction, NavigateOptions } from 'react-router-dom';
7
7
  /**
8
8
  * Global application
9
9
  */
@@ -28,10 +28,6 @@ export interface IReactAppBase {
28
28
  * User state
29
29
  */
30
30
  readonly userState: UserState<any>;
31
- /**
32
- * Router history
33
- */
34
- readonly history: History;
35
31
  /**
36
32
  * Set page data
37
33
  * @param data Page data
@@ -77,10 +73,6 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
77
73
  * Culture state
78
74
  */
79
75
  readonly cultureState: CultureState;
80
- /**
81
- * Router history
82
- */
83
- readonly history: History;
84
76
  /**
85
77
  * Page state
86
78
  */
@@ -97,6 +89,10 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
97
89
  * Is screen size up 'md'
98
90
  */
99
91
  mdUp?: boolean;
92
+ /**
93
+ * Navigate function
94
+ */
95
+ navigateFunction?: NavigateFunction;
100
96
  /**
101
97
  * Page state dispatch
102
98
  */
@@ -150,11 +146,6 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
150
146
  * @param callback Callback
151
147
  */
152
148
  freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
153
- /**
154
- * Redirect to the Url
155
- * @param url Url
156
- */
157
- redirectTo(url: string): void;
158
149
  /**
159
150
  * Set page data
160
151
  * @param data Page data
@@ -165,6 +156,12 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
165
156
  * @param title Page title
166
157
  */
167
158
  setPageTitle(title: string): void;
159
+ /**
160
+ * Navigate to Url or delta
161
+ * @param url Url or delta
162
+ * @param options Options
163
+ */
164
+ navigate<T extends number | string | URL>(to: T, options?: T extends number ? never : NavigateOptions): void;
168
165
  /**
169
166
  * Set page title and data
170
167
  * @param key Page title resource key
@@ -6,7 +6,6 @@ import { NotifierMU } from '../NotifierMU';
6
6
  import { ProgressCount } from '../ProgressCount';
7
7
  import { Labels } from './Labels';
8
8
  import { CultureState, PageActionType, PageState, UserActionType, UserState } from '@etsoo/react';
9
- import { createBrowserHistory, createMemoryHistory } from '@remix-run/router';
10
9
  /**
11
10
  * Global application
12
11
  */
@@ -64,17 +63,10 @@ export class ReactApp extends CoreApp {
64
63
  */
65
64
  this.userState = new UserState();
66
65
  if (BridgeUtils.host) {
67
- const startUrl = BridgeUtils.host.getStartUrl();
68
- this.history = createMemoryHistory({
69
- initialEntries: startUrl == null ? undefined : [startUrl]
70
- });
71
66
  BridgeUtils.host.onUpdate((app, version) => {
72
67
  this.notifier.message(NotificationMessageType.Success, this.get('updateTip') + `(${[app, version].join(', ')})`, this.get('updateReady'));
73
68
  });
74
69
  }
75
- else {
76
- this.history = createBrowserHistory();
77
- }
78
70
  this.cultureState = new CultureState(settings.currentCulture);
79
71
  this.pageState = new PageState();
80
72
  globalApp = this;
@@ -201,13 +193,6 @@ export class ReactApp extends CoreApp {
201
193
  inputs: progress
202
194
  });
203
195
  }
204
- /**
205
- * Redirect to the Url
206
- * @param url Url
207
- */
208
- redirectTo(url) {
209
- this.history.push(url);
210
- }
211
196
  /**
212
197
  * Set page data
213
198
  * @param data Page data
@@ -236,6 +221,19 @@ export class ReactApp extends CoreApp {
236
221
  });
237
222
  }
238
223
  }
224
+ /**
225
+ * Navigate to Url or delta
226
+ * @param url Url or delta
227
+ * @param options Options
228
+ */
229
+ navigate(to, options) {
230
+ if (this.navigateFunction == null)
231
+ super.navigate(to, options);
232
+ else if (typeof to === 'number')
233
+ this.navigateFunction(to);
234
+ else
235
+ this.navigateFunction(to, options);
236
+ }
239
237
  /**
240
238
  * Set page title and data
241
239
  * @param key Page title resource key
package/lib/index.d.ts CHANGED
@@ -55,7 +55,6 @@ export * from './PList';
55
55
  export * from './ProgressCount';
56
56
  export * from './PullToRefreshUI';
57
57
  export * from './ResponsibleContainer';
58
- export * from './RLink';
59
58
  export * from './ScrollerListEx';
60
59
  export * from './ScrollTopFab';
61
60
  export * from './SearchBar';
package/lib/index.js CHANGED
@@ -55,7 +55,6 @@ export * from './PList';
55
55
  export * from './ProgressCount';
56
56
  export * from './PullToRefreshUI';
57
57
  export * from './ResponsibleContainer';
58
- export * from './RLink';
59
58
  export * from './ScrollerListEx';
60
59
  export * from './ScrollTopFab';
61
60
  export * from './SearchBar';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -57,7 +57,6 @@
57
57
  "@etsoo/shared": "^1.1.57",
58
58
  "@mui/icons-material": "^5.10.3",
59
59
  "@mui/material": "^5.10.5",
60
- "@remix-run/router": "^1.0.0",
61
60
  "@types/pica": "^9.0.1",
62
61
  "@types/pulltorefreshjs": "^0.1.5",
63
62
  "@types/react": "^18.0.20",
package/src/MUGlobal.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NumberUtils } from '@etsoo/shared';
2
2
  import { Breakpoint, ListItemButtonProps, Theme } from '@mui/material';
3
- import { RLink } from './RLink';
3
+ import { Link } from 'react-router-dom';
4
4
 
5
5
  /**
6
6
  * Mouse event handler with data
@@ -74,9 +74,9 @@ export class MUGlobal {
74
74
  }
75
75
 
76
76
  return {
77
- component: RLink,
77
+ component: Link,
78
78
  selected,
79
- href,
79
+ to: href,
80
80
  sx: {
81
81
  ...(selected && {
82
82
  '.MuiListItemIcon-root': {
@@ -34,11 +34,7 @@ import {
34
34
  UserCalls,
35
35
  UserState
36
36
  } from '@etsoo/react';
37
- import {
38
- History,
39
- createBrowserHistory,
40
- createMemoryHistory
41
- } from '@remix-run/router';
37
+ import { NavigateFunction, NavigateOptions } from 'react-router-dom';
42
38
 
43
39
  /**
44
40
  * Global application
@@ -96,11 +92,6 @@ export interface IReactAppBase {
96
92
  */
97
93
  readonly userState: UserState<any>;
98
94
 
99
- /**
100
- * Router history
101
- */
102
- readonly history: History;
103
-
104
95
  /**
105
96
  * Set page data
106
97
  * @param data Page data
@@ -181,11 +172,6 @@ export class ReactApp<
181
172
  */
182
173
  readonly cultureState: CultureState;
183
174
 
184
- /**
185
- * Router history
186
- */
187
- readonly history: History;
188
-
189
175
  /**
190
176
  * Page state
191
177
  */
@@ -206,6 +192,11 @@ export class ReactApp<
206
192
  */
207
193
  mdUp?: boolean;
208
194
 
195
+ /**
196
+ * Navigate function
197
+ */
198
+ navigateFunction?: NavigateFunction;
199
+
209
200
  /**
210
201
  * Page state dispatch
211
202
  */
@@ -231,11 +222,6 @@ export class ReactApp<
231
222
  );
232
223
 
233
224
  if (BridgeUtils.host) {
234
- const startUrl = BridgeUtils.host.getStartUrl();
235
- this.history = createMemoryHistory({
236
- initialEntries: startUrl == null ? undefined : [startUrl]
237
- });
238
-
239
225
  BridgeUtils.host.onUpdate((app, version) => {
240
226
  this.notifier.message(
241
227
  NotificationMessageType.Success,
@@ -243,8 +229,6 @@ export class ReactApp<
243
229
  this.get('updateReady')
244
230
  );
245
231
  });
246
- } else {
247
- this.history = createBrowserHistory();
248
232
  }
249
233
 
250
234
  this.cultureState = new CultureState(settings.currentCulture);
@@ -388,14 +372,6 @@ export class ReactApp<
388
372
  );
389
373
  }
390
374
 
391
- /**
392
- * Redirect to the Url
393
- * @param url Url
394
- */
395
- override redirectTo(url: string) {
396
- this.history.push(url);
397
- }
398
-
399
375
  /**
400
376
  * Set page data
401
377
  * @param data Page data
@@ -427,6 +403,20 @@ export class ReactApp<
427
403
  }
428
404
  }
429
405
 
406
+ /**
407
+ * Navigate to Url or delta
408
+ * @param url Url or delta
409
+ * @param options Options
410
+ */
411
+ override navigate<T extends number | string | URL>(
412
+ to: T,
413
+ options?: T extends number ? never : NavigateOptions
414
+ ) {
415
+ if (this.navigateFunction == null) super.navigate(to, options);
416
+ else if (typeof to === 'number') this.navigateFunction(to);
417
+ else this.navigateFunction(to, options);
418
+ }
419
+
430
420
  /**
431
421
  * Set page title and data
432
422
  * @param key Page title resource key
package/src/index.ts CHANGED
@@ -58,7 +58,6 @@ export * from './PList';
58
58
  export * from './ProgressCount';
59
59
  export * from './PullToRefreshUI';
60
60
  export * from './ResponsibleContainer';
61
- export * from './RLink';
62
61
  export * from './ScrollerListEx';
63
62
  export * from './ScrollTopFab';
64
63
  export * from './SearchBar';
package/lib/RLink.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { LinkProps } from '@mui/material';
2
- import React from 'react';
3
- /**
4
- * Router Link properties
5
- */
6
- export declare type RLinkProps = LinkProps & {
7
- delay?: number;
8
- };
9
- /**
10
- * Router Link
11
- * @param props Props
12
- * @returns Component
13
- */
14
- export declare const RLink: React.ForwardRefExoticComponent<Pick<RLinkProps, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "variant" | "p" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "position" | "type" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint" | "underline" | "media" | "target" | "href" | "download" | "hrefLang" | "ping" | "rel" | "referrerPolicy" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "TypographyClasses" | "delay"> & React.RefAttributes<HTMLAnchorElement>>;
package/lib/RLink.js DELETED
@@ -1,37 +0,0 @@
1
- import { useDelayedExecutor } from '@etsoo/react';
2
- import { Link } from '@mui/material';
3
- import React from 'react';
4
- import { globalApp } from './app/ReactApp';
5
- /**
6
- * Router Link
7
- * @param props Props
8
- * @returns Component
9
- */
10
- export const RLink = React.forwardRef((props, ref) => {
11
- // Destruct
12
- const { delay = 0, href, target, onClick, ...rest } = props;
13
- const delayed = useDelayedExecutor((href) => {
14
- // Router push
15
- globalApp.history.push(href);
16
- }, delay);
17
- // Click handler
18
- const onClickLocl = (event) => {
19
- if (onClick)
20
- onClick(event);
21
- if (!event.isDefaultPrevented() &&
22
- href &&
23
- (!target || target === '_self') && // Let browser handle "target=_blank" etc
24
- globalApp) {
25
- // Prevent href action
26
- event.preventDefault();
27
- // Delayed excution
28
- delayed.call(undefined, href);
29
- }
30
- };
31
- // Clear when exit
32
- React.useEffect(() => {
33
- return () => delayed.clear();
34
- }, [delayed]);
35
- // Component
36
- return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
37
- });
package/src/RLink.tsx DELETED
@@ -1,64 +0,0 @@
1
- import { useDelayedExecutor } from '@etsoo/react';
2
- import { Link, LinkProps } from '@mui/material';
3
- import React from 'react';
4
- import { globalApp } from './app/ReactApp';
5
-
6
- /**
7
- * Router Link properties
8
- */
9
- export type RLinkProps = LinkProps & {
10
- delay?: number;
11
- };
12
-
13
- /**
14
- * Router Link
15
- * @param props Props
16
- * @returns Component
17
- */
18
- export const RLink = React.forwardRef<HTMLAnchorElement, RLinkProps>(
19
- (props, ref) => {
20
- // Destruct
21
- const { delay = 0, href, target, onClick, ...rest } = props;
22
-
23
- const delayed = useDelayedExecutor((href: string) => {
24
- // Router push
25
- globalApp.history.push(href);
26
- }, delay);
27
-
28
- // Click handler
29
- const onClickLocl = (
30
- event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
31
- ) => {
32
- if (onClick) onClick(event);
33
-
34
- if (
35
- !event.isDefaultPrevented() &&
36
- href &&
37
- (!target || target === '_self') && // Let browser handle "target=_blank" etc
38
- globalApp
39
- ) {
40
- // Prevent href action
41
- event.preventDefault();
42
-
43
- // Delayed excution
44
- delayed.call(undefined, href);
45
- }
46
- };
47
-
48
- // Clear when exit
49
- React.useEffect(() => {
50
- return () => delayed.clear();
51
- }, [delayed]);
52
-
53
- // Component
54
- return (
55
- <Link
56
- {...rest}
57
- onClick={onClickLocl}
58
- href={href}
59
- target={target}
60
- ref={ref}
61
- />
62
- );
63
- }
64
- );