@apexhub/apex-ui-react-source 0.0.0-stage → 1.2.1
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/LICENSE +21 -0
- package/README.md +111 -2
- package/bin/apex-ui-react-source.mjs +901 -0
- package/dist/files/AGENTS.md +89 -0
- package/dist/files/LICENSE +21 -0
- package/dist/files/_assets/adapt-to-page.raw.ts +3 -0
- package/dist/files/_assets/adapt-to-page.url.ts +3 -0
- package/dist/files/_assets/calendar.raw.ts +3 -0
- package/dist/files/_assets/doc-format.raw.ts +3 -0
- package/dist/files/_assets/docx-format.raw.ts +3 -0
- package/dist/files/_assets/full-screen.raw.ts +3 -0
- package/dist/files/_assets/full-screen.url.ts +3 -0
- package/dist/files/_assets/gif-format.raw.ts +3 -0
- package/dist/files/_assets/jpeg-format.raw.ts +3 -0
- package/dist/files/_assets/jpg-format.raw.ts +3 -0
- package/dist/files/_assets/ofd-format.raw.ts +3 -0
- package/dist/files/_assets/one-to-one.raw.ts +3 -0
- package/dist/files/_assets/one-to-one.url.ts +3 -0
- package/dist/files/_assets/pdf-format.raw.ts +3 -0
- package/dist/files/_assets/png-format.raw.ts +3 -0
- package/dist/files/_assets/rotate-left.raw.ts +3 -0
- package/dist/files/_assets/rotate-left.url.ts +3 -0
- package/dist/files/_assets/rotate-right.raw.ts +3 -0
- package/dist/files/_assets/rotate-right.url.ts +3 -0
- package/dist/files/_assets/table-empty.url.ts +3 -0
- package/dist/files/_assets/txt-format.raw.ts +3 -0
- package/dist/files/_assets/upload-file-doc-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-docx-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-gif-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-jpeg-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-jpg-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-ofd-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-pdf-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-png-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-txt-20.raw.ts +3 -0
- package/dist/files/_assets/upload-file-xlsx-20.raw.ts +3 -0
- package/dist/files/_assets/xlsx-format.raw.ts +3 -0
- package/dist/files/_assets/zoom-in.raw.ts +3 -0
- package/dist/files/_assets/zoom-in.url.ts +3 -0
- package/dist/files/_assets/zoom-out.raw.ts +3 -0
- package/dist/files/_assets/zoom-out.url.ts +3 -0
- package/dist/files/_headless/dismiss-intent.ts +1 -0
- package/dist/files/_headless/placement.ts +1 -0
- package/dist/files/_headless/use-embedded-scroll-lock-guard.ts +47 -0
- package/dist/files/_headless/use-floating-overlay.tsx +3 -0
- package/dist/files/_namespace/constants.ts +23 -0
- package/dist/files/_namespace/index.ts +1 -0
- package/dist/files/_overlay/auto-update-anchored-overlay.ts +11 -0
- package/dist/files/_overlay/collision-boundary.ts +78 -0
- package/dist/files/_overlay/dismiss-intent.ts +107 -0
- package/dist/files/_overlay/get-overlay-root.ts +157 -0
- package/dist/files/_overlay/index.ts +57 -0
- package/dist/files/_overlay/observe-anchor-lifecycle.ts +72 -0
- package/dist/files/_overlay/overlay-theme.ts +91 -0
- package/dist/files/_overlay/overlay-trigger.ts +100 -0
- package/dist/files/_overlay/overlay.css +29 -0
- package/dist/files/_overlay/placement.ts +18 -0
- package/dist/files/_overlay/resolve-portal-container.ts +13 -0
- package/dist/files/_overlay/use-anchored-overlay.tsx +493 -0
- package/dist/files/_overlay/zIndex.ts +17 -0
- package/dist/files/_tags/MaxTagList.tsx +336 -0
- package/dist/files/_tags/OverflowTagPopover.tsx +315 -0
- package/dist/files/_tags/get-max-tag-display.ts +26 -0
- package/dist/files/_tags/index.ts +15 -0
- package/dist/files/_tags/resolve-max-tag-popover.ts +28 -0
- package/dist/files/_tags/tags.css +126 -0
- package/dist/files/_tags/types.ts +46 -0
- package/dist/files/_tags/use-responsive-max-tag-count.ts +165 -0
- package/dist/files/alert/Alert.tsx +100 -0
- package/dist/files/alert/alert.css +85 -0
- package/dist/files/alert/index.ts +2 -0
- package/dist/files/alert/interface.ts +59 -0
- package/dist/files/alert/llm.txt +160 -0
- package/dist/files/alert/tokens.txt +44 -0
- package/dist/files/alert/variants.ts +17 -0
- package/dist/files/apex-env.d.ts +2 -0
- package/dist/files/apex-provider/ApexProvider.tsx +53 -0
- package/dist/files/apex-provider/apex-provider.css +0 -0
- package/dist/files/apex-provider/context.ts +17 -0
- package/dist/files/apex-provider/index.ts +18 -0
- package/dist/files/apex-provider/interface.ts +181 -0
- package/dist/files/apex-provider/llm.txt +367 -0
- package/dist/files/apex-provider/localeKind.ts +20 -0
- package/dist/files/auto-complete/AutoComplete.tsx +419 -0
- package/dist/files/auto-complete/auto-complete.css +108 -0
- package/dist/files/auto-complete/auto-complete.stories.css +17 -0
- package/dist/files/auto-complete/index.ts +8 -0
- package/dist/files/auto-complete/interface.ts +77 -0
- package/dist/files/auto-complete/llm.txt +374 -0
- package/dist/files/auto-complete/tokens.txt +77 -0
- package/dist/files/auto-complete/variants.ts +19 -0
- package/dist/files/avatar/Avatar.tsx +277 -0
- package/dist/files/avatar/avatar.css +159 -0
- package/dist/files/avatar/index.ts +2 -0
- package/dist/files/avatar/interface.ts +147 -0
- package/dist/files/avatar/llm.txt +195 -0
- package/dist/files/avatar/tokens.txt +38 -0
- package/dist/files/avatar/use-responsive-size.ts +66 -0
- package/dist/files/avatar/variants.ts +41 -0
- package/dist/files/breadcrumb/Breadcrumb.stories.css +5 -0
- package/dist/files/breadcrumb/Breadcrumb.tsx +238 -0
- package/dist/files/breadcrumb/BreadcrumbLink.tsx +63 -0
- package/dist/files/breadcrumb/BreadcrumbSeparatorIcon.tsx +30 -0
- package/dist/files/breadcrumb/breadcrumb.css +113 -0
- package/dist/files/breadcrumb/index.ts +12 -0
- package/dist/files/breadcrumb/interface.ts +81 -0
- package/dist/files/breadcrumb/llm.txt +249 -0
- package/dist/files/breadcrumb/tokens.txt +193 -0
- package/dist/files/breadcrumb/variants.ts +8 -0
- package/dist/files/button/Button.tsx +235 -0
- package/dist/files/button/button.css +261 -0
- package/dist/files/button/index.ts +2 -0
- package/dist/files/button/interface.ts +145 -0
- package/dist/files/button/llm.txt +254 -0
- package/dist/files/button/tokens.txt +470 -0
- package/dist/files/button/variants.ts +89 -0
- package/dist/files/card/Card.tsx +63 -0
- package/dist/files/card/card.css +66 -0
- package/dist/files/card/index.ts +2 -0
- package/dist/files/card/interface.ts +25 -0
- package/dist/files/card/llm.txt +93 -0
- package/dist/files/card/tokens.txt +27 -0
- package/dist/files/cascader/Cascader.tsx +955 -0
- package/dist/files/cascader/_adapter/locale.ts +4 -0
- package/dist/files/cascader/cascader-data.ts +354 -0
- package/dist/files/cascader/cascader.css +382 -0
- package/dist/files/cascader/index.ts +16 -0
- package/dist/files/cascader/interface.ts +358 -0
- package/dist/files/cascader/llm.txt +897 -0
- package/dist/files/cascader/tokens.txt +253 -0
- package/dist/files/cascader/variants.ts +35 -0
- package/dist/files/checkbox/Checkbox.tsx +477 -0
- package/dist/files/checkbox/checkbox.css +196 -0
- package/dist/files/checkbox/index.ts +9 -0
- package/dist/files/checkbox/interface.ts +162 -0
- package/dist/files/checkbox/llm.txt +326 -0
- package/dist/files/checkbox/tokens.txt +28 -0
- package/dist/files/checkbox/variants.ts +29 -0
- package/dist/files/clear/Clear.tsx +49 -0
- package/dist/files/clear/clear.css +60 -0
- package/dist/files/clear/index.ts +2 -0
- package/dist/files/clear/interface.ts +8 -0
- package/dist/files/collapse/Collapse.tsx +163 -0
- package/dist/files/collapse/collapse.css +174 -0
- package/dist/files/collapse/index.ts +2 -0
- package/dist/files/collapse/interface.ts +132 -0
- package/dist/files/collapse/llm.txt +328 -0
- package/dist/files/collapse/tokens.txt +84 -0
- package/dist/files/core/date-picker/index.ts +191 -0
- package/dist/files/core/form/index.ts +212 -0
- package/dist/files/core/index.ts +11 -0
- package/dist/files/core/input-number/index.ts +112 -0
- package/dist/files/core/namespace/index.ts +14 -0
- package/dist/files/core/overlay/index.ts +40 -0
- package/dist/files/core/pagination/index.ts +128 -0
- package/dist/files/core/table/access.ts +37 -0
- package/dist/files/core/table/columns.ts +4 -0
- package/dist/files/core/table/data-model.ts +58 -0
- package/dist/files/core/table/fixed-offset.ts +29 -0
- package/dist/files/core/table/grouped-header.ts +24 -0
- package/dist/files/core/table/index.ts +11 -0
- package/dist/files/core/table/merge.ts +132 -0
- package/dist/files/core/table/pagination.ts +51 -0
- package/dist/files/core/table/rowModel.ts +4 -0
- package/dist/files/core/table/types.ts +14 -0
- package/dist/files/core/typography/index.ts +125 -0
- package/dist/files/core/upload/file-type.ts +160 -0
- package/dist/files/core/upload/format-size.ts +17 -0
- package/dist/files/core/upload/index.ts +19 -0
- package/dist/files/core/upload/limits.ts +76 -0
- package/dist/files/core/utils/cn.ts +6 -0
- package/dist/files/core/utils/index.ts +2 -0
- package/dist/files/core/utils/svg.ts +101 -0
- package/dist/files/date-picker/DatePicker.tsx +601 -0
- package/dist/files/date-picker/RangePicker.tsx +1047 -0
- package/dist/files/date-picker/Trigger.tsx +115 -0
- package/dist/files/date-picker/_adapter/calendar.ts +136 -0
- package/dist/files/date-picker/_adapter/disable.ts +89 -0
- package/dist/files/date-picker/_adapter/format.ts +54 -0
- package/dist/files/date-picker/_adapter/keymap.ts +17 -0
- package/dist/files/date-picker/_adapter/locale.ts +4 -0
- package/dist/files/date-picker/_adapter/presets.ts +30 -0
- package/dist/files/date-picker/_adapter/range.ts +44 -0
- package/dist/files/date-picker/_adapter/types.ts +29 -0
- package/dist/files/date-picker/context.ts +60 -0
- package/dist/files/date-picker/date-picker.css +1093 -0
- package/dist/files/date-picker/index.ts +26 -0
- package/dist/files/date-picker/interface.ts +135 -0
- package/dist/files/date-picker/llm.txt +422 -0
- package/dist/files/date-picker/panels/DatePanel.tsx +110 -0
- package/dist/files/date-picker/panels/DecadePanel.tsx +49 -0
- package/dist/files/date-picker/panels/Footer.tsx +109 -0
- package/dist/files/date-picker/panels/Header.tsx +228 -0
- package/dist/files/date-picker/panels/MonthPanel.tsx +83 -0
- package/dist/files/date-picker/panels/Panel.tsx +339 -0
- package/dist/files/date-picker/panels/QuarterPanel.tsx +70 -0
- package/dist/files/date-picker/panels/TimePanel.tsx +171 -0
- package/dist/files/date-picker/panels/WeekPanel.tsx +145 -0
- package/dist/files/date-picker/panels/YearPanel.tsx +89 -0
- package/dist/files/date-picker/panels/time-panel-utils.ts +33 -0
- package/dist/files/date-picker/tokens.txt +171 -0
- package/dist/files/date-picker/variants.ts +20 -0
- package/dist/files/divider/Divider.tsx +80 -0
- package/dist/files/divider/divider.css +66 -0
- package/dist/files/divider/index.ts +7 -0
- package/dist/files/divider/interface.ts +58 -0
- package/dist/files/divider/llm.txt +158 -0
- package/dist/files/divider/tokens.txt +22 -0
- package/dist/files/drawer/Drawer.tsx +491 -0
- package/dist/files/drawer/drawer.css +201 -0
- package/dist/files/drawer/index.ts +13 -0
- package/dist/files/drawer/interface.ts +172 -0
- package/dist/files/drawer/llm.txt +374 -0
- package/dist/files/drawer/tokens.txt +71 -0
- package/dist/files/drawer/variants.ts +14 -0
- package/dist/files/dropdown/Dropdown.tsx +629 -0
- package/dist/files/dropdown/dropdown.css +243 -0
- package/dist/files/dropdown/index.ts +12 -0
- package/dist/files/dropdown/interface.ts +91 -0
- package/dist/files/dropdown/lib.ts +78 -0
- package/dist/files/dropdown/llm.txt +427 -0
- package/dist/files/dropdown/tokens.txt +59 -0
- package/dist/files/form/Form.tsx +229 -0
- package/dist/files/form/FormItem.tsx +526 -0
- package/dist/files/form/_adapter/bindField.ts +189 -0
- package/dist/files/form/_adapter/compileRules.ts +185 -0
- package/dist/files/form/_adapter/controlStatus.ts +23 -0
- package/dist/files/form/_adapter/deriveStatus.ts +42 -0
- package/dist/files/form/_adapter/instance.ts +281 -0
- package/dist/files/form/_adapter/messages.ts +15 -0
- package/dist/files/form/_adapter/types.ts +82 -0
- package/dist/files/form/_adapter/validationMeta.ts +29 -0
- package/dist/files/form/_adapter/validationTransaction.ts +69 -0
- package/dist/files/form/context.ts +38 -0
- package/dist/files/form/form.css +268 -0
- package/dist/files/form/index.ts +13 -0
- package/dist/files/form/interface.ts +99 -0
- package/dist/files/form/llm.txt +346 -0
- package/dist/files/form/tokens.txt +26 -0
- package/dist/files/form/useForm.ts +150 -0
- package/dist/files/form/utils.ts +28 -0
- package/dist/files/form/variants.ts +30 -0
- package/dist/files/global.css +8 -0
- package/dist/files/grid/Col.tsx +104 -0
- package/dist/files/grid/Grid.tsx +18 -0
- package/dist/files/grid/Row.tsx +129 -0
- package/dist/files/grid/grid.css +990 -0
- package/dist/files/grid/index.ts +12 -0
- package/dist/files/grid/interface.ts +109 -0
- package/dist/files/grid/llm.txt +419 -0
- package/dist/files/grid/useBreakpoint.ts +67 -0
- package/dist/files/icon/Icon.tsx +16 -0
- package/dist/files/icon/icon.css +26 -0
- package/dist/files/icon/icons-map.ts +1 -0
- package/dist/files/icon/index.ts +2 -0
- package/dist/files/icon/interface.ts +9 -0
- package/dist/files/icons/ActionIcons.tsx +105 -0
- package/dist/files/icons/AlertCloseIcon.tsx +21 -0
- package/dist/files/icons/CalendarIcon.tsx +6 -0
- package/dist/files/icons/CaretIcons.tsx +43 -0
- package/dist/files/icons/FileFormatIcons.tsx +27 -0
- package/dist/files/icons/Icons.tsx +10 -0
- package/dist/files/icons/MagnifyingGlassIcon.tsx +26 -0
- package/dist/files/icons/MessageIcons.tsx +111 -0
- package/dist/files/icons/NavigationIcons.tsx +126 -0
- package/dist/files/icons/PreviewIcons.tsx +18 -0
- package/dist/files/icons/StarIcons.tsx +71 -0
- package/dist/files/icons/UploadIcons.tsx +167 -0
- package/dist/files/icons/XCloseIcon.tsx +26 -0
- package/dist/files/icons/createAssetIcon.tsx +64 -0
- package/dist/files/icons/icons.css +4 -0
- package/dist/files/icons/index.ts +36 -0
- package/dist/files/icons/interface.ts +9 -0
- package/dist/files/icons/registry.ts +94 -0
- package/dist/files/image/Image.tsx +328 -0
- package/dist/files/image/ImageActionIcons.tsx +60 -0
- package/dist/files/image/ImagePreview.tsx +684 -0
- package/dist/files/image/_adapter/locale.ts +4 -0
- package/dist/files/image/image.css +451 -0
- package/dist/files/image/index.ts +7 -0
- package/dist/files/image/interface.ts +139 -0
- package/dist/files/image/llm.txt +429 -0
- package/dist/files/image/tokens.txt +28 -0
- package/dist/files/input/Input.tsx +261 -0
- package/dist/files/input/icons.tsx +3 -0
- package/dist/files/input/index.ts +12 -0
- package/dist/files/input/input-clear.stories.css +12 -0
- package/dist/files/input/input-size.ts +36 -0
- package/dist/files/input/input.css +366 -0
- package/dist/files/input/interface.ts +204 -0
- package/dist/files/input/lib.ts +51 -0
- package/dist/files/input/llm.txt +419 -0
- package/dist/files/input/tokens.txt +136 -0
- package/dist/files/input/variants.ts +17 -0
- package/dist/files/input-number/InputNumber.tsx +510 -0
- package/dist/files/input-number/icons.tsx +28 -0
- package/dist/files/input-number/index.ts +15 -0
- package/dist/files/input-number/input-number.css +440 -0
- package/dist/files/input-number/interface.ts +269 -0
- package/dist/files/input-number/lib.ts +128 -0
- package/dist/files/input-number/llm.txt +484 -0
- package/dist/files/input-number/tokens.txt +159 -0
- package/dist/files/input-number/variants.ts +27 -0
- package/dist/files/layout/Layout.tsx +360 -0
- package/dist/files/layout/index.ts +21 -0
- package/dist/files/layout/interface.ts +106 -0
- package/dist/files/layout/layout.css +278 -0
- package/dist/files/layout/llm.txt +296 -0
- package/dist/files/layout/tokens.txt +29 -0
- package/dist/files/llms-theme.txt +32 -0
- package/dist/files/llms.txt +895 -0
- package/dist/files/locale/en_US.ts +167 -0
- package/dist/files/locale/zh_CN.ts +166 -0
- package/dist/files/menu/Menu.stories.shared.tsx +85 -0
- package/dist/files/menu/Menu.tsx +713 -0
- package/dist/files/menu/demo/menu-sliding-panel.css +71 -0
- package/dist/files/menu/demo/use-sliding-panel.ts +35 -0
- package/dist/files/menu/icons.tsx +92 -0
- package/dist/files/menu/index.ts +17 -0
- package/dist/files/menu/interface.ts +229 -0
- package/dist/files/menu/lib.ts +160 -0
- package/dist/files/menu/llm.txt +686 -0
- package/dist/files/menu/menu.css +455 -0
- package/dist/files/menu/tokens.txt +87 -0
- package/dist/files/message/Message.tsx +217 -0
- package/dist/files/message/index.ts +2 -0
- package/dist/files/message/interface.ts +149 -0
- package/dist/files/message/lib/constants.ts +18 -0
- package/dist/files/message/lib/helpers.ts +26 -0
- package/dist/files/message/lib/motion.ts +117 -0
- package/dist/files/message/lib/store.ts +72 -0
- package/dist/files/message/llm.txt +301 -0
- package/dist/files/message/message.css +178 -0
- package/dist/files/message/tokens.txt +25 -0
- package/dist/files/modal/Modal.tsx +547 -0
- package/dist/files/modal/_adapter/locale.ts +4 -0
- package/dist/files/modal/index.ts +16 -0
- package/dist/files/modal/interface.ts +368 -0
- package/dist/files/modal/lib/ConfirmDialog.tsx +229 -0
- package/dist/files/modal/lib/confirm.tsx +112 -0
- package/dist/files/modal/lib/confirmIcons.tsx +21 -0
- package/dist/files/modal/lib/useModal.tsx +130 -0
- package/dist/files/modal/llm.txt +586 -0
- package/dist/files/modal/modal-padding.stories.css +22 -0
- package/dist/files/modal/modal.css +322 -0
- package/dist/files/modal/tokens.txt +96 -0
- package/dist/files/modal/variants.ts +41 -0
- package/dist/files/notification/Notification.tsx +354 -0
- package/dist/files/notification/index.ts +8 -0
- package/dist/files/notification/interface.ts +140 -0
- package/dist/files/notification/lib/constants.ts +40 -0
- package/dist/files/notification/lib/helpers.ts +31 -0
- package/dist/files/notification/lib/motion.ts +148 -0
- package/dist/files/notification/lib/store.ts +149 -0
- package/dist/files/notification/llm.txt +386 -0
- package/dist/files/notification/notification.css +416 -0
- package/dist/files/notification/tokens.txt +79 -0
- package/dist/files/pagination/PageButton.tsx +48 -0
- package/dist/files/pagination/PageSizeChanger.tsx +42 -0
- package/dist/files/pagination/Pagination.tsx +308 -0
- package/dist/files/pagination/QuickJumper.tsx +52 -0
- package/dist/files/pagination/TotalText.tsx +28 -0
- package/dist/files/pagination/_adapter/calculate.ts +33 -0
- package/dist/files/pagination/_adapter/locale.ts +4 -0
- package/dist/files/pagination/_adapter/responsive.ts +22 -0
- package/dist/files/pagination/_adapter/types.ts +27 -0
- package/dist/files/pagination/context.ts +15 -0
- package/dist/files/pagination/index.ts +3 -0
- package/dist/files/pagination/interface.ts +55 -0
- package/dist/files/pagination/llm.txt +204 -0
- package/dist/files/pagination/pagination.css +241 -0
- package/dist/files/pagination/tokens.txt +33 -0
- package/dist/files/pagination/useResizeObserver.ts +40 -0
- package/dist/files/pagination/variants.ts +3 -0
- package/dist/files/popover/Popover.tsx +353 -0
- package/dist/files/popover/index.ts +2 -0
- package/dist/files/popover/interface.ts +124 -0
- package/dist/files/popover/llm.txt +235 -0
- package/dist/files/popover/placement.ts +39 -0
- package/dist/files/popover/popover.css +65 -0
- package/dist/files/popover/popover.stories.css +42 -0
- package/dist/files/popover/tokens.txt +28 -0
- package/dist/files/progress/Progress.tsx +213 -0
- package/dist/files/progress/index.ts +4 -0
- package/dist/files/progress/interface.ts +89 -0
- package/dist/files/progress/llm.txt +277 -0
- package/dist/files/progress/progress.css +192 -0
- package/dist/files/progress/tokens.txt +83 -0
- package/dist/files/radio/Radio.tsx +315 -0
- package/dist/files/radio/context.tsx +16 -0
- package/dist/files/radio/helpers.ts +163 -0
- package/dist/files/radio/index.ts +13 -0
- package/dist/files/radio/interface.ts +207 -0
- package/dist/files/radio/llm.txt +344 -0
- package/dist/files/radio/radio.css +137 -0
- package/dist/files/radio/tokens.txt +21 -0
- package/dist/files/radio/variants.ts +20 -0
- package/dist/files/rate/Rate.tsx +199 -0
- package/dist/files/rate/RateItem.tsx +113 -0
- package/dist/files/rate/StarFilled.tsx +19 -0
- package/dist/files/rate/index.ts +11 -0
- package/dist/files/rate/interface.ts +116 -0
- package/dist/files/rate/lib.ts +72 -0
- package/dist/files/rate/llm.txt +237 -0
- package/dist/files/rate/rate.css +126 -0
- package/dist/files/rate/tokens.txt +20 -0
- package/dist/files/rate/variants.ts +19 -0
- package/dist/files/scrollbar.css +148 -0
- package/dist/files/select/Select.tsx +1366 -0
- package/dist/files/select/_adapter/locale.ts +4 -0
- package/dist/files/select/index.ts +17 -0
- package/dist/files/select/interface.ts +494 -0
- package/dist/files/select/llm.txt +828 -0
- package/dist/files/select/select-overflow.stories.css +3 -0
- package/dist/files/select/select.css +443 -0
- package/dist/files/select/tokens.txt +160 -0
- package/dist/files/select/variants.ts +63 -0
- package/dist/files/skeleton/Skeleton.tsx +345 -0
- package/dist/files/skeleton/index.ts +19 -0
- package/dist/files/skeleton/interface.ts +101 -0
- package/dist/files/skeleton/llm.txt +274 -0
- package/dist/files/skeleton/skeleton.css +171 -0
- package/dist/files/skeleton/tokens.txt +15 -0
- package/dist/files/skeleton/variants.ts +40 -0
- package/dist/files/spin/Spin.tsx +197 -0
- package/dist/files/spin/index.ts +2 -0
- package/dist/files/spin/interface.ts +69 -0
- package/dist/files/spin/llm.txt +294 -0
- package/dist/files/spin/spin.css +111 -0
- package/dist/files/spin/tokens.txt +21 -0
- package/dist/files/spin/variants.ts +19 -0
- package/dist/files/steps/Steps.tsx +211 -0
- package/dist/files/steps/index.ts +11 -0
- package/dist/files/steps/interface.ts +155 -0
- package/dist/files/steps/lib.ts +46 -0
- package/dist/files/steps/llm.txt +296 -0
- package/dist/files/steps/steps.css +268 -0
- package/dist/files/steps/tokens.txt +30 -0
- package/dist/files/steps/variants.ts +15 -0
- package/dist/files/switch/Switch.tsx +131 -0
- package/dist/files/switch/index.ts +2 -0
- package/dist/files/switch/interface.ts +92 -0
- package/dist/files/switch/llm.txt +212 -0
- package/dist/files/switch/switch.css +198 -0
- package/dist/files/switch/tokens.txt +38 -0
- package/dist/files/switch/variants.ts +15 -0
- package/dist/files/table/Table.stories.css +56 -0
- package/dist/files/table/Table.tsx +481 -0
- package/dist/files/table/_adapter/locale.ts +4 -0
- package/dist/files/table/constants.ts +7 -0
- package/dist/files/table/context.ts +46 -0
- package/dist/files/table/hooks/useColumnControl.ts +135 -0
- package/dist/files/table/hooks/useColumns.ts +87 -0
- package/dist/files/table/hooks/useExpandable.tsx +271 -0
- package/dist/files/table/hooks/useOverlayScrollbar.ts +304 -0
- package/dist/files/table/hooks/usePagination.ts +110 -0
- package/dist/files/table/hooks/useRowSelection.tsx +250 -0
- package/dist/files/table/hooks/useScrollShadow.ts +66 -0
- package/dist/files/table/hooks/useSkeletonRowCount.ts +78 -0
- package/dist/files/table/hooks/useTableLayoutScale.ts +38 -0
- package/dist/files/table/hooks/useTableModel.ts +91 -0
- package/dist/files/table/index.ts +24 -0
- package/dist/files/table/interface.ts +407 -0
- package/dist/files/table/llm.txt +1050 -0
- package/dist/files/table/parts/TableBody.tsx +396 -0
- package/dist/files/table/parts/TableCell.tsx +123 -0
- package/dist/files/table/parts/TableColgroup.tsx +35 -0
- package/dist/files/table/parts/TableEmpty.tsx +48 -0
- package/dist/files/table/parts/TableEmptyIllustration.tsx +27 -0
- package/dist/files/table/parts/TableHeader.tsx +102 -0
- package/dist/files/table/parts/TablePagination.tsx +46 -0
- package/dist/files/table/parts/TableRow.tsx +42 -0
- package/dist/files/table/parts/TableScrollbars.tsx +79 -0
- package/dist/files/table/parts/TableSkeleton.tsx +47 -0
- package/dist/files/table/parts/TableSummary.tsx +121 -0
- package/dist/files/table/table.css +850 -0
- package/dist/files/table/tokenScopes.ts +28 -0
- package/dist/files/table/tokens.txt +94 -0
- package/dist/files/table/utils/computeMergeGrid.ts +41 -0
- package/dist/files/table/utils/dataModel.ts +45 -0
- package/dist/files/table/utils/getCellValue.ts +7 -0
- package/dist/files/table/utils/getGroupedHeaderSpan.ts +73 -0
- package/dist/files/table/utils/getRowKey.ts +31 -0
- package/dist/files/table/utils/paginationState.ts +31 -0
- package/dist/files/table/utils/prefixSvgIds.ts +6 -0
- package/dist/files/table/utils/scaleFixedOffset.ts +19 -0
- package/dist/files/tabs/Tabs.tsx +140 -0
- package/dist/files/tabs/index.ts +2 -0
- package/dist/files/tabs/interface.ts +117 -0
- package/dist/files/tabs/llm.txt +305 -0
- package/dist/files/tabs/tabs.css +299 -0
- package/dist/files/tabs/tokens.txt +78 -0
- package/dist/files/tabs/variants.ts +51 -0
- package/dist/files/tag/Tag.tsx +180 -0
- package/dist/files/tag/index.ts +8 -0
- package/dist/files/tag/interface.ts +68 -0
- package/dist/files/tag/llm.txt +301 -0
- package/dist/files/tag/tag.css +96 -0
- package/dist/files/tag/tokens.txt +76 -0
- package/dist/files/tag/variants.ts +71 -0
- package/dist/files/theme/aliases.css +217 -0
- package/dist/files/theme/component-tokens.css +2211 -0
- package/dist/files/theme/index.css +4 -0
- package/dist/files/theme/primitives.css +182 -0
- package/dist/files/theme/static.css +13 -0
- package/dist/files/tooltip/Tooltip.tsx +362 -0
- package/dist/files/tooltip/index.ts +7 -0
- package/dist/files/tooltip/interface.ts +118 -0
- package/dist/files/tooltip/llm.txt +308 -0
- package/dist/files/tooltip/placement.ts +51 -0
- package/dist/files/tooltip/tokens.txt +22 -0
- package/dist/files/tooltip/tooltip.css +78 -0
- package/dist/files/tree/Tree.tsx +1069 -0
- package/dist/files/tree/constants.ts +2 -0
- package/dist/files/tree/index.ts +22 -0
- package/dist/files/tree/interface.ts +447 -0
- package/dist/files/tree/llm.txt +501 -0
- package/dist/files/tree/tokens.txt +36 -0
- package/dist/files/tree/tree-data.ts +260 -0
- package/dist/files/tree/tree.css +231 -0
- package/dist/files/tree/variants.ts +25 -0
- package/dist/files/tree-select/TreeSelect.tsx +864 -0
- package/dist/files/tree-select/_adapter/locale.ts +4 -0
- package/dist/files/tree-select/index.ts +23 -0
- package/dist/files/tree-select/interface.ts +415 -0
- package/dist/files/tree-select/llm.txt +754 -0
- package/dist/files/tree-select/tokens.txt +174 -0
- package/dist/files/tree-select/tree-select-data.ts +294 -0
- package/dist/files/tree-select/tree-select.css +303 -0
- package/dist/files/tree-select/variants.ts +42 -0
- package/dist/files/typography/Typography.tsx +739 -0
- package/dist/files/typography/_adapter/locale.ts +4 -0
- package/dist/files/typography/canvasTextMeasure.ts +148 -0
- package/dist/files/typography/index.ts +21 -0
- package/dist/files/typography/interface.ts +154 -0
- package/dist/files/typography/llm.txt +412 -0
- package/dist/files/typography/tokens.txt +60 -0
- package/dist/files/typography/typography.css +312 -0
- package/dist/files/typography/useEllipsisSuffix.ts +245 -0
- package/dist/files/typography/variants.ts +24 -0
- package/dist/files/upload/Upload.stories.css +54 -0
- package/dist/files/upload/Upload.stories.shared.ts +21 -0
- package/dist/files/upload/Upload.tsx +1108 -0
- package/dist/files/upload/UploadActionIcons.tsx +13 -0
- package/dist/files/upload/UploadFileIcon.tsx +52 -0
- package/dist/files/upload/_adapter/locale.ts +4 -0
- package/dist/files/upload/constants.ts +46 -0
- package/dist/files/upload/index.ts +38 -0
- package/dist/files/upload/interface.ts +302 -0
- package/dist/files/upload/lib/file-type.ts +60 -0
- package/dist/files/upload/lib/format-size.ts +6 -0
- package/dist/files/upload/lib/limits.ts +46 -0
- package/dist/files/upload/llm.txt +705 -0
- package/dist/files/upload/tokens.txt +201 -0
- package/dist/files/upload/upload.css +460 -0
- package/dist/files/utils/cn.ts +16 -0
- package/dist/files/utils/env.ts +16 -0
- package/dist/files/utils/normalizeRawSvg.ts +12 -0
- package/dist/manifest.json +580 -0
- package/package.json +29 -4
- package/template/_gitignore +5 -0
- package/template/index.html +12 -0
- package/template/src/App.tsx +25 -0
- package/template/src/main.tsx +14 -0
- package/template/tsconfig.app.json +22 -0
- package/template/tsconfig.json +4 -0
- package/template/tsconfig.node.json +16 -0
- package/template/vite.config.ts +8 -0
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
# Upload
|
|
2
|
+
|
|
3
|
+
> Upload:需要将本地文件上传到服务端,并展示上传进度与结果列表时。
|
|
4
|
+
|
|
5
|
+
版本:`1.2.1`。组件源码在本目录,属于当前项目。
|
|
6
|
+
|
|
7
|
+
公开导出:`canPreviewFile`、`configureUploadLimits`、`formatFileSize`、`getFileExtension`、`getFileFormatIconName`、`getFileKind`、`getFilePreviewKind`、`getFilePreviewUrl`、`getUploadLimits`、`isDocumentFile`、`isImageFile`、`resetUploadLimits`、`UPLOAD_DEFAULT_MAX_COUNT`、`UPLOAD_DEFAULT_MAX_FILE_SIZE`、`UPLOAD_LIST_IGNORE`、`Upload`。
|
|
8
|
+
|
|
9
|
+
以下 API 属于 Apex UI;不要据 antd 的同名组件推断额外属性或默认值。默认值列的空缺表示未声明,不代表 `false`。
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Upload } from '@/components/apex/upload'
|
|
15
|
+
|
|
16
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
17
|
+
|
|
18
|
+
function uploadDemoImageDataUrl(
|
|
19
|
+
fill: string,
|
|
20
|
+
label: string,
|
|
21
|
+
width = 200,
|
|
22
|
+
height = 200,
|
|
23
|
+
): string {
|
|
24
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
25
|
+
return (
|
|
26
|
+
'data:image/svg+xml;utf8,' +
|
|
27
|
+
encodeURIComponent(
|
|
28
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
34
|
+
|
|
35
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
36
|
+
|
|
37
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
38
|
+
|
|
39
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
40
|
+
|
|
41
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
42
|
+
onSuccess,
|
|
43
|
+
}) => {
|
|
44
|
+
window.setTimeout(() => {
|
|
45
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
46
|
+
}, 300)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default () => <Upload customRequest={uploadDemoCustomRequest} listType="text" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 何时使用
|
|
53
|
+
|
|
54
|
+
- 需要将本地文件上传到服务端,并展示上传进度与结果列表时。
|
|
55
|
+
- 图片场景可使用 `listType="picture"` 或 `picture-card` 展示缩略图。
|
|
56
|
+
- 大文件、分片上传或自定义签名流程请使用 `customRequest` 完全接管上传逻辑。
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
仅使用类型定义支持的属性;原生属性、ref 目标和事件签名因组件而异。关联类型用于解释字段结构;只有「导出类型」中的名称可从包根导入。
|
|
61
|
+
|
|
62
|
+
### Upload
|
|
63
|
+
|
|
64
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
65
|
+
| --- | --- | --- | --- | --- |
|
|
66
|
+
| accept | 接受的文件类型 | `string \| UploadAcceptObject` | 否 | — |
|
|
67
|
+
| action | 上传地址;可为异步函数以动态解析 URL | `string \| ((file: File) => Promise<string>)` | 否 | — |
|
|
68
|
+
| beforeUpload | 上传前钩子;返回 `false` 或 reject 的 Promise 则不上传;<br>返回 `File`/`Blob` 则上传该对象;返回 `UPLOAD_LIST_IGNORE` 则不展示在列表 | `( file: File, fileList: File[], ) => File \| Blob \| boolean \| UploadListIgnore \| Promise<File \| Blob \| boolean \| UploadListIgnore>` | 否 | — |
|
|
69
|
+
| customRequest | 自定义上传实现;可通过 `info.defaultRequest` 调用内置上传 | `( options: UploadRequestOptions, info: { defaultRequest: (option: UploadRequestOptions) => void }, ) => void \| Promise<void>` | 否 | — |
|
|
70
|
+
| data | 上传附加字段或动态生成附加字段 | `Record<string, unknown> \| ((file: File) => Record<string, unknown> \| Promise<Record<string, unknown>>)` | 否 | — |
|
|
71
|
+
| defaultFileList | 非受控模式下的初始文件列表 | `UploadFile[]` | 否 | — |
|
|
72
|
+
| disabled | 是否禁用文件选择、拖拽及列表修改操作;已有文件仍可预览、下载。<br>text/picture 正常与手动文件行使用禁用样式,上传中与错误文件保留状态色。 | `boolean` | 否 | `false` |
|
|
73
|
+
| fileList | 受控文件列表 | `UploadFile[]` | 否 | — |
|
|
74
|
+
| headers | 上传请求头 | `Record<string, string>` | 否 | — |
|
|
75
|
+
| isImageUrl | 自定义是否按图片渲染缩略图 | `(file: UploadFile) => boolean` | 否 | — |
|
|
76
|
+
| prefixIcon | text 列表文件名前的装饰图标,可传节点或按文件返回节点。<br>未传或返回 undefined 时使用默认文件格式图标;null/false 隐藏图标。<br>不影响 picture/picture-card 缩略图或右侧操作图标。 | `React.ReactNode \| ((file: UploadFile) => React.ReactNode)` | 否 | — |
|
|
77
|
+
| itemRender | 自定义列表项节点 | `( originNode: React.ReactElement, file: UploadFile, fileList: UploadFile[], actions: { download: () => void preview: () => void remove: () => void }, ) => React.ReactNode` | 否 | — |
|
|
78
|
+
| listType | 列表展示形态 | `"picture" \| "text" \| "picture-card"` | 否 | `'text'` |
|
|
79
|
+
| variant | 触发区与 text/picture 列表项的视觉变体(`picture-card` 列表项仍用 `apex-picture-upload`)。 | `"default" \| "elevated"` | 否 | `'default'` |
|
|
80
|
+
| maxCount | 最大上传数量;为 `1` 时始终保留最新文件。<br>`picture-card` 未传时默认使用 `UPLOAD_DEFAULT_MAX_COUNT`(10)。 | `number` | 否 | — |
|
|
81
|
+
| maxSize | 单文件最大体积(字节)。<br>`picture-card` 未传时默认使用 `UPLOAD_DEFAULT_MAX_FILE_SIZE`(20 MB)。 | `number` | 否 | — |
|
|
82
|
+
| method | HTTP 方法 | `string` | 否 | `'post'` |
|
|
83
|
+
| multiple | 是否支持多选文件 | `boolean` | 否 | `false` |
|
|
84
|
+
| name | 上传字段名 | `string` | 否 | `'file'` |
|
|
85
|
+
| openFileDialogOnClick | 点击触发区是否打开文件选择框 | `boolean` | 否 | `true` |
|
|
86
|
+
| showUploadList | 是否展示上传列表;对象形式可配置操作图标 | `boolean \| ShowUploadListConfig` | 否 | `true` |
|
|
87
|
+
| withCredentials | 上传请求是否携带 cookie | `boolean` | 否 | `false` |
|
|
88
|
+
| onChange | 文件状态变化回调 | `(info: UploadChangeParam) => void` | 否 | — |
|
|
89
|
+
| onDrop | 拖入文件时触发(`Upload.Dragger`) | `(event: React.DragEvent<HTMLDivElement>) => void` | 否 | — |
|
|
90
|
+
| onDownload | 点击下载时的回调 | `(file: UploadFile) => void` | 否 | — |
|
|
91
|
+
| onPreview | 点击预览时的回调;返回 `false` 可阻止内置预览层 | `(file: UploadFile) => void \| false` | 否 | — |
|
|
92
|
+
| onRemove | 移除文件前的回调;返回 `false` 或 reject 则不移除 | `(file: UploadFile) => boolean \| void \| Promise<boolean \| void>` | 否 | — |
|
|
93
|
+
| children | 触发区内容(按钮、加号卡片等) | `React.ReactNode` | 否 | — |
|
|
94
|
+
| ref | 根节点 ref | `React.Ref<HTMLDivElement>` | 否 | — |
|
|
95
|
+
|
|
96
|
+
### UploadListType
|
|
97
|
+
|
|
98
|
+
上传列表展示形态
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
type UploadListType = 'text' | 'picture' | 'picture-card'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### UploadVariant
|
|
105
|
+
|
|
106
|
+
Upload trigger / text & picture list item surface variant
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
type UploadVariant = 'default' | 'elevated'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### UploadFileStatus
|
|
113
|
+
|
|
114
|
+
单个文件的上传状态
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
type UploadFileStatus = 'error' | 'done' | 'uploading' | 'removed'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### UploadListIgnore
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
type UploadListIgnore = typeof UPLOAD_LIST_IGNORE
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### UploadFile
|
|
127
|
+
|
|
128
|
+
继承:`File`;本节列出新增或重声明字段。
|
|
129
|
+
|
|
130
|
+
上传文件对象,保持与既有业务兼容:继承浏览器 `File` 并附带列表渲染字段。
|
|
131
|
+
|
|
132
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
133
|
+
| --- | --- | --- | --- | --- |
|
|
134
|
+
| uid | 唯一标识;未设置时由组件生成 | `string` | 是 | — |
|
|
135
|
+
| name | 文件名 | `string` | 是 | — |
|
|
136
|
+
| status | 上传状态 | `"error" \| "done" \| "uploading" \| "removed"` | 否 | — |
|
|
137
|
+
| percent | 上传进度 0–100 | `number` | 否 | — |
|
|
138
|
+
| thumbUrl | 缩略图地址(本地或远程) | `string` | 否 | — |
|
|
139
|
+
| url | 下载/预览地址 | `string` | 否 | — |
|
|
140
|
+
| response | 服务端响应体 | `unknown` | 否 | — |
|
|
141
|
+
| error | 错误对象 | `Error` | 否 | — |
|
|
142
|
+
| originFileObj | 原始 File(便于从 `info.file` 取原文件) | `File` | 否 | — |
|
|
143
|
+
|
|
144
|
+
### UploadProgressEvent
|
|
145
|
+
|
|
146
|
+
上传进度事件(百分比范围 0–100)
|
|
147
|
+
|
|
148
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
149
|
+
| --- | --- | --- | --- | --- |
|
|
150
|
+
| percent | — | `number` | 是 | — |
|
|
151
|
+
|
|
152
|
+
### UploadChangeParam
|
|
153
|
+
|
|
154
|
+
泛型参数:`<T extends UploadFile = UploadFile>`。
|
|
155
|
+
|
|
156
|
+
`onChange` 回调参数
|
|
157
|
+
|
|
158
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
159
|
+
| --- | --- | --- | --- | --- |
|
|
160
|
+
| file | — | `T` | 是 | — |
|
|
161
|
+
| fileList | — | `T[]` | 是 | — |
|
|
162
|
+
| event | — | `ProgressEvent` | 否 | — |
|
|
163
|
+
|
|
164
|
+
### ShowUploadListConfig
|
|
165
|
+
|
|
166
|
+
`showUploadList` 为对象时的配置
|
|
167
|
+
|
|
168
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
169
|
+
| --- | --- | --- | --- | --- |
|
|
170
|
+
| extra | — | `React.ReactNode \| ((file: UploadFile) => React.ReactNode)` | 否 | — |
|
|
171
|
+
| showTrigger | 是否展示上传触发区(按钮 / `picture-card` 的「+」卡片)。<br>设为 `false` 时仅展示已上传列表,适用于只读预览。 | `boolean` | 否 | `true` |
|
|
172
|
+
| showPreviewIcon | — | `boolean \| ((file: UploadFile) => boolean)` | 否 | — |
|
|
173
|
+
| showRemoveIcon | 是否展示删除图标;disabled 时默认隐藏,显式展示时按钮仍禁用 | `boolean \| ((file: UploadFile) => boolean)` | 否 | — |
|
|
174
|
+
| showDownloadIcon | 是否展示下载图标;picture-card 默认 `false`,可显式设为 `true` 开启 | `boolean \| ((file: UploadFile) => boolean)` | 否 | — |
|
|
175
|
+
| previewIcon | — | `React.ReactNode \| ((file: UploadFile) => React.ReactNode)` | 否 | — |
|
|
176
|
+
| removeIcon | — | `React.ReactNode \| ((file: UploadFile) => React.ReactNode)` | 否 | — |
|
|
177
|
+
| downloadIcon | — | `React.ReactNode \| ((file: UploadFile) => React.ReactNode)` | 否 | — |
|
|
178
|
+
|
|
179
|
+
### UploadAcceptObject
|
|
180
|
+
|
|
181
|
+
`accept` 对象形式
|
|
182
|
+
|
|
183
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
184
|
+
| --- | --- | --- | --- | --- |
|
|
185
|
+
| format | 与原生 input `accept` 相同 | `string` | 是 | — |
|
|
186
|
+
| filter | `native` 使用浏览器过滤;函数返回 `true` 表示接受 | `'native' \| ((file: File) => boolean)` | 否 | — |
|
|
187
|
+
|
|
188
|
+
### UploadRequestOptions
|
|
189
|
+
|
|
190
|
+
`customRequest` 请求参数
|
|
191
|
+
|
|
192
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 |
|
|
193
|
+
| --- | --- | --- | --- | --- |
|
|
194
|
+
| action | — | `string` | 是 | — |
|
|
195
|
+
| file | — | `File \| Blob` | 是 | — |
|
|
196
|
+
| fileName | 上传文件名;当 `file` 是普通 Blob 时用于保留原文件名 | `string` | 否 | — |
|
|
197
|
+
| filename | multipart/form-data 字段名 | `string` | 否 | — |
|
|
198
|
+
| data | — | `Record<string, unknown>` | 否 | — |
|
|
199
|
+
| headers | — | `Record<string, string>` | 否 | — |
|
|
200
|
+
| method | — | `string` | 否 | — |
|
|
201
|
+
| withCredentials | — | `boolean` | 否 | — |
|
|
202
|
+
| onProgress | — | `(event: UploadProgressEvent) => void` | 否 | — |
|
|
203
|
+
| onError | — | `(error: Error, body?: unknown) => void` | 否 | — |
|
|
204
|
+
| onSuccess | — | `(body: unknown) => void` | 否 | — |
|
|
205
|
+
|
|
206
|
+
### UploadDraggerProps
|
|
207
|
+
|
|
208
|
+
`Upload.Dragger` 与 `Upload` 共用同一套 Props
|
|
209
|
+
|
|
210
|
+
**类型别名**:`UploadDraggerProps` 即 `UploadProps`,字段见上文 `### Upload`。
|
|
211
|
+
|
|
212
|
+
等价写法:`UploadDraggerProps` ≡ `UploadProps`
|
|
213
|
+
|
|
214
|
+
### 导出类型
|
|
215
|
+
|
|
216
|
+
类型从本组件目录导入:`FileKind`、`FilePreviewKind`、`ShowUploadListConfig`、`UploadAcceptObject`、`UploadChangeParam`、`UploadDraggerProps`、`UploadFile`、`UploadFileStatus`、`UploadLimitsConfig`、`UploadListIgnore`、`UploadListType`、`UploadProgressEvent`、`UploadProps`、`UploadRequestOptions`(与上文子类型配合使用)。
|
|
217
|
+
|
|
218
|
+
## 代码演示
|
|
219
|
+
|
|
220
|
+
### 多文件上传
|
|
221
|
+
|
|
222
|
+
设置 `multiple` 允许一次选择多个文件。
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
import { Upload } from '@/components/apex/upload'
|
|
226
|
+
|
|
227
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
228
|
+
|
|
229
|
+
function uploadDemoImageDataUrl(
|
|
230
|
+
fill: string,
|
|
231
|
+
label: string,
|
|
232
|
+
width = 200,
|
|
233
|
+
height = 200,
|
|
234
|
+
): string {
|
|
235
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
236
|
+
return (
|
|
237
|
+
'data:image/svg+xml;utf8,' +
|
|
238
|
+
encodeURIComponent(
|
|
239
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
245
|
+
|
|
246
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
247
|
+
|
|
248
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
249
|
+
|
|
250
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
251
|
+
|
|
252
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
253
|
+
onSuccess,
|
|
254
|
+
}) => {
|
|
255
|
+
window.setTimeout(() => {
|
|
256
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
257
|
+
}, 300)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export default () => <Upload customRequest={uploadDemoCustomRequest} listType="text" multiple />
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 已上传文件列表
|
|
264
|
+
|
|
265
|
+
通过 `defaultFileList` 展示不同状态的文件。文本列表显示文件类型图标,附件行提供默认、悬停、按下、禁用、上传中和错误样式。
|
|
266
|
+
|
|
267
|
+
内置 DOC、DOCX、GIF、JPEG、JPG、OFD、PDF、PNG、TXT、XLSX 十种 Figma 格式图标,按文件扩展名优先、MIME 类型其次识别(扩展名不区分大小写),未知格式回退通用文件图标。文件名前的图标固定为 20px;可通过 `Icon` 的 `docx-format`、`ofd-format`、`txt-format` 等名称独立使用。
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import type { UploadFile } from '@/components/apex/upload'
|
|
271
|
+
|
|
272
|
+
import { Upload } from '@/components/apex/upload'
|
|
273
|
+
|
|
274
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
275
|
+
|
|
276
|
+
function uploadDemoImageDataUrl(
|
|
277
|
+
fill: string,
|
|
278
|
+
label: string,
|
|
279
|
+
width = 200,
|
|
280
|
+
height = 200,
|
|
281
|
+
): string {
|
|
282
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
283
|
+
return (
|
|
284
|
+
'data:image/svg+xml;utf8,' +
|
|
285
|
+
encodeURIComponent(
|
|
286
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
287
|
+
)
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
292
|
+
|
|
293
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
294
|
+
|
|
295
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
296
|
+
|
|
297
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
298
|
+
|
|
299
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
300
|
+
onSuccess,
|
|
301
|
+
}) => {
|
|
302
|
+
window.setTimeout(() => {
|
|
303
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
304
|
+
}, 300)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const defaultFileList = [
|
|
308
|
+
{
|
|
309
|
+
uid: '1',
|
|
310
|
+
name: 'example.png',
|
|
311
|
+
status: 'done',
|
|
312
|
+
url: 'https://example.com/1.png',
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
uid: '2',
|
|
316
|
+
name: 'uploading.png',
|
|
317
|
+
status: 'uploading',
|
|
318
|
+
percent: 50,
|
|
319
|
+
},
|
|
320
|
+
{ uid: '3', name: 'error.png', status: 'error' },
|
|
321
|
+
] as unknown as UploadFile[]
|
|
322
|
+
|
|
323
|
+
export default () => (
|
|
324
|
+
<Upload
|
|
325
|
+
customRequest={uploadDemoCustomRequest}
|
|
326
|
+
listType="text"
|
|
327
|
+
defaultFileList={defaultFileList}
|
|
328
|
+
/>
|
|
329
|
+
)
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### 自定义前置图标
|
|
333
|
+
|
|
334
|
+
`prefixIcon` 仅替换 text 列表文件名前的图标,不影响右侧操作图标或图片缩略图。不传或回调返回 `undefined` 时保留默认文件格式图标;传入或返回 `null`/`false` 时隐藏。
|
|
335
|
+
|
|
336
|
+
```tsx
|
|
337
|
+
import { Upload, type UploadFile, type UploadProps } from '@/components/apex/upload'
|
|
338
|
+
|
|
339
|
+
const files: UploadFile[] = [
|
|
340
|
+
Object.assign(new File(['notes'], 'notes.txt', { type: 'text/plain' }), {
|
|
341
|
+
uid: 'notes',
|
|
342
|
+
status: 'done' as const,
|
|
343
|
+
}),
|
|
344
|
+
Object.assign(new File(['report'], 'report.pdf', { type: 'application/pdf' }), {
|
|
345
|
+
uid: 'report',
|
|
346
|
+
status: 'done' as const,
|
|
347
|
+
}),
|
|
348
|
+
]
|
|
349
|
+
|
|
350
|
+
const prefixIcon: UploadProps['prefixIcon'] = (file) =>
|
|
351
|
+
file.name.endsWith('.txt') ? (
|
|
352
|
+
<svg viewBox="0 0 20 20" fill="none" stroke="currentColor">
|
|
353
|
+
<path d="M4 2h8l4 4v12H4zM12 2v4h4M7 10h6M7 14h6" />
|
|
354
|
+
</svg>
|
|
355
|
+
) : undefined
|
|
356
|
+
|
|
357
|
+
export default () => (
|
|
358
|
+
<Upload defaultFileList={files} prefixIcon={prefixIcon} showUploadList={{ showTrigger: false }} />
|
|
359
|
+
)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### 图片列表
|
|
363
|
+
|
|
364
|
+
`listType="picture"` 以缩略图形式展示文件。
|
|
365
|
+
|
|
366
|
+
```tsx
|
|
367
|
+
import type { UploadFile } from '@/components/apex/upload'
|
|
368
|
+
|
|
369
|
+
import { Upload } from '@/components/apex/upload'
|
|
370
|
+
|
|
371
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
372
|
+
|
|
373
|
+
function uploadDemoImageDataUrl(
|
|
374
|
+
fill: string,
|
|
375
|
+
label: string,
|
|
376
|
+
width = 200,
|
|
377
|
+
height = 200,
|
|
378
|
+
): string {
|
|
379
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
380
|
+
return (
|
|
381
|
+
'data:image/svg+xml;utf8,' +
|
|
382
|
+
encodeURIComponent(
|
|
383
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
389
|
+
|
|
390
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
391
|
+
|
|
392
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
393
|
+
|
|
394
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
395
|
+
|
|
396
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
397
|
+
onSuccess,
|
|
398
|
+
}) => {
|
|
399
|
+
window.setTimeout(() => {
|
|
400
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
401
|
+
}, 300)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const defaultFileList = [
|
|
405
|
+
{
|
|
406
|
+
uid: '1',
|
|
407
|
+
name: 'example.png',
|
|
408
|
+
status: 'done',
|
|
409
|
+
thumbUrl: UPLOAD_DEMO_IMAGE,
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
uid: '2',
|
|
413
|
+
name: 'uploading.png',
|
|
414
|
+
status: 'uploading',
|
|
415
|
+
percent: 50,
|
|
416
|
+
thumbUrl: UPLOAD_DEMO_IMAGE_BLUR,
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
uid: '3',
|
|
420
|
+
name: 'error.png',
|
|
421
|
+
status: 'error',
|
|
422
|
+
thumbUrl: UPLOAD_DEMO_IMAGE_GRAY,
|
|
423
|
+
},
|
|
424
|
+
] as unknown as UploadFile[]
|
|
425
|
+
|
|
426
|
+
export default () => (
|
|
427
|
+
<Upload
|
|
428
|
+
customRequest={uploadDemoCustomRequest}
|
|
429
|
+
listType="picture"
|
|
430
|
+
defaultFileList={defaultFileList}
|
|
431
|
+
/>
|
|
432
|
+
)
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### 表面变体
|
|
436
|
+
|
|
437
|
+
`variant` 控制触发区和 text/picture 列表项的表面:`default`(默认)或 `elevated`。`picture-card` 列表项保持卡片样式。
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
import type { UploadFile } from '@/components/apex/upload'
|
|
441
|
+
|
|
442
|
+
import { Typography } from '@/components/apex/typography'
|
|
443
|
+
import { Upload } from '@/components/apex/upload'
|
|
444
|
+
|
|
445
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
446
|
+
|
|
447
|
+
function uploadDemoImageDataUrl(
|
|
448
|
+
fill: string,
|
|
449
|
+
label: string,
|
|
450
|
+
width = 200,
|
|
451
|
+
height = 200,
|
|
452
|
+
): string {
|
|
453
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
454
|
+
return (
|
|
455
|
+
'data:image/svg+xml;utf8,' +
|
|
456
|
+
encodeURIComponent(
|
|
457
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
458
|
+
)
|
|
459
|
+
)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
463
|
+
|
|
464
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
465
|
+
|
|
466
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
467
|
+
|
|
468
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
469
|
+
|
|
470
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
471
|
+
onSuccess,
|
|
472
|
+
}) => {
|
|
473
|
+
window.setTimeout(() => {
|
|
474
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
475
|
+
}, 300)
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const defaultFileList: UploadFile[] = [
|
|
479
|
+
Object.assign(new File(['项目需求说明'], '需求说明.txt', { type: 'text/plain' }), {
|
|
480
|
+
uid: 'requirements',
|
|
481
|
+
status: 'done' as const,
|
|
482
|
+
url: `data:text/plain;charset=utf-8,${encodeURIComponent('项目需求说明')}`,
|
|
483
|
+
}),
|
|
484
|
+
Object.assign(
|
|
485
|
+
new File(['文件名,状态\n需求说明.txt,已上传'], '上传清单.csv', { type: 'text/csv' }),
|
|
486
|
+
{
|
|
487
|
+
uid: 'upload-list',
|
|
488
|
+
status: 'done' as const,
|
|
489
|
+
url: `data:text/csv;charset=utf-8,${encodeURIComponent('文件名,状态\n需求说明.txt,已上传')}`,
|
|
490
|
+
},
|
|
491
|
+
),
|
|
492
|
+
]
|
|
493
|
+
|
|
494
|
+
export default () => (
|
|
495
|
+
<>
|
|
496
|
+
<Typography.Title level={4}>默认表面</Typography.Title>
|
|
497
|
+
<Upload
|
|
498
|
+
variant="default"
|
|
499
|
+
defaultFileList={defaultFileList}
|
|
500
|
+
customRequest={uploadDemoCustomRequest}
|
|
501
|
+
/>
|
|
502
|
+
<Typography.Title level={4}>Elevated 表面</Typography.Title>
|
|
503
|
+
<Upload
|
|
504
|
+
variant="elevated"
|
|
505
|
+
defaultFileList={defaultFileList}
|
|
506
|
+
customRequest={uploadDemoCustomRequest}
|
|
507
|
+
/>
|
|
508
|
+
</>
|
|
509
|
+
)
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### 照片墙
|
|
513
|
+
|
|
514
|
+
`listType="picture-card"` 以卡片栅格展示,适合图片上传场景。
|
|
515
|
+
|
|
516
|
+
```tsx
|
|
517
|
+
import type { UploadFile } from '@/components/apex/upload'
|
|
518
|
+
|
|
519
|
+
import { Upload } from '@/components/apex/upload'
|
|
520
|
+
|
|
521
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
522
|
+
|
|
523
|
+
function uploadDemoImageDataUrl(
|
|
524
|
+
fill: string,
|
|
525
|
+
label: string,
|
|
526
|
+
width = 200,
|
|
527
|
+
height = 200,
|
|
528
|
+
): string {
|
|
529
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
530
|
+
return (
|
|
531
|
+
'data:image/svg+xml;utf8,' +
|
|
532
|
+
encodeURIComponent(
|
|
533
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
534
|
+
)
|
|
535
|
+
)
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
539
|
+
|
|
540
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
541
|
+
|
|
542
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
543
|
+
|
|
544
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
545
|
+
|
|
546
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
547
|
+
onSuccess,
|
|
548
|
+
}) => {
|
|
549
|
+
window.setTimeout(() => {
|
|
550
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
551
|
+
}, 300)
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const defaultFileList = [
|
|
555
|
+
{
|
|
556
|
+
uid: '1',
|
|
557
|
+
name: 'example.png',
|
|
558
|
+
status: 'done',
|
|
559
|
+
thumbUrl: UPLOAD_DEMO_IMAGE,
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
uid: '2',
|
|
563
|
+
name: 'uploading.png',
|
|
564
|
+
status: 'uploading',
|
|
565
|
+
thumbUrl: UPLOAD_DEMO_IMAGE_BLUR,
|
|
566
|
+
},
|
|
567
|
+
{ uid: '3', name: 'error.png', status: 'error' },
|
|
568
|
+
] as unknown as UploadFile[]
|
|
569
|
+
|
|
570
|
+
export default () => (
|
|
571
|
+
<Upload
|
|
572
|
+
customRequest={uploadDemoCustomRequest}
|
|
573
|
+
listType="picture-card"
|
|
574
|
+
defaultFileList={defaultFileList}
|
|
575
|
+
/>
|
|
576
|
+
)
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### 拖拽上传
|
|
580
|
+
|
|
581
|
+
使用 `Upload.Dragger` 提供拖拽区域,拖入文件即可上传。
|
|
582
|
+
|
|
583
|
+
```tsx
|
|
584
|
+
import { Typography } from '@/components/apex/typography'
|
|
585
|
+
import { Upload } from '@/components/apex/upload'
|
|
586
|
+
|
|
587
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
588
|
+
|
|
589
|
+
function uploadDemoImageDataUrl(
|
|
590
|
+
fill: string,
|
|
591
|
+
label: string,
|
|
592
|
+
width = 200,
|
|
593
|
+
height = 200,
|
|
594
|
+
): string {
|
|
595
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
596
|
+
return (
|
|
597
|
+
'data:image/svg+xml;utf8,' +
|
|
598
|
+
encodeURIComponent(
|
|
599
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
600
|
+
)
|
|
601
|
+
)
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
605
|
+
|
|
606
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
607
|
+
|
|
608
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
609
|
+
|
|
610
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
611
|
+
|
|
612
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
613
|
+
onSuccess,
|
|
614
|
+
}) => {
|
|
615
|
+
window.setTimeout(() => {
|
|
616
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
617
|
+
}, 300)
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
export default () => (
|
|
621
|
+
<Upload.Dragger
|
|
622
|
+
accept=".jpg,.jpeg,.png,.gif,.pdf,.docx,.xlsx,.ofd"
|
|
623
|
+
multiple
|
|
624
|
+
maxCount={10}
|
|
625
|
+
maxSize={20 * 1024 * 1024}
|
|
626
|
+
customRequest={uploadDemoCustomRequest}
|
|
627
|
+
>
|
|
628
|
+
<Typography.Text>点击或拖拽文件到此处上传</Typography.Text>
|
|
629
|
+
<Typography.Text variant="caption">
|
|
630
|
+
支持jpg、jpeg、png、gif、pdf、docx、xlsx、ofd,最多10个,单文件不超过20MB
|
|
631
|
+
</Typography.Text>
|
|
632
|
+
</Upload.Dragger>
|
|
633
|
+
)
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
### 禁用状态
|
|
637
|
+
|
|
638
|
+
`disabled` 时禁止选择文件、拖拽、删除与重试;已有文件仍可预览、下载。text/picture 的正常和手动文件行使用禁用样式,上传中与错误文件保留状态色。删除按钮默认隐藏,显式设置 `showUploadList.showRemoveIcon` 时按配置展示,但仍不可点击。
|
|
639
|
+
|
|
640
|
+
```tsx
|
|
641
|
+
import { Upload } from '@/components/apex/upload'
|
|
642
|
+
|
|
643
|
+
import type { UploadProps } from '@/components/apex/upload'
|
|
644
|
+
|
|
645
|
+
function uploadDemoImageDataUrl(
|
|
646
|
+
fill: string,
|
|
647
|
+
label: string,
|
|
648
|
+
width = 200,
|
|
649
|
+
height = 200,
|
|
650
|
+
): string {
|
|
651
|
+
const fontSize = Math.round(Math.min(width, height) * 0.2)
|
|
652
|
+
return (
|
|
653
|
+
'data:image/svg+xml;utf8,' +
|
|
654
|
+
encodeURIComponent(
|
|
655
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${fill}"/><text x="50%" y="55%" dominant-baseline="middle" fill="white" font-family="Arial,sans-serif" font-size="${fontSize}" text-anchor="middle">${label}</text></svg>`,
|
|
656
|
+
)
|
|
657
|
+
)
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
const UPLOAD_DEMO_IMAGE = uploadDemoImageDataUrl('#7B61FF', 'IMG')
|
|
661
|
+
|
|
662
|
+
const UPLOAD_DEMO_IMAGE_BLUR = uploadDemoImageDataUrl('#5B8DEF', 'BLUR')
|
|
663
|
+
|
|
664
|
+
const UPLOAD_DEMO_IMAGE_GRAY = uploadDemoImageDataUrl('#888888', 'ERR')
|
|
665
|
+
|
|
666
|
+
const UPLOAD_DEMO_IMAGE_LARGE = uploadDemoImageDataUrl('#7B61FF', 'UP', 400, 400)
|
|
667
|
+
|
|
668
|
+
const uploadDemoCustomRequest: NonNullable<UploadProps['customRequest']> = ({
|
|
669
|
+
onSuccess,
|
|
670
|
+
}) => {
|
|
671
|
+
window.setTimeout(() => {
|
|
672
|
+
onSuccess?.({ url: UPLOAD_DEMO_IMAGE_LARGE })
|
|
673
|
+
}, 300)
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export default () => <Upload customRequest={uploadDemoCustomRequest} disabled />
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
## DOM 结构
|
|
680
|
+
|
|
681
|
+
源码声明的静态 `data-slot`:`upload-list-trigger`、`upload-list-item-thumb`、`upload-list-item-progress`、`upload-picture-card-mask`、`upload-actions`、`upload-list-item-retry`、`upload-list-item-icon`、`upload-list-item-name`、`upload-list-item-size`、`upload-list`、`upload`、`upload-input`、`upload-action-icon`。具体节点随模式和状态出现,不表示固定嵌套顺序。
|
|
682
|
+
|
|
683
|
+
## 样式定制
|
|
684
|
+
|
|
685
|
+
优先使用本组件公开的尺寸、类型和状态属性。换肤与变量覆盖方式见 [主题指南](../llms-theme.txt)。
|
|
686
|
+
|
|
687
|
+
需要定制具体样式时再读取 [Token 明细](./tokens.txt),其中包含用途、定义值及适用作用域。常规组件使用无需加载该文件。
|
|
688
|
+
|
|
689
|
+
## FAQ
|
|
690
|
+
|
|
691
|
+
### 上传失败后如何重试?
|
|
692
|
+
|
|
693
|
+
列表项 `status="error"` 且存在 `originFileObj` 时会展示「点击重试」,点击后使用同一原始文件和 `uid` 重新发起上传。远程列表文件没有本地二进制数据时不会展示重试,避免把空文件上传到服务器。text/picture 附件行使用错误底色、描边与文字色,文本列表的文件类型图标同步使用错误色;重试使用链接样式。picture-card 保持缩略图与原有卡片底色,不增加独立 error 图标。
|
|
694
|
+
|
|
695
|
+
### 为什么没有 antd 的线型进度条?
|
|
696
|
+
|
|
697
|
+
v1 列表 uploading 态使用圆形 Spin 指示进度,不提供 antd 线型 `progress` 配置。需要线型进度请通过 `itemRender` 或 `customRequest` 自行扩展。
|
|
698
|
+
|
|
699
|
+
### `beforeUpload` 返回 `'LIST_IGNORE'` 是什么效果?
|
|
700
|
+
|
|
701
|
+
文件不会出现在上传列表中,也不会触发上传。可返回字符串 `'LIST_IGNORE'`,或从包中导入常量 `UPLOAD_LIST_IGNORE`(值同为 `'LIST_IGNORE'`)。
|
|
702
|
+
|
|
703
|
+
### Upload 能预览 PDF 或 Office 文件吗?
|
|
704
|
+
|
|
705
|
+
不能。默认预览仅对图片生效(通过 `Image.PreviewGroup`)。非图片文件需使用 `onPreview` 回调自行实现,例如在新窗口打开文件 URL 或调用第三方文档预览服务。
|