@webority-technologies/mobile 0.0.22 → 0.0.23
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 +4 -2
- package/lib/commonjs/components/Avatar/Avatar.js +4 -2
- package/lib/commonjs/components/Badge/Badge.js +5 -5
- package/lib/commonjs/components/Banner/Banner.js +8 -4
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +8 -9
- package/lib/commonjs/components/Box/Box.js +162 -0
- package/lib/commonjs/components/Box/index.js +37 -0
- package/lib/commonjs/components/Button/Button.js +7 -7
- package/lib/commonjs/components/Carousel/Carousel.js +4 -2
- package/lib/commonjs/components/Checkbox/Checkbox.js +14 -5
- package/lib/commonjs/components/DatePicker/DatePicker.js +9 -7
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +5 -2
- package/lib/commonjs/components/Dialog/Dialog.js +2 -2
- package/lib/commonjs/components/FieldBase/FieldBase.js +8 -4
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +13 -5
- package/lib/commonjs/components/FormField/FormField.js +61 -25
- package/lib/commonjs/components/Input/Input.js +41 -29
- package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +102 -0
- package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -0
- package/lib/commonjs/components/KeyboardToolbar/KeyboardToolbar.js +130 -0
- package/lib/commonjs/components/KeyboardToolbar/index.js +13 -0
- package/lib/commonjs/components/Modal/Modal.js +17 -6
- package/lib/commonjs/components/NumberInput/NumberInput.js +35 -28
- package/lib/commonjs/components/OTPInput/OTPInput.js +33 -18
- package/lib/commonjs/components/Radio/Radio.js +7 -5
- package/lib/commonjs/components/Radio/RadioGroup.js +10 -3
- package/lib/commonjs/components/SearchBar/SearchBar.js +4 -2
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +20 -10
- package/lib/commonjs/components/Select/Select.js +33 -32
- package/lib/commonjs/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/commonjs/components/Slider/Slider.js +42 -26
- package/lib/commonjs/components/Spinner/Spinner.js +5 -5
- package/lib/commonjs/components/Switch/Switch.js +29 -16
- package/lib/commonjs/components/Tabs/Tabs.js +4 -2
- package/lib/commonjs/components/Text/Text.js +142 -0
- package/lib/commonjs/components/Text/index.js +13 -0
- package/lib/commonjs/components/TimePicker/TimePicker.js +10 -7
- package/lib/commonjs/components/Toast/Toast.js +22 -10
- package/lib/commonjs/components/Tooltip/Tooltip.js +6 -2
- package/lib/commonjs/components/index.js +135 -89
- package/lib/commonjs/form/FormContext.js +40 -0
- package/lib/commonjs/form/index.js +68 -0
- package/lib/commonjs/form/path.js +79 -0
- package/lib/commonjs/form/rules.js +67 -0
- package/lib/commonjs/form/types.js +2 -0
- package/lib/commonjs/form/useField.js +54 -0
- package/lib/commonjs/form/useForm.js +316 -0
- package/lib/commonjs/hooks/index.js +14 -0
- package/lib/commonjs/hooks/useControllableState.js +30 -0
- package/lib/commonjs/hooks/useReducedMotion.js +31 -0
- package/lib/commonjs/index.js +96 -11
- package/lib/commonjs/theme/ThemeContext.js +30 -2
- package/lib/commonjs/theme/tokens.js +12 -0
- package/lib/module/components/Accordion/Accordion.js +4 -2
- package/lib/module/components/Avatar/Avatar.js +4 -2
- package/lib/module/components/Badge/Badge.js +5 -5
- package/lib/module/components/Banner/Banner.js +8 -4
- package/lib/module/components/BottomNavigation/BottomNavigation.js +6 -4
- package/lib/module/components/BottomSheet/BottomSheet.js +8 -9
- package/lib/module/components/Box/Box.js +156 -0
- package/lib/module/components/Box/index.js +4 -0
- package/lib/module/components/Button/Button.js +7 -7
- package/lib/module/components/Carousel/Carousel.js +4 -2
- package/lib/module/components/Checkbox/Checkbox.js +14 -5
- package/lib/module/components/DatePicker/DatePicker.js +9 -7
- package/lib/module/components/DateRangePicker/DateRangePicker.js +5 -2
- package/lib/module/components/Dialog/Dialog.js +2 -2
- package/lib/module/components/FieldBase/FieldBase.js +8 -4
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +13 -5
- package/lib/module/components/FormField/FormField.js +62 -26
- package/lib/module/components/Input/Input.js +41 -29
- package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +98 -0
- package/lib/module/components/KeyboardAwareScrollView/index.js +4 -0
- package/lib/module/components/KeyboardToolbar/KeyboardToolbar.js +125 -0
- package/lib/module/components/KeyboardToolbar/index.js +4 -0
- package/lib/module/components/Modal/Modal.js +17 -6
- package/lib/module/components/NumberInput/NumberInput.js +30 -23
- package/lib/module/components/OTPInput/OTPInput.js +30 -15
- package/lib/module/components/Radio/Radio.js +7 -5
- package/lib/module/components/Radio/RadioGroup.js +10 -3
- package/lib/module/components/SearchBar/SearchBar.js +4 -2
- package/lib/module/components/SegmentedControl/SegmentedControl.js +20 -10
- package/lib/module/components/Select/Select.js +33 -32
- package/lib/module/components/Skeleton/SkeletonContent.js +5 -2
- package/lib/module/components/Slider/Slider.js +42 -26
- package/lib/module/components/Spinner/Spinner.js +5 -5
- package/lib/module/components/Switch/Switch.js +29 -16
- package/lib/module/components/Tabs/Tabs.js +4 -2
- package/lib/module/components/Text/Text.js +138 -0
- package/lib/module/components/Text/index.js +4 -0
- package/lib/module/components/TimePicker/TimePicker.js +10 -7
- package/lib/module/components/Toast/Toast.js +22 -10
- package/lib/module/components/Tooltip/Tooltip.js +6 -2
- package/lib/module/components/index.js +4 -0
- package/lib/module/form/FormContext.js +32 -0
- package/lib/module/form/index.js +12 -0
- package/lib/module/form/path.js +72 -0
- package/lib/module/form/rules.js +52 -0
- package/lib/module/form/types.js +2 -0
- package/lib/module/form/useField.js +49 -0
- package/lib/module/form/useForm.js +312 -0
- package/lib/module/hooks/index.js +2 -0
- package/lib/module/hooks/useControllableState.js +26 -0
- package/lib/module/hooks/useReducedMotion.js +27 -0
- package/lib/module/index.js +3 -1
- package/lib/module/theme/ThemeContext.js +30 -2
- package/lib/module/theme/tokens.js +12 -0
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/commonjs/components/Box/Box.d.ts +60 -0
- package/lib/typescript/commonjs/components/Box/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/Button/Button.d.ts +1 -1
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +2 -2
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +13 -2
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
- package/lib/typescript/commonjs/components/KeyboardToolbar/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -2
- package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +3 -2
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +6 -4
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/commonjs/components/Text/Text.d.ts +25 -0
- package/lib/typescript/commonjs/components/Text/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -3
- package/lib/typescript/commonjs/components/index.d.ts +8 -0
- package/lib/typescript/commonjs/form/FormContext.d.ts +17 -0
- package/lib/typescript/commonjs/form/index.d.ts +9 -0
- package/lib/typescript/commonjs/form/path.d.ts +10 -0
- package/lib/typescript/commonjs/form/rules.d.ts +31 -0
- package/lib/typescript/commonjs/form/types.d.ts +94 -0
- package/lib/typescript/commonjs/form/useField.d.ts +27 -0
- package/lib/typescript/commonjs/form/useForm.d.ts +10 -0
- package/lib/typescript/commonjs/hooks/index.d.ts +3 -0
- package/lib/typescript/commonjs/hooks/useControllableState.d.ts +17 -0
- package/lib/typescript/commonjs/hooks/useReducedMotion.d.ts +8 -0
- package/lib/typescript/commonjs/index.d.ts +4 -2
- package/lib/typescript/commonjs/theme/types.d.ts +15 -0
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +1 -1
- package/lib/typescript/module/components/Box/Box.d.ts +60 -0
- package/lib/typescript/module/components/Box/index.d.ts +3 -0
- package/lib/typescript/module/components/Button/Button.d.ts +1 -1
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +3 -2
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -3
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +2 -2
- package/lib/typescript/module/components/FormField/FormField.d.ts +13 -2
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
- package/lib/typescript/module/components/KeyboardAwareScrollView/index.d.ts +3 -0
- package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
- package/lib/typescript/module/components/KeyboardToolbar/index.d.ts +3 -0
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -2
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
- package/lib/typescript/module/components/Radio/Radio.d.ts +2 -2
- package/lib/typescript/module/components/Radio/RadioGroup.d.ts +3 -2
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/module/components/Slider/Slider.d.ts +6 -4
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +1 -1
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/module/components/Text/Text.d.ts +25 -0
- package/lib/typescript/module/components/Text/index.d.ts +3 -0
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -3
- package/lib/typescript/module/components/index.d.ts +8 -0
- package/lib/typescript/module/form/FormContext.d.ts +17 -0
- package/lib/typescript/module/form/index.d.ts +9 -0
- package/lib/typescript/module/form/path.d.ts +10 -0
- package/lib/typescript/module/form/rules.d.ts +31 -0
- package/lib/typescript/module/form/types.d.ts +94 -0
- package/lib/typescript/module/form/useField.d.ts +27 -0
- package/lib/typescript/module/form/useForm.d.ts +10 -0
- package/lib/typescript/module/hooks/index.d.ts +3 -0
- package/lib/typescript/module/hooks/useControllableState.d.ts +17 -0
- package/lib/typescript/module/hooks/useReducedMotion.d.ts +8 -0
- package/lib/typescript/module/index.d.ts +4 -2
- package/lib/typescript/module/theme/types.d.ts +15 -0
- package/package.json +1 -1
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.NumberInput = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _index = require("../../
|
|
10
|
-
var _index2 = require("../../
|
|
9
|
+
var _index = require("../../hooks/index.js");
|
|
10
|
+
var _index2 = require("../../theme/index.js");
|
|
11
|
+
var _index3 = require("../../utils/index.js");
|
|
11
12
|
var _FieldBase = require("../FieldBase/FieldBase.js");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
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); }
|
|
@@ -48,6 +49,7 @@ const sanitizeTyped = (raw, allowDecimal) => {
|
|
|
48
49
|
const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
49
50
|
const {
|
|
50
51
|
value,
|
|
52
|
+
defaultValue,
|
|
51
53
|
onChange,
|
|
52
54
|
min = Number.NEGATIVE_INFINITY,
|
|
53
55
|
max = Number.POSITIVE_INFINITY,
|
|
@@ -71,7 +73,12 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
71
73
|
textInputProps,
|
|
72
74
|
testID
|
|
73
75
|
} = props;
|
|
74
|
-
const
|
|
76
|
+
const [current, setCurrent] = (0, _index.useControllableState)({
|
|
77
|
+
value,
|
|
78
|
+
defaultValue: defaultValue ?? props.min ?? 0,
|
|
79
|
+
onChange
|
|
80
|
+
});
|
|
81
|
+
const theme = (0, _index2.useTheme)();
|
|
75
82
|
const sizeTokens = (0, _FieldBase.resolveFieldSize)(theme, size);
|
|
76
83
|
const fieldText = (0, _FieldBase.resolveFieldTextStyle)(theme, {
|
|
77
84
|
disabled
|
|
@@ -81,7 +88,7 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
81
88
|
const longPressInterval = theme.components.numberInput?.longPressIntervalMs ?? DEFAULT_LONG_PRESS_INTERVAL;
|
|
82
89
|
const pressHaptic = theme.components.numberInput?.pressHaptic ?? false;
|
|
83
90
|
const inputRef = (0, _react.useRef)(null);
|
|
84
|
-
const [draft, setDraft] = (0, _react.useState)(formatValue(
|
|
91
|
+
const [draft, setDraft] = (0, _react.useState)(formatValue(current, allowDecimal, precision));
|
|
85
92
|
const [editing, setEditing] = (0, _react.useState)(false);
|
|
86
93
|
const [focused, setFocused] = (0, _react.useState)(false);
|
|
87
94
|
const repeatTimeoutRef = (0, _react.useRef)(null);
|
|
@@ -99,41 +106,41 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
99
106
|
(0, _react.useEffect)(() => clearRepeat, [clearRepeat]);
|
|
100
107
|
(0, _react.useEffect)(() => {
|
|
101
108
|
if (!editing) {
|
|
102
|
-
setDraft(formatValue(
|
|
109
|
+
setDraft(formatValue(current, allowDecimal, precision));
|
|
103
110
|
}
|
|
104
|
-
}, [
|
|
105
|
-
const atMin =
|
|
106
|
-
const atMax =
|
|
111
|
+
}, [current, allowDecimal, precision, editing]);
|
|
112
|
+
const atMin = current <= min;
|
|
113
|
+
const atMax = current >= max;
|
|
107
114
|
const interactive = !disabled;
|
|
108
115
|
const setExternal = (0, _react.useCallback)(next => {
|
|
109
116
|
const rounded = roundToPrecision(next, allowDecimal ? precision : 0);
|
|
110
117
|
const clamped = clamp(rounded, min, max);
|
|
111
|
-
if (clamped !==
|
|
112
|
-
|
|
118
|
+
if (clamped !== current) {
|
|
119
|
+
setCurrent(clamped);
|
|
113
120
|
}
|
|
114
|
-
}, [allowDecimal, max, min,
|
|
121
|
+
}, [allowDecimal, max, min, setCurrent, precision, current]);
|
|
115
122
|
const decrement = (0, _react.useCallback)(() => {
|
|
116
123
|
if (!interactive || atMin) return;
|
|
117
|
-
if (pressHaptic) (0,
|
|
118
|
-
setExternal(
|
|
119
|
-
}, [atMin, interactive, pressHaptic, setExternal, step,
|
|
124
|
+
if (pressHaptic) (0, _index3.triggerHaptic)('impactLight');
|
|
125
|
+
setExternal(current - step);
|
|
126
|
+
}, [atMin, interactive, pressHaptic, setExternal, step, current]);
|
|
120
127
|
const increment = (0, _react.useCallback)(() => {
|
|
121
128
|
if (!interactive || atMax) return;
|
|
122
|
-
if (pressHaptic) (0,
|
|
123
|
-
setExternal(
|
|
124
|
-
}, [atMax, interactive, pressHaptic, setExternal, step,
|
|
129
|
+
if (pressHaptic) (0, _index3.triggerHaptic)('impactLight');
|
|
130
|
+
setExternal(current + step);
|
|
131
|
+
}, [atMax, interactive, pressHaptic, setExternal, step, current]);
|
|
125
132
|
_react.default.useImperativeHandle(ref, () => ({
|
|
126
133
|
focus: () => inputRef.current?.focus(),
|
|
127
134
|
blur: () => inputRef.current?.blur(),
|
|
128
135
|
clear: () => {
|
|
129
136
|
setDraft('');
|
|
130
137
|
if (Number.isFinite(min) && min > 0) {
|
|
131
|
-
|
|
138
|
+
setCurrent(min);
|
|
132
139
|
} else {
|
|
133
|
-
|
|
140
|
+
setCurrent(0 < min ? min : 0 > max ? max : 0);
|
|
134
141
|
}
|
|
135
142
|
}
|
|
136
|
-
}), [max, min,
|
|
143
|
+
}), [max, min, setCurrent]);
|
|
137
144
|
const startRepeating = (0, _react.useCallback)(direction => {
|
|
138
145
|
if (!interactive) return;
|
|
139
146
|
clearRepeat();
|
|
@@ -153,27 +160,27 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
153
160
|
const parsed = Number(cleaned);
|
|
154
161
|
if (cleaned !== '' && cleaned !== '-' && cleaned !== '.' && Number.isFinite(parsed)) {
|
|
155
162
|
if (parsed >= min && parsed <= max) {
|
|
156
|
-
if (parsed !==
|
|
157
|
-
|
|
163
|
+
if (parsed !== current) {
|
|
164
|
+
setCurrent(roundToPrecision(parsed, allowDecimal ? precision : 0));
|
|
158
165
|
}
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
|
-
}, [allowDecimal, max, min,
|
|
168
|
+
}, [allowDecimal, max, min, setCurrent, precision, current]);
|
|
162
169
|
const handleBlur = (0, _react.useCallback)(() => {
|
|
163
170
|
setEditing(false);
|
|
164
171
|
setFocused(false);
|
|
165
172
|
const parsed = Number(draft);
|
|
166
173
|
if (draft === '' || !Number.isFinite(parsed)) {
|
|
167
|
-
setDraft(formatValue(
|
|
174
|
+
setDraft(formatValue(current, allowDecimal, precision));
|
|
168
175
|
return;
|
|
169
176
|
}
|
|
170
177
|
const rounded = roundToPrecision(parsed, allowDecimal ? precision : 0);
|
|
171
178
|
const clamped = clamp(rounded, min, max);
|
|
172
|
-
if (clamped !==
|
|
173
|
-
|
|
179
|
+
if (clamped !== current) {
|
|
180
|
+
setCurrent(clamped);
|
|
174
181
|
}
|
|
175
182
|
setDraft(formatValue(clamped, allowDecimal, precision));
|
|
176
|
-
}, [allowDecimal, draft, max, min,
|
|
183
|
+
}, [allowDecimal, draft, max, min, setCurrent, precision, current]);
|
|
177
184
|
const handleFocus = (0, _react.useCallback)(() => {
|
|
178
185
|
setEditing(true);
|
|
179
186
|
setFocused(true);
|
|
@@ -237,7 +244,7 @@ const NumberInput = exports.NumberInput = /*#__PURE__*/(0, _react.forwardRef)((p
|
|
|
237
244
|
accessibilityRole: "adjustable",
|
|
238
245
|
accessibilityLabel: accessibleInputLabel,
|
|
239
246
|
accessibilityValue: {
|
|
240
|
-
now: Number.isFinite(
|
|
247
|
+
now: Number.isFinite(current) ? current : 0
|
|
241
248
|
},
|
|
242
249
|
accessibilityState: {
|
|
243
250
|
disabled
|
|
@@ -7,7 +7,8 @@ exports.default = exports.OTPInput = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _index = require("../../theme/index.js");
|
|
10
|
-
var _index2 = require("../../
|
|
10
|
+
var _index2 = require("../../hooks/index.js");
|
|
11
|
+
var _index3 = require("../../utils/index.js");
|
|
11
12
|
var _FieldBase = require("../FieldBase/FieldBase.js");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
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); }
|
|
@@ -41,6 +42,7 @@ const sanitizeChar = (input, kind) => {
|
|
|
41
42
|
const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
42
43
|
const {
|
|
43
44
|
value,
|
|
45
|
+
defaultValue,
|
|
44
46
|
onChange,
|
|
45
47
|
onComplete,
|
|
46
48
|
length = 6,
|
|
@@ -56,6 +58,11 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
56
58
|
textStyle,
|
|
57
59
|
testID
|
|
58
60
|
} = props;
|
|
61
|
+
const [current, setCurrent] = (0, _index2.useControllableState)({
|
|
62
|
+
value,
|
|
63
|
+
defaultValue: defaultValue ?? '',
|
|
64
|
+
onChange
|
|
65
|
+
});
|
|
59
66
|
const theme = (0, _index.useTheme)();
|
|
60
67
|
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
61
68
|
const sizeStyles = {
|
|
@@ -86,6 +93,7 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
86
93
|
}, [length]);
|
|
87
94
|
const previousFocusedIndexRef = (0, _react.useRef)(-1);
|
|
88
95
|
const shakeOnError = theme.components.otpInput?.shakeOnError ?? false;
|
|
96
|
+
const reduceMotion = (0, _index2.useReducedMotion)();
|
|
89
97
|
const errorHaptic = theme.components.otpInput?.errorHaptic ?? false;
|
|
90
98
|
const selectionHaptic = theme.components.otpInput?.selectionHaptic ?? false;
|
|
91
99
|
const hasError = Boolean(error);
|
|
@@ -95,11 +103,12 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
95
103
|
// error is initially true — there's no transition to animate.
|
|
96
104
|
(0, _react.useEffect)(() => {
|
|
97
105
|
const isFirstRun = previousErrorRef.current === null;
|
|
106
|
+
let anim;
|
|
98
107
|
if (!isFirstRun && hasError && !previousErrorRef.current) {
|
|
99
|
-
if (errorHaptic) (0,
|
|
100
|
-
if (shakeOnError) {
|
|
108
|
+
if (errorHaptic) (0, _index3.triggerHaptic)('notificationError');
|
|
109
|
+
if (shakeOnError && !reduceMotion) {
|
|
101
110
|
(0, _index.setNativeValue)(shake, 0);
|
|
102
|
-
_reactNative.Animated.sequence([_reactNative.Animated.timing(shake, {
|
|
111
|
+
anim = _reactNative.Animated.sequence([_reactNative.Animated.timing(shake, {
|
|
103
112
|
toValue: 1,
|
|
104
113
|
duration: 75,
|
|
105
114
|
easing: _reactNative.Easing.linear,
|
|
@@ -119,10 +128,12 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
119
128
|
duration: 75,
|
|
120
129
|
easing: _reactNative.Easing.linear,
|
|
121
130
|
useNativeDriver: true
|
|
122
|
-
})])
|
|
131
|
+
})]);
|
|
132
|
+
anim.start();
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
135
|
previousErrorRef.current = hasError;
|
|
136
|
+
return () => anim?.stop();
|
|
126
137
|
}, [hasError, shake, shakeOnError, errorHaptic]);
|
|
127
138
|
|
|
128
139
|
// Animate underline opacity for the focused cell. Skip on first mount
|
|
@@ -132,17 +143,21 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
132
143
|
previousFocusedIndexRef.current = focusedIndex;
|
|
133
144
|
if (previous === focusedIndex) return;
|
|
134
145
|
if (previous === -1 && focusedIndex === -1) return;
|
|
146
|
+
const anims = [];
|
|
135
147
|
underlines.forEach((anim, idx) => {
|
|
136
148
|
const target = idx === focusedIndex ? 1 : 0;
|
|
137
149
|
// Only animate the cells whose target changed.
|
|
138
150
|
if (idx !== focusedIndex && idx !== previous) return;
|
|
139
|
-
_reactNative.Animated.timing(anim, {
|
|
151
|
+
const animation = _reactNative.Animated.timing(anim, {
|
|
140
152
|
toValue: target,
|
|
141
153
|
duration: theme.motion.duration.fast,
|
|
142
154
|
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
143
155
|
useNativeDriver: true
|
|
144
|
-
})
|
|
156
|
+
});
|
|
157
|
+
animation.start();
|
|
158
|
+
anims.push(animation);
|
|
145
159
|
});
|
|
160
|
+
return () => anims.forEach(a => a.stop());
|
|
146
161
|
}, [focusedIndex, underlines, theme]);
|
|
147
162
|
const focusCell = (0, _react.useCallback)(index => {
|
|
148
163
|
const target = inputsRef.current[index];
|
|
@@ -157,10 +172,10 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
157
172
|
current?.blur();
|
|
158
173
|
},
|
|
159
174
|
clear: () => {
|
|
160
|
-
|
|
175
|
+
setCurrent('');
|
|
161
176
|
focusCell(0);
|
|
162
177
|
}
|
|
163
|
-
}), [focusCell, focusedIndex,
|
|
178
|
+
}), [focusCell, focusedIndex, setCurrent]);
|
|
164
179
|
(0, _react.useEffect)(() => {
|
|
165
180
|
if (autoFocus && !disabled) {
|
|
166
181
|
// Defer one frame so the inputs are mounted.
|
|
@@ -171,19 +186,19 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
171
186
|
}, [autoFocus, disabled, focusCell]);
|
|
172
187
|
const cells = (0, _react.useMemo)(() => {
|
|
173
188
|
const arr = new Array(length).fill('');
|
|
174
|
-
for (let i = 0; i < Math.min(
|
|
175
|
-
arr[i] =
|
|
189
|
+
for (let i = 0; i < Math.min(current.length, length); i += 1) {
|
|
190
|
+
arr[i] = current[i] ?? '';
|
|
176
191
|
}
|
|
177
192
|
return arr;
|
|
178
|
-
}, [
|
|
193
|
+
}, [current, length]);
|
|
179
194
|
const updateValue = (0, _react.useCallback)(next => {
|
|
180
195
|
const trimmed = next.slice(0, length);
|
|
181
|
-
if (trimmed ===
|
|
182
|
-
|
|
196
|
+
if (trimmed === current) return;
|
|
197
|
+
setCurrent(trimmed);
|
|
183
198
|
if (trimmed.length === length && onComplete) {
|
|
184
199
|
onComplete(trimmed);
|
|
185
200
|
}
|
|
186
|
-
}, [length,
|
|
201
|
+
}, [length, setCurrent, onComplete, current]);
|
|
187
202
|
const handleChangeText = (0, _react.useCallback)((index, raw) => {
|
|
188
203
|
// Strip the ZWSP placeholder (used so iOS fires onKeyPress/Backspace on otherwise-empty cells).
|
|
189
204
|
const stripped = raw.replace(/\u200B/g, '');
|
|
@@ -213,10 +228,10 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
213
228
|
writeIndex += 1;
|
|
214
229
|
}
|
|
215
230
|
const next = chars.join('').slice(0, length);
|
|
216
|
-
const previousLength =
|
|
231
|
+
const previousLength = current.length;
|
|
217
232
|
updateValue(next);
|
|
218
233
|
if (next.length !== previousLength && selectionHaptic) {
|
|
219
|
-
(0,
|
|
234
|
+
(0, _index3.triggerHaptic)('selection');
|
|
220
235
|
}
|
|
221
236
|
|
|
222
237
|
// Move focus to the next empty cell or last cell.
|
|
@@ -226,7 +241,7 @@ const OTPInput = exports.OTPInput = /*#__PURE__*/(0, _react.forwardRef)((props,
|
|
|
226
241
|
} else {
|
|
227
242
|
focusCell(nextFocus);
|
|
228
243
|
}
|
|
229
|
-
}, [cells, focusCell, keyboardType, length, selectionHaptic, updateValue,
|
|
244
|
+
}, [cells, focusCell, keyboardType, length, selectionHaptic, updateValue, current]);
|
|
230
245
|
const handleKeyPress = (0, _react.useCallback)((index, e) => {
|
|
231
246
|
const key = e.nativeEvent.key;
|
|
232
247
|
if (key !== 'Backspace') return;
|
|
@@ -44,7 +44,7 @@ const Radio = exports.Radio = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =
|
|
|
44
44
|
const {
|
|
45
45
|
value,
|
|
46
46
|
selected: selectedProp,
|
|
47
|
-
|
|
47
|
+
onChange,
|
|
48
48
|
disabled: disabledProp = false,
|
|
49
49
|
label,
|
|
50
50
|
size = 'md',
|
|
@@ -74,13 +74,15 @@ const Radio = exports.Radio = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =
|
|
|
74
74
|
const resolvedHaptic = haptic === undefined ? pressHapticEnabled ? 'selection' : false : haptic;
|
|
75
75
|
const progress = (0, _react.useRef)((0, _index.createAnimatedValue)(selected ? 1 : 0)).current;
|
|
76
76
|
(0, _react.useEffect)(() => {
|
|
77
|
-
_reactNative.Animated.spring(progress, {
|
|
77
|
+
const anim = _reactNative.Animated.spring(progress, {
|
|
78
78
|
toValue: selected ? 1 : 0,
|
|
79
79
|
damping: theme.motion.spring.snappy.damping,
|
|
80
80
|
stiffness: theme.motion.spring.snappy.stiffness,
|
|
81
81
|
mass: theme.motion.spring.snappy.mass,
|
|
82
82
|
useNativeDriver: true
|
|
83
|
-
})
|
|
83
|
+
});
|
|
84
|
+
anim.start();
|
|
85
|
+
return () => anim.stop();
|
|
84
86
|
}, [selected, progress, theme.motion.spring.snappy]);
|
|
85
87
|
const scale = progress.interpolate({
|
|
86
88
|
inputRange: [0, 1],
|
|
@@ -90,9 +92,9 @@ const Radio = exports.Radio = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =
|
|
|
90
92
|
if (disabled) return;
|
|
91
93
|
if (resolvedHaptic !== false) (0, _hapticUtils.triggerHaptic)(resolvedHaptic);
|
|
92
94
|
if (ctx) {
|
|
93
|
-
ctx.
|
|
95
|
+
ctx.onChange(value);
|
|
94
96
|
} else {
|
|
95
|
-
|
|
97
|
+
onChange?.(value);
|
|
96
98
|
}
|
|
97
99
|
rest.onPressOut?.(event);
|
|
98
100
|
};
|
|
@@ -7,10 +7,12 @@ exports.default = exports.RadioGroup = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _Radio = require("./Radio.js");
|
|
10
|
+
var _index = require("../../hooks/index.js");
|
|
10
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
12
|
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); }
|
|
12
13
|
const RadioGroup = ({
|
|
13
14
|
value,
|
|
15
|
+
defaultValue,
|
|
14
16
|
onChange,
|
|
15
17
|
children,
|
|
16
18
|
disabled = false,
|
|
@@ -18,11 +20,16 @@ const RadioGroup = ({
|
|
|
18
20
|
style,
|
|
19
21
|
testID
|
|
20
22
|
}) => {
|
|
23
|
+
const [current, setCurrent] = (0, _index.useControllableState)({
|
|
24
|
+
value,
|
|
25
|
+
defaultValue: defaultValue ?? undefined,
|
|
26
|
+
onChange: onChange
|
|
27
|
+
});
|
|
21
28
|
const ctx = (0, _react.useMemo)(() => ({
|
|
22
|
-
selectedValue:
|
|
23
|
-
|
|
29
|
+
selectedValue: current,
|
|
30
|
+
onChange: setCurrent,
|
|
24
31
|
disabled
|
|
25
|
-
}), [
|
|
32
|
+
}), [current, setCurrent, disabled]);
|
|
26
33
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Radio.RadioGroupContext.Provider, {
|
|
27
34
|
value: ctx,
|
|
28
35
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
@@ -80,12 +80,14 @@ const SearchBar = exports.SearchBar = /*#__PURE__*/(0, _react.forwardRef)((props
|
|
|
80
80
|
}, [debouncedValue, debounceMs, onChangeText]);
|
|
81
81
|
const showCancelButton = showCancel && isFocused;
|
|
82
82
|
(0, _react.useEffect)(() => {
|
|
83
|
-
_reactNative.Animated.timing(cancelAnim, {
|
|
83
|
+
const anim = _reactNative.Animated.timing(cancelAnim, {
|
|
84
84
|
toValue: showCancelButton ? 1 : 0,
|
|
85
85
|
duration: 200,
|
|
86
86
|
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
87
87
|
useNativeDriver: false
|
|
88
|
-
})
|
|
88
|
+
});
|
|
89
|
+
anim.start();
|
|
90
|
+
return () => anim.stop();
|
|
89
91
|
}, [showCancelButton, cancelAnim, theme.motion.easing.standard]);
|
|
90
92
|
const handleChangeText = (0, _react.useCallback)(text => {
|
|
91
93
|
if (debounceMs !== undefined) {
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
var _index = require("../../theme/index.js");
|
|
10
10
|
var _index2 = require("../../utils/index.js");
|
|
11
|
+
var _index3 = require("../../hooks/index.js");
|
|
11
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
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); }
|
|
13
14
|
/**
|
|
@@ -34,7 +35,8 @@ const TRACK_PADDING = 2;
|
|
|
34
35
|
const SegmentedControl = exports.SegmentedControl = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
35
36
|
const {
|
|
36
37
|
segments,
|
|
37
|
-
value,
|
|
38
|
+
value: valueProp,
|
|
39
|
+
defaultValue,
|
|
38
40
|
onChange,
|
|
39
41
|
size = 'md',
|
|
40
42
|
fullWidth = true,
|
|
@@ -49,6 +51,11 @@ const SegmentedControl = exports.SegmentedControl = /*#__PURE__*/(0, _react.forw
|
|
|
49
51
|
labelStyle,
|
|
50
52
|
testID
|
|
51
53
|
} = props;
|
|
54
|
+
const [current, setCurrent] = (0, _index3.useControllableState)({
|
|
55
|
+
value: valueProp,
|
|
56
|
+
defaultValue: defaultValue ?? segments[0]?.value,
|
|
57
|
+
onChange
|
|
58
|
+
});
|
|
52
59
|
const theme = (0, _index.useTheme)();
|
|
53
60
|
const segTheme = theme.components.segmentedControl;
|
|
54
61
|
const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
|
|
@@ -69,23 +76,26 @@ const SegmentedControl = exports.SegmentedControl = /*#__PURE__*/(0, _react.forw
|
|
|
69
76
|
// only animate translateX via the native driver.
|
|
70
77
|
const [trackWidth, setTrackWidth] = (0, _react.useState)(0);
|
|
71
78
|
const thumbTranslateX = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
|
|
72
|
-
const activeIndex = Math.max(0, segments.findIndex(s => s.value ===
|
|
79
|
+
const activeIndex = Math.max(0, segments.findIndex(s => s.value === current));
|
|
73
80
|
const segmentWidth = trackWidth > 0 ? (trackWidth - trackPadding * 2) / Math.max(segments.length, 1) : 0;
|
|
74
81
|
const animateThumb = (0, _react.useCallback)((index, segWidth) => {
|
|
75
|
-
if (segWidth <= 0) return;
|
|
82
|
+
if (segWidth <= 0) return undefined;
|
|
76
83
|
const targetX = trackPadding + segWidth * index;
|
|
77
84
|
const spring = theme.motion.spring.snappy;
|
|
78
|
-
_reactNative.Animated.spring(thumbTranslateX, {
|
|
85
|
+
const anim = _reactNative.Animated.spring(thumbTranslateX, {
|
|
79
86
|
toValue: targetX,
|
|
80
87
|
damping: spring.damping,
|
|
81
88
|
stiffness: spring.stiffness,
|
|
82
89
|
mass: spring.mass,
|
|
83
90
|
useNativeDriver: true
|
|
84
|
-
})
|
|
91
|
+
});
|
|
92
|
+
anim.start();
|
|
93
|
+
return anim;
|
|
85
94
|
}, [theme.motion.spring.snappy, thumbTranslateX]);
|
|
86
95
|
(0, _react.useEffect)(() => {
|
|
87
96
|
if (segmentWidth > 0) {
|
|
88
|
-
animateThumb(activeIndex, segmentWidth);
|
|
97
|
+
const anim = animateThumb(activeIndex, segmentWidth);
|
|
98
|
+
return () => anim?.stop();
|
|
89
99
|
}
|
|
90
100
|
}, [activeIndex, segmentWidth, animateThumb]);
|
|
91
101
|
const handleTrackLayout = (0, _react.useCallback)(e => {
|
|
@@ -96,10 +106,10 @@ const SegmentedControl = exports.SegmentedControl = /*#__PURE__*/(0, _react.forw
|
|
|
96
106
|
}, [trackWidth]);
|
|
97
107
|
const handlePress = (0, _react.useCallback)(segment => {
|
|
98
108
|
if (disabled) return;
|
|
99
|
-
if (segment.value ===
|
|
109
|
+
if (segment.value === current) return;
|
|
100
110
|
if (changeHapticEnabled) (0, _index2.triggerHaptic)('selection');
|
|
101
|
-
|
|
102
|
-
}, [disabled,
|
|
111
|
+
setCurrent(segment.value);
|
|
112
|
+
}, [disabled, setCurrent, current, changeHapticEnabled]);
|
|
103
113
|
const thumbBg = tone === 'primary' ? theme.colors.background.elevated : theme.colors.background.elevated;
|
|
104
114
|
const activeTextColor = tone === 'primary' ? theme.colors.text.primary : theme.colors.text.primary;
|
|
105
115
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
@@ -130,7 +140,7 @@ const SegmentedControl = exports.SegmentedControl = /*#__PURE__*/(0, _react.forw
|
|
|
130
140
|
...theme.shadows.sm
|
|
131
141
|
}, selectedIndicatorStyle]
|
|
132
142
|
}) : null, segments.map(segment => {
|
|
133
|
-
const isActive = segment.value ===
|
|
143
|
+
const isActive = segment.value === current;
|
|
134
144
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
|
|
135
145
|
onPress: () => handlePress(segment),
|
|
136
146
|
disabled: disabled,
|
|
@@ -66,34 +66,32 @@ const Select = exports.Select = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
|
|
|
66
66
|
const backdropAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
|
|
67
67
|
const sheetAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(sheetMaxHeight)).current;
|
|
68
68
|
(0, _react.useEffect)(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_reactNative.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
})]).start();
|
|
96
|
-
}
|
|
69
|
+
const anim = open ? _reactNative.Animated.parallel([
|
|
70
|
+
// Backdrop opacity uses JS driver — see Modal.tsx for the Fabric reason.
|
|
71
|
+
_reactNative.Animated.timing(backdropAnim, {
|
|
72
|
+
toValue: 1,
|
|
73
|
+
duration: theme.motion.duration.fast,
|
|
74
|
+
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
75
|
+
useNativeDriver: false
|
|
76
|
+
}), _reactNative.Animated.spring(sheetAnim, {
|
|
77
|
+
toValue: 0,
|
|
78
|
+
damping: theme.motion.spring.snappy.damping,
|
|
79
|
+
stiffness: theme.motion.spring.snappy.stiffness,
|
|
80
|
+
mass: theme.motion.spring.snappy.mass,
|
|
81
|
+
useNativeDriver: true
|
|
82
|
+
})]) : _reactNative.Animated.parallel([_reactNative.Animated.timing(backdropAnim, {
|
|
83
|
+
toValue: 0,
|
|
84
|
+
duration: theme.motion.duration.fast,
|
|
85
|
+
easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
|
|
86
|
+
useNativeDriver: false
|
|
87
|
+
}), _reactNative.Animated.timing(sheetAnim, {
|
|
88
|
+
toValue: sheetMaxHeight,
|
|
89
|
+
duration: theme.motion.duration.fast,
|
|
90
|
+
easing: _reactNative.Easing.bezier(...theme.motion.easing.accelerate),
|
|
91
|
+
useNativeDriver: true
|
|
92
|
+
})]);
|
|
93
|
+
anim.start();
|
|
94
|
+
return () => anim.stop();
|
|
97
95
|
}, [open, backdropAnim, sheetAnim, sheetMaxHeight, theme.motion.duration.fast, theme.motion.easing.standard, theme.motion.easing.accelerate, theme.motion.spring.snappy]);
|
|
98
96
|
|
|
99
97
|
// Selection helpers — typed to keep callbacks fully type-safe.
|
|
@@ -391,14 +389,17 @@ const Chevron = ({
|
|
|
391
389
|
size,
|
|
392
390
|
open
|
|
393
391
|
}) => {
|
|
392
|
+
const theme = (0, _index.useTheme)();
|
|
394
393
|
const rotate = (0, _react.useRef)((0, _index.createAnimatedValue)(open ? 1 : 0)).current;
|
|
395
394
|
(0, _react.useEffect)(() => {
|
|
396
|
-
_reactNative.Animated.timing(rotate, {
|
|
395
|
+
const anim = _reactNative.Animated.timing(rotate, {
|
|
397
396
|
toValue: open ? 1 : 0,
|
|
398
|
-
duration:
|
|
397
|
+
duration: theme.motion.duration.fast,
|
|
399
398
|
useNativeDriver: true
|
|
400
|
-
})
|
|
401
|
-
|
|
399
|
+
});
|
|
400
|
+
anim.start();
|
|
401
|
+
return () => anim.stop();
|
|
402
|
+
}, [open, rotate, theme.motion.duration.fast]);
|
|
402
403
|
const rotation = rotate.interpolate({
|
|
403
404
|
inputRange: [0, 1],
|
|
404
405
|
outputRange: ['0deg', '180deg']
|
|
@@ -221,19 +221,22 @@ const SkeletonContent = ({
|
|
|
221
221
|
const wasLoadingRef = (0, _react.useRef)(loading);
|
|
222
222
|
const fadeAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(loading ? 0 : 1)).current;
|
|
223
223
|
(0, _react.useEffect)(() => {
|
|
224
|
+
let anim;
|
|
224
225
|
if (wasLoadingRef.current && !loading) {
|
|
225
226
|
fadeAnim.setValue(0);
|
|
226
|
-
_reactNative.Animated.timing(fadeAnim, {
|
|
227
|
+
anim = _reactNative.Animated.timing(fadeAnim, {
|
|
227
228
|
toValue: 1,
|
|
228
229
|
duration: resolvedFadeDuration,
|
|
229
230
|
useNativeDriver: true
|
|
230
|
-
})
|
|
231
|
+
});
|
|
232
|
+
anim.start();
|
|
231
233
|
} else if (!wasLoadingRef.current && loading) {
|
|
232
234
|
// Going back into loading from loaded — snap opacity so the
|
|
233
235
|
// placeholder appears instantly when data invalidates.
|
|
234
236
|
fadeAnim.setValue(1);
|
|
235
237
|
}
|
|
236
238
|
wasLoadingRef.current = loading;
|
|
239
|
+
return () => anim?.stop();
|
|
237
240
|
}, [loading, fadeAnim, resolvedFadeDuration]);
|
|
238
241
|
if (!loading) {
|
|
239
242
|
if (resolvedFadeDuration <= 0) {
|