@webority-technologies/mobile 0.0.24 → 0.0.25
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/Autocomplete/Autocomplete.js +204 -0
- package/lib/commonjs/components/Autocomplete/index.js +13 -0
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +170 -0
- package/lib/commonjs/components/Confetti/index.js +13 -0
- package/lib/commonjs/components/FieldBase/FieldBase.js +0 -2
- package/lib/commonjs/components/IconButton/IconButton.js +176 -0
- package/lib/commonjs/components/IconButton/index.js +13 -0
- package/lib/commonjs/components/Modal/Modal.js +0 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +32 -4
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +224 -0
- package/lib/commonjs/components/SlideToConfirm/index.js +13 -0
- package/lib/commonjs/components/index.js +142 -114
- package/lib/commonjs/hooks/usePressAnimation.js +0 -1
- package/lib/module/components/Autocomplete/Autocomplete.js +199 -0
- package/lib/module/components/Autocomplete/index.js +4 -0
- package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +166 -0
- package/lib/module/components/Confetti/index.js +4 -0
- package/lib/module/components/FieldBase/FieldBase.js +0 -2
- package/lib/module/components/IconButton/IconButton.js +172 -0
- package/lib/module/components/IconButton/index.js +4 -0
- package/lib/module/components/Modal/Modal.js +0 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +33 -5
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +220 -0
- package/lib/module/components/SlideToConfirm/index.js +4 -0
- package/lib/module/components/index.js +4 -0
- package/lib/module/hooks/usePressAnimation.js +0 -1
- package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +53 -0
- package/lib/typescript/commonjs/components/Autocomplete/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +41 -0
- package/lib/typescript/commonjs/components/Confetti/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +34 -0
- package/lib/typescript/commonjs/components/IconButton/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +12 -0
- package/lib/typescript/commonjs/components/ProgressBar/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
- package/lib/typescript/commonjs/components/SlideToConfirm/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts +9 -1
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +1 -2
- package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +53 -0
- package/lib/typescript/module/components/Autocomplete/index.d.ts +3 -0
- package/lib/typescript/module/components/Confetti/Confetti.d.ts +41 -0
- package/lib/typescript/module/components/Confetti/index.d.ts +3 -0
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +34 -0
- package/lib/typescript/module/components/IconButton/index.d.ts +3 -0
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +12 -0
- package/lib/typescript/module/components/ProgressBar/index.d.ts +1 -1
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +34 -0
- package/lib/typescript/module/components/SlideToConfirm/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts +9 -1
- package/lib/typescript/module/hooks/usePressAnimation.d.ts +1 -2
- package/package.json +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Autocomplete = Autocomplete;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _index = require("../../theme/index.js");
|
|
11
|
+
var _index2 = require("../../utils/index.js");
|
|
12
|
+
var _index3 = require("../../hooks/index.js");
|
|
13
|
+
var _index4 = require("../Input/index.js");
|
|
14
|
+
var _index5 = require("../Spinner/index.js");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
+
const defaultGetLabel = o => typeof o === 'string' ? o : String(o);
|
|
18
|
+
function Autocomplete(props) {
|
|
19
|
+
const {
|
|
20
|
+
options,
|
|
21
|
+
value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
onChangeText,
|
|
24
|
+
onSelect,
|
|
25
|
+
getOptionLabel,
|
|
26
|
+
getOptionKey,
|
|
27
|
+
filter,
|
|
28
|
+
minChars = 1,
|
|
29
|
+
maxResults = 8,
|
|
30
|
+
emptyText = 'No matches',
|
|
31
|
+
loading = false,
|
|
32
|
+
filterMode = 'client',
|
|
33
|
+
loadingText = 'Searching…',
|
|
34
|
+
placeholder,
|
|
35
|
+
label,
|
|
36
|
+
error,
|
|
37
|
+
helperText,
|
|
38
|
+
disabled = false,
|
|
39
|
+
size = 'md',
|
|
40
|
+
variant,
|
|
41
|
+
haptic,
|
|
42
|
+
style,
|
|
43
|
+
listStyle,
|
|
44
|
+
optionTextStyle,
|
|
45
|
+
testID
|
|
46
|
+
} = props;
|
|
47
|
+
const theme = (0, _index.useTheme)();
|
|
48
|
+
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
49
|
+
const [text, setText] = (0, _index3.useControllableState)({
|
|
50
|
+
value,
|
|
51
|
+
defaultValue: defaultValue ?? '',
|
|
52
|
+
onChange: onChangeText
|
|
53
|
+
});
|
|
54
|
+
const [focused, setFocused] = (0, _react.useState)(false);
|
|
55
|
+
const [fieldHeight, setFieldHeight] = (0, _react.useState)(0);
|
|
56
|
+
const blurTimer = (0, _react.useRef)(null);
|
|
57
|
+
const labelOf = (0, _react.useCallback)(o => getOptionLabel ? getOptionLabel(o) : defaultGetLabel(o), [getOptionLabel]);
|
|
58
|
+
const filtered = (0, _react.useMemo)(() => {
|
|
59
|
+
// Server-side search: trust the provided options, don't re-filter them away.
|
|
60
|
+
if (filterMode === 'none') return options.slice(0, maxResults);
|
|
61
|
+
const q = text.trim();
|
|
62
|
+
if (q.length < minChars) return [];
|
|
63
|
+
const lower = q.toLowerCase();
|
|
64
|
+
const match = filter ? o => filter(o, q) : o => labelOf(o).toLowerCase().includes(lower);
|
|
65
|
+
return options.filter(match).slice(0, maxResults);
|
|
66
|
+
}, [options, text, minChars, maxResults, filter, labelOf, filterMode]);
|
|
67
|
+
const showList = focused && (loading || text.trim().length >= minChars);
|
|
68
|
+
const handleSelect = (0, _react.useCallback)(o => {
|
|
69
|
+
const h = (0, _index2.resolveHaptic)(haptic, 'selection');
|
|
70
|
+
if (h) (0, _index2.triggerHaptic)(h);
|
|
71
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
72
|
+
setText(labelOf(o));
|
|
73
|
+
setFocused(false);
|
|
74
|
+
_reactNative.Keyboard.dismiss();
|
|
75
|
+
onSelect(o);
|
|
76
|
+
}, [haptic, setText, labelOf, onSelect]);
|
|
77
|
+
_react.default.useEffect(() => () => {
|
|
78
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
79
|
+
}, []);
|
|
80
|
+
const onFieldLayout = (0, _react.useCallback)(e => {
|
|
81
|
+
setFieldHeight(e.nativeEvent.layout.height);
|
|
82
|
+
}, []);
|
|
83
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
84
|
+
style: [styles.container, style],
|
|
85
|
+
testID: testID,
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
87
|
+
onLayout: onFieldLayout,
|
|
88
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index4.Input, {
|
|
89
|
+
value: text,
|
|
90
|
+
onChangeText: setText,
|
|
91
|
+
onFocus: () => {
|
|
92
|
+
if (blurTimer.current) clearTimeout(blurTimer.current);
|
|
93
|
+
setFocused(true);
|
|
94
|
+
},
|
|
95
|
+
onBlur: () => {
|
|
96
|
+
blurTimer.current = setTimeout(() => setFocused(false), 120);
|
|
97
|
+
},
|
|
98
|
+
placeholder: placeholder,
|
|
99
|
+
label: label,
|
|
100
|
+
error: error,
|
|
101
|
+
helperText: helperText,
|
|
102
|
+
editable: !disabled,
|
|
103
|
+
size: size,
|
|
104
|
+
variant: variant,
|
|
105
|
+
autoCorrect: false,
|
|
106
|
+
autoCapitalize: "none"
|
|
107
|
+
})
|
|
108
|
+
}), showList ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
109
|
+
style: [styles.list, {
|
|
110
|
+
top: fieldHeight,
|
|
111
|
+
backgroundColor: theme.colors.background.elevated,
|
|
112
|
+
borderColor: theme.colors.border.primary,
|
|
113
|
+
borderRadius: theme.radius.md,
|
|
114
|
+
...theme.shadows.lg
|
|
115
|
+
}, listStyle],
|
|
116
|
+
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
117
|
+
style: styles.loadingRow,
|
|
118
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index5.Spinner, {
|
|
119
|
+
size: "sm"
|
|
120
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
121
|
+
style: [styles.loadingText, {
|
|
122
|
+
color: theme.colors.text.secondary,
|
|
123
|
+
fontSize: theme.typography.fontSize.sm
|
|
124
|
+
}],
|
|
125
|
+
children: loadingText
|
|
126
|
+
})]
|
|
127
|
+
}) : filtered.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
128
|
+
style: [styles.empty, {
|
|
129
|
+
color: theme.colors.text.tertiary,
|
|
130
|
+
fontSize: theme.typography.fontSize.sm
|
|
131
|
+
}],
|
|
132
|
+
children: emptyText
|
|
133
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
|
|
134
|
+
keyboardShouldPersistTaps: "handled",
|
|
135
|
+
style: styles.scroll,
|
|
136
|
+
children: filtered.map((o, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
137
|
+
onPress: () => handleSelect(o),
|
|
138
|
+
android_ripple: {
|
|
139
|
+
color: theme.colors.surface.pressed
|
|
140
|
+
},
|
|
141
|
+
style: ({
|
|
142
|
+
pressed
|
|
143
|
+
}) => [styles.option, {
|
|
144
|
+
paddingHorizontal: theme.spacing.md,
|
|
145
|
+
paddingVertical: theme.spacing.sm,
|
|
146
|
+
backgroundColor: pressed ? theme.colors.surface.pressed : 'transparent'
|
|
147
|
+
}],
|
|
148
|
+
accessibilityRole: "button",
|
|
149
|
+
accessibilityLabel: labelOf(o),
|
|
150
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
151
|
+
style: [styles.optionText, {
|
|
152
|
+
color: theme.colors.text.primary,
|
|
153
|
+
fontSize: theme.typography.fontSize.base
|
|
154
|
+
}, optionTextStyle],
|
|
155
|
+
numberOfLines: 1,
|
|
156
|
+
children: labelOf(o)
|
|
157
|
+
})
|
|
158
|
+
}, getOptionKey ? getOptionKey(o) : `${labelOf(o)}-${i}`))
|
|
159
|
+
})
|
|
160
|
+
}) : null]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
Autocomplete.displayName = 'Autocomplete';
|
|
164
|
+
const buildStyles = theme => _reactNative.StyleSheet.create({
|
|
165
|
+
container: {
|
|
166
|
+
width: '100%',
|
|
167
|
+
position: 'relative',
|
|
168
|
+
zIndex: 10
|
|
169
|
+
},
|
|
170
|
+
list: {
|
|
171
|
+
position: 'absolute',
|
|
172
|
+
left: 0,
|
|
173
|
+
right: 0,
|
|
174
|
+
borderWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
175
|
+
overflow: 'hidden',
|
|
176
|
+
zIndex: 20,
|
|
177
|
+
maxHeight: 240
|
|
178
|
+
},
|
|
179
|
+
scroll: {
|
|
180
|
+
maxHeight: 240
|
|
181
|
+
},
|
|
182
|
+
option: {
|
|
183
|
+
width: '100%'
|
|
184
|
+
},
|
|
185
|
+
optionText: {
|
|
186
|
+
includeFontPadding: false
|
|
187
|
+
},
|
|
188
|
+
empty: {
|
|
189
|
+
padding: theme.spacing.md,
|
|
190
|
+
textAlign: 'center',
|
|
191
|
+
includeFontPadding: false
|
|
192
|
+
},
|
|
193
|
+
loadingRow: {
|
|
194
|
+
flexDirection: 'row',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
gap: theme.spacing.sm,
|
|
197
|
+
padding: theme.spacing.md
|
|
198
|
+
},
|
|
199
|
+
loadingText: {
|
|
200
|
+
includeFontPadding: false
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
var _default = exports.default = Autocomplete;
|
|
204
|
+
//# sourceMappingURL=Autocomplete.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Autocomplete", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Autocomplete.Autocomplete;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Autocomplete = require("./Autocomplete.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -159,7 +159,7 @@ const BottomNavigation = exports.BottomNavigation = /*#__PURE__*/(0, _react.forw
|
|
|
159
159
|
translateX: indicatorTranslateX
|
|
160
160
|
}]
|
|
161
161
|
}, indicatorStyle]
|
|
162
|
-
}) : null, tabs.map(
|
|
162
|
+
}) : null, tabs.map(tab => {
|
|
163
163
|
const isActive = tab.key === activeTab;
|
|
164
164
|
const color = isActive ? theme.colors.primary : theme.colors.text.tertiary;
|
|
165
165
|
const renderIcon = isActive && tab.activeIcon ? tab.activeIcon : tab.icon;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Confetti = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _index = require("../../theme/index.js");
|
|
11
|
+
var _index2 = require("../../hooks/index.js");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
14
|
+
const TAU = Math.PI * 2;
|
|
15
|
+
const rand = (min, max) => min + Math.random() * (max - min);
|
|
16
|
+
const buildPieces = (count, colors, mode, baseSize) => Array.from({
|
|
17
|
+
length: count
|
|
18
|
+
}, (_, i) => {
|
|
19
|
+
const isCannon = mode === 'cannon';
|
|
20
|
+
return {
|
|
21
|
+
color: colors[i % colors.length] ?? colors[0],
|
|
22
|
+
size: baseSize * rand(0.6, 1.4),
|
|
23
|
+
isCircle: Math.random() < 0.35,
|
|
24
|
+
baseXFrac: isCannon ? 0.5 : Math.random(),
|
|
25
|
+
vxFrac: isCannon ? rand(-0.7, 0.7) : rand(-0.15, 0.15),
|
|
26
|
+
vy0Frac: isCannon ? rand(-1.5, -1.0) : rand(0, 0.15),
|
|
27
|
+
rotations: rand(1, 5),
|
|
28
|
+
rotateDir: Math.random() < 0.5 ? 1 : -1,
|
|
29
|
+
swayAmp: rand(8, 28),
|
|
30
|
+
swayFreq: rand(1, 3),
|
|
31
|
+
flutterFreq: rand(2, 5)
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const ConfettiPiece = ({
|
|
35
|
+
piece,
|
|
36
|
+
progress,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
originX,
|
|
40
|
+
originY,
|
|
41
|
+
mode,
|
|
42
|
+
fadeOut
|
|
43
|
+
}) => {
|
|
44
|
+
const animStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
45
|
+
const t = progress.value;
|
|
46
|
+
const startX = mode === 'cannon' ? originX : piece.baseXFrac * width;
|
|
47
|
+
const startY = mode === 'cannon' ? originY : -piece.size * 2;
|
|
48
|
+
const gravity = height * (mode === 'cannon' ? 1.8 : 1.5);
|
|
49
|
+
const x = startX + piece.vxFrac * width * t + Math.sin(t * piece.swayFreq * TAU) * piece.swayAmp;
|
|
50
|
+
const y = startY + piece.vy0Frac * height * t + gravity * t * t;
|
|
51
|
+
const rotate = piece.rotateDir * piece.rotations * 360 * t;
|
|
52
|
+
// Paper-flutter: oscillate scaleX so pieces read as thin spinning paper.
|
|
53
|
+
const flutter = 0.35 + 0.65 * Math.abs(Math.cos(t * piece.flutterFreq * TAU));
|
|
54
|
+
const opacity = fadeOut ? Math.max(0, 1 - Math.max(0, t - 0.8) / 0.2) : 1;
|
|
55
|
+
return {
|
|
56
|
+
opacity,
|
|
57
|
+
transform: [{
|
|
58
|
+
translateX: x
|
|
59
|
+
}, {
|
|
60
|
+
translateY: y
|
|
61
|
+
}, {
|
|
62
|
+
rotate: `${rotate}deg`
|
|
63
|
+
}, {
|
|
64
|
+
scaleX: flutter
|
|
65
|
+
}]
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
69
|
+
style: [{
|
|
70
|
+
position: 'absolute',
|
|
71
|
+
width: piece.size,
|
|
72
|
+
height: piece.isCircle ? piece.size : piece.size * 0.5,
|
|
73
|
+
borderRadius: piece.isCircle ? piece.size / 2 : 1,
|
|
74
|
+
backgroundColor: piece.color
|
|
75
|
+
}, animStyle]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const Confetti = exports.Confetti = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
79
|
+
count = 80,
|
|
80
|
+
colors,
|
|
81
|
+
mode = 'rain',
|
|
82
|
+
origin,
|
|
83
|
+
duration = 2800,
|
|
84
|
+
fadeOut = true,
|
|
85
|
+
autoStart = false,
|
|
86
|
+
recycle = false,
|
|
87
|
+
size = 10,
|
|
88
|
+
onComplete,
|
|
89
|
+
style,
|
|
90
|
+
testID
|
|
91
|
+
}, ref) => {
|
|
92
|
+
const theme = (0, _index.useTheme)();
|
|
93
|
+
const reduceMotion = (0, _index2.useReducedMotion)();
|
|
94
|
+
const window = (0, _reactNative.useWindowDimensions)();
|
|
95
|
+
const [layout, setLayout] = (0, _react.useState)({
|
|
96
|
+
width: window.width,
|
|
97
|
+
height: window.height
|
|
98
|
+
});
|
|
99
|
+
const [active, setActive] = (0, _react.useState)(false);
|
|
100
|
+
const [pieces, setPieces] = (0, _react.useState)([]);
|
|
101
|
+
const palette = (0, _react.useMemo)(() => colors ?? [theme.colors.primary, theme.colors.secondary, theme.colors.success, theme.colors.warning, theme.colors.error, theme.colors.info], [colors, theme.colors]);
|
|
102
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
103
|
+
const finish = (0, _react.useCallback)(() => {
|
|
104
|
+
setActive(false);
|
|
105
|
+
onComplete?.();
|
|
106
|
+
}, [onComplete]);
|
|
107
|
+
const start = (0, _react.useCallback)(() => {
|
|
108
|
+
if (reduceMotion) {
|
|
109
|
+
onComplete?.();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
(0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
113
|
+
progress.value = 0;
|
|
114
|
+
setPieces(buildPieces(count, palette, mode, size));
|
|
115
|
+
setActive(true);
|
|
116
|
+
const tween = (0, _reactNativeReanimated.withTiming)(1, {
|
|
117
|
+
duration,
|
|
118
|
+
easing: _reactNativeReanimated.Easing.linear
|
|
119
|
+
}, finished => {
|
|
120
|
+
'worklet';
|
|
121
|
+
|
|
122
|
+
if (finished && !recycle) (0, _reactNativeReanimated.runOnJS)(finish)();
|
|
123
|
+
});
|
|
124
|
+
progress.value = recycle ? (0, _reactNativeReanimated.withRepeat)(tween, -1, false) : tween;
|
|
125
|
+
}, [reduceMotion, progress, duration, recycle, finish, onComplete, count, palette, mode, size]);
|
|
126
|
+
const stop = (0, _react.useCallback)(() => {
|
|
127
|
+
(0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
128
|
+
setActive(false);
|
|
129
|
+
}, [progress]);
|
|
130
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
131
|
+
start,
|
|
132
|
+
stop
|
|
133
|
+
}), [start, stop]);
|
|
134
|
+
(0, _react.useEffect)(() => {
|
|
135
|
+
if (autoStart) start();
|
|
136
|
+
return () => (0, _reactNativeReanimated.cancelAnimation)(progress);
|
|
137
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
|
+
}, []);
|
|
139
|
+
const onLayout = (0, _react.useCallback)(e => {
|
|
140
|
+
const {
|
|
141
|
+
width,
|
|
142
|
+
height
|
|
143
|
+
} = e.nativeEvent.layout;
|
|
144
|
+
if (width > 0 && height > 0) setLayout({
|
|
145
|
+
width,
|
|
146
|
+
height
|
|
147
|
+
});
|
|
148
|
+
}, []);
|
|
149
|
+
const originX = origin?.x ?? layout.width / 2;
|
|
150
|
+
const originY = origin?.y ?? layout.height;
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
152
|
+
style: [_reactNative.StyleSheet.absoluteFill, style],
|
|
153
|
+
pointerEvents: "none",
|
|
154
|
+
onLayout: onLayout,
|
|
155
|
+
testID: testID,
|
|
156
|
+
children: active ? pieces.map((piece, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(ConfettiPiece, {
|
|
157
|
+
piece: piece,
|
|
158
|
+
progress: progress,
|
|
159
|
+
width: layout.width,
|
|
160
|
+
height: layout.height,
|
|
161
|
+
originX: originX,
|
|
162
|
+
originY: originY,
|
|
163
|
+
mode: mode,
|
|
164
|
+
fadeOut: fadeOut
|
|
165
|
+
}, i)) : null
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
Confetti.displayName = 'Confetti';
|
|
169
|
+
var _default = exports.default = Confetti;
|
|
170
|
+
//# sourceMappingURL=Confetti.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Confetti", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Confetti.Confetti;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _Confetti = require("./Confetti.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -33,8 +33,6 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
33
33
|
* - Shake-on-error or any cross-field animation.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
const SIDES = ['top', 'right', 'bottom', 'left'];
|
|
37
|
-
|
|
38
36
|
/** Map a single colour string to all four sides (shorthand expansion). */
|
|
39
37
|
const expandColorSides = value => {
|
|
40
38
|
if (typeof value === 'string') {
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.IconButton = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _index = require("../../theme/index.js");
|
|
10
|
+
var _usePressAnimation = require("../../hooks/usePressAnimation.js");
|
|
11
|
+
var _index2 = require("../../utils/index.js");
|
|
12
|
+
var _index3 = require("../Spinner/index.js");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
const SIZE_MAP = {
|
|
16
|
+
sm: {
|
|
17
|
+
diameter: 32,
|
|
18
|
+
icon: 16
|
|
19
|
+
},
|
|
20
|
+
md: {
|
|
21
|
+
diameter: 40,
|
|
22
|
+
icon: 20
|
|
23
|
+
},
|
|
24
|
+
lg: {
|
|
25
|
+
diameter: 48,
|
|
26
|
+
icon: 24
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const toneFor = (theme, tone) => {
|
|
30
|
+
switch (tone) {
|
|
31
|
+
case 'secondary':
|
|
32
|
+
return {
|
|
33
|
+
base: theme.colors.secondary,
|
|
34
|
+
on: theme.colors.onSecondary,
|
|
35
|
+
fg: theme.colors.secondary
|
|
36
|
+
};
|
|
37
|
+
case 'success':
|
|
38
|
+
return {
|
|
39
|
+
base: theme.colors.success,
|
|
40
|
+
on: theme.colors.onSuccess,
|
|
41
|
+
fg: theme.colors.success
|
|
42
|
+
};
|
|
43
|
+
case 'warning':
|
|
44
|
+
return {
|
|
45
|
+
base: theme.colors.warning,
|
|
46
|
+
on: theme.colors.onWarning,
|
|
47
|
+
fg: theme.colors.warning
|
|
48
|
+
};
|
|
49
|
+
case 'error':
|
|
50
|
+
return {
|
|
51
|
+
base: theme.colors.error,
|
|
52
|
+
on: theme.colors.onError,
|
|
53
|
+
fg: theme.colors.error
|
|
54
|
+
};
|
|
55
|
+
case 'neutral':
|
|
56
|
+
return {
|
|
57
|
+
base: theme.colors.background.tertiary,
|
|
58
|
+
on: theme.colors.text.primary,
|
|
59
|
+
fg: theme.colors.text.primary
|
|
60
|
+
};
|
|
61
|
+
case 'primary':
|
|
62
|
+
default:
|
|
63
|
+
return {
|
|
64
|
+
base: theme.colors.primary,
|
|
65
|
+
on: theme.colors.onPrimary,
|
|
66
|
+
fg: theme.colors.primary
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const IconButton = exports.IconButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
71
|
+
const {
|
|
72
|
+
icon,
|
|
73
|
+
onPress,
|
|
74
|
+
accessibilityLabel,
|
|
75
|
+
tone = 'primary',
|
|
76
|
+
variant = 'solid',
|
|
77
|
+
size = 'md',
|
|
78
|
+
shape = 'circle',
|
|
79
|
+
active = false,
|
|
80
|
+
disabled = false,
|
|
81
|
+
loading = false,
|
|
82
|
+
haptic,
|
|
83
|
+
style,
|
|
84
|
+
testID
|
|
85
|
+
} = props;
|
|
86
|
+
const theme = (0, _index.useTheme)();
|
|
87
|
+
const sizeCfg = SIZE_MAP[size];
|
|
88
|
+
const isDisabled = disabled || loading;
|
|
89
|
+
const {
|
|
90
|
+
scale,
|
|
91
|
+
pressIn,
|
|
92
|
+
pressOut
|
|
93
|
+
} = (0, _usePressAnimation.usePressAnimation)({
|
|
94
|
+
scaleTo: 0.92,
|
|
95
|
+
enabled: !isDisabled
|
|
96
|
+
});
|
|
97
|
+
const {
|
|
98
|
+
base,
|
|
99
|
+
on,
|
|
100
|
+
fg
|
|
101
|
+
} = toneFor(theme, tone);
|
|
102
|
+
const effectiveVariant = active ? 'solid' : variant;
|
|
103
|
+
let backgroundColor = 'transparent';
|
|
104
|
+
let borderColor = 'transparent';
|
|
105
|
+
let borderWidth = 0;
|
|
106
|
+
let iconColor = isDisabled ? theme.colors.text.disabled : fg;
|
|
107
|
+
if (effectiveVariant === 'solid') {
|
|
108
|
+
backgroundColor = isDisabled ? theme.colors.surface.disabled : base;
|
|
109
|
+
iconColor = isDisabled ? theme.colors.text.disabled : on;
|
|
110
|
+
} else if (effectiveVariant === 'soft') {
|
|
111
|
+
backgroundColor = isDisabled ? theme.colors.surface.disabled : `${base}22`;
|
|
112
|
+
} else if (effectiveVariant === 'outline') {
|
|
113
|
+
borderColor = isDisabled ? theme.colors.border.primary : base;
|
|
114
|
+
borderWidth = theme.colors.border.width;
|
|
115
|
+
}
|
|
116
|
+
const radius = shape === 'circle' ? sizeCfg.diameter / 2 : theme.radius.md;
|
|
117
|
+
const handlePress = e => {
|
|
118
|
+
if (isDisabled) return;
|
|
119
|
+
const h = (0, _index2.resolveHaptic)(haptic, 'selection');
|
|
120
|
+
if (h) (0, _index2.triggerHaptic)(h);
|
|
121
|
+
onPress?.(e);
|
|
122
|
+
};
|
|
123
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
|
|
124
|
+
ref: ref,
|
|
125
|
+
onPress: handlePress,
|
|
126
|
+
onPressIn: pressIn,
|
|
127
|
+
onPressOut: pressOut,
|
|
128
|
+
disabled: isDisabled,
|
|
129
|
+
accessibilityRole: "button",
|
|
130
|
+
accessibilityLabel: accessibilityLabel,
|
|
131
|
+
accessibilityState: {
|
|
132
|
+
disabled: isDisabled,
|
|
133
|
+
selected: active
|
|
134
|
+
},
|
|
135
|
+
hitSlop: 6,
|
|
136
|
+
testID: testID,
|
|
137
|
+
style: ({
|
|
138
|
+
pressed
|
|
139
|
+
}) => [styles.base, {
|
|
140
|
+
width: sizeCfg.diameter,
|
|
141
|
+
height: sizeCfg.diameter,
|
|
142
|
+
borderRadius: radius,
|
|
143
|
+
backgroundColor,
|
|
144
|
+
borderColor,
|
|
145
|
+
borderWidth,
|
|
146
|
+
opacity: pressed && effectiveVariant !== 'solid' ? 0.7 : 1
|
|
147
|
+
}, style],
|
|
148
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
149
|
+
style: [styles.content, {
|
|
150
|
+
transform: [{
|
|
151
|
+
scale
|
|
152
|
+
}]
|
|
153
|
+
}],
|
|
154
|
+
children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index3.Spinner, {
|
|
155
|
+
size: "sm",
|
|
156
|
+
color: iconColor
|
|
157
|
+
}) : typeof icon === 'function' ? icon({
|
|
158
|
+
color: iconColor,
|
|
159
|
+
size: sizeCfg.icon
|
|
160
|
+
}) : icon
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
IconButton.displayName = 'IconButton';
|
|
165
|
+
const styles = _reactNative.StyleSheet.create({
|
|
166
|
+
base: {
|
|
167
|
+
alignItems: 'center',
|
|
168
|
+
justifyContent: 'center'
|
|
169
|
+
},
|
|
170
|
+
content: {
|
|
171
|
+
alignItems: 'center',
|
|
172
|
+
justifyContent: 'center'
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
var _default = exports.default = IconButton;
|
|
176
|
+
//# sourceMappingURL=IconButton.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "IconButton", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _IconButton.IconButton;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _IconButton = require("./IconButton.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -38,6 +38,8 @@ const ProgressBar = exports.ProgressBar = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
38
38
|
tone = 'primary',
|
|
39
39
|
trackColor,
|
|
40
40
|
barColor,
|
|
41
|
+
gradient,
|
|
42
|
+
segments,
|
|
41
43
|
animated = true,
|
|
42
44
|
style,
|
|
43
45
|
containerStyle,
|
|
@@ -58,6 +60,12 @@ const ProgressBar = exports.ProgressBar = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
58
60
|
const resolvedRadius = radius ?? theme.radius.full;
|
|
59
61
|
const resolvedTrack = trackColor ?? theme.colors.surface.disabled;
|
|
60
62
|
const resolvedBar = barColor ?? toneColor(theme, tone);
|
|
63
|
+
const resolvedGradient = (0, _react.useMemo)(() => {
|
|
64
|
+
if (!gradient) return null;
|
|
65
|
+
if (typeof gradient === 'string') return theme.gradients[gradient] ?? null;
|
|
66
|
+
return gradient;
|
|
67
|
+
}, [gradient, theme.gradients]);
|
|
68
|
+
const hasSegments = Array.isArray(segments) && segments.length > 0;
|
|
61
69
|
(0, _react.useEffect)(() => {
|
|
62
70
|
if (isIndeterminate) return;
|
|
63
71
|
if (!animated) {
|
|
@@ -116,7 +124,18 @@ const ProgressBar = exports.ProgressBar = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
116
124
|
borderRadius: resolvedRadius,
|
|
117
125
|
backgroundColor: resolvedTrack
|
|
118
126
|
}, style, containerStyle],
|
|
119
|
-
children:
|
|
127
|
+
children: hasSegments ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
128
|
+
style: [styles.segments, {
|
|
129
|
+
height
|
|
130
|
+
}],
|
|
131
|
+
children: (segments ?? []).map((s, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
132
|
+
style: {
|
|
133
|
+
width: `${clampProgress(s.value) * 100}%`,
|
|
134
|
+
height,
|
|
135
|
+
backgroundColor: s.color ?? toneColor(theme, s.tone ?? 'primary')
|
|
136
|
+
}
|
|
137
|
+
}, i))
|
|
138
|
+
}) : isIndeterminate ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
120
139
|
style: [styles.indeterminateBar, {
|
|
121
140
|
height,
|
|
122
141
|
borderRadius: resolvedRadius,
|
|
@@ -130,9 +149,14 @@ const ProgressBar = exports.ProgressBar = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
130
149
|
style: [styles.determinateBar, {
|
|
131
150
|
height,
|
|
132
151
|
borderRadius: resolvedRadius,
|
|
133
|
-
backgroundColor: resolvedBar,
|
|
134
|
-
width: determinateWidth
|
|
135
|
-
|
|
152
|
+
backgroundColor: resolvedGradient ? 'transparent' : resolvedBar,
|
|
153
|
+
width: determinateWidth,
|
|
154
|
+
overflow: resolvedGradient ? 'hidden' : undefined
|
|
155
|
+
}, barStyle],
|
|
156
|
+
children: resolvedGradient ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Gradient, {
|
|
157
|
+
gradient: resolvedGradient,
|
|
158
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
159
|
+
}) : null
|
|
136
160
|
})
|
|
137
161
|
});
|
|
138
162
|
});
|
|
@@ -151,6 +175,10 @@ const buildStyles = _theme => _reactNative.StyleSheet.create({
|
|
|
151
175
|
position: 'absolute',
|
|
152
176
|
left: 0,
|
|
153
177
|
top: 0
|
|
178
|
+
},
|
|
179
|
+
segments: {
|
|
180
|
+
flexDirection: 'row',
|
|
181
|
+
width: '100%'
|
|
154
182
|
}
|
|
155
183
|
});
|
|
156
184
|
var _default = exports.default = ProgressBar;
|