@neko-os/ui 0.2.3 → 0.3.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/dist/DynamicStyleTag.js +18 -2
- package/dist/DynamicStyleTag.native.js +3 -1
- package/dist/NekoUI.js +39 -1
- package/dist/abstractions/ActivityIndicator.js +19 -1
- package/dist/abstractions/ActivityIndicator.native.js +43 -1
- package/dist/abstractions/ActivityIndicator.web.js +43 -1
- package/dist/abstractions/AnimatedView.js +3 -1
- package/dist/abstractions/AnimatedView.native.js +5 -1
- package/dist/abstractions/AnimatedView.web.js +3 -1
- package/dist/abstractions/BlurView.js +43 -1
- package/dist/abstractions/BlurView.native.js +39 -1
- package/dist/abstractions/BlurView.web.js +39 -1
- package/dist/abstractions/DraggableSlideView.js +3 -1
- package/dist/abstractions/DraggableSlideView.native.js +62 -1
- package/dist/abstractions/FlatList.js +3 -1
- package/dist/abstractions/FlatList.native.js +37 -1
- package/dist/abstractions/FlatList.web.js +3 -1
- package/dist/abstractions/GradientView.js +5 -1
- package/dist/abstractions/GradientView.native.js +32 -1
- package/dist/abstractions/HiddenInput.js +3 -1
- package/dist/abstractions/HiddenInput.native.js +3 -1
- package/dist/abstractions/Icon.js +10 -1
- package/dist/abstractions/Icon.native.js +13 -1
- package/dist/abstractions/Icon.web.js +11 -1
- package/dist/abstractions/Image.js +12 -1
- package/dist/abstractions/Image.native.js +7 -1
- package/dist/abstractions/Image.web.js +7 -1
- package/dist/abstractions/ImageBackground.js +17 -1
- package/dist/abstractions/ImageBackground.native.js +27 -1
- package/dist/abstractions/ImageBackground.web.js +7 -1
- package/dist/abstractions/KeyboardAvoidingView.js +3 -1
- package/dist/abstractions/KeyboardAvoidingView.native.js +3 -1
- package/dist/abstractions/Platform.js +1 -1
- package/dist/abstractions/Platform.native.js +3 -1
- package/dist/abstractions/Platform.web.js +3 -1
- package/dist/abstractions/Pressable.js +4 -1
- package/dist/abstractions/Pressable.native.js +3 -1
- package/dist/abstractions/Pressable.web.js +3 -1
- package/dist/abstractions/SafeAreaView.js +3 -1
- package/dist/abstractions/SafeAreaView.native.js +3 -1
- package/dist/abstractions/ScrollView.js +3 -1
- package/dist/abstractions/ScrollView.native.js +5 -1
- package/dist/abstractions/ScrollView.web.js +3 -1
- package/dist/abstractions/StaticList.js +51 -1
- package/dist/abstractions/Switch.js +97 -1
- package/dist/abstractions/Switch.native.js +12 -1
- package/dist/abstractions/Table.js +29 -1
- package/dist/abstractions/Table.native.js +19 -1
- package/dist/abstractions/Text.js +14 -1
- package/dist/abstractions/Text.native.js +3 -1
- package/dist/abstractions/Text.web.js +18 -1
- package/dist/abstractions/TextInput.js +12 -1
- package/dist/abstractions/TextInput.native.js +5 -1
- package/dist/abstractions/TextInput.web.js +5 -1
- package/dist/abstractions/TouchableOpacity.js +4 -1
- package/dist/abstractions/TouchableOpacity.native.js +3 -1
- package/dist/abstractions/View.js +3 -1
- package/dist/abstractions/View.native.js +3 -1
- package/dist/abstractions/View.web.js +3 -1
- package/dist/abstractions/helpers/componentSize.js +13 -1
- package/dist/abstractions/helpers/componentSize.native.js +12 -1
- package/dist/abstractions/helpers/storage.js +32 -1
- package/dist/abstractions/helpers/storage.native.js +34 -1
- package/dist/abstractions/helpers/transformStyle.js +8 -1
- package/dist/abstractions/helpers/transformStyle.native.js +3 -1
- package/dist/abstractions/helpers/useSafeAreaInsets.js +3 -1
- package/dist/abstractions/helpers/useSafeAreaInsets.native.js +3 -1
- package/dist/abstractions/helpers/windowWidth.js +13 -1
- package/dist/abstractions/helpers/windowWidth.native.js +6 -1
- package/dist/abstractions/helpers/windowWidth.web.js +6 -1
- package/dist/components/actions/ActionsDrawer.js +81 -1
- package/dist/components/actions/Breadcrumb.js +47 -1
- package/dist/components/actions/Button.js +82 -1
- package/dist/components/actions/Dropdown.js +91 -1
- package/dist/components/actions/FloatingButton.js +87 -1
- package/dist/components/actions/FloatingMenu.js +39 -1
- package/dist/components/actions/Link.js +66 -1
- package/dist/components/actions/Pressable.js +38 -1
- package/dist/components/actions/index.js +9 -1
- package/dist/components/actions/menu/HorizontalMenu.js +98 -1
- package/dist/components/actions/menu/Menu.js +7 -1
- package/dist/components/actions/menu/SubmenuWrapper.js +16 -1
- package/dist/components/actions/menu/VerticalMenu.js +133 -1
- package/dist/components/animations/AnimatedTopBar.js +10 -1
- package/dist/components/animations/AnimatedTopBar.native.js +34 -1
- package/dist/components/animations/AnimatedTopBar.web.js +1 -1
- package/dist/components/animations/AnimatedView.js +45 -1
- package/dist/components/animations/DraggableSlideView.js +42 -1
- package/dist/components/animations/ParallaxHeader.js +9 -1
- package/dist/components/animations/ParallaxHeader.native.js +32 -1
- package/dist/components/animations/ParallaxHeader.web.js +32 -1
- package/dist/components/animations/ReanimatedScrollHandler.js +8 -1
- package/dist/components/animations/ReanimatedScrollHandler.native.js +24 -1
- package/dist/components/animations/ReanimatedScrollHandler.web.js +1 -1
- package/dist/components/animations/ReanimatedView.js +40 -1
- package/dist/components/animations/index.js +5 -1
- package/dist/components/calendar/CalendarNav.js +67 -1
- package/dist/components/calendar/WeekDaysBar.js +18 -1
- package/dist/components/calendar/_helpers/calendarDays.js +16 -1
- package/dist/components/calendar/_helpers/dateDisabled.js +24 -1
- package/dist/components/feedback/alerter.js +31 -1
- package/dist/components/feedback/confirmer.js +70 -1
- package/dist/components/feedback/index.js +3 -1
- package/dist/components/feedback/notifications/Notification.js +37 -1
- package/dist/components/feedback/notifications/NotificationsHandler.js +65 -1
- package/dist/components/filter/DateFilter.js +72 -0
- package/dist/components/filter/FilterGroup.js +17 -0
- package/dist/components/filter/FilterHandler.js +54 -0
- package/dist/components/filter/FilterItem.js +30 -0
- package/dist/components/filter/PopoverFilterItem.js +84 -0
- package/dist/components/filter/SearchInput.js +49 -0
- package/dist/components/filter/index.js +6 -0
- package/dist/components/form/Form.js +31 -1
- package/dist/components/form/FormGroup.js +21 -1
- package/dist/components/form/FormItem.js +118 -1
- package/dist/components/form/FormList.js +143 -1
- package/dist/components/form/FormWrapperComponent.js +52 -1
- package/dist/components/form/FormWrapperComponent.native.js +5 -1
- package/dist/components/form/SubmitButton.js +22 -1
- package/dist/components/form/index.js +9 -1
- package/dist/components/form/useNewForm.js +211 -1
- package/dist/components/form/useWatch.js +70 -1
- package/dist/components/form/validation/defaultMessages.js +20 -1
- package/dist/components/form/validation/index.js +5 -1
- package/dist/components/form/validation/normalizeRules.js +22 -1
- package/dist/components/form/validation/shouldValidateOn.js +21 -1
- package/dist/components/form/validation/validateRules.js +83 -1
- package/dist/components/form/validation/validators.js +82 -1
- package/dist/components/helpers/ConditionalLazyRender.js +6 -1
- package/dist/components/helpers/LazyAction.js +22 -1
- package/dist/components/helpers/LazyRender.js +55 -1
- package/dist/components/helpers/LazyRender.native.js +58 -1
- package/dist/components/helpers/Portal.js +21 -1
- package/dist/components/helpers/PortalHandler.js +32 -1
- package/dist/components/helpers/Responsive.js +18 -1
- package/dist/components/helpers/Separator.js +49 -1
- package/dist/components/helpers/VerticalView.js +34 -1
- package/dist/components/helpers/index.js +8 -1
- package/dist/components/index.js +20 -1
- package/dist/components/inputs/BooleanSelect.js +14 -0
- package/dist/components/inputs/Checkbox.js +56 -1
- package/dist/components/inputs/DateInput.js +123 -1
- package/dist/components/inputs/DateRangeInput.js +41 -0
- package/dist/components/inputs/Editable.js +129 -0
- package/dist/components/inputs/EnabledSelect.js +14 -0
- package/dist/components/inputs/InputWrapper.js +93 -1
- package/dist/components/inputs/LinkInput.js +17 -1
- package/dist/components/inputs/MaskInput.js +67 -1
- package/dist/components/inputs/NumberInput.js +111 -1
- package/dist/components/inputs/NumberRangeInput.js +41 -0
- package/dist/components/inputs/PasswordInput.js +24 -0
- package/dist/components/inputs/Picker.js +169 -1
- package/dist/components/inputs/Radio.js +55 -1
- package/dist/components/inputs/RateInput.js +62 -1
- package/dist/components/inputs/SegmentedPicker.js +62 -1
- package/dist/components/inputs/Select.js +219 -1
- package/dist/components/inputs/Switch.js +60 -1
- package/dist/components/inputs/TextArea.js +5 -0
- package/dist/components/inputs/TextInput.js +32 -1
- package/dist/components/inputs/UploadInput.js +140 -0
- package/dist/components/inputs/_DateInput.native.js +89 -1
- package/dist/components/inputs/datePicker/DatePicker.js +24 -1
- package/dist/components/inputs/datePicker/DayPicker.js +64 -1
- package/dist/components/inputs/datePicker/MonthPicker.js +62 -1
- package/dist/components/inputs/datePicker/QuarterPicker.js +65 -1
- package/dist/components/inputs/datePicker/WeekPicker.js +74 -1
- package/dist/components/inputs/datePicker/YearPicker.js +70 -1
- package/dist/components/inputs/index.js +23 -1
- package/dist/components/inputs/upload/Upload.js +99 -0
- package/dist/components/inputs/upload/Upload.native.js +154 -0
- package/dist/components/inputs/upload/useUploadState.js +143 -0
- package/dist/components/layout/Layout.js +40 -1
- package/dist/components/layout/LayoutContent.js +42 -1
- package/dist/components/layout/LayoutHeader.js +70 -1
- package/dist/components/layout/LayoutSider.js +64 -1
- package/dist/components/layout/index.js +4 -1
- package/dist/components/list/FlatList.js +91 -1
- package/dist/components/list/ScrollView.js +58 -1
- package/dist/components/list/index.js +2 -1
- package/dist/components/modals/bottomDrawer/index.js +3 -1
- package/dist/components/modals/bottomDrawer/index.native.js +5 -1
- package/dist/components/modals/bottomDrawer/index.web.js +5 -1
- package/dist/components/modals/bottomDrawer/native/BottomDrawer.js +239 -1
- package/dist/components/modals/bottomDrawer/native/DrawerContext.js +17 -1
- package/dist/components/modals/bottomDrawer/native/DrawerHandle.js +12 -1
- package/dist/components/modals/bottomDrawer/native/DrawerScrollView.js +5 -1
- package/dist/components/modals/bottomDrawer/native/createDrawerScrollComponent.js +139 -1
- package/dist/components/modals/bottomDrawer/native/utils.js +65 -1
- package/dist/components/modals/bottomDrawer/web/BottomDrawer.js +5 -1
- package/dist/components/modals/drawer/Drawer.js +5 -1
- package/dist/components/modals/drawer/Drawer.native.js +3 -1
- package/dist/components/modals/drawer/Drawer.web.js +3 -1
- package/dist/components/modals/drawer/index.js +1 -1
- package/dist/components/modals/index.js +4 -1
- package/dist/components/modals/modal/Modal.js +84 -1
- package/dist/components/modals/modal/Modal.native.js +83 -1
- package/dist/components/modals/modal/ModalBackdrop.js +58 -1
- package/dist/components/modals/modal/ModalContent.js +28 -1
- package/dist/components/modals/modal/ModalFooter.js +31 -1
- package/dist/components/modals/modal/ModalHeader.js +50 -1
- package/dist/components/modals/modal/handler/ModalsHandler.js +61 -1
- package/dist/components/modals/modal/index.js +6 -1
- package/dist/components/modals/router/ModalRoute.js +15 -1
- package/dist/components/modals/router/ModalsRouter.js +120 -1
- package/dist/components/modals/router/ModalsRouterContext.js +16 -1
- package/dist/components/modals/router/index.js +6 -1
- package/dist/components/modals/router/useAllModalsParams.js +6 -1
- package/dist/components/modals/router/useModalParams.js +6 -1
- package/dist/components/modals/router/useModalsNavigation.js +6 -1
- package/dist/components/modals/router/useUpdateModalContainer.js +6 -1
- package/dist/components/presentation/Avatar.js +79 -1
- package/dist/components/presentation/AvatarLabel.js +60 -1
- package/dist/components/presentation/AvatarsGroup.js +30 -0
- package/dist/components/presentation/Badge.js +91 -1
- package/dist/components/presentation/ContentLabel.js +43 -1
- package/dist/components/presentation/Icon.js +20 -1
- package/dist/components/presentation/IconLabel.js +40 -1
- package/dist/components/presentation/Image.js +33 -1
- package/dist/components/presentation/ImageBackground.js +38 -1
- package/dist/components/presentation/LabelValue.js +51 -1
- package/dist/components/presentation/Progress.js +20 -0
- package/dist/components/presentation/Rate.js +58 -1
- package/dist/components/presentation/RateTag.js +35 -1
- package/dist/components/presentation/Result.js +60 -1
- package/dist/components/presentation/ResultBar.js +56 -1
- package/dist/components/presentation/Tag.js +69 -1
- package/dist/components/presentation/Tooltip.js +44 -1
- package/dist/components/presentation/index.js +16 -1
- package/dist/components/sections/Section.js +50 -1
- package/dist/components/sections/SectionItem.js +24 -1
- package/dist/components/sections/SectionItemDropdown.js +68 -1
- package/dist/components/sections/SectionItemLink.js +35 -1
- package/dist/components/sections/index.js +4 -1
- package/dist/components/state/Loading.js +20 -1
- package/dist/components/state/LoadingView.js +37 -1
- package/dist/components/state/StatePresenter.js +41 -1
- package/dist/components/state/index.js +3 -1
- package/dist/components/steps/ActiveStepContent.js +16 -0
- package/dist/components/steps/StepsHandler.js +53 -0
- package/dist/components/steps/StepsMenu.js +14 -0
- package/dist/components/steps/StepsNavigation.js +37 -0
- package/dist/components/steps/index.js +4 -0
- package/dist/components/structure/Accordion.js +69 -1
- package/dist/components/structure/AccordionGroup.js +35 -1
- package/dist/components/structure/Affix.js +34 -0
- package/dist/components/structure/Affix.native.js +3 -0
- package/dist/components/structure/BlurView.js +59 -1
- package/dist/components/structure/Card.js +46 -1
- package/dist/components/structure/Col.js +22 -1
- package/dist/components/structure/GradientView.js +42 -1
- package/dist/components/structure/KeyboardAvoidingView.js +52 -1
- package/dist/components/structure/Row.js +50 -1
- package/dist/components/structure/SafeAreaView.js +42 -1
- package/dist/components/structure/Segment.js +51 -1
- package/dist/components/structure/TopBar.js +57 -1
- package/dist/components/structure/View.js +44 -1
- package/dist/components/structure/index.js +14 -1
- package/dist/components/structure/overlay/OverlayHandler.js +83 -1
- package/dist/components/structure/overlay/OverlayHandler.native.js +6 -1
- package/dist/components/structure/overlay/OverlayWrapper.js +52 -1
- package/dist/components/structure/overlay/calculatePosition.js +29 -1
- package/dist/components/structure/overlay/smartPlacement.js +32 -1
- package/dist/components/structure/popover/Popover.js +135 -1
- package/dist/components/structure/popover/Popover.native.js +105 -1
- package/dist/components/structure/popover/PopoverContent.js +18 -1
- package/dist/components/structure/popover/Popover_BU.js +157 -1
- package/dist/components/table/DataTable.js +62 -1
- package/dist/components/table/Pagination.js +128 -1
- package/dist/components/table/Table.js +66 -1
- package/dist/components/table/TableCol.js +67 -1
- package/dist/components/table/TableHeader.js +69 -1
- package/dist/components/table/TableHeaderRow.js +31 -1
- package/dist/components/table/TableRow.js +30 -1
- package/dist/components/table/index.js +7 -1
- package/dist/components/tabs/ActiveTabContent.js +38 -1
- package/dist/components/tabs/TabsHandler.js +16 -1
- package/dist/components/tabs/TabsMenu.js +15 -1
- package/dist/components/tabs/index.js +3 -1
- package/dist/components/text/DateText.js +24 -1
- package/dist/components/text/Text.js +32 -1
- package/dist/components/text/VerticalText.js +29 -1
- package/dist/components/text/index.js +3 -1
- package/dist/components/theme/ThemePicker.js +48 -1
- package/dist/components/theme/ThemePickerDrawer.js +12 -1
- package/dist/components/theme/ThemeStatusBar.js +3 -1
- package/dist/components/theme/ThemeStatusBar.native.js +9 -1
- package/dist/components/theme/ThemeThumb.js +98 -1
- package/dist/components/theme/index.js +3 -1
- package/dist/helpers/debounce.js +9 -1
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/options.js +65 -1
- package/dist/helpers/random.js +5 -1
- package/dist/helpers/storage.js +76 -1
- package/dist/helpers/string.js +74 -1
- package/dist/i18n/I18n.js +96 -1
- package/dist/i18n/I18nProvider.js +40 -1
- package/dist/i18n/index.js +2 -1
- package/dist/index.js +8 -1
- package/dist/modifiers/_helpers.js +6 -1
- package/dist/modifiers/alignConverter.js +11 -1
- package/dist/modifiers/animation.js +18 -1
- package/dist/modifiers/animations/animatedEffects.js +64 -1
- package/dist/modifiers/animations/animatedEffects.native.js +55 -1
- package/dist/modifiers/animations/animatedEffects.web.js +55 -1
- package/dist/modifiers/animations/fadeEffect.js +46 -1
- package/dist/modifiers/animations/fadeEffect.native.js +33 -1
- package/dist/modifiers/animations/fadeEffect.web.js +3 -1
- package/dist/modifiers/animations/scaleEffect.js +46 -1
- package/dist/modifiers/animations/scaleEffect.native.js +33 -1
- package/dist/modifiers/animations/scrollEffect.web.js +3 -1
- package/dist/modifiers/animations/slideEffect.js +64 -1
- package/dist/modifiers/animations/slideEffect.native.js +53 -1
- package/dist/modifiers/animations/slideEffect.web.js +3 -1
- package/dist/modifiers/applyStyles.js +7 -1
- package/dist/modifiers/background.js +34 -1
- package/dist/modifiers/border.js +86 -1
- package/dist/modifiers/colorConverter.js +13 -1
- package/dist/modifiers/cursor.js +21 -1
- package/dist/modifiers/default.js +9 -1
- package/dist/modifiers/display.js +22 -1
- package/dist/modifiers/flex.js +20 -1
- package/dist/modifiers/flexWrapper.js +87 -1
- package/dist/modifiers/fullColor.js +32 -1
- package/dist/modifiers/grid.js +27 -1
- package/dist/modifiers/hover.js +28 -1
- package/dist/modifiers/logger.js +6 -1
- package/dist/modifiers/margin.js +25 -1
- package/dist/modifiers/overflow.js +28 -1
- package/dist/modifiers/padding.js +25 -1
- package/dist/modifiers/position.js +57 -1
- package/dist/modifiers/responsiveConverter.js +19 -1
- package/dist/modifiers/shadow.js +35 -1
- package/dist/modifiers/size.js +59 -1
- package/dist/modifiers/sizeConverter.js +12 -1
- package/dist/modifiers/state.js +33 -1
- package/dist/modifiers/text.js +62 -1
- package/dist/modifiers/textConverter.js +12 -1
- package/dist/modifiers/themeComponent.js +11 -1
- package/dist/responsive/ResponsiveHandler.js +28 -1
- package/dist/responsive/index.js +2 -1
- package/dist/responsive/responsiveHooks.js +67 -1
- package/dist/theme/ThemeHandler.js +81 -1
- package/dist/theme/default/base.js +95 -1
- package/dist/theme/default/blackTheme.js +47 -1
- package/dist/theme/default/cyberpunkTheme.js +36 -1
- package/dist/theme/default/darkTheme.js +35 -1
- package/dist/theme/default/hackerTheme.js +55 -1
- package/dist/theme/default/lightTheme.js +35 -1
- package/dist/theme/default/paperTheme.js +36 -1
- package/dist/theme/default/themes.js +15 -1
- package/dist/theme/format/colorsVariations.js +31 -1
- package/dist/theme/format/formatTheme.js +28 -1
- package/dist/theme/helpers/colorScale.js +12 -1
- package/dist/theme/helpers/contrastColor.js +18 -1
- package/dist/theme/helpers/dynamicColor.js +32 -1
- package/dist/theme/helpers/mergePreset.js +7 -1
- package/dist/theme/helpers/relatedScales.js +34 -1
- package/dist/theme/helpers/sizeScale.js +20 -1
- package/dist/theme/helpers/textScale.js +15 -1
- package/dist/theme/index.js +2 -1
- package/package.json +1 -3
- package/src/abstractions/Icon.js +1 -1
- package/src/abstractions/TextInput.js +10 -1
- package/src/components/actions/ActionsDrawer.js +1 -1
- package/src/components/actions/Button.js +3 -1
- package/src/components/actions/FloatingMenu.js +1 -1
- package/src/components/actions/menu/HorizontalMenu.js +2 -1
- package/src/components/actions/menu/VerticalMenu.js +2 -1
- package/src/components/filter/DateFilter.js +72 -0
- package/src/components/filter/FilterGroup.js +17 -0
- package/src/components/filter/FilterHandler.js +54 -0
- package/src/components/filter/FilterItem.js +30 -0
- package/src/components/filter/PopoverFilterItem.js +84 -0
- package/src/components/filter/SearchInput.js +49 -0
- package/src/components/filter/index.js +6 -0
- package/src/components/form/Form.js +9 -3
- package/src/components/form/FormItem.js +26 -1
- package/src/components/form/FormWrapperComponent.js +12 -3
- package/src/components/form/useNewForm.js +55 -4
- package/src/components/helpers/Separator.js +15 -11
- package/src/components/helpers/index.js +1 -0
- package/src/components/index.js +2 -0
- package/src/components/inputs/BooleanSelect.js +14 -0
- package/src/components/inputs/DateInput.js +3 -1
- package/src/components/inputs/DateRangeInput.js +41 -0
- package/src/components/inputs/Editable.js +129 -0
- package/src/components/inputs/EnabledSelect.js +14 -0
- package/src/components/inputs/InputWrapper.js +7 -4
- package/src/components/inputs/NumberInput.js +10 -5
- package/src/components/inputs/NumberRangeInput.js +41 -0
- package/src/components/inputs/PasswordInput.js +24 -0
- package/src/components/inputs/Picker.js +2 -2
- package/src/components/inputs/Select.js +61 -47
- package/src/components/inputs/TextArea.js +5 -0
- package/src/components/inputs/TextInput.js +14 -4
- package/src/components/inputs/UploadInput.js +140 -0
- package/src/components/inputs/index.js +9 -0
- package/src/components/inputs/upload/Upload.js +99 -0
- package/src/components/inputs/upload/Upload.native.js +154 -0
- package/src/components/inputs/upload/useUploadState.js +143 -0
- package/src/components/layout/LayoutHeader.js +1 -0
- package/src/components/presentation/AvatarLabel.js +1 -1
- package/src/components/presentation/AvatarsGroup.js +30 -0
- package/src/components/presentation/Badge.js +3 -2
- package/src/components/presentation/ContentLabel.js +1 -1
- package/src/components/presentation/IconLabel.js +1 -0
- package/src/components/presentation/Progress.js +20 -0
- package/src/components/presentation/index.js +2 -0
- package/src/components/sections/Section.js +1 -1
- package/src/components/sections/SectionItemLink.js +4 -2
- package/src/components/steps/ActiveStepContent.js +16 -0
- package/src/components/steps/StepsHandler.js +53 -0
- package/src/components/steps/StepsMenu.js +14 -0
- package/src/components/steps/StepsNavigation.js +37 -0
- package/src/components/steps/index.js +4 -0
- package/src/components/structure/Affix.js +34 -0
- package/src/components/structure/Affix.native.js +3 -0
- package/src/components/structure/Card.js +1 -0
- package/src/components/structure/TopBar.js +13 -1
- package/src/components/structure/index.js +1 -0
- package/src/components/structure/overlay/OverlayHandler.js +9 -1
- package/src/components/structure/popover/Popover.js +22 -5
- package/src/components/table/DataTable.js +7 -2
- package/src/components/table/Table.js +2 -1
- package/src/components/tabs/ActiveTabContent.js +4 -1
- package/src/components/text/DateText.js +15 -2
- package/src/modifiers/border.js +15 -9
- package/src/modifiers/size.js +8 -5
- package/src/theme/default/base.js +2 -0
- package/src/theme/default/hackerTheme.js +1 -10
- package/src/theme/default/paperTheme.js +1 -14
|
@@ -27,6 +27,7 @@ export function InputWrapper({
|
|
|
27
27
|
suffixIconColor,
|
|
28
28
|
loading,
|
|
29
29
|
error,
|
|
30
|
+
multiline,
|
|
30
31
|
children,
|
|
31
32
|
ref,
|
|
32
33
|
...rootProps
|
|
@@ -63,7 +64,9 @@ export function InputWrapper({
|
|
|
63
64
|
return (
|
|
64
65
|
<View
|
|
65
66
|
className="neko-input-wrapper"
|
|
66
|
-
height={size}
|
|
67
|
+
height={multiline ? undefined : size}
|
|
68
|
+
minHeight={multiline ? size : undefined}
|
|
69
|
+
paddingV={multiline ? 'sm' : undefined}
|
|
67
70
|
onPress={handlePress}
|
|
68
71
|
borderColor={borderColor}
|
|
69
72
|
onMouseEnter={() => setHover(true)}
|
|
@@ -71,17 +74,17 @@ export function InputWrapper({
|
|
|
71
74
|
{...props}
|
|
72
75
|
>
|
|
73
76
|
{!!prefix && (
|
|
74
|
-
<View paddingV={5} fullHeight center>
|
|
77
|
+
<View paddingV={5} fullHeight={!multiline} center={!multiline}>
|
|
75
78
|
{prefix}
|
|
76
79
|
</View>
|
|
77
80
|
)}
|
|
78
81
|
|
|
79
|
-
<View flex fullH>
|
|
82
|
+
<View flex fullH={!multiline}>
|
|
80
83
|
{childWithProps}
|
|
81
84
|
</View>
|
|
82
85
|
|
|
83
86
|
{!!suffix && (
|
|
84
|
-
<View paddingV={5} fullHeight center>
|
|
87
|
+
<View paddingV={5} fullHeight={!multiline} center={!multiline}>
|
|
85
88
|
{suffix}
|
|
86
89
|
</View>
|
|
87
90
|
)}
|
|
@@ -73,7 +73,8 @@ export function formatNumericValue(newValue, prevValue, options = {}) {
|
|
|
73
73
|
return numericValue
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export function NumberInput({ onChange, onBlur, value, useInt, precision, min, max, error, ...props }) {
|
|
76
|
+
export function NumberInput({ onChange, onBlur, value, defaultValue, useInt, precision, min, max, error, ...props }) {
|
|
77
|
+
if (value === undefined || value === null) value = defaultValue ?? null
|
|
77
78
|
const [hasError, setHasError] = React.useState(false)
|
|
78
79
|
const [inputValue, setInputValue] = React.useState(value)
|
|
79
80
|
const [localValue, setLocalValue] = React.useState(value)
|
|
@@ -81,7 +82,8 @@ export function NumberInput({ onChange, onBlur, value, useInt, precision, min, m
|
|
|
81
82
|
|
|
82
83
|
if (useInt) precision = 0
|
|
83
84
|
if (!useInt && precision === 0) useInt = true
|
|
84
|
-
const opts = { useInt, precision
|
|
85
|
+
const opts = { useInt, precision }
|
|
86
|
+
const optsWithMinMax = { ...opts, min, max }
|
|
85
87
|
|
|
86
88
|
return (
|
|
87
89
|
<TextInput
|
|
@@ -91,11 +93,14 @@ export function NumberInput({ onChange, onBlur, value, useInt, precision, min, m
|
|
|
91
93
|
setInputValue(newValue?.toString() || '')
|
|
92
94
|
setLocalValue(numericValue)
|
|
93
95
|
onChange?.(numericValue)
|
|
94
|
-
setHasError(!isValidNumber(newValue,
|
|
96
|
+
setHasError(!isValidNumber(newValue, optsWithMinMax))
|
|
95
97
|
}}
|
|
96
98
|
onBlur={(e) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
const clamped = formatNumericValue(localValue, localValue, optsWithMinMax)
|
|
100
|
+
setLocalValue(clamped)
|
|
101
|
+
setInputValue(clamped?.toString() || '')
|
|
102
|
+
setHasError(!isValidNumber(clamped, optsWithMinMax))
|
|
103
|
+
onChange?.(clamped)
|
|
99
104
|
onBlur?.(e)
|
|
100
105
|
}}
|
|
101
106
|
value={inputValue}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { NumberInput } from './NumberInput'
|
|
2
|
+
import { Text } from '../text/Text'
|
|
3
|
+
import { View } from '../structure/View'
|
|
4
|
+
|
|
5
|
+
export function NumberRangeInput({
|
|
6
|
+
value,
|
|
7
|
+
onChange,
|
|
8
|
+
minProps,
|
|
9
|
+
maxProps,
|
|
10
|
+
placeholderMin = 'Min',
|
|
11
|
+
placeholderMax = 'Max',
|
|
12
|
+
separator = '–',
|
|
13
|
+
...props
|
|
14
|
+
}) {
|
|
15
|
+
const handleChangeMin = (min) => onChange?.({ ...value, min })
|
|
16
|
+
const handleChangeMax = (max) => onChange?.({ ...value, max })
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<View row centerV gap="sm">
|
|
20
|
+
<NumberInput
|
|
21
|
+
placeholder={placeholderMin}
|
|
22
|
+
value={value?.min}
|
|
23
|
+
onChange={handleChangeMin}
|
|
24
|
+
max={value?.max}
|
|
25
|
+
flex
|
|
26
|
+
{...props}
|
|
27
|
+
{...minProps}
|
|
28
|
+
/>
|
|
29
|
+
<Text text4>{separator}</Text>
|
|
30
|
+
<NumberInput
|
|
31
|
+
placeholder={placeholderMax}
|
|
32
|
+
value={value?.max}
|
|
33
|
+
onChange={handleChangeMax}
|
|
34
|
+
min={value?.min}
|
|
35
|
+
flex
|
|
36
|
+
{...props}
|
|
37
|
+
{...maxProps}
|
|
38
|
+
/>
|
|
39
|
+
</View>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { Icon } from '../presentation/Icon'
|
|
4
|
+
import { Link } from '../actions/Link'
|
|
5
|
+
import { TextInput } from './TextInput'
|
|
6
|
+
|
|
7
|
+
export function PasswordInput({ hideToggle, suffix, ...props }) {
|
|
8
|
+
const [visible, setVisible] = React.useState(false)
|
|
9
|
+
|
|
10
|
+
const toggle = !hideToggle ? (
|
|
11
|
+
<Link onPress={() => setVisible((v) => !v)}>
|
|
12
|
+
<Icon name={visible ? 'RiEyeOffLine' : 'RiEyeLine'} color="text3" />
|
|
13
|
+
</Link>
|
|
14
|
+
) : null
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<TextInput
|
|
18
|
+
type={visible ? 'text' : 'password'}
|
|
19
|
+
secureTextEntry={!visible}
|
|
20
|
+
suffix={suffix || toggle}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -10,13 +10,13 @@ import { normalizeString } from '../../helpers/string'
|
|
|
10
10
|
import { useOptions } from '../../helpers/options'
|
|
11
11
|
|
|
12
12
|
export function getOption(options, value, config = {}) {
|
|
13
|
-
if (!options
|
|
13
|
+
if (!Array.isArray(options) || !options.length) return value
|
|
14
14
|
const option = options.find((option) => compareOptionsValues(option, value, config))
|
|
15
15
|
return option || value
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function getOptionLabel(options, value, config = {}) {
|
|
19
|
-
if (!options
|
|
19
|
+
if (!Array.isArray(options) || !options.length) return ''
|
|
20
20
|
const { labelKey } = config
|
|
21
21
|
const selectedOption = getOption(options, value, config)
|
|
22
22
|
const label = selectedOption?.[labelKey] || value
|
|
@@ -40,6 +40,8 @@ export function Select({
|
|
|
40
40
|
popoverProps,
|
|
41
41
|
popoverMaxHeight,
|
|
42
42
|
snapPoints,
|
|
43
|
+
startsOpen,
|
|
44
|
+
onOpenChange,
|
|
43
45
|
...props
|
|
44
46
|
}) {
|
|
45
47
|
const [focus, setFocus] = React.useState(false)
|
|
@@ -70,7 +72,7 @@ export function Select({
|
|
|
70
72
|
|
|
71
73
|
useBottomDrawer = useResponsiveValue(useBottomDrawer)
|
|
72
74
|
|
|
73
|
-
value = value
|
|
75
|
+
value = value ?? localValue
|
|
74
76
|
|
|
75
77
|
const handleChange = React.useCallback(
|
|
76
78
|
(value, option) => {
|
|
@@ -117,6 +119,11 @@ export function Select({
|
|
|
117
119
|
return (
|
|
118
120
|
<Popover
|
|
119
121
|
trigger="click"
|
|
122
|
+
startsOpen={startsOpen}
|
|
123
|
+
onOpenChange={(open) => {
|
|
124
|
+
if (open) handleChangeSearch('')
|
|
125
|
+
onOpenChange?.(open)
|
|
126
|
+
}}
|
|
120
127
|
placement={placement || 'bottomLeft'}
|
|
121
128
|
snapPoints={snapPoints || [450]}
|
|
122
129
|
useBottomDrawer={useBottomDrawer}
|
|
@@ -127,52 +134,59 @@ export function Select({
|
|
|
127
134
|
maxHeight={popoverMaxHeight}
|
|
128
135
|
{...popoverProps}
|
|
129
136
|
renderContent={({ onClose }) => (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
137
|
+
<Picker
|
|
138
|
+
row={false}
|
|
139
|
+
options={searchOptions(options, search, { labelKey })}
|
|
140
|
+
value={value}
|
|
141
|
+
gap={0}
|
|
142
|
+
maxHeight={!useBottomDrawer && popoverMaxHeight}
|
|
143
|
+
useFlatList
|
|
144
|
+
onlyOnScreen
|
|
145
|
+
itemMinHeight={30}
|
|
146
|
+
onChange={(v, option) => {
|
|
147
|
+
handleChange(v, option)
|
|
148
|
+
if (!multiple) {
|
|
149
|
+
setFocus(false)
|
|
150
|
+
onClose()
|
|
151
|
+
}
|
|
152
|
+
}}
|
|
153
|
+
{...pickerProps}
|
|
154
|
+
renderHeader={
|
|
155
|
+
useBottomDrawer && useSearch
|
|
156
|
+
? () => (
|
|
157
|
+
<>
|
|
158
|
+
<View padding="md" paddingB="xs">
|
|
159
|
+
<TextInput
|
|
160
|
+
prefixIcon="search-line"
|
|
161
|
+
prefixIconColor="text4"
|
|
162
|
+
value={search}
|
|
163
|
+
onChange={handleChangeSearch}
|
|
164
|
+
/>
|
|
165
|
+
</View>
|
|
166
|
+
{renderHeader?.()}
|
|
167
|
+
</>
|
|
168
|
+
)
|
|
169
|
+
: renderHeader
|
|
170
|
+
}
|
|
171
|
+
renderOption={({ option, selected, onChange }) => (
|
|
172
|
+
<Link
|
|
173
|
+
row
|
|
174
|
+
paddingH={useBottomDrawer ? 'md' : 'sm'}
|
|
175
|
+
paddingV="xs"
|
|
176
|
+
minHeight={useBottomDrawer ? 'xl' : 'md'}
|
|
177
|
+
gap="sm"
|
|
178
|
+
onMouseDown={(e) => !!multiple && e.preventDefault()}
|
|
179
|
+
onPress={onChange}
|
|
180
|
+
centerV
|
|
181
|
+
bg={selected && 'primary_op10'}
|
|
182
|
+
>
|
|
183
|
+
<View flex row>
|
|
184
|
+
{finalRenderOption({ option, labelKey, selected })}
|
|
185
|
+
</View>
|
|
186
|
+
{selected && <Icon name="checkbox-circle-fill" primary />}
|
|
187
|
+
</Link>
|
|
188
|
+
)}
|
|
189
|
+
/>
|
|
176
190
|
)}
|
|
177
191
|
>
|
|
178
192
|
<Input
|
|
@@ -2,21 +2,31 @@ import { AbsTextInput } from '../../abstractions/TextInput'
|
|
|
2
2
|
import { InputWrapper } from './InputWrapper'
|
|
3
3
|
import { useColors } from '../../theme/ThemeHandler'
|
|
4
4
|
|
|
5
|
-
export function TextInput({ onChange, ...props }) {
|
|
5
|
+
export function TextInput({ onChange, multiline, rows, ...props }) {
|
|
6
6
|
const colors = useColors()
|
|
7
7
|
|
|
8
8
|
const STYLE = {
|
|
9
9
|
width: '100%',
|
|
10
|
-
height: '100%',
|
|
11
10
|
borderWidth: 0,
|
|
12
11
|
background: 'transparent',
|
|
13
12
|
outline: 'none',
|
|
14
13
|
color: colors.text,
|
|
14
|
+
// fontFamily: 'inherit',
|
|
15
|
+
// fontSize: 'inherit',
|
|
16
|
+
// lineHeight: 'inherit',
|
|
17
|
+
...(multiline ? { resize: 'none' } : { height: '100%' }),
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
return (
|
|
18
|
-
<InputWrapper {...props}>
|
|
19
|
-
<AbsTextInput
|
|
21
|
+
<InputWrapper {...props} multiline={multiline}>
|
|
22
|
+
<AbsTextInput
|
|
23
|
+
style={STYLE}
|
|
24
|
+
placeholderTextColor={colors.text_op30}
|
|
25
|
+
{...props}
|
|
26
|
+
multiline={multiline}
|
|
27
|
+
rows={rows}
|
|
28
|
+
onChange={onChange}
|
|
29
|
+
/>
|
|
20
30
|
</InputWrapper>
|
|
21
31
|
)
|
|
22
32
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Icon, Image } from '../presentation'
|
|
2
|
+
import { Link } from '../actions'
|
|
3
|
+
import { LinkInput } from './LinkInput'
|
|
4
|
+
import { Loading } from '../state'
|
|
5
|
+
import { Text } from '../text'
|
|
6
|
+
import { Upload } from './upload/Upload'
|
|
7
|
+
import { View } from '../structure'
|
|
8
|
+
|
|
9
|
+
function FilePreview({ value, ...props }) {
|
|
10
|
+
const isImage = value.type?.startsWith('image/')
|
|
11
|
+
if (!isImage) {
|
|
12
|
+
return (
|
|
13
|
+
<View {...props} bg="text4_op10" center>
|
|
14
|
+
<Icon name="file-line" />
|
|
15
|
+
</View>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
return <Image src={value?.uri || value?.url} {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function ListItem({ value, remove, ...props }) {
|
|
22
|
+
const isDone = !value?.status || value?.status !== 'uploading'
|
|
23
|
+
const loading = value?.status === 'uploading'
|
|
24
|
+
const hasError = value?.status === 'error'
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<View row gap="sm" centerV border br="md" paddingR="md">
|
|
28
|
+
<FilePreview value={value} width={50} height={50} br="md" />
|
|
29
|
+
<Text label={value.name} flex />
|
|
30
|
+
{hasError && <Text label="Error" sm red />}
|
|
31
|
+
{loading && <Loading />}
|
|
32
|
+
{isDone && (
|
|
33
|
+
<Link onPress={() => remove(value)} padding="xs">
|
|
34
|
+
<Icon name="delete-bin-2-line" red xs />
|
|
35
|
+
</Link>
|
|
36
|
+
)}
|
|
37
|
+
</View>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function GridItem({ value, remove }) {
|
|
42
|
+
const loading = value?.status === 'uploading'
|
|
43
|
+
const hasError = value?.status === 'error'
|
|
44
|
+
const isDone = !value?.status || value?.status !== 'uploading'
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View width={80} height={80} br="md" hiddenOverflow relative>
|
|
48
|
+
<FilePreview value={value} width={80} height={80} br="md" />
|
|
49
|
+
<View absolute top={0} right={0}>
|
|
50
|
+
{loading && (
|
|
51
|
+
<View center bg="backdrop_op70" br="md" padding="xs">
|
|
52
|
+
<Loading sm />
|
|
53
|
+
</View>
|
|
54
|
+
)}
|
|
55
|
+
{hasError && (
|
|
56
|
+
<View center bg="backdrop_op70" br="md" padding="xs">
|
|
57
|
+
<Icon name="error-warning-line" red />
|
|
58
|
+
</View>
|
|
59
|
+
)}
|
|
60
|
+
{isDone && (
|
|
61
|
+
<Link onPress={() => remove(value)} bg="backdrop_op70" padding="xs">
|
|
62
|
+
<Icon name="delete-bin-2-line" xxs red />
|
|
63
|
+
</Link>
|
|
64
|
+
)}
|
|
65
|
+
</View>
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function AddTile({ isDragging, ...props }) {
|
|
71
|
+
return (
|
|
72
|
+
<Link
|
|
73
|
+
center
|
|
74
|
+
width={80}
|
|
75
|
+
height={80}
|
|
76
|
+
border
|
|
77
|
+
borderStyle="dashed"
|
|
78
|
+
br="md"
|
|
79
|
+
bg={isDragging ? 'primary_op10' : 'transparent'}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<Icon name="add-line" />
|
|
83
|
+
</Link>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function DropArea({ placeholder, isDragging, ...props }) {
|
|
88
|
+
return (
|
|
89
|
+
<Link
|
|
90
|
+
center
|
|
91
|
+
gap="sm"
|
|
92
|
+
border
|
|
93
|
+
borderStyle="dashed"
|
|
94
|
+
padding="md"
|
|
95
|
+
minH={160}
|
|
96
|
+
br="md"
|
|
97
|
+
bg={isDragging ? 'primary_op10' : 'transparent'}
|
|
98
|
+
{...props}
|
|
99
|
+
>
|
|
100
|
+
<Icon name="upload-cloud-2-line" />
|
|
101
|
+
<Text label={placeholder} text4 center />
|
|
102
|
+
</Link>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Content({ value, open, remove, isDragging, multiple, area, grid, maxCount, ...props }) {
|
|
107
|
+
const items = multiple ? value || [] : value ? [value] : []
|
|
108
|
+
const showAdd = multiple ? !maxCount || items.length < maxCount : !value
|
|
109
|
+
|
|
110
|
+
if (grid) {
|
|
111
|
+
return (
|
|
112
|
+
<View row wrap gap="sm">
|
|
113
|
+
{items.map((item) => (
|
|
114
|
+
<GridItem key={item._id} value={item} remove={remove} />
|
|
115
|
+
))}
|
|
116
|
+
{showAdd && <AddTile onPress={open} isDragging={isDragging} />}
|
|
117
|
+
</View>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const placeholder = 'Upload file'
|
|
122
|
+
const link = area ? (
|
|
123
|
+
<DropArea onPress={open} placeholder={placeholder} isDragging={isDragging} {...props} />
|
|
124
|
+
) : (
|
|
125
|
+
<LinkInput onPress={open} prefixIcon="upload-cloud-2-line" placeholder={placeholder} {...props} />
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<View gap="xs">
|
|
130
|
+
{showAdd && link}
|
|
131
|
+
{items.map((item) => (
|
|
132
|
+
<ListItem key={item._id} value={item} remove={remove} />
|
|
133
|
+
))}
|
|
134
|
+
</View>
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function UploadInput({ ...props }) {
|
|
139
|
+
return <Upload {...props}>{(params) => <Content {...props} {...params} />}</Upload>
|
|
140
|
+
}
|
|
@@ -3,12 +3,21 @@ export * from './Radio'
|
|
|
3
3
|
export * from './Switch'
|
|
4
4
|
export * from './InputWrapper'
|
|
5
5
|
export * from './TextInput'
|
|
6
|
+
export * from './PasswordInput'
|
|
7
|
+
export * from './TextArea'
|
|
6
8
|
export * from './NumberInput'
|
|
9
|
+
export * from './NumberRangeInput'
|
|
7
10
|
export * from './LinkInput'
|
|
8
11
|
export * from './MaskInput'
|
|
9
12
|
export * from './DateInput'
|
|
13
|
+
export * from './DateRangeInput'
|
|
10
14
|
export * from './datePicker/DatePicker'
|
|
11
15
|
export * from './Picker'
|
|
12
16
|
export * from './Select'
|
|
17
|
+
export * from './BooleanSelect'
|
|
18
|
+
export * from './EnabledSelect'
|
|
13
19
|
export * from './RateInput'
|
|
14
20
|
export * from './SegmentedPicker'
|
|
21
|
+
export * from './Editable'
|
|
22
|
+
export * from './upload/Upload'
|
|
23
|
+
export * from './UploadInput'
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useRef, useState, useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
import { View } from '../../structure/View'
|
|
4
|
+
import { useUploadState } from './useUploadState'
|
|
5
|
+
|
|
6
|
+
function normalizeFile(file) {
|
|
7
|
+
return {
|
|
8
|
+
uri: URL.createObjectURL(file),
|
|
9
|
+
name: file.name,
|
|
10
|
+
type: file.type,
|
|
11
|
+
size: file.size,
|
|
12
|
+
file,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function Upload({ children, onChange, onUpload, value: valueProp, accept, multiple = false, maxCount, disabled = false, dnd = true, ...props }) {
|
|
17
|
+
const { value, addFiles, remove } = useUploadState({ onUpload, onChange, multiple, maxCount, value: valueProp })
|
|
18
|
+
const inputRef = useRef()
|
|
19
|
+
const [isDragging, setIsDragging] = useState(false)
|
|
20
|
+
const dragCounter = useRef(0)
|
|
21
|
+
|
|
22
|
+
const handleClick = useCallback(() => {
|
|
23
|
+
if (disabled) return
|
|
24
|
+
inputRef.current?.click()
|
|
25
|
+
}, [disabled])
|
|
26
|
+
|
|
27
|
+
const handleInputChange = useCallback(
|
|
28
|
+
(e) => {
|
|
29
|
+
const files = e.target.files
|
|
30
|
+
if (!files?.length) return
|
|
31
|
+
addFiles(Array.from(files).map(normalizeFile))
|
|
32
|
+
e.target.value = ''
|
|
33
|
+
},
|
|
34
|
+
[addFiles]
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const handleDragEnter = useCallback(
|
|
38
|
+
(e) => {
|
|
39
|
+
if (!dnd || disabled) return
|
|
40
|
+
e.preventDefault()
|
|
41
|
+
e.stopPropagation()
|
|
42
|
+
dragCounter.current++
|
|
43
|
+
if (dragCounter.current === 1) setIsDragging(true)
|
|
44
|
+
},
|
|
45
|
+
[dnd, disabled]
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const handleDragOver = useCallback(
|
|
49
|
+
(e) => {
|
|
50
|
+
if (!dnd || disabled) return
|
|
51
|
+
e.preventDefault()
|
|
52
|
+
e.stopPropagation()
|
|
53
|
+
},
|
|
54
|
+
[dnd, disabled]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
const handleDragLeave = useCallback(
|
|
58
|
+
(e) => {
|
|
59
|
+
if (!dnd || disabled) return
|
|
60
|
+
e.preventDefault()
|
|
61
|
+
e.stopPropagation()
|
|
62
|
+
dragCounter.current--
|
|
63
|
+
if (dragCounter.current === 0) setIsDragging(false)
|
|
64
|
+
},
|
|
65
|
+
[dnd, disabled]
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
const handleDrop = useCallback(
|
|
69
|
+
(e) => {
|
|
70
|
+
if (!dnd || disabled) return
|
|
71
|
+
e.preventDefault()
|
|
72
|
+
e.stopPropagation()
|
|
73
|
+
dragCounter.current = 0
|
|
74
|
+
setIsDragging(false)
|
|
75
|
+
const files = e.dataTransfer?.files
|
|
76
|
+
if (!files?.length) return
|
|
77
|
+
addFiles(Array.from(files).map(normalizeFile))
|
|
78
|
+
},
|
|
79
|
+
[dnd, disabled, addFiles]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const dndHandlers = dnd
|
|
83
|
+
? {
|
|
84
|
+
onDragEnter: handleDragEnter,
|
|
85
|
+
onDragOver: handleDragOver,
|
|
86
|
+
onDragLeave: handleDragLeave,
|
|
87
|
+
onDrop: handleDrop,
|
|
88
|
+
}
|
|
89
|
+
: {}
|
|
90
|
+
|
|
91
|
+
const isRenderFn = typeof children === 'function'
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<View onPress={!isRenderFn && !disabled ? handleClick : undefined} pointer={!isRenderFn && !disabled} {...dndHandlers} {...props}>
|
|
95
|
+
{isRenderFn ? children({ value, remove, isDragging, open: handleClick }) : children}
|
|
96
|
+
<input ref={inputRef} type="file" style={{ display: 'none' }} accept={accept} multiple={multiple} onChange={handleInputChange} />
|
|
97
|
+
</View>
|
|
98
|
+
)
|
|
99
|
+
}
|