plain-design 1.0.0-beta.70 → 1.0.0-beta.72
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -2
- package/dist/plain-design.commonjs.min.js +3 -12
- package/dist/plain-design.min.css +3 -3
- package/dist/plain-design.min.js +3 -12
- package/dist/report.html +2 -2
- package/package.json +91 -91
- package/src/index.ts +1 -1
- package/src/packages/build.ts +7 -7
- package/src/packages/components/$address/address.utils.ts +31 -31
- package/src/packages/components/$address/createAddressService.tsx +184 -184
- package/src/packages/components/$address/index.tsx +7 -7
- package/src/packages/components/$configuration/index.tsx +58 -58
- package/src/packages/components/$dialog/index.tsx +7 -7
- package/src/packages/components/$file/index.tsx +212 -212
- package/src/packages/components/$image/index.tsx +7 -7
- package/src/packages/components/$message/image.service.utils.tsx +161 -161
- package/src/packages/components/$message/index.tsx +7 -7
- package/src/packages/components/$notice/index.tsx +7 -7
- package/src/packages/components/$object/createObjectService.tsx +215 -215
- package/src/packages/components/$object/index.ts +5 -5
- package/src/packages/components/$object/object.conver.ts +56 -56
- package/src/packages/components/$object/object.service.utils.ts +56 -56
- package/src/packages/components/$ov/createOvService.ts +86 -86
- package/src/packages/components/$ov/index.tsx +5 -5
- package/src/packages/components/$ov/ov.utils.ts +11 -11
- package/src/packages/components/$previewer/ImagePreviewerFixedContainer.tsx +108 -108
- package/src/packages/components/$previewer/image-previewer-fixed-container.scss +18 -18
- package/src/packages/components/$previewer/index.tsx +52 -52
- package/src/packages/components/$upload/createUploadService.tsx +57 -57
- package/src/packages/components/$upload/upload.utils.ts +17 -17
- package/src/packages/components/Address/index.tsx +138 -138
- package/src/packages/components/AddressCascade/address-cascade.utils.ts +44 -44
- package/src/packages/components/AddressCascade/createAddressCascade.hooks.ts +9 -9
- package/src/packages/components/AddressCascade/createAddressCascade.multiple.tsx +53 -53
- package/src/packages/components/AddressCascade/createAddressCascade.single.tsx +75 -75
- package/src/packages/components/AddressCascade/index.tsx +57 -57
- package/src/packages/components/Alert/alert.scss +136 -136
- package/src/packages/components/Alert/index.tsx +93 -93
- package/src/packages/components/Application/application.scss +16 -16
- package/src/packages/components/Application/index.tsx +56 -56
- package/src/packages/components/Application/service/createApplicationService.tsx +47 -47
- package/src/packages/components/Application/service/createApplicationServiceComponent.tsx +41 -41
- package/src/packages/components/Application/service/createApplicationServiceManager.tsx +98 -98
- package/src/packages/components/Application/service/useApplicationService.tsx +126 -126
- package/src/packages/components/Application/theme/theme.ts +282 -282
- package/src/packages/components/Application/theme/theme.utils.ts +17 -17
- package/src/packages/components/Application/utils/application.utils.ts +27 -27
- package/src/packages/components/Application/utils/createServiceReadyObserver.ts +18 -18
- package/src/packages/components/ApplicationConfigurationProvider/index.tsx +5 -5
- package/src/packages/components/ArrowStep/index.tsx +73 -73
- package/src/packages/components/ArrowStepGroup/arrow-step.scss +106 -106
- package/src/packages/components/ArrowStepGroup/index.tsx +63 -63
- package/src/packages/components/AsyncFormatter/index.tsx +1 -1
- package/src/packages/components/AutoLoadingObserver/index.tsx +173 -172
- package/src/packages/components/AutoTable/AutoTable.tsx +56 -56
- package/src/packages/components/AutoTable/auto-table.scss +432 -432
- package/src/packages/components/AutoTable/createTableOptionUser.tsx +75 -75
- package/src/packages/components/AutoTable/filter/useTableOption.filter.form.tsx +214 -214
- package/src/packages/components/AutoTable/filter/useTableOption.filter.search.tsx +168 -168
- package/src/packages/components/AutoTable/filter/useTableOption.filter.state.ts +194 -194
- package/src/packages/components/AutoTable/index.tsx +4 -4
- package/src/packages/components/AutoTable/setting/useTableOption.setting.all.fitler.tsx +79 -79
- package/src/packages/components/AutoTable/setting/useTableOption.setting.cache.tsx +145 -145
- package/src/packages/components/AutoTable/setting/useTableOption.setting.config.tsx +218 -218
- package/src/packages/components/AutoTable/setting/useTableOption.setting.export.tsx +308 -308
- package/src/packages/components/AutoTable/setting/useTableOption.setting.import.tsx +100 -100
- package/src/packages/components/AutoTable/setting/useTableOption.setting.senior.filter.tsx +385 -385
- package/src/packages/components/AutoTable/setting/useTableOption.setting.senior.sort.tsx +116 -116
- package/src/packages/components/AutoTable/setting/useTableOption.setting.tsx +109 -109
- package/src/packages/components/AutoTable/setting/useTableOption.setting.utils.ts +40 -40
- package/src/packages/components/AutoTable/use/useTableOption.buttons.tsx +239 -239
- package/src/packages/components/AutoTable/use/useTableOption.cache.ts +235 -235
- package/src/packages/components/AutoTable/use/useTableOption.cache.utils.ts +83 -83
- package/src/packages/components/AutoTable/use/useTableOption.check.tsx +80 -80
- package/src/packages/components/AutoTable/use/useTableOption.column.popper.tsx +491 -491
- package/src/packages/components/AutoTable/use/useTableOption.confirm.tsx +122 -122
- package/src/packages/components/AutoTable/use/useTableOption.fill.tsx +153 -153
- package/src/packages/components/AutoTable/use/useTableOption.hooks.tsx +140 -140
- package/src/packages/components/AutoTable/use/useTableOption.loading.tsx +77 -77
- package/src/packages/components/AutoTable/use/useTableOption.methods.tsx +512 -512
- package/src/packages/components/AutoTable/use/useTableOption.pagination.tsx +191 -191
- package/src/packages/components/AutoTable/use/useTableOption.parent.tsx +131 -131
- package/src/packages/components/AutoTable/use/useTableOption.permission.tsx +16 -16
- package/src/packages/components/AutoTable/use/useTableOption.render.tsx +34 -34
- package/src/packages/components/AutoTable/use/useTableOption.sort.ts +197 -197
- package/src/packages/components/AutoTable/use/useTableOption.state.tsx +31 -31
- package/src/packages/components/AutoTable/use/useTableOption.table.tsx +78 -78
- package/src/packages/components/AutoTable/use/useTableOption.tips.tsx +87 -87
- package/src/packages/components/AutoTable/use/useTableOptionKeyboard.tsx +102 -102
- package/src/packages/components/AutoTable/utils/AutoModule.ts +10 -10
- package/src/packages/components/AutoTable/utils/AutoTable.utils.ts +45 -45
- package/src/packages/components/AutoTable/utils/TableOption.space.tsx +199 -199
- package/src/packages/components/AutoTable/utils/TableOption.url.ts +153 -153
- package/src/packages/components/AutoTable/utils/TableOption.utils.tsx +57 -57
- package/src/packages/components/AutoTable/utils/buildPlainDefaultUrlConfig.ts +134 -134
- package/src/packages/components/AutoWidthInput/auto-width-input.scss +25 -25
- package/src/packages/components/AutoWidthInput/index.tsx +67 -67
- package/src/packages/components/Badge/badge.scss +67 -67
- package/src/packages/components/Badge/index.tsx +52 -52
- package/src/packages/components/Button/button.scss +203 -203
- package/src/packages/components/Button/index.tsx +206 -206
- package/src/packages/components/ButtonGroup/button-group.scss +73 -73
- package/src/packages/components/ButtonGroup/index.tsx +43 -43
- package/src/packages/components/Card/card.scss +122 -122
- package/src/packages/components/Card/index.tsx +74 -74
- package/src/packages/components/Carousel/carousel.scss +391 -391
- package/src/packages/components/Carousel/index.tsx +591 -591
- package/src/packages/components/CarouselItem/index.tsx +77 -77
- package/src/packages/components/Cascade/cascade.scss +111 -111
- package/src/packages/components/Cascade/cascade.utils.ts +68 -68
- package/src/packages/components/Cascade/createCascadeHooks.ts +12 -12
- package/src/packages/components/Cascade/createCascadePopper.tsx +119 -119
- package/src/packages/components/Cascade/createCascadeUtils.ts +15 -15
- package/src/packages/components/Cascade/createMultipleCascadeRender.tsx +157 -157
- package/src/packages/components/Cascade/createSingleCascadeRender.tsx +175 -175
- package/src/packages/components/Cascade/index.tsx +106 -106
- package/src/packages/components/CascadePanel/cascade-panel.utils.ts +90 -90
- package/src/packages/components/CascadePanel/flat/CascadeFlatPanelNode.tsx +56 -56
- package/src/packages/components/CascadePanel/flat/cascade-flat-panel.scss +132 -132
- package/src/packages/components/CascadePanel/flat/createCascadeFlatRender.tsx +82 -82
- package/src/packages/components/CascadePanel/index.tsx +190 -190
- package/src/packages/components/CascadePanel/list/CascadeListPanelItem.tsx +93 -93
- package/src/packages/components/CascadePanel/list/CascadeListPanelNode.tsx +69 -69
- package/src/packages/components/CascadePanel/list/createCascadeListRender.tsx +27 -27
- package/src/packages/components/Checkbox/checkbox.scss +77 -77
- package/src/packages/components/Checkbox/index.tsx +141 -141
- package/src/packages/components/CheckboxGroup/index.tsx +205 -205
- package/src/packages/components/CheckboxInner/checkbox-inner.scss +55 -55
- package/src/packages/components/CheckboxInner/index.tsx +34 -34
- package/src/packages/components/ClientZoom/index.ts +5 -5
- package/src/packages/components/Collapse/collapse.scss +44 -44
- package/src/packages/components/Collapse/index.tsx +94 -94
- package/src/packages/components/CollapseGroup/index.tsx +70 -70
- package/src/packages/components/CollapseTransition/index.tsx +184 -184
- package/src/packages/components/ColorPicker/ColorPanel.tsx +125 -125
- package/src/packages/components/ColorPicker/color-panel.scss +97 -97
- package/src/packages/components/ColorPicker/color-picker.scss +58 -58
- package/src/packages/components/ColorPicker/index.tsx +131 -131
- package/src/packages/components/ColorPicker/sub/ColorAlphaSlider.tsx +43 -43
- package/src/packages/components/ColorPicker/sub/ColorHueSlider.tsx +17 -17
- package/src/packages/components/ColorPicker/sub/ColorSlider.tsx +163 -163
- package/src/packages/components/ColorPicker/sub/ColorSvPanel.tsx +125 -125
- package/src/packages/components/ColorPicker/sub/color-alpha-slider.scss +8 -8
- package/src/packages/components/ColorPicker/sub/color-hue-slider.scss +3 -3
- package/src/packages/components/ColorPicker/sub/color-slider.scss +22 -22
- package/src/packages/components/ColorPicker/sub/color-sv-panel.scss +55 -55
- package/src/packages/components/ColorPicker/useColorPanelEditor.tsx +119 -119
- package/src/packages/components/ColorPicker/useColorPanelHistory.tsx +51 -51
- package/src/packages/components/ColorPicker/utils/PlainColor.ts +70 -70
- package/src/packages/components/ColorPicker/utils/color-picker.utils.tsx +27 -27
- package/src/packages/components/DatePicker/createDateRender.multiple.tsx +188 -188
- package/src/packages/components/DatePicker/createDateRender.single.tsx +167 -167
- package/src/packages/components/DatePicker/createRangeDateRender.range.tsx +106 -106
- package/src/packages/components/DatePicker/createRangeDateRender.separate.tsx +112 -112
- package/src/packages/components/DatePicker/date.mixin.scss +73 -73
- package/src/packages/components/DatePicker/date.scss +542 -542
- package/src/packages/components/DatePicker/date.utils.tsx +397 -397
- package/src/packages/components/DatePicker/index.tsx +82 -82
- package/src/packages/components/DatePicker/panel/DatePanel.tsx +99 -99
- package/src/packages/components/DatePicker/panel/DatePanelDate.tsx +278 -278
- package/src/packages/components/DatePicker/panel/DatePanelMonth.tsx +190 -190
- package/src/packages/components/DatePicker/panel/DatePanelQuarter.tsx +50 -50
- package/src/packages/components/DatePicker/panel/DatePanelRange.tsx +146 -146
- package/src/packages/components/DatePicker/panel/DatePanelWeek.tsx +52 -52
- package/src/packages/components/DatePicker/panel/DatePanelYear.tsx +100 -100
- package/src/packages/components/DatePicker/panel/useDatePanel.tsx +618 -618
- package/src/packages/components/DatePicker/panel/useDateWeek.tsx +153 -153
- package/src/packages/components/DatePicker/useRangeDateRender.tsx +317 -317
- package/src/packages/components/Dialog/dialog.scss +261 -261
- package/src/packages/components/Dialog/index.tsx +445 -445
- package/src/packages/components/Dialog/useDialogMovable.tsx +72 -72
- package/src/packages/components/Dialog/utils/dialog.mouse.ts +16 -16
- package/src/packages/components/Dialog/utils/dialog.utils.ts +10 -10
- package/src/packages/components/Dropdown/dropdown.public.scss +94 -94
- package/src/packages/components/Dropdown/dropdown.scss +13 -13
- package/src/packages/components/Dropdown/dropdown.utils.tsx +109 -109
- package/src/packages/components/Dropdown/index.tsx +161 -161
- package/src/packages/components/DropdownGroup/index.tsx +18 -18
- package/src/packages/components/DropdownOption/index.tsx +74 -74
- package/src/packages/components/DropdownSeparator/index.tsx +8 -8
- package/src/packages/components/Empty/empty.scss +14 -14
- package/src/packages/components/Empty/index.tsx +48 -48
- package/src/packages/components/FilterFormMultiple/filter-form-multiple.scss +36 -36
- package/src/packages/components/FilterFormMultiple/index.tsx +282 -282
- package/src/packages/components/FilterFormSingle/index.tsx +173 -173
- package/src/packages/components/FilterService/filter/filter.city.tsx +84 -84
- package/src/packages/components/FilterService/filter/filter.date.tsx +85 -85
- package/src/packages/components/FilterService/filter/filter.datetime.tsx +68 -68
- package/src/packages/components/FilterService/filter/filter.district.tsx +85 -85
- package/src/packages/components/FilterService/filter/filter.number.tsx +66 -66
- package/src/packages/components/FilterService/filter/filter.province.tsx +91 -91
- package/src/packages/components/FilterService/filter/filter.select.tsx +66 -66
- package/src/packages/components/FilterService/filter/filter.text.tsx +57 -57
- package/src/packages/components/FilterService/filter/fitler.object.tsx +115 -115
- package/src/packages/components/FilterService/index.tsx +250 -250
- package/src/packages/components/FilterService/utils/filter.service.utils.ts +138 -138
- package/src/packages/components/FilterService/utils/mergeQueryParam.ts +80 -80
- package/src/packages/components/Form/form.scss +226 -226
- package/src/packages/components/Form/index.tsx +66 -66
- package/src/packages/components/Form/layout/useFormLayout.tsx +304 -304
- package/src/packages/components/Form/types/any.tsx +54 -54
- package/src/packages/components/Form/types/array.tsx +55 -55
- package/src/packages/components/Form/types/arrayjson.tsx +15 -15
- package/src/packages/components/Form/types/arraystring.tsx +15 -15
- package/src/packages/components/Form/types/date.tsx +72 -72
- package/src/packages/components/Form/types/datetime.tsx +8 -8
- package/src/packages/components/Form/types/email.tsx +11 -11
- package/src/packages/components/Form/types/idcard.tsx +13 -13
- package/src/packages/components/Form/types/number.tsx +59 -59
- package/src/packages/components/Form/types/phone.tsx +11 -11
- package/src/packages/components/Form/types/qq.tsx +11 -11
- package/src/packages/components/Form/types/string.tsx +68 -68
- package/src/packages/components/Form/types/time.tsx +8 -8
- package/src/packages/components/Form/validate/createValidation.tsx +274 -274
- package/src/packages/components/Form/validate/useFormItemValidation.tsx +121 -121
- package/src/packages/components/Form/validate/useFormValidation.tsx +137 -137
- package/src/packages/components/Form/validate/validate.utils.tsx +436 -436
- package/src/packages/components/FormCascade/index.tsx +6 -6
- package/src/packages/components/FormCheckbox/index.tsx +6 -6
- package/src/packages/components/FormCheckboxGroup/index.tsx +6 -6
- package/src/packages/components/FormColorPicker/index.tsx +6 -6
- package/src/packages/components/FormDatePicker/index.tsx +6 -6
- package/src/packages/components/FormInput/index.tsx +6 -6
- package/src/packages/components/FormInputNumber/index.tsx +6 -6
- package/src/packages/components/FormItem/FormItemValidateMessage.tsx +16 -16
- package/src/packages/components/FormItem/createFormEditor.tsx +87 -87
- package/src/packages/components/FormItem/index.tsx +127 -127
- package/src/packages/components/FormRadio/index.tsx +6 -6
- package/src/packages/components/FormRadioGroup/index.tsx +6 -6
- package/src/packages/components/FormRate/index.tsx +6 -6
- package/src/packages/components/FormSelect/index.tsx +6 -6
- package/src/packages/components/FormSlider/index.tsx +6 -6
- package/src/packages/components/FormTimePicker/index.tsx +6 -6
- package/src/packages/components/FormToggle/index.tsx +6 -6
- package/src/packages/components/Formatter/index.tsx +64 -64
- package/src/packages/components/Grid/GridCol.tsx +72 -72
- package/src/packages/components/Grid/GridRow.tsx +55 -55
- package/src/packages/components/Grid/grid.scss +109 -109
- package/src/packages/components/Grid/grid.utils.ts +21 -21
- package/src/packages/components/GridCol/index.tsx +5 -5
- package/src/packages/components/GridRow/index.tsx +5 -5
- package/src/packages/components/Icon/icon.registry.tsx +21 -21
- package/src/packages/components/Icon/icon.scss +12 -12
- package/src/packages/components/Icon/index.tsx +54 -54
- package/src/packages/components/Illustration/index.tsx +28 -28
- package/src/packages/components/Image/image.scss +333 -333
- package/src/packages/components/Image/index.tsx +166 -166
- package/src/packages/components/ImagePreviewer/ImagePreviewer.tsx +574 -574
- package/src/packages/components/ImagePreviewer/ImagePreviewerButtonBar.tsx +140 -140
- package/src/packages/components/ImagePreviewer/ImagePreviewerCarouselImage.tsx +54 -54
- package/src/packages/components/ImagePreviewer/ImagePreviewerGallery.tsx +202 -202
- package/src/packages/components/ImagePreviewer/PreviewerLoading.tsx +26 -26
- package/src/packages/components/ImagePreviewer/image-previewer.scss +244 -244
- package/src/packages/components/ImagePreviewer/image-previewer.utils.tsx +136 -135
- package/src/packages/components/ImagePreviewer/index.tsx +5 -5
- package/src/packages/components/ImagePreviewer/previewer-loading.scss +52 -52
- package/src/packages/components/ImageUploader/index.tsx +224 -224
- package/src/packages/components/Input/index.scss +412 -412
- package/src/packages/components/Input/index.tsx +137 -137
- package/src/packages/components/Input/input.utils.ts +118 -118
- package/src/packages/components/Input/useMultipleInput.tsx +123 -123
- package/src/packages/components/Input/useSingleInput.tsx +43 -43
- package/src/packages/components/Input/useSuggestionInput.tsx +218 -218
- package/src/packages/components/Input/useTextareaInput.tsx +152 -152
- package/src/packages/components/Input/uses/useInputEnterHandler.tsx +72 -72
- package/src/packages/components/Input/uses/useInputHooks.tsx +21 -21
- package/src/packages/components/Input/uses/useInputMaxLength.tsx +35 -35
- package/src/packages/components/Input/uses/useInputSuffixIcon.tsx +63 -63
- package/src/packages/components/InputGroup/index.tsx +31 -31
- package/src/packages/components/InputGroup/input-group.scss +37 -37
- package/src/packages/components/InputNumber/NumberResize.tsx +111 -111
- package/src/packages/components/InputNumber/index.tsx +36 -36
- package/src/packages/components/InputNumber/input-number.utils.tsx +96 -96
- package/src/packages/components/InputNumber/number.scss +86 -86
- package/src/packages/components/InputNumber/number.utils.ts +3 -3
- package/src/packages/components/InputNumber/useInputNumber.multiple.tsx +121 -121
- package/src/packages/components/InputNumber/useInputNumber.public.tsx +477 -477
- package/src/packages/components/InputNumber/useInputNumber.single.tsx +137 -137
- package/src/packages/components/KeepAlive/KeepAliveCacheItemWrapper.tsx +114 -114
- package/src/packages/components/KeepAlive/index.tsx +77 -77
- package/src/packages/components/KeepAlive/utils/keepalive.utils.ts +33 -33
- package/src/packages/components/KeyboardService/index.ts +214 -214
- package/src/packages/components/Layout/index.tsx +31 -31
- package/src/packages/components/Layout/layout.scss +227 -227
- package/src/packages/components/Layout/layout.utils.ts +3 -3
- package/src/packages/components/LayoutSection/index.tsx +67 -67
- package/src/packages/components/LayoutSection/useLayoutSectionResizer.tsx +184 -184
- package/src/packages/components/List/index.tsx +74 -74
- package/src/packages/components/List/list.scss +3 -3
- package/src/packages/components/Loading/index.tsx +27 -27
- package/src/packages/components/Loading/loading.scss +7 -7
- package/src/packages/components/LoadingMask/index.tsx +101 -101
- package/src/packages/components/LoadingMask/loading-mask.scss +34 -34
- package/src/packages/components/NumberRange/index.tsx +93 -93
- package/src/packages/components/Object/createObjectHooks.tsx +13 -13
- package/src/packages/components/Object/createObjectRender.multiple.tsx +289 -289
- package/src/packages/components/Object/createObjectRender.single.tsx +215 -215
- package/src/packages/components/Object/index.tsx +104 -104
- package/src/packages/components/Object/object.scss +18 -18
- package/src/packages/components/Object/object.utils.ts +54 -54
- package/src/packages/components/OuterOperation/index.tsx +5 -5
- package/src/packages/components/Ov/index.tsx +23 -23
- package/src/packages/components/Ov/ov.utils.ts +9 -9
- package/src/packages/components/Ov/usePublicOv.tsx +35 -35
- package/src/packages/components/PageRenderList/index.tsx +22 -22
- package/src/packages/components/PageThemeUtils/deepmerge.ts +21 -21
- package/src/packages/components/PageThemeUtils/index.tsx +258 -258
- package/src/packages/components/Pagination/index.tsx +339 -339
- package/src/packages/components/Pagination/pagination.scss +126 -126
- package/src/packages/components/Plc/index.tsx +4 -4
- package/src/packages/components/PlcAddress/index.tsx +4 -4
- package/src/packages/components/PlcAddressItem/index.tsx +4 -4
- package/src/packages/components/PlcCheck/index.tsx +5 -5
- package/src/packages/components/PlcCheckbox/index.tsx +4 -4
- package/src/packages/components/PlcColorPicker/index.tsx +4 -4
- package/src/packages/components/PlcDate/index.tsx +4 -4
- package/src/packages/components/PlcDateRange/index.tsx +4 -4
- package/src/packages/components/PlcDraggier/index.tsx +5 -5
- package/src/packages/components/PlcExpand/index.tsx +5 -5
- package/src/packages/components/PlcGroup/index.tsx +4 -4
- package/src/packages/components/PlcImage/index.tsx +80 -80
- package/src/packages/components/PlcIndex/index.tsx +5 -5
- package/src/packages/components/PlcInput/index.tsx +4 -4
- package/src/packages/components/PlcNumber/index.tsx +4 -4
- package/src/packages/components/PlcObject/index.tsx +53 -53
- package/src/packages/components/PlcOperation/index.tsx +5 -5
- package/src/packages/components/PlcOv/index.tsx +31 -31
- package/src/packages/components/PlcRate/index.tsx +4 -4
- package/src/packages/components/PlcSelect/index.tsx +4 -4
- package/src/packages/components/PlcTextarea/index.tsx +4 -4
- package/src/packages/components/PlcTime/index.tsx +4 -4
- package/src/packages/components/PlcTimeRange/index.tsx +4 -4
- package/src/packages/components/PlcToggle/index.tsx +4 -4
- package/src/packages/components/PlcTree/index.tsx +5 -5
- package/src/packages/components/Popup/PopupProvider.tsx +21 -21
- package/src/packages/components/Popup/index.tsx +395 -395
- package/src/packages/components/Popup/popup.scss +13 -13
- package/src/packages/components/ProgressBar/index.tsx +87 -87
- package/src/packages/components/ProgressBar/progress-bar.scss +40 -40
- package/src/packages/components/ProgressBar/progress.utils.ts +24 -24
- package/src/packages/components/ProgressCircle/index.tsx +188 -188
- package/src/packages/components/ProgressCircle/progress-circle.scss +44 -44
- package/src/packages/components/ProgressMini/index.tsx +98 -98
- package/src/packages/components/ProgressMini/progress-mini.scss +17 -17
- package/src/packages/components/Radio/index.tsx +137 -137
- package/src/packages/components/Radio/radio.scss +79 -79
- package/src/packages/components/RadioGroup/index.tsx +62 -62
- package/src/packages/components/RadioInner/index.tsx +31 -31
- package/src/packages/components/RadioInner/radio-inner.scss +17 -17
- package/src/packages/components/Rate/index.tsx +152 -152
- package/src/packages/components/Rate/rate.scss +32 -32
- package/src/packages/components/Reference/ReferenceProvider.tsx +13 -13
- package/src/packages/components/Reference/index.tsx +57 -57
- package/src/packages/components/Scroll/HorizontalScrollbar.tsx +96 -96
- package/src/packages/components/Scroll/VerticalScrollbar.tsx +102 -102
- package/src/packages/components/Scroll/index.tsx +384 -380
- package/src/packages/components/Scroll/scroll.scss +168 -166
- package/src/packages/components/Scroll/useAutoScroll.ts +68 -68
- package/src/packages/components/Segment/index.tsx +39 -39
- package/src/packages/components/Segment/segment.scss +46 -46
- package/src/packages/components/SegmentGroup/index.tsx +48 -48
- package/src/packages/components/Select/SelectPanel.tsx +78 -78
- package/src/packages/components/Select/createMultipleSelectRender.tsx +244 -244
- package/src/packages/components/Select/createPublicSelectRender.tsx +405 -405
- package/src/packages/components/Select/createSelectOptionDecoder.tsx +43 -43
- package/src/packages/components/Select/createSingleSelectRender.tsx +129 -129
- package/src/packages/components/Select/decodeSelectRenderNode.tsx +50 -50
- package/src/packages/components/Select/index.tsx +85 -85
- package/src/packages/components/Select/select.scss +101 -101
- package/src/packages/components/Select/select.utils.tsx +247 -247
- package/src/packages/components/SelectDisplay/index.tsx +30 -30
- package/src/packages/components/SelectGroup/index.tsx +37 -37
- package/src/packages/components/SelectOption/index.tsx +72 -72
- package/src/packages/components/Slider/index.tsx +123 -123
- package/src/packages/components/Slider/slider.scss +128 -128
- package/src/packages/components/Slider/slider.utils.tsx +71 -71
- package/src/packages/components/Slider/useSlider.range.tsx +208 -208
- package/src/packages/components/Slider/useSlider.single.tsx +149 -149
- package/src/packages/components/Slider/useSliderDotDragier.tsx +66 -66
- package/src/packages/components/SortList/index.tsx +191 -191
- package/src/packages/components/SortList/sort-list.scss +11 -11
- package/src/packages/components/Space/index.tsx +30 -30
- package/src/packages/components/Space/space.scss +26 -26
- package/src/packages/components/StackCard/index.tsx +416 -416
- package/src/packages/components/StackCard/stack-card.scss +40 -40
- package/src/packages/components/StackCardItem/index.tsx +24 -24
- package/src/packages/components/Step/index.tsx +120 -120
- package/src/packages/components/StepGroup/index.tsx +63 -63
- package/src/packages/components/StepGroup/step-group.scss +411 -411
- package/src/packages/components/StepGroup/step.utils.ts +44 -44
- package/src/packages/components/Tab/index.tsx +42 -42
- package/src/packages/components/TabGroup/TabsHeader.tsx +105 -105
- package/src/packages/components/TabGroup/TabsInner.tsx +60 -60
- package/src/packages/components/TabGroup/header/horizontal/TabsHeaderHorizontal.tsx +94 -94
- package/src/packages/components/TabGroup/header/horizontal/TabsHeaderHorizontalCard.tsx +15 -15
- package/src/packages/components/TabGroup/header/horizontal/TabsHeaderHorizontalShadow.tsx +15 -15
- package/src/packages/components/TabGroup/header/horizontal/TabsHeaderHorizontalText.tsx +66 -66
- package/src/packages/components/TabGroup/header/horizontal/tabs-header-card.scss +85 -85
- package/src/packages/components/TabGroup/header/horizontal/tabs-header-horizontal.scss +59 -59
- package/src/packages/components/TabGroup/header/horizontal/tabs-header-shadow.scss +88 -88
- package/src/packages/components/TabGroup/header/horizontal/tabs-header-text.scss +50 -50
- package/src/packages/components/TabGroup/header/vertical/TabsHeaderVertical.tsx +24 -24
- package/src/packages/components/TabGroup/header/vertical/tabs-header-vertical.scss +116 -116
- package/src/packages/components/TabGroup/index.tsx +131 -131
- package/src/packages/components/TabGroup/tabs.scss +39 -39
- package/src/packages/components/TabGroup/tabs.utils.tsx +22 -22
- package/src/packages/components/Table/editor/PlcAddress.tsx +91 -91
- package/src/packages/components/Table/editor/PlcAddressItem.tsx +60 -60
- package/src/packages/components/Table/editor/PlcCheckbox.tsx +36 -36
- package/src/packages/components/Table/editor/PlcColorPicker.tsx +29 -29
- package/src/packages/components/Table/editor/PlcDate.tsx +97 -97
- package/src/packages/components/Table/editor/PlcDate.utils.tsx +45 -45
- package/src/packages/components/Table/editor/PlcDateRange.tsx +73 -73
- package/src/packages/components/Table/editor/PlcInput.tsx +21 -21
- package/src/packages/components/Table/editor/PlcNumber.tsx +23 -23
- package/src/packages/components/Table/editor/PlcRate.tsx +24 -24
- package/src/packages/components/Table/editor/PlcSelect.tsx +180 -180
- package/src/packages/components/Table/editor/PlcTextarea.tsx +22 -22
- package/src/packages/components/Table/editor/PlcTime.tsx +54 -54
- package/src/packages/components/Table/editor/PlcTime.utils.ts +15 -15
- package/src/packages/components/Table/editor/PlcTimeRange.tsx +66 -66
- package/src/packages/components/Table/editor/PlcToggle.tsx +40 -40
- package/src/packages/components/Table/index.tsx +4 -4
- package/src/packages/components/Table/plc/formatPlcList.tsx +92 -92
- package/src/packages/components/Table/plc/group/PlcGroup.tsx +20 -20
- package/src/packages/components/Table/plc/plc/Plc.tsx +19 -19
- package/src/packages/components/Table/plc/process/copyPlcList.ts +23 -23
- package/src/packages/components/Table/plc/process/getPltCellClass.ts +8 -8
- package/src/packages/components/Table/plc/process/processAutoFixed.ts +73 -73
- package/src/packages/components/Table/plc/process/processHeadPlcList.ts +110 -110
- package/src/packages/components/Table/plc/process/processPlcClassAndStyle.ts +43 -43
- package/src/packages/components/Table/plc/process/processPlcFixed.ts +81 -81
- package/src/packages/components/Table/plc/process/processPlcSort.ts +91 -91
- package/src/packages/components/Table/plc/use/useBasePlc.tsx +85 -85
- package/src/packages/components/Table/plc/use/useBasePlcGroup.tsx +70 -70
- package/src/packages/components/Table/plc/use/usePlc.tsx +136 -136
- package/src/packages/components/Table/plc/use/usePlcPropsState.tsx +112 -112
- package/src/packages/components/Table/plc/useTablePlc.tsx +226 -226
- package/src/packages/components/Table/plc/utils/iteratePlcList.tsx +48 -48
- package/src/packages/components/Table/plc/utils/plc.render.ts +122 -122
- package/src/packages/components/Table/plc/utils/plc.scope-slots.ts +63 -63
- package/src/packages/components/Table/plc/utils/plc.utils.ts +299 -299
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.hooks.tsx +16 -16
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.multiple.tsx +281 -281
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.single.tsx +90 -90
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.tsx +61 -61
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.utils.ts +35 -35
- package/src/packages/components/Table/standard/PlcDraggier/PlcDraggier.tsx +55 -55
- package/src/packages/components/Table/standard/PlcExclusion.tsx +26 -26
- package/src/packages/components/Table/standard/PlcExpand.tsx +198 -198
- package/src/packages/components/Table/standard/PlcIndex.tsx +34 -34
- package/src/packages/components/Table/standard/PlcOperation/OuterOperation.tsx +209 -209
- package/src/packages/components/Table/standard/PlcOperation/PlcOperation.tsx +385 -385
- package/src/packages/components/Table/standard/PlcOperation/PlcOperation.utils.tsx +159 -159
- package/src/packages/components/Table/standard/PlcOperation/outer-operation.scss +39 -39
- package/src/packages/components/Table/standard/PlcOperation/useOperationPermission.ts +53 -53
- package/src/packages/components/Table/standard/PlcTree/PlcTree.autoWidth.tsx +52 -52
- package/src/packages/components/Table/standard/PlcTree/PlcTree.renderNode.tsx +78 -78
- package/src/packages/components/Table/standard/PlcTree/PlcTree.tsx +194 -194
- package/src/packages/components/Table/standard/PlcTree/PlcTree.utils.ts +59 -59
- package/src/packages/components/Table/standard/PlcTree/PlcTreeHeader.tsx +64 -64
- package/src/packages/components/Table/standard/PlcTree/RenderPlcTreeNode.tsx +113 -113
- package/src/packages/components/Table/table/Table.tsx +378 -378
- package/src/packages/components/Table/table/body/cell.tsx +279 -279
- package/src/packages/components/Table/table/body/row.tsx +47 -47
- package/src/packages/components/Table/table/body/useCellValue.tsx +136 -136
- package/src/packages/components/Table/table/head/head-cell.tsx +94 -94
- package/src/packages/components/Table/table/head/useHeadCellResize.ts +79 -79
- package/src/packages/components/Table/table/node/useTableNode.tsx +66 -66
- package/src/packages/components/Table/table/table.scss +434 -434
- package/src/packages/components/Table/table/use/useFixedShadow.ts +48 -48
- package/src/packages/components/Table/table/use/useTableDraggier.col.tsx +639 -639
- package/src/packages/components/Table/table/use/useTableDraggier.row.tsx +267 -267
- package/src/packages/components/Table/table/use/useTableDraggier.tsx +237 -237
- package/src/packages/components/Table/table/use/useTableFormEditor.tsx +182 -182
- package/src/packages/components/Table/table/use/useTableLoading.tsx +39 -39
- package/src/packages/components/Table/table/use/useTableMethods.tsx +65 -65
- package/src/packages/components/Table/table/use/useTableModifyEditor.tsx +198 -198
- package/src/packages/components/Table/table/use/useTableScroll.tsx +49 -49
- package/src/packages/components/Table/table/utils/createTableHooks.ts +68 -68
- package/src/packages/components/Table/table/utils/table.utils.ts +283 -283
- package/src/packages/components/Table/table/utils/url.utils.ts +23 -23
- package/src/packages/components/TableOptionSpace/index.ts +5 -5
- package/src/packages/components/TableOptionUtils/index.ts +5 -5
- package/src/packages/components/Tag/index.tsx +77 -77
- package/src/packages/components/Tag/tag.scss +27 -27
- package/src/packages/components/Tag/tag.utils.ts +20 -20
- package/src/packages/components/ThemeColor/index.tsx +22 -22
- package/src/packages/components/ThemeColor/theme-color.scss +36 -36
- package/src/packages/components/ThemeColorSelector/index.tsx +40 -40
- package/src/packages/components/ThemeDarkSelector/index.tsx +24 -24
- package/src/packages/components/ThemeDarkSelector/theme-dark-selector.scss +5 -5
- package/src/packages/components/ThemeEditor/index.tsx +201 -201
- package/src/packages/components/ThemeEditor/theme-editor.scss +105 -105
- package/src/packages/components/ThemeLocaleSelector/index.tsx +28 -28
- package/src/packages/components/ThemeLocaleSelector/theme-locale-selector.scss +5 -5
- package/src/packages/components/ThemePrimaryColors/index.ts +5 -5
- package/src/packages/components/ThemeShapeSelector/index.tsx +45 -45
- package/src/packages/components/ThemeShapeSelector/theme-shape-selector.scss +5 -5
- package/src/packages/components/ThemeSizeSelector/index.tsx +40 -40
- package/src/packages/components/ThemeSizeSelector/theme-size-selector.scss +5 -5
- package/src/packages/components/TimePicker/createRangeTimeRender.tsx +72 -72
- package/src/packages/components/TimePicker/createSeparateRangeTimeRender.tsx +96 -96
- package/src/packages/components/TimePicker/createSingleTimeRender.tsx +202 -202
- package/src/packages/components/TimePicker/index.tsx +65 -65
- package/src/packages/components/TimePicker/panel/TimeBaseColumn.tsx +136 -136
- package/src/packages/components/TimePicker/panel/TimeBasePanel.tsx +172 -172
- package/src/packages/components/TimePicker/panel/TimePanel.tsx +94 -94
- package/src/packages/components/TimePicker/panel/TimeRangePanel.tsx +141 -141
- package/src/packages/components/TimePicker/panel/time-base-column.scss +51 -51
- package/src/packages/components/TimePicker/panel/time-base-panel.scss +39 -39
- package/src/packages/components/TimePicker/panel/time-panel.utils.ts +16 -16
- package/src/packages/components/TimePicker/panel/time-range-panel.scss +9 -9
- package/src/packages/components/TimePicker/time.scss +10 -10
- package/src/packages/components/TimePicker/time.utils.ts +99 -99
- package/src/packages/components/TimePicker/useRangeTimeRender.tsx +235 -235
- package/src/packages/components/TimePicker/useTimeHooks.ts +11 -11
- package/src/packages/components/Toggle/index.tsx +112 -112
- package/src/packages/components/Toggle/toggle.scss +147 -147
- package/src/packages/components/Tooltip/index.tsx +118 -118
- package/src/packages/components/Tooltip/tooltip.scss +5 -5
- package/src/packages/components/Transition/index.tsx +134 -133
- package/src/packages/components/Tree/RenderTreeNode.tsx +177 -177
- package/src/packages/components/Tree/index.tsx +130 -130
- package/src/packages/components/Tree/tree.scss +259 -259
- package/src/packages/components/TreeCore/TreeCore.type.tsx +138 -138
- package/src/packages/components/TreeCore/createTreeCore.tsx +364 -364
- package/src/packages/components/TreeCore/createTreeDraggier.tsx +412 -412
- package/src/packages/components/TreeCore/createTreeHooks.ts +16 -16
- package/src/packages/components/TreeCore/createTreeMethods.tsx +421 -421
- package/src/packages/components/TreeCore/createTreeNode.tsx +239 -239
- package/src/packages/components/TreeCore/createTreeProps.ts +75 -75
- package/src/packages/components/TreeCore/createTreeUtils.ts +140 -140
- package/src/packages/components/TreeCore/fromatNodeData.ts +65 -65
- package/src/packages/components/TreeNodeWithMenu/index.tsx +91 -91
- package/src/packages/components/TreeNodeWithMenu/tree-node-with-menu.scss +39 -39
- package/src/packages/components/TreeNodeWithMenu/treeNodeWithMenu.utils.ts +12 -12
- package/src/packages/components/Triangle/index.tsx +88 -88
- package/src/packages/components/Triangle/triangle.scss +12 -12
- package/src/packages/components/Upload/index.tsx +422 -422
- package/src/packages/components/Upload/upload.scss +185 -185
- package/src/packages/components/VirtualList/createVirtualDraggier.ts +407 -0
- package/src/packages/components/VirtualList/index.tsx +109 -72
- package/src/packages/components/VirtualList/useVirtualList.tsx +412 -396
- package/src/packages/components/VirtualList/virtual-list.scss +64 -49
- package/src/packages/components/VirtualTable/index.tsx +214 -201
- package/src/packages/components/VirtualTable/virtual-table.scss +179 -179
- package/src/packages/components/_Object/index.tsx +5 -5
- package/src/packages/components/buildPlainDefaultUrlConfig/index.tsx +5 -5
- package/src/packages/components/createAddressService/index.ts +5 -5
- package/src/packages/components/createHttp/http.utils.ts +56 -56
- package/src/packages/components/createHttp/index.tsx +29 -29
- package/src/packages/components/createObjectService/index.tsx +5 -5
- package/src/packages/components/createOvService/index.tsx +5 -5
- package/src/packages/components/createPlainAddressService/index.tsx +101 -101
- package/src/packages/components/createPopup/index.ts +5 -5
- package/src/packages/components/createProvider/index.ts +5 -5
- package/src/packages/components/createRequestInterceptor/index.ts +139 -139
- package/src/packages/components/createScrollUtils/index.tsx +163 -163
- package/src/packages/components/createTableOptionUser/index.tsx +5 -5
- package/src/packages/components/createUploadService/index.tsx +5 -5
- package/src/packages/components/createVirtualDraggier/index.ts +5 -0
- package/src/packages/components/createWebDraggier/index.ts +5 -0
- package/src/packages/components/i18n/index.tsx +5 -5
- package/src/packages/components/nextPopupId/index.ts +5 -5
- package/src/packages/components/useAutoScrollUtils/auto-scroll-utils.scss +48 -48
- package/src/packages/components/useAutoScrollUtils/index.tsx +86 -86
- package/src/packages/components/useDialog/DialogService.tsx +227 -227
- package/src/packages/components/useDialog/dialog-service.scss +50 -50
- package/src/packages/components/useDialog/dialog.service.utils.tsx +88 -88
- package/src/packages/components/useDialog/index.tsx +66 -66
- package/src/packages/components/useImage/ImageService.tsx +262 -262
- package/src/packages/components/useImage/index.tsx +28 -28
- package/src/packages/components/useMessage/Message.tsx +75 -75
- package/src/packages/components/useMessage/MessageContainer.tsx +64 -64
- package/src/packages/components/useMessage/MessageManager.tsx +58 -58
- package/src/packages/components/useMessage/index.tsx +51 -51
- package/src/packages/components/useMessage/message.scss +149 -149
- package/src/packages/components/useMessage/message.service.utils.tsx +43 -43
- package/src/packages/components/useNotice/Notice.tsx +91 -91
- package/src/packages/components/useNotice/NoticeContainer.tsx +65 -65
- package/src/packages/components/useNotice/NoticeManager.tsx +58 -58
- package/src/packages/components/useNotice/index.tsx +42 -42
- package/src/packages/components/useNotice/noitice.service.utils.tsx +48 -48
- package/src/packages/components/useNotice/notice.scss +158 -158
- package/src/packages/components/usePageRender/index.tsx +3 -3
- package/src/packages/components/usePageRenderContext/index.tsx +8 -8
- package/src/packages/components/usePopup/PopupItem.tsx +426 -426
- package/src/packages/components/usePopup/index.tsx +1 -1
- package/src/packages/components/usePopup/popup-item.scss +252 -252
- package/src/packages/components/usePopup/refresh/applyPosition.ts +61 -61
- package/src/packages/components/usePopup/refresh/calcPosition.ts +85 -85
- package/src/packages/components/usePopup/refresh/refreshArrow.ts +112 -112
- package/src/packages/components/usePopup/refresh/refreshPopup.ts +77 -77
- package/src/packages/components/usePopup/trigger/useManagerTrigger.click.tsx +56 -56
- package/src/packages/components/usePopup/trigger/useManagerTrigger.clickOutside.tsx +44 -44
- package/src/packages/components/usePopup/trigger/useManagerTrigger.contextmenu.tsx +59 -59
- package/src/packages/components/usePopup/trigger/useManagerTrigger.focus.tsx +30 -30
- package/src/packages/components/usePopup/trigger/useManagerTrigger.hover.tsx +60 -60
- package/src/packages/components/usePopup/trigger/usePopupTrigger.tsx +56 -56
- package/src/packages/components/usePopup/trigger/useReferenceTrigger.tsx +84 -84
- package/src/packages/components/usePopup/usePopup.tsx +73 -73
- package/src/packages/components/usePopup/usePopupManager.tsx +314 -314
- package/src/packages/components/usePopup/utils/closeAllPopper.ts +5 -5
- package/src/packages/components/usePopup/utils/createPopperAttrsGetter.ts +5 -5
- package/src/packages/components/usePopup/utils/createPopupManagerHooks.tsx +65 -65
- package/src/packages/components/usePopup/utils/decodePlacement.ts +16 -16
- package/src/packages/components/usePopup/utils/getAvailableDirection.ts +91 -91
- package/src/packages/components/usePopup/utils/getBoundary.ts +25 -25
- package/src/packages/components/usePopup/utils/getRects.ts +24 -24
- package/src/packages/components/usePopup/utils/handleDirection.ts +10 -10
- package/src/packages/components/usePopup/utils/ids2map.ts +11 -11
- package/src/packages/components/usePopup/utils/popup.utils.ts +236 -236
- package/src/packages/components/usePopup/utils/stopPopup.ts +7 -7
- package/src/packages/components/usePopupEditor/index.tsx +116 -116
- package/src/packages/components/usePopupEditor/popup-editor.utils.ts +15 -15
- package/src/packages/components/usePopupManager/index.ts +5 -5
- package/src/packages/components/usePopupTrigger/index.tsx +5 -5
- package/src/packages/components/useReferenceTrigger/index.tsx +5 -5
- package/src/packages/components/useTooltip/index.tsx +188 -188
- package/src/packages/components/useWatchAutoClear/index.ts +5 -5
- package/src/packages/directives/ClickWave/click-wave.scss +57 -57
- package/src/packages/directives/ClickWave/index.tsx +78 -78
- package/src/packages/directives/ResizeDetector/index.tsx +107 -100
- package/src/packages/entry.tsx +229 -227
- package/src/packages/i18n/i18n.utils.ts +272 -272
- package/src/packages/i18n/index.ts +5 -5
- package/src/packages/i18n/lang/en-us.ts +307 -307
- package/src/packages/i18n/lang/zh-cn.ts +314 -314
- package/src/packages/index.tsx +5 -5
- package/src/packages/styles/application/application.public.scss +8 -8
- package/src/packages/styles/application/application.public.transition.scss +90 -90
- package/src/packages/styles/global.import.scss +133 -133
- package/src/packages/uses/createInputPopperAttrs.ts +60 -60
- package/src/packages/uses/useCollapseStyles.tsx +56 -56
- package/src/packages/uses/useDragHorizontalScroll.ts +82 -82
- package/src/packages/uses/useEdit.ts +89 -89
- package/src/packages/uses/useFocusHandler.ts +60 -60
- package/src/packages/uses/useFunctionWrapper.ts +29 -29
- package/src/packages/uses/useMultipleModel.tsx +63 -63
- package/src/packages/uses/useRenderReference.tsx +32 -32
- package/src/packages/uses/useStyle.tsx +78 -78
- package/src/packages/utils/ClientZoom.ts +50 -50
- package/src/packages/utils/ComponentUtils.ts +10 -10
- package/src/packages/utils/FixInput.ts +3 -3
- package/src/packages/utils/InnerTransition.ts +13 -13
- package/src/packages/utils/LoadingText.ts +11 -11
- package/src/packages/utils/OpenController.ts +15 -15
- package/src/packages/utils/buildCycleIndexList.ts +31 -31
- package/src/packages/utils/clearFields.ts +16 -16
- package/src/packages/utils/color.utils.ts +189 -189
- package/src/packages/utils/combineURL.ts +5 -5
- package/src/packages/utils/constant.tsx +5 -5
- package/src/packages/utils/createAnimate.ts +45 -45
- package/src/packages/utils/createCache.ts +32 -32
- package/src/packages/utils/createDraggier.ts +256 -0
- package/src/packages/utils/createEffectiveHandler.ts +8 -8
- package/src/packages/utils/createError.ts +16 -16
- package/src/packages/utils/createFlagManager.ts +34 -34
- package/src/packages/utils/createKeyHandler.ts +20 -20
- package/src/packages/utils/createProvider.tsx +35 -35
- package/src/packages/utils/customDeepClone.ts +15 -15
- package/src/packages/utils/deepCloneRenderNode.ts +41 -41
- package/src/packages/utils/deepIterateObject.ts +14 -14
- package/src/packages/utils/findReactElement.tsx +76 -76
- package/src/packages/utils/getDeviceInfo.ts +59 -59
- package/src/packages/utils/getElementRect.ts +32 -32
- package/src/packages/utils/getRowEl.ts +33 -33
- package/src/packages/utils/incrementalMerge.ts +8 -8
- package/src/packages/utils/inheritSlots.ts +28 -28
- package/src/packages/utils/installAllIcons.ts +19 -19
- package/src/packages/utils/installAllLazyIcons.ts +17 -17
- package/src/packages/utils/isObjectCommonMatch.ts +21 -21
- package/src/packages/utils/isSSR.tsx +3 -3
- package/src/packages/utils/onParentElementsScroll.tsx +26 -26
- package/src/packages/utils/plainDate.ts +203 -203
- package/src/packages/utils/renderNothing.tsx +1 -1
- package/src/packages/utils/type.ts +11 -11
- package/src/packages/utils/useMove.tsx +78 -78
- package/src/packages/utils/watchEffectAutoClear.ts +28 -28
- package/src/packages/utils/doNothing.ts +0 -3
- package/src/packages/utils/findParentElement.ts +0 -12
- package/src/packages/utils/formatServiceOptions.ts +0 -7
- package/src/packages/utils/getElement.ts +0 -17
- package/src/packages/utils/getElementParents.ts +0 -9
- package/src/packages/utils/getRectAutoFormat.ts +0 -9
- package/src/packages/utils/getScrollParent.ts +0 -11
- package/src/packages/utils/iterate.ts +0 -53
- package/src/packages/utils/notNull.ts +0 -9
- package/src/packages/utils/omit.ts +0 -6
- package/src/packages/utils/pick.ts +0 -11
- package/src/packages/utils/runOnce.tsx +0 -14
@@ -1,591 +1,591 @@
|
|
1
|
-
import {computed, CSSProperties, designComponent, getComponentCls, iHTMLDivElement, iMouseEvent, isReact, iTouchEvent, onBeforeUnmount, PropType, reactive, StyleProperties, useClasses, useModel, useRefs, useStyles,} from 'plain-design-composition';
|
2
|
-
import './carousel.scss';
|
3
|
-
import CarouselItem, {iCarouselItemMeta} from '../CarouselItem';
|
4
|
-
import {createCounter} from 'plain-utils/utils/createCounter';
|
5
|
-
import {Icon} from '../Icon';
|
6
|
-
import {useWatchAutoClear} from '../../utils/watchEffectAutoClear';
|
7
|
-
import {findReactElement} from '../../utils/findReactElement';
|
8
|
-
import {addElementListener} from 'plain-utils/dom/addElementListener';
|
9
|
-
import {createEffects} from "plain-utils/utils/createEffects";
|
10
|
-
import {unit} from "plain-utils/string/unit";
|
11
|
-
import {doNothing} from "
|
12
|
-
import {delay} from "plain-utils/utils/delay";
|
13
|
-
import {Tooltip} from "../Tooltip";
|
14
|
-
import {buildCycleIndexList} from "../../utils/buildCycleIndexList";
|
15
|
-
import {ComponentUtils} from "../../utils/ComponentUtils";
|
16
|
-
import {addWindowListener} from "plain-utils/dom/addWindowListener";
|
17
|
-
|
18
|
-
export const Carousel = designComponent({
|
19
|
-
name: 'carousel',
|
20
|
-
provideRefer: true,
|
21
|
-
props: {
|
22
|
-
modelValue: { type: [String, Number] }, // 双向绑定值
|
23
|
-
vertical: { type: Boolean }, // 纵向轮播
|
24
|
-
card: { type: Boolean }, // 卡片形式切换
|
25
|
-
noIndicator: { type: Boolean }, // 禁用指示器
|
26
|
-
indicatorStyle: { type: String as PropType<'line' | 'dot' | 'text'>, default: 'line' }, // 指示器类型
|
27
|
-
switchButton: { type: Boolean, default: true }, // 显示切换按钮
|
28
|
-
largeSwitchButton: { type: Boolean }, // 使用大型的切换按钮
|
29
|
-
autoPlay: { type: [Boolean, Number] as PropType<number | boolean>, default: true }, // 自动播放
|
30
|
-
height: { type: [String, Number] }, // 固定高度
|
31
|
-
disableSwiper: { type: Boolean }, // 禁用拂动切换
|
32
|
-
indicatorTrigger: { type: String as PropType<'click' | 'hover'>, default: 'click' }, // 指示器的触发类型,click点击,hover鼠标悬浮
|
33
|
-
alignItems: { type: String as PropType<CSSProperties['alignItems']>, default: 'center' }, // 每个子元素的对其方式
|
34
|
-
fullHeight: { type: Boolean }, // 适配容器高度,开启这个特性会限制每个子元素的高度为容器高度
|
35
|
-
prevSwitchButtonTip: { type: String }, // 上一页按钮提示文本
|
36
|
-
nextSwitchButtonTip: { type: String }, // 下一页按钮提示文本
|
37
|
-
},
|
38
|
-
emits: {
|
39
|
-
onUpdateModelValue: (val?: string | number) => true
|
40
|
-
},
|
41
|
-
scopeSlots: {
|
42
|
-
indicator: (scope: {
|
43
|
-
total: number;
|
44
|
-
activeIndex: number;
|
45
|
-
prevIndex: number;
|
46
|
-
nextIndex: number;
|
47
|
-
}) => {}
|
48
|
-
},
|
49
|
-
slots: ['default', 'cover'],
|
50
|
-
setup({ props, event: { emit }, slots, scopeSlots }) {
|
51
|
-
|
52
|
-
const { refs, onRef } = useRefs({ el: iHTMLDivElement });
|
53
|
-
|
54
|
-
const id = nextCarouselId();
|
55
|
-
|
56
|
-
const model = useModel(() => props.modelValue, emit.onUpdateModelValue, {
|
57
|
-
onChange: async (newVal, oldVal) => {
|
58
|
-
methods.show(newVal, oldVal, false);
|
59
|
-
}
|
60
|
-
});
|
61
|
-
|
62
|
-
const direction = computed(() =>
|
63
|
-
/*方向,是横向还是纵向*/
|
64
|
-
props.vertical ? ('vertical' as const) : ('horizontal' as const)
|
65
|
-
);
|
66
|
-
|
67
|
-
const classes = useClasses(() => [
|
68
|
-
getComponentCls('carousel'),
|
69
|
-
`carousel-${direction.value}`,
|
70
|
-
{
|
71
|
-
'carousel-card': props.card,
|
72
|
-
'carousel-disable-swiper': props.disableSwiper,
|
73
|
-
'carousel-touching': !!touchHandler.touchState.touching,
|
74
|
-
'carousel-full-height': !!props.fullHeight,
|
75
|
-
'carousel-fixed-height': !!props.height,
|
76
|
-
'carousel-large-switch-button': !!props.largeSwitchButton
|
77
|
-
}
|
78
|
-
]);
|
79
|
-
|
80
|
-
const styles = useStyles((style) => {
|
81
|
-
if (!!props.height) {
|
82
|
-
style.height = unit(props.height);
|
83
|
-
}
|
84
|
-
});
|
85
|
-
|
86
|
-
const state = reactive({
|
87
|
-
/*临时绑定值,不直接使用modelValue,这个值与baseLeft,baseLeftCount对应,同时变化*/
|
88
|
-
tempValue: model.value,
|
89
|
-
});
|
90
|
-
|
91
|
-
const utils = {
|
92
|
-
/**
|
93
|
-
* 获取container item的style
|
94
|
-
* @author 韦胜健
|
95
|
-
* @date 2023/4/27 23:13
|
96
|
-
*/
|
97
|
-
getItemStyles(itemMeta: iCarouselItemMeta) {
|
98
|
-
const style = {} as StyleProperties;
|
99
|
-
let base = -itemMeta.props.index; // 令item偏移到第一个item的位置
|
100
|
-
|
101
|
-
if (itemMeta.props.distance < 0) {
|
102
|
-
base--;
|
103
|
-
} else if (itemMeta.props.distance > 0) {
|
104
|
-
base++;
|
105
|
-
}
|
106
|
-
|
107
|
-
const isMoving = Math.abs(itemMeta.props.distance) <= 1;
|
108
|
-
|
109
|
-
/*实际偏移位置*/
|
110
|
-
style.transform = props.vertical
|
111
|
-
? `translate3d(0,calc(${base * 100}% + ${!isMoving ? 0 : (touchHandler.touchState.touching?.moveTop || 0)}px),0)`
|
112
|
-
: `translate3d(calc(${base * 100}% + ${!isMoving ? 0 : (touchHandler.touchState.touching?.moveLeft || 0)}px),0,0)`;
|
113
|
-
|
114
|
-
/*既不是prev,也不是next以及active的item不显示,但是占用空间,以实现自动撑开高度的效果*/
|
115
|
-
if (Math.abs(itemMeta.props.distance) > 1) {
|
116
|
-
style.opacity = '0';
|
117
|
-
style.transition = 'none';
|
118
|
-
style.pointerEvents = 'none';
|
119
|
-
}
|
120
|
-
if (touchHandler.touchState.touching) {
|
121
|
-
style.transition = 'none';
|
122
|
-
}
|
123
|
-
|
124
|
-
if (itemMeta.props.distance != 0) {
|
125
|
-
/*如果一个元素从循环列表的一端跑到另一端,则禁用过度动画*/
|
126
|
-
if (!!tempState.prev && !!tempState.curr) {
|
127
|
-
|
128
|
-
/*上一次在循环列表的左边还是右边*/
|
129
|
-
const prevPos: 'left' | 'right' | null = ((() => {
|
130
|
-
if (itemMeta.props.index === tempState.prev!.current) {return null;}
|
131
|
-
const prevCurrIndex = tempState.prev!.cycleIndexList.indexOf(tempState.prev!.current);
|
132
|
-
const prevItemIndex = tempState.prev!.cycleIndexList.indexOf(itemMeta.props.index);
|
133
|
-
return prevCurrIndex > prevItemIndex ? 'left' : 'right';
|
134
|
-
})());
|
135
|
-
|
136
|
-
/*这一次在循环列表的左边还是右边*/
|
137
|
-
const nextPos: 'left' | 'right' | null = ((() => {
|
138
|
-
if (itemMeta.props.index === tempState.curr!.current) {return null;}
|
139
|
-
const nextCurrIndex = tempState.curr!.cycleIndexList.indexOf(tempState.curr!.current);
|
140
|
-
const nextItemIndex = tempState.curr!.cycleIndexList.indexOf(itemMeta.props.index);
|
141
|
-
return nextCurrIndex > nextItemIndex ? 'left' : 'right';
|
142
|
-
})());
|
143
|
-
|
144
|
-
/*两次渲染的左右位置不同的话,则禁用过度动画*/
|
145
|
-
if (!!prevPos && !!nextPos && prevPos !== nextPos) {
|
146
|
-
style.transition = 'none';
|
147
|
-
}
|
148
|
-
}
|
149
|
-
}
|
150
|
-
|
151
|
-
style.zIndex = itemProps.length - Math.abs(itemMeta.props.distance);
|
152
|
-
return style;
|
153
|
-
}
|
154
|
-
};
|
155
|
-
|
156
|
-
const touchHandler = (() => {
|
157
|
-
let touchState = reactive({
|
158
|
-
/*拖拽开始时x定位*/
|
159
|
-
startX: null as null | number,
|
160
|
-
/*拖拽开始时y定位*/
|
161
|
-
startY: null as null | number,
|
162
|
-
/*拖拽的状态,拖拽开始时偏移大于5个px开始计算*/
|
163
|
-
touching: null as null | {
|
164
|
-
/*拖拽开始时container的left偏移量*/
|
165
|
-
startLeft: number;
|
166
|
-
/*拖拽 过程中container的left偏移量*/
|
167
|
-
moveLeft: number;
|
168
|
-
/*拖拽开始时container的top偏移量*/
|
169
|
-
startTop: number;
|
170
|
-
/*拖拽 过程中container的top偏移量*/
|
171
|
-
moveTop: number;
|
172
|
-
}
|
173
|
-
});
|
174
|
-
|
175
|
-
/**
|
176
|
-
* 拖拽开始
|
177
|
-
* @author 韦胜健
|
178
|
-
* @date 2023/4/27 23:17
|
179
|
-
*/
|
180
|
-
const touchstart = (e: TouchEvent | MouseEvent) => {
|
181
|
-
|
182
|
-
e.preventDefault();
|
183
|
-
e.stopPropagation();
|
184
|
-
|
185
|
-
const { effects: draggierEffects } = createEffects();
|
186
|
-
|
187
|
-
if (props.vertical) {
|
188
|
-
touchHandler.touchState.startY = 'touches' in e ? e.touches[0].clientY : e.clientY;
|
189
|
-
} else {
|
190
|
-
touchHandler.touchState.startX = 'touches' in e ? e.touches[0].clientX : e.clientX;
|
191
|
-
}
|
192
|
-
|
193
|
-
/**
|
194
|
-
* 拖拽移动
|
195
|
-
* @author 韦胜健
|
196
|
-
* @date 2023/4/27 23:17
|
197
|
-
*/
|
198
|
-
const touchmove = (e: TouchEvent | MouseEvent) => {
|
199
|
-
if (props.disableSwiper) {
|
200
|
-
return;
|
201
|
-
}
|
202
|
-
if (props.vertical) {
|
203
|
-
const durY = ('touches' in e ? e.touches[0].clientY : e.clientY) - touchHandler.touchState.startY!;
|
204
|
-
if (!touchState.touching) {
|
205
|
-
if (Math.abs(durY) > 5) {
|
206
|
-
touchState.touching = {
|
207
|
-
startLeft: 0,
|
208
|
-
moveLeft: 0,
|
209
|
-
startTop: 0,
|
210
|
-
moveTop: 0,
|
211
|
-
};
|
212
|
-
draggierEffects.push(touchend);
|
213
|
-
}
|
214
|
-
}
|
215
|
-
if (touchState.touching) {
|
216
|
-
touchState.touching.moveTop = touchState.touching.startTop + durY;
|
217
|
-
}
|
218
|
-
} else {
|
219
|
-
const durX = ('touches' in e ? e.touches[0].clientX : e.clientX) - touchHandler.touchState.startX!;
|
220
|
-
if (!touchState.touching) {
|
221
|
-
if (Math.abs(durX) > 5) {
|
222
|
-
touchState.touching = {
|
223
|
-
startLeft: 0,
|
224
|
-
moveLeft: 0,
|
225
|
-
startTop: 0,
|
226
|
-
moveTop: 0,
|
227
|
-
};
|
228
|
-
draggierEffects.push(touchend);
|
229
|
-
}
|
230
|
-
}
|
231
|
-
if (touchState.touching) {
|
232
|
-
touchState.touching.moveLeft = touchState.touching.startLeft + durX;
|
233
|
-
}
|
234
|
-
}
|
235
|
-
};
|
236
|
-
|
237
|
-
/**
|
238
|
-
* 拖拽结束
|
239
|
-
* @author 韦胜健
|
240
|
-
* @date 2023/4/27 23:17
|
241
|
-
*/
|
242
|
-
const touchend = async (e: iTouchEvent | iMouseEvent) => {
|
243
|
-
if (!touchState.touching) {
|
244
|
-
return;
|
245
|
-
}
|
246
|
-
let dur = props.vertical
|
247
|
-
? touchState.touching.moveTop - touchState.touching.startTop!
|
248
|
-
: touchState.touching.moveLeft - touchState.touching.startLeft!;
|
249
|
-
const info = await ComponentUtils.getElInfo(`#${id}`);
|
250
|
-
const duration = props.vertical ? info.height / 4 : info.width / 4;
|
251
|
-
|
252
|
-
let activeIndex = itemProps!.findIndex((i) => i == state.tempValue);
|
253
|
-
if (activeIndex === -1) {
|
254
|
-
activeIndex = 0;
|
255
|
-
}
|
256
|
-
if (itemProps.length <= 1) {
|
257
|
-
/**
|
258
|
-
* 轮播节点少于等于1个,不做切换
|
259
|
-
* @author 韦胜健
|
260
|
-
* @date 2024/1/4 10:57
|
261
|
-
*/
|
262
|
-
dur = 0;
|
263
|
-
} else {
|
264
|
-
/**
|
265
|
-
* 当轮播节点数量少于或者等于2时,
|
266
|
-
* 如果是第一个节点后移,不做切换
|
267
|
-
* 如果是最后一个节点前移,不做切换
|
268
|
-
* @author 韦胜健
|
269
|
-
* @date 2024/1/4 10:56
|
270
|
-
*/
|
271
|
-
if (itemProps.length <= 2) {
|
272
|
-
if (dur < 0 && activeIndex === itemProps.length - 1) {
|
273
|
-
dur = 0;
|
274
|
-
} else if (dur > 0 && activeIndex === 0) {
|
275
|
-
dur = 0;
|
276
|
-
}
|
277
|
-
}
|
278
|
-
}
|
279
|
-
if (dur > duration) {
|
280
|
-
/*上一张*/
|
281
|
-
activeIndex--;
|
282
|
-
} else if (dur < -duration) {
|
283
|
-
/*下一张*/
|
284
|
-
activeIndex++;
|
285
|
-
}
|
286
|
-
if (activeIndex < 0) {
|
287
|
-
activeIndex = itemProps!.length - 1;
|
288
|
-
}
|
289
|
-
if (activeIndex >= itemProps!.length) {
|
290
|
-
activeIndex = 0;
|
291
|
-
}
|
292
|
-
state.tempValue = itemProps![activeIndex];
|
293
|
-
model.value = state.tempValue;
|
294
|
-
|
295
|
-
reset();
|
296
|
-
};
|
297
|
-
|
298
|
-
draggierEffects.push(addWindowListener('mousemove', touchmove));
|
299
|
-
draggierEffects.push(addWindowListener('touchmove', touchmove));
|
300
|
-
draggierEffects.push(addWindowListener('mouseup', draggierEffects.clear));
|
301
|
-
draggierEffects.push(addWindowListener('touchend', draggierEffects.clear));
|
302
|
-
};
|
303
|
-
|
304
|
-
const reset = () => {
|
305
|
-
/*重置拖拽状态*/
|
306
|
-
touchState.startX = null;
|
307
|
-
touchState.startY = null;
|
308
|
-
touchState.touching = null;
|
309
|
-
};
|
310
|
-
|
311
|
-
return { touchstart, touchState, reset };
|
312
|
-
})();
|
313
|
-
|
314
|
-
let itemProps = [] as any[];
|
315
|
-
|
316
|
-
const play = (() => {
|
317
|
-
let timer: any = null;
|
318
|
-
const start = () => {
|
319
|
-
if (!!timer) {
|
320
|
-
return;
|
321
|
-
}
|
322
|
-
timer = setInterval(
|
323
|
-
() => {
|
324
|
-
methods.next();
|
325
|
-
},
|
326
|
-
typeof props.autoPlay === 'boolean' ? 3000 : props.autoPlay
|
327
|
-
);
|
328
|
-
};
|
329
|
-
|
330
|
-
const stop = () => {
|
331
|
-
if (!!timer) {
|
332
|
-
clearInterval(timer);
|
333
|
-
timer = null;
|
334
|
-
}
|
335
|
-
};
|
336
|
-
|
337
|
-
return { start, stop };
|
338
|
-
})();
|
339
|
-
|
340
|
-
const methods = {
|
341
|
-
/**
|
342
|
-
* 切换到上一张
|
343
|
-
* @author 韦胜健
|
344
|
-
* @date 2023/4/28 16:21
|
345
|
-
*/
|
346
|
-
prev: async (): Promise<void> => {
|
347
|
-
/*当前只有一个元素,不做处理*/
|
348
|
-
if (itemProps.length < 2) {return;}
|
349
|
-
|
350
|
-
if (!itemProps) {
|
351
|
-
return;
|
352
|
-
}
|
353
|
-
let activeIndex = itemProps.findIndex((i) => i === state.tempValue);
|
354
|
-
if (activeIndex === -1) {
|
355
|
-
activeIndex = 0;
|
356
|
-
}
|
357
|
-
|
358
|
-
/*当前只有两个元素,并且已经是第一个元素了,点击prev的时候转为next*/
|
359
|
-
if (activeIndex === 0 && itemProps.length === 2) {
|
360
|
-
return methods.next();
|
361
|
-
}
|
362
|
-
let prevIndex = activeIndex == 0 ? itemProps.length - 1 : activeIndex - 1;
|
363
|
-
|
364
|
-
state.tempValue = itemProps[prevIndex];
|
365
|
-
model.value = state.tempValue;
|
366
|
-
|
367
|
-
if (props.autoPlay) {
|
368
|
-
methods.stop();
|
369
|
-
methods.start();
|
370
|
-
}
|
371
|
-
},
|
372
|
-
/**
|
373
|
-
* 切换到下一张
|
374
|
-
* @author 韦胜健
|
375
|
-
* @date 2023/4/28 16:21
|
376
|
-
*/
|
377
|
-
next: async () => {
|
378
|
-
/*当前只有一个元素,不做处理*/
|
379
|
-
if (itemProps.length < 2) {return;}
|
380
|
-
if (!itemProps) {
|
381
|
-
return;
|
382
|
-
}
|
383
|
-
let activeIndex = itemProps.findIndex((i) => i === state.tempValue);
|
384
|
-
if (activeIndex === -1) {
|
385
|
-
activeIndex = 0;
|
386
|
-
}
|
387
|
-
|
388
|
-
/*当前只有两个元素,并且已经是最后一个元素了,点击next的时候转为prev*/
|
389
|
-
if (activeIndex === itemProps.length - 1 && itemProps.length === 2) {
|
390
|
-
return methods.prev();
|
391
|
-
}
|
392
|
-
let nextIndex = activeIndex == itemProps.length - 1 ? 0 : activeIndex + 1;
|
393
|
-
|
394
|
-
state.tempValue = itemProps[nextIndex];
|
395
|
-
model.value = state.tempValue;
|
396
|
-
|
397
|
-
if (props.autoPlay) {
|
398
|
-
methods.stop();
|
399
|
-
methods.start();
|
400
|
-
}
|
401
|
-
},
|
402
|
-
...play,
|
403
|
-
show: async (newVal: any, oldVal: any, autoEmit = true) => {
|
404
|
-
if (autoEmit && newVal === oldVal) {
|
405
|
-
return;
|
406
|
-
}
|
407
|
-
/*更新tempValue*/
|
408
|
-
state.tempValue = newVal;
|
409
|
-
if (autoEmit) {
|
410
|
-
model.value = state.tempValue;
|
411
|
-
}
|
412
|
-
if (!!props.autoPlay) {
|
413
|
-
methods.stop();
|
414
|
-
methods.start();
|
415
|
-
}
|
416
|
-
},
|
417
|
-
};
|
418
|
-
|
419
|
-
const handler = {
|
420
|
-
onDoubleClickSwitchButton: (e: iMouseEvent) => {
|
421
|
-
e.stopPropagation();
|
422
|
-
}
|
423
|
-
};
|
424
|
-
|
425
|
-
useWatchAutoClear(
|
426
|
-
/*拖拽过程中禁用自动播放*/
|
427
|
-
() => props.autoPlay && !touchHandler.touchState.touching,
|
428
|
-
(autoPlay) => {
|
429
|
-
if (!!autoPlay) {
|
430
|
-
methods.start();
|
431
|
-
}
|
432
|
-
return () => {
|
433
|
-
methods.stop();
|
434
|
-
};
|
435
|
-
}
|
436
|
-
);
|
437
|
-
|
438
|
-
const { effects: listenerEffects } = createEffects();
|
439
|
-
useWatchAutoClear(() => props.disableSwiper, disableSwiper => {
|
440
|
-
listenerEffects.clear();
|
441
|
-
if (disableSwiper) {
|
442
|
-
touchHandler.reset();
|
443
|
-
return doNothing;
|
444
|
-
}
|
445
|
-
delay().then(() => {
|
446
|
-
listenerEffects.push(addElementListener(refs.el!, 'touchstart', touchHandler.touchstart, { passive: false }));
|
447
|
-
listenerEffects.push(addElementListener(refs.el!, 'mousedown', touchHandler.touchstart, { passive: false }));
|
448
|
-
});
|
449
|
-
return listenerEffects.clear;
|
450
|
-
});
|
451
|
-
|
452
|
-
onBeforeUnmount(() => {
|
453
|
-
play.stop();
|
454
|
-
listenerEffects.clear();
|
455
|
-
});
|
456
|
-
|
457
|
-
let tempState = {
|
458
|
-
/*上一次渲染的循环列表数据*/
|
459
|
-
prev: null as null | {
|
460
|
-
current: number,
|
461
|
-
cycleIndexList: number[],
|
462
|
-
},
|
463
|
-
/*下一次渲染的循环列表数据*/
|
464
|
-
curr: null as null | {
|
465
|
-
current: number,
|
466
|
-
cycleIndexList: number[],
|
467
|
-
}
|
468
|
-
};
|
469
|
-
|
470
|
-
return {
|
471
|
-
refer: {
|
472
|
-
utils,
|
473
|
-
methods,
|
474
|
-
refs,
|
475
|
-
},
|
476
|
-
render: () => {
|
477
|
-
const content = slots.default() as any;
|
478
|
-
|
479
|
-
const items: any[] = !content
|
480
|
-
? []
|
481
|
-
: findReactElement(content, (i: any) => i.type?.name === CarouselItem.name) || [];
|
482
|
-
|
483
|
-
itemProps = items.map((i, index) => i.props?.val == null ? index : i.props?.val);
|
484
|
-
|
485
|
-
const total = items.length;
|
486
|
-
const activeIndex = !state.tempValue
|
487
|
-
? 0
|
488
|
-
: itemProps.findIndex((i) => i === state.tempValue);
|
489
|
-
|
490
|
-
const { index2distance, cycleIndexList, currentIndexInCycle } = buildCycleIndexList({ length: itemProps.length, current: activeIndex });
|
491
|
-
const prevIndex = cycleIndexList[currentIndexInCycle] - 1;
|
492
|
-
const nextIndex = cycleIndexList[currentIndexInCycle] + 1;
|
493
|
-
|
494
|
-
if (!tempState.curr || tempState.curr.current !== activeIndex) {
|
495
|
-
tempState.prev = tempState.curr;
|
496
|
-
tempState.curr = {
|
497
|
-
current: activeIndex,
|
498
|
-
cycleIndexList: cycleIndexList,
|
499
|
-
};
|
500
|
-
}
|
501
|
-
|
502
|
-
return (
|
503
|
-
<div
|
504
|
-
id={id}
|
505
|
-
className={classes.value}
|
506
|
-
style={styles.value}
|
507
|
-
ref={onRef.el}
|
508
|
-
>
|
509
|
-
<div className="carousel-container">
|
510
|
-
{items.map((Item: any, index: number) => {
|
511
|
-
const ItemComp = isReact ? Item.type : Item;
|
512
|
-
return (
|
513
|
-
<ItemComp
|
514
|
-
{...Item.props}
|
515
|
-
index={index}
|
516
|
-
distance={index2distance[index]}
|
517
|
-
alignItems={props.alignItems}
|
518
|
-
key={index}
|
519
|
-
/>
|
520
|
-
);
|
521
|
-
})}
|
522
|
-
</div>
|
523
|
-
{!props.noIndicator &&
|
524
|
-
scopeSlots.indicator(
|
525
|
-
{ total, activeIndex, prevIndex, nextIndex },
|
526
|
-
(() => {
|
527
|
-
return (
|
528
|
-
<div
|
529
|
-
className={`carousel-indicator carousel-indicator-style-${props.indicatorStyle}`} style={{ zIndex: itemProps.length + 2 }}>
|
530
|
-
{(() => {
|
531
|
-
if (props.indicatorStyle === 'text') {
|
532
|
-
return `${activeIndex + 1} / ${total}`;
|
533
|
-
} else {
|
534
|
-
return itemProps.map((_, index) => (
|
535
|
-
<div
|
536
|
-
key={index}
|
537
|
-
{...props.indicatorTrigger === 'click' ?
|
538
|
-
{ onClick: () => methods.show(itemProps[index], model.value) } :
|
539
|
-
{ onMouseEnter: () => methods.show(itemProps[index], model.value) }}
|
540
|
-
className={`carousel-indicator-item ${
|
541
|
-
index === activeIndex
|
542
|
-
? 'carousel-indicator-item-active'
|
543
|
-
: index === prevIndex
|
544
|
-
? 'carousel-indicator-item-prev'
|
545
|
-
: index === nextIndex
|
546
|
-
? 'carousel-indicator-item-next'
|
547
|
-
: ''
|
548
|
-
}`}
|
549
|
-
/>
|
550
|
-
));
|
551
|
-
}
|
552
|
-
})()}
|
553
|
-
</div>
|
554
|
-
);
|
555
|
-
})()
|
556
|
-
)}
|
557
|
-
{props.switchButton && (
|
558
|
-
<div className="carousel-switch-button" style={{ zIndex: itemProps.length + 2 }}>
|
559
|
-
{(() => {
|
560
|
-
const prevButton = (
|
561
|
-
<div className="carousel-switch-button-prev" onClick={methods.prev} onDoubleClick={handler.onDoubleClickSwitchButton}>
|
562
|
-
<Icon icon={props.vertical ? 'pi-up' : 'pi-left'}/>
|
563
|
-
</div>
|
564
|
-
);
|
565
|
-
return !!props.prevSwitchButtonTip ? <Tooltip message={props.prevSwitchButtonTip} placement="bottom-start">{prevButton}</Tooltip> : prevButton;
|
566
|
-
})()}
|
567
|
-
{(() => {
|
568
|
-
const nextButton = (
|
569
|
-
<div className="carousel-switch-button-next" onClick={methods.next} onDoubleClick={handler.onDoubleClickSwitchButton}>
|
570
|
-
<Icon icon={props.vertical ? 'pi-down' : 'pi-right'}/>
|
571
|
-
</div>
|
572
|
-
);
|
573
|
-
return !!props.nextSwitchButtonTip ? <Tooltip message={props.nextSwitchButtonTip} placement="bottom-end">{nextButton}</Tooltip> : nextButton;
|
574
|
-
})()}
|
575
|
-
</div>
|
576
|
-
)}
|
577
|
-
{slots.cover.isExist() && (
|
578
|
-
<div className="carousel-cover" style={{ zIndex: itemProps.length + 2 }}>
|
579
|
-
{slots.cover()}
|
580
|
-
</div>
|
581
|
-
)}
|
582
|
-
</div>
|
583
|
-
);
|
584
|
-
}
|
585
|
-
};
|
586
|
-
}
|
587
|
-
});
|
588
|
-
|
589
|
-
const nextCarouselId = createCounter('carousel');
|
590
|
-
|
591
|
-
export default Carousel;
|
1
|
+
import {computed, CSSProperties, designComponent, getComponentCls, iHTMLDivElement, iMouseEvent, isReact, iTouchEvent, onBeforeUnmount, PropType, reactive, StyleProperties, useClasses, useModel, useRefs, useStyles,} from 'plain-design-composition';
|
2
|
+
import './carousel.scss';
|
3
|
+
import CarouselItem, {iCarouselItemMeta} from '../CarouselItem';
|
4
|
+
import {createCounter} from 'plain-utils/utils/createCounter';
|
5
|
+
import {Icon} from '../Icon';
|
6
|
+
import {useWatchAutoClear} from '../../utils/watchEffectAutoClear';
|
7
|
+
import {findReactElement} from '../../utils/findReactElement';
|
8
|
+
import {addElementListener} from 'plain-utils/dom/addElementListener';
|
9
|
+
import {createEffects} from "plain-utils/utils/createEffects";
|
10
|
+
import {unit} from "plain-utils/string/unit";
|
11
|
+
import {doNothing} from "plain-utils/utils/doNothing";
|
12
|
+
import {delay} from "plain-utils/utils/delay";
|
13
|
+
import {Tooltip} from "../Tooltip";
|
14
|
+
import {buildCycleIndexList} from "../../utils/buildCycleIndexList";
|
15
|
+
import {ComponentUtils} from "../../utils/ComponentUtils";
|
16
|
+
import {addWindowListener} from "plain-utils/dom/addWindowListener";
|
17
|
+
|
18
|
+
export const Carousel = designComponent({
|
19
|
+
name: 'carousel',
|
20
|
+
provideRefer: true,
|
21
|
+
props: {
|
22
|
+
modelValue: { type: [String, Number] }, // 双向绑定值
|
23
|
+
vertical: { type: Boolean }, // 纵向轮播
|
24
|
+
card: { type: Boolean }, // 卡片形式切换
|
25
|
+
noIndicator: { type: Boolean }, // 禁用指示器
|
26
|
+
indicatorStyle: { type: String as PropType<'line' | 'dot' | 'text'>, default: 'line' }, // 指示器类型
|
27
|
+
switchButton: { type: Boolean, default: true }, // 显示切换按钮
|
28
|
+
largeSwitchButton: { type: Boolean }, // 使用大型的切换按钮
|
29
|
+
autoPlay: { type: [Boolean, Number] as PropType<number | boolean>, default: true }, // 自动播放
|
30
|
+
height: { type: [String, Number] }, // 固定高度
|
31
|
+
disableSwiper: { type: Boolean }, // 禁用拂动切换
|
32
|
+
indicatorTrigger: { type: String as PropType<'click' | 'hover'>, default: 'click' }, // 指示器的触发类型,click点击,hover鼠标悬浮
|
33
|
+
alignItems: { type: String as PropType<CSSProperties['alignItems']>, default: 'center' }, // 每个子元素的对其方式
|
34
|
+
fullHeight: { type: Boolean }, // 适配容器高度,开启这个特性会限制每个子元素的高度为容器高度
|
35
|
+
prevSwitchButtonTip: { type: String }, // 上一页按钮提示文本
|
36
|
+
nextSwitchButtonTip: { type: String }, // 下一页按钮提示文本
|
37
|
+
},
|
38
|
+
emits: {
|
39
|
+
onUpdateModelValue: (val?: string | number) => true
|
40
|
+
},
|
41
|
+
scopeSlots: {
|
42
|
+
indicator: (scope: {
|
43
|
+
total: number;
|
44
|
+
activeIndex: number;
|
45
|
+
prevIndex: number;
|
46
|
+
nextIndex: number;
|
47
|
+
}) => {}
|
48
|
+
},
|
49
|
+
slots: ['default', 'cover'],
|
50
|
+
setup({ props, event: { emit }, slots, scopeSlots }) {
|
51
|
+
|
52
|
+
const { refs, onRef } = useRefs({ el: iHTMLDivElement });
|
53
|
+
|
54
|
+
const id = nextCarouselId();
|
55
|
+
|
56
|
+
const model = useModel(() => props.modelValue, emit.onUpdateModelValue, {
|
57
|
+
onChange: async (newVal, oldVal) => {
|
58
|
+
methods.show(newVal, oldVal, false);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
|
62
|
+
const direction = computed(() =>
|
63
|
+
/*方向,是横向还是纵向*/
|
64
|
+
props.vertical ? ('vertical' as const) : ('horizontal' as const)
|
65
|
+
);
|
66
|
+
|
67
|
+
const classes = useClasses(() => [
|
68
|
+
getComponentCls('carousel'),
|
69
|
+
`carousel-${direction.value}`,
|
70
|
+
{
|
71
|
+
'carousel-card': props.card,
|
72
|
+
'carousel-disable-swiper': props.disableSwiper,
|
73
|
+
'carousel-touching': !!touchHandler.touchState.touching,
|
74
|
+
'carousel-full-height': !!props.fullHeight,
|
75
|
+
'carousel-fixed-height': !!props.height,
|
76
|
+
'carousel-large-switch-button': !!props.largeSwitchButton
|
77
|
+
}
|
78
|
+
]);
|
79
|
+
|
80
|
+
const styles = useStyles((style) => {
|
81
|
+
if (!!props.height) {
|
82
|
+
style.height = unit(props.height);
|
83
|
+
}
|
84
|
+
});
|
85
|
+
|
86
|
+
const state = reactive({
|
87
|
+
/*临时绑定值,不直接使用modelValue,这个值与baseLeft,baseLeftCount对应,同时变化*/
|
88
|
+
tempValue: model.value,
|
89
|
+
});
|
90
|
+
|
91
|
+
const utils = {
|
92
|
+
/**
|
93
|
+
* 获取container item的style
|
94
|
+
* @author 韦胜健
|
95
|
+
* @date 2023/4/27 23:13
|
96
|
+
*/
|
97
|
+
getItemStyles(itemMeta: iCarouselItemMeta) {
|
98
|
+
const style = {} as StyleProperties;
|
99
|
+
let base = -itemMeta.props.index; // 令item偏移到第一个item的位置
|
100
|
+
|
101
|
+
if (itemMeta.props.distance < 0) {
|
102
|
+
base--;
|
103
|
+
} else if (itemMeta.props.distance > 0) {
|
104
|
+
base++;
|
105
|
+
}
|
106
|
+
|
107
|
+
const isMoving = Math.abs(itemMeta.props.distance) <= 1;
|
108
|
+
|
109
|
+
/*实际偏移位置*/
|
110
|
+
style.transform = props.vertical
|
111
|
+
? `translate3d(0,calc(${base * 100}% + ${!isMoving ? 0 : (touchHandler.touchState.touching?.moveTop || 0)}px),0)`
|
112
|
+
: `translate3d(calc(${base * 100}% + ${!isMoving ? 0 : (touchHandler.touchState.touching?.moveLeft || 0)}px),0,0)`;
|
113
|
+
|
114
|
+
/*既不是prev,也不是next以及active的item不显示,但是占用空间,以实现自动撑开高度的效果*/
|
115
|
+
if (Math.abs(itemMeta.props.distance) > 1) {
|
116
|
+
style.opacity = '0';
|
117
|
+
style.transition = 'none';
|
118
|
+
style.pointerEvents = 'none';
|
119
|
+
}
|
120
|
+
if (touchHandler.touchState.touching) {
|
121
|
+
style.transition = 'none';
|
122
|
+
}
|
123
|
+
|
124
|
+
if (itemMeta.props.distance != 0) {
|
125
|
+
/*如果一个元素从循环列表的一端跑到另一端,则禁用过度动画*/
|
126
|
+
if (!!tempState.prev && !!tempState.curr) {
|
127
|
+
|
128
|
+
/*上一次在循环列表的左边还是右边*/
|
129
|
+
const prevPos: 'left' | 'right' | null = ((() => {
|
130
|
+
if (itemMeta.props.index === tempState.prev!.current) {return null;}
|
131
|
+
const prevCurrIndex = tempState.prev!.cycleIndexList.indexOf(tempState.prev!.current);
|
132
|
+
const prevItemIndex = tempState.prev!.cycleIndexList.indexOf(itemMeta.props.index);
|
133
|
+
return prevCurrIndex > prevItemIndex ? 'left' : 'right';
|
134
|
+
})());
|
135
|
+
|
136
|
+
/*这一次在循环列表的左边还是右边*/
|
137
|
+
const nextPos: 'left' | 'right' | null = ((() => {
|
138
|
+
if (itemMeta.props.index === tempState.curr!.current) {return null;}
|
139
|
+
const nextCurrIndex = tempState.curr!.cycleIndexList.indexOf(tempState.curr!.current);
|
140
|
+
const nextItemIndex = tempState.curr!.cycleIndexList.indexOf(itemMeta.props.index);
|
141
|
+
return nextCurrIndex > nextItemIndex ? 'left' : 'right';
|
142
|
+
})());
|
143
|
+
|
144
|
+
/*两次渲染的左右位置不同的话,则禁用过度动画*/
|
145
|
+
if (!!prevPos && !!nextPos && prevPos !== nextPos) {
|
146
|
+
style.transition = 'none';
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
style.zIndex = itemProps.length - Math.abs(itemMeta.props.distance);
|
152
|
+
return style;
|
153
|
+
}
|
154
|
+
};
|
155
|
+
|
156
|
+
const touchHandler = (() => {
|
157
|
+
let touchState = reactive({
|
158
|
+
/*拖拽开始时x定位*/
|
159
|
+
startX: null as null | number,
|
160
|
+
/*拖拽开始时y定位*/
|
161
|
+
startY: null as null | number,
|
162
|
+
/*拖拽的状态,拖拽开始时偏移大于5个px开始计算*/
|
163
|
+
touching: null as null | {
|
164
|
+
/*拖拽开始时container的left偏移量*/
|
165
|
+
startLeft: number;
|
166
|
+
/*拖拽 过程中container的left偏移量*/
|
167
|
+
moveLeft: number;
|
168
|
+
/*拖拽开始时container的top偏移量*/
|
169
|
+
startTop: number;
|
170
|
+
/*拖拽 过程中container的top偏移量*/
|
171
|
+
moveTop: number;
|
172
|
+
}
|
173
|
+
});
|
174
|
+
|
175
|
+
/**
|
176
|
+
* 拖拽开始
|
177
|
+
* @author 韦胜健
|
178
|
+
* @date 2023/4/27 23:17
|
179
|
+
*/
|
180
|
+
const touchstart = (e: TouchEvent | MouseEvent) => {
|
181
|
+
|
182
|
+
e.preventDefault();
|
183
|
+
e.stopPropagation();
|
184
|
+
|
185
|
+
const { effects: draggierEffects } = createEffects();
|
186
|
+
|
187
|
+
if (props.vertical) {
|
188
|
+
touchHandler.touchState.startY = 'touches' in e ? e.touches[0].clientY : e.clientY;
|
189
|
+
} else {
|
190
|
+
touchHandler.touchState.startX = 'touches' in e ? e.touches[0].clientX : e.clientX;
|
191
|
+
}
|
192
|
+
|
193
|
+
/**
|
194
|
+
* 拖拽移动
|
195
|
+
* @author 韦胜健
|
196
|
+
* @date 2023/4/27 23:17
|
197
|
+
*/
|
198
|
+
const touchmove = (e: TouchEvent | MouseEvent) => {
|
199
|
+
if (props.disableSwiper) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (props.vertical) {
|
203
|
+
const durY = ('touches' in e ? e.touches[0].clientY : e.clientY) - touchHandler.touchState.startY!;
|
204
|
+
if (!touchState.touching) {
|
205
|
+
if (Math.abs(durY) > 5) {
|
206
|
+
touchState.touching = {
|
207
|
+
startLeft: 0,
|
208
|
+
moveLeft: 0,
|
209
|
+
startTop: 0,
|
210
|
+
moveTop: 0,
|
211
|
+
};
|
212
|
+
draggierEffects.push(touchend);
|
213
|
+
}
|
214
|
+
}
|
215
|
+
if (touchState.touching) {
|
216
|
+
touchState.touching.moveTop = touchState.touching.startTop + durY;
|
217
|
+
}
|
218
|
+
} else {
|
219
|
+
const durX = ('touches' in e ? e.touches[0].clientX : e.clientX) - touchHandler.touchState.startX!;
|
220
|
+
if (!touchState.touching) {
|
221
|
+
if (Math.abs(durX) > 5) {
|
222
|
+
touchState.touching = {
|
223
|
+
startLeft: 0,
|
224
|
+
moveLeft: 0,
|
225
|
+
startTop: 0,
|
226
|
+
moveTop: 0,
|
227
|
+
};
|
228
|
+
draggierEffects.push(touchend);
|
229
|
+
}
|
230
|
+
}
|
231
|
+
if (touchState.touching) {
|
232
|
+
touchState.touching.moveLeft = touchState.touching.startLeft + durX;
|
233
|
+
}
|
234
|
+
}
|
235
|
+
};
|
236
|
+
|
237
|
+
/**
|
238
|
+
* 拖拽结束
|
239
|
+
* @author 韦胜健
|
240
|
+
* @date 2023/4/27 23:17
|
241
|
+
*/
|
242
|
+
const touchend = async (e: iTouchEvent | iMouseEvent) => {
|
243
|
+
if (!touchState.touching) {
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
let dur = props.vertical
|
247
|
+
? touchState.touching.moveTop - touchState.touching.startTop!
|
248
|
+
: touchState.touching.moveLeft - touchState.touching.startLeft!;
|
249
|
+
const info = await ComponentUtils.getElInfo(`#${id}`);
|
250
|
+
const duration = props.vertical ? info.height / 4 : info.width / 4;
|
251
|
+
|
252
|
+
let activeIndex = itemProps!.findIndex((i) => i == state.tempValue);
|
253
|
+
if (activeIndex === -1) {
|
254
|
+
activeIndex = 0;
|
255
|
+
}
|
256
|
+
if (itemProps.length <= 1) {
|
257
|
+
/**
|
258
|
+
* 轮播节点少于等于1个,不做切换
|
259
|
+
* @author 韦胜健
|
260
|
+
* @date 2024/1/4 10:57
|
261
|
+
*/
|
262
|
+
dur = 0;
|
263
|
+
} else {
|
264
|
+
/**
|
265
|
+
* 当轮播节点数量少于或者等于2时,
|
266
|
+
* 如果是第一个节点后移,不做切换
|
267
|
+
* 如果是最后一个节点前移,不做切换
|
268
|
+
* @author 韦胜健
|
269
|
+
* @date 2024/1/4 10:56
|
270
|
+
*/
|
271
|
+
if (itemProps.length <= 2) {
|
272
|
+
if (dur < 0 && activeIndex === itemProps.length - 1) {
|
273
|
+
dur = 0;
|
274
|
+
} else if (dur > 0 && activeIndex === 0) {
|
275
|
+
dur = 0;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
if (dur > duration) {
|
280
|
+
/*上一张*/
|
281
|
+
activeIndex--;
|
282
|
+
} else if (dur < -duration) {
|
283
|
+
/*下一张*/
|
284
|
+
activeIndex++;
|
285
|
+
}
|
286
|
+
if (activeIndex < 0) {
|
287
|
+
activeIndex = itemProps!.length - 1;
|
288
|
+
}
|
289
|
+
if (activeIndex >= itemProps!.length) {
|
290
|
+
activeIndex = 0;
|
291
|
+
}
|
292
|
+
state.tempValue = itemProps![activeIndex];
|
293
|
+
model.value = state.tempValue;
|
294
|
+
|
295
|
+
reset();
|
296
|
+
};
|
297
|
+
|
298
|
+
draggierEffects.push(addWindowListener('mousemove', touchmove));
|
299
|
+
draggierEffects.push(addWindowListener('touchmove', touchmove));
|
300
|
+
draggierEffects.push(addWindowListener('mouseup', draggierEffects.clear));
|
301
|
+
draggierEffects.push(addWindowListener('touchend', draggierEffects.clear));
|
302
|
+
};
|
303
|
+
|
304
|
+
const reset = () => {
|
305
|
+
/*重置拖拽状态*/
|
306
|
+
touchState.startX = null;
|
307
|
+
touchState.startY = null;
|
308
|
+
touchState.touching = null;
|
309
|
+
};
|
310
|
+
|
311
|
+
return { touchstart, touchState, reset };
|
312
|
+
})();
|
313
|
+
|
314
|
+
let itemProps = [] as any[];
|
315
|
+
|
316
|
+
const play = (() => {
|
317
|
+
let timer: any = null;
|
318
|
+
const start = () => {
|
319
|
+
if (!!timer) {
|
320
|
+
return;
|
321
|
+
}
|
322
|
+
timer = setInterval(
|
323
|
+
() => {
|
324
|
+
methods.next();
|
325
|
+
},
|
326
|
+
typeof props.autoPlay === 'boolean' ? 3000 : props.autoPlay
|
327
|
+
);
|
328
|
+
};
|
329
|
+
|
330
|
+
const stop = () => {
|
331
|
+
if (!!timer) {
|
332
|
+
clearInterval(timer);
|
333
|
+
timer = null;
|
334
|
+
}
|
335
|
+
};
|
336
|
+
|
337
|
+
return { start, stop };
|
338
|
+
})();
|
339
|
+
|
340
|
+
const methods = {
|
341
|
+
/**
|
342
|
+
* 切换到上一张
|
343
|
+
* @author 韦胜健
|
344
|
+
* @date 2023/4/28 16:21
|
345
|
+
*/
|
346
|
+
prev: async (): Promise<void> => {
|
347
|
+
/*当前只有一个元素,不做处理*/
|
348
|
+
if (itemProps.length < 2) {return;}
|
349
|
+
|
350
|
+
if (!itemProps) {
|
351
|
+
return;
|
352
|
+
}
|
353
|
+
let activeIndex = itemProps.findIndex((i) => i === state.tempValue);
|
354
|
+
if (activeIndex === -1) {
|
355
|
+
activeIndex = 0;
|
356
|
+
}
|
357
|
+
|
358
|
+
/*当前只有两个元素,并且已经是第一个元素了,点击prev的时候转为next*/
|
359
|
+
if (activeIndex === 0 && itemProps.length === 2) {
|
360
|
+
return methods.next();
|
361
|
+
}
|
362
|
+
let prevIndex = activeIndex == 0 ? itemProps.length - 1 : activeIndex - 1;
|
363
|
+
|
364
|
+
state.tempValue = itemProps[prevIndex];
|
365
|
+
model.value = state.tempValue;
|
366
|
+
|
367
|
+
if (props.autoPlay) {
|
368
|
+
methods.stop();
|
369
|
+
methods.start();
|
370
|
+
}
|
371
|
+
},
|
372
|
+
/**
|
373
|
+
* 切换到下一张
|
374
|
+
* @author 韦胜健
|
375
|
+
* @date 2023/4/28 16:21
|
376
|
+
*/
|
377
|
+
next: async () => {
|
378
|
+
/*当前只有一个元素,不做处理*/
|
379
|
+
if (itemProps.length < 2) {return;}
|
380
|
+
if (!itemProps) {
|
381
|
+
return;
|
382
|
+
}
|
383
|
+
let activeIndex = itemProps.findIndex((i) => i === state.tempValue);
|
384
|
+
if (activeIndex === -1) {
|
385
|
+
activeIndex = 0;
|
386
|
+
}
|
387
|
+
|
388
|
+
/*当前只有两个元素,并且已经是最后一个元素了,点击next的时候转为prev*/
|
389
|
+
if (activeIndex === itemProps.length - 1 && itemProps.length === 2) {
|
390
|
+
return methods.prev();
|
391
|
+
}
|
392
|
+
let nextIndex = activeIndex == itemProps.length - 1 ? 0 : activeIndex + 1;
|
393
|
+
|
394
|
+
state.tempValue = itemProps[nextIndex];
|
395
|
+
model.value = state.tempValue;
|
396
|
+
|
397
|
+
if (props.autoPlay) {
|
398
|
+
methods.stop();
|
399
|
+
methods.start();
|
400
|
+
}
|
401
|
+
},
|
402
|
+
...play,
|
403
|
+
show: async (newVal: any, oldVal: any, autoEmit = true) => {
|
404
|
+
if (autoEmit && newVal === oldVal) {
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
/*更新tempValue*/
|
408
|
+
state.tempValue = newVal;
|
409
|
+
if (autoEmit) {
|
410
|
+
model.value = state.tempValue;
|
411
|
+
}
|
412
|
+
if (!!props.autoPlay) {
|
413
|
+
methods.stop();
|
414
|
+
methods.start();
|
415
|
+
}
|
416
|
+
},
|
417
|
+
};
|
418
|
+
|
419
|
+
const handler = {
|
420
|
+
onDoubleClickSwitchButton: (e: iMouseEvent) => {
|
421
|
+
e.stopPropagation();
|
422
|
+
}
|
423
|
+
};
|
424
|
+
|
425
|
+
useWatchAutoClear(
|
426
|
+
/*拖拽过程中禁用自动播放*/
|
427
|
+
() => props.autoPlay && !touchHandler.touchState.touching,
|
428
|
+
(autoPlay) => {
|
429
|
+
if (!!autoPlay) {
|
430
|
+
methods.start();
|
431
|
+
}
|
432
|
+
return () => {
|
433
|
+
methods.stop();
|
434
|
+
};
|
435
|
+
}
|
436
|
+
);
|
437
|
+
|
438
|
+
const { effects: listenerEffects } = createEffects();
|
439
|
+
useWatchAutoClear(() => props.disableSwiper, disableSwiper => {
|
440
|
+
listenerEffects.clear();
|
441
|
+
if (disableSwiper) {
|
442
|
+
touchHandler.reset();
|
443
|
+
return doNothing;
|
444
|
+
}
|
445
|
+
delay().then(() => {
|
446
|
+
listenerEffects.push(addElementListener(refs.el!, 'touchstart', touchHandler.touchstart, { passive: false }));
|
447
|
+
listenerEffects.push(addElementListener(refs.el!, 'mousedown', touchHandler.touchstart, { passive: false }));
|
448
|
+
});
|
449
|
+
return listenerEffects.clear;
|
450
|
+
});
|
451
|
+
|
452
|
+
onBeforeUnmount(() => {
|
453
|
+
play.stop();
|
454
|
+
listenerEffects.clear();
|
455
|
+
});
|
456
|
+
|
457
|
+
let tempState = {
|
458
|
+
/*上一次渲染的循环列表数据*/
|
459
|
+
prev: null as null | {
|
460
|
+
current: number,
|
461
|
+
cycleIndexList: number[],
|
462
|
+
},
|
463
|
+
/*下一次渲染的循环列表数据*/
|
464
|
+
curr: null as null | {
|
465
|
+
current: number,
|
466
|
+
cycleIndexList: number[],
|
467
|
+
}
|
468
|
+
};
|
469
|
+
|
470
|
+
return {
|
471
|
+
refer: {
|
472
|
+
utils,
|
473
|
+
methods,
|
474
|
+
refs,
|
475
|
+
},
|
476
|
+
render: () => {
|
477
|
+
const content = slots.default() as any;
|
478
|
+
|
479
|
+
const items: any[] = !content
|
480
|
+
? []
|
481
|
+
: findReactElement(content, (i: any) => i.type?.name === CarouselItem.name) || [];
|
482
|
+
|
483
|
+
itemProps = items.map((i, index) => i.props?.val == null ? index : i.props?.val);
|
484
|
+
|
485
|
+
const total = items.length;
|
486
|
+
const activeIndex = !state.tempValue
|
487
|
+
? 0
|
488
|
+
: itemProps.findIndex((i) => i === state.tempValue);
|
489
|
+
|
490
|
+
const { index2distance, cycleIndexList, currentIndexInCycle } = buildCycleIndexList({ length: itemProps.length, current: activeIndex });
|
491
|
+
const prevIndex = cycleIndexList[currentIndexInCycle] - 1;
|
492
|
+
const nextIndex = cycleIndexList[currentIndexInCycle] + 1;
|
493
|
+
|
494
|
+
if (!tempState.curr || tempState.curr.current !== activeIndex) {
|
495
|
+
tempState.prev = tempState.curr;
|
496
|
+
tempState.curr = {
|
497
|
+
current: activeIndex,
|
498
|
+
cycleIndexList: cycleIndexList,
|
499
|
+
};
|
500
|
+
}
|
501
|
+
|
502
|
+
return (
|
503
|
+
<div
|
504
|
+
id={id}
|
505
|
+
className={classes.value}
|
506
|
+
style={styles.value}
|
507
|
+
ref={onRef.el}
|
508
|
+
>
|
509
|
+
<div className="carousel-container">
|
510
|
+
{items.map((Item: any, index: number) => {
|
511
|
+
const ItemComp = isReact ? Item.type : Item;
|
512
|
+
return (
|
513
|
+
<ItemComp
|
514
|
+
{...Item.props}
|
515
|
+
index={index}
|
516
|
+
distance={index2distance[index]}
|
517
|
+
alignItems={props.alignItems}
|
518
|
+
key={index}
|
519
|
+
/>
|
520
|
+
);
|
521
|
+
})}
|
522
|
+
</div>
|
523
|
+
{!props.noIndicator &&
|
524
|
+
scopeSlots.indicator(
|
525
|
+
{ total, activeIndex, prevIndex, nextIndex },
|
526
|
+
(() => {
|
527
|
+
return (
|
528
|
+
<div
|
529
|
+
className={`carousel-indicator carousel-indicator-style-${props.indicatorStyle}`} style={{ zIndex: itemProps.length + 2 }}>
|
530
|
+
{(() => {
|
531
|
+
if (props.indicatorStyle === 'text') {
|
532
|
+
return `${activeIndex + 1} / ${total}`;
|
533
|
+
} else {
|
534
|
+
return itemProps.map((_, index) => (
|
535
|
+
<div
|
536
|
+
key={index}
|
537
|
+
{...props.indicatorTrigger === 'click' ?
|
538
|
+
{ onClick: () => methods.show(itemProps[index], model.value) } :
|
539
|
+
{ onMouseEnter: () => methods.show(itemProps[index], model.value) }}
|
540
|
+
className={`carousel-indicator-item ${
|
541
|
+
index === activeIndex
|
542
|
+
? 'carousel-indicator-item-active'
|
543
|
+
: index === prevIndex
|
544
|
+
? 'carousel-indicator-item-prev'
|
545
|
+
: index === nextIndex
|
546
|
+
? 'carousel-indicator-item-next'
|
547
|
+
: ''
|
548
|
+
}`}
|
549
|
+
/>
|
550
|
+
));
|
551
|
+
}
|
552
|
+
})()}
|
553
|
+
</div>
|
554
|
+
);
|
555
|
+
})()
|
556
|
+
)}
|
557
|
+
{props.switchButton && (
|
558
|
+
<div className="carousel-switch-button" style={{ zIndex: itemProps.length + 2 }}>
|
559
|
+
{(() => {
|
560
|
+
const prevButton = (
|
561
|
+
<div className="carousel-switch-button-prev" onClick={methods.prev} onDoubleClick={handler.onDoubleClickSwitchButton}>
|
562
|
+
<Icon icon={props.vertical ? 'pi-up' : 'pi-left'}/>
|
563
|
+
</div>
|
564
|
+
);
|
565
|
+
return !!props.prevSwitchButtonTip ? <Tooltip message={props.prevSwitchButtonTip} placement="bottom-start">{prevButton}</Tooltip> : prevButton;
|
566
|
+
})()}
|
567
|
+
{(() => {
|
568
|
+
const nextButton = (
|
569
|
+
<div className="carousel-switch-button-next" onClick={methods.next} onDoubleClick={handler.onDoubleClickSwitchButton}>
|
570
|
+
<Icon icon={props.vertical ? 'pi-down' : 'pi-right'}/>
|
571
|
+
</div>
|
572
|
+
);
|
573
|
+
return !!props.nextSwitchButtonTip ? <Tooltip message={props.nextSwitchButtonTip} placement="bottom-end">{nextButton}</Tooltip> : nextButton;
|
574
|
+
})()}
|
575
|
+
</div>
|
576
|
+
)}
|
577
|
+
{slots.cover.isExist() && (
|
578
|
+
<div className="carousel-cover" style={{ zIndex: itemProps.length + 2 }}>
|
579
|
+
{slots.cover()}
|
580
|
+
</div>
|
581
|
+
)}
|
582
|
+
</div>
|
583
|
+
);
|
584
|
+
}
|
585
|
+
};
|
586
|
+
}
|
587
|
+
});
|
588
|
+
|
589
|
+
const nextCarouselId = createCounter('carousel');
|
590
|
+
|
591
|
+
export default Carousel;
|