From 7e330109b36e5c33b3d9f1239ac8abd099eef6cc Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Fri, 12 Feb 2021 13:03:04 +0800 Subject: [PATCH 1/2] types(Cascader): fieldNames should be optional --- src/cascader/index.tsx | 6 +++--- src/picker/PickerColumn.tsx | 4 ++-- src/picker/index.tsx | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cascader/index.tsx b/src/cascader/index.tsx index ba1fe73fd..b11378888 100644 --- a/src/cascader/index.tsx +++ b/src/cascader/index.tsx @@ -22,9 +22,9 @@ type CascaderTab = { }; type CascaderFieldNames = { - text: string; - value: string; - children: string; + text?: string; + value?: string; + children?: string; }; export default createComponent({ diff --git a/src/picker/PickerColumn.tsx b/src/picker/PickerColumn.tsx index 91ac41405..1fd763029 100644 --- a/src/picker/PickerColumn.tsx +++ b/src/picker/PickerColumn.tsx @@ -38,7 +38,7 @@ export type PickerOption = [key: string]: any; }; -export type PickerStringColumn = string[]; +export type PickerPlainColumn = PickerOption[]; export type PickerObjectColumn = { values?: PickerOption[]; @@ -49,7 +49,7 @@ export type PickerObjectColumn = { [key: string]: any; }; -export type PickerColumn = PickerStringColumn | PickerObjectColumn; +export type PickerColumn = PickerPlainColumn | PickerObjectColumn; function isOptionDisabled(option: PickerOption) { return isObject(option) && option.disabled; diff --git a/src/picker/index.tsx b/src/picker/index.tsx index 8fce4d1d1..ded83c6cf 100644 --- a/src/picker/index.tsx +++ b/src/picker/index.tsx @@ -83,7 +83,7 @@ export default createComponent({ return 'object'; } } - return 'text'; + return 'plain'; }); const formatCascade = () => { @@ -121,7 +121,7 @@ export default createComponent({ const format = () => { const { columns } = props; - if (dataType.value === 'text') { + if (dataType.value === 'plain') { formattedColumns.value = [{ [valuesKey]: columns }]; } else if (dataType.value === 'cascade') { formatCascade(); @@ -225,7 +225,7 @@ export default createComponent({ }; const emitAction = (event: 'confirm' | 'cancel') => { - if (dataType.value === 'text') { + if (dataType.value === 'plain') { emit(event, getColumnValue(0), getColumnIndex(0)); } else { emit(event, getValues(), getIndexes()); @@ -237,7 +237,7 @@ export default createComponent({ onCascadeChange(columnIndex); } - if (dataType.value === 'text') { + if (dataType.value === 'plain') { emit('change', getColumnValue(0), getColumnIndex(0)); } else { emit('change', getValues(), columnIndex); From 30254b0420dcf6e8c88d4e95de118a6ea544779e Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Fri, 12 Feb 2021 13:04:20 +0800 Subject: [PATCH 2/2] chore: merge --- src/picker/PickerColumn.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/picker/PickerColumn.tsx b/src/picker/PickerColumn.tsx index 1fd763029..3068f45e2 100644 --- a/src/picker/PickerColumn.tsx +++ b/src/picker/PickerColumn.tsx @@ -38,8 +38,6 @@ export type PickerOption = [key: string]: any; }; -export type PickerPlainColumn = PickerOption[]; - export type PickerObjectColumn = { values?: PickerOption[]; children?: PickerColumn; @@ -49,7 +47,7 @@ export type PickerObjectColumn = { [key: string]: any; }; -export type PickerColumn = PickerPlainColumn | PickerObjectColumn; +export type PickerColumn = PickerOption[] | PickerObjectColumn; function isOptionDisabled(option: PickerOption) { return isObject(option) && option.disabled;