@tecsinapse/react-native-kit 1.10.3 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/components/atoms/Button/Button.d.ts +6 -0
  3. package/dist/components/atoms/Button/Button.js +35 -0
  4. package/dist/components/atoms/Button/Button.js.map +1 -0
  5. package/dist/components/atoms/Button/index.d.ts +1 -0
  6. package/dist/components/atoms/Button/index.js +14 -0
  7. package/dist/components/atoms/Button/index.js.map +1 -1
  8. package/dist/components/atoms/Select/Modal.d.ts +5 -1
  9. package/dist/components/atoms/Select/Modal.js +19 -8
  10. package/dist/components/atoms/Select/Modal.js.map +1 -1
  11. package/dist/components/atoms/Select/Select.d.ts +2 -2
  12. package/dist/components/atoms/Select/Select.js +67 -6
  13. package/dist/components/atoms/Select/Select.js.map +1 -1
  14. package/dist/components/atoms/Select/styled.d.ts +8 -5
  15. package/dist/components/atoms/Select/styled.js +13 -17
  16. package/dist/components/atoms/Select/styled.js.map +1 -1
  17. package/dist/components/molecules/Calendar/Calendar.d.ts +4 -1
  18. package/dist/components/molecules/Calendar/Calendar.js +9 -3
  19. package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
  20. package/dist/components/molecules/DatePicker/DatePicker.d.ts +4 -1
  21. package/dist/components/molecules/DatePicker/DatePicker.js +9 -3
  22. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  23. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +9 -3
  24. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  25. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +9 -3
  26. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +14 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/utils/date.d.ts +1 -0
  31. package/dist/utils/date.js +30 -0
  32. package/dist/utils/date.js.map +1 -0
  33. package/package.json +3 -3
  34. package/src/components/atoms/Button/Button.tsx +17 -0
  35. package/src/components/atoms/Button/index.ts +2 -1
  36. package/src/components/atoms/Select/Modal.tsx +39 -23
  37. package/src/components/atoms/Select/Select.tsx +96 -8
  38. package/src/components/atoms/Select/styled.ts +11 -11
  39. package/src/components/molecules/Calendar/Calendar.tsx +12 -4
  40. package/src/components/molecules/DatePicker/DatePicker.tsx +7 -4
  41. package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +7 -2
  42. package/src/components/molecules/DateTimeSelector/DateTimeSelector.tsx +9 -2
  43. package/src/index.ts +1 -1
  44. package/src/utils/date.ts +17 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,44 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.11.1](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.11.0...@tecsinapse/react-native-kit@1.11.1) (2021-12-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * handleLazySelect ([1102499](https://github.com/tecsinapse/design-system/commit/11024996571866d542d4d112baf7b183b8b146e1))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.11.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.10.5...@tecsinapse/react-native-kit@1.11.0) (2021-12-17)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * [163127] Modais de picker do DS estão em inglês ([a95b0b2](https://github.com/tecsinapse/design-system/commit/a95b0b283f3535af20a23ac6a9a5e5633127d5b0))
23
+
24
+
25
+
26
+
27
+
28
+ ## [1.10.5](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.10.4...@tecsinapse/react-native-kit@1.10.5) (2021-12-07)
29
+
30
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
31
+
32
+
33
+
34
+
35
+
36
+ ## [1.10.4](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.10.3...@tecsinapse/react-native-kit@1.10.4) (2021-12-06)
37
+
38
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
39
+
40
+
41
+
42
+
43
+
6
44
  ## [1.10.3](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.10.2...@tecsinapse/react-native-kit@1.10.3) (2021-11-29)
7
45
 
8
46
  **Note:** Version bump only for package @tecsinapse/react-native-kit
@@ -0,0 +1,6 @@
1
+ import { ButtonProps } from "@tecsinapse/react-core";
2
+ import { FC } from "react";
3
+ export declare type ButtonNativeProps = ButtonProps & {
4
+ autoDismissKeyboard?: boolean;
5
+ };
6
+ export declare const Button: FC<ButtonNativeProps>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Button = void 0;
7
+
8
+ var _reactCore = require("@tecsinapse/react-core");
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _reactNative = require("react-native");
13
+
14
+ 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); }
15
+
16
+ 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; }
17
+
18
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
+
20
+ const Button = ({
21
+ autoDismissKeyboard = true,
22
+ onPress,
23
+ ...others
24
+ }) => {
25
+ const handleOnPress = (0, _react.useCallback)(event => {
26
+ autoDismissKeyboard && _reactNative.Keyboard.dismiss();
27
+ onPress === null || onPress === void 0 ? void 0 : onPress(event);
28
+ }, [onPress]);
29
+ return _react.default.createElement(_reactCore.Button, _extends({}, others, {
30
+ onPress: handleOnPress
31
+ }));
32
+ };
33
+
34
+ exports.Button = Button;
35
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/atoms/Button/Button.tsx"],"names":["Button","autoDismissKeyboard","onPress","others","handleOnPress","event","Keyboard","dismiss"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;AAMO,MAAMA,MAA6B,GAAG,CAAC;AAAEC,EAAAA,mBAAmB,GAAG,IAAxB;AAA8BC,EAAAA,OAA9B;AAAuC,KAAGC;AAA1C,CAAD,KAAwD;AAEjG,QAAMC,aAAa,GAAG,wBAAaC,KAAD,IAAW;AACzCJ,IAAAA,mBAAmB,IAAIK,sBAASC,OAAT,EAAvB;AACAL,IAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAGG,KAAH,CAAP;AACH,GAHqB,EAGnB,CAACH,OAAD,CAHmB,CAAtB;AAKA,SAAO,6BAAC,iBAAD,eAAgBC,MAAhB;AAAwB,IAAA,OAAO,EAAEC;AAAjC,KAAP;AACH,CARM","sourcesContent":["import { Button as ButtonCore, ButtonProps } from \"@tecsinapse/react-core\";\nimport React, { FC, useCallback } from \"react\";\nimport { Keyboard } from \"react-native\";\n\nexport type ButtonNativeProps = ButtonProps & {\n autoDismissKeyboard?: boolean\n}\n\nexport const Button: FC<ButtonNativeProps> = ({ autoDismissKeyboard = true, onPress, ...others }) => {\n\n const handleOnPress = useCallback((event) => {\n autoDismissKeyboard && Keyboard.dismiss()\n onPress?.(event)\n }, [onPress])\n\n return <ButtonCore {...others} onPress={handleOnPress}/>\n}"],"file":"Button.js"}
@@ -1 +1,2 @@
1
+ export { Button, ButtonNativeProps } from './Button';
1
2
  export { Error, Loading, Success } from './States';
@@ -3,6 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "Button", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Button.Button;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ButtonNativeProps", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Button.ButtonNativeProps;
16
+ }
17
+ });
6
18
  Object.defineProperty(exports, "Error", {
7
19
  enumerable: true,
8
20
  get: function () {
@@ -22,5 +34,7 @@ Object.defineProperty(exports, "Success", {
22
34
  }
23
35
  });
24
36
 
37
+ var _Button = require("./Button");
38
+
25
39
  var _States = require("./States");
26
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export { Error, Loading, Success } from './States';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Button/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { Button, ButtonNativeProps } from './Button';\nexport { Error, Loading, Success } from './States';"],"file":"index.js"}
@@ -1,3 +1,7 @@
1
1
  import { ModalProps } from 'react-native';
2
2
  import { SelectNativeProps } from './Select';
3
- export declare const Modal: <Data, Type extends "single" | "multi">({ options, keyExtractor, labelExtractor, groupKeyExtractor, hideSearchBar, searchBarPlaceholder, focused, type, value, onSelect, onSearch, onRequestClose, selectModalTitle, selectModalTitleComponent, confirmButtonText, ...modalProps }: SelectNativeProps<Data, Type> & import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps) => JSX.Element;
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, onRequestClose, selectModalTitle, selectModalTitleComponent, confirmButtonText, loading, ...modalProps }: SelectNativeProps<Data, Type> & import("react-native").ModalBaseProps & import("react-native").ModalPropsIOS & import("react-native").ModalPropsAndroid & import("react-native").ViewProps & LoadingProps) => JSX.Element;
7
+ export {};
@@ -41,6 +41,7 @@ const Component = ({
41
41
  selectModalTitle,
42
42
  selectModalTitleComponent,
43
43
  confirmButtonText,
44
+ loading,
44
45
  ...modalProps
45
46
  }) => {
46
47
  const [selectedValues, setSelectedValues] = React.useState([]);
@@ -48,9 +49,14 @@ const Component = ({
48
49
  React.useEffect(() => {
49
50
  setSelectedValues(value ? type === 'multi' ? value : [value] : []);
50
51
  }, [value, focused, setSelectedValues]);
51
- const data = options.map((option, index) => ({ ...option,
52
- _checked: type === 'multi' ? !!selectedValues.find(value => keyExtractor(option, index) == keyExtractor(value, index)) : keyExtractor(selectedValues[0] || {}, index) == keyExtractor(option, index)
53
- }));
52
+
53
+ const getData = options => {
54
+ return options === null || options === void 0 ? void 0 : options.map((option, index) => ({ ...option,
55
+ _checked: type === 'multi' ? !!selectedValues.find(value => keyExtractor(option, index) == keyExtractor(value, index)) : keyExtractor(selectedValues[0] || {}, index) == keyExtractor(option, index)
56
+ }));
57
+ };
58
+
59
+ const data = typeof options !== 'function' ? getData(options) : [];
54
60
 
55
61
  const handlePressItem = option => () => {
56
62
  setSelectedValues(selectedValues => {
@@ -102,10 +108,14 @@ const Component = ({
102
108
  type: "ionicon",
103
109
  size: "centi"
104
110
  })
105
- })), React.createElement(_reactNative.FlatList, {
111
+ })), loading && React.createElement(_styled.FetchIndicator, {
112
+ animating: true,
113
+ color: 'grey',
114
+ size: 'large'
115
+ }), React.createElement(_reactNative.FlatList, {
106
116
  data: data,
107
117
  keyExtractor: keyExtractor,
108
- ListFooterComponent: React.createElement(_styled.ListFooter, null),
118
+ fadingEdgeLength: 200,
109
119
  renderItem: ({
110
120
  item
111
121
  }) => React.createElement(_styled.ListItem, {
@@ -125,14 +135,15 @@ const Component = ({
125
135
  }, React.createElement(_Text.Text, {
126
136
  fontWeight: item._checked ? 'bold' : 'regular'
127
137
  }, labelExtractor(item)))))
128
- }), React.createElement(_styled.FloatingButton, {
138
+ }), React.createElement(_styled.ModalFooter, null, React.createElement(_reactCore.Button, {
129
139
  variant: 'filled',
130
140
  color: 'primary',
131
- onPress: handleConfirm
141
+ onPress: handleConfirm,
142
+ disabled: loading
132
143
  }, React.createElement(_Text.Text, {
133
144
  fontColor: 'light',
134
145
  fontWeight: "bold"
135
- }, confirmButtonText))));
146
+ }, confirmButtonText)))));
136
147
  };
137
148
 
138
149
  const Modal = Component;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Select/Modal.tsx"],"names":["Component","options","keyExtractor","labelExtractor","groupKeyExtractor","hideSearchBar","searchBarPlaceholder","focused","type","value","onSelect","onSearch","onRequestClose","selectModalTitle","selectModalTitleComponent","confirmButtonText","modalProps","selectedValues","setSelectedValues","React","useState","searchArg","setSearchArg","useEffect","data","map","option","index","_checked","find","handlePressItem","newArr","found","push","handleConfirm","headerContent","onPress","icon","name","fontColor","text","item","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AAEA;;AACA;;AAKA;;AACA;;;;;;;;AAEA,MAAMA,SAAS,GAAG,CAAwC;AACxDC,EAAAA,OADwD;AAExDC,EAAAA,YAFwD;AAGxDC,EAAAA,cAHwD;AAIxDC,EAAAA,iBAJwD;AAKxDC,EAAAA,aALwD;AAMxDC,EAAAA,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ZJ,CADF;AALJ,IAzBF,EAyDE,oBAAC,sBAAD;AACE,IAAA,OAAO,EAAE,QADX;AAEE,IAAA,KAAK,EAAE,SAFT;AAGE,IAAA,OAAO,EAAEP;AAHX,KAKE,oBAAC,UAAD;AAAM,IAAA,SAAS,EAAE,OAAjB;AAA0B,IAAA,UAAU,EAAC;AAArC,KACGnB,iBADH,CALF,CAzDF,CANF,CADF;AA4ED,CAxJD;;AA0JO,MAAM2B,KAAK,GAAG1C,SAAd","sourcesContent":["import * as React from 'react';\nimport {\n FloatingButton,\n ListFooter,\n ListItem,\n SearchBarContainer,\n SelectIcon,\n StyledModal,\n} from './styled';\nimport { FlatList, Modal as RNModal, ModalProps, View } from 'react-native';\nimport { SelectNativeProps } from './Select';\nimport { Text } from '../Text';\nimport {\n Checkbox,\n RadioButton,\n useDebouncedState,\n} from '@tecsinapse/react-core';\nimport { Input } from '../Input';\nimport { Header } from '../Header';\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 onRequestClose,\n selectModalTitle,\n selectModalTitleComponent,\n confirmButtonText,\n ...modalProps\n}: SelectNativeProps<Data, Type> & ModalProps): JSX.Element => {\n const [selectedValues, setSelectedValues] = React.useState<Data[]>([]);\n const [searchArg, setSearchArg] = useDebouncedState<string>('', onSearch);\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 data = 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 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 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 onRequestClose && onRequestClose();\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 <RNModal\n transparent\n hardwareAccelerated\n {...modalProps}\n onRequestClose={onRequestClose}\n >\n <StyledModal>\n <Header\n rightButton={{\n onPress: onRequestClose,\n icon: {\n name: 'close',\n type: 'material-community',\n fontColor: 'light',\n },\n }}\n >\n {headerContent}\n </Header>\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 <FlatList\n data={data}\n keyExtractor={keyExtractor}\n ListFooterComponent={<ListFooter />}\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 <FloatingButton\n variant={'filled'}\n color={'primary'}\n onPress={handleConfirm}\n >\n <Text fontColor={'light'} fontWeight=\"bold\">\n {confirmButtonText}\n </Text>\n </FloatingButton>\n </StyledModal>\n </RNModal>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Select/Modal.tsx"],"names":["Component","options","keyExtractor","labelExtractor","groupKeyExtractor","hideSearchBar","searchBarPlaceholder","focused","type","value","onSelect","onSearch","onRequestClose","selectModalTitle","selectModalTitleComponent","confirmButtonText","loading","modalProps","selectedValues","setSelectedValues","React","useState","searchArg","setSearchArg","useEffect","getData","map","option","index","_checked","find","data","handlePressItem","newArr","found","push","handleConfirm","headerContent","onPress","icon","name","fontColor","text","item","Modal"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AAEA;;AACA;;AAMA;;AACA;;;;;;;;AAMA,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,cAZwD;AAaxDC,EAAAA,gBAbwD;AAcxDC,EAAAA,yBAdwD;AAexDC,EAAAA,iBAfwD;AAgBxDC,EAAAA,OAhBwD;AAiBxD,KAAGC;AAjBqD,CAAxC,KAkB4D;AAC5E,QAAM,CAACC,cAAD,EAAiBC,iBAAjB,IAAsCC,KAAK,CAACC,QAAN,CAAuB,EAAvB,CAA5C;AACA,QAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,kCAA0B,EAA1B,EAA8BZ,QAA9B,CAAlC;AAIAS,EAAAA,KAAK,CAACI,SAAN,CAAgB,MAAM;AACpBL,IAAAA,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,oBAAC,UAAD;AAAM,IAAA,SAAS,EAAE,OAAjB;AAA0B,IAAA,UAAU,EAAC;AAArC,KACGD,iBADH,CANF,CADF,CA5DF,CANF,CADF;AAkFD,CAnKD;;AAqKO,MAAM6B,KAAK,GAAG5C,SAAd","sourcesContent":["import * as React from 'react';\nimport {\n FetchIndicator,\n ModalFooter,\n ListItem,\n SearchBarContainer,\n SelectIcon,\n StyledModal,\n} from './styled';\nimport { FlatList, Modal as RNModal, ModalProps, View } from 'react-native';\nimport { SelectNativeProps } from './Select';\nimport { Text } from '../Text';\nimport {\n Button,\n Checkbox,\n RadioButton,\n useDebouncedState,\n} from '@tecsinapse/react-core';\nimport { Input } from '../Input';\nimport { Header } from '../Header';\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 onRequestClose,\n selectModalTitle,\n selectModalTitleComponent,\n confirmButtonText,\n loading,\n ...modalProps\n}: SelectNativeProps<Data, Type> & ModalProps & LoadingProps): JSX.Element => {\n const [selectedValues, setSelectedValues] = React.useState<Data[]>([]);\n const [searchArg, setSearchArg] = useDebouncedState<string>('', onSearch);\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 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 onRequestClose && onRequestClose();\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 <RNModal\n transparent\n hardwareAccelerated\n {...modalProps}\n onRequestClose={onRequestClose}\n >\n <StyledModal>\n <Header\n rightButton={{\n onPress: onRequestClose,\n icon: {\n name: 'close',\n type: 'material-community',\n fontColor: 'light',\n },\n }}\n >\n {headerContent}\n </Header>\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 {loading && (\n <FetchIndicator animating={true} color={'grey'} size={'large'} />\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 <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 </StyledModal>\n </RNModal>\n );\n};\n\nexport const Modal = Component;\n"],"file":"Modal.js"}
@@ -1,6 +1,6 @@
1
1
  import { InputContainerProps } from '@tecsinapse/react-core';
2
2
  export interface SelectNativeProps<Data, Type extends 'single' | 'multi'> extends Omit<InputContainerProps, 'value' | 'onChange' | 'onChangeText'> {
3
- options: Data[];
3
+ options: ((searchInput?: string) => Promise<Data[]>) | Data[];
4
4
  onSelect: (option: Type extends 'single' ? Data | undefined : Data[]) => never | void;
5
5
  value: Type extends 'single' ? Data | undefined : Data[];
6
6
  type: Type;
@@ -11,7 +11,7 @@ export interface SelectNativeProps<Data, Type extends 'single' | 'multi'> extend
11
11
  placeholder?: string;
12
12
  onFocus?: () => void | never;
13
13
  onBlur?: () => void | never;
14
- onSearch?: (searchArg: string) => void | never;
14
+ onSearch?: ((searchArg: string) => void) | ((searchInput?: string) => Promise<Data[]>) | never;
15
15
  searchBarPlaceholder?: string;
16
16
  confirmButtonText?: string;
17
17
  selectModalTitle?: string;
@@ -52,10 +52,70 @@ function Select({
52
52
  handleFocus
53
53
  } = (0, _reactCore.useInputFocus)(onFocus, onBlur, !disabled);
54
54
  const [modalVisible, setModalVisible] = React.useState(false);
55
+ const [selectOptions, setSelectOptions] = (0, React.useState)([]);
56
+ const [loading, setLoading] = (0, React.useState)(false);
57
+ (0, React.useEffect)(() => {
58
+ if (typeof options !== 'function') {
59
+ setSelectOptions(options);
60
+ }
61
+ }, [options]);
62
+ (0, React.useEffect)(() => {
63
+ if (typeof options === 'function') {
64
+ if (value) {
65
+ if (type === 'single') setSelectOptions([value]);else setSelectOptions([...value]);
66
+ } else setSelectOptions([]);
67
+ }
68
+ }, [value]);
69
+
70
+ const handleLazyFocus = async () => {
71
+ if (typeof options === 'function') {
72
+ setLoading(true);
73
+
74
+ try {
75
+ const result = await options();
76
+
77
+ if (result) {
78
+ if (value && !result.find(v => keyExtractor(value) === keyExtractor(v))) {
79
+ setSelectOptions([value, ...result]);
80
+ } else setSelectOptions(result);
81
+ }
82
+ } catch (e) {} finally {
83
+ setLoading(false);
84
+ }
85
+ }
86
+ };
87
+
88
+ const handleOnSearch = React.useCallback(async searchInput => {
89
+ if (searchInput !== undefined && onSearch) {
90
+ setLoading(true);
91
+
92
+ try {
93
+ const result = await onSearch(searchInput);
94
+
95
+ if (result) {
96
+ if (type === 'single') {
97
+ if (value && !result.find(v => keyExtractor(value) === keyExtractor(v))) {
98
+ setSelectOptions([value, ...result]);
99
+ } else setSelectOptions(result);
100
+ } else {
101
+ if (value.length > 0) {
102
+ const selectedValues = value.filter(v => !result.find(current => keyExtractor(v) === keyExtractor(current))) || [];
103
+ setSelectOptions([...selectedValues, ...result]);
104
+ } else {
105
+ setSelectOptions(result);
106
+ }
107
+ }
108
+ }
109
+ } catch (e) {} finally {
110
+ setLoading(false);
111
+ }
112
+ }
113
+ }, [options, value, keyExtractor]);
55
114
 
56
- const handlePressInput = () => {
115
+ const handlePressInput = async () => {
57
116
  setModalVisible(true);
58
117
  handleFocus();
118
+ await handleLazyFocus();
59
119
  };
60
120
 
61
121
  const handleCloseModal = () => {
@@ -66,11 +126,11 @@ function Select({
66
126
  const getDisplayValue = () => {
67
127
  if (Array.isArray(value)) {
68
128
  if (value.length === 0) return placeholder;else {
69
- return options.reduce((acc, option, index) => value.find(key => keyExtractor(option, index) == keyExtractor(key, index)) ? acc + labelExtractor(option) + ', ' : acc, '').slice(0, -2);
129
+ return selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.reduce((acc, option, index) => value.find(key => keyExtractor(option, index) == keyExtractor(key, index)) ? acc + labelExtractor(option) + ', ' : acc, '').slice(0, -2);
70
130
  }
71
131
  } else {
72
132
  if (value === undefined) return placeholder;
73
- const selectedOption = options.find((option, index) => keyExtractor(option, index) == keyExtractor(value, index));
133
+ const selectedOption = selectOptions === null || selectOptions === void 0 ? void 0 : selectOptions.find((option, index) => keyExtractor(option, index) == keyExtractor(value, index));
74
134
  return selectedOption ? labelExtractor(selectedOption) : placeholder;
75
135
  }
76
136
  };
@@ -94,7 +154,7 @@ function Select({
94
154
  disabled: disabled
95
155
  }, getDisplayValue() || ' ')), React.createElement(_Modal.Modal, {
96
156
  visible: modalVisible,
97
- options: options,
157
+ options: selectOptions || [],
98
158
  focused: modalVisible,
99
159
  keyExtractor: keyExtractor,
100
160
  labelExtractor: labelExtractor,
@@ -107,10 +167,11 @@ function Select({
107
167
  onRequestClose: handleCloseModal,
108
168
  animated: true,
109
169
  animationType: 'slide',
110
- onSearch: onSearch,
170
+ onSearch: handleOnSearch,
111
171
  selectModalTitle: selectModalTitle,
112
172
  selectModalTitleComponent: selectModalTitleComponent,
113
- confirmButtonText: confirmButtonText
173
+ confirmButtonText: confirmButtonText,
174
+ loading: loading
114
175
  }));
115
176
  }
116
177
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/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","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","handlePressInput","handleCloseModal","getDisplayValue","Array","isArray","length","reduce","acc","option","index","find","key","slice","undefined","selectedOption","Text"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;AACA;;AACA;;;;;;;;AA0BA,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,E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cALlB;AAME,IAAA,iBAAiB,EAAEH,iBANrB;AAOE,IAAA,oBAAoB,EAAEW,oBAPxB;AAQE,IAAA,IAAI,EAAET,IARR;AASE,IAAA,QAAQ,EAAED,QATZ;AAUE,IAAA,KAAK,EAAEJ,KAVT;AAWE,IAAA,aAAa,EAAEe,aAXjB;AAYE,IAAA,cAAc,EAAEgB,gBAZlB;AAaE,IAAA,QAAQ,MAbV;AAcE,IAAA,aAAa,EAAE,OAdjB;AAeE,IAAA,QAAQ,EAAEpB,QAfZ;AAgBE,IAAA,gBAAgB,EAAEC,gBAhBpB;AAiBE,IAAA,yBAAyB,EAAEC,yBAjB7B;AAkBE,IAAA,iBAAiB,EAAEG;AAlBrB,IAtBF,CADF;AA6CD;;eAEcjB,M","sourcesContent":["import * as React from 'react';\nimport {\n InputContainerProps,\n useInputFocus,\n HintInputContainer,\n} from '@tecsinapse/react-core';\nimport { Text } from '../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: 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?: (searchArg: string) => void | never;\n searchBarPlaceholder?: string;\n confirmButtonText?: string;\n selectModalTitle?: string;\n selectModalTitleComponent?: JSX.Element;\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 ...rest\n}: SelectNativeProps<Data, Type>): JSX.Element {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n\n const handlePressInput = () => {\n setModalVisible(true);\n handleFocus();\n };\n\n const handleCloseModal = () => {\n setModalVisible(false);\n handleBlur();\n };\n\n const getDisplayValue = () => {\n if (Array.isArray(value)) {\n if (value.length === 0) return placeholder;\n else {\n return options\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 = options.find(\n (option, index) =>\n keyExtractor(option, index) == keyExtractor(value as Data, index)\n );\n return selectedOption ? labelExtractor(selectedOption) : placeholder;\n }\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 <Modal\n visible={modalVisible}\n options={options}\n focused={modalVisible}\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 onRequestClose={handleCloseModal}\n animated\n animationType={'slide'}\n onSearch={onSearch}\n selectModalTitle={selectModalTitle}\n selectModalTitleComponent={selectModalTitleComponent}\n confirmButtonText={confirmButtonText}\n />\n </>\n );\n}\n\nexport default Select;\n"],"file":"Select.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/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","rest","focused","handleBlur","handleFocus","modalVisible","setModalVisible","React","useState","selectOptions","setSelectOptions","loading","setLoading","handleLazyFocus","result","find","v","e","handleOnSearch","useCallback","searchInput","undefined","length","selectedValues","filter","current","handlePressInput","handleCloseModal","getDisplayValue","Array","isArray","reduce","acc","option","index","key","slice","selectedOption","Text"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;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;AAwBrD,KAAGC;AAxBkD,CAAvD,EAyB+C;AAC7C,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,UAAX;AAAuBC,IAAAA;AAAvB,MAAuC,8BAC3CjB,OAD2C,EAE3CC,MAF2C,EAG3C,CAACC,QA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import * as React from 'react';\nimport {\n InputContainerProps,\n useInputFocus,\n HintInputContainer,\n} from '@tecsinapse/react-core';\nimport { Text } from '../Text';\nimport { Modal } from './Modal';\nimport { SelectIcon, StyledSelectionText } from './styled';\nimport { useEffect, useState } from 'react';\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}\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 ...rest\n}: SelectNativeProps<Data, Type>): JSX.Element {\n const { focused, handleBlur, handleFocus } = useInputFocus(\n onFocus,\n onBlur,\n !disabled\n );\n\n const [modalVisible, setModalVisible] = React.useState(false);\n const [selectOptions, setSelectOptions] = useState<Data[]>([]);\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 setLoading(false);\n }\n }\n },\n [options, value, keyExtractor]\n );\n\n const handlePressInput = async () => {\n setModalVisible(true);\n handleFocus();\n await handleLazyFocus();\n };\n\n const handleCloseModal = () => {\n setModalVisible(false);\n handleBlur();\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 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 <Modal\n visible={modalVisible}\n options={selectOptions || []}\n focused={modalVisible}\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 onRequestClose={handleCloseModal}\n animated\n animationType={'slide'}\n onSearch={handleOnSearch}\n selectModalTitle={selectModalTitle}\n selectModalTitleComponent={selectModalTitleComponent}\n confirmButtonText={confirmButtonText}\n loading={loading}\n />\n </>\n );\n}\n\nexport default Select;\n"],"file":"Select.js"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { View, ViewProps } from 'react-native';
2
+ import { ActivityIndicator, View, ViewProps } from 'react-native';
3
3
  export declare const StyledModal: import("@emotion/native").StyledComponent<any, {}, {
4
4
  ref?: import("react").Ref<View> | undefined;
5
5
  }>;
@@ -26,12 +26,15 @@ export declare const SearchBar: import("@emotion/native").StyledComponent<any, {
26
26
  export declare const ListItem: import("@emotion/native").StyledComponent<any, {}, {
27
27
  ref?: import("react").Ref<any> | undefined;
28
28
  }>;
29
- export declare const ListFooter: import("@emotion/native").StyledComponent<any, {}, {
29
+ export declare const ModalFooter: import("@emotion/native").StyledComponent<any, {}, {
30
30
  ref?: import("react").Ref<View> | undefined;
31
31
  }>;
32
- export declare const FloatingButton: import("@emotion/native").StyledComponent<any, {}, {
33
- ref?: import("react").Ref<any> | undefined;
34
- }>;
35
32
  export declare const SelectIcon: import("@emotion/native").StyledComponent<any, {}, {
36
33
  ref?: import("react").Ref<any> | undefined;
37
34
  }>;
35
+ export declare const FetchIndicator: import("@emotion/native").StyledComponent<import("react-native").ActivityIndicatorProps & {
36
+ theme?: import("@emotion/react").Theme | undefined;
37
+ as?: import("react").ElementType<any> | undefined;
38
+ }, {}, {
39
+ ref?: import("react").Ref<ActivityIndicator> | undefined;
40
+ }>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SelectIcon = exports.FloatingButton = exports.ListFooter = 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.StyledModal = void 0;
7
7
 
8
8
  var _native = _interopRequireWildcard(require("@emotion/native"));
9
9
 
@@ -68,6 +68,7 @@ const SearchBarContainer = (0, _native.default)(_reactNative.View)`
68
68
  padding: ${({
69
69
  theme
70
70
  }) => theme.spacing.deca};
71
+ position: relative;
71
72
  `;
72
73
  exports.SearchBarContainer = SearchBarContainer;
73
74
  const SearchBar = (0, _native.default)(_Input.Input)`
@@ -89,27 +90,18 @@ const ListItem = (0, _native.default)(_reactCore.PressableSurface)`
89
90
  }) => theme.spacing.deca};
90
91
  `;
91
92
  exports.ListItem = ListItem;
92
- const ListFooter = _native.default.View`
93
+ const ModalFooter = (0, _native.default)(_reactNative.View)`
93
94
  width: 100%;
94
- min-height: 44px;
95
- margin-vertical: ${({
96
- theme
97
- }) => theme.spacing.deca};
98
- `;
99
- exports.ListFooter = ListFooter;
100
- const FloatingButton = (0, _native.default)(_reactCore.Button)`
101
- position: absolute;
102
- bottom: ${({
103
- theme
104
- }) => theme.spacing.deca};
105
- left: ${({
95
+ height: auto;
96
+ bottom: 0;
97
+ background-color: ${({
106
98
  theme
107
- }) => theme.spacing.deca};
108
- right: ${({
99
+ }) => theme.miscellaneous.bodyColor};
100
+ padding: ${({
109
101
  theme
110
102
  }) => theme.spacing.deca};
111
103
  `;
112
- exports.FloatingButton = FloatingButton;
104
+ exports.ModalFooter = ModalFooter;
113
105
  const SelectIcon = (0, _native.default)(_reactCore.Icon)`
114
106
  padding: ${({
115
107
  theme
@@ -119,4 +111,8 @@ const SelectIcon = (0, _native.default)(_reactCore.Icon)`
119
111
  }) => theme.color.secondary.medium};
120
112
  `;
121
113
  exports.SelectIcon = SelectIcon;
114
+ const FetchIndicator = (0, _native.default)(_reactNative.ActivityIndicator)`
115
+ align-self: center;
116
+ `;
117
+ exports.FetchIndicator = FetchIndicator;
122
118
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/atoms/Select/styled.ts"],"names":["StyledModal","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","ListFooter","styled","FloatingButton","SelectIcon","Icon","centi","medium"],"mappings":";;;;;;;AAAA;;AACA;;AAUA;;AACA;;AACA;;;;;;AAEO,MAAMA,WAAW,GAAG,qBAAOC,iBAAP,CAA+C;AAC1E;AACA,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,aAAN,CAAoBC,SAAU;AACnE;AACA;AACA,CALO;;AAOA,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,C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D;AAChF;AACA,YAAY,CAAC;AAAEhB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC9C,UAAU,CAAC;AAAEd,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC5C,WAAW,CAAC;AAAEd,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC7C,CALO;;AAOA,MAAMc,UAAU,GAAG,qBAAOC,eAAP,CAAkC;AAC5D,aAAa,CAAC;AAAE7B,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAciB,KAAM;AAChD,WAAW,CAAC;AAAE9B,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACqB,KAAN,CAAYC,SAAZ,CAAsBS,MAAO;AACvD,CAHO","sourcesContent":["import styled, { css } from '@emotion/native';\nimport {\n Button,\n ButtonProps,\n disabledInputStyles,\n Icon,\n InputContainerProps,\n PressableSurface,\n PressableSurfaceProps,\n StyleProps,\n} from '@tecsinapse/react-core';\nimport { ModalProps, View, ViewProps } from 'react-native';\nimport { Input, InputNativeProps } from '../Input';\nimport { Text } from '../Text';\n\nexport const StyledModal = styled(View)<ModalProps & Partial<StyleProps>>`\n position: relative;\n background-color: ${({ theme }) => theme.miscellaneous.bodyColor};\n height: 100%;\n width: 100%;\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: 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`;\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: 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 ListFooter = styled.View<Partial<StyleProps>>`\n width: 100%;\n min-height: 44px;\n margin-vertical: ${({ theme }) => theme.spacing.deca};\n`;\n\nexport const FloatingButton = styled(Button)<ButtonProps & Partial<StyleProps>>`\n position: absolute;\n bottom: ${({ theme }) => theme.spacing.deca};\n left: ${({ theme }) => theme.spacing.deca};\n right: ${({ 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"],"file":"styled.js"}
1
+ {"version":3,"sources":["../../../../src/components/atoms/Select/styled.ts"],"names":["StyledModal","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;;AAUA;;AACA;;AACA;;;;;;AAEO,MAAMA,WAAW,GAAG,qBAAOC,iBAAP,CAA+C;AAC1E;AACA,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,aAAN,CAAo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,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC1D,CAPO;;AASA,MAAMW,WAAW,GAAG,qBAAO1B,iBAAP,CAAkC;AAC7D;AACA;AACA;AACA,sBAAsB,CAAC;AAAEC,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACC,aAAN,CAAoBC,SAAU;AACnE,aAAa,CAAC;AAAEF,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcC,IAAK;AAC/C,CANO;;AAQA,MAAMY,UAAU,GAAG,qBAAOC,eAAP,CAAkC;AAC5D,aAAa,CAAC;AAAE3B,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAce,KAAM;AAChD,WAAW,CAAC;AAAE5B,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACqB,KAAN,CAAYC,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 StyleProps,\n} from '@tecsinapse/react-core';\nimport { ActivityIndicator, ModalProps, View, ViewProps } from 'react-native';\nimport { Input, InputNativeProps } from '../Input';\nimport { Text } from '../Text';\n\nexport const StyledModal = styled(View)<ModalProps & Partial<StyleProps>>`\n position: relative;\n background-color: ${({ theme }) => theme.miscellaneous.bodyColor};\n height: 100%;\n width: 100%;\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: 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: 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"}
@@ -1 +1,4 @@
1
- export declare const Calendar: <T extends any>(props: any) => JSX.Element;
1
+ export declare const Calendar: <T extends any>({ locale, ...rest }: {
2
+ [x: string]: any;
3
+ locale: any;
4
+ }) => JSX.Element;
@@ -11,13 +11,19 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _Text = require("../../atoms/Text");
13
13
 
14
+ var _date = require("../../../utils/date");
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
19
 
18
- const Calendar = props => {
19
- return _react.default.createElement(_reactCore.Calendar, _extends({}, props, {
20
- TextComponent: _Text.Text
20
+ const Calendar = ({
21
+ locale,
22
+ ...rest
23
+ }) => {
24
+ return _react.default.createElement(_reactCore.Calendar, _extends({}, rest, {
25
+ TextComponent: _Text.Text,
26
+ locale: locale ?? (0, _date.getLocale)()
21
27
  }));
22
28
  };
23
29
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/Calendar/Calendar.tsx"],"names":["Calendar","props","Text"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;;;;;AAEO,MAAMA,QAAQ,GACnBC,KADsB,IAEN;AAChB,SAAO,6BAAC,mBAAD,eAAkBA,KAAlB;AAAyB,IAAA,aAAa,EAAEC;AAAxC,KAAP;AACD,CAJM","sourcesContent":["import {\n Calendar as CalendarCore,\n CalendarProps,\n SelectionType,\n} from '@tecsinapse/react-core';\nimport React from 'react';\nimport { Text } from '../../atoms/Text';\n\nexport const Calendar = <T extends SelectionType>(\n props: CalendarProps<T>\n): JSX.Element => {\n return <CalendarCore {...props} TextComponent={Text} />;\n};\n"],"file":"Calendar.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/Calendar/Calendar.tsx"],"names":["Calendar","locale","rest","Text"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AACA;;;;;;AAEO,MAAMA,QAAQ,GAAG,CAA0B;AAChDC,EAAAA,MADgD;AAEhD,KAAGC;AAF6C,CAA1B,KAGL;AACjB,SACE,6BAAC,mBAAD,eACMA,IADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,MAAM,EAAEF,MAAM,IAAI;AAHpB,KADF;AAOD,CAXM","sourcesContent":["import {\n Calendar as CalendarCore,\n CalendarProps,\n SelectionType,\n} from '@tecsinapse/react-core';\nimport React from 'react';\nimport { Text } from '../../atoms/Text';\nimport { getLocale } from '../../../utils/date';\n\nexport const Calendar = <T extends SelectionType>({\n locale,\n ...rest\n}): JSX.Element => {\n return (\n <CalendarCore\n {...rest}\n TextComponent={Text}\n locale={locale ?? getLocale()}\n />\n );\n};\n"],"file":"Calendar.js"}
@@ -1 +1,4 @@
1
- export declare const DatePicker: <T extends any>(props: any) => JSX.Element;
1
+ export declare const DatePicker: <T extends any>({ locale, ...rest }: {
2
+ [x: string]: any;
3
+ locale: any;
4
+ }) => JSX.Element;
@@ -13,15 +13,21 @@ var _Text = require("../../atoms/Text");
13
13
 
14
14
  var _Calendar = require("../Calendar");
15
15
 
16
+ var _date = require("../../../utils/date");
17
+
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
19
 
18
20
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
21
 
20
- const DatePicker = props => {
21
- return _react.default.createElement(_reactCore.DatePicker, _extends({}, props, {
22
+ const DatePicker = ({
23
+ locale,
24
+ ...rest
25
+ }) => {
26
+ return _react.default.createElement(_reactCore.DatePicker, _extends({}, rest, {
22
27
  TextComponent: _Text.Text,
23
28
  CalendarComponent: _Calendar.Calendar,
24
- animationType: "slide"
29
+ animationType: "slide",
30
+ locale: locale ?? (0, _date.getLocale)()
25
31
  }));
26
32
  };
27
33