@webority-technologies/mobile 0.0.21 → 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 (187) 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 +69 -13
  7. package/lib/commonjs/components/BottomSheet/index.js +6 -0
  8. package/lib/commonjs/components/Box/Box.js +162 -0
  9. package/lib/commonjs/components/Box/index.js +37 -0
  10. package/lib/commonjs/components/Button/Button.js +7 -7
  11. package/lib/commonjs/components/Carousel/Carousel.js +4 -2
  12. package/lib/commonjs/components/Checkbox/Checkbox.js +14 -5
  13. package/lib/commonjs/components/DatePicker/DatePicker.js +9 -7
  14. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +5 -2
  15. package/lib/commonjs/components/Dialog/Dialog.js +2 -2
  16. package/lib/commonjs/components/FieldBase/FieldBase.js +8 -4
  17. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +13 -5
  18. package/lib/commonjs/components/FormField/FormField.js +61 -25
  19. package/lib/commonjs/components/Input/Input.js +41 -29
  20. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +102 -0
  21. package/lib/commonjs/components/KeyboardAwareScrollView/index.js +13 -0
  22. package/lib/commonjs/components/KeyboardToolbar/KeyboardToolbar.js +130 -0
  23. package/lib/commonjs/components/KeyboardToolbar/index.js +13 -0
  24. package/lib/commonjs/components/Modal/Modal.js +17 -6
  25. package/lib/commonjs/components/NumberInput/NumberInput.js +35 -28
  26. package/lib/commonjs/components/OTPInput/OTPInput.js +33 -18
  27. package/lib/commonjs/components/Radio/Radio.js +7 -5
  28. package/lib/commonjs/components/Radio/RadioGroup.js +10 -3
  29. package/lib/commonjs/components/SearchBar/SearchBar.js +4 -2
  30. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +20 -10
  31. package/lib/commonjs/components/Select/Select.js +33 -32
  32. package/lib/commonjs/components/Skeleton/SkeletonContent.js +5 -2
  33. package/lib/commonjs/components/Slider/Slider.js +42 -26
  34. package/lib/commonjs/components/Spinner/Spinner.js +5 -5
  35. package/lib/commonjs/components/Switch/Switch.js +29 -16
  36. package/lib/commonjs/components/Tabs/Tabs.js +4 -2
  37. package/lib/commonjs/components/Text/Text.js +142 -0
  38. package/lib/commonjs/components/Text/index.js +13 -0
  39. package/lib/commonjs/components/TimePicker/TimePicker.js +10 -7
  40. package/lib/commonjs/components/Toast/Toast.js +22 -10
  41. package/lib/commonjs/components/Tooltip/Tooltip.js +6 -2
  42. package/lib/commonjs/components/index.js +141 -89
  43. package/lib/commonjs/form/FormContext.js +40 -0
  44. package/lib/commonjs/form/index.js +68 -0
  45. package/lib/commonjs/form/path.js +79 -0
  46. package/lib/commonjs/form/rules.js +67 -0
  47. package/lib/commonjs/form/types.js +2 -0
  48. package/lib/commonjs/form/useField.js +54 -0
  49. package/lib/commonjs/form/useForm.js +316 -0
  50. package/lib/commonjs/hooks/index.js +14 -0
  51. package/lib/commonjs/hooks/useControllableState.js +30 -0
  52. package/lib/commonjs/hooks/useReducedMotion.js +31 -0
  53. package/lib/commonjs/index.js +96 -11
  54. package/lib/commonjs/theme/ThemeContext.js +30 -2
  55. package/lib/commonjs/theme/tokens.js +12 -0
  56. package/lib/module/components/Accordion/Accordion.js +4 -2
  57. package/lib/module/components/Avatar/Avatar.js +4 -2
  58. package/lib/module/components/Badge/Badge.js +5 -5
  59. package/lib/module/components/Banner/Banner.js +8 -4
  60. package/lib/module/components/BottomNavigation/BottomNavigation.js +6 -4
  61. package/lib/module/components/BottomSheet/BottomSheet.js +68 -13
  62. package/lib/module/components/BottomSheet/index.js +1 -1
  63. package/lib/module/components/Box/Box.js +156 -0
  64. package/lib/module/components/Box/index.js +4 -0
  65. package/lib/module/components/Button/Button.js +7 -7
  66. package/lib/module/components/Carousel/Carousel.js +4 -2
  67. package/lib/module/components/Checkbox/Checkbox.js +14 -5
  68. package/lib/module/components/DatePicker/DatePicker.js +9 -7
  69. package/lib/module/components/DateRangePicker/DateRangePicker.js +5 -2
  70. package/lib/module/components/Dialog/Dialog.js +2 -2
  71. package/lib/module/components/FieldBase/FieldBase.js +8 -4
  72. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +13 -5
  73. package/lib/module/components/FormField/FormField.js +62 -26
  74. package/lib/module/components/Input/Input.js +41 -29
  75. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +98 -0
  76. package/lib/module/components/KeyboardAwareScrollView/index.js +4 -0
  77. package/lib/module/components/KeyboardToolbar/KeyboardToolbar.js +125 -0
  78. package/lib/module/components/KeyboardToolbar/index.js +4 -0
  79. package/lib/module/components/Modal/Modal.js +17 -6
  80. package/lib/module/components/NumberInput/NumberInput.js +30 -23
  81. package/lib/module/components/OTPInput/OTPInput.js +30 -15
  82. package/lib/module/components/Radio/Radio.js +7 -5
  83. package/lib/module/components/Radio/RadioGroup.js +10 -3
  84. package/lib/module/components/SearchBar/SearchBar.js +4 -2
  85. package/lib/module/components/SegmentedControl/SegmentedControl.js +20 -10
  86. package/lib/module/components/Select/Select.js +33 -32
  87. package/lib/module/components/Skeleton/SkeletonContent.js +5 -2
  88. package/lib/module/components/Slider/Slider.js +42 -26
  89. package/lib/module/components/Spinner/Spinner.js +5 -5
  90. package/lib/module/components/Switch/Switch.js +29 -16
  91. package/lib/module/components/Tabs/Tabs.js +4 -2
  92. package/lib/module/components/Text/Text.js +138 -0
  93. package/lib/module/components/Text/index.js +4 -0
  94. package/lib/module/components/TimePicker/TimePicker.js +10 -7
  95. package/lib/module/components/Toast/Toast.js +22 -10
  96. package/lib/module/components/Tooltip/Tooltip.js +6 -2
  97. package/lib/module/components/index.js +5 -1
  98. package/lib/module/form/FormContext.js +32 -0
  99. package/lib/module/form/index.js +12 -0
  100. package/lib/module/form/path.js +72 -0
  101. package/lib/module/form/rules.js +52 -0
  102. package/lib/module/form/types.js +2 -0
  103. package/lib/module/form/useField.js +49 -0
  104. package/lib/module/form/useForm.js +312 -0
  105. package/lib/module/hooks/index.js +2 -0
  106. package/lib/module/hooks/useControllableState.js +26 -0
  107. package/lib/module/hooks/useReducedMotion.js +27 -0
  108. package/lib/module/index.js +3 -1
  109. package/lib/module/theme/ThemeContext.js +30 -2
  110. package/lib/module/theme/tokens.js +12 -0
  111. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +1 -1
  112. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +41 -0
  113. package/lib/typescript/commonjs/components/BottomSheet/index.d.ts +2 -2
  114. package/lib/typescript/commonjs/components/Box/Box.d.ts +60 -0
  115. package/lib/typescript/commonjs/components/Box/index.d.ts +3 -0
  116. package/lib/typescript/commonjs/components/Button/Button.d.ts +1 -1
  117. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +3 -2
  118. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +3 -3
  119. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +2 -2
  120. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +13 -2
  121. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
  122. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/index.d.ts +3 -0
  123. package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
  124. package/lib/typescript/commonjs/components/KeyboardToolbar/index.d.ts +3 -0
  125. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +3 -2
  126. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
  127. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -2
  128. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +3 -2
  129. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  130. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +6 -4
  131. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +1 -1
  132. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
  133. package/lib/typescript/commonjs/components/Text/Text.d.ts +25 -0
  134. package/lib/typescript/commonjs/components/Text/index.d.ts +3 -0
  135. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +3 -3
  136. package/lib/typescript/commonjs/components/index.d.ts +10 -2
  137. package/lib/typescript/commonjs/form/FormContext.d.ts +17 -0
  138. package/lib/typescript/commonjs/form/index.d.ts +9 -0
  139. package/lib/typescript/commonjs/form/path.d.ts +10 -0
  140. package/lib/typescript/commonjs/form/rules.d.ts +31 -0
  141. package/lib/typescript/commonjs/form/types.d.ts +94 -0
  142. package/lib/typescript/commonjs/form/useField.d.ts +27 -0
  143. package/lib/typescript/commonjs/form/useForm.d.ts +10 -0
  144. package/lib/typescript/commonjs/hooks/index.d.ts +3 -0
  145. package/lib/typescript/commonjs/hooks/useControllableState.d.ts +17 -0
  146. package/lib/typescript/commonjs/hooks/useReducedMotion.d.ts +8 -0
  147. package/lib/typescript/commonjs/index.d.ts +4 -2
  148. package/lib/typescript/commonjs/theme/types.d.ts +15 -0
  149. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +1 -1
  150. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +41 -0
  151. package/lib/typescript/module/components/BottomSheet/index.d.ts +2 -2
  152. package/lib/typescript/module/components/Box/Box.d.ts +60 -0
  153. package/lib/typescript/module/components/Box/index.d.ts +3 -0
  154. package/lib/typescript/module/components/Button/Button.d.ts +1 -1
  155. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +3 -2
  156. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +3 -3
  157. package/lib/typescript/module/components/Dialog/Dialog.d.ts +2 -2
  158. package/lib/typescript/module/components/FormField/FormField.d.ts +13 -2
  159. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +20 -0
  160. package/lib/typescript/module/components/KeyboardAwareScrollView/index.d.ts +3 -0
  161. package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +29 -0
  162. package/lib/typescript/module/components/KeyboardToolbar/index.d.ts +3 -0
  163. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +3 -2
  164. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
  165. package/lib/typescript/module/components/Radio/Radio.d.ts +2 -2
  166. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +3 -2
  167. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  168. package/lib/typescript/module/components/Slider/Slider.d.ts +6 -4
  169. package/lib/typescript/module/components/Spinner/Spinner.d.ts +1 -1
  170. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
  171. package/lib/typescript/module/components/Text/Text.d.ts +25 -0
  172. package/lib/typescript/module/components/Text/index.d.ts +3 -0
  173. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +3 -3
  174. package/lib/typescript/module/components/index.d.ts +10 -2
  175. package/lib/typescript/module/form/FormContext.d.ts +17 -0
  176. package/lib/typescript/module/form/index.d.ts +9 -0
  177. package/lib/typescript/module/form/path.d.ts +10 -0
  178. package/lib/typescript/module/form/rules.d.ts +31 -0
  179. package/lib/typescript/module/form/types.d.ts +94 -0
  180. package/lib/typescript/module/form/useField.d.ts +27 -0
  181. package/lib/typescript/module/form/useForm.d.ts +10 -0
  182. package/lib/typescript/module/hooks/index.d.ts +3 -0
  183. package/lib/typescript/module/hooks/useControllableState.d.ts +17 -0
  184. package/lib/typescript/module/hooks/useReducedMotion.d.ts +8 -0
  185. package/lib/typescript/module/index.d.ts +4 -2
  186. package/lib/typescript/module/theme/types.d.ts +15 -0
  187. 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
  /**
@@ -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 === 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
- }).start();
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 === value) return;
109
+ if (segment.value === current) return;
100
110
  if (changeHapticEnabled) (0, _index2.triggerHaptic)('selection');
101
- onChange(segment.value);
102
- }, [disabled, onChange, value, changeHapticEnabled]);
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 === 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
- if (open) {
70
- _reactNative.Animated.parallel([
71
- // Backdrop opacity uses JS driver — see Modal.tsx for the Fabric reason.
72
- _reactNative.Animated.timing(backdropAnim, {
73
- toValue: 1,
74
- duration: theme.motion.duration.fast,
75
- easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
76
- useNativeDriver: false
77
- }), _reactNative.Animated.spring(sheetAnim, {
78
- toValue: 0,
79
- damping: theme.motion.spring.snappy.damping,
80
- stiffness: theme.motion.spring.snappy.stiffness,
81
- mass: theme.motion.spring.snappy.mass,
82
- useNativeDriver: true
83
- })]).start();
84
- } else {
85
- _reactNative.Animated.parallel([_reactNative.Animated.timing(backdropAnim, {
86
- toValue: 0,
87
- duration: theme.motion.duration.fast,
88
- easing: _reactNative.Easing.bezier(...theme.motion.easing.standard),
89
- useNativeDriver: false
90
- }), _reactNative.Animated.timing(sheetAnim, {
91
- toValue: sheetMaxHeight,
92
- duration: theme.motion.duration.fast,
93
- easing: _reactNative.Easing.bezier(...theme.motion.easing.accelerate),
94
- useNativeDriver: true
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: 160,
397
+ duration: theme.motion.duration.fast,
399
398
  useNativeDriver: true
400
- }).start();
401
- }, [open, rotate]);
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
- }).start();
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) {
@@ -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