@fle-ui/next 2.0.0-alpha.6 → 2.0.0-alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- package/es/affix/index.d.ts +54 -0
- package/es/affix/index.js +330 -0
- package/es/affix/style/css.js +2 -0
- package/es/affix/style/index-pure.less +6 -0
- package/es/affix/style/index.css +8 -0
- package/es/affix/style/index.d.ts +2 -0
- package/es/affix/style/index.js +2 -0
- package/es/affix/style/index.less +3 -0
- package/es/affix/utils.d.ts +15 -0
- package/es/affix/utils.js +86 -0
- package/es/config-provider/DisabledContext.d.ts +9 -0
- package/es/config-provider/DisabledContext.js +11 -0
- package/es/config-provider/SizeContext.d.ts +9 -0
- package/es/config-provider/SizeContext.js +12 -0
- package/es/config-provider/context.d.ts +58 -0
- package/es/config-provider/context.js +41 -0
- package/es/config-provider/cssVariables.d.ts +3 -0
- package/es/config-provider/cssVariables.js +97 -0
- package/es/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/es/config-provider/defaultRenderEmpty.js +36 -0
- package/es/config-provider/index.d.ts +61 -5
- package/es/config-provider/index.js +209 -10
- package/es/config-provider/style/css.js +1 -0
- package/es/config-provider/style/index-pure.less +2 -0
- package/es/config-provider/style/index.css +4 -0
- package/es/config-provider/style/index.d.ts +1 -0
- package/es/config-provider/style/index.js +1 -0
- package/es/config-provider/style/index.less +3 -0
- package/lib/config-provider/DisabledContext.d.ts +9 -0
- package/lib/config-provider/DisabledContext.js +25 -0
- package/lib/config-provider/SizeContext.d.ts +9 -0
- package/lib/config-provider/SizeContext.js +26 -0
- package/lib/config-provider/context.d.ts +58 -0
- package/lib/config-provider/context.js +57 -0
- package/lib/config-provider/cssVariables.d.ts +3 -0
- package/lib/config-provider/cssVariables.js +115 -0
- package/lib/config-provider/defaultRenderEmpty.d.ts +4 -0
- package/lib/config-provider/defaultRenderEmpty.js +50 -0
- package/lib/config-provider/index.d.ts +61 -5
- package/lib/config-provider/index.js +250 -10
- package/lib/config-provider/style/css.js +3 -0
- package/lib/config-provider/style/index-pure.less +2 -0
- package/lib/config-provider/style/index.css +4 -0
- package/lib/config-provider/style/index.d.ts +1 -0
- package/lib/config-provider/style/index.js +3 -0
- package/lib/config-provider/style/index.less +3 -0
- package/package.json +1 -2
- package/es/affix/ActionButton.d.ts +0 -15
- package/es/affix/ActionButton.js +0 -118
- package/es/affix/colors.d.ts +0 -5
- package/es/affix/colors.js +0 -4
- package/es/affix/easings.d.ts +0 -1
- package/es/affix/easings.js +0 -12
- package/es/affix/getDataOrAriaProps.d.ts +0 -1
- package/es/affix/getDataOrAriaProps.js +0 -9
- package/es/affix/getRenderPropValue.d.ts +0 -3
- package/es/affix/getRenderPropValue.js +0 -11
- package/es/affix/getScroll.d.ts +0 -2
- package/es/affix/getScroll.js +0 -34
- package/es/affix/hooks/useFlexGapSupport.d.ts +0 -2
- package/es/affix/hooks/useFlexGapSupport.js +0 -14
- package/es/affix/hooks/useForceUpdate.d.ts +0 -2
- package/es/affix/hooks/useForceUpdate.js +0 -11
- package/es/affix/hooks/usePatchElement.d.ts +0 -5
- package/es/affix/hooks/usePatchElement.js +0 -26
- package/es/affix/hooks/useSyncState.d.ts +0 -3
- package/es/affix/hooks/useSyncState.js +0 -13
- package/es/affix/isNumeric.d.ts +0 -2
- package/es/affix/isNumeric.js +0 -5
- package/es/affix/motion.d.ts +0 -8
- package/es/affix/motion.js +0 -60
- package/es/affix/placements.d.ts +0 -17
- package/es/affix/placements.js +0 -88
- package/es/affix/raf.d.ts +0 -9
- package/es/affix/raf.js +0 -31
- package/es/affix/reactNode.d.ts +0 -8
- package/es/affix/reactNode.js +0 -16
- package/es/affix/responsiveObserve.d.ts +0 -21
- package/es/affix/responsiveObserve.js +0 -67
- package/es/affix/scrollTo.d.ts +0 -10
- package/es/affix/scrollTo.js +0 -38
- package/es/affix/statusUtils.d.ts +0 -6
- package/es/affix/statusUtils.js +0 -12
- package/es/affix/styleChecker.d.ts +0 -4
- package/es/affix/styleChecker.js +0 -31
- package/es/affix/throttleByAnimationFrame.d.ts +0 -8
- package/es/affix/throttleByAnimationFrame.js +0 -58
- package/es/affix/transButton.d.ts +0 -9
- package/es/affix/transButton.js +0 -75
- package/es/affix/type.d.ts +0 -9
- package/es/affix/type.js +0 -15
- package/es/affix/warning.d.ts +0 -6
- package/es/affix/warning.js +0 -17
- package/es/affix/wave.d.ts +0 -32
- package/es/affix/wave.js +0 -247
@@ -0,0 +1,54 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { ConfigConsumerProps } from '../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 | undefined;
|
43
|
+
getOffsetBottom: () => number | undefined;
|
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 type InternalAffixClass = Affix;
|
53
|
+
declare const AffixFC: React.ForwardRefExoticComponent<AffixProps & React.RefAttributes<Affix>>;
|
54
|
+
export default AffixFC;
|
@@ -0,0 +1,330 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
7
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
8
|
+
|
9
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
10
|
+
var c = arguments.length,
|
11
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
12
|
+
d;
|
13
|
+
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--) {
|
14
|
+
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
15
|
+
}
|
16
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
17
|
+
};
|
18
|
+
|
19
|
+
import classNames from 'classnames';
|
20
|
+
import ResizeObserver from 'rc-resize-observer';
|
21
|
+
import omit from "rc-util/es/omit";
|
22
|
+
import * as React from 'react';
|
23
|
+
import { ConfigContext } from "../config-provider";
|
24
|
+
import { throttleByAnimationFrameDecorator } from "../_util/throttleByAnimationFrame";
|
25
|
+
import { addObserveTarget, getFixedBottom, getFixedTop, getTargetRect, removeObserveTarget } from "./utils";
|
26
|
+
|
27
|
+
function getDefaultTarget() {
|
28
|
+
return typeof window !== 'undefined' ? window : null;
|
29
|
+
}
|
30
|
+
|
31
|
+
var AffixStatus;
|
32
|
+
|
33
|
+
(function (AffixStatus) {
|
34
|
+
AffixStatus[AffixStatus["None"] = 0] = "None";
|
35
|
+
AffixStatus[AffixStatus["Prepare"] = 1] = "Prepare";
|
36
|
+
})(AffixStatus || (AffixStatus = {}));
|
37
|
+
|
38
|
+
var Affix = /*#__PURE__*/function (_React$Component) {
|
39
|
+
_inherits(Affix, _React$Component);
|
40
|
+
|
41
|
+
var _super = _createSuper(Affix);
|
42
|
+
|
43
|
+
function Affix() {
|
44
|
+
var _this;
|
45
|
+
|
46
|
+
_classCallCheck(this, Affix);
|
47
|
+
|
48
|
+
_this = _super.apply(this, arguments);
|
49
|
+
_this.state = {
|
50
|
+
status: AffixStatus.None,
|
51
|
+
lastAffix: false,
|
52
|
+
prevTarget: null
|
53
|
+
};
|
54
|
+
|
55
|
+
_this.getOffsetTop = function () {
|
56
|
+
var _this$props = _this.props,
|
57
|
+
offsetBottom = _this$props.offsetBottom,
|
58
|
+
offsetTop = _this$props.offsetTop;
|
59
|
+
return offsetBottom === undefined && offsetTop === undefined ? 0 : offsetTop;
|
60
|
+
};
|
61
|
+
|
62
|
+
_this.getOffsetBottom = function () {
|
63
|
+
return _this.props.offsetBottom;
|
64
|
+
};
|
65
|
+
|
66
|
+
_this.savePlaceholderNode = function (node) {
|
67
|
+
_this.placeholderNode = node;
|
68
|
+
};
|
69
|
+
|
70
|
+
_this.saveFixedNode = function (node) {
|
71
|
+
_this.fixedNode = node;
|
72
|
+
}; // =================== Measure ===================
|
73
|
+
|
74
|
+
|
75
|
+
_this.measure = function () {
|
76
|
+
var _this$state = _this.state,
|
77
|
+
status = _this$state.status,
|
78
|
+
lastAffix = _this$state.lastAffix;
|
79
|
+
var onChange = _this.props.onChange;
|
80
|
+
|
81
|
+
var targetFunc = _this.getTargetFunc();
|
82
|
+
|
83
|
+
if (status !== AffixStatus.Prepare || !_this.fixedNode || !_this.placeholderNode || !targetFunc) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
var offsetTop = _this.getOffsetTop();
|
88
|
+
|
89
|
+
var offsetBottom = _this.getOffsetBottom();
|
90
|
+
|
91
|
+
var targetNode = targetFunc();
|
92
|
+
|
93
|
+
if (!targetNode) {
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
|
97
|
+
var newState = {
|
98
|
+
status: AffixStatus.None
|
99
|
+
};
|
100
|
+
var targetRect = getTargetRect(targetNode);
|
101
|
+
var placeholderReact = getTargetRect(_this.placeholderNode);
|
102
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
103
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
104
|
+
|
105
|
+
if (placeholderReact.top === 0 && placeholderReact.left === 0 && placeholderReact.width === 0 && placeholderReact.height === 0) {
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
|
109
|
+
if (fixedTop !== undefined) {
|
110
|
+
newState.affixStyle = {
|
111
|
+
position: 'fixed',
|
112
|
+
top: fixedTop,
|
113
|
+
width: placeholderReact.width,
|
114
|
+
height: placeholderReact.height
|
115
|
+
};
|
116
|
+
newState.placeholderStyle = {
|
117
|
+
width: placeholderReact.width,
|
118
|
+
height: placeholderReact.height
|
119
|
+
};
|
120
|
+
} else if (fixedBottom !== undefined) {
|
121
|
+
newState.affixStyle = {
|
122
|
+
position: 'fixed',
|
123
|
+
bottom: fixedBottom,
|
124
|
+
width: placeholderReact.width,
|
125
|
+
height: placeholderReact.height
|
126
|
+
};
|
127
|
+
newState.placeholderStyle = {
|
128
|
+
width: placeholderReact.width,
|
129
|
+
height: placeholderReact.height
|
130
|
+
};
|
131
|
+
}
|
132
|
+
|
133
|
+
newState.lastAffix = !!newState.affixStyle;
|
134
|
+
|
135
|
+
if (onChange && lastAffix !== newState.lastAffix) {
|
136
|
+
onChange(newState.lastAffix);
|
137
|
+
}
|
138
|
+
|
139
|
+
_this.setState(newState);
|
140
|
+
}; // @ts-ignore TS6133
|
141
|
+
|
142
|
+
|
143
|
+
_this.prepareMeasure = function () {
|
144
|
+
// event param is used before. Keep compatible ts define here.
|
145
|
+
_this.setState({
|
146
|
+
status: AffixStatus.Prepare,
|
147
|
+
affixStyle: undefined,
|
148
|
+
placeholderStyle: undefined
|
149
|
+
}); // Test if `updatePosition` called
|
150
|
+
|
151
|
+
|
152
|
+
if (process.env.NODE_ENV === 'test') {
|
153
|
+
var onTestUpdatePosition = _this.props.onTestUpdatePosition;
|
154
|
+
onTestUpdatePosition === null || onTestUpdatePosition === void 0 ? void 0 : onTestUpdatePosition();
|
155
|
+
}
|
156
|
+
};
|
157
|
+
|
158
|
+
return _this;
|
159
|
+
}
|
160
|
+
|
161
|
+
_createClass(Affix, [{
|
162
|
+
key: "getTargetFunc",
|
163
|
+
value: function getTargetFunc() {
|
164
|
+
var getTargetContainer = this.context.getTargetContainer;
|
165
|
+
var target = this.props.target;
|
166
|
+
|
167
|
+
if (target !== undefined) {
|
168
|
+
return target;
|
169
|
+
}
|
170
|
+
|
171
|
+
return getTargetContainer !== null && getTargetContainer !== void 0 ? getTargetContainer : getDefaultTarget;
|
172
|
+
} // Event handler
|
173
|
+
|
174
|
+
}, {
|
175
|
+
key: "componentDidMount",
|
176
|
+
value: function componentDidMount() {
|
177
|
+
var _this2 = this;
|
178
|
+
|
179
|
+
var targetFunc = this.getTargetFunc();
|
180
|
+
|
181
|
+
if (targetFunc) {
|
182
|
+
// [Legacy] Wait for parent component ref has its value.
|
183
|
+
// We should use target as directly element instead of function which makes element check hard.
|
184
|
+
this.timeout = setTimeout(function () {
|
185
|
+
addObserveTarget(targetFunc(), _this2); // Mock Event object.
|
186
|
+
|
187
|
+
_this2.updatePosition();
|
188
|
+
});
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}, {
|
192
|
+
key: "componentDidUpdate",
|
193
|
+
value: function componentDidUpdate(prevProps) {
|
194
|
+
var prevTarget = this.state.prevTarget;
|
195
|
+
var targetFunc = this.getTargetFunc();
|
196
|
+
var newTarget = (targetFunc === null || targetFunc === void 0 ? void 0 : targetFunc()) || null;
|
197
|
+
|
198
|
+
if (prevTarget !== newTarget) {
|
199
|
+
removeObserveTarget(this);
|
200
|
+
|
201
|
+
if (newTarget) {
|
202
|
+
addObserveTarget(newTarget, this); // Mock Event object.
|
203
|
+
|
204
|
+
this.updatePosition();
|
205
|
+
} // eslint-disable-next-line react/no-did-update-set-state
|
206
|
+
|
207
|
+
|
208
|
+
this.setState({
|
209
|
+
prevTarget: newTarget
|
210
|
+
});
|
211
|
+
}
|
212
|
+
|
213
|
+
if (prevProps.offsetTop !== this.props.offsetTop || prevProps.offsetBottom !== this.props.offsetBottom) {
|
214
|
+
this.updatePosition();
|
215
|
+
}
|
216
|
+
|
217
|
+
this.measure();
|
218
|
+
}
|
219
|
+
}, {
|
220
|
+
key: "componentWillUnmount",
|
221
|
+
value: function componentWillUnmount() {
|
222
|
+
clearTimeout(this.timeout);
|
223
|
+
removeObserveTarget(this);
|
224
|
+
this.updatePosition.cancel(); // https://github.com/ant-design/ant-design/issues/22683
|
225
|
+
|
226
|
+
this.lazyUpdatePosition.cancel();
|
227
|
+
} // Handle realign logic
|
228
|
+
|
229
|
+
}, {
|
230
|
+
key: "updatePosition",
|
231
|
+
value: function updatePosition() {
|
232
|
+
this.prepareMeasure();
|
233
|
+
}
|
234
|
+
}, {
|
235
|
+
key: "lazyUpdatePosition",
|
236
|
+
value: function lazyUpdatePosition() {
|
237
|
+
var targetFunc = this.getTargetFunc();
|
238
|
+
var affixStyle = this.state.affixStyle; // Check position change before measure to make Safari smooth
|
239
|
+
|
240
|
+
if (targetFunc && affixStyle) {
|
241
|
+
var offsetTop = this.getOffsetTop();
|
242
|
+
var offsetBottom = this.getOffsetBottom();
|
243
|
+
var targetNode = targetFunc();
|
244
|
+
|
245
|
+
if (targetNode && this.placeholderNode) {
|
246
|
+
var targetRect = getTargetRect(targetNode);
|
247
|
+
var placeholderReact = getTargetRect(this.placeholderNode);
|
248
|
+
var fixedTop = getFixedTop(placeholderReact, targetRect, offsetTop);
|
249
|
+
var fixedBottom = getFixedBottom(placeholderReact, targetRect, offsetBottom);
|
250
|
+
|
251
|
+
if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {
|
252
|
+
return;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
} // Directly call prepare measure since it's already throttled.
|
256
|
+
|
257
|
+
|
258
|
+
this.prepareMeasure();
|
259
|
+
} // =================== Render ===================
|
260
|
+
|
261
|
+
}, {
|
262
|
+
key: "render",
|
263
|
+
value: function render() {
|
264
|
+
var _this3 = this;
|
265
|
+
|
266
|
+
var _this$state2 = this.state,
|
267
|
+
affixStyle = _this$state2.affixStyle,
|
268
|
+
placeholderStyle = _this$state2.placeholderStyle;
|
269
|
+
var _this$props2 = this.props,
|
270
|
+
affixPrefixCls = _this$props2.affixPrefixCls,
|
271
|
+
children = _this$props2.children;
|
272
|
+
var className = classNames(_defineProperty({}, affixPrefixCls, !!affixStyle));
|
273
|
+
var props = omit(this.props, ['prefixCls', 'offsetTop', 'offsetBottom', 'target', 'onChange', 'affixPrefixCls']); // Omit this since `onTestUpdatePosition` only works on test.
|
274
|
+
|
275
|
+
if (process.env.NODE_ENV === 'test') {
|
276
|
+
props = omit(props, ['onTestUpdatePosition']);
|
277
|
+
}
|
278
|
+
|
279
|
+
return /*#__PURE__*/React.createElement(ResizeObserver, {
|
280
|
+
onResize: function onResize() {
|
281
|
+
_this3.updatePosition();
|
282
|
+
}
|
283
|
+
}, /*#__PURE__*/React.createElement("div", _extends({}, props, {
|
284
|
+
ref: this.savePlaceholderNode
|
285
|
+
}), affixStyle && /*#__PURE__*/React.createElement("div", {
|
286
|
+
style: placeholderStyle,
|
287
|
+
"aria-hidden": "true"
|
288
|
+
}), /*#__PURE__*/React.createElement("div", {
|
289
|
+
className: className,
|
290
|
+
ref: this.saveFixedNode,
|
291
|
+
style: affixStyle
|
292
|
+
}, /*#__PURE__*/React.createElement(ResizeObserver, {
|
293
|
+
onResize: function onResize() {
|
294
|
+
_this3.updatePosition();
|
295
|
+
}
|
296
|
+
}, children))));
|
297
|
+
}
|
298
|
+
}]);
|
299
|
+
|
300
|
+
return Affix;
|
301
|
+
}(React.Component);
|
302
|
+
|
303
|
+
Affix.contextType = ConfigContext;
|
304
|
+
|
305
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "updatePosition", null);
|
306
|
+
|
307
|
+
__decorate([throttleByAnimationFrameDecorator()], Affix.prototype, "lazyUpdatePosition", null);
|
308
|
+
|
309
|
+
var AffixFC = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
310
|
+
var customizePrefixCls = props.prefixCls;
|
311
|
+
|
312
|
+
var _React$useContext = React.useContext(ConfigContext),
|
313
|
+
getPrefixCls = _React$useContext.getPrefixCls;
|
314
|
+
|
315
|
+
var affixPrefixCls = getPrefixCls('affix', customizePrefixCls);
|
316
|
+
|
317
|
+
var affixProps = _extends(_extends({}, props), {
|
318
|
+
affixPrefixCls: affixPrefixCls
|
319
|
+
});
|
320
|
+
|
321
|
+
return /*#__PURE__*/React.createElement(Affix, _extends({}, affixProps, {
|
322
|
+
ref: ref
|
323
|
+
}));
|
324
|
+
});
|
325
|
+
|
326
|
+
if (process.env.NODE_ENV !== 'production') {
|
327
|
+
AffixFC.displayName = 'Affix';
|
328
|
+
}
|
329
|
+
|
330
|
+
export default AffixFC;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
|
2
|
+
/* stylelint-disable no-duplicate-selectors */
|
3
|
+
/* stylelint-disable */
|
4
|
+
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
|
5
|
+
.ant-affix {
|
6
|
+
position: fixed;
|
7
|
+
z-index: 10;
|
8
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
export type BindElement = HTMLElement | Window | null | undefined;
|
2
|
+
export declare function getTargetRect(target: BindElement): DOMRect;
|
3
|
+
export declare function getFixedTop(placeholderReact: DOMRect, targetRect: DOMRect, offsetTop?: number): number | undefined;
|
4
|
+
export declare function getFixedBottom(placeholderReact: DOMRect, targetRect: DOMRect, offsetBottom?: number): number | undefined;
|
5
|
+
interface ObserverEntity {
|
6
|
+
target: HTMLElement | Window;
|
7
|
+
affixList: any[];
|
8
|
+
eventHandlers: {
|
9
|
+
[eventName: string]: any;
|
10
|
+
};
|
11
|
+
}
|
12
|
+
export declare function getObserverEntities(): ObserverEntity[];
|
13
|
+
export declare function addObserveTarget<T>(target: HTMLElement | Window | null, affix?: T): void;
|
14
|
+
export declare function removeObserveTarget<T>(affix: T): void;
|
15
|
+
export {};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import addEventListener from "rc-util/es/Dom/addEventListener";
|
2
|
+
export function getTargetRect(target) {
|
3
|
+
return target !== window ? target.getBoundingClientRect() : {
|
4
|
+
top: 0,
|
5
|
+
bottom: window.innerHeight
|
6
|
+
};
|
7
|
+
}
|
8
|
+
export function getFixedTop(placeholderReact, targetRect, offsetTop) {
|
9
|
+
if (offsetTop !== undefined && targetRect.top > placeholderReact.top - offsetTop) {
|
10
|
+
return offsetTop + targetRect.top;
|
11
|
+
}
|
12
|
+
|
13
|
+
return undefined;
|
14
|
+
}
|
15
|
+
export function getFixedBottom(placeholderReact, targetRect, offsetBottom) {
|
16
|
+
if (offsetBottom !== undefined && targetRect.bottom < placeholderReact.bottom + offsetBottom) {
|
17
|
+
var targetBottomOffset = window.innerHeight - targetRect.bottom;
|
18
|
+
return offsetBottom + targetBottomOffset;
|
19
|
+
}
|
20
|
+
|
21
|
+
return undefined;
|
22
|
+
} // ======================== Observer ========================
|
23
|
+
|
24
|
+
var TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];
|
25
|
+
var observerEntities = [];
|
26
|
+
export function getObserverEntities() {
|
27
|
+
// Only used in test env. Can be removed if refactor.
|
28
|
+
return observerEntities;
|
29
|
+
}
|
30
|
+
export function addObserveTarget(target, affix) {
|
31
|
+
if (!target) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
var entity = observerEntities.find(function (item) {
|
36
|
+
return item.target === target;
|
37
|
+
});
|
38
|
+
|
39
|
+
if (entity) {
|
40
|
+
entity.affixList.push(affix);
|
41
|
+
} else {
|
42
|
+
entity = {
|
43
|
+
target: target,
|
44
|
+
affixList: [affix],
|
45
|
+
eventHandlers: {}
|
46
|
+
};
|
47
|
+
observerEntities.push(entity); // Add listener
|
48
|
+
|
49
|
+
TRIGGER_EVENTS.forEach(function (eventName) {
|
50
|
+
entity.eventHandlers[eventName] = addEventListener(target, eventName, function () {
|
51
|
+
entity.affixList.forEach(function (targetAffix) {
|
52
|
+
targetAffix.lazyUpdatePosition();
|
53
|
+
});
|
54
|
+
});
|
55
|
+
});
|
56
|
+
}
|
57
|
+
}
|
58
|
+
export function removeObserveTarget(affix) {
|
59
|
+
var observerEntity = observerEntities.find(function (oriObserverEntity) {
|
60
|
+
var hasAffix = oriObserverEntity.affixList.some(function (item) {
|
61
|
+
return item === affix;
|
62
|
+
});
|
63
|
+
|
64
|
+
if (hasAffix) {
|
65
|
+
oriObserverEntity.affixList = oriObserverEntity.affixList.filter(function (item) {
|
66
|
+
return item !== affix;
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
return hasAffix;
|
71
|
+
});
|
72
|
+
|
73
|
+
if (observerEntity && observerEntity.affixList.length === 0) {
|
74
|
+
observerEntities = observerEntities.filter(function (item) {
|
75
|
+
return item !== observerEntity;
|
76
|
+
}); // Remove listener
|
77
|
+
|
78
|
+
TRIGGER_EVENTS.forEach(function (eventName) {
|
79
|
+
var handler = observerEntity.eventHandlers[eventName];
|
80
|
+
|
81
|
+
if (handler && handler.remove) {
|
82
|
+
handler.remove();
|
83
|
+
}
|
84
|
+
});
|
85
|
+
}
|
86
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type DisabledType = true | false | undefined;
|
3
|
+
declare const DisabledContext: React.Context<DisabledType>;
|
4
|
+
export interface DisabledContextProps {
|
5
|
+
disabled?: DisabledType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const DisabledContextProvider: React.FC<DisabledContextProps>;
|
9
|
+
export default DisabledContext;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
var DisabledContext = /*#__PURE__*/React.createContext(false);
|
3
|
+
export var DisabledContextProvider = function DisabledContextProvider(_ref) {
|
4
|
+
var children = _ref.children,
|
5
|
+
disabled = _ref.disabled;
|
6
|
+
var originDisabled = React.useContext(DisabledContext);
|
7
|
+
return /*#__PURE__*/React.createElement(DisabledContext.Provider, {
|
8
|
+
value: disabled !== null && disabled !== void 0 ? disabled : originDisabled
|
9
|
+
}, children);
|
10
|
+
};
|
11
|
+
export default DisabledContext;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
3
|
+
declare const SizeContext: React.Context<SizeType>;
|
4
|
+
export interface SizeContextProps {
|
5
|
+
size?: SizeType;
|
6
|
+
children?: React.ReactNode;
|
7
|
+
}
|
8
|
+
export declare const SizeContextProvider: React.FC<SizeContextProps>;
|
9
|
+
export default SizeContext;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
var SizeContext = /*#__PURE__*/React.createContext(undefined);
|
3
|
+
export var SizeContextProvider = function SizeContextProvider(_ref) {
|
4
|
+
var children = _ref.children,
|
5
|
+
size = _ref.size;
|
6
|
+
return /*#__PURE__*/React.createElement(SizeContext.Consumer, null, function (originSize) {
|
7
|
+
return /*#__PURE__*/React.createElement(SizeContext.Provider, {
|
8
|
+
value: size || originSize
|
9
|
+
}, children);
|
10
|
+
});
|
11
|
+
};
|
12
|
+
export default SizeContext;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { RequiredMark } from '../form/Form';
|
3
|
+
import type { Locale } from '../locale-provider';
|
4
|
+
import type { RenderEmptyHandler } from './defaultRenderEmpty';
|
5
|
+
import type { SizeType } from './SizeContext';
|
6
|
+
export interface Theme {
|
7
|
+
primaryColor?: string;
|
8
|
+
infoColor?: string;
|
9
|
+
successColor?: string;
|
10
|
+
processingColor?: string;
|
11
|
+
errorColor?: string;
|
12
|
+
warningColor?: string;
|
13
|
+
}
|
14
|
+
export interface CSPConfig {
|
15
|
+
nonce?: string;
|
16
|
+
}
|
17
|
+
export type DirectionType = 'ltr' | 'rtl' | undefined;
|
18
|
+
export interface ConfigConsumerProps {
|
19
|
+
getTargetContainer?: () => HTMLElement;
|
20
|
+
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
|
21
|
+
rootPrefixCls?: string;
|
22
|
+
iconPrefixCls?: string;
|
23
|
+
getPrefixCls: (suffixCls?: string, customizePrefixCls?: string) => string;
|
24
|
+
renderEmpty?: RenderEmptyHandler;
|
25
|
+
csp?: CSPConfig;
|
26
|
+
autoInsertSpaceInButton?: boolean;
|
27
|
+
input?: {
|
28
|
+
autoComplete?: string;
|
29
|
+
};
|
30
|
+
pagination?: {
|
31
|
+
showSizeChanger?: boolean;
|
32
|
+
};
|
33
|
+
locale?: Locale;
|
34
|
+
pageHeader?: {
|
35
|
+
ghost: boolean;
|
36
|
+
};
|
37
|
+
direction?: DirectionType;
|
38
|
+
space?: {
|
39
|
+
size?: SizeType | number;
|
40
|
+
};
|
41
|
+
virtual?: boolean;
|
42
|
+
dropdownMatchSelectWidth?: boolean;
|
43
|
+
form?: {
|
44
|
+
requiredMark?: RequiredMark;
|
45
|
+
colon?: boolean;
|
46
|
+
};
|
47
|
+
}
|
48
|
+
export declare const ConfigContext: React.Context<ConfigConsumerProps>;
|
49
|
+
export declare const ConfigConsumer: React.Consumer<ConfigConsumerProps>;
|
50
|
+
interface BasicExportProps {
|
51
|
+
prefixCls?: string;
|
52
|
+
}
|
53
|
+
interface ConsumerConfig {
|
54
|
+
prefixCls: string;
|
55
|
+
}
|
56
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
57
|
+
export declare function withConfigConsumer<ExportProps extends BasicExportProps>(config: ConsumerConfig): <ComponentDef>(Component: React.ComponentType<ExportProps>) => React.FC<ExportProps> & ComponentDef;
|
58
|
+
export {};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
2
|
+
import * as React from 'react';
|
3
|
+
|
4
|
+
var defaultGetPrefixCls = function defaultGetPrefixCls(suffixCls, customizePrefixCls) {
|
5
|
+
if (customizePrefixCls) return customizePrefixCls;
|
6
|
+
return suffixCls ? "ant-".concat(suffixCls) : 'ant';
|
7
|
+
}; // zombieJ: 🚨 Do not pass `defaultRenderEmpty` here since it will case circular dependency.
|
8
|
+
|
9
|
+
|
10
|
+
export var ConfigContext = /*#__PURE__*/React.createContext({
|
11
|
+
// We provide a default function for Context without provider
|
12
|
+
getPrefixCls: defaultGetPrefixCls
|
13
|
+
});
|
14
|
+
export var ConfigConsumer = ConfigContext.Consumer;
|
15
|
+
/** @deprecated Use hooks instead. This is a legacy function */
|
16
|
+
|
17
|
+
export function withConfigConsumer(config) {
|
18
|
+
return function withConfigConsumerFunc(Component) {
|
19
|
+
// Wrap with ConfigConsumer. Since we need compatible with react 15, be care when using ref methods
|
20
|
+
var SFC = function SFC(props) {
|
21
|
+
return /*#__PURE__*/React.createElement(ConfigConsumer, null, function (configProps) {
|
22
|
+
var basicPrefixCls = config.prefixCls;
|
23
|
+
var getPrefixCls = configProps.getPrefixCls;
|
24
|
+
var customizePrefixCls = props.prefixCls;
|
25
|
+
var prefixCls = getPrefixCls(basicPrefixCls, customizePrefixCls);
|
26
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, configProps, props, {
|
27
|
+
prefixCls: prefixCls
|
28
|
+
}));
|
29
|
+
});
|
30
|
+
};
|
31
|
+
|
32
|
+
var cons = Component.constructor;
|
33
|
+
var name = cons && cons.displayName || Component.name || 'Component';
|
34
|
+
|
35
|
+
if (process.env.NODE_ENV !== 'production') {
|
36
|
+
SFC.displayName = "withConfigConsumer(".concat(name, ")");
|
37
|
+
}
|
38
|
+
|
39
|
+
return SFC;
|
40
|
+
};
|
41
|
+
}
|