@etsoo/react 1.5.39 → 1.5.42

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/mu/RLink.d.ts CHANGED
@@ -1,13 +1,8 @@
1
- /// <reference types="react" />
2
1
  import { LinkProps } from '@mui/material';
3
- import { LinkProps as RouterLinkProps } from 'react-router-dom';
4
- /**
5
- * Router Link props
6
- */
7
- export declare type RLinkProps = LinkProps & RouterLinkProps;
2
+ import React from 'react';
8
3
  /**
9
4
  * Router Link
10
5
  * @param props Props
11
6
  * @returns Component
12
7
  */
13
- export declare function RLink(props: RLinkProps): JSX.Element;
8
+ export declare const RLink: React.ForwardRefExoticComponent<Pick<LinkProps<"a", {}>, "role" | "children" | "p" | "slot" | "title" | "maxWidth" | "type" | keyof import("@mui/material/OverridableComponent").CommonProps | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "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" | "sx" | "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" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "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" | "href" | "variant" | "key" | "underline" | "media" | "target" | "hrefLang" | "referrerPolicy" | "rel" | "download" | "ping" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping" | "TypographyClasses"> & React.RefAttributes<HTMLAnchorElement>>;
package/lib/mu/RLink.js CHANGED
@@ -1,11 +1,29 @@
1
1
  import { Link } from '@mui/material';
2
- import { Link as RouterLink } from 'react-router-dom';
3
2
  import React from 'react';
3
+ import { globalApp } from '../app/ReactApp';
4
4
  /**
5
5
  * Router Link
6
6
  * @param props Props
7
7
  * @returns Component
8
8
  */
9
- export function RLink(props) {
10
- return React.createElement(Link, { component: RouterLink, ...props });
11
- }
9
+ export const RLink = React.forwardRef((props, ref) => {
10
+ // Destruct
11
+ const { href, target, onClick, ...rest } = props;
12
+ // Click handler
13
+ const onClickLocl = (event) => {
14
+ if (onClick)
15
+ onClick(event);
16
+ if (!event.isDefaultPrevented() &&
17
+ href &&
18
+ (!target || target === '_self') && // Let browser handle "target=_blank" etc
19
+ globalApp) {
20
+ // Cancel further processing
21
+ event.preventDefault();
22
+ event.stopPropagation();
23
+ // Router push
24
+ globalApp.history.push(href);
25
+ }
26
+ };
27
+ // Component
28
+ return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
29
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.39",
3
+ "version": "1.5.42",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/mu/RLink.tsx CHANGED
@@ -1,20 +1,47 @@
1
1
  import { Link, LinkProps } from '@mui/material';
2
- import {
3
- Link as RouterLink,
4
- LinkProps as RouterLinkProps
5
- } from 'react-router-dom';
6
2
  import React from 'react';
7
-
8
- /**
9
- * Router Link props
10
- */
11
- export type RLinkProps = LinkProps & RouterLinkProps;
3
+ import { globalApp } from '../app/ReactApp';
12
4
 
13
5
  /**
14
6
  * Router Link
15
7
  * @param props Props
16
8
  * @returns Component
17
9
  */
18
- export function RLink(props: RLinkProps) {
19
- return <Link component={RouterLink} {...props} />;
20
- }
10
+ export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
11
+ (props, ref) => {
12
+ // Destruct
13
+ const { href, target, onClick, ...rest } = props;
14
+
15
+ // Click handler
16
+ const onClickLocl = (
17
+ event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
18
+ ) => {
19
+ if (onClick) onClick(event);
20
+
21
+ if (
22
+ !event.isDefaultPrevented() &&
23
+ href &&
24
+ (!target || target === '_self') && // Let browser handle "target=_blank" etc
25
+ globalApp
26
+ ) {
27
+ // Cancel further processing
28
+ event.preventDefault();
29
+ event.stopPropagation();
30
+
31
+ // Router push
32
+ globalApp.history.push(href);
33
+ }
34
+ };
35
+
36
+ // Component
37
+ return (
38
+ <Link
39
+ {...rest}
40
+ onClick={onClickLocl}
41
+ href={href}
42
+ target={target}
43
+ ref={ref}
44
+ />
45
+ );
46
+ }
47
+ );