@boostdev/design-system-react-native 0.3.0 → 0.5.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.
- package/CHANGELOG.md +44 -0
- package/README.md +10 -0
- package/dist/index.cjs +589 -536
- package/dist/index.d.cts +36 -5
- package/dist/index.d.ts +36 -5
- package/dist/index.js +442 -493
- package/package.json +1 -1
- package/src/components/interaction/Button/Button.spec.tsx +17 -0
- package/src/components/interaction/Button/Button.tsx +8 -2
- package/src/components/interaction/Dialog/Dialog.tsx +2 -9
- package/src/components/interaction/DropdownMenu/DropdownMenu.tsx +2 -13
- package/src/components/interaction/Rating/Rating.tsx +2 -1
- package/src/components/interaction/SideSheet/SideSheet.tsx +2 -11
- package/src/components/interaction/Toast/Toast.tsx +2 -9
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.tsx +2 -1
- package/src/components/interaction/form/Combobox/Combobox.tsx +2 -10
- package/src/components/interaction/form/FileInput/FileInput.tsx +2 -1
- package/src/components/interaction/form/FormInput/FormInput.spec.tsx +11 -9
- package/src/components/interaction/form/FormInput/FormInput.tsx +4 -10
- package/src/components/interaction/form/NumberInput/NumberInput.tsx +2 -9
- package/src/components/interaction/form/RadioGroup/RadioGroup.tsx +2 -1
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.mdx +17 -3
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.spec.tsx +55 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.stories.tsx +9 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.tsx +10 -3
- package/src/components/interaction/form/Select/Select.tsx +2 -11
- package/src/components/interaction/form/Slider/Slider.tsx +2 -9
- package/src/components/interaction/form/Textarea/Textarea.tsx +2 -7
- package/src/components/interaction/form/atoms/Label.tsx +2 -1
- package/src/components/interaction/form/atoms/Message.tsx +2 -1
- package/src/components/layout/SectionHeader/SectionHeader.tsx +2 -1
- package/src/components/ui/Accordion/Accordion.tsx +2 -11
- package/src/components/ui/Alert/Alert.tsx +2 -1
- package/src/components/ui/Avatar/Avatar.tsx +2 -1
- package/src/components/ui/Badge/Badge.spec.tsx +28 -0
- package/src/components/ui/Badge/Badge.tsx +9 -3
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +2 -1
- package/src/components/ui/Calendar/Calendar.tsx +2 -8
- package/src/components/ui/Carousel/Carousel.tsx +2 -12
- package/src/components/ui/Collapsible/Collapsible.tsx +2 -12
- package/src/components/ui/DescriptionList/DescriptionList.tsx +2 -1
- package/src/components/ui/Link/Link.tsx +2 -1
- package/src/components/ui/NotificationBanner/NotificationBanner.tsx +2 -1
- package/src/components/ui/Pagination/Pagination.tsx +2 -1
- package/src/components/ui/Progress/Progress.tsx +2 -1
- package/src/components/ui/ProgressCircle/ProgressCircle.tsx +2 -1
- package/src/components/ui/Table/Table.tsx +2 -9
- package/src/components/ui/Tabs/Tabs.tsx +2 -10
- package/src/components/ui/Tooltip/Tooltip.tsx +2 -1
- package/src/components/ui/Typography/Typography.mdx +2 -0
- package/src/components/ui/Typography/Typography.spec.tsx +59 -0
- package/src/components/ui/Typography/Typography.tsx +18 -2
- package/src/index.ts +2 -0
- package/src/native/ScaledText.guard.spec.ts +25 -0
- package/src/native/ScaledText.spec.tsx +77 -0
- package/src/native/ScaledText.tsx +30 -0
- package/src/native/fontScale.spec.ts +35 -0
- package/src/native/fontScale.ts +15 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
2
3
|
import { ReactNode, ReactElement } from 'react';
|
|
3
4
|
import { colors } from '@boostdev/design-system-foundation/native';
|
|
4
5
|
export { animation, border, colors, font, spacing, zIndex } from '@boostdev/design-system-foundation/native';
|
|
5
|
-
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
6
|
+
import { TextProps, Text, TextInputProps, TextInput, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
6
7
|
|
|
7
8
|
/** Absolute lineHeight values for React Native (ratio × fontSize). */
|
|
8
9
|
declare const lineHeight: {
|
|
@@ -80,21 +81,51 @@ declare function createReactNavigationTheme(options?: CreateReactNavigationTheme
|
|
|
80
81
|
*/
|
|
81
82
|
declare function useReactNavigationTheme(overrides?: Pick<CreateReactNavigationThemeOptions, 'colors' | 'fonts'>): ReactNavigationTheme;
|
|
82
83
|
|
|
84
|
+
/** The ceiling for a text with this style (see `maxFontScaleFor`), unless the caller passes its own. */
|
|
85
|
+
declare function maxFontScaleForStyle(style: StyleProp<TextStyle>, override?: number | null): number;
|
|
86
|
+
/**
|
|
87
|
+
* React Native's `Text` with a ceiling on how far it grows with the OS text size, taken from its
|
|
88
|
+
* own font size. Pass `maxFontSizeMultiplier` to override it, e.g. `1` for text in a fixed shape.
|
|
89
|
+
*/
|
|
90
|
+
declare const ScaledText: react.ForwardRefExoticComponent<TextProps & react.RefAttributes<Text>>;
|
|
91
|
+
/** React Native's `TextInput` with the same ceiling as `ScaledText`. */
|
|
92
|
+
declare const ScaledTextInput: react.ForwardRefExoticComponent<TextInputProps & react.RefAttributes<TextInput>>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* How far text of this size may grow with the OS text size (iOS Dynamic Type, Android font
|
|
96
|
+
* scale), as React Native's `maxFontSizeMultiplier`. Big text grows less: a 16 pt body line may
|
|
97
|
+
* double, a 32 pt heading grows to about 42, and a figure of 60 pt or more (a countdown, a score)
|
|
98
|
+
* stays as it is.
|
|
99
|
+
*/
|
|
100
|
+
declare function maxFontScaleFor(fontSize: number): number;
|
|
101
|
+
|
|
83
102
|
type TypographyVariant = 'h1' | 'h2' | 'h3' | 'body' | 'body_s';
|
|
84
103
|
interface TypographyProps {
|
|
85
104
|
variant?: TypographyVariant;
|
|
86
105
|
children: ReactNode;
|
|
87
106
|
style?: StyleProp<TextStyle>;
|
|
107
|
+
/**
|
|
108
|
+
* Overrides the ceiling on how far the text grows with the OS text size (default: from its
|
|
109
|
+
* font size, see `maxFontScaleFor`). `1` keeps the text at its own size.
|
|
110
|
+
*/
|
|
111
|
+
maxFontSizeMultiplier?: number;
|
|
112
|
+
/** Truncates the text with an ellipsis after this many lines. */
|
|
113
|
+
numberOfLines?: number;
|
|
88
114
|
}
|
|
89
|
-
declare function Typography({ variant, children, style }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare function Typography({ variant, children, style, maxFontSizeMultiplier, numberOfLines, }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
90
116
|
|
|
91
117
|
type BadgeVariant = 'primary' | 'secondary' | 'success' | 'error' | 'warning';
|
|
92
118
|
interface BadgeProps {
|
|
93
119
|
children: ReactNode;
|
|
94
120
|
variant?: BadgeVariant;
|
|
95
121
|
style?: StyleProp<ViewStyle>;
|
|
122
|
+
/**
|
|
123
|
+
* Overrides the ceiling on how far the text grows with the OS text size (default: from its
|
|
124
|
+
* font size, see `maxFontScaleFor`). Pass `1` for a count on a fixed shape.
|
|
125
|
+
*/
|
|
126
|
+
maxFontSizeMultiplier?: number;
|
|
96
127
|
}
|
|
97
|
-
declare function Badge({ children, variant, style }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
128
|
+
declare function Badge({ children, variant, style, maxFontSizeMultiplier }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
98
129
|
|
|
99
130
|
type AvatarSize = 'small' | 'medium' | 'large';
|
|
100
131
|
interface AvatarProps {
|
|
@@ -468,7 +499,7 @@ interface ComboboxProps {
|
|
|
468
499
|
}
|
|
469
500
|
declare function Combobox({ label, name, options, placeholder, value, onChange, disabled, error, hint, style, }: Readonly<ComboboxProps>): react_jsx_runtime.JSX.Element;
|
|
470
501
|
|
|
471
|
-
type SegmentedControlSize = 'small' | 'medium' | 'large';
|
|
502
|
+
type SegmentedControlSize = 'small' | 'medium' | 'large' | 'xlarge';
|
|
472
503
|
type SegmentedControlVariant = 'outline' | 'filled';
|
|
473
504
|
interface SegmentedControlProps {
|
|
474
505
|
selectedIndex?: number;
|
|
@@ -636,4 +667,4 @@ interface MessageProps {
|
|
|
636
667
|
}
|
|
637
668
|
declare function Message({ message, type, style }: MessageProps): react_jsx_runtime.JSX.Element | null;
|
|
638
669
|
|
|
639
|
-
export { Accordion, type AccordionItem, Alert, Avatar, Badge, Breadcrumb, type BreadcrumbItem, Button, ButtonContainer, type ButtonContainerProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, Calendar, Card, Carousel, Checkbox, CheckboxGroup, Collapsible, type CollapsibleProps, Combobox, type ComboboxOption, type CreateReactNavigationThemeOptions, type DescriptionItem, DescriptionList, Dialog, DropdownMenu, type DropdownMenuItem, FileInput, FormInput, IconWrapper, type IconWrapperProps, Label, Link, Loading, Message, NotificationBanner, NumberInput, Pagination, Popover, Progress, ProgressCircle, Radio, RadioGroup, Rating, type ReactNavigationFontStyle, type ReactNavigationTheme, type ReactNavigationThemeColors, type ReactNavigationThemeFonts, SectionHeader, SegmentedControl, Select, type SelectOption, Separator, SideSheet, Skeleton, Slider, Switch, type TabItem, Table, type TableColumn, Tabs, Textarea, type ThemeColorName, type ThemeColors, ThemeProvider, type ThemeTokenOverrides, ToastProvider, Tooltip, Typography, createReactNavigationTheme, lineHeight, useReactNavigationTheme, useTheme, useToast };
|
|
670
|
+
export { Accordion, type AccordionItem, Alert, Avatar, Badge, Breadcrumb, type BreadcrumbItem, Button, ButtonContainer, type ButtonContainerProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, Calendar, Card, Carousel, Checkbox, CheckboxGroup, Collapsible, type CollapsibleProps, Combobox, type ComboboxOption, type CreateReactNavigationThemeOptions, type DescriptionItem, DescriptionList, Dialog, DropdownMenu, type DropdownMenuItem, FileInput, FormInput, IconWrapper, type IconWrapperProps, Label, Link, Loading, Message, NotificationBanner, NumberInput, Pagination, Popover, Progress, ProgressCircle, Radio, RadioGroup, Rating, type ReactNavigationFontStyle, type ReactNavigationTheme, type ReactNavigationThemeColors, type ReactNavigationThemeFonts, ScaledText, ScaledTextInput, SectionHeader, SegmentedControl, Select, type SelectOption, Separator, SideSheet, Skeleton, Slider, Switch, type TabItem, Table, type TableColumn, Tabs, Textarea, type ThemeColorName, type ThemeColors, ThemeProvider, type ThemeTokenOverrides, ToastProvider, Tooltip, Typography, createReactNavigationTheme, lineHeight, maxFontScaleFor, maxFontScaleForStyle, useReactNavigationTheme, useTheme, useToast };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
2
3
|
import { ReactNode, ReactElement } from 'react';
|
|
3
4
|
import { colors } from '@boostdev/design-system-foundation/native';
|
|
4
5
|
export { animation, border, colors, font, spacing, zIndex } from '@boostdev/design-system-foundation/native';
|
|
5
|
-
import { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
6
|
+
import { TextProps, Text, TextInputProps, TextInput, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
6
7
|
|
|
7
8
|
/** Absolute lineHeight values for React Native (ratio × fontSize). */
|
|
8
9
|
declare const lineHeight: {
|
|
@@ -80,21 +81,51 @@ declare function createReactNavigationTheme(options?: CreateReactNavigationTheme
|
|
|
80
81
|
*/
|
|
81
82
|
declare function useReactNavigationTheme(overrides?: Pick<CreateReactNavigationThemeOptions, 'colors' | 'fonts'>): ReactNavigationTheme;
|
|
82
83
|
|
|
84
|
+
/** The ceiling for a text with this style (see `maxFontScaleFor`), unless the caller passes its own. */
|
|
85
|
+
declare function maxFontScaleForStyle(style: StyleProp<TextStyle>, override?: number | null): number;
|
|
86
|
+
/**
|
|
87
|
+
* React Native's `Text` with a ceiling on how far it grows with the OS text size, taken from its
|
|
88
|
+
* own font size. Pass `maxFontSizeMultiplier` to override it, e.g. `1` for text in a fixed shape.
|
|
89
|
+
*/
|
|
90
|
+
declare const ScaledText: react.ForwardRefExoticComponent<TextProps & react.RefAttributes<Text>>;
|
|
91
|
+
/** React Native's `TextInput` with the same ceiling as `ScaledText`. */
|
|
92
|
+
declare const ScaledTextInput: react.ForwardRefExoticComponent<TextInputProps & react.RefAttributes<TextInput>>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* How far text of this size may grow with the OS text size (iOS Dynamic Type, Android font
|
|
96
|
+
* scale), as React Native's `maxFontSizeMultiplier`. Big text grows less: a 16 pt body line may
|
|
97
|
+
* double, a 32 pt heading grows to about 42, and a figure of 60 pt or more (a countdown, a score)
|
|
98
|
+
* stays as it is.
|
|
99
|
+
*/
|
|
100
|
+
declare function maxFontScaleFor(fontSize: number): number;
|
|
101
|
+
|
|
83
102
|
type TypographyVariant = 'h1' | 'h2' | 'h3' | 'body' | 'body_s';
|
|
84
103
|
interface TypographyProps {
|
|
85
104
|
variant?: TypographyVariant;
|
|
86
105
|
children: ReactNode;
|
|
87
106
|
style?: StyleProp<TextStyle>;
|
|
107
|
+
/**
|
|
108
|
+
* Overrides the ceiling on how far the text grows with the OS text size (default: from its
|
|
109
|
+
* font size, see `maxFontScaleFor`). `1` keeps the text at its own size.
|
|
110
|
+
*/
|
|
111
|
+
maxFontSizeMultiplier?: number;
|
|
112
|
+
/** Truncates the text with an ellipsis after this many lines. */
|
|
113
|
+
numberOfLines?: number;
|
|
88
114
|
}
|
|
89
|
-
declare function Typography({ variant, children, style }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
declare function Typography({ variant, children, style, maxFontSizeMultiplier, numberOfLines, }: TypographyProps): react_jsx_runtime.JSX.Element;
|
|
90
116
|
|
|
91
117
|
type BadgeVariant = 'primary' | 'secondary' | 'success' | 'error' | 'warning';
|
|
92
118
|
interface BadgeProps {
|
|
93
119
|
children: ReactNode;
|
|
94
120
|
variant?: BadgeVariant;
|
|
95
121
|
style?: StyleProp<ViewStyle>;
|
|
122
|
+
/**
|
|
123
|
+
* Overrides the ceiling on how far the text grows with the OS text size (default: from its
|
|
124
|
+
* font size, see `maxFontScaleFor`). Pass `1` for a count on a fixed shape.
|
|
125
|
+
*/
|
|
126
|
+
maxFontSizeMultiplier?: number;
|
|
96
127
|
}
|
|
97
|
-
declare function Badge({ children, variant, style }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
128
|
+
declare function Badge({ children, variant, style, maxFontSizeMultiplier }: BadgeProps): react_jsx_runtime.JSX.Element;
|
|
98
129
|
|
|
99
130
|
type AvatarSize = 'small' | 'medium' | 'large';
|
|
100
131
|
interface AvatarProps {
|
|
@@ -468,7 +499,7 @@ interface ComboboxProps {
|
|
|
468
499
|
}
|
|
469
500
|
declare function Combobox({ label, name, options, placeholder, value, onChange, disabled, error, hint, style, }: Readonly<ComboboxProps>): react_jsx_runtime.JSX.Element;
|
|
470
501
|
|
|
471
|
-
type SegmentedControlSize = 'small' | 'medium' | 'large';
|
|
502
|
+
type SegmentedControlSize = 'small' | 'medium' | 'large' | 'xlarge';
|
|
472
503
|
type SegmentedControlVariant = 'outline' | 'filled';
|
|
473
504
|
interface SegmentedControlProps {
|
|
474
505
|
selectedIndex?: number;
|
|
@@ -636,4 +667,4 @@ interface MessageProps {
|
|
|
636
667
|
}
|
|
637
668
|
declare function Message({ message, type, style }: MessageProps): react_jsx_runtime.JSX.Element | null;
|
|
638
669
|
|
|
639
|
-
export { Accordion, type AccordionItem, Alert, Avatar, Badge, Breadcrumb, type BreadcrumbItem, Button, ButtonContainer, type ButtonContainerProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, Calendar, Card, Carousel, Checkbox, CheckboxGroup, Collapsible, type CollapsibleProps, Combobox, type ComboboxOption, type CreateReactNavigationThemeOptions, type DescriptionItem, DescriptionList, Dialog, DropdownMenu, type DropdownMenuItem, FileInput, FormInput, IconWrapper, type IconWrapperProps, Label, Link, Loading, Message, NotificationBanner, NumberInput, Pagination, Popover, Progress, ProgressCircle, Radio, RadioGroup, Rating, type ReactNavigationFontStyle, type ReactNavigationTheme, type ReactNavigationThemeColors, type ReactNavigationThemeFonts, SectionHeader, SegmentedControl, Select, type SelectOption, Separator, SideSheet, Skeleton, Slider, Switch, type TabItem, Table, type TableColumn, Tabs, Textarea, type ThemeColorName, type ThemeColors, ThemeProvider, type ThemeTokenOverrides, ToastProvider, Tooltip, Typography, createReactNavigationTheme, lineHeight, useReactNavigationTheme, useTheme, useToast };
|
|
670
|
+
export { Accordion, type AccordionItem, Alert, Avatar, Badge, Breadcrumb, type BreadcrumbItem, Button, ButtonContainer, type ButtonContainerProps, ButtonGroup, type ButtonGroupProps, type ButtonProps, Calendar, Card, Carousel, Checkbox, CheckboxGroup, Collapsible, type CollapsibleProps, Combobox, type ComboboxOption, type CreateReactNavigationThemeOptions, type DescriptionItem, DescriptionList, Dialog, DropdownMenu, type DropdownMenuItem, FileInput, FormInput, IconWrapper, type IconWrapperProps, Label, Link, Loading, Message, NotificationBanner, NumberInput, Pagination, Popover, Progress, ProgressCircle, Radio, RadioGroup, Rating, type ReactNavigationFontStyle, type ReactNavigationTheme, type ReactNavigationThemeColors, type ReactNavigationThemeFonts, ScaledText, ScaledTextInput, SectionHeader, SegmentedControl, Select, type SelectOption, Separator, SideSheet, Skeleton, Slider, Switch, type TabItem, Table, type TableColumn, Tabs, Textarea, type ThemeColorName, type ThemeColors, ThemeProvider, type ThemeTokenOverrides, ToastProvider, Tooltip, Typography, createReactNavigationTheme, lineHeight, maxFontScaleFor, maxFontScaleForStyle, useReactNavigationTheme, useTheme, useToast };
|