@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.
Files changed (181) hide show
  1. package/lib/commonjs/components/Accordion/Accordion.js +4 -2
  2. package/lib/commonjs/components/Avatar/Avatar.js +4 -2
  3. package/lib/commonjs/components/Badge/Badge.js +5 -5
  4. package/lib/commonjs/components/Banner/Banner.js +8 -4
  5. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +6 -4
  6. package/lib/commonjs/components/BottomSheet/BottomSheet.js +8 -9
  7. package/lib/commonjs/components/Box/Box.js +162 -0
  8. package/lib/commonjs/components/Box/index.js +37 -0
  9. package/lib/commonjs/components/Button/Button.js +7 -7
  10. package/lib/commonjs/components/Carousel/Carousel.js +4 -2
  11. package/lib/commonjs/components/Checkbox/Checkbox.js +14 -5
  12. package/lib/commonjs/components/DatePicker/DatePicker.js +9 -7
  13. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +5 -2
  14. package/lib/commonjs/components/Dialog/Dialog.js +2 -2
  15. package/lib/commonjs/components/FieldBase/FieldBase.js +8 -4
  16. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +13 -5
  17. package/lib/commonjs/components/FormField/FormField.js +61 -25
  18. package/lib/commonjs/components/Input/Input.js +41 -29
  19. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +102 -0
  20. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -0
  21. package/lib/commonjs/components/KeyboardToolbar/KeyboardToolbar.js +130 -0
  22. package/lib/commonjs/components/KeyboardToolbar/index.js +13 -0
  23. package/lib/commonjs/components/Modal/Modal.js +17 -6
  24. package/lib/commonjs/components/NumberInput/NumberInput.js +35 -28
  25. package/lib/commonjs/components/OTPInput/OTPInput.js +33 -18
  26. package/lib/commonjs/components/Radio/Radio.js +7 -5
  27. package/lib/commonjs/components/Radio/RadioGroup.js +10 -3
  28. package/lib/commonjs/components/SearchBar/SearchBar.js +4 -2
  29. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +20 -10
  30. package/lib/commonjs/components/Select/Select.js +33 -32
  31. package/lib/commonjs/components/Skeleton/SkeletonContent.js +5 -2
  32. package/lib/commonjs/components/Slider/Slider.js +42 -26
  33. package/lib/commonjs/components/Spinner/Spinner.js +5 -5
  34. package/lib/commonjs/components/Switch/Switch.js +29 -16
  35. package/lib/commonjs/components/Tabs/Tabs.js +4 -2
  36. package/lib/commonjs/components/Text/Text.js +142 -0
  37. package/lib/commonjs/components/Text/index.js +13 -0
  38. package/lib/commonjs/components/TimePicker/TimePicker.js +10 -7
  39. package/lib/commonjs/components/Toast/Toast.js +22 -10
  40. package/lib/commonjs/components/Tooltip/Tooltip.js +6 -2
  41. package/lib/commonjs/components/index.js +135 -89
  42. package/lib/commonjs/form/FormContext.js +40 -0
  43. package/lib/commonjs/form/index.js +68 -0
  44. package/lib/commonjs/form/path.js +79 -0
  45. package/lib/commonjs/form/rules.js +67 -0
  46. package/lib/commonjs/form/types.js +2 -0
  47. package/lib/commonjs/form/useField.js +54 -0
  48. package/lib/commonjs/form/useForm.js +316 -0
  49. package/lib/commonjs/hooks/index.js +14 -0
  50. package/lib/commonjs/hooks/useControllableState.js +30 -0
  51. package/lib/commonjs/hooks/useReducedMotion.js +31 -0
  52. package/lib/commonjs/index.js +96 -11
  53. package/lib/commonjs/theme/ThemeContext.js +30 -2
  54. package/lib/commonjs/theme/tokens.js +12 -0
  55. package/lib/module/components/Accordion/Accordion.js +4 -2
  56. package/lib/module/components/Avatar/Avatar.js +4 -2
  57. package/lib/module/components/Badge/Badge.js +5 -5
  58. package/lib/module/components/Banner/Banner.js +8 -4
  59. package/lib/module/components/BottomNavigation/BottomNavigation.js +6 -4
  60. package/lib/module/components/BottomSheet/BottomSheet.js +8 -9
  61. package/lib/module/components/Box/Box.js +156 -0
  62. package/lib/module/components/Box/index.js +4 -0
  63. package/lib/module/components/Button/Button.js +7 -7
  64. package/lib/module/components/Carousel/Carousel.js +4 -2
  65. package/lib/module/components/Checkbox/Checkbox.js +14 -5
  66. package/lib/module/components/DatePicker/DatePicker.js +9 -7
  67. package/lib/module/components/DateRangePicker/DateRangePicker.js +5 -2
  68. package/lib/module/components/Dialog/Dialog.js +2 -2
  69. package/lib/module/components/FieldBase/FieldBase.js +8 -4
  70. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +13 -5
  71. package/lib/module/components/FormField/FormField.js +62 -26
  72. package/lib/module/components/Input/Input.js +41 -29
  73. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +98 -0
  74. package/lib/module/components/KeyboardAwareScrollView/index.js +4 -0
  75. package/lib/module/components/KeyboardToolbar/KeyboardToolbar.js +125 -0
  76. package/lib/module/components/KeyboardToolbar/index.js +4 -0
  77. package/lib/module/components/Modal/Modal.js +17 -6
  78. package/lib/module/components/NumberInput/NumberInput.js +30 -23
  79. package/lib/module/components/OTPInput/OTPInput.js +30 -15
  80. package/lib/module/components/Radio/Radio.js +7 -5
  81. package/lib/module/components/Radio/RadioGroup.js +10 -3
  82. package/lib/module/components/SearchBar/SearchBar.js +4 -2
  83. package/lib/module/components/SegmentedControl/SegmentedControl.js +20 -10
  84. package/lib/module/components/Select/Select.js +33 -32
  85. package/lib/module/components/Skeleton/SkeletonContent.js +5 -2
  86. package/lib/module/components/Slider/Slider.js +42 -26
  87. package/lib/module/components/Spinner/Spinner.js +5 -5
  88. package/lib/module/components/Switch/Switch.js +29 -16
  89. package/lib/module/components/Tabs/Tabs.js +4 -2
  90. package/lib/module/components/Text/Text.js +138 -0
  91. package/lib/module/components/Text/index.js +4 -0
  92. package/lib/module/components/TimePicker/TimePicker.js +10 -7
  93. package/lib/module/components/Toast/Toast.js +22 -10
  94. package/lib/module/components/Tooltip/Tooltip.js +6 -2
  95. package/lib/module/components/index.js +4 -0
  96. package/lib/module/form/FormContext.js +32 -0
  97. package/lib/module/form/index.js +12 -0
  98. package/lib/module/form/path.js +72 -0
  99. package/lib/module/form/rules.js +52 -0
  100. package/lib/module/form/types.js +2 -0
  101. package/lib/module/form/useField.js +49 -0
  102. package/lib/module/form/useForm.js +312 -0
  103. package/lib/module/hooks/index.js +2 -0
  104. package/lib/module/hooks/useControllableState.js +26 -0
  105. package/lib/module/hooks/useReducedMotion.js +27 -0
  106. package/lib/module/index.js +3 -1
  107. package/lib/module/theme/ThemeContext.js +30 -2
  108. package/lib/module/theme/tokens.js +12 -0
  109. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +1 -1
  110. package/lib/typescript/commonjs/components/Box/Box.d.ts +60 -0
  111. package/lib/typescript/commonjs/components/Box/index.d.ts +3 -0
  112. package/lib/typescript/commonjs/components/Button/Button.d.ts +1 -1
  113. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +3 -2
  114. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -3
  115. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +2 -2
  116. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +13 -2
  117. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
  118. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/index.d.ts +3 -0
  119. package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
  120. package/lib/typescript/commonjs/components/KeyboardToolbar/index.d.ts +3 -0
  121. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -2
  122. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
  123. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -2
  124. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +3 -2
  125. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  126. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +6 -4
  127. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +1 -1
  128. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
  129. package/lib/typescript/commonjs/components/Text/Text.d.ts +25 -0
  130. package/lib/typescript/commonjs/components/Text/index.d.ts +3 -0
  131. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -3
  132. package/lib/typescript/commonjs/components/index.d.ts +8 -0
  133. package/lib/typescript/commonjs/form/FormContext.d.ts +17 -0
  134. package/lib/typescript/commonjs/form/index.d.ts +9 -0
  135. package/lib/typescript/commonjs/form/path.d.ts +10 -0
  136. package/lib/typescript/commonjs/form/rules.d.ts +31 -0
  137. package/lib/typescript/commonjs/form/types.d.ts +94 -0
  138. package/lib/typescript/commonjs/form/useField.d.ts +27 -0
  139. package/lib/typescript/commonjs/form/useForm.d.ts +10 -0
  140. package/lib/typescript/commonjs/hooks/index.d.ts +3 -0
  141. package/lib/typescript/commonjs/hooks/useControllableState.d.ts +17 -0
  142. package/lib/typescript/commonjs/hooks/useReducedMotion.d.ts +8 -0
  143. package/lib/typescript/commonjs/index.d.ts +4 -2
  144. package/lib/typescript/commonjs/theme/types.d.ts +15 -0
  145. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +1 -1
  146. package/lib/typescript/module/components/Box/Box.d.ts +60 -0
  147. package/lib/typescript/module/components/Box/index.d.ts +3 -0
  148. package/lib/typescript/module/components/Button/Button.d.ts +1 -1
  149. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +3 -2
  150. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -3
  151. package/lib/typescript/module/components/Dialog/Dialog.d.ts +2 -2
  152. package/lib/typescript/module/components/FormField/FormField.d.ts +13 -2
  153. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
  154. package/lib/typescript/module/components/KeyboardAwareScrollView/index.d.ts +3 -0
  155. package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
  156. package/lib/typescript/module/components/KeyboardToolbar/index.d.ts +3 -0
  157. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -2
  158. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
  159. package/lib/typescript/module/components/Radio/Radio.d.ts +2 -2
  160. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +3 -2
  161. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  162. package/lib/typescript/module/components/Slider/Slider.d.ts +6 -4
  163. package/lib/typescript/module/components/Spinner/Spinner.d.ts +1 -1
  164. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
  165. package/lib/typescript/module/components/Text/Text.d.ts +25 -0
  166. package/lib/typescript/module/components/Text/index.d.ts +3 -0
  167. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -3
  168. package/lib/typescript/module/components/index.d.ts +8 -0
  169. package/lib/typescript/module/form/FormContext.d.ts +17 -0
  170. package/lib/typescript/module/form/index.d.ts +9 -0
  171. package/lib/typescript/module/form/path.d.ts +10 -0
  172. package/lib/typescript/module/form/rules.d.ts +31 -0
  173. package/lib/typescript/module/form/types.d.ts +94 -0
  174. package/lib/typescript/module/form/useField.d.ts +27 -0
  175. package/lib/typescript/module/form/useForm.d.ts +10 -0
  176. package/lib/typescript/module/hooks/index.d.ts +3 -0
  177. package/lib/typescript/module/hooks/useControllableState.d.ts +17 -0
  178. package/lib/typescript/module/hooks/useReducedMotion.d.ts +8 -0
  179. package/lib/typescript/module/index.d.ts +4 -2
  180. package/lib/typescript/module/theme/types.d.ts +15 -0
  181. package/package.json +1 -1
@@ -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
  const SIZE_MAP = {
@@ -79,10 +80,15 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
79
80
  const [trackWidth, setTrackWidth] = (0, _react.useState)(0);
80
81
  const fillColor = theme.colors[TONE_TO_COLOR_KEY[tone]];
81
82
  const isRange = props.range === true;
83
+ const [currentValue, setCurrentValue] = (0, _index3.useControllableState)({
84
+ value: props.value,
85
+ defaultValue: props.defaultValue ?? (isRange ? [min, max] : min),
86
+ onChange: props.onChange
87
+ });
82
88
 
83
89
  // Current value is mirrored in refs so PanResponder closures get fresh values.
84
- const lowRef = (0, _react.useRef)(isRange ? props.value[0] : props.value);
85
- const highRef = (0, _react.useRef)(isRange ? props.value[1] : props.value);
90
+ const lowRef = (0, _react.useRef)(isRange ? currentValue[0] : currentValue);
91
+ const highRef = (0, _react.useRef)(isRange ? currentValue[1] : currentValue);
86
92
  const lastReportedLow = (0, _react.useRef)(lowRef.current);
87
93
  const lastReportedHigh = (0, _react.useRef)(highRef.current);
88
94
 
@@ -120,7 +126,7 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
120
126
  (0, _react.useEffect)(() => {
121
127
  if (trackWidth <= 0) return;
122
128
  if (isRange) {
123
- const [v0, v1] = props.value;
129
+ const [v0, v1] = currentValue;
124
130
  const lo = Math.min(v0, v1);
125
131
  const hi = Math.max(v0, v1);
126
132
  lowRef.current = lo;
@@ -130,38 +136,34 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
130
136
  (0, _index.setNativeValue)(lowX, valueToPx(lo, trackWidth));
131
137
  (0, _index.setNativeValue)(highX, valueToPx(hi, trackWidth));
132
138
  } else {
133
- const v = props.value;
139
+ const v = currentValue;
134
140
  lowRef.current = v;
135
141
  highRef.current = v;
136
142
  lastReportedLow.current = v;
137
143
  (0, _index.setNativeValue)(lowX, valueToPx(v, trackWidth));
138
144
  }
139
- // We intentionally listen to props.value across both shapes via JSON; ESLint is fine.
145
+ // We intentionally listen to the value across both shapes via JSON; ESLint is fine.
140
146
  // eslint-disable-next-line react-hooks/exhaustive-deps
141
- }, [JSON.stringify(props.value), trackWidth, isRange, valueToPx]);
147
+ }, [JSON.stringify(currentValue), trackWidth, isRange, valueToPx]);
142
148
  const onTrackLayout = (0, _react.useCallback)(e => {
143
149
  const w = e.nativeEvent.layout.width;
144
150
  setTrackWidth(w);
145
151
  // Initialize positions immediately.
146
152
  if (isRange) {
147
- const [v0, v1] = props.value;
153
+ const [v0, v1] = currentValue;
148
154
  const lo = Math.min(v0, v1);
149
155
  const hi = Math.max(v0, v1);
150
156
  (0, _index.setNativeValue)(lowX, valueToPx(lo, w));
151
157
  (0, _index.setNativeValue)(highX, valueToPx(hi, w));
152
158
  } else {
153
- (0, _index.setNativeValue)(lowX, valueToPx(props.value, w));
159
+ (0, _index.setNativeValue)(lowX, valueToPx(currentValue, w));
154
160
  }
155
161
  },
156
162
  // eslint-disable-next-line react-hooks/exhaustive-deps
157
163
  [isRange, valueToPx]);
158
164
  const fireChange = (0, _react.useCallback)((lo, hi) => {
159
- if (isRange) {
160
- props.onChange([lo, hi]);
161
- } else {
162
- props.onChange(lo);
163
- }
164
- }, [isRange, props]);
165
+ setCurrentValue(isRange ? [lo, hi] : lo);
166
+ }, [isRange, setCurrentValue]);
165
167
  const animateThumbPress = (0, _react.useCallback)((target, opacity, pressed) => {
166
168
  if (thumbPressAnimationEnabled) {
167
169
  _reactNative.Animated.spring(target, {
@@ -196,24 +198,29 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
196
198
  if (trackWidth <= 0) return;
197
199
  const nextPx = clamp(dragOffsetRef.current + gesture.dx, 0, trackWidth);
198
200
  let nextValue = pxToValue(nextPx, trackWidth);
201
+
202
+ // Only touch the native driver + fire onChange when the snapped value
203
+ // actually changes — between step boundaries the drag is a visual
204
+ // no-op (px is derived from the snapped value), so this drops the
205
+ // per-frame native round-trip and per-frame consumer re-render.
199
206
  if (which === 'low') {
200
207
  if (isRange && nextValue > highRef.current) nextValue = highRef.current;
201
208
  if (nextValue !== lastReportedLow.current) {
202
209
  if (sliderTheme?.stepHaptic ?? false) (0, _index2.triggerHaptic)('selection');
203
210
  lastReportedLow.current = nextValue;
211
+ lowRef.current = nextValue;
212
+ (0, _index.setNativeValue)(lowX, valueToPx(nextValue, trackWidth));
213
+ fireChange(nextValue, highRef.current);
204
214
  }
205
- lowRef.current = nextValue;
206
- (0, _index.setNativeValue)(lowX, valueToPx(nextValue, trackWidth));
207
- fireChange(nextValue, highRef.current);
208
215
  } else {
209
216
  if (isRange && nextValue < lowRef.current) nextValue = lowRef.current;
210
217
  if (nextValue !== lastReportedHigh.current) {
211
218
  if (sliderTheme?.stepHaptic ?? false) (0, _index2.triggerHaptic)('selection');
212
219
  lastReportedHigh.current = nextValue;
220
+ highRef.current = nextValue;
221
+ (0, _index.setNativeValue)(highX, valueToPx(nextValue, trackWidth));
222
+ fireChange(lowRef.current, nextValue);
213
223
  }
214
- highRef.current = nextValue;
215
- (0, _index.setNativeValue)(highX, valueToPx(nextValue, trackWidth));
216
- fireChange(lowRef.current, nextValue);
217
224
  }
218
225
  },
219
226
  onPanResponderRelease: () => {
@@ -272,12 +279,21 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
272
279
  }
273
280
  }
274
281
  }, [disabled, step, isRange, min, max, valueToPx, trackWidth, lowX, fireChange, sliderTheme]);
275
-
276
- // Computed values for fill bar.
277
- const fillLeft = isRange ? lowX : new _reactNative.Animated.Value(0);
278
- const fillWidth = isRange ? _reactNative.Animated.subtract(highX, lowX) : lowX;
279
282
  const thumbRadius = sizeCfg.thumbDiameter / 2;
280
283
 
284
+ // Stable Animated nodes for the fill bar and thumb offsets — created once and
285
+ // memoised so a render doesn't rebuild `new Animated.Value(...)` /
286
+ // Animated.subtract nodes and re-attach the animation graph every pass.
287
+ const zeroX = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
288
+ const thumbRadiusX = (0, _react.useRef)((0, _index.createAnimatedValue)(thumbRadius)).current;
289
+ (0, _react.useEffect)(() => {
290
+ (0, _index.setNativeValue)(thumbRadiusX, thumbRadius);
291
+ }, [thumbRadius, thumbRadiusX]);
292
+ const fillLeft = isRange ? lowX : zeroX;
293
+ const fillWidth = (0, _react.useMemo)(() => isRange ? _reactNative.Animated.subtract(highX, lowX) : lowX, [isRange, highX, lowX]);
294
+ const lowTranslateX = (0, _react.useMemo)(() => _reactNative.Animated.subtract(lowX, thumbRadiusX), [lowX, thumbRadiusX]);
295
+ const highTranslateX = (0, _react.useMemo)(() => _reactNative.Animated.subtract(highX, thumbRadiusX), [highX, thumbRadiusX]);
296
+
281
297
  // Display values for labels.
282
298
  const lowDisplayValue = isRange ? lowRef.current : lowRef.current;
283
299
  const highDisplayValue = highRef.current;
@@ -330,7 +346,7 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
330
346
  backgroundColor: theme.colors.background.elevated,
331
347
  borderColor: disabled ? theme.colors.surface.disabled : fillColor,
332
348
  transform: [{
333
- translateX: _reactNative.Animated.subtract(lowX, new _reactNative.Animated.Value(thumbRadius))
349
+ translateX: lowTranslateX
334
350
  }, {
335
351
  scale: lowScale
336
352
  }],
@@ -358,7 +374,7 @@ const Slider = exports.Slider = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
358
374
  backgroundColor: theme.colors.background.elevated,
359
375
  borderColor: disabled ? theme.colors.surface.disabled : fillColor,
360
376
  transform: [{
361
- translateX: _reactNative.Animated.subtract(highX, new _reactNative.Animated.Value(thumbRadius))
377
+ translateX: highTranslateX
362
378
  }, {
363
379
  scale: highScale
364
380
  }],
@@ -10,9 +10,9 @@ var _index = require("../../theme/index.js");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  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
12
  const sizeMap = {
13
- small: 20,
14
- medium: 32,
15
- large: 48
13
+ sm: 20,
14
+ md: 32,
15
+ lg: 48
16
16
  };
17
17
  const DOT_COUNT = 3;
18
18
  const DOT_STAGGER_MS = 150;
@@ -55,7 +55,7 @@ const Dot = ({
55
55
  };
56
56
  const Spinner = exports.Spinner = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
57
57
  const {
58
- size = 'medium',
58
+ size = 'md',
59
59
  color,
60
60
  message,
61
61
  overlay = false,
@@ -98,7 +98,7 @@ const Spinner = exports.Spinner = /*#__PURE__*/(0, _react.forwardRef)((props, re
98
98
  }
99
99
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
100
100
  color: resolvedColor,
101
- size: size === 'small' ? 'small' : 'large',
101
+ size: size === 'sm' ? 'small' : 'large',
102
102
  style: {
103
103
  width: dimension,
104
104
  height: dimension
@@ -7,6 +7,7 @@ exports.default = exports.Switch = 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("../../hooks/index.js");
10
11
  var _hapticUtils = require("../../utils/hapticUtils.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); }
@@ -46,7 +47,8 @@ const toneColor = (theme, tone) => {
46
47
  const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
47
48
  const {
48
49
  value,
49
- onValueChange,
50
+ defaultValue,
51
+ onChange,
50
52
  disabled = false,
51
53
  size = 'md',
52
54
  tone = 'primary',
@@ -61,6 +63,11 @@ const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
61
63
  testID,
62
64
  ...rest
63
65
  } = props;
66
+ const [current, setCurrent] = (0, _index2.useControllableState)({
67
+ value,
68
+ defaultValue: defaultValue ?? false,
69
+ onChange
70
+ });
64
71
  const theme = (0, _index.useTheme)();
65
72
  const sizeStyles = {
66
73
  ...sizeMap[size],
@@ -70,25 +77,29 @@ const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
70
77
  const styles = (0, _react.useMemo)(() => buildStyles(theme), [theme]);
71
78
  const offTrackColor = theme.mode === 'dark' ? theme.colors.secondary : theme.colors.surface.disabled;
72
79
  const onTrackColor = toneColor(theme, tone);
73
- const progress = (0, _react.useRef)((0, _index.createAnimatedValue)(value ? 1 : 0)).current;
80
+ const progress = (0, _react.useRef)((0, _index.createAnimatedValue)(current ? 1 : 0)).current;
74
81
  (0, _react.useEffect)(() => {
75
- _reactNative.Animated.spring(progress, {
76
- toValue: value ? 1 : 0,
82
+ const anim = _reactNative.Animated.spring(progress, {
83
+ toValue: current ? 1 : 0,
77
84
  damping: theme.motion.spring.snappy.damping,
78
85
  stiffness: theme.motion.spring.snappy.stiffness,
79
86
  mass: theme.motion.spring.snappy.mass,
80
87
  useNativeDriver: true
81
- }).start();
82
- }, [value, progress, theme.motion.spring.snappy]);
83
- const trackBgAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(value ? 1 : 0)).current;
88
+ });
89
+ anim.start();
90
+ return () => anim.stop();
91
+ }, [current, progress, theme.motion.spring.snappy]);
92
+ const trackBgAnim = (0, _react.useRef)((0, _index.createAnimatedValue)(current ? 1 : 0)).current;
84
93
  (0, _react.useEffect)(() => {
85
- _reactNative.Animated.timing(trackBgAnim, {
86
- toValue: value ? 1 : 0,
94
+ const anim = _reactNative.Animated.timing(trackBgAnim, {
95
+ toValue: current ? 1 : 0,
87
96
  duration: theme.motion.duration.fast,
88
97
  easing: _reactNative.Easing.out(_reactNative.Easing.ease),
89
98
  useNativeDriver: false
90
- }).start();
91
- }, [value, trackBgAnim, theme.motion.duration.fast]);
99
+ });
100
+ anim.start();
101
+ return () => anim.stop();
102
+ }, [current, trackBgAnim, theme.motion.duration.fast]);
92
103
  const offX = sizeStyles.padding;
93
104
  const onX = sizeStyles.trackWidth - sizeStyles.thumbSize - sizeStyles.padding;
94
105
  const translateX = progress.interpolate({
@@ -107,7 +118,7 @@ const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
107
118
  isFirstRender.current = false;
108
119
  return;
109
120
  }
110
- _reactNative.Animated.sequence([_reactNative.Animated.spring(bounceScale, {
121
+ const anim = _reactNative.Animated.sequence([_reactNative.Animated.spring(bounceScale, {
111
122
  toValue: 1.15,
112
123
  damping: 10,
113
124
  stiffness: 220,
@@ -119,12 +130,14 @@ const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
119
130
  stiffness: 240,
120
131
  mass: 1,
121
132
  useNativeDriver: true
122
- })]).start();
123
- }, [value, bounce, bounceScale]);
133
+ })]);
134
+ anim.start();
135
+ return () => anim.stop();
136
+ }, [current, bounce, bounceScale]);
124
137
  const handlePress = event => {
125
138
  if (disabled) return;
126
139
  if (haptic !== false) (0, _hapticUtils.triggerHaptic)(haptic);
127
- onValueChange(!value);
140
+ setCurrent(!current);
128
141
  rest.onPressOut?.(event);
129
142
  };
130
143
  const accessibleLabel = accessibilityLabel ?? label;
@@ -135,7 +148,7 @@ const Switch = exports.Switch = /*#__PURE__*/(0, _react.forwardRef)((props, ref)
135
148
  accessibilityRole: "switch",
136
149
  accessibilityLabel: accessibleLabel,
137
150
  accessibilityState: {
138
- checked: value,
151
+ checked: current,
139
152
  disabled
140
153
  },
141
154
  testID: testID,
@@ -87,7 +87,7 @@ const Tabs = exports.Tabs = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
87
87
  if (!activeLayout) return;
88
88
  if (useProgress) return;
89
89
  const spring = theme.motion.spring.snappy;
90
- _reactNative.Animated.parallel([
90
+ const anim = _reactNative.Animated.parallel([
91
91
  // Both must use the JS driver: width can't run on native, and mixing
92
92
  // drivers on the same view (transform native + width JS) trips RN's
93
93
  // "node already moved to native" guard under the new architecture.
@@ -103,7 +103,9 @@ const Tabs = exports.Tabs = /*#__PURE__*/(0, _react.forwardRef)((props, ref) =>
103
103
  stiffness: spring.stiffness,
104
104
  mass: spring.mass,
105
105
  useNativeDriver: false
106
- })]).start();
106
+ })]);
107
+ anim.start();
108
+ return () => anim.stop();
107
109
  }, [activeLayout, activeKey, indicatorTranslateX, indicatorWidth, theme.motion.spring.snappy, useProgress]);
108
110
  const handleLayout = (0, _react.useCallback)(key => e => {
109
111
  const {
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.Text = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _index = require("../../theme/index.js");
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ 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
+ const VARIANTS = {
13
+ display: {
14
+ size: '4xl',
15
+ weight: 'bold',
16
+ line: 'tight',
17
+ color: 'primary',
18
+ heading: true
19
+ },
20
+ h1: {
21
+ size: '3xl',
22
+ weight: 'bold',
23
+ line: 'tight',
24
+ color: 'primary',
25
+ heading: true
26
+ },
27
+ h2: {
28
+ size: '2xl',
29
+ weight: 'semibold',
30
+ line: 'tight',
31
+ color: 'primary',
32
+ heading: true
33
+ },
34
+ h3: {
35
+ size: 'xl',
36
+ weight: 'semibold',
37
+ line: 'tight',
38
+ color: 'primary',
39
+ heading: true
40
+ },
41
+ title: {
42
+ size: 'lg',
43
+ weight: 'semibold',
44
+ line: 'normal',
45
+ color: 'primary'
46
+ },
47
+ body: {
48
+ size: 'base',
49
+ weight: 'normal',
50
+ line: 'normal',
51
+ color: 'primary'
52
+ },
53
+ bodySmall: {
54
+ size: 'sm',
55
+ weight: 'normal',
56
+ line: 'normal',
57
+ color: 'secondary'
58
+ },
59
+ caption: {
60
+ size: 'xs',
61
+ weight: 'normal',
62
+ line: 'normal',
63
+ color: 'tertiary'
64
+ },
65
+ label: {
66
+ size: 'sm',
67
+ weight: 'medium',
68
+ line: 'normal',
69
+ color: 'secondary'
70
+ },
71
+ overline: {
72
+ size: 'xs',
73
+ weight: 'semibold',
74
+ line: 'normal',
75
+ color: 'secondary',
76
+ uppercase: true,
77
+ letterSpacing: 'wide'
78
+ }
79
+ };
80
+ const TEXT_ROLES = {
81
+ primary: true,
82
+ secondary: true,
83
+ tertiary: true,
84
+ inverse: true,
85
+ disabled: true,
86
+ link: true
87
+ };
88
+ const SEMANTIC = {
89
+ success: true,
90
+ warning: true,
91
+ error: true,
92
+ info: true
93
+ };
94
+ const resolveColor = (theme, color) => {
95
+ // Text roles win over the same-named brand colour ('primary' -> text.primary),
96
+ // which is the intent the vast majority of the time for text.
97
+ if (TEXT_ROLES[color]) return theme.colors.text[color];
98
+ if (SEMANTIC[color]) return theme.colors[color];
99
+ return color; // raw colour string
100
+ };
101
+ const Text = exports.Text = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
102
+ const {
103
+ variant = 'body',
104
+ color,
105
+ weight,
106
+ size,
107
+ align,
108
+ italic,
109
+ underline,
110
+ style,
111
+ children,
112
+ ...rest
113
+ } = props;
114
+ const theme = (0, _index.useTheme)();
115
+ const textStyle = (0, _react.useMemo)(() => {
116
+ const spec = VARIANTS[variant];
117
+ const fontSize = typeof size === 'number' ? size : theme.typography.fontSize[size ?? spec.size];
118
+ const lineHeight = Math.round(fontSize * theme.typography.lineHeight[spec.line]);
119
+ return {
120
+ fontSize,
121
+ lineHeight,
122
+ color: resolveColor(theme, color ?? spec.color),
123
+ textAlign: align,
124
+ textTransform: spec.uppercase ? 'uppercase' : undefined,
125
+ letterSpacing: spec.letterSpacing ? theme.typography.letterSpacing[spec.letterSpacing] : undefined,
126
+ fontStyle: italic ? 'italic' : undefined,
127
+ textDecorationLine: underline ? 'underline' : undefined,
128
+ ...(0, _index.fontFor)(theme, weight ?? spec.weight)
129
+ };
130
+ }, [theme, variant, color, weight, size, align, italic, underline]);
131
+ const heading = VARIANTS[variant].heading;
132
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
133
+ ref: ref,
134
+ style: [textStyle, style],
135
+ accessibilityRole: heading ? 'header' : rest.accessibilityRole,
136
+ ...rest,
137
+ children: children
138
+ });
139
+ });
140
+ Text.displayName = 'Text';
141
+ var _default = exports.default = Text;
142
+ //# sourceMappingURL=Text.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Text", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Text.Text;
10
+ }
11
+ });
12
+ var _Text = require("./Text.js");
13
+ //# sourceMappingURL=index.js.map
@@ -17,12 +17,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
17
17
  /**
18
18
  * TimePicker supports two modes:
19
19
  *
20
- * 1. Controlled-modal mode — pass `visible`, `onSelect`, `onClose`. The
20
+ * 1. Controlled-modal mode — pass `visible`, `onChange`, `onClose`. The
21
21
  * component renders only the modal sheet and the caller owns open/close
22
22
  * state plus its own trigger UI.
23
23
  * 2. Trigger mode — omit `visible`. The component renders a PickerTrigger
24
24
  * field (label / value / placeholder / chevron / clear / helper / error)
25
- * and manages its own modal open state. `onSelect` is still called on
25
+ * and manages its own modal open state. `onChange` is still called on
26
26
  * confirm.
27
27
  */
28
28
 
@@ -223,7 +223,7 @@ const TimePicker = props => {
223
223
  const {
224
224
  visible,
225
225
  value,
226
- onSelect,
226
+ onChange,
227
227
  onClose,
228
228
  format = '12h',
229
229
  minuteStep = 1,
@@ -310,8 +310,9 @@ const TimePicker = props => {
310
310
  const opacity = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
311
311
  const translateY = (0, _react.useRef)((0, _index.createAnimatedValue)(40)).current;
312
312
  (0, _react.useEffect)(() => {
313
+ let anim;
313
314
  if (open) {
314
- _reactNative.Animated.parallel([
315
+ anim = _reactNative.Animated.parallel([
315
316
  // Backdrop opacity uses JS driver — see Modal.tsx for the Fabric reason.
316
317
  _reactNative.Animated.timing(opacity, {
317
318
  toValue: 1,
@@ -324,11 +325,13 @@ const TimePicker = props => {
324
325
  stiffness: theme.motion.spring.snappy.stiffness,
325
326
  mass: theme.motion.spring.snappy.mass,
326
327
  useNativeDriver: true
327
- })]).start();
328
+ })]);
329
+ anim.start();
328
330
  } else {
329
331
  opacity.setValue(0);
330
332
  (0, _index.setNativeValue)(translateY, 40);
331
333
  }
334
+ return () => anim?.stop();
332
335
  }, [open, opacity, translateY, theme.motion]);
333
336
  const announce = (0, _react.useCallback)(msg => {
334
337
  if (_reactNative.Platform.OS === 'ios' || _reactNative.Platform.OS === 'android') {
@@ -357,12 +360,12 @@ const TimePicker = props => {
357
360
  const hour24 = to24h(displayHour, period, format);
358
361
  const minute = minutes[minuteIndex] ?? 0;
359
362
  if (theme.components.timePicker?.haptic) (0, _hapticUtils.triggerHaptic)('notificationSuccess');
360
- onSelect?.({
363
+ onChange?.({
361
364
  hour: hour24,
362
365
  minute
363
366
  });
364
367
  handleCloseModal();
365
- }, [hours, hourIndex, periods, periodIndex, minutes, minuteIndex, format, onSelect, handleCloseModal, theme.components.timePicker]);
368
+ }, [hours, hourIndex, periods, periodIndex, minutes, minuteIndex, format, onChange, handleCloseModal, theme.components.timePicker]);
366
369
  const summary = (0, _react.useMemo)(() => {
367
370
  const displayHour = hours[hourIndex] ?? 0;
368
371
  const minute = minutes[minuteIndex] ?? 0;
@@ -44,6 +44,18 @@ const Toast = ({
44
44
  const translateX = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
45
45
  const opacity = (0, _react.useRef)((0, _index.createAnimatedValue)(0)).current;
46
46
  const dismissedRef = (0, _react.useRef)(false);
47
+ const stackTranslate = position === 'top' ? index * stackOffset : -index * stackOffset;
48
+ const stackScale = Math.max(1 - index * stackScaleStep, stackMinScale);
49
+
50
+ // The stack offset rides on its own value so the enter spring (translateY)
51
+ // and the layout offset compose once instead of rebuilding a fresh
52
+ // `new Animated.Value` + `Animated.add` node on every render. setNativeValue
53
+ // keeps it in sync after the node has moved to the native driver.
54
+ const stackTranslateY = (0, _react.useRef)((0, _index.createAnimatedValue)(stackTranslate)).current;
55
+ (0, _react.useEffect)(() => {
56
+ (0, _index.setNativeValue)(stackTranslateY, stackTranslate);
57
+ }, [stackTranslate, stackTranslateY]);
58
+ const composedTranslateY = (0, _react.useMemo)(() => _reactNative.Animated.add(translateY, stackTranslateY), [translateY, stackTranslateY]);
47
59
  const dismiss = (animateOut = true) => {
48
60
  if (dismissedRef.current) return;
49
61
  dismissedRef.current = true;
@@ -62,7 +74,7 @@ const Toast = ({
62
74
  }
63
75
  };
64
76
  (0, _react.useEffect)(() => {
65
- _reactNative.Animated.parallel([_reactNative.Animated.spring(translateY, {
77
+ const enter = _reactNative.Animated.parallel([_reactNative.Animated.spring(translateY, {
66
78
  toValue: 0,
67
79
  damping: enterSpringDamping,
68
80
  stiffness: enterSpringStiffness,
@@ -72,13 +84,17 @@ const Toast = ({
72
84
  toValue: 1,
73
85
  duration: theme.motion.duration.fast,
74
86
  useNativeDriver: true
75
- })]).start();
87
+ })]);
88
+ enter.start();
76
89
  const duration = toast.duration ?? defaultDurationMs;
77
90
  if (duration > 0) {
78
91
  const timer = setTimeout(() => dismiss(true), duration);
79
- return () => clearTimeout(timer);
92
+ return () => {
93
+ enter.stop();
94
+ clearTimeout(timer);
95
+ };
80
96
  }
81
- return undefined;
97
+ return () => enter.stop();
82
98
  // eslint-disable-next-line react-hooks/exhaustive-deps
83
99
  }, []);
84
100
  const panResponder = (0, _react.useMemo)(() => _reactNative.PanResponder.create({
@@ -113,11 +129,7 @@ const Toast = ({
113
129
  })]).start();
114
130
  }
115
131
  }
116
- }),
117
- // eslint-disable-next-line react-hooks/exhaustive-deps
118
- []);
119
- const stackTranslate = position === 'top' ? index * stackOffset : -index * stackOffset;
120
- const stackScale = Math.max(1 - index * stackScaleStep, stackMinScale);
132
+ }), [translateX, opacity, swipeDismissThreshold, swipeVelocityThreshold, theme.motion.duration.fast, onDismiss, toast.id]);
121
133
  const handleActionPress = () => {
122
134
  toast.action?.onPress();
123
135
  dismiss(true);
@@ -157,7 +169,7 @@ const Toast = ({
157
169
  shadowColor: theme.shadows.md.shadowColor,
158
170
  opacity,
159
171
  transform: [{
160
- translateY: _reactNative.Animated.add(translateY, new _reactNative.Animated.Value(stackTranslate))
172
+ translateY: composedTranslateY
161
173
  }, {
162
174
  translateX
163
175
  }, {
@@ -107,6 +107,7 @@ const Tooltip = props => {
107
107
  }
108
108
  };
109
109
  }
110
+ let anim;
110
111
  if (visible) {
111
112
  measureAnchor();
112
113
  const enterAnims = [_reactNative.Animated.timing(opacity, {
@@ -123,7 +124,8 @@ const Tooltip = props => {
123
124
  useNativeDriver: true
124
125
  }));
125
126
  }
126
- _reactNative.Animated.parallel(enterAnims).start();
127
+ anim = _reactNative.Animated.parallel(enterAnims);
128
+ anim.start();
127
129
  if (trigger === 'press') {
128
130
  if (autoHideTimer.current) clearTimeout(autoHideTimer.current);
129
131
  autoHideTimer.current = setTimeout(() => {
@@ -143,13 +145,15 @@ const Tooltip = props => {
143
145
  useNativeDriver: true
144
146
  }));
145
147
  }
146
- _reactNative.Animated.parallel(exitAnims).start();
148
+ anim = _reactNative.Animated.parallel(exitAnims);
149
+ anim.start();
147
150
  if (autoHideTimer.current) {
148
151
  clearTimeout(autoHideTimer.current);
149
152
  autoHideTimer.current = null;
150
153
  }
151
154
  }
152
155
  return () => {
156
+ anim?.stop();
153
157
  if (autoHideTimer.current) {
154
158
  clearTimeout(autoHideTimer.current);
155
159
  autoHideTimer.current = null;