Skip to content

Commit

Permalink
refactor(Drawer): Document optimization & Upgrade testing tools and o…
Browse files Browse the repository at this point in the history
…ptimize use cases

fix(Overlay): solve problems caused by numerical floating, close #4740

chore(*): Release-1.27.5-beta.1

fix(*): rollback #4746 and fix textarea clear spec

chore(*): Release-1.27.5

fix(Drawer): not to change package-lock.json

Update stale.yml

chore(BuildTool): 支持指定主题包调试`run start --theme xxx`

chore(DatePicker): fix theme demo margin, close #3627

chore(Shell): fix spell error "palceholder -> placeholder", close #3564

docs(Field): improve document description of parseName, close #3453

chore(Pagination): improve document of pageSizeSelector, fix pageJump runtime error, close #3306

docs(Calendar2): remove legacy api, close #3100

fix(Table): fix merging cell width in locked columns, close #4716 (#4752)

* fix(Table): 修复合并单元格的锁列滑动问题

* fix(Table): should support for merging cells in locked columns, close #4716

* fix(Table): 修复测试用例

chore(*): update lock

fix(Shell): phone shell should hidden when collapsed, close #3886 (#4766)

Co-authored-by: lancely <[email protected]>

refactor(Timeline): rename timeline file to ts

refactor(Timeline): ts & doc improvement

refactor(Timeline): test improve

refactor(Timeline): fix cr comments

fix(Upload): should hide trigger when limit is reached for Upload.Dragger, close #3951 (#4761)

Co-authored-by: lancely <[email protected]>

feat(DatePicker): improve focus logic, close #3998 (#4769)

* feat(DatePicker): interactive optimization of date selection box close #3998

* feat(DatePicker): improve focus logic

---------

Co-authored-by: WB01081293 <[email protected]>
Co-authored-by: 珵之 <[email protected]>

refactor(Field): rename to ts

refactor(Field): convert to TypeScript, impove docs and tests

refactor(Field): convert to TypeScript, impove docs and tests

chore(Field): improve for codereview

chore(Field): fix dependency version

feat(TreeSelect): support useDetailValue, close #3531 (#4771)

* feat(TreeSelect): support useDetailValue, close #3531

* chore(TreeSelect): improve useDetailValue tc and demos by codereview

* test(TreeSelect): add control mode spec for useDetailValue

refactor(Collapse): rename to ts

refactor(Collapse): convert to TypeScript, impove docs and tests

refactor(Collapse): imporve docs and types

chore(Collapse): improve by codereview

chore(Collapse): remove useless propTypes comments

chore(*): Release-1.27.6

fix(Collapse): hotfix panel className missing

chore(*): Release-1.27.7

chore(Divider): adjust ts types

chore(Divider): adjust ts & docs & test
  • Loading branch information
骆林 authored and eternalsky committed Jul 16, 2024
1 parent 4bc2898 commit 6283510
Show file tree
Hide file tree
Showing 20 changed files with 711 additions and 499 deletions.
3 changes: 2 additions & 1 deletion components/drawer/__docs__/demo/basic/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, Drawer } from '@alifd/next';
import type { DrawerProps } from '@alifd/next/lib/drawer';

class Demo extends React.Component {
state = {
Expand All @@ -13,7 +14,7 @@ class Demo extends React.Component {
});
};

onClose = (reason, e) => {
onClose: DrawerProps['onClose'] = (reason, e) => {
console.log('onClose: ', reason, e);
this.setState({
visible: false,
Expand Down
7 changes: 4 additions & 3 deletions components/drawer/__docs__/demo/placement/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Radio, Button, Drawer } from '@alifd/next';
import type { RadioProps } from '@alifd/next/lib/radio';

class Demo extends React.Component {
state = {
Expand All @@ -14,13 +15,13 @@ class Demo extends React.Component {
});
};

onClose = reason => {
onClose = () => {
this.setState({
visible: false,
});
};

onPlacementChange = dir => {
onPlacementChange: RadioProps['onChange'] = dir => {
this.setState({
placement: dir,
});
Expand All @@ -44,7 +45,7 @@ class Demo extends React.Component {
v2
title="标题"
visible={this.state.visible}
placement={this.state.placement}
placement={this.state.placement as 'right' | 'bottom' | 'left' | 'top'}
onClose={this.onClose}
>
Start your business here by searching a popular product
Expand Down
4 changes: 3 additions & 1 deletion components/drawer/__docs__/demo/quick/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, Drawer } from '@alifd/next';
import type { QuickShowRet } from '@alifd/next/lib/drawer';

let instance = null;
let instance: QuickShowRet | null = null;
const show = () => {
instance && instance.hide();
instance = Drawer.show({
title: 'quick',
hasMask: false,
Expand Down
17 changes: 13 additions & 4 deletions components/drawer/__docs__/demo/select/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Radio, Drawer, Select } from '@alifd/next';
import type { SelectProps } from '@alifd/next/lib/select';
import type { RadioProps } from '@alifd/next/lib/radio';

interface onToggleHighlightItemProps {
deep: number;
value: string;
label: string;
}

const Option = Select.Option;

const onChange = function (value) {
const onChange: SelectProps['onChange'] = value => {
console.log(value);
};
const onBlur = function (e) {

const onBlur: SelectProps['onBlur'] = e => {
console.log(/onblur/, e);
};

const onToggleHighlightItem = function (item, type) {
const onToggleHighlightItem = (item: onToggleHighlightItemProps, type: 'up' | 'down') => {
console.log(item, type);
};

Expand All @@ -20,7 +29,7 @@ class Demo extends React.Component {
placement: 'right',
};

onPlacementChange = dir => {
onPlacementChange: RadioProps['onChange'] = dir => {
this.setState({
placement: dir,
});
Expand Down
4 changes: 2 additions & 2 deletions components/drawer/__docs__/demo/size/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Demo = () => {

return (
<div>
<Button type="primary" onClick={setVisible}>
<Button type="primary" onClick={() => setVisible(true)}>
{' '}
fixed 700{' '}
</Button>
Expand All @@ -23,7 +23,7 @@ const Demo = () => {
>
Start your business here by searching a popular product
</Drawer>
<Button type="primary" onClick={setVisible2} style={{ marginLeft: 8 }}>
<Button type="primary" onClick={() => setVisible2(true)} style={{ marginLeft: 8 }}>
{' '}
auto width
</Button>
Expand Down
80 changes: 53 additions & 27 deletions components/drawer/__docs__/index.en-us.md

Large diffs are not rendered by default.

76 changes: 49 additions & 27 deletions components/drawer/__docs__/index.md

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions components/drawer/__docs__/theme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,26 @@ import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import '../../../demo-helper/style';
import '../../style';
import { Demo, DemoGroup, initDemo } from '../../../demo-helper';
import {
Demo,
DemoGroup,
initDemo,
type DemoFunctionDefineForArray,
type DemoFunctionDefineForObject,
} from '../../../demo-helper';
import Drawer from '../../index';

import zhCN from '../../../locale/zh-cn';
import enUS from '../../../locale/en-us';

interface FunctionProps {
lang: string;
i18n: {
title: string;
content: string;
};
}

const i18nMaps = {
'en-us': {
title: 'Title Here',
Expand All @@ -20,7 +34,7 @@ const i18nMaps = {
},
};

class FunctionDemo extends Component {
class FunctionDemo extends Component<FunctionProps> {
state = {
demoFunction: {
hasTitle: {
Expand Down Expand Up @@ -75,13 +89,15 @@ class FunctionDemo extends Component {
},
},
};
onFunctionChange = demoFunction => {
onFunctionChange = (
demoFunction: Record<string, DemoFunctionDefineForObject> | DemoFunctionDefineForArray[]
) => {
this.setState({
demoFunction,
});
};

renderMask(hasMask, content) {
renderMask(hasMask: boolean, content: object | null | undefined) {
return hasMask ? (
<div
className="next-overlay-wrapper opened"
Expand All @@ -96,14 +112,17 @@ class FunctionDemo extends Component {
}

render() {
// eslint-disable-next-line
const { lang, i18n } = this.props;
const locale = (lang === 'en-us' ? enUS : zhCN).Drawer;
const hasTitle = this.state.demoFunction.hasTitle.value === 'true';
const hasCloseIcon = this.state.demoFunction.hasCloseIcon.value === 'true';

const placement = this.state.demoFunction.placement.value;
const style = {
const placement = this.state.demoFunction.placement.value as
| 'top'
| 'bottom'
| 'left'
| 'right';
const style: React.CSSProperties = {
position: 'absolute',
top: placement === 'bottom' ? 'auto' : 0,
[placement]: 0,
Expand Down Expand Up @@ -138,7 +157,7 @@ class FunctionDemo extends Component {
}

const render = (lang = 'en-us') => {
const i18n = i18nMaps[lang];
const i18n = i18nMaps[lang as keyof typeof i18nMaps];
ReactDOM.render(<FunctionDemo lang={lang} i18n={i18n} />, document.getElementById('container'));
};

Expand Down
24 changes: 2 additions & 22 deletions components/drawer/__tests__/a11y-spec.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
import React from 'react';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import assert from 'power-assert';
import Drawer from '../index';
import { testReact } from '../../util/__tests__/a11y/validate';
import '../style';
import { test, unmount } from '../../util/__tests__/legacy/a11y/validate';
import { roleType, isHeading, isButton } from '../../util/__tests__/legacy/a11y/checks';

/* eslint-disable react/jsx-filename-extension */
/* global describe it afterEach */

Enzyme.configure({ adapter: new Adapter() });

describe('Drawer A11y', () => {
describe('Basic', () => {
let wrapper;

afterEach(() => {
if (wrapper && wrapper.unmount) {
wrapper.unmount();
wrapper = null;
}
unmount();
});

it('should not have any violations', async () => {
wrapper = await mount(<Drawer visible />);
return test('.next-overlay-wrapper');
await testReact(<Drawer visible />);
});
});
});
Loading

0 comments on commit 6283510

Please sign in to comment.