first commit
This commit is contained in:
25
frontend/node_modules/antd/lib/affix/index.d.ts
generated
vendored
Normal file
25
frontend/node_modules/antd/lib/affix/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import throttleByAnimationFrame from '../_util/throttleByAnimationFrame';
|
||||
export interface AffixProps {
|
||||
/** Triggered when the specified offset is reached from the top of the window */
|
||||
offsetTop?: number;
|
||||
/** Triggered when the specified offset is reached from the bottom of the window */
|
||||
offsetBottom?: number;
|
||||
style?: React.CSSProperties;
|
||||
/** Callback function triggered when fixed state changes */
|
||||
onChange?: (affixed?: boolean) => void;
|
||||
/** Set the element that Affix needs to listen to its scroll event, the value is a function that returns the corresponding DOM element */
|
||||
target?: () => Window | HTMLElement | null;
|
||||
prefixCls?: string;
|
||||
className?: string;
|
||||
rootClassName?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export interface AffixRef {
|
||||
updatePosition: ReturnType<typeof throttleByAnimationFrame>;
|
||||
}
|
||||
interface InternalAffixProps extends AffixProps {
|
||||
onTestUpdatePosition?: () => void;
|
||||
}
|
||||
declare const Affix: React.ForwardRefExoticComponent<InternalAffixProps & React.RefAttributes<AffixRef>>;
|
||||
export default Affix;
|
||||
213
frontend/node_modules/antd/lib/affix/index.js
generated
vendored
Normal file
213
frontend/node_modules/antd/lib/affix/index.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
var _classnames = _interopRequireDefault(require("classnames"));
|
||||
var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
|
||||
var _throttleByAnimationFrame = _interopRequireDefault(require("../_util/throttleByAnimationFrame"));
|
||||
var _configProvider = require("../config-provider");
|
||||
var _style = _interopRequireDefault(require("./style"));
|
||||
var _utils = require("./utils");
|
||||
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
||||
var t = {};
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
||||
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
const TRIGGER_EVENTS = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];
|
||||
function getDefaultTarget() {
|
||||
return typeof window !== 'undefined' ? window : null;
|
||||
}
|
||||
const AFFIX_STATUS_NONE = 0;
|
||||
const AFFIX_STATUS_PREPARE = 1;
|
||||
const Affix = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
||||
var _a;
|
||||
const {
|
||||
style,
|
||||
offsetTop,
|
||||
offsetBottom,
|
||||
prefixCls,
|
||||
className,
|
||||
rootClassName,
|
||||
children,
|
||||
target,
|
||||
onChange,
|
||||
onTestUpdatePosition
|
||||
} = props,
|
||||
restProps = __rest(props, ["style", "offsetTop", "offsetBottom", "prefixCls", "className", "rootClassName", "children", "target", "onChange", "onTestUpdatePosition"]);
|
||||
const {
|
||||
getPrefixCls,
|
||||
getTargetContainer
|
||||
} = _react.default.useContext(_configProvider.ConfigContext);
|
||||
const affixPrefixCls = getPrefixCls('affix', prefixCls);
|
||||
const [lastAffix, setLastAffix] = _react.default.useState(false);
|
||||
const [affixStyle, setAffixStyle] = _react.default.useState();
|
||||
const [placeholderStyle, setPlaceholderStyle] = _react.default.useState();
|
||||
const status = _react.default.useRef(AFFIX_STATUS_NONE);
|
||||
const prevTarget = _react.default.useRef(null);
|
||||
const prevListener = _react.default.useRef(null);
|
||||
const placeholderNodeRef = _react.default.useRef(null);
|
||||
const fixedNodeRef = _react.default.useRef(null);
|
||||
const timer = _react.default.useRef(null);
|
||||
const targetFunc = (_a = target !== null && target !== void 0 ? target : getTargetContainer) !== null && _a !== void 0 ? _a : getDefaultTarget;
|
||||
const internalOffsetTop = offsetBottom === undefined && offsetTop === undefined ? 0 : offsetTop;
|
||||
// =================== Measure ===================
|
||||
const measure = () => {
|
||||
if (status.current !== AFFIX_STATUS_PREPARE || !fixedNodeRef.current || !placeholderNodeRef.current || !targetFunc) {
|
||||
return;
|
||||
}
|
||||
const targetNode = targetFunc();
|
||||
if (targetNode) {
|
||||
const newState = {
|
||||
status: AFFIX_STATUS_NONE
|
||||
};
|
||||
const placeholderRect = (0, _utils.getTargetRect)(placeholderNodeRef.current);
|
||||
if (placeholderRect.top === 0 && placeholderRect.left === 0 && placeholderRect.width === 0 && placeholderRect.height === 0) {
|
||||
return;
|
||||
}
|
||||
const targetRect = (0, _utils.getTargetRect)(targetNode);
|
||||
const fixedTop = (0, _utils.getFixedTop)(placeholderRect, targetRect, internalOffsetTop);
|
||||
const fixedBottom = (0, _utils.getFixedBottom)(placeholderRect, targetRect, offsetBottom);
|
||||
if (fixedTop !== undefined) {
|
||||
newState.affixStyle = {
|
||||
position: 'fixed',
|
||||
top: fixedTop,
|
||||
width: placeholderRect.width,
|
||||
height: placeholderRect.height
|
||||
};
|
||||
newState.placeholderStyle = {
|
||||
width: placeholderRect.width,
|
||||
height: placeholderRect.height
|
||||
};
|
||||
} else if (fixedBottom !== undefined) {
|
||||
newState.affixStyle = {
|
||||
position: 'fixed',
|
||||
bottom: fixedBottom,
|
||||
width: placeholderRect.width,
|
||||
height: placeholderRect.height
|
||||
};
|
||||
newState.placeholderStyle = {
|
||||
width: placeholderRect.width,
|
||||
height: placeholderRect.height
|
||||
};
|
||||
}
|
||||
newState.lastAffix = !!newState.affixStyle;
|
||||
if (lastAffix !== newState.lastAffix) {
|
||||
onChange === null || onChange === void 0 ? void 0 : onChange(newState.lastAffix);
|
||||
}
|
||||
status.current = newState.status;
|
||||
setAffixStyle(newState.affixStyle);
|
||||
setPlaceholderStyle(newState.placeholderStyle);
|
||||
setLastAffix(newState.lastAffix);
|
||||
}
|
||||
};
|
||||
const prepareMeasure = () => {
|
||||
status.current = AFFIX_STATUS_PREPARE;
|
||||
measure();
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
onTestUpdatePosition === null || onTestUpdatePosition === void 0 ? void 0 : onTestUpdatePosition();
|
||||
}
|
||||
};
|
||||
const updatePosition = (0, _throttleByAnimationFrame.default)(() => {
|
||||
prepareMeasure();
|
||||
});
|
||||
const lazyUpdatePosition = (0, _throttleByAnimationFrame.default)(() => {
|
||||
// Check position change before measure to make Safari smooth
|
||||
if (targetFunc && affixStyle) {
|
||||
const targetNode = targetFunc();
|
||||
if (targetNode && placeholderNodeRef.current) {
|
||||
const targetRect = (0, _utils.getTargetRect)(targetNode);
|
||||
const placeholderRect = (0, _utils.getTargetRect)(placeholderNodeRef.current);
|
||||
const fixedTop = (0, _utils.getFixedTop)(placeholderRect, targetRect, internalOffsetTop);
|
||||
const fixedBottom = (0, _utils.getFixedBottom)(placeholderRect, targetRect, offsetBottom);
|
||||
if (fixedTop !== undefined && affixStyle.top === fixedTop || fixedBottom !== undefined && affixStyle.bottom === fixedBottom) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Directly call prepare measure since it's already throttled.
|
||||
prepareMeasure();
|
||||
});
|
||||
const addListeners = () => {
|
||||
const listenerTarget = targetFunc === null || targetFunc === void 0 ? void 0 : targetFunc();
|
||||
if (!listenerTarget) {
|
||||
return;
|
||||
}
|
||||
TRIGGER_EVENTS.forEach(eventName => {
|
||||
var _a;
|
||||
if (prevListener.current) {
|
||||
(_a = prevTarget.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(eventName, prevListener.current);
|
||||
}
|
||||
listenerTarget === null || listenerTarget === void 0 ? void 0 : listenerTarget.addEventListener(eventName, lazyUpdatePosition);
|
||||
});
|
||||
prevTarget.current = listenerTarget;
|
||||
prevListener.current = lazyUpdatePosition;
|
||||
};
|
||||
const removeListeners = () => {
|
||||
const newTarget = targetFunc === null || targetFunc === void 0 ? void 0 : targetFunc();
|
||||
TRIGGER_EVENTS.forEach(eventName => {
|
||||
var _a;
|
||||
newTarget === null || newTarget === void 0 ? void 0 : newTarget.removeEventListener(eventName, lazyUpdatePosition);
|
||||
if (prevListener.current) {
|
||||
(_a = prevTarget.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(eventName, prevListener.current);
|
||||
}
|
||||
});
|
||||
updatePosition.cancel();
|
||||
lazyUpdatePosition.cancel();
|
||||
};
|
||||
_react.default.useImperativeHandle(ref, () => ({
|
||||
updatePosition
|
||||
}));
|
||||
// mount & unmount
|
||||
_react.default.useEffect(() => {
|
||||
// [Legacy] Wait for parent component ref has its value.
|
||||
// We should use target as directly element instead of function which makes element check hard.
|
||||
timer.current = setTimeout(addListeners);
|
||||
return () => {
|
||||
if (timer.current) {
|
||||
clearTimeout(timer.current);
|
||||
timer.current = null;
|
||||
}
|
||||
removeListeners();
|
||||
};
|
||||
}, []);
|
||||
_react.default.useEffect(() => {
|
||||
addListeners();
|
||||
return () => removeListeners();
|
||||
}, [target, affixStyle, lastAffix, offsetTop, offsetBottom]);
|
||||
_react.default.useEffect(() => {
|
||||
updatePosition();
|
||||
}, [target, offsetTop, offsetBottom]);
|
||||
const [wrapCSSVar, hashId, cssVarCls] = (0, _style.default)(affixPrefixCls);
|
||||
const rootCls = (0, _classnames.default)(rootClassName, hashId, affixPrefixCls, cssVarCls);
|
||||
const mergedCls = (0, _classnames.default)({
|
||||
[rootCls]: affixStyle
|
||||
});
|
||||
return wrapCSSVar(/*#__PURE__*/_react.default.createElement(_rcResizeObserver.default, {
|
||||
onResize: updatePosition
|
||||
}, /*#__PURE__*/_react.default.createElement("div", Object.assign({
|
||||
style: style,
|
||||
className: className,
|
||||
ref: placeholderNodeRef
|
||||
}, restProps), affixStyle && /*#__PURE__*/_react.default.createElement("div", {
|
||||
style: placeholderStyle,
|
||||
"aria-hidden": "true"
|
||||
}), /*#__PURE__*/_react.default.createElement("div", {
|
||||
className: mergedCls,
|
||||
ref: fixedNodeRef,
|
||||
style: affixStyle
|
||||
}, /*#__PURE__*/_react.default.createElement(_rcResizeObserver.default, {
|
||||
onResize: updatePosition
|
||||
}, children)))));
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Affix.displayName = 'Affix';
|
||||
}
|
||||
var _default = exports.default = Affix;
|
||||
11
frontend/node_modules/antd/lib/affix/style/index.d.ts
generated
vendored
Normal file
11
frontend/node_modules/antd/lib/affix/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { GetDefaultToken } from '../../theme/internal';
|
||||
export interface ComponentToken {
|
||||
/**
|
||||
* @desc 弹出层的 z-index
|
||||
* @descEN z-index of popup
|
||||
*/
|
||||
zIndexPopup: number;
|
||||
}
|
||||
export declare const prepareComponentToken: GetDefaultToken<'Affix'>;
|
||||
declare const _default: (prefixCls: string, rootCls?: string) => readonly [(node: React.ReactElement) => React.ReactElement, string, string];
|
||||
export default _default;
|
||||
25
frontend/node_modules/antd/lib/affix/style/index.js
generated
vendored
Normal file
25
frontend/node_modules/antd/lib/affix/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.prepareComponentToken = exports.default = void 0;
|
||||
var _internal = require("../../theme/internal");
|
||||
// ============================== Shared ==============================
|
||||
const genSharedAffixStyle = token => {
|
||||
const {
|
||||
componentCls
|
||||
} = token;
|
||||
return {
|
||||
[componentCls]: {
|
||||
position: 'fixed',
|
||||
zIndex: token.zIndexPopup
|
||||
}
|
||||
};
|
||||
};
|
||||
const prepareComponentToken = token => ({
|
||||
zIndexPopup: token.zIndexBase + 10
|
||||
});
|
||||
// ============================== Export ==============================
|
||||
exports.prepareComponentToken = prepareComponentToken;
|
||||
var _default = exports.default = (0, _internal.genStyleHooks)('Affix', genSharedAffixStyle, prepareComponentToken);
|
||||
4
frontend/node_modules/antd/lib/affix/utils.d.ts
generated
vendored
Normal file
4
frontend/node_modules/antd/lib/affix/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type BindElement = HTMLElement | Window | null | undefined;
|
||||
export declare function getTargetRect(target: BindElement): DOMRect;
|
||||
export declare function getFixedTop(placeholderRect: DOMRect, targetRect: DOMRect, offsetTop?: number): number | undefined;
|
||||
export declare function getFixedBottom(placeholderRect: DOMRect, targetRect: DOMRect, offsetBottom?: number): number | undefined;
|
||||
27
frontend/node_modules/antd/lib/affix/utils.js
generated
vendored
Normal file
27
frontend/node_modules/antd/lib/affix/utils.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getFixedBottom = getFixedBottom;
|
||||
exports.getFixedTop = getFixedTop;
|
||||
exports.getTargetRect = getTargetRect;
|
||||
function getTargetRect(target) {
|
||||
return target !== window ? target.getBoundingClientRect() : {
|
||||
top: 0,
|
||||
bottom: window.innerHeight
|
||||
};
|
||||
}
|
||||
function getFixedTop(placeholderRect, targetRect, offsetTop) {
|
||||
if (offsetTop !== undefined && Math.round(targetRect.top) > Math.round(placeholderRect.top) - offsetTop) {
|
||||
return offsetTop + targetRect.top;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getFixedBottom(placeholderRect, targetRect, offsetBottom) {
|
||||
if (offsetBottom !== undefined && Math.round(targetRect.bottom) < Math.round(placeholderRect.bottom) + offsetBottom) {
|
||||
const targetBottomOffset = window.innerHeight - targetRect.bottom;
|
||||
return offsetBottom + targetBottomOffset;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user