@rc-component/dialog 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -17
- package/dist/common-async.js +2518 -0
- package/dist/common-async.js.map +1 -0
- package/dist/demos-async.css +396 -0
- package/dist/demos-async.css.map +1 -0
- package/dist/demos-async.js +1242 -0
- package/dist/demos-async.js.map +1 -0
- package/dist/docs_changelog_md-async.js +2141 -0
- package/dist/docs_changelog_md-async.js.map +1 -0
- package/dist/docs_demo_ant-design_md-async.js +101 -0
- package/dist/docs_demo_ant-design_md-async.js.map +1 -0
- package/dist/docs_demo_bootstrap_md-async.js +101 -0
- package/dist/docs_demo_bootstrap_md-async.js.map +1 -0
- package/dist/docs_demo_draggable_md-async.js +101 -0
- package/dist/docs_demo_draggable_md-async.js.map +1 -0
- package/dist/docs_demo_multiple-Portal_md-async.js +147 -0
- package/dist/docs_demo_multiple-Portal_md-async.js.map +1 -0
- package/dist/docs_demo_pure_md-async.js +101 -0
- package/dist/docs_demo_pure_md-async.js.map +1 -0
- package/dist/docs_index_md-async.js +1754 -0
- package/dist/docs_index_md-async.js.map +1 -0
- package/dist/dumi__tmp__dumi__theme__ContextWrapper-async.js +201 -0
- package/dist/dumi__tmp__dumi__theme__ContextWrapper-async.js.map +1 -0
- package/dist/meta__docs-async.css +396 -0
- package/dist/meta__docs-async.css.map +1 -0
- package/dist/meta__docs-async.js +1048 -0
- package/dist/meta__docs-async.js.map +1 -0
- package/dist/nm__dumi__dist__client__pages__404-async.js +69 -0
- package/dist/nm__dumi__dist__client__pages__404-async.js.map +1 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index-async.js +63 -0
- package/dist/nm__dumi__dist__client__pages__Demo__index-async.js.map +1 -0
- package/dist/node_modules_dumi_dist_client_misc_reactDemoCompiler_js-async.js +368 -0
- package/dist/node_modules_dumi_dist_client_misc_reactDemoCompiler_js-async.js.map +1 -0
- package/dist/node_modules_dumi_theme-default_layouts_DocLayout_index_js-async.js +1077 -0
- package/dist/node_modules_dumi_theme-default_layouts_DocLayout_index_js-async.js.map +1 -0
- package/dist/node_modules_react-dom_server_browser_js-async.js +18 -0
- package/dist/node_modules_react-dom_server_browser_js-async.js.map +1 -0
- package/dist/umi.css +1317 -0
- package/dist/umi.css.map +1 -0
- package/dist/umi.js +83003 -0
- package/dist/umi.js.map +1 -0
- package/dist/vendors-async.css +26259 -0
- package/dist/vendors-async.css.map +1 -0
- package/dist/vendors-async.js +56792 -0
- package/dist/vendors-async.js.map +1 -0
- package/es/Dialog/Content/Panel.d.ts +0 -1
- package/es/Dialog/Content/Panel.js +8 -37
- package/es/Dialog/index.js +0 -7
- package/lib/Dialog/Content/Panel.d.ts +0 -1
- package/lib/Dialog/Content/Panel.js +8 -37
- package/lib/Dialog/index.js +0 -7
- package/package.json +2 -2
|
@@ -9,7 +9,6 @@ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
|
9
9
|
}
|
|
10
10
|
export type PanelRef = {
|
|
11
11
|
focus: () => void;
|
|
12
|
-
changeActive: (next: boolean) => void;
|
|
13
12
|
};
|
|
14
13
|
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<PanelRef>>;
|
|
15
14
|
export default Panel;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { useComposeRef } from "@rc-component/util/es/ref";
|
|
4
|
+
import { useLockFocus } from "@rc-component/util/es/Dom/focus";
|
|
4
5
|
import React, { useMemo, useRef } from 'react';
|
|
5
6
|
import { RefContext } from "../../context";
|
|
6
7
|
import MemoChildren from "./MemoChildren";
|
|
7
8
|
import pickAttrs from "@rc-component/util/es/pickAttrs";
|
|
8
|
-
const sentinelStyle = {
|
|
9
|
-
width: 0,
|
|
10
|
-
height: 0,
|
|
11
|
-
overflow: 'hidden',
|
|
12
|
-
outline: 'none'
|
|
13
|
-
};
|
|
14
|
-
const entityStyle = {
|
|
15
|
-
outline: 'none'
|
|
16
|
-
};
|
|
17
9
|
const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
18
10
|
const {
|
|
19
11
|
prefixCls,
|
|
@@ -44,28 +36,14 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
44
36
|
const {
|
|
45
37
|
panel: panelRef
|
|
46
38
|
} = React.useContext(RefContext);
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
39
|
+
const internalRef = useRef(null);
|
|
40
|
+
const mergedRef = useComposeRef(holderRef, panelRef, internalRef);
|
|
41
|
+
useLockFocus(visible, () => internalRef.current);
|
|
50
42
|
React.useImperativeHandle(ref, () => ({
|
|
51
43
|
focus: () => {
|
|
52
|
-
|
|
44
|
+
internalRef.current?.focus({
|
|
53
45
|
preventScroll: true
|
|
54
46
|
});
|
|
55
|
-
},
|
|
56
|
-
changeActive: next => {
|
|
57
|
-
const {
|
|
58
|
-
activeElement
|
|
59
|
-
} = document;
|
|
60
|
-
if (next && activeElement === sentinelEndRef.current) {
|
|
61
|
-
sentinelStartRef.current.focus({
|
|
62
|
-
preventScroll: true
|
|
63
|
-
});
|
|
64
|
-
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
65
|
-
sentinelEndRef.current.focus({
|
|
66
|
-
preventScroll: true
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
47
|
}
|
|
70
48
|
}));
|
|
71
49
|
|
|
@@ -141,18 +119,11 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
141
119
|
},
|
|
142
120
|
className: clsx(prefixCls, className),
|
|
143
121
|
onMouseDown: onMouseDown,
|
|
144
|
-
onMouseUp: onMouseUp
|
|
145
|
-
|
|
146
|
-
ref: sentinelStartRef,
|
|
147
|
-
tabIndex: 0,
|
|
148
|
-
style: entityStyle
|
|
122
|
+
onMouseUp: onMouseUp,
|
|
123
|
+
tabIndex: -1
|
|
149
124
|
}, /*#__PURE__*/React.createElement(MemoChildren, {
|
|
150
125
|
shouldUpdate: visible || forceRender
|
|
151
|
-
}, modalRender ? modalRender(content) : content))
|
|
152
|
-
tabIndex: 0,
|
|
153
|
-
ref: sentinelEndRef,
|
|
154
|
-
style: sentinelStyle
|
|
155
|
-
}));
|
|
126
|
+
}, modalRender ? modalRender(content) : content));
|
|
156
127
|
});
|
|
157
128
|
if (process.env.NODE_ENV !== 'production') {
|
|
158
129
|
Panel.displayName = 'Panel';
|
package/es/Dialog/index.js
CHANGED
|
@@ -43,7 +43,6 @@ const Dialog = props => {
|
|
|
43
43
|
} = props;
|
|
44
44
|
if (process.env.NODE_ENV !== 'production') {
|
|
45
45
|
['wrapStyle', 'bodyStyle', 'maskStyle'].forEach(prop => {
|
|
46
|
-
// (prop in props) && console.error(`Warning: ${prop} is deprecated, please use styles instead.`)
|
|
47
46
|
warning(!(prop in props), `${prop} is deprecated, please use styles instead.`);
|
|
48
47
|
});
|
|
49
48
|
if ('wrapClassName' in props) {
|
|
@@ -137,11 +136,6 @@ const Dialog = props => {
|
|
|
137
136
|
onInternalClose(e);
|
|
138
137
|
return;
|
|
139
138
|
}
|
|
140
|
-
|
|
141
|
-
// keep focus inside dialog
|
|
142
|
-
if (visible && e.keyCode === KeyCode.TAB) {
|
|
143
|
-
contentRef.current.changeActive(!e.shiftKey);
|
|
144
|
-
}
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
// ========================= Effect =========================
|
|
@@ -183,7 +177,6 @@ const Dialog = props => {
|
|
|
183
177
|
maskProps: maskProps,
|
|
184
178
|
className: modalClassNames?.mask
|
|
185
179
|
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
186
|
-
tabIndex: -1,
|
|
187
180
|
onKeyDown: onWrapperKeyDown,
|
|
188
181
|
className: clsx(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
189
182
|
ref: wrapperRef,
|
|
@@ -9,7 +9,6 @@ export interface PanelProps extends Omit<IDialogPropTypes, 'getOpenCount'> {
|
|
|
9
9
|
}
|
|
10
10
|
export type PanelRef = {
|
|
11
11
|
focus: () => void;
|
|
12
|
-
changeActive: (next: boolean) => void;
|
|
13
12
|
};
|
|
14
13
|
declare const Panel: React.ForwardRefExoticComponent<PanelProps & React.RefAttributes<PanelRef>>;
|
|
15
14
|
export default Panel;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _clsx = require("clsx");
|
|
8
8
|
var _ref = require("@rc-component/util/lib/ref");
|
|
9
|
+
var _focus = require("@rc-component/util/lib/Dom/focus");
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _context = require("../../context");
|
|
11
12
|
var _MemoChildren = _interopRequireDefault(require("./MemoChildren"));
|
|
@@ -14,15 +15,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
16
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
17
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
-
const sentinelStyle = {
|
|
18
|
-
width: 0,
|
|
19
|
-
height: 0,
|
|
20
|
-
overflow: 'hidden',
|
|
21
|
-
outline: 'none'
|
|
22
|
-
};
|
|
23
|
-
const entityStyle = {
|
|
24
|
-
outline: 'none'
|
|
25
|
-
};
|
|
26
18
|
const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
27
19
|
const {
|
|
28
20
|
prefixCls,
|
|
@@ -53,28 +45,14 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
53
45
|
const {
|
|
54
46
|
panel: panelRef
|
|
55
47
|
} = _react.default.useContext(_context.RefContext);
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
48
|
+
const internalRef = (0, _react.useRef)(null);
|
|
49
|
+
const mergedRef = (0, _ref.useComposeRef)(holderRef, panelRef, internalRef);
|
|
50
|
+
(0, _focus.useLockFocus)(visible, () => internalRef.current);
|
|
59
51
|
_react.default.useImperativeHandle(ref, () => ({
|
|
60
52
|
focus: () => {
|
|
61
|
-
|
|
53
|
+
internalRef.current?.focus({
|
|
62
54
|
preventScroll: true
|
|
63
55
|
});
|
|
64
|
-
},
|
|
65
|
-
changeActive: next => {
|
|
66
|
-
const {
|
|
67
|
-
activeElement
|
|
68
|
-
} = document;
|
|
69
|
-
if (next && activeElement === sentinelEndRef.current) {
|
|
70
|
-
sentinelStartRef.current.focus({
|
|
71
|
-
preventScroll: true
|
|
72
|
-
});
|
|
73
|
-
} else if (!next && activeElement === sentinelStartRef.current) {
|
|
74
|
-
sentinelEndRef.current.focus({
|
|
75
|
-
preventScroll: true
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
56
|
}
|
|
79
57
|
}));
|
|
80
58
|
|
|
@@ -150,18 +128,11 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
150
128
|
},
|
|
151
129
|
className: (0, _clsx.clsx)(prefixCls, className),
|
|
152
130
|
onMouseDown: onMouseDown,
|
|
153
|
-
onMouseUp: onMouseUp
|
|
154
|
-
|
|
155
|
-
ref: sentinelStartRef,
|
|
156
|
-
tabIndex: 0,
|
|
157
|
-
style: entityStyle
|
|
131
|
+
onMouseUp: onMouseUp,
|
|
132
|
+
tabIndex: -1
|
|
158
133
|
}, /*#__PURE__*/_react.default.createElement(_MemoChildren.default, {
|
|
159
134
|
shouldUpdate: visible || forceRender
|
|
160
|
-
}, modalRender ? modalRender(content) : content))
|
|
161
|
-
tabIndex: 0,
|
|
162
|
-
ref: sentinelEndRef,
|
|
163
|
-
style: sentinelStyle
|
|
164
|
-
}));
|
|
135
|
+
}, modalRender ? modalRender(content) : content));
|
|
165
136
|
});
|
|
166
137
|
if (process.env.NODE_ENV !== 'production') {
|
|
167
138
|
Panel.displayName = 'Panel';
|
package/lib/Dialog/index.js
CHANGED
|
@@ -52,7 +52,6 @@ const Dialog = props => {
|
|
|
52
52
|
} = props;
|
|
53
53
|
if (process.env.NODE_ENV !== 'production') {
|
|
54
54
|
['wrapStyle', 'bodyStyle', 'maskStyle'].forEach(prop => {
|
|
55
|
-
// (prop in props) && console.error(`Warning: ${prop} is deprecated, please use styles instead.`)
|
|
56
55
|
(0, _warning.warning)(!(prop in props), `${prop} is deprecated, please use styles instead.`);
|
|
57
56
|
});
|
|
58
57
|
if ('wrapClassName' in props) {
|
|
@@ -146,11 +145,6 @@ const Dialog = props => {
|
|
|
146
145
|
onInternalClose(e);
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
|
-
|
|
150
|
-
// keep focus inside dialog
|
|
151
|
-
if (visible && e.keyCode === _KeyCode.default.TAB) {
|
|
152
|
-
contentRef.current.changeActive(!e.shiftKey);
|
|
153
|
-
}
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
// ========================= Effect =========================
|
|
@@ -192,7 +186,6 @@ const Dialog = props => {
|
|
|
192
186
|
maskProps: maskProps,
|
|
193
187
|
className: modalClassNames?.mask
|
|
194
188
|
}), /*#__PURE__*/React.createElement("div", _extends({
|
|
195
|
-
tabIndex: -1,
|
|
196
189
|
onKeyDown: onWrapperKeyDown,
|
|
197
190
|
className: (0, _clsx.clsx)(`${prefixCls}-wrap`, wrapClassName, modalClassNames?.wrapper),
|
|
198
191
|
ref: wrapperRef,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/dialog",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "dialog ui component for react",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@rc-component/motion": "^1.1.3",
|
|
54
54
|
"@rc-component/portal": "^2.0.0",
|
|
55
|
-
"@rc-component/util": "^1.0
|
|
55
|
+
"@rc-component/util": "^1.5.0",
|
|
56
56
|
"clsx": "^2.1.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|