@hero-design/rn 7.16.2 → 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 (51) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +224 -160
  3. package/lib/index.js +223 -159
  4. package/package.json +2 -2
  5. package/src/components/List/BasicListItem.tsx +8 -4
  6. package/src/components/Select/MultiSelect/Option.tsx +20 -11
  7. package/src/components/Select/MultiSelect/OptionList.tsx +47 -41
  8. package/src/components/Select/MultiSelect/__tests__/OptionList.spec.tsx +25 -14
  9. package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +3 -1
  10. package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1612 -108
  11. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5265 -319
  12. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +122 -1
  13. package/src/components/Select/MultiSelect/index.tsx +26 -36
  14. package/src/components/Select/SingleSelect/Option.tsx +19 -3
  15. package/src/components/Select/SingleSelect/OptionList.tsx +47 -39
  16. package/src/components/Select/SingleSelect/__tests__/OptionList.spec.tsx +23 -12
  17. package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +3 -1
  18. package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +1612 -108
  19. package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4898 -268
  20. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +117 -1
  21. package/src/components/Select/SingleSelect/index.tsx +26 -37
  22. package/src/components/Select/StyledOptionList.tsx +43 -44
  23. package/src/components/Select/StyledSelect.tsx +7 -3
  24. package/src/components/Select/__tests__/StyledSelect.spec.tsx +1 -9
  25. package/src/components/Select/__tests__/__snapshots__/StyledSelect.spec.tsx.snap +0 -13
  26. package/src/components/Select/__tests__/helpers.spec.tsx +74 -0
  27. package/src/components/Select/helpers.tsx +87 -4
  28. package/src/components/Select/types.ts +99 -0
  29. package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +157 -1
  30. package/src/components/TextInput/__tests__/index.spec.tsx +29 -8
  31. package/src/components/TextInput/index.tsx +18 -7
  32. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +3 -3
  33. package/src/theme/components/select.ts +3 -3
  34. package/src/types.ts +7 -1
  35. package/types/components/List/BasicListItem.d.ts +1 -1
  36. package/types/components/Select/MultiSelect/Option.d.ts +4 -2
  37. package/types/components/Select/MultiSelect/OptionList.d.ts +6 -7
  38. package/types/components/Select/MultiSelect/index.d.ts +5 -5
  39. package/types/components/Select/SingleSelect/Option.d.ts +4 -2
  40. package/types/components/Select/SingleSelect/OptionList.d.ts +6 -7
  41. package/types/components/Select/SingleSelect/index.d.ts +5 -5
  42. package/types/components/Select/StyledOptionList.d.ts +10 -16
  43. package/types/components/Select/StyledSelect.d.ts +8 -2
  44. package/types/components/Select/__tests__/helpers.spec.d.ts +1 -0
  45. package/types/components/Select/helpers.d.ts +14 -2
  46. package/types/components/Select/index.d.ts +1 -1
  47. package/types/components/Select/types.d.ts +32 -7
  48. package/types/components/TextInput/index.d.ts +4 -2
  49. package/types/theme/components/select.d.ts +3 -3
  50. package/types/types.d.ts +2 -1
  51. package/src/components/Select/types.tsx +0 -52
@@ -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,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
- }