@momo-kits/native-kits 0.157.1-beta.9 → 0.157.1-com.1-debug
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/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +180 -0
- package/compose/build.gradle.kts.backup +180 -0
- package/compose/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +110 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +107 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +448 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +350 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +360 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +449 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +185 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +119 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +98 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +161 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +331 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +497 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +149 -0
- package/gradle/libs.versions.toml +57 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Input/Input.swift +4 -0
- package/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +52 -0
- package/src/doctor/README.md +73 -0
- package/src/doctor/package-lock.json +885 -0
- package/src/doctor/package.json +44 -0
- package/src/doctor/publish.sh +27 -0
- package/src/doctor/src/Users.json +112 -0
- package/src/doctor/src/Whitelist.json +6 -0
- package/src/doctor/src/commands/check.ts +81 -0
- package/src/doctor/src/commands/doctor.ts +193 -0
- package/src/doctor/src/index.ts +35 -0
- package/src/doctor/src/logger.ts +84 -0
- package/src/doctor/src/task/native.ts +21 -0
- package/src/doctor/src/task/utils.ts +20 -0
- package/src/doctor/src/utils/checkCoreDependencies.ts +138 -0
- package/src/doctor/src/utils/checkDeletedPackage.ts +53 -0
- package/src/doctor/src/utils/checkDeprecatedPackages.ts +168 -0
- package/src/doctor/src/utils/checkDeprecatedVersion.ts +60 -0
- package/src/doctor/src/utils/checkShareDependencies.ts +251 -0
- package/src/doctor/src/utils/checkWrongVersionCommunityPackage.ts +64 -0
- package/src/doctor/src/utils/getErrorMessage.ts +84 -0
- package/src/doctor/src/utils/scanComponentUsage.ts +206 -0
- package/src/doctor/src/utils/scanFoundationImports.ts +169 -0
- package/src/doctor/src/utils/scanMaxApiUsage.ts +86 -0
- package/src/doctor/src/utils/scanNativeModulesUsage.ts +78 -0
- package/src/doctor/src/utils/sendMessage.ts +28 -0
- package/src/doctor/tsconfig.json +14 -0
- package/src/doctor/yarn.lock +492 -0
- package/src/foundations/Application/BottomSheet.tsx +358 -0
- package/src/foundations/Application/BottomTab/BottomTabBar.tsx +320 -0
- package/src/foundations/Application/BottomTab/CustomBottomTabItem.tsx +155 -0
- package/src/foundations/Application/BottomTab/TabBarIcon.tsx +113 -0
- package/src/foundations/Application/BottomTab/index.tsx +449 -0
- package/src/foundations/Application/Components/BackgroundImageView.tsx +126 -0
- package/src/foundations/Application/Components/HeaderAnimated.tsx +69 -0
- package/src/foundations/Application/Components/HeaderBackground.tsx +83 -0
- package/src/foundations/Application/Components/HeaderExtendHeader.tsx +225 -0
- package/src/foundations/Application/Components/HeaderLeft.tsx +93 -0
- package/src/foundations/Application/Components/HeaderRight.tsx +444 -0
- package/src/foundations/Application/Components/HeaderTitle.tsx +596 -0
- package/src/foundations/Application/Components/NavigationButton.tsx +76 -0
- package/src/foundations/Application/Components/SearchHeader.tsx +127 -0
- package/src/foundations/Application/Localize.ts +44 -0
- package/src/foundations/Application/ModalScreen.tsx +148 -0
- package/src/foundations/Application/Navigation.ts +63 -0
- package/src/foundations/Application/NavigationContainer.tsx +245 -0
- package/src/foundations/Application/Navigator.ts +171 -0
- package/src/foundations/Application/ScaleSizeProvider.tsx +16 -0
- package/src/foundations/Application/StackScreen.tsx +420 -0
- package/src/foundations/Application/TooltipPortal.tsx +127 -0
- package/src/foundations/Application/WidgetContainer.tsx +162 -0
- package/src/foundations/Application/index.ts +34 -0
- package/src/foundations/Application/types.ts +350 -0
- package/src/foundations/Application/utils.tsx +239 -0
- package/src/foundations/Assets/DotAnimation.json +256 -0
- package/src/foundations/Assets/SpinnerAnimation.json +1027 -0
- package/src/foundations/Assets/icon.json +4052 -0
- package/src/foundations/Assets/icon_bank.json +506 -0
- package/src/foundations/Assets/language.json +208 -0
- package/src/foundations/Assets/lottie_circle_loader.json +1 -0
- package/src/foundations/Assets/pinAnimation.json +1 -0
- package/src/foundations/Assets/unpinAnimation.json +1 -0
- package/src/foundations/Badge/Badge.tsx +104 -0
- package/src/foundations/Badge/BadgeDot.tsx +35 -0
- package/src/foundations/Badge/BadgeDotAnimation.tsx +95 -0
- package/src/foundations/Badge/BadgeRibbon.tsx +112 -0
- package/src/foundations/Badge/Shape.tsx +29 -0
- package/src/foundations/Badge/index.tsx +8 -0
- package/src/foundations/Badge/styles.ts +125 -0
- package/src/foundations/Badge/types.ts +68 -0
- package/src/foundations/Button/index.tsx +371 -0
- package/src/foundations/Button/styles.ts +65 -0
- package/src/foundations/CheckBox/index.tsx +104 -0
- package/src/foundations/CheckBox/styles.ts +17 -0
- package/src/foundations/CheckBox/types.ts +37 -0
- package/src/foundations/Consts/colors+spacing+radius.ts +232 -0
- package/src/foundations/Consts/index.ts +4 -0
- package/src/foundations/Consts/styles.ts +52 -0
- package/src/foundations/Consts/theme.ts +121 -0
- package/src/foundations/Context/index.ts +27 -0
- package/src/foundations/Divider/DashDivider.tsx +46 -0
- package/src/foundations/Divider/index.tsx +45 -0
- package/src/foundations/FoundationList/index.tsx +12 -0
- package/src/foundations/FoundationList/types.ts +7 -0
- package/src/foundations/Icon/index.tsx +57 -0
- package/src/foundations/Icon/types.ts +32 -0
- package/src/foundations/IconButton/index.tsx +144 -0
- package/src/foundations/IconButton/styles.ts +20 -0
- package/src/foundations/Image/index.tsx +115 -0
- package/src/foundations/Image/styles.ts +7 -0
- package/src/foundations/Image/types.ts +7 -0
- package/src/foundations/Input/Input.tsx +280 -0
- package/src/foundations/Input/InputDropDown.tsx +161 -0
- package/src/foundations/Input/InputMoney.tsx +325 -0
- package/src/foundations/Input/InputOTP.tsx +299 -0
- package/src/foundations/Input/InputPhoneNumber.tsx +287 -0
- package/src/foundations/Input/InputSearch.tsx +351 -0
- package/src/foundations/Input/InputTextArea.tsx +218 -0
- package/src/foundations/Input/SystemTextInput.tsx +44 -0
- package/src/foundations/Input/TextTyping.tsx +115 -0
- package/src/foundations/Input/common.tsx +243 -0
- package/src/foundations/Input/index.tsx +373 -0
- package/src/foundations/Input/styles.ts +226 -0
- package/src/foundations/Input/utils.ts +97 -0
- package/src/foundations/Layout/Card.tsx +108 -0
- package/src/foundations/Layout/FloatingButton.tsx +179 -0
- package/src/foundations/Layout/GridSystem.tsx +137 -0
- package/src/foundations/Layout/Item.tsx +59 -0
- package/src/foundations/Layout/ItemList.tsx +66 -0
- package/src/foundations/Layout/ItemSectionList.tsx +40 -0
- package/src/foundations/Layout/Screen.tsx +644 -0
- package/src/foundations/Layout/Section.tsx +103 -0
- package/src/foundations/Layout/TrackingScope.tsx +18 -0
- package/src/foundations/Layout/index.ts +34 -0
- package/src/foundations/Layout/styles.ts +95 -0
- package/src/foundations/Layout/types.ts +40 -0
- package/src/foundations/Layout/utils.ts +47 -0
- package/src/foundations/Loader/DotLoader.tsx +37 -0
- package/src/foundations/Loader/Loader.tsx +13 -0
- package/src/foundations/Loader/ProgressBar.tsx +45 -0
- package/src/foundations/Loader/Spinner.tsx +29 -0
- package/src/foundations/Loader/index.tsx +6 -0
- package/src/foundations/Loader/styles.ts +10 -0
- package/src/foundations/Loader/types.ts +35 -0
- package/src/foundations/Loader/utils.ts +25 -0
- package/src/foundations/Pagination/Dot.tsx +19 -0
- package/src/foundations/Pagination/PaginationDot.tsx +44 -0
- package/src/foundations/Pagination/PaginationNumber.tsx +31 -0
- package/src/foundations/Pagination/PaginationScroll.tsx +99 -0
- package/src/foundations/Pagination/PaginationWhiteDot.tsx +43 -0
- package/src/foundations/Pagination/index.tsx +25 -0
- package/src/foundations/Pagination/styles.ts +51 -0
- package/src/foundations/Pagination/types.ts +40 -0
- package/src/foundations/Popup/PopupNotify.tsx +276 -0
- package/src/foundations/Popup/PopupPromotion.tsx +118 -0
- package/src/foundations/Popup/index.tsx +4 -0
- package/src/foundations/Popup/types.ts +96 -0
- package/src/foundations/Radio/index.tsx +108 -0
- package/src/foundations/Radio/styles.ts +15 -0
- package/src/foundations/Radio/types.ts +31 -0
- package/src/foundations/Skeleton/index.tsx +118 -0
- package/src/foundations/Skeleton/styles.ts +5 -0
- package/src/foundations/Skeleton/types.ts +6 -0
- package/src/foundations/Switch/index.tsx +68 -0
- package/src/foundations/Switch/styles.ts +25 -0
- package/src/foundations/Switch/types.ts +19 -0
- package/src/foundations/Tag/index.tsx +128 -0
- package/src/foundations/Tag/types.ts +41 -0
- package/src/foundations/Text/index.tsx +241 -0
- package/src/foundations/Text/styles.ts +78 -0
- package/src/foundations/Text/types.ts +53 -0
- package/src/foundations/Text/utils.ts +63 -0
- package/src/foundations/Title/index.tsx +285 -0
- package/src/foundations/Title/styles.ts +55 -0
- package/src/foundations/Title/types.ts +21 -0
- package/src/foundations/index.ts +50 -0
- package/src/foundations/package.json +35 -0
- package/src/foundations/publish.sh +17 -0
- package/src/libs/AutoComplete/index.tsx +88 -0
- package/src/libs/AutoComplete/package.json +16 -0
- package/src/libs/AutoComplete/publish.sh +16 -0
- package/src/libs/AutoComplete/styles.ts +15 -0
- package/src/libs/AutoComplete/types.ts +60 -0
- package/src/libs/Avatar/index.tsx +146 -0
- package/src/libs/Avatar/package.json +16 -0
- package/src/libs/Avatar/publish.sh +20 -0
- package/src/libs/Avatar/styles.ts +18 -0
- package/src/libs/Avatar/types.ts +57 -0
- package/src/libs/Badge/Badge.tsx +70 -0
- package/src/libs/Badge/BadgeDot.tsx +11 -0
- package/src/libs/Badge/BadgeRibbon.tsx +122 -0
- package/src/libs/Badge/Shape.tsx +29 -0
- package/src/libs/Badge/index.tsx +7 -0
- package/src/libs/Badge/package.json +16 -0
- package/src/libs/Badge/publish.sh +18 -0
- package/src/libs/Badge/styles.ts +55 -0
- package/src/libs/Badge/types.ts +63 -0
- package/src/libs/Calendar/CalendarPro.tsx +307 -0
- package/src/libs/Calendar/Day.tsx +150 -0
- package/src/libs/Calendar/HeaderControl.tsx +55 -0
- package/src/libs/Calendar/LunarDateConverter.ts +228 -0
- package/src/libs/Calendar/LunarService.ts +206 -0
- package/src/libs/Calendar/Month.tsx +118 -0
- package/src/libs/Calendar/MonthList.tsx +226 -0
- package/src/libs/Calendar/TabHeader.tsx +91 -0
- package/src/libs/Calendar/Util.ts +288 -0
- package/src/libs/Calendar/holidayData.ts +118 -0
- package/src/libs/Calendar/index.tsx +383 -0
- package/src/libs/Calendar/package.json +18 -0
- package/src/libs/Calendar/publish.sh +18 -0
- package/src/libs/Calendar/styles.ts +122 -0
- package/src/libs/Calendar/types.ts +212 -0
- package/src/libs/Carousel/animation.ts +62 -0
- package/src/libs/Carousel/index.tsx +517 -0
- package/src/libs/Carousel/package.json +18 -0
- package/src/libs/Carousel/publish.sh +16 -0
- package/src/libs/Carousel/types.ts +71 -0
- package/src/libs/Chip/index.tsx +164 -0
- package/src/libs/Chip/package.json +16 -0
- package/src/libs/Chip/publish.sh +16 -0
- package/src/libs/Chip/styles.ts +20 -0
- package/src/libs/Chip/types.ts +72 -0
- package/src/libs/Collapse/index.tsx +305 -0
- package/src/libs/Collapse/package.json +16 -0
- package/src/libs/Collapse/publish.sh +18 -0
- package/src/libs/Collapse/styles.ts +37 -0
- package/src/libs/Collapse/types.ts +84 -0
- package/src/libs/DateTimePicker/WheelPicker.tsx +163 -0
- package/src/libs/DateTimePicker/WheelPickerItem.tsx +58 -0
- package/src/libs/DateTimePicker/index.tsx +188 -0
- package/src/libs/DateTimePicker/package.json +16 -0
- package/src/libs/DateTimePicker/publish.sh +17 -0
- package/src/libs/DateTimePicker/styles.ts +31 -0
- package/src/libs/DateTimePicker/types.ts +102 -0
- package/src/libs/DateTimePicker/utils.ts +114 -0
- package/src/libs/Information/index.tsx +129 -0
- package/src/libs/Information/package.json +16 -0
- package/src/libs/Information/publish.sh +18 -0
- package/src/libs/Information/styles.ts +34 -0
- package/src/libs/Information/types.ts +79 -0
- package/src/libs/Logo/index.tsx +39 -0
- package/src/libs/Logo/package.json +17 -0
- package/src/libs/Logo/publish.sh +16 -0
- package/src/libs/Logo/styles.ts +25 -0
- package/src/libs/Logo/types.ts +13 -0
- package/src/libs/ProgressInfo/ProgressInfoHorizontal.tsx +128 -0
- package/src/libs/ProgressInfo/ProgressInfoIcon.tsx +88 -0
- package/src/libs/ProgressInfo/ProgressInfoVertical.tsx +85 -0
- package/src/libs/ProgressInfo/index.tsx +22 -0
- package/src/libs/ProgressInfo/package.json +16 -0
- package/src/libs/ProgressInfo/publish.sh +16 -0
- package/src/libs/ProgressInfo/styles.ts +46 -0
- package/src/libs/ProgressInfo/types.ts +60 -0
- package/src/libs/ProgressInfo/yarn.lock +8 -0
- package/src/libs/Rating/index.tsx +74 -0
- package/src/libs/Rating/package.json +16 -0
- package/src/libs/Rating/publish.sh +18 -0
- package/src/libs/Rating/type.ts +25 -0
- package/src/libs/Slider/Label.tsx +33 -0
- package/src/libs/Slider/helpers.ts +35 -0
- package/src/libs/Slider/hooks.tsx +218 -0
- package/src/libs/Slider/index.tsx +453 -0
- package/src/libs/Slider/package.json +16 -0
- package/src/libs/Slider/publish.sh +18 -0
- package/src/libs/Slider/styles.ts +36 -0
- package/src/libs/Stepper/NumberView.tsx +64 -0
- package/src/libs/Stepper/StepperButton.tsx +37 -0
- package/src/libs/Stepper/index.tsx +139 -0
- package/src/libs/Stepper/package.json +16 -0
- package/src/libs/Stepper/publish.sh +17 -0
- package/src/libs/Stepper/styles.ts +44 -0
- package/src/libs/Stepper/types.ts +154 -0
- package/src/libs/Steps/StepIcon.tsx +86 -0
- package/src/libs/Steps/StepsHorizontal.tsx +189 -0
- package/src/libs/Steps/StepsVertical.tsx +133 -0
- package/src/libs/Steps/index.tsx +20 -0
- package/src/libs/Steps/package.json +16 -0
- package/src/libs/Steps/publish.sh +16 -0
- package/src/libs/Steps/styles.ts +46 -0
- package/src/libs/Steps/types.ts +159 -0
- package/src/libs/Steps/utils.ts +175 -0
- package/src/libs/SuggestAction/SuggestActionView.tsx +124 -0
- package/src/libs/SuggestAction/index.tsx +3 -0
- package/src/libs/SuggestAction/package.json +16 -0
- package/src/libs/SuggestAction/publish.sh +16 -0
- package/src/libs/SuggestAction/styles.ts +30 -0
- package/src/libs/SuggestAction/types.ts +36 -0
- package/src/libs/Swipe/SwipeView.tsx +151 -0
- package/src/libs/Swipe/index.tsx +5 -0
- package/src/libs/Swipe/package.json +16 -0
- package/src/libs/Swipe/publish.sh +16 -0
- package/src/libs/Swipe/styles.ts +16 -0
- package/src/libs/Swipe/types.ts +109 -0
- package/src/libs/TabView/assets/Path.tsx +29 -0
- package/src/libs/TabView/index.tsx +184 -0
- package/src/libs/TabView/package.json +16 -0
- package/src/libs/TabView/publish.sh +16 -0
- package/src/libs/TabView/styles.ts +96 -0
- package/src/libs/TabView/tabBar/CardTabBar.tsx +137 -0
- package/src/libs/TabView/tabBar/SrollableTabBar.tsx +218 -0
- package/src/libs/TabView/tabBar/TabBar.tsx +67 -0
- package/src/libs/TabView/tabItem/CardTabItem.tsx +118 -0
- package/src/libs/TabView/tabItem/TabItem.tsx +180 -0
- package/src/libs/TabView/types.ts +166 -0
- package/src/libs/Template/HeaderSliderBanner/index.tsx +86 -0
- package/src/libs/Template/HeaderSliderBanner/types.ts +16 -0
- package/src/libs/Template/TrustBanner/CustomAvatar.tsx +39 -0
- package/src/libs/Template/TrustBanner/index.tsx +161 -0
- package/src/libs/Template/TrustBanner/styles.ts +48 -0
- package/src/libs/Template/TrustBanner/types.ts +50 -0
- package/src/libs/Template/index.tsx +4 -0
- package/src/libs/Template/package.json +18 -0
- package/src/libs/Template/publish.sh +17 -0
- package/src/libs/Title/index.tsx +284 -0
- package/src/libs/Title/package.json +17 -0
- package/src/libs/Title/publish.sh +16 -0
- package/src/libs/Title/styles.ts +54 -0
- package/src/libs/Title/types.ts +21 -0
- package/src/libs/Tooltip/TooltipButtons.tsx +54 -0
- package/src/libs/Tooltip/index.tsx +608 -0
- package/src/libs/Tooltip/package.json +16 -0
- package/src/libs/Tooltip/publish.sh +18 -0
- package/src/libs/Tooltip/styles.ts +70 -0
- package/src/libs/Tooltip/types.ts +61 -0
- package/src/libs/Uploader/index.tsx +87 -0
- package/src/libs/Uploader/package.json +17 -0
- package/src/libs/Uploader/publish.sh +18 -0
- package/src/libs/Uploader/styles.ts +30 -0
- package/src/libs/Uploader/types.ts +69 -0
- package/src/native/MoMoNative.podspec +18 -0
- package/src/native/calculator/android/build.gradle +61 -0
- package/src/native/calculator/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/native/calculator/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/native/calculator/android/gradlew +172 -0
- package/src/native/calculator/android/gradlew.bat +84 -0
- package/src/native/calculator/android/src/main/AndroidManifest.xml +5 -0
- package/src/native/calculator/android/src/main/java/com/calculator/KeyboardViewModule.java +22 -0
- package/src/native/calculator/android/src/main/java/com/calculator/KeyboardViewPackage.java +35 -0
- package/src/native/calculator/android/src/main/java/com/calculator/modules/CalculatorKeyboardModule.java +157 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/CalculatorEditText.java +36 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/FixedRelativeLayout.java +45 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/MomoTextInputCalculatorManager.java +173 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/customkeyboard/RNCustomKeyboardModule.java +417 -0
- package/src/native/calculator/ios/Helper/MomoHelper.swift +16 -0
- package/src/native/calculator/ios/KeyboardView-Bridging-Header.h +60 -0
- package/src/native/calculator/ios/KeyboardView.h +19 -0
- package/src/native/calculator/ios/KeyboardView.m +56 -0
- package/src/native/calculator/ios/MomoTextInputCalculator.swift +144 -0
- package/src/native/calculator/ios/RNCustomKeyboard/RNCustomKeyboard.h +6 -0
- package/src/native/calculator/ios/RNCustomKeyboard/RNCustomKeyboard.m +143 -0
- package/src/native/package.json +14 -0
- package/src/native/publish.sh +29 -0
- package/src/native/resource/android/build.gradle +57 -0
- package/src/native/resource/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/native/resource/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/native/resource/android/src/main/AndroidManifest.xml +6 -0
- package/src/native/resource/android/src/main/java/com/resource/RNResourceModule.java +90 -0
- package/src/native/resource/android/src/main/java/com/resource/RNResourcePackage.java +22 -0
- package/src/native/resource/ios/RNResouce.m +71 -0
- package/src/native/resource/ios/RNResource.h +5 -0
- package/example/ios/Example.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
RefObject,
|
|
3
|
+
useCallback,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import {Animated} from 'react-native';
|
|
9
|
+
import {clamp} from './helpers';
|
|
10
|
+
import styles from './styles';
|
|
11
|
+
import FollowerContainer, {LabelRef} from './Label';
|
|
12
|
+
import {Spacing} from '@momo-kits/foundation';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* low and high state variables are fallbacks for props (props are not required).
|
|
16
|
+
* This hook ensures that current low and high are not out of [min, max] range.
|
|
17
|
+
* It returns an object which contains:
|
|
18
|
+
* - ref containing correct low, high, min, max and step to work with.
|
|
19
|
+
* - setLow and setHigh setters
|
|
20
|
+
* @param lowProp
|
|
21
|
+
* @param highProp
|
|
22
|
+
* @param min
|
|
23
|
+
* @param max
|
|
24
|
+
* @param step
|
|
25
|
+
* @returns {{inPropsRef: React.MutableRefObject<{high: (*|number), low: (*|number)}>, setLow: (function(number): undefined), setHigh: (function(number): undefined)}}
|
|
26
|
+
*/
|
|
27
|
+
export const useLowHigh = (
|
|
28
|
+
lowProp: number | undefined,
|
|
29
|
+
highProp: number | undefined,
|
|
30
|
+
min: number,
|
|
31
|
+
max: number,
|
|
32
|
+
step: number
|
|
33
|
+
) => {
|
|
34
|
+
const validLowProp = lowProp === undefined ? min : clamp(lowProp, min, max);
|
|
35
|
+
const validHighProp =
|
|
36
|
+
highProp === undefined ? max : clamp(highProp, min, max);
|
|
37
|
+
const inPropsRef = useRef({
|
|
38
|
+
low: validLowProp,
|
|
39
|
+
high: validHighProp,
|
|
40
|
+
step,
|
|
41
|
+
// These 2 fields will be overwritten below.
|
|
42
|
+
min: validLowProp,
|
|
43
|
+
max: validHighProp,
|
|
44
|
+
});
|
|
45
|
+
const {low: lowState, high: highState} = inPropsRef.current;
|
|
46
|
+
const inPropsRefPrev = {lowPrev: lowState, highPrev: highState};
|
|
47
|
+
|
|
48
|
+
// Props have higher priority.
|
|
49
|
+
// If no props are passed, use internal state variables.
|
|
50
|
+
const low = clamp(lowProp === undefined ? lowState : lowProp, min, max);
|
|
51
|
+
const high = clamp(highProp === undefined ? highState : highProp, min, max);
|
|
52
|
+
|
|
53
|
+
// Always update values of refs so pan responder will have updated values
|
|
54
|
+
Object.assign(inPropsRef.current, {low, high, min, max});
|
|
55
|
+
|
|
56
|
+
const setLow = (value: number) => (inPropsRef.current.low = value);
|
|
57
|
+
const setHigh = (value: number) => (inPropsRef.current.high = value);
|
|
58
|
+
return {inPropsRef, inPropsRefPrev, setLow, setHigh};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Sets the current value of widthRef and calls the callback with new width parameter.
|
|
63
|
+
* @param widthRef
|
|
64
|
+
* @param callback
|
|
65
|
+
* @returns {function({nativeEvent: *}): void}
|
|
66
|
+
*/
|
|
67
|
+
export const useWidthLayout = (
|
|
68
|
+
widthRef: RefObject<number>,
|
|
69
|
+
callback?: (width: number) => void
|
|
70
|
+
) => {
|
|
71
|
+
return useCallback(
|
|
72
|
+
({nativeEvent}: {nativeEvent: {layout: {width: number}}}) => {
|
|
73
|
+
const {
|
|
74
|
+
layout: {width},
|
|
75
|
+
} = nativeEvent;
|
|
76
|
+
const {current: w} = widthRef;
|
|
77
|
+
if (w !== width) {
|
|
78
|
+
widthRef.current = width;
|
|
79
|
+
if (callback) {
|
|
80
|
+
callback(width);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[callback, widthRef]
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* This hook creates a component which follows the thumb.
|
|
90
|
+
* Content renderer is passed to FollowerContainer which re-renders only it's content with setValue method.
|
|
91
|
+
* This allows to re-render only follower, instead of the whole slider with all children (thumb, rail, etc.).
|
|
92
|
+
* Returned update function should be called every time follower should be updated.
|
|
93
|
+
* @param containerWidthRef
|
|
94
|
+
* @param gestureStateRef
|
|
95
|
+
* @param isPressed
|
|
96
|
+
* @param allowOverflow
|
|
97
|
+
* @param disabledLow
|
|
98
|
+
* @param disabledHigh
|
|
99
|
+
* @returns {[JSX.Element, function(*, *=): void]|*[]}
|
|
100
|
+
*/
|
|
101
|
+
export const useThumbFollower = (
|
|
102
|
+
containerWidthRef: RefObject<number>,
|
|
103
|
+
gestureStateRef: RefObject<{
|
|
104
|
+
isLow: boolean;
|
|
105
|
+
lastValue: number;
|
|
106
|
+
lastPosition: number;
|
|
107
|
+
}>,
|
|
108
|
+
isPressed: boolean,
|
|
109
|
+
allowOverflow: boolean,
|
|
110
|
+
disabledLow: boolean,
|
|
111
|
+
disabledHigh: boolean
|
|
112
|
+
): [React.ReactElement, (thumbPositionInView: number, value: number) => void] => {
|
|
113
|
+
const xRef = useRef(new Animated.Value(0));
|
|
114
|
+
const widthRef = useRef(0);
|
|
115
|
+
const contentContainerRef = useRef<LabelRef>(null);
|
|
116
|
+
|
|
117
|
+
const {current: x} = xRef;
|
|
118
|
+
|
|
119
|
+
const update = useCallback(
|
|
120
|
+
(thumbPositionInView: number, value: number) => {
|
|
121
|
+
if (
|
|
122
|
+
(gestureStateRef.current.isLow && disabledLow) ||
|
|
123
|
+
(!gestureStateRef.current.isLow && disabledHigh)
|
|
124
|
+
) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const {current: width} = widthRef;
|
|
129
|
+
const {current: containerWidth} = containerWidthRef;
|
|
130
|
+
const position = thumbPositionInView - width / 2;
|
|
131
|
+
xRef.current.setValue(
|
|
132
|
+
allowOverflow ? position : clamp(position, 0, containerWidth - width)
|
|
133
|
+
);
|
|
134
|
+
contentContainerRef.current?.setValue(value);
|
|
135
|
+
},
|
|
136
|
+
[widthRef, containerWidthRef, allowOverflow, disabledLow, disabledHigh, gestureStateRef] // Include dependencies here.
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const handleLayout = useWidthLayout(widthRef, () => {
|
|
140
|
+
update(
|
|
141
|
+
gestureStateRef.current.lastPosition,
|
|
142
|
+
gestureStateRef.current.lastValue
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const transform = {transform: [{translateX: x}]};
|
|
147
|
+
|
|
148
|
+
const shouldDisplayLabel =
|
|
149
|
+
isPressed &&
|
|
150
|
+
((gestureStateRef.current.isLow && !disabledLow) ||
|
|
151
|
+
(!gestureStateRef.current.isLow && !disabledHigh));
|
|
152
|
+
|
|
153
|
+
const follower = (
|
|
154
|
+
<Animated.View style={[transform, {opacity: shouldDisplayLabel ? 1 : 0}]}>
|
|
155
|
+
<FollowerContainer onLayout={handleLayout} ref={contentContainerRef} />
|
|
156
|
+
</Animated.View>
|
|
157
|
+
);
|
|
158
|
+
return [follower, update];
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
interface InProps {
|
|
162
|
+
low: number;
|
|
163
|
+
high: number;
|
|
164
|
+
min: number;
|
|
165
|
+
max: number;
|
|
166
|
+
step: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const useSelectedRail = (
|
|
170
|
+
inPropsRef: RefObject<InProps>,
|
|
171
|
+
containerWidthRef: RefObject<number>,
|
|
172
|
+
thumbWidth: number,
|
|
173
|
+
disableRange: boolean
|
|
174
|
+
) => {
|
|
175
|
+
const {current: left} = useRef(new Animated.Value(0));
|
|
176
|
+
const {current: right} = useRef(new Animated.Value(0));
|
|
177
|
+
const update = useCallback(() => {
|
|
178
|
+
const {low, high, min, max} = inPropsRef.current;
|
|
179
|
+
const {current: containerWidth} = containerWidthRef;
|
|
180
|
+
const fullScale = (max - min) / (containerWidth - thumbWidth);
|
|
181
|
+
const leftValue = (low - min) / fullScale;
|
|
182
|
+
const rightValue = (max - high) / fullScale;
|
|
183
|
+
left.setValue(disableRange ? 0 : leftValue);
|
|
184
|
+
right.setValue(
|
|
185
|
+
disableRange ? containerWidth - thumbWidth - leftValue : rightValue
|
|
186
|
+
);
|
|
187
|
+
}, [inPropsRef, containerWidthRef, disableRange, thumbWidth, left, right]);
|
|
188
|
+
const styles = useMemo(
|
|
189
|
+
() => ({
|
|
190
|
+
position: 'absolute',
|
|
191
|
+
left: left,
|
|
192
|
+
right: right,
|
|
193
|
+
}),
|
|
194
|
+
[left, right]
|
|
195
|
+
);
|
|
196
|
+
return [styles, update];
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param floating
|
|
201
|
+
* @returns {{onLayout: ((function({nativeEvent: *}): void)|undefined), style: [*, {top}]}}
|
|
202
|
+
*/
|
|
203
|
+
export const useLabelContainerProps = (floating: boolean) => {
|
|
204
|
+
const [labelContainerHeight, setLabelContainerHeight] = useState(0);
|
|
205
|
+
const onLayout = useCallback(({nativeEvent}: {nativeEvent: {layout: {height: number}}}) => {
|
|
206
|
+
const {
|
|
207
|
+
layout: {height},
|
|
208
|
+
} = nativeEvent;
|
|
209
|
+
setLabelContainerHeight(height);
|
|
210
|
+
}, []);
|
|
211
|
+
|
|
212
|
+
const top = floating ? -(labelContainerHeight + Spacing.XS) : Spacing.XS;
|
|
213
|
+
const style = [
|
|
214
|
+
floating ? styles.labelFloatingContainer : styles.labelFixedContainer,
|
|
215
|
+
{top},
|
|
216
|
+
];
|
|
217
|
+
return {style, onLayout: onLayout};
|
|
218
|
+
};
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
memo,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import {
|
|
11
|
+
Animated,
|
|
12
|
+
GestureResponderEvent,
|
|
13
|
+
LayoutChangeEvent,
|
|
14
|
+
PanResponder,
|
|
15
|
+
PanResponderGestureState,
|
|
16
|
+
View,
|
|
17
|
+
ViewProps,
|
|
18
|
+
ViewStyle,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
|
|
21
|
+
import styles from './styles';
|
|
22
|
+
import {
|
|
23
|
+
useLabelContainerProps,
|
|
24
|
+
useLowHigh,
|
|
25
|
+
useSelectedRail,
|
|
26
|
+
useThumbFollower,
|
|
27
|
+
useWidthLayout,
|
|
28
|
+
} from './hooks';
|
|
29
|
+
import {clamp, getValueForPosition, isLowCloser} from './helpers';
|
|
30
|
+
import {ApplicationContext, Radius, Shadow} from '@momo-kits/foundation';
|
|
31
|
+
|
|
32
|
+
const trueFunc = () => true;
|
|
33
|
+
const falseFunc = () => false;
|
|
34
|
+
|
|
35
|
+
export interface SliderProps extends ViewProps {
|
|
36
|
+
/**
|
|
37
|
+
* Specifies the minimum value permitted for selection in the slider. This value sets the lower
|
|
38
|
+
* bound for the component.
|
|
39
|
+
*/
|
|
40
|
+
min: number;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Specifies the maximum value allowed for selection. This value sets the upper bound for the component.
|
|
44
|
+
*/
|
|
45
|
+
max: number;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Optional. Defines the minimum permitted range between the low and high values of the slider.
|
|
49
|
+
* Particularly useful when 'low' and 'high' values both exist, ensuring a certain spread between them.
|
|
50
|
+
*/
|
|
51
|
+
minRange?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Specifies the interval between individual step values. The slider's handle will move only in these increments.
|
|
55
|
+
*/
|
|
56
|
+
step: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Optional. Represents the initial lower value of the range when the component is used as a range slider.
|
|
60
|
+
* This value is part of the selected range, between 'min' and 'high'.
|
|
61
|
+
*/
|
|
62
|
+
low?: number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Optional. Represents the initial upper value of the range when used as a range slider.
|
|
66
|
+
* This value is part of the selected range, between 'low' and 'max'.
|
|
67
|
+
*/
|
|
68
|
+
high?: number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Optional. If `true`, allows the label to extend beyond the width of the Slider component itself,
|
|
72
|
+
* rather than being clipped at the component boundaries. Defaults to `false` if not provided.
|
|
73
|
+
*/
|
|
74
|
+
allowLabelOverflow?: boolean;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Optional. If `true`, disables the range functionality of the slider, turning it into a regular
|
|
78
|
+
* single-value slider. Defaults to `false` if not provided.
|
|
79
|
+
*/
|
|
80
|
+
disableRange?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Optional. If `true`, the 'high' handle of the slider will be disabled and cannot be moved.
|
|
84
|
+
* Useful for setting a maximum limit that users cannot increase. Defaults to `false` if not provided.
|
|
85
|
+
*/
|
|
86
|
+
disabledHigh?: boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Optional. If `true`, the 'low' handle of the slider will be disabled and cannot be moved.
|
|
90
|
+
* Useful for setting a minimum limit that users cannot decrease. Defaults to `false` if not provided.
|
|
91
|
+
*/
|
|
92
|
+
disabledLow?: boolean;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Optional. If `true`, labels will be displayed in a floating manner above the slider handles,
|
|
96
|
+
* typically used to display the current value. Defaults to `false` if not provided.
|
|
97
|
+
*/
|
|
98
|
+
floatingLabel?: boolean;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Optional. A callback function triggered when the slider value changes, either by the user or programmatically.
|
|
102
|
+
* It receives the new low and high values of the slider, as well as a boolean indicating if the change was made by the user.
|
|
103
|
+
*/
|
|
104
|
+
onValueChanged?: (low: number, high: number, byUser: boolean) => void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Optional. A callback function triggered when the user starts touching the slider's draggable area.
|
|
108
|
+
* It receives the current low and high values of the slider.
|
|
109
|
+
*/
|
|
110
|
+
onSliderTouchStart?: (low: number, high: number) => void;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Optional. A callback function triggered when the user releases the slider's draggable area.
|
|
114
|
+
* It receives the current low and high values of the slider.
|
|
115
|
+
*/
|
|
116
|
+
onSliderTouchEnd?: (low: number, high: number) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const Slider: React.FC<SliderProps> = memo(
|
|
120
|
+
({
|
|
121
|
+
min,
|
|
122
|
+
max,
|
|
123
|
+
minRange = 0,
|
|
124
|
+
step,
|
|
125
|
+
low: lowProp,
|
|
126
|
+
high: highProp,
|
|
127
|
+
floatingLabel = false,
|
|
128
|
+
allowLabelOverflow = false,
|
|
129
|
+
disableRange = false,
|
|
130
|
+
disabledHigh = false,
|
|
131
|
+
disabledLow = false,
|
|
132
|
+
onValueChanged,
|
|
133
|
+
onSliderTouchStart,
|
|
134
|
+
onSliderTouchEnd,
|
|
135
|
+
...restProps
|
|
136
|
+
}) => {
|
|
137
|
+
const {theme} = useContext(ApplicationContext);
|
|
138
|
+
|
|
139
|
+
const {inPropsRef, inPropsRefPrev, setLow, setHigh} = useLowHigh(
|
|
140
|
+
lowProp,
|
|
141
|
+
disableRange ? max : highProp,
|
|
142
|
+
min,
|
|
143
|
+
max,
|
|
144
|
+
step
|
|
145
|
+
);
|
|
146
|
+
const lowThumbXRef = useRef(new Animated.Value(0));
|
|
147
|
+
const highThumbXRef = useRef(new Animated.Value(0));
|
|
148
|
+
const pointerX = useRef(new Animated.Value(0)).current;
|
|
149
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
150
|
+
const {current: highThumbX} = highThumbXRef;
|
|
151
|
+
|
|
152
|
+
const gestureStateRef = useRef({
|
|
153
|
+
isLow: true,
|
|
154
|
+
lastValue: 0,
|
|
155
|
+
lastPosition: 0,
|
|
156
|
+
});
|
|
157
|
+
const [isPressed, setPressed] = useState(false);
|
|
158
|
+
|
|
159
|
+
const containerWidthRef = useRef(0);
|
|
160
|
+
const [thumbWidth, setThumbWidth] = useState(0);
|
|
161
|
+
|
|
162
|
+
const [selectedRailStyle, updateSelectedRail] = useSelectedRail(
|
|
163
|
+
inPropsRef,
|
|
164
|
+
containerWidthRef,
|
|
165
|
+
thumbWidth,
|
|
166
|
+
disableRange
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const updateThumbs = useCallback(() => {
|
|
170
|
+
const {current: containerWidth} = containerWidthRef;
|
|
171
|
+
if (!thumbWidth || !containerWidth) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const {low, high} = inPropsRef.current;
|
|
175
|
+
if (!disableRange) {
|
|
176
|
+
const {current: highThumbX} = highThumbXRef;
|
|
177
|
+
const highPosition =
|
|
178
|
+
((high - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
179
|
+
highThumbX.setValue(highPosition);
|
|
180
|
+
}
|
|
181
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
182
|
+
const lowPosition =
|
|
183
|
+
((low - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
184
|
+
lowThumbX.setValue(lowPosition);
|
|
185
|
+
typeof updateSelectedRail === 'function' && updateSelectedRail();
|
|
186
|
+
onValueChanged?.(low, high, false);
|
|
187
|
+
}, [
|
|
188
|
+
disableRange,
|
|
189
|
+
inPropsRef,
|
|
190
|
+
max,
|
|
191
|
+
min,
|
|
192
|
+
onValueChanged,
|
|
193
|
+
thumbWidth,
|
|
194
|
+
updateSelectedRail,
|
|
195
|
+
]);
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const {lowPrev, highPrev} = inPropsRefPrev;
|
|
199
|
+
if (
|
|
200
|
+
(lowProp !== undefined && lowProp !== lowPrev) ||
|
|
201
|
+
(highProp !== undefined && highProp !== highPrev)
|
|
202
|
+
) {
|
|
203
|
+
updateThumbs();
|
|
204
|
+
}
|
|
205
|
+
}, [highProp, inPropsRefPrev, lowProp, updateThumbs]);
|
|
206
|
+
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
updateThumbs();
|
|
209
|
+
}, [updateThumbs]);
|
|
210
|
+
|
|
211
|
+
const handleContainerLayout = useWidthLayout(
|
|
212
|
+
containerWidthRef,
|
|
213
|
+
updateThumbs
|
|
214
|
+
);
|
|
215
|
+
const handleThumbLayout = useCallback(
|
|
216
|
+
({
|
|
217
|
+
nativeEvent,
|
|
218
|
+
}: LayoutChangeEvent) => {
|
|
219
|
+
const {
|
|
220
|
+
layout: {width},
|
|
221
|
+
} = nativeEvent;
|
|
222
|
+
if (thumbWidth !== width) {
|
|
223
|
+
setThumbWidth(width);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
[thumbWidth]
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
const lowStyles = useMemo(() => {
|
|
230
|
+
return {transform: [{translateX: lowThumbX}]};
|
|
231
|
+
}, [lowThumbX]);
|
|
232
|
+
|
|
233
|
+
const highStyles = useMemo(() => {
|
|
234
|
+
return disableRange
|
|
235
|
+
? null
|
|
236
|
+
: [styles.highThumbContainer, {transform: [{translateX: highThumbX}]}];
|
|
237
|
+
}, [disableRange, highThumbX]);
|
|
238
|
+
|
|
239
|
+
const railContainerStyles = useMemo(() => {
|
|
240
|
+
return [styles.railsContainer, {marginHorizontal: thumbWidth / 2}];
|
|
241
|
+
}, [thumbWidth]);
|
|
242
|
+
|
|
243
|
+
const [labelView, labelUpdate] = useThumbFollower(
|
|
244
|
+
containerWidthRef,
|
|
245
|
+
gestureStateRef,
|
|
246
|
+
isPressed,
|
|
247
|
+
allowLabelOverflow,
|
|
248
|
+
disabledLow,
|
|
249
|
+
disabledHigh
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
const renderThumb = (name: string) => {
|
|
253
|
+
const isDisabled =
|
|
254
|
+
(name === 'low' && disabledLow) || (name === 'high' && disabledHigh);
|
|
255
|
+
|
|
256
|
+
const thumbColor = isDisabled
|
|
257
|
+
? theme.colors.text.disable
|
|
258
|
+
: theme.colors.primary;
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<View
|
|
262
|
+
style={[
|
|
263
|
+
Shadow.Light,
|
|
264
|
+
{
|
|
265
|
+
width: 20,
|
|
266
|
+
height: 20,
|
|
267
|
+
borderRadius: Radius.M,
|
|
268
|
+
borderWidth: 4,
|
|
269
|
+
borderColor: theme.colors.background.surface,
|
|
270
|
+
backgroundColor: thumbColor,
|
|
271
|
+
},
|
|
272
|
+
]}
|
|
273
|
+
/>
|
|
274
|
+
);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const lowThumb = renderThumb('low');
|
|
278
|
+
const highThumb = renderThumb('high');
|
|
279
|
+
|
|
280
|
+
const labelContainerProps = useLabelContainerProps(floatingLabel);
|
|
281
|
+
|
|
282
|
+
const {panHandlers} = useMemo(
|
|
283
|
+
() =>
|
|
284
|
+
PanResponder.create({
|
|
285
|
+
onStartShouldSetPanResponderCapture: falseFunc,
|
|
286
|
+
onMoveShouldSetPanResponderCapture: falseFunc,
|
|
287
|
+
onPanResponderTerminationRequest: falseFunc,
|
|
288
|
+
onPanResponderTerminate: trueFunc,
|
|
289
|
+
onShouldBlockNativeResponder: trueFunc,
|
|
290
|
+
|
|
291
|
+
onMoveShouldSetPanResponder: (
|
|
292
|
+
evt: GestureResponderEvent,
|
|
293
|
+
gestureState: PanResponderGestureState
|
|
294
|
+
) => Math.abs(gestureState.dx) > 2 * Math.abs(gestureState.dy),
|
|
295
|
+
|
|
296
|
+
onPanResponderGrant: ({nativeEvent}, gestureState) => {
|
|
297
|
+
const {numberActiveTouches} = gestureState;
|
|
298
|
+
if (numberActiveTouches > 1) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
setPressed(true);
|
|
302
|
+
const {current: lowThumbX} = lowThumbXRef;
|
|
303
|
+
const {current: highThumbX} = highThumbXRef;
|
|
304
|
+
const {locationX: downX, pageX} = nativeEvent;
|
|
305
|
+
const containerX = pageX - downX;
|
|
306
|
+
|
|
307
|
+
const {low, high, min, max} = inPropsRef.current;
|
|
308
|
+
onSliderTouchStart?.(low, high);
|
|
309
|
+
const containerWidth = containerWidthRef.current;
|
|
310
|
+
|
|
311
|
+
const lowPosition =
|
|
312
|
+
thumbWidth / 2 +
|
|
313
|
+
((low - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
314
|
+
const highPosition =
|
|
315
|
+
thumbWidth / 2 +
|
|
316
|
+
((high - min) / (max - min)) * (containerWidth - thumbWidth);
|
|
317
|
+
|
|
318
|
+
const isLow =
|
|
319
|
+
disableRange || isLowCloser(downX, lowPosition, highPosition);
|
|
320
|
+
gestureStateRef.current.isLow = isLow;
|
|
321
|
+
|
|
322
|
+
if ((isLow && disabledLow) || (!isLow && disabledHigh)) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const handlePositionChange = (positionInView: number) => {
|
|
327
|
+
const {low, high, min, max, step} = inPropsRef.current;
|
|
328
|
+
const minValue = isLow ? min : low + minRange;
|
|
329
|
+
const maxValue = isLow ? high - minRange : max;
|
|
330
|
+
const value = clamp(
|
|
331
|
+
getValueForPosition(
|
|
332
|
+
positionInView,
|
|
333
|
+
containerWidth,
|
|
334
|
+
thumbWidth,
|
|
335
|
+
min,
|
|
336
|
+
max,
|
|
337
|
+
step
|
|
338
|
+
),
|
|
339
|
+
minValue,
|
|
340
|
+
maxValue
|
|
341
|
+
);
|
|
342
|
+
if (gestureStateRef.current.lastValue === value) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const availableSpace = containerWidth - thumbWidth;
|
|
346
|
+
const absolutePosition =
|
|
347
|
+
((value - min) / (max - min)) * availableSpace;
|
|
348
|
+
gestureStateRef.current.lastValue = value;
|
|
349
|
+
gestureStateRef.current.lastPosition =
|
|
350
|
+
absolutePosition + thumbWidth / 2;
|
|
351
|
+
(isLow ? lowThumbX : highThumbX).setValue(absolutePosition);
|
|
352
|
+
onValueChanged?.(isLow ? value : low, isLow ? high : value, true);
|
|
353
|
+
(isLow ? setLow : setHigh)(value);
|
|
354
|
+
labelUpdate &&
|
|
355
|
+
typeof labelUpdate === 'function' &&
|
|
356
|
+
labelUpdate(gestureStateRef.current.lastPosition, value);
|
|
357
|
+
|
|
358
|
+
typeof updateSelectedRail === 'function' && updateSelectedRail();
|
|
359
|
+
};
|
|
360
|
+
handlePositionChange(downX);
|
|
361
|
+
pointerX.removeAllListeners();
|
|
362
|
+
pointerX.addListener(({value: pointerPosition}) => {
|
|
363
|
+
const positionInView = pointerPosition - containerX;
|
|
364
|
+
handlePositionChange(positionInView);
|
|
365
|
+
});
|
|
366
|
+
},
|
|
367
|
+
|
|
368
|
+
onPanResponderMove: (evt, gestureState) => {
|
|
369
|
+
if (gestureStateRef.current.isLow ? disabledLow : disabledHigh) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
Animated.event([null, {moveX: pointerX}], {
|
|
374
|
+
useNativeDriver: false,
|
|
375
|
+
})(evt, gestureState);
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
onPanResponderRelease: () => {
|
|
379
|
+
setPressed(false);
|
|
380
|
+
const {low, high} = inPropsRef.current;
|
|
381
|
+
if (
|
|
382
|
+
(gestureStateRef.current.isLow && disabledLow) ||
|
|
383
|
+
(!gestureStateRef.current.isLow && disabledHigh)
|
|
384
|
+
) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
onSliderTouchEnd?.(low, high);
|
|
388
|
+
},
|
|
389
|
+
}),
|
|
390
|
+
[
|
|
391
|
+
pointerX,
|
|
392
|
+
inPropsRef,
|
|
393
|
+
thumbWidth,
|
|
394
|
+
disableRange,
|
|
395
|
+
onValueChanged,
|
|
396
|
+
disabledHigh,
|
|
397
|
+
disabledLow,
|
|
398
|
+
setLow,
|
|
399
|
+
setHigh,
|
|
400
|
+
labelUpdate,
|
|
401
|
+
updateSelectedRail,
|
|
402
|
+
minRange,
|
|
403
|
+
onSliderTouchEnd,
|
|
404
|
+
onSliderTouchStart,
|
|
405
|
+
]
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
const renderTrack = (color: string) => {
|
|
409
|
+
return (
|
|
410
|
+
<View
|
|
411
|
+
style={{
|
|
412
|
+
width: '100%',
|
|
413
|
+
height: 4,
|
|
414
|
+
borderRadius: Radius.L,
|
|
415
|
+
backgroundColor: color,
|
|
416
|
+
}}
|
|
417
|
+
/>
|
|
418
|
+
);
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const trackColor =
|
|
422
|
+
disabledHigh && disabledLow
|
|
423
|
+
? theme.colors.text.disable
|
|
424
|
+
: theme.colors.primary;
|
|
425
|
+
|
|
426
|
+
return (
|
|
427
|
+
<View {...restProps}>
|
|
428
|
+
<View {...labelContainerProps}>{labelView}</View>
|
|
429
|
+
<View onLayout={handleContainerLayout} style={styles.controlsContainer}>
|
|
430
|
+
<View style={railContainerStyles}>
|
|
431
|
+
{renderTrack(theme.colors.background.default)}
|
|
432
|
+
<Animated.View style={selectedRailStyle as ViewStyle}>
|
|
433
|
+
{renderTrack(trackColor)}
|
|
434
|
+
</Animated.View>
|
|
435
|
+
</View>
|
|
436
|
+
<Animated.View style={lowStyles} onLayout={handleThumbLayout}>
|
|
437
|
+
{lowThumb}
|
|
438
|
+
</Animated.View>
|
|
439
|
+
{!disableRange && (
|
|
440
|
+
<Animated.View style={highStyles}>{highThumb}</Animated.View>
|
|
441
|
+
)}
|
|
442
|
+
<View
|
|
443
|
+
{...panHandlers}
|
|
444
|
+
style={styles.touchableArea}
|
|
445
|
+
collapsable={false}
|
|
446
|
+
/>
|
|
447
|
+
</View>
|
|
448
|
+
</View>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
export {Slider};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@momo-kits/slider",
|
|
3
|
+
"version": "0.157.1-beta.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*"
|
|
10
|
+
},
|
|
11
|
+
"license": "MoMo",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
if [ "$1" == "stable" ]; then
|
|
5
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
6
|
+
npm version patch
|
|
7
|
+
npm publish --tag stable --access=public
|
|
8
|
+
elif [ "$1" == "latest" ]; then
|
|
9
|
+
npm publish --tag latest --access=public
|
|
10
|
+
elif [ "$1" == "beta" ]; then
|
|
11
|
+
npm publish --tag beta --access=public
|
|
12
|
+
else
|
|
13
|
+
npm publish --tag alpha --access=public
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
PACKAGE_NAME=$(npm pkg get name)
|
|
17
|
+
NEW_PACKAGE_VERSION=$(npm pkg get version)
|
|
18
|
+
|