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
|
@@ -38,18 +38,18 @@ const IS_WEB = _reactNative().Platform.OS === 'web';
|
|
|
38
38
|
const OverlayImpl = (props, ref) => {
|
|
39
39
|
const {
|
|
40
40
|
children,
|
|
41
|
-
isOpen:
|
|
42
|
-
visible:
|
|
43
|
-
useRNModal:
|
|
44
|
-
useRNModalOnAndroid:
|
|
45
|
-
isKeyboardDismissable:
|
|
46
|
-
animationPreset:
|
|
41
|
+
isOpen: openP,
|
|
42
|
+
visible: visP,
|
|
43
|
+
useRNModal: useModalP,
|
|
44
|
+
useRNModalOnAndroid: useModalAndroidP = false,
|
|
45
|
+
isKeyboardDismissable: kbDismissP = true,
|
|
46
|
+
animationPreset: animP = 'fade',
|
|
47
47
|
onRequestClose,
|
|
48
48
|
style
|
|
49
49
|
} = props;
|
|
50
50
|
const tokens = (0, _tokens.useOverlayTokens)();
|
|
51
|
-
const
|
|
52
|
-
const
|
|
51
|
+
const useModal = useModalP ?? !IS_WEB;
|
|
52
|
+
const webStyle = IS_WEB ? {
|
|
53
53
|
zIndex: tokens.layer.zIndex,
|
|
54
54
|
position: 'fixed',
|
|
55
55
|
top: 0,
|
|
@@ -57,22 +57,22 @@ const OverlayImpl = (props, ref) => {
|
|
|
57
57
|
right: 0,
|
|
58
58
|
bottom: 0
|
|
59
59
|
} : undefined;
|
|
60
|
-
const
|
|
60
|
+
const open = openP ?? visP ?? false;
|
|
61
61
|
(0, _interactions().useKeyboardDismissable)({
|
|
62
|
-
enabled: !IS_WEB &&
|
|
62
|
+
enabled: !IS_WEB && open && kbDismissP,
|
|
63
63
|
callback: onRequestClose ?? (() => {})
|
|
64
64
|
});
|
|
65
|
-
if (!
|
|
66
|
-
if (
|
|
65
|
+
if (!open) return null;
|
|
66
|
+
if (useModal || useModalAndroidP && _reactNative().Platform.OS === 'android') return /*#__PURE__*/_react().default.createElement(_reactNative().Modal, {
|
|
67
67
|
statusBarTranslucent: true,
|
|
68
68
|
transparent: true,
|
|
69
|
-
visible:
|
|
69
|
+
visible: open,
|
|
70
70
|
onRequestClose: onRequestClose,
|
|
71
|
-
animationType:
|
|
71
|
+
animationType: animP,
|
|
72
72
|
ref: ref
|
|
73
73
|
}, children);
|
|
74
74
|
return /*#__PURE__*/_react().default.createElement(_overlays().OverlayContainer, {
|
|
75
|
-
style: [style,
|
|
75
|
+
style: [style, webStyle]
|
|
76
76
|
}, children);
|
|
77
77
|
};
|
|
78
78
|
const OverlayForwardRef = /*#__PURE__*/_react().default.forwardRef(OverlayImpl);
|
|
@@ -61,7 +61,7 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
61
61
|
onBlur,
|
|
62
62
|
...rest
|
|
63
63
|
} = props;
|
|
64
|
-
const
|
|
64
|
+
const lenVal = Math.max(1, Math.floor((0, _number.parseNumberLike)(length, 6) ?? 6));
|
|
65
65
|
const tokens = (0, _tokens.usePasswordInputTokens)(tokensOverride);
|
|
66
66
|
const {
|
|
67
67
|
colors,
|
|
@@ -71,36 +71,36 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
71
71
|
opacity,
|
|
72
72
|
spacing
|
|
73
73
|
} = tokens;
|
|
74
|
-
const inputRef = (0, _react().useRef)(null)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
const inputRef = (0, _react().useRef)(null);
|
|
75
|
+
const [cursorVisible, setCursorVisible] = (0, _react().useState)(true);
|
|
76
|
+
const blinkTimer = (0, _react().useRef)(null);
|
|
77
|
+
const [focused, setFocused] = (0, _react().useState)(autoFocus);
|
|
78
78
|
const keyboardType = type === 'number' ? 'number-pad' : 'default';
|
|
79
79
|
const inputMode = type === 'number' ? 'numeric' : 'text';
|
|
80
80
|
const [code = '', setCode] = (0, _hooks.useControllableValue)(props, {
|
|
81
81
|
defaultValue: ''
|
|
82
82
|
});
|
|
83
83
|
const normalizeValue = (0, _react().useCallback)(v => {
|
|
84
|
-
let
|
|
85
|
-
if (type === 'number')
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
88
|
-
}, [
|
|
89
|
-
const
|
|
90
|
-
const validatorRef = (0, _react().useRef)(validator)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
let n = v === null || v === undefined ? '' : (0, _validate.isString)(v) ? v : String(v);
|
|
85
|
+
if (type === 'number') n = stripNonNumeric(n);
|
|
86
|
+
if (lenVal > 0 && n.length > lenVal) n = n.slice(0, lenVal);
|
|
87
|
+
return n;
|
|
88
|
+
}, [lenVal, type]);
|
|
89
|
+
const normCode = normalizeValue(code);
|
|
90
|
+
const validatorRef = (0, _react().useRef)(validator);
|
|
91
|
+
const onFocusRef = (0, _react().useRef)(onFocus);
|
|
92
|
+
const onBlurRef = (0, _react().useRef)(onBlur);
|
|
93
|
+
const onSubmitRef = (0, _react().useRef)(onSubmit);
|
|
94
94
|
validatorRef.current = validator;
|
|
95
95
|
onFocusRef.current = onFocus;
|
|
96
96
|
onBlurRef.current = onBlur;
|
|
97
97
|
onSubmitRef.current = onSubmit;
|
|
98
98
|
const updateValue = (0, _react().useCallback)(v => {
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
if (validatorRef.current && !validatorRef.current(
|
|
102
|
-
setCode(
|
|
103
|
-
}, [normalizeValue,
|
|
99
|
+
const n = normalizeValue(v);
|
|
100
|
+
if (n === normCode) return;
|
|
101
|
+
if (validatorRef.current && !validatorRef.current(n)) return;
|
|
102
|
+
setCode(n);
|
|
103
|
+
}, [normalizeValue, normCode, setCode]);
|
|
104
104
|
const focusInput = (0, _react().useCallback)(() => {
|
|
105
105
|
if (disabled) return;
|
|
106
106
|
inputRef.current?.focus();
|
|
@@ -118,10 +118,10 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
118
118
|
}), [blurInput, clearInput, focusInput]);
|
|
119
119
|
(0, _react().useEffect)(() => {
|
|
120
120
|
if (!autoFocus || disabled) return;
|
|
121
|
-
const
|
|
121
|
+
const t = setTimeout(() => {
|
|
122
122
|
inputRef.current?.focus();
|
|
123
123
|
}, 60);
|
|
124
|
-
return () => clearTimeout(
|
|
124
|
+
return () => clearTimeout(t);
|
|
125
125
|
}, [autoFocus, disabled]);
|
|
126
126
|
const handleChangeText = (0, _react().useCallback)(txt => {
|
|
127
127
|
updateValue(txt ?? '');
|
|
@@ -135,22 +135,22 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
135
135
|
onBlurRef.current?.();
|
|
136
136
|
}, []);
|
|
137
137
|
const prevSubmitRef = (0, _react().useRef)({
|
|
138
|
-
value:
|
|
139
|
-
length:
|
|
138
|
+
value: normCode,
|
|
139
|
+
length: lenVal
|
|
140
140
|
});
|
|
141
141
|
(0, _react().useEffect)(() => {
|
|
142
142
|
const prev = prevSubmitRef.current;
|
|
143
143
|
prevSubmitRef.current = {
|
|
144
|
-
value:
|
|
145
|
-
length:
|
|
144
|
+
value: normCode,
|
|
145
|
+
length: lenVal
|
|
146
146
|
};
|
|
147
147
|
if (!onSubmitRef.current) return;
|
|
148
|
-
if (prev.length !==
|
|
149
|
-
if (
|
|
150
|
-
if (prev.value ===
|
|
151
|
-
onSubmitRef.current(
|
|
148
|
+
if (prev.length !== lenVal) return;
|
|
149
|
+
if (lenVal <= 0 || normCode.length !== lenVal) return;
|
|
150
|
+
if (prev.value === normCode) return;
|
|
151
|
+
onSubmitRef.current(normCode);
|
|
152
152
|
inputRef.current?.blur();
|
|
153
|
-
}, [
|
|
153
|
+
}, [lenVal, normCode]);
|
|
154
154
|
(0, _react().useEffect)(() => {
|
|
155
155
|
const shouldBlink = showCursor && focused && !disabled;
|
|
156
156
|
if (blinkTimer.current) {
|
|
@@ -175,11 +175,11 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
175
175
|
};
|
|
176
176
|
}, [disabled, focused, showCursor]);
|
|
177
177
|
const cells = Array.from({
|
|
178
|
-
length:
|
|
178
|
+
length: lenVal
|
|
179
179
|
}, (_, i) => {
|
|
180
|
-
const char =
|
|
180
|
+
const char = normCode?.[i];
|
|
181
181
|
const isFilled = !!char;
|
|
182
|
-
const showBlink = showCursor && focused && !disabled &&
|
|
182
|
+
const showBlink = showCursor && focused && !disabled && normCode.length === i && i < lenVal;
|
|
183
183
|
return {
|
|
184
184
|
key: i,
|
|
185
185
|
char,
|
|
@@ -187,35 +187,35 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
187
187
|
showBlink
|
|
188
188
|
};
|
|
189
189
|
});
|
|
190
|
-
const
|
|
191
|
-
const hasGutter =
|
|
190
|
+
const gutterVal = Math.max(0, (0, _number.parseNumberLike)(gutter, 0) ?? 0);
|
|
191
|
+
const hasGutter = gutterVal > 0;
|
|
192
192
|
const tipInfo = errorInfo ?? info;
|
|
193
|
-
const
|
|
194
|
-
const
|
|
193
|
+
const tipClr = errorInfo ? colors.error : colors.muted;
|
|
194
|
+
const bgClr = hasGutter ? colors.transparent : colors.background;
|
|
195
195
|
const hiddenInputProps = {
|
|
196
196
|
...HIP,
|
|
197
197
|
underlineColorAndroid: colors.transparent
|
|
198
198
|
};
|
|
199
|
-
const
|
|
199
|
+
const cellTxtBase = {
|
|
200
200
|
color: colors.text,
|
|
201
201
|
fontSize: sizing.cellTextSize,
|
|
202
202
|
fontWeight: typography.cellTextWeight,
|
|
203
203
|
fontFamily: typography.fontFamily
|
|
204
204
|
};
|
|
205
|
-
const
|
|
206
|
-
backgroundColor,
|
|
205
|
+
const wrapStyle = [S.w, {
|
|
206
|
+
backgroundColor: bgClr,
|
|
207
207
|
borderRadius: radii.wrapper,
|
|
208
208
|
paddingHorizontal: spacing.none,
|
|
209
209
|
opacity: disabled ? opacity.disabled : 1
|
|
210
210
|
}];
|
|
211
211
|
const sheetStyle = [S.s, {
|
|
212
212
|
borderRadius: hasGutter ? 0 : radii.wrapper,
|
|
213
|
-
backgroundColor
|
|
213
|
+
backgroundColor: bgClr
|
|
214
214
|
}];
|
|
215
215
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
216
216
|
style: style
|
|
217
217
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().Pressable, _extends({}, rest, {
|
|
218
|
-
style:
|
|
218
|
+
style: wrapStyle,
|
|
219
219
|
onPress: focusInput,
|
|
220
220
|
disabled: disabled,
|
|
221
221
|
accessibilityRole: "button",
|
|
@@ -225,7 +225,7 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
225
225
|
}), /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
226
226
|
style: sheetStyle
|
|
227
227
|
}, cells.map((item, i) => {
|
|
228
|
-
const filledTextStyle = [
|
|
228
|
+
const filledTextStyle = [cellTxtBase, cellTextStyle, !mask && item.isFilled && highlightTextStyle];
|
|
229
229
|
const baseCell = [S.c, {
|
|
230
230
|
backgroundColor: colors.background,
|
|
231
231
|
height: sizing.cellHeight
|
|
@@ -234,7 +234,7 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
234
234
|
baseCell.push(S.cg, {
|
|
235
235
|
borderRadius: radii.cellGutter
|
|
236
236
|
}, i > 0 && {
|
|
237
|
-
marginLeft:
|
|
237
|
+
marginLeft: gutterVal
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
;
|
|
@@ -269,7 +269,7 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
269
269
|
color: colors.border,
|
|
270
270
|
borderRadius: radii.cellGutter
|
|
271
271
|
})
|
|
272
|
-
}), !hasGutter && i <
|
|
272
|
+
}), !hasGutter && i < lenVal - 1 && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
273
273
|
style: (0, _hairline.createHairlineView)({
|
|
274
274
|
position: 'right',
|
|
275
275
|
color: colors.border,
|
|
@@ -279,11 +279,11 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
279
279
|
}));
|
|
280
280
|
}), /*#__PURE__*/_react().default.createElement(_reactNative().TextInput, _extends({
|
|
281
281
|
ref: inputRef,
|
|
282
|
-
value:
|
|
282
|
+
value: normCode,
|
|
283
283
|
editable: !disabled,
|
|
284
284
|
keyboardType: keyboardType,
|
|
285
285
|
inputMode: inputMode,
|
|
286
|
-
maxLength:
|
|
286
|
+
maxLength: lenVal,
|
|
287
287
|
autoFocus: false,
|
|
288
288
|
secureTextEntry: mask
|
|
289
289
|
}, hiddenInputProps, {
|
|
@@ -306,7 +306,7 @@ const PasswordInputImpl = (props, ref) => {
|
|
|
306
306
|
}]
|
|
307
307
|
}, (0, _validate.isText)(tipInfo) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
308
308
|
style: [S.it, {
|
|
309
|
-
color:
|
|
309
|
+
color: tipClr
|
|
310
310
|
}]
|
|
311
311
|
}, tipInfo) : tipInfo) : null);
|
|
312
312
|
};
|
|
@@ -634,17 +634,15 @@ function usePickerValue({
|
|
|
634
634
|
onChange,
|
|
635
635
|
onConfirm
|
|
636
636
|
}) {
|
|
637
|
-
const
|
|
637
|
+
const prep = (0, _react().useMemo)(() => prepareColumns(columns), [columns]);
|
|
638
638
|
const isControlled = valueProp !== undefined;
|
|
639
639
|
const onChangeRef = (0, _react().useRef)(onChange);
|
|
640
|
-
onChangeRef.current = onChange;
|
|
641
640
|
const onConfirmRef = (0, _react().useRef)(onConfirm);
|
|
641
|
+
onChangeRef.current = onChange;
|
|
642
642
|
onConfirmRef.current = onConfirm;
|
|
643
|
-
const [innerValue, setInnerValue] = (0, _react().useState)(() =>
|
|
644
|
-
const initial = toArrayValue(valueProp ?? defaultValue);
|
|
645
|
-
return normalizePicker(preparedColumns, initial).values;
|
|
646
|
-
});
|
|
643
|
+
const [innerValue, setInnerValue] = (0, _react().useState)(() => normalizePicker(prep, toArrayValue(valueProp ?? defaultValue)).values);
|
|
647
644
|
const innerValueRef = (0, _react().useRef)(innerValue);
|
|
645
|
+
innerValueRef.current = innerValue;
|
|
648
646
|
const commitValue = (0, _react().useCallback)(next => {
|
|
649
647
|
innerValueRef.current = next;
|
|
650
648
|
setInnerValue(next);
|
|
@@ -652,38 +650,32 @@ function usePickerValue({
|
|
|
652
650
|
(0, _react().useEffect)(() => {
|
|
653
651
|
if (!isControlled) return;
|
|
654
652
|
const next = toArrayValue(valueProp);
|
|
655
|
-
if (!(0, _utils.shallowEqualArray)(innerValueRef.current, next))
|
|
656
|
-
commitValue(next);
|
|
657
|
-
}
|
|
653
|
+
if (!(0, _utils.shallowEqualArray)(innerValueRef.current, next)) commitValue(next);
|
|
658
654
|
}, [commitValue, isControlled, valueProp]);
|
|
659
|
-
const
|
|
655
|
+
const norm = (0, _react().useMemo)(() => normalizePicker(prep, innerValue), [prep, innerValue]);
|
|
660
656
|
(0, _react().useEffect)(() => {
|
|
661
657
|
if (isControlled) return;
|
|
662
|
-
if (!(0, _utils.shallowEqualArray)(innerValue,
|
|
663
|
-
commitValue(
|
|
664
|
-
onChangeRef.current?.(
|
|
665
|
-
if (emitConfirmOnAutoSelect)
|
|
666
|
-
onConfirmRef.current?.(normalized.values, normalized.options);
|
|
667
|
-
}
|
|
658
|
+
if (!(0, _utils.shallowEqualArray)(innerValue, norm.values)) {
|
|
659
|
+
commitValue(norm.values);
|
|
660
|
+
onChangeRef.current?.(norm.values, norm.options);
|
|
661
|
+
if (emitConfirmOnAutoSelect) onConfirmRef.current?.(norm.values, norm.options);
|
|
668
662
|
}
|
|
669
|
-
}, [commitValue, emitConfirmOnAutoSelect, innerValue, isControlled,
|
|
663
|
+
}, [commitValue, emitConfirmOnAutoSelect, innerValue, isControlled, norm]);
|
|
670
664
|
const handleSelect = (0, _react().useCallback)((option, colIdx) => {
|
|
671
665
|
const next = [...innerValueRef.current];
|
|
672
666
|
next[colIdx] = option.value;
|
|
673
|
-
if (
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
const final = normalizePicker(preparedColumns, next);
|
|
667
|
+
if (prep.type === 'cascade') next.length = colIdx + 1;
|
|
668
|
+
const final = normalizePicker(prep, next);
|
|
677
669
|
if ((0, _utils.shallowEqualArray)(innerValueRef.current, final.values)) return;
|
|
678
670
|
commitValue(final.values);
|
|
679
671
|
onChangeRef.current?.(final.values, final.options);
|
|
680
|
-
}, [commitValue,
|
|
672
|
+
}, [commitValue, prep]);
|
|
681
673
|
const handleConfirm = (0, _react().useCallback)(() => {
|
|
682
|
-
onConfirmRef.current?.(
|
|
683
|
-
}, [
|
|
674
|
+
onConfirmRef.current?.(norm.values, norm.options);
|
|
675
|
+
}, [norm]);
|
|
684
676
|
return {
|
|
685
|
-
preparedColumns,
|
|
686
|
-
normalized,
|
|
677
|
+
preparedColumns: prep,
|
|
678
|
+
normalized: norm,
|
|
687
679
|
handleSelect,
|
|
688
680
|
handleConfirm
|
|
689
681
|
};
|
|
@@ -756,7 +748,7 @@ const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
|
756
748
|
swipeDuration
|
|
757
749
|
} = props;
|
|
758
750
|
const restVisible = Math.max(1, Math.floor((visibleItemCount - 1) / 2));
|
|
759
|
-
const valueIndexMap = (0, _react().useMemo)(() => new Map(options.map((
|
|
751
|
+
const valueIndexMap = (0, _react().useMemo)(() => new Map(options.map((opt, idx) => [opt.value, idx])), [options]);
|
|
760
752
|
const selIdx = (0, _react().useMemo)(() => {
|
|
761
753
|
if (!options.length) return 0;
|
|
762
754
|
const idx = valueIndexMap.get(value);
|
|
@@ -764,17 +756,17 @@ const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
|
764
756
|
return findEnabledIndex(options, startIdx);
|
|
765
757
|
}, [options, value, valueIndexMap]);
|
|
766
758
|
const handleChange = (0, _react().useCallback)(index => {
|
|
767
|
-
const
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
770
|
-
onSelect(
|
|
759
|
+
const tgt = findEnabledIndex(options, index);
|
|
760
|
+
const opt = options[tgt];
|
|
761
|
+
if (!opt || opt.disabled) return;
|
|
762
|
+
onSelect(opt, columnIndex, tgt);
|
|
771
763
|
}, [columnIndex, onSelect, options]);
|
|
772
764
|
const {
|
|
773
765
|
text: cText,
|
|
774
766
|
textDisabled: cDisabled,
|
|
775
767
|
textMuted: cMuted
|
|
776
768
|
} = tokens.colors;
|
|
777
|
-
const
|
|
769
|
+
const optFont = {
|
|
778
770
|
fontSize: tokens.typography.optionSize,
|
|
779
771
|
fontFamily: tokens.typography.fontFamily,
|
|
780
772
|
fontWeight: tokens.typography.optionWeight
|
|
@@ -784,8 +776,8 @@ const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
|
784
776
|
active = false,
|
|
785
777
|
disabled = false
|
|
786
778
|
} = meta ?? {};
|
|
787
|
-
const
|
|
788
|
-
const
|
|
779
|
+
const clr = disabled ? cDisabled : active ? cText : cMuted;
|
|
780
|
+
const cnt = optionRender ? optionRender(item, {
|
|
789
781
|
columnIndex,
|
|
790
782
|
active
|
|
791
783
|
}) : item.label ?? item.value;
|
|
@@ -793,7 +785,7 @@ const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
|
793
785
|
columnIndex,
|
|
794
786
|
active
|
|
795
787
|
});
|
|
796
|
-
const
|
|
788
|
+
const a11y = getOptionA11yLabel?.(item, {
|
|
797
789
|
columnIndex,
|
|
798
790
|
active
|
|
799
791
|
});
|
|
@@ -803,15 +795,15 @@ const PickerColumn = /*#__PURE__*/_react().default.memo(props => {
|
|
|
803
795
|
minHeight: itemHeight
|
|
804
796
|
}],
|
|
805
797
|
testID: testID,
|
|
806
|
-
accessible: !!
|
|
807
|
-
accessibilityLabel:
|
|
808
|
-
}, (0, _validate.isText)(
|
|
798
|
+
accessible: !!a11y,
|
|
799
|
+
accessibilityLabel: a11y
|
|
800
|
+
}, (0, _validate.isText)(cnt) ? /*#__PURE__*/_react().default.createElement(_reactNative().Text, {
|
|
809
801
|
numberOfLines: 1,
|
|
810
|
-
style: [S.optTxt,
|
|
811
|
-
color
|
|
802
|
+
style: [S.optTxt, optFont, {
|
|
803
|
+
color: clr
|
|
812
804
|
}]
|
|
813
|
-
},
|
|
814
|
-
}, [cText, cDisabled, cMuted, columnIndex, getOptionA11yLabel, getOptionTestID, itemHeight,
|
|
805
|
+
}, cnt) : cnt);
|
|
806
|
+
}, [cText, cDisabled, cMuted, columnIndex, getOptionA11yLabel, getOptionTestID, itemHeight, optFont, optionRender]);
|
|
815
807
|
return /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
816
808
|
style: [W.column, {
|
|
817
809
|
height: itemHeight * visibleItemCount
|
|
@@ -871,12 +863,12 @@ const PickerImpl = props => {
|
|
|
871
863
|
testID,
|
|
872
864
|
...rest
|
|
873
865
|
} = props;
|
|
874
|
-
const
|
|
866
|
+
const visCnt = getVisibleCount(visibleItemCountProp ?? tokens.defaults.visibleItemCount);
|
|
875
867
|
const {
|
|
876
|
-
normalized,
|
|
868
|
+
normalized: norm,
|
|
877
869
|
handleSelect,
|
|
878
870
|
handleConfirm,
|
|
879
|
-
preparedColumns
|
|
871
|
+
preparedColumns: prep
|
|
880
872
|
} = usePickerValue({
|
|
881
873
|
columns,
|
|
882
874
|
valueProp,
|
|
@@ -885,7 +877,7 @@ const PickerImpl = props => {
|
|
|
885
877
|
onChange,
|
|
886
878
|
onConfirm
|
|
887
879
|
});
|
|
888
|
-
const isCascade =
|
|
880
|
+
const isCascade = prep.type === 'cascade';
|
|
889
881
|
const toolbarFont = {
|
|
890
882
|
fontSize: tokens.typography.toolbarSize,
|
|
891
883
|
fontFamily: tokens.typography.fontFamily,
|
|
@@ -928,21 +920,21 @@ const PickerImpl = props => {
|
|
|
928
920
|
right: 0
|
|
929
921
|
})
|
|
930
922
|
})) : null;
|
|
931
|
-
const wrapperH = itemHeight *
|
|
932
|
-
const
|
|
933
|
-
const indicatorOff = itemHeight *
|
|
923
|
+
const wrapperH = itemHeight * visCnt;
|
|
924
|
+
const maskVisCnt = Math.max(1, Math.floor((visCnt - 1) / 2));
|
|
925
|
+
const indicatorOff = itemHeight * maskVisCnt;
|
|
934
926
|
const maskH = indicatorOff;
|
|
935
|
-
const
|
|
936
|
-
const
|
|
937
|
-
const columnsContent =
|
|
938
|
-
const key = isCascade ? `${colIdx}-${
|
|
927
|
+
const hasCols = norm.columns.length > 0;
|
|
928
|
+
const effMaskColor = maskColor ?? tokens.colors.mask;
|
|
929
|
+
const columnsContent = hasCols ? norm.columns.map((column, colIdx) => {
|
|
930
|
+
const key = isCascade ? `${colIdx}-${norm.values.slice(0, colIdx).map(String).join('|')}` : String(colIdx);
|
|
939
931
|
return /*#__PURE__*/_react().default.createElement(PickerColumn, {
|
|
940
932
|
key: key,
|
|
941
933
|
columnIndex: colIdx,
|
|
942
934
|
options: column,
|
|
943
|
-
value:
|
|
935
|
+
value: norm.values[colIdx],
|
|
944
936
|
itemHeight: itemHeight,
|
|
945
|
-
visibleItemCount:
|
|
937
|
+
visibleItemCount: visCnt,
|
|
946
938
|
decelerationRate: decelerationRate,
|
|
947
939
|
scrollEventThrottle: scrollEventThrottle,
|
|
948
940
|
optionRender: optionRender,
|
|
@@ -967,7 +959,7 @@ const PickerImpl = props => {
|
|
|
967
959
|
}, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
968
960
|
style: S.columns,
|
|
969
961
|
pointerEvents: loading ? 'none' : 'auto'
|
|
970
|
-
}, columnsTop, columnsContent, columnsBottom,
|
|
962
|
+
}, columnsTop, columnsContent, columnsBottom, hasCols && /*#__PURE__*/_react().default.createElement(_react().default.Fragment, null, /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
971
963
|
pointerEvents: "none",
|
|
972
964
|
style: [S.indicator, {
|
|
973
965
|
top: indicatorOff,
|
|
@@ -990,12 +982,12 @@ const PickerImpl = props => {
|
|
|
990
982
|
})), /*#__PURE__*/_react().default.createElement(GradientMask, {
|
|
991
983
|
position: "top",
|
|
992
984
|
height: maskH,
|
|
993
|
-
color:
|
|
985
|
+
color: effMaskColor,
|
|
994
986
|
maskType: maskType
|
|
995
987
|
}), /*#__PURE__*/_react().default.createElement(GradientMask, {
|
|
996
988
|
position: "bottom",
|
|
997
989
|
height: maskH,
|
|
998
|
-
color:
|
|
990
|
+
color: effMaskColor,
|
|
999
991
|
maskType: maskType
|
|
1000
992
|
}))), loading && /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
1001
993
|
style: [S.loading, {
|
|
@@ -129,7 +129,7 @@ const PopupImpl = props => {
|
|
|
129
129
|
round,
|
|
130
130
|
safeArea = false,
|
|
131
131
|
safeAreaInsetTop = false,
|
|
132
|
-
safeAreaInsetBottom:
|
|
132
|
+
safeAreaInsetBottom: safeBottomP,
|
|
133
133
|
lockScroll = true,
|
|
134
134
|
destroyOnClose = true,
|
|
135
135
|
duration = 300,
|
|
@@ -149,9 +149,9 @@ const PopupImpl = props => {
|
|
|
149
149
|
...rest
|
|
150
150
|
} = props;
|
|
151
151
|
const placement = placementProp ?? position ?? 'center';
|
|
152
|
-
const
|
|
152
|
+
const closeOvl = closeOnClickOverlay ?? closeOnOverlayPress ?? true;
|
|
153
153
|
const isCenter = placement === 'center';
|
|
154
|
-
const safeAreaInsetBottom =
|
|
154
|
+
const safeAreaInsetBottom = safeBottomP ?? false;
|
|
155
155
|
const tokens = (0, _tokens.usePopupTokens)(tokensOverride);
|
|
156
156
|
const reducedMotion = (0, _animation.useReducedMotion)();
|
|
157
157
|
const cbRef = (0, _react().useRef)({
|
|
@@ -186,6 +186,7 @@ const PopupImpl = props => {
|
|
|
186
186
|
},
|
|
187
187
|
title: {
|
|
188
188
|
color: c.title,
|
|
189
|
+
fontFamily: t.fontFamily,
|
|
189
190
|
fontSize: t.titleSize,
|
|
190
191
|
fontWeight: t.titleWeight,
|
|
191
192
|
marginHorizontal: s.descriptionHorizontal,
|
|
@@ -199,6 +200,7 @@ const PopupImpl = props => {
|
|
|
199
200
|
},
|
|
200
201
|
desc: {
|
|
201
202
|
color: c.description,
|
|
203
|
+
fontFamily: t.fontFamily,
|
|
202
204
|
fontSize: t.descriptionSize,
|
|
203
205
|
lineHeight: t.descriptionLineHeight
|
|
204
206
|
},
|
|
@@ -228,7 +230,7 @@ const PopupImpl = props => {
|
|
|
228
230
|
const [mounted, setMounted] = (0, _react().useState)(visible);
|
|
229
231
|
const [interVis, setInterVis] = (0, _react().useState)(visible);
|
|
230
232
|
const isOpen = visible || interVis;
|
|
231
|
-
const canCloseOvl =
|
|
233
|
+
const canCloseOvl = closeOvl && (onClose || beforeClose);
|
|
232
234
|
const progress = (0, _react().useRef)(new (_reactNative().Animated.Value)(0)).current;
|
|
233
235
|
const animRef = (0, _react().useRef)(null);
|
|
234
236
|
const seqRef = (0, _react().useRef)(0);
|
|
@@ -254,9 +256,7 @@ const PopupImpl = props => {
|
|
|
254
256
|
finished
|
|
255
257
|
}) => {
|
|
256
258
|
if (!finished || seq !== seqRef.current) return;
|
|
257
|
-
if (show) {
|
|
258
|
-
cbRef.current.onOpened?.();
|
|
259
|
-
} else {
|
|
259
|
+
if (show) cbRef.current.onOpened?.();else {
|
|
260
260
|
setInterVis(false);
|
|
261
261
|
if (destroyOnClose) setMounted(false);
|
|
262
262
|
cbRef.current.onClosed?.();
|
|
@@ -301,8 +301,8 @@ const PopupImpl = props => {
|
|
|
301
301
|
}, [closeOnPopstate, requestClose, visible]);
|
|
302
302
|
const handleOvlPress = (0, _react().useCallback)(() => {
|
|
303
303
|
cbRef.current.onClickOverlay?.();
|
|
304
|
-
if (
|
|
305
|
-
}, [requestClose,
|
|
304
|
+
if (closeOvl) requestClose('overlay');
|
|
305
|
+
}, [requestClose, closeOvl]);
|
|
306
306
|
const handleClosePress = (0, _react().useCallback)(() => requestClose('close-icon'), [requestClose]);
|
|
307
307
|
const handleEscape = (0, _react().useCallback)(() => requestClose('close'), [requestClose]);
|
|
308
308
|
const {
|
|
@@ -321,7 +321,7 @@ const PopupImpl = props => {
|
|
|
321
321
|
} = (0, _hooks.useAriaOverlay)({
|
|
322
322
|
isOpen,
|
|
323
323
|
onClose: () => requestClose('overlay'),
|
|
324
|
-
isDismissable:
|
|
324
|
+
isDismissable: closeOvl,
|
|
325
325
|
overlayProps: {
|
|
326
326
|
...(_reactNative().Platform.OS === 'android' ? {} : {
|
|
327
327
|
accessibilityRole: 'dialog'
|
|
@@ -21,13 +21,12 @@ const PortalComponentImpl = ({
|
|
|
21
21
|
}, _ref) => {
|
|
22
22
|
const manager = (0, _react().useContext)(_PortalContext.PortalContext) ?? _PortalHost.portalManager;
|
|
23
23
|
const keyRef = (0, _react().useRef)(null);
|
|
24
|
-
const
|
|
25
|
-
const content = shouldRender ? children : null;
|
|
24
|
+
const content = isOpen ?? visible ?? true ? children : null;
|
|
26
25
|
(0, _react().useLayoutEffect)(() => {
|
|
27
|
-
|
|
26
|
+
keyRef.current === null ? keyRef.current = manager.mount(content) : manager.update(keyRef.current, content);
|
|
28
27
|
}, [manager, content]);
|
|
29
28
|
(0, _react().useLayoutEffect)(() => () => {
|
|
30
|
-
if (keyRef.current
|
|
29
|
+
if (keyRef.current != null) {
|
|
31
30
|
manager.unmount(keyRef.current);
|
|
32
31
|
keyRef.current = null;
|
|
33
32
|
}
|