@douyinfe/semi-ui 2.36.0-beta.0 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/semi-ui.js +45123 -59672
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.LICENSE.txt +3 -3
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_base/base.d.ts +3 -3
- package/lib/cjs/_base/baseComponent.d.ts +1 -1
- package/lib/cjs/_base/baseComponent.js +5 -16
- package/lib/cjs/_base/reactUtils.js +3 -9
- package/lib/cjs/_cssAnimation/index.js +4 -25
- package/lib/cjs/_portal/index.js +0 -31
- package/lib/cjs/_utils/hooks/usePrevFocus.js +0 -6
- package/lib/cjs/_utils/index.js +6 -45
- package/lib/cjs/anchor/anchor-context.d.ts +1 -1
- package/lib/cjs/anchor/anchor-context.js +0 -4
- package/lib/cjs/anchor/index.js +2 -48
- package/lib/cjs/anchor/link.js +4 -36
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.js +3 -42
- package/lib/cjs/autoComplete/option.js +26 -54
- package/lib/cjs/avatar/avatarGroup.js +9 -42
- package/lib/cjs/avatar/index.js +15 -56
- package/lib/cjs/avatar/interface.d.ts +6 -6
- package/lib/cjs/backtop/index.js +9 -34
- package/lib/cjs/badge/index.d.ts +3 -3
- package/lib/cjs/badge/index.js +16 -38
- package/lib/cjs/banner/index.d.ts +1 -1
- package/lib/cjs/banner/index.js +3 -31
- package/lib/cjs/breadcrumb/bread-context.js +0 -4
- package/lib/cjs/breadcrumb/index.d.ts +1 -1
- package/lib/cjs/breadcrumb/index.js +1 -45
- package/lib/cjs/breadcrumb/item.d.ts +1 -1
- package/lib/cjs/breadcrumb/item.js +16 -56
- package/lib/cjs/button/Button.d.ts +4 -4
- package/lib/cjs/button/Button.js +18 -37
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/button/buttonGroup.js +10 -35
- package/lib/cjs/button/index.js +0 -9
- package/lib/cjs/button/splitButtonGroup.js +0 -11
- package/lib/cjs/calendar/dayCalendar.js +0 -29
- package/lib/cjs/calendar/dayCol.js +1 -28
- package/lib/cjs/calendar/index.js +4 -22
- package/lib/cjs/calendar/interface.d.ts +5 -5
- package/lib/cjs/calendar/monthCalendar.js +6 -62
- package/lib/cjs/calendar/rangeCalendar.js +1 -34
- package/lib/cjs/calendar/timeCol.js +0 -20
- package/lib/cjs/calendar/weekCalendar.js +0 -35
- package/lib/cjs/card/cardGroup.d.ts +1 -1
- package/lib/cjs/card/cardGroup.js +8 -24
- package/lib/cjs/card/index.d.ts +1 -1
- package/lib/cjs/card/index.js +7 -38
- package/lib/cjs/card/meta.d.ts +1 -1
- package/lib/cjs/card/meta.js +8 -27
- package/lib/cjs/carousel/CarouselArrow.d.ts +2 -2
- package/lib/cjs/carousel/CarouselArrow.js +1 -13
- package/lib/cjs/carousel/CarouselIndicator.js +9 -33
- package/lib/cjs/carousel/index.js +1 -49
- package/lib/cjs/cascader/index.d.ts +2 -2
- package/lib/cjs/cascader/index.js +12 -144
- package/lib/cjs/cascader/item.js +2 -63
- package/lib/cjs/checkbox/checkbox.d.ts +1 -1
- package/lib/cjs/checkbox/checkbox.js +21 -55
- package/lib/cjs/checkbox/checkboxGroup.d.ts +4 -4
- package/lib/cjs/checkbox/checkboxGroup.js +9 -29
- package/lib/cjs/checkbox/checkboxInner.js +1 -15
- package/lib/cjs/checkbox/context.d.ts +1 -1
- package/lib/cjs/checkbox/context.js +0 -4
- package/lib/cjs/checkbox/index.js +0 -5
- package/lib/cjs/collapse/collapse-context.js +0 -4
- package/lib/cjs/collapse/index.js +14 -42
- package/lib/cjs/collapse/item.js +13 -41
- package/lib/cjs/collapsible/index.js +0 -34
- package/lib/cjs/configProvider/context.js +0 -4
- package/lib/cjs/configProvider/index.js +5 -21
- package/lib/cjs/datePicker/dateInput.js +39 -93
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.js +11 -119
- package/lib/cjs/datePicker/footer.js +0 -6
- package/lib/cjs/datePicker/index.js +2 -17
- package/lib/cjs/datePicker/insetInput.js +0 -9
- package/lib/cjs/datePicker/month.d.ts +1 -1
- package/lib/cjs/datePicker/month.js +25 -90
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.js +21 -96
- package/lib/cjs/datePicker/navigation.js +7 -24
- package/lib/cjs/datePicker/quickControl.js +1 -17
- package/lib/cjs/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.js +6 -52
- package/lib/cjs/descriptions/descriptions-context.d.ts +1 -1
- package/lib/cjs/descriptions/descriptions-context.js +0 -4
- package/lib/cjs/descriptions/index.d.ts +1 -1
- package/lib/cjs/descriptions/index.js +0 -15
- package/lib/cjs/descriptions/item.js +0 -14
- package/lib/cjs/divider/index.js +9 -23
- package/lib/cjs/dropdown/context.js +0 -4
- package/lib/cjs/dropdown/dropdownDivider.d.ts +1 -1
- package/lib/cjs/dropdown/dropdownDivider.js +0 -8
- package/lib/cjs/dropdown/dropdownItem.d.ts +1 -1
- package/lib/cjs/dropdown/dropdownItem.js +0 -21
- package/lib/cjs/dropdown/dropdownMenu.d.ts +1 -1
- package/lib/cjs/dropdown/dropdownMenu.js +6 -24
- package/lib/cjs/dropdown/dropdownTitle.d.ts +1 -1
- package/lib/cjs/dropdown/dropdownTitle.js +0 -12
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/dropdown/index.js +21 -62
- package/lib/cjs/empty/index.js +0 -20
- package/lib/cjs/form/arrayField.js +15 -47
- package/lib/cjs/form/baseForm.js +26 -72
- package/lib/cjs/form/context.js +1 -10
- package/lib/cjs/form/errorMessage.d.ts +1 -1
- package/lib/cjs/form/errorMessage.js +1 -20
- package/lib/cjs/form/field.js +4 -23
- package/lib/cjs/form/group.js +11 -48
- package/lib/cjs/form/hoc/withField.js +69 -144
- package/lib/cjs/form/hoc/withFormApi.js +0 -7
- package/lib/cjs/form/hoc/withFormState.js +0 -7
- package/lib/cjs/form/hooks/index.js +0 -8
- package/lib/cjs/form/hooks/useArrayFieldState.js +0 -4
- package/lib/cjs/form/hooks/useFieldApi.js +0 -5
- package/lib/cjs/form/hooks/useFieldState.js +0 -8
- package/lib/cjs/form/hooks/useFormApi.js +0 -3
- package/lib/cjs/form/hooks/useFormState.js +0 -4
- package/lib/cjs/form/hooks/useFormUpdater.js +0 -3
- package/lib/cjs/form/hooks/useStateWithGetter.js +0 -5
- package/lib/cjs/form/index.js +0 -9
- package/lib/cjs/form/interface.d.ts +4 -4
- package/lib/cjs/form/interface.js +1 -8
- package/lib/cjs/form/label.js +0 -16
- package/lib/cjs/form/section.js +1 -11
- package/lib/cjs/form/slot.js +10 -51
- package/lib/cjs/grid/col.js +10 -29
- package/lib/cjs/grid/index.js +0 -3
- package/lib/cjs/grid/row.d.ts +2 -2
- package/lib/cjs/grid/row.js +10 -34
- package/lib/cjs/highlight/index.js +0 -11
- package/lib/cjs/iconButton/index.d.ts +1 -1
- package/lib/cjs/iconButton/index.js +18 -42
- package/lib/cjs/icons/index.js +0 -3
- package/lib/cjs/image/image.d.ts +0 -3
- package/lib/cjs/image/image.js +19 -88
- package/lib/cjs/image/index.js +0 -6
- package/lib/cjs/image/interface.d.ts +1 -1
- package/lib/cjs/image/preview.d.ts +4 -0
- package/lib/cjs/image/preview.js +53 -61
- package/lib/cjs/image/previewContext.js +0 -2
- package/lib/cjs/image/previewFooter.js +9 -62
- package/lib/cjs/image/previewHeader.js +0 -13
- package/lib/cjs/image/previewImage.js +46 -79
- package/lib/cjs/image/previewInner.js +70 -126
- package/lib/cjs/index.js +0 -86
- package/lib/cjs/input/index.d.ts +3 -3
- package/lib/cjs/input/index.js +35 -103
- package/lib/cjs/input/inputGroup.d.ts +1 -1
- package/lib/cjs/input/inputGroup.js +20 -44
- package/lib/cjs/input/textarea.d.ts +1 -1
- package/lib/cjs/input/textarea.js +33 -77
- package/lib/cjs/inputNumber/index.js +127 -199
- package/lib/cjs/layout/Sider.js +7 -32
- package/lib/cjs/layout/index.js +16 -40
- package/lib/cjs/layout/layout-context.js +0 -5
- package/lib/cjs/list/index.js +0 -26
- package/lib/cjs/list/item.js +6 -30
- package/lib/cjs/list/list-context.js +0 -4
- package/lib/cjs/locale/context.js +0 -4
- package/lib/cjs/locale/localeConsumer.d.ts +1 -1
- package/lib/cjs/locale/localeConsumer.js +0 -16
- package/lib/cjs/locale/localeProvider.js +0 -11
- package/lib/cjs/locale/source/ar.js +2 -4
- package/lib/cjs/locale/source/de.js +2 -4
- package/lib/cjs/locale/source/en_GB.js +2 -4
- package/lib/cjs/locale/source/en_US.js +2 -4
- package/lib/cjs/locale/source/es.js +0 -2
- package/lib/cjs/locale/source/fr.js +2 -4
- package/lib/cjs/locale/source/id_ID.js +2 -4
- package/lib/cjs/locale/source/it.js +2 -4
- package/lib/cjs/locale/source/ja_JP.js +2 -4
- package/lib/cjs/locale/source/ko_KR.js +2 -4
- package/lib/cjs/locale/source/ms_MY.js +2 -4
- package/lib/cjs/locale/source/nl_NL.js +0 -2
- package/lib/cjs/locale/source/pl_PL.js +0 -2
- package/lib/cjs/locale/source/pt_BR.js +2 -4
- package/lib/cjs/locale/source/ro.js +0 -2
- package/lib/cjs/locale/source/ru_RU.js +2 -4
- package/lib/cjs/locale/source/sv_SE.js +0 -2
- package/lib/cjs/locale/source/th_TH.js +2 -4
- package/lib/cjs/locale/source/tr_TR.js +2 -4
- package/lib/cjs/locale/source/vi_VN.js +2 -4
- package/lib/cjs/locale/source/zh_CN.js +2 -4
- package/lib/cjs/locale/source/zh_TW.js +2 -4
- package/lib/cjs/modal/ConfirmModal.js +9 -29
- package/lib/cjs/modal/Modal.d.ts +2 -2
- package/lib/cjs/modal/Modal.js +17 -80
- package/lib/cjs/modal/ModalContent.js +13 -72
- package/lib/cjs/modal/confirm.d.ts +9 -3
- package/lib/cjs/modal/confirm.js +4 -28
- package/lib/cjs/modal/index.d.ts +1 -1
- package/lib/cjs/modal/index.js +0 -4
- package/lib/cjs/modal/useModal/HookModal.js +4 -18
- package/lib/cjs/modal/useModal/index.d.ts +1 -1
- package/lib/cjs/modal/useModal/index.js +4 -18
- package/lib/cjs/navigation/CollapseButton.js +0 -11
- package/lib/cjs/navigation/Footer.js +0 -20
- package/lib/cjs/navigation/Header.d.ts +1 -1
- package/lib/cjs/navigation/Header.js +0 -18
- package/lib/cjs/navigation/Item.js +3 -51
- package/lib/cjs/navigation/SubNav.js +7 -67
- package/lib/cjs/navigation/index.d.ts +2 -2
- package/lib/cjs/navigation/index.js +5 -60
- package/lib/cjs/navigation/nav-context.js +0 -4
- package/lib/cjs/notification/index.d.ts +1 -1
- package/lib/cjs/notification/index.js +4 -56
- package/lib/cjs/notification/notice.js +24 -58
- package/lib/cjs/notification/useNotification/HookNotice.js +3 -18
- package/lib/cjs/notification/useNotification/index.js +4 -25
- package/lib/cjs/overflowList/index.d.ts +41 -24
- package/lib/cjs/overflowList/index.js +7 -65
- package/lib/cjs/overflowList/intersectionObserver.js +2 -21
- package/lib/cjs/pagination/index.d.ts +2 -2
- package/lib/cjs/pagination/index.js +7 -59
- package/lib/cjs/popconfirm/index.js +9 -54
- package/lib/cjs/popover/Arrow.js +6 -19
- package/lib/cjs/popover/index.js +11 -38
- package/lib/cjs/progress/index.js +8 -48
- package/lib/cjs/radio/context.d.ts +2 -2
- package/lib/cjs/radio/context.js +0 -4
- package/lib/cjs/radio/index.js +0 -5
- package/lib/cjs/radio/radio.d.ts +3 -3
- package/lib/cjs/radio/radio.js +1 -36
- package/lib/cjs/radio/radioGroup.d.ts +2 -2
- package/lib/cjs/radio/radioGroup.js +0 -24
- package/lib/cjs/radio/radioInner.d.ts +1 -1
- package/lib/cjs/radio/radioInner.js +0 -21
- package/lib/cjs/rating/index.js +4 -51
- package/lib/cjs/rating/item.d.ts +1 -1
- package/lib/cjs/rating/item.js +2 -27
- package/lib/cjs/resizeObserver/index.js +4 -28
- package/lib/cjs/scrollList/index.js +0 -13
- package/lib/cjs/scrollList/scrollItem.js +15 -113
- package/lib/cjs/select/index.d.ts +6 -6
- package/lib/cjs/select/index.js +27 -164
- package/lib/cjs/select/option.js +27 -55
- package/lib/cjs/select/optionGroup.js +0 -12
- package/lib/cjs/select/utils.js +8 -24
- package/lib/cjs/select/virtualRow.js +0 -2
- package/lib/cjs/sideSheet/SideSheetContent.js +2 -40
- package/lib/cjs/sideSheet/index.js +21 -66
- package/lib/cjs/skeleton/index.js +9 -28
- package/lib/cjs/skeleton/item.d.ts +2 -2
- package/lib/cjs/skeleton/item.js +8 -29
- package/lib/cjs/slider/index.js +7 -68
- package/lib/cjs/space/index.d.ts +3 -3
- package/lib/cjs/space/index.js +0 -20
- package/lib/cjs/space/utils.js +0 -9
- package/lib/cjs/spin/icon.js +4 -17
- package/lib/cjs/spin/index.d.ts +1 -1
- package/lib/cjs/spin/index.js +0 -20
- package/lib/cjs/steps/basicStep.d.ts +2 -2
- package/lib/cjs/steps/basicStep.js +0 -22
- package/lib/cjs/steps/basicSteps.d.ts +3 -3
- package/lib/cjs/steps/basicSteps.js +0 -15
- package/lib/cjs/steps/context.js +0 -4
- package/lib/cjs/steps/fillStep.d.ts +1 -1
- package/lib/cjs/steps/fillStep.js +0 -19
- package/lib/cjs/steps/fillSteps.d.ts +2 -2
- package/lib/cjs/steps/fillSteps.js +0 -17
- package/lib/cjs/steps/index.d.ts +1 -1
- package/lib/cjs/steps/index.js +4 -26
- package/lib/cjs/steps/navStep.js +0 -11
- package/lib/cjs/steps/navSteps.d.ts +1 -1
- package/lib/cjs/steps/navSteps.js +0 -13
- package/lib/cjs/steps/step.d.ts +1 -1
- package/lib/cjs/steps/step.js +0 -15
- package/lib/cjs/switch/index.js +1 -22
- package/lib/cjs/table/Body/BaseRow.d.ts +1 -1
- package/lib/cjs/table/Body/BaseRow.js +37 -101
- package/lib/cjs/table/Body/ExpandedRow.d.ts +1 -1
- package/lib/cjs/table/Body/ExpandedRow.js +5 -30
- package/lib/cjs/table/Body/SectionRow.js +8 -46
- package/lib/cjs/table/Body/index.js +38 -153
- package/lib/cjs/table/ColGroup.js +2 -14
- package/lib/cjs/table/Column.js +0 -7
- package/lib/cjs/table/ColumnFilter.js +4 -30
- package/lib/cjs/table/ColumnSelection.js +5 -24
- package/lib/cjs/table/ColumnShape.js +0 -4
- package/lib/cjs/table/ColumnSorter.js +0 -13
- package/lib/cjs/table/CustomExpandIcon.js +0 -16
- package/lib/cjs/table/HeadTable.js +0 -23
- package/lib/cjs/table/ResizableHeaderCell.d.ts +1 -1
- package/lib/cjs/table/ResizableHeaderCell.js +9 -20
- package/lib/cjs/table/ResizableTable.js +5 -47
- package/lib/cjs/table/Table.d.ts +2 -2
- package/lib/cjs/table/Table.js +534 -771
- package/lib/cjs/table/TableCell.js +20 -81
- package/lib/cjs/table/TableContextProvider.js +0 -7
- package/lib/cjs/table/TableHeader.js +5 -33
- package/lib/cjs/table/TableHeaderRow.js +8 -45
- package/lib/cjs/table/TablePagination.js +1 -12
- package/lib/cjs/table/getColumns.js +0 -11
- package/lib/cjs/table/index.js +2 -20
- package/lib/cjs/table/interface.d.ts +58 -58
- package/lib/cjs/table/table-context.js +1 -5
- package/lib/cjs/table/utils.js +6 -30
- package/lib/cjs/tabs/TabBar.js +13 -61
- package/lib/cjs/tabs/TabItem.js +18 -31
- package/lib/cjs/tabs/TabPane.js +10 -35
- package/lib/cjs/tabs/index.js +20 -83
- package/lib/cjs/tabs/interface.d.ts +3 -3
- package/lib/cjs/tabs/tabs-context.js +0 -4
- package/lib/cjs/tag/group.js +0 -27
- package/lib/cjs/tag/index.js +23 -60
- package/lib/cjs/tag/interface.d.ts +5 -5
- package/lib/cjs/tagInput/index.d.ts +3 -3
- package/lib/cjs/tagInput/index.js +2 -77
- package/lib/cjs/timePicker/Combobox.d.ts +2 -2
- package/lib/cjs/timePicker/Combobox.js +7 -54
- package/lib/cjs/timePicker/PanelShape.js +0 -3
- package/lib/cjs/timePicker/TimeInput.d.ts +1 -1
- package/lib/cjs/timePicker/TimeInput.js +32 -64
- package/lib/cjs/timePicker/TimePicker.d.ts +3 -3
- package/lib/cjs/timePicker/TimePicker.js +39 -99
- package/lib/cjs/timePicker/TimeShape.js +0 -5
- package/lib/cjs/timePicker/index.d.ts +1 -1
- package/lib/cjs/timePicker/index.js +0 -9
- package/lib/cjs/timeline/index.js +0 -27
- package/lib/cjs/timeline/item.js +0 -13
- package/lib/cjs/toast/index.js +5 -59
- package/lib/cjs/toast/toast.js +1 -29
- package/lib/cjs/toast/useToast/HookToast.js +3 -18
- package/lib/cjs/toast/useToast/index.js +2 -17
- package/lib/cjs/tooltip/ArrowBoundingShape.js +0 -4
- package/lib/cjs/tooltip/TriangleArrow.js +4 -12
- package/lib/cjs/tooltip/TriangleArrowVertical.js +4 -12
- package/lib/cjs/tooltip/index.d.ts +2 -2
- package/lib/cjs/tooltip/index.js +24 -134
- package/lib/cjs/transfer/index.d.ts +5 -5
- package/lib/cjs/transfer/index.js +10 -93
- package/lib/cjs/tree/autoSizer.js +4 -24
- package/lib/cjs/tree/index.js +31 -122
- package/lib/cjs/tree/interface.d.ts +2 -2
- package/lib/cjs/tree/nodeCollapsible.js +4 -15
- package/lib/cjs/tree/nodeList.js +0 -22
- package/lib/cjs/tree/treeContext.js +0 -4
- package/lib/cjs/tree/treeNode.js +21 -94
- package/lib/cjs/tree/treeUtil.js +0 -6
- package/lib/cjs/treeSelect/index.d.ts +6 -6
- package/lib/cjs/treeSelect/index.js +46 -196
- package/lib/cjs/trigger/index.js +5 -16
- package/lib/cjs/typography/base.js +35 -130
- package/lib/cjs/typography/copyable.js +2 -30
- package/lib/cjs/typography/index.d.ts +1 -1
- package/lib/cjs/typography/index.js +0 -9
- package/lib/cjs/typography/interface.d.ts +9 -9
- package/lib/cjs/typography/numeral.d.ts +1 -1
- package/lib/cjs/typography/numeral.js +4 -20
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/paragraph.js +0 -12
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/text.js +0 -10
- package/lib/cjs/typography/title.d.ts +2 -2
- package/lib/cjs/typography/title.js +6 -20
- package/lib/cjs/typography/typography.js +7 -23
- package/lib/cjs/typography/util.js +22 -50
- package/lib/cjs/upload/fileCard.js +2 -52
- package/lib/cjs/upload/index.js +1 -70
- package/lib/cjs/upload/interface.d.ts +5 -5
- package/lib/es/_base/base.d.ts +3 -3
- package/lib/es/_base/baseComponent.d.ts +1 -1
- package/lib/es/_base/baseComponent.js +4 -11
- package/lib/es/_base/reactUtils.js +4 -8
- package/lib/es/_cssAnimation/index.js +4 -22
- package/lib/es/_portal/index.js +0 -23
- package/lib/es/_utils/hooks/usePrevFocus.js +0 -2
- package/lib/es/_utils/index.js +6 -28
- package/lib/es/anchor/anchor-context.d.ts +1 -1
- package/lib/es/anchor/index.js +2 -32
- package/lib/es/anchor/link.js +4 -24
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/autoComplete/index.js +3 -25
- package/lib/es/autoComplete/option.js +26 -45
- package/lib/es/avatar/avatarGroup.js +9 -28
- package/lib/es/avatar/index.js +15 -41
- package/lib/es/avatar/interface.d.ts +6 -6
- package/lib/es/backtop/index.js +9 -22
- package/lib/es/badge/index.d.ts +3 -3
- package/lib/es/badge/index.js +16 -24
- package/lib/es/banner/index.d.ts +1 -1
- package/lib/es/banner/index.js +2 -15
- package/lib/es/breadcrumb/index.d.ts +1 -1
- package/lib/es/breadcrumb/index.js +0 -31
- package/lib/es/breadcrumb/item.d.ts +1 -1
- package/lib/es/breadcrumb/item.js +16 -38
- package/lib/es/button/Button.d.ts +4 -4
- package/lib/es/button/Button.js +18 -27
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/button/buttonGroup.js +10 -24
- package/lib/es/button/index.js +0 -5
- package/lib/es/button/splitButtonGroup.js +0 -1
- package/lib/es/calendar/dayCalendar.js +0 -13
- package/lib/es/calendar/dayCol.js +0 -14
- package/lib/es/calendar/index.js +6 -12
- package/lib/es/calendar/interface.d.ts +5 -5
- package/lib/es/calendar/monthCalendar.js +6 -41
- package/lib/es/calendar/rangeCalendar.js +2 -18
- package/lib/es/calendar/timeCol.js +0 -7
- package/lib/es/calendar/weekCalendar.js +0 -17
- package/lib/es/card/cardGroup.d.ts +1 -1
- package/lib/es/card/cardGroup.js +8 -15
- package/lib/es/card/index.d.ts +1 -1
- package/lib/es/card/index.js +7 -23
- package/lib/es/card/meta.d.ts +1 -1
- package/lib/es/card/meta.js +8 -15
- package/lib/es/carousel/CarouselArrow.d.ts +2 -2
- package/lib/es/carousel/CarouselArrow.js +0 -8
- package/lib/es/carousel/CarouselIndicator.js +9 -27
- package/lib/es/carousel/index.js +0 -34
- package/lib/es/cascader/index.d.ts +2 -2
- package/lib/es/cascader/index.js +12 -105
- package/lib/es/cascader/item.js +2 -44
- package/lib/es/checkbox/checkbox.d.ts +1 -1
- package/lib/es/checkbox/checkbox.js +20 -42
- package/lib/es/checkbox/checkboxGroup.d.ts +4 -4
- package/lib/es/checkbox/checkboxGroup.js +8 -20
- package/lib/es/checkbox/checkboxInner.js +0 -6
- package/lib/es/checkbox/context.d.ts +1 -1
- package/lib/es/checkbox/index.js +0 -2
- package/lib/es/collapse/index.js +14 -31
- package/lib/es/collapse/item.js +13 -27
- package/lib/es/collapsible/index.js +0 -25
- package/lib/es/configProvider/index.js +5 -13
- package/lib/es/datePicker/dateInput.js +41 -81
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/datePicker.js +10 -103
- package/lib/es/datePicker/index.js +2 -8
- package/lib/es/datePicker/insetInput.js +0 -6
- package/lib/es/datePicker/month.d.ts +1 -1
- package/lib/es/datePicker/month.js +24 -78
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.js +20 -76
- package/lib/es/datePicker/navigation.js +8 -13
- package/lib/es/datePicker/quickControl.js +0 -6
- package/lib/es/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.js +5 -36
- package/lib/es/descriptions/descriptions-context.d.ts +1 -1
- package/lib/es/descriptions/index.d.ts +1 -1
- package/lib/es/descriptions/index.js +0 -3
- package/lib/es/descriptions/item.js +0 -3
- package/lib/es/divider/index.js +9 -17
- package/lib/es/dropdown/dropdownDivider.d.ts +1 -1
- package/lib/es/dropdown/dropdownDivider.js +0 -2
- package/lib/es/dropdown/dropdownItem.d.ts +1 -1
- package/lib/es/dropdown/dropdownItem.js +0 -11
- package/lib/es/dropdown/dropdownMenu.d.ts +1 -1
- package/lib/es/dropdown/dropdownMenu.js +6 -15
- package/lib/es/dropdown/dropdownTitle.d.ts +1 -1
- package/lib/es/dropdown/dropdownTitle.js +0 -3
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/dropdown/index.js +21 -47
- package/lib/es/empty/index.js +0 -10
- package/lib/es/form/arrayField.js +14 -41
- package/lib/es/form/baseForm.js +26 -49
- package/lib/es/form/errorMessage.d.ts +1 -1
- package/lib/es/form/errorMessage.js +0 -9
- package/lib/es/form/field.js +4 -4
- package/lib/es/form/group.js +11 -29
- package/lib/es/form/hoc/withField.js +68 -125
- package/lib/es/form/hoc/withFormApi.js +0 -3
- package/lib/es/form/hoc/withFormState.js +0 -3
- package/lib/es/form/hooks/index.js +2 -2
- package/lib/es/form/hooks/useArrayFieldState.js +0 -2
- package/lib/es/form/hooks/useFieldApi.js +0 -3
- package/lib/es/form/hooks/useFieldState.js +0 -3
- package/lib/es/form/hooks/useFormState.js +0 -2
- package/lib/es/form/hooks/useStateWithGetter.js +2 -5
- package/lib/es/form/index.js +4 -4
- package/lib/es/form/interface.d.ts +4 -4
- package/lib/es/form/interface.js +0 -1
- package/lib/es/form/label.js +0 -1
- package/lib/es/form/section.js +0 -1
- package/lib/es/form/slot.js +10 -39
- package/lib/es/grid/col.js +10 -23
- package/lib/es/grid/row.d.ts +2 -2
- package/lib/es/grid/row.js +10 -25
- package/lib/es/highlight/index.js +0 -3
- package/lib/es/iconButton/index.d.ts +1 -1
- package/lib/es/iconButton/index.js +18 -31
- package/lib/es/image/image.d.ts +0 -3
- package/lib/es/image/image.js +19 -70
- package/lib/es/image/interface.d.ts +1 -1
- package/lib/es/image/preview.d.ts +4 -0
- package/lib/es/image/preview.js +51 -48
- package/lib/es/image/previewFooter.js +9 -34
- package/lib/es/image/previewHeader.js +0 -4
- package/lib/es/image/previewImage.js +46 -69
- package/lib/es/image/previewInner.js +69 -110
- package/lib/es/index.js +0 -1
- package/lib/es/input/index.d.ts +3 -3
- package/lib/es/input/index.js +35 -88
- package/lib/es/input/inputGroup.d.ts +1 -1
- package/lib/es/input/inputGroup.js +20 -33
- package/lib/es/input/textarea.d.ts +1 -1
- package/lib/es/input/textarea.js +34 -65
- package/lib/es/inputNumber/index.js +127 -181
- package/lib/es/layout/Sider.js +7 -23
- package/lib/es/layout/index.js +16 -31
- package/lib/es/list/index.js +0 -11
- package/lib/es/list/item.js +6 -18
- package/lib/es/locale/localeConsumer.d.ts +1 -1
- package/lib/es/locale/localeConsumer.js +0 -7
- package/lib/es/locale/localeProvider.js +0 -2
- package/lib/es/locale/source/ar.js +2 -2
- package/lib/es/locale/source/de.js +2 -2
- package/lib/es/locale/source/en_GB.js +2 -2
- package/lib/es/locale/source/en_US.js +2 -2
- package/lib/es/locale/source/es.js +0 -1
- package/lib/es/locale/source/fr.js +2 -2
- package/lib/es/locale/source/id_ID.js +2 -2
- package/lib/es/locale/source/it.js +2 -2
- package/lib/es/locale/source/ja_JP.js +2 -2
- package/lib/es/locale/source/ko_KR.js +2 -2
- package/lib/es/locale/source/ms_MY.js +2 -2
- package/lib/es/locale/source/nl_NL.js +0 -1
- package/lib/es/locale/source/pl_PL.js +0 -1
- package/lib/es/locale/source/pt_BR.js +2 -2
- package/lib/es/locale/source/ro.js +0 -1
- package/lib/es/locale/source/ru_RU.js +2 -2
- package/lib/es/locale/source/sv_SE.js +0 -1
- package/lib/es/locale/source/th_TH.js +2 -2
- package/lib/es/locale/source/tr_TR.js +2 -2
- package/lib/es/locale/source/vi_VN.js +2 -2
- package/lib/es/locale/source/zh_CN.js +2 -2
- package/lib/es/locale/source/zh_TW.js +2 -2
- package/lib/es/modal/ConfirmModal.js +9 -20
- package/lib/es/modal/Modal.d.ts +2 -2
- package/lib/es/modal/Modal.js +17 -63
- package/lib/es/modal/ModalContent.js +14 -54
- package/lib/es/modal/confirm.d.ts +9 -3
- package/lib/es/modal/confirm.js +4 -11
- package/lib/es/modal/index.d.ts +1 -1
- package/lib/es/modal/useModal/HookModal.js +6 -14
- package/lib/es/modal/useModal/index.d.ts +1 -1
- package/lib/es/modal/useModal/index.js +4 -9
- package/lib/es/navigation/CollapseButton.js +0 -4
- package/lib/es/navigation/Footer.js +0 -7
- package/lib/es/navigation/Header.d.ts +1 -1
- package/lib/es/navigation/Header.js +0 -5
- package/lib/es/navigation/Item.js +2 -35
- package/lib/es/navigation/SubNav.js +6 -45
- package/lib/es/navigation/index.d.ts +2 -2
- package/lib/es/navigation/index.js +5 -38
- package/lib/es/notification/index.d.ts +1 -1
- package/lib/es/notification/index.js +4 -39
- package/lib/es/notification/notice.js +24 -46
- package/lib/es/notification/useNotification/HookNotice.js +3 -11
- package/lib/es/notification/useNotification/index.js +6 -16
- package/lib/es/overflowList/index.d.ts +41 -24
- package/lib/es/overflowList/index.js +6 -46
- package/lib/es/overflowList/intersectionObserver.js +2 -13
- package/lib/es/pagination/index.d.ts +2 -2
- package/lib/es/pagination/index.js +7 -37
- package/lib/es/popconfirm/index.js +9 -37
- package/lib/es/popover/Arrow.js +6 -18
- package/lib/es/popover/index.js +11 -27
- package/lib/es/progress/index.js +8 -37
- package/lib/es/radio/context.d.ts +2 -2
- package/lib/es/radio/index.js +0 -2
- package/lib/es/radio/radio.d.ts +3 -3
- package/lib/es/radio/radio.js +0 -23
- package/lib/es/radio/radioGroup.d.ts +2 -2
- package/lib/es/radio/radioGroup.js +0 -14
- package/lib/es/radio/radioInner.d.ts +1 -1
- package/lib/es/radio/radioInner.js +0 -11
- package/lib/es/rating/index.js +4 -36
- package/lib/es/rating/item.d.ts +1 -1
- package/lib/es/rating/item.js +2 -16
- package/lib/es/resizeObserver/index.js +4 -19
- package/lib/es/scrollList/index.js +2 -5
- package/lib/es/scrollList/scrollItem.js +15 -104
- package/lib/es/select/index.d.ts +6 -6
- package/lib/es/select/index.js +27 -123
- package/lib/es/select/option.js +27 -46
- package/lib/es/select/optionGroup.js +0 -5
- package/lib/es/select/utils.js +8 -19
- package/lib/es/select/virtualRow.js +0 -1
- package/lib/es/sideSheet/SideSheetContent.js +2 -28
- package/lib/es/sideSheet/index.js +21 -52
- package/lib/es/skeleton/index.js +9 -18
- package/lib/es/skeleton/item.d.ts +2 -2
- package/lib/es/skeleton/item.js +8 -17
- package/lib/es/slider/index.js +6 -53
- package/lib/es/space/index.d.ts +3 -3
- package/lib/es/space/index.js +0 -6
- package/lib/es/space/utils.js +0 -2
- package/lib/es/spin/icon.js +4 -15
- package/lib/es/spin/index.d.ts +1 -1
- package/lib/es/spin/index.js +0 -10
- package/lib/es/steps/basicStep.d.ts +2 -2
- package/lib/es/steps/basicStep.js +0 -15
- package/lib/es/steps/basicSteps.d.ts +3 -3
- package/lib/es/steps/basicSteps.js +0 -6
- package/lib/es/steps/fillStep.d.ts +1 -1
- package/lib/es/steps/fillStep.js +0 -13
- package/lib/es/steps/fillSteps.d.ts +2 -2
- package/lib/es/steps/fillSteps.js +0 -6
- package/lib/es/steps/index.d.ts +1 -1
- package/lib/es/steps/index.js +4 -15
- package/lib/es/steps/navStep.js +0 -5
- package/lib/es/steps/navSteps.d.ts +1 -1
- package/lib/es/steps/navSteps.js +0 -3
- package/lib/es/steps/step.d.ts +1 -1
- package/lib/es/steps/step.js +0 -7
- package/lib/es/switch/index.js +0 -13
- package/lib/es/table/Body/BaseRow.d.ts +1 -1
- package/lib/es/table/Body/BaseRow.js +37 -85
- package/lib/es/table/Body/ExpandedRow.d.ts +1 -1
- package/lib/es/table/Body/ExpandedRow.js +5 -18
- package/lib/es/table/Body/SectionRow.js +8 -35
- package/lib/es/table/Body/index.js +38 -149
- package/lib/es/table/ColGroup.js +2 -7
- package/lib/es/table/Column.js +0 -2
- package/lib/es/table/ColumnFilter.js +3 -20
- package/lib/es/table/ColumnSelection.js +5 -15
- package/lib/es/table/ColumnSorter.js +0 -1
- package/lib/es/table/CustomExpandIcon.js +0 -6
- package/lib/es/table/HeadTable.js +0 -15
- package/lib/es/table/ResizableHeaderCell.d.ts +1 -1
- package/lib/es/table/ResizableHeaderCell.js +9 -17
- package/lib/es/table/ResizableTable.js +5 -37
- package/lib/es/table/Table.d.ts +2 -2
- package/lib/es/table/Table.js +457 -664
- package/lib/es/table/TableCell.js +19 -65
- package/lib/es/table/TableContextProvider.js +0 -2
- package/lib/es/table/TableHeader.js +4 -23
- package/lib/es/table/TableHeaderRow.js +8 -39
- package/lib/es/table/TablePagination.js +0 -4
- package/lib/es/table/getColumns.js +0 -4
- package/lib/es/table/index.js +2 -10
- package/lib/es/table/interface.d.ts +58 -58
- package/lib/es/table/table-context.js +0 -1
- package/lib/es/table/utils.js +6 -19
- package/lib/es/tabs/TabBar.js +13 -46
- package/lib/es/tabs/TabItem.js +18 -24
- package/lib/es/tabs/TabPane.js +10 -25
- package/lib/es/tabs/index.js +20 -59
- package/lib/es/tabs/interface.d.ts +3 -3
- package/lib/es/tag/group.js +0 -14
- package/lib/es/tag/index.js +23 -45
- package/lib/es/tag/interface.d.ts +5 -5
- package/lib/es/tagInput/index.d.ts +3 -3
- package/lib/es/tagInput/index.js +2 -54
- package/lib/es/timePicker/Combobox.d.ts +2 -2
- package/lib/es/timePicker/Combobox.js +6 -42
- package/lib/es/timePicker/TimeInput.d.ts +1 -1
- package/lib/es/timePicker/TimeInput.js +32 -56
- package/lib/es/timePicker/TimePicker.d.ts +3 -3
- package/lib/es/timePicker/TimePicker.js +39 -80
- package/lib/es/timePicker/TimeShape.js +0 -1
- package/lib/es/timePicker/index.d.ts +1 -1
- package/lib/es/timePicker/index.js +0 -1
- package/lib/es/timeline/index.js +0 -16
- package/lib/es/timeline/item.js +0 -1
- package/lib/es/toast/index.js +4 -41
- package/lib/es/toast/toast.js +0 -17
- package/lib/es/toast/useToast/HookToast.js +3 -11
- package/lib/es/toast/useToast/index.js +4 -13
- package/lib/es/tooltip/TriangleArrow.js +4 -10
- package/lib/es/tooltip/TriangleArrowVertical.js +4 -10
- package/lib/es/tooltip/index.d.ts +2 -2
- package/lib/es/tooltip/index.js +24 -112
- package/lib/es/transfer/index.d.ts +5 -5
- package/lib/es/transfer/index.js +10 -67
- package/lib/es/tree/autoSizer.js +4 -13
- package/lib/es/tree/index.js +30 -96
- package/lib/es/tree/interface.d.ts +2 -2
- package/lib/es/tree/nodeCollapsible.js +4 -10
- package/lib/es/tree/nodeList.js +0 -14
- package/lib/es/tree/treeNode.js +21 -76
- package/lib/es/tree/treeUtil.js +0 -1
- package/lib/es/treeSelect/index.d.ts +6 -6
- package/lib/es/treeSelect/index.js +46 -156
- package/lib/es/trigger/index.js +5 -13
- package/lib/es/typography/base.js +35 -113
- package/lib/es/typography/copyable.js +2 -14
- package/lib/es/typography/index.d.ts +1 -1
- package/lib/es/typography/interface.d.ts +9 -9
- package/lib/es/typography/numeral.d.ts +1 -1
- package/lib/es/typography/numeral.js +4 -10
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/paragraph.js +0 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/text.js +0 -1
- package/lib/es/typography/title.d.ts +2 -2
- package/lib/es/typography/title.js +6 -11
- package/lib/es/typography/typography.js +7 -14
- package/lib/es/typography/util.js +22 -45
- package/lib/es/upload/fileCard.js +2 -31
- package/lib/es/upload/index.js +0 -57
- package/lib/es/upload/interface.d.ts +5 -5
- package/package.json +8 -8
package/lib/es/table/Table.js
CHANGED
|
@@ -12,36 +12,23 @@ import _find from "lodash/find";
|
|
|
12
12
|
import _includes from "lodash/includes";
|
|
13
13
|
import _noop from "lodash/noop";
|
|
14
14
|
import _get from "lodash/get";
|
|
15
|
-
|
|
16
15
|
var __rest = this && this.__rest || function (s, e) {
|
|
17
16
|
var t = {};
|
|
18
|
-
|
|
19
17
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
20
|
-
|
|
21
18
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
19
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
23
20
|
}
|
|
24
21
|
return t;
|
|
25
22
|
};
|
|
26
23
|
/* eslint-disable no-nested-ternary */
|
|
27
|
-
|
|
28
24
|
/* eslint-disable prefer-const */
|
|
29
|
-
|
|
30
25
|
/* eslint-disable prefer-destructuring */
|
|
31
|
-
|
|
32
26
|
/* eslint-disable no-shadow */
|
|
33
|
-
|
|
34
27
|
/* eslint-disable no-param-reassign */
|
|
35
|
-
|
|
36
28
|
/* eslint-disable max-len */
|
|
37
|
-
|
|
38
29
|
/* eslint-disable react/no-did-update-set-state */
|
|
39
|
-
|
|
40
30
|
/* eslint-disable eqeqeq */
|
|
41
|
-
|
|
42
31
|
/* eslint-disable max-lines-per-function */
|
|
43
|
-
|
|
44
|
-
|
|
45
32
|
import React, { createRef, isValidElement } from 'react';
|
|
46
33
|
import PropTypes from 'prop-types';
|
|
47
34
|
import classnames from 'classnames';
|
|
@@ -65,185 +52,381 @@ import ExpandedIcon from './CustomExpandIcon';
|
|
|
65
52
|
import HeadTable from './HeadTable';
|
|
66
53
|
import BodyTable from './Body';
|
|
67
54
|
import { logger, cloneDeep, mergeComponents, mergeColumns } from './utils';
|
|
68
|
-
|
|
69
55
|
class Table extends BaseComponent {
|
|
56
|
+
get adapter() {
|
|
57
|
+
var _this = this;
|
|
58
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
59
|
+
resetScrollY: () => {
|
|
60
|
+
if (this.bodyWrapRef.current) {
|
|
61
|
+
this.bodyWrapRef.current.scrollTop = 0;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
setSelectedRowKeys: selectedRowKeys => {
|
|
65
|
+
this.setState({
|
|
66
|
+
rowSelection: Object.assign(Object.assign({}, this.state.rowSelection), {
|
|
67
|
+
selectedRowKeys: [...selectedRowKeys],
|
|
68
|
+
selectedRowKeysSet: new Set(selectedRowKeys)
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
setDisabledRowKeys: disabledRowKeys => {
|
|
73
|
+
this.setState({
|
|
74
|
+
disabledRowKeys,
|
|
75
|
+
disabledRowKeysSet: new Set(disabledRowKeys)
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
setCurrentPage: currentPage => {
|
|
79
|
+
const {
|
|
80
|
+
pagination
|
|
81
|
+
} = this.state;
|
|
82
|
+
if (typeof pagination === 'object') {
|
|
83
|
+
this.setState({
|
|
84
|
+
pagination: Object.assign(Object.assign({}, pagination), {
|
|
85
|
+
currentPage
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
this.setState({
|
|
90
|
+
pagination: {
|
|
91
|
+
currentPage
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
setPagination: pagination => this.setState({
|
|
97
|
+
pagination
|
|
98
|
+
}),
|
|
99
|
+
setGroups: groups => this.setState({
|
|
100
|
+
groups
|
|
101
|
+
}),
|
|
102
|
+
setDataSource: dataSource => this.setState({
|
|
103
|
+
dataSource
|
|
104
|
+
}),
|
|
105
|
+
setExpandedRowKeys: expandedRowKeys => this.setState({
|
|
106
|
+
expandedRowKeys: [...expandedRowKeys]
|
|
107
|
+
}),
|
|
108
|
+
setQuery: function () {
|
|
109
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
110
|
+
let queries = [..._this.state.queries];
|
|
111
|
+
queries = mergeQueries(query, queries);
|
|
112
|
+
_this.setState({
|
|
113
|
+
queries
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
// Update queries when filtering or sorting
|
|
117
|
+
setQueries: queries => this.setState({
|
|
118
|
+
queries
|
|
119
|
+
}),
|
|
120
|
+
setFlattenData: flattenData => this.setState({
|
|
121
|
+
flattenData
|
|
122
|
+
}),
|
|
123
|
+
setAllRowKeys: allRowKeys => this.setState({
|
|
124
|
+
allRowKeys
|
|
125
|
+
}),
|
|
126
|
+
setHoveredRowKey: hoveredRowKey => {
|
|
127
|
+
this.store.setState({
|
|
128
|
+
hoveredRowKey
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
setCachedFilteredSortedDataSource: filteredSortedDataSource => {
|
|
132
|
+
this.cachedFilteredSortedDataSource = filteredSortedDataSource;
|
|
133
|
+
},
|
|
134
|
+
setCachedFilteredSortedRowKeys: filteredSortedRowKeys => {
|
|
135
|
+
this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
|
|
136
|
+
this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
|
|
137
|
+
},
|
|
138
|
+
setAllDisabledRowKeys: allDisabledRowKeys => {
|
|
139
|
+
const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
|
|
140
|
+
this.setState({
|
|
141
|
+
allDisabledRowKeys,
|
|
142
|
+
allDisabledRowKeysSet
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
getCurrentPage: () => _get(this.state, 'pagination.currentPage', 1),
|
|
146
|
+
getCurrentPageSize: () => _get(this.state, 'pagination.pageSize', numbers.DEFAULT_PAGE_SIZE),
|
|
147
|
+
getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
|
|
148
|
+
getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
|
|
149
|
+
getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
|
|
150
|
+
getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
|
|
151
|
+
getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
|
|
152
|
+
notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
|
|
153
|
+
notifyChange: function () {
|
|
154
|
+
return _this.props.onChange(...arguments);
|
|
155
|
+
},
|
|
156
|
+
notifyExpand: function () {
|
|
157
|
+
return _this.props.onExpand(...arguments);
|
|
158
|
+
},
|
|
159
|
+
notifyExpandedRowsChange: function () {
|
|
160
|
+
return _this.props.onExpandedRowsChange(...arguments);
|
|
161
|
+
},
|
|
162
|
+
notifySelect: function () {
|
|
163
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
164
|
+
args[_key] = arguments[_key];
|
|
165
|
+
}
|
|
166
|
+
return _this._invokeRowSelection('onSelect', ...args);
|
|
167
|
+
},
|
|
168
|
+
notifySelectAll: function () {
|
|
169
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
170
|
+
args[_key2] = arguments[_key2];
|
|
171
|
+
}
|
|
172
|
+
return _this._invokeRowSelection('onSelectAll', ...args);
|
|
173
|
+
},
|
|
174
|
+
notifySelectInvert: function () {
|
|
175
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
176
|
+
args[_key3] = arguments[_key3];
|
|
177
|
+
}
|
|
178
|
+
return _this._invokeRowSelection('onSelectInvert', ...args);
|
|
179
|
+
},
|
|
180
|
+
notifySelectionChange: function () {
|
|
181
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
182
|
+
args[_key4] = arguments[_key4];
|
|
183
|
+
}
|
|
184
|
+
return _this._invokeRowSelection('onChange', ...args);
|
|
185
|
+
},
|
|
186
|
+
isAnyColumnFixed: columns => _some(this.getColumns(columns || this.props.columns, this.props.children), column => Boolean(column.fixed)),
|
|
187
|
+
useFixedHeader: () => {
|
|
188
|
+
const {
|
|
189
|
+
scroll,
|
|
190
|
+
sticky
|
|
191
|
+
} = this.props;
|
|
192
|
+
if (_get(scroll, 'y')) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
if (sticky) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
return false;
|
|
199
|
+
},
|
|
200
|
+
getTableLayout: () => {
|
|
201
|
+
let isFixed = false;
|
|
202
|
+
const {
|
|
203
|
+
flattenColumns
|
|
204
|
+
} = this.state;
|
|
205
|
+
if (Array.isArray(flattenColumns)) {
|
|
206
|
+
isFixed = flattenColumns.some(column => Boolean(column.ellipsis) || Boolean(column.fixed));
|
|
207
|
+
}
|
|
208
|
+
return isFixed ? 'fixed' : 'auto';
|
|
209
|
+
},
|
|
210
|
+
setHeadWidths: function (headWidths) {
|
|
211
|
+
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
212
|
+
if (!equalWith(_this.state.headWidths[index], headWidths)) {
|
|
213
|
+
// The map call depends on the last state
|
|
214
|
+
_this.setState(state => {
|
|
215
|
+
const newHeadWidths = [...state.headWidths];
|
|
216
|
+
newHeadWidths[index] = [...headWidths];
|
|
217
|
+
return {
|
|
218
|
+
headWidths: newHeadWidths
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
getHeadWidths: function () {
|
|
224
|
+
let index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
225
|
+
if (_this.state.headWidths.length && typeof index === 'number') {
|
|
226
|
+
const configs = _this.state.headWidths[index] || [];
|
|
227
|
+
return configs.map(item => item.width);
|
|
228
|
+
}
|
|
229
|
+
return [];
|
|
230
|
+
},
|
|
231
|
+
// This method is called by row rendering function
|
|
232
|
+
getCellWidths: function (flattenedColumns) {
|
|
233
|
+
let flattenedWidths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
234
|
+
let ignoreScrollBarKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
235
|
+
if (Array.isArray(flattenedColumns) && flattenedColumns.length) {
|
|
236
|
+
flattenedWidths = flattenedWidths == null && _this.state.headWidths.length ? _flattenDeep(_this.state.headWidths) : [];
|
|
237
|
+
if (Array.isArray(flattenedWidths) && flattenedWidths.length) {
|
|
238
|
+
return flattenedColumns.reduce((result, column) => {
|
|
239
|
+
const found = column.key === strings.DEFAULT_KEY_COLUMN_SCROLLBAR && ignoreScrollBarKey ? null : _find(flattenedWidths, item => item && item.key != null && item.key === column.key);
|
|
240
|
+
if (found) {
|
|
241
|
+
result.push(found.width);
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
}, []);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return [];
|
|
248
|
+
},
|
|
249
|
+
mergedRowExpandable: record => {
|
|
250
|
+
const {
|
|
251
|
+
expandedRowRender,
|
|
252
|
+
childrenRecordName,
|
|
253
|
+
rowExpandable
|
|
254
|
+
} = this.props;
|
|
255
|
+
const children = _get(record, childrenRecordName);
|
|
256
|
+
const hasExpandedRowRender = typeof expandedRowRender === 'function';
|
|
257
|
+
const hasRowExpandable = typeof rowExpandable === 'function';
|
|
258
|
+
const hasChildren = Array.isArray(children) && children.length;
|
|
259
|
+
const strictExpandableResult = hasRowExpandable && rowExpandable(record);
|
|
260
|
+
const looseExpandableResult = !hasRowExpandable || strictExpandableResult;
|
|
261
|
+
return (hasExpandedRowRender || hasChildren) && looseExpandableResult || !(hasExpandedRowRender || hasChildren) && strictExpandableResult;
|
|
262
|
+
},
|
|
263
|
+
isAnyColumnUseFullRender: columns => _some(columns, column => Boolean(column.useFullRender)),
|
|
264
|
+
getNormalizeColumns: () => this.normalizeColumns,
|
|
265
|
+
getHandleColumns: () => this.handleColumns,
|
|
266
|
+
getMergePagination: () => this.mergePagination,
|
|
267
|
+
setBodyHasScrollbar: bodyHasScrollBar => {
|
|
268
|
+
if (bodyHasScrollBar !== this.state.bodyHasScrollBar) {
|
|
269
|
+
this.setState({
|
|
270
|
+
bodyHasScrollBar
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
stopPropagation(e) {
|
|
275
|
+
// The event definition here is not very accurate for now, it belongs to a broad structure definition
|
|
276
|
+
if (e && typeof e === 'object') {
|
|
277
|
+
if (typeof e.stopPropagation === 'function') {
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
}
|
|
280
|
+
if (e.nativeEvent && typeof e.nativeEvent.stopPropagation === 'function') {
|
|
281
|
+
e.nativeEvent.stopPropagation();
|
|
282
|
+
} else if (typeof e.stopImmediatePropagation === 'function') {
|
|
283
|
+
e.stopImmediatePropagation();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
70
289
|
constructor(props, context) {
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
-
super(props);
|
|
74
|
-
_this = this;
|
|
75
|
-
|
|
290
|
+
var _this2;
|
|
76
291
|
// TODO: notify when data don't have key
|
|
292
|
+
super(props);
|
|
293
|
+
_this2 = this;
|
|
77
294
|
this._warnIfNoKey = () => {
|
|
78
295
|
if ((this.props.rowSelection || this.props.expandedRowRender) && _some(this.props.dataSource, record => this.foundation.getRecordKey(record) == null)) {
|
|
79
296
|
logger.error('You must specify a key for each element in the dataSource or use "rowKey" to specify an attribute name as the primary key!');
|
|
80
297
|
}
|
|
81
298
|
};
|
|
82
|
-
|
|
83
299
|
this._invokeRowSelection = function (funcName) {
|
|
84
|
-
const func = _get(
|
|
85
|
-
|
|
300
|
+
const func = _get(_this2.state, ['rowSelection', funcName]);
|
|
86
301
|
if (typeof func === 'function') {
|
|
87
|
-
for (var
|
|
88
|
-
args[
|
|
302
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
303
|
+
args[_key5 - 1] = arguments[_key5];
|
|
89
304
|
}
|
|
90
|
-
|
|
91
305
|
func(...args);
|
|
92
306
|
}
|
|
93
307
|
};
|
|
94
|
-
|
|
95
308
|
this._invokeColumnFn = function (key, funcName) {
|
|
96
309
|
if (key && funcName) {
|
|
97
|
-
const column =
|
|
98
|
-
|
|
310
|
+
const column = _this2.foundation.getQuery(key);
|
|
99
311
|
const func = _get(column, funcName, null);
|
|
100
|
-
|
|
101
312
|
if (typeof func === 'function') {
|
|
102
|
-
for (var
|
|
103
|
-
args[
|
|
313
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
|
|
314
|
+
args[_key6 - 2] = arguments[_key6];
|
|
104
315
|
}
|
|
105
|
-
|
|
106
316
|
func(...args);
|
|
107
317
|
}
|
|
108
318
|
}
|
|
109
319
|
};
|
|
110
|
-
|
|
111
320
|
this._cacheHeaderRef = node => {
|
|
112
321
|
this.headerWrapRef.current = node;
|
|
113
322
|
};
|
|
114
|
-
|
|
115
323
|
this.getCurrentPageData = () => {
|
|
116
324
|
const pageData = this.foundation.getCurrentPageData();
|
|
117
325
|
const retObj = ['dataSource', 'groups'].reduce((result, key) => {
|
|
118
326
|
if (pageData[key]) {
|
|
119
327
|
result[key] = pageData[key];
|
|
120
328
|
}
|
|
121
|
-
|
|
122
329
|
return result;
|
|
123
330
|
}, {});
|
|
124
331
|
return cloneDeep(retObj);
|
|
125
332
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
333
|
+
this.getColumns = (columns, children) => !Array.isArray(columns) || !columns || !columns.length ? getColumns(children) : columns;
|
|
334
|
+
// @ts-ignore
|
|
130
335
|
this.getCellWidths = function () {
|
|
131
|
-
return
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
|
|
336
|
+
return _this2.foundation.getCellWidths(...arguments);
|
|
337
|
+
};
|
|
338
|
+
// @ts-ignore
|
|
135
339
|
this.setHeadWidths = function () {
|
|
136
|
-
return
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
|
|
340
|
+
return _this2.foundation.setHeadWidths(...arguments);
|
|
341
|
+
};
|
|
342
|
+
// @ts-ignore
|
|
140
343
|
this.getHeadWidths = function () {
|
|
141
|
-
return
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
|
|
344
|
+
return _this2.foundation.getHeadWidths(...arguments);
|
|
345
|
+
};
|
|
346
|
+
// @ts-ignore
|
|
145
347
|
this.mergedRowExpandable = function () {
|
|
146
|
-
return
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
|
|
348
|
+
return _this2.foundation.mergedRowExpandable(...arguments);
|
|
349
|
+
};
|
|
350
|
+
// @ts-ignore
|
|
150
351
|
this.setBodyHasScrollbar = function () {
|
|
151
|
-
return
|
|
352
|
+
return _this2.foundation.setBodyHasScrollbar(...arguments);
|
|
152
353
|
};
|
|
153
|
-
|
|
154
354
|
this.handleWheel = event => {
|
|
155
355
|
const {
|
|
156
356
|
scroll = {}
|
|
157
357
|
} = this.props;
|
|
158
|
-
|
|
159
358
|
if (window.navigator.userAgent.match(/Trident\/7\./) && scroll.y) {
|
|
160
359
|
event.preventDefault();
|
|
161
360
|
const wd = event.deltaY;
|
|
162
361
|
const {
|
|
163
362
|
target
|
|
164
|
-
} = event;
|
|
165
|
-
|
|
363
|
+
} = event;
|
|
364
|
+
// const { bodyTable, fixedColumnsBodyLeft, fixedColumnsBodyRight } = this;
|
|
166
365
|
const bodyTable = this.bodyWrapRef.current;
|
|
167
366
|
let scrollTop = 0;
|
|
168
|
-
|
|
169
367
|
if (this.lastScrollTop) {
|
|
170
368
|
scrollTop = this.lastScrollTop + wd;
|
|
171
369
|
} else {
|
|
172
370
|
scrollTop = wd;
|
|
173
371
|
}
|
|
174
|
-
|
|
175
372
|
if (bodyTable && target !== bodyTable) {
|
|
176
373
|
bodyTable.scrollTop = scrollTop;
|
|
177
374
|
}
|
|
178
375
|
}
|
|
179
376
|
};
|
|
180
|
-
|
|
181
377
|
this.handleBodyScrollLeft = e => {
|
|
182
378
|
if (e.currentTarget !== e.target) {
|
|
183
379
|
return;
|
|
184
380
|
}
|
|
185
|
-
|
|
186
381
|
const {
|
|
187
382
|
target
|
|
188
|
-
} = e;
|
|
189
|
-
|
|
383
|
+
} = e;
|
|
384
|
+
// const { headTable, bodyTable } = this;
|
|
190
385
|
const headTable = this.headerWrapRef.current;
|
|
191
386
|
const bodyTable = this.bodyWrapRef.current;
|
|
192
|
-
|
|
193
387
|
if (target.scrollLeft !== this.lastScrollLeft) {
|
|
194
388
|
if (target === bodyTable && headTable) {
|
|
195
389
|
headTable.scrollLeft = target.scrollLeft;
|
|
196
390
|
} else if (target === headTable && bodyTable) {
|
|
197
391
|
bodyTable.scrollLeft = target.scrollLeft;
|
|
198
392
|
}
|
|
199
|
-
|
|
200
393
|
this.setScrollPositionClassName();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
394
|
+
}
|
|
395
|
+
// Remember last scrollLeft for scroll direction detecting.
|
|
204
396
|
this.lastScrollLeft = target.scrollLeft;
|
|
205
397
|
};
|
|
206
|
-
|
|
207
398
|
this.handleWindowResize = () => {
|
|
208
399
|
this.syncTableWidth();
|
|
209
400
|
this.setScrollPositionClassName();
|
|
210
401
|
};
|
|
211
|
-
|
|
212
402
|
this.handleBodyScrollTop = e => {
|
|
213
403
|
const {
|
|
214
404
|
target
|
|
215
405
|
} = e;
|
|
216
|
-
|
|
217
406
|
if (e.currentTarget !== target) {
|
|
218
407
|
return;
|
|
219
408
|
}
|
|
220
|
-
|
|
221
409
|
const {
|
|
222
410
|
scroll = {}
|
|
223
|
-
} = this.props;
|
|
224
|
-
|
|
411
|
+
} = this.props;
|
|
412
|
+
// const { headTable, bodyTable, fixedColumnsBodyLeft, fixedColumnsBodyRight } = this;
|
|
225
413
|
const headTable = this.headerWrapRef.current;
|
|
226
414
|
const bodyTable = this.bodyWrapRef.current;
|
|
227
|
-
|
|
228
415
|
if (target.scrollTop !== this.lastScrollTop && scroll.y && target !== headTable) {
|
|
229
416
|
const {
|
|
230
417
|
scrollTop
|
|
231
418
|
} = target;
|
|
232
|
-
|
|
233
419
|
if (bodyTable && target !== bodyTable) {
|
|
234
420
|
bodyTable.scrollTop = scrollTop;
|
|
235
421
|
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
422
|
+
}
|
|
423
|
+
// Remember last scrollTop for scroll direction detecting.
|
|
239
424
|
this.lastScrollTop = target.scrollTop;
|
|
240
425
|
};
|
|
241
|
-
|
|
242
426
|
this.handleBodyScroll = e => {
|
|
243
427
|
this.handleBodyScrollLeft(e);
|
|
244
428
|
this.handleBodyScrollTop(e);
|
|
245
429
|
};
|
|
246
|
-
|
|
247
430
|
this.setScrollPosition = position => {
|
|
248
431
|
const {
|
|
249
432
|
prefixCls
|
|
@@ -251,7 +434,6 @@ class Table extends BaseComponent {
|
|
|
251
434
|
const positionAll = [`${prefixCls}-scroll-position-both`, `${prefixCls}-scroll-position-middle`, `${prefixCls}-scroll-position-left`, `${prefixCls}-scroll-position-right`];
|
|
252
435
|
this.scrollPosition = position;
|
|
253
436
|
const tableNode = this.wrapRef.current;
|
|
254
|
-
|
|
255
437
|
if (tableNode && tableNode.nodeType) {
|
|
256
438
|
if (position === 'both') {
|
|
257
439
|
const acceptPosition = [`${prefixCls}-scroll-position-left`, `${prefixCls}-scroll-position-right`];
|
|
@@ -264,15 +446,12 @@ class Table extends BaseComponent {
|
|
|
264
446
|
}
|
|
265
447
|
}
|
|
266
448
|
};
|
|
267
|
-
|
|
268
449
|
this.setScrollPositionClassName = () => {
|
|
269
450
|
const node = this.bodyWrapRef.current;
|
|
270
|
-
|
|
271
451
|
if (node && node.children && node.children.length) {
|
|
272
|
-
const scrollToLeft = node.scrollLeft === 0;
|
|
273
|
-
|
|
452
|
+
const scrollToLeft = node.scrollLeft === 0;
|
|
453
|
+
// why use Math.abs? @see https://bugzilla.mozilla.org/show_bug.cgi?id=1447743
|
|
274
454
|
const scrollToRight = Math.abs(node.scrollLeft) + 1 >= node.children[0].getBoundingClientRect().width - node.getBoundingClientRect().width;
|
|
275
|
-
|
|
276
455
|
if (scrollToLeft && scrollToRight) {
|
|
277
456
|
this.setScrollPosition('both');
|
|
278
457
|
} else if (scrollToLeft) {
|
|
@@ -284,7 +463,6 @@ class Table extends BaseComponent {
|
|
|
284
463
|
}
|
|
285
464
|
}
|
|
286
465
|
};
|
|
287
|
-
|
|
288
466
|
this.syncTableWidth = () => {
|
|
289
467
|
if (this.rootWrapRef && this.rootWrapRef.current) {
|
|
290
468
|
this.setState({
|
|
@@ -292,15 +470,13 @@ class Table extends BaseComponent {
|
|
|
292
470
|
});
|
|
293
471
|
}
|
|
294
472
|
};
|
|
295
|
-
|
|
296
473
|
this.renderSelection = function () {
|
|
297
474
|
let record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
298
475
|
let inHeader = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
299
476
|
const {
|
|
300
477
|
rowSelection,
|
|
301
478
|
allDisabledRowKeysSet
|
|
302
|
-
} =
|
|
303
|
-
|
|
479
|
+
} = _this2.state;
|
|
304
480
|
if (rowSelection && typeof rowSelection === 'object') {
|
|
305
481
|
const {
|
|
306
482
|
selectedRowKeys = [],
|
|
@@ -308,17 +484,12 @@ class Table extends BaseComponent {
|
|
|
308
484
|
getCheckboxProps,
|
|
309
485
|
disabled
|
|
310
486
|
} = rowSelection;
|
|
311
|
-
|
|
312
487
|
if (inHeader) {
|
|
313
488
|
const columnKey = _get(rowSelection, 'key', strings.DEFAULT_KEY_COLUMN_SELECTION);
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const allIsSelected = _this.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
|
|
319
|
-
|
|
320
|
-
const hasRowSelected = _this.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
|
|
321
|
-
|
|
489
|
+
const allRowKeys = _this2.cachedFilteredSortedRowKeys;
|
|
490
|
+
const allRowKeysSet = _this2.cachedFilteredSortedRowKeysSet;
|
|
491
|
+
const allIsSelected = _this2.foundation.allIsSelected(selectedRowKeysSet, allDisabledRowKeysSet, allRowKeys);
|
|
492
|
+
const hasRowSelected = _this2.foundation.hasRowSelected(selectedRowKeys, allRowKeysSet);
|
|
322
493
|
return /*#__PURE__*/React.createElement(ColumnSelection, {
|
|
323
494
|
"aria-label": `${allIsSelected ? 'Deselect' : 'Select'} all rows`,
|
|
324
495
|
disabled: disabled,
|
|
@@ -326,35 +497,28 @@ class Table extends BaseComponent {
|
|
|
326
497
|
selected: allIsSelected,
|
|
327
498
|
indeterminate: hasRowSelected && !allIsSelected,
|
|
328
499
|
onChange: (selected, e) => {
|
|
329
|
-
|
|
500
|
+
_this2.toggleSelectAllRow(selected, e);
|
|
330
501
|
}
|
|
331
502
|
});
|
|
332
503
|
} else {
|
|
333
|
-
const key =
|
|
334
|
-
|
|
504
|
+
const key = _this2.foundation.getRecordKey(record);
|
|
335
505
|
const selected = selectedRowKeysSet.has(key);
|
|
336
|
-
|
|
337
506
|
const checkboxPropsFn = () => typeof getCheckboxProps === 'function' ? getCheckboxProps(record) : {};
|
|
338
|
-
|
|
339
507
|
return /*#__PURE__*/React.createElement(ColumnSelection, {
|
|
340
508
|
"aria-label": `${selected ? 'Deselect' : 'Select'} this row`,
|
|
341
509
|
getCheckboxProps: checkboxPropsFn,
|
|
342
510
|
selected: selected,
|
|
343
|
-
onChange: (status, e) =>
|
|
511
|
+
onChange: (status, e) => _this2.toggleSelectRow(status, key, e)
|
|
344
512
|
});
|
|
345
513
|
}
|
|
346
514
|
}
|
|
347
|
-
|
|
348
515
|
return null;
|
|
349
516
|
};
|
|
350
|
-
|
|
351
517
|
this.renderRowSelectionCallback = function (text) {
|
|
352
518
|
let record = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
353
|
-
return
|
|
519
|
+
return _this2.renderSelection(record);
|
|
354
520
|
};
|
|
355
|
-
|
|
356
521
|
this.renderTitleSelectionCallback = () => this.renderSelection(null, true);
|
|
357
|
-
|
|
358
522
|
this.normalizeSelectionColumn = function () {
|
|
359
523
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
360
524
|
const {
|
|
@@ -362,26 +526,21 @@ class Table extends BaseComponent {
|
|
|
362
526
|
prefixCls
|
|
363
527
|
} = props;
|
|
364
528
|
let column = {};
|
|
365
|
-
|
|
366
529
|
if (rowSelection) {
|
|
367
530
|
const needOmitSelectionKey = ['selectedRowKeys', 'selectedRowKeysSet'];
|
|
368
531
|
column = {
|
|
369
532
|
key: strings.DEFAULT_KEY_COLUMN_SELECTION
|
|
370
533
|
};
|
|
371
|
-
|
|
372
534
|
if (_isObject(rowSelection)) {
|
|
373
535
|
column = Object.assign(Object.assign({}, column), _omit(rowSelection, needOmitSelectionKey));
|
|
374
536
|
}
|
|
375
|
-
|
|
376
537
|
column.className = classnames(column.className, `${prefixCls}-column-selection`);
|
|
377
|
-
column.title =
|
|
378
|
-
column.render =
|
|
538
|
+
column.title = _this2.renderTitleSelectionCallback;
|
|
539
|
+
column.render = _this2.renderRowSelectionCallback;
|
|
379
540
|
}
|
|
380
|
-
|
|
381
541
|
return column;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
|
|
542
|
+
};
|
|
543
|
+
// If there is a scroll bar, manually construct a column and insert it into the header
|
|
385
544
|
this.normalizeScrollbarColumn = function () {
|
|
386
545
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
387
546
|
const {
|
|
@@ -400,33 +559,29 @@ class Table extends BaseComponent {
|
|
|
400
559
|
* @param {String} groupKey
|
|
401
560
|
* @returns {ReactNode}
|
|
402
561
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
562
|
this.renderExpandIcon = function () {
|
|
406
563
|
let record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
407
564
|
let isNested = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
408
565
|
let groupKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
409
566
|
const {
|
|
410
567
|
expandedRowKeys
|
|
411
|
-
} =
|
|
568
|
+
} = _this2.state;
|
|
412
569
|
const {
|
|
413
570
|
expandIcon
|
|
414
|
-
} =
|
|
415
|
-
const key = typeof groupKey === 'string' || typeof groupKey === 'number' ? groupKey :
|
|
571
|
+
} = _this2.props;
|
|
572
|
+
const key = typeof groupKey === 'string' || typeof groupKey === 'number' ? groupKey : _this2.foundation.getRecordKey(record);
|
|
416
573
|
return /*#__PURE__*/React.createElement(ExpandedIcon, {
|
|
417
574
|
key: key,
|
|
418
575
|
componentType: isNested ? 'tree' : 'expand',
|
|
419
576
|
expanded: _includes(expandedRowKeys, key),
|
|
420
577
|
expandIcon: expandIcon,
|
|
421
|
-
onClick: (expanded, e) =>
|
|
578
|
+
onClick: (expanded, e) => _this2.handleRowExpanded(expanded, key, e)
|
|
422
579
|
});
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
|
|
580
|
+
};
|
|
581
|
+
// @ts-ignore
|
|
426
582
|
this.handleRowExpanded = function () {
|
|
427
|
-
return
|
|
583
|
+
return _this2.foundation.handleRowExpanded(...arguments);
|
|
428
584
|
};
|
|
429
|
-
|
|
430
585
|
this.normalizeExpandColumn = function () {
|
|
431
586
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
432
587
|
let column = null;
|
|
@@ -444,7 +599,7 @@ class Table extends BaseComponent {
|
|
|
444
599
|
let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
445
600
|
let record = arguments.length > 1 ? arguments[1] : undefined;
|
|
446
601
|
let index = arguments.length > 2 ? arguments[2] : undefined;
|
|
447
|
-
return
|
|
602
|
+
return _this2.adapter.mergedRowExpandable(record) ? _this2.renderExpandIcon(record) : null;
|
|
448
603
|
} : () => null;
|
|
449
604
|
return column;
|
|
450
605
|
};
|
|
@@ -453,14 +608,11 @@ class Table extends BaseComponent {
|
|
|
453
608
|
* Title support function, passing parameters as {filter: node, sorter: node, selection: node}
|
|
454
609
|
* @param {*} column
|
|
455
610
|
*/
|
|
456
|
-
|
|
457
|
-
|
|
458
611
|
this.addFnsInColumn = function () {
|
|
459
612
|
let column = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
460
613
|
const {
|
|
461
614
|
prefixCls
|
|
462
|
-
} =
|
|
463
|
-
|
|
615
|
+
} = _this2.props;
|
|
464
616
|
if (column && (column.sorter || column.filters || column.useFullRender)) {
|
|
465
617
|
let hasSorterOrFilter = false;
|
|
466
618
|
const {
|
|
@@ -468,35 +620,29 @@ class Table extends BaseComponent {
|
|
|
468
620
|
title: rawTitle,
|
|
469
621
|
useFullRender
|
|
470
622
|
} = column;
|
|
471
|
-
|
|
472
|
-
const curQuery = _this.foundation.getQuery(dataIndex);
|
|
473
|
-
|
|
623
|
+
const curQuery = _this2.foundation.getQuery(dataIndex);
|
|
474
624
|
const titleMap = {};
|
|
475
|
-
const titleArr = [];
|
|
476
|
-
|
|
625
|
+
const titleArr = [];
|
|
626
|
+
// useFullRender adds select buttons to each column
|
|
477
627
|
if (useFullRender) {
|
|
478
|
-
titleMap.selection =
|
|
628
|
+
titleMap.selection = _this2.renderSelection(null, true);
|
|
479
629
|
}
|
|
480
|
-
|
|
481
630
|
const stateSortOrder = _get(curQuery, 'sortOrder');
|
|
482
|
-
|
|
483
631
|
const defaultSortOrder = _get(curQuery, 'defaultSortOrder', false);
|
|
484
|
-
|
|
485
|
-
const sortOrder = _this.foundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : defaultSortOrder;
|
|
632
|
+
const sortOrder = _this2.foundation.isSortOrderValid(stateSortOrder) ? stateSortOrder : defaultSortOrder;
|
|
486
633
|
const showEllipsisTitle = shouldShowEllipsisTitle(column.ellipsis);
|
|
487
634
|
const TitleNode = typeof rawTitle !== 'function' && /*#__PURE__*/React.createElement("span", {
|
|
488
635
|
className: `${prefixCls}-row-head-title`,
|
|
489
636
|
key: strings.DEFAULT_KEY_COLUMN_TITLE,
|
|
490
637
|
title: showEllipsisTitle && typeof rawTitle === 'string' ? rawTitle : undefined
|
|
491
638
|
}, rawTitle);
|
|
492
|
-
|
|
493
639
|
if (typeof column.sorter === 'function' || column.sorter === true) {
|
|
494
640
|
// In order to increase the click hot area of sorting, when sorting is required & useFullRender is false,
|
|
495
641
|
// both the title and sorting areas are used as the click hot area for sorting。
|
|
496
642
|
const sorter = /*#__PURE__*/React.createElement(ColumnSorter, {
|
|
497
643
|
key: strings.DEFAULT_KEY_COLUMN_SORTER,
|
|
498
644
|
sortOrder: sortOrder,
|
|
499
|
-
onClick: e =>
|
|
645
|
+
onClick: e => _this2.foundation.handleSort(column, e),
|
|
500
646
|
title: TitleNode
|
|
501
647
|
});
|
|
502
648
|
useFullRender && (titleMap.sorter = sorter);
|
|
@@ -505,26 +651,21 @@ class Table extends BaseComponent {
|
|
|
505
651
|
} else {
|
|
506
652
|
titleArr.push(TitleNode);
|
|
507
653
|
}
|
|
508
|
-
|
|
509
654
|
const stateFilteredValue = _get(curQuery, 'filteredValue');
|
|
510
|
-
|
|
511
655
|
const defaultFilteredValue = _get(curQuery, 'defaultFilteredValue');
|
|
512
|
-
|
|
513
656
|
const filteredValue = stateFilteredValue ? stateFilteredValue : defaultFilteredValue;
|
|
514
|
-
|
|
515
657
|
if (Array.isArray(column.filters) && column.filters.length || /*#__PURE__*/isValidElement(column.filterDropdown)) {
|
|
516
658
|
const filter = /*#__PURE__*/React.createElement(ColumnFilter, Object.assign({
|
|
517
659
|
key: strings.DEFAULT_KEY_COLUMN_FILTER
|
|
518
660
|
}, curQuery, {
|
|
519
661
|
filteredValue: filteredValue,
|
|
520
|
-
onFilterDropdownVisibleChange: visible =>
|
|
521
|
-
onSelect: data =>
|
|
662
|
+
onFilterDropdownVisibleChange: visible => _this2.foundation.toggleShowFilter(dataIndex, visible),
|
|
663
|
+
onSelect: data => _this2.foundation.handleFilterSelect(dataIndex, data)
|
|
522
664
|
}));
|
|
523
665
|
useFullRender && (titleMap.filter = filter);
|
|
524
666
|
hasSorterOrFilter = true;
|
|
525
667
|
titleArr.push(filter);
|
|
526
668
|
}
|
|
527
|
-
|
|
528
669
|
const newTitle = typeof rawTitle === 'function' ? () => rawTitle(titleMap) : hasSorterOrFilter ? /*#__PURE__*/React.createElement("div", {
|
|
529
670
|
className: `${prefixCls}-operate-wrapper`
|
|
530
671
|
}, titleArr) : titleArr;
|
|
@@ -532,14 +673,11 @@ class Table extends BaseComponent {
|
|
|
532
673
|
title: newTitle
|
|
533
674
|
});
|
|
534
675
|
}
|
|
535
|
-
|
|
536
676
|
return column;
|
|
537
677
|
};
|
|
538
|
-
|
|
539
678
|
this.toggleSelectRow = (selected, realKey, e) => {
|
|
540
679
|
this.foundation.handleSelectRow(realKey, selected, e);
|
|
541
680
|
};
|
|
542
|
-
|
|
543
681
|
this.toggleSelectAllRow = (selected, e) => {
|
|
544
682
|
this.foundation.handleSelectAllRow(selected, e);
|
|
545
683
|
};
|
|
@@ -548,14 +686,11 @@ class Table extends BaseComponent {
|
|
|
548
686
|
* @param {object} pagination
|
|
549
687
|
* @param {object} propRenderPagination
|
|
550
688
|
*/
|
|
551
|
-
|
|
552
|
-
|
|
553
689
|
this.renderPagination = (pagination, propRenderPagination) => {
|
|
554
690
|
if (!pagination) {
|
|
555
691
|
return null;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
692
|
+
}
|
|
693
|
+
// use memoized pagination
|
|
559
694
|
const mergedPagination = this.foundation.memoizedPagination(pagination);
|
|
560
695
|
return /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
561
696
|
componentName: "Table"
|
|
@@ -568,7 +703,6 @@ class Table extends BaseComponent {
|
|
|
568
703
|
});
|
|
569
704
|
});
|
|
570
705
|
};
|
|
571
|
-
|
|
572
706
|
this.renderTitle = function () {
|
|
573
707
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
574
708
|
let {
|
|
@@ -578,17 +712,14 @@ class Table extends BaseComponent {
|
|
|
578
712
|
prefixCls,
|
|
579
713
|
dataSource
|
|
580
714
|
} = props;
|
|
581
|
-
|
|
582
715
|
if (typeof title === 'function') {
|
|
583
716
|
title = title(dataSource);
|
|
584
717
|
}
|
|
585
|
-
|
|
586
718
|
return /*#__PURE__*/isValidElement(title) || typeof title === 'string' ? /*#__PURE__*/React.createElement("div", {
|
|
587
719
|
className: `${prefixCls}-title`,
|
|
588
720
|
"x-semi-prop": "title"
|
|
589
721
|
}, title) : null;
|
|
590
722
|
};
|
|
591
|
-
|
|
592
723
|
this.renderEmpty = function () {
|
|
593
724
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
594
725
|
const {
|
|
@@ -597,13 +728,10 @@ class Table extends BaseComponent {
|
|
|
597
728
|
dataSource
|
|
598
729
|
} = props;
|
|
599
730
|
const wrapCls = `${prefixCls}-placeholder`;
|
|
600
|
-
|
|
601
|
-
const isEmpty = _this.foundation.isEmpty(dataSource);
|
|
602
|
-
|
|
731
|
+
const isEmpty = _this2.foundation.isEmpty(dataSource);
|
|
603
732
|
if (!isEmpty) {
|
|
604
733
|
return null;
|
|
605
734
|
}
|
|
606
|
-
|
|
607
735
|
return /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
608
736
|
componentName: "Table",
|
|
609
737
|
key: 'emptyText'
|
|
@@ -614,7 +742,6 @@ class Table extends BaseComponent {
|
|
|
614
742
|
"x-semi-prop": "empty"
|
|
615
743
|
}, empty || locale.emptyText)));
|
|
616
744
|
};
|
|
617
|
-
|
|
618
745
|
this.renderFooter = function () {
|
|
619
746
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
620
747
|
let {
|
|
@@ -624,18 +751,15 @@ class Table extends BaseComponent {
|
|
|
624
751
|
prefixCls,
|
|
625
752
|
dataSource
|
|
626
753
|
} = props;
|
|
627
|
-
|
|
628
754
|
if (typeof footer === 'function') {
|
|
629
755
|
footer = footer(dataSource);
|
|
630
756
|
}
|
|
631
|
-
|
|
632
757
|
return /*#__PURE__*/isValidElement(footer) || typeof footer === 'string' ? /*#__PURE__*/React.createElement("div", {
|
|
633
758
|
className: `${prefixCls}-footer`,
|
|
634
759
|
key: "footer",
|
|
635
760
|
"x-semi-prop": "footer"
|
|
636
761
|
}, footer) : null;
|
|
637
762
|
};
|
|
638
|
-
|
|
639
763
|
this.renderMainTable = props => {
|
|
640
764
|
const useFixedHeader = this.adapter.useFixedHeader();
|
|
641
765
|
const emptySlot = this.renderEmpty(props);
|
|
@@ -649,7 +773,6 @@ class Table extends BaseComponent {
|
|
|
649
773
|
})), this.renderFooter(props)];
|
|
650
774
|
return table;
|
|
651
775
|
};
|
|
652
|
-
|
|
653
776
|
this.renderTable = props => {
|
|
654
777
|
const {
|
|
655
778
|
columns,
|
|
@@ -671,9 +794,7 @@ class Table extends BaseComponent {
|
|
|
671
794
|
disabledRowKeysSet,
|
|
672
795
|
sticky
|
|
673
796
|
} = props;
|
|
674
|
-
|
|
675
797
|
const selectedRowKeysSet = _get(rowSelection, 'selectedRowKeysSet', new Set());
|
|
676
|
-
|
|
677
798
|
const tableLayout = this.adapter.getTableLayout();
|
|
678
799
|
const headTable = fixed || useFixedHeader ? /*#__PURE__*/React.createElement(HeadTable, {
|
|
679
800
|
key: "head",
|
|
@@ -729,8 +850,6 @@ class Table extends BaseComponent {
|
|
|
729
850
|
* @param {Array} cachedColumns
|
|
730
851
|
* @returns columns after adding extended functions
|
|
731
852
|
*/
|
|
732
|
-
|
|
733
|
-
|
|
734
853
|
this.handleColumns = (queries, cachedColumns) => {
|
|
735
854
|
const {
|
|
736
855
|
hideExpandedColumn,
|
|
@@ -740,410 +859,131 @@ class Table extends BaseComponent {
|
|
|
740
859
|
expandIcon,
|
|
741
860
|
rowSelection
|
|
742
861
|
} = this.props;
|
|
743
|
-
const childrenColumnName = 'children';
|
|
744
|
-
let columns = cloneDeep(cachedColumns);
|
|
745
|
-
|
|
746
|
-
const addFns = function () {
|
|
747
|
-
let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
newColumn[childrenColumnName] = newChildren;
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
originColumns[index] = newColumn;
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
addFns(columns); // hideExpandedColumn=false render expand column separately
|
|
767
|
-
|
|
768
|
-
if (!hideExpandedColumn) {
|
|
769
|
-
const column = this.normalizeExpandColumn({
|
|
770
|
-
prefixCls,
|
|
771
|
-
expandCellFixed,
|
|
772
|
-
expandIcon
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
const destIndex = _findIndex(columns, item => item.key === strings.DEFAULT_KEY_COLUMN_EXPAND);
|
|
776
|
-
|
|
777
|
-
if (column) {
|
|
778
|
-
if (destIndex > -1) {
|
|
779
|
-
columns[destIndex] = Object.assign(Object.assign({}, column), columns[destIndex]);
|
|
780
|
-
} else if (column.fixed === 'right') {
|
|
781
|
-
columns = [...columns, column];
|
|
782
|
-
} else {
|
|
783
|
-
columns = [column, ...columns];
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
} // selection column
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
if (rowSelection && !_get(rowSelection, 'hidden')) {
|
|
790
|
-
const destIndex = _findIndex(columns, item => item.key === strings.DEFAULT_KEY_COLUMN_SELECTION);
|
|
791
|
-
|
|
792
|
-
const column = this.normalizeSelectionColumn({
|
|
793
|
-
rowSelection,
|
|
794
|
-
prefixCls
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
if (destIndex > -1) {
|
|
798
|
-
columns[destIndex] = Object.assign(Object.assign({}, column), columns[destIndex]);
|
|
799
|
-
} else if (column.fixed === 'right') {
|
|
800
|
-
columns = [...columns, column];
|
|
801
|
-
} else {
|
|
802
|
-
columns = [column, ...columns];
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
assignColumnKeys(columns);
|
|
807
|
-
return columns;
|
|
808
|
-
};
|
|
809
|
-
/**
|
|
810
|
-
* Convert children to columns object
|
|
811
|
-
* @param {Array} columns
|
|
812
|
-
* @param {ReactNode} children
|
|
813
|
-
* @returns {Array}
|
|
814
|
-
*/
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
this.normalizeColumns = (columns, children) => {
|
|
818
|
-
const normalColumns = cloneDeep(this.getColumns(columns, children));
|
|
819
|
-
return normalColumns;
|
|
820
|
-
};
|
|
821
|
-
/**
|
|
822
|
-
* Combine pagination and table paging processing functions
|
|
823
|
-
*/
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
this.mergePagination = pagination => {
|
|
827
|
-
const newPagination = Object.assign({
|
|
828
|
-
onChange: this.foundation.setPage
|
|
829
|
-
}, pagination);
|
|
830
|
-
return newPagination;
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
this.foundation = new TableFoundation(this.adapter); // columns cannot be deepClone, otherwise the comparison will be false
|
|
834
|
-
|
|
835
|
-
const columns = this.getColumns(props.columns, props.children);
|
|
836
|
-
const cachedflattenColumns = flattenColumns(columns);
|
|
837
|
-
const queries = TableFoundation.initColumnsFilteredValueAndSorterOrder(cloneDeep(cachedflattenColumns));
|
|
838
|
-
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(this.props.dataSource, queries);
|
|
839
|
-
const newPagination = _isPlainObject(this.props.pagination) ? this.props.pagination : {};
|
|
840
|
-
const pageData = this.foundation.getCurrentPageData(filteredSortedDataSource, newPagination, queries);
|
|
841
|
-
this.state = {
|
|
842
|
-
/**
|
|
843
|
-
* Cached props
|
|
844
|
-
*/
|
|
845
|
-
cachedColumns: columns,
|
|
846
|
-
cachedChildren: props.children,
|
|
847
|
-
flattenColumns: cachedflattenColumns,
|
|
848
|
-
components: mergeComponents(props.components, props.virtualized),
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* State calculated based on prop
|
|
852
|
-
*/
|
|
853
|
-
queries,
|
|
854
|
-
dataSource: pageData.dataSource,
|
|
855
|
-
flattenData: [],
|
|
856
|
-
expandedRowKeys: [...(props.expandedRowKeys || []), ...(props.defaultExpandedRowKeys || [])],
|
|
857
|
-
rowSelection: props.rowSelection ? _isObject(props.rowSelection) ? Object.assign({}, props.rowSelection) : {} : null,
|
|
858
|
-
pagination: pageData.pagination,
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* Internal state
|
|
862
|
-
*/
|
|
863
|
-
groups: null,
|
|
864
|
-
allRowKeys: [],
|
|
865
|
-
disabledRowKeys: [],
|
|
866
|
-
disabledRowKeysSet: new Set(),
|
|
867
|
-
allDisabledRowKeys: [],
|
|
868
|
-
allDisabledRowKeysSet: new Set(),
|
|
869
|
-
headWidths: [],
|
|
870
|
-
bodyHasScrollBar: false,
|
|
871
|
-
prePropRowSelection: undefined,
|
|
872
|
-
prePagination: undefined
|
|
873
|
-
};
|
|
874
|
-
this.rootWrapRef = /*#__PURE__*/createRef();
|
|
875
|
-
this.wrapRef = /*#__PURE__*/createRef(); // table's outside wrap
|
|
876
|
-
|
|
877
|
-
this.bodyWrapRef = /*#__PURE__*/createRef();
|
|
878
|
-
this.headerWrapRef = /*#__PURE__*/createRef();
|
|
879
|
-
this.store = new Store({
|
|
880
|
-
hoveredRowKey: null
|
|
881
|
-
});
|
|
882
|
-
this.debouncedWindowResize = _debounce(this.handleWindowResize, 150);
|
|
883
|
-
this.cachedFilteredSortedDataSource = [];
|
|
884
|
-
this.cachedFilteredSortedRowKeys = [];
|
|
885
|
-
this.cachedFilteredSortedRowKeysSet = new Set();
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
get adapter() {
|
|
889
|
-
var _this2 = this;
|
|
890
|
-
|
|
891
|
-
return Object.assign(Object.assign({}, super.adapter), {
|
|
892
|
-
resetScrollY: () => {
|
|
893
|
-
if (this.bodyWrapRef.current) {
|
|
894
|
-
this.bodyWrapRef.current.scrollTop = 0;
|
|
895
|
-
}
|
|
896
|
-
},
|
|
897
|
-
setSelectedRowKeys: selectedRowKeys => {
|
|
898
|
-
this.setState({
|
|
899
|
-
rowSelection: Object.assign(Object.assign({}, this.state.rowSelection), {
|
|
900
|
-
selectedRowKeys: [...selectedRowKeys],
|
|
901
|
-
selectedRowKeysSet: new Set(selectedRowKeys)
|
|
902
|
-
})
|
|
903
|
-
});
|
|
904
|
-
},
|
|
905
|
-
setDisabledRowKeys: disabledRowKeys => {
|
|
906
|
-
this.setState({
|
|
907
|
-
disabledRowKeys,
|
|
908
|
-
disabledRowKeysSet: new Set(disabledRowKeys)
|
|
909
|
-
});
|
|
910
|
-
},
|
|
911
|
-
setCurrentPage: currentPage => {
|
|
912
|
-
const {
|
|
913
|
-
pagination
|
|
914
|
-
} = this.state;
|
|
915
|
-
|
|
916
|
-
if (typeof pagination === 'object') {
|
|
917
|
-
this.setState({
|
|
918
|
-
pagination: Object.assign(Object.assign({}, pagination), {
|
|
919
|
-
currentPage
|
|
920
|
-
})
|
|
921
|
-
});
|
|
922
|
-
} else {
|
|
923
|
-
this.setState({
|
|
924
|
-
pagination: {
|
|
925
|
-
currentPage
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
},
|
|
930
|
-
setPagination: pagination => this.setState({
|
|
931
|
-
pagination
|
|
932
|
-
}),
|
|
933
|
-
setGroups: groups => this.setState({
|
|
934
|
-
groups
|
|
935
|
-
}),
|
|
936
|
-
setDataSource: dataSource => this.setState({
|
|
937
|
-
dataSource
|
|
938
|
-
}),
|
|
939
|
-
setExpandedRowKeys: expandedRowKeys => this.setState({
|
|
940
|
-
expandedRowKeys: [...expandedRowKeys]
|
|
941
|
-
}),
|
|
942
|
-
setQuery: function () {
|
|
943
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
944
|
-
let queries = [..._this2.state.queries];
|
|
945
|
-
queries = mergeQueries(query, queries);
|
|
946
|
-
|
|
947
|
-
_this2.setState({
|
|
948
|
-
queries
|
|
949
|
-
});
|
|
950
|
-
},
|
|
951
|
-
// Update queries when filtering or sorting
|
|
952
|
-
setQueries: queries => this.setState({
|
|
953
|
-
queries
|
|
954
|
-
}),
|
|
955
|
-
setFlattenData: flattenData => this.setState({
|
|
956
|
-
flattenData
|
|
957
|
-
}),
|
|
958
|
-
setAllRowKeys: allRowKeys => this.setState({
|
|
959
|
-
allRowKeys
|
|
960
|
-
}),
|
|
961
|
-
setHoveredRowKey: hoveredRowKey => {
|
|
962
|
-
this.store.setState({
|
|
963
|
-
hoveredRowKey
|
|
964
|
-
});
|
|
965
|
-
},
|
|
966
|
-
setCachedFilteredSortedDataSource: filteredSortedDataSource => {
|
|
967
|
-
this.cachedFilteredSortedDataSource = filteredSortedDataSource;
|
|
968
|
-
},
|
|
969
|
-
setCachedFilteredSortedRowKeys: filteredSortedRowKeys => {
|
|
970
|
-
this.cachedFilteredSortedRowKeys = filteredSortedRowKeys;
|
|
971
|
-
this.cachedFilteredSortedRowKeysSet = new Set(filteredSortedRowKeys);
|
|
972
|
-
},
|
|
973
|
-
setAllDisabledRowKeys: allDisabledRowKeys => {
|
|
974
|
-
const allDisabledRowKeysSet = new Set(allDisabledRowKeys);
|
|
975
|
-
this.setState({
|
|
976
|
-
allDisabledRowKeys,
|
|
977
|
-
allDisabledRowKeysSet
|
|
978
|
-
});
|
|
979
|
-
},
|
|
980
|
-
getCurrentPage: () => _get(this.state, 'pagination.currentPage', 1),
|
|
981
|
-
getCurrentPageSize: () => _get(this.state, 'pagination.pageSize', numbers.DEFAULT_PAGE_SIZE),
|
|
982
|
-
getCachedFilteredSortedDataSource: () => this.cachedFilteredSortedDataSource,
|
|
983
|
-
getCachedFilteredSortedRowKeys: () => this.cachedFilteredSortedRowKeys,
|
|
984
|
-
getCachedFilteredSortedRowKeysSet: () => this.cachedFilteredSortedRowKeysSet,
|
|
985
|
-
getAllDisabledRowKeys: () => this.state.allDisabledRowKeys,
|
|
986
|
-
getAllDisabledRowKeysSet: () => this.state.allDisabledRowKeysSet,
|
|
987
|
-
notifyFilterDropdownVisibleChange: (visible, dataIndex) => this._invokeColumnFn(dataIndex, 'onFilterDropdownVisibleChange', visible),
|
|
988
|
-
notifyChange: function () {
|
|
989
|
-
return _this2.props.onChange(...arguments);
|
|
990
|
-
},
|
|
991
|
-
notifyExpand: function () {
|
|
992
|
-
return _this2.props.onExpand(...arguments);
|
|
993
|
-
},
|
|
994
|
-
notifyExpandedRowsChange: function () {
|
|
995
|
-
return _this2.props.onExpandedRowsChange(...arguments);
|
|
996
|
-
},
|
|
997
|
-
notifySelect: function () {
|
|
998
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
999
|
-
args[_key3] = arguments[_key3];
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
return _this2._invokeRowSelection('onSelect', ...args);
|
|
1003
|
-
},
|
|
1004
|
-
notifySelectAll: function () {
|
|
1005
|
-
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1006
|
-
args[_key4] = arguments[_key4];
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
return _this2._invokeRowSelection('onSelectAll', ...args);
|
|
1010
|
-
},
|
|
1011
|
-
notifySelectInvert: function () {
|
|
1012
|
-
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
1013
|
-
args[_key5] = arguments[_key5];
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
return _this2._invokeRowSelection('onSelectInvert', ...args);
|
|
1017
|
-
},
|
|
1018
|
-
notifySelectionChange: function () {
|
|
1019
|
-
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1020
|
-
args[_key6] = arguments[_key6];
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
return _this2._invokeRowSelection('onChange', ...args);
|
|
1024
|
-
},
|
|
1025
|
-
isAnyColumnFixed: columns => _some(this.getColumns(columns || this.props.columns, this.props.children), column => Boolean(column.fixed)),
|
|
1026
|
-
useFixedHeader: () => {
|
|
1027
|
-
const {
|
|
1028
|
-
scroll,
|
|
1029
|
-
sticky
|
|
1030
|
-
} = this.props;
|
|
1031
|
-
|
|
1032
|
-
if (_get(scroll, 'y')) {
|
|
1033
|
-
return true;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
if (sticky) {
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
return false;
|
|
1041
|
-
},
|
|
1042
|
-
getTableLayout: () => {
|
|
1043
|
-
let isFixed = false;
|
|
1044
|
-
const {
|
|
1045
|
-
flattenColumns
|
|
1046
|
-
} = this.state;
|
|
1047
|
-
|
|
1048
|
-
if (Array.isArray(flattenColumns)) {
|
|
1049
|
-
isFixed = flattenColumns.some(column => Boolean(column.ellipsis) || Boolean(column.fixed));
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
return isFixed ? 'fixed' : 'auto';
|
|
1053
|
-
},
|
|
1054
|
-
setHeadWidths: function (headWidths) {
|
|
1055
|
-
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1056
|
-
|
|
1057
|
-
if (!equalWith(_this2.state.headWidths[index], headWidths)) {
|
|
1058
|
-
// The map call depends on the last state
|
|
1059
|
-
_this2.setState(state => {
|
|
1060
|
-
const newHeadWidths = [...state.headWidths];
|
|
1061
|
-
newHeadWidths[index] = [...headWidths];
|
|
1062
|
-
return {
|
|
1063
|
-
headWidths: newHeadWidths
|
|
1064
|
-
};
|
|
862
|
+
const childrenColumnName = 'children';
|
|
863
|
+
let columns = cloneDeep(cachedColumns);
|
|
864
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
865
|
+
const addFns = function () {
|
|
866
|
+
let columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
867
|
+
if (Array.isArray(columns) && columns.length) {
|
|
868
|
+
_each(columns, (column, index, originColumns) => {
|
|
869
|
+
const newColumn = _this2.addFnsInColumn(column);
|
|
870
|
+
const children = column[childrenColumnName];
|
|
871
|
+
if (Array.isArray(children) && children.length) {
|
|
872
|
+
const newChildren = [...children];
|
|
873
|
+
addFns(newChildren);
|
|
874
|
+
newColumn[childrenColumnName] = newChildren;
|
|
875
|
+
}
|
|
876
|
+
originColumns[index] = newColumn;
|
|
1065
877
|
});
|
|
1066
878
|
}
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
flattenedWidths = flattenedWidths == null && _this2.state.headWidths.length ? _flattenDeep(_this2.state.headWidths) : [];
|
|
1085
|
-
|
|
1086
|
-
if (Array.isArray(flattenedWidths) && flattenedWidths.length) {
|
|
1087
|
-
return flattenedColumns.reduce((result, column) => {
|
|
1088
|
-
const found = column.key === strings.DEFAULT_KEY_COLUMN_SCROLLBAR && ignoreScrollBarKey ? null : _find(flattenedWidths, item => item && item.key != null && item.key === column.key);
|
|
1089
|
-
|
|
1090
|
-
if (found) {
|
|
1091
|
-
result.push(found.width);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
return result;
|
|
1095
|
-
}, []);
|
|
879
|
+
};
|
|
880
|
+
addFns(columns);
|
|
881
|
+
// hideExpandedColumn=false render expand column separately
|
|
882
|
+
if (!hideExpandedColumn) {
|
|
883
|
+
const column = this.normalizeExpandColumn({
|
|
884
|
+
prefixCls,
|
|
885
|
+
expandCellFixed,
|
|
886
|
+
expandIcon
|
|
887
|
+
});
|
|
888
|
+
const destIndex = _findIndex(columns, item => item.key === strings.DEFAULT_KEY_COLUMN_EXPAND);
|
|
889
|
+
if (column) {
|
|
890
|
+
if (destIndex > -1) {
|
|
891
|
+
columns[destIndex] = Object.assign(Object.assign({}, column), columns[destIndex]);
|
|
892
|
+
} else if (column.fixed === 'right') {
|
|
893
|
+
columns = [...columns, column];
|
|
894
|
+
} else {
|
|
895
|
+
columns = [column, ...columns];
|
|
1096
896
|
}
|
|
1097
897
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
const {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
const hasChildren = Array.isArray(children) && children.length;
|
|
1113
|
-
const strictExpandableResult = hasRowExpandable && rowExpandable(record);
|
|
1114
|
-
const looseExpandableResult = !hasRowExpandable || strictExpandableResult;
|
|
1115
|
-
return (hasExpandedRowRender || hasChildren) && looseExpandableResult || !(hasExpandedRowRender || hasChildren) && strictExpandableResult;
|
|
1116
|
-
},
|
|
1117
|
-
isAnyColumnUseFullRender: columns => _some(columns, column => Boolean(column.useFullRender)),
|
|
1118
|
-
getNormalizeColumns: () => this.normalizeColumns,
|
|
1119
|
-
getHandleColumns: () => this.handleColumns,
|
|
1120
|
-
getMergePagination: () => this.mergePagination,
|
|
1121
|
-
setBodyHasScrollbar: bodyHasScrollBar => {
|
|
1122
|
-
if (bodyHasScrollBar !== this.state.bodyHasScrollBar) {
|
|
1123
|
-
this.setState({
|
|
1124
|
-
bodyHasScrollBar
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
stopPropagation(e) {
|
|
1130
|
-
// The event definition here is not very accurate for now, it belongs to a broad structure definition
|
|
1131
|
-
if (e && typeof e === 'object') {
|
|
1132
|
-
if (typeof e.stopPropagation === 'function') {
|
|
1133
|
-
e.stopPropagation();
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
if (e.nativeEvent && typeof e.nativeEvent.stopPropagation === 'function') {
|
|
1137
|
-
e.nativeEvent.stopPropagation();
|
|
1138
|
-
} else if (typeof e.stopImmediatePropagation === 'function') {
|
|
1139
|
-
e.stopImmediatePropagation();
|
|
1140
|
-
}
|
|
898
|
+
}
|
|
899
|
+
// selection column
|
|
900
|
+
if (rowSelection && !_get(rowSelection, 'hidden')) {
|
|
901
|
+
const destIndex = _findIndex(columns, item => item.key === strings.DEFAULT_KEY_COLUMN_SELECTION);
|
|
902
|
+
const column = this.normalizeSelectionColumn({
|
|
903
|
+
rowSelection,
|
|
904
|
+
prefixCls
|
|
905
|
+
});
|
|
906
|
+
if (destIndex > -1) {
|
|
907
|
+
columns[destIndex] = Object.assign(Object.assign({}, column), columns[destIndex]);
|
|
908
|
+
} else if (column.fixed === 'right') {
|
|
909
|
+
columns = [...columns, column];
|
|
910
|
+
} else {
|
|
911
|
+
columns = [column, ...columns];
|
|
1141
912
|
}
|
|
1142
913
|
}
|
|
1143
|
-
|
|
914
|
+
assignColumnKeys(columns);
|
|
915
|
+
return columns;
|
|
916
|
+
};
|
|
917
|
+
/**
|
|
918
|
+
* Convert children to columns object
|
|
919
|
+
* @param {Array} columns
|
|
920
|
+
* @param {ReactNode} children
|
|
921
|
+
* @returns {Array}
|
|
922
|
+
*/
|
|
923
|
+
this.normalizeColumns = (columns, children) => {
|
|
924
|
+
const normalColumns = cloneDeep(this.getColumns(columns, children));
|
|
925
|
+
return normalColumns;
|
|
926
|
+
};
|
|
927
|
+
/**
|
|
928
|
+
* Combine pagination and table paging processing functions
|
|
929
|
+
*/
|
|
930
|
+
this.mergePagination = pagination => {
|
|
931
|
+
const newPagination = Object.assign({
|
|
932
|
+
onChange: this.foundation.setPage
|
|
933
|
+
}, pagination);
|
|
934
|
+
return newPagination;
|
|
935
|
+
};
|
|
936
|
+
this.foundation = new TableFoundation(this.adapter);
|
|
937
|
+
// columns cannot be deepClone, otherwise the comparison will be false
|
|
938
|
+
const columns = this.getColumns(props.columns, props.children);
|
|
939
|
+
const cachedflattenColumns = flattenColumns(columns);
|
|
940
|
+
const queries = TableFoundation.initColumnsFilteredValueAndSorterOrder(cloneDeep(cachedflattenColumns));
|
|
941
|
+
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(this.props.dataSource, queries);
|
|
942
|
+
const newPagination = _isPlainObject(this.props.pagination) ? this.props.pagination : {};
|
|
943
|
+
const pageData = this.foundation.getCurrentPageData(filteredSortedDataSource, newPagination, queries);
|
|
944
|
+
this.state = {
|
|
945
|
+
/**
|
|
946
|
+
* Cached props
|
|
947
|
+
*/
|
|
948
|
+
cachedColumns: columns,
|
|
949
|
+
cachedChildren: props.children,
|
|
950
|
+
flattenColumns: cachedflattenColumns,
|
|
951
|
+
components: mergeComponents(props.components, props.virtualized),
|
|
952
|
+
/**
|
|
953
|
+
* State calculated based on prop
|
|
954
|
+
*/
|
|
955
|
+
queries,
|
|
956
|
+
dataSource: pageData.dataSource,
|
|
957
|
+
flattenData: [],
|
|
958
|
+
expandedRowKeys: [...(props.expandedRowKeys || []), ...(props.defaultExpandedRowKeys || [])],
|
|
959
|
+
rowSelection: props.rowSelection ? _isObject(props.rowSelection) ? Object.assign({}, props.rowSelection) : {} : null,
|
|
960
|
+
pagination: pageData.pagination,
|
|
961
|
+
/**
|
|
962
|
+
* Internal state
|
|
963
|
+
*/
|
|
964
|
+
groups: null,
|
|
965
|
+
allRowKeys: [],
|
|
966
|
+
disabledRowKeys: [],
|
|
967
|
+
disabledRowKeysSet: new Set(),
|
|
968
|
+
allDisabledRowKeys: [],
|
|
969
|
+
allDisabledRowKeysSet: new Set(),
|
|
970
|
+
headWidths: [],
|
|
971
|
+
bodyHasScrollBar: false,
|
|
972
|
+
prePropRowSelection: undefined,
|
|
973
|
+
prePagination: undefined
|
|
974
|
+
};
|
|
975
|
+
this.rootWrapRef = /*#__PURE__*/createRef();
|
|
976
|
+
this.wrapRef = /*#__PURE__*/createRef(); // table's outside wrap
|
|
977
|
+
this.bodyWrapRef = /*#__PURE__*/createRef();
|
|
978
|
+
this.headerWrapRef = /*#__PURE__*/createRef();
|
|
979
|
+
this.store = new Store({
|
|
980
|
+
hoveredRowKey: null
|
|
1144
981
|
});
|
|
982
|
+
this.debouncedWindowResize = _debounce(this.handleWindowResize, 150);
|
|
983
|
+
this.cachedFilteredSortedDataSource = [];
|
|
984
|
+
this.cachedFilteredSortedRowKeys = [];
|
|
985
|
+
this.cachedFilteredSortedRowKeysSet = new Set();
|
|
1145
986
|
}
|
|
1146
|
-
|
|
1147
987
|
static getDerivedStateFromProps(props, state) {
|
|
1148
988
|
const willUpdateStates = {};
|
|
1149
989
|
const {
|
|
@@ -1154,7 +994,6 @@ class Table extends BaseComponent {
|
|
|
1154
994
|
pagination
|
|
1155
995
|
} = props;
|
|
1156
996
|
props.columns && props.children && logger.warn('columns should not given by object and children at the same time');
|
|
1157
|
-
|
|
1158
997
|
if (props.columns && props.columns !== state.cachedColumns) {
|
|
1159
998
|
const newFlattenColumns = flattenColumns(props.columns);
|
|
1160
999
|
willUpdateStates.flattenColumns = newFlattenColumns;
|
|
@@ -1169,29 +1008,22 @@ class Table extends BaseComponent {
|
|
|
1169
1008
|
willUpdateStates.queries = [...columns];
|
|
1170
1009
|
willUpdateStates.cachedColumns = [...newNestedColumns];
|
|
1171
1010
|
willUpdateStates.cachedChildren = props.children;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
|
|
1011
|
+
}
|
|
1012
|
+
// Update controlled selection column
|
|
1175
1013
|
if (rowSelection !== state.prePropRowSelection) {
|
|
1176
1014
|
let newSelectionStates = {};
|
|
1177
|
-
|
|
1178
1015
|
if (_isObject(state.rowSelection)) {
|
|
1179
1016
|
newSelectionStates = Object.assign(Object.assign({}, newSelectionStates), state.rowSelection);
|
|
1180
1017
|
}
|
|
1181
|
-
|
|
1182
1018
|
if (_isObject(rowSelection)) {
|
|
1183
1019
|
newSelectionStates = Object.assign(Object.assign({}, newSelectionStates), rowSelection);
|
|
1184
1020
|
}
|
|
1185
|
-
|
|
1186
1021
|
const selectedRowKeys = _get(rowSelection, 'selectedRowKeys');
|
|
1187
|
-
|
|
1188
1022
|
const getCheckboxProps = _get(rowSelection, 'getCheckboxProps');
|
|
1189
|
-
|
|
1190
1023
|
if (selectedRowKeys && Array.isArray(selectedRowKeys)) {
|
|
1191
1024
|
newSelectionStates.selectedRowKeysSet = new Set(selectedRowKeys);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1025
|
+
}
|
|
1026
|
+
// The return value of getCheckboxProps affects the disabled rows
|
|
1195
1027
|
if (_isFunction(getCheckboxProps)) {
|
|
1196
1028
|
const disabledRowKeys = getAllDisabledRowKeys({
|
|
1197
1029
|
dataSource,
|
|
@@ -1205,40 +1037,31 @@ class Table extends BaseComponent {
|
|
|
1205
1037
|
willUpdateStates.allDisabledRowKeys = disabledRowKeys;
|
|
1206
1038
|
willUpdateStates.allDisabledRowKeysSet = disabledRowKeysSet;
|
|
1207
1039
|
}
|
|
1208
|
-
|
|
1209
1040
|
willUpdateStates.rowSelection = newSelectionStates;
|
|
1210
1041
|
willUpdateStates.prePropRowSelection = rowSelection;
|
|
1211
1042
|
}
|
|
1212
|
-
|
|
1213
1043
|
if (pagination !== state.prePagination) {
|
|
1214
1044
|
let newPagination = {};
|
|
1215
|
-
|
|
1216
1045
|
if (_isObject(state.pagination)) {
|
|
1217
1046
|
newPagination = Object.assign(Object.assign({}, newPagination), state.pagination);
|
|
1218
1047
|
}
|
|
1219
|
-
|
|
1220
1048
|
if (_isObject(pagination)) {
|
|
1221
1049
|
newPagination = Object.assign(Object.assign({}, newPagination), pagination);
|
|
1222
1050
|
}
|
|
1223
|
-
|
|
1224
1051
|
willUpdateStates.pagination = newPagination;
|
|
1225
1052
|
willUpdateStates.prePagination = pagination;
|
|
1226
1053
|
}
|
|
1227
|
-
|
|
1228
1054
|
return willUpdateStates;
|
|
1229
1055
|
}
|
|
1230
|
-
|
|
1231
1056
|
componentDidMount() {
|
|
1232
1057
|
super.componentDidMount();
|
|
1233
1058
|
this.setScrollPosition('left');
|
|
1234
|
-
|
|
1235
1059
|
if (this.adapter.isAnyColumnFixed() || this.props.showHeader && this.adapter.useFixedHeader()) {
|
|
1236
1060
|
this.handleWindowResize();
|
|
1237
1061
|
window.addEventListener('resize', this.debouncedWindowResize);
|
|
1238
1062
|
}
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1063
|
+
}
|
|
1064
|
+
// TODO: Extract the setState operation to the adapter or getDerivedStateFromProps function
|
|
1242
1065
|
componentDidUpdate(prevProps, prevState) {
|
|
1243
1066
|
const {
|
|
1244
1067
|
dataSource,
|
|
@@ -1266,30 +1089,24 @@ class Table extends BaseComponent {
|
|
|
1266
1089
|
* @param allRowKeys
|
|
1267
1090
|
* @param queries
|
|
1268
1091
|
*/
|
|
1269
|
-
|
|
1270
1092
|
const states = {};
|
|
1271
|
-
|
|
1272
1093
|
this._warnIfNoKey();
|
|
1273
1094
|
/**
|
|
1274
1095
|
* The state that needs to be updated after props changes
|
|
1275
1096
|
*/
|
|
1276
1097
|
// Update controlled expand column
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
1098
|
if (Array.isArray(expandedRowKeys) && expandedRowKeys !== prevProps.expandedRowKeys) {
|
|
1280
1099
|
this.setState({
|
|
1281
1100
|
expandedRowKeys
|
|
1282
1101
|
});
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1102
|
+
}
|
|
1103
|
+
// Update components
|
|
1286
1104
|
if (components !== prevProps.components || virtualized !== prevProps.virtualized) {
|
|
1287
1105
|
this.setState({
|
|
1288
1106
|
components: mergeComponents(components, virtualized)
|
|
1289
1107
|
});
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1108
|
+
}
|
|
1109
|
+
// Update the default expanded column
|
|
1293
1110
|
if (expandAllRows !== prevProps.expandAllRows || expandAllGroupRows !== prevProps.expandAllGroupRows) {
|
|
1294
1111
|
this.foundation.initExpandedRowKeys({
|
|
1295
1112
|
groups: stateGroups
|
|
@@ -1300,8 +1117,6 @@ class Table extends BaseComponent {
|
|
|
1300
1117
|
* 1. Cache filtered sorted data and a collection of data rows, stored in this
|
|
1301
1118
|
* 2. Update pager and group, stored in state
|
|
1302
1119
|
*/
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
1120
|
if (dataSource !== prevProps.dataSource || stateCachedColumns !== prevState.cachedColumns || stateCachedChildren !== prevState.cachedChildren) {
|
|
1306
1121
|
// TODO: foundation.getFilteredSortedDataSource has side effects and will be modified to the dataSource reference
|
|
1307
1122
|
// Temporarily use _dataSource=[...dataSource] for processing
|
|
@@ -1311,19 +1126,16 @@ class Table extends BaseComponent {
|
|
|
1311
1126
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
1312
1127
|
this.foundation.setAllDisabledRowKeys(allDataDisabledRowKeys);
|
|
1313
1128
|
states.dataSource = filteredSortedDataSource;
|
|
1314
|
-
|
|
1315
1129
|
if (this.props.groupBy) {
|
|
1316
1130
|
states.groups = null;
|
|
1317
1131
|
}
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
|
|
1132
|
+
}
|
|
1133
|
+
// when dataSource has change, should reset currentPage
|
|
1321
1134
|
if (dataSource !== prevProps.dataSource) {
|
|
1322
1135
|
states.pagination = _isObject(statePagination) ? Object.assign(Object.assign({}, statePagination), {
|
|
1323
1136
|
currentPage: _isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1324
1137
|
}) : statePagination;
|
|
1325
1138
|
}
|
|
1326
|
-
|
|
1327
1139
|
if (Object.keys(states).length) {
|
|
1328
1140
|
const {
|
|
1329
1141
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
@@ -1331,66 +1143,57 @@ class Table extends BaseComponent {
|
|
|
1331
1143
|
queries: stateQueries = null,
|
|
1332
1144
|
dataSource: stateDataSource = null
|
|
1333
1145
|
} = states;
|
|
1334
|
-
const handledProps = this.foundation.getCurrentPageData(stateDataSource, mergedStatePagination, stateQueries);
|
|
1335
|
-
|
|
1146
|
+
const handledProps = this.foundation.getCurrentPageData(stateDataSource, mergedStatePagination, stateQueries);
|
|
1147
|
+
// After the pager is updated, reset allRowKeys of the current page
|
|
1336
1148
|
this.adapter.setAllRowKeys(handledProps.allRowKeys);
|
|
1337
1149
|
this.adapter.setDisabledRowKeys(handledProps.disabledRowKeys);
|
|
1338
|
-
|
|
1339
1150
|
if ('dataSource' in states) {
|
|
1340
1151
|
if (this.props.defaultExpandAllRows && handledProps.groups && handledProps.groups.size || this.props.expandAllRows || this.props.expandAllGroupRows) {
|
|
1341
1152
|
this.foundation.initExpandedRowKeys(handledProps);
|
|
1342
1153
|
}
|
|
1343
|
-
|
|
1344
1154
|
states.pagination = handledProps.pagination;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1155
|
+
}
|
|
1156
|
+
// Centrally update paging related state
|
|
1348
1157
|
const statesKeys = Object.keys(states);
|
|
1349
|
-
|
|
1350
1158
|
for (const k of statesKeys) {
|
|
1351
1159
|
this.setState({
|
|
1352
1160
|
[k]: handledProps[k]
|
|
1353
1161
|
});
|
|
1354
1162
|
}
|
|
1355
1163
|
}
|
|
1356
|
-
|
|
1357
1164
|
if (this.adapter.isAnyColumnFixed() || this.props.showHeader && this.adapter.useFixedHeader()) {
|
|
1358
1165
|
if (!this.debouncedWindowResize) {
|
|
1359
1166
|
window.addEventListener('resize', this.debouncedWindowResize);
|
|
1360
1167
|
}
|
|
1361
1168
|
}
|
|
1362
1169
|
}
|
|
1363
|
-
|
|
1364
1170
|
componentWillUnmount() {
|
|
1365
1171
|
super.componentWillUnmount();
|
|
1366
|
-
|
|
1367
1172
|
if (this.debouncedWindowResize) {
|
|
1368
1173
|
window.removeEventListener('resize', this.debouncedWindowResize);
|
|
1369
1174
|
this.debouncedWindowResize.cancel();
|
|
1370
1175
|
this.debouncedWindowResize = null;
|
|
1371
1176
|
}
|
|
1372
1177
|
}
|
|
1373
|
-
|
|
1374
1178
|
render() {
|
|
1375
1179
|
let _a = this.props,
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1180
|
+
{
|
|
1181
|
+
scroll,
|
|
1182
|
+
prefixCls,
|
|
1183
|
+
className,
|
|
1184
|
+
style: wrapStyle = {},
|
|
1185
|
+
bordered,
|
|
1186
|
+
id,
|
|
1187
|
+
pagination: propPagination,
|
|
1188
|
+
virtualized,
|
|
1189
|
+
size,
|
|
1190
|
+
renderPagination: propRenderPagination,
|
|
1191
|
+
getVirtualizedListRef,
|
|
1192
|
+
loading,
|
|
1193
|
+
hideExpandedColumn,
|
|
1194
|
+
rowSelection: propRowSelection
|
|
1195
|
+
} = _a,
|
|
1196
|
+
rest = __rest(_a, ["scroll", "prefixCls", "className", "style", "bordered", "id", "pagination", "virtualized", "size", "renderPagination", "getVirtualizedListRef", "loading", "hideExpandedColumn", "rowSelection"]);
|
|
1394
1197
|
let {
|
|
1395
1198
|
rowSelection,
|
|
1396
1199
|
expandedRowKeys,
|
|
@@ -1420,15 +1223,14 @@ class Table extends BaseComponent {
|
|
|
1420
1223
|
* useFullRender需要传给用户selection ReactNode,因此需要每次selectedRowKeys变化时重新计算columns
|
|
1421
1224
|
* TODO: 未来可以将传给用户的selection改为函数类型,让用户执行函数获取selection title的实时状态
|
|
1422
1225
|
*/
|
|
1423
|
-
|
|
1424
1226
|
if (!this.adapter.isAnyColumnUseFullRender(queries)) {
|
|
1425
1227
|
const rowSelectionUpdate = propRowSelection && !_get(propRowSelection, 'hidden');
|
|
1426
|
-
columns = this.foundation.memoizedWithFnsColumns(queries, cachedColumns, rowSelectionUpdate, hideExpandedColumn,
|
|
1228
|
+
columns = this.foundation.memoizedWithFnsColumns(queries, cachedColumns, rowSelectionUpdate, hideExpandedColumn,
|
|
1229
|
+
// Update the columns after the body scrollbar changes to ensure that the head and body are aligned
|
|
1427
1230
|
bodyHasScrollBar);
|
|
1428
1231
|
} else {
|
|
1429
1232
|
columns = this.handleColumns(queries, cachedColumns);
|
|
1430
1233
|
}
|
|
1431
|
-
|
|
1432
1234
|
const filteredColumns = this.foundation.memoizedFilterColumns(columns);
|
|
1433
1235
|
const flattenFnsColumns = this.foundation.memoizedFlattenFnsColumns(columns);
|
|
1434
1236
|
const anyColumnFixed = this.adapter.isAnyColumnFixed(columns);
|
|
@@ -1444,7 +1246,6 @@ class Table extends BaseComponent {
|
|
|
1444
1246
|
// dataSource = pageData.dataSource;
|
|
1445
1247
|
// pagination = pageData.pagination;
|
|
1446
1248
|
// }
|
|
1447
|
-
|
|
1448
1249
|
const props = Object.assign(Object.assign(Object.assign({}, rest), this.state), {
|
|
1449
1250
|
// props not in rest
|
|
1450
1251
|
virtualized,
|
|
@@ -1464,17 +1265,13 @@ class Table extends BaseComponent {
|
|
|
1464
1265
|
renderExpandIcon: this.renderExpandIcon,
|
|
1465
1266
|
filteredColumns
|
|
1466
1267
|
});
|
|
1467
|
-
|
|
1468
1268
|
const x = _get(scroll, 'x');
|
|
1469
|
-
|
|
1470
1269
|
const y = _get(scroll, 'y');
|
|
1471
|
-
|
|
1472
1270
|
if (virtualized) {
|
|
1473
1271
|
if (typeof wrapStyle.width !== 'number') {
|
|
1474
1272
|
wrapStyle.width = x;
|
|
1475
1273
|
}
|
|
1476
1274
|
}
|
|
1477
|
-
|
|
1478
1275
|
const wrapCls = classnames({
|
|
1479
1276
|
[`${prefixCls}-${strings.SIZE_SMALL}`]: size === strings.SIZE_SMALL,
|
|
1480
1277
|
[`${prefixCls}-${strings.SIZE_MIDDLE}`]: size === strings.SIZE_MIDDLE,
|
|
@@ -1483,12 +1280,10 @@ class Table extends BaseComponent {
|
|
|
1483
1280
|
[`${prefixCls}-fixed-header`]: Boolean(y),
|
|
1484
1281
|
[`${prefixCls}-scroll-position-left`]: ['both', 'left'].includes(this.position),
|
|
1485
1282
|
[`${prefixCls}-scroll-position-right`]: ['both', 'right'].includes(this.position)
|
|
1486
|
-
});
|
|
1487
|
-
|
|
1283
|
+
});
|
|
1284
|
+
// pagination
|
|
1488
1285
|
const tablePagination = pagination && propPagination ? this.renderPagination(pagination, propRenderPagination) : null;
|
|
1489
|
-
|
|
1490
1286
|
const paginationPosition = _get(propPagination, 'position', 'bottom');
|
|
1491
|
-
|
|
1492
1287
|
const tableContextValue = Object.assign(Object.assign({}, this.context), {
|
|
1493
1288
|
headWidths,
|
|
1494
1289
|
tableWidth,
|
|
@@ -1529,9 +1324,7 @@ class Table extends BaseComponent {
|
|
|
1529
1324
|
key: 'pagination-bottom'
|
|
1530
1325
|
}, ['bottom', 'both'].includes(paginationPosition) ? tablePagination : null)))));
|
|
1531
1326
|
}
|
|
1532
|
-
|
|
1533
1327
|
}
|
|
1534
|
-
|
|
1535
1328
|
Table.contextType = TableContext;
|
|
1536
1329
|
Table.propTypes = {
|
|
1537
1330
|
className: PropTypes.string,
|
|
@@ -1583,8 +1376,8 @@ Table.propTypes = {
|
|
|
1583
1376
|
dropdownPrefixCls: PropTypes.string,
|
|
1584
1377
|
expandRowByClick: PropTypes.bool,
|
|
1585
1378
|
getVirtualizedListRef: PropTypes.func // TODO: future api
|
|
1586
|
-
|
|
1587
1379
|
};
|
|
1380
|
+
|
|
1588
1381
|
Table.defaultProps = {
|
|
1589
1382
|
// rowExpandable: stubTrue,
|
|
1590
1383
|
tableLayout: '',
|