feat: AutoComplete PurePanel (#37225)

* feat: AutoComplete PurePanel

* test: update snapshot

* test: Update snapshot
This commit is contained in:
二货爱吃白萝卜 2022-08-25 11:50:24 +08:00 committed by GitHub
parent ed1bb649ba
commit 137af11d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 288 additions and 0 deletions

View File

@ -1899,6 +1899,182 @@ exports[`renders ./components/auto-complete/demo/options.md extend context corre
</div>
`;
exports[`renders ./components/auto-complete/demo/render-panel.md extend context correctly 1`] = `
<div
class="ant-space ant-space-vertical"
style="display:flex"
>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<button
aria-checked="false"
class="ant-switch"
role="switch"
type="button"
>
<div
class="ant-switch-handle"
/>
<span
class="ant-switch-inner"
/>
</button>
</div>
<div
class="ant-space-item"
>
<div
style="padding-bottom:0;position:relative;width:fit-content"
>
<div
class="ant-select ant-select-auto-complete ant-select-single ant-select-show-search"
style="width:120px;margin:0"
>
<div
class="ant-select-selector"
>
<span
class="ant-select-selection-search"
>
<input
aria-activedescendant="undefined_list_0"
aria-autocomplete="list"
aria-controls="undefined_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="undefined_list"
autocomplete="off"
class="ant-select-selection-search-input"
role="combobox"
type="search"
value="lucy"
/>
</span>
</div>
<div>
<div
class="ant-select-dropdown"
style="opacity:0"
>
<div>
<div
id="undefined_list"
role="listbox"
style="height:0;width:0;overflow:hidden"
>
<div
aria-label="Jack"
aria-selected="false"
id="undefined_list_0"
role="option"
>
jack
</div>
<div
aria-label="Lucy"
aria-selected="false"
id="undefined_list_1"
role="option"
>
lucy
</div>
</div>
<div
class="rc-virtual-list"
style="position:relative"
>
<div
class="rc-virtual-list-holder"
style="max-height:256px;overflow-y:auto;overflow-anchor:none"
>
<div>
<div
class="rc-virtual-list-holder-inner"
style="display:flex;flex-direction:column"
>
<div
aria-selected="false"
class="ant-select-item ant-select-item-option ant-select-item-option-active"
title="Jack"
>
<div
class="ant-select-item-option-content"
>
Jack
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select:none;-webkit-user-select:none"
unselectable="on"
/>
</div>
<div
aria-selected="false"
class="ant-select-item ant-select-item-option"
title="Lucy"
>
<div
class="ant-select-item-option-content"
>
Lucy
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select:none;-webkit-user-select:none"
unselectable="on"
/>
</div>
<div
aria-selected="false"
class="ant-select-item ant-select-item-option"
title="Disabled"
>
<div
class="ant-select-item-option-content"
>
Disabled
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select:none;-webkit-user-select:none"
unselectable="on"
/>
</div>
<div
aria-selected="false"
class="ant-select-item ant-select-item-option"
title="Bamboo"
>
<div
class="ant-select-item-option-content"
>
Bamboo
</div>
<span
aria-hidden="true"
class="ant-select-item-option-state"
style="user-select:none;-webkit-user-select:none"
unselectable="on"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
exports[`renders ./components/auto-complete/demo/status.md extend context correctly 1`] = `
<div
class="ant-space ant-space-vertical"

View File

@ -1061,6 +1061,66 @@ exports[`renders ./components/auto-complete/demo/options.md correctly 1`] = `
</div>
`;
exports[`renders ./components/auto-complete/demo/render-panel.md correctly 1`] = `
<div
class="ant-space ant-space-vertical"
style="display:flex"
>
<div
class="ant-space-item"
style="margin-bottom:8px"
>
<button
aria-checked="false"
class="ant-switch"
role="switch"
type="button"
>
<div
class="ant-switch-handle"
/>
<span
class="ant-switch-inner"
/>
</button>
</div>
<div
class="ant-space-item"
>
<div
style="padding-bottom:0;position:relative;width:fit-content"
>
<div
class="ant-select ant-select-auto-complete ant-select-single ant-select-show-search"
style="width:120px;margin:0"
>
<div
class="ant-select-selector"
>
<span
class="ant-select-selection-search"
>
<input
aria-activedescendant="undefined_list_0"
aria-autocomplete="list"
aria-controls="undefined_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="undefined_list"
autocomplete="off"
class="ant-select-selection-search-input"
role="combobox"
type="search"
value="lucy"
/>
</span>
</div>
</div>
</div>
</div>
</div>
`;
exports[`renders ./components/auto-complete/demo/status.md correctly 1`] = `
<div
class="ant-space ant-space-vertical"

View File

@ -0,0 +1,45 @@
---
order: 999
title:
zh-CN: _InternalPanelDoNotUseOrYouWillBeFired
en-US: _InternalPanelDoNotUseOrYouWillBeFired
debug: true
---
## zh-CN
调试用组件,请勿直接使用。
## en-US
Debug usage. Do not use in your production.
```tsx
import { AutoComplete, Switch, Space } from 'antd';
import React from 'react';
const { _InternalPanelDoNotUseOrYouWillBeFired: InternalAutoComplete } = AutoComplete;
const App: React.FC = () => {
const [open, setOpen] = React.useState(false);
return (
<Space direction="vertical" style={{ display: 'flex' }}>
<Switch checked={open} onChange={() => setOpen(!open)} />
<InternalAutoComplete
defaultValue="lucy"
style={{ width: 120 }}
open={open}
options={[
{ label: 'Jack', value: 'jack' },
{ label: 'Lucy', value: 'lucy' },
{ label: 'Disabled', value: 'disabled' },
{ label: 'Bamboo', value: 'bamboo' },
]}
/>
</Space>
);
};
export default App;
```

View File

@ -20,6 +20,7 @@ import type {
RefSelectProps,
} from '../select';
import Select from '../select';
import genPurePanel from '../_util/PurePanel';
import { isValidElement } from '../_util/reactNode';
import type { InputStatus } from '../_util/statusUtils';
import warning from '../_util/warning';
@ -156,8 +157,14 @@ const RefAutoComplete = React.forwardRef<RefSelectProps, AutoCompleteProps>(
},
) => React.ReactElement) & {
Option: typeof Option;
_InternalPanelDoNotUseOrYouWillBeFired: typeof PurePanel;
};
// We don't care debug panel
/* istanbul ignore next */
const PurePanel = genPurePanel(RefAutoComplete);
RefAutoComplete.Option = Option;
RefAutoComplete._InternalPanelDoNotUseOrYouWillBeFired = PurePanel;
export default RefAutoComplete;