Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into 20220902_feature_t…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
chaishi committed Sep 4, 2022
2 parents 1620bd9 + 83886f9 commit 72aef32
Show file tree
Hide file tree
Showing 40 changed files with 1,354 additions and 1,349 deletions.
36 changes: 27 additions & 9 deletions src/cascader/Cascader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useMemo } from 'react';
import classNames from 'classnames';
import pick from 'lodash/pick';
import omit from 'lodash/omit';
import Panel from './components/Panel';
import SelectInput from '../select-input';
import FakeArrow from '../common/FakeArrow';
Expand Down Expand Up @@ -79,7 +80,7 @@ const Cascader = (props: CascaderProps) => {
suffixIcon={() => renderSuffixIcon()}
popupProps={{
...props.popupProps,
overlayInnerStyle: panels.length ? { width: 'auto' } : {},
overlayInnerStyle: panels.length && !props.loading ? { width: 'auto' } : {},
overlayClassName: [`${classPrefix}-cascader__popup`, props.popupProps?.overlayClassName],
}}
inputProps={{ size: props.size, ...(props.inputProps as TdCascaderProps['inputProps']) }}
Expand All @@ -88,36 +89,53 @@ const Cascader = (props: CascaderProps) => {
...(props.tagInputProps as TdCascaderProps['tagInputProps']),
}}
tagProps={{ ...(props.tagProps as TdCascaderProps['tagProps']) }}
{...props.selectInputProps}
onInputChange={(value) => {
onInputChange={(value, ctx) => {
if (!visible) return;
setInputVal(`${value}`);
props?.selectInputProps?.onInputChange?.(value, ctx);
}}
onTagChange={(val: CascaderValue, ctx) => {
if (!(val as []).length && ctx.trigger === 'clear') {
ctx.e?.stopPropagation();
closeIconClickEffect(cascaderContext);
return;
}
if (ctx.trigger === 'enter') return;
handleRemoveTagEffect(cascaderContext, ctx.index, props.onRemove);
props?.selectInputProps?.onTagChange?.(val, ctx);
}}
onPopupVisibleChange={(val: boolean, context) => {
if (props.disabled) return;
setVisible(val, context);
props?.selectInputProps?.onPopupVisibleChange?.(val, context);
}}
onBlur={(val, context) => {
props.onBlur?.({
value: cascaderContext.value,
e: context.e,
});
props?.selectInputProps?.onBlur?.(val, context);
}}
onFocus={(val, context) => {
props.onFocus?.({
value: cascaderContext.value,
e: context.e,
});
props?.selectInputProps?.onFocus?.(val, context);
}}
panel={<Panel cascaderContext={cascaderContext} {...pick(props, ['trigger', 'onChange', 'empty'])}></Panel>}
onClear={(context) => {
closeIconClickEffect(cascaderContext);
props?.selectInputProps?.onClear?.(context);
}}
{...omit(props.selectInputProps, [
'onTagChange',
'onInputChange',
'onPopupVisibleChange',
'onBlur',
'onFocus',
'onClear',
])}
panel={
<Panel
cascaderContext={cascaderContext}
{...pick(props, ['trigger', 'onChange', 'empty', 'loading', 'loadingText'])}
></Panel>
}
/>
);
};
Expand Down
Loading

0 comments on commit 72aef32

Please sign in to comment.