rc-drawer
Advanced tools
Comparing version 4.3.1 to 4.4.0
@@ -10,2 +10,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _createSuper from "@babel/runtime/helpers/esm/createSuper"; | ||
var _excluded = ["className", "children", "style", "width", "height", "defaultOpen", "open", "prefixCls", "placement", "level", "levelMove", "ease", "duration", "getContainer", "handler", "onChange", "afterVisibleChange", "showMask", "maskClosable", "maskStyle", "onClose", "onHandleClick", "keyboard", "getOpenCount", "scrollLocker", "contentWrapperStyle"]; | ||
import * as React from 'react'; | ||
@@ -30,2 +31,12 @@ import classnames from 'classnames'; | ||
_this = _super.call(this, props); | ||
_this.levelDom = void 0; | ||
_this.dom = void 0; | ||
_this.contentWrapper = void 0; | ||
_this.contentDom = void 0; | ||
_this.maskDom = void 0; | ||
_this.handlerDom = void 0; | ||
_this.drawerId = void 0; | ||
_this.timeout = void 0; | ||
_this.passive = void 0; | ||
_this.startPos = void 0; | ||
@@ -378,3 +389,4 @@ _this.domFocus = function () { | ||
getContainer = _this$props7.getContainer, | ||
showMask = _this$props7.showMask; | ||
showMask = _this$props7.showMask, | ||
autoFocus = _this$props7.autoFocus; | ||
var container = getContainer && getContainer(); | ||
@@ -392,3 +404,5 @@ this.drawerId = "drawer_id_".concat(Number((Date.now() + Math.random()).toString().replace('.', Math.round(Math.random() * 9).toString())).toString(16)); | ||
this.forceUpdate(function () { | ||
_this2.domFocus(); | ||
if (autoFocus) { | ||
_this2.domFocus(); | ||
} | ||
}); | ||
@@ -410,3 +424,4 @@ | ||
scrollLocker = _this$props8.scrollLocker, | ||
showMask = _this$props8.showMask; | ||
showMask = _this$props8.showMask, | ||
autoFocus = _this$props8.autoFocus; | ||
var container = getContainer && getContainer(); | ||
@@ -422,3 +437,5 @@ | ||
if (open) { | ||
this.domFocus(); | ||
if (autoFocus) { | ||
this.domFocus(); | ||
} | ||
@@ -447,7 +464,7 @@ if (showMask) { | ||
scrollLocker === null || scrollLocker === void 0 ? void 0 : scrollLocker.unLock(); | ||
} // tslint:disable-next-line:member-ordering | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
value: // tslint:disable-next-line:member-ordering | ||
function render() { | ||
var _classnames, | ||
@@ -483,3 +500,3 @@ _this3 = this; | ||
contentWrapperStyle = _this$props10.contentWrapperStyle, | ||
props = _objectWithoutProperties(_this$props10, ["className", "children", "style", "width", "height", "defaultOpen", "open", "prefixCls", "placement", "level", "levelMove", "ease", "duration", "getContainer", "handler", "onChange", "afterVisibleChange", "showMask", "maskClosable", "maskStyle", "onClose", "onHandleClick", "keyboard", "getOpenCount", "scrollLocker", "contentWrapperStyle"]); // 首次渲染都将是关闭状态。 | ||
props = _objectWithoutProperties(_this$props10, _excluded); // 首次渲染都将是关闭状态。 | ||
@@ -486,0 +503,0 @@ |
@@ -25,2 +25,3 @@ import * as React from 'react'; | ||
forceRender: boolean; | ||
autoFocus: boolean; | ||
}; | ||
@@ -27,0 +28,0 @@ static getDerivedStateFromProps(props: IDrawerProps, { prevProps }: { |
@@ -7,2 +7,4 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _createSuper from "@babel/runtime/helpers/esm/createSuper"; | ||
var _excluded = ["defaultOpen", "getContainer", "wrapperClassName", "forceRender", "handler"], | ||
_excluded2 = ["visible", "afterClose"]; | ||
import Portal from "rc-util/es/PortalWrapper"; | ||
@@ -23,2 +25,3 @@ import * as React from 'react'; | ||
_this = _super.call(this, props); | ||
_this.dom = void 0; | ||
@@ -35,6 +38,6 @@ _this.onHandleClick = function (e) { | ||
if (typeof $open === 'undefined') { | ||
var _open = _this.state.open; | ||
var open = _this.state.open; | ||
_this.setState({ | ||
open: !_open | ||
open: !open | ||
}); | ||
@@ -60,5 +63,6 @@ } | ||
var open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen; | ||
var _open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen; | ||
_this.state = { | ||
open: open | ||
open: _open | ||
}; | ||
@@ -85,3 +89,3 @@ | ||
handler = _this$props3.handler, | ||
props = _objectWithoutProperties(_this$props3, ["defaultOpen", "getContainer", "wrapperClassName", "forceRender", "handler"]); | ||
props = _objectWithoutProperties(_this$props3, _excluded); | ||
@@ -117,3 +121,3 @@ var open = this.state.open; // 渲染在当前 dom 里; | ||
afterClose = _ref.afterClose, | ||
rest = _objectWithoutProperties(_ref, ["visible", "afterClose"]); | ||
rest = _objectWithoutProperties(_ref, _excluded2); | ||
@@ -173,4 +177,5 @@ return ( | ||
keyboard: true, | ||
forceRender: false | ||
forceRender: false, | ||
autoFocus: true | ||
}; | ||
export default DrawerWrapper; |
@@ -31,2 +31,3 @@ import type { GetContainer } from 'rc-util/lib/PortalWrapper'; | ||
contentWrapperStyle?: React.CSSProperties; | ||
autoFocus?: boolean; | ||
} | ||
@@ -33,0 +34,0 @@ export interface IDrawerProps extends IProps { |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -42,2 +42,3 @@ value: true | ||
var _excluded = ["className", "children", "style", "width", "height", "defaultOpen", "open", "prefixCls", "placement", "level", "levelMove", "ease", "duration", "getContainer", "handler", "onChange", "afterVisibleChange", "showMask", "maskClosable", "maskStyle", "onClose", "onHandleClick", "keyboard", "getOpenCount", "scrollLocker", "contentWrapperStyle"]; | ||
var currentDrawer = {}; | ||
@@ -55,2 +56,12 @@ | ||
_this = _super.call(this, props); | ||
_this.levelDom = void 0; | ||
_this.dom = void 0; | ||
_this.contentWrapper = void 0; | ||
_this.contentDom = void 0; | ||
_this.maskDom = void 0; | ||
_this.handlerDom = void 0; | ||
_this.drawerId = void 0; | ||
_this.timeout = void 0; | ||
_this.passive = void 0; | ||
_this.startPos = void 0; | ||
@@ -403,3 +414,4 @@ _this.domFocus = function () { | ||
getContainer = _this$props7.getContainer, | ||
showMask = _this$props7.showMask; | ||
showMask = _this$props7.showMask, | ||
autoFocus = _this$props7.autoFocus; | ||
var container = getContainer && getContainer(); | ||
@@ -417,3 +429,5 @@ this.drawerId = "drawer_id_".concat(Number((Date.now() + Math.random()).toString().replace('.', Math.round(Math.random() * 9).toString())).toString(16)); | ||
this.forceUpdate(function () { | ||
_this2.domFocus(); | ||
if (autoFocus) { | ||
_this2.domFocus(); | ||
} | ||
}); | ||
@@ -435,3 +449,4 @@ | ||
scrollLocker = _this$props8.scrollLocker, | ||
showMask = _this$props8.showMask; | ||
showMask = _this$props8.showMask, | ||
autoFocus = _this$props8.autoFocus; | ||
var container = getContainer && getContainer(); | ||
@@ -447,3 +462,5 @@ | ||
if (open) { | ||
this.domFocus(); | ||
if (autoFocus) { | ||
this.domFocus(); | ||
} | ||
@@ -472,7 +489,7 @@ if (showMask) { | ||
scrollLocker === null || scrollLocker === void 0 ? void 0 : scrollLocker.unLock(); | ||
} // tslint:disable-next-line:member-ordering | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
value: // tslint:disable-next-line:member-ordering | ||
function render() { | ||
var _classnames, | ||
@@ -508,3 +525,3 @@ _this3 = this; | ||
contentWrapperStyle = _this$props10.contentWrapperStyle, | ||
props = (0, _objectWithoutProperties2.default)(_this$props10, ["className", "children", "style", "width", "height", "defaultOpen", "open", "prefixCls", "placement", "level", "levelMove", "ease", "duration", "getContainer", "handler", "onChange", "afterVisibleChange", "showMask", "maskClosable", "maskStyle", "onClose", "onHandleClick", "keyboard", "getOpenCount", "scrollLocker", "contentWrapperStyle"]); // 首次渲染都将是关闭状态。 | ||
props = (0, _objectWithoutProperties2.default)(_this$props10, _excluded); // 首次渲染都将是关闭状态。 | ||
@@ -511,0 +528,0 @@ var open = this.dom ? $open : false; |
@@ -25,2 +25,3 @@ import * as React from 'react'; | ||
forceRender: boolean; | ||
autoFocus: boolean; | ||
}; | ||
@@ -27,0 +28,0 @@ static getDerivedStateFromProps(props: IDrawerProps, { prevProps }: { |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -30,2 +30,5 @@ value: true | ||
var _excluded = ["defaultOpen", "getContainer", "wrapperClassName", "forceRender", "handler"], | ||
_excluded2 = ["visible", "afterClose"]; | ||
var DrawerWrapper = /*#__PURE__*/function (_React$Component) { | ||
@@ -41,2 +44,3 @@ (0, _inherits2.default)(DrawerWrapper, _React$Component); | ||
_this = _super.call(this, props); | ||
_this.dom = void 0; | ||
@@ -53,6 +57,6 @@ _this.onHandleClick = function (e) { | ||
if (typeof $open === 'undefined') { | ||
var _open = _this.state.open; | ||
var open = _this.state.open; | ||
_this.setState({ | ||
open: !_open | ||
open: !open | ||
}); | ||
@@ -78,5 +82,6 @@ } | ||
var open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen; | ||
var _open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen; | ||
_this.state = { | ||
open: open | ||
open: _open | ||
}; | ||
@@ -103,3 +108,3 @@ | ||
handler = _this$props3.handler, | ||
props = (0, _objectWithoutProperties2.default)(_this$props3, ["defaultOpen", "getContainer", "wrapperClassName", "forceRender", "handler"]); | ||
props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded); | ||
var open = this.state.open; // 渲染在当前 dom 里; | ||
@@ -134,3 +139,3 @@ | ||
afterClose = _ref.afterClose, | ||
rest = (0, _objectWithoutProperties2.default)(_ref, ["visible", "afterClose"]); | ||
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded2); | ||
return ( | ||
@@ -188,5 +193,6 @@ /*#__PURE__*/ | ||
keyboard: true, | ||
forceRender: false | ||
forceRender: false, | ||
autoFocus: true | ||
}; | ||
var _default = DrawerWrapper; | ||
exports.default = _default; |
@@ -31,2 +31,3 @@ import type { GetContainer } from 'rc-util/lib/PortalWrapper'; | ||
contentWrapperStyle?: React.CSSProperties; | ||
autoFocus?: boolean; | ||
} | ||
@@ -33,0 +34,0 @@ export interface IDrawerProps extends IProps { |
{ | ||
"name": "rc-drawer", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"description": "drawer component for react", | ||
@@ -35,4 +35,4 @@ "keywords": [ | ||
"scripts": { | ||
"start": "rm -rf .storybook lib es && father doc dev --storybook", | ||
"build": "father doc build --storybook", | ||
"start": "dumi dev", | ||
"build": "dumi build", | ||
"compile": "father build && lessc assets/index.less assets/index.css", | ||
@@ -58,6 +58,7 @@ "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", | ||
"@types/raf": "^3.4.0", | ||
"@types/react": "^16.9.5", | ||
"@types/react-dom": "^16.9.1", | ||
"@types/react": "^17.0.9", | ||
"@types/react-dom": "^17.0.6", | ||
"@types/warning": "^3.0.0", | ||
"@umijs/fabric": "^2.0.0", | ||
"dumi": "^1.1.10", | ||
"enzyme": "^3.10.0", | ||
@@ -68,5 +69,6 @@ "enzyme-adapter-react-16": "^1.14.0", | ||
"father": "^2.13.2", | ||
"glob": "^7.1.6", | ||
"jsonp": "^0.2.0", | ||
"less": "^3.10.3", | ||
"np": "^6.0.0", | ||
"np": "^7.5.0", | ||
"querystring": "^0.2.0", | ||
@@ -73,0 +75,0 @@ "rc-test": "^6.0.1", |
# rc-drawer | ||
--- | ||
[![NPM version][npm-image]][npm-url] | ||
[![build status][github-actions-image]][github-actions-url] | ||
[![codecov](https://codecov.io/gh/react-component/drawer/branch/master/graph/badge.svg)](https://codecov.io/gh/react-component/drawer) | ||
[![node version][node-image]][node-url] | ||
[![npm download][download-image]][download-url] | ||
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![codecov](https://codecov.io/gh/react-component/drawer/branch/master/graph/badge.svg)](https://codecov.io/gh/react-component/drawer) [![node version][node-image]][node-url] [![npm download][download-image]][download-url] | ||
@@ -21,3 +16,3 @@ [npm-image]: http://img.shields.io/npm/v/rc-drawer.svg?style=flat-square | ||
https://rc-drawer.react-component.now.sh | ||
https://drawer-react-component.vercel.app/ | ||
@@ -75,2 +70,3 @@ ## Usage | ||
| contentWrapperStyle | CSSProperties | null | content wrapper style | | ||
| autoFocus | Boolean | true | Whether focusing on the drawer after it opened | | ||
@@ -77,0 +73,0 @@ > 2.0 Rename `onMaskClick` -> `onClose`, add `maskClosable`. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
82035
1938
24
79