@rockshin/tao-ui 0.0.60 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/component-manifest.json +1 -1
- package/dist/components/affix/affix.css +1 -1
- package/dist/components/affix/affix.d.ts +1 -0
- package/dist/components/affix/affix.js +18 -17
- package/dist/components/alert/alert.css +123 -119
- package/dist/components/alert/alert.js +78 -188
- package/dist/components/app/app-modals.js +49 -98
- package/dist/components/app/app-notices.d.ts +2 -2
- package/dist/components/app/app-notices.js +294 -243
- package/dist/components/app/app-types.d.ts +6 -3
- package/dist/components/app/app.css +185 -183
- package/dist/components/app/app.js +1 -1
- package/dist/components/auto-complete/auto-complete.css +30 -28
- package/dist/components/auto-complete/auto-complete.d.ts +3 -1
- package/dist/components/auto-complete/auto-complete.js +2 -1
- package/dist/components/badge/badge.js +42 -127
- package/dist/components/border-beam/border-beam.css +1 -1
- package/dist/components/border-beam/border-beam.d.ts +1 -0
- package/dist/components/border-beam/border-beam.js +1 -0
- package/dist/components/breadcrumb/breadcrumb.css +123 -120
- package/dist/components/breadcrumb/breadcrumb.js +160 -265
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +52 -151
- package/dist/components/calendar/calendar.js +28 -27
- package/dist/components/card/card-tabs.d.ts +56 -5
- package/dist/components/card/card-tabs.js +214 -468
- package/dist/components/card/card.d.ts +1 -2
- package/dist/components/card/card.js +64 -226
- package/dist/components/carousel/carousel.css +1 -1
- package/dist/components/carousel/carousel.d.ts +59 -4
- package/dist/components/carousel/carousel.js +299 -243
- package/dist/components/cascader/cascader.css +186 -184
- package/dist/components/cascader/cascader.d.ts +3 -1
- package/dist/components/cascader/cascader.js +28 -34
- package/dist/components/checkbox/checkbox.css +93 -90
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +171 -499
- package/dist/components/collapse/collapse-panels.js +145 -400
- package/dist/components/collapse/collapse.css +172 -170
- package/dist/components/collapse/collapse.d.ts +1 -1
- package/dist/components/collapse/collapse.js +62 -181
- package/dist/components/color-picker/color-picker.js +418 -982
- package/dist/components/context-menu/context-menu.css +4 -4
- package/dist/components/context-menu/context-menu.d.ts +1 -1
- package/dist/components/context-menu/context-menu.js +52 -138
- package/dist/components/date-picker/calendar/calendar-grid.js +41 -41
- package/dist/components/date-picker/calendar/calendar-header.js +171 -337
- package/dist/components/date-picker/calendar/month-grid.js +33 -103
- package/dist/components/date-picker/calendar/time-panel.js +81 -210
- package/dist/components/date-picker/calendar/year-grid.js +36 -105
- package/dist/components/date-picker/date-localization.js +1 -1
- package/dist/components/date-picker/date-picker.css +599 -642
- package/dist/components/date-picker/date-picker.d.ts +2 -1
- package/dist/components/date-picker/date-picker.js +93 -104
- package/dist/components/date-picker/presets.js +12 -37
- package/dist/components/date-picker/range-picker.d.ts +2 -1
- package/dist/components/date-picker/range-picker.js +217 -252
- package/dist/components/date-picker/types.d.ts +2 -1
- package/dist/components/descriptions/descriptions.css +1 -1
- package/dist/components/descriptions/descriptions.js +30 -39
- package/dist/components/drawer/drawer.css +202 -200
- package/dist/components/drawer/drawer.js +28 -34
- package/dist/components/dropdown/dropdown-core.d.ts +32 -0
- package/dist/components/dropdown/dropdown-core.js +156 -0
- package/dist/components/dropdown/dropdown.css +38 -36
- package/dist/components/dropdown/dropdown.d.ts +4 -31
- package/dist/components/dropdown/dropdown.js +90 -276
- package/dist/components/empty/empty.css +30 -28
- package/dist/components/empty/empty.js +81 -236
- package/dist/components/float-button/float-button.css +1 -1
- package/dist/components/float-button/float-button.js +36 -47
- package/dist/components/form/field-control.js +2 -3
- package/dist/components/form/form-item.js +67 -129
- package/dist/components/form/form.css +36 -34
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.js +29 -100
- package/dist/components/form/index.d.ts +1 -1
- package/dist/components/form/use-form.js +48 -67
- package/dist/components/form-actions/form-actions.d.ts +1 -0
- package/dist/components/form-actions/form-actions.js +10 -36
- package/dist/components/form-field/form-field-view.d.ts +1 -0
- package/dist/components/form-field/form-field-view.js +81 -288
- package/dist/components/form-field/form-field.js +13 -31
- package/dist/components/form-field/form.css +74 -72
- package/dist/components/form-section/form-section.d.ts +1 -0
- package/dist/components/form-section/form-section.js +38 -91
- package/dist/components/image/image-icons.js +16 -31
- package/dist/components/image/image.css +1 -1
- package/dist/components/image/image.js +298 -911
- package/dist/components/input/base-input.d.ts +3 -1
- package/dist/components/input/base-input.js +8 -7
- package/dist/components/input/input-shared.css +62 -60
- package/dist/components/input/input-shared.d.ts +1 -1
- package/dist/components/input/input-shared.js +56 -100
- package/dist/components/input/input.css +222 -220
- package/dist/components/input/otp.d.ts +2 -1
- package/dist/components/input/otp.js +143 -324
- package/dist/components/input/password.js +12 -67
- package/dist/components/input/search.js +13 -13
- package/dist/components/input-number/input-number.d.ts +2 -1
- package/dist/components/input-number/input-number.js +30 -152
- package/dist/components/list/list-pagination.css +107 -105
- package/dist/components/list/list-pagination.d.ts +56 -5
- package/dist/components/list/list-pagination.js +249 -316
- package/dist/components/list/list.css +179 -177
- package/dist/components/list/list.js +170 -604
- package/dist/components/listy/listy.css +55 -53
- package/dist/components/listy/listy.d.ts +43 -4
- package/dist/components/listy/listy.js +198 -216
- package/dist/components/masonry/masonry.css +1 -1
- package/dist/components/masonry/masonry.d.ts +1 -0
- package/dist/components/masonry/masonry.js +90 -244
- package/dist/components/mentions/mentions.css +153 -151
- package/dist/components/mentions/mentions.d.ts +53 -11
- package/dist/components/mentions/mentions.js +288 -73
- package/dist/components/menu/menu-render.d.ts +2 -1
- package/dist/components/menu/menu-render.js +149 -307
- package/dist/components/menu/menu.css +142 -140
- package/dist/components/modal/confirm-dialog.js +8 -18
- package/dist/components/modal/modal.css +165 -162
- package/dist/components/modal/modal.js +285 -731
- package/dist/components/modal/use-modal.js +25 -25
- package/dist/components/pagination/pagination.css +134 -131
- package/dist/components/pagination/pagination.d.ts +1 -1
- package/dist/components/pagination/pagination.js +137 -290
- package/dist/components/popconfirm/popconfirm.css +38 -36
- package/dist/components/popconfirm/popconfirm.js +105 -288
- package/dist/components/popover/popover.css +89 -87
- package/dist/components/popover/popover.js +168 -275
- package/dist/components/progress/progress.css +153 -151
- package/dist/components/progress/progress.js +34 -43
- package/dist/components/qr-code/qr-code.css +36 -34
- package/dist/components/qr-code/qr-code.js +83 -277
- package/dist/components/radio/radio.css +95 -92
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +114 -376
- package/dist/components/rate/rate.css +80 -78
- package/dist/components/rate/rate.d.ts +34 -6
- package/dist/components/rate/rate.js +160 -244
- package/dist/components/result/result.css +59 -57
- package/dist/components/result/result.d.ts +1 -0
- package/dist/components/result/result.js +118 -291
- package/dist/components/scroll-area/scroll-area.css +160 -148
- package/dist/components/scroll-area/scroll-area.js +284 -488
- package/dist/components/segmented/segmented.css +1 -1
- package/dist/components/segmented/segmented.js +59 -58
- package/dist/components/select/mobile-select.css +166 -164
- package/dist/components/select/mobile-select.js +48 -131
- package/dist/components/select/select-icons.js +59 -128
- package/dist/components/select/select-searchable-list.js +19 -19
- package/dist/components/select/select-tags.js +70 -156
- package/dist/components/select/select-types.d.ts +2 -1
- package/dist/components/select/select.css +509 -506
- package/dist/components/select/select.d.ts +1 -0
- package/dist/components/select/select.js +67 -65
- package/dist/components/select/use-select-selection.js +181 -269
- package/dist/components/skeleton/skeleton.css +105 -103
- package/dist/components/skeleton/skeleton.js +140 -399
- package/dist/components/slider/slider.css +160 -158
- package/dist/components/slider/slider.d.ts +45 -6
- package/dist/components/slider/slider.js +359 -74
- package/dist/components/sonner/index.d.ts +1 -1
- package/dist/components/sonner/sonner.css +190 -182
- package/dist/components/sonner/sonner.js +12 -11
- package/dist/components/spinner/spinner.css +80 -76
- package/dist/components/spinner/spinner.d.ts +1 -1
- package/dist/components/spinner/spinner.js +75 -219
- package/dist/components/splitter/splitter.css +157 -154
- package/dist/components/splitter/splitter.js +271 -448
- package/dist/components/statistic/statistic.css +1 -1
- package/dist/components/statistic/statistic.js +121 -413
- package/dist/components/status-icon/status-icon.js +14 -26
- package/dist/components/steps/steps-icons.js +63 -100
- package/dist/components/steps/steps.css +817 -807
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/steps/steps.js +38 -94
- package/dist/components/steps/use-display-steps.js +21 -54
- package/dist/components/switch/switch-touch.css +17 -15
- package/dist/components/switch/switch.css +192 -190
- package/dist/components/switch/switch.js +63 -196
- package/dist/components/table/table-filter.d.ts +1 -1
- package/dist/components/table/table-filter.js +68 -155
- package/dist/components/table/table-icons.js +77 -152
- package/dist/components/table/table-summary.js +30 -77
- package/dist/components/table/table-types.d.ts +2 -1
- package/dist/components/table/table.css +468 -465
- package/dist/components/table/table.js +85 -84
- package/dist/components/table/use-table-data.js +137 -248
- package/dist/components/tabs/tabs.css +123 -120
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +156 -331
- package/dist/components/tag/tag.css +231 -221
- package/dist/components/tag/tag.js +110 -248
- package/dist/components/textarea/textarea.css +2 -1
- package/dist/components/textarea/textarea.d.ts +3 -1
- package/dist/components/textarea/textarea.js +16 -15
- package/dist/components/time-picker/time-picker.d.ts +1 -0
- package/dist/components/time-picker/time-picker.js +88 -220
- package/dist/components/timeline/timeline.css +1 -1
- package/dist/components/timeline/timeline.js +17 -17
- package/dist/components/tooltip/tooltip.css +79 -77
- package/dist/components/tooltip/tooltip.js +105 -215
- package/dist/components/tour/tour.css +1 -1
- package/dist/components/tour/tour.d.ts +59 -6
- package/dist/components/tour/tour.js +343 -622
- package/dist/components/transfer/transfer-list.js +19 -19
- package/dist/components/transfer/transfer-parts.js +63 -139
- package/dist/components/transfer/transfer.css +192 -190
- package/dist/components/transfer/transfer.js +57 -56
- package/dist/components/tree/tree-check.js +25 -32
- package/dist/components/tree/tree-keyboard.js +1 -1
- package/dist/components/tree/tree.css +204 -200
- package/dist/components/tree/tree.js +139 -277
- package/dist/components/tree-select/select-engine.css +200 -197
- package/dist/components/tree-select/select-engine.js +11 -38
- package/dist/components/tree-select/tree-select.css +21 -19
- package/dist/components/tree-select/tree-select.d.ts +3 -1
- package/dist/components/tree-select/tree-select.js +11 -10
- package/dist/components/upload/upload.js +193 -308
- package/dist/components/watermark/watermark-context.js +8 -14
- package/dist/components/watermark/watermark.css +1 -1
- package/dist/components/watermark/watermark.js +209 -400
- package/dist/docs/components/stack.doc.js +1 -1
- package/dist/docs/components/table.doc.js +1 -1
- package/dist/entries/affix.d.ts +0 -2
- package/dist/entries/affix.js +0 -2
- package/dist/entries/alert.d.ts +0 -2
- package/dist/entries/alert.js +0 -2
- package/dist/entries/app.d.ts +0 -2
- package/dist/entries/app.js +0 -2
- package/dist/entries/auto-complete.d.ts +0 -2
- package/dist/entries/auto-complete.js +0 -2
- package/dist/entries/avatar.d.ts +0 -2
- package/dist/entries/avatar.js +0 -2
- package/dist/entries/badge.d.ts +0 -2
- package/dist/entries/badge.js +0 -2
- package/dist/entries/border-beam.d.ts +0 -2
- package/dist/entries/border-beam.js +0 -2
- package/dist/entries/breadcrumb.d.ts +0 -2
- package/dist/entries/breadcrumb.js +0 -2
- package/dist/entries/button.d.ts +0 -2
- package/dist/entries/button.js +0 -2
- package/dist/entries/calendar.d.ts +0 -2
- package/dist/entries/calendar.js +0 -2
- package/dist/entries/card.d.ts +0 -2
- package/dist/entries/card.js +0 -2
- package/dist/entries/carousel.d.ts +0 -2
- package/dist/entries/carousel.js +0 -2
- package/dist/entries/cascader.d.ts +0 -2
- package/dist/entries/cascader.js +0 -2
- package/dist/entries/checkbox.d.ts +0 -2
- package/dist/entries/checkbox.js +0 -2
- package/dist/entries/collapse.d.ts +0 -2
- package/dist/entries/collapse.js +0 -2
- package/dist/entries/color-picker.d.ts +0 -2
- package/dist/entries/color-picker.js +0 -2
- package/dist/entries/context-menu.d.ts +0 -2
- package/dist/entries/context-menu.js +0 -2
- package/dist/entries/date-picker.d.ts +0 -2
- package/dist/entries/date-picker.js +0 -2
- package/dist/entries/descriptions.d.ts +0 -2
- package/dist/entries/descriptions.js +0 -2
- package/dist/entries/divider.d.ts +0 -2
- package/dist/entries/divider.js +0 -2
- package/dist/entries/drawer.d.ts +0 -2
- package/dist/entries/drawer.js +0 -2
- package/dist/entries/dropdown.d.ts +0 -2
- package/dist/entries/dropdown.js +0 -2
- package/dist/entries/empty.d.ts +0 -2
- package/dist/entries/empty.js +0 -2
- package/dist/entries/float-button.d.ts +0 -2
- package/dist/entries/float-button.js +0 -2
- package/dist/entries/form-actions.d.ts +0 -2
- package/dist/entries/form-actions.js +0 -2
- package/dist/entries/form-field.d.ts +0 -2
- package/dist/entries/form-field.js +0 -2
- package/dist/entries/form-layout.d.ts +0 -2
- package/dist/entries/form-layout.js +0 -2
- package/dist/entries/form-section.d.ts +0 -2
- package/dist/entries/form-section.js +0 -2
- package/dist/entries/form.d.ts +1 -3
- package/dist/entries/form.js +0 -2
- package/dist/entries/image.d.ts +0 -2
- package/dist/entries/image.js +0 -2
- package/dist/entries/input-number.d.ts +0 -2
- package/dist/entries/input-number.js +0 -2
- package/dist/entries/input.d.ts +1 -3
- package/dist/entries/input.js +0 -2
- package/dist/entries/list.d.ts +0 -2
- package/dist/entries/list.js +0 -2
- package/dist/entries/listy.d.ts +0 -2
- package/dist/entries/listy.js +0 -2
- package/dist/entries/masonry.d.ts +0 -2
- package/dist/entries/masonry.js +0 -2
- package/dist/entries/mentions.d.ts +0 -2
- package/dist/entries/mentions.js +0 -2
- package/dist/entries/modal.d.ts +0 -2
- package/dist/entries/modal.js +0 -2
- package/dist/entries/number-input.d.ts +0 -2
- package/dist/entries/number-input.js +0 -2
- package/dist/entries/pagination.d.ts +0 -2
- package/dist/entries/pagination.js +0 -2
- package/dist/entries/popconfirm.d.ts +0 -2
- package/dist/entries/popconfirm.js +0 -2
- package/dist/entries/popover.d.ts +0 -2
- package/dist/entries/popover.js +0 -2
- package/dist/entries/progress.d.ts +0 -2
- package/dist/entries/progress.js +0 -2
- package/dist/entries/provider.d.ts +1 -3
- package/dist/entries/provider.js +1 -3
- package/dist/entries/qr-code.d.ts +0 -2
- package/dist/entries/qr-code.js +0 -2
- package/dist/entries/radio.d.ts +0 -2
- package/dist/entries/radio.js +0 -2
- package/dist/entries/range-picker.d.ts +0 -2
- package/dist/entries/range-picker.js +0 -2
- package/dist/entries/rate.d.ts +0 -2
- package/dist/entries/rate.js +0 -2
- package/dist/entries/result.d.ts +0 -2
- package/dist/entries/result.js +0 -2
- package/dist/entries/scroll-area.d.ts +0 -2
- package/dist/entries/scroll-area.js +0 -2
- package/dist/entries/segmented.d.ts +0 -2
- package/dist/entries/segmented.js +0 -2
- package/dist/entries/select.d.ts +0 -2
- package/dist/entries/select.js +0 -2
- package/dist/entries/skeleton.d.ts +0 -2
- package/dist/entries/skeleton.js +0 -2
- package/dist/entries/slider.d.ts +0 -2
- package/dist/entries/slider.js +0 -2
- package/dist/entries/sonner.d.ts +0 -2
- package/dist/entries/sonner.js +0 -2
- package/dist/entries/spinner.d.ts +0 -2
- package/dist/entries/spinner.js +0 -2
- package/dist/entries/splitter.d.ts +0 -2
- package/dist/entries/splitter.js +0 -2
- package/dist/entries/stack.d.ts +0 -2
- package/dist/entries/stack.js +0 -2
- package/dist/entries/statistic.d.ts +0 -2
- package/dist/entries/statistic.js +0 -2
- package/dist/entries/steps.d.ts +0 -2
- package/dist/entries/steps.js +0 -2
- package/dist/entries/switch.d.ts +0 -2
- package/dist/entries/switch.js +0 -2
- package/dist/entries/table.d.ts +0 -2
- package/dist/entries/table.js +0 -2
- package/dist/entries/tabs.d.ts +0 -2
- package/dist/entries/tabs.js +0 -2
- package/dist/entries/tag.d.ts +0 -2
- package/dist/entries/tag.js +0 -2
- package/dist/entries/textarea.d.ts +0 -2
- package/dist/entries/textarea.js +0 -2
- package/dist/entries/time-picker.d.ts +0 -2
- package/dist/entries/time-picker.js +0 -2
- package/dist/entries/timeline.d.ts +0 -2
- package/dist/entries/timeline.js +0 -2
- package/dist/entries/tooltip.d.ts +0 -2
- package/dist/entries/tooltip.js +0 -2
- package/dist/entries/tour.d.ts +0 -2
- package/dist/entries/tour.js +0 -2
- package/dist/entries/transfer.d.ts +0 -2
- package/dist/entries/transfer.js +0 -2
- package/dist/entries/tree-select.d.ts +0 -2
- package/dist/entries/tree-select.js +0 -2
- package/dist/entries/tree.d.ts +0 -2
- package/dist/entries/tree.js +0 -2
- package/dist/entries/upload.d.ts +0 -2
- package/dist/entries/upload.js +0 -2
- package/dist/entries/watermark.d.ts +0 -2
- package/dist/entries/watermark.js +0 -2
- package/dist/index.d.ts +5 -7
- package/dist/index.js +2 -4
- package/dist/layouts/form-layout/form-layout.d.ts +1 -0
- package/dist/layouts/form-layout/form-layout.js +10 -36
- package/dist/layouts/stack/layout.css +46 -44
- package/dist/layouts/stack/stack.d.ts +1 -0
- package/dist/layouts/stack/stack.js +16 -69
- package/dist/locales/ar-EG.js +25 -2
- package/dist/locales/create-locale.d.ts +1 -2
- package/dist/locales/create-locale.js +0 -28
- package/dist/locales/de-DE.js +25 -2
- package/dist/locales/en-US.js +24 -1
- package/dist/locales/es-ES.js +25 -2
- package/dist/locales/fr-FR.js +25 -2
- package/dist/locales/hi-IN.js +25 -2
- package/dist/locales/id-ID.js +25 -2
- package/dist/locales/index.d.ts +10 -10
- package/dist/locales/index.js +9 -9
- package/dist/locales/it-IT.js +25 -2
- package/dist/locales/ja-JP.js +25 -2
- package/dist/locales/ko-KR.js +25 -2
- package/dist/locales/pt-BR.js +25 -2
- package/dist/locales/ru-RU.js +25 -2
- package/dist/locales/th-TH.js +25 -2
- package/dist/locales/tr-TR.js +25 -2
- package/dist/locales/vi-VN.js +25 -2
- package/dist/locales/zh-CN.js +25 -2
- package/dist/locales/zh-TW.js +25 -2
- package/dist/number-input/number-input.js +24 -81
- package/dist/number-input/use-number-input.js +42 -42
- package/dist/provider/locale.d.ts +1 -1
- package/dist/provider/tao-context.d.ts +38 -0
- package/dist/provider/tao-context.js +92 -0
- package/dist/provider/tao-portal-scope.d.ts +14 -0
- package/dist/provider/tao-portal-scope.js +54 -0
- package/dist/provider/tao-provider.d.ts +5 -55
- package/dist/provider/tao-provider.js +94 -378
- package/dist/theme/control.css +106 -126
- package/dist/theme/theme.css +2 -0
- package/dist/utils/dialog-content.js +55 -210
- package/dist/utils/overlay.js +15 -30
- package/dist/utils/rc-compat.d.ts +13 -0
- package/dist/utils/rc-compat.js +48 -0
- package/dist/utils/refs.js +5 -19
- package/package.json +10 -16
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { c } from "react-compiler-runtime";
|
|
3
2
|
import upload from "@rc-component/upload";
|
|
4
3
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
5
4
|
import { flushSync } from "react-dom";
|
|
@@ -51,162 +50,84 @@ function isImageFile(file) {
|
|
|
51
50
|
if (/^data:/i.test(url)) return false;
|
|
52
51
|
return !extension || /^\.(avif|bmp|dpg|gif|heic|heif|ico|jfif|jpe?g|png|svg|tiff?|webp)$/i.test(extension);
|
|
53
52
|
}
|
|
54
|
-
function FilePreview(
|
|
55
|
-
const $ = c(13);
|
|
56
|
-
const { file, previewFile } = t0;
|
|
53
|
+
function FilePreview({ file, previewFile }) {
|
|
57
54
|
const { locale } = useTaoConfig();
|
|
58
55
|
const source = file.originFileObj;
|
|
59
56
|
const [preview, setPreview] = useState();
|
|
60
57
|
const [error, setError] = useState();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (active) setPreview({
|
|
71
|
-
source,
|
|
72
|
-
url: value
|
|
73
|
-
});
|
|
74
|
-
}, (reason)=>{
|
|
75
|
-
if (active) setError(reason instanceof Error ? reason.message : locale.messages.previewUnavailable);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
setError(void 0);
|
|
60
|
+
if (file.thumbUrl || file.url || !source) return void setPreview(void 0);
|
|
61
|
+
let active = true;
|
|
62
|
+
const load = async (source)=>previewFile ? previewFile(source) : readPreview(source, locale.messages.readFileError);
|
|
63
|
+
load(source).then((value)=>{
|
|
64
|
+
if (active) setPreview({
|
|
65
|
+
source,
|
|
66
|
+
url: value
|
|
76
67
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
}, (reason)=>{
|
|
69
|
+
if (active) setError(reason instanceof Error ? reason.message : locale.messages.previewUnavailable);
|
|
70
|
+
});
|
|
71
|
+
return ()=>{
|
|
72
|
+
active = false;
|
|
80
73
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
$[0] = file.thumbUrl;
|
|
90
|
-
$[1] = file.url;
|
|
91
|
-
$[2] = locale.messages.previewUnavailable;
|
|
92
|
-
$[3] = locale.messages.readFileError;
|
|
93
|
-
$[4] = previewFile;
|
|
94
|
-
$[5] = source;
|
|
95
|
-
$[6] = t1;
|
|
96
|
-
$[7] = t2;
|
|
97
|
-
} else {
|
|
98
|
-
t1 = $[6];
|
|
99
|
-
t2 = $[7];
|
|
100
|
-
}
|
|
101
|
-
useEffect(t1, t2);
|
|
74
|
+
}, [
|
|
75
|
+
source,
|
|
76
|
+
file.thumbUrl,
|
|
77
|
+
file.url,
|
|
78
|
+
previewFile,
|
|
79
|
+
locale.messages.readFileError,
|
|
80
|
+
locale.messages.previewUnavailable
|
|
81
|
+
]);
|
|
102
82
|
const src = file.thumbUrl || file.url || preview?.source === source && preview?.url;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
crossOrigin: file.crossOrigin
|
|
112
|
-
}) : /*#__PURE__*/ jsx(FileIcon, {});
|
|
113
|
-
$[8] = error;
|
|
114
|
-
$[9] = file.crossOrigin;
|
|
115
|
-
$[10] = file.name;
|
|
116
|
-
$[11] = src;
|
|
117
|
-
$[12] = t3;
|
|
118
|
-
} else t3 = $[12];
|
|
119
|
-
return t3;
|
|
83
|
+
return error ? /*#__PURE__*/ jsx("span", {
|
|
84
|
+
role: "status",
|
|
85
|
+
children: error
|
|
86
|
+
}) : src ? /*#__PURE__*/ jsx("img", {
|
|
87
|
+
src: src,
|
|
88
|
+
alt: file.name,
|
|
89
|
+
crossOrigin: file.crossOrigin
|
|
90
|
+
}) : /*#__PURE__*/ jsx(FileIcon, {});
|
|
120
91
|
}
|
|
121
|
-
function FileIcon(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
t5 = "download" === kind && /*#__PURE__*/ jsx("path", {
|
|
161
|
-
d: "M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"
|
|
162
|
-
});
|
|
163
|
-
$[6] = kind;
|
|
164
|
-
$[7] = t5;
|
|
165
|
-
} else t5 = $[7];
|
|
166
|
-
let t6;
|
|
167
|
-
if ($[8] !== kind) {
|
|
168
|
-
t6 = "plus" === kind && /*#__PURE__*/ jsx("path", {
|
|
169
|
-
d: "M12 4v16M4 12h16"
|
|
170
|
-
});
|
|
171
|
-
$[8] = kind;
|
|
172
|
-
$[9] = t6;
|
|
173
|
-
} else t6 = $[9];
|
|
174
|
-
let t7;
|
|
175
|
-
if ($[10] !== kind) {
|
|
176
|
-
t7 = "upload" === kind && /*#__PURE__*/ jsx("path", {
|
|
177
|
-
d: "M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5"
|
|
178
|
-
});
|
|
179
|
-
$[10] = kind;
|
|
180
|
-
$[11] = t7;
|
|
181
|
-
} else t7 = $[11];
|
|
182
|
-
let t8;
|
|
183
|
-
if ($[12] !== t2 || $[13] !== t3 || $[14] !== t4 || $[15] !== t5 || $[16] !== t6 || $[17] !== t7) {
|
|
184
|
-
t8 = /*#__PURE__*/ jsxs("svg", {
|
|
185
|
-
viewBox: "0 0 24 24",
|
|
186
|
-
width: "16",
|
|
187
|
-
height: "16",
|
|
188
|
-
fill: "none",
|
|
189
|
-
stroke: "currentColor",
|
|
190
|
-
strokeWidth: "1.8",
|
|
191
|
-
"aria-hidden": "true",
|
|
192
|
-
children: [
|
|
193
|
-
t2,
|
|
194
|
-
t3,
|
|
195
|
-
t4,
|
|
196
|
-
t5,
|
|
197
|
-
t6,
|
|
198
|
-
t7
|
|
199
|
-
]
|
|
200
|
-
});
|
|
201
|
-
$[12] = t2;
|
|
202
|
-
$[13] = t3;
|
|
203
|
-
$[14] = t4;
|
|
204
|
-
$[15] = t5;
|
|
205
|
-
$[16] = t6;
|
|
206
|
-
$[17] = t7;
|
|
207
|
-
$[18] = t8;
|
|
208
|
-
} else t8 = $[18];
|
|
209
|
-
return t8;
|
|
92
|
+
function FileIcon({ kind = 'file' }) {
|
|
93
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
94
|
+
viewBox: "0 0 24 24",
|
|
95
|
+
width: "16",
|
|
96
|
+
height: "16",
|
|
97
|
+
fill: "none",
|
|
98
|
+
stroke: "currentColor",
|
|
99
|
+
strokeWidth: "1.8",
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: [
|
|
102
|
+
'file' === kind && /*#__PURE__*/ jsx("path", {
|
|
103
|
+
d: "M7 3h7l4 4v14H7V3Zm7 0v5h4M10 12h5M10 16h5"
|
|
104
|
+
}),
|
|
105
|
+
'remove' === kind && /*#__PURE__*/ jsx("path", {
|
|
106
|
+
d: "M4 6h16M9 6V3h6v3M6 6l1 15h10l1-15M10 10v7M14 10v7"
|
|
107
|
+
}),
|
|
108
|
+
'preview' === kind && /*#__PURE__*/ jsxs(Fragment, {
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ jsx("path", {
|
|
111
|
+
d: "M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12Z"
|
|
112
|
+
}),
|
|
113
|
+
/*#__PURE__*/ jsx("circle", {
|
|
114
|
+
cx: "12",
|
|
115
|
+
cy: "12",
|
|
116
|
+
r: "3"
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
}),
|
|
120
|
+
'download' === kind && /*#__PURE__*/ jsx("path", {
|
|
121
|
+
d: "M12 3v12m-5-5 5 5 5-5M4 16v5h16v-5"
|
|
122
|
+
}),
|
|
123
|
+
'plus' === kind && /*#__PURE__*/ jsx("path", {
|
|
124
|
+
d: "M12 4v16M4 12h16"
|
|
125
|
+
}),
|
|
126
|
+
'upload' === kind && /*#__PURE__*/ jsx("path", {
|
|
127
|
+
d: "M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5"
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
210
131
|
}
|
|
211
132
|
const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
212
133
|
const config = useTaoConfig();
|
|
@@ -262,7 +183,7 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
262
183
|
setFiles(limited);
|
|
263
184
|
}
|
|
264
185
|
const onChange = propsRef.current.onChange;
|
|
265
|
-
if (onChange && ('removed' === file.status || limited.some((
|
|
186
|
+
if (onChange && ('removed' === file.status || limited.some((item)=>item.uid === file.uid))) {
|
|
266
187
|
const changed = {
|
|
267
188
|
...file
|
|
268
189
|
};
|
|
@@ -278,33 +199,33 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
278
199
|
}
|
|
279
200
|
});
|
|
280
201
|
};
|
|
281
|
-
const update = (
|
|
282
|
-
if (settledRequests.current.has(
|
|
283
|
-
const items = current(), found = items.find((
|
|
202
|
+
const update = (file, patch, event)=>{
|
|
203
|
+
if (settledRequests.current.has(file)) return;
|
|
204
|
+
const items = current(), found = items.find((item)=>item.uid === file.uid);
|
|
284
205
|
if (!found) return;
|
|
285
|
-
const origin = requestOrigins.current.get(
|
|
206
|
+
const origin = requestOrigins.current.get(file);
|
|
286
207
|
if (origin && found.originFileObj && found.originFileObj !== origin) return;
|
|
287
|
-
if ('done' === patch.status || 'error' === patch.status) settledRequests.current.add(
|
|
288
|
-
const
|
|
208
|
+
if ('done' === patch.status || 'error' === patch.status) settledRequests.current.add(file);
|
|
209
|
+
const changed = {
|
|
289
210
|
...found,
|
|
290
211
|
...patch
|
|
291
212
|
};
|
|
292
|
-
emit(
|
|
213
|
+
emit(changed, items.map((item)=>item.uid === file.uid ? changed : item), event);
|
|
293
214
|
};
|
|
294
|
-
const onSuccess = (response,
|
|
215
|
+
const onSuccess = (response, file, xhr)=>update(file, {
|
|
295
216
|
status: 'done',
|
|
296
217
|
percent: 100,
|
|
297
218
|
response,
|
|
298
219
|
xhr
|
|
299
220
|
});
|
|
300
|
-
const onProgress = (
|
|
221
|
+
const onProgress = (event, file)=>update(file, {
|
|
301
222
|
status: 'uploading',
|
|
302
|
-
percent:
|
|
303
|
-
},
|
|
304
|
-
const onError = (error,
|
|
223
|
+
percent: event.percent
|
|
224
|
+
}, event);
|
|
225
|
+
const onError = (error, response, file)=>update(file, {
|
|
305
226
|
status: 'error',
|
|
306
227
|
error,
|
|
307
|
-
response
|
|
228
|
+
response
|
|
308
229
|
});
|
|
309
230
|
const customRequest = props.customRequest;
|
|
310
231
|
const request = customRequest ? (options, info)=>{
|
|
@@ -316,9 +237,9 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
316
237
|
finished = true;
|
|
317
238
|
options.onSuccess?.(...args);
|
|
318
239
|
},
|
|
319
|
-
onError: (...
|
|
240
|
+
onError: (...args)=>{
|
|
320
241
|
finished = true;
|
|
321
|
-
options.onError?.(...
|
|
242
|
+
options.onError?.(...args);
|
|
322
243
|
}
|
|
323
244
|
}, info);
|
|
324
245
|
return finished ? void 0 : handle;
|
|
@@ -328,31 +249,31 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
328
249
|
}
|
|
329
250
|
} : void 0;
|
|
330
251
|
const onBatchStart = (batch)=>{
|
|
331
|
-
const allowed = batch.filter(({ file
|
|
332
|
-
for (const { file
|
|
333
|
-
requestOrigins.current.set(parsedFile,
|
|
252
|
+
const allowed = batch.filter(({ file })=>!ignored.current.delete(file.uid));
|
|
253
|
+
for (const { file, parsedFile } of allowed)if (parsedFile && 'object' == typeof parsedFile) {
|
|
254
|
+
requestOrigins.current.set(parsedFile, file);
|
|
334
255
|
settledRequests.current.delete(parsedFile);
|
|
335
256
|
}
|
|
336
|
-
let
|
|
257
|
+
let next = [
|
|
337
258
|
...current()
|
|
338
259
|
];
|
|
339
|
-
const additions = allowed.map(({ file
|
|
340
|
-
const
|
|
260
|
+
const additions = allowed.map(({ file, parsedFile })=>{
|
|
261
|
+
const error = preparations.current.get(file)?.error;
|
|
341
262
|
return {
|
|
342
|
-
...toFile(
|
|
343
|
-
...
|
|
263
|
+
...toFile(file),
|
|
264
|
+
...error ? {
|
|
344
265
|
status: 'error',
|
|
345
|
-
error
|
|
346
|
-
} :
|
|
266
|
+
error
|
|
267
|
+
} : parsedFile ? {
|
|
347
268
|
status: 'uploading'
|
|
348
269
|
} : {}
|
|
349
270
|
};
|
|
350
271
|
});
|
|
351
|
-
for (const
|
|
352
|
-
...
|
|
353
|
-
|
|
272
|
+
for (const item of additions)next = [
|
|
273
|
+
...next.filter((old)=>old.uid !== item.uid),
|
|
274
|
+
item
|
|
354
275
|
];
|
|
355
|
-
for (const
|
|
276
|
+
for (const item of additions)emit(item, next);
|
|
356
277
|
};
|
|
357
278
|
useImperativeHandle(ref, ()=>({
|
|
358
279
|
onBatchStart,
|
|
@@ -363,37 +284,37 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
363
284
|
upload: uploader.current,
|
|
364
285
|
nativeElement: root.current
|
|
365
286
|
}));
|
|
366
|
-
const remove = async (
|
|
287
|
+
const remove = async (file)=>{
|
|
367
288
|
if (disabled) return;
|
|
368
289
|
const pending = pendingRemovals.current;
|
|
369
|
-
if (sameUploadFile(
|
|
370
|
-
pending.set(
|
|
371
|
-
const isCurrent = (candidate)=>root.current && pending.get(
|
|
290
|
+
if (sameUploadFile(file, pending.get(file.uid))) return;
|
|
291
|
+
pending.set(file.uid, file);
|
|
292
|
+
const isCurrent = (candidate)=>root.current && pending.get(file.uid) === file && sameUploadFile(file, candidate);
|
|
372
293
|
try {
|
|
373
|
-
if (await propsRef.current.onRemove?.(
|
|
374
|
-
const
|
|
375
|
-
const latest =
|
|
294
|
+
if (await propsRef.current.onRemove?.(file) === false) return;
|
|
295
|
+
const items = current();
|
|
296
|
+
const latest = items.find((item)=>item.uid === file.uid);
|
|
376
297
|
if (!latest || !isCurrent(latest)) return;
|
|
377
|
-
uploader.current?.abort(
|
|
298
|
+
uploader.current?.abort(file);
|
|
378
299
|
emit({
|
|
379
300
|
...latest,
|
|
380
301
|
status: 'removed'
|
|
381
|
-
},
|
|
302
|
+
}, items.filter((item)=>item.uid !== file.uid));
|
|
382
303
|
setRemoveError(void 0);
|
|
383
|
-
} catch (
|
|
384
|
-
if (!isCurrent(current().find((
|
|
385
|
-
setRemoveError(
|
|
304
|
+
} catch (error) {
|
|
305
|
+
if (!isCurrent(current().find((item)=>item.uid === file.uid))) return;
|
|
306
|
+
setRemoveError(error instanceof Error ? error.message : config.locale.messages.removeFileError);
|
|
386
307
|
} finally{
|
|
387
|
-
if (pending.get(
|
|
308
|
+
if (pending.get(file.uid) === file) pending.delete(file.uid);
|
|
388
309
|
}
|
|
389
310
|
};
|
|
390
|
-
const download = (
|
|
391
|
-
if (props.onDownload) props.onDownload(
|
|
392
|
-
else if (
|
|
311
|
+
const download = (file)=>{
|
|
312
|
+
if (props.onDownload) props.onDownload(file);
|
|
313
|
+
else if (file.url) window.open(file.url, '_blank', 'noopener,noreferrer');
|
|
393
314
|
};
|
|
394
315
|
const listConfig = 'object' == typeof props.showUploadList ? props.showUploadList : {};
|
|
395
|
-
const visible = (option,
|
|
396
|
-
const renderOption = (
|
|
316
|
+
const visible = (option, file, fallback)=>'function' == typeof option ? option(file) : option ?? fallback;
|
|
317
|
+
const renderOption = (option, file)=>'function' == typeof option ? option(file) : option;
|
|
397
318
|
const triggerStyle = {
|
|
398
319
|
...styles?.trigger
|
|
399
320
|
};
|
|
@@ -404,20 +325,20 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
404
325
|
style: triggerStyle,
|
|
405
326
|
onDragOver: disabled ? void 0 : ()=>setDragging(true),
|
|
406
327
|
onDragLeave: disabled ? void 0 : ()=>setDragging(false),
|
|
407
|
-
onDrop: disabled ? void 0 : (
|
|
328
|
+
onDrop: disabled ? void 0 : (event)=>{
|
|
408
329
|
setDragging(false);
|
|
409
|
-
props.onDrop?.(
|
|
330
|
+
props.onDrop?.(event);
|
|
410
331
|
},
|
|
411
332
|
children: /*#__PURE__*/ jsx(RcUploaderComponent, {
|
|
412
333
|
onFocus: props.onFocus,
|
|
413
334
|
ref: uploader,
|
|
414
335
|
prefixCls: props.prefixCls ?? 'tao-upload-input',
|
|
415
336
|
component: "span",
|
|
416
|
-
action: (
|
|
337
|
+
action: (file)=>preparations.current.get(file)?.action ?? '',
|
|
417
338
|
name: props.name,
|
|
418
339
|
method: props.method,
|
|
419
340
|
headers: props.headers,
|
|
420
|
-
data: (
|
|
341
|
+
data: (file)=>preparations.current.get(file)?.data ?? {},
|
|
421
342
|
customRequest: request,
|
|
422
343
|
withCredentials: props.withCredentials,
|
|
423
344
|
disabled: disabled,
|
|
@@ -429,38 +350,38 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
429
350
|
id: props.id,
|
|
430
351
|
openFileDialogOnClick: props.openFileDialogOnClick,
|
|
431
352
|
hasControlInside: props.hasControlInside ?? (!!props.children || !isCard && 'drag' !== type),
|
|
432
|
-
beforeUpload: async (
|
|
353
|
+
beforeUpload: async (file, list)=>{
|
|
433
354
|
if (!normalizedBatches.current.has(list)) {
|
|
434
|
-
for (const
|
|
435
|
-
lastModifiedDate: new Date(
|
|
355
|
+
for (const item of list)if (!('lastModifiedDate' in item)) Object.assign(item, {
|
|
356
|
+
lastModifiedDate: new Date(item.lastModified)
|
|
436
357
|
});
|
|
437
358
|
normalizedBatches.current.add(list);
|
|
438
359
|
}
|
|
439
|
-
preparations.current.delete(
|
|
440
|
-
const result = await props.beforeUpload?.(
|
|
360
|
+
preparations.current.delete(file);
|
|
361
|
+
const result = await props.beforeUpload?.(file, list);
|
|
441
362
|
if (result === LIST_IGNORE) {
|
|
442
|
-
ignored.current.add(
|
|
363
|
+
ignored.current.add(file.uid);
|
|
443
364
|
return false;
|
|
444
365
|
}
|
|
445
366
|
if (false === result) return false;
|
|
446
367
|
const { action, data } = propsRef.current;
|
|
447
368
|
try {
|
|
448
|
-
preparations.current.set(
|
|
449
|
-
action: 'function' == typeof action ? await action(
|
|
450
|
-
data: 'function' == typeof data ? await data(toFile(
|
|
369
|
+
preparations.current.set(file, {
|
|
370
|
+
action: 'function' == typeof action ? await action(file) : action,
|
|
371
|
+
data: 'function' == typeof data ? await data(toFile(file)) : data
|
|
451
372
|
});
|
|
452
|
-
} catch (
|
|
453
|
-
preparations.current.set(
|
|
454
|
-
error: asError(
|
|
373
|
+
} catch (reason) {
|
|
374
|
+
preparations.current.set(file, {
|
|
375
|
+
error: asError(reason)
|
|
455
376
|
});
|
|
456
377
|
return false;
|
|
457
378
|
}
|
|
458
379
|
return result;
|
|
459
380
|
},
|
|
460
381
|
onBatchStart: onBatchStart,
|
|
461
|
-
onProgress: (
|
|
462
|
-
percent:
|
|
463
|
-
},
|
|
382
|
+
onProgress: (event, file)=>onProgress({
|
|
383
|
+
percent: event.percent ?? 0
|
|
384
|
+
}, file),
|
|
464
385
|
onSuccess: onSuccess,
|
|
465
386
|
onError: onError,
|
|
466
387
|
children: void 0 === props.children ? 'drag' === type ? /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -514,41 +435,41 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
514
435
|
className: names?.list,
|
|
515
436
|
style: styles?.list,
|
|
516
437
|
children: [
|
|
517
|
-
files.map((
|
|
518
|
-
const image = (props.isImageUrl ?? isImageFile)(
|
|
519
|
-
const uploading = 'uploading' ===
|
|
520
|
-
const hasThumbnail = image && !!(
|
|
521
|
-
const icon = props.iconRender?.(
|
|
438
|
+
files.map((file)=>{
|
|
439
|
+
const image = (props.isImageUrl ?? isImageFile)(file);
|
|
440
|
+
const uploading = 'uploading' === file.status;
|
|
441
|
+
const hasThumbnail = image && !!(file.thumbUrl || file.url || file.originFileObj) && !uploading;
|
|
442
|
+
const icon = props.iconRender?.(file, listType) ?? (uploading ? isCard ? locale.uploading : /*#__PURE__*/ jsx(Spinner, {
|
|
522
443
|
size: "small"
|
|
523
444
|
}) : /*#__PURE__*/ jsx(FileIcon, {}));
|
|
524
|
-
const localPreview = image && !!
|
|
525
|
-
const previewUrl =
|
|
445
|
+
const localPreview = image && !!file.originFileObj;
|
|
446
|
+
const previewUrl = file.url || file.thumbUrl;
|
|
526
447
|
const actions = {
|
|
527
448
|
preview: ()=>{
|
|
528
|
-
if (props.onPreview) props.onPreview(
|
|
449
|
+
if (props.onPreview) props.onPreview(file);
|
|
529
450
|
else if (previewUrl) window.open(previewUrl, '_blank', 'noopener,noreferrer');
|
|
530
|
-
else if (localPreview) setPreviewFile(
|
|
451
|
+
else if (localPreview) setPreviewFile(file);
|
|
531
452
|
},
|
|
532
|
-
download: ()=>download(
|
|
453
|
+
download: ()=>download(file),
|
|
533
454
|
remove: ()=>{
|
|
534
|
-
remove(
|
|
455
|
+
remove(file);
|
|
535
456
|
}
|
|
536
457
|
};
|
|
537
458
|
const node = /*#__PURE__*/ jsxs("span", {
|
|
538
459
|
"data-tao-upload-item": "",
|
|
539
|
-
"data-status":
|
|
460
|
+
"data-status": file.status,
|
|
540
461
|
"data-thumbnail": hasThumbnail || void 0,
|
|
541
|
-
title: 'error' ===
|
|
462
|
+
title: 'error' === file.status ? file.error?.message ?? locale.uploadError : file.name,
|
|
542
463
|
className: names?.item,
|
|
543
464
|
style: styles?.item,
|
|
544
465
|
children: [
|
|
545
466
|
'text' !== listType ? hasThumbnail ? /*#__PURE__*/ jsx("button", {
|
|
546
467
|
type: "button",
|
|
547
468
|
"data-tao-upload-thumbnail": "",
|
|
548
|
-
"aria-label":
|
|
469
|
+
"aria-label": file.name,
|
|
549
470
|
onClick: actions.preview,
|
|
550
471
|
children: /*#__PURE__*/ jsx(FilePreview, {
|
|
551
|
-
file:
|
|
472
|
+
file: file,
|
|
552
473
|
previewFile: props.previewFile
|
|
553
474
|
})
|
|
554
475
|
}) : /*#__PURE__*/ jsx("span", {
|
|
@@ -561,86 +482,86 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
561
482
|
/*#__PURE__*/ jsxs("span", {
|
|
562
483
|
"data-tao-upload-details": "",
|
|
563
484
|
children: [
|
|
564
|
-
|
|
485
|
+
file.url ? /*#__PURE__*/ jsx("a", {
|
|
565
486
|
"data-tao-upload-name": "",
|
|
566
|
-
title:
|
|
567
|
-
...
|
|
568
|
-
href:
|
|
487
|
+
title: file.name,
|
|
488
|
+
...file.linkProps,
|
|
489
|
+
href: file.url,
|
|
569
490
|
target: "_blank",
|
|
570
491
|
rel: "noopener noreferrer",
|
|
571
|
-
onClick: (
|
|
572
|
-
const linkClick =
|
|
573
|
-
if ('function' == typeof linkClick) linkClick(
|
|
574
|
-
if (!
|
|
575
|
-
|
|
492
|
+
onClick: (event)=>{
|
|
493
|
+
const linkClick = file.linkProps?.onClick;
|
|
494
|
+
if ('function' == typeof linkClick) linkClick(event);
|
|
495
|
+
if (!event.defaultPrevented && props.onPreview) {
|
|
496
|
+
event.preventDefault();
|
|
576
497
|
actions.preview();
|
|
577
498
|
}
|
|
578
499
|
},
|
|
579
|
-
children:
|
|
500
|
+
children: file.name
|
|
580
501
|
}) : props.onPreview ? /*#__PURE__*/ jsx("button", {
|
|
581
502
|
type: "button",
|
|
582
503
|
"data-tao-upload-name": "",
|
|
583
|
-
title:
|
|
504
|
+
title: file.name,
|
|
584
505
|
onClick: actions.preview,
|
|
585
|
-
children:
|
|
506
|
+
children: file.name
|
|
586
507
|
}) : /*#__PURE__*/ jsx("span", {
|
|
587
508
|
"data-tao-upload-name": "",
|
|
588
|
-
title:
|
|
589
|
-
children:
|
|
509
|
+
title: file.name,
|
|
510
|
+
children: file.name
|
|
590
511
|
}),
|
|
591
|
-
'error' ===
|
|
512
|
+
'error' === file.status && /*#__PURE__*/ jsx("span", {
|
|
592
513
|
"data-tao-upload-error": "",
|
|
593
514
|
role: "status",
|
|
594
|
-
children:
|
|
515
|
+
children: file.error?.message ?? locale.uploadError
|
|
595
516
|
}),
|
|
596
|
-
'uploading' ===
|
|
517
|
+
'uploading' === file.status && /*#__PURE__*/ jsx(Progress, {
|
|
597
518
|
size: "small",
|
|
598
519
|
strokeWidth: 2,
|
|
599
520
|
showInfo: false,
|
|
600
521
|
...props.progress,
|
|
601
|
-
percent:
|
|
602
|
-
"aria-label":
|
|
603
|
-
"aria-labelledby":
|
|
522
|
+
percent: file.percent ?? 0,
|
|
523
|
+
"aria-label": file['aria-label'] ?? props.progress?.['aria-label'] ?? file.name,
|
|
524
|
+
"aria-labelledby": file['aria-labelledby'] ?? props.progress?.['aria-labelledby']
|
|
604
525
|
}),
|
|
605
526
|
null != listConfig.extra && /*#__PURE__*/ jsx("span", {
|
|
606
527
|
"data-tao-upload-extra": "",
|
|
607
|
-
children: renderOption(listConfig.extra,
|
|
528
|
+
children: renderOption(listConfig.extra, file)
|
|
608
529
|
})
|
|
609
530
|
]
|
|
610
531
|
}),
|
|
611
532
|
(!isCard || !uploading) && /*#__PURE__*/ jsxs("span", {
|
|
612
533
|
"data-tao-upload-actions": "",
|
|
613
534
|
children: [
|
|
614
|
-
visible(listConfig.showPreviewIcon,
|
|
535
|
+
visible(listConfig.showPreviewIcon, file, 'picture-card' === listType || 'picture-circle' === listType) && /*#__PURE__*/ jsx(Button, {
|
|
615
536
|
variant: "ghost",
|
|
616
537
|
size: "small",
|
|
617
538
|
disabled: !props.onPreview && !previewUrl && !localPreview,
|
|
618
539
|
type: "button",
|
|
619
|
-
"aria-label": `${locale.previewFile} ${
|
|
540
|
+
"aria-label": `${locale.previewFile} ${file.name}`,
|
|
620
541
|
onClick: actions.preview,
|
|
621
|
-
children: renderOption(listConfig.previewIcon,
|
|
542
|
+
children: renderOption(listConfig.previewIcon, file) ?? /*#__PURE__*/ jsx(FileIcon, {
|
|
622
543
|
kind: "preview"
|
|
623
544
|
})
|
|
624
545
|
}),
|
|
625
|
-
'done' ===
|
|
546
|
+
'done' === file.status && visible(listConfig.showDownloadIcon, file, false) && /*#__PURE__*/ jsx(Button, {
|
|
626
547
|
variant: "ghost",
|
|
627
548
|
size: "small",
|
|
628
|
-
disabled: !props.onDownload && !
|
|
549
|
+
disabled: !props.onDownload && !file.url,
|
|
629
550
|
type: "button",
|
|
630
|
-
"aria-label": `${locale.downloadFile} ${
|
|
551
|
+
"aria-label": `${locale.downloadFile} ${file.name}`,
|
|
631
552
|
onClick: actions.download,
|
|
632
|
-
children: renderOption(listConfig.downloadIcon,
|
|
553
|
+
children: renderOption(listConfig.downloadIcon, file) ?? /*#__PURE__*/ jsx(FileIcon, {
|
|
633
554
|
kind: "download"
|
|
634
555
|
})
|
|
635
556
|
}),
|
|
636
|
-
visible(listConfig.showRemoveIcon,
|
|
557
|
+
visible(listConfig.showRemoveIcon, file, true) && !disabled && /*#__PURE__*/ jsx(Button, {
|
|
637
558
|
variant: "ghost",
|
|
638
559
|
size: "small",
|
|
639
560
|
disabled: false,
|
|
640
561
|
type: "button",
|
|
641
|
-
"aria-label": `${locale.removeFile} ${
|
|
562
|
+
"aria-label": `${locale.removeFile} ${file.name}`,
|
|
642
563
|
onClick: actions.remove,
|
|
643
|
-
children: renderOption(listConfig.removeIcon,
|
|
564
|
+
children: renderOption(listConfig.removeIcon, file) ?? /*#__PURE__*/ jsx(FileIcon, {
|
|
644
565
|
kind: "remove"
|
|
645
566
|
})
|
|
646
567
|
})
|
|
@@ -650,8 +571,8 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
650
571
|
});
|
|
651
572
|
return /*#__PURE__*/ jsx("span", {
|
|
652
573
|
"data-tao-upload-row": "",
|
|
653
|
-
children: props.itemRender ? props.itemRender(node,
|
|
654
|
-
},
|
|
574
|
+
children: props.itemRender ? props.itemRender(node, file, files, actions) : node
|
|
575
|
+
}, file.uid);
|
|
655
576
|
}),
|
|
656
577
|
isCard && trigger
|
|
657
578
|
]
|
|
@@ -677,29 +598,12 @@ const UploadRoot = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
677
598
|
});
|
|
678
599
|
});
|
|
679
600
|
UploadRoot.displayName = 'Upload';
|
|
680
|
-
const Dragger = /*#__PURE__*/ forwardRef((
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
if ($[0] !== t0) {
|
|
687
|
-
({ height, style, styles, ...props } = t0);
|
|
688
|
-
$[0] = t0;
|
|
689
|
-
$[1] = height;
|
|
690
|
-
$[2] = props;
|
|
691
|
-
$[3] = style;
|
|
692
|
-
$[4] = styles;
|
|
693
|
-
} else {
|
|
694
|
-
height = $[1];
|
|
695
|
-
props = $[2];
|
|
696
|
-
style = $[3];
|
|
697
|
-
styles = $[4];
|
|
698
|
-
}
|
|
699
|
-
let t1;
|
|
700
|
-
if ($[5] !== height || $[6] !== style || $[7] !== styles) {
|
|
701
|
-
t1 = (info)=>{
|
|
702
|
-
const resolved = "function" == typeof styles ? styles(info) : styles;
|
|
601
|
+
const Dragger = /*#__PURE__*/ forwardRef(({ height, style, styles, ...props }, ref)=>/*#__PURE__*/ jsx(UploadRoot, {
|
|
602
|
+
...props,
|
|
603
|
+
ref: ref,
|
|
604
|
+
type: "drag",
|
|
605
|
+
styles: (info)=>{
|
|
606
|
+
const resolved = 'function' == typeof styles ? styles(info) : styles;
|
|
703
607
|
return {
|
|
704
608
|
...resolved,
|
|
705
609
|
trigger: {
|
|
@@ -708,27 +612,8 @@ const Dragger = /*#__PURE__*/ forwardRef((t0, ref)=>{
|
|
|
708
612
|
...resolved?.trigger
|
|
709
613
|
}
|
|
710
614
|
};
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
$[6] = style;
|
|
714
|
-
$[7] = styles;
|
|
715
|
-
$[8] = t1;
|
|
716
|
-
} else t1 = $[8];
|
|
717
|
-
let t2;
|
|
718
|
-
if ($[9] !== props || $[10] !== ref || $[11] !== t1) {
|
|
719
|
-
t2 = /*#__PURE__*/ jsx(UploadRoot, {
|
|
720
|
-
...props,
|
|
721
|
-
ref: ref,
|
|
722
|
-
type: "drag",
|
|
723
|
-
styles: t1
|
|
724
|
-
});
|
|
725
|
-
$[9] = props;
|
|
726
|
-
$[10] = ref;
|
|
727
|
-
$[11] = t1;
|
|
728
|
-
$[12] = t2;
|
|
729
|
-
} else t2 = $[12];
|
|
730
|
-
return t2;
|
|
731
|
-
});
|
|
615
|
+
}
|
|
616
|
+
}));
|
|
732
617
|
Dragger.displayName = 'Upload.Dragger';
|
|
733
618
|
const Upload = Object.assign(UploadRoot, {
|
|
734
619
|
Dragger: Dragger,
|