wn-native-ui 0.0.0-stage → 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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +128 -3
- package/lib/module/components/Avatar/Avatar.js +131 -0
- package/lib/module/components/Avatar/index.js +3 -0
- package/lib/module/components/Avatar/styles.js +49 -0
- package/lib/module/components/BottomActionBar/BottomActionBar.js +43 -0
- package/lib/module/components/BottomActionBar/index.js +3 -0
- package/lib/module/components/BottomActionBar/styles.js +22 -0
- package/lib/module/components/BottomSheet/BottomSheet.js +103 -0
- package/lib/module/components/BottomSheet/index.js +3 -0
- package/lib/module/components/BottomSheet/styles.js +84 -0
- package/lib/module/components/Button/Button.js +38 -0
- package/lib/module/components/Button/index.js +3 -0
- package/lib/module/components/Button/styles.js +50 -0
- package/lib/module/components/Checkbox/Checkbox.js +131 -0
- package/lib/module/components/Checkbox/index.js +3 -0
- package/lib/module/components/Checkbox/styles.js +64 -0
- package/lib/module/components/DatePicker/DatePicker.js +521 -0
- package/lib/module/components/DatePicker/index.js +3 -0
- package/lib/module/components/DatePicker/model.js +255 -0
- package/lib/module/components/DatePicker/styles.js +273 -0
- package/lib/module/components/Dialog/Dialog.js +146 -0
- package/lib/module/components/Dialog/index.js +3 -0
- package/lib/module/components/Dialog/styles.js +112 -0
- package/lib/module/components/EmptyState/EmptyState.js +56 -0
- package/lib/module/components/EmptyState/index.js +3 -0
- package/lib/module/components/EmptyState/styles.js +84 -0
- package/lib/module/components/Field/Field.js +54 -0
- package/lib/module/components/Field/FieldContext.js +7 -0
- package/lib/module/components/Field/index.js +3 -0
- package/lib/module/components/Field/styles.js +56 -0
- package/lib/module/components/FilterChips/FilterChips.js +74 -0
- package/lib/module/components/FilterChips/index.js +3 -0
- package/lib/module/components/FilterChips/styles.js +72 -0
- package/lib/module/components/Form/Form.js +53 -0
- package/lib/module/components/Form/FormItem.js +128 -0
- package/lib/module/components/Form/context.js +4 -0
- package/lib/module/components/Form/index.js +10 -0
- package/lib/module/components/Form/model.js +327 -0
- package/lib/module/components/Form/styles.js +10 -0
- package/lib/module/components/ImagePreview/ImagePreview.js +189 -0
- package/lib/module/components/ImagePreview/index.js +3 -0
- package/lib/module/components/ImagePreview/styles.js +87 -0
- package/lib/module/components/InlineFeedback/InlineFeedback.js +78 -0
- package/lib/module/components/InlineFeedback/index.js +3 -0
- package/lib/module/components/InlineFeedback/styles.js +148 -0
- package/lib/module/components/Input/Input.js +50 -0
- package/lib/module/components/Input/index.js +3 -0
- package/lib/module/components/Input/styles.js +41 -0
- package/lib/module/components/ListSkeleton/ListSkeleton.js +50 -0
- package/lib/module/components/ListSkeleton/index.js +3 -0
- package/lib/module/components/ListSkeleton/styles.js +30 -0
- package/lib/module/components/NavigationBar/NavigationBar.js +170 -0
- package/lib/module/components/NavigationBar/index.js +3 -0
- package/lib/module/components/NavigationBar/styles.js +98 -0
- package/lib/module/components/Picker/Picker.js +156 -0
- package/lib/module/components/Picker/index.js +3 -0
- package/lib/module/components/Picker/styles.js +96 -0
- package/lib/module/components/Radio/Radio.js +114 -0
- package/lib/module/components/Radio/index.js +3 -0
- package/lib/module/components/Radio/styles.js +70 -0
- package/lib/module/components/SearchInput/SearchInput.js +102 -0
- package/lib/module/components/SearchInput/index.js +3 -0
- package/lib/module/components/SearchInput/styles.js +106 -0
- package/lib/module/components/SideDrawer/SideDrawer.js +161 -0
- package/lib/module/components/SideDrawer/index.js +3 -0
- package/lib/module/components/SideDrawer/styles.js +89 -0
- package/lib/module/components/Skeleton/Skeleton.js +66 -0
- package/lib/module/components/Skeleton/index.js +3 -0
- package/lib/module/components/Skeleton/styles.js +18 -0
- package/lib/module/components/Switch/Switch.js +61 -0
- package/lib/module/components/Switch/index.js +3 -0
- package/lib/module/components/Switch/styles.js +33 -0
- package/lib/module/components/TabBar/TabBar.js +68 -0
- package/lib/module/components/TabBar/index.js +3 -0
- package/lib/module/components/TabBar/styles.js +84 -0
- package/lib/module/components/Tabs/Tabs.js +65 -0
- package/lib/module/components/Tabs/index.js +3 -0
- package/lib/module/components/Tabs/styles.js +99 -0
- package/lib/module/components/Tag/Tag.js +171 -0
- package/lib/module/components/Tag/index.js +3 -0
- package/lib/module/components/Tag/styles.js +163 -0
- package/lib/module/components/TextArea/TextArea.js +74 -0
- package/lib/module/components/TextArea/index.js +3 -0
- package/lib/module/components/TextArea/styles.js +45 -0
- package/lib/module/components/TimePicker/TimePicker.js +262 -0
- package/lib/module/components/TimePicker/index.js +3 -0
- package/lib/module/components/TimePicker/model.js +63 -0
- package/lib/module/components/TimePicker/styles.js +143 -0
- package/lib/module/components/Timeline/Timeline.js +154 -0
- package/lib/module/components/Timeline/index.js +3 -0
- package/lib/module/components/Timeline/model.js +36 -0
- package/lib/module/components/Timeline/styles.js +115 -0
- package/lib/module/components/Toast/Toast.js +249 -0
- package/lib/module/components/Toast/index.js +3 -0
- package/lib/module/components/Toast/styles.js +61 -0
- package/lib/module/components/Upload/Upload.js +762 -0
- package/lib/module/components/Upload/index.js +3 -0
- package/lib/module/components/Upload/model.js +3 -0
- package/lib/module/components/Upload/picker.js +97 -0
- package/lib/module/components/Upload/styles.js +358 -0
- package/lib/module/components/index.js +32 -0
- package/lib/module/index.js +4 -0
- package/lib/module/package.json +1 -0
- package/lib/module/ui/tokens.js +174 -0
- package/lib/typescript/components/Avatar/Avatar.d.ts +20 -0
- package/lib/typescript/components/Avatar/Avatar.d.ts.map +1 -0
- package/lib/typescript/components/Avatar/index.d.ts +3 -0
- package/lib/typescript/components/Avatar/index.d.ts.map +1 -0
- package/lib/typescript/components/Avatar/styles.d.ts +46 -0
- package/lib/typescript/components/Avatar/styles.d.ts.map +1 -0
- package/lib/typescript/components/BottomActionBar/BottomActionBar.d.ts +17 -0
- package/lib/typescript/components/BottomActionBar/BottomActionBar.d.ts.map +1 -0
- package/lib/typescript/components/BottomActionBar/index.d.ts +3 -0
- package/lib/typescript/components/BottomActionBar/index.d.ts.map +1 -0
- package/lib/typescript/components/BottomActionBar/styles.d.ts +19 -0
- package/lib/typescript/components/BottomActionBar/styles.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet/BottomSheet.d.ts +19 -0
- package/lib/typescript/components/BottomSheet/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet/index.d.ts +3 -0
- package/lib/typescript/components/BottomSheet/index.d.ts.map +1 -0
- package/lib/typescript/components/BottomSheet/styles.d.ts +86 -0
- package/lib/typescript/components/BottomSheet/styles.d.ts.map +1 -0
- package/lib/typescript/components/Button/Button.d.ts +12 -0
- package/lib/typescript/components/Button/Button.d.ts.map +1 -0
- package/lib/typescript/components/Button/index.d.ts +3 -0
- package/lib/typescript/components/Button/index.d.ts.map +1 -0
- package/lib/typescript/components/Button/styles.d.ts +48 -0
- package/lib/typescript/components/Button/styles.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/Checkbox.d.ts +39 -0
- package/lib/typescript/components/Checkbox/Checkbox.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/index.d.ts +3 -0
- package/lib/typescript/components/Checkbox/index.d.ts.map +1 -0
- package/lib/typescript/components/Checkbox/styles.d.ts +65 -0
- package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -0
- package/lib/typescript/components/DatePicker/DatePicker.d.ts +40 -0
- package/lib/typescript/components/DatePicker/DatePicker.d.ts.map +1 -0
- package/lib/typescript/components/DatePicker/index.d.ts +4 -0
- package/lib/typescript/components/DatePicker/index.d.ts.map +1 -0
- package/lib/typescript/components/DatePicker/model.d.ts +49 -0
- package/lib/typescript/components/DatePicker/model.d.ts.map +1 -0
- package/lib/typescript/components/DatePicker/styles.d.ts +287 -0
- package/lib/typescript/components/DatePicker/styles.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/Dialog.d.ts +35 -0
- package/lib/typescript/components/Dialog/Dialog.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/index.d.ts +3 -0
- package/lib/typescript/components/Dialog/index.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/styles.d.ts +114 -0
- package/lib/typescript/components/Dialog/styles.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState/EmptyState.d.ts +13 -0
- package/lib/typescript/components/EmptyState/EmptyState.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState/index.d.ts +3 -0
- package/lib/typescript/components/EmptyState/index.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState/styles.d.ts +86 -0
- package/lib/typescript/components/EmptyState/styles.d.ts.map +1 -0
- package/lib/typescript/components/Field/Field.d.ts +14 -0
- package/lib/typescript/components/Field/Field.d.ts.map +1 -0
- package/lib/typescript/components/Field/FieldContext.d.ts +8 -0
- package/lib/typescript/components/Field/FieldContext.d.ts.map +1 -0
- package/lib/typescript/components/Field/index.d.ts +3 -0
- package/lib/typescript/components/Field/index.d.ts.map +1 -0
- package/lib/typescript/components/Field/styles.d.ts +58 -0
- package/lib/typescript/components/Field/styles.d.ts.map +1 -0
- package/lib/typescript/components/FilterChips/FilterChips.d.ts +23 -0
- package/lib/typescript/components/FilterChips/FilterChips.d.ts.map +1 -0
- package/lib/typescript/components/FilterChips/index.d.ts +3 -0
- package/lib/typescript/components/FilterChips/index.d.ts.map +1 -0
- package/lib/typescript/components/FilterChips/styles.d.ts +75 -0
- package/lib/typescript/components/FilterChips/styles.d.ts.map +1 -0
- package/lib/typescript/components/Form/Form.d.ts +17 -0
- package/lib/typescript/components/Form/Form.d.ts.map +1 -0
- package/lib/typescript/components/Form/FormItem.d.ts +29 -0
- package/lib/typescript/components/Form/FormItem.d.ts.map +1 -0
- package/lib/typescript/components/Form/context.d.ts +8 -0
- package/lib/typescript/components/Form/context.d.ts.map +1 -0
- package/lib/typescript/components/Form/index.d.ts +12 -0
- package/lib/typescript/components/Form/index.d.ts.map +1 -0
- package/lib/typescript/components/Form/model.d.ts +82 -0
- package/lib/typescript/components/Form/model.d.ts.map +1 -0
- package/lib/typescript/components/Form/styles.d.ts +7 -0
- package/lib/typescript/components/Form/styles.d.ts.map +1 -0
- package/lib/typescript/components/ImagePreview/ImagePreview.d.ts +17 -0
- package/lib/typescript/components/ImagePreview/ImagePreview.d.ts.map +1 -0
- package/lib/typescript/components/ImagePreview/index.d.ts +3 -0
- package/lib/typescript/components/ImagePreview/index.d.ts.map +1 -0
- package/lib/typescript/components/ImagePreview/styles.d.ts +87 -0
- package/lib/typescript/components/ImagePreview/styles.d.ts.map +1 -0
- package/lib/typescript/components/InlineFeedback/InlineFeedback.d.ts +13 -0
- package/lib/typescript/components/InlineFeedback/InlineFeedback.d.ts.map +1 -0
- package/lib/typescript/components/InlineFeedback/index.d.ts +3 -0
- package/lib/typescript/components/InlineFeedback/index.d.ts.map +1 -0
- package/lib/typescript/components/InlineFeedback/styles.d.ts +151 -0
- package/lib/typescript/components/InlineFeedback/styles.d.ts.map +1 -0
- package/lib/typescript/components/Input/Input.d.ts +14 -0
- package/lib/typescript/components/Input/Input.d.ts.map +1 -0
- package/lib/typescript/components/Input/index.d.ts +3 -0
- package/lib/typescript/components/Input/index.d.ts.map +1 -0
- package/lib/typescript/components/Input/styles.d.ts +40 -0
- package/lib/typescript/components/Input/styles.d.ts.map +1 -0
- package/lib/typescript/components/ListSkeleton/ListSkeleton.d.ts +10 -0
- package/lib/typescript/components/ListSkeleton/ListSkeleton.d.ts.map +1 -0
- package/lib/typescript/components/ListSkeleton/index.d.ts +3 -0
- package/lib/typescript/components/ListSkeleton/index.d.ts.map +1 -0
- package/lib/typescript/components/ListSkeleton/styles.d.ts +27 -0
- package/lib/typescript/components/ListSkeleton/styles.d.ts.map +1 -0
- package/lib/typescript/components/NavigationBar/NavigationBar.d.ts +34 -0
- package/lib/typescript/components/NavigationBar/NavigationBar.d.ts.map +1 -0
- package/lib/typescript/components/NavigationBar/index.d.ts +3 -0
- package/lib/typescript/components/NavigationBar/index.d.ts.map +1 -0
- package/lib/typescript/components/NavigationBar/styles.d.ts +97 -0
- package/lib/typescript/components/NavigationBar/styles.d.ts.map +1 -0
- package/lib/typescript/components/Picker/Picker.d.ts +32 -0
- package/lib/typescript/components/Picker/Picker.d.ts.map +1 -0
- package/lib/typescript/components/Picker/index.d.ts +3 -0
- package/lib/typescript/components/Picker/index.d.ts.map +1 -0
- package/lib/typescript/components/Picker/styles.d.ts +99 -0
- package/lib/typescript/components/Picker/styles.d.ts.map +1 -0
- package/lib/typescript/components/Radio/Radio.d.ts +38 -0
- package/lib/typescript/components/Radio/Radio.d.ts.map +1 -0
- package/lib/typescript/components/Radio/index.d.ts +3 -0
- package/lib/typescript/components/Radio/index.d.ts.map +1 -0
- package/lib/typescript/components/Radio/styles.d.ts +71 -0
- package/lib/typescript/components/Radio/styles.d.ts.map +1 -0
- package/lib/typescript/components/SearchInput/SearchInput.d.ts +20 -0
- package/lib/typescript/components/SearchInput/SearchInput.d.ts.map +1 -0
- package/lib/typescript/components/SearchInput/index.d.ts +3 -0
- package/lib/typescript/components/SearchInput/index.d.ts.map +1 -0
- package/lib/typescript/components/SearchInput/styles.d.ts +105 -0
- package/lib/typescript/components/SearchInput/styles.d.ts.map +1 -0
- package/lib/typescript/components/SideDrawer/SideDrawer.d.ts +19 -0
- package/lib/typescript/components/SideDrawer/SideDrawer.d.ts.map +1 -0
- package/lib/typescript/components/SideDrawer/index.d.ts +3 -0
- package/lib/typescript/components/SideDrawer/index.d.ts.map +1 -0
- package/lib/typescript/components/SideDrawer/styles.d.ts +88 -0
- package/lib/typescript/components/SideDrawer/styles.d.ts.map +1 -0
- package/lib/typescript/components/Skeleton/Skeleton.d.ts +11 -0
- package/lib/typescript/components/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/typescript/components/Skeleton/index.d.ts +3 -0
- package/lib/typescript/components/Skeleton/index.d.ts.map +1 -0
- package/lib/typescript/components/Skeleton/styles.d.ts +15 -0
- package/lib/typescript/components/Skeleton/styles.d.ts.map +1 -0
- package/lib/typescript/components/Switch/Switch.d.ts +9 -0
- package/lib/typescript/components/Switch/Switch.d.ts.map +1 -0
- package/lib/typescript/components/Switch/index.d.ts +3 -0
- package/lib/typescript/components/Switch/index.d.ts.map +1 -0
- package/lib/typescript/components/Switch/styles.d.ts +30 -0
- package/lib/typescript/components/Switch/styles.d.ts.map +1 -0
- package/lib/typescript/components/TabBar/TabBar.d.ts +26 -0
- package/lib/typescript/components/TabBar/TabBar.d.ts.map +1 -0
- package/lib/typescript/components/TabBar/index.d.ts +3 -0
- package/lib/typescript/components/TabBar/index.d.ts.map +1 -0
- package/lib/typescript/components/TabBar/styles.d.ts +82 -0
- package/lib/typescript/components/TabBar/styles.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/Tabs.d.ts +21 -0
- package/lib/typescript/components/Tabs/Tabs.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/index.d.ts +3 -0
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -0
- package/lib/typescript/components/Tabs/styles.d.ts +100 -0
- package/lib/typescript/components/Tabs/styles.d.ts.map +1 -0
- package/lib/typescript/components/Tag/Tag.d.ts +22 -0
- package/lib/typescript/components/Tag/Tag.d.ts.map +1 -0
- package/lib/typescript/components/Tag/index.d.ts +3 -0
- package/lib/typescript/components/Tag/index.d.ts.map +1 -0
- package/lib/typescript/components/Tag/styles.d.ts +164 -0
- package/lib/typescript/components/Tag/styles.d.ts.map +1 -0
- package/lib/typescript/components/TextArea/TextArea.d.ts +16 -0
- package/lib/typescript/components/TextArea/TextArea.d.ts.map +1 -0
- package/lib/typescript/components/TextArea/index.d.ts +3 -0
- package/lib/typescript/components/TextArea/index.d.ts.map +1 -0
- package/lib/typescript/components/TextArea/styles.d.ts +46 -0
- package/lib/typescript/components/TextArea/styles.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/TimePicker.d.ts +17 -0
- package/lib/typescript/components/TimePicker/TimePicker.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/index.d.ts +4 -0
- package/lib/typescript/components/TimePicker/index.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/model.d.ts +16 -0
- package/lib/typescript/components/TimePicker/model.d.ts.map +1 -0
- package/lib/typescript/components/TimePicker/styles.d.ts +150 -0
- package/lib/typescript/components/TimePicker/styles.d.ts.map +1 -0
- package/lib/typescript/components/Timeline/Timeline.d.ts +12 -0
- package/lib/typescript/components/Timeline/Timeline.d.ts.map +1 -0
- package/lib/typescript/components/Timeline/index.d.ts +4 -0
- package/lib/typescript/components/Timeline/index.d.ts.map +1 -0
- package/lib/typescript/components/Timeline/model.d.ts +45 -0
- package/lib/typescript/components/Timeline/model.d.ts.map +1 -0
- package/lib/typescript/components/Timeline/styles.d.ts +120 -0
- package/lib/typescript/components/Timeline/styles.d.ts.map +1 -0
- package/lib/typescript/components/Toast/Toast.d.ts +30 -0
- package/lib/typescript/components/Toast/Toast.d.ts.map +1 -0
- package/lib/typescript/components/Toast/index.d.ts +3 -0
- package/lib/typescript/components/Toast/index.d.ts.map +1 -0
- package/lib/typescript/components/Toast/styles.d.ts +59 -0
- package/lib/typescript/components/Toast/styles.d.ts.map +1 -0
- package/lib/typescript/components/Upload/Upload.d.ts +31 -0
- package/lib/typescript/components/Upload/Upload.d.ts.map +1 -0
- package/lib/typescript/components/Upload/index.d.ts +4 -0
- package/lib/typescript/components/Upload/index.d.ts.map +1 -0
- package/lib/typescript/components/Upload/model.d.ts +50 -0
- package/lib/typescript/components/Upload/model.d.ts.map +1 -0
- package/lib/typescript/components/Upload/picker.d.ts +13 -0
- package/lib/typescript/components/Upload/picker.d.ts.map +1 -0
- package/lib/typescript/components/Upload/styles.d.ts +376 -0
- package/lib/typescript/components/Upload/styles.d.ts.map +1 -0
- package/lib/typescript/components/index.d.ts +61 -0
- package/lib/typescript/components/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/ui/tokens.d.ts +167 -0
- package/lib/typescript/ui/tokens.d.ts.map +1 -0
- package/package.json +216 -6
- package/src/components/Avatar/Avatar.tsx +192 -0
- package/src/components/Avatar/README.md +32 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Avatar/styles.ts +49 -0
- package/src/components/BottomActionBar/BottomActionBar.tsx +53 -0
- package/src/components/BottomActionBar/README.md +50 -0
- package/src/components/BottomActionBar/index.ts +2 -0
- package/src/components/BottomActionBar/styles.ts +22 -0
- package/src/components/BottomSheet/BottomSheet.tsx +136 -0
- package/src/components/BottomSheet/README.md +51 -0
- package/src/components/BottomSheet/index.ts +2 -0
- package/src/components/BottomSheet/styles.ts +84 -0
- package/src/components/Button/Button.tsx +65 -0
- package/src/components/Button/README.md +59 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Button/styles.ts +50 -0
- package/src/components/Checkbox/Checkbox.tsx +220 -0
- package/src/components/Checkbox/README.md +60 -0
- package/src/components/Checkbox/index.ts +2 -0
- package/src/components/Checkbox/styles.ts +64 -0
- package/src/components/DatePicker/DatePicker.tsx +728 -0
- package/src/components/DatePicker/README.md +88 -0
- package/src/components/DatePicker/index.ts +9 -0
- package/src/components/DatePicker/model.ts +316 -0
- package/src/components/DatePicker/styles.ts +267 -0
- package/src/components/Dialog/Dialog.tsx +254 -0
- package/src/components/Dialog/README.md +98 -0
- package/src/components/Dialog/index.ts +2 -0
- package/src/components/Dialog/styles.ts +109 -0
- package/src/components/EmptyState/EmptyState.tsx +58 -0
- package/src/components/EmptyState/README.md +44 -0
- package/src/components/EmptyState/index.ts +2 -0
- package/src/components/EmptyState/styles.ts +82 -0
- package/src/components/Field/Field.tsx +59 -0
- package/src/components/Field/FieldContext.ts +13 -0
- package/src/components/Field/README.md +68 -0
- package/src/components/Field/index.ts +2 -0
- package/src/components/Field/styles.ts +56 -0
- package/src/components/FilterChips/FilterChips.tsx +110 -0
- package/src/components/FilterChips/README.md +69 -0
- package/src/components/FilterChips/index.ts +2 -0
- package/src/components/FilterChips/styles.ts +72 -0
- package/src/components/Form/Form.tsx +77 -0
- package/src/components/Form/FormItem.tsx +204 -0
- package/src/components/Form/README.md +101 -0
- package/src/components/Form/context.ts +11 -0
- package/src/components/Form/index.ts +25 -0
- package/src/components/Form/model.ts +427 -0
- package/src/components/Form/styles.ts +10 -0
- package/src/components/ImagePreview/ImagePreview.tsx +207 -0
- package/src/components/ImagePreview/README.md +51 -0
- package/src/components/ImagePreview/index.ts +2 -0
- package/src/components/ImagePreview/styles.ts +87 -0
- package/src/components/InlineFeedback/InlineFeedback.tsx +88 -0
- package/src/components/InlineFeedback/README.md +47 -0
- package/src/components/InlineFeedback/index.ts +2 -0
- package/src/components/InlineFeedback/styles.ts +140 -0
- package/src/components/Input/Input.tsx +79 -0
- package/src/components/Input/README.md +62 -0
- package/src/components/Input/index.ts +2 -0
- package/src/components/Input/styles.ts +41 -0
- package/src/components/ListSkeleton/ListSkeleton.tsx +48 -0
- package/src/components/ListSkeleton/README.md +37 -0
- package/src/components/ListSkeleton/index.ts +2 -0
- package/src/components/ListSkeleton/styles.ts +30 -0
- package/src/components/NavigationBar/NavigationBar.tsx +218 -0
- package/src/components/NavigationBar/README.md +72 -0
- package/src/components/NavigationBar/index.ts +7 -0
- package/src/components/NavigationBar/styles.ts +98 -0
- package/src/components/Picker/Picker.tsx +238 -0
- package/src/components/Picker/README.md +76 -0
- package/src/components/Picker/index.ts +8 -0
- package/src/components/Picker/styles.ts +94 -0
- package/src/components/README.md +44 -0
- package/src/components/Radio/README.md +52 -0
- package/src/components/Radio/Radio.tsx +195 -0
- package/src/components/Radio/index.ts +2 -0
- package/src/components/Radio/styles.ts +70 -0
- package/src/components/SearchInput/README.md +48 -0
- package/src/components/SearchInput/SearchInput.tsx +131 -0
- package/src/components/SearchInput/index.ts +2 -0
- package/src/components/SearchInput/styles.ts +100 -0
- package/src/components/SideDrawer/README.md +48 -0
- package/src/components/SideDrawer/SideDrawer.tsx +198 -0
- package/src/components/SideDrawer/index.ts +2 -0
- package/src/components/SideDrawer/styles.ts +86 -0
- package/src/components/Skeleton/README.md +38 -0
- package/src/components/Skeleton/Skeleton.tsx +108 -0
- package/src/components/Skeleton/index.ts +2 -0
- package/src/components/Skeleton/styles.ts +18 -0
- package/src/components/Switch/README.md +27 -0
- package/src/components/Switch/Switch.tsx +77 -0
- package/src/components/Switch/index.ts +2 -0
- package/src/components/Switch/styles.ts +33 -0
- package/src/components/TabBar/README.md +66 -0
- package/src/components/TabBar/TabBar.tsx +93 -0
- package/src/components/TabBar/index.ts +2 -0
- package/src/components/TabBar/styles.ts +81 -0
- package/src/components/Tabs/README.md +64 -0
- package/src/components/Tabs/Tabs.tsx +114 -0
- package/src/components/Tabs/index.ts +2 -0
- package/src/components/Tabs/styles.ts +99 -0
- package/src/components/Tag/README.md +60 -0
- package/src/components/Tag/Tag.tsx +166 -0
- package/src/components/Tag/index.ts +2 -0
- package/src/components/Tag/styles.ts +159 -0
- package/src/components/TextArea/README.md +61 -0
- package/src/components/TextArea/TextArea.tsx +114 -0
- package/src/components/TextArea/index.ts +2 -0
- package/src/components/TextArea/styles.ts +45 -0
- package/src/components/TimePicker/README.md +62 -0
- package/src/components/TimePicker/TimePicker.tsx +343 -0
- package/src/components/TimePicker/index.ts +3 -0
- package/src/components/TimePicker/model.ts +88 -0
- package/src/components/TimePicker/styles.ts +141 -0
- package/src/components/Timeline/README.md +81 -0
- package/src/components/Timeline/Timeline.tsx +197 -0
- package/src/components/Timeline/index.ts +12 -0
- package/src/components/Timeline/model.ts +87 -0
- package/src/components/Timeline/styles.ts +115 -0
- package/src/components/Toast/README.md +68 -0
- package/src/components/Toast/Toast.tsx +310 -0
- package/src/components/Toast/index.ts +8 -0
- package/src/components/Toast/styles.ts +58 -0
- package/src/components/Upload/README.md +93 -0
- package/src/components/Upload/Upload.tsx +839 -0
- package/src/components/Upload/index.ts +14 -0
- package/src/components/Upload/model.ts +61 -0
- package/src/components/Upload/picker.ts +125 -0
- package/src/components/Upload/styles.ts +358 -0
- package/src/components/index.ts +119 -0
- package/src/index.ts +2 -0
- package/src/ui/tokens.ts +144 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import type { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
ActivityIndicator,
|
|
5
|
+
Animated,
|
|
6
|
+
Easing,
|
|
7
|
+
Text,
|
|
8
|
+
View,
|
|
9
|
+
type StyleProp,
|
|
10
|
+
type ViewStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
13
|
+
import Svg, { Path } from 'react-native-svg';
|
|
14
|
+
|
|
15
|
+
import { uiTokens as token } from '../../ui/tokens';
|
|
16
|
+
|
|
17
|
+
import { styles } from './styles';
|
|
18
|
+
|
|
19
|
+
export type ToastPosition = 'bottom' | 'center' | 'top';
|
|
20
|
+
export type ToastIcon = 'fail' | 'loading' | 'none' | 'success';
|
|
21
|
+
|
|
22
|
+
export type ToastShowOptions = {
|
|
23
|
+
afterClose?: () => void;
|
|
24
|
+
content: ReactNode;
|
|
25
|
+
duration?: number;
|
|
26
|
+
icon?: ReactNode | ToastIcon;
|
|
27
|
+
maskClickable?: boolean;
|
|
28
|
+
position?: ToastPosition;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ToastProviderProps = PropsWithChildren<{
|
|
32
|
+
defaultDuration?: number;
|
|
33
|
+
defaultPosition?: ToastPosition;
|
|
34
|
+
style?: StyleProp<ViewStyle>;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export type ToastShowResult = {
|
|
38
|
+
close: () => void;
|
|
39
|
+
id: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type ToastItem = Required<Pick<ToastShowOptions, 'duration' | 'maskClickable' | 'position'>> & {
|
|
43
|
+
afterClose?: () => void;
|
|
44
|
+
content: ReactNode;
|
|
45
|
+
icon?: ReactNode | ToastIcon;
|
|
46
|
+
id: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type ToastEvent = { item: ToastItem; type: 'show' } | { id?: number; type: 'clear' };
|
|
50
|
+
|
|
51
|
+
type ToastListener = (event: ToastEvent) => void;
|
|
52
|
+
|
|
53
|
+
let toastSeed = 0;
|
|
54
|
+
const listeners = new Set<ToastListener>();
|
|
55
|
+
|
|
56
|
+
export const Toast = {
|
|
57
|
+
clear(id?: number) {
|
|
58
|
+
emitToastEvent({ id, type: 'clear' });
|
|
59
|
+
},
|
|
60
|
+
fail(content: ReactNode, options?: Omit<ToastShowOptions, 'content' | 'icon'>) {
|
|
61
|
+
return Toast.show({ ...options, content, icon: 'fail' });
|
|
62
|
+
},
|
|
63
|
+
loading(content: ReactNode = '加载中', options?: Omit<ToastShowOptions, 'content' | 'icon'>) {
|
|
64
|
+
return Toast.show({ duration: 0, ...options, content, icon: 'loading', maskClickable: false });
|
|
65
|
+
},
|
|
66
|
+
show(contentOrOptions: ReactNode | ToastShowOptions): ToastShowResult {
|
|
67
|
+
const options = normalizeToastOptions(contentOrOptions);
|
|
68
|
+
const id = createToastId();
|
|
69
|
+
emitToastEvent({
|
|
70
|
+
item: {
|
|
71
|
+
content: options.content,
|
|
72
|
+
duration: options.duration ?? defaultToastDuration,
|
|
73
|
+
icon: options.icon,
|
|
74
|
+
id,
|
|
75
|
+
maskClickable: options.maskClickable ?? true,
|
|
76
|
+
position: options.position ?? 'center',
|
|
77
|
+
afterClose: options.afterClose,
|
|
78
|
+
},
|
|
79
|
+
type: 'show',
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
close: () => Toast.clear(id),
|
|
83
|
+
id,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
success(content: ReactNode, options?: Omit<ToastShowOptions, 'content' | 'icon'>) {
|
|
87
|
+
return Toast.show({ ...options, content, icon: 'success' });
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const defaultToastDuration = 2000;
|
|
92
|
+
const animationDuration = 180;
|
|
93
|
+
|
|
94
|
+
export function ToastProvider({
|
|
95
|
+
children,
|
|
96
|
+
defaultDuration = defaultToastDuration,
|
|
97
|
+
defaultPosition = 'center',
|
|
98
|
+
style,
|
|
99
|
+
}: ToastProviderProps) {
|
|
100
|
+
const insets = useSafeAreaInsets();
|
|
101
|
+
const [toast, setToast] = useState<ToastItem | null>(null);
|
|
102
|
+
const [opacity] = useState(() => new Animated.Value(0));
|
|
103
|
+
const [scale] = useState(() => new Animated.Value(0.96));
|
|
104
|
+
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
105
|
+
const closingRef = useRef(false);
|
|
106
|
+
const toastRef = useRef<ToastItem | null>(null);
|
|
107
|
+
|
|
108
|
+
const clearTimer = useCallback(() => {
|
|
109
|
+
if (!timerRef.current) return;
|
|
110
|
+
clearTimeout(timerRef.current);
|
|
111
|
+
timerRef.current = null;
|
|
112
|
+
}, []);
|
|
113
|
+
|
|
114
|
+
const closeToast = useCallback(
|
|
115
|
+
(id?: number) => {
|
|
116
|
+
const currentToast = toastRef.current;
|
|
117
|
+
if (!currentToast || closingRef.current) return;
|
|
118
|
+
if (id !== undefined && currentToast.id !== id) return;
|
|
119
|
+
|
|
120
|
+
closingRef.current = true;
|
|
121
|
+
clearTimer();
|
|
122
|
+
Animated.parallel([
|
|
123
|
+
Animated.timing(opacity, {
|
|
124
|
+
duration: animationDuration,
|
|
125
|
+
easing: Easing.in(Easing.cubic),
|
|
126
|
+
toValue: 0,
|
|
127
|
+
useNativeDriver: true,
|
|
128
|
+
}),
|
|
129
|
+
Animated.timing(scale, {
|
|
130
|
+
duration: animationDuration,
|
|
131
|
+
easing: Easing.in(Easing.cubic),
|
|
132
|
+
toValue: 0.96,
|
|
133
|
+
useNativeDriver: true,
|
|
134
|
+
}),
|
|
135
|
+
]).start(({ finished }) => {
|
|
136
|
+
if (!finished) return;
|
|
137
|
+
const closedToast = toastRef.current;
|
|
138
|
+
toastRef.current = null;
|
|
139
|
+
setToast(null);
|
|
140
|
+
closingRef.current = false;
|
|
141
|
+
closedToast?.afterClose?.();
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
[clearTimer, opacity, scale],
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const showToast = useCallback(
|
|
148
|
+
(item: ToastItem) => {
|
|
149
|
+
const nextToast: ToastItem = {
|
|
150
|
+
...item,
|
|
151
|
+
duration: item.duration ?? defaultDuration,
|
|
152
|
+
position: item.position ?? defaultPosition,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
closingRef.current = false;
|
|
156
|
+
toastRef.current = nextToast;
|
|
157
|
+
clearTimer();
|
|
158
|
+
opacity.stopAnimation();
|
|
159
|
+
scale.stopAnimation();
|
|
160
|
+
opacity.setValue(0);
|
|
161
|
+
scale.setValue(0.96);
|
|
162
|
+
setToast(nextToast);
|
|
163
|
+
Animated.parallel([
|
|
164
|
+
Animated.timing(opacity, {
|
|
165
|
+
duration: animationDuration,
|
|
166
|
+
easing: Easing.out(Easing.cubic),
|
|
167
|
+
toValue: 1,
|
|
168
|
+
useNativeDriver: true,
|
|
169
|
+
}),
|
|
170
|
+
Animated.timing(scale, {
|
|
171
|
+
duration: animationDuration,
|
|
172
|
+
easing: Easing.out(Easing.cubic),
|
|
173
|
+
toValue: 1,
|
|
174
|
+
useNativeDriver: true,
|
|
175
|
+
}),
|
|
176
|
+
]).start();
|
|
177
|
+
|
|
178
|
+
if (nextToast.duration > 0) {
|
|
179
|
+
timerRef.current = setTimeout(() => closeToast(nextToast.id), nextToast.duration);
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
[clearTimer, closeToast, defaultDuration, defaultPosition, opacity, scale],
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
const listener: ToastListener = (event) => {
|
|
187
|
+
if (event.type === 'show') {
|
|
188
|
+
showToast(event.item);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
closeToast(event.id);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
listeners.add(listener);
|
|
195
|
+
return () => {
|
|
196
|
+
listeners.delete(listener);
|
|
197
|
+
clearTimer();
|
|
198
|
+
};
|
|
199
|
+
}, [clearTimer, closeToast, showToast]);
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<View style={[styles.provider, style]}>
|
|
203
|
+
{children}
|
|
204
|
+
{toast ? (
|
|
205
|
+
<View
|
|
206
|
+
pointerEvents={toast.maskClickable ? 'box-none' : 'auto'}
|
|
207
|
+
style={[
|
|
208
|
+
styles.overlay,
|
|
209
|
+
stylesByPosition[toast.position],
|
|
210
|
+
toast.position === 'top' && { paddingTop: Math.max(insets.top + token.space.s16, 60) },
|
|
211
|
+
toast.position === 'bottom' && {
|
|
212
|
+
paddingBottom: Math.max(insets.bottom + token.space.s24, 72),
|
|
213
|
+
},
|
|
214
|
+
]}
|
|
215
|
+
>
|
|
216
|
+
<Animated.View
|
|
217
|
+
accessibilityLiveRegion="polite"
|
|
218
|
+
accessibilityRole="alert"
|
|
219
|
+
style={[
|
|
220
|
+
styles.toast,
|
|
221
|
+
hasToastIcon(toast.icon) ? styles.toastWithIcon : null,
|
|
222
|
+
{ opacity, transform: [{ scale }] },
|
|
223
|
+
]}
|
|
224
|
+
>
|
|
225
|
+
<ToastIconView icon={toast.icon} />
|
|
226
|
+
{typeof toast.content === 'string' || typeof toast.content === 'number' ? (
|
|
227
|
+
<Text style={styles.content}>{toast.content}</Text>
|
|
228
|
+
) : (
|
|
229
|
+
toast.content
|
|
230
|
+
)}
|
|
231
|
+
</Animated.View>
|
|
232
|
+
</View>
|
|
233
|
+
) : null}
|
|
234
|
+
</View>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const stylesByPosition: Record<ToastPosition, StyleProp<ViewStyle>> = {
|
|
239
|
+
bottom: styles.overlayBottom,
|
|
240
|
+
center: styles.overlayCenter,
|
|
241
|
+
top: styles.overlayTop,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
function ToastIconView({ icon }: { icon?: ReactNode | ToastIcon }) {
|
|
245
|
+
if (!hasToastIcon(icon)) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (icon === 'loading') {
|
|
250
|
+
return <ActivityIndicator color={token.color.onTint} size="small" />;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (icon === 'success') {
|
|
254
|
+
return (
|
|
255
|
+
<Svg fill="none" height={28} viewBox="0 0 28 28" width={28}>
|
|
256
|
+
<Path
|
|
257
|
+
d="m8 14.4 3.8 3.8L20.5 9"
|
|
258
|
+
stroke={token.color.onTint}
|
|
259
|
+
strokeLinecap="round"
|
|
260
|
+
strokeLinejoin="round"
|
|
261
|
+
strokeWidth={2.4}
|
|
262
|
+
/>
|
|
263
|
+
</Svg>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (icon === 'fail') {
|
|
268
|
+
return (
|
|
269
|
+
<Svg fill="none" height={28} viewBox="0 0 28 28" width={28}>
|
|
270
|
+
<Path
|
|
271
|
+
d="M9 9 19 19M19 9 9 19"
|
|
272
|
+
stroke={token.color.onTint}
|
|
273
|
+
strokeLinecap="round"
|
|
274
|
+
strokeLinejoin="round"
|
|
275
|
+
strokeWidth={2.4}
|
|
276
|
+
/>
|
|
277
|
+
</Svg>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return <>{icon}</>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function hasToastIcon(icon?: ReactNode | ToastIcon) {
|
|
285
|
+
return Boolean(icon && icon !== 'none');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function createToastId() {
|
|
289
|
+
toastSeed += 1;
|
|
290
|
+
return toastSeed;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function emitToastEvent(event: ToastEvent) {
|
|
294
|
+
listeners.forEach((listener) => listener(event));
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function normalizeToastOptions(contentOrOptions: ReactNode | ToastShowOptions): ToastShowOptions {
|
|
298
|
+
if (
|
|
299
|
+
contentOrOptions &&
|
|
300
|
+
typeof contentOrOptions === 'object' &&
|
|
301
|
+
!Array.isArray(contentOrOptions) &&
|
|
302
|
+
'content' in contentOrOptions
|
|
303
|
+
) {
|
|
304
|
+
return contentOrOptions;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
content: contentOrOptions,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { uiTokens as token } from '../../ui/tokens';
|
|
4
|
+
|
|
5
|
+
export const styles = StyleSheet.create({
|
|
6
|
+
content: {
|
|
7
|
+
color: token.color.onTint,
|
|
8
|
+
textAlign: 'center',
|
|
9
|
+
...token.type.footnote,
|
|
10
|
+
fontWeight: '600',
|
|
11
|
+
},
|
|
12
|
+
overlay: {
|
|
13
|
+
bottom: 0,
|
|
14
|
+
left: 0,
|
|
15
|
+
paddingHorizontal: token.space.s24,
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
right: 0,
|
|
18
|
+
top: 0,
|
|
19
|
+
zIndex: 999,
|
|
20
|
+
},
|
|
21
|
+
overlayBottom: {
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'flex-end',
|
|
24
|
+
},
|
|
25
|
+
overlayCenter: {
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
},
|
|
29
|
+
overlayTop: {
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'flex-start',
|
|
32
|
+
},
|
|
33
|
+
provider: {
|
|
34
|
+
flex: 1,
|
|
35
|
+
},
|
|
36
|
+
toast: {
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
backgroundColor: 'rgba(25, 43, 50, 0.88)',
|
|
39
|
+
borderRadius: token.radius.large,
|
|
40
|
+
maxWidth: '88%',
|
|
41
|
+
minHeight: 44,
|
|
42
|
+
minWidth: 120,
|
|
43
|
+
paddingHorizontal: token.space.s16,
|
|
44
|
+
paddingVertical: token.space.s12,
|
|
45
|
+
shadowColor: token.color.tabBarShadow,
|
|
46
|
+
shadowOffset: { height: 8, width: 0 },
|
|
47
|
+
shadowOpacity: 0.14,
|
|
48
|
+
shadowRadius: 20,
|
|
49
|
+
elevation: token.shadow.floatingElevation,
|
|
50
|
+
},
|
|
51
|
+
toastWithIcon: {
|
|
52
|
+
gap: token.space.s8,
|
|
53
|
+
minHeight: 96,
|
|
54
|
+
minWidth: 112,
|
|
55
|
+
paddingHorizontal: token.space.s20,
|
|
56
|
+
paddingVertical: token.space.s16,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Upload 上传
|
|
2
|
+
|
|
3
|
+
## 作用
|
|
4
|
+
|
|
5
|
+
`Upload` 统一承载头像、图片宫格和文件列表的选择、单文件校验、上传任务状态、删除与重试。组件参考设计稿中的 `Upload · picture`,每个条目独立显示待上传、上传中、上传成功和上传失败状态。
|
|
6
|
+
|
|
7
|
+
## 适用场景
|
|
8
|
+
|
|
9
|
+
- `listType="avatar"`:单张头像。
|
|
10
|
+
- `listType="picture"`:多图宫格、凭证和成长记录。
|
|
11
|
+
- `listType="file"`:PDF、Office 等普通文件列表。
|
|
12
|
+
|
|
13
|
+
不适用于页面专属附件卡片、业务接口编排或服务端附件关系维护。字段标签、必填标识和表单错误由 `Field` / `Form.Item` 负责。
|
|
14
|
+
|
|
15
|
+
## 基础用法
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
const [files, setFiles] = useState<UploadItem[]>([]);
|
|
19
|
+
|
|
20
|
+
<Upload
|
|
21
|
+
accept={['image/jpeg', 'image/png']}
|
|
22
|
+
maxCount={9}
|
|
23
|
+
maxSize={10 * 1024 * 1024}
|
|
24
|
+
multiple
|
|
25
|
+
onChange={setFiles}
|
|
26
|
+
upload={async (asset) => {
|
|
27
|
+
const response = await repository.upload(asset);
|
|
28
|
+
return { fileId: response.id, url: response.url };
|
|
29
|
+
}}
|
|
30
|
+
value={files}
|
|
31
|
+
/>;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
不传 `upload` 时,选择结果保持 `pending`,由表单最终提交时统一上传:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Form.Item label="荣誉资料" name="attachments" trigger="onChange">
|
|
38
|
+
<Upload listType="file" maxCount={10} />
|
|
39
|
+
</Form.Item>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 核心 Props
|
|
43
|
+
|
|
44
|
+
| 属性 | 说明 | 默认值 |
|
|
45
|
+
| ---------------------- | -------------------------------------- | -------------------------------------- |
|
|
46
|
+
| `value / defaultValue` | 受控值 / 非受控初始值 | `[]` |
|
|
47
|
+
| `onChange` | 任一条目状态或列表变化回调 | - |
|
|
48
|
+
| `listType` | `avatar / picture / file` | `picture` |
|
|
49
|
+
| `sources` | `camera / library / document` 来源 | 图片为相机、相册、文件;文件列表为文档 |
|
|
50
|
+
| `accept` | MIME 或扩展名白名单,支持 `image/*` | 图片为 `image/*`,文件为 `*/*` |
|
|
51
|
+
| `maxCount` | 最大条目数 | 图片 `9`,其他 `1` |
|
|
52
|
+
| `maxSize` | 单个文件的最大字节数 | - |
|
|
53
|
+
| `multiple` | 是否允许系统选择器多选 | 根据 `maxCount` 推断 |
|
|
54
|
+
| `upload` | 自动上传函数;未提供时保留 `pending` | - |
|
|
55
|
+
| `beforeAdd` | 上传前转换或返回 `false` 忽略文件 | - |
|
|
56
|
+
| `onReject` | 类型、数量、大小、权限或选择器失败回调 | - |
|
|
57
|
+
| `onRemove` | 删除前回调,返回 `false` 可阻止删除 | - |
|
|
58
|
+
| `previewable` | 成功图片点击后打开 `ImagePreview` | `true` |
|
|
59
|
+
| `deletable` | 是否显示删除操作 | `true` |
|
|
60
|
+
| `readOnly` | 禁止选择、删除和重试,但允许预览 | `false` |
|
|
61
|
+
| `disabled` | 整体禁用,包括预览 | `false` |
|
|
62
|
+
|
|
63
|
+
## 值与状态
|
|
64
|
+
|
|
65
|
+
`UploadItem.status` 为:
|
|
66
|
+
|
|
67
|
+
- `pending`:已选择,等待调用方提交。
|
|
68
|
+
- `uploading`:正在执行 `upload`;只有上传函数调用 `onProgress` 时才显示真实百分比,不伪造进度。
|
|
69
|
+
- `uploaded`:上传成功,可点击图片进入独立预览层。
|
|
70
|
+
- `failed`:上传失败;保留“重试”和右上角删除。
|
|
71
|
+
|
|
72
|
+
`UploadItem` 只保存通用文件信息,不包含业务 `scene`、API DTO 或 repository 类型。系统选择器返回的原始对象保存在 `raw`,来源保存在 `source`;调用方可以使用 `extra` 保存不可见的业务映射。
|
|
73
|
+
|
|
74
|
+
## 校验规则
|
|
75
|
+
|
|
76
|
+
- `maxSize` 只校验单个图片或文件,不累计总大小。
|
|
77
|
+
- 校验发生在上传函数执行前;超限文件不进入列表,也不调用 `upload`。
|
|
78
|
+
- 多选时仅拒绝不合规文件,其他文件继续添加。
|
|
79
|
+
- 无法从系统选择器获得 `size` 时不猜测大小,由后端继续执行最终限制。
|
|
80
|
+
|
|
81
|
+
## 交互与无障碍
|
|
82
|
+
|
|
83
|
+
- 图片删除视觉为右上角小叉,外层点击区域固定为 `44 × 44pt`。
|
|
84
|
+
- 只有 `uploaded` 图片可以打开预览;失败图片同时保留重试和删除。
|
|
85
|
+
- 上传状态包含文字,不只依赖颜色。
|
|
86
|
+
- 多来源选择直接组合公共 `BottomSheet`,统一展示拍照、相册和文件入口;来源列表保留为 `Upload` 内部实现,不公开 `UploadSourceSheet`。
|
|
87
|
+
- 当前上传函数完成后才能确认成功;移除上传中条目不会取消已经发出的网络请求,调用方需要避免因此生成孤立附件。
|
|
88
|
+
|
|
89
|
+
## 组件边界
|
|
90
|
+
|
|
91
|
+
- `Upload` 组合公共 `ImagePreview`,但不直接请求 API、不读取 repository、route 或业务 store。
|
|
92
|
+
- 服务端删除、附件解绑、鉴权图片请求头和上传 `scene` 均由调用方处理。
|
|
93
|
+
- 展示入口:`ComponentIndex` 的 `Upload + ImagePreview` 区域。
|