@unif/react-native-chat 2.0.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/LICENSE +20 -0
- package/README.md +48 -0
- package/lib/module/actions/index.js +2 -0
- package/lib/module/actions/index.js.map +1 -0
- package/lib/module/actions/types.js +4 -0
- package/lib/module/actions/types.js.map +1 -0
- package/lib/module/components/Attachments/AttachmentItem.js +108 -0
- package/lib/module/components/Attachments/AttachmentItem.js.map +1 -0
- package/lib/module/components/Attachments/Attachments.js +60 -0
- package/lib/module/components/Attachments/Attachments.js.map +1 -0
- package/lib/module/components/Attachments/constants.js +18 -0
- package/lib/module/components/Attachments/constants.js.map +1 -0
- package/lib/module/components/Attachments/index.js +4 -0
- package/lib/module/components/Attachments/index.js.map +1 -0
- package/lib/module/components/Attachments/styles.js +83 -0
- package/lib/module/components/Attachments/styles.js.map +1 -0
- package/lib/module/components/Attachments/types.js +4 -0
- package/lib/module/components/Attachments/types.js.map +1 -0
- package/lib/module/components/Chat/Chat.js +29 -0
- package/lib/module/components/Chat/Chat.js.map +1 -0
- package/lib/module/components/Chat/index.js +4 -0
- package/lib/module/components/Chat/index.js.map +1 -0
- package/lib/module/components/Chat/styles.js +17 -0
- package/lib/module/components/Chat/styles.js.map +1 -0
- package/lib/module/components/Chat/types.js +4 -0
- package/lib/module/components/Chat/types.js.map +1 -0
- package/lib/module/components/Citation/Citation.js +32 -0
- package/lib/module/components/Citation/Citation.js.map +1 -0
- package/lib/module/components/Citation/index.js +4 -0
- package/lib/module/components/Citation/index.js.map +1 -0
- package/lib/module/components/Citation/styles.js +15 -0
- package/lib/module/components/Citation/styles.js.map +1 -0
- package/lib/module/components/Citation/types.js +2 -0
- package/lib/module/components/Citation/types.js.map +1 -0
- package/lib/module/components/Composer/Composer.js +149 -0
- package/lib/module/components/Composer/Composer.js.map +1 -0
- package/lib/module/components/Composer/constants.js +14 -0
- package/lib/module/components/Composer/constants.js.map +1 -0
- package/lib/module/components/Composer/index.js +4 -0
- package/lib/module/components/Composer/index.js.map +1 -0
- package/lib/module/components/Composer/styles.js +43 -0
- package/lib/module/components/Composer/styles.js.map +1 -0
- package/lib/module/components/Composer/types.js +4 -0
- package/lib/module/components/Composer/types.js.map +1 -0
- package/lib/module/components/Confirmation/Confirmation.js +56 -0
- package/lib/module/components/Confirmation/Confirmation.js.map +1 -0
- package/lib/module/components/Confirmation/constants.js +10 -0
- package/lib/module/components/Confirmation/constants.js.map +1 -0
- package/lib/module/components/Confirmation/index.js +4 -0
- package/lib/module/components/Confirmation/index.js.map +1 -0
- package/lib/module/components/Confirmation/styles.js +34 -0
- package/lib/module/components/Confirmation/styles.js.map +1 -0
- package/lib/module/components/Confirmation/types.js +4 -0
- package/lib/module/components/Confirmation/types.js.map +1 -0
- package/lib/module/components/Feedback/Feedback.js +82 -0
- package/lib/module/components/Feedback/Feedback.js.map +1 -0
- package/lib/module/components/Feedback/constants.js +15 -0
- package/lib/module/components/Feedback/constants.js.map +1 -0
- package/lib/module/components/Feedback/index.js +4 -0
- package/lib/module/components/Feedback/index.js.map +1 -0
- package/lib/module/components/Feedback/styles.js +30 -0
- package/lib/module/components/Feedback/styles.js.map +1 -0
- package/lib/module/components/Feedback/types.js +4 -0
- package/lib/module/components/Feedback/types.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownContent.js +68 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownContent.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.js +53 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/styles.js +10 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/styles.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/types.js +2 -0
- package/lib/module/components/Message/MarkdownContent/MarkdownImage/types.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/styles.js +85 -0
- package/lib/module/components/Message/MarkdownContent/styles.js.map +1 -0
- package/lib/module/components/Message/MarkdownContent/types.js +2 -0
- package/lib/module/components/Message/MarkdownContent/types.js.map +1 -0
- package/lib/module/components/Message/Message.js +87 -0
- package/lib/module/components/Message/Message.js.map +1 -0
- package/lib/module/components/Message/constants.js +4 -0
- package/lib/module/components/Message/constants.js.map +1 -0
- package/lib/module/components/Message/index.js +4 -0
- package/lib/module/components/Message/index.js.map +1 -0
- package/lib/module/components/Message/isNestedAction.js +14 -0
- package/lib/module/components/Message/isNestedAction.js.map +1 -0
- package/lib/module/components/Message/styles.js +73 -0
- package/lib/module/components/Message/styles.js.map +1 -0
- package/lib/module/components/Message/types.js +4 -0
- package/lib/module/components/Message/types.js.map +1 -0
- package/lib/module/components/MessageList/MessageList.js +223 -0
- package/lib/module/components/MessageList/MessageList.js.map +1 -0
- package/lib/module/components/MessageList/constants.js +4 -0
- package/lib/module/components/MessageList/constants.js.map +1 -0
- package/lib/module/components/MessageList/index.js +4 -0
- package/lib/module/components/MessageList/index.js.map +1 -0
- package/lib/module/components/MessageList/styles.js +20 -0
- package/lib/module/components/MessageList/styles.js.map +1 -0
- package/lib/module/components/MessageList/types.js +4 -0
- package/lib/module/components/MessageList/types.js.map +1 -0
- package/lib/module/components/MessageList/webPrependAnchor/constants.js +4 -0
- package/lib/module/components/MessageList/webPrependAnchor/constants.js.map +1 -0
- package/lib/module/components/MessageList/webPrependAnchor/index.js +4 -0
- package/lib/module/components/MessageList/webPrependAnchor/index.js.map +1 -0
- package/lib/module/components/MessageList/webPrependAnchor/types.js +4 -0
- package/lib/module/components/MessageList/webPrependAnchor/types.js.map +1 -0
- package/lib/module/components/MessageList/webPrependAnchor/useWebPrependAnchor.js +19 -0
- package/lib/module/components/MessageList/webPrependAnchor/useWebPrependAnchor.js.map +1 -0
- package/lib/module/components/MessageList/webPrependAnchor/useWebPrependAnchor.web.js +208 -0
- package/lib/module/components/MessageList/webPrependAnchor/useWebPrependAnchor.web.js.map +1 -0
- package/lib/module/components/Process/Process.js +121 -0
- package/lib/module/components/Process/Process.js.map +1 -0
- package/lib/module/components/Process/constants.js +17 -0
- package/lib/module/components/Process/constants.js.map +1 -0
- package/lib/module/components/Process/index.js +4 -0
- package/lib/module/components/Process/index.js.map +1 -0
- package/lib/module/components/Process/styles.js +77 -0
- package/lib/module/components/Process/styles.js.map +1 -0
- package/lib/module/components/Process/types.js +4 -0
- package/lib/module/components/Process/types.js.map +1 -0
- package/lib/module/components/Sources/Sources.js +64 -0
- package/lib/module/components/Sources/Sources.js.map +1 -0
- package/lib/module/components/Sources/constants.js +4 -0
- package/lib/module/components/Sources/constants.js.map +1 -0
- package/lib/module/components/Sources/index.js +4 -0
- package/lib/module/components/Sources/index.js.map +1 -0
- package/lib/module/components/Sources/styles.js +52 -0
- package/lib/module/components/Sources/styles.js.map +1 -0
- package/lib/module/components/Sources/types.js +4 -0
- package/lib/module/components/Sources/types.js.map +1 -0
- package/lib/module/components/Suggestions/Suggestions.js +31 -0
- package/lib/module/components/Suggestions/Suggestions.js.map +1 -0
- package/lib/module/components/Suggestions/index.js +4 -0
- package/lib/module/components/Suggestions/index.js.map +1 -0
- package/lib/module/components/Suggestions/styles.js +18 -0
- package/lib/module/components/Suggestions/styles.js.map +1 -0
- package/lib/module/components/Suggestions/types.js +4 -0
- package/lib/module/components/Suggestions/types.js.map +1 -0
- package/lib/module/index.js +14 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/actions/index.d.ts +2 -0
- package/lib/typescript/src/actions/index.d.ts.map +1 -0
- package/lib/typescript/src/actions/types.d.ts +11 -0
- package/lib/typescript/src/actions/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts +3 -0
- package/lib/typescript/src/components/Attachments/AttachmentItem.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/Attachments.d.ts +3 -0
- package/lib/typescript/src/components/Attachments/Attachments.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/constants.d.ts +13 -0
- package/lib/typescript/src/components/Attachments/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/index.d.ts +3 -0
- package/lib/typescript/src/components/Attachments/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/styles.d.ts +80 -0
- package/lib/typescript/src/components/Attachments/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Attachments/types.d.ts +34 -0
- package/lib/typescript/src/components/Attachments/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Chat/Chat.d.ts +3 -0
- package/lib/typescript/src/components/Chat/Chat.d.ts.map +1 -0
- package/lib/typescript/src/components/Chat/index.d.ts +3 -0
- package/lib/typescript/src/components/Chat/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Chat/styles.d.ts +15 -0
- package/lib/typescript/src/components/Chat/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Chat/types.d.ts +12 -0
- package/lib/typescript/src/components/Chat/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Citation/Citation.d.ts +3 -0
- package/lib/typescript/src/components/Citation/Citation.d.ts.map +1 -0
- package/lib/typescript/src/components/Citation/index.d.ts +3 -0
- package/lib/typescript/src/components/Citation/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Citation/styles.d.ts +12 -0
- package/lib/typescript/src/components/Citation/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Citation/types.d.ts +8 -0
- package/lib/typescript/src/components/Citation/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Composer/Composer.d.ts +4 -0
- package/lib/typescript/src/components/Composer/Composer.d.ts.map +1 -0
- package/lib/typescript/src/components/Composer/constants.d.ts +12 -0
- package/lib/typescript/src/components/Composer/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Composer/index.d.ts +3 -0
- package/lib/typescript/src/components/Composer/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Composer/styles.d.ts +40 -0
- package/lib/typescript/src/components/Composer/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Composer/types.d.ts +53 -0
- package/lib/typescript/src/components/Composer/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Confirmation/Confirmation.d.ts +3 -0
- package/lib/typescript/src/components/Confirmation/Confirmation.d.ts.map +1 -0
- package/lib/typescript/src/components/Confirmation/constants.d.ts +5 -0
- package/lib/typescript/src/components/Confirmation/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Confirmation/index.d.ts +3 -0
- package/lib/typescript/src/components/Confirmation/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Confirmation/styles.d.ts +31 -0
- package/lib/typescript/src/components/Confirmation/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Confirmation/types.d.ts +19 -0
- package/lib/typescript/src/components/Confirmation/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Feedback/Feedback.d.ts +3 -0
- package/lib/typescript/src/components/Feedback/Feedback.d.ts.map +1 -0
- package/lib/typescript/src/components/Feedback/constants.d.ts +5 -0
- package/lib/typescript/src/components/Feedback/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Feedback/index.d.ts +3 -0
- package/lib/typescript/src/components/Feedback/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Feedback/styles.d.ts +27 -0
- package/lib/typescript/src/components/Feedback/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Feedback/types.d.ts +12 -0
- package/lib/typescript/src/components/Feedback/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownContent.d.ts +3 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownContent.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.d.ts +3 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/styles.d.ts +7 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/types.d.ts +9 -0
- package/lib/typescript/src/components/Message/MarkdownContent/MarkdownImage/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts +92 -0
- package/lib/typescript/src/components/Message/MarkdownContent/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/MarkdownContent/types.d.ts +5 -0
- package/lib/typescript/src/components/Message/MarkdownContent/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/Message.d.ts +3 -0
- package/lib/typescript/src/components/Message/Message.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/constants.d.ts +2 -0
- package/lib/typescript/src/components/Message/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/index.d.ts +3 -0
- package/lib/typescript/src/components/Message/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/isNestedAction.d.ts +3 -0
- package/lib/typescript/src/components/Message/isNestedAction.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/styles.d.ts +70 -0
- package/lib/typescript/src/components/Message/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Message/types.d.ts +44 -0
- package/lib/typescript/src/components/Message/types.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/MessageList.d.ts +4 -0
- package/lib/typescript/src/components/MessageList/MessageList.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/constants.d.ts +2 -0
- package/lib/typescript/src/components/MessageList/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/index.d.ts +3 -0
- package/lib/typescript/src/components/MessageList/index.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/styles.d.ts +16 -0
- package/lib/typescript/src/components/MessageList/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/types.d.ts +36 -0
- package/lib/typescript/src/components/MessageList/types.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/constants.d.ts +2 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/index.d.ts +3 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/index.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/types.d.ts +72 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/types.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.d.ts +3 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.d.ts.map +1 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.web.d.ts +3 -0
- package/lib/typescript/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/Process.d.ts +3 -0
- package/lib/typescript/src/components/Process/Process.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/constants.d.ts +5 -0
- package/lib/typescript/src/components/Process/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/index.d.ts +3 -0
- package/lib/typescript/src/components/Process/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/styles.d.ts +74 -0
- package/lib/typescript/src/components/Process/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Process/types.d.ts +32 -0
- package/lib/typescript/src/components/Process/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Sources/Sources.d.ts +3 -0
- package/lib/typescript/src/components/Sources/Sources.d.ts.map +1 -0
- package/lib/typescript/src/components/Sources/constants.d.ts +2 -0
- package/lib/typescript/src/components/Sources/constants.d.ts.map +1 -0
- package/lib/typescript/src/components/Sources/index.d.ts +3 -0
- package/lib/typescript/src/components/Sources/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Sources/styles.d.ts +49 -0
- package/lib/typescript/src/components/Sources/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Sources/types.d.ts +16 -0
- package/lib/typescript/src/components/Sources/types.d.ts.map +1 -0
- package/lib/typescript/src/components/Suggestions/Suggestions.d.ts +3 -0
- package/lib/typescript/src/components/Suggestions/Suggestions.d.ts.map +1 -0
- package/lib/typescript/src/components/Suggestions/index.d.ts +3 -0
- package/lib/typescript/src/components/Suggestions/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Suggestions/styles.d.ts +14 -0
- package/lib/typescript/src/components/Suggestions/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/Suggestions/types.d.ts +18 -0
- package/lib/typescript/src/components/Suggestions/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +24 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/types.ts +11 -0
- package/src/components/Attachments/AttachmentItem.tsx +139 -0
- package/src/components/Attachments/Attachments.tsx +72 -0
- package/src/components/Attachments/constants.ts +21 -0
- package/src/components/Attachments/index.ts +6 -0
- package/src/components/Attachments/styles.ts +54 -0
- package/src/components/Attachments/types.ts +38 -0
- package/src/components/Chat/Chat.tsx +26 -0
- package/src/components/Chat/index.ts +2 -0
- package/src/components/Chat/styles.ts +12 -0
- package/src/components/Chat/types.ts +11 -0
- package/src/components/Citation/Citation.tsx +33 -0
- package/src/components/Citation/index.ts +2 -0
- package/src/components/Citation/styles.ts +15 -0
- package/src/components/Citation/types.ts +7 -0
- package/src/components/Composer/Composer.tsx +208 -0
- package/src/components/Composer/constants.ts +11 -0
- package/src/components/Composer/index.ts +11 -0
- package/src/components/Composer/styles.ts +25 -0
- package/src/components/Composer/types.ts +61 -0
- package/src/components/Confirmation/Confirmation.tsx +63 -0
- package/src/components/Confirmation/constants.ts +12 -0
- package/src/components/Confirmation/index.ts +2 -0
- package/src/components/Confirmation/styles.ts +39 -0
- package/src/components/Confirmation/types.ts +21 -0
- package/src/components/Feedback/Feedback.tsx +87 -0
- package/src/components/Feedback/constants.ts +16 -0
- package/src/components/Feedback/index.ts +2 -0
- package/src/components/Feedback/styles.ts +30 -0
- package/src/components/Feedback/types.ts +13 -0
- package/src/components/Message/MarkdownContent/MarkdownContent.tsx +70 -0
- package/src/components/Message/MarkdownContent/MarkdownImage/MarkdownImage.tsx +52 -0
- package/src/components/Message/MarkdownContent/MarkdownImage/styles.ts +4 -0
- package/src/components/Message/MarkdownContent/MarkdownImage/types.ts +8 -0
- package/src/components/Message/MarkdownContent/styles.ts +61 -0
- package/src/components/Message/MarkdownContent/types.ts +4 -0
- package/src/components/Message/Message.tsx +137 -0
- package/src/components/Message/constants.ts +2 -0
- package/src/components/Message/index.ts +10 -0
- package/src/components/Message/isNestedAction.ts +22 -0
- package/src/components/Message/styles.ts +42 -0
- package/src/components/Message/types.ts +45 -0
- package/src/components/MessageList/MessageList.tsx +238 -0
- package/src/components/MessageList/constants.ts +1 -0
- package/src/components/MessageList/index.ts +6 -0
- package/src/components/MessageList/styles.ts +7 -0
- package/src/components/MessageList/types.ts +36 -0
- package/src/components/MessageList/webPrependAnchor/constants.ts +6 -0
- package/src/components/MessageList/webPrependAnchor/index.ts +7 -0
- package/src/components/MessageList/webPrependAnchor/types.ts +92 -0
- package/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.ts +27 -0
- package/src/components/MessageList/webPrependAnchor/useWebPrependAnchor.web.ts +293 -0
- package/src/components/Process/Process.tsx +160 -0
- package/src/components/Process/constants.ts +22 -0
- package/src/components/Process/index.ts +9 -0
- package/src/components/Process/styles.ts +77 -0
- package/src/components/Process/types.ts +39 -0
- package/src/components/Sources/Sources.tsx +70 -0
- package/src/components/Sources/constants.ts +1 -0
- package/src/components/Sources/index.ts +2 -0
- package/src/components/Sources/styles.ts +59 -0
- package/src/components/Sources/types.ts +17 -0
- package/src/components/Suggestions/Suggestions.tsx +34 -0
- package/src/components/Suggestions/index.ts +2 -0
- package/src/components/Suggestions/styles.ts +16 -0
- package/src/components/Suggestions/types.ts +19 -0
- package/src/index.tsx +61 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface WebRectLike {
|
|
4
|
+
top: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface WebEventListenerOptions {
|
|
9
|
+
capture?: boolean;
|
|
10
|
+
passive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface WebElementLike {
|
|
14
|
+
id: string;
|
|
15
|
+
scrollTop: number;
|
|
16
|
+
scrollHeight: number;
|
|
17
|
+
getBoundingClientRect(): WebRectLike;
|
|
18
|
+
querySelectorAll(selector: string): ArrayLike<unknown>;
|
|
19
|
+
contains(candidate: unknown): boolean;
|
|
20
|
+
addEventListener(
|
|
21
|
+
type: string,
|
|
22
|
+
listener: () => void,
|
|
23
|
+
options?: WebEventListenerOptions
|
|
24
|
+
): void;
|
|
25
|
+
removeEventListener(
|
|
26
|
+
type: string,
|
|
27
|
+
listener: () => void,
|
|
28
|
+
options?: WebEventListenerOptions
|
|
29
|
+
): void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface WebObserverLike {
|
|
33
|
+
observe(target: unknown, options?: unknown): void;
|
|
34
|
+
unobserve?(target: unknown): void;
|
|
35
|
+
disconnect(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface WebObserverConstructor {
|
|
39
|
+
new (callback: () => void): WebObserverLike;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface WebDocumentLike {
|
|
43
|
+
getElementById(id: string): unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface WebGlobals {
|
|
47
|
+
document?: WebDocumentLike;
|
|
48
|
+
MutationObserver?: WebObserverConstructor;
|
|
49
|
+
ResizeObserver?: WebObserverConstructor;
|
|
50
|
+
requestAnimationFrame?(callback: () => void): number;
|
|
51
|
+
cancelAnimationFrame?(frame: number): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface WebAnchorSnapshot {
|
|
55
|
+
id: string;
|
|
56
|
+
top: number;
|
|
57
|
+
scrollHeight: number;
|
|
58
|
+
scrollTop: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface WebPrependScrollToOffsetOptions {
|
|
62
|
+
offset: number;
|
|
63
|
+
animated?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface WebPrependAnchorListHandle {
|
|
67
|
+
getScrollableNode(): unknown;
|
|
68
|
+
scrollToOffset(options: WebPrependScrollToOffsetOptions): void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface WebPrependAnchorConnection {
|
|
72
|
+
list: WebPrependAnchorListHandle;
|
|
73
|
+
scroller: WebElementLike;
|
|
74
|
+
mutationObserver?: WebObserverLike;
|
|
75
|
+
resizeObserver?: WebObserverLike;
|
|
76
|
+
resizeTargets: Set<WebElementLike>;
|
|
77
|
+
userInteraction(): void;
|
|
78
|
+
scroll(): void;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface UseWebPrependAnchorOptions {
|
|
82
|
+
listRef: RefObject<WebPrependAnchorListHandle | null>;
|
|
83
|
+
itemsIdentity: unknown;
|
|
84
|
+
keys: readonly string[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface WebPrependAnchorHandle {
|
|
88
|
+
rowNativeIDPrefix: string;
|
|
89
|
+
getRowNativeID(key: string): string;
|
|
90
|
+
preservingPrependRef: RefObject<boolean>;
|
|
91
|
+
cancelPrependPreservation(): void;
|
|
92
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useCallback, useId, useRef } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
UseWebPrependAnchorOptions,
|
|
4
|
+
WebPrependAnchorHandle,
|
|
5
|
+
} from './types';
|
|
6
|
+
|
|
7
|
+
export function useWebPrependAnchor(
|
|
8
|
+
_options: UseWebPrependAnchorOptions
|
|
9
|
+
): WebPrependAnchorHandle {
|
|
10
|
+
const instanceId = useId();
|
|
11
|
+
const rowNativeIDPrefix = `unif-message-row-${encodeURIComponent(instanceId)}`;
|
|
12
|
+
const preservingPrependRef = useRef(false);
|
|
13
|
+
const getRowNativeID = useCallback(
|
|
14
|
+
(key: string) => `${rowNativeIDPrefix}-${encodeURIComponent(key)}`,
|
|
15
|
+
[rowNativeIDPrefix]
|
|
16
|
+
);
|
|
17
|
+
const cancelPrependPreservation = useCallback(() => {
|
|
18
|
+
preservingPrependRef.current = false;
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
rowNativeIDPrefix,
|
|
23
|
+
getRowNativeID,
|
|
24
|
+
preservingPrependRef,
|
|
25
|
+
cancelPrependPreservation,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { useId, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { USER_INTERACTION_EVENTS } from './constants';
|
|
4
|
+
import type {
|
|
5
|
+
UseWebPrependAnchorOptions,
|
|
6
|
+
WebAnchorSnapshot,
|
|
7
|
+
WebElementLike,
|
|
8
|
+
WebGlobals,
|
|
9
|
+
WebPrependAnchorHandle,
|
|
10
|
+
WebPrependAnchorConnection,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
function isWebElementLike(value: unknown): value is WebElementLike {
|
|
14
|
+
if (!value || typeof value !== 'object') return false;
|
|
15
|
+
const candidate = value as Partial<WebElementLike>;
|
|
16
|
+
return (
|
|
17
|
+
typeof candidate.scrollTop === 'number' &&
|
|
18
|
+
typeof candidate.scrollHeight === 'number' &&
|
|
19
|
+
typeof candidate.getBoundingClientRect === 'function' &&
|
|
20
|
+
typeof candidate.querySelectorAll === 'function' &&
|
|
21
|
+
typeof candidate.contains === 'function' &&
|
|
22
|
+
typeof candidate.addEventListener === 'function' &&
|
|
23
|
+
typeof candidate.removeEventListener === 'function'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function sameKeys(left: readonly string[], right: readonly string[]): boolean {
|
|
28
|
+
return (
|
|
29
|
+
left.length === right.length &&
|
|
30
|
+
left.every((key, index) => key === right[index])
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function isPurePrepend(
|
|
35
|
+
previous: readonly string[],
|
|
36
|
+
current: readonly string[]
|
|
37
|
+
): boolean {
|
|
38
|
+
const added = current.length - previous.length;
|
|
39
|
+
return (
|
|
40
|
+
previous.length > 0 &&
|
|
41
|
+
added > 0 &&
|
|
42
|
+
previous.every((key, index) => current[index + added] === key)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function disconnectConnection(
|
|
47
|
+
connection: WebPrependAnchorConnection | undefined
|
|
48
|
+
) {
|
|
49
|
+
if (!connection) return;
|
|
50
|
+
connection.mutationObserver?.disconnect();
|
|
51
|
+
connection.resizeObserver?.disconnect();
|
|
52
|
+
connection.resizeTargets.clear();
|
|
53
|
+
USER_INTERACTION_EVENTS.forEach((eventName) =>
|
|
54
|
+
connection.scroller.removeEventListener(
|
|
55
|
+
eventName,
|
|
56
|
+
connection.userInteraction,
|
|
57
|
+
{ capture: true }
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
connection.scroller.removeEventListener('scroll', connection.scroll);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function useWebPrependAnchor({
|
|
64
|
+
listRef,
|
|
65
|
+
itemsIdentity,
|
|
66
|
+
keys,
|
|
67
|
+
}: UseWebPrependAnchorOptions): WebPrependAnchorHandle {
|
|
68
|
+
const instanceId = useId();
|
|
69
|
+
const rowNativeIDPrefix = `unif-message-row-${encodeURIComponent(instanceId)}`;
|
|
70
|
+
const preservingPrependRef = useRef(false);
|
|
71
|
+
const previousIdentityRef = useRef<unknown>(itemsIdentity);
|
|
72
|
+
const previousKeysRef = useRef<readonly string[] | undefined>(undefined);
|
|
73
|
+
const lastAnchorRef = useRef<WebAnchorSnapshot | undefined>(undefined);
|
|
74
|
+
const preservationRef = useRef<WebAnchorSnapshot | undefined>(undefined);
|
|
75
|
+
const connectionRef = useRef<WebPrependAnchorConnection | undefined>(
|
|
76
|
+
undefined
|
|
77
|
+
);
|
|
78
|
+
const frameRef = useRef<number | undefined>(undefined);
|
|
79
|
+
|
|
80
|
+
const globals = globalThis as unknown as WebGlobals;
|
|
81
|
+
|
|
82
|
+
const getRowNativeID = (key: string) =>
|
|
83
|
+
`${rowNativeIDPrefix}-${encodeURIComponent(key)}`;
|
|
84
|
+
|
|
85
|
+
const getRows = (scroller: WebElementLike): WebElementLike[] =>
|
|
86
|
+
Array.from(scroller.querySelectorAll('[id]')).filter(
|
|
87
|
+
(candidate): candidate is WebElementLike =>
|
|
88
|
+
isWebElementLike(candidate) &&
|
|
89
|
+
candidate.id.startsWith(`${rowNativeIDPrefix}-`)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const findRow = (
|
|
93
|
+
scroller: WebElementLike,
|
|
94
|
+
id: string
|
|
95
|
+
): WebElementLike | undefined => {
|
|
96
|
+
const candidate = globals.document?.getElementById(id);
|
|
97
|
+
return isWebElementLike(candidate) && scroller.contains(candidate)
|
|
98
|
+
? candidate
|
|
99
|
+
: undefined;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const captureAnchor = (connection: WebPrependAnchorConnection) => {
|
|
103
|
+
const viewport = connection.scroller.getBoundingClientRect();
|
|
104
|
+
const firstVisible = getRows(connection.scroller).find((row) => {
|
|
105
|
+
const rect = row.getBoundingClientRect();
|
|
106
|
+
return rect.bottom > viewport.top && rect.top < viewport.bottom;
|
|
107
|
+
});
|
|
108
|
+
if (!firstVisible) return;
|
|
109
|
+
lastAnchorRef.current = {
|
|
110
|
+
id: firstVisible.id,
|
|
111
|
+
top: firstVisible.getBoundingClientRect().top - viewport.top,
|
|
112
|
+
scrollHeight: connection.scroller.scrollHeight,
|
|
113
|
+
scrollTop: connection.scroller.scrollTop,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const refreshResizeTargets = (connection: WebPrependAnchorConnection) => {
|
|
118
|
+
const resizeObserver = connection.resizeObserver;
|
|
119
|
+
if (!resizeObserver) return;
|
|
120
|
+
const nextTargets = new Set([
|
|
121
|
+
connection.scroller,
|
|
122
|
+
...getRows(connection.scroller),
|
|
123
|
+
]);
|
|
124
|
+
connection.resizeTargets.forEach((target) => {
|
|
125
|
+
if (!nextTargets.has(target)) resizeObserver.unobserve?.(target);
|
|
126
|
+
});
|
|
127
|
+
nextTargets.forEach((target) => {
|
|
128
|
+
if (!connection.resizeTargets.has(target)) resizeObserver.observe(target);
|
|
129
|
+
});
|
|
130
|
+
connection.resizeTargets = nextTargets;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const correctPrepend = (connection: WebPrependAnchorConnection) => {
|
|
134
|
+
const preservation = preservationRef.current;
|
|
135
|
+
if (!preservation) return;
|
|
136
|
+
const anchor = findRow(connection.scroller, preservation.id);
|
|
137
|
+
if (anchor) {
|
|
138
|
+
const viewport = connection.scroller.getBoundingClientRect();
|
|
139
|
+
const currentTop = anchor.getBoundingClientRect().top - viewport.top;
|
|
140
|
+
const delta = currentTop - preservation.top;
|
|
141
|
+
if (Math.abs(delta) > 0.5) {
|
|
142
|
+
connection.list.scrollToOffset({
|
|
143
|
+
offset: Math.max(0, connection.scroller.scrollTop + delta),
|
|
144
|
+
animated: false,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const heightDelta = Math.max(
|
|
151
|
+
0,
|
|
152
|
+
connection.scroller.scrollHeight - preservation.scrollHeight
|
|
153
|
+
);
|
|
154
|
+
if (heightDelta > 0) {
|
|
155
|
+
connection.list.scrollToOffset({
|
|
156
|
+
offset: Math.max(0, preservation.scrollTop + heightDelta),
|
|
157
|
+
animated: false,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const runFrame = () => {
|
|
163
|
+
frameRef.current = undefined;
|
|
164
|
+
const connection = connectionRef.current;
|
|
165
|
+
if (!connection) return;
|
|
166
|
+
refreshResizeTargets(connection);
|
|
167
|
+
if (preservingPrependRef.current) correctPrepend(connection);
|
|
168
|
+
else captureAnchor(connection);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const scheduleFrame = () => {
|
|
172
|
+
if (frameRef.current !== undefined) return;
|
|
173
|
+
if (globals.requestAnimationFrame) {
|
|
174
|
+
frameRef.current = globals.requestAnimationFrame(runFrame);
|
|
175
|
+
} else {
|
|
176
|
+
runFrame();
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const stopPreserving = () => {
|
|
181
|
+
preservingPrependRef.current = false;
|
|
182
|
+
preservationRef.current = undefined;
|
|
183
|
+
lastAnchorRef.current = undefined;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const disconnect = () => {
|
|
187
|
+
const connection = connectionRef.current;
|
|
188
|
+
disconnectConnection(connection);
|
|
189
|
+
connectionRef.current = undefined;
|
|
190
|
+
if (frameRef.current !== undefined) {
|
|
191
|
+
globals.cancelAnimationFrame?.(frameRef.current);
|
|
192
|
+
frameRef.current = undefined;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const ensureConnected = () => {
|
|
197
|
+
if (Platform.OS !== 'web') return;
|
|
198
|
+
const list = listRef.current;
|
|
199
|
+
const scroller = list ? list.getScrollableNode() : undefined;
|
|
200
|
+
if (!list || !isWebElementLike(scroller)) {
|
|
201
|
+
disconnect();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (connectionRef.current?.scroller === scroller) return;
|
|
205
|
+
disconnect();
|
|
206
|
+
stopPreserving();
|
|
207
|
+
|
|
208
|
+
const userInteraction = () => {
|
|
209
|
+
stopPreserving();
|
|
210
|
+
const currentConnection = connectionRef.current;
|
|
211
|
+
if (currentConnection) captureAnchor(currentConnection);
|
|
212
|
+
scheduleFrame();
|
|
213
|
+
};
|
|
214
|
+
const scroll = () => scheduleFrame();
|
|
215
|
+
const mutationObserver = globals.MutationObserver
|
|
216
|
+
? new globals.MutationObserver(scheduleFrame)
|
|
217
|
+
: undefined;
|
|
218
|
+
const resizeObserver = globals.ResizeObserver
|
|
219
|
+
? new globals.ResizeObserver(scheduleFrame)
|
|
220
|
+
: undefined;
|
|
221
|
+
const connection: WebPrependAnchorConnection = {
|
|
222
|
+
list,
|
|
223
|
+
scroller,
|
|
224
|
+
mutationObserver,
|
|
225
|
+
resizeObserver,
|
|
226
|
+
resizeTargets: new Set(),
|
|
227
|
+
userInteraction,
|
|
228
|
+
scroll,
|
|
229
|
+
};
|
|
230
|
+
connectionRef.current = connection;
|
|
231
|
+
mutationObserver?.observe(scroller, {
|
|
232
|
+
childList: true,
|
|
233
|
+
subtree: true,
|
|
234
|
+
});
|
|
235
|
+
USER_INTERACTION_EVENTS.forEach((eventName) =>
|
|
236
|
+
scroller.addEventListener(eventName, userInteraction, {
|
|
237
|
+
capture: true,
|
|
238
|
+
passive: eventName === 'wheel' || eventName === 'touchstart',
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
scroller.addEventListener('scroll', scroll, { passive: true });
|
|
242
|
+
refreshResizeTargets(connection);
|
|
243
|
+
scheduleFrame();
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const cancelPrependPreservation = () => {
|
|
247
|
+
stopPreserving();
|
|
248
|
+
scheduleFrame();
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
useLayoutEffect(() => {
|
|
252
|
+
ensureConnected();
|
|
253
|
+
const previousKeys = previousKeysRef.current;
|
|
254
|
+
const identityChanged = previousIdentityRef.current !== itemsIdentity;
|
|
255
|
+
if (previousKeys) {
|
|
256
|
+
const keysChanged = !sameKeys(previousKeys, keys);
|
|
257
|
+
if (
|
|
258
|
+
keysChanged &&
|
|
259
|
+
isPurePrepend(previousKeys, keys) &&
|
|
260
|
+
lastAnchorRef.current
|
|
261
|
+
) {
|
|
262
|
+
preservationRef.current = lastAnchorRef.current;
|
|
263
|
+
preservingPrependRef.current = true;
|
|
264
|
+
} else if (keysChanged || identityChanged) {
|
|
265
|
+
stopPreserving();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
previousIdentityRef.current = itemsIdentity;
|
|
269
|
+
previousKeysRef.current = [...keys];
|
|
270
|
+
scheduleFrame();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
useLayoutEffect(
|
|
274
|
+
() => () => {
|
|
275
|
+
disconnectConnection(connectionRef.current);
|
|
276
|
+
connectionRef.current = undefined;
|
|
277
|
+
if (frameRef.current !== undefined) {
|
|
278
|
+
(globalThis as unknown as WebGlobals).cancelAnimationFrame?.(
|
|
279
|
+
frameRef.current
|
|
280
|
+
);
|
|
281
|
+
frameRef.current = undefined;
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
[]
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
rowNativeIDPrefix,
|
|
289
|
+
getRowNativeID,
|
|
290
|
+
preservingPrependRef,
|
|
291
|
+
cancelPrependPreservation,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Icon,
|
|
6
|
+
useColors,
|
|
7
|
+
useThemedStyles,
|
|
8
|
+
} from '@unif/react-native-design';
|
|
9
|
+
import { PROCESS_STATUS_ICONS, PROCESS_STATUS_LABELS } from './constants';
|
|
10
|
+
import { createStyles } from './styles';
|
|
11
|
+
import type { ProcessProps, ProcessStep } from './types';
|
|
12
|
+
|
|
13
|
+
function idsWithDetails(
|
|
14
|
+
ids: readonly string[],
|
|
15
|
+
steps: readonly ProcessStep[]
|
|
16
|
+
): readonly string[] {
|
|
17
|
+
const availableIds = new Set(
|
|
18
|
+
steps.filter((step) => step.details != null).map((step) => step.id)
|
|
19
|
+
);
|
|
20
|
+
return ids.filter((id) => availableIds.has(id));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function formatElapsedMs(elapsedMs: number | undefined): string | undefined {
|
|
24
|
+
if (elapsedMs === undefined || !Number.isFinite(elapsedMs) || elapsedMs < 0) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (elapsedMs < 1000) return `${Math.round(elapsedMs)} 毫秒`;
|
|
28
|
+
|
|
29
|
+
const roundedSeconds = Math.round(elapsedMs / 100) / 10;
|
|
30
|
+
if (roundedSeconds < 60) {
|
|
31
|
+
const formatted = Number.isInteger(roundedSeconds)
|
|
32
|
+
? String(roundedSeconds)
|
|
33
|
+
: roundedSeconds.toFixed(1);
|
|
34
|
+
return `${formatted} 秒`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const totalSeconds = Math.round(elapsedMs / 1000);
|
|
38
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
39
|
+
const remainingSeconds = totalSeconds % 60;
|
|
40
|
+
return remainingSeconds === 0
|
|
41
|
+
? `${minutes} 分钟`
|
|
42
|
+
: `${minutes} 分 ${remainingSeconds} 秒`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function Process(props: ProcessProps): React.JSX.Element {
|
|
46
|
+
const { steps, title, identity, style, testID } = props;
|
|
47
|
+
const styles = useThemedStyles(createStyles);
|
|
48
|
+
const colors = useColors();
|
|
49
|
+
const isControlled = props.expandedIds !== undefined;
|
|
50
|
+
const [localExpandedIds, setLocalExpandedIds] = useState<readonly string[]>(
|
|
51
|
+
() => idsWithDetails(props.defaultExpandedIds ?? [], steps)
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!isControlled) {
|
|
56
|
+
setLocalExpandedIds((current) => idsWithDetails(current, steps));
|
|
57
|
+
}
|
|
58
|
+
}, [isControlled, steps]);
|
|
59
|
+
|
|
60
|
+
const expandedIds = idsWithDetails(
|
|
61
|
+
isControlled ? props.expandedIds : localExpandedIds,
|
|
62
|
+
steps
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const toggleDetails = (stepId: string) => {
|
|
66
|
+
const nextIds = expandedIds.includes(stepId)
|
|
67
|
+
? expandedIds.filter((id) => id !== stepId)
|
|
68
|
+
: [...expandedIds, stepId];
|
|
69
|
+
if (!isControlled) setLocalExpandedIds(nextIds);
|
|
70
|
+
props.onExpandedChange?.(nextIds);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View style={[styles.root, style]} testID={testID}>
|
|
75
|
+
{title || identity ? (
|
|
76
|
+
<View style={styles.heading}>
|
|
77
|
+
{identity}
|
|
78
|
+
{title ? <Text style={styles.headingTitle}>{title}</Text> : null}
|
|
79
|
+
</View>
|
|
80
|
+
) : null}
|
|
81
|
+
<View style={styles.steps}>
|
|
82
|
+
{steps.map((step, index) => {
|
|
83
|
+
const statusLabel = PROCESS_STATUS_LABELS[step.status];
|
|
84
|
+
const elapsed = formatElapsedMs(step.elapsedMs);
|
|
85
|
+
const isExpanded = expandedIds.includes(step.id);
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
key={step.id}
|
|
89
|
+
style={[
|
|
90
|
+
styles.step,
|
|
91
|
+
index === steps.length - 1 && styles.stepLast,
|
|
92
|
+
]}
|
|
93
|
+
>
|
|
94
|
+
<View style={styles.stepHeader}>
|
|
95
|
+
<Text
|
|
96
|
+
style={styles.stepTitle}
|
|
97
|
+
testID={`process-step-title-${step.id}`}
|
|
98
|
+
>
|
|
99
|
+
{step.title}
|
|
100
|
+
</Text>
|
|
101
|
+
<View
|
|
102
|
+
style={styles.status}
|
|
103
|
+
accessible
|
|
104
|
+
accessibilityLabel={`${step.title},${statusLabel}`}
|
|
105
|
+
>
|
|
106
|
+
<Icon
|
|
107
|
+
name={PROCESS_STATUS_ICONS[step.status]}
|
|
108
|
+
color={
|
|
109
|
+
step.status === 'failed'
|
|
110
|
+
? colors.error
|
|
111
|
+
: step.status === 'completed'
|
|
112
|
+
? colors.success
|
|
113
|
+
: colors.foregroundMuted
|
|
114
|
+
}
|
|
115
|
+
/>
|
|
116
|
+
<Text style={styles.statusText}>{statusLabel}</Text>
|
|
117
|
+
</View>
|
|
118
|
+
</View>
|
|
119
|
+
{step.description ? (
|
|
120
|
+
<Text style={styles.description}>{step.description}</Text>
|
|
121
|
+
) : null}
|
|
122
|
+
{elapsed ? <Text style={styles.elapsed}>{elapsed}</Text> : null}
|
|
123
|
+
{step.details != null ? (
|
|
124
|
+
<>
|
|
125
|
+
<Button
|
|
126
|
+
label={isExpanded ? '收起详情' : '展开详情'}
|
|
127
|
+
onPress={() => toggleDetails(step.id)}
|
|
128
|
+
size="sm"
|
|
129
|
+
variant="text"
|
|
130
|
+
testID={`process-step-${step.id}-toggle`}
|
|
131
|
+
/>
|
|
132
|
+
{isExpanded ? (
|
|
133
|
+
<View style={styles.details}>{step.details}</View>
|
|
134
|
+
) : null}
|
|
135
|
+
</>
|
|
136
|
+
) : null}
|
|
137
|
+
{step.actions && step.actions.length > 0 ? (
|
|
138
|
+
<View style={styles.actions}>
|
|
139
|
+
{step.actions.map((action) => (
|
|
140
|
+
<Button
|
|
141
|
+
key={action.id}
|
|
142
|
+
label={action.label}
|
|
143
|
+
leftIcon={action.icon}
|
|
144
|
+
onPress={action.onPress}
|
|
145
|
+
disabled={action.disabled}
|
|
146
|
+
loading={action.loading}
|
|
147
|
+
accessibilityHint={action.accessibilityHint}
|
|
148
|
+
size="sm"
|
|
149
|
+
variant="outline"
|
|
150
|
+
/>
|
|
151
|
+
))}
|
|
152
|
+
</View>
|
|
153
|
+
) : null}
|
|
154
|
+
</View>
|
|
155
|
+
);
|
|
156
|
+
})}
|
|
157
|
+
</View>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IconName } from '@unif/react-native-design';
|
|
2
|
+
import type { ProcessStepStatus } from './types';
|
|
3
|
+
|
|
4
|
+
export const PROCESS_STATUS_LABELS: Readonly<
|
|
5
|
+
Record<ProcessStepStatus, string>
|
|
6
|
+
> = {
|
|
7
|
+
pending: '待处理',
|
|
8
|
+
running: '处理中',
|
|
9
|
+
completed: '已完成',
|
|
10
|
+
failed: '失败',
|
|
11
|
+
cancelled: '已取消',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const PROCESS_STATUS_ICONS: Readonly<
|
|
15
|
+
Record<ProcessStepStatus, IconName>
|
|
16
|
+
> = {
|
|
17
|
+
pending: 'circle-minus',
|
|
18
|
+
running: 'thinking',
|
|
19
|
+
completed: 'success',
|
|
20
|
+
failed: 'error',
|
|
21
|
+
cancelled: 'close',
|
|
22
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { fw, radius, space, type } from '@unif/react-native-design';
|
|
3
|
+
import type { ColorTokens } from '@unif/react-native-design';
|
|
4
|
+
|
|
5
|
+
export const createStyles = (colors: ColorTokens) =>
|
|
6
|
+
StyleSheet.create({
|
|
7
|
+
root: {
|
|
8
|
+
gap: space[4],
|
|
9
|
+
padding: space[5],
|
|
10
|
+
borderRadius: radius.xl,
|
|
11
|
+
borderWidth: 1,
|
|
12
|
+
borderColor: colors.outline,
|
|
13
|
+
backgroundColor: colors.surface,
|
|
14
|
+
},
|
|
15
|
+
heading: {
|
|
16
|
+
flexDirection: 'row',
|
|
17
|
+
alignItems: 'center',
|
|
18
|
+
gap: space[3],
|
|
19
|
+
},
|
|
20
|
+
headingTitle: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
color: colors.foreground,
|
|
23
|
+
fontSize: type.h3,
|
|
24
|
+
fontWeight: fw.semi,
|
|
25
|
+
},
|
|
26
|
+
steps: {
|
|
27
|
+
gap: space[4],
|
|
28
|
+
},
|
|
29
|
+
step: {
|
|
30
|
+
gap: space[2],
|
|
31
|
+
paddingBottom: space[4],
|
|
32
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
33
|
+
borderBottomColor: colors.outline,
|
|
34
|
+
},
|
|
35
|
+
stepLast: {
|
|
36
|
+
paddingBottom: 0,
|
|
37
|
+
borderBottomWidth: 0,
|
|
38
|
+
},
|
|
39
|
+
stepHeader: {
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
gap: space[3],
|
|
43
|
+
},
|
|
44
|
+
stepTitle: {
|
|
45
|
+
flex: 1,
|
|
46
|
+
color: colors.foreground,
|
|
47
|
+
fontSize: type.sm,
|
|
48
|
+
fontWeight: fw.medium,
|
|
49
|
+
},
|
|
50
|
+
status: {
|
|
51
|
+
flexDirection: 'row',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
gap: space[1],
|
|
54
|
+
},
|
|
55
|
+
statusText: {
|
|
56
|
+
color: colors.foregroundMuted,
|
|
57
|
+
fontSize: type.xxs,
|
|
58
|
+
},
|
|
59
|
+
description: {
|
|
60
|
+
color: colors.foregroundMuted,
|
|
61
|
+
fontSize: type.sm,
|
|
62
|
+
},
|
|
63
|
+
elapsed: {
|
|
64
|
+
color: colors.foregroundSubtle,
|
|
65
|
+
fontSize: type.xxs,
|
|
66
|
+
},
|
|
67
|
+
details: {
|
|
68
|
+
padding: space[4],
|
|
69
|
+
borderRadius: radius.md,
|
|
70
|
+
backgroundColor: colors.surfaceContainer,
|
|
71
|
+
},
|
|
72
|
+
actions: {
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
flexWrap: 'wrap',
|
|
75
|
+
gap: space[3],
|
|
76
|
+
},
|
|
77
|
+
});
|