@tecsinapse/react-native-kit 1.10.5 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/components/atoms/Select/Modal.d.ts +5 -1
  3. package/dist/components/atoms/Select/Modal.js +19 -8
  4. package/dist/components/atoms/Select/Modal.js.map +1 -1
  5. package/dist/components/atoms/Select/Select.d.ts +2 -2
  6. package/dist/components/atoms/Select/Select.js +67 -6
  7. package/dist/components/atoms/Select/Select.js.map +1 -1
  8. package/dist/components/atoms/Select/styled.d.ts +8 -5
  9. package/dist/components/atoms/Select/styled.js +13 -17
  10. package/dist/components/atoms/Select/styled.js.map +1 -1
  11. package/dist/components/molecules/Calendar/Calendar.d.ts +4 -1
  12. package/dist/components/molecules/Calendar/Calendar.js +9 -3
  13. package/dist/components/molecules/Calendar/Calendar.js.map +1 -1
  14. package/dist/components/molecules/DatePicker/DatePicker.d.ts +4 -1
  15. package/dist/components/molecules/DatePicker/DatePicker.js +9 -3
  16. package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
  17. package/dist/components/molecules/DateTimePicker/DateTimePicker.js +9 -3
  18. package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
  19. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +9 -3
  20. package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
  21. package/dist/utils/date.d.ts +1 -0
  22. package/dist/utils/date.js +30 -0
  23. package/dist/utils/date.js.map +1 -0
  24. package/package.json +3 -3
  25. package/src/components/atoms/Select/Modal.tsx +39 -23
  26. package/src/components/atoms/Select/Select.tsx +96 -8
  27. package/src/components/atoms/Select/styled.ts +11 -11
  28. package/src/components/molecules/Calendar/Calendar.tsx +12 -4
  29. package/src/components/molecules/DatePicker/DatePicker.tsx +7 -4
  30. package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +7 -2
  31. package/src/components/molecules/DateTimeSelector/DateTimeSelector.tsx +9 -2
  32. 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.12.0](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.11.2...@tecsinapse/react-native-kit@1.12.0) (2021-12-21)
7
+
8
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.11.2](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-native-kit@1.11.1...@tecsinapse/react-native-kit@1.11.2) (2021-12-20)
15
+
16
+ **Note:** Version bump only for package @tecsinapse/react-native-kit
17
+
18
+
19
+
20
+
21
+
22
+ ## [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)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * handleLazySelect ([1102499](https://github.com/tecsinapse/design-system/commit/11024996571866d542d4d112baf7b183b8b146e1))
28
+
29
+
30
+
31
+
32
+
33
+ # [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)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * [163127] Modais de picker do DS estão em inglês ([a95b0b2](https://github.com/tecsinapse/design-system/commit/a95b0b283f3535af20a23ac6a9a5e5633127d5b0))
39
+
40
+
41
+
42
+
43
+
6
44
  ## [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)
7
45
 
8
46
  **Note:** Version bump only for package @tecsinapse/react-native-kit
@@ -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,EAAA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EAAEa,IAAI,CAACb,QAAL,GAAgB,MAAhB,GAAyB;AAA3C,OACGzB,cAAc,CAACsC,IAAD,CADjB,CALF,CAZJ,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,kCAA0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IAAA,KAAK,EAAE,SAFT;AAGE,IAAA,OAAO,EAAEP,aAHX;AAIE,IAAA,QAAQ,EAAEpB;AAJZ,KAME,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;AAK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FX;AAGE,IAAA,OAAO,EAAEyB,YAHX;AAIE,IAAA,YAAY,EAAExB,YAJhB;AAKE,IAAA,cAAc,EAAEI,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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,EAAEG,iBAlBrB;AAmBE,IAAA,OAAO,EAAEgB;AAnBX,IAtBF,CADF;AA8CD;;eAEcjC,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';\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,UA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eA,KAAK,CAACa,OAAN,CAAcC,IAAK;AACvD,CAJO;;AAMA,MAAMa,cAAc,GAAG,qBAAOX,iBAAP,CAAkD;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,iBA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;AAAEvB,EAAAA;AAAF,CAAD,KAAeA,KAAK,CAACa,OAAN,CAAcW,IAAK;AACxD,wBAAwB,CAAC;AAAExB,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
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DatePicker/DatePicker.tsx"],"names":["DatePicker","props","Text","Calendar"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AACA;;;;;;AAEO,MAAMA,UAAU,GACrBC,KADwB,IAER;AAChB,SACE,6BAAC,qBAAD,eACMA,KADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,iBAAiB,EAAEC,kBAHrB;AAIE,IAAA,aAAa,EAAC;AAJhB,KADF;AAQD,CAXM","sourcesContent":["import {\n DatePicker as DatePickerCore,\n DatePickerProps,\n SelectionType,\n} from '@tecsinapse/react-core';\nimport React from 'react';\nimport { Text } from '../../atoms/Text';\nimport { Calendar } from '../Calendar';\n\nexport const DatePicker = <T extends SelectionType>(\n props: DatePickerProps<T>\n): JSX.Element => {\n return (\n <DatePickerCore\n {...props}\n TextComponent={Text}\n CalendarComponent={Calendar}\n animationType=\"slide\"\n />\n );\n};\n"],"file":"DatePicker.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DatePicker/DatePicker.tsx"],"names":["DatePicker","locale","rest","Text","Calendar"],"mappings":";;;;;;;AAAA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAEO,MAAMA,UAAU,GAAG,CAA0B;AAClDC,EAAAA,MADkD;AAElD,KAAGC;AAF+C,CAA1B,KAGP;AACjB,SACE,6BAAC,qBAAD,eACMA,IADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,iBAAiB,EAAEC,kBAHrB;AAIE,IAAA,aAAa,EAAC,OAJhB;AAKE,IAAA,MAAM,EAAEH,MAAM,IAAI;AALpB,KADF;AASD,CAbM","sourcesContent":["import {\n DatePicker as DatePickerCore,\n DatePickerProps,\n SelectionType,\n} from '@tecsinapse/react-core';\nimport React from 'react';\nimport { Text } from '../../atoms/Text';\nimport { Calendar } from '../Calendar';\nimport { getLocale } from '../../../utils/date';\n\nexport const DatePicker = <T extends SelectionType>({\n locale,\n ...rest\n}): JSX.Element => {\n return (\n <DatePickerCore\n {...rest}\n TextComponent={Text}\n CalendarComponent={Calendar}\n animationType=\"slide\"\n locale={locale ?? getLocale()}\n />\n );\n};\n"],"file":"DatePicker.js"}
@@ -13,15 +13,21 @@ var _Text = require("../../atoms/Text");
13
13
 
14
14
  var _DateTimeSelector = require("../DateTimeSelector");
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 DateTimePicker = props => {
21
- return _react.default.createElement(_reactCore.DateTimePicker, _extends({}, props, {
22
+ const DateTimePicker = ({
23
+ locale,
24
+ ...rest
25
+ }) => {
26
+ return _react.default.createElement(_reactCore.DateTimePicker, _extends({}, rest, {
22
27
  TextComponent: _Text.Text,
23
28
  DateTimeSelectorComponent: _DateTimeSelector.DateTimeSelector,
24
- animationType: "slide"
29
+ animationType: "slide",
30
+ locale: locale ?? (0, _date.getLocale)()
25
31
  }));
26
32
  };
27
33
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/molecules/DateTimePicker/DateTimePicker.tsx"],"names":["DateTimePicker","props","Text","DateTimeSelector"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;;;;;AAEO,MAAMA,cAAuC,GAAGC,KAAK,IAAI;AAC9D,SACE,6BAAC,yBAAD,eACMA,KADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,yBAAyB,EAAEC,kCAH7B;AAIE,IAAA,aAAa,EAAC;AAJhB,KADF;AAQD,CATM","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';\n\nexport const DateTimePicker: FC<DateTimePickerProps> = props => {\n return (\n <DateTimePickerCore\n {...props}\n TextComponent={Text}\n DateTimeSelectorComponent={DateTimeSelector}\n animationType=\"slide\"\n />\n );\n};\n"],"file":"DateTimePicker.js"}
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"}
@@ -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 DateTimeSelector = props => {
19
- return _react.default.createElement(_reactCore.DateTimeSelector, _extends({}, props, {
20
- TextComponent: _Text.Text
20
+ const DateTimeSelector = ({
21
+ locale,
22
+ ...rest
23
+ }) => {
24
+ return _react.default.createElement(_reactCore.DateTimeSelector, _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/DateTimeSelector/DateTimeSelector.tsx"],"names":["DateTimeSelector","props","Text"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;;;;;AAEO,MAAMA,gBAA2C,GAAGC,KAAK,IAAI;AAClE,SAAO,6BAAC,2BAAD,eAA0BA,KAA1B;AAAiC,IAAA,aAAa,EAAEC;AAAhD,KAAP;AACD,CAFM","sourcesContent":["import {\n DateTimeSelector as DateTimeSelectorCore,\n DateTimeSelectorProps,\n} from '@tecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { Text } from '../../atoms/Text';\n\nexport const DateTimeSelector: FC<DateTimeSelectorProps> = props => {\n return <DateTimeSelectorCore {...props} TextComponent={Text} />;\n};\n"],"file":"DateTimeSelector.js"}
1
+ {"version":3,"sources":["../../../../src/components/molecules/DateTimeSelector/DateTimeSelector.tsx"],"names":["DateTimeSelector","locale","rest","Text"],"mappings":";;;;;;;AAAA;;AAIA;;AACA;;AACA;;;;;;AAEO,MAAMA,gBAA2C,GAAG,CAAC;AAACC,EAAAA,MAAD;AAAS,KAAGC;AAAZ,CAAD,KAAuB;AAChF,SACE,6BAAC,2BAAD,eACMA,IADN;AAEE,IAAA,aAAa,EAAEC,UAFjB;AAGE,IAAA,MAAM,EAAEF,MAAM,IAAI;AAHpB,KADF;AAOD,CARM","sourcesContent":["import {\n DateTimeSelector as DateTimeSelectorCore,\n DateTimeSelectorProps,\n} from '@tecsinapse/react-core';\nimport React, { FC } from 'react';\nimport { Text } from '../../atoms/Text';\nimport { getLocale } from '../../../utils/date';\n\nexport const DateTimeSelector: FC<DateTimeSelectorProps> = ({locale, ...rest}) => {\n return (\n <DateTimeSelectorCore\n {...rest}\n TextComponent={Text}\n locale={locale ?? getLocale()}\n />\n );\n};\n"],"file":"DateTimeSelector.js"}
@@ -0,0 +1 @@
1
+ export declare const getLocale: () => Locale;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getLocale = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var dateFnsLocales = _interopRequireWildcard(require("date-fns/locale"));
11
+
12
+ 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); }
13
+
14
+ 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; }
15
+
16
+ const getLocale = () => {
17
+ let locale;
18
+
19
+ if (_reactNative.Platform.OS === 'ios') {
20
+ locale = _reactNative.NativeModules.SettingsManager.settings.AppleLocale || _reactNative.NativeModules.SettingsManager.settings.AppleLanguages[0];
21
+ } else {
22
+ locale = _reactNative.NativeModules.I18nManager.localeIdentifier;
23
+ }
24
+
25
+ const code = locale.replace('_', '');
26
+ return dateFnsLocales[code];
27
+ };
28
+
29
+ exports.getLocale = getLocale;
30
+ //# sourceMappingURL=date.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/date.ts"],"names":["getLocale","locale","Platform","OS","NativeModules","SettingsManager","settings","AppleLocale","AppleLanguages","I18nManager","localeIdentifier","code","replace","dateFnsLocales"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,SAAS,GAAG,MAAc;AACrC,MAAIC,MAAJ;;AACA,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBF,IAAAA,MAAM,GACJG,2BAAcC,eAAd,CAA8BC,QAA9B,CAAuCC,WAAvC,IACAH,2BAAcC,eAAd,CAA8BC,QAA9B,CAAuCE,cAAvC,CAAsD,CAAtD,CAFF;AAGD,GAJD,MAIO;AACLP,IAAAA,MAAM,GAAGG,2BAAcK,WAAd,CAA0BC,gBAAnC;AACD;;AAED,QAAMC,IAAI,GAAGV,MAAM,CAACW,OAAP,CAAe,GAAf,EAAoB,EAApB,CAAb;AAEA,SAAOC,cAAc,CAACF,IAAD,CAArB;AACD,CAbM","sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport * as dateFnsLocales from 'date-fns/locale';\n\nexport const getLocale = (): Locale => {\n let locale: string;\n if (Platform.OS === 'ios') {\n locale =\n NativeModules.SettingsManager.settings.AppleLocale ||\n NativeModules.SettingsManager.settings.AppleLanguages[0];\n } else {\n locale = NativeModules.I18nManager.localeIdentifier;\n }\n\n const code = locale.replace('_', '');\n\n return dateFnsLocales[code];\n};\n"],"file":"date.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.10.5",
4
+ "version": "1.12.0",
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.10.4"
16
+ "@tecsinapse/react-core": "^1.12.0"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
@@ -29,5 +29,5 @@
29
29
  "react-native": ">=0.64.0",
30
30
  "react-native-vector-icons": ">=8.1.0"
31
31
  },
32
- "gitHead": "a0f4ed0567683273692e4336ca4f05a9ee98a881"
32
+ "gitHead": "33520278e4683586a9a4338cc3e1aea57773bdfd"
33
33
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import {
3
- FloatingButton,
4
- ListFooter,
3
+ FetchIndicator,
4
+ ModalFooter,
5
5
  ListItem,
6
6
  SearchBarContainer,
7
7
  SelectIcon,
@@ -11,6 +11,7 @@ import { FlatList, Modal as RNModal, ModalProps, View } from 'react-native';
11
11
  import { SelectNativeProps } from './Select';
12
12
  import { Text } from '../Text';
13
13
  import {
14
+ Button,
14
15
  Checkbox,
15
16
  RadioButton,
16
17
  useDebouncedState,
@@ -18,6 +19,10 @@ import {
18
19
  import { Input } from '../Input';
19
20
  import { Header } from '../Header';
20
21
 
22
+ interface LoadingProps {
23
+ loading?: boolean;
24
+ }
25
+
21
26
  const Component = <Data, Type extends 'single' | 'multi'>({
22
27
  options,
23
28
  keyExtractor,
@@ -34,8 +39,9 @@ const Component = <Data, Type extends 'single' | 'multi'>({
34
39
  selectModalTitle,
35
40
  selectModalTitleComponent,
36
41
  confirmButtonText,
42
+ loading,
37
43
  ...modalProps
38
- }: SelectNativeProps<Data, Type> & ModalProps): JSX.Element => {
44
+ }: SelectNativeProps<Data, Type> & ModalProps & LoadingProps): JSX.Element => {
39
45
  const [selectedValues, setSelectedValues] = React.useState<Data[]>([]);
40
46
  const [searchArg, setSearchArg] = useDebouncedState<string>('', onSearch);
41
47
 
@@ -47,16 +53,20 @@ const Component = <Data, Type extends 'single' | 'multi'>({
47
53
  );
48
54
  }, [value, focused, setSelectedValues]);
49
55
 
50
- const data = options.map((option, index) => ({
51
- ...option,
52
- _checked:
53
- type === 'multi'
54
- ? !!selectedValues.find(
55
- value => keyExtractor(option, index) == keyExtractor(value, index)
56
- )
57
- : keyExtractor((selectedValues[0] || {}) as Data, index) ==
58
- keyExtractor(option, index),
59
- }));
56
+ const getData = (options: Data[]) => {
57
+ return options?.map((option, index) => ({
58
+ ...option,
59
+ _checked:
60
+ type === 'multi'
61
+ ? !!selectedValues.find(
62
+ value => keyExtractor(option, index) == keyExtractor(value, index)
63
+ )
64
+ : keyExtractor((selectedValues[0] || {}) as Data, index) ==
65
+ keyExtractor(option, index),
66
+ }));
67
+ };
68
+
69
+ const data = typeof options !== 'function' ? getData(options) : [];
60
70
 
61
71
  const handlePressItem = (option: Data) => () => {
62
72
  setSelectedValues(selectedValues => {
@@ -126,10 +136,13 @@ const Component = <Data, Type extends 'single' | 'multi'>({
126
136
  />
127
137
  </SearchBarContainer>
128
138
  )}
139
+ {loading && (
140
+ <FetchIndicator animating={true} color={'grey'} size={'large'} />
141
+ )}
129
142
  <FlatList
130
143
  data={data}
131
144
  keyExtractor={keyExtractor}
132
- ListFooterComponent={<ListFooter />}
145
+ fadingEdgeLength={200}
133
146
  renderItem={({ item }) => (
134
147
  <ListItem onPress={handlePressItem(item)}>
135
148
  <View pointerEvents={'none'}>
@@ -158,15 +171,18 @@ const Component = <Data, Type extends 'single' | 'multi'>({
158
171
  </ListItem>
159
172
  )}
160
173
  />
161
- <FloatingButton
162
- variant={'filled'}
163
- color={'primary'}
164
- onPress={handleConfirm}
165
- >
166
- <Text fontColor={'light'} fontWeight="bold">
167
- {confirmButtonText}
168
- </Text>
169
- </FloatingButton>
174
+ <ModalFooter>
175
+ <Button
176
+ variant={'filled'}
177
+ color={'primary'}
178
+ onPress={handleConfirm}
179
+ disabled={loading}
180
+ >
181
+ <Text fontColor={'light'} fontWeight="bold">
182
+ {confirmButtonText}
183
+ </Text>
184
+ </Button>
185
+ </ModalFooter>
170
186
  </StyledModal>
171
187
  </RNModal>
172
188
  );
@@ -7,10 +7,11 @@ import {
7
7
  import { Text } from '../Text';
8
8
  import { Modal } from './Modal';
9
9
  import { SelectIcon, StyledSelectionText } from './styled';
10
+ import { useEffect, useState } from 'react';
10
11
 
11
12
  export interface SelectNativeProps<Data, Type extends 'single' | 'multi'>
12
13
  extends Omit<InputContainerProps, 'value' | 'onChange' | 'onChangeText'> {
13
- options: Data[];
14
+ options: ((searchInput?: string) => Promise<Data[]>) | Data[];
14
15
  onSelect: (
15
16
  option: Type extends 'single' ? Data | undefined : Data[]
16
17
  ) => never | void;
@@ -25,7 +26,10 @@ export interface SelectNativeProps<Data, Type extends 'single' | 'multi'>
25
26
  placeholder?: string;
26
27
  onFocus?: () => void | never;
27
28
  onBlur?: () => void | never;
28
- onSearch?: (searchArg: string) => void | never;
29
+ onSearch?:
30
+ | ((searchArg: string) => void)
31
+ | ((searchInput?: string) => Promise<Data[]>)
32
+ | never;
29
33
  searchBarPlaceholder?: string;
30
34
  confirmButtonText?: string;
31
35
  selectModalTitle?: string;
@@ -65,10 +69,93 @@ function Select<Data, Type extends 'single' | 'multi'>({
65
69
  );
66
70
 
67
71
  const [modalVisible, setModalVisible] = React.useState(false);
72
+ const [selectOptions, setSelectOptions] = useState<Data[]>([]);
68
73
 
69
- const handlePressInput = () => {
74
+ // TODO: Add Skeleton to modal height when loading is true
75
+ const [loading, setLoading] = useState<boolean>(false);
76
+
77
+ useEffect(() => {
78
+ if (typeof options !== 'function') {
79
+ setSelectOptions(options);
80
+ }
81
+ }, [options]);
82
+
83
+ useEffect(() => {
84
+ if (typeof options === 'function') {
85
+ if (value) {
86
+ if (type === 'single') setSelectOptions([value as Data]);
87
+ else setSelectOptions([...(value as Data[])]);
88
+ } else setSelectOptions([]);
89
+ }
90
+ }, [value]);
91
+
92
+ const handleLazyFocus = async () => {
93
+ if (typeof options === 'function') {
94
+ setLoading(true);
95
+ try {
96
+ const result = await options();
97
+ if (result) {
98
+ if (
99
+ value &&
100
+ !result.find(v => keyExtractor(value as Data) === keyExtractor(v))
101
+ ) {
102
+ setSelectOptions([value as Data, ...result]);
103
+ } else setSelectOptions(result);
104
+ }
105
+ } catch (e) {
106
+ // TODO: Catch error
107
+ } finally {
108
+ setLoading(false);
109
+ }
110
+ }
111
+ };
112
+
113
+ const handleOnSearch = React.useCallback(
114
+ async (searchInput: string | undefined) => {
115
+ if (searchInput !== undefined && onSearch) {
116
+ setLoading(true);
117
+ try {
118
+ const result = await onSearch(searchInput);
119
+ if (result) {
120
+ if (type === 'single') {
121
+ if (
122
+ value &&
123
+ !result.find(
124
+ v => keyExtractor(value as Data) === keyExtractor(v)
125
+ )
126
+ ) {
127
+ setSelectOptions([value as Data, ...result]);
128
+ } else setSelectOptions(result);
129
+ } else {
130
+ if ((value as Data[]).length > 0) {
131
+ const selectedValues =
132
+ (value as Data[]).filter(
133
+ v =>
134
+ !result.find(
135
+ current =>
136
+ keyExtractor(v as Data) === keyExtractor(current)
137
+ )
138
+ ) || [];
139
+ setSelectOptions([...selectedValues, ...result]);
140
+ } else {
141
+ setSelectOptions(result);
142
+ }
143
+ }
144
+ }
145
+ } catch (e) {
146
+ // TODO: Catch error
147
+ } finally {
148
+ setLoading(false);
149
+ }
150
+ }
151
+ },
152
+ [options, value, keyExtractor]
153
+ );
154
+
155
+ const handlePressInput = async () => {
70
156
  setModalVisible(true);
71
157
  handleFocus();
158
+ await handleLazyFocus();
72
159
  };
73
160
 
74
161
  const handleCloseModal = () => {
@@ -80,8 +167,8 @@ function Select<Data, Type extends 'single' | 'multi'>({
80
167
  if (Array.isArray(value)) {
81
168
  if (value.length === 0) return placeholder;
82
169
  else {
83
- return options
84
- .reduce(
170
+ return selectOptions
171
+ ?.reduce(
85
172
  (acc, option, index) =>
86
173
  value.find(
87
174
  key => keyExtractor(option, index) == keyExtractor(key, index)
@@ -94,7 +181,7 @@ function Select<Data, Type extends 'single' | 'multi'>({
94
181
  }
95
182
  } else {
96
183
  if (value === undefined) return placeholder;
97
- const selectedOption = options.find(
184
+ const selectedOption = selectOptions?.find(
98
185
  (option, index) =>
99
186
  keyExtractor(option, index) == keyExtractor(value as Data, index)
100
187
  );
@@ -127,7 +214,7 @@ function Select<Data, Type extends 'single' | 'multi'>({
127
214
  </HintInputContainer>
128
215
  <Modal
129
216
  visible={modalVisible}
130
- options={options}
217
+ options={selectOptions || []}
131
218
  focused={modalVisible}
132
219
  keyExtractor={keyExtractor}
133
220
  labelExtractor={labelExtractor}
@@ -140,10 +227,11 @@ function Select<Data, Type extends 'single' | 'multi'>({
140
227
  onRequestClose={handleCloseModal}
141
228
  animated
142
229
  animationType={'slide'}
143
- onSearch={onSearch}
230
+ onSearch={handleOnSearch}
144
231
  selectModalTitle={selectModalTitle}
145
232
  selectModalTitleComponent={selectModalTitleComponent}
146
233
  confirmButtonText={confirmButtonText}
234
+ loading={loading}
147
235
  />
148
236
  </>
149
237
  );
@@ -9,7 +9,7 @@ import {
9
9
  PressableSurfaceProps,
10
10
  StyleProps,
11
11
  } from '@tecsinapse/react-core';
12
- import { ModalProps, View, ViewProps } from 'react-native';
12
+ import { ActivityIndicator, ModalProps, View, ViewProps } from 'react-native';
13
13
  import { Input, InputNativeProps } from '../Input';
14
14
  import { Text } from '../Text';
15
15
 
@@ -56,6 +56,7 @@ export const CloseButton = styled(Button)<ButtonProps & Partial<StyleProps>>`
56
56
 
57
57
  export const SearchBarContainer = styled(View)<ViewProps & Partial<StyleProps>>`
58
58
  padding: ${({ theme }) => theme.spacing.deca};
59
+ position: relative;
59
60
  `;
60
61
 
61
62
  export const SearchBar = styled(Input)<InputNativeProps & Partial<StyleProps>>`
@@ -71,20 +72,19 @@ export const ListItem = styled(PressableSurface)<
71
72
  padding-horizontal: ${({ theme }) => theme.spacing.deca};
72
73
  `;
73
74
 
74
- export const ListFooter = styled.View<Partial<StyleProps>>`
75
+ export const ModalFooter = styled(View)<Partial<StyleProps>>`
75
76
  width: 100%;
76
- min-height: 44px;
77
- margin-vertical: ${({ theme }) => theme.spacing.deca};
78
- `;
79
-
80
- export const FloatingButton = styled(Button)<ButtonProps & Partial<StyleProps>>`
81
- position: absolute;
82
- bottom: ${({ theme }) => theme.spacing.deca};
83
- left: ${({ theme }) => theme.spacing.deca};
84
- right: ${({ theme }) => theme.spacing.deca};
77
+ height: auto;
78
+ bottom: 0;
79
+ background-color: ${({ theme }) => theme.miscellaneous.bodyColor};
80
+ padding: ${({ theme }) => theme.spacing.deca};
85
81
  `;
86
82
 
87
83
  export const SelectIcon = styled(Icon)<Partial<StyleProps>>`
88
84
  padding: ${({ theme }) => theme.spacing.centi};
89
85
  color: ${({ theme }) => theme.color.secondary.medium};
90
86
  `;
87
+
88
+ export const FetchIndicator = styled(ActivityIndicator)`
89
+ align-self: center;
90
+ `;
@@ -5,9 +5,17 @@ import {
5
5
  } from '@tecsinapse/react-core';
6
6
  import React from 'react';
7
7
  import { Text } from '../../atoms/Text';
8
+ import { getLocale } from '../../../utils/date';
8
9
 
9
- export const Calendar = <T extends SelectionType>(
10
- props: CalendarProps<T>
11
- ): JSX.Element => {
12
- return <CalendarCore {...props} TextComponent={Text} />;
10
+ export const Calendar = <T extends SelectionType>({
11
+ locale,
12
+ ...rest
13
+ }): JSX.Element => {
14
+ return (
15
+ <CalendarCore
16
+ {...rest}
17
+ TextComponent={Text}
18
+ locale={locale ?? getLocale()}
19
+ />
20
+ );
13
21
  };
@@ -6,16 +6,19 @@ import {
6
6
  import React from 'react';
7
7
  import { Text } from '../../atoms/Text';
8
8
  import { Calendar } from '../Calendar';
9
+ import { getLocale } from '../../../utils/date';
9
10
 
10
- export const DatePicker = <T extends SelectionType>(
11
- props: DatePickerProps<T>
12
- ): JSX.Element => {
11
+ export const DatePicker = <T extends SelectionType>({
12
+ locale,
13
+ ...rest
14
+ }): JSX.Element => {
13
15
  return (
14
16
  <DatePickerCore
15
- {...props}
17
+ {...rest}
16
18
  TextComponent={Text}
17
19
  CalendarComponent={Calendar}
18
20
  animationType="slide"
21
+ locale={locale ?? getLocale()}
19
22
  />
20
23
  );
21
24
  };
@@ -5,14 +5,19 @@ import {
5
5
  import React, { FC } from 'react';
6
6
  import { Text } from '../../atoms/Text';
7
7
  import { DateTimeSelector } from '../DateTimeSelector';
8
+ import { getLocale } from '../../../utils/date';
8
9
 
9
- export const DateTimePicker: FC<DateTimePickerProps> = props => {
10
+ export const DateTimePicker: FC<DateTimePickerProps> = ({
11
+ locale,
12
+ ...rest
13
+ }) => {
10
14
  return (
11
15
  <DateTimePickerCore
12
- {...props}
16
+ {...rest}
13
17
  TextComponent={Text}
14
18
  DateTimeSelectorComponent={DateTimeSelector}
15
19
  animationType="slide"
20
+ locale={locale ?? getLocale()}
16
21
  />
17
22
  );
18
23
  };
@@ -4,7 +4,14 @@ import {
4
4
  } from '@tecsinapse/react-core';
5
5
  import React, { FC } from 'react';
6
6
  import { Text } from '../../atoms/Text';
7
+ import { getLocale } from '../../../utils/date';
7
8
 
8
- export const DateTimeSelector: FC<DateTimeSelectorProps> = props => {
9
- return <DateTimeSelectorCore {...props} TextComponent={Text} />;
9
+ export const DateTimeSelector: FC<DateTimeSelectorProps> = ({locale, ...rest}) => {
10
+ return (
11
+ <DateTimeSelectorCore
12
+ {...rest}
13
+ TextComponent={Text}
14
+ locale={locale ?? getLocale()}
15
+ />
16
+ );
10
17
  };
@@ -0,0 +1,17 @@
1
+ import { NativeModules, Platform } from 'react-native';
2
+ import * as dateFnsLocales from 'date-fns/locale';
3
+
4
+ export const getLocale = (): Locale => {
5
+ let locale: string;
6
+ if (Platform.OS === 'ios') {
7
+ locale =
8
+ NativeModules.SettingsManager.settings.AppleLocale ||
9
+ NativeModules.SettingsManager.settings.AppleLanguages[0];
10
+ } else {
11
+ locale = NativeModules.I18nManager.localeIdentifier;
12
+ }
13
+
14
+ const code = locale.replace('_', '');
15
+
16
+ return dateFnsLocales[code];
17
+ };