@tecsinapse/react-native-kit 1.12.11 → 1.12.15

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 (70) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/components/atoms/Modal/ModalLifecycleHandler.js +24 -22
  3. package/dist/components/atoms/Modal/ModalLifecycleHandler.js.map +1 -1
  4. package/dist/components/atoms/Modal/index.d.ts +1 -0
  5. package/dist/components/atoms/Modal/index.js +13 -0
  6. package/dist/components/atoms/Modal/index.js.map +1 -1
  7. package/dist/components/atoms/Modal/ui/BaseModalView.js +20 -8
  8. package/dist/components/atoms/Modal/ui/BaseModalView.js.map +1 -1
  9. package/dist/components/atoms/Modal/ui/types.d.ts +1 -0
  10. package/dist/components/atoms/Modal/useLazyModalManager.d.ts +8 -0
  11. package/dist/components/atoms/Modal/useLazyModalManager.js +40 -0
  12. package/dist/components/atoms/Modal/useLazyModalManager.js.map +1 -0
  13. package/dist/components/atoms/Text/styled.js +3 -1
  14. package/dist/components/atoms/Text/styled.js.map +1 -1
  15. package/dist/components/molecules/Calendar/Calendar.d.ts +1 -4
  16. package/dist/components/molecules/Calendar/Calendar.js +2 -2
  17. package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
  18. package/dist/components/molecules/DatePicker/DatePicker.d.ts +3 -4
  19. package/dist/components/molecules/DatePicker/DatePicker.js +29 -3
  20. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  21. package/dist/components/molecules/DatePicker/index.d.ts +1 -1
  22. package/dist/components/molecules/DatePicker/index.js +6 -0
  23. package/dist/components/molecules/DatePicker/index.js.map +1 -1
  24. package/dist/components/molecules/DatePicker/styled.d.ts +4 -0
  25. package/dist/components/molecules/DatePicker/styled.js +20 -0
  26. package/dist/components/molecules/DatePicker/styled.js.map +1 -0
  27. package/dist/components/molecules/DateTimePicker/DateTimePicker.d.ts +2 -1
  28. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +18 -4
  29. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  30. package/dist/components/molecules/DateTimePicker/index.d.ts +1 -1
  31. package/dist/components/molecules/DateTimePicker/index.js +6 -0
  32. package/dist/components/molecules/DateTimePicker/index.js.map +1 -1
  33. package/dist/components/molecules/Select/Modal.d.ts +7 -0
  34. package/dist/components/{atoms → molecules}/Select/Modal.js +31 -18
  35. package/dist/components/molecules/Select/Modal.js.map +1 -0
  36. package/dist/components/{atoms → molecules}/Select/Select.d.ts +2 -1
  37. package/dist/components/{atoms → molecules}/Select/Select.js +35 -36
  38. package/dist/components/molecules/Select/Select.js.map +1 -0
  39. package/dist/components/{atoms → molecules}/Select/index.d.ts +0 -0
  40. package/dist/components/{atoms → molecules}/Select/index.js +0 -0
  41. package/dist/components/molecules/Select/index.js.map +1 -0
  42. package/dist/components/{atoms → molecules}/Select/styled.d.ts +1 -1
  43. package/dist/components/{atoms → molecules}/Select/styled.js +14 -12
  44. package/dist/components/molecules/Select/styled.js.map +1 -0
  45. package/dist/index.d.ts +4 -4
  46. package/dist/index.js +22 -1
  47. package/dist/index.js.map +1 -1
  48. package/package.json +3 -3
  49. package/src/components/atoms/Modal/ModalLifecycleHandler.ts +22 -20
  50. package/src/components/atoms/Modal/index.ts +2 -1
  51. package/src/components/atoms/Modal/ui/BaseModalView.tsx +29 -15
  52. package/src/components/atoms/Modal/ui/types.ts +1 -0
  53. package/src/components/atoms/Modal/useLazyModalManager.ts +43 -0
  54. package/src/components/atoms/Text/styled.ts +2 -1
  55. package/src/components/molecules/Calendar/Calendar.tsx +3 -7
  56. package/src/components/molecules/DatePicker/DatePicker.tsx +33 -10
  57. package/src/components/molecules/DatePicker/index.ts +1 -1
  58. package/src/components/molecules/DatePicker/styled.ts +6 -0
  59. package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +24 -7
  60. package/src/components/molecules/DateTimePicker/index.ts +1 -1
  61. package/src/components/{atoms → molecules}/Select/Modal.tsx +32 -33
  62. package/src/components/{atoms → molecules}/Select/Select.tsx +38 -39
  63. package/src/components/{atoms → molecules}/Select/index.ts +0 -0
  64. package/src/components/{atoms → molecules}/Select/styled.ts +10 -8
  65. package/src/index.ts +4 -4
  66. package/dist/components/atoms/Select/Modal.d.ts +0 -7
  67. package/dist/components/atoms/Select/Modal.js.map +0 -1
  68. package/dist/components/atoms/Select/Select.js.map +0 -1
  69. package/dist/components/atoms/Select/index.js.map +0 -1
  70. package/dist/components/atoms/Select/styled.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/DateTimePicker.tsx"],"names":["DateTimePicker","locale","rest","Text","DateTimeSelector"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;AACA;;;;;;AAEO,MAAMA,cAAuC,GAAG,CAAC;AACtDC,EAAAA,MADsD;AAEtD,KAAGC;AAFmD,CAAD,KAGjD;AACJ,SACE,6BAAC,yBAAD,eACMA,IADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,yBAAyB,EAAEC,kCAH7B;AAIE,IAAA,aAAa,EAAC,OAJhB;AAKE,IAAA,MAAM,EAAEH,MAAM,IAAI;AALpB,KADF;AASD,CAbM","sourcesContent":["import {\n DateTimePicker as DateTimePickerCore,\n DateTimePickerProps,\n} from '@tecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { Text } from '../../atoms/Text';\nimport { DateTimeSelector } from '../DateTimeSelector';\nimport { getLocale } from '../../../utils/date';\n\nexport const DateTimePicker: FC<DateTimePickerProps> = ({\n locale,\n ...rest\n}) => {\n return (\n <DateTimePickerCore\n {...rest}\n TextComponent={Text}\n DateTimeSelectorComponent={DateTimeSelector}\n animationType=\"slide\"\n locale={locale ?? getLocale()}\n />\n );\n};\n"],"file":"DateTimePicker.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/DateTimePicker.tsx"],"names":["DateTimePicker","locale","rest","modal","Text","DateTimeSelector","show","close","selector","blur","sync","NativeModal","children","others"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;AACA;;AACA;;;;;;AAIO,MAAMA,cAA6C,GAAG,CAAC;AAAEC,EAAAA,MAAF;AAAU,KAAGC;AAAb,CAAD,KAAyB;AAEpF,QAAMC,KAAK,GAAG,iCAAd;AAEA,SACE,6BAAC,yBAAD,eACMD,IADN;AAEE,IAAA,aAAa,EAAEE,UAFjB;AAGE,IAAA,yBAAyB,EAAEC,kCAH7B;AAIE,IAAA,MAAM,EAAEJ,MAAM,IAAI,sBAJpB;AAKE,IAAA,mBAAmB,EAAE,MAAME,KAAK,CAACG,IAAN,EAL7B;AAME,IAAA,oBAAoB,EAAE,MAAMH,KAAK,CAACI,KAAN,EAN9B;AAOE,IAAA,cAAc,EAAE,CAACC,QAAD,EAAWC,IAAX,KAAoBN,KAAK,CAACO,IAAN,CAClC,6BAAC,WAAD;AAAa,MAAA,OAAO,EAAED;AAAtB,OACGD,QADH,CADkC;AAPtC,KADF;AAeD,CAnBM;;;;AAqBP,MAAMG,WAA2B,GAAG,CAAC;AAAEC,EAAAA,QAAF;AAAY,KAAGC;AAAf,CAAD,KAA6B;AAC/D,SACE,6BAAC,gBAAD,EAAeA,MAAf,EACGD,QADH,CADF;AAKD,CAND","sourcesContent":["import {\n DateTimePicker as DateTimePickerCore,\n DateTimePickerProps\n} from '@tecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { getLocale } from '../../../utils/date';\nimport { IBaseModal, ModalView, useLazyModalManager } from '../../atoms/Modal';\nimport { Text } from '../../atoms/Text';\nimport { DateTimeSelector } from '../DateTimeSelector';\n\nexport type NativeDateTimePickerProps = Omit<DateTimePickerProps, 'DateTimeSelectorComponent' | 'renderSelector' | 'requestCloseSelector' | 'requestShowSelector'>\n\nexport const DateTimePicker: FC<NativeDateTimePickerProps> = ({ locale, ...rest }) => {\n\n const modal = useLazyModalManager()\n\n return (\n <DateTimePickerCore\n {...rest}\n TextComponent={Text}\n DateTimeSelectorComponent={DateTimeSelector}\n locale={locale ?? getLocale()}\n requestShowSelector={() => modal.show()}\n requestCloseSelector={() => modal.close()}\n renderSelector={(selector, blur) => modal.sync(\n <NativeModal onClose={blur}>\n {selector}\n </NativeModal>\n )}\n />\n );\n};\n\nconst NativeModal: FC<IBaseModal> = ({ children, ...others }) => {\n return (\n <ModalView {...others}>\n {children}\n </ModalView>\n )\n}"],"file":"DateTimePicker.js"}
@@ -1 +1 @@
1
- export { DateTimePicker } from './DateTimePicker';
1
+ export { DateTimePicker, NativeDateTimePickerProps } from './DateTimePicker';
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "DateTimePicker", {
9
9
  return _DateTimePicker.DateTimePicker;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "NativeDateTimePickerProps", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _DateTimePicker.NativeDateTimePickerProps;
16
+ }
17
+ });
12
18
 
13
19
  var _DateTimePicker = require("./DateTimePicker");
14
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { DateTimePicker } from './DateTimePicker';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export { DateTimePicker, NativeDateTimePickerProps } from './DateTimePicker';\n"],"file":"index.js"}
@@ -0,0 +1,7 @@
1
+ import { IBaseModal } from '../../atoms/Modal';
2
+ import { SelectNativeProps } from './Select';
3
+ interface LoadingProps {
4
+ loading?: boolean;
5
+ }
6
+ export declare const Modal: <Data, Type extends "single" | "multi">({ options, keyExtractor, labelExtractor, groupKeyExtractor, hideSearchBar, searchBarPlaceholder, focused, type, value, onSelect, onSearch, selectModalTitle, selectModalTitleComponent, confirmButtonText, loading, close, closeOnPick, ...others }: SelectNativeProps<Data, Type> & LoadingProps & IBaseModal) => JSX.Element;
7
+ export {};
@@ -5,19 +5,23 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Modal = void 0;
7
7
 
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _reactCore = require("@tecsinapse/react-core");
9
9
 
10
- var _styled = require("./styled");
10
+ var React = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _reactNative = require("react-native");
13
13
 
14
- var _Text = require("../Text");
14
+ var _Button = require("../../atoms/Button");
15
15
 
16
- var _reactCore = require("@tecsinapse/react-core");
16
+ var _Header = require("../../atoms/Header");
17
+
18
+ var _Input = require("../../atoms/Input");
17
19
 
18
- var _Input = require("../Input");
20
+ var _Modal = require("../../atoms/Modal");
19
21
 
20
- var _Header = require("../Header");
22
+ var _Text = require("../../atoms/Text");
23
+
24
+ var _styled = require("./styled");
21
25
 
22
26
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
27
 
@@ -37,15 +41,20 @@ const Component = ({
37
41
  value,
38
42
  onSelect,
39
43
  onSearch,
40
- onRequestClose,
41
44
  selectModalTitle,
42
45
  selectModalTitleComponent,
43
46
  confirmButtonText,
44
47
  loading,
45
- ...modalProps
48
+ close,
49
+ closeOnPick,
50
+ ...others
46
51
  }) => {
47
52
  const [selectedValues, setSelectedValues] = React.useState([]);
48
53
  const [searchArg, setSearchArg] = (0, _reactCore.useDebouncedState)('', onSearch);
54
+ const ModalComponent = React.useMemo(() => (0, _styled.getStyledModal)((0, _reactCore.getStatusBarHeight)(true)), []);
55
+
56
+ const _closeOnPick = closeOnPick && type === 'single';
57
+
49
58
  React.useEffect(() => {
50
59
  setSelectedValues(value ? type === 'multi' ? value : [value] : []);
51
60
  }, [value, focused, setSelectedValues]);
@@ -76,23 +85,27 @@ const Component = ({
76
85
  });
77
86
  };
78
87
 
88
+ React.useEffect(() => {
89
+ if (_closeOnPick && selectedValues[0] && selectedValues[0] !== value) {
90
+ handleConfirm();
91
+ }
92
+ }, [selectedValues[0], value, closeOnPick]);
93
+
79
94
  const handleConfirm = () => {
80
95
  onSelect(type === 'single' ? selectedValues[0] : selectedValues);
81
- onRequestClose && onRequestClose();
96
+ close === null || close === void 0 ? void 0 : close();
82
97
  };
83
98
 
84
99
  const headerContent = selectModalTitleComponent ? selectModalTitleComponent : selectModalTitle ? React.createElement(_Text.Text, {
85
100
  typography: "h4",
86
101
  fontWeight: "bold"
87
102
  }, selectModalTitle) : null;
88
- return React.createElement(_reactNative.Modal, _extends({
89
- transparent: true,
90
- hardwareAccelerated: true
91
- }, modalProps, {
92
- onRequestClose: onRequestClose
93
- }), React.createElement(_styled.StyledModal, null, React.createElement(_Header.Header, {
103
+ return React.createElement(_Modal.ModalView, _extends({}, others, {
104
+ BoxComponent: ModalComponent,
105
+ showCloseBar: false
106
+ }), React.createElement(_Header.Header, {
94
107
  rightButton: {
95
- onPress: onRequestClose,
108
+ onPress: close,
96
109
  icon: {
97
110
  name: 'close',
98
111
  type: 'material-community',
@@ -135,7 +148,7 @@ const Component = ({
135
148
  }, React.createElement(_Text.Text, {
136
149
  fontWeight: item._checked ? 'bold' : 'regular'
137
150
  }, labelExtractor(item)))))
138
- }), React.createElement(_styled.ModalFooter, null, React.createElement(_reactCore.Button, {
151
+ }), !_closeOnPick && React.createElement(_styled.ModalFooter, null, React.createElement(_Button.Button, {
139
152
  variant: 'filled',
140
153
  color: 'primary',
141
154
  onPress: handleConfirm,
@@ -143,7 +156,7 @@ const Component = ({
143
156
  }, React.createElement(_Text.Text, {
144
157
  fontColor: 'light',
145
158
  fontWeight: "bold"
146
- }, confirmButtonText)))));
159
+ }, confirmButtonText))));
147
160
  };
148
161
 
149
162
  const Modal = Component;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/molecules/Select/Modal.tsx"],"names":["Component","options","keyExtractor","labelExtractor","groupKeyExtractor","hideSearchBar","searchBarPlaceholder","focused","type","value","onSelect","onSearch","selectModalTitle","selectModalTitleComponent","confirmButtonText","loading","close","closeOnPick","others","selectedValues","setSelectedValues","React","useState","searchArg","setSearchArg","ModalComponent","useMemo","_closeOnPick","useEffect","getData","map","option","index","_checked","find","data","handlePressItem","newArr","found","push","handleConfirm","headerContent","onPress","icon","name","fontColor","text","item","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;AASA,MAAMA,SAAS,GAAG,CAAwC;AACxDC,EAAAA,OADwD;AAExDC,EAAAA,YAFwD;AAGxDC,EAAAA,cAHwD;AAIxDC,EAAAA,iBAJwD;AAKxDC,EAAAA,aALwD;AAMxDC,EAAAA,oBANwD;AAOxDC,EAAAA,OAPwD;AAQxDC,EAAAA,IARwD;AASxDC,EAAAA,KATwD;AAUxDC,EAAAA,QAVwD;AAWxDC,EAAAA,QAXwD;AAYxDC,EAAAA,gBAZwD;AAaxDC,EAAAA,yBAbwD;AAcxDC,EAAAA,iBAdwD;AAexDC,EAAAA,OAfwD;AAgBxDC,EAAAA,KAhBwD;AAiBxDC,EAAAA,WAjBwD;AAkBxD,KAAGC;AAlBqD,CAAxC,KAmB4D;AAC5E,QAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCC,KAAK,CAACC,QAAN,CAAuB,EAAvB,CAA5C;AACA,QAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,kCAA0B,EAA1B,EAA8Bb,QAA9B,CAAlC;AACA,QAAMc,cAAc,GAAGJ,KAAK,CAACK,OAAN,CAAc,MAAM,4BAAe,mCAAmB,IAAnB,CAAf,CAApB,EAA8D,EAA9D,CAAvB;;AACA,QAAMC,YAAY,GAAGV,WAAW,IAAIT,IAAI,KAAK,QAA7C;;AAIAa,EAAAA,KAAK,CAACO,SAAN,CAAgB,MAAM;AACpBR,IAAAA,iBAAiB,CACdX,KAAK,GA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C,OACG9B,cAAc,CAAC4C,IAAD,CADjB,CALF,CAZJ,CADF;AALJ,IA/BJ,EAgEM,CAACpB,YAAD,IAAiB,oBAAC,mBAAD,QACjB,oBAAC,cAAD;AACE,IAAA,OAAO,EAAE,QADX;AAEE,IAAA,KAAK,EAAE,SAFT;AAGE,IAAA,OAAO,EAAEa,aAHX;AAIE,IAAA,QAAQ,EAAEzB;AAJZ,KAME,oBAAC,UAAD;AAAM,IAAA,SAAS,EAAE,OAAjB;AAA0B,IAAA,UAAU,EAAC;AAArC,KACGD,iBADH,CANF,CADiB,CAhEvB,CADF;AA+ED,CAzKD;;AA2KO,MAAMkC,KAAK,GAAGhD,SAAd","sourcesContent":["import { Checkbox, getStatusBarHeight, RadioButton, useDebouncedState } from '@tecsinapse/react-core';\nimport * as React from 'react';\nimport { FlatList, StatusBar, View } from 'react-native';\nimport { Button } from '../../atoms/Button';\nimport { Header } from '../../atoms/Header';\nimport { Input } from '../../atoms/Input';\nimport { IBaseModal, ModalView } from '../../atoms/Modal';\nimport { Text } from '../../atoms/Text';\nimport { SelectNativeProps } from './Select';\nimport {\n FetchIndicator, getStyledModal, ListItem, ModalFooter, SearchBarContainer,\n SelectIcon\n} from './styled';\n\ninterface LoadingProps {\n loading?: boolean;\n}\n\nconst Component = <Data, Type extends 'single' | 'multi'>({\n options,\n keyExtractor,\n labelExtractor,\n groupKeyExtractor,\n hideSearchBar,\n searchBarPlaceholder,\n focused,\n type,\n value,\n onSelect,\n onSearch,\n selectModalTitle,\n selectModalTitleComponent,\n confirmButtonText,\n loading,\n close,\n closeOnPick,\n ...others\n}: SelectNativeProps<Data, Type> & LoadingProps & IBaseModal): JSX.Element => {\n const [selectedValues, setSelectedValues] = React.useState<Data[]>([]);\n const [searchArg, setSearchArg] = useDebouncedState<string>('', onSearch);\n const ModalComponent = React.useMemo(() => getStyledModal(getStatusBarHeight(true)), [])\n const _closeOnPick = closeOnPick && type === 'single'\n\n // Resets the temporary state to the initial state whenever the\n // modal is reopened or the value changes\n React.useEffect(() => {\n setSelectedValues(\n (value ? (type === 'multi' ? value : [value]) : []) as Data[]\n );\n }, [value, focused, setSelectedValues]);\n\n const getData = (options: Data[]) => {\n return options?.map((option, index) => ({\n ...option,\n _checked:\n type === 'multi'\n ? !!selectedValues.find(\n value => keyExtractor(option, index) == keyExtractor(value, index)\n )\n : keyExtractor((selectedValues[0] || {}) as Data, index) ==\n keyExtractor(option, index),\n }));\n };\n\n const data = typeof options !== 'function' ? getData(options) : [];\n\n const handlePressItem = (option: Data) => () => {\n setSelectedValues(selectedValues => {\n if (type === 'multi') {\n const newArr: Data[] = [];\n let found = false;\n for (const value of selectedValues) {\n if (keyExtractor(value) != keyExtractor(option)) newArr.push(value);\n else found = true;\n }\n if (!found) newArr.push(option);\n return newArr;\n }\n return keyExtractor((selectedValues[0] || {}) as Data) ===\n keyExtractor(option)\n ? []\n : [option];\n });\n };\n\n React.useEffect(() => {\n if (_closeOnPick && selectedValues[0] && (selectedValues[0] !== value)) {\n handleConfirm()\n }\n }, [selectedValues[0], value, closeOnPick])\n\n const handleConfirm = () => {\n // TS Workaround since TS won't infer the ternary operator's result type correctly\n type OnSelectArg = Parameters<typeof onSelect>[0];\n onSelect(\n (type === 'single' ? selectedValues[0] : selectedValues) as OnSelectArg\n );\n close?.()\n };\n\n const headerContent = selectModalTitleComponent ? (\n selectModalTitleComponent\n ) : selectModalTitle ? (\n <Text typography=\"h4\" fontWeight=\"bold\">\n {selectModalTitle}\n </Text>\n ) : null;\n\n return (\n <ModalView {...others} BoxComponent={ModalComponent} showCloseBar={false}>\n <Header\n rightButton={{\n onPress: close,\n icon: {\n name: 'close',\n type: 'material-community',\n fontColor: 'light',\n },\n }}\n >\n {headerContent}\n </Header>\n\n {!hideSearchBar && (\n <SearchBarContainer>\n <Input\n placeholder={searchBarPlaceholder}\n value={searchArg}\n onChange={text => setSearchArg(text)}\n leftComponent={\n <SelectIcon name=\"search\" type=\"ionicon\" size=\"centi\" />\n }\n />\n </SearchBarContainer>\n )}\n\n {loading && (\n <FetchIndicator animating={true} color={'grey'} size={'large'} />\n )}\n\n <FlatList\n data={data}\n keyExtractor={keyExtractor}\n fadingEdgeLength={200}\n renderItem={({ item }) => (\n <ListItem onPress={handlePressItem(item)}>\n <View pointerEvents={'none'}>\n {type === 'multi' ? (\n <Checkbox\n color={'primary'}\n labelPosition={'right'}\n checked={item._checked}\n >\n <Text fontWeight={item._checked ? 'bold' : 'regular'}>\n {labelExtractor(item)}\n </Text>\n </Checkbox>\n ) : (\n <RadioButton\n color={'primary'}\n labelPosition={'right'}\n checked={item._checked}\n >\n <Text fontWeight={item._checked ? 'bold' : 'regular'}>\n {labelExtractor(item)}\n </Text>\n </RadioButton>\n )}\n </View>\n </ListItem>\n )}\n />\n \n { !_closeOnPick && <ModalFooter>\n <Button\n variant={'filled'}\n color={'primary'}\n onPress={handleConfirm}\n disabled={loading}\n >\n <Text fontColor={'light'} fontWeight=\"bold\">\n {confirmButtonText}\n </Text>\n </Button>\n </ModalFooter>}\n </ModalView>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
@@ -16,6 +16,7 @@ export interface SelectNativeProps<Data, Type extends 'single' | 'multi'> extend
16
16
  confirmButtonText?: string;
17
17
  selectModalTitle?: string;
18
18
  selectModalTitleComponent?: JSX.Element;
19
+ closeOnPick?: boolean;
19
20
  }
20
- declare function Select<Data, Type extends 'single' | 'multi'>({ value, options, keyExtractor, groupKeyExtractor, onSelect, type, labelExtractor, placeholder, onFocus, onBlur, disabled, onSearch, selectModalTitle, selectModalTitleComponent, searchBarPlaceholder, hideSearchBar, confirmButtonText, rightComponent, variant, hintComponent, hint, style, ...rest }: SelectNativeProps<Data, Type>): JSX.Element;
21
+ declare function Select<Data, Type extends 'single' | 'multi'>({ value, options, keyExtractor, groupKeyExtractor, onSelect, type, labelExtractor, placeholder, onFocus, onBlur, disabled, onSearch, selectModalTitle, selectModalTitleComponent, searchBarPlaceholder, hideSearchBar, confirmButtonText, rightComponent, variant, hintComponent, hint, style, closeOnPick, ...rest }: SelectNativeProps<Data, Type>): JSX.Element;
21
22
  export default Select;
@@ -5,13 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _reactCore = require("@tecsinapse/react-core");
9
+
8
10
  var React = _interopRequireWildcard(require("react"));
9
11
 
10
- var _reactCore = require("@tecsinapse/react-core");
12
+ var _Modal = require("../../atoms/Modal");
11
13
 
12
- var _Text = require("../Text");
14
+ var _Text = require("../../atoms/Text");
13
15
 
14
- var _Modal = require("./Modal");
16
+ var _Modal2 = require("./Modal");
15
17
 
16
18
  var _styled = require("./styled");
17
19
 
@@ -44,6 +46,7 @@ function Select({
44
46
  hintComponent,
45
47
  hint,
46
48
  style,
49
+ closeOnPick = type === 'single',
47
50
  ...rest
48
51
  }) {
49
52
  const {
@@ -51,8 +54,8 @@ function Select({
51
54
  handleBlur,
52
55
  handleFocus
53
56
  } = (0, _reactCore.useInputFocus)(onFocus, onBlur, !disabled);
54
- const [modalVisible, setModalVisible] = React.useState(false);
55
57
  const [selectOptions, setSelectOptions] = (0, React.useState)([]);
58
+ const modal = (0, _Modal.useLazyModalManager)();
56
59
  const [loading, setLoading] = (0, React.useState)(false);
57
60
  (0, React.useEffect)(() => {
58
61
  if (typeof options !== 'function') {
@@ -107,22 +110,12 @@ function Select({
107
110
  }
108
111
  }
109
112
  } catch (e) {} finally {
113
+ modal.requestUpdate();
110
114
  setLoading(false);
111
115
  }
112
116
  }
113
117
  }, [options, value, keyExtractor]);
114
118
 
115
- const handlePressInput = async () => {
116
- setModalVisible(true);
117
- handleFocus();
118
- await handleLazyFocus();
119
- };
120
-
121
- const handleCloseModal = () => {
122
- setModalVisible(false);
123
- handleBlur();
124
- };
125
-
126
119
  const getDisplayValue = () => {
127
120
  if (Array.isArray(value)) {
128
121
  if (value.length === 0) return placeholder;else {
@@ -135,6 +128,32 @@ function Select({
135
128
  }
136
129
  };
137
130
 
131
+ modal.sync(React.createElement(_Modal2.Modal, {
132
+ options: selectOptions || [],
133
+ focused: true,
134
+ keyExtractor: keyExtractor,
135
+ labelExtractor: labelExtractor,
136
+ groupKeyExtractor: groupKeyExtractor,
137
+ searchBarPlaceholder: searchBarPlaceholder,
138
+ type: type,
139
+ onSelect: onSelect,
140
+ value: value,
141
+ hideSearchBar: hideSearchBar,
142
+ onSearch: handleOnSearch,
143
+ selectModalTitle: selectModalTitle,
144
+ selectModalTitleComponent: selectModalTitleComponent,
145
+ confirmButtonText: confirmButtonText,
146
+ loading: loading,
147
+ onClose: handleBlur,
148
+ closeOnPick: closeOnPick
149
+ }));
150
+
151
+ const handlePressInput = async () => {
152
+ modal.show();
153
+ handleFocus();
154
+ await handleLazyFocus();
155
+ };
156
+
138
157
  return React.createElement(React.Fragment, null, React.createElement(_reactCore.HintInputContainer, _extends({
139
158
  viewStyle: style,
140
159
  onPress: handlePressInput,
@@ -152,27 +171,7 @@ function Select({
152
171
  }, rest), React.createElement(_styled.StyledSelectionText, {
153
172
  fontWeight: "bold",
154
173
  disabled: disabled
155
- }, getDisplayValue() || ' ')), React.createElement(_Modal.Modal, {
156
- visible: modalVisible,
157
- options: selectOptions || [],
158
- focused: modalVisible,
159
- keyExtractor: keyExtractor,
160
- labelExtractor: labelExtractor,
161
- groupKeyExtractor: groupKeyExtractor,
162
- searchBarPlaceholder: searchBarPlaceholder,
163
- type: type,
164
- onSelect: onSelect,
165
- value: value,
166
- hideSearchBar: hideSearchBar,
167
- onRequestClose: handleCloseModal,
168
- animated: true,
169
- animationType: 'slide',
170
- onSearch: handleOnSearch,
171
- selectModalTitle: selectModalTitle,
172
- selectModalTitleComponent: selectModalTitleComponent,
173
- confirmButtonText: confirmButtonText,
174
- loading: loading
175
- }));
174
+ }, getDisplayValue() || ' ')));
176
175
  }
177
176
 
178
177
  var _default = Select;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/molecules/Select/Select.tsx"],"names":["Select","value","options","keyExtractor","groupKeyExtractor","onSelect","type","labelExtractor","placeholder","onFocus","onBlur","disabled","onSearch","selectModalTitle","selectModalTitleComponent","searchBarPlaceholder","hideSearchBar","confirmButtonText","rightComponent","variant","hintComponent","hint","style","closeOnPick","rest","focused","handleBlur","handleFocus","selectOptions","setSelectOptions","modal","loading","setLoading","handleLazyFocus","result","find","v","e","handleOnSearch","React","useCallback","searchInput","undefined","length","selectedValues","filter","current","requestUpdate","getDisplayValue","Array","isArray","reduce","acc","option","index","key","slice","selectedOption","sync","handlePressInput","show","Text"],"mappings":";;;;;;;AAAA;;AAIA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;AA8BA,SAASA,MAAT,CAAuD;AAErDC,EAAAA,KAFqD;AAGrDC,EAAAA,OAHqD;AAIrDC,EAAAA,YAJqD;AAKrDC,EAAAA,iBALqD;AAMrDC,EAAAA,QANqD;AAOrDC,EAAAA,IAPqD;AAQrDC,EAAAA,cARqD;AASrDC,EAAAA,WATqD;AAUrDC,EAAAA,OAVqD;AAWrDC,EAAAA,MAXqD;AAYrDC,EAAAA,QAZqD;AAarDC,EAAAA,QAbqD;AAcrDC,EAAAA,gBAdqD;AAerDC,EAAAA,yBAfqD;AAgBrDC,EAAAA,oBAhBqD;AAiBrDC,EAAAA,aAjBqD;AAkBrDC,EAAAA,iBAlBqD;AAmBrDC,EAAAA,cAnBqD;AAoBrDC,EAAAA,OAAO,GAAG,SApB2C;AAqBrDC,EAAAA,aArBqD;AAsBrDC,EAAAA,IAtBqD;AAuBrDC,EAAAA,KAvBqD;AAwBrDC,EAAAA,WAAW,GAAGjB,IAAI,KAAK,QAxB8B;AAyBrD,KAAGkB;AAzBkD,CAAvD,EA0B+C;AAC7C,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,UAAX;AAAuBC,IAAAA;AAAvB,MAAuC,8BAC3ClB,OAD2C,EAE3CC,MAF2C,EAG3C,CAACC,QAH0C,CAA7C;AAMA,QAAM,CAACiB,aAAD,EAAgBC,gBAAhB,IAAoC,o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AAa,EAAEe,aAVjB;AAWE,IAAA,QAAQ,EAAEsB,cAXZ;AAYE,IAAA,gBAAgB,EAAEzB,gBAZpB;AAaE,IAAA,yBAAyB,EAAEC,yBAb7B;AAcE,IAAA,iBAAiB,EAAEG,iBAdrB;AAeE,IAAA,OAAO,EAAEc,OAfX;AAgBE,IAAA,OAAO,EAAEL,UAhBX;AAiBE,IAAA,WAAW,EAAEH;AAjBf,IADF;;AAsBA,QAAMoC,gBAAgB,GAAG,YAAY;AACnC7B,IAAAA,KAAK,CAAC8B,IAAN;AACAjC,IAAAA,WAAW;AACX,UAAMM,eAAe,EAArB;AACD,GAJD;;AAMA,SACE,0CACE,oBAAC,6BAAD;AACE,IAAA,SAAS,EAAEX,KADb;AAEE,IAAA,OAAO,EAAEqC,gBAFX;AAGE,IAAA,OAAO,EAAElC,OAHX;AAIE,IAAA,QAAQ,EAAEd,QAJZ;AAKE,IAAA,cAAc,EAAEkD,UALlB;AAME,IAAA,OAAO,EAAE1C,OANX;AAOE,IAAA,IAAI,EAAEE,IAPR;AAQE,IAAA,aAAa,EAAED,aARjB;AASE,IAAA,cAAc,EACZ,0CACE,oBAAC,kBAAD;AAAY,MAAA,IAAI,EAAC,cAAjB;AAAgC,MAAA,IAAI,EAAC,SAArC;AAA+C,MAAA,IAAI,EAAC;AAApD,MADF,EAEGF,cAFH;AAVJ,KAeMM,IAfN,GAiBE,oBAAC,2BAAD;AAAqB,IAAA,UAAU,EAAC,MAAhC;AAAuC,IAAA,QAAQ,EAAEb;AAAjD,KACGqC,eAAe,MAAM,GADxB,CAjBF,CADF,CADF;AAyBD;;eAEchD,M","sourcesContent":["import {\n HintInputContainer, InputContainerProps,\n useInputFocus\n} from '@tecsinapse/react-core';\nimport * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport { useLazyModalManager } from '../../atoms/Modal';\nimport { Text } from '../../atoms/Text';\nimport { Modal } from './Modal';\nimport { SelectIcon, StyledSelectionText } from './styled';\n\nexport interface SelectNativeProps<Data, Type extends 'single' | 'multi'>\n extends Omit<InputContainerProps, 'value' | 'onChange' | 'onChangeText'> {\n options: ((searchInput?: string) => Promise<Data[]>) | Data[];\n onSelect: (\n option: Type extends 'single' ? Data | undefined : Data[]\n ) => never | void;\n value: Type extends 'single' ? Data | undefined : Data[];\n type: Type;\n\n keyExtractor: (t: Data, index?: number) => string;\n labelExtractor: (t: Data) => string;\n groupKeyExtractor?: (t: Data) => string;\n\n hideSearchBar?: boolean;\n placeholder?: string;\n onFocus?: () => void | never;\n onBlur?: () => void | never;\n onSearch?:\n | ((searchArg: string) => void)\n | ((searchInput?: string) => Promise<Data[]>)\n | never;\n searchBarPlaceholder?: string;\n confirmButtonText?: string;\n selectModalTitle?: string;\n selectModalTitleComponent?: JSX.Element;\n closeOnPick?: boolean;\n}\n\nfunction Select<Data, Type extends 'single' | 'multi'>({\n /** Select props */\n value,\n options,\n keyExtractor,\n groupKeyExtractor,\n onSelect,\n type,\n labelExtractor,\n placeholder,\n onFocus,\n onBlur,\n disabled,\n onSearch,\n selectModalTitle,\n selectModalTitleComponent,\n searchBarPlaceholder,\n hideSearchBar,\n confirmButtonText,\n rightComponent,\n variant = 'default',\n hintComponent,\n hint,\n style,\n closeOnPick = type === 'single',\n ...rest\n}: SelectNativeProps<Data, Type>): JSX.Element {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [selectOptions, setSelectOptions] = useState<Data[]>([]);\n const modal = useLazyModalManager()\n\n // TODO: Add Skeleton to modal height when loading is true\n const [loading, setLoading] = useState<boolean>(false);\n\n useEffect(() => {\n if (typeof options !== 'function') {\n setSelectOptions(options);\n }\n }, [options]);\n\n useEffect(() => {\n if (typeof options === 'function') {\n if (value) {\n if (type === 'single') setSelectOptions([value as Data]);\n else setSelectOptions([...(value as Data[])]);\n } else setSelectOptions([]);\n }\n }, [value]);\n\n const handleLazyFocus = async () => {\n if (typeof options === 'function') {\n setLoading(true);\n try {\n const result = await options();\n if (result) {\n if (\n value &&\n !result.find(v => keyExtractor(value as Data) === keyExtractor(v))\n ) {\n setSelectOptions([value as Data, ...result]);\n } else setSelectOptions(result);\n }\n } catch (e) {\n // TODO: Catch error\n } finally {\n setLoading(false);\n }\n }\n };\n\n const handleOnSearch = React.useCallback(\n async (searchInput: string | undefined) => {\n if (searchInput !== undefined && onSearch) {\n setLoading(true);\n try {\n const result = await onSearch(searchInput);\n if (result) {\n if (type === 'single') {\n if (\n value &&\n !result.find(\n v => keyExtractor(value as Data) === keyExtractor(v)\n )\n ) {\n setSelectOptions([value as Data, ...result]);\n } else setSelectOptions(result);\n } else {\n if ((value as Data[]).length > 0) {\n const selectedValues =\n (value as Data[]).filter(\n v =>\n !result.find(\n current =>\n keyExtractor(v as Data) === keyExtractor(current)\n )\n ) || [];\n setSelectOptions([...selectedValues, ...result]);\n } else {\n setSelectOptions(result);\n }\n }\n }\n } catch (e) {\n // TODO: Catch error\n } finally {\n modal.requestUpdate()\n setLoading(false);\n }\n }\n },\n [options, value, keyExtractor]\n );\n\n const getDisplayValue = () => {\n if (Array.isArray(value)) {\n if (value.length === 0) return placeholder;\n else {\n return selectOptions\n ?.reduce(\n (acc, option, index) =>\n value.find(\n key => keyExtractor(option, index) == keyExtractor(key, index)\n )\n ? acc + labelExtractor(option) + ', '\n : acc,\n ''\n )\n .slice(0, -2);\n }\n } else {\n if (value === undefined) return placeholder;\n const selectedOption = selectOptions?.find(\n (option, index) =>\n keyExtractor(option, index) == keyExtractor(value as Data, index)\n );\n return selectedOption ? labelExtractor(selectedOption) : placeholder;\n }\n };\n\n modal.sync(\n <Modal\n options={selectOptions || []}\n focused={true}\n keyExtractor={keyExtractor}\n labelExtractor={labelExtractor}\n groupKeyExtractor={groupKeyExtractor}\n searchBarPlaceholder={searchBarPlaceholder}\n type={type}\n onSelect={onSelect}\n value={value}\n hideSearchBar={hideSearchBar}\n onSearch={handleOnSearch}\n selectModalTitle={selectModalTitle}\n selectModalTitleComponent={selectModalTitleComponent}\n confirmButtonText={confirmButtonText}\n loading={loading}\n onClose={handleBlur}\n closeOnPick={closeOnPick}\n />\n )\n \n const handlePressInput = async () => {\n modal.show()\n handleFocus();\n await handleLazyFocus();\n };\n\n return (\n <>\n <HintInputContainer\n viewStyle={style}\n onPress={handlePressInput}\n focused={focused}\n disabled={disabled}\n LabelComponent={Text}\n variant={variant}\n hint={hint}\n hintComponent={hintComponent}\n rightComponent={\n <>\n <SelectIcon name=\"chevron-down\" type=\"ionicon\" size=\"centi\" />\n {rightComponent}\n </>\n }\n {...rest}\n >\n <StyledSelectionText fontWeight=\"bold\" disabled={disabled}>\n {getDisplayValue() || ' '}\n </StyledSelectionText>\n </HintInputContainer>\n </>\n );\n}\n\nexport default Select;\n"],"file":"Select.js"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/molecules/Select/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export { default as Select, SelectNativeProps } from './Select';\n"],"file":"index.js"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ActivityIndicator, View, ViewProps } from 'react-native';
3
- export declare const StyledModal: import("@emotion/native").StyledComponent<any, {}, {
3
+ export declare const getStyledModal: (safeTop?: number) => import("@emotion/native").StyledComponent<any, {}, {
4
4
  ref?: import("react").Ref<View> | undefined;
5
5
  }>;
6
6
  export declare const StyledSelectionText: import("@emotion/native").StyledComponent<any, {}, {}>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.FetchIndicator = exports.SelectIcon = exports.ModalFooter = exports.ListItem = exports.SearchBar = exports.SearchBarContainer = exports.CloseButton = exports.Header = exports.StyledPressableSurface = exports.Dummy = exports.StyledSelectionText = exports.StyledModal = void 0;
6
+ exports.FetchIndicator = exports.SelectIcon = exports.ModalFooter = exports.ListItem = exports.SearchBar = exports.SearchBarContainer = exports.CloseButton = exports.Header = exports.StyledPressableSurface = exports.Dummy = exports.StyledSelectionText = exports.getStyledModal = void 0;
7
7
 
8
8
  var _native = _interopRequireWildcard(require("@emotion/native"));
9
9
 
@@ -11,23 +11,25 @@ var _reactCore = require("@tecsinapse/react-core");
11
11
 
12
12
  var _reactNative = require("react-native");
13
13
 
14
- var _Input = require("../Input");
14
+ var _Input = require("../../atoms/Input");
15
15
 
16
- var _Text = require("../Text");
16
+ var _Text = require("../../atoms/Text");
17
17
 
18
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
19
 
20
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
21
 
22
- const StyledModal = (0, _native.default)(_reactNative.View)`
23
- position: relative;
24
- background-color: ${({
25
- theme
26
- }) => theme.miscellaneous.bodyColor};
27
- height: 100%;
28
- width: 100%;
29
- `;
30
- exports.StyledModal = StyledModal;
22
+ const getStyledModal = (safeTop = 0) => {
23
+ return (0, _native.default)(_reactNative.View)`
24
+ padding-top: ${`${(0, _reactCore.RFValue)(safeTop)}px`};
25
+ background-color: ${({
26
+ theme
27
+ }) => theme.miscellaneous.bodyColor};
28
+ height: 100%;
29
+ `;
30
+ };
31
+
32
+ exports.getStyledModal = getStyledModal;
31
33
  const StyledSelectionText = (0, _native.default)(_Text.Text)(props => {
32
34
  var _props$theme;
33
35
 
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/molecules/Select/styled.ts"],"names":["getStyledModal","safeTop","View","theme","miscellaneous","bodyColor","StyledSelectionText","Text","props","typography","h5","lineHeight","Dummy","StyledPressableSurface","PressableSurface","Header","spacing","deca","CloseButton","Button","SearchBarContainer","SearchBar","Input","ListItem","color","secondary","light","mili","ModalFooter","SelectIcon","Icon","centi","medium","FetchIndicator","ActivityIndicator"],"mappings":";;;;;;;AAAA;;AACA;;AAYA;;AACA;;AACA;;;;;;AAEO,MAAMA,cAAc,GAAG,CAACC,OAAe,GAAG,CAAnB,KAAyB;AACrD,SAAO,qBAAOC,iBAAP,CAA+C;AACxD,mBAAoB,GAAE,wBAAQD,OAAR,CAAiB,IAAI;AAC3C,wBAAwB,CAAC;AAAEE,IAAAA;AAAF,GAAD,KAAeA,KAAK,CAACC,aAAN,CAAoBC,SAAU;AACrE;AACA,GAJE;AAKD,CANM;;;AAQA,MAAMC,mBAAmB,GAAG,qBAAOC,UAAP,EAChCC,KAAD;AAAA;;AAAA,SAA+D,gBAAI;AACrE,mBADoE,gBACjDA,KAAK,CAACL,KAD2C,iDACjD,aAAaM,UAAb,CAAwBC,EAAxB,CAA2BC,UAAW;AACzD,MAAM,oCAAoBH,KAApB,CAA2B;AACjC,GAHE;AAAA,CADiC,CAA5B;;AAOA,MAAMI,KAAK,GAAG,qBAAOV,iBAAP,CAAa;AAClC;AACA;AACA,CAHO;;AAKA,MAAMW,sBAAsB,GAAG,qBACpCC,2BADoC,CAEb;AACzB;AACA,CAJO;;AAMA,MAAMC,MAAM,GAAG,qBAAOb,iBAAP,CAA8C;AACpE;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC/C,YAAY,2B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AYC,SAAZ,CAAsBO,MAAO;AACvD,CAHO;;AAKA,MAAMC,cAAc,GAAG,qBAAOC,8BAAP,CAA0B;AACxD;AACA,CAFO","sourcesContent":["import styled, { css } from '@emotion/native';\nimport {\n Button,\n ButtonProps,\n disabledInputStyles,\n Icon,\n InputContainerProps,\n PressableSurface,\n PressableSurfaceProps,\n RFValue,\n RFValueStr,\n StyleProps\n} from '@tecsinapse/react-core';\nimport { ActivityIndicator, ModalProps, View, ViewProps } from 'react-native';\nimport { Input, InputNativeProps } from '../../atoms/Input';\nimport { Text } from '../../atoms/Text';\n\nexport const getStyledModal = (safeTop: number = 0) => {\n return styled(View)<ModalProps & Partial<StyleProps>>`\n padding-top: ${`${RFValue(safeTop)}px`};\n background-color: ${({ theme }) => theme.miscellaneous.bodyColor};\n height: 100%;\n `\n}\n\nexport const StyledSelectionText = styled(Text)(\n (props: Partial<InputContainerProps> & Partial<StyleProps>) => css`\n line-height: ${props.theme?.typography.h5.lineHeight};\n ${disabledInputStyles(props)};\n `\n);\n\nexport const Dummy = styled(View)`\n aspect-ratio: 1;\n height: 100%;\n`;\n\nexport const StyledPressableSurface = styled(\n PressableSurface\n)<PressableSurfaceProps>`\n width: 100%;\n`;\n\nexport const Header = styled(View)<ViewProps & Partial<StyleProps>>`\n position: relative;\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n padding: ${({ theme }) => theme.spacing.deca};\n height: ${RFValueStr('75px')};\n`;\n\nexport const CloseButton = styled(Button)<ButtonProps & Partial<StyleProps>>`\n aspect-ratio: 1;\n height: 100%;\n`;\n\nexport const SearchBarContainer = styled(View)<ViewProps & Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.deca};\n position: relative;\n`;\n\nexport const SearchBar = styled(Input)<InputNativeProps & Partial<StyleProps>>`\n margin-bottom: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const ListItem = styled(PressableSurface)<\n PressableSurfaceProps & Partial<StyleProps>\n>`\n border-bottom-width: ${RFValueStr('1px')};\n border-color: ${({ theme }) => theme.color.secondary.light};\n padding-vertical: ${({ theme }) => theme.spacing.mili};\n padding-horizontal: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const ModalFooter = styled(View)<Partial<StyleProps>>`\n width: 100%;\n height: auto;\n bottom: 0;\n background-color: ${({ theme }) => theme.miscellaneous.bodyColor};\n padding: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const SelectIcon = styled(Icon)<Partial<StyleProps>>`\n padding: ${({ theme }) => theme.spacing.centi};\n color: ${({ theme }) => theme.color.secondary.medium};\n`;\n\nexport const FetchIndicator = styled(ActivityIndicator)`\n align-self: center;\n`;\n"],"file":"styled.js"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export * from '@tecsinapse/react-core';
2
2
  export { Header, HeaderProps } from './components/atoms/Header';
3
- export { Select, SelectNativeProps } from './components/atoms/Select';
3
+ export { Select, SelectNativeProps } from './components/molecules/Select';
4
4
  export { Input, InputNativeProps } from './components/atoms/Input';
5
5
  export { TextArea, TextAreaProps } from './components/atoms/TextArea';
6
6
  export { Text, TextNativeProps } from './components/atoms/Text';
@@ -12,9 +12,9 @@ export { Tag, TagProps } from './components/atoms/Tag';
12
12
  export { SnappingSlider, SnappingSliderProps, } from './components/atoms/SnappingSlider';
13
13
  export { Badge, BadgeNativeProps } from './components/atoms/Badge';
14
14
  export { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';
15
- export { DatePicker } from './components/molecules/DatePicker';
16
- export { DateTimePicker } from './components/molecules/DateTimePicker';
15
+ export { DatePicker, NativeDatePickerProps } from './components/molecules/DatePicker';
16
+ export { DateTimePicker, NativeDateTimePickerProps } from './components/molecules/DateTimePicker';
17
17
  export { Avatar } from './components/atoms/Avatar';
18
18
  export { Calendar } from './components/molecules/Calendar';
19
19
  export { DateTimeSelector } from './components/molecules/DateTimeSelector';
20
- export { ModalGroupManager, ModalView, ModalLifecycleHandler, useModalManager, IBaseModal } from './components/atoms/Modal';
20
+ export { ModalGroupManager, ModalView, ModalLifecycleHandler, useLazyModalManager, useModalManager, IBaseModal } from './components/atoms/Modal';
package/dist/index.js CHANGED
@@ -33,13 +33,16 @@ var _exportNames = {
33
33
  Snackbar: true,
34
34
  SnackbarNativeProps: true,
35
35
  DatePicker: true,
36
+ NativeDatePickerProps: true,
36
37
  DateTimePicker: true,
38
+ NativeDateTimePickerProps: true,
37
39
  Avatar: true,
38
40
  Calendar: true,
39
41
  DateTimeSelector: true,
40
42
  ModalGroupManager: true,
41
43
  ModalView: true,
42
44
  ModalLifecycleHandler: true,
45
+ useLazyModalManager: true,
43
46
  useModalManager: true,
44
47
  IBaseModal: true
45
48
  };
@@ -217,12 +220,24 @@ Object.defineProperty(exports, "DatePicker", {
217
220
  return _DatePicker.DatePicker;
218
221
  }
219
222
  });
223
+ Object.defineProperty(exports, "NativeDatePickerProps", {
224
+ enumerable: true,
225
+ get: function () {
226
+ return _DatePicker.NativeDatePickerProps;
227
+ }
228
+ });
220
229
  Object.defineProperty(exports, "DateTimePicker", {
221
230
  enumerable: true,
222
231
  get: function () {
223
232
  return _DateTimePicker.DateTimePicker;
224
233
  }
225
234
  });
235
+ Object.defineProperty(exports, "NativeDateTimePickerProps", {
236
+ enumerable: true,
237
+ get: function () {
238
+ return _DateTimePicker.NativeDateTimePickerProps;
239
+ }
240
+ });
226
241
  Object.defineProperty(exports, "Avatar", {
227
242
  enumerable: true,
228
243
  get: function () {
@@ -259,6 +274,12 @@ Object.defineProperty(exports, "ModalLifecycleHandler", {
259
274
  return _Modal.ModalLifecycleHandler;
260
275
  }
261
276
  });
277
+ Object.defineProperty(exports, "useLazyModalManager", {
278
+ enumerable: true,
279
+ get: function () {
280
+ return _Modal.useLazyModalManager;
281
+ }
282
+ });
262
283
  Object.defineProperty(exports, "useModalManager", {
263
284
  enumerable: true,
264
285
  get: function () {
@@ -288,7 +309,7 @@ Object.keys(_reactCore).forEach(function (key) {
288
309
 
289
310
  var _Header = require("./components/atoms/Header");
290
311
 
291
- var _Select = require("./components/atoms/Select");
312
+ var _Select = require("./components/molecules/Select");
292
313
 
293
314
  var _Input = require("./components/atoms/Input");
294
315
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAIA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export * from '@tecsinapse/react-core';\nexport { Header, HeaderProps } from './components/atoms/Header';\nexport { Select, SelectNativeProps } from './components/atoms/Select';\nexport { Input, InputNativeProps } from './components/atoms/Input';\nexport { TextArea, TextAreaProps } from './components/atoms/TextArea';\nexport { Text, TextNativeProps } from './components/atoms/Text';\nexport { Error, Loading, Success, Button, ButtonNativeProps } from './components/atoms/Button';\nexport { GroupButtonOption } from './components/atoms/GroupButton';\nexport {\n InputPassword,\n InputPasswordNativeProps,\n} from './components/molecules/InputPassword';\nexport {\n BottomNavigator,\n BottomNavigatorProps,\n} from './components/atoms/BottomNavigator';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport {\n SnappingSlider,\n SnappingSliderProps,\n} from './components/atoms/SnappingSlider';\nexport { Badge, BadgeNativeProps } from './components/atoms/Badge';\nexport { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';\nexport { DatePicker } from './components/molecules/DatePicker';\nexport { DateTimePicker } from './components/molecules/DateTimePicker';\nexport { Avatar } from './components/atoms/Avatar';\nexport { Calendar } from './components/molecules/Calendar';\nexport { DateTimeSelector } from './components/molecules/DateTimeSelector';\nexport { ModalGroupManager, ModalView, ModalLifecycleHandler, useModalManager, IBaseModal } from './components/atoms/Modal';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAIA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["export * from '@tecsinapse/react-core';\nexport { Header, HeaderProps } from './components/atoms/Header';\nexport { Select, SelectNativeProps } from './components/molecules/Select';\nexport { Input, InputNativeProps } from './components/atoms/Input';\nexport { TextArea, TextAreaProps } from './components/atoms/TextArea';\nexport { Text, TextNativeProps } from './components/atoms/Text';\nexport { Error, Loading, Success, Button, ButtonNativeProps } from './components/atoms/Button';\nexport { GroupButtonOption } from './components/atoms/GroupButton';\nexport {\n InputPassword,\n InputPasswordNativeProps,\n} from './components/molecules/InputPassword';\nexport {\n BottomNavigator,\n BottomNavigatorProps,\n} from './components/atoms/BottomNavigator';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport {\n SnappingSlider,\n SnappingSliderProps,\n} from './components/atoms/SnappingSlider';\nexport { Badge, BadgeNativeProps } from './components/atoms/Badge';\nexport { Snackbar, SnackbarNativeProps } from './components/molecules/Snackbar';\nexport { DatePicker, NativeDatePickerProps } from './components/molecules/DatePicker';\nexport { DateTimePicker, NativeDateTimePickerProps } from './components/molecules/DateTimePicker';\nexport { Avatar } from './components/atoms/Avatar';\nexport { Calendar } from './components/molecules/Calendar';\nexport { DateTimeSelector } from './components/molecules/DateTimeSelector';\nexport { ModalGroupManager, ModalView, ModalLifecycleHandler, useLazyModalManager, useModalManager, IBaseModal } from './components/atoms/Modal';\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-native-kit",
3
3
  "description": "TecSinapse React Native components",
4
- "version": "1.12.11",
4
+ "version": "1.12.15",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@emotion/native": "^11.0.0",
15
15
  "@emotion/react": "^11.4.1",
16
- "@tecsinapse/react-core": "^1.12.8"
16
+ "@tecsinapse/react-core": "^1.12.10"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "@types/uuid": "^8.3.3"
36
36
  },
37
- "gitHead": "5ae217bb1d1226eb9d83e1b7d7630ccc177df104"
37
+ "gitHead": "b786cb2b22f10dcb8939354cf4a1dba4a5a1ee3a"
38
38
  }
@@ -37,27 +37,29 @@ export class ModalLifecycleHandler {
37
37
  * Updates all the modal components.
38
38
  */
39
39
  public update = () => {
40
- const nodes = Array.from(this.nodeGroup.values())
41
- .filter(node => node.visible || !!node.lastVisualization)
42
- .sort((nodeA, nodeB) => (nodeA.lastVisualization?.getTime() || 0) - (nodeB.lastVisualization?.getTime() || 0))
43
- .map((node, index, filteredNodes) => {
44
- let modalElement = node.modal()
45
- let { props } = modalElement
46
- return React.cloneElement(modalElement, {
47
- ...props,
48
- key: node.id,
49
- visible: node.visible,
50
- isLastShown: filteredNodes.length - 1 === index,
51
- close: () => this.close(node.id),
52
- onClose: () => {
53
- this.remove(node.id)
54
- props.onClose?.()
55
- }
40
+ requestAnimationFrame(() => {
41
+ const nodes = Array.from(this.nodeGroup.values())
42
+ .filter(node => node.visible || !!node.lastVisualization)
43
+ .sort((nodeA, nodeB) => (nodeA.lastVisualization?.getTime() || 0) - (nodeB.lastVisualization?.getTime() || 0))
44
+ .map((node, index, filteredNodes) => {
45
+ let modalElement = node.modal()
46
+ let { props } = modalElement
47
+ return React.cloneElement(modalElement, {
48
+ ...props,
49
+ key: node.id,
50
+ visible: node.visible,
51
+ isLastShown: filteredNodes.length - 1 === index,
52
+ close: () => this.close(node.id),
53
+ onClose: () => {
54
+ this.remove(node.id)
55
+ props.onClose?.()
56
+ }
57
+ })
56
58
  })
57
- })
58
-
59
- const [, updateState ] = this.state || []
60
- updateState?.(nodes)
59
+
60
+ const [, updateState ] = this.state || []
61
+ updateState?.(nodes)
62
+ })
61
63
  }
62
64
 
63
65
  /**
@@ -2,4 +2,5 @@ export * from './ModalGroupManager'
2
2
  export * from './ModalLifecycleHandler'
3
3
  export * from './ui/BaseModalView'
4
4
  export * from './ui/types'
5
- export * from './useModalManager'
5
+ export * from './useModalManager'
6
+ export * from './useLazyModalManager'