react-native-system-ui 1.0.0 → 1.0.2

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 (210) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/components/action-sheet/ActionSheet.js +51 -53
  3. package/dist/cjs/components/area/Area.js +22 -22
  4. package/dist/cjs/components/avatar/Avatar.js +23 -23
  5. package/dist/cjs/components/badge/Badge.js +56 -61
  6. package/dist/cjs/components/button/Button.js +87 -92
  7. package/dist/cjs/components/button/ButtonGroup.js +4 -4
  8. package/dist/cjs/components/calendar/Calendar.js +28 -28
  9. package/dist/cjs/components/cascader/Cascader.js +206 -212
  10. package/dist/cjs/components/cell/Cell.js +54 -51
  11. package/dist/cjs/components/cell/CellGroup.js +26 -25
  12. package/dist/cjs/components/checkbox/Checkbox.js +1 -0
  13. package/dist/cjs/components/checkbox/CheckboxGroup.js +20 -19
  14. package/dist/cjs/components/circle/Circle.js +66 -54
  15. package/dist/cjs/components/collapse/Collapse.js +18 -18
  16. package/dist/cjs/components/config-provider/ConfigProvider.js +5 -5
  17. package/dist/cjs/components/count-down/CountDown.js +17 -17
  18. package/dist/cjs/components/datetime-picker/DatetimePicker.js +34 -35
  19. package/dist/cjs/components/dialog/Dialog.js +16 -10
  20. package/dist/cjs/components/dialog/imperative.js +8 -14
  21. package/dist/cjs/components/dialog/tokens.js +1 -0
  22. package/dist/cjs/components/divider/Divider.js +48 -51
  23. package/dist/cjs/components/empty/Empty.js +30 -25
  24. package/dist/cjs/components/error-boundary/ErrorBoundary.js +3 -2
  25. package/dist/cjs/components/flex/Flex.js +27 -27
  26. package/dist/cjs/components/flex/FlexItem.js +1 -0
  27. package/dist/cjs/components/form/Form.js +94 -93
  28. package/dist/cjs/components/form/FormItem.js +60 -54
  29. package/dist/cjs/components/form/FormList.js +35 -35
  30. package/dist/cjs/components/grid/Grid.js +48 -48
  31. package/dist/cjs/components/grid/GridItem.js +9 -2
  32. package/dist/cjs/components/image/Image.js +25 -24
  33. package/dist/cjs/components/image/tokens.js +3 -1
  34. package/dist/cjs/components/image-preview/ImagePreview.js +38 -28
  35. package/dist/cjs/components/image-preview/tokens.js +3 -1
  36. package/dist/cjs/components/input/Input.js +16 -19
  37. package/dist/cjs/components/loading/Loading.js +27 -27
  38. package/dist/cjs/components/nav-bar/NavBar.js +21 -18
  39. package/dist/cjs/components/nav-bar/tokens.js +3 -1
  40. package/dist/cjs/components/notice-bar/NoticeBar.js +7 -3
  41. package/dist/cjs/components/notice-bar/tokens.js +3 -1
  42. package/dist/cjs/components/notify/Notify.js +2 -1
  43. package/dist/cjs/components/notify/imperative.js +17 -17
  44. package/dist/cjs/components/notify/tokens.js +1 -0
  45. package/dist/cjs/components/number-keyboard/NumberKeyboard.js +217 -201
  46. package/dist/cjs/components/number-keyboard/tokens.js +7 -1
  47. package/dist/cjs/components/overlay/Overlay.js +15 -15
  48. package/dist/cjs/components/password-input/PasswordInput.js +49 -49
  49. package/dist/cjs/components/picker/Picker.js +50 -58
  50. package/dist/cjs/components/popup/Popup.js +10 -10
  51. package/dist/cjs/components/popup/tokens.js +1 -0
  52. package/dist/cjs/components/portal/Portal.js +3 -4
  53. package/dist/cjs/components/progress/Progress.js +94 -95
  54. package/dist/cjs/components/progress/tokens.js +1 -0
  55. package/dist/cjs/components/radio/Radio.js +67 -63
  56. package/dist/cjs/components/radio/RadioGroup.js +6 -6
  57. package/dist/cjs/components/safe-area-view/SafeAreaView.js +7 -7
  58. package/dist/cjs/components/search/Search.js +28 -28
  59. package/dist/cjs/components/selector/Selector.js +19 -26
  60. package/dist/cjs/components/share-sheet/ShareSheet.js +8 -2
  61. package/dist/cjs/components/share-sheet/tokens.js +3 -1
  62. package/dist/cjs/components/sidebar/Sidebar.js +22 -16
  63. package/dist/cjs/components/sidebar/SidebarItem.js +9 -8
  64. package/dist/cjs/components/sidebar/tokens.js +3 -1
  65. package/dist/cjs/components/skeleton/Skeleton.js +43 -42
  66. package/dist/cjs/components/slider/Slider.js +1 -1
  67. package/dist/cjs/components/space/Space.js +45 -41
  68. package/dist/cjs/components/space/tokens.js +7 -1
  69. package/dist/cjs/components/stepper/Stepper.js +17 -15
  70. package/dist/cjs/components/stepper/tokens.js +1 -0
  71. package/dist/cjs/components/swiper/Swiper.js +10 -7
  72. package/dist/cjs/components/swiper/SwiperPagIndicator.js +3 -2
  73. package/dist/cjs/components/switch/Switch.js +23 -23
  74. package/dist/cjs/components/tabbar/Tabbar.js +26 -26
  75. package/dist/cjs/components/tabbar/TabbarItem.js +6 -0
  76. package/dist/cjs/components/tabs/Tabs.js +143 -153
  77. package/dist/cjs/components/tabs/tokens.js +3 -1
  78. package/dist/cjs/components/tag/Tag.js +38 -38
  79. package/dist/cjs/components/toast/Toast.js +7 -3
  80. package/dist/cjs/components/toast/tokens.js +1 -0
  81. package/dist/cjs/components/typography/Typography.js +23 -21
  82. package/dist/cjs/components/water-mark/WaterMark.js +65 -65
  83. package/dist/cjs/design-system/Text.js +38 -0
  84. package/dist/cjs/design-system/createComponentTokensHook.js +2 -2
  85. package/dist/cjs/design-system/index.js +7 -0
  86. package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
  87. package/dist/cjs/hooks/useControllableValue.js +11 -11
  88. package/dist/cjs/hooks/useCountDown.js +18 -18
  89. package/dist/cjs/platform/measure.js +4 -2
  90. package/dist/cjs/utils/color.js +2 -7
  91. package/dist/cjs/utils/compare.js +3 -3
  92. package/dist/cjs/utils/date.js +2 -2
  93. package/dist/cjs/utils/deepMerge.js +5 -5
  94. package/dist/cjs/utils/hairline.js +1 -0
  95. package/dist/cjs/utils/render.js +2 -8
  96. package/dist/cjs/utils/validate.js +2 -4
  97. package/dist/es/components/action-sheet/ActionSheet.js +51 -53
  98. package/dist/es/components/area/Area.js +22 -22
  99. package/dist/es/components/avatar/Avatar.js +23 -23
  100. package/dist/es/components/badge/Badge.js +56 -61
  101. package/dist/es/components/button/Button.js +87 -92
  102. package/dist/es/components/button/ButtonGroup.js +4 -4
  103. package/dist/es/components/calendar/Calendar.js +28 -28
  104. package/dist/es/components/cascader/Cascader.js +206 -212
  105. package/dist/es/components/cell/Cell.js +55 -52
  106. package/dist/es/components/cell/CellGroup.js +26 -25
  107. package/dist/es/components/checkbox/Checkbox.js +1 -0
  108. package/dist/es/components/checkbox/CheckboxGroup.js +20 -19
  109. package/dist/es/components/circle/Circle.js +66 -54
  110. package/dist/es/components/collapse/Collapse.js +18 -18
  111. package/dist/es/components/config-provider/ConfigProvider.js +5 -5
  112. package/dist/es/components/count-down/CountDown.js +17 -17
  113. package/dist/es/components/datetime-picker/DatetimePicker.js +34 -35
  114. package/dist/es/components/dialog/Dialog.js +16 -10
  115. package/dist/es/components/dialog/imperative.js +8 -14
  116. package/dist/es/components/dialog/tokens.js +1 -0
  117. package/dist/es/components/divider/Divider.js +48 -51
  118. package/dist/es/components/empty/Empty.js +30 -25
  119. package/dist/es/components/error-boundary/ErrorBoundary.js +3 -2
  120. package/dist/es/components/flex/Flex.js +27 -27
  121. package/dist/es/components/flex/FlexItem.js +1 -0
  122. package/dist/es/components/form/Form.js +95 -94
  123. package/dist/es/components/form/FormItem.js +60 -54
  124. package/dist/es/components/form/FormList.js +35 -35
  125. package/dist/es/components/grid/Grid.js +48 -48
  126. package/dist/es/components/grid/GridItem.js +10 -3
  127. package/dist/es/components/image/Image.js +25 -24
  128. package/dist/es/components/image/tokens.js +3 -1
  129. package/dist/es/components/image-preview/ImagePreview.js +39 -29
  130. package/dist/es/components/image-preview/tokens.js +3 -1
  131. package/dist/es/components/input/Input.js +16 -19
  132. package/dist/es/components/loading/Loading.js +27 -27
  133. package/dist/es/components/nav-bar/NavBar.js +21 -18
  134. package/dist/es/components/nav-bar/tokens.js +3 -1
  135. package/dist/es/components/notice-bar/NoticeBar.js +7 -3
  136. package/dist/es/components/notice-bar/tokens.js +3 -1
  137. package/dist/es/components/notify/Notify.js +2 -1
  138. package/dist/es/components/notify/imperative.js +17 -17
  139. package/dist/es/components/notify/tokens.js +1 -0
  140. package/dist/es/components/number-keyboard/NumberKeyboard.js +217 -201
  141. package/dist/es/components/number-keyboard/tokens.js +7 -1
  142. package/dist/es/components/overlay/Overlay.js +15 -15
  143. package/dist/es/components/password-input/PasswordInput.js +49 -49
  144. package/dist/es/components/picker/Picker.js +50 -58
  145. package/dist/es/components/popup/Popup.js +10 -10
  146. package/dist/es/components/popup/tokens.js +1 -0
  147. package/dist/es/components/portal/Portal.js +3 -4
  148. package/dist/es/components/progress/Progress.js +94 -95
  149. package/dist/es/components/progress/tokens.js +1 -0
  150. package/dist/es/components/radio/Radio.js +67 -63
  151. package/dist/es/components/radio/RadioGroup.js +6 -6
  152. package/dist/es/components/safe-area-view/SafeAreaView.js +7 -7
  153. package/dist/es/components/search/Search.js +28 -28
  154. package/dist/es/components/selector/Selector.js +19 -26
  155. package/dist/es/components/share-sheet/ShareSheet.js +8 -2
  156. package/dist/es/components/share-sheet/tokens.js +3 -1
  157. package/dist/es/components/sidebar/Sidebar.js +22 -16
  158. package/dist/es/components/sidebar/SidebarItem.js +9 -8
  159. package/dist/es/components/sidebar/tokens.js +3 -1
  160. package/dist/es/components/skeleton/Skeleton.js +43 -42
  161. package/dist/es/components/slider/Slider.js +3 -3
  162. package/dist/es/components/space/Space.js +45 -41
  163. package/dist/es/components/space/tokens.js +7 -1
  164. package/dist/es/components/stepper/Stepper.js +17 -15
  165. package/dist/es/components/stepper/tokens.js +1 -0
  166. package/dist/es/components/swiper/Swiper.js +11 -8
  167. package/dist/es/components/swiper/SwiperPagIndicator.js +3 -2
  168. package/dist/es/components/switch/Switch.js +23 -23
  169. package/dist/es/components/tabbar/Tabbar.js +26 -26
  170. package/dist/es/components/tabbar/TabbarItem.js +6 -0
  171. package/dist/es/components/tabs/Tabs.js +144 -154
  172. package/dist/es/components/tabs/tokens.js +3 -1
  173. package/dist/es/components/tag/Tag.js +38 -38
  174. package/dist/es/components/toast/Toast.js +7 -3
  175. package/dist/es/components/toast/tokens.js +1 -0
  176. package/dist/es/components/typography/Typography.js +23 -21
  177. package/dist/es/components/water-mark/WaterMark.js +65 -65
  178. package/dist/es/design-system/Text.js +19 -0
  179. package/dist/es/design-system/createComponentTokensHook.js +2 -2
  180. package/dist/es/design-system/index.js +1 -0
  181. package/dist/es/design-system/mergeTokensOverride.js +1 -4
  182. package/dist/es/hooks/useControllableValue.js +11 -11
  183. package/dist/es/hooks/useCountDown.js +18 -18
  184. package/dist/es/platform/measure.js +4 -2
  185. package/dist/es/utils/color.js +1 -4
  186. package/dist/es/utils/compare.js +3 -3
  187. package/dist/es/utils/date.js +2 -2
  188. package/dist/es/utils/deepMerge.js +5 -5
  189. package/dist/es/utils/hairline.js +1 -0
  190. package/dist/es/utils/render.js +1 -1
  191. package/dist/es/utils/validate.js +1 -2
  192. package/dist/types/components/dialog/tokens.d.ts +1 -0
  193. package/dist/types/components/image-preview/tokens.d.ts +1 -0
  194. package/dist/types/components/nav-bar/tokens.d.ts +1 -1
  195. package/dist/types/components/notice-bar/tokens.d.ts +1 -0
  196. package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
  197. package/dist/types/components/picker/Picker.d.ts +1 -1
  198. package/dist/types/components/popup/tokens.d.ts +1 -0
  199. package/dist/types/components/share-sheet/tokens.d.ts +1 -0
  200. package/dist/types/components/stepper/tokens.d.ts +1 -0
  201. package/dist/types/components/tabs/tokens.d.ts +1 -0
  202. package/dist/types/components/toast/tokens.d.ts +1 -0
  203. package/dist/types/design-system/Text.d.ts +3 -0
  204. package/dist/types/design-system/index.d.ts +1 -0
  205. package/dist/types/hooks/useCountDown.d.ts +1 -1
  206. package/dist/types/utils/color.d.ts +0 -2
  207. package/dist/types/utils/date.d.ts +1 -1
  208. package/dist/types/utils/render.d.ts +1 -1
  209. package/dist/types/utils/validate.d.ts +0 -1
  210. package/package.json +17 -3
@@ -36,23 +36,23 @@ var _useCascaderExtend = require("./useCascaderExtend");
36
36
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
37
37
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
38
38
  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); }
39
- const getFieldKeys = fieldNames => ({
40
- textKey: fieldNames?.text ?? "text",
41
- valueKey: fieldNames?.value ?? "value",
42
- childrenKey: fieldNames?.children ?? "children"
39
+ const getFieldKeys = fn => ({
40
+ textKey: fn?.text ?? "text",
41
+ valueKey: fn?.value ?? "value",
42
+ childrenKey: fn?.children ?? "children"
43
43
  });
44
- const resolveRows = (options = [], keys, values) => {
45
- const selected = [];
46
- let current = options;
47
- values.forEach(val => {
48
- if (!current || !current.length) return;
49
- const matched = current.find(o => o[keys.valueKey] === val);
50
- if (matched) {
51
- selected.push(matched);
52
- current = matched[keys.childrenKey] ?? [];
44
+ const resolveRows = (opts = [], k, vals) => {
45
+ const sel = [];
46
+ let cur = opts;
47
+ vals.forEach(val => {
48
+ if (!cur?.length) return;
49
+ const m = cur.find(o => o[k.valueKey] === val);
50
+ if (m) {
51
+ sel.push(m);
52
+ cur = m[k.childrenKey] ?? [];
53
53
  }
54
54
  });
55
- return selected;
55
+ return sel;
56
56
  };
57
57
  const CascaderImpl = props => {
58
58
  const {
@@ -76,9 +76,9 @@ const CascaderImpl = props => {
76
76
  testID,
77
77
  children,
78
78
  poppable,
79
- visible: _visible,
80
- defaultVisible: _defaultVisible,
81
- onVisibleChange: _onVisibleChange,
79
+ visible: _v,
80
+ defaultVisible: _dv,
81
+ onVisibleChange: _ov,
82
82
  closeOnClickOverlay,
83
83
  closeOnFinish,
84
84
  popupPlacement,
@@ -89,146 +89,142 @@ const CascaderImpl = props => {
89
89
  } = props;
90
90
  const locale = (0, _useLocale.useLocale)();
91
91
  const tokens = (0, _tokens.useCascaderTokens)(tokensOverride);
92
- const resolvedTitle = title ?? locale?.vanCascader?.placeholder ?? tokens.defaults.title;
93
- const resolvedPlaceholder = placeholder ?? locale?.vanCascader?.placeholder ?? tokens.defaults.placeholder;
94
- const resolvedActiveColor = activeColor ?? tokens.colors.tabActive;
95
- const resolvedShowHeader = showHeader ?? tokens.defaults.showHeader;
96
- const resolvedSwipeable = swipeable ?? tokens.defaults.swipeable;
97
- const resolvedPoppable = poppable ?? tokens.defaults.poppable;
98
- const resolvedCloseOnClickOverlay = closeOnClickOverlay ?? tokens.defaults.closeOnClickOverlay;
99
- const resolvedCloseOnFinish = closeOnFinish ?? tokens.defaults.closeOnFinish;
100
- const resolvedPopupPlacement = popupPlacement ?? tokens.defaults.popupPlacement;
101
- const resolvedPopupRound = popupRound ?? tokens.defaults.popupRound;
102
- const resolvedLoadingText = loadingText ?? tokens.defaults.loadingText;
92
+ const rT = title ?? locale?.vanCascader?.placeholder ?? tokens.defaults.title;
93
+ const rP = placeholder ?? locale?.vanCascader?.placeholder ?? tokens.defaults.placeholder;
94
+ const rAc = activeColor ?? tokens.colors.tabActive;
95
+ const rSH = showHeader ?? tokens.defaults.showHeader;
96
+ const rSw = swipeable ?? tokens.defaults.swipeable;
97
+ const rPop = poppable ?? tokens.defaults.poppable;
98
+ const rCO = closeOnClickOverlay ?? tokens.defaults.closeOnClickOverlay;
99
+ const rCF = closeOnFinish ?? tokens.defaults.closeOnFinish;
100
+ const rPP = popupPlacement ?? tokens.defaults.popupPlacement;
101
+ const rPR = popupRound ?? tokens.defaults.popupRound;
102
+ const rLT = loadingText ?? tokens.defaults.loadingText;
103
103
  const [value, setValue] = (0, _hooks.useControllableValue)(props, {
104
104
  defaultValue: [],
105
105
  trigger: "onChange"
106
106
  });
107
107
  const keys = getFieldKeys(fieldNames);
108
- const currentValue = Array.isArray(value) ? value : [];
109
- const [pendingValue, setPendingValue] = (0, _react().useState)(currentValue);
110
- const showClose = closeable ?? tokens.defaults.closeable;
111
- const [popupVisible, setPopupVisible] = (0, _hooks.useControllableValue)(props, {
108
+ const curVal = Array.isArray(value) ? value : [];
109
+ const [pending, setPending] = (0, _react().useState)(curVal);
110
+ const showCl = closeable ?? tokens.defaults.closeable;
111
+ const [popVis, setPopVis] = (0, _hooks.useControllableValue)(props, {
112
112
  defaultValue: false,
113
113
  valuePropName: "visible",
114
114
  defaultValuePropName: "defaultVisible",
115
115
  trigger: "onVisibleChange"
116
116
  });
117
- const current = resolvedPoppable ? pendingValue : currentValue;
117
+ const cur = rPop ? pending : curVal;
118
118
  const {
119
119
  tabs,
120
120
  items,
121
121
  depth
122
- } = (0, _useCascaderExtend.useCascaderExtend)(options, keys, current);
122
+ } = (0, _useCascaderExtend.useCascaderExtend)(options, keys, cur);
123
123
  const {
124
- width: windowWidth
124
+ width: winW
125
125
  } = (0, _reactNative().useWindowDimensions)();
126
- const [measuredWidth, setMeasuredWidth] = (0, _react().useState)(0);
127
- const handleTabsLayout = (0, _react().useCallback)(e => {
128
- const width = e.nativeEvent.layout.width;
129
- if (!width) return;
130
- setMeasuredWidth(prev => prev === width ? prev : width);
126
+ const [measW, setMeasW] = (0, _react().useState)(0);
127
+ const onTabsLayout = (0, _react().useCallback)(e => {
128
+ const w = e.nativeEvent.layout.width;
129
+ if (w) setMeasW(prev => prev === w ? prev : w);
131
130
  }, []);
132
- const currentRows = resolveRows(options, keys, currentValue);
133
- const [activeTab, setActiveTab] = (0, _react().useState)(0);
131
+ const curRows = resolveRows(options, keys, curVal);
132
+ const [actTab, setActTab] = (0, _react().useState)(0);
134
133
  (0, _react().useEffect)(() => {
135
- const currentLength = Array.isArray(current) ? current.length : 0;
136
- let tabIndex = currentLength;
137
- if (tabIndex >= depth) tabIndex = Math.max(depth - 1, 0);
138
- setActiveTab(prev => prev === tabIndex ? prev : tabIndex);
139
- }, [current.length, depth]);
134
+ const len = Array.isArray(cur) ? cur.length : 0;
135
+ let ti = len;
136
+ if (ti >= depth) ti = Math.max(depth - 1, 0);
137
+ setActTab(prev => prev === ti ? prev : ti);
138
+ }, [cur.length, depth]);
140
139
  (0, _react().useEffect)(() => {
141
- if (!resolvedPoppable || !popupVisible) setPendingValue(prev => (0, _utils.shallowEqualArray)(prev, currentValue) ? prev : currentValue);
142
- }, [currentValue, resolvedPoppable, popupVisible]);
143
- const openPopup = (0, _react().useCallback)(() => {
144
- if (!resolvedPoppable || popupVisible) return;
145
- setPendingValue(prev => (0, _utils.shallowEqualArray)(prev, currentValue) ? prev : currentValue);
146
- setPopupVisible(true);
147
- }, [currentValue, resolvedPoppable, popupVisible, setPopupVisible]);
148
- const onCloseRef = (0, _react().useRef)(onClose),
149
- onChangeRef = (0, _react().useRef)(onChange),
150
- onFinishRef = (0, _react().useRef)(onFinish),
151
- onClickTabRef = (0, _react().useRef)(onClickTab),
152
- onTabChangeRef = (0, _react().useRef)(onTabChange);
140
+ if (!rPop || !popVis) setPending(prev => (0, _utils.shallowEqualArray)(prev, curVal) ? prev : curVal);
141
+ }, [curVal, rPop, popVis]);
142
+ const openPop = (0, _react().useCallback)(() => {
143
+ if (!rPop || popVis) return;
144
+ setPending(prev => (0, _utils.shallowEqualArray)(prev, curVal) ? prev : curVal);
145
+ setPopVis(true);
146
+ }, [curVal, rPop, popVis, setPopVis]);
147
+ const onCloseRef = (0, _react().useRef)(onClose);
148
+ const onChangeRef = (0, _react().useRef)(onChange);
149
+ const onFinRef = (0, _react().useRef)(onFinish);
150
+ const onClickTabRef = (0, _react().useRef)(onClickTab);
151
+ const onTabChgRef = (0, _react().useRef)(onTabChange);
153
152
  onCloseRef.current = onClose;
154
153
  onChangeRef.current = onChange;
155
- onFinishRef.current = onFinish;
154
+ onFinRef.current = onFinish;
156
155
  onClickTabRef.current = onClickTab;
157
- onTabChangeRef.current = onTabChange;
158
- const closePopup = (0, _react().useCallback)(notify => {
159
- if (!resolvedPoppable || !popupVisible) return;
160
- setPopupVisible(false);
156
+ onTabChgRef.current = onTabChange;
157
+ const closePop = (0, _react().useCallback)(notify => {
158
+ if (!rPop || !popVis) return;
159
+ setPopVis(false);
161
160
  if (notify) onCloseRef.current?.();
162
- }, [resolvedPoppable, popupVisible, setPopupVisible]);
163
- const togglePopup = (0, _react().useCallback)(() => {
164
- if (!resolvedPoppable) return;
165
- popupVisible ? closePopup(true) : openPopup();
166
- }, [closePopup, openPopup, resolvedPoppable, popupVisible]);
167
- const isRenderProps = (0, _validate.isFunction)(children);
168
- const renderProps = isRenderProps ? children : null;
169
- const handleClickTab = (0, _react().useCallback)(e => {
170
- const index = (0, _validate.isNumber)(e.index) ? e.index : Number(e.name);
171
- if (Number.isNaN(index)) return;
172
- const tabName = items[index]?.[keys.textKey];
173
- const tabText = (0, _validate.isText)(tabName) ? String(tabName) : resolvedPlaceholder;
174
- onClickTabRef.current?.(index, tabText);
175
- }, [items, keys.textKey, resolvedPlaceholder]);
176
- const handleTabChange = (0, _react().useCallback)((tabValue, indexExplicit) => {
177
- const index = (0, _validate.isNumber)(indexExplicit) ? indexExplicit : Number(tabValue);
178
- if (Number.isNaN(index)) return;
179
- setActiveTab(index);
180
- onTabChangeRef.current?.(index);
161
+ }, [rPop, popVis, setPopVis]);
162
+ const togglePop = (0, _react().useCallback)(() => {
163
+ if (!rPop) return;
164
+ popVis ? closePop(true) : openPop();
165
+ }, [closePop, openPop, rPop, popVis]);
166
+ const isRP = (0, _validate.isFunction)(children);
167
+ const rp = isRP ? children : null;
168
+ const onClkTab = (0, _react().useCallback)(e => {
169
+ const i = (0, _validate.isNumber)(e.index) ? e.index : Number(e.name);
170
+ if (Number.isNaN(i)) return;
171
+ const tabName = items[i]?.[keys.textKey];
172
+ onClickTabRef.current?.(i, (0, _validate.isText)(tabName) ? String(tabName) : rP);
173
+ }, [items, keys.textKey, rP]);
174
+ const onTabChg = (0, _react().useCallback)((tv, iEx) => {
175
+ const i = (0, _validate.isNumber)(iEx) ? iEx : Number(tv);
176
+ if (Number.isNaN(i)) return;
177
+ setActTab(i);
178
+ onTabChgRef.current?.(i);
181
179
  }, []);
182
- const handleSelect = (0, _react().useCallback)((option, tabIndex) => {
183
- if (option.disabled) return;
184
- const optionValue = option[keys.valueKey];
185
- if (optionValue == null) return;
186
- const base = (resolvedPoppable ? pendingValue : currentValue).slice(0, tabIndex);
187
- const nextValue = [...base, optionValue];
188
- const rows = resolveRows(options, keys, nextValue);
189
- const children = option[keys.childrenKey] ?? [];
190
- const hasChildrenProp = Object.prototype.hasOwnProperty.call(option, keys.childrenKey);
191
- const hasChildren = children.length > 0;
192
- const isAsync = hasChildrenProp && !hasChildren;
193
- const reachedDepth = nextValue.length >= depth;
194
- const isLeaf = !hasChildren && !isAsync;
195
- if (resolvedPoppable) {
196
- setPendingValue(nextValue);
197
- onChangeRef.current?.(nextValue, rows);
198
- } else setValue(nextValue, rows);
199
- if (isLeaf || reachedDepth) {
200
- if (resolvedPoppable) {
201
- setValue(nextValue, rows);
202
- if (resolvedCloseOnFinish) closePopup(true);
180
+ const onSelect = (0, _react().useCallback)((opt, ti) => {
181
+ if (opt.disabled) return;
182
+ const ov = opt[keys.valueKey];
183
+ if (ov == null) return;
184
+ const base = (rPop ? pending : curVal).slice(0, ti);
185
+ const next = [...base, ov];
186
+ const rows = resolveRows(options, keys, next);
187
+ const ch = opt[keys.childrenKey] ?? [];
188
+ const hasCh = Object.prototype.hasOwnProperty.call(opt, keys.childrenKey);
189
+ const isAsync = hasCh && !ch.length;
190
+ const atDepth = next.length >= depth;
191
+ const isLeaf = !ch.length && !isAsync;
192
+ if (rPop) {
193
+ setPending(next);
194
+ onChangeRef.current?.(next, rows);
195
+ } else setValue(next, rows);
196
+ if (isLeaf || atDepth) {
197
+ if (rPop) {
198
+ setValue(next, rows);
199
+ if (rCF) closePop(true);
203
200
  }
204
- onFinishRef.current?.(nextValue, rows);
201
+ onFinRef.current?.(next, rows);
205
202
  }
206
- }, [currentValue, resolvedCloseOnFinish, closePopup, depth, keys, options, pendingValue, resolvedPoppable, setValue]);
207
- const getEmptyText = (0, _react().useCallback)(tabIndex => {
208
- if (tabIndex <= 0) return resolvedPlaceholder;
209
- const parent = items[tabIndex - 1];
210
- if (!parent) return resolvedPlaceholder;
211
- const hasChildrenProp = Object.prototype.hasOwnProperty.call(parent, keys.childrenKey);
212
- if (!hasChildrenProp) return resolvedPlaceholder;
213
- const children = parent[keys.childrenKey] ?? [];
214
- const isAsync = children.length === 0 && current.length === tabIndex;
215
- return isAsync ? resolvedLoadingText : resolvedPlaceholder;
216
- }, [current.length, items, keys.childrenKey, resolvedLoadingText, resolvedPlaceholder]);
203
+ }, [curVal, rCF, closePop, depth, keys, options, pending, rPop, setValue]);
204
+ const getEmpty = (0, _react().useCallback)(ti => {
205
+ if (ti <= 0) return rP;
206
+ const p = items[ti - 1];
207
+ if (!p) return rP;
208
+ const hasCh = Object.prototype.hasOwnProperty.call(p, keys.childrenKey);
209
+ if (!hasCh) return rP;
210
+ const ch = p[keys.childrenKey] ?? [];
211
+ return ch.length === 0 && cur.length === ti ? rLT : rP;
212
+ }, [cur.length, items, keys.childrenKey, rLT, rP]);
217
213
  const renderTabs = () => {
218
214
  if (!tabs.length) return /*#__PURE__*/_react().default.createElement(CascaderOptionList, {
219
215
  optionList: [],
220
216
  tabIndex: 0,
221
- selectedValue: current[0],
222
- activeColor: resolvedActiveColor,
217
+ selectedValue: cur[0],
218
+ activeColor: rAc,
223
219
  keys: keys,
224
220
  optionRender: optionRender,
225
- onSelect: handleSelect,
221
+ onSelect: onSelect,
226
222
  tokens: tokens,
227
- emptyText: getEmptyText(0)
223
+ emptyText: getEmpty(0)
228
224
  });
229
- const swipeEnabled = !!resolvedSwipeable;
230
- const renderTabsWidth = measuredWidth || windowWidth || undefined;
231
- const tabBarStyle = {
225
+ const swEn = !!rSw;
226
+ const tabsW = measW || winW || undefined;
227
+ const tbStyle = {
232
228
  height: tokens.sizing.headerHeight,
233
229
  paddingHorizontal: tokens.spacing.tabNavPaddingHorizontal,
234
230
  paddingVertical: tokens.spacing.tabNavPaddingVertical,
@@ -236,79 +232,78 @@ const CascaderImpl = props => {
236
232
  };
237
233
  return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
238
234
  style: tokens.layout.tabsWrapper,
239
- onLayout: handleTabsLayout
235
+ onLayout: onTabsLayout
240
236
  }, /*#__PURE__*/_react().default.createElement(_tabs.default, {
241
- style: renderTabsWidth ? {
242
- width: renderTabsWidth
237
+ style: tabsW ? {
238
+ width: tabsW
243
239
  } : undefined,
244
- active: activeTab,
245
- onChange: handleTabChange,
246
- onClickTab: handleClickTab,
240
+ active: actTab,
241
+ onChange: onTabChg,
242
+ onClickTab: onClkTab,
247
243
  align: "center",
248
- swipeable: swipeEnabled,
244
+ swipeable: swEn,
249
245
  swipeThreshold: 0,
250
246
  scrollable: true,
251
247
  animated: true,
252
248
  duration: 300,
253
- color: resolvedActiveColor,
249
+ color: rAc,
254
250
  lineHeight: tokens.sizing.indicatorHeight,
255
251
  titleActiveColor: tokens.colors.tabText,
256
252
  titleInactiveColor: tokens.colors.tabInactive,
257
- tabBarStyle: tabBarStyle,
253
+ tabBarStyle: tbStyle,
258
254
  tabStyle: [tokens.layout.tabsItem, {
259
255
  paddingHorizontal: tokens.spacing.tabPaddingHorizontal
260
256
  }],
261
257
  titleStyle: [tokens.layout.tabsTitle, {
262
258
  fontSize: tokens.typography.tabsTitleSize
263
259
  }],
264
- contentStyle: !swipeEnabled ? tokens.layout.tabsContentStatic : undefined
265
- }, tabs.map((optionList, i) => {
266
- const selectedOption = items[i];
267
- const labelValue = selectedOption?.[keys.textKey];
268
- const label = (0, _validate.isText)(labelValue) ? String(labelValue) : "";
269
- const usePlaceholder = !label;
260
+ contentStyle: !swEn ? tokens.layout.tabsContentStatic : undefined
261
+ }, tabs.map((optList, i) => {
262
+ const sel = items[i];
263
+ const lbl = (0, _validate.isText)(sel?.[keys.textKey]) ? String(sel?.[keys.textKey]) : "";
264
+ const usePh = !lbl;
270
265
  const titleNode = _ => /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
271
266
  style: [tokens.layout.tabTitleNode, {
272
- color: usePlaceholder ? tokens.colors.tabInactive : tokens.colors.tabText,
273
- fontWeight: usePlaceholder ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
267
+ color: usePh ? tokens.colors.tabInactive : tokens.colors.tabText,
268
+ fontWeight: usePh ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
274
269
  }]
275
- }, usePlaceholder ? resolvedPlaceholder : label);
270
+ }, usePh ? rP : lbl);
276
271
  return /*#__PURE__*/_react().default.createElement(_tabs.default.TabPane, {
277
272
  key: i,
278
273
  name: i,
279
274
  title: titleNode
280
275
  }, /*#__PURE__*/_react().default.createElement(CascaderOptionList, {
281
- optionList: optionList,
276
+ optionList: optList,
282
277
  tabIndex: i,
283
- selectedValue: current[i],
284
- activeColor: resolvedActiveColor,
278
+ selectedValue: cur[i],
279
+ activeColor: rAc,
285
280
  keys: keys,
286
281
  optionRender: optionRender,
287
- onSelect: handleSelect,
282
+ onSelect: onSelect,
288
283
  tokens: tokens,
289
- emptyText: getEmptyText(i)
284
+ emptyText: getEmpty(i)
290
285
  }));
291
286
  })));
292
287
  };
293
- const inlineChildren = !resolvedPoppable && !isRenderProps ? children : null;
288
+ const inlineCh = !rPop && !isRP ? children : null;
294
289
  const content = /*#__PURE__*/_react().default.createElement(_reactNative().View, _extends({
295
290
  testID: testID,
296
291
  style: [tokens.layout.container, {
297
292
  backgroundColor: tokens.colors.background
298
293
  }, style]
299
- }, rest), resolvedShowHeader ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
294
+ }, rest), rSH ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
300
295
  style: [tokens.layout.header, {
301
296
  height: tokens.sizing.headerHeight,
302
297
  paddingHorizontal: tokens.spacing.headerPaddingHorizontal
303
298
  }]
304
- }, (0, _utils.renderTextOrNode)(resolvedTitle, [tokens.layout.title, {
299
+ }, (0, _utils.renderTextOrNode)(rT, [tokens.layout.title, {
305
300
  color: tokens.colors.headerText,
306
301
  fontSize: tokens.typography.titleSize,
307
302
  fontWeight: tokens.typography.titleWeight
308
- }]), showClose ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
303
+ }]), showCl ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
309
304
  hitSlop: 8,
310
305
  onPress: () => {
311
- if (resolvedPoppable) closePopup(true);else onCloseRef.current?.();
306
+ rPop ? closePop(true) : onCloseRef.current?.();
312
307
  },
313
308
  style: [tokens.layout.closeButton, {
314
309
  marginLeft: tokens.spacing.closeButtonMarginLeft
@@ -319,63 +314,61 @@ const CascaderImpl = props => {
319
314
  size: tokens.sizing.closeIconSize,
320
315
  fill: state.pressed ? tokens.colors.closeIconActive : tokens.colors.closeIcon,
321
316
  color: state.pressed ? tokens.colors.closeIconActive : tokens.colors.closeIcon
322
- }))) : null) : null, renderTabs(), inlineChildren ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
317
+ }))) : null) : null, renderTabs(), inlineCh ? /*#__PURE__*/_react().default.createElement(_reactNative().View, {
323
318
  style: [tokens.layout.inlineChildren, {
324
319
  paddingVertical: tokens.spacing.inlineChildrenPaddingVertical,
325
320
  paddingHorizontal: tokens.spacing.headerPaddingHorizontal
326
321
  }]
327
- }, inlineChildren) : null);
328
- if (!resolvedPoppable) return content;
322
+ }, inlineCh) : null);
323
+ if (!rPop) return content;
329
324
  const {
330
- closeOnOverlayPress: overlayCloseOnPress,
331
- overlay: popupOverlay,
332
- onOpen: popupOnOpen,
333
- onOpened: popupOnOpened,
334
- onClose: popupOnClose,
335
- onClosed: popupOnClosed,
336
- ...popupRestProps
325
+ closeOnOverlayPress: ovClose,
326
+ overlay: popOv,
327
+ onOpen: popOnOpen,
328
+ onOpened: popOnOpened,
329
+ onClose: popOnClose,
330
+ onClosed: popOnClosed,
331
+ ...popRest
337
332
  } = popupProps ?? {};
338
- const renderOverlay = popupOverlay ?? true;
339
- const renderCloseOnPress = overlayCloseOnPress ?? resolvedCloseOnClickOverlay;
340
- const popupOnCloseRef = (0, _react().useRef)(popupOnClose);
341
- popupOnCloseRef.current = popupOnClose;
342
- const handlePopupClose = (0, _react().useCallback)(() => {
343
- popupOnCloseRef.current?.();
344
- closePopup(true);
345
- }, [closePopup]);
346
- const controlActions = {
347
- open: openPopup,
348
- close: () => closePopup(true),
349
- toggle: togglePopup
333
+ const popOnCloseRef = (0, _react().useRef)(popOnClose);
334
+ popOnCloseRef.current = popOnClose;
335
+ const onPopupClose = (0, _react().useCallback)(() => {
336
+ popOnCloseRef.current?.();
337
+ closePop(true);
338
+ }, [closePop]);
339
+ const actions = {
340
+ open: openPop,
341
+ close: () => closePop(true),
342
+ toggle: togglePop
350
343
  };
351
- const enhanceTriggerNode = (0, _react().useCallback)(node => {
344
+ const enhanceTrigger = (0, _react().useCallback)(node => {
352
345
  if (! /*#__PURE__*/_react().default.isValidElement(node)) return node;
353
- const props = node.props;
354
- const handlePress = () => {
355
- props.onPress?.();
356
- props.onClick?.();
357
- openPopup();
346
+ const p = node.props;
347
+ const onP = () => {
348
+ p.onPress?.();
349
+ p.onClick?.();
350
+ openPop();
358
351
  };
359
352
  return /*#__PURE__*/_react().default.cloneElement(node, {
360
- onPress: handlePress,
361
- onClick: handlePress
353
+ onPress: onP,
354
+ onClick: onP
362
355
  });
363
- }, [openPopup]);
364
- const triggerNode = renderProps ? renderProps(currentValue, currentRows, controlActions) : isRenderProps ? null : children || null;
365
- const renderTriggerNode = enhanceTriggerNode(triggerNode);
366
- return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, renderTriggerNode, /*#__PURE__*/_react().default.createElement(_popup.default, _extends({
367
- visible: popupVisible,
368
- placement: resolvedPopupPlacement,
369
- round: resolvedPopupRound,
370
- closeOnOverlayPress: renderCloseOnPress,
371
- overlay: renderOverlay,
372
- safeAreaInsetTop: popupRestProps?.safeAreaInsetTop != null ? popupRestProps.safeAreaInsetTop : resolvedShowHeader && showClose,
373
- safeAreaInsetBottom: popupRestProps?.safeAreaInsetBottom != null ? popupRestProps.safeAreaInsetBottom : resolvedPopupPlacement === 'bottom',
374
- onOpen: popupOnOpen,
375
- onOpened: popupOnOpened,
376
- onClose: handlePopupClose,
377
- onClosed: popupOnClosed
378
- }, popupRestProps, {
356
+ }, [openPop]);
357
+ const triggerNode = rp ? rp(curVal, curRows, actions) : isRP ? null : children || null;
358
+ const renderTrigger = enhanceTrigger(triggerNode);
359
+ return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, renderTrigger, /*#__PURE__*/_react().default.createElement(_popup.default, _extends({
360
+ visible: popVis,
361
+ placement: rPP,
362
+ round: rPR,
363
+ closeOnOverlayPress: ovClose ?? rCO,
364
+ overlay: popOv ?? true,
365
+ safeAreaInsetTop: popRest?.safeAreaInsetTop != null ? popRest.safeAreaInsetTop : rSH && showCl,
366
+ safeAreaInsetBottom: popRest?.safeAreaInsetBottom != null ? popRest.safeAreaInsetBottom : rPP === 'bottom',
367
+ onOpen: popOnOpen,
368
+ onOpened: popOnOpened,
369
+ onClose: onPopupClose,
370
+ onClosed: popOnClosed
371
+ }, popRest, {
379
372
  style: {
380
373
  paddingLeft: 0,
381
374
  paddingRight: 0
@@ -392,41 +385,42 @@ const CascaderOptionItem = /*#__PURE__*/_react().default.memo(({
392
385
  onSelect,
393
386
  tokens
394
387
  }) => {
395
- const optionValue = option[keys.valueKey];
396
- const label = option[keys.textKey];
397
- const disabled = !!option.disabled;
398
- const baseColor = option.color ?? tokens.colors.optionText;
399
- const textColor = disabled ? tokens.colors.optionDisabled : selected ? option.color ?? activeColor : baseColor;
400
- const optionTextStyle = [tokens.layout.optionText, {
401
- color: textColor,
388
+ const ov = option[keys.valueKey];
389
+ const lbl = option[keys.textKey];
390
+ const dis = !!option.disabled;
391
+ const baseCl = option.color ?? tokens.colors.optionText;
392
+ const txtCl = dis ? tokens.colors.optionDisabled : selected ? option.color ?? activeColor : baseCl;
393
+ const txtStyle = [tokens.layout.optionText, {
394
+ color: txtCl,
402
395
  fontSize: tokens.typography.optionTextSize
403
396
  }, selected ? {
404
397
  fontWeight: tokens.typography.optionTextActiveWeight
405
398
  } : null];
406
- const content = optionRender ? optionRender({
399
+ const rawCnt = optionRender ? optionRender({
407
400
  option,
408
401
  selected
409
- }) : (0, _utils.renderTextOrNode)(label, optionTextStyle);
402
+ }) : (0, _utils.renderTextOrNode)(lbl, txtStyle);
403
+ const cnt = (0, _validate.isText)(rawCnt) ? (0, _utils.renderTextOrNode)(rawCnt, txtStyle) : rawCnt;
410
404
  return /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
411
- testID: `cascader-option-${tabIndex}-${String(optionValue)}`,
405
+ testID: `cascader-option-${tabIndex}-${String(ov)}`,
412
406
  style: ({
413
407
  pressed
414
408
  }) => [tokens.layout.option, {
415
409
  minHeight: tokens.sizing.optionMinHeight,
416
410
  paddingVertical: tokens.spacing.optionPaddingVertical,
417
411
  paddingHorizontal: tokens.spacing.optionPaddingHorizontal
418
- }, pressed && !disabled && {
412
+ }, pressed && !dis && {
419
413
  backgroundColor: tokens.colors.optionActiveBackground
420
414
  }],
421
415
  onPress: () => onSelect(option, tabIndex),
422
- disabled: disabled
416
+ disabled: dis
423
417
  }, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
424
418
  style: tokens.layout.optionContent
425
419
  }, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
426
420
  style: [tokens.layout.optionLabel, {
427
421
  marginRight: tokens.spacing.optionLabelMarginRight
428
422
  }]
429
- }, content), selected ? /*#__PURE__*/_react().default.createElement(_reactNativeSystemIcon().Checked, {
423
+ }, cnt), selected ? /*#__PURE__*/_react().default.createElement(_reactNativeSystemIcon().Checked, {
430
424
  size: tokens.sizing.selectedIconSize,
431
425
  fill: activeColor,
432
426
  color: activeColor
@@ -455,7 +449,7 @@ const CascaderOptionList = /*#__PURE__*/_react().default.memo(({
455
449
  onSelect: onSelect,
456
450
  tokens: tokens
457
451
  }), [activeColor, keys, onSelect, optionRender, selectedValue, tabIndex, tokens]);
458
- const keyExtractor = (0, _react().useCallback)(item => String(item[keys.valueKey]), [keys.valueKey]);
452
+ const keyExt = (0, _react().useCallback)(item => String(item[keys.valueKey]), [keys.valueKey]);
459
453
  if (!optionList.length) return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
460
454
  style: [tokens.layout.optionList, {
461
455
  height: tokens.sizing.optionListHeight
@@ -478,7 +472,7 @@ const CascaderOptionList = /*#__PURE__*/_react().default.memo(({
478
472
  },
479
473
  showsVerticalScrollIndicator: false,
480
474
  renderItem: renderItem,
481
- keyExtractor: keyExtractor,
475
+ keyExtractor: keyExt,
482
476
  removeClippedSubviews: true,
483
477
  initialNumToRender: 20,
484
478
  windowSize: 5