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.
- package/README.md +3 -3
- package/dist/cjs/components/action-sheet/ActionSheet.js +51 -53
- package/dist/cjs/components/area/Area.js +22 -22
- package/dist/cjs/components/avatar/Avatar.js +23 -23
- package/dist/cjs/components/badge/Badge.js +56 -61
- package/dist/cjs/components/button/Button.js +87 -92
- package/dist/cjs/components/button/ButtonGroup.js +4 -4
- package/dist/cjs/components/calendar/Calendar.js +28 -28
- package/dist/cjs/components/cascader/Cascader.js +206 -212
- package/dist/cjs/components/cell/Cell.js +54 -51
- package/dist/cjs/components/cell/CellGroup.js +26 -25
- package/dist/cjs/components/checkbox/Checkbox.js +1 -0
- package/dist/cjs/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/cjs/components/circle/Circle.js +66 -54
- package/dist/cjs/components/collapse/Collapse.js +18 -18
- package/dist/cjs/components/config-provider/ConfigProvider.js +5 -5
- package/dist/cjs/components/count-down/CountDown.js +17 -17
- package/dist/cjs/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/cjs/components/dialog/Dialog.js +16 -10
- package/dist/cjs/components/dialog/imperative.js +8 -14
- package/dist/cjs/components/dialog/tokens.js +1 -0
- package/dist/cjs/components/divider/Divider.js +48 -51
- package/dist/cjs/components/empty/Empty.js +30 -25
- package/dist/cjs/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/cjs/components/flex/Flex.js +27 -27
- package/dist/cjs/components/flex/FlexItem.js +1 -0
- package/dist/cjs/components/form/Form.js +94 -93
- package/dist/cjs/components/form/FormItem.js +60 -54
- package/dist/cjs/components/form/FormList.js +35 -35
- package/dist/cjs/components/grid/Grid.js +48 -48
- package/dist/cjs/components/grid/GridItem.js +9 -2
- package/dist/cjs/components/image/Image.js +25 -24
- package/dist/cjs/components/image/tokens.js +3 -1
- package/dist/cjs/components/image-preview/ImagePreview.js +38 -28
- package/dist/cjs/components/image-preview/tokens.js +3 -1
- package/dist/cjs/components/input/Input.js +16 -19
- package/dist/cjs/components/loading/Loading.js +27 -27
- package/dist/cjs/components/nav-bar/NavBar.js +21 -18
- package/dist/cjs/components/nav-bar/tokens.js +3 -1
- package/dist/cjs/components/notice-bar/NoticeBar.js +7 -3
- package/dist/cjs/components/notice-bar/tokens.js +3 -1
- package/dist/cjs/components/notify/Notify.js +2 -1
- package/dist/cjs/components/notify/imperative.js +17 -17
- package/dist/cjs/components/notify/tokens.js +1 -0
- package/dist/cjs/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/cjs/components/number-keyboard/tokens.js +7 -1
- package/dist/cjs/components/overlay/Overlay.js +15 -15
- package/dist/cjs/components/password-input/PasswordInput.js +49 -49
- package/dist/cjs/components/picker/Picker.js +50 -58
- package/dist/cjs/components/popup/Popup.js +10 -10
- package/dist/cjs/components/popup/tokens.js +1 -0
- package/dist/cjs/components/portal/Portal.js +3 -4
- package/dist/cjs/components/progress/Progress.js +94 -95
- package/dist/cjs/components/progress/tokens.js +1 -0
- package/dist/cjs/components/radio/Radio.js +67 -63
- package/dist/cjs/components/radio/RadioGroup.js +6 -6
- package/dist/cjs/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/cjs/components/search/Search.js +28 -28
- package/dist/cjs/components/selector/Selector.js +19 -26
- package/dist/cjs/components/share-sheet/ShareSheet.js +8 -2
- package/dist/cjs/components/share-sheet/tokens.js +3 -1
- package/dist/cjs/components/sidebar/Sidebar.js +22 -16
- package/dist/cjs/components/sidebar/SidebarItem.js +9 -8
- package/dist/cjs/components/sidebar/tokens.js +3 -1
- package/dist/cjs/components/skeleton/Skeleton.js +43 -42
- package/dist/cjs/components/slider/Slider.js +1 -1
- package/dist/cjs/components/space/Space.js +45 -41
- package/dist/cjs/components/space/tokens.js +7 -1
- package/dist/cjs/components/stepper/Stepper.js +17 -15
- package/dist/cjs/components/stepper/tokens.js +1 -0
- package/dist/cjs/components/swiper/Swiper.js +10 -7
- package/dist/cjs/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/cjs/components/switch/Switch.js +23 -23
- package/dist/cjs/components/tabbar/Tabbar.js +26 -26
- package/dist/cjs/components/tabbar/TabbarItem.js +6 -0
- package/dist/cjs/components/tabs/Tabs.js +143 -153
- package/dist/cjs/components/tabs/tokens.js +3 -1
- package/dist/cjs/components/tag/Tag.js +38 -38
- package/dist/cjs/components/toast/Toast.js +7 -3
- package/dist/cjs/components/toast/tokens.js +1 -0
- package/dist/cjs/components/typography/Typography.js +23 -21
- package/dist/cjs/components/water-mark/WaterMark.js +65 -65
- package/dist/cjs/design-system/Text.js +38 -0
- package/dist/cjs/design-system/createComponentTokensHook.js +2 -2
- package/dist/cjs/design-system/index.js +7 -0
- package/dist/cjs/design-system/mergeTokensOverride.js +1 -4
- package/dist/cjs/hooks/useControllableValue.js +11 -11
- package/dist/cjs/hooks/useCountDown.js +18 -18
- package/dist/cjs/platform/measure.js +4 -2
- package/dist/cjs/utils/color.js +2 -7
- package/dist/cjs/utils/compare.js +3 -3
- package/dist/cjs/utils/date.js +2 -2
- package/dist/cjs/utils/deepMerge.js +5 -5
- package/dist/cjs/utils/hairline.js +1 -0
- package/dist/cjs/utils/render.js +2 -8
- package/dist/cjs/utils/validate.js +2 -4
- package/dist/es/components/action-sheet/ActionSheet.js +51 -53
- package/dist/es/components/area/Area.js +22 -22
- package/dist/es/components/avatar/Avatar.js +23 -23
- package/dist/es/components/badge/Badge.js +56 -61
- package/dist/es/components/button/Button.js +87 -92
- package/dist/es/components/button/ButtonGroup.js +4 -4
- package/dist/es/components/calendar/Calendar.js +28 -28
- package/dist/es/components/cascader/Cascader.js +206 -212
- package/dist/es/components/cell/Cell.js +55 -52
- package/dist/es/components/cell/CellGroup.js +26 -25
- package/dist/es/components/checkbox/Checkbox.js +1 -0
- package/dist/es/components/checkbox/CheckboxGroup.js +20 -19
- package/dist/es/components/circle/Circle.js +66 -54
- package/dist/es/components/collapse/Collapse.js +18 -18
- package/dist/es/components/config-provider/ConfigProvider.js +5 -5
- package/dist/es/components/count-down/CountDown.js +17 -17
- package/dist/es/components/datetime-picker/DatetimePicker.js +34 -35
- package/dist/es/components/dialog/Dialog.js +16 -10
- package/dist/es/components/dialog/imperative.js +8 -14
- package/dist/es/components/dialog/tokens.js +1 -0
- package/dist/es/components/divider/Divider.js +48 -51
- package/dist/es/components/empty/Empty.js +30 -25
- package/dist/es/components/error-boundary/ErrorBoundary.js +3 -2
- package/dist/es/components/flex/Flex.js +27 -27
- package/dist/es/components/flex/FlexItem.js +1 -0
- package/dist/es/components/form/Form.js +95 -94
- package/dist/es/components/form/FormItem.js +60 -54
- package/dist/es/components/form/FormList.js +35 -35
- package/dist/es/components/grid/Grid.js +48 -48
- package/dist/es/components/grid/GridItem.js +10 -3
- package/dist/es/components/image/Image.js +25 -24
- package/dist/es/components/image/tokens.js +3 -1
- package/dist/es/components/image-preview/ImagePreview.js +39 -29
- package/dist/es/components/image-preview/tokens.js +3 -1
- package/dist/es/components/input/Input.js +16 -19
- package/dist/es/components/loading/Loading.js +27 -27
- package/dist/es/components/nav-bar/NavBar.js +21 -18
- package/dist/es/components/nav-bar/tokens.js +3 -1
- package/dist/es/components/notice-bar/NoticeBar.js +7 -3
- package/dist/es/components/notice-bar/tokens.js +3 -1
- package/dist/es/components/notify/Notify.js +2 -1
- package/dist/es/components/notify/imperative.js +17 -17
- package/dist/es/components/notify/tokens.js +1 -0
- package/dist/es/components/number-keyboard/NumberKeyboard.js +217 -201
- package/dist/es/components/number-keyboard/tokens.js +7 -1
- package/dist/es/components/overlay/Overlay.js +15 -15
- package/dist/es/components/password-input/PasswordInput.js +49 -49
- package/dist/es/components/picker/Picker.js +50 -58
- package/dist/es/components/popup/Popup.js +10 -10
- package/dist/es/components/popup/tokens.js +1 -0
- package/dist/es/components/portal/Portal.js +3 -4
- package/dist/es/components/progress/Progress.js +94 -95
- package/dist/es/components/progress/tokens.js +1 -0
- package/dist/es/components/radio/Radio.js +67 -63
- package/dist/es/components/radio/RadioGroup.js +6 -6
- package/dist/es/components/safe-area-view/SafeAreaView.js +7 -7
- package/dist/es/components/search/Search.js +28 -28
- package/dist/es/components/selector/Selector.js +19 -26
- package/dist/es/components/share-sheet/ShareSheet.js +8 -2
- package/dist/es/components/share-sheet/tokens.js +3 -1
- package/dist/es/components/sidebar/Sidebar.js +22 -16
- package/dist/es/components/sidebar/SidebarItem.js +9 -8
- package/dist/es/components/sidebar/tokens.js +3 -1
- package/dist/es/components/skeleton/Skeleton.js +43 -42
- package/dist/es/components/slider/Slider.js +3 -3
- package/dist/es/components/space/Space.js +45 -41
- package/dist/es/components/space/tokens.js +7 -1
- package/dist/es/components/stepper/Stepper.js +17 -15
- package/dist/es/components/stepper/tokens.js +1 -0
- package/dist/es/components/swiper/Swiper.js +11 -8
- package/dist/es/components/swiper/SwiperPagIndicator.js +3 -2
- package/dist/es/components/switch/Switch.js +23 -23
- package/dist/es/components/tabbar/Tabbar.js +26 -26
- package/dist/es/components/tabbar/TabbarItem.js +6 -0
- package/dist/es/components/tabs/Tabs.js +144 -154
- package/dist/es/components/tabs/tokens.js +3 -1
- package/dist/es/components/tag/Tag.js +38 -38
- package/dist/es/components/toast/Toast.js +7 -3
- package/dist/es/components/toast/tokens.js +1 -0
- package/dist/es/components/typography/Typography.js +23 -21
- package/dist/es/components/water-mark/WaterMark.js +65 -65
- package/dist/es/design-system/Text.js +19 -0
- package/dist/es/design-system/createComponentTokensHook.js +2 -2
- package/dist/es/design-system/index.js +1 -0
- package/dist/es/design-system/mergeTokensOverride.js +1 -4
- package/dist/es/hooks/useControllableValue.js +11 -11
- package/dist/es/hooks/useCountDown.js +18 -18
- package/dist/es/platform/measure.js +4 -2
- package/dist/es/utils/color.js +1 -4
- package/dist/es/utils/compare.js +3 -3
- package/dist/es/utils/date.js +2 -2
- package/dist/es/utils/deepMerge.js +5 -5
- package/dist/es/utils/hairline.js +1 -0
- package/dist/es/utils/render.js +1 -1
- package/dist/es/utils/validate.js +1 -2
- package/dist/types/components/dialog/tokens.d.ts +1 -0
- package/dist/types/components/image-preview/tokens.d.ts +1 -0
- package/dist/types/components/nav-bar/tokens.d.ts +1 -1
- package/dist/types/components/notice-bar/tokens.d.ts +1 -0
- package/dist/types/components/number-keyboard/tokens.d.ts +5 -0
- package/dist/types/components/picker/Picker.d.ts +1 -1
- package/dist/types/components/popup/tokens.d.ts +1 -0
- package/dist/types/components/share-sheet/tokens.d.ts +1 -0
- package/dist/types/components/stepper/tokens.d.ts +1 -0
- package/dist/types/components/tabs/tokens.d.ts +1 -0
- package/dist/types/components/toast/tokens.d.ts +1 -0
- package/dist/types/design-system/Text.d.ts +3 -0
- package/dist/types/design-system/index.d.ts +1 -0
- package/dist/types/hooks/useCountDown.d.ts +1 -1
- package/dist/types/utils/color.d.ts +0 -2
- package/dist/types/utils/date.d.ts +1 -1
- package/dist/types/utils/render.d.ts +1 -1
- package/dist/types/utils/validate.d.ts +0 -1
- 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 =
|
|
40
|
-
textKey:
|
|
41
|
-
valueKey:
|
|
42
|
-
childrenKey:
|
|
39
|
+
const getFieldKeys = fn => ({
|
|
40
|
+
textKey: fn?.text ?? "text",
|
|
41
|
+
valueKey: fn?.value ?? "value",
|
|
42
|
+
childrenKey: fn?.children ?? "children"
|
|
43
43
|
});
|
|
44
|
-
const resolveRows = (
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
|
|
48
|
-
if (!
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
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:
|
|
80
|
-
defaultVisible:
|
|
81
|
-
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
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
const
|
|
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
|
|
109
|
-
const [
|
|
110
|
-
const
|
|
111
|
-
const [
|
|
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
|
|
117
|
+
const cur = rPop ? pending : curVal;
|
|
118
118
|
const {
|
|
119
119
|
tabs,
|
|
120
120
|
items,
|
|
121
121
|
depth
|
|
122
|
-
} = (0, _useCascaderExtend.useCascaderExtend)(options, keys,
|
|
122
|
+
} = (0, _useCascaderExtend.useCascaderExtend)(options, keys, cur);
|
|
123
123
|
const {
|
|
124
|
-
width:
|
|
124
|
+
width: winW
|
|
125
125
|
} = (0, _reactNative().useWindowDimensions)();
|
|
126
|
-
const [
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
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
|
|
133
|
-
const [
|
|
131
|
+
const curRows = resolveRows(options, keys, curVal);
|
|
132
|
+
const [actTab, setActTab] = (0, _react().useState)(0);
|
|
134
133
|
(0, _react().useEffect)(() => {
|
|
135
|
-
const
|
|
136
|
-
let
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
}, [
|
|
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 (!
|
|
142
|
-
}, [
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}, [
|
|
148
|
-
const onCloseRef = (0, _react().useRef)(onClose)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
154
|
+
onFinRef.current = onFinish;
|
|
156
155
|
onClickTabRef.current = onClickTab;
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
160
|
-
|
|
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
|
-
}, [
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
165
|
-
|
|
166
|
-
}, [
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
if (Number.isNaN(
|
|
172
|
-
const tabName = items[
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
if (
|
|
186
|
-
const base = (
|
|
187
|
-
const
|
|
188
|
-
const rows = resolveRows(options, keys,
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
201
|
+
onFinRef.current?.(next, rows);
|
|
205
202
|
}
|
|
206
|
-
}, [
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
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:
|
|
222
|
-
activeColor:
|
|
217
|
+
selectedValue: cur[0],
|
|
218
|
+
activeColor: rAc,
|
|
223
219
|
keys: keys,
|
|
224
220
|
optionRender: optionRender,
|
|
225
|
-
onSelect:
|
|
221
|
+
onSelect: onSelect,
|
|
226
222
|
tokens: tokens,
|
|
227
|
-
emptyText:
|
|
223
|
+
emptyText: getEmpty(0)
|
|
228
224
|
});
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
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:
|
|
235
|
+
onLayout: onTabsLayout
|
|
240
236
|
}, /*#__PURE__*/_react().default.createElement(_tabs.default, {
|
|
241
|
-
style:
|
|
242
|
-
width:
|
|
237
|
+
style: tabsW ? {
|
|
238
|
+
width: tabsW
|
|
243
239
|
} : undefined,
|
|
244
|
-
active:
|
|
245
|
-
onChange:
|
|
246
|
-
onClickTab:
|
|
240
|
+
active: actTab,
|
|
241
|
+
onChange: onTabChg,
|
|
242
|
+
onClickTab: onClkTab,
|
|
247
243
|
align: "center",
|
|
248
|
-
swipeable:
|
|
244
|
+
swipeable: swEn,
|
|
249
245
|
swipeThreshold: 0,
|
|
250
246
|
scrollable: true,
|
|
251
247
|
animated: true,
|
|
252
248
|
duration: 300,
|
|
253
|
-
color:
|
|
249
|
+
color: rAc,
|
|
254
250
|
lineHeight: tokens.sizing.indicatorHeight,
|
|
255
251
|
titleActiveColor: tokens.colors.tabText,
|
|
256
252
|
titleInactiveColor: tokens.colors.tabInactive,
|
|
257
|
-
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: !
|
|
265
|
-
}, tabs.map((
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
const
|
|
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:
|
|
273
|
-
fontWeight:
|
|
267
|
+
color: usePh ? tokens.colors.tabInactive : tokens.colors.tabText,
|
|
268
|
+
fontWeight: usePh ? tokens.typography.tabTitlePlaceholderWeight : tokens.typography.tabTitleWeight
|
|
274
269
|
}]
|
|
275
|
-
},
|
|
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:
|
|
276
|
+
optionList: optList,
|
|
282
277
|
tabIndex: i,
|
|
283
|
-
selectedValue:
|
|
284
|
-
activeColor:
|
|
278
|
+
selectedValue: cur[i],
|
|
279
|
+
activeColor: rAc,
|
|
285
280
|
keys: keys,
|
|
286
281
|
optionRender: optionRender,
|
|
287
|
-
onSelect:
|
|
282
|
+
onSelect: onSelect,
|
|
288
283
|
tokens: tokens,
|
|
289
|
-
emptyText:
|
|
284
|
+
emptyText: getEmpty(i)
|
|
290
285
|
}));
|
|
291
286
|
})));
|
|
292
287
|
};
|
|
293
|
-
const
|
|
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),
|
|
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)(
|
|
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
|
-
}]),
|
|
303
|
+
}]), showCl ? /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, {
|
|
309
304
|
hitSlop: 8,
|
|
310
305
|
onPress: () => {
|
|
311
|
-
|
|
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(),
|
|
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
|
-
},
|
|
328
|
-
if (!
|
|
322
|
+
}, inlineCh) : null);
|
|
323
|
+
if (!rPop) return content;
|
|
329
324
|
const {
|
|
330
|
-
closeOnOverlayPress:
|
|
331
|
-
overlay:
|
|
332
|
-
onOpen:
|
|
333
|
-
onOpened:
|
|
334
|
-
onClose:
|
|
335
|
-
onClosed:
|
|
336
|
-
...
|
|
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
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
|
344
|
+
const enhanceTrigger = (0, _react().useCallback)(node => {
|
|
352
345
|
if (! /*#__PURE__*/_react().default.isValidElement(node)) return node;
|
|
353
|
-
const
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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:
|
|
361
|
-
onClick:
|
|
353
|
+
onPress: onP,
|
|
354
|
+
onClick: onP
|
|
362
355
|
});
|
|
363
|
-
}, [
|
|
364
|
-
const triggerNode =
|
|
365
|
-
const
|
|
366
|
-
return /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null,
|
|
367
|
-
visible:
|
|
368
|
-
placement:
|
|
369
|
-
round:
|
|
370
|
-
closeOnOverlayPress:
|
|
371
|
-
overlay:
|
|
372
|
-
safeAreaInsetTop:
|
|
373
|
-
safeAreaInsetBottom:
|
|
374
|
-
onOpen:
|
|
375
|
-
onOpened:
|
|
376
|
-
onClose:
|
|
377
|
-
onClosed:
|
|
378
|
-
},
|
|
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
|
|
396
|
-
const
|
|
397
|
-
const
|
|
398
|
-
const
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
color:
|
|
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
|
|
399
|
+
const rawCnt = optionRender ? optionRender({
|
|
407
400
|
option,
|
|
408
401
|
selected
|
|
409
|
-
}) : (0, _utils.renderTextOrNode)(
|
|
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(
|
|
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 && !
|
|
412
|
+
}, pressed && !dis && {
|
|
419
413
|
backgroundColor: tokens.colors.optionActiveBackground
|
|
420
414
|
}],
|
|
421
415
|
onPress: () => onSelect(option, tabIndex),
|
|
422
|
-
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
|
-
},
|
|
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
|
|
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:
|
|
475
|
+
keyExtractor: keyExt,
|
|
482
476
|
removeClippedSubviews: true,
|
|
483
477
|
initialNumToRender: 20,
|
|
484
478
|
windowSize: 5
|