@hero-design/rn 7.20.1 → 7.21.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 (92) hide show
  1. package/.eslintrc.json +1 -0
  2. package/.turbo/turbo-build.log +2 -2
  3. package/es/index.js +370 -237
  4. package/lib/index.js +370 -234
  5. package/package.json +4 -2
  6. package/rollup.config.js +1 -0
  7. package/src/components/BottomSheet/index.tsx +6 -1
  8. package/src/components/Checkbox/__tests__/__snapshots__/StyledCheckbox.spec.tsx.snap +4 -4
  9. package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +13 -13
  10. package/src/components/Empty/StyledEmpty.tsx +1 -9
  11. package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +58 -5
  12. package/src/components/Empty/__tests__/index.spec.tsx +13 -0
  13. package/src/components/Empty/index.tsx +38 -18
  14. package/src/components/Image/__tests__/__snapshots__/index.spec.tsx.snap +81 -0
  15. package/src/components/Image/__tests__/index.spec.tsx +29 -0
  16. package/src/components/Image/index.tsx +46 -0
  17. package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -5
  18. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +60 -60
  19. package/src/components/RichTextEditor/__tests__/__snapshots__/EditorToolbar.spec.tsx.snap +2 -2
  20. package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -2
  21. package/src/components/Select/MultiSelect/OptionList.tsx +4 -6
  22. package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +21 -0
  23. package/src/components/Select/MultiSelect/index.tsx +33 -3
  24. package/src/components/Select/SingleSelect/OptionList.tsx +4 -5
  25. package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +16 -0
  26. package/src/components/Select/SingleSelect/index.tsx +34 -4
  27. package/src/components/Select/StyledOptionList.tsx +3 -9
  28. package/src/components/Slider/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
  29. package/src/components/Slider/__tests__/index.spec.tsx +33 -0
  30. package/src/components/Slider/index.tsx +89 -0
  31. package/src/components/Switch/StyledSwitch.tsx +4 -4
  32. package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -10
  33. package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -8
  34. package/src/components/Switch/index.tsx +5 -4
  35. package/src/components/TextInput/index.tsx +43 -37
  36. package/src/index.ts +4 -0
  37. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +56 -11
  38. package/src/theme/components/alert.ts +1 -2
  39. package/src/theme/components/avatar.ts +8 -8
  40. package/src/theme/components/badge.ts +4 -4
  41. package/src/theme/components/bottomNavigation.ts +1 -1
  42. package/src/theme/components/bottomSheet.ts +2 -3
  43. package/src/theme/components/calendar.ts +9 -7
  44. package/src/theme/components/card.ts +1 -1
  45. package/src/theme/components/checkbox.ts +2 -5
  46. package/src/theme/components/datePicker.ts +3 -3
  47. package/src/theme/components/drawer.ts +2 -3
  48. package/src/theme/components/empty.ts +3 -8
  49. package/src/theme/components/fab.ts +2 -2
  50. package/src/theme/components/image.ts +12 -0
  51. package/src/theme/components/pinInput.ts +3 -3
  52. package/src/theme/components/progress.ts +2 -3
  53. package/src/theme/components/radio.ts +7 -3
  54. package/src/theme/components/richTextEditor.ts +4 -4
  55. package/src/theme/components/slider.ts +13 -0
  56. package/src/theme/components/switch.ts +16 -1
  57. package/src/theme/components/tabs.ts +1 -1
  58. package/src/theme/components/timePicker.ts +3 -3
  59. package/src/theme/components/toast.ts +1 -2
  60. package/src/theme/getTheme.ts +9 -2
  61. package/src/theme/global/colors/swag.ts +2 -0
  62. package/src/theme/global/colors/types.ts +2 -0
  63. package/src/theme/global/index.ts +3 -0
  64. package/src/theme/global/scale.ts +3 -0
  65. package/src/theme/global/sizes.ts +29 -0
  66. package/testUtils/setup.tsx +14 -0
  67. package/types/components/BottomSheet/index.d.ts +5 -1
  68. package/types/components/Empty/StyledEmpty.d.ts +1 -7
  69. package/types/components/Empty/index.d.ts +8 -2
  70. package/types/components/Image/__tests__/index.spec.d.ts +1 -0
  71. package/types/components/Image/index.d.ts +17 -0
  72. package/types/components/Select/MultiSelect/OptionList.d.ts +5 -2
  73. package/types/components/Select/MultiSelect/index.d.ts +7 -1
  74. package/types/components/Select/SingleSelect/OptionList.d.ts +5 -2
  75. package/types/components/Select/SingleSelect/index.d.ts +8 -2
  76. package/types/components/Select/StyledOptionList.d.ts +4 -3
  77. package/types/components/Select/index.d.ts +1 -1
  78. package/types/components/Slider/__tests__/index.spec.d.ts +1 -0
  79. package/types/components/Slider/index.d.ts +52 -0
  80. package/types/components/TextInput/index.d.ts +2 -1
  81. package/types/index.d.ts +3 -1
  82. package/types/theme/components/datePicker.d.ts +2 -1
  83. package/types/theme/components/empty.d.ts +2 -5
  84. package/types/theme/components/image.d.ts +8 -0
  85. package/types/theme/components/slider.d.ts +9 -0
  86. package/types/theme/components/switch.d.ts +14 -1
  87. package/types/theme/components/timePicker.d.ts +2 -1
  88. package/types/theme/getTheme.d.ts +4 -0
  89. package/types/theme/global/colors/types.d.ts +2 -0
  90. package/types/theme/global/index.d.ts +3 -0
  91. package/types/theme/global/scale.d.ts +1 -0
  92. package/types/theme/global/sizes.d.ts +14 -0
@@ -1,8 +1,11 @@
1
+ import React from 'react';
2
+ import type { SectionList } from 'react-native';
1
3
  import type { SingleSelectProps } from '.';
2
- import type { OptionType, SectionData } from '../types';
4
+ import type { OptionType, SectionData, SectionType } from '../types';
3
5
  declare type OptionListProps<V, T extends OptionType<V>> = Pick<SingleSelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange' | 'value' | 'renderOption'> & {
4
6
  onPress: (value: V | null) => void;
5
7
  sections: SectionData<V, T>[];
8
+ sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
6
9
  };
7
- declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, }: OptionListProps<V, T>) => JSX.Element;
10
+ declare const OptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onPress, onQueryChange, sections, renderOption, value, sectionListRef, }: OptionListProps<V, T>) => JSX.Element;
8
11
  export default OptionList;
@@ -1,3 +1,5 @@
1
+ import React from 'react';
2
+ import type { TextInputProps as NativeTextInputProps } from 'react-native';
1
3
  import type { OptionType, SelectProps } from '../types';
2
4
  export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>> extends SelectProps<V, T> {
3
5
  /**
@@ -5,9 +7,13 @@ export interface SingleSelectProps<V, T extends OptionType<V> = OptionType<V>> e
5
7
  */
6
8
  value: V | null;
7
9
  /**
8
- * on select event handler
10
+ * On select event handler
9
11
  */
10
12
  onConfirm: (value: V | null) => void;
13
+ /**
14
+ * Customise the selected value rendering.
15
+ */
16
+ renderSelectedValue?: (selectedValue: V | null, inputProps: NativeTextInputProps) => React.ReactNode;
11
17
  }
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;
18
+ declare const SingleSelect: <V, T extends OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element;
13
19
  export default SingleSelect;
@@ -1,11 +1,12 @@
1
+ import React from 'react';
2
+ import { SectionList } from 'react-native';
1
3
  import type { ReactElement } from 'react';
2
4
  import type { SectionListRenderItemInfo } from 'react-native';
3
- import type { ScrollParams } from './helpers';
4
5
  import type { SectionData, OptionType, SelectProps, SectionType } from './types';
5
6
  export declare type StyledOptionListProps<V, T extends OptionType<V>> = Pick<SelectProps<V, T>, 'keyExtractor' | 'loading' | 'onEndReached' | 'onQueryChange'> & {
6
- scrollParams: ScrollParams;
7
7
  sections: SectionData<V, T>[];
8
8
  renderItem: (info: SectionListRenderItemInfo<T, SectionType>) => ReactElement;
9
+ sectionListRef?: React.RefObject<SectionList<T, SectionType>>;
9
10
  };
10
- declare const StyledOptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onQueryChange, sections, renderItem, scrollParams, }: StyledOptionListProps<V, T>) => JSX.Element;
11
+ declare const StyledOptionList: <V, T extends OptionType<V>>({ keyExtractor, loading, onEndReached, onQueryChange, sections, renderItem, sectionListRef, }: StyledOptionListProps<V, T>) => JSX.Element;
11
12
  export default StyledOptionList;
@@ -2,7 +2,7 @@ import MultiSelect from './MultiSelect';
2
2
  import type { MultiSelectProps } from './MultiSelect';
3
3
  import type { SingleSelectProps } from './SingleSelect';
4
4
  export type { MultiSelectProps, SingleSelectProps };
5
- 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) & {
5
+ declare const _default: (<V, T extends import("./types").OptionType<V>>({ label, loading, inputProps, onConfirm, onDimiss, onEndReached, onQueryChange, options, renderOption, renderSelectedValue, query, error, editable, disabled, numberOfLines, style, testID, value, }: SingleSelectProps<V, T>) => JSX.Element) & {
6
6
  Multi: typeof MultiSelect;
7
7
  };
8
8
  export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,52 @@
1
+ import { StyleProp, ViewStyle } from 'react-native';
2
+ export interface SliderProps {
3
+ /**
4
+ * Minimum value of the slider.
5
+ * Defaults to 0.
6
+ */
7
+ minimumValue?: number;
8
+ /**
9
+ * Maximum value of the slider.
10
+ * Defaults to 1.
11
+ */
12
+ maximumValue?: number;
13
+ /**
14
+ * Step value of the slider.
15
+ * The value should be between 0 and (maximumValue - minimumValue).
16
+ * Defaults to 0.
17
+ */
18
+ step?: number;
19
+ /**
20
+ * Value of the slider.
21
+ * Defaults to 0.
22
+ */
23
+ value?: number;
24
+ /**
25
+ * Callback continuously called while the user is dragging the slider.
26
+ */
27
+ onValueChange?: (value: number) => void;
28
+ /**
29
+ * Callback that is called when the user picks up the slider.
30
+ * The initial value is passed as an argument to the callback handler.
31
+ */
32
+ onSlidingStart?: (value: number) => void;
33
+ /**
34
+ * Callback that is called when the user releases the slider, regardless if the value has changed.
35
+ * The current value is passed as an argument to the callback handler.
36
+ */
37
+ onSlidingComplete?: (value: number) => void;
38
+ /**
39
+ * Whether the slider is disabled.
40
+ */
41
+ disabled?: boolean;
42
+ /**
43
+ * Additional style.
44
+ */
45
+ style?: StyleProp<ViewStyle>;
46
+ /**
47
+ * Testing id of the component.
48
+ */
49
+ testID?: string;
50
+ }
51
+ export declare const Slider: ({ minimumValue, maximumValue, step, value, onValueChange, onSlidingStart, onSlidingComplete, disabled, style, testID, }: SliderProps) => JSX.Element;
52
+ export default Slider;
@@ -51,6 +51,7 @@ export interface TextInputProps extends NativeTextInputProps {
51
51
  loading?: boolean;
52
52
  maxLength?: number;
53
53
  helpText?: string;
54
+ renderInputValue?: (inputProps: NativeTextInputProps) => React.ReactNode;
54
55
  }
55
56
  export declare const getVariant: ({ disabled, error, editable, loading, isFocused, isEmptyValue, }: {
56
57
  disabled?: boolean;
@@ -60,5 +61,5 @@ export declare const getVariant: ({ disabled, error, editable, loading, isFocuse
60
61
  isFocused?: boolean;
61
62
  isEmptyValue?: boolean;
62
63
  }) => Variant;
63
- declare const TextInput: ({ label, prefix, suffix, style, textStyle, testID, accessibilityLabelledBy, error, required, editable, disabled, loading, maxLength, helpText, value, defaultValue, ...nativeProps }: TextInputProps) => JSX.Element;
64
+ declare const TextInput: ({ label, prefix, suffix, style, textStyle, testID, accessibilityLabelledBy, error, required, editable, disabled, loading, maxLength, helpText, value, defaultValue, renderInputValue, ...nativeProps }: TextInputProps) => JSX.Element;
64
65
  export default TextInput;
package/types/index.d.ts CHANGED
@@ -19,9 +19,11 @@ import Drawer from './components/Drawer';
19
19
  import Empty from './components/Empty';
20
20
  import FAB from './components/FAB';
21
21
  import Icon from './components/Icon';
22
+ import Image from './components/Image';
22
23
  import List from './components/List';
23
24
  import PinInput from './components/PinInput';
24
25
  import Progress from './components/Progress';
26
+ import Slider from './components/Slider';
25
27
  import Spinner from './components/Spinner';
26
28
  import Radio from './components/Radio';
27
29
  import SectionHeading from './components/SectionHeading';
@@ -35,5 +37,5 @@ import Toast from './components/Toast';
35
37
  import Toolbar from './components/Toolbar';
36
38
  import Typography from './components/Typography';
37
39
  import RichTextEditor from './components/RichTextEditor';
38
- export { theme, getTheme, useTheme, scale, ThemeProvider, swagSystemPalette, workSystemPalette, Accordion, Alert, Avatar, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, FAB, Icon, List, PinInput, Progress, Spinner, Radio, SectionHeading, Select, Switch, Tabs, Tag, TextInput, TimePicker, Toast, Toolbar, Typography, RichTextEditor, };
40
+ export { theme, getTheme, useTheme, scale, ThemeProvider, swagSystemPalette, workSystemPalette, Accordion, Alert, Avatar, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, FAB, Icon, Image, List, PinInput, Progress, Slider, Spinner, Radio, SectionHeading, Select, Switch, Tabs, Tag, TextInput, TimePicker, Toast, Toolbar, Typography, RichTextEditor, };
39
41
  export * from './types';
@@ -1,4 +1,5 @@
1
- declare const getDatePickerTheme: () => {
1
+ import { GlobalTheme } from '../global';
2
+ declare const getDatePickerTheme: (theme: GlobalTheme) => {
2
3
  sizes: {
3
4
  height: number;
4
5
  };
@@ -11,19 +11,16 @@ declare const getEmptyTheme: (theme: GlobalTheme) => {
11
11
  illustrationBackground: string;
12
12
  };
13
13
  sizes: {
14
- illustration: number;
14
+ image: number;
15
15
  };
16
16
  space: {
17
17
  titleMargin: number;
18
- illustrationMargin: number;
18
+ imageMargin: number;
19
19
  wrapperPadding: number;
20
20
  };
21
21
  fonts: {
22
22
  title: string;
23
23
  description: string;
24
24
  };
25
- radii: {
26
- illustration: number;
27
- };
28
25
  };
29
26
  export default getEmptyTheme;
@@ -0,0 +1,8 @@
1
+ import type { GlobalTheme } from '../global';
2
+ declare const getImageTheme: (theme: GlobalTheme) => {
3
+ sizes: {
4
+ '6xlarge': number;
5
+ '15xlarge': number;
6
+ };
7
+ };
8
+ export default getImageTheme;
@@ -0,0 +1,9 @@
1
+ import type { GlobalTheme } from '../global';
2
+ declare const getSliderTheme: (theme: GlobalTheme) => {
3
+ colors: {
4
+ minimumTrackTint: string;
5
+ thumbTint: string;
6
+ maximumTrackTint: string;
7
+ };
8
+ };
9
+ export default getSliderTheme;
@@ -9,6 +9,20 @@ declare const getSwitchTheme: (theme: GlobalTheme) => {
9
9
  };
10
10
  thumb: string;
11
11
  };
12
+ sizes: {
13
+ thumbs: {
14
+ small: number;
15
+ medium: number;
16
+ };
17
+ widths: {
18
+ small: number;
19
+ medium: number;
20
+ };
21
+ heights: {
22
+ small: number;
23
+ medium: number;
24
+ };
25
+ };
12
26
  thumbSizes: {
13
27
  small: number;
14
28
  medium: number;
@@ -24,7 +38,6 @@ declare const getSwitchTheme: (theme: GlobalTheme) => {
24
38
  spaces: {
25
39
  small: number;
26
40
  medium: number;
27
- inactive: number;
28
41
  };
29
42
  radii: {
30
43
  rounded: number;
@@ -1,4 +1,5 @@
1
- declare const getTimePickerTheme: () => {
1
+ import { GlobalTheme } from '../global';
2
+ declare const getTimePickerTheme: (theme: GlobalTheme) => {
2
3
  sizes: {
3
4
  height: number;
4
5
  };
@@ -15,6 +15,7 @@ import getDrawerTheme from './components/drawer';
15
15
  import getEmptyTheme from './components/empty';
16
16
  import getFABTheme from './components/fab';
17
17
  import getIconTheme from './components/icon';
18
+ import getImageTheme from './components/image';
18
19
  import getListTheme from './components/list';
19
20
  import getPinInputTheme from './components/pinInput';
20
21
  import getProgressTheme from './components/progress';
@@ -22,6 +23,7 @@ import getRadioTheme from './components/radio';
22
23
  import getRichTextEditorTheme from './components/richTextEditor';
23
24
  import getSectionHeadingTheme from './components/sectionHeading';
24
25
  import getSelectTheme from './components/select';
26
+ import getSliderTheme from './components/slider';
25
27
  import getSpinnerTheme from './components/spinner';
26
28
  import getSwitchTheme from './components/switch';
27
29
  import getTabsTheme from './components/tabs';
@@ -51,6 +53,7 @@ declare type Theme = GlobalTheme & {
51
53
  empty: ReturnType<typeof getEmptyTheme>;
52
54
  fab: ReturnType<typeof getFABTheme>;
53
55
  icon: ReturnType<typeof getIconTheme>;
56
+ image: ReturnType<typeof getImageTheme>;
54
57
  list: ReturnType<typeof getListTheme>;
55
58
  pinInput: ReturnType<typeof getPinInputTheme>;
56
59
  progress: ReturnType<typeof getProgressTheme>;
@@ -58,6 +61,7 @@ declare type Theme = GlobalTheme & {
58
61
  richTextEditor: ReturnType<typeof getRichTextEditorTheme>;
59
62
  sectionHeading: ReturnType<typeof getSectionHeadingTheme>;
60
63
  select: ReturnType<typeof getSelectTheme>;
64
+ slider: ReturnType<typeof getSliderTheme>;
61
65
  spinner: ReturnType<typeof getSpinnerTheme>;
62
66
  switch: ReturnType<typeof getSwitchTheme>;
63
67
  tabs: ReturnType<typeof getTabsTheme>;
@@ -44,6 +44,7 @@ export declare type SystemPalette = {
44
44
  shadow: string;
45
45
  __alpha__globalPrimary: string;
46
46
  __alpha__globalSecondary1: string;
47
+ __alpha__globalSecondary4: string;
47
48
  __alpha__globalNeutral3: string;
48
49
  __alpha__globalLabel1: string;
49
50
  __alpha__globalLabel2: string;
@@ -54,6 +55,7 @@ export declare type SystemPalette = {
54
55
  __alpha__globalLabel7: string;
55
56
  __alpha__globalLabel8: string;
56
57
  __alpha__globalLabel9: string;
58
+ __alpha__primary1: string;
57
59
  __alpha__primary2: string;
58
60
  __alpha__secondary1: string;
59
61
  __alpha__secondary2: string;
@@ -50,6 +50,7 @@ declare const getGlobalTheme: (scale: Scale, systemPalette: SystemPalette) => {
50
50
  shadow: string;
51
51
  __alpha__globalPrimary: string;
52
52
  __alpha__globalSecondary1: string;
53
+ __alpha__globalSecondary4: string;
53
54
  __alpha__globalNeutral3: string;
54
55
  __alpha__globalLabel1: string;
55
56
  __alpha__globalLabel2: string;
@@ -60,6 +61,7 @@ declare const getGlobalTheme: (scale: Scale, systemPalette: SystemPalette) => {
60
61
  __alpha__globalLabel7: string;
61
62
  __alpha__globalLabel8: string;
62
63
  __alpha__globalLabel9: string;
64
+ __alpha__primary1: string;
63
65
  __alpha__primary2: string;
64
66
  __alpha__secondary1: string;
65
67
  __alpha__secondary2: string;
@@ -71,6 +73,7 @@ declare const getGlobalTheme: (scale: Scale, systemPalette: SystemPalette) => {
71
73
  lineHeights: import("./typography").FontSizes;
72
74
  borderWidths: import("./borders").BorderWidths;
73
75
  space: import("./space").Space;
76
+ sizes: import("./sizes").Sizes;
74
77
  radii: import("./borders").Radii;
75
78
  };
76
79
  declare type GlobalTheme = ReturnType<typeof getGlobalTheme>;
@@ -1,6 +1,7 @@
1
1
  declare const scale: {
2
2
  borderWidth: number;
3
3
  space: number;
4
+ size: number;
4
5
  font: string;
5
6
  fontSize: number;
6
7
  radius: number;
@@ -0,0 +1,14 @@
1
+ import type { Space } from './space';
2
+ interface Sizes extends Space {
3
+ xxxxxlarge: number;
4
+ '6xlarge': number;
5
+ '7xlarge': number;
6
+ '9xlarge': number;
7
+ '14xlarge': number;
8
+ '15xlarge': number;
9
+ '18xlarge': number;
10
+ '19xlarge': number;
11
+ }
12
+ declare const getSizes: (baseSize: number) => Sizes;
13
+ export { getSizes };
14
+ export type { Sizes };