feffery_antd_components 0.4.3-rc6 → 0.4.3
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/CONTRIBUTING.md +4 -4
- package/DESCRIPTION +1 -1
- package/LICENSE +21 -21
- package/MANIFEST.in +6 -6
- package/Project.toml +1 -1
- package/README-en_US.md +73 -73
- package/README.md +87 -87
- package/bug_fix.py +21 -36
- package/fac-logo.svg +151 -151
- package/feffery_antd_components/AntdAccordion.py +7 -7
- package/feffery_antd_components/AntdAffix.py +2 -2
- package/feffery_antd_components/AntdAlert.py +5 -5
- package/feffery_antd_components/AntdAnchor.py +5 -5
- package/feffery_antd_components/AntdAvatar.py +4 -4
- package/feffery_antd_components/AntdAvatarGroup.py +1 -1
- package/feffery_antd_components/AntdBackTop.py +4 -4
- package/feffery_antd_components/AntdBadge.py +5 -5
- package/feffery_antd_components/AntdBreadcrumb.py +4 -4
- package/feffery_antd_components/AntdButton.py +14 -14
- package/feffery_antd_components/AntdCalendar.py +4 -4
- package/feffery_antd_components/AntdCard.py +5 -5
- package/feffery_antd_components/AntdCardGrid.py +3 -3
- package/feffery_antd_components/AntdCardMeta.py +1 -1
- package/feffery_antd_components/AntdCarousel.py +13 -13
- package/feffery_antd_components/AntdCascader.py +16 -17
- package/feffery_antd_components/AntdCenter.py +3 -3
- package/feffery_antd_components/AntdCheckCard.py +7 -7
- package/feffery_antd_components/AntdCheckCardGroup.py +9 -9
- package/feffery_antd_components/AntdCheckableTag.py +2 -2
- package/feffery_antd_components/AntdCheckbox.py +8 -8
- package/feffery_antd_components/AntdCheckboxGroup.py +6 -6
- package/feffery_antd_components/AntdCol.py +5 -5
- package/feffery_antd_components/AntdCollapse.py +8 -8
- package/feffery_antd_components/AntdColorPicker.py +13 -13
- package/feffery_antd_components/AntdComment.py +7 -7
- package/feffery_antd_components/AntdCompact.py +3 -3
- package/feffery_antd_components/AntdConfigProvider.py +6 -6
- package/feffery_antd_components/AntdContent.py +1 -1
- package/feffery_antd_components/AntdCopyText.py +2 -2
- package/feffery_antd_components/AntdCountdown.py +1 -1
- package/feffery_antd_components/AntdCountup.py +1 -1
- package/feffery_antd_components/AntdCustomSkeleton.py +5 -5
- package/feffery_antd_components/AntdDatePicker.py +13 -13
- package/feffery_antd_components/AntdDateRangePicker.py +12 -12
- package/feffery_antd_components/AntdDescriptionItem.py +2 -2
- package/feffery_antd_components/AntdDescriptions.py +6 -6
- package/feffery_antd_components/AntdDivider.py +5 -5
- package/feffery_antd_components/AntdDraggerUpload.py +15 -15
- package/feffery_antd_components/AntdDrawer.py +12 -12
- package/feffery_antd_components/AntdDropdown.py +18 -18
- package/feffery_antd_components/AntdEmpty.py +2 -2
- package/feffery_antd_components/AntdFlex.py +6 -6
- package/feffery_antd_components/AntdFloatButton.py +5 -5
- package/feffery_antd_components/AntdFloatButtonGroup.py +3 -3
- package/feffery_antd_components/AntdFooter.py +1 -1
- package/feffery_antd_components/AntdForm.py +10 -6
- package/feffery_antd_components/AntdFormItem.py +4 -4
- package/feffery_antd_components/AntdFormRender.py +2 -2
- package/feffery_antd_components/AntdHappyProvider.py +2 -2
- package/feffery_antd_components/AntdHeader.py +1 -1
- package/feffery_antd_components/AntdIcon.py +3 -3
- package/feffery_antd_components/AntdImage.py +6 -6
- package/feffery_antd_components/AntdImageGroup.py +6 -6
- package/feffery_antd_components/AntdInput.py +17 -17
- package/feffery_antd_components/AntdInputNumber.py +12 -12
- package/feffery_antd_components/AntdLayout.py +1 -1
- package/feffery_antd_components/AntdMentions.py +9 -9
- package/feffery_antd_components/AntdMenu.py +9 -9
- package/feffery_antd_components/AntdMessage.py +3 -3
- package/feffery_antd_components/AntdModal.py +28 -28
- package/feffery_antd_components/AntdNotification.py +9 -9
- package/feffery_antd_components/AntdOTP.py +7 -7
- package/feffery_antd_components/AntdPageHeader.py +5 -5
- package/feffery_antd_components/AntdPagination.py +15 -15
- package/feffery_antd_components/AntdParagraph.py +2 -2
- package/feffery_antd_components/AntdPictureUpload.py +28 -28
- package/feffery_antd_components/AntdPopconfirm.py +21 -21
- package/feffery_antd_components/AntdPopover.py +9 -9
- package/feffery_antd_components/AntdPopupCard.py +9 -9
- package/feffery_antd_components/AntdProgress.py +9 -9
- package/feffery_antd_components/AntdQRCode.py +10 -10
- package/feffery_antd_components/AntdRadioGroup.py +9 -9
- package/feffery_antd_components/AntdRate.py +9 -9
- package/feffery_antd_components/AntdResult.py +1 -1
- package/feffery_antd_components/AntdRibbon.py +2 -2
- package/feffery_antd_components/AntdRow.py +3 -3
- package/feffery_antd_components/AntdSegmented.py +9 -9
- package/feffery_antd_components/AntdSegmentedColoring.py +11 -11
- package/feffery_antd_components/AntdSelect.py +19 -19
- package/feffery_antd_components/AntdSider.py +6 -6
- package/feffery_antd_components/AntdSkeleton.py +11 -11
- package/feffery_antd_components/AntdSkeletonAvatar.py +3 -3
- package/feffery_antd_components/AntdSkeletonButton.py +5 -5
- package/feffery_antd_components/AntdSkeletonImage.py +1 -1
- package/feffery_antd_components/AntdSkeletonInput.py +3 -3
- package/feffery_antd_components/AntdSlider.py +10 -10
- package/feffery_antd_components/AntdSpace.py +4 -4
- package/feffery_antd_components/AntdSpin.py +7 -8
- package/feffery_antd_components/AntdSplitter.py +5 -5
- package/feffery_antd_components/AntdSpoiler.py +5 -5
- package/feffery_antd_components/AntdStatistic.py +2 -2
- package/feffery_antd_components/AntdSteps.py +8 -8
- package/feffery_antd_components/AntdSwitch.py +8 -8
- package/feffery_antd_components/AntdTable.py +64 -63
- package/feffery_antd_components/AntdTabs.py +13 -14
- package/feffery_antd_components/AntdTag.py +4 -4
- package/feffery_antd_components/AntdText.py +2 -2
- package/feffery_antd_components/AntdTimePicker.py +16 -16
- package/feffery_antd_components/AntdTimeRangePicker.py +15 -15
- package/feffery_antd_components/AntdTimeline.py +2 -2
- package/feffery_antd_components/AntdTitle.py +2 -2
- package/feffery_antd_components/AntdTooltip.py +9 -9
- package/feffery_antd_components/AntdTour.py +9 -9
- package/feffery_antd_components/AntdTransfer.py +11 -11
- package/feffery_antd_components/AntdTree.py +17 -17
- package/feffery_antd_components/AntdTreeSelect.py +18 -18
- package/feffery_antd_components/AntdUpload.py +18 -18
- package/feffery_antd_components/AntdWatermark.py +6 -6
- package/feffery_antd_components/Fragment.py +1 -1
- package/feffery_antd_components/__init__.py +88 -88
- package/feffery_antd_components/_icons.py +559 -559
- package/feffery_antd_components/alias.py +222 -222
- package/feffery_antd_components/async-antd_table.js +2 -2
- package/feffery_antd_components/async-data_display.js +1 -1
- package/feffery_antd_components/async-data_entry.js +3 -3
- package/feffery_antd_components/async-upload.js +2 -2
- package/feffery_antd_components/feffery_antd_components.min.js +8 -8
- package/feffery_antd_components/metadata.json +1 -1
- package/feffery_antd_components/package-info.json +111 -96
- package/feffery_antd_components/utils.py +262 -262
- package/package.json +111 -96
- package/pytest.ini +5 -5
- package/release-to-test-pypi.sh +1 -1
- package/requirements.txt +2 -2
- package/review_checklist.md +47 -47
- package/ruff.toml +4 -4
- package/setup.py +33 -33
- package/src/jl/'feffery'_antdform.jl +2 -1
- package/src/jl/'feffery'_antdtable.jl +7 -6
- package/src/lib/components/dataDisplay/AntdAccordion.react.js +232 -232
- package/src/lib/components/dataDisplay/AntdAvatar.react.js +177 -177
- package/src/lib/components/dataDisplay/AntdAvatarGroup.react.js +133 -133
- package/src/lib/components/dataDisplay/AntdBadge.react.js +196 -196
- package/src/lib/components/dataDisplay/AntdCarousel.react.js +187 -187
- package/src/lib/components/dataDisplay/AntdCheckableTag.react.js +105 -105
- package/src/lib/components/dataDisplay/AntdCollapse.react.js +239 -239
- package/src/lib/components/dataDisplay/AntdComment.react.js +251 -251
- package/src/lib/components/dataDisplay/AntdCountdown.react.js +143 -143
- package/src/lib/components/dataDisplay/AntdCountup.react.js +133 -133
- package/src/lib/components/dataDisplay/AntdEmpty.react.js +162 -162
- package/src/lib/components/dataDisplay/AntdImage.react.js +202 -202
- package/src/lib/components/dataDisplay/AntdImageGroup.react.js +181 -181
- package/src/lib/components/dataDisplay/AntdPopover.react.js +220 -220
- package/src/lib/components/dataDisplay/AntdQRCode.react.js +191 -191
- package/src/lib/components/dataDisplay/AntdRibbon.react.js +105 -105
- package/src/lib/components/dataDisplay/AntdSegmented.react.js +234 -234
- package/src/lib/components/dataDisplay/AntdSpoiler.react.js +154 -154
- package/src/lib/components/dataDisplay/AntdStatistic.react.js +168 -168
- package/src/lib/components/dataDisplay/AntdTable.react.js +1859 -1858
- package/src/lib/components/dataDisplay/AntdTabs.react.js +352 -352
- package/src/lib/components/dataDisplay/AntdTag.react.js +135 -135
- package/src/lib/components/dataDisplay/AntdTimeline.react.js +136 -136
- package/src/lib/components/dataDisplay/AntdTooltip.react.js +230 -230
- package/src/lib/components/dataDisplay/AntdTree.react.js +641 -641
- package/src/lib/components/dataDisplay/card/AntdCard.react.js +249 -249
- package/src/lib/components/dataDisplay/card/AntdCardGrid.react.js +99 -99
- package/src/lib/components/dataDisplay/card/AntdCardMeta.react.js +97 -97
- package/src/lib/components/dataDisplay/descriptions/AntdDescriptionItem.react.js +130 -130
- package/src/lib/components/dataDisplay/descriptions/AntdDescriptions.react.js +237 -237
- package/src/lib/components/dataEntry/AntdCalendar.react.js +205 -205
- package/src/lib/components/dataEntry/AntdCascader.react.js +435 -435
- package/src/lib/components/dataEntry/AntdCheckbox.react.js +182 -182
- package/src/lib/components/dataEntry/AntdCheckboxGroup.react.js +193 -193
- package/src/lib/components/dataEntry/AntdColorPicker.react.js +240 -240
- package/src/lib/components/dataEntry/AntdDatePicker.react.js +432 -432
- package/src/lib/components/dataEntry/AntdDateRangePicker.react.js +439 -439
- package/src/lib/components/dataEntry/AntdInput.react.js +423 -423
- package/src/lib/components/dataEntry/AntdInputNumber.react.js +329 -329
- package/src/lib/components/dataEntry/AntdMentions.react.js +236 -236
- package/src/lib/components/dataEntry/AntdOTP.react.js +186 -186
- package/src/lib/components/dataEntry/AntdRadioGroup.react.js +241 -241
- package/src/lib/components/dataEntry/AntdRate.react.js +199 -199
- package/src/lib/components/dataEntry/AntdSegmentedColoring.react.js +251 -251
- package/src/lib/components/dataEntry/AntdSelect.react.js +492 -492
- package/src/lib/components/dataEntry/AntdSlider.react.js +325 -325
- package/src/lib/components/dataEntry/AntdSwitch.react.js +210 -210
- package/src/lib/components/dataEntry/AntdTimePicker.react.js +344 -344
- package/src/lib/components/dataEntry/AntdTimeRangePicker.react.js +325 -325
- package/src/lib/components/dataEntry/AntdTransfer.react.js +317 -317
- package/src/lib/components/dataEntry/AntdTreeSelect.react.js +573 -573
- package/src/lib/components/dataEntry/check-card/AntdCheckCard.react.js +186 -186
- package/src/lib/components/dataEntry/check-card/AntdCheckCardGroup.react.js +214 -214
- package/src/lib/components/dataEntry/form/AntdForm.react.js +201 -194
- package/src/lib/components/dataEntry/form/AntdFormItem.react.js +210 -210
- package/src/lib/components/dataEntry/upload/AntdDraggerUpload.react.js +504 -504
- package/src/lib/components/dataEntry/upload/AntdPictureUpload.react.js +530 -530
- package/src/lib/components/dataEntry/upload/AntdUpload.react.js +537 -537
- package/src/lib/components/feedback/AntdAlert.react.js +185 -185
- package/src/lib/components/feedback/AntdDrawer.react.js +306 -306
- package/src/lib/components/feedback/AntdMessage.react.js +143 -143
- package/src/lib/components/feedback/AntdModal.react.js +530 -530
- package/src/lib/components/feedback/AntdNotification.react.js +211 -211
- package/src/lib/components/feedback/AntdPopconfirm.react.js +433 -433
- package/src/lib/components/feedback/AntdPopupCard.react.js +362 -362
- package/src/lib/components/feedback/AntdProgress.react.js +300 -300
- package/src/lib/components/feedback/AntdResult.react.js +125 -125
- package/src/lib/components/feedback/AntdSpin.react.js +273 -273
- package/src/lib/components/feedback/skeleton/AntdCustomSkeleton.react.js +197 -197
- package/src/lib/components/feedback/skeleton/AntdSkeleton.react.js +291 -291
- package/src/lib/components/feedback/skeleton/AntdSkeletonAvatar.react.js +109 -109
- package/src/lib/components/feedback/skeleton/AntdSkeletonButton.react.js +114 -114
- package/src/lib/components/feedback/skeleton/AntdSkeletonImage.react.js +82 -82
- package/src/lib/components/feedback/skeleton/AntdSkeletonInput.react.js +98 -98
- package/src/lib/components/formRender/AntdFormRender.react.js +945 -945
- package/src/lib/components/general/AntdButton.react.js +328 -328
- package/src/lib/components/general/AntdFloatButton.react.js +157 -157
- package/src/lib/components/general/AntdFloatButtonGroup.react.js +162 -162
- package/src/lib/components/general/AntdIcon.react.js +176 -176
- package/src/lib/components/general/typography/AntdParagraph.react.js +202 -202
- package/src/lib/components/general/typography/AntdText.react.js +194 -194
- package/src/lib/components/general/typography/AntdTitle.react.js +186 -186
- package/src/lib/components/icons.react.js +1136 -1136
- package/src/lib/components/layout/AntdCenter.react.js +122 -122
- package/src/lib/components/layout/AntdCompact.react.js +108 -108
- package/src/lib/components/layout/AntdContent.react.js +92 -92
- package/src/lib/components/layout/AntdDivider.react.js +219 -219
- package/src/lib/components/layout/AntdFlex.react.js +143 -143
- package/src/lib/components/layout/AntdFooter.react.js +92 -92
- package/src/lib/components/layout/AntdHeader.react.js +92 -92
- package/src/lib/components/layout/AntdLayout.react.js +90 -90
- package/src/lib/components/layout/AntdSider.react.js +162 -162
- package/src/lib/components/layout/AntdSpace.react.js +213 -213
- package/src/lib/components/layout/AntdSplitter.react.js +173 -173
- package/src/lib/components/layout/grid/AntdCol.react.js +349 -349
- package/src/lib/components/layout/grid/AntdRow.react.js +152 -152
- package/src/lib/components/locales.react.js +197 -197
- package/src/lib/components/navigation/AntdAnchor.react.js +208 -208
- package/src/lib/components/navigation/AntdBreadcrumb.react.js +270 -270
- package/src/lib/components/navigation/AntdDropdown.react.js +469 -469
- package/src/lib/components/navigation/AntdMenu.react.js +573 -649
- package/src/lib/components/navigation/AntdPageHeader.react.js +139 -139
- package/src/lib/components/navigation/AntdPagination.react.js +303 -303
- package/src/lib/components/navigation/AntdSteps.react.js +199 -199
- package/src/lib/components/other/AntdAffix.react.js +120 -120
- package/src/lib/components/other/AntdBackTop.react.js +128 -128
- package/src/lib/components/other/AntdConfigProvider.react.js +246 -246
- package/src/lib/components/other/AntdCopyText.react.js +138 -138
- package/src/lib/components/other/AntdHappyProvider.react.js +50 -50
- package/src/lib/components/other/AntdTour.react.js +277 -277
- package/src/lib/components/other/AntdWatermark.react.js +179 -179
- package/src/lib/components/other/Fragment.react.js +50 -50
- package/src/lib/components/styles.css +513 -513
- package/src/lib/components/utils.js +51 -51
- package/src/lib/contexts/FormContext.js +4 -4
- package/src/lib/contexts/FormItemContext.js +4 -4
- package/src/lib/contexts/PropsContext.js +4 -4
- package/src/lib/fragments/AntdTable.react.js +2215 -2200
- package/src/lib/fragments/dataDisplay/AntdAccordion.react.js +101 -101
- package/src/lib/fragments/dataDisplay/AntdAvatar.react.js +127 -127
- package/src/lib/fragments/dataDisplay/AntdAvatarGroup.react.js +51 -51
- package/src/lib/fragments/dataDisplay/AntdBadge.react.js +73 -73
- package/src/lib/fragments/dataDisplay/AntdCarousel.react.js +71 -71
- package/src/lib/fragments/dataDisplay/AntdCheckableTag.react.js +57 -57
- package/src/lib/fragments/dataDisplay/AntdComment.react.js +178 -178
- package/src/lib/fragments/dataDisplay/AntdCountdown.react.js +83 -83
- package/src/lib/fragments/dataDisplay/AntdCountup.react.js +70 -70
- package/src/lib/fragments/dataDisplay/AntdEmpty.react.js +71 -71
- package/src/lib/fragments/dataDisplay/AntdImage.react.js +206 -206
- package/src/lib/fragments/dataDisplay/AntdImageGroup.react.js +91 -91
- package/src/lib/fragments/dataDisplay/AntdPopover.react.js +106 -106
- package/src/lib/fragments/dataDisplay/AntdQRCode.react.js +93 -93
- package/src/lib/fragments/dataDisplay/AntdRibbon.react.js +53 -53
- package/src/lib/fragments/dataDisplay/AntdSegmented.react.js +129 -129
- package/src/lib/fragments/dataDisplay/AntdSpoiler.react.js +96 -96
- package/src/lib/fragments/dataDisplay/AntdTabs.react.js +211 -211
- package/src/lib/fragments/dataDisplay/AntdTag.react.js +66 -66
- package/src/lib/fragments/dataDisplay/AntdTimeline.react.js +67 -67
- package/src/lib/fragments/dataDisplay/AntdTooltip.react.js +98 -98
- package/src/lib/fragments/dataDisplay/AntdTree.react.js +581 -581
- package/src/lib/fragments/dataDisplay/card/AntdCard.react.js +104 -104
- package/src/lib/fragments/dataDisplay/card/AntdCardGrid.react.js +54 -54
- package/src/lib/fragments/dataDisplay/card/AntdCardMeta.react.js +54 -54
- package/src/lib/fragments/dataDisplay/descriptions/AntdDescriptionItem.react.js +56 -56
- package/src/lib/fragments/dataDisplay/descriptions/AntdDescriptions.react.js +139 -139
- package/src/lib/fragments/dataEntry/AntdCalendar.react.js +178 -178
- package/src/lib/fragments/dataEntry/AntdCascader.react.js +319 -319
- package/src/lib/fragments/dataEntry/AntdCheckbox.react.js +119 -119
- package/src/lib/fragments/dataEntry/AntdCheckboxGroup.react.js +122 -122
- package/src/lib/fragments/dataEntry/AntdColorPicker.react.js +244 -244
- package/src/lib/fragments/dataEntry/AntdDatePicker.react.js +586 -586
- package/src/lib/fragments/dataEntry/AntdDateRangePicker.react.js +628 -628
- package/src/lib/fragments/dataEntry/AntdInput.react.js +450 -450
- package/src/lib/fragments/dataEntry/AntdInputNumber.react.js +194 -194
- package/src/lib/fragments/dataEntry/AntdMentions.react.js +180 -180
- package/src/lib/fragments/dataEntry/AntdOTP.react.js +127 -127
- package/src/lib/fragments/dataEntry/AntdRadioGroup.react.js +203 -203
- package/src/lib/fragments/dataEntry/AntdRate.react.js +131 -131
- package/src/lib/fragments/dataEntry/AntdSegmentedColoring.react.js +246 -246
- package/src/lib/fragments/dataEntry/AntdSelect.react.js +373 -373
- package/src/lib/fragments/dataEntry/AntdSlider.react.js +177 -177
- package/src/lib/fragments/dataEntry/AntdSwitch.react.js +132 -132
- package/src/lib/fragments/dataEntry/AntdTimePicker.react.js +191 -191
- package/src/lib/fragments/dataEntry/AntdTimeRangePicker.react.js +213 -213
- package/src/lib/fragments/dataEntry/AntdTransfer.react.js +183 -183
- package/src/lib/fragments/dataEntry/AntdTreeSelect.react.js +355 -355
- package/src/lib/fragments/dataEntry/check-card/AntdCheckCard.react.js +111 -111
- package/src/lib/fragments/dataEntry/check-card/AntdCheckCardGroup.react.js +122 -122
- package/src/lib/fragments/dataEntry/form/AntdForm.react.js +126 -120
- package/src/lib/fragments/dataEntry/form/AntdFormItem.react.js +85 -84
- package/src/lib/fragments/formRender/AntdFormRender.react.js +179 -179
- package/src/lib/fragments/upload/AntdDraggerUpload.react.js +622 -622
- package/src/lib/fragments/upload/AntdPictureUpload.react.js +577 -577
- package/src/lib/fragments/upload/AntdUpload.react.js +613 -613
- package/src/lib/hooks/useCss.js +28 -28
- package/src/lib/hooks/useStickyOffset.js +115 -115
- package/src/lib/index.js +240 -240
- package/src/lib/internal_components/UtilsLink.react.js +82 -0
- package/src/lib/store/formStore.js +54 -47
- package/tests/dash3.0tests/AntdQRCode/347/273/204/344/273/266loading/347/212/266/346/200/201/351/207/215/346/236/204/test.py +51 -51
- package/tests/dash3.0tests/AntdTable/345/207/275/346/225/260/345/274/217/346/224/271/351/200/240/test.py +62 -62
- package/tests/dash3.0tests/_dashprivate_layout/346/224/271/345/212/250/346/265/213/350/257/225/test.py +50 -50
- package/tests/dash3.0tests/loading_state/346/224/271/345/212/250/346/265/213/350/257/225/test.py +38 -38
- package/tests/dash3.0tests//345/207/275/346/225/260/345/274/217/347/273/204/344/273/266/351/273/230/350/256/244/345/200/274/351/207/215/346/236/204/test.py +30 -30
- package/tests/dash3.0tests//345/212/240/350/275/275/345/212/250/347/224/273/347/261/273/347/273/204/344/273/266/351/207/215/346/236/204/346/265/213/350/257/225/test.py +62 -62
- package/tests/dash3.0tests//347/273/204/344/273/266/345/261/236/346/200/247/345/237/272/347/241/200/346/214/201/344/271/205/345/214/226/351/207/215/346/236/204/346/265/213/350/257/225/test.py +25 -25
- package/tests/dataDisplay/AntdAccordion/feat_size.py +36 -36
- package/tests/dataDisplay/AntdAccordion/feat_styles.py +35 -35
- package/tests/dataDisplay/AntdCard/refactor_delete_props.py +83 -83
- package/tests/dataDisplay/AntdCarousel/feat_auto_play_dot_duration.py +34 -34
- package/tests/dataDisplay/AntdCollapse/feat_size.py +30 -30
- package/tests/dataDisplay/AntdCollapse/feat_styles.py +29 -29
- package/tests/dataDisplay/AntdCountdown/feat_finish_event.py +41 -41
- package/tests/dataDisplay/AntdCountdown/refactor_to_timer.py +57 -57
- package/tests/dataDisplay/AntdCountup/refactor_to_timer.py +57 -57
- package/tests/dataDisplay/AntdDescriptions/feat_span_filled.py +42 -42
- package/tests/dataDisplay/AntdImage/debug_preview_toolbar.py +23 -23
- package/tests/dataDisplay/AntdSegmented/feat_shape.py +39 -39
- package/tests/dataDisplay/AntdSegmented/feat_simple_options.py +43 -43
- package/tests/dataDisplay/AntdSegmented/feat_vertical.py +32 -32
- package/tests/dataDisplay/AntdTable/feat_button_mode_like_dcc_link.py +125 -0
- package/tests/dataDisplay/AntdTable/feat_button_mode_refactor.py +143 -143
- package/tests/dataDisplay/AntdTable/feat_button_mode_tooltip.py +47 -47
- package/tests/dataDisplay/AntdTable/feat_columns_fixed_bool.py +40 -40
- package/tests/dataDisplay/AntdTable/feat_columns_min_width.py +51 -51
- package/tests/dataDisplay/AntdTable/feat_columns_sort_order.py +131 -131
- package/tests/dataDisplay/AntdTable/feat_editable_disabled_keys.py +71 -71
- package/tests/dataDisplay/AntdTable/feat_header_align.py +38 -38
- package/tests/dataDisplay/AntdTable/feat_link_mode_like_dcc_link.py +49 -0
- package/tests/dataDisplay/AntdTable/feat_loading.py +76 -76
- package/tests/dataDisplay/AntdTable/feat_mini_chart_color.py +139 -139
- package/tests/dataDisplay/AntdTable/feat_row_class_name.py +39 -39
- package/tests/dataDisplay/AntdTable/feat_row_class_name_func.py +41 -41
- package/tests/dataDisplay/AntdTable/feat_select_mode_show_search.py +70 -70
- package/tests/dataDisplay/AntdTable/feat_sticky_header.py +81 -81
- package/tests/dataDisplay/AntdTable/feat_table_scroll.py +54 -54
- package/tests/dataDisplay/AntdTable/feat_tag_mode_tooltip.py +88 -88
- package/tests/dataDisplay/AntdTable/feat_title_popover_nodes.py +94 -79
- package/tests/dataDisplay/AntdTable/fix_context_locale.py +37 -37
- package/tests/dataDisplay/AntdTable/fix_field_bool.py +50 -50
- package/tests/dataDisplay/AntdTable/fix_nested_editable.py +115 -115
- package/tests/dataDisplay/AntdTable/fix_select_with_editable.py +84 -84
- package/tests/dataDisplay/AntdTable/fix_server_side_mode_filter_search.py +194 -194
- package/tests/dataDisplay/AntdTable/fix_summary.py +474 -474
- package/tests/dataDisplay/AntdTable/fix_summary_multi_level_header.py +85 -85
- package/tests/dataDisplay/AntdTable/fix_zero_value_filter.py +34 -34
- package/tests/dataDisplay/AntdTable/perf_button_mode_auto_wrap.py +39 -39
- package/tests/dataDisplay/AntdTable/perf_editable_column_format_constrait_message.py +65 -65
- package/tests/dataDisplay/AntdTable/refactor_mini_progress_mode.py +134 -134
- package/tests/dataDisplay/AntdTable/rollback_title_popover_info.py +46 -0
- package/tests/dataDisplay/AntdTabs/feat_item_icon.py +39 -39
- package/tests/dataDisplay/AntdTabs/feat_placeholder.py +124 -124
- package/tests/dataDisplay/AntdTabs/feat_tab_bar_style.py +40 -40
- package/tests/dataDisplay/AntdTree/feat_async_data_load.py +71 -71
- package/tests/dataDisplay/descriptions/AntdDescriptions/feat_extra.py +83 -83
- package/tests/dataEntry/AntdCalendar/feat_custom_cells.py +52 -52
- package/tests/dataEntry/AntdCascader/feat_prefix.py +62 -62
- package/tests/dataEntry/AntdCascader/feat_suffix_icon.py +62 -62
- package/tests/dataEntry/AntdCascader/fix_read_only.py +74 -74
- package/tests/dataEntry/AntdDatePicker/feat_custom_cells.py +79 -79
- package/tests/dataEntry/AntdDatePicker/feat_picker_value.py +38 -38
- package/tests/dataEntry/AntdDatePicker/feat_prefix.py +21 -21
- package/tests/dataEntry/AntdDatePicker/feat_suffix_icon.py +21 -21
- package/tests/dataEntry/AntdDateRangePicker/feat_custom_cells.py +79 -79
- package/tests/dataEntry/AntdDateRangePicker/feat_picker_value.py +38 -38
- package/tests/dataEntry/AntdDateRangePicker/feat_prefix.py +21 -21
- package/tests/dataEntry/AntdDateRangePicker/feat_suffix_icon.py +21 -21
- package/tests/dataEntry/AntdForm/feat_batch_control_tooltips.py +35 -0
- package/tests/dataEntry/AntdForm/feat_optional_batch_control.py +62 -62
- package/tests/dataEntry/AntdForm/fix_checkbox.py +65 -65
- package/tests/dataEntry/AntdRadioGroup/feat_block.py +40 -40
- package/tests/dataEntry/AntdSelect/feat_locale_ru.py +24 -24
- package/tests/dataEntry/AntdSelect/feat_max_count.py +28 -28
- package/tests/dataEntry/AntdSelect/feat_prefix.py +26 -26
- package/tests/dataEntry/AntdSelect/feat_show_search.py +32 -32
- package/tests/dataEntry/AntdSelect/feat_suffix_icon.py +46 -46
- package/tests/dataEntry/AntdSelect/fix_read_only.py +50 -50
- package/tests/dataEntry/AntdSelect/fix_read_only_with_allow_clear.py +29 -29
- package/tests/dataEntry/AntdSlider/feat_range_editable.py +49 -49
- package/tests/dataEntry/AntdTimePicker/feat_prefix.py +21 -21
- package/tests/dataEntry/AntdTimePicker/feat_suffix_icon.py +21 -21
- package/tests/dataEntry/AntdTimeRangePicker/feat_prefix.py +21 -21
- package/tests/dataEntry/AntdTimeRangePicker/feat_suffix_icon.py +21 -21
- package/tests/dataEntry/AntdTreeSelect/feat_async_data_load.py +69 -69
- package/tests/dataEntry/AntdTreeSelect/feat_max_count.py +71 -71
- package/tests/dataEntry/AntdTreeSelect/feat_prefix.py +43 -43
- package/tests/dataEntry/AntdTreeSelect/fix_read_only.py +50 -50
- package/tests/dataEntry/AntdUpload/feat_pastable.py +22 -22
- package/tests/dataEntry/AntdUpload/fix_follow_theme.py +28 -28
- package/tests/feat_variant_underlined.py +100 -100
- package/tests/feedback/AntdAlert/feat_icon.py +35 -35
- package/tests/feedback/AntdMessage/fix_follow_config_provider.py +44 -44
- package/tests/feedback/AntdModal/feat_force_render.py +57 -57
- package/tests/feedback/AntdModal/feat_loading_title.py +92 -92
- package/tests/feedback/AntdModal/feat_prevent_close.py +54 -54
- package/tests/feedback/AntdModal/feat_responsive_width.py +31 -31
- package/tests/feedback/AntdNotification/feat_component_content.py +64 -64
- package/tests/feedback/AntdNotification/feat_number_of_stack.py +40 -40
- package/tests/feedback/AntdNotification/feat_show_progress.py +40 -40
- package/tests/feedback/AntdNotification/fix_follow_config_provider.py +46 -46
- package/tests/feedback/AntdPopupCard/feat_force_render.py +61 -61
- package/tests/feedback/AntdProgress/feat_percent_position.py +39 -39
- package/tests/feedback/AntdProgress/perf_size.py +26 -26
- package/tests/feedback/AntdProgress/perf_steps.py +37 -37
- package/tests/feedback/AntdProgress/perf_stroke_color.py +58 -58
- package/tests/feedback/AntdResult/feat_extra.py +26 -26
- package/tests/feedback/AntdSkeleton/fix_dash3.py +43 -43
- package/tests/general/AntdButton/feat_color_and_variant.py +40 -40
- package/tests/general/AntdButton/feat_preset_color.py +46 -46
- package/tests/general/AntdFloatButtonGroup/feat_placement.py +83 -83
- package/tests/general/AntdFloatButtonGroup/feat_tooltip.py +34 -34
- package/tests/general/AntdIcon/feat_iconfont.py +41 -41
- package/tests/layout/AntdCenter/feat_use_token.py +41 -41
- package/tests/layout/AntdDivider/feat_plain.py +21 -21
- package/tests/layout/AntdDivider/feat_size.py +36 -36
- package/tests/layout/AntdSplitter/feat_AntdSplitter.py +210 -210
- package/tests/layout/AntdSplitter/feat_lazy.py +56 -56
- package/tests/layout/AntdSplitter/refactor.py +303 -303
- package/tests/navigation/AntdAnchor/feat_current_anchor.py +43 -43
- package/tests/navigation/AntdAnchor/feat_direction.py +43 -43
- package/tests/navigation/AntdAnchor/feat_replace.py +43 -43
- package/tests/navigation/AntdBreadcrumb/feat_menu_item_event.py +64 -64
- package/tests/navigation/AntdBreadcrumb/refactor_items.py +140 -140
- package/tests/navigation/AntdDropdown/feat_extra.py +29 -29
- package/tests/navigation/AntdMenu/feat_currentItem.py +85 -85
- package/tests/navigation/AntdMenu/feat_currentItemPath.py +85 -85
- package/tests/navigation/AntdMenu/feat_currentKeyPath.py +85 -85
- package/tests/navigation/AntdMenu/feat_custom_icon.py +57 -57
- package/tests/navigation/AntdMenu/feat_expandIcon.py +70 -70
- package/tests/navigation/AntdMenu/feat_triggerSubMenuAction.py +67 -67
- package/tests/navigation/AntdMenu/fix_onlyExpandCurrentSubMenu.py +57 -57
- package/tests/navigation/AntdMenu/fix_with_sider.py +71 -71
- package/tests/navigation/AntdPagination/feat_align.py +31 -31
- package/tests/other/AntdAffix/feat_listen_affixed.py +41 -41
- package/tests/other/AntdBackTop/refactor.py +18 -18
- package/tests/other/AntdConfigProvider/feat_use_css.py +67 -67
- package/tests/other/AntdCopyText/feat_copy_table.py +67 -67
- package/tests/other/AntdCopyText/feat_tooltips.py +61 -61
- package/tests/other/AntdHappyProvider/feat_component.py +60 -60
- package/tests/other/Fragment/feat_use_token.py +32 -32
- package/usage.py +34 -34
- package/webpack.config.js +181 -181
- package/webpack.serve.config.js +12 -12
|
@@ -1,262 +1,262 @@
|
|
|
1
|
-
import dash
|
|
2
|
-
import warnings
|
|
3
|
-
import importlib
|
|
4
|
-
from collections import defaultdict
|
|
5
|
-
import feffery_antd_components as fac
|
|
6
|
-
from typing import Union, Literal, Any, List, Callable, Dict
|
|
7
|
-
|
|
8
|
-
try:
|
|
9
|
-
import pandas as pd
|
|
10
|
-
except ImportError:
|
|
11
|
-
warning_message = (
|
|
12
|
-
'检测到您的环境中未安装\033[93mpandas\033[0m,'
|
|
13
|
-
'部分工具函数如\033[93mdf2table\033[0m将无法正常使用,'
|
|
14
|
-
'如有需要请使用pip或conda安装pandas。'
|
|
15
|
-
'\n\nDetected that \033[93mpandas\033[0m is not installed in your environment. '
|
|
16
|
-
'Some utility functions, such as \033[93mdf2table\033[0m, will not function properly. '
|
|
17
|
-
'If necessary, please install pandas using pip or conda.'
|
|
18
|
-
)
|
|
19
|
-
warnings.warn(warning_message, UserWarning)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__all__ = ['fill_output_dict', 'df2table']
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def fill_output_dict(
|
|
26
|
-
output_dict: dict, fill_value: Any = dash.no_update
|
|
27
|
-
) -> dict:
|
|
28
|
-
"""用于配合回调函数中Output角色的字典化写法,在已有明确字典返回值的基础上,为其他返回项进行默认值填充
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
output_dict (dict): 已有明确返回值字典
|
|
32
|
-
fill_value (Any): 设置其余无明确返回值的Output角色键值对统一填充值,默认为dash.no_update
|
|
33
|
-
|
|
34
|
-
Returns:
|
|
35
|
-
dict: 处理后可以直接通过回调返回的完整Output结果字典
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
# 构造辅助用defaultdict
|
|
39
|
-
output = defaultdict(lambda: fill_value, output_dict)
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
key: output[key]
|
|
43
|
-
# 通过上下文遍历所有Output字典键名
|
|
44
|
-
for key in dash.ctx.outputs_grouping.keys()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
def df2table(
|
|
49
|
-
raw_df: Any,
|
|
50
|
-
id: str = None, # 设置对应AntdTable组件的id
|
|
51
|
-
columns_alias: dict = None, # 为指定字段定义充当title的别名
|
|
52
|
-
# 为指定字段设置对应AntdTable原columns.*.renderOptions配置参数
|
|
53
|
-
columns_render_options: dict = None,
|
|
54
|
-
# 样式相关参数
|
|
55
|
-
# 列宽分配策略,可选的有'auto'、'fmit-title'、'equal'
|
|
56
|
-
column_width_mode: Literal[
|
|
57
|
-
'auto', 'fit-title', 'equal'
|
|
58
|
-
] = 'auto',
|
|
59
|
-
column_width_sum: str = '100%', # 用于定义各列宽之和,常用的有'100%'、'1000px'等符合css中宽度规则的值
|
|
60
|
-
left_fixed_columns: List[
|
|
61
|
-
str
|
|
62
|
-
] = None, # 定义需要在左侧固定的列名数组
|
|
63
|
-
right_fixed_columns: List[
|
|
64
|
-
str
|
|
65
|
-
] = None, # 定义需要在右侧固定的列名数组
|
|
66
|
-
# 字段排序功能相关参数
|
|
67
|
-
numeric_auto_sort: bool = True, # 是否针对数据框中的数值型字段自动添加排序功能
|
|
68
|
-
# 针对字段排序配置组合排序相关参数,同AntdTable的sortOptions.multiple
|
|
69
|
-
sort_multiple: Union[bool, Literal['auto']] = False,
|
|
70
|
-
# 字段筛选功能相关参数
|
|
71
|
-
str_auto_filter: bool = True, # 是否针对数据框中的字符型字段自动添加筛选功能
|
|
72
|
-
str_max_unique_value_count: int = 20, # 允许自动添加筛选功能的字符型字段唯一值数量上限
|
|
73
|
-
checkbox_filter_radio_columns: List[
|
|
74
|
-
str
|
|
75
|
-
] = None, # 需要将筛选功能设置为单选模式的字段名数组
|
|
76
|
-
checkbox_filter_enable_search: bool = True, # 是否为字段筛选菜单启用搜索框
|
|
77
|
-
# 字段编辑功能相关参数
|
|
78
|
-
# 设置需要开启可编辑功能的列名数组,特别地,传入'*'表示全部字段均开启可编辑功能
|
|
79
|
-
editable_columns: Union[List[str], Literal['*']] = None,
|
|
80
|
-
# 数据预处理相关参数
|
|
81
|
-
# 为指定字段设置小数保留位数,特别地,当传入{'*': 小数位数}时,表示对所有数值型字段统一设置保留位数
|
|
82
|
-
columns_precision: dict = None,
|
|
83
|
-
columns_processor: Dict[
|
|
84
|
-
str, Callable
|
|
85
|
-
] = None, # 对指定字段进行预处理的自定义函数
|
|
86
|
-
**kwargs,
|
|
87
|
-
) -> fac.AntdTable:
|
|
88
|
-
"""
|
|
89
|
-
将 pandas DataFrame 转换为 AntdTable 组件。
|
|
90
|
-
参数:
|
|
91
|
-
raw_df (Any): 要转换的输入 pandas DataFrame。
|
|
92
|
-
id (str, 可选): 设置对应 AntdTable 组件的 id,默认为 None。
|
|
93
|
-
columns_alias (dict, 可选): 为指定字段定义充当 title 的别名,默认为 None。
|
|
94
|
-
columns_render_options (dict, 可选): 为指定字段设置对应 AntdTable 原 columns.*.renderOptions 配置参数,默认为 None。
|
|
95
|
-
column_width_mode (Literal['auto', 'fit-title', 'equal'], 可选): 列宽分配策略,可选 'auto'、'fit-title'、'equal',默认为 'auto'。
|
|
96
|
-
column_width_sum (str, 可选): 用于定义各列宽之和,常用的有 '100%'、'1000px' 等符合 CSS 宽度规则的值,默认为 '100%'。
|
|
97
|
-
left_fixed_columns (List[str], 可选): 定义需要在左侧固定的列名数组,默认为 None。
|
|
98
|
-
right_fixed_columns (List[str], 可选): 定义需要在右侧固定的列名数组,默认为 None。
|
|
99
|
-
numeric_auto_sort (bool, 可选): 是否针对数据框中的数值型字段自动添加排序功能,默认为 True。
|
|
100
|
-
sort_multiple (Union[bool, Literal['auto']], 可选): 针对字段排序配置组合排序相关参数,默认值同 AntdTable 的 sortOptions.multiple,默认为 False。
|
|
101
|
-
str_auto_filter (bool, 可选): 是否针对数据框中的字符型字段自动添加筛选功能,默认为 True。
|
|
102
|
-
str_max_unique_value_count (int, 可选): 设置筛选功能的字符型字段唯一值数量上限,默认为 20。
|
|
103
|
-
checkbox_filter_radio_columns (List[str], 可选): 将筛选功能设置为单选模式的字段名数组,默认为空列表。
|
|
104
|
-
checkbox_filter_enable_search (bool, 可选): 字段筛选菜单是否启用搜索框,默认为 True。
|
|
105
|
-
editable_columns (List[str] | Literal['*'], 可选): 设置需要开启可编辑功能的列名数组,传入 '*' 表示全部字段均开启可编辑功能,默认为 None。
|
|
106
|
-
columns_precision (dict, 可选): 为指定字段设置小数保留位数,当传入 {'*': 小数位数} 时,表示对所有数值型字段统一设置保留位数,默认为 None。
|
|
107
|
-
columns_processor (Dict[str, Callable], 可选): 对指定字段进行预处理的自定义函数,默认为 None。
|
|
108
|
-
**kwargs: 其他传递给 AntdTable 组件的参数。
|
|
109
|
-
返回值:
|
|
110
|
-
fac.AntdTable: 从输入 DataFrame 生成的 AntdTable 组件。
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
|
-
# 默认参数定义
|
|
114
|
-
columns_alias = columns_alias or {}
|
|
115
|
-
columns_alias = {
|
|
116
|
-
column: columns_alias.get(column) or column
|
|
117
|
-
for column in raw_df.columns
|
|
118
|
-
}
|
|
119
|
-
columns_render_options = columns_render_options or {}
|
|
120
|
-
left_fixed_columns = left_fixed_columns or []
|
|
121
|
-
right_fixed_columns = right_fixed_columns or []
|
|
122
|
-
checkbox_filter_radio_columns = (
|
|
123
|
-
checkbox_filter_radio_columns or []
|
|
124
|
-
)
|
|
125
|
-
editable_columns = editable_columns or []
|
|
126
|
-
columns_precision = columns_precision or {}
|
|
127
|
-
columns_processor = columns_processor or {}
|
|
128
|
-
|
|
129
|
-
# 拷贝源数据框,防止修改源数据
|
|
130
|
-
output_df = pd.DataFrame(raw_df).copy(deep=True)
|
|
131
|
-
|
|
132
|
-
# 构造必选参数
|
|
133
|
-
# 构造columns参数
|
|
134
|
-
columns = []
|
|
135
|
-
for column in output_df.columns:
|
|
136
|
-
columns.append(
|
|
137
|
-
{
|
|
138
|
-
'dataIndex': column,
|
|
139
|
-
'title': columns_alias.get(column),
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
# 根据column_width_mode构造列宽
|
|
143
|
-
if column_width_mode == 'fit-title':
|
|
144
|
-
# 计算所有字段名字符数之和
|
|
145
|
-
columns_title_length_sum = sum(
|
|
146
|
-
output_df.columns.map(
|
|
147
|
-
lambda s: len(columns_alias.get(s))
|
|
148
|
-
)
|
|
149
|
-
)
|
|
150
|
-
# 为各字段按比例分配列宽
|
|
151
|
-
for i, column in enumerate(columns):
|
|
152
|
-
columns[i]['width'] = 'calc({} * {} )'.format(
|
|
153
|
-
column_width_sum,
|
|
154
|
-
len(column['title'])
|
|
155
|
-
/ columns_title_length_sum,
|
|
156
|
-
)
|
|
157
|
-
elif column_width_mode == 'equal':
|
|
158
|
-
for i, column in enumerate(columns):
|
|
159
|
-
columns[i]['width'] = 'calc({} / {})'.format(
|
|
160
|
-
column_width_sum, len(columns)
|
|
161
|
-
)
|
|
162
|
-
# 根据left_fixed_columns、right_fixed_columns为相应字段设置是否固定
|
|
163
|
-
for i, column in enumerate(columns):
|
|
164
|
-
if column['dataIndex'] in left_fixed_columns:
|
|
165
|
-
columns[i]['fixed'] = 'left'
|
|
166
|
-
elif column['dataIndex'] in right_fixed_columns:
|
|
167
|
-
columns[i]['fixed'] = 'right'
|
|
168
|
-
# 根据editable_columns对相关列开启可编辑功能
|
|
169
|
-
for i, column in enumerate(columns):
|
|
170
|
-
if (
|
|
171
|
-
column['dataIndex'] in editable_columns
|
|
172
|
-
or editable_columns == '*'
|
|
173
|
-
):
|
|
174
|
-
columns[i]['editable'] = True
|
|
175
|
-
# 根据columns_render_options为columns各字段补充再渲染相关参数
|
|
176
|
-
if columns_render_options:
|
|
177
|
-
for i, column in enumerate(columns):
|
|
178
|
-
if columns_render_options.get(
|
|
179
|
-
column['dataIndex']
|
|
180
|
-
):
|
|
181
|
-
columns[i]['renderOptions'] = (
|
|
182
|
-
columns_render_options.get(
|
|
183
|
-
column['dataIndex']
|
|
184
|
-
)
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
# 构造可选参数
|
|
188
|
-
optional_params = {}
|
|
189
|
-
# 构造sortOptions参数
|
|
190
|
-
if numeric_auto_sort:
|
|
191
|
-
optional_params['sortOptions'] = {
|
|
192
|
-
'sortDataIndexes': output_df.select_dtypes(
|
|
193
|
-
'number'
|
|
194
|
-
).columns.tolist(),
|
|
195
|
-
'multiple': sort_multiple,
|
|
196
|
-
}
|
|
197
|
-
# 构造filterOptions参数
|
|
198
|
-
if str_auto_filter:
|
|
199
|
-
filterOptions = {}
|
|
200
|
-
for column in output_df.select_dtypes(
|
|
201
|
-
include='object'
|
|
202
|
-
):
|
|
203
|
-
# 检查当前字符型字段唯一值数量是否小于等于str_max_unique_value_count
|
|
204
|
-
try:
|
|
205
|
-
if (
|
|
206
|
-
output_df[column].nunique()
|
|
207
|
-
<= str_max_unique_value_count
|
|
208
|
-
):
|
|
209
|
-
filterOptions[column] = {
|
|
210
|
-
'filterSearch': checkbox_filter_enable_search
|
|
211
|
-
}
|
|
212
|
-
# 检查当前字段是否需要设置为单选模式
|
|
213
|
-
if (
|
|
214
|
-
column
|
|
215
|
-
in checkbox_filter_radio_columns
|
|
216
|
-
):
|
|
217
|
-
filterOptions[column][
|
|
218
|
-
'filterMultiple'
|
|
219
|
-
] = False
|
|
220
|
-
else:
|
|
221
|
-
filterOptions[column] = {
|
|
222
|
-
'filterMode': 'keyword'
|
|
223
|
-
}
|
|
224
|
-
# 忽略计算nunique时出现的异常
|
|
225
|
-
except:
|
|
226
|
-
pass
|
|
227
|
-
# 更新到optional_params中
|
|
228
|
-
optional_params['filterOptions'] = filterOptions
|
|
229
|
-
|
|
230
|
-
# 数据预处理
|
|
231
|
-
# 根据columns_precision对指定字段进行小数保留处理
|
|
232
|
-
if len(
|
|
233
|
-
columns_precision
|
|
234
|
-
) == 1 and columns_precision.get('*'):
|
|
235
|
-
for column in output_df.select_dtypes(
|
|
236
|
-
'number'
|
|
237
|
-
).columns:
|
|
238
|
-
output_df[column] = output_df[column].round(
|
|
239
|
-
columns_precision.get('*')
|
|
240
|
-
)
|
|
241
|
-
else:
|
|
242
|
-
for key in columns_precision.keys():
|
|
243
|
-
output_df[key] = output_df[key].round(
|
|
244
|
-
columns_precision.get(key)
|
|
245
|
-
)
|
|
246
|
-
# 根据columns_processor对指定字段进行自定义预处理
|
|
247
|
-
if columns_processor:
|
|
248
|
-
for key, processor in columns_processor.items():
|
|
249
|
-
output_df[key] = output_df[key].apply(processor)
|
|
250
|
-
|
|
251
|
-
return fac.AntdTable(
|
|
252
|
-
# data以kwargs中的data为准
|
|
253
|
-
data=kwargs.get('data')
|
|
254
|
-
or output_df.to_dict('records'),
|
|
255
|
-
columns=columns,
|
|
256
|
-
**optional_params,
|
|
257
|
-
**kwargs,
|
|
258
|
-
)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if __name__ == '__main__':
|
|
262
|
-
pass
|
|
1
|
+
import dash
|
|
2
|
+
import warnings
|
|
3
|
+
import importlib
|
|
4
|
+
from collections import defaultdict
|
|
5
|
+
import feffery_antd_components as fac
|
|
6
|
+
from typing import Union, Literal, Any, List, Callable, Dict
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
import pandas as pd
|
|
10
|
+
except ImportError:
|
|
11
|
+
warning_message = (
|
|
12
|
+
'检测到您的环境中未安装\033[93mpandas\033[0m,'
|
|
13
|
+
'部分工具函数如\033[93mdf2table\033[0m将无法正常使用,'
|
|
14
|
+
'如有需要请使用pip或conda安装pandas。'
|
|
15
|
+
'\n\nDetected that \033[93mpandas\033[0m is not installed in your environment. '
|
|
16
|
+
'Some utility functions, such as \033[93mdf2table\033[0m, will not function properly. '
|
|
17
|
+
'If necessary, please install pandas using pip or conda.'
|
|
18
|
+
)
|
|
19
|
+
warnings.warn(warning_message, UserWarning)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
__all__ = ['fill_output_dict', 'df2table']
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def fill_output_dict(
|
|
26
|
+
output_dict: dict, fill_value: Any = dash.no_update
|
|
27
|
+
) -> dict:
|
|
28
|
+
"""用于配合回调函数中Output角色的字典化写法,在已有明确字典返回值的基础上,为其他返回项进行默认值填充
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
output_dict (dict): 已有明确返回值字典
|
|
32
|
+
fill_value (Any): 设置其余无明确返回值的Output角色键值对统一填充值,默认为dash.no_update
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
dict: 处理后可以直接通过回调返回的完整Output结果字典
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
# 构造辅助用defaultdict
|
|
39
|
+
output = defaultdict(lambda: fill_value, output_dict)
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
key: output[key]
|
|
43
|
+
# 通过上下文遍历所有Output字典键名
|
|
44
|
+
for key in dash.ctx.outputs_grouping.keys()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def df2table(
|
|
49
|
+
raw_df: Any,
|
|
50
|
+
id: str = None, # 设置对应AntdTable组件的id
|
|
51
|
+
columns_alias: dict = None, # 为指定字段定义充当title的别名
|
|
52
|
+
# 为指定字段设置对应AntdTable原columns.*.renderOptions配置参数
|
|
53
|
+
columns_render_options: dict = None,
|
|
54
|
+
# 样式相关参数
|
|
55
|
+
# 列宽分配策略,可选的有'auto'、'fmit-title'、'equal'
|
|
56
|
+
column_width_mode: Literal[
|
|
57
|
+
'auto', 'fit-title', 'equal'
|
|
58
|
+
] = 'auto',
|
|
59
|
+
column_width_sum: str = '100%', # 用于定义各列宽之和,常用的有'100%'、'1000px'等符合css中宽度规则的值
|
|
60
|
+
left_fixed_columns: List[
|
|
61
|
+
str
|
|
62
|
+
] = None, # 定义需要在左侧固定的列名数组
|
|
63
|
+
right_fixed_columns: List[
|
|
64
|
+
str
|
|
65
|
+
] = None, # 定义需要在右侧固定的列名数组
|
|
66
|
+
# 字段排序功能相关参数
|
|
67
|
+
numeric_auto_sort: bool = True, # 是否针对数据框中的数值型字段自动添加排序功能
|
|
68
|
+
# 针对字段排序配置组合排序相关参数,同AntdTable的sortOptions.multiple
|
|
69
|
+
sort_multiple: Union[bool, Literal['auto']] = False,
|
|
70
|
+
# 字段筛选功能相关参数
|
|
71
|
+
str_auto_filter: bool = True, # 是否针对数据框中的字符型字段自动添加筛选功能
|
|
72
|
+
str_max_unique_value_count: int = 20, # 允许自动添加筛选功能的字符型字段唯一值数量上限
|
|
73
|
+
checkbox_filter_radio_columns: List[
|
|
74
|
+
str
|
|
75
|
+
] = None, # 需要将筛选功能设置为单选模式的字段名数组
|
|
76
|
+
checkbox_filter_enable_search: bool = True, # 是否为字段筛选菜单启用搜索框
|
|
77
|
+
# 字段编辑功能相关参数
|
|
78
|
+
# 设置需要开启可编辑功能的列名数组,特别地,传入'*'表示全部字段均开启可编辑功能
|
|
79
|
+
editable_columns: Union[List[str], Literal['*']] = None,
|
|
80
|
+
# 数据预处理相关参数
|
|
81
|
+
# 为指定字段设置小数保留位数,特别地,当传入{'*': 小数位数}时,表示对所有数值型字段统一设置保留位数
|
|
82
|
+
columns_precision: dict = None,
|
|
83
|
+
columns_processor: Dict[
|
|
84
|
+
str, Callable
|
|
85
|
+
] = None, # 对指定字段进行预处理的自定义函数
|
|
86
|
+
**kwargs,
|
|
87
|
+
) -> fac.AntdTable:
|
|
88
|
+
"""
|
|
89
|
+
将 pandas DataFrame 转换为 AntdTable 组件。
|
|
90
|
+
参数:
|
|
91
|
+
raw_df (Any): 要转换的输入 pandas DataFrame。
|
|
92
|
+
id (str, 可选): 设置对应 AntdTable 组件的 id,默认为 None。
|
|
93
|
+
columns_alias (dict, 可选): 为指定字段定义充当 title 的别名,默认为 None。
|
|
94
|
+
columns_render_options (dict, 可选): 为指定字段设置对应 AntdTable 原 columns.*.renderOptions 配置参数,默认为 None。
|
|
95
|
+
column_width_mode (Literal['auto', 'fit-title', 'equal'], 可选): 列宽分配策略,可选 'auto'、'fit-title'、'equal',默认为 'auto'。
|
|
96
|
+
column_width_sum (str, 可选): 用于定义各列宽之和,常用的有 '100%'、'1000px' 等符合 CSS 宽度规则的值,默认为 '100%'。
|
|
97
|
+
left_fixed_columns (List[str], 可选): 定义需要在左侧固定的列名数组,默认为 None。
|
|
98
|
+
right_fixed_columns (List[str], 可选): 定义需要在右侧固定的列名数组,默认为 None。
|
|
99
|
+
numeric_auto_sort (bool, 可选): 是否针对数据框中的数值型字段自动添加排序功能,默认为 True。
|
|
100
|
+
sort_multiple (Union[bool, Literal['auto']], 可选): 针对字段排序配置组合排序相关参数,默认值同 AntdTable 的 sortOptions.multiple,默认为 False。
|
|
101
|
+
str_auto_filter (bool, 可选): 是否针对数据框中的字符型字段自动添加筛选功能,默认为 True。
|
|
102
|
+
str_max_unique_value_count (int, 可选): 设置筛选功能的字符型字段唯一值数量上限,默认为 20。
|
|
103
|
+
checkbox_filter_radio_columns (List[str], 可选): 将筛选功能设置为单选模式的字段名数组,默认为空列表。
|
|
104
|
+
checkbox_filter_enable_search (bool, 可选): 字段筛选菜单是否启用搜索框,默认为 True。
|
|
105
|
+
editable_columns (List[str] | Literal['*'], 可选): 设置需要开启可编辑功能的列名数组,传入 '*' 表示全部字段均开启可编辑功能,默认为 None。
|
|
106
|
+
columns_precision (dict, 可选): 为指定字段设置小数保留位数,当传入 {'*': 小数位数} 时,表示对所有数值型字段统一设置保留位数,默认为 None。
|
|
107
|
+
columns_processor (Dict[str, Callable], 可选): 对指定字段进行预处理的自定义函数,默认为 None。
|
|
108
|
+
**kwargs: 其他传递给 AntdTable 组件的参数。
|
|
109
|
+
返回值:
|
|
110
|
+
fac.AntdTable: 从输入 DataFrame 生成的 AntdTable 组件。
|
|
111
|
+
"""
|
|
112
|
+
|
|
113
|
+
# 默认参数定义
|
|
114
|
+
columns_alias = columns_alias or {}
|
|
115
|
+
columns_alias = {
|
|
116
|
+
column: columns_alias.get(column) or column
|
|
117
|
+
for column in raw_df.columns
|
|
118
|
+
}
|
|
119
|
+
columns_render_options = columns_render_options or {}
|
|
120
|
+
left_fixed_columns = left_fixed_columns or []
|
|
121
|
+
right_fixed_columns = right_fixed_columns or []
|
|
122
|
+
checkbox_filter_radio_columns = (
|
|
123
|
+
checkbox_filter_radio_columns or []
|
|
124
|
+
)
|
|
125
|
+
editable_columns = editable_columns or []
|
|
126
|
+
columns_precision = columns_precision or {}
|
|
127
|
+
columns_processor = columns_processor or {}
|
|
128
|
+
|
|
129
|
+
# 拷贝源数据框,防止修改源数据
|
|
130
|
+
output_df = pd.DataFrame(raw_df).copy(deep=True)
|
|
131
|
+
|
|
132
|
+
# 构造必选参数
|
|
133
|
+
# 构造columns参数
|
|
134
|
+
columns = []
|
|
135
|
+
for column in output_df.columns:
|
|
136
|
+
columns.append(
|
|
137
|
+
{
|
|
138
|
+
'dataIndex': column,
|
|
139
|
+
'title': columns_alias.get(column),
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
# 根据column_width_mode构造列宽
|
|
143
|
+
if column_width_mode == 'fit-title':
|
|
144
|
+
# 计算所有字段名字符数之和
|
|
145
|
+
columns_title_length_sum = sum(
|
|
146
|
+
output_df.columns.map(
|
|
147
|
+
lambda s: len(columns_alias.get(s))
|
|
148
|
+
)
|
|
149
|
+
)
|
|
150
|
+
# 为各字段按比例分配列宽
|
|
151
|
+
for i, column in enumerate(columns):
|
|
152
|
+
columns[i]['width'] = 'calc({} * {} )'.format(
|
|
153
|
+
column_width_sum,
|
|
154
|
+
len(column['title'])
|
|
155
|
+
/ columns_title_length_sum,
|
|
156
|
+
)
|
|
157
|
+
elif column_width_mode == 'equal':
|
|
158
|
+
for i, column in enumerate(columns):
|
|
159
|
+
columns[i]['width'] = 'calc({} / {})'.format(
|
|
160
|
+
column_width_sum, len(columns)
|
|
161
|
+
)
|
|
162
|
+
# 根据left_fixed_columns、right_fixed_columns为相应字段设置是否固定
|
|
163
|
+
for i, column in enumerate(columns):
|
|
164
|
+
if column['dataIndex'] in left_fixed_columns:
|
|
165
|
+
columns[i]['fixed'] = 'left'
|
|
166
|
+
elif column['dataIndex'] in right_fixed_columns:
|
|
167
|
+
columns[i]['fixed'] = 'right'
|
|
168
|
+
# 根据editable_columns对相关列开启可编辑功能
|
|
169
|
+
for i, column in enumerate(columns):
|
|
170
|
+
if (
|
|
171
|
+
column['dataIndex'] in editable_columns
|
|
172
|
+
or editable_columns == '*'
|
|
173
|
+
):
|
|
174
|
+
columns[i]['editable'] = True
|
|
175
|
+
# 根据columns_render_options为columns各字段补充再渲染相关参数
|
|
176
|
+
if columns_render_options:
|
|
177
|
+
for i, column in enumerate(columns):
|
|
178
|
+
if columns_render_options.get(
|
|
179
|
+
column['dataIndex']
|
|
180
|
+
):
|
|
181
|
+
columns[i]['renderOptions'] = (
|
|
182
|
+
columns_render_options.get(
|
|
183
|
+
column['dataIndex']
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# 构造可选参数
|
|
188
|
+
optional_params = {}
|
|
189
|
+
# 构造sortOptions参数
|
|
190
|
+
if numeric_auto_sort:
|
|
191
|
+
optional_params['sortOptions'] = {
|
|
192
|
+
'sortDataIndexes': output_df.select_dtypes(
|
|
193
|
+
'number'
|
|
194
|
+
).columns.tolist(),
|
|
195
|
+
'multiple': sort_multiple,
|
|
196
|
+
}
|
|
197
|
+
# 构造filterOptions参数
|
|
198
|
+
if str_auto_filter:
|
|
199
|
+
filterOptions = {}
|
|
200
|
+
for column in output_df.select_dtypes(
|
|
201
|
+
include='object'
|
|
202
|
+
):
|
|
203
|
+
# 检查当前字符型字段唯一值数量是否小于等于str_max_unique_value_count
|
|
204
|
+
try:
|
|
205
|
+
if (
|
|
206
|
+
output_df[column].nunique()
|
|
207
|
+
<= str_max_unique_value_count
|
|
208
|
+
):
|
|
209
|
+
filterOptions[column] = {
|
|
210
|
+
'filterSearch': checkbox_filter_enable_search
|
|
211
|
+
}
|
|
212
|
+
# 检查当前字段是否需要设置为单选模式
|
|
213
|
+
if (
|
|
214
|
+
column
|
|
215
|
+
in checkbox_filter_radio_columns
|
|
216
|
+
):
|
|
217
|
+
filterOptions[column][
|
|
218
|
+
'filterMultiple'
|
|
219
|
+
] = False
|
|
220
|
+
else:
|
|
221
|
+
filterOptions[column] = {
|
|
222
|
+
'filterMode': 'keyword'
|
|
223
|
+
}
|
|
224
|
+
# 忽略计算nunique时出现的异常
|
|
225
|
+
except:
|
|
226
|
+
pass
|
|
227
|
+
# 更新到optional_params中
|
|
228
|
+
optional_params['filterOptions'] = filterOptions
|
|
229
|
+
|
|
230
|
+
# 数据预处理
|
|
231
|
+
# 根据columns_precision对指定字段进行小数保留处理
|
|
232
|
+
if len(
|
|
233
|
+
columns_precision
|
|
234
|
+
) == 1 and columns_precision.get('*'):
|
|
235
|
+
for column in output_df.select_dtypes(
|
|
236
|
+
'number'
|
|
237
|
+
).columns:
|
|
238
|
+
output_df[column] = output_df[column].round(
|
|
239
|
+
columns_precision.get('*')
|
|
240
|
+
)
|
|
241
|
+
else:
|
|
242
|
+
for key in columns_precision.keys():
|
|
243
|
+
output_df[key] = output_df[key].round(
|
|
244
|
+
columns_precision.get(key)
|
|
245
|
+
)
|
|
246
|
+
# 根据columns_processor对指定字段进行自定义预处理
|
|
247
|
+
if columns_processor:
|
|
248
|
+
for key, processor in columns_processor.items():
|
|
249
|
+
output_df[key] = output_df[key].apply(processor)
|
|
250
|
+
|
|
251
|
+
return fac.AntdTable(
|
|
252
|
+
# data以kwargs中的data为准
|
|
253
|
+
data=kwargs.get('data')
|
|
254
|
+
or output_df.to_dict('records'),
|
|
255
|
+
columns=columns,
|
|
256
|
+
**optional_params,
|
|
257
|
+
**kwargs,
|
|
258
|
+
)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if __name__ == '__main__':
|
|
262
|
+
pass
|