@etsoo/materialui 1.0.18 → 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,6 +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 { NavigateFunction, NavigateOptions } from 'react-router-dom';
6
7
  /**
7
8
  * Global application
8
9
  */
@@ -88,6 +89,10 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
88
89
  * Is screen size up 'md'
89
90
  */
90
91
  mdUp?: boolean;
92
+ /**
93
+ * Navigate function
94
+ */
95
+ navigateFunction?: NavigateFunction;
91
96
  /**
92
97
  * Page state dispatch
93
98
  */
@@ -141,11 +146,6 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
141
146
  * @param callback Callback
142
147
  */
143
148
  freshCountdownUI(callback?: () => PromiseLike<unknown>): void;
144
- /**
145
- * Redirect to the Url
146
- * @param url Url
147
- */
148
- redirectTo(url: string): void;
149
149
  /**
150
150
  * Set page data
151
151
  * @param data Page data
@@ -156,6 +156,12 @@ export declare class ReactApp<S extends IAppSettings, D extends IUser, P extends
156
156
  * @param title Page title
157
157
  */
158
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;
159
165
  /**
160
166
  * Set page title and data
161
167
  * @param key Page title resource key
@@ -193,13 +193,6 @@ export class ReactApp extends CoreApp {
193
193
  inputs: progress
194
194
  });
195
195
  }
196
- /**
197
- * Redirect to the Url
198
- * @param url Url
199
- */
200
- redirectTo(url) {
201
- location.href = url;
202
- }
203
196
  /**
204
197
  * Set page data
205
198
  * @param data Page data
@@ -228,6 +221,19 @@ export class ReactApp extends CoreApp {
228
221
  });
229
222
  }
230
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
+ }
231
237
  /**
232
238
  * Set page title and data
233
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.18",
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",
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,6 +34,7 @@ import {
34
34
  UserCalls,
35
35
  UserState
36
36
  } from '@etsoo/react';
37
+ import { NavigateFunction, NavigateOptions } from 'react-router-dom';
37
38
 
38
39
  /**
39
40
  * Global application
@@ -191,6 +192,11 @@ export class ReactApp<
191
192
  */
192
193
  mdUp?: boolean;
193
194
 
195
+ /**
196
+ * Navigate function
197
+ */
198
+ navigateFunction?: NavigateFunction;
199
+
194
200
  /**
195
201
  * Page state dispatch
196
202
  */
@@ -366,14 +372,6 @@ export class ReactApp<
366
372
  );
367
373
  }
368
374
 
369
- /**
370
- * Redirect to the Url
371
- * @param url Url
372
- */
373
- override redirectTo(url: string) {
374
- location.href = url;
375
- }
376
-
377
375
  /**
378
376
  * Set page data
379
377
  * @param data Page data
@@ -405,6 +403,20 @@ export class ReactApp<
405
403
  }
406
404
  }
407
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
+
408
420
  /**
409
421
  * Set page title and data
410
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.redirectTo(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.redirectTo(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
- );