@rc-component/dialog 1.2.0 → 1.4.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 CHANGED
@@ -49,34 +49,34 @@ ReactDOM.render(
49
49
 
50
50
  ### rc-dialog
51
51
 
52
- | Name | Type | Default | Description | Version |
53
- | ---------------------- | ------------------------------ | --------- | ------------------------------------------------------------------------------- | ------- |
54
- | prefixCls | String | rc-dialog | The dialog dom node's prefixCls | |
55
- | className | String | | additional className for dialog | |
56
- | classNames | { header?: string; body?: string; footer?: string; mask?: string; content?: string; wrapper?: string; } | | pass className to target area | |
57
- | styles | { header?: CSSProperties; body?: CSSProperties; footer?: CSSProperties; mask?: CSSProperties; content?: CSSProperties; wrapper?: CSSProperties; } | | pass styles to target area | |
58
- | style | Object | {} | Root style for dialog element.Such as width, height | |
59
- | zIndex | Number | | | |
60
- | visible | Boolean | false | current dialog's visible status | |
61
- | animation | String | | part of dialog animation css class name | |
62
- | maskAnimation | String | | part of dialog's mask animation css class name | |
63
- | transitionName | String | | dialog animation css class name | |
64
- | maskTransitionName | String | | mask animation css class name | |
65
- | title | String\|React.Element | | Title of the dialog | |
66
- | footer | React.Element | | footer of the dialog | |
67
- | closable | Boolean \| ({ closeIcon?: React.ReactNode; disabled?: boolean } & React.AriaAttributes | true | whether show close button | |
68
- | mask | Boolean | true | whether show mask | |
69
- | maskClosable | Boolean | true | whether click mask to close | |
70
- | keyboard | Boolean | true | whether support press esc to close | |
71
- | mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | |
72
- | onClose | function() | | called when click close button or mask | |
73
- | afterClose | function() | | called when close animation end | |
74
- | getContainer | function(): HTMLElement | | to determine where Dialog will be mounted | |
75
- | destroyOnClose | Boolean | false | to unmount child compenents on onClose | |
76
- | closeIcon | ReactNode | | specific the close icon. | |
77
- | forceRender | Boolean | false | Create dialog dom node before dialog first show | |
78
- | focusTriggerAfterClose | Boolean | true | focus trigger element when dialog closed | |
79
- | modalRender | (node: ReactNode) => ReactNode | | Custom modal content render | 8.3.0 |
52
+ | Name | Type | Default | Description | Version |
53
+ | --- | --- | --- | --- | --- |
54
+ | prefixCls | String | rc-dialog | The dialog dom node's prefixCls | |
55
+ | className | String | | additional className for dialog | |
56
+ | classNames | { header?: string; body?: string; footer?: string; mask?: string; content?: string; wrapper?: string; } | | pass className to target area | |
57
+ | styles | { header?: CSSProperties; body?: CSSProperties; footer?: CSSProperties; mask?: CSSProperties; content?: CSSProperties; wrapper?: CSSProperties; } | | pass styles to target area | |
58
+ | style | Object | {} | Root style for dialog element.Such as width, height | |
59
+ | zIndex | Number | | | |
60
+ | visible | Boolean | false | current dialog's visible status | |
61
+ | animation | String | | part of dialog animation css class name | |
62
+ | maskAnimation | String | | part of dialog's mask animation css class name | |
63
+ | transitionName | String | | dialog animation css class name | |
64
+ | maskTransitionName | String | | mask animation css class name | |
65
+ | title | String\|React.Element | | Title of the dialog | |
66
+ | footer | React.Element | | footer of the dialog | |
67
+ | closable | Boolean \| ({ closeIcon?: React.ReactNode; disabled?: boolean } & React.AriaAttributes | true | whether show close button | |
68
+ | mask | Boolean | true | whether show mask | |
69
+ | maskClosable | Boolean | true | whether click mask to close | |
70
+ | keyboard | Boolean | true | whether support press esc to close | |
71
+ | mousePosition | {x:number,y:number} | | set pageX and pageY of current mouse(it will cause transform origin to be set). | |
72
+ | onClose | function() | | called when click close button or mask | |
73
+ | afterClose | function() | | called when close animation end | |
74
+ | getContainer | function(): HTMLElement | | to determine where Dialog will be mounted | |
75
+ | destroyOnHidden | Boolean | false | to unmount child compenents on onClose | |
76
+ | closeIcon | ReactNode | | specific the close icon. | |
77
+ | forceRender | Boolean | false | Create dialog dom node before dialog first show | |
78
+ | focusTriggerAfterClose | Boolean | true | focus trigger element when dialog closed | |
79
+ | modalRender | (node: ReactNode) => ReactNode | | Custom modal content render | 8.3.0 |
80
80
 
81
81
  ## Development
82
82
 
@@ -85,8 +85,6 @@ npm install
85
85
  npm start
86
86
  ```
87
87
 
88
-
89
-
90
88
  ## Test Case
91
89
 
92
90
  ```
@@ -102,7 +100,13 @@ npm run coverage
102
100
 
103
101
  open coverage/ dir
104
102
 
105
-
106
103
  ## License
107
104
 
108
105
  rc-dialog is released under the MIT license.
106
+
107
+
108
+ ## 🤝 Contributing
109
+
110
+ <a href="https://openomy.app/github/react-component/dialog" target="_blank" style="display: block; width: 100%;" align="center">
111
+ <img src="https://www.openomy.app/svg?repo=react-component/dialog&chart=bubble&latestMonth=24" target="_blank" alt="Contribution Leaderboard" style="display: block; width: 100%;" />
112
+ </a>
@@ -14,7 +14,7 @@
14
14
  -webkit-overflow-scrolling: touch;
15
15
  outline: 0;
16
16
  }
17
- .rc-dialog-section {
17
+ .rc-dialog-container {
18
18
  position: relative;
19
19
  background-color: #fff;
20
20
  border: 1px solid #999;
@@ -80,7 +80,7 @@
80
80
  width: 600px;
81
81
  margin: 30px auto;
82
82
  }
83
- .rc-dialog-section {
83
+ .rc-dialog-container {
84
84
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
85
85
  }
86
86
  }
package/assets/index.css CHANGED
@@ -20,7 +20,7 @@
20
20
  line-height: 21px;
21
21
  font-weight: bold;
22
22
  }
23
- .rc-dialog-section {
23
+ .rc-dialog-container {
24
24
  position: relative;
25
25
  background-color: #ffffff;
26
26
  border: none;
@@ -45,8 +45,8 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
45
45
  panel: panelRef
46
46
  } = React.useContext(RefContext);
47
47
  const mergedRef = useComposeRef(holderRef, panelRef);
48
- const sentinelStartRef = useRef();
49
- const sentinelEndRef = useRef();
48
+ const sentinelStartRef = useRef(null);
49
+ const sentinelEndRef = useRef(null);
50
50
  React.useImperativeHandle(ref, () => ({
51
51
  focus: () => {
52
52
  sentinelStartRef.current?.focus({
@@ -120,8 +120,8 @@ const Panel = /*#__PURE__*/React.forwardRef((props, ref) => {
120
120
  disabled: closeBtnIsDisabled
121
121
  }), closableObj.closeIcon) : null;
122
122
  const content = /*#__PURE__*/React.createElement("div", {
123
- className: classNames(`${prefixCls}-section`, modalClassNames?.section),
124
- style: modalStyles?.section
123
+ className: classNames(`${prefixCls}-container`, modalClassNames?.container),
124
+ style: modalStyles?.container
125
125
  }, closerNode, headerNode, /*#__PURE__*/React.createElement("div", _extends({
126
126
  className: classNames(`${prefixCls}-body`, modalClassNames?.body),
127
127
  style: {
@@ -13,14 +13,14 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
13
13
  className,
14
14
  visible,
15
15
  forceRender,
16
- destroyOnClose,
16
+ destroyOnHidden,
17
17
  motionName,
18
18
  ariaId,
19
19
  onVisibleChanged,
20
20
  mousePosition
21
21
  } = props;
22
- const dialogRef = useRef();
23
- const panelRef = useRef();
22
+ const dialogRef = useRef(null);
23
+ const panelRef = useRef(null);
24
24
 
25
25
  // ============================== Refs ==============================
26
26
  React.useImperativeHandle(ref, () => ({
@@ -48,7 +48,7 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
48
48
  onEnterPrepare: onPrepare,
49
49
  forceRender: forceRender,
50
50
  motionName: motionName,
51
- removeOnLeave: destroyOnClose,
51
+ removeOnLeave: destroyOnHidden,
52
52
  ref: dialogRef
53
53
  }, ({
54
54
  className: motionClassName,
@@ -67,5 +67,7 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
67
67
  className: classNames(className, motionClassName)
68
68
  })));
69
69
  });
70
- Content.displayName = 'Content';
70
+ if (process.env.NODE_ENV !== 'production') {
71
+ Content.displayName = 'Content';
72
+ }
71
73
  export default Content;
@@ -50,9 +50,9 @@ const Dialog = props => {
50
50
  warning(false, `wrapClassName is deprecated, please use classNames instead.`);
51
51
  }
52
52
  }
53
- const lastOutSideActiveElementRef = useRef();
54
- const wrapperRef = useRef();
55
- const contentRef = useRef();
53
+ const lastOutSideActiveElementRef = useRef(null);
54
+ const wrapperRef = useRef(null);
55
+ const contentRef = useRef(null);
56
56
  const [animatedVisible, setAnimatedVisible] = React.useState(visible);
57
57
 
58
58
  // ========================== Init ==========================
@@ -106,7 +106,7 @@ const Dialog = props => {
106
106
 
107
107
  // >>> Content
108
108
  const contentClickRef = useRef(false);
109
- const contentTimeoutRef = useRef();
109
+ const contentTimeoutRef = useRef(null);
110
110
 
111
111
  // We need record content click incase content popup out of dialog
112
112
  const onContentMouseDown = () => {
package/es/DialogWrap.js CHANGED
@@ -17,7 +17,7 @@ const DialogWrap = props => {
17
17
  visible,
18
18
  getContainer,
19
19
  forceRender,
20
- destroyOnClose = false,
20
+ destroyOnHidden = false,
21
21
  afterClose,
22
22
  panelRef
23
23
  } = props;
@@ -32,7 +32,7 @@ const DialogWrap = props => {
32
32
  }, [visible]);
33
33
 
34
34
  // Destroy on close will remove wrapped div
35
- if (!forceRender && destroyOnClose && !animatedVisible) {
35
+ if (!forceRender && destroyOnHidden && !animatedVisible) {
36
36
  return null;
37
37
  }
38
38
  return /*#__PURE__*/React.createElement(RefContext.Provider, {
@@ -43,12 +43,14 @@ const DialogWrap = props => {
43
43
  getContainer: getContainer,
44
44
  autoLock: visible || animatedVisible
45
45
  }, /*#__PURE__*/React.createElement(Dialog, _extends({}, props, {
46
- destroyOnClose: destroyOnClose,
46
+ destroyOnHidden: destroyOnHidden,
47
47
  afterClose: () => {
48
48
  afterClose?.();
49
49
  setAnimatedVisible(false);
50
50
  }
51
51
  }))));
52
52
  };
53
- DialogWrap.displayName = 'Dialog';
53
+ if (process.env.NODE_ENV !== 'production') {
54
+ DialogWrap.displayName = 'Dialog';
55
+ }
54
56
  export default DialogWrap;
@@ -1,6 +1,6 @@
1
1
  import type { GetContainer } from '@rc-component/util/lib/PortalWrapper';
2
2
  import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';
3
- export type SemanticName = 'header' | 'body' | 'footer' | 'section' | 'title' | 'wrapper' | 'mask';
3
+ export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask';
4
4
  export type ModalClassNames = Partial<Record<SemanticName, string>>;
5
5
  export type ModalStyles = Partial<Record<SemanticName, CSSProperties>>;
6
6
  export type IDialogPropTypes = {
@@ -19,7 +19,7 @@ export type IDialogPropTypes = {
19
19
  } & React.AriaAttributes);
20
20
  maskClosable?: boolean;
21
21
  visible?: boolean;
22
- destroyOnClose?: boolean;
22
+ destroyOnHidden?: boolean;
23
23
  mousePosition?: {
24
24
  x: number;
25
25
  y: number;
@@ -54,8 +54,8 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
54
54
  panel: panelRef
55
55
  } = _react.default.useContext(_context.RefContext);
56
56
  const mergedRef = (0, _ref.useComposeRef)(holderRef, panelRef);
57
- const sentinelStartRef = (0, _react.useRef)();
58
- const sentinelEndRef = (0, _react.useRef)();
57
+ const sentinelStartRef = (0, _react.useRef)(null);
58
+ const sentinelEndRef = (0, _react.useRef)(null);
59
59
  _react.default.useImperativeHandle(ref, () => ({
60
60
  focus: () => {
61
61
  sentinelStartRef.current?.focus({
@@ -129,8 +129,8 @@ const Panel = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
129
129
  disabled: closeBtnIsDisabled
130
130
  }), closableObj.closeIcon) : null;
131
131
  const content = /*#__PURE__*/_react.default.createElement("div", {
132
- className: (0, _classnames.default)(`${prefixCls}-section`, modalClassNames?.section),
133
- style: modalStyles?.section
132
+ className: (0, _classnames.default)(`${prefixCls}-container`, modalClassNames?.container),
133
+ style: modalStyles?.container
134
134
  }, closerNode, headerNode, /*#__PURE__*/_react.default.createElement("div", _extends({
135
135
  className: (0, _classnames.default)(`${prefixCls}-body`, modalClassNames?.body),
136
136
  style: {
@@ -22,14 +22,14 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
22
22
  className,
23
23
  visible,
24
24
  forceRender,
25
- destroyOnClose,
25
+ destroyOnHidden,
26
26
  motionName,
27
27
  ariaId,
28
28
  onVisibleChanged,
29
29
  mousePosition
30
30
  } = props;
31
- const dialogRef = (0, _react.useRef)();
32
- const panelRef = (0, _react.useRef)();
31
+ const dialogRef = (0, _react.useRef)(null);
32
+ const panelRef = (0, _react.useRef)(null);
33
33
 
34
34
  // ============================== Refs ==============================
35
35
  React.useImperativeHandle(ref, () => ({
@@ -57,7 +57,7 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
57
57
  onEnterPrepare: onPrepare,
58
58
  forceRender: forceRender,
59
59
  motionName: motionName,
60
- removeOnLeave: destroyOnClose,
60
+ removeOnLeave: destroyOnHidden,
61
61
  ref: dialogRef
62
62
  }, ({
63
63
  className: motionClassName,
@@ -76,5 +76,7 @@ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
76
76
  className: (0, _classnames.default)(className, motionClassName)
77
77
  })));
78
78
  });
79
- Content.displayName = 'Content';
79
+ if (process.env.NODE_ENV !== 'production') {
80
+ Content.displayName = 'Content';
81
+ }
80
82
  var _default = exports.default = Content;
@@ -59,9 +59,9 @@ const Dialog = props => {
59
59
  (0, _warning.warning)(false, `wrapClassName is deprecated, please use classNames instead.`);
60
60
  }
61
61
  }
62
- const lastOutSideActiveElementRef = (0, _react.useRef)();
63
- const wrapperRef = (0, _react.useRef)();
64
- const contentRef = (0, _react.useRef)();
62
+ const lastOutSideActiveElementRef = (0, _react.useRef)(null);
63
+ const wrapperRef = (0, _react.useRef)(null);
64
+ const contentRef = (0, _react.useRef)(null);
65
65
  const [animatedVisible, setAnimatedVisible] = React.useState(visible);
66
66
 
67
67
  // ========================== Init ==========================
@@ -115,7 +115,7 @@ const Dialog = props => {
115
115
 
116
116
  // >>> Content
117
117
  const contentClickRef = (0, _react.useRef)(false);
118
- const contentTimeoutRef = (0, _react.useRef)();
118
+ const contentTimeoutRef = (0, _react.useRef)(null);
119
119
 
120
120
  // We need record content click incase content popup out of dialog
121
121
  const onContentMouseDown = () => {
package/lib/DialogWrap.js CHANGED
@@ -26,7 +26,7 @@ const DialogWrap = props => {
26
26
  visible,
27
27
  getContainer,
28
28
  forceRender,
29
- destroyOnClose = false,
29
+ destroyOnHidden = false,
30
30
  afterClose,
31
31
  panelRef
32
32
  } = props;
@@ -41,7 +41,7 @@ const DialogWrap = props => {
41
41
  }, [visible]);
42
42
 
43
43
  // Destroy on close will remove wrapped div
44
- if (!forceRender && destroyOnClose && !animatedVisible) {
44
+ if (!forceRender && destroyOnHidden && !animatedVisible) {
45
45
  return null;
46
46
  }
47
47
  return /*#__PURE__*/React.createElement(_context.RefContext.Provider, {
@@ -52,12 +52,14 @@ const DialogWrap = props => {
52
52
  getContainer: getContainer,
53
53
  autoLock: visible || animatedVisible
54
54
  }, /*#__PURE__*/React.createElement(_Dialog.default, _extends({}, props, {
55
- destroyOnClose: destroyOnClose,
55
+ destroyOnHidden: destroyOnHidden,
56
56
  afterClose: () => {
57
57
  afterClose?.();
58
58
  setAnimatedVisible(false);
59
59
  }
60
60
  }))));
61
61
  };
62
- DialogWrap.displayName = 'Dialog';
62
+ if (process.env.NODE_ENV !== 'production') {
63
+ DialogWrap.displayName = 'Dialog';
64
+ }
63
65
  var _default = exports.default = DialogWrap;
@@ -1,6 +1,6 @@
1
1
  import type { GetContainer } from '@rc-component/util/lib/PortalWrapper';
2
2
  import type { CSSProperties, ReactNode, SyntheticEvent } from 'react';
3
- export type SemanticName = 'header' | 'body' | 'footer' | 'section' | 'title' | 'wrapper' | 'mask';
3
+ export type SemanticName = 'header' | 'body' | 'footer' | 'container' | 'title' | 'wrapper' | 'mask';
4
4
  export type ModalClassNames = Partial<Record<SemanticName, string>>;
5
5
  export type ModalStyles = Partial<Record<SemanticName, CSSProperties>>;
6
6
  export type IDialogPropTypes = {
@@ -19,7 +19,7 @@ export type IDialogPropTypes = {
19
19
  } & React.AriaAttributes);
20
20
  maskClosable?: boolean;
21
21
  visible?: boolean;
22
- destroyOnClose?: boolean;
22
+ destroyOnHidden?: boolean;
23
23
  mousePosition?: {
24
24
  x: number;
25
25
  y: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/dialog",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "dialog ui component for react",
5
5
  "keywords": [
6
6
  "react",
@@ -57,18 +57,18 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@rc-component/drawer": "^1.0.0",
60
- "@rc-component/select": "^1.0.0",
61
60
  "@rc-component/father-plugin": "^2.0.2",
62
61
  "@rc-component/np": "^1.0.3",
62
+ "@rc-component/select": "^1.0.0",
63
63
  "@testing-library/jest-dom": "^6.1.6",
64
- "@testing-library/react": "^13.0.0",
64
+ "@testing-library/react": "^16.3.0",
65
65
  "@types/jest": "^29.4.0",
66
66
  "@types/keyv": "3.1.4",
67
- "@types/react": "^18.0.24",
68
- "@types/react-dom": "^18.0.8",
67
+ "@types/node": "^24.0.8",
68
+ "@types/react": "^19.1.4",
69
+ "@types/react-dom": "^19.1.5",
69
70
  "@umijs/fabric": "^3.0.0",
70
- "bootstrap": "^4.3.1",
71
- "cheerio": "1.0.0-rc.12",
71
+ "bootstrap": "^5.3.7",
72
72
  "cross-env": "^7.0.0",
73
73
  "dumi": "^2.1.3",
74
74
  "eslint": "^7.1.0",
@@ -77,9 +77,9 @@
77
77
  "father": "^4.1.5",
78
78
  "gh-pages": "^6.1.1",
79
79
  "glob": "^11.0.0",
80
- "husky": "^8.0.3",
80
+ "husky": "^9.1.6",
81
81
  "less": "^4.1.3",
82
- "lint-staged": "^15.2.0",
82
+ "lint-staged": "^16.1.2",
83
83
  "prettier": "^3.2.1",
84
84
  "rc-test": "^7.0.14",
85
85
  "react": "^18.0.0",