@webority-technologies/mobile 0.0.15 → 0.0.20
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/lib/commonjs/components/Accordion/Accordion.js +60 -19
- package/lib/commonjs/components/AppBar/AppBar.js +29 -20
- package/lib/commonjs/components/Avatar/Avatar.js +38 -8
- package/lib/commonjs/components/Badge/Badge.js +66 -4
- package/lib/commonjs/components/Banner/Banner.js +146 -66
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +78 -53
- package/lib/commonjs/components/Button/Button.js +12 -5
- package/lib/commonjs/components/Card/Card.js +106 -16
- package/lib/commonjs/components/Carousel/Carousel.js +66 -12
- package/lib/commonjs/components/Checkbox/Checkbox.js +11 -7
- package/lib/commonjs/components/Chip/Chip.js +44 -12
- package/lib/commonjs/components/DatePicker/DatePicker.js +185 -76
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +133 -59
- package/lib/commonjs/components/Dialog/Dialog.js +16 -10
- package/lib/commonjs/components/Drawer/Drawer.js +13 -10
- package/lib/commonjs/components/FieldBase/FieldBase.js +306 -0
- package/lib/commonjs/components/FieldBase/index.js +32 -0
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/commonjs/components/FormField/FormField.js +3 -2
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +132 -44
- package/lib/commonjs/components/Input/Input.js +144 -181
- package/lib/commonjs/components/ListItem/ListItem.js +90 -11
- package/lib/commonjs/components/Modal/Modal.js +55 -27
- package/lib/commonjs/components/NumberInput/NumberInput.js +60 -106
- package/lib/commonjs/components/OTPInput/OTPInput.js +65 -58
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +185 -0
- package/lib/commonjs/components/{AppIcon → PickerTrigger}/index.js +4 -4
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/commonjs/components/Radio/Radio.js +11 -6
- package/lib/commonjs/components/Rating/Rating.js +85 -19
- package/lib/commonjs/components/SearchBar/SearchBar.js +84 -107
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/commonjs/components/Select/Select.js +62 -91
- package/lib/commonjs/components/Skeleton/Skeleton.js +131 -174
- package/lib/commonjs/components/Skeleton/SkeletonClock.js +117 -0
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +164 -81
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +72 -10
- package/lib/commonjs/components/Skeleton/index.js +17 -16
- package/lib/commonjs/components/Slider/Slider.js +44 -25
- package/lib/commonjs/components/Stepper/Stepper.js +199 -29
- package/lib/commonjs/components/Swipeable/Swipeable.js +36 -19
- package/lib/commonjs/components/Switch/Switch.js +9 -2
- package/lib/commonjs/components/Tabs/Tabs.js +84 -21
- package/lib/commonjs/components/TimePicker/TimePicker.js +123 -45
- package/lib/commonjs/components/Toast/Toast.js +27 -16
- package/lib/commonjs/components/Tooltip/Tooltip.js +56 -32
- package/lib/commonjs/components/index.js +37 -37
- package/lib/commonjs/theme/tokens.js +55 -7
- package/lib/module/components/Accordion/Accordion.js +61 -20
- package/lib/module/components/AppBar/AppBar.js +29 -20
- package/lib/module/components/Avatar/Avatar.js +39 -9
- package/lib/module/components/Badge/Badge.js +67 -5
- package/lib/module/components/Banner/Banner.js +147 -67
- package/lib/module/components/BottomNavigation/BottomNavigation.js +37 -15
- package/lib/module/components/BottomSheet/BottomSheet.js +80 -55
- package/lib/module/components/Button/Button.js +12 -5
- package/lib/module/components/Card/Card.js +107 -17
- package/lib/module/components/Carousel/Carousel.js +67 -13
- package/lib/module/components/Checkbox/Checkbox.js +11 -7
- package/lib/module/components/Chip/Chip.js +45 -13
- package/lib/module/components/DatePicker/DatePicker.js +185 -76
- package/lib/module/components/DateRangePicker/DateRangePicker.js +134 -60
- package/lib/module/components/Dialog/Dialog.js +16 -10
- package/lib/module/components/Drawer/Drawer.js +13 -10
- package/lib/module/components/FieldBase/FieldBase.js +297 -0
- package/lib/module/components/FieldBase/index.js +4 -0
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +69 -44
- package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +8 -2
- package/lib/module/components/FormField/FormField.js +3 -2
- package/lib/module/components/ImageGallery/ImageGallery.js +128 -40
- package/lib/module/components/Input/Input.js +144 -179
- package/lib/module/components/ListItem/ListItem.js +91 -12
- package/lib/module/components/Modal/Modal.js +55 -27
- package/lib/module/components/NumberInput/NumberInput.js +60 -106
- package/lib/module/components/OTPInput/OTPInput.js +65 -58
- package/lib/module/components/PickerTrigger/PickerTrigger.js +181 -0
- package/lib/module/components/PickerTrigger/index.js +4 -0
- package/lib/module/components/ProgressBar/ProgressBar.js +19 -11
- package/lib/module/components/Radio/Radio.js +11 -6
- package/lib/module/components/Rating/Rating.js +86 -20
- package/lib/module/components/SearchBar/SearchBar.js +84 -107
- package/lib/module/components/SegmentedControl/SegmentedControl.js +22 -11
- package/lib/module/components/Select/Select.js +62 -91
- package/lib/module/components/Skeleton/Skeleton.js +135 -175
- package/lib/module/components/Skeleton/SkeletonClock.js +110 -0
- package/lib/module/components/Skeleton/SkeletonContent.js +167 -84
- package/lib/module/components/Skeleton/SkeletonProvider.js +71 -10
- package/lib/module/components/Skeleton/index.js +3 -2
- package/lib/module/components/Slider/Slider.js +44 -25
- package/lib/module/components/Stepper/Stepper.js +201 -31
- package/lib/module/components/Swipeable/Swipeable.js +36 -19
- package/lib/module/components/Switch/Switch.js +9 -2
- package/lib/module/components/Tabs/Tabs.js +84 -21
- package/lib/module/components/TimePicker/TimePicker.js +123 -45
- package/lib/module/components/Toast/Toast.js +27 -16
- package/lib/module/components/Tooltip/Tooltip.js +56 -32
- package/lib/module/components/index.js +2 -2
- package/lib/module/theme/tokens.js +55 -7
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +17 -6
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/commonjs/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/commonjs/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/commonjs/components/Input/Input.d.ts +6 -0
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/commonjs/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/commonjs/components/index.d.ts +5 -5
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/index.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +553 -11
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +10 -5
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +8 -0
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +12 -6
- package/lib/typescript/module/components/Badge/Badge.d.ts +7 -6
- package/lib/typescript/module/components/Banner/Banner.d.ts +17 -6
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +7 -0
- package/lib/typescript/module/components/Card/Card.d.ts +17 -6
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +7 -6
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +9 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +13 -6
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +38 -3
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +36 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +13 -1
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +141 -0
- package/lib/typescript/module/components/FieldBase/index.d.ts +3 -0
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -6
- package/lib/typescript/module/components/FloatingActionButton/index.d.ts +1 -1
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +7 -0
- package/lib/typescript/module/components/FormField/FormField.d.ts +7 -0
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +6 -4
- package/lib/typescript/module/components/Input/Input.d.ts +6 -0
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +13 -6
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -0
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +57 -0
- package/lib/typescript/module/components/PickerTrigger/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
- package/lib/typescript/module/components/Radio/Radio.d.ts +3 -0
- package/lib/typescript/module/components/Rating/Rating.d.ts +9 -6
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +49 -20
- package/lib/typescript/module/components/Skeleton/SkeletonClock.d.ts +60 -0
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +80 -19
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +39 -5
- package/lib/typescript/module/components/Skeleton/index.d.ts +6 -4
- package/lib/typescript/module/components/Slider/Slider.d.ts +12 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +18 -6
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +2 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +1 -0
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +26 -2
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +36 -3
- package/lib/typescript/module/components/Toast/Toast.d.ts +8 -0
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +7 -1
- package/lib/typescript/module/components/index.d.ts +5 -5
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/theme/index.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +553 -11
- package/package.json +2 -6
- package/lib/commonjs/components/AppIcon/AppIcon.js +0 -120
- package/lib/commonjs/types/vector-icons.d.js +0 -2
- package/lib/module/components/AppIcon/AppIcon.js +0 -111
- package/lib/module/components/AppIcon/index.js +0 -4
- package/lib/module/types/vector-icons.d.js +0 -2
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/commonjs/components/AppIcon/index.d.ts +0 -3
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +0 -20
- package/lib/typescript/module/components/AppIcon/index.d.ts +0 -3
|
@@ -4,7 +4,7 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo, useR
|
|
|
4
4
|
import { Animated, Easing, LayoutAnimation, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
6
6
|
import { triggerHaptic } from "../../utils/hapticUtils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Skeleton } from "../Skeleton/index.js";
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
const AccordionGroupContext = /*#__PURE__*/createContext(null);
|
|
10
10
|
const useAccordionGroup = () => useContext(AccordionGroupContext);
|
|
@@ -87,6 +87,8 @@ const Accordion = props => {
|
|
|
87
87
|
style,
|
|
88
88
|
headerStyle,
|
|
89
89
|
contentStyle,
|
|
90
|
+
contentWrapperStyle,
|
|
91
|
+
containerStyle,
|
|
90
92
|
testID,
|
|
91
93
|
loading = false
|
|
92
94
|
} = props;
|
|
@@ -133,7 +135,9 @@ const Accordion = props => {
|
|
|
133
135
|
}, [measuredHeight]);
|
|
134
136
|
const handlePress = useCallback(() => {
|
|
135
137
|
if (disabled) return;
|
|
136
|
-
|
|
138
|
+
if (theme.components.accordion?.pressHaptic ?? false) {
|
|
139
|
+
triggerHaptic('selection');
|
|
140
|
+
}
|
|
137
141
|
if (group && id) {
|
|
138
142
|
group.toggle(id);
|
|
139
143
|
onChange?.(!expanded);
|
|
@@ -141,7 +145,7 @@ const Accordion = props => {
|
|
|
141
145
|
}
|
|
142
146
|
if (!isControlled) setInternalExpanded(!expanded);
|
|
143
147
|
onChange?.(!expanded);
|
|
144
|
-
}, [disabled, group, id, expanded, isControlled, onChange]);
|
|
148
|
+
}, [disabled, group, id, expanded, isControlled, onChange, theme.components.accordion]);
|
|
145
149
|
const rotate = rotateAnim.interpolate({
|
|
146
150
|
inputRange: [0, 1],
|
|
147
151
|
outputRange: ['0deg', '180deg']
|
|
@@ -155,24 +159,12 @@ const Accordion = props => {
|
|
|
155
159
|
borderRadius: theme.radius.md
|
|
156
160
|
}] : null;
|
|
157
161
|
if (loading) {
|
|
158
|
-
return /*#__PURE__*/_jsx(
|
|
159
|
-
|
|
160
|
-
mode: "auto",
|
|
161
|
-
style: [cardStyle, style],
|
|
162
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
163
|
-
style: styles.header,
|
|
164
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
165
|
-
style: [styles.title, {
|
|
166
|
-
fontSize: theme.typography.fontSize.base
|
|
167
|
-
}],
|
|
168
|
-
numberOfLines: 1,
|
|
169
|
-
children: title ?? ' '
|
|
170
|
-
})
|
|
171
|
-
})
|
|
162
|
+
return /*#__PURE__*/_jsx(AccordionSkeleton, {
|
|
163
|
+
...props
|
|
172
164
|
});
|
|
173
165
|
}
|
|
174
166
|
return /*#__PURE__*/_jsxs(View, {
|
|
175
|
-
style: [cardStyle, style],
|
|
167
|
+
style: [cardStyle, style, containerStyle],
|
|
176
168
|
testID: testID,
|
|
177
169
|
children: [/*#__PURE__*/_jsxs(Pressable, {
|
|
178
170
|
onPress: handlePress,
|
|
@@ -218,7 +210,7 @@ const Accordion = props => {
|
|
|
218
210
|
} : {
|
|
219
211
|
height: animatedHeight,
|
|
220
212
|
opacity: opacityAnim
|
|
221
|
-
}]
|
|
213
|
+
}, contentWrapperStyle]
|
|
222
214
|
// Re-measure if children change size by listening to layout of inner
|
|
223
215
|
,
|
|
224
216
|
children: /*#__PURE__*/_jsx(View, {
|
|
@@ -231,12 +223,61 @@ const Accordion = props => {
|
|
|
231
223
|
};
|
|
232
224
|
Accordion.displayName = 'Accordion';
|
|
233
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Placeholder shape for `<Accordion>`. Header pill with a title-line
|
|
228
|
+
* skeleton; content is collapsed (matches the closed-by-default behaviour).
|
|
229
|
+
*/
|
|
230
|
+
const AccordionSkeleton = ({
|
|
231
|
+
variant = 'plain',
|
|
232
|
+
style
|
|
233
|
+
}) => {
|
|
234
|
+
const theme = useTheme();
|
|
235
|
+
const isCard = variant === 'card';
|
|
236
|
+
return /*#__PURE__*/_jsx(View, {
|
|
237
|
+
style: [isCard ? {
|
|
238
|
+
paddingHorizontal: theme.spacing.md,
|
|
239
|
+
paddingVertical: theme.spacing.sm,
|
|
240
|
+
backgroundColor: theme.colors.background.elevated,
|
|
241
|
+
borderRadius: theme.radius.md
|
|
242
|
+
} : {
|
|
243
|
+
paddingVertical: theme.spacing.sm
|
|
244
|
+
}, style],
|
|
245
|
+
accessibilityRole: "progressbar",
|
|
246
|
+
accessibilityState: {
|
|
247
|
+
busy: true
|
|
248
|
+
},
|
|
249
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
250
|
+
style: {
|
|
251
|
+
flexDirection: 'row',
|
|
252
|
+
alignItems: 'center'
|
|
253
|
+
},
|
|
254
|
+
children: [/*#__PURE__*/_jsx(Skeleton, {
|
|
255
|
+
shape: "text",
|
|
256
|
+
width: "60%",
|
|
257
|
+
height: 18,
|
|
258
|
+
style: {
|
|
259
|
+
flex: 1
|
|
260
|
+
}
|
|
261
|
+
}), /*#__PURE__*/_jsx(Skeleton, {
|
|
262
|
+
width: 16,
|
|
263
|
+
height: 16,
|
|
264
|
+
radius: "sm",
|
|
265
|
+
style: {
|
|
266
|
+
marginLeft: theme.spacing.sm
|
|
267
|
+
}
|
|
268
|
+
})]
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
AccordionSkeleton.displayName = 'AccordionSkeleton';
|
|
273
|
+
Accordion.Skeleton = AccordionSkeleton;
|
|
274
|
+
|
|
234
275
|
// Suppress unused warnings on platforms that don't support LayoutAnimation
|
|
235
276
|
void LayoutAnimation;
|
|
236
277
|
const buildStyles = theme => StyleSheet.create({
|
|
237
278
|
card: {
|
|
238
279
|
paddingHorizontal: theme.spacing.md,
|
|
239
|
-
paddingVertical: 4,
|
|
280
|
+
paddingVertical: theme.components.accordion?.cardPaddingVertical ?? 4,
|
|
240
281
|
marginVertical: theme.spacing.xs
|
|
241
282
|
},
|
|
242
283
|
header: {
|
|
@@ -35,7 +35,8 @@ const variantSize = (theme, variant) => {
|
|
|
35
35
|
};
|
|
36
36
|
const ActionButton = ({
|
|
37
37
|
action,
|
|
38
|
-
side
|
|
38
|
+
side,
|
|
39
|
+
badgeStyle
|
|
39
40
|
}) => {
|
|
40
41
|
const theme = useTheme();
|
|
41
42
|
const {
|
|
@@ -47,7 +48,9 @@ const ActionButton = ({
|
|
|
47
48
|
});
|
|
48
49
|
const styles = useMemo(() => buildActionStyles(theme), [theme]);
|
|
49
50
|
const onPress = () => {
|
|
50
|
-
|
|
51
|
+
if (theme.components.appBar?.pressHaptic ?? false) {
|
|
52
|
+
triggerHaptic('selection');
|
|
53
|
+
}
|
|
51
54
|
action.onPress();
|
|
52
55
|
};
|
|
53
56
|
const badgeValue = action.badge;
|
|
@@ -76,7 +79,7 @@ const ActionButton = ({
|
|
|
76
79
|
style: styles.iconWrap,
|
|
77
80
|
children: action.icon
|
|
78
81
|
}), badgeValue !== undefined && !badgeIsDot ? /*#__PURE__*/_jsx(View, {
|
|
79
|
-
style: styles.badge,
|
|
82
|
+
style: [styles.badge, badgeStyle],
|
|
80
83
|
pointerEvents: "none",
|
|
81
84
|
children: /*#__PURE__*/_jsx(Text, {
|
|
82
85
|
style: styles.badgeText,
|
|
@@ -101,6 +104,10 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
101
104
|
transparent = false,
|
|
102
105
|
scrollY,
|
|
103
106
|
style,
|
|
107
|
+
containerStyle,
|
|
108
|
+
titleStyle,
|
|
109
|
+
subtitleStyle,
|
|
110
|
+
badgeStyle,
|
|
104
111
|
testID
|
|
105
112
|
} = props;
|
|
106
113
|
const theme = useTheme();
|
|
@@ -112,6 +119,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
112
119
|
// Interpolations for the collapsing-app-bar behaviour. Native driver supports
|
|
113
120
|
// transform/opacity; height + borderBottomWidth must run on the JS driver and
|
|
114
121
|
// are wired through the same scrollY (RN coalesces the listener).
|
|
122
|
+
const collapseTranslateDistance = theme.components.appBar?.collapseTranslateDistance ?? -20;
|
|
115
123
|
const collapse = useMemo(() => {
|
|
116
124
|
if (!scrollY) return null;
|
|
117
125
|
const clamp = {
|
|
@@ -127,7 +135,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
127
135
|
// area. Approximate vertical travel = (large 96 - default 56) / 2.
|
|
128
136
|
titleTranslateY: scrollY.interpolate({
|
|
129
137
|
...clamp,
|
|
130
|
-
outputRange: [0,
|
|
138
|
+
outputRange: [0, collapseTranslateDistance]
|
|
131
139
|
}),
|
|
132
140
|
titleTranslateX: scrollY.interpolate({
|
|
133
141
|
...clamp,
|
|
@@ -148,7 +156,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
148
156
|
outputRange: [0, 1]
|
|
149
157
|
})
|
|
150
158
|
};
|
|
151
|
-
}, [scrollY, titleAlignment]);
|
|
159
|
+
}, [scrollY, titleAlignment, collapseTranslateDistance]);
|
|
152
160
|
const titleNode = title ? /*#__PURE__*/_jsx(Animated.Text, {
|
|
153
161
|
style: [styles.title, {
|
|
154
162
|
fontSize: v.titleSize,
|
|
@@ -162,7 +170,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
162
170
|
}, {
|
|
163
171
|
scale: collapse.titleScale
|
|
164
172
|
}]
|
|
165
|
-
} : null],
|
|
173
|
+
} : null, titleStyle],
|
|
166
174
|
numberOfLines: 1,
|
|
167
175
|
children: title
|
|
168
176
|
}) : null;
|
|
@@ -171,7 +179,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
171
179
|
textAlign: titleAlignment === 'center' ? 'center' : 'left'
|
|
172
180
|
}, isCollapsing && collapse ? {
|
|
173
181
|
opacity: collapse.subtitleOpacity
|
|
174
|
-
} : null],
|
|
182
|
+
} : null, subtitleStyle],
|
|
175
183
|
numberOfLines: 1,
|
|
176
184
|
children: subtitle
|
|
177
185
|
}) : null;
|
|
@@ -202,7 +210,7 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
202
210
|
!isCollapsing ? {
|
|
203
211
|
borderBottomWidth: transparent ? 0 : StyleSheet.hairlineWidth,
|
|
204
212
|
borderBottomColor: theme.colors.border.primary
|
|
205
|
-
} : null, style],
|
|
213
|
+
} : null, style, containerStyle],
|
|
206
214
|
children: [isCollapsing && collapse && !transparent ? /*#__PURE__*/_jsx(Animated.View, {
|
|
207
215
|
pointerEvents: "none",
|
|
208
216
|
style: [styles.animatedBorder, {
|
|
@@ -226,7 +234,8 @@ const AppBar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
226
234
|
style: [styles.sideSlot, styles.sideSlotRight],
|
|
227
235
|
children: rightActions?.map((action, index) => /*#__PURE__*/_jsx(ActionButton, {
|
|
228
236
|
action: action,
|
|
229
|
-
side: "right"
|
|
237
|
+
side: "right",
|
|
238
|
+
badgeStyle: badgeStyle
|
|
230
239
|
}, `appbar-right-${index}`))
|
|
231
240
|
})]
|
|
232
241
|
})]
|
|
@@ -249,7 +258,7 @@ const buildStyles = theme => StyleSheet.create({
|
|
|
249
258
|
sideSlot: {
|
|
250
259
|
flexDirection: 'row',
|
|
251
260
|
alignItems: 'center',
|
|
252
|
-
minWidth: 48
|
|
261
|
+
minWidth: theme.components.appBar?.sideSlotMinWidth ?? 48
|
|
253
262
|
},
|
|
254
263
|
sideSlotRight: {
|
|
255
264
|
justifyContent: 'flex-end'
|
|
@@ -277,7 +286,7 @@ const buildStyles = theme => StyleSheet.create({
|
|
|
277
286
|
color: theme.colors.text.primary
|
|
278
287
|
},
|
|
279
288
|
subtitle: {
|
|
280
|
-
marginTop: 2,
|
|
289
|
+
marginTop: theme.components.appBar?.subtitleMarginTop ?? 2,
|
|
281
290
|
color: theme.colors.text.tertiary,
|
|
282
291
|
fontSize: theme.typography.fontSize.sm,
|
|
283
292
|
fontWeight: theme.typography.fontWeight.normal
|
|
@@ -292,8 +301,8 @@ const buildStyles = theme => StyleSheet.create({
|
|
|
292
301
|
});
|
|
293
302
|
const buildActionStyles = theme => StyleSheet.create({
|
|
294
303
|
actionButton: {
|
|
295
|
-
width: 40,
|
|
296
|
-
height: 40,
|
|
304
|
+
width: theme.components.appBar?.actionButtonSize ?? 40,
|
|
305
|
+
height: theme.components.appBar?.actionButtonSize ?? 40,
|
|
297
306
|
borderRadius: theme.radius.full,
|
|
298
307
|
alignItems: 'center',
|
|
299
308
|
justifyContent: 'center'
|
|
@@ -313,11 +322,11 @@ const buildActionStyles = theme => StyleSheet.create({
|
|
|
313
322
|
},
|
|
314
323
|
badge: {
|
|
315
324
|
position: 'absolute',
|
|
316
|
-
top: 4,
|
|
317
|
-
right: 4,
|
|
318
|
-
minWidth: 16,
|
|
319
|
-
height: 16,
|
|
320
|
-
paddingHorizontal: 4,
|
|
325
|
+
top: theme.components.appBar?.badgeOffset ?? 4,
|
|
326
|
+
right: theme.components.appBar?.badgeOffset ?? 4,
|
|
327
|
+
minWidth: theme.components.appBar?.badgeMinWidth ?? 16,
|
|
328
|
+
height: theme.components.appBar?.badgeHeight ?? 16,
|
|
329
|
+
paddingHorizontal: theme.components.appBar?.badgePaddingHorizontal ?? 4,
|
|
321
330
|
borderRadius: theme.radius.full,
|
|
322
331
|
backgroundColor: theme.colors.error,
|
|
323
332
|
alignItems: 'center',
|
|
@@ -325,9 +334,9 @@ const buildActionStyles = theme => StyleSheet.create({
|
|
|
325
334
|
},
|
|
326
335
|
badgeText: {
|
|
327
336
|
color: theme.colors.text.inverse,
|
|
328
|
-
fontSize: 10,
|
|
337
|
+
fontSize: theme.components.appBar?.badgeFontSize ?? 10,
|
|
329
338
|
fontWeight: theme.typography.fontWeight.semibold,
|
|
330
|
-
lineHeight: 12
|
|
339
|
+
lineHeight: theme.components.appBar?.badgeLineHeight ?? 12
|
|
331
340
|
}
|
|
332
341
|
});
|
|
333
342
|
export { AppBar };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { Children, cloneElement, forwardRef, isValidElement, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { Animated, Easing, Image, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { useTheme, createAnimatedValue } from "../../theme/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Skeleton } from "../Skeleton/index.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const sizeMap = {
|
|
9
9
|
xs: 24,
|
|
@@ -65,6 +65,7 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
65
65
|
statusPosition = 'bottomRight',
|
|
66
66
|
backgroundColor,
|
|
67
67
|
color,
|
|
68
|
+
fontSize: fontSizeProp,
|
|
68
69
|
loading = false,
|
|
69
70
|
accessibilityLabel,
|
|
70
71
|
style,
|
|
@@ -72,9 +73,14 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
72
73
|
testID
|
|
73
74
|
} = props;
|
|
74
75
|
const theme = useTheme();
|
|
76
|
+
const avatarTokens = theme.components.avatar;
|
|
75
77
|
const [imageFailed, setImageFailed] = useState(false);
|
|
76
78
|
const dimension = useMemo(() => resolveSize(size), [size]);
|
|
77
79
|
const borderRadius = useMemo(() => resolveRadius(shape, dimension), [shape, dimension]);
|
|
80
|
+
const borderWidth = avatarTokens?.borderWidth ?? 0;
|
|
81
|
+
const borderColor = avatarTokens?.borderColor ?? theme.colors.border.primary;
|
|
82
|
+
const statusBorder = avatarTokens?.statusBorderWidth ?? 2;
|
|
83
|
+
const statusBorderColor = avatarTokens?.statusBorderColor ?? theme.colors.background.elevated;
|
|
78
84
|
const initials = useMemo(() => initialsFromName(name), [name]);
|
|
79
85
|
const resolvedBackground = useMemo(() => {
|
|
80
86
|
if (backgroundColor) return backgroundColor;
|
|
@@ -82,9 +88,11 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
82
88
|
}, [backgroundColor, name]);
|
|
83
89
|
const resolvedTextColor = color ?? theme.colors.text.inverse;
|
|
84
90
|
const showImage = !!source && !imageFailed;
|
|
85
|
-
|
|
91
|
+
// Font size resolution: per-instance prop → absolute theme token → ratio
|
|
92
|
+
// token → library default (40% of avatar dimension, floored at 10px).
|
|
93
|
+
const fontSizeRatio = avatarTokens?.fontSizeRatio ?? 0.4;
|
|
94
|
+
const fontSize = fontSizeProp ?? avatarTokens?.fontSize ?? Math.max(10, Math.round(dimension * fontSizeRatio));
|
|
86
95
|
const statusSize = Math.max(8, Math.round(dimension * 0.25));
|
|
87
|
-
const statusBorder = 2;
|
|
88
96
|
const a11yLabel = accessibilityLabel ?? (name ? `${name}'s avatar` : 'Avatar');
|
|
89
97
|
const rendered = /*#__PURE__*/_jsxs(View, {
|
|
90
98
|
ref: ref,
|
|
@@ -92,6 +100,8 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
92
100
|
width: dimension,
|
|
93
101
|
height: dimension,
|
|
94
102
|
borderRadius,
|
|
103
|
+
borderWidth,
|
|
104
|
+
borderColor,
|
|
95
105
|
backgroundColor: showImage ? theme.colors.background.tertiary : resolvedBackground
|
|
96
106
|
}, style],
|
|
97
107
|
accessible: true,
|
|
@@ -112,7 +122,7 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
112
122
|
style: [styles.initials, {
|
|
113
123
|
color: resolvedTextColor,
|
|
114
124
|
fontSize,
|
|
115
|
-
fontWeight: theme.typography.fontWeight
|
|
125
|
+
fontWeight: theme.typography.fontWeight[avatarTokens?.fontWeight ?? 'semibold']
|
|
116
126
|
}, textStyle],
|
|
117
127
|
numberOfLines: 1,
|
|
118
128
|
allowFontScaling: false,
|
|
@@ -124,22 +134,42 @@ const Avatar = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
124
134
|
borderRadius: statusSize / 2,
|
|
125
135
|
backgroundColor: statusColor(theme, status),
|
|
126
136
|
borderWidth: statusBorder,
|
|
127
|
-
borderColor:
|
|
137
|
+
borderColor: statusBorderColor
|
|
128
138
|
}],
|
|
129
139
|
accessible: false,
|
|
130
140
|
pointerEvents: "none"
|
|
131
141
|
}) : null]
|
|
132
142
|
});
|
|
133
143
|
if (loading) {
|
|
134
|
-
return /*#__PURE__*/_jsx(
|
|
135
|
-
|
|
136
|
-
mode: "auto",
|
|
137
|
-
children: rendered
|
|
144
|
+
return /*#__PURE__*/_jsx(AvatarSkeleton, {
|
|
145
|
+
...props
|
|
138
146
|
});
|
|
139
147
|
}
|
|
140
148
|
return rendered;
|
|
141
149
|
});
|
|
142
150
|
Avatar.displayName = 'Avatar';
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Authored placeholder for `<Avatar>`. Matches the real shape (circle /
|
|
154
|
+
* rounded / square at the requested size), so the layout doesn't shift
|
|
155
|
+
* when the image / name resolves.
|
|
156
|
+
*/
|
|
157
|
+
const AvatarSkeleton = ({
|
|
158
|
+
size = 'md',
|
|
159
|
+
shape = 'circle',
|
|
160
|
+
style
|
|
161
|
+
}) => {
|
|
162
|
+
const dim = resolveSize(size);
|
|
163
|
+
const skeletonShape = shape === 'circle' ? 'circle' : shape === 'rounded' ? 'rounded' : 'rect';
|
|
164
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
165
|
+
shape: skeletonShape,
|
|
166
|
+
width: dim,
|
|
167
|
+
height: dim,
|
|
168
|
+
style: style
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
AvatarSkeleton.displayName = 'AvatarSkeleton';
|
|
172
|
+
Avatar.Skeleton = AvatarSkeleton;
|
|
143
173
|
const styles = StyleSheet.create({
|
|
144
174
|
root: {
|
|
145
175
|
alignItems: 'center',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import React, { forwardRef, useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { Animated, Easing, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { fontFor, useTheme, createAnimatedValue, setNativeValue } from "../../theme/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { Skeleton } from "../Skeleton/index.js";
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const toneFor = (theme, tone) => {
|
|
9
9
|
switch (tone) {
|
|
@@ -196,15 +196,77 @@ const Badge = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
196
196
|
children: badgeContent
|
|
197
197
|
});
|
|
198
198
|
if (loading) {
|
|
199
|
-
return /*#__PURE__*/_jsx(
|
|
200
|
-
|
|
201
|
-
mode: "auto",
|
|
202
|
-
children: rendered
|
|
199
|
+
return /*#__PURE__*/_jsx(BadgeSkeleton, {
|
|
200
|
+
...props
|
|
203
201
|
});
|
|
204
202
|
}
|
|
205
203
|
return rendered;
|
|
206
204
|
});
|
|
207
205
|
Badge.displayName = 'Badge';
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Placeholder shape for `<Badge>`. Dot variant renders a small circle at
|
|
209
|
+
* the dot size; standard variant renders a pill shape at the badge's
|
|
210
|
+
* resolved height. Anchored badges (with `children`) overlay the badge
|
|
211
|
+
* shape on a wrapper that hosts the children below.
|
|
212
|
+
*/
|
|
213
|
+
const BadgeSkeleton = ({
|
|
214
|
+
variant = 'standard',
|
|
215
|
+
size = 'md',
|
|
216
|
+
children,
|
|
217
|
+
anchor,
|
|
218
|
+
style,
|
|
219
|
+
badgeStyle
|
|
220
|
+
}) => {
|
|
221
|
+
const sz = sizeMap[size];
|
|
222
|
+
if (variant === 'dot') {
|
|
223
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
224
|
+
shape: "circle",
|
|
225
|
+
width: sz.dot,
|
|
226
|
+
height: sz.dot,
|
|
227
|
+
style: [badgeStyle, style]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const pillRadius = sz.height / 2;
|
|
231
|
+
// Anchored badge: render the children underneath, overlay the badge.
|
|
232
|
+
if (children !== undefined) {
|
|
233
|
+
const offsetStyle = anchor === 'topLeft' ? {
|
|
234
|
+
top: -sz.height / 2,
|
|
235
|
+
left: -sz.height / 2
|
|
236
|
+
} : anchor === 'bottomRight' ? {
|
|
237
|
+
bottom: -sz.height / 2,
|
|
238
|
+
right: -sz.height / 2
|
|
239
|
+
} : anchor === 'bottomLeft' ? {
|
|
240
|
+
bottom: -sz.height / 2,
|
|
241
|
+
left: -sz.height / 2
|
|
242
|
+
} : {
|
|
243
|
+
top: -sz.height / 2,
|
|
244
|
+
right: -sz.height / 2
|
|
245
|
+
};
|
|
246
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
247
|
+
style: [styles.wrapper, style],
|
|
248
|
+
children: [children, /*#__PURE__*/_jsx(View, {
|
|
249
|
+
style: [{
|
|
250
|
+
position: 'absolute'
|
|
251
|
+
}, offsetStyle],
|
|
252
|
+
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
253
|
+
width: sz.minWidth + sz.paddingH,
|
|
254
|
+
height: sz.height,
|
|
255
|
+
radius: pillRadius,
|
|
256
|
+
style: badgeStyle
|
|
257
|
+
})
|
|
258
|
+
})]
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return /*#__PURE__*/_jsx(Skeleton, {
|
|
262
|
+
width: sz.minWidth + sz.paddingH,
|
|
263
|
+
height: sz.height,
|
|
264
|
+
radius: pillRadius,
|
|
265
|
+
style: [badgeStyle, style]
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
BadgeSkeleton.displayName = 'BadgeSkeleton';
|
|
269
|
+
Badge.Skeleton = BadgeSkeleton;
|
|
208
270
|
const styles = StyleSheet.create({
|
|
209
271
|
wrapper: {
|
|
210
272
|
position: 'relative',
|