@zat-design/sisyphus-react 4.5.8-beta.4 → 4.5.8-beta.6
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/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProAction/components/CheckModalContent/index.d.ts +1 -2
- package/es/ProDownload/index.d.ts +1 -2
- package/es/ProEditTable/components/ActionButton/index.d.ts +1 -2
- package/es/ProEditTable/components/RcTable/BaseTable.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/BaseTable.js +7 -6
- package/es/ProEditTable/components/RcTable/DraggableTable.d.ts +1 -1
- package/es/ProEditTable/components/RcTable/DraggableTable.js +4 -4
- package/es/ProEditTable/components/RenderField/index.d.ts +1 -1
- package/es/ProEditTable/components/RenderField/index.js +22 -21
- package/es/ProEditTable/components/RenderField/tools.d.ts +7 -0
- package/es/ProEditTable/components/RenderField/tools.js +29 -2
- package/es/ProEditTable/components/RenderToolbar/index.d.ts +1 -2
- package/es/ProEditTable/components/Summary/index.d.ts +1 -2
- package/es/ProEditTable/index.d.ts +1 -1
- package/es/ProEditTable/index.js +44 -38
- package/es/ProEditTable/propsType.d.ts +6 -0
- package/es/ProEditTable/utils/config.d.ts +1 -2
- package/es/ProEditTable/utils/index.js +3 -2
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +11 -4
- package/es/ProEnum/components/Group.d.ts +1 -2
- package/es/ProEnum/components/Tag.d.ts +1 -2
- package/es/ProEnum/index.d.ts +2 -3
- package/es/ProEnum/utils/getEnumLabel.d.ts +1 -2
- package/es/ProForm/components/base/Input/index.d.ts +1 -2
- package/es/ProForm/components/combination/FormList/components/Empty.d.ts +1 -2
- package/es/ProForm/components/combination/ProCascader/index.d.ts +1 -1
- package/es/ProForm/hooks/useForm.d.ts +1 -1
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.d.ts +1 -2
- package/es/ProLayout/components/ProCollapse/index.d.ts +1 -2
- package/es/ProLayout/components/ProFooter/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.d.ts +1 -2
- package/es/ProLayout/components/ProHeader/components/Describe/index.d.ts +3 -3
- package/es/ProLayout/components/ProHeader/index.d.ts +1 -1
- package/es/ProLayout/components/ProHeader/index.js +1 -0
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.d.ts +1 -2
- package/es/ProLayout/components/TabsManager/components/TabsHeader.d.ts +1 -2
- package/es/ProLayout/index.d.ts +4 -4
- package/es/ProSelect/components/AdaptiveTooltip.d.ts +1 -2
- package/es/ProSelect/index.d.ts +1 -1
- package/es/ProStep/components/Anchor/index.d.ts +2 -2
- package/es/ProStep/components/Anchor/index.js +4 -3
- package/es/ProStep/components/Item/index.js +8 -5
- package/es/ProStep/components/Step/index.d.ts +6 -3
- package/es/ProStep/components/Step/index.js +5 -3
- package/es/ProStep/constants.d.ts +1 -0
- package/es/ProStep/constants.js +1 -0
- package/es/ProStep/index.js +102 -6
- package/es/ProStep/propsType.d.ts +12 -6
- package/es/ProStep/style/index.less +6 -3
- package/es/ProStep/utils/index.d.ts +5 -5
- package/es/ProStep/utils/index.js +35 -11
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -1
- package/es/ProTable/components/RenderFooter/index.d.ts +1 -2
- package/es/ProTable/components/RenderTableHeader/index.d.ts +1 -2
- package/es/ProTable/components/RenderTabs/index.d.ts +1 -1
- package/es/ProTable/components/TableResizable/index.d.ts +1 -2
- package/es/ProTabs/components/Card/index.d.ts +1 -2
- package/es/ProThemeTools/component/ProTools/index.d.ts +1 -2
- package/es/ProThemeTools/index.d.ts +1 -2
- package/es/ProTooltip/index.d.ts +1 -2
- package/es/ProTree/components/AdaptiveTooltip.d.ts +1 -2
- package/es/ProTree/components/CloseIcon.d.ts +1 -2
- package/es/ProTree/components/List.d.ts +1 -1
- package/es/ProTree/components/ProTree.d.ts +1 -2
- package/es/ProTree/components/ProTreeSelect/index.d.ts +1 -1
- package/es/ProTree/components/SearchTitle.d.ts +1 -1
- package/es/ProTree/components/Tree.d.ts +2 -2
- package/es/ProTree/index.d.ts +1 -2
- package/es/ProTreeModal/components/Cascader.d.ts +1 -1
- package/es/ProTreeModal/components/CloseIcon.d.ts +1 -2
- package/es/ProTreeModal/components/SearchTitle.d.ts +1 -1
- package/es/ProTreeModal/components/Trigger.d.ts +1 -1
- package/es/ProTreeModal/components/Trigger.js +4 -2
- package/es/ProTreeModal/index.d.ts +1 -2
- package/es/ProUpload/components/DraggableUploadListItem.d.ts +1 -2
- package/package.json +2 -1
|
@@ -5,4 +5,4 @@ export interface FormInstanceOption {
|
|
|
5
5
|
formKey?: string;
|
|
6
6
|
source?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const useForm: <T>(originForm?: ModifiedFormInstanceType<T
|
|
8
|
+
export declare const useForm: <T>(originForm?: FormInstanceOption | ModifiedFormInstanceType<T>, options?: FormInstanceOption) => [ModifiedFormInstanceType<T>];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { OpenMenuPropsType } from './propsType';
|
|
3
|
-
declare const OpenMenu: (props: OpenMenuPropsType) => import("react").JSX.Element;
|
|
2
|
+
declare const OpenMenu: (props: OpenMenuPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
4
3
|
export default OpenMenu;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ProCollapseType } from './PropTypes';
|
|
3
|
-
declare const ProCollapse: (props: ProCollapseType) =>
|
|
2
|
+
declare const ProCollapse: (props: ProCollapseType) => import("react/jsx-runtime").JSX.Element;
|
|
4
3
|
export default ProCollapse;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ProFooterType } from './PropTypes';
|
|
3
|
-
declare const _default: import("react").MemoExoticComponent<(props: ProFooterType) => import("react").JSX.Element>;
|
|
3
|
+
declare const _default: import("react").MemoExoticComponent<(props: ProFooterType) => import("react/jsx-runtime").JSX.Element>;
|
|
4
4
|
export default _default;
|
|
@@ -8,13 +8,13 @@ type DescribeValueItem = Pick<DescribeColumnType, 'tag' | 'link' | 'value' | 'co
|
|
|
8
8
|
export declare const DescribeTag: ({ tag, parentKey, }: {
|
|
9
9
|
tag?: DescribeColumnType['tag'];
|
|
10
10
|
parentKey: string;
|
|
11
|
-
}) =>
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
/**
|
|
13
13
|
* 单行值渲染:link → <a>,copyable+字符串 → 复制按钮,末尾追加 tag
|
|
14
14
|
*/
|
|
15
15
|
export declare const DescribeValue: ({ value, link, copyable, tag, parentKey, }: DescribeValueItem & {
|
|
16
16
|
parentKey: string;
|
|
17
|
-
}) =>
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
/**
|
|
19
19
|
* 多值渲染:以「、」连接;超 3 个显示「共N个,」前缀;内容溢出时显示「...」并用 Tooltip 展示全部
|
|
20
20
|
*/
|
|
@@ -22,5 +22,5 @@ export declare const DescribeItems: ({ items, parentKey, containerRef, }: {
|
|
|
22
22
|
items: DescribeValueItem[];
|
|
23
23
|
parentKey: string;
|
|
24
24
|
containerRef: React.RefObject<HTMLDivElement>;
|
|
25
|
-
}) =>
|
|
25
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ProHeaderType } from './PropTypes';
|
|
3
|
-
declare const _default: React.MemoExoticComponent<(props: ProHeaderType) =>
|
|
3
|
+
declare const _default: React.MemoExoticComponent<(props: ProHeaderType) => import("react/jsx-runtime").JSX.Element>;
|
|
4
4
|
export default _default;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TabContextMenuProps } from '../propTypes';
|
|
3
2
|
/**
|
|
4
3
|
* 右键菜单组件 - 兼容Antd 4.x和5.x
|
|
5
4
|
*/
|
|
6
|
-
declare function TabContextMenu({ tabId, children, closable, onClose, onCloseOthers, onCloseRight, onCloseAll, pinned, pinDisabled, onTogglePin, menuItems: customMenuItems, tabMenuClick, tab, tabs, }: TabContextMenuProps): import("react").JSX.Element;
|
|
5
|
+
declare function TabContextMenu({ tabId, children, closable, onClose, onCloseOthers, onCloseRight, onCloseAll, pinned, pinDisabled, onTogglePin, menuItems: customMenuItems, tabMenuClick, tab, tabs, }: TabContextMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
7
6
|
export default TabContextMenu;
|
|
8
7
|
export { TabContextMenu };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { TabsProps } from 'antd';
|
|
3
2
|
export interface TabsHeaderProps {
|
|
4
3
|
activeKey: string | undefined;
|
|
@@ -8,4 +7,4 @@ export interface TabsHeaderProps {
|
|
|
8
7
|
draggable?: boolean;
|
|
9
8
|
onReorder?: (activeId: string, overId: string) => void;
|
|
10
9
|
}
|
|
11
|
-
export declare function TabsHeader({ activeKey, tabsItems, onTabChange, onTabEdit, draggable, onReorder, }: TabsHeaderProps):
|
|
10
|
+
export declare function TabsHeader({ activeKey, tabsItems, onTabChange, onTabEdit, draggable, onReorder, }: TabsHeaderProps): import("react/jsx-runtime").JSX.Element;
|
package/es/ProLayout/index.d.ts
CHANGED
|
@@ -9,10 +9,10 @@ interface LayoutContextValue {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const LayoutContext: import("react").Context<LayoutContextValue>;
|
|
11
11
|
declare const ProLayout: {
|
|
12
|
-
(props: ProLayoutType): import("react").JSX.Element;
|
|
13
|
-
ProCollapse: (props: import("
|
|
14
|
-
ProFooter: import("react").MemoExoticComponent<(props: import("
|
|
15
|
-
ProHeader: import("react").MemoExoticComponent<(props: import("
|
|
12
|
+
(props: ProLayoutType): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
ProCollapse: (props: import("../index").ProCollapseType) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
ProFooter: import("react").MemoExoticComponent<(props: import("../index").ProFooterType) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
ProHeader: import("react").MemoExoticComponent<(props: import("../index").ProHeaderType) => import("react/jsx-runtime").JSX.Element>;
|
|
16
16
|
useProLayoutTabs: typeof useProLayoutTabs;
|
|
17
17
|
useActiveTab: () => import("./propTypes").TabItem;
|
|
18
18
|
};
|
package/es/ProSelect/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PropSelectType, ProSelectActionType } from './propsType';
|
|
3
|
-
export declare const ProSelect: (props: PropSelectType, ref: React.Ref<ProSelectActionType> | undefined) =>
|
|
3
|
+
export declare const ProSelect: (props: PropSelectType, ref: React.Ref<ProSelectActionType> | undefined) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const _default: React.ForwardRefExoticComponent<PropSelectType & React.RefAttributes<ProSelectActionType>>;
|
|
5
5
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
2
|
import { MenuItemProps } from '../../propsType';
|
|
3
|
-
export declare const MenuItem: (props: MenuItemProps) =>
|
|
3
|
+
export declare const MenuItem: (props: MenuItemProps) => ReactElement;
|
|
4
4
|
export default MenuItem;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
2
|
import { Badge } from 'antd';
|
|
3
|
-
import { handleScroll } from "../../utils";
|
|
3
|
+
import { handleScroll as defaultHandleScroll } from "../../utils";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
const AnchorSvg = ({
|
|
6
6
|
color
|
|
@@ -42,7 +42,8 @@ export const MenuItem = props => {
|
|
|
42
42
|
errorNum,
|
|
43
43
|
currentNum,
|
|
44
44
|
targetOffset,
|
|
45
|
-
scrollToError = true
|
|
45
|
+
scrollToError = true,
|
|
46
|
+
onAnchorClick = defaultHandleScroll
|
|
46
47
|
} = props;
|
|
47
48
|
const renderMenuIcon = () => {
|
|
48
49
|
if (isCurrentStep) {
|
|
@@ -81,7 +82,7 @@ export const MenuItem = props => {
|
|
|
81
82
|
current: isCurrentStep && onOff
|
|
82
83
|
}),
|
|
83
84
|
onClick: () => {
|
|
84
|
-
|
|
85
|
+
onAnchorClick(code, {
|
|
85
86
|
targetOffset,
|
|
86
87
|
scrollToError
|
|
87
88
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _isBoolean from "lodash/isBoolean";
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
import { useEffect } from 'react';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
4
|
import LazyLoad, { forceCheck } from "../LazyLoad";
|
|
5
5
|
import { useStep } from "../../index";
|
|
6
6
|
import ProCollapse from "../../../ProLayout/components/ProCollapse";
|
|
@@ -25,9 +25,9 @@ const ProStepItem = ({
|
|
|
25
25
|
const {
|
|
26
26
|
register,
|
|
27
27
|
collapse,
|
|
28
|
-
lazyLoad: globalLazyLoad
|
|
29
|
-
targetOffset
|
|
28
|
+
lazyLoad: globalLazyLoad
|
|
30
29
|
} = useStep();
|
|
30
|
+
const itemRef = useRef(null);
|
|
31
31
|
const lazyLoad = stepLazyLoad ?? globalLazyLoad;
|
|
32
32
|
useEffect(() => {
|
|
33
33
|
// Schedule registration to avoid re-render issues
|
|
@@ -37,6 +37,7 @@ const ProStepItem = ({
|
|
|
37
37
|
title,
|
|
38
38
|
order,
|
|
39
39
|
lazyLoad,
|
|
40
|
+
element: itemRef.current,
|
|
40
41
|
...restProps
|
|
41
42
|
});
|
|
42
43
|
}, 0);
|
|
@@ -59,10 +60,11 @@ const ProStepItem = ({
|
|
|
59
60
|
// If there's no `register` function or if collapsing is enabled, wrap in ProCollapse
|
|
60
61
|
if (!register || collapse && collapseItem && title) {
|
|
61
62
|
return /*#__PURE__*/_jsx("div", {
|
|
63
|
+
ref: itemRef,
|
|
62
64
|
className: "pro-step-item",
|
|
63
65
|
id: id,
|
|
64
66
|
style: {
|
|
65
|
-
scrollMarginTop:
|
|
67
|
+
scrollMarginTop: 'var(--pro-step-anchor-offset)'
|
|
66
68
|
},
|
|
67
69
|
children: /*#__PURE__*/_jsx(ProCollapse, {
|
|
68
70
|
title: title,
|
|
@@ -85,10 +87,11 @@ const ProStepItem = ({
|
|
|
85
87
|
|
|
86
88
|
// Otherwise, just render children
|
|
87
89
|
return /*#__PURE__*/_jsx("div", {
|
|
90
|
+
ref: itemRef,
|
|
88
91
|
className: "pro-step-item",
|
|
89
92
|
id: id,
|
|
90
93
|
style: {
|
|
91
|
-
scrollMarginTop:
|
|
94
|
+
scrollMarginTop: 'var(--pro-step-anchor-offset)'
|
|
92
95
|
},
|
|
93
96
|
children: renderChildren()
|
|
94
97
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ProStepType } from '../../propsType';
|
|
3
|
-
export declare const Step: ({ fixedTop, dataSource, activeKey, errorCollection, style, targetOffset, scrollToError, }: import("../../propsType").ProStepPropsType & {
|
|
2
|
+
export declare const Step: ({ fixedTop, dataSource, activeKey, errorCollection, style, targetOffset, scrollToError, onAnchorClick, }: import("../../propsType").ProStepPropsType & {
|
|
4
3
|
errorCollection: object;
|
|
5
|
-
|
|
4
|
+
onAnchorClick?: (id: string, options?: {
|
|
5
|
+
targetOffset?: string | number;
|
|
6
|
+
scrollToError?: boolean;
|
|
7
|
+
}) => void;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
9
|
export default Step;
|
|
@@ -4,8 +4,8 @@ import ProIcon from "../../../ProIcon/index";
|
|
|
4
4
|
import catalogSvg from "../../../assets/catalog.svg";
|
|
5
5
|
import Anchor from "../Anchor";
|
|
6
6
|
import locale from "../../../locale";
|
|
7
|
+
import { DEFAULT_FIXED_TOP } from "../../constants";
|
|
7
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
const DEFAULT_FIXED_TOP = 'var(--pro-layout-content-sticky-top, 64px)';
|
|
9
9
|
const toCssLength = value => typeof value === 'number' ? `${value}px` : value;
|
|
10
10
|
export const Step = ({
|
|
11
11
|
fixedTop = DEFAULT_FIXED_TOP,
|
|
@@ -14,7 +14,8 @@ export const Step = ({
|
|
|
14
14
|
errorCollection,
|
|
15
15
|
style,
|
|
16
16
|
targetOffset,
|
|
17
|
-
scrollToError
|
|
17
|
+
scrollToError,
|
|
18
|
+
onAnchorClick
|
|
18
19
|
}) => {
|
|
19
20
|
const [onOff, setOnOff] = useState(false);
|
|
20
21
|
const fixedTopCss = toCssLength(fixedTop);
|
|
@@ -36,9 +37,10 @@ export const Step = ({
|
|
|
36
37
|
item.currentNum = index + 1;
|
|
37
38
|
item.errorNum = errorNum;
|
|
38
39
|
item.targetOffset = targetOffset;
|
|
40
|
+
item.onAnchorClick = onAnchorClick;
|
|
39
41
|
});
|
|
40
42
|
return nextDataSource;
|
|
41
|
-
}, [dataSource, activeKey, errorCollection]);
|
|
43
|
+
}, [dataSource, activeKey, errorCollection, onAnchorClick, targetOffset]);
|
|
42
44
|
const handleMouseEnter = () => {
|
|
43
45
|
setOnOff(true);
|
|
44
46
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_FIXED_TOP = "var(--pro-layout-content-sticky-top, 64px)";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_FIXED_TOP = 'var(--pro-layout-content-sticky-top, 64px)';
|
package/es/ProStep/index.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import _debounce from "lodash/debounce";
|
|
2
|
-
import { createContext, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { useSetState, useLocalStorageState } from 'ahooks';
|
|
4
4
|
import { handleScroll, handleScrollError } from "./utils";
|
|
5
5
|
import Step from "./components/Step";
|
|
6
6
|
import Item from "./components/Item";
|
|
7
7
|
import Listener from "./components/Listener";
|
|
8
|
+
import { DEFAULT_FIXED_TOP } from "./constants";
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const DEFAULT_ANCHOR_GAP = '16px';
|
|
11
|
+
const ANCHOR_SCROLL_DELAY = 50;
|
|
12
|
+
const STICKY_HEADER_SELECTOR = '[data-pro-step-sticky-header="true"]';
|
|
13
|
+
const toCssLength = value => typeof value === 'number' ? `${value}px` : value;
|
|
14
|
+
|
|
9
15
|
// 创建上下文并提供类型
|
|
10
16
|
export const ProStepContext = /*#__PURE__*/createContext(null);
|
|
11
17
|
export const useStep = () => {
|
|
@@ -23,13 +29,24 @@ const ProStep = ({
|
|
|
23
29
|
});
|
|
24
30
|
// 注册子节点id与title映射的集合
|
|
25
31
|
const registerMap = useRef({});
|
|
32
|
+
const wrapperRef = useRef(null);
|
|
33
|
+
const stickyHeaderRef = useRef(null);
|
|
34
|
+
const autoAnchorEnabledRef = useRef(false);
|
|
35
|
+
const scrollTaskRef = useRef(null);
|
|
26
36
|
const [, setLocalData] = useLocalStorageState('cache-pro-step');
|
|
27
37
|
const ids = Object.keys(registerMap.current);
|
|
28
38
|
const {
|
|
29
39
|
collapse = false,
|
|
30
40
|
lazyLoad = false,
|
|
31
|
-
targetOffset
|
|
41
|
+
targetOffset,
|
|
42
|
+
fixedTop
|
|
32
43
|
} = resetProps;
|
|
44
|
+
const hasExplicitTargetOffset = targetOffset !== undefined && targetOffset !== null;
|
|
45
|
+
const anchorBase = fixedTop === undefined || fixedTop === null ? DEFAULT_FIXED_TOP : toCssLength(fixedTop);
|
|
46
|
+
const autoAnchorOffset = `calc(${anchorBase} + var(--pro-step-sticky-header-height, 0px) + ${DEFAULT_ANCHOR_GAP})`;
|
|
47
|
+
const wrapperStyle = hasExplicitTargetOffset ? {
|
|
48
|
+
'--pro-step-anchor-offset': toCssLength(targetOffset)
|
|
49
|
+
} : undefined;
|
|
33
50
|
const dataSource = useMemo(() => {
|
|
34
51
|
if (resetProps?.dataSource) {
|
|
35
52
|
return resetProps?.dataSource;
|
|
@@ -56,12 +73,14 @@ const ProStep = ({
|
|
|
56
73
|
order,
|
|
57
74
|
disabled,
|
|
58
75
|
lazyLoad,
|
|
76
|
+
element,
|
|
59
77
|
...rest
|
|
60
78
|
}) => {
|
|
61
79
|
const record = {};
|
|
62
80
|
record.id = id;
|
|
63
81
|
record.title = title;
|
|
64
82
|
record.order = order;
|
|
83
|
+
record.element = element;
|
|
65
84
|
if (!registerMap.current[id]) {
|
|
66
85
|
debounceReRender();
|
|
67
86
|
}
|
|
@@ -100,6 +119,80 @@ const ProStep = ({
|
|
|
100
119
|
});
|
|
101
120
|
}
|
|
102
121
|
};
|
|
122
|
+
const measureStickyHeader = useCallback((detect = false) => {
|
|
123
|
+
if (hasExplicitTargetOffset) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
if (!detect && !autoAnchorEnabledRef.current) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const wrapper = wrapperRef.current;
|
|
130
|
+
if (!wrapper) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const currentHeader = stickyHeaderRef.current;
|
|
134
|
+
const header = currentHeader && currentHeader.parentElement === wrapper ? currentHeader : Array.from(wrapper.children).find(element => element.matches(STICKY_HEADER_SELECTOR));
|
|
135
|
+
if (!header) {
|
|
136
|
+
autoAnchorEnabledRef.current = false;
|
|
137
|
+
stickyHeaderRef.current = null;
|
|
138
|
+
wrapper.style.removeProperty('--pro-step-sticky-header-height');
|
|
139
|
+
wrapper.style.removeProperty('--pro-step-anchor-offset');
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
autoAnchorEnabledRef.current = true;
|
|
143
|
+
stickyHeaderRef.current = header;
|
|
144
|
+
wrapper.style.setProperty('--pro-step-sticky-header-height', `${header.getBoundingClientRect().height}px`);
|
|
145
|
+
wrapper.style.setProperty('--pro-step-anchor-offset', autoAnchorOffset);
|
|
146
|
+
return true;
|
|
147
|
+
}, [autoAnchorOffset, hasExplicitTargetOffset]);
|
|
148
|
+
useLayoutEffect(() => {
|
|
149
|
+
autoAnchorEnabledRef.current = false;
|
|
150
|
+
if (hasExplicitTargetOffset || !measureStickyHeader(true)) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
const header = stickyHeaderRef.current;
|
|
154
|
+
if (!header || typeof ResizeObserver === 'undefined') {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const observer = new ResizeObserver(() => {
|
|
158
|
+
measureStickyHeader();
|
|
159
|
+
});
|
|
160
|
+
observer.observe(header);
|
|
161
|
+
return () => {
|
|
162
|
+
observer.disconnect();
|
|
163
|
+
autoAnchorEnabledRef.current = false;
|
|
164
|
+
stickyHeaderRef.current = null;
|
|
165
|
+
};
|
|
166
|
+
}, [hasExplicitTargetOffset, measureStickyHeader]);
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
return () => {
|
|
169
|
+
if (scrollTaskRef.current !== null) {
|
|
170
|
+
window.clearTimeout(scrollTaskRef.current);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
const scrollToStep = useCallback((id, options) => {
|
|
175
|
+
if (autoAnchorEnabledRef.current) {
|
|
176
|
+
measureStickyHeader();
|
|
177
|
+
}
|
|
178
|
+
const root = wrapperRef.current;
|
|
179
|
+
if (!root) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const registeredElement = registerMap.current[id]?.element;
|
|
183
|
+
const target = registeredElement && root.contains(registeredElement) ? registeredElement : Array.from(root.querySelectorAll('.pro-step-item')).find(item => item.id === id);
|
|
184
|
+
if (scrollTaskRef.current !== null) {
|
|
185
|
+
window.clearTimeout(scrollTaskRef.current);
|
|
186
|
+
}
|
|
187
|
+
scrollTaskRef.current = window.setTimeout(() => {
|
|
188
|
+
scrollTaskRef.current = null;
|
|
189
|
+
handleScroll(id, {
|
|
190
|
+
...options,
|
|
191
|
+
root,
|
|
192
|
+
target
|
|
193
|
+
});
|
|
194
|
+
}, ANCHOR_SCROLL_DELAY);
|
|
195
|
+
}, [measureStickyHeader]);
|
|
103
196
|
const notify = async params => {
|
|
104
197
|
const {
|
|
105
198
|
excludes
|
|
@@ -121,7 +214,7 @@ const ProStep = ({
|
|
|
121
214
|
setState({
|
|
122
215
|
errorCollection: nextErrorCollection
|
|
123
216
|
});
|
|
124
|
-
handleScrollError();
|
|
217
|
+
handleScrollError(undefined, wrapperRef.current || document);
|
|
125
218
|
return res;
|
|
126
219
|
};
|
|
127
220
|
const triggerTo = async keys => {
|
|
@@ -139,7 +232,7 @@ const ProStep = ({
|
|
|
139
232
|
setState({
|
|
140
233
|
errorCollection: nextErrorCollection
|
|
141
234
|
});
|
|
142
|
-
handleScrollError();
|
|
235
|
+
handleScrollError(undefined, wrapperRef.current || document);
|
|
143
236
|
return result;
|
|
144
237
|
};
|
|
145
238
|
return /*#__PURE__*/_jsx(ProStepContext.Provider, {
|
|
@@ -149,19 +242,22 @@ const ProStep = ({
|
|
|
149
242
|
register,
|
|
150
243
|
notify,
|
|
151
244
|
triggerTo,
|
|
152
|
-
handleScroll,
|
|
245
|
+
handleScroll: scrollToStep,
|
|
153
246
|
lazyLoad,
|
|
154
247
|
targetOffset,
|
|
155
248
|
unNotify,
|
|
156
249
|
source: 'ProStep'
|
|
157
250
|
},
|
|
158
251
|
children: /*#__PURE__*/_jsxs("div", {
|
|
252
|
+
ref: wrapperRef,
|
|
159
253
|
className: "pro-step-wrapper",
|
|
160
254
|
id: "pro-step",
|
|
255
|
+
style: wrapperStyle,
|
|
161
256
|
children: [children, /*#__PURE__*/_jsx(Step, {
|
|
162
257
|
...resetProps,
|
|
163
258
|
dataSource: dataSource,
|
|
164
|
-
errorCollection: errorCollection
|
|
259
|
+
errorCollection: errorCollection,
|
|
260
|
+
onAnchorClick: scrollToStep
|
|
165
261
|
})]
|
|
166
262
|
})
|
|
167
263
|
});
|
|
@@ -45,8 +45,8 @@ export interface ProStepPropsType {
|
|
|
45
45
|
children?: ReactNode;
|
|
46
46
|
/** 组件自定义样式 */
|
|
47
47
|
style?: CSSProperties;
|
|
48
|
-
/**
|
|
49
|
-
targetOffset?: number;
|
|
48
|
+
/** 完整滚动偏移量,显式设置时覆盖 ProHeader 自动偏移 */
|
|
49
|
+
targetOffset?: string | number;
|
|
50
50
|
/** 是否使用折叠标题 */
|
|
51
51
|
collapse?: boolean;
|
|
52
52
|
/** 是否自动滚动到第一个报错的步骤 */
|
|
@@ -102,8 +102,8 @@ export interface ProStepContextType {
|
|
|
102
102
|
handleScroll: (id: string, options?: ScrollOptions) => void;
|
|
103
103
|
/** 懒加载配置 */
|
|
104
104
|
lazyLoad?: boolean | any;
|
|
105
|
-
/**
|
|
106
|
-
targetOffset?: number;
|
|
105
|
+
/** 完整滚动偏移量 */
|
|
106
|
+
targetOffset?: string | number;
|
|
107
107
|
/** 取消注册函数 */
|
|
108
108
|
unNotify: (keys: string | string[]) => void;
|
|
109
109
|
/** 来源 */
|
|
@@ -126,6 +126,8 @@ export interface RegisterParams {
|
|
|
126
126
|
order: number;
|
|
127
127
|
/** 是否禁用 */
|
|
128
128
|
disabled?: boolean;
|
|
129
|
+
/** 当前步骤项 DOM,仅供 ProStep 实例内定位使用 */
|
|
130
|
+
element?: HTMLElement | null;
|
|
129
131
|
/** 懒加载配置 */
|
|
130
132
|
lazyLoad?: boolean | any;
|
|
131
133
|
/** 允许其他任意属性 */
|
|
@@ -144,6 +146,8 @@ export interface RegisterMapItem {
|
|
|
144
146
|
order: number;
|
|
145
147
|
/** 提交事件 */
|
|
146
148
|
subEvent?: () => Promise<any>;
|
|
149
|
+
/** 当前步骤项 DOM,仅供 ProStep 实例内定位使用 */
|
|
150
|
+
element?: HTMLElement | null;
|
|
147
151
|
/** 允许其他任意属性 */
|
|
148
152
|
[key: string]: any;
|
|
149
153
|
}
|
|
@@ -161,7 +165,7 @@ export interface NotifyParams {
|
|
|
161
165
|
*/
|
|
162
166
|
export interface ScrollOptions {
|
|
163
167
|
/** 目标偏移量 */
|
|
164
|
-
targetOffset?: number;
|
|
168
|
+
targetOffset?: string | number;
|
|
165
169
|
/** 是否滚动到错误位置 */
|
|
166
170
|
scrollToError?: boolean;
|
|
167
171
|
}
|
|
@@ -213,9 +217,11 @@ export interface MenuItemProps {
|
|
|
213
217
|
/** 当前数量 */
|
|
214
218
|
currentNum?: number;
|
|
215
219
|
/** 目标偏移量 */
|
|
216
|
-
targetOffset?: number;
|
|
220
|
+
targetOffset?: string | number;
|
|
217
221
|
/** 是否滚动到错误位置 */
|
|
218
222
|
scrollToError?: boolean;
|
|
223
|
+
/** 当前 ProStep 实例的锚点处理器 */
|
|
224
|
+
onAnchorClick?: (id: string, options?: ScrollOptions) => void;
|
|
219
225
|
}
|
|
220
226
|
/**
|
|
221
227
|
* ProStep 组件基础类型
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
@import '../../style/variables.less';
|
|
2
2
|
|
|
3
|
+
@pro-step-closed-width: 48px;
|
|
4
|
+
@pro-step-content-gap: var(--zaui-space-size-md, 16px);
|
|
5
|
+
|
|
3
6
|
.pro-step-wrapper {
|
|
4
|
-
padding-right:
|
|
7
|
+
padding-right: calc(@pro-step-closed-width - @pro-step-content-gap);
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
.pro-step {
|
|
8
11
|
position: fixed;
|
|
9
12
|
right: 0;
|
|
10
13
|
z-index: 99;
|
|
11
|
-
min-width:
|
|
14
|
+
min-width: @pro-step-closed-width;
|
|
12
15
|
min-height: 48px;
|
|
13
16
|
overflow-x: hidden;
|
|
14
17
|
overflow-y: auto;
|
|
@@ -217,6 +220,6 @@
|
|
|
217
220
|
}
|
|
218
221
|
|
|
219
222
|
&.pro-step-closed {
|
|
220
|
-
width:
|
|
223
|
+
width: @pro-step-closed-width;
|
|
221
224
|
}
|
|
222
225
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { LoadedMapType } from '../propsType';
|
|
2
|
+
import type { LoadedMapType, ScrollOptions } from '../propsType';
|
|
3
3
|
/**
|
|
4
4
|
* 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
|
|
5
5
|
*/
|
|
6
|
-
export declare const handleScrollError: (dom?: HTMLElement) => void;
|
|
6
|
+
export declare const handleScrollError: (dom?: HTMLElement, root?: ParentNode) => void;
|
|
7
7
|
/**
|
|
8
8
|
* 处理滚动到指定元素位置, 如发现有错误, 则优先滚动到错误位置
|
|
9
9
|
* @param id 目标元素的ID
|
|
10
10
|
* @param options 滚动选项
|
|
11
11
|
*/
|
|
12
|
-
export declare const handleScroll: (id: string, options?: {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export declare const handleScroll: (id: string, options?: ScrollOptions & {
|
|
13
|
+
root?: ParentNode;
|
|
14
|
+
target?: HTMLElement | null;
|
|
15
15
|
}) => void;
|
|
16
16
|
/**
|
|
17
17
|
* 获取加载模块数据信息
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import _pick from "lodash/pick";
|
|
2
|
-
import _debounce from "lodash/debounce";
|
|
3
2
|
import scrollIntoView from 'scroll-into-view-if-needed';
|
|
3
|
+
const toCssLength = value => typeof value === 'number' ? `${value}px` : value;
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
|
|
6
7
|
*/
|
|
7
|
-
export const handleScrollError = dom => {
|
|
8
|
+
export const handleScrollError = (dom, root = document) => {
|
|
8
9
|
setTimeout(() => {
|
|
9
|
-
const errorDom = dom ||
|
|
10
|
+
const errorDom = dom || root.querySelector('[class*="form-item-has-error"]');
|
|
10
11
|
if (errorDom) {
|
|
11
12
|
scrollIntoView(errorDom, {
|
|
12
13
|
behavior: 'smooth',
|
|
@@ -24,10 +25,12 @@ export const handleScrollError = dom => {
|
|
|
24
25
|
*/
|
|
25
26
|
export const handleScroll = (id, options) => {
|
|
26
27
|
const {
|
|
27
|
-
targetOffset
|
|
28
|
-
scrollToError
|
|
28
|
+
targetOffset,
|
|
29
|
+
scrollToError,
|
|
30
|
+
root = document,
|
|
31
|
+
target
|
|
29
32
|
} = options || {};
|
|
30
|
-
const dom =
|
|
33
|
+
const dom = target || Array.from(root.querySelectorAll('.pro-step-item')).find(item => item.id === id);
|
|
31
34
|
if (dom) {
|
|
32
35
|
// 查找指定id下的错误表单项
|
|
33
36
|
const errorDom = dom.querySelector('[class*="form-item-has-error"]');
|
|
@@ -35,14 +38,35 @@ export const handleScroll = (id, options) => {
|
|
|
35
38
|
// 如果发现错误表单项,执行handleScrollError函数
|
|
36
39
|
handleScrollError(errorDom);
|
|
37
40
|
} else {
|
|
38
|
-
//
|
|
39
|
-
|
|
41
|
+
// 目录点击必须重新对齐到 sticky 区域下方,不能因“当前可见”而跳过。
|
|
42
|
+
const previousScrollMarginTop = dom.style.scrollMarginTop;
|
|
43
|
+
if (targetOffset !== undefined && targetOffset !== null) {
|
|
44
|
+
dom.style.scrollMarginTop = toCssLength(targetOffset);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
40
47
|
scrollIntoView(dom, {
|
|
41
|
-
behavior
|
|
48
|
+
// compute-scroll-into-view 已计算 scroll-margin;custom behavior 避免外层库再次扣减。
|
|
49
|
+
behavior: actions => {
|
|
50
|
+
actions.forEach(({
|
|
51
|
+
el,
|
|
52
|
+
top,
|
|
53
|
+
left
|
|
54
|
+
}) => {
|
|
55
|
+
el.scroll({
|
|
56
|
+
top,
|
|
57
|
+
left,
|
|
58
|
+
behavior: 'smooth'
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
},
|
|
42
62
|
block: 'start',
|
|
43
|
-
scrollMode: '
|
|
63
|
+
scrollMode: 'always'
|
|
44
64
|
});
|
|
45
|
-
}
|
|
65
|
+
} finally {
|
|
66
|
+
if (targetOffset !== undefined && targetOffset !== null) {
|
|
67
|
+
dom.style.scrollMarginTop = previousScrollMarginTop;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
};
|