@tecsinapse/react-native-kit 3.4.1 → 3.5.0-beta.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.
Files changed (42) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +9 -7
  3. package/dist/cjs/components/atoms/Modal/ModalGroupManager.js +1 -0
  4. package/dist/cjs/components/atoms/Modal/ModalLifecycleHandler.js +5 -0
  5. package/dist/cjs/components/atoms/Modal/ui/BaseModalView.js +3 -6
  6. package/dist/cjs/components/molecules/Select/Select.js +42 -157
  7. package/dist/cjs/components/molecules/Select/components/Flat.js +24 -0
  8. package/dist/cjs/components/molecules/Select/components/Modal.js +96 -0
  9. package/dist/cjs/components/molecules/Select/components/Option.js +50 -0
  10. package/dist/cjs/components/molecules/Select/components/Section.js +29 -0
  11. package/dist/cjs/components/molecules/Select/functions.js +43 -0
  12. package/dist/cjs/components/molecules/Select/hooks/useModal.js +109 -0
  13. package/dist/cjs/components/molecules/Select/hooks/useSelect.js +147 -0
  14. package/dist/cjs/components/molecules/Select/styled.js +12 -2
  15. package/dist/esm/components/atoms/Modal/ModalGroupManager.js +1 -0
  16. package/dist/esm/components/atoms/Modal/ModalLifecycleHandler.js +5 -0
  17. package/dist/esm/components/atoms/Modal/ui/BaseModalView.js +3 -6
  18. package/dist/esm/components/molecules/Select/Select.js +44 -141
  19. package/dist/esm/components/molecules/Select/components/Flat.js +22 -0
  20. package/dist/esm/components/molecules/Select/components/Modal.js +94 -0
  21. package/dist/esm/components/molecules/Select/components/Option.js +48 -0
  22. package/dist/esm/components/molecules/Select/components/Section.js +27 -0
  23. package/dist/esm/components/molecules/Select/functions.js +35 -0
  24. package/dist/esm/components/molecules/Select/hooks/useModal.js +107 -0
  25. package/dist/esm/components/molecules/Select/hooks/useSelect.js +145 -0
  26. package/dist/esm/components/molecules/Select/styled.js +11 -3
  27. package/dist/types/components/atoms/Modal/ModalLifecycleHandler.d.ts +1 -0
  28. package/dist/types/components/molecules/Select/Select.d.ts +2 -23
  29. package/dist/types/components/molecules/Select/components/Flat.d.ts +8 -0
  30. package/dist/types/components/molecules/Select/components/Modal.d.ts +4 -0
  31. package/dist/types/components/molecules/Select/components/Option.d.ts +10 -0
  32. package/dist/types/components/molecules/Select/components/Section.d.ts +8 -0
  33. package/dist/types/components/molecules/Select/functions.d.ts +9 -0
  34. package/dist/types/components/molecules/Select/hooks/useModal.d.ts +66 -0
  35. package/dist/types/components/molecules/Select/hooks/useSelect.d.ts +58 -0
  36. package/dist/types/components/molecules/Select/index.d.ts +1 -1
  37. package/dist/types/components/molecules/Select/styled.d.ts +12 -0
  38. package/dist/types/components/molecules/Select/types.d.ts +33 -0
  39. package/package.json +9 -6
  40. package/dist/cjs/components/molecules/Select/Modal.js +0 -224
  41. package/dist/esm/components/molecules/Select/Modal.js +0 -203
  42. package/dist/types/components/molecules/Select/Modal.d.ts +0 -8
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var styled = require('../styled.js');
5
+ var Option = require('../components/Option.js');
6
+ var reactCore = require('@tecsinapse/react-core');
7
+ var functions = require('../functions.js');
8
+
9
+ const useModal = ({
10
+ keyExtractor,
11
+ labelExtractor,
12
+ focused,
13
+ type,
14
+ value,
15
+ onSelect,
16
+ onSearch,
17
+ close,
18
+ closeOnPick,
19
+ ...others
20
+ }) => {
21
+ const [selectedValues, setSelectedValues] = React.useState([]);
22
+ const [searchArg, setSearchArg] = reactCore.useDebouncedState("", onSearch);
23
+ const ModalComponent = React.useMemo(
24
+ () => styled.getStyledModal(reactCore.getStatusBarHeight(true)),
25
+ []
26
+ );
27
+ const _closeOnPick = closeOnPick && type === "single";
28
+ React.useEffect(() => {
29
+ setSelectedValues(
30
+ value ? type === "multi" ? value : [value] : []
31
+ );
32
+ }, [value, focused, setSelectedValues]);
33
+ const getData = React.useCallback(
34
+ (_options) => {
35
+ return _options.map((option, index) => {
36
+ return {
37
+ ...option,
38
+ _checked: functions.isOptionChecked(
39
+ type,
40
+ option,
41
+ selectedValues,
42
+ keyExtractor,
43
+ index
44
+ )
45
+ };
46
+ });
47
+ },
48
+ [type, selectedValues, keyExtractor]
49
+ );
50
+ const handlePressItem = React.useCallback(
51
+ (option) => {
52
+ setSelectedValues(
53
+ (prev) => type === "multi" ? functions.multiBuilder(option, prev, keyExtractor) : functions.singleBuilder(option, prev, keyExtractor)
54
+ );
55
+ },
56
+ [keyExtractor, type]
57
+ );
58
+ React.useEffect(() => {
59
+ if (_closeOnPick && selectedValues[0] && selectedValues[0] !== value) {
60
+ handleConfirm();
61
+ }
62
+ }, [selectedValues[0], value, closeOnPick]);
63
+ const handleConfirm = React.useCallback(() => {
64
+ onSelect(
65
+ type === "single" ? selectedValues[0] : selectedValues
66
+ );
67
+ close?.();
68
+ }, [selectedValues]);
69
+ const renderItem = React.useCallback(
70
+ ({ item }) => /* @__PURE__ */ React.createElement(
71
+ Option,
72
+ {
73
+ item,
74
+ type,
75
+ handlePressItem: (t) => {
76
+ handlePressItem(t);
77
+ },
78
+ labelExtractor
79
+ }
80
+ ),
81
+ [type, handlePressItem, labelExtractor]
82
+ );
83
+ return {
84
+ /**
85
+ * Hook props
86
+ */
87
+ searchArg,
88
+ setSearchArg,
89
+ ModalComponent,
90
+ renderItem,
91
+ getData,
92
+ handleConfirm,
93
+ /**
94
+ * Component props
95
+ */
96
+ keyExtractor,
97
+ labelExtractor,
98
+ focused,
99
+ type,
100
+ value,
101
+ onSelect,
102
+ onSearch,
103
+ close,
104
+ closeOnPick: _closeOnPick,
105
+ ...others
106
+ };
107
+ };
108
+
109
+ module.exports = useModal;
@@ -0,0 +1,147 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ require('react-native');
5
+ var reactCore = require('@tecsinapse/react-core');
6
+ require('react-native-safe-area-context');
7
+ require('../../../atoms/Modal/ui/styled.js');
8
+ var useLazyModalManager = require('../../../atoms/Modal/useLazyModalManager.js');
9
+ var functions = require('../functions.js');
10
+
11
+ const useSelect = ({
12
+ value,
13
+ options,
14
+ keyExtractor,
15
+ type,
16
+ labelExtractor,
17
+ placeholder,
18
+ onFocus,
19
+ onBlur,
20
+ disabled,
21
+ onSearch,
22
+ label,
23
+ ...rest
24
+ }) => {
25
+ const { focused, handleBlur, handleFocus } = reactCore.useInputFocus(
26
+ onFocus,
27
+ onBlur,
28
+ !disabled
29
+ );
30
+ const [selectOptions, setSelectOptions] = React.useState([]);
31
+ const modal = useLazyModalManager.useLazyModalManager();
32
+ const [loading, setLoading] = React.useState(false);
33
+ const onlyLabel = label && !placeholder;
34
+ const hasValue = type === "single" ? !!value : (value || []).length > 0;
35
+ const _placeholder = onlyLabel ? label : placeholder;
36
+ const _label = hasValue ? label : void 0;
37
+ React.useEffect(() => {
38
+ if (typeof options !== "function") {
39
+ setSelectOptions(options);
40
+ }
41
+ }, [options]);
42
+ const handleLazyFocus = React.useCallback(async () => {
43
+ if (typeof options === "function" && !onSearch) {
44
+ setLoading(true);
45
+ try {
46
+ const result = await options();
47
+ if (result) {
48
+ const _value = value;
49
+ if (_value && !(result instanceof Map) && !functions.findValue(result, _value, keyExtractor)) {
50
+ setSelectOptions([_value, ...result]);
51
+ } else setSelectOptions(result);
52
+ }
53
+ } catch (e) {
54
+ } finally {
55
+ setLoading(false);
56
+ }
57
+ }
58
+ }, [options, value, setSelectOptions]);
59
+ const handleOnSearch = React.useCallback(
60
+ async (searchInput) => {
61
+ if (searchInput !== void 0 && onSearch) {
62
+ setLoading(true);
63
+ modal.requestUpdate();
64
+ try {
65
+ const result = await onSearch(searchInput);
66
+ if (result) {
67
+ if (type === "single") {
68
+ const _value = value;
69
+ if (_value && !(result instanceof Map) && !functions.findValue(result, _value, keyExtractor)) {
70
+ setSelectOptions([_value, ...result]);
71
+ } else setSelectOptions(result);
72
+ } else {
73
+ const _value = value;
74
+ if (_value?.length && !(result instanceof Map)) {
75
+ const selected = _value.filter((it) => !functions.findValue(result, it, keyExtractor)) ?? [];
76
+ setSelectOptions([...selected, ...result]);
77
+ } else {
78
+ setSelectOptions(result);
79
+ }
80
+ }
81
+ }
82
+ } catch (e) {
83
+ } finally {
84
+ modal.requestUpdate();
85
+ setLoading(false);
86
+ }
87
+ }
88
+ },
89
+ [options, value, keyExtractor]
90
+ );
91
+ const getDisplayValue = React.useCallback(() => {
92
+ if (Array.isArray(value)) {
93
+ return functions.getMultiLabel(
94
+ value,
95
+ String(_placeholder),
96
+ selectOptions,
97
+ keyExtractor,
98
+ labelExtractor
99
+ );
100
+ } else {
101
+ return functions.getSingleLabel(
102
+ value,
103
+ String(_placeholder),
104
+ selectOptions,
105
+ keyExtractor,
106
+ labelExtractor
107
+ );
108
+ }
109
+ }, [_placeholder, value, selectOptions]);
110
+ const handlePressInput = async () => {
111
+ modal.show();
112
+ handleFocus();
113
+ await handleLazyFocus();
114
+ };
115
+ return {
116
+ /**
117
+ * Hook props
118
+ */
119
+ focused,
120
+ handleBlur,
121
+ handlePressInput,
122
+ getDisplayValue,
123
+ handleOnSearch,
124
+ _label,
125
+ loading,
126
+ modal,
127
+ selectOptions,
128
+ setSelectOptions,
129
+ /**
130
+ * Component props
131
+ */
132
+ value,
133
+ options,
134
+ keyExtractor,
135
+ type,
136
+ labelExtractor,
137
+ placeholder,
138
+ onFocus,
139
+ onBlur,
140
+ disabled,
141
+ onSearch,
142
+ label,
143
+ ...rest
144
+ };
145
+ };
146
+
147
+ module.exports = useSelect;
@@ -33,8 +33,6 @@ const SearchBarContainer = styled(reactNative.View)`
33
33
  position: relative;
34
34
  `;
35
35
  const ListItem = styled(reactCore.PressableSurface)`
36
- border-bottom-width: ${reactCore.RFValueStr("1px")};
37
- border-color: ${({ theme }) => theme.color.secondary.light};
38
36
  padding-top: ${({ theme }) => theme.spacing.mili};
39
37
  padding-bottom: ${({ theme }) => theme.spacing.mili};
40
38
  padding-left: ${({ theme }) => theme.spacing.deca};
@@ -60,11 +58,23 @@ const TextTitleModal = styled(Text)`
60
58
  const StyledTextItemSelect = styled(Text)`
61
59
  width: 90%;
62
60
  `;
61
+ const Divider = styled(reactNative.View)`
62
+ height: ${reactCore.RFValueStr("1px")};
63
+ display: flex;
64
+ flex: 1 1 auto;
65
+ background-color: ${({ theme }) => theme.color.secondary.light};
66
+ `;
67
+ const SectionHeader = styled(reactNative.View)`
68
+ background-color: #fff;
69
+ padding: ${({ theme }) => theme.spacing.deca};
70
+ `;
63
71
 
72
+ exports.Divider = Divider;
64
73
  exports.FetchIndicator = FetchIndicator;
65
74
  exports.ListItem = ListItem;
66
75
  exports.ModalFooter = ModalFooter;
67
76
  exports.SearchBarContainer = SearchBarContainer;
77
+ exports.SectionHeader = SectionHeader;
68
78
  exports.SelectIcon = SelectIcon;
69
79
  exports.StyledSelectionText = StyledSelectionText;
70
80
  exports.StyledTextItemSelect = StyledTextItemSelect;
@@ -14,6 +14,7 @@ const ModalGroupManager = ({ children, ...others }) => {
14
14
  statusBarTranslucent: true,
15
15
  animationType: "none",
16
16
  visible: hasModals,
17
+ onRequestClose: modalLifecycle.closeLastOpenedModal,
17
18
  ...others
18
19
  },
19
20
  _render
@@ -119,6 +119,11 @@ class ModalLifecycleHandler {
119
119
  savedNode && this.nodeGroup.set(id, { ...savedNode, visible: false });
120
120
  this.update();
121
121
  };
122
+ closeLastOpenedModal = () => {
123
+ const [modals] = this.state || [];
124
+ const lastModal = modals?.pop();
125
+ lastModal?.props?.close?.();
126
+ };
122
127
  }
123
128
  const createModalLifecycleHandler = () => {
124
129
  return new ModalLifecycleHandler();
@@ -27,8 +27,7 @@ const ModalView = ({
27
27
  const opacityCarrier = useRef(new Animated.Value(0)).current;
28
28
  const offset = isLastShown && keyboardOpened > 0 ? 0 : bottom;
29
29
  const getKeyboardHeight = (keyboard) => {
30
- if (keyboard === 0)
31
- return 0;
30
+ if (keyboard === 0) return 0;
32
31
  const wHeight = Math.ceil(Dimensions.get("window").height);
33
32
  const sHeight = Math.ceil(Dimensions.get("screen").height);
34
33
  if (wHeight !== sHeight) {
@@ -99,14 +98,12 @@ const ModalView = ({
99
98
  [show, ready, visible, setReady]
100
99
  );
101
100
  useEffect(() => {
102
- if (visible && ready)
103
- requestAnimationFrame(() => show());
101
+ if (visible && ready) requestAnimationFrame(() => show());
104
102
  if (!visible && !ready) {
105
103
  Keyboard.dismiss();
106
104
  requestAnimationFrame(() => hide(boxHeight));
107
105
  }
108
- if (!visible && ready)
109
- setReady(false);
106
+ if (!visible && ready) setReady(false);
110
107
  }, [ready, visible]);
111
108
  useEffect(() => {
112
109
  const showEvent = Keyboard.addListener(
@@ -1,139 +1,47 @@
1
- import { useInputFocus, HintInputContainer } from '@tecsinapse/react-core';
2
- import * as React from 'react';
3
- import { useState, useEffect } from 'react';
4
- import 'react-native';
5
- import 'react-native-safe-area-context';
6
- import '../../atoms/Modal/ui/styled.js';
7
- import { useLazyModalManager } from '../../atoms/Modal/useLazyModalManager.js';
1
+ import { HintInputContainer } from '@tecsinapse/react-core';
2
+ import React__default from 'react';
8
3
  import Text from '../../atoms/Text/Text.js';
9
- import { Modal } from './Modal.js';
4
+ import { Modal } from './components/Modal.js';
10
5
  import { SelectIcon, StyledSelectionText } from './styled.js';
6
+ import useSelect from './hooks/useSelect.js';
11
7
 
12
- function Select({
13
- /** Select props */
14
- value,
15
- options,
16
- keyExtractor,
17
- groupKeyExtractor,
18
- onSelect,
19
- type,
20
- labelExtractor,
21
- placeholder,
22
- onFocus,
23
- onBlur,
24
- disabled,
25
- onSearch,
26
- selectModalTitle,
27
- selectModalTitleComponent,
28
- searchBarPlaceholder,
29
- hideSearchBar,
30
- confirmButtonText,
31
- rightComponent,
32
- variant = "default",
33
- hintComponent,
34
- hint,
35
- style,
36
- controlComponent,
37
- closeOnPick = type === "single",
38
- label,
39
- numberOfLines,
40
- ...rest
41
- }) {
42
- const { focused, handleBlur, handleFocus } = useInputFocus(
43
- onFocus,
44
- onBlur,
45
- !disabled
46
- );
47
- const [selectOptions, setSelectOptions] = useState([]);
48
- const modal = useLazyModalManager();
49
- const [loading, setLoading] = useState(false);
50
- const onlyLabel = label && !placeholder;
51
- const hasValue = type === "single" ? !!value : (value || []).length > 0;
52
- const _placeholder = onlyLabel ? label : placeholder;
53
- const _label = hasValue ? label : void 0;
54
- useEffect(() => {
55
- if (typeof options !== "function") {
56
- setSelectOptions(options);
57
- }
58
- }, [options]);
59
- const handleLazyFocus = React.useCallback(async () => {
60
- if (typeof options === "function" && !onSearch) {
61
- setLoading(true);
62
- try {
63
- const result = await options();
64
- if (result) {
65
- if (value && !result.find((v) => keyExtractor(value) === keyExtractor(v))) {
66
- setSelectOptions([value, ...result]);
67
- } else
68
- setSelectOptions(result);
69
- }
70
- } catch (e) {
71
- } finally {
72
- setLoading(false);
73
- }
74
- }
75
- }, [options, value, setSelectOptions]);
76
- const handleOnSearch = React.useCallback(
77
- async (searchInput) => {
78
- if (searchInput !== void 0 && onSearch) {
79
- setLoading(true);
80
- modal.requestUpdate();
81
- try {
82
- const result = await onSearch(searchInput);
83
- if (result) {
84
- if (type === "single") {
85
- if (value && !result.find(
86
- (v) => keyExtractor(value) === keyExtractor(v)
87
- )) {
88
- setSelectOptions([value, ...result]);
89
- } else
90
- setSelectOptions(result);
91
- } else {
92
- if (value?.length) {
93
- const selectedValues = value.filter(
94
- (v) => !result.find(
95
- (current) => keyExtractor(v) === keyExtractor(current)
96
- )
97
- ) || [];
98
- setSelectOptions([...selectedValues, ...result]);
99
- } else {
100
- setSelectOptions(result);
101
- }
102
- }
103
- }
104
- } catch (e) {
105
- } finally {
106
- modal.requestUpdate();
107
- setLoading(false);
108
- }
109
- }
110
- },
111
- [options, value, keyExtractor]
112
- );
113
- const getDisplayValue = React.useCallback(() => {
114
- if (Array.isArray(value)) {
115
- if (value.length === 0)
116
- return _placeholder;
117
- else {
118
- const options2 = selectOptions.length > 0 ? selectOptions : value;
119
- return options2?.reduce(
120
- (acc, option, index) => value.find(
121
- (key) => keyExtractor(option, index) == keyExtractor(key, index)
122
- ) ? acc + labelExtractor(option) + ", " : acc,
123
- ""
124
- ).slice(0, -2);
125
- }
126
- } else {
127
- if (!value)
128
- return _placeholder;
129
- const selectedOption = selectOptions?.find(
130
- (option, index) => keyExtractor(option, index) == keyExtractor(value, index)
131
- );
132
- return labelExtractor(selectedOption ?? value);
133
- }
134
- }, [_placeholder, value, selectOptions]);
8
+ function Select(props) {
9
+ const {
10
+ groupKeyExtractor,
11
+ onSelect,
12
+ selectModalTitle,
13
+ selectModalTitleComponent,
14
+ searchBarPlaceholder,
15
+ hideSearchBar,
16
+ confirmButtonText,
17
+ rightComponent,
18
+ variant = "default",
19
+ hintComponent,
20
+ hint,
21
+ style,
22
+ controlComponent,
23
+ type,
24
+ numberOfLines,
25
+ closeOnPick = type === "single",
26
+ modal,
27
+ selectOptions,
28
+ keyExtractor,
29
+ labelExtractor,
30
+ value,
31
+ handleOnSearch,
32
+ loading,
33
+ options,
34
+ setSelectOptions,
35
+ handleBlur,
36
+ handlePressInput,
37
+ getDisplayValue,
38
+ focused,
39
+ disabled,
40
+ _label,
41
+ ...rest
42
+ } = useSelect(props);
135
43
  modal.sync(
136
- /* @__PURE__ */ React.createElement(
44
+ /* @__PURE__ */ React__default.createElement(
137
45
  Modal,
138
46
  {
139
47
  options: selectOptions || [],
@@ -161,14 +69,10 @@ function Select({
161
69
  }
162
70
  )
163
71
  );
164
- const handlePressInput = async () => {
165
- modal.show();
166
- handleFocus();
167
- await handleLazyFocus();
168
- };
169
- return /* @__PURE__ */ React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React.createElement(
72
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React__default.createElement(
170
73
  HintInputContainer,
171
74
  {
75
+ ...rest,
172
76
  viewStyle: style,
173
77
  onPress: handlePressInput,
174
78
  focused,
@@ -178,10 +82,9 @@ function Select({
178
82
  hint,
179
83
  hintComponent,
180
84
  label: _label,
181
- rightComponent: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SelectIcon, { name: "chevron-down", type: "ionicon", size: "centi" }), rightComponent),
182
- ...rest
85
+ rightComponent: /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(SelectIcon, { name: "chevron-down", type: "ionicon", size: "centi" }), rightComponent)
183
86
  },
184
- /* @__PURE__ */ React.createElement(
87
+ /* @__PURE__ */ React__default.createElement(
185
88
  StyledSelectionText,
186
89
  {
187
90
  numberOfLines,
@@ -0,0 +1,22 @@
1
+ import React__default from 'react';
2
+ import { Divider } from '../styled.js';
3
+ import { FlatList } from 'react-native';
4
+
5
+ const Flat = ({ options, keyExtractor, renderItem, getData }) => {
6
+ const data = React__default.useMemo(
7
+ () => typeof options !== "function" ? getData(options) : [],
8
+ [options, getData]
9
+ );
10
+ return /* @__PURE__ */ React__default.createElement(
11
+ FlatList,
12
+ {
13
+ data,
14
+ keyExtractor,
15
+ fadingEdgeLength: 200,
16
+ ItemSeparatorComponent: Divider,
17
+ renderItem
18
+ }
19
+ );
20
+ };
21
+
22
+ export { Flat as default };
@@ -0,0 +1,94 @@
1
+ import React__default from 'react';
2
+ import { Button } from '../../../atoms/Button/Button.js';
3
+ import { RFValue } from '@tecsinapse/react-core';
4
+ import Text from '../../../atoms/Text/Text.js';
5
+ import Header from '../../../atoms/Header/Header.js';
6
+ import Input from '../../../atoms/Input/Input.js';
7
+ import 'react-native';
8
+ import { ModalView } from '../../../atoms/Modal/ui/BaseModalView.js';
9
+ import { SearchBarContainer, SelectIcon, FetchIndicator, ModalFooter, TextTitleModal } from '../styled.js';
10
+ import Section from './Section.js';
11
+ import Flat from './Flat.js';
12
+ import useModal from '../hooks/useModal.js';
13
+
14
+ const ModalTitle = ({ title }) => title ? /* @__PURE__ */ React__default.createElement(
15
+ TextTitleModal,
16
+ {
17
+ typography: "h4",
18
+ fontWeight: "bold",
19
+ numberOfLines: 3,
20
+ style: { maxWidth: RFValue(250) }
21
+ },
22
+ title
23
+ ) : null;
24
+ const Component = (props) => {
25
+ const {
26
+ ModalComponent,
27
+ selectModalTitleComponent,
28
+ selectModalTitle,
29
+ hideSearchBar,
30
+ searchBarPlaceholder,
31
+ searchArg,
32
+ setSearchArg,
33
+ loading,
34
+ options,
35
+ getData,
36
+ renderItem,
37
+ keyExtractor,
38
+ closeOnPick,
39
+ confirmButtonText,
40
+ handleConfirm,
41
+ close,
42
+ ...others
43
+ } = useModal(props);
44
+ return /* @__PURE__ */ React__default.createElement(ModalView, { ...others, BoxComponent: ModalComponent, showCloseBar: false }, /* @__PURE__ */ React__default.createElement(
45
+ Header,
46
+ {
47
+ rightButton: {
48
+ onPress: close,
49
+ icon: {
50
+ name: "close",
51
+ type: "material-community",
52
+ fontColor: "light"
53
+ }
54
+ }
55
+ },
56
+ selectModalTitleComponent ? selectModalTitleComponent : /* @__PURE__ */ React__default.createElement(ModalTitle, { title: selectModalTitle })
57
+ ), !hideSearchBar ? /* @__PURE__ */ React__default.createElement(SearchBarContainer, null, /* @__PURE__ */ React__default.createElement(
58
+ Input,
59
+ {
60
+ placeholder: searchBarPlaceholder,
61
+ value: searchArg,
62
+ onChange: setSearchArg,
63
+ leftComponent: /* @__PURE__ */ React__default.createElement(SelectIcon, { name: "search", type: "ionicon", size: "centi" })
64
+ }
65
+ )) : null, loading ? /* @__PURE__ */ React__default.createElement(FetchIndicator, { animating: true, color: "grey", size: "large" }) : null, options instanceof Map ? /* @__PURE__ */ React__default.createElement(
66
+ Section,
67
+ {
68
+ options,
69
+ getData,
70
+ renderItem,
71
+ keyExtractor
72
+ }
73
+ ) : /* @__PURE__ */ React__default.createElement(
74
+ Flat,
75
+ {
76
+ renderItem,
77
+ getData,
78
+ options,
79
+ keyExtractor
80
+ }
81
+ ), !closeOnPick ? /* @__PURE__ */ React__default.createElement(ModalFooter, null, /* @__PURE__ */ React__default.createElement(
82
+ Button,
83
+ {
84
+ variant: "filled",
85
+ color: "primary",
86
+ onPress: handleConfirm,
87
+ disabled: loading
88
+ },
89
+ /* @__PURE__ */ React__default.createElement(Text, { fontColor: "light", fontWeight: "bold" }, confirmButtonText)
90
+ )) : null);
91
+ };
92
+ const Modal = Component;
93
+
94
+ export { Modal };