react-native-system-ui 0.0.3 → 0.0.5

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 (168) hide show
  1. package/dist/cjs/components/area/Area.js +4 -10
  2. package/dist/cjs/components/avatar/Avatar.js +3 -3
  3. package/dist/cjs/components/avatar/tokens.js +2 -1
  4. package/dist/cjs/components/badge/Badge.js +30 -38
  5. package/dist/cjs/components/button/Button.js +13 -13
  6. package/dist/cjs/components/button/ButtonGroup.js +8 -8
  7. package/dist/cjs/components/calendar/Calendar.js +10 -10
  8. package/dist/cjs/components/cascader/Cascader.js +4 -4
  9. package/dist/cjs/components/cascader/useCascaderExtend.js +5 -15
  10. package/dist/cjs/components/checkbox/CheckboxGroup.js +2 -2
  11. package/dist/cjs/components/circle/Circle.js +2 -2
  12. package/dist/cjs/components/collapse/Collapse.js +13 -16
  13. package/dist/cjs/components/config-provider/ConfigProvider.js +1 -1
  14. package/dist/cjs/components/datetime-picker/DatetimePicker.js +7 -7
  15. package/dist/cjs/components/dialog/Dialog.js +4 -6
  16. package/dist/cjs/components/dialog/tokens.js +2 -1
  17. package/dist/cjs/components/dropdown-menu/DropdownItem.js +53 -52
  18. package/dist/cjs/components/dropdown-menu/DropdownMenu.js +19 -23
  19. package/dist/cjs/components/dropdown-menu/tokens.js +20 -3
  20. package/dist/cjs/components/field/Field.js +6 -6
  21. package/dist/cjs/components/form/Form.js +5 -9
  22. package/dist/cjs/components/grid/Grid.js +4 -4
  23. package/dist/cjs/components/image/Image.js +19 -15
  24. package/dist/cjs/components/image-preview/ImagePreview.js +62 -60
  25. package/dist/cjs/components/image-preview/tokens.js +21 -2
  26. package/dist/cjs/components/index-bar/IndexAnchor.js +7 -6
  27. package/dist/cjs/components/index-bar/IndexBar.js +38 -44
  28. package/dist/cjs/components/index-bar/tokens.js +22 -13
  29. package/dist/cjs/components/index.js +343 -0
  30. package/dist/cjs/components/input/Input.js +7 -10
  31. package/dist/cjs/components/notice-bar/NoticeBar.js +69 -95
  32. package/dist/cjs/components/notify/Notify.js +49 -24
  33. package/dist/cjs/components/notify/defaults.js +2 -2
  34. package/dist/cjs/components/notify/imperative.js +1 -1
  35. package/dist/cjs/components/notify/tokens.js +5 -4
  36. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +12 -12
  37. package/dist/cjs/components/number-keyboard/tokens.js +4 -2
  38. package/dist/cjs/components/overlay/useOverlayStack.js +5 -1
  39. package/dist/cjs/components/pagination/Pagination.js +2 -2
  40. package/dist/cjs/components/password-input/PasswordInput.js +35 -27
  41. package/dist/cjs/components/picker/Picker.js +11 -12
  42. package/dist/cjs/components/picker/WheelPicker.js +9 -9
  43. package/dist/cjs/components/picker/tokens.js +4 -2
  44. package/dist/cjs/components/popup/Popup.js +39 -54
  45. package/dist/cjs/components/popup/tokens.js +2 -1
  46. package/dist/cjs/components/portal/Portal.js +5 -0
  47. package/dist/cjs/components/portal/PortalHost.js +1 -13
  48. package/dist/cjs/components/pull-refresh/PullRefresh.js +46 -27
  49. package/dist/cjs/components/radio/RadioGroup.js +2 -2
  50. package/dist/cjs/components/search/Search.js +52 -67
  51. package/dist/cjs/components/search/tokens.js +2 -1
  52. package/dist/cjs/components/selector/Selector.js +3 -3
  53. package/dist/cjs/components/share-sheet/ShareSheet.js +64 -62
  54. package/dist/cjs/components/share-sheet/tokens.js +15 -2
  55. package/dist/cjs/components/sidebar/Sidebar.js +15 -19
  56. package/dist/cjs/components/sidebar/SidebarItem.js +0 -3
  57. package/dist/cjs/components/skeleton/Skeleton.js +44 -56
  58. package/dist/cjs/components/slider/Slider.js +55 -61
  59. package/dist/cjs/components/stepper/Stepper.js +13 -16
  60. package/dist/cjs/components/stepper/tokens.js +4 -2
  61. package/dist/cjs/components/swiper/Swiper.js +21 -42
  62. package/dist/cjs/components/swiper/useSwiperWeb.js +15 -18
  63. package/dist/cjs/components/tabbar/Tabbar.js +8 -11
  64. package/dist/cjs/components/tabbar/TabbarItem.js +0 -3
  65. package/dist/cjs/components/tabs/Tabs.js +33 -54
  66. package/dist/cjs/components/tabs/tokens.js +9 -1
  67. package/dist/cjs/components/tabs/useTabsScroll.js +4 -0
  68. package/dist/cjs/components/toast/Toast.js +10 -8
  69. package/dist/cjs/components/toast/tokens.js +5 -1
  70. package/dist/cjs/components/typography/Typography.js +17 -30
  71. package/dist/cjs/components/uploader/Uploader.js +49 -46
  72. package/dist/cjs/components/uploader/tokens.js +27 -1
  73. package/dist/cjs/components/water-mark/WaterMark.js +16 -16
  74. package/dist/cjs/hooks/usePresenceAnimation.js +12 -2
  75. package/dist/es/components/area/Area.js +5 -11
  76. package/dist/es/components/avatar/Avatar.js +3 -3
  77. package/dist/es/components/avatar/tokens.js +2 -1
  78. package/dist/es/components/badge/Badge.js +31 -39
  79. package/dist/es/components/button/Button.js +14 -14
  80. package/dist/es/components/button/ButtonGroup.js +7 -7
  81. package/dist/es/components/calendar/Calendar.js +11 -11
  82. package/dist/es/components/cascader/Cascader.js +5 -5
  83. package/dist/es/components/cascader/useCascaderExtend.js +5 -9
  84. package/dist/es/components/checkbox/CheckboxGroup.js +3 -3
  85. package/dist/es/components/circle/Circle.js +3 -3
  86. package/dist/es/components/collapse/Collapse.js +14 -17
  87. package/dist/es/components/config-provider/ConfigProvider.js +2 -2
  88. package/dist/es/components/datetime-picker/DatetimePicker.js +8 -8
  89. package/dist/es/components/dialog/Dialog.js +4 -6
  90. package/dist/es/components/dialog/tokens.js +2 -1
  91. package/dist/es/components/dropdown-menu/DropdownItem.js +53 -52
  92. package/dist/es/components/dropdown-menu/DropdownMenu.js +20 -24
  93. package/dist/es/components/dropdown-menu/tokens.js +20 -3
  94. package/dist/es/components/field/Field.js +7 -7
  95. package/dist/es/components/field/index.js +1 -1
  96. package/dist/es/components/form/Form.js +6 -10
  97. package/dist/es/components/grid/Grid.js +3 -3
  98. package/dist/es/components/image/Image.js +20 -16
  99. package/dist/es/components/image-preview/ImagePreview.js +63 -61
  100. package/dist/es/components/image-preview/tokens.js +21 -2
  101. package/dist/es/components/index-bar/IndexAnchor.js +7 -6
  102. package/dist/es/components/index-bar/IndexBar.js +39 -45
  103. package/dist/es/components/index-bar/tokens.js +22 -13
  104. package/dist/es/components/index.js +50 -1
  105. package/dist/es/components/input/Input.js +8 -11
  106. package/dist/es/components/notice-bar/NoticeBar.js +70 -96
  107. package/dist/es/components/notify/Notify.js +49 -25
  108. package/dist/es/components/notify/defaults.js +2 -2
  109. package/dist/es/components/notify/imperative.js +1 -1
  110. package/dist/es/components/notify/tokens.js +5 -4
  111. package/dist/es/components/number-keyboard/NumberKeyboard.js +13 -13
  112. package/dist/es/components/number-keyboard/tokens.js +4 -2
  113. package/dist/es/components/overlay/useOverlayStack.js +6 -2
  114. package/dist/es/components/pagination/Pagination.js +3 -3
  115. package/dist/es/components/password-input/PasswordInput.js +36 -28
  116. package/dist/es/components/picker/Picker.js +12 -13
  117. package/dist/es/components/picker/WheelPicker.js +10 -10
  118. package/dist/es/components/picker/tokens.js +4 -2
  119. package/dist/es/components/popup/Popup.js +41 -56
  120. package/dist/es/components/popup/tokens.js +2 -1
  121. package/dist/es/components/portal/Portal.js +5 -0
  122. package/dist/es/components/portal/PortalHost.js +1 -13
  123. package/dist/es/components/pull-refresh/PullRefresh.js +47 -28
  124. package/dist/es/components/radio/RadioGroup.js +3 -3
  125. package/dist/es/components/search/Search.js +53 -68
  126. package/dist/es/components/search/tokens.js +2 -1
  127. package/dist/es/components/selector/Selector.js +4 -4
  128. package/dist/es/components/share-sheet/ShareSheet.js +65 -63
  129. package/dist/es/components/share-sheet/tokens.js +15 -2
  130. package/dist/es/components/sidebar/Sidebar.js +14 -18
  131. package/dist/es/components/sidebar/SidebarItem.js +0 -3
  132. package/dist/es/components/skeleton/Skeleton.js +45 -57
  133. package/dist/es/components/slider/Slider.js +56 -62
  134. package/dist/es/components/stepper/Stepper.js +14 -17
  135. package/dist/es/components/stepper/tokens.js +4 -2
  136. package/dist/es/components/swiper/Swiper.js +22 -43
  137. package/dist/es/components/swiper/useSwiperWeb.js +16 -19
  138. package/dist/es/components/tabbar/Tabbar.js +9 -12
  139. package/dist/es/components/tabbar/TabbarItem.js +0 -3
  140. package/dist/es/components/tabs/Tabs.js +34 -55
  141. package/dist/es/components/tabs/tokens.js +9 -1
  142. package/dist/es/components/tabs/useTabsScroll.js +4 -0
  143. package/dist/es/components/toast/Toast.js +10 -8
  144. package/dist/es/components/toast/tokens.js +5 -1
  145. package/dist/es/components/typography/Typography.js +18 -31
  146. package/dist/es/components/uploader/Uploader.js +49 -46
  147. package/dist/es/components/uploader/tokens.js +27 -1
  148. package/dist/es/components/water-mark/WaterMark.js +17 -17
  149. package/dist/es/hooks/usePresenceAnimation.js +12 -2
  150. package/dist/types/components/dialog/tokens.d.ts +1 -0
  151. package/dist/types/components/dropdown-menu/tokens.d.ts +17 -0
  152. package/dist/types/components/field/index.d.ts +1 -1
  153. package/dist/types/components/image-preview/tokens.d.ts +16 -0
  154. package/dist/types/components/index-bar/tokens.d.ts +13 -4
  155. package/dist/types/components/index.d.ts +102 -0
  156. package/dist/types/components/notify/defaults.d.ts +2 -2
  157. package/dist/types/components/number-keyboard/tokens.d.ts +1 -0
  158. package/dist/types/components/password-input/PasswordInput.d.ts +4 -0
  159. package/dist/types/components/picker/tokens.d.ts +2 -0
  160. package/dist/types/components/popup/tokens.d.ts +1 -0
  161. package/dist/types/components/search/tokens.d.ts +1 -0
  162. package/dist/types/components/share-sheet/tokens.d.ts +13 -0
  163. package/dist/types/components/stepper/tokens.d.ts +2 -0
  164. package/dist/types/components/tabs/tokens.d.ts +8 -0
  165. package/dist/types/components/toast/tokens.d.ts +4 -0
  166. package/dist/types/components/uploader/tokens.d.ts +25 -0
  167. package/dist/types/hooks/usePresenceAnimation.d.ts +6 -1
  168. package/package.json +135 -135
@@ -54,10 +54,10 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
54
54
  sizing
55
55
  } = tokens;
56
56
  const translateY = (0, _react().useRef)(new (_reactNative().Animated.Value)(0)).current;
57
- const headHeightNumber = (0, _react().useMemo)(() => Math.max(0, (0, _number.parseNumberLike)(headHeight, sizing.headHeight) ?? sizing.headHeight), [headHeight, sizing.headHeight]);
58
- const pullDistanceNumber = (0, _react().useMemo)(() => Math.max(0, (0, _number.parseNumberLike)(pullDistance, headHeightNumber) ?? headHeightNumber), [headHeightNumber, pullDistance]);
59
- const successDurationMs = (0, _react().useMemo)(() => Math.max(0, (0, _number.parseNumberLike)(successDuration, DEFAULT_SUCCESS_DURATION) ?? DEFAULT_SUCCESS_DURATION), [successDuration]);
60
- const animationDurationMs = (0, _react().useMemo)(() => Math.max(0, (0, _number.parseNumberLike)(animationDuration, 300) ?? 300), [animationDuration]);
57
+ const headHeightNumber = Math.max(0, (0, _number.parseNumberLike)(headHeight, sizing.headHeight) ?? sizing.headHeight);
58
+ const pullDistanceNumber = Math.max(0, (0, _number.parseNumberLike)(pullDistance, headHeightNumber) ?? headHeightNumber);
59
+ const successDurationMs = Math.max(0, (0, _number.parseNumberLike)(successDuration, DEFAULT_SUCCESS_DURATION) ?? DEFAULT_SUCCESS_DURATION);
60
+ const animationDurationMs = Math.max(0, (0, _number.parseNumberLike)(animationDuration, 300) ?? 300);
61
61
  const isControlled = !(0, _validate.isUndefined)(refreshing);
62
62
  const [innerRefreshing, setInnerRefreshing] = (0, _react().useState)(!!defaultRefreshing);
63
63
  const mergedRefreshing = isControlled ? !!refreshing : innerRefreshing;
@@ -65,6 +65,8 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
65
65
  const draggingRef = (0, _react().useRef)(false);
66
66
  const webDragRafRef = (0, _react().useRef)(null);
67
67
  const webDragPendingRef = (0, _react().useRef)(null);
68
+ const webStateUpdateAtRef = (0, _react().useRef)(0);
69
+ const webStateUpdateValueRef = (0, _react().useRef)(0);
68
70
  const [distance, setDistance] = (0, _react().useState)(0);
69
71
  const [showSuccess, setShowSuccess] = (0, _react().useState)(false);
70
72
  const timerRef = (0, _react().useRef)(null);
@@ -72,28 +74,45 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
72
74
  const mergedRefreshingRef = (0, _react().useRef)(mergedRefreshing);
73
75
  const refreshTriggeredRef = (0, _react().useRef)(false);
74
76
  const refreshSucceededRef = (0, _react().useRef)(false);
77
+ const normalizeDistance = (0, _react().useCallback)(nextDistance => Math.max(0, Math.round(nextDistance)), []);
78
+ const updateDistanceState = (0, _react().useCallback)(normalized => {
79
+ setDistance(prev => Math.abs(prev - normalized) < 1 ? prev : normalized);
80
+ }, []);
81
+ const applyWebTranslate = (0, _react().useCallback)((normalized, animate = false) => {
82
+ translateY.stopAnimation();
83
+ if (animate && animationDurationMs > 0) {
84
+ _reactNative().Animated.timing(translateY, {
85
+ toValue: normalized,
86
+ duration: animationDurationMs,
87
+ useNativeDriver: false
88
+ }).start();
89
+ } else {
90
+ translateY.setValue(normalized);
91
+ }
92
+ }, [animationDurationMs, translateY]);
75
93
  const setDistanceValue = (0, _react().useCallback)((nextDistance, animate = false) => {
76
- const normalized = Math.max(0, Math.round(nextDistance));
94
+ const normalized = normalizeDistance(nextDistance);
77
95
  if (isWeb) {
78
- translateY.stopAnimation();
79
- if (animate && animationDurationMs > 0) {
80
- _reactNative().Animated.timing(translateY, {
81
- toValue: normalized,
82
- duration: animationDurationMs,
83
- useNativeDriver: false
84
- }).start();
85
- } else {
86
- translateY.setValue(normalized);
87
- }
96
+ applyWebTranslate(normalized, animate);
88
97
  }
89
- setDistance(prev => Math.abs(prev - normalized) < 1 ? prev : normalized);
90
- }, [animationDurationMs, isWeb, translateY]);
98
+ updateDistanceState(normalized);
99
+ return normalized;
100
+ }, [applyWebTranslate, isWeb, normalizeDistance, updateDistanceState]);
91
101
  const flushWebDrag = (0, _react().useCallback)(() => {
92
102
  const pending = webDragPendingRef.current;
93
103
  if (pending == null) return;
94
104
  webDragPendingRef.current = null;
95
- setDistanceValue(pending);
96
- }, [setDistanceValue]);
105
+ const normalized = normalizeDistance(pending);
106
+ if (isWeb) {
107
+ applyWebTranslate(normalized);
108
+ }
109
+ const now = Date.now();
110
+ if (now - webStateUpdateAtRef.current >= 32 || Math.abs(normalized - webStateUpdateValueRef.current) >= 4) {
111
+ webStateUpdateAtRef.current = now;
112
+ webStateUpdateValueRef.current = normalized;
113
+ updateDistanceState(normalized);
114
+ }
115
+ }, [applyWebTranslate, isWeb, normalizeDistance, updateDistanceState]);
97
116
  const cancelWebDrag = (0, _react().useCallback)(() => {
98
117
  if (webDragRafRef.current != null && typeof cancelAnimationFrame === 'function') {
99
118
  cancelAnimationFrame(webDragRafRef.current);
@@ -207,7 +226,7 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
207
226
  refreshTriggeredRef.current = false;
208
227
  refreshSucceededRef.current = false;
209
228
  }, [mergedRefreshing, showSuccess, triggerSuccess]);
210
- const status = (0, _react().useMemo)(() => mergedRefreshing ? 'loading' : showSuccess ? 'success' : disabled || distance === 0 ? 'normal' : distance < pullDistanceNumber ? 'pulling' : 'loosing', [disabled, distance, mergedRefreshing, pullDistanceNumber, showSuccess]);
229
+ const status = mergedRefreshing ? 'loading' : showSuccess ? 'success' : disabled || distance === 0 ? 'normal' : distance < pullDistanceNumber ? 'pulling' : 'loosing';
211
230
  const opacity = (0, _react().useRef)(new (_reactNative().Animated.Value)(status === 'normal' ? 0 : 1)).current;
212
231
  (0, _react().useEffect)(() => {
213
232
  const toValue = status === 'normal' ? 0 : 1;
@@ -222,7 +241,7 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
222
241
  useNativeDriver: _platform.nativeDriverEnabled
223
242
  }).start();
224
243
  }, [animationDurationMs, opacity, status]);
225
- const statusNode = (0, _react().useMemo)(() => {
244
+ const statusNode = (() => {
226
245
  switch (status) {
227
246
  case 'pulling':
228
247
  return resolveStatusText(pullingText, locale.vanPullRefresh.pulling);
@@ -235,13 +254,13 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
235
254
  default:
236
255
  return null;
237
256
  }
238
- }, [loadingText, locale.vanPullRefresh.loading, locale.vanPullRefresh.loosing, locale.vanPullRefresh.pulling, loosingText, pullingText, resolveStatusText, status, successText]);
257
+ })();
239
258
  const shouldReserveHead = (status === 'loading' || status === 'success') && distance === 0;
240
- const flattenedContainerStyle = (0, _react().useMemo)(() => _reactNative().StyleSheet.flatten(scrollProps.contentContainerStyle), [scrollProps.contentContainerStyle]);
259
+ const flattenedContainerStyle = _reactNative().StyleSheet.flatten(scrollProps.contentContainerStyle);
241
260
  const basePaddingTop = (0, _validate.isNumber)(flattenedContainerStyle?.paddingTop) ? flattenedContainerStyle.paddingTop : 0;
242
- const contentContainerStyle = (0, _react().useMemo)(() => shouldReserveHead ? [scrollProps.contentContainerStyle, {
261
+ const contentContainerStyle = shouldReserveHead ? [scrollProps.contentContainerStyle, {
243
262
  paddingTop: basePaddingTop + headHeightNumber
244
- }] : scrollProps.contentContainerStyle, [basePaddingTop, headHeightNumber, scrollProps.contentContainerStyle, shouldReserveHead]);
263
+ }] : scrollProps.contentContainerStyle;
245
264
  const onScrollProp = scrollProps.onScroll;
246
265
  const handleScroll = (0, _react().useCallback)(event => {
247
266
  onScrollProp?.(event);
@@ -257,7 +276,7 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
257
276
  }
258
277
  setDistanceValue(offset < 0 ? -offset : 0);
259
278
  }, [disabled, isWeb, mergedRefreshing, onRefresh, onScrollProp, setDistanceValue, showSuccess]);
260
- const panResponder = (0, _react().useMemo)(() => {
279
+ const panResponder = (() => {
261
280
  if (!isWeb || !(0, _validate.isFunction)(onRefresh)) return null;
262
281
  const easeDistance = raw => {
263
282
  const pullDistance = pullDistanceNumber;
@@ -314,7 +333,7 @@ const PullRefresh = /*#__PURE__*/_react().default.forwardRef((props, ref) => {
314
333
  setDistanceValue(0, true);
315
334
  }
316
335
  });
317
- }, [disabled, handleRefresh, headHeightNumber, isWeb, pullDistanceNumber, cancelWebDrag, scheduleWebDrag, setDistanceValue, showSuccess]);
336
+ })();
318
337
  return /*#__PURE__*/_react().default.createElement(_reactNative().ScrollView, _extends({}, scrollProps, {
319
338
  ref: ref,
320
339
  style: style,
@@ -108,7 +108,7 @@ const RadioGroup = props => {
108
108
  columnGap: direction === 'horizontal' ? gap : undefined,
109
109
  rowGap: gap
110
110
  } : null;
111
- const contextValue = (0, _react().useMemo)(() => ({
111
+ const contextValue = {
112
112
  state,
113
113
  direction,
114
114
  iconSize,
@@ -116,7 +116,7 @@ const RadioGroup = props => {
116
116
  labelDisabled,
117
117
  registerValue,
118
118
  unregisterValue
119
- }), [state, direction, iconSize, checkedColor, labelDisabled]);
119
+ };
120
120
  return /*#__PURE__*/_react().default.createElement(_RadioContext.RadioGroupContext.Provider, {
121
121
  value: contextValue
122
122
  }, /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({}, resolvedRadioGroupProps, viewProps, {
@@ -67,7 +67,7 @@ const SearchComponent = (props, ref) => {
67
67
  defaultValue: ''
68
68
  });
69
69
  const inputValue = value ?? '';
70
- const resolvedInputAlign = (0, _react().useMemo)(() => align ?? inputAlign, [align, inputAlign]);
70
+ const resolvedInputAlign = align ?? inputAlign;
71
71
  const handleChange = (0, _react().useCallback)(next => {
72
72
  triggerChange(next);
73
73
  onChangeText?.(next);
@@ -80,14 +80,14 @@ const SearchComponent = (props, ref) => {
80
80
  onSearch?.(inputValue);
81
81
  onSubmitEditing?.(event);
82
82
  }, [inputValue, onSearch, onSubmitEditing]);
83
- const resolvedBackground = (0, _react().useMemo)(() => background ?? tokens.colors.background, [background, tokens.colors.background]);
84
- const resolvedLeftIcon = (0, _react().useMemo)(() => leftIcon ?? /*#__PURE__*/_react().default.createElement(_reactNativeSystemIcon().Search, {
83
+ const resolvedBackground = background ?? tokens.colors.background;
84
+ const resolvedLeftIcon = leftIcon ?? /*#__PURE__*/_react().default.createElement(_reactNativeSystemIcon().Search, {
85
85
  size: tokens.icon.size,
86
86
  fill: tokens.colors.icon,
87
87
  color: tokens.colors.icon
88
- }), [leftIcon, tokens.colors.icon, tokens.icon.size]);
89
- const resolvedClearTrigger = (0, _react().useMemo)(() => clearTrigger ?? tokens.defaults.clearTrigger, [clearTrigger, tokens.defaults.clearTrigger]);
90
- const resolvedReturnKeyType = (0, _react().useMemo)(() => returnKeyType ?? 'search', [returnKeyType]);
88
+ });
89
+ const resolvedClearTrigger = clearTrigger ?? tokens.defaults.clearTrigger;
90
+ const resolvedReturnKeyType = returnKeyType ?? 'search';
91
91
  const shouldShowAction = !!action || showAction;
92
92
  const isCustomActionText = /*#__PURE__*/_react().default.isValidElement(actionText);
93
93
  const shouldRenderCancelAction = shouldShowAction && !action && !isCustomActionText;
@@ -106,64 +106,49 @@ const SearchComponent = (props, ref) => {
106
106
  testID: 'rnsu-search-action'
107
107
  }
108
108
  });
109
- const containerStyles = (0, _react().useMemo)(() => [styles.container, {
109
+ const containerStyles = [styles.container, {
110
110
  paddingHorizontal: tokens.spacing.paddingHorizontal,
111
111
  paddingVertical: tokens.spacing.paddingVertical,
112
112
  backgroundColor: resolvedBackground
113
- }, containerStyle], [containerStyle, resolvedBackground, tokens.spacing.paddingHorizontal, tokens.spacing.paddingVertical]);
114
- const contentStyles = (0, _react().useMemo)(() => [styles.content, {
113
+ }, containerStyle];
114
+ const contentStyles = [styles.content, {
115
115
  borderRadius: radius,
116
116
  paddingHorizontal: tokens.spacing.contentPaddingHorizontal,
117
117
  paddingVertical: tokens.spacing.contentPaddingVertical,
118
118
  backgroundColor: tokens.colors.contentBackground
119
- }], [radius, tokens.colors.contentBackground, tokens.spacing.contentPaddingHorizontal, tokens.spacing.contentPaddingVertical]);
120
- const labelNode = (0, _react().useMemo)(() => {
121
- if (!label) return null;
122
- if ((0, _validate.isText)(label)) {
123
- return /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
124
- style: {
125
- marginRight: tokens.spacing.labelGap,
126
- color: tokens.colors.label,
127
- fontSize: tokens.typography.label,
128
- fontWeight: tokens.typography.labelWeight
129
- }
130
- }, label);
119
+ }];
120
+ const labelNode = !label ? null : (0, _validate.isText)(label) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
121
+ style: {
122
+ marginRight: tokens.spacing.labelGap,
123
+ color: tokens.colors.label,
124
+ fontSize: tokens.typography.label,
125
+ fontWeight: tokens.typography.labelWeight
131
126
  }
132
- return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
133
- style: {
134
- marginRight: tokens.spacing.labelGap
135
- }
136
- }, label);
137
- }, [label, tokens.colors.label, tokens.spacing.labelGap, tokens.typography.label, tokens.typography.labelWeight]);
138
- const actionNode = (0, _react().useMemo)(() => {
139
- if (action) {
140
- return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
141
- style: [styles.actionWrapper, {
142
- marginLeft: tokens.spacing.actionGap
143
- }]
144
- }, action);
127
+ }, label) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
128
+ style: {
129
+ marginRight: tokens.spacing.labelGap
145
130
  }
146
- if (!shouldShowAction) return null;
147
- if (isCustomActionText) {
148
- return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
149
- style: [styles.actionWrapper, {
150
- marginLeft: tokens.spacing.actionGap
151
- }]
152
- }, actionText);
131
+ }, label);
132
+ const actionNode = action ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
133
+ style: [styles.actionWrapper, {
134
+ marginLeft: tokens.spacing.actionGap
135
+ }]
136
+ }, action) : !shouldShowAction ? null : isCustomActionText ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
137
+ style: [styles.actionWrapper, {
138
+ marginLeft: tokens.spacing.actionGap
139
+ }]
140
+ }, actionText) : /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
141
+ style: [styles.actionWrapper, {
142
+ marginLeft: tokens.spacing.actionGap,
143
+ opacity: cancelActionPress.states.pressed ? tokens.opacity.actionPressed : 1
144
+ }]
145
+ }, cancelActionPress.interactionProps), /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
146
+ style: {
147
+ color: tokens.colors.action,
148
+ fontSize: tokens.typography.action,
149
+ fontWeight: tokens.typography.actionWeight
153
150
  }
154
- return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
155
- style: [styles.actionWrapper, {
156
- marginLeft: tokens.spacing.actionGap,
157
- opacity: cancelActionPress.states.pressed ? tokens.opacity.actionPressed : 1
158
- }]
159
- }, cancelActionPress.interactionProps), /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
160
- style: {
161
- color: tokens.colors.action,
162
- fontSize: tokens.typography.action,
163
- fontWeight: tokens.typography.actionWeight
164
- }
165
- }, actionText ?? locale.cancel));
166
- }, [action, actionText, cancelActionPress.interactionProps, cancelActionPress.states.pressed, isCustomActionText, locale.cancel, shouldShowAction, tokens.colors.action, tokens.opacity.actionPressed, tokens.spacing.actionGap, tokens.typography.action, tokens.typography.actionWeight]);
151
+ }, actionText ?? locale.cancel));
167
152
  return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
168
153
  style: containerStyles
169
154
  }, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
@@ -183,9 +168,16 @@ const SearchComponent = (props, ref) => {
183
168
  errorMessage: errorMessage,
184
169
  inputAlign: resolvedInputAlign,
185
170
  border: false,
186
- style: [styles.field, fieldStyle],
187
- contentStyle: [styles.fieldContent, fieldContentStyle],
188
- inputStyle: [styles.input, inputStyle],
171
+ style: [styles.field, {
172
+ paddingHorizontal: tokens.spacing.none,
173
+ paddingVertical: tokens.spacing.none
174
+ }, fieldStyle],
175
+ contentStyle: [styles.fieldContent, {
176
+ paddingVertical: tokens.spacing.none
177
+ }, fieldContentStyle],
178
+ inputStyle: [styles.input, {
179
+ paddingVertical: tokens.spacing.none
180
+ }, inputStyle],
189
181
  onSubmitEditing: handleSubmit,
190
182
  returnKeyType: resolvedReturnKeyType
191
183
  }, restFieldProps)))), actionNode);
@@ -205,16 +197,9 @@ const styles = _reactNative().StyleSheet.create({
205
197
  fieldWrapper: {
206
198
  flex: 1
207
199
  },
208
- field: {
209
- paddingHorizontal: 0,
210
- paddingVertical: 0
211
- },
212
- fieldContent: {
213
- paddingVertical: 0
214
- },
215
- input: {
216
- paddingVertical: 0
217
- },
200
+ field: {},
201
+ fieldContent: {},
202
+ input: {},
218
203
  actionWrapper: {
219
204
  justifyContent: 'center'
220
205
  }
@@ -30,7 +30,8 @@ const createSearchTokens = foundations => {
30
30
  labelGap: spacing.sm,
31
31
  actionGap: spacing.sm,
32
32
  contentPaddingHorizontal: spacing.sm,
33
- contentPaddingVertical: spacing.xs
33
+ contentPaddingVertical: spacing.xs,
34
+ none: spacing.none
34
35
  },
35
36
  radius: {
36
37
  square: radii.md,
@@ -141,15 +141,15 @@ const SelectorImpl = props => {
141
141
  const [value = [], triggerChange] = (0, _hooks.useControllableValue)(props, {
142
142
  defaultValue: []
143
143
  });
144
- const optionByValue = (0, _react().useMemo)(() => {
144
+ const optionByValue = (() => {
145
145
  const map = new Map();
146
146
  for (const option of options) map.set(option.value, option);
147
147
  return map;
148
- }, [options]);
148
+ })();
149
149
  const resolvedColumns = Math.max(1, Math.floor(columns));
150
150
  const basis = `${100 / resolvedColumns}%`;
151
151
  const itemMargin = tokens.spacing.gap / 2;
152
- const selectedSet = (0, _react().useMemo)(() => new Set(value), [value]);
152
+ const selectedSet = new Set(value);
153
153
  const toggleOption = (0, _react().useCallback)(option => {
154
154
  if (disabled || option.disabled) return;
155
155
  const active = selectedSet.has(option.value);
@@ -40,13 +40,13 @@ const ShareSheetOptionItem = ({
40
40
  tokens,
41
41
  onSelect
42
42
  }) => {
43
- const optionWidthStyle = (0, _react().useMemo)(() => ({
43
+ const optionWidthStyle = {
44
44
  width: `${100 / columns}%`
45
- }), [columns]);
46
- const iconStyle = (0, _react().useMemo)(() => ({
45
+ };
46
+ const iconStyle = {
47
47
  width: tokens.sizing.icon,
48
48
  height: tokens.sizing.icon
49
- }), [tokens.sizing.icon]);
49
+ };
50
50
  const press = (0, _hooks.useAriaPress)({
51
51
  onPress: () => onSelect(option, index),
52
52
  extraProps: {
@@ -57,21 +57,26 @@ const ShareSheetOptionItem = ({
57
57
  return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
58
58
  style: [styles.option, optionWidthStyle]
59
59
  }, press.interactionProps), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
60
- style: [styles.icon, iconStyle]
60
+ style: [styles.icon, iconStyle, {
61
+ marginHorizontal: tokens.spacing.iconMarginHorizontal
62
+ }]
61
63
  }, option.icon), (0, _validate.isValidNode)(option.name) ? (0, _validate.isText)(option.name) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
62
64
  style: [styles.optionText, {
63
65
  color: tokens.colors.option,
64
- fontSize: tokens.typography.option
66
+ fontSize: tokens.typography.option,
67
+ paddingHorizontal: tokens.spacing.optionTextPaddingHorizontal
65
68
  }]
66
69
  }, option.name) : option.name : null, (0, _validate.isValidNode)(option.description) ? (0, _validate.isText)(option.description) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
67
70
  style: [styles.optionDesc, {
68
71
  color: tokens.colors.optionDesc,
69
72
  marginTop: tokens.spacing.gap,
70
- fontSize: tokens.typography.optionDesc
73
+ fontSize: tokens.typography.optionDesc,
74
+ paddingHorizontal: tokens.spacing.optionDescPaddingHorizontal
71
75
  }]
72
76
  }, option.description) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
73
77
  style: [styles.optionDescNode, {
74
- marginTop: tokens.spacing.gap
78
+ marginTop: tokens.spacing.gap,
79
+ paddingHorizontal: tokens.spacing.optionDescPaddingHorizontal
75
80
  }]
76
81
  }, option.description) : null);
77
82
  };
@@ -93,11 +98,14 @@ const ShareSheetCancel = ({
93
98
  }
94
99
  }, /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({
95
100
  style: [styles.cancel, {
96
- backgroundColor: tokens.colors.background
101
+ backgroundColor: tokens.colors.background,
102
+ paddingVertical: tokens.spacing.cancelPaddingVertical,
103
+ marginTop: tokens.spacing.cancelMarginTop
97
104
  }]
98
105
  }, cancelPress.interactionProps), (0, _validate.isText)(cancelText) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
99
106
  style: [styles.cancelText, {
100
- color: tokens.colors.option
107
+ color: tokens.colors.option,
108
+ fontSize: tokens.typography.cancel
101
109
  }]
102
110
  }, cancelText) : cancelText));
103
111
  };
@@ -125,8 +133,8 @@ const ShareSheet = props => {
125
133
  ...popupProps
126
134
  } = props;
127
135
  const tokens = (0, _tokens.useShareSheetTokens)(tokensOverride);
128
- const groups = (0, _react().useMemo)(() => normalizeOptions(options), [options]);
129
- const resolvedColumns = (0, _react().useMemo)(() => (0, _validate.isFiniteNumber)(columns) ? Math.max(1, Math.floor(columns)) : 4, [columns]);
136
+ const groups = normalizeOptions(options);
137
+ const resolvedColumns = (0, _validate.isFiniteNumber)(columns) ? Math.max(1, Math.floor(columns)) : 4;
130
138
  const hasTitle = (0, _validate.isValidNode)(title);
131
139
  const hasDescription = (0, _validate.isValidNode)(description);
132
140
  const hasCancelText = (0, _validate.isValidNode)(cancelText);
@@ -140,14 +148,14 @@ const ShareSheet = props => {
140
148
  if (closeOnSelect) close();
141
149
  }, [close, closeOnSelect, onSelect]);
142
150
  const onPopupClose = (0, _react().useCallback)(() => close(true), [close]);
143
- const wrapperStyle = (0, _react().useMemo)(() => [styles.wrapper, {
151
+ const wrapperStyle = [styles.wrapper, {
144
152
  backgroundColor: tokens.colors.background
145
- }], [tokens.colors.background]);
146
- const groupRowStyle = (0, _react().useMemo)(() => [styles.optionsRow, {
153
+ }];
154
+ const groupRowStyle = [styles.optionsRow, {
147
155
  paddingLeft: tokens.spacing.gap,
148
156
  paddingVertical: 12
149
- }], [tokens.spacing.gap]);
150
- const groupNodes = (0, _react().useMemo)(() => {
157
+ }];
158
+ const groupNodes = (() => {
151
159
  if (!groups.length) return null;
152
160
  let globalIndex = 0;
153
161
  return groups.map((group, groupIndex) => /*#__PURE__*/_react().default.createElement(_reactNative().View, {
@@ -172,27 +180,34 @@ const ShareSheet = props => {
172
180
  onSelect: handleSelect
173
181
  });
174
182
  }))));
175
- }, [groupRowStyle, groups, handleSelect, resolvedColumns, tokens, tokens.colors.border, tokens.spacing.horizontal]);
176
- const headerNode = (0, _react().useMemo)(() => {
177
- if (!hasTitle && !hasDescription) return null;
178
- return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
179
- style: styles.header
180
- }, hasTitle ? (0, _validate.isText)(title) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
181
- style: [styles.title, {
182
- color: tokens.colors.title,
183
- fontSize: tokens.typography.title
184
- }]
185
- }, title) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
186
- style: styles.node
187
- }, title) : null, hasDescription ? (0, _validate.isText)(description) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
188
- style: [styles.description, {
189
- color: tokens.colors.description,
190
- fontSize: tokens.typography.description
191
- }]
192
- }, description) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
193
- style: styles.node
194
- }, description) : null);
195
- }, [description, hasDescription, hasTitle, title, tokens.colors.description, tokens.colors.title, tokens.typography.description, tokens.typography.title]);
183
+ })();
184
+ const headerNode = !hasTitle && !hasDescription ? null : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
185
+ style: [styles.header, {
186
+ paddingTop: tokens.spacing.headerPaddingTop,
187
+ paddingHorizontal: tokens.spacing.headerPaddingHorizontal,
188
+ paddingBottom: tokens.spacing.headerPaddingBottom
189
+ }]
190
+ }, hasTitle ? (0, _validate.isText)(title) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
191
+ style: [styles.title, {
192
+ color: tokens.colors.title,
193
+ fontSize: tokens.typography.title,
194
+ marginTop: tokens.spacing.titleMarginTop
195
+ }]
196
+ }, title) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
197
+ style: [styles.node, {
198
+ marginTop: tokens.spacing.nodeMarginTop
199
+ }]
200
+ }, title) : null, hasDescription ? (0, _validate.isText)(description) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
201
+ style: [styles.description, {
202
+ color: tokens.colors.description,
203
+ fontSize: tokens.typography.description,
204
+ marginTop: tokens.spacing.descriptionMarginTop
205
+ }]
206
+ }, description) : /*#__PURE__*/_react().default.createElement(_reactNative().View, {
207
+ style: [styles.node, {
208
+ marginTop: tokens.spacing.nodeMarginTop
209
+ }]
210
+ }, description) : null);
196
211
  return /*#__PURE__*/_react().default.createElement(_popup.default, _extends({}, popupProps, {
197
212
  visible: visible,
198
213
  placement: "bottom",
@@ -201,7 +216,9 @@ const ShareSheet = props => {
201
216
  overlay: overlay,
202
217
  lockScroll: lockScroll,
203
218
  onClose: onPopupClose,
204
- style: [styles.popupOverride, popupStyle]
219
+ style: [styles.popupOverride, {
220
+ padding: tokens.spacing.popupPadding
221
+ }, popupStyle]
205
222
  }), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
206
223
  style: wrapperStyle
207
224
  }, headerNode, groupNodes, children, hasCancelText ? /*#__PURE__*/_react().default.createElement(ShareSheetCancel, {
@@ -211,30 +228,22 @@ const ShareSheet = props => {
211
228
  }) : null));
212
229
  };
213
230
  const styles = _reactNative().StyleSheet.create({
214
- popupOverride: {
215
- padding: 0
216
- },
231
+ popupOverride: {},
217
232
  wrapper: {
218
233
  width: '100%'
219
234
  },
220
235
  header: {
221
- paddingTop: 8,
222
- paddingHorizontal: 16,
223
- paddingBottom: 12,
224
236
  alignItems: 'center'
225
237
  },
226
238
  title: {
227
239
  fontWeight: 'normal',
228
- textAlign: 'center',
229
- marginTop: 4
240
+ textAlign: 'center'
230
241
  },
231
242
  description: {
232
- textAlign: 'center',
233
- marginTop: 4
243
+ textAlign: 'center'
234
244
  },
235
245
  node: {
236
- alignItems: 'center',
237
- marginTop: 4
246
+ alignItems: 'center'
238
247
  },
239
248
  optionsRow: {
240
249
  flexDirection: 'row',
@@ -246,29 +255,22 @@ const styles = _reactNative().StyleSheet.create({
246
255
  },
247
256
  icon: {
248
257
  alignItems: 'center',
249
- justifyContent: 'center',
250
- marginHorizontal: 12
258
+ justifyContent: 'center'
251
259
  },
252
260
  optionText: {
253
261
  fontWeight: '500',
254
- textAlign: 'center',
255
- paddingHorizontal: 4
262
+ textAlign: 'center'
256
263
  },
257
264
  optionDesc: {
258
- textAlign: 'center',
259
- paddingHorizontal: 16
265
+ textAlign: 'center'
260
266
  },
261
267
  optionDescNode: {
262
- alignItems: 'center',
263
- paddingHorizontal: 16
268
+ alignItems: 'center'
264
269
  },
265
270
  cancel: {
266
- paddingVertical: 14,
267
- marginTop: 8,
268
271
  alignItems: 'center'
269
272
  },
270
273
  cancelText: {
271
- fontSize: 16,
272
274
  fontWeight: '500'
273
275
  }
274
276
  });
@@ -24,7 +24,19 @@ const createTokens = foundations => {
24
24
  spacing: {
25
25
  horizontal: spacing.md,
26
26
  vertical: spacing.sm,
27
- gap: spacing.xs
27
+ gap: spacing.xs,
28
+ popupPadding: 0,
29
+ headerPaddingTop: spacing.sm,
30
+ headerPaddingHorizontal: spacing.lg,
31
+ headerPaddingBottom: spacing.md,
32
+ titleMarginTop: spacing.xs,
33
+ descriptionMarginTop: spacing.xs,
34
+ nodeMarginTop: spacing.xs,
35
+ iconMarginHorizontal: spacing.md,
36
+ optionTextPaddingHorizontal: spacing.xs,
37
+ optionDescPaddingHorizontal: spacing.lg,
38
+ cancelPaddingVertical: 14,
39
+ cancelMarginTop: spacing.sm
28
40
  },
29
41
  sizing: {
30
42
  icon: 48
@@ -33,7 +45,8 @@ const createTokens = foundations => {
33
45
  title: fontSize.md,
34
46
  description: fontSize.xs,
35
47
  option: fontSize.xs,
36
- optionDesc: fontSize.xxs
48
+ optionDesc: fontSize.xxs,
49
+ cancel: fontSize.md
37
50
  }
38
51
  };
39
52
  };