@shaquillehinds/react-native-dropdown-selector 0.0.1

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.
Files changed (61) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +526 -0
  3. package/lib/commonjs/DropDownSelector/DropDownSelector.controller.js +129 -0
  4. package/lib/commonjs/DropDownSelector/DropDownSelector.controller.js.map +1 -0
  5. package/lib/commonjs/DropDownSelector/DropDownSelector.js +136 -0
  6. package/lib/commonjs/DropDownSelector/DropDownSelector.js.map +1 -0
  7. package/lib/commonjs/DropDownSelector/DropDownSelector.types.js +6 -0
  8. package/lib/commonjs/DropDownSelector/DropDownSelector.types.js.map +1 -0
  9. package/lib/commonjs/DropDownSelector/index.js +28 -0
  10. package/lib/commonjs/DropDownSelector/index.js.map +1 -0
  11. package/lib/commonjs/DropDownSelector/svgs/ChevronUp.js +26 -0
  12. package/lib/commonjs/DropDownSelector/svgs/ChevronUp.js.map +1 -0
  13. package/lib/commonjs/index.js +21 -0
  14. package/lib/commonjs/index.js.map +1 -0
  15. package/lib/commonjs/package.json +1 -0
  16. package/lib/module/DropDownSelector/DropDownSelector.controller.js +125 -0
  17. package/lib/module/DropDownSelector/DropDownSelector.controller.js.map +1 -0
  18. package/lib/module/DropDownSelector/DropDownSelector.js +132 -0
  19. package/lib/module/DropDownSelector/DropDownSelector.js.map +1 -0
  20. package/lib/module/DropDownSelector/DropDownSelector.types.js +4 -0
  21. package/lib/module/DropDownSelector/DropDownSelector.types.js.map +1 -0
  22. package/lib/module/DropDownSelector/index.js +5 -0
  23. package/lib/module/DropDownSelector/index.js.map +1 -0
  24. package/lib/module/DropDownSelector/svgs/ChevronUp.js +21 -0
  25. package/lib/module/DropDownSelector/svgs/ChevronUp.js.map +1 -0
  26. package/lib/module/index.js +6 -0
  27. package/lib/module/index.js.map +1 -0
  28. package/lib/module/package.json +1 -0
  29. package/lib/typescript/commonjs/package.json +1 -0
  30. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.controller.d.ts +28 -0
  31. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.controller.d.ts.map +1 -0
  32. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.d.ts +3 -0
  33. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.types.d.ts +45 -0
  35. package/lib/typescript/commonjs/src/DropDownSelector/DropDownSelector.types.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/src/DropDownSelector/index.d.ts +3 -0
  37. package/lib/typescript/commonjs/src/DropDownSelector/index.d.ts.map +1 -0
  38. package/lib/typescript/commonjs/src/DropDownSelector/svgs/ChevronUp.d.ts +5 -0
  39. package/lib/typescript/commonjs/src/DropDownSelector/svgs/ChevronUp.d.ts.map +1 -0
  40. package/lib/typescript/commonjs/src/index.d.ts +4 -0
  41. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  42. package/lib/typescript/module/package.json +1 -0
  43. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.controller.d.ts +28 -0
  44. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.controller.d.ts.map +1 -0
  45. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.d.ts +3 -0
  46. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.d.ts.map +1 -0
  47. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.types.d.ts +45 -0
  48. package/lib/typescript/module/src/DropDownSelector/DropDownSelector.types.d.ts.map +1 -0
  49. package/lib/typescript/module/src/DropDownSelector/index.d.ts +3 -0
  50. package/lib/typescript/module/src/DropDownSelector/index.d.ts.map +1 -0
  51. package/lib/typescript/module/src/DropDownSelector/svgs/ChevronUp.d.ts +5 -0
  52. package/lib/typescript/module/src/DropDownSelector/svgs/ChevronUp.d.ts.map +1 -0
  53. package/lib/typescript/module/src/index.d.ts +4 -0
  54. package/lib/typescript/module/src/index.d.ts.map +1 -0
  55. package/package.json +203 -0
  56. package/src/DropDownSelector/DropDownSelector.controller.tsx +174 -0
  57. package/src/DropDownSelector/DropDownSelector.tsx +183 -0
  58. package/src/DropDownSelector/DropDownSelector.types.ts +44 -0
  59. package/src/DropDownSelector/index.ts +2 -0
  60. package/src/DropDownSelector/svgs/ChevronUp.tsx +18 -0
  61. package/src/index.tsx +4 -0
@@ -0,0 +1,28 @@
1
+ import type { AnimateComponentAnimationConfig, AnimateComponentRef } from '@shaquillehinds/react-native-essentials';
2
+ import type { Animated, LayoutChangeEvent, ViewStyle } from 'react-native';
3
+ import { ScrollView } from 'react-native-gesture-handler';
4
+ import type { DropDownSelectorProps } from './DropDownSelector.types';
5
+ export declare function DropDownSelectorController<T>(props: DropDownSelectorProps<T>): {
6
+ showItems: boolean;
7
+ setShowItems: import("react").Dispatch<import("react").SetStateAction<boolean>>;
8
+ label: string | undefined;
9
+ canRenderDown: boolean | null;
10
+ relativeY: (num: number) => number;
11
+ scrollViewRef: import("react").MutableRefObject<ScrollView | null>;
12
+ animateComponentRef: import("react").RefObject<AnimateComponentRef<number>>;
13
+ animateChevronRef: import("react").RefObject<AnimateComponentRef<number>>;
14
+ animateAndroidShadowRef: import("react").RefObject<AnimateComponentRef<number>>;
15
+ pageYRef: import("react").MutableRefObject<number | null>;
16
+ canRenderDownRef: import("react").MutableRefObject<boolean | null>;
17
+ maxHeight: number;
18
+ handleLayout: (e: LayoutChangeEvent) => void;
19
+ androidShadowAnimatedStyle: (opacity: Animated.Value) => ViewStyle;
20
+ androidShadowAnimationConfig: AnimateComponentAnimationConfig;
21
+ scrollViewStyle: ViewStyle;
22
+ selectionItemsListAnimatedStyle: (translateY: Animated.Value) => ViewStyle;
23
+ selectionItemsListAnimationConfig: AnimateComponentAnimationConfig;
24
+ chevronAnimationConfig: AnimateComponentAnimationConfig;
25
+ chevronAnimatedStyle: (scaleY: Animated.Value) => ViewStyle;
26
+ unMountDelayInMilliSeconds: number;
27
+ };
28
+ //# sourceMappingURL=DropDownSelector.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.controller.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACpB,MAAM,yCAAyC,CAAC;AAOjD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC;;;;;;;;;;;;;sBAuFrE,iBAAiB;0CAUX,QAAQ,CAAC,KAAK,KAAG,SAAS;;;kDAqBvB,QAAQ,CAAC,KAAK,KAAG,SAAS;;;mCAtC9B,QAAQ,CAAC,KAAK,KAAG,SAAS;;EA+EtC"}
@@ -0,0 +1,3 @@
1
+ import type { DropDownSelectorProps } from './DropDownSelector.types';
2
+ export declare function DropDownSelector<T>(props: DropDownSelectorProps<T>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=DropDownSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,2CAkKlE"}
@@ -0,0 +1,45 @@
1
+ import type { BaseTextProps, LayoutProps, RNPressableLayoutProps, TouchableLayoutProps } from '@shaquillehinds/react-native-essentials';
2
+ import type { Animated, ScrollViewProps } from 'react-native';
3
+ export type DropDownItemValue<T> = T;
4
+ export type DropDownItem<T> = {
5
+ label: string;
6
+ value: DropDownItemValue<T>;
7
+ };
8
+ export type DropDownSelectorProps<T> = {
9
+ items: DropDownItem<T>[];
10
+ selectedItem: T;
11
+ onSelect: (item: T) => void;
12
+ placeholder: string;
13
+ onOpen?: () => void;
14
+ onClose?: () => void;
15
+ unMountDelayInMilliSeconds?: number;
16
+ isDisabled?: boolean;
17
+ disableShadow?: boolean;
18
+ expandDirection?: 'up' | 'down';
19
+ expandDistance?: number;
20
+ expandAnimationConfig?: (Omit<Animated.TimingAnimationConfig, 'toValue'> & {
21
+ type: 'timing';
22
+ }) | (Omit<Animated.SpringAnimationConfig, 'toValue'> & {
23
+ type: 'spring';
24
+ });
25
+ containerProps?: LayoutProps;
26
+ dropdownButtonProps?: RNPressableLayoutProps;
27
+ dropdownButtonTextProps?: BaseTextProps;
28
+ DropdownButtonIcon?: (props: {
29
+ isOpen: boolean;
30
+ expandDirection: 'up' | 'down';
31
+ }) => React.JSX.Element;
32
+ dropdownScrollViewProps?: ScrollViewProps;
33
+ dropdownContentContainerProps?: LayoutProps;
34
+ DropdownItemComponent?: (props: {
35
+ item: DropDownItem<T>;
36
+ isSelected: boolean;
37
+ }) => React.JSX.Element;
38
+ onDropdownItemPress?: (item: DropDownItem<T>) => void;
39
+ dropdownItemProps?: TouchableLayoutProps;
40
+ dropdownItemTextProps?: BaseTextProps;
41
+ DropdownItemSelectedIcon?: (props: {
42
+ item: DropDownItem<T>;
43
+ }) => React.JSX.Element;
44
+ };
45
+ //# sourceMappingURL=DropDownSelector.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.types.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,eA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,GAAG,CAAC,OAAO,CAAC;IACvG,uBAAuB,CAAC,EAAE,eAAe,CAAC;IAC1C,6BAA6B,CAAC,EAAE,WAAW,CAAC;IAE5C,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACpG,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACtD,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC,qBAAqB,CAAC,EAAE,aAAa,CAAC;IAEtC,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;KAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CAClF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './DropDownSelector';
2
+ export * from './DropDownSelector.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function ChevronUp({ size, color }: {
2
+ size?: number;
3
+ color?: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=ChevronUp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChevronUp.d.ts","sourceRoot":"","sources":["../../../../../../src/DropDownSelector/svgs/ChevronUp.tsx"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CAc3E"}
@@ -0,0 +1,4 @@
1
+ import { DropDownSelector } from './DropDownSelector';
2
+ export * from './DropDownSelector';
3
+ export default DropDownSelector;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,oBAAoB,CAAC;AAEnC,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,28 @@
1
+ import type { AnimateComponentAnimationConfig, AnimateComponentRef } from '@shaquillehinds/react-native-essentials';
2
+ import type { Animated, LayoutChangeEvent, ViewStyle } from 'react-native';
3
+ import { ScrollView } from 'react-native-gesture-handler';
4
+ import type { DropDownSelectorProps } from './DropDownSelector.types';
5
+ export declare function DropDownSelectorController<T>(props: DropDownSelectorProps<T>): {
6
+ showItems: boolean;
7
+ setShowItems: import("react").Dispatch<import("react").SetStateAction<boolean>>;
8
+ label: string | undefined;
9
+ canRenderDown: boolean | null;
10
+ relativeY: (num: number) => number;
11
+ scrollViewRef: import("react").MutableRefObject<ScrollView | null>;
12
+ animateComponentRef: import("react").RefObject<AnimateComponentRef<number>>;
13
+ animateChevronRef: import("react").RefObject<AnimateComponentRef<number>>;
14
+ animateAndroidShadowRef: import("react").RefObject<AnimateComponentRef<number>>;
15
+ pageYRef: import("react").MutableRefObject<number | null>;
16
+ canRenderDownRef: import("react").MutableRefObject<boolean | null>;
17
+ maxHeight: number;
18
+ handleLayout: (e: LayoutChangeEvent) => void;
19
+ androidShadowAnimatedStyle: (opacity: Animated.Value) => ViewStyle;
20
+ androidShadowAnimationConfig: AnimateComponentAnimationConfig;
21
+ scrollViewStyle: ViewStyle;
22
+ selectionItemsListAnimatedStyle: (translateY: Animated.Value) => ViewStyle;
23
+ selectionItemsListAnimationConfig: AnimateComponentAnimationConfig;
24
+ chevronAnimationConfig: AnimateComponentAnimationConfig;
25
+ chevronAnimatedStyle: (scaleY: Animated.Value) => ViewStyle;
26
+ unMountDelayInMilliSeconds: number;
27
+ };
28
+ //# sourceMappingURL=DropDownSelector.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.controller.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.controller.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,mBAAmB,EACpB,MAAM,yCAAyC,CAAC;AAOjD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC;;;;;;;;;;;;;sBAuFrE,iBAAiB;0CAUX,QAAQ,CAAC,KAAK,KAAG,SAAS;;;kDAqBvB,QAAQ,CAAC,KAAK,KAAG,SAAS;;;mCAtC9B,QAAQ,CAAC,KAAK,KAAG,SAAS;;EA+EtC"}
@@ -0,0 +1,3 @@
1
+ import type { DropDownSelectorProps } from './DropDownSelector.types';
2
+ export declare function DropDownSelector<T>(props: DropDownSelectorProps<T>): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=DropDownSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,2CAkKlE"}
@@ -0,0 +1,45 @@
1
+ import type { BaseTextProps, LayoutProps, RNPressableLayoutProps, TouchableLayoutProps } from '@shaquillehinds/react-native-essentials';
2
+ import type { Animated, ScrollViewProps } from 'react-native';
3
+ export type DropDownItemValue<T> = T;
4
+ export type DropDownItem<T> = {
5
+ label: string;
6
+ value: DropDownItemValue<T>;
7
+ };
8
+ export type DropDownSelectorProps<T> = {
9
+ items: DropDownItem<T>[];
10
+ selectedItem: T;
11
+ onSelect: (item: T) => void;
12
+ placeholder: string;
13
+ onOpen?: () => void;
14
+ onClose?: () => void;
15
+ unMountDelayInMilliSeconds?: number;
16
+ isDisabled?: boolean;
17
+ disableShadow?: boolean;
18
+ expandDirection?: 'up' | 'down';
19
+ expandDistance?: number;
20
+ expandAnimationConfig?: (Omit<Animated.TimingAnimationConfig, 'toValue'> & {
21
+ type: 'timing';
22
+ }) | (Omit<Animated.SpringAnimationConfig, 'toValue'> & {
23
+ type: 'spring';
24
+ });
25
+ containerProps?: LayoutProps;
26
+ dropdownButtonProps?: RNPressableLayoutProps;
27
+ dropdownButtonTextProps?: BaseTextProps;
28
+ DropdownButtonIcon?: (props: {
29
+ isOpen: boolean;
30
+ expandDirection: 'up' | 'down';
31
+ }) => React.JSX.Element;
32
+ dropdownScrollViewProps?: ScrollViewProps;
33
+ dropdownContentContainerProps?: LayoutProps;
34
+ DropdownItemComponent?: (props: {
35
+ item: DropDownItem<T>;
36
+ isSelected: boolean;
37
+ }) => React.JSX.Element;
38
+ onDropdownItemPress?: (item: DropDownItem<T>) => void;
39
+ dropdownItemProps?: TouchableLayoutProps;
40
+ dropdownItemTextProps?: BaseTextProps;
41
+ DropdownItemSelectedIcon?: (props: {
42
+ item: DropDownItem<T>;
43
+ }) => React.JSX.Element;
44
+ };
45
+ //# sourceMappingURL=DropDownSelector.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropDownSelector.types.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/DropDownSelector.types.ts"],"names":[],"mappings":"AAAA,OAA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AAC,EAAE,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,IAAI,GAAG,MAAM,CAAA;KAAE,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACvG,uBAAuB,CAAC,EAAE,eAAe,CAAC;IAC1C,6BAA6B,CAAC,EAAE,WAAW,CAAC;IAE5C,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;IACpG,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACtD,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC,qBAAqB,CAAC,EAAE,aAAa,CAAC;IAEtC,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;KAAC,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CAClF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './DropDownSelector';
2
+ export * from './DropDownSelector.types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/DropDownSelector/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function ChevronUp({ size, color }: {
2
+ size?: number;
3
+ color?: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=ChevronUp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChevronUp.d.ts","sourceRoot":"","sources":["../../../../../../src/DropDownSelector/svgs/ChevronUp.tsx"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CAc3E"}
@@ -0,0 +1,4 @@
1
+ import { DropDownSelector } from './DropDownSelector';
2
+ export * from './DropDownSelector';
3
+ export default DropDownSelector;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,oBAAoB,CAAC;AAEnC,eAAe,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,203 @@
1
+ {
2
+ "name": "@shaquillehinds/react-native-dropdown-selector",
3
+ "version": "0.0.1",
4
+ "description": "A simple dropdown selector for react native that just works.",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "react-native": "./src/index.tsx",
9
+ "types": "lib/typescript/commonjs/src/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./lib/typescript/module/src/index.d.ts",
14
+ "react-native": "./src/index.tsx",
15
+ "default": "./lib/module/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
19
+ "default": "./lib/commonjs/index.js"
20
+ }
21
+ }
22
+ },
23
+ "files": [
24
+ "lib",
25
+ "src",
26
+ "android",
27
+ "ios",
28
+ "cpp",
29
+ "*.podspec",
30
+ "react-native.config.js",
31
+ "!ios/build",
32
+ "!android/build",
33
+ "!android/gradle",
34
+ "!android/gradlew",
35
+ "!android/gradlew.bat",
36
+ "!android/local.properties",
37
+ "!**/__tests__",
38
+ "!**/__fixtures__",
39
+ "!**/__mocks__",
40
+ "!**/.*"
41
+ ],
42
+ "scripts": {
43
+ "example": "yarn workspace react-native-dropdown-selector-example",
44
+ "dev:mkdir": "mkdir -p ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-dropdown-selector/",
45
+ "dev:copy": "cp -r src/* ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-dropdown-selector/",
46
+ "dev:sync": "npm run dev:copy && chokidar \"src/**/*\" -c \"rsync -a src/ ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-dropdown-selector/\"",
47
+ "test": "jest",
48
+ "tarball": "npm pack @shaquillehinds/react-native-dropdown-selector",
49
+ "typecheck": "tsc",
50
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
51
+ "clean": "del-cli lib",
52
+ "prepare": "bob build",
53
+ "release": "release-it"
54
+ },
55
+ "keywords": [
56
+ "react-native",
57
+ "ios",
58
+ "android",
59
+ "modal",
60
+ "sheet",
61
+ "bottomsheet",
62
+ "bottommodal",
63
+ "bottom-sheet",
64
+ "bottom-modal"
65
+ ],
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/shaquillehinds/react-native-dropdown-selector.git"
69
+ },
70
+ "author": "Shaquille Hinds <shaqdulove@gmail.com> (https://github.com/shaquillehinds)",
71
+ "license": "MIT",
72
+ "bugs": {
73
+ "url": "https://github.com/shaquillehinds/react-native-dropdown-selector/issues"
74
+ },
75
+ "homepage": "https://github.com/shaquillehinds/react-native-dropdown-selector#readme",
76
+ "publishConfig": {
77
+ "registry": "https://registry.npmjs.org/",
78
+ "access": "public"
79
+ },
80
+ "dependencies": {
81
+ "@shaquillehinds/react-native-essentials": "^1.8.0"
82
+ },
83
+ "devDependencies": {
84
+ "@commitlint/config-conventional": "^19.6.0",
85
+ "@react-native/eslint-config": "^0.73.1",
86
+ "@release-it/conventional-changelog": "^9.0.2",
87
+ "@types/jest": "^29.5.5",
88
+ "@types/react": "^18.2.44",
89
+ "chokidar-cli": "^3.0.0",
90
+ "commitlint": "^19.6.1",
91
+ "del-cli": "^5.1.0",
92
+ "eslint": "^8.51.0",
93
+ "eslint-config-prettier": "^9.0.0",
94
+ "eslint-plugin-prettier": "^5.0.1",
95
+ "jest": "^29.7.0",
96
+ "prettier": "^3.0.3",
97
+ "react": "18.3.1",
98
+ "react-native": "0.76.7",
99
+ "react-native-builder-bob": "^0.38.0",
100
+ "react-native-gesture-handler": "^2.24.0",
101
+ "react-native-reanimated": "^3.17.1",
102
+ "react-native-svg": "^15.11.2",
103
+ "release-it": "^17.10.0",
104
+ "typescript": "^5.2.2"
105
+ },
106
+ "resolutions": {
107
+ "@types/react": "^18.2.44"
108
+ },
109
+ "peerDependencies": {
110
+ "react": "*",
111
+ "react-native": "*"
112
+ },
113
+ "workspaces": [
114
+ "example"
115
+ ],
116
+ "packageManager": "yarn@3.6.1",
117
+ "jest": {
118
+ "preset": "react-native",
119
+ "modulePathIgnorePatterns": [
120
+ "<rootDir>/example/node_modules",
121
+ "<rootDir>/lib/"
122
+ ]
123
+ },
124
+ "commitlint": {
125
+ "extends": [
126
+ "@commitlint/config-conventional"
127
+ ]
128
+ },
129
+ "release-it": {
130
+ "git": {
131
+ "commitMessage": "chore: release ${version}",
132
+ "tagName": "v${version}"
133
+ },
134
+ "npm": {
135
+ "publish": true,
136
+ "access": true
137
+ },
138
+ "github": {
139
+ "release": true
140
+ },
141
+ "plugins": {
142
+ "@release-it/conventional-changelog": {
143
+ "preset": {
144
+ "name": "angular"
145
+ }
146
+ }
147
+ }
148
+ },
149
+ "eslintConfig": {
150
+ "root": true,
151
+ "extends": [
152
+ "@react-native",
153
+ "prettier"
154
+ ],
155
+ "rules": {
156
+ "react/react-in-jsx-scope": "off",
157
+ "react-hooks/rules-of-hooks": "off",
158
+ "react-hooks/exhaustive-deps": "off",
159
+ "prettier/prettier": "off"
160
+ }
161
+ },
162
+ "eslintIgnore": [
163
+ "node_modules/",
164
+ "lib/"
165
+ ],
166
+ "prettier": {
167
+ "quoteProps": "consistent",
168
+ "singleQuote": true,
169
+ "tabWidth": 2,
170
+ "trailingComma": "es5",
171
+ "useTabs": false
172
+ },
173
+ "react-native-builder-bob": {
174
+ "source": "src",
175
+ "output": "lib",
176
+ "targets": [
177
+ [
178
+ "commonjs",
179
+ {
180
+ "esm": true
181
+ }
182
+ ],
183
+ [
184
+ "module",
185
+ {
186
+ "esm": true
187
+ }
188
+ ],
189
+ [
190
+ "typescript",
191
+ {
192
+ "project": "tsconfig.build.json",
193
+ "esm": true
194
+ }
195
+ ]
196
+ ]
197
+ },
198
+ "create-react-native-library": {
199
+ "languages": "js",
200
+ "type": "library",
201
+ "version": "0.48.5"
202
+ }
203
+ }
@@ -0,0 +1,174 @@
1
+ import type {
2
+ AnimateComponentAnimationConfig,
3
+ AnimateComponentRef,
4
+ } from '@shaquillehinds/react-native-essentials';
5
+ import {
6
+ isAndroid,
7
+ radiusSizes,
8
+ useDeviceOrientation,
9
+ } from '@shaquillehinds/react-native-essentials';
10
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
11
+ import type { Animated, LayoutChangeEvent, ViewStyle } from 'react-native';
12
+ import { ScrollView } from 'react-native-gesture-handler';
13
+ import type { DropDownSelectorProps } from './DropDownSelector.types';
14
+
15
+ export function DropDownSelectorController<T>(props: DropDownSelectorProps<T>) {
16
+ const [showItems, setShowItems] = useState(false);
17
+ const [hasPageY, setHasPageY] = useState(false);
18
+
19
+ const { screenHeight, relativeY } = useDeviceOrientation();
20
+
21
+ const pageYRef = useRef<number | null>(null);
22
+ const scrollViewRef = useRef<ScrollView | null>(null);
23
+ const canRenderDownRef = useRef<boolean | null>(null);
24
+ const animateChevronRef = useRef<AnimateComponentRef<number>>(null);
25
+ const animateComponentRef = useRef<AnimateComponentRef<number>>(null);
26
+ const animateAndroidShadowRef = useRef<AnimateComponentRef<number>>(null);
27
+
28
+ const unMountDelayInMilliSeconds = useMemo(() => {
29
+ if (props.expandAnimationConfig?.type === 'timing')
30
+ return props.expandAnimationConfig?.duration || 300;
31
+ return props.unMountDelayInMilliSeconds || 300;
32
+ }, [props.expandAnimationConfig]);
33
+ const maxHeight = useMemo(
34
+ () => props.expandDistance || relativeY(30),
35
+ [relativeY, props.expandDistance]
36
+ );
37
+ const label = useMemo(
38
+ () => props.items.find((item) => item.value === props.selectedItem)?.label,
39
+ [props.items, props.selectedItem]
40
+ );
41
+ const canRenderDown = useMemo(() => {
42
+ if (props.expandDirection === 'up') return false;
43
+ if (props.expandDirection === 'down') return true;
44
+ if (!pageYRef.current) return null;
45
+ if (!showItems && canRenderDownRef.current !== null)
46
+ return canRenderDownRef.current;
47
+ const distanceToBottom = screenHeight - pageYRef.current;
48
+ if (distanceToBottom < maxHeight) canRenderDownRef.current = false;
49
+ else canRenderDownRef.current = true;
50
+ return canRenderDownRef.current;
51
+ }, [showItems, screenHeight, maxHeight, hasPageY]);
52
+ const androidShadowAnimationConfig = useMemo<AnimateComponentAnimationConfig>(
53
+ () => ({
54
+ toValue: 1,
55
+ type: 'timing',
56
+ useNativeDriver: true,
57
+ duration: canRenderDown ? (showItems ? 400 : 200) : showItems ? 800 : 100,
58
+ }),
59
+ [canRenderDown, showItems]
60
+ );
61
+ const scrollViewStyle = useMemo<ViewStyle>(
62
+ () => ({
63
+ overflow: 'hidden',
64
+ maxHeight: maxHeight,
65
+ minHeight: relativeY(5),
66
+ borderRadius: radiusSizes.soft,
67
+ transform: [
68
+ { translateY: canRenderDown ? 0 : -maxHeight + relativeY(4) },
69
+ ],
70
+ }),
71
+ [canRenderDown, maxHeight, relativeY]
72
+ );
73
+ const chevronAnimationConfig = useMemo<AnimateComponentAnimationConfig>(
74
+ () => ({
75
+ toValue: canRenderDown ? 1 : -1,
76
+ type: 'spring',
77
+ speed: 1,
78
+ bounciness: 1,
79
+ useNativeDriver: true,
80
+ }),
81
+ [canRenderDown]
82
+ );
83
+ const selectionItemsListAnimationConfig =
84
+ useMemo<AnimateComponentAnimationConfig>(
85
+ () => ({
86
+ toValue: 0,
87
+ type: 'spring',
88
+ speed: 1,
89
+ bounciness: 1,
90
+ useNativeDriver: true,
91
+ }),
92
+ []
93
+ );
94
+ const chevronAnimatedStyle = useCallback(
95
+ (scaleY: Animated.Value): ViewStyle => ({
96
+ transform: [{ scaleY }],
97
+ }),
98
+ []
99
+ );
100
+
101
+ const handleLayout = useCallback(
102
+ (e: LayoutChangeEvent) => {
103
+ e.currentTarget.measure((_x, _y, _width, _height, _pageX, pageY) => {
104
+ pageYRef.current = pageY || screenHeight / 2;
105
+ setHasPageY(true);
106
+ });
107
+ props.containerProps?.onLayout?.(e);
108
+ },
109
+ [props.containerProps?.onLayout]
110
+ );
111
+ const androidShadowAnimatedStyle = useCallback(
112
+ (opacity: Animated.Value): ViewStyle => ({
113
+ opacity,
114
+ right: 0,
115
+ left: 0,
116
+ top: 0,
117
+ bottom: 0,
118
+ position: 'absolute',
119
+ boxShadow: canRenderDown
120
+ ? '5px 18px 25px 0px rgba(0,0,0,0.15)'
121
+ : '5px -18px 25px 0px rgba(0,0,0,0.15)',
122
+ borderRadius: radiusSizes.soft,
123
+ transform: [
124
+ {
125
+ translateY: canRenderDown ? 0 : -maxHeight + relativeY(4),
126
+ },
127
+ ],
128
+ }),
129
+ [canRenderDown, maxHeight, relativeY]
130
+ );
131
+
132
+ const selectionItemsListAnimatedStyle = useCallback(
133
+ (translateY: Animated.Value): ViewStyle => ({
134
+ transform: [{ translateY }],
135
+ }),
136
+ []
137
+ );
138
+
139
+ useEffect(() => {
140
+ if (animateComponentRef.current && !showItems)
141
+ animateComponentRef.current.reverse();
142
+ if (animateChevronRef.current) {
143
+ if (showItems) animateChevronRef.current.start();
144
+ else {
145
+ animateChevronRef.current.reverse();
146
+ }
147
+ }
148
+ if (isAndroid && !showItems) animateAndroidShadowRef.current?.reverse();
149
+ }, [showItems]);
150
+
151
+ return {
152
+ showItems,
153
+ setShowItems,
154
+ label,
155
+ canRenderDown,
156
+ relativeY,
157
+ scrollViewRef,
158
+ animateComponentRef,
159
+ animateChevronRef,
160
+ animateAndroidShadowRef,
161
+ pageYRef,
162
+ canRenderDownRef,
163
+ maxHeight,
164
+ handleLayout,
165
+ androidShadowAnimatedStyle,
166
+ androidShadowAnimationConfig,
167
+ scrollViewStyle,
168
+ selectionItemsListAnimatedStyle,
169
+ selectionItemsListAnimationConfig,
170
+ chevronAnimationConfig,
171
+ chevronAnimatedStyle,
172
+ unMountDelayInMilliSeconds,
173
+ };
174
+ }