rc-util
Advanced tools
Comparing version 5.27.1 to 5.27.2
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/esm/inherits"; | ||
import _createSuper from "@babel/runtime/helpers/esm/createSuper"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import React from 'react'; | ||
@@ -22,3 +24,3 @@ import ReactDOM from 'react-dom'; | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.removeContainer = function () { | ||
_defineProperty(_assertThisInitialized(_this), "removeContainer", function () { | ||
if (_this.container) { | ||
@@ -29,4 +31,4 @@ ReactDOM.unmountComponentAtNode(_this.container); | ||
} | ||
}; | ||
_this.renderComponent = function (props, ready) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "renderComponent", function (props, ready) { | ||
var _this$props = _this.props, | ||
@@ -48,3 +50,3 @@ visible = _this$props.visible, | ||
} | ||
}; | ||
}); | ||
return _this; | ||
@@ -84,7 +86,7 @@ } | ||
}(React.Component); | ||
ContainerRender.defaultProps = { | ||
_defineProperty(ContainerRender, "defaultProps", { | ||
autoMount: true, | ||
autoDestroy: true, | ||
forceRender: false | ||
}; | ||
}); | ||
export { ContainerRender as default }; |
@@ -5,2 +5,3 @@ export default function contains(root, n) { | ||
} | ||
// Use native if support | ||
@@ -10,2 +11,3 @@ if (root.contains) { | ||
} | ||
// `document.contains` not support with IE11 | ||
@@ -12,0 +14,0 @@ var node = n; |
@@ -1,4 +0,4 @@ | ||
export type ContainerType = Element | ShadowRoot; | ||
export type Prepend = boolean | 'queue'; | ||
export type AppendType = 'prependQueue' | 'append' | 'prepend'; | ||
export declare type ContainerType = Element | ShadowRoot; | ||
export declare type Prepend = boolean | 'queue'; | ||
export declare type AppendType = 'prependQueue' | 'append' | 'prepend'; | ||
interface Options { | ||
@@ -5,0 +5,0 @@ attachTo?: ContainerType; |
@@ -1,3 +0,3 @@ | ||
import canUseDom from './canUseDom'; | ||
import contains from './contains'; | ||
import canUseDom from "./canUseDom"; | ||
import contains from "./contains"; | ||
var APPEND_ORDER = 'data-rc-order'; | ||
@@ -27,2 +27,3 @@ var MARK_KEY = "rc-util-key"; | ||
} | ||
/** | ||
@@ -45,3 +46,3 @@ * Find style which inject by rc-util | ||
styleNode.setAttribute(APPEND_ORDER, getOrder(prepend)); | ||
if (csp === null || csp === void 0 ? void 0 : csp.nonce) { | ||
if (csp !== null && csp !== void 0 && csp.nonce) { | ||
styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce; | ||
@@ -63,2 +64,3 @@ } | ||
} | ||
// Use `insertBefore` as `prepend` | ||
@@ -86,2 +88,3 @@ container.insertBefore(styleNode, firstChild); | ||
} | ||
/** | ||
@@ -92,2 +95,3 @@ * qiankun will inject `appendChild` to insert into other | ||
var cachedRealContainer = containerCache.get(container); | ||
// Find real container when not cached or cached container removed | ||
@@ -101,2 +105,3 @@ if (!cachedRealContainer || !contains(document, cachedRealContainer)) { | ||
} | ||
/** | ||
@@ -111,2 +116,3 @@ * manually clear container cache to avoid global cache in unit testes | ||
var container = getContainer(option); | ||
// Sync real parent | ||
@@ -117,3 +123,3 @@ syncRealContainer(container, option); | ||
var _option$csp, _option$csp2; | ||
if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { | ||
if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { | ||
var _option$csp3; | ||
@@ -120,0 +126,0 @@ existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Return if a node is a DOM node. Else will return by `findDOMNode` |
@@ -0,2 +1,4 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
/** | ||
@@ -9,3 +11,6 @@ * Return if a node is a DOM node. Else will return by `findDOMNode` | ||
} | ||
return ReactDOM.findDOMNode(node); | ||
if (node instanceof React.Component) { | ||
return ReactDOM.findDOMNode(node); | ||
} | ||
return null; | ||
} |
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import isVisible from './isVisible'; | ||
import isVisible from "./isVisible"; | ||
function focusable(node) { | ||
@@ -14,5 +14,7 @@ var includePositive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
nodeName === 'a' && !!node.getAttribute('href'); | ||
// Get tabIndex | ||
var tabIndexAttr = node.getAttribute('tabindex'); | ||
var tabIndexNum = Number(tabIndexAttr); | ||
// Parse as number if validate | ||
@@ -25,2 +27,3 @@ var tabIndex = null; | ||
} | ||
// Block focusable if disabled | ||
@@ -45,2 +48,3 @@ if (isFocusableElement && node.disabled) { | ||
var lastFocusElement = null; | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -50,2 +54,3 @@ export function saveLastFocusNode() { | ||
} | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -55,2 +60,3 @@ export function clearLastFocusNode() { | ||
} | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -62,2 +68,3 @@ export function backLastFocusNode() { | ||
lastFocusElement.focus(); | ||
/* eslint-disable no-empty */ | ||
@@ -64,0 +71,0 @@ } catch (e) { |
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import getScrollBarSize from '../getScrollBarSize'; | ||
import setStyle from '../setStyle'; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import getScrollBarSize from "../getScrollBarSize"; | ||
import setStyle from "../setStyle"; | ||
var uuid = 0; | ||
@@ -10,2 +11,3 @@ var locks = []; | ||
var scrollingEffectClassNameReg = new RegExp("".concat(scrollingEffectClassName), 'g'); | ||
// https://github.com/ant-design/ant-design/issues/19340 | ||
@@ -17,9 +19,9 @@ // https://github.com/ant-design/ant-design/issues/19332 | ||
_classCallCheck(this, ScrollLocker); | ||
this.lockTarget = void 0; | ||
this.options = void 0; | ||
this.getContainer = function () { | ||
_defineProperty(this, "lockTarget", void 0); | ||
_defineProperty(this, "options", void 0); | ||
_defineProperty(this, "getContainer", function () { | ||
var _this$options; | ||
return (_this$options = _this.options) === null || _this$options === void 0 ? void 0 : _this$options.container; | ||
}; | ||
this.reLock = function (options) { | ||
}); | ||
_defineProperty(this, "reLock", function (options) { | ||
var findLock = locks.find(function (_ref) { | ||
@@ -37,4 +39,4 @@ var target = _ref.target; | ||
} | ||
}; | ||
this.lock = function () { | ||
}); | ||
_defineProperty(this, "lock", function () { | ||
var _this$options3; | ||
@@ -48,2 +50,3 @@ // If lockTarget exist return | ||
} | ||
// If same container effect, return | ||
@@ -64,3 +67,5 @@ if (locks.some(function (_ref3) { | ||
if (container === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || container.scrollHeight > container.clientHeight) { | ||
scrollBarSize = getScrollBarSize(); | ||
if (getComputedStyle(container).overflow !== 'hidden') { | ||
scrollBarSize = getScrollBarSize(); | ||
} | ||
} | ||
@@ -82,2 +87,3 @@ var containerClassName = container.className; | ||
} | ||
// https://github.com/ant-design/ant-design/issues/19729 | ||
@@ -92,4 +98,4 @@ if (!scrollingEffectClassNameReg.test(containerClassName)) { | ||
}]); | ||
}; | ||
this.unLock = function () { | ||
}); | ||
_defineProperty(this, "unLock", function () { | ||
var _this$options5; | ||
@@ -111,2 +117,3 @@ var findLock = locks.find(function (_ref5) { | ||
} | ||
// Remove Effect | ||
@@ -121,3 +128,3 @@ var container = ((_this$options5 = _this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.container) || document.body; | ||
container.className = container.className.replace(scrollingEffectClassNameReg, '').trim(); | ||
}; | ||
}); | ||
// eslint-disable-next-line no-plusplus | ||
@@ -124,0 +131,0 @@ this.lockTarget = uuid++; |
@@ -1,2 +0,2 @@ | ||
import canUseDom from './canUseDom'; | ||
import canUseDom from "./canUseDom"; | ||
var isStyleNameSupport = function isStyleNameSupport(styleName) { | ||
@@ -3,0 +3,0 @@ if (canUseDom() && window.document.documentElement) { |
@@ -1,2 +0,2 @@ | ||
import canUseDOM from './canUseDom'; | ||
import canUseDOM from "./canUseDom"; | ||
var animationEndEventNames = { | ||
@@ -3,0 +3,0 @@ WebkitAnimation: 'webkitAnimationEnd', |
/* eslint-disable no-param-reassign */ | ||
var cached; | ||
@@ -3,0 +4,0 @@ export default function getScrollBarSize(fresh) { |
import * as React from 'react'; | ||
/** As `React.useEffect` but pass origin value in callback and not need care deps length change. */ | ||
@@ -3,0 +4,0 @@ export default function useEffect(callback, deps) { |
@@ -10,2 +10,3 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
var uuid = 0; | ||
/** @private Note only worked in develop env. Not work in production. */ | ||
@@ -32,2 +33,3 @@ export function resetUuid() { | ||
}, []); | ||
// Developer passed id is single source of truth | ||
@@ -37,2 +39,3 @@ if (id) { | ||
} | ||
// Test env always return mock id | ||
@@ -42,4 +45,5 @@ if (process.env.NODE_ENV === 'test') { | ||
} | ||
// Return react native id or inner id | ||
return reactNativeId || innerId; | ||
} |
import * as React from 'react'; | ||
import canUseDom from '../Dom/canUseDom'; | ||
import canUseDom from "../Dom/canUseDom"; | ||
/** | ||
@@ -15,2 +16,3 @@ * Wrap `React.useLayoutEffect` which will not throw warning message in test env | ||
}, deps); | ||
// We tell react that first mount has passed | ||
@@ -17,0 +19,0 @@ useLayoutEffect(function () { |
@@ -1,2 +0,2 @@ | ||
type Updater<T> = (updater: T | ((origin: T) => T), ignoreDestroy?: boolean) => void; | ||
declare type Updater<T> = (updater: T | ((origin: T) => T), ignoreDestroy?: boolean) => void; | ||
/** | ||
@@ -3,0 +3,0 @@ * Similar to `useState` but will use props value if provided. |
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import useEvent from './useEvent'; | ||
import { useLayoutUpdateEffect } from './useLayoutEffect'; | ||
import useState from './useState'; | ||
import useEvent from "./useEvent"; | ||
import { useLayoutUpdateEffect } from "./useLayoutEffect"; | ||
import useState from "./useState"; | ||
/** We only think `undefined` is empty */ | ||
@@ -9,2 +9,3 @@ function hasValue(value) { | ||
} | ||
/** | ||
@@ -20,2 +21,3 @@ * Similar to `useState` but will use props value if provided. | ||
postState = _ref.postState; | ||
// ======================= Init ======================= | ||
@@ -36,2 +38,3 @@ var _useState = useState(function () { | ||
var postMergedValue = postState ? postState(mergedValue) : mergedValue; | ||
// ====================== Change ====================== | ||
@@ -49,2 +52,3 @@ var onChangeFn = useEvent(onChange); | ||
}, [prevValue]); | ||
// Sync value back to `undefined` when it from control to un-control | ||
@@ -56,2 +60,3 @@ useLayoutUpdateEffect(function () { | ||
}, [value]); | ||
// ====================== Update ====================== | ||
@@ -58,0 +63,0 @@ var triggerChange = useEvent(function (updater, ignoreDestroy) { |
@@ -1,3 +0,3 @@ | ||
type Updater<T> = T | ((prevValue: T) => T); | ||
export type SetState<T> = (nextValue: Updater<T>, | ||
declare type Updater<T> = T | ((prevValue: T) => T); | ||
export declare type SetState<T> = (nextValue: Updater<T>, | ||
/** | ||
@@ -4,0 +4,0 @@ * Will not update state when destroyed. |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import warning from './warning'; | ||
import warning from "./warning"; | ||
/** | ||
@@ -4,0 +5,0 @@ * Deeply compares two object literals. |
@@ -6,2 +6,3 @@ /** | ||
*/ | ||
var KeyCode = { | ||
@@ -24,2 +25,3 @@ /** | ||
NUM_CENTER: 12, | ||
// NUMLOCK on FF/Safari Mac | ||
/** | ||
@@ -61,2 +63,3 @@ * ENTER | ||
PAGE_UP: 33, | ||
// also NUM_NORTH_EAST | ||
/** | ||
@@ -66,2 +69,3 @@ * PAGE_DOWN | ||
PAGE_DOWN: 34, | ||
// also NUM_SOUTH_EAST | ||
/** | ||
@@ -71,2 +75,3 @@ * END | ||
END: 35, | ||
// also NUM_SOUTH_WEST | ||
/** | ||
@@ -76,2 +81,3 @@ * HOME | ||
HOME: 36, | ||
// also NUM_NORTH_WEST | ||
/** | ||
@@ -81,2 +87,3 @@ * LEFT | ||
LEFT: 37, | ||
// also NUM_WEST | ||
/** | ||
@@ -86,2 +93,3 @@ * UP | ||
UP: 38, | ||
// also NUM_NORTH | ||
/** | ||
@@ -91,2 +99,3 @@ * RIGHT | ||
RIGHT: 39, | ||
// also NUM_EAST | ||
/** | ||
@@ -96,2 +105,3 @@ * DOWN | ||
DOWN: 40, | ||
// also NUM_SOUTH | ||
/** | ||
@@ -105,2 +115,3 @@ * PRINT_SCREEN | ||
INSERT: 45, | ||
// also NUM_INSERT | ||
/** | ||
@@ -110,2 +121,3 @@ * DELETE | ||
DELETE: 46, | ||
// also NUM_DELETE | ||
/** | ||
@@ -155,2 +167,3 @@ * ZERO | ||
QUESTION_MARK: 63, | ||
// needs localization | ||
/** | ||
@@ -264,2 +277,3 @@ * A | ||
META: 91, | ||
// WIN_KEY_LEFT | ||
/** | ||
@@ -389,2 +403,3 @@ * WIN_KEY_RIGHT | ||
SEMICOLON: 186, | ||
// needs localization | ||
/** | ||
@@ -394,2 +409,3 @@ * DASH | ||
DASH: 189, | ||
// needs localization | ||
/** | ||
@@ -399,2 +415,3 @@ * EQUALS | ||
EQUALS: 187, | ||
// needs localization | ||
/** | ||
@@ -404,2 +421,3 @@ * COMMA | ||
COMMA: 188, | ||
// needs localization | ||
/** | ||
@@ -409,2 +427,3 @@ * PERIOD | ||
PERIOD: 190, | ||
// needs localization | ||
/** | ||
@@ -414,2 +433,3 @@ * SLASH | ||
SLASH: 191, | ||
// needs localization | ||
/** | ||
@@ -419,2 +439,3 @@ * APOSTROPHE | ||
APOSTROPHE: 192, | ||
// needs localization | ||
/** | ||
@@ -424,2 +445,3 @@ * SINGLE_QUOTE | ||
SINGLE_QUOTE: 222, | ||
// needs localization | ||
/** | ||
@@ -429,2 +451,3 @@ * OPEN_SQUARE_BRACKET | ||
OPEN_SQUARE_BRACKET: 219, | ||
// needs localization | ||
/** | ||
@@ -434,2 +457,3 @@ * BACKSLASH | ||
BACKSLASH: 220, | ||
// needs localization | ||
/** | ||
@@ -439,2 +463,3 @@ * CLOSE_SQUARE_BRACKET | ||
CLOSE_SQUARE_BRACKET: 221, | ||
// needs localization | ||
/** | ||
@@ -448,2 +473,3 @@ * WIN_KEY | ||
MAC_FF_META: 224, | ||
// Firefox (Gecko) fires this for the meta key instead of 91 | ||
/** | ||
@@ -464,2 +490,3 @@ * WIN_IME | ||
} | ||
// The following keys are quite harmless, even in combination with | ||
@@ -509,2 +536,3 @@ // CTRL, ALT or SHIFT. | ||
} | ||
// Safari sends zero key code for non-latin characters. | ||
@@ -511,0 +539,0 @@ if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) { |
@@ -5,2 +5,3 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
var propList = "".concat(attributes, " ").concat(eventsName).split(/[\s\n]+/); | ||
/* eslint-enable max-len */ | ||
@@ -7,0 +8,0 @@ var ariaPrefix = 'aria-'; |
import type * as React from 'react'; | ||
export type PortalRef = {}; | ||
export declare type PortalRef = {}; | ||
export interface PortalProps { | ||
@@ -4,0 +4,0 @@ didUpdate?: (prevProps: PortalProps) => void; |
import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import canUseDom from './Dom/canUseDom'; | ||
import canUseDom from "./Dom/canUseDom"; | ||
var Portal = /*#__PURE__*/forwardRef(function (props, ref) { | ||
@@ -10,2 +10,3 @@ var didUpdate = props.didUpdate, | ||
var containerRef = useRef(); | ||
// Ref return nothing, only for wrapper check exist | ||
@@ -15,2 +16,3 @@ useImperativeHandle(ref, function () { | ||
}); | ||
// Create container in client side with sync to avoid useEffect not get ref | ||
@@ -23,2 +25,3 @@ var initRef = useRef(false); | ||
} | ||
// [Legacy] Used by `rc-trigger` | ||
@@ -25,0 +28,0 @@ useEffect(function () { |
@@ -6,3 +6,3 @@ import * as React from 'react'; | ||
export declare function getOpenCount(): number; | ||
export type GetContainer = string | HTMLElement | (() => HTMLElement); | ||
export declare type GetContainer = string | HTMLElement | (() => HTMLElement); | ||
export interface PortalWrapperProps { | ||
@@ -9,0 +9,0 @@ visible?: boolean; |
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
import _createClass from "@babel/runtime/helpers/esm/createClass"; | ||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized"; | ||
import _inherits from "@babel/runtime/helpers/esm/inherits"; | ||
import _createSuper from "@babel/runtime/helpers/esm/createSuper"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
/* eslint-disable no-underscore-dangle,react/require-default-props */ | ||
import * as React from 'react'; | ||
import raf from './raf'; | ||
import Portal from './Portal'; | ||
import canUseDom from './Dom/canUseDom'; | ||
import switchScrollingEffect from './switchScrollingEffect'; | ||
import setStyle from './setStyle'; | ||
import ScrollLocker from './Dom/scrollLocker'; | ||
import raf from "./raf"; | ||
import Portal from "./Portal"; | ||
import canUseDom from "./Dom/canUseDom"; | ||
import switchScrollingEffect from "./switchScrollingEffect"; | ||
import setStyle from "./setStyle"; | ||
import ScrollLocker from "./Dom/scrollLocker"; | ||
var openCount = 0; | ||
var supportDom = canUseDom(); | ||
/** @private Test usage only */ | ||
@@ -20,2 +23,3 @@ export function getOpenCount() { | ||
} | ||
// https://github.com/ant-design/ant-design/issues/19340 | ||
@@ -48,8 +52,8 @@ // https://github.com/ant-design/ant-design/issues/19332 | ||
_this = _super.call(this, props); | ||
_this.container = void 0; | ||
_this.componentRef = /*#__PURE__*/React.createRef(); | ||
_this.rafId = void 0; | ||
_this.scrollLocker = void 0; | ||
_this.renderComponent = void 0; | ||
_this.updateScrollLocker = function (prevProps) { | ||
_defineProperty(_assertThisInitialized(_this), "container", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "componentRef", /*#__PURE__*/React.createRef()); | ||
_defineProperty(_assertThisInitialized(_this), "rafId", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "scrollLocker", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "renderComponent", void 0); | ||
_defineProperty(_assertThisInitialized(_this), "updateScrollLocker", function (prevProps) { | ||
var _ref = prevProps || {}, | ||
@@ -65,4 +69,4 @@ prevVisible = _ref.visible; | ||
} | ||
}; | ||
_this.updateOpenCount = function (prevProps) { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "updateOpenCount", function (prevProps) { | ||
var _ref2 = prevProps || {}, | ||
@@ -74,2 +78,3 @@ prevVisible = _ref2.visible, | ||
getContainer = _this$props2.getContainer; | ||
// Update count | ||
@@ -83,2 +88,3 @@ if (visible !== prevVisible && supportDom && getParent(getContainer) === document.body) { | ||
} | ||
// Clean up container if needed | ||
@@ -89,4 +95,4 @@ var getContainerIsFunc = typeof getContainer === 'function' && typeof prevGetContainer === 'function'; | ||
} | ||
}; | ||
_this.attachToParent = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "attachToParent", function () { | ||
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
@@ -102,4 +108,4 @@ if (force || _this.container && !_this.container.parentNode) { | ||
return true; | ||
}; | ||
_this.getContainer = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "getContainer", function () { | ||
if (!supportDom) { | ||
@@ -114,4 +120,4 @@ return null; | ||
return _this.container; | ||
}; | ||
_this.setWrapperClassName = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "setWrapperClassName", function () { | ||
var wrapperClassName = _this.props.wrapperClassName; | ||
@@ -121,4 +127,4 @@ if (_this.container && wrapperClassName && wrapperClassName !== _this.container.className) { | ||
} | ||
}; | ||
_this.removeCurrentContainer = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "removeCurrentContainer", function () { | ||
var _this$container, _this$container$paren; | ||
@@ -128,4 +134,4 @@ // Portal will remove from `parentNode`. | ||
(_this$container = _this.container) === null || _this$container === void 0 ? void 0 : (_this$container$paren = _this$container.parentNode) === null || _this$container$paren === void 0 ? void 0 : _this$container$paren.removeChild(_this.container); | ||
}; | ||
_this.switchScrollingEffect = function () { | ||
}); | ||
_defineProperty(_assertThisInitialized(_this), "switchScrollingEffect", function () { | ||
if (openCount === 1 && !Object.keys(cacheOverflow).length) { | ||
@@ -144,3 +150,3 @@ switchScrollingEffect(); | ||
} | ||
}; | ||
}); | ||
_this.scrollLocker = new ScrollLocker({ | ||
@@ -147,0 +153,0 @@ container: getParent(props.getContainer) |
@@ -12,3 +12,3 @@ /** | ||
import isEqual from './isEqual'; | ||
import isEqual from "./isEqual"; | ||
function shallowCompare(instance, nextProps, nextState) { | ||
@@ -15,0 +15,0 @@ return !isEqual(instance.props, nextProps, true) || !isEqual(instance.state, nextState, true); |
@@ -28,2 +28,3 @@ var raf = function raf(callback) { | ||
cleanup(id); | ||
// Trigger | ||
@@ -36,2 +37,3 @@ callback(); | ||
}); | ||
// Bind real raf id | ||
@@ -38,0 +40,0 @@ rafIds.set(id, realId); |
import type * as React from 'react'; | ||
import type { Root } from 'react-dom/client'; | ||
declare const MARK = "__rc_react_root__"; | ||
type ContainerType = (Element | DocumentFragment) & { | ||
declare type ContainerType = (Element | DocumentFragment) & { | ||
[MARK]?: Root; | ||
@@ -6,0 +6,0 @@ }; |
@@ -27,2 +27,5 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime"; | ||
var MARK = '__rc_react_root__'; | ||
// ========================== Render ========================== | ||
function modernRender(node, container) { | ||
@@ -38,2 +41,3 @@ toggleWarning(true); | ||
} | ||
/** @private Test usage. Not work in prod */ | ||
@@ -52,2 +56,3 @@ export function _r(node, container) { | ||
} | ||
// ========================= Unmount ========================== | ||
@@ -60,14 +65,12 @@ function modernUnmount(_x) { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", Promise.resolve().then(function () { | ||
var _container$MARK; | ||
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount(); | ||
delete container[MARK]; | ||
})); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", Promise.resolve().then(function () { | ||
var _container$MARK; | ||
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount(); | ||
delete container[MARK]; | ||
})); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
@@ -81,2 +84,3 @@ }, _callee); | ||
} | ||
/** @private Test usage. Not work in prod */ | ||
@@ -94,16 +98,14 @@ export function _u(container) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!(createRoot !== undefined)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
return _context2.abrupt("return", modernUnmount(container)); | ||
case 2: | ||
legacyUnmount(container); | ||
case 3: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!(createRoot !== undefined)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
return _context2.abrupt("return", modernUnmount(container)); | ||
case 2: | ||
legacyUnmount(container); | ||
case 3: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
@@ -110,0 +112,0 @@ }, _callee2); |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
/* eslint-disable no-param-reassign */ | ||
import { isMemo } from 'react-is'; | ||
import useMemo from './hooks/useMemo'; | ||
import useMemo from "./hooks/useMemo"; | ||
export function fillRef(ref, node) { | ||
@@ -11,2 +13,3 @@ if (typeof ref === 'function') { | ||
} | ||
/** | ||
@@ -46,8 +49,10 @@ * Merge refs into one ref function to support ref passing. | ||
var type = isMemo(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type; | ||
// Function component node | ||
if (typeof type === 'function' && !((_type$prototype = type.prototype) === null || _type$prototype === void 0 ? void 0 : _type$prototype.render)) { | ||
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render)) { | ||
return false; | ||
} | ||
// Class component | ||
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) === null || _nodeOrComponent$prot === void 0 ? void 0 : _nodeOrComponent$prot.render)) { | ||
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render)) { | ||
return false; | ||
@@ -54,0 +59,0 @@ } |
@@ -16,2 +16,3 @@ /** | ||
var styleKeys = Object.keys(style); | ||
// IE browser compatible | ||
@@ -18,0 +19,0 @@ styleKeys.forEach(function (key) { |
@@ -1,3 +0,3 @@ | ||
import getScrollBarSize from './getScrollBarSize'; | ||
import setStyle from './setStyle'; | ||
import getScrollBarSize from "./getScrollBarSize"; | ||
import setStyle from "./setStyle"; | ||
function isBodyOverflowing() { | ||
@@ -4,0 +4,0 @@ return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight) && window.innerWidth > document.body.offsetWidth; |
@@ -1,3 +0,3 @@ | ||
export type ElementClass = Function; | ||
export type Property = PropertyDescriptor | Function; | ||
export declare type ElementClass = Function; | ||
export declare type Property = PropertyDescriptor | Function; | ||
export declare function spyElementPrototypes<T extends ElementClass>(elementClass: T, properties: Record<string, Property>): { | ||
@@ -4,0 +4,0 @@ mockRestore(): void; |
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
import _toArray from "@babel/runtime/helpers/esm/toArray"; | ||
import get from './get'; | ||
import get from "./get"; | ||
function internalSet(entity, paths, value, removeIfUndefined) { | ||
@@ -20,2 +20,3 @@ if (!paths.length) { | ||
} | ||
// Delete prop if `removeIfUndefined` and value is undefined | ||
@@ -22,0 +23,0 @@ if (removeIfUndefined && value === undefined && restPath.length === 1) { |
@@ -10,4 +10,6 @@ "use strict"; | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -29,3 +31,3 @@ var _reactDom = _interopRequireDefault(require("react-dom")); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
_this.removeContainer = function () { | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeContainer", function () { | ||
if (_this.container) { | ||
@@ -36,4 +38,4 @@ _reactDom.default.unmountComponentAtNode(_this.container); | ||
} | ||
}; | ||
_this.renderComponent = function (props, ready) { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderComponent", function (props, ready) { | ||
var _this$props = _this.props, | ||
@@ -55,3 +57,3 @@ visible = _this$props.visible, | ||
} | ||
}; | ||
}); | ||
return _this; | ||
@@ -92,6 +94,6 @@ } | ||
exports.default = ContainerRender; | ||
ContainerRender.defaultProps = { | ||
(0, _defineProperty2.default)(ContainerRender, "defaultProps", { | ||
autoMount: true, | ||
autoDestroy: true, | ||
forceRender: false | ||
}; | ||
}); |
@@ -11,2 +11,3 @@ "use strict"; | ||
} | ||
// Use native if support | ||
@@ -16,2 +17,3 @@ if (root.contains) { | ||
} | ||
// `document.contains` not support with IE11 | ||
@@ -18,0 +20,0 @@ var node = n; |
@@ -1,4 +0,4 @@ | ||
export type ContainerType = Element | ShadowRoot; | ||
export type Prepend = boolean | 'queue'; | ||
export type AppendType = 'prependQueue' | 'append' | 'prepend'; | ||
export declare type ContainerType = Element | ShadowRoot; | ||
export declare type Prepend = boolean | 'queue'; | ||
export declare type AppendType = 'prependQueue' | 'append' | 'prepend'; | ||
interface Options { | ||
@@ -5,0 +5,0 @@ attachTo?: ContainerType; |
@@ -37,2 +37,3 @@ "use strict"; | ||
} | ||
/** | ||
@@ -55,3 +56,3 @@ * Find style which inject by rc-util | ||
styleNode.setAttribute(APPEND_ORDER, getOrder(prepend)); | ||
if (csp === null || csp === void 0 ? void 0 : csp.nonce) { | ||
if (csp !== null && csp !== void 0 && csp.nonce) { | ||
styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce; | ||
@@ -73,2 +74,3 @@ } | ||
} | ||
// Use `insertBefore` as `prepend` | ||
@@ -96,2 +98,3 @@ container.insertBefore(styleNode, firstChild); | ||
} | ||
/** | ||
@@ -102,2 +105,3 @@ * qiankun will inject `appendChild` to insert into other | ||
var cachedRealContainer = containerCache.get(container); | ||
// Find real container when not cached or cached container removed | ||
@@ -111,2 +115,3 @@ if (!cachedRealContainer || !(0, _contains.default)(document, cachedRealContainer)) { | ||
} | ||
/** | ||
@@ -121,2 +126,3 @@ * manually clear container cache to avoid global cache in unit testes | ||
var container = getContainer(option); | ||
// Sync real parent | ||
@@ -127,3 +133,3 @@ syncRealContainer(container, option); | ||
var _option$csp, _option$csp2; | ||
if (((_option$csp = option.csp) === null || _option$csp === void 0 ? void 0 : _option$csp.nonce) && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { | ||
if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) { | ||
var _option$csp3; | ||
@@ -130,0 +136,0 @@ existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce; |
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
/** | ||
@@ -3,0 +3,0 @@ * Return if a node is a DOM node. Else will return by `findDOMNode` |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.default = findDOMNode; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _reactDom = _interopRequireDefault(require("react-dom")); | ||
@@ -17,3 +18,6 @@ /** | ||
} | ||
return _reactDom.default.findDOMNode(node); | ||
if (node instanceof _react.default.Component) { | ||
return _reactDom.default.findDOMNode(node); | ||
} | ||
return null; | ||
} |
@@ -25,5 +25,7 @@ "use strict"; | ||
nodeName === 'a' && !!node.getAttribute('href'); | ||
// Get tabIndex | ||
var tabIndexAttr = node.getAttribute('tabindex'); | ||
var tabIndexNum = Number(tabIndexAttr); | ||
// Parse as number if validate | ||
@@ -36,2 +38,3 @@ var tabIndex = null; | ||
} | ||
// Block focusable if disabled | ||
@@ -56,2 +59,3 @@ if (isFocusableElement && node.disabled) { | ||
var lastFocusElement = null; | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -61,2 +65,3 @@ function saveLastFocusNode() { | ||
} | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -66,2 +71,3 @@ function clearLastFocusNode() { | ||
} | ||
/** @deprecated Do not use since this may failed when used in async */ | ||
@@ -73,2 +79,3 @@ function backLastFocusNode() { | ||
lastFocusElement.focus(); | ||
/* eslint-disable no-empty */ | ||
@@ -75,0 +82,0 @@ } catch (e) { |
@@ -11,2 +11,3 @@ "use strict"; | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _getScrollBarSize = _interopRequireDefault(require("../getScrollBarSize")); | ||
@@ -18,2 +19,3 @@ var _setStyle = _interopRequireDefault(require("../setStyle")); | ||
var scrollingEffectClassNameReg = new RegExp("".concat(scrollingEffectClassName), 'g'); | ||
// https://github.com/ant-design/ant-design/issues/19340 | ||
@@ -25,9 +27,9 @@ // https://github.com/ant-design/ant-design/issues/19332 | ||
(0, _classCallCheck2.default)(this, ScrollLocker); | ||
this.lockTarget = void 0; | ||
this.options = void 0; | ||
this.getContainer = function () { | ||
(0, _defineProperty2.default)(this, "lockTarget", void 0); | ||
(0, _defineProperty2.default)(this, "options", void 0); | ||
(0, _defineProperty2.default)(this, "getContainer", function () { | ||
var _this$options; | ||
return (_this$options = _this.options) === null || _this$options === void 0 ? void 0 : _this$options.container; | ||
}; | ||
this.reLock = function (options) { | ||
}); | ||
(0, _defineProperty2.default)(this, "reLock", function (options) { | ||
var findLock = locks.find(function (_ref) { | ||
@@ -45,4 +47,4 @@ var target = _ref.target; | ||
} | ||
}; | ||
this.lock = function () { | ||
}); | ||
(0, _defineProperty2.default)(this, "lock", function () { | ||
var _this$options3; | ||
@@ -56,2 +58,3 @@ // If lockTarget exist return | ||
} | ||
// If same container effect, return | ||
@@ -72,3 +75,5 @@ if (locks.some(function (_ref3) { | ||
if (container === document.body && window.innerWidth - document.documentElement.clientWidth > 0 || container.scrollHeight > container.clientHeight) { | ||
scrollBarSize = (0, _getScrollBarSize.default)(); | ||
if (getComputedStyle(container).overflow !== 'hidden') { | ||
scrollBarSize = (0, _getScrollBarSize.default)(); | ||
} | ||
} | ||
@@ -90,2 +95,3 @@ var containerClassName = container.className; | ||
} | ||
// https://github.com/ant-design/ant-design/issues/19729 | ||
@@ -100,4 +106,4 @@ if (!scrollingEffectClassNameReg.test(containerClassName)) { | ||
}]); | ||
}; | ||
this.unLock = function () { | ||
}); | ||
(0, _defineProperty2.default)(this, "unLock", function () { | ||
var _this$options5; | ||
@@ -119,2 +125,3 @@ var findLock = locks.find(function (_ref5) { | ||
} | ||
// Remove Effect | ||
@@ -129,3 +136,3 @@ var container = ((_this$options5 = _this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.container) || document.body; | ||
container.className = container.className.replace(scrollingEffectClassNameReg, '').trim(); | ||
}; | ||
}); | ||
// eslint-disable-next-line no-plusplus | ||
@@ -132,0 +139,0 @@ this.lockTarget = uuid++; |
@@ -9,2 +9,3 @@ "use strict"; | ||
/* eslint-disable no-param-reassign */ | ||
var cached; | ||
@@ -11,0 +12,0 @@ function getScrollBarSize(fresh) { |
@@ -19,2 +19,3 @@ "use strict"; | ||
var uuid = 0; | ||
/** @private Note only worked in develop env. Not work in production. */ | ||
@@ -41,2 +42,3 @@ function resetUuid() { | ||
}, []); | ||
// Developer passed id is single source of truth | ||
@@ -46,2 +48,3 @@ if (id) { | ||
} | ||
// Test env always return mock id | ||
@@ -51,4 +54,5 @@ if (process.env.NODE_ENV === 'test') { | ||
} | ||
// Return react native id or inner id | ||
return reactNativeId || innerId; | ||
} |
@@ -24,2 +24,3 @@ "use strict"; | ||
}, deps); | ||
// We tell react that first mount has passed | ||
@@ -26,0 +27,0 @@ useLayoutEffect(function () { |
@@ -1,2 +0,2 @@ | ||
type Updater<T> = (updater: T | ((origin: T) => T), ignoreDestroy?: boolean) => void; | ||
declare type Updater<T> = (updater: T | ((origin: T) => T), ignoreDestroy?: boolean) => void; | ||
/** | ||
@@ -3,0 +3,0 @@ * Similar to `useState` but will use props value if provided. |
@@ -16,2 +16,3 @@ "use strict"; | ||
} | ||
/** | ||
@@ -27,2 +28,3 @@ * Similar to `useState` but will use props value if provided. | ||
postState = _ref.postState; | ||
// ======================= Init ======================= | ||
@@ -43,2 +45,3 @@ var _useState = (0, _useState5.default)(function () { | ||
var postMergedValue = postState ? postState(mergedValue) : mergedValue; | ||
// ====================== Change ====================== | ||
@@ -56,2 +59,3 @@ var onChangeFn = (0, _useEvent.default)(onChange); | ||
}, [prevValue]); | ||
// Sync value back to `undefined` when it from control to un-control | ||
@@ -63,2 +67,3 @@ (0, _useLayoutEffect.useLayoutUpdateEffect)(function () { | ||
}, [value]); | ||
// ====================== Update ====================== | ||
@@ -65,0 +70,0 @@ var triggerChange = (0, _useEvent.default)(function (updater, ignoreDestroy) { |
@@ -1,3 +0,3 @@ | ||
type Updater<T> = T | ((prevValue: T) => T); | ||
export type SetState<T> = (nextValue: Updater<T>, | ||
declare type Updater<T> = T | ((prevValue: T) => T); | ||
export declare type SetState<T> = (nextValue: Updater<T>, | ||
/** | ||
@@ -4,0 +4,0 @@ * Will not update state when destroyed. |
@@ -12,2 +12,3 @@ "use strict"; | ||
*/ | ||
var KeyCode = { | ||
@@ -30,2 +31,3 @@ /** | ||
NUM_CENTER: 12, | ||
// NUMLOCK on FF/Safari Mac | ||
/** | ||
@@ -67,2 +69,3 @@ * ENTER | ||
PAGE_UP: 33, | ||
// also NUM_NORTH_EAST | ||
/** | ||
@@ -72,2 +75,3 @@ * PAGE_DOWN | ||
PAGE_DOWN: 34, | ||
// also NUM_SOUTH_EAST | ||
/** | ||
@@ -77,2 +81,3 @@ * END | ||
END: 35, | ||
// also NUM_SOUTH_WEST | ||
/** | ||
@@ -82,2 +87,3 @@ * HOME | ||
HOME: 36, | ||
// also NUM_NORTH_WEST | ||
/** | ||
@@ -87,2 +93,3 @@ * LEFT | ||
LEFT: 37, | ||
// also NUM_WEST | ||
/** | ||
@@ -92,2 +99,3 @@ * UP | ||
UP: 38, | ||
// also NUM_NORTH | ||
/** | ||
@@ -97,2 +105,3 @@ * RIGHT | ||
RIGHT: 39, | ||
// also NUM_EAST | ||
/** | ||
@@ -102,2 +111,3 @@ * DOWN | ||
DOWN: 40, | ||
// also NUM_SOUTH | ||
/** | ||
@@ -111,2 +121,3 @@ * PRINT_SCREEN | ||
INSERT: 45, | ||
// also NUM_INSERT | ||
/** | ||
@@ -116,2 +127,3 @@ * DELETE | ||
DELETE: 46, | ||
// also NUM_DELETE | ||
/** | ||
@@ -161,2 +173,3 @@ * ZERO | ||
QUESTION_MARK: 63, | ||
// needs localization | ||
/** | ||
@@ -270,2 +283,3 @@ * A | ||
META: 91, | ||
// WIN_KEY_LEFT | ||
/** | ||
@@ -395,2 +409,3 @@ * WIN_KEY_RIGHT | ||
SEMICOLON: 186, | ||
// needs localization | ||
/** | ||
@@ -400,2 +415,3 @@ * DASH | ||
DASH: 189, | ||
// needs localization | ||
/** | ||
@@ -405,2 +421,3 @@ * EQUALS | ||
EQUALS: 187, | ||
// needs localization | ||
/** | ||
@@ -410,2 +427,3 @@ * COMMA | ||
COMMA: 188, | ||
// needs localization | ||
/** | ||
@@ -415,2 +433,3 @@ * PERIOD | ||
PERIOD: 190, | ||
// needs localization | ||
/** | ||
@@ -420,2 +439,3 @@ * SLASH | ||
SLASH: 191, | ||
// needs localization | ||
/** | ||
@@ -425,2 +445,3 @@ * APOSTROPHE | ||
APOSTROPHE: 192, | ||
// needs localization | ||
/** | ||
@@ -430,2 +451,3 @@ * SINGLE_QUOTE | ||
SINGLE_QUOTE: 222, | ||
// needs localization | ||
/** | ||
@@ -435,2 +457,3 @@ * OPEN_SQUARE_BRACKET | ||
OPEN_SQUARE_BRACKET: 219, | ||
// needs localization | ||
/** | ||
@@ -440,2 +463,3 @@ * BACKSLASH | ||
BACKSLASH: 220, | ||
// needs localization | ||
/** | ||
@@ -445,2 +469,3 @@ * CLOSE_SQUARE_BRACKET | ||
CLOSE_SQUARE_BRACKET: 221, | ||
// needs localization | ||
/** | ||
@@ -454,2 +479,3 @@ * WIN_KEY | ||
MAC_FF_META: 224, | ||
// Firefox (Gecko) fires this for the meta key instead of 91 | ||
/** | ||
@@ -470,2 +496,3 @@ * WIN_IME | ||
} | ||
// The following keys are quite harmless, even in combination with | ||
@@ -515,2 +542,3 @@ // CTRL, ALT or SHIFT. | ||
} | ||
// Safari sends zero key code for non-latin characters. | ||
@@ -517,0 +545,0 @@ if (window.navigator.userAgent.indexOf('WebKit') !== -1 && keyCode === 0) { |
@@ -12,2 +12,3 @@ "use strict"; | ||
var propList = "".concat(attributes, " ").concat(eventsName).split(/[\s\n]+/); | ||
/* eslint-enable max-len */ | ||
@@ -14,0 +15,0 @@ var ariaPrefix = 'aria-'; |
import type * as React from 'react'; | ||
export type PortalRef = {}; | ||
export declare type PortalRef = {}; | ||
export interface PortalProps { | ||
@@ -4,0 +4,0 @@ didUpdate?: (prevProps: PortalProps) => void; |
@@ -17,2 +17,3 @@ "use strict"; | ||
var containerRef = (0, _react.useRef)(); | ||
// Ref return nothing, only for wrapper check exist | ||
@@ -22,2 +23,3 @@ (0, _react.useImperativeHandle)(ref, function () { | ||
}); | ||
// Create container in client side with sync to avoid useEffect not get ref | ||
@@ -30,2 +32,3 @@ var initRef = (0, _react.useRef)(false); | ||
} | ||
// [Legacy] Used by `rc-trigger` | ||
@@ -32,0 +35,0 @@ (0, _react.useEffect)(function () { |
@@ -6,3 +6,3 @@ import * as React from 'react'; | ||
export declare function getOpenCount(): number; | ||
export type GetContainer = string | HTMLElement | (() => HTMLElement); | ||
export declare type GetContainer = string | HTMLElement | (() => HTMLElement); | ||
export interface PortalWrapperProps { | ||
@@ -9,0 +9,0 @@ visible?: boolean; |
@@ -12,4 +12,6 @@ "use strict"; | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); | ||
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
@@ -27,2 +29,3 @@ var React = _interopRequireWildcard(require("react")); | ||
var supportDom = (0, _canUseDom.default)(); | ||
/** @private Test usage only */ | ||
@@ -32,2 +35,3 @@ function getOpenCount() { | ||
} | ||
// https://github.com/ant-design/ant-design/issues/19340 | ||
@@ -60,8 +64,8 @@ // https://github.com/ant-design/ant-design/issues/19332 | ||
_this = _super.call(this, props); | ||
_this.container = void 0; | ||
_this.componentRef = /*#__PURE__*/React.createRef(); | ||
_this.rafId = void 0; | ||
_this.scrollLocker = void 0; | ||
_this.renderComponent = void 0; | ||
_this.updateScrollLocker = function (prevProps) { | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "container", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "componentRef", /*#__PURE__*/React.createRef()); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rafId", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scrollLocker", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderComponent", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateScrollLocker", function (prevProps) { | ||
var _ref = prevProps || {}, | ||
@@ -77,4 +81,4 @@ prevVisible = _ref.visible; | ||
} | ||
}; | ||
_this.updateOpenCount = function (prevProps) { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateOpenCount", function (prevProps) { | ||
var _ref2 = prevProps || {}, | ||
@@ -86,2 +90,3 @@ prevVisible = _ref2.visible, | ||
getContainer = _this$props2.getContainer; | ||
// Update count | ||
@@ -95,2 +100,3 @@ if (visible !== prevVisible && supportDom && getParent(getContainer) === document.body) { | ||
} | ||
// Clean up container if needed | ||
@@ -101,4 +107,4 @@ var getContainerIsFunc = typeof getContainer === 'function' && typeof prevGetContainer === 'function'; | ||
} | ||
}; | ||
_this.attachToParent = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "attachToParent", function () { | ||
var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
@@ -114,4 +120,4 @@ if (force || _this.container && !_this.container.parentNode) { | ||
return true; | ||
}; | ||
_this.getContainer = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getContainer", function () { | ||
if (!supportDom) { | ||
@@ -126,4 +132,4 @@ return null; | ||
return _this.container; | ||
}; | ||
_this.setWrapperClassName = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setWrapperClassName", function () { | ||
var wrapperClassName = _this.props.wrapperClassName; | ||
@@ -133,4 +139,4 @@ if (_this.container && wrapperClassName && wrapperClassName !== _this.container.className) { | ||
} | ||
}; | ||
_this.removeCurrentContainer = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "removeCurrentContainer", function () { | ||
var _this$container, _this$container$paren; | ||
@@ -140,4 +146,4 @@ // Portal will remove from `parentNode`. | ||
(_this$container = _this.container) === null || _this$container === void 0 ? void 0 : (_this$container$paren = _this$container.parentNode) === null || _this$container$paren === void 0 ? void 0 : _this$container$paren.removeChild(_this.container); | ||
}; | ||
_this.switchScrollingEffect = function () { | ||
}); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "switchScrollingEffect", function () { | ||
if (openCount === 1 && !Object.keys(cacheOverflow).length) { | ||
@@ -156,3 +162,3 @@ (0, _switchScrollingEffect.default)(); | ||
} | ||
}; | ||
}); | ||
_this.scrollLocker = new _scrollLocker.default({ | ||
@@ -159,0 +165,0 @@ container: getParent(props.getContainer) |
@@ -34,2 +34,3 @@ "use strict"; | ||
cleanup(id); | ||
// Trigger | ||
@@ -42,2 +43,3 @@ callback(); | ||
}); | ||
// Bind real raf id | ||
@@ -44,0 +46,0 @@ rafIds.set(id, realId); |
import type * as React from 'react'; | ||
import type { Root } from 'react-dom/client'; | ||
declare const MARK = "__rc_react_root__"; | ||
type ContainerType = (Element | DocumentFragment) & { | ||
declare type ContainerType = (Element | DocumentFragment) & { | ||
[MARK]?: Root; | ||
@@ -6,0 +6,0 @@ }; |
@@ -38,2 +38,5 @@ "use strict"; | ||
var MARK = '__rc_react_root__'; | ||
// ========================== Render ========================== | ||
function modernRender(node, container) { | ||
@@ -49,2 +52,3 @@ toggleWarning(true); | ||
} | ||
/** @private Test usage. Not work in prod */ | ||
@@ -63,2 +67,3 @@ function _r(node, container) { | ||
} | ||
// ========================= Unmount ========================== | ||
@@ -71,14 +76,12 @@ function modernUnmount(_x) { | ||
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", Promise.resolve().then(function () { | ||
var _container$MARK; | ||
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount(); | ||
delete container[MARK]; | ||
})); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
while (1) switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", Promise.resolve().then(function () { | ||
var _container$MARK; | ||
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 ? void 0 : _container$MARK.unmount(); | ||
delete container[MARK]; | ||
})); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
@@ -92,2 +95,3 @@ }, _callee); | ||
} | ||
/** @private Test usage. Not work in prod */ | ||
@@ -105,16 +109,14 @@ function _u(container) { | ||
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!(createRoot !== undefined)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
return _context2.abrupt("return", modernUnmount(container)); | ||
case 2: | ||
legacyUnmount(container); | ||
case 3: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
while (1) switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (!(createRoot !== undefined)) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
return _context2.abrupt("return", modernUnmount(container)); | ||
case 2: | ||
legacyUnmount(container); | ||
case 3: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
@@ -121,0 +123,0 @@ }, _callee2); |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _useMemo = _interopRequireDefault(require("./hooks/useMemo")); | ||
/* eslint-disable no-param-reassign */ | ||
function fillRef(ref, node) { | ||
@@ -22,2 +24,3 @@ if (typeof ref === 'function') { | ||
} | ||
/** | ||
@@ -57,8 +60,10 @@ * Merge refs into one ref function to support ref passing. | ||
var type = (0, _reactIs.isMemo)(nodeOrComponent) ? nodeOrComponent.type.type : nodeOrComponent.type; | ||
// Function component node | ||
if (typeof type === 'function' && !((_type$prototype = type.prototype) === null || _type$prototype === void 0 ? void 0 : _type$prototype.render)) { | ||
if (typeof type === 'function' && !((_type$prototype = type.prototype) !== null && _type$prototype !== void 0 && _type$prototype.render)) { | ||
return false; | ||
} | ||
// Class component | ||
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) === null || _nodeOrComponent$prot === void 0 ? void 0 : _nodeOrComponent$prot.render)) { | ||
if (typeof nodeOrComponent === 'function' && !((_nodeOrComponent$prot = nodeOrComponent.prototype) !== null && _nodeOrComponent$prot !== void 0 && _nodeOrComponent$prot.render)) { | ||
return false; | ||
@@ -65,0 +70,0 @@ } |
@@ -22,2 +22,3 @@ "use strict"; | ||
var styleKeys = Object.keys(style); | ||
// IE browser compatible | ||
@@ -24,0 +25,0 @@ styleKeys.forEach(function (key) { |
@@ -1,3 +0,3 @@ | ||
export type ElementClass = Function; | ||
export type Property = PropertyDescriptor | Function; | ||
export declare type ElementClass = Function; | ||
export declare type Property = PropertyDescriptor | Function; | ||
export declare function spyElementPrototypes<T extends ElementClass>(elementClass: T, properties: Record<string, Property>): { | ||
@@ -4,0 +4,0 @@ mockRestore(): void; |
@@ -27,2 +27,3 @@ "use strict"; | ||
} | ||
// Delete prop if `removeIfUndefined` and value is undefined | ||
@@ -29,0 +30,0 @@ if (removeIfUndefined && value === undefined && restPath.length === 1) { |
{ | ||
"name": "rc-util", | ||
"version": "5.27.1", | ||
"version": "5.27.2", | ||
"description": "Common Utils For React Component", | ||
@@ -24,9 +24,8 @@ "keywords": [ | ||
"compile": "father build", | ||
"coverage": "father test --coverage && cat ./coverage/lcov.info | coveralls", | ||
"docs:build": "dumi build", | ||
"coverage": "npm test -- --coverage", | ||
"build": "dumi build", | ||
"lint": "eslint src/ --ext .tsx,.ts & eslint tests/ --ext .js", | ||
"now-build": "npm run docs:build", | ||
"prepublishOnly": "npm run compile && np --yolo --no-publish", | ||
"start": "dumi dev", | ||
"test": "father test" | ||
"test": "rc-test" | ||
}, | ||
@@ -38,3 +37,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^5.16.4", | ||
"@rc-component/father-plugin": "1.0.0", | ||
"@testing-library/react": "^13.0.0", | ||
@@ -46,11 +45,11 @@ "@types/jest": "^25.2.3", | ||
"@types/warning": "^3.0.0", | ||
"@umijs/fabric": "^2.0.8", | ||
"coveralls": "^3.1.0", | ||
"@umijs/fabric": "^3.0.0", | ||
"create-react-class": "^15.6.3", | ||
"cross-env": "^7.0.2", | ||
"dumi": "^1.1.4", | ||
"eslint": "^6.6.0", | ||
"father": "^2.29.9", | ||
"dumi": "^2.1.3", | ||
"eslint": "~7.32.0", | ||
"father": "^4.1.3", | ||
"glob": "^7.1.6", | ||
"np": "^6.2.3", | ||
"rc-test": "^7.0.14", | ||
"react": "^18.0.0", | ||
@@ -57,0 +56,0 @@ "react-dom": "^18.0.0", |
211465
6544