Skip to content

Commit

Permalink
feat: adjust the import method (#400)
Browse files Browse the repository at this point in the history
* feat: adjust the import method

* test: update scrollable component snapshot

* We are in  Qiandao lake.
  • Loading branch information
ProfBramble authored Sep 5, 2021
1 parent e5971b7 commit 1ea6238
Show file tree
Hide file tree
Showing 100 changed files with 453 additions and 450 deletions.
8 changes: 4 additions & 4 deletions build/web/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import React, { StrictMode } from 'react';
import ReactDOM from 'react-dom';
import { Workbench, MoleculeProvider } from '../../esm';
import '../../esm/style/mo.css';

const App = () => (
<React.StrictMode>
<StrictMode>
<MoleculeProvider>
<Workbench />
</MoleculeProvider>
</React.StrictMode>
</StrictMode>
);

ReactDOM.render(<App />, document.getElementById('root'));
2 changes: 1 addition & 1 deletion src/components/actionBar/__tests__/actionBar.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion src/components/actionBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { useCallback, useEffect, useRef } from 'react';
import {
prefixClaName,
Expand Down
2 changes: 1 addition & 1 deletion src/components/breadcrumb/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { prefixClaName, classNames, getBEMElement } from 'mo/common/className';
import { ComponentProps } from 'react';
import { Icon } from 'mo/components';
Expand Down
2 changes: 1 addition & 1 deletion src/components/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { classNames, getBEMModifier, prefixClaName } from 'mo/common/className';

type BtnSizeType = 'normal' | 'large';
Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/__tests__/checkbox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { render, fireEvent, screen } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { ComponentProps } from 'react';
import { prefixClaName, classNames, getBEMElement } from 'mo/common/className';

Expand Down
14 changes: 7 additions & 7 deletions src/components/collapse/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React, { useRef, useLayoutEffect, useEffect, useCallback } from 'react';
import { useState } from 'react';
import Logger from 'mo/common/logger';
import { Toolbar } from 'mo/components/toolbar';
Expand Down Expand Up @@ -57,8 +57,8 @@ export const MAX_GROW_HEIGHT = 220;

export function Collapse(props: ICollapseProps) {
const [activePanelKeys, setActivePanelKeys] = useState<React.Key[]>([]);
const wrapper = React.useRef<HTMLDivElement>(null);
const requestAF = React.useRef<number>();
const wrapper = useRef<HTMLDivElement>(null);
const requestAF = useRef<number>();

const {
className,
Expand All @@ -80,19 +80,19 @@ export function Collapse(props: ICollapseProps) {

// to save position temporarily, empty array when rerender
const _cachePosition: number[][] = [];
let _cacheWrapperHeight = React.useRef(0);
const _cacheWrapperHeight = useRef(0);

const handleResize = React.useCallback(() => {
const handleResize = useCallback(() => {
// just want to trigger rerender
setActivePanelKeys((keys) => keys.concat());
}, []);

React.useEffect(() => {
useEffect(() => {
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);

React.useLayoutEffect(() => {
useLayoutEffect(() => {
// It's necessary to check panel's empty before calculate every panel
filterData.forEach((panel) => {
const isActive = activePanelKeys.includes(panel.id);
Expand Down
2 changes: 1 addition & 1 deletion src/components/contextMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { HTMLElementType } from 'mo/common/dom';
import { IContextView, useContextView } from 'mo/components/contextView';

Expand Down
4 changes: 2 additions & 2 deletions src/components/contextView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import React from 'react';
import ReactDOM from 'react-dom';
import {
prefixClaName,
classNames,
Expand Down
4 changes: 2 additions & 2 deletions src/components/dialog/actionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import React, { useRef } from 'react';
import { Button, IButtonProps } from 'mo/components/button';
export interface ActionButtonProps extends IButtonProps {
actionFn?: (...args: any[]) => any | PromiseLike<any>;
closeModal: Function;
}

const ActionButton: React.FC<ActionButtonProps> = (props) => {
const clickedRef = React.useRef<boolean>(false);
const clickedRef = useRef<boolean>(false);

const handlePromiseOnOk = (returnValueOfOnOk?: PromiseLike<any>) => {
const { closeModal } = props;
Expand Down
4 changes: 2 additions & 2 deletions src/components/dialog/confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import React from 'react';
import ReactDOM from 'react-dom';

import { Icon } from 'mo/components/icon';
import { IModalFuncProps, destroyFns } from './modal';
Expand Down
2 changes: 1 addition & 1 deletion src/components/dialog/confirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { classNames } from 'mo/common/className';
import {
confirmClassName,
Expand Down
6 changes: 3 additions & 3 deletions src/components/dropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React, { forwardRef, useImperativeHandle } from 'react';
import { classNames, getBEMModifier, prefixClaName } from 'mo/common/className';
import { useContextView } from '../contextView';
import {
Expand All @@ -20,7 +20,7 @@ export type DropDownRef = {

export const defaultDropDownClassName = prefixClaName('drop-down');

export const DropDown = React.forwardRef<DropDownRef, IDropDownProps>(
export const DropDown = forwardRef<DropDownRef, IDropDownProps>(
(props: IDropDownProps, ref) => {
const {
className,
Expand All @@ -34,7 +34,7 @@ export const DropDown = React.forwardRef<DropDownRef, IDropDownProps>(
render: () => overlay,
});

React.useImperativeHandle(ref, () => ({
useImperativeHandle(ref, () => ({
contextView,
dispose: () => {
contextView!.hide();
Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/__tests__/icon.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion src/components/icon/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { classNames, prefixClaName } from 'mo/common/className';
import 'vscode-codicons/dist/codicon.css';
import { ComponentProps } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion src/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { classNames, prefixClaName, getBEMModifier } from 'mo/common/className';
import { KeyCodes } from 'mo/common/keyCodes';

Expand Down
2 changes: 1 addition & 1 deletion src/components/input/textArea.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import RcTextArea, { TextAreaProps } from 'rc-textarea';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import { useEffect, useRef } from 'react';
Expand Down
2 changes: 1 addition & 1 deletion src/components/list/__tests__/list.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import renderer from 'react-test-renderer';

Expand Down
2 changes: 1 addition & 1 deletion src/components/list/list.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { prefixClaName, classNames, getBEMModifier } from 'mo/common/className';
import { ComponentProps, useEffect, useState } from 'react';
import { cloneReactChildren } from 'mo/react';
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/subMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import { classNames } from 'mo/common/className';
import { TriggerEvent } from 'mo/common/dom';
import { Icon } from 'mo/components/icon';
Expand Down
2 changes: 1 addition & 1 deletion src/components/monaco/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'reflect-metadata';
import * as React from 'react';
import React from 'react';
import { PureComponent } from 'react';
import { editor } from 'monaco-editor';
import { isEqual } from 'lodash';
Expand Down
Loading

0 comments on commit 1ea6238

Please sign in to comment.