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
|
@@ -13,15 +13,17 @@ import { useLocale } from '../config-provider/useLocale';
|
|
|
13
13
|
import { SafeAreaView } from '../safe-area-view';
|
|
14
14
|
import { useNumberKeyboardTokens } from './tokens';
|
|
15
15
|
const registry = new Set();
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const NUM_KEYS = ['1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
17
|
+
const ZERO = '0';
|
|
18
|
+
const RE_NUM_LIKE = /^\d+$|^\.$|^x$/i;
|
|
18
19
|
const shuffle = list => {
|
|
19
|
-
const
|
|
20
|
-
for (let i =
|
|
20
|
+
const n = [...list];
|
|
21
|
+
for (let i = n.length - 1; i > 0; i--) {
|
|
21
22
|
const j = Math.floor(Math.random() * (i + 1));
|
|
22
|
-
[
|
|
23
|
+
[n[i], n[j]] = [n[j], n[i]];
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
;
|
|
26
|
+
return n;
|
|
25
27
|
};
|
|
26
28
|
const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
27
29
|
const {
|
|
@@ -42,8 +44,8 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
42
44
|
onBlur,
|
|
43
45
|
onHide,
|
|
44
46
|
onShow,
|
|
45
|
-
value:
|
|
46
|
-
defaultValue:
|
|
47
|
+
value: _v,
|
|
48
|
+
defaultValue: _dv,
|
|
47
49
|
maxlength: maxlengthProp,
|
|
48
50
|
blurOnClose = true,
|
|
49
51
|
safeAreaInsetBottom = true,
|
|
@@ -63,7 +65,8 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
63
65
|
radii,
|
|
64
66
|
shadow,
|
|
65
67
|
sizing,
|
|
66
|
-
spacing
|
|
68
|
+
spacing,
|
|
69
|
+
typography
|
|
67
70
|
} = tokens;
|
|
68
71
|
const [value, setValue] = useControllableValue(props, {
|
|
69
72
|
defaultValue: '',
|
|
@@ -71,37 +74,39 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
71
74
|
defaultValuePropName: 'defaultValue',
|
|
72
75
|
trigger: 'onChange'
|
|
73
76
|
});
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
const curVal = value ?? '';
|
|
78
|
+
const maxLen = (() => {
|
|
79
|
+
const p = parseNumberLike(maxlengthProp, undefined);
|
|
80
|
+
return p != null && Number.isFinite(p) && p >= 0 ? Math.floor(p) : undefined;
|
|
81
|
+
})();
|
|
82
|
+
const valRef = useRef(curVal);
|
|
83
|
+
const maxRef = useRef(maxLen);
|
|
84
|
+
const onCloseRef = useRef(onClose);
|
|
85
|
+
const onBlurRef = useRef(onBlur);
|
|
86
|
+
const onShowRef = useRef(onShow);
|
|
87
|
+
const onHideRef = useRef(onHide);
|
|
88
|
+
const onDelRef = useRef(onDelete);
|
|
89
|
+
const onInpRef = useRef(onInput);
|
|
90
|
+
valRef.current = curVal;
|
|
91
|
+
maxRef.current = maxLen;
|
|
87
92
|
onCloseRef.current = onClose;
|
|
88
93
|
onBlurRef.current = onBlur;
|
|
89
94
|
onShowRef.current = onShow;
|
|
90
95
|
onHideRef.current = onHide;
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
onDelRef.current = onDelete;
|
|
97
|
+
onInpRef.current = onInput;
|
|
93
98
|
const isCustom = theme === 'custom';
|
|
94
|
-
const
|
|
95
|
-
const
|
|
99
|
+
const defClose = locale?.vanNumberKeyboard?.close ?? 'Done';
|
|
100
|
+
const closeTxt = isCustom ? closeButtonText ?? defClose : closeButtonText;
|
|
96
101
|
const handleClose = useCallback(() => {
|
|
97
102
|
onCloseRef.current?.();
|
|
98
103
|
if (blurOnClose) onBlurRef.current?.();
|
|
99
104
|
}, [blurOnClose]);
|
|
100
|
-
const
|
|
105
|
+
const prevVis = useRef(visible);
|
|
101
106
|
useEffect(() => {
|
|
102
|
-
if (visible && !
|
|
103
|
-
if (!visible &&
|
|
104
|
-
|
|
107
|
+
if (visible && !prevVis.current) onShowRef.current?.();
|
|
108
|
+
if (!visible && prevVis.current) onHideRef.current?.();
|
|
109
|
+
prevVis.current = visible;
|
|
105
110
|
}, [visible]);
|
|
106
111
|
useEffect(() => {
|
|
107
112
|
if (visible) {
|
|
@@ -115,91 +120,94 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
115
120
|
};
|
|
116
121
|
}, [visible, handleClose]);
|
|
117
122
|
const keys = useMemo(() => {
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
text,
|
|
123
|
+
const sh = randomKeyOrder && visible;
|
|
124
|
+
const nK = sh ? shuffle(NUM_KEYS) : NUM_KEYS;
|
|
125
|
+
const mat = nK.map(t => ({
|
|
126
|
+
text: t,
|
|
122
127
|
type: ''
|
|
123
128
|
}));
|
|
124
129
|
if (isCustom) {
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
text:
|
|
130
|
+
const e = Array.isArray(extraKey) ? extraKey : extraKey ? [extraKey] : [];
|
|
131
|
+
if (e.length === 1) mat.push({
|
|
132
|
+
text: ZERO,
|
|
128
133
|
type: '',
|
|
129
134
|
wider: true
|
|
130
135
|
}, {
|
|
131
|
-
text:
|
|
136
|
+
text: e[0],
|
|
132
137
|
type: 'extra'
|
|
133
|
-
});else if (
|
|
134
|
-
text:
|
|
138
|
+
});else if (e.length >= 2) mat.push({
|
|
139
|
+
text: e[0],
|
|
135
140
|
type: 'extra'
|
|
136
141
|
}, {
|
|
137
|
-
text:
|
|
142
|
+
text: ZERO,
|
|
138
143
|
type: ''
|
|
139
144
|
}, {
|
|
140
|
-
text:
|
|
145
|
+
text: e[1],
|
|
141
146
|
type: 'extra'
|
|
142
|
-
});else
|
|
143
|
-
text:
|
|
147
|
+
});else mat.push({
|
|
148
|
+
text: ZERO,
|
|
144
149
|
type: ''
|
|
145
150
|
});
|
|
146
|
-
return
|
|
151
|
+
return mat;
|
|
147
152
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
text:
|
|
153
|
+
const nE = Array.isArray(extraKey) ? extraKey[0] ?? '' : extraKey ?? '';
|
|
154
|
+
mat.push({
|
|
155
|
+
text: nE,
|
|
151
156
|
type: 'extra'
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
text: ZERO_KEY,
|
|
157
|
+
}, {
|
|
158
|
+
text: ZERO,
|
|
155
159
|
type: ''
|
|
156
|
-
}
|
|
157
|
-
matrix.push({
|
|
160
|
+
}, {
|
|
158
161
|
type: showDeleteKey ? 'delete' : '',
|
|
159
162
|
text: showDeleteKey ? undefined : ''
|
|
160
163
|
});
|
|
161
|
-
return
|
|
164
|
+
return mat;
|
|
162
165
|
}, [extraKey, isCustom, randomKeyOrder, showDeleteKey, visible]);
|
|
163
166
|
const handleInput = useCallback((text, type) => {
|
|
164
167
|
if (type === 'delete') {
|
|
165
|
-
const
|
|
166
|
-
if (!
|
|
167
|
-
|
|
168
|
-
setValue(
|
|
168
|
+
const c = valRef.current;
|
|
169
|
+
if (!c) return;
|
|
170
|
+
onDelRef.current?.();
|
|
171
|
+
setValue(c.slice(0, -1));
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
171
174
|
if (type === 'close' || type === 'extra' && !text) {
|
|
172
175
|
handleClose();
|
|
173
176
|
return;
|
|
174
177
|
}
|
|
178
|
+
;
|
|
175
179
|
if (!text) return;
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
if (
|
|
179
|
-
|
|
180
|
-
setValue(`${
|
|
180
|
+
const c = valRef.current;
|
|
181
|
+
const m = maxRef.current;
|
|
182
|
+
if (m !== undefined && c.length >= m) return;
|
|
183
|
+
onInpRef.current?.(text);
|
|
184
|
+
setValue(`${c}${text}`);
|
|
181
185
|
}, [handleClose, setValue]);
|
|
182
|
-
const
|
|
183
|
-
const renderKey = useCallback((key, index,
|
|
184
|
-
const
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
186
|
+
const winShadow = useMemo(() => createPlatformShadow(shadow), [shadow.color, shadow.elevation, shadow.offsetY, shadow.opacity, shadow.radius]);
|
|
187
|
+
const renderKey = useCallback((key, index, isClose = false, fullW = false, customH) => {
|
|
188
|
+
const kt = key.type;
|
|
189
|
+
const isPh = kt === '' && !key.text;
|
|
190
|
+
const dis = isPh || isClose && closeButtonLoading;
|
|
191
|
+
const onP = dis ? undefined : () => handleInput(key.text, kt);
|
|
192
|
+
const bg = isClose ? colors.closeBackground : colors.keyBackground;
|
|
193
|
+
const aBg = isClose ? colors.closeActiveBackground : colors.keyActiveBackground;
|
|
194
|
+
const tInact = isClose ? colors.closeText : colors.keyText;
|
|
195
|
+
const tPress = isClose ? colors.closeText : colors.keyTextActive;
|
|
196
|
+
const kH = customH ?? (isClose ? sizing.closeHeight : sizing.keyHeight);
|
|
197
|
+
const auxFs = sizing.auxFontSize ?? Math.round(sizing.fontSize * 0.64);
|
|
198
|
+
const defIconFs = sizing.defaultIconFontSize ?? sizing.fontSize;
|
|
199
|
+
const kTxt = key.text ?? '';
|
|
200
|
+
const cnt = kt === 'delete' ? deleteRender?.() ?? deleteButtonText ?? '⌫' : kt === 'extra' ? extraKeyRender ? extraKeyRender(kTxt) : kTxt || '⌨︎' : kt === 'close' ? closeTxt ?? defClose : numberKeyRender ? numberKeyRender(kTxt) : kTxt;
|
|
201
|
+
const isDefIcon = kt === 'delete' && deleteRender == null && deleteButtonText == null || kt === 'extra' && !extraKeyRender && !kTxt;
|
|
202
|
+
const isNumLike = kt === 'extra' && typeof cnt === 'string' && RE_NUM_LIKE.test(cnt);
|
|
203
|
+
const tFs = kt === '' ? sizing.fontSize : isDefIcon ? defIconFs : isNumLike ? sizing.fontSize : auxFs;
|
|
196
204
|
return /*#__PURE__*/React.createElement(Pressable, {
|
|
197
|
-
key: `${
|
|
198
|
-
onPress:
|
|
199
|
-
disabled:
|
|
205
|
+
key: `${kt}-${index}-${key.text ?? index}`,
|
|
206
|
+
onPress: onP,
|
|
207
|
+
disabled: dis,
|
|
200
208
|
style: [{
|
|
201
|
-
opacity:
|
|
202
|
-
},
|
|
209
|
+
opacity: isPh ? 1 : dis ? 0.6 : 1
|
|
210
|
+
}, fullW ? {
|
|
203
211
|
width: '100%',
|
|
204
212
|
flexBasis: 'auto',
|
|
205
213
|
flexGrow: 0,
|
|
@@ -210,184 +218,192 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
210
218
|
flexShrink: 1,
|
|
211
219
|
minWidth: 0
|
|
212
220
|
}],
|
|
213
|
-
accessible: !
|
|
214
|
-
accessibilityRole:
|
|
215
|
-
accessibilityLabel:
|
|
216
|
-
accessibilityState:
|
|
217
|
-
disabled: !!
|
|
221
|
+
accessible: !isPh,
|
|
222
|
+
accessibilityRole: isPh ? undefined : 'button',
|
|
223
|
+
accessibilityLabel: isPh ? undefined : kt === 'delete' ? 'delete' : kt === 'close' ? closeTxt ?? 'close' : kt === 'extra' ? kTxt || 'collapse' : kTxt,
|
|
224
|
+
accessibilityState: isPh ? undefined : {
|
|
225
|
+
disabled: !!dis
|
|
218
226
|
},
|
|
219
|
-
accessibilityElementsHidden:
|
|
220
|
-
importantForAccessibility:
|
|
227
|
+
accessibilityElementsHidden: isPh,
|
|
228
|
+
importantForAccessibility: isPh ? 'no-hide-descendants' : undefined
|
|
221
229
|
}, ({
|
|
222
230
|
pressed
|
|
223
231
|
}) => {
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
232
|
+
const isP = pressed && !dis;
|
|
233
|
+
const kBg = dis ? colors.keyBackground : isP ? aBg : bg;
|
|
234
|
+
const tClr = isP ? tPress : tInact;
|
|
227
235
|
return /*#__PURE__*/React.createElement(View, {
|
|
228
236
|
style: [S.k, {
|
|
229
|
-
height:
|
|
230
|
-
backgroundColor:
|
|
237
|
+
height: kH,
|
|
238
|
+
backgroundColor: kBg,
|
|
231
239
|
borderRadius: radii.key
|
|
232
240
|
}]
|
|
233
|
-
},
|
|
241
|
+
}, isClose && closeButtonLoading ? /*#__PURE__*/React.createElement(Loading, {
|
|
234
242
|
size: 18,
|
|
235
|
-
color:
|
|
236
|
-
}) : isRenderable(
|
|
237
|
-
color:
|
|
238
|
-
|
|
243
|
+
color: tClr
|
|
244
|
+
}) : isRenderable(cnt) ? renderTextOrNode(cnt, [S.kTxt, {
|
|
245
|
+
color: tClr,
|
|
246
|
+
fontFamily: typography.fontFamily,
|
|
247
|
+
fontSize: tFs
|
|
239
248
|
}]) : null);
|
|
240
249
|
});
|
|
241
|
-
}, [closeButtonLoading, colors.closeActiveBackground, colors.closeBackground, colors.closeText, colors.keyActiveBackground, colors.keyBackground, colors.keyText, colors.keyTextActive, deleteButtonText, deleteRender, extraKeyRender, handleInput, numberKeyRender, radii.key, sizing.closeHeight, sizing.fontSize, sizing.keyHeight,
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const [
|
|
250
|
+
}, [closeButtonLoading, colors.closeActiveBackground, colors.closeBackground, colors.closeText, colors.keyActiveBackground, colors.keyBackground, colors.keyText, colors.keyTextActive, defClose, deleteButtonText, deleteRender, extraKeyRender, handleInput, numberKeyRender, radii.key, sizing.auxFontSize, sizing.closeHeight, sizing.defaultIconFontSize, sizing.fontSize, sizing.keyHeight, typography.fontFamily, closeTxt]);
|
|
251
|
+
const animVal = useRef(new Animated.Value(visible ? 1 : 0)).current;
|
|
252
|
+
const animRef = useRef(null);
|
|
253
|
+
const seqRef = useRef(0);
|
|
254
|
+
const [contentH, setContentH] = useState(0);
|
|
246
255
|
const [shouldRender, setShouldRender] = useState(visible);
|
|
247
|
-
const
|
|
256
|
+
const effD = reducedMotion ? 0 : transition === false ? 0 : transitionDuration;
|
|
248
257
|
useEffect(() => {
|
|
249
|
-
|
|
250
|
-
const
|
|
258
|
+
seqRef.current += 1;
|
|
259
|
+
const seq = seqRef.current;
|
|
251
260
|
if (visible) setShouldRender(true);
|
|
252
|
-
|
|
253
|
-
const
|
|
261
|
+
animRef.current?.stop();
|
|
262
|
+
const a = Animated.timing(animVal, {
|
|
254
263
|
toValue: visible ? 1 : 0,
|
|
255
|
-
duration:
|
|
264
|
+
duration: effD,
|
|
256
265
|
useNativeDriver: nativeDriverEnabled,
|
|
257
266
|
easing: visible ? Easing.out(Easing.cubic) : Easing.in(Easing.cubic),
|
|
258
267
|
isInteraction: false
|
|
259
268
|
});
|
|
260
|
-
|
|
261
|
-
|
|
269
|
+
animRef.current = a;
|
|
270
|
+
a.start(({
|
|
262
271
|
finished
|
|
263
272
|
}) => {
|
|
264
|
-
if (finished && !visible &&
|
|
273
|
+
if (finished && !visible && seqRef.current === seq) setShouldRender(false);
|
|
265
274
|
});
|
|
266
275
|
return () => {
|
|
267
|
-
|
|
268
|
-
|
|
276
|
+
animRef.current?.stop();
|
|
277
|
+
animRef.current = null;
|
|
269
278
|
};
|
|
270
|
-
}, [
|
|
271
|
-
const translateY =
|
|
279
|
+
}, [animVal, visible, effD]);
|
|
280
|
+
const translateY = animVal.interpolate({
|
|
272
281
|
inputRange: [0, 1],
|
|
273
|
-
outputRange: [
|
|
282
|
+
outputRange: [contentH || 320, 0]
|
|
274
283
|
});
|
|
275
|
-
const
|
|
284
|
+
const onLayout = useCallback(e => {
|
|
276
285
|
const {
|
|
277
286
|
height
|
|
278
287
|
} = e.nativeEvent.layout;
|
|
279
|
-
|
|
288
|
+
setContentH(prev => Math.abs(height - prev) > 0.5 ? height : prev);
|
|
280
289
|
}, []);
|
|
281
|
-
const
|
|
282
|
-
const
|
|
290
|
+
const hasHdr = !isCustom && (title || closeButtonText);
|
|
291
|
+
const dblH = sizing.keyHeight * 2 + spacing.keyGap;
|
|
283
292
|
const memoized = useMemo(() => {
|
|
284
|
-
const
|
|
285
|
-
|
|
293
|
+
const kg = spacing.keyGap;
|
|
294
|
+
const ph = spacing.paddingHorizontal;
|
|
295
|
+
const tp = spacing.titlePadding;
|
|
296
|
+
const hP = {
|
|
297
|
+
paddingHorizontal: tp
|
|
286
298
|
};
|
|
287
|
-
const
|
|
299
|
+
const dC = [S.dRow, {
|
|
288
300
|
flexDirection: 'column',
|
|
289
301
|
flexWrap: 'nowrap',
|
|
290
|
-
paddingHorizontal:
|
|
291
|
-
paddingTop:
|
|
292
|
-
paddingBottom:
|
|
293
|
-
gap:
|
|
302
|
+
paddingHorizontal: ph,
|
|
303
|
+
paddingTop: kg,
|
|
304
|
+
paddingBottom: kg,
|
|
305
|
+
gap: kg
|
|
294
306
|
}];
|
|
295
|
-
const
|
|
307
|
+
const dL = {
|
|
296
308
|
flexDirection: 'row',
|
|
297
|
-
gap:
|
|
309
|
+
gap: kg
|
|
298
310
|
};
|
|
299
|
-
const
|
|
300
|
-
paddingHorizontal:
|
|
301
|
-
paddingTop:
|
|
302
|
-
paddingBottom:
|
|
311
|
+
const cR = [S.cRow, {
|
|
312
|
+
paddingHorizontal: ph,
|
|
313
|
+
paddingTop: hasHdr ? 0 : kg,
|
|
314
|
+
paddingBottom: kg,
|
|
303
315
|
width: '100%'
|
|
304
316
|
}];
|
|
305
|
-
const
|
|
317
|
+
const cM = [S.cMat, {
|
|
306
318
|
flexDirection: 'column',
|
|
307
319
|
flexWrap: 'nowrap',
|
|
308
|
-
gap:
|
|
320
|
+
gap: kg
|
|
309
321
|
}];
|
|
310
|
-
const
|
|
311
|
-
gap:
|
|
312
|
-
marginLeft:
|
|
322
|
+
const cS = [S.cSide, {
|
|
323
|
+
gap: kg,
|
|
324
|
+
marginLeft: kg
|
|
313
325
|
}];
|
|
314
|
-
const
|
|
315
|
-
key,
|
|
326
|
+
const ents = keys.map((k, i) => ({
|
|
327
|
+
key: k,
|
|
316
328
|
index: i
|
|
317
329
|
}));
|
|
318
|
-
const
|
|
319
|
-
for (let i = 0; i <
|
|
320
|
-
const
|
|
321
|
-
style:
|
|
322
|
-
},
|
|
330
|
+
const dLns = [];
|
|
331
|
+
for (let i = 0; i < ents.length; i += 3) dLns.push(ents.slice(i, i + 3));
|
|
332
|
+
const dN = /*#__PURE__*/React.createElement(View, {
|
|
333
|
+
style: dC
|
|
334
|
+
}, dLns.map((line, li) => /*#__PURE__*/React.createElement(View, {
|
|
323
335
|
key: `l-${li}`,
|
|
324
|
-
style:
|
|
325
|
-
}, line.map(
|
|
326
|
-
const
|
|
327
|
-
for (let i = 0; i < 9 && i <
|
|
328
|
-
const
|
|
329
|
-
if (
|
|
336
|
+
style: dL
|
|
337
|
+
}, line.map(it => renderKey(it.key, it.index)))));
|
|
338
|
+
const cLns = [];
|
|
339
|
+
for (let i = 0; i < 9 && i < ents.length; i += 3) cLns.push(ents.slice(i, i + 3));
|
|
340
|
+
const tl = ents.slice(9);
|
|
341
|
+
if (tl.length === 1) cLns.push([{
|
|
330
342
|
key: {
|
|
331
343
|
type: ''
|
|
332
344
|
},
|
|
333
345
|
index: 1000001
|
|
334
|
-
},
|
|
346
|
+
}, tl[0], {
|
|
335
347
|
key: {
|
|
336
348
|
type: ''
|
|
337
349
|
},
|
|
338
350
|
index: 1000002
|
|
339
|
-
}]);else if (
|
|
340
|
-
const
|
|
341
|
-
style:
|
|
342
|
-
},
|
|
351
|
+
}]);else if (tl.length) cLns.push(tl);
|
|
352
|
+
const cMN = /*#__PURE__*/React.createElement(View, {
|
|
353
|
+
style: cM
|
|
354
|
+
}, cLns.map((line, li) => /*#__PURE__*/React.createElement(View, {
|
|
343
355
|
key: `cl-${li}`,
|
|
344
|
-
style:
|
|
345
|
-
}, line.map(
|
|
346
|
-
const
|
|
356
|
+
style: dL
|
|
357
|
+
}, line.map(it => renderKey(it.key, it.index)))));
|
|
358
|
+
const delN = showDeleteKey && renderKey({
|
|
347
359
|
type: 'delete'
|
|
348
|
-
}, 999, false, true,
|
|
349
|
-
const
|
|
360
|
+
}, 999, false, true, dblH);
|
|
361
|
+
const closeN = renderKey({
|
|
350
362
|
type: 'close'
|
|
351
|
-
}, 1000, true, true,
|
|
352
|
-
const
|
|
353
|
-
|
|
363
|
+
}, 1000, true, true, dblH);
|
|
364
|
+
const tS = {
|
|
365
|
+
color: colors.title,
|
|
366
|
+
fontFamily: typography.fontFamily,
|
|
367
|
+
fontSize: sizing.titleFontSize
|
|
368
|
+
};
|
|
369
|
+
const closeStyle = {
|
|
370
|
+
color: colors.title,
|
|
371
|
+
fontFamily: typography.fontFamily,
|
|
372
|
+
fontSize: sizing.auxFontSize ?? Math.round(sizing.fontSize * 0.64)
|
|
373
|
+
};
|
|
374
|
+
const hN = hasHdr ? /*#__PURE__*/React.createElement(View, {
|
|
375
|
+
style: [S.hdr, hP]
|
|
354
376
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
355
|
-
style: [S.
|
|
356
|
-
color: colors.title,
|
|
357
|
-
fontSize: sizing.titleFontSize
|
|
358
|
-
}],
|
|
377
|
+
style: [S.tBold, S.tCenter, tS],
|
|
359
378
|
numberOfLines: 1
|
|
360
|
-
}, title),
|
|
379
|
+
}, title), closeTxt && /*#__PURE__*/React.createElement(Pressable, {
|
|
361
380
|
onPress: handleClose,
|
|
362
|
-
style: S.
|
|
381
|
+
style: S.hdrClose,
|
|
363
382
|
accessibilityRole: "button",
|
|
364
|
-
accessibilityLabel:
|
|
383
|
+
accessibilityLabel: closeTxt
|
|
365
384
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
366
|
-
style:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
style:
|
|
372
|
-
},
|
|
373
|
-
style: customSideStyle
|
|
374
|
-
}, deleteNode, closeNode)) : defaultNode;
|
|
375
|
-
const safeAreaNode = safeAreaInsetBottom && /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
376
|
-
edge: "bottom"
|
|
377
|
-
});
|
|
385
|
+
style: closeStyle
|
|
386
|
+
}, closeTxt))) : null;
|
|
387
|
+
const bN = isCustom ? /*#__PURE__*/React.createElement(View, {
|
|
388
|
+
style: cR
|
|
389
|
+
}, cMN, /*#__PURE__*/React.createElement(View, {
|
|
390
|
+
style: cS
|
|
391
|
+
}, delN, closeN)) : dN;
|
|
378
392
|
return {
|
|
379
|
-
headerNode,
|
|
380
|
-
bodyNode,
|
|
381
|
-
safeAreaNode
|
|
393
|
+
headerNode: hN,
|
|
394
|
+
bodyNode: bN,
|
|
395
|
+
safeAreaNode: safeAreaInsetBottom && /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
396
|
+
edge: "bottom"
|
|
397
|
+
})
|
|
382
398
|
};
|
|
383
|
-
}, [handleClose, colors.title,
|
|
399
|
+
}, [handleClose, colors.title, dblH, hasHdr, isCustom, keys, renderKey, closeTxt, safeAreaInsetBottom, sizing.auxFontSize, sizing.fontSize, sizing.titleFontSize, spacing.keyGap, spacing.paddingHorizontal, spacing.titlePadding, typography.fontFamily, title, showDeleteKey]);
|
|
384
400
|
if (!shouldRender && !visible) return null;
|
|
385
401
|
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Animated.View, _extends({}, rest, {
|
|
386
402
|
pointerEvents: visible ? 'auto' : 'none',
|
|
387
403
|
renderToHardwareTextureAndroid: true,
|
|
388
404
|
shouldRasterizeIOS: true,
|
|
389
|
-
onLayout:
|
|
390
|
-
style: [S.
|
|
405
|
+
onLayout: onLayout,
|
|
406
|
+
style: [S.wrap, winShadow, style, {
|
|
391
407
|
transform: [{
|
|
392
408
|
translateY
|
|
393
409
|
}],
|
|
@@ -396,29 +412,29 @@ const NumberKeyboard = /*#__PURE__*/React.memo(props => {
|
|
|
396
412
|
}), memoized.headerNode, memoized.bodyNode, memoized.safeAreaNode));
|
|
397
413
|
});
|
|
398
414
|
const S = StyleSheet.create({
|
|
399
|
-
|
|
415
|
+
wrap: {
|
|
400
416
|
position: 'absolute',
|
|
401
417
|
left: 0,
|
|
402
418
|
right: 0,
|
|
403
419
|
bottom: 0
|
|
404
420
|
},
|
|
405
|
-
|
|
421
|
+
hdr: {
|
|
406
422
|
flexDirection: 'row',
|
|
407
423
|
alignItems: 'center',
|
|
408
424
|
justifyContent: 'flex-end',
|
|
409
425
|
height: 44,
|
|
410
426
|
position: 'relative'
|
|
411
427
|
},
|
|
412
|
-
|
|
428
|
+
tBold: {
|
|
413
429
|
fontWeight: '600'
|
|
414
430
|
},
|
|
415
|
-
|
|
431
|
+
tCenter: {
|
|
416
432
|
position: 'absolute',
|
|
417
433
|
left: 12,
|
|
418
434
|
right: 12,
|
|
419
435
|
textAlign: 'center'
|
|
420
436
|
},
|
|
421
|
-
|
|
437
|
+
hdrClose: {
|
|
422
438
|
minWidth: 56,
|
|
423
439
|
alignItems: 'flex-end'
|
|
424
440
|
},
|
|
@@ -426,23 +442,23 @@ const S = StyleSheet.create({
|
|
|
426
442
|
justifyContent: 'center',
|
|
427
443
|
alignItems: 'center'
|
|
428
444
|
},
|
|
429
|
-
|
|
445
|
+
kTxt: {
|
|
430
446
|
includeFontPadding: false,
|
|
431
447
|
textAlign: 'center'
|
|
432
448
|
},
|
|
433
|
-
|
|
449
|
+
dRow: {
|
|
434
450
|
flexDirection: 'row',
|
|
435
451
|
flexWrap: 'wrap'
|
|
436
452
|
},
|
|
437
|
-
|
|
453
|
+
cRow: {
|
|
438
454
|
flexDirection: 'row'
|
|
439
455
|
},
|
|
440
|
-
|
|
456
|
+
cMat: {
|
|
441
457
|
flex: 3,
|
|
442
458
|
flexDirection: 'row',
|
|
443
459
|
flexWrap: 'wrap'
|
|
444
460
|
},
|
|
445
|
-
|
|
461
|
+
cSide: {
|
|
446
462
|
flex: 1,
|
|
447
463
|
flexDirection: 'column',
|
|
448
464
|
justifyContent: 'flex-start'
|
|
@@ -4,7 +4,8 @@ const createTokens = foundations => {
|
|
|
4
4
|
palette,
|
|
5
5
|
spacing,
|
|
6
6
|
radii,
|
|
7
|
-
fontSize
|
|
7
|
+
fontSize,
|
|
8
|
+
typography
|
|
8
9
|
} = foundations;
|
|
9
10
|
const onPrimary = palette.primary.foreground ?? '#ffffff';
|
|
10
11
|
return {
|
|
@@ -30,8 +31,13 @@ const createTokens = foundations => {
|
|
|
30
31
|
keyHeight: 54,
|
|
31
32
|
closeHeight: 44,
|
|
32
33
|
fontSize: 28,
|
|
34
|
+
defaultIconFontSize: 30,
|
|
35
|
+
auxFontSize: 18,
|
|
33
36
|
titleFontSize: fontSize.md
|
|
34
37
|
},
|
|
38
|
+
typography: {
|
|
39
|
+
fontFamily: typography.fontFamily
|
|
40
|
+
},
|
|
35
41
|
radii: {
|
|
36
42
|
key: radii.xs
|
|
37
43
|
},
|