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, useMemo } from 'react';
2
+ import React, { useCallback } from 'react';
3
3
  import { Pressable, StyleSheet, Text, View } from 'react-native';
4
4
  import { useAriaPress } from '../../hooks';
5
5
  import { createHairlineView } from '../../utils/hairline';
@@ -20,13 +20,13 @@ const ShareSheetOptionItem = ({
20
20
  tokens,
21
21
  onSelect
22
22
  }) => {
23
- const optionWidthStyle = useMemo(() => ({
23
+ const optionWidthStyle = {
24
24
  width: `${100 / columns}%`
25
- }), [columns]);
26
- const iconStyle = useMemo(() => ({
25
+ };
26
+ const iconStyle = {
27
27
  width: tokens.sizing.icon,
28
28
  height: tokens.sizing.icon
29
- }), [tokens.sizing.icon]);
29
+ };
30
30
  const press = useAriaPress({
31
31
  onPress: () => onSelect(option, index),
32
32
  extraProps: {
@@ -37,21 +37,26 @@ const ShareSheetOptionItem = ({
37
37
  return /*#__PURE__*/React.createElement(Pressable, _extends({
38
38
  style: [styles.option, optionWidthStyle]
39
39
  }, press.interactionProps), /*#__PURE__*/React.createElement(View, {
40
- style: [styles.icon, iconStyle]
40
+ style: [styles.icon, iconStyle, {
41
+ marginHorizontal: tokens.spacing.iconMarginHorizontal
42
+ }]
41
43
  }, option.icon), isValidNode(option.name) ? isText(option.name) ? /*#__PURE__*/React.createElement(Text, {
42
44
  style: [styles.optionText, {
43
45
  color: tokens.colors.option,
44
- fontSize: tokens.typography.option
46
+ fontSize: tokens.typography.option,
47
+ paddingHorizontal: tokens.spacing.optionTextPaddingHorizontal
45
48
  }]
46
49
  }, option.name) : option.name : null, isValidNode(option.description) ? isText(option.description) ? /*#__PURE__*/React.createElement(Text, {
47
50
  style: [styles.optionDesc, {
48
51
  color: tokens.colors.optionDesc,
49
52
  marginTop: tokens.spacing.gap,
50
- fontSize: tokens.typography.optionDesc
53
+ fontSize: tokens.typography.optionDesc,
54
+ paddingHorizontal: tokens.spacing.optionDescPaddingHorizontal
51
55
  }]
52
56
  }, option.description) : /*#__PURE__*/React.createElement(View, {
53
57
  style: [styles.optionDescNode, {
54
- marginTop: tokens.spacing.gap
58
+ marginTop: tokens.spacing.gap,
59
+ paddingHorizontal: tokens.spacing.optionDescPaddingHorizontal
55
60
  }]
56
61
  }, option.description) : null);
57
62
  };
@@ -73,11 +78,14 @@ const ShareSheetCancel = ({
73
78
  }
74
79
  }, /*#__PURE__*/React.createElement(Pressable, _extends({
75
80
  style: [styles.cancel, {
76
- backgroundColor: tokens.colors.background
81
+ backgroundColor: tokens.colors.background,
82
+ paddingVertical: tokens.spacing.cancelPaddingVertical,
83
+ marginTop: tokens.spacing.cancelMarginTop
77
84
  }]
78
85
  }, cancelPress.interactionProps), isText(cancelText) ? /*#__PURE__*/React.createElement(Text, {
79
86
  style: [styles.cancelText, {
80
- color: tokens.colors.option
87
+ color: tokens.colors.option,
88
+ fontSize: tokens.typography.cancel
81
89
  }]
82
90
  }, cancelText) : cancelText));
83
91
  };
@@ -105,8 +113,8 @@ const ShareSheet = props => {
105
113
  ...popupProps
106
114
  } = props;
107
115
  const tokens = useShareSheetTokens(tokensOverride);
108
- const groups = useMemo(() => normalizeOptions(options), [options]);
109
- const resolvedColumns = useMemo(() => isFiniteNumber(columns) ? Math.max(1, Math.floor(columns)) : 4, [columns]);
116
+ const groups = normalizeOptions(options);
117
+ const resolvedColumns = isFiniteNumber(columns) ? Math.max(1, Math.floor(columns)) : 4;
110
118
  const hasTitle = isValidNode(title);
111
119
  const hasDescription = isValidNode(description);
112
120
  const hasCancelText = isValidNode(cancelText);
@@ -120,14 +128,14 @@ const ShareSheet = props => {
120
128
  if (closeOnSelect) close();
121
129
  }, [close, closeOnSelect, onSelect]);
122
130
  const onPopupClose = useCallback(() => close(true), [close]);
123
- const wrapperStyle = useMemo(() => [styles.wrapper, {
131
+ const wrapperStyle = [styles.wrapper, {
124
132
  backgroundColor: tokens.colors.background
125
- }], [tokens.colors.background]);
126
- const groupRowStyle = useMemo(() => [styles.optionsRow, {
133
+ }];
134
+ const groupRowStyle = [styles.optionsRow, {
127
135
  paddingLeft: tokens.spacing.gap,
128
136
  paddingVertical: 12
129
- }], [tokens.spacing.gap]);
130
- const groupNodes = useMemo(() => {
137
+ }];
138
+ const groupNodes = (() => {
131
139
  if (!groups.length) return null;
132
140
  let globalIndex = 0;
133
141
  return groups.map((group, groupIndex) => /*#__PURE__*/React.createElement(View, {
@@ -152,27 +160,34 @@ const ShareSheet = props => {
152
160
  onSelect: handleSelect
153
161
  });
154
162
  }))));
155
- }, [groupRowStyle, groups, handleSelect, resolvedColumns, tokens, tokens.colors.border, tokens.spacing.horizontal]);
156
- const headerNode = useMemo(() => {
157
- if (!hasTitle && !hasDescription) return null;
158
- return /*#__PURE__*/React.createElement(View, {
159
- style: styles.header
160
- }, hasTitle ? isText(title) ? /*#__PURE__*/React.createElement(Text, {
161
- style: [styles.title, {
162
- color: tokens.colors.title,
163
- fontSize: tokens.typography.title
164
- }]
165
- }, title) : /*#__PURE__*/React.createElement(View, {
166
- style: styles.node
167
- }, title) : null, hasDescription ? isText(description) ? /*#__PURE__*/React.createElement(Text, {
168
- style: [styles.description, {
169
- color: tokens.colors.description,
170
- fontSize: tokens.typography.description
171
- }]
172
- }, description) : /*#__PURE__*/React.createElement(View, {
173
- style: styles.node
174
- }, description) : null);
175
- }, [description, hasDescription, hasTitle, title, tokens.colors.description, tokens.colors.title, tokens.typography.description, tokens.typography.title]);
163
+ })();
164
+ const headerNode = !hasTitle && !hasDescription ? null : /*#__PURE__*/React.createElement(View, {
165
+ style: [styles.header, {
166
+ paddingTop: tokens.spacing.headerPaddingTop,
167
+ paddingHorizontal: tokens.spacing.headerPaddingHorizontal,
168
+ paddingBottom: tokens.spacing.headerPaddingBottom
169
+ }]
170
+ }, hasTitle ? isText(title) ? /*#__PURE__*/React.createElement(Text, {
171
+ style: [styles.title, {
172
+ color: tokens.colors.title,
173
+ fontSize: tokens.typography.title,
174
+ marginTop: tokens.spacing.titleMarginTop
175
+ }]
176
+ }, title) : /*#__PURE__*/React.createElement(View, {
177
+ style: [styles.node, {
178
+ marginTop: tokens.spacing.nodeMarginTop
179
+ }]
180
+ }, title) : null, hasDescription ? isText(description) ? /*#__PURE__*/React.createElement(Text, {
181
+ style: [styles.description, {
182
+ color: tokens.colors.description,
183
+ fontSize: tokens.typography.description,
184
+ marginTop: tokens.spacing.descriptionMarginTop
185
+ }]
186
+ }, description) : /*#__PURE__*/React.createElement(View, {
187
+ style: [styles.node, {
188
+ marginTop: tokens.spacing.nodeMarginTop
189
+ }]
190
+ }, description) : null);
176
191
  return /*#__PURE__*/React.createElement(Popup, _extends({}, popupProps, {
177
192
  visible: visible,
178
193
  placement: "bottom",
@@ -181,7 +196,9 @@ const ShareSheet = props => {
181
196
  overlay: overlay,
182
197
  lockScroll: lockScroll,
183
198
  onClose: onPopupClose,
184
- style: [styles.popupOverride, popupStyle]
199
+ style: [styles.popupOverride, {
200
+ padding: tokens.spacing.popupPadding
201
+ }, popupStyle]
185
202
  }), /*#__PURE__*/React.createElement(View, {
186
203
  style: wrapperStyle
187
204
  }, headerNode, groupNodes, children, hasCancelText ? /*#__PURE__*/React.createElement(ShareSheetCancel, {
@@ -191,30 +208,22 @@ const ShareSheet = props => {
191
208
  }) : null));
192
209
  };
193
210
  const styles = StyleSheet.create({
194
- popupOverride: {
195
- padding: 0
196
- },
211
+ popupOverride: {},
197
212
  wrapper: {
198
213
  width: '100%'
199
214
  },
200
215
  header: {
201
- paddingTop: 8,
202
- paddingHorizontal: 16,
203
- paddingBottom: 12,
204
216
  alignItems: 'center'
205
217
  },
206
218
  title: {
207
219
  fontWeight: 'normal',
208
- textAlign: 'center',
209
- marginTop: 4
220
+ textAlign: 'center'
210
221
  },
211
222
  description: {
212
- textAlign: 'center',
213
- marginTop: 4
223
+ textAlign: 'center'
214
224
  },
215
225
  node: {
216
- alignItems: 'center',
217
- marginTop: 4
226
+ alignItems: 'center'
218
227
  },
219
228
  optionsRow: {
220
229
  flexDirection: 'row',
@@ -226,29 +235,22 @@ const styles = StyleSheet.create({
226
235
  },
227
236
  icon: {
228
237
  alignItems: 'center',
229
- justifyContent: 'center',
230
- marginHorizontal: 12
238
+ justifyContent: 'center'
231
239
  },
232
240
  optionText: {
233
241
  fontWeight: '500',
234
- textAlign: 'center',
235
- paddingHorizontal: 4
242
+ textAlign: 'center'
236
243
  },
237
244
  optionDesc: {
238
- textAlign: 'center',
239
- paddingHorizontal: 16
245
+ textAlign: 'center'
240
246
  },
241
247
  optionDescNode: {
242
- alignItems: 'center',
243
- paddingHorizontal: 16
248
+ alignItems: 'center'
244
249
  },
245
250
  cancel: {
246
- paddingVertical: 14,
247
- marginTop: 8,
248
251
  alignItems: 'center'
249
252
  },
250
253
  cancelText: {
251
- fontSize: 16,
252
254
  fontWeight: '500'
253
255
  }
254
256
  });
@@ -18,7 +18,19 @@ const createTokens = foundations => {
18
18
  spacing: {
19
19
  horizontal: spacing.md,
20
20
  vertical: spacing.sm,
21
- gap: spacing.xs
21
+ gap: spacing.xs,
22
+ popupPadding: 0,
23
+ headerPaddingTop: spacing.sm,
24
+ headerPaddingHorizontal: spacing.lg,
25
+ headerPaddingBottom: spacing.md,
26
+ titleMarginTop: spacing.xs,
27
+ descriptionMarginTop: spacing.xs,
28
+ nodeMarginTop: spacing.xs,
29
+ iconMarginHorizontal: spacing.md,
30
+ optionTextPaddingHorizontal: spacing.xs,
31
+ optionDescPaddingHorizontal: spacing.lg,
32
+ cancelPaddingVertical: 14,
33
+ cancelMarginTop: spacing.sm
22
34
  },
23
35
  sizing: {
24
36
  icon: 48
@@ -27,7 +39,8 @@ const createTokens = foundations => {
27
39
  title: fontSize.md,
28
40
  description: fontSize.xs,
29
41
  option: fontSize.xs,
30
- optionDesc: fontSize.xxs
42
+ optionDesc: fontSize.xxs,
43
+ cancel: fontSize.md
31
44
  }
32
45
  };
33
46
  };
@@ -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 { Text, View } from 'react-native';
4
4
  import { mergeTokensOverride } from '../../design-system';
5
5
  import { useControllableValue } from '../../hooks';
@@ -15,7 +15,7 @@ const SidebarBase = props => {
15
15
  ...rest
16
16
  } = props;
17
17
  const tokens = useSidebarTokens(tokensOverride);
18
- const items = useMemo(() => {
18
+ const items = (() => {
19
19
  const out = [];
20
20
  const list = React.Children.toArray(children);
21
21
  for (let i = 0; i < list.length; i++) {
@@ -27,7 +27,7 @@ const SidebarBase = props => {
27
27
  });
28
28
  }
29
29
  return out;
30
- }, [children]);
30
+ })();
31
31
  const firstIndex = items[0]?.index ?? 0;
32
32
  const [activeIndex, setActiveIndex] = useControllableValue(props, {
33
33
  defaultValue: firstIndex,
@@ -42,24 +42,20 @@ const SidebarBase = props => {
42
42
  break;
43
43
  }
44
44
  }
45
- const contextValue = useMemo(() => ({
45
+ const contextValue = {
46
46
  activeIndex: currentIndex,
47
47
  onSelect: setActiveIndex
48
- }), [currentIndex, setActiveIndex]);
49
- const clonedItems = useMemo(() => {
50
- return items.map(item => {
51
- const key = item.element.key ?? item.index;
52
- const merged = mergeTokensOverride(tokensOverride, item.element.props.tokensOverride);
53
- return /*#__PURE__*/React.cloneElement(item.element, {
54
- key,
55
- index: item.index,
56
- tokensOverride: merged
57
- });
48
+ };
49
+ const clonedItems = items.map(item => {
50
+ const key = item.element.key ?? item.index;
51
+ const merged = mergeTokensOverride(tokensOverride, item.element.props.tokensOverride);
52
+ return /*#__PURE__*/React.cloneElement(item.element, {
53
+ key,
54
+ index: item.index,
55
+ tokensOverride: merged
58
56
  });
59
- }, [items, tokensOverride]);
60
- const activeItem = useMemo(() => {
61
- return items.find(item => item.index === currentIndex)?.element;
62
- }, [currentIndex, items]);
57
+ });
58
+ const activeItem = items.find(item => item.index === currentIndex)?.element;
63
59
  const activeContentStyle = activeItem?.props?.contentStyle;
64
60
  const activeContent = activeItem?.props?.children;
65
61
  const activeContentNode = activeContent == null || activeContent === false ? null : isText(activeContent) ? /*#__PURE__*/React.createElement(Text, null, activeContent) : activeContent;
@@ -25,9 +25,6 @@ const SidebarItem = props => {
25
25
  const tokens = useSidebarTokens(tokensOverride);
26
26
  const context = useSidebarContext();
27
27
  if (!context) {
28
- if (typeof __DEV__ !== 'undefined' && __DEV__) {
29
- console.warn('[SidebarItem] 需要作为 Sidebar 子节点使用。');
30
- }
31
28
  return null;
32
29
  }
33
30
  const disabled = disabledProp ?? tokens.defaults.disabled;
@@ -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, { useEffect, useMemo, useRef } from 'react';
2
+ import React, { useEffect, useRef } from 'react';
3
3
  import { Animated, StyleSheet, View } from 'react-native';
4
4
  import { nativeDriverEnabled } from '../../platform';
5
5
  import { isFiniteNumber, isString } from '../../utils';
@@ -39,18 +39,18 @@ const Skeleton = /*#__PURE__*/React.forwardRef((props, ref) => {
39
39
  const row = rowProp ?? tokens.defaults.rowCount;
40
40
  const rowWidth = rowWidthProp ?? tokens.defaults.rowWidth;
41
41
  const round = roundProp ?? false;
42
- const rows = useMemo(() => isFiniteNumber(row) ? Math.max(0, Math.floor(row)) : 0, [row]);
43
- const rowWidths = useMemo(() => {
42
+ const rows = isFiniteNumber(row) ? Math.max(0, Math.floor(row)) : 0;
43
+ const rowWidths = (() => {
44
44
  const widths = resolveSeries(rows, rowWidth, tokens.defaults.rowWidth);
45
45
  if (!Array.isArray(rowWidth) && rows > 1 && (props.rowWidth === undefined || isString(props.rowWidth) && props.rowWidth.trim() === '100%')) {
46
46
  widths[rows - 1] = tokens.defaults.lastRowWidth;
47
47
  }
48
48
  return widths;
49
- }, [props.rowWidth, rowWidth, rows, tokens.defaults.lastRowWidth, tokens.defaults.rowWidth]);
50
- const rowHeights = useMemo(() => resolveSeries(rows, rowHeight, tokens.defaults.rowHeight), [rowHeight, rows, tokens.defaults.rowHeight]);
51
- const titleHeight = useMemo(() => rowHeights[0] ?? tokens.defaults.rowHeight, [rowHeights, tokens.defaults.rowHeight]);
52
- const resolvedAvatarSize = useMemo(() => normalize(avatarSize, tokens.defaults.avatarSize), [avatarSize, tokens.defaults.avatarSize]);
53
- const resolvedTitleWidth = useMemo(() => normalize(titleWidth, tokens.defaults.titleWidth), [titleWidth, tokens.defaults.titleWidth]);
49
+ })();
50
+ const rowHeights = resolveSeries(rows, rowHeight, tokens.defaults.rowHeight);
51
+ const titleHeight = rowHeights[0] ?? tokens.defaults.rowHeight;
52
+ const resolvedAvatarSize = normalize(avatarSize, tokens.defaults.avatarSize);
53
+ const resolvedTitleWidth = normalize(titleWidth, tokens.defaults.titleWidth);
54
54
  const animated = useRef(new Animated.Value(0)).current;
55
55
  useEffect(() => {
56
56
  if (!loading || !animate || tokens.animation.duration <= 0) {
@@ -69,56 +69,44 @@ const Skeleton = /*#__PURE__*/React.forwardRef((props, ref) => {
69
69
  loop.start();
70
70
  return () => loop.stop();
71
71
  }, [animate, animated, loading, tokens.animation.duration]);
72
- const animatedStyle = useMemo(() => {
73
- if (!loading || !animate) return undefined;
74
- return {
75
- opacity: animated.interpolate({
76
- inputRange: [0, 1],
77
- outputRange: [tokens.animation.minOpacity, tokens.animation.maxOpacity]
78
- })
79
- };
80
- }, [animate, animated, loading, tokens.animation.maxOpacity, tokens.animation.minOpacity]);
81
- const containerStyles = useMemo(() => [styles.container, {
72
+ const animatedStyle = !loading || !animate ? undefined : {
73
+ opacity: animated.interpolate({
74
+ inputRange: [0, 1],
75
+ outputRange: [tokens.animation.minOpacity, tokens.animation.maxOpacity]
76
+ })
77
+ };
78
+ const containerStyles = [styles.container, {
82
79
  gap: tokens.spacing.containerGap
83
- }, style], [style, tokens.spacing.containerGap]);
84
- const avatarNode = useMemo(() => {
85
- if (!avatar) return null;
86
- return /*#__PURE__*/React.createElement(Animated.View, {
87
- style: [{
88
- width: resolvedAvatarSize,
89
- height: resolvedAvatarSize,
90
- borderRadius: avatarShape === 'round' ? 999 : tokens.radius,
91
- backgroundColor: tokens.colors.block
92
- }, animatedStyle]
93
- });
94
- }, [animatedStyle, avatar, avatarShape, resolvedAvatarSize, tokens.colors.block, tokens.radius]);
95
- const titleNode = useMemo(() => {
96
- if (!title) return null;
97
- return /*#__PURE__*/React.createElement(Animated.View, {
98
- style: [{
99
- width: resolvedTitleWidth,
100
- height: titleHeight,
101
- backgroundColor: tokens.colors.block,
102
- borderRadius: round ? tokens.radius : 0
103
- }, animatedStyle]
104
- });
105
- }, [animatedStyle, round, resolvedTitleWidth, title, titleHeight, tokens.colors.block, tokens.radius]);
106
- const rowNodes = useMemo(() => {
107
- if (rows <= 0) return null;
108
- return /*#__PURE__*/React.createElement(View, {
109
- style: styles.rows
110
- }, rowWidths.map((width, index) => /*#__PURE__*/React.createElement(Animated.View, {
111
- key: index,
112
- testID: `rv-skeleton-row-${index}`,
113
- style: [{
114
- width: width,
115
- height: rowHeights[index],
116
- marginTop: index === 0 && !title ? 0 : tokens.spacing.rowGap,
117
- backgroundColor: tokens.colors.block,
118
- borderRadius: round ? tokens.radius : 0
119
- }, animatedStyle]
120
- })));
121
- }, [animatedStyle, rowHeights, rowWidths, round, rows, title, tokens.colors.block, tokens.radius, tokens.spacing.rowGap]);
80
+ }, style];
81
+ const avatarNode = !avatar ? null : /*#__PURE__*/React.createElement(Animated.View, {
82
+ style: [{
83
+ width: resolvedAvatarSize,
84
+ height: resolvedAvatarSize,
85
+ borderRadius: avatarShape === 'round' ? 999 : tokens.radius,
86
+ backgroundColor: tokens.colors.block
87
+ }, animatedStyle]
88
+ });
89
+ const titleNode = !title ? null : /*#__PURE__*/React.createElement(Animated.View, {
90
+ style: [{
91
+ width: resolvedTitleWidth,
92
+ height: titleHeight,
93
+ backgroundColor: tokens.colors.block,
94
+ borderRadius: round ? tokens.radius : 0
95
+ }, animatedStyle]
96
+ });
97
+ const rowNodes = rows <= 0 ? null : /*#__PURE__*/React.createElement(View, {
98
+ style: styles.rows
99
+ }, rowWidths.map((width, index) => /*#__PURE__*/React.createElement(Animated.View, {
100
+ key: index,
101
+ testID: `rv-skeleton-row-${index}`,
102
+ style: [{
103
+ width: width,
104
+ height: rowHeights[index],
105
+ marginTop: index === 0 && !title ? 0 : tokens.spacing.rowGap,
106
+ backgroundColor: tokens.colors.block,
107
+ borderRadius: round ? tokens.radius : 0
108
+ }, animatedStyle]
109
+ })));
122
110
  if (!loading) {
123
111
  return /*#__PURE__*/React.createElement(View, _extends({
124
112
  ref: ref,
@@ -2,7 +2,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
2
2
  import { useSlider, useSliderThumb } from '@react-native-aria/slider';
3
3
  import { isRTL } from '@react-native-aria/utils';
4
4
  import { useSliderState } from '@react-stately/slider';
5
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
6
6
  import { Platform, Pressable, StyleSheet, View } from 'react-native';
7
7
  import { useSliderTokens } from './tokens';
8
8
  import { parseNumber } from '../../utils/number';
@@ -43,38 +43,35 @@ const ThumbNode = /*#__PURE__*/React.memo(({
43
43
  }, state, ariaReverse);
44
44
  const rawThumbViewProps = thumbProps;
45
45
  const handlers = enhanceHandlers(rawThumbViewProps, index) ?? rawThumbViewProps ?? {};
46
- const translate = useMemo(() => -size / 2, [size]);
47
- const thumbStyle = useMemo(() => {
48
- const next = {
49
- width: size,
50
- height: size,
51
- borderRadius: size / 2,
52
- borderColor: activeColor,
53
- transform: [{
54
- translateX: translate
55
- }, {
56
- translateY: translate
57
- }]
58
- };
59
- if (orientation === 'vertical') {
60
- next.top = `${visualPercent}%`;
61
- next.left = '50%';
62
- } else {
63
- next.left = `${visualPercent}%`;
64
- next.top = '50%';
65
- }
66
- if (!content) {
67
- next.backgroundColor = thumbBackgroundColor;
68
- next.elevation = thumbElevation;
69
- }
70
- return next;
71
- }, [activeColor, content, orientation, size, thumbBackgroundColor, thumbElevation, translate, visualPercent]);
72
- const indicatorStyle = useMemo(() => ({
46
+ const translate = -size / 2;
47
+ const thumbStyle = {
48
+ width: size,
49
+ height: size,
50
+ borderRadius: size / 2,
51
+ borderColor: activeColor,
52
+ transform: [{
53
+ translateX: translate
54
+ }, {
55
+ translateY: translate
56
+ }]
57
+ };
58
+ if (orientation === 'vertical') {
59
+ thumbStyle.top = `${visualPercent}%`;
60
+ thumbStyle.left = '50%';
61
+ } else {
62
+ thumbStyle.left = `${visualPercent}%`;
63
+ thumbStyle.top = '50%';
64
+ }
65
+ if (!content) {
66
+ thumbStyle.backgroundColor = thumbBackgroundColor;
67
+ thumbStyle.elevation = thumbElevation;
68
+ }
69
+ const indicatorStyle = {
73
70
  width: indicatorSize,
74
71
  height: indicatorSize,
75
72
  borderRadius: indicatorSize / 2,
76
73
  backgroundColor: indicatorColor
77
- }), [indicatorColor, indicatorSize]);
74
+ };
78
75
  const accessibilityProps = createAccessibilityProps(inputProps);
79
76
  return /*#__PURE__*/React.createElement(View, _extends({}, handlers, accessibilityProps, {
80
77
  pointerEvents: isDisabled ? 'none' : 'auto',
@@ -131,7 +128,7 @@ export const Slider = props => {
131
128
  const resolvedActiveColor = activeColor ?? tokens.colors.active;
132
129
  const resolvedInactiveColor = inactiveColor ?? tokens.colors.inactive;
133
130
  const scope = Math.max(resolvedMax - resolvedMin, 0.00001);
134
- const normalized = useMemo(() => normalizeValue(valueProp, range, resolvedMin, resolvedMax), [valueProp, range, resolvedMin, resolvedMax]);
131
+ const normalized = normalizeValue(valueProp, range, resolvedMin, resolvedMax);
135
132
  const isControlled = valueProp !== undefined;
136
133
  const formatOutput = useCallback(values => toSliderValue(values, range, resolvedMin), [range, resolvedMin]);
137
134
  const handleStateChange = useCallback(values => {
@@ -140,7 +137,7 @@ export const Slider = props => {
140
137
  const handleStateChangeEnd = useCallback(values => {
141
138
  onChangeAfter?.(formatOutput(values));
142
139
  }, [formatOutput, onChangeAfter]);
143
- const sliderStateOptions = useMemo(() => ({
140
+ const sliderStateOptions = {
144
141
  minValue: resolvedMin,
145
142
  maxValue: resolvedMax,
146
143
  step: resolvedStep,
@@ -151,7 +148,7 @@ export const Slider = props => {
151
148
  defaultValue: !isControlled ? normalized : undefined,
152
149
  onChange: handleStateChange,
153
150
  onChangeEnd: handleStateChangeEnd
154
- }), [ariaDisabled, handleStateChange, handleStateChangeEnd, isControlled, normalized, orientation, resolvedMax, resolvedMin, resolvedStep]);
151
+ };
155
152
  const state = useSliderState(sliderStateOptions);
156
153
  const [trackLayout, setTrackLayout] = useState({
157
154
  width: 0,
@@ -360,9 +357,9 @@ export const Slider = props => {
360
357
  return wrapped;
361
358
  }, [onDragStart, onDragEnd]);
362
359
  const values = state.values;
363
- const thumbPercents = useMemo(() => values.map(value => ((value ?? resolvedMin) - resolvedMin) / scope * 100), [resolvedMin, scope, values]);
364
- const thumbVisualPercents = useMemo(() => thumbPercents.map(percent => orientation === 'vertical' ? reverse ? percent : 100 - percent : reverseX ? 100 - percent : percent), [orientation, reverse, reverseX, thumbPercents]);
365
- const activeRange = useMemo(() => {
360
+ const thumbPercents = values.map(value => ((value ?? resolvedMin) - resolvedMin) / scope * 100);
361
+ const thumbVisualPercents = thumbPercents.map(percent => orientation === 'vertical' ? reverse ? percent : 100 - percent : reverseX ? 100 - percent : percent);
362
+ const activeRange = (() => {
366
363
  const first = thumbVisualPercents[0] ?? 0;
367
364
  const second = thumbVisualPercents[1] ?? first;
368
365
  return range && thumbVisualPercents.length > 1 ? {
@@ -375,33 +372,30 @@ export const Slider = props => {
375
372
  offset: first,
376
373
  size: 100 - first
377
374
  };
378
- }, [orientation, range, reverse, reverseX, thumbVisualPercents]);
379
- const activeTrackStyle = useMemo(() => {
380
- const next = {
381
- backgroundColor: resolvedActiveColor,
382
- borderRadius: tokens.track.radius
383
- };
384
- if (orientation === 'vertical') {
385
- next.left = 0;
386
- next.width = '100%';
387
- next.height = `${Math.max(activeRange.size, 0)}%`;
388
- next.top = `${Math.max(activeRange.offset, 0)}%`;
389
- } else {
390
- next.top = 0;
391
- next.height = '100%';
392
- next.width = `${Math.max(activeRange.size, 0)}%`;
393
- next.left = `${Math.max(activeRange.offset, 0)}%`;
394
- }
395
- return next;
396
- }, [activeRange.offset, activeRange.size, orientation, resolvedActiveColor, tokens.track.radius]);
397
- const trackBaseStyle = useMemo(() => orientation === 'vertical' ? [styles.trackVertical, {
375
+ })();
376
+ const activeTrackStyle = {
377
+ backgroundColor: resolvedActiveColor,
378
+ borderRadius: tokens.track.radius
379
+ };
380
+ if (orientation === 'vertical') {
381
+ activeTrackStyle.left = 0;
382
+ activeTrackStyle.width = '100%';
383
+ activeTrackStyle.height = `${Math.max(activeRange.size, 0)}%`;
384
+ activeTrackStyle.top = `${Math.max(activeRange.offset, 0)}%`;
385
+ } else {
386
+ activeTrackStyle.top = 0;
387
+ activeTrackStyle.height = '100%';
388
+ activeTrackStyle.width = `${Math.max(activeRange.size, 0)}%`;
389
+ activeTrackStyle.left = `${Math.max(activeRange.offset, 0)}%`;
390
+ }
391
+ const trackBaseStyle = orientation === 'vertical' ? [styles.trackVertical, {
398
392
  width: resolvedTrackHeight,
399
393
  backgroundColor: resolvedInactiveColor,
400
394
  alignSelf: 'center'
401
395
  }] : [styles.trackHorizontal, {
402
396
  height: resolvedTrackHeight,
403
397
  backgroundColor: resolvedInactiveColor
404
- }], [orientation, resolvedInactiveColor, resolvedTrackHeight]);
398
+ }];
405
399
  const isButtonFunction = isFunction(button);
406
400
  const sharedThumb = isButtonFunction ? button({
407
401
  value: currentValue
@@ -409,21 +403,21 @@ export const Slider = props => {
409
403
  const leftThumbContent = leftButton ?? leftThumb ?? sharedThumb;
410
404
  const rightThumbContent = rightButton ?? rightThumb ?? sharedThumb;
411
405
  const resolveThumbContent = useCallback((index, total) => total > 1 ? index === 0 ? leftThumbContent : rightThumbContent : sharedThumb, [leftThumbContent, rightThumbContent, sharedThumb]);
412
- const webGestureStyle = useMemo(() => Platform.OS === 'web' ? {
406
+ const webGestureStyle = Platform.OS === 'web' ? {
413
407
  touchAction: orientation === 'horizontal' ? 'pan-y' : 'none',
414
408
  userSelect: 'none'
415
- } : undefined, [orientation]);
416
- const baseTrackPressableStyle = useMemo(() => [styles.trackPressable, orientation === 'vertical' ? styles.trackPressableVertical : null, webGestureStyle], [orientation, webGestureStyle]);
409
+ } : undefined;
410
+ const baseTrackPressableStyle = [styles.trackPressable, orientation === 'vertical' ? styles.trackPressableVertical : null, webGestureStyle];
417
411
  const trackPressableStyleFn = useCallback(pressableState => [baseTrackPressableStyle, trackAriaStyle(pressableState)], [baseTrackPressableStyle, trackAriaStyle]);
418
- const trackPressableStyle = useMemo(() => trackAriaStyle && isFunction(trackAriaStyle) ? trackPressableStyleFn : [baseTrackPressableStyle, trackAriaStyle], [baseTrackPressableStyle, trackAriaStyle, trackPressableStyleFn]);
419
- const containerStyles = useMemo(() => [styles.container, {
412
+ const trackPressableStyle = trackAriaStyle && isFunction(trackAriaStyle) ? trackPressableStyleFn : [baseTrackPressableStyle, trackAriaStyle];
413
+ const containerStyles = [styles.container, {
420
414
  paddingVertical: tokens.spacing.containerPaddingVertical
421
415
  }, orientation === 'vertical' && [styles.verticalContainer, {
422
416
  minHeight: tokens.layout.verticalMinHeight,
423
417
  width: tokens.layout.verticalWidth
424
418
  }], disabled && {
425
419
  opacity: tokens.states.disabledOpacity
426
- }, style], [disabled, orientation, style, tokens.layout.verticalMinHeight, tokens.layout.verticalWidth, tokens.spacing.containerPaddingVertical, tokens.states.disabledOpacity]);
420
+ }, style];
427
421
  return /*#__PURE__*/React.createElement(View, _extends({
428
422
  style: containerStyles,
429
423
  onLayout: containerOnLayout