@webority-technologies/mobile 0.0.6 → 0.0.8
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/README.md +3 -463
- package/lib/commonjs/components/Badge/Badge.js +23 -13
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +39 -5
- package/lib/commonjs/components/Button/Button.js +25 -6
- package/lib/commonjs/components/Card/Card.js +13 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +5 -3
- package/lib/commonjs/components/Chip/Chip.js +12 -3
- package/lib/commonjs/components/Dialog/Dialog.js +15 -8
- package/lib/commonjs/components/EmptyState/EmptyState.js +32 -26
- package/lib/commonjs/components/FormField/FormField.js +3 -3
- package/lib/commonjs/components/Input/Input.js +13 -5
- package/lib/commonjs/components/ListItem/ListItem.js +33 -27
- package/lib/commonjs/components/OTPInput/OTPInput.js +6 -3
- package/lib/commonjs/components/Radio/Radio.js +7 -6
- package/lib/commonjs/components/SearchBar/SearchBar.js +9 -5
- package/lib/commonjs/components/Skeleton/Skeleton.js +20 -12
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +25 -9
- package/lib/commonjs/components/Skeleton/SkeletonList.js +7 -2
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +48 -0
- package/lib/commonjs/components/Skeleton/SkeletonSkip.js +37 -0
- package/lib/commonjs/components/Skeleton/index.js +20 -0
- package/lib/commonjs/components/Switch/Switch.js +31 -2
- package/lib/commonjs/components/Toast/Toast.js +16 -11
- package/lib/commonjs/components/index.js +18 -0
- package/lib/commonjs/theme/Gradient.js +57 -0
- package/lib/commonjs/theme/index.js +20 -0
- package/lib/commonjs/theme/textStyle.js +37 -0
- package/lib/commonjs/theme/tokens.js +260 -2
- package/lib/module/components/Badge/Badge.js +24 -14
- package/lib/module/components/BottomSheet/BottomSheet.js +40 -6
- package/lib/module/components/Button/Button.js +26 -7
- package/lib/module/components/Card/Card.js +14 -2
- package/lib/module/components/Checkbox/Checkbox.js +5 -3
- package/lib/module/components/Chip/Chip.js +13 -4
- package/lib/module/components/Dialog/Dialog.js +16 -9
- package/lib/module/components/EmptyState/EmptyState.js +33 -27
- package/lib/module/components/FormField/FormField.js +4 -4
- package/lib/module/components/Input/Input.js +14 -6
- package/lib/module/components/ListItem/ListItem.js +34 -28
- package/lib/module/components/OTPInput/OTPInput.js +7 -4
- package/lib/module/components/Radio/Radio.js +7 -6
- package/lib/module/components/SearchBar/SearchBar.js +10 -6
- package/lib/module/components/Skeleton/Skeleton.js +20 -12
- package/lib/module/components/Skeleton/SkeletonContent.js +25 -9
- package/lib/module/components/Skeleton/SkeletonList.js +7 -2
- package/lib/module/components/Skeleton/SkeletonProvider.js +41 -0
- package/lib/module/components/Skeleton/SkeletonSkip.js +31 -0
- package/lib/module/components/Skeleton/index.js +2 -0
- package/lib/module/components/Switch/Switch.js +31 -2
- package/lib/module/components/Toast/Toast.js +17 -12
- package/lib/module/components/index.js +1 -1
- package/lib/module/theme/Gradient.js +50 -0
- package/lib/module/theme/index.js +2 -0
- package/lib/module/theme/textStyle.js +32 -0
- package/lib/module/theme/tokens.js +260 -2
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +10 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts +8 -0
- package/lib/typescript/commonjs/components/Card/Card.d.ts +8 -0
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +5 -0
- package/lib/typescript/commonjs/components/Input/Input.d.ts +12 -0
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +9 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +6 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +3 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +32 -0
- package/lib/typescript/commonjs/components/Skeleton/SkeletonSkip.d.ts +25 -0
- package/lib/typescript/commonjs/components/Skeleton/index.d.ts +4 -0
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +5 -0
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +5 -0
- package/lib/typescript/commonjs/components/index.d.ts +2 -2
- package/lib/typescript/commonjs/theme/Gradient.d.ts +11 -0
- package/lib/typescript/commonjs/theme/index.d.ts +5 -1
- package/lib/typescript/commonjs/theme/textStyle.d.ts +18 -0
- package/lib/typescript/commonjs/theme/types.d.ts +178 -0
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +10 -0
- package/lib/typescript/module/components/Button/Button.d.ts +8 -0
- package/lib/typescript/module/components/Card/Card.d.ts +8 -0
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +5 -0
- package/lib/typescript/module/components/Input/Input.d.ts +12 -0
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +9 -0
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +6 -0
- package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +3 -0
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +32 -0
- package/lib/typescript/module/components/Skeleton/SkeletonSkip.d.ts +25 -0
- package/lib/typescript/module/components/Skeleton/index.d.ts +4 -0
- package/lib/typescript/module/components/Switch/Switch.d.ts +5 -0
- package/lib/typescript/module/components/Toast/Toast.d.ts +5 -0
- package/lib/typescript/module/components/index.d.ts +2 -2
- package/lib/typescript/module/theme/Gradient.d.ts +11 -0
- package/lib/typescript/module/theme/index.d.ts +5 -1
- package/lib/typescript/module/theme/textStyle.d.ts +18 -0
- package/lib/typescript/module/theme/types.d.ts +178 -0
- package/package.json +5 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React, { Children, cloneElement, isValidElement, useState } from 'react';
|
|
4
4
|
import { Image, StyleSheet, Text, View } from 'react-native';
|
|
5
5
|
import { Skeleton } from "./Skeleton.js";
|
|
6
|
+
import { SkeletonSkip } from "./SkeletonSkip.js";
|
|
6
7
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
8
|
const flattenStyle = style => {
|
|
8
9
|
if (!style) return {};
|
|
@@ -22,7 +23,7 @@ const resolveRadius = (raw, fallback) => {
|
|
|
22
23
|
if (typeof raw === 'number') return raw;
|
|
23
24
|
return fallback;
|
|
24
25
|
};
|
|
25
|
-
const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
26
|
+
const skeletonizeNode = (node, variant, speed, colors, keyHint = 'r') => {
|
|
26
27
|
if (node == null || typeof node === 'boolean') return null;
|
|
27
28
|
if (typeof node === 'string' || typeof node === 'number') {
|
|
28
29
|
return /*#__PURE__*/_jsx(Skeleton, {
|
|
@@ -30,11 +31,12 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
30
31
|
height: 14,
|
|
31
32
|
radius: "sm",
|
|
32
33
|
variant: variant,
|
|
33
|
-
speed: speed
|
|
34
|
+
speed: speed,
|
|
35
|
+
colors: colors
|
|
34
36
|
}, `${keyHint}-text`);
|
|
35
37
|
}
|
|
36
38
|
if (Array.isArray(node)) {
|
|
37
|
-
return Children.map(node, (child, index) => skeletonizeNode(child, variant, speed, `${keyHint}-${index}`));
|
|
39
|
+
return Children.map(node, (child, index) => skeletonizeNode(child, variant, speed, colors, `${keyHint}-${index}`));
|
|
38
40
|
}
|
|
39
41
|
if (! /*#__PURE__*/isValidElement(node)) return null;
|
|
40
42
|
const element = node;
|
|
@@ -42,6 +44,13 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
42
44
|
const elementStyle = flattenStyle(props.style);
|
|
43
45
|
const elementType = element.type;
|
|
44
46
|
|
|
47
|
+
// <SkeletonSkip /> → opt-out marker; render its children unchanged
|
|
48
|
+
if (elementType === SkeletonSkip) {
|
|
49
|
+
return /*#__PURE__*/cloneElement(element, {
|
|
50
|
+
key: `${keyHint}-skip`
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
// <Image /> → fixed-size skeleton block matching style.width/height/borderRadius
|
|
46
55
|
if (elementType === Image) {
|
|
47
56
|
const width = resolveWidth(elementStyle.width, '100%');
|
|
@@ -53,6 +62,7 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
53
62
|
radius: radius,
|
|
54
63
|
variant: variant,
|
|
55
64
|
speed: speed,
|
|
65
|
+
colors: colors,
|
|
56
66
|
style: {
|
|
57
67
|
margin: typeof elementStyle.margin === 'number' ? elementStyle.margin : undefined
|
|
58
68
|
}
|
|
@@ -69,6 +79,7 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
69
79
|
radius: "sm",
|
|
70
80
|
variant: variant,
|
|
71
81
|
speed: speed,
|
|
82
|
+
colors: colors,
|
|
72
83
|
style: {
|
|
73
84
|
marginVertical: 2
|
|
74
85
|
}
|
|
@@ -79,7 +90,7 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
79
90
|
if (props.children != null) {
|
|
80
91
|
return /*#__PURE__*/cloneElement(element, {
|
|
81
92
|
key: `${keyHint}-w`
|
|
82
|
-
}, skeletonizeNode(props.children, variant, speed, `${keyHint}-c`));
|
|
93
|
+
}, skeletonizeNode(props.children, variant, speed, colors, `${keyHint}-c`));
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
// Leaf <View /> with explicit dimensions → skeleton block
|
|
@@ -92,7 +103,8 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
92
103
|
height: height,
|
|
93
104
|
radius: radius,
|
|
94
105
|
variant: variant,
|
|
95
|
-
speed: speed
|
|
106
|
+
speed: speed,
|
|
107
|
+
colors: colors
|
|
96
108
|
}, `${keyHint}-vw`);
|
|
97
109
|
}
|
|
98
110
|
|
|
@@ -105,10 +117,11 @@ const skeletonizeNode = (node, variant, speed, keyHint = 'r') => {
|
|
|
105
117
|
const SkeletonContent = ({
|
|
106
118
|
loading,
|
|
107
119
|
children,
|
|
108
|
-
variant
|
|
109
|
-
speed
|
|
120
|
+
variant,
|
|
121
|
+
speed,
|
|
110
122
|
mode = 'auto',
|
|
111
123
|
count = 1,
|
|
124
|
+
colors,
|
|
112
125
|
style,
|
|
113
126
|
testID
|
|
114
127
|
}) => {
|
|
@@ -128,6 +141,7 @@ const SkeletonContent = ({
|
|
|
128
141
|
testID: testID,
|
|
129
142
|
variant: variant,
|
|
130
143
|
speed: speed,
|
|
144
|
+
colors: colors,
|
|
131
145
|
children: repeated
|
|
132
146
|
});
|
|
133
147
|
}
|
|
@@ -138,7 +152,7 @@ const SkeletonContent = ({
|
|
|
138
152
|
accessibilityLabel: "Loading",
|
|
139
153
|
accessibilityRole: "progressbar",
|
|
140
154
|
accessibilityLiveRegion: "polite",
|
|
141
|
-
children: skeletonizeNode(repeated, variant, speed)
|
|
155
|
+
children: skeletonizeNode(repeated, variant, speed, colors)
|
|
142
156
|
});
|
|
143
157
|
};
|
|
144
158
|
SkeletonContent.displayName = 'SkeletonContent';
|
|
@@ -146,6 +160,7 @@ const BlockSkeleton = ({
|
|
|
146
160
|
children,
|
|
147
161
|
variant,
|
|
148
162
|
speed,
|
|
163
|
+
colors,
|
|
149
164
|
style,
|
|
150
165
|
testID
|
|
151
166
|
}) => {
|
|
@@ -182,7 +197,8 @@ const BlockSkeleton = ({
|
|
|
182
197
|
height: size.height,
|
|
183
198
|
radius: "md",
|
|
184
199
|
variant: variant,
|
|
185
|
-
speed: speed
|
|
200
|
+
speed: speed,
|
|
201
|
+
colors: colors
|
|
186
202
|
})
|
|
187
203
|
}) : null]
|
|
188
204
|
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { FlatList, View } from 'react-native';
|
|
5
5
|
import { SkeletonContent } from "./SkeletonContent.js";
|
|
6
|
+
import { useSkeletonDefaults } from "./SkeletonProvider.js";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
/**
|
|
8
9
|
* Drop-in FlatList replacement that renders `placeholderCount` skeleton rows while
|
|
@@ -27,9 +28,10 @@ function SkeletonListInner(props) {
|
|
|
27
28
|
data,
|
|
28
29
|
renderItem,
|
|
29
30
|
renderPlaceholder,
|
|
30
|
-
placeholderCount
|
|
31
|
+
placeholderCount,
|
|
31
32
|
variant,
|
|
32
33
|
speed,
|
|
34
|
+
colors,
|
|
33
35
|
placeholderContainerStyle,
|
|
34
36
|
horizontal,
|
|
35
37
|
contentContainerStyle,
|
|
@@ -37,9 +39,11 @@ function SkeletonListInner(props) {
|
|
|
37
39
|
testID,
|
|
38
40
|
...rest
|
|
39
41
|
} = props;
|
|
42
|
+
const defaults = useSkeletonDefaults();
|
|
43
|
+
const resolvedCount = placeholderCount ?? defaults.placeholderCount ?? 3;
|
|
40
44
|
if (loading) {
|
|
41
45
|
const slots = Array.from({
|
|
42
|
-
length: Math.max(0,
|
|
46
|
+
length: Math.max(0, resolvedCount)
|
|
43
47
|
}, (_, index) => /*#__PURE__*/_jsx(React.Fragment, {
|
|
44
48
|
children: renderPlaceholder ? renderPlaceholder(index) : null
|
|
45
49
|
}, `sk-list-${index}`));
|
|
@@ -47,6 +51,7 @@ function SkeletonListInner(props) {
|
|
|
47
51
|
loading: true,
|
|
48
52
|
variant: variant,
|
|
49
53
|
speed: speed,
|
|
54
|
+
colors: colors,
|
|
50
55
|
style: style,
|
|
51
56
|
testID: testID,
|
|
52
57
|
children: /*#__PURE__*/_jsx(View, {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useMemo } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Per-instance color override for a skeleton. `background` is the resting tone
|
|
7
|
+
* of the placeholder; `highlight` is the moving shimmer band (or pulse fade).
|
|
8
|
+
* Either can be omitted — missing keys fall back to the active theme.
|
|
9
|
+
*/
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const SkeletonDefaultsContext = /*#__PURE__*/createContext({});
|
|
12
|
+
export const SkeletonProvider = ({
|
|
13
|
+
children,
|
|
14
|
+
variant,
|
|
15
|
+
speed,
|
|
16
|
+
placeholderCount,
|
|
17
|
+
radius,
|
|
18
|
+
colors
|
|
19
|
+
}) => {
|
|
20
|
+
const value = useMemo(() => ({
|
|
21
|
+
variant,
|
|
22
|
+
speed,
|
|
23
|
+
placeholderCount,
|
|
24
|
+
radius,
|
|
25
|
+
colors
|
|
26
|
+
}), [variant, speed, placeholderCount, radius, colors]);
|
|
27
|
+
return /*#__PURE__*/_jsx(SkeletonDefaultsContext.Provider, {
|
|
28
|
+
value: value,
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
SkeletonProvider.displayName = 'SkeletonProvider';
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Read the current SkeletonProvider defaults. Returns an empty object when no
|
|
36
|
+
* provider is mounted, so the skeleton primitives still work outside of one.
|
|
37
|
+
*/
|
|
38
|
+
export const useSkeletonDefaults = () => {
|
|
39
|
+
return useContext(SkeletonDefaultsContext);
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=SkeletonProvider.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
/**
|
|
6
|
+
* Pass-through marker that opts a subtree out of `SkeletonContent`'s auto walker.
|
|
7
|
+
*
|
|
8
|
+
* The walker recognizes this element type and returns its children unchanged
|
|
9
|
+
* even while `loading` is true. Use it to keep a specific Text/Image/View
|
|
10
|
+
* visible inside a skeleton block — e.g., a brand mark, a status icon, or a
|
|
11
|
+
* decorative element that should never shimmer.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <SkeletonContent loading>
|
|
15
|
+
* <View style={styles.card}>
|
|
16
|
+
* <SkeletonSkip>
|
|
17
|
+
* <Image source={Logo} style={styles.brandMark} />
|
|
18
|
+
* </SkeletonSkip>
|
|
19
|
+
* <Text>Loading…</Text>
|
|
20
|
+
* </View>
|
|
21
|
+
* </SkeletonContent>
|
|
22
|
+
*/
|
|
23
|
+
export const SkeletonSkip = ({
|
|
24
|
+
children
|
|
25
|
+
}) => {
|
|
26
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
SkeletonSkip.displayName = 'SkeletonSkip';
|
|
31
|
+
//# sourceMappingURL=SkeletonSkip.js.map
|
|
@@ -3,4 +3,6 @@
|
|
|
3
3
|
export { Skeleton, SkeletonCircle, SkeletonText, SkeletonAvatar, SkeletonCard, SkeletonListItem, default } from "./Skeleton.js";
|
|
4
4
|
export { SkeletonContent } from "./SkeletonContent.js";
|
|
5
5
|
export { SkeletonList } from "./SkeletonList.js";
|
|
6
|
+
export { SkeletonProvider, useSkeletonDefaults } from "./SkeletonProvider.js";
|
|
7
|
+
export { SkeletonSkip } from "./SkeletonSkip.js";
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -48,6 +48,7 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
48
48
|
label,
|
|
49
49
|
accessibilityLabel,
|
|
50
50
|
haptic = 'selection',
|
|
51
|
+
bounce = false,
|
|
51
52
|
style,
|
|
52
53
|
trackStyle,
|
|
53
54
|
thumbStyle,
|
|
@@ -55,7 +56,11 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
55
56
|
...rest
|
|
56
57
|
} = props;
|
|
57
58
|
const theme = useTheme();
|
|
58
|
-
const sizeStyles =
|
|
59
|
+
const sizeStyles = {
|
|
60
|
+
...sizeMap[size],
|
|
61
|
+
...(theme.components.switch?.[size] ?? {})
|
|
62
|
+
};
|
|
63
|
+
const switchThumbColor = theme.components.switch?.thumbColor ?? '#FFFFFF';
|
|
59
64
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
60
65
|
const offTrackColor = theme.mode === 'dark' ? theme.colors.secondary : theme.colors.surface.disabled;
|
|
61
66
|
const onTrackColor = toneColor(theme, tone);
|
|
@@ -88,6 +93,28 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
88
93
|
inputRange: [0, 1],
|
|
89
94
|
outputRange: [offTrackColor, onTrackColor]
|
|
90
95
|
});
|
|
96
|
+
const bounceScale = useRef(new Animated.Value(1)).current;
|
|
97
|
+
const isFirstRender = useRef(true);
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!bounce) return;
|
|
100
|
+
if (isFirstRender.current) {
|
|
101
|
+
isFirstRender.current = false;
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
Animated.sequence([Animated.spring(bounceScale, {
|
|
105
|
+
toValue: 1.15,
|
|
106
|
+
damping: 10,
|
|
107
|
+
stiffness: 220,
|
|
108
|
+
mass: 1,
|
|
109
|
+
useNativeDriver: true
|
|
110
|
+
}), Animated.spring(bounceScale, {
|
|
111
|
+
toValue: 1,
|
|
112
|
+
damping: 14,
|
|
113
|
+
stiffness: 240,
|
|
114
|
+
mass: 1,
|
|
115
|
+
useNativeDriver: true
|
|
116
|
+
})]).start();
|
|
117
|
+
}, [value, bounce, bounceScale]);
|
|
91
118
|
const handlePress = event => {
|
|
92
119
|
if (disabled) return;
|
|
93
120
|
if (haptic !== false) triggerHaptic(haptic);
|
|
@@ -122,11 +149,14 @@ const Switch = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
122
149
|
}, trackStyle],
|
|
123
150
|
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
124
151
|
style: [styles.thumb, theme.shadows.sm, {
|
|
152
|
+
backgroundColor: switchThumbColor,
|
|
125
153
|
width: sizeStyles.thumbSize,
|
|
126
154
|
height: sizeStyles.thumbSize,
|
|
127
155
|
borderRadius: sizeStyles.thumbSize / 2,
|
|
128
156
|
transform: [{
|
|
129
157
|
translateX
|
|
158
|
+
}, {
|
|
159
|
+
scale: bounceScale
|
|
130
160
|
}]
|
|
131
161
|
}, thumbStyle]
|
|
132
162
|
})
|
|
@@ -155,7 +185,6 @@ const buildStyles = _theme => StyleSheet.create({
|
|
|
155
185
|
justifyContent: 'center'
|
|
156
186
|
},
|
|
157
187
|
thumb: {
|
|
158
|
-
backgroundColor: '#FFFFFF',
|
|
159
188
|
position: 'absolute',
|
|
160
189
|
top: 2
|
|
161
190
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
4
4
|
import { Animated, PanResponder, Pressable, StyleSheet, Text, View } from 'react-native';
|
|
5
|
-
import { useTheme } from "../../theme/index.js";
|
|
5
|
+
import { fontFor, useTheme } from "../../theme/index.js";
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
7
|
const SWIPE_DISMISS_THRESHOLD = 80;
|
|
8
8
|
const SWIPE_VELOCITY_THRESHOLD = 0.5;
|
|
@@ -18,6 +18,11 @@ const Toast = ({
|
|
|
18
18
|
const position = toast.position ?? 'bottom';
|
|
19
19
|
const styles = useMemo(() => buildStyles(theme), [theme]);
|
|
20
20
|
const tint = useMemo(() => tintFor(theme, variant), [theme, variant]);
|
|
21
|
+
const toastTokens = theme.components.toast;
|
|
22
|
+
const iconCircleSize = toastTokens?.iconCircleSize ?? 28;
|
|
23
|
+
const iconCircleBorderRadius = toastTokens?.iconCircleBorderRadius ?? 14;
|
|
24
|
+
const iconGlyphFontSize = toastTokens?.iconGlyphFontSize ?? 16;
|
|
25
|
+
const tintBarWidth = toastTokens?.tintBarWidth ?? 4;
|
|
21
26
|
const enterFrom = position === 'top' ? -120 : 120;
|
|
22
27
|
const translateY = useRef(new Animated.Value(enterFrom)).current;
|
|
23
28
|
const translateX = useRef(new Animated.Value(0)).current;
|
|
@@ -107,11 +112,15 @@ const Toast = ({
|
|
|
107
112
|
if (!glyph) return null;
|
|
108
113
|
return /*#__PURE__*/_jsx(View, {
|
|
109
114
|
style: [styles.iconCircle, {
|
|
115
|
+
width: iconCircleSize,
|
|
116
|
+
height: iconCircleSize,
|
|
117
|
+
borderRadius: iconCircleBorderRadius,
|
|
110
118
|
backgroundColor: tint + '22'
|
|
111
119
|
}],
|
|
112
120
|
children: /*#__PURE__*/_jsx(Text, {
|
|
113
121
|
style: [styles.iconGlyph, {
|
|
114
|
-
color: tint
|
|
122
|
+
color: tint,
|
|
123
|
+
fontSize: iconGlyphFontSize
|
|
115
124
|
}],
|
|
116
125
|
accessible: false,
|
|
117
126
|
children: glyph
|
|
@@ -138,9 +147,10 @@ const Toast = ({
|
|
|
138
147
|
}, {
|
|
139
148
|
scale: stackScale
|
|
140
149
|
}]
|
|
141
|
-
}],
|
|
150
|
+
}, toast.style],
|
|
142
151
|
children: [/*#__PURE__*/_jsx(View, {
|
|
143
152
|
style: [styles.tintBar, {
|
|
153
|
+
width: tintBarWidth,
|
|
144
154
|
backgroundColor: tint
|
|
145
155
|
}]
|
|
146
156
|
}), /*#__PURE__*/_jsxs(View, {
|
|
@@ -151,8 +161,8 @@ const Toast = ({
|
|
|
151
161
|
style: [styles.message, {
|
|
152
162
|
color: theme.colors.text.primary,
|
|
153
163
|
fontSize: theme.typography.fontSize.base,
|
|
154
|
-
|
|
155
|
-
}],
|
|
164
|
+
...fontFor(theme, 'semibold')
|
|
165
|
+
}, toast.textStyle],
|
|
156
166
|
numberOfLines: 2,
|
|
157
167
|
children: toast.message
|
|
158
168
|
}), toast.description ? /*#__PURE__*/_jsx(Text, {
|
|
@@ -176,7 +186,7 @@ const Toast = ({
|
|
|
176
186
|
style: {
|
|
177
187
|
color: tint,
|
|
178
188
|
fontSize: theme.typography.fontSize.sm,
|
|
179
|
-
|
|
189
|
+
...fontFor(theme, 'semibold')
|
|
180
190
|
},
|
|
181
191
|
numberOfLines: 1,
|
|
182
192
|
children: toast.action.label
|
|
@@ -224,8 +234,7 @@ const buildStyles = _theme => StyleSheet.create({
|
|
|
224
234
|
position: 'absolute',
|
|
225
235
|
left: 0,
|
|
226
236
|
top: 0,
|
|
227
|
-
bottom: 0
|
|
228
|
-
width: 4
|
|
237
|
+
bottom: 0
|
|
229
238
|
},
|
|
230
239
|
row: {
|
|
231
240
|
flexDirection: 'row',
|
|
@@ -233,15 +242,11 @@ const buildStyles = _theme => StyleSheet.create({
|
|
|
233
242
|
paddingLeft: 8
|
|
234
243
|
},
|
|
235
244
|
iconCircle: {
|
|
236
|
-
width: 28,
|
|
237
|
-
height: 28,
|
|
238
|
-
borderRadius: 14,
|
|
239
245
|
alignItems: 'center',
|
|
240
246
|
justifyContent: 'center',
|
|
241
247
|
marginRight: 12
|
|
242
248
|
},
|
|
243
249
|
iconGlyph: {
|
|
244
|
-
fontSize: 16,
|
|
245
250
|
fontWeight: '700',
|
|
246
251
|
lineHeight: 18
|
|
247
252
|
},
|
|
@@ -36,7 +36,7 @@ export { SearchBar } from "./SearchBar/index.js";
|
|
|
36
36
|
export { SegmentedControl } from "./SegmentedControl/index.js";
|
|
37
37
|
export { Select } from "./Select/index.js";
|
|
38
38
|
export { Stepper } from "./Stepper/index.js";
|
|
39
|
-
export { Skeleton, SkeletonAvatar, SkeletonCard, SkeletonCircle, SkeletonContent, SkeletonList, SkeletonListItem, SkeletonText } from "./Skeleton/index.js";
|
|
39
|
+
export { Skeleton, SkeletonAvatar, SkeletonCard, SkeletonCircle, SkeletonContent, SkeletonList, SkeletonListItem, SkeletonProvider, SkeletonSkip, SkeletonText, useSkeletonDefaults } from "./Skeleton/index.js";
|
|
40
40
|
export { Slider } from "./Slider/index.js";
|
|
41
41
|
export { Swipeable } from "./Swipeable/index.js";
|
|
42
42
|
export { Switch } from "./Switch/index.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View } from 'react-native';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* Render a linear gradient using `react-native-linear-gradient` when available.
|
|
8
|
+
*
|
|
9
|
+
* The dep is OPTIONAL — apps that never use gradients don't need it installed.
|
|
10
|
+
* If `<Gradient>` (or any component that accepts a `gradient` prop) is reached
|
|
11
|
+
* without the package present, we fall back to a flat View using the first
|
|
12
|
+
* colour and emit a one-time dev warning so the omission is loud but
|
|
13
|
+
* non-fatal.
|
|
14
|
+
*/
|
|
15
|
+
let LinearGradientImpl = null;
|
|
16
|
+
let warned = false;
|
|
17
|
+
try {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
19
|
+
LinearGradientImpl = require('react-native-linear-gradient').default;
|
|
20
|
+
} catch {
|
|
21
|
+
// Optional peer; resolved lazily by consumers that need gradients.
|
|
22
|
+
}
|
|
23
|
+
export const Gradient = ({
|
|
24
|
+
gradient,
|
|
25
|
+
style,
|
|
26
|
+
children
|
|
27
|
+
}) => {
|
|
28
|
+
if (LinearGradientImpl) {
|
|
29
|
+
return /*#__PURE__*/_jsx(LinearGradientImpl, {
|
|
30
|
+
colors: gradient.colors,
|
|
31
|
+
locations: gradient.locations,
|
|
32
|
+
start: gradient.start,
|
|
33
|
+
end: gradient.end,
|
|
34
|
+
style: style,
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (__DEV__ && !warned) {
|
|
39
|
+
warned = true;
|
|
40
|
+
console.warn('[@webority-technologies/mobile] gradient prop set but react-native-linear-gradient is not installed. ' + 'Run `npm install react-native-linear-gradient` to enable.');
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/_jsx(View, {
|
|
43
|
+
style: [{
|
|
44
|
+
backgroundColor: gradient.colors[0]
|
|
45
|
+
}, style],
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
export const isGradientAvailable = () => LinearGradientImpl != null;
|
|
50
|
+
//# sourceMappingURL=Gradient.js.map
|
|
@@ -45,4 +45,6 @@ export const subscribeTheme = callback => {
|
|
|
45
45
|
export { ThemeProvider, useTheme, useThemeMode } from "./ThemeContext.js";
|
|
46
46
|
export { lightTheme, darkTheme } from "./tokens.js";
|
|
47
47
|
export { mergeTheme } from "./merge.js";
|
|
48
|
+
export { fontFor } from "./textStyle.js";
|
|
49
|
+
export { Gradient, isGradientAvailable } from "./Gradient.js";
|
|
48
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const FAMILY_KEY = {
|
|
4
|
+
normal: 'regular',
|
|
5
|
+
medium: 'medium',
|
|
6
|
+
semibold: 'semibold',
|
|
7
|
+
bold: 'bold'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve text-weight style for the active theme.
|
|
12
|
+
*
|
|
13
|
+
* When the consumer registers a brand `theme.typography.fontFamily.<weight>`,
|
|
14
|
+
* we set `fontFamily` and leave `fontWeight` undefined — RN can't combine the
|
|
15
|
+
* two reliably across iOS/Android once a custom face is in play, so the brand
|
|
16
|
+
* file controls the weight glyph itself. Falls back to `fontWeight` when no
|
|
17
|
+
* brand font is registered for that weight.
|
|
18
|
+
*
|
|
19
|
+
* Note: the fontWeight scale uses `normal` while FontFamilyScale uses
|
|
20
|
+
* `regular` (the conventional font-name suffix). The helper maps between
|
|
21
|
+
* them transparently.
|
|
22
|
+
*/
|
|
23
|
+
export const fontFor = (theme, weight) => {
|
|
24
|
+
const family = theme.typography.fontFamily?.[FAMILY_KEY[weight]];
|
|
25
|
+
if (family) return {
|
|
26
|
+
fontFamily: family
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
fontWeight: theme.typography.fontWeight[weight]
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=textStyle.js.map
|