react-native-input-select 1.3.7 → 1.3.9

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 (96) hide show
  1. package/README.md +35 -34
  2. package/lib/commonjs/components/CheckBox/index.js +1 -1
  3. package/lib/commonjs/components/CheckBox/index.js.map +1 -1
  4. package/lib/commonjs/components/CustomModal/index.js +5 -5
  5. package/lib/commonjs/components/CustomModal/index.js.map +1 -1
  6. package/lib/commonjs/components/Dropdown/Dropdown.js +5 -3
  7. package/lib/commonjs/components/Dropdown/Dropdown.js.map +1 -1
  8. package/lib/commonjs/components/Dropdown/DropdownFlatList.js +2 -2
  9. package/lib/commonjs/components/Dropdown/DropdownFlatList.js.map +1 -1
  10. package/lib/commonjs/components/Dropdown/DropdownListItem.js +1 -1
  11. package/lib/commonjs/components/Dropdown/DropdownListItem.js.map +1 -1
  12. package/lib/commonjs/components/Dropdown/DropdownSectionList.js +2 -2
  13. package/lib/commonjs/components/Dropdown/DropdownSectionList.js.map +1 -1
  14. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js +7 -7
  15. package/lib/commonjs/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
  16. package/lib/commonjs/components/Input/index.js +1 -1
  17. package/lib/commonjs/components/Input/index.js.map +1 -1
  18. package/lib/commonjs/components/Others/index.js +1 -1
  19. package/lib/commonjs/components/Others/index.js.map +1 -1
  20. package/lib/commonjs/index.js +19 -8
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/module/components/CustomModal/index.js +4 -4
  23. package/lib/module/components/CustomModal/index.js.map +1 -1
  24. package/lib/module/components/Dropdown/Dropdown.js +4 -2
  25. package/lib/module/components/Dropdown/Dropdown.js.map +1 -1
  26. package/lib/module/components/Dropdown/DropdownFlatList.js +1 -1
  27. package/lib/module/components/Dropdown/DropdownFlatList.js.map +1 -1
  28. package/lib/module/components/Dropdown/DropdownSectionList.js +1 -1
  29. package/lib/module/components/Dropdown/DropdownSectionList.js.map +1 -1
  30. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js +6 -6
  31. package/lib/module/components/Dropdown/DropdownSelectedItemsView.js.map +1 -1
  32. package/lib/module/components/Input/index.js +1 -1
  33. package/lib/module/index.js +18 -7
  34. package/lib/module/index.js.map +1 -1
  35. package/lib/typescript/jest-setup.d.ts +2 -0
  36. package/lib/typescript/jest-setup.d.ts.map +1 -0
  37. package/lib/typescript/src/components/CheckBox/checkbox.types.d.ts.map +1 -0
  38. package/lib/typescript/src/components/CheckBox/index.d.ts.map +1 -0
  39. package/lib/typescript/src/components/CustomModal/index.d.ts +6 -0
  40. package/lib/typescript/src/components/CustomModal/index.d.ts.map +1 -0
  41. package/lib/typescript/src/components/Dropdown/Dropdown.d.ts +4 -0
  42. package/lib/typescript/src/components/Dropdown/Dropdown.d.ts.map +1 -0
  43. package/lib/typescript/src/components/Dropdown/DropdownFlatList.d.ts.map +1 -0
  44. package/lib/typescript/src/components/Dropdown/DropdownListItem.d.ts.map +1 -0
  45. package/lib/typescript/src/components/Dropdown/DropdownSectionList.d.ts.map +1 -0
  46. package/lib/typescript/src/components/Dropdown/DropdownSelectedItemsView.d.ts +4 -0
  47. package/lib/typescript/src/components/Dropdown/DropdownSelectedItemsView.d.ts.map +1 -0
  48. package/lib/typescript/src/components/Input/index.d.ts.map +1 -0
  49. package/lib/typescript/src/components/Others/index.d.ts.map +1 -0
  50. package/lib/typescript/src/constants/index.d.ts.map +1 -0
  51. package/lib/typescript/src/index.d.ts.map +1 -0
  52. package/lib/typescript/src/styles/colors.d.ts.map +1 -0
  53. package/lib/typescript/src/styles/input.d.ts.map +1 -0
  54. package/lib/typescript/src/styles/typography.d.ts.map +1 -0
  55. package/lib/typescript/{types → src/types}/index.types.d.ts +8 -3
  56. package/lib/typescript/src/types/index.types.d.ts.map +1 -0
  57. package/lib/typescript/src/utils/index.d.ts.map +1 -0
  58. package/package.json +9 -2
  59. package/src/components/CustomModal/index.tsx +5 -3
  60. package/src/components/Dropdown/Dropdown.tsx +4 -2
  61. package/src/components/Dropdown/DropdownSelectedItemsView.tsx +5 -5
  62. package/src/index.tsx +18 -6
  63. package/src/types/index.types.ts +7 -3
  64. package/lib/typescript/components/CheckBox/checkbox.types.d.ts.map +0 -1
  65. package/lib/typescript/components/CheckBox/index.d.ts.map +0 -1
  66. package/lib/typescript/components/CustomModal/index.d.ts +0 -6
  67. package/lib/typescript/components/CustomModal/index.d.ts.map +0 -1
  68. package/lib/typescript/components/Dropdown/Dropdown.d.ts +0 -4
  69. package/lib/typescript/components/Dropdown/Dropdown.d.ts.map +0 -1
  70. package/lib/typescript/components/Dropdown/DropdownFlatList.d.ts.map +0 -1
  71. package/lib/typescript/components/Dropdown/DropdownListItem.d.ts.map +0 -1
  72. package/lib/typescript/components/Dropdown/DropdownSectionList.d.ts.map +0 -1
  73. package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts +0 -4
  74. package/lib/typescript/components/Dropdown/DropdownSelectedItemsView.d.ts.map +0 -1
  75. package/lib/typescript/components/Input/index.d.ts.map +0 -1
  76. package/lib/typescript/components/Others/index.d.ts.map +0 -1
  77. package/lib/typescript/constants/index.d.ts.map +0 -1
  78. package/lib/typescript/index.d.ts.map +0 -1
  79. package/lib/typescript/styles/colors.d.ts.map +0 -1
  80. package/lib/typescript/styles/input.d.ts.map +0 -1
  81. package/lib/typescript/styles/typography.d.ts.map +0 -1
  82. package/lib/typescript/types/index.types.d.ts.map +0 -1
  83. package/lib/typescript/utils/index.d.ts.map +0 -1
  84. /package/lib/typescript/{components → src/components}/CheckBox/checkbox.types.d.ts +0 -0
  85. /package/lib/typescript/{components → src/components}/CheckBox/index.d.ts +0 -0
  86. /package/lib/typescript/{components → src/components}/Dropdown/DropdownFlatList.d.ts +0 -0
  87. /package/lib/typescript/{components → src/components}/Dropdown/DropdownListItem.d.ts +0 -0
  88. /package/lib/typescript/{components → src/components}/Dropdown/DropdownSectionList.d.ts +0 -0
  89. /package/lib/typescript/{components → src/components}/Input/index.d.ts +0 -0
  90. /package/lib/typescript/{components → src/components}/Others/index.d.ts +0 -0
  91. /package/lib/typescript/{constants → src/constants}/index.d.ts +0 -0
  92. /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
  93. /package/lib/typescript/{styles → src/styles}/colors.d.ts +0 -0
  94. /package/lib/typescript/{styles → src/styles}/input.d.ts +0 -0
  95. /package/lib/typescript/{styles → src/styles}/typography.d.ts +0 -0
  96. /package/lib/typescript/{utils → src/utils}/index.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,eAAO,MAAM,KAAK,gGAQf,GAAG,sBA4BL,CAAC;AAMF,eAAe,KAAK,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/Others/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAKL,SAAS,EAET,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,kBAAkB,mDAG5B,GAAG,sBAQL,CAAC;AAEF,eAAO,MAAM,sBAAsB,4BAEhC;IACD,kBAAkB,EAAE,SAAS,CAAC;CAC/B,sBAEA,CAAC;AAEF,eAAO,MAAM,iBAAiB,0CAG3B;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,sBAAsB,EAAE,SAAS,CAAC;CACnC,sBAMA,CAAC;AAEF,eAAO,MAAM,kBAAkB,wDAK5B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB,sBAaA,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,aAAa,KAAK,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAUxE,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA0blD,CAAC;AAUF,eAAe,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../src/styles/colors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE,GASpB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/styles/input.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,EAAE,GAsBxB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../../src/styles/typography.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,EAAE,GAOvB,CAAC"}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import type { ViewStyle, ColorValue, TextStyle, ModalProps, TextInputProps } from 'react-native';
3
3
  export type DropdownProps = CommonDropdownProps & TDropdownInputProps & TSearchControls & TCheckboxControls & TCustomModalControls & TListControls;
4
4
  export type CommonDropdownProps = {
@@ -8,6 +8,7 @@ export type CommonDropdownProps = {
8
8
  optionValue?: string;
9
9
  onValueChange: Function;
10
10
  selectedValue?: string | boolean | number | string[] | boolean[] | number[] | null;
11
+ autoCloseOnSelect?: boolean;
11
12
  };
12
13
  export type TDropdownInputProps = {
13
14
  placeholder?: string;
@@ -71,8 +72,11 @@ export type TCustomModalControls = {
71
72
  modalControls?: {
72
73
  modalBackgroundStyle?: ViewStyle;
73
74
  modalOptionsContainerStyle?: ViewStyle;
74
- modalProps?: ModalProps;
75
+ modalProps?: ModalProps & TCloseModal;
75
76
  };
77
+ } & TCloseModal;
78
+ type TCloseModal = {
79
+ closeModal?: () => void;
76
80
  };
77
81
  export type TListControls = {
78
82
  listHeaderComponent?: React.ReactNode;
@@ -93,11 +97,12 @@ export type TListControls = {
93
97
  };
94
98
  export type TFlatList = TFlatListItem[];
95
99
  export type TFlatListItem = {
96
- [key: string]: string | number | boolean;
100
+ [key: string]: string | number | boolean | React.JSX.Element;
97
101
  };
98
102
  export type TSectionList = TSectionListItem[];
99
103
  export type TSectionListItem = {
100
104
  title: string;
101
105
  data: TFlatList;
102
106
  };
107
+ export {};
103
108
  //# sourceMappingURL=index.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../../../src/types/index.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAC7C,mBAAmB,GACnB,eAAe,GACf,iBAAiB,GACjB,oBAAoB,GACpB,aAAa,CAAC;AAEhB,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,GAAG,YAAY,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,QAAQ,CAAC;IACxB,aAAa,CAAC,EACV,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,EAAE,GACR,OAAO,EAAE,GACT,MAAM,EA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CAAC;IACF,YAAY,CAAC,EAAE;QACb,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;QAC/B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;QACjC,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;AACxC,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CAC9D,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,wBAAwB,QAAS,GAAG,EAAE,YAAY,MAAM,UAIpE,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,WAExC,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-native-input-select",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "description": "A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
- "types": "lib/typescript/index.d.ts",
7
+ "types": "lib/typescript/src/types/index.types.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -56,9 +56,14 @@
56
56
  "registry": "https://registry.npmjs.org/"
57
57
  },
58
58
  "devDependencies": {
59
+ "@babel/plugin-transform-private-methods": "^7.24.7",
60
+ "@babel/plugin-transform-private-property-in-object": "^7.24.7",
61
+ "@babel/preset-typescript": "^7.24.7",
59
62
  "@commitlint/config-conventional": "^19.2.2",
60
63
  "@react-native-community/eslint-config": "^3.2.0",
61
64
  "@release-it/conventional-changelog": "^8.0.1",
65
+ "@testing-library/jest-dom": "^6.4.8",
66
+ "@testing-library/react-native": "^12.5.1",
62
67
  "@types/jest": "^29.5.12",
63
68
  "@types/react": "18.3.2",
64
69
  "@types/react-native": "^0.73.0",
@@ -68,11 +73,13 @@
68
73
  "eslint-plugin-prettier": "^5.1.3",
69
74
  "husky": "^9.0.11",
70
75
  "jest": "^29.7.0",
76
+ "metro-react-native-babel-preset": "^0.77.0",
71
77
  "pod-install": "^0.2.2",
72
78
  "prettier": "^3.2.5",
73
79
  "react": "^18.3.1",
74
80
  "react-native": "^0.74.1",
75
81
  "react-native-builder-bob": "^0.23.2",
82
+ "react-test-renderer": "^18.3.1",
76
83
  "release-it": "^17.2.1",
77
84
  "typescript": "^5.4.5"
78
85
  },
@@ -32,7 +32,7 @@ const ModalContentWrapper = ({
32
32
 
33
33
  const CustomModal = ({
34
34
  visible,
35
- onRequestClose,
35
+ closeModal,
36
36
  modalBackgroundStyle, //kept for backwards compatibility
37
37
  modalOptionsContainerStyle, //kept for backwards compatibility
38
38
  modalControls,
@@ -43,7 +43,7 @@ const CustomModal = ({
43
43
  <Modal
44
44
  transparent={true}
45
45
  visible={visible}
46
- onRequestClose={(e) => onRequestClose?.(e)}
46
+ onRequestClose={() => closeModal?.()}
47
47
  animationType="fade"
48
48
  {...modalControls?.modalProps}
49
49
  {...modalProps} //kept for backwards compatibility
@@ -51,7 +51,9 @@ const CustomModal = ({
51
51
  {/*Used to fix the select with search box behavior in iOS*/}
52
52
  <ModalContentWrapper>
53
53
  <TouchableOpacity
54
- onPress={(e) => onRequestClose?.(e)}
54
+ onPress={() =>
55
+ closeModal?.() || modalControls?.modalProps?.closeModal?.()
56
+ }
55
57
  style={[
56
58
  styles.modalContainer,
57
59
  styles.modalBackgroundStyle,
@@ -10,7 +10,8 @@ const Dropdown = ({
10
10
  helperText,
11
11
  error,
12
12
  getSelectedItemsLabel,
13
- handleToggleModal,
13
+ openModal,
14
+ closeModal,
14
15
  isMultiple,
15
16
  selectedItem,
16
17
  selectedItems,
@@ -39,7 +40,8 @@ const Dropdown = ({
39
40
  placeholder={placeholder}
40
41
  error={error}
41
42
  getSelectedItemsLabel={getSelectedItemsLabel}
42
- handleToggleModal={handleToggleModal}
43
+ openModal={openModal}
44
+ closeModal={closeModal}
43
45
  isMultiple={isMultiple}
44
46
  selectedItem={selectedItem}
45
47
  selectedItems={selectedItems}
@@ -15,7 +15,7 @@ const DropdownSelectedItemsView = ({
15
15
  placeholder,
16
16
  error,
17
17
  getSelectedItemsLabel,
18
- handleToggleModal,
18
+ openModal,
19
19
  isMultiple,
20
20
  selectedItem,
21
21
  selectedItems,
@@ -32,7 +32,7 @@ const DropdownSelectedItemsView = ({
32
32
  }: any) => {
33
33
  return (
34
34
  <Pressable
35
- onPress={() => handleToggleModal()}
35
+ onPress={() => openModal()}
36
36
  style={({ pressed }) => [
37
37
  pressed && {
38
38
  ...inputStyles.inputFocusState,
@@ -61,7 +61,7 @@ const DropdownSelectedItemsView = ({
61
61
  getSelectedItemsLabel()?.map((label: string, i: Number) => (
62
62
  <DropdownContent
63
63
  onPress={() => {
64
- handleToggleModal();
64
+ openModal();
65
65
  setIndexOfSelectedItem(label); // immediately scrolls to list item with the specified label when modal
66
66
  }}
67
67
  key={`react-native-input-select-${Math.random()}-${i}`}
@@ -77,7 +77,7 @@ const DropdownSelectedItemsView = ({
77
77
  ) : (
78
78
  <DropdownContent
79
79
  onPress={() => {
80
- handleToggleModal();
80
+ openModal();
81
81
  setIndexOfSelectedItem(getSelectedItemsLabel()); // immediately scrolls to list item with the specified label when modal
82
82
  }}
83
83
  style={[styles.blackText, selectedItemStyle]}
@@ -87,7 +87,7 @@ const DropdownSelectedItemsView = ({
87
87
  )}
88
88
  {!selectedItem && selectedItems?.length === 0 && (
89
89
  <DropdownContent
90
- onPress={() => handleToggleModal()}
90
+ onPress={() => openModal()}
91
91
  style={[styles.blackText, placeholderStyle]}
92
92
  label={placeholder ?? 'Select an option'}
93
93
  disabled={disabled}
package/src/index.tsx CHANGED
@@ -59,6 +59,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
59
59
  searchControls,
60
60
  modalControls,
61
61
  checkboxControls,
62
+ autoCloseOnSelect=true,
62
63
  ...rest
63
64
  }) => {
64
65
  const [newOptions, setNewOptions] = useState<TFlatList | TSectionList>([]);
@@ -122,7 +123,10 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
122
123
  } else {
123
124
  setSelectedItem(value);
124
125
  onValueChange(value); // send value to parent
126
+
127
+ if(autoCloseOnSelect){
125
128
  setOpen(false); // close modal upon selection
129
+ }
126
130
  }
127
131
  };
128
132
 
@@ -298,13 +302,20 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
298
302
  /*===========================================
299
303
  * Modal
300
304
  *==========================================*/
301
- const handleToggleModal = () => {
305
+ const openModal = () => {
302
306
  if (disabled) {
303
- // protecting any toggleModal invocation when Dropdown is disabled by not activating state
304
307
  return;
305
308
  }
309
+ setOpen(true);
310
+ resetComponent();
311
+ };
312
+
313
+ const closeModal = () => {
314
+ setOpen(false);
315
+ resetComponent();
316
+ };
306
317
 
307
- setOpen(!open);
318
+ const resetComponent = () => {
308
319
  setSearchValue('');
309
320
  setNewOptions(options);
310
321
  setListIndex({ itemIndex: -1, sectionIndex: -1 });
@@ -352,7 +363,8 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
352
363
  getSelectedItemsLabel={getSelectedItemsLabel}
353
364
  selectedItem={selectedItem}
354
365
  selectedItems={selectedItems}
355
- handleToggleModal={handleToggleModal}
366
+ openModal={openModal}
367
+ closeModal={closeModal}
356
368
  labelStyle={labelStyle}
357
369
  dropdownIcon={dropdownIcon}
358
370
  dropdownStyle={dropdownStyle}
@@ -374,7 +386,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
374
386
  visible={open}
375
387
  modalBackgroundStyle={modalBackgroundStyle} // kept for backwards compatibility
376
388
  modalOptionsContainerStyle={modalOptionsContainerStyle} // kept for backwards compatibility
377
- onRequestClose={() => handleToggleModal()}
389
+ closeModal={closeModal}
378
390
  modalControls={modalControls}
379
391
  modalProps={modalProps} // kept for backwards compatibility
380
392
  >
@@ -382,7 +394,7 @@ export const DropdownSelect: React.FC<DropdownProps> = ({
382
394
  ListHeaderComponent={
383
395
  <>
384
396
  {isSearchable && (
385
- <Input
397
+ <Input
386
398
  value={searchValue}
387
399
  onChangeText={(text: string) => onSearch(text)}
388
400
  style={searchControls?.textInputStyle || searchInputStyle}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import type {
2
3
  ViewStyle,
3
4
  ColorValue,
@@ -27,6 +28,7 @@ export type CommonDropdownProps = {
27
28
  | boolean[]
28
29
  | number[]
29
30
  | null;
31
+ autoCloseOnSelect?: boolean;
30
32
  };
31
33
 
32
34
  export type TDropdownInputProps = {
@@ -93,9 +95,11 @@ export type TCustomModalControls = {
93
95
  modalControls?: {
94
96
  modalBackgroundStyle?: ViewStyle;
95
97
  modalOptionsContainerStyle?: ViewStyle;
96
- modalProps?: ModalProps;
98
+ modalProps?: ModalProps & TCloseModal;
97
99
  };
98
- };
100
+ } & TCloseModal;
101
+
102
+ type TCloseModal = { closeModal?: () => void };
99
103
 
100
104
  export type TListControls = {
101
105
  listHeaderComponent?: React.ReactNode;
@@ -117,7 +121,7 @@ export type TListControls = {
117
121
 
118
122
  export type TFlatList = TFlatListItem[];
119
123
  export type TFlatListItem = {
120
- [key: string]: string | number | boolean;
124
+ [key: string]: string | number | boolean | React.JSX.Element;
121
125
  };
122
126
 
123
127
  export type TSectionList = TSectionListItem[];
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkbox.types.d.ts","sourceRoot":"","sources":["../../../../src/components/CheckBox/checkbox.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CACvD,GAAG,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CheckBox/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,QAAA,MAAM,QAAQ,uKAYX,aAAa,sBAoEf,CAAC;AAkBF,eAAe,QAAQ,CAAC"}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { ModalProps } from 'react-native';
3
- import { TCustomModalControls } from 'src/types/index.types';
4
- declare const CustomModal: ({ visible, onRequestClose, modalBackgroundStyle, modalOptionsContainerStyle, modalControls, modalProps, children, }: TCustomModalControls & ModalProps) => React.JSX.Element;
5
- export default CustomModal;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/CustomModal/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,EAGL,UAAU,EAMX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAoB7D,QAAA,MAAM,WAAW,wHAQd,oBAAoB,GAAG,UAAU,sBAoCnC,CAAC;AAiBF,eAAe,WAAW,CAAC"}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare const Dropdown: ({ label, placeholder, helperText, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, labelStyle, dropdownStyle, dropdownIconStyle, dropdownContainerStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, dropdownErrorTextStyle, dropdownHelperTextStyle, primaryColor, disabled, setIndexOfSelectedItem, }: any) => React.JSX.Element;
3
- export default Dropdown;
4
- //# sourceMappingURL=Dropdown.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,QAAA,MAAM,QAAQ,2YAwBX,GAAG,sBAsCL,CAAC;AAUF,eAAe,QAAQ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownFlatList.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownFlatList.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAMjD,QAAA,MAAM,gBAAgB,0UAqBnB,GAAG,sBAgEL,CAAC;AA2BF,eAAe,gBAAgB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownListItem.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownListItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;;AAyDpC,wBAAsC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownSectionList.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownSectionList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAW3D,QAAA,MAAM,mBAAmB,0UAqBtB,GAAG,sBAwGL,CAAC;AA+BF,eAAe,mBAAmB,CAAC"}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare const DropdownSelectedItemsView: ({ placeholder, error, getSelectedItemsLabel, handleToggleModal, isMultiple, selectedItem, selectedItems, dropdownIcon, dropdownStyle, dropdownIconStyle, selectedItemStyle, placeholderStyle, multipleSelectedItemStyle, dropdownErrorStyle, primaryColor, disabled, setIndexOfSelectedItem, }: any) => React.JSX.Element;
3
- export default DropdownSelectedItemsView;
4
- //# sourceMappingURL=DropdownSelectedItemsView.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownSelectedItemsView.d.ts","sourceRoot":"","sources":["../../../../src/components/Dropdown/DropdownSelectedItemsView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B,QAAA,MAAM,yBAAyB,mSAkB5B,GAAG,sBAyEL,CAAC;AA6BF,eAAe,yBAAyB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Input/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,eAAO,MAAM,KAAK,gGAQf,GAAG,sBA4BL,CAAC;AAMF,eAAe,KAAK,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Others/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAKL,SAAS,EAET,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,kBAAkB,mDAG5B,GAAG,sBAQL,CAAC;AAEF,eAAO,MAAM,sBAAsB,4BAEhC;IACD,kBAAkB,EAAE,SAAS,CAAC;CAC/B,sBAEA,CAAC;AAEF,eAAO,MAAM,iBAAiB,0CAG3B;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,sBAAsB,EAAE,SAAS,CAAC;CACnC,sBAMA,CAAC;AAEF,eAAO,MAAM,kBAAkB,wDAK5B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;CACrB,sBAaA,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,aAAa,KAAK,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAUxE,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA8alD,CAAC;AAUF,eAAe,cAAc,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/styles/colors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE,GASpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/styles/input.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW,EAAE,GAsBxB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"typography.d.ts","sourceRoot":"","sources":["../../../src/styles/typography.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,EAAE,GAOvB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.d.ts","sourceRoot":"","sources":["../../../src/types/index.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,SAAS,EACT,UAA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vC,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,mBAAmB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,mBAAmB,CAAC,EAAE;QACpB,uBAAuB,CAAC,EAAE,SAAS,CAAC;QACpC,kBAAkB,CAAC,EAAE,SAAS,CAAC;QAC/B,kBAAkB,CAAC,EAAE,SAAS,CAAC;KAChC,CAAC;IACF,YAAY,CAAC,EAAE;QACb,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;QAC/B,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;QACjC,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;AACxC,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,EAAE,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,wBAAwB,QAAS,GAAG,EAAE,YAAY,MAAM,UAIpE,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,WAExC,CAAC"}
File without changes
File without changes