@app-studio/components 0.10.18 → 0.10.20
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/dist/fonts/mulish-subset.woff2 +0 -0
- package/dist/illustrations/cross-platform.svg +37 -0
- package/dist/index.d.ts +276 -6
- package/dist/native/components/Accordion/Accordion/Accordion.view.native.js +72 -8
- package/dist/native/components/Accordion/Accordion/Accordion.view.native.js.map +1 -1
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.props.d.ts +36 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.props.js +2 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.props.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.state.d.ts +8 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.state.js +33 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.state.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.style.d.ts +17 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.style.js +39 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.style.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.type.d.ts +37 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.type.js +2 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.type.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.d.ts +4 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js +122 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.d.ts +4 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js +173 -0
- package/dist/native/components/ActionSheet/ActionSheet/ActionSheet.view.native.js.map +1 -0
- package/dist/native/components/ActionSheet/ActionSheet.d.ts +3 -0
- package/dist/native/components/ActionSheet/ActionSheet.js +9 -0
- package/dist/native/components/ActionSheet/ActionSheet.js.map +1 -0
- package/dist/native/components/ActionSheet/index.d.ts +3 -0
- package/dist/native/components/ActionSheet/index.js +4 -0
- package/dist/native/components/ActionSheet/index.js.map +1 -0
- package/dist/native/components/AppRoot/AppRoot.d.ts +17 -0
- package/dist/native/components/AppRoot/AppRoot.js +25 -0
- package/dist/native/components/AppRoot/AppRoot.js.map +1 -0
- package/dist/native/components/AppRoot/AppRoot.native.d.ts +9 -0
- package/dist/native/components/AppRoot/AppRoot.native.js +33 -0
- package/dist/native/components/AppRoot/AppRoot.native.js.map +1 -0
- package/dist/native/components/AppRoot/AppRoot.types.d.ts +22 -0
- package/dist/native/components/AppRoot/AppRoot.types.js +2 -0
- package/dist/native/components/AppRoot/AppRoot.types.js.map +1 -0
- package/dist/native/components/AppRoot/index.d.ts +2 -0
- package/dist/native/components/AppRoot/index.js +2 -0
- package/dist/native/components/AppRoot/index.js.map +1 -0
- package/dist/native/components/AttachmentGroup/AttachmentGroup/AttachmentGroup.js +8 -1
- package/dist/native/components/AttachmentGroup/AttachmentGroup/AttachmentGroup.js.map +1 -1
- package/dist/native/components/AudioInput/AudioInput/AudioInput.state.d.ts +1 -1
- package/dist/native/components/AudioInput/AudioInput/AudioInput.view.js +1 -1
- package/dist/native/components/AudioInput/AudioInput/AudioInput.view.js.map +1 -1
- package/dist/native/components/AudioInput/useAudioRecording.native.d.ts +25 -0
- package/dist/native/components/AudioInput/useAudioRecording.native.js +96 -0
- package/dist/native/components/AudioInput/useAudioRecording.native.js.map +1 -0
- package/dist/native/components/Background/Background/Background.view.native.js +279 -24
- package/dist/native/components/Background/Background/Background.view.native.js.map +1 -1
- package/dist/native/components/Badge/Badge/Badge.view.js +4 -0
- package/dist/native/components/Badge/Badge/Badge.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.js +4 -1
- package/dist/native/components/Button/Button/Button.view.js.map +1 -1
- package/dist/native/components/Button/Button/Button.view.native.js +13 -4
- package/dist/native/components/Button/Button/Button.view.native.js.map +1 -1
- package/dist/native/components/Carousel/Carousel/Carousel.view.native.js +32 -5
- package/dist/native/components/Carousel/Carousel/Carousel.view.native.js.map +1 -1
- package/dist/native/components/Chart/Chart/BarChart.native.d.ts +15 -0
- package/dist/native/components/Chart/Chart/BarChart.native.js +47 -0
- package/dist/native/components/Chart/Chart/BarChart.native.js.map +1 -0
- package/dist/native/components/Chart/Chart/ChartTooltip.js +6 -0
- package/dist/native/components/Chart/Chart/ChartTooltip.js.map +1 -1
- package/dist/native/components/Chart/Chart/LineChart.native.d.ts +15 -0
- package/dist/native/components/Chart/Chart/LineChart.native.js +44 -0
- package/dist/native/components/Chart/Chart/LineChart.native.js.map +1 -0
- package/dist/native/components/Chart/Chart/PieChart.native.d.ts +15 -0
- package/dist/native/components/Chart/Chart/PieChart.native.js +231 -0
- package/dist/native/components/Chart/Chart/PieChart.native.js.map +1 -0
- package/dist/native/components/ChatInput/EditableInput.native.d.ts +48 -0
- package/dist/native/components/ChatInput/EditableInput.native.js +122 -0
- package/dist/native/components/ChatInput/EditableInput.native.js.map +1 -0
- package/dist/native/components/ChatInput/MessageInput.native.d.ts +46 -0
- package/dist/native/components/ChatInput/MessageInput.native.js +55 -0
- package/dist/native/components/ChatInput/MessageInput.native.js.map +1 -0
- package/dist/native/components/ChatWidget/ChatWidget/ChatWidget.view.native.d.ts +14 -0
- package/dist/native/components/ChatWidget/ChatWidget/ChatWidget.view.native.js +89 -0
- package/dist/native/components/ChatWidget/ChatWidget/ChatWidget.view.native.js.map +1 -0
- package/dist/native/components/ChatWidget/Widget/ChatWidgetWidget.native.d.ts +18 -0
- package/dist/native/components/ChatWidget/Widget/ChatWidgetWidget.native.js +91 -0
- package/dist/native/components/ChatWidget/Widget/ChatWidgetWidget.native.js.map +1 -0
- package/dist/native/components/ChatWidget/Widget/useContextSelector.js +3 -0
- package/dist/native/components/ChatWidget/Widget/useContextSelector.js.map +1 -1
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.state.js +10 -2
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.state.js.map +1 -1
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.style.js +5 -0
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.style.js.map +1 -1
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.view.js +20 -13
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.view.js.map +1 -1
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.view.native.d.ts +4 -0
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.view.native.js +88 -0
- package/dist/native/components/ColorPicker/ColorPicker/ColorPicker.view.native.js.map +1 -0
- package/dist/native/components/Command/Command/Command.state.js +13 -3
- package/dist/native/components/Command/Command/Command.state.js.map +1 -1
- package/dist/native/components/Command/Command/Command.view.js +6 -4
- package/dist/native/components/Command/Command/Command.view.js.map +1 -1
- package/dist/native/components/Command/Command/Command.view.native.d.ts +31 -0
- package/dist/native/components/Command/Command/Command.view.native.js +184 -0
- package/dist/native/components/Command/Command/Command.view.native.js.map +1 -0
- package/dist/native/components/Command/Command/CommandOverlay.d.ts +10 -0
- package/dist/native/components/Command/Command/CommandOverlay.js +13 -0
- package/dist/native/components/Command/Command/CommandOverlay.js.map +1 -0
- package/dist/native/components/Command/Command/CommandOverlay.native.d.ts +12 -0
- package/dist/native/components/Command/Command/CommandOverlay.native.js +12 -0
- package/dist/native/components/Command/Command/CommandOverlay.native.js.map +1 -0
- package/dist/native/components/Command/Command/CommandTextInput.d.ts +8 -0
- package/dist/native/components/Command/Command/CommandTextInput.js +7 -0
- package/dist/native/components/Command/Command/CommandTextInput.js.map +1 -0
- package/dist/native/components/Command/Command/CommandTextInput.native.d.ts +13 -0
- package/dist/native/components/Command/Command/CommandTextInput.native.js +27 -0
- package/dist/native/components/Command/Command/CommandTextInput.native.js.map +1 -0
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.props.d.ts +1 -0
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.state.js +8 -0
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.state.js.map +1 -1
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.d.ts +3 -1
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js +38 -22
- package/dist/native/components/ContextMenu/ContextMenu/ContextMenu.view.native.js.map +1 -1
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.state.js +12 -6
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.state.js.map +1 -1
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.style.js +8 -8
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.style.js.map +1 -1
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.view.js +1 -1
- package/dist/native/components/CookieConsent/CookieConsent/CookieConsent.view.js.map +1 -1
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.state.js +4 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.state.js.map +1 -1
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.state.native.d.ts +18 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.state.native.js +23 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.state.native.js.map +1 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.view.native.d.ts +17 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.view.native.js +49 -0
- package/dist/native/components/DragAndDrop/DragAndDrop/DragAndDrop.view.native.js.map +1 -0
- package/dist/native/components/Drawer/Drawer/Drawer.view.native.js +54 -14
- package/dist/native/components/Drawer/Drawer/Drawer.view.native.js.map +1 -1
- package/dist/native/components/DropZone/DropZone/DropZone.view.native.d.ts +14 -0
- package/dist/native/components/DropZone/DropZone/DropZone.view.native.js +33 -0
- package/dist/native/components/DropZone/DropZone/DropZone.view.native.js.map +1 -0
- package/dist/native/components/DropdownMenu/DropdownMenu/DropdownMenu.state.js +7 -0
- package/dist/native/components/DropdownMenu/DropdownMenu/DropdownMenu.state.js.map +1 -1
- package/dist/native/components/DropdownMenu/DropdownMenu/DropdownMenu.view.native.js +20 -16
- package/dist/native/components/DropdownMenu/DropdownMenu/DropdownMenu.view.native.js.map +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.state.js +6 -2
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.state.js.map +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.style.js +9 -0
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.style.js.map +1 -1
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.d.ts +4 -0
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js +108 -0
- package/dist/native/components/EmojiPicker/EmojiPicker/EmojiPicker.view.native.js.map +1 -0
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.state.js +11 -4
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.state.js.map +1 -1
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.d.ts +4 -0
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js +92 -0
- package/dist/native/components/Form/ColorInput/ColorInput/ColorInput.view.native.js.map +1 -0
- package/dist/native/components/Form/ComboBox/ComboBox/ComboBox.view.native.d.ts +13 -0
- package/dist/native/components/Form/ComboBox/ComboBox/ComboBox.view.native.js +118 -0
- package/dist/native/components/Form/ComboBox/ComboBox/ComboBox.view.native.js.map +1 -0
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.native.d.ts +3 -0
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.native.js +88 -0
- package/dist/native/components/Form/CountryPicker/CountryPicker/CountryPicker.view.native.js.map +1 -0
- package/dist/native/components/Form/Password/Password/Password.state.d.ts +26 -0
- package/dist/native/components/Form/Select/Select/Select.view.native.d.ts +2 -2
- package/dist/native/components/Form/Select/Select/Select.view.native.js +19 -33
- package/dist/native/components/Form/Select/Select/Select.view.native.js.map +1 -1
- package/dist/native/components/Form/Selector/Selector/Selector.view.native.d.ts +12 -0
- package/dist/native/components/Form/Selector/Selector/Selector.view.native.js +44 -0
- package/dist/native/components/Form/Selector/Selector/Selector.view.native.js.map +1 -0
- package/dist/native/components/Form/Switch/Switch/Switch.view.js +2 -2
- package/dist/native/components/Form/Switch/Switch/Switch.view.js.map +1 -1
- package/dist/native/components/Form/TextArea/TextArea/TextArea.props.d.ts +3 -0
- package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js +2 -2
- package/dist/native/components/Form/TextArea/TextArea/TextArea.view.js.map +1 -1
- package/dist/native/components/Form/TextField/TextField/TextField.props.d.ts +3 -0
- package/dist/native/components/Form/TextField/TextField/TextField.view.js +2 -2
- package/dist/native/components/Form/TextField/TextField/TextField.view.js.map +1 -1
- package/dist/native/components/Formik/Formik.Form.d.ts +4 -10
- package/dist/native/components/Formik/Formik.Form.js +6 -3
- package/dist/native/components/Formik/Formik.Form.js.map +1 -1
- package/dist/native/components/Formik/Formik.Hook.d.ts +5 -1
- package/dist/native/components/Formik/Formik.Hook.js +27 -3
- package/dist/native/components/Formik/Formik.Hook.js.map +1 -1
- package/dist/native/components/Formik/Formik.OTPInput.js +63 -7
- package/dist/native/components/Formik/Formik.OTPInput.js.map +1 -1
- package/dist/native/components/Formik/Formik.Password.js +1 -1
- package/dist/native/components/Formik/Formik.Password.js.map +1 -1
- package/dist/native/components/Formik/Formik.TextField.js +1 -1
- package/dist/native/components/Formik/Formik.TextField.js.map +1 -1
- package/dist/native/components/Gradient/Gradient/Gradient.view.native.js +83 -11
- package/dist/native/components/Gradient/Gradient/Gradient.view.native.js.map +1 -1
- package/dist/native/components/HoverCard/HoverCard/HoverCard.view.native.js +39 -5
- package/dist/native/components/HoverCard/HoverCard/HoverCard.view.native.js.map +1 -1
- package/dist/native/components/Icon/Icon.native.js +9 -1
- package/dist/native/components/Icon/Icon.native.js.map +1 -1
- package/dist/native/components/IconPicker/IconPicker/IconPicker.state.js +4 -0
- package/dist/native/components/IconPicker/IconPicker/IconPicker.state.js.map +1 -1
- package/dist/native/components/IconPicker/IconPicker/IconPicker.style.js +5 -0
- package/dist/native/components/IconPicker/IconPicker/IconPicker.style.js.map +1 -1
- package/dist/native/components/IconPicker/IconPicker/IconPicker.view.native.d.ts +4 -0
- package/dist/native/components/IconPicker/IconPicker/IconPicker.view.native.js +73 -0
- package/dist/native/components/IconPicker/IconPicker/IconPicker.view.native.js.map +1 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.d.ts +12 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.js +17 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.js.map +1 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.native.d.ts +12 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.native.js +24 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.native.js.map +1 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.types.d.ts +24 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.types.js +2 -0
- package/dist/native/components/KeyboardAvoidingView/KeyboardAvoidingView.types.js.map +1 -0
- package/dist/native/components/KeyboardAvoidingView/index.d.ts +2 -0
- package/dist/native/components/KeyboardAvoidingView/index.js +2 -0
- package/dist/native/components/KeyboardAvoidingView/index.js.map +1 -0
- package/dist/native/components/Menubar/Menubar/Menubar.props.d.ts +4 -1
- package/dist/native/components/Menubar/Menubar/Menubar.state.js +6 -0
- package/dist/native/components/Menubar/Menubar/Menubar.state.js.map +1 -1
- package/dist/native/components/Menubar/Menubar/Menubar.view.native.d.ts +4 -1
- package/dist/native/components/Menubar/Menubar/Menubar.view.native.js +29 -23
- package/dist/native/components/Menubar/Menubar/Menubar.view.native.js.map +1 -1
- package/dist/native/components/Message/Message/Message.layout.native.d.ts +3 -0
- package/dist/native/components/Message/Message/Message.layout.native.js +26 -0
- package/dist/native/components/Message/Message/Message.layout.native.js.map +1 -0
- package/dist/native/components/Modal/Modal/Modal.store.js +0 -1
- package/dist/native/components/Modal/Modal/Modal.store.js.map +1 -1
- package/dist/native/components/Modal/Modal.d.ts +2 -0
- package/dist/native/components/Modal/Modal.js +6 -0
- package/dist/native/components/Modal/Modal.js.map +1 -1
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.d.ts +2 -2
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js +92 -14
- package/dist/native/components/OTPInput/OTPInput/OTPInput.state.js.map +1 -1
- package/dist/native/components/OTPInput/OTPInput/OTPInput.view.native.js +64 -11
- package/dist/native/components/OTPInput/OTPInput/OTPInput.view.native.js.map +1 -1
- package/dist/native/components/OTPInput/OTPInput.js +34 -2
- package/dist/native/components/OTPInput/OTPInput.js.map +1 -1
- package/dist/native/components/PageLayout/PageLayout.d.ts +16 -0
- package/dist/native/components/PageLayout/PageLayout.js +49 -0
- package/dist/native/components/PageLayout/PageLayout.js.map +1 -0
- package/dist/native/components/PageLayout/PageLayout.types.d.ts +30 -0
- package/dist/native/components/PageLayout/PageLayout.types.js +2 -0
- package/dist/native/components/PageLayout/PageLayout.types.js.map +1 -0
- package/dist/native/components/PageLayout/index.d.ts +2 -0
- package/dist/native/components/PageLayout/index.js +2 -0
- package/dist/native/components/PageLayout/index.js.map +1 -0
- package/dist/native/components/Pagination/Pagination/Pagination.view.native.js +12 -1
- package/dist/native/components/Pagination/Pagination/Pagination.view.native.js.map +1 -1
- package/dist/native/components/ProgressBar/ProgressBar/ProgressBar.view.native.js +48 -1
- package/dist/native/components/ProgressBar/ProgressBar/ProgressBar.view.native.js.map +1 -1
- package/dist/native/components/Resizable/Resizable/Resizable.state.js +6 -0
- package/dist/native/components/Resizable/Resizable/Resizable.state.js.map +1 -1
- package/dist/native/components/Router/Router.d.ts +11 -0
- package/dist/native/components/Router/Router.js +51 -0
- package/dist/native/components/Router/Router.js.map +1 -0
- package/dist/native/components/Router/Router.match.d.ts +15 -0
- package/dist/native/components/Router/Router.match.js +45 -0
- package/dist/native/components/Router/Router.match.js.map +1 -0
- package/dist/native/components/Router/Router.native.d.ts +11 -0
- package/dist/native/components/Router/Router.native.js +27 -0
- package/dist/native/components/Router/Router.native.js.map +1 -0
- package/dist/native/components/Router/Router.store.d.ts +28 -0
- package/dist/native/components/Router/Router.store.js +38 -0
- package/dist/native/components/Router/Router.store.js.map +1 -0
- package/dist/native/components/Router/Router.types.d.ts +16 -0
- package/dist/native/components/Router/Router.types.js +2 -0
- package/dist/native/components/Router/Router.types.js.map +1 -0
- package/dist/native/components/Router/index.d.ts +5 -0
- package/dist/native/components/Router/index.js +5 -0
- package/dist/native/components/Router/index.js.map +1 -0
- package/dist/native/components/Router/useHistory.d.ts +21 -0
- package/dist/native/components/Router/useHistory.js +34 -0
- package/dist/native/components/Router/useHistory.js.map +1 -0
- package/dist/native/components/ShareButton/ShareButton/ShareButton.state.native.d.ts +15 -0
- package/dist/native/components/ShareButton/ShareButton/ShareButton.state.native.js +55 -0
- package/dist/native/components/ShareButton/ShareButton/ShareButton.state.native.js.map +1 -0
- package/dist/native/components/Slider/Slider/Slider.state.js +14 -2
- package/dist/native/components/Slider/Slider/Slider.state.js.map +1 -1
- package/dist/native/components/Slider/Slider/Slider.view.native.js +6 -2
- package/dist/native/components/Slider/Slider/Slider.view.native.js.map +1 -1
- package/dist/native/components/SplashScreen/SplashScreen.d.ts +14 -0
- package/dist/native/components/SplashScreen/SplashScreen.js +49 -0
- package/dist/native/components/SplashScreen/SplashScreen.js.map +1 -0
- package/dist/native/components/SplashScreen/SplashScreen.store.d.ts +18 -0
- package/dist/native/components/SplashScreen/SplashScreen.store.js +13 -0
- package/dist/native/components/SplashScreen/SplashScreen.store.js.map +1 -0
- package/dist/native/components/SplashScreen/SplashScreen.types.d.ts +23 -0
- package/dist/native/components/SplashScreen/SplashScreen.types.js +2 -0
- package/dist/native/components/SplashScreen/SplashScreen.types.js.map +1 -0
- package/dist/native/components/SplashScreen/index.d.ts +3 -0
- package/dist/native/components/SplashScreen/index.js +3 -0
- package/dist/native/components/SplashScreen/index.js.map +1 -0
- package/dist/native/components/Table/Table/Table.style.js +10 -0
- package/dist/native/components/Table/Table/Table.style.js.map +1 -1
- package/dist/native/components/Table/Table/Table.view.js +27 -20
- package/dist/native/components/Table/Table/Table.view.js.map +1 -1
- package/dist/native/components/Table/Table/TableScroll.d.ts +8 -0
- package/dist/native/components/Table/Table/TableScroll.js +10 -0
- package/dist/native/components/Table/Table/TableScroll.js.map +1 -0
- package/dist/native/components/Table/Table/TableScroll.native.d.ts +9 -0
- package/dist/native/components/Table/Table/TableScroll.native.js +11 -0
- package/dist/native/components/Table/Table/TableScroll.native.js.map +1 -0
- package/dist/native/components/TextArea/TextArea.native.d.ts +21 -0
- package/dist/native/components/TextArea/TextArea.native.js +15 -0
- package/dist/native/components/TextArea/TextArea.native.js.map +1 -0
- package/dist/native/components/Toast/Toast/Toast.view.native.js +6 -1
- package/dist/native/components/Toast/Toast/Toast.view.native.js.map +1 -1
- package/dist/native/components/Toggle/Toggle/Toggle.view.native.js +11 -3
- package/dist/native/components/Toggle/Toggle/Toggle.view.native.js.map +1 -1
- package/dist/native/components/Tooltip/Tooltip/Tooltip.state.js +3 -0
- package/dist/native/components/Tooltip/Tooltip/Tooltip.state.js.map +1 -1
- package/dist/native/components/Tooltip/Tooltip/Tooltip.view.native.js +84 -7
- package/dist/native/components/Tooltip/Tooltip/Tooltip.view.native.js.map +1 -1
- package/dist/native/components/Uploader/Uploader/Uploader.state.d.ts +1 -1
- package/dist/native/components/Uploader/Uploader/Uploader.state.js +18 -5
- package/dist/native/components/Uploader/Uploader/Uploader.state.js.map +1 -1
- package/dist/native/components/index.d.ts +7 -0
- package/dist/native/components/index.js +7 -0
- package/dist/native/components/index.js.map +1 -1
- package/dist/orange.webp +0 -0
- package/dist/web.cjs.js +9 -9
- package/dist/web.cjs.js.map +1 -1
- package/dist/web.esm.js +8266 -7578
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.js +9 -9
- package/dist/web.umd.js.map +1 -1
- package/docs/LIGHTHOUSE_100_GUIDE.md +277 -0
- package/docs/app-studio/Design.md +1 -1
- package/docs/app-studio/Theming.md +3 -3
- package/package.json +5 -3
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { View, Vertical, Horizontal, Text, useTheme } from 'app-studio';
|
|
3
|
+
import { DEFAULT_COLORS } from './Chart.style';
|
|
4
|
+
let Svg = null;
|
|
5
|
+
let Path = null;
|
|
6
|
+
let Circle = null;
|
|
7
|
+
let SvgText = null;
|
|
8
|
+
try {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
+
const RNSvg = require('react-native-svg');
|
|
11
|
+
Svg = RNSvg.Svg ?? RNSvg.default;
|
|
12
|
+
Path = RNSvg.Path;
|
|
13
|
+
Circle = RNSvg.Circle;
|
|
14
|
+
SvgText = RNSvg.Text;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
/* optional peer absent */
|
|
18
|
+
}
|
|
19
|
+
const FULL_CIRCLE = Math.PI * 2;
|
|
20
|
+
const FULL_CIRCLE_EPSILON = 0.0001;
|
|
21
|
+
const FALLBACK_COLORS = [
|
|
22
|
+
'#3b82f6',
|
|
23
|
+
'#22c55e',
|
|
24
|
+
'#a855f7',
|
|
25
|
+
'#f97316',
|
|
26
|
+
'#ef4444',
|
|
27
|
+
'#14b8a6',
|
|
28
|
+
'#ec4899',
|
|
29
|
+
'#6366f1',
|
|
30
|
+
'#eab308',
|
|
31
|
+
'#06b6d4',
|
|
32
|
+
];
|
|
33
|
+
const getNumericSize = (value, fallback) => typeof value === 'number' && Number.isFinite(value) && value > 0
|
|
34
|
+
? value
|
|
35
|
+
: fallback;
|
|
36
|
+
const isColorToken = (value) => typeof value === 'string' &&
|
|
37
|
+
(value.startsWith('color-') || value.startsWith('theme-'));
|
|
38
|
+
const isRawColor = (value) => typeof value === 'string' &&
|
|
39
|
+
(/^(#|rgb\(|rgba\(|hsl\(|hsla\()/.test(value) ||
|
|
40
|
+
['black', 'transparent', 'white'].includes(value));
|
|
41
|
+
const resolveSvgColor = (value, fallback, getColor) => {
|
|
42
|
+
if (isRawColor(value))
|
|
43
|
+
return value;
|
|
44
|
+
const resolved = getColor(value);
|
|
45
|
+
return resolved && !isColorToken(resolved) ? resolved : fallback;
|
|
46
|
+
};
|
|
47
|
+
const createCirclePath = (centerX, centerY, radius) => [
|
|
48
|
+
`M ${centerX} ${centerY - radius}`,
|
|
49
|
+
`A ${radius} ${radius} 0 1 1 ${centerX} ${centerY + radius}`,
|
|
50
|
+
`A ${radius} ${radius} 0 1 1 ${centerX} ${centerY - radius}`,
|
|
51
|
+
'Z',
|
|
52
|
+
].join(' ');
|
|
53
|
+
export const PieChart = ({ dataPoints, width, height, animationProgress, isDonut = false, onSliceClick, showTooltip, hideTooltip, views, }) => {
|
|
54
|
+
const { getColor } = useTheme();
|
|
55
|
+
const chartWidth = getNumericSize(width, 200);
|
|
56
|
+
const chartHeight = getNumericSize(height, 200);
|
|
57
|
+
const size = Math.min(chartWidth, chartHeight);
|
|
58
|
+
const radius = (size / 2) * 0.8;
|
|
59
|
+
const centerX = chartWidth / 2;
|
|
60
|
+
const centerY = chartHeight / 2;
|
|
61
|
+
const donutRadius = isDonut ? radius * 0.6 : 0;
|
|
62
|
+
const visibleDataPoints = useMemo(() => dataPoints
|
|
63
|
+
.map((point, index) => ({ point, originalIndex: index }))
|
|
64
|
+
.filter(({ point }) => !point.hidden), [dataPoints]);
|
|
65
|
+
const total = useMemo(() => visibleDataPoints.reduce((sum, { point }) => sum + point.value, 0), [visibleDataPoints]);
|
|
66
|
+
const resolveColor = useCallback((color, index = 0) => {
|
|
67
|
+
const fallback = FALLBACK_COLORS[index % FALLBACK_COLORS.length];
|
|
68
|
+
return resolveSvgColor(color || DEFAULT_COLORS[index % DEFAULT_COLORS.length], fallback, getColor);
|
|
69
|
+
}, [getColor]);
|
|
70
|
+
const slices = useMemo(() => {
|
|
71
|
+
if (total === 0) {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
path: createCirclePath(centerX, centerY, radius),
|
|
75
|
+
color: resolveSvgColor('color-gray-200', '#e4e4e7', getColor),
|
|
76
|
+
label: 'Total',
|
|
77
|
+
value: 0,
|
|
78
|
+
percentage: '0.0%',
|
|
79
|
+
labelX: centerX,
|
|
80
|
+
labelY: centerY,
|
|
81
|
+
startAngle: 0,
|
|
82
|
+
endAngle: FULL_CIRCLE,
|
|
83
|
+
originalIndex: -1,
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
const result = [];
|
|
88
|
+
let startAngle = -Math.PI / 2;
|
|
89
|
+
visibleDataPoints.forEach(({ point, originalIndex }, visibleIndex) => {
|
|
90
|
+
const percentage = point.value / total;
|
|
91
|
+
const angle = percentage * 2 * Math.PI * animationProgress;
|
|
92
|
+
const gapAngle = visibleDataPoints.length > 1 ? 0.02 : 0;
|
|
93
|
+
const effectiveAngle = Math.max(0, angle - gapAngle);
|
|
94
|
+
const currentEndAngle = startAngle + effectiveAngle;
|
|
95
|
+
const isFullCircle = effectiveAngle >= FULL_CIRCLE - FULL_CIRCLE_EPSILON;
|
|
96
|
+
const startX = centerX + Math.cos(startAngle) * radius;
|
|
97
|
+
const startY = centerY + Math.sin(startAngle) * radius;
|
|
98
|
+
const endX = centerX + Math.cos(currentEndAngle) * radius;
|
|
99
|
+
const endY = centerY + Math.sin(currentEndAngle) * radius;
|
|
100
|
+
const largeArcFlag = effectiveAngle > Math.PI ? 1 : 0;
|
|
101
|
+
let path;
|
|
102
|
+
if (isFullCircle) {
|
|
103
|
+
path = createCirclePath(centerX, centerY, radius);
|
|
104
|
+
}
|
|
105
|
+
else if (isDonut) {
|
|
106
|
+
const innerStartX = centerX + Math.cos(startAngle) * donutRadius;
|
|
107
|
+
const innerStartY = centerY + Math.sin(startAngle) * donutRadius;
|
|
108
|
+
const innerEndX = centerX + Math.cos(currentEndAngle) * donutRadius;
|
|
109
|
+
const innerEndY = centerY + Math.sin(currentEndAngle) * donutRadius;
|
|
110
|
+
path = [
|
|
111
|
+
`M ${startX} ${startY}`,
|
|
112
|
+
`A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endX} ${endY}`,
|
|
113
|
+
`L ${innerEndX} ${innerEndY}`,
|
|
114
|
+
`A ${donutRadius} ${donutRadius} 0 ${largeArcFlag} 0 ${innerStartX} ${innerStartY}`,
|
|
115
|
+
'Z',
|
|
116
|
+
].join(' ');
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
path = [
|
|
120
|
+
`M ${centerX} ${centerY}`,
|
|
121
|
+
`L ${startX} ${startY}`,
|
|
122
|
+
`A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endX} ${endY}`,
|
|
123
|
+
'Z',
|
|
124
|
+
].join(' ');
|
|
125
|
+
}
|
|
126
|
+
const labelAngle = startAngle + effectiveAngle / 2;
|
|
127
|
+
const labelRadius = isDonut ? (radius + donutRadius) / 2 : radius * 0.7;
|
|
128
|
+
const labelX = centerX + Math.cos(labelAngle) * labelRadius;
|
|
129
|
+
const labelY = centerY + Math.sin(labelAngle) * labelRadius;
|
|
130
|
+
result.push({
|
|
131
|
+
path,
|
|
132
|
+
color: resolveColor(point.color, visibleIndex),
|
|
133
|
+
label: point.label,
|
|
134
|
+
value: point.value,
|
|
135
|
+
percentage: `${(percentage * 100).toFixed(1)}%`,
|
|
136
|
+
labelX,
|
|
137
|
+
labelY,
|
|
138
|
+
startAngle,
|
|
139
|
+
endAngle: currentEndAngle,
|
|
140
|
+
originalIndex,
|
|
141
|
+
});
|
|
142
|
+
startAngle = currentEndAngle;
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
}, [
|
|
146
|
+
visibleDataPoints,
|
|
147
|
+
total,
|
|
148
|
+
radius,
|
|
149
|
+
centerX,
|
|
150
|
+
centerY,
|
|
151
|
+
donutRadius,
|
|
152
|
+
animationProgress,
|
|
153
|
+
isDonut,
|
|
154
|
+
getColor,
|
|
155
|
+
resolveColor,
|
|
156
|
+
]);
|
|
157
|
+
const renderFallback = () => (<Vertical width="100%" gap={10} padding={8}>
|
|
158
|
+
<Horizontal justifyContent="space-between" alignItems="center">
|
|
159
|
+
<Text fontWeight="600" color="color-gray-500" fontSize={13}>
|
|
160
|
+
{isDonut ? 'Total' : 'Distribution'}
|
|
161
|
+
</Text>
|
|
162
|
+
<Text fontWeight="800" color="color-gray-900" fontSize={16}>
|
|
163
|
+
{total.toLocaleString()}
|
|
164
|
+
</Text>
|
|
165
|
+
</Horizontal>
|
|
166
|
+
<Vertical gap={8}>
|
|
167
|
+
{visibleDataPoints.map(({ point, originalIndex }, index) => {
|
|
168
|
+
const percentage = total > 0 ? ((point.value / total) * 100).toFixed(1) : '0.0';
|
|
169
|
+
const color = resolveColor(point.color, index);
|
|
170
|
+
return (<Horizontal key={`slice-${originalIndex}`} alignItems="center" justifyContent="space-between" gap={8} onPress={onSliceClick
|
|
171
|
+
? () => onSliceClick(dataPoints[originalIndex], originalIndex)
|
|
172
|
+
: undefined} {...views?.pie}>
|
|
173
|
+
<Horizontal alignItems="center" gap={8} flex={1}>
|
|
174
|
+
<View width={12} height={12} borderRadius={3} backgroundColor={color}/>
|
|
175
|
+
<Text fontSize={13} color="color-gray-700">
|
|
176
|
+
{point.label}
|
|
177
|
+
</Text>
|
|
178
|
+
</Horizontal>
|
|
179
|
+
<Horizontal alignItems="center" gap={8}>
|
|
180
|
+
<Text fontSize={13} fontWeight="500" color="color-gray-900">
|
|
181
|
+
{point.value.toLocaleString()}
|
|
182
|
+
</Text>
|
|
183
|
+
<Text fontSize={12} color="color-gray-500">
|
|
184
|
+
{percentage}%
|
|
185
|
+
</Text>
|
|
186
|
+
</Horizontal>
|
|
187
|
+
</Horizontal>);
|
|
188
|
+
})}
|
|
189
|
+
</Vertical>
|
|
190
|
+
</Vertical>);
|
|
191
|
+
if (!Svg || !Path) {
|
|
192
|
+
return renderFallback();
|
|
193
|
+
}
|
|
194
|
+
return (<View width="100%" alignItems="center" justifyContent="center">
|
|
195
|
+
<Svg width={chartWidth} height={chartHeight} viewBox={`0 0 ${chartWidth} ${chartHeight}`}>
|
|
196
|
+
{slices.map((slice, index) => {
|
|
197
|
+
const isPlaceholder = slice.originalIndex === -1;
|
|
198
|
+
const handlePress = () => {
|
|
199
|
+
if (isPlaceholder)
|
|
200
|
+
return;
|
|
201
|
+
const tooltipContent = (<Vertical minWidth={160} gap={4}>
|
|
202
|
+
<Text fontWeight="600">{slice.label}</Text>
|
|
203
|
+
<Text color="color-gray-500" fontSize={12}>
|
|
204
|
+
{slice.value.toLocaleString()} ({slice.percentage})
|
|
205
|
+
</Text>
|
|
206
|
+
</Vertical>);
|
|
207
|
+
showTooltip(slice.labelX, slice.labelY, tooltipContent);
|
|
208
|
+
onSliceClick?.(dataPoints[slice.originalIndex], slice.originalIndex);
|
|
209
|
+
};
|
|
210
|
+
return (<React.Fragment key={`slice-${slice.originalIndex}-${index}`}>
|
|
211
|
+
<Path d={slice.path} fill={slice.color} stroke={resolveSvgColor('color-white', '#ffffff', getColor)} strokeWidth={2} onPress={!isPlaceholder ? handlePress : undefined} onPressOut={!isPlaceholder ? hideTooltip : undefined} {...views?.pie}/>
|
|
212
|
+
{!isPlaceholder &&
|
|
213
|
+
SvgText &&
|
|
214
|
+
slice.endAngle - slice.startAngle > 0.25 && (<SvgText x={slice.labelX} y={slice.labelY} fill="#ffffff" fontSize={11} fontWeight="800" textAnchor="middle" alignmentBaseline="middle" stroke="rgba(0,0,0,0.2)" strokeWidth={2}>
|
|
215
|
+
{slice.percentage}
|
|
216
|
+
</SvgText>)}
|
|
217
|
+
</React.Fragment>);
|
|
218
|
+
})}
|
|
219
|
+
{isDonut && Circle && (<Circle cx={centerX} cy={centerY} r={donutRadius} fill={resolveSvgColor('color-white', '#ffffff', getColor)}/>)}
|
|
220
|
+
{isDonut && SvgText && (<>
|
|
221
|
+
<SvgText x={centerX} y={centerY - 8} fill={resolveSvgColor('color-gray-500', '#71717a', getColor)} fontSize={14} fontWeight="500" textAnchor="middle" alignmentBaseline="middle">
|
|
222
|
+
Total
|
|
223
|
+
</SvgText>
|
|
224
|
+
<SvgText x={centerX} y={centerY + 12} fill={resolveSvgColor('color-gray-900', '#18181b', getColor)} fontSize={20} fontWeight="800" textAnchor="middle" alignmentBaseline="middle">
|
|
225
|
+
{total.toLocaleString()}
|
|
226
|
+
</SvgText>
|
|
227
|
+
</>)}
|
|
228
|
+
</Svg>
|
|
229
|
+
</View>);
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=PieChart.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PieChart.native.js","sourceRoot":"","sources":["../../../../../src/components/Chart/Chart/PieChart.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,IAAI,GAAG,GAAQ,IAAI,CAAC;AACpB,IAAI,IAAI,GAAQ,IAAI,CAAC;AACrB,IAAI,MAAM,GAAQ,IAAI,CAAC;AACvB,IAAI,OAAO,GAAQ,IAAI,CAAC;AACxB,IAAI,CAAC;IACH,8DAA8D;IAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC1C,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC;IACjC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAClB,MAAM,GAAG,KA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C,QAAQ,CAE1B;;YACF,EAAE,OAAO,CACT;YAAA,CAAC,OAAO,CACN,CAAC,CAAC,CAAC,OAAO,CAAC,CACX,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC,CAChB,IAAI,CAAC,CAAC,eAAe,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAC7D,QAAQ,CAAC,CAAC,EAAE,CAAC,CACb,UAAU,CAAC,KAAK,CAChB,UAAU,CAAC,QAAQ,CACnB,iBAAiB,CAAC,QAAQ,CAE1B;cAAA,CAAC,KAAK,CAAC,cAAc,EAAE,CACzB;YAAA,EAAE,OAAO,CACX;UAAA,GAAG,CACJ,CACH;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface Suggestion {
|
|
3
|
+
id: string;
|
|
4
|
+
text: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
}
|
|
7
|
+
interface MentionData {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
avatar?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
interface EditableInputProps {
|
|
14
|
+
value: string;
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
autoFocus?: boolean;
|
|
19
|
+
suggestions?: Suggestion[];
|
|
20
|
+
onSuggestionSelect?: (suggestion: Suggestion) => void;
|
|
21
|
+
showSuggestions?: boolean;
|
|
22
|
+
mentionData?: MentionData[];
|
|
23
|
+
mentionTrigger?: string;
|
|
24
|
+
onMentionSelect?: (mention: MentionData) => void;
|
|
25
|
+
maxHeight?: string;
|
|
26
|
+
minHeight?: string;
|
|
27
|
+
views?: {
|
|
28
|
+
container?: any;
|
|
29
|
+
input?: any;
|
|
30
|
+
placeholder?: any;
|
|
31
|
+
suggestionsContainer?: any;
|
|
32
|
+
suggestionItem?: any;
|
|
33
|
+
mentionContainer?: any;
|
|
34
|
+
mentionItem?: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* React Native variant of `EditableInput`.
|
|
39
|
+
*
|
|
40
|
+
* React Native has no DOM, so the web version's `contentEditable` div,
|
|
41
|
+
* `window.getSelection`, `document.createRange`, and `getBoundingClientRect`
|
|
42
|
+
* based positioning are not available. This variant uses app-studio's `Input`
|
|
43
|
+
* (a TextInput on native) with `multiline`, wired to the same `value`/`onChange`
|
|
44
|
+
* contract. Mentions and suggestions are rendered as a simple inline list of
|
|
45
|
+
* `View`/`Text` choices that invoke the same selection callbacks.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EditableInput: React.ForwardRefExoticComponent<EditableInputProps & React.RefAttributes<any>>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useState } from 'react';
|
|
2
|
+
import { View, Text, Vertical, Input } from 'app-studio';
|
|
3
|
+
/**
|
|
4
|
+
* React Native variant of `EditableInput`.
|
|
5
|
+
*
|
|
6
|
+
* React Native has no DOM, so the web version's `contentEditable` div,
|
|
7
|
+
* `window.getSelection`, `document.createRange`, and `getBoundingClientRect`
|
|
8
|
+
* based positioning are not available. This variant uses app-studio's `Input`
|
|
9
|
+
* (a TextInput on native) with `multiline`, wired to the same `value`/`onChange`
|
|
10
|
+
* contract. Mentions and suggestions are rendered as a simple inline list of
|
|
11
|
+
* `View`/`Text` choices that invoke the same selection callbacks.
|
|
12
|
+
*/
|
|
13
|
+
export const EditableInput = forwardRef(({ value, onChange, placeholder = 'Type your message...', disabled = false, autoFocus = true, suggestions = [], onSuggestionSelect, showSuggestions = false, mentionData = [], mentionTrigger = '@', onMentionSelect, maxHeight = '200px', minHeight = '40px', views = {}, }, ref) => {
|
|
14
|
+
// State variable to control the visibility of the mention dropdown list.
|
|
15
|
+
const [showMentions, setShowMentions] = useState(false);
|
|
16
|
+
// State variable holding the list of `MentionData` objects filtered by the current mention query.
|
|
17
|
+
const [filteredMentions, setFilteredMentions] = useState([]);
|
|
18
|
+
// State variable to store the starting character index of the mention trigger in the input text.
|
|
19
|
+
const [mentionStartPos, setMentionStartPos] = useState(-1);
|
|
20
|
+
// State variable to store the text being typed after the mention trigger (e.g., 'joh' in '@joh').
|
|
21
|
+
const [mentionQuery, setMentionQuery] = useState('');
|
|
22
|
+
// State variable to track whether the input field currently has focus (controls suggestion visibility).
|
|
23
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
24
|
+
// Analyzes the typed text for an active mention trigger and filters `mentionData` accordingly.
|
|
25
|
+
const checkForMentions = useCallback((text) => {
|
|
26
|
+
// On native we don't have a caret position; use end of string as cursor.
|
|
27
|
+
const triggerIndex = text.lastIndexOf(mentionTrigger);
|
|
28
|
+
if (triggerIndex !== -1) {
|
|
29
|
+
const afterTrigger = text.substring(triggerIndex + 1);
|
|
30
|
+
const hasSpaceAfterTrigger = afterTrigger.includes(' ');
|
|
31
|
+
if (!hasSpaceAfterTrigger) {
|
|
32
|
+
const query = afterTrigger.toLowerCase();
|
|
33
|
+
const filtered = mentionData.filter((mention) => mention.name.toLowerCase().includes(query));
|
|
34
|
+
setMentionQuery(query);
|
|
35
|
+
setMentionStartPos(triggerIndex);
|
|
36
|
+
setFilteredMentions(filtered);
|
|
37
|
+
setShowMentions(filtered.length > 0);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
setShowMentions(false);
|
|
42
|
+
setMentionQuery('');
|
|
43
|
+
setMentionStartPos(-1);
|
|
44
|
+
}, [mentionData, mentionTrigger]);
|
|
45
|
+
// Handles text changes from the native `Input`, updating the value and checking for mentions.
|
|
46
|
+
const handleChangeText = useCallback((text) => {
|
|
47
|
+
onChange(text);
|
|
48
|
+
checkForMentions(text);
|
|
49
|
+
}, [onChange, checkForMentions]);
|
|
50
|
+
// Inserts a selected mention into the input text, replacing the active mention query.
|
|
51
|
+
const handleMentionSelect = useCallback((mention) => {
|
|
52
|
+
if (mentionStartPos !== -1) {
|
|
53
|
+
const beforeMention = value.substring(0, mentionStartPos);
|
|
54
|
+
const afterMention = value.substring(mentionStartPos + mentionTrigger.length + mentionQuery.length);
|
|
55
|
+
const newText = beforeMention + mentionTrigger + mention.name + ' ' + afterMention;
|
|
56
|
+
onChange(newText);
|
|
57
|
+
}
|
|
58
|
+
setShowMentions(false);
|
|
59
|
+
setMentionQuery('');
|
|
60
|
+
setMentionStartPos(-1);
|
|
61
|
+
if (onMentionSelect) {
|
|
62
|
+
onMentionSelect(mention);
|
|
63
|
+
}
|
|
64
|
+
}, [
|
|
65
|
+
value,
|
|
66
|
+
mentionStartPos,
|
|
67
|
+
mentionTrigger,
|
|
68
|
+
mentionQuery,
|
|
69
|
+
onChange,
|
|
70
|
+
onMentionSelect,
|
|
71
|
+
]);
|
|
72
|
+
// Handles the selection of a suggestion, invoking the `onSuggestionSelect` prop if provided.
|
|
73
|
+
const handleSuggestionSelect = useCallback((suggestion) => {
|
|
74
|
+
if (onSuggestionSelect) {
|
|
75
|
+
onSuggestionSelect(suggestion);
|
|
76
|
+
}
|
|
77
|
+
}, [onSuggestionSelect]);
|
|
78
|
+
return (<View ref={ref} width="100%" position="relative" {...views?.container}>
|
|
79
|
+
<View width="100%" minHeight={minHeight} maxHeight={maxHeight} position="relative">
|
|
80
|
+
<Input multiline value={value} onChangeText={handleChangeText} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} placeholder={placeholder} editable={!disabled} autoFocus={autoFocus} width="100%" minHeight="24px" padding="8px" fontSize="14px" color="color-gray-900" backgroundColor="transparent" {...views?.input}/>
|
|
81
|
+
</View>
|
|
82
|
+
|
|
83
|
+
{/* Mentions list */}
|
|
84
|
+
{showMentions && filteredMentions.length > 0 && (<View width="100%" backgroundColor="color-white" border="2px solid" borderColor="color-blue-300" borderRadius="8px" maxHeight="200px" marginTop={4} {...views?.mentionContainer}>
|
|
85
|
+
<Vertical gap={0}>
|
|
86
|
+
{filteredMentions.map((mention) => (<View key={mention.id} width="100%" padding="12px 16px" backgroundColor="transparent" onPress={() => handleMentionSelect(mention)} {...views?.mentionItem}>
|
|
87
|
+
<Vertical gap={4}>
|
|
88
|
+
<Text fontSize="14px" color="color-gray-900" fontWeight="medium">
|
|
89
|
+
{mentionTrigger}
|
|
90
|
+
{mention.name}
|
|
91
|
+
</Text>
|
|
92
|
+
{mention.description && (<Text fontSize="12px" color="color-gray-600">
|
|
93
|
+
{mention.description}
|
|
94
|
+
</Text>)}
|
|
95
|
+
</Vertical>
|
|
96
|
+
</View>))}
|
|
97
|
+
</Vertical>
|
|
98
|
+
</View>)}
|
|
99
|
+
|
|
100
|
+
{/* Suggestions list */}
|
|
101
|
+
{showSuggestions &&
|
|
102
|
+
suggestions.length > 0 &&
|
|
103
|
+
!showMentions &&
|
|
104
|
+
isFocused &&
|
|
105
|
+
!value && (<View width="100%" backgroundColor="color-white" border="2px solid" borderColor="color-green-300" borderRadius="8px" maxHeight="200px" marginTop={4} {...views?.suggestionsContainer}>
|
|
106
|
+
<Vertical gap={0}>
|
|
107
|
+
{suggestions.map((suggestion) => (<View key={suggestion.id} width="100%" padding="12px 16px" backgroundColor="transparent" onPress={() => handleSuggestionSelect(suggestion)} {...views?.suggestionItem}>
|
|
108
|
+
<Vertical gap={4}>
|
|
109
|
+
<Text fontSize="14px" color="color-gray-900" fontWeight="medium">
|
|
110
|
+
{suggestion.text}
|
|
111
|
+
</Text>
|
|
112
|
+
{suggestion.description && (<Text fontSize="12px" color="color-gray-600">
|
|
113
|
+
{suggestion.description}
|
|
114
|
+
</Text>)}
|
|
115
|
+
</Vertical>
|
|
116
|
+
</View>))}
|
|
117
|
+
</Vertical>
|
|
118
|
+
</View>)}
|
|
119
|
+
</View>);
|
|
120
|
+
});
|
|
121
|
+
EditableInput.displayName = 'EditableInput';
|
|
122
|
+
//# sourceMappingURL=EditableInput.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableInput.native.js","sourceRoot":"","sources":["../../../../src/components/ChatInput/EditableInput.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA8DzD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CACrC,CACE,EACE,KAAK,EACL,QAAQ,EACR,WAAW,GAAG,sBAAsB,EACpC,QAAQ,GAAG,KAAK,EAChB,SAAS,GAAG,IAAI,EAChB,WAAW,GAAG,EAAE,EAChB,kBAAkB,EAClB,eAAe,GAAG,KAAK,EACvB,WAAW,GAAG,EAAE,EAChB,cAAc,GAAG,GAAG,EACpB,eAAe,EACf,SAAS,GAAG,OAAO,EACnB,SAAS,GAAG,MAAM,EAClB,KAAK,GAAG,EAAE,GACX,EACD,GAAG,EACH,EAAE;IACF,yEAAyE;IACzE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,kGAAkG;IAClG,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAgB,EAAE,CAAC,CAAC;IAC5E,iGAAiG;IACjG,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,kGAAkG;IAClG,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACrD,wGAAwG;IACxG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAElD,+FAA+F;IAC/F,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAA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AAC,aAAa,CAC7B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,CAClD,IAAI,KAAK,EAAE,cAAc,CAAC,CAE1B;oBAAA,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACf;sBAAA,CAAC,IAAI,CACH,QAAQ,CAAC,MAAM,CACf,KAAK,CAAC,gBAAgB,CACtB,UAAU,CAAC,QAAQ,CAEnB;wBAAA,CAAC,UAAU,CAAC,IAAI,CAClB;sBAAA,EAAE,IAAI,CACN;sBAAA,CAAC,UAAU,CAAC,WAAW,IAAI,CACzB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAC1C;0BAAA,CAAC,UAAU,CAAC,WAAW,CACzB;wBAAA,EAAE,IAAI,CAAC,CACR,CACH;oBAAA,EAAE,QAAQ,CACZ;kBAAA,EAAE,IAAI,CAAC,CACR,CAAC,CACJ;cAAA,EAAE,QAAQ,CACZ;YAAA,EAAE,IAAI,CAAC,CACR,CACL;MAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ModelOption } from './ChatInput/ChatInput.type';
|
|
3
|
+
interface MessageInputProps {
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
6
|
+
onSubmit: (e: React.FormEvent) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
isAgentRunning?: boolean;
|
|
11
|
+
onStopAgent?: () => void;
|
|
12
|
+
isDraggingOver?: boolean;
|
|
13
|
+
uploadedFiles: File[];
|
|
14
|
+
fileInputRef: React.RefObject<HTMLInputElement>;
|
|
15
|
+
isUploading: boolean;
|
|
16
|
+
sandboxId?: string;
|
|
17
|
+
setPendingFiles: React.Dispatch<React.SetStateAction<File[]>>;
|
|
18
|
+
setUploadedFiles: React.Dispatch<React.SetStateAction<File[]>>;
|
|
19
|
+
setIsUploading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
20
|
+
hideAttachments?: boolean;
|
|
21
|
+
selectedModel: string;
|
|
22
|
+
onModelChange: (model: string) => void;
|
|
23
|
+
modelOptions: ModelOption[];
|
|
24
|
+
subscriptionStatus?: string;
|
|
25
|
+
canAccessModel: (model: string) => boolean;
|
|
26
|
+
views?: {
|
|
27
|
+
container?: any;
|
|
28
|
+
textarea?: any;
|
|
29
|
+
buttonGroup?: any;
|
|
30
|
+
submitButton?: any;
|
|
31
|
+
submitIcon?: any;
|
|
32
|
+
modelSelector?: any;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* React Native variant of `MessageInput`.
|
|
37
|
+
*
|
|
38
|
+
* React Native has no DOM: the web version's `<textarea>`, `<select>`/`<option>`,
|
|
39
|
+
* and the file `<input>` (via `ChatUploader`) are all browser-only and would
|
|
40
|
+
* crash. This variant uses app-studio's `Input` (a TextInput on native) with
|
|
41
|
+
* `multiline`, replaces the model `<select>` with a row of `View`/`Text`
|
|
42
|
+
* choices, and omits the web-only file-attachment chrome. The same
|
|
43
|
+
* `value`/`onChange`/`onSubmit`/`onModelChange` callbacks are preserved.
|
|
44
|
+
*/
|
|
45
|
+
export declare const MessageInput: React.ForwardRefExoticComponent<MessageInputProps & React.RefAttributes<any>>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { Button, Horizontal, Vertical, View, Text, Input } from 'app-studio';
|
|
3
|
+
/**
|
|
4
|
+
* React Native variant of `MessageInput`.
|
|
5
|
+
*
|
|
6
|
+
* React Native has no DOM: the web version's `<textarea>`, `<select>`/`<option>`,
|
|
7
|
+
* and the file `<input>` (via `ChatUploader`) are all browser-only and would
|
|
8
|
+
* crash. This variant uses app-studio's `Input` (a TextInput on native) with
|
|
9
|
+
* `multiline`, replaces the model `<select>` with a row of `View`/`Text`
|
|
10
|
+
* choices, and omits the web-only file-attachment chrome. The same
|
|
11
|
+
* `value`/`onChange`/`onSubmit`/`onModelChange` callbacks are preserved.
|
|
12
|
+
*/
|
|
13
|
+
export const MessageInput = forwardRef(({ value, onChange, onSubmit, placeholder = 'Describe what you need help with...', loading = false, disabled = false, isAgentRunning = false, uploadedFiles, selectedModel, onModelChange, modelOptions, canAccessModel, views = {}, }, ref) => {
|
|
14
|
+
// Bridges the native `onChangeText` (a raw string) to the web-style `onChange`
|
|
15
|
+
// signature by synthesizing a minimal change-event-like object.
|
|
16
|
+
const handleChangeText = (text) => {
|
|
17
|
+
onChange({
|
|
18
|
+
target: { value: text },
|
|
19
|
+
currentTarget: { value: text },
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
// Triggers submission while reusing the same `onSubmit` callback the web uses.
|
|
23
|
+
const handleSubmit = () => {
|
|
24
|
+
onSubmit({});
|
|
25
|
+
};
|
|
26
|
+
const submitDisabled = (!value.trim() && uploadedFiles.length === 0) ||
|
|
27
|
+
loading ||
|
|
28
|
+
(disabled && !isAgentRunning);
|
|
29
|
+
return (<View width="100%" position="relative" {...views?.container}>
|
|
30
|
+
<Input ref={ref} multiline value={value} onChangeText={handleChangeText} onSubmitEditing={handleSubmit} placeholder={placeholder} editable={!(disabled && !isAgentRunning)} width="100%" minHeight="40px" maxHeight="200px" padding="8px 12px" fontSize="14px" lineHeight="15px" color="color-gray-900" backgroundColor="transparent" {...views?.textarea}/>
|
|
31
|
+
<Horizontal justifyContent="space-between" alignItems="center" padding="4px 8px" {...views?.buttonGroup}>
|
|
32
|
+
{/* Model selection rendered as tappable choices (no DOM <select>). */}
|
|
33
|
+
<Horizontal gap={8} alignItems="center" flexWrap="wrap">
|
|
34
|
+
{modelOptions.map((model) => {
|
|
35
|
+
const accessible = canAccessModel(model.id);
|
|
36
|
+
const isSelected = model.id === selectedModel;
|
|
37
|
+
return (<View key={model.id} height="36px" padding="0 12px" borderRadius="8px" justifyContent="center" backgroundColor={isSelected ? 'color-blue-50' : 'transparent'} opacity={accessible ? 1 : 0.5} onPress={accessible ? () => onModelChange(model.id) : undefined} {...views?.modelSelector}>
|
|
38
|
+
<Vertical justifyContent="center" height="100%">
|
|
39
|
+
<Text fontSize="14px" color={isSelected ? 'color-blue-600' : 'color-gray-500'}>
|
|
40
|
+
{model.name}
|
|
41
|
+
</Text>
|
|
42
|
+
</Vertical>
|
|
43
|
+
</View>);
|
|
44
|
+
})}
|
|
45
|
+
</Horizontal>
|
|
46
|
+
<Button onClick={handleSubmit} height="36px" minWidth="36px" padding="0 12px" borderRadius="8px" backgroundColor={isAgentRunning ? 'theme-error' : 'theme-primary'} color="color-white" disabled={submitDisabled} {...views?.submitButton}>
|
|
47
|
+
<Text color="color-white" fontSize="14px">
|
|
48
|
+
{isAgentRunning ? 'Stop' : loading ? '...' : 'Send'}
|
|
49
|
+
</Text>
|
|
50
|
+
</Button>
|
|
51
|
+
</Horizontal>
|
|
52
|
+
</View>);
|
|
53
|
+
});
|
|
54
|
+
MessageInput.displayName = 'MessageInput';
|
|
55
|
+
//# sourceMappingURL=MessageInput.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageInput.native.js","sourceRoot":"","sources":["../../../../src/components/ChatInput/MessageInput.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA2D7E;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CACpC,CACE,EACE,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,W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C,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAExD;sBAAA,CAAC,KAAK,CAAC,IAAI,CACb;oBAAA,EAAE,IAAI,CACR;kBAAA,EAAE,QAAQ,CACZ;gBAAA,EAAE,IAAI,CAAC,CACR,CAAC;QACJ,CAAC,CAAC,CACJ;UAAA,EAAE,UAAU,CACZ;UAAA,CAAC,MAAM,CACL,OAAO,CAAC,CAAC,YAAY,CAAC,CACtB,MAAM,CAAC,MAAM,CACb,QAAQ,CAAC,MAAM,CACf,OAAO,CAAC,QAAQ,CAChB,YAAY,CAAC,KAAK,CAClB,eAAe,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAClE,KAAK,CAAC,aAAa,CACnB,QAAQ,CAAC,CAAC,cAAc,CAAC,CACzB,IAAI,KAAK,EAAE,YAAY,CAAC,CAExB;YAAA,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CACvC;cAAA,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CACrD;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,MAAM,CACV;QAAA,EAAE,UAAU,CACd;MAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatWidgetView (React Native)
|
|
3
|
+
*
|
|
4
|
+
* The web view's input is `<View as="textarea">` — on native `as` is ignored,
|
|
5
|
+
* so it renders a non-editable View and the chat isn't interactive. This native
|
|
6
|
+
* variant mirrors the same surface (messages list, context chips, attachment /
|
|
7
|
+
* context-picker / send buttons) but uses app-studio's `Input` (a real
|
|
8
|
+
* TextInput) wired to `internalInputValue` / `handleInputChange` /
|
|
9
|
+
* `handleSubmit`, so you can type and send on native.
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { ChatWidgetViewProps } from './ChatWidget.props';
|
|
13
|
+
declare const ChatWidgetView: React.FC<ChatWidgetViewProps>;
|
|
14
|
+
export default ChatWidgetView;
|