react-native-system-ui 0.0.3 → 0.0.4

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 +46 -22
  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 +46 -23
  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
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Animated, Easing, Text, View } from 'react-native';
4
4
  import { Arrow } from 'react-native-system-icon';
5
5
  import { Cell } from '../cell';
@@ -72,7 +72,7 @@ export const Collapse = props => {
72
72
  }
73
73
  onChange?.(buildOutputValue(next, accordion));
74
74
  }, [accordion, activeKeys, controlled, disabled, onChange]);
75
- const contextValue = useMemo(() => ({
75
+ const contextValue = {
76
76
  activeKeys,
77
77
  toggle,
78
78
  accordion,
@@ -81,8 +81,8 @@ export const Collapse = props => {
81
81
  border,
82
82
  disabled,
83
83
  tokens
84
- }), [accordion, activeKeys, border, disabled, expandIcon, iconPosition, tokens, toggle]);
85
- const renderedChildren = useMemo(() => {
84
+ };
85
+ const renderedChildren = (() => {
86
86
  const items = React.Children.toArray(children);
87
87
  return items.map((child, index) => {
88
88
  if (! /*#__PURE__*/React.isValidElement(child)) return child;
@@ -95,7 +95,7 @@ export const Collapse = props => {
95
95
  index
96
96
  });
97
97
  });
98
- }, [children]);
98
+ })();
99
99
  return /*#__PURE__*/React.createElement(CollapseContext.Provider, {
100
100
  value: contextValue
101
101
  }, /*#__PURE__*/React.createElement(View, _extends({
@@ -172,10 +172,10 @@ const CollapsePanel = /*#__PURE__*/React.forwardRef((props, ref) => {
172
172
  } = tokens;
173
173
  const [contentHeight, setContentHeight] = useState(0);
174
174
  const animation = useRef(new Animated.Value(isActive ? 1 : 0)).current;
175
- const rotate = useMemo(() => animation.interpolate({
175
+ const rotate = animation.interpolate({
176
176
  inputRange: [0, 1],
177
177
  outputRange: ['90deg', '-90deg']
178
- }), [animation]);
178
+ });
179
179
  useEffect(() => {
180
180
  Animated.timing(animation, {
181
181
  toValue: isActive ? 1 : 0,
@@ -226,16 +226,13 @@ const CollapsePanel = /*#__PURE__*/React.forwardRef((props, ref) => {
226
226
  fill: mergedDisabled ? colors.disabled : colors.arrow
227
227
  }));
228
228
  }, [colors.arrow, colors.disabled, expandIcon, isActive, mergedDisabled, rotate]);
229
- const contentNode = useMemo(() => {
230
- if (!isText(children)) return children;
231
- return /*#__PURE__*/React.createElement(Text, {
232
- style: {
233
- color: mergedDisabled ? colors.disabled : colors.description,
234
- fontSize: typography.descriptionSize,
235
- lineHeight: Math.round(typography.descriptionSize * 1.5)
236
- }
237
- }, children);
238
- }, [children, colors.description, colors.disabled, mergedDisabled, typography.descriptionSize]);
229
+ const contentNode = !isText(children) ? children : /*#__PURE__*/React.createElement(Text, {
230
+ style: {
231
+ color: mergedDisabled ? colors.disabled : colors.description,
232
+ fontSize: typography.descriptionSize,
233
+ lineHeight: Math.round(typography.descriptionSize * 1.5)
234
+ }
235
+ }, children);
239
236
  const showItemBorder = Boolean(panelBorder);
240
237
  const showTopBorder = index > 0 && showItemBorder;
241
238
  const showHeaderBottomBorder = isActive && showItemBorder;
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo } from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { ThemeProvider } from '../../design-system/ThemeProvider';
3
3
  import { PortalHost } from '../portal';
4
4
  import { LocaleContext } from './LocaleContext';
@@ -8,7 +8,7 @@ const ConfigProviderBase = ({
8
8
  children
9
9
  }) => {
10
10
  const parentLocale = useContext(LocaleContext);
11
- const resolvedLocale = useMemo(() => locale ?? parentLocale, [locale, parentLocale]);
11
+ const resolvedLocale = locale ?? parentLocale;
12
12
  return /*#__PURE__*/React.createElement(ThemeProvider, {
13
13
  value: theme
14
14
  }, /*#__PURE__*/React.createElement(LocaleContext.Provider, {
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import Picker from '../picker';
4
4
  import { Popup } from '../popup/Popup';
5
5
  import { useControllableValue } from '../../hooks';
@@ -111,7 +111,7 @@ const DatePicker = props => {
111
111
  originColumns,
112
112
  columns,
113
113
  pickerValue
114
- } = useMemo(() => {
114
+ } = (() => {
115
115
  const getBoundary = (boundaryType, date) => {
116
116
  const boundaryDate = boundaryType === 'min' ? minDate : maxDate;
117
117
  const boundary = {
@@ -212,7 +212,7 @@ const DatePicker = props => {
212
212
  columns,
213
213
  pickerValue
214
214
  };
215
- }, [columnsOrder, currentDate, filter, formatter, maxDate, minDate, type]);
215
+ })();
216
216
  const buildDateFromValues = useCallback(values => {
217
217
  const getValue = columnType => {
218
218
  const index = originColumns.findIndex(column => column.type === columnType);
@@ -292,7 +292,7 @@ const TimePicker = props => {
292
292
  setCurrentTime(next);
293
293
  }
294
294
  }, [formatTime, value]);
295
- const [hourValues, minuteValues] = useMemo(() => {
295
+ const [hourValues, minuteValues] = (() => {
296
296
  let hours = times(maxHour - minHour + 1, index => padZero(minHour + index));
297
297
  let minutes = times(maxMinute - minMinute + 1, index => padZero(minMinute + index));
298
298
  if (filter) {
@@ -300,14 +300,14 @@ const TimePicker = props => {
300
300
  minutes = filter('minute', minutes);
301
301
  }
302
302
  return [hours, minutes];
303
- }, [filter, maxHour, maxMinute, minHour, minMinute]);
304
- const columns = useMemo(() => [hourValues.map(value => ({
303
+ })();
304
+ const columns = [hourValues.map(value => ({
305
305
  label: formatter('hour', value),
306
306
  value
307
307
  })), minuteValues.map(value => ({
308
308
  label: formatter('minute', value),
309
309
  value
310
- }))], [formatter, hourValues, minuteValues]);
310
+ }))];
311
311
  const handleChange = useCallback(values => {
312
312
  const nextHour = values[0] ?? hourValues[0];
313
313
  const nextMinute = values[1] ?? minuteValues[0];
@@ -317,7 +317,7 @@ const TimePicker = props => {
317
317
  onChange?.(next);
318
318
  }, [hourValues, minuteValues, onChange]);
319
319
  const handleConfirm = useCallback(() => onConfirm?.(timeRef.current), [onConfirm]);
320
- const pickerValue = useMemo(() => currentTime.split(':'), [currentTime]);
320
+ const pickerValue = currentTime.split(':');
321
321
  return /*#__PURE__*/React.createElement(Picker, _extends({}, pickerProps, {
322
322
  columns: columns,
323
323
  interactionMode: interactionMode,
@@ -110,8 +110,7 @@ export const Dialog = props => {
110
110
  if (!beforeClose) return true;
111
111
  try {
112
112
  return beforeClose(action);
113
- } catch (error) {
114
- if (typeof __DEV__ !== 'undefined' && __DEV__) console.error(error);
113
+ } catch {
115
114
  return true;
116
115
  }
117
116
  };
@@ -125,8 +124,7 @@ export const Dialog = props => {
125
124
  if (resolved === false) return;
126
125
  if (actionSeqRef.current !== seq) return;
127
126
  handler?.();
128
- }).catch(error => {
129
- if (typeof __DEV__ !== 'undefined' && __DEV__) console.error(error);
127
+ }).catch(() => {
130
128
  if (actionSeqRef.current !== seq) return;
131
129
  handler?.();
132
130
  });
@@ -287,7 +285,8 @@ export const Dialog = props => {
287
285
  }, rest), closeable ? /*#__PURE__*/React.createElement(Pressable, {
288
286
  style: [styles.closeIcon, {
289
287
  top: tokens.spacing.paddingTop / 2,
290
- right: tokens.spacing.paddingHorizontal / 2
288
+ right: tokens.spacing.paddingHorizontal / 2,
289
+ padding: tokens.spacing.closeIconPadding
291
290
  }],
292
291
  hitSlop: {
293
292
  top: 8,
@@ -357,7 +356,6 @@ const styles = StyleSheet.create({
357
356
  },
358
357
  closeIcon: {
359
358
  position: 'absolute',
360
- padding: 4,
361
359
  zIndex: 1
362
360
  }
363
361
  });
@@ -34,7 +34,8 @@ export const createDialogTokens = foundations => {
34
34
  titleGap: spacing.sm,
35
35
  footerGap: spacing.md,
36
36
  roundFooterPadding: spacing.md,
37
- roundFooterGap: spacing.sm
37
+ roundFooterGap: spacing.sm,
38
+ closeIconPadding: spacing.xs
38
39
  },
39
40
  sizes: {
40
41
  minWidth: 280,
@@ -53,7 +53,9 @@ const DropdownItem = /*#__PURE__*/React.forwardRef((props, ref) => {
53
53
  const panelContent = useMemo(() => {
54
54
  if (children) {
55
55
  return /*#__PURE__*/React.createElement(View, {
56
- style: [styles.customPanel, panelStyle]
56
+ style: [styles.customPanel, {
57
+ padding: tokens.spacing.customPanelPadding
58
+ }, panelStyle]
57
59
  }, children);
58
60
  }
59
61
  if (!options?.length) {
@@ -73,17 +75,21 @@ const DropdownItem = /*#__PURE__*/React.forwardRef((props, ref) => {
73
75
  if (isText(activeIcon)) {
74
76
  return /*#__PURE__*/React.createElement(Text, {
75
77
  style: [styles.indicator, {
76
- color
78
+ color,
79
+ marginLeft: tokens.spacing.indicatorMarginLeft
77
80
  }]
78
81
  }, activeIcon);
79
82
  }
80
83
  return /*#__PURE__*/React.createElement(View, {
81
- style: styles.indicator
84
+ style: [styles.indicator, {
85
+ marginLeft: tokens.spacing.indicatorMarginLeft
86
+ }]
82
87
  }, activeIcon);
83
88
  }
84
89
  return /*#__PURE__*/React.createElement(Text, {
85
90
  style: [styles.indicator, {
86
- color
91
+ color,
92
+ marginLeft: tokens.spacing.indicatorMarginLeft
87
93
  }]
88
94
  }, "\u2713");
89
95
  };
@@ -92,7 +98,9 @@ const DropdownItem = /*#__PURE__*/React.forwardRef((props, ref) => {
92
98
  if (/*#__PURE__*/React.isValidElement(optionIcon)) return optionIcon;
93
99
  if (isText(optionIcon)) {
94
100
  return /*#__PURE__*/React.createElement(Text, {
95
- style: styles.optionIconText
101
+ style: [styles.optionIconText, {
102
+ fontSize: tokens.sizing.optionFontSize
103
+ }]
96
104
  }, optionIcon);
97
105
  }
98
106
  return optionIcon;
@@ -110,30 +118,38 @@ const DropdownItem = /*#__PURE__*/React.forwardRef((props, ref) => {
110
118
  }
111
119
  };
112
120
  return /*#__PURE__*/React.createElement(View, {
113
- style: [styles.optionPanel, panelStyle]
121
+ style: [styles.optionPanel, {
122
+ paddingHorizontal: tokens.spacing.panelPaddingHorizontal
123
+ }, panelStyle]
114
124
  }, options.map(option => {
115
125
  const active = value === option.value;
116
126
  const optionText = getOptionText(option);
117
127
  const optionColor = option.disabled ? tokens.colors.disabledText : active ? activeTextColor : tokens.colors.text;
118
128
  return /*#__PURE__*/React.createElement(Pressable, {
119
129
  key: String(option.value),
120
- style: [styles.optionRow, createHairlineBorderBottom('rgba(0,0,0,0.06)')],
130
+ style: [styles.optionRow, {
131
+ paddingVertical: tokens.spacing.optionRowPaddingVertical,
132
+ paddingHorizontal: tokens.spacing.optionRowPaddingHorizontal
133
+ }, createHairlineBorderBottom('rgba(0,0,0,0.06)')],
121
134
  onPress: () => handleSelect(option),
122
135
  disabled: option.disabled,
123
136
  testID: `rv-dropdown-option-${option.value}`
124
137
  }, /*#__PURE__*/React.createElement(View, {
125
138
  style: styles.optionLeft
126
139
  }, option.icon ? /*#__PURE__*/React.createElement(View, {
127
- style: styles.optionIcon
140
+ style: [styles.optionIcon, {
141
+ marginRight: tokens.spacing.optionIconMarginRight
142
+ }]
128
143
  }, renderOptionIcon(option.icon)) : null, isText(optionText) ? /*#__PURE__*/React.createElement(Text, {
129
144
  style: [styles.optionText, {
130
- color: optionColor
145
+ color: optionColor,
146
+ fontSize: tokens.sizing.optionFontSize
131
147
  }]
132
148
  }, optionText) : /*#__PURE__*/React.createElement(View, {
133
149
  style: styles.optionTextNode
134
150
  }, optionText)), active ? renderActiveIcon() : null);
135
151
  }));
136
- }, [children, options, panelStyle, tokens, value, activeIcon, activeTextColor, closeMenu, closeOnSelect, menuValue, name, onMenuChange, triggerChange]);
152
+ }, [activeIcon, activeTextColor, children, closeMenu, closeOnSelect, menuValue, name, onMenuChange, options, panelStyle, tokens, triggerChange, value]);
137
153
  useEffect(() => {
138
154
  registerPanel(index, panelContent);
139
155
  }, [index, panelContent, registerPanel]);
@@ -175,12 +191,26 @@ const DropdownItem = /*#__PURE__*/React.forwardRef((props, ref) => {
175
191
  color: displayColor
176
192
  }];
177
193
  const arrowStyle = [styles.arrow, {
178
- borderTopColor: tokens.colors.arrow
194
+ borderTopColor: tokens.colors.arrow,
195
+ marginLeft: tokens.spacing.arrowMarginLeft,
196
+ width: tokens.sizing.arrowSize,
197
+ height: tokens.sizing.arrowSize,
198
+ borderLeftWidth: tokens.sizing.arrowBorderWidth,
199
+ borderRightWidth: tokens.sizing.arrowBorderWidth,
200
+ borderTopWidth: tokens.sizing.arrowBorderHeight,
201
+ borderLeftColor: tokens.colors.transparent,
202
+ borderRightColor: tokens.colors.transparent,
203
+ opacity: tokens.opacity.arrowInactive
179
204
  }, isActive && styles.arrowActive, isActive && {
180
- borderBottomColor: activeColor ?? tokens.colors.activeText
205
+ borderBottomColor: activeColor ?? tokens.colors.activeText,
206
+ borderBottomWidth: tokens.sizing.arrowBorderHeight,
207
+ borderTopColor: tokens.colors.transparent,
208
+ opacity: tokens.opacity.arrowActive
181
209
  }];
182
210
  return /*#__PURE__*/React.createElement(Pressable, _extends({}, rest, {
183
- style: [styles.item, barScrollable ? styles.itemScrollable : null, style],
211
+ style: [styles.item, barScrollable ? [styles.itemScrollable, {
212
+ paddingHorizontal: tokens.spacing.itemScrollablePaddingHorizontal
213
+ }] : null, style],
184
214
  onPress: handleToggle,
185
215
  accessibilityRole: "button",
186
216
  testID: `rv-dropdown-trigger-${index}`,
@@ -204,40 +234,21 @@ const styles = StyleSheet.create({
204
234
  minWidth: 0
205
235
  },
206
236
  itemScrollable: {
207
- flex: 0,
208
- paddingHorizontal: 12
237
+ flex: 0
209
238
  },
210
239
  titleNode: {
211
240
  flexShrink: 1,
212
241
  minWidth: 0
213
242
  },
214
- arrow: {
215
- marginLeft: 4,
216
- width: 6,
217
- height: 6,
218
- borderLeftWidth: 3,
219
- borderRightWidth: 3,
220
- borderTopWidth: 4,
221
- borderLeftColor: 'transparent',
222
- borderRightColor: 'transparent',
223
- opacity: 0.8
224
- },
243
+ arrow: {},
225
244
  arrowActive: {
226
- borderTopWidth: 0,
227
- borderBottomWidth: 4,
228
- borderBottomColor: 'currentColor',
229
- borderTopColor: 'transparent',
230
- opacity: 1
231
- },
232
- optionPanel: {
233
- paddingHorizontal: 0
245
+ borderTopWidth: 0
234
246
  },
247
+ optionPanel: {},
235
248
  optionRow: {
236
249
  flexDirection: 'row',
237
250
  alignItems: 'center',
238
- justifyContent: 'space-between',
239
- paddingVertical: 10,
240
- paddingHorizontal: 16
251
+ justifyContent: 'space-between'
241
252
  },
242
253
  optionLeft: {
243
254
  flex: 1,
@@ -245,24 +256,14 @@ const styles = StyleSheet.create({
245
256
  alignItems: 'center',
246
257
  minWidth: 0
247
258
  },
248
- optionIcon: {
249
- marginRight: 8
250
- },
251
- optionIconText: {
252
- fontSize: 16
253
- },
254
- optionText: {
255
- fontSize: 16
256
- },
259
+ optionIcon: {},
260
+ optionIconText: {},
261
+ optionText: {},
257
262
  optionTextNode: {
258
263
  flex: 1
259
264
  },
260
- indicator: {
261
- marginLeft: 12
262
- },
263
- customPanel: {
264
- padding: 16
265
- }
265
+ indicator: {},
266
+ customPanel: {}
266
267
  });
267
268
  DropdownItem.displayName = 'DropdownMenu.Item';
268
269
  export default DropdownItem;
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Animated, Pressable, ScrollView, StyleSheet, View, useWindowDimensions } from 'react-native';
4
4
  import { useControllableValue } from '../../hooks';
5
5
  import { measureInWindow, nativeDriverEnabled } from '../../platform';
@@ -167,7 +167,7 @@ const DropdownMenu = /*#__PURE__*/React.forwardRef((props, ref) => {
167
167
  animationRef.current?.stop();
168
168
  }, []);
169
169
  const barScrollable = threshold !== undefined && React.Children.count(children) > threshold;
170
- const contextValue = useMemo(() => ({
170
+ const contextValue = {
171
171
  activeIndex,
172
172
  registerPanel,
173
173
  toggleItem,
@@ -179,7 +179,7 @@ const DropdownMenu = /*#__PURE__*/React.forwardRef((props, ref) => {
179
179
  disabled,
180
180
  menuValue,
181
181
  onMenuChange
182
- }), [activeColor, activeIcon, activeIndex, closeMenu, direction, disabled, registerPanel, showItem, toggleItem, menuValue, onMenuChange]);
182
+ };
183
183
  const shouldRenderMask = mounted && (overlay || closeOnClickOutside);
184
184
  const shouldCloseOnMask = closeOnClickOverlay || closeOnClickOutside;
185
185
  const resolvedBarTop = barFrame?.y ?? 0;
@@ -188,29 +188,25 @@ const DropdownMenu = /*#__PURE__*/React.forwardRef((props, ref) => {
188
188
  const resolvedBarWidth = barFrame?.width ?? (barWidth || windowWidth);
189
189
  const resolvedBarBottom = resolvedBarTop + resolvedBarHeight;
190
190
  const bottomInset = Math.max(0, windowHeight - resolvedBarTop);
191
- const insetStyle = useMemo(() => direction === 'up' ? {
191
+ const insetStyle = direction === 'up' ? {
192
192
  bottom: bottomInset
193
193
  } : {
194
194
  top: resolvedBarBottom
195
- }, [bottomInset, direction, resolvedBarBottom]);
196
- const panelPositionStyle = useMemo(() => ({
195
+ };
196
+ const panelPositionStyle = {
197
197
  left: resolvedBarLeft,
198
198
  width: resolvedBarWidth
199
- }), [resolvedBarLeft, resolvedBarWidth]);
199
+ };
200
200
  const panelRadiusStyle = direction === 'up' ? styles.panelUp : styles.panelDown;
201
- const panelAnimatedStyle = useMemo(() => {
202
- const offset = 8;
203
- const translate = progress.interpolate({
204
- inputRange: [0, 1],
205
- outputRange: direction === 'up' ? [offset, 0] : [-offset, 0]
206
- });
207
- return {
208
- opacity: progress,
209
- transform: [{
210
- translateY: translate
211
- }]
212
- };
213
- }, [direction, progress]);
201
+ const panelAnimatedStyle = {
202
+ opacity: progress,
203
+ transform: [{
204
+ translateY: progress.interpolate({
205
+ inputRange: [0, 1],
206
+ outputRange: direction === 'up' ? [8, 0] : [-8, 0]
207
+ })
208
+ }]
209
+ };
214
210
  const {
215
211
  zIndex: stackZIndex
216
212
  } = useOverlayStack({
@@ -220,21 +216,21 @@ const DropdownMenu = /*#__PURE__*/React.forwardRef((props, ref) => {
220
216
  type: 'dropdown-menu'
221
217
  });
222
218
  const resolvedZIndex = stackZIndex ?? zIndex;
223
- const barChildren = useMemo(() => React.Children.map(children, (child, index) => {
219
+ const barChildren = React.Children.map(children, (child, index) => {
224
220
  if (! /*#__PURE__*/React.isValidElement(child)) return child;
225
221
  const element = child;
226
222
  return /*#__PURE__*/React.cloneElement(element, {
227
223
  index,
228
224
  barScrollable
229
225
  });
230
- }), [barScrollable, children]);
231
- const barStyle = useMemo(() => [styles.barWrapper, {
226
+ });
227
+ const barStyle = [styles.barWrapper, {
232
228
  height: tokens.sizing.barHeight,
233
229
  backgroundColor: tokens.colors.barBackground,
234
230
  paddingHorizontal: tokens.spacing.horizontal,
235
231
  zIndex: mounted ? resolvedZIndex + 1 : undefined,
236
232
  ...tokens.shadow
237
- }, createHairlineBorderBottom(tokens.colors.divider)], [mounted, resolvedZIndex, tokens.colors.barBackground, tokens.colors.divider, tokens.shadow, tokens.sizing.barHeight, tokens.spacing.horizontal]);
233
+ }, createHairlineBorderBottom(tokens.colors.divider)];
238
234
  const handleBarLayout = useCallback(event => {
239
235
  const {
240
236
  height,
@@ -16,18 +16,35 @@ const createTokens = foundations => {
16
16
  panelBackground: '#ffffff',
17
17
  mask: 'rgba(0,0,0,0.45)',
18
18
  divider: palette.default[200],
19
- barBackground: '#ffffff'
19
+ barBackground: '#ffffff',
20
+ transparent: 'transparent'
20
21
  },
21
22
  spacing: {
22
23
  horizontal: spacing.md,
23
24
  vertical: spacing.sm,
24
- titlePadding: spacing.xs
25
+ titlePadding: spacing.xs,
26
+ customPanelPadding: spacing.lg,
27
+ optionRowPaddingHorizontal: spacing.lg,
28
+ optionRowPaddingVertical: 10,
29
+ itemScrollablePaddingHorizontal: spacing.md,
30
+ arrowMarginLeft: spacing.xs,
31
+ optionIconMarginRight: spacing.sm,
32
+ indicatorMarginLeft: spacing.md,
33
+ panelPaddingHorizontal: spacing.none
25
34
  },
26
35
  sizing: {
27
36
  barHeight: 48,
28
37
  titleFontSize: 15,
29
38
  titleLineHeight: fontSize.lg * typography.lineHeightMultiplier,
30
- panelMaxHeight: 320
39
+ panelMaxHeight: 320,
40
+ optionFontSize: fontSize.md,
41
+ arrowSize: 6,
42
+ arrowBorderWidth: 3,
43
+ arrowBorderHeight: 4
44
+ },
45
+ opacity: {
46
+ arrowInactive: 0.8,
47
+ arrowActive: 1
31
48
  },
32
49
  shadow: {
33
50
  shadowColor: 'rgba(100, 101, 102, 0.12)',
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useId, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { Platform, Pressable, Text, TextInput, View } from 'react-native';
4
4
  import { Clear, QuestionO } from 'react-native-system-icon';
5
5
  import Cell from '../cell';
@@ -80,7 +80,7 @@ export const Field = /*#__PURE__*/React.forwardRef((props, ref) => {
80
80
  const clearTrigger = clearTriggerProp ?? tokens.defaults.clearTrigger;
81
81
  const rows = rowsProp ?? tokens.defaults.rows;
82
82
  const formatTrigger = formatTriggerProp ?? tokens.defaults.formatTrigger;
83
- const mergedTitleStyle = useMemo(() => [{
83
+ const mergedTitleStyle = [{
84
84
  width: labelWidth,
85
85
  minWidth: labelWidth,
86
86
  maxWidth: labelWidth,
@@ -88,7 +88,7 @@ export const Field = /*#__PURE__*/React.forwardRef((props, ref) => {
88
88
  marginRight: tokens.spacing.labelGap,
89
89
  flexShrink: 0,
90
90
  flexGrow: 0
91
- }, titleStyle], [labelWidth, titleStyle, tokens.spacing.labelGap]);
91
+ }, titleStyle];
92
92
  const resolvedSuffix = suffixProp ?? button;
93
93
  const resolvedDescription = intro ?? description;
94
94
  const resolvedPlaceholderColor = placeholderTextColor ?? (disabled ? tokens.colors.disabled : tokens.colors.placeholder);
@@ -101,10 +101,10 @@ export const Field = /*#__PURE__*/React.forwardRef((props, ref) => {
101
101
  const inputRef = useRef(null);
102
102
  const introId = useId();
103
103
  const errorId = useId();
104
- const describedBy = useMemo(() => {
104
+ const describedBy = (() => {
105
105
  const ids = [isRenderable(errorMessage) ? errorId : null, isRenderable(resolvedDescription) ? introId : null].filter(Boolean);
106
106
  return ids.length ? ids : undefined;
107
- }, [errorId, errorMessage, introId, resolvedDescription]);
107
+ })();
108
108
  const lineHeight = tokens.defaults.textareaLineHeight;
109
109
  const autoSizeConfig = autoSize && isObject(autoSize) ? autoSize : undefined;
110
110
  const minRows = !isTextarea ? 1 : autoSizeConfig && isDef(autoSizeConfig.minRows) ? Math.max(1, autoSizeConfig.minRows) : Math.max(1, rows);
@@ -378,10 +378,10 @@ export const Field = /*#__PURE__*/React.forwardRef((props, ref) => {
378
378
  }
379
379
  }, resolvedDescription);
380
380
  };
381
- const contentWrapperStyle = useMemo(() => [{
381
+ const contentWrapperStyle = [{
382
382
  width: '100%',
383
383
  justifyContent: alignMap[controlAlign]
384
- }, contentStyle], [contentStyle, controlAlign]);
384
+ }, contentStyle];
385
385
  const renderAffix = node => {
386
386
  if (isText(node)) {
387
387
  return /*#__PURE__*/React.createElement(Text, {
@@ -1,6 +1,6 @@
1
1
  import Field from './Field';
2
2
  import { CellGroup as FieldGroup } from '../cell';
3
- export { useFieldTokens } from './tokens';
4
3
  export { FieldGroup };
4
+ export { useFieldTokens } from './tokens';
5
5
  export default Field;
6
6
  export { Field };
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
2
+ import React, { useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { View } from 'react-native';
4
4
  import { isPromiseLike } from '../../utils/promise';
5
5
  import { isNumber, isString, isText } from '../../utils/validate';
@@ -226,7 +226,7 @@ const InternalForm = /*#__PURE__*/React.forwardRef((props, ref) => {
226
226
  return next;
227
227
  });
228
228
  }, [notify, onValuesChange, runFieldValidation]);
229
- const formApi = useMemo(() => ({
229
+ const formApi = {
230
230
  submit: async () => {
231
231
  try {
232
232
  const result = await validateFields();
@@ -278,12 +278,12 @@ const InternalForm = /*#__PURE__*/React.forwardRef((props, ref) => {
278
278
  },
279
279
  validateFields,
280
280
  getFieldError: name => errorsRef.current[serializeNamePath(name)] ?? []
281
- }), [notify, onFinish, onValuesChange, validateFields, runFieldValidation]);
281
+ };
282
282
  useImperativeHandle(ref, () => formApi, [formApi]);
283
283
  const getFieldError = useCallback(name => errors[serializeNamePath(name)], [errors]);
284
284
  const getFieldValue = useCallback(name => getValueByName(values, name), [values]);
285
285
  const contextValidateField = useCallback((name, trigger) => runFieldValidation(name, trigger), [runFieldValidation]);
286
- const contextValue = useMemo(() => ({
286
+ const contextValue = {
287
287
  values,
288
288
  getFieldValue,
289
289
  setFieldValue,
@@ -299,7 +299,7 @@ const InternalForm = /*#__PURE__*/React.forwardRef((props, ref) => {
299
299
  colon,
300
300
  labelWidth,
301
301
  showValidateMessage
302
- }), [values, setFieldValue, registerField, getFieldError, contextValidateField, formApi, colon, labelWidth, showValidateMessage]);
302
+ };
303
303
  return /*#__PURE__*/React.createElement(FormContext.Provider, {
304
304
  value: contextValue
305
305
  }, /*#__PURE__*/React.createElement(View, _extends({
@@ -309,11 +309,7 @@ const InternalForm = /*#__PURE__*/React.forwardRef((props, ref) => {
309
309
  InternalForm.displayName = 'Form';
310
310
  export const useWatch = (name, formRef) => {
311
311
  const context = useContext(FormContext);
312
- const names = useMemo(() => {
313
- if (name === undefined) return undefined;
314
- if (!Array.isArray(name)) return [name];
315
- return name.length && isText(name[0]) ? [name] : name;
316
- }, [name]);
312
+ const names = name === undefined ? undefined : !Array.isArray(name) ? [name] : name.length && isText(name[0]) ? [name] : name;
317
313
  const getSnapshot = useCallback(allValues => {
318
314
  const source = allValues ?? context?.getFieldsValue?.() ?? formRef?.current?.getFieldsValue?.() ?? {};
319
315
  if (!names) return source;
@@ -1,5 +1,5 @@
1
1
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useMemo } from 'react';
2
+ import React from 'react';
3
3
  import { View } from 'react-native';
4
4
  import { createHairlineView } from '../../utils';
5
5
  import { GridContext } from './GridContext';
@@ -55,7 +55,7 @@ export const Grid = props => {
55
55
  bottom: 0
56
56
  })]
57
57
  });
58
- const contextValue = useMemo(() => ({
58
+ const contextValue = {
59
59
  columnNum,
60
60
  gutter,
61
61
  border,
@@ -68,7 +68,7 @@ export const Grid = props => {
68
68
  iconColor,
69
69
  count: childArray.length,
70
70
  tokens
71
- }), [border, center, childArray.length, clickable, columnNum, direction, gutter, iconColor, iconSize, reverse, square, tokens]);
71
+ };
72
72
  return /*#__PURE__*/React.createElement(GridContext.Provider, {
73
73
  value: contextValue
74
74
  }, /*#__PURE__*/React.createElement(View, _extends({