diff --git a/package-lock.json b/package-lock.json
index 1a57e48b..eae110ac 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,15 +1,15 @@
{
"name": "dtable-ui-component",
- "version": "6.0.25",
+ "version": "6.0.28",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "dtable-ui-component",
- "version": "6.0.25",
+ "version": "6.0.28",
"dependencies": {
"@seafile/react-image-lightbox": "4.0.2",
- "@seafile/seafile-calendar": "0.0.24",
+ "@seafile/seafile-calendar": "0.0.29",
"@seafile/seafile-editor": "~2.0.6",
"antd-mobile": "2.3.1",
"classnames": "2.3.2",
@@ -6142,9 +6142,9 @@
}
},
"node_modules/@seafile/seafile-calendar": {
- "version": "0.0.24",
- "resolved": "https://registry.npmjs.org/@seafile/seafile-calendar/-/seafile-calendar-0.0.24.tgz",
- "integrity": "sha512-q1efVDcHAxJ2foMgsR8mQPD6Fbd6ISu2WHRM82P7tO0KPiQNS5pz9V0YVCblgi7da085jaog2iAplJM+vH7xLQ==",
+ "version": "0.0.29",
+ "resolved": "https://registry.npmjs.org/@seafile/seafile-calendar/-/seafile-calendar-0.0.29.tgz",
+ "integrity": "sha512-8dg6Y8Taz31LawfnZ7T1QVbJUYCp/tFkqn8VLcFJk6A2BLlaakE2WN36vS4kfU4gyNcFZWObt4DmFj2Xc1FuiA==",
"dependencies": {
"babel-runtime": "6.x",
"classnames": "2.x",
@@ -40326,9 +40326,9 @@
}
},
"@seafile/seafile-calendar": {
- "version": "0.0.24",
- "resolved": "https://registry.npmjs.org/@seafile/seafile-calendar/-/seafile-calendar-0.0.24.tgz",
- "integrity": "sha512-q1efVDcHAxJ2foMgsR8mQPD6Fbd6ISu2WHRM82P7tO0KPiQNS5pz9V0YVCblgi7da085jaog2iAplJM+vH7xLQ==",
+ "version": "0.0.29",
+ "resolved": "https://registry.npmjs.org/@seafile/seafile-calendar/-/seafile-calendar-0.0.29.tgz",
+ "integrity": "sha512-8dg6Y8Taz31LawfnZ7T1QVbJUYCp/tFkqn8VLcFJk6A2BLlaakE2WN36vS4kfU4gyNcFZWObt4DmFj2Xc1FuiA==",
"requires": {
"babel-runtime": "6.x",
"classnames": "2.x",
diff --git a/package.json b/package.json
index 0ffa46f9..d11201a7 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"main": "./lib/index.js",
"dependencies": {
"@seafile/react-image-lightbox": "4.0.2",
- "@seafile/seafile-calendar": "0.0.24",
+ "@seafile/seafile-calendar": "0.0.29",
"@seafile/seafile-editor": "~2.0.6",
"antd-mobile": "2.3.1",
"classnames": "2.3.2",
diff --git a/src/BodyPortal/index.js b/src/BodyPortal/index.js
new file mode 100644
index 00000000..7a5afe24
--- /dev/null
+++ b/src/BodyPortal/index.js
@@ -0,0 +1,41 @@
+import React from 'react';
+import ReactDOM from 'react-dom';
+import PropTypes from 'prop-types';
+
+const canUseDOM = !!(
+ typeof window !== 'undefined' &&
+ window.document &&
+ window.document.createElement
+);
+
+class BodyPortal extends React.Component {
+ componentWillUnmount() {
+ if (this.defaultNode) {
+ document.body.removeChild(this.defaultNode);
+ }
+ this.defaultNode = null;
+ }
+
+ render() {
+ if (!canUseDOM) {
+ return null;
+ }
+
+ if (!this.props.node && !this.defaultNode) {
+ this.defaultNode = document.createElement('div');
+ document.body.appendChild(this.defaultNode);
+ }
+
+ return ReactDOM.createPortal(
+ this.props.children,
+ this.props.node || this.defaultNode,
+ );
+ }
+}
+
+BodyPortal.propTypes = {
+ children: PropTypes.node.isRequired,
+ node: PropTypes.any,
+};
+
+export default BodyPortal;
diff --git a/src/CheckboxEditor/index.js b/src/CheckboxEditor/index.js
index 639ed1b7..6081886a 100644
--- a/src/CheckboxEditor/index.js
+++ b/src/CheckboxEditor/index.js
@@ -1,108 +1,29 @@
-import React, { Component } from 'react';
+import React, { forwardRef } from 'react';
import PropTypes from 'prop-types';
-import classnames from 'classnames';
-import SvgIcon from '../SvgIcon';
-import { isMobile } from '../utils/utils';
-import { KeyCodes, DEFAULT_CHECKBOX_MARK_STYLE } from '../constants';
+import MediaQuery from 'react-responsive';
+import PCCheckboxEditor from './pc-editor';
+import MBCheckboxEditor from './mb-editor';
import './index.css';
-class CheckboxEditor extends Component {
-
- constructor(props) {
- super(props);
- this.state = {
- value: props.value || false,
- };
- }
-
- componentDidMount() {
- document.addEventListener('keydown', this.onKeyDown);
- }
-
- componentWillUnmount() {
- document.removeEventListener('keydown', this.onKeyDown);
- }
-
- componentDidUpdate(prevProps) {
- const { value } = this.props;
- if (value !== prevProps.value) {
- this.setState({ value });
- }
- }
-
- onKeyDown = (event) => {
- const { isEditorShow, readOnly } = this.props;
- if (event.keyCode === KeyCodes.Enter && isEditorShow && !readOnly) {
- this.setState({ value: !this.state.value });
- }
- };
-
- getValue = () => {
- const { value } = this.state;
- return value;
- };
-
- updateValue = (value) => {
- if (value === this.state.value) {
- return;
- }
- this.setState({ value });
- };
-
- onChangeCheckboxValue = (event) => {
- if (event) {
- event.stopPropagation();
- event.nativeEvent.stopImmediatePropagation();
- event.persist();
- }
- const { value } = this.state;
- const newValue = !value;
- this.setState({ value: newValue }, () => {
- if (this.props.onCommit) {
- this.props.onCommit(event);
- }
- });
- };
-
- renderIcon = (symbol, color) => {
- const className = classnames('dtable-ui-checkbox-check-mark', { 'dtable-ui-checkbox-check-svg': !symbol?.startsWith('dtable-icon') });
- if (symbol.startsWith('dtable-icon')) {
- return ();
- }
- return (