Skip to content

Commit

Permalink
chore: rtl & empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 26, 2023
1 parent ce84920 commit 892636d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
4 changes: 4 additions & 0 deletions examples/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export default () => {
console.log('Change:', value);
}}
/>

<Cascader.Panel options={addressOptions} direction="rtl" />

<Cascader.Panel notFoundContent="Empty!!!" />
</>
);
};
2 changes: 1 addition & 1 deletion examples/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const addressOptions = [
class Demo extends React.Component {
render() {
return (
<Cascader options={addressOptions} showSearch style={{ width: 300 }} animation="slide-up" />
<Cascader options={addressOptions} showSearch style={{ width: 300 }} animation="slide-up" notFoundContent="Empty Content!" />
);
}
}
Expand Down
40 changes: 31 additions & 9 deletions src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export type PickType =
| 'expandIcon'
| 'loadingIcon'
| 'className'
| 'style';
| 'style'
| 'direction'
| 'notFoundContent';

export type PanelProps = Pick<CascaderProps, PickType>;

Expand All @@ -49,6 +51,8 @@ export default function Panel(props: PanelProps) {
expandTrigger,
expandIcon = '>',
loadingIcon,
direction,
notFoundContent = 'Not Found',
} = props as Pick<InternalCascaderProps, PickType>;

// ======================== Multiple ========================
Expand Down Expand Up @@ -155,16 +159,34 @@ export default function Panel(props: PanelProps) {
);

// ========================= Render =========================
const panelPrefixCls = `${prefixCls}-panel`;
const isEmpty = !mergedOptions.length;

return (
<CascaderContext.Provider value={cascaderContext}>
<div className={classNames(`${prefixCls}-panel`, className)} style={style}>
<RawOptionList
prefixCls={prefixCls}
searchValue={null}
multiple={multiple}
toggleOpen={noop}
open
/>
<div
className={classNames(
panelPrefixCls,
{
[`${panelPrefixCls}-rtl`]: direction === 'rtl',
[`${panelPrefixCls}-empty`]: isEmpty,
},
className,
)}
style={style}
>
{isEmpty ? (
notFoundContent
) : (
<RawOptionList
prefixCls={prefixCls}
searchValue={null}
multiple={multiple}
toggleOpen={noop}
open
direction={direction}
/>
)}
</div>
</CascaderContext.Provider>
);
Expand Down

0 comments on commit 892636d

Please sign in to comment.