@hero-design/rn 7.16.1 → 7.17.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 (54) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +228 -187
  3. package/lib/index.js +227 -186
  4. package/package.json +2 -2
  5. package/src/components/DatePicker/DatePickerIOS.tsx +2 -2
  6. package/src/components/List/BasicListItem.tsx +8 -4
  7. package/src/components/List/StyledBasicListItem.tsx +2 -2
  8. package/src/components/Select/MultiSelect/Option.tsx +21 -15
  9. package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
  10. package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
  11. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +41 -21
  12. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1995 -352
  13. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5611 -523
  14. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
  15. package/src/components/Select/MultiSelect/index.tsx +26 -36
  16. package/src/components/Select/SingleSelect/Option.tsx +20 -13
  17. package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
  18. package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
  19. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +23 -14
  20. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1846 -258
  21. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +5140 -412
  22. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
  23. package/src/components/Select/SingleSelect/index.tsx +26 -37
  24. package/src/components/Select/StyledOptionList.tsx +43 -44
  25. package/src/components/Select/StyledSelect.tsx +6 -15
  26. package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -23
  27. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -67
  28. package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
  29. package/src/components/Select/helpers.tsx +87 -4
  30. package/src/components/Select/types.ts +99 -0
  31. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
  32. package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
  33. package/src/components/TextInput/index.tsx +18 -7
  34. package/src/components/TimePicker/TimePickerIOS.tsx +2 -2
  35. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -5
  36. package/src/theme/components/select.ts +3 -5
  37. package/src/types.ts +7 -1
  38. package/types/components/List/BasicListItem.d.ts +1 -1
  39. package/types/components/Select/MultiSelect/Option.d.ts +4 -2
  40. package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
  41. package/types/components/Select/MultiSelect/index.d.ts +5 -5
  42. package/types/components/Select/SingleSelect/Option.d.ts +4 -2
  43. package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
  44. package/types/components/Select/SingleSelect/index.d.ts +5 -5
  45. package/types/components/Select/StyledOptionList.d.ts +10 -16
  46. package/types/components/Select/StyledSelect.d.ts +5 -7
  47. package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
  48. package/types/components/Select/helpers.d.ts +14 -2
  49. package/types/components/Select/index.d.ts +1 -1
  50. package/types/components/Select/types.d.ts +32 -7
  51. package/types/components/TextInput/index.d.ts +4 -2
  52. package/types/theme/components/select.d.ts +3 -5
  53. package/types/types.d.ts +2 -1
  54. package/src/components/Select/types.tsx +0 -52
@@ -1,13 +1,11 @@
1
- import { View, TouchableOpacity } from 'react-native';
2
- declare const OptionWrapper: import("@emotion/native").StyledComponent<import("react-native").TouchableOpacityProps & {
1
+ import { View } from 'react-native';
2
+ declare const SectionSpacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
3
3
  theme?: import("@emotion/react").Theme | undefined;
4
4
  as?: import("react").ElementType<any> | undefined;
5
- } & {
6
- themeSelected: boolean;
7
5
  }, {}, {
8
- ref?: import("react").Ref<TouchableOpacity> | undefined;
6
+ ref?: import("react").Ref<View> | undefined;
9
7
  }>;
10
- declare const Spacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
8
+ declare const OptionSpacer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
11
9
  theme?: import("@emotion/react").Theme | undefined;
12
10
  as?: import("react").ElementType<any> | undefined;
13
11
  }, {}, {
@@ -23,4 +21,4 @@ declare const StyledSearchBar: import("@emotion/native").StyledComponent<import(
23
21
  }, {}, {
24
22
  ref?: import("react").Ref<View> | undefined;
25
23
  }>;
26
- export { OptionWrapper, 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;
@@ -2,16 +2,14 @@ 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;
11
11
  };
12
12
  colors: {
13
- option: string;
14
- checkedOption: string;
15
13
  footerText: string;
16
14
  };
17
15
  radii: {
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
- }