@hero-design/rn 7.16.2 → 7.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +331 -259
  3. package/lib/index.js +330 -258
  4. package/package.json +2 -2
  5. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +12 -12
  6. package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +18 -18
  7. package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +26 -26
  8. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +3 -3
  9. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
  10. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +1 -1
  11. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +2 -2
  12. package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
  13. package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
  14. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +2 -2
  15. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
  16. package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
  17. package/src/components/Button/__tests__/__snapshots__/IconButton.spec.tsx.snap +1 -1
  18. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +67 -67
  19. package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +12 -12
  20. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +1 -1
  21. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +1 -1
  22. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
  23. package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +1 -1
  24. package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +6 -6
  25. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +5 -5
  26. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +12 -12
  27. package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +12 -12
  28. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
  29. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
  30. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +28 -28
  31. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +2 -2
  32. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +3 -3
  33. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
  34. package/src/components/Icon/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
  35. package/src/components/List/BasicListItem.tsx +8 -4
  36. package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +3 -3
  37. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +20 -20
  38. package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +6 -6
  39. package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +12 -12
  40. package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +4 -4
  41. package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +22 -22
  42. package/src/components/Progress/ProgressCircle.tsx +25 -22
  43. package/src/components/Progress/StyledProgressCircle.tsx +33 -28
  44. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +102 -92
  45. package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +5 -5
  46. package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +6 -6
  47. package/src/components/Radio/__tests__/__snapshots__/StyledRadio.spec.tsx.snap +3 -3
  48. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +11 -11
  49. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +6 -6
  50. package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +1 -1
  51. package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +9 -9
  52. package/src/components/Select/MultiSelect/Option.tsx +20 -11
  53. package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
  54. package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
  55. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +6 -4
  56. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1638 -134
  57. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5312 -366
  58. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
  59. package/src/components/Select/MultiSelect/index.tsx +26 -36
  60. package/src/components/Select/SingleSelect/Option.tsx +19 -3
  61. package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
  62. package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
  63. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +5 -3
  64. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1632 -128
  65. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4932 -302
  66. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
  67. package/src/components/Select/SingleSelect/index.tsx +26 -37
  68. package/src/components/Select/StyledOptionList.tsx +43 -44
  69. package/src/components/Select/StyledSelect.tsx +7 -3
  70. package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -9
  71. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +2 -15
  72. package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
  73. package/src/components/Select/helpers.tsx +87 -4
  74. package/src/components/Select/types.ts +99 -0
  75. package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +4 -4
  76. package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +8 -8
  77. package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
  78. package/src/components/Switch/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +1 -1
  79. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
  80. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +6 -6
  81. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  82. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +8 -8
  83. package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +50 -50
  84. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +241 -85
  85. package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
  86. package/src/components/TextInput/index.tsx +18 -7
  87. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +5 -5
  88. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +12 -12
  89. package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +22 -22
  90. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -12
  91. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +8 -8
  92. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +13 -13
  93. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +145 -146
  94. package/src/theme/components/alert.ts +3 -3
  95. package/src/theme/components/badge.ts +1 -1
  96. package/src/theme/components/card.ts +4 -4
  97. package/src/theme/components/list.ts +4 -4
  98. package/src/theme/components/pinInput.ts +2 -2
  99. package/src/theme/components/progress.ts +5 -5
  100. package/src/theme/components/select.ts +3 -3
  101. package/src/theme/components/toast.ts +3 -3
  102. package/src/theme/global/colors.ts +40 -39
  103. package/src/types.ts +7 -1
  104. package/types/components/List/BasicListItem.d.ts +1 -1
  105. package/types/components/Progress/StyledProgressCircle.d.ts +12 -6
  106. package/types/components/Select/MultiSelect/Option.d.ts +4 -2
  107. package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
  108. package/types/components/Select/MultiSelect/index.d.ts +5 -5
  109. package/types/components/Select/SingleSelect/Option.d.ts +4 -2
  110. package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
  111. package/types/components/Select/SingleSelect/index.d.ts +5 -5
  112. package/types/components/Select/StyledOptionList.d.ts +10 -16
  113. package/types/components/Select/StyledSelect.d.ts +8 -2
  114. package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
  115. package/types/components/Select/helpers.d.ts +14 -2
  116. package/types/components/Select/index.d.ts +1 -1
  117. package/types/components/Select/types.d.ts +32 -7
  118. package/types/components/TextInput/index.d.ts +4 -2
  119. package/types/theme/components/progress.d.ts +1 -2
  120. package/types/theme/components/select.d.ts +3 -3
  121. package/types/types.d.ts +2 -1
  122. package/src/components/Select/types.tsx +0 -52
@@ -7,9 +7,9 @@ const getSelectTheme = (theme: GlobalTheme) => {
7
7
 
8
8
  const space = {
9
9
  minimumOptionListHeight: theme.space.xxxxlarge * 5,
10
- optionPadding: theme.space.medium,
11
- optionListPadding: theme.space.medium, // left padding should be 12 according to the design
12
- optionListSpacing: theme.space.xsmall,
10
+ sectionSpacing: theme.space.smallMedium,
11
+ optionSpacing: theme.space.xsmall,
12
+ optionHorizontalMargin: theme.space.smallMedium,
13
13
  searchBarMarginTopSpacing: theme.space.small,
14
14
  searchBarHorizontalSpacing: theme.space.medium,
15
15
  searchBarBottomSpacing: theme.space.small,
@@ -5,9 +5,9 @@ const getToastTheme = (theme: GlobalTheme) => {
5
5
  const colors = {
6
6
  success: theme.colors.success,
7
7
  warning: theme.colors.warning,
8
- error: theme.colors.danger,
9
- info: theme.colors.infoMediumLight,
10
- divider: theme.colors.backgroundLight,
8
+ error: theme.colors.dangerLight,
9
+ info: theme.colors.infoLight,
10
+ divider: theme.colors.outline,
11
11
  };
12
12
 
13
13
  const sizes = {
@@ -1,48 +1,49 @@
1
- import palette, {
2
- defaultMobilePalette as mobilePalette,
1
+ import {
2
+ defaultMobilePalette as palette,
3
+ swagPalette,
3
4
  } from '@hero-design/colors';
4
5
 
5
6
  const systemPalette = {
6
- primary: palette.violet,
7
- primaryLight: palette.violetLight60,
8
- primaryDark: palette.purpleDark15,
9
- primaryBackground: palette.violetLight90,
10
- primaryBackgroundDark: mobilePalette.maasstrichtBlueLight30,
11
- secondary: palette.dodgerBlue,
12
- secondaryLight: palette.dodgerBlueLight75,
13
- secondaryBackground: palette.dodgerBlueLight90,
14
- info: palette.dodgerBlue,
15
- infoMediumLight: mobilePalette.vodka,
16
- infoLight: palette.dodgerBlueLight75,
17
- infoBackground: palette.dodgerBlueLight90,
18
- success: palette.green,
19
- successLight: mobilePalette.emerald,
20
- successDark: palette.greenDark30,
21
- successBackground: palette.grotesqueGreenLight90,
22
- danger: palette.red,
23
- dangerMediumLight: mobilePalette.apple,
24
- dangerLight: palette.redLight60,
25
- dangerBackground: palette.redLight90,
26
- warning: palette.orange,
27
- warningLight: mobilePalette.mellowApricot,
28
- warningDark: palette.orangeDark15,
29
- warningBackground: palette.orangeLight90,
7
+ primary: swagPalette.violet,
8
+ primaryLight: swagPalette.violetLight50, // no longer needed after revising Button
9
+ primaryDark: swagPalette.scarletGumLight30, // DEPRECATED
10
+ primaryBackground: swagPalette.violetLight90,
11
+ primaryBackgroundDark: palette.maasstrichtBlueLight30,
12
+ secondary: swagPalette.ultramarineBlue, // no longer needed after revising Button
13
+ secondaryLight: swagPalette.vodka, // no longer needed after revising Button
14
+ secondaryBackground: swagPalette.aliceBlue, // no longer needed after revising Button
15
+ info: palette.ultramarineBlue,
16
+ infoMediumLight: palette.vodka, // DEPRECATED, use infoLight instead
17
+ infoLight: palette.vodka,
18
+ infoBackground: palette.aliceBlue,
19
+ success: palette.emerald,
20
+ successLight: palette.emerald, // DEPRECATED, use success instead
21
+ successDark: palette.pineGreen,
22
+ successBackground: palette.honeydew,
23
+ danger: palette.vermilion,
24
+ dangerMediumLight: palette.apple, // should be dangerDark?
25
+ dangerLight: palette.pastelRed,
26
+ dangerBackground: palette.linen,
27
+ warning: palette.mellowApricot,
28
+ warningLight: palette.mellowApricot, // DEPRECATED, use warning instead
29
+ warningDark: palette.deepSaffron,
30
+ warningBackground: palette.seashell,
30
31
  platformBackground: palette.white,
31
- backgroundLight: palette.greyLight95,
32
- backgroundDark: palette.greyDark75,
33
- text: palette.greyDark75, // should be Maastricht Blue
34
- subduedText: palette.greyDark30,
35
- disabledText: palette.greyDark15,
36
- disabledLightText: palette.greyLight45,
32
+ backgroundLight: palette.greyLight90,
33
+ backgroundDark: palette.maasstrichtBlue,
34
+ text: palette.maasstrichtBlue,
35
+ subduedText: palette.maasstrichtBlueLight30, // secondary
36
+ disabledText: palette.maasstrichtBlueLight50, // readonly
37
+ disabledLightText: palette.greyLight30, // disabled
37
38
  invertedText: palette.white,
38
- outline: palette.greyLight60,
39
- archived: palette.greyLight45,
40
- archivedLight: mobilePalette.greyLight30,
41
- archivedDark: mobilePalette.sonicSilver,
42
- archivedBackground: mobilePalette.antiFlashWhite,
39
+ outline: palette.greyLight75, // divider
40
+ archived: palette.greyLight45, // no usage
41
+ archivedLight: palette.greyLight30,
42
+ archivedDark: palette.sonicSilver, // should replace archived as archived has no usage?
43
+ archivedBackground: palette.antiFlashWhite,
43
44
  black: palette.black,
44
- inactiveBackground: palette.greyDark30,
45
- shadow: palette.greyLight60,
45
+ inactiveBackground: palette.maasstrichtBlueLight50,
46
+ shadow: palette.greyLight45, // waiting for new color
46
47
  };
47
48
 
48
49
  type SystemPalette = typeof systemPalette;
package/src/types.ts CHANGED
@@ -10,14 +10,20 @@ import {
10
10
  } from './components/RichTextEditor';
11
11
 
12
12
  import { Theme } from './theme';
13
+ import {
14
+ ListRenderOptionInfo,
15
+ SectionListRenderOptionInfo,
16
+ } from './components/Select/types';
13
17
 
14
18
  export type {
15
19
  BottomNavigationTabType,
16
20
  IconName,
21
+ SingleSelectProps,
17
22
  MultiSelectProps,
23
+ ListRenderOptionInfo,
24
+ SectionListRenderOptionInfo,
18
25
  RichTextEditorProps,
19
26
  RichTextEditorRef,
20
- SingleSelectProps,
21
27
  TabType,
22
28
  TextInputProps,
23
29
  Theme,
@@ -13,7 +13,7 @@ export interface ListItemProps {
13
13
  /**
14
14
  * The title of the component.
15
15
  */
16
- title: string;
16
+ title: string | React.ReactElement;
17
17
  /**
18
18
  * The subtile title of the component.
19
19
  */
@@ -1,12 +1,18 @@
1
1
  import { View, ViewProps } from 'react-native';
2
2
  import { ThemeIntent } from './types';
3
- declare const HalfCircleWrapper: import("@emotion/native").StyledComponent<ViewProps & {
3
+ declare const StyledContainer: import("@emotion/native").StyledComponent<ViewProps & {
4
4
  theme?: import("@emotion/react").Theme | undefined;
5
5
  as?: import("react").ElementType<any> | undefined;
6
6
  }, {}, {
7
7
  ref?: import("react").Ref<View> | undefined;
8
8
  }>;
9
- declare const HalfCircleInnerFG: import("@emotion/native").StyledComponent<ViewProps & {
9
+ declare const StyledHalfCircleWrapper: import("@emotion/native").StyledComponent<ViewProps & {
10
+ theme?: import("@emotion/react").Theme | undefined;
11
+ as?: import("react").ElementType<any> | undefined;
12
+ }, {}, {
13
+ ref?: import("react").Ref<View> | undefined;
14
+ }>;
15
+ declare const StyledHalfCircleInnerFG: import("@emotion/native").StyledComponent<ViewProps & {
10
16
  theme?: import("@emotion/react").Theme | undefined;
11
17
  as?: import("react").ElementType<any> | undefined;
12
18
  } & {
@@ -14,19 +20,19 @@ declare const HalfCircleInnerFG: import("@emotion/native").StyledComponent<ViewP
14
20
  }, {}, {
15
21
  ref?: import("react").Ref<View> | undefined;
16
22
  }>;
17
- declare const HalfCircleInnerBG: import("@emotion/native").StyledComponent<ViewProps & {
23
+ declare const StyledHalfCircleInnerBG: import("@emotion/native").StyledComponent<ViewProps & {
18
24
  theme?: import("@emotion/react").Theme | undefined;
19
25
  as?: import("react").ElementType<any> | undefined;
20
26
  }, {}, {
21
27
  ref?: import("react").Ref<View> | undefined;
22
28
  }>;
23
- declare const DonutCircle: import("@emotion/native").StyledComponent<ViewProps & {
29
+ declare const StyledDonutCircle: import("@emotion/native").StyledComponent<ViewProps & {
24
30
  theme?: import("@emotion/react").Theme | undefined;
25
31
  as?: import("react").ElementType<any> | undefined;
26
32
  }, {}, {
27
33
  ref?: import("react").Ref<View> | undefined;
28
34
  }>;
29
- declare const StrokeEnd: import("@emotion/native").StyledComponent<ViewProps & {
35
+ declare const StyledStrokeEnd: import("@emotion/native").StyledComponent<ViewProps & {
30
36
  theme?: import("@emotion/react").Theme | undefined;
31
37
  as?: import("react").ElementType<any> | undefined;
32
38
  } & {
@@ -34,4 +40,4 @@ declare const StrokeEnd: import("@emotion/native").StyledComponent<ViewProps & {
34
40
  }, {}, {
35
41
  ref?: import("react").Ref<View> | undefined;
36
42
  }>;
37
- export { DonutCircle, HalfCircleWrapper, HalfCircleInnerFG, HalfCircleInnerBG, StrokeEnd, };
43
+ export { StyledContainer, StyledDonutCircle, StyledHalfCircleWrapper, StyledHalfCircleInnerFG, StyledHalfCircleInnerBG, StyledStrokeEnd, };
@@ -1,5 +1,7 @@
1
- declare const Option: ({ text, selected, onPress, }: {
2
- text: string;
1
+ import { ReactElement } from 'react';
2
+ declare const Option: ({ text, disabled, selected, onPress, }: {
3
+ text: string | ReactElement;
4
+ disabled?: boolean | undefined;
3
5
  selected: boolean;
4
6
  onPress: () => void;
5
7
  }) => JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { MultiSelectProps } from '.';
2
- interface OptionListProps<T> extends MultiSelectProps<T> {
3
- /**
4
- * event handler for select
5
- */
6
- onPress: (value: T[]) => void;
7
- }
8
- declare const OptionList: <T>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, options, value, }: Pick<OptionListProps<T>, "value" | "onPress" | "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached">) => JSX.Element;
2
+ import { OptionType, SectionData } from '../types';
3
+ declare type OptionListProps<V, T extends OptionType<V>> = Pick<MultiSelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption'> & {
4
+ onPress: (value: V[]) => void;
5
+ sections: SectionData<V, T>[];
6
+ };
7
+ declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, }: OptionListProps<V, T>) => JSX.Element;
9
8
  export default OptionList;
@@ -1,17 +1,17 @@
1
- import { SelectProps } from '../types';
2
- export interface MultiSelectProps<T> extends SelectProps<T> {
1
+ import { OptionType, SelectProps } from '../types';
2
+ export interface MultiSelectProps<V, T extends OptionType<V> = OptionType<V>> extends SelectProps<V, T> {
3
3
  /**
4
4
  * Current selected value.
5
5
  */
6
- value: T[];
6
+ value: V[];
7
7
  /**
8
8
  * event handler for footer button.
9
9
  */
10
- onConfirm: (value: T[]) => void;
10
+ onConfirm: (value: V[]) => void;
11
11
  /**
12
12
  * Footer label.
13
13
  */
14
14
  footerLabel: string;
15
15
  }
16
- declare function MultiSelect<T>({ footerLabel, label, loading, onConfirm, onDimiss, onEndReached, onQueryChange, options, query, error, editable, disabled, numberOfLines, style, testID, value, }: MultiSelectProps<T>): JSX.Element;
16
+ declare function MultiSelect<V, T extends OptionType<V>>({ footerLabel, label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, query, error, editable, disabled, numberOfLines, style, testID, value, }: MultiSelectProps<V, T>): JSX.Element;
17
17
  export default MultiSelect;
@@ -1,5 +1,7 @@
1
- declare const Option: ({ text, selected, onPress, }: {
2
- text: string;
1
+ import { ReactElement } from 'react';
2
+ declare const Option: ({ text, disabled, selected, onPress, }: {
3
+ text: string | ReactElement;
4
+ disabled?: boolean | undefined;
3
5
  selected: boolean;
4
6
  onPress: () => void;
5
7
  }) => JSX.Element;
@@ -1,9 +1,8 @@
1
1
  import { SingleSelectProps } from '.';
2
- interface OptionListProps<T> extends SingleSelectProps<T> {
3
- /**
4
- * event handler for select
5
- */
6
- onPress: (value: T | null) => void;
7
- }
8
- declare const OptionList: <T>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, options, value, }: Pick<OptionListProps<T>, "value" | "onPress" | "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached">) => JSX.Element;
2
+ import { OptionType, SectionData } from '../types';
3
+ declare type OptionListProps<V, T extends OptionType<V>> = Pick<SingleSelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption'> & {
4
+ onPress: (value: V | null) => void;
5
+ sections: SectionData<V, T>[];
6
+ };
7
+ declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, }: OptionListProps<V, T>) => JSX.Element;
9
8
  export default OptionList;
@@ -1,13 +1,13 @@
1
- import { SelectProps } from '../types';
2
- export interface SingleSelectProps<T> extends SelectProps<T> {
1
+ import { OptionType, SelectProps } from '../types';
2
+ export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>> extends SelectProps<V, T> {
3
3
  /**
4
4
  * Current selected value.
5
5
  */
6
- value: T | null;
6
+ value: V | null;
7
7
  /**
8
8
  * on select event handler
9
9
  */
10
- onConfirm: (value: T | null) => void;
10
+ onConfirm: (value: V | null) => void;
11
11
  }
12
- declare const SingleSelect: <T>({ label, loading, onConfirm, onDimiss, onEndReached, onQueryChange, options, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<T>) => JSX.Element;
12
+ declare const SingleSelect: <V, T extends OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element;
13
13
  export default SingleSelect;
@@ -1,17 +1,11 @@
1
- import React from 'react';
2
- import { OptionType, SelectProps } from './types';
3
- export interface RenderItemProps<T> {
4
- item: OptionType<T>;
5
- }
6
- export interface OptionListProps<T> extends SelectProps<T> {
7
- /**
8
- * FlatList renderItem Element
9
- */
10
- RenderItem: React.FC<RenderItemProps<T>>;
11
- /**
12
- * Selected scroll index
13
- */
14
- scrollIndex?: number;
15
- }
16
- declare const StyledOptionList: <T>({ keyExtractor, loading, onEndReached, onQueryChange, options, RenderItem, scrollIndex, }: Pick<OptionListProps<T>, "loading" | "options" | "keyExtractor" | "onQueryChange" | "onEndReached" | "scrollIndex" | "RenderItem">) => JSX.Element;
1
+ import { ReactElement } from 'react';
2
+ import { SectionListRenderItemInfo } from 'react-native';
3
+ import { ScrollParams } from './helpers';
4
+ import { SectionData, OptionType, SelectProps, SectionType } from './types';
5
+ export declare type StyledOptionListProps<V, T extends OptionType<V>> = Pick<SelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange'> & {
6
+ scrollParams: ScrollParams;
7
+ sections: SectionData<V, T>[];
8
+ renderItem: (info: SectionListRenderItemInfo<T, SectionType>) => ReactElement;
9
+ };
10
+ declare const StyledOptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onQueryChange, sections, renderItem, scrollParams, }: StyledOptionListProps<V, T>) => JSX.Element;
17
11
  export default StyledOptionList;
@@ -1,5 +1,11 @@
1
1
  import { View } from 'react-native';
2
- declare const Spacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
2
+ declare const SectionSpacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
3
+ theme?: import("@emotion/react").Theme | undefined;
4
+ as?: import("react").ElementType<any> | undefined;
5
+ }, {}, {
6
+ ref?: import("react").Ref<View> | undefined;
7
+ }>;
8
+ declare const OptionSpacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
3
9
  theme?: import("@emotion/react").Theme | undefined;
4
10
  as?: import("react").ElementType<any> | undefined;
5
11
  }, {}, {
@@ -15,4 +21,4 @@ declare const StyledSearchBar: import("@emotion/native").StyledComponent<import(
15
21
  }, {}, {
16
22
  ref?: import("react").Ref<View> | undefined;
17
23
  }>;
18
- export { Spacer, FooterText, StyledSearchBar };
24
+ export { SectionSpacer, OptionSpacer, FooterText, StyledSearchBar };
@@ -1,2 +1,14 @@
1
- import { OptionType } from './types';
2
- export declare const getKey: <T>(option: OptionType<T>, index: number, keyExtractor?: ((opt: OptionType<T>, i?: number | undefined) => string) | undefined) => import("react").Key;
1
+ import { SectionData, CombinedOptionsType, OptionType } from './types';
2
+ export declare const getKey: <V, T extends OptionType<V>>(option: T, index: number, keyExtractor?: ((opt: T, i?: number | undefined) => string) | undefined) => import("react").Key;
3
+ export declare const isSections: <V, T extends OptionType<V>>(options: CombinedOptionsType<V, T>) => options is SectionData<V, T>[];
4
+ export declare const toSections: <V, T extends OptionType<V>>(options: CombinedOptionsType<V, T>) => SectionData<V, T>[];
5
+ export declare const toFlatOptions: <V, T extends OptionType<V>>(options: CombinedOptionsType<V, T>) => OptionType<V>[];
6
+ export declare type ScrollParams = {
7
+ itemIndex: number;
8
+ sectionIndex: number;
9
+ };
10
+ export declare const getScrollParams: <V, T extends OptionType<V>>(value: V, sections: SectionData<V, T>[]) => ScrollParams;
11
+ export declare const useKeyboard: () => {
12
+ isKeyboardVisible: boolean;
13
+ keyboardHeight: number;
14
+ };
@@ -1,6 +1,6 @@
1
1
  import MultiSelect, { MultiSelectProps } from './MultiSelect';
2
2
  import { SingleSelectProps } from './SingleSelect';
3
- declare const _default: (<T>({ label, loading, onConfirm, onDimiss, onEndReached, onQueryChange, options, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<T>) => JSX.Element) & {
3
+ declare const _default: (<V, T extends import("./types").OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element) & {
4
4
  Multi: typeof MultiSelect;
5
5
  };
6
6
  export default _default;
@@ -1,20 +1,39 @@
1
- import { StyleProp, ViewStyle } from 'react-native';
1
+ import { ReactElement } from 'react';
2
+ import { ListRenderItemInfo, SectionListData, SectionListRenderItemInfo, StyleProp, ViewStyle } from 'react-native';
2
3
  import { TextInputProps } from '../TextInput';
3
- export declare type OptionType<T> = {
4
- value: T;
4
+ export declare type OptionType<V> = {
5
+ value: V;
5
6
  text: string;
6
7
  key?: string;
8
+ disabled?: boolean;
7
9
  };
8
- export interface SelectProps<T> extends Pick<TextInputProps, 'editable' | 'disabled' | 'numberOfLines' | 'error'> {
10
+ export declare type SectionType = {
11
+ category: string;
12
+ };
13
+ export declare type SectionData<V, T extends OptionType<V>> = SectionListData<T, SectionType>;
14
+ export declare type CombinedOptionsType<V, T extends OptionType<V>> = T[] | SectionData<V, T>[];
15
+ export declare type ListRenderOptionInfo<V, T extends OptionType<V>> = ListRenderItemInfo<T> & {
16
+ selected: boolean;
17
+ onPress: () => void;
18
+ };
19
+ export declare type SectionListRenderOptionInfo<V, T extends OptionType<V>> = SectionListRenderItemInfo<T, SectionType> & {
20
+ selected: boolean;
21
+ onPress: () => void;
22
+ };
23
+ export interface SelectProps<V, T extends OptionType<V>> extends Pick<TextInputProps, 'editable' | 'disabled' | 'numberOfLines' | 'error'> {
9
24
  /**
10
25
  * An array of options to be selected.
11
26
  */
12
- options: OptionType<T>[];
27
+ options: CombinedOptionsType<V, T>;
28
+ /**
29
+ * Customize option renderer.
30
+ */
31
+ renderOption?: ((info: ListRenderOptionInfo<V, T>) => ReactElement) | ((info: SectionListRenderOptionInfo<V, T>) => ReactElement);
13
32
  /**
14
33
  * Used to extract a unique key for a given option at the specified index. Key is used for caching and as the react key to track item re-ordering.
15
34
  * The default extractor checks option.key, and then falls back to using the index, like React does.
16
35
  */
17
- keyExtractor?: (option: OptionType<T>, index?: number) => string;
36
+ keyExtractor?: (option: T, index?: number) => string;
18
37
  /**
19
38
  * Current search value.
20
39
  */
@@ -32,9 +51,15 @@ export interface SelectProps<T> extends Pick<TextInputProps, 'editable' | 'disab
32
51
  */
33
52
  onEndReached?: () => void;
34
53
  /**
35
- * Show indicator at bottom of option list
54
+ * Show loading indicator at bottom of option list
36
55
  */
37
56
  loading?: boolean;
57
+ /**
58
+ * Props that are passed to TextInput.
59
+ */
60
+ inputProps?: {
61
+ loading?: boolean;
62
+ };
38
63
  /**
39
64
  * Field label.
40
65
  */
@@ -48,15 +48,17 @@ export interface TextInputProps extends NativeTextInputProps {
48
48
  * */
49
49
  editable?: boolean;
50
50
  disabled?: boolean;
51
+ loading?: boolean;
51
52
  maxLength?: number;
52
53
  helpText?: string;
53
54
  }
54
- export declare const getVariant: ({ disabled, error, editable, isFocused, isEmptyValue, }: {
55
+ export declare const getVariant: ({ disabled, error, editable, loading, isFocused, isEmptyValue, }: {
55
56
  disabled?: boolean | undefined;
56
57
  error?: string | undefined;
57
58
  editable?: boolean | undefined;
59
+ loading: boolean;
58
60
  isFocused?: boolean | undefined;
59
61
  isEmptyValue?: boolean | undefined;
60
62
  }) => Variant;
61
- declare const TextInput: ({ label, prefix, suffix, style, textStyle, testID, accessibilityLabelledBy, error, required, editable, disabled, maxLength, helpText, value, defaultValue, ...nativeProps }: TextInputProps) => JSX.Element;
63
+ declare const TextInput: ({ label, prefix, suffix, style, textStyle, testID, accessibilityLabelledBy, error, required, editable, disabled, loading, maxLength, helpText, value, defaultValue, ...nativeProps }: TextInputProps) => JSX.Element;
62
64
  export default TextInput;
@@ -10,8 +10,7 @@ declare const getProgressTheme: (theme: GlobalTheme) => {
10
10
  innerBackground: string;
11
11
  };
12
12
  sizes: {
13
- radius: number;
14
- strokeWidth: number;
13
+ circleWidth: number;
15
14
  barHeight: number;
16
15
  };
17
16
  radii: {
@@ -2,9 +2,9 @@ import { GlobalTheme } from '../global';
2
2
  declare const getSelectTheme: (theme: GlobalTheme) => {
3
3
  space: {
4
4
  minimumOptionListHeight: number;
5
- optionPadding: number;
6
- optionListPadding: number;
7
- optionListSpacing: number;
5
+ sectionSpacing: number;
6
+ optionSpacing: number;
7
+ optionHorizontalMargin: number;
8
8
  searchBarMarginTopSpacing: number;
9
9
  searchBarHorizontalSpacing: number;
10
10
  searchBarBottomSpacing: number;
package/types/types.d.ts CHANGED
@@ -5,4 +5,5 @@ import { TabType } from './components/Tabs';
5
5
  import { TextInputProps } from './components/TextInput';
6
6
  import { RichTextEditorRef, RichTextEditorProps, ToolbarButtonName } from './components/RichTextEditor';
7
7
  import { Theme } from './theme';
8
- export type { BottomNavigationTabType, IconName, MultiSelectProps, RichTextEditorProps, RichTextEditorRef, SingleSelectProps, TabType, TextInputProps, Theme, ToolbarButtonName, };
8
+ import { ListRenderOptionInfo, SectionListRenderOptionInfo } from './components/Select/types';
9
+ export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, Theme, ToolbarButtonName, };
@@ -1,52 +0,0 @@
1
- import { StyleProp, ViewStyle } from 'react-native';
2
- import { TextInputProps } from '../TextInput';
3
-
4
- export type OptionType<T> = { value: T; text: string; key?: string };
5
-
6
- export interface SelectProps<T>
7
- extends Pick<
8
- TextInputProps,
9
- 'editable' | 'disabled' | 'numberOfLines' | 'error'
10
- > {
11
- /**
12
- * An array of options to be selected.
13
- */
14
- options: OptionType<T>[];
15
- /**
16
- * Used to extract a unique key for a given option at the specified index. Key is used for caching and as the react key to track item re-ordering.
17
- * The default extractor checks option.key, and then falls back to using the index, like React does.
18
- */
19
- keyExtractor?: (option: OptionType<T>, index?: number) => string;
20
- /**
21
- * Current search value.
22
- */
23
- query?: string;
24
- /**
25
- * Search bar onChangeText event handler
26
- */
27
- onQueryChange?: (value: string) => void;
28
- /**
29
- * Event handler when selection dismiss
30
- */
31
- onDimiss?: () => void;
32
- /**
33
- * Event handler when end of the list reached
34
- */
35
- onEndReached?: () => void;
36
- /**
37
- * Show indicator at bottom of option list
38
- */
39
- loading?: boolean;
40
- /**
41
- * Field label.
42
- */
43
- label: string;
44
- /**
45
- * Additional style.
46
- */
47
- style?: StyleProp<ViewStyle>;
48
- /**
49
- * Testing id of the component.
50
- */
51
- testID?: string;
52
- }