@seakoi/native-ui 1.2.0 → 1.3.0

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 (178) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/commonjs/components/base/index.js +33 -11
  3. package/dist/commonjs/components/base/input/base-input.js +4 -2
  4. package/dist/commonjs/components/base/overflow/all-mode-overflow.js +49 -0
  5. package/dist/commonjs/components/base/overflow/fixed-count-overflow.js +70 -0
  6. package/dist/commonjs/components/base/overflow/index.js +16 -0
  7. package/dist/commonjs/components/base/overflow/overflow.js +72 -0
  8. package/dist/commonjs/components/base/overflow/responsive-overflow.js +280 -0
  9. package/dist/commonjs/components/base/overflow/style/index.js +39 -0
  10. package/dist/commonjs/components/base/overflow/types.js +5 -0
  11. package/dist/commonjs/components/base/picker/picker-content.js +16 -12
  12. package/dist/commonjs/components/base/picker/picker-field.js +9 -7
  13. package/dist/commonjs/components/base/picker/picker.js +6 -1
  14. package/dist/commonjs/components/base/picker/style/index.js +7 -1
  15. package/dist/commonjs/components/base/portal/portal-host.js +5 -3
  16. package/dist/commonjs/components/base/select/hooks/use-select-actions.js +155 -0
  17. package/dist/commonjs/components/base/select/hooks/use-select-options.js +169 -0
  18. package/dist/commonjs/components/base/select/hooks/use-selector.js +104 -0
  19. package/dist/commonjs/components/base/select/index.js +16 -0
  20. package/dist/commonjs/components/base/select/select-multiple-content.js +182 -0
  21. package/dist/commonjs/components/base/select/select-popup.js +233 -0
  22. package/dist/commonjs/components/base/select/select-single-content.js +100 -0
  23. package/dist/commonjs/components/base/select/select-suffix.js +67 -0
  24. package/dist/commonjs/components/base/select/select.js +285 -0
  25. package/dist/commonjs/components/base/select/style/index.js +40 -0
  26. package/dist/commonjs/components/base/select/style/select-multiple-content-styles.js +46 -0
  27. package/dist/commonjs/components/base/select/style/select-popup-styles.js +67 -0
  28. package/dist/commonjs/components/base/select/style/select-single-content-styles.js +28 -0
  29. package/dist/commonjs/components/base/select/style/select-styles.js +46 -0
  30. package/dist/commonjs/components/base/select/style/select-suffix-styles.js +21 -0
  31. package/dist/commonjs/components/base/select/types.js +5 -0
  32. package/dist/commonjs/components/base/tabs/style/index.js +37 -0
  33. package/dist/commonjs/components/base/tabs/tabs.js +90 -45
  34. package/dist/commonjs/native-provider/native-provider.js +5 -5
  35. package/dist/commonjs/shared/utils/index.js +11 -0
  36. package/dist/commonjs/shared/utils/object.js +39 -0
  37. package/dist/module/components/base/index.js +2 -0
  38. package/dist/module/components/base/input/base-input.js +4 -2
  39. package/dist/module/components/base/overflow/all-mode-overflow.js +43 -0
  40. package/dist/module/components/base/overflow/fixed-count-overflow.js +64 -0
  41. package/dist/module/components/base/overflow/index.js +3 -0
  42. package/dist/module/components/base/overflow/overflow.js +66 -0
  43. package/dist/module/components/base/overflow/responsive-overflow.js +274 -0
  44. package/dist/module/components/base/overflow/style/index.js +36 -0
  45. package/dist/module/components/base/overflow/types.js +3 -0
  46. package/dist/module/components/base/picker/picker-content.js +16 -12
  47. package/dist/module/components/base/picker/picker-field.js +9 -7
  48. package/dist/module/components/base/picker/picker.js +6 -1
  49. package/dist/module/components/base/picker/style/index.js +6 -0
  50. package/dist/module/components/base/portal/portal-host.js +4 -3
  51. package/dist/module/components/base/select/hooks/use-select-actions.js +151 -0
  52. package/dist/module/components/base/select/hooks/use-select-options.js +162 -0
  53. package/dist/module/components/base/select/hooks/use-selector.js +100 -0
  54. package/dist/module/components/base/select/index.js +3 -0
  55. package/dist/module/components/base/select/select-multiple-content.js +176 -0
  56. package/dist/module/components/base/select/select-popup.js +227 -0
  57. package/dist/module/components/base/select/select-single-content.js +94 -0
  58. package/dist/module/components/base/select/select-suffix.js +61 -0
  59. package/dist/module/components/base/select/select.js +279 -0
  60. package/dist/module/components/base/select/style/index.js +7 -0
  61. package/dist/module/components/base/select/style/select-multiple-content-styles.js +43 -0
  62. package/dist/module/components/base/select/style/select-popup-styles.js +64 -0
  63. package/dist/module/components/base/select/style/select-single-content-styles.js +25 -0
  64. package/dist/module/components/base/select/style/select-styles.js +43 -0
  65. package/dist/module/components/base/select/style/select-suffix-styles.js +18 -0
  66. package/dist/module/components/base/select/types.js +3 -0
  67. package/dist/module/components/base/tabs/style/index.js +33 -0
  68. package/dist/module/components/base/tabs/tabs.js +92 -47
  69. package/dist/module/native-provider/native-provider.js +5 -5
  70. package/dist/module/shared/utils/index.js +2 -1
  71. package/dist/module/shared/utils/object.js +35 -0
  72. package/dist/typescript/components/base/index.d.ts +2 -0
  73. package/dist/typescript/components/base/index.d.ts.map +1 -1
  74. package/dist/typescript/components/base/input/base-input.d.ts.map +1 -1
  75. package/dist/typescript/components/base/overflow/all-mode-overflow.d.ts +11 -0
  76. package/dist/typescript/components/base/overflow/all-mode-overflow.d.ts.map +1 -0
  77. package/dist/typescript/components/base/overflow/fixed-count-overflow.d.ts +11 -0
  78. package/dist/typescript/components/base/overflow/fixed-count-overflow.d.ts.map +1 -0
  79. package/dist/typescript/components/base/overflow/index.d.ts +3 -0
  80. package/dist/typescript/components/base/overflow/index.d.ts.map +1 -0
  81. package/dist/typescript/components/base/overflow/overflow.d.ts +13 -0
  82. package/dist/typescript/components/base/overflow/overflow.d.ts.map +1 -0
  83. package/dist/typescript/components/base/overflow/responsive-overflow.d.ts +12 -0
  84. package/dist/typescript/components/base/overflow/responsive-overflow.d.ts.map +1 -0
  85. package/dist/typescript/components/base/overflow/style/index.d.ts +31 -0
  86. package/dist/typescript/components/base/overflow/style/index.d.ts.map +1 -0
  87. package/dist/typescript/components/base/overflow/types.d.ts +77 -0
  88. package/dist/typescript/components/base/overflow/types.d.ts.map +1 -0
  89. package/dist/typescript/components/base/picker/picker-content.d.ts +12 -0
  90. package/dist/typescript/components/base/picker/picker-content.d.ts.map +1 -1
  91. package/dist/typescript/components/base/picker/picker-field.d.ts.map +1 -1
  92. package/dist/typescript/components/base/picker/picker.d.ts +9 -0
  93. package/dist/typescript/components/base/picker/picker.d.ts.map +1 -1
  94. package/dist/typescript/components/base/picker/style/index.d.ts +6 -0
  95. package/dist/typescript/components/base/picker/style/index.d.ts.map +1 -1
  96. package/dist/typescript/components/base/portal/portal-host.d.ts +1 -0
  97. package/dist/typescript/components/base/portal/portal-host.d.ts.map +1 -1
  98. package/dist/typescript/components/base/portal/types.d.ts +2 -0
  99. package/dist/typescript/components/base/portal/types.d.ts.map +1 -1
  100. package/dist/typescript/components/base/select/hooks/use-select-actions.d.ts +144 -0
  101. package/dist/typescript/components/base/select/hooks/use-select-actions.d.ts.map +1 -0
  102. package/dist/typescript/components/base/select/hooks/use-select-options.d.ts +91 -0
  103. package/dist/typescript/components/base/select/hooks/use-select-options.d.ts.map +1 -0
  104. package/dist/typescript/components/base/select/hooks/use-selector.d.ts +90 -0
  105. package/dist/typescript/components/base/select/hooks/use-selector.d.ts.map +1 -0
  106. package/dist/typescript/components/base/select/index.d.ts +3 -0
  107. package/dist/typescript/components/base/select/index.d.ts.map +1 -0
  108. package/dist/typescript/components/base/select/select-multiple-content.d.ts +51 -0
  109. package/dist/typescript/components/base/select/select-multiple-content.d.ts.map +1 -0
  110. package/dist/typescript/components/base/select/select-popup.d.ts +107 -0
  111. package/dist/typescript/components/base/select/select-popup.d.ts.map +1 -0
  112. package/dist/typescript/components/base/select/select-single-content.d.ts +48 -0
  113. package/dist/typescript/components/base/select/select-single-content.d.ts.map +1 -0
  114. package/dist/typescript/components/base/select/select-suffix.d.ts +43 -0
  115. package/dist/typescript/components/base/select/select-suffix.d.ts.map +1 -0
  116. package/dist/typescript/components/base/select/select.d.ts +40 -0
  117. package/dist/typescript/components/base/select/select.d.ts.map +1 -0
  118. package/dist/typescript/components/base/select/style/index.d.ts +6 -0
  119. package/dist/typescript/components/base/select/style/index.d.ts.map +1 -0
  120. package/dist/typescript/components/base/select/style/select-multiple-content-styles.d.ts +40 -0
  121. package/dist/typescript/components/base/select/style/select-multiple-content-styles.d.ts.map +1 -0
  122. package/dist/typescript/components/base/select/style/select-popup-styles.d.ts +61 -0
  123. package/dist/typescript/components/base/select/style/select-popup-styles.d.ts.map +1 -0
  124. package/dist/typescript/components/base/select/style/select-single-content-styles.d.ts +22 -0
  125. package/dist/typescript/components/base/select/style/select-single-content-styles.d.ts.map +1 -0
  126. package/dist/typescript/components/base/select/style/select-styles.d.ts +40 -0
  127. package/dist/typescript/components/base/select/style/select-styles.d.ts.map +1 -0
  128. package/dist/typescript/components/base/select/style/select-suffix-styles.d.ts +15 -0
  129. package/dist/typescript/components/base/select/style/select-suffix-styles.d.ts.map +1 -0
  130. package/dist/typescript/components/base/select/types.d.ts +206 -0
  131. package/dist/typescript/components/base/select/types.d.ts.map +1 -0
  132. package/dist/typescript/components/base/tabs/style/index.d.ts +29 -0
  133. package/dist/typescript/components/base/tabs/style/index.d.ts.map +1 -0
  134. package/dist/typescript/components/base/tabs/tabs.d.ts +26 -5
  135. package/dist/typescript/components/base/tabs/tabs.d.ts.map +1 -1
  136. package/dist/typescript/native-provider/native-provider.d.ts +2 -0
  137. package/dist/typescript/native-provider/native-provider.d.ts.map +1 -1
  138. package/dist/typescript/shared/utils/index.d.ts +1 -0
  139. package/dist/typescript/shared/utils/index.d.ts.map +1 -1
  140. package/dist/typescript/shared/utils/object.d.ts +21 -0
  141. package/dist/typescript/shared/utils/object.d.ts.map +1 -0
  142. package/package.json +1 -1
  143. package/src/components/base/index.ts +2 -0
  144. package/src/components/base/input/base-input.tsx +4 -2
  145. package/src/components/base/overflow/all-mode-overflow.tsx +49 -0
  146. package/src/components/base/overflow/fixed-count-overflow.tsx +71 -0
  147. package/src/components/base/overflow/index.ts +2 -0
  148. package/src/components/base/overflow/overflow.tsx +60 -0
  149. package/src/components/base/overflow/responsive-overflow.tsx +349 -0
  150. package/src/components/base/overflow/style/index.ts +32 -0
  151. package/src/components/base/overflow/types.ts +75 -0
  152. package/src/components/base/picker/picker-content.tsx +24 -9
  153. package/src/components/base/picker/picker-field.tsx +19 -13
  154. package/src/components/base/picker/picker.tsx +10 -1
  155. package/src/components/base/picker/style/index.ts +4 -0
  156. package/src/components/base/portal/portal-host.tsx +13 -3
  157. package/src/components/base/portal/types.ts +2 -0
  158. package/src/components/base/select/hooks/use-select-actions.ts +263 -0
  159. package/src/components/base/select/hooks/use-select-options.ts +250 -0
  160. package/src/components/base/select/hooks/use-selector.ts +155 -0
  161. package/src/components/base/select/index.ts +2 -0
  162. package/src/components/base/select/select-multiple-content.tsx +292 -0
  163. package/src/components/base/select/select-popup.tsx +384 -0
  164. package/src/components/base/select/select-single-content.tsx +127 -0
  165. package/src/components/base/select/select-suffix.tsx +100 -0
  166. package/src/components/base/select/select.tsx +302 -0
  167. package/src/components/base/select/style/index.ts +5 -0
  168. package/src/components/base/select/style/select-multiple-content-styles.ts +41 -0
  169. package/src/components/base/select/style/select-popup-styles.ts +62 -0
  170. package/src/components/base/select/style/select-single-content-styles.ts +23 -0
  171. package/src/components/base/select/style/select-styles.ts +41 -0
  172. package/src/components/base/select/style/select-suffix-styles.ts +16 -0
  173. package/src/components/base/select/types.ts +261 -0
  174. package/src/components/base/tabs/style/index.ts +32 -0
  175. package/src/components/base/tabs/tabs.tsx +146 -55
  176. package/src/native-provider/native-provider.tsx +4 -4
  177. package/src/shared/utils/index.ts +1 -0
  178. package/src/shared/utils/object.ts +37 -0
@@ -4,16 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Tabs = void 0;
7
+ var _ahooks = require("ahooks");
7
8
  var _react = require("react");
8
9
  var _reactNative = require("react-native");
9
10
  var _index = require("./../index.js");
10
11
  var _index2 = require("../../../native-provider/index.js");
12
+ var _index3 = require("./style/index.js");
11
13
  var _jsxRuntime = require("react/jsx-runtime");
12
14
  const Tabs = ({
13
15
  tabs,
14
- onChange
16
+ equalWidth = false,
17
+ variant = 'underline',
18
+ ...restProps
15
19
  }) => {
16
- const styles = useStyles();
20
+ const [activeValue, setActiveValue] = (0, _ahooks.useControllableValue)(restProps, {
21
+ trigger: 'onChange',
22
+ defaultValue: restProps.defaultValue ?? tabs[0]?.value
23
+ });
24
+ const styles = (0, _index3.useTabsStyles)();
17
25
  const theme = (0, _index2.useTheme)();
18
26
  const tabNum = tabs.length;
19
27
  const scrollViewWidthRef = (0, _react.useRef)(0);
@@ -41,27 +49,21 @@ const Tabs = ({
41
49
  };
42
50
  initIndicator();
43
51
  };
44
- const normalizedTabs = tabs.map(tab => {
45
- if (typeof tab === 'string') {
46
- return {
47
- label: tab,
48
- value: tab
49
- };
50
- }
51
- });
52
52
  const navigateTo = index => {
53
53
  const targetLayout = layouts.current[index];
54
54
  const left = targetLayout.tab.x + (targetLayout.tab.width - targetLayout.text.width) / 2;
55
- const width = targetLayout.text.width;
56
- _reactNative.Animated.parallel([_reactNative.Animated.timing(animatedIndicatorLeft.current, {
57
- toValue: left,
58
- useNativeDriver: false,
59
- duration: 300
60
- }), _reactNative.Animated.timing(animatedIndicatorWidth.current, {
61
- toValue: width,
62
- useNativeDriver: false,
63
- duration: 300
64
- })]).start();
55
+ if (variant === 'underline') {
56
+ const width = targetLayout.text.width;
57
+ _reactNative.Animated.parallel([_reactNative.Animated.timing(animatedIndicatorLeft.current, {
58
+ toValue: left,
59
+ useNativeDriver: false,
60
+ duration: 300
61
+ }), _reactNative.Animated.timing(animatedIndicatorWidth.current, {
62
+ toValue: width,
63
+ useNativeDriver: false,
64
+ duration: 300
65
+ })]).start();
66
+ }
65
67
  const hh = scrollViewWidthRef.current / 2;
66
68
  scrollViewRef.current?.scrollTo({
67
69
  x: targetLayout.tab.x + targetLayout.tab.width / 2 - hh,
@@ -69,10 +71,10 @@ const Tabs = ({
69
71
  });
70
72
  };
71
73
  const genOnPress = (v, index) => {
72
- onChange?.(v);
74
+ setActiveValue?.(v.value);
73
75
  navigateTo(index);
74
76
  };
75
- const initIndicator = (0, _react.useCallback)(() => {
77
+ const initIndicator = (0, _ahooks.useMemoizedFn)(() => {
76
78
  const layoutItems = layouts.current.filter(item => item.tab && item.text);
77
79
  if (layoutItems.length === layouts.current.length) {
78
80
  setState(s => ({
@@ -80,7 +82,7 @@ const Tabs = ({
80
82
  layoutFinish: true
81
83
  }));
82
84
  }
83
- }, []);
85
+ });
84
86
  const indicatorJSX = (0, _react.useMemo)(() => {
85
87
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
86
88
  style: {
@@ -93,22 +95,72 @@ const Tabs = ({
93
95
  }
94
96
  });
95
97
  }, [theme]);
96
- const tabsJSX = normalizedTabs.map((item, index) => {
98
+ const renderTab = (0, _ahooks.useMemoizedFn)((tab, index) => {
99
+ const isActive = activeValue === tab.value;
100
+ const badgeCount = tab.badge !== undefined ? typeof tab.badge === 'number' ? tab.badge : undefined : undefined;
101
+ if (variant === 'label') {
102
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
103
+ onLayout: genOnLayoutTab(index),
104
+ style: [{
105
+ paddingVertical: 10,
106
+ zIndex: tabNum - index
107
+ }, equalWidth && {
108
+ flex: 1
109
+ }],
110
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Badge, {
111
+ count: badgeCount,
112
+ visible: tab.badge !== undefined,
113
+ size: "small",
114
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
115
+ activeOpacity: 0.7,
116
+ onPress: () => genOnPress(tab, index),
117
+ style: [styles.labelTab, isActive && styles.labelTabActive, equalWidth && {
118
+ alignSelf: 'stretch',
119
+ justifyContent: 'center',
120
+ alignItems: 'center'
121
+ }],
122
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
123
+ onLayout: genOnLayoutText(index),
124
+ style: [styles.labelText, isActive && styles.labelTextActive],
125
+ size: 14,
126
+ children: tab.label
127
+ })
128
+ })
129
+ })
130
+ }, tab.value);
131
+ }
97
132
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
98
- style: styles.tabItem,
99
- onPress: () => genOnPress(item, index),
133
+ style: [styles.tabItem, {
134
+ zIndex: tabNum - index
135
+ }, equalWidth && {
136
+ flex: 1,
137
+ justifyContent: 'center',
138
+ alignItems: 'center'
139
+ }],
140
+ onPress: () => genOnPress(tab, index),
100
141
  onLayout: genOnLayoutTab(index),
101
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
102
- onLayout: genOnLayoutText(index),
103
- children: item?.label
142
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Badge, {
143
+ count: badgeCount,
144
+ visible: tab.badge !== undefined,
145
+ size: "small",
146
+ offset: [-4, -4],
147
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Text, {
148
+ color: isActive ? theme.palette.fontGray1 : theme.palette.fontGray2,
149
+ font: isActive ? 'semiBold' : 'regular',
150
+ onLayout: genOnLayoutText(index),
151
+ size: 14,
152
+ children: tab?.label
153
+ })
104
154
  })
105
- }, item?.value);
155
+ }, tab?.value);
106
156
  });
107
157
  (0, _react.useEffect)(() => {
108
158
  if (state.layoutFinish) {
109
- navigateTo(0);
159
+ const index = tabs.findIndex(item => item.value === activeValue);
160
+ navigateTo(index === -1 ? 0 : index);
110
161
  }
111
- }, [state.layoutFinish]);
162
+ // eslint-disable-next-line react-hooks/exhaustive-deps
163
+ }, [state.layoutFinish, activeValue]);
112
164
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
113
165
  style: styles.container,
114
166
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
@@ -116,22 +168,15 @@ const Tabs = ({
116
168
  horizontal: true,
117
169
  showsHorizontalScrollIndicator: false,
118
170
  onLayout: onLayoutScrollView,
171
+ scrollEnabled: !equalWidth,
119
172
  contentContainerStyle: {
120
173
  alignContent: 'center',
121
- columnGap: 16
174
+ columnGap: 8,
175
+ flexGrow: equalWidth ? 1 : 0,
176
+ paddingHorizontal: 16
122
177
  },
123
- children: [tabsJSX, indicatorJSX]
178
+ children: [tabs.map(renderTab), indicatorJSX]
124
179
  })
125
180
  });
126
181
  };
127
- exports.Tabs = Tabs;
128
- const useStyles = (0, _index2.createThemedStyles)(() => {
129
- return {
130
- container: {
131
- paddingHorizontal: 16
132
- },
133
- tabItem: {
134
- paddingVertical: 16
135
- }
136
- };
137
- });
182
+ exports.Tabs = Tabs;
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.NativeProvider = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
8
  var _index = require("../components/base/index.js");
10
9
  var _index2 = require("../shared/theme/index.js");
11
10
  var _index3 = require("./contexts/index.js");
@@ -19,9 +18,9 @@ const NativeProvider = ({
19
18
  children,
20
19
  navigators,
21
20
  errorBoundary,
22
- request = null
21
+ request = null,
22
+ portalHostProps
23
23
  }) => {
24
- const isNative = _reactNative.Platform.OS !== 'web';
25
24
  const themeContextValue = (0, _react.useMemo)(() => (0, _index2.createTheme)(theme), [theme]);
26
25
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_safeAreaCompactProvider.SafeAreaCompactProvider, {
27
26
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index3.ConfigContext, {
@@ -34,9 +33,10 @@ const NativeProvider = ({
34
33
  value: themeContextValue,
35
34
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_errorBoundary.ErrorBoundary, {
36
35
  ...errorBoundary,
37
- children: isNative ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Portal.Host, {
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.Portal.Host, {
37
+ ...portalHostProps,
38
38
  children: children
39
- }) : children
39
+ })
40
40
  })
41
41
  })
42
42
  })
@@ -24,4 +24,15 @@ Object.keys(_error).forEach(function (key) {
24
24
  return _error[key];
25
25
  }
26
26
  });
27
+ });
28
+ var _object = require("./object.js");
29
+ Object.keys(_object).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _object[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _object[key];
36
+ }
37
+ });
27
38
  });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shallowEqual = void 0;
7
+ var _lodashEs = require("lodash-es");
8
+ /**
9
+ * 浅比较两个对象是否相等
10
+ *
11
+ * 仅比较对象的第一层属性,使用严格相等(===)进行比较。
12
+ * 不会递归比较嵌套对象或数组的内容。
13
+ *
14
+ * @param a - 第一个对象
15
+ * @param b - 第二个对象
16
+ * @returns 如果两个对象的所有第一层属性都相等则返回 true,否则返回 false。如果 a/b 有一个非对象,则直接比较二者
17
+ *
18
+ * @example
19
+ * shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true
20
+ * shallowEqual({ a: 1 }, { a: 1, b: 2 }); // false
21
+ * shallowEqual({ a: { x: 1 } }, { a: { x: 1 } }); // false
22
+ * shallowEqual(null, null); // true
23
+ * shallowEqual(null, undefined); // false
24
+ * shallowEqual(1, 1); // true
25
+ * shallowEqual(1, '1'); // false
26
+ */
27
+ const shallowEqual = (a, b) => {
28
+ if ((0, _lodashEs.isNil)(a) || (0, _lodashEs.isNil)(b)) {
29
+ return a === b;
30
+ }
31
+ if (typeof a !== 'object' || typeof b !== 'object') {
32
+ return a === b;
33
+ }
34
+ const aKeys = Object.keys(a);
35
+ const bKeys = Object.keys(b);
36
+ if (aKeys.length !== bKeys.length) return false;
37
+ return aKeys.every(key => a[key] === b[key]);
38
+ };
39
+ exports.shallowEqual = shallowEqual;
@@ -24,12 +24,14 @@ export * from "./link/index.js";
24
24
  export * from "./loading/index.js";
25
25
  export * from "./modal/index.js";
26
26
  export * from "./nav-bar/index.js";
27
+ export * from "./overflow/index.js";
27
28
  export * from "./picker/index.js";
28
29
  export * from "./picker-backup/index.js";
29
30
  export * from "./picker-view/index.js";
30
31
  export * from "./portal/index.js";
31
32
  export * from "./radio/index.js";
32
33
  export * from "./result/index.js";
34
+ export * from "./select/index.js";
33
35
  export * from "./surface/index.js";
34
36
  export * from "./switch/index.js";
35
37
  export * from "./tabs/index.js";
@@ -126,7 +126,9 @@ export const BaseInput = ({
126
126
  if (!elementState.current.pointerDown) {
127
127
  props.onBlur?.(event);
128
128
  setInputIsFocused(false);
129
- setInputValue(inputValue?.trimEnd());
129
+ if (inputValue && inputValue?.trimEnd() !== inputValue) {
130
+ setInputValue(inputValue?.trimEnd());
131
+ }
130
132
  } else {
131
133
  inputRef.current?.focus();
132
134
  }
@@ -134,7 +136,7 @@ export const BaseInput = ({
134
136
  pointerDown: false
135
137
  };
136
138
  }
137
- }), !!hasSuffixNode && /*#__PURE__*/_jsxs(Flex, {
139
+ }), hasSuffixNode && /*#__PURE__*/_jsxs(Flex, {
138
140
  align: "center",
139
141
  gap: theme.spacing.sm,
140
142
  children: [!!props.allowClear && /*#__PURE__*/_jsx(Animated.View, {
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect } from 'react';
4
+ import { View } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ /**
7
+ * 全部显示模式组件
8
+ */
9
+ export const AllModeOverflow = ({
10
+ data,
11
+ renderItem,
12
+ prefix,
13
+ suffix,
14
+ style,
15
+ prefixStyle,
16
+ itemStyle,
17
+ suffixStyle,
18
+ onVisibleCountChange,
19
+ styles,
20
+ getKey
21
+ }) => {
22
+ useEffect(() => {
23
+ onVisibleCountChange?.(data.length);
24
+ }, [data.length, onVisibleCountChange]);
25
+ return /*#__PURE__*/_jsxs(View, {
26
+ style: [styles.container, style],
27
+ children: [prefix && /*#__PURE__*/_jsx(View, {
28
+ style: [styles.item, prefixStyle],
29
+ children: prefix
30
+ }), data.map((item, index) => {
31
+ const key = getKey(item, index);
32
+ return /*#__PURE__*/_jsx(View, {
33
+ style: [styles.item, itemStyle],
34
+ children: renderItem(item, {
35
+ index
36
+ })
37
+ }, key);
38
+ }), suffix && /*#__PURE__*/_jsx(View, {
39
+ style: [styles.item, suffixStyle],
40
+ children: suffix
41
+ })]
42
+ });
43
+ };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ import React, { useCallback, useEffect } from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
6
+ /**
7
+ * 固定数量模式组件
8
+ */
9
+ export const FixedCountOverflow = ({
10
+ data,
11
+ renderItem,
12
+ renderRest,
13
+ maxCount,
14
+ prefix,
15
+ suffix,
16
+ style,
17
+ prefixStyle,
18
+ itemStyle,
19
+ suffixStyle,
20
+ restStyle,
21
+ onVisibleCountChange,
22
+ styles,
23
+ getKey
24
+ }) => {
25
+ const visibleCount = Math.min(data.length, maxCount);
26
+ const showRest = data.length > maxCount;
27
+ const omittedData = data.slice(maxCount);
28
+ useEffect(() => {
29
+ onVisibleCountChange?.(visibleCount);
30
+ }, [visibleCount, onVisibleCountChange]);
31
+ const renderRestContent = useCallback(() => {
32
+ if (typeof renderRest === 'function') {
33
+ return renderRest(omittedData);
34
+ }
35
+ if (renderRest) {
36
+ return renderRest;
37
+ }
38
+ return /*#__PURE__*/_jsxs(Text, {
39
+ style: [styles.rest],
40
+ children: ["+", omittedData.length, "..."]
41
+ });
42
+ }, [renderRest, omittedData, styles.rest]);
43
+ return /*#__PURE__*/_jsxs(View, {
44
+ style: [styles.container, style],
45
+ children: [prefix && /*#__PURE__*/_jsx(View, {
46
+ style: [styles.item, prefixStyle],
47
+ children: prefix
48
+ }), data.slice(0, visibleCount).map((item, index) => {
49
+ const key = getKey(item, index);
50
+ return /*#__PURE__*/_jsx(View, {
51
+ style: [styles.item, itemStyle],
52
+ children: renderItem(item, {
53
+ index
54
+ })
55
+ }, key);
56
+ }), showRest && /*#__PURE__*/_jsx(View, {
57
+ style: [styles.item, restStyle],
58
+ children: renderRestContent()
59
+ }), suffix && /*#__PURE__*/_jsx(View, {
60
+ style: [styles.item, suffixStyle],
61
+ children: suffix
62
+ })]
63
+ });
64
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ export * from "./overflow.js";
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ import { isNumber } from 'lodash-es';
4
+ import React, { useCallback } from 'react';
5
+ import { AllModeOverflow } from "./all-mode-overflow.js";
6
+ import { FixedCountOverflow } from "./fixed-count-overflow.js";
7
+ import { ResponsiveOverflow } from "./responsive-overflow.js";
8
+ import { useOverflowStyles } from "./style/index.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ /**
11
+ * Overflow 组件
12
+ *
13
+ * 利用 onLayout 在渲染前触发的特性,实现单次渲染的溢出处理组件
14
+ * 固定数量模式直接渲染,响应式模式通过预先计算确定最终显示状态
15
+ *
16
+ * @param props - 组件属性
17
+ * @returns React 元素
18
+ */
19
+ export const Overflow = props => {
20
+ const {
21
+ maxCount = 'responsive',
22
+ itemKey
23
+ } = props;
24
+ const styles = useOverflowStyles({
25
+ maxCount
26
+ });
27
+
28
+ /**
29
+ * 获取元素唯一标识
30
+ */
31
+ const getKey = useCallback((item, index) => {
32
+ if (typeof itemKey === 'function') {
33
+ return itemKey(item, index);
34
+ }
35
+ if (itemKey && typeof item === 'object' && item !== null && typeof itemKey === 'string') {
36
+ const value = item[itemKey];
37
+ return typeof value === 'string' || typeof value === 'number' ? value : index;
38
+ }
39
+ return index;
40
+ }, [itemKey]);
41
+
42
+ // 固定数量模式
43
+ if (isNumber(maxCount)) {
44
+ return /*#__PURE__*/_jsx(FixedCountOverflow, {
45
+ ...props,
46
+ styles: styles,
47
+ getKey: getKey
48
+ });
49
+ }
50
+
51
+ // 全部显示模式
52
+ if (maxCount === 'all') {
53
+ return /*#__PURE__*/_jsx(AllModeOverflow, {
54
+ ...props,
55
+ styles: styles,
56
+ getKey: getKey
57
+ });
58
+ }
59
+
60
+ // 响应式模式
61
+ return /*#__PURE__*/_jsx(ResponsiveOverflow, {
62
+ ...props,
63
+ styles: styles,
64
+ getKey: getKey
65
+ });
66
+ };