@utilitywarehouse/hearth-react-native 0.10.0 → 0.12.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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +18 -0
- package/build/components/Avatar/Avatar.d.ts +6 -0
- package/build/components/Avatar/Avatar.js +80 -0
- package/build/components/Avatar/Avatar.props.d.ts +28 -0
- package/build/components/Avatar/Avatar.props.js +1 -0
- package/build/components/Avatar/index.d.ts +2 -0
- package/build/components/Avatar/index.js +1 -0
- package/build/components/Banner/Banner.context.d.ts +7 -0
- package/build/components/Banner/Banner.context.js +8 -0
- package/build/components/Banner/Banner.js +10 -40
- package/build/components/Banner/Banner.props.d.ts +3 -5
- package/build/components/Banner/BannerIllustration.d.ts +4 -0
- package/build/components/Banner/BannerIllustration.js +53 -0
- package/build/components/Banner/BannerImage.d.ts +4 -0
- package/build/components/Banner/BannerImage.js +53 -0
- package/build/components/Banner/index.d.ts +2 -0
- package/build/components/Banner/index.js +2 -0
- package/build/components/Card/CardAction/CardAction.props.d.ts +2 -3
- package/build/components/Card/CardAction/CardActionRoot.js +1 -2
- package/build/components/Checkbox/Checkbox.js +1 -2
- package/build/components/Checkbox/Checkbox.props.d.ts +3 -3
- package/build/components/Checkbox/CheckboxImage.d.ts +2 -1
- package/build/components/Checkbox/CheckboxImage.js +8 -1
- package/build/components/DateInput/DateInput.d.ts +6 -0
- package/build/components/DateInput/DateInput.js +19 -0
- package/build/components/DateInput/DateInput.props.d.ts +79 -0
- package/build/components/DateInput/DateInput.props.js +1 -0
- package/build/components/DateInput/DateInputSegment.d.ts +20 -0
- package/build/components/DateInput/DateInputSegment.js +31 -0
- package/build/components/DateInput/index.d.ts +2 -0
- package/build/components/DateInput/index.js +1 -0
- package/build/components/ExpandableCard/ExpandableCard.props.d.ts +1 -2
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +4 -5
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +1 -14
- package/build/components/HighlightBanner/HighlightBanner.js +2 -6
- package/build/components/HighlightBanner/HighlightBanner.props.d.ts +2 -3
- package/build/components/HighlightBanner/HighlightBannerImage.d.ts +4 -0
- package/build/components/HighlightBanner/HighlightBannerImage.js +18 -0
- package/build/components/HighlightBanner/index.d.ts +1 -0
- package/build/components/HighlightBanner/index.js +1 -0
- package/build/components/Input/Input.d.ts +5 -7
- package/build/components/Input/Input.js +11 -4
- package/build/components/Input/InputField.d.ts +4 -7
- package/build/components/Input/InputField.js +6 -5
- package/build/components/List/ListItem/ListItem.props.d.ts +2 -2
- package/build/components/List/ListItem/ListItemRoot.js +1 -2
- package/build/components/Modal/Modal.js +2 -6
- package/build/components/Modal/Modal.props.d.ts +3 -2
- package/build/components/Modal/Modal.web.js +2 -6
- package/build/components/Modal/ModalImage.d.ts +4 -0
- package/build/components/Modal/ModalImage.js +18 -0
- package/build/components/Modal/index.d.ts +1 -0
- package/build/components/Modal/index.js +1 -0
- package/build/components/Radio/Radio.js +1 -2
- package/build/components/Radio/Radio.props.d.ts +3 -3
- package/build/components/Radio/RadioImage.d.ts +2 -1
- package/build/components/Radio/RadioImage.js +8 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/utils/getInitials.d.ts +1 -0
- package/build/utils/getInitials.js +8 -0
- package/build/utils/index.d.ts +2 -0
- package/build/utils/index.js +2 -0
- package/build/utils/isThemedImageProps.d.ts +4 -0
- package/build/utils/isThemedImageProps.js +4 -0
- package/docs/components/AllComponents.web.tsx +18 -1
- package/package.json +2 -2
- package/src/components/Avatar/Avatar.docs.mdx +105 -0
- package/src/components/Avatar/Avatar.props.ts +31 -0
- package/src/components/Avatar/Avatar.stories.tsx +77 -0
- package/src/components/Avatar/Avatar.tsx +136 -0
- package/src/components/Avatar/index.ts +2 -0
- package/src/components/Banner/Banner.context.ts +11 -0
- package/src/components/Banner/Banner.docs.mdx +55 -37
- package/src/components/Banner/Banner.props.ts +3 -5
- package/src/components/Banner/Banner.stories.tsx +86 -57
- package/src/components/Banner/Banner.tsx +24 -67
- package/src/components/Banner/BannerIllustration.tsx +63 -0
- package/src/components/Banner/BannerImage.tsx +63 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/Card/Card.docs.mdx +4 -4
- package/src/components/Card/CardAction/CardAction.props.ts +2 -3
- package/src/components/Card/CardAction/CardAction.stories.tsx +4 -3
- package/src/components/Card/CardAction/CardActionRoot.tsx +4 -5
- package/src/components/Checkbox/Checkbox.docs.mdx +23 -4
- package/src/components/Checkbox/Checkbox.props.ts +3 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +14 -8
- package/src/components/Checkbox/Checkbox.tsx +1 -2
- package/src/components/Checkbox/CheckboxImage.tsx +8 -3
- package/src/components/DateInput/DateInput.docs.mdx +163 -0
- package/src/components/DateInput/DateInput.props.ts +80 -0
- package/src/components/DateInput/DateInput.stories.tsx +269 -0
- package/src/components/DateInput/DateInput.tsx +117 -0
- package/src/components/DateInput/DateInputSegment.tsx +83 -0
- package/src/components/DateInput/index.ts +2 -0
- package/src/components/ExpandableCard/ExpandableCard.docs.mdx +2 -2
- package/src/components/ExpandableCard/ExpandableCard.props.ts +1 -2
- package/src/components/ExpandableCard/ExpandableCard.stories.tsx +3 -3
- package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +4 -5
- package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +2 -17
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +73 -42
- package/src/components/HighlightBanner/HighlightBanner.props.ts +2 -3
- package/src/components/HighlightBanner/HighlightBanner.stories.tsx +85 -60
- package/src/components/HighlightBanner/HighlightBanner.tsx +3 -10
- package/src/components/HighlightBanner/HighlightBannerImage.tsx +20 -0
- package/src/components/HighlightBanner/index.ts +1 -0
- package/src/components/Input/Input.stories.tsx +76 -3
- package/src/components/Input/Input.tsx +110 -98
- package/src/components/Input/InputField.tsx +27 -26
- package/src/components/List/List.docs.mdx +15 -9
- package/src/components/List/List.stories.tsx +2 -2
- package/src/components/List/ListItem/ListItem.props.ts +2 -2
- package/src/components/List/ListItem/ListItemRoot.tsx +2 -3
- package/src/components/Modal/Modal.docs.mdx +16 -4
- package/src/components/Modal/Modal.props.ts +3 -2
- package/src/components/Modal/Modal.stories.tsx +2 -5
- package/src/components/Modal/Modal.tsx +2 -6
- package/src/components/Modal/Modal.web.tsx +2 -6
- package/src/components/Modal/ModalImage.tsx +20 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/PillGroup/PillGroup.stories.tsx +1 -1
- package/src/components/Radio/Radio.docs.mdx +21 -8
- package/src/components/Radio/Radio.props.ts +3 -3
- package/src/components/Radio/Radio.stories.tsx +15 -11
- package/src/components/Radio/Radio.tsx +1 -2
- package/src/components/Radio/RadioImage.tsx +8 -3
- package/src/components/index.ts +2 -0
- package/src/utils/getInitials.ts +7 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/isThemedImageProps.ts +8 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @utilitywarehouse/hearth-react-native@0.
|
|
2
|
+
> @utilitywarehouse/hearth-react-native@0.12.0 lint /home/runner/work/hearth/hearth/packages/react-native
|
|
3
3
|
> TIMING=1 eslint --max-warnings 0
|
|
4
4
|
|
|
5
5
|
Rule | Time (ms) | Relative
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @utilitywarehouse/hearth-react-native
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#685](https://github.com/utilitywarehouse/hearth/pull/685) [`10f5209`](https://github.com/utilitywarehouse/hearth/commit/10f52095e5f36e58f9821e3fec3fdf43f4578fbb) Thanks [@jordmccord](https://github.com/jordmccord)! - [BREAKING] Component props moved from objects to React Nodes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#687](https://github.com/utilitywarehouse/hearth/pull/687) [`11e8176`](https://github.com/utilitywarehouse/hearth/commit/11e8176ced40b0a8b2d27e07c482ed10a7b7ce7a) Thanks [@jordmccord](https://github.com/jordmccord)! - Fixes `Input` refs
|
|
12
|
+
|
|
13
|
+
## 0.11.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [#674](https://github.com/utilitywarehouse/hearth/pull/674) [`c617257`](https://github.com/utilitywarehouse/hearth/commit/c617257974b11c39d706d6fd46712a284ff5fe10) Thanks [@jordmccord](https://github.com/jordmccord)! - Adds `DateInput` component
|
|
18
|
+
|
|
19
|
+
- [#663](https://github.com/utilitywarehouse/hearth/pull/663) [`8889a07`](https://github.com/utilitywarehouse/hearth/commit/8889a07e347e9289928e679cee495d7656a4e9aa) Thanks [@Utakato](https://github.com/Utakato)! - Add Avatar component
|
|
20
|
+
|
|
3
21
|
## 0.10.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { UserMediumIcon, UserSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { Image, View } from 'react-native';
|
|
5
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
+
import { useTheme } from '../../hooks';
|
|
7
|
+
import { getInitials } from '../../utils';
|
|
8
|
+
import BodyText from '../BodyText/BodyText';
|
|
9
|
+
const Avatar = ({ src, name, size = 'md', delayMs = 0, onLoadingStatusChange, style, ...props }) => {
|
|
10
|
+
const [status, setStatus] = useState('idle');
|
|
11
|
+
const [isDelayed, setIsDelayed] = useState(delayMs > 0);
|
|
12
|
+
const { components } = useTheme();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!src) {
|
|
15
|
+
setStatus('idle');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
setStatus('loading');
|
|
19
|
+
}, [src]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
onLoadingStatusChange?.(status);
|
|
22
|
+
}, [status, onLoadingStatusChange]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (delayMs <= 0) {
|
|
25
|
+
setIsDelayed(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const timerId = setTimeout(() => {
|
|
29
|
+
setIsDelayed(false);
|
|
30
|
+
}, delayMs);
|
|
31
|
+
return () => clearTimeout(timerId);
|
|
32
|
+
}, [delayMs]);
|
|
33
|
+
styles.useVariants({ size });
|
|
34
|
+
const initials = getInitials(name);
|
|
35
|
+
const handleLoad = () => setStatus('loaded');
|
|
36
|
+
const handleError = () => setStatus('error');
|
|
37
|
+
const showImage = src && status === 'loaded';
|
|
38
|
+
const showFallback = !showImage && !isDelayed;
|
|
39
|
+
const textSize = size === 'sm' ? 'md' : 'lg';
|
|
40
|
+
const FallbackIcon = size === 'sm' ? UserSmallIcon : UserMediumIcon;
|
|
41
|
+
return (_jsxs(View, { ...props, style: [styles.container, style], accessibilityRole: showImage && name ? 'image' : undefined, accessibilityLabel: showImage ? name : undefined, children: [src && (_jsx(Image, { source: src, style: styles.image, onLoad: handleLoad, onError: handleError, accessibilityElementsHidden: true })), showFallback && (_jsx(View, { style: styles.fallback, children: name ? (_jsx(BodyText, { size: textSize, weight: "semibold", textTransform: "uppercase", style: styles.text, children: initials })) : (_jsx(FallbackIcon, {})) }))] }));
|
|
42
|
+
};
|
|
43
|
+
Avatar.displayName = 'Avatar';
|
|
44
|
+
const styles = StyleSheet.create(theme => ({
|
|
45
|
+
container: {
|
|
46
|
+
justifyContent: 'center',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
overflow: 'hidden',
|
|
49
|
+
backgroundColor: theme.color.surface.pig.subtle,
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
sm: {
|
|
53
|
+
width: theme.components.avatar.sm.width,
|
|
54
|
+
height: theme.components.avatar.sm.height,
|
|
55
|
+
borderRadius: theme.components.avatar.sm.borderRadius,
|
|
56
|
+
},
|
|
57
|
+
md: {
|
|
58
|
+
width: theme.components.avatar.md.width,
|
|
59
|
+
height: theme.components.avatar.md.height,
|
|
60
|
+
borderRadius: theme.components.avatar.md.borderRadius,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
image: {
|
|
66
|
+
width: '100%',
|
|
67
|
+
height: '100%',
|
|
68
|
+
position: 'absolute',
|
|
69
|
+
},
|
|
70
|
+
fallback: {
|
|
71
|
+
width: '100%',
|
|
72
|
+
height: '100%',
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
},
|
|
76
|
+
text: {
|
|
77
|
+
color: theme.color.text.primary,
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
export default Avatar;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ImageSourcePropType, ViewProps } from 'react-native';
|
|
2
|
+
export type AvatarLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
3
|
+
interface AvatarProps extends ViewProps {
|
|
4
|
+
/**
|
|
5
|
+
* The image source to display.
|
|
6
|
+
*/
|
|
7
|
+
src?: ImageSourcePropType;
|
|
8
|
+
/**
|
|
9
|
+
* The name associated with the avatar, used for creating initials and accessibility label.
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the avatar size.
|
|
14
|
+
* @default md
|
|
15
|
+
*/
|
|
16
|
+
size?: 'sm' | 'md';
|
|
17
|
+
/**
|
|
18
|
+
* Delay in milliseconds before the image is rendered.
|
|
19
|
+
* Useful to prevent flickering when the image loads very quickly.
|
|
20
|
+
* @default 0
|
|
21
|
+
*/
|
|
22
|
+
delayMs?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Callback fired when the loading status of the image changes.
|
|
25
|
+
*/
|
|
26
|
+
onLoadingStatusChange?: (status: AvatarLoadingStatus) => void;
|
|
27
|
+
}
|
|
28
|
+
export default AvatarProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Avatar } from './Avatar';
|
|
@@ -1,34 +1,29 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronRightSmallIcon, CloseSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { Pressable, View } from 'react-native';
|
|
4
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
6
|
import { BodyText } from '../BodyText';
|
|
6
7
|
import { Card } from '../Card';
|
|
7
8
|
import { Heading } from '../Heading';
|
|
8
9
|
import { IconContainer } from '../IconContainer';
|
|
9
|
-
import { ThemedImage } from '../ThemedImage';
|
|
10
10
|
import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
11
|
-
|
|
12
|
-
return 'light' in props && 'dark' in props;
|
|
13
|
-
};
|
|
11
|
+
import BannerContext from './Banner.context';
|
|
14
12
|
const Banner = ({ icon, iconContainerVariant = 'subtle', iconContainerSize = 'md', iconContainerColor = 'pig', illustration, image, heading, description, direction = 'horizontal', link, button, onPress, onClose, variant = 'subtle', colorScheme = 'pig', style, ...props }) => {
|
|
15
13
|
const hasIllustration = Boolean(illustration);
|
|
16
14
|
styles.useVariants({ direction, hasIllustration });
|
|
15
|
+
const context = useMemo(() => ({
|
|
16
|
+
direction,
|
|
17
|
+
}), [direction]);
|
|
17
18
|
const renderIconOrImage = () => {
|
|
18
19
|
if (icon) {
|
|
19
20
|
return (_jsx(IconContainer, { icon: icon, variant: iconContainerVariant, size: iconContainerSize, color: iconContainerColor, style: styles.media }));
|
|
20
21
|
}
|
|
21
22
|
if (illustration) {
|
|
22
|
-
|
|
23
|
-
return (_jsx(ThemedImage, { ...illustration, resizeMode: "cover", style: [styles.media, styles.imageWrapper, illustration.style] }));
|
|
24
|
-
}
|
|
25
|
-
return (_jsx(Image, { ...illustration, resizeMode: "cover", style: [styles.media, styles.imageWrapper, illustration.style] }));
|
|
23
|
+
return illustration;
|
|
26
24
|
}
|
|
27
25
|
if (image) {
|
|
28
|
-
|
|
29
|
-
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(ThemedImage, { ...image, style: [styles.image, image.style] }) }));
|
|
30
|
-
}
|
|
31
|
-
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(Image, { ...image, style: [styles.image, image.style] }) }));
|
|
26
|
+
return image;
|
|
32
27
|
}
|
|
33
28
|
return null;
|
|
34
29
|
};
|
|
@@ -43,9 +38,9 @@ const Banner = ({ icon, iconContainerVariant = 'subtle', iconContainerSize = 'md
|
|
|
43
38
|
};
|
|
44
39
|
const content = (_jsxs(View, { style: styles.container, children: [onClose && direction === 'vertical' && (_jsx(UnstyledIconButton, { icon: CloseSmallIcon, size: "sm", onPress: onClose, style: styles.closeButton, accessibilityLabel: "Close banner" })), renderIconOrImage(), _jsxs(View, { style: styles.contentContainer, children: [_jsxs(View, { style: styles.contentTextContainer, children: [_jsxs(View, { style: styles.textContainer, children: [_jsx(Heading, { size: "sm", style: styles.heading, textAlign: hasIllustration && direction === 'vertical' ? 'center' : 'left', children: heading }), _jsx(BodyText, { size: "md", style: styles.description, textAlign: hasIllustration && direction === 'vertical' ? 'center' : 'left', children: description })] }), renderAction()] }), onPress && (_jsx(UnstyledIconButton, { icon: ChevronRightSmallIcon, size: "sm", onPress: onPress, style: styles.chevron })), onClose && direction === 'horizontal' && (_jsx(UnstyledIconButton, { icon: CloseSmallIcon, size: "sm", onPress: onClose, style: styles.closeButton, accessibilityLabel: "Close banner" }))] })] }));
|
|
45
40
|
if (onPress) {
|
|
46
|
-
return (_jsx(Card, { variant: variant, style: [styles.card, style], ...props, children: _jsx(Pressable, { onPress: onPress, accessibilityRole: "button", style: styles.pressable, children: content }) }));
|
|
41
|
+
return (_jsx(BannerContext.Provider, { value: context, children: _jsx(Card, { variant: variant, style: [styles.card, style], ...props, children: _jsx(Pressable, { onPress: onPress, accessibilityRole: "button", style: styles.pressable, children: content }) }) }));
|
|
47
42
|
}
|
|
48
|
-
return (_jsx(Card, { variant: variant, style: [styles.card, style], ...props, children: content }));
|
|
43
|
+
return (_jsx(BannerContext.Provider, { value: context, children: _jsx(Card, { variant: variant, style: [styles.card, style], ...props, children: content }) }));
|
|
49
44
|
};
|
|
50
45
|
Banner.displayName = 'Banner';
|
|
51
46
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -100,31 +95,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
100
95
|
},
|
|
101
96
|
},
|
|
102
97
|
},
|
|
103
|
-
imageWrapper: {
|
|
104
|
-
flexDirection: 'row',
|
|
105
|
-
variants: {
|
|
106
|
-
direction: {
|
|
107
|
-
horizontal: {},
|
|
108
|
-
vertical: {
|
|
109
|
-
width: '100%',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
image: {
|
|
115
|
-
borderRadius: theme.borderRadius.md,
|
|
116
|
-
borderColor: theme.color.border.strong,
|
|
117
|
-
borderWidth: theme.borderWidth[1],
|
|
118
|
-
variants: {
|
|
119
|
-
direction: {
|
|
120
|
-
horizontal: { width: 160, height: 95 },
|
|
121
|
-
vertical: {
|
|
122
|
-
width: '100%',
|
|
123
|
-
height: 160,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
98
|
contentContainer: {
|
|
129
99
|
alignItems: 'flex-start',
|
|
130
100
|
justifyContent: 'space-between',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { ComponentType, ReactElement } from 'react';
|
|
2
|
-
import { ImageProps } from 'react-native';
|
|
1
|
+
import type { ComponentType, ReactElement, ReactNode } from 'react';
|
|
3
2
|
import type CardProps from '../Card/Card.props';
|
|
4
|
-
import { ThemedImageProps } from '../ThemedImage';
|
|
5
3
|
export type BannerDirection = 'horizontal' | 'vertical';
|
|
6
4
|
export interface BannerProps extends Omit<CardProps, 'noPadding' | 'variant' | 'colorScheme' | 'space' | 'gap' | 'rowGap' | 'columnGap' | 'flexDirection' | 'flexWrap' | 'alignItems' | 'justifyContent'> {
|
|
7
5
|
/**
|
|
@@ -28,12 +26,12 @@ export interface BannerProps extends Omit<CardProps, 'noPadding' | 'variant' | '
|
|
|
28
26
|
* Illustration to display in the banner
|
|
29
27
|
* Mutually exclusive with icon and image
|
|
30
28
|
*/
|
|
31
|
-
illustration?:
|
|
29
|
+
illustration?: ReactNode;
|
|
32
30
|
/**
|
|
33
31
|
* Image to display in the banner
|
|
34
32
|
* Mutually exclusive with icon and illustration
|
|
35
33
|
*/
|
|
36
|
-
image?:
|
|
34
|
+
image?: ReactNode;
|
|
37
35
|
/**
|
|
38
36
|
* Heading text
|
|
39
37
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Image, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { isThemedImageProps } from '../../utils';
|
|
5
|
+
import { ThemedImage } from '../ThemedImage';
|
|
6
|
+
import { useBannerContext } from './Banner.context';
|
|
7
|
+
const BannerIllustration = (props) => {
|
|
8
|
+
const { direction } = useBannerContext();
|
|
9
|
+
styles.useVariants({ direction });
|
|
10
|
+
if (isThemedImageProps(props)) {
|
|
11
|
+
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(ThemedImage, { ...props, style: [styles.image, props.style] }) }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(Image, { ...props, style: [styles.image, props.style] }) }));
|
|
14
|
+
};
|
|
15
|
+
const styles = StyleSheet.create(theme => ({
|
|
16
|
+
media: {
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
variants: {
|
|
19
|
+
direction: {
|
|
20
|
+
horizontal: {},
|
|
21
|
+
vertical: {
|
|
22
|
+
alignSelf: 'flex-start',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
imageWrapper: {
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
variants: {
|
|
30
|
+
direction: {
|
|
31
|
+
horizontal: {},
|
|
32
|
+
vertical: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
image: {
|
|
39
|
+
borderRadius: theme.borderRadius.md,
|
|
40
|
+
borderColor: theme.color.border.strong,
|
|
41
|
+
borderWidth: theme.borderWidth[1],
|
|
42
|
+
variants: {
|
|
43
|
+
direction: {
|
|
44
|
+
horizontal: { width: 160, height: 95 },
|
|
45
|
+
vertical: {
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: 160,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
export default BannerIllustration;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Image, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { isThemedImageProps } from '../../utils';
|
|
5
|
+
import { ThemedImage } from '../ThemedImage';
|
|
6
|
+
import { useBannerContext } from './Banner.context';
|
|
7
|
+
const BannerImage = (props) => {
|
|
8
|
+
const { direction } = useBannerContext();
|
|
9
|
+
styles.useVariants({ direction });
|
|
10
|
+
if (isThemedImageProps(props)) {
|
|
11
|
+
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(ThemedImage, { ...props, style: [styles.image, props.style] }) }));
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(View, { style: [styles.media, styles.imageWrapper], children: _jsx(Image, { ...props, style: [styles.image, props.style] }) }));
|
|
14
|
+
};
|
|
15
|
+
const styles = StyleSheet.create(theme => ({
|
|
16
|
+
media: {
|
|
17
|
+
flexShrink: 0,
|
|
18
|
+
variants: {
|
|
19
|
+
direction: {
|
|
20
|
+
horizontal: {},
|
|
21
|
+
vertical: {
|
|
22
|
+
alignSelf: 'flex-start',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
imageWrapper: {
|
|
28
|
+
flexDirection: 'row',
|
|
29
|
+
variants: {
|
|
30
|
+
direction: {
|
|
31
|
+
horizontal: {},
|
|
32
|
+
vertical: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
image: {
|
|
39
|
+
borderRadius: theme.borderRadius.md,
|
|
40
|
+
borderColor: theme.color.border.strong,
|
|
41
|
+
borderWidth: theme.borderWidth[1],
|
|
42
|
+
variants: {
|
|
43
|
+
direction: {
|
|
44
|
+
horizontal: { width: 160, height: 95 },
|
|
45
|
+
vertical: {
|
|
46
|
+
width: '100%',
|
|
47
|
+
height: 160,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
export default BannerImage;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
|
-
import BadgeProps from '../../Badge/Badge.props';
|
|
4
3
|
import { IconContainerProps } from '../../IconContainer';
|
|
5
4
|
interface CardActionBaseProps extends Omit<PressableProps, 'children'> {
|
|
6
5
|
loading?: boolean;
|
|
@@ -10,7 +9,7 @@ interface CardActionBaseProps extends Omit<PressableProps, 'children'> {
|
|
|
10
9
|
interface CardActionContentProps {
|
|
11
10
|
heading: string;
|
|
12
11
|
helperText?: string;
|
|
13
|
-
badge?:
|
|
12
|
+
badge?: ReactNode;
|
|
14
13
|
badgePosition?: 'bottom' | 'middle' | 'right' | 'top';
|
|
15
14
|
iconContainer?: boolean;
|
|
16
15
|
iconContainerVariant?: IconContainerProps['variant'];
|
|
@@ -3,7 +3,6 @@ import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-ico
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { Pressable, View } from 'react-native';
|
|
5
5
|
import { StyleSheet } from 'react-native-unistyles';
|
|
6
|
-
import { Badge } from '../../Badge';
|
|
7
6
|
import { IconContainer } from '../../IconContainer';
|
|
8
7
|
import { Skeleton } from '../../Skeleton';
|
|
9
8
|
import { useCardContext } from '../Card.context';
|
|
@@ -46,7 +45,7 @@ const CardActionRoot = ({ heading, helperText, leadingContent, trailingContent,
|
|
|
46
45
|
if (loading) {
|
|
47
46
|
return (_jsxs(Pressable, { ...props, testID: loadingTestID, style: [styles.container, styles.alignCenter, props.style], disabled: isDisabled, children: [leadingContent || leadingIcon ? (_jsx(Skeleton, { width: 24, height: 24, style: styles.alignCenter })) : null, _jsxs(CardActionContent, { children: [_jsx(Skeleton, { width: "80%", height: 24, borderRadius: "xs" }), _jsx(Skeleton, { width: "100%", height: 24, borderRadius: "xs" })] }), trailingIcon || trailingContent ? (_jsx(Skeleton, { width: 24, height: 24, borderRadius: "xs", style: styles.alignCenter })) : null] }));
|
|
48
47
|
}
|
|
49
|
-
return (_jsx(CardActionContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingIcon && iconContainer ? (_jsx(View, { style: styles.iconContainerWrap, children: _jsx(IconContainer, { style: styles.iconContainer, icon: leadingIcon, variant: iconContainerVariant, color: iconContainerColor, radiusNone: true }) })) : null, _jsxs(View, { style: styles.withIconContainer, children: [leadingContent ? (_jsx(CardActionLeadingContent, { children: leadingContent })) : null, leadingIcon && !iconContainer && !leadingContent ? (_jsx(CardActionLeadingContent, { children: _jsx(CardActionIcon, { as: leadingIcon }) })) : null, _jsxs(CardActionContent, { children: [badgePosition === 'top' && badge ?
|
|
48
|
+
return (_jsx(CardActionContext.Provider, { value: value, children: _jsx(Pressable, { ...props, testID: testID, style: [styles.container, props.style], disabled: isDisabled, accessibilityRole: onPress ? 'button' : undefined, children: children ? (children) : (_jsxs(_Fragment, { children: [leadingIcon && iconContainer ? (_jsx(View, { style: styles.iconContainerWrap, children: _jsx(IconContainer, { style: styles.iconContainer, icon: leadingIcon, variant: iconContainerVariant, color: iconContainerColor, radiusNone: true }) })) : null, _jsxs(View, { style: styles.withIconContainer, children: [leadingContent ? (_jsx(CardActionLeadingContent, { children: leadingContent })) : null, leadingIcon && !iconContainer && !leadingContent ? (_jsx(CardActionLeadingContent, { children: _jsx(CardActionIcon, { as: leadingIcon }) })) : null, _jsxs(CardActionContent, { children: [badgePosition === 'top' && badge ? badge : null, _jsx(CardActionText, { children: heading }), badgePosition === 'middle' && badge ? badge : null, helperText ? _jsx(CardActionHelperText, { children: helperText }) : null, badgePosition === 'bottom' && badge ? badge : null] }), badgePosition === 'right' && badge ? (_jsx(View, { style: styles.alignCenter, children: badge })) : null, trailingContent ? (_jsx(CardActionTrailingContent, { children: trailingContent })) : null, trailingIcon && !trailingContent ? (_jsx(CardActionTrailingContent, { children: _jsx(CardActionTrailingIcon, { as: trailingIcon }) })) : null] })] })) }) }));
|
|
50
49
|
};
|
|
51
50
|
CardActionRoot.displayName = 'CardActionRoot';
|
|
52
51
|
const styles = StyleSheet.create(theme => ({
|
|
@@ -5,7 +5,6 @@ import { Helper } from '../Helper';
|
|
|
5
5
|
import { useCheckboxGroupContext } from './CheckboxGroup.context';
|
|
6
6
|
import StyledCheckboxGroup from './CheckboxGroupRoot';
|
|
7
7
|
import StyledCheckboxIcon from './CheckboxIcon';
|
|
8
|
-
import CheckboxImage from './CheckboxImage';
|
|
9
8
|
import StyledCheckboxIndicator from './CheckboxIndicator';
|
|
10
9
|
import StyledCheckboxLabel from './CheckboxLabel';
|
|
11
10
|
import StyledCheckbox from './CheckboxRoot';
|
|
@@ -31,7 +30,7 @@ const Checkbox = ({ children, label, disabled, checked, helperIcon, helperText,
|
|
|
31
30
|
const { validationStatus: groupValidationStatus, type: groupType } = useCheckboxGroupContext();
|
|
32
31
|
const validationStatus = fieldValidationStatus ?? groupValidationStatus ?? validation ?? 'initial';
|
|
33
32
|
const checkboxType = groupType ?? type;
|
|
34
|
-
const checkboxChildren = children ? (children) : (_jsxs(_Fragment, { children: [_jsx(CheckboxIndicator, { children: _jsx(CheckboxIcon, {}) }), image ?
|
|
33
|
+
const checkboxChildren = children ? (children) : (_jsxs(_Fragment, { children: [_jsx(CheckboxIndicator, { children: _jsx(CheckboxIcon, {}) }), image ? image : null, _jsxs(CheckboxTextContent, { children: [!!label && _jsx(CheckboxLabel, { children: label }), !!helperText && _jsx(Helper, { disabled: disabled, icon: helperIcon, text: helperText }), validationStatus === 'invalid' && !!invalidText && (_jsx(Helper, { showIcon: showValidationIcon, disabled: disabled, validationStatus: "invalid", text: invalidText })), validationStatus === 'valid' && !!validText && (_jsx(Helper, { disabled: disabled, showIcon: showValidationIcon, validationStatus: "valid", text: validText }))] })] }));
|
|
35
34
|
return (
|
|
36
35
|
// @ts-expect-error - type
|
|
37
36
|
_jsx(CheckboxComponent, { ...props, isDisabled: disabled, isChecked: checked, children: checkboxType === 'tile' ? (_jsx(CheckboxTileRoot, { children: checkboxChildren })) : (checkboxChildren) }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentType } from 'react';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
3
|
type CheckboxBaseProps = {
|
|
4
4
|
onChange?: (isSelected: boolean) => void;
|
|
5
5
|
disabled?: boolean;
|
|
@@ -30,7 +30,7 @@ type CheckboxWithoutChildrenProps = {
|
|
|
30
30
|
invalidText?: string;
|
|
31
31
|
validText?: string;
|
|
32
32
|
showValidationIcon?: boolean;
|
|
33
|
-
image?:
|
|
33
|
+
image?: ReactNode;
|
|
34
34
|
} & CheckboxBaseProps;
|
|
35
35
|
type CheckboxProps = CheckboxWithChildrenProps | CheckboxWithoutChildrenProps;
|
|
36
36
|
export default CheckboxProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ImageProps } from 'react-native';
|
|
2
|
+
import { ThemedImageProps } from '../ThemedImage';
|
|
2
3
|
declare const CheckboxImage: {
|
|
3
|
-
({
|
|
4
|
+
({ ...props }: ImageProps | ThemedImageProps): import("react/jsx-runtime").JSX.Element;
|
|
4
5
|
displayName: string;
|
|
5
6
|
};
|
|
6
7
|
export default CheckboxImage;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
|
-
|
|
3
|
+
import { isThemedImageProps } from '../../utils';
|
|
4
|
+
import { ThemedImage } from '../ThemedImage';
|
|
5
|
+
const CheckboxImage = ({ ...props }) => {
|
|
6
|
+
if (isThemedImageProps(props)) {
|
|
7
|
+
return _jsx(ThemedImage, { ...props });
|
|
8
|
+
}
|
|
9
|
+
return _jsx(Image, { ...props });
|
|
10
|
+
};
|
|
4
11
|
CheckboxImage.displayName = 'CheckboxImage';
|
|
5
12
|
export default CheckboxImage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DateInputProps } from './DateInput.props';
|
|
2
|
+
declare const DateInput: {
|
|
3
|
+
({ label, helperText, helperIcon, validationStatus, validText, invalidText, disabled, readonly, required, hideDay, hideMonth, hideYear, dayPlaceholder, monthPlaceholder, yearPlaceholder, dayValue, monthValue, yearValue, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, ...props }: DateInputProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
export default DateInput;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { FormField } from '../FormField';
|
|
5
|
+
import DateInputSegment from './DateInputSegment';
|
|
6
|
+
const DateInput = ({ label, helperText, helperIcon, validationStatus = 'initial', validText, invalidText, disabled, readonly, required, hideDay = false, hideMonth = false, hideYear = false, dayPlaceholder = 'DD', monthPlaceholder = 'MM', yearPlaceholder = 'YYYY', dayValue, monthValue, yearValue, onDayChange, onMonthChange, onYearChange, onDayFocus, onMonthFocus, onYearFocus, onDayBlur, onMonthBlur, onYearBlur, ...props }) => {
|
|
7
|
+
return (_jsx(FormField, { label: label, helperText: helperText, helperIcon: helperIcon, validationStatus: validationStatus, validText: validText, invalidText: invalidText, disabled: disabled, readonly: readonly, required: required, style: styles.wrap, ...props, children: _jsxs(View, { style: styles.container, children: [!hideDay && (_jsx(DateInputSegment, { label: "Day", placeholder: dayPlaceholder, value: dayValue, onChange: onDayChange, onFocus: onDayFocus, onBlur: onDayBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-day" })), !hideMonth && (_jsx(DateInputSegment, { label: "Month", placeholder: monthPlaceholder, value: monthValue, onChange: onMonthChange, onFocus: onMonthFocus, onBlur: onMonthBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 2, testID: "date-input-month" })), !hideYear && (_jsx(DateInputSegment, { label: "Year", placeholder: yearPlaceholder, value: yearValue, onChange: onYearChange, onFocus: onYearFocus, onBlur: onYearBlur, disabled: disabled, required: required, readonly: readonly, validationStatus: validationStatus, maxLength: 4, testID: "date-input-year" }))] }) }));
|
|
8
|
+
};
|
|
9
|
+
DateInput.displayName = 'DateInput';
|
|
10
|
+
const styles = StyleSheet.create(theme => ({
|
|
11
|
+
wrap: {
|
|
12
|
+
gap: theme.components.input.gap,
|
|
13
|
+
},
|
|
14
|
+
container: {
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
gap: theme.components.input.date.gap,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
export default DateInput;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { TextInputProps } from 'react-native';
|
|
2
|
+
import type { FormFieldBaseProps } from '../FormField/FormField.props';
|
|
3
|
+
export interface DateInputProps extends FormFieldBaseProps {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the day segment is hidden.
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
hideDay?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the month segment is hidden.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
hideMonth?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the year segment is hidden.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
hideYear?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Placeholder text for the day segment.
|
|
21
|
+
*/
|
|
22
|
+
dayPlaceholder?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Placeholder text for the month segment.
|
|
25
|
+
*/
|
|
26
|
+
monthPlaceholder?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Placeholder text for the year segment.
|
|
29
|
+
*/
|
|
30
|
+
yearPlaceholder?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The controlled value for the day segment. Must be used with an `onDayChange` handler.
|
|
33
|
+
*/
|
|
34
|
+
dayValue?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The controlled value for the month segment. Must be used with an `onMonthChange` handler.
|
|
37
|
+
*/
|
|
38
|
+
monthValue?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The controlled value for the year segment. Must be used with an `onYearChange` handler.
|
|
41
|
+
*/
|
|
42
|
+
yearValue?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Callback fired when the day value changes.
|
|
45
|
+
*/
|
|
46
|
+
onDayChange?: (text: string) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Callback fired when the month value changes.
|
|
49
|
+
*/
|
|
50
|
+
onMonthChange?: (text: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Callback fired when the year value changes.
|
|
53
|
+
*/
|
|
54
|
+
onYearChange?: (text: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Callback fired when the day segment receives focus.
|
|
57
|
+
*/
|
|
58
|
+
onDayFocus?: TextInputProps['onFocus'];
|
|
59
|
+
/**
|
|
60
|
+
* Callback fired when the month segment receives focus.
|
|
61
|
+
*/
|
|
62
|
+
onMonthFocus?: TextInputProps['onFocus'];
|
|
63
|
+
/**
|
|
64
|
+
* Callback fired when the year segment receives focus.
|
|
65
|
+
*/
|
|
66
|
+
onYearFocus?: TextInputProps['onFocus'];
|
|
67
|
+
/**
|
|
68
|
+
* Callback fired when the day segment loses focus.
|
|
69
|
+
*/
|
|
70
|
+
onDayBlur?: TextInputProps['onBlur'];
|
|
71
|
+
/**
|
|
72
|
+
* Callback fired when the month segment loses focus.
|
|
73
|
+
*/
|
|
74
|
+
onMonthBlur?: TextInputProps['onBlur'];
|
|
75
|
+
/**
|
|
76
|
+
* Callback fired when the year segment loses focus.
|
|
77
|
+
*/
|
|
78
|
+
onYearBlur?: TextInputProps['onBlur'];
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|