@tecsinapse/react-native-kit 3.5.1 → 3.5.2

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.
@@ -9,7 +9,7 @@ var useSelect = require('./hooks/useSelect.js');
9
9
 
10
10
  function Select(props) {
11
11
  const {
12
- groupKeyExtractor,
12
+ groupLabelExtractor,
13
13
  onSelect,
14
14
  selectModalTitle,
15
15
  selectModalTitleComponent,
@@ -46,11 +46,11 @@ function Select(props) {
46
46
  /* @__PURE__ */ React.createElement(
47
47
  Modal.Modal,
48
48
  {
49
- options: selectOptions || [],
49
+ options: selectOptions ?? [],
50
50
  focused: true,
51
51
  keyExtractor,
52
52
  labelExtractor,
53
- groupKeyExtractor,
53
+ groupLabelExtractor,
54
54
  searchBarPlaceholder,
55
55
  type,
56
56
  onSelect,
@@ -71,7 +71,7 @@ function Select(props) {
71
71
  }
72
72
  )
73
73
  );
74
- return /* @__PURE__ */ React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React.createElement(
74
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() ?? "") : /* @__PURE__ */ React.createElement(
75
75
  reactCore.HintInputContainer,
76
76
  {
77
77
  ...rest,
@@ -93,7 +93,7 @@ function Select(props) {
93
93
  fontWeight: "bold",
94
94
  disabled
95
95
  },
96
- getDisplayValue() || " "
96
+ getDisplayValue() ?? " "
97
97
  )
98
98
  ));
99
99
  }
@@ -4,7 +4,12 @@ var React = require('react');
4
4
  var styled = require('../styled.js');
5
5
  var reactNative = require('react-native');
6
6
 
7
- const Flat = ({ options, keyExtractor, renderItem, getData }) => {
7
+ const Flat = ({
8
+ options,
9
+ keyExtractor,
10
+ renderItem,
11
+ getData
12
+ }) => {
8
13
  const data = React.useMemo(
9
14
  () => typeof options !== "function" ? getData(options) : [],
10
15
  [options, getData]
@@ -41,6 +41,7 @@ const Component = (props) => {
41
41
  confirmButtonText,
42
42
  handleConfirm,
43
43
  close,
44
+ groupLabelExtractor,
44
45
  ...others
45
46
  } = useModal(props);
46
47
  return /* @__PURE__ */ React.createElement(BaseModalView.ModalView, { ...others, BoxComponent: ModalComponent, showCloseBar: false }, /* @__PURE__ */ React.createElement(
@@ -70,7 +71,8 @@ const Component = (props) => {
70
71
  options,
71
72
  getData,
72
73
  renderItem,
73
- keyExtractor
74
+ keyExtractor,
75
+ groupLabelExtractor
74
76
  }
75
77
  ) : /* @__PURE__ */ React.createElement(
76
78
  Flat,
@@ -5,8 +5,17 @@ var styled = require('../styled.js');
5
5
  var reactNative = require('react-native');
6
6
  var Text = require('../../../atoms/Text/Text.js');
7
7
 
8
- const SectionHead = ({ section: { title } }) => /* @__PURE__ */ React.createElement(styled.SectionHeader, null, /* @__PURE__ */ React.createElement(Text, { fontWeight: "bold" }, title));
9
- const Section = ({ options, renderItem, getData, keyExtractor }) => {
8
+ const SectionHead = ({
9
+ title,
10
+ groupLabelExtractor
11
+ }) => /* @__PURE__ */ React.createElement(styled.SectionHeader, null, /* @__PURE__ */ React.createElement(Text, { fontWeight: "bold" }, groupLabelExtractor ? groupLabelExtractor(title) : title));
12
+ const Section = ({
13
+ options,
14
+ renderItem,
15
+ getData,
16
+ keyExtractor,
17
+ groupLabelExtractor
18
+ }) => {
10
19
  const sectionList = React.useMemo(
11
20
  () => options instanceof Map ? [...options].map(([key, value]) => ({
12
21
  title: key,
@@ -20,7 +29,7 @@ const Section = ({ options, renderItem, getData, keyExtractor }) => {
20
29
  sections: sectionList,
21
30
  renderItem,
22
31
  ItemSeparatorComponent: styled.Divider,
23
- renderSectionHeader: SectionHead,
32
+ renderSectionHeader: ({ section: { title } }) => /* @__PURE__ */ React.createElement(SectionHead, { title, groupLabelExtractor }),
24
33
  keyExtractor
25
34
  }
26
35
  );
@@ -31,7 +31,7 @@ const useSelect = ({
31
31
  const modal = useLazyModalManager.useLazyModalManager();
32
32
  const [loading, setLoading] = React.useState(false);
33
33
  const onlyLabel = label && !placeholder;
34
- const hasValue = type === "single" ? !!value : (value || []).length > 0;
34
+ const hasValue = type === "single" ? !!value : (value ?? []).length > 0;
35
35
  const _placeholder = onlyLabel ? label : placeholder;
36
36
  const _label = hasValue ? label : void 0;
37
37
  React.useEffect(() => {
@@ -7,7 +7,7 @@ import useSelect from './hooks/useSelect.js';
7
7
 
8
8
  function Select(props) {
9
9
  const {
10
- groupKeyExtractor,
10
+ groupLabelExtractor,
11
11
  onSelect,
12
12
  selectModalTitle,
13
13
  selectModalTitleComponent,
@@ -44,11 +44,11 @@ function Select(props) {
44
44
  /* @__PURE__ */ React__default.createElement(
45
45
  Modal,
46
46
  {
47
- options: selectOptions || [],
47
+ options: selectOptions ?? [],
48
48
  focused: true,
49
49
  keyExtractor,
50
50
  labelExtractor,
51
- groupKeyExtractor,
51
+ groupLabelExtractor,
52
52
  searchBarPlaceholder,
53
53
  type,
54
54
  onSelect,
@@ -69,7 +69,7 @@ function Select(props) {
69
69
  }
70
70
  )
71
71
  );
72
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() || "") : /* @__PURE__ */ React__default.createElement(
72
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, controlComponent ? controlComponent(handlePressInput, getDisplayValue() ?? "") : /* @__PURE__ */ React__default.createElement(
73
73
  HintInputContainer,
74
74
  {
75
75
  ...rest,
@@ -91,7 +91,7 @@ function Select(props) {
91
91
  fontWeight: "bold",
92
92
  disabled
93
93
  },
94
- getDisplayValue() || " "
94
+ getDisplayValue() ?? " "
95
95
  )
96
96
  ));
97
97
  }
@@ -2,7 +2,12 @@ import React__default from 'react';
2
2
  import { Divider } from '../styled.js';
3
3
  import { FlatList } from 'react-native';
4
4
 
5
- const Flat = ({ options, keyExtractor, renderItem, getData }) => {
5
+ const Flat = ({
6
+ options,
7
+ keyExtractor,
8
+ renderItem,
9
+ getData
10
+ }) => {
6
11
  const data = React__default.useMemo(
7
12
  () => typeof options !== "function" ? getData(options) : [],
8
13
  [options, getData]
@@ -39,6 +39,7 @@ const Component = (props) => {
39
39
  confirmButtonText,
40
40
  handleConfirm,
41
41
  close,
42
+ groupLabelExtractor,
42
43
  ...others
43
44
  } = useModal(props);
44
45
  return /* @__PURE__ */ React__default.createElement(ModalView, { ...others, BoxComponent: ModalComponent, showCloseBar: false }, /* @__PURE__ */ React__default.createElement(
@@ -68,7 +69,8 @@ const Component = (props) => {
68
69
  options,
69
70
  getData,
70
71
  renderItem,
71
- keyExtractor
72
+ keyExtractor,
73
+ groupLabelExtractor
72
74
  }
73
75
  ) : /* @__PURE__ */ React__default.createElement(
74
76
  Flat,
@@ -3,8 +3,17 @@ import { Divider, SectionHeader } from '../styled.js';
3
3
  import { SectionList } from 'react-native';
4
4
  import Text from '../../../atoms/Text/Text.js';
5
5
 
6
- const SectionHead = ({ section: { title } }) => /* @__PURE__ */ React__default.createElement(SectionHeader, null, /* @__PURE__ */ React__default.createElement(Text, { fontWeight: "bold" }, title));
7
- const Section = ({ options, renderItem, getData, keyExtractor }) => {
6
+ const SectionHead = ({
7
+ title,
8
+ groupLabelExtractor
9
+ }) => /* @__PURE__ */ React__default.createElement(SectionHeader, null, /* @__PURE__ */ React__default.createElement(Text, { fontWeight: "bold" }, groupLabelExtractor ? groupLabelExtractor(title) : title));
10
+ const Section = ({
11
+ options,
12
+ renderItem,
13
+ getData,
14
+ keyExtractor,
15
+ groupLabelExtractor
16
+ }) => {
8
17
  const sectionList = useMemo(
9
18
  () => options instanceof Map ? [...options].map(([key, value]) => ({
10
19
  title: key,
@@ -18,7 +27,7 @@ const Section = ({ options, renderItem, getData, keyExtractor }) => {
18
27
  sections: sectionList,
19
28
  renderItem,
20
29
  ItemSeparatorComponent: Divider,
21
- renderSectionHeader: SectionHead,
30
+ renderSectionHeader: ({ section: { title } }) => /* @__PURE__ */ React__default.createElement(SectionHead, { title, groupLabelExtractor }),
22
31
  keyExtractor
23
32
  }
24
33
  );
@@ -29,7 +29,7 @@ const useSelect = ({
29
29
  const modal = useLazyModalManager();
30
30
  const [loading, setLoading] = useState(false);
31
31
  const onlyLabel = label && !placeholder;
32
- const hasValue = type === "single" ? !!value : (value || []).length > 0;
32
+ const hasValue = type === "single" ? !!value : (value ?? []).length > 0;
33
33
  const _placeholder = onlyLabel ? label : placeholder;
34
34
  const _label = hasValue ? label : void 0;
35
35
  useEffect(() => {
@@ -1,8 +1,4 @@
1
1
  /// <reference types="react" />
2
- declare const Flat: ({ options, keyExtractor, renderItem, getData }: {
3
- options: any;
4
- keyExtractor: any;
5
- renderItem: any;
6
- getData: any;
7
- }) => JSX.Element;
2
+ import { BaseFlatList } from '../types';
3
+ declare const Flat: <Data>({ options, keyExtractor, renderItem, getData, }: BaseFlatList<Data>) => JSX.Element;
8
4
  export default Flat;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { IBaseModal } from '../../../atoms/Modal';
3
- import { LoadingProps, SelectNativeProps, SelectType } from '../types';
4
- export declare const Modal: <Data, Type extends SelectType>(props: SelectNativeProps<Data, Type> & LoadingProps & IBaseModal) => JSX.Element;
3
+ import { LoadingProps, OverrideModalProps, SelectType } from '../types';
4
+ export declare const Modal: <Data, Type extends SelectType>(props: OverrideModalProps<Data, Type> & LoadingProps & IBaseModal) => JSX.Element;
@@ -1,8 +1,4 @@
1
1
  /// <reference types="react" />
2
- declare const Section: ({ options, renderItem, getData, keyExtractor }: {
3
- options: any;
4
- renderItem: any;
5
- getData: any;
6
- keyExtractor: any;
7
- }) => JSX.Element;
2
+ import { BaseSectionList } from '../types';
3
+ declare const Section: <Data>({ options, renderItem, getData, keyExtractor, groupLabelExtractor, }: BaseSectionList<Data>) => JSX.Element;
8
4
  export default Section;
@@ -6,4 +6,4 @@ export declare const singleBuilder: <Data>(option: Data, src: Data[], keyExtract
6
6
  export declare const isMap: <Data>(value: Data[] | Map<string, Data[]>) => boolean;
7
7
  export declare const mapToArray: <Data>(map: Map<string, Data[]>) => Data[];
8
8
  export declare const getMultiLabel: <Data>(value: Data[], placeholder: string, options: Data[] | Map<string, Data[]>, keyExtractor: Extractor<Data>, labelExtractor: Extractor<Data>) => string;
9
- export declare const getSingleLabel: <Data>(value: Data, placeholder: string, options: Data[] | Map<string, Data[]>, keyExtractor: Extractor<Data>, labelExtractor: Extractor<Data>) => string;
9
+ export declare const getSingleLabel: <Data>(value: Data | null | undefined, placeholder: string, options: Data[] | Map<string, Data[]>, keyExtractor: Extractor<Data>, labelExtractor: Extractor<Data>) => string;
@@ -1,26 +1,18 @@
1
1
  import React from 'react';
2
- import { LoadingProps, OptionData, SelectNativeProps, SelectType } from '../types';
2
+ import { LoadingProps, OptionData, OverrideModalProps, SelectType } from '../types';
3
3
  import { ListRenderItemInfo } from 'react-native';
4
4
  import { IBaseModal } from '../../../atoms/Modal';
5
- declare const useModal: <Data, Type extends SelectType>({ keyExtractor, labelExtractor, focused, type, value, onSelect, onSearch, close, closeOnPick, ...others }: SelectNativeProps<Data, Type> & LoadingProps & IBaseModal) => {
6
- options: ((searchInput?: string | undefined) => Promise<Data[] | Map<string, Data[]>>) | Data[] | Map<string, Data[]>;
7
- groupKeyExtractor?: import("../types").Extractor<Data> | undefined;
8
- hideSearchBar?: boolean | undefined;
9
- placeholder?: string | undefined;
10
- onFocus?: (() => void) | undefined;
11
- onBlur?: (() => void) | undefined;
12
- searchBarPlaceholder?: string | undefined;
13
- confirmButtonText?: string | undefined;
14
- selectModalTitle?: string | undefined;
15
- selectModalTitleComponent?: JSX.Element | undefined;
16
- controlComponent?: ((onPress: () => void, displayValue?: string | undefined) => JSX.Element) | undefined;
17
- numberOfLines?: number | undefined;
5
+ declare const useModal: <Data, Type extends SelectType>({ keyExtractor, labelExtractor, focused, type, value, onSelect, onSearch, close, closeOnPick, ...others }: OverrideModalProps<Data, Type> & LoadingProps & IBaseModal) => {
18
6
  label?: string | undefined;
19
7
  style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
8
+ numberOfLines?: number | undefined;
20
9
  testID?: string | undefined;
21
10
  borderColor?: keyof import("@tecsinapse/react-core").Color | undefined;
11
+ onBlur?: (() => void) | undefined;
12
+ onFocus?: (() => void) | undefined;
22
13
  disabled?: boolean | undefined;
23
14
  variant?: import("@tecsinapse/react-core").InputVariantType | undefined;
15
+ placeholder?: string | undefined;
24
16
  labelColor?: keyof import("@tecsinapse/react-core").FontColor | undefined;
25
17
  labelColorVariant?: keyof import("@tecsinapse/react-core").Color | undefined;
26
18
  labelColorTone?: keyof import("@tecsinapse/react-core").ColorGradation | undefined;
@@ -34,6 +26,14 @@ declare const useModal: <Data, Type extends SelectType>({ keyExtractor, labelExt
34
26
  inputContainerStyle?: import("react-native").StyleProp<import("react-native").ViewStyle>;
35
27
  hint?: string | undefined;
36
28
  hintComponent?: JSX.Element | undefined;
29
+ controlComponent?: ((onPress: () => void, displayValue?: string | undefined) => JSX.Element) | undefined;
30
+ confirmButtonText?: string | undefined;
31
+ groupLabelExtractor?: ((title: string) => string) | undefined;
32
+ hideSearchBar?: boolean | undefined;
33
+ searchBarPlaceholder?: string | undefined;
34
+ selectModalTitle?: string | undefined;
35
+ selectModalTitleComponent?: JSX.Element | undefined;
36
+ options: Data[] | Map<string, Data[]>;
37
37
  loading?: boolean | undefined;
38
38
  visible?: boolean | undefined;
39
39
  BoxComponent?: React.FC<any> | undefined;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { SelectNativeProps, SelectType } from '../types';
3
3
  declare const useSelect: <Data, Type extends SelectType>({ value, options, keyExtractor, type, labelExtractor, placeholder, onFocus, onBlur, disabled, onSearch, label, ...rest }: SelectNativeProps<Data, Type>) => {
4
4
  onSelect: (option: Type extends "single" ? Data | undefined : Data[]) => void;
5
- groupKeyExtractor?: import("../types").Extractor<Data> | undefined;
5
+ groupLabelExtractor?: ((title: string) => string) | undefined;
6
6
  hideSearchBar?: boolean | undefined;
7
7
  searchBarPlaceholder?: string | undefined;
8
8
  confirmButtonText?: string | undefined;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { InputContainerProps } from '@tecsinapse/react-core';
3
+ import { ListRenderItemInfo } from 'react-native';
3
4
  export type OptionData<T> = T & {
4
5
  _checked: boolean;
5
6
  };
@@ -16,7 +17,7 @@ export interface SelectNativeProps<Data, Type extends SelectType> extends Omit<I
16
17
  type: Type;
17
18
  keyExtractor: Extractor<Data>;
18
19
  labelExtractor: Extractor<Data>;
19
- groupKeyExtractor?: Extractor<Data>;
20
+ groupLabelExtractor?: (title: string) => string;
20
21
  hideSearchBar?: boolean;
21
22
  placeholder?: string;
22
23
  onFocus?: () => void | never;
@@ -30,4 +31,19 @@ export interface SelectNativeProps<Data, Type extends SelectType> extends Omit<I
30
31
  controlComponent?: (onPress: () => void, displayValue?: string) => JSX.Element;
31
32
  numberOfLines?: number;
32
33
  }
34
+ type BaseList<Data> = {
35
+ renderItem: (item: ListRenderItemInfo<OptionData<Data>>) => JSX.Element;
36
+ getData: (options: Data[]) => OptionData<Data>[];
37
+ keyExtractor: Extractor<Data>;
38
+ };
39
+ export type BaseSectionList<Data> = BaseList<Data> & {
40
+ options: Map<string, Data[]>;
41
+ groupLabelExtractor?: (title: string) => string;
42
+ };
43
+ export type BaseFlatList<Data> = BaseList<Data> & {
44
+ options: Data[];
45
+ };
46
+ export type OverrideModalProps<Data, Type extends SelectType> = Omit<SelectNativeProps<Data, Type>, 'options'> & {
47
+ options: Data[] | Map<string, Data[]>;
48
+ };
33
49
  export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-native-kit",
3
3
  "description": "React Native components library",
4
- "version": "3.5.1",
4
+ "version": "3.5.2",
5
5
  "license": "MIT",
6
6
  "main": "dist/esm/index.js",
7
7
  "module": "dist/esm/index.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@emotion/native": "~11.11.0",
22
22
  "@emotion/react": "~11.11.0",
23
- "@tecsinapse/react-core": "3.4.2",
23
+ "@tecsinapse/react-core": "3.4.3",
24
24
  "react-native-linear-gradient": "~2.8.3"
25
25
  },
26
26
  "devDependencies": {
@@ -42,5 +42,5 @@
42
42
  "react-native-safe-area-context": "^4.0.0",
43
43
  "react-native-vector-icons": "^9.2.0"
44
44
  },
45
- "gitHead": "88caf1e99c9ff6e9a3cf84e60f79a6358fd3fc32"
45
+ "gitHead": "cb0b51647a39310e5cffadd41b1258ddadb2af94"
46
46
  }