Skip to content

Commit ef96118

Browse files
author
小豪
committed
chore: reorganize code for better readability
1 parent 243125a commit ef96118

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

examples/panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default () => {
101101
disabled={disabled}
102102
/>
103103

104-
<Cascader.Panel options={addressOptions} direction="rtl" />
104+
<Cascader.Panel options={addressOptions} disabled={disabled} direction="rtl" />
105105

106106
<Cascader.Panel notFoundContent="Empty!!!" />
107107
</>

src/OptionList/Column.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface ColumnProps<OptionType extends DefaultOptionType = DefaultOptio
2323
halfCheckedSet: Set<React.Key>;
2424
loadingKeys: React.Key[];
2525
isSelectable: (option: DefaultOptionType) => boolean;
26-
panelDisabled?: boolean;
26+
disabled?: boolean;
2727
}
2828

2929
export default function Column<OptionType extends DefaultOptionType = DefaultOptionType>({
@@ -39,7 +39,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
3939
halfCheckedSet,
4040
loadingKeys,
4141
isSelectable,
42-
panelDisabled,
42+
disabled,
4343
}: ColumnProps<OptionType>) {
4444
const menuPrefixCls = `${prefixCls}-menu`;
4545
const menuItemPrefixCls = `${prefixCls}-menu-item`;
@@ -56,7 +56,7 @@ export default function Column<OptionType extends DefaultOptionType = DefaultOpt
5656

5757
const hoverOpen = expandTrigger === 'hover';
5858

59-
const isOptionDisabled = (optionDisabled?: boolean) => panelDisabled || optionDisabled;
59+
const isOptionDisabled = (optionDisabled?: boolean) => disabled || optionDisabled;
6060

6161
// ============================ Option ============================
6262
const optionInfoList = React.useMemo(

src/OptionList/List.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
4040
notFoundContent,
4141
direction,
4242
open,
43-
disabled: panelDisabled,
43+
disabled,
4444
} = props;
4545

4646
const containerRef = React.useRef<HTMLDivElement>(null);
@@ -116,10 +116,11 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
116116
};
117117

118118
const isSelectable = (option: DefaultOptionType) => {
119-
if (panelDisabled) return false;
119+
if (disabled) return false;
120120

121121
const { disabled: optionDisabled } = option;
122122
const isMergedLeaf = isLeaf(option, fieldNames);
123+
123124
return !optionDisabled && (isMergedLeaf || changeOnSelect || multiple);
124125
};
125126

@@ -220,7 +221,6 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
220221
halfCheckedSet,
221222
loadingKeys,
222223
isSelectable,
223-
panelDisabled,
224224
};
225225

226226
// >>>>> Columns
@@ -238,7 +238,6 @@ const RawOptionList = React.forwardRef<RefOptionListProps, RawOptionListProps>((
238238
options={col.options}
239239
prevValuePath={prevValuePath}
240240
activeValue={activeValue}
241-
panelDisabled={panelDisabled}
242241
/>
243242
);
244243
});

0 commit comments

Comments
 (0)