@etsoo/react 1.5.44 → 1.5.45
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 +7 -1
- package/lib/mu/RLink.js +12 -7
- package/package.json +1 -1
- package/src/mu/RLink.tsx +20 -8
package/lib/mu/RLink.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { LinkProps } from '@mui/material';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Router Link properties
|
|
5
|
+
*/
|
|
6
|
+
export declare type RLinkProps = LinkProps & {
|
|
7
|
+
delay?: number;
|
|
8
|
+
};
|
|
3
9
|
/**
|
|
4
10
|
* Router Link
|
|
5
11
|
* @param props Props
|
|
6
12
|
* @returns Component
|
|
7
13
|
*/
|
|
8
|
-
export declare const RLink: React.ForwardRefExoticComponent<Pick<
|
|
14
|
+
export declare const RLink: React.ForwardRefExoticComponent<Pick<RLinkProps, "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" | "delay"> & React.RefAttributes<HTMLAnchorElement>>;
|
package/lib/mu/RLink.js
CHANGED
|
@@ -9,11 +9,13 @@ import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
|
9
9
|
*/
|
|
10
10
|
export const RLink = React.forwardRef((props, ref) => {
|
|
11
11
|
// Destruct
|
|
12
|
-
const { href, target, onClick, ...rest } = props;
|
|
13
|
-
const delayed =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const { delay = 0, href, target, onClick, ...rest } = props;
|
|
13
|
+
const delayed = delay > 0
|
|
14
|
+
? useDelayedExecutor((href) => {
|
|
15
|
+
// Router push
|
|
16
|
+
globalApp.history.push(href);
|
|
17
|
+
}, delay)
|
|
18
|
+
: null;
|
|
17
19
|
// Click handler
|
|
18
20
|
const onClickLocl = (event) => {
|
|
19
21
|
if (onClick)
|
|
@@ -24,11 +26,14 @@ export const RLink = React.forwardRef((props, ref) => {
|
|
|
24
26
|
globalApp) {
|
|
25
27
|
// Prevent href action
|
|
26
28
|
event.preventDefault();
|
|
27
|
-
delayed
|
|
29
|
+
if (delayed != null)
|
|
30
|
+
delayed.call(undefined, href);
|
|
31
|
+
else
|
|
32
|
+
globalApp.history.push(href);
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
35
|
React.useEffect(() => {
|
|
31
|
-
return () => delayed.clear();
|
|
36
|
+
return () => delayed === null || delayed === void 0 ? void 0 : delayed.clear();
|
|
32
37
|
}, [delayed]);
|
|
33
38
|
// Component
|
|
34
39
|
return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
|
package/package.json
CHANGED
package/src/mu/RLink.tsx
CHANGED
|
@@ -3,20 +3,30 @@ import React from 'react';
|
|
|
3
3
|
import { globalApp } from '../app/ReactApp';
|
|
4
4
|
import { useDelayedExecutor } from '../uses/useDelayedExecutor';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Router Link properties
|
|
8
|
+
*/
|
|
9
|
+
export type RLinkProps = LinkProps & {
|
|
10
|
+
delay?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
6
13
|
/**
|
|
7
14
|
* Router Link
|
|
8
15
|
* @param props Props
|
|
9
16
|
* @returns Component
|
|
10
17
|
*/
|
|
11
|
-
export const RLink = React.forwardRef<HTMLAnchorElement,
|
|
18
|
+
export const RLink = React.forwardRef<HTMLAnchorElement, RLinkProps>(
|
|
12
19
|
(props, ref) => {
|
|
13
20
|
// Destruct
|
|
14
|
-
const { href, target, onClick, ...rest } = props;
|
|
21
|
+
const { delay = 0, href, target, onClick, ...rest } = props;
|
|
15
22
|
|
|
16
|
-
const delayed =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
const delayed =
|
|
24
|
+
delay > 0
|
|
25
|
+
? useDelayedExecutor((href: string) => {
|
|
26
|
+
// Router push
|
|
27
|
+
globalApp.history.push(href);
|
|
28
|
+
}, delay)
|
|
29
|
+
: null;
|
|
20
30
|
|
|
21
31
|
// Click handler
|
|
22
32
|
const onClickLocl = (
|
|
@@ -32,12 +42,14 @@ export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
32
42
|
) {
|
|
33
43
|
// Prevent href action
|
|
34
44
|
event.preventDefault();
|
|
35
|
-
|
|
45
|
+
|
|
46
|
+
if (delayed != null) delayed.call(undefined, href);
|
|
47
|
+
else globalApp.history.push(href);
|
|
36
48
|
}
|
|
37
49
|
};
|
|
38
50
|
|
|
39
51
|
React.useEffect(() => {
|
|
40
|
-
return () => delayed
|
|
52
|
+
return () => delayed?.clear();
|
|
41
53
|
}, [delayed]);
|
|
42
54
|
|
|
43
55
|
// Component
|