@rc-component/trigger 3.7.2 → 3.8.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/es/Popup/index.d.ts +2 -0
- package/es/Popup/index.js +3 -1
- package/es/UniqueProvider/index.js +1 -0
- package/es/context.d.ts +2 -0
- package/es/index.js +11 -2
- package/lib/Popup/index.d.ts +2 -0
- package/lib/Popup/index.js +3 -1
- package/lib/UniqueProvider/index.js +1 -0
- package/lib/context.d.ts +2 -0
- package/lib/index.js +11 -2
- package/package.json +2 -2
package/es/Popup/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ResizeObserverProps } from '@rc-component/resize-observer';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { TriggerProps } from '../';
|
|
5
5
|
import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
|
|
6
|
+
import type { PortalProps } from '@rc-component/portal';
|
|
6
7
|
export interface MobileConfig {
|
|
7
8
|
mask?: boolean;
|
|
8
9
|
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
@@ -11,6 +12,7 @@ export interface MobileConfig {
|
|
|
11
12
|
maskMotion?: CSSMotionProps;
|
|
12
13
|
}
|
|
13
14
|
export interface PopupProps {
|
|
15
|
+
onEsc?: PortalProps['onEsc'];
|
|
14
16
|
prefixCls: string;
|
|
15
17
|
className?: string;
|
|
16
18
|
style?: React.CSSProperties;
|
package/es/Popup/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import useOffsetStyle from "../hooks/useOffsetStyle";
|
|
|
12
12
|
import { useEvent } from '@rc-component/util';
|
|
13
13
|
const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
14
14
|
const {
|
|
15
|
+
onEsc,
|
|
15
16
|
popup,
|
|
16
17
|
className,
|
|
17
18
|
prefixCls,
|
|
@@ -120,7 +121,8 @@ const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
120
121
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
121
122
|
open: forceRender || isNodeVisible,
|
|
122
123
|
getContainer: getPopupContainer && (() => getPopupContainer(target)),
|
|
123
|
-
autoDestroy: autoDestroy
|
|
124
|
+
autoDestroy: autoDestroy,
|
|
125
|
+
onEsc: onEsc
|
|
124
126
|
}, /*#__PURE__*/React.createElement(Mask, {
|
|
125
127
|
prefixCls: prefixCls,
|
|
126
128
|
open: open,
|
|
@@ -119,6 +119,7 @@ const UniqueProvider = ({
|
|
|
119
119
|
}, /*#__PURE__*/React.createElement(Popup, {
|
|
120
120
|
ref: setPopupRef,
|
|
121
121
|
portal: Portal,
|
|
122
|
+
onEsc: mergedOptions.onEsc,
|
|
122
123
|
prefixCls: prefixCls,
|
|
123
124
|
popup: mergedOptions.popup,
|
|
124
125
|
className: clsx(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
package/es/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
|
+
import type { PortalProps } from '@rc-component/portal';
|
|
3
4
|
import type { TriggerProps } from './index';
|
|
4
5
|
import type { AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
|
|
5
6
|
export interface TriggerContextProps {
|
|
@@ -28,6 +29,7 @@ export interface UniqueShowOptions {
|
|
|
28
29
|
arrow?: ArrowTypeOuter;
|
|
29
30
|
getPopupContainer?: TriggerProps['getPopupContainer'];
|
|
30
31
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
32
|
+
onEsc?: PortalProps['onEsc'];
|
|
31
33
|
}
|
|
32
34
|
export interface UniqueContextProps {
|
|
33
35
|
show: (options: UniqueShowOptions, isOpen: () => boolean) => void;
|
package/es/index.js
CHANGED
|
@@ -175,7 +175,8 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
175
175
|
arrow: innerArrow,
|
|
176
176
|
getPopupContainer,
|
|
177
177
|
getPopupClassNameFromAlign,
|
|
178
|
-
id
|
|
178
|
+
id,
|
|
179
|
+
onEsc
|
|
179
180
|
}));
|
|
180
181
|
|
|
181
182
|
// Handle controlled state changes for UniqueProvider
|
|
@@ -233,6 +234,13 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
233
234
|
internalTriggerOpen(nextOpen);
|
|
234
235
|
}, delay);
|
|
235
236
|
};
|
|
237
|
+
function onEsc({
|
|
238
|
+
top
|
|
239
|
+
}) {
|
|
240
|
+
if (top) {
|
|
241
|
+
triggerOpen(false);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
236
244
|
|
|
237
245
|
// ========================== Motion ============================
|
|
238
246
|
const [inMotion, setInMotion] = React.useState(false);
|
|
@@ -518,7 +526,8 @@ export function generateTrigger(PortalComponent = Portal) {
|
|
|
518
526
|
,
|
|
519
527
|
forceRender: forceRender,
|
|
520
528
|
autoDestroy: mergedAutoDestroy,
|
|
521
|
-
getPopupContainer: getPopupContainer
|
|
529
|
+
getPopupContainer: getPopupContainer,
|
|
530
|
+
onEsc: onEsc
|
|
522
531
|
// Arrow
|
|
523
532
|
,
|
|
524
533
|
align: alignInfo,
|
package/lib/Popup/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ResizeObserverProps } from '@rc-component/resize-observer';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import type { TriggerProps } from '../';
|
|
5
5
|
import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
|
|
6
|
+
import type { PortalProps } from '@rc-component/portal';
|
|
6
7
|
export interface MobileConfig {
|
|
7
8
|
mask?: boolean;
|
|
8
9
|
/** Set popup motion. You can ref `rc-motion` for more info. */
|
|
@@ -11,6 +12,7 @@ export interface MobileConfig {
|
|
|
11
12
|
maskMotion?: CSSMotionProps;
|
|
12
13
|
}
|
|
13
14
|
export interface PopupProps {
|
|
15
|
+
onEsc?: PortalProps['onEsc'];
|
|
14
16
|
prefixCls: string;
|
|
15
17
|
className?: string;
|
|
16
18
|
style?: React.CSSProperties;
|
package/lib/Popup/index.js
CHANGED
|
@@ -21,6 +21,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
21
21
|
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); }
|
|
22
22
|
const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
23
23
|
const {
|
|
24
|
+
onEsc,
|
|
24
25
|
popup,
|
|
25
26
|
className,
|
|
26
27
|
prefixCls,
|
|
@@ -129,7 +130,8 @@ const Popup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
129
130
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
130
131
|
open: forceRender || isNodeVisible,
|
|
131
132
|
getContainer: getPopupContainer && (() => getPopupContainer(target)),
|
|
132
|
-
autoDestroy: autoDestroy
|
|
133
|
+
autoDestroy: autoDestroy,
|
|
134
|
+
onEsc: onEsc
|
|
133
135
|
}, /*#__PURE__*/React.createElement(_Mask.default, {
|
|
134
136
|
prefixCls: prefixCls,
|
|
135
137
|
open: open,
|
|
@@ -128,6 +128,7 @@ const UniqueProvider = ({
|
|
|
128
128
|
}, /*#__PURE__*/React.createElement(_Popup.default, {
|
|
129
129
|
ref: setPopupRef,
|
|
130
130
|
portal: _portal.default,
|
|
131
|
+
onEsc: mergedOptions.onEsc,
|
|
131
132
|
prefixCls: prefixCls,
|
|
132
133
|
popup: mergedOptions.popup,
|
|
133
134
|
className: (0, _clsx.clsx)(mergedOptions.popupClassName, alignedClassName, `${prefixCls}-unique-controlled`),
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { CSSMotionProps } from '@rc-component/motion';
|
|
3
|
+
import type { PortalProps } from '@rc-component/portal';
|
|
3
4
|
import type { TriggerProps } from './index';
|
|
4
5
|
import type { AlignType, ArrowTypeOuter, BuildInPlacements } from './interface';
|
|
5
6
|
export interface TriggerContextProps {
|
|
@@ -28,6 +29,7 @@ export interface UniqueShowOptions {
|
|
|
28
29
|
arrow?: ArrowTypeOuter;
|
|
29
30
|
getPopupContainer?: TriggerProps['getPopupContainer'];
|
|
30
31
|
getPopupClassNameFromAlign?: (align: AlignType) => string;
|
|
32
|
+
onEsc?: PortalProps['onEsc'];
|
|
31
33
|
}
|
|
32
34
|
export interface UniqueContextProps {
|
|
33
35
|
show: (options: UniqueShowOptions, isOpen: () => boolean) => void;
|
package/lib/index.js
CHANGED
|
@@ -189,7 +189,8 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
189
189
|
arrow: innerArrow,
|
|
190
190
|
getPopupContainer,
|
|
191
191
|
getPopupClassNameFromAlign,
|
|
192
|
-
id
|
|
192
|
+
id,
|
|
193
|
+
onEsc
|
|
193
194
|
}));
|
|
194
195
|
|
|
195
196
|
// Handle controlled state changes for UniqueProvider
|
|
@@ -247,6 +248,13 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
247
248
|
internalTriggerOpen(nextOpen);
|
|
248
249
|
}, delay);
|
|
249
250
|
};
|
|
251
|
+
function onEsc({
|
|
252
|
+
top
|
|
253
|
+
}) {
|
|
254
|
+
if (top) {
|
|
255
|
+
triggerOpen(false);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
250
258
|
|
|
251
259
|
// ========================== Motion ============================
|
|
252
260
|
const [inMotion, setInMotion] = React.useState(false);
|
|
@@ -532,7 +540,8 @@ function generateTrigger(PortalComponent = _portal.default) {
|
|
|
532
540
|
,
|
|
533
541
|
forceRender: forceRender,
|
|
534
542
|
autoDestroy: mergedAutoDestroy,
|
|
535
|
-
getPopupContainer: getPopupContainer
|
|
543
|
+
getPopupContainer: getPopupContainer,
|
|
544
|
+
onEsc: onEsc
|
|
536
545
|
// Arrow
|
|
537
546
|
,
|
|
538
547
|
align: alignInfo,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc-component/trigger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "base abstract trigger component for react",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.x"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@rc-component/motion": "^1.1.4",
|
|
45
|
-
"@rc-component/portal": "^2.
|
|
45
|
+
"@rc-component/portal": "^2.2.0",
|
|
46
46
|
"@rc-component/resize-observer": "^1.0.0",
|
|
47
47
|
"@rc-component/util": "^1.2.1",
|
|
48
48
|
"clsx": "^2.1.1"
|