rn-custom-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +477 -0
- package/lib/module/assets/images/close.png +0 -0
- package/lib/module/components/CustomCheckbox/index.js +99 -0
- package/lib/module/components/CustomCheckbox/index.js.map +1 -0
- package/lib/module/components/CustomCheckbox/styles.js +213 -0
- package/lib/module/components/CustomCheckbox/styles.js.map +1 -0
- package/lib/module/components/CustomCheckbox/types.js +4 -0
- package/lib/module/components/CustomCheckbox/types.js.map +1 -0
- package/lib/module/components/closeButton/index.js +45 -0
- package/lib/module/components/closeButton/index.js.map +1 -0
- package/lib/module/components/closeButton/types.js +4 -0
- package/lib/module/components/closeButton/types.js.map +1 -0
- package/lib/module/components/customButton/index.js +176 -0
- package/lib/module/components/customButton/index.js.map +1 -0
- package/lib/module/components/customButton/styles.js +282 -0
- package/lib/module/components/customButton/styles.js.map +1 -0
- package/lib/module/components/customButton/types.js +4 -0
- package/lib/module/components/customButton/types.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js +57 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownList.js +51 -0
- package/lib/module/components/customDropDown/DropDownList.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListItem.js +38 -0
- package/lib/module/components/customDropDown/DropDownListItem.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListModal.js +63 -0
- package/lib/module/components/customDropDown/DropDownListModal.js.map +1 -0
- package/lib/module/components/customDropDown/index.js +143 -0
- package/lib/module/components/customDropDown/index.js.map +1 -0
- package/lib/module/components/customDropDown/styles.js +189 -0
- package/lib/module/components/customDropDown/styles.js.map +1 -0
- package/lib/module/components/customDropDown/types.js +4 -0
- package/lib/module/components/customDropDown/types.js.map +1 -0
- package/lib/module/components/customDropDown/utils.js +17 -0
- package/lib/module/components/customDropDown/utils.js.map +1 -0
- package/lib/module/components/customList/ListEmpty.js +33 -0
- package/lib/module/components/customList/ListEmpty.js.map +1 -0
- package/lib/module/components/customList/ListFooterLoader.js +14 -0
- package/lib/module/components/customList/ListFooterLoader.js.map +1 -0
- package/lib/module/components/customList/defaultKeyExtractor.js +9 -0
- package/lib/module/components/customList/defaultKeyExtractor.js.map +1 -0
- package/lib/module/components/customList/getFlashList.js +19 -0
- package/lib/module/components/customList/getFlashList.js.map +1 -0
- package/lib/module/components/customList/index.js +117 -0
- package/lib/module/components/customList/index.js.map +1 -0
- package/lib/module/components/customList/styles.js +45 -0
- package/lib/module/components/customList/styles.js.map +1 -0
- package/lib/module/components/customList/types.js +4 -0
- package/lib/module/components/customList/types.js.map +1 -0
- package/lib/module/components/customModal/ModalFooter.js +44 -0
- package/lib/module/components/customModal/ModalFooter.js.map +1 -0
- package/lib/module/components/customModal/index.js +132 -0
- package/lib/module/components/customModal/index.js.map +1 -0
- package/lib/module/components/customModal/styles.js +123 -0
- package/lib/module/components/customModal/styles.js.map +1 -0
- package/lib/module/components/customModal/types.js +4 -0
- package/lib/module/components/customModal/types.js.map +1 -0
- package/lib/module/components/customModal/useCustomModal.js +23 -0
- package/lib/module/components/customModal/useCustomModal.js.map +1 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js +39 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js.map +1 -0
- package/lib/module/components/customNumberPad/index.js +156 -0
- package/lib/module/components/customNumberPad/index.js.map +1 -0
- package/lib/module/components/customNumberPad/styles.js +131 -0
- package/lib/module/components/customNumberPad/styles.js.map +1 -0
- package/lib/module/components/customNumberPad/types.js +4 -0
- package/lib/module/components/customNumberPad/types.js.map +1 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js +44 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js.map +1 -0
- package/lib/module/components/customNumberPad/utils.js +38 -0
- package/lib/module/components/customNumberPad/utils.js.map +1 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js +66 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js +61 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabScene.js +88 -0
- package/lib/module/components/customSlideTabs/TabScene.js.map +1 -0
- package/lib/module/components/customSlideTabs/index.js +277 -0
- package/lib/module/components/customSlideTabs/index.js.map +1 -0
- package/lib/module/components/customSlideTabs/styles.js +132 -0
- package/lib/module/components/customSlideTabs/styles.js.map +1 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js +65 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js.map +1 -0
- package/lib/module/components/customSlideTabs/types.js +4 -0
- package/lib/module/components/customSlideTabs/types.js.map +1 -0
- package/lib/module/components/loading/index.js +34 -0
- package/lib/module/components/loading/index.js.map +1 -0
- package/lib/module/customFunctions/array.js +61 -0
- package/lib/module/customFunctions/array.js.map +1 -0
- package/lib/module/customFunctions/async.js +62 -0
- package/lib/module/customFunctions/async.js.map +1 -0
- package/lib/module/customFunctions/date.js +109 -0
- package/lib/module/customFunctions/date.js.map +1 -0
- package/lib/module/customFunctions/general.js +29 -0
- package/lib/module/customFunctions/general.js.map +1 -0
- package/lib/module/customFunctions/id.js +20 -0
- package/lib/module/customFunctions/id.js.map +1 -0
- package/lib/module/customFunctions/index.js +29 -0
- package/lib/module/customFunctions/index.js.map +1 -0
- package/lib/module/customFunctions/number.js +94 -0
- package/lib/module/customFunctions/number.js.map +1 -0
- package/lib/module/customFunctions/object.js +39 -0
- package/lib/module/customFunctions/object.js.map +1 -0
- package/lib/module/customFunctions/string.js +63 -0
- package/lib/module/customFunctions/string.js.map +1 -0
- package/lib/module/customFunctions/types.js +2 -0
- package/lib/module/customFunctions/types.js.map +1 -0
- package/lib/module/customFunctions/validation.js +34 -0
- package/lib/module/customFunctions/validation.js.map +1 -0
- package/lib/module/customHooks/errors.js +61 -0
- package/lib/module/customHooks/errors.js.map +1 -0
- package/lib/module/customHooks/fetchJson.js +36 -0
- package/lib/module/customHooks/fetchJson.js.map +1 -0
- package/lib/module/customHooks/index.js +10 -0
- package/lib/module/customHooks/index.js.map +1 -0
- package/lib/module/customHooks/internal.js +49 -0
- package/lib/module/customHooks/internal.js.map +1 -0
- package/lib/module/customHooks/types.js +2 -0
- package/lib/module/customHooks/types.js.map +1 -0
- package/lib/module/customHooks/useApi.js +91 -0
- package/lib/module/customHooks/useApi.js.map +1 -0
- package/lib/module/customHooks/useLazyApi.js +80 -0
- package/lib/module/customHooks/useLazyApi.js.map +1 -0
- package/lib/module/customHooks/useMutation.js +69 -0
- package/lib/module/customHooks/useMutation.js.map +1 -0
- package/lib/module/customHooks/usePaginatedApi.js +127 -0
- package/lib/module/customHooks/usePaginatedApi.js.map +1 -0
- package/lib/module/customHooks/usePollingApi.js +37 -0
- package/lib/module/customHooks/usePollingApi.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiply.js +6 -0
- package/lib/module/multiply.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts +5 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts +67 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts +28 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/index.d.ts +4 -0
- package/lib/typescript/src/components/closeButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/types.d.ts +8 -0
- package/lib/typescript/src/components/closeButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/index.d.ts +5 -0
- package/lib/typescript/src/components/customButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/styles.d.ts +231 -0
- package/lib/typescript/src/components/customButton/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/types.d.ts +46 -0
- package/lib/typescript/src/components/customButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts +18 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts +17 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts +15 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts +19 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts +5 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts +190 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts +37 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts +4 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts +10 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts +3 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts +2 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts +6 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/index.d.ts +11 -0
- package/lib/typescript/src/components/customList/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/styles.d.ts +42 -0
- package/lib/typescript/src/components/customList/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/types.d.ts +33 -0
- package/lib/typescript/src/components/customList/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts +12 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/index.d.ts +6 -0
- package/lib/typescript/src/components/customModal/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/styles.d.ts +83 -0
- package/lib/typescript/src/components/customModal/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/types.d.ts +36 -0
- package/lib/typescript/src/components/customModal/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts +8 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts +23 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts +7 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts +37 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts +47 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts +16 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts +4 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts +16 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts +23 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts +21 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts +5 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts +130 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts +15 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts +68 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts.map +1 -0
- package/lib/typescript/src/components/loading/index.d.ts +7 -0
- package/lib/typescript/src/components/loading/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/array.d.ts +7 -0
- package/lib/typescript/src/customFunctions/array.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/async.d.ts +9 -0
- package/lib/typescript/src/customFunctions/async.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/date.d.ts +18 -0
- package/lib/typescript/src/customFunctions/date.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/general.d.ts +7 -0
- package/lib/typescript/src/customFunctions/general.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/id.d.ts +4 -0
- package/lib/typescript/src/customFunctions/id.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/index.d.ts +26 -0
- package/lib/typescript/src/customFunctions/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/number.d.ts +15 -0
- package/lib/typescript/src/customFunctions/number.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/object.d.ts +6 -0
- package/lib/typescript/src/customFunctions/object.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/string.d.ts +20 -0
- package/lib/typescript/src/customFunctions/string.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/types.d.ts +22 -0
- package/lib/typescript/src/customFunctions/types.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/validation.d.ts +11 -0
- package/lib/typescript/src/customFunctions/validation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/errors.d.ts +16 -0
- package/lib/typescript/src/customHooks/errors.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts +5 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/index.d.ts +9 -0
- package/lib/typescript/src/customHooks/index.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/internal.d.ts +12 -0
- package/lib/typescript/src/customHooks/internal.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/types.d.ts +49 -0
- package/lib/typescript/src/customHooks/types.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/useApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts +14 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts +15 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts +19 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiply.d.ts +2 -0
- package/lib/typescript/src/multiply.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/assets/images/close.png +0 -0
- package/src/components/CustomCheckbox/index.tsx +143 -0
- package/src/components/CustomCheckbox/styles.ts +146 -0
- package/src/components/CustomCheckbox/types.ts +33 -0
- package/src/components/closeButton/index.tsx +40 -0
- package/src/components/closeButton/types.ts +13 -0
- package/src/components/customButton/index.tsx +288 -0
- package/src/components/customButton/styles.ts +247 -0
- package/src/components/customButton/types.ts +71 -0
- package/src/components/customDropDown/DropDownBottomSheet.tsx +70 -0
- package/src/components/customDropDown/DropDownList.tsx +88 -0
- package/src/components/customDropDown/DropDownListItem.tsx +74 -0
- package/src/components/customDropDown/DropDownListModal.tsx +86 -0
- package/src/components/customDropDown/index.tsx +213 -0
- package/src/components/customDropDown/styles.ts +184 -0
- package/src/components/customDropDown/types.ts +48 -0
- package/src/components/customDropDown/utils.ts +24 -0
- package/src/components/customList/ListEmpty.tsx +36 -0
- package/src/components/customList/ListFooterLoader.tsx +11 -0
- package/src/components/customList/defaultKeyExtractor.ts +7 -0
- package/src/components/customList/getFlashList.ts +26 -0
- package/src/components/customList/index.tsx +142 -0
- package/src/components/customList/styles.ts +43 -0
- package/src/components/customList/types.ts +60 -0
- package/src/components/customModal/ModalFooter.tsx +57 -0
- package/src/components/customModal/index.tsx +166 -0
- package/src/components/customModal/styles.ts +131 -0
- package/src/components/customModal/types.ts +48 -0
- package/src/components/customModal/useCustomModal.ts +25 -0
- package/src/components/customNumberPad/NumberPadKey.tsx +81 -0
- package/src/components/customNumberPad/index.tsx +204 -0
- package/src/components/customNumberPad/styles.ts +146 -0
- package/src/components/customNumberPad/types.ts +53 -0
- package/src/components/customNumberPad/useNumberPadInput.ts +56 -0
- package/src/components/customNumberPad/utils.ts +54 -0
- package/src/components/customSlideTabs/AnimatedTabIndicator.tsx +103 -0
- package/src/components/customSlideTabs/TabBarItem.tsx +118 -0
- package/src/components/customSlideTabs/TabScene.tsx +136 -0
- package/src/components/customSlideTabs/index.tsx +385 -0
- package/src/components/customSlideTabs/styles.ts +136 -0
- package/src/components/customSlideTabs/tabBarScroll.ts +92 -0
- package/src/components/customSlideTabs/types.ts +87 -0
- package/src/components/loading/index.tsx +34 -0
- package/src/customFunctions/array.ts +83 -0
- package/src/customFunctions/async.ts +85 -0
- package/src/customFunctions/date.ts +158 -0
- package/src/customFunctions/general.ts +35 -0
- package/src/customFunctions/id.ts +25 -0
- package/src/customFunctions/index.ts +91 -0
- package/src/customFunctions/number.ts +139 -0
- package/src/customFunctions/object.ts +59 -0
- package/src/customFunctions/string.ts +119 -0
- package/src/customFunctions/types.ts +25 -0
- package/src/customFunctions/validation.ts +49 -0
- package/src/customHooks/errors.ts +87 -0
- package/src/customHooks/fetchJson.ts +49 -0
- package/src/customHooks/index.ts +20 -0
- package/src/customHooks/internal.ts +67 -0
- package/src/customHooks/types.ts +71 -0
- package/src/customHooks/useApi.ts +107 -0
- package/src/customHooks/useLazyApi.ts +92 -0
- package/src/customHooks/useMutation.ts +97 -0
- package/src/customHooks/usePaginatedApi.ts +168 -0
- package/src/customHooks/usePollingApi.ts +48 -0
- package/src/index.tsx +63 -0
- package/src/multiply.tsx +3 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ScrollView,
|
|
3
|
+
StyleSheet,
|
|
4
|
+
type ImageStyle,
|
|
5
|
+
type StyleProp,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
type ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
|
|
11
|
+
import DropDownOptionRow from './DropDownListItem';
|
|
12
|
+
import { dropdownStyles } from './styles';
|
|
13
|
+
import type {
|
|
14
|
+
DropDownItemImageAlign,
|
|
15
|
+
DropDownListItem as DropDownListItemType,
|
|
16
|
+
} from './types';
|
|
17
|
+
import { normalizeListItems } from './utils';
|
|
18
|
+
|
|
19
|
+
type DropDownListProps = {
|
|
20
|
+
data: DropDownListItemType[];
|
|
21
|
+
selectedText?: string;
|
|
22
|
+
onSelect: (item: string, index: number) => void;
|
|
23
|
+
maxHeight?: number;
|
|
24
|
+
itemImageAlign?: DropDownItemImageAlign;
|
|
25
|
+
itemImageGap?: number;
|
|
26
|
+
listStyle?: StyleProp<ViewStyle>;
|
|
27
|
+
itemTextStyle?: StyleProp<TextStyle>;
|
|
28
|
+
itemImageStyle?: StyleProp<ImageStyle>;
|
|
29
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const DropDownList = ({
|
|
33
|
+
data,
|
|
34
|
+
selectedText,
|
|
35
|
+
onSelect,
|
|
36
|
+
maxHeight = 220,
|
|
37
|
+
itemImageAlign = 'left',
|
|
38
|
+
itemImageGap = 10,
|
|
39
|
+
listStyle,
|
|
40
|
+
itemTextStyle,
|
|
41
|
+
itemImageStyle,
|
|
42
|
+
containerStyle,
|
|
43
|
+
}: DropDownListProps) => {
|
|
44
|
+
const normalizedData = useMemo(() => normalizeListItems(data), [data]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<ScrollView
|
|
48
|
+
style={[
|
|
49
|
+
dropdownStyles.list,
|
|
50
|
+
styles.scrollView,
|
|
51
|
+
{ maxHeight },
|
|
52
|
+
listStyle,
|
|
53
|
+
containerStyle,
|
|
54
|
+
]}
|
|
55
|
+
nestedScrollEnabled
|
|
56
|
+
keyboardShouldPersistTaps="handled"
|
|
57
|
+
showsVerticalScrollIndicator={false}
|
|
58
|
+
>
|
|
59
|
+
{normalizedData.map((item, index) => {
|
|
60
|
+
const isLast = index === normalizedData.length - 1;
|
|
61
|
+
const isSelected =
|
|
62
|
+
selectedText === item.label || selectedText === item.value;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<DropDownOptionRow
|
|
66
|
+
key={`${item.value}-${index}`}
|
|
67
|
+
item={item}
|
|
68
|
+
isSelected={isSelected}
|
|
69
|
+
isLast={isLast}
|
|
70
|
+
imageAlign={itemImageAlign}
|
|
71
|
+
imageGap={itemImageGap}
|
|
72
|
+
itemTextStyle={itemTextStyle}
|
|
73
|
+
itemImageStyle={itemImageStyle}
|
|
74
|
+
onPress={() => onSelect(item.label, index)}
|
|
75
|
+
/>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</ScrollView>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default DropDownList;
|
|
83
|
+
|
|
84
|
+
const styles = StyleSheet.create({
|
|
85
|
+
scrollView: {
|
|
86
|
+
flexGrow: 0,
|
|
87
|
+
},
|
|
88
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Image,
|
|
3
|
+
Text,
|
|
4
|
+
TouchableOpacity,
|
|
5
|
+
View,
|
|
6
|
+
type ImageStyle,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
type TextStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
import { dropdownStyles } from './styles';
|
|
12
|
+
import type { DropDownItemImageAlign, NormalizedDropDownOption } from './types';
|
|
13
|
+
|
|
14
|
+
type DropDownListItemProps = {
|
|
15
|
+
item: NormalizedDropDownOption;
|
|
16
|
+
isSelected: boolean;
|
|
17
|
+
isLast: boolean;
|
|
18
|
+
imageAlign: DropDownItemImageAlign;
|
|
19
|
+
imageGap: number;
|
|
20
|
+
itemTextStyle?: StyleProp<TextStyle>;
|
|
21
|
+
itemImageStyle?: StyleProp<ImageStyle>;
|
|
22
|
+
onPress: () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DropDownListItem = ({
|
|
26
|
+
item,
|
|
27
|
+
isSelected,
|
|
28
|
+
isLast,
|
|
29
|
+
imageAlign,
|
|
30
|
+
imageGap,
|
|
31
|
+
itemTextStyle,
|
|
32
|
+
itemImageStyle,
|
|
33
|
+
onPress,
|
|
34
|
+
}: DropDownListItemProps) => {
|
|
35
|
+
const imageNode = item.image ? (
|
|
36
|
+
<Image
|
|
37
|
+
resizeMode="contain"
|
|
38
|
+
source={item.image}
|
|
39
|
+
style={[dropdownStyles.itemImage, itemImageStyle]}
|
|
40
|
+
/>
|
|
41
|
+
) : null;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<TouchableOpacity
|
|
45
|
+
activeOpacity={0.6}
|
|
46
|
+
style={[dropdownStyles.listItem, isLast && dropdownStyles.listItemLast]}
|
|
47
|
+
onPress={onPress}
|
|
48
|
+
>
|
|
49
|
+
<View
|
|
50
|
+
style={[
|
|
51
|
+
dropdownStyles.itemRow,
|
|
52
|
+
imageAlign === 'right' && dropdownStyles.itemRowImageRight,
|
|
53
|
+
{ gap: imageGap },
|
|
54
|
+
]}
|
|
55
|
+
>
|
|
56
|
+
{imageAlign === 'left' && imageNode}
|
|
57
|
+
<Text
|
|
58
|
+
style={[
|
|
59
|
+
dropdownStyles.itemText,
|
|
60
|
+
imageAlign === 'right' && dropdownStyles.itemTextWithRightImage,
|
|
61
|
+
isSelected && dropdownStyles.itemTextSelected,
|
|
62
|
+
itemTextStyle,
|
|
63
|
+
]}
|
|
64
|
+
numberOfLines={1}
|
|
65
|
+
>
|
|
66
|
+
{item.label}
|
|
67
|
+
</Text>
|
|
68
|
+
{imageAlign === 'right' && imageNode}
|
|
69
|
+
</View>
|
|
70
|
+
</TouchableOpacity>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default DropDownListItem;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Modal,
|
|
3
|
+
Pressable,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
type ImageSourcePropType,
|
|
7
|
+
type ImageStyle,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type TextStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
|
|
12
|
+
import CloseButton from '../closeButton';
|
|
13
|
+
import DropDownList from './DropDownList';
|
|
14
|
+
import { dropdownStyles } from './styles';
|
|
15
|
+
import type { DropDownItemImageAlign, DropDownListItem } from './types';
|
|
16
|
+
|
|
17
|
+
type DropDownListModalProps = {
|
|
18
|
+
data: DropDownListItem[];
|
|
19
|
+
visible: boolean;
|
|
20
|
+
title?: string;
|
|
21
|
+
selectedText?: string;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
onSelect: (item: string, index: number) => void;
|
|
24
|
+
maxListHeight?: number;
|
|
25
|
+
itemImageAlign?: DropDownItemImageAlign;
|
|
26
|
+
itemImageGap?: number;
|
|
27
|
+
itemTextStyle?: StyleProp<TextStyle>;
|
|
28
|
+
itemImageStyle?: StyleProp<ImageStyle>;
|
|
29
|
+
closeImage?: ImageSourcePropType;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const DropDownListModal = ({
|
|
33
|
+
data,
|
|
34
|
+
visible,
|
|
35
|
+
title,
|
|
36
|
+
selectedText,
|
|
37
|
+
onClose,
|
|
38
|
+
onSelect,
|
|
39
|
+
maxListHeight,
|
|
40
|
+
itemImageAlign,
|
|
41
|
+
itemImageGap,
|
|
42
|
+
itemTextStyle,
|
|
43
|
+
itemImageStyle,
|
|
44
|
+
closeImage,
|
|
45
|
+
}: DropDownListModalProps) => {
|
|
46
|
+
return (
|
|
47
|
+
<Modal
|
|
48
|
+
transparent
|
|
49
|
+
visible={visible}
|
|
50
|
+
supportedOrientations={['landscape', 'portrait']}
|
|
51
|
+
onRequestClose={onClose}
|
|
52
|
+
>
|
|
53
|
+
<Pressable style={dropdownStyles.modalContainer} onPress={onClose}>
|
|
54
|
+
<Pressable style={dropdownStyles.modalContent} onPress={() => {}}>
|
|
55
|
+
<View style={dropdownStyles.modalHeader}>
|
|
56
|
+
<Text style={dropdownStyles.modalTitle} numberOfLines={1}>
|
|
57
|
+
{title || 'Select an option'}
|
|
58
|
+
</Text>
|
|
59
|
+
<CloseButton
|
|
60
|
+
closeImage={closeImage}
|
|
61
|
+
onPress={onClose}
|
|
62
|
+
containerStyle={dropdownStyles.modalCloseButton}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
|
|
66
|
+
<DropDownList
|
|
67
|
+
data={data}
|
|
68
|
+
selectedText={selectedText}
|
|
69
|
+
maxHeight={maxListHeight}
|
|
70
|
+
itemImageAlign={itemImageAlign}
|
|
71
|
+
itemImageGap={itemImageGap}
|
|
72
|
+
itemTextStyle={itemTextStyle}
|
|
73
|
+
itemImageStyle={itemImageStyle}
|
|
74
|
+
containerStyle={dropdownStyles.modalList}
|
|
75
|
+
onSelect={(item, index) => {
|
|
76
|
+
onSelect(item, index);
|
|
77
|
+
onClose();
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
</Pressable>
|
|
81
|
+
</Pressable>
|
|
82
|
+
</Modal>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default DropDownListModal;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import DropDownBottomSheet from './DropDownBottomSheet';
|
|
5
|
+
import DropDownList from './DropDownList';
|
|
6
|
+
import DropDownListModal from './DropDownListModal';
|
|
7
|
+
import { dropdownStyles } from './styles';
|
|
8
|
+
import type { CustomDropDownProps } from './types';
|
|
9
|
+
import { findSelectedOption, normalizeListItems } from './utils';
|
|
10
|
+
|
|
11
|
+
const CustomDropDown = ({
|
|
12
|
+
mode = 'modal',
|
|
13
|
+
label = '',
|
|
14
|
+
selectedText,
|
|
15
|
+
listItems,
|
|
16
|
+
onSelect,
|
|
17
|
+
isSelected = false,
|
|
18
|
+
disabled = false,
|
|
19
|
+
placeholder = 'Select an option',
|
|
20
|
+
maxListHeight = 220,
|
|
21
|
+
itemImageAlign = 'left',
|
|
22
|
+
itemImageGap = 10,
|
|
23
|
+
toggleImageAlign,
|
|
24
|
+
itemImageStyle,
|
|
25
|
+
toggleImageStyle,
|
|
26
|
+
styleDropdown = {},
|
|
27
|
+
labelTextStyle,
|
|
28
|
+
dropdownTextStyles,
|
|
29
|
+
listStyle,
|
|
30
|
+
itemTextStyle,
|
|
31
|
+
closeImage,
|
|
32
|
+
}: CustomDropDownProps) => {
|
|
33
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
34
|
+
|
|
35
|
+
const normalizedItems = useMemo(
|
|
36
|
+
() => normalizeListItems(listItems),
|
|
37
|
+
[listItems]
|
|
38
|
+
);
|
|
39
|
+
const selectedOption = useMemo(
|
|
40
|
+
() => findSelectedOption(normalizedItems, selectedText),
|
|
41
|
+
[normalizedItems, selectedText]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const displayText = selectedText || placeholder;
|
|
45
|
+
const hasSelection = isSelected || Boolean(selectedText);
|
|
46
|
+
const isOverlayOpen = isOpen && (mode === 'inline' || mode === 'anchored');
|
|
47
|
+
const resolvedToggleImageAlign = toggleImageAlign ?? itemImageAlign;
|
|
48
|
+
|
|
49
|
+
const rotation = isOpen ? '180deg' : '0deg';
|
|
50
|
+
|
|
51
|
+
const textStyle = useMemo(
|
|
52
|
+
() => [
|
|
53
|
+
dropdownStyles.selectedText,
|
|
54
|
+
hasSelection && dropdownStyles.selectedTextActive,
|
|
55
|
+
dropdownTextStyles,
|
|
56
|
+
],
|
|
57
|
+
[hasSelection, dropdownTextStyles]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const close = () => setIsOpen(false);
|
|
61
|
+
|
|
62
|
+
const toggle = () => {
|
|
63
|
+
if (disabled) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (mode === 'inline' || mode === 'anchored') {
|
|
68
|
+
setIsOpen((current) => !current);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setIsOpen(true);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const handleSelect = (item: string, index: number) => {
|
|
76
|
+
onSelect(item, index);
|
|
77
|
+
close();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const listContainerStyle =
|
|
81
|
+
mode === 'anchored'
|
|
82
|
+
? [dropdownStyles.anchoredList, dropdownStyles.inlineList]
|
|
83
|
+
: dropdownStyles.inlineList;
|
|
84
|
+
|
|
85
|
+
const listProps = {
|
|
86
|
+
data: listItems,
|
|
87
|
+
selectedText,
|
|
88
|
+
maxHeight: maxListHeight,
|
|
89
|
+
itemImageAlign,
|
|
90
|
+
itemImageGap,
|
|
91
|
+
listStyle,
|
|
92
|
+
itemTextStyle,
|
|
93
|
+
itemImageStyle,
|
|
94
|
+
onSelect: handleSelect,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const renderToggleImage = () => {
|
|
98
|
+
if (!selectedOption?.image) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<Image
|
|
104
|
+
resizeMode="contain"
|
|
105
|
+
source={selectedOption.image}
|
|
106
|
+
style={[dropdownStyles.toggleImage, toggleImageStyle]}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const renderToggleLabel = () => (
|
|
112
|
+
<Text style={textStyle} numberOfLines={1}>
|
|
113
|
+
{displayText}
|
|
114
|
+
</Text>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<View
|
|
119
|
+
style={[
|
|
120
|
+
dropdownStyles.container,
|
|
121
|
+
isOverlayOpen && dropdownStyles.toggleWrapperOpen,
|
|
122
|
+
]}
|
|
123
|
+
>
|
|
124
|
+
{!!label && (
|
|
125
|
+
<Text style={[dropdownStyles.labelText, labelTextStyle]}>{label}</Text>
|
|
126
|
+
)}
|
|
127
|
+
|
|
128
|
+
<View
|
|
129
|
+
style={[
|
|
130
|
+
dropdownStyles.toggleWrapper,
|
|
131
|
+
isOverlayOpen && dropdownStyles.toggleWrapperOpen,
|
|
132
|
+
]}
|
|
133
|
+
>
|
|
134
|
+
<TouchableOpacity
|
|
135
|
+
activeOpacity={0.5}
|
|
136
|
+
disabled={disabled}
|
|
137
|
+
style={[
|
|
138
|
+
dropdownStyles.dropDown,
|
|
139
|
+
disabled && dropdownStyles.dropDownDisabled,
|
|
140
|
+
styleDropdown,
|
|
141
|
+
isOverlayOpen && styles.toggleOpen,
|
|
142
|
+
]}
|
|
143
|
+
onPress={toggle}
|
|
144
|
+
accessibilityRole="button"
|
|
145
|
+
accessibilityState={{ disabled, expanded: isOpen }}
|
|
146
|
+
>
|
|
147
|
+
<View
|
|
148
|
+
style={[
|
|
149
|
+
dropdownStyles.itemRow,
|
|
150
|
+
{ flex: 1, gap: itemImageGap },
|
|
151
|
+
resolvedToggleImageAlign === 'right' &&
|
|
152
|
+
dropdownStyles.itemRowImageRight,
|
|
153
|
+
]}
|
|
154
|
+
>
|
|
155
|
+
{resolvedToggleImageAlign === 'left' && renderToggleImage()}
|
|
156
|
+
{renderToggleLabel()}
|
|
157
|
+
{resolvedToggleImageAlign === 'right' && renderToggleImage()}
|
|
158
|
+
</View>
|
|
159
|
+
<Text
|
|
160
|
+
style={[
|
|
161
|
+
dropdownStyles.arrow,
|
|
162
|
+
{ transform: [{ rotate: rotation }] },
|
|
163
|
+
]}
|
|
164
|
+
>
|
|
165
|
+
▼
|
|
166
|
+
</Text>
|
|
167
|
+
</TouchableOpacity>
|
|
168
|
+
|
|
169
|
+
{isOverlayOpen && (
|
|
170
|
+
<DropDownList {...listProps} containerStyle={listContainerStyle} />
|
|
171
|
+
)}
|
|
172
|
+
</View>
|
|
173
|
+
|
|
174
|
+
{mode === 'modal' && (
|
|
175
|
+
<DropDownListModal
|
|
176
|
+
{...listProps}
|
|
177
|
+
visible={isOpen}
|
|
178
|
+
title={label || undefined}
|
|
179
|
+
closeImage={closeImage}
|
|
180
|
+
maxListHeight={maxListHeight}
|
|
181
|
+
onClose={close}
|
|
182
|
+
onSelect={handleSelect}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
185
|
+
|
|
186
|
+
{mode === 'bottomSheet' && (
|
|
187
|
+
<DropDownBottomSheet
|
|
188
|
+
{...listProps}
|
|
189
|
+
visible={isOpen}
|
|
190
|
+
title={label || undefined}
|
|
191
|
+
maxListHeight={maxListHeight}
|
|
192
|
+
onClose={close}
|
|
193
|
+
onSelect={handleSelect}
|
|
194
|
+
/>
|
|
195
|
+
)}
|
|
196
|
+
</View>
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export default CustomDropDown;
|
|
201
|
+
export type {
|
|
202
|
+
CustomDropDownProps,
|
|
203
|
+
DropDownItemImageAlign,
|
|
204
|
+
DropDownListItem,
|
|
205
|
+
DropDownMode,
|
|
206
|
+
DropDownOption,
|
|
207
|
+
} from './types';
|
|
208
|
+
|
|
209
|
+
const styles = StyleSheet.create({
|
|
210
|
+
toggleOpen: {
|
|
211
|
+
borderColor: '#0d6efd',
|
|
212
|
+
},
|
|
213
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const dropdownStyles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
justifyContent: 'center',
|
|
6
|
+
width: '100%',
|
|
7
|
+
marginBottom: 15,
|
|
8
|
+
},
|
|
9
|
+
labelText: {
|
|
10
|
+
marginBottom: 10,
|
|
11
|
+
fontSize: 14,
|
|
12
|
+
fontWeight: '600',
|
|
13
|
+
color: '#212529',
|
|
14
|
+
},
|
|
15
|
+
toggleWrapper: {
|
|
16
|
+
position: 'relative',
|
|
17
|
+
zIndex: 1,
|
|
18
|
+
},
|
|
19
|
+
toggleWrapperOpen: {
|
|
20
|
+
zIndex: 20,
|
|
21
|
+
},
|
|
22
|
+
dropDown: {
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
borderWidth: 1,
|
|
25
|
+
borderColor: '#e0e0e0',
|
|
26
|
+
borderRadius: 8,
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
paddingVertical: 15,
|
|
30
|
+
paddingHorizontal: 15,
|
|
31
|
+
backgroundColor: '#fff',
|
|
32
|
+
},
|
|
33
|
+
dropDownDisabled: {
|
|
34
|
+
backgroundColor: '#f8f9fa',
|
|
35
|
+
opacity: 0.7,
|
|
36
|
+
},
|
|
37
|
+
selectedText: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
fontSize: 14,
|
|
40
|
+
fontWeight: '700',
|
|
41
|
+
color: '#6c757d',
|
|
42
|
+
},
|
|
43
|
+
selectedTextActive: {
|
|
44
|
+
color: '#000',
|
|
45
|
+
},
|
|
46
|
+
arrow: {
|
|
47
|
+
fontSize: 12,
|
|
48
|
+
color: '#495057',
|
|
49
|
+
marginLeft: 8,
|
|
50
|
+
},
|
|
51
|
+
list: {
|
|
52
|
+
borderWidth: 1,
|
|
53
|
+
borderColor: '#e0e0e0',
|
|
54
|
+
borderRadius: 8,
|
|
55
|
+
backgroundColor: '#fff',
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
},
|
|
58
|
+
inlineList: {
|
|
59
|
+
marginTop: 4,
|
|
60
|
+
},
|
|
61
|
+
anchoredList: {
|
|
62
|
+
position: 'absolute',
|
|
63
|
+
top: '100%',
|
|
64
|
+
left: 0,
|
|
65
|
+
right: 0,
|
|
66
|
+
marginTop: 4,
|
|
67
|
+
shadowColor: '#000',
|
|
68
|
+
shadowOffset: { width: 0, height: 4 },
|
|
69
|
+
shadowOpacity: 0.12,
|
|
70
|
+
shadowRadius: 8,
|
|
71
|
+
elevation: 6,
|
|
72
|
+
},
|
|
73
|
+
listItem: {
|
|
74
|
+
paddingVertical: 14,
|
|
75
|
+
paddingHorizontal: 15,
|
|
76
|
+
borderBottomWidth: 1,
|
|
77
|
+
borderBottomColor: '#f1f3f5',
|
|
78
|
+
},
|
|
79
|
+
listItemLast: {
|
|
80
|
+
borderBottomWidth: 0,
|
|
81
|
+
},
|
|
82
|
+
itemRow: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
},
|
|
86
|
+
itemRowImageRight: {
|
|
87
|
+
justifyContent: 'space-between',
|
|
88
|
+
},
|
|
89
|
+
itemImage: {
|
|
90
|
+
width: 28,
|
|
91
|
+
height: 28,
|
|
92
|
+
},
|
|
93
|
+
toggleImage: {
|
|
94
|
+
width: 24,
|
|
95
|
+
height: 24,
|
|
96
|
+
},
|
|
97
|
+
itemText: {
|
|
98
|
+
flex: 1,
|
|
99
|
+
fontSize: 14,
|
|
100
|
+
fontWeight: '400',
|
|
101
|
+
color: '#212529',
|
|
102
|
+
},
|
|
103
|
+
itemTextWithRightImage: {
|
|
104
|
+
flex: 1,
|
|
105
|
+
marginRight: 4,
|
|
106
|
+
},
|
|
107
|
+
itemTextSelected: {
|
|
108
|
+
fontWeight: '700',
|
|
109
|
+
color: '#0d6efd',
|
|
110
|
+
},
|
|
111
|
+
modalContainer: {
|
|
112
|
+
flex: 1,
|
|
113
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
114
|
+
justifyContent: 'center',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
},
|
|
117
|
+
modalContent: {
|
|
118
|
+
width: '88%',
|
|
119
|
+
maxWidth: 400,
|
|
120
|
+
maxHeight: '70%',
|
|
121
|
+
backgroundColor: '#fff',
|
|
122
|
+
borderRadius: 12,
|
|
123
|
+
paddingHorizontal: 16,
|
|
124
|
+
paddingTop: 16,
|
|
125
|
+
paddingBottom: 12,
|
|
126
|
+
overflow: 'hidden',
|
|
127
|
+
},
|
|
128
|
+
modalHeader: {
|
|
129
|
+
flexDirection: 'row',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
justifyContent: 'space-between',
|
|
132
|
+
marginBottom: 12,
|
|
133
|
+
gap: 12,
|
|
134
|
+
},
|
|
135
|
+
modalTitle: {
|
|
136
|
+
flex: 1,
|
|
137
|
+
fontSize: 16,
|
|
138
|
+
fontWeight: '700',
|
|
139
|
+
color: '#212529',
|
|
140
|
+
},
|
|
141
|
+
modalCloseButton: {
|
|
142
|
+
position: 'relative',
|
|
143
|
+
top: 0,
|
|
144
|
+
right: 0,
|
|
145
|
+
},
|
|
146
|
+
modalList: {
|
|
147
|
+
borderWidth: 0,
|
|
148
|
+
borderRadius: 8,
|
|
149
|
+
},
|
|
150
|
+
bottomSheetBackdrop: {
|
|
151
|
+
flex: 1,
|
|
152
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
153
|
+
justifyContent: 'flex-end',
|
|
154
|
+
},
|
|
155
|
+
bottomSheetContent: {
|
|
156
|
+
backgroundColor: '#fff',
|
|
157
|
+
borderTopLeftRadius: 16,
|
|
158
|
+
borderTopRightRadius: 16,
|
|
159
|
+
paddingTop: 12,
|
|
160
|
+
paddingBottom: 24,
|
|
161
|
+
paddingHorizontal: 20,
|
|
162
|
+
maxHeight: '70%',
|
|
163
|
+
},
|
|
164
|
+
bottomSheetHandle: {
|
|
165
|
+
alignSelf: 'center',
|
|
166
|
+
width: 40,
|
|
167
|
+
height: 4,
|
|
168
|
+
borderRadius: 2,
|
|
169
|
+
backgroundColor: '#dee2e6',
|
|
170
|
+
marginBottom: 16,
|
|
171
|
+
},
|
|
172
|
+
bottomSheetTitle: {
|
|
173
|
+
fontSize: 16,
|
|
174
|
+
fontWeight: '700',
|
|
175
|
+
color: '#212529',
|
|
176
|
+
marginBottom: 12,
|
|
177
|
+
},
|
|
178
|
+
bottomSheetList: {
|
|
179
|
+
borderWidth: 0,
|
|
180
|
+
},
|
|
181
|
+
backdropDismiss: {
|
|
182
|
+
...StyleSheet.absoluteFill,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ImageSourcePropType,
|
|
3
|
+
ImageStyle,
|
|
4
|
+
StyleProp,
|
|
5
|
+
TextStyle,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
export type DropDownMode = 'modal' | 'inline' | 'anchored' | 'bottomSheet';
|
|
10
|
+
|
|
11
|
+
export type DropDownItemImageAlign = 'left' | 'right';
|
|
12
|
+
|
|
13
|
+
export interface DropDownOption {
|
|
14
|
+
label: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
image?: ImageSourcePropType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type DropDownListItem = string | DropDownOption;
|
|
20
|
+
|
|
21
|
+
export interface CustomDropDownProps {
|
|
22
|
+
mode?: DropDownMode;
|
|
23
|
+
label?: string;
|
|
24
|
+
selectedText: string;
|
|
25
|
+
listItems: DropDownListItem[];
|
|
26
|
+
onSelect: (item: string, index: number) => void;
|
|
27
|
+
isSelected?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
maxListHeight?: number;
|
|
31
|
+
itemImageAlign?: DropDownItemImageAlign;
|
|
32
|
+
itemImageGap?: number;
|
|
33
|
+
toggleImageAlign?: DropDownItemImageAlign;
|
|
34
|
+
itemImageStyle?: StyleProp<ImageStyle>;
|
|
35
|
+
toggleImageStyle?: StyleProp<ImageStyle>;
|
|
36
|
+
styleDropdown?: StyleProp<ViewStyle>;
|
|
37
|
+
labelTextStyle?: StyleProp<TextStyle>;
|
|
38
|
+
dropdownTextStyles?: StyleProp<TextStyle>;
|
|
39
|
+
listStyle?: StyleProp<ViewStyle>;
|
|
40
|
+
itemTextStyle?: StyleProp<TextStyle>;
|
|
41
|
+
closeImage?: ImageSourcePropType;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type NormalizedDropDownOption = {
|
|
45
|
+
label: string;
|
|
46
|
+
value: string;
|
|
47
|
+
image?: ImageSourcePropType;
|
|
48
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DropDownListItem, NormalizedDropDownOption } from './types';
|
|
2
|
+
|
|
3
|
+
export const normalizeListItems = (
|
|
4
|
+
items: DropDownListItem[]
|
|
5
|
+
): NormalizedDropDownOption[] =>
|
|
6
|
+
items.map((item) => {
|
|
7
|
+
if (typeof item === 'string') {
|
|
8
|
+
return { label: item, value: item };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
label: item.label,
|
|
13
|
+
value: item.value ?? item.label,
|
|
14
|
+
image: item.image,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const findSelectedOption = (
|
|
19
|
+
items: NormalizedDropDownOption[],
|
|
20
|
+
selectedText?: string
|
|
21
|
+
) =>
|
|
22
|
+
items.find(
|
|
23
|
+
(item) => item.label === selectedText || item.value === selectedText
|
|
24
|
+
);
|