linkmore-design 1.0.54 → 1.0.57
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/Affix/demos/basic.d.ts +2 -0
- package/dist/Affix/index.d.ts +54 -0
- package/dist/Affix/style/index.d.ts +1 -0
- package/dist/Affix/utils.d.ts +15 -0
- package/dist/Button/index.d.ts +4 -0
- package/dist/CardTable/card/PictureTextRowOperate.d.ts +7 -0
- package/dist/CardTable/fns/index.d.ts +1 -5
- package/dist/CustomTableOption/cardSort.d.ts +4 -0
- package/dist/CustomTableOption/index.d.ts +1 -0
- package/dist/DatePicker/PickerButton.d.ts +2 -0
- package/dist/DatePicker/PickerTag.d.ts +2 -0
- package/dist/DatePicker/demos/basic.d.ts +2 -0
- package/dist/DatePicker/generatePicker/generateRangePicker.d.ts +4 -0
- package/dist/DatePicker/generatePicker/generateSinglePicker.d.ts +14 -0
- package/dist/DatePicker/generatePicker/index.d.ts +106 -0
- package/dist/DatePicker/generatePicker/interface.d.ts +12 -0
- package/dist/DatePicker/index.d.ts +17 -0
- package/dist/DatePicker/style/index.d.ts +1 -0
- package/dist/DatePicker/util.d.ts +14 -0
- package/dist/IconFont/index.d.ts +1 -1
- package/dist/LmEditTable/demos/basic copy.d.ts +2 -0
- package/dist/LmFilter/Controls/CheckboxTags.d.ts +6 -0
- package/dist/LmFilter/Controls/index.d.ts +2 -0
- package/dist/LmFilter/LmFilter.d.ts +4 -1
- package/dist/LmFilter/{components → baseFilter}/fuzzySearch.d.ts +0 -0
- package/dist/LmFilter/complexFilter/drawer.d.ts +4 -0
- package/dist/LmFilter/complexFilter/index.d.ts +3 -1
- package/dist/LmFilter/complexFilter/valueDrawer.d.ts +4 -0
- package/dist/LmFilter/localization.d.ts +8 -0
- package/dist/LmFilter/utils.d.ts +1 -0
- package/dist/QuickMenu/demos/basic.d.ts +2 -0
- package/dist/QuickMenu/index.d.ts +14 -0
- package/dist/QuickMenu/style/index.d.ts +1 -0
- package/dist/Switch/demos/table.d.ts +2 -0
- package/dist/Switch/index.d.ts +2 -1
- package/dist/Tag/demos/ExigencyTag.d.ts +2 -0
- package/dist/Tag/index.d.ts +4 -0
- package/dist/Upload/demos/picture-little.d.ts +3 -0
- package/dist/Upload/index.d.ts +5 -1
- package/dist/_util/domTarget.d.ts +7 -0
- package/dist/_util/motion.d.ts +8 -0
- package/dist/_util/statusUtils.d.ts +6 -0
- package/dist/_util/throttleByAnimationFrame.d.ts +8 -0
- package/dist/_util/type.d.ts +9 -0
- package/dist/_util/warning.d.ts +6 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.umd.js +10843 -131
- package/dist/index.umd.min.js +6 -6
- package/es/Affix/index.d.ts +54 -0
- package/es/Affix/index.js +326 -0
- package/es/Affix/style/index.css +505 -0
- package/es/Affix/style/index.d.ts +1 -0
- package/es/Affix/style/index.js +1 -0
- package/es/Affix/utils.d.ts +15 -0
- package/es/Affix/utils.js +83 -0
- package/es/Button/index.d.ts +4 -0
- package/es/Button/index.js +1 -1
- package/es/CardTable/body/TableBodyCell.js +3 -0
- package/es/CardTable/card/PictureTextRow.js +13 -50
- package/es/CardTable/card/PictureTextRowOperate.js +130 -0
- package/es/CardTable/fns/index.js +6 -5
- package/es/CardTable/style/index.css +158 -10
- package/es/CustomTableOption/cardSort.d.ts +4 -0
- package/es/CustomTableOption/cardSort.js +222 -0
- package/es/CustomTableOption/index.d.ts +1 -0
- package/es/CustomTableOption/index.js +35 -11
- package/es/CustomTableOption/style/index.css +3 -0
- package/es/DatePicker/PickerButton.d.ts +2 -0
- package/es/DatePicker/PickerButton.js +8 -0
- package/es/DatePicker/PickerTag.d.ts +2 -0
- package/es/DatePicker/PickerTag.js +7 -0
- package/es/DatePicker/generatePicker/generateRangePicker.d.ts +4 -0
- package/es/DatePicker/generatePicker/generateRangePicker.js +142 -0
- package/es/DatePicker/generatePicker/generateSinglePicker.d.ts +14 -0
- package/es/DatePicker/generatePicker/generateSinglePicker.js +170 -0
- package/es/DatePicker/generatePicker/index.d.ts +106 -0
- package/es/DatePicker/generatePicker/index.js +84 -0
- package/es/DatePicker/generatePicker/interface.d.ts +12 -0
- package/es/DatePicker/generatePicker/interface.js +1 -0
- package/es/DatePicker/index.d.ts +17 -0
- package/es/DatePicker/index.js +7 -0
- package/es/DatePicker/style/index.css +505 -0
- package/es/DatePicker/style/index.d.ts +1 -0
- package/es/DatePicker/style/index.js +1 -0
- package/es/DatePicker/util.d.ts +14 -0
- package/es/DatePicker/util.js +111 -0
- package/es/Descriptions/style/index.css +10 -8
- package/es/IconFont/index.js +3 -2
- package/es/LmEditTable/DragHandle.js +1 -1
- package/es/LmEditTable/EditTable.js +27 -35
- package/es/LmFilter/Controls/CheckboxTags.js +53 -0
- package/es/LmFilter/Controls/index.js +47 -0
- package/es/LmFilter/LmFilter.js +17 -5
- package/es/LmFilter/baseFilter/fuzzySearch.js +53 -0
- package/es/LmFilter/baseFilter/index.js +1 -1
- package/es/LmFilter/clearFilter/index.js +3 -1
- package/es/LmFilter/complexFilter/drawer.js +376 -0
- package/es/LmFilter/complexFilter/index.js +50 -3
- package/es/LmFilter/complexFilter/valueDrawer.js +238 -0
- package/es/LmFilter/components/CascaderFilter.js +17 -41
- package/es/LmFilter/components/DateFilter.js +12 -20
- package/es/LmFilter/components/DropdownFIlter.js +79 -12
- package/es/LmFilter/components/index.js +56 -13
- package/es/LmFilter/filterFns/index.js +22 -3
- package/es/LmFilter/hooks/useDelayedFn.js +8 -6
- package/es/LmFilter/localization.d.ts +8 -0
- package/es/LmFilter/localization.js +12 -0
- package/es/LmFilter/style/style.css +27 -4
- package/es/LmFilter/utils.js +16 -0
- package/es/LmFilter/wrapper/FilterRoot.js +62 -6
- package/es/LmTable/Table.js +9 -4
- package/es/QuickMenu/index.d.ts +14 -0
- package/es/QuickMenu/index.js +171 -0
- package/es/QuickMenu/style/index.css +560 -0
- package/es/QuickMenu/style/index.d.ts +1 -0
- package/es/QuickMenu/style/index.js +1 -0
- package/es/Switch/index.d.ts +2 -1
- package/es/Switch/index.js +33 -1
- package/es/Switch/style/index.css +41 -0
- package/es/Tag/index.d.ts +4 -0
- package/es/Tag/index.js +48 -2
- package/es/Tag/style/index.css +4 -1
- package/es/Upload/index.d.ts +5 -1
- package/es/Upload/index.js +7 -2
- package/es/Upload/style/index.css +35 -0
- package/es/_util/domTarget.d.ts +7 -0
- package/es/_util/domTarget.js +20 -0
- package/es/_util/motion.d.ts +8 -0
- package/es/_util/motion.js +60 -0
- package/es/_util/statusUtils.d.ts +6 -0
- package/es/_util/statusUtils.js +12 -0
- package/es/_util/throttleByAnimationFrame.d.ts +8 -0
- package/es/_util/throttleByAnimationFrame.js +58 -0
- package/es/_util/type.d.ts +9 -0
- package/es/_util/type.js +15 -0
- package/es/_util/warning.d.ts +6 -0
- package/es/_util/warning.js +17 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -1
- package/es/message/index.d.ts +5 -5
- package/lib/Affix/index.d.ts +54 -0
- package/lib/Affix/index.js +349 -0
- package/lib/Affix/style/index.css +505 -0
- package/lib/Affix/style/index.d.ts +1 -0
- package/lib/Affix/style/index.js +3 -0
- package/lib/Affix/utils.d.ts +15 -0
- package/lib/Affix/utils.js +104 -0
- package/lib/Button/index.d.ts +4 -0
- package/lib/Button/index.js +1 -1
- package/lib/CardTable/body/TableBodyCell.js +3 -0
- package/lib/CardTable/card/PictureTextRow.js +13 -50
- package/lib/CardTable/card/PictureTextRowOperate.js +130 -0
- package/lib/CardTable/fns/index.js +6 -5
- package/lib/CardTable/style/index.css +158 -10
- package/lib/CustomTableOption/cardSort.d.ts +4 -0
- package/lib/CustomTableOption/cardSort.js +242 -0
- package/lib/CustomTableOption/index.d.ts +1 -0
- package/lib/CustomTableOption/index.js +36 -11
- package/lib/CustomTableOption/style/index.css +3 -0
- package/lib/DatePicker/PickerButton.d.ts +2 -0
- package/lib/DatePicker/PickerButton.js +19 -0
- package/lib/DatePicker/PickerTag.d.ts +2 -0
- package/lib/DatePicker/PickerTag.js +18 -0
- package/lib/DatePicker/generatePicker/generateRangePicker.d.ts +4 -0
- package/lib/DatePicker/generatePicker/generateRangePicker.js +168 -0
- package/lib/DatePicker/generatePicker/generateSinglePicker.d.ts +14 -0
- package/lib/DatePicker/generatePicker/generateSinglePicker.js +196 -0
- package/lib/DatePicker/generatePicker/index.d.ts +106 -0
- package/lib/DatePicker/generatePicker/index.js +102 -0
- package/lib/DatePicker/generatePicker/interface.d.ts +12 -0
- package/lib/DatePicker/generatePicker/interface.js +5 -0
- package/lib/DatePicker/index.d.ts +17 -0
- package/lib/DatePicker/index.js +21 -0
- package/lib/DatePicker/style/index.css +505 -0
- package/lib/DatePicker/style/index.d.ts +1 -0
- package/lib/DatePicker/style/index.js +3 -0
- package/lib/DatePicker/util.d.ts +14 -0
- package/lib/DatePicker/util.js +122 -0
- package/lib/Descriptions/style/index.css +10 -8
- package/lib/IconFont/index.js +3 -2
- package/lib/LmEditTable/DragHandle.js +1 -1
- package/lib/LmEditTable/EditTable.js +26 -36
- package/lib/LmFilter/Controls/CheckboxTags.js +53 -0
- package/lib/LmFilter/Controls/index.js +47 -0
- package/lib/LmFilter/LmFilter.js +17 -5
- package/lib/LmFilter/baseFilter/fuzzySearch.js +53 -0
- package/lib/LmFilter/baseFilter/index.js +1 -1
- package/lib/LmFilter/clearFilter/index.js +3 -1
- package/lib/LmFilter/complexFilter/drawer.js +376 -0
- package/lib/LmFilter/complexFilter/index.js +50 -3
- package/lib/LmFilter/complexFilter/valueDrawer.js +238 -0
- package/lib/LmFilter/components/CascaderFilter.js +17 -41
- package/lib/LmFilter/components/DateFilter.js +12 -20
- package/lib/LmFilter/components/DropdownFIlter.js +79 -12
- package/lib/LmFilter/components/index.js +56 -13
- package/lib/LmFilter/filterFns/index.js +22 -3
- package/lib/LmFilter/hooks/useDelayedFn.js +8 -6
- package/lib/LmFilter/localization.d.ts +8 -0
- package/lib/LmFilter/localization.js +19 -0
- package/lib/LmFilter/style/style.css +27 -4
- package/lib/LmFilter/utils.js +16 -0
- package/lib/LmFilter/wrapper/FilterRoot.js +62 -6
- package/lib/LmTable/Table.js +9 -4
- package/lib/QuickMenu/index.d.ts +14 -0
- package/lib/QuickMenu/index.js +189 -0
- package/lib/QuickMenu/style/index.css +560 -0
- package/lib/QuickMenu/style/index.d.ts +1 -0
- package/lib/QuickMenu/style/index.js +3 -0
- package/lib/Switch/index.d.ts +2 -1
- package/lib/Switch/index.js +34 -1
- package/lib/Switch/style/index.css +41 -0
- package/lib/Tag/index.d.ts +4 -0
- package/lib/Tag/index.js +48 -1
- package/lib/Tag/style/index.css +4 -1
- package/lib/Upload/index.d.ts +5 -1
- package/lib/Upload/index.js +8 -2
- package/lib/Upload/style/index.css +35 -0
- package/lib/_util/domTarget.d.ts +7 -0
- package/lib/_util/domTarget.js +31 -0
- package/lib/_util/motion.d.ts +8 -0
- package/lib/_util/motion.js +71 -0
- package/lib/_util/statusUtils.d.ts +6 -0
- package/lib/_util/statusUtils.js +29 -0
- package/lib/_util/throttleByAnimationFrame.d.ts +8 -0
- package/lib/_util/throttleByAnimationFrame.js +72 -0
- package/lib/_util/type.d.ts +9 -0
- package/lib/_util/type.js +27 -0
- package/lib/_util/warning.d.ts +6 -0
- package/lib/_util/warning.js +35 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +17 -1
- package/lib/message/index.d.ts +5 -5
- package/package.json +5 -2
- package/es/LmFilter/components/fuzzySearch.js +0 -37
- package/lib/LmFilter/components/fuzzySearch.js +0 -37
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ConfigConsumerProps } from 'antd/es/config-provider';
|
|
3
|
+
export interface AffixProps {
|
|
4
|
+
/** 距离窗口顶部达到指定偏移量后触发 */
|
|
5
|
+
offsetTop?: number;
|
|
6
|
+
/** 距离窗口底部达到指定偏移量后触发 */
|
|
7
|
+
offsetBottom?: number;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
/** 固定状态改变时触发的回调函数 */
|
|
10
|
+
onChange?: (affixed?: boolean) => void;
|
|
11
|
+
/** 设置 Affix 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 */
|
|
12
|
+
target?: () => Window | HTMLElement | null;
|
|
13
|
+
prefixCls?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
interface InternalAffixProps extends AffixProps {
|
|
18
|
+
affixPrefixCls: string;
|
|
19
|
+
}
|
|
20
|
+
declare enum AffixStatus {
|
|
21
|
+
None = 0,
|
|
22
|
+
Prepare = 1
|
|
23
|
+
}
|
|
24
|
+
export interface AffixState {
|
|
25
|
+
affixStyle?: React.CSSProperties;
|
|
26
|
+
placeholderStyle?: React.CSSProperties;
|
|
27
|
+
status: AffixStatus;
|
|
28
|
+
lastAffix: boolean;
|
|
29
|
+
prevTarget: Window | HTMLElement | null;
|
|
30
|
+
}
|
|
31
|
+
declare class Affix extends React.Component<InternalAffixProps, AffixState> {
|
|
32
|
+
static contextType: React.Context<ConfigConsumerProps>;
|
|
33
|
+
state: AffixState;
|
|
34
|
+
placeholderNode: HTMLDivElement;
|
|
35
|
+
fixedNode: HTMLDivElement;
|
|
36
|
+
private timeout;
|
|
37
|
+
context: ConfigConsumerProps;
|
|
38
|
+
private getTargetFunc;
|
|
39
|
+
componentDidMount(): void;
|
|
40
|
+
componentDidUpdate(prevProps: AffixProps): void;
|
|
41
|
+
componentWillUnmount(): void;
|
|
42
|
+
getOffsetTop: () => number;
|
|
43
|
+
getOffsetBottom: () => number;
|
|
44
|
+
savePlaceholderNode: (node: HTMLDivElement) => void;
|
|
45
|
+
saveFixedNode: (node: HTMLDivElement) => void;
|
|
46
|
+
measure: () => void;
|
|
47
|
+
prepareMeasure: () => void;
|
|
48
|
+
updatePosition(): void;
|
|
49
|
+
lazyUpdatePosition(): void;
|
|
50
|
+
render(): JSX.Element;
|
|
51
|
+
}
|
|
52
|
+
export declare type InternalAffixClass = Affix;
|
|
53
|
+
declare const AffixFC: React.ForwardRefExoticComponent<AffixProps & React.RefAttributes<Affix>>;
|
|
54
|
+
export default AffixFC;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import "antd/es/affix/style";
|
|
2
|
+
import _Affix from "antd/es/affix";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
9
|
+
|
|
10
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length,
|
|
12
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
13
|
+
d;
|
|
14
|
+
if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
16
|
+
}
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
import classNames from 'classnames';
|
|
21
|
+
import ResizeObserver from 'rc-resize-observer';
|
|
22
|
+
import omit from 'rc-util/lib/omit';
|
|
23
|
+
import * as React from 'react';
|
|
24
|
+
import { ConfigContext } from 'antd/es/config-provider';
|
|
25
|
+
import { throttleByAnimationFrameDecorator } from '../_util/throttleByAnimationFrame';
|
|
26
|
+
import { addObserveTarget, getFixedBottom, getFixedTop, getTargetRect, removeObserveTarget } from './utils';
|
|
27
|
+
|
|
28
|
+
function getDefaultTarget() {
|
|
29
|
+
return typeof window !== 'undefined' ? window : null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var AffixStatus;
|
|
33
|
+
|
|
34
|
+
(function (AffixStatus) {
|
|
35
|
+
AffixStatus[AffixStatus["None"] = 0] = "None";
|
|
36
|
+
AffixStatus[AffixStatus["Prepare"] = 1] = "Prepare";
|
|
37
|
+
})(AffixStatus || (AffixStatus = {}));
|
|
38
|
+
|
|
39
|
+
var Affix = /*#__PURE__*/function (_React$Component) {
|
|
40
|
+
_inherits(Affix, _React$Component);
|
|
41
|
+
|
|
42
|
+
var _super = _createSuper(Affix);
|
|
43
|
+
|
|
44
|
+
function Affix() {
|
|
45
|
+
var _this;
|
|
46
|
+
|
|
47
|
+
_classCallCheck(this, Affix);
|
|
48
|
+
|
|
49
|
+
_this = _super.apply(this, arguments);
|
|
50
|
+
_this.state = {
|
|
51
|
+
status: AffixStatus.None,
|
|
52
|
+
lastAffix: false,
|
|
53
|
+
prevTarget: null
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
_this.getOffsetTop = function () {
|
|
57
|
+
var _this$props = _this.props,
|
|
58
|
+
offsetBottom = _this$props.offsetBottom,
|
|
59
|
+
offsetTop = _this$props.offsetTop;
|
|
60
|
+
return offsetBottom === undefined && offsetTop === undefined ? 0 : offsetTop;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
_this.getOffsetBottom = function () {
|
|
64
|
+
return _this.props.offsetBottom;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
_this.savePlaceholderNode = function (node) {
|
|
68
|
+
_this.placeholderNode = node;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
_this.saveFixedNode = function (node) {
|
|
72
|
+
_this.fixedNode = node;
|
|
73
|
+
}; // =================== Measure ===================
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
_this.measure = function () {
|
|
77
|
+
var _this$state = _this.state,
|
|
78
|
+
status = _this$state.status,
|
|
79
|
+
lastAffix = _this$state.lastAffix;
|
|
80
|
+
var onChange = _this.props.onChange;
|
|
81
|
+
|
|
82
|
+
var targetFunc = _this.getTargetFunc();
|
|
83
|
+
|
|
84
|
+
if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !targetFunc) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var offsetTop = _this.getOffsetTop();
|
|
89
|
+
|
|
90
|
+
var offsetBottom = _this.getOffsetBottom();
|
|
91
|
+
|
|
92
|
+
var targetNode = targetFunc();
|
|
93
|
+
|
|
94
|
+
if (!targetNode) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var newState = {
|
|
99
|
+
status: AffixStatus.None
|
|
100
|
+
};
|
|
101
|
+
var targetRect = getTargetRect(targetNode);
|
|
102
|
+
var placeholderReact = getTargetRect(_this.placeholderNode);
|
|
103
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
|
104
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
|
105
|
+
|
|
106
|
+
if (fixedTop !== undefined) {
|
|
107
|
+
newState.affixStyle = {
|
|
108
|
+
position: 'fixed',
|
|
109
|
+
top: fixedTop,
|
|
110
|
+
width: placeholderReact.width,
|
|
111
|
+
height: placeholderReact.height
|
|
112
|
+
};
|
|
113
|
+
newState.placeholderStyle = {
|
|
114
|
+
width: placeholderReact.width,
|
|
115
|
+
height: placeholderReact.height
|
|
116
|
+
};
|
|
117
|
+
} else if (fixedBottom !== undefined) {
|
|
118
|
+
newState.affixStyle = {
|
|
119
|
+
position: 'fixed',
|
|
120
|
+
bottom: fixedBottom,
|
|
121
|
+
width: placeholderReact.width,
|
|
122
|
+
height: placeholderReact.height
|
|
123
|
+
};
|
|
124
|
+
newState.placeholderStyle = {
|
|
125
|
+
width: placeholderReact.width,
|
|
126
|
+
height: placeholderReact.height
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
newState.lastAffix = !!newState.affixStyle;
|
|
131
|
+
|
|
132
|
+
if (onChange && lastAffix !== newState.lastAffix) {
|
|
133
|
+
onChange(newState.lastAffix);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
_this.setState(newState);
|
|
137
|
+
}; // @ts-ignore TS6133
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
_this.prepareMeasure = function () {
|
|
141
|
+
// event param is used before. Keep compatible ts define here.
|
|
142
|
+
_this.setState({
|
|
143
|
+
status: AffixStatus.Prepare,
|
|
144
|
+
affixStyle: undefined,
|
|
145
|
+
placeholderStyle: undefined
|
|
146
|
+
}); // Test if `updatePosition` called
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
if (process.env.NODE_ENV === 'test') {
|
|
150
|
+
var onTestUpdatePosition = _this.props.onTestUpdatePosition;
|
|
151
|
+
onTestUpdatePosition === null || onTestUpdatePosition === void 0 ? void 0 : onTestUpdatePosition();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
return _this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_createClass(Affix, [{
|
|
159
|
+
key: "getTargetFunc",
|
|
160
|
+
value: function getTargetFunc() {
|
|
161
|
+
var getTargetContainer = this.context.getTargetContainer;
|
|
162
|
+
var target = this.props.target;
|
|
163
|
+
|
|
164
|
+
if (target !== undefined) {
|
|
165
|
+
return target;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return getTargetContainer || getDefaultTarget;
|
|
169
|
+
} // Event handler
|
|
170
|
+
|
|
171
|
+
}, {
|
|
172
|
+
key: "componentDidMount",
|
|
173
|
+
value: function componentDidMount() {
|
|
174
|
+
var _this2 = this;
|
|
175
|
+
|
|
176
|
+
var targetFunc = this.getTargetFunc();
|
|
177
|
+
|
|
178
|
+
if (targetFunc) {
|
|
179
|
+
// [Legacy] Wait for parent component ref has its value.
|
|
180
|
+
// We should use target as directly element instead of function which makes element check hard.
|
|
181
|
+
this.timeout = setTimeout(function () {
|
|
182
|
+
addObserveTarget(targetFunc(), _this2); // Mock Event object.
|
|
183
|
+
|
|
184
|
+
_this2.updatePosition();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "componentDidUpdate",
|
|
190
|
+
value: function componentDidUpdate(prevProps) {
|
|
191
|
+
var prevTarget = this.state.prevTarget;
|
|
192
|
+
var targetFunc = this.getTargetFunc();
|
|
193
|
+
var newTarget = (targetFunc === null || targetFunc === void 0 ? void 0 : targetFunc()) || null;
|
|
194
|
+
|
|
195
|
+
if (prevTarget !== newTarget) {
|
|
196
|
+
removeObserveTarget(this);
|
|
197
|
+
|
|
198
|
+
if (newTarget) {
|
|
199
|
+
addObserveTarget(newTarget, this); // Mock Event object.
|
|
200
|
+
|
|
201
|
+
this.updatePosition();
|
|
202
|
+
} // eslint-disable-next-line react/no-did-update-set-state
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
this.setState({
|
|
206
|
+
prevTarget: newTarget
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {
|
|
211
|
+
this.updatePosition();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.measure();
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "componentWillUnmount",
|
|
218
|
+
value: function componentWillUnmount() {
|
|
219
|
+
clearTimeout(this.timeout);
|
|
220
|
+
removeObserveTarget(this);
|
|
221
|
+
this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683
|
|
222
|
+
|
|
223
|
+
this.lazyUpdatePosition.cancel();
|
|
224
|
+
} // Handle realign logic
|
|
225
|
+
|
|
226
|
+
}, {
|
|
227
|
+
key: "updatePosition",
|
|
228
|
+
value: function updatePosition() {
|
|
229
|
+
this.prepareMeasure();
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "lazyUpdatePosition",
|
|
233
|
+
value: function lazyUpdatePosition() {
|
|
234
|
+
var targetFunc = this.getTargetFunc();
|
|
235
|
+
var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth
|
|
236
|
+
|
|
237
|
+
if (targetFunc && affixStyle) {
|
|
238
|
+
var offsetTop = this.getOffsetTop();
|
|
239
|
+
var offsetBottom = this.getOffsetBottom();
|
|
240
|
+
var targetNode = targetFunc();
|
|
241
|
+
|
|
242
|
+
if (targetNode && this.placeholderNode) {
|
|
243
|
+
var targetRect = getTargetRect(targetNode);
|
|
244
|
+
var placeholderReact = getTargetRect(this.placeholderNode);
|
|
245
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
|
246
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
|
247
|
+
|
|
248
|
+
if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
} // Directly call prepare measure since it's already throttled.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
this.prepareMeasure();
|
|
256
|
+
} // =================== Render ===================
|
|
257
|
+
|
|
258
|
+
}, {
|
|
259
|
+
key: "render",
|
|
260
|
+
value: function render() {
|
|
261
|
+
var _this3 = this;
|
|
262
|
+
|
|
263
|
+
var _this$state2 = this.state,
|
|
264
|
+
affixStyle = _this$state2.affixStyle,
|
|
265
|
+
placeholderStyle = _this$state2.placeholderStyle;
|
|
266
|
+
var _this$props2 = this.props,
|
|
267
|
+
affixPrefixCls = _this$props2.affixPrefixCls,
|
|
268
|
+
children = _this$props2.children;
|
|
269
|
+
var className = classNames(_defineProperty({}, affixPrefixCls, !!affixStyle));
|
|
270
|
+
var props = omit(this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange', 'affixPrefixCls']); // Omit this since `onTestUpdatePosition` only works on test.
|
|
271
|
+
|
|
272
|
+
if (process.env.NODE_ENV === 'test') {
|
|
273
|
+
props = omit(props, ['onTestUpdatePosition']);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
277
|
+
onResize: function onResize() {
|
|
278
|
+
_this3.updatePosition();
|
|
279
|
+
}
|
|
280
|
+
}, /*#__PURE__*/React.createElement("div", Object.assign({}, props, {
|
|
281
|
+
ref: this.savePlaceholderNode
|
|
282
|
+
}), affixStyle && /*#__PURE__*/React.createElement("div", {
|
|
283
|
+
style: placeholderStyle,
|
|
284
|
+
"aria-hidden": "true"
|
|
285
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
286
|
+
className: className,
|
|
287
|
+
ref: this.saveFixedNode,
|
|
288
|
+
style: affixStyle
|
|
289
|
+
}, /*#__PURE__*/React.createElement(ResizeObserver, {
|
|
290
|
+
onResize: function onResize() {
|
|
291
|
+
_this3.updatePosition();
|
|
292
|
+
}
|
|
293
|
+
}, children))));
|
|
294
|
+
}
|
|
295
|
+
}]);
|
|
296
|
+
|
|
297
|
+
return Affix;
|
|
298
|
+
}(React.Component);
|
|
299
|
+
|
|
300
|
+
Affix.contextType = ConfigContext;
|
|
301
|
+
|
|
302
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "updatePosition", null);
|
|
303
|
+
|
|
304
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "lazyUpdatePosition", null);
|
|
305
|
+
|
|
306
|
+
var AffixFC = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
307
|
+
var customizePrefixCls = props.prefixCls;
|
|
308
|
+
|
|
309
|
+
var _React$useContext = React.useContext(ConfigContext),
|
|
310
|
+
getPrefixCls = _React$useContext.getPrefixCls;
|
|
311
|
+
|
|
312
|
+
var affixPrefixCls = getPrefixCls('affix', customizePrefixCls);
|
|
313
|
+
var affixProps = Object.assign(Object.assign({}, props), {
|
|
314
|
+
affixPrefixCls: affixPrefixCls
|
|
315
|
+
});
|
|
316
|
+
return /*#__PURE__*/React.createElement(Affix, Object.assign({}, affixProps, {
|
|
317
|
+
ref: ref
|
|
318
|
+
}));
|
|
319
|
+
});
|
|
320
|
+
AffixFC.AntdAffix = _Affix;
|
|
321
|
+
|
|
322
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
323
|
+
AffixFC.displayName = 'Affix';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export default AffixFC;
|