@hero-design/rn 8.94.0 → 8.97.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 (73) hide show
  1. package/.turbo/turbo-build.log +7 -2
  2. package/CHANGELOG.md +18 -0
  3. package/es/index.js +1744 -1322
  4. package/lib/index.js +1747 -1324
  5. package/locales/en_AU.js +10 -0
  6. package/locales/en_AU.mjs +8 -0
  7. package/locales/en_CA.js +10 -0
  8. package/locales/en_CA.mjs +8 -0
  9. package/locales/index.js +11 -0
  10. package/locales/index.mjs +9 -0
  11. package/locales/types.js +2 -0
  12. package/locales/types.mjs +1 -0
  13. package/package.json +4 -3
  14. package/rollup.config.mjs +97 -58
  15. package/src/components/DatePicker/DatePickerAndroid.tsx +34 -40
  16. package/src/components/DatePicker/DatePickerCalendar.tsx +23 -4
  17. package/src/components/DatePicker/DatePickerIOS.tsx +36 -67
  18. package/src/components/DatePicker/Dialog/AndroidDialog.tsx +68 -0
  19. package/src/components/DatePicker/Dialog/IOSDialog.tsx +91 -0
  20. package/src/components/DatePicker/Dialog/__tests__/AndroidDialog.spec.tsx +70 -0
  21. package/src/components/DatePicker/Dialog/__tests__/IOSDialog.spec.tsx +114 -0
  22. package/src/components/DatePicker/Dialog/type.ts +50 -0
  23. package/src/components/DatePicker/__tests__/DatePicker.spec.tsx +30 -1
  24. package/src/components/DatePicker/__tests__/DatePickerAndroid.spec.tsx +27 -0
  25. package/src/components/DatePicker/__tests__/DatePickerCalendar.spec.tsx +27 -0
  26. package/src/components/DatePicker/__tests__/DatePickerIOS.spec.tsx +28 -1
  27. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +18 -9
  28. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +1 -0
  29. package/src/components/DatePicker/hooks/__tests__/useFormatDate.spec.ts +61 -0
  30. package/src/components/DatePicker/{useCalculateDate.tsx → hooks/useCalculateDate.tsx} +1 -1
  31. package/src/components/DatePicker/hooks/useFormatDate.ts +25 -0
  32. package/src/components/DatePicker/hooks/utils.ts +30 -0
  33. package/src/components/DatePicker/index.tsx +12 -1
  34. package/src/components/DatePicker/types.ts +15 -1
  35. package/src/components/HeroDesignProvider/index.tsx +19 -6
  36. package/src/components/LocaleProvider/__tests__/utils.specs.ts +12 -0
  37. package/src/components/LocaleProvider/context.ts +7 -0
  38. package/src/components/LocaleProvider/hooks.ts +19 -0
  39. package/src/components/LocaleProvider/index.tsx +27 -0
  40. package/src/components/LocaleProvider/utils.ts +14 -0
  41. package/src/index.ts +2 -0
  42. package/src/locales/en_AU.ts +10 -0
  43. package/src/locales/en_CA.ts +10 -0
  44. package/src/locales/index.ts +7 -0
  45. package/src/locales/types.ts +12 -0
  46. package/src/testHelpers/renderWithTheme.tsx +7 -1
  47. package/src/types.ts +4 -0
  48. package/stats/8.95.0/rn-stats.html +4842 -0
  49. package/stats/8.96.0/rn-stats.html +4842 -0
  50. package/stats/8.97.0/rn-stats.html +4842 -0
  51. package/types/components/DatePicker/DatePickerAndroid.d.ts +1 -1
  52. package/types/components/DatePicker/DatePickerCalendar.d.ts +1 -1
  53. package/types/components/DatePicker/DatePickerIOS.d.ts +1 -1
  54. package/types/components/DatePicker/Dialog/AndroidDialog.d.ts +5 -0
  55. package/types/components/DatePicker/Dialog/IOSDialog.d.ts +4 -0
  56. package/types/components/DatePicker/Dialog/type.d.ts +50 -0
  57. package/types/components/DatePicker/{useCalculateDate.d.ts → hooks/useCalculateDate.d.ts} +1 -1
  58. package/types/components/DatePicker/hooks/useFormatDate.d.ts +10 -0
  59. package/types/components/DatePicker/hooks/utils.d.ts +6 -0
  60. package/types/components/DatePicker/index.d.ts +5 -2
  61. package/types/components/DatePicker/types.d.ts +8 -1
  62. package/types/components/HeroDesignProvider/index.d.ts +5 -1
  63. package/types/components/LocaleProvider/__tests__/utils.specs.d.ts +1 -0
  64. package/types/components/LocaleProvider/context.d.ts +3 -0
  65. package/types/components/LocaleProvider/hooks.d.ts +5 -0
  66. package/types/components/LocaleProvider/index.d.ts +7 -0
  67. package/types/components/LocaleProvider/utils.d.ts +3 -0
  68. package/types/index.d.ts +2 -1
  69. package/types/locales/en_AU.d.ts +3 -0
  70. package/types/locales/en_CA.d.ts +3 -0
  71. package/types/locales/index.d.ts +5 -0
  72. package/types/locales/types.d.ts +10 -0
  73. package/types/types.d.ts +2 -1
@@ -3,5 +3,5 @@ import type { DatePickerProps } from './types';
3
3
  type DatePickerAndroidProps = Omit<DatePickerProps, 'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'> & {
4
4
  variant?: 'default' | 'month-year';
5
5
  };
6
- declare const DatePickerAndroid: ({ value, minDate, maxDate, label, placeholder, onChange, displayFormat, disabled, required, error, helpText, style, testID, variant, }: DatePickerAndroidProps) => React.JSX.Element;
6
+ declare const DatePickerAndroid: ({ value, minDate, maxDate, label, placeholder, onChange, displayFormat, disabled, required, error, helpText, style, testID, variant, renderSelectedValue, locale, }: DatePickerAndroidProps) => React.JSX.Element;
7
7
  export default DatePickerAndroid;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { DatePickerProps } from './types';
3
- declare const DatePickerCalendar: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, monthPickerConfirmLabel, monthPickerCancelLabel, supportedOrientations, }: Omit<DatePickerProps, "variant">) => React.JSX.Element;
3
+ declare const DatePickerCalendar: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, monthPickerConfirmLabel, monthPickerCancelLabel, supportedOrientations, renderSelectedValue, locale, }: Omit<DatePickerProps, "variant">) => React.JSX.Element;
4
4
  export default DatePickerCalendar;
@@ -3,5 +3,5 @@ import type { DatePickerProps } from './types';
3
3
  type DatePickerIOSProps = Omit<DatePickerProps, 'variant' | 'monthPickerConfirmLabel' | 'monthPickerCancelLabel'> & {
4
4
  variant?: 'default' | 'month-year';
5
5
  };
6
- declare const DatePickerIOS: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, supportedOrientations, variant, locale, }: DatePickerIOSProps) => React.JSX.Element;
6
+ declare const DatePickerIOS: ({ value, minDate, maxDate, label, placeholder, onChange, confirmLabel, displayFormat, disabled, required, error, helpText, style, testID, supportedOrientations, variant, locale, renderSelectedValue, }: DatePickerIOSProps) => React.JSX.Element;
7
7
  export default DatePickerIOS;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { DatePickerDialogProps } from './type';
3
+ export type AndroidDatePickerDialogProps = Omit<DatePickerDialogProps, 'supportedOrientations' | 'confirmLabel' | 'label' | 'locale'>;
4
+ declare const AndroidDatePickerDialog: ({ open, onClose, value, minDate, maxDate, onChange, testID, variant, }: AndroidDatePickerDialogProps) => React.JSX.Element | null;
5
+ export default AndroidDatePickerDialog;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { DatePickerDialogProps } from './type';
3
+ declare const IOSDatePickerDialog: ({ label, open, onClose, confirmLabel, locale, value, minDate, maxDate, onChange, testID, variant, supportedOrientations, }: DatePickerDialogProps) => React.JSX.Element;
4
+ export default IOSDatePickerDialog;
@@ -0,0 +1,50 @@
1
+ export interface DatePickerDialogProps {
2
+ /**
3
+ * The value of the date picker.
4
+ */
5
+ value?: Date;
6
+ /**
7
+ * The minimum date of the date picker.
8
+ */
9
+ minDate?: Date;
10
+ /**
11
+ * The maximum date of the date picker.
12
+ */
13
+ maxDate?: Date;
14
+ /**
15
+ * The function to call when the date is changed.
16
+ */
17
+ onChange: (date: Date) => void;
18
+ /**
19
+ * The test ID of the date picker.
20
+ */
21
+ testID?: string;
22
+ /**
23
+ * Whether the dialog is open
24
+ */
25
+ open: boolean;
26
+ /**
27
+ * The function to call when the dialog is closed.
28
+ */
29
+ onClose: () => void;
30
+ /**
31
+ * The variant of the date picker.
32
+ */
33
+ variant?: 'default' | 'month-year';
34
+ /**
35
+ * [iOS only] The label of the DatePicker bottom sheet.
36
+ */
37
+ label: string;
38
+ /**
39
+ * [iOS only] The confirm label of the date picker bottom sheet.
40
+ */
41
+ confirmLabel: string;
42
+ /**
43
+ * [iOS only] The supported orientations of the date picker.
44
+ */
45
+ supportedOrientations?: ('portrait' | 'landscape')[];
46
+ /**
47
+ * [iOS only] The locale of the date picker.
48
+ */
49
+ locale?: string;
50
+ }
@@ -1,4 +1,4 @@
1
- import { DatePickerProps } from './types';
1
+ import { DatePickerProps } from '../types';
2
2
  export declare const getDateValue: (value: Date, minDate?: Date | undefined, maxDate?: Date | undefined) => Date;
3
3
  declare const useCalculateDate: ({ maxDate, minDate, onChange, value, }: Pick<DatePickerProps, "maxDate" | "minDate" | "onChange" | "value">) => void;
4
4
  export default useCalculateDate;
@@ -0,0 +1,10 @@
1
+ type UseFormatDateProps = {
2
+ displayFormat?: string;
3
+ locale?: string;
4
+ value?: Date;
5
+ };
6
+ declare const useFormatDate: ({ displayFormat, locale, value, }: UseFormatDateProps) => {
7
+ displayValue: string;
8
+ format: string;
9
+ };
10
+ export default useFormatDate;
@@ -0,0 +1,6 @@
1
+ import { DateTimeFormats } from '../../../types';
2
+ export declare const getDateFormat: ({ displayFormat, locale, localizeDateTime, }: {
3
+ displayFormat?: string;
4
+ locale?: string;
5
+ localizeDateTime: (key: keyof DateTimeFormats) => string;
6
+ }) => string;
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { DatePickerProps } from './types';
3
- declare const DatePicker: ({ variant, ...props }: DatePickerProps) => React.JSX.Element;
4
- export default DatePicker;
3
+ import { DatePickerDialogProps } from './Dialog/type';
4
+ declare const _default: (({ variant, ...props }: DatePickerProps) => React.JSX.Element) & {
5
+ Dialog: ({ ...props }: DatePickerDialogProps) => React.JSX.Element;
6
+ };
7
+ export default _default;
@@ -1,4 +1,4 @@
1
- import type { StyleProp, ViewStyle } from 'react-native';
1
+ import type { TextInputProps as NativeTextInputProps, StyleProp, ViewStyle } from 'react-native';
2
2
  export interface DatePickerProps {
3
3
  /**
4
4
  * Date picker input label.
@@ -84,4 +84,11 @@ export interface DatePickerProps {
84
84
  * [Android only] autoTheme will automatically set the theme based on the device's light mode or dark mode.
85
85
  * */
86
86
  autoTheme?: boolean;
87
+ /**
88
+ * Custom renderer for the selected value. The function provides the current date object and the formatted date string for the current display format.
89
+ */
90
+ renderSelectedValue?: (value: {
91
+ date: Date;
92
+ formattedDateString: string;
93
+ }, props?: NativeTextInputProps) => React.ReactNode;
87
94
  }
@@ -1,4 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ThemeProviderProps } from '../../theme/ThemeProvider';
3
- declare const HeroDesignProvider: ({ theme, children }: ThemeProviderProps) => React.JSX.Element;
3
+ import { LocaleValues } from '../../locales/types';
4
+ interface HeroDesignProviderProps extends ThemeProviderProps {
5
+ locale?: LocaleValues;
6
+ }
7
+ declare const HeroDesignProvider: ({ theme, locale, children, }: HeroDesignProviderProps) => React.JSX.Element;
4
8
  export default HeroDesignProvider;
@@ -0,0 +1,3 @@
1
+ import { LocaleValues } from '../../locales/types';
2
+ declare const LocaleContext: import("react").Context<LocaleValues>;
3
+ export { LocaleContext };
@@ -0,0 +1,5 @@
1
+ import type { DateTimeFormats } from '../../locales/types';
2
+ export declare const useLocale: () => import("../../locales/types").LocaleValues;
3
+ export declare const useDateTimeFormat: () => {
4
+ localizeDateTime: (key: keyof DateTimeFormats) => string;
5
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { LocaleValues } from '../../locales/types';
3
+ interface LocaleProviderProps {
4
+ locale: LocaleValues;
5
+ }
6
+ declare const LocaleProvider: (props: React.PropsWithChildren<LocaleProviderProps>) => React.JSX.Element;
7
+ export default LocaleProvider;
@@ -0,0 +1,3 @@
1
+ import type { Locale } from 'date-fns';
2
+ import { LocaleCode } from '../../locales/types';
3
+ export declare function getDateFnsLocale(locale: LocaleCode): Locale;
package/types/index.d.ts CHANGED
@@ -54,5 +54,6 @@ import Portal from './components/Portal';
54
54
  import { ScrollViewWithFAB, SectionListWithFAB, FlatListWithFAB } from './components/AnimatedScroller';
55
55
  import Search from './components/Search';
56
56
  import FloatingIsland from './components/FloatingIsland';
57
- export { theme, getTheme, useTheme, scale, ThemeProvider, ThemeSwitcher, withTheme, swagSystemPalette, swagLightSystemPalette, swagLightJobsSystemPalette, swagDarkSystemPalette, workSystemPalette, jobsSystemPalette, walletSystemPalette, eBensSystemPalette, ehWorkDarkSystemPalette, ehWorkSystemPalette, ehJobsSystemPalette, Accordion, Alert, AppCue, Attachment, Avatar, useAvatarColors, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Carousel, Chip, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, Error, FAB, FlatListWithFAB, Icon, Image, HeroDesignProvider, MapPin, List, PinInput, Progress, Portal, PageControl, Skeleton, Slider, Spinner, Swipeable, Radio, Search, ScrollViewWithFAB, SectionHeading, SectionListWithFAB, Select, Success, Switch, Tabs, Tag, TextInput, TimePicker, Toast, Toolbar, Typography, Rate, RefreshControl, RichTextEditor, FloatingIsland, };
57
+ import LocaleProvider from './components/LocaleProvider';
58
+ export { theme, getTheme, useTheme, scale, ThemeProvider, ThemeSwitcher, withTheme, swagSystemPalette, swagLightSystemPalette, swagLightJobsSystemPalette, swagDarkSystemPalette, workSystemPalette, jobsSystemPalette, walletSystemPalette, eBensSystemPalette, ehWorkDarkSystemPalette, ehWorkSystemPalette, ehJobsSystemPalette, Accordion, Alert, AppCue, Attachment, Avatar, useAvatarColors, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Carousel, Chip, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, Error, FAB, FlatListWithFAB, Icon, Image, HeroDesignProvider, MapPin, List, PinInput, Progress, Portal, PageControl, Skeleton, Slider, Spinner, Swipeable, Radio, Search, ScrollViewWithFAB, SectionHeading, SectionListWithFAB, Select, Success, Switch, Tabs, Tag, TextInput, TimePicker, Toast, Toolbar, Typography, Rate, RefreshControl, RichTextEditor, FloatingIsland, LocaleProvider, };
58
59
  export * from './types';
@@ -0,0 +1,3 @@
1
+ import { LocaleValues } from './types';
2
+ declare const locale: LocaleValues;
3
+ export default locale;
@@ -0,0 +1,3 @@
1
+ import { LocaleValues } from './types';
2
+ declare const locale: LocaleValues;
3
+ export default locale;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ 'en-AU': import("./types").LocaleValues;
3
+ 'en-CA': import("./types").LocaleValues;
4
+ };
5
+ export default _default;
@@ -0,0 +1,10 @@
1
+ declare const LOCALES: readonly ["en-AU", "en-CA"];
2
+ export type LocaleCode = typeof LOCALES[number];
3
+ export type DateTimeFormats = {
4
+ fullDate: string;
5
+ };
6
+ export type LocaleValues = {
7
+ lang: LocaleCode;
8
+ dateTimeFormats: DateTimeFormats;
9
+ };
10
+ export {};
package/types/types.d.ts CHANGED
@@ -13,4 +13,5 @@ import { FABHandles } from './components/FAB/FAB';
13
13
  import { ActionGroupHandles } from './components/FAB/ActionGroup';
14
14
  import type { SliderRangeValue } from './components/Slider/RangeSlider';
15
15
  import type { CalendarDateRange } from './components/Calendar/CalendarRange';
16
- export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, SwipeableProps, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, TextProps, TextInputHandles, Theme, CardCarouselHandles, FABHandles, ActionGroupHandles, SliderRangeValue, CalendarDateRange, };
16
+ import { LocaleCode, LocaleValues, DateTimeFormats } from './locales/types';
17
+ export type { BottomNavigationTabType, IconName, SingleSelectProps, MultiSelectProps, ListRenderOptionInfo, SectionListRenderOptionInfo, SwipeableProps, RichTextEditorProps, RichTextEditorRef, TabType, TextInputProps, TextProps, TextInputHandles, Theme, CardCarouselHandles, FABHandles, ActionGroupHandles, SliderRangeValue, CalendarDateRange, LocaleCode, LocaleValues, DateTimeFormats, };